{"binding":{"chosen_proof_sha256":"1ac71a1335fae03f9ab4015f0cbc3ac0d6dcc2e5c97110e96fdcbcf709f6b896","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"270545cf57b6dc5f952c86776571052d7103990fc8fcf50da12a2013e6b3323a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0bea8797c6d495662c882fbef1ee471c2eff47dfde392f3050e338bb7b68ba59","source_sha256":"041ed7418835f513eaa8645f42a9c7a8b7fd952d76bd23f080a507a71e985240","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by rw [pn.out, Nat.cast_zero, Multiset.range_zero]","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.133333},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"00d5d8c57ec424947fb79772d3b43cc40589af8fcde10cdb9db2417017accee7","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Basic -- shake: keep (Qq dependency)\npublic import Mathlib.Tactic.NormNum.Basic\n\nNamespace:\nMathlib.Meta\n\nLocal context:\n/-\nCopyright (c) 2023 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Floris van Doorn\n-/\n/-!\n# `norm_num` plugin for big operators\n\nThis file adds `norm_num` plugins for `Finset.prod` and `Finset.sum`.\n\nThe driving part of this plugin is `Mathlib.Meta.NormNum.evalFinsetBigop`.\nWe repeatedly use `Finset.proveEmptyOrCons` to try to find a proof that the given set is empty,\nor that it consists of one element inserted into a strict subset, and evaluate the big operator\non that subset until the set is completely exhausted.\n\n## See also\n\n* The `fin_cases` tactic has similar scope: splitting out a finite collection into its elements.\n\n## Porting notes\n\nThis plugin is noticeably less powerful than the equivalent version in Mathlib 3: the design of\n`norm_num` means plugins have to return numerals, rather than a generic expression.\nIn particular, we can't use the plugin on sums containing variables.\n(See also the TODO note \"To support variables\".)\n\n## TODO\n\n* Support intervals: `Finset.Ico`, `Finset.Icc`, ...\n* To support variables, like in Mathlib 3, turn this into a standalone tactic that unfolds\n the sum/prod, without computing its numeric value (using the `ring` tactic to do some\n normalization?)\n-/\n\npublic meta section\n\nnamespace Mathlib.Meta\n\nopen Lean\nopen Meta\nopen Qq\n\nvariable {u v : Level}\n\n/-- This represents the result of trying to determine whether the given expression `n : Q(ℕ)`\nis either `zero` or `succ`. -/\ninductive Nat.UnifyZeroOrSuccResult (n : Q(ℕ))\n /-- `n` unifies with `0` -/\n | zero (pf : $n =Q 0)\n /-- `n` unifies with `succ n'` for this specific `n'` -/\n | succ (n' : Q(ℕ)) (pf : $n =Q Nat.succ $n')\n\n/-- Determine whether the expression `n : Q(ℕ)` unifies with `0` or `Nat.succ n'`.\n\nWe do not use `norm_num` functionality because we want definitional equality,\nnot propositional equality, for use in dependent types.\n\nFails if neither of the options succeed.\n-/\ndef Nat.unifyZeroOrSucc (n : Q(ℕ)) : MetaM (Nat.UnifyZeroOrSuccResult n) := do\n match ← isDefEqQ n q(0) with\n | .defEq pf => return .zero pf\n | .notDefEq => do\n let n' : Q(ℕ) ← mkFreshExprMVar q(ℕ)\n let ⟨(_pf : $n =Q Nat.succ $n')⟩ ← assertDefEqQ n q(Nat.succ $n')\n let (.some (n'_val : Q(ℕ))) ← getExprMVarAssignment? n'.mvarId! |\n throwError \"could not figure out value of `?n` from `{n} =?= Nat.succ ?n`\"\n pure (.succ n'_val ⟨⟩)\n\n/-- This represents the result of trying to determine whether the given expression\n`s : Q(List $α)` is either empty or consists of an element inserted into a strict subset. -/\ninductive List.ProveNilOrConsResult {α : Q(Type u)} (s : Q(List $α))\n /-- The set is Nil. -/\n | nil (pf : Q($s = []))\n /-- The set equals `a` inserted into the strict subset `s'`. -/\n | cons (a : Q($α)) (s' : Q(List $α)) (pf : Q($s = List.cons $a $s'))\n\n/-- If `s` unifies with `t`, convert a result for `s` to a result for `t`.\n\nIf `s` does not unify with `t`, this results in a type-incorrect proof.\n-/\ndef List.ProveNilOrConsResult.uncheckedCast {α : Q(Type u)} {β : Q(Type v)}\n (s : Q(List $α)) (t : Q(List $β)) :\n List.ProveNilOrConsResult s → List.ProveNilOrConsResult t\n | .nil pf => .nil pf\n | .cons a s' pf => .cons a s' pf\n\n/-- If `s = t` and we can get the result for `t`, then we can get the result for `s`.\n-/\ndef List.ProveNilOrConsResult.eq_trans {α : Q(Type u)} {s t : Q(List $α)}\n (eq : Q($s = $t)) :\n List.ProveNilOrConsResult t → List.ProveNilOrConsResult s\n | .nil pf => .nil q(Eq.trans $eq $pf)\n | .cons a s' pf => .cons a s' q(Eq.trans $eq $pf)\n\nlemma List.range_zero' {n : ℕ} (pn : NormNum.IsNat n 0) :\n List.range n = [] := by rw [pn.out, Nat.cast_zero, List.range_zero]\n\nlemma List.range_succ_eq_map' {n nn n' : ℕ} (pn : NormNum.IsNat n nn) (pn' : nn = Nat.succ n') :\n List.range n = 0 :: List.map Nat.succ (List.range n') := by\n rw [pn.out, Nat.cast_id, pn', List.range_succ_eq_map]\n\nset_option linter.unusedVariables false in\n/-- Either show the expression `s : Q(List α)` is Nil, or remove one element from it.\n\nFails if we cannot determine which of the alternatives apply to the expression.\n-/\npartial def List.proveNilOrCons {u : Level} {α : Q(Type u)} (s : Q(List $α)) :\n MetaM (List.ProveNilOrConsResult s) :=\n s.withApp fun e a =>\n match (e, e.constName, a) with\n | (_, ``EmptyCollection.emptyCollection, _) => haveI : $s =Q {} := ⟨⟩; pure (.nil q(.refl []))\n | (_, ``List.nil, _) => haveI : $s =Q [] := ⟨⟩; pure (.nil q(rfl))\n | (_, ``List.cons, #[_, (a : Q($α)), (s' : Q(List $α))]) =>\n haveI : $s =Q $a :: $s' := ⟨⟩; pure (.cons a s' q(rfl))\n | (_, ``List.range, #[(n : Q(ℕ))]) =>\n have s : Q(List ℕ) := s; .uncheckedCast _ _ <$> show MetaM (ProveNilOrConsResult s) from do\n let ⟨nn, pn⟩ ← NormNum.deriveNat n _\n haveI' : $s =Q .range $n := ⟨⟩\n let nnL := nn.natLit!\n if nnL = 0 then\n haveI' : $nn =Q 0 := ⟨⟩\n return .nil q(List.range_zero' $pn)\n else\n have n' : Q(ℕ) := mkRawNatLit (nnL - 1)\n have : $nn =Q .succ $n' := ⟨⟩\n return .cons _ _ q(List.range_succ_eq_map' $pn (.refl $nn))\n | (_, ``List.finRange, #[(n : Q(ℕ))]) =>\n have s : Q(List (Fin $n)) := s\n .uncheckedCast _ _ <$> show MetaM (ProveNilOrConsResult s) from do\n haveI' : $s =Q .finRange $n := ⟨⟩\n return match ← Nat.unifyZeroOrSucc n with -- We want definitional equality on `n`.\n | .zero _pf => .nil q(List.finRange_zero)\n | .succ n' _pf => .cons _ _ q(List.finRange_succ)\n | (.const ``List.map [v, _], _, #[(β : Q(Type v)), _, (f : Q($β → $α)), (xxs : Q(List $β))]) => do\n haveI' : $s =Q ($xxs).map $f := ⟨⟩\n return match ← List.proveNilOrCons xxs with\n | .nil pf => .nil q(($pf ▸ List.map_nil : List.map _ _ = _))\n | .cons x xs pf => .cons q($f $x) q(($xs).map $f)\n q(($pf ▸ List.map_cons : List.map _ _ = _))\n | (_, fn, args) =>\n throwError \"List.proveNilOrCons: unsupported List expression {s} ({fn}, {args})\"\n\n/-- This represents the result of trying to determine whether the given expression\n`s : Q(Multiset $α)` is either empty or consists of an element inserted into a strict subset. -/\ninductive Multiset.ProveZeroOrConsResult {α : Q(Type u)} (s : Q(Multiset $α))\n /-- The set is zero. -/\n | zero (pf : Q($s = 0))\n /-- The set equals `a` inserted into the strict subset `s'`. -/\n | cons (a : Q($α)) (s' : Q(Multiset $α)) (pf : Q($s = Multiset.cons $a $s'))\n\n/-- If `s` unifies with `t`, convert a result for `s` to a result for `t`.\n\nIf `s` does not unify with `t`, this results in a type-incorrect proof.\n-/\ndef Multiset.ProveZeroOrConsResult.uncheckedCast {α : Q(Type u)} {β : Q(Type v)}\n (s : Q(Multiset $α)) (t : Q(Multiset $β)) :\n Multiset.ProveZeroOrConsResult s → Multiset.ProveZeroOrConsResult t\n | .zero pf => .zero pf\n | .cons a s' pf => .cons a s' pf\n\n/-- If `s = t` and we can get the result for `t`, then we can get the result for `s`.\n-/\ndef Multiset.ProveZeroOrConsResult.eq_trans {α : Q(Type u)} {s t : Q(Multiset $α)}\n (eq : Q($s = $t)) :\n Multiset.ProveZeroOrConsResult t → Multiset.ProveZeroOrConsResult s\n | .zero pf => .zero q(Eq.trans $eq $pf)\n | .cons a s' pf => .cons a s' q(Eq.trans $eq $pf)\n\nlemma Multiset.insert_eq_cons {α : Type*} (a : α) (s : Multiset α) :\n insert a s = Multiset.cons a s :=\n rfl\n\nTarget:\nlemma Multiset.range_zero' {n : ℕ} (pn : NormNum.IsNat n 0) :\n Multiset.range n = 0 :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_0bea8797c6d4","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"639361f90ed89627713f8aced904bb7f5a29f51fb577108de181366ce3c5b31f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/NormNum","family_id":"multiset","file_id":"mathlib/Mathlib/Tactic/NormNum/BigOperators.lean","sample_id":"0bea8797c6d495662c882fbef1ee471c2eff47dfde392f3050e338bb7b68ba59"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"18fa08cf6d80a8f5b43d1036f03329daf7943e5bd6d50fe11af9e19a0e41aa25","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7c33e64161ab0864bd6d70719c5e75272141a5097b243cdfc0a79459dd0943c9","source_sha256":"864bb4bb18dcd59ea0d99974e94e6f80f27ed7f81365f8520c597842fa036700","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [ker_comp, ker_mk'_eq]\n\n/-- Makes an isomorphism of quotients by two ring congruence\nrelations, given that the relations are equal. -/\nprotected def congr (h : c = d) :\n c.Quotient ≃+* d.Quotient :=\n { Quotient.congr (Equiv.refl M) <| by apply RingCon.ext_iff.mp h with\n map_add' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl\n map_mul' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl }","hard_negative":false,"metrics":{"chosen_tokens":109,"rejected_tokens":3,"token_jaccard":0.016129,"token_length_ratio":0.027523},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"00eb537feabee4b2288493cce28942654e301d7a25913d4dbf02a40a4983676c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Subalgebra.Lattice\npublic import Mathlib.Algebra.Algebra.Subalgebra.Basic\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.RingTheory.Congruence.Basic\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.Algebra.Ring.Subring.Basic\npublic import Mathlib.Algebra.RingQuot\n\nNamespace:\nRingCon\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Congruence relations and ring homomorphisms\n\nThis file contains elementary definitions involving congruence\nrelations and morphisms for rings and semirings\n\n## Main definitions\n\n* `RingCon.ker`: the kernel of a monoid homomorphism as a congruence relation\n* `RingCon.lift`, `RingCon.liftₐ`: the homomorphism / the algebra morphism\n on the quotient given that the congruence is in the kernel\n* `RingCon.map`, `RingCon.mapₐ`: homomorphism / algebra morphism\n from a smaller to a larger quotient\n\n* `RingCon.quotientKerEquivRangeS`, `RingCon.quotientKerEquivRange`,\n `RingCon.quotientKerEquivRangeₐ` :\n the first isomorphism theorem for semirings (using `RingHom.rangeS`),\n rings (using `RingHom.range`) and algebras (using `AlgHom.range`).\n* `RingCon.comapQuotientEquivRangeS`, `RingCon.comapQuotientEquivRange`,\n `RingCon.comapQuotientEquivRangeₐ` : the second isomorphism theorem\n for semirings (using `RingHom.rangeS`), rings (using `RingHom.range`)\n and algebras (using `AlgHom.range`).\n\n* `RingCon.quotientQuotientEquivQuotient`, `RingCon.quotientQuotientEquivQuotientₐ` :\n the third isomorphism theorem for semirings (or rings) and algebras\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, ring,\nquotient ring\n-/\n\n@[expose] public section\n\nvariable {M : Type*} {N : Type*} {P : Type*}\n\nopen Function Setoid\n\nnamespace RingCon\n\nsection\n\nvariable [NonAssocSemiring M] [NonAssocSemiring N] [NonAssocSemiring P] {c d : RingCon M}\n\n/-- The kernel of a ring homomorphism as a ring congruence relation. -/\ndef ker (f : M →+* N) : RingCon M := comap ⊥ f\n\ntheorem comap_bot (f : M →+* N) : comap ⊥ f = ker f := rfl\n\n/-- The definition of the ring congruence relation defined by a ring homomorphism's kernel. -/\n@[simp]\ntheorem ker_apply (f : M →+* N) {x y} : ker f x y ↔ f x = f y :=\n Iff.rfl\n\n/-- The kernel of the quotient map induced by a ring congruence relation `c` equals `c`. -/\ntheorem ker_mk'_eq (c : RingCon M) : ker c.mk' = c :=\n ext fun _ _ => Quotient.eq''\n\ntheorem ker_comp {f : M →+* N} {g : N →+* P} :\n ker (g.comp f) = (ker g).comap f :=\n ext fun x y ↦ by simp [ker_apply, comap_rel]\n\nTarget:\ntheorem comap_eq {g : N →+* M} :\n c.comap g = ker (c.mk'.comp g) :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Congruence","family_id":"comap_eq","file_id":"mathlib/Mathlib/RingTheory/Congruence/Hom.lean","sample_id":"7c33e64161ab0864bd6d70719c5e75272141a5097b243cdfc0a79459dd0943c9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b2aca3b4f39f802af0731bbfab213936c8527e00bde887ca09c9bb79f9d8e3ac","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5517a4dbd67677c4883e38ab697621a61d29f071e9329f6548fc7ae999e28ada","source_sha256":"ea49da8fadbef6df5542f48b737813b13b1fd6e8a00c791df91871e459b5fa18","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext y; simp [cylinder, Set.pi]","hard_negative":true,"metrics":{"chosen_tokens":12,"rejected_tokens":8,"token_jaccard":0.055556,"token_length_ratio":0.666667},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"0103e919bd6a8bb28485ad75277ab214d80f0201f67736a8bbe658552684ed24","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Separation.Basic\n\nNamespace:\nSymbolicDynamics.FullShift\n\nLocal context:\n/-\nCopyright (c) 2025 Silvère Gangloff. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Silvère Gangloff\n-/\n/-!\n# Symbolic dynamics on cancellative monoids\n\nThis file develops a minimal API for symbolic dynamics over a\n**left-cancellative monoid** `G`—formally, a structure carrying `[Monoid G]`\nand `[IsLeftCancelMul G]` (which becomes `[AddMonoid G]` and\n`[IsLeftCancelAdd G]` in the additive form). Throughout the documentation we use the\n**additive** notations, which are the most common in symbolic dynamics, although\nall the notions introduced are defined in the multiplicative notations and adapted\nto the additive notation.\n\nGiven a finite alphabet `A`, the ambient configuration space is the set of\nfunctions `G → A`, endowed with the product topology. We define the\nleft-translation action, cylinders, finite patterns, their occurrences,\nforbidden sets, and subshifts (closed, shift-invariant subsets). Basic\ntopological facts (e.g. cylinders are clopen, occurrence sets are clopen,\nforbidden sets are closed) are proved under discreteness assumptions on\nthe alphabet.\n\nThe development is generic for left-cancellative monoids. This covers both\ngroups (the standard setting of symbolic dynamics) and more general monoids\nwhere cancellation holds but inverses may not exist. Geometry specific to\n`ℤ^d` (boxes/cubes and the box-based entropy) is deferred to a separate\nspecialization.\n\n## Why cancellativity?\n\nSome constructions, such as translating a finite pattern to occur at a point `v`,\nrequire solving equations of the form `w + v = h`. For this to have a unique\nsolution `w` given `h` and `v`, we assume **left-cancellation**:\nif `v + a = v + b` then `a = b`. This allows us to define\n`Pattern.shift` (which shifts a pattern) without using inverses,\nso that the theory works not only for groups but also for cancellative monoids.\n\n## Main definitions\n\n* `shift g x` — left translation: in additive notation `(shift v x) u = x (v + u)` (using the\n**left** action of `G` on configurations).\n* `cylinder U x` — configurations agreeing with `x` on a finite set `U ⊆ G`.\n* `Pattern A G` — a configuration which takes\ndefault value outside of a finite support, together with this support.\n* `Pattern.occursInAt p x g` — occurrence of `p` in `x` at translate `g`.\n* `forbidden F` — configurations avoiding every pattern in `F`.\n* `Subshift A G` — closed, shift-invariant subsets of the full shift.\n* `MulSubshift.ofForbidden F` — the subshift defined by forbidding a family of patterns.\n* `subshift_of_finite_type F` — a subshift of finite type defined by a finite set of\nforbidden patterns.\n* `languageOn X U` — the set of patterns of shape `U` obtained by restricting some `x ∈ X`.\n\n## Design choice: ambient vs. inner (subshift-relative) viewpoint\n\nAll core notions (shift, cylinder, occurrence, language, …) are defined **in the\nambient full shift** `G → A`. A subshift is then a closed, invariant subset,\nbundled as `Subshift A G`. Working inside a subshift is done by restriction.\n\n**Motivation.**\n\nIf cylinders and shifts were defined only *inside* a subshift, local ergonomics\nwould improve but global operations would become awkward. For instance, to prove\nthat for finite shape `U`:\n\n`languageOn (X ∪ Y) U = languageOn X U ∪ languageOn Y U,`\n\none must eventually move both sides to the ambient pattern type. Similar issues\narise for intersections, factors, and products. By contrast, with ambient\ndefinitions these set-theoretic identities are tautological.\nThus the file develops the theory ambiently, and subshifts reuse it by restriction.\n\n**Working inside a subshift.**\n\nFor `Y : Subshift A G`, cylinders and occurrence sets *inside `Y`* are simply\npreimages of the ambient ones under the inclusion `Y → (G → A)`. For example:\n\n`{ y : Y | ∀ i ∈ U, (y : G → A) i = (x : G → A) i } = (Subtype.val) ⁻¹' (cylinder U (x : G → A)).`\n\nShift invariance guarantees that the ambient shift restricts to `Y`.\n\n**Ergonomics.**\n\nThin wrappers (e.g. `Subshift.shift`, `Subshift.cylinder`, `Subshift.languageOn`)\nmay be added for convenience. They introduce no new theory and unfold to the\nambient definitions.\n\n## Namespacing policy\n\nAll ambient definitions live under the namespace `SymbolicDynamics.FullShift`.\nIf inner, subshift-relative wrappers are provided, they will be placed in the\nsubnamespace `SymbolicDynamics.Subshift`. This separation avoids name clashes\nbetween the two viewpoints, since both may naturally want to reuse names like\n`cylinder`, `shift`, `occursAt`, or `languageOn`.\n\n## Implementation notes\n\n* Openness results for cylinders and occurrence sets use\n `[DiscreteTopology A]`. Closeness results use `[T1Space A]`.\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Set Topology\n\nnamespace SymbolicDynamics\n\nnamespace FullShift\n\n/-! ## Full shift and shift action -/\n\nsection ShiftDefinition\n\nvariable {A G : Type*} [Monoid G]\n\n/-- The **left-translation shift** on configurations.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the monoid, the shifted configuration\n`mulShift g x` is defined by `(mulShift g x) h = x (g * h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g * h` in the original one.\n\nFor example, if `G = ℤ` (with addition) and `A = {0, 1}`, then\n`mulShift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/\n@[to_additive /-- The **left-translation shift** on configurations, in additive notation.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the additive monoid,\nthe shifted configuration `shift g x` is defined by `(shift g x) h = x (g + h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g + h` in the original one.\n\nFor example, if `G = ℤ` and `A = {0, 1}`, then\n`shift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/]\ndef mulShift (g : G) (x : G → A) : G → A :=\n fun h => x (g * h)\n\n@[to_additive (attr := simp)] lemma mulShift_apply (g : G) (x : G → A) (h : G) :\n mulShift g x h = x (g * h) := rfl\n\n@[to_additive (attr := simp)] lemma mulShift_one (x : G → A) : mulShift (1 : G) x = x := by\n ext h; simp [mulShift]\n\n/-- Composition of left-translation shifts corresponds to multiplication in the monoid `G`. -/\n@[to_additive] lemma mulShift_mul (g₁ g₂ : G) (x : G → A) :\n mulShift (g₁ * g₂) x = mulShift g₂ (mulShift g₁ x) := by\n ext h; simp [mulShift, mul_assoc]\n\nvariable [TopologicalSpace A]\n\n/-- The left-translation shift is continuous. -/\n@[to_additive (attr := fun_prop)] lemma continuous_mulShift (g : G) :\n Continuous (mulShift (A := A) g) := by\n -- coordinate projections are continuous; composition preserves continuity\n unfold mulShift\n fun_prop\n\nend ShiftDefinition\n\n/-! ## Cylinders -/\n\nsection Cylinders\n\nvariable {A G : Type*}\n\n/-- A *cylinder set* is the set of all configurations that agree with a given\nreference configuration `x` on a fixed finite subset `U` of the index set `G`.\n\nThe set `U` is called the *support* of the cylinder.\n\nIntuitively, cylinders specify the \"letters\" on finitely many coordinates, while\nleaving all other coordinates free. For example, in the full shift `{0, 1}^ℤ`,\nthe cylinder determined by `U = {0, 1}` and `x 0 = 1, x 1 = 0` consists of all\nbi-infinite sequences of `0`s and `1`s whose entries on positions `0` and `1`\nrespectively are `1` and `0`.\n\nWhen `A` has the discrete topology, cylinder sets form a basis of clopen sets\nfor the product topology on `G → A`. -/\ndef cylinder (U : Finset G) (x : G → A) : Set (G → A) :=\n { y | ∀ i ∈ U, y i = x i }\n\n/-- A cylinder set on `U` is the `Set.pi` over `U` of the singletons `{x i}`,\nviewed as a subset of `G → A`. Equivalently, it is the preimage of that product\nof singletons in `U → A` under the restriction map `(G → A) → (U → A)`. -/\n\nTarget:\nlemma cylinder_eq_set_pi (U : Finset G) (x : G → A) :\n cylinder U x = Set.pi (↑U : Set G) (fun i => ({x i} : Set A)) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"f4fe06e6c461cfcdcf710a01c94853c9dfa2dbad386636ac60c9b3320b9b0bc1","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/SymbolicDynamics","family_id":"cylinder_eq_set_pi","file_id":"mathlib/Mathlib/Dynamics/SymbolicDynamics/Basic.lean","sample_id":"5517a4dbd67677c4883e38ab697621a61d29f071e9329f6548fc7ae999e28ada"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1bc65818fb02e7713e68737362a7b391023f8ba3f1dc7e6b575b0f2fd0af5940","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f36cc1c4b748204b23ca7078b7df1beabf793b6845620b48ed96d0dafd011748","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dd284ce40872189e36817d75ed4ce2dd3378a4fab7a93f26cda064c455bcada2","source_sha256":"976709af1494098e2290d3c3a6a052dad499a43ec44c3bd6016d3ce147bb9165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using map_add_const f 0","hard_negative":false,"metrics":{"chosen_tokens":6,"rejected_tokens":10,"token_jaccard":0.6,"token_length_ratio":1.666667},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"010d840e8c658994f2f847b1b631ed2ace4f6798cf503487769f6d10f3d6e4e3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Algebra.Module.NatInt\npublic import Mathlib.Algebra.Order.Archimedean.Basic\nimport Mathlib.Algebra.Order.Group.Basic\n\nNamespace:\nAddConstMapClass\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Maps (semi)conjugating a shift to a shift\n\nDenote by $S^1$ the unit circle `UnitAddCircle`.\nA common way to study a self-map $f\\colon S^1\\to S^1$ of degree `1`\nis to lift it to a map $\\tilde f\\colon \\mathbb R\\to \\mathbb R$\nsuch that $\\tilde f(x + 1) = \\tilde f(x)+1$ for all `x`.\n\nIn this file we define a structure and a typeclass\nfor bundled maps satisfying `f (x + a) = f x + b`.\n\nWe use parameters `a` and `b` instead of `1` to accommodate for two use cases:\n\n- maps between circles of different lengths;\n- self-maps $f\\colon S^1\\to S^1$ of degree other than one,\n including orientation-reversing maps.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nopen Function Set\n\n/-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`,\ndenoted as `f : G →+c[a, b] H`.\n\nOne can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/\nstructure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where\n /-- The underlying function of an `AddConstMap`.\n Use automatic coercion to function instead. -/\n protected toFun : G → H\n /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/\n map_add_const' (x : G) : toFun (x + a) = toFun x + b\n\n@[inherit_doc]\nscoped[AddConstMap] notation:25 G \" →+c[\" a \", \" b \"] \" H => AddConstMap G H a b\n\n/-- Typeclass for maps satisfying `f (x + a) = f x + b`.\n\nNote that `a` and `b` are `outParam`s,\nso one should not add instances like\n`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/\nclass AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]\n (a : outParam G) (b : outParam H) [FunLike F G H] : Prop where\n /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:\n `∀ x, f (x + a) = f x + b`. -/\n map_add_const (f : F) (x : G) : f (x + a) = f x + b\n\nnamespace AddConstMapClass\n\n/-!\n### Properties of `AddConstMapClass` maps\n\nIn this section we prove properties like `f (x + n • a) = f x + n • b`.\n-/\n\nscoped[AddConstMapClass] attribute [simp] map_add_const\n\nvariable {F G H : Type*} [FunLike F G H] {a : G} {b : H}\n\nprotected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n Semiconj f (· + a) (· + b) :=\n map_add_const f\n\n@[scoped simp]\ntheorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by\n simpa using (AddConstMapClass.semiconj f).iterate_right n x\n\n@[scoped simp]\ntheorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul]\n\ntheorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x\n\n@[scoped simp]\ntheorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + (ofNat(n) : ℕ) • b :=\n map_add_nat' f x n\n\ntheorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp\n\ntheorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n\n\n@[scoped simp]\n\nTarget:\ntheorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n f a = f 0 + b :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n simpa using map_add_const f 0","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/AddConstMap","family_id":"map_const","file_id":"mathlib/Mathlib/Algebra/AddConstMap/Basic.lean","sample_id":"dd284ce40872189e36817d75ed4ce2dd3378a4fab7a93f26cda064c455bcada2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5cf6a0d2e46e048d4d7e1c25b5e089b1205c69d56f8cec82499e91c9d0843d6d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a35b825e3e67bb8b4d1424a4359b820bbf3da0b149808ca58cbb9519deff8d2d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"80128840662b22e53d1840a39802444548ca6c793df4148c58e604fe82cb2d91","source_sha256":"2c2718794f6ab5e1e4b2caadae5fbbfa623398ededcc8a106c24929950ce1748","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Algebra.smul_def, mul_smul]\n rfl","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":17,"token_jaccard":0.833333,"token_length_ratio":1.7},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"015248920170b8e9d6e5fb246542c911c2431fbf270526bf49e2f2cade1a6ef9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Tower\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# The `RestrictScalars` type alias\n\nSee the documentation attached to the `RestrictScalars` definition for advice on how and when to\nuse this type alias. As described there, it is often a better choice to use the `IsScalarTower`\ntypeclass instead.\n\n## Main definitions\n\n* `RestrictScalars R S M`: the `S`-module `M` viewed as an `R` module when `S` is an `R`-algebra.\n Note that by default we do *not* have a `Module S (RestrictScalars R S M)` instance\n for the original action.\n This is available as a def `RestrictScalars.moduleOrig` if really needed.\n* `RestrictScalars.addEquiv : RestrictScalars R S M ≃+ M`: the additive equivalence\n between the restricted and original space (in fact, they are definitionally equal,\n but sometimes it is helpful to avoid using this fact, to keep instances from leaking).\n* `RestrictScalars.ringEquiv : RestrictScalars R S A ≃+* A`: the ring equivalence\n between the restricted and original space when the module is an algebra.\n* `Module.restrictScalars R S M`, `Algebra.restrictScalars R S A`: non-instance definitions for\n `Module R M` and `Algebra R A`.\n\n## See also\n\nThere are many similarly-named definitions elsewhere which do not refer to this type alias. These\nrefer to restricting the scalar type in a bundled type, such as from `A →ₗ[R] B` to `A →ₗ[S] B`:\n\n* `LinearMap.restrictScalars`\n* `LinearEquiv.restrictScalars`\n* `AlgHom.restrictScalars`\n* `AlgEquiv.restrictScalars`\n* `Submodule.restrictScalars`\n* `Subalgebra.restrictScalars`\n-/\n\n@[expose] public section\n\n\nvariable (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 `RestrictScalars` 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\nvariable (R S M : Type*)\nvariable [CommSemiring R] [Semiring S] [Algebra R S] [AddCommMonoid 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`RestrictScalars` permits it to be written as:\n```lean\n-- an `R`-module structure on `M` is provided by `RestrictScalars` which is compatible\nexample : RestrictScalars R S M →ₗ[R] S := sorry\n```\nHowever, it is usually better just to add this extra structure as an argument:\n```lean\n-- an `R`-module structure on `M` and proof of its compatibility is provided by the user\nexample [Module R M] [IsScalarTower R S M] : M →ₗ[R] S := sorry\n```\nThe advantage of the second approach is that it defers the duty of providing the missing typeclasses\n`[Module R M] [IsScalarTower R S M]`. If some concrete `M` naturally carries these (as is often\nthe case) then we have avoided `RestrictScalars` entirely. If not, we can pass\n`RestrictScalars 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`IsScalarTower` rather than `RestrictScalars`.\n\nAn example of when one might want to use `RestrictScalars` would be if one has a vector space\nover a field of characteristic zero and wishes to make use of the `ℚ`-algebra structure. -/\n@[nolint unusedArguments]\ndef RestrictScalars (_R _S M : Type*) : Type _ := M\n\ninstance [I : Inhabited M] : Inhabited (RestrictScalars R S M) := I\n\ninstance [I : AddCommMonoid M] : AddCommMonoid (RestrictScalars R S M) := I\n\ninstance [I : AddCommGroup M] : AddCommGroup (RestrictScalars R S M) := I\n\nsection Module\n\nsection\n\nvariable [Semiring S] [AddCommMonoid M]\n\n/-- We temporarily install an action of the original ring on `RestrictScalars R S M`. -/\n@[instance_reducible]\ndef RestrictScalars.moduleOrig [I : Module S M] : Module S (RestrictScalars R S M) := I\n\nvariable [CommSemiring R] [Algebra R S]\n\nsection\n\nattribute [local instance] RestrictScalars.moduleOrig\n\n/-- When `M` is a module over a ring `S`, and `S` is an algebra over `R`, then `M` inherits a\nmodule structure over `R`. Not an instance because `S` cannot be inferred.\n\nThe preferred way of setting this up is `[Module R M] [Module S M] [IsScalarTower R S M]`.\n-/\nabbrev Module.restrictScalars [Module S M] : Module R M :=\n Module.compHom M (algebraMap R S)\n\n/-- When `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] [IsScalarTower R S M]`.\n-/\ninstance RestrictScalars.module [Module S M] : Module R (RestrictScalars R S M) :=\n Module.restrictScalars R S M\n\n/-- `Module.restrictScalars` forms a scalar tower. -/\ntheorem IsScalarTower.restrictScalars [Module S M] :\n letI := Module.restrictScalars R S M\n IsScalarTower R S M :=\n IsScalarTower.of_compHom R S M\n\n/-- This instance is only relevant when `RestrictScalars.moduleOrig` is available as an instance.\n-/\ninstance RestrictScalars.isScalarTower [Module S M] : IsScalarTower R S (RestrictScalars R S M) :=\n IsScalarTower.restrictScalars R S M\n\nend\n\n/-- When `M` is a right-module over a ring `S`, and `S` is an algebra over `R`, then `M` inherits a\nright-module structure over `R`.\nThe preferred way of setting this up is\n`[Module Rᵐᵒᵖ M] [Module Sᵐᵒᵖ M] [IsScalarTower Rᵐᵒᵖ Sᵐᵒᵖ M]`.\n-/\ninstance RestrictScalars.opModule [Module Sᵐᵒᵖ M] : Module Rᵐᵒᵖ (RestrictScalars R S M) :=\n letI : Module Sᵐᵒᵖ (RestrictScalars R S M) := ‹Module Sᵐᵒᵖ M›\n Module.compHom M (RingHom.op <| algebraMap R S)\n\ninstance RestrictScalars.isCentralScalar [Module S M] [Module Sᵐᵒᵖ M] [IsCentralScalar S M] :\n IsCentralScalar R (RestrictScalars R S M) where\n op_smul_eq_smul r _x := (op_smul_eq_smul (algebraMap R S r) (_ : M) :)\n\n/-- The `R`-algebra homomorphism from the original coefficient algebra `S` to endomorphisms\nof `RestrictScalars R S M`.\n-/\ndef RestrictScalars.lsmul [Module S M] : S →ₐ[R] Module.End R (RestrictScalars R S M) :=\n -- We use `RestrictScalars.moduleOrig` in the implementation,\n -- but not in the type.\n letI : Module S (RestrictScalars R S M) := RestrictScalars.moduleOrig R S M\n Algebra.lsmul R R (RestrictScalars R S M)\n\nend\n\nvariable [AddCommMonoid M]\n\n/-- `RestrictScalars.addEquiv` is the additive equivalence with the original module. -/\ndef RestrictScalars.addEquiv : RestrictScalars R S M ≃+ M :=\n AddEquiv.refl M\n\nvariable [CommSemiring R] [Semiring S] [Algebra R S] [Module S M]\n\ntheorem RestrictScalars.smul_def (c : R) (x : RestrictScalars R S M) :\n c • x = (RestrictScalars.addEquiv R S M).symm\n (algebraMap R S c • RestrictScalars.addEquiv R S M x) :=\n rfl\n\n@[simp]\ntheorem RestrictScalars.addEquiv_map_smul (c : R) (x : RestrictScalars R S M) :\n RestrictScalars.addEquiv R S M (c • x) = algebraMap R S c • RestrictScalars.addEquiv R S M x :=\n rfl\n\ntheorem RestrictScalars.addEquiv_symm_map_algebraMap_smul (r : R) (x : M) :\n (RestrictScalars.addEquiv R S M).symm (algebraMap R S r • x) =\n r • (RestrictScalars.addEquiv R S M).symm x :=\n rfl\n\nTarget:\ntheorem RestrictScalars.addEquiv_symm_map_smul_smul (r : R) (s : S) (x : M) :\n (RestrictScalars.addEquiv R S M).symm ((r • s) • x) =\n r • (RestrictScalars.addEquiv R S M).symm (s • x) :=\n\nProof body:\n","rejected":"```lean\nby\n rw [Algebra.smul_def, mul_smul]\n rfl\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"restrictscalars","file_id":"mathlib/Mathlib/Algebra/Algebra/RestrictScalars.lean","sample_id":"80128840662b22e53d1840a39802444548ca6c793df4148c58e604fe82cb2d91"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f8a398c775cdfbad2e386f235b1aa221b80f09e334a924b4c948d46c7f364040","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e9647d473593fd3612d2aa65b14ab5cfc70a1a164c8dac33a2d2aa3ac8342714","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a93c8deaf18a57ea7eb188ad78df710464dffeb90776aa1626fc3d22ea26ee2e","source_sha256":"8fa72a43e680b83403f64aed4f242d29897ff5dbd1caf9a8138cd5ff2f09e69b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mul_iInf]\n exact le_ciInf H","hard_negative":true,"metrics":{"chosen_tokens":8,"rejected_tokens":3,"token_jaccard":0.222222,"token_length_ratio":0.375},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"019328555249bd12223d9f455b1deb1797b499ce71742aaf76d3fbb393cca3a8","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.Order.BigOperators.Group.Finset\npublic import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset\npublic import Mathlib.Algebra.Order.Field.Canonical\npublic import Mathlib.Algebra.Order.Nonneg.Floor\npublic import Mathlib.Data.Real.Pointwise\npublic import Mathlib.Data.NNReal.Defs\npublic import Mathlib.Order.ConditionallyCompleteLattice.Group\npublic import Mathlib.Order.Lattice.Nat\n\nNamespace:\nNNReal\n\nLocal context:\n/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Basic results on nonnegative real numbers\n\nThis file contains all results on `NNReal` that do not directly follow from its basic structure.\nAs a consequence, it is a bit of a random collection of results, and is a good target for cleanup.\n\n## Notation\n\nThis file uses `ℝ≥0` as a localized notation for `NNReal`.\n-/\n\npublic section\n\nassert_not_exists TrivialStar\n\nopen Function Set\nopen scoped BigOperators\n\nnamespace NNReal\nvariable {M : Type*} [Zero M]\n\nnoncomputable instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)\n\n@[simp, norm_cast]\ntheorem coe_mulIndicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.mulIndicator f a : ℝ≥0) : ℝ) = s.mulIndicator (fun x => ↑(f x)) a :=\n map_mulIndicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_indicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.indicator f a : ℝ≥0) : ℝ) = s.indicator (fun x => ↑(f x)) a :=\n map_indicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_mulSingle {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.mulSingle a b : α → ℝ≥0) c : ℝ) = (Pi.mulSingle a b : α → ℝ) c := by\n simpa using coe_mulIndicator {a} (fun _ ↦ b) c\n\n@[simp, norm_cast]\ntheorem coe_single {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.single a b : α → ℝ≥0) c : ℝ) = (Pi.single a b : α → ℝ) c := by\n simpa using coe_indicator {a} (fun _ ↦ b) c\n\n@[norm_cast]\ntheorem coe_list_sum (l : List ℝ≥0) : ((l.sum : ℝ≥0) : ℝ) = (l.map (↑)).sum :=\n map_list_sum toRealHom l\n\n@[norm_cast]\ntheorem coe_list_prod (l : List ℝ≥0) : ((l.prod : ℝ≥0) : ℝ) = (l.map (↑)).prod :=\n map_list_prod toRealHom l\n\n@[norm_cast]\ntheorem coe_multiset_sum (s : Multiset ℝ≥0) : ((s.sum : ℝ≥0) : ℝ) = (s.map (↑)).sum :=\n map_multiset_sum toRealHom s\n\n@[norm_cast]\ntheorem coe_multiset_prod (s : Multiset ℝ≥0) : ((s.prod : ℝ≥0) : ℝ) = (s.map (↑)).prod :=\n map_multiset_prod toRealHom s\n\nvariable {ι : Type*} {s : Finset ι} {f : ι → ℝ}\n\n@[simp, norm_cast]\ntheorem coe_sum (s : Finset ι) (f : ι → ℝ≥0) : ∑ i ∈ s, f i = ∑ i ∈ s, (f i : ℝ) :=\n map_sum toRealHom _ _\n\n@[simp, norm_cast]\nlemma toReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.sum g = f.sum (fun i m ↦ toReal (g i m)) := map_finsuppSum toRealHom ..\n\n@[simp, norm_cast]\nlemma toReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.prod g = f.prod (fun i m ↦ toReal (g i m)) := map_finsuppProd toRealHom ..\n\n@[simp, norm_cast]\nlemma coe_expect (s : Finset ι) (f : ι → ℝ≥0) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : ℝ) :=\n map_expect toRealHom ..\n\ntheorem _root_.Real.toNNReal_sum_of_nonneg (hf : ∀ i ∈ s, 0 ≤ f i) :\n Real.toNNReal (∑ a ∈ s, f a) = ∑ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)]\n exact Finset.sum_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\n@[simp, norm_cast]\ntheorem coe_prod (s : Finset ι) (f : ι → ℝ≥0) : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ) :=\n map_prod toRealHom _ _\n\ntheorem _root_.Real.toNNReal_prod_of_nonneg (hf : ∀ a, a ∈ s → 0 ≤ f a) :\n Real.toNNReal (∏ a ∈ s, f a) = ∏ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]\n exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\ntheorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}\n {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j := by\n rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]\n exact le_ciInf_add_ciInf h\n\ntheorem mul_finset_sup {α} (r : ℝ≥0) (s : Finset α) (f : α → ℝ≥0) :\n r * s.sup f = s.sup fun a => r * f a :=\n Finset.apply_sup_eq_sup_comp _ (NNReal.mul_sup r) (mul_zero r)\n\ntheorem finset_sup_mul {α} (s : Finset α) (f : α → ℝ≥0) (r : ℝ≥0) :\n s.sup f * r = s.sup fun a => f a * r :=\n Finset.apply_sup_eq_sup_comp (· * r) (fun x y => NNReal.sup_mul x y r) (zero_mul r)\n\ntheorem finset_sup_div {α} {f : α → ℝ≥0} {s : Finset α} (r : ℝ≥0) :\n s.sup f / r = s.sup fun a => f a / r := by simp only [div_eq_inv_mul, mul_finset_sup]\n\nsection Set\n\n@[simp] lemma bddAbove_natCast_image_iff {s : Set ℕ} : BddAbove ((↑) '' s : Set ℝ≥0) ↔ BddAbove s :=\n ⟨.imp' Nat.floor (by simp [upperBounds, Nat.le_floor_iff]), .imp' (↑) (by simp [upperBounds])⟩\n\n@[simp, norm_cast] lemma bddAbove_range_natCast_iff {ι : Sort*} (f : ι → ℕ) :\n BddAbove (Set.range (f ·) : Set NNReal) ↔ BddAbove (Set.range f) := by\n rw [← bddAbove_natCast_image_iff, ← Set.range_comp]\n rfl\n\nend Set\n\nopen Real\n\nsection Sub\n\n/-!\n### Lemmas about subtraction\n\nIn this section we provide a few lemmas about subtraction that do not fit well into any other\ntypeclass. For lemmas about subtraction and addition see lemmas about `OrderedSub` in the file\n`Mathlib/Algebra/Order/Sub/Basic.lean`. See also `mul_tsub` and `tsub_mul`.\n-/\n\ntheorem sub_div (a b c : ℝ≥0) : (a - b) / c = a / c - b / c :=\n tsub_div _ _ _\n\n/-- This lemma is needed for the `norm_cast` simp set. Outside of this use case `Nat.coe_sub`\nshould be used. -/\n@[norm_cast]\nprotected theorem coe_sub_of_lt {a b : ℝ≥0} (h : a < b) :\n ((b - a : ℝ≥0) : ℝ) = b - a := NNReal.coe_sub h.le\n\nend Sub\n\nsection Csupr\n\nopen Set\n\nvariable {ι : Sort*} {f : ι → ℝ≥0}\n\ntheorem iInf_mul (f : ι → ℝ≥0) (a : ℝ≥0) : iInf f * a = ⨅ i, f i * a := by\n rw [← coe_inj, NNReal.coe_mul, coe_iInf, coe_iInf]\n exact Real.iInf_mul_of_nonneg (NNReal.coe_nonneg _) _\n\ntheorem mul_iInf (f : ι → ℝ≥0) (a : ℝ≥0) : a * iInf f = ⨅ i, a * f i := by\n simpa only [mul_comm] using iInf_mul f a\n\ntheorem mul_iSup (f : ι → ℝ≥0) (a : ℝ≥0) : (a * ⨆ i, f i) = ⨆ i, a * f i := by\n rw [← coe_inj, NNReal.coe_mul, NNReal.coe_iSup, NNReal.coe_iSup]\n exact Real.mul_iSup_of_nonneg (NNReal.coe_nonneg _) _\n\ntheorem iSup_mul (f : ι → ℝ≥0) (a : ℝ≥0) : (⨆ i, f i) * a = ⨆ i, f i * a := by\n rw [mul_comm, mul_iSup]\n simp_rw [mul_comm]\n\ntheorem iSup_div (f : ι → ℝ≥0) (a : ℝ≥0) : (⨆ i, f i) / a = ⨆ i, f i / a := by\n simp only [div_eq_mul_inv, iSup_mul]\n\ntheorem mul_iSup_le {a : ℝ≥0} {g : ℝ≥0} {h : ι → ℝ≥0} (H : ∀ j, g * h j ≤ a) : g * iSup h ≤ a := by\n rw [mul_iSup]\n exact ciSup_le' H\n\ntheorem iSup_mul_le {a : ℝ≥0} {g : ι → ℝ≥0} {h : ℝ≥0} (H : ∀ i, g i * h ≤ a) : iSup g * h ≤ a := by\n rw [iSup_mul]\n exact ciSup_le' H\n\ntheorem iSup_mul_iSup_le {a : ℝ≥0} {g h : ι → ℝ≥0} (H : ∀ i j, g i * h j ≤ a) :\n iSup g * iSup h ≤ a :=\n iSup_mul_le fun _ => mul_iSup_le <| H _\n\nvariable [Nonempty ι]\n\nTarget:\ntheorem le_mul_iInf {a : ℝ≥0} {g : ℝ≥0} {h : ι → ℝ≥0} (H : ∀ j, a ≤ g * h j) : a ≤ g * iInf h :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_a93c8deaf18a","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"32c04cd83e2796fb9e706d2c91c364a73135aadb4fb4f8402ac6d6417f4f705b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/NNReal","family_id":"le_mul_iinf","file_id":"mathlib/Mathlib/Data/NNReal/Basic.lean","sample_id":"a93c8deaf18a57ea7eb188ad78df710464dffeb90776aa1626fc3d22ea26ee2e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8fba53f509cbcaa7077e1b9aaefbeecf912a8e10535c22fd02c1ba65487eb495","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":false,"metrics":{"chosen_tokens":2,"rejected_tokens":3,"token_jaccard":0.25,"token_length_ratio":1.5},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"02a63c129ea7299522e67bb99ce843e8a5e86dc86beef7af8d3c298c608c3680","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g := by\n ext a\n exact DFunLike.congr_fun h a\n\n@[norm_cast]\n\nTarget:\ntheorem coe_distribMulActionHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₑ+[φ] B) = ⟨⟨f, h₁⟩, h₂, h₃⟩ :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_distribmulactionhom_mk","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"8fba53f509cbcaa7077e1b9aaefbeecf912a8e10535c22fd02c1ba65487eb495"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca1dcd67cfdd60cbc4b2d15424590a3a4f4ff2107356c87664972f16169bd8bf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"040970e0d960ad5bb812a560b5914e4dfd0360d0acd1cff690447a1eabc7e220","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c15ff78bafeaf3a8bd67bcf30863b0235b5c68e08443e7038b8311fb84eab8e8","source_sha256":"4520455e04cb9adf9401fd1986b8a1189314f45434160dfa03eb1331410ec345","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← Finset.card_range m, ← Finset.prod_const]\n exact IsCoprime.prod_left fun _ _ ↦ H","hard_negative":false,"metrics":{"chosen_tokens":23,"rejected_tokens":27,"token_jaccard":0.857143,"token_length_ratio":1.173913},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"0332c32231778ca16d27cd0f89f57c5a4d96ca37371faa7c9d98114592a8d06c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Data.Fintype.Basic\npublic import Mathlib.Data.Int.GCD\npublic import Mathlib.RingTheory.Coprime.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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-/\n/-!\n# Additional lemmas about elements of a ring satisfying `IsCoprime`\nand elements of a monoid satisfying `IsRelPrime`\n\nThese lemmas are in a separate file to the definition of `IsCoprime` or `IsRelPrime`\nas they require more imports.\n\nNotably, this includes lemmas about `Finset.prod` as this requires importing BigOperators, and\nlemmas about `Pow` since these are easiest to prove via `Finset.prod`.\n\n-/\n\npublic section\n\nuniverse u v\n\nopen scoped Function -- required for scoped `on` notation\n\nsection IsCoprime\n\nvariable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}\n\nsection\n\ntheorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by\n constructor\n · rintro ⟨a, b, h⟩\n refine Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, ?_⟩)\n rwa [mul_comm m, mul_comm n, eq_comm]\n · rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]\n intro h\n exact ⟨_, _, h⟩\n\ninstance : DecidableRel (IsCoprime : ℤ → ℤ → Prop) :=\n fun m n => decidable_of_iff (Int.gcd m n = 1) Int.isCoprime_iff_gcd_eq_one.symm\n\n@[simp, norm_cast]\ntheorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by\n rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]\n\nalias ⟨IsCoprime.natCoprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime\n\ntheorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :\n IsCoprime (a : R) (b : R) :=\n mod_cast h.isCoprime.intCast\n\ntheorem Rat.isCoprime_num_den (x : ℚ) : IsCoprime x.num x.den :=\n x.reduced.cast.of_isCoprime_of_dvd_left Int.dvd_natAbs_self\n\ntheorem Int.isCoprime_gcdA {x y : ℤ} (h : IsCoprime x y) : IsCoprime (x.gcdA y) y := by\n use x, x.gcdB y\n rwa [mul_comm _ y, ← Int.gcd_eq_gcd_ab, Nat.cast_eq_one, ← Int.isCoprime_iff_gcd_eq_one]\n\ntheorem Int.isCoprime_gcdB {x y : ℤ} (h : IsCoprime x y) : IsCoprime (x.gcdB y) x := by\n use y, x.gcdA y\n rwa [add_comm, mul_comm, ← Int.gcd_eq_gcd_ab, Nat.cast_eq_one, ← Int.isCoprime_iff_gcd_eq_one]\n\ntheorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}\n (h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=\n IsCoprime.ne_zero_or_ne_zero (R := A) <| by\n simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)\n\ntheorem IsCoprime.prod_left (h : ∀ i ∈ t, IsCoprime (s i) x) : IsCoprime (∏ i ∈ t, s i) x := by\n induction t using Finset.cons_induction with\n | empty => apply isCoprime_one_left\n | cons b t hbt ih =>\n rw [Finset.prod_cons]\n rw [Finset.forall_mem_cons] at h\n exact h.1.mul_left (ih h.2)\n\ntheorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by\n simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)\n\ntheorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by\n classical\n refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_\n rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert]\n\ntheorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by\n simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)\n\ntheorem IsCoprime.of_prod_left (H1 : IsCoprime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :\n IsCoprime (s i) x :=\n IsCoprime.prod_left_iff.1 H1 i hit\n\ntheorem IsCoprime.of_prod_right (H1 : IsCoprime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :\n IsCoprime x (s i) :=\n IsCoprime.prod_right_iff.1 H1 i hit\n\ntheorem Finset.prod_dvd_of_coprime\n (Hs : (t : Set I).Pairwise (IsCoprime on s)) (Hs1 : (∀ i ∈ t, s i ∣ z)) :\n (∏ x ∈ t, s x) ∣ z := by\n classical\n induction t using Finset.induction_on with\n | empty => simp\n | insert a r har ih =>\n rw [Finset.prod_insert har]\n refine IsCoprime.mul_dvd ?_ ?_ ?_\n · refine IsCoprime.prod_right fun i hir ↦ ?_\n exact Hs (by simp) (by simp [hir]) (ne_of_mem_of_not_mem hir har).symm\n · exact Hs1 a (Finset.mem_insert_self a r)\n · refine ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi\n simp only [Finset.coe_insert, Set.subset_insert]\n\ntheorem Fintype.prod_dvd_of_coprime [Fintype I] (Hs : Pairwise (IsCoprime on s))\n (Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=\n Finset.prod_dvd_of_coprime (Hs.set_pairwise _) fun i _ ↦ Hs1 i\n\nend\n\nopen Finset\n\ntheorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) :\n (∃ μ : I → R, (∑ i ∈ t, μ i * ∏ j ∈ t \\ {i}, s j) = 1) ↔\n Pairwise (IsCoprime on fun i : t ↦ s i) := by\n induction h using Finset.Nonempty.cons_induction with\n | singleton =>\n simp [exists_apply_eq, Pairwise, Function.onFun]\n | cons a t hat h ih =>\n rw [pairwise_cons']\n have mem : ∀ x ∈ t, a ∈ insert a t \\ {x} := fun x hx ↦ by\n rw [mem_sdiff, mem_singleton]\n exact ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩\n constructor\n · rintro ⟨μ, hμ⟩\n rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ\n refine ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩\n · rw [prod_eq_mul_prod_sdiff_singleton_of_mem h.choose_spec, ← mul_assoc, ←\n @if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ\n rw [← hμ, sum_congr rfl]\n intro x hx\n convert! add_mul (R := R) _ _ _ using 2\n · by_cases hx : x = h.choose\n · rw [hx, Pi.single_eq_same, Pi.single_eq_same]\n · rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]\n · convert! (mul_assoc _ _ _).symm\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx), mul_comm, sdiff_sdiff_comm,\n sdiff_singleton_eq_erase a, erase_insert hat]\n · have : IsCoprime (s b) (s a) :=\n ⟨μ a * ∏ i ∈ t \\ {b}, s i, ∑ i ∈ t, μ i * ∏ j ∈ t \\ {i}, s j, ?_⟩\n · exact ⟨this.symm, this⟩\n rw [mul_assoc, ← prod_eq_prod_sdiff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]\n intro x hx\n rw [mul_assoc]\n congr\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx) _]\n congr 2\n rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]\n · rintro ⟨hs, Hb⟩\n obtain ⟨μ, hμ⟩ := ih.mpr hs\n obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right\n use fun i ↦ if i = a then u else v * μ i\n have hμ' : (∑ i ∈ t, v * ((μ i * ∏ j ∈ t \\ {i}, s j) * s a)) = v * s a := by\n rw [← mul_sum, ← sum_mul, hμ, one_mul]\n rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat]\n simp only [↓reduceIte, ite_mul]\n rw [← huv, ← hμ', sum_congr rfl]\n intro x hx\n rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]\n rw [mul_assoc]\n congr\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx) _]\n congr 2\n rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]\n\ntheorem exists_sum_eq_one_iff_pairwise_coprime' [Fintype I] [Nonempty I] [DecidableEq I] :\n (∃ μ : I → R, (∑ i : I, μ i * ∏ j ∈ {i}ᶜ, s j) = 1) ↔ Pairwise (IsCoprime on s) := by\n convert! exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1\n simp only [pairwise_subtype_iff_pairwise_finset', coe_univ, Set.pairwise_univ]\n\ntheorem pairwise_coprime_iff_coprime_prod [DecidableEq I] :\n Pairwise (IsCoprime on fun i : t ↦ s i) ↔ ∀ i ∈ t, IsCoprime (s i) (∏ j ∈ t \\ {i}, s j) := by\n rw [Finset.pairwise_subtype_iff_pairwise_finset']\n refine ⟨fun hp i hi ↦ IsCoprime.prod_right_iff.mpr fun j hj ↦ ?_, fun hp ↦ ?_⟩\n · rw [Finset.mem_sdiff, Finset.mem_singleton] at hj\n exact (hp hj.1 hi hj.2).symm\n · rintro i hi j hj h\n apply IsCoprime.prod_right_iff.mp (hp i hi)\n exact Finset.mem_sdiff.mpr ⟨hj, fun f ↦ h (Finset.mem_singleton.mp f).symm⟩\n\nvariable {m n : ℕ}\n\nTarget:\ntheorem IsCoprime.pow_left (H : IsCoprime x y) : IsCoprime (x ^ m) y :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [← Finset.card_range m, ← Finset.prod_const]\n exact IsCoprime.prod_left fun _ _ ↦ H","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Coprime","family_id":"iscoprime","file_id":"mathlib/Mathlib/RingTheory/Coprime/Lemmas.lean","sample_id":"c15ff78bafeaf3a8bd67bcf30863b0235b5c68e08443e7038b8311fb84eab8e8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c693da27c01f2761aed66594d655f978980d479028970c91f11d6603ed2c2d04","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":false,"metrics":{"chosen_tokens":2,"rejected_tokens":3,"token_jaccard":0.25,"token_length_ratio":1.5},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"0333518aadd51c75578a42aca87a3fda8f5cddc162916f356dab3ab697945e57","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g := by\n ext a\n exact DFunLike.congr_fun h a\n\n@[norm_cast]\ntheorem coe_distribMulActionHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₑ+[φ] B) = ⟨⟨f, h₁⟩, h₂, h₃⟩ := by\n rfl\n\n@[norm_cast]\n\nTarget:\ntheorem coe_mulHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₙ* B) = ⟨f, h₄⟩ :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_mulhom_mk","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"c693da27c01f2761aed66594d655f978980d479028970c91f11d6603ed2c2d04"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ee16869d7bd3de840ebf805ea8a50302c7f8e78f8d08cfc4b7268a631ce6d845","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"610c4a344d5ed7b4f1c72f6c26c7ad6e868225689c28d1b2546fb73aa5d83d1c","source_sha256":"ccfd4dd3593c6c1f210133749c73e4a778fa70e4772e48b50cde116f0b334020","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases h.lt_or_gt with (h_neg | h_pos)\n · exact continuousAt_sign_of_neg h_neg\n · exact continuousAt_sign_of_pos h_pos","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.105263},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"033900a939df31e57344c8c6f095821ae68092a66198afa2ca38287194670c80","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Sign.Defs\npublic import Mathlib.Topology.Order.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Topology on `SignType`\n\nThis file gives `SignType` the discrete topology, and proves continuity results for `SignType.sign`\nin an `OrderTopology`.\n-/\n\npublic section\n\ninstance : TopologicalSpace SignType :=\n ⊥\n\ninstance : DiscreteTopology SignType :=\n ⟨rfl⟩\n\nvariable {α : Type*} [Zero α] [TopologicalSpace α]\n\nsection PartialOrder\n\nvariable [PartialOrder α] [DecidableLT α] [OrderTopology α]\n\ntheorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a := by\n refine (continuousAt_const : ContinuousAt (fun _ => (1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩\n\ntheorem continuousAt_sign_of_neg {a : α} (h : a < 0) : ContinuousAt SignType.sign a := by\n refine (continuousAt_const : ContinuousAt (fun x => (-1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | x < 0 }, fun x hx => (sign_neg hx).symm, isOpen_gt' 0, h⟩\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderTopology α]\n\nTarget:\ntheorem continuousAt_sign_of_ne_zero {a : α} (h : a ≠ 0) : ContinuousAt SignType.sign a :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Instances","family_id":"continuousat_sign_of_ne_zero","file_id":"mathlib/Mathlib/Topology/Instances/Sign.lean","sample_id":"610c4a344d5ed7b4f1c72f6c26c7ad6e868225689c28d1b2546fb73aa5d83d1c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5ae92dbfddfe819bfac27021f8580f504cd4c2ea6824b19ea7e75584b3176d0d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"95eb35341f6b66514b4aea37b06f3f516af23e39a7f2db32907d078876401de3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7f8f2d49d19fbcf3691e83a8cf398c0ac6cc521fafb9109ebc077a79f1434b69","source_sha256":"0cf246dc3c2cbecf11bebc087d277ba7f05345ab88d2c3bf6b111583252fdecf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩","hard_negative":true,"metrics":{"chosen_tokens":22,"rejected_tokens":3,"token_jaccard":0.125,"token_length_ratio":0.136364},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"03ac42dfebf4eba5cb0c6d3a4b1248d0e3f1476ac957debfd4365fa4d4be9586","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Combinatorics.Digraph.Basic\npublic import Mathlib.Combinatorics.SimpleGraph.Basic\n\nNamespace:\nDigraph\n\nLocal context:\n/-\nCopyright (c) 2024 Rida Hamadani. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rida Hamadani\n-/\n/-!\n\n# Graph Orientation\n\nThis module introduces conversion operations between `Digraph`s and `SimpleGraph`s, by forgetting\nthe edge orientations of `Digraph`.\n\n## Main Definitions\n\n- `Digraph.toSimpleGraphInclusive`: Converts a `Digraph` to a `SimpleGraph` by creating an\n undirected edge if either orientation exists in the digraph.\n- `Digraph.toSimpleGraphStrict`: Converts a `Digraph` to a `SimpleGraph` by creating an undirected\n edge only if both orientations exist in the digraph.\n\n## TODO\n\n- Show that there is an isomorphism between loopless complete digraphs and oriented graphs.\n- Define more ways to orient a `SimpleGraph`.\n- Provide lemmas on how `toSimpleGraphInclusive` and `toSimpleGraphStrict` relate to other lattice\n structures on `SimpleGraph`s and `Digraph`s.\n\n## Tags\n\ndigraph, simple graph, oriented graphs\n-/\n\n@[expose] public section\n\nvariable {V : Type*}\n\nnamespace Digraph\n\nsection toSimpleGraph\n\n/-! ### Orientation-forgetting maps on digraphs -/\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\neither orientation is present.\n-/\ndef toSimpleGraphInclusive (G : Digraph V) : SimpleGraph V := SimpleGraph.fromRel G.Adj\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\nboth orientations are present.\n-/\ndef toSimpleGraphStrict (G : Digraph V) : SimpleGraph V where\n Adj v w := v ≠ w ∧ G.Adj v w ∧ G.Adj w v\n\nlemma toSimpleGraphStrict_subgraph_toSimpleGraphInclusive (G : Digraph V) :\n G.toSimpleGraphStrict ≤ G.toSimpleGraphInclusive :=\n fun _ _ h ↦ ⟨h.1, Or.inl h.2.1⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphInclusive_mono : Monotone (toSimpleGraphInclusive : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₂.2.imp (@h₁ _ _) (@h₁ _ _)⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphStrict_mono : Monotone (toSimpleGraphStrict : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₁ h₂.2.1, h₁ h₂.2.2⟩\n\n@[simp]\nlemma toSimpleGraphInclusive_top : (⊤ : Digraph V).toSimpleGraphInclusive = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, Or.inl trivial⟩⟩\n\n@[simp]\n\nTarget:\nlemma toSimpleGraphStrict_top : (⊤ : Digraph V).toSimpleGraphStrict = ⊤ :=\n\nProof body:\n","rejected":"by\n exact toSimpleGraphStrict_top","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"f7feff79f1434c741127ba561a3a6445a68627c955e7d436f33c51e9c387130e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Digraph","family_id":"tosimplegraphstrict_top","file_id":"mathlib/Mathlib/Combinatorics/Digraph/Orientation.lean","sample_id":"7f8f2d49d19fbcf3691e83a8cf398c0ac6cc521fafb9109ebc077a79f1434b69"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"db709b9557b7edfb820f6282a17c5246567430a010a339154efd985351bee30d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"3820f0a9b426b44434d39e0bb5eefc513c02e2b3fae5c0f53ab73f237028f7c8","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"eac5a4fea11a8c13f1d57d8116ad127301563307b7eb33350d74d4e3f3014980","source_sha256":"4c0d6362d88633d87b94227be85c3259bd3147b3bcd830b894bbdd5c5e741fdb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain rfl | hz := eq_or_ne z 0; · simp\n ext p\n rw [mem_primeFactors, mem_normalizedFactors_iff' hz, irreducible_iff_prime,\n Int.nonneg_iff_normalize_eq_self, Finset.mem_map, Function.Embedding.coeFn_mk]\n refine ⟨fun ⟨pp, nnp, dp⟩ ↦ ?_, fun h ↦ ?_⟩\n · lift p to ℕ using nnp\n rw [← Nat.prime_iff_prime_int] at pp\n rw [Int.natCast_dvd] at dp\n exact ⟨p, by simp_all, rfl⟩\n · simp_rw [Nat.mem_primeFactors, Function.Embedding.toFun_eq_coe, Nat.castEmbedding_apply] at h\n obtain ⟨n, ⟨pn, dn, -⟩, rfl⟩ := h\n rw [Int.natCast_dvd, ← Nat.prime_iff_prime_int]\n exact ⟨pn, by simp, dn⟩","hard_negative":true,"metrics":{"chosen_tokens":145,"rejected_tokens":2,"token_jaccard":0.016949,"token_length_ratio":0.013793},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"04547cc276a586fb21dbdffde2608aba243f268b6306b77407f405ca9d9c8c3b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.EuclideanDomain.Int\npublic import Mathlib.Algebra.GCDMonoid.Nat\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.RingTheory.PrincipalIdealDomain\npublic import Mathlib.RingTheory.Radical.Basic\npublic import Mathlib.RingTheory.UniqueFactorizationDomain.Nat\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Arend Mellendijk, Jeremy Tan\n-/\n/-!\n# The radical in `ℕ` and `ℤ`\n\n## Declarations for `ℕ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors`: The prime factors of a natural number\n are the same as the prime factors defined in `Nat.primeFactors`.\n- `Nat.radical_eq_prod_primeFactors`: The radical is computable for natural numbers.\n- `Nat.radical_le_self_iff`: if `n ≠ 0`, `radical n ≤ n`.\n- `Nat.two_le_radical_iff`: `2 ≤ n.radical` iff `2 ≤ n`.\n\n## Declarations for `ℤ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs`: The prime factors of an integer\n are the same as the prime factors of its absolute value.\n- `Int.radical_eq_prod_primeFactors`: The radical is computable for integers.\n-/\n\n@[expose] public section\n\nopen UniqueFactorizationMonoid\n\n/-! ### Lemmas about natural numbers -/\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors :\n primeFactors = Nat.primeFactors := by\n ext n : 1\n rw [primeFactors, Nat.factors_eq, Nat.primeFactors]\n -- this convert is necessary because of the different DecidableEq instances\n convert! List.toFinset_coe _\n\nnamespace Nat\n\nvariable {n : ℕ}\n\nlemma radical_eq_prod_primeFactors : radical n = ∏ p ∈ n.primeFactors, p := by\n simp [radical, primeFactors_eq_natPrimeFactors]\n\nlemma radical_pos (n) : 0 < radical n := pos_of_ne_zero radical_ne_zero\n\n@[simp] lemma one_lt_radical_iff : 1 < radical n ↔ 1 < n := by\n have pp (p) (h : p ∈ n.primeFactors) : 1 ≤ p := pos_of_mem_primeFactors h\n rw [radical_eq_prod_primeFactors, ← @nonempty_primeFactors n, Finset.one_lt_prod_iff_of_one_le pp]\n exact ⟨fun ⟨p, h⟩ ↦ ⟨p, h.1⟩, fun ⟨p, h⟩ ↦ ⟨p, h, (mem_primeFactors.mp h).1.one_lt⟩⟩\n\n@[simp] lemma two_le_radical_iff : 2 ≤ radical n ↔ 2 ≤ n := one_lt_radical_iff\n\n@[simp] lemma radical_le_one_iff : radical n ≤ 1 ↔ n ≤ 1 := by\n simpa only [not_lt] using one_lt_radical_iff.not\n\n@[simp] lemma radical_eq_one_iff : radical n = 1 ↔ n ≤ 1 := by\n rw [← radical_le_one_iff]\n grind [radical_pos n]\n\n@[simp] lemma radical_le_self_iff : radical n ≤ n ↔ n ≠ 0 :=\n ⟨by aesop, fun h ↦ Nat.le_of_dvd (by lia) radical_dvd_self⟩\n\n@[simp] lemma self_lt_radical_iff : n < radical n ↔ n = 0 := by\n simpa only [not_le, not_not] using radical_le_self_iff.not\n\nopen Qq Lean Mathlib.Meta Finset\n\nnamespace Mathlib.Meta.Positivity\nopen Positivity\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- Positivity extension for radical. Proves radicals are nonzero. -/\n@[positivity UniqueFactorizationMonoid.radical _]\nmeta def evalRadical : PositivityExt where eval {u α} _ _ e := do\n match e with\n | ~q(@radical _ $inst $inst' $inst'' $n) =>\n have _ := ← synthInstanceQ q(Nontrivial $α)\n assertInstancesCommute\n return .nonzero q(radical_ne_zero)\n | _ => throwError \"not radical\"\n\nexample : 0 < radical 100 := by positivity\n\nend Mathlib.Meta.Positivity\n\nend Nat\n\n/-! ### Lemmas about integers -/\n\nvariable {z : ℤ}\n\nTarget:\nlemma UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs :\n primeFactors z = z.natAbs.primeFactors.map Nat.castEmbedding :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_eac5a4fea11a","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"1701123a0e98d9f33ddbe1114d7634508156007f4b22464edadfb413e64d87e2","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Radical","family_id":"uniquefactorizationmonoid","file_id":"mathlib/Mathlib/RingTheory/Radical/NatInt.lean","sample_id":"eac5a4fea11a8c13f1d57d8116ad127301563307b7eb33350d74d4e3f3014980"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0e121e69e933498eda1d470b6a56289810b90b4630837893f096bf538b327d3c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6c0cf838709fafcdbab260c6ef69ca4fd9d47e4b1d8b54131f2a3de496447ffa","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5ead7c6d304f6128d5ce7a1f1318a0e4120c41e938959f50a1ef8d65051dd5d7","source_sha256":"bf16fcfb1dfc63e4dd62a210f9db2b7f6873dc4a7240ee55394377c58fa8cf79","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [GroupFilterBasis.nhds_one_eq]\n constructor\n · rintro ⟨-, ⟨-, ⟨E, fin, rfl⟩, rfl⟩, hE⟩\n exact ⟨E, fin, hE⟩\n · rintro ⟨E, fin, hE⟩\n exact ⟨E.fixingSubgroup, ⟨E.fixingSubgroup, ⟨E, fin, rfl⟩, rfl⟩, hE⟩","hard_negative":false,"metrics":{"chosen_tokens":70,"rejected_tokens":77,"token_jaccard":0.909091,"token_length_ratio":1.1},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"049bfd6bfdba437004209da066341366f325d872cb9d185bd14b5285350257e4","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Galois.Basic\npublic import Mathlib.Topology.Algebra.FilterBasis\npublic import Mathlib.Topology.Algebra.OpenSubgroup\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2022 Sebastian Monnet. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sebastian Monnet\n-/\n/-!\n# Krull topology\n\nWe define the Krull topology on `Gal(L/K)` for an arbitrary field extension `L/K`. In order to do\nthis, we first define a `GroupFilterBasis` on `Gal(L/K)`, whose sets are `E.fixingSubgroup` for\nall intermediate fields `E` with `E/K` finite dimensional.\n\n## Main Definitions\n\n- `finiteExts K L`. Given a field extension `L/K`, this is the set of intermediate fields that are\n finite-dimensional over `K`.\n\n- `fixedByFinite K L`. Given a field extension `L/K`, `fixedByFinite K L` is the set of\n subsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite\n\n- `galBasis K L`. Given a field extension `L/K`, this is the filter basis on `Gal(L/K)` whose\n sets are `Gal(L/E)` for intermediate fields `E` with `E/K` finite.\n\n- `galGroupBasis K L`. This is the same as `galBasis K L`, but with the added structure\n that it is a group filter basis on `Gal(L/K)`, rather than just a filter basis.\n\n- `krullTopology K L`. Given a field extension `L/K`, this is the topology on `Gal(L/K)`, induced\n by the group filter basis `galGroupBasis K L`.\n\n## Main Results\n\n- `krullTopology_t2 K L`. For an integral field extension `L/K`, the topology `krullTopology K L`\n is Hausdorff.\n\n- `krullTopology_isTotallySeparated K L`. For an integral field extension `L/K`, the topology\n `krullTopology K L` is totally separated.\n\n- `stabilizer_isOpen_of_isIntegral`: For an integral field extension `L/K`, the stabilizer\n in `Gal(L/K)` of any element in `L` is open for the Krull topology.\n\n- `IntermediateField.finrank_eq_fixingSubgroup_index`: given a Galois extension `K/k` and an\n intermediate field `L`, the `[L : k]` as a natural number is equal to the index of the\n fixing subgroup of `L`.\n\n## Notation\n\n- In docstrings, we will write `Gal(L/E)` to denote the fixing subgroup of an intermediate field\n `E`. That is, `Gal(L/E)` is the subgroup of `Gal(L/K)` consisting of automorphisms that fix\n every element of `E`. In particular, we distinguish between `Gal(L/E)` and `Gal(L/E)`, since the\n former is defined to be a subgroup of `Gal(L/K)`, while the latter is a group in its own right.\n\n## Implementation Notes\n\n- `krullTopology K L` is defined as an instance for type class inference.\n-/\n\n@[expose] public section\n\nopen scoped Pointwise\n\n/-- Given a field extension `L/K`, `finiteExts K L` is the set of\nintermediate field extensions `L/E/K` such that `E/K` is finite. -/\ndef finiteExts (K : Type*) [Field K] (L : Type*) [Field L] [Algebra K L] :\n Set (IntermediateField K L) :=\n {E | FiniteDimensional K E}\n\n/-- Given a field extension `L/K`, `fixedByFinite K L` is the set of\nsubsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite. -/\ndef fixedByFinite (K L : Type*) [Field K] [Field L] [Algebra K L] : Set (Subgroup Gal(L/K)) :=\n IntermediateField.fixingSubgroup '' finiteExts K L\n\n/-- If `L/K` is a field extension, then we have `Gal(L/K) ∈ fixedByFinite K L`. -/\ntheorem top_fixedByFinite {K L : Type*} [Field K] [Field L] [Algebra K L] :\n ⊤ ∈ fixedByFinite K L :=\n ⟨⊥, IntermediateField.instFiniteSubtypeMemBot K, IntermediateField.fixingSubgroup_bot⟩\n\n/-- Given a field extension `L/K`, `galBasis K L` is the filter basis on `Gal(L/K)` whose sets\nare `Gal(L/E)` for intermediate fields `E` with `E/K` finite dimensional. -/\ndef galBasis (K L : Type*) [Field K] [Field L] [Algebra K L] : FilterBasis Gal(L/K) where\n sets := (fun g => g.carrier) '' fixedByFinite K L\n nonempty := ⟨⊤, ⊤, top_fixedByFinite, rfl⟩\n inter_sets := by\n rintro _ _ ⟨_, ⟨E1, h_E1, rfl⟩, rfl⟩ ⟨_, ⟨E2, h_E2, rfl⟩, rfl⟩\n have : FiniteDimensional K E1 := h_E1\n have : FiniteDimensional K E2 := h_E2\n refine ⟨(E1 ⊔ E2).fixingSubgroup.carrier, ⟨_, ⟨_, E1.finiteDimensional_sup E2, rfl⟩, rfl⟩, ?_⟩\n exact Set.subset_inter (E1.fixingSubgroup_le le_sup_left) (E2.fixingSubgroup_le le_sup_right)\n\n/-- A subset of `Gal(L/K)` is a member of `galBasis K L` if and only if it is the underlying set\nof `Gal(L/E)` for some finite subextension `E/K`. -/\ntheorem mem_galBasis_iff (K L : Type*) [Field K] [Field L] [Algebra K L] (U : Set Gal(L/K)) :\n U ∈ galBasis K L ↔ U ∈ (fun g => g.carrier) '' fixedByFinite K L :=\n Iff.rfl\n\n/-- For a field extension `L/K`, `galGroupBasis K L` is the group filter basis on `Gal(L/K)`\nwhose sets are `Gal(L/E)` for finite subextensions `E/K`. -/\n@[implicit_reducible]\ndef galGroupBasis (K L : Type*) [Field K] [Field L] [Algebra K L] :\n GroupFilterBasis Gal(L/K) where\n toFilterBasis := galBasis K L\n one' := fun ⟨H, _, h2⟩ => h2 ▸ H.one_mem\n mul' {U} hU :=\n ⟨U, hU, by\n rcases hU with ⟨H, _, rfl⟩\n rintro x ⟨a, haH, b, hbH, rfl⟩\n exact H.mul_mem haH hbH⟩\n inv' {U} hU :=\n ⟨U, hU, by\n rcases hU with ⟨H, _, rfl⟩\n exact fun _ => H.inv_mem'⟩\n conj' := by\n rintro σ U ⟨H, ⟨E, hE, rfl⟩, rfl⟩\n let F : IntermediateField K L := E.map σ.symm.toAlgHom\n refine ⟨F.fixingSubgroup.carrier, ⟨⟨F.fixingSubgroup, ⟨F, ?_, rfl⟩, rfl⟩, fun g hg => ?_⟩⟩\n · have : FiniteDimensional K E := hE\n exact IntermediateField.finiteDimensional_map σ.symm.toAlgHom\n change σ * g * σ⁻¹ ∈ E.fixingSubgroup\n rw [IntermediateField.mem_fixingSubgroup_iff]\n intro x hx\n change σ (g (σ⁻¹ x)) = x\n have h_in_F : σ⁻¹ x ∈ F := ⟨x, hx, by dsimp⟩\n have h_g_fix : g (σ⁻¹ x) = σ⁻¹ x := by\n rw [Subgroup.mem_carrier, IntermediateField.mem_fixingSubgroup_iff F g] at hg\n exact hg (σ⁻¹ x) h_in_F\n rw [h_g_fix]\n change σ (σ⁻¹ x) = x\n exact AlgEquiv.apply_symm_apply σ x\n\n/-- For a field extension `L/K`, `krullTopology K L` is the topological space structure on\n`Gal(L/K)` induced by the group filter basis `galGroupBasis K L`. -/\ninstance krullTopology (K L : Type*) [Field K] [Field L] [Algebra K L] :\n TopologicalSpace Gal(L/K) :=\n GroupFilterBasis.topology (galGroupBasis K L)\n\n/-- For a field extension `L/K`, the Krull topology on `Gal(L/K)` makes it a topological group. -/\n@[stacks 0BMJ \"We define Krull topology directly without proving the universal property\"]\ninstance (K L : Type*) [Field K] [Field L] [Algebra K L] : IsTopologicalGroup Gal(L/K) :=\n GroupFilterBasis.isTopologicalGroup (galGroupBasis K L)\n\nopen scoped Topology in\n\nTarget:\nlemma krullTopology_mem_nhds_one_iff (K L : Type*) [Field K] [Field L] [Algebra K L]\n (s : Set Gal(L/K)) : s ∈ 𝓝 1 ↔ ∃ E : IntermediateField K L,\n FiniteDimensional K E ∧ (E.fixingSubgroup : Set Gal(L/K)) ⊆ s :=\n\nProof body:\n","rejected":"```lean\nby\n rw [GroupFilterBasis.nhds_one_eq]\n constructor\n · rintro ⟨-, ⟨-, ⟨E, fin, rfl⟩, rfl⟩, hE⟩\n exact ⟨E, fin, hE⟩\n · rintro ⟨E, fin, hE⟩\n exact ⟨E.fixingSubgroup, ⟨E.fixingSubgroup, ⟨E, fin, rfl⟩, rfl⟩, hE⟩\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory","family_id":"krulltopology_mem_nhds_one_iff","file_id":"mathlib/Mathlib/FieldTheory/KrullTopology.lean","sample_id":"5ead7c6d304f6128d5ce7a1f1318a0e4120c41e938959f50a1ef8d65051dd5d7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3d672b5fcbfc441a03f02b841c7530642ee083d80e7d67ae94b2026d6a5a2ff0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c641c3a440e74e4625110563d50a864df264ff1a4060896fd5801c4b02e1cdbf","source_sha256":"4c0d6362d88633d87b94227be85c3259bd3147b3bcd830b894bbdd5c5e741fdb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← radical_natAbs_eq_radical, natCast_pos]\n exact Nat.radical_pos _","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":8,"token_jaccard":0.052632,"token_length_ratio":0.615385},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"0603dd73f9b7f9044fdbcc2a23eec2a11bcc073f0c6d0a4bdf81c7f5d6dd27cd","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.EuclideanDomain.Int\npublic import Mathlib.Algebra.GCDMonoid.Nat\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.RingTheory.PrincipalIdealDomain\npublic import Mathlib.RingTheory.Radical.Basic\npublic import Mathlib.RingTheory.UniqueFactorizationDomain.Nat\n\nNamespace:\nInt\n\nLocal context:\n/-\nCopyright (c) 2025 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Arend Mellendijk, Jeremy Tan\n-/\n/-!\n# The radical in `ℕ` and `ℤ`\n\n## Declarations for `ℕ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors`: The prime factors of a natural number\n are the same as the prime factors defined in `Nat.primeFactors`.\n- `Nat.radical_eq_prod_primeFactors`: The radical is computable for natural numbers.\n- `Nat.radical_le_self_iff`: if `n ≠ 0`, `radical n ≤ n`.\n- `Nat.two_le_radical_iff`: `2 ≤ n.radical` iff `2 ≤ n`.\n\n## Declarations for `ℤ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs`: The prime factors of an integer\n are the same as the prime factors of its absolute value.\n- `Int.radical_eq_prod_primeFactors`: The radical is computable for integers.\n-/\n\n@[expose] public section\n\nopen UniqueFactorizationMonoid\n\n/-! ### Lemmas about natural numbers -/\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors :\n primeFactors = Nat.primeFactors := by\n ext n : 1\n rw [primeFactors, Nat.factors_eq, Nat.primeFactors]\n -- this convert is necessary because of the different DecidableEq instances\n convert! List.toFinset_coe _\n\nnamespace Nat\n\nvariable {n : ℕ}\n\nlemma radical_eq_prod_primeFactors : radical n = ∏ p ∈ n.primeFactors, p := by\n simp [radical, primeFactors_eq_natPrimeFactors]\n\nlemma radical_pos (n) : 0 < radical n := pos_of_ne_zero radical_ne_zero\n\n@[simp] lemma one_lt_radical_iff : 1 < radical n ↔ 1 < n := by\n have pp (p) (h : p ∈ n.primeFactors) : 1 ≤ p := pos_of_mem_primeFactors h\n rw [radical_eq_prod_primeFactors, ← @nonempty_primeFactors n, Finset.one_lt_prod_iff_of_one_le pp]\n exact ⟨fun ⟨p, h⟩ ↦ ⟨p, h.1⟩, fun ⟨p, h⟩ ↦ ⟨p, h, (mem_primeFactors.mp h).1.one_lt⟩⟩\n\n@[simp] lemma two_le_radical_iff : 2 ≤ radical n ↔ 2 ≤ n := one_lt_radical_iff\n\n@[simp] lemma radical_le_one_iff : radical n ≤ 1 ↔ n ≤ 1 := by\n simpa only [not_lt] using one_lt_radical_iff.not\n\n@[simp] lemma radical_eq_one_iff : radical n = 1 ↔ n ≤ 1 := by\n rw [← radical_le_one_iff]\n grind [radical_pos n]\n\n@[simp] lemma radical_le_self_iff : radical n ≤ n ↔ n ≠ 0 :=\n ⟨by aesop, fun h ↦ Nat.le_of_dvd (by lia) radical_dvd_self⟩\n\n@[simp] lemma self_lt_radical_iff : n < radical n ↔ n = 0 := by\n simpa only [not_le, not_not] using radical_le_self_iff.not\n\nopen Qq Lean Mathlib.Meta Finset\n\nnamespace Mathlib.Meta.Positivity\nopen Positivity\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- Positivity extension for radical. Proves radicals are nonzero. -/\n@[positivity UniqueFactorizationMonoid.radical _]\nmeta def evalRadical : PositivityExt where eval {u α} _ _ e := do\n match e with\n | ~q(@radical _ $inst $inst' $inst'' $n) =>\n have _ := ← synthInstanceQ q(Nontrivial $α)\n assertInstancesCommute\n return .nonzero q(radical_ne_zero)\n | _ => throwError \"not radical\"\n\nexample : 0 < radical 100 := by positivity\n\nend Mathlib.Meta.Positivity\n\nend Nat\n\n/-! ### Lemmas about integers -/\n\nvariable {z : ℤ}\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs :\n primeFactors z = z.natAbs.primeFactors.map Nat.castEmbedding := by\n obtain rfl | hz := eq_or_ne z 0; · simp\n ext p\n rw [mem_primeFactors, mem_normalizedFactors_iff' hz, irreducible_iff_prime,\n Int.nonneg_iff_normalize_eq_self, Finset.mem_map, Function.Embedding.coeFn_mk]\n refine ⟨fun ⟨pp, nnp, dp⟩ ↦ ?_, fun h ↦ ?_⟩\n · lift p to ℕ using nnp\n rw [← Nat.prime_iff_prime_int] at pp\n rw [Int.natCast_dvd] at dp\n exact ⟨p, by simp_all, rfl⟩\n · simp_rw [Nat.mem_primeFactors, Function.Embedding.toFun_eq_coe, Nat.castEmbedding_apply] at h\n obtain ⟨n, ⟨pn, dn, -⟩, rfl⟩ := h\n rw [Int.natCast_dvd, ← Nat.prime_iff_prime_int]\n exact ⟨pn, by simp, dn⟩\n\nnamespace Int\n\n@[simp] lemma radical_natAbs_eq_radical : radical z.natAbs = radical z := by\n rw [Nat.radical_eq_prod_primeFactors, radical]\n simp [primeFactors_eq_primeFactors_natAbs]\n\nlemma radical_eq_prod_primeFactors : radical z = ∏ p ∈ z.natAbs.primeFactors, p := by\n rw [← radical_natAbs_eq_radical, Nat.radical_eq_prod_primeFactors]\n\nTarget:\nlemma radical_pos (z : ℤ) : 0 < radical z :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"90638fc539bb8577710cc78ba523a3ac714d60d6e13c0b974c188e61f3cf50a6","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Radical","family_id":"radical_pos","file_id":"mathlib/Mathlib/RingTheory/Radical/NatInt.lean","sample_id":"c641c3a440e74e4625110563d50a864df264ff1a4060896fd5801c4b02e1cdbf"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5a85d26b86ddf2f74915bdec71c3437727410190652cd57dd0255d39ab75018a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ecee7cb42701eaca3a8a08bfc0ad982fcd67173ed23879c02450d49dcf3ee172","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4f87257324df665d9debff8ca9d6a0ef1f5b0744b7fac7ec6bc51e6c735c540d","source_sha256":"efebd44e71fcef2bd69a9d7802ed9c86042b0931e37af3daaa195109d5ee3e6a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [edist_comm y]; apply edist_triangle","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":2,"token_jaccard":0.1,"token_length_ratio":0.222222},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"062c3fc9f400ed290212b6f0c3edb5596cad86139a670ef3a3fb4d66d3bf6403","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ENNReal.Inv\npublic import Mathlib.Topology.UniformSpace.Basic\npublic import Mathlib.Topology.UniformSpace.OfFun\n\nNamespace:\n(root)\n\nLocal context:\n/-\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, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel\n-/\n/-!\n# Extended metric spaces\n\nThis file is devoted to the definition and study of `EMetricSpace`s, i.e., metric\nspaces in which the distance is allowed to take the value ∞. This extended distance is\ncalled `edist`, and takes values in `ℝ≥0∞`.\n\nMany definitions and theorems expected on emetric spaces are already introduced on uniform spaces\nand topological spaces. For example: open and closed sets, compactness, completeness, continuity and\nuniform continuity.\n\nThe class `EMetricSpace` therefore extends `UniformSpace` (and `TopologicalSpace`).\n\nSince a lot of elementary properties don't require `eq_of_edist_eq_zero` we start setting up the\ntheory of `PseudoEMetricSpace`, where we don't require `edist x y = 0 → x = y` and we specialize\nto `EMetricSpace` at the end.\n-/\n\n@[expose] public section\n\n\nassert_not_exists Nat.instLocallyFiniteOrder IsUniformEmbedding.prod TendstoUniformlyOnFilter\n\nopen Filter Set Topology Set.Notation\n\nuniverse u v w\n\nvariable {α : Type u} {β : Type v} {X : Type*}\n\n/-- Characterizing uniformities associated to a (generalized) distance function `D`\nin terms of the elements of the uniformity. -/\ntheorem uniformity_dist_of_mem_uniformity [LT β] {U : Filter (α × α)} (z : β)\n (D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) :\n U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } :=\n HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩\n\nopen scoped Uniformity Topology Filter NNReal ENNReal Pointwise\n\n/-- `EDist α` means that `α` is equipped with an extended distance. -/\n@[ext]\nclass EDist (α : Type*) where\n /-- Extended distance between two points -/\n edist : α → α → ℝ≥0∞\n\nexport EDist (edist)\n\nsection\n\nvariable {x y z : α} {ε : ℝ≥0∞} [EDist α]\n\n/-- `EMetric.ball x ε` is the set of all points `y` with `edist y x < ε` -/\ndef Metric.eball (x : α) (ε : ℝ≥0∞) : Set α :=\n { y | edist y x < ε }\n\n@[simp] theorem Metric.mem_eball {x y : α} {ε : ℝ≥0∞} : y ∈ eball x ε ↔ edist y x < ε := Iff.rfl\n\nend\n\n/-- Creating a uniform space from an extended distance. -/\n@[reducible]\nnoncomputable def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0)\n (edist_comm : ∀ x y : α, edist x y = edist y x)\n (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α :=\n .ofFun edist edist_self edist_comm edist_triangle fun ε ε0 =>\n ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>\n (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩\n\n/-- Creating a uniform space from an extended distance. We assume that\nthere is a preexisting topology, for which the neighborhoods can be expressed using the distance,\nand we make sure that the uniform space structure we construct has a topology which is defeq\nto the original one. -/\n@[reducible] noncomputable def uniformSpaceOfEDistOfHasBasis [TopologicalSpace α]\n (edist : α → α → ℝ≥0∞)\n (edist_self : ∀ x : α, edist x x = 0)\n (edist_comm : ∀ x y : α, edist x y = edist y x)\n (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z)\n (basis : ∀ x, (𝓝 x).HasBasis (fun c ↦ 0 < c) (fun c ↦ {y | edist x y < c})) :\n UniformSpace α :=\n .ofFunOfHasBasis edist edist_self edist_comm edist_triangle (fun ε ε0 =>\n ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>\n (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩) basis\n\n/-- A pseudo extended metric space is a type endowed with a `ℝ≥0∞`-valued distance `edist`\nsatisfying reflexivity `edist x x = 0`, commutativity `edist x y = edist y x`, and the triangle\ninequality `edist x z ≤ edist x y + edist y z`.\n\nNote that we do not require `edist x y = 0 → x = y`. See extended metric spaces (`EMetricSpace`) for\nthe similar class with that stronger assumption.\n\nAny pseudo extended metric space is a topological space and a uniform space (see `TopologicalSpace`,\n`UniformSpace`), where the topology and uniformity come from the metric.\nNote that a T1 pseudo extended metric space is just an extended metric space.\n\nWe make the uniformity/topology part of the data instead of deriving it from the metric. This e.g.\nensures that we do not get a diamond when doing\n`[PseudoEMetricSpace α] [PseudoEMetricSpace β] : TopologicalSpace (α × β)`:\nThe product metric and product topology agree, but not definitionally so.\nSee Note [forgetful inheritance]. -/\nclass PseudoEMetricSpace (α : Type u) : Type u extends EDist α where\n edist_self : ∀ x : α, edist x x = 0\n edist_comm : ∀ x y : α, edist x y = edist y x\n edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z\n toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle\n uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl\n\nattribute [instance_reducible, instance] PseudoEMetricSpace.toUniformSpace\n\n/- Pseudoemetric spaces are less common than metric spaces. Therefore, we work in a dedicated\nnamespace, while notions associated to metric spaces are mostly in the root namespace. -/\n\n/-- Two pseudo emetric space structures with the same edistance function coincide. -/\n@[ext]\nprotected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α}\n (h : m.toEDist = m'.toEDist) : m = m' := by\n obtain ⟨_, _, _, U, hU⟩ := m; rename EDist α => ed\n obtain ⟨_, _, _, U', hU'⟩ := m'; rename EDist α => ed'\n congr 1\n exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm)\n\nvariable [PseudoEMetricSpace α]\n\nexport PseudoEMetricSpace (edist_self edist_comm edist_triangle)\n\nattribute [simp] edist_self\n\n/-- Triangle inequality for the extended distance -/\ntheorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by\n rw [edist_comm z]; apply edist_triangle\n\nTarget:\ntheorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_4f87257324df","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"9ded20253a5f0467430ba2281fc5e844f5d6fe9027810419642b576915c6f199","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/EMetricSpace","family_id":"edist_triangle_right","file_id":"mathlib/Mathlib/Topology/EMetricSpace/Defs.lean","sample_id":"4f87257324df665d9debff8ca9d6a0ef1f5b0744b7fac7ec6bc51e6c735c540d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d28c744573cbd912e935cdf2d8d8e3831400e3ac90187b57895a593edb6ccec6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5e9d6c6a10a021e227b7a94b9d6d2e10f44870985b77d8b393a4759ad04cd534","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"10519652ea9bdadc30cb78a3e7cc9a834c7c7f48bd8153e93a3546df65c6a95a","source_sha256":"78722ac35abaf2b426eb18d35b60539a431bd4ad639256905b6661437efc9fcc","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨n, s, h⟩ := Module.Finite.exists_fin (R := R) (M := M)\n rw [← Set.countable_univ_iff]\n have : Countable (Submodule.span R (Set.range s)) := inferInstance\n rwa [h] at this","hard_negative":true,"metrics":{"chosen_tokens":55,"rejected_tokens":5,"token_jaccard":0.085714,"token_length_ratio":0.090909},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"0646d7da14f2c097c8e762f72accac980ac0da75b761aad4f537cea54a518010","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finsupp.Encodable\npublic import Mathlib.Data.Set.Countable\npublic import Mathlib.LinearAlgebra.Finsupp.LinearCombination\npublic import Mathlib.RingTheory.Finiteness.Defs\n\nNamespace:\nFinsupp\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\n/-!\n# Countable modules\n-/\n\npublic section\n\nnoncomputable section\n\nnamespace Finsupp\n\nvariable {M : Type*} {R : Type*} [Semiring R] [AddCommMonoid M] [Module R M]\n\n/-- If `R` is countable, then any `R`-submodule spanned by a countable family of vectors is\ncountable. -/\ninstance {ι : Type*} [Countable R] [Countable ι] (v : ι → M) :\n Countable (Submodule.span R (Set.range v)) := by\n refine Set.countable_coe_iff.mpr (Set.Countable.mono ?_ (Set.countable_range\n (fun c : (ι →₀ R) => c.sum fun i _ => (c i) • v i)))\n exact fun _ h => Finsupp.mem_span_range_iff_exists_finsupp.mp (SetLike.mem_coe.mp h)\n\nTarget:\ntheorem Countable.of_moduleFinite [Countable R] [Module.Finite R M] : Countable M :=\n\nProof body:\n","rejected":"by\n exact Countable.of_moduleFinite","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"d1be457b8b520bf91909b0ec5d7ac03021a9ff71aaf4cb1c9d0b1538b0ae4866","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra","family_id":"countable","file_id":"mathlib/Mathlib/LinearAlgebra/Countable.lean","sample_id":"10519652ea9bdadc30cb78a3e7cc9a834c7c7f48bd8153e93a3546df65c6a95a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"20520ce19c4f598c908e4d36d327798a9e8496da73d6ca49739202a8af4adf56","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b3a4b1eb1295da6e2ab03812fb37fc03fa8b24b29598af926f949b90e5d6a290","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d3e1feb970de1f47ed34d5ed579d7a21a0a27e50b73499c15c6a6fbb5fc9c261","source_sha256":"ca26128848cc1b74ed4b1ae483833cc8e4d0beb45b9d3c1cf73700271a77bdb4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← mk_uLift, ← mk_uLift]\n choose g hg₁ hg₂ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop\n refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_\n rw [lift_le_aleph0, le_aleph0_iff_set_countable]\n suffices MapsTo (↑) (g ⁻¹' {f}) (f.rootSet A) from\n this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable\n rintro x (rfl : g x = f)\n exact mem_rootSet.2 ⟨hg₁ x, hg₂ x⟩","hard_negative":false,"metrics":{"chosen_tokens":106,"rejected_tokens":111,"token_jaccard":0.934426,"token_length_ratio":1.04717},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"066b0cb8534775fc34d3eead5d93eb3f794a7c3971fa79321fccd98023b0c6fc","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Polynomial.Cardinal\npublic import Mathlib.RingTheory.Algebraic.Basic\n\nNamespace:\nAlgebraic\n\nLocal context:\n/-\nCopyright (c) 2022 Violeta Hernández Palacios. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Violeta Hernández Palacios\n-/\n/-!\n### Cardinality of algebraic numbers\n\nIn this file, we prove variants of the following result: the cardinality of algebraic numbers under\nan R-algebra is at most `#R[X] * ℵ₀`.\n\nAlthough this can be used to prove that real or complex transcendental numbers exist, a more direct\nproof is given by `Liouville.transcendental`.\n-/\n\npublic section\n\n\nuniverse u v\n\nopen Cardinal Polynomial Set\n\nopen Cardinal Polynomial\n\nnamespace Algebraic\n\ntheorem infinite_of_charZero (R A : Type*) [CommRing R] [Ring A] [Algebra R A]\n [CharZero A] : { x : A | IsAlgebraic R x }.Infinite := by\n letI := MulActionWithZero.nontrivial R A\n exact infinite_of_injective_forall_mem Nat.cast_injective isAlgebraic_nat\n\ntheorem aleph0_le_cardinalMk_of_charZero (R A : Type*) [CommRing R] [Ring A]\n [Algebra R A] [CharZero A] : ℵ₀ ≤ #{ x : A // IsAlgebraic R x } :=\n infinite_iff.1 (Set.infinite_coe_iff.2 <| infinite_of_charZero R A)\n\nsection lift\n\nvariable (R : Type u) (A : Type v) [CommRing R] [IsDomain R] [CommRing A] [IsDomain A] [Algebra R A]\n [Module.IsTorsionFree R A]\n\nTarget:\ntheorem cardinalMk_lift_le_mul :\n Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } ≤ Cardinal.lift.{v} #R[X] * ℵ₀ :=\n\nProof body:\n","rejected":"by\n rw [← mk_uLift, ← mk_uLift]\n choose g hg₁ hg₂ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop\n refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_\n rw [lift_le_aleph0, le_aleph0_iff_set_countable]\n suffices MapsTo (↑) (g ⁻¹' {f}) (f.rootSet A) from\n this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable\n rintro x (rfl : g x = f)\n exact mem_rootSet.2 ⟨hg₁ x, hg₂ x⟩\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra","family_id":"cardinalmk_lift_le_mul","file_id":"mathlib/Mathlib/Algebra/AlgebraicCard.lean","sample_id":"d3e1feb970de1f47ed34d5ed579d7a21a0a27e50b73499c15c6a6fbb5fc9c261"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"907633de4129302813f759b855a8876e4ea997f756c4c3eaa0b174c693d9f3a2","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e905c7d00efe611a65686aeaafc68dd8014ade808292dce1567b2e3e2bf45c54","source_sha256":"594526dd0b78e6f5230ed2942c4aa65bf99f40b1c821a95454182a610e50cd9a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun _ ↦ ?_, fun hf ↦ homotopyEquivalences_le_quasiIso _ _ _ hf⟩\n rw [← HomotopyCategory.inverseImage_quotient_isomorphisms,\n MorphismProperty.inverseImage_iff, MorphismProperty.isomorphisms.iff]\n obtain ⟨g, hg⟩ := (Qh_map_bijective _ _).surjective\n ((quotientCompQhIso C).hom.app L ≫ inv (Q.map f) ≫ (quotientCompQhIso C).inv.app K)\n refine ⟨g, (Qh_map_bijective _ _).injective ?_, (Qh_map_bijective _ _).injective ?_⟩\n · simp [hg]; rfl\n · simp [hg, ← quotientCompQhIso_inv_naturality, -NatTrans.naturality]; rfl","hard_negative":false,"metrics":{"chosen_tokens":124,"rejected_tokens":5,"token_jaccard":0.037736,"token_length_ratio":0.040323},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"0680ec062bb320800ae3f44922b15d65f2e8cfc0e165825cea3a545dd286f8c3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.DerivedCategory.SmallShiftedHom\npublic import Mathlib.Algebra.Homology.HomotopyCategory.KInjective\npublic import Mathlib.Algebra.Homology.Embedding.ExtendHomotopy\n\nNamespace:\nCochainComplex.IsKInjective\n\nLocal context:\n/-\nCopyright (c) 2025 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Morphisms to K-injective complexes in the derived category\n\nIn this file, we show that if `L : CochainComplex C ℤ` is K-injective,\nthen for any `K : HomotopyCategory C (.up ℤ)`, the functor `DerivedCategory.Qh`\ninduces a bijection from the type of morphisms `K ⟶ (HomotopyCategory.quotient _ _).obj L)`\n(i.e. homotopy classes of morphisms of cochain complexes) to the type of\nmorphisms in the derived category.\nWe obtain that a morphism between `K`-injective cochain complexes is a quasi-isomorphism\niff it is a homotopy equivalence. In particular, a morphism between cochain complexes\nindexed by `ℕ` which consist of injective objects is a quasi-isomorphism iff\nit is a homotopy equivalence.\n\n-/\n\n@[expose] public section\n\nuniverse w v u\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] [Abelian C]\n\nopen CategoryTheory Localization DerivedCategory\n\nnamespace CochainComplex\n\nnamespace IsKInjective\n\nlemma Qh_map_bijective [HasDerivedCategory C]\n (K : HomotopyCategory C (ComplexShape.up ℤ))\n (L : CochainComplex C ℤ) [L.IsKInjective] :\n Function.Bijective (DerivedCategory.Qh.map :\n (K ⟶ (HomotopyCategory.quotient _ _).obj L) → _) :=\n (CochainComplex.IsKInjective.rightOrthogonal L).map_bijective_of_isTriangulated _ _\n\nset_option backward.isDefEq.respectTransparency false in\nopen HomologicalComplex in\nattribute [local instance] HasDerivedCategory.standard in\n\nTarget:\nlemma quasiIso_iff {K L : CochainComplex C ℤ} [K.IsKInjective] [L.IsKInjective] (f : K ⟶ L) :\n QuasiIso f ↔ homotopyEquivalences C (.up ℤ) f :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Homology","family_id":"quasiiso_iff","file_id":"mathlib/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean","sample_id":"e905c7d00efe611a65686aeaafc68dd8014ade808292dce1567b2e3e2bf45c54"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"68f4be1a74b4ebf33651430b328acfd5b503c8c14886762241b2eb6d133671d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2c93ae538bb5314f013ad26261bdad9269517948b7e335c42f5739ceaba15a2c","source_sha256":"d958937be9af4a6b0fb8e729ceaf03c04a4a5d4477d0d9768e44a20281735051","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← not_countable_iff, countable_iff_nonempty_embedding, not_nonempty_iff]","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":2,"token_jaccard":0.1,"token_length_ratio":0.2},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"06d62cfc30a6651bf3d8eea519f2b1ed464c19cc00e8463fdbc04f2a6bedd2d4","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Countable.Defs\npublic import Mathlib.Data.Fin.Tuple.Basic\npublic import Mathlib.Data.ENat.Defs\npublic import Mathlib.Logic.Equiv.Nat\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Countable types\n\nIn this file we provide basic instances of the `Countable` typeclass defined elsewhere.\n-/\n\npublic section\n\nassert_not_exists Monoid\n\nuniverse u v w\n\nopen Function\n\ninstance : Countable ℤ :=\n Countable.of_equiv ℕ Equiv.intEquivNat.symm\n\n/-!\n### Definition in terms of `Function.Embedding`\n-/\n\nsection Embedding\n\nvariable {α : Sort u} {β : Sort v}\n\ntheorem countable_iff_nonempty_embedding : Countable α ↔ Nonempty (α ↪ ℕ) :=\n ⟨fun ⟨⟨f, hf⟩⟩ => ⟨⟨f, hf⟩⟩, fun ⟨f⟩ => ⟨⟨f, f.2⟩⟩⟩\n\nTarget:\ntheorem uncountable_iff_isEmpty_embedding : Uncountable α ↔ IsEmpty (α ↪ ℕ) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Countable","family_id":"uncountable_iff_isempty_embedding","file_id":"mathlib/Mathlib/Data/Countable/Basic.lean","sample_id":"2c93ae538bb5314f013ad26261bdad9269517948b7e335c42f5739ceaba15a2c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"35ab53fe79d4113d65c677290358d579efd748d687233a57bc7ee95525ee31ae","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"87e1deb70f4c79b10f671487f01f3c8637ef344a8508ee92321614273648e8dd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0f9a99abd92dd5aece612a161e2ac094ccc406554e08311119408b5083b26bf1","source_sha256":"8e40b01e7ccf6ab3c48f4a90d26615e74e27bf1ea1850224aad736249f560b66","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using lift_cardinalMk_adjoin_le R s","hard_negative":false,"metrics":{"chosen_tokens":6,"rejected_tokens":11,"token_jaccard":0.545455,"token_length_ratio":1.833333},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"07504b15695822783bc41d8bf501cbc4060cbcc1d4fa2f5d0c8cd478bd33feb9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.FreeAlgebra\npublic import Mathlib.SetTheory.Cardinal.Free\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n# Cardinality of free algebras\n\nThis file contains some results about the cardinality of `FreeAlgebra`,\nparallel to that of `MvPolynomial`.\n-/\n\npublic section\n\nuniverse u v\n\nvariable (R : Type u) [CommSemiring R]\n\nopen Cardinal\n\nnamespace FreeAlgebra\n\nvariable (X : Type v)\n\n@[simp]\ntheorem cardinalMk_eq_max_lift [Nonempty X] [Nontrivial R] :\n #(FreeAlgebra R X) = Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n have hX := mk_freeMonoid X\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra,\n mk_finsupp_lift_of_infinite, hX, lift_max, lift_aleph0, sup_comm, ← sup_assoc]\n\n@[simp]\ntheorem cardinalMk_eq_lift [IsEmpty X] : #(FreeAlgebra R X) = Cardinal.lift.{v} #R := by\n have := lift_mk_eq'.2 ⟨show (FreeMonoid X →₀ R) ≃ R from Finsupp.uniqueEquiv 1⟩\n rw [lift_id'.{u, v}, lift_umax] at this\n rwa [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra]\n\n@[nontriviality]\ntheorem cardinalMk_eq_one [Subsingleton R] : #(FreeAlgebra R X) = 1 := by\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra, mk_eq_one]\n\ntheorem cardinalMk_le_max_lift :\n #(FreeAlgebra R X) ≤ Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n cases subsingleton_or_nontrivial R\n · exact (cardinalMk_eq_one R X).trans_le (le_max_of_le_right one_le_aleph0)\n cases isEmpty_or_nonempty X\n · exact (cardinalMk_eq_lift R X).trans_le (le_max_of_le_left <| le_max_left _ _)\n · exact (cardinalMk_eq_max_lift R X).le\n\nvariable (X : Type u)\n\ntheorem cardinalMk_eq_max [Nonempty X] [Nontrivial R] : #(FreeAlgebra R X) = #R ⊔ #X ⊔ ℵ₀ := by\n simp\n\ntheorem cardinalMk_eq [IsEmpty X] : #(FreeAlgebra R X) = #R := by\n simp\n\ntheorem cardinalMk_le_max : #(FreeAlgebra R X) ≤ #R ⊔ #X ⊔ ℵ₀ := by\n simpa using cardinalMk_le_max_lift R X\n\nend FreeAlgebra\n\nnamespace Algebra\n\ntheorem lift_cardinalMk_adjoin_le {A : Type v} [Semiring A] [Algebra R A] (s : Set A) :\n lift.{u} #(adjoin R s) ≤ lift.{v} #R ⊔ lift.{u} #s ⊔ ℵ₀ := by\n have H := mk_range_le_lift (f := FreeAlgebra.lift R ((↑) : s → A))\n rw [lift_umax, lift_id'.{v, u}] at H\n rw [Algebra.adjoin_eq_range_freeAlgebra_lift]\n exact H.trans (FreeAlgebra.cardinalMk_le_max_lift R s)\n\nTarget:\ntheorem cardinalMk_adjoin_le {A : Type u} [Semiring A] [Algebra R A] (s : Set A) :\n #(adjoin R s) ≤ #R ⊔ #s ⊔ ℵ₀ :=\n\nProof body:\n","rejected":"by\n simpa using lift_cardinalMk_adjoin_le R s\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAlgebra","family_id":"cardinalmk_adjoin_le","file_id":"mathlib/Mathlib/Algebra/FreeAlgebra/Cardinality.lean","sample_id":"0f9a99abd92dd5aece612a161e2ac094ccc406554e08311119408b5083b26bf1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"026c094e05742398ef51ec3471a1354547404d83e78eaf89d3c5e201cfb57979","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b0f7e660c4f2f9ffa17673d99bf53a0a8a3036b67ba47a9858a82076d80d9547","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b0ea6624faaaac2d22490b52c012672eb21f6b4ce2d71dfe46fe7034344c1c00","source_sha256":"39c30fd995f1c9f0b8e74b8d494ee14295763c6d290c46b81af97a15d6bc3764","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro p q hpq\n rw [NNRat.cast_def, NNRat.cast_def, Commute.div_eq_div_iff] at hpq\n on_goal 1 => rw [← p.num_div_den, ← q.num_div_den, div_eq_div_iff]\n · norm_cast at hpq ⊢\n any_goals norm_cast\n any_goals apply den_ne_zero\n exact Nat.cast_commute ..","hard_negative":true,"metrics":{"chosen_tokens":54,"rejected_tokens":3,"token_jaccard":0.066667,"token_length_ratio":0.055556},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"078e4d636578092c8179e56c4acb58615f50b1e8ef1867aa06fc6c28e7c51bd8","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.GroupWithZero.Units.Lemmas\npublic import Mathlib.Data.Rat.Cast.Defs\n\nNamespace:\nNNRat\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Casts of rational numbers into characteristic zero fields (or division rings).\n-/\n\n@[expose] public section\n\nopen Function\n\nvariable {F ι α β : Type*}\n\nnamespace Rat\nvariable [DivisionRing α] [CharZero α] {p q : ℚ}\n\n@[stacks 09FR \"Characteristic zero case.\"]\nlemma cast_injective : Injective ((↑) : ℚ → α)\n | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩, h => by\n have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0\n have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0\n rw [mk_eq_divInt, mk_eq_divInt] at h ⊢\n rw [cast_divInt_of_ne_zero _ (by simpa), cast_divInt_of_ne_zero _ (by simpa)] at h\n norm_cast at h\n rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq,\n ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_natCast d₁,\n ← Int.cast_mul, ← Int.cast_natCast d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0]\n at h\n\n@[simp, norm_cast] lemma cast_inj : (p : α) = q ↔ p = q := cast_injective.eq_iff\n\n@[simp, norm_cast] lemma cast_eq_zero : (p : α) = 0 ↔ p = 0 := cast_injective.eq_iff' cast_zero\nlemma cast_ne_zero : (p : α) ≠ 0 ↔ p ≠ 0 := cast_eq_zero.ne\n\n@[simp, norm_cast] lemma cast_add (p q : ℚ) : ↑(p + q) = (p + q : α) :=\n cast_add_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_sub (p q : ℚ) : ↑(p - q) = (p - q : α) :=\n cast_sub_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_mul (p q : ℚ) : ↑(p * q) = (p * q : α) :=\n cast_mul_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\nvariable (α) in\n/-- Coercion `ℚ → α` as a `RingHom`. -/\ndef castHom : ℚ →+* α where\n toFun := (↑)\n map_one' := cast_one\n map_mul' := cast_mul\n map_zero' := cast_zero\n map_add' := cast_add\n\n@[simp] lemma coe_castHom : ⇑(castHom α) = ((↑) : ℚ → α) := rfl\n\n@[simp, norm_cast] lemma cast_inv (p : ℚ) : ↑(p⁻¹) = (p⁻¹ : α) := map_inv₀ (castHom α) _\n@[simp, norm_cast] lemma cast_div (p q : ℚ) : ↑(p / q) = (p / q : α) := map_div₀ (castHom α) ..\n\n@[simp, norm_cast]\nlemma cast_zpow (p : ℚ) (n : ℤ) : ↑(p ^ n) = (p ^ n : α) := map_zpow₀ (castHom α) ..\n\n@[norm_cast]\ntheorem cast_divInt (a b : ℤ) : (a /. b : α) = a / b := by\n simp only [divInt_eq_div, cast_div, cast_intCast]\n\nend Rat\n\nnamespace NNRat\nvariable [DivisionSemiring α] [CharZero α] {p q : ℚ≥0}\n\nTarget:\nlemma cast_injective : Injective ((↑) : ℚ≥0 → α) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_b0ea6624faaa","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5c10599114231c6de5788d749f38e3d1dece35a212be875dcae4c5b84ccedf93","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Rat","family_id":"cast_injective","file_id":"mathlib/Mathlib/Data/Rat/Cast/CharZero.lean","sample_id":"b0ea6624faaaac2d22490b52c012672eb21f6b4ce2d71dfe46fe7034344c1c00"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4d9fc79d10e1f6cb1bece30ad581c5e9a4c8ed212136bc32f05d6fe6801040d3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"17c3175dcc5d6935e9b2a54193d874ea97985073af025fca12e3ceedb742c0b7","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff0d0cdb5305b4521e38ab8e2a66557ca4113d303b26bfc8037a5fa896f22a1c","source_sha256":"79322b0ce86dce1bd44237d38805d8410f0a2666387db3473ce98af0009c270a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using inclusion_exclusion_sum_inf_compl (G := ℤ) s S (f := 1)","hard_negative":true,"metrics":{"chosen_tokens":16,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.125},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"07fdf437ec52c3b6049fdff666288b439bbea10ca97ab16f9f9f13e4a234ca70","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Pi\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Algebra.Module.BigOperators\n\nNamespace:\nFinset\n\nLocal context:\n/-\nCopyright (c) 2024 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\n/-!\n# Inclusion-exclusion principle\n\nThis file proves several variants of the inclusion-exclusion principle.\n\nThe inclusion-exclusion principle says that the sum/integral of a function over a finite union of\nsets can be calculated as the alternating sum over `n > 0` of the sum/integral of the function over\nthe intersection of `n` of the sets.\n\nBy taking complements, it also says that the sum/integral of a function over a finite intersection\nof complements of sets can be calculated as the alternating sum over `n ≥ 0` of the sum/integral of\nthe function over the intersection of `n` of the sets.\n\nBy taking the function to be constant `1`, we instead get a result about the cardinality/measure of\nthe sets.\n\n## Main declarations\n\nPer the above explanation, this file contains the following variants of inclusion-exclusion:\n* `Finset.inclusion_exclusion_sum_biUnion`: Sum of a function over a finite union of sets\n* `Finset.inclusion_exclusion_card_biUnion`: Cardinality of a finite union of sets\n* `Finset.inclusion_exclusion_sum_inf_compl`: Sum of a function over a finite intersection of\n complements of sets\n* `Finset.inclusion_exclusion_card_inf_compl`: Cardinality of a finite intersection of\n complements of sets\n\nSee also `MeasureTheory.integral_biUnion_eq_sum_powerset` for the version with integrals, and\n`MeasureTheory.measureReal_biUnion_eq_sum_powerset` for the version with measures.\n\n## TODO\n\n* Prove that truncating the series alternatively gives an upper/lower bound to the true value.\n-/\n\npublic section\n\nassert_not_exists Field\n\nnamespace Finset\nvariable {ι α G : Type*} [AddCommGroup G] {s : Finset ι}\n\nlemma prod_indicator_biUnion_sub_indicator (hs : s.Nonempty) (S : ι → Set α) (a : α) :\n ∏ i ∈ s, (Set.indicator (⋃ i ∈ s, S i) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by\n by_cases ha : a ∈ ⋃ i ∈ s, S i\n · have ha' := ha\n simp only [Set.mem_iUnion, exists_prop] at ha\n obtain ⟨i, hi, ha⟩ := ha\n apply prod_eq_zero hi (by simp [ha, ha'])\n · obtain ⟨i, hi⟩ := hs\n have ha : a ∉ S i := by aesop\n exact prod_eq_zero hi <| by simp [*, -coe_biUnion]\n\n/-- **Inclusion-exclusion principle**, indicator version over a finite union of sets. -/\nlemma indicator_biUnion_eq_sum_powerset (s : Finset ι) (S : ι → Set α) (f : α → G) (a : α) :\n Set.indicator (⋃ i ∈ s, S i) f a = ∑ t ∈ s.powerset with t.Nonempty,\n (-1) ^ (#t + 1) • Set.indicator (⋂ i ∈ t, S i) f a := by\n classical\n by_cases ha : a ∈ ⋃ i ∈ s, S i; swap\n · simp only [ha, not_false_eq_true, Set.indicator_of_notMem, Int.reduceNeg, pow_succ, mul_neg,\n mul_one, neg_smul]\n symm\n apply sum_eq_zero\n simp only [Int.reduceNeg, neg_eq_zero, mem_filter, mem_powerset, and_imp]\n intro t hts ht\n rw [Set.indicator_of_notMem]\n · simp\n · contrapose ha\n simp only [Set.mem_iInter] at ha\n rcases ht with ⟨i, hi⟩\n simp only [Set.mem_iUnion, exists_prop]\n exact ⟨i, hts hi, ha _ hi⟩\n rw [← sub_eq_zero]\n calc\n Set.indicator (⋃ i ∈ s, S i) f a - ∑ t ∈ s.powerset with t.Nonempty,\n (-1) ^ (#t + 1) • Set.indicator (⋂ i ∈ t.1, S i) f a\n _ = ∑ t ∈ s.powerset with t.Nonempty, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a +\n ∑ t ∈ s.powerset with ¬ t.Nonempty, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a := by\n simp [sub_eq_neg_add, ← sum_neg_distrib, filter_eq', pow_succ, ha]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a := by\n rw [sum_filter_add_sum_filter_not]\n _ = (∏ i ∈ s, (1 - Set.indicator (S i) 1 a : ℤ)) • f a := by\n simp only [Int.reduceNeg, prod_sub, prod_const_one, mul_one, sum_smul]\n congr! 1 with t\n simp only [prod_const_one, prod_indicator_apply]\n simp [Set.indicator]\n _ = 0 := by\n have : Set.indicator (⋃ i ∈ s, S i) 1 a = (1 : ℤ) := Set.indicator_of_mem ha 1\n rw [← this, prod_indicator_biUnion_sub_indicator, zero_smul]\n simp only [Set.mem_iUnion, exists_prop] at ha\n rcases ha with ⟨i, hi, -⟩\n exact ⟨i, hi⟩\n\nvariable [DecidableEq α]\n\nlemma prod_indicator_biUnion_finset_sub_indicator (hs : s.Nonempty) (S : ι → Finset α) (a : α) :\n ∏ i ∈ s, (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by\n convert! prod_indicator_biUnion_sub_indicator hs (fun i ↦ S i) a\n simp\n\n/-- **Inclusion-exclusion principle** for the sum of a function over a union.\n\nThe sum of a function `f` over the union of the `S i` over `i ∈ s` is the alternating sum of the\nsums of `f` over the intersections of the `S i`. -/\ntheorem inclusion_exclusion_sum_biUnion (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.biUnion S, f a = ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ (#t.1 + 1) • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a := by\n classical\n rw [← sub_eq_zero]\n calc\n ∑ a ∈ s.biUnion S, f a - ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ (#t.1 + 1) • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a\n = ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ #t.1 • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a +\n ∑ t ∈ s.powerset.filter (¬ ·.Nonempty), (-1) ^ #t • ∑ a ∈ s.biUnion S, f a := by\n simp [sub_eq_neg_add, ← sum_neg_distrib, filter_eq', pow_succ]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t •\n if ht : t.Nonempty then ∑ a ∈ t.inf' ht S, f a else ∑ a ∈ s.biUnion S, f a := by\n rw [← sum_attach (filter ..)]; simp [sum_dite]\n _ = ∑ a ∈ s.biUnion S, (∏ i ∈ s, (1 - Set.indicator (S i) 1 a : ℤ)) • f a := by\n simp only [Int.reduceNeg, prod_sub, sum_comm (s := s.biUnion S), sum_smul, mul_assoc]\n congr! with t\n split_ifs with ht\n · obtain ⟨i, hi⟩ := ht\n simp only [prod_const_one, prod_indicator_apply]\n simp only [smul_sum, Set.indicator, Set.mem_iInter, mem_coe, Pi.one_apply, mul_ite, mul_one,\n mul_zero, ite_smul, zero_smul, sum_ite, not_forall, sum_const_zero, add_zero]\n congr\n aesop\n · obtain rfl := not_nonempty_iff_eq_empty.1 ht\n simp\n _ = ∑ a ∈ s.biUnion S, (∏ i ∈ s,\n (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) : ℤ) • f a := by\n congr! with t; rw [Set.indicator_of_mem ‹_›, Pi.one_apply]\n _ = 0 := by\n obtain rfl | hs := s.eq_empty_or_nonempty <;>\n simp [-coe_biUnion, prod_indicator_biUnion_finset_sub_indicator, *]\n\n/-- **Inclusion-exclusion principle** for the cardinality of a union.\n\nThe cardinality of the union of the `S i` over `i ∈ s` is the alternating sum of the cardinalities\nof the intersections of the `S i`. -/\ntheorem inclusion_exclusion_card_biUnion (s : Finset ι) (S : ι → Finset α) :\n #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),\n (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S) := by\n simpa using inclusion_exclusion_sum_biUnion (G := ℤ) s S (f := 1)\n\nvariable [Fintype α]\n\n/-- **Inclusion-exclusion principle** for the sum of a function over an intersection of complements.\n\nThe sum of a function `f` over the intersection of the complements of the `S i` over `i ∈ s` is the\nalternating sum of the sums of `f` over the intersections of the `S i`. -/\ntheorem inclusion_exclusion_sum_inf_compl (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.inf fun i ↦ (S i)ᶜ, f a = ∑ t ∈ s.powerset, (-1) ^ #t • ∑ a ∈ t.inf S, f a := by\n classical\n calc\n ∑ a ∈ s.inf fun i ↦ (S i)ᶜ, f a\n = ∑ a, f a - ∑ a ∈ s.biUnion S, f a := by\n rw [← Finset.compl_sup, sup_eq_biUnion, eq_sub_iff_add_eq, sum_compl_add_sum]\n _ = ∑ t ∈ s.powerset.filter (¬ ·.Nonempty), (-1) ^ #t • ∑ a ∈ t.inf S, f a\n + ∑ t ∈ s.powerset.filter (·.Nonempty), (-1) ^ #t • ∑ a ∈ t.inf S, f a := by\n simp [← sum_attach (filter ..), inclusion_exclusion_sum_biUnion, inf'_eq_inf, filter_eq',\n sub_eq_add_neg, pow_succ]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t • ∑ a ∈ t.inf S, f a := sum_filter_not_add_sum_filter ..\n\n/-- **Inclusion-exclusion principle** for the cardinality of an intersection of complements.\n\nThe cardinality of the intersection of the complements of the `S i` over `i ∈ s` is the\nalternating sum of the cardinalities of the intersections of the `S i`. -/\n\nTarget:\ntheorem inclusion_exclusion_card_inf_compl (s : Finset ι) (S : ι → Finset α) :\n #(s.inf fun i ↦ (S i)ᶜ) = ∑ t ∈ s.powerset, (-1 : ℤ) ^ #t * #(t.inf S) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_ff0d0cdb5305","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"0772acdc112486d9eca49ef33b900e9781123d027834ba283884574172454777","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Enumerative","family_id":"inclusion_exclusion_card_inf_compl","file_id":"mathlib/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean","sample_id":"ff0d0cdb5305b4521e38ab8e2a66557ca4113d303b26bfc8037a5fa896f22a1c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"df7fc3d0ee9e66586c63b5b29d742f6bdd373f08c808dcf9a1665939392bfaad","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f900c4905bcccf7cab99aaf2498c05a1343d32af1b35424ba41c7c427d729fb0","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective","hard_negative":false,"metrics":{"chosen_tokens":17,"rejected_tokens":5,"token_jaccard":0.117647,"token_length_ratio":0.294118},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"086e6019a1b8d94eb61da6d966fe22619e6554b3db68517d2d853697e45e6efc","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\nTarget:\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"f900c4905bcccf7cab99aaf2498c05a1343d32af1b35424ba41c7c427d729fb0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b3826865ea6bb6ef0aa544410f78b3435a37635af3ea2ebdbe1092f2787b1731","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e5efde683f51ef778b1c9df1337bf4713c8148828691f379c04f9ec372be55a8","source_sha256":"856ddd3a6715738ded0302a3b4f9054bf9dfb29b5d83f0085a1091d6b7175a51","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← oscillationWithin_univ_eq_oscillation] at hK\n convert! ← comp.uniform_oscillationWithin hK\n exact inter_univ _","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.055556,"token_length_ratio":0.105263},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"0a042dc30275f00b9053f2a134f0a253095e8d7a496e9276b74683361ef7b5af","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ENNReal.Real\npublic import Mathlib.Order.WellFoundedSet\npublic import Mathlib.Topology.EMetricSpace.Diam\n\nNamespace:\nIsCompact\n\nLocal context:\n/-\nCopyright (c) 2024 James Sundstrom. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: James Sundstrom\n-/\n/-!\n# Oscillation\n\nIn this file we define the oscillation of a function `f: E → F` at a point `x` of `E`. (`E` is\nrequired to be a TopologicalSpace and `F` a PseudoEMetricSpace.) The oscillation of `f` at `x` is\ndefined to be the infimum of `diam f '' N` for all neighborhoods `N` of `x`. We also define\n`oscillationWithin f D x`, which is the oscillation at `x` of `f` restricted to `D`.\n\nWe also prove some simple facts about oscillation, most notably that the oscillation of `f`\nat `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and\n`oscillationWithin`.\n\n## Tags\n\noscillation, oscillationWithin\n-/\n\n@[expose] public section\n\nopen Topology Metric Set ENNReal\n\nuniverse u v\n\nvariable {E : Type u} {F : Type v} [PseudoEMetricSpace F]\n\n/-- The oscillation of `f : E → F` at `x`. -/\nnoncomputable def oscillation [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=\n ⨅ S ∈ (𝓝 x).map f, ediam S\n\n/-- The oscillation of `f : E → F` within `D` at `x`. -/\nnoncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :\n ENNReal :=\n ⨅ S ∈ (𝓝[D] x).map f, ediam S\n\n/-- The oscillation of `f` at `x` within a neighborhood `D` of `x` is equal to `oscillation f x` -/\ntheorem oscillationWithin_nhds_eq_oscillation [TopologicalSpace E] (f : E → F) (D : Set E) (x : E)\n (hD : D ∈ 𝓝 x) : oscillationWithin f D x = oscillation f x := by\n rw [oscillation, oscillationWithin, nhdsWithin_eq_nhds.2 hD]\n\n/-- The oscillation of `f` at `x` within `univ` is equal to `oscillation f x` -/\ntheorem oscillationWithin_univ_eq_oscillation [TopologicalSpace E] (f : E → F) (x : E) :\n oscillationWithin f univ x = oscillation f x :=\n oscillationWithin_nhds_eq_oscillation f univ x Filter.univ_mem\n\nnamespace ContinuousWithinAt\n\ntheorem oscillationWithin_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}\n {x : E} (hf : ContinuousWithinAt f D x) : oscillationWithin f D x = 0 := by\n rw [← nonpos_iff_eq_zero]\n refine _root_.le_of_forall_pos_le_add fun ε hε ↦ ?_\n rw [zero_add]\n have : eball (f x) (ε / 2) ∈ (𝓝[D] x).map f :=\n hf <| eball_mem_nhds _ (by simp [ne_of_gt hε])\n refine (biInf_le ediam this).trans (le_of_le_of_eq ediam_eball_le ?_)\n exact (ENNReal.mul_div_cancel (by simp) (by simp))\n\nend ContinuousWithinAt\n\nnamespace ContinuousAt\n\ntheorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :\n oscillation f x = 0 := by\n rw [← continuousWithinAt_univ f x] at hf\n exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero\n\nend ContinuousAt\n\nnamespace OscillationWithin\n\n/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/\ntheorem eq_zero_iff_continuousWithinAt [TopologicalSpace E] (f : E → F) {D : Set E}\n {x : E} (xD : x ∈ D) : oscillationWithin f D x = 0 ↔ ContinuousWithinAt f D x := by\n refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_), fun hf ↦ hf.oscillationWithin_eq_zero⟩\n simp_rw [← hf, oscillationWithin, iInf_lt_iff] at ε0\n obtain ⟨S, hS, Sε⟩ := ε0\n refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)\n exact edist_le_ediam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)\n\nend OscillationWithin\n\nnamespace Oscillation\n\n/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/\ntheorem eq_zero_iff_continuousAt [TopologicalSpace E] (f : E → F) (x : E) :\n oscillation f x = 0 ↔ ContinuousAt f x := by\n rw [← oscillationWithin_univ_eq_oscillation, ← continuousWithinAt_univ f x]\n exact OscillationWithin.eq_zero_iff_continuousWithinAt f (mem_univ x)\n\nend Oscillation\n\nnamespace IsCompact\n\nvariable [PseudoEMetricSpace E] {K : Set E}\nvariable {f : E → F} {D : Set E} {ε : ENNReal}\n\n/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`\nsuch that the oscillation of `f` on `ball x δ ∩ D` is less than `ε` for every `x` in `K`. -/\ntheorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithin f D x < ε) :\n ∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by\n let S := fun r ↦\n {x : E | ∃ (a : ℝ), (a > r ∧ ediam (f '' (eball x (ENNReal.ofReal a) ∩ D)) ≤ ε)}\n have S_open : ∀ r > 0, IsOpen (S r) := by\n refine fun r _ ↦ EMetric.isOpen_iff.mpr fun x ⟨a, ar, ha⟩ ↦\n ⟨ENNReal.ofReal ((a - r) / 2), by simp [ar], ?_⟩\n refine fun y hy ↦ ⟨a - (a - r) / 2, by linarith,\n le_trans (ediam_mono (image_mono fun z hz ↦ ?_)) ha⟩\n refine ⟨lt_of_le_of_lt (edist_triangle z y x) (lt_of_lt_of_eq (ENNReal.add_lt_add hz.1 hy) ?_),\n hz.2⟩\n rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]\n have S_cover : K ⊆ ⋃ r > 0, S r := by\n intro x hx\n have : oscillationWithin f D x < ε := hK x hx\n simp only [oscillationWithin, Filter.mem_map, iInf_lt_iff] at this\n obtain ⟨n, hn₁, hn₂⟩ := this\n obtain ⟨r, r0, hr⟩ := EMetric.mem_nhdsWithin_iff.1 hn₁\n simp only [gt_iff_lt, mem_iUnion, exists_prop]\n have : ∀ r', (ENNReal.ofReal r') ≤ r →\n ediam (f '' (eball x (ENNReal.ofReal r') ∩ D)) ≤ ε := by\n intro r' hr'\n grw [← hn₂, ← image_subset_iff.2 hr, hr']\n by_cases r_top : r = ⊤\n · exact ⟨1, one_pos, 2, by simp, this 2 (by simp only [r_top, le_top])⟩\n · obtain ⟨r', hr'⟩ := exists_between (toReal_pos (ne_of_gt r0) r_top)\n use r', hr'.1, r.toReal, hr'.2, this r.toReal ofReal_toReal_le\n have S_antitone : ∀ (r₁ r₂ : ℝ), r₁ ≤ r₂ → S r₂ ⊆ S r₁ :=\n fun r₁ r₂ hr x ⟨a, ar₂, ha⟩ ↦ ⟨a, lt_of_le_of_lt hr ar₂, ha⟩\n obtain ⟨δ, δ0, hδ⟩ : ∃ r > 0, K ⊆ S r := by\n obtain ⟨T, Tb, Tfin, hT⟩ := comp.elim_finite_subcover_image S_open S_cover\n by_cases T_nonempty : T.Nonempty\n · use Tfin.isWF.min T_nonempty, Tb (Tfin.isWF.min_mem T_nonempty)\n intro x hx\n obtain ⟨r, hr⟩ := mem_iUnion.1 (hT hx)\n simp only [mem_iUnion, exists_prop] at hr\n exact (S_antitone _ r (IsWF.min_le Tfin.isWF T_nonempty hr.1)) hr.2\n · rw [not_nonempty_iff_eq_empty] at T_nonempty\n use 1, one_pos, subset_trans hT (by simp [T_nonempty])\n use δ, δ0\n intro x xK\n obtain ⟨a, δa, ha⟩ := hδ xK\n grw [← ha]\n gcongr\n\n/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such\nthat the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/\n\nTarget:\ntheorem uniform_oscillation {K : Set E} (comp : IsCompact K)\n {f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :\n ∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ))) ≤ ε :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis","family_id":"uniform_oscillation","file_id":"mathlib/Mathlib/Analysis/Oscillation.lean","sample_id":"e5efde683f51ef778b1c9df1337bf4713c8148828691f379c04f9ec372be55a8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ba26f65f5dc1563877b3c0401eab0a8e8bc886e50bc464785b0f979599e7091d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"16e7737fd96f6e7a33e5121240c5eb654485ce01158b7b4d817076e7704c0dd1","source_sha256":"5252581a03c05b29d2c6b097493100e8b021df5941541f10a645d410d9cd2563","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [isProbabilityMeasure_iff, measure_univ] using hμ.mem_extremePoints_measure_univ_eq","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.153846},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"0b507dc8d657edb77c7daa331efba4581bdef6bb198af938c0f61726ce15a370","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Convex.Extreme\npublic import Mathlib.Dynamics.Ergodic.Function\npublic import Mathlib.Dynamics.Ergodic.RadonNikodym\npublic import Mathlib.Probability.ConditionalProbability\n\nNamespace:\nErgodic\n\nLocal context:\n/-\nCopyright (c) 2025 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Ergodic measures as extreme points\n\nIn this file we prove that a finite measure `μ` is an ergodic measure for a self-map `f`\niff it is an extreme point of the set of invariant measures of `f` with the same total volume.\nWe also specialize this result to probability measures.\n-/\n\npublic section\n\nopen Filter Set Function MeasureTheory Measure ProbabilityTheory\nopen scoped NNReal ENNReal Topology\n\nvariable {X : Type*} {m : MeasurableSpace X} {μ ν : Measure X} {f : X → X}\n\nnamespace Ergodic\n\n/-- Given a constant `c ≠ ∞`, an extreme point of the set of measures that are invariant under `f`\nand have total mass `c` is an ergodic measure. -/\ntheorem of_mem_extremePoints_measure_univ_eq {c : ℝ≥0∞} (hc : c ≠ ∞)\n (h : μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ ν univ = c}) : Ergodic f μ := by\n have hf : MeasurePreserving f μ μ := h.1.1\n rcases eq_or_ne c 0 with rfl | hc₀\n · convert! zero_measure hf.measurable\n rw [← measure_univ_eq_zero, h.1.2]\n · refine ⟨hf, ⟨?_⟩⟩\n have : IsFiniteMeasure μ := by\n constructor\n rwa [h.1.2, lt_top_iff_ne_top]\n set S := {ν | MeasurePreserving f ν ν ∧ ν univ = c}\n have {s : Set X} (hsm : MeasurableSet s) (hfs : f ⁻¹' s = s) (hμs : μ s ≠ 0) :\n c • μ[|s] ∈ S := by\n refine ⟨.smul_measure (.smul_measure ?_ _) c, ?_⟩\n · convert! hf.restrict_preimage hsm\n exact hfs.symm\n · rw [Measure.smul_apply, (cond_isProbabilityMeasure hμs).1, smul_eq_mul, mul_one]\n intro s hsm hfs\n by_contra H\n obtain ⟨hs, hs'⟩ : μ s ≠ 0 ∧ μ sᶜ ≠ 0 := by\n simpa [eventuallyConst_set, ae_iff, and_comm] using! H\n have hcond : c • μ[|s] = μ := by\n apply h.2 (this hsm hfs hs) (this hsm.compl (by rw [preimage_compl, hfs]) hs')\n refine ⟨μ s / c, μ sᶜ / c, ENNReal.div_pos hs hc, ENNReal.div_pos hs' hc, ?_, ?_⟩\n · rw [← ENNReal.add_div, measure_add_measure_compl hsm, h.1.2, ENNReal.div_self hc₀ hc]\n · simp [ProbabilityTheory.cond, smul_smul, ← mul_assoc, ENNReal.div_mul_cancel,\n ENNReal.mul_inv_cancel, *]\n rw [← hcond] at hs'\n simp [ProbabilityTheory.cond_apply, hsm] at hs'\n\n/-- An extreme point of the set of invariant probability measures is an ergodic measure. -/\ntheorem of_mem_extremePoints\n (h : μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ IsProbabilityMeasure ν}) :\n Ergodic f μ :=\n .of_mem_extremePoints_measure_univ_eq ENNReal.one_ne_top <| by\n simpa only [isProbabilityMeasure_iff] using h\n\n-- TODO: do we need `IsFiniteMeasure ν` here?\ntheorem eq_smul_of_absolutelyContinuous [IsFiniteMeasure μ] [IsFiniteMeasure ν] (hμ : Ergodic f μ)\n (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) : ∃ c : ℝ≥0∞, ν = c • μ := by\n have := hfν.rnDeriv_comp_aeEq hμ.toMeasurePreserving\n obtain ⟨c, hc⟩ := hμ.ae_eq_const_of_ae_eq_comp₀ (measurable_rnDeriv _ _).nullMeasurable this\n use c\n ext s hs\n calc\n ν s = ∫⁻ a in s, ν.rnDeriv μ a ∂μ := .symm <| setLIntegral_rnDeriv hνμ _\n _ = ∫⁻ _ in s, c ∂μ := lintegral_congr_ae <| hc.filter_mono <| ae_mono restrict_le_self\n _ = (c • μ) s := by simp\n\ntheorem eq_of_absolutelyContinuous_measure_univ_eq [IsFiniteMeasure μ] [IsFiniteMeasure ν]\n (hμ : Ergodic f μ) (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) (huniv : ν univ = μ univ) :\n ν = μ := by\n rcases hμ.eq_smul_of_absolutelyContinuous hfν hνμ with ⟨c, rfl⟩\n rcases eq_or_ne μ 0 with rfl | hμ₀\n · simp\n · simp_all [ENNReal.mul_eq_right]\n\ntheorem eq_of_absolutelyContinuous [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]\n (hμ : Ergodic f μ) (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) : ν = μ :=\n eq_of_absolutelyContinuous_measure_univ_eq hμ hfν hνμ <| by simp\n\ntheorem mem_extremePoints_measure_univ_eq [IsFiniteMeasure μ] (hμ : Ergodic f μ) :\n μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ ν univ = μ univ} := by\n rw [mem_extremePoints_iff_left]\n refine ⟨⟨hμ.toMeasurePreserving, rfl⟩, ?_⟩\n rintro ν₁ ⟨hfν₁, hν₁μ⟩ ν₂ ⟨hfν₂, hν₂μ⟩ ⟨a, b, ha, hb, hab, rfl⟩\n have : IsFiniteMeasure ν₁ := ⟨by rw [hν₁μ]; apply measure_lt_top⟩\n apply hμ.eq_of_absolutelyContinuous_measure_univ_eq hfν₁ (.add_right _ _) hν₁μ\n apply absolutelyContinuous_smul ha.ne'\n\nTarget:\ntheorem mem_extremePoints [IsProbabilityMeasure μ] (hμ : Ergodic f μ) :\n μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ IsProbabilityMeasure ν} :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/Ergodic","family_id":"mem_extremepoints","file_id":"mathlib/Mathlib/Dynamics/Ergodic/Extreme.lean","sample_id":"16e7737fd96f6e7a33e5121240c5eb654485ce01158b7b4d817076e7704c0dd1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"155002d614e8c731a4ef806fe01f4e1723729cd9b4f323dba5e3df259c1644a1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a6d3789b1db0dee10abd6269a79afc39145174f4bbc1106a6fc4d6522b77d32f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff1309a891d7188d1fd6da1d56afb597567ed65d35e9646075f9497d1d36a578","source_sha256":"2ff452ff2d90e79f08d7edf4d71dd7e384aea8e09470d3f1230302b0e21e8153","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : (fun s : Set α => ⨆ _ : s.Nonempty, m s) = m := by\n ext1 t\n rcases t.eq_empty_or_nonempty with h | h <;> simp [h, Set.not_nonempty_empty, m_empty]\n simp [boundedBy, this]","hard_negative":true,"metrics":{"chosen_tokens":53,"rejected_tokens":3,"token_jaccard":0.027027,"token_length_ratio":0.056604},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"0c43bd25d3ef03e42af834b4fde6ecab6548b8cfccbf59a3c9d59517f607699b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.OuterMeasure.Operations\npublic import Mathlib.Analysis.SpecificLimits.Basic\n\nNamespace:\nMeasureTheory.OuterMeasure\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Outer measures from functions\n\nGiven an arbitrary function `m : Set α → ℝ≥0∞` that sends `∅` to `0` we can define an outer\nmeasure on `α` that on `s` is defined to be the infimum of `∑ᵢ, m (sᵢ)` for all collections of sets\n`sᵢ` that cover `s`. This is the unique maximal outer measure that is at most the given function.\n\nGiven an outer measure `m`, the Carathéodory-measurable sets are the sets `s` such that\nfor all sets `t` we have `m t = m (t ∩ s) + m (t \\ s)`. This forms a measurable space.\n\n## Main definitions and statements\n\n* `OuterMeasure.boundedBy` is the greatest outer measure that is at most the given function.\n If you know that the given function sends `∅` to `0`, then `OuterMeasure.ofFunction` is a\n special case.\n* `sInf_eq_boundedBy_sInfGen` is a characterization of the infimum of outer measures.\n\n## References\n\n* \n* \n\n## Tags\n\nouter measure, Carathéodory-measurable, Carathéodory's criterion\n\n-/\n\n@[expose] public section\n\nassert_not_exists Module.Basis\n\nnoncomputable section\n\nopen Set Function Filter\nopen scoped NNReal Topology ENNReal\n\nnamespace MeasureTheory\nnamespace OuterMeasure\n\nsection OfFunction\n\nvariable {α : Type*}\n\n/-- Given any function `m` assigning measures to sets satisfying `m ∅ = 0`, there is\n a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/\nprotected def ofFunction (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0) : OuterMeasure α :=\n let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)\n { measureOf := μ\n empty := by\n rw [← nonpos_iff_eq_zero]\n exact (iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simpa\n mono := fun {_ _} hs => iInf_mono fun _ => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩\n iUnion_nat := fun s _ =>\n ENNReal.le_of_forall_pos_le_add <| by\n intro ε hε (hb : (∑' i, μ (s i)) < ∞)\n rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩\n grw [← hl]\n rw [← ENNReal.tsum_add]\n choose f hf using\n show ∀ i, ∃ f : ℕ → Set α, (s i ⊆ ⋃ i, f i) ∧ (∑' i, m (f i)) < μ (s i) + ε' i by\n intro i\n have : μ (s i) < μ (s i) + ε' i :=\n ENNReal.lt_add_right (ne_top_of_le_ne_top hb.ne <| ENNReal.le_tsum _)\n (by simpa using (hε' i).ne')\n rcases iInf_lt_iff.mp this with ⟨t, ht⟩\n exists t\n contrapose! ht\n exact le_iInf ht\n refine le_trans ?_ (ENNReal.tsum_le_tsum fun i => le_of_lt (hf i).2)\n rw [← ENNReal.tsum_prod, ← Nat.pairEquiv.symm.tsum_eq]\n refine iInf_le_of_le _ (iInf_le _ ?_)\n apply iUnion_subset\n intro i\n apply Subset.trans (hf i).1\n apply iUnion_subset\n simp only [Nat.pairEquiv_symm_apply]\n rw [iUnion_unpair]\n intro j\n apply subset_iUnion₂ i }\n\nvariable (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0)\n\n/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets\n`tᵢ` that cover `s`. -/\ntheorem ofFunction_apply (s : Set α) :\n OuterMeasure.ofFunction m m_empty s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, m (t n) :=\n rfl\n\n/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets\n`tᵢ` that cover `s`, with all `tᵢ` satisfying a predicate `P` such that `m` is infinite for sets\nthat don't satisfy `P`.\nThis is similar to `ofFunction_apply`, except that the sets `tᵢ` satisfy `P`.\nThe hypothesis `m_top` applies in particular to a function of the form `extend m'`. -/\ntheorem ofFunction_eq_iInf_mem {P : Set α → Prop} (m_top : ∀ s, ¬ P s → m s = ∞) (s : Set α) :\n OuterMeasure.ofFunction m m_empty s =\n ⨅ (t : ℕ → Set α) (_ : ∀ i, P (t i)) (_ : s ⊆ ⋃ i, t i), ∑' i, m (t i) := by\n rw [OuterMeasure.ofFunction_apply]\n apply le_antisymm\n · exact le_iInf fun t ↦ le_iInf fun _ ↦ le_iInf fun h ↦ iInf₂_le _ (by exact h)\n · simp_rw [le_iInf_iff]\n refine fun t ht_subset ↦ iInf_le_of_le t ?_\n by_cases ht : ∀ i, P (t i)\n · exact iInf_le_of_le ht (iInf_le_of_le ht_subset le_rfl)\n · simp only [ht, not_false_eq_true, iInf_neg, top_le_iff]\n push Not at ht\n obtain ⟨i, hti_notMem⟩ := ht\n have hfi_top : m (t i) = ∞ := m_top _ hti_notMem\n exact ENNReal.tsum_eq_top_of_eq_top ⟨i, hfi_top⟩\n\nvariable {m m_empty}\n\ntheorem ofFunction_le (s : Set α) : OuterMeasure.ofFunction m m_empty s ≤ m s :=\n let f : ℕ → Set α := fun i => Nat.casesOn i s fun _ => ∅\n iInf_le_of_le f <|\n iInf_le_of_le (subset_iUnion f 0) <|\n le_of_eq <| tsum_eq_single 0 <| by\n rintro (_ | i)\n · simp\n · simp [f, m_empty]\n\ntheorem ofFunction_eq (s : Set α) (m_mono : ∀ ⦃t : Set α⦄, s ⊆ t → m s ≤ m t)\n (m_subadd : ∀ s : ℕ → Set α, m (⋃ i, s i) ≤ ∑' i, m (s i)) :\n OuterMeasure.ofFunction m m_empty s = m s :=\n le_antisymm (ofFunction_le s) <|\n le_iInf fun f => le_iInf fun hf => le_trans (m_mono hf) (m_subadd f)\n\ntheorem le_ofFunction {μ : OuterMeasure α} :\n μ ≤ OuterMeasure.ofFunction m m_empty ↔ ∀ s, μ s ≤ m s :=\n ⟨fun H s => le_trans (H s) (ofFunction_le s), fun H _ =>\n le_iInf fun f =>\n le_iInf fun hs =>\n le_trans (μ.mono hs) <| le_trans (measure_iUnion_le f) <| ENNReal.tsum_le_tsum fun _ => H _⟩\n\ntheorem isGreatest_ofFunction :\n IsGreatest { μ : OuterMeasure α | ∀ s, μ s ≤ m s } (OuterMeasure.ofFunction m m_empty) :=\n ⟨fun _ => ofFunction_le _, fun _ => le_ofFunction.2⟩\n\ntheorem ofFunction_eq_sSup : OuterMeasure.ofFunction m m_empty = sSup { μ | ∀ s, μ s ≤ m s } :=\n (@isGreatest_ofFunction α m m_empty).isLUB.sSup_eq.symm\n\n/-- If `m u = ∞` for any set `u` that has nonempty intersection both with `s` and `t`, then\n`μ (s ∪ t) = μ s + μ t`, where `μ = MeasureTheory.OuterMeasure.ofFunction m m_empty`.\n\nE.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma\nimplies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s`\nand `y ∈ t`. -/\ntheorem ofFunction_union_of_top_of_nonempty_inter {s t : Set α}\n (h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) :\n OuterMeasure.ofFunction m m_empty (s ∪ t) =\n OuterMeasure.ofFunction m m_empty s + OuterMeasure.ofFunction m m_empty t := by\n refine le_antisymm (measure_union_le _ _) (le_iInf₂ fun f hf ↦ ?_)\n set μ := OuterMeasure.ofFunction m m_empty\n rcases Classical.em (∃ i, (s ∩ f i).Nonempty ∧ (t ∩ f i).Nonempty) with (⟨i, hs, ht⟩ | he)\n · calc\n μ s + μ t ≤ ∞ := le_top\n _ = m (f i) := (h (f i) hs ht).symm\n _ ≤ ∑' i, m (f i) := ENNReal.le_tsum i\n set I := fun s => { i : ℕ | (s ∩ f i).Nonempty }\n have hd : Disjoint (I s) (I t) := disjoint_iff_inf_le.mpr fun i hi => he ⟨i, hi⟩\n have hI : ∀ u ⊆ s ∪ t, μ u ≤ ∑' i : I u, μ (f i) := fun u hu =>\n calc\n μ u ≤ μ (⋃ i : I u, f i) :=\n μ.mono fun x hx =>\n let ⟨i, hi⟩ := mem_iUnion.1 (hf (hu hx))\n mem_iUnion.2 ⟨⟨i, ⟨x, hx, hi⟩⟩, hi⟩\n _ ≤ ∑' i : I u, μ (f i) := measure_iUnion_le _\n calc\n μ s + μ t ≤ (∑' i : I s, μ (f i)) + ∑' i : I t, μ (f i) :=\n add_le_add (hI _ subset_union_left) (hI _ subset_union_right)\n _ = ∑' i : ↑(I s ∪ I t), μ (f i) :=\n (ENNReal.summable.tsum_union_disjoint (f := fun i => μ (f i)) hd ENNReal.summable).symm\n _ ≤ ∑' i, μ (f i) :=\n (ENNReal.summable.tsum_le_tsum_of_inj (↑) Subtype.coe_injective (fun _ _ => zero_le)\n (fun _ => le_rfl) ENNReal.summable)\n _ ≤ ∑' i, m (f i) := ENNReal.tsum_le_tsum fun i => ofFunction_le _\n\ntheorem comap_ofFunction {β} (f : β → α) (h : Monotone m ∨ Surjective f) :\n comap f (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun s => m (f '' s)) (by simp; simp [m_empty]) := by\n refine le_antisymm (le_ofFunction.2 fun s => ?_) fun s => ?_\n · rw [comap_apply]\n apply ofFunction_le\n · rw [comap_apply, ofFunction_apply, ofFunction_apply]\n refine iInf_mono' fun t => ⟨fun k => f ⁻¹' t k, ?_⟩\n refine iInf_mono' fun ht => ?_\n rw [Set.image_subset_iff, preimage_iUnion] at ht\n refine ⟨ht, ENNReal.tsum_le_tsum fun n => ?_⟩\n rcases h with hl | hr\n exacts [hl (image_preimage_subset _ _), (congr_arg m (hr.image_preimage (t n))).le]\n\ntheorem map_ofFunction_le {β} (f : α → β) :\n map f (OuterMeasure.ofFunction m m_empty) ≤\n OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty :=\n le_ofFunction.2 fun s => by\n rw [map_apply]\n apply ofFunction_le\n\ntheorem map_ofFunction {β} {f : α → β} (hf : Injective f) :\n map f (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty := by\n refine (map_ofFunction_le _).antisymm fun s => ?_\n simp only [ofFunction_apply, map_apply, le_iInf_iff]\n intro t ht\n refine iInf_le_of_le (fun n => (range f)ᶜ ∪ f '' t n) (iInf_le_of_le ?_ ?_)\n · rw [← union_iUnion, ← inter_subset, ← image_preimage_eq_inter_range, ← image_iUnion]\n exact image_mono ht\n · refine ENNReal.tsum_le_tsum fun n => le_of_eq ?_\n simp [hf.preimage_image]\n\n-- TODO (kmill): change `m (t ∩ s)` to `m (s ∩ t)`\ntheorem restrict_ofFunction (s : Set α) (hm : Monotone m) :\n restrict s (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun t => m (t ∩ s)) (by simp; simp [m_empty]) := by\n rw [restrict]\n simp only [inter_comm _ s, LinearMap.comp_apply]\n rw [comap_ofFunction _ (Or.inl hm)]\n simp only [map_ofFunction Subtype.coe_injective, Subtype.image_preimage_coe]\n\ntheorem smul_ofFunction {c : ℝ≥0∞} (hc : c ≠ ∞) : c • OuterMeasure.ofFunction m m_empty =\n OuterMeasure.ofFunction (c • m) (by simp [m_empty]) := by\n ext1 s\n haveI : Nonempty { t : ℕ → Set α // s ⊆ ⋃ i, t i } := ⟨⟨fun _ => s, subset_iUnion (fun _ => s) 0⟩⟩\n simp only [smul_apply, ofFunction_apply, ENNReal.tsum_mul_left, Pi.smul_apply, smul_eq_mul,\n iInf_subtype']\n rw [ENNReal.mul_iInf fun h => (hc h).elim]\n\nend OfFunction\n\nsection BoundedBy\n\nvariable {α : Type*} (m : Set α → ℝ≥0∞)\n\n/-- Given any function `m` assigning measures to sets, there is a unique maximal outer measure `μ`\n satisfying `μ s ≤ m s` for all `s : Set α`. This is the same as `OuterMeasure.ofFunction`,\n except that it doesn't require `m ∅ = 0`. -/\ndef boundedBy : OuterMeasure α :=\n OuterMeasure.ofFunction (fun s => ⨆ _ : s.Nonempty, m s) (by simp [Set.not_nonempty_empty])\n\nvariable {m}\n\ntheorem boundedBy_le (s : Set α) : boundedBy m s ≤ m s :=\n (ofFunction_le _).trans iSup_const_le\n\nTarget:\ntheorem boundedBy_eq_ofFunction (m_empty : m ∅ = 0) (s : Set α) :\n boundedBy m s = OuterMeasure.ofFunction m m_empty s :=\n\nProof body:\n","rejected":"by\n exact boundedBy_eq_ofFunction","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"2b52f55d63b8180a18633165670ad4db471fabea3f864338d5c08833d17e6805","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/OuterMeasure","family_id":"boundedby_eq_offunction","file_id":"mathlib/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean","sample_id":"ff1309a891d7188d1fd6da1d56afb597567ed65d35e9646075f9497d1d36a578"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9ae2d83b6a808c7bae8375f991f38020fedde520026e77033201ea33c6afd882","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8fbb2956d24b167e7702ee0a4a99c5bbfbc944a5212dacb8308e622534b65d6d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2cdcc1dd0c4f5dba1df2244028dbe522178ef51a9ac80121eb406c12d554155b","source_sha256":"b1a6de0bf7dd13eb86b75cd8d95aebb591d157a9fea40ceef9dbefb4524b23ba","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine eq_of_le_of_not_lt (krullDimLE_iff (n := 1).mp ?_) fun h ↦ ?_\n · exact krullDimLE_one_iff_of_isPrime_bot.mpr fun I hI hI' ↦ hI'.isMaximal hI\n · have : KrullDimLE 0 R := krullDimLE_iff.mpr (ENat.WithBot.lt_add_one_iff.mp h)\n exact IsDiscreteValuationRing.not_isField R KrullDimLE.isField_of_isDomain","hard_negative":true,"metrics":{"chosen_tokens":62,"rejected_tokens":5,"token_jaccard":0.081081,"token_length_ratio":0.080645},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"0ccdac951d8f780ac9f6cdc7a7302bd01e1ece0bf905305097ab78b26a96157d","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.DedekindDomain.Basic\npublic import Mathlib.RingTheory.DiscreteValuationRing.Basic\npublic import Mathlib.RingTheory.Finiteness.Ideal\npublic import Mathlib.RingTheory.Ideal.Cotangent\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# Equivalent conditions for DVR\n\nIn `IsDiscreteValuationRing.TFAE`, we show that the following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n- `R` is a discrete valuation ring\n- `R` is a valuation ring\n- `R` is a Dedekind domain\n- `R` is integrally closed with a unique prime ideal\n- `m` is principal\n- `dimₖ m/m² = 1`\n- Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\npublic section\n\n\nvariable (R : Type*) [CommRing R]\n\nopen scoped Multiplicative\n\nopen IsLocalRing Module\n\ntheorem exists_maximalIdeal_pow_eq_of_principal [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h' : (maximalIdeal R).IsPrincipal) (I : Ideal R) (hI : I ≠ ⊥) :\n ∃ n : ℕ, I = maximalIdeal R ^ n := by\n by_cases h : IsField R\n · let _ := h.toField\n exact ⟨0, by simp [(eq_bot_or_eq_top I).resolve_left hI]⟩\n classical\n obtain ⟨x, hx : _ = Ideal.span _⟩ := h'\n by_cases hI' : I = ⊤\n · use 0; rw [pow_zero, hI', Ideal.one_eq_top]\n have H : ∀ r : R, ¬IsUnit r ↔ x ∣ r := fun r =>\n (SetLike.ext_iff.mp hx r).trans Ideal.mem_span_singleton\n have : x ≠ 0 := by\n rintro rfl\n apply Ring.ne_bot_of_isMaximal_of_not_isField (maximalIdeal.isMaximal R) h\n simp [hx]\n have hx' := IsDiscreteValuationRing.irreducible_of_span_eq_maximalIdeal x this hx\n have H' : ∀ r : R, r ≠ 0 → r ∈ nonunits R → ∃ n : ℕ, Associated (x ^ n) r := by\n intro r hr₁ hr₂\n obtain ⟨f, hf₁, rfl, hf₂⟩ := (WfDvdMonoid.not_unit_iff_exists_factors_eq r hr₁).mp hr₂\n have : ∀ b ∈ f, Associated x b := by\n intro b hb\n exact Irreducible.associated_of_dvd hx' (hf₁ b hb) ((H b).mp (hf₁ b hb).1)\n clear hr₁ hr₂ hf₁\n induction f using Multiset.induction with\n | empty => exact (hf₂ rfl).elim\n | cons fa fs fh => ?_\n rcases eq_or_ne fs ∅ with (rfl | hf')\n · use 1\n rw [pow_one, Multiset.prod_cons, Multiset.empty_eq_zero, Multiset.prod_zero, mul_one]\n exact this _ (Multiset.mem_cons_self _ _)\n · obtain ⟨n, hn⟩ := fh hf' fun b hb => this _ (Multiset.mem_cons_of_mem hb)\n use n + 1\n rw [pow_add, Multiset.prod_cons, mul_comm, pow_one]\n exact Associated.mul_mul (this _ (Multiset.mem_cons_self _ _)) hn\n have : ∃ n : ℕ, x ^ n ∈ I := by\n obtain ⟨r, hr₁, hr₂⟩ : ∃ r : R, r ∈ I ∧ r ≠ 0 := by\n by_contra! h; apply hI; rw [eq_bot_iff]; exact h\n obtain ⟨n, u, rfl⟩ := H' r hr₂ (le_maximalIdeal hI' hr₁)\n use n\n rwa [← I.unit_mul_mem_iff_mem u.isUnit, mul_comm]\n use Nat.find this\n apply le_antisymm\n · change ∀ s ∈ I, s ∈ _\n by_contra! ⟨s, hs₁, hs₂⟩\n apply hs₂\n by_cases hs₃ : s = 0; · rw [hs₃]; exact zero_mem _\n obtain ⟨n, u, rfl⟩ := H' s hs₃ (le_maximalIdeal hI' hs₁)\n rw [mul_comm, Ideal.unit_mul_mem_iff_mem _ u.isUnit] at hs₁ ⊢\n apply Ideal.pow_le_pow_right (Nat.find_min' this hs₁)\n apply Ideal.pow_mem_pow\n exact (H _).mpr (dvd_refl _)\n · rw [hx, Ideal.span_singleton_pow, Ideal.span_le, Set.singleton_subset_iff]\n exact Nat.find_spec this\n\ntheorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDedekindDomain R] :\n (maximalIdeal R).IsPrincipal := by\n classical\n by_cases ne_bot : maximalIdeal R = ⊥\n · rw [ne_bot]; infer_instance\n obtain ⟨a, ha₁, ha₂⟩ : ∃ a ∈ maximalIdeal R, a ≠ (0 : R) := by\n by_contra! h'; apply ne_bot; rwa [eq_bot_iff]\n have hle : Ideal.span {a} ≤ maximalIdeal R := by rwa [Ideal.span_le, Set.singleton_subset_iff]\n have : (Ideal.span {a}).radical = maximalIdeal R := by\n rw [Ideal.radical_eq_sInf]\n apply le_antisymm\n · exact sInf_le ⟨hle, inferInstance⟩\n · refine\n le_sInf fun I hI =>\n (eq_maximalIdeal <| hI.2.isMaximal (fun e => ha₂ ?_)).ge\n rw [← Ideal.span_singleton_eq_bot, eq_bot_iff, ← e]; exact hI.1\n have : ∃ n, maximalIdeal R ^ n ≤ Ideal.span {a} := by\n rw [← this]; apply Ideal.exists_radical_pow_le_of_fg; exact IsNoetherian.noetherian _\n rcases hn : Nat.find this with - | n\n · have := Nat.find_spec this\n rw [hn, pow_zero, Ideal.one_eq_top] at this\n exact (Ideal.IsMaximal.ne_top inferInstance (eq_top_iff.mpr <| this.trans hle)).elim\n obtain ⟨b, hb₁, hb₂⟩ : ∃ b ∈ maximalIdeal R ^ n, b ∉ Ideal.span {a} := by\n by_contra! h'; rw [Nat.find_eq_iff] at hn; exact hn.2 n n.lt_succ_self fun x hx => h' x hx\n have hb₃ : ∀ m ∈ maximalIdeal R, ∃ k : R, k * a = b * m := by\n intro m hm; rw [← Ideal.mem_span_singleton']; apply Nat.find_spec this\n rw [hn, pow_succ]; exact Ideal.mul_mem_mul hb₁ hm\n have hb₄ : b ≠ 0 := by rintro rfl; apply hb₂; exact zero_mem _\n let K := FractionRing R\n let x : K := algebraMap R K b / algebraMap R K a\n let M := Submodule.map (Algebra.linearMap R K) (maximalIdeal R)\n have ha₃ : algebraMap R K a ≠ 0 := IsFractionRing.to_map_eq_zero_iff.not.mpr ha₂\n by_cases hx : ∀ y ∈ M, x * y ∈ M\n · have := isIntegral_of_smul_mem_submodule M ?_ ?_ x hx\n · obtain ⟨y, e⟩ := IsIntegrallyClosed.algebraMap_eq_of_integral this\n refine (hb₂ (Ideal.mem_span_singleton'.mpr ⟨y, ?_⟩)).elim\n apply IsFractionRing.injective R K\n rw [map_mul, e, div_mul_cancel₀ _ ha₃]\n · rw [Submodule.ne_bot_iff]; refine ⟨_, ⟨a, ha₁, rfl⟩, ?_⟩\n exact (IsFractionRing.to_map_eq_zero_iff (K := K)).not.mpr ha₂\n · apply Submodule.FG.map; exact IsNoetherian.noetherian _\n · have :\n (M.map (DistribSMul.toLinearMap R K x)).comap (Algebra.linearMap R K) = ⊤ := by\n contrapose! hx with h\n rintro m' ⟨m, hm, rfl : algebraMap R K m = m'⟩\n obtain ⟨k, hk⟩ := hb₃ m hm\n have hk' : x * algebraMap R K m = algebraMap R K k := by\n rw [← mul_div_right_comm, ← map_mul, ← hk, map_mul, mul_div_cancel_right₀ _ ha₃]\n exact ⟨k, le_maximalIdeal h ⟨_, ⟨_, hm, rfl⟩, hk'⟩, hk'.symm⟩\n obtain ⟨y, hy₁, hy₂⟩ : ∃ y ∈ maximalIdeal R, b * y = a := by\n rw [Ideal.eq_top_iff_one, Submodule.mem_comap] at this\n obtain ⟨_, ⟨y, hy, rfl⟩, hy' : x * algebraMap R K y = algebraMap R K 1⟩ := this\n rw [map_one, ← mul_div_right_comm, div_eq_one_iff_eq ha₃, ← map_mul] at hy'\n exact ⟨y, hy, IsFractionRing.injective R K hy'⟩\n refine ⟨⟨y, ?_⟩⟩\n apply le_antisymm\n · intro m hm; obtain ⟨k, hk⟩ := hb₃ m hm; rw [← hy₂, mul_comm, mul_assoc] at hk\n rw [← mul_left_cancel₀ hb₄ hk, mul_comm]; exact Ideal.mem_span_singleton'.mpr ⟨_, rfl⟩\n · rwa [Submodule.span_le, Set.singleton_subset_iff]\n\n/--\nLet `(R, m, k)` be a Noetherian local domain (possibly a field).\nThe following are equivalent:\n0. `R` is a PID\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with at most one non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² ≤ 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `IsDiscreteValuationRing.TFAE` for a version assuming `¬ IsField R`.\n-/\ntheorem tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain\n [IsNoetherianRing R] [IsLocalRing R] [IsDomain R] :\n List.TFAE\n [IsPrincipalIdealRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∀ P : Ideal R, P ≠ ⊥ → P.IsPrime → P = maximalIdeal R,\n (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) ≤ 1,\n ∀ I ≠ ⊥, ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n tfae_have 1 → 2 := fun _ ↦ inferInstance\n tfae_have 2 → 1 := fun _ ↦ ((IsBezout.TFAE (R := R)).out 0 1).mp ‹_›\n tfae_have 1 → 4\n | H => ⟨inferInstance, fun P hP hP' ↦ eq_maximalIdeal (hP'.isMaximal hP)⟩\n tfae_have 4 → 3 :=\n fun ⟨h₁, h₂⟩ ↦ { h₁ with maximalOfPrime := (h₂ _ · · ▸ maximalIdeal.isMaximal R) }\n tfae_have 3 → 5 := fun h ↦ maximalIdeal_isPrincipal_of_isDedekindDomain R\n tfae_have 6 ↔ 5 := finrank_cotangentSpace_le_one_iff\n tfae_have 5 → 7 := exists_maximalIdeal_pow_eq_of_principal R\n tfae_have 7 → 2 := by\n rw [ValuationRing.iff_ideal_total]\n intro H\n constructor\n intro I J\n by_cases hI : I = ⊥; · order\n by_cases hJ : J = ⊥; · order\n obtain ⟨n, rfl⟩ := H I hI\n obtain ⟨m, rfl⟩ := H J hJ\n exact (le_total m n).imp Ideal.pow_le_pow_right Ideal.pow_le_pow_right\n tfae_finish\n\n/--\nThe following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n0. `R` is a discrete valuation ring\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with a unique non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² = 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\ntheorem IsDiscreteValuationRing.TFAE [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h : ¬IsField R) :\n List.TFAE\n [IsDiscreteValuationRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ P.IsPrime, (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) = 1,\n ∀ (I) (_ : I ≠ ⊥), ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n have : finrank (ResidueField R) (CotangentSpace R) = 1 ↔\n finrank (ResidueField R) (CotangentSpace R) ≤ 1 := by\n simp [Nat.le_one_iff_eq_zero_or_eq_one, finrank_cotangentSpace_eq_zero_iff, h]\n rw [this]\n have : maximalIdeal R ≠ ⊥ := isField_iff_maximalIdeal_eq.not.mp h\n convert! tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R\n · exact ⟨fun _ ↦ inferInstance, fun h ↦ { h with not_a_field' := this }⟩\n · exact ⟨fun h P h₁ h₂ ↦ h.unique ⟨h₁, h₂⟩ ⟨this, inferInstance⟩,\n fun H ↦ ⟨_, ⟨this, inferInstance⟩, fun P hP ↦ H P hP.1 hP.2⟩⟩\n\nvariable {R}\n\nlemma IsLocalRing.finrank_CotangentSpace_eq_one_iff [IsNoetherianRing R] [IsLocalRing R]\n [IsDomain R] : finrank (ResidueField R) (CotangentSpace R) = 1 ↔ IsDiscreteValuationRing R := by\n by_cases hR : IsField R\n · letI := hR.toField\n simp only [finrank_cotangentSpace_eq_zero, zero_ne_one, false_iff]\n exact fun h ↦ h.3 maximalIdeal_eq_bot\n · exact (IsDiscreteValuationRing.TFAE R hR).out 5 0\n\nvariable (R)\n\nlemma IsLocalRing.finrank_CotangentSpace_eq_one [IsDomain R] [IsDiscreteValuationRing R] :\n finrank (ResidueField R) (CotangentSpace R) = 1 :=\n finrank_CotangentSpace_eq_one_iff.mpr ‹_›\n\nopen Ring in\n\nTarget:\nlemma IsDiscreteValuationRing.ringKrullDim_eq_one [IsDomain R] [IsDiscreteValuationRing R] :\n ringKrullDim R = 1 :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_2cdcc1dd0c4f","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"43f98b26613d8c4bdb583e7d3d0f8a531971b19a8ef1099fde8bb5d7d8c7a9c6","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/DiscreteValuationRing","family_id":"isdiscretevaluationring","file_id":"mathlib/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean","sample_id":"2cdcc1dd0c4f5dba1df2244028dbe522178ef51a9ac80121eb406c12d554155b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"33ca22f3b5bf5fc06222f4523b841e69cdf5f12cc093fd3d894334378b9f1819","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"71d40dbf91009a8d289f32f35fd098eb312b3c5f7d77a88722243c78657ed903","source_sha256":"3b2fe3ce97a7f385df1705afa4e64183ee3b93d50020ad74beb0ced8ddd98b80","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Module.Relations.Solution.isPresentation_iff]\n constructor\n · rw [← Module.Relations.Solution.surjective_π_iff_span_eq_top, ← comm₂₃]\n exact Extension.toKaehler_surjective.comp pres.cotangentSpaceBasis.repr.symm.surjective\n · rw [← Module.Relations.range_map]\n exact Function.Exact.linearMap_ker_eq\n ((LinearMap.exact_iff_of_surjective_of_bijective_of_injective\n _ _ _ _ (hom₁ pres)\n pres.cotangentSpaceBasis.repr.symm.toLinearMap .id\n (comm₁₂ pres) (by simpa using comm₂₃ pres) (surjective_hom₁ pres)\n (LinearEquiv.bijective _) (Equiv.refl _).injective).2\n pres.toExtension.exact_cotangentComplex_toKaehler)\n\n/-- The presentation of the `S`-module `Ω[S⁄R]` deduced from a presentation\nof `S` as an `R`-algebra. -/\nnoncomputable def differentials : Module.Presentation S Ω[S⁄R] where\n G := ι\n R := σ\n relation := _\n toSolution := differentialsSolution pres\n toIsPresentation := pres.differentialsSolution_isPresentation","hard_negative":true,"metrics":{"chosen_tokens":201,"rejected_tokens":8,"token_jaccard":0.033708,"token_length_ratio":0.039801},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"0dc98acdc2297bf8573177ca220ad5e9868d119521c8a0d7997adb374644e533","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.Presentation.Basic\npublic import Mathlib.RingTheory.Kaehler.Polynomial\npublic import Mathlib.RingTheory.Extension.Cotangent.Basic\npublic import Mathlib.RingTheory.Extension.Presentation.Basic\n\nNamespace:\nAlgebra.Presentation\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Presentation of the module of differentials\n\nGiven a presentation of an `R`-algebra `S`, we obtain a presentation\nof the `S`-module `Ω[S⁄R]`.\n\nAssume `pres : Algebra.Presentation R S` is a presentation of `S` as an `R`-algebra.\nWe then have a type `ι` for the generators, a type `σ` for the relations,\nand for each `r : σ` we have the relation `pres.relation r` in `pres.Ring` (which is\na ring of polynomials over `R` with variables indexed by `ι`).\nThen, `Ω[pres.Ring⁄R]` identifies to the free module on the type `ι`, and\nfor each `r : σ`, we may consider the image of the differential of `pres.relation r`\nin this free module, and by using the (surjective) map `pres.Ring → S`, we obtain\nan element `pres.differentialsRelations.relation r` in the free `S`-module on `ι`.\nThe main result in this file is that `Ω[S⁄R]` identifies to the quotient of the\nfree `S`-module on `ι` by the submodule generated by these\nelements `pres.differentialsRelations.relation r`. We show this as a consequence\nof `Algebra.Extension.exact_cotangentComplex_toKaehler`\nfrom the file `Mathlib/RingTheory/Extension/Cotangent/Basic.lean`.\n\n-/\n\n@[expose] public section\n\nopen Module\n\nuniverse w' t w u v\n\nnamespace Algebra.Presentation\n\nopen KaehlerDifferential\n\nvariable {R : Type u} {S : Type v} {ι : Type w} {σ : Type t} [CommRing R] [CommRing S] [Algebra R S]\n (pres : Algebra.Presentation R S ι σ)\n\n/-- The shape of the presentation by generators and relations of the `S`-module `Ω[S⁄R]`\nthat is obtained from a presentation of `S` as an `R`-algebra. -/\n@[simps G R]\nnoncomputable def differentialsRelations : Module.Relations S where\n G := ι\n R := σ\n relation r :=\n Finsupp.mapRange (algebraMap pres.Ring S) (by simp)\n ((mvPolynomialBasis R ι).repr (D _ _ (pres.relation r)))\n\nnamespace differentials\n\n/-! We obtain here a few compatibilities which allow to compare the two sequences\n`(σ →₀ S) → (ι →₀ S) → Ω[S⁄R]` and\n`pres.toExtension.Cotangent →ₗ[S] pres.toExtension.CotangentSpace → Ω[S⁄R]`.\nIndeed, there is commutative diagram with a surjective map\n`hom₁ : (σ →₀ S) →ₗ[S] pres.toExtension.Cotangent` on the left and\nbijections on the middle and on the right. Then, the exactness of the first\nsequence shall follow from the exactness of the second which is\n`Algebra.Extension.exact_cotangentComplex_toKaehler`. -/\n\n/-- Same as `comm₂₃` below, but here we have not yet constructed `differentialsSolution`. -/\nlemma comm₂₃' : pres.toExtension.toKaehler.comp pres.cotangentSpaceBasis.repr.symm.toLinearMap =\n Finsupp.linearCombination S (fun g ↦ D _ _ (pres.val g)) := by\n ext\n simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- The canonical map `(σ →₀ S) →ₗ[S] pres.toExtension.Cotangent`. -/\nnoncomputable def hom₁ : (σ →₀ S) →ₗ[S] pres.toExtension.Cotangent :=\n Finsupp.linearCombination S (fun r ↦ Extension.Cotangent.mk ⟨pres.relation r, by simp⟩)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma hom₁_single (r : σ) :\n hom₁ pres (Finsupp.single r 1) = Extension.Cotangent.mk ⟨pres.relation r, by simp⟩ := by\n simp [hom₁]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma surjective_hom₁ : Function.Surjective (hom₁ pres) := by\n let φ : (σ →₀ S) →ₗ[pres.Ring] pres.toExtension.Cotangent :=\n { toFun := hom₁ pres\n map_add' := by simp\n map_smul' := by simp }\n change Function.Surjective φ\n have h₁ := Algebra.Extension.Cotangent.mk_surjective (P := pres.toExtension)\n have h₂ : Submodule.span pres.Ring\n (Set.range (fun r ↦ (⟨pres.relation r, by simp⟩ : pres.ker))) = ⊤ := by\n refine Submodule.map_injective_of_injective (f := Submodule.subtype pres.ker)\n Subtype.coe_injective ?_\n rw [Submodule.map_top, Submodule.range_subtype, Submodule.map_span,\n Submodule.coe_subtype, Ideal.submodule_span_eq]\n simp only [← pres.span_range_relation_eq_ker]\n congr\n aesop\n rw [← LinearMap.range_eq_top] at h₁ ⊢\n rw [← top_le_iff, ← h₁, LinearMap.range_eq_map, ← h₂]\n dsimp\n rw [Submodule.map_span_le]\n rintro _ ⟨r, rfl⟩\n simp only [LinearMap.mem_range]\n refine ⟨Finsupp.single r 1, ?_⟩\n simp only [LinearMap.coe_mk, AddHom.coe_mk, hom₁_single, φ]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma comm₁₂_single (r : σ) :\n pres.toExtension.cotangentComplex (hom₁ pres (Finsupp.single r 1)) =\n pres.cotangentSpaceBasis.repr.symm ((differentialsRelations pres).relation r) := by\n simp only [hom₁, Finsupp.linearCombination_single, one_smul, differentialsRelations,\n Basis.repr_symm_apply, Extension.cotangentComplex_mk]\n exact pres.cotangentSpaceBasis.repr.injective (by ext; simp)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma comm₁₂ : pres.toExtension.cotangentComplex.comp (hom₁ pres) =\n pres.cotangentSpaceBasis.repr.symm.comp (differentialsRelations pres).map := by\n ext r\n have := (differentialsRelations pres).map_single\n dsimp at this ⊢\n rw [comm₁₂_single, this]\n\nend differentials\n\nset_option backward.isDefEq.respectTransparency false in\nopen differentials in\n/-- The `S`-module `Ω[S⁄R]` contains an obvious solution to the system of linear\nequations `pres.differentialsRelations.Solution` when `pres` is a presentation\nof `S` as an `R`-algebra. -/\nnoncomputable def differentialsSolution :\n pres.differentialsRelations.Solution Ω[S⁄R] where\n var g := D _ _ (pres.val g)\n linearCombination_var_relation r := by\n simp only [LinearMap.coe_comp, LinearEquiv.coe_coe,\n Function.comp_apply, ← comm₂₃', ← comm₁₂_single]\n apply DFunLike.congr_fun (Function.Exact.linearMap_comp_eq_zero\n (pres.toExtension.exact_cotangentComplex_toKaehler))\n\nlemma differentials.comm₂₃ :\n pres.toExtension.toKaehler.comp pres.cotangentSpaceBasis.repr.symm.toLinearMap =\n pres.differentialsSolution.π :=\n comm₂₃' pres\n\nopen differentials in\n\nTarget:\nlemma differentialsSolution_isPresentation :\n pres.differentialsSolution.IsPresentation :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"525d75aee1af541686b7a4d90a1293ff2adc0b2a8946ad6b34a46b1c6ebbd890","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Module","family_id":"differentialssolution_ispresentation","file_id":"mathlib/Mathlib/Algebra/Module/Presentation/Differentials.lean","sample_id":"71d40dbf91009a8d289f32f35fd098eb312b3c5f7d77a88722243c78657ed903"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8bd307b8cc9c99cbc4bc3592dc0b57d7d573a0a2f38015d6a57bbe306ee61b93","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a435ccdd383599bddc503b771663e3c57c997f89c0cbac7d6a0a3dcc2c74b5cb","source_sha256":"da4cd279b2edf42975da9f895fb47e84796c353c7d0f3ffb104f564078fc4165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n induction Δ' using SimplexCategory.rec with | _ m\n obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i fun h => by\n rw [← h] at h₁\n exact h₁ rfl)\n rcases k with _ | k\n · change n = m + 1 at hk\n subst hk\n obtain ⟨j, rfl⟩ := eq_δ_of_mono i\n rw [Isδ₀.iff] at h₂\n have h₃ : 1 ≤ (j : ℕ) := by\n by_contra h\n exact h₂ (by simpa only [Fin.ext_iff, not_le, Nat.lt_one_iff] using! h)\n exact (HigherFacesVanish.of_P (m + 1) m).comp_δ_eq_zero j h₂ (by lia)\n · simp only [← add_assoc] at hk\n clear h₂ hi\n subst hk\n obtain ⟨j₁ : Fin (_ + 1), i, rfl⟩ :=\n eq_comp_δ_of_not_surjective i fun h => by\n rw [← SimplexCategory.epi_iff_surjective] at h\n grind [→ le_of_epi]\n obtain ⟨j₂, i, rfl⟩ :=\n eq_comp_δ_of_not_surjective i fun h => by\n rw [← SimplexCategory.epi_iff_surjective] at h\n grind [→ le_of_epi]\n by_cases hj₁ : j₁ = 0\n · subst hj₁\n rw [assoc, ← SimplexCategory.δ_comp_δ'' (Fin.zero_le _)]\n simp only [op_comp, X.map_comp, assoc, PInfty_f]\n erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ j₂.succ_ne_zero, zero_comp]\n simp only [Fin.succ]\n lia\n · simp only [op_comp, X.map_comp, assoc, PInfty_f]\n erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ hj₁, zero_comp]\n by_contra\n exact hj₁ (by simp only [Fin.ext_iff, Fin.val_zero]; lia)","hard_negative":false,"metrics":{"chosen_tokens":353,"rejected_tokens":2,"token_jaccard":0.010204,"token_length_ratio":0.005666},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"0e9e49475a9851a0af41ca07f6098c5a5c19b38fd1fda7008202191e358eb513","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicTopology.DoldKan.GammaCompN\npublic import Mathlib.AlgebraicTopology.DoldKan.NReflectsIso\n\nNamespace:\nAlgebraicTopology.DoldKan\n\nLocal context:\n/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-! # The unit isomorphism of the Dold-Kan equivalence\n\nIn order to construct the unit isomorphism of the Dold-Kan equivalence,\nwe first construct natural transformations\n`Γ₂N₁.natTrans : N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)` and\n`Γ₂N₂.natTrans : N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`.\nIt is then shown that `Γ₂N₂.natTrans` is an isomorphism by using\nthat it becomes an isomorphism after the application of the functor\n`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`\nwhich reflects isomorphisms.\n\n(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)\n\n-/\n\n@[expose] public section\n\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents\n SimplexCategory Opposite SimplicialObject Simplicial DoldKan\n\nnamespace AlgebraicTopology\n\nnamespace DoldKan\n\nvariable {C : Type*} [Category* C] [Preadditive C]\n\nTarget:\ntheorem PInfty_comp_map_mono_eq_zero (X : SimplicialObject C) {n : ℕ} {Δ' : SimplexCategory}\n (i : Δ' ⟶ ⦋n⦌) [hi : Mono i] (h₁ : Δ'.len ≠ n) (h₂ : ¬Isδ₀ i) :\n PInfty.f n ≫ X.map i.op = 0 :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/DoldKan","family_id":"pinfty_comp_map_mono_eq_zero","file_id":"mathlib/Mathlib/AlgebraicTopology/DoldKan/NCompGamma.lean","sample_id":"a435ccdd383599bddc503b771663e3c57c997f89c0cbac7d6a0a3dcc2c74b5cb"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"30bb36978b5aceacdd29f48af8c30b501b8e69410ab9dd4e1b61315431e61ee1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"71dbc31658ac1ff5aa5818dcc2905dbc1accca7650707a0a4c268713c2ccc548","source_sha256":"72246782b71daa80cd3a53e10741fb7d5a50defa6fdac5ddb21bb2fb8eb02883","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← LinearMap.det_toMatrix <| basis ..]\n have : !![z.re, a * z.im; z.im, z.re + b * z.im].det = z.norm := by\n simp [norm]\n ring\n convert! this\n apply LinearEquiv.eq_symm_apply _ |>.mp\n ext1 w\n apply basis .. |>.repr.injective\n apply DFunLike.coe_injective\n rw [LinearMap.toMatrix_symm, Matrix.repr_toLin]\n ext i\n fin_cases i\n <;> simp\n <;> ring","hard_negative":false,"metrics":{"chosen_tokens":105,"rejected_tokens":5,"token_jaccard":0.038462,"token_length_ratio":0.047619},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"0ea19727a8187add684a03ef90602f756e43d043954b6d6d5e835abf1ac7155a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.QuadraticAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Determinant\n\nNamespace:\nQuadraticAlgebra\n\nLocal context:\n/-\nCopyright (c) 2025 Snir Broshi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Snir Broshi\n-/\n/-!\n# Quadratic Algebra\n\nWe prove that the expression for the norm of an element in a quadratic algebra comes from looking at\nthe endomorphism defined by left multiplication by that element and taking its determinant.\n-/\n\npublic section\n\nnamespace QuadraticAlgebra\n\nvariable {R : Type*} [CommRing R] {a b : R}\n\n/-- The norm of an element in a quadratic algebra is the determinant of the endomorphism defined by\nleft multiplication by that element. -/\n@[simp]\n\nTarget:\ntheorem det_toLinearMap_eq_norm (z : QuadraticAlgebra R a b) :\n (DistribSMul.toLinearMap R (QuadraticAlgebra R a b) z).det = z.norm :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/QuadraticAlgebra","family_id":"det_tolinearmap_eq_norm","file_id":"mathlib/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean","sample_id":"71dbc31658ac1ff5aa5818dcc2905dbc1accca7650707a0a4c268713c2ccc548"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a8eb3c5891260403cb7ab35d3f5a3988827b89009dfef4f81dbe53a8bc63f578","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d8b24639b34779d57bd85557d3fc1543fd94c60c3e248f88189ff1b262443415","source_sha256":"38d64e4f1a0e05f9858787ff51b94222506a7fd69d13ef99d2c65865e8c1dd3f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases x with - | x <;> simp! [*, functor_norm, Option.traverse]","hard_negative":false,"metrics":{"chosen_tokens":21,"rejected_tokens":2,"token_jaccard":0.05,"token_length_ratio":0.095238},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"0f690aea1589bf4985c4c59e5e55febf44ec0be0bac1b1bef83ccc140381afef","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Applicative\npublic import Mathlib.Control.Traversable.Basic\npublic import Mathlib.Data.List.Forall2\npublic import Mathlib.Data.Set.Functor\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# LawfulTraversable instances\n\nThis file provides instances of `LawfulTraversable` for types from the core library: `Option`,\n`List` and `Sum`.\n-/\n\npublic section\n\n\nuniverse u v\n\nsection Option\n\nopen Functor\n\nvariable {F G : Type u → Type u}\nvariable [Applicative F] [Applicative G]\nvariable [LawfulApplicative G]\n\ntheorem Option.id_traverse {α} (x : Option α) : Option.traverse (pure : α → Id α) x = pure x := by\n cases x <;> rfl\n\ntheorem Option.comp_traverse {α β γ} (f : β → F γ) (g : α → G β) (x : Option α) :\n Option.traverse (Comp.mk ∘ (f <$> ·) ∘ g) x =\n Comp.mk (Option.traverse f <$> Option.traverse g x) := by\n cases x <;> (simp [Option.traverse, Option.mapM, functor_norm] <;> rfl)\n\ntheorem Option.traverse_eq_map_id {α β} (f : α → β) (x : Option α) :\n Option.traverse ((pure : _ → Id _) ∘ f) x = (pure : _ → Id _) (f <$> x) := by cases x <;> rfl\n\nvariable (η : ApplicativeTransformation F G)\n\nTarget:\ntheorem Option.naturality [LawfulApplicative F] {α β} (f : α → F β) (x : Option α) :\n η (Option.traverse f x) = Option.traverse (@η _ ∘ f) x :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Control/Traversable","family_id":"option","file_id":"mathlib/Mathlib/Control/Traversable/Instances.lean","sample_id":"d8b24639b34779d57bd85557d3fc1543fd94c60c3e248f88189ff1b262443415"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c9dbd881a5ed47f31840c085355e71ed7e291a1211ad303c942b7229e665977","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"4109bb61b2ecee0dfdac6e7d4542780209fc3eb9ecddf371bea7de46caafdf45","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"70715065c8baaa52e3064ea8d7edcf518d16d6d17d8c5de1a85ed448cd5718fc","source_sha256":"489e94b5a0fdc1e85b9de912615179de095084afc00e827ea680f3735104c593","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Perm.subsingleton_eq_refl e, coe_refl]","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":15,"token_jaccard":0.714286,"token_length_ratio":1.5},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"0f994ae95e0125b671c98bab2a6f00f9c3f426926f5cf3a15c078de7a3bb7baa","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.FunLike.Equiv\npublic import Mathlib.Data.Quot\npublic import Mathlib.Data.Subtype\npublic import Mathlib.Logic.Unique\npublic import Mathlib.Tactic.Simps.Basic\npublic import Mathlib.Tactic.Substs\nimport Mathlib.Tactic.Attr.Register\n\nNamespace:\nEquiv\n\nLocal context:\n/-\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/-!\n# Equivalence between types\n\nIn this file we define two types:\n\n* `Equiv α β` a.k.a. `α ≃ β`: a bijective map `α → β` bundled with its inverse map; we use this (and\n not equality!) to express that various `Type`s or `Sort`s are equivalent.\n\n* `Equiv.Perm α`: the group of permutations `α ≃ α`. More lemmas about `Equiv.Perm` can be found in\n `Mathlib/GroupTheory/Perm/`.\n\nThen we define\n\n* canonical isomorphisms between various types: e.g.,\n\n - `Equiv.refl α` is the identity map interpreted as `α ≃ α`;\n\n* operations on equivalences: e.g.,\n\n - `Equiv.symm e : β ≃ α` is the inverse of `e : α ≃ β`;\n\n - `Equiv.trans e₁ e₂ : α ≃ γ` is the composition of `e₁ : α ≃ β` and `e₂ : β ≃ γ` (note the order\n of the arguments!);\n\n* definitions that transfer some instances along an equivalence. By convention, we transfer\n instances from right to left.\n\n - `Equiv.inhabited` takes `e : α ≃ β` and `[Inhabited β]` and returns `Inhabited α`;\n - `Equiv.unique` takes `e : α ≃ β` and `[Unique β]` and returns `Unique α`;\n - `Equiv.decidableEq` takes `e : α ≃ β` and `[DecidableEq β]` and returns `DecidableEq α`.\n\n More definitions of this kind can be found in other files.\n E.g., `Mathlib/Algebra/Group/TransferInstance.lean` does it for `Group`,\n `Mathlib/Algebra/Module/TransferInstance.lean` does it for `Module`, and similar files exist for\n other algebraic type classes.\n\nMany more such isomorphisms and operations are defined in `Mathlib/Logic/Equiv/Basic.lean`.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n@[expose] public section\n\nopen Function\n\nuniverse u v w z\n\nvariable {α : Sort u} {β : Sort v} {γ : Sort w}\n\n/-- `α ≃ β` is the type of functions from `α → β` with a two-sided inverse. -/\nstructure Equiv (α : Sort*) (β : Sort _) where\n /-- The forward map of an equivalence.\n\n Do NOT use directly. Use the coercion instead. -/\n protected toFun : α → β\n /-- The backward map of an equivalence.\n\n Do NOT use `e.invFun` directly. Use the coercion of `e.symm` instead. -/\n protected invFun : β → α\n protected left_inv : LeftInverse invFun toFun := by intro; first | rfl | ext <;> rfl\n protected right_inv : RightInverse invFun toFun := by intro; first | rfl | ext <;> rfl\n\n@[inherit_doc]\ninfixl:25 \" ≃ \" => Equiv\n\n/-- Turn an element of a type `F` satisfying `EquivLike F α β` into an actual\n`Equiv`. This is declared as the default coercion from `F` to `α ≃ β`. -/\n@[coe]\ndef EquivLike.toEquiv {F} [EquivLike F α β] (f : F) : α ≃ β where\n toFun := f\n invFun := EquivLike.inv f\n left_inv := EquivLike.left_inv f\n right_inv := EquivLike.right_inv f\n\n/-- Any type satisfying `EquivLike` can be cast into `Equiv` via `EquivLike.toEquiv`. -/\ninstance {F} [EquivLike F α β] : CoeTC F (α ≃ β) :=\n ⟨EquivLike.toEquiv⟩\n\n/-- `Perm α` is the type of bijections from `α` to itself. -/\nabbrev Equiv.Perm (α : Sort*) :=\n Equiv α α\n\nnamespace Equiv\n\ninstance : EquivLike (α ≃ β) α β where\n coe := Equiv.toFun\n inv := Equiv.invFun\n left_inv := Equiv.left_inv\n right_inv := Equiv.right_inv\n coe_injective' e₁ e₂ h₁ h₂ := by cases e₁; cases e₂; congr\n\n@[simp, norm_cast]\nlemma _root_.EquivLike.coe_coe {F} [EquivLike F α β] (e : F) :\n ((e : α ≃ β) : α → β) = e := rfl\n\n@[simp, grind =] theorem coe_fn_mk (f : α → β) (g l r) : (Equiv.mk f g l r : α → β) = f :=\n rfl\n\n/-- The map `(r ≃ s) → (r → s)` is injective. -/\ntheorem coe_fn_injective : @Function.Injective (α ≃ β) (α → β) (fun e => e) :=\n DFunLike.coe_injective\n\nprotected theorem coe_inj {e₁ e₂ : α ≃ β} : (e₁ : α → β) = e₂ ↔ e₁ = e₂ :=\n @DFunLike.coe_fn_eq _ _ _ _ e₁ e₂\n\n@[ext, grind ext] theorem ext {f g : Equiv α β} (H : ∀ x, f x = g x) : f = g := DFunLike.ext f g H\n\nprotected theorem congr_arg {f : Equiv α β} {x x' : α} : x = x' → f x = f x' :=\n DFunLike.congr_arg f\n\nprotected theorem congr_fun {f g : Equiv α β} (h : f = g) (x : α) : f x = g x :=\n DFunLike.congr_fun h x\n\n@[ext] theorem Perm.ext {σ τ : Equiv.Perm α} (H : ∀ x, σ x = τ x) : σ = τ := Equiv.ext H\n\nprotected theorem Perm.congr_arg {f : Equiv.Perm α} {x x' : α} : x = x' → f x = f x' :=\n Equiv.congr_arg\n\nprotected theorem Perm.congr_fun {f g : Equiv.Perm α} (h : f = g) (x : α) : f x = g x :=\n Equiv.congr_fun h x\n\n/-- Any type is equivalent to itself. -/\n@[refl] protected def refl (α : Sort*) : α ≃ α := ⟨id, id, fun _ => rfl, fun _ => rfl⟩\n\ninstance inhabited' : Inhabited (α ≃ α) := ⟨Equiv.refl α⟩\n\n/-- Inverse of an equivalence `e : α ≃ β`. -/\n@[symm]\nprotected def symm (e : α ≃ β) : β ≃ α := ⟨e.invFun, e.toFun, e.right_inv, e.left_inv⟩\n\n/-- See Note [custom simps projection] -/\ndef Simps.symm_apply (e : α ≃ β) : β → α := e.symm\n\ninitialize_simps_projections Equiv (toFun → apply, invFun → symm_apply)\n\n/-- Restatement of `Equiv.left_inv` in terms of `Function.LeftInverse`. -/\ntheorem left_inv' (e : α ≃ β) : Function.LeftInverse e.symm e := e.left_inv\n/-- Restatement of `Equiv.right_inv` in terms of `Function.RightInverse`. -/\ntheorem right_inv' (e : α ≃ β) : Function.RightInverse e.symm e := e.right_inv\n\n@[simp] lemma symm_mk (f : α → β) (g hl hr) : (mk f g hl hr).symm = mk g f hr hl := rfl\n\n/-- Composition of equivalences `e₁ : α ≃ β` and `e₂ : β ≃ γ`. -/\n@[trans]\nprotected def trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=\n ⟨e₂ ∘ e₁, e₁.symm ∘ e₂.symm, e₂.left_inv.comp e₁.left_inv, e₂.right_inv.comp e₁.right_inv⟩\n\n@[simps]\ninstance : Trans Equiv Equiv Equiv where\n trans := Equiv.trans\n\n/-- `Equiv.symm` defines an equivalence between `α ≃ β` and `β ≃ α`. -/\n@[simps! (attr := grind =)]\ndef symmEquiv (α β : Sort*) : (α ≃ β) ≃ (β ≃ α) where\n toFun := .symm\n invFun := .symm\n\n@[simp, mfld_simps] theorem toFun_as_coe (e : α ≃ β) : e.toFun = e := rfl\n\n@[simp, mfld_simps] theorem invFun_as_coe (e : α ≃ β) : e.invFun = e.symm := rfl\n\nprotected theorem injective (e : α ≃ β) : Injective e := EquivLike.injective e\n\nprotected theorem surjective (e : α ≃ β) : Surjective e := EquivLike.surjective e\n\nprotected theorem bijective (e : α ≃ β) : Bijective e := EquivLike.bijective e\n\nprotected theorem subsingleton (e : α ≃ β) [Subsingleton β] : Subsingleton α :=\n e.injective.subsingleton\n\nprotected theorem subsingleton.symm (e : α ≃ β) [Subsingleton α] : Subsingleton β :=\n e.symm.injective.subsingleton\n\ntheorem subsingleton_congr (e : α ≃ β) : Subsingleton α ↔ Subsingleton β :=\n ⟨fun _ => e.symm.subsingleton, fun _ => e.subsingleton⟩\n\ninstance equiv_subsingleton_cod [Subsingleton β] : Subsingleton (α ≃ β) :=\n ⟨fun _ _ => Equiv.ext fun _ => Subsingleton.elim _ _⟩\n\ninstance equiv_subsingleton_dom [Subsingleton α] : Subsingleton (α ≃ β) :=\n ⟨fun f _ => Equiv.ext fun _ => @Subsingleton.elim _ (Equiv.subsingleton.symm f) _ _⟩\n\ninstance permUnique [Subsingleton α] : Unique (Perm α) :=\n uniqueOfSubsingleton (Equiv.refl α)\n\ntheorem Perm.subsingleton_eq_refl [Subsingleton α] (e : Perm α) : e = Equiv.refl α :=\n Subsingleton.elim _ _\n\nprotected theorem nontrivial {α β} (e : α ≃ β) [Nontrivial β] : Nontrivial α :=\n e.surjective.nontrivial\n\ntheorem nontrivial_congr {α β} (e : α ≃ β) : Nontrivial α ↔ Nontrivial β :=\n ⟨fun _ ↦ e.symm.nontrivial, fun _ ↦ e.nontrivial⟩\n\n/-- Transfer `DecidableEq` across an equivalence. -/\nprotected abbrev decidableEq (e : α ≃ β) [DecidableEq β] : DecidableEq α :=\n e.injective.decidableEq\n\ntheorem nonempty_congr (e : α ≃ β) : Nonempty α ↔ Nonempty β := Nonempty.congr e e.symm\n\nprotected theorem nonempty (e : α ≃ β) [Nonempty β] : Nonempty α := e.nonempty_congr.mpr ‹_›\n\n/-- If `α ≃ β` and `β` is inhabited, then so is `α`. -/\nprotected abbrev inhabited [Inhabited β] (e : α ≃ β) : Inhabited α := ⟨e.symm default⟩\n\n/-- If `α ≃ β` and `β` is a singleton type, then so is `α`. -/\nprotected abbrev unique [Unique β] (e : α ≃ β) : Unique α := e.symm.surjective.unique\n\n/-- Equivalence between equal types. -/\nprotected def cast {α β : Sort _} (h : α = β) : α ≃ β where\n toFun := cast h\n invFun := cast h.symm\n left_inv := by grind\n right_inv := by grind\n\n@[simp] theorem coe_fn_symm_mk (f : α → β) (g l r) : ((Equiv.mk f g l r).symm : β → α) = g := rfl\n\n@[simp] theorem coe_refl : (Equiv.refl α : α → α) = id := rfl\n\n/-- This cannot be a `simp` lemmas as it incorrectly matches against `e : α ≃ synonym α`, when\n`synonym α` is semireducible. This makes a mess of `Multiplicative.ofAdd` etc. -/\n\nTarget:\ntheorem Perm.coe_subsingleton {α : Type*} [Subsingleton α] (e : Perm α) : (e : α → α) = id :=\n\nProof body:\n","rejected":"by\n rw [Perm.subsingleton_eq_refl e, coe_refl]\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Equiv","family_id":"perm","file_id":"mathlib/Mathlib/Logic/Equiv/Defs.lean","sample_id":"70715065c8baaa52e3064ea8d7edcf518d16d6d17d8c5de1a85ed448cd5718fc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a2602fcb0f851fb8f71b48522066956561749031a457acc0bb80c3e8d5266e5a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da3ecd97ba2e623f6c548fe5685cd572e1f5aa21d590419b2463bcb667e9a8ce","source_sha256":"f39a78c281935d81de36ca9564987ad4a6cf6b74a66133b16f897a6f004c581d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [isConjRoot_def, minpoly.neg x, minpoly.neg y, h]","hard_negative":false,"metrics":{"chosen_tokens":17,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.117647},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"0fb2189dd2ca93c36ba42f77bab3b1c4d148a9cda411163d535b9ebb0f12d56e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Extension\npublic import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic\npublic import Mathlib.FieldTheory.Minpoly.Basic\npublic import Mathlib.FieldTheory.Normal.Defs\n\nNamespace:\nIsConjRoot\n\nLocal context:\n/-\nCopyright (c) 2024 Jiedong Jiang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jiedong Jiang\n-/\n/-!\n# Conjugate roots\n\nGiven two elements `x` and `y` of some `K`-algebra, these two elements are *conjugate roots*\nover `K` if they have the same minimal polynomial over `K`.\n\n## Main definitions\n\n* `IsConjRoot`: `IsConjRoot K x y` means `y` is a conjugate root of `x` over `K`.\n\n## Main results\n\n* `isConjRoot_iff_exists_algEquiv`: Let `L / K` be a normal field extension. For any two elements\n `x` and `y` in `L`, `IsConjRoot K x y` is equivalent to the existence of an algebra equivalence\n `σ : Gal(L/K)` such that `y = σ x`.\n* `notMem_iff_exists_ne_and_isConjRoot`: Let `L / K` be a field extension. If `x` is a separable\n element over `K` and the minimal polynomial of `x` splits in `L`, then `x` is not in the `K` iff\n there exists a different conjugate root of `x` in `L` over `K`.\n\n## TODO\n* Move `IsConjRoot` to earlier files and refactor the theorems in field theory using `IsConjRoot`.\n\n* Prove `IsConjRoot.smul`, if `x` and `y` are conjugate roots, then so are `r • x` and `r • y`.\n\n## Tags\nconjugate root, minimal polynomial\n-/\n\n@[expose] public section\n\n\nopen Polynomial minpoly Module IntermediateField\n\nvariable {R K L S A B : Type*} [CommRing R] [CommRing S] [Ring A] [Ring B] [Field K] [Field L]\nvariable [Algebra R S] [Algebra R A] [Algebra R B]\nvariable [Algebra K S] [Algebra K L] [Algebra K A] [Algebra L S]\n\nvariable (R) in\n/--\nWe say that `y` is a conjugate root of `x` over `K` if the minimal polynomial of `x` is the\nsame as the minimal polynomial of `y`.\n-/\ndef IsConjRoot (x y : A) : Prop := minpoly R x = minpoly R y\n\n/--\nThe definition of conjugate roots.\n-/\ntheorem isConjRoot_def {x y : A} : IsConjRoot R x y ↔ minpoly R x = minpoly R y := Iff.rfl\n\nnamespace IsConjRoot\n\n/--\nEvery element is a conjugate root of itself.\n-/\n@[refl] theorem refl {x : A} : IsConjRoot R x x := rfl\n\n/--\nIf `y` is a conjugate root of `x`, then `x` is also a conjugate root of `y`.\n-/\n@[symm] theorem symm {x y : A} (h : IsConjRoot R x y) : IsConjRoot R y x := Eq.symm h\n\n/--\nIf `y` is a conjugate root of `x` and `z` is a conjugate root of `y`, then `z` is a conjugate\nroot of `x`.\n-/\n@[trans] theorem trans {x y z : A} (h₁ : IsConjRoot R x y) (h₂ : IsConjRoot R y z) :\n IsConjRoot R x z := Eq.trans h₁ h₂\n\nvariable (R A) in\n/--\nThe setoid structure on `A` defined by the equivalence relation of `IsConjRoot R · ·`.\n-/\n@[implicit_reducible]\ndef setoid : Setoid A where\n r := IsConjRoot R\n iseqv := ⟨fun _ => refl, symm, trans⟩\n\ntheorem comm {x y : A} : IsConjRoot R x y ↔ IsConjRoot R y x :=\n ⟨symm, symm⟩\n\n/--\nLet `p` be the minimal polynomial of `x`. If `y` is a conjugate root of `x`, then `p y = 0`.\n-/\ntheorem aeval_eq_zero {x y : A} (h : IsConjRoot R x y) : aeval y (minpoly R x) = 0 :=\n h ▸ minpoly.aeval R y\n\n/--\nLet `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y + r` is a\nconjugate root of `x + r`.\n-/\ntheorem add_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) :\n IsConjRoot K (x + algebraMap K S r) (y + algebraMap K S r) := by\n rw [isConjRoot_def, minpoly.add_algebraMap x r, minpoly.add_algebraMap y r, h]\n\n/--\nLet `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y - r` is a\nconjugate root of `x - r`.\n-/\ntheorem sub_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) :\n IsConjRoot K (x - algebraMap K S r) (y - algebraMap K S r) := by\n simpa only [sub_eq_add_neg, map_neg] using add_algebraMap (-r) h\n\n/--\nIf `y` is a conjugate root of `x`, then `-y` is a conjugate root of `-x`.\n-/\n\nTarget:\ntheorem neg {x y : S} (h : IsConjRoot K x y) :\n IsConjRoot K (-x) (-y) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory/Minpoly","family_id":"neg","file_id":"mathlib/Mathlib/FieldTheory/Minpoly/IsConjRoot.lean","sample_id":"da3ecd97ba2e623f6c548fe5685cd572e1f5aa21d590419b2463bcb667e9a8ce"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f4fada5c5bff3d6bc9e29d14916de44cf82fcfaab68c0ed5737f190445d775d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e40b4767a1389b751ce40c1da0e998e07eb893c76cfb3e542e8c8eaab9e27cbe","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fc8a87fbf987153a9f95d9d74c75f82e1fb755b3b65142ba97d0535c075a4809","source_sha256":"958c418e0895d6f0133c0f2d3fa1bc785024b3935ebe9bea89aa615109a727cf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n exact ⟨fun _ => h.symm.isOpenEmbedding.locallyCompactSpace,\n fun _ => h.isClosedEmbedding.locallyCompactSpace⟩","hard_negative":true,"metrics":{"chosen_tokens":23,"rejected_tokens":2,"token_jaccard":0.066667,"token_length_ratio":0.086957},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"0fc4f578f96f69123cbb2271c6f30b7d643cacc724bda078f5c18276cee8ffcd","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Equiv.Fin.Basic\npublic import Mathlib.Topology.Connected.LocallyConnected\npublic import Mathlib.Topology.DenseEmbedding\npublic import Mathlib.Topology.Connected.TotallyDisconnected\npublic import Mathlib.Topology.Baire.Lemmas\n\nNamespace:\nHomeomorph\n\nLocal context:\n/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\n/-!\n# Further properties of homeomorphisms\n\nThis file proves further properties of homeomorphisms between topological spaces.\nPretty much every topological property is preserved under homeomorphisms.\n\n-/\n\n@[expose] public section\n\nassert_not_exists Module MonoidWithZero\n\nopen Filter Function Set Topology\n\nvariable {X Y W Z : Type*}\n\nsection\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace W] [TopologicalSpace Z]\n {X' Y' : Type*} [TopologicalSpace X'] [TopologicalSpace Y']\n\nnamespace Homeomorph\n\nprotected theorem secondCountableTopology [SecondCountableTopology Y]\n (h : X ≃ₜ Y) : SecondCountableTopology X :=\n h.isInducing.secondCountableTopology\n\nprotected theorem baireSpace [BaireSpace X] (f : X ≃ₜ Y) : BaireSpace Y :=\n f.isOpenQuotientMap.baireSpace\n\n/-- If `h : X → Y` is a homeomorphism, `h(s)` is compact iff `s` is. -/\n@[simp]\ntheorem isCompact_image {s : Set X} (h : X ≃ₜ Y) : IsCompact (h '' s) ↔ IsCompact s :=\n h.isEmbedding.isCompact_iff.symm\n\n/-- If `h : X → Y` is a homeomorphism, `h⁻¹(s)` is compact iff `s` is. -/\n@[simp]\ntheorem isCompact_preimage {s : Set Y} (h : X ≃ₜ Y) : IsCompact (h ⁻¹' s) ↔ IsCompact s := by\n rw [← image_symm]; exact h.symm.isCompact_image\n\n/-- If `h : X → Y` is a homeomorphism, `s` is σ-compact iff `h(s)` is. -/\n@[simp]\ntheorem isSigmaCompact_image {s : Set X} (h : X ≃ₜ Y) :\n IsSigmaCompact (h '' s) ↔ IsSigmaCompact s :=\n h.isEmbedding.isSigmaCompact_iff.symm\n\n/-- If `h : X → Y` is a homeomorphism, `h⁻¹(s)` is σ-compact iff `s` is. -/\n@[simp]\ntheorem isSigmaCompact_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsSigmaCompact (h ⁻¹' s) ↔ IsSigmaCompact s := by\n rw [← image_symm]; exact h.symm.isSigmaCompact_image\n\n@[simp]\ntheorem isPreconnected_image {s : Set X} (h : X ≃ₜ Y) :\n IsPreconnected (h '' s) ↔ IsPreconnected s :=\n ⟨fun hs ↦ by simpa only [image_symm, preimage_image]\n using hs.image _ h.symm.continuous.continuousOn,\n fun hs ↦ hs.image _ h.continuous.continuousOn⟩\n\n@[simp]\ntheorem isPreconnected_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsPreconnected (h ⁻¹' s) ↔ IsPreconnected s := by\n rw [← image_symm, isPreconnected_image]\n\n@[simp]\ntheorem isConnected_image {s : Set X} (h : X ≃ₜ Y) :\n IsConnected (h '' s) ↔ IsConnected s :=\n image_nonempty.and h.isPreconnected_image\n\n@[simp]\ntheorem isConnected_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsConnected (h ⁻¹' s) ↔ IsConnected s := by\n rw [← image_symm, isConnected_image]\n\ntheorem image_connectedComponentIn {s : Set X} (h : X ≃ₜ Y) {x : X} (hx : x ∈ s) :\n h '' connectedComponentIn s x = connectedComponentIn (h '' s) (h x) := by\n refine (h.continuous.image_connectedComponentIn_subset hx).antisymm ?_\n have := h.symm.continuous.image_connectedComponentIn_subset (mem_image_of_mem h hx)\n rwa [image_subset_iff, h.preimage_symm, h.image_symm, h.preimage_image, h.symm_apply_apply]\n at this\n\n@[simp]\ntheorem comap_cocompact (h : X ≃ₜ Y) : comap h (cocompact Y) = cocompact X :=\n (comap_cocompact_le h.continuous).antisymm <|\n (hasBasis_cocompact.le_basis_iff (hasBasis_cocompact.comap h)).2 fun K hK =>\n ⟨h ⁻¹' K, h.isCompact_preimage.2 hK, Subset.rfl⟩\n\n@[simp]\ntheorem map_cocompact (h : X ≃ₜ Y) : map h (cocompact X) = cocompact Y := by\n rw [← h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected theorem compactSpace [CompactSpace X] (h : X ≃ₜ Y) : CompactSpace Y where\n isCompact_univ := h.symm.isCompact_preimage.2 isCompact_univ\n\ntheorem isDenseEmbedding (h : X ≃ₜ Y) : IsDenseEmbedding h :=\n { h.isEmbedding with dense := h.surjective.denseRange }\n\nprotected lemma totallyDisconnectedSpace (h : X ≃ₜ Y) [tdc : TotallyDisconnectedSpace X] :\n TotallyDisconnectedSpace Y :=\n (totallyDisconnectedSpace_iff Y).mpr\n (h.range_coe ▸ ((IsEmbedding.isTotallyDisconnected_range h.isEmbedding).mpr tdc))\n\n@[simp]\ntheorem map_punctured_nhds_eq (h : X ≃ₜ Y) (x : X) : map h (𝓝[≠] x) = 𝓝[≠] (h x) := by\n convert! h.isEmbedding.map_nhdsWithin_eq ({ x }ᶜ) x\n rw [h.image_compl, Set.image_singleton]\n\n@[simp]\ntheorem comap_coclosedCompact (h : X ≃ₜ Y) : comap h (coclosedCompact Y) = coclosedCompact X :=\n (hasBasis_coclosedCompact.comap h).eq_of_same_basis <| by\n simpa [comp_def] using hasBasis_coclosedCompact.comp_surjective h.injective.preimage_surjective\n\n@[simp]\ntheorem map_coclosedCompact (h : X ≃ₜ Y) : map h (coclosedCompact X) = coclosedCompact Y := by\n rw [← h.comap_coclosedCompact, map_comap_of_surjective h.surjective]\n\n/-- If the codomain of a homeomorphism is a locally connected space, then the domain is also\na locally connected space. -/\ntheorem locallyConnectedSpace [i : LocallyConnectedSpace Y] (h : X ≃ₜ Y) :\n LocallyConnectedSpace X := by\n have : ∀ x, (𝓝 x).HasBasis (fun s ↦ IsOpen s ∧ h x ∈ s ∧ IsConnected s)\n (h.symm '' ·) := fun x ↦ by\n rw [← h.symm_map_nhds_eq]\n exact (i.1 _).map _\n refine locallyConnectedSpace_of_connected_bases _ _ this fun _ _ hs ↦ ?_\n exact hs.2.2.2.image _ h.symm.continuous.continuousOn\n\n/-- The codomain of a homeomorphism is a locally compact space if and only if\nthe domain is a locally compact space. -/\n\nTarget:\ntheorem locallyCompactSpace_iff (h : X ≃ₜ Y) :\n LocallyCompactSpace X ↔ LocallyCompactSpace Y :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_fc8a87fbf987","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"f04a73ef4c152824bc6383b610a34ec10b5e48a21619e4b6f1b587f045648ca7","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Homeomorph","family_id":"locallycompactspace_iff","file_id":"mathlib/Mathlib/Topology/Homeomorph/Lemmas.lean","sample_id":"fc8a87fbf987153a9f95d9d74c75f82e1fb755b3b65142ba97d0535c075a4809"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e6c9973add2c55eb451a24c7a6914e454c6fdef9a6fc1767e9b32475061ed644","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f59f776c9473025e81d7ec9f41a8f825d6029f48b5179462995f7613d2346168","source_sha256":"651dce3b94e5b311088fa509a50eb8110baabffebf693d59dd3bad38cea600c6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [Set.mem_prod, Prod.fst_neg, Set.mem_pi, Set.mem_univ, Pi.neg_apply,\n mem_ball_zero_iff, norm_neg, Real.norm_eq_abs, forall_true_left, Subtype.forall,\n Prod.snd_neg] at hx ⊢\n exact hx","hard_negative":false,"metrics":{"chosen_tokens":47,"rejected_tokens":2,"token_jaccard":0.035714,"token_length_ratio":0.042553},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"1009930c392cc41d025a02b1406b68a0e2bfde0dcdafeb06d12a8ec8e6d8c27d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.Group.GeometryOfNumbers\npublic import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls\npublic import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic\npublic import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup\n\nNamespace:\nNumberField.mixedEmbedding\n\nLocal context:\n/-\nCopyright (c) 2022 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Xavier Roblot\n-/\n/-!\n# Convex Bodies\n\nThe file contains the definitions of several convex bodies lying in the mixed space `ℝ^r₁ × ℂ^r₂`\nassociated to a number field of signature `K` and proves several existence theorems by applying\n*Minkowski Convex Body Theorem* to those.\n\n## Main definitions and results\n\n* `NumberField.mixedEmbedding.convexBodyLT`: The set of points `x` such that `‖x w‖ < f w` for all\n infinite places `w` with `f : InfinitePlace K → ℝ≥0`.\n\n* `NumberField.mixedEmbedding.convexBodySum`: The set of points `x` such that\n `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B`\n\n* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_lt`: Let `I` be a fractional ideal of `K`.\n Assume that `f` is such that `minkowskiBound K I < volume (convexBodyLT K f)`, then there exists a\n nonzero algebraic number `a` in `I` such that `w a < f w` for all infinite places `w`.\n\n* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_of_norm_le`: Let `I` be a fractional ideal\n of `K`. Assume that `B` is such that `minkowskiBound K I < volume (convexBodySum K B)` (see\n `convexBodySum_volume` for the computation of this volume), then there exists a nonzero algebraic\n number `a` in `I` such that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`.\n\n## Tags\n\nnumber field, infinite places\n-/\n\n@[expose] public section\n\nvariable (K : Type*) [Field K]\n\nnamespace NumberField.mixedEmbedding\n\nopen NumberField NumberField.InfinitePlace Module\n\nsection convexBodyLT\n\nopen Metric NNReal\n\nvariable (f : InfinitePlace K → ℝ≥0)\n\n/-- The convex body defined by `f`: the set of points `x : E` such that `‖x w‖ < f w` for all\ninfinite places `w`. -/\nabbrev convexBodyLT : Set (mixedSpace K) :=\n (Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } => ball 0 (f w))) ×ˢ\n (Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } => ball 0 (f w)))\n\ntheorem convexBodyLT_mem {x : K} :\n mixedEmbedding K x ∈ (convexBodyLT K f) ↔ ∀ w : InfinitePlace K, w x < f w := by\n simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,\n forall_true_left, mem_ball_zero_iff, RingHom.pi_apply, ← Complex.norm_real,\n embedding_of_isReal_apply, Subtype.forall, ← forall₂_or_left, ← not_isReal_iff_isComplex, em,\n forall_true_left, norm_embedding_eq]\n\nTarget:\ntheorem convexBodyLT_neg_mem (x : mixedSpace K) (hx : x ∈ (convexBodyLT K f)) :\n -x ∈ (convexBodyLT K f) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/NumberField","family_id":"convexbodylt_neg_mem","file_id":"mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean","sample_id":"f59f776c9473025e81d7ec9f41a8f825d6029f48b5179462995f7613d2346168"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0a786c63a29f8f8a6ad111cc9d2cf6858a7e8f212b31cf748094b97c30c37643","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"af240d963e62aaa8711a1da761e560d3c34ab906546296413da6e4e1238af800","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"97745478c40faafd4cfc44e547295322c87fa94f88a62a3b71d18cdea8c1ea36","source_sha256":"664243cc517bfe84fcfa2881fa7e4b33cbb4a93e56372a947fb2d4d35413e37d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using Monoid.FG.fg_top.finite_irreducible_mem_submonoidClosure","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":5,"token_jaccard":0.181818,"token_length_ratio":0.5},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"107b22c07f306bcae5b86643f9553f0320dc0142ed10e10232f9fc342fe48b09","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Irreducible.Defs\npublic import Mathlib.GroupTheory.Finiteness\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Yaël Dillies, Patrick Luo. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Patrick Luo\n-/\n/-!\n# An affine monoid with no non-trivial unit is generated by its irreducible elements\n\nThis file proves that an additive cancellative monoid with no non-trivial unit unit is generated by\nits irreducible elements.\n-/\n\npublic section\n\nvariable {M : Type*}\n\nsection CommMonoid\nvariable [CommMonoid M] [Subsingleton Mˣ] {S : Set M}\n\n/-- Any set `S` inside a monoid with a single unit contains the irreducible elements of the\nsubmonoid it generates. -/\n@[to_additive /-- Any set `S` inside an additive monoid with a single unit contains the irreducible\nelements of the submonoid it generates. -/]\nlemma irreducible_mem_submonoidClosure_subset : {p ∈ Submonoid.closure S | Irreducible p} ⊆ S := by\n refine fun x hx ↦\n Submonoid.closure_induction (s := S) (motive := fun x _ ↦ (Irreducible x → x ∈ S))\n (fun _ hx _ ↦ hx) (by simp) (fun a b _ _ ha hb h ↦ ?_) hx.1 hx.2\n obtain rfl | rfl := h.eq_one_or_eq_one <;> simp_all\n\n/-- In a monoid with a single unit, irreducible elements lie in all generating sets. -/\n@[to_additive\n/-- In an additive monoid with a single unit, irreducible elements lie in all generating sets. -/]\nlemma irreducible_subset_of_submonoidClosure_eq_top (hS : Submonoid.closure S = ⊤) :\n {p | Irreducible p} ⊆ S := by\n simpa [hS] using irreducible_mem_submonoidClosure_subset (S := S)\n\n/-- A finitely generated submonoid of a monoid with a single unit has finitely many irreducible\nelements. -/\n@[to_additive\n/-- A finitely generated submonoid of an additive monoid with a single unit has finitely many\nirreducible elements. -/]\nlemma Submonoid.FG.finite_irreducible_mem_submonoidClosure {S : Submonoid M} (hS : S.FG) :\n {p ∈ S | Irreducible p}.Finite := by\n obtain ⟨T, hT⟩ := hS; exact T.finite_toSet.subset <| hT ▸ irreducible_mem_submonoidClosure_subset\n\nvariable [Monoid.FG M]\n\n/-- A finitely generated monoid with a single unit has finitely many irreducible elements. -/\n@[to_additive\n/-- A finitely generated additive monoid with a single unit has finitely many irreducible\nelements. -/]\n\nTarget:\nlemma finite_irreducible : {p : M | Irreducible p}.Finite :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_97745478c40f","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"f34091c52936debba1e1de1c3e5bd7e55e141e916c2846724dc94580dd672b04","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"finite_irreducible","file_id":"mathlib/Mathlib/Algebra/AffineMonoid/Irreducible.lean","sample_id":"97745478c40faafd4cfc44e547295322c87fa94f88a62a3b71d18cdea8c1ea36"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9b04864f5019d5fcf223d79992fd2afb10fb0011642bb1afc6ab7980c57f9a80","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"039a079f29ef0cd3a30b54b4901e9dab2d0f0f73861eeb146efaf0b8b1c6bc93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ded6faa6d48b99d8145f41b676cb932b10ee82b07e71517181c782fc3638c0db","source_sha256":"10e25e11aaeed3e571034bb2dc616107c37c9ec1e439be369d5af752525aea30","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun hf ↦ ?_, fun hf ↦ (mem_smallGrothendieckTopology _ _).2 ?_⟩\n · obtain ⟨U, _, _, hU⟩ := (mem_smallGrothendieckTopology _ _).1 hf\n ext y\n simp only [Set.mem_iUnion, Set.mem_range, Set.mem_univ, iff_true]\n obtain ⟨i, ⟨u, rfl⟩⟩ := ((ofArrows_mem_precoverage_iff _).1 U.mem₀).1 y\n obtain ⟨_, b, _, ⟨j⟩, fac⟩ := hU _ _ ⟨i⟩\n replace fac : b.left ≫ (f j).left = U.f i :=\n (Etale.forget _ ⋙ CategoryTheory.Over.forget _).congr_map fac\n exact ⟨j, b.left u, by simp [← fac]⟩\n · have (w : W.left) : ∃ (i : ι), w ∈ Set.range (f i).left := by\n have := Set.mem_univ w\n simpa [← hf]\n choose i z hz using this\n let V : Cover (precoverage @Etale) W.left :=\n Cover.mkOfCovers W.left (fun w ↦ (Z (i w)).left)\n (fun w ↦ (f (i w)).left) (fun w ↦ ⟨_, _, hz w⟩) inferInstance\n letI : Cover.Over X V :=\n { over w := ⟨(Z (i w)).hom⟩\n isOver_map w := by cat_disch }\n have (w : W.left) : Etale (V.X w ↘ X) := (Z (i w)).prop\n refine ⟨V, inferInstance, inferInstance, ?_⟩\n rintro _ _ ⟨w⟩\n refine ⟨_, 𝟙 _, _, ⟨i w⟩, by cat_disch⟩","hard_negative":true,"metrics":{"chosen_tokens":358,"rejected_tokens":3,"token_jaccard":0.022472,"token_length_ratio":0.00838},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"116ef9c5c3e26ca77987c42ee0087167a718c273bde3fd6007fd5755e42c874c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.Morphisms.Etale\npublic import Mathlib.AlgebraicGeometry.Sites.BigZariski\npublic import Mathlib.AlgebraicGeometry.Sites.Small\npublic import Mathlib.CategoryTheory.Limits.Elements\npublic import Mathlib.CategoryTheory.Sites.Point.Basic\n\nNamespace:\nAlgebraicGeometry.Scheme\n\nLocal context:\n/-\nCopyright (c) 2024 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten\n-/\n/-!\n\n# The étale site\n\nIn this file we define the big étale site, i.e. the étale topology as a Grothendieck topology\non the category of schemes.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nopen CategoryTheory MorphismProperty Limits\n\nnamespace AlgebraicGeometry.Scheme\n\n/-- Big étale site: the étale precoverage on the category of schemes. -/\ndef etalePrecoverage : Precoverage Scheme.{u} :=\n precoverage @Etale\n\n/-- Big étale site: the étale pretopology on the category of schemes. -/\ndef etalePretopology : Pretopology Scheme.{u} :=\n pretopology @Etale\n\n/-- Big étale site: the étale topology on the category of schemes. -/\nabbrev etaleTopology : GrothendieckTopology Scheme.{u} :=\n grothendieckTopology @Etale\n\nlemma zariskiTopology_le_etaleTopology : zariskiTopology ≤ etaleTopology := by\n apply grothendieckTopology_monotone\n intro X Y f hf\n infer_instance\n\n/-- The small étale site of a scheme is the Grothendieck topology on the\ncategory of schemes étale over `X` induced from the étale topology on `Scheme.{u}`. -/\ndef smallEtaleTopology (X : Scheme.{u}) : GrothendieckTopology X.Etale :=\n X.smallGrothendieckTopology (P := @Etale)\n\n/-- The pretopology generating the small étale site. -/\ndef smallEtalePretopology (X : Scheme.{u}) : Pretopology X.Etale :=\n X.smallPretopology (Q := @Etale) (P := @Etale)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma ofArrows_mem_smallEtaleTopology_iff\n {X : Scheme.{u}} {W : X.Etale} {ι : Type*}\n {Z : ι → X.Etale} (f : ∀ i, Z i ⟶ W) :\n Sieve.ofArrows _ f ∈ smallEtaleTopology _ _ ↔\n ⋃ i, Set.range (f i).left = .univ :=\n\nProof body:\n","rejected":"by\n exact ofArrows_mem_smallEtaleTopology_iff","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"4ed065cbb0e7fac43f0f8cbe05ec9f152f9aa41e81f1dd41baf9972413b7c18e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Sites","family_id":"ofarrows_mem_smalletaletopology_iff","file_id":"mathlib/Mathlib/AlgebraicGeometry/Sites/Etale.lean","sample_id":"ded6faa6d48b99d8145f41b676cb932b10ee82b07e71517181c782fc3638c0db"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"599464289d07256ec61782d2be1d9ba89cacfc1a18c288b401246ef6a92bb6e3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da8499cd13fb52409c3f27404e6e49d6e33f6445a6fef5f37eaef62975f7f16f","source_sha256":"efda126d5013b26b39c63e370763fbfd6cf8d87774b0c191b7a98bd3554d6c1e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply ibc.algHom_ext\n intro v\n simp [toDual_comp_apply, Algebra.algebraMap_eq_smul_one]","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.2},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"121958df2b5c971080a7185b437c7d16f0858bd41141956fcc6185e5e1d6bc80","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.Dual.Defs\npublic import Mathlib.LinearAlgebra.FreeModule.Finite.Basic\npublic import Mathlib.RingTheory.TensorProduct.IsBaseChangeFree\npublic import Mathlib.RingTheory.TensorProduct.IsBaseChangeHom\n\nNamespace:\nIsBaseChange\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Base change for the dual of a module\n\n* `Module.Dual.congr` : equivalent modules have equivalent duals.\n\nIf `f : Module.Dual R V` and `Algebra R A`, then\n\n* `Module.Dual.baseChange A f` is the element\n of `Module.Dual A (A ⊗[R] V)` deduced by base change.\n\n* `Module.Dual.baseChangeHom` is the `R`-linear map\n given by `Module.Dual.baseChange`.\n\n* `IsBaseChange.dual` : for finite free modules, taking dual commutes with base change.\n\n-/\n\n@[expose] public section\n\nnamespace Module.Dual\n\nopen TensorProduct LinearEquiv\n\nvariable {R : Type*} [CommSemiring R]\n {V : Type*} [AddCommMonoid V] [Module R V]\n {W : Type*} [AddCommMonoid W] [Module R W]\n (A : Type*) [CommSemiring A] [Algebra R A]\n\n/-- Equivalent modules have equivalent duals. -/\n@[simps!] def congr (e : V ≃ₗ[R] W) :\n Dual R V ≃ₗ[R] Dual R W := congrLeft R R e\n\n/-- `LinearMap.baseChange` for `Module.Dual`. -/\ndef baseChange : Dual R V →ₗ[R] Dual A (A ⊗[R] V) :=\n (AlgebraTensorModule.rid R A A).compRight R ∘ₗ LinearMap.baseChangeHom R A V R\n\n@[simp]\ntheorem baseChange_apply_tmul (f : Dual R V) (a : A) (v : V) :\n f.baseChange A (a ⊗ₜ v) = (f v) • a :=\n rfl\n\nvariable {B : Type*} [CommSemiring B] [Algebra R B] [Algebra A B] [IsScalarTower R A B]\n\nopen AlgebraTensorModule in\ntheorem baseChange_baseChange (f : Dual R V) :\n (f.baseChange A).baseChange B = (congr (cancelBaseChange R A B B V)).symm (f.baseChange B) := by\n ext; simp\n\nend Module.Dual\n\nnamespace IsBaseChange\n\nopen Module TensorProduct\n\nvariable {R : Type*} [CommSemiring R]\n {V : Type*} [AddCommMonoid V] [Module R V]\n {W : Type*} [AddCommMonoid W] [Module R W]\n {A : Type*} [CommSemiring A] [Algebra R A] [Module A W] [IsScalarTower R A W]\n {j : V →ₗ[R] W} (ibc : IsBaseChange A j)\n\n/-- The base change of an element of the dual. -/\nnoncomputable def toDual :\n Dual R V →ₗ[R] Dual A W :=\n linearMapLeftRightHom ibc (Algebra.linearMap R A)\n\ntheorem toDual_comp_apply (f : Dual R V) (v : V) :\n ibc.toDual f (j v) = algebraMap R A (f v) := by\n simp [toDual, linearMapLeftRightHom_comp_apply]\n\nTarget:\ntheorem toDual_apply (f : Dual R V) :\n ibc.toDual f = (f.baseChange A).congr ibc.equiv :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/Dual","family_id":"todual_apply","file_id":"mathlib/Mathlib/LinearAlgebra/Dual/BaseChange.lean","sample_id":"da8499cd13fb52409c3f27404e6e49d6e33f6445a6fef5f37eaef62975f7f16f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"30bb36978b5aceacdd29f48af8c30b501b8e69410ab9dd4e1b61315431e61ee1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"71dbc31658ac1ff5aa5818dcc2905dbc1accca7650707a0a4c268713c2ccc548","source_sha256":"72246782b71daa80cd3a53e10741fb7d5a50defa6fdac5ddb21bb2fb8eb02883","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← LinearMap.det_toMatrix <| basis ..]\n have : !![z.re, a * z.im; z.im, z.re + b * z.im].det = z.norm := by\n simp [norm]\n ring\n convert! this\n apply LinearEquiv.eq_symm_apply _ |>.mp\n ext1 w\n apply basis .. |>.repr.injective\n apply DFunLike.coe_injective\n rw [LinearMap.toMatrix_symm, Matrix.repr_toLin]\n ext i\n fin_cases i\n <;> simp\n <;> ring","hard_negative":true,"metrics":{"chosen_tokens":105,"rejected_tokens":8,"token_jaccard":0.076923,"token_length_ratio":0.07619},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"12d4773b754cdd416955c2dd02409d384ab740a438a84e599c619937e5c88de5","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.QuadraticAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Determinant\n\nNamespace:\nQuadraticAlgebra\n\nLocal context:\n/-\nCopyright (c) 2025 Snir Broshi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Snir Broshi\n-/\n/-!\n# Quadratic Algebra\n\nWe prove that the expression for the norm of an element in a quadratic algebra comes from looking at\nthe endomorphism defined by left multiplication by that element and taking its determinant.\n-/\n\npublic section\n\nnamespace QuadraticAlgebra\n\nvariable {R : Type*} [CommRing R] {a b : R}\n\n/-- The norm of an element in a quadratic algebra is the determinant of the endomorphism defined by\nleft multiplication by that element. -/\n@[simp]\n\nTarget:\ntheorem det_toLinearMap_eq_norm (z : QuadraticAlgebra R a b) :\n (DistribSMul.toLinearMap R (QuadraticAlgebra R a b) z).det = z.norm :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"a1a07a1dc96db258dc8ae7d73c93055e0bc0b90e98eed54fa173e4b687c09f83","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/QuadraticAlgebra","family_id":"det_tolinearmap_eq_norm","file_id":"mathlib/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean","sample_id":"71dbc31658ac1ff5aa5818dcc2905dbc1accca7650707a0a4c268713c2ccc548"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f2aef0814f0203717bab6778c3e9bf91fbf8a44936fb1cc7bc30f47f2dbb07f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"61aad771c0745ae7f025a7aff63a48e8098c50b76a439861d3a2b0cdbd49c72c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e61605c632db87c588307f1db5335cc30d2f905e1cf43f63f119ba678f181bf9","source_sha256":"5fe320cf8339285f3ebda4142570292583dc5699644499632f4faabcfba59b47","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [MapsTo, setOf_forall] using! isClosed_biInter fun y hy ↦ ht.preimage (hf y hy)","hard_negative":false,"metrics":{"chosen_tokens":23,"rejected_tokens":28,"token_jaccard":0.84,"token_length_ratio":1.217391},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"136b2a0a66165e1171668a121669226305aa3ef2f983329265e4e28c760497e9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homeomorph.Defs\npublic import Mathlib.Topology.Maps.Basic\npublic import Mathlib.Topology.Separation.SeparatedNhds\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\n/-!\n# Disjoint unions and products of topological spaces\n\nThis file constructs sums (disjoint unions) and products of topological spaces\nand sets up their basic theory, such as criteria for maps into or out of these\nconstructions to be continuous; descriptions of the open sets, neighborhood filters,\nand generators of these constructions; and their behavior with respect to embeddings\nand other specific classes of maps.\n\nWe also provide basic homeomorphisms, to show that sums and products are commutative, associative\nand distributive (up to homeomorphism).\n\n## Implementation note\n\nThe constructed topologies are defined using induced and coinduced topologies\nalong with the complete lattice structure on topologies. Their universal properties\n(for example, a map `X → Y × Z` is continuous if and only if both projections\n`X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of\ncontinuity. With more work we can also extract descriptions of the open sets,\nneighborhood filters and so on.\n\n## Tags\n\nproduct, sum, disjoint union\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology TopologicalSpace Set Filter Function\n\nuniverse u v u' v'\n\nvariable {X : Type u} {Y : Type v} {W Z ε ζ : Type*}\n\ninstance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X ⊕ Y) :=\n coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂\n\ninstance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X × Y) :=\n induced Prod.fst t₁ ⊓ induced Prod.snd t₂\n\nsection Prod\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W]\n [TopologicalSpace ε] [TopologicalSpace ζ]\n\n@[simp]\ntheorem continuous_prodMk {f : X → Y} {g : X → Z} :\n (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g :=\n continuous_inf_rng.trans <| continuous_induced_rng.and continuous_induced_rng\n\n@[continuity]\ntheorem continuous_fst : Continuous (@Prod.fst X Y) :=\n (continuous_prodMk.1 continuous_id).1\n\n/-- Postcomposing `f` with `Prod.fst` is continuous -/\n@[fun_prop]\ntheorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 :=\n continuous_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous -/\ntheorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst :=\n hf.comp continuous_fst\n\ntheorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p :=\n continuous_fst.continuousAt\n\n/-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).1) x :=\n continuousAt_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/\ntheorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X × Y => f x.fst) (x, y) :=\n ContinuousAt.comp hf continuousAt_fst\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) :\n ContinuousAt (fun x : X × Y => f x.fst) x :=\n hf.comp continuousAt_fst\n\ntheorem Filter.Tendsto.fst_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) :=\n continuousAt_fst.tendsto.comp h\n\n@[continuity]\ntheorem continuous_snd : Continuous (@Prod.snd X Y) :=\n (continuous_prodMk.1 continuous_id).2\n\n/-- Postcomposing `f` with `Prod.snd` is continuous -/\n@[fun_prop]\ntheorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 :=\n continuous_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous -/\ntheorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd :=\n hf.comp continuous_snd\n\ntheorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p :=\n continuous_snd.continuousAt\n\n/-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).2) x :=\n continuousAt_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/\ntheorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) :\n ContinuousAt (fun x : X × Y => f x.snd) (x, y) :=\n ContinuousAt.comp hf continuousAt_snd\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) :\n ContinuousAt (fun x : X × Y => f x.snd) x :=\n hf.comp continuousAt_snd\n\ntheorem Filter.Tendsto.snd_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) :=\n continuousAt_snd.tendsto.comp h\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous fun x => (f x, g x) :=\n continuous_prodMk.2 ⟨hf, hg⟩\n\n@[continuity]\ntheorem Continuous.prodMk_right (x : X) : Continuous fun y : Y => (x, y) := by fun_prop\n\n@[continuity]\ntheorem Continuous.prodMk_left (y : Y) : Continuous fun x : X => (x, y) := by fun_prop\n\n/-- If `f x y` is continuous in `x` for all `y ∈ s`,\nthen the set of `x` such that `f x` maps `s` to `t` is closed. -/\n\nTarget:\nlemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t)\n (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} :=\n\nProof body:\n","rejected":"by\n simpa only [MapsTo, setOf_forall] using! isClosed_biInter fun y hy ↦ ht.preimage (hf y hy)\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Constructions","family_id":"isclosed","file_id":"mathlib/Mathlib/Topology/Constructions/SumProd.lean","sample_id":"e61605c632db87c588307f1db5335cc30d2f905e1cf43f63f119ba678f181bf9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d62c14bdae60057b28370351a0b86a71b3c2207758aa2837b15ccae4509ec197","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"12ec9c288402497e6ba29fc2d007ea097af2128cad69586b46f491c1f5ed5b35","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"76b153c82addb4b4abe8baeee56a920e4e2f119e3ed0118bf67b947a0ced663a","source_sha256":"4449401fdf20870ca4f9ac299173a0357ae475a7bad6ab7ca2a374a91c09001b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨d, rfl⟩ := h\n use d\n rw [mul_assoc]","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.066667,"token_length_ratio":0.133333},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"13bf90978b70f4afbb2f0b7479c77b8ea43dbfb8817d674f0231c4c80ef141e8","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Basic\npublic import Mathlib.Tactic.Common\npublic import Batteries.Tactic.SeqFocus\n\nNamespace:\n(root)\n\nLocal context:\n/-\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, Amelia Livingston, Yury Kudryashov,\nNeil Strickland, Aaron Anderson\n-/\n/-!\n# Divisibility\n\nThis file defines the basics of the divisibility relation in the context of `(Comm)` `Monoid`s.\n\n## Main definitions\n\n* `semigroupDvd`\n\n## Implementation notes\n\nThe divisibility relation is defined for all monoids, and as such, depends on the order of\n multiplication if the monoid is not commutative. There are two possible conventions for\n divisibility in the noncommutative context, and this relation follows the convention for ordinals,\n so `a | b` is defined as `∃ c, b = a * c`.\n\n## Tags\n\ndivisibility, divides\n-/\n\n@[expose] public section\n\n\nvariable {α : Type*}\n\nsection Semigroup\n\nvariable [Semigroup α] {a b c : α}\n\n/-- There are two possible conventions for divisibility, which coincide in a `CommMonoid`.\nThis matches the convention for ordinals. -/\ninstance (priority := 100) semigroupDvd : Dvd α :=\n Dvd.mk fun a b => ∃ c, b = a * c\n\n-- TODO: this used to not have `c` explicit, but that seems to be important\n-- for use with tactics, similar to `Exists.intro`\ntheorem Dvd.intro (c : α) (h : a * c = b) : a ∣ b :=\n Exists.intro c h.symm\n\nalias dvd_of_mul_right_eq := Dvd.intro\n\ntheorem exists_eq_mul_right_of_dvd (h : a ∣ b) : ∃ c, b = a * c :=\n h\n\ntheorem dvd_def : a ∣ b ↔ ∃ c, b = a * c :=\n Iff.rfl\n\nalias dvd_iff_exists_eq_mul_right := dvd_def\n\ntheorem Dvd.elim {P : Prop} {a b : α} (H₁ : a ∣ b) (H₂ : ∀ c, b = a * c → P) : P :=\n Exists.elim H₁ H₂\n\nattribute [local simp] mul_assoc mul_comm mul_left_comm\n\n@[trans]\ntheorem dvd_trans : a ∣ b → b ∣ c → a ∣ c\n | ⟨d, h₁⟩, ⟨e, h₂⟩ => ⟨d * e, h₁ ▸ h₂.trans <| mul_assoc a d e⟩\n\nalias Dvd.dvd.trans := dvd_trans\n\n/-- Transitivity of `|` for use in `calc` blocks. -/\ninstance : IsTrans α Dvd.dvd :=\n ⟨fun _ _ _ => dvd_trans⟩\n\n@[simp]\ntheorem dvd_mul_right (a b : α) : a ∣ a * b :=\n Dvd.intro b rfl\n\ntheorem dvd_mul_of_dvd_left (h : a ∣ b) (c : α) : a ∣ b * c :=\n h.trans (dvd_mul_right b c)\n\nalias Dvd.dvd.mul_right := dvd_mul_of_dvd_left\n\ntheorem dvd_of_mul_right_dvd (h : a * b ∣ c) : a ∣ c :=\n (dvd_mul_right a b).trans h\n\n/-- An element `a` in a semigroup is primal if whenever `a` is a divisor of `b * c`, it can be\nfactored as the product of a divisor of `b` and a divisor of `c`. -/\ndef IsPrimal (a : α) : Prop := ∀ ⦃b c⦄, a ∣ b * c → ∃ a₁ a₂, a₁ ∣ b ∧ a₂ ∣ c ∧ a = a₁ * a₂\n\nvariable (α) in\n/-- A monoid is a decomposition monoid if every element is primal. An integral domain whose\nmultiplicative monoid is a decomposition monoid, is called a pre-Schreier domain; it is a\nSchreier domain if it is moreover integrally closed. -/\n@[mk_iff] class DecompositionMonoid : Prop where\n primal (a : α) : IsPrimal a\n\ntheorem exists_dvd_and_dvd_of_dvd_mul [DecompositionMonoid α] {b c a : α} (H : a ∣ b * c) :\n ∃ a₁ a₂, a₁ ∣ b ∧ a₂ ∣ c ∧ a = a₁ * a₂ := DecompositionMonoid.primal a H\n\n@[gcongr]\n\nTarget:\ntheorem mul_dvd_mul_left (a : α) (h : b ∣ c) : a * b ∣ a * c :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_76b153c82add","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"6f1462e15f736e05b3c07b72184531fa45fbaf53bb9e5cbed05aa9f8220c4765","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Divisibility","family_id":"mul_dvd_mul_left","file_id":"mathlib/Mathlib/Algebra/Divisibility/Basic.lean","sample_id":"76b153c82addb4b4abe8baeee56a920e4e2f119e3ed0118bf67b947a0ced663a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"aee59ddfe6958b15038f19255036946319da0f5a08aa7e5d278dbbe06ab56ff4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"1d415766668d47885b057aa49e16b2286d392d4a1ba7e74acf9b99a139b21239","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a0be12b25531ea1b915fbec47e5b007039e62415b37090bd30cbde3be74f5a3e","source_sha256":"2e9a501203fcdaedf24b8cbbdb6811adf4ee5e6975f40ec706beec7ece81c5a4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [LinearEquiv.finrank_eq <| quotientEquivDirectSum F b h, Module.finrank_directSum]","hard_negative":false,"metrics":{"chosen_tokens":17,"rejected_tokens":24,"token_jaccard":0.888889,"token_length_ratio":1.411765},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"14400b2a66d6c205e1e173fea8328db4c9bd50d7d9ce57261d72a54002d5c744","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ZMod.QuotientRing\npublic import Mathlib.LinearAlgebra.Dimension.Constructions\npublic import Mathlib.LinearAlgebra.FreeModule.PID\npublic import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition\npublic import Mathlib.LinearAlgebra.Quotient.Pi\n\nNamespace:\nSubmodule\n\nLocal context:\n/-\nCopyright (c) 2025 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Xavier Roblot\n-/\n/-! # Quotient of submodules of full rank in free finite modules over PIDs\n\n## Main results\n\n* `Submodule.quotientEquivPiSpan`: `M ⧸ N`, if `M` is free finite module over a PID `R` and `N`\n is a submodule of full rank, can be written as a product of quotients of `R` by principal ideals.\n\n-/\n\n@[expose] public section\n\nopen Module\nopen scoped DirectSum\n\nnamespace Submodule\n\nvariable {ι R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]\nvariable [IsDomain R] [IsPrincipalIdealRing R] [Finite ι]\n\n/--\nWe can write the quotient by a submodule of full rank over a PID as a product of quotients\nby principal ideals.\n-/\nnoncomputable def quotientEquivPiSpan (N : Submodule R M) (b : Basis ι R M)\n (h : Module.finrank R N = Module.finrank R M) :\n (M ⧸ N) ≃ₗ[R] Π i, R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R) := by\n haveI := Fintype.ofFinite ι\n -- Choose `e : M ≃ₗ N` and a basis `b'` for `M` that turns the map\n -- `f := ((Submodule.subtype N).comp e` into a diagonal matrix:\n -- there is an `a : ι → ℤ` such that `f (b' i) = a i • b' i`.\n let a := smithNormalFormCoeffs b h\n let b' := smithNormalFormTopBasis b h\n let ab := smithNormalFormBotBasis b h\n have ab_eq := smithNormalFormBotBasis_def b h\n have mem_I_iff : ∀ x, x ∈ N ↔ ∀ i, a i ∣ b'.repr x i := by\n intro x\n simp_rw [ab.mem_submodule_iff', ab, ab_eq]\n have : ∀ (c : ι → R) (i), b'.repr (∑ j : ι, c j • a j • b' j) i = a i * c i := by\n intro c i\n simp only [← mul_smul, b'.repr_sum_self, mul_comm]\n constructor\n · rintro ⟨c, rfl⟩ i\n exact ⟨c i, this c i⟩\n · rintro ha\n choose c hc using ha\n exact ⟨c, b'.ext_elem fun i => Eq.trans (hc i) (this c i).symm⟩\n -- Now we map everything through the linear equiv `M ≃ₗ (ι → R)`,\n -- which maps `N` to `N' := Π i, a i ℤ`.\n let N' : Submodule R (ι → R) := Submodule.pi Set.univ fun i => span R ({a i} : Set R)\n have : Submodule.map (b'.equivFun : M →ₗ[R] ι → R) N = N' := by\n ext x\n simp only [N', Submodule.mem_map, Submodule.mem_pi, mem_span_singleton, Set.mem_univ,\n mem_I_iff, smul_eq_mul, forall_true_left, LinearEquiv.coe_coe,\n Basis.equivFun_apply, mul_comm _ (a _), eq_comm (b := (x _))]\n constructor\n · rintro ⟨y, hy, rfl⟩ i\n exact hy i\n · rintro hdvd\n refine ⟨∑ i, x i • b' i, fun i => ?_, ?_⟩ <;> rw [b'.repr_sum_self]\n · exact hdvd i\n refine (Submodule.Quotient.equiv N N' b'.equivFun this).trans (re₂₃ := inferInstance)\n (re₃₂ := inferInstance) ?_\n classical\n exact Submodule.quotientPi (show _ → Submodule R R from fun i => span R ({a i} : Set R))\n\n/--\nQuotients by submodules of full rank of free finite `ℤ`-modules are isomorphic\nto a direct product of `ZMod`.\n-/\nnoncomputable def quotientEquivPiZMod (N : Submodule ℤ M) (b : Basis ι ℤ M)\n (h : Module.finrank ℤ N = Module.finrank ℤ M) :\n M ⧸ N ≃+ Π i, ZMod (smithNormalFormCoeffs b h i).natAbs :=\n let a := smithNormalFormCoeffs b h\n let e := N.quotientEquivPiSpan b h\n let e' : (∀ i : ι, ℤ ⧸ Ideal.span ({a i} : Set ℤ)) ≃+ ∀ i : ι, ZMod (a i).natAbs :=\n AddEquiv.piCongrRight fun i => ↑(Int.quotientSpanEquivZMod (a i))\n (↑(e : (M ⧸ N) ≃ₗ[ℤ] _) : M ⧸ N ≃+ _).trans e'\n\n/--\nA submodule of full rank of a free finite `ℤ`-module has a finite quotient.\nIt can't be an instance because of the side condition `Module.finrank ℤ N = Module.finrank ℤ M`.\n-/\ntheorem finiteQuotientOfFreeOfRankEq [Module.Free ℤ M] [Module.Finite ℤ M]\n (N : Submodule ℤ M) (h : Module.finrank ℤ N = Module.finrank ℤ M) : Finite (M ⧸ N) := by\n let b := Module.Free.chooseBasis ℤ M\n let a := smithNormalFormCoeffs b h\n let e := N.quotientEquivPiZMod b h\n have : ∀ i, NeZero (a i).natAbs := fun i ↦\n ⟨Int.natAbs_ne_zero.mpr (smithNormalFormCoeffs_ne_zero b h i)⟩\n exact Finite.of_equiv (Π i, ZMod (a i).natAbs) e.symm\n\ntheorem finiteQuotient_iff [Module.Free ℤ M] [Module.Finite ℤ M] (N : Submodule ℤ M) :\n Finite (M ⧸ N) ↔ Module.finrank ℤ N = Module.finrank ℤ M := by\n refine ⟨fun h ↦ le_antisymm (finrank_le N) <|\n ((LinearMap.lsmul ℤ M (Nat.card (M ⧸ N))).codRestrict N\n fun x ↦ ?_).finrank_le_finrank_of_injective ?_, fun h ↦ finiteQuotientOfFreeOfRankEq N h⟩\n · simpa using! AddSubgroup.nsmul_index_mem N.toAddSubgroup x\n · refine (LinearMap.lsmul_injective ?_).codRestrict _\n exact Int.ofNat_ne_zero.mpr <| Nat.card_ne_zero.mpr\n ⟨Set.nonempty_iff_univ_nonempty.mpr Set.univ_nonempty, h⟩\n\nvariable (F : Type*) [CommRing F] [Algebra F R] [Module F M] [IsScalarTower F R M]\n (b : Basis ι R M) {N : Submodule R M}\n\n/-- Decompose `M⧸N` as a direct sum of cyclic `R`-modules\n (quotients by the ideals generated by Smith coefficients of `N`). -/\nnoncomputable def quotientEquivDirectSum (h : Module.finrank R N = Module.finrank R M) :\n (M ⧸ N) ≃ₗ[F] ⨁ i, R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R) := by\n haveI := Fintype.ofFinite ι\n exact ((N.quotientEquivPiSpan b _).restrictScalars F).trans\n (DirectSum.linearEquivFunOnFintype _ _ _).symm\n\nTarget:\ntheorem finrank_quotient_eq_sum {ι} [Fintype ι] (b : Basis ι R M) [Nontrivial F]\n (h : Module.finrank R N = Module.finrank R M)\n [∀ i, Module.Free F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R))]\n [∀ i, Module.Finite F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R))] :\n Module.finrank F (M ⧸ N) =\n ∑ i, Module.finrank F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R)) :=\n\nProof body:\n","rejected":"```lean\nby\n rw [LinearEquiv.finrank_eq <| quotientEquivDirectSum F b h, Module.finrank_directSum]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/FreeModule","family_id":"finrank_quotient_eq_sum","file_id":"mathlib/Mathlib/LinearAlgebra/FreeModule/Finite/Quotient.lean","sample_id":"a0be12b25531ea1b915fbec47e5b007039e62415b37090bd30cbde3be74f5a3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"026c094e05742398ef51ec3471a1354547404d83e78eaf89d3c5e201cfb57979","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b0ea6624faaaac2d22490b52c012672eb21f6b4ce2d71dfe46fe7034344c1c00","source_sha256":"39c30fd995f1c9f0b8e74b8d494ee14295763c6d290c46b81af97a15d6bc3764","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro p q hpq\n rw [NNRat.cast_def, NNRat.cast_def, Commute.div_eq_div_iff] at hpq\n on_goal 1 => rw [← p.num_div_den, ← q.num_div_den, div_eq_div_iff]\n · norm_cast at hpq ⊢\n any_goals norm_cast\n any_goals apply den_ne_zero\n exact Nat.cast_commute ..","hard_negative":false,"metrics":{"chosen_tokens":54,"rejected_tokens":2,"token_jaccard":0.033333,"token_length_ratio":0.037037},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"14f1d083c2a39ceb7354e5e78150c9d7f56becb967c2b898d74a20389d51211b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.GroupWithZero.Units.Lemmas\npublic import Mathlib.Data.Rat.Cast.Defs\n\nNamespace:\nNNRat\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Casts of rational numbers into characteristic zero fields (or division rings).\n-/\n\n@[expose] public section\n\nopen Function\n\nvariable {F ι α β : Type*}\n\nnamespace Rat\nvariable [DivisionRing α] [CharZero α] {p q : ℚ}\n\n@[stacks 09FR \"Characteristic zero case.\"]\nlemma cast_injective : Injective ((↑) : ℚ → α)\n | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩, h => by\n have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0\n have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0\n rw [mk_eq_divInt, mk_eq_divInt] at h ⊢\n rw [cast_divInt_of_ne_zero _ (by simpa), cast_divInt_of_ne_zero _ (by simpa)] at h\n norm_cast at h\n rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq,\n ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_natCast d₁,\n ← Int.cast_mul, ← Int.cast_natCast d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0]\n at h\n\n@[simp, norm_cast] lemma cast_inj : (p : α) = q ↔ p = q := cast_injective.eq_iff\n\n@[simp, norm_cast] lemma cast_eq_zero : (p : α) = 0 ↔ p = 0 := cast_injective.eq_iff' cast_zero\nlemma cast_ne_zero : (p : α) ≠ 0 ↔ p ≠ 0 := cast_eq_zero.ne\n\n@[simp, norm_cast] lemma cast_add (p q : ℚ) : ↑(p + q) = (p + q : α) :=\n cast_add_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_sub (p q : ℚ) : ↑(p - q) = (p - q : α) :=\n cast_sub_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_mul (p q : ℚ) : ↑(p * q) = (p * q : α) :=\n cast_mul_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\nvariable (α) in\n/-- Coercion `ℚ → α` as a `RingHom`. -/\ndef castHom : ℚ →+* α where\n toFun := (↑)\n map_one' := cast_one\n map_mul' := cast_mul\n map_zero' := cast_zero\n map_add' := cast_add\n\n@[simp] lemma coe_castHom : ⇑(castHom α) = ((↑) : ℚ → α) := rfl\n\n@[simp, norm_cast] lemma cast_inv (p : ℚ) : ↑(p⁻¹) = (p⁻¹ : α) := map_inv₀ (castHom α) _\n@[simp, norm_cast] lemma cast_div (p q : ℚ) : ↑(p / q) = (p / q : α) := map_div₀ (castHom α) ..\n\n@[simp, norm_cast]\nlemma cast_zpow (p : ℚ) (n : ℤ) : ↑(p ^ n) = (p ^ n : α) := map_zpow₀ (castHom α) ..\n\n@[norm_cast]\ntheorem cast_divInt (a b : ℤ) : (a /. b : α) = a / b := by\n simp only [divInt_eq_div, cast_div, cast_intCast]\n\nend Rat\n\nnamespace NNRat\nvariable [DivisionSemiring α] [CharZero α] {p q : ℚ≥0}\n\nTarget:\nlemma cast_injective : Injective ((↑) : ℚ≥0 → α) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Rat","family_id":"cast_injective","file_id":"mathlib/Mathlib/Data/Rat/Cast/CharZero.lean","sample_id":"b0ea6624faaaac2d22490b52c012672eb21f6b4ce2d71dfe46fe7034344c1c00"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b7e2030a7ec47c7b71a48940b4f664219a5143ac729247364a10420a06ef146e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"bda9a314bc69c00131b5f4e9d460c09916762da67699d0569d53a443e75f3989","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5de52c50b2eddaf2f88883702c8b9d6c2225dea85192213aa9a8033d5ad54366","source_sha256":"c176da80e4503efe6183e93024842ffebc5fe13ab472dafc9d3c186d0c4027cd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← not_lt, find_lt_iff, not_exists, not_and]","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.230769},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"150a79ea04b580420adacc92ec7fbc661aaf9ced6619a78b895d2d99dc90027b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Nat.Find\npublic import Mathlib.Data.PNat.Basic\n\nNamespace:\nPNat\n\nLocal context:\n/-\nCopyright (c) 2022 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky, Floris van Doorn\n-/\n/-!\n# Explicit least witnesses to existentials on positive natural numbers\n\nImplemented via calling out to `Nat.find`.\n\n-/\n\n@[expose] public section\n\n\nnamespace PNat\n\nvariable {p q : ℕ+ → Prop} [DecidablePred p] [DecidablePred q] (h : ∃ n, p n)\n\ninstance decidablePredExistsNat : DecidablePred fun n' : ℕ => ∃ (n : ℕ+) (_ : n' = n), p n :=\n fun n' =>\n decidable_of_iff' (∃ h : 0 < n', p ⟨n', h⟩) <|\n Subtype.exists.trans <| by\n simp_rw [mk_coe, @exists_comm (_ < _) (_ = _), exists_prop, exists_eq_left']\n\n/-- The `PNat` version of `Nat.findX` -/\nprotected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by\n have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩\n have n := Nat.findX this\n refine ⟨⟨n, ?_⟩, ?_, fun m hm pm => ?_⟩\n · obtain ⟨n', hn', -⟩ := n.prop.1\n rw [hn']\n exact n'.prop\n · obtain ⟨n', hn', pn'⟩ := n.prop.1\n simpa [hn', Subtype.coe_eta] using! pn'\n · exact n.prop.2 m hm ⟨m, rfl, pm⟩\n\n/-- If `p` is a (decidable) predicate on `ℕ+` and `hp : ∃ (n : ℕ+), p n` is a proof that\nthere exists some positive natural number satisfying `p`, then `PNat.find hp` is the\nsmallest positive natural number satisfying `p`. Note that `PNat.find` is protected,\nmeaning that you can't just write `find`, even if the `PNat` namespace is open.\n\nThe API for `PNat.find` is:\n\n* `PNat.find_spec` is the proof that `PNat.find hp` satisfies `p`.\n* `PNat.find_min` is the proof that if `m < PNat.find hp` then `m` does not satisfy `p`.\n* `PNat.find_min'` is the proof that if `m` does satisfy `p` then `PNat.find hp ≤ m`.\n-/\nprotected def find : ℕ+ :=\n PNat.findX h\n\nprotected theorem find_spec : p (PNat.find h) :=\n (PNat.findX h).prop.left\n\nprotected theorem find_min : ∀ {m : ℕ+}, m < PNat.find h → ¬p m :=\n @(PNat.findX h).prop.right\n\nprotected theorem find_min' {m : ℕ+} (hm : p m) : PNat.find h ≤ m :=\n le_of_not_gt fun l => PNat.find_min h l hm\n\nvariable {n m : ℕ+}\n\ntheorem find_eq_iff : PNat.find h = m ↔ p m ∧ ∀ n < m, ¬p n := by\n constructor\n · rintro rfl\n exact ⟨PNat.find_spec h, fun _ => PNat.find_min h⟩\n · rintro ⟨hm, hlt⟩\n exact le_antisymm (PNat.find_min' h hm) (not_lt.1 <| imp_not_comm.1 (hlt _) <| PNat.find_spec h)\n\n@[simp]\ntheorem find_lt_iff (n : ℕ+) : PNat.find h < n ↔ ∃ m < n, p m :=\n ⟨fun h2 => ⟨PNat.find h, h2, PNat.find_spec h⟩, fun ⟨_, hmn, hm⟩ =>\n (PNat.find_min' h hm).trans_lt hmn⟩\n\n@[simp]\ntheorem find_le_iff (n : ℕ+) : PNat.find h ≤ n ↔ ∃ m ≤ n, p m := by\n simp only [← lt_add_one_iff, find_lt_iff]\n\n@[simp]\n\nTarget:\ntheorem le_find_iff (n : ℕ+) : n ≤ PNat.find h ↔ ∀ m < n, ¬p m :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_5de52c50b2ed","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"2bbb2c5c0ca1e04f82ab782afe031e59e862d64227a710c2a9cc53af51b2f04f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PNat","family_id":"le_find_iff","file_id":"mathlib/Mathlib/Data/PNat/Find.lean","sample_id":"5de52c50b2eddaf2f88883702c8b9d6c2225dea85192213aa9a8033d5ad54366"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4a44785a09d00583d0a2883ace933a9a1a54511e619ea74fa77bdba1468dfd34","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"752ce8369192939adc72ab17549364fbc0f233d3f70f2ac0b1ccc05a31dd39c2","source_sha256":"90c64177e9fa7320c5cf96c0ae3a1383ca6bb2e38ff9d15f6eac1d27c5994294","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n algebraize [f, g, g.comp f]\n exact Algebra.EssFiniteType.comp_iff R S T","hard_negative":false,"metrics":{"chosen_tokens":21,"rejected_tokens":2,"token_jaccard":0.058824,"token_length_ratio":0.095238},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"15c27588be2a8593eb6824412bd336e85eda6c259aa053c8e22c9913e5822f57","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.EssentialFiniteness\npublic import Mathlib.RingTheory.Localization.AtPrime.Basic\npublic import Mathlib.RingTheory.LocalRing.ResidueField.Basic\npublic import Mathlib.RingTheory.LocalProperties.Basic\n\nNamespace:\nRingHom.EssFiniteType\n\nLocal context:\n/-\nCopyright (c) 2026 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten\n-/\n/-!\n# Meta properties of essentially of finite type ring homomorphisms\n-/\n\npublic section\n\nnamespace RingHom.EssFiniteType\n\nvariable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]\n\nlemma comp {f : R →+* S} {g : S →+* T} (hf : f.EssFiniteType) (hg : g.EssFiniteType) :\n (g.comp f).EssFiniteType := by\n algebraize [f, g, g.comp f]\n exact Algebra.EssFiniteType.comp R S T\n\nTarget:\nlemma comp_iff {f : R →+* S} {g : S →+* T} (hf : f.EssFiniteType) :\n (g.comp f).EssFiniteType ↔ g.EssFiniteType :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RingHom","family_id":"comp_iff","file_id":"mathlib/Mathlib/RingTheory/RingHom/EssFiniteType.lean","sample_id":"752ce8369192939adc72ab17549364fbc0f233d3f70f2ac0b1ccc05a31dd39c2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b3826865ea6bb6ef0aa544410f78b3435a37635af3ea2ebdbe1092f2787b1731","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cb29445617b36b05522ffdada9821f1f742558c77023e16eefabd80a2358c32c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e5efde683f51ef778b1c9df1337bf4713c8148828691f379c04f9ec372be55a8","source_sha256":"856ddd3a6715738ded0302a3b4f9054bf9dfb29b5d83f0085a1091d6b7175a51","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← oscillationWithin_univ_eq_oscillation] at hK\n convert! ← comp.uniform_oscillationWithin hK\n exact inter_univ _","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.157895},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"170f4d4ede5f4179056a7735b0c53eb7479e07aa7f997efe8ee308f9de455fde","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ENNReal.Real\npublic import Mathlib.Order.WellFoundedSet\npublic import Mathlib.Topology.EMetricSpace.Diam\n\nNamespace:\nIsCompact\n\nLocal context:\n/-\nCopyright (c) 2024 James Sundstrom. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: James Sundstrom\n-/\n/-!\n# Oscillation\n\nIn this file we define the oscillation of a function `f: E → F` at a point `x` of `E`. (`E` is\nrequired to be a TopologicalSpace and `F` a PseudoEMetricSpace.) The oscillation of `f` at `x` is\ndefined to be the infimum of `diam f '' N` for all neighborhoods `N` of `x`. We also define\n`oscillationWithin f D x`, which is the oscillation at `x` of `f` restricted to `D`.\n\nWe also prove some simple facts about oscillation, most notably that the oscillation of `f`\nat `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and\n`oscillationWithin`.\n\n## Tags\n\noscillation, oscillationWithin\n-/\n\n@[expose] public section\n\nopen Topology Metric Set ENNReal\n\nuniverse u v\n\nvariable {E : Type u} {F : Type v} [PseudoEMetricSpace F]\n\n/-- The oscillation of `f : E → F` at `x`. -/\nnoncomputable def oscillation [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=\n ⨅ S ∈ (𝓝 x).map f, ediam S\n\n/-- The oscillation of `f : E → F` within `D` at `x`. -/\nnoncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :\n ENNReal :=\n ⨅ S ∈ (𝓝[D] x).map f, ediam S\n\n/-- The oscillation of `f` at `x` within a neighborhood `D` of `x` is equal to `oscillation f x` -/\ntheorem oscillationWithin_nhds_eq_oscillation [TopologicalSpace E] (f : E → F) (D : Set E) (x : E)\n (hD : D ∈ 𝓝 x) : oscillationWithin f D x = oscillation f x := by\n rw [oscillation, oscillationWithin, nhdsWithin_eq_nhds.2 hD]\n\n/-- The oscillation of `f` at `x` within `univ` is equal to `oscillation f x` -/\ntheorem oscillationWithin_univ_eq_oscillation [TopologicalSpace E] (f : E → F) (x : E) :\n oscillationWithin f univ x = oscillation f x :=\n oscillationWithin_nhds_eq_oscillation f univ x Filter.univ_mem\n\nnamespace ContinuousWithinAt\n\ntheorem oscillationWithin_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}\n {x : E} (hf : ContinuousWithinAt f D x) : oscillationWithin f D x = 0 := by\n rw [← nonpos_iff_eq_zero]\n refine _root_.le_of_forall_pos_le_add fun ε hε ↦ ?_\n rw [zero_add]\n have : eball (f x) (ε / 2) ∈ (𝓝[D] x).map f :=\n hf <| eball_mem_nhds _ (by simp [ne_of_gt hε])\n refine (biInf_le ediam this).trans (le_of_le_of_eq ediam_eball_le ?_)\n exact (ENNReal.mul_div_cancel (by simp) (by simp))\n\nend ContinuousWithinAt\n\nnamespace ContinuousAt\n\ntheorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :\n oscillation f x = 0 := by\n rw [← continuousWithinAt_univ f x] at hf\n exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero\n\nend ContinuousAt\n\nnamespace OscillationWithin\n\n/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/\ntheorem eq_zero_iff_continuousWithinAt [TopologicalSpace E] (f : E → F) {D : Set E}\n {x : E} (xD : x ∈ D) : oscillationWithin f D x = 0 ↔ ContinuousWithinAt f D x := by\n refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_), fun hf ↦ hf.oscillationWithin_eq_zero⟩\n simp_rw [← hf, oscillationWithin, iInf_lt_iff] at ε0\n obtain ⟨S, hS, Sε⟩ := ε0\n refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)\n exact edist_le_ediam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)\n\nend OscillationWithin\n\nnamespace Oscillation\n\n/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/\ntheorem eq_zero_iff_continuousAt [TopologicalSpace E] (f : E → F) (x : E) :\n oscillation f x = 0 ↔ ContinuousAt f x := by\n rw [← oscillationWithin_univ_eq_oscillation, ← continuousWithinAt_univ f x]\n exact OscillationWithin.eq_zero_iff_continuousWithinAt f (mem_univ x)\n\nend Oscillation\n\nnamespace IsCompact\n\nvariable [PseudoEMetricSpace E] {K : Set E}\nvariable {f : E → F} {D : Set E} {ε : ENNReal}\n\n/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`\nsuch that the oscillation of `f` on `ball x δ ∩ D` is less than `ε` for every `x` in `K`. -/\ntheorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithin f D x < ε) :\n ∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by\n let S := fun r ↦\n {x : E | ∃ (a : ℝ), (a > r ∧ ediam (f '' (eball x (ENNReal.ofReal a) ∩ D)) ≤ ε)}\n have S_open : ∀ r > 0, IsOpen (S r) := by\n refine fun r _ ↦ EMetric.isOpen_iff.mpr fun x ⟨a, ar, ha⟩ ↦\n ⟨ENNReal.ofReal ((a - r) / 2), by simp [ar], ?_⟩\n refine fun y hy ↦ ⟨a - (a - r) / 2, by linarith,\n le_trans (ediam_mono (image_mono fun z hz ↦ ?_)) ha⟩\n refine ⟨lt_of_le_of_lt (edist_triangle z y x) (lt_of_lt_of_eq (ENNReal.add_lt_add hz.1 hy) ?_),\n hz.2⟩\n rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]\n have S_cover : K ⊆ ⋃ r > 0, S r := by\n intro x hx\n have : oscillationWithin f D x < ε := hK x hx\n simp only [oscillationWithin, Filter.mem_map, iInf_lt_iff] at this\n obtain ⟨n, hn₁, hn₂⟩ := this\n obtain ⟨r, r0, hr⟩ := EMetric.mem_nhdsWithin_iff.1 hn₁\n simp only [gt_iff_lt, mem_iUnion, exists_prop]\n have : ∀ r', (ENNReal.ofReal r') ≤ r →\n ediam (f '' (eball x (ENNReal.ofReal r') ∩ D)) ≤ ε := by\n intro r' hr'\n grw [← hn₂, ← image_subset_iff.2 hr, hr']\n by_cases r_top : r = ⊤\n · exact ⟨1, one_pos, 2, by simp, this 2 (by simp only [r_top, le_top])⟩\n · obtain ⟨r', hr'⟩ := exists_between (toReal_pos (ne_of_gt r0) r_top)\n use r', hr'.1, r.toReal, hr'.2, this r.toReal ofReal_toReal_le\n have S_antitone : ∀ (r₁ r₂ : ℝ), r₁ ≤ r₂ → S r₂ ⊆ S r₁ :=\n fun r₁ r₂ hr x ⟨a, ar₂, ha⟩ ↦ ⟨a, lt_of_le_of_lt hr ar₂, ha⟩\n obtain ⟨δ, δ0, hδ⟩ : ∃ r > 0, K ⊆ S r := by\n obtain ⟨T, Tb, Tfin, hT⟩ := comp.elim_finite_subcover_image S_open S_cover\n by_cases T_nonempty : T.Nonempty\n · use Tfin.isWF.min T_nonempty, Tb (Tfin.isWF.min_mem T_nonempty)\n intro x hx\n obtain ⟨r, hr⟩ := mem_iUnion.1 (hT hx)\n simp only [mem_iUnion, exists_prop] at hr\n exact (S_antitone _ r (IsWF.min_le Tfin.isWF T_nonempty hr.1)) hr.2\n · rw [not_nonempty_iff_eq_empty] at T_nonempty\n use 1, one_pos, subset_trans hT (by simp [T_nonempty])\n use δ, δ0\n intro x xK\n obtain ⟨a, δa, ha⟩ := hδ xK\n grw [← ha]\n gcongr\n\n/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such\nthat the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/\n\nTarget:\ntheorem uniform_oscillation {K : Set E} (comp : IsCompact K)\n {f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :\n ∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ))) ≤ ε :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_e5efde683f51","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"1e4b8606af2f79762ac6011888c040b4955a318dac1586dd1ac0d8aa4b68b380","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis","family_id":"uniform_oscillation","file_id":"mathlib/Mathlib/Analysis/Oscillation.lean","sample_id":"e5efde683f51ef778b1c9df1337bf4713c8148828691f379c04f9ec372be55a8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a8e3d8fb688ab1229bd8cd7bcfe5f7d9e7e2758bf845ae01e3eb2f6b658975ff","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"282bc74fe07542abb25ab28bc5c34627728795a8d032e8c6207a5bc75a5812ec","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6d2093bbe881216b7accab5fcc348aac399f23c381d948de399abfefa6c8a543","source_sha256":"fba9f03949fb71c822ca9bce084299af5da1008b68ee86b47a488c537325bc59","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.sup'_eq_of_forall hs (fun x ↦ f x a) ha","hard_negative":true,"metrics":{"chosen_tokens":61,"rejected_tokens":5,"token_jaccard":0.075,"token_length_ratio":0.081967},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"173da4cb20849a78b95157209cb01371bbf449fc17b82386be1302f3ff153edb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmas\npublic import Mathlib.Algebra.FiniteSupport.Defs\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.GroupWithZero.Action.Defs\npublic import Mathlib.Algebra.Order.Group.Indicator\npublic import Mathlib.Data.Set.Finite.Lattice\nimport Mathlib.Algebra.GroupWithZero.Indicator\nimport Mathlib.Algebra.Module.Basic\n\nNamespace:\nFunction\n\nLocal context:\n/-\nCopyright (c) 2026 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Make `fun_prop` work for finite (multiplicative) support\n\nWe provide API lemmas for the predicate `HasFiniteMulSupport` (and its additivized version\n`HasFiniteSupport`) on functions so that `fun_prop` can prove it for functions that are\nbuilt from other functions with finite multiplicative support.\n-/\n\npublic section\n\nnamespace Function\n\nvariable {α M : Type*} [One M]\n\n@[to_additive (attr := fun_prop)]\nlemma hasFiniteMulSupport_fun_one : HasFiniteMulSupport (1 : α → M) := by\n simp [HasFiniteMulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport fun a ↦ g (f a) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport (g ∘ f) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fst {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).fst :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.snd {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).snd :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prodMk {M' : Type*} [One M'] {f : α → M} {g : α → M'}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ (f a, g a) := by\n simp only [HasFiniteMulSupport] at hf hg ⊢\n rw [mulSupport_prodMk f g]\n exact hf.union hg\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.mul {M : Type*} [MulOneClass M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f * g) :=\n (hf.union hg).subset <| mulSupport_mul ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.inv {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport f⁻¹ :=\n hf.comp inv_one\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prod {M : Type*} [CommMonoid M] {ι : Type*} {f : ι → α → M}\n (hf : ∀ i, HasFiniteMulSupport (f i)) (s : Finset ι) :\n HasFiniteMulSupport fun a ↦ ∏ i ∈ s, f i a :=\n (s.finite_toSet.biUnion fun i _ ↦ hf i).subset <| s.mulSupport_prod f\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.div {M : Type*} [DivisionMonoid M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f / g) :=\n (hf.union hg).subset <| mulSupport_div ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.pow {M : Type*} [Monoid M] {f : α → M} (hf : HasFiniteMulSupport f)\n (n : ℕ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_pow n)\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.zpow {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) (n : ℤ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_zpow n)\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.max [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ max (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_max ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.min [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ min (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_min ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup [SemilatticeSup M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊔ g a :=\n (hf.union hg).subset <| mulSupport_sup ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf [SemilatticeInf M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊓ g a :=\n (hf.union hg).subset <| mulSupport_inf ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iSup [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨆ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iSup f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iInf [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨅ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iInf f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.pi {ι : Type*} [Finite α] {f : ι → α → M}\n (hf : ∀ a, HasFiniteMulSupport (f · a)) :\n HasFiniteMulSupport f := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (Set.finite_iUnion hf).subset fun i hi ↦ ?_\n simp only [mem_mulSupport, Set.mem_iUnion] at hi ⊢\n exact ne_iff.mp hi\n\n@[to_additive (attr := fun_prop)]\n\nTarget:\nlemma HasFiniteMulSupport.sup' [SemilatticeSup M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.sup' hs (f · a) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_6d2093bbe881","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"689224a1d73fbaa63ccb9b98747ef8446008c68ae8c29fa34fbfa5653d9352cb","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FiniteSupport","family_id":"hasfinitemulsupport","file_id":"mathlib/Mathlib/Algebra/FiniteSupport/Basic.lean","sample_id":"6d2093bbe881216b7accab5fcc348aac399f23c381d948de399abfefa6c8a543"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"558366532443c10e8642207576c008e53da35c4d87815099d9d4e82ce1c2f146","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b8837610771cf2c2cd2e4901dcb56247d98cf4012befdcf67c34c19187b05f39","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a6ee80262e49ce214623008850bfa1d620c7f34c79c0a368ec60fc7393ba68dc","source_sha256":"ea708406b6484e91e56b8bdc3f2dba09e17fe9bba92bc78c394fdb116a849211","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun s ↦ ⟨fun hs ↦ ?_, fun ⟨u, hu⟩ ↦ mem_nhds_iff.mpr ⟨u, hu.2, hu.1.1, hu.1.2.1⟩⟩⟩\n have ⟨u, hus, hu, hxu⟩ := mem_nhds_iff.mp hs\n exact ⟨pathComponentIn u x, ⟨hu.pathComponentIn _, ⟨mem_pathComponentIn_self hxu,\n isPathConnected_pathComponentIn hxu⟩⟩, pathComponentIn_subset.trans hus⟩","hard_negative":false,"metrics":{"chosen_tokens":87,"rejected_tokens":92,"token_jaccard":0.882353,"token_length_ratio":1.057471},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"176b45b26033ab4fa7359145325568f59539e6743b59bed2648f8800bdb0c893","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Connected.PathConnected\npublic import Mathlib.Topology.AlexandrovDiscrete\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Ben Eltschig\n-/\n/-!\n# Locally path-connected spaces\n\nThis file defines `LocPathConnectedSpace X`, a predicate class asserting that `X` is locally\npath-connected, in that each point has a basis of path-connected neighborhoods.\n\n## Main results\n\n* `IsOpen.pathComponent` / `IsClosed.pathComponent`: in locally path-connected spaces,\n path-components are both open and closed.\n* `pathComponent_eq_connectedComponent`: in locally path-connected spaces, path-components and\n connected components agree.\n* `pathConnectedSpace_iff_connectedSpace`: locally path-connected spaces are path-connected iff they\n are connected.\n* `instLocallyConnectedSpace`: locally path-connected spaces are also locally connected.\n* `IsOpen.locPathConnectedSpace`: open subsets of locally path-connected spaces are\n locally path-connected.\n* `LocPathConnectedSpace.coinduced` / `Quotient.locPathConnectedSpace`: quotients of locally\n path-connected spaces are locally path-connected.\n* `Sum.locPathConnectedSpace` / `Sigma.locPathConnectedSpace`: disjoint unions of locally\n path-connected spaces are locally path-connected.\n\nAbstractly, this also shows that locally path-connected spaces form a coreflective subcategory of\nthe category of topological spaces, although we do not prove that in this form here.\n\n## Implementation notes\n\nIn the definition of `LocPathConnectedSpace X` we require neighbourhoods in the basis to be\npath-connected, but not necessarily open; that they can also be required to be open is shown as\na theorem in `isOpen_isPathConnected_basis`.\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology Filter unitInterval Set Function\n\nvariable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {x y z : X} {ι : Type*} {F : Set X}\n\nsection LocPathConnectedSpace\n\n/-- A topological space is locally path connected if, at every point, path connected\nneighborhoods form a neighborhood basis. -/\nclass LocPathConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where\n /-- Each neighborhood filter has a basis of path-connected neighborhoods. -/\n path_connected_basis : ∀ x : X, (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s) id\n\nexport LocPathConnectedSpace (path_connected_basis)\n\ntheorem LocPathConnectedSpace.of_bases {p : X → ι → Prop} {s : X → ι → Set X}\n (h : ∀ x, (𝓝 x).HasBasis (p x) (s x)) (h' : ∀ x i, p x i → IsPathConnected (s x i)) :\n LocPathConnectedSpace X where\n path_connected_basis x := by\n rw [hasBasis_self]\n intro t ht\n rcases (h x).mem_iff.mp ht with ⟨i, hpi, hi⟩\n exact ⟨s x i, (h x).mem_of_mem hpi, h' x i hpi, hi⟩\n\nvariable [LocPathConnectedSpace X]\n\nprotected theorem IsOpen.pathComponentIn (hF : IsOpen F) (x : X) :\n IsOpen (pathComponentIn F x) := by\n rw [isOpen_iff_mem_nhds]\n intro y hy\n let ⟨s, hs⟩ := (path_connected_basis y).mem_iff.mp (hF.mem_nhds (pathComponentIn_subset hy))\n exact mem_of_superset hs.1.1 <| pathComponentIn_congr hy ▸\n hs.1.2.subset_pathComponentIn (mem_of_mem_nhds hs.1.1) hs.2\n\n/-- In a locally path connected space, each path component is an open set. -/\nprotected theorem IsOpen.pathComponent (x : X) : IsOpen (pathComponent x) := by\n rw [← pathComponentIn_univ]\n exact isOpen_univ.pathComponentIn _\n\n/-- In a locally path connected space, each path component is a closed set. -/\nprotected theorem IsClosed.pathComponent (x : X) : IsClosed (pathComponent x) := by\n rw [← isOpen_compl_iff, isOpen_iff_mem_nhds]\n intro y hxy\n rcases (path_connected_basis y).ex_mem with ⟨V, hVy, hVc⟩\n filter_upwards [hVy] with z hz hxz\n exact hxy <| hxz.trans (hVc.joinedIn _ hz _ (mem_of_mem_nhds hVy)).joined\n\n/-- In a locally path connected space, each path component is a clopen set. -/\nprotected theorem IsClopen.pathComponent (x : X) : IsClopen (pathComponent x) :=\n ⟨.pathComponent x, .pathComponent x⟩\n\nlemma pathComponentIn_mem_nhds (hF : F ∈ 𝓝 x) : pathComponentIn F x ∈ 𝓝 x := by\n let ⟨u, huF, hu, hxu⟩ := mem_nhds_iff.mp hF\n exact mem_nhds_iff.mpr ⟨pathComponentIn u x, pathComponentIn_mono huF,\n hu.pathComponentIn x, mem_pathComponentIn_self hxu⟩\n\ntheorem PathConnectedSpace.of_locPathConnectedSpace [ConnectedSpace X] : PathConnectedSpace X :=\n ⟨inferInstance, by simp [← mem_pathComponent_iff, IsClopen.pathComponent _ |>.eq_univ]⟩\n\ntheorem pathConnectedSpace_iff_connectedSpace : PathConnectedSpace X ↔ ConnectedSpace X :=\n ⟨fun _ ↦ inferInstance, fun _ ↦ .of_locPathConnectedSpace⟩\n\ntheorem pathComponent_eq_connectedComponent (x : X) : pathComponent x = connectedComponent x :=\n (pathComponent_subset_component x).antisymm <|\n (IsClopen.pathComponent x).connectedComponent_subset (mem_pathComponent_self _)\n\ntheorem connectedComponent_eq_iff_joined (x y : X) :\n connectedComponent x = connectedComponent y ↔ Joined x y := by\n rw [← mem_pathComponent_iff, pathComponent_eq_connectedComponent, eq_comm]\n exact connectedComponent_eq_iff_mem\n\ntheorem connectedComponentSetoid_eq_pathSetoid : connectedComponentSetoid X = pathSetoid X :=\n Setoid.ext connectedComponent_eq_iff_joined\n\n/-- In a locally path-connected space, connected components and path-connected components align -/\ndef connectedComponentsEquivZerothHomotopy : ConnectedComponents X ≃ ZerothHomotopy X where\n toFun := Quotient.map id (connectedComponent_eq_iff_joined · · |>.mp ·)\n invFun := ZerothHomotopy.toConnectedComponents\n left_inv := Quot.ind <| congrFun rfl\n right_inv := Quot.ind <| congrFun rfl\n\n@[simp]\nlemma connectedComponentsEquivZerothHomotopy_apply (x : X) :\n connectedComponentsEquivZerothHomotopy ⟦x⟧ = (.mk x) :=\n rfl\n\n@[simp]\nlemma coe_connectedComponentsEquivZerothHomotopy_symm :\n ⇑connectedComponentsEquivZerothHomotopy.symm = ZerothHomotopy.toConnectedComponents (X := X) :=\n rfl\n\nlemma connectedComponentsEquivZerothHomotopy_symm_apply (x : X) :\n connectedComponentsEquivZerothHomotopy.symm (.mk x) = ⟦x⟧ :=\n rfl\n\ntheorem pathConnected_subset_basis {U : Set X} (h : IsOpen U) (hx : x ∈ U) :\n (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s ∧ s ⊆ U) id :=\n (path_connected_basis x).hasBasis_self_subset (IsOpen.mem_nhds h hx)\n\nTarget:\ntheorem isOpen_isPathConnected_basis (x : X) :\n (𝓝 x).HasBasis (fun s : Set X ↦ IsOpen s ∧ x ∈ s ∧ IsPathConnected s) id :=\n\nProof body:\n","rejected":"by\n refine ⟨fun s ↦ ⟨fun hs ↦ ?_, fun ⟨u, hu⟩ ↦ mem_nhds_iff.mpr ⟨u, hu.2, hu.1.1, hu.1.2.1⟩⟩⟩\n have ⟨u, hus, hu, hxu⟩ := mem_nhds_iff.mp hs\n exact ⟨pathComponentIn u x, ⟨hu.pathComponentIn _, ⟨mem_pathComponentIn_self hxu,\n isPathConnected_pathComponentIn hxu⟩⟩, pathComponentIn_subset.trans hus⟩\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Connected","family_id":"isopen_ispathconnected_basis","file_id":"mathlib/Mathlib/Topology/Connected/LocPathConnected.lean","sample_id":"a6ee80262e49ce214623008850bfa1d620c7f34c79c0a368ec60fc7393ba68dc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e463c0a51ae47a64bfacbe44ee3286b4937f046e3fd0e78fa6ba8aac816150fa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d92cbd50d78e34b130448827c5fbab63d030dcf676a08eb657820f4a86be3bff","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d37839532a84c2d07a0730fd769a564b1722feba2c9b6fd17a5620baffb9e3a3","source_sha256":"f80f4ba6dd3c9529c67233c78268f6288754ad7511c9d37d6a6f6a1690fb2af0","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← fst_compEquiv, ← compEquiv_symm_inr]\n conv_rhs => rw [← LinearEquiv.symm_symm (compEquiv Q P)]\n rw [LinearEquiv.conj_exact_iff_exact]\n exact Function.Exact.inr_fst","hard_negative":false,"metrics":{"chosen_tokens":35,"rejected_tokens":40,"token_jaccard":0.821429,"token_length_ratio":1.142857},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"18bcea4e32346257629cb4ad4fde62d21961ee9cdceab4bca5c8622656fbcc4b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Extension.Cotangent.Basic\npublic import Mathlib.RingTheory.Extension.Generators\npublic import Mathlib.Algebra.Module.SnakeLemma\n\nNamespace:\nAlgebra.Generators\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n\n# The Jacobi-Zariski exact sequence\n\nGiven `R → S → T`, the Jacobi-Zariski exact sequence is\n```\nH¹(L_{T/R}) → H¹(L_{T/S}) → T ⊗[S] Ω[S/R] → Ω[T/R] → Ω[T/S] → 0\n```\nThe maps are\n- `Algebra.H1Cotangent.map`\n- `Algebra.H1Cotangent.δ`\n- `KaehlerDifferential.mapBaseChange`\n- `KaehlerDifferential.map`\n\nand the exactness lemmas are\n- `Algebra.H1Cotangent.exact_map_δ`\n- `Algebra.H1Cotangent.exact_δ_mapBaseChange`\n- `KaehlerDifferential.exact_mapBaseChange_map`\n- `KaehlerDifferential.map_surjective`\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential Module MvPolynomial TensorProduct\n\nnamespace Algebra\n\n-- `Generators.{w, u₁, u₂}` depends on three universe variables and\n-- to improve performance of universe unification, it should hold that\n-- `w > u₁` and `w > u₂` in the lexicographic order. For more details\n-- see https://github.com/leanprover-community/mathlib4/issues/26018\n-- TODO: this remains an unsolved problem, ideally the lexicographic\n-- order does not affect performance\nuniverse w₁ w₂ w₃ w₄ w₅ u₁ u₂ u₃\n\nvariable {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] [Algebra R S]\nvariable {T : Type u₃} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]\nvariable {ι : Type w₁} {ι' : Type w₃} {σ : Type w₂} {σ' : Type w₄} {τ : Type w₅}\nvariable (Q : Generators S T ι) (P : Generators R S σ)\nvariable (Q' : Generators S T ι') (P' : Generators R S σ') (W : Generators R T τ)\n\nattribute [local instance] SMulCommClass.of_commMonoid\n\nnamespace Generators\n\nset_option backward.isDefEq.respectTransparency false in\nlemma Cotangent.surjective_map_ofComp :\n Function.Surjective (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by\n intro x\n obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n have : x ∈ Q.ker := hx\n rw [← map_ofComp_ker Q P, Ideal.mem_map_iff_of_surjective\n _ (toAlgHom_ofComp_surjective Q P)] at this\n obtain ⟨x, hx', rfl⟩ := this\n exact ⟨.mk ⟨x, hx'⟩, Extension.Cotangent.map_mk _ _⟩\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nopen Extension.Cotangent in\n/--\nGiven representations `0 → I → R[X] → S → 0` and `0 → K → S[Y] → T → 0`,\nwe may consider the induced representation `0 → J → R[X, Y] → T → 0`, and the sequence\n`T ⊗[S] (I/I²) → J/J² → K/K²` is exact.\n-/\nlemma Cotangent.exact :\n Function.Exact\n ((Extension.Cotangent.map (Q.toComp P).toExtensionHom).liftBaseChange T)\n (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by\n apply LinearMap.exact_of_comp_of_mem_range\n · rw [LinearMap.liftBaseChange_comp, ← Extension.Cotangent.map_comp,\n EmbeddingLike.map_eq_zero_iff]\n ext x\n obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n simp only [map_mk, val_mk, LinearMap.zero_apply, val_zero]\n convert! Q.ker.toCotangent.map_zero\n trans ((IsScalarTower.toAlgHom R _ _).comp (IsScalarTower.toAlgHom R P.Ring S)) x\n · congr\n refine MvPolynomial.algHom_ext fun i ↦ ?_\n change (Q.ofComp P).toAlgHom ((Q.toComp P).toAlgHom (X i)) = _\n simp\n · simp [aeval_val_eq_zero hx]\n · intro x hx\n obtain ⟨⟨x : (Q.comp P).Ring, hx'⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n replace hx : (Q.ofComp P).toAlgHom x ∈ Q.ker ^ 2 := by\n simpa only [map_mk, val_mk, val_zero, Ideal.toCotangent_eq_zero] using! congr(($hx).val)\n rw [pow_two, ← map_ofComp_ker (P := P), ← Ideal.map_mul, Ideal.mem_map_iff_of_surjective\n _ (toAlgHom_ofComp_surjective Q P)] at hx\n obtain ⟨y, hy, e⟩ := hx\n rw [eq_comm, ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker, ← map_toComp_ker] at e\n rw [LinearMap.range_liftBaseChange]\n let z : (Q.comp P).ker := ⟨x - y, Ideal.sub_mem _ hx' (Ideal.mul_le_left hy)⟩\n have hz : z.1 ∈ P.ker.map (Q.toComp P).toAlgHom.toRingHom := e\n have : Extension.Cotangent.mk (P := (Q.comp P).toExtension) ⟨x, hx'⟩ =\n Extension.Cotangent.mk z := by\n ext; simpa only [val_mk, Ideal.toCotangent_eq, sub_sub_cancel, pow_two, z]\n rw [this, ← Submodule.restrictScalars_mem (Q.comp P).Ring, ← Submodule.mem_comap,\n ← Submodule.span_singleton_le_iff_mem, ← Submodule.map_le_map_iff_of_injective\n (f := Submodule.subtype _) Subtype.val_injective, Submodule.map_subtype_span_singleton,\n Submodule.span_singleton_le_iff_mem]\n refine (show Ideal.map (Q.toComp P).toAlgHom.toRingHom P.ker ≤ _ from ?_) hz\n rw [Ideal.map_le_iff_le_comap]\n rintro w hw\n simp only [AlgHom.toRingHom_eq_coe, Ideal.mem_comap, RingHom.coe_coe,\n Submodule.mem_map, Submodule.mem_comap, Submodule.restrictScalars_mem, Submodule.coe_subtype,\n Subtype.exists, exists_and_right, exists_eq_right,\n toExtension_Ring]\n refine ⟨?_, Submodule.subset_span ⟨Extension.Cotangent.mk ⟨w, hw⟩, ?_⟩⟩\n · simp only [ker_eq_ker_aeval_val, RingHom.mem_ker, Hom.algebraMap_toAlgHom]\n rw [aeval_val_eq_zero hw, map_zero]\n · rw [map_mk]\n rfl\n\n/-- Given `R[X] → S` and `S[Y] → T`, the cotangent space of `R[X][Y] → T` is isomorphic\nto the direct product of the cotangent space of `S[Y] → T` and `R[X] → S` (base changed to `T`). -/\nnoncomputable\ndef CotangentSpace.compEquiv :\n (Q.comp P).toExtension.CotangentSpace ≃ₗ[T]\n Q.toExtension.CotangentSpace × (T ⊗[S] P.toExtension.CotangentSpace) :=\n (Q.comp P).cotangentSpaceBasis.repr.trans\n (Q.cotangentSpaceBasis.prod (P.cotangentSpaceBasis.baseChange T)).repr.symm\n\nsection instanceProblem\n\n-- Note: these instances are needed to prevent instance search timeouts.\nattribute [local instance 999999] Zero.toOfNat0 SemilinearMapClass.distribMulActionSemiHomClass\n SemilinearEquivClass.instSemilinearMapClass instAddZeroClassTensorProduct AddZero.toZero\n\nlemma CotangentSpace.compEquiv_symm_inr :\n (compEquiv Q P).symm.toLinearMap ∘ₗ\n LinearMap.inr T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) =\n (Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T := by\n classical\n apply (P.cotangentSpaceBasis.baseChange T).ext\n intro i\n apply (Q.comp P).cotangentSpaceBasis.repr.injective\n ext j\n simp only [compEquiv, LinearEquiv.trans_symm, LinearEquiv.symm_symm,\n Basis.baseChange_apply, LinearMap.coe_comp, LinearEquiv.coe_coe, LinearMap.coe_inr,\n Function.comp_apply, LinearEquiv.trans_apply, Basis.repr_symm_apply, pderiv_X, toComp_val,\n Basis.repr_linearCombination, LinearMap.liftBaseChange_tmul, one_smul, repr_CotangentSpaceMap]\n obtain (j | j) := j <;>\n simp only [Basis.prod_repr_inr, Basis.baseChange_repr_tmul,\n Basis.repr_self, Basis.prod_repr_inl, map_zero, Finsupp.coe_zero,\n Pi.zero_apply, ne_eq, not_false_eq_true, Pi.single_eq_of_ne, Pi.single_apply,\n Finsupp.single_apply, ite_smul, one_smul, zero_smul, Sum.inr.injEq,\n MonoidWithZeroHom.map_ite_one_zero, reduceCtorEq]\n\nlemma CotangentSpace.compEquiv_symm_zero (x) :\n (compEquiv Q P).symm (0, x) =\n (Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T x :=\n DFunLike.congr_fun (compEquiv_symm_inr Q P) x\n\nlemma CotangentSpace.fst_compEquiv :\n LinearMap.fst T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) ∘ₗ\n (compEquiv Q P).toLinearMap = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom := by\n classical\n apply (Q.comp P).cotangentSpaceBasis.ext\n intro i\n apply Q.cotangentSpaceBasis.repr.injective\n ext j\n simp only [compEquiv, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, ofComp_val,\n LinearEquiv.trans_apply, Basis.repr_self, LinearMap.fst_apply, repr_CotangentSpaceMap]\n obtain (i | i) := i <;>\n simp only [Basis.repr_symm_apply, Finsupp.linearCombination_single, Basis.prod_apply,\n LinearMap.coe_inl, LinearMap.coe_inr, Sum.elim_inl, Function.comp_apply, one_smul,\n Basis.repr_self, Finsupp.single_apply, pderiv_X, Pi.single_apply,\n Sum.elim_inr, Function.comp_apply, Basis.baseChange_apply, one_smul,\n MonoidWithZeroHom.map_ite_one_zero, map_zero, Finsupp.coe_zero, Pi.zero_apply, derivation_C]\n\nlemma CotangentSpace.fst_compEquiv_apply (x) :\n (compEquiv Q P x).1 = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom x :=\n DFunLike.congr_fun (fst_compEquiv Q P) x\n\nlemma CotangentSpace.map_toComp_injective :\n Function.Injective\n ((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T) := by\n rw [← compEquiv_symm_inr]\n apply (compEquiv Q P).symm.injective.comp\n exact Prod.mk_right_injective _\n\nlemma CotangentSpace.map_ofComp_surjective :\n Function.Surjective (Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) := by\n rw [← fst_compEquiv]\n exact (Prod.fst_surjective).comp (compEquiv Q P).surjective\n\n/-!\nGiven representations `R[X] → S` and `S[Y] → T`, the sequence\n`T ⊗[S] (⨁ₓ S dx) → (⨁ₓ T dx) ⊕ (⨁ᵧ T dy) → ⨁ᵧ T dy`\nis exact.\n-/\n\nTarget:\nlemma CotangentSpace.exact :\n Function.Exact ((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T)\n (Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n rw [← fst_compEquiv, ← compEquiv_symm_inr]\n conv_rhs => rw [← LinearEquiv.symm_symm (compEquiv Q P)]\n rw [LinearEquiv.conj_exact_iff_exact]\n exact Function.Exact.inr_fst","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Kaehler","family_id":"cotangentspace","file_id":"mathlib/Mathlib/RingTheory/Kaehler/JacobiZariski.lean","sample_id":"d37839532a84c2d07a0730fd769a564b1722feba2c9b6fd17a5620baffb9e3a3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"13716daf79df24376d8e5d7ed7a266d42b36e9d308212424f5b69bc3db3cf074","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fa4af827734bb83e464f39726ff7d89ea2151af35a18b98ec24f8425602ed737","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bf8e687a0883c818afc808a7a35756dd04de3fe1a5e0555e87d141002492aa5d","source_sha256":"77932a4459c89002b639ed8830c116b32a50a724e462bfb0159cf7169631dd79","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [epiWithInjectiveKernel_iff]\n exact ⟨0, inferInstance, 0, by simp,\n ⟨ShortComplex.Splitting.ofIsZeroOfIsIso _ (isZero_zero C) (by assumption)⟩⟩","hard_negative":false,"metrics":{"chosen_tokens":33,"rejected_tokens":40,"token_jaccard":0.916667,"token_length_ratio":1.212121},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"18d3c99dcb712e208a732335dd76e1235e734687f144ed626a0be593625e55f3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.ShortComplex.ShortExact\npublic import Mathlib.CategoryTheory.MorphismProperty.Retract\npublic import Mathlib.CategoryTheory.MorphismProperty.LiftingProperty\npublic import Mathlib.CategoryTheory.Preadditive.Injective.LiftingProperties\n\nNamespace:\nCategoryTheory.Abelian\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Epimorphisms with an injective kernel\n\nIn this file, we define the class of morphisms `epiWithInjectiveKernel` in an\nabelian category. We show that this property of morphisms is multiplicative.\n\nThis shall be used in the file `Mathlib/Algebra/Homology/Factorizations/Basic.lean` in\norder to define morphisms of cochain complexes which satisfy this property\ndegreewise.\n\n-/\n\n@[expose] public section\n\nnamespace CategoryTheory\n\nopen Category Limits ZeroObject Preadditive\n\nvariable {C : Type*} [Category* C] [Abelian C]\n\nnamespace Abelian\n\n/-- The class of morphisms in an abelian category that are epimorphisms\nand have an injective kernel. -/\ndef epiWithInjectiveKernel : MorphismProperty C :=\n fun _ _ f => Epi f ∧ Injective (kernel f)\n\n/-- A morphism `g : X ⟶ Y` is epi with an injective kernel iff there exists a morphism\n`f : I ⟶ X` with `I` injective such that `f ≫ g = 0` and\nthe short complex `I ⟶ X ⟶ Y` has a splitting. -/\nlemma epiWithInjectiveKernel_iff {X Y : C} (g : X ⟶ Y) :\n epiWithInjectiveKernel g ↔ ∃ (I : C) (_ : Injective I) (f : I ⟶ X) (w : f ≫ g = 0),\n Nonempty (ShortComplex.mk f g w).Splitting := by\n constructor\n · rintro ⟨_, _⟩\n let S := ShortComplex.mk (kernel.ι g) g (by simp)\n exact ⟨_, inferInstance, _, S.zero,\n ⟨ShortComplex.Splitting.ofExactOfRetraction S\n (S.exact_of_f_is_kernel (kernelIsKernel g)) (Injective.factorThru (𝟙 _) (kernel.ι g))\n (by simp [S]) inferInstance⟩⟩\n · rintro ⟨I, _, f, w, ⟨σ⟩⟩\n have : IsSplitEpi g := ⟨σ.s, σ.s_g⟩\n let e : I ≅ kernel g :=\n IsLimit.conePointUniqueUpToIso σ.shortExact.fIsKernel (limit.isLimit _)\n exact ⟨inferInstance, Injective.of_iso e inferInstance⟩\n\nTarget:\nlemma epiWithInjectiveKernel_of_iso {X Y : C} (f : X ⟶ Y) [IsIso f] :\n epiWithInjectiveKernel f :=\n\nProof body:\n","rejected":"```lean\nby\n rw [epiWithInjectiveKernel_iff]\n exact ⟨0, inferInstance, 0, by simp,\n ⟨ShortComplex.Splitting.ofIsZeroOfIsIso _ (isZero_zero C) (by assumption)⟩⟩\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Abelian","family_id":"epiwithinjectivekernel_of_iso","file_id":"mathlib/Mathlib/CategoryTheory/Abelian/EpiWithInjectiveKernel.lean","sample_id":"bf8e687a0883c818afc808a7a35756dd04de3fe1a5e0555e87d141002492aa5d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f4a938cf920b10ddd5b681c22011be436be65cbfda87e6aa9698f6088fa7837","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5202372db7ffcf9b53a940dee95fc9ef0766aab29a03bc1a6a3fb06c4b208171","source_sha256":"d13991b9cfa5aed210efd9dfa59ee78d50d7a73c6e7dcb74ea09b33b3785b547","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have h' : Cospherical ({a, c, b, d} : Set P) := by rwa [Set.insert_comm c b {d}]\n have hmul := mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_pi h' hapc hbpd\n have hbp := left_dist_ne_zero_of_angle_eq_pi hbpd\n have h₁ : dist c d = dist c p / dist b p * dist a b := by\n rw [dist_mul_of_eq_angle_of_dist_mul b p a c p d, dist_comm a b]\n · rw [angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi hbpd hapc, angle_comm]\n all_goals simp [field, mul_comm, hmul]\n have h₂ : dist d a = dist a p / dist b p * dist b c := by\n rw [dist_mul_of_eq_angle_of_dist_mul c p b d p a, dist_comm c b]\n · rwa [angle_comm, angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi]; rwa [angle_comm]\n all_goals simp [field, mul_comm, hmul]\n have h₃ : dist d p = dist a p * dist c p / dist b p := by simp [field, hmul]\n have h₄ : ∀ x y : ℝ, x * (y * x) = x * x * y := fun x y => by rw [mul_left_comm, mul_comm]\n simp [field, h₁, h₂, dist_eq_add_dist_of_angle_eq_pi hbpd, h₃, dist_comm a b, h₄, ← sq,\n dist_sq_mul_dist_add_dist_sq_mul_dist b, hapc]","hard_negative":true,"metrics":{"chosen_tokens":246,"rejected_tokens":8,"token_jaccard":0.063492,"token_length_ratio":0.03252},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"195f14ae42a13604976df059e82db116499d2533e32eb0d1c5bf34127d1a5779","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Euclidean.Sphere.Power\npublic import Mathlib.Geometry.Euclidean.Triangle\n\nNamespace:\nEuclideanGeometry\n\nLocal context:\n/-\nCopyright (c) 2021 Manuel Candales. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Manuel Candales, Benjamin Davidson\n-/\n/-!\n# Ptolemy's theorem\n\nThis file proves Ptolemy's theorem on the lengths of the diagonals and sides of a cyclic\nquadrilateral.\n\n## Main theorems\n\n* `mul_dist_add_mul_dist_eq_mul_dist_of_cospherical`: Ptolemy’s Theorem (Freek No. 95).\n\nTODO: The current statement of Ptolemy’s theorem works around the lack of a \"cyclic polygon\" concept\nin mathlib, which is what the theorem statement would naturally use (or two such concepts, since\nboth a strict version, where all vertices must be distinct, and a weak version, where consecutive\nvertices may be equal, would be useful; Ptolemy's theorem should then use the weak one).\n\nAn API needs to be built around that concept, which would include:\n- strict cyclic implies weak cyclic,\n- weak cyclic and consecutive points distinct implies strict cyclic,\n- weak/strict cyclic implies weak/strict cyclic for any subsequence,\n- any three points on a sphere are weakly or strictly cyclic according to whether they are distinct,\n- any number of points on a sphere intersected with a two-dimensional affine subspace are cyclic in\n some order,\n- a list of points is cyclic if and only if its reversal is,\n- a list of points is cyclic if and only if any cyclic permutation is, while other permutations\n are not when the points are distinct,\n- a point P where the diagonals of a cyclic polygon cross exists (and is unique) with weak/strict\n betweenness depending on weak/strict cyclicity,\n- four points on a sphere with such a point P are cyclic in the appropriate order,\n\nand so on.\n-/\n\npublic section\n\n\nopen Real\n\nopen scoped EuclideanGeometry RealInnerProductSpace Real\n\nnamespace EuclideanGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\nvariable {P : Type*} [MetricSpace P] [NormedAddTorsor V P]\n\n/-- **Ptolemy’s Theorem**. -/\n\nTarget:\ntheorem mul_dist_add_mul_dist_eq_mul_dist_of_cospherical {a b c d p : P}\n (h : Cospherical ({a, b, c, d} : Set P)) (hapc : ∠ a p c = π) (hbpd : ∠ b p d = π) :\n dist a b * dist c d + dist b c * dist d a = dist a c * dist b d :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"134ef55183faafeb433b26b4bc2f4b2d78d784d7ec83033b7e7e27df6296c00f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Euclidean","family_id":"mul_dist_add_mul_dist_eq_mul_dist_of_cospherical","file_id":"mathlib/Mathlib/Geometry/Euclidean/Sphere/Ptolemy.lean","sample_id":"5202372db7ffcf9b53a940dee95fc9ef0766aab29a03bc1a6a3fb06c4b208171"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"977d78234735bfa5d4d34b3bd8d433f93c7fb84667b44174c0e1307b6298157b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"66cdf8d99156e74263d86c204ef22580175a198f9704962d65eb1860b4a47913","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c1d8adcd1dc14fbe13ce66f52a3923797e65f8ed46f53c24f6fa8d7484a01062","source_sha256":"b1a6de0bf7dd13eb86b75cd8d95aebb591d157a9fea40ceef9dbefb4524b23ba","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : finrank (ResidueField R) (CotangentSpace R) = 1 ↔\n finrank (ResidueField R) (CotangentSpace R) ≤ 1 := by\n simp [Nat.le_one_iff_eq_zero_or_eq_one, finrank_cotangentSpace_eq_zero_iff, h]\n rw [this]\n have : maximalIdeal R ≠ ⊥ := isField_iff_maximalIdeal_eq.not.mp h\n convert! tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R\n · exact ⟨fun _ ↦ inferInstance, fun h ↦ { h with not_a_field' := this }⟩\n · exact ⟨fun h P h₁ h₂ ↦ h.unique ⟨h₁, h₂⟩ ⟨this, inferInstance⟩,\n fun H ↦ ⟨_, ⟨this, inferInstance⟩, fun P hP ↦ H P hP.1 hP.2⟩⟩\n\nvariable {R}","hard_negative":true,"metrics":{"chosen_tokens":135,"rejected_tokens":5,"token_jaccard":0.053571,"token_length_ratio":0.037037},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"198e8f2736ac0392b3b9cdcbd51a2fdeb173537786ef69ce2ef644b56fb6eaf6","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.DedekindDomain.Basic\npublic import Mathlib.RingTheory.DiscreteValuationRing.Basic\npublic import Mathlib.RingTheory.Finiteness.Ideal\npublic import Mathlib.RingTheory.Ideal.Cotangent\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# Equivalent conditions for DVR\n\nIn `IsDiscreteValuationRing.TFAE`, we show that the following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n- `R` is a discrete valuation ring\n- `R` is a valuation ring\n- `R` is a Dedekind domain\n- `R` is integrally closed with a unique prime ideal\n- `m` is principal\n- `dimₖ m/m² = 1`\n- Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\npublic section\n\n\nvariable (R : Type*) [CommRing R]\n\nopen scoped Multiplicative\n\nopen IsLocalRing Module\n\ntheorem exists_maximalIdeal_pow_eq_of_principal [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h' : (maximalIdeal R).IsPrincipal) (I : Ideal R) (hI : I ≠ ⊥) :\n ∃ n : ℕ, I = maximalIdeal R ^ n := by\n by_cases h : IsField R\n · let _ := h.toField\n exact ⟨0, by simp [(eq_bot_or_eq_top I).resolve_left hI]⟩\n classical\n obtain ⟨x, hx : _ = Ideal.span _⟩ := h'\n by_cases hI' : I = ⊤\n · use 0; rw [pow_zero, hI', Ideal.one_eq_top]\n have H : ∀ r : R, ¬IsUnit r ↔ x ∣ r := fun r =>\n (SetLike.ext_iff.mp hx r).trans Ideal.mem_span_singleton\n have : x ≠ 0 := by\n rintro rfl\n apply Ring.ne_bot_of_isMaximal_of_not_isField (maximalIdeal.isMaximal R) h\n simp [hx]\n have hx' := IsDiscreteValuationRing.irreducible_of_span_eq_maximalIdeal x this hx\n have H' : ∀ r : R, r ≠ 0 → r ∈ nonunits R → ∃ n : ℕ, Associated (x ^ n) r := by\n intro r hr₁ hr₂\n obtain ⟨f, hf₁, rfl, hf₂⟩ := (WfDvdMonoid.not_unit_iff_exists_factors_eq r hr₁).mp hr₂\n have : ∀ b ∈ f, Associated x b := by\n intro b hb\n exact Irreducible.associated_of_dvd hx' (hf₁ b hb) ((H b).mp (hf₁ b hb).1)\n clear hr₁ hr₂ hf₁\n induction f using Multiset.induction with\n | empty => exact (hf₂ rfl).elim\n | cons fa fs fh => ?_\n rcases eq_or_ne fs ∅ with (rfl | hf')\n · use 1\n rw [pow_one, Multiset.prod_cons, Multiset.empty_eq_zero, Multiset.prod_zero, mul_one]\n exact this _ (Multiset.mem_cons_self _ _)\n · obtain ⟨n, hn⟩ := fh hf' fun b hb => this _ (Multiset.mem_cons_of_mem hb)\n use n + 1\n rw [pow_add, Multiset.prod_cons, mul_comm, pow_one]\n exact Associated.mul_mul (this _ (Multiset.mem_cons_self _ _)) hn\n have : ∃ n : ℕ, x ^ n ∈ I := by\n obtain ⟨r, hr₁, hr₂⟩ : ∃ r : R, r ∈ I ∧ r ≠ 0 := by\n by_contra! h; apply hI; rw [eq_bot_iff]; exact h\n obtain ⟨n, u, rfl⟩ := H' r hr₂ (le_maximalIdeal hI' hr₁)\n use n\n rwa [← I.unit_mul_mem_iff_mem u.isUnit, mul_comm]\n use Nat.find this\n apply le_antisymm\n · change ∀ s ∈ I, s ∈ _\n by_contra! ⟨s, hs₁, hs₂⟩\n apply hs₂\n by_cases hs₃ : s = 0; · rw [hs₃]; exact zero_mem _\n obtain ⟨n, u, rfl⟩ := H' s hs₃ (le_maximalIdeal hI' hs₁)\n rw [mul_comm, Ideal.unit_mul_mem_iff_mem _ u.isUnit] at hs₁ ⊢\n apply Ideal.pow_le_pow_right (Nat.find_min' this hs₁)\n apply Ideal.pow_mem_pow\n exact (H _).mpr (dvd_refl _)\n · rw [hx, Ideal.span_singleton_pow, Ideal.span_le, Set.singleton_subset_iff]\n exact Nat.find_spec this\n\ntheorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDedekindDomain R] :\n (maximalIdeal R).IsPrincipal := by\n classical\n by_cases ne_bot : maximalIdeal R = ⊥\n · rw [ne_bot]; infer_instance\n obtain ⟨a, ha₁, ha₂⟩ : ∃ a ∈ maximalIdeal R, a ≠ (0 : R) := by\n by_contra! h'; apply ne_bot; rwa [eq_bot_iff]\n have hle : Ideal.span {a} ≤ maximalIdeal R := by rwa [Ideal.span_le, Set.singleton_subset_iff]\n have : (Ideal.span {a}).radical = maximalIdeal R := by\n rw [Ideal.radical_eq_sInf]\n apply le_antisymm\n · exact sInf_le ⟨hle, inferInstance⟩\n · refine\n le_sInf fun I hI =>\n (eq_maximalIdeal <| hI.2.isMaximal (fun e => ha₂ ?_)).ge\n rw [← Ideal.span_singleton_eq_bot, eq_bot_iff, ← e]; exact hI.1\n have : ∃ n, maximalIdeal R ^ n ≤ Ideal.span {a} := by\n rw [← this]; apply Ideal.exists_radical_pow_le_of_fg; exact IsNoetherian.noetherian _\n rcases hn : Nat.find this with - | n\n · have := Nat.find_spec this\n rw [hn, pow_zero, Ideal.one_eq_top] at this\n exact (Ideal.IsMaximal.ne_top inferInstance (eq_top_iff.mpr <| this.trans hle)).elim\n obtain ⟨b, hb₁, hb₂⟩ : ∃ b ∈ maximalIdeal R ^ n, b ∉ Ideal.span {a} := by\n by_contra! h'; rw [Nat.find_eq_iff] at hn; exact hn.2 n n.lt_succ_self fun x hx => h' x hx\n have hb₃ : ∀ m ∈ maximalIdeal R, ∃ k : R, k * a = b * m := by\n intro m hm; rw [← Ideal.mem_span_singleton']; apply Nat.find_spec this\n rw [hn, pow_succ]; exact Ideal.mul_mem_mul hb₁ hm\n have hb₄ : b ≠ 0 := by rintro rfl; apply hb₂; exact zero_mem _\n let K := FractionRing R\n let x : K := algebraMap R K b / algebraMap R K a\n let M := Submodule.map (Algebra.linearMap R K) (maximalIdeal R)\n have ha₃ : algebraMap R K a ≠ 0 := IsFractionRing.to_map_eq_zero_iff.not.mpr ha₂\n by_cases hx : ∀ y ∈ M, x * y ∈ M\n · have := isIntegral_of_smul_mem_submodule M ?_ ?_ x hx\n · obtain ⟨y, e⟩ := IsIntegrallyClosed.algebraMap_eq_of_integral this\n refine (hb₂ (Ideal.mem_span_singleton'.mpr ⟨y, ?_⟩)).elim\n apply IsFractionRing.injective R K\n rw [map_mul, e, div_mul_cancel₀ _ ha₃]\n · rw [Submodule.ne_bot_iff]; refine ⟨_, ⟨a, ha₁, rfl⟩, ?_⟩\n exact (IsFractionRing.to_map_eq_zero_iff (K := K)).not.mpr ha₂\n · apply Submodule.FG.map; exact IsNoetherian.noetherian _\n · have :\n (M.map (DistribSMul.toLinearMap R K x)).comap (Algebra.linearMap R K) = ⊤ := by\n contrapose! hx with h\n rintro m' ⟨m, hm, rfl : algebraMap R K m = m'⟩\n obtain ⟨k, hk⟩ := hb₃ m hm\n have hk' : x * algebraMap R K m = algebraMap R K k := by\n rw [← mul_div_right_comm, ← map_mul, ← hk, map_mul, mul_div_cancel_right₀ _ ha₃]\n exact ⟨k, le_maximalIdeal h ⟨_, ⟨_, hm, rfl⟩, hk'⟩, hk'.symm⟩\n obtain ⟨y, hy₁, hy₂⟩ : ∃ y ∈ maximalIdeal R, b * y = a := by\n rw [Ideal.eq_top_iff_one, Submodule.mem_comap] at this\n obtain ⟨_, ⟨y, hy, rfl⟩, hy' : x * algebraMap R K y = algebraMap R K 1⟩ := this\n rw [map_one, ← mul_div_right_comm, div_eq_one_iff_eq ha₃, ← map_mul] at hy'\n exact ⟨y, hy, IsFractionRing.injective R K hy'⟩\n refine ⟨⟨y, ?_⟩⟩\n apply le_antisymm\n · intro m hm; obtain ⟨k, hk⟩ := hb₃ m hm; rw [← hy₂, mul_comm, mul_assoc] at hk\n rw [← mul_left_cancel₀ hb₄ hk, mul_comm]; exact Ideal.mem_span_singleton'.mpr ⟨_, rfl⟩\n · rwa [Submodule.span_le, Set.singleton_subset_iff]\n\n/--\nLet `(R, m, k)` be a Noetherian local domain (possibly a field).\nThe following are equivalent:\n0. `R` is a PID\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with at most one non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² ≤ 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `IsDiscreteValuationRing.TFAE` for a version assuming `¬ IsField R`.\n-/\ntheorem tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain\n [IsNoetherianRing R] [IsLocalRing R] [IsDomain R] :\n List.TFAE\n [IsPrincipalIdealRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∀ P : Ideal R, P ≠ ⊥ → P.IsPrime → P = maximalIdeal R,\n (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) ≤ 1,\n ∀ I ≠ ⊥, ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n tfae_have 1 → 2 := fun _ ↦ inferInstance\n tfae_have 2 → 1 := fun _ ↦ ((IsBezout.TFAE (R := R)).out 0 1).mp ‹_›\n tfae_have 1 → 4\n | H => ⟨inferInstance, fun P hP hP' ↦ eq_maximalIdeal (hP'.isMaximal hP)⟩\n tfae_have 4 → 3 :=\n fun ⟨h₁, h₂⟩ ↦ { h₁ with maximalOfPrime := (h₂ _ · · ▸ maximalIdeal.isMaximal R) }\n tfae_have 3 → 5 := fun h ↦ maximalIdeal_isPrincipal_of_isDedekindDomain R\n tfae_have 6 ↔ 5 := finrank_cotangentSpace_le_one_iff\n tfae_have 5 → 7 := exists_maximalIdeal_pow_eq_of_principal R\n tfae_have 7 → 2 := by\n rw [ValuationRing.iff_ideal_total]\n intro H\n constructor\n intro I J\n by_cases hI : I = ⊥; · order\n by_cases hJ : J = ⊥; · order\n obtain ⟨n, rfl⟩ := H I hI\n obtain ⟨m, rfl⟩ := H J hJ\n exact (le_total m n).imp Ideal.pow_le_pow_right Ideal.pow_le_pow_right\n tfae_finish\n\n/--\nThe following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n0. `R` is a discrete valuation ring\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with a unique non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² = 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\nTarget:\ntheorem IsDiscreteValuationRing.TFAE [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h : ¬IsField R) :\n List.TFAE\n [IsDiscreteValuationRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ P.IsPrime, (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) = 1,\n ∀ (I) (_ : I ≠ ⊥), ∃ n : ℕ, I = maximalIdeal R ^ n] :=\n\nProof body:\n","rejected":"by\n exact IsDiscreteValuationRing.TFAE","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"14539ba54b4114064a28490606c966acf0259b34bc9415a1dca46e38e29a6bd0","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/DiscreteValuationRing","family_id":"isdiscretevaluationring","file_id":"mathlib/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean","sample_id":"c1d8adcd1dc14fbe13ce66f52a3923797e65f8ed46f53c24f6fa8d7484a01062"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"138fd0dfaf279dab1f9e3472aed4b2fafde23aeb012e9f93f69001e1b2855b36","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fe1d788ea2651314e663e536f71c5fa53f9403c58ddf16c37ccc0615f3f39b5d","source_sha256":"87e0e602c5ed8c95da912c9f4ecabbc8ebe865981c3e20341425368377e739dd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n unfold recEmptyOption\n split\n · congr 1; exact Subsingleton.allEq _ _\n · exact Nat.noConfusion <| h.symm.trans ‹_›","hard_negative":false,"metrics":{"chosen_tokens":29,"rejected_tokens":3,"token_jaccard":0.086957,"token_length_ratio":0.103448},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"1a27280dd73fe94db54087d89d4194effb776365c16526c70ffcaff8304b4175","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.FinEnum\npublic import Mathlib.Logic.Equiv.Fin.Basic\n\nNamespace:\nFinEnum\n\nLocal context:\n/-\nCopyright (c) 2024 Tom Kranz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tom Kranz\n-/\n/-!\n# FinEnum instance for Option\n\nProvides a recursor for FinEnum types like `Fintype.truncRecEmptyOption`, but capable of producing\nnon-truncated data.\n\n## TODO\n* recreate rest of `Mathlib/Data/Fintype/Option.lean`\n-/\n\n@[expose] public section\n\nnamespace FinEnum\nuniverse u v\n\n/-- Inserting an `Option.none` anywhere in an enumeration yields another enumeration. -/\n@[implicit_reducible]\ndef insertNone (α : Type u) [FinEnum α] (i : Fin (card α + 1)) : FinEnum (Option α) where\n card := card α + 1\n equiv := equiv.optionCongr.trans <| finSuccEquiv' i |>.symm\n\n/-- This is an arbitrary choice of insertion rank for a default instance.\nIt keeps the mapping of the existing `α`-inhabitants intact, modulo `Fin.castSucc`. -/\ninstance instFinEnumOptionLast (α : Type u) [FinEnum α] : FinEnum (Option α) :=\n insertNone α (Fin.last _)\n\nopen Fin.NatCast in -- TODO: refactor the proof to avoid needing this.\n/-- A recursor principle for finite-and-enumerable types, analogous to `Nat.rec`.\nIt effectively says that every `FinEnum` is either `Empty` or `Option α`, up to an `Equiv` mediated\nby `Fin`s of equal cardinality.\nIn contrast to the `Fintype` case, data can be transported along such an `Equiv`.\nAlso, since order matters, the choice of element that gets replaced by `Option.none` has\nto be provided for every step.\n\nSince every `FinEnum` instance implies a `Fintype` instance and `Prop` is squashed already,\n`Fintype.induction_empty_option` can be used if a `Prop` needs to be constructed.\nCf. `Data.Fintype.Option`\n-/\ndef recEmptyOption {P : Type u → Sort v}\n (finChoice : (n : ℕ) → Fin (n + 1))\n (congr : {α β : Type u} → (_ : FinEnum α) → (_ : FinEnum β) → card β = card α → P α → P β)\n (empty : P PEmpty.{u + 1})\n (option : {α : Type u} → FinEnum α → P α → P (Option α))\n (α : Type u) [FinEnum α] :\n P α :=\n match cardeq : card α with\n | 0 => congr _ _ cardeq empty\n | n + 1 =>\n let fN := ULift.instFinEnum (α := Fin n)\n have : card (ULift.{u} <| Fin n) = n := card_ulift.trans card_fin\n congr (insertNone _ <| finChoice n) _\n (cardeq.trans <| congrArg Nat.succ this.symm) <|\n option fN (recEmptyOption finChoice congr empty option _)\ntermination_by card α\n\n/--\nFor an empty type, the recursion principle evaluates to whatever `congr`\nmakes of the base case.\n-/\n\nTarget:\ntheorem recEmptyOption_of_card_eq_zero {P : Type u → Sort v}\n (finChoice : (n : ℕ) → Fin (n + 1))\n (congr : {α β : Type u} → (_ : FinEnum α) → (_ : FinEnum β) → card β = card α → P α → P β)\n (empty : P PEmpty.{u + 1})\n (option : {α : Type u} → FinEnum α → P α → P (Option α))\n (α : Type u) [FinEnum α] (h : card α = 0) (_ : FinEnum PEmpty.{u + 1}) :\n recEmptyOption finChoice congr empty option α =\n congr _ _ (h.trans card_eq_zero.symm) empty :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/FinEnum","family_id":"recemptyoption_of_card_eq_zero","file_id":"mathlib/Mathlib/Data/FinEnum/Option.lean","sample_id":"fe1d788ea2651314e663e536f71c5fa53f9403c58ddf16c37ccc0615f3f39b5d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5400a4bcaf358aa3b63215d17a18ae9124a51c7ea1a62153bca9eeccb7255a7c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0c5f50d72a2e8fada5ad187e43a06475a222c271747002476aca377409e898d6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bb2cd1dc1ca862e5834880bcae70362b553393815a6d23f611f6a7116781ebf5","source_sha256":"1150b79a47f039251bed2c3cc4606a2dd353eeb957087827d3b401533e782eff","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [eventually_nhdsSet_iff_exists]\n use {x | f =ᶠ[𝓝[≠] x] g}\n simp only [Set.mem_setOf_eq, imp_self, implies_true, and_true]\n constructor\n · apply isOpen_setOf_eventually_nhdsWithin\n · intro x hx\n rw [Set.mem_setOf]\n exact eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (hf x hx) (hg x hx) hx (hU x hx) h","hard_negative":true,"metrics":{"chosen_tokens":67,"rejected_tokens":3,"token_jaccard":0.04878,"token_length_ratio":0.044776},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"1aaf1ab27d7505e8105ab6652a5492fdbd22932ca1847dc4902e047103b4c921","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Meromorphic.Order\n\nNamespace:\nMeromorphicAt\n\nLocal context:\n/-\nCopyright (c) 2025 Stefan Kebekus. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stefan Kebekus\n-/\n/-!\n# Principles of Isolated Zeros and Identity Principles for Meromorphic Functions\n\nIn line with results in `Mathlib.Analysis.Analytic.IsolatedZeros` and\n`Mathlib.Analysis.Analytic.Uniqueness`, this file establishes principles of isolated zeros and\nidentity principles for meromorphic functions.\n\nCompared to the results for analytic functions, the principles established here are a little more\ncomplicated to state. This is because meromorphic functions can be modified at will along discrete\nsubsets and still remain meromorphic.\n-/\n\npublic section\n\nvariable\n {𝕜 : Type*} [NontriviallyNormedField 𝕜]\n {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]\n {U : Set 𝕜} {x : 𝕜} {f g : 𝕜 → E}\n\nopen Filter Topology\n\nnamespace MeromorphicAt\n\n/-!\n## Principles of Isolated Zeros\n-/\n\n/--\nThe principle of isolated zeros: If `f` is meromorphic at `x`, then `f` vanishes eventually in a\npunctured neighborhood of `x` iff it vanishes frequently in punctured neighborhoods.\n\nSee `AnalyticAt.frequently_zero_iff_eventually_zero` for a stronger result in the analytic case.\n-/\ntheorem frequently_zero_iff_eventuallyEq_zero (hf : MeromorphicAt f x) :\n (∃ᶠ z in 𝓝[≠] x, f z = 0) ↔ f =ᶠ[𝓝[≠] x] 0 :=\n ⟨hf.eventually_eq_zero_or_eventually_ne_zero.resolve_right, fun h ↦ h.frequently⟩\n\n/--\nVariant of the principle of isolated zeros: Let `U` be a subset of `𝕜` and assume that `x ∈ U` is\nnot an isolated point of `U`. If a function `f` is meromorphic at `x` and vanishes along a subset\nthat is codiscrete within `U`, then `f` vanishes in a punctured neighbourhood of `f`.\n\nFor a typical application, let `U` be a path in the complex plane and let `x` be one of the end\npoints. If `f` is meromorphic at `x` and vanishes on `U`, then it will vanish in a punctured\nneighbourhood of `x`, which intersects `U` non-trivially but is not contained in `U`.\n\nThe assumption that `x` is not an isolated point of `U` is expressed as `AccPt x (𝓟 U)`. See\n`accPt_iff_frequently` and `accPt_iff_frequently_nhdsNE` for useful reformulations.\n-/\ntheorem eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin (hf : MeromorphicAt f x)\n (h₁x : x ∈ U) (h₂x : AccPt x (𝓟 U)) (h : f =ᶠ[codiscreteWithin U] 0) :\n f =ᶠ[𝓝[≠] x] 0 := by\n rw [← hf.frequently_zero_iff_eventuallyEq_zero]\n apply ((accPt_iff_frequently_nhdsNE.1 h₂x).and_eventually <| eventually_mem_set.2\n (mem_codiscreteWithin_iff_forall_mem_nhdsNE.1 h x h₁x)).mono\n simp +contextual\n\n/--\nVariant of the principle of isolated zeros, formulated in terms of orders: If `f` is nowhere locally\nconstant zero, then its zero set is discrete within its domain of meromorphicity.\n-/\ntheorem MeromorphicOn.codiscreteWithin_setOf_ne_zero (h₁f : MeromorphicOn f U)\n (h₂f : ∀ u ∈ U, meromorphicOrderAt f u ≠ ⊤) :\n ∀ᶠ x in codiscreteWithin U, f x ≠ 0 := by\n filter_upwards [h₁f.analyticAt_mem_codiscreteWithin,\n h₁f.codiscreteWithin_setOf_meromorphicOrderAt_eq_zero_or_top h₂f] with x h₁x h₂x\n have := h₂f x h₂x.1\n simp_all [← h₁x.analyticOrderAt_eq_zero, h₁x.meromorphicOrderAt_eq]\n\n/-!\n## Identity Principles\n-/\n\n/--\nFormulation of `MeromorphicAt.frequently_zero_iff_eventuallyEq_zero` as an identity principle: If\n`f` and `g` are meromorphic at `x`, then `f` and `g` agree eventually in a punctured neighborhood of\n`x` iff they agree at points arbitrarily close to (but different from) `x`.\n-/\ntheorem frequently_eq_iff_eventuallyEq (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :\n (∃ᶠ z in 𝓝[≠] x, f z = g z) ↔ f =ᶠ[𝓝[≠] x] g := by\n rw [eventuallyEq_iff_sub, ← (hf.sub hg).frequently_zero_iff_eventuallyEq_zero]\n simp_rw [Pi.sub_apply, sub_eq_zero]\n\n/--\nFormulation of `MeromorphicAt.eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin` as an\nidentity principle: Let `U` be a subset of `𝕜` and assume that `x ∈ U` is not an isolated point of\n`U`. If function `f` and `g` are meromorphic at `x` and agree along a subset that is codiscrete\nwithin `U`, then `f` and `g` agree in a punctured neighbourhood of `f`.\n-/\ntheorem eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (hf : MeromorphicAt f x)\n (hg : MeromorphicAt g x) (h₁x : x ∈ U) (h₂x : AccPt x (𝓟 U)) (h : f =ᶠ[codiscreteWithin U] g) :\n f =ᶠ[𝓝[≠] x] g := by\n rw [eventuallyEq_iff_sub] at *\n apply (hf.sub hg).eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin h₁x h₂x h\n\n/-\nVariant of `MeromorphicAt.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin`, as a statement\nabout meromorphic functions that agree outside a set codiscrete within a perfect set.\n-/\ntheorem eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin_preperfect (hf : MeromorphicAt f x)\n (hg : MeromorphicAt g x) (hx : x ∈ U) (hU : Preperfect U) (h : f =ᶠ[codiscreteWithin U] g) :\n f =ᶠ[𝓝[≠] x] g :=\n hf.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin hg hx (hU x hx) h\n\n/-\nVariant of `MeromorphicAt.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin`, as a statement\nabout meromorphic functions agreeing in a neighborhood of a preperfect set.\n-/\n\nTarget:\ntheorem eventually_nhdsSet_eventuallyEq_codiscreteWithin (hf : MeromorphicOn f U)\n (hg : MeromorphicOn g U) (hU : Preperfect U) (h : f =ᶠ[codiscreteWithin U] g) :\n ∀ᶠ x in 𝓝ˢ U, f =ᶠ[𝓝[≠] x] g :=\n\nProof body:\n","rejected":"by\n exact eventually_nhdsSet_eventuallyEq_codiscreteWithin","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"1caac9068f331d91816993988aff119c9aa971ce267625b953cc9d07e1254875","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Meromorphic","family_id":"eventually_nhdsset_eventuallyeq_codiscretewithin","file_id":"mathlib/Mathlib/Analysis/Meromorphic/IsolatedZeros.lean","sample_id":"bb2cd1dc1ca862e5834880bcae70362b553393815a6d23f611f6a7116781ebf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1a4f85515bab94ebedb0653eaef526303090ac4170d93ee5d3f143fddf238577","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f67c7a57091479147410be7781e61fa79b14c7f42ac8b81957e6d6e20ea81aed","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6ded992d9dff50ff1f7713cf83e3d3d46911843ee49f5692a23de0fb332e63ed","source_sha256":"dadd27768139699caee7d5df148073f0d11219956d3bdcf7101de781c664a7fc","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← LinearMap.range_eq_top,\n ← (Submodule.map_injective_of_injective h1Cotangentι_injective).eq_iff,\n ← LinearMap.range_comp, ← P.h1CotangentEquivCotangent_comp_map, LinearMap.range_comp,\n ← (Algebra.H1Cotangent.exact_map_δ R P.Ring S).linearMap_ker_eq, Submodule.map_top,\n ← exact_hCotangentι_cotangentComplex.linearMap_ker_eq, Submodule.map_equiv_eq_comap_symm,\n LinearMap.ker, LinearMap.ker, ← Submodule.comap_comp]\n congr\n rw [LinearEquiv.comp_toLinearMap_symm_eq, P.cotangentComplex_comp_h1CotangentEquivCotangent]","hard_negative":false,"metrics":{"chosen_tokens":90,"rejected_tokens":94,"token_jaccard":0.926829,"token_length_ratio":1.044444},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"1c149efb39e334d4e54a9a478c0e9cb9a1498f7da260fa1999766a736c7ff8b0","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.JacobiZariski\n\nNamespace:\nAlgebra.Extension\n\nLocal context:\n/-\nCopyright (c) 2024 Bingyu Xia. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bingyu Xia\n-/\n/-!\n# Extension of Scalars for Algebra Extensions\n\nThis file provides APIs for extending the base ring of an algebra extension `P : Extension R S`\nto its own extension ring `P.Ring`. We introduce canonical maps and isomorphisms between\nthe cotangent spaces and the first homology of naive cotangent complex associated with\n`P.extendScalars` and `P`. We provide commutativity results of these maps and ismorphisms\n(See https://github.com/leanprover-community/mathlib4/pull/39520 for an image of the full diagram).\nIn particular, we show the boundary map of the Jacobi-Zariski sequence of `R → P.Ring → S`\ncoincides with `P.cotangentComplex` via a canonical isomorphism `P.h1CotangentEquivCotangent`.\n\n## Main definitions and results\n\n- `extendScalars`: Views `P : Extension R S` as `Extension P.Ring S`.\n- `toExtendScalars`: The canonical homomorphism from `P` to `P.extendScalars` induced by\n the identity map on the underlying extension rings.\n- `cotangentExtendScalarsEquiv` : The linear equivalence between the cotangent spaces of\n `P.extensScalars` and `P` induced by the identity map.\n- `h1CotangentExtendScalarsEquiv`: `P.extensScalars` can be used to compute the first homology of\n the naive cotangent complex of `S` over `P.Ring`.\n- `h1CotangentEquivOfSurjective`: If `R → P.Ring` is surjective, this is the linear isomorphism\n induced by `P.h1Cotangentι`.\n- `h1CotangentEquivCotangent`: This is the linear equivalence between `H1Cotangent P.Ring S` and\n `P.Cotangent` defined by the composition of `h1CotangentExtendScalarsEquiv.symm`,\n `h1CotangentEquivOfSurjective` and `cotangentExtendScalarsEquiv`.\n- `cotangentComplex_comp_h1CotangentEquivCotangent`,\n `h1CotangentEquivCotangent_comp_map`: commutativity results.\n\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential\n\nnamespace Algebra.Extension\n\nuniverse w v u\n\nvariable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n\n/-- Given an extension `P` of `S` over `R`, `P.extendScalars` is the same extension\nbut viewed as an extension of `S` over `P.Ring`. -/\n@[simps]\ndef extendScalars {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n (P : Extension.{w} R S) : Extension P.Ring S where\n Ring := P.Ring\n σ := P.σ\n algebraMap_σ := P.algebraMap_σ\n\nset_option backward.isDefEq.respectTransparency false in\nset_option backward.defeqAttrib.useBackward true in\n/-- The canonical homomorphism from `P` to `P.extendScalars` induced by the identity map\non the underlying extension rings. -/\n@[simps!]\nnoncomputable\ndef toExtendScalars {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n (P : Extension.{w} R S) : P.Hom P.extendScalars :=\n .ofAlgHom (IsScalarTower.toAlgHom R P.Ring P.extendScalars.Ring)\n (by dsimp; ext; simp)\n\n/-- `Extension.extendScalars` does not change the cotangent space of an extension. -/\nnoncomputable\ndef cotangentExtendScalarsEquiv {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n P.extendScalars.Cotangent ≃ₗ[S] P.Cotangent :=\n LinearEquiv.refl _ _\n\n@[simp]\nlemma cotangentExtendScalarsEquiv_symm_toLinearMap (P : Extension.{w} R S) :\n P.cotangentExtendScalarsEquiv.symm.toLinearMap = Cotangent.map P.toExtendScalars := by\n ext x\n obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x\n rfl\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem H1Cotangent.map_toExtendScalars_injective (P : Extension.{w} R S) :\n Function.Injective (H1Cotangent.map P.toExtendScalars) := by\n rw [← LinearMap.ker_eq_bot, H1Cotangent.map, LinearMap.ker_restrict,\n ← cotangentExtendScalarsEquiv_symm_toLinearMap, LinearEquiv.ker,\n Submodule.comap_bot, Submodule.ker_subtype]\n\n/-- The first homology of the naive cotangent complex of `P.extendScalars` is\nlinearly equivalent to that of `S` over `P.Ring`. -/\n@[simps! toLinearMap]\nnoncomputable\ndef h1CotangentExtendScalarsEquiv {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n P.extendScalars.H1Cotangent ≃ₗ[S] H1Cotangent P.Ring S :=\n Extension.H1Cotangent.equiv\n (.ofAlgHom (Algebra.ofId _ _) (by ext)) P.extendScalars.defaultHom\n\n@[simp]\nlemma h1CotangentExtendScalarsEquiv_symm_toLinearMap (P : Extension.{w} R S) :\n P.h1CotangentExtendScalarsEquiv.symm = H1Cotangent.map P.extendScalars.defaultHom := rfl\n\n/-- Given an extension `P` of `S` over `R` such that `algebraMap R P.Ring` is surjective,\nthis is the equivalence induced by `P.h1Cotangentι`. -/\n@[simps! toLinearMap]\nnoncomputable\ndef h1CotangentEquivOfSurjective {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) (h : Function.Surjective (algebraMap R P.Ring)) :\n P.H1Cotangent ≃ₗ[S] P.Cotangent where\n __ := P.h1Cotangentι\n invFun x := ⟨x, by\n have : Subsingleton Ω[P.Ring⁄R] := subsingleton_of_surjective R P.Ring h\n exact Subsingleton.elim _ _⟩\n\n/-- Given an extension `P : Extension R S`, this is the linear equivalence between\nthe first homology of the naive cotangent complex of `S` over `P.Ring` and\nthe cotangent space of `P`. -/\nnoncomputable\ndef h1CotangentEquivCotangent {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n H1Cotangent P.Ring S ≃ₗ[S] P.Cotangent :=\n P.h1CotangentExtendScalarsEquiv.symm ≪≫ₗ\n P.extendScalars.h1CotangentEquivOfSurjective Function.surjective_id ≪≫ₗ\n P.cotangentExtendScalarsEquiv\n\ntheorem cotangentComplex_comp_h1CotangentEquivCotangent (P : Extension.{w} R S) :\n P.cotangentComplex.comp P.h1CotangentEquivCotangent.toLinearMap =\n H1Cotangent.δ R P.Ring S := by\n rw [h1CotangentEquivCotangent, LinearEquiv.coe_trans, LinearEquiv.coe_trans,\n h1CotangentEquivOfSurjective_toLinearMap, ← LinearMap.comp_assoc, ← LinearMap.comp_assoc,\n LinearEquiv.comp_toLinearMap_symm_eq, LinearMap.comp_assoc,\n h1CotangentExtendScalarsEquiv_toLinearMap]\n ext ⟨x, _⟩\n obtain ⟨⟨x : P.Ring, x_in : x ∈ P.ker⟩, rfl⟩ := Cotangent.mk_surjective x\n trans 1 ⊗ₜ[P.Ring] D R P.Ring x; · exact cotangentComplex_mk P ⟨x, x_in⟩\n let u : (Generators.self P.Ring S).toExtension.ker :=\n ⟨algebraMap P.Ring (Generators.self P.Ring S).toExtension.Ring x, by\n rwa [← Ideal.mem_comap, RingHom.comap_ker, ← IsScalarTower.algebraMap_eq]⟩\n rw [← Generators.H1Cotangent.δ_C _ _ u.prop]\n congr\n\ntheorem h1CotangentEquivCotangent_comp_map (P : Extension.{w} R S) :\n P.h1CotangentEquivCotangent.toLinearMap.comp (Algebra.H1Cotangent.map R P.Ring S S) =\n h1Cotangentι.comp (H1Cotangent.map P.defaultHom) := by\n rw [h1CotangentEquivCotangent, LinearEquiv.coe_trans, LinearEquiv.coe_trans,\n h1CotangentExtendScalarsEquiv_symm_toLinearMap, h1CotangentEquivOfSurjective_toLinearMap,\n LinearMap.comp_assoc, LinearMap.comp_assoc, Algebra.H1Cotangent.map,\n ← (H1Cotangent.map P.extendScalars.defaultHom).restrictScalars_self, ← H1Cotangent.map_comp,\n eq_comm, ← LinearEquiv.toLinearMap_symm_comp_eq, cotangentExtendScalarsEquiv_symm_toLinearMap,\n ← LinearMap.comp_assoc, Cotangent.map_comp_h1Cotangentι, LinearMap.restrictScalars_self,\n LinearMap.comp_assoc, ← (H1Cotangent.map P.toExtendScalars).restrictScalars_self,\n ← H1Cotangent.map_comp, H1Cotangent.map_eq]\n\nTarget:\ntheorem H1Cotangent.map_defaultHom_surjective (P : Extension.{w} R S) :\n Function.Surjective (H1Cotangent.map P.defaultHom) :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [← LinearMap.range_eq_top,\n ← (Submodule.map_injective_of_injective h1Cotangentι_injective).eq_iff,\n ← LinearMap.range_comp, ← P.h1CotangentEquivCotangent_comp_map, LinearMap.range_comp,\n ← (Algebra.H1Cotangent.exact_map_δ R P.Ring S).linearMap_ker_eq, Submodule.map_top,\n ← exact_hCotangentι_cotangentComplex.linearMap_ker_eq, Submodule.map_equiv_eq_comap_symm,\n LinearMap.ker, LinearMap.ker, ← Submodule.comap_comp]\n congr\n rw [LinearEquiv.comp_toLinearMap_symm_eq, P.cotangentComplex_comp_h1CotangentEquivCotangent]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Extension","family_id":"h1cotangent","file_id":"mathlib/Mathlib/RingTheory/Extension/ExtendScalars.lean","sample_id":"6ded992d9dff50ff1f7713cf83e3d3d46911843ee49f5692a23de0fb332e63ed"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"138fd0dfaf279dab1f9e3472aed4b2fafde23aeb012e9f93f69001e1b2855b36","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fa42413954c225cc1dbb0e5ee334b9017a6f299206d621ecea1ba4706801ad50","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fe1d788ea2651314e663e536f71c5fa53f9403c58ddf16c37ccc0615f3f39b5d","source_sha256":"87e0e602c5ed8c95da912c9f4ecabbc8ebe865981c3e20341425368377e739dd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n unfold recEmptyOption\n split\n · congr 1; exact Subsingleton.allEq _ _\n · exact Nat.noConfusion <| h.symm.trans ‹_›","hard_negative":true,"metrics":{"chosen_tokens":29,"rejected_tokens":3,"token_jaccard":0.086957,"token_length_ratio":0.103448},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"1c1a0f18d0ccb4c4b22732ece8061e487681dd891a7d362be79e402fa95b47bb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.FinEnum\npublic import Mathlib.Logic.Equiv.Fin.Basic\n\nNamespace:\nFinEnum\n\nLocal context:\n/-\nCopyright (c) 2024 Tom Kranz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tom Kranz\n-/\n/-!\n# FinEnum instance for Option\n\nProvides a recursor for FinEnum types like `Fintype.truncRecEmptyOption`, but capable of producing\nnon-truncated data.\n\n## TODO\n* recreate rest of `Mathlib/Data/Fintype/Option.lean`\n-/\n\n@[expose] public section\n\nnamespace FinEnum\nuniverse u v\n\n/-- Inserting an `Option.none` anywhere in an enumeration yields another enumeration. -/\n@[implicit_reducible]\ndef insertNone (α : Type u) [FinEnum α] (i : Fin (card α + 1)) : FinEnum (Option α) where\n card := card α + 1\n equiv := equiv.optionCongr.trans <| finSuccEquiv' i |>.symm\n\n/-- This is an arbitrary choice of insertion rank for a default instance.\nIt keeps the mapping of the existing `α`-inhabitants intact, modulo `Fin.castSucc`. -/\ninstance instFinEnumOptionLast (α : Type u) [FinEnum α] : FinEnum (Option α) :=\n insertNone α (Fin.last _)\n\nopen Fin.NatCast in -- TODO: refactor the proof to avoid needing this.\n/-- A recursor principle for finite-and-enumerable types, analogous to `Nat.rec`.\nIt effectively says that every `FinEnum` is either `Empty` or `Option α`, up to an `Equiv` mediated\nby `Fin`s of equal cardinality.\nIn contrast to the `Fintype` case, data can be transported along such an `Equiv`.\nAlso, since order matters, the choice of element that gets replaced by `Option.none` has\nto be provided for every step.\n\nSince every `FinEnum` instance implies a `Fintype` instance and `Prop` is squashed already,\n`Fintype.induction_empty_option` can be used if a `Prop` needs to be constructed.\nCf. `Data.Fintype.Option`\n-/\ndef recEmptyOption {P : Type u → Sort v}\n (finChoice : (n : ℕ) → Fin (n + 1))\n (congr : {α β : Type u} → (_ : FinEnum α) → (_ : FinEnum β) → card β = card α → P α → P β)\n (empty : P PEmpty.{u + 1})\n (option : {α : Type u} → FinEnum α → P α → P (Option α))\n (α : Type u) [FinEnum α] :\n P α :=\n match cardeq : card α with\n | 0 => congr _ _ cardeq empty\n | n + 1 =>\n let fN := ULift.instFinEnum (α := Fin n)\n have : card (ULift.{u} <| Fin n) = n := card_ulift.trans card_fin\n congr (insertNone _ <| finChoice n) _\n (cardeq.trans <| congrArg Nat.succ this.symm) <|\n option fN (recEmptyOption finChoice congr empty option _)\ntermination_by card α\n\n/--\nFor an empty type, the recursion principle evaluates to whatever `congr`\nmakes of the base case.\n-/\n\nTarget:\ntheorem recEmptyOption_of_card_eq_zero {P : Type u → Sort v}\n (finChoice : (n : ℕ) → Fin (n + 1))\n (congr : {α β : Type u} → (_ : FinEnum α) → (_ : FinEnum β) → card β = card α → P α → P β)\n (empty : P PEmpty.{u + 1})\n (option : {α : Type u} → FinEnum α → P α → P (Option α))\n (α : Type u) [FinEnum α] (h : card α = 0) (_ : FinEnum PEmpty.{u + 1}) :\n recEmptyOption finChoice congr empty option α =\n congr _ _ (h.trans card_eq_zero.symm) empty :=\n\nProof body:\n","rejected":"by\n exact recEmptyOption_of_card_eq_zero","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"54e1a97432d938a9b31fc3460f4e85f8522b5aa508a12ad4d04b2c19a53f9668","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/FinEnum","family_id":"recemptyoption_of_card_eq_zero","file_id":"mathlib/Mathlib/Data/FinEnum/Option.lean","sample_id":"fe1d788ea2651314e663e536f71c5fa53f9403c58ddf16c37ccc0615f3f39b5d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0fc3ffde48221e0c6de049969eb07449fb8d0bef56191dde47b1c056396304fc","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8dfa4cbeabaa34a88c663ec293bcd521cf11a47da5dc596a9b5faad70653593f","source_sha256":"1dcf65c8ea7778a6ecd23b33c451f9deaac459a250401fe1c6886135569df43d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [fderiv_fun_pow n differentiableAt_fun_id, fderiv_fun_id]","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":2,"token_jaccard":0.1,"token_length_ratio":0.222222},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"1c624f3b1e935377bb09d7486b9eda4e6a79049339c2a7afcf7cbb6b1094c37a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Calculus.FDeriv.Mul\npublic import Mathlib.Analysis.Calculus.FDeriv.Comp\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n/-!\n# Fréchet Derivative of `f x ^ n`, `n : ℕ`\n\nIn this file we prove that the Fréchet derivative of `fun x => f x ^ n`,\nwhere `n` is a natural number, is `n • f x ^ (n - 1)) • f'`.\nAdditionally, we prove the case for non-commutative rings (with primed names like `fderiv_pow'`),\nwhere the result is instead `∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i`.\n\nFor detailed documentation of the Fréchet derivative,\nsee the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.\n\n## Keywords\n\nderivative, power\n-/\n\npublic section\n\nvariable {𝕜 𝔸 E : Type*}\n\nsection NormedRing\nvariable [NontriviallyNormedField 𝕜] [NormedRing 𝔸] [NormedAddCommGroup E]\nvariable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}\n\nopen scoped RightActions\n\nprivate theorem aux (f : E → 𝔸) (f' : E →L[𝕜] 𝔸) (x : E) (n : ℕ) :\n f x •> ∑ i ∈ Finset.range (n + 1), f x ^ ((n + 1).pred - i) •> f' <• f x ^ i\n + f' <• (f x ^ (n + 1)) =\n ∑ i ∈ Finset.range (n + 1 + 1), f x ^ ((n + 1 + 1).pred - i) •> f' <• f x ^ i := by\n rw [Finset.sum_range_succ _ (n + 1), Finset.smul_sum]\n simp only [Nat.pred_eq_sub_one, add_tsub_cancel_right, tsub_self, pow_zero, one_smul]\n simp_rw [smul_comm (_ : 𝔸) (_ : 𝔸ᵐᵒᵖ), smul_smul, ← pow_succ']\n congr! 5 with x hx\n simp only [Finset.mem_range, Nat.lt_succ_iff] at hx\n rw [tsub_add_eq_add_tsub hx]\n\n@[to_fun]\ntheorem HasStrictFDerivAt.pow' (h : HasStrictFDerivAt f f' x) (n : ℕ) :\n HasStrictFDerivAt (f ^ n)\n (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=\n match n with\n | 0 => by simpa using! hasStrictFDerivAt_const 1 x\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n refine this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasStrictFDerivAt_pow' (n : ℕ) {x : 𝔸} :\n HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=\n hasStrictFDerivAt_id _ |>.pow' n\n\n@[to_fun]\ntheorem HasFDerivWithinAt.pow' (h : HasFDerivWithinAt f f' s x) (n : ℕ) :\n HasFDerivWithinAt (f ^ n)\n (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) s x :=\n match n with\n | 0 => by simpa using! hasFDerivWithinAt_const 1 x s\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n exact this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasFDerivWithinAt_pow' (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n HasFDerivWithinAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) s x :=\n hasFDerivWithinAt_id _ _ |>.pow' n\n\n@[to_fun]\ntheorem HasFDerivAt.pow' (h : HasFDerivAt f f' x) (n : ℕ) :\n HasFDerivAt (f ^ n) (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=\n match n with\n | 0 => by simpa using! hasFDerivAt_const 1 x\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n exact this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasFDerivAt_pow' (n : ℕ) {x : 𝔸} :\n HasFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=\n hasFDerivAt_id _ |>.pow' n\n\n@[fun_prop]\ntheorem DifferentiableWithinAt.fun_pow (hf : DifferentiableWithinAt 𝕜 f s x) (n : ℕ) :\n DifferentiableWithinAt 𝕜 (fun x => f x ^ n) s x :=\n let ⟨_, hf'⟩ := hf; ⟨_, hf'.pow' n⟩\n\n@[fun_prop]\ntheorem DifferentiableWithinAt.pow (hf : DifferentiableWithinAt 𝕜 f s x) :\n ∀ n : ℕ, DifferentiableWithinAt 𝕜 (f ^ n) s x :=\n hf.fun_pow\n\ntheorem differentiableWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n DifferentiableWithinAt 𝕜 (fun x : 𝔸 => x ^ n) s x :=\n differentiableWithinAt_id.pow _\n\n@[to_fun (attr := simp, fun_prop)]\ntheorem DifferentiableAt.pow (hf : DifferentiableAt 𝕜 f x) (n : ℕ) :\n DifferentiableAt 𝕜 (f ^ n) x :=\n differentiableWithinAt_univ.mp <| hf.differentiableWithinAt.pow n\n\ntheorem differentiableAt_pow (n : ℕ) {x : 𝔸} : DifferentiableAt 𝕜 (fun x : 𝔸 => x ^ n) x :=\n differentiableAt_id.pow _\n\n@[to_fun (attr := fun_prop)]\ntheorem DifferentiableOn.pow (hf : DifferentiableOn 𝕜 f s) (n : ℕ) :\n DifferentiableOn 𝕜 (f ^ n) s := fun x h => (hf x h).pow n\n\ntheorem differentiableOn_pow (n : ℕ) {s : Set 𝔸} : DifferentiableOn 𝕜 (fun x : 𝔸 => x ^ n) s :=\n differentiableOn_id.pow n\n\n@[to_fun (attr := simp, fun_prop)]\ntheorem Differentiable.pow (hf : Differentiable 𝕜 f) (n : ℕ) : Differentiable 𝕜 (f ^ n) :=\n fun x => (hf x).pow n\n\ntheorem differentiable_pow (n : ℕ) : Differentiable 𝕜 fun x : 𝔸 => x ^ n :=\n differentiable_id.pow _\n\n@[to_fun fderiv_fun_pow']\ntheorem fderiv_pow' (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :\n fderiv 𝕜 (f ^ n) x\n = (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderiv 𝕜 f x <• f x ^ i) :=\n hf.hasFDerivAt.pow' n |>.fderiv\n\ntheorem fderiv_pow_ring' {x : 𝔸} (n : ℕ) :\n fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x\n = (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by\n rw [fderiv_fun_pow' n differentiableAt_fun_id, fderiv_fun_id]\n\n@[to_fun fderivWithin_fun_pow']\ntheorem fderivWithin_pow' (hxs : UniqueDiffWithinAt 𝕜 s x)\n (n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :\n fderivWithin 𝕜 (f ^ n) s x\n = (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderivWithin 𝕜 f s x <• f x ^ i) :=\n hf.hasFDerivWithinAt.pow' n |>.fderivWithin hxs\n\ntheorem fderivWithin_pow_ring' {s : Set 𝔸} {x : 𝔸} (n : ℕ) (hxs : UniqueDiffWithinAt 𝕜 s x) :\n fderivWithin 𝕜 (fun x : 𝔸 ↦ x ^ n) s x\n = (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by\n rw [fderivWithin_fun_pow' hxs n differentiableAt_fun_id.differentiableWithinAt,\n fderivWithin_fun_id hxs]\n\nend NormedRing\n\nsection NormedCommRing\nvariable [NontriviallyNormedField 𝕜] [NormedCommRing 𝔸] [NormedAddCommGroup E]\nvariable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}\n\nprivate theorem aux_sum_eq_pow (n : ℕ) :\n ∑ i ∈ Finset.range n, MulOpposite.op (f x ^ i) • f x ^ (n.pred - i) • f' =\n (n • f x ^ (n - 1)) • f' := by\n simp_rw [op_smul_eq_smul, smul_smul, ← pow_add, ← Finset.sum_smul]\n rw [Finset.sum_eq_card_nsmul, Finset.card_range, smul_assoc]\n intro a ha\n congr\n exact add_tsub_cancel_of_le (Nat.le_pred_of_lt <| Finset.mem_range.1 ha)\n\ntheorem HasStrictFDerivAt.pow (h : HasStrictFDerivAt f f' x) (n : ℕ) :\n HasStrictFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasStrictFDerivAt_pow (n : ℕ) {x : 𝔸} :\n HasStrictFDerivAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=\n hasStrictFDerivAt_id _ |>.pow n\n\ntheorem HasFDerivWithinAt.pow (h : HasFDerivWithinAt f f' s x) (n : ℕ) :\n HasFDerivWithinAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') s x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasFDerivWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n HasFDerivWithinAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) s x :=\n hasFDerivWithinAt_id _ _ |>.pow n\n\ntheorem HasFDerivAt.pow (h : HasFDerivAt f f' x) (n : ℕ) :\n HasFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasFDerivAt_pow (n : ℕ) {x : 𝔸} :\n HasFDerivAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=\n hasFDerivAt_id _ |>.pow n\n\n@[to_fun fderiv_fun_pow]\ntheorem fderiv_pow (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :\n fderiv 𝕜 (f ^ n) x = (n • f x ^ (n - 1)) • fderiv 𝕜 f x :=\n hf.hasFDerivAt.pow n |>.fderiv\n\nTarget:\ntheorem fderiv_pow_ring {x : 𝔸} (n : ℕ) :\n fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x = (n • x ^ (n - 1)) • .id _ _ :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Calculus","family_id":"fderiv_pow_ring","file_id":"mathlib/Mathlib/Analysis/Calculus/FDeriv/Pow.lean","sample_id":"8dfa4cbeabaa34a88c663ec293bcd521cf11a47da5dc596a9b5faad70653593f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fb6d9ad21d798130f93cce38e40fc5f8b53e8db782bb3d5f7d2838f6433452b1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"827d378be1c0b42e61ff0401552778c6e616e69f468aa2120ce372683a59754f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b0692eabc0c31660fdc5eb22cd5140790caef341f52b22645412e7622dc52bd5","source_sha256":"6c7073e5e01a46e3eeb41e7b78026bf34b3b5442b0dd2251d80491d13afb5e57","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap']\n rintro ⟨v₁, v₂⟩\n change\n (e₁.prod e₂).coordChangeL 𝕜 (e₁'.prod e₂') b (v₁, v₂) =\n (e₁.coordChangeL 𝕜 e₁' b v₁, e₂.coordChangeL 𝕜 e₂' b v₂)\n rw [e₁.coordChangeL_apply e₁', e₂.coordChangeL_apply e₂', (e₁.prod e₂).coordChangeL_apply']\n exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩]\n\nvariable {e₁ e₂} [∀ x : B, TopologicalSpace (E₁ x)] [∀ x : B, TopologicalSpace (E₂ x)]\n [FiberBundle F₁ E₁] [FiberBundle F₂ E₂]","hard_negative":true,"metrics":{"chosen_tokens":185,"rejected_tokens":3,"token_jaccard":0.022222,"token_length_ratio":0.016216},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"1dc565426f187f509ef12bdd984fe79cb80d577ffa22b17c4d19f2b0e5382ab1","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.FiberBundle.Constructions\npublic import Mathlib.Topology.VectorBundle.Basic\npublic import Mathlib.Analysis.Normed.Operator.Prod\n\nNamespace:\nBundle.Trivialization\n\nLocal context:\n/-\nCopyright (c) 2022 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri, Sébastien Gouëzel, Heather Macbeth, Floris van Doorn\n-/\n/-!\n# Standard constructions on vector bundles\n\nThis file contains several standard constructions on vector bundles:\n\n* `Bundle.Trivial.vectorBundle 𝕜 B F`: the trivial vector bundle with scalar field `𝕜` and model\n fiber `F` over the base `B`\n\n* `VectorBundle.prod`: for vector bundles `E₁` and `E₂` with scalar field `𝕜` over a common base,\n a vector bundle structure on their direct sum `E₁ ×ᵇ E₂` (the notation stands for\n `fun x ↦ E₁ x × E₂ x`).\n\n* `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its\n pullback `f *ᵖ E` by a map `f : B' → B` (the notation is a type synonym for `E ∘ f`).\n\n## Tags\nVector bundle, direct sum, pullback\n-/\n\npublic section\n\nnoncomputable section\n\nopen Bundle Set FiberBundle\n\n/-! ### The trivial vector bundle -/\n\nnamespace Bundle.Trivial\n\nvariable (𝕜 : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField 𝕜] [NormedAddCommGroup F]\n [NormedSpace 𝕜 F] [TopologicalSpace B]\n\ninstance trivialization.isLinear : (trivialization B F).IsLinear 𝕜 where\n linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩\n\nvariable {𝕜} in\ntheorem trivialization.coordChangeL (b : B) :\n (trivialization B F).coordChangeL 𝕜 (trivialization B F) b =\n ContinuousLinearEquiv.refl 𝕜 F := by\n ext v\n rw [Trivialization.coordChangeL_apply']\n exacts [rfl, ⟨mem_univ _, mem_univ _⟩]\n\ninstance vectorBundle : VectorBundle 𝕜 F (Bundle.Trivial B F) where\n trivialization_linear' e he := by\n rw [eq_trivialization B F e]\n infer_instance\n continuousOn_coordChange' e e' he he' := by\n obtain rfl := eq_trivialization B F e\n obtain rfl := eq_trivialization B F e'\n simp only [trivialization.coordChangeL]\n exact continuous_const.continuousOn\n\n@[simp] lemma linearMapAt_trivialization (x : B) :\n (trivialization B F).linearMapAt 𝕜 x = LinearMap.id := by\n ext v\n rw [Trivialization.coe_linearMapAt_of_mem _ (by simp)]\n rfl\n\n@[simp] lemma continuousLinearMapAt_trivialization (x : B) :\n (trivialization B F).continuousLinearMapAt 𝕜 x = ContinuousLinearMap.id 𝕜 F := by\n ext; simp\n\n@[simp] lemma symmₗ_trivialization (x : B) :\n (trivialization B F).symmₗ 𝕜 x = LinearMap.id := by\n ext; simp [Trivialization.coe_symmₗ, trivialization_symm_apply B F]\n\n@[simp] lemma symmL_trivialization (x : B) :\n (trivialization B F).symmL 𝕜 x = ContinuousLinearMap.id 𝕜 F := by\n ext; simp [trivialization_symm_apply B F]\n\n@[simp] lemma continuousLinearEquivAt_trivialization (x : B) :\n (trivialization B F).continuousLinearEquivAt 𝕜 x (mem_univ _) =\n ContinuousLinearEquiv.refl 𝕜 F := by\n ext; simp\n\nend Bundle.Trivial\n\n/-! ### Direct sum of two vector bundles -/\n\nsection\n\nvariable (𝕜 : Type*) {B : Type*} [NontriviallyNormedField 𝕜] [TopologicalSpace B] (F₁ : Type*)\n [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] (E₁ : B → Type*) [TopologicalSpace (TotalSpace F₁ E₁)]\n (F₂ : Type*) [NormedAddCommGroup F₂] [NormedSpace 𝕜 F₂] (E₂ : B → Type*)\n [TopologicalSpace (TotalSpace F₂ E₂)]\n\nnamespace Bundle.Trivialization\n\nvariable {F₁ E₁ F₂ E₂}\nvariable [∀ x, AddCommMonoid (E₁ x)] [∀ x, Module 𝕜 (E₁ x)]\n [∀ x, AddCommMonoid (E₂ x)] [∀ x, Module 𝕜 (E₂ x)] (e₁ e₁' : Trivialization F₁ (π F₁ E₁))\n (e₂ e₂' : Trivialization F₂ (π F₂ E₂))\n\ninstance prod.isLinear [e₁.IsLinear 𝕜] [e₂.IsLinear 𝕜] : (e₁.prod e₂).IsLinear 𝕜 where\n linear := fun _ ⟨h₁, h₂⟩ =>\n (((e₁.linear 𝕜 h₁).mk' _).prodMap ((e₂.linear 𝕜 h₂).mk' _)).isLinear\n\n@[simp]\n\nTarget:\ntheorem coordChangeL_prod [e₁.IsLinear 𝕜] [e₁'.IsLinear 𝕜] [e₂.IsLinear 𝕜] [e₂'.IsLinear 𝕜] ⦃b⦄\n (hb : (b ∈ e₁.baseSet ∧ b ∈ e₂.baseSet) ∧ b ∈ e₁'.baseSet ∧ b ∈ e₂'.baseSet) :\n ((e₁.prod e₂).coordChangeL 𝕜 (e₁'.prod e₂') b : F₁ × F₂ →L[𝕜] F₁ × F₂) =\n (e₁.coordChangeL 𝕜 e₁' b : F₁ →L[𝕜] F₁).prodMap (e₂.coordChangeL 𝕜 e₂' b) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_b0692eabc0c3","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"74f5a04d94470c8fa299d3be3a39f942eb2ed3b6449220dbd2e1ad23e0c83b85","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/VectorBundle","family_id":"coordchangel_prod","file_id":"mathlib/Mathlib/Topology/VectorBundle/Constructions.lean","sample_id":"b0692eabc0c31660fdc5eb22cd5140790caef341f52b22645412e7622dc52bd5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5400a4bcaf358aa3b63215d17a18ae9124a51c7ea1a62153bca9eeccb7255a7c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bb2cd1dc1ca862e5834880bcae70362b553393815a6d23f611f6a7116781ebf5","source_sha256":"1150b79a47f039251bed2c3cc4606a2dd353eeb957087827d3b401533e782eff","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [eventually_nhdsSet_iff_exists]\n use {x | f =ᶠ[𝓝[≠] x] g}\n simp only [Set.mem_setOf_eq, imp_self, implies_true, and_true]\n constructor\n · apply isOpen_setOf_eventually_nhdsWithin\n · intro x hx\n rw [Set.mem_setOf]\n exact eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (hf x hx) (hg x hx) hx (hU x hx) h","hard_negative":false,"metrics":{"chosen_tokens":67,"rejected_tokens":3,"token_jaccard":0.04878,"token_length_ratio":0.044776},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"1e34e3b4c48a2943095e36d133c62e88bc1897d398203b6b847b5d41858105ba","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Meromorphic.Order\n\nNamespace:\nMeromorphicAt\n\nLocal context:\n/-\nCopyright (c) 2025 Stefan Kebekus. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stefan Kebekus\n-/\n/-!\n# Principles of Isolated Zeros and Identity Principles for Meromorphic Functions\n\nIn line with results in `Mathlib.Analysis.Analytic.IsolatedZeros` and\n`Mathlib.Analysis.Analytic.Uniqueness`, this file establishes principles of isolated zeros and\nidentity principles for meromorphic functions.\n\nCompared to the results for analytic functions, the principles established here are a little more\ncomplicated to state. This is because meromorphic functions can be modified at will along discrete\nsubsets and still remain meromorphic.\n-/\n\npublic section\n\nvariable\n {𝕜 : Type*} [NontriviallyNormedField 𝕜]\n {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]\n {U : Set 𝕜} {x : 𝕜} {f g : 𝕜 → E}\n\nopen Filter Topology\n\nnamespace MeromorphicAt\n\n/-!\n## Principles of Isolated Zeros\n-/\n\n/--\nThe principle of isolated zeros: If `f` is meromorphic at `x`, then `f` vanishes eventually in a\npunctured neighborhood of `x` iff it vanishes frequently in punctured neighborhoods.\n\nSee `AnalyticAt.frequently_zero_iff_eventually_zero` for a stronger result in the analytic case.\n-/\ntheorem frequently_zero_iff_eventuallyEq_zero (hf : MeromorphicAt f x) :\n (∃ᶠ z in 𝓝[≠] x, f z = 0) ↔ f =ᶠ[𝓝[≠] x] 0 :=\n ⟨hf.eventually_eq_zero_or_eventually_ne_zero.resolve_right, fun h ↦ h.frequently⟩\n\n/--\nVariant of the principle of isolated zeros: Let `U` be a subset of `𝕜` and assume that `x ∈ U` is\nnot an isolated point of `U`. If a function `f` is meromorphic at `x` and vanishes along a subset\nthat is codiscrete within `U`, then `f` vanishes in a punctured neighbourhood of `f`.\n\nFor a typical application, let `U` be a path in the complex plane and let `x` be one of the end\npoints. If `f` is meromorphic at `x` and vanishes on `U`, then it will vanish in a punctured\nneighbourhood of `x`, which intersects `U` non-trivially but is not contained in `U`.\n\nThe assumption that `x` is not an isolated point of `U` is expressed as `AccPt x (𝓟 U)`. See\n`accPt_iff_frequently` and `accPt_iff_frequently_nhdsNE` for useful reformulations.\n-/\ntheorem eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin (hf : MeromorphicAt f x)\n (h₁x : x ∈ U) (h₂x : AccPt x (𝓟 U)) (h : f =ᶠ[codiscreteWithin U] 0) :\n f =ᶠ[𝓝[≠] x] 0 := by\n rw [← hf.frequently_zero_iff_eventuallyEq_zero]\n apply ((accPt_iff_frequently_nhdsNE.1 h₂x).and_eventually <| eventually_mem_set.2\n (mem_codiscreteWithin_iff_forall_mem_nhdsNE.1 h x h₁x)).mono\n simp +contextual\n\n/--\nVariant of the principle of isolated zeros, formulated in terms of orders: If `f` is nowhere locally\nconstant zero, then its zero set is discrete within its domain of meromorphicity.\n-/\ntheorem MeromorphicOn.codiscreteWithin_setOf_ne_zero (h₁f : MeromorphicOn f U)\n (h₂f : ∀ u ∈ U, meromorphicOrderAt f u ≠ ⊤) :\n ∀ᶠ x in codiscreteWithin U, f x ≠ 0 := by\n filter_upwards [h₁f.analyticAt_mem_codiscreteWithin,\n h₁f.codiscreteWithin_setOf_meromorphicOrderAt_eq_zero_or_top h₂f] with x h₁x h₂x\n have := h₂f x h₂x.1\n simp_all [← h₁x.analyticOrderAt_eq_zero, h₁x.meromorphicOrderAt_eq]\n\n/-!\n## Identity Principles\n-/\n\n/--\nFormulation of `MeromorphicAt.frequently_zero_iff_eventuallyEq_zero` as an identity principle: If\n`f` and `g` are meromorphic at `x`, then `f` and `g` agree eventually in a punctured neighborhood of\n`x` iff they agree at points arbitrarily close to (but different from) `x`.\n-/\ntheorem frequently_eq_iff_eventuallyEq (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :\n (∃ᶠ z in 𝓝[≠] x, f z = g z) ↔ f =ᶠ[𝓝[≠] x] g := by\n rw [eventuallyEq_iff_sub, ← (hf.sub hg).frequently_zero_iff_eventuallyEq_zero]\n simp_rw [Pi.sub_apply, sub_eq_zero]\n\n/--\nFormulation of `MeromorphicAt.eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin` as an\nidentity principle: Let `U` be a subset of `𝕜` and assume that `x ∈ U` is not an isolated point of\n`U`. If function `f` and `g` are meromorphic at `x` and agree along a subset that is codiscrete\nwithin `U`, then `f` and `g` agree in a punctured neighbourhood of `f`.\n-/\ntheorem eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (hf : MeromorphicAt f x)\n (hg : MeromorphicAt g x) (h₁x : x ∈ U) (h₂x : AccPt x (𝓟 U)) (h : f =ᶠ[codiscreteWithin U] g) :\n f =ᶠ[𝓝[≠] x] g := by\n rw [eventuallyEq_iff_sub] at *\n apply (hf.sub hg).eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin h₁x h₂x h\n\n/-\nVariant of `MeromorphicAt.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin`, as a statement\nabout meromorphic functions that agree outside a set codiscrete within a perfect set.\n-/\ntheorem eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin_preperfect (hf : MeromorphicAt f x)\n (hg : MeromorphicAt g x) (hx : x ∈ U) (hU : Preperfect U) (h : f =ᶠ[codiscreteWithin U] g) :\n f =ᶠ[𝓝[≠] x] g :=\n hf.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin hg hx (hU x hx) h\n\n/-\nVariant of `MeromorphicAt.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin`, as a statement\nabout meromorphic functions agreeing in a neighborhood of a preperfect set.\n-/\n\nTarget:\ntheorem eventually_nhdsSet_eventuallyEq_codiscreteWithin (hf : MeromorphicOn f U)\n (hg : MeromorphicOn g U) (hU : Preperfect U) (h : f =ᶠ[codiscreteWithin U] g) :\n ∀ᶠ x in 𝓝ˢ U, f =ᶠ[𝓝[≠] x] g :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Meromorphic","family_id":"eventually_nhdsset_eventuallyeq_codiscretewithin","file_id":"mathlib/Mathlib/Analysis/Meromorphic/IsolatedZeros.lean","sample_id":"bb2cd1dc1ca862e5834880bcae70362b553393815a6d23f611f6a7116781ebf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"50e1884f204fe9b0194be2baa5dce9eea0b7edf0ff4416c86d663c15e06a8313","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9cce75ab917fb3c053ffd27cab71b947abe3384de97a41143ca69e50f697cd74","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf27af568e5ddb49b9516f70bedf6915249cc5893f64759981a14879b4377b5b","source_sha256":"f7d1bebf16f480e84526d8880e653d41fa5a6f52a23418295c797275de9896c1","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n induction n with\n | zero => rfl\n | succ n hn =>\n rw [Finset.sum_range_succ, numDerangements_succ, hn, Finset.mul_sum, tsub_self,\n Nat.ascFactorial_zero, Int.ofNat_one, mul_one, pow_succ', neg_one_mul, sub_eq_add_neg,\n add_left_inj, Finset.sum_congr rfl]\n -- show that (n + 1) * (-1)^x * asc_fac x (n - x) = (-1)^x * asc_fac x (n.succ - x)\n intro x hx\n have h_le : x ≤ n := Finset.mem_range_succ_iff.mp hx\n rw [Nat.succ_sub h_le, Nat.ascFactorial_succ, add_right_comm, add_tsub_cancel_of_le h_le,\n Int.natCast_mul, Int.natCast_add, mul_left_comm, Nat.cast_one]","hard_negative":false,"metrics":{"chosen_tokens":139,"rejected_tokens":146,"token_jaccard":0.967213,"token_length_ratio":1.05036},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"1f84a31fb5b766755fc250eb1cd3158f90df1c8f657aa16ba1422354ed776796","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Combinatorics.Derangements.Basic\npublic import Mathlib.Data.Fintype.BigOperators\npublic import Mathlib.Tactic.Ring\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Henry Swanson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henry Swanson\n-/\n/-!\n# Derangements on fintypes\n\nThis file contains lemmas that describe the cardinality of `derangements α` when `α` is a fintype.\n\n## Main definitions\n\n* `card_derangements_invariant`: A lemma stating that the number of derangements on a type `α`\n depends only on the cardinality of `α`.\n* `numDerangements n`: The number of derangements on an n-element set, defined in a computation-\n friendly way.\n* `card_derangements_eq_numDerangements`: Proof that `numDerangements` really does compute the\n number of derangements.\n* `numDerangements_sum`: A lemma giving an expression for `numDerangements n` in terms of\n factorials.\n-/\n\n@[expose] public section\n\n\nopen derangements Equiv Fintype\n\nvariable {α : Type*} [DecidableEq α] [Fintype α]\n\ninstance : DecidablePred (· ∈ derangements α) := fun _ => Fintype.decidableForallFintype\n\ninstance : Fintype (derangements α) :=\n inferInstanceAs <| Fintype { f : Perm α | ∀ x : α, f x ≠ x }\n\n\ntheorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β]\n [DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) :=\n Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h)\n\ntheorem card_derangements_fin_add_two (n : ℕ) :\n card (derangements (Fin (n + 2))) =\n (n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by\n -- get some basic results about the size of Fin (n+1) plus or minus an element\n have h1 : ∀ a : Fin (n + 1), card ({a}ᶜ : Set (Fin (n + 1))) = card (Fin n) := by\n intro a\n rw [Fintype.card_compl_set]\n simp\n have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option]\n -- rewrite the LHS and substitute in our fintype-level equivalence\n simp only [card_derangements_invariant h2,\n card_congr\n (@derangementsRecursionEquiv (Fin (n + 1))\n _), -- push the cardinality through the Σ and ⊕ so that we can use `card_n`\n card_sigma,\n card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin,\n mul_add, Nat.cast_id]\n\n/-- The number of derangements of an `n`-element set. -/\ndef numDerangements : ℕ → ℕ\n | 0 => 1\n | 1 => 0\n | n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1))\n\n@[simp]\ntheorem numDerangements_zero : numDerangements 0 = 1 :=\n rfl\n\n@[simp]\ntheorem numDerangements_one : numDerangements 1 = 0 :=\n rfl\n\ntheorem numDerangements_add_two (n : ℕ) :\n numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) :=\n rfl\n\ntheorem numDerangements_succ (n : ℕ) :\n (numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by\n induction n with\n | zero => rfl\n | succ n hn =>\n simp only [numDerangements_add_two, hn, pow_succ, Int.natCast_mul, Int.natCast_add]\n ring\n\ntheorem card_derangements_fin_eq_numDerangements {n : ℕ} :\n card (derangements (Fin n)) = numDerangements n := by\n induction n using Nat.strongRecOn with | ind n hyp => _\n rcases n with _ | _ | n\n -- knock out cases 0 and 1\n · rfl\n · rfl\n -- now we have n ≥ 2. rewrite everything in terms of card_derangements, so that we can use\n -- `card_derangements_fin_add_two`\n rw [numDerangements_add_two, card_derangements_fin_add_two, mul_add, hyp, hyp] <;> lia\n\ntheorem card_derangements_eq_numDerangements (α : Type*) [Fintype α] [DecidableEq α] :\n card (derangements α) = numDerangements (card α) := by\n rw [← card_derangements_invariant (card_fin _)]\n exact card_derangements_fin_eq_numDerangements\n\nTarget:\ntheorem numDerangements_sum (n : ℕ) :\n (numDerangements n : ℤ) =\n ∑ k ∈ Finset.range (n + 1), (-1 : ℤ) ^ k * Nat.ascFactorial (k + 1) (n - k) :=\n\nProof body:\n","rejected":"```lean\nby\n induction n with\n | zero => rfl\n | succ n hn =>\n rw [Finset.sum_range_succ, numDerangements_succ, hn, Finset.mul_sum, tsub_self,\n Nat.ascFactorial_zero, Int.ofNat_one, mul_one, pow_succ', neg_one_mul, sub_eq_add_neg,\n add_left_inj, Finset.sum_congr rfl]\n -- show that (n + 1) * (-1)^x * asc_fac x (n - x) = (-1)^x * asc_fac x (n.succ - x)\n intro x hx\n have h_le : x ≤ n := Finset.mem_range_succ_iff.mp hx\n rw [Nat.succ_sub h_le, Nat.ascFactorial_succ, add_right_comm, add_tsub_cancel_of_le h_le,\n Int.natCast_mul, Int.natCast_add, mul_left_comm, Nat.cast_one]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Derangements","family_id":"numderangements_sum","file_id":"mathlib/Mathlib/Combinatorics/Derangements/Finite.lean","sample_id":"cf27af568e5ddb49b9516f70bedf6915249cc5893f64759981a14879b4377b5b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0e2365d082165e3f9f94dfdeaecbad20029ad2665e51c2321129c8c07c450e6c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1b1dc83866b44921ff69681b932b284279c83a51731f2c627f731ad11176b5b7","source_sha256":"c1a21bb2aff2b44e6ec04f2e53e3c6ae24da1643eeece808534c81e1e3b64c70","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [RemoveNone.fiber, derangements]","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":3,"token_jaccard":0.090909,"token_length_ratio":0.333333},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"1f93df8998bee4ca1b644c198a4677e4d7b5194ad2f92c214347b072963129f5","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.FixedPoints.Basic\npublic import Mathlib.GroupTheory.Perm.Option\npublic import Mathlib.Logic.Equiv.Defs\npublic import Mathlib.Logic.Equiv.Option\npublic import Mathlib.Tactic.ApplyFun\n\nNamespace:\nderangements.Equiv\n\nLocal context:\n/-\nCopyright (c) 2021 Henry Swanson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henry Swanson\n-/\n/-!\n# Derangements on types\n\nIn this file we define `derangements α`, the set of derangements on a type `α`.\n\nWe also define some equivalences involving various subtypes of `Perm α` and `derangements α`:\n* `derangementsOptionEquivSigmaAtMostOneFixedPoint`: An equivalence between\n `derangements (Option α)` and the sigma-type `Σ a : α, {f : Perm α // fixedPoints f ⊆ a}`.\n* `derangementsRecursionEquiv`: An equivalence between `derangements (Option α)` and the\n sigma-type `Σ a : α, (derangements (({a}ᶜ : Set α) : Type*) ⊕ derangements α)` which is later\n used to inductively count the number of derangements.\n\nIn order to prove the above, we also prove some results about the effect of `Equiv.removeNone`\non derangements: `RemoveNone.fiber_none` and `RemoveNone.fiber_some`.\n-/\n\n@[expose] public section\n\n\nopen Equiv Function\n\n/-- A permutation is a derangement if it has no fixed points. -/\ndef derangements (α : Type*) : Set (Perm α) :=\n { f : Perm α | ∀ x : α, f x ≠ x }\n\nvariable {α β : Type*}\n\ntheorem mem_derangements_iff_fixedPoints_eq_empty {f : Perm α} :\n f ∈ derangements α ↔ fixedPoints f = ∅ :=\n Set.eq_empty_iff_forall_notMem.symm\n\n/-- If `α` is equivalent to `β`, then `derangements α` is equivalent to `derangements β`. -/\ndef Equiv.derangementsCongr (e : α ≃ β) : derangements α ≃ derangements β :=\n e.permCongr.subtypeEquiv fun {f} => e.forall_congr <| by\n intro b; simp only [ne_eq, permCongr_apply, symm_apply_apply, EmbeddingLike.apply_eq_iff_eq]\n\nnamespace derangements\n\n/-- Derangements on a subtype are equivalent to permutations on the original type where points are\nfixed iff they are not in the subtype. -/\nprotected def subtypeEquiv (p : α → Prop) [DecidablePred p] :\n derangements (Subtype p) ≃ { f : Perm α // ∀ a, ¬p a ↔ a ∈ fixedPoints f } :=\n calc\n derangements (Subtype p) ≃ { f : { f : Perm α // ∀ a, ¬p a → a ∈ fixedPoints f } //\n ∀ a, a ∈ fixedPoints f → ¬p a } := by\n refine (Perm.subtypeEquivSubtypePerm p).subtypeEquiv fun f => ⟨fun hf a hfa ha => ?_, ?_⟩\n · refine hf ⟨a, ha⟩ (Subtype.ext ?_)\n simp_rw [mem_fixedPoints, IsFixedPt, Perm.subtypeEquivSubtypePerm,\n Equiv.coe_fn_mk, Perm.ofSubtype_apply_of_mem _ ha] at hfa\n assumption\n rintro hf ⟨a, ha⟩ hfa\n refine hf _ ?_ ha\n simp only [Perm.subtypeEquivSubtypePerm_apply_coe, mem_fixedPoints]\n dsimp [IsFixedPt]\n simp_rw [Perm.ofSubtype_apply_of_mem _ ha, hfa]\n _ ≃ { f : Perm α // ∃ _h : ∀ a, ¬p a → a ∈ fixedPoints f, ∀ a, a ∈ fixedPoints f → ¬p a } :=\n subtypeSubtypeEquivSubtypeExists _ _\n _ ≃ { f : Perm α // ∀ a, ¬p a ↔ a ∈ fixedPoints f } :=\n subtypeEquivRight fun f => by\n simp_rw [exists_prop, ← forall_and, ← iff_iff_implies_and_implies]\n\nuniverse u\n/-- The set of permutations that fix either `a` or nothing is equivalent to the sum of:\n- derangements on `α`\n- derangements on `α` minus `a`. -/\ndef atMostOneFixedPointEquivSum_derangements [DecidableEq α] (a : α) :\n { f : Perm α // fixedPoints f ⊆ {a} } ≃ (derangements ({a}ᶜ : Set α)) ⊕ (derangements α) :=\n calc\n { f : Perm α // fixedPoints f ⊆ {a} } ≃\n { f : { f : Perm α // fixedPoints f ⊆ {a} } // a ∈ fixedPoints f } ⊕\n { f : { f : Perm α // fixedPoints f ⊆ {a} } // a ∉ fixedPoints f } :=\n (Equiv.sumCompl _).symm\n _ ≃ { f : Perm α // fixedPoints f ⊆ {a} ∧ a ∈ fixedPoints f } ⊕\n { f : Perm α // fixedPoints f ⊆ {a} ∧ a ∉ fixedPoints f } := by\n refine Equiv.sumCongr ?_ ?_\n · exact subtypeSubtypeEquivSubtypeInter\n (fun x : Perm α => fixedPoints x ⊆ {a})\n (a ∈ fixedPoints ·)\n · exact subtypeSubtypeEquivSubtypeInter\n (fun x : Perm α => fixedPoints x ⊆ {a})\n (a ∉ fixedPoints ·)\n _ ≃ { f : Perm α // fixedPoints f = {a} } ⊕ { f : Perm α // fixedPoints f = ∅ } := by\n refine Equiv.sumCongr (subtypeEquivRight fun f => ?_) (subtypeEquivRight fun f => ?_)\n · rw [Set.eq_singleton_iff_unique_mem, and_comm]\n rfl\n · rw [Set.eq_empty_iff_forall_notMem]\n exact ⟨fun h x hx => h.2 (h.1 hx ▸ hx), fun h => ⟨fun x hx => (h _ hx).elim, h _⟩⟩\n _ ≃ derangements ({a}ᶜ : Set α) ⊕ derangements α := by\n refine\n Equiv.sumCongr ((derangements.subtypeEquiv _).trans <|\n subtypeEquivRight fun x => ?_).symm\n (subtypeEquivRight fun f => mem_derangements_iff_fixedPoints_eq_empty.symm)\n rw [eq_comm, Set.ext_iff]\n simp_rw [Set.mem_compl_iff, Classical.not_not]\n\nnamespace Equiv\n\nvariable [DecidableEq α]\n\n/-- The set of permutations `f` such that the preimage of `(a, f)` under\n`Equiv.Perm.decomposeOption` is a derangement. -/\ndef RemoveNone.fiber (a : Option α) : Set (Perm α) :=\n { f : Perm α | (a, f) ∈ Equiv.Perm.decomposeOption '' derangements (Option α) }\n\nTarget:\ntheorem RemoveNone.mem_fiber (a : Option α) (f : Perm α) :\n f ∈ RemoveNone.fiber a ↔\n ∃ F : Perm (Option α), F ∈ derangements (Option α) ∧ F none = a ∧ removeNone F = f :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Derangements","family_id":"removenone","file_id":"mathlib/Mathlib/Combinatorics/Derangements/Basic.lean","sample_id":"1b1dc83866b44921ff69681b932b284279c83a51731f2c627f731ad11176b5b7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5a761837ffec5e8a77b1f2327450071cb981ebac00b45daf2e26ebda06d2cb51","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e24732b0f9210e3970530279fd8af200c184f576c489cb66cd869725d4803016","source_sha256":"506091950f9a5ddd7bcf057ff1f552335cf3d11ecb0050a4aad97186871b2737","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [smul_one_smul] using SMulInvariantMeasure.measure_preimage_smul (c • 1 : N) hsm\n aeconst_of_forall_preimage_smul_ae_eq {s} hsm hs := by\n refine aeconst_of_dense_setOf_preimage_smul_ae (M := N) hsm.nullMeasurableSet ?_\n refine (MulAction.dense_orbit M 1).mono ?_\n rintro _ ⟨g, rfl⟩\n simpa using hs g","hard_negative":false,"metrics":{"chosen_tokens":61,"rejected_tokens":5,"token_jaccard":0.047619,"token_length_ratio":0.081967},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"1fe139ae97f3a1598551355f899f58119b53da92382f668e760e5b365a57242a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.Ergodic.Action.Regular\npublic import Mathlib.MeasureTheory.Measure.ContinuousPreimage\npublic import Mathlib.MeasureTheory.Measure.Haar.Unique\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Ergodicity from minimality\n\nIn this file we prove that the left shift `(a * ·)` on a compact topological group `G`\nis ergodic with respect to the Haar measure if and only if it is minimal,\ni.e., the powers `a ^ n` are dense in `G`.\n\nThe proof of the more difficult \"if minimal, then ergodic\" implication\nis based on the ergodicity of the left action of a group on itself\nand the following fact that we prove in `ergodic_smul_of_denseRange_pow` below:\n\nIf a monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural powers are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the scalar multiplication by `g` is an ergodic map.\n\nWe also prove that a continuous monoid homomorphism `f : G →* G` is ergodic,\nif it is surjective and the preimages of `1` under iterations of `f` are dense in the group.\nThis theorem applies, e.g., to the map `z ↦ n • z` on the additive circle or a torus.\n-/\n\npublic section\n\nopen MeasureTheory Filter Set Function\nopen scoped Pointwise Topology\n\nsection SMul\n\nvariable {M : Type*} [TopologicalSpace M]\n {X : Type*} [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]\n [SMul M X] [ContinuousSMul M X]\n {μ : Measure X} [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] {s : Set X}\n\n/-- Let `M` act continuously on an R₁ topological space `X`.\nLet `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.\nIf a null measurable set `s` is a.e. equal\nto its preimages under the action of a dense set of elements of `M`,\nthen it is either null or conull. -/\n@[to_additive /-- Let `M` act continuously on an R₁ topological space `X`.\nLet `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.\nIf a null measurable set `s` is a.e. equal\nto its preimages under the action of a dense set of elements of `M`,\nthen it is either null or conull. -/]\ntheorem aeconst_of_dense_setOf_preimage_smul_ae (hsm : NullMeasurableSet s μ)\n (hd : Dense {g : M | (g • ·) ⁻¹' s =ᵐ[μ] s}) : EventuallyConst s (ae μ) := by\n borelize M\n refine aeconst_of_forall_preimage_smul_ae_eq M hsm ?_\n rwa [dense_iff_closure_eq, IsClosed.closure_eq, eq_univ_iff_forall] at hd\n let f : C(M × X, X) := ⟨(· • ·).uncurry, continuous_smul⟩\n exact isClosed_setOf_preimage_ae_eq f.curry.continuous (measurePreserving_smul · μ) _ hsm\n (measure_ne_top _ _)\n\n@[to_additive]\ntheorem aeconst_of_dense_setOf_preimage_smul_eq (hsm : NullMeasurableSet s μ)\n (hd : Dense {g : M | (g • ·) ⁻¹' s = s}) : EventuallyConst s (ae μ) :=\n aeconst_of_dense_setOf_preimage_smul_ae hsm <| hd.mono fun _ h ↦ mem_setOf.2 <| .of_eq h\n\n/-- If a monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural powers are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the scalar multiplication by `g` is an ergodic map. -/\n@[to_additive /-- If an additive monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural multiples are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the vector addition of `g` is an ergodic map. -/]\ntheorem ergodic_smul_of_denseRange_pow {M : Type*} [Monoid M] [TopologicalSpace M]\n [MulAction M X] [ContinuousSMul M X] {g : M} (hg : DenseRange (g ^ · : ℕ → M))\n (μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] :\n Ergodic (g • ·) μ := by\n borelize M\n refine ⟨measurePreserving_smul _ _, ⟨fun s hsm hs ↦ ?_⟩⟩\n refine aeconst_of_dense_setOf_preimage_smul_eq hsm.nullMeasurableSet (hg.mono ?_)\n refine range_subset_iff.2 fun n ↦ ?_\n rw [mem_setOf, ← smul_iterate, preimage_iterate_eq, iterate_fixed hs]\n\nend SMul\n\nsection IsScalarTower\n\nvariable {M X : Type*} [Monoid M] [SMul M X]\n [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]\n (μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular]\n\n/-- If `N` acts continuously and ergodically on `X` and `M` acts minimally on `N`,\nthen the corresponding action of `M` on `X` is ergodic. -/\n@[to_additive\n /-- If `N` acts additively continuously and ergodically on `X` and `M` acts minimally on `N`,\nthen the corresponding action of `M` on `X` is ergodic. -/]\n\nTarget:\ntheorem ErgodicSMul.trans_isMinimal (N : Type*) [MulAction M N]\n [Monoid N] [TopologicalSpace N] [MulAction.IsMinimal M N]\n [MulAction N X] [IsScalarTower M N X] [ContinuousSMul N X] [ErgodicSMul N X μ] :\n ErgodicSMul M X μ where\n measure_preimage_smul c s hsm :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/Ergodic","family_id":"ergodicsmul","file_id":"mathlib/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean","sample_id":"e24732b0f9210e3970530279fd8af200c184f576c489cb66cd869725d4803016"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6faafed98e03cc2a26389678ceb051ea0db59bcdfaa4b05ea6a8a05465195a05","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6e28ab5985d130ab13612f54c6272987c76a8b30f577aff077482516afe19217","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5564cc38c1b82f10157b782588a5b57207242633422df26e8b2ff5770e710c69","source_sha256":"6ca40a9a028dbe37b0e6d35f519e15fb40bd243ba89a07bbe3689aea9c6deaf6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := e.isLocalRing\n have := isNoetherianRing_of_ringEquiv R e\n rwa [isRegularLocalRing_iff, ← ringKrullDim_eq_of_ringEquiv e, ← map_ringEquiv_maximalIdeal e,\n Ideal.spanFinrank_map_eq_of_ringEquiv, ← isRegularLocalRing_iff]","hard_negative":false,"metrics":{"chosen_tokens":30,"rejected_tokens":37,"token_jaccard":0.9,"token_length_ratio":1.233333},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"219ff75a4f064bb6127beb706a302f001e596107089c7aff65d0b6a3c14f5c74","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.SpanRankOperations\npublic import Mathlib.RingTheory.DedekindDomain.Dvr\npublic import Mathlib.RingTheory.Ideal.KrullsHeightTheorem\npublic import Mathlib.RingTheory.KrullDimension.Field\npublic import Mathlib.RingTheory.KrullDimension.PID\n\nNamespace:\nIsRegularLocalRing\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# Regular local rings\n\nFor a Noetherian local ring `R`, we define `IsRegularLocalRing` as\n`(maximalIdeal R).spanFinrank = ringKrullDim R`. This definition is equivalent to\nthe dimension of the cotangent space over the residue field being equal to `ringKrullDim R`,\n(see `IsRegularLocalRing.iff_finrank_cotangentSpace`).\n\nFor the next section, we define regular rings as Noetherian rings whose localization at every prime\nare regular local rings.\n(Note that a regular local ring is a regular ring, but this is not immediate under this definition).\n\n# Main Definition and Results\n\n* `IsRegularLocalRing` : A Noetherian local ring is regular if\n `(maximalIdeal R).spanFinrank = ringKrullDim R`,\n i.e. its maximal ideal can be generated by `dim R` elements.\n\n* `IsRegularLocalRing.iff_finrank_cotangentSpace` : the equivalence of `IsRegularLocalRing` and\n `Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R`\n\n* `IsRegularRing` : A noetherian ring is regular if its localization at any prime\n `IsRegularLocalRing`.\n\n## TODO\nShow that regular local rings are regular under this definition.\nThis follows from localizations of regular local rings being regular (@Thmoas-Guan).\n\n-/\n\npublic section\n\nopen IsLocalRing\n\n/-- A Noetherian local ring is said to be regular if its maximal ideal\ncan be generated by `dim R` elements. -/\n@[stacks 00KU]\nclass IsRegularLocalRing (R : Type*) [CommRing R] : Prop extends\n IsLocalRing R, IsNoetherianRing R where\n spanFinrank_maximalIdeal : (maximalIdeal R).spanFinrank = ringKrullDim R\n\nvariable (R : Type*) [CommRing R]\n\nlemma isRegularLocalRing_iff [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ (maximalIdeal R).spanFinrank = ringKrullDim R :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nnamespace IsRegularLocalRing\n\nlemma of_spanFinrank_maximalIdeal_le [IsLocalRing R] [IsNoetherianRing R]\n (le : (maximalIdeal R).spanFinrank ≤ ringKrullDim R) : IsRegularLocalRing R :=\n (isRegularLocalRing_iff _).mpr (le_antisymm le (ringKrullDim_le_spanFinrank_maximalIdeal R))\n\nvariable {R} in\n\nTarget:\nlemma of_ringEquiv [IsRegularLocalRing R] {R' : Type*} [CommRing R']\n (e : R ≃+* R') : IsRegularLocalRing R' :=\n\nProof body:\n","rejected":"```lean\nby\n have := e.isLocalRing\n have := isNoetherianRing_of_ringEquiv R e\n rwa [isRegularLocalRing_iff, ← ringKrullDim_eq_of_ringEquiv e, ← map_ringEquiv_maximalIdeal e,\n Ideal.spanFinrank_map_eq_of_ringEquiv, ← isRegularLocalRing_iff]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RegularLocalRing","family_id":"of_ringequiv","file_id":"mathlib/Mathlib/RingTheory/RegularLocalRing/Defs.lean","sample_id":"5564cc38c1b82f10157b782588a5b57207242633422df26e8b2ff5770e710c69"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e2d0eb1061c28564b13ac9438a2f1e865121d76a9bcfc8384b6637eb94e69716","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a612a3692a4ac846073a03e162d2b14004d764ba83f8274c66dd9508374681a0","source_sha256":"a0c4f879a338ab6470bdd61aa6cb4790c1abee3840d61f2c802fcb6c81cb3ac9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · exact codRestrictEqLocusPushoutCocone.injective_of_faithfulSMul _ _\n · exact codRestrictEqLocusPushoutCocone.surjective_of_isEffective _ _ (.of_faithfullyFlat R S)","hard_negative":false,"metrics":{"chosen_tokens":22,"rejected_tokens":5,"token_jaccard":0.1875,"token_length_ratio":0.227273},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"21ca0f1c8144f27f990534780a930ca8a3a0fdbec3a1af52645e2cb0b23d67ff","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Ring.Constructions\npublic import Mathlib.RingTheory.Flat.FaithfullyFlat.Algebra\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2025 Yong-Gyu Choi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yong-Gyu Choi\n-/\n/-!\n# Exactness properties of the difference map on tensor products\n\nFor an `R`-algebra `S`, we collect some properties of the `R`-linear map `S →ₗ[R] S ⊗[R] S` given\nby `s ↦ s ⊗ₜ 1 - 1 ⊗ₜ s`.\n\n## Main definitions\n\n* `includeLeftSubRight`: The `R`-linear map sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`.\n* `IsEffective`: Exactness of the sequence `R → S → S ⊗[R] S` where the first map is\n `Algebra.linearMap R S` and the second map is `includeLeftSubRight`. When `R` and `S` are\n commutative rings, this is equivalent to the inclusion `im (algebraMap : R → S) → S` being an\n effective monomorphism in `CommRingCat`.\n\n## Main results\n\n* `IsEffective.of_faithfullyFlat`: `IsEffective R S` is true for any faithfully flat `R`-algebra `S`\n\n-/\n\n@[expose] public section\n\nopen scoped TensorProduct\n\nnamespace Algebra\n\nvariable {R : Type*} [CommSemiring R]\nvariable {S : Type*} [Ring S] [Algebra R S]\n\nnamespace TensorProduct\n\nsection IncludeLeftSubRight\n\nvariable (R S) in\n/-- The `R`-linear map `S →ₗ[R] S ⊗[R] S` sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`. -/\ndef includeLeftSubRight : S →ₗ[R] S ⊗[R] S :=\n includeLeft.toLinearMap - includeRight.toLinearMap\n\n@[simp]\nlemma includeLeftSubRight_apply (s : S) : includeLeftSubRight R S s = s ⊗ₜ[R] 1 - 1 ⊗ₜ[R] s :=\n rfl\n\n/-- `includeLeftSubRight R S` vanishes in the range of `algebraMap R S`. -/\nlemma includeLeftSubRight_zero_of_mem_range {s : S} (hs : s ∈ Set.range ⇑(algebraMap R S)) :\n includeLeftSubRight R S s = 0 := by\n obtain ⟨_, hr⟩ := Set.mem_range.mp hs\n simp [← hr, algebraMap_eq_smul_one]\n\n/-- `includeLeftSubRight R S` vanishes at `algebraMap R S r`. -/\nlemma includeLeftSubRight_algebraMap_zero (r : R) :\n includeLeftSubRight R S (algebraMap R S r) = 0 :=\n includeLeftSubRight_zero_of_mem_range (Set.mem_range.mp (exists_apply_eq_apply _ _))\n\n/-- `includeLeftSubRight` is compatible with `distribBaseChange` and `lTensor`. -/\nlemma distribBaseChange_comp_includeLeftSubRight (T : Type*) [CommRing T] [Algebra R T] :\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).restrictScalars R).toLinearMap ∘ₗ\n (includeLeftSubRight R S).lTensor T =\n (includeLeftSubRight T (T ⊗[R] S)).restrictScalars R := by\n ext\n simp [TensorProduct.tmul_sub, TensorProduct.one_def, tmul_one_tmul_one_tmul]\n\n@[simp]\nlemma distribBaseChange_includeLeftSubRight_apply (T : Type*) [CommRing T] [Algebra R T]\n (x : T ⊗[R] S) :\n TensorProduct.AlgebraTensorModule.distribBaseChange R T S S\n ((includeLeftSubRight R S).lTensor T x) =\n includeLeftSubRight T (T ⊗[R] S) x :=\n congr($(distribBaseChange_comp_includeLeftSubRight _) x)\n\nend IncludeLeftSubRight\n\nend TensorProduct\n\nvariable (R S) in\n/-- For an `R`-algebra `S`, this asserts that the maps `algebraMap : R → S` and\n`includeLeftSubRight R S : S → S ⊗[R] S` form an exact pair.\nWhen `R` and `S` are commutative rings, this is true if and only if the inclusion\n`im (algebraMap : R → S) → S` is an effective monomorphism in the category of commutative rings. -/\ndef IsEffective : Prop :=\n Function.Exact (Algebra.linearMap R S) (TensorProduct.includeLeftSubRight R S)\n\nnamespace IsEffective\n\n/-- If `IsEffective R S` is true, then the equalizer of `s ↦ s ⊗ₜ 1 : S →+* S ⊗[R] S` and\n`s ↦ 1 ⊗ₜ s : S →+* S ⊗[R] S` is the image of `algebraMap R S : R →+* S`. -/\nlemma eqLocus_includeLeft_includeRight (h : IsEffective R S) :\n TensorProduct.includeLeftRingHom.eqLocus TensorProduct.includeRight.toRingHom (S := S ⊗[R] S) =\n Set.range (algebraMap R S) := by\n ext s\n refine ⟨?_, fun ⟨_, hr⟩ ↦ by simp [← hr]⟩\n intro hs\n exact (h s).mp <| (TensorProduct.includeLeftSubRight_apply (R := R) s).symm ▸ sub_eq_zero.mpr hs\n\n/-- `IsEffective` is true for any `R`-algebra `S` having an `R`-algebra section of\n`Algebra.ofId _ _ : R →ₐ[R] S`. -/\nlemma of_section (g : S →ₐ[R] R) : IsEffective R S := by\n intro s\n refine ⟨?_, TensorProduct.includeLeftSubRight_zero_of_mem_range⟩\n intro hs\n use g s\n apply (TensorProduct.lid R S).symm.injective\n rw [TensorProduct.lid_symm_apply, TensorProduct.lid_symm_apply,\n ← mul_one ((Algebra.linearMap R S) _), Algebra.coe_linearMap, ← Algebra.smul_def,\n ← TensorProduct.smul_tmul, smul_eq_mul, mul_one, ← AlgHom.id_apply (R := R) (1 : S),\n ← TensorProduct.map_tmul,\n sub_eq_zero.mp ((TensorProduct.includeLeftSubRight_apply s).symm.trans hs),\n TensorProduct.map_tmul, map_one, AlgHom.id_apply]\n\nsection FaithfullyFlat\n\nvariable (R : Type*) [CommRing R]\nvariable (S : Type*)\nvariable (T : Type*) [CommRing T] [Algebra R T]\n\n/-- `IsEffective` descends along faithfully flat algebras. -/\nlemma of_isEffective_tensorProduct_of_faithfullyFlat\n [Ring S] [Algebra R S] [Module.FaithfullyFlat R T] (h : IsEffective T (T ⊗[R] S)) :\n IsEffective R S := by\n refine Module.FaithfullyFlat.lTensor_reflects_exact _ _ _ _ <|\n AddMonoidHom.exact_iff_of_surjective_of_bijective_of_injective\n ((Algebra.linearMap R S).lTensor T) ((TensorProduct.includeLeftSubRight R S).lTensor T)\n (Algebra.linearMap T (T ⊗[R] S)) (TensorProduct.includeLeftSubRight T (T ⊗[R] S))\n (TensorProduct.rid R R T).toAddMonoidHom (AddMonoidHom.id (T ⊗[R] S))\n (TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).toAddMonoidHom ?_ ?_\n (TensorProduct.rid R R T).surjective Function.bijective_id\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).injective) |>.mpr ‹_›\n · ext\n simp [← Algebra.TensorProduct.linearMap_comp_rid]\n -- The goal is TensorProduct.rid .. = TensorProduct.AlgebraTensorModule.rid ..\n -- TODO: merge both into one definition, and remove the rfl.\n rfl\n · ext\n simp\n\n/-- `IsEffective R S` is true for any faithfully flat `R`-algebra `S`. -/\nlemma of_faithfullyFlat [CommRing S] [Algebra R S] [Module.FaithfullyFlat R S] :\n IsEffective R S :=\n of_isEffective_tensorProduct_of_faithfullyFlat _ _ _ (of_section (TensorProduct.lmul'' R))\n\nend FaithfullyFlat\n\nend IsEffective\n\nsection CodRestrictEqLocusPushoutCocone\n\nuniverse u\n\nvariable (R S : Type u) [CommRing R] [CommRing S] [Algebra R S]\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The canonical ring map from `R` to the explicit equalizer of\n`includeLeft : S ⟶ S ⊗[R] S` and `includeRight : S ⟶ S ⊗[R] S`. -/\ndef codRestrictEqLocusPushoutCocone :\n R →+* (CommRingCat.equalizerFork\n (CommRingCat.pushoutCocone R S S).inl (CommRingCat.pushoutCocone R S S).inr).pt :=\n RingHom.codRestrict (algebraMap R S)\n ((CommRingCat.pushoutCocone R S S).inl.hom.eqLocus (CommRingCat.pushoutCocone R S S).inr.hom)\n (by simp)\n\n/-- Injectivity of `algebraMap R S` implies injectivity of `codRestrictEqLocusPushoutCocone`. -/\nlemma codRestrictEqLocusPushoutCocone.injective_of_faithfulSMul [FaithfulSMul R S] :\n Function.Injective (codRestrictEqLocusPushoutCocone R S) :=\n RingHom.injective_codRestrict.mpr (FaithfulSMul.algebraMap_injective _ _)\n\n/-- `Algebra.IsEffective R S` implies surjectivity of `codRestrictEqLocusPushoutCocone`. -/\nlemma codRestrictEqLocusPushoutCocone.surjective_of_isEffective (hf : Algebra.IsEffective R S) :\n Function.Surjective (codRestrictEqLocusPushoutCocone R S) := by\n intro ⟨s, hs⟩\n obtain ⟨t, rfl⟩ := Set.mem_range.mp <|\n Algebra.IsEffective.eqLocus_includeLeft_includeRight hf ▸ SetLike.mem_coe.mpr hs\n exact ⟨t, rfl⟩\n\n/-- If `S` is a faithfully flat `R`-algebra, `codRestrictEqLocusPushoutCocone` is bijective. -/\n\nTarget:\nlemma codRestrictEqLocusPushoutCocone.bijective_of_faithfullyFlat [Module.FaithfullyFlat R S] :\n Function.Bijective (codRestrictEqLocusPushoutCocone R S) :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/TensorProduct","family_id":"codrestricteqlocuspushoutcocone","file_id":"mathlib/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean","sample_id":"a612a3692a4ac846073a03e162d2b14004d764ba83f8274c66dd9508374681a0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f7e98285d54ed438b66b5fa3b3ec01a93901428fb62dffe9d958e186c396e8d4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e61fc132fd729d0478ef12501e85b3a757bd1d3766242afe2b8bdee40bbf66c8","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cead6dd50e97e63a22930509dad26949a52479242dfd79be2acbe7afd3d8de3e","source_sha256":"70a5b82da05fcedf5f71e60cf25a2a57b4c0e22c0f3c87605458658cd985002a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mem_invtSubmodule, Submodule.span_le, Submodule.comap_coe]\n intro y hy\n simp only [Set.mem_preimage, DistribSMul.toLinearMap_apply, SetLike.mem_coe]\n exact Submodule.subset_span <| MulAction.mem_orbit_of_mem_orbit g hy","hard_negative":true,"metrics":{"chosen_tokens":42,"rejected_tokens":5,"token_jaccard":0.1,"token_length_ratio":0.119048},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"21eae7ab3fae036f6f76296d2a5dd08d94142c4edfca719f1329780ca1dd9022","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Module.Equiv.Basic\npublic import Mathlib.Algebra.Module.Submodule.Map\npublic import Mathlib.LinearAlgebra.Span.Defs\npublic import Mathlib.Order.Sublattice\n\nNamespace:\nModule.End\n\nLocal context:\n/-\nCopyright (c) 2024 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\n/-!\n# The lattice of invariant submodules\n\nIn this file we defined the type `Module.End.invtSubmodule`, associated to a linear endomorphism of\na module. Its utility stems primarily from those occasions on which we wish to take advantage of the\nlattice structure of invariant submodules.\n\nSee also `Mathlib/Algebra/Polynomial/Module/AEval.lean`.\n\n-/\n\n@[expose] public section\n\nopen Submodule (span)\n\nnamespace Module.End\n\nvariable {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] (f g : End R M)\n\n/-- Given an endomorphism, `f` of some module, this is the sublattice of all `f`-invariant\nsubmodules. -/\ndef invtSubmodule : Sublattice (Submodule R M) where\n carrier := {p : Submodule R M | p ≤ p.comap f}\n supClosed' p hp q hq := sup_le_iff.mpr\n ⟨le_trans hp <| Submodule.comap_mono le_sup_left,\n le_trans hq <| Submodule.comap_mono le_sup_right⟩\n infClosed' p hp q hq := by\n simp only [Set.mem_setOf_eq, Submodule.comap_inf, le_inf_iff]\n exact ⟨inf_le_of_left_le hp, inf_le_of_right_le hq⟩\n\nlemma mem_invtSubmodule {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ p ≤ p.comap f :=\n Iff.rfl\n\n/-- `p` is `f` invariant if and only if `p.map f ≤ p`. -/\ntheorem mem_invtSubmodule_iff_map_le {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ p.map f ≤ p := Submodule.map_le_iff_le_comap.symm\n\n/-- `p` is `f` invariant if and only if `Set.MapsTo f p p`. -/\ntheorem mem_invtSubmodule_iff_mapsTo {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ Set.MapsTo f p p := Iff.rfl\n\nalias ⟨_, _root_.Set.Mapsto.mem_invtSubmodule⟩ := mem_invtSubmodule_iff_mapsTo\n\ntheorem mem_invtSubmodule_iff_forall_mem_of_mem {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ ∀ x ∈ p, f x ∈ p :=\n Iff.rfl\n\n/-- `p` is `f.symm` invariant if and only if `p ≤ p.map f`. -/\nlemma mem_invtSubmodule_symm_iff_le_map {f : M ≃ₗ[R] M} {p : Submodule R M} :\n p ∈ invtSubmodule f.symm ↔ p ≤ p.map (f : M →ₗ[R] M) :=\n (mem_invtSubmodule_iff_map_le _).trans (f.toEquiv.symm.subset_symm_image _ _).symm\n\nlemma invtSubmodule_inf_invtSubmodule_le_invtSubmodule_add :\n f.invtSubmodule ⊓ g.invtSubmodule ≤ (f + g).invtSubmodule :=\n fun p ⟨hfp, hgp⟩ _ hx ↦ p.add_mem (hfp hx) (hgp hx)\n\nsection CommRing\n\nvariable {R S : Type*} [Semiring R] [Semiring S] [Module R M] [Module S M]\n [DistribSMul S R] [SMulCommClass R S M] [IsScalarTower S R M] (f : End R M)\n\nlemma invtSubmodule_le_invtSubmodule_smul (c : S) : f.invtSubmodule ≤ (c • f).invtSubmodule :=\n fun p hfp _ hx ↦ p.smul_of_tower_mem c (hfp hx)\n\n@[simp]\nlemma invtSubmodule_smul (c : Sˣ) : (c • f).invtSubmodule = f.invtSubmodule := by\n apply le_antisymm ?_ (invtSubmodule_le_invtSubmodule_smul f c.1)\n grw [invtSubmodule_le_invtSubmodule_smul (c.1 • f) c⁻¹.1]\n simp [smul_smul]\n\nend CommRing\n\nnamespace invtSubmodule\n\nvariable {f}\n\nlemma inf_mem {p q : Submodule R M} (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n p ⊓ q ∈ f.invtSubmodule :=\n Sublattice.inf_mem hp hq\n\nlemma sup_mem {p q : Submodule R M} (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n p ⊔ q ∈ f.invtSubmodule :=\n Sublattice.sup_mem hp hq\n\nvariable (f)\n\n@[simp]\nprotected lemma top_mem : ⊤ ∈ f.invtSubmodule := by simp [invtSubmodule]\n\n@[simp]\nprotected lemma bot_mem : ⊥ ∈ f.invtSubmodule := by simp [invtSubmodule]\n\ninstance : BoundedOrder (f.invtSubmodule) where\n top := ⟨⊤, invtSubmodule.top_mem f⟩\n bot := ⟨⊥, invtSubmodule.bot_mem f⟩\n le_top := fun ⟨p, hp⟩ ↦ by simp\n bot_le := fun ⟨p, hp⟩ ↦ by simp\n\n@[simp]\nprotected lemma zero :\n (0 : End R M).invtSubmodule = ⊤ :=\n eq_top_iff.mpr fun x ↦ by simp [invtSubmodule]\n\n@[simp]\nprotected lemma id :\n invtSubmodule (LinearMap.id : End R M) = ⊤ :=\n eq_top_iff.mpr fun x ↦ by simp [invtSubmodule]\n\n@[simp]\nprotected lemma one :\n invtSubmodule (1 : End R M) = ⊤ :=\n invtSubmodule.id\n\nprotected lemma mk_eq_bot_iff {p : Submodule R M} (hp : p ∈ f.invtSubmodule) :\n (⟨p, hp⟩ : f.invtSubmodule) = ⊥ ↔ p = ⊥ :=\n Subtype.mk_eq_bot_iff (by simp [invtSubmodule]) _\n\nprotected lemma mk_eq_top_iff {p : Submodule R M} (hp : p ∈ f.invtSubmodule) :\n (⟨p, hp⟩ : f.invtSubmodule) = ⊤ ↔ p = ⊤ :=\n Subtype.mk_eq_top_iff (by simp [invtSubmodule]) _\n\n@[simp]\nprotected lemma disjoint_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n Disjoint (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ Disjoint p q := by\n rw [disjoint_iff, disjoint_iff, Sublattice.mk_inf_mk,\n Subtype.mk_eq_bot_iff (⊥ : f.invtSubmodule).property]\n\nprotected lemma disjoint_iff {p q : f.invtSubmodule} :\n Disjoint p q ↔ Disjoint (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\n@[simp]\nprotected lemma codisjoint_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n Codisjoint (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ Codisjoint p q := by\n rw [codisjoint_iff, codisjoint_iff, Sublattice.mk_sup_mk,\n Subtype.mk_eq_top_iff (⊤ : f.invtSubmodule).property]\n\nprotected lemma codisjoint_iff {p q : f.invtSubmodule} :\n Codisjoint p q ↔ Codisjoint (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\n@[simp]\nprotected lemma isCompl_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n IsCompl (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ IsCompl p q := by\n simp [isCompl_iff]\n\nprotected lemma isCompl_iff {p q : f.invtSubmodule} :\n IsCompl p q ↔ IsCompl (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\nlemma map_subtype_mem_of_mem_invtSubmodule {p : Submodule R M} (hp : p ∈ f.invtSubmodule)\n {q : Submodule R p} (hq : q ∈ invtSubmodule (LinearMap.restrict f hp)) :\n Submodule.map p.subtype q ∈ f.invtSubmodule := by\n rintro - ⟨⟨x, hx⟩, hx', rfl⟩\n specialize hq hx'\n rw [Submodule.mem_comap, LinearMap.restrict_apply] at hq\n simpa [hq] using hp hx\n\nprotected lemma comp {p : Submodule R M} {g : End R M}\n (hf : p ∈ f.invtSubmodule) (hg : p ∈ g.invtSubmodule) :\n p ∈ invtSubmodule (f ∘ₗ g) :=\n fun _ hx ↦ hf (hg hx)\n\n@[simp] lemma _root_.LinearEquiv.map_mem_invtSubmodule_conj_iff {R M N : Type*} [CommSemiring R]\n [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] {f : End R M}\n {e : M ≃ₗ[R] N} {p : Submodule R M} :\n p.map (e : M →ₗ[R] N) ∈ (e.conj f).invtSubmodule ↔ p ∈ f.invtSubmodule := by\n have : e.symm.toLinearMap ∘ₗ ((e ∘ₗ f) ∘ₗ e.symm.toLinearMap) ∘ₗ e = f := by ext; simp\n rw [LinearEquiv.conj_apply, mem_invtSubmodule, mem_invtSubmodule, Submodule.map_le_iff_le_comap,\n Submodule.map_equiv_eq_comap_symm, ← Submodule.comap_comp, ← Submodule.comap_comp, this]\n\nlemma _root_.LinearEquiv.map_mem_invtSubmodule_iff {R M N : Type*} [CommSemiring R]\n [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] {f : End R N}\n {e : M ≃ₗ[R] N} {p : Submodule R M} :\n p.map (e : M →ₗ[R] N) ∈ f.invtSubmodule ↔ p ∈ (e.symm.conj f).invtSubmodule := by\n simp [← e.map_mem_invtSubmodule_conj_iff]\n\nend invtSubmodule\n\nvariable (R) in\n\nTarget:\nlemma span_orbit_mem_invtSubmodule {G : Type*}\n [Monoid G] [DistribMulAction G M] [SMulCommClass G R M] (x : M) (g : G) :\n span R (MulAction.orbit G x) ∈ invtSubmodule (DistribSMul.toLinearMap R M g) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_cead6dd50e97","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a97182ab9c12c89d59cd2f270b594c746bd1ef3dfb68427a011483c56fab4658","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Module","family_id":"span_orbit_mem_invtsubmodule","file_id":"mathlib/Mathlib/Algebra/Module/Submodule/Invariant.lean","sample_id":"cead6dd50e97e63a22930509dad26949a52479242dfd79be2acbe7afd3d8de3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"25285bb117855c2247c950210d465fbb991e444f5f49f7719dabed62d341df1d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ddcd291a8031554b5fdaeb10518bdef406add0faa35071aea1818ffcc2a8a144","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"76d4e5d0ef729b7147b4052f71b58455e3f9da5556b436da682e738305f7a123","source_sha256":"c7f8b975f885dfe8e2a3866c7aecd0f7c16223863419d554634cf6ca861c1a6d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [balance]","hard_negative":true,"metrics":{"chosen_tokens":5,"rejected_tokens":3,"token_jaccard":0.142857,"token_length_ratio":0.6},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"220c701d0d061dc1d931c532c4c46e051708295e7062986af8cac701ab8b9125","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Balance\npublic import Mathlib.Data.Complex.Basic\n\nNamespace:\nComplex\n\nLocal context:\n/-\nCopyright (c) 2017 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Mario Carneiro\n-/\n/-!\n# Finite sums and products of complex numbers\n-/\n\npublic section\n\nopen Fintype\nopen scoped BigOperators\n\nnamespace Complex\n\nvariable {α : Type*} (s : Finset α)\n\n@[simp, norm_cast]\ntheorem ofReal_prod (f : α → ℝ) : ((∏ i ∈ s, f i : ℝ) : ℂ) = ∏ i ∈ s, (f i : ℂ) :=\n map_prod ofRealHom _ _\n\n@[simp, norm_cast]\ntheorem ofReal_sum (f : α → ℝ) : ((∑ i ∈ s, f i : ℝ) : ℂ) = ∑ i ∈ s, (f i : ℂ) :=\n map_sum ofRealHom _ _\n\n@[simp, norm_cast]\nlemma ofReal_expect (f : α → ℝ) : (𝔼 i ∈ s, f i : ℝ) = 𝔼 i ∈ s, (f i : ℂ) :=\n map_expect ofRealHom ..\n\n@[simp, norm_cast]\n\nTarget:\nlemma ofReal_balance [Fintype α] (f : α → ℝ) (a : α) :\n ((balance f a : ℝ) : ℂ) = balance ((↑) ∘ f) a :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_76d4e5d0ef72","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"52be7cc4c85ef8186c74cfb592a19acf2602018a1c51f2b0a330cbab1a2d32d7","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Complex","family_id":"ofreal_balance","file_id":"mathlib/Mathlib/Data/Complex/BigOperators.lean","sample_id":"76d4e5d0ef729b7147b4052f71b58455e3f9da5556b436da682e738305f7a123"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"13716daf79df24376d8e5d7ed7a266d42b36e9d308212424f5b69bc3db3cf074","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e1a46b6eddb0586d8124f6508b048c0eb205def3ba3045e8f875474bc5bfd921","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bf8e687a0883c818afc808a7a35756dd04de3fe1a5e0555e87d141002492aa5d","source_sha256":"77932a4459c89002b639ed8830c116b32a50a724e462bfb0159cf7169631dd79","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [epiWithInjectiveKernel_iff]\n exact ⟨0, inferInstance, 0, by simp,\n ⟨ShortComplex.Splitting.ofIsZeroOfIsIso _ (isZero_zero C) (by assumption)⟩⟩","hard_negative":true,"metrics":{"chosen_tokens":33,"rejected_tokens":2,"token_jaccard":0.043478,"token_length_ratio":0.060606},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"237c15dcc934fc09eb5b3bc050768e92f0f1f142d7650b30974ead3d7100f123","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.ShortComplex.ShortExact\npublic import Mathlib.CategoryTheory.MorphismProperty.Retract\npublic import Mathlib.CategoryTheory.MorphismProperty.LiftingProperty\npublic import Mathlib.CategoryTheory.Preadditive.Injective.LiftingProperties\n\nNamespace:\nCategoryTheory.Abelian\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Epimorphisms with an injective kernel\n\nIn this file, we define the class of morphisms `epiWithInjectiveKernel` in an\nabelian category. We show that this property of morphisms is multiplicative.\n\nThis shall be used in the file `Mathlib/Algebra/Homology/Factorizations/Basic.lean` in\norder to define morphisms of cochain complexes which satisfy this property\ndegreewise.\n\n-/\n\n@[expose] public section\n\nnamespace CategoryTheory\n\nopen Category Limits ZeroObject Preadditive\n\nvariable {C : Type*} [Category* C] [Abelian C]\n\nnamespace Abelian\n\n/-- The class of morphisms in an abelian category that are epimorphisms\nand have an injective kernel. -/\ndef epiWithInjectiveKernel : MorphismProperty C :=\n fun _ _ f => Epi f ∧ Injective (kernel f)\n\n/-- A morphism `g : X ⟶ Y` is epi with an injective kernel iff there exists a morphism\n`f : I ⟶ X` with `I` injective such that `f ≫ g = 0` and\nthe short complex `I ⟶ X ⟶ Y` has a splitting. -/\nlemma epiWithInjectiveKernel_iff {X Y : C} (g : X ⟶ Y) :\n epiWithInjectiveKernel g ↔ ∃ (I : C) (_ : Injective I) (f : I ⟶ X) (w : f ≫ g = 0),\n Nonempty (ShortComplex.mk f g w).Splitting := by\n constructor\n · rintro ⟨_, _⟩\n let S := ShortComplex.mk (kernel.ι g) g (by simp)\n exact ⟨_, inferInstance, _, S.zero,\n ⟨ShortComplex.Splitting.ofExactOfRetraction S\n (S.exact_of_f_is_kernel (kernelIsKernel g)) (Injective.factorThru (𝟙 _) (kernel.ι g))\n (by simp [S]) inferInstance⟩⟩\n · rintro ⟨I, _, f, w, ⟨σ⟩⟩\n have : IsSplitEpi g := ⟨σ.s, σ.s_g⟩\n let e : I ≅ kernel g :=\n IsLimit.conePointUniqueUpToIso σ.shortExact.fIsKernel (limit.isLimit _)\n exact ⟨inferInstance, Injective.of_iso e inferInstance⟩\n\nTarget:\nlemma epiWithInjectiveKernel_of_iso {X Y : C} (f : X ⟶ Y) [IsIso f] :\n epiWithInjectiveKernel f :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_bf8e687a0883","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"d0f940e5af96893ef14aae6095f04a1e69d689f88ce1a847798d8dc0636e6e44","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Abelian","family_id":"epiwithinjectivekernel_of_iso","file_id":"mathlib/Mathlib/CategoryTheory/Abelian/EpiWithInjectiveKernel.lean","sample_id":"bf8e687a0883c818afc808a7a35756dd04de3fe1a5e0555e87d141002492aa5d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e850cb8690c0b3e0e15e79d7ff3e05e204dd3ab2deae96dc5125ed68cc44daaa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b679eacd543999b2117e09996434fae3d18def8bda1dbab7320e1b0bab433420","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c50e7dfc15f5b03aac949d5d4c73b6d02918eb7ce6d372c202e9c6d7181bbde0","source_sha256":"8089e9bbcb1a48e8e29fbebba778eeb4b97519d0a41b768086dd5d1224f6551a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor <;> intro h\n · exact h 1 0\n · intro n₁ n₂ a₁ a₂\n have h' : ∀ n a₁ a₂, f^[n] (a₁ ⊔ a₂) ≤ f^[n] a₁ ⊔ a₂ := by\n intro n\n induction n with\n | zero => intro a₁ a₂; rfl\n | succ n ih =>\n intro a₁ a₂\n calc\n f^[n + 1] (a₁ ⊔ a₂) = f^[n] (f (a₁ ⊔ a₂)) := Function.iterate_succ_apply f n _\n _ ≤ f^[n] (f a₁ ⊔ a₂) := f.mono.iterate n (h a₁ a₂)\n _ ≤ f^[n] (f a₁) ⊔ a₂ := ih _ _\n _ = f^[n + 1] a₁ ⊔ a₂ := by rw [← Function.iterate_succ_apply]\n calc\n f^[n₁ + n₂] (a₁ ⊔ a₂) = f^[n₁] (f^[n₂] (a₁ ⊔ a₂)) :=\n Function.iterate_add_apply f n₁ n₂ _\n _ = f^[n₁] (f^[n₂] (a₂ ⊔ a₁)) := by rw [sup_comm]\n _ ≤ f^[n₁] (f^[n₂] a₂ ⊔ a₁) := f.mono.iterate n₁ (h' n₂ _ _)\n _ = f^[n₁] (a₁ ⊔ f^[n₂] a₂) := by rw [sup_comm]\n _ ≤ f^[n₁] a₁ ⊔ f^[n₂] a₂ := h' n₁ a₁ _","hard_negative":false,"metrics":{"chosen_tokens":358,"rejected_tokens":362,"token_jaccard":0.943396,"token_length_ratio":1.011173},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"2617ae29306774ad81005030cfb2bc531cf8d93dc28ad50fd6bbc669175006b4","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Function.Iterate\npublic import Mathlib.Order.GaloisConnection.Basic\npublic import Mathlib.Order.Hom.Basic\n\nNamespace:\nOrderHom\n\nLocal context:\n/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Anne Baanen\n-/\n/-!\n# Lattice structure on order homomorphisms\n\nThis file defines the lattice structure on order homomorphisms, which are bundled\nmonotone functions.\n\n## Main definitions\n\n* `OrderHom.instCompleteLattice`: if `β` is a complete lattice, so is `α →o β`\n\n## Tags\n\nmonotone map, bundled morphism\n-/\n\npublic section\n\n\nnamespace OrderHom\n\nvariable {α β : Type*}\n\nsection Preorder\n\nvariable [Preorder α]\n\ninstance [SemilatticeSup β] : Max (α →o β) where\n max f g := ⟨fun a => f a ⊔ g a, f.mono.sup g.mono⟩\n\n@[simp] lemma coe_sup [SemilatticeSup β] (f g : α →o β) :\n ((f ⊔ g : α →o β) : α → β) = (f : α → β) ⊔ g := rfl\n\ninstance [SemilatticeSup β] : SemilatticeSup (α →o β) :=\n { (_ : PartialOrder (α →o β)) with\n sup := Max.max\n le_sup_left := fun _ _ _ => le_sup_left\n le_sup_right := fun _ _ _ => le_sup_right\n sup_le := fun _ _ _ h₀ h₁ x => sup_le (h₀ x) (h₁ x) }\n\ninstance [SemilatticeInf β] : Min (α →o β) where\n min f g := ⟨fun a => f a ⊓ g a, f.mono.inf g.mono⟩\n\n@[simp] lemma coe_inf [SemilatticeInf β] (f g : α →o β) :\n ((f ⊓ g : α →o β) : α → β) = (f : α → β) ⊓ g := rfl\n\ninstance [SemilatticeInf β] : SemilatticeInf (α →o β) :=\n { (_ : PartialOrder (α →o β)), (dualIso α β).symm.toGaloisInsertion.liftSemilatticeInf with\n inf := (· ⊓ ·) }\n\ninstance lattice [Lattice β] : Lattice (α →o β) :=\n { (_ : SemilatticeSup (α →o β)), (_ : SemilatticeInf (α →o β)) with }\n\n@[simps]\ninstance [Preorder β] [OrderBot β] : Bot (α →o β) where\n bot := const α ⊥\n\ninstance orderBot [Preorder β] [OrderBot β] : OrderBot (α →o β) where\n bot_le _ _ := bot_le\n\n@[simps]\ninstance instTopOrderHom [Preorder β] [OrderTop β] : Top (α →o β) where\n top := const α ⊤\n\ninstance orderTop [Preorder β] [OrderTop β] : OrderTop (α →o β) where\n le_top _ _ := le_top\n\ninstance [CompleteLattice β] : InfSet (α →o β) where\n sInf s := ⟨fun x => ⨅ f ∈ s, (f :) x, fun _ _ h => iInf₂_mono fun f _ => f.mono h⟩\n\n@[simp]\ntheorem sInf_apply [CompleteLattice β] (s : Set (α →o β)) (x : α) :\n sInf s x = ⨅ f ∈ s, (f :) x :=\n rfl\n\ntheorem iInf_apply {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) (x : α) :\n (⨅ i, f i) x = ⨅ i, f i x :=\n (sInf_apply _ _).trans iInf_range\n\n@[simp, norm_cast]\ntheorem coe_iInf {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) :\n ((⨅ i, f i : α →o β) : α → β) = ⨅ i, (f i : α → β) := by\n funext x; simp [iInf_apply]\n\ninstance [CompleteLattice β] : SupSet (α →o β) where\n sSup s := ⟨fun x => ⨆ f ∈ s, (f :) x, fun _ _ h => iSup₂_mono fun f _ => f.mono h⟩\n\n@[simp]\ntheorem sSup_apply [CompleteLattice β] (s : Set (α →o β)) (x : α) :\n sSup s x = ⨆ f ∈ s, (f :) x :=\n rfl\n\ntheorem iSup_apply {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) (x : α) :\n (⨆ i, f i) x = ⨆ i, f i x :=\n (sSup_apply _ _).trans iSup_range\n\n@[simp, norm_cast]\ntheorem coe_iSup {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) :\n ((⨆ i, f i : α →o β) : α → β) = ⨆ i, (f i : α → β) := by\n funext x; simp [iSup_apply]\n\ninstance [CompleteLattice β] : CompleteLattice (α →o β) :=\n { (_ : Lattice (α →o β)), OrderHom.orderTop, OrderHom.orderBot with\n isLUB_sSup _ :=\n .of_image (f := (⇑)) coe_le_coe (by simp [isLUB_pi, Set.image_image, isLUB_biSup])\n isGLB_sInf _ :=\n .of_image (f := (⇑)) coe_le_coe (by simp [isGLB_pi, Set.image_image, isGLB_biInf]) }\n\nTarget:\ntheorem iterate_sup_le_sup_iff {α : Type*} [SemilatticeSup α] (f : α →o α) :\n (∀ n₁ n₂ a₁ a₂, f^[n₁ + n₂] (a₁ ⊔ a₂) ≤ f^[n₁] a₁ ⊔ f^[n₂] a₂) ↔\n ∀ a₁ a₂, f (a₁ ⊔ a₂) ≤ f a₁ ⊔ a₂ :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n constructor <;> intro h\n · exact h 1 0\n · intro n₁ n₂ a₁ a₂\n have h' : ∀ n a₁ a₂, f^[n] (a₁ ⊔ a₂) ≤ f^[n] a₁ ⊔ a₂ := by\n intro n\n induction n with\n | zero => intro a₁ a₂; rfl\n | succ n ih =>\n intro a₁ a₂\n calc\n f^[n + 1] (a₁ ⊔ a₂) = f^[n] (f (a₁ ⊔ a₂)) := Function.iterate_succ_apply f n _\n _ ≤ f^[n] (f a₁ ⊔ a₂) := f.mono.iterate n (h a₁ a₂)\n _ ≤ f^[n] (f a₁) ⊔ a₂ := ih _ _\n _ = f^[n + 1] a₁ ⊔ a₂ := by rw [← Function.iterate_succ_apply]\n calc\n f^[n₁ + n₂] (a₁ ⊔ a₂) = f^[n₁] (f^[n₂] (a₁ ⊔ a₂)) :=\n Function.iterate_add_apply f n₁ n₂ _\n _ = f^[n₁] (f^[n₂] (a₂ ⊔ a₁)) := by rw [sup_comm]\n _ ≤ f^[n₁] (f^[n₂] a₂ ⊔ a₁) := f.mono.iterate n₁ (h' n₂ _ _)\n _ = f^[n₁] (a₁ ⊔ f^[n₂] a₂) := by rw [sup_comm]\n _ ≤ f^[n₁] a₁ ⊔ f^[n₂] a₂ := h' n₁ a₁ _","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Hom","family_id":"iterate_sup_le_sup_iff","file_id":"mathlib/Mathlib/Order/Hom/Order.lean","sample_id":"c50e7dfc15f5b03aac949d5d4c73b6d02918eb7ce6d372c202e9c6d7181bbde0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ed7f1f542771eb5fddb7734bfde55d1376aed730f064c0316496915624dd1e22","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"15b625fa6ff97c182fed3d2d788c0981d5e318a3c5ef609d7051f2893527b7fc","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1939e07ffc3a746055b1935b8ac9b00f5226d7dbcaf252ce02d76282f9e08cce","source_sha256":"c1d40ca8793192b2a1e02b083144d77da7c781464bb316546f36e29eac1559fe","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← nonpos_iff_eq_zero, ← measure_limsup_cofinite_eq_zero h]\n exact measure_mono liminf_le_limsup","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":5,"token_jaccard":0.133333,"token_length_ratio":0.384615},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"26a55693a9f022996dd8af5d5906894a0cadee13bf58029cdeef4cda0e2dc672","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.OuterMeasure.AE\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Yury Kudryashov\n-/\n/-!\n# Borel-Cantelli lemma, part 1\n\nIn this file we show one implication of the **Borel-Cantelli lemma**:\nif `s i` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen a.e. all points belong to finitely many sets of the family.\n\nWe prove several versions of this lemma:\n\n- `MeasureTheory.ae_finite_setOf_mem`: as stated above;\n- `MeasureTheory.measure_limsup_cofinite_eq_zero`:\n in terms of `Filter.limsup` along `Filter.cofinite`;\n- `MeasureTheory.measure_limsup_atTop_eq_zero`:\n in terms of `Filter.limsup` along `(Filter.atTop : Filter ℕ)`.\n\nFor the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`.\n-/\n\npublic section\n\nopen Filter Set\nopen scoped ENNReal Topology\n\nnamespace MeasureTheory\n\nvariable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] [Countable ι] {μ : F}\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen the limit superior of the `s i` along the cofinite filter is a null set.\n\nNote: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`. -/\ntheorem measure_limsup_cofinite_eq_zero {s : ι → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :\n μ (limsup s cofinite) = 0 := by\n refine bot_unique <| ge_of_tendsto' (ENNReal.tendsto_tsum_compl_atTop_zero hs) fun t ↦ ?_\n calc\n μ (limsup s cofinite) ≤ μ (⋃ i : {i // i ∉ t}, s i) := by\n gcongr\n rw [hasBasis_cofinite.limsup_eq_iInf_iSup, iUnion_subtype]\n exact iInter₂_subset _ t.finite_toSet\n _ ≤ ∑' i : {i // i ∉ t}, μ (s i) := measure_iUnion_le _\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a sequence of sets such that `∑' i, μ (s i)` is finite,\nthen the limit superior of the `s i` along the `atTop` filter is a null set.\n\nNote: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`. -/\ntheorem measure_limsup_atTop_eq_zero {s : ℕ → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :\n μ (limsup s atTop) = 0 := by\n rw [← Nat.cofinite_eq_atTop, measure_limsup_cofinite_eq_zero hs]\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen a.e. all points belong to finitely many sets of the family. -/\ntheorem ae_finite_setOf_mem {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :\n ∀ᵐ x ∂μ, {i | x ∈ s i}.Finite := by\n rw [ae_iff, ← measure_limsup_cofinite_eq_zero h]\n congr 1 with x\n simp [mem_limsup_iff_frequently_mem, Filter.Frequently]\n\n/-- A version of the **Borel-Cantelli lemma**: if `pᵢ` is a sequence of predicates such that\n`∑' i, μ {x | pᵢ x}` is finite, then the measure of `x` such that `pᵢ x` holds frequently as `i → ∞`\n(or equivalently, `pᵢ x` holds for infinitely many `i`) is equal to zero. -/\ntheorem measure_setOf_frequently_eq_zero {p : ℕ → α → Prop} (hp : ∑' i, μ { x | p i x } ≠ ∞) :\n μ { x | ∃ᶠ n in atTop, p n x } = 0 := by\n simpa only [limsup_eq_iInf_iSup_of_nat, frequently_atTop, ← bex_def, setOf_forall,\n setOf_exists] using! measure_limsup_atTop_eq_zero hp\n\n/-- A version of the **Borel-Cantelli lemma**: if `sᵢ` is a sequence of sets such that\n`∑' i, μ sᵢ` is finite, then for almost all `x`, `x` does not belong to `sᵢ` for large `i`. -/\ntheorem ae_eventually_notMem {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :\n ∀ᵐ x ∂μ, ∀ᶠ n in atTop, x ∉ s n :=\n measure_setOf_frequently_eq_zero hs\n\nTarget:\ntheorem measure_liminf_cofinite_eq_zero [Infinite ι] {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :\n μ (liminf s cofinite) = 0 :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_1939e07ffc3a","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"7547f0b91a11f62d0d5443f31564b8fdf1799040863661e9b4165ffb9806546f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/OuterMeasure","family_id":"measure_liminf_cofinite_eq_zero","file_id":"mathlib/Mathlib/MeasureTheory/OuterMeasure/BorelCantelli.lean","sample_id":"1939e07ffc3a746055b1935b8ac9b00f5226d7dbcaf252ce02d76282f9e08cce"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"049cec324945f12ffba7399c360e05a07919a6d1a773c6d93c4a1a8114edc258","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dc237fee9a01f721e3a2e7346681c0340a16b09a4bff536ceed7bf17412ca041","source_sha256":"8e667d45959923a4720fe5c44df65ca7c34aebce53072a9647abd3ed6428ad7b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine strictAntiOn_of_deriv_neg (convex_Icc ..) continuous_mul_log.continuousOn fun x hx ↦ ?_\n have hgt : x < rexp (-1) := by simp_all [interior_Icc, mem_Ioo]\n have hpos : 0 < x := by simp_all [interior_Icc, mem_Ioo]\n grind [deriv_mul_log, Real.log_lt_iff_lt_exp hpos |>.mpr hgt]","hard_negative":false,"metrics":{"chosen_tokens":63,"rejected_tokens":2,"token_jaccard":0.025641,"token_length_ratio":0.031746},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"27af463b71340cc5ce9fc451386bc25c16e47417baf42ae223fb344c8e154ce9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.SpecialFunctions.Pow.Real\npublic import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2021 Bolton Bailey. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bolton Bailey\n-/\n/-!\n# Logarithm Tonality\n\nIn this file we describe the tonality of the logarithm function when multiplied by functions of the\nform `x ^ a`.\n\n## Tags\n\nlogarithm, tonality\n-/\n\npublic section\n\n\nopen Set Filter Function\n\nopen Topology\n\nnoncomputable section\n\nnamespace Real\n\ntheorem mul_log_strictMonoOn : StrictMonoOn (fun x ↦ x * log x) <| .Ici <| exp (-1) := by\n refine strictMonoOn_of_deriv_pos (convex_Ici _) continuous_mul_log.continuousOn fun x hx ↦ ?_\n have hlt : rexp (-1) < x := by simpa using hx\n have hpos : 0 < x := by grind [Real.exp_pos]\n grind [deriv_mul_log, Real.lt_log_iff_exp_lt hpos |>.mpr hlt]\n\n@[deprecated Real.mul_log_strictMonoOn (since := \"2026-04-07\")]\ntheorem log_mul_self_monotoneOn : MonotoneOn (fun x : ℝ => log x * x) { x | 1 ≤ x } := by\n grind [mul_log_strictMonoOn.monotoneOn, MonotoneOn.mono, show exp (-1) < 1 by norm_num]\n\nTarget:\ntheorem mul_log_strictAntiOn :\n StrictAntiOn (fun x : ℝ ↦ x * log x) <| .Icc 0 (exp (-1)) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/SpecialFunctions","family_id":"mul_log_strictantion","file_id":"mathlib/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean","sample_id":"dc237fee9a01f721e3a2e7346681c0340a16b09a4bff536ceed7bf17412ca041"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4d5b45b69ab3c62a4548e2cb469ea9c53a099ca2ae47db5b75c64800be36cbfe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9281fbd9e322f5a5d81e48aec1ca10a91fb333297ed2f043375917939030136d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cdec5f9eb18d68c299a4d3c311a051c2af449bc934a19bb8d3f0cfafc1742324","source_sha256":"95d50974f2281ad2a4ec76fe3c119af793109b3fa6e188801eaecdf86f226a41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n rcases eq_or_ne x c with rfl | hx; · simp [dist_comm]\n rw [mem_preimage, mem_sphere, ← inversion_mem_perpBisector_inversion_iff hR] <;> simp [*]","hard_negative":true,"metrics":{"chosen_tokens":34,"rejected_tokens":2,"token_jaccard":0.037037,"token_length_ratio":0.058824},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"27d121c9ad02eb55fe65f85e599e48a03cace3f4a68d8ed91850bbfa53f500e2","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Euclidean.Inversion.Basic\npublic import Mathlib.Geometry.Euclidean.PerpBisector\n\nNamespace:\nEuclideanGeometry\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Image of a hyperplane under inversion\n\nIn this file we prove that the inversion with center `c` and radius `R ≠ 0` maps a sphere passing\nthrough the center to a hyperplane, and vice versa. More precisely, it maps a sphere with center\n`y ≠ c` and radius `dist y c` to the hyperplane\n`AffineSubspace.perpBisector c (EuclideanGeometry.inversion c R y)`.\n\nThe exact statements are a little more complicated because `EuclideanGeometry.inversion c R` sends\nthe center to itself, not to a point at infinity.\n\nWe also prove that the inversion sends an affine subspace passing through the center to itself.\n\n## Keywords\n\ninversion\n-/\n\npublic section\n\nopen Metric Function AffineMap Set AffineSubspace\nopen scoped Topology\n\nvariable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P] {c x y : P} {R : ℝ}\n\nnamespace EuclideanGeometry\n\n-- see https://github.com/leanprover-community/mathlib4/issues/29041\nset_option linter.unusedSimpArgs false in\n/-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a\nhyperplane. -/\ntheorem inversion_mem_perpBisector_inversion_iff (hR : R ≠ 0) (hx : x ≠ c) (hy : y ≠ c) :\n inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c := by\n rw [mem_perpBisector_iff_dist_eq, dist_inversion_inversion hx hy, dist_inversion_center]\n simp [field, eq_comm, ↓hx, ↓hy]\n\n/-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a\nhyperplane. -/\ntheorem inversion_mem_perpBisector_inversion_iff' (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c ∧ x ≠ c := by\n rcases eq_or_ne x c with rfl | hx\n · simp [*]\n · simp [inversion_mem_perpBisector_inversion_iff hR hx hy, hx]\n\ntheorem preimage_inversion_perpBisector_inversion (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' perpBisector c (inversion c R y) = sphere y (dist y c) \\ {c} :=\n Set.ext fun _ ↦ inversion_mem_perpBisector_inversion_iff' hR hy\n\ntheorem preimage_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \\ {c} := by\n rw [← dist_inversion_center, ← preimage_inversion_perpBisector_inversion hR,\n inversion_inversion] <;> simp [*]\n\ntheorem image_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R '' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \\ {c} := by\n rw [image_eq_preimage_of_inverse (inversion_involutive _ hR) (inversion_involutive _ hR),\n preimage_inversion_perpBisector hR hy]\n\nTarget:\ntheorem preimage_inversion_sphere_dist_center (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' sphere y (dist y c) =\n insert c (perpBisector c (inversion c R y) : Set P) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_cdec5f9eb18d","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"88240fe8ec449b9eae2787920c4c356c567053419baf53dd6c7fcc100bad13c7","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Euclidean","family_id":"preimage_inversion_sphere_dist_center","file_id":"mathlib/Mathlib/Geometry/Euclidean/Inversion/ImageHyperplane.lean","sample_id":"cdec5f9eb18d68c299a4d3c311a051c2af449bc934a19bb8d3f0cfafc1742324"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c9ba50e9e1bb70040fd117a7261d87360d04aa82494173dae5e3edcb8ee182c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"151bd6343ce6efc88f7c7af395fa56b97569a0eb6c7ed6b43645660f392cf13a","source_sha256":"5b8c2af2d3decf7ecd5055a9af72eebcb8ad7bb17d12bd917e766de67c6175aa","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have h_int := h.integrable_exp_mul 1\n simpa using (aemeasurable_of_aemeasurable_exp h_int.1.aemeasurable).aestronglyMeasurable","hard_negative":false,"metrics":{"chosen_tokens":20,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.1},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"28972d30600ba0368c7bbf31af407e3a55330b9dcec1ca46d9742a0f4fc143ac","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Kernel.Condexp\npublic import Mathlib.Probability.Moments.MGFAnalytic\npublic import Mathlib.Probability.Moments.Tilted\n\nNamespace:\nProbabilityTheory.Kernel.HasSubgaussianMGF\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Sub-Gaussian random variables\n\nThis presentation of sub-Gaussian random variables is inspired by section 2.5 of\n[vershynin2018high]. Let `X` be a random variable. Consider the following five properties, in which\n`Kᵢ` are positive reals,\n* (i) for all `t ≥ 0`, `ℙ(|X| ≥ t) ≤ 2 * exp(-t^2 / K₁^2)`,\n* (ii) for all `p : ℕ` with `1 ≤ p`, `𝔼[|X|^p]^(1/p) ≤ K₂ sqrt(p)`,\n* (iii) for all `|t| ≤ 1/K₃`, `𝔼[exp (t^2 * X^2)] ≤ exp (K₃^2 * t^2)`,\n* (iv) `𝔼[exp(X^2 / K₄)] ≤ 2`,\n* (v) for all `t : ℝ`, `𝔼[exp (t * X)] ≤ exp (K₅ * t^2 / 2)`.\n\nProperties (i) to (iv) are equivalent, in the sense that there exists a constant `C` such that\nif `X` satisfies one of those properties with constant `K`, then it satisfies any other one with\nconstant at most `CK`.\n\nIf `𝔼[X] = 0` then properties (i)-(iv) are equivalent to (v) in that same sense.\nProperty (v) implies that `X` has expectation zero.\n\nThe name sub-Gaussian is used by various authors to refer to any one of (i)-(v). We will say that a\nrandom variable has sub-Gaussian moment-generating function (mgf) with constant `K₅` to mean that\nproperty (v) holds with that constant. The function `exp (K₅ * t^2 / 2)` which appears in\nproperty (v) is the mgf of a Gaussian with variance `K₅`.\nThat property (v) is the most convenient one to work with if one wants to prove concentration\ninequalities using Chernoff's method.\n\nTODO: implement definitions for (i)-(iv) when it makes sense. For example the maximal constant `K₄`\nsuch that (iv) is true is an Orlicz norm. Prove relations between those properties.\n\n### Conditionally sub-Gaussian random variables and kernels\n\nA related notion to sub-Gaussian random variables is that of conditionally sub-Gaussian random\nvariables. A random variable `X` is conditionally sub-Gaussian in the sense of (v) with respect to\na sigma-algebra `m` and a measure `μ` if for all `t : ℝ`, `exp (t * X)` is `μ`-integrable and\nthe conditional mgf of `X` conditioned on `m` is almost surely bounded by `exp (c * t^2 / 2)`\nfor some constant `c`.\n\nAs in other parts of Mathlib's probability library (notably the independence and conditional\nindependence definitions), we express both sub-Gaussian and conditionally sub-Gaussian properties\nas special cases of a notion of sub-Gaussianity with respect to a kernel and a measure.\n\n## Main definitions\n\n* `Kernel.HasSubgaussianMGF`: a random variable `X` has a sub-Gaussian moment-generating function\n with parameter `c` with respect to a kernel `κ` and a measure `ν` if for `ν`-almost all `ω'`,\n for all `t : ℝ`, the moment-generating function of `X` with respect to `κ ω'` is bounded by\n `exp (c * t ^ 2 / 2)`.\n* `HasCondSubgaussianMGF`: a random variable `X` has a conditionally sub-Gaussian moment-generating\n function with parameter `c` with respect to a sigma-algebra `m` and a measure `μ` if for all\n `t : ℝ`, `exp (t * X)` is `μ`-integrable and the moment-generating function of `X` conditioned\n on `m` is almost surely bounded by `exp (c * t ^ 2 / 2)` for all `t : ℝ`.\n The actual definition uses `Kernel.HasSubgaussianMGF`: `HasCondSubgaussianMGF` is defined as\n sub-Gaussian with respect to the conditional expectation kernel for `m` and the restriction of `μ`\n to the sigma-algebra `m`.\n* `HasSubgaussianMGF`: a random variable `X` has a sub-Gaussian moment-generating function\n with parameter `c` with respect to a measure `μ` if for all `t : ℝ`, `exp (t * X)`\n is `μ`-integrable and the moment-generating function of `X` is bounded by `exp (c * t ^ 2 / 2)`\n for all `t : ℝ`.\n This is equivalent to `Kernel.HasSubgaussianMGF` with a constant kernel.\n See `HasSubgaussianMGF_iff_kernel`.\n\n## Main statements\n\n* `measure_sum_ge_le_of_iIndepFun`: Hoeffding's inequality for sums of independent sub-Gaussian\n random variables.\n* `hasSubgaussianMGF_of_mem_Icc_of_integral_eq_zero`: Hoeffding's lemma for random variables with\n expectation zero.\n* `measure_sum_ge_le_of_HasCondSubgaussianMGF`: the Azuma-Hoeffding inequality for sub-Gaussian\n random variables.\n\n## Implementation notes\n\n### Definition of `Kernel.HasSubgaussianMGF`\n\nThe definition of sub-Gaussian with respect to a kernel and a measure is the following:\n```\nstructure Kernel.HasSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0)\n (κ : Kernel Ω' Ω) (ν : Measure Ω' := by volume_tac) : Prop where\n integrable_exp_mul : ∀ t, Integrable (fun ω ↦ exp (t * X ω)) (κ ∘ₘ ν)\n mgf_le : ∀ᵐ ω' ∂ν, ∀ t, mgf X (κ ω') t ≤ exp (c * t ^ 2 / 2)\n```\nAn interesting point is that the integrability condition is not integrability of `exp (t * X)`\nwith respect to `κ ω'` for `ν`-almost all `ω'`, but integrability with respect to `κ ∘ₘ ν`.\nThis is a stronger condition, as the weaker one did not allow to prove interesting results about\nthe sum of two sub-Gaussian random variables.\n\nFor the conditional case, that integrability condition reduces to integrability of `exp (t * X)`\nwith respect to `μ`.\n\n### Definition of `HasCondSubgaussianMGF`\n\nWe define `HasCondSubgaussianMGF` as a special case of `Kernel.HasSubgaussianMGF` with the\nconditional expectation kernel for `m`, `condExpKernel μ m`, and the restriction of `μ` to `m`,\n`μ.trim hm` (where `hm` states that `m` is a sub-sigma-algebra).\nNote that `condExpKernel μ m ∘ₘ μ.trim hm = μ`. The definition is equivalent to the two\nconditions\n* for all `t`, `exp (t * X)` is `μ`-integrable,\n* for `μ.trim hm`-almost all `ω`, for all `t`, the mgf with respect to the conditional\n distribution `condExpKernel μ m ω` is bounded by `exp (c * t ^ 2 / 2)`.\n\nFor any `t`, we can write the mgf of `X` with respect to the conditional expectation kernel as\na conditional expectation, `(μ.trim hm)`-almost surely:\n`mgf X (condExpKernel μ m ·) t =ᵐ[μ.trim hm] μ[fun ω' ↦ exp (t * X ω') | m]`.\n\n## References\n\n* [R. Vershynin, *High-dimensional probability: An introduction with applications in data\n science*][vershynin2018high]\n\n-/\n\n@[expose] public section\n\nopen MeasureTheory Real\n\nopen scoped ENNReal NNReal Topology\n\nnamespace ProbabilityTheory\n\nsection Kernel\n\nvariable {Ω Ω' : Type*} {mΩ : MeasurableSpace Ω} {mΩ' : MeasurableSpace Ω'}\n {ν : Measure Ω'} {κ : Kernel Ω' Ω} {X : Ω → ℝ} {c : ℝ≥0}\n\n/-! ### Sub-Gaussian with respect to a kernel and a measure -/\n\n/-- A random variable `X` has a sub-Gaussian moment-generating function with parameter `c`\nwith respect to a kernel `κ` and a measure `ν` if for `ν`-almost all `ω'`, for all `t : ℝ`,\nthe moment-generating function of `X` with respect to `κ ω'` is bounded by `exp (c * t ^ 2 / 2)`.\nThis implies in particular that `X` has expectation 0. -/\nstructure Kernel.HasSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0)\n (κ : Kernel Ω' Ω) (ν : Measure Ω' := by volume_tac) : Prop where\n integrable_exp_mul : ∀ t, Integrable (fun ω ↦ exp (t * X ω)) (κ ∘ₘ ν)\n mgf_le : ∀ᵐ ω' ∂ν, ∀ t, mgf X (κ ω') t ≤ exp (c * t ^ 2 / 2)\n\nnamespace Kernel.HasSubgaussianMGF\n\nsection BasicProperties\n\nTarget:\nlemma aestronglyMeasurable (h : HasSubgaussianMGF X c κ ν) :\n AEStronglyMeasurable X (κ ∘ₘ ν) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Moments","family_id":"aestronglymeasurable","file_id":"mathlib/Mathlib/Probability/Moments/SubGaussian.lean","sample_id":"151bd6343ce6efc88f7c7af395fa56b97569a0eb6c7ed6b43645660f392cf13a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a9779047fa7876991256a33bdb3e59e4b9e741463a906593ac6cdb02c52b9b9b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"eada120509fdcedf78f67a332fe4369dba1c0cf15287ad0121a8a59d862419e9","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa8622e4654fc596914560a34e89d20db8c2ad34a6ad4dad32b4200c14e665f6","source_sha256":"fba9f03949fb71c822ca9bce084299af5da1008b68ee86b47a488c537325bc59","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine Set.Finite.subset hfg fun _ ha ↦ Set.mem_setOf.mpr fun H ↦ Set.mem_setOf.mp ha ?_\n grind\n\n-- The additive version is a special case of `Function.HasFiniteSupport.smul_left`.","hard_negative":true,"metrics":{"chosen_tokens":47,"rejected_tokens":5,"token_jaccard":0.060606,"token_length_ratio":0.106383},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"2a412272d5a00bfdf89872a49729a0f4f4cbee78c2f113017dfc1d3dcef9709c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmas\npublic import Mathlib.Algebra.FiniteSupport.Defs\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.GroupWithZero.Action.Defs\npublic import Mathlib.Algebra.Order.Group.Indicator\npublic import Mathlib.Data.Set.Finite.Lattice\nimport Mathlib.Algebra.GroupWithZero.Indicator\nimport Mathlib.Algebra.Module.Basic\n\nNamespace:\nFunction\n\nLocal context:\n/-\nCopyright (c) 2026 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Make `fun_prop` work for finite (multiplicative) support\n\nWe provide API lemmas for the predicate `HasFiniteMulSupport` (and its additivized version\n`HasFiniteSupport`) on functions so that `fun_prop` can prove it for functions that are\nbuilt from other functions with finite multiplicative support.\n-/\n\npublic section\n\nnamespace Function\n\nvariable {α M : Type*} [One M]\n\n@[to_additive (attr := fun_prop)]\nlemma hasFiniteMulSupport_fun_one : HasFiniteMulSupport (1 : α → M) := by\n simp [HasFiniteMulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport fun a ↦ g (f a) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport (g ∘ f) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fst {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).fst :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.snd {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).snd :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prodMk {M' : Type*} [One M'] {f : α → M} {g : α → M'}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ (f a, g a) := by\n simp only [HasFiniteMulSupport] at hf hg ⊢\n rw [mulSupport_prodMk f g]\n exact hf.union hg\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.mul {M : Type*} [MulOneClass M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f * g) :=\n (hf.union hg).subset <| mulSupport_mul ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.inv {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport f⁻¹ :=\n hf.comp inv_one\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prod {M : Type*} [CommMonoid M] {ι : Type*} {f : ι → α → M}\n (hf : ∀ i, HasFiniteMulSupport (f i)) (s : Finset ι) :\n HasFiniteMulSupport fun a ↦ ∏ i ∈ s, f i a :=\n (s.finite_toSet.biUnion fun i _ ↦ hf i).subset <| s.mulSupport_prod f\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.div {M : Type*} [DivisionMonoid M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f / g) :=\n (hf.union hg).subset <| mulSupport_div ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.pow {M : Type*} [Monoid M] {f : α → M} (hf : HasFiniteMulSupport f)\n (n : ℕ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_pow n)\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.zpow {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) (n : ℤ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_zpow n)\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.max [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ max (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_max ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.min [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ min (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_min ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup [SemilatticeSup M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊔ g a :=\n (hf.union hg).subset <| mulSupport_sup ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf [SemilatticeInf M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊓ g a :=\n (hf.union hg).subset <| mulSupport_inf ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iSup [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨆ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iSup f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iInf [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨅ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iInf f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.pi {ι : Type*} [Finite α] {f : ι → α → M}\n (hf : ∀ a, HasFiniteMulSupport (f · a)) :\n HasFiniteMulSupport f := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (Set.finite_iUnion hf).subset fun i hi ↦ ?_\n simp only [mem_mulSupport, Set.mem_iUnion] at hi ⊢\n exact ne_iff.mp hi\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup' [SemilatticeSup M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.sup' hs (f · a) := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.sup'_eq_of_forall hs (fun x ↦ f x a) ha\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf' [SemilatticeInf M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.inf' hs (f · a) := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.inf'_eq_of_forall hs (fun x ↦ f x a) ha\n\nvariable {β : Type*} {f : β → M} {g : α → β}\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp_of_injective (hg : Injective g) (hf : f.HasFiniteMulSupport) :\n (f ∘ g).HasFiniteMulSupport := by\n refine Set.Finite.of_injOn ?_ (Set.injOn_of_injective hg) hf\n grind [Set.mapsTo_iff_subset_preimage, Function.mulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp_of_injective (hg : Injective g) (hf : f.HasFiniteMulSupport) :\n (fun a ↦ f (g a)).HasFiniteMulSupport :=\n hf.comp_of_injective hg\n\n@[to_additive]\n\nTarget:\nlemma HasFiniteMulSupport.of_comp [One β] (hfg : (f ∘ g).HasFiniteMulSupport) (h : f 1 = 1)\n (hf : Injective f) :\n g.HasFiniteMulSupport :=\n\nProof body:\n","rejected":"by\n exact HasFiniteMulSupport.of_comp","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"b827a9c0fa8c805ca02accea696d55b41e76aa8cd14041cc015f53bb85cf2ee8","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FiniteSupport","family_id":"hasfinitemulsupport","file_id":"mathlib/Mathlib/Algebra/FiniteSupport/Basic.lean","sample_id":"fa8622e4654fc596914560a34e89d20db8c2ad34a6ad4dad32b4200c14e665f6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6faafed98e03cc2a26389678ceb051ea0db59bcdfaa4b05ea6a8a05465195a05","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7642c0cfc8bf77fe3f27f389ac5b64b8753dc97f95aa98d9d014de84c40d9b1e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5564cc38c1b82f10157b782588a5b57207242633422df26e8b2ff5770e710c69","source_sha256":"6ca40a9a028dbe37b0e6d35f519e15fb40bd243ba89a07bbe3689aea9c6deaf6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := e.isLocalRing\n have := isNoetherianRing_of_ringEquiv R e\n rwa [isRegularLocalRing_iff, ← ringKrullDim_eq_of_ringEquiv e, ← map_ringEquiv_maximalIdeal e,\n Ideal.spanFinrank_map_eq_of_ringEquiv, ← isRegularLocalRing_iff]","hard_negative":true,"metrics":{"chosen_tokens":30,"rejected_tokens":2,"token_jaccard":0.052632,"token_length_ratio":0.066667},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"2bd36141e5be07086cfc2198e711a95cef3fd47fd50092a0d7e40414264cabbc","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.SpanRankOperations\npublic import Mathlib.RingTheory.DedekindDomain.Dvr\npublic import Mathlib.RingTheory.Ideal.KrullsHeightTheorem\npublic import Mathlib.RingTheory.KrullDimension.Field\npublic import Mathlib.RingTheory.KrullDimension.PID\n\nNamespace:\nIsRegularLocalRing\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# Regular local rings\n\nFor a Noetherian local ring `R`, we define `IsRegularLocalRing` as\n`(maximalIdeal R).spanFinrank = ringKrullDim R`. This definition is equivalent to\nthe dimension of the cotangent space over the residue field being equal to `ringKrullDim R`,\n(see `IsRegularLocalRing.iff_finrank_cotangentSpace`).\n\nFor the next section, we define regular rings as Noetherian rings whose localization at every prime\nare regular local rings.\n(Note that a regular local ring is a regular ring, but this is not immediate under this definition).\n\n# Main Definition and Results\n\n* `IsRegularLocalRing` : A Noetherian local ring is regular if\n `(maximalIdeal R).spanFinrank = ringKrullDim R`,\n i.e. its maximal ideal can be generated by `dim R` elements.\n\n* `IsRegularLocalRing.iff_finrank_cotangentSpace` : the equivalence of `IsRegularLocalRing` and\n `Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R`\n\n* `IsRegularRing` : A noetherian ring is regular if its localization at any prime\n `IsRegularLocalRing`.\n\n## TODO\nShow that regular local rings are regular under this definition.\nThis follows from localizations of regular local rings being regular (@Thmoas-Guan).\n\n-/\n\npublic section\n\nopen IsLocalRing\n\n/-- A Noetherian local ring is said to be regular if its maximal ideal\ncan be generated by `dim R` elements. -/\n@[stacks 00KU]\nclass IsRegularLocalRing (R : Type*) [CommRing R] : Prop extends\n IsLocalRing R, IsNoetherianRing R where\n spanFinrank_maximalIdeal : (maximalIdeal R).spanFinrank = ringKrullDim R\n\nvariable (R : Type*) [CommRing R]\n\nlemma isRegularLocalRing_iff [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ (maximalIdeal R).spanFinrank = ringKrullDim R :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nnamespace IsRegularLocalRing\n\nlemma of_spanFinrank_maximalIdeal_le [IsLocalRing R] [IsNoetherianRing R]\n (le : (maximalIdeal R).spanFinrank ≤ ringKrullDim R) : IsRegularLocalRing R :=\n (isRegularLocalRing_iff _).mpr (le_antisymm le (ringKrullDim_le_spanFinrank_maximalIdeal R))\n\nvariable {R} in\n\nTarget:\nlemma of_ringEquiv [IsRegularLocalRing R] {R' : Type*} [CommRing R']\n (e : R ≃+* R') : IsRegularLocalRing R' :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_5564cc38c1b8","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"a953f80ac9f07625467e9f5f774f23c44d4b2e45f042e1e53bc81aa70e0e62dd","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RegularLocalRing","family_id":"of_ringequiv","file_id":"mathlib/Mathlib/RingTheory/RegularLocalRing/Defs.lean","sample_id":"5564cc38c1b82f10157b782588a5b57207242633422df26e8b2ff5770e710c69"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"599464289d07256ec61782d2be1d9ba89cacfc1a18c288b401246ef6a92bb6e3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"1fa105a627f767cfd9213f202a09354f92ae05aab28c03ae1d640b7d8cf84716","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da8499cd13fb52409c3f27404e6e49d6e33f6445a6fef5f37eaef62975f7f16f","source_sha256":"efda126d5013b26b39c63e370763fbfd6cf8d87774b0c191b7a98bd3554d6c1e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply ibc.algHom_ext\n intro v\n simp [toDual_comp_apply, Algebra.algebraMap_eq_smul_one]","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.2},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"2bf44f7f9238e911baef1080a00a45010547b7a312a5fc3c089b6d77814a4480","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.Dual.Defs\npublic import Mathlib.LinearAlgebra.FreeModule.Finite.Basic\npublic import Mathlib.RingTheory.TensorProduct.IsBaseChangeFree\npublic import Mathlib.RingTheory.TensorProduct.IsBaseChangeHom\n\nNamespace:\nIsBaseChange\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Base change for the dual of a module\n\n* `Module.Dual.congr` : equivalent modules have equivalent duals.\n\nIf `f : Module.Dual R V` and `Algebra R A`, then\n\n* `Module.Dual.baseChange A f` is the element\n of `Module.Dual A (A ⊗[R] V)` deduced by base change.\n\n* `Module.Dual.baseChangeHom` is the `R`-linear map\n given by `Module.Dual.baseChange`.\n\n* `IsBaseChange.dual` : for finite free modules, taking dual commutes with base change.\n\n-/\n\n@[expose] public section\n\nnamespace Module.Dual\n\nopen TensorProduct LinearEquiv\n\nvariable {R : Type*} [CommSemiring R]\n {V : Type*} [AddCommMonoid V] [Module R V]\n {W : Type*} [AddCommMonoid W] [Module R W]\n (A : Type*) [CommSemiring A] [Algebra R A]\n\n/-- Equivalent modules have equivalent duals. -/\n@[simps!] def congr (e : V ≃ₗ[R] W) :\n Dual R V ≃ₗ[R] Dual R W := congrLeft R R e\n\n/-- `LinearMap.baseChange` for `Module.Dual`. -/\ndef baseChange : Dual R V →ₗ[R] Dual A (A ⊗[R] V) :=\n (AlgebraTensorModule.rid R A A).compRight R ∘ₗ LinearMap.baseChangeHom R A V R\n\n@[simp]\ntheorem baseChange_apply_tmul (f : Dual R V) (a : A) (v : V) :\n f.baseChange A (a ⊗ₜ v) = (f v) • a :=\n rfl\n\nvariable {B : Type*} [CommSemiring B] [Algebra R B] [Algebra A B] [IsScalarTower R A B]\n\nopen AlgebraTensorModule in\ntheorem baseChange_baseChange (f : Dual R V) :\n (f.baseChange A).baseChange B = (congr (cancelBaseChange R A B B V)).symm (f.baseChange B) := by\n ext; simp\n\nend Module.Dual\n\nnamespace IsBaseChange\n\nopen Module TensorProduct\n\nvariable {R : Type*} [CommSemiring R]\n {V : Type*} [AddCommMonoid V] [Module R V]\n {W : Type*} [AddCommMonoid W] [Module R W]\n {A : Type*} [CommSemiring A] [Algebra R A] [Module A W] [IsScalarTower R A W]\n {j : V →ₗ[R] W} (ibc : IsBaseChange A j)\n\n/-- The base change of an element of the dual. -/\nnoncomputable def toDual :\n Dual R V →ₗ[R] Dual A W :=\n linearMapLeftRightHom ibc (Algebra.linearMap R A)\n\ntheorem toDual_comp_apply (f : Dual R V) (v : V) :\n ibc.toDual f (j v) = algebraMap R A (f v) := by\n simp [toDual, linearMapLeftRightHom_comp_apply]\n\nTarget:\ntheorem toDual_apply (f : Dual R V) :\n ibc.toDual f = (f.baseChange A).congr ibc.equiv :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_da8499cd13fb","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"3c1f2d6a65a3c37947ca926ed7508ebd3776eedf456e828b009280798a5dae27","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/Dual","family_id":"todual_apply","file_id":"mathlib/Mathlib/LinearAlgebra/Dual/BaseChange.lean","sample_id":"da8499cd13fb52409c3f27404e6e49d6e33f6445a6fef5f37eaef62975f7f16f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a87755c7ff08764e6be4c6a0e3e2ca51b7a7fcc69b56648997d781554bde816b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fc2c14474837ed185efa6ad5ef2a733f4faa9df894a312c1af2aecde29b669e9","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7b6e5798fb01f5d57039217ed9c10498f339f78d55489e72cce49c284a570913","source_sha256":"2ad7529c6ca34a33092cc21bddd0d1e71ee1e7768fa0823e2ae39f94de46fb42","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro b hab\n obtain hb | hb' := hab\n · exact (h b hb).mono fun _ hx ↦ Or.inl hx\n · exact (h' b hb').mono fun _ hx ↦ Or.inr hx","hard_negative":true,"metrics":{"chosen_tokens":44,"rejected_tokens":5,"token_jaccard":0.115385,"token_length_ratio":0.113636},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"2c5e67d75884d8ce415ee4eae80aab559a4ea4c7ad45eed9b22d726b670b5a10","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Defs.Induced\npublic import Mathlib.Topology.Constructions.SumProd\nimport Mathlib.Topology.ContinuousOn\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Antoine Chambert-Loir, Anatole Dedecker, Jireh Loreaux\n-/\n/-!\n# Semicontinuous maps\n\nA function `f` from a topological space `α` to an ordered space `β` is *lower semicontinuous* at a\npoint `x` if, for any `y < f x`, for any `x'` close enough to `x`, one has `f x' > y`. In other\nwords, `f` can jump up, but it cannot jump down.\n\n*Upper semicontinuous* functions are defined similarly. Upper and lower hemicontinuity (of\nfunctions `f : α → Set β`) are often defined in terms of sequential characterizations, but\nhere we take an equivalent approach. `f : α → Set β` is *upper hemicontinuous* at `x` if for any\nneighborhood of `f x`, `f x'` is included in this neighborhood for all `x'` close enough to `x`.\n\nOf course, one can see a superficial similarity between upper semicontinuity and upper\nhemicontinuity. In fact, we can unify all of upper and lower semicontinuity and also upper and\nlower hemicontinuity under one umbrella, by considering a general relation `r : α → β → Prop` and\ndefining semicontinuity of this relation.\n\nThis file introduces these notions, and a basic API around them mimicking the API for continuous\nfunctions.\n\n## Main definitions and results\n\nWe introduce 4 generic definitions related to semicontinuity:\n* `SemicontinuousWithinAt r s x`\n* `SemicontinuousAt r x`\n* `SemicontinuousOn r s`\n* `Semicontinuous r`\n\nWe build a basic API using dot notation around these notions, and we prove that\n* constant functions are semicontinuous;\n* right composition with continuous functions preserves semicontinuity;\n\nWe also define lower and upper semicontinuity as abbreviations of these generic definitions\nand transfer the generic results to these notions.\n\nWe also define two useful notions for set-valued functions: `HasOpenLowerSections` (which says that\nfor `f : α → β` and for all `y ∈ β`, the set `{x | y ∈ f x}` is open. Similarly, we define\n`HasOpenCGraph` which says that the set of all pairs `(x, y) : α × β` with `y ∈ f x` is open.\nWe show that `HasOpenCGraph` implies `HasOpenLowerSections` (`HasOpenCGraph.hasOpenLowerSections`)\nwhich implies `LowerHemicontinuous` (`HasOpenLowerSections.lowerHemicontinuous`).\n\nWe also define variants of these two notions for `On`/`At`/`WithinAt`.\n\n## References\n\n* \n* \n\n-/\n\n@[expose] public section\n\nopen scoped Topology\n\nopen Set Function Filter\n\nvariable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace γ]\n\n/-! ## Main definitions -/\n\nsection Semicontinuous\n\n/-- A relation `r : α → β → Prop` is semicontinuous within `s` at `x : α`, if whenever `r x y`\nis true, it is also true for all `x'` sufficiently close to `x` within `s`.\n\nThis notion generalizes lower and upper semicontinuity of functions, as well as\nlower and upper hemicontinuity of set-valued correspondences. -/\ndef SemicontinuousWithinAt (r : α → β → Prop) (s : Set α) (x : α) :=\n ∀ y, r x y → ∀ᶠ x' in 𝓝[s] x, r x' y\n\n/-- A relation `r : α → β → Prop` is semicontinuous on `s` if it is semicontinuous within `s` at\neach `x ∈ s`. -/\ndef SemicontinuousOn (r : α → β → Prop) (s : Set α) :=\n ∀ x ∈ s, SemicontinuousWithinAt r s x\n\n/-- A relation `r : α → β → Prop` is semicontinuous at `x : α`, if whenever `r x y`\nis true, it is also true for all `x'` sufficiently close to `x`.\n\nThis notion generalizes lower and upper semicontinuity of functions, as well as\nlower and upper hemicontinuity of set-valued correspondences. -/\ndef SemicontinuousAt (r : α → β → Prop) (x : α) : Prop :=\n ∀ y, r x y → ∀ᶠ x' in 𝓝 x, r x' y\n\n/-- A relation `r : α → β → Prop` is semicontinuous if it is semicontinuous within `s` at each\n`x : α`. -/\ndef Semicontinuous (r : α → β → Prop) : Prop :=\n ∀ x, SemicontinuousAt r x\n\nvariable {r r' : α → β → Prop} {x : α} {s t : Set α}\n\nlemma semicontinuousWithinAt_iff_frequently :\n SemicontinuousWithinAt r s x ↔ ∀ y, (∃ᶠ x' in 𝓝[s] x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousWithinAt]\n\nlemma semicontinuousOn_iff_frequently :\n SemicontinuousOn r s ↔ ∀ x ∈ s, ∀ y, (∃ᶠ x' in 𝓝[s] x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousWithinAt, SemicontinuousOn]\n\nlemma semicontinuousAt_iff_frequently :\n SemicontinuousAt r x ↔ ∀ y, (∃ᶠ x' in 𝓝 x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousAt]\n\nlemma semicontinuous_iff_frequently :\n Semicontinuous r ↔ ∀ x y, (∃ᶠ x' in 𝓝 x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, Semicontinuous, SemicontinuousAt]\n\ntheorem SemicontinuousWithinAt.mono (h : SemicontinuousWithinAt r s x) (hst : t ⊆ s) :\n SemicontinuousWithinAt r t x := fun y hy =>\n Filter.Eventually.filter_mono (nhdsWithin_mono _ hst) (h y hy)\n\ntheorem SemicontinuousWithinAt.congr_of_eventuallyEq {a : α}\n (h : SemicontinuousWithinAt r s a)\n (has : a ∈ s) (hfg : ∀ᶠ x in 𝓝[s] a, ∀ y, r x y ↔ r' x y) :\n SemicontinuousWithinAt r' s a := by\n intro b hb\n simp_rw [← propext_iff, ← funext_iff] at hfg\n rw [← Filter.EventuallyEq.eq_of_nhdsWithin hfg has] at hb\n filter_upwards [hfg, h b hb] with x hx hxb\n exact hx ▸ hxb\n\ntheorem semicontinuousWithinAt_univ_iff :\n SemicontinuousWithinAt r univ x ↔ SemicontinuousAt r x := by\n simp [SemicontinuousWithinAt, SemicontinuousAt, nhdsWithin_univ]\n\ntheorem SemicontinuousAt.semicontinuousWithinAt (s : Set α)\n (h : SemicontinuousAt r x) : SemicontinuousWithinAt r s x := fun y hy =>\n Filter.Eventually.filter_mono nhdsWithin_le_nhds (h y hy)\n\ntheorem SemicontinuousOn.semicontinuousWithinAt (h : SemicontinuousOn r s)\n (hx : x ∈ s) : SemicontinuousWithinAt r s x :=\n h x hx\n\ntheorem SemicontinuousOn.mono (h : SemicontinuousOn r s) (hst : t ⊆ s) :\n SemicontinuousOn r t := fun x hx => (h x (hst hx)).mono hst\n\ntheorem semicontinuousOn_univ_iff : SemicontinuousOn r univ ↔ Semicontinuous r := by\n simp [SemicontinuousOn, Semicontinuous, semicontinuousWithinAt_univ_iff]\n\n@[simp] theorem semicontinuous_restrict_iff :\n Semicontinuous (s.restrict r) ↔ SemicontinuousOn r s := by\n rw [SemicontinuousOn, Semicontinuous, SetCoe.forall]\n refine forall₂_congr fun a ha ↦ forall₂_congr fun b _ ↦ ?_\n simp only [nhdsWithin_eq_map_subtype_coe ha, eventually_map, restrict]\n\ntheorem Semicontinuous.semicontinuousAt (h : Semicontinuous r) (x : α) :\n SemicontinuousAt r x :=\n h x\n\ntheorem Semicontinuous.semicontinuousWithinAt (h : Semicontinuous r) (s : Set α)\n (x : α) : SemicontinuousWithinAt r s x :=\n (h x).semicontinuousWithinAt s\n\ntheorem Semicontinuous.semicontinuousOn (h : Semicontinuous r) (s : Set α) :\n SemicontinuousOn r s := fun x _hx => h.semicontinuousWithinAt s x\n\ntheorem semicontinuous_iff_isOpen : Semicontinuous r ↔ ∀ b, IsOpen {x | r x b} := by\n exact ⟨fun h b ↦ by simpa [isOpen_iff_mem_nhds, Filter.Eventually] using fun x hx ↦ h x b hx,\n fun h x b hbx ↦ (h b).mem_nhds hbx⟩\n\ntheorem Semicontinuous.isOpen (h : Semicontinuous r) (b : β) : IsOpen {x | r x b} :=\n semicontinuous_iff_isOpen.mp h b\n\ntheorem SemicontinuousWithinAt.inf {r' : α → β → Prop}\n (h : SemicontinuousWithinAt r s x) (h' : SemicontinuousWithinAt r' s x) :\n SemicontinuousWithinAt (r ⊓ r') s x := fun b ⟨hb, hb'⟩ ↦\n (h b hb).and (h' b hb')\n\ntheorem SemicontinuousWithinAt.sup {r' : α → β → Prop}\n (h : SemicontinuousWithinAt r s x) (h' : SemicontinuousWithinAt r' s x) :\n SemicontinuousWithinAt (r ⊔ r') s x := by\n intro b hab\n obtain hb | hb' := hab\n · exact (h b hb).mono fun _ hx ↦ Or.inl hx\n · exact (h' b hb').mono fun _ hx ↦ Or.inr hx\n\ntheorem SemicontinuousAt.inf {r' : α → β → Prop}\n (h : SemicontinuousAt r x) (h' : SemicontinuousAt r' x) :\n SemicontinuousAt (r ⊓ r') x := fun b ⟨hb, hb'⟩ ↦\n (h b hb).and (h' b hb')\n\nTarget:\ntheorem SemicontinuousAt.sup {r' : α → β → Prop}\n (h : SemicontinuousAt r x) (h' : SemicontinuousAt r' x) :\n SemicontinuousAt (r ⊔ r') x :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_7b6e5798fb01","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"1e1617f655e53f75a1750d3884545c6b8dd7af3535dc0ba49bc3d76b6f037b12","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Semicontinuity","family_id":"semicontinuousat","file_id":"mathlib/Mathlib/Topology/Semicontinuity/Defs.lean","sample_id":"7b6e5798fb01f5d57039217ed9c10498f339f78d55489e72cce49c284a570913"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"01400d4c9d2d9d2d5931cd47105d99e1eb32289a9c912524894e9aeeceb8d336","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e33ed1887f5738b4833bcae3bd11de96fa1adc451e3c174db53c9ab0ddfd8c95","source_sha256":"8889e08ccb62ae20505e23db3758a48b309775542abaa43a2ae2c2cddeb30453","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [hom',\n HomologicalComplex.extendMap_f _ ComplexShape.embeddingUpNat (i := m) (i' := n) (by simpa),\n cochainComplexXIso]","hard_negative":false,"metrics":{"chosen_tokens":29,"rejected_tokens":3,"token_jaccard":0.043478,"token_length_ratio":0.103448},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"3093b41016ac6c29939a284de776849b6f2f89cc16cfa182e9b16b43999a2b54","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.Embedding.CochainComplex\npublic import Mathlib.CategoryTheory.Preadditive.Injective.Resolution\n\nNamespace:\nCategoryTheory.InjectiveResolution.Hom\n\nLocal context:\n/-\nCopyright (c) 2025 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Injective resolutions as cochain complexes indexed by the integers\n\nGiven an injective resolution `R` of an object `X` in an abelian category `C`,\nwe define `R.cochainComplex : CochainComplex C ℤ`, which is the extension\nof `R.cocomplex : CochainComplex C ℕ`, and the quasi-isomorphism\n`R.ι' : (CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nnamespace CategoryTheory\n\nopen Limits\n\nvariable {C : Type u} [Category.{v} C]\n\nnamespace InjectiveResolution\n\nsection\n\nvariable [HasZeroObject C] [Preadditive C] {X : C}\n (R : InjectiveResolution X)\n\n/-- If `R : InjectiveResolution X`, this is the cochain complex indexed by `ℤ`\nobtained by extending by zero the cochain complex `R.cocomplex` indexed by `ℕ`. -/\nnoncomputable def cochainComplex : CochainComplex C ℤ :=\n R.cocomplex.extend ComplexShape.embeddingUpNat\n\ninstance : R.cochainComplex.IsStrictlyGE 0 := by\n dsimp [cochainComplex]\n infer_instance\n\n/-- If `R : InjectiveResolution X`, then `R.cochainComplex.X n` (with `n : ℕ`)\nis isomorphic to `R.cocomplex.X k` (with `k : ℕ`) when `k = n`. -/\nnoncomputable def cochainComplexXIso (n : ℤ) (k : ℕ) (h : k = n) :\n R.cochainComplex.X n ≅ R.cocomplex.X k :=\n HomologicalComplex.extendXIso _ _ h\n\n@[reassoc]\nlemma cochainComplex_d (n₁ n₂ : ℤ) (k₁ k₂ : ℕ) (h₁ : k₁ = n₁) (h₂ : k₂ = n₂) :\n R.cochainComplex.d n₁ n₂ = (cochainComplexXIso _ _ _ h₁).hom ≫\n R.cocomplex.d k₁ k₂ ≫ (cochainComplexXIso _ _ _ h₂).inv :=\n HomologicalComplex.extend_d_eq _ _ h₁ h₂\n\ninstance : R.cochainComplex.IsStrictlyGE 0 := by\n dsimp [cochainComplex]\n infer_instance\n\ninstance (n : ℤ) : Injective (R.cochainComplex.X n) := by\n by_cases hn : 0 ≤ n\n · obtain ⟨k, rfl⟩ := Int.eq_ofNat_of_zero_le hn\n exact Injective.of_iso (R.cochainComplexXIso _ _ rfl).symm inferInstance\n · exact IsZero.injective (CochainComplex.isZero_of_isStrictlyGE _ 0 _ (by lia))\n\n/-- The quasi-isomorphism `(CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex`\nin `CochainComplex C ℤ` when `R` is an injective resolution of `X`. -/\nnoncomputable def ι' : (CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex :=\n (HomologicalComplex.extendSingleIso _ _ _ _ (by simp)).inv ≫\n (ComplexShape.embeddingUpNat.extendFunctor C).map R.ι\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc]\nlemma ι'_f_zero :\n R.ι'.f 0 = (HomologicalComplex.singleObjXSelf (.up ℤ) 0 X).hom ≫ R.ι.f 0 ≫\n (R.cochainComplexXIso _ _ (by simp)).inv := by\n dsimp [ι']\n rw [HomologicalComplex.extendMap_f _ _ (i := 0) (by simp),\n HomologicalComplex.extendSingleIso_inv_f]\n cat_disch\n\nend\n\nvariable [Abelian C] {X : C} (R : InjectiveResolution X)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\ninstance : QuasiIso R.ι' := by dsimp [ι']; infer_instance\n\ninstance : R.cochainComplex.IsLE 0 := by\n simp only [← HomologicalComplex.isSupported_iff_of_quasiIso R.ι']\n infer_instance\n\nnamespace Hom\n\nvariable {R} {X' : C} {R' : InjectiveResolution X'} {f : X ⟶ X'}\n (φ : Hom R R' f)\n\n/-- The morphism on cochain complexes indexed by `ℤ` that is induced by\nan (heterogeneous) morphism of injective resolutions. -/\nnoncomputable def hom' : R.cochainComplex ⟶ R'.cochainComplex :=\n HomologicalComplex.extendMap φ.hom _\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc]\n\nTarget:\nlemma hom'_f (n : ℤ) (m : ℕ) (h : m = n) :\n φ.hom'.f n =\n (R.cochainComplexXIso n m h).hom ≫ φ.hom.f m ≫ (R'.cochainComplexXIso n m h).inv :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Abelian","family_id":"hom'_f","file_id":"mathlib/Mathlib/CategoryTheory/Abelian/Injective/Extend.lean","sample_id":"e33ed1887f5738b4833bcae3bd11de96fa1adc451e3c174db53c9ab0ddfd8c95"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4815aeb2672e30c1806bf7cd4715d59757508ece8b29a80697b8616581ac7a88","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7d30123c5f8ed7b60ef157343f65b0a92e727cfdb2c0c0edbfe74cd8b2fc1c64","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"35db60c2733598ed4931ff1339b1e19ec57f35aff3079e50a87adcb6e8207eab","source_sha256":"0cf246dc3c2cbecf11bebc087d277ba7f05345ab88d2c3bf6b111583252fdecf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext; exact ⟨fun ⟨_, h⟩ ↦ by tauto, False.elim⟩","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":3,"token_jaccard":0.125,"token_length_ratio":0.157895},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"30d763f5ac3081b9d715eecb0b5606993d203ceb43a1093477e77b87d7f77fa4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Combinatorics.Digraph.Basic\npublic import Mathlib.Combinatorics.SimpleGraph.Basic\n\nNamespace:\nDigraph\n\nLocal context:\n/-\nCopyright (c) 2024 Rida Hamadani. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rida Hamadani\n-/\n/-!\n\n# Graph Orientation\n\nThis module introduces conversion operations between `Digraph`s and `SimpleGraph`s, by forgetting\nthe edge orientations of `Digraph`.\n\n## Main Definitions\n\n- `Digraph.toSimpleGraphInclusive`: Converts a `Digraph` to a `SimpleGraph` by creating an\n undirected edge if either orientation exists in the digraph.\n- `Digraph.toSimpleGraphStrict`: Converts a `Digraph` to a `SimpleGraph` by creating an undirected\n edge only if both orientations exist in the digraph.\n\n## TODO\n\n- Show that there is an isomorphism between loopless complete digraphs and oriented graphs.\n- Define more ways to orient a `SimpleGraph`.\n- Provide lemmas on how `toSimpleGraphInclusive` and `toSimpleGraphStrict` relate to other lattice\n structures on `SimpleGraph`s and `Digraph`s.\n\n## Tags\n\ndigraph, simple graph, oriented graphs\n-/\n\n@[expose] public section\n\nvariable {V : Type*}\n\nnamespace Digraph\n\nsection toSimpleGraph\n\n/-! ### Orientation-forgetting maps on digraphs -/\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\neither orientation is present.\n-/\ndef toSimpleGraphInclusive (G : Digraph V) : SimpleGraph V := SimpleGraph.fromRel G.Adj\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\nboth orientations are present.\n-/\ndef toSimpleGraphStrict (G : Digraph V) : SimpleGraph V where\n Adj v w := v ≠ w ∧ G.Adj v w ∧ G.Adj w v\n\nlemma toSimpleGraphStrict_subgraph_toSimpleGraphInclusive (G : Digraph V) :\n G.toSimpleGraphStrict ≤ G.toSimpleGraphInclusive :=\n fun _ _ h ↦ ⟨h.1, Or.inl h.2.1⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphInclusive_mono : Monotone (toSimpleGraphInclusive : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₂.2.imp (@h₁ _ _) (@h₁ _ _)⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphStrict_mono : Monotone (toSimpleGraphStrict : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₁ h₂.2.1, h₁ h₂.2.2⟩\n\n@[simp]\nlemma toSimpleGraphInclusive_top : (⊤ : Digraph V).toSimpleGraphInclusive = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, Or.inl trivial⟩⟩\n\n@[simp]\nlemma toSimpleGraphStrict_top : (⊤ : Digraph V).toSimpleGraphStrict = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩\n\n@[simp]\n\nTarget:\nlemma toSimpleGraphInclusive_bot : (⊥ : Digraph V).toSimpleGraphInclusive = ⊥ :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_35db60c27335","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5e652b7682b33088c2d788c3367bc83e35828fa3f590f8280616addde21dee11","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Digraph","family_id":"tosimplegraphinclusive_bot","file_id":"mathlib/Mathlib/Combinatorics/Digraph/Orientation.lean","sample_id":"35db60c2733598ed4931ff1339b1e19ec57f35aff3079e50a87adcb6e8207eab"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"26663fc1bf6b4e5aefb65660a393c53e27dfaf28983bb18a6c7510bb8a675597","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d9c4e7f713b55d8ae8a36e3dccce93a77837d629ec0bf1a0d646d0cb0af21183","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e279e1822904168067ecd9997a88ad6f26de6f6b0101216ed184ae97359d0b3e","source_sha256":"22fa7dc543ea04781c497c923ce59749d770278f4d57644a7a47b8e8d1036d31","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases t\n apply Nat.succ_pos","hard_negative":true,"metrics":{"chosen_tokens":7,"rejected_tokens":5,"token_jaccard":0.2,"token_length_ratio":0.714286},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"324ae592c3cab17f27a60eb698c2fdbb1b5dbe1bcc1f7842007c2aed53901daf","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finset.Lattice.Fold\npublic import Mathlib.Logic.Encodable.Pi\n\nNamespace:\nWType\n\nLocal context:\n/-\nCopyright (c) 2019 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad\n-/\n/-!\n# W types\n\nGiven `α : Type` and `β : α → Type`, the W type determined by this data, `WType β`, is the\ninductively defined type of trees where the nodes are labeled by elements of `α` and the children of\na node labeled `a` are indexed by elements of `β a`.\n\nThis file is currently a stub, awaiting a full development of the theory. Currently, the main result\nis that if `α` is an encodable fintype and `β a` is encodable for every `a : α`, then `WType β` 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 `WType` is somewhat verbose, it is preferable to putting a single character\nidentifier `W` in the root namespace.\n-/\n\n@[expose] public section\n\n-- For \"W_type\"\n\n/--\nGiven `β : α → Type*`, `WType β` is the type of finitely branching trees where nodes are labeled by\nelements of `α` and the children of a node labeled `a` are indexed by elements of `β a`.\n-/\ninductive WType {α : Type*} (β : α → Type*)\n | mk (a : α) (f : β a → WType β) : WType β\n\ninstance : Inhabited (WType fun _ : Unit => Empty) :=\n ⟨WType.mk Unit.unit Empty.elim⟩\n\nnamespace WType\n\nvariable {α : Type*} {β : α → Type*}\n\n/-- The canonical map to the corresponding sigma type, returning the label of a node as an\n element `a` of `α`, and the children of the node as a function `β a → WType β`. -/\ndef toSigma : WType β → Σ a : α, β a → WType β\n | ⟨a, f⟩ => ⟨a, f⟩\n\n/-- The canonical map from the sigma type into a `WType`. Given a node `a : α`, and\n its children as a function `β a → WType β`, return the corresponding tree. -/\ndef ofSigma : (Σ a : α, β a → WType β) → WType β\n | ⟨a, f⟩ => WType.mk a f\n\n@[simp]\ntheorem ofSigma_toSigma : ∀ w : WType β, ofSigma (toSigma w) = w\n | ⟨_, _⟩ => rfl\n\n@[simp]\ntheorem toSigma_ofSigma : ∀ s : Σ a : α, β a → WType β, toSigma (ofSigma s) = s\n | ⟨_, _⟩ => rfl\n\nvariable (β) in\n/-- The canonical bijection with the sigma type, showing that `WType` is a fixed point of\n the polynomial functor `X ↦ Σ a : α, β a → X`. -/\n@[simps]\ndef equivSigma : WType β ≃ Σ a : α, β a → WType β where\n toFun := toSigma\n invFun := ofSigma\n left_inv := ofSigma_toSigma\n right_inv := toSigma_ofSigma\n\n/-- The canonical map from `WType β` into any type `γ` given a map `(Σ a : α, β a → γ) → γ`. -/\ndef elim (γ : Type*) (fγ : (Σ a : α, β a → γ) → γ) : WType β → γ\n | ⟨a, f⟩ => fγ ⟨a, fun b => elim γ fγ (f b)⟩\n\ntheorem elim_injective (γ : Type*) (fγ : (Σ a : α, β a → γ) → γ)\n (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)\n | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h => by\n obtain ⟨rfl, h⟩ := Sigma.mk.inj_iff.mp (fγ_injective h)\n congr with x\n exact elim_injective γ fγ fγ_injective (congr_fun (eq_of_heq h) x :)\n\ninstance [hα : IsEmpty α] : IsEmpty (WType β) :=\n ⟨fun w => WType.recOn w (IsEmpty.elim hα)⟩\n\ntheorem infinite_of_nonempty_of_isEmpty (a b : α) [ha : Nonempty (β a)] [he : IsEmpty (β b)] :\n Infinite (WType β) :=\n ⟨by\n intro hf\n have hba : b ≠ a := fun h => ha.elim (IsEmpty.elim' (show IsEmpty (β a) from h ▸ he))\n refine\n not_injective_infinite_finite\n (fun n : ℕ =>\n show WType β from Nat.recOn n ⟨b, IsEmpty.elim' he⟩ fun _ ih => ⟨a, fun _ => ih⟩)\n ?_\n intro n m h\n induction n generalizing m with\n | zero => rcases m with - | m <;> simp_all\n | succ n ih =>\n rcases m with - | m\n · simp_all\n · refine congr_arg Nat.succ (ih ?_)\n simp_all [funext_iff]⟩\n\nvariable [∀ a : α, Fintype (β a)]\n\n/-- The depth of a finitely branching tree. -/\ndef depth : WType β → ℕ\n | ⟨_, f⟩ => (Finset.sup Finset.univ fun n => depth (f n)) + 1\n\nTarget:\ntheorem depth_pos (t : WType β) : 0 < t.depth :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_e279e1822904","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"e892474ab5ef84b8997d9ba8fa3bf718f1f59bb2af090b1d5ab3a2eebd0b66a6","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/W","family_id":"depth_pos","file_id":"mathlib/Mathlib/Data/W/Basic.lean","sample_id":"e279e1822904168067ecd9997a88ad6f26de6f6b0101216ed184ae97359d0b3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1432092ec00658210991ef62fdf17b3098cf9ea9d7bc68a7a025aabc5d08061e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"aa723eecf685cfd6fc5271833b0e86ca29cc0c5f663b3df66652e4aa2b6b5178","source_sha256":"8c28bee61c275be882f91a7d90b8745fd8945186718df7d844b9acdb9fd9341b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← map_mul, sum_characters_eq, ZMod.inv_mul_eq_one_of_isUnit ha]","hard_negative":true,"metrics":{"chosen_tokens":14,"rejected_tokens":8,"token_jaccard":0.052632,"token_length_ratio":0.571429},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"33d3a9efd70463cdfbf69c64e0d9b9db733b311aef81e44a3c3a013e803d7891","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Finite.Basic\npublic import Mathlib.NumberTheory.DirichletCharacter.Basic\npublic import Mathlib.NumberTheory.MulChar.Duality\n\nNamespace:\nDirichletCharacter\n\nLocal context:\n/-\nCopyright (c) 2024 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Orthogonality relations for Dirichlet characters\n\nLet `n` be a positive natural number. The main result of this file is\n`DirichletCharacter.sum_char_inv_mul_char_eq`, which says that when `a : ZMod n` is a unit\nand `b : ZMod n`, then the sum `∑ χ : DirichletCharacter R n, χ a⁻¹ * χ b` vanishes\nwhen `a ≠ b` and has the value `n.totient` otherwise. This requires `R` to have\nenough roots of unity (e.g., `R` could be an algebraically closed field of characteristic zero).\n-/\n\npublic section\n\nnamespace DirichletCharacter\n\n-- This is needed to be able to write down sums over characters.\nnoncomputable instance fintype {R : Type*} [CommRing R] [IsDomain R] {n : ℕ} :\n Fintype (DirichletCharacter R n) := .ofFinite _\n\nvariable (R : Type*) [CommRing R] (n : ℕ) [NeZero n]\n [HasEnoughRootsOfUnity R (Monoid.exponent (ZMod n)ˣ)]\n\n/-- The group of Dirichlet characters mod `n` with values in a ring `R` that has enough\nroots of unity is (noncanonically) isomorphic to `(ZMod n)ˣ`. -/\nlemma mulEquiv_units : Nonempty (DirichletCharacter R n ≃* (ZMod n)ˣ) :=\n MulChar.mulEquiv_units ..\n\n/-- There are `n.totient` Dirichlet characters mod `n` with values in a ring that has enough\nroots of unity. -/\nlemma card_eq_totient_of_hasEnoughRootsOfUnity :\n Nat.card (DirichletCharacter R n) = n.totient := by\n rw [← ZMod.card_units_eq_totient n, ← Nat.card_eq_fintype_card]\n exact Nat.card_congr (mulEquiv_units R n).some.toEquiv\n\nvariable {n}\n\n/-- If `R` is a ring that has enough roots of unity and `n ≠ 0`, then for each\n`a ≠ 1` in `ZMod n`, there exists a Dirichlet character `χ` mod `n` with values in `R`\nsuch that `χ a ≠ 1`. -/\ntheorem exists_apply_ne_one_of_hasEnoughRootsOfUnity [Nontrivial R] ⦃a : ZMod n⦄ (ha : a ≠ 1) :\n ∃ χ : DirichletCharacter R n, χ a ≠ 1 :=\n MulChar.exists_apply_ne_one_of_hasEnoughRootsOfUnity (ZMod n) R ha\n\nvariable [IsDomain R]\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then\nfor each `a ≠ 1` in `ZMod n`, the sum of `χ a` over all Dirichlet characters mod `n`\nwith values in `R` vanishes. -/\ntheorem sum_characters_eq_zero ⦃a : ZMod n⦄ (ha : a ≠ 1) :\n ∑ χ : DirichletCharacter R n, χ a = 0 := by\n obtain ⟨χ, hχ⟩ := exists_apply_ne_one_of_hasEnoughRootsOfUnity R ha\n refine eq_zero_of_mul_eq_self_left hχ ?_\n simp only [Finset.mul_sum, ← MulChar.mul_apply]\n exact Fintype.sum_bijective _ (Group.mulLeft_bijective χ) _ _ fun χ' ↦ rfl\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then\nfor `a` in `ZMod n`, the sum of `χ a` over all Dirichlet characters mod `n`\nwith values in `R` vanishes if `a ≠ 1` and has the value `n.totient` if `a = 1`. -/\ntheorem sum_characters_eq (a : ZMod n) :\n ∑ χ : DirichletCharacter R n, χ a = if a = 1 then (n.totient : R) else 0 := by\n split_ifs with ha\n · simpa only [ha, map_one, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one,\n ← Nat.card_eq_fintype_card]\n using congrArg Nat.cast <| card_eq_totient_of_hasEnoughRootsOfUnity R n\n · exact sum_characters_eq_zero R ha\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then for `a` and `b`\nin `ZMod n` with `a` a unit, the sum of `χ a⁻¹ * χ b` over all Dirichlet characters\nmod `n` with values in `R` vanishes if `a ≠ b` and has the value `n.totient` if `a = b`. -/\n\nTarget:\ntheorem sum_char_inv_mul_char_eq {a : ZMod n} (ha : IsUnit a) (b : ZMod n) :\n ∑ χ : DirichletCharacter R n, χ a⁻¹ * χ b = if a = b then (n.totient : R) else 0 :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"d4bfd942fd338248dffd8db54f4765b2a6e2d2a3565a88ce70392ecaab28e209","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/DirichletCharacter","family_id":"sum_char_inv_mul_char_eq","file_id":"mathlib/Mathlib/NumberTheory/DirichletCharacter/Orthogonality.lean","sample_id":"aa723eecf685cfd6fc5271833b0e86ca29cc0c5f663b3df66652e4aa2b6b5178"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bb2bbade796218fc602cae73b83839fef9caa5d8cd70cea38cea67788bdd4ad8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d871f0c8dbf8519eff4e1bdf250eb04471606613a1434286691a5354331815e3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d1dbab6d531d2409109ce1cd5d2f43ef978ecebab2e551a8f5f4ae20169ca22f","source_sha256":"b1ad611057493f75821a824485b9f5ad1e1b6dd4eaa317b9db2936b30ae77c1d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [Perm.subtypeCongr.apply, h]","hard_negative":false,"metrics":{"chosen_tokens":11,"rejected_tokens":16,"token_jaccard":0.666667,"token_length_ratio":1.454545},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"349fcb9df3cdbbe3cc5364057acdc7b471cfb43bfb5be4ea8d4f30b3446a11ee","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Equiv.Option\npublic import Mathlib.Logic.Equiv.Sum\npublic import Mathlib.Logic.Function.Conjugate\npublic import Mathlib.Tactic.Lift\npublic import Mathlib.Data.Int.Notation\n\nNamespace:\nEquiv\n\nLocal context:\n/-\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/-!\n# Equivalence between types\n\nIn this file we continue the work on equivalences begun in `Mathlib/Logic/Equiv/Defs.lean`, defining\na lot of equivalences between various types and operations on these equivalences.\n\nMore definitions of this kind can be found in other files.\nE.g., `Mathlib/Algebra/Group/TransferInstance.lean` does it for `Group`,\n`Mathlib/Algebra/Module/TransferInstance.lean` does it for `Module`, and similar files exist for\nother algebraic type classes.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n@[expose] public section\n\nuniverse u v w z\n\nopen Function\n\n-- Unless required to be `Type*`, all variables in this file are `Sort*`\nvariable {α α₁ α₂ β β₁ β₂ γ δ : Sort*}\n\nnamespace Equiv\n\n/-- The product over `Option α` of `β a` is the binary product of the\nproduct over `α` of `β (some α)` and `β none` -/\n@[simps]\ndef piOptionEquivProd {α} {β : Option α → Type*} :\n (∀ a : Option α, β a) ≃ β none × ∀ a : α, β (some a) 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\nsection subtypeCongr\n\n/-- Combines an `Equiv` between two subtypes with an `Equiv` between their complements to form a\n permutation. -/\ndef subtypeCongr {α} {p q : α → Prop} [DecidablePred p] [DecidablePred q]\n (e : { x // p x } ≃ { x // q x }) (f : { x // ¬p x } ≃ { x // ¬q x }) : Perm α :=\n (sumCompl p).symm.trans ((sumCongr e f).trans (sumCompl q))\n\nvariable {ε : Type*} {p : ε → Prop} [DecidablePred p]\nvariable (ep ep' : Perm { a // p a }) (en en' : Perm { a // ¬p a })\n\n/-- Combining permutations on `ε` that permute only inside or outside the subtype\nsplit induced by `p : ε → Prop` constructs a permutation on `ε`. -/\ndef Perm.subtypeCongr : Equiv.Perm ε :=\n permCongr (sumCompl p) (sumCongr ep en)\n\ntheorem Perm.subtypeCongr.apply (a : ε) : ep.subtypeCongr en a =\n if h : p a then (ep ⟨a, h⟩ : ε) else en ⟨a, h⟩ := by\n by_cases h : p a <;> simp [Perm.subtypeCongr, h]\n\n@[simp]\n\nTarget:\ntheorem Perm.subtypeCongr.left_apply {a : ε} (h : p a) : ep.subtypeCongr en a = ep ⟨a, h⟩ :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n simp [Perm.subtypeCongr.apply, h]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Equiv","family_id":"perm","file_id":"mathlib/Mathlib/Logic/Equiv/Basic.lean","sample_id":"d1dbab6d531d2409109ce1cd5d2f43ef978ecebab2e551a8f5f4ae20169ca22f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5dbd71689158601c5789ec24cc14570ce28d27112ad7ed5d699e6e66523ae261","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a596a1ccb0d0a918a560b38e1d029403d9f1e2e9bfaa6c957f03ddc8f0f8cd05","source_sha256":"f134e208ef1ed7469f55b728b3abbaf40d3b9460e8d396abbdb8740673919f45","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨f, -⟩ ⟨g, -⟩; simp","hard_negative":true,"metrics":{"chosen_tokens":14,"rejected_tokens":8,"token_jaccard":0.0625,"token_length_ratio":0.571429},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"351934e8d3d394c6ad10668a1688c9d007b07044a9b4347e8d4cb2ba2eabac6f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Embedding.Basic\npublic import Mathlib.Order.RelClasses\n\nNamespace:\nRelEmbedding\n\nLocal context:\n/-\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/-!\n# Relation homomorphisms, embeddings, isomorphisms\n\nThis file defines relation homomorphisms, embeddings, isomorphisms and order embeddings and\nisomorphisms.\n\n## Main declarations\n\n* `RelHom`: Relation homomorphism. A `RelHom r s` is a function `f : α → β` such that\n `r a b → s (f a) (f b)`.\n* `RelEmbedding`: Relation embedding. A `RelEmbedding r s` is an embedding `f : α ↪ β` such that\n `r a b ↔ s (f a) (f b)`.\n* `RelIso`: Relation isomorphism. A `RelIso r s` is an equivalence `f : α ≃ β` such that\n `r a b ↔ s (f a) (f b)`.\n* `sumLexCongr`, `prodLexCongr`: Creates a relation homomorphism between two `Sum.Lex` or two\n `Prod.Lex` from relation homomorphisms between their arguments.\n\n## Notation\n\n* `→r`: `RelHom`\n* `↪r`: `RelEmbedding`\n* `≃r`: `RelIso`\n-/\n\n@[expose] public section\n\nopen Function\n\nuniverse u v w\n\nvariable {α β γ δ : Type*} {r : α → α → Prop} {s : β → β → Prop}\n {t : γ → γ → Prop} {u : δ → δ → Prop}\n\n/-- A relation homomorphism with respect to a given pair of relations `r` and `s`\nis a function `f : α → β` such that `r a b → s (f a) (f b)`. -/\nstructure RelHom {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) where\n /-- The underlying function of a `RelHom` -/\n toFun : α → β\n /-- A `RelHom` sends related elements to related elements -/\n map_rel' : ∀ {a b}, r a b → s (toFun a) (toFun b)\n\n/-- A relation homomorphism with respect to a given pair of relations `r` and `s`\nis a function `f : α → β` such that `r a b → s (f a) (f b)`. -/\ninfixl:25 \" →r \" => RelHom\n\nsection\n\n/-- `RelHomClass F r s` asserts that `F` is a type of functions such that all `f : F`\nsatisfy `r a b → s (f a) (f b)`.\n\nThe relations `r` and `s` are `outParam`s since figuring them out from a goal is a higher-order\nmatching problem that Lean usually can't do unaided.\n-/\nclass RelHomClass (F : Type*) {α β : outParam Type*} (r : outParam <| α → α → Prop)\n (s : outParam <| β → β → Prop) [FunLike F α β] : Prop where\n /-- A `RelHomClass` sends related elements to related elements -/\n map_rel : ∀ (f : F) {a b}, r a b → s (f a) (f b)\n\nexport RelHomClass (map_rel)\n\nend\n\nnamespace RelHomClass\n\nvariable {F : Type*} [FunLike F α β]\n\nprotected theorem irrefl [RelHomClass F r s] (f : F) : ∀ [Std.Irrefl s], Std.Irrefl r\n | ⟨H⟩ => ⟨fun _ h => H _ (map_rel f h)⟩\n\n@[deprecated (since := \"2026-01-07\")] protected alias isIrrefl := RelHomClass.irrefl\n\nprotected theorem asymm [RelHomClass F r s] (f : F) : ∀ [Std.Asymm s], Std.Asymm r\n | ⟨H⟩ => ⟨fun _ _ h₁ h₂ => H _ _ (map_rel f h₁) (map_rel f h₂)⟩\n\n@[deprecated (since := \"2026-01-07\")] protected alias isAsymm := RelHomClass.asymm\n\nprotected theorem acc [RelHomClass F r s] (f : F) (a : α) : Acc s (f a) → Acc r a := by\n generalize h : f a = b\n intro ac\n induction ac generalizing a with | intro _ H IH => ?_\n subst h\n exact ⟨_, fun a' h => IH (f a') (map_rel f h) _ rfl⟩\n\nprotected theorem wellFounded [RelHomClass F r s] (f : F) : WellFounded s → WellFounded r\n | ⟨H⟩ => ⟨fun _ => RelHomClass.acc f _ (H _)⟩\n\nprotected theorem isWellFounded [RelHomClass F r s] (f : F) [IsWellFounded β s] :\n IsWellFounded α r :=\n ⟨RelHomClass.wellFounded f IsWellFounded.wf⟩\n\nend RelHomClass\n\nnamespace RelHom\n\ninstance : FunLike (r →r s) α β where\n coe o := o.toFun\n coe_injective f g h := by\n cases f\n cases g\n congr\n\ninstance : RelHomClass (r →r s) r s where\n map_rel := map_rel'\n\ninitialize_simps_projections RelHom (toFun → apply)\n\nprotected theorem map_rel (f : r →r s) {a b} : r a b → s (f a) (f b) :=\n f.map_rel'\n\n@[simp]\ntheorem coe_fn_toFun (f : r →r s) : f.toFun = (f : α → β) :=\n rfl\n\n@[simp]\ntheorem coeFn_mk (f : α → β) (h : ∀ {a b}, r a b → s (f a) (f b)) :\n RelHom.mk f @h = f :=\n rfl\n\n/-- The map `coe_fn : (r →r s) → (α → β)` is injective. -/\ntheorem coe_fn_injective : Injective fun (f : r →r s) => (f : α → β) :=\n DFunLike.coe_injective\n\n@[ext]\ntheorem ext ⦃f g : r →r s⦄ (h : ∀ x, f x = g x) : f = g :=\n DFunLike.ext f g h\n\n/-- Identity map is a relation homomorphism. -/\n@[refl, simps]\nprotected def id (r : α → α → Prop) : r →r r :=\n ⟨fun x => x, fun x => x⟩\n\n/-- Composition of two relation homomorphisms is a relation homomorphism. -/\n@[simps]\nprotected def comp (g : s →r t) (f : r →r s) : r →r t :=\n ⟨fun x => g (f x), fun h => g.2 (f.2 h)⟩\n\ntheorem comp_assoc (h : r →r s) (g : s →r t) (f : t →r u) :\n (f.comp g).comp h = f.comp (g.comp h) := rfl\n\n@[simp]\ntheorem comp_id (f : r →r s) : f.comp (RelHom.id r) = f := rfl\n\n@[simp]\ntheorem id_comp (f : r →r s) : (RelHom.id s).comp f = f := rfl\n\n/-- A relation homomorphism is also a relation homomorphism between dual relations. -/\n@[simps]\nprotected def swap (f : r →r s) : swap r →r swap s :=\n ⟨f, f.map_rel⟩\n\n/-- A function is a relation homomorphism from the preimage relation of `s` to `s`. -/\n@[simps]\ndef preimage (f : α → β) (s : β → β → Prop) : f ⁻¹'o s →r s :=\n ⟨f, id⟩\n\nend RelHom\n\n/-- An increasing function is injective -/\ntheorem injective_of_increasing (r : α → α → Prop) (s : β → β → Prop) [Std.Trichotomous r]\n [Std.Irrefl s] (f : α → β) (hf : ∀ {x y}, r x y → s (f x) (f y)) : Injective f := by\n intro x y hxy\n rcases trichotomous_of r x y with (h | h | h)\n · have := hf h\n rw [hxy] at this\n exfalso\n exact irrefl_of s (f y) this\n · exact h\n · have := hf h\n rw [hxy] at this\n exfalso\n exact irrefl_of s (f y) this\n\n/-- An increasing function is injective -/\ntheorem RelHom.injective_of_increasing [Std.Trichotomous r] [Std.Irrefl s] (f : r →r s) :\n Injective f :=\n _root_.injective_of_increasing r s f f.map_rel\n\ntheorem Function.Surjective.wellFounded_iff {f : α → β} (hf : Surjective f)\n (o : ∀ {a b}, r a b ↔ s (f a) (f b)) :\n WellFounded r ↔ WellFounded s :=\n Iff.intro\n (RelHomClass.wellFounded (⟨surjInv hf,\n fun h => by simpa only [o, surjInv_eq hf] using h⟩ : s →r r))\n (RelHomClass.wellFounded (⟨f, o.1⟩ : r →r s))\n\n/-- A relation embedding with respect to a given pair of relations `r` and `s`\nis an embedding `f : α ↪ β` such that `r a b ↔ s (f a) (f b)`. -/\nstructure RelEmbedding {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends α ↪ β where\n /-- Elements are related iff they are related after apply a `RelEmbedding` -/\n map_rel_iff' : ∀ {a b}, s (toEmbedding a) (toEmbedding b) ↔ r a b\n\n/-- A relation embedding with respect to a given pair of relations `r` and `s`\nis an embedding `f : α ↪ β` such that `r a b ↔ s (f a) (f b)`. -/\ninfixl:25 \" ↪r \" => RelEmbedding\n\ntheorem preimage_equivalence {α β} (f : α → β) {s : β → β → Prop} (hs : Equivalence s) :\n Equivalence (f ⁻¹'o s) :=\n ⟨fun _ => hs.1 _, fun h => hs.2 h, fun h₁ h₂ => hs.3 h₁ h₂⟩\n\nnamespace RelEmbedding\n\n/-- A relation embedding is also a relation homomorphism -/\n@[reducible]\ndef toRelHom (f : r ↪r s) : r →r s where\n toFun := f.toEmbedding.toFun\n map_rel' := (map_rel_iff' f).mpr\n\ninstance : Coe (r ↪r s) (r →r s) :=\n ⟨toRelHom⟩\n\ninstance : FunLike (r ↪r s) α β where\n coe x := x.toFun\n coe_injective f g h := by\n rcases f with ⟨⟨⟩⟩\n rcases g with ⟨⟨⟩⟩\n congr\n\ninstance : RelHomClass (r ↪r s) r s where\n map_rel f _ _ := Iff.mpr (map_rel_iff' f)\n\ninitialize_simps_projections RelEmbedding (toFun → apply)\n\ninstance : EmbeddingLike (r ↪r s) α β where\n injective' f := f.inj'\n\n@[simp]\ntheorem coe_toEmbedding {f : r ↪r s} : ((f : r ↪r s).toEmbedding : α → β) = f :=\n rfl\n\ntheorem coe_toRelHom {f : r ↪r s} : ((f : r ↪r s).toRelHom : α → β) = f :=\n rfl\n\nTarget:\ntheorem toEmbedding_injective : Injective (toEmbedding : r ↪r s → (α ↪ β)) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"24c082ad88b6e04d894b2ee7bb12373d523be8a3dc4337ec9db82be6d67b98e2","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/RelIso","family_id":"toembedding_injective","file_id":"mathlib/Mathlib/Order/RelIso/Basic.lean","sample_id":"a596a1ccb0d0a918a560b38e1d029403d9f1e2e9bfaa6c957f03ddc8f0f8cd05"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a10105848e4bffb1795b5dc079306ee66c220f6a62d93d28fb5548635276786e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ec4f96f91a09dbf29e1f7b52148becbb79f68ade3baa7edeb9ce6bbae0b8528a","source_sha256":"fa786fdfdd4a74d50a5a2889ef1a1e8a8dcab254efa8b824a0f56b7cd2d5e90c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n exact _root_.Quotient.exact h","hard_negative":true,"metrics":{"chosen_tokens":8,"rejected_tokens":8,"token_jaccard":0.083333,"token_length_ratio":1.0},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"35dbb2d1a8b7c8f326ef9eb6c5be6a06fd1c9dc446961fa0edff2ef4d37ef6e1","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homotopy.Basic\npublic import Mathlib.Topology.Connected.PathConnected\npublic import Mathlib.Analysis.Convex.Basic\n\nNamespace:\nHomotopic.Quotient\n\nLocal context:\n/-\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/-!\n# Homotopy between paths\n\nIn this file, we define a `Homotopy` between two `Path`s. In addition, we define a relation\n`Homotopic` on `Path`s, and prove that it is an equivalence relation.\n\n## Definitions\n\n* `Path.Homotopy p₀ p₁` is the type of homotopies between paths `p₀` and `p₁`\n* `Path.Homotopy.refl p` is the constant homotopy between `p` and itself\n* `Path.Homotopy.symm F` is the `Path.Homotopy p₁ p₀` defined by reversing the homotopy\n* `Path.Homotopy.trans F G`, where `F : Path.Homotopy p₀ p₁`, `G : Path.Homotopy p₁ p₂` is the\n `Path.Homotopy p₀ p₂` defined by putting the first homotopy on `[0, 1/2]` and the second on\n `[1/2, 1]`\n* `Path.Homotopy.hcomp F G`, where `F : Path.Homotopy p₀ q₀` and `G : Path.Homotopy p₁ q₁` is\n a `Path.Homotopy (p₀.trans p₁) (q₀.trans q₁)`\n* `Path.Homotopic p₀ p₁` is the relation saying that there is a homotopy between `p₀` and `p₁`\n* `Path.Homotopic.setoid x₀ x₁` is the setoid on `Path`s from `Path.Homotopic`\n* `Path.Homotopic.Quotient x₀ x₁` is the quotient type from `Path x₀ x₀` by `Path.Homotopic.setoid`\n\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nvariable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]\nvariable {x₀ x₁ x₂ x₃ : X}\n\nnoncomputable section\n\nopen unitInterval\n\nnamespace Path\n\n/-- The type of homotopies between two paths.\n-/\nabbrev Homotopy (p₀ p₁ : Path x₀ x₁) :=\n ContinuousMap.HomotopyRel p₀.toContinuousMap p₁.toContinuousMap {0, 1}\n\nnamespace Homotopy\n\nsection\n\nvariable {p₀ p₁ : Path x₀ x₁}\n\ntheorem coeFn_injective : @Function.Injective (Homotopy p₀ p₁) (I × I → X) (⇑) :=\n DFunLike.coe_injective\n\n@[simp]\ntheorem source (F : Homotopy p₀ p₁) (t : I) : F (t, 0) = x₀ :=\n calc F (t, 0) = p₀ 0 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inl rfl)\n _ = x₀ := p₀.source\n\n@[simp]\ntheorem target (F : Homotopy p₀ p₁) (t : I) : F (t, 1) = x₁ :=\n calc F (t, 1) = p₀ 1 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inr rfl)\n _ = x₁ := p₀.target\n\n/-- Evaluating a path homotopy at an intermediate point, giving us a `Path`.\n-/\n@[simps]\ndef eval (F : Homotopy p₀ p₁) (t : I) : Path x₀ x₁ where\n toFun := F.toHomotopy.curry t\n source' := by simp\n target' := by simp\n\n@[simp]\ntheorem eval_zero (F : Homotopy p₀ p₁) : F.eval 0 = p₀ := by\n ext t\n simp\n\n@[simp]\ntheorem eval_one (F : Homotopy p₀ p₁) : F.eval 1 = p₁ := by\n ext t\n simp\n\nend\n\nsection\n\nvariable {p₀ p₁ p₂ : Path x₀ x₁}\n\n/-- Given a path `p`, we can define a `Homotopy p p` by `F (t, x) = p x`.\n-/\n@[simps!]\ndef refl (p : Path x₀ x₁) : Homotopy p p :=\n ContinuousMap.HomotopyRel.refl p.toContinuousMap {0, 1}\n\n/-- Given a `Homotopy p₀ p₁`, we can define a `Homotopy p₁ p₀` by reversing the homotopy.\n-/\n@[simps!]\ndef symm (F : Homotopy p₀ p₁) : Homotopy p₁ p₀ :=\n ContinuousMap.HomotopyRel.symm F\n\n@[simp]\ntheorem symm_symm (F : Homotopy p₀ p₁) : F.symm.symm = F :=\n ContinuousMap.HomotopyRel.symm_symm F\n\ntheorem symm_bijective : Function.Bijective (Homotopy.symm : Homotopy p₀ p₁ → Homotopy p₁ p₀) :=\n Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩\n\n/--\nGiven `Homotopy p₀ p₁` and `Homotopy p₁ p₂`, we can define a `Homotopy p₀ p₂` by putting the first\nhomotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) : Homotopy p₀ p₂ :=\n ContinuousMap.HomotopyRel.trans F G\n\ntheorem trans_apply (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) (x : I × I) :\n (F.trans G) x =\n if h : (x.1 : ℝ) ≤ 1 / 2 then\n F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2)\n else\n G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) :=\n ContinuousMap.HomotopyRel.trans_apply _ _ _\n\ntheorem symm_trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) :\n (F.trans G).symm = G.symm.trans F.symm :=\n ContinuousMap.HomotopyRel.symm_trans _ _\n\n/-- Casting a `Homotopy p₀ p₁` to a `Homotopy q₀ q₁` where `p₀ = q₀` and `p₁ = q₁`. -/\n@[simps!]\ndef cast {p₀ p₁ q₀ q₁ : Path x₀ x₁} (F : Homotopy p₀ p₁) (h₀ : p₀ = q₀) (h₁ : p₁ = q₁) :\n Homotopy q₀ q₁ :=\n ContinuousMap.HomotopyRel.cast F (congr_arg _ h₀) (congr_arg _ h₁)\n\n/-- If paths `p` and `q` are homotopic as paths `x ⟶ y`,\nthen they are homotopic as paths `x' ⟶ y'`, where `x' = x` and `y' = y`. -/\n@[simp]\ndef pathCast {x x' y y' : X} {p q : Path x y} (F : p.Homotopy q) (hx : x' = x) (hy : y' = y) :\n (p.cast hx hy).Homotopy (q.cast hx hy) :=\n F\n\nend\n\nsection\n\nvariable {p₀ q₀ : Path x₀ x₁} {p₁ q₁ : Path x₁ x₂}\n\n/-- Suppose `p₀` and `q₀` are paths from `x₀` to `x₁`, `p₁` and `q₁` are paths from `x₁` to `x₂`.\nFurthermore, suppose `F : Homotopy p₀ q₀` and `G : Homotopy p₁ q₁`. Then we can define a homotopy\nfrom `p₀.trans p₁` to `q₀.trans q₁`.\n-/\ndef hcomp (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) : Homotopy (p₀.trans p₁) (q₀.trans q₁) where\n toFun x :=\n if (x.2 : ℝ) ≤ 1 / 2 then (F.eval x.1).extend (2 * x.2) else (G.eval x.1).extend (2 * x.2 - 1)\n continuous_toFun := continuous_if_le (continuous_induced_dom.comp continuous_snd) continuous_const\n (F.toHomotopy.continuous.comp (by fun_prop)).continuousOn\n (G.toHomotopy.continuous.comp (by fun_prop)).continuousOn fun x hx ↦ by norm_num [hx]\n map_zero_left x := by simp [Path.trans]\n map_one_left x := by simp [Path.trans]\n prop' x t ht := by\n rcases ht with ht | ht\n · norm_num [ht]\n · rw [Set.mem_singleton_iff] at ht\n norm_num [ht]\n\ntheorem hcomp_apply (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (x : I × I) :\n F.hcomp G x =\n if h : (x.2 : ℝ) ≤ 1 / 2 then\n F.eval x.1 ⟨2 * x.2, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.2.2.1, h⟩⟩\n else\n G.eval x.1\n ⟨2 * x.2 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.2.2.2⟩⟩ :=\n show ite _ _ _ = _ by split_ifs <;> exact Path.extend_apply _ _\n\ntheorem hcomp_half (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (t : I) :\n F.hcomp G (t, ⟨1 / 2, by norm_num, by norm_num⟩) = x₁ :=\n show ite _ _ _ = _ by norm_num\n\nend\n\n/--\nSuppose `p` is a path, then we have a homotopy from `p` to `p.reparam f` by the convexity of `I`.\n-/\ndef reparam (p : Path x₀ x₁) (f : I → I) (hf : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) :\n Homotopy p (p.reparam f hf hf₀ hf₁) where\n toFun x := p ⟨σ x.1 * x.2 + x.1 * f x.2,\n show (σ x.1 : ℝ) • (x.2 : ℝ) + (x.1 : ℝ) • (f x.2 : ℝ) ∈ I from\n convex_Icc _ _ x.2.2 (f x.2).2 (by unit_interval) (by unit_interval) (by simp)⟩\n map_zero_left x := by norm_num\n map_one_left x := by norm_num\n prop' t x hx := by\n rcases hx with hx | hx\n · rw [hx]\n simp [hf₀]\n · rw [Set.mem_singleton_iff] at hx\n rw [hx]\n simp [hf₁]\n continuous_toFun := by fun_prop\n\n/-- Suppose `F : Homotopy p q`. Then we have a `Homotopy p.symm q.symm` by reversing the second\nargument.\n-/\n@[simps]\ndef symm₂ {p q : Path x₀ x₁} (F : p.Homotopy q) : p.symm.Homotopy q.symm where\n toFun x := F ⟨x.1, σ x.2⟩\n map_zero_left := by simp [Path.symm]\n map_one_left := by simp [Path.symm]\n prop' t x hx := by\n rcases hx with hx | hx\n · rw [hx]\n simp\n · rw [Set.mem_singleton_iff] at hx\n rw [hx]\n simp\n\n/--\nGiven `F : Homotopy p q`, and `f : C(X, Y)`, we can define a homotopy from `p.map f.continuous` to\n`q.map f.continuous`.\n-/\n@[simps]\ndef map {p q : Path x₀ x₁} (F : p.Homotopy q) (f : C(X, Y)) :\n Homotopy (p.map f.continuous) (q.map f.continuous) where\n toFun := f ∘ F\n map_zero_left := by simp\n map_one_left := by simp\n prop' t x hx := by\n rcases hx with hx | hx\n · simp [hx]\n · rw [Set.mem_singleton_iff] at hx\n simp [hx]\n\nend Homotopy\n\n/-- Two paths `p₀` and `p₁` are `Path.Homotopic` if there exists a `Homotopy` between them.\n-/\ndef Homotopic (p₀ p₁ : Path x₀ x₁) : Prop :=\n Nonempty (p₀.Homotopy p₁)\n\nnamespace Homotopic\n\n@[refl]\ntheorem refl (p : Path x₀ x₁) : p.Homotopic p :=\n ⟨Homotopy.refl p⟩\n\n@[symm]\ntheorem symm ⦃p₀ p₁ : Path x₀ x₁⦄ (h : p₀.Homotopic p₁) : p₁.Homotopic p₀ :=\n h.map Homotopy.symm\n\ntheorem symm₂ {p q : Path x₀ x₁} (h : p.Homotopic q) : p.symm.Homotopic q.symm :=\n h.map Homotopy.symm₂\n\n@[trans]\ntheorem trans ⦃p₀ p₁ p₂ : Path x₀ x₁⦄ (h₀ : p₀.Homotopic p₁) (h₁ : p₁.Homotopic p₂) :\n p₀.Homotopic p₂ :=\n h₀.map2 Homotopy.trans h₁\n\ntheorem equivalence : Equivalence (@Homotopic X _ x₀ x₁) :=\n ⟨refl, (symm ·), (trans · ·)⟩\n\ninstance : IsEquiv (Path x₀ x₁) Homotopic where\n refl := refl\n symm := symm\n trans := trans\n\nnonrec theorem map {p q : Path x₀ x₁} (h : p.Homotopic q) (f : C(X, Y)) :\n Homotopic (p.map f.continuous) (q.map f.continuous) :=\n h.map fun F => F.map f\n\ntheorem hcomp {p₀ p₁ : Path x₀ x₁} {q₀ q₁ : Path x₁ x₂} (hp : p₀.Homotopic p₁)\n (hq : q₀.Homotopic q₁) : (p₀.trans q₀).Homotopic (p₁.trans q₁) :=\n hp.map2 Homotopy.hcomp hq\n\n/-- If paths `p` and `q` are homotopic as paths `x ⟶ y`,\nthen they are homotopic as paths `x' ⟶ y'`, where `x' = x` and `y' = y`. -/\ntheorem pathCast {p q : Path x₀ x₁} (hpq : p.Homotopic q) (hsource : x₂ = x₀) (htarget : x₃ = x₁) :\n (p.cast hsource htarget).Homotopic (q.cast hsource htarget) :=\n hpq\n\n/--\nThe setoid on `Path`s defined by the equivalence relation `Path.Homotopic`. That is, two paths are\nequivalent if there is a `Homotopy` between them.\n-/\n@[instance_reducible]\nprotected def setoid (x₀ x₁ : X) : Setoid (Path x₀ x₁) :=\n ⟨Homotopic, equivalence⟩\n\n/-- The quotient on `Path x₀ x₁` by the equivalence relation `Path.Homotopic`.\n-/\nprotected def Quotient (x₀ x₁ : X) :=\n Quotient (Homotopic.setoid x₀ x₁)\n\nattribute [local instance] Homotopic.setoid\n\ninstance : Inhabited (Homotopic.Quotient () ()) :=\n ⟨Quotient.mk' <| Path.refl ()⟩\n\nnamespace Quotient\n\n/-- The canonical map from `Path x₀ x₁` to `Path.Homotopic.Quotient x₀ x₁`. -/\ndef mk (p : Path x₀ x₁) : Path.Homotopic.Quotient x₀ x₁ :=\n Quotient.mk' p\n\ntheorem mk_surjective : Function.Surjective (@mk X _ x₀ x₁) :=\n Quotient.mk'_surjective\n\n/-- `Path.Homotopic.Quotient.mk` is the simp normal form. -/\n@[simp] theorem mk'_eq_mk (p : Path x₀ x₁) : Quotient.mk' p = mk p := rfl\n@[simp] theorem mk''_eq_mk (p : Path x₀ x₁) : Quotient.mk'' p = mk p := rfl\n\nTarget:\ntheorem exact {p q : Path x₀ x₁} (h : Quotient.mk p = Quotient.mk q) :\n Homotopic p q :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"36840fef51c1cb27470777b32dc4fdd3c54348dcfcadda0b5c8c4b45081678f4","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Homotopy","family_id":"exact","file_id":"mathlib/Mathlib/Topology/Homotopy/Path.lean","sample_id":"ec4f96f91a09dbf29e1f7b52148becbb79f68ade3baa7edeb9ce6bbae0b8528a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"01079e9ab62b24ad092f4002968409b301457dea6b33d77faa44a19222419aff","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"74ad69d06c197527d7c00c4fd3dff023e710c362b7d895ddcb9f119a35d037be","source_sha256":"bdfd7123efa6932f7f417fb21d899a1972d4f19df96a39961e46ce27a071ef94","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [equivariantProjection, smul_apply, sumOfConjugatesEquivariant_apply,\n Fintype.card_eq_nat_card]","hard_negative":false,"metrics":{"chosen_tokens":14,"rejected_tokens":3,"token_jaccard":0.071429,"token_length_ratio":0.214286},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"35f894a26fe61745c1dfa12867e71b937db3b89e8f1315703b705a81e257745f","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TypeTags.Finite\npublic import Mathlib.Algebra.MonoidAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Basis.VectorSpace\npublic import Mathlib.RingTheory.SimpleModule.Basic\npublic import Mathlib.RepresentationTheory.Semisimple\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# Maschke's theorem\n\nWe prove **Maschke's theorem** for finite groups,\nin the formulation that every submodule of a `k[G]` module has a complement,\nwhen `k` is a field with `Fintype.card G` invertible in `k`.\n\nWe do the core computation in greater generality.\nFor any commutative ring `k` in which `Fintype.card G` is invertible,\nand a `k[G]`-linear map `i : V → W` which admits a `k`-linear retraction `π`,\nwe produce a `k[G]`-linear retraction by\ntaking the average over `G` of the conjugates of `π`.\n\n## Implementation Notes\n\n* These results assume `IsUnit (Fintype.card G : k)` which is equivalent to the more\n familiar `¬(ringChar k ∣ Fintype.card G)`.\n\n## Future work\nIt's not so far to give the usual statement, that every finite-dimensional representation\nof a finite group is semisimple (i.e. a direct sum of irreducibles).\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Module MonoidAlgebra\nopen scoped Ring\n\n/-!\nWe now do the key calculation in Maschke's theorem.\n\nGiven `V → W`, an inclusion of `k[G]` modules,\nassume we have some retraction `π` (i.e. `∀ v, π (i v) = v`),\njust as a `k`-linear map.\n(When `k` is a field, this will be available cheaply, by choosing a basis.)\n\nWe now construct a retraction of the inclusion as a `k[G]`-linear map,\nby the formula\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\n\nnamespace LinearMap\n\n\n-- At first we work with any `[CommRing k]`, and add the assumption that\n-- `IsUnit (Fintype.card G : k)` when it is required.\nvariable {k : Type*} [CommRing k] {G : Type*} [Group G]\nvariable {V : Type*} [AddCommGroup V] [Module k V] [Module k[G] V] [IsScalarTower k k[G] V]\nvariable {W : Type*} [AddCommGroup W] [Module k W] [Module k[G] W] [IsScalarTower k k[G] W]\nvariable (π : W →ₗ[k] V)\n\n/-- We define the conjugate of `π` by `g`, as a `k`-linear map. -/\ndef conjugate (g : G) : W →ₗ[k] V :=\n GroupSMul.linearMap k V g⁻¹ ∘ₗ π ∘ₗ GroupSMul.linearMap k W g\n\ntheorem conjugate_apply (g : G) (v : W) :\n π.conjugate g v = MonoidAlgebra.single g⁻¹ (1 : k) • π (MonoidAlgebra.single g (1 : k) • v) :=\n rfl\n\nvariable (i : V →ₗ[k[G]] W)\n\nsection\n\ntheorem conjugate_i (h : ∀ v : V, π (i v) = v) (g : G) (v : V) :\n (conjugate π g : W → V) (i v) = v := by\n rw [conjugate_apply, ← i.map_smul, h, ← mul_smul, single_mul_single, mul_one, inv_mul_cancel,\n ← one_def, one_smul]\n\nend\n\nvariable (G) [Fintype G]\n\n/-- The sum of the conjugates of `π` by each element `g : G`, as a `k`-linear map.\n\n(We postpone dividing by the size of the group as long as possible.)\n-/\ndef sumOfConjugates : W →ₗ[k] V :=\n ∑ g : G, π.conjugate g\n\nlemma sumOfConjugates_apply (v : W) : π.sumOfConjugates G v = ∑ g : G, π.conjugate g v :=\n LinearMap.sum_apply _ _ _\n\n/-- In fact, the sum over `g : G` of the conjugate of `π` by `g` is a `k[G]`-linear map.\n-/\ndef sumOfConjugatesEquivariant : W →ₗ[k[G]] V :=\n MonoidAlgebra.equivariantOfLinearOfComm (π.sumOfConjugates G) fun g v => by\n simp only [sumOfConjugates_apply, Finset.smul_sum, conjugate_apply]\n refine Fintype.sum_bijective (· * g) (Group.mulRight_bijective g) _ _ fun i ↦ ?_\n simp only [smul_smul, single_mul_single, mul_inv_rev, mul_inv_cancel_left, one_mul]\n\ntheorem sumOfConjugatesEquivariant_apply (v : W) :\n π.sumOfConjugatesEquivariant G v = ∑ g : G, π.conjugate g v :=\n π.sumOfConjugates_apply G v\n\nsection\n\n/-- We construct our `k[G]`-linear retraction of `i` as\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\ndef equivariantProjection : W →ₗ[k[G]] V :=\n (Fintype.card G : k)⁻¹ʳ • π.sumOfConjugatesEquivariant G\n\nTarget:\ntheorem equivariantProjection_apply (v : W) :\n π.equivariantProjection G v = (Nat.card G : k)⁻¹ʳ • ∑ g : G, π.conjugate g v :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory","family_id":"equivariantprojection_apply","file_id":"mathlib/Mathlib/RepresentationTheory/Maschke.lean","sample_id":"74ad69d06c197527d7c00c4fd3dff023e710c362b7d895ddcb9f119a35d037be"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"155002d614e8c731a4ef806fe01f4e1723729cd9b4f323dba5e3df259c1644a1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff1309a891d7188d1fd6da1d56afb597567ed65d35e9646075f9497d1d36a578","source_sha256":"2ff452ff2d90e79f08d7edf4d71dd7e384aea8e09470d3f1230302b0e21e8153","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : (fun s : Set α => ⨆ _ : s.Nonempty, m s) = m := by\n ext1 t\n rcases t.eq_empty_or_nonempty with h | h <;> simp [h, Set.not_nonempty_empty, m_empty]\n simp [boundedBy, this]","hard_negative":false,"metrics":{"chosen_tokens":53,"rejected_tokens":3,"token_jaccard":0.027027,"token_length_ratio":0.056604},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"36ccc11b85bed630499d1dcf042e4502d3d58a04a1b559a5475271f804cc5bd5","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.OuterMeasure.Operations\npublic import Mathlib.Analysis.SpecificLimits.Basic\n\nNamespace:\nMeasureTheory.OuterMeasure\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Outer measures from functions\n\nGiven an arbitrary function `m : Set α → ℝ≥0∞` that sends `∅` to `0` we can define an outer\nmeasure on `α` that on `s` is defined to be the infimum of `∑ᵢ, m (sᵢ)` for all collections of sets\n`sᵢ` that cover `s`. This is the unique maximal outer measure that is at most the given function.\n\nGiven an outer measure `m`, the Carathéodory-measurable sets are the sets `s` such that\nfor all sets `t` we have `m t = m (t ∩ s) + m (t \\ s)`. This forms a measurable space.\n\n## Main definitions and statements\n\n* `OuterMeasure.boundedBy` is the greatest outer measure that is at most the given function.\n If you know that the given function sends `∅` to `0`, then `OuterMeasure.ofFunction` is a\n special case.\n* `sInf_eq_boundedBy_sInfGen` is a characterization of the infimum of outer measures.\n\n## References\n\n* \n* \n\n## Tags\n\nouter measure, Carathéodory-measurable, Carathéodory's criterion\n\n-/\n\n@[expose] public section\n\nassert_not_exists Module.Basis\n\nnoncomputable section\n\nopen Set Function Filter\nopen scoped NNReal Topology ENNReal\n\nnamespace MeasureTheory\nnamespace OuterMeasure\n\nsection OfFunction\n\nvariable {α : Type*}\n\n/-- Given any function `m` assigning measures to sets satisfying `m ∅ = 0`, there is\n a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/\nprotected def ofFunction (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0) : OuterMeasure α :=\n let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)\n { measureOf := μ\n empty := by\n rw [← nonpos_iff_eq_zero]\n exact (iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simpa\n mono := fun {_ _} hs => iInf_mono fun _ => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩\n iUnion_nat := fun s _ =>\n ENNReal.le_of_forall_pos_le_add <| by\n intro ε hε (hb : (∑' i, μ (s i)) < ∞)\n rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩\n grw [← hl]\n rw [← ENNReal.tsum_add]\n choose f hf using\n show ∀ i, ∃ f : ℕ → Set α, (s i ⊆ ⋃ i, f i) ∧ (∑' i, m (f i)) < μ (s i) + ε' i by\n intro i\n have : μ (s i) < μ (s i) + ε' i :=\n ENNReal.lt_add_right (ne_top_of_le_ne_top hb.ne <| ENNReal.le_tsum _)\n (by simpa using (hε' i).ne')\n rcases iInf_lt_iff.mp this with ⟨t, ht⟩\n exists t\n contrapose! ht\n exact le_iInf ht\n refine le_trans ?_ (ENNReal.tsum_le_tsum fun i => le_of_lt (hf i).2)\n rw [← ENNReal.tsum_prod, ← Nat.pairEquiv.symm.tsum_eq]\n refine iInf_le_of_le _ (iInf_le _ ?_)\n apply iUnion_subset\n intro i\n apply Subset.trans (hf i).1\n apply iUnion_subset\n simp only [Nat.pairEquiv_symm_apply]\n rw [iUnion_unpair]\n intro j\n apply subset_iUnion₂ i }\n\nvariable (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0)\n\n/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets\n`tᵢ` that cover `s`. -/\ntheorem ofFunction_apply (s : Set α) :\n OuterMeasure.ofFunction m m_empty s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, m (t n) :=\n rfl\n\n/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets\n`tᵢ` that cover `s`, with all `tᵢ` satisfying a predicate `P` such that `m` is infinite for sets\nthat don't satisfy `P`.\nThis is similar to `ofFunction_apply`, except that the sets `tᵢ` satisfy `P`.\nThe hypothesis `m_top` applies in particular to a function of the form `extend m'`. -/\ntheorem ofFunction_eq_iInf_mem {P : Set α → Prop} (m_top : ∀ s, ¬ P s → m s = ∞) (s : Set α) :\n OuterMeasure.ofFunction m m_empty s =\n ⨅ (t : ℕ → Set α) (_ : ∀ i, P (t i)) (_ : s ⊆ ⋃ i, t i), ∑' i, m (t i) := by\n rw [OuterMeasure.ofFunction_apply]\n apply le_antisymm\n · exact le_iInf fun t ↦ le_iInf fun _ ↦ le_iInf fun h ↦ iInf₂_le _ (by exact h)\n · simp_rw [le_iInf_iff]\n refine fun t ht_subset ↦ iInf_le_of_le t ?_\n by_cases ht : ∀ i, P (t i)\n · exact iInf_le_of_le ht (iInf_le_of_le ht_subset le_rfl)\n · simp only [ht, not_false_eq_true, iInf_neg, top_le_iff]\n push Not at ht\n obtain ⟨i, hti_notMem⟩ := ht\n have hfi_top : m (t i) = ∞ := m_top _ hti_notMem\n exact ENNReal.tsum_eq_top_of_eq_top ⟨i, hfi_top⟩\n\nvariable {m m_empty}\n\ntheorem ofFunction_le (s : Set α) : OuterMeasure.ofFunction m m_empty s ≤ m s :=\n let f : ℕ → Set α := fun i => Nat.casesOn i s fun _ => ∅\n iInf_le_of_le f <|\n iInf_le_of_le (subset_iUnion f 0) <|\n le_of_eq <| tsum_eq_single 0 <| by\n rintro (_ | i)\n · simp\n · simp [f, m_empty]\n\ntheorem ofFunction_eq (s : Set α) (m_mono : ∀ ⦃t : Set α⦄, s ⊆ t → m s ≤ m t)\n (m_subadd : ∀ s : ℕ → Set α, m (⋃ i, s i) ≤ ∑' i, m (s i)) :\n OuterMeasure.ofFunction m m_empty s = m s :=\n le_antisymm (ofFunction_le s) <|\n le_iInf fun f => le_iInf fun hf => le_trans (m_mono hf) (m_subadd f)\n\ntheorem le_ofFunction {μ : OuterMeasure α} :\n μ ≤ OuterMeasure.ofFunction m m_empty ↔ ∀ s, μ s ≤ m s :=\n ⟨fun H s => le_trans (H s) (ofFunction_le s), fun H _ =>\n le_iInf fun f =>\n le_iInf fun hs =>\n le_trans (μ.mono hs) <| le_trans (measure_iUnion_le f) <| ENNReal.tsum_le_tsum fun _ => H _⟩\n\ntheorem isGreatest_ofFunction :\n IsGreatest { μ : OuterMeasure α | ∀ s, μ s ≤ m s } (OuterMeasure.ofFunction m m_empty) :=\n ⟨fun _ => ofFunction_le _, fun _ => le_ofFunction.2⟩\n\ntheorem ofFunction_eq_sSup : OuterMeasure.ofFunction m m_empty = sSup { μ | ∀ s, μ s ≤ m s } :=\n (@isGreatest_ofFunction α m m_empty).isLUB.sSup_eq.symm\n\n/-- If `m u = ∞` for any set `u` that has nonempty intersection both with `s` and `t`, then\n`μ (s ∪ t) = μ s + μ t`, where `μ = MeasureTheory.OuterMeasure.ofFunction m m_empty`.\n\nE.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma\nimplies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s`\nand `y ∈ t`. -/\ntheorem ofFunction_union_of_top_of_nonempty_inter {s t : Set α}\n (h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) :\n OuterMeasure.ofFunction m m_empty (s ∪ t) =\n OuterMeasure.ofFunction m m_empty s + OuterMeasure.ofFunction m m_empty t := by\n refine le_antisymm (measure_union_le _ _) (le_iInf₂ fun f hf ↦ ?_)\n set μ := OuterMeasure.ofFunction m m_empty\n rcases Classical.em (∃ i, (s ∩ f i).Nonempty ∧ (t ∩ f i).Nonempty) with (⟨i, hs, ht⟩ | he)\n · calc\n μ s + μ t ≤ ∞ := le_top\n _ = m (f i) := (h (f i) hs ht).symm\n _ ≤ ∑' i, m (f i) := ENNReal.le_tsum i\n set I := fun s => { i : ℕ | (s ∩ f i).Nonempty }\n have hd : Disjoint (I s) (I t) := disjoint_iff_inf_le.mpr fun i hi => he ⟨i, hi⟩\n have hI : ∀ u ⊆ s ∪ t, μ u ≤ ∑' i : I u, μ (f i) := fun u hu =>\n calc\n μ u ≤ μ (⋃ i : I u, f i) :=\n μ.mono fun x hx =>\n let ⟨i, hi⟩ := mem_iUnion.1 (hf (hu hx))\n mem_iUnion.2 ⟨⟨i, ⟨x, hx, hi⟩⟩, hi⟩\n _ ≤ ∑' i : I u, μ (f i) := measure_iUnion_le _\n calc\n μ s + μ t ≤ (∑' i : I s, μ (f i)) + ∑' i : I t, μ (f i) :=\n add_le_add (hI _ subset_union_left) (hI _ subset_union_right)\n _ = ∑' i : ↑(I s ∪ I t), μ (f i) :=\n (ENNReal.summable.tsum_union_disjoint (f := fun i => μ (f i)) hd ENNReal.summable).symm\n _ ≤ ∑' i, μ (f i) :=\n (ENNReal.summable.tsum_le_tsum_of_inj (↑) Subtype.coe_injective (fun _ _ => zero_le)\n (fun _ => le_rfl) ENNReal.summable)\n _ ≤ ∑' i, m (f i) := ENNReal.tsum_le_tsum fun i => ofFunction_le _\n\ntheorem comap_ofFunction {β} (f : β → α) (h : Monotone m ∨ Surjective f) :\n comap f (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun s => m (f '' s)) (by simp; simp [m_empty]) := by\n refine le_antisymm (le_ofFunction.2 fun s => ?_) fun s => ?_\n · rw [comap_apply]\n apply ofFunction_le\n · rw [comap_apply, ofFunction_apply, ofFunction_apply]\n refine iInf_mono' fun t => ⟨fun k => f ⁻¹' t k, ?_⟩\n refine iInf_mono' fun ht => ?_\n rw [Set.image_subset_iff, preimage_iUnion] at ht\n refine ⟨ht, ENNReal.tsum_le_tsum fun n => ?_⟩\n rcases h with hl | hr\n exacts [hl (image_preimage_subset _ _), (congr_arg m (hr.image_preimage (t n))).le]\n\ntheorem map_ofFunction_le {β} (f : α → β) :\n map f (OuterMeasure.ofFunction m m_empty) ≤\n OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty :=\n le_ofFunction.2 fun s => by\n rw [map_apply]\n apply ofFunction_le\n\ntheorem map_ofFunction {β} {f : α → β} (hf : Injective f) :\n map f (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty := by\n refine (map_ofFunction_le _).antisymm fun s => ?_\n simp only [ofFunction_apply, map_apply, le_iInf_iff]\n intro t ht\n refine iInf_le_of_le (fun n => (range f)ᶜ ∪ f '' t n) (iInf_le_of_le ?_ ?_)\n · rw [← union_iUnion, ← inter_subset, ← image_preimage_eq_inter_range, ← image_iUnion]\n exact image_mono ht\n · refine ENNReal.tsum_le_tsum fun n => le_of_eq ?_\n simp [hf.preimage_image]\n\n-- TODO (kmill): change `m (t ∩ s)` to `m (s ∩ t)`\ntheorem restrict_ofFunction (s : Set α) (hm : Monotone m) :\n restrict s (OuterMeasure.ofFunction m m_empty) =\n OuterMeasure.ofFunction (fun t => m (t ∩ s)) (by simp; simp [m_empty]) := by\n rw [restrict]\n simp only [inter_comm _ s, LinearMap.comp_apply]\n rw [comap_ofFunction _ (Or.inl hm)]\n simp only [map_ofFunction Subtype.coe_injective, Subtype.image_preimage_coe]\n\ntheorem smul_ofFunction {c : ℝ≥0∞} (hc : c ≠ ∞) : c • OuterMeasure.ofFunction m m_empty =\n OuterMeasure.ofFunction (c • m) (by simp [m_empty]) := by\n ext1 s\n haveI : Nonempty { t : ℕ → Set α // s ⊆ ⋃ i, t i } := ⟨⟨fun _ => s, subset_iUnion (fun _ => s) 0⟩⟩\n simp only [smul_apply, ofFunction_apply, ENNReal.tsum_mul_left, Pi.smul_apply, smul_eq_mul,\n iInf_subtype']\n rw [ENNReal.mul_iInf fun h => (hc h).elim]\n\nend OfFunction\n\nsection BoundedBy\n\nvariable {α : Type*} (m : Set α → ℝ≥0∞)\n\n/-- Given any function `m` assigning measures to sets, there is a unique maximal outer measure `μ`\n satisfying `μ s ≤ m s` for all `s : Set α`. This is the same as `OuterMeasure.ofFunction`,\n except that it doesn't require `m ∅ = 0`. -/\ndef boundedBy : OuterMeasure α :=\n OuterMeasure.ofFunction (fun s => ⨆ _ : s.Nonempty, m s) (by simp [Set.not_nonempty_empty])\n\nvariable {m}\n\ntheorem boundedBy_le (s : Set α) : boundedBy m s ≤ m s :=\n (ofFunction_le _).trans iSup_const_le\n\nTarget:\ntheorem boundedBy_eq_ofFunction (m_empty : m ∅ = 0) (s : Set α) :\n boundedBy m s = OuterMeasure.ofFunction m m_empty s :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/OuterMeasure","family_id":"boundedby_eq_offunction","file_id":"mathlib/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean","sample_id":"ff1309a891d7188d1fd6da1d56afb597567ed65d35e9646075f9497d1d36a578"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a4afcfeafb65c35a791387820a78793ccb06aa6e4c9194772166334f528b1da6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"056a44affe05cb47a186359bc608380275906bdf4208d6218458bed1cdeb2556","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0ac1a3dd33839e1cdf5946d42abc39431d5fd65e074198696a3a18cf5b3bf239","source_sha256":"8c1834cbc470868957d2c382f59c5cbb2b41442470cd514155de91f952bc7a9f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨_, rfl⟩\n have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n))\n exact ⟨this, by simp⟩","hard_negative":true,"metrics":{"chosen_tokens":35,"rejected_tokens":3,"token_jaccard":0.086957,"token_length_ratio":0.085714},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"3748ea2cc98c71e907667fa53324c64d7b0524aeac28e541790876c63ef3806f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Rat.Cast.CharZero\npublic import Mathlib.Tactic.NormNum.Basic\n\nNamespace:\nMathlib.Meta.NormNum\n\nLocal context:\n/-\nCopyright (c) 2022 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\n/-!\n# `norm_num` plugins for `Rat.cast` and `⁻¹`.\n-/\n\npublic meta section\n\nvariable {u : Lean.Level}\n\nnamespace Mathlib.Meta.NormNum\n\nopen Lean.Meta Qq\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`. -/\ndef inferCharZeroOfRing {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :\n MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero ring\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`, if it exists. -/\ndef inferCharZeroOfRing? {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :\n MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`. -/\ndef inferCharZeroOfAddMonoidWithOne {α : Q(Type u)}\n (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero AddMonoidWithOne\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`, if it\nexists. -/\ndef inferCharZeroOfAddMonoidWithOne? {α : Q(Type u)}\n (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) :\n MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`. -/\ndef inferCharZeroOfDivisionRing {α : Q(Type u)}\n (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero division ring\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Divisionsemiring α`, if it\nexists. -/\ndef inferCharZeroOfDivisionSemiring? {α : Q(Type u)}\n (_i : Q(DivisionSemiring $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`, if it\nexists. -/\ndef inferCharZeroOfDivisionRing? {α : Q(Type u)}\n (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\ntheorem isRat_mkRat : {a na n : ℤ} → {b nb d : ℕ} → IsInt a na → IsNat b nb →\n IsRat (na / nb : ℚ) n d → IsRat (mkRat a b) n d\n | _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [Rat.mkRat_eq_div]; exact ⟨_, h⟩\n\ntheorem isNNRat_divNat : {a na n : ℕ} → {b nb d : ℕ} → IsNat a na → IsNat b nb →\n IsNNRat (na / nb : ℚ≥0) n d → IsNNRat (NNRat.divNat a b) n d\n | _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [NNRat.divNat_eq_div]; exact ⟨_, h⟩\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- The `norm_num` extension which identifies expressions of the form `mkRat a b`,\nsuch that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. -/\n@[norm_num mkRat _ _]\ndef evalMkRat : NormNumExt where eval {u α} (e : Q(ℚ)) : MetaM (Result e) := do\n let .app (.app (.const ``mkRat _) (a : Q(ℤ))) (b : Q(ℕ)) ← whnfR e | failure\n haveI' : $e =Q mkRat $a $b := ⟨⟩\n let ra ← derive a\n let some ⟨_, na, pa⟩ := ra.toInt (q(Int.instRing) : Q(Ring Int)) | failure\n let ⟨nb, pb⟩ ← deriveNat q($b) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let rab ← derive q($na / $nb : Rat)\n let ⟨q, n, d, p⟩ ← rab.toRat' q(Rat.instDivisionRing)\n return .isRat _ q n d q(isRat_mkRat $pa $pb $p)\n\n/-- The `norm_num` extension which identifies expressions of the form `NNRat.divNat a b`,\nsuch that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. -/\n@[norm_num NNRat.divNat _ _]\ndef evalNNRatDivNat : NormNumExt where eval {u α} (e : Q(ℚ≥0)) : MetaM (Result e) := do\n let .app (.app (.const ``NNRat.divNat _) (a : Q(ℕ))) (b : Q(ℕ)) ← whnfR e | failure\n haveI' : $e =Q NNRat.divNat $a $b := ⟨⟩\n let ra ← derive q($a)\n let ⟨na, pa⟩ ← deriveNat q($a) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let ⟨nb, pb⟩ ← deriveNat q($b) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let rab ← derive q($na / $nb : NNRat)\n let some ⟨q, n, d, p⟩ := rab.toNNRat' q(NNRat.instSemifield.toDivisionSemiring) | failure\n return .isNNRat _ q n d q(isNNRat_divNat $pa $pb $p)\n\ntheorem isNat_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℕ} →\n IsNat q n → IsNat (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isNat_nnratCast {R : Type*} [DivisionSemiring R] : {q : ℚ≥0} → {n : ℕ} →\n IsNat q n → IsNat (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isInt_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℤ} →\n IsInt q n → IsInt (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isNNRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℕ} → {d : ℕ} →\n IsNNRat q n d → IsNNRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\ntheorem isNNRat_nnratCast {R : Type*} [DivisionSemiring R] [CharZero R] : {q : ℚ≥0} → {n : ℕ} →\n {d : ℕ} → IsNNRat q n d → IsNNRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\ntheorem isRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℤ} → {d : ℕ} →\n IsRat q n d → IsRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\n/-- The `norm_num` extension which identifies an expression `RatCast.ratCast q` where `norm_num`\nrecognizes `q`, returning the cast of `q`. -/\n@[norm_num Rat.cast _, RatCast.ratCast _] def evalRatCast : NormNumExt where eval {u α} e := do\n let dα ← inferDivisionRing α\n let .app r (a : Q(ℚ)) ← whnfR e | failure\n guard <|← withNewMCtxDepth <| isDefEq r q(Rat.cast (K := $α))\n let r ← derive q($a)\n haveI' : $e =Q Rat.cast $a := ⟨⟩\n match r with\n | .isNat _ na pa =>\n assumeInstancesCommute\n return .isNat _ na q(isNat_ratCast $pa)\n | .isNegNat _ na pa =>\n assumeInstancesCommute\n return .isNegNat _ na q(isInt_ratCast $pa)\n | .isNNRat _ qa na da pa =>\n assumeInstancesCommute\n let i ← inferCharZeroOfDivisionRing dα\n return .isNNRat q(inferInstance) qa na da q(isNNRat_ratCast $pa)\n | .isNegNNRat _ qa na da pa =>\n assumeInstancesCommute\n let i ← inferCharZeroOfDivisionRing dα\n return .isNegNNRat dα qa na da q(isRat_ratCast $pa)\n | _ => failure\n\n/-- The `norm_num` extension which identifies an expression `NNRat.cast q` where `norm_num`\nrecognizes `q`, returning the cast of `q`. -/\n@[norm_num NNRat.cast _, NNRatCast.nnratCast _]\ndef evalNNRatCast : NormNumExt where eval {u α} e := do\n let dα ← inferDivisionSemiring α\n let ~q(@NNRat.cast _ $dα' $a) := e | failure\n guard <| ← matchesInstance dα' q(@DivisionSemiring.toNNRatCast _ $dα)\n match ← derive q($a) with\n | .isNat _ na pa =>\n assumeInstancesCommute\n return .isNat _ na q(isNat_nnratCast $pa)\n | .isNNRat _ qa na da pa =>\n assumeInstancesCommute\n let some _ ← inferCharZeroOfDivisionSemiring? dα | failure\n return .isNNRat q(inferInstance) qa na da q(isNNRat_nnratCast $pa)\n | _ => failure\n\nTarget:\ntheorem isNNRat_inv_pos {α} [DivisionSemiring α] [CharZero α] {a : α} {n d : ℕ} :\n IsNNRat a (Nat.succ n) d → IsNNRat a⁻¹ d (Nat.succ n) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_0ac1a3dd3383","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"cb0667f0153c91ee1750864cea614445b484b9a7f626c0fde8a33412d234c282","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/NormNum","family_id":"isnnrat_inv_pos","file_id":"mathlib/Mathlib/Tactic/NormNum/Inv.lean","sample_id":"0ac1a3dd33839e1cdf5946d42abc39431d5fd65e074198696a3a18cf5b3bf239"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0fc725d5dcd81120698ac855465cd02f9ea230705aced56562338bc198bfb1db","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf84818bad60b740e5413a27332cd137949ed179c618a42f3b9b61cefa96c51a","source_sha256":"a7fe36236e2ed09f5c9d6f891e25635e8949de49ab4080f1346dbb2cc7d33457","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext\n simp","hard_negative":false,"metrics":{"chosen_tokens":3,"rejected_tokens":2,"token_jaccard":0.25,"token_length_ratio":0.666667},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"3854a52ddedf5a2db8190febd6c8e8a682733471f90a90fb4ee85185d5924398","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.Module.End\npublic import Mathlib.GroupTheory.FreeAbelianGroup\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n\nIn this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`.\nWe use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`.\n\n## Main declarations\n\n- `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n- `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X`\n- `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X`\n-/\n\n@[expose] public section\n\nassert_not_exists Cardinal Module.Basis\n\nnoncomputable section\n\nvariable {X : Type*}\n\n/-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/\ndef FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ :=\n FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ)\n\n/-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/\ndef Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X :=\n Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x)\n\n@[simp] lemma FreeAbelianGroup.toFinsupp_of (x : X) : toFinsupp (of x) = .single x 1 := by\n simp [toFinsupp]\n\n@[simp] lemma Finsupp.toFreeAbelianGroup_single (x : X) (n : ℤ) :\n toFreeAbelianGroup (single x n) = n • .of x := by simp [toFreeAbelianGroup]\n\nopen Finsupp FreeAbelianGroup\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) :\n Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) =\n (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) :=\n AddMonoidHom.ext <| toFreeAbelianGroup_single _\n\n@[simp]\n\nTarget:\ntheorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup :\n toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAbelianGroup","family_id":"freeabeliangroup","file_id":"mathlib/Mathlib/Algebra/FreeAbelianGroup/Finsupp.lean","sample_id":"cf84818bad60b740e5413a27332cd137949ed179c618a42f3b9b61cefa96c51a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8a12836c9b440860e51cc07ca0fc539df9b6adb2f57bdb7930f62da8346e7681","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"edc2135002541915231c0224ca364c3d0a60b89c6b08437b7d0942c0e460c2ff","source_sha256":"7b261493fb95075ca2d1b5990fccb0ceaaa4dbde63a52fb2337aa202b5b048ff","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply (iSup₂_le _).antisymm ((one_le_netMaxcard_iff T F U 0).2 h)\n intro s ⟨_, s_net⟩\n simp only [ball, dynEntourage_zero, preimage_univ] at s_net\n norm_cast\n refine Finset.card_le_one.2 fun x x_s y y_s ↦ ?_\n exact PairwiseDisjoint.elim_set s_net x_s y_s x (mem_univ x) (mem_univ x)","hard_negative":false,"metrics":{"chosen_tokens":71,"rejected_tokens":2,"token_jaccard":0.043478,"token_length_ratio":0.028169},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"395333d3c11ffd6358bcb592cc683790e816a244f3429ce7a0cc354ddfb27edf","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.TopologicalEntropy.CoverEntropy\n\nNamespace:\nDynamics\n\nLocal context:\n/-\nCopyright (c) 2024 Damien Thomine. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damien Thomine, Pietro Monticone\n-/\n/-!\n# Topological entropy via nets\nWe implement Bowen-Dinaburg's definitions of the topological entropy, via nets.\n\nThe major design decisions are the same as in\n`Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean`, and are explained in detail there:\nuse of uniform spaces, definition of the topological entropy of a subset, and values taken in\n`EReal`.\n\nGiven a map `T : X → X` and a subset `F ⊆ X`, the topological entropy is loosely defined using\nnets as the exponential growth (in `n`) of the number of distinguishable orbits of length `n`\nstarting from `F`. More precisely, given an entourage `U`, two orbits of length `n` can be\ndistinguished if there exists some index `k < n` such that `T^[k] x` and `T^[k] y` are far enough\n(i.e. `(T^[k] x, T^[k] y)` is not in `U`). The maximal number of distinguishable orbits of\nlength `n` is `netMaxcard T F U n`, and its exponential growth `netEntropyEntourage T F U`. This\nquantity increases when `U` decreases, and a definition of the topological entropy is\n`⨆ U ∈ 𝓤 X, netEntropyInfEntourage T F U`.\n\nThe definition of topological entropy using nets coincides with the definition using covers.\nInstead of defining a new notion of topological entropy, we prove that\n`coverEntropy` coincides with `⨆ U ∈ 𝓤 X, netEntropyEntourage T F U`.\n\n## Main definitions\n- `IsDynNetIn`: property that dynamical balls centered on a subset `s` of `F` are disjoint.\n- `netMaxcard`: maximal cardinality of a dynamical net. Takes values in `ℕ∞`.\n- `netEntropyInfEntourage`/`netEntropyEntourage`: exponential growth of `netMaxcard`. The former is\n defined with a `liminf`, the latter with a `limsup`. Take values in `EReal`.\n\n## Implementation notes\nAs when using covers, there are two competing definitions `netEntropyInfEntourage` and\n`netEntropyEntourage` in this file: one uses a `liminf`, the other a `limsup`. When using covers,\nwe chose the `limsup` definition as the default.\n\n## Main results\n- `coverEntropy_eq_iSup_netEntropyEntourage`: equality between the notions of topological entropy\n defined with covers and with nets. Has a variant for `coverEntropyInf`.\n\n## Tags\nnet, entropy\n\n## TODO\nGet versions of the topological entropy on (pseudo-e)metric spaces.\n-/\n\n@[expose] public section\n\nopen Set Uniformity UniformSpace\nopen scoped SetRel\n\nnamespace Dynamics\n\nvariable {X : Type*} {T : X → X} {U V : SetRel X X} {m n : ℕ} {F s : Set X} {x : X}\n\n/-! ### Dynamical nets -/\n\n/-- Given a subset `F`, an entourage `U` and an integer `n`, a subset `s` of `F` is a\n`(U, n)`-dynamical net of `F` if no two orbits of length `n` of points in `s` shadow each other. -/\ndef IsDynNetIn (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) (s : Set X) : Prop :=\n s ⊆ F ∧ s.PairwiseDisjoint fun x : X ↦ ball x (dynEntourage T U n)\n\nlemma IsDynNetIn.of_le (m_n : m ≤ n) (h : IsDynNetIn T F U m s) : IsDynNetIn T F U n s :=\n ⟨h.1, PairwiseDisjoint.mono h.2 fun x ↦ ball_mono (dynEntourage_antitone T U m_n) x⟩\n\nlemma IsDynNetIn.of_entourage_subset (U_V : U ⊆ V) (h : IsDynNetIn T F V n s) :\n IsDynNetIn T F U n s :=\n ⟨h.1, PairwiseDisjoint.mono h.2 fun x ↦ ball_mono (dynEntourage_monotone T n U_V) x⟩\n\nlemma isDynNetIn_empty : IsDynNetIn T F U n ∅ := ⟨empty_subset F, pairwise_empty _⟩\n\nlemma isDynNetIn_singleton (T : X → X) (U : SetRel X X) (n : ℕ) (h : x ∈ F) :\n IsDynNetIn T F U n {x} :=\n ⟨singleton_subset_iff.2 h, pairwise_singleton x _⟩\n\n/-- Given an entourage `U` and a time `n`, a dynamical net has a smaller cardinality than\n a dynamical cover. This lemma is the first of two key results to compare two versions of\n topological entropy: with cover and with nets, the second being `coverMincard_le_netMaxcard`. -/\nlemma IsDynNetIn.card_le_card_of_isDynCoverOf {s t : Finset X}\n (hs : IsDynNetIn T F U n s) (ht : IsDynCoverOf T F U n t) :\n s.card ≤ t.card := by\n have (x : X) (x_s : x ∈ s) : ∃ z ∈ t, z ∈ ball x (dynEntourage T U n) := by\n simpa using! ht (hs.1 x_s)\n choose! F s_t using this\n apply Finset.card_le_card_of_injOn F fun x x_s ↦ (s_t x x_s).1\n exact fun x x_s y y_s Fx_Fy ↦\n PairwiseDisjoint.elim_set hs.2 x_s y_s (F x) (s_t x x_s).2 (Fx_Fy ▸ (s_t y y_s).2)\n\n/-! ### Maximal cardinality of dynamical nets -/\n\n/-- The largest cardinality of a `(U, n)`-dynamical net of `F`. Takes values in `ℕ∞`, and is\ninfinite if and only if `F` admits nets of arbitrarily large size. -/\nnoncomputable def netMaxcard (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) : ℕ∞ :=\n ⨆ (s : Finset X) (_ : IsDynNetIn T F U n s), (s.card : ℕ∞)\n\nlemma IsDynNetIn.card_le_netMaxcard {s : Finset X} (h : IsDynNetIn T F U n s) :\n s.card ≤ netMaxcard T F U n :=\n le_iSup₂ (α := ℕ∞) s h\n\nlemma netMaxcard_monotone_time (T : X → X) (F : Set X) (U : SetRel X X) :\n Monotone fun n : ℕ ↦ netMaxcard T F U n :=\n fun _ _ m_n ↦ biSup_mono fun _ h ↦ h.of_le m_n\n\nlemma netMaxcard_antitone (T : X → X) (F : Set X) (n : ℕ) :\n Antitone fun U : SetRel X X ↦ netMaxcard T F U n :=\n fun _ _ U_V ↦ biSup_mono fun _ h ↦ h.of_entourage_subset U_V\n\nset_option backward.isDefEq.respectTransparency false in\nlemma netMaxcard_finite_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n netMaxcard T F U n < ⊤ ↔\n ∃ s : Finset X, IsDynNetIn T F U n s ∧ (s.card : ℕ∞) = netMaxcard T F U n := by\n apply Iff.intro <;> intro h\n · obtain ⟨k, k_max⟩ := WithTop.ne_top_iff_exists.1 h.ne\n rw [← k_max]\n simp only [ENat.some_eq_coe, Nat.cast_inj]\n -- The criterion we want to use is `Nat.sSup_mem`. We rewrite `netMaxcard` with an `sSup`,\n -- then check its `BddAbove` and `Nonempty` hypotheses.\n have : netMaxcard T F U n\n = sSup (WithTop.some '' Finset.card '' {s : Finset X | IsDynNetIn T F U n s}) := by\n rw [netMaxcard, ← image_comp, sSup_image]\n simp only [mem_setOf_eq, ENat.some_eq_coe, Function.comp_apply]\n rw [this] at k_max\n have h_bdda : BddAbove (Finset.card '' {s : Finset X | IsDynNetIn T F U n s}) := by\n refine ⟨k, mem_upperBounds.2 ?_⟩\n simp only [mem_image, mem_setOf_eq, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n intro s h\n rw [← WithTop.coe_le_coe, k_max]\n apply le_sSup\n simp only [ENat.some_eq_coe, mem_image, mem_setOf_eq, Nat.cast_inj, exists_eq_right]\n exact Filter.frequently_principal.mp fun a ↦ a h rfl\n have h_nemp : (Finset.card '' {s : Finset X | IsDynNetIn T F U n s}).Nonempty := by\n refine ⟨0, ?_⟩\n simp only [mem_image, mem_setOf_eq, Finset.card_eq_zero, exists_eq_right, Finset.coe_empty]\n exact isDynNetIn_empty\n rw [← WithTop.coe_sSup' h_bdda, ENat.some_eq_coe, Nat.cast_inj] at k_max\n have key := Nat.sSup_mem h_nemp h_bdda\n rw [← k_max, mem_image] at key\n simp only [mem_setOf_eq] at key\n exact key\n · obtain ⟨s, _, s_card⟩ := h\n rw [← s_card]\n exact WithTop.coe_lt_top s.card\n\n@[simp]\nlemma netMaxcard_empty : netMaxcard T ∅ U n = 0 := by\n rw [netMaxcard, ← bot_eq_zero, iSup₂_eq_bot]\n intro s s_net\n replace s_net := subset_empty_iff.1 s_net.1\n norm_cast at s_net\n rw [s_net, Finset.card_empty, CharP.cast_eq_zero, bot_eq_zero']\n\nlemma netMaxcard_eq_zero_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n netMaxcard T F U n = 0 ↔ F = ∅ := by\n refine ⟨fun h ↦ ?_, fun h ↦ by rw [h, netMaxcard_empty]⟩\n rw [eq_empty_iff_forall_notMem]\n intro x x_F\n have key := isDynNetIn_singleton T U n x_F\n rw [← Finset.coe_singleton] at key\n replace key := key.card_le_netMaxcard\n rw [Finset.card_singleton, Nat.cast_one, h] at key\n exact key.not_gt zero_lt_one\n\nlemma one_le_netMaxcard_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n 1 ≤ netMaxcard T F U n ↔ F.Nonempty := by\n rw [Order.one_le_iff_ne_zero, nonempty_iff_ne_empty]\n exact not_iff_not.2 (netMaxcard_eq_zero_iff T F U n)\n\nTarget:\nlemma netMaxcard_zero (T : X → X) (h : F.Nonempty) (U : SetRel X X) : netMaxcard T F U 0 = 1 :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/TopologicalEntropy","family_id":"netmaxcard_zero","file_id":"mathlib/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean","sample_id":"edc2135002541915231c0224ca364c3d0a60b89c6b08437b7d0942c0e460c2ff"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"021186df91df0216ba94186a36abd33fd1bfc10e88295c5baa9b3160e99602a6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"429778af4db70d39feb49b6e7b7edd4a27f7102f9ea8ed95f66c2687b1a4ab12","source_sha256":"ec72b205c7193e28bfc129d0a079e5a35f0db46566eba3abee8190af9187973c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [j, c₄_of_isShortNF_of_char_three]; simp","hard_negative":false,"metrics":{"chosen_tokens":11,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.272727},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"39ab39542bfc2a0c7b3932cfb568ad6a8524cbefbf35c4a36f704a6c298dbd1f","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange\npublic import Mathlib.Algebra.CharP.Defs\n\nNamespace:\nWeierstrassCurve\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n\n# Some normal forms of elliptic curves\n\nThis file defines some normal forms of Weierstrass equations of elliptic curves.\n\n## Main definitions and results\n\nThe following normal forms are in [silverman2009], section III.1, page 42.\n\n- `WeierstrassCurve.IsCharNeTwoNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₂X² + a₄X + a₆`. It is the normal form of characteristic ≠ 2.\n\n If 2 is invertible in the ring (for example, if it is a field of characteristic ≠ 2),\n then for any `WeierstrassCurve` there exists a change of variables which will change\n it into such normal form (`WeierstrassCurve.exists_variableChange_isCharNeTwoNF`).\n See also `WeierstrassCurve.toCharNeTwoNF` and `WeierstrassCurve.toCharNeTwoNF_spec`.\n\nThe following normal forms are in [silverman2009], Appendix A, Proposition 1.1.\n\n- `WeierstrassCurve.IsShortNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₄X + a₆`. It is the normal form of characteristic ≠ 2 or 3, and\n also the normal form of characteristic = 3 and j = 0.\n\n If 2 and 3 are invertible in the ring (for example, if it is a field of characteristic ≠ 2 or 3),\n then for any `WeierstrassCurve` there exists a change of variables which will change\n it into such normal form (`WeierstrassCurve.exists_variableChange_isShortNF`).\n See also `WeierstrassCurve.toShortNF` and `WeierstrassCurve.toShortNF_spec`.\n\n If the ring is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ = 0` (for an\n elliptic curve, this is equivalent to j = 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toShortNFOfCharThree`\n and `WeierstrassCurve.toShortNFOfCharThree_spec`).\n\n- `WeierstrassCurve.IsCharThreeJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₂X² + a₆`. It is the normal form of characteristic = 3 and j ≠ 0.\n\n If the field is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ ≠ 0` (for an\n elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharThreeNF`\n and `WeierstrassCurve.toCharThreeNF_spec_of_b₂_ne_zero`).\n\n- `WeierstrassCurve.IsCharThreeNF` is the combination of the above two, that is, asserts that\n a `WeierstrassCurve` is of form `Y² = X³ + a₂X² + a₆` or `Y² = X³ + a₄X + a₆`.\n It is the normal form of characteristic = 3.\n\n If the field is of characteristic = 3, then for any `WeierstrassCurve` there exists a change of\n variables which will change it into such normal form\n (`WeierstrassCurve.exists_variableChange_isCharThreeNF`).\n See also `WeierstrassCurve.toCharThreeNF` and `WeierstrassCurve.toCharThreeNF_spec`.\n\n- `WeierstrassCurve.IsCharTwoJEqZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2 and j = 0.\n\n If the ring is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ = 0` (for an\n elliptic curve, this is equivalent to j = 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharTwoJEqZeroNF`\n and `WeierstrassCurve.toCharTwoJEqZeroNF_spec`).\n\n- `WeierstrassCurve.IsCharTwoJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² + XY = X³ + a₂X² + a₆`. It is the normal form of characteristic = 2 and j ≠ 0.\n\n If the field is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ ≠ 0` (for an\n elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharTwoJNeZeroNF`\n and `WeierstrassCurve.toCharTwoJNeZeroNF_spec`).\n\n- `WeierstrassCurve.IsCharTwoNF` is the combination of the above two, that is, asserts that\n a `WeierstrassCurve` is of form `Y² + XY = X³ + a₂X² + a₆` or\n `Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2.\n\n If the field is of characteristic = 2, then for any `WeierstrassCurve` there exists a change of\n variables which will change it into such normal form\n (`WeierstrassCurve.exists_variableChange_isCharTwoNF`).\n See also `WeierstrassCurve.toCharTwoNF` and `WeierstrassCurve.toCharTwoNF_spec`.\n\n## References\n\n* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]\n\n## Tags\n\nelliptic curve, weierstrass equation, normal form\n\n-/\n\n@[expose] public section\n\nvariable {R : Type*} [CommRing R] {F : Type*} [Field F] (W : WeierstrassCurve R)\n\nnamespace WeierstrassCurve\n\n/-! ## Normal forms of characteristic ≠ 2 -/\n\n/-- A `WeierstrassCurve` is in normal form of characteristic ≠ 2, if its `a₁, a₃ = 0`.\nIn other words it is `Y² = X³ + a₂X² + a₄X + a₆`. -/\n@[mk_iff]\nclass IsCharNeTwoNF : Prop where\n a₁ : W.a₁ = 0\n a₃ : W.a₃ = 0\n\nsection Quantity\n\nvariable [W.IsCharNeTwoNF]\n\n@[simp]\ntheorem a₁_of_isCharNeTwoNF : W.a₁ = 0 := IsCharNeTwoNF.a₁\n\n@[simp]\ntheorem a₃_of_isCharNeTwoNF : W.a₃ = 0 := IsCharNeTwoNF.a₃\n\n@[simp]\ntheorem b₂_of_isCharNeTwoNF : W.b₂ = 4 * W.a₂ := by\n rw [b₂, a₁_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₄_of_isCharNeTwoNF : W.b₄ = 2 * W.a₄ := by\n rw [b₄, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₆_of_isCharNeTwoNF : W.b₆ = 4 * W.a₆ := by\n rw [b₆, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₈_of_isCharNeTwoNF : W.b₈ = 4 * W.a₂ * W.a₆ - W.a₄ ^ 2 := by\n rw [b₈, a₁_of_isCharNeTwoNF, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem c₄_of_isCharNeTwoNF : W.c₄ = 16 * W.a₂ ^ 2 - 48 * W.a₄ := by\n rw [c₄, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem c₆_of_isCharNeTwoNF : W.c₆ = -64 * W.a₂ ^ 3 + 288 * W.a₂ * W.a₄ - 864 * W.a₆ := by\n rw [c₆, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem Δ_of_isCharNeTwoNF : W.Δ = -64 * W.a₂ ^ 3 * W.a₆ + 16 * W.a₂ ^ 2 * W.a₄ ^ 2 - 64 * W.a₄ ^ 3\n - 432 * W.a₆ ^ 2 + 288 * W.a₂ * W.a₄ * W.a₆ := by\n rw [Δ, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF, b₈_of_isCharNeTwoNF]\n ring1\n\nend Quantity\n\nsection VariableChange\n\nvariable [Invertible (2 : R)]\n\n/-- There is an explicit change of variables of a `WeierstrassCurve` to\na normal form of characteristic ≠ 2, provided that 2 is invertible in the ring. -/\n@[simps]\ndef toCharNeTwoNF : VariableChange R := ⟨1, 0, ⅟2 * -W.a₁, ⅟2 * -W.a₃⟩\n\ninstance toCharNeTwoNF_spec : (W.toCharNeTwoNF • W).IsCharNeTwoNF := by\n constructor <;> simp [variableChange_a₁, variableChange_a₃]\n\ntheorem exists_variableChange_isCharNeTwoNF : ∃ C : VariableChange R, (C • W).IsCharNeTwoNF :=\n ⟨_, W.toCharNeTwoNF_spec⟩\n\nend VariableChange\n\n/-! ## Short normal form -/\n\n/-- A `WeierstrassCurve` is in short normal form, if its `a₁, a₂, a₃ = 0`.\nIn other words it is `Y² = X³ + a₄X + a₆`.\n\nThis is the normal form of characteristic ≠ 2 or 3, and\nalso the normal form of characteristic = 3 and j = 0. -/\n@[mk_iff]\nclass IsShortNF : Prop where\n a₁ : W.a₁ = 0\n a₂ : W.a₂ = 0\n a₃ : W.a₃ = 0\n\nsection Quantity\n\nvariable [W.IsShortNF]\n\ninstance isCharNeTwoNF_of_isShortNF : W.IsCharNeTwoNF := ⟨IsShortNF.a₁, IsShortNF.a₃⟩\n\ntheorem a₁_of_isShortNF : W.a₁ = 0 := IsShortNF.a₁\n\n@[simp]\ntheorem a₂_of_isShortNF : W.a₂ = 0 := IsShortNF.a₂\n\ntheorem a₃_of_isShortNF : W.a₃ = 0 := IsShortNF.a₃\n\ntheorem b₂_of_isShortNF : W.b₂ = 0 := by\n simp\n\ntheorem b₄_of_isShortNF : W.b₄ = 2 * W.a₄ := W.b₄_of_isCharNeTwoNF\n\ntheorem b₆_of_isShortNF : W.b₆ = 4 * W.a₆ := W.b₆_of_isCharNeTwoNF\n\ntheorem b₈_of_isShortNF : W.b₈ = -W.a₄ ^ 2 := by\n simp\n\ntheorem c₄_of_isShortNF : W.c₄ = -48 * W.a₄ := by\n simp\n\ntheorem c₆_of_isShortNF : W.c₆ = -864 * W.a₆ := by\n simp\n\ntheorem Δ_of_isShortNF : W.Δ = -16 * (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by\n rw [Δ_of_isCharNeTwoNF, a₂_of_isShortNF]\n ring1\n\nvariable [CharP R 3]\n\ntheorem b₄_of_isShortNF_of_char_three : W.b₄ = -W.a₄ := by\n rw [b₄_of_isShortNF]\n linear_combination W.a₄ * CharP.cast_eq_zero R 3\n\ntheorem b₆_of_isShortNF_of_char_three : W.b₆ = W.a₆ := by\n rw [b₆_of_isShortNF]\n linear_combination W.a₆ * CharP.cast_eq_zero R 3\n\ntheorem c₄_of_isShortNF_of_char_three : W.c₄ = 0 := by\n rw [c₄_of_isShortNF]\n linear_combination -16 * W.a₄ * CharP.cast_eq_zero R 3\n\ntheorem c₆_of_isShortNF_of_char_three : W.c₆ = 0 := by\n rw [c₆_of_isShortNF]\n linear_combination -288 * W.a₆ * CharP.cast_eq_zero R 3\n\ntheorem Δ_of_isShortNF_of_char_three : W.Δ = -W.a₄ ^ 3 := by\n rw [Δ_of_isShortNF]\n linear_combination (-21 * W.a₄ ^ 3 - 144 * W.a₆ ^ 2) * CharP.cast_eq_zero R 3\n\nvariable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsShortNF]\n\ntheorem j_of_isShortNF : W.j = 6912 * W.a₄ ^ 3 / (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by\n have h := W.Δ'.ne_zero\n rw [coe_Δ', Δ_of_isShortNF] at h\n rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',\n c₄_of_isShortNF, Δ_of_isShortNF, div_eq_div_iff h (right_ne_zero_of_mul h)]\n ring1\n\n@[simp]\n\nTarget:\ntheorem j_of_isShortNF_of_char_three [CharP F 3] : W.j = 0 :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/EllipticCurve","family_id":"j_of_isshortnf_of_char_three","file_id":"mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/NormalForms.lean","sample_id":"429778af4db70d39feb49b6e7b7edd4a27f7102f9ea8ed95f66c2687b1a4ab12"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"19b90f49104298bf55068ae2e350172a63e652de1da4ae129a2ba0d4e16ad9da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"daf414148db4dd1d48cb65f018368a912e17403bcef4ece6f2f5ba6e2af7a9b2","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"536eb9e8faf93f6440a7f3be49581c67d2ec61efdd731032fb0bc72a64cfe022","source_sha256":"8f6e1cc0d5e8bf0c658ed9049ca96f8833956a603531c0743e7d6a3cd38b05d8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n delta finsetIntegerMultiple commonDenom\n rw [Finset.coe_image]\n ext\n constructor\n · rintro ⟨_, ⟨x, -, rfl⟩, rfl⟩\n rw [map_integerMultiple]\n exact Set.mem_image_of_mem _ x.prop\n · rintro ⟨x, hx, rfl⟩\n exact ⟨_, ⟨⟨x, hx⟩, s.mem_attach _, rfl⟩, map_integerMultiple M s id _⟩","hard_negative":false,"metrics":{"chosen_tokens":73,"rejected_tokens":80,"token_jaccard":0.939394,"token_length_ratio":1.09589},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"3a0dda323e237cdfd0c88110a6ee60fd99628c85ed51ae371c6055d076dac6b1","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Pointwise.Set.Scalar\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.RingTheory.Localization.Defs\n\nNamespace:\nIsLocalization\n\nLocal context:\n/-\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-/\n/-!\n# Integer elements of a localization\n\n## Main definitions\n\n* `IsLocalization.IsInteger` is a predicate stating that `x : S` is in the image of `R`\n\n## Implementation notes\n\nSee `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.\n\n## Tags\nlocalization, ring localization, commutative ring localization, characteristic predicate,\ncommutative ring, field of fractions\n-/\n\n@[expose] public section\n\n\nvariable {R : Type*} [CommSemiring R] {M : Submonoid R} {S : Type*} [CommSemiring S]\nvariable [Algebra R S] {P : Type*} [CommSemiring P]\n\nopen Function\n\nnamespace IsLocalization\n\nsection\n\nvariable (R)\n\n-- TODO: define a subalgebra of `IsInteger`s\n/-- Given `a : S`, `S` a localization of `R`, `IsInteger R a` iff `a` is in the image of\nthe localization map from `R` to `S`. -/\ndef IsInteger (a : S) : Prop :=\n a ∈ (algebraMap R S).rangeS\n\nend\n\ntheorem isInteger_zero : IsInteger R (0 : S) :=\n Subsemiring.zero_mem _\n\ntheorem isInteger_one : IsInteger R (1 : S) :=\n Subsemiring.one_mem _\n\ntheorem isInteger_add {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a + b) :=\n Subsemiring.add_mem _ ha hb\n\ntheorem isInteger_mul {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a * b) :=\n Subsemiring.mul_mem _ ha hb\n\ntheorem isInteger_smul {a : R} {b : S} (hb : IsInteger R b) : IsInteger R (a • b) := by\n rcases hb with ⟨b', hb⟩\n use a * b'\n rw [← hb, (algebraMap R S).map_mul, Algebra.smul_def]\n\nvariable (M)\nvariable [IsLocalization M S]\n\n/-- Each element `a : S` has an `M`-multiple which is an integer.\n\nThis version multiplies `a` on the right, matching the argument order in `LocalizationMap.surj`.\n-/\ntheorem exists_integer_multiple' (a : S) : ∃ b : M, IsInteger R (a * algebraMap R S b) :=\n let ⟨⟨Num, denom⟩, h⟩ := IsLocalization.surj _ a\n ⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩\n\n/-- Each element `a : S` has an `M`-multiple which is an integer.\n\nThis version multiplies `a` on the left, matching the argument order in the `SMul` instance.\n-/\ntheorem exists_integer_multiple (a : S) : ∃ b : M, IsInteger R ((b : R) • a) := by\n simp_rw [Algebra.smul_def, mul_comm _ a]\n apply exists_integer_multiple'\n\n/-- We can clear the denominators of a `Finset`-indexed family of fractions. -/\ntheorem exist_integer_multiples {ι : Type*} (s : Finset ι) (f : ι → S) :\n ∃ b : M, ∀ i ∈ s, IsLocalization.IsInteger R ((b : R) • f i) := by\n haveI := Classical.propDecidable\n refine ⟨∏ i ∈ s, (sec M (f i)).2, fun i hi => ⟨?_, ?_⟩⟩\n · exact (∏ j ∈ s.erase i, (sec M (f j)).2) * (sec M (f i)).1\n rw [map_mul, sec_spec', ← mul_assoc, ← (algebraMap R S).map_mul, ← Algebra.smul_def]\n congr 2\n refine _root_.trans ?_ (map_prod (Submonoid.subtype M) _ _).symm\n rw [mul_comm, Submonoid.coe_finsetProd,\n -- Porting note: explicitly supplied `f`\n ← Finset.prod_insert (f := fun i => ((sec M (f i)).snd : R)) (s.notMem_erase i),\n Finset.insert_erase hi]\n rfl\n\n/-- We can clear the denominators of a finite indexed family of fractions. -/\ntheorem exist_integer_multiples_of_finite {ι : Type*} [Finite ι] (f : ι → S) :\n ∃ b : M, ∀ i, IsLocalization.IsInteger R ((b : R) • f i) := by\n cases nonempty_fintype ι\n obtain ⟨b, hb⟩ := exist_integer_multiples M Finset.univ f\n exact ⟨b, fun i => hb i (Finset.mem_univ _)⟩\n\n/-- We can clear the denominators of a finite set of fractions. -/\ntheorem exist_integer_multiples_of_finset (s : Finset S) :\n ∃ b : M, ∀ a ∈ s, IsInteger R ((b : R) • a) :=\n exist_integer_multiples M s id\n\n/-- A choice of a common multiple of the denominators of a `Finset`-indexed family of fractions. -/\nnoncomputable def commonDenom {ι : Type*} (s : Finset ι) (f : ι → S) : M :=\n (exist_integer_multiples M s f).choose\n\n/-- The numerator of a fraction after clearing the denominators\nof a `Finset`-indexed family of fractions. -/\nnoncomputable def integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) : R :=\n ((exist_integer_multiples M s f).choose_spec i i.prop).choose\n\n@[simp]\ntheorem map_integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) :\n algebraMap R S (integerMultiple M s f i) = commonDenom M s f • f i :=\n ((exist_integer_multiples M s f).choose_spec _ i.prop).choose_spec\n\n/-- A choice of a common multiple of the denominators of a finite set of fractions. -/\nnoncomputable def commonDenomOfFinset (s : Finset S) : M :=\n commonDenom M s id\n\n/-- The finset of numerators after clearing the denominators of a finite set of fractions. -/\nnoncomputable def finsetIntegerMultiple [DecidableEq R] (s : Finset S) : Finset R :=\n s.attach.image fun t => integerMultiple M s id t\n\nopen scoped Pointwise\n\nTarget:\ntheorem finsetIntegerMultiple_image [DecidableEq R] (s : Finset S) :\n algebraMap R S '' finsetIntegerMultiple M s = commonDenomOfFinset M s • (s : Set S) :=\n\nProof body:\n","rejected":"```lean\nby\n delta finsetIntegerMultiple commonDenom\n rw [Finset.coe_image]\n ext\n constructor\n · rintro ⟨_, ⟨x, -, rfl⟩, rfl⟩\n rw [map_integerMultiple]\n exact Set.mem_image_of_mem _ x.prop\n · rintro ⟨x, hx, rfl⟩\n exact ⟨_, ⟨⟨x, hx⟩, s.mem_attach _, rfl⟩, map_integerMultiple M s id _⟩\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Localization","family_id":"finsetintegermultiple_image","file_id":"mathlib/Mathlib/RingTheory/Localization/Integer.lean","sample_id":"536eb9e8faf93f6440a7f3be49581c67d2ec61efdd731032fb0bc72a64cfe022"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"85696dea5504cd1164ffc3684a5e36e714466d554e3b0ae16af94b2f33819e59","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2fb92bb72b20d250a56c163cb5794bffd6e862657504a1cf0db2b8138f0fc6f6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e3651abb98a9e4138a6fe48b841c7029c7c8d0f375ffa6c162d66151aae5632b","source_sha256":"4aa6d5f205e5da21fe6cb14e97e5791ceca9066a3371d5af97c468fa8d297973","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← smul_one_mul, mul_top']\n simp_rw [smul_eq_zero, or_iff_left one_ne_zero]","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.133333},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"3a3b5341dd283d579206deadbee585044f9f401217c0150b0ce41d31db5e5297","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.Torsion.Field\npublic import Mathlib.Algebra.Order.AddTorsor\npublic import Mathlib.Data.ENNReal.Operations\n\nNamespace:\nENNReal\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov\n-/\n/-!\n# Scalar multiplication on `ℝ≥0∞`.\n\nThis file defines basic scalar actions on extended nonnegative reals, showing that\n`MulAction`s, `DistribMulAction`s, `Module`s and `Algebra`s restrict from `ℝ≥0∞` to `ℝ≥0`.\n-/\n\n@[expose] public section\n\nopen Set NNReal ENNReal\n\nnamespace ENNReal\n\nvariable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}\n\n-- TODO: generalize some of these to `WithTop α`\nsection Actions\n\nnoncomputable instance {M : Type*} [MulAction ℝ≥0∞ M] : SMul ℝ≥0 M :=\n ⟨fun c m ↦ (c : ℝ≥0∞) • m⟩\n\n/-- A `MulAction` over `ℝ≥0∞` restricts to a `MulAction` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [MulAction ℝ≥0∞ M] : MulAction ℝ≥0 M :=\n fast_instance% MulAction.compHom M ofNNRealHom.toMonoidHom\n\ntheorem smul_def {M : Type*} [MulAction ℝ≥0∞ M] (c : ℝ≥0) (x : M) : c • x = (c : ℝ≥0∞) • x :=\n rfl\n\n@[simp]\ntheorem smul_one (c : ℝ≥0) : c • (1 : ℝ≥0∞) = (c : ℝ≥0∞) := by simp [smul_def]\n\ninstance {M N : Type*} [MulAction ℝ≥0∞ M] [MulAction ℝ≥0∞ N] [SMul M N] [IsScalarTower ℝ≥0∞ M N] :\n IsScalarTower ℝ≥0 M N where smul_assoc r := smul_assoc (r : ℝ≥0∞)\n\ninstance smulCommClass_left {M N : Type*} [MulAction ℝ≥0∞ N] [SMul M N] [SMulCommClass ℝ≥0∞ M N] :\n SMulCommClass ℝ≥0 M N where smul_comm r := smul_comm (r : ℝ≥0∞)\n\ninstance smulCommClass_right {M N : Type*} [MulAction ℝ≥0∞ N] [SMul M N] [SMulCommClass M ℝ≥0∞ N] :\n SMulCommClass M ℝ≥0 N where smul_comm m r := smul_comm m (r : ℝ≥0∞)\n\n/-- A `DistribMulAction` over `ℝ≥0∞` restricts to a `DistribMulAction` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [AddMonoid M] [DistribMulAction ℝ≥0∞ M] :\n DistribMulAction ℝ≥0 M :=\n fast_instance% DistribMulAction.compHom M ofNNRealHom.toMonoidHom\n\n/-- A `Module` over `ℝ≥0∞` restricts to a `Module` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [AddCommMonoid M] [Module ℝ≥0∞ M] : Module ℝ≥0 M :=\n fast_instance% Module.compHom M ofNNRealHom\n\n/-- An `Algebra` over `ℝ≥0∞` restricts to an `Algebra` over `ℝ≥0`. -/\nnoncomputable instance {A : Type*} [Semiring A] [Algebra ℝ≥0∞ A] : Algebra ℝ≥0 A where\n commutes' r x := by simp [Algebra.commutes]\n smul_def' r x := by simp [← Algebra.smul_def (r : ℝ≥0∞) x, smul_def]\n algebraMap := (algebraMap ℝ≥0∞ A).comp (ofNNRealHom : ℝ≥0 →+* ℝ≥0∞)\n\n-- verify that the above produces instances we might care about\nnoncomputable example : Algebra ℝ≥0 ℝ≥0∞ := inferInstance\n\nnoncomputable example : DistribMulAction ℝ≥0ˣ ℝ≥0∞ := inferInstance\n\ntheorem coe_smul {R} (r : R) (s : ℝ≥0) [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0]\n [IsScalarTower R ℝ≥0 ℝ≥0∞] : (↑(r • s) : ℝ≥0∞) = (r : R) • (s : ℝ≥0∞) := by\n rw [← smul_one_smul ℝ≥0 r (s : ℝ≥0∞), smul_def, smul_eq_mul, ← ENNReal.coe_mul, smul_mul_assoc,\n one_mul]\n\nTarget:\ntheorem smul_top {R : Type*} [Semiring R] [IsDomain R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]\n [Module.IsTorsionFree R ℝ≥0∞] [DecidableEq R] (c : R) :\n c • ∞ = if c = 0 then 0 else ∞ :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_e3651abb98a9","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"9459dd667f2942ac4fcb04e9d3c63752ff2b5016fdd618dfe5557902c8ef42d2","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/ENNReal","family_id":"smul_top","file_id":"mathlib/Mathlib/Data/ENNReal/Action.lean","sample_id":"e3651abb98a9e4138a6fe48b841c7029c7c8d0f375ffa6c162d66151aae5632b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3216557a3aff7a0388936ef882d87a370b33bad5f6db61e7be3c432b34ecca90","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cf5c4f9a80016c5a62b8baf04fc5dc0f22db22af5e6f316c23b4a9fd259106a0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8e0c0563df1280eaca460eabfa177c0aa9b5168635cf8293cca1d2c06361b3a0","source_sha256":"2a118611f2c24b41d1413bb14336c2f80a467287b119c0d8a05360e212cf41d2","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [fromNondegComplex, fullyFaithfulToKaroubi,\n cofan, IndexSet.id, IndexSet.e]","hard_negative":true,"metrics":{"chosen_tokens":17,"rejected_tokens":3,"token_jaccard":0.071429,"token_length_ratio":0.176471},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"3ad7ccf3ee6322efd3ce254f9b94f8ee903168a59334f593000219f012bd9663","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicTopology.DoldKan.Degeneracies\npublic import Mathlib.AlgebraicTopology.DoldKan.HomotopyEquivalence\npublic import Mathlib.AlgebraicTopology.SimplicialObject.Split\n\nNamespace:\nCategoryTheory.SimplicialObject.Splitting\n\nLocal context:\n/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n\n# Split simplicial objects in preadditive categories\n\nIn this file we define a functor `nondegComplex : SimplicialObject.Split C ⥤ ChainComplex C ℕ`\nwhen `C` is a preadditive category with finite coproducts, and get an isomorphism\n`toKaroubiNondegComplexFunctorIsoN₁ : nondegComplex ⋙ toKaroubi _ ≅ forget C ⋙ DoldKan.N₁`.\n\n(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)\n\n-/\n\n@[expose] public section\n\n\nnamespace CategoryTheory.SimplicialObject\n\nopen AlgebraicTopology Limits Category Preadditive Idempotents Opposite DoldKan Simplicial\n\nnamespace Splitting\n\nvariable {C : Type*} [Category* C] {X : SimplicialObject C}\n (s : Splitting X)\n\n/-- The projection on a summand of the coproduct decomposition given\nby a splitting of a simplicial object. -/\nnoncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :\n X.obj Δ ⟶ s.N A.1.unop.len :=\n s.desc Δ (fun B => by\n by_cases h : B = A\n · exact eqToHom (by subst h; rfl)\n · exact 0)\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :\n (s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by\n simp [πSummand]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ)\n (h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by\n dsimp [πSummand]\n rw [ι_desc, dif_neg h.symm]\n\nvariable [Preadditive C]\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem decomposition_id (Δ : SimplexCategoryᵒᵖ) :\n 𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by\n apply s.hom_ext'\n intro A\n dsimp\n erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc]\n · intro B _ h₂\n rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp]\n · simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) :\n X.σ i ≫ s.πSummand (IndexSet.id (op ⦋n + 1⦌)) = 0 := by\n apply s.hom_ext'\n intro A\n dsimp only [SimplicialObject.σ]\n rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op,\n cofan_inj_πSummand_eq_zero]\n rw [ne_comm]\n change ¬(A.epiComp (SimplexCategory.σ i).op).EqId\n rw [IndexSet.eqId_iff_len_eq]\n have h := SimplexCategory.len_le_of_epi A.e\n dsimp at h ⊢\n lia\n\nset_option backward.isDefEq.respectTransparency false in\n/-- If a simplicial object `X` in an additive category is split,\nthen `PInfty` vanishes on all the summands of `X _⦋n⦌` which do\nnot correspond to the identity of `⦋n⦌`. -/\ntheorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X)\n {n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op ⦋n⦌)) (hA : ¬A.EqId) :\n (s.cofan _).inj A ≫ PInfty.f n = 0 := by\n rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA\n rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem comp_PInfty_eq_zero_iff {Z : C} {n : ℕ} (f : Z ⟶ X _⦋n⦌) :\n f ≫ PInfty.f n = 0 ↔ f ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = 0 := by\n constructor\n · intro h\n rcases n with _ | n\n · dsimp at h\n rw [comp_id] at h\n rw [h, zero_comp]\n · have h' := f ≫= PInfty_f_add_QInfty_f (n + 1)\n dsimp at h'\n rw [comp_id, comp_add, h, zero_add] at h'\n rw [← h', assoc, QInfty_f, decomposition_Q, Preadditive.sum_comp, Preadditive.comp_sum,\n Finset.sum_eq_zero]\n intro i _\n simp only [assoc, σ_comp_πSummand_id_eq_zero, comp_zero]\n · intro h\n rw [← comp_id f, assoc, s.decomposition_id, Preadditive.sum_comp, Preadditive.comp_sum,\n Fintype.sum_eq_zero]\n intro A\n by_cases hA : A.EqId\n · dsimp at hA\n subst hA\n rw [assoc, reassoc_of% h, zero_comp]\n · simp only [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem PInfty_comp_πSummand_id (n : ℕ) :\n PInfty.f n ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = s.πSummand (IndexSet.id (op ⦋n⦌)) := by\n conv_rhs => rw [← id_comp (s.πSummand _)]\n symm\n rw [← sub_eq_zero, ← sub_comp, ← comp_PInfty_eq_zero_iff, sub_comp, id_comp, PInfty_f_idem,\n sub_self]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty (n : ℕ) :\n s.πSummand (IndexSet.id (op ⦋n⦌)) ≫ (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n =\n PInfty.f n := by\n conv_rhs => rw [← id_comp (PInfty.f n)]\n dsimp only [AlternatingFaceMapComplex.obj_X]\n rw [s.decomposition_id, Preadditive.sum_comp]\n rw [Fintype.sum_eq_single (IndexSet.id (op ⦋n⦌)), assoc]\n rintro A (hA : ¬A.EqId)\n rw [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]\n\n/-- The differentials `s.d i j : s.N i ⟶ s.N j` on nondegenerate simplices of a split\nsimplicial object are induced by the differentials on the alternating face map complex. -/\n@[simp]\nnoncomputable def d (i j : ℕ) : s.N i ⟶ s.N j :=\n (s.cofan _).inj (IndexSet.id (op ⦋i⦌)) ≫ K[X].d i j ≫ s.πSummand (IndexSet.id (op ⦋j⦌))\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem ιSummand_comp_d_comp_πSummand_eq_zero (j k : ℕ) (A : IndexSet (op ⦋j⦌)) (hA : ¬A.EqId) :\n (s.cofan _).inj A ≫ K[X].d j k ≫ s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by\n rw [A.eqId_iff_mono] at hA\n rw [← assoc, ← s.comp_PInfty_eq_zero_iff, assoc, ← PInfty.comm j k, s.cofan_inj_eq, assoc,\n degeneracy_comp_PInfty_assoc X j A.e hA, zero_comp, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\n/-- If `s` is a splitting of a simplicial object `X` in a preadditive category,\n`s.nondegComplex` is a chain complex which is given in degree `n` by\nthe nondegenerate `n`-simplices of `X`. This chain complex should be thought\nas the normalized chain complex of `X` because of the isomorphism\n`toKaroubiNondegComplexIsoN₁`. -/\n@[simps]\nnoncomputable def nondegComplex : ChainComplex C ℕ where\n X := s.N\n d := s.d\n shape i j hij := by simp only [d, K[X].shape i j hij, zero_comp, comp_zero]\n d_comp_d' i j k _ _ := by\n simp only [d, assoc]\n have eq : K[X].d i j ≫ 𝟙 (X.obj (op ⦋j⦌)) ≫ K[X].d j k ≫\n s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by\n simp\n rw [s.decomposition_id] at eq\n classical\n rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op ⦋j⦌)), add_comp, comp_add, assoc,\n Preadditive.sum_comp, Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq\n swap\n · intro A hA\n simp only [Finset.mem_compl, Finset.mem_singleton] at hA\n simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]\n rw [eq, comp_zero]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- The chain complex `s.nondegComplex` attached to a splitting of a simplicial object `X`\nbecomes isomorphic to the normalized Moore complex `N₁.obj X` defined as a formal direct\nfactor in the category `Karoubi (ChainComplex C ℕ)`. -/\n@[simps]\nnoncomputable def toKaroubiNondegComplexIsoN₁ :\n (toKaroubi _).obj s.nondegComplex ≅ N₁.obj X where\n hom :=\n { f :=\n { f := fun n => (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n\n comm' := fun i j _ => by\n dsimp\n rw [assoc, assoc, assoc, πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty,\n HomologicalComplex.Hom.comm] }\n comm := by\n ext n\n dsimp\n rw [id_comp, assoc, PInfty_f_idem] }\n inv :=\n { f :=\n { f := fun n => s.πSummand (IndexSet.id (op ⦋n⦌))\n comm' := fun i j _ => by\n dsimp\n slice_rhs 1 1 => rw [← id_comp (K[X].d i j)]\n dsimp only [AlternatingFaceMapComplex.obj_X]\n rw [s.decomposition_id, sum_comp, sum_comp, Finset.sum_eq_single (IndexSet.id (op ⦋i⦌)),\n assoc, assoc]\n · intro A _ hA\n simp only [assoc, s.ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ hA, comp_zero]\n · simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff] }\n comm := by\n ext n\n dsimp\n simp only [comp_id, PInfty_comp_πSummand_id] }\n hom_inv_id := by\n ext n\n simp only [assoc, PInfty_comp_πSummand_id, Karoubi.comp_f, HomologicalComplex.comp_f,\n cofan_inj_πSummand_eq_id]\n rfl\n inv_hom_id := by\n ext n\n simp only [πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty, Karoubi.comp_f,\n HomologicalComplex.comp_f, N₁_obj_p, Karoubi.id_f]\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma toKaroubiNondegComplexIsoN₁_hom_f_PInfty :\n dsimp% s.toKaroubiNondegComplexIsoN₁.hom.f ≫ PInfty =\n s.toKaroubiNondegComplexIsoN₁.hom.f := by\n simpa using s.toKaroubiNondegComplexIsoN₁.hom.comm\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma toKaroubiNondegComplexIsoN₁_hom_inv_id_f :\n dsimp% s.toKaroubiNondegComplexIsoN₁.hom.f ≫ s.toKaroubiNondegComplexIsoN₁.inv.f = 𝟙 _ := by\n rw [← dsimp% [-Karoubi.comp_f] Karoubi.comp_f s.toKaroubiNondegComplexIsoN₁.hom\n s.toKaroubiNondegComplexIsoN₁.inv, Iso.hom_inv_id]\n simp\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Given a splitting `s` of a simplicial object `X` in a preadditive category,\nthis is the split epimorphism from the alternating face map complex of `X` to the chain\ncomplex `s.nondegComplex`. -/\n@[no_expose]\nnoncomputable def toNondegComplex : K[X] ⟶ s.nondegComplex :=\n (fullyFaithfulToKaroubi _).preimage\n ({ f := by exact PInfty } ≫ s.toKaroubiNondegComplexIsoN₁.inv)\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Given a splitting `s` of a simplicial object `X` in a preadditive category,\nthis is the split monomormphism from the chain complex `s.nondegComplex` to\nthe alternating face map complex fo `X`. -/\n@[no_expose]\nnoncomputable def fromNondegComplex : s.nondegComplex ⟶ K[X] :=\n (fullyFaithfulToKaroubi _).preimage\n (s.toKaroubiNondegComplexIsoN₁.hom ≫ { f := PInfty })\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma PInfty_toNondegComplex : PInfty ≫ s.toNondegComplex = s.toNondegComplex :=\n (toKaroubi _).map_injective (by simp [toNondegComplex])\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma fromNondegComplex_toNondegComplex :\n s.fromNondegComplex ≫ s.toNondegComplex = 𝟙 _ :=\n (toKaroubi _).map_injective (by simp [toNondegComplex, fromNondegComplex])\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc]\nlemma toNondegComplex_f (n : ℕ) :\n s.toNondegComplex.f n = PInfty.f n ≫ s.toKaroubiNondegComplexIsoN₁.inv.f.f n := by\n simp [toNondegComplex, fullyFaithfulToKaroubi]\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc]\n\nTarget:\nlemma fromNondegComplex_f (n : ℕ) :\n s.fromNondegComplex.f n = s.ι n ≫ PInfty.f n :=\n\nProof body:\n","rejected":"by\n exact fromNondegComplex_f","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"3edf93e02989f0990001f27ddd15cbcacb6bca89de42bf63219d5cc968e47dfe","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/DoldKan","family_id":"fromnondegcomplex_f","file_id":"mathlib/Mathlib/AlgebraicTopology/DoldKan/SplitSimplicialObject.lean","sample_id":"8e0c0563df1280eaca460eabfa177c0aa9b5168635cf8293cca1d2c06361b3a0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f194b7d6eac4e2d6633da0a5617552c227efdbfa726721214ee562dea2432d2d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3a5018e6c1566751dbdf9f58dd1239c8644e55701a13fb33847400d3465f55c4","source_sha256":"31511787b8ee979ad68b270d70d53565c4f726a4fcbb6bab5c8059163486f498","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [← mem_coe, coe_smul, Set.mem_inv_smul_set_iff]","hard_negative":false,"metrics":{"chosen_tokens":12,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.25},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"3bc8cd5f9ec6870105ca5778b6e81865f07adf5522a989385780fe9c78e65091","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Finite\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.GroupTheory.Coset.Defs\n\nNamespace:\nDiscreteTiling.PlacedTile\n\nLocal context:\n/-\nCopyright (c) 2026 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Tiles for tilings\n\nThis file defines some basic concepts related to individual tiles for tilings in a discrete context\n(with definitions in a continuous context to be developed separately but analogously).\n\nWork in the field of tilings does not generally try to define or state things in any kind of maximal\ngenerality, so it is necessary to adapt definitions and statements from the literature to produce\nsomething that seems appropriately general for mathlib, covering a wide range of tiling-related\nconcepts found in the literature. Nevertheless, further generalization may prove of use as this work\nis extended in future.\n\nWe work in the context of a space `X` acted on by a group `G`; the action is not required to be\nfaithful, although typically it is. In a discrete context, tiles are expected to cover the space, or\na subset of it being tiled when working with tilings not of the whole space, and the tiles are\npairwise disjoint. In a continuous context, definitions in the literature vary; the tiles may be\nclosed and cover the space with interiors required to be disjoint (as used by Grünbaum and Shephard\nor Goodman-Strauss), or they may be required to be measurable and to partition it up to null sets\n(as used by Greenfeld and Tao).\n\nIn general we are concerned not with a tiling in isolation but with tilings by some protoset of\ntiles; thus we make definitions in the context of such a protoset, where copies of the tiles in the\ntiling must be images of those tiles under the action of an element of the given group.\n\nWhere there are matching rules that say what combinations of tiles are considered as valid, these\nare provided as separate hypotheses where required. Tiles in a protoset are commonly considered in\nthe literature to be marked in some way. When this is simply to distinguish two otherwise identical\ntiles, this is represented by the use of different indices in the protoset. When this is to give a\ntile fewer symmetries than it would otherwise have under the action of the given group, this is\nrepresented by the symmetries specified in the `Prototile` being less than its full stabilizer.\n\nThe group `G` is throughout here a multiplicative group. Additive groups are also used in the\nliterature, typically when based on `ℤ`; to support the use of additive groups, `to_additive` could\nbe used with the theory here.\n\n## Main definitions\n\n* `Prototile G X`: A prototile in `X` as acted on by `G`, carrying the information of a subgroup of\n the stabilizer that says when two copies of the prototile are considered the same.\n\n* `Protoset G X ιₚ`: An indexed family of prototiles.\n\n* `PlacedTile ps`: An image of a tile in the protoset `ps`.\n\n## References\n\n* [Branko Grünbaum and G. C. Shephard, *Tilings and Patterns*][GrunbaumShephard1987]\n* [Chaim Goodman-Strauss, *Open Questions in Tiling*][GoodmanStrauss2000]\n* [Rachel Greenfeld and Terence Tao, *A counterexample to the periodic tiling\n conjecture*][GreenfeldTao2024]\n-/\n\n\n@[expose] public section\n\nnamespace DiscreteTiling\n\nopen Function\nopen scoped Pointwise\n\nvariable {G X ιₚ : Type*} [Group G] [MulAction G X]\n\nvariable (G X) in\n/-- A `Prototile G X` describes a tile in `X`, copies of which under elements of `G` may be used in\ntilings. Two copies related by an element of `symmetries` are considered the same; two copies not so\nrelated, even if they have the same points, are considered distinct. -/\n@[ext] structure Prototile where\n /-- The points in the prototile. Use the coercion to `Set X`, or `∈` on the `Prototile`, rather\n than using `carrier` directly. The coercion cannot use `SetLike` because it does not satisfy\n `coe_injective`. -/\n carrier : Set X\n /-- The group elements considered to be symmetries of the prototile. -/\n symmetries : Subgroup (MulAction.stabilizer G carrier)\n\nnamespace Prototile\n\ninstance : Inhabited (Prototile G X) where\n default := ⟨∅, ⊥⟩\n\ninstance : CoeOut (Prototile G X) (Set X) where\n coe := Prototile.carrier\n\nattribute [coe] carrier\n\ninstance : Membership X (Prototile G X) where\n mem p x := x ∈ (p : Set X)\n\nlemma coe_mk (c s) : (⟨c, s⟩ : Prototile G X) = c := rfl\n\n@[simp] lemma mem_coe {x : X} {p : Prototile G X} : x ∈ (p : Set X) ↔ x ∈ p := Iff.rfl\n\nend Prototile\n\nvariable (G X ιₚ) in\n/-- A `Protoset G X ιₚ` is an indexed family of `Prototile G X`. This is a separate definition\nrather than just using plain functions to facilitate defining associated API that can be used with\ndot notation. -/\n@[ext] structure Protoset where\n /-- The tiles in the protoset. Use the coercion to a function rather than using `tiles`\n directly. -/\n tiles : ιₚ → Prototile G X\n\nnamespace Protoset\n\ninstance : Inhabited (Protoset G X ιₚ) where\n default := ⟨fun _ ↦ default⟩\n\ninstance : CoeFun (Protoset G X ιₚ) (fun _ ↦ ιₚ → Prototile G X) where\n coe := tiles\n\nattribute [coe] tiles\n\nlemma coe_mk (t) : (⟨t⟩ : Protoset G X ιₚ) = t := rfl\n\n@[simp, norm_cast] lemma coe_inj {ps₁ ps₂ : Protoset G X ιₚ} :\n (ps₁ : ιₚ → Prototile G X) = ps₂ ↔ ps₁ = ps₂ :=\n Protoset.ext_iff.symm\n\nlemma coe_injective : Injective (Protoset.tiles : Protoset G X ιₚ → ιₚ → Prototile G X) :=\n fun _ _ ↦ coe_inj.1\n\nend Protoset\n\nvariable {ps : Protoset G X ιₚ}\n\nvariable (ps) in\n/-- A `PlacedTile ps` is an image of a tile in the protoset `p` under an element of the group `G`.\nThis is represented using a quotient so that images under group elements differing only by a\nsymmetry of the tile are equal. -/\n@[ext] structure PlacedTile where\n /-- The index of the tile in the protoset. -/\n index : ιₚ\n /-- The group elements under which this tile is an image. -/\n groupElts : G ⧸ ((ps index).symmetries.map <| Subgroup.subtype _)\n\nnamespace PlacedTile\n\ninstance [Nonempty ιₚ] : Nonempty (PlacedTile ps) := ⟨⟨Classical.arbitrary _, (1 : G)⟩⟩\n\n/-- An induction principle to deduce results for `PlacedTile` from those given an index and an\nelement of `G`, used with `induction pt using PlacedTile.induction_on`. -/\n@[elab_as_elim] protected lemma induction_on {ppt : PlacedTile ps → Prop} (pt : PlacedTile ps)\n (h : ∀ i : ιₚ, ∀ gx : G, ppt ⟨i, gx⟩) : ppt pt := by\n rcases pt with ⟨i, gx⟩\n induction gx using Quotient.inductionOn\n apply h\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using existence of a\ncommon group element. -/\nlemma ext_iff_of_exists {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧ ∃ g, ⟦g⟧ = pt₁.groupElts ∧ ⟦g⟧ = pt₂.groupElts := by\n refine ⟨fun h ↦ ?_, fun ⟨h, g, hg₁, hg₂⟩ ↦ ?_⟩\n · subst h\n simp only [and_self, true_and]\n refine ⟨pt₁.groupElts.out, ?_⟩\n rw [Quotient.out_eq]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at h\n subst h\n ext\n · rfl\n · exact heq_of_eq (hg₁.symm.trans hg₂)\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using equality of\nquotient preimages. -/\nlemma ext_iff_of_preimage {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧\n (Quotient.mk _) ⁻¹' {pt₁.groupElts} = (Quotient.mk _) ⁻¹' {pt₂.groupElts} := by\n refine ⟨fun h ↦ ?_, fun ⟨hi, hq⟩ ↦ ?_⟩\n · subst h\n simp only [and_self]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at hi\n subst hi\n ext\n · rfl\n · exact heq_of_eq (Set.singleton_eq_singleton_iff.1\n ((Set.preimage_eq_preimage Quotient.mk''_surjective).1 hq))\n\n/-- Coercion from a `PlacedTile` to a set of points. Use the coercion rather than using `coeSet`\ndirectly. -/\n@[coe] def coeSet (pt : PlacedTile ps) : Set X :=\n Quotient.liftOn' pt.groupElts (fun g ↦ g • (ps pt.index : Set X))\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n rw [eq_comm, ← inv_smul_eq_iff, smul_smul, ← MulAction.mem_stabilizer_iff]\n exact SetLike.le_def.1 (Subgroup.map_subtype_le _) r\n\ninstance : CoeOut (PlacedTile ps) (Set X) where\n coe := coeSet\n\ninstance : Membership X (PlacedTile ps) where\n mem p x := x ∈ (p : Set X)\n\n@[simp] lemma mem_coe {x : X} {pt : PlacedTile ps} : x ∈ (pt : Set X) ↔ x ∈ pt := Iff.rfl\n\nlemma coe_mk_mk (i : ιₚ) (g : G) : (⟨i, ⟦g⟧⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_mk_coe (i : ιₚ) (g : G) : (⟨i, g⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_nonempty_iff {pt : PlacedTile ps} :\n (pt : Set X).Nonempty ↔ (ps pt.index : Set X).Nonempty := by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp\n\n@[simp] lemma coe_mk_nonempty_iff {i : ιₚ} (g) :\n ((⟨i, g⟩ : PlacedTile ps) : Set X).Nonempty ↔ (ps i : Set X).Nonempty :=\n coe_nonempty_iff\n\nlemma coe_finite_iff {pt : PlacedTile ps} :\n (pt : Set X).Finite ↔ (ps pt.index : Set X).Finite := by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp\n\n@[simp] lemma coe_mk_finite_iff {i : ιₚ} (g) :\n ((⟨i, g⟩ : PlacedTile ps) : Set X).Finite ↔ (ps i : Set X).Finite :=\n coe_finite_iff\n\ninstance : SMul G (PlacedTile ps) where\n smul g pt := Quotient.liftOn' pt.groupElts (fun h ↦ ⟨pt.index, g * h⟩)\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n refine PlacedTile.ext rfl ?_\n simpa [QuotientGroup.eq, ← mul_assoc] using r\n\n@[simp] lemma smul_mk_mk (g h : G) (i : ιₚ) : g • (⟨i, ⟦h⟧⟩ : PlacedTile ps) = ⟨i, g * h⟩ := rfl\n\n@[simp] lemma smul_mk_coe (g h : G) (i : ιₚ) : g • (⟨i, h⟩ : PlacedTile ps) = ⟨i, g * h⟩ := rfl\n\n@[simp] lemma smul_index (g : G) (pt : PlacedTile ps) : (g • pt).index = pt.index := by\n induction pt using PlacedTile.induction_on\n rfl\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp] lemma coe_smul (g : G) (pt : PlacedTile ps) :\n (g • pt : PlacedTile ps) = g • (pt : Set X) := by\n induction pt using PlacedTile.induction_on\n simp [coeSet, mul_smul]\n\ninstance : MulAction G (PlacedTile ps) where\n __ : SMul G (PlacedTile ps) := inferInstance\n one_smul pt := by\n induction pt using PlacedTile.induction_on\n simp\n mul_smul x y pt := by\n induction pt using PlacedTile.induction_on\n simp [mul_assoc]\n\n@[simp] lemma smul_mem_smul_iff (g : G) {x : X} {pt : PlacedTile ps} : g • x ∈ g • pt ↔ x ∈ pt := by\n rw [← mem_coe, coe_smul, Set.smul_mem_smul_set_iff, mem_coe]\n\nlemma mem_smul_iff_smul_inv_mem {g : G} {x : X} {pt : PlacedTile ps} :\n x ∈ g • pt ↔ g⁻¹ • x ∈ pt := by\n simp_rw [← mem_coe, coe_smul, Set.mem_smul_set_iff_inv_smul_mem]\n\nTarget:\nlemma mem_inv_smul_iff_smul_mem {g : G} {x : X} {pt : PlacedTile ps} :\n x ∈ g⁻¹ • pt ↔ g • x ∈ pt :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Tiling","family_id":"mem_inv_smul_iff_smul_mem","file_id":"mathlib/Mathlib/Combinatorics/Tiling/Tile.lean","sample_id":"3a5018e6c1566751dbdf9f58dd1239c8644e55701a13fb33847400d3465f55c4"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b76825397e63e5db910ed9ce861676c41de624845586a29c999cf5385a9fa38c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5a6ac7caf5150468b380c4e0e02998d77af45490f9823a7727b0ef5ed26d00b2","source_sha256":"9fab1381fa124c77b2984ae6d7a34091cf75e467bd0bd60181fa1205c081c09e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← h]\n apply R.gc_leftDual_rightDual.monotone_l\n apply R.gc_leftDual_rightDual.monotone_u\n exact h₁","hard_negative":true,"metrics":{"chosen_tokens":21,"rejected_tokens":8,"token_jaccard":0.05,"token_length_ratio":0.380952},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"3c047c2c87f047bd4ff13c57425367046c386675e40445d2645e5cbf7585799b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Rel\n\nNamespace:\nSetRel\n\nLocal context:\n/-\nCopyright (c) 2024 Lagrange Mathematics and Computing Research Center. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anthony Bordg\n-/\n/-!\n# The Galois Connection Induced by a Relation\n\nIn this file, we show that an arbitrary relation `R` between a pair of types `α` and `β` defines\na pair `toDual ∘ R.leftDual` and `R.rightDual ∘ ofDual` of adjoint order-preserving maps between the\ncorresponding posets `Set α` and `(Set β)ᵒᵈ`.\nWe define `R.leftFixedPoints` (resp. `R.rightFixedPoints`) as the set of fixed points `J`\n(resp. `I`) of `Set α` (resp. `Set β`) such that `rightDual (leftDual J) = J`\n(resp. `leftDual (rightDual I) = I`).\n\n## Main Results\n\n⋆ `Rel.gc_leftDual_rightDual`: we prove that the maps `toDual ∘ R.leftDual` and\n `R.rightDual ∘ ofDual` form a Galois connection.\n⋆ `Rel.equivFixedPoints`: we prove that the maps `R.leftDual` and `R.rightDual` induce inverse\n bijections between the sets of fixed points.\n\n## References\n\n⋆ Engendrement de topologies, démontrabilité et opérations sur les sous-topos, Olivia Caramello and\n Laurent Lafforgue (in preparation)\n\n## Tags\n\nrelation, Galois connection, induced bijection, fixed points\n-/\n\n@[expose] public section\n\nvariable {α β : Type*} (R : SetRel α β)\n\nnamespace SetRel\n\n/-! ### Pairs of adjoint maps defined by relations -/\n\nopen OrderDual\n\n/-- `leftDual` maps any set `J` of elements of type `α` to the set `{b : β | ∀ a ∈ J, a ~[R] b}` of\nelements `b` of type `β` such that `a ~[R] b` for every element `a` of `J`. -/\ndef leftDual (J : Set α) : Set β := {b : β | ∀ ⦃a⦄, a ∈ J → a ~[R] b}\n\n/-- `rightDual` maps any set `I` of elements of type `β` to the set `{a : α | ∀ b ∈ I, a ~[R] b}`\nof elements `a` of type `α` such that `a ~[R] b` for every element `b` of `I`. -/\ndef rightDual (I : Set β) : Set α := {a : α | ∀ ⦃b⦄, b ∈ I → a ~[R] b}\n\n/-- The pair of functions `toDual ∘ leftDual` and `rightDual ∘ ofDual` forms a Galois connection. -/\ntheorem gc_leftDual_rightDual : GaloisConnection (toDual ∘ R.leftDual) (R.rightDual ∘ ofDual) :=\n fun _ _ ↦ ⟨fun h _ ha _ hb ↦ h (by simpa) ha, fun h _ hb _ ha ↦ h (by simpa) hb⟩\n\n/-! ### Induced equivalences between fixed points -/\n\n/-- `leftFixedPoints` is the set of elements `J : Set α` satisfying `rightDual (leftDual J) = J`. -/\ndef leftFixedPoints := {J : Set α | R.rightDual (R.leftDual J) = J}\n\n/-- `rightFixedPoints` is the set of elements `I : Set β` satisfying `leftDual (rightDual I) = I`.\n-/\ndef rightFixedPoints := {I : Set β | R.leftDual (R.rightDual I) = I}\n\nopen GaloisConnection\n\n/-- `leftDual` maps every element `J` to `rightFixedPoints`. -/\ntheorem leftDual_mem_rightFixedPoint (J : Set α) : R.leftDual J ∈ R.rightFixedPoints := by\n apply le_antisymm\n · apply R.gc_leftDual_rightDual.monotone_l; exact R.gc_leftDual_rightDual.le_u_l J\n · exact R.gc_leftDual_rightDual.l_u_le (R.leftDual J)\n\n/-- `rightDual` maps every element `I` to `leftFixedPoints`. -/\ntheorem rightDual_mem_leftFixedPoint (I : Set β) : R.rightDual I ∈ R.leftFixedPoints := by\n apply le_antisymm\n · apply R.gc_leftDual_rightDual.monotone_u; exact R.gc_leftDual_rightDual.l_u_le I\n · exact R.gc_leftDual_rightDual.le_u_l (R.rightDual I)\n\n/-- The maps `leftDual` and `rightDual` induce inverse bijections between the sets of fixed points.\n-/\ndef equivFixedPoints : R.leftFixedPoints ≃ R.rightFixedPoints where\n toFun := fun ⟨J, _⟩ => ⟨R.leftDual J, R.leftDual_mem_rightFixedPoint J⟩\n invFun := fun ⟨I, _⟩ => ⟨R.rightDual I, R.rightDual_mem_leftFixedPoint I⟩\n left_inv J := by obtain ⟨J, hJ⟩ := J; rw [Subtype.mk.injEq, hJ]\n right_inv I := by obtain ⟨I, hI⟩ := I; rw [Subtype.mk.injEq, hI]\n\ntheorem rightDual_leftDual_le_of_le {J J' : Set α} (h : J' ∈ R.leftFixedPoints) (h₁ : J ≤ J') :\n R.rightDual (R.leftDual J) ≤ J' := by\n rw [← h]\n apply R.gc_leftDual_rightDual.monotone_u\n apply R.gc_leftDual_rightDual.monotone_l\n exact h₁\n\nTarget:\ntheorem leftDual_rightDual_le_of_le {I I' : Set β} (h : I' ∈ R.rightFixedPoints) (h₁ : I ≤ I') :\n R.leftDual (R.rightDual I) ≤ I' :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"aa680dd804a07da2325ed7f088e470d0fe0b9ddad8c178a2f3c92834ed6a1e59","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Rel","family_id":"leftdual_rightdual_le_of_le","file_id":"mathlib/Mathlib/Order/Rel/GaloisConnection.lean","sample_id":"5a6ac7caf5150468b380c4e0e02998d77af45490f9823a7727b0ef5ed26d00b2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4340b8178dce658187fe2d00cc40731483c2db0d7d0d6a3155533ff967498f19","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"79ee1034b7bb6e0513a9ad86fb33ebba77cb166b447c9dba3af1d99cb9e50dca","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"890232717f85060b74a3ee0f5945cfb30376f59193c213d21fc2e6e77bfa7a61","source_sha256":"864bb4bb18dcd59ea0d99974e94e6f80f27ed7f81365f8520c597842fa036700","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine le_antisymm ?_ <| (RingCon.gi N).gc.le_u_l _\n have := Relation.map_equivalence c.toSetoid.2 _ hf h\n intro _ _ hg\n induction hg with\n | of _ _ a => exact a\n | refl x => exact this.refl x\n | symm _ h => exact this.symm h\n | trans _ _ h₁ h₂ => exact this.trans h₁ h₂\n | add _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a + p, b + q, c.add h1 h2, map_add f _ _, map_add f _ _⟩\n | mul _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a * p, b * q, c.mul h1 h2, map_mul f _ _, map_mul f _ _⟩","hard_negative":true,"metrics":{"chosen_tokens":212,"rejected_tokens":2,"token_jaccard":0.017544,"token_length_ratio":0.009434},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"3c94b30cc2f80b8afb495c04af66fd6d169e9402754fba1144bb04dea8daf26c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Subalgebra.Lattice\npublic import Mathlib.Algebra.Algebra.Subalgebra.Basic\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.RingTheory.Congruence.Basic\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.Algebra.Ring.Subring.Basic\npublic import Mathlib.Algebra.RingQuot\n\nNamespace:\nRingCon\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Congruence relations and ring homomorphisms\n\nThis file contains elementary definitions involving congruence\nrelations and morphisms for rings and semirings\n\n## Main definitions\n\n* `RingCon.ker`: the kernel of a monoid homomorphism as a congruence relation\n* `RingCon.lift`, `RingCon.liftₐ`: the homomorphism / the algebra morphism\n on the quotient given that the congruence is in the kernel\n* `RingCon.map`, `RingCon.mapₐ`: homomorphism / algebra morphism\n from a smaller to a larger quotient\n\n* `RingCon.quotientKerEquivRangeS`, `RingCon.quotientKerEquivRange`,\n `RingCon.quotientKerEquivRangeₐ` :\n the first isomorphism theorem for semirings (using `RingHom.rangeS`),\n rings (using `RingHom.range`) and algebras (using `AlgHom.range`).\n* `RingCon.comapQuotientEquivRangeS`, `RingCon.comapQuotientEquivRange`,\n `RingCon.comapQuotientEquivRangeₐ` : the second isomorphism theorem\n for semirings (using `RingHom.rangeS`), rings (using `RingHom.range`)\n and algebras (using `AlgHom.range`).\n\n* `RingCon.quotientQuotientEquivQuotient`, `RingCon.quotientQuotientEquivQuotientₐ` :\n the third isomorphism theorem for semirings (or rings) and algebras\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, ring,\nquotient ring\n-/\n\n@[expose] public section\n\nvariable {M : Type*} {N : Type*} {P : Type*}\n\nopen Function Setoid\n\nnamespace RingCon\n\nsection\n\nvariable [NonAssocSemiring M] [NonAssocSemiring N] [NonAssocSemiring P] {c d : RingCon M}\n\n/-- The kernel of a ring homomorphism as a ring congruence relation. -/\ndef ker (f : M →+* N) : RingCon M := comap ⊥ f\n\ntheorem comap_bot (f : M →+* N) : comap ⊥ f = ker f := rfl\n\n/-- The definition of the ring congruence relation defined by a ring homomorphism's kernel. -/\n@[simp]\ntheorem ker_apply (f : M →+* N) {x y} : ker f x y ↔ f x = f y :=\n Iff.rfl\n\n/-- The kernel of the quotient map induced by a ring congruence relation `c` equals `c`. -/\ntheorem ker_mk'_eq (c : RingCon M) : ker c.mk' = c :=\n ext fun _ _ => Quotient.eq''\n\ntheorem ker_comp {f : M →+* N} {g : N →+* P} :\n ker (g.comp f) = (ker g).comap f :=\n ext fun x y ↦ by simp [ker_apply, comap_rel]\n\ntheorem comap_eq {g : N →+* M} :\n c.comap g = ker (c.mk'.comp g) := by\n rw [ker_comp, ker_mk'_eq]\n\n/-- Makes an isomorphism of quotients by two ring congruence\nrelations, given that the relations are equal. -/\nprotected def congr (h : c = d) :\n c.Quotient ≃+* d.Quotient :=\n { Quotient.congr (Equiv.refl M) <| by apply RingCon.ext_iff.mp h with\n map_add' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl\n map_mul' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl }\n\n@[simp] theorem congr_mk (h : c = d) (a : M) :\n RingCon.congr h (a : c.Quotient) = (a : d.Quotient) := rfl\n\n/-- Given a function `f`, the smallest ring congruence relation containing the binary\nrelation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to\nthe elements of `f⁻¹(y)` by a ring congruence relation `c`.' -/\ndef mapGen {c : RingCon M} (f : M → N) : RingCon N :=\n ringConGen <| Relation.Map c f f\n\n/-- If `c` is a ring congruence on `M`, then the smallest ring\ncongruence relation on `N` deduced from `c` by a ring homomorphism\nfrom `M` to `N` is the relation deduced from `c`. -/\n\nTarget:\ntheorem mapGen_eq_map_of_surjective\n {c : RingCon M} (f : M →+* N) (h : ker f ≤ c) (hf : Surjective f) :\n c.mapGen f = Relation.Map c f f :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_890232717f85","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"3a2c398c2e7a7b03e8bc57b6d7e7b9373ce1e9453d0c9bbdf959240382e6e39c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Congruence","family_id":"mapgen_eq_map_of_surjective","file_id":"mathlib/Mathlib/RingTheory/Congruence/Hom.lean","sample_id":"890232717f85060b74a3ee0f5945cfb30376f59193c213d21fc2e6e77bfa7a61"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0899b18df743631c4399d57209590382d7b2e9e3a847090548d5e404d07daf6d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4e0643ed342157b454698b88f13138db1a0caa45526eeac574e5f5b754a35c03","source_sha256":"ccfd4dd3593c6c1f210133749c73e4a778fa70e4772e48b50cde116f0b334020","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine (continuousAt_const : ContinuousAt (fun _ => (1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩","hard_negative":true,"metrics":{"chosen_tokens":56,"rejected_tokens":8,"token_jaccard":0.047619,"token_length_ratio":0.142857},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"3cae0690a918730d8e0d315a5a39e94a774b8a270170b21601c0bcfc11e618a0","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Sign.Defs\npublic import Mathlib.Topology.Order.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Topology on `SignType`\n\nThis file gives `SignType` the discrete topology, and proves continuity results for `SignType.sign`\nin an `OrderTopology`.\n-/\n\npublic section\n\ninstance : TopologicalSpace SignType :=\n ⊥\n\ninstance : DiscreteTopology SignType :=\n ⟨rfl⟩\n\nvariable {α : Type*} [Zero α] [TopologicalSpace α]\n\nsection PartialOrder\n\nvariable [PartialOrder α] [DecidableLT α] [OrderTopology α]\n\nTarget:\ntheorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"3d107879f0ee8c0874311d6c600ace9324caab3f62c90969f74f623075402bfc","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Instances","family_id":"continuousat_sign_of_pos","file_id":"mathlib/Mathlib/Topology/Instances/Sign.lean","sample_id":"4e0643ed342157b454698b88f13138db1a0caa45526eeac574e5f5b754a35c03"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"219aabb3f49e8e9f29dd6b52b015615566d77a5e4b67b3d6ea17166f372f1304","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"548c1dc0c4573523f7f04a8c5e4c876bf6f8602d323840f2b69bf0e2529a3781","source_sha256":"5fe320cf8339285f3ebda4142570292583dc5699644499632f4faabcfba59b47","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [nhdsWithin, nhds_prod_eq, ← prod_inf_prod, prod_principal_principal]","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":8,"token_jaccard":0.058824,"token_length_ratio":0.615385},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"3cc612ffc6215afc5aeb7bee2d7e0039489fb3fae8a7a7e7fd7b437903156569","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homeomorph.Defs\npublic import Mathlib.Topology.Maps.Basic\npublic import Mathlib.Topology.Separation.SeparatedNhds\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\n/-!\n# Disjoint unions and products of topological spaces\n\nThis file constructs sums (disjoint unions) and products of topological spaces\nand sets up their basic theory, such as criteria for maps into or out of these\nconstructions to be continuous; descriptions of the open sets, neighborhood filters,\nand generators of these constructions; and their behavior with respect to embeddings\nand other specific classes of maps.\n\nWe also provide basic homeomorphisms, to show that sums and products are commutative, associative\nand distributive (up to homeomorphism).\n\n## Implementation note\n\nThe constructed topologies are defined using induced and coinduced topologies\nalong with the complete lattice structure on topologies. Their universal properties\n(for example, a map `X → Y × Z` is continuous if and only if both projections\n`X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of\ncontinuity. With more work we can also extract descriptions of the open sets,\nneighborhood filters and so on.\n\n## Tags\n\nproduct, sum, disjoint union\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology TopologicalSpace Set Filter Function\n\nuniverse u v u' v'\n\nvariable {X : Type u} {Y : Type v} {W Z ε ζ : Type*}\n\ninstance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X ⊕ Y) :=\n coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂\n\ninstance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X × Y) :=\n induced Prod.fst t₁ ⊓ induced Prod.snd t₂\n\nsection Prod\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W]\n [TopologicalSpace ε] [TopologicalSpace ζ]\n\n@[simp]\ntheorem continuous_prodMk {f : X → Y} {g : X → Z} :\n (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g :=\n continuous_inf_rng.trans <| continuous_induced_rng.and continuous_induced_rng\n\n@[continuity]\ntheorem continuous_fst : Continuous (@Prod.fst X Y) :=\n (continuous_prodMk.1 continuous_id).1\n\n/-- Postcomposing `f` with `Prod.fst` is continuous -/\n@[fun_prop]\ntheorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 :=\n continuous_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous -/\ntheorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst :=\n hf.comp continuous_fst\n\ntheorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p :=\n continuous_fst.continuousAt\n\n/-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).1) x :=\n continuousAt_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/\ntheorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X × Y => f x.fst) (x, y) :=\n ContinuousAt.comp hf continuousAt_fst\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) :\n ContinuousAt (fun x : X × Y => f x.fst) x :=\n hf.comp continuousAt_fst\n\ntheorem Filter.Tendsto.fst_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) :=\n continuousAt_fst.tendsto.comp h\n\n@[continuity]\ntheorem continuous_snd : Continuous (@Prod.snd X Y) :=\n (continuous_prodMk.1 continuous_id).2\n\n/-- Postcomposing `f` with `Prod.snd` is continuous -/\n@[fun_prop]\ntheorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 :=\n continuous_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous -/\ntheorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd :=\n hf.comp continuous_snd\n\ntheorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p :=\n continuous_snd.continuousAt\n\n/-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).2) x :=\n continuousAt_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/\ntheorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) :\n ContinuousAt (fun x : X × Y => f x.snd) (x, y) :=\n ContinuousAt.comp hf continuousAt_snd\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) :\n ContinuousAt (fun x : X × Y => f x.snd) x :=\n hf.comp continuousAt_snd\n\ntheorem Filter.Tendsto.snd_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) :=\n continuousAt_snd.tendsto.comp h\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous fun x => (f x, g x) :=\n continuous_prodMk.2 ⟨hf, hg⟩\n\n@[continuity]\ntheorem Continuous.prodMk_right (x : X) : Continuous fun y : Y => (x, y) := by fun_prop\n\n@[continuity]\ntheorem Continuous.prodMk_left (y : Y) : Continuous fun x : X => (x, y) := by fun_prop\n\n/-- If `f x y` is continuous in `x` for all `y ∈ s`,\nthen the set of `x` such that `f x` maps `s` to `t` is closed. -/\nlemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t)\n (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} := by\n simpa only [MapsTo, setOf_forall] using! isClosed_biInter fun y hy ↦ ht.preimage (hf y hy)\n\ntheorem Continuous.comp₂ {g : X × Y → Z} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) : Continuous fun w => g (e w, f w) :=\n hg.comp <| he.prodMk hf\n\ntheorem Continuous.comp₃ {g : X × Y × Z → ε} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) :\n Continuous fun w => g (e w, f w, k w) :=\n hg.comp₂ he <| hf.prodMk hk\n\ntheorem Continuous.comp₄ {g : X × Y × Z × ζ → ε} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) {l : W → ζ}\n (hl : Continuous l) : Continuous fun w => g (e w, f w, k w, l w) :=\n hg.comp₃ he hf <| hk.prodMk hl\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMap {f : Z → X} {g : W → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous (Prod.map f g) :=\n hf.fst'.prodMk hg.snd'\n\n/-- A version of `continuous_inf_dom_left` for binary functions -/\ntheorem continuous_inf_dom_left₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X}\n {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z}\n (h : by haveI := ta1; haveI := tb1; exact Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by\n have ha := @continuous_inf_dom_left _ _ id ta1 ta2 ta1 (@continuous_id _ (id _))\n have hb := @continuous_inf_dom_left _ _ id tb1 tb2 tb1 (@continuous_id _ (id _))\n have h_continuous_id := @Continuous.prodMap _ _ _ _ ta1 tb1 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id\n\n/-- A version of `continuous_inf_dom_right` for binary functions -/\ntheorem continuous_inf_dom_right₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X}\n {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z}\n (h : by haveI := ta2; haveI := tb2; exact Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by\n have ha := @continuous_inf_dom_right _ _ id ta1 ta2 ta2 (@continuous_id _ (id _))\n have hb := @continuous_inf_dom_right _ _ id tb1 tb2 tb2 (@continuous_id _ (id _))\n have h_continuous_id := @Continuous.prodMap _ _ _ _ ta2 tb2 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id\n\n/-- A version of `continuous_sInf_dom` for binary functions -/\ntheorem continuous_sInf_dom₂ {X Y Z} {f : X → Y → Z} {tas : Set (TopologicalSpace X)}\n {tbs : Set (TopologicalSpace Y)} {tX : TopologicalSpace X} {tY : TopologicalSpace Y}\n {tc : TopologicalSpace Z} (hX : tX ∈ tas) (hY : tY ∈ tbs)\n (hf : Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := sInf tas; haveI := sInf tbs\n exact @Continuous _ _ _ tc fun p : X × Y => f p.1 p.2 := by\n have hX := continuous_sInf_dom hX continuous_id\n have hY := continuous_sInf_dom hY continuous_id\n have h_continuous_id := @Continuous.prodMap _ _ _ _ tX tY (sInf tas) (sInf tbs) _ _ hX hY\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ hf h_continuous_id\n\ntheorem Filter.Eventually.prod_inl_nhds {p : X → Prop} {x : X} (h : ∀ᶠ x in 𝓝 x, p x) (y : Y) :\n ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).1 :=\n continuousAt_fst h\n\ntheorem Filter.Eventually.prod_inr_nhds {p : Y → Prop} {y : Y} (h : ∀ᶠ x in 𝓝 y, p x) (x : X) :\n ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).2 :=\n continuousAt_snd h\n\ntheorem Filter.Eventually.prodMk_nhds {px : X → Prop} {x} (hx : ∀ᶠ x in 𝓝 x, px x) {py : Y → Prop}\n {y} (hy : ∀ᶠ y in 𝓝 y, py y) : ∀ᶠ p in 𝓝 (x, y), px (p : X × Y).1 ∧ py p.2 :=\n (hx.prod_inl_nhds y).and (hy.prod_inr_nhds x)\n\n@[fun_prop]\ntheorem continuous_swap : Continuous (Prod.swap : X × Y → Y × X) :=\n continuous_snd.prodMk continuous_fst\n\nlemma isClosedMap_swap : IsClosedMap (Prod.swap : X × Y → Y × X) := fun s hs ↦ by\n rw [image_swap_eq_preimage_swap]\n exact hs.preimage continuous_swap\n\ntheorem Continuous.uncurry_left {f : X → Y → Z} (x : X) (h : Continuous (uncurry f)) :\n Continuous (f x) :=\n h.comp (.prodMk_right _)\n\ntheorem Continuous.uncurry_right {f : X → Y → Z} (y : Y) (h : Continuous (uncurry f)) :\n Continuous fun a => f a y :=\n h.comp (.prodMk_left _)\n\ntheorem continuous_curry {g : X × Y → Z} (x : X) (h : Continuous g) : Continuous (curry g x) :=\n Continuous.uncurry_left x h\n\ntheorem IsOpen.prod {s : Set X} {t : Set Y} (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ×ˢ t) :=\n (hs.preimage continuous_fst).inter (ht.preimage continuous_snd)\n\n-- Porting note: Lean fails to find `t₁` and `t₂` by unification\ntheorem nhds_prod_eq {x : X} {y : Y} : 𝓝 (x, y) = 𝓝 x ×ˢ 𝓝 y := by\n rw [prod_eq_inf, instTopologicalSpaceProd, nhds_inf (t₁ := TopologicalSpace.induced Prod.fst _)\n (t₂ := TopologicalSpace.induced Prod.snd _), nhds_induced, nhds_induced]\n\nTarget:\ntheorem nhdsWithin_prod_eq (x : X) (y : Y) (s : Set X) (t : Set Y) :\n 𝓝[s ×ˢ t] (x, y) = 𝓝[s] x ×ˢ 𝓝[t] y :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"56e14dd6581ced7e87ca8ffcbf04ae00475a8be697c83d86734acc7cf92541f0","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Constructions","family_id":"nhdswithin_prod_eq","file_id":"mathlib/Mathlib/Topology/Constructions/SumProd.lean","sample_id":"548c1dc0c4573523f7f04a8c5e4c876bf6f8602d323840f2b69bf0e2529a3781"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7b4003e846db02e4042f455413073cdd2527f085a3fc82f898c0dedf4f118fd0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a93572d00e3b15ac0e868b16faf2de7151ef159546024bf00b541a88cc14acad","source_sha256":"c30a3d4b1c42fcb7d8e6bf63ba23497757e589a03ca883e3c4dcb6c17db24a2c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨y, hy, hdist⟩ := D.isCover_coveringRadius (x := x) (by trivial)\n exact ⟨y, hy, by simpa [edist_dist] using hdist⟩","hard_negative":true,"metrics":{"chosen_tokens":36,"rejected_tokens":8,"token_jaccard":0.115385,"token_length_ratio":0.222222},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"3d4b0554d6f95d432d9d1b32cc9b77246442b3245e5a034c01b1d3bfe765de04","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.MetricSpace.Cover\n\nNamespace:\nDelone.DeloneSet\n\nLocal context:\n/-\nCopyright (c) 2026 Newell Jensen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Newell Jensen\n-/\n/-!\n# Delone sets\n\nA **Delone set** `D ⊆ X` in a metric space is a set which is both:\n\n* **Uniformly Discrete**: there exists `packingRadius > 0` such that distinct points of `D`\n are separated by a distance strictly greater than `packingRadius`;\n* **Relatively Dense**: there exists `coveringRadius > 0` such that every point of `X`\n lies within distance `coveringRadius` of some point of `D`.\n\nThe `DeloneSet` structure stores the set together with explicit radii witnessing\nthese properties. The definitions use metric entourages so that the theory fits\nnaturally into the uniformity framework.\n\nDelone sets appear in discrete geometry, crystallography, aperiodic order, and tiling theory.\n\n## Main definitions\n\n* `Delone.DeloneSet X`: The main structure representing a Delone set in a metric space `X`.\n* `DeloneSet.mapBilipschitz`: Transports a Delone set along a bilipschitz equivalence,\n scaling the radii.\n* `DeloneSet.mapIsometry` Preserves the packing and covering radii exactly.\n\n## Basic properties\n\n* `packingRadius_lt_dist_of_mem_ne` : Distinct points in a Delone set are further apart than\n the packing radius.\n* `exists_dist_le_coveringRadius` : Every point of the space lies within the covering radius\n of the set.\n* `subset_ball_singleton` : Any ball of sufficiently small radius contains at most one point of\n the set.\n\n## Implementation notes\n\n* **Bundled Structure**: `DeloneSet` is bundled as a structure rather than a predicate\n (e.g., `IsDelone`). This facilitates dynamical systems constructions like hulls and patches by\n ensuring operations automatically preserve the required properties, eliminating the need to\n manually pass around proofs that the set remains Delone.\n* **Explicit Data**: Since radii are stored as explicit data, the map from `DeloneSet X` to `Set X`\n is not injective. We provide a `Membership` instance and `mem_carrier` to allow the convenience\n of `∈` notation while ensuring radii remain bundled, computationally accessible, and tracked by\n extensionality.\n-/\n\n@[expose] public section\n\nopen Metric\nopen scoped NNReal\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nnamespace Delone\n\n/-- A **Delone set** consists of a set together with explicit radii\nwitnessing uniform discreteness and relative denseness. -/\n@[ext]\nstructure DeloneSet (X : Type*) [MetricSpace X] where\n /-- The underlying set. -/\n carrier : Set X\n /-- Radius such that distinct points of `carrier` are separated by more than `r`. -/\n packingRadius : ℝ≥0\n packingRadius_pos : 0 < packingRadius\n isSeparated_packingRadius : IsSeparated packingRadius carrier\n /-- Radius such that every point of the space is within `R` of `carrier`. -/\n coveringRadius : ℝ≥0\n coveringRadius_pos : 0 < coveringRadius\n isCover_coveringRadius : IsCover coveringRadius .univ carrier\n\nnamespace DeloneSet\n\n/-- The underlying set of points of a Delone set. -/\n@[coe] def toSet (D : DeloneSet X) : Set X := D.carrier\n\ninstance : Coe (DeloneSet X) (Set X) where\n coe := DeloneSet.toSet\n\ninstance : Membership X (DeloneSet X) where\n mem D x := x ∈ (D : Set X)\n\n@[simp, norm_cast]\nlemma mem_coe {D : DeloneSet X} {x : X} : x ∈ (D : Set X) ↔ x ∈ D := .rfl\n\n@[simp] lemma mem_carrier {D : DeloneSet X} {x : X} :\n x ∈ D.carrier ↔ x ∈ D := .rfl\n\nlemma nonempty [Nonempty X] (D : DeloneSet X) : (D : Set X).Nonempty :=\n D.isCover_coveringRadius.nonempty Set.univ_nonempty\n\n/-- Copy of a Delone set with new fields equal to the old ones.\nUseful to fix definitional equalities. -/\nprotected def copy (D : DeloneSet X) (carrier : Set X) (packingRadius coveringRadius : ℝ≥0)\n (h_carrier : carrier = D.carrier) (h_packing : packingRadius = D.packingRadius)\n (h_covering : coveringRadius = D.coveringRadius) :\n DeloneSet X where\n carrier := carrier\n packingRadius := packingRadius\n packingRadius_pos := by simpa [h_packing] using D.packingRadius_pos\n isSeparated_packingRadius := by\n simpa [h_carrier, h_packing] using D.isSeparated_packingRadius\n coveringRadius := coveringRadius\n coveringRadius_pos := by simpa [h_covering] using D.coveringRadius_pos\n isCover_coveringRadius := by\n simpa [h_carrier, h_covering] using D.isCover_coveringRadius\n\ntheorem copy_eq (D : DeloneSet X)\n (carrier packingRadius coveringRadius h_carrier h_packing h_covering) :\n D.copy carrier packingRadius coveringRadius h_carrier h_packing h_covering = D :=\n DeloneSet.ext h_carrier h_packing h_covering\n\nlemma packingRadius_lt_dist_of_mem_ne (D : DeloneSet X) {x y : X}\n (hx : x ∈ D) (hy : y ∈ D) (hne : x ≠ y) :\n D.packingRadius < dist x y := by\n have hsep : ENNReal.ofReal D.packingRadius < ENNReal.ofReal (dist x y) := by\n simpa [edist_dist] using D.isSeparated_packingRadius hx hy hne\n exact (ENNReal.ofReal_lt_ofReal_iff (h := dist_pos.mpr hne)).1 hsep\n\nTarget:\nlemma exists_dist_le_coveringRadius (D : DeloneSet X) (x : X) :\n ∃ y ∈ D, dist x y ≤ D.coveringRadius :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"61a8eba1aec38d640233d3b5b3ca0600223c8b223b78abc3e15406e9fa97674c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/AperiodicOrder","family_id":"exists_dist_le_coveringradius","file_id":"mathlib/Mathlib/Analysis/AperiodicOrder/Delone/Basic.lean","sample_id":"a93572d00e3b15ac0e868b16faf2de7151ef159546024bf00b541a88cc14acad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ebc48890c3ae78ed36c04e75d23bfb79cdc9858a1639886a8e7520e88c2a6dbf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8cd941aa0e522d6c509db430b1007ae8141a73c02ef92af538775f9bdf783a8f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"975f2393856df943a6b8c869594b08cc9e3a6df82aca394df0da942bc9b864e2","source_sha256":"3fa27d4724df81d3aa4e7bd288a473172f238ad50a2de2c3cbb8ac8e2dec37a9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [jacobiSum, MulChar.ringHomComp, MulChar.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk,\n map_sum, map_mul]","hard_negative":false,"metrics":{"chosen_tokens":26,"rejected_tokens":31,"token_jaccard":0.75,"token_length_ratio":1.192308},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"3e311776e364a994f28594ddb2e0ed7f64db45ea6539e11c861f0da114a7d00d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.GaussSum\npublic import Mathlib.NumberTheory.MulChar.Lemmas\npublic import Mathlib.RingTheory.RootsOfUnity.Lemmas\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Jacobi Sums\n\nThis file defines the *Jacobi sum* of two multiplicative characters `χ` and `ψ` on a finite\ncommutative ring `R` with values in another commutative ring `R'`:\n\n`jacobiSum χ ψ = ∑ x : R, χ x * ψ (1 - x)`\n\n(see `jacobiSum`) and provides some basic results and API lemmas on Jacobi sums.\n\n## References\n\nWe essentially follow\n* [K. Ireland, M. Rosen, *A classical introduction to modern number theory*\n (Section 8.3)][IrelandRosen1990]\n\nbut generalize where appropriate.\n\nThis is based on Lean code written as part of the bachelor's thesis of Alexander Spahl.\n-/\n\n@[expose] public section\n\nopen Finset\n\n/-!\n### Jacobi sums: definition and first properties\n-/\n\nsection Def\n\n-- need `Fintype` instead of `Finite` to make `jacobiSum` computable.\nvariable {R R' : Type*} [CommRing R] [Fintype R] [CommRing R']\n\n/-- The *Jacobi sum* of two multiplicative characters on a finite commutative ring. -/\ndef jacobiSum (χ ψ : MulChar R R') : R' :=\n ∑ x : R, χ x * ψ (1 - x)\n\nlemma jacobiSum_comm (χ ψ : MulChar R R') : jacobiSum χ ψ = jacobiSum ψ χ := by\n simp only [jacobiSum, mul_comm (χ _)]\n rw [← (Equiv.subLeft 1).sum_comp]\n simp only [Equiv.subLeft_apply, sub_sub_cancel]\n\n/-- The Jacobi sum is compatible with ring homomorphisms. -/\n\nTarget:\nlemma jacobiSum_ringHomComp {R'' : Type*} [CommRing R''] (χ ψ : MulChar R R') (f : R' →+* R'') :\n jacobiSum (χ.ringHomComp f) (ψ.ringHomComp f) = f (jacobiSum χ ψ) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n simp only [jacobiSum, MulChar.ringHomComp, MulChar.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk,\n map_sum, map_mul]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/JacobiSum","family_id":"jacobisum_ringhomcomp","file_id":"mathlib/Mathlib/NumberTheory/JacobiSum/Basic.lean","sample_id":"975f2393856df943a6b8c869594b08cc9e3a6df82aca394df0da942bc9b864e2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0e2365d082165e3f9f94dfdeaecbad20029ad2665e51c2321129c8c07c450e6c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"90d36b2124fe820dae40fecb2428b26839b039f2f93d79e0676fa2abbd34ceb0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1b1dc83866b44921ff69681b932b284279c83a51731f2c627f731ad11176b5b7","source_sha256":"c1a21bb2aff2b44e6ec04f2e53e3c6ae24da1643eeece808534c81e1e3b64c70","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [RemoveNone.fiber, derangements]","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":3,"token_jaccard":0.090909,"token_length_ratio":0.333333},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"3e345c41787906e6924d838e3259ec49351f6ae67a3e81785891ce6077454552","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.FixedPoints.Basic\npublic import Mathlib.GroupTheory.Perm.Option\npublic import Mathlib.Logic.Equiv.Defs\npublic import Mathlib.Logic.Equiv.Option\npublic import Mathlib.Tactic.ApplyFun\n\nNamespace:\nderangements.Equiv\n\nLocal context:\n/-\nCopyright (c) 2021 Henry Swanson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henry Swanson\n-/\n/-!\n# Derangements on types\n\nIn this file we define `derangements α`, the set of derangements on a type `α`.\n\nWe also define some equivalences involving various subtypes of `Perm α` and `derangements α`:\n* `derangementsOptionEquivSigmaAtMostOneFixedPoint`: An equivalence between\n `derangements (Option α)` and the sigma-type `Σ a : α, {f : Perm α // fixedPoints f ⊆ a}`.\n* `derangementsRecursionEquiv`: An equivalence between `derangements (Option α)` and the\n sigma-type `Σ a : α, (derangements (({a}ᶜ : Set α) : Type*) ⊕ derangements α)` which is later\n used to inductively count the number of derangements.\n\nIn order to prove the above, we also prove some results about the effect of `Equiv.removeNone`\non derangements: `RemoveNone.fiber_none` and `RemoveNone.fiber_some`.\n-/\n\n@[expose] public section\n\n\nopen Equiv Function\n\n/-- A permutation is a derangement if it has no fixed points. -/\ndef derangements (α : Type*) : Set (Perm α) :=\n { f : Perm α | ∀ x : α, f x ≠ x }\n\nvariable {α β : Type*}\n\ntheorem mem_derangements_iff_fixedPoints_eq_empty {f : Perm α} :\n f ∈ derangements α ↔ fixedPoints f = ∅ :=\n Set.eq_empty_iff_forall_notMem.symm\n\n/-- If `α` is equivalent to `β`, then `derangements α` is equivalent to `derangements β`. -/\ndef Equiv.derangementsCongr (e : α ≃ β) : derangements α ≃ derangements β :=\n e.permCongr.subtypeEquiv fun {f} => e.forall_congr <| by\n intro b; simp only [ne_eq, permCongr_apply, symm_apply_apply, EmbeddingLike.apply_eq_iff_eq]\n\nnamespace derangements\n\n/-- Derangements on a subtype are equivalent to permutations on the original type where points are\nfixed iff they are not in the subtype. -/\nprotected def subtypeEquiv (p : α → Prop) [DecidablePred p] :\n derangements (Subtype p) ≃ { f : Perm α // ∀ a, ¬p a ↔ a ∈ fixedPoints f } :=\n calc\n derangements (Subtype p) ≃ { f : { f : Perm α // ∀ a, ¬p a → a ∈ fixedPoints f } //\n ∀ a, a ∈ fixedPoints f → ¬p a } := by\n refine (Perm.subtypeEquivSubtypePerm p).subtypeEquiv fun f => ⟨fun hf a hfa ha => ?_, ?_⟩\n · refine hf ⟨a, ha⟩ (Subtype.ext ?_)\n simp_rw [mem_fixedPoints, IsFixedPt, Perm.subtypeEquivSubtypePerm,\n Equiv.coe_fn_mk, Perm.ofSubtype_apply_of_mem _ ha] at hfa\n assumption\n rintro hf ⟨a, ha⟩ hfa\n refine hf _ ?_ ha\n simp only [Perm.subtypeEquivSubtypePerm_apply_coe, mem_fixedPoints]\n dsimp [IsFixedPt]\n simp_rw [Perm.ofSubtype_apply_of_mem _ ha, hfa]\n _ ≃ { f : Perm α // ∃ _h : ∀ a, ¬p a → a ∈ fixedPoints f, ∀ a, a ∈ fixedPoints f → ¬p a } :=\n subtypeSubtypeEquivSubtypeExists _ _\n _ ≃ { f : Perm α // ∀ a, ¬p a ↔ a ∈ fixedPoints f } :=\n subtypeEquivRight fun f => by\n simp_rw [exists_prop, ← forall_and, ← iff_iff_implies_and_implies]\n\nuniverse u\n/-- The set of permutations that fix either `a` or nothing is equivalent to the sum of:\n- derangements on `α`\n- derangements on `α` minus `a`. -/\ndef atMostOneFixedPointEquivSum_derangements [DecidableEq α] (a : α) :\n { f : Perm α // fixedPoints f ⊆ {a} } ≃ (derangements ({a}ᶜ : Set α)) ⊕ (derangements α) :=\n calc\n { f : Perm α // fixedPoints f ⊆ {a} } ≃\n { f : { f : Perm α // fixedPoints f ⊆ {a} } // a ∈ fixedPoints f } ⊕\n { f : { f : Perm α // fixedPoints f ⊆ {a} } // a ∉ fixedPoints f } :=\n (Equiv.sumCompl _).symm\n _ ≃ { f : Perm α // fixedPoints f ⊆ {a} ∧ a ∈ fixedPoints f } ⊕\n { f : Perm α // fixedPoints f ⊆ {a} ∧ a ∉ fixedPoints f } := by\n refine Equiv.sumCongr ?_ ?_\n · exact subtypeSubtypeEquivSubtypeInter\n (fun x : Perm α => fixedPoints x ⊆ {a})\n (a ∈ fixedPoints ·)\n · exact subtypeSubtypeEquivSubtypeInter\n (fun x : Perm α => fixedPoints x ⊆ {a})\n (a ∉ fixedPoints ·)\n _ ≃ { f : Perm α // fixedPoints f = {a} } ⊕ { f : Perm α // fixedPoints f = ∅ } := by\n refine Equiv.sumCongr (subtypeEquivRight fun f => ?_) (subtypeEquivRight fun f => ?_)\n · rw [Set.eq_singleton_iff_unique_mem, and_comm]\n rfl\n · rw [Set.eq_empty_iff_forall_notMem]\n exact ⟨fun h x hx => h.2 (h.1 hx ▸ hx), fun h => ⟨fun x hx => (h _ hx).elim, h _⟩⟩\n _ ≃ derangements ({a}ᶜ : Set α) ⊕ derangements α := by\n refine\n Equiv.sumCongr ((derangements.subtypeEquiv _).trans <|\n subtypeEquivRight fun x => ?_).symm\n (subtypeEquivRight fun f => mem_derangements_iff_fixedPoints_eq_empty.symm)\n rw [eq_comm, Set.ext_iff]\n simp_rw [Set.mem_compl_iff, Classical.not_not]\n\nnamespace Equiv\n\nvariable [DecidableEq α]\n\n/-- The set of permutations `f` such that the preimage of `(a, f)` under\n`Equiv.Perm.decomposeOption` is a derangement. -/\ndef RemoveNone.fiber (a : Option α) : Set (Perm α) :=\n { f : Perm α | (a, f) ∈ Equiv.Perm.decomposeOption '' derangements (Option α) }\n\nTarget:\ntheorem RemoveNone.mem_fiber (a : Option α) (f : Perm α) :\n f ∈ RemoveNone.fiber a ↔\n ∃ F : Perm (Option α), F ∈ derangements (Option α) ∧ F none = a ∧ removeNone F = f :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_1b1dc83866b4","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"d32636cc6a515be467753211975aa23f1236f3734c1eaefdfe22a0a1bd0ee260","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Derangements","family_id":"removenone","file_id":"mathlib/Mathlib/Combinatorics/Derangements/Basic.lean","sample_id":"1b1dc83866b44921ff69681b932b284279c83a51731f2c627f731ad11176b5b7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7b4003e846db02e4042f455413073cdd2527f085a3fc82f898c0dedf4f118fd0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6b57942086fae1ec57fd3a6b05d9873e8cd49d686970a0b0ce9eab931c397ec4","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a93572d00e3b15ac0e868b16faf2de7151ef159546024bf00b541a88cc14acad","source_sha256":"c30a3d4b1c42fcb7d8e6bf63ba23497757e589a03ca883e3c4dcb6c17db24a2c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨y, hy, hdist⟩ := D.isCover_coveringRadius (x := x) (by trivial)\n exact ⟨y, hy, by simpa [edist_dist] using hdist⟩","hard_negative":false,"metrics":{"chosen_tokens":36,"rejected_tokens":41,"token_jaccard":0.814815,"token_length_ratio":1.138889},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"3ead7db826c37bf0616c2b47f615e4e82abd7eb8f5a56abfcc73518ded8c527d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.MetricSpace.Cover\n\nNamespace:\nDelone.DeloneSet\n\nLocal context:\n/-\nCopyright (c) 2026 Newell Jensen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Newell Jensen\n-/\n/-!\n# Delone sets\n\nA **Delone set** `D ⊆ X` in a metric space is a set which is both:\n\n* **Uniformly Discrete**: there exists `packingRadius > 0` such that distinct points of `D`\n are separated by a distance strictly greater than `packingRadius`;\n* **Relatively Dense**: there exists `coveringRadius > 0` such that every point of `X`\n lies within distance `coveringRadius` of some point of `D`.\n\nThe `DeloneSet` structure stores the set together with explicit radii witnessing\nthese properties. The definitions use metric entourages so that the theory fits\nnaturally into the uniformity framework.\n\nDelone sets appear in discrete geometry, crystallography, aperiodic order, and tiling theory.\n\n## Main definitions\n\n* `Delone.DeloneSet X`: The main structure representing a Delone set in a metric space `X`.\n* `DeloneSet.mapBilipschitz`: Transports a Delone set along a bilipschitz equivalence,\n scaling the radii.\n* `DeloneSet.mapIsometry` Preserves the packing and covering radii exactly.\n\n## Basic properties\n\n* `packingRadius_lt_dist_of_mem_ne` : Distinct points in a Delone set are further apart than\n the packing radius.\n* `exists_dist_le_coveringRadius` : Every point of the space lies within the covering radius\n of the set.\n* `subset_ball_singleton` : Any ball of sufficiently small radius contains at most one point of\n the set.\n\n## Implementation notes\n\n* **Bundled Structure**: `DeloneSet` is bundled as a structure rather than a predicate\n (e.g., `IsDelone`). This facilitates dynamical systems constructions like hulls and patches by\n ensuring operations automatically preserve the required properties, eliminating the need to\n manually pass around proofs that the set remains Delone.\n* **Explicit Data**: Since radii are stored as explicit data, the map from `DeloneSet X` to `Set X`\n is not injective. We provide a `Membership` instance and `mem_carrier` to allow the convenience\n of `∈` notation while ensuring radii remain bundled, computationally accessible, and tracked by\n extensionality.\n-/\n\n@[expose] public section\n\nopen Metric\nopen scoped NNReal\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nnamespace Delone\n\n/-- A **Delone set** consists of a set together with explicit radii\nwitnessing uniform discreteness and relative denseness. -/\n@[ext]\nstructure DeloneSet (X : Type*) [MetricSpace X] where\n /-- The underlying set. -/\n carrier : Set X\n /-- Radius such that distinct points of `carrier` are separated by more than `r`. -/\n packingRadius : ℝ≥0\n packingRadius_pos : 0 < packingRadius\n isSeparated_packingRadius : IsSeparated packingRadius carrier\n /-- Radius such that every point of the space is within `R` of `carrier`. -/\n coveringRadius : ℝ≥0\n coveringRadius_pos : 0 < coveringRadius\n isCover_coveringRadius : IsCover coveringRadius .univ carrier\n\nnamespace DeloneSet\n\n/-- The underlying set of points of a Delone set. -/\n@[coe] def toSet (D : DeloneSet X) : Set X := D.carrier\n\ninstance : Coe (DeloneSet X) (Set X) where\n coe := DeloneSet.toSet\n\ninstance : Membership X (DeloneSet X) where\n mem D x := x ∈ (D : Set X)\n\n@[simp, norm_cast]\nlemma mem_coe {D : DeloneSet X} {x : X} : x ∈ (D : Set X) ↔ x ∈ D := .rfl\n\n@[simp] lemma mem_carrier {D : DeloneSet X} {x : X} :\n x ∈ D.carrier ↔ x ∈ D := .rfl\n\nlemma nonempty [Nonempty X] (D : DeloneSet X) : (D : Set X).Nonempty :=\n D.isCover_coveringRadius.nonempty Set.univ_nonempty\n\n/-- Copy of a Delone set with new fields equal to the old ones.\nUseful to fix definitional equalities. -/\nprotected def copy (D : DeloneSet X) (carrier : Set X) (packingRadius coveringRadius : ℝ≥0)\n (h_carrier : carrier = D.carrier) (h_packing : packingRadius = D.packingRadius)\n (h_covering : coveringRadius = D.coveringRadius) :\n DeloneSet X where\n carrier := carrier\n packingRadius := packingRadius\n packingRadius_pos := by simpa [h_packing] using D.packingRadius_pos\n isSeparated_packingRadius := by\n simpa [h_carrier, h_packing] using D.isSeparated_packingRadius\n coveringRadius := coveringRadius\n coveringRadius_pos := by simpa [h_covering] using D.coveringRadius_pos\n isCover_coveringRadius := by\n simpa [h_carrier, h_covering] using D.isCover_coveringRadius\n\ntheorem copy_eq (D : DeloneSet X)\n (carrier packingRadius coveringRadius h_carrier h_packing h_covering) :\n D.copy carrier packingRadius coveringRadius h_carrier h_packing h_covering = D :=\n DeloneSet.ext h_carrier h_packing h_covering\n\nlemma packingRadius_lt_dist_of_mem_ne (D : DeloneSet X) {x y : X}\n (hx : x ∈ D) (hy : y ∈ D) (hne : x ≠ y) :\n D.packingRadius < dist x y := by\n have hsep : ENNReal.ofReal D.packingRadius < ENNReal.ofReal (dist x y) := by\n simpa [edist_dist] using D.isSeparated_packingRadius hx hy hne\n exact (ENNReal.ofReal_lt_ofReal_iff (h := dist_pos.mpr hne)).1 hsep\n\nTarget:\nlemma exists_dist_le_coveringRadius (D : DeloneSet X) (x : X) :\n ∃ y ∈ D, dist x y ≤ D.coveringRadius :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n obtain ⟨y, hy, hdist⟩ := D.isCover_coveringRadius (x := x) (by trivial)\n exact ⟨y, hy, by simpa [edist_dist] using hdist⟩","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/AperiodicOrder","family_id":"exists_dist_le_coveringradius","file_id":"mathlib/Mathlib/Analysis/AperiodicOrder/Delone/Basic.lean","sample_id":"a93572d00e3b15ac0e868b16faf2de7151ef159546024bf00b541a88cc14acad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"060dddeef280a6dc6216754acde1d7a82b6261bb11566ff22b1c2132db22fefe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"19023025525198e7a926d51de673115fae9f0c35ed6213aa87a48fcd16099086","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f4d5dbeb4ecbfce13f8303d07c10da1b35578c4c90953c6ec1ea9c00e130c216","source_sha256":"02d9d7bede062982511bfb44d2ffb029197390fd0d9b35d6bc34757ad110e59c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [avgRisk_fintype' hℓ]","hard_negative":true,"metrics":{"chosen_tokens":7,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.428571},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"3f06c341c322ea4801e9494ae1dc6603553daed9cb2255bc0bfdbeb92a263a5b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Decision.Risk.Defs\nimport Mathlib.Probability.Decision.Risk.Basic\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Risk in countable spaces\n\nIn countable spaces, we can write integrals as sums, hence we can write the average or Bayes risk\nwith sums instead of integrals.\n\n-/\n\npublic section\n\nopen MeasureTheory Function\nopen scoped ENNReal NNReal\n\nnamespace ProbabilityTheory\n\nvariable {Θ Θ' 𝓧 𝓧' 𝓨 : Type*} {mΘ : MeasurableSpace Θ} {mΘ' : MeasurableSpace Θ'}\n {m𝓧 : MeasurableSpace 𝓧} {m𝓧' : MeasurableSpace 𝓧'} {m𝓨 : MeasurableSpace 𝓨}\n {ℓ : Θ → 𝓨 → ℝ≥0∞} {P : Kernel Θ 𝓧} {κ : Kernel 𝓧 𝓨} {π : Measure Θ}\n\nlemma avgRisk_countable [Countable Θ] [MeasurableSingletonClass Θ] :\n avgRisk ℓ P κ π = ∑' θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [avgRisk, lintegral_countable']\n\nlemma avgRisk_fintype [Fintype Θ] [MeasurableSingletonClass Θ] :\n avgRisk ℓ P κ π = ∑ θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [avgRisk, lintegral_fintype]\n\nlemma avgRisk_countable' [Countable 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n avgRisk ℓ P κ π = ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp only [avgRisk, lintegral_countable']\n rw [lintegral_tsum]\n · rfl\n · refine fun y ↦ Measurable.aemeasurable ?_\n exact Measurable.mul (by fun_prop) ((κ ∘ₖ P).measurable_coe (measurableSet_singleton y))\n\nlemma avgRisk_fintype' [Fintype 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n avgRisk ℓ P κ π = ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n rw [avgRisk_countable' hℓ, tsum_fintype]\n\nlemma bayesRisk_countable [Countable Θ] [MeasurableSingletonClass Θ] :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑' θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [bayesRisk, avgRisk_countable]\n\nlemma bayesRisk_fintype [Fintype Θ] [MeasurableSingletonClass Θ] :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑ θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [bayesRisk, avgRisk_fintype]\n\nlemma bayesRisk_countable' [Countable 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp [bayesRisk, avgRisk_countable' hℓ]\n\nlemma bayesRisk_fintype' [Fintype 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp [bayesRisk, avgRisk_fintype' hℓ]\n\nsection Const\n\nlemma avgRisk_const_of_countable [Countable 𝓨] [MeasurableSingletonClass 𝓨]\n (hℓ : Measurable ℓ) (μ : Measure 𝓧) (κ : Kernel 𝓧 𝓨) (π : Measure Θ) :\n avgRisk ℓ (Kernel.const Θ μ) κ π = ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ μ) {y} ∂π := by\n simp [avgRisk_countable' hℓ]\n\nTarget:\nlemma avgRisk_const_of_fintype [Fintype 𝓨] [MeasurableSingletonClass 𝓨]\n (hℓ : Measurable ℓ) (μ : Measure 𝓧) (κ : Kernel 𝓧 𝓨) (π : Measure Θ) :\n avgRisk ℓ (Kernel.const Θ μ) κ π = ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ μ) {y} ∂π :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_f4d5dbeb4ecb","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"91e9dd5b350101030ac81285ed680c94311011bb0f13b17e60d12795b1abff4f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Decision","family_id":"avgrisk_const_of_fintype","file_id":"mathlib/Mathlib/Probability/Decision/Risk/Countable.lean","sample_id":"f4d5dbeb4ecbfce13f8303d07c10da1b35578c4c90953c6ec1ea9c00e130c216"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d28c744573cbd912e935cdf2d8d8e3831400e3ac90187b57895a593edb6ccec6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8bcec96d1dc324efafa5957b1703b5629c59f8314f59431e77e4205596ff344a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"10519652ea9bdadc30cb78a3e7cc9a834c7c7f48bd8153e93a3546df65c6a95a","source_sha256":"78722ac35abaf2b426eb18d35b60539a431bd4ad639256905b6661437efc9fcc","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨n, s, h⟩ := Module.Finite.exists_fin (R := R) (M := M)\n rw [← Set.countable_univ_iff]\n have : Countable (Submodule.span R (Set.range s)) := inferInstance\n rwa [h] at this","hard_negative":false,"metrics":{"chosen_tokens":55,"rejected_tokens":59,"token_jaccard":0.916667,"token_length_ratio":1.072727},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"3f56aeaaaf2f5970e7eeddd9f42fd30c470f62f1e2303662ca721f03428f40db","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finsupp.Encodable\npublic import Mathlib.Data.Set.Countable\npublic import Mathlib.LinearAlgebra.Finsupp.LinearCombination\npublic import Mathlib.RingTheory.Finiteness.Defs\n\nNamespace:\nFinsupp\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\n/-!\n# Countable modules\n-/\n\npublic section\n\nnoncomputable section\n\nnamespace Finsupp\n\nvariable {M : Type*} {R : Type*} [Semiring R] [AddCommMonoid M] [Module R M]\n\n/-- If `R` is countable, then any `R`-submodule spanned by a countable family of vectors is\ncountable. -/\ninstance {ι : Type*} [Countable R] [Countable ι] (v : ι → M) :\n Countable (Submodule.span R (Set.range v)) := by\n refine Set.countable_coe_iff.mpr (Set.Countable.mono ?_ (Set.countable_range\n (fun c : (ι →₀ R) => c.sum fun i _ => (c i) • v i)))\n exact fun _ h => Finsupp.mem_span_range_iff_exists_finsupp.mp (SetLike.mem_coe.mp h)\n\nTarget:\ntheorem Countable.of_moduleFinite [Countable R] [Module.Finite R M] : Countable M :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n obtain ⟨n, s, h⟩ := Module.Finite.exists_fin (R := R) (M := M)\n rw [← Set.countable_univ_iff]\n have : Countable (Submodule.span R (Set.range s)) := inferInstance\n rwa [h] at this","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra","family_id":"countable","file_id":"mathlib/Mathlib/LinearAlgebra/Countable.lean","sample_id":"10519652ea9bdadc30cb78a3e7cc9a834c7c7f48bd8153e93a3546df65c6a95a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c7447d6b7ef5b2499552f0a9ea2c10ee3982f942ee24fb3733f29cf9d6fb4bcc","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3ce96acfb04dbc12ad341c07ff30b17b76c023a8f28c2048ea4a7e7e61f94a7d","source_sha256":"c8a33bb8cce3962f230d95a94382ba6537d37e619b16dfe9b8c1fe283237e032","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [← SetLike.coe_set_eq]","hard_negative":false,"metrics":{"chosen_tokens":8,"rejected_tokens":2,"token_jaccard":0.111111,"token_length_ratio":0.25},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"4097383dde138f79e36ae063536b08e7b6ddf20b5a30e12004b28843ad033e31","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.GroupTheory.Subsemigroup.Center\npublic import Mathlib.RingTheory.NonUnitalSubring.Defs\npublic import Mathlib.RingTheory.NonUnitalSubsemiring.Basic\n\nNamespace:\nNonUnitalSubring\n\nLocal context:\n/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n/-!\n# `NonUnitalSubring`s\n\nLet `R` be a non-unital ring.\nWe prove that non-unital subrings 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 `NonUnitalSubring R`, sending a subset of\n`R` to the non-unital subring it generates, and prove that it is a Galois insertion.\n\n## Main definitions\n\nNotation used here:\n\n`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`\n`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`\n\n* `instance : CompleteLattice (NonUnitalSubring R)` : the complete lattice structure on the\n non-unital subrings.\n\n* `NonUnitalSubring.center` : the center of a non-unital ring `R`.\n\n* `NonUnitalSubring.closure` : non-unital subring closure of a set, i.e., the smallest\n non-unital subring that includes the set.\n\n* `NonUnitalSubring.gi` : `closure : Set M → NonUnitalSubring M` and coercion\n `coe : NonUnitalSubring M → Set M`\n form a `GaloisInsertion`.\n\n* `comap f B : NonUnitalSubring A` : the preimage of a non-unital subring `B` along the\n non-unital ring homomorphism `f`\n\n* `map f A : NonUnitalSubring B` : the image of a non-unital subring `A` along the\n non-unital ring homomorphism `f`.\n\n* `Prod A B : NonUnitalSubring (R × S)` : the product of non-unital subrings\n\n* `f.range : NonUnitalSubring B` : the range of the non-unital ring homomorphism `f`.\n\n* `eq_locus f g : NonUnitalSubring R` : given non-unital ring homomorphisms `f g : R →ₙ+* S`,\n the non-unital subring of `R` where `f x = g x`\n\n## Implementation notes\n\nA non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an\nadditive subgroup.\n\nLattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although\n`∈` is defined as membership of a non-unital subring's underlying set.\n\n## Tags\nnon-unital subring\n-/\n\n@[expose] public section\n\n\nuniverse u v w\n\nsection Basic\n\nvariable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]\n\nnamespace NonUnitalSubring\n\nvariable (s : NonUnitalSubring R)\n\n/-- Sum of a list of elements in a non-unital subring is in the non-unital subring. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=\n list_sum_mem\n\n/-- Sum of a multiset of elements in a `NonUnitalSubring` of a `NonUnitalRing` is\nin the `NonUnitalSubring`. -/\nprotected theorem multiset_sum_mem {R} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=\n multiset_sum_mem _\n\n/-- Sum of elements in a `NonUnitalSubring` of a `NonUnitalRing` indexed by a `Finset`\nis in the `NonUnitalSubring`. -/\nprotected theorem sum_mem {R : Type*} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n {ι : Type*} {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∑ i ∈ t, f i) ∈ s :=\n sum_mem h\n\n/-! ## top -/\n\n\n/-- The non-unital subring `R` of the ring `R`. -/\ninstance : Top (NonUnitalSubring R) :=\n ⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubgroup R) with }⟩\n\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubring R) :=\n Set.mem_univ x\n\n@[simp]\ntheorem coe_top : ((⊤ : NonUnitalSubring R) : Set R) = Set.univ :=\n rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_top : (⊤ : NonUnitalSubring R).toNonUnitalSubsemiring = ⊤ := rfl\n\n@[simp] lemma toAddSubgroup_top : (⊤ : NonUnitalSubring R).toAddSubgroup = ⊤ := rfl\n\n@[simp]\n\nTarget:\nlemma toNonUnitalSubsemiring_eq_top {S : NonUnitalSubring R} :\n S.toNonUnitalSubsemiring = ⊤ ↔ S = ⊤ :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/NonUnitalSubring","family_id":"tononunitalsubsemiring_eq_top","file_id":"mathlib/Mathlib/RingTheory/NonUnitalSubring/Basic.lean","sample_id":"3ce96acfb04dbc12ad341c07ff30b17b76c023a8f28c2048ea4a7e7e61f94a7d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"53047500b7c382ff7eb46afaca5559abff17a015ca4956ed5b93309713ab7a37","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8e52f7e7d4abc1cbadcfeac6b0697214ff0be1711917c1f7f7c52bd06eea013c","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]","hard_negative":false,"metrics":{"chosen_tokens":33,"rejected_tokens":3,"token_jaccard":0.041667,"token_length_ratio":0.090909},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"40a81f85ed4023404c51aa9ea6f352df319b311206f4e682bfad11ea60db167c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nTarget:\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"8e52f7e7d4abc1cbadcfeac6b0697214ff0be1711917c1f7f7c52bd06eea013c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e2d0eb1061c28564b13ac9438a2f1e865121d76a9bcfc8384b6637eb94e69716","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a612a3692a4ac846073a03e162d2b14004d764ba83f8274c66dd9508374681a0","source_sha256":"a0c4f879a338ab6470bdd61aa6cb4790c1abee3840d61f2c802fcb6c81cb3ac9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · exact codRestrictEqLocusPushoutCocone.injective_of_faithfulSMul _ _\n · exact codRestrictEqLocusPushoutCocone.surjective_of_isEffective _ _ (.of_faithfullyFlat R S)","hard_negative":true,"metrics":{"chosen_tokens":22,"rejected_tokens":8,"token_jaccard":0.05,"token_length_ratio":0.363636},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"40cdb4a60d8b4ca1bbdaade6738a41d401c620d171a06240674bfda9b0358412","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Ring.Constructions\npublic import Mathlib.RingTheory.Flat.FaithfullyFlat.Algebra\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2025 Yong-Gyu Choi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yong-Gyu Choi\n-/\n/-!\n# Exactness properties of the difference map on tensor products\n\nFor an `R`-algebra `S`, we collect some properties of the `R`-linear map `S →ₗ[R] S ⊗[R] S` given\nby `s ↦ s ⊗ₜ 1 - 1 ⊗ₜ s`.\n\n## Main definitions\n\n* `includeLeftSubRight`: The `R`-linear map sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`.\n* `IsEffective`: Exactness of the sequence `R → S → S ⊗[R] S` where the first map is\n `Algebra.linearMap R S` and the second map is `includeLeftSubRight`. When `R` and `S` are\n commutative rings, this is equivalent to the inclusion `im (algebraMap : R → S) → S` being an\n effective monomorphism in `CommRingCat`.\n\n## Main results\n\n* `IsEffective.of_faithfullyFlat`: `IsEffective R S` is true for any faithfully flat `R`-algebra `S`\n\n-/\n\n@[expose] public section\n\nopen scoped TensorProduct\n\nnamespace Algebra\n\nvariable {R : Type*} [CommSemiring R]\nvariable {S : Type*} [Ring S] [Algebra R S]\n\nnamespace TensorProduct\n\nsection IncludeLeftSubRight\n\nvariable (R S) in\n/-- The `R`-linear map `S →ₗ[R] S ⊗[R] S` sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`. -/\ndef includeLeftSubRight : S →ₗ[R] S ⊗[R] S :=\n includeLeft.toLinearMap - includeRight.toLinearMap\n\n@[simp]\nlemma includeLeftSubRight_apply (s : S) : includeLeftSubRight R S s = s ⊗ₜ[R] 1 - 1 ⊗ₜ[R] s :=\n rfl\n\n/-- `includeLeftSubRight R S` vanishes in the range of `algebraMap R S`. -/\nlemma includeLeftSubRight_zero_of_mem_range {s : S} (hs : s ∈ Set.range ⇑(algebraMap R S)) :\n includeLeftSubRight R S s = 0 := by\n obtain ⟨_, hr⟩ := Set.mem_range.mp hs\n simp [← hr, algebraMap_eq_smul_one]\n\n/-- `includeLeftSubRight R S` vanishes at `algebraMap R S r`. -/\nlemma includeLeftSubRight_algebraMap_zero (r : R) :\n includeLeftSubRight R S (algebraMap R S r) = 0 :=\n includeLeftSubRight_zero_of_mem_range (Set.mem_range.mp (exists_apply_eq_apply _ _))\n\n/-- `includeLeftSubRight` is compatible with `distribBaseChange` and `lTensor`. -/\nlemma distribBaseChange_comp_includeLeftSubRight (T : Type*) [CommRing T] [Algebra R T] :\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).restrictScalars R).toLinearMap ∘ₗ\n (includeLeftSubRight R S).lTensor T =\n (includeLeftSubRight T (T ⊗[R] S)).restrictScalars R := by\n ext\n simp [TensorProduct.tmul_sub, TensorProduct.one_def, tmul_one_tmul_one_tmul]\n\n@[simp]\nlemma distribBaseChange_includeLeftSubRight_apply (T : Type*) [CommRing T] [Algebra R T]\n (x : T ⊗[R] S) :\n TensorProduct.AlgebraTensorModule.distribBaseChange R T S S\n ((includeLeftSubRight R S).lTensor T x) =\n includeLeftSubRight T (T ⊗[R] S) x :=\n congr($(distribBaseChange_comp_includeLeftSubRight _) x)\n\nend IncludeLeftSubRight\n\nend TensorProduct\n\nvariable (R S) in\n/-- For an `R`-algebra `S`, this asserts that the maps `algebraMap : R → S` and\n`includeLeftSubRight R S : S → S ⊗[R] S` form an exact pair.\nWhen `R` and `S` are commutative rings, this is true if and only if the inclusion\n`im (algebraMap : R → S) → S` is an effective monomorphism in the category of commutative rings. -/\ndef IsEffective : Prop :=\n Function.Exact (Algebra.linearMap R S) (TensorProduct.includeLeftSubRight R S)\n\nnamespace IsEffective\n\n/-- If `IsEffective R S` is true, then the equalizer of `s ↦ s ⊗ₜ 1 : S →+* S ⊗[R] S` and\n`s ↦ 1 ⊗ₜ s : S →+* S ⊗[R] S` is the image of `algebraMap R S : R →+* S`. -/\nlemma eqLocus_includeLeft_includeRight (h : IsEffective R S) :\n TensorProduct.includeLeftRingHom.eqLocus TensorProduct.includeRight.toRingHom (S := S ⊗[R] S) =\n Set.range (algebraMap R S) := by\n ext s\n refine ⟨?_, fun ⟨_, hr⟩ ↦ by simp [← hr]⟩\n intro hs\n exact (h s).mp <| (TensorProduct.includeLeftSubRight_apply (R := R) s).symm ▸ sub_eq_zero.mpr hs\n\n/-- `IsEffective` is true for any `R`-algebra `S` having an `R`-algebra section of\n`Algebra.ofId _ _ : R →ₐ[R] S`. -/\nlemma of_section (g : S →ₐ[R] R) : IsEffective R S := by\n intro s\n refine ⟨?_, TensorProduct.includeLeftSubRight_zero_of_mem_range⟩\n intro hs\n use g s\n apply (TensorProduct.lid R S).symm.injective\n rw [TensorProduct.lid_symm_apply, TensorProduct.lid_symm_apply,\n ← mul_one ((Algebra.linearMap R S) _), Algebra.coe_linearMap, ← Algebra.smul_def,\n ← TensorProduct.smul_tmul, smul_eq_mul, mul_one, ← AlgHom.id_apply (R := R) (1 : S),\n ← TensorProduct.map_tmul,\n sub_eq_zero.mp ((TensorProduct.includeLeftSubRight_apply s).symm.trans hs),\n TensorProduct.map_tmul, map_one, AlgHom.id_apply]\n\nsection FaithfullyFlat\n\nvariable (R : Type*) [CommRing R]\nvariable (S : Type*)\nvariable (T : Type*) [CommRing T] [Algebra R T]\n\n/-- `IsEffective` descends along faithfully flat algebras. -/\nlemma of_isEffective_tensorProduct_of_faithfullyFlat\n [Ring S] [Algebra R S] [Module.FaithfullyFlat R T] (h : IsEffective T (T ⊗[R] S)) :\n IsEffective R S := by\n refine Module.FaithfullyFlat.lTensor_reflects_exact _ _ _ _ <|\n AddMonoidHom.exact_iff_of_surjective_of_bijective_of_injective\n ((Algebra.linearMap R S).lTensor T) ((TensorProduct.includeLeftSubRight R S).lTensor T)\n (Algebra.linearMap T (T ⊗[R] S)) (TensorProduct.includeLeftSubRight T (T ⊗[R] S))\n (TensorProduct.rid R R T).toAddMonoidHom (AddMonoidHom.id (T ⊗[R] S))\n (TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).toAddMonoidHom ?_ ?_\n (TensorProduct.rid R R T).surjective Function.bijective_id\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).injective) |>.mpr ‹_›\n · ext\n simp [← Algebra.TensorProduct.linearMap_comp_rid]\n -- The goal is TensorProduct.rid .. = TensorProduct.AlgebraTensorModule.rid ..\n -- TODO: merge both into one definition, and remove the rfl.\n rfl\n · ext\n simp\n\n/-- `IsEffective R S` is true for any faithfully flat `R`-algebra `S`. -/\nlemma of_faithfullyFlat [CommRing S] [Algebra R S] [Module.FaithfullyFlat R S] :\n IsEffective R S :=\n of_isEffective_tensorProduct_of_faithfullyFlat _ _ _ (of_section (TensorProduct.lmul'' R))\n\nend FaithfullyFlat\n\nend IsEffective\n\nsection CodRestrictEqLocusPushoutCocone\n\nuniverse u\n\nvariable (R S : Type u) [CommRing R] [CommRing S] [Algebra R S]\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The canonical ring map from `R` to the explicit equalizer of\n`includeLeft : S ⟶ S ⊗[R] S` and `includeRight : S ⟶ S ⊗[R] S`. -/\ndef codRestrictEqLocusPushoutCocone :\n R →+* (CommRingCat.equalizerFork\n (CommRingCat.pushoutCocone R S S).inl (CommRingCat.pushoutCocone R S S).inr).pt :=\n RingHom.codRestrict (algebraMap R S)\n ((CommRingCat.pushoutCocone R S S).inl.hom.eqLocus (CommRingCat.pushoutCocone R S S).inr.hom)\n (by simp)\n\n/-- Injectivity of `algebraMap R S` implies injectivity of `codRestrictEqLocusPushoutCocone`. -/\nlemma codRestrictEqLocusPushoutCocone.injective_of_faithfulSMul [FaithfulSMul R S] :\n Function.Injective (codRestrictEqLocusPushoutCocone R S) :=\n RingHom.injective_codRestrict.mpr (FaithfulSMul.algebraMap_injective _ _)\n\n/-- `Algebra.IsEffective R S` implies surjectivity of `codRestrictEqLocusPushoutCocone`. -/\nlemma codRestrictEqLocusPushoutCocone.surjective_of_isEffective (hf : Algebra.IsEffective R S) :\n Function.Surjective (codRestrictEqLocusPushoutCocone R S) := by\n intro ⟨s, hs⟩\n obtain ⟨t, rfl⟩ := Set.mem_range.mp <|\n Algebra.IsEffective.eqLocus_includeLeft_includeRight hf ▸ SetLike.mem_coe.mpr hs\n exact ⟨t, rfl⟩\n\n/-- If `S` is a faithfully flat `R`-algebra, `codRestrictEqLocusPushoutCocone` is bijective. -/\n\nTarget:\nlemma codRestrictEqLocusPushoutCocone.bijective_of_faithfullyFlat [Module.FaithfullyFlat R S] :\n Function.Bijective (codRestrictEqLocusPushoutCocone R S) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"0dab86b817d6db97f4ed0d7a1d2af56f6cd592c56757af2c023aef9893bc282f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/TensorProduct","family_id":"codrestricteqlocuspushoutcocone","file_id":"mathlib/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean","sample_id":"a612a3692a4ac846073a03e162d2b14004d764ba83f8274c66dd9508374681a0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"feafaa3bb07bd5457e9a390cbaab0163ff18cc790026c510e20f83437d157626","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"73c2d20150cd35c63c37ab95709b930659d675aa4ebe1e64bb85e30678fdecda","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bc78bf768f8b4dd1496d36a83703054152a59db89d8cd0de9554de53327fee5a","source_sha256":"c8dece265e2164323e741d2898bece661865ebee891ab28a390ba26cfdb86441","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := DFunLike.congr_fun (toBaseChange_comp_reverseOp A Q) x\n refine (congr_arg unop this).trans ?_; clear this\n refine (LinearMap.congr_fun (TensorProduct.AlgebraTensorModule.map_comp _ _ _ _).symm _).trans ?_\n rw [reverse, AlgEquiv.toAlgHom_toLinearMap, AlgEquiv.toLinearEquiv_toOpposite]\n dsimp\n -- `simp` fails here due to a timeout looking for a `Subsingleton` instance!?\n rw [LinearEquiv.self_trans_symm]\n rfl","hard_negative":true,"metrics":{"chosen_tokens":89,"rejected_tokens":2,"token_jaccard":0.018868,"token_length_ratio":0.022472},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"41128f52bd7ac1e198f56908cf22a0b8834903b4ab2f7bc2f4bc6bf2f545b7a2","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.QuadraticForm.TensorProduct\npublic import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation\npublic import Mathlib.LinearAlgebra.TensorProduct.Opposite\npublic import Mathlib.RingTheory.TensorProduct.Basic\n\nNamespace:\nCliffordAlgebra\n\nLocal context:\n/-\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/-!\n# The base change of a clifford algebra\n\nIn this file we show the isomorphism\n\n* `CliffordAlgebra.equivBaseChange A Q` :\n `CliffordAlgebra (Q.baseChange A) ≃ₐ[A] (A ⊗[R] CliffordAlgebra Q)`\n with forward direction `CliffordAlgebra.toBaseChange A Q` and reverse direction\n `CliffordAlgebra.ofBaseChange A Q`.\n\nThis covers a more general case of the complexification of clifford algebras (as described in §2.2\nof https://empg.maths.ed.ac.uk/Activities/Spin/Lecture2.pdf), where ℂ and ℝ are replaced by an\n`R`-algebra `A` (where `2 : R` is invertible).\n\nWe show the additional results:\n\n* `CliffordAlgebra.toBaseChange_ι`: the effect of base-changing pure vectors.\n* `CliffordAlgebra.ofBaseChange_tmul_ι`: the effect of un-base-changing a tensor of a pure vectors.\n* `CliffordAlgebra.toBaseChange_involute`: the effect of base-changing an involution.\n* `CliffordAlgebra.toBaseChange_reverse`: the effect of base-changing a reversal.\n-/\n\n@[expose] public section\n\nvariable {R A V : Type*}\nvariable [CommRing R] [CommRing A] [AddCommGroup V]\nvariable [Algebra R A] [Module R V]\nvariable [Invertible (2 : R)]\n\nopen scoped TensorProduct\n\nnamespace CliffordAlgebra\n\nvariable (A)\n\nset_option backward.isDefEq.respectTransparency false in\n/-- Auxiliary construction: note this is really just a heterobasic `CliffordAlgebra.map`. -/\ndef ofBaseChangeAux (Q : QuadraticForm R V) :\n CliffordAlgebra Q →ₐ[R] CliffordAlgebra (Q.baseChange A) :=\n CliffordAlgebra.lift Q <| by\n refine ⟨(ι (Q.baseChange A)).restrictScalars R ∘ₗ TensorProduct.mk R A V 1, fun v => ?_⟩\n refine (CliffordAlgebra.ι_sq_scalar (Q.baseChange A) (1 ⊗ₜ v)).trans ?_\n rw [QuadraticForm.baseChange_tmul, one_mul, ← Algebra.algebraMap_eq_smul_one,\n ← IsScalarTower.algebraMap_apply]\n\n@[simp] theorem ofBaseChangeAux_ι (Q : QuadraticForm R V) (v : V) :\n ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (1 ⊗ₜ v) :=\n CliffordAlgebra.lift_ι_apply _ _ v\n\nset_option backward.isDefEq.respectTransparency false in\n/-- Convert from the base-changed clifford algebra to the clifford algebra over a base-changed\nmodule. -/\ndef ofBaseChange (Q : QuadraticForm R V) :\n A ⊗[R] CliffordAlgebra Q →ₐ[A] CliffordAlgebra (Q.baseChange A) :=\n Algebra.TensorProduct.lift (Algebra.ofId _ _) (ofBaseChangeAux A Q)\n fun _a _x => Algebra.commutes _ _\n\n@[simp] theorem ofBaseChange_tmul_ι (Q : QuadraticForm R V) (z : A) (v : V) :\n ofBaseChange A Q (z ⊗ₜ ι Q v) = ι (Q.baseChange A) (z ⊗ₜ v) := by\n change algebraMap _ _ z * ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (z ⊗ₜ[R] v)\n rw [ofBaseChangeAux_ι, ← Algebra.smul_def, ← map_smul, TensorProduct.smul_tmul', smul_eq_mul,\n mul_one]\n\n@[simp] theorem ofBaseChange_tmul_one (Q : QuadraticForm R V) (z : A) :\n ofBaseChange A Q (z ⊗ₜ 1) = algebraMap _ _ z := by\n change algebraMap _ _ z * ofBaseChangeAux A Q 1 = _\n rw [map_one, mul_one]\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Convert from the clifford algebra over a base-changed module to the base-changed clifford\nalgebra. -/\ndef toBaseChange (Q : QuadraticForm R V) :\n CliffordAlgebra (Q.baseChange A) →ₐ[A] A ⊗[R] CliffordAlgebra Q :=\n CliffordAlgebra.lift _ <| by\n refine ⟨TensorProduct.AlgebraTensorModule.map (LinearMap.id : A →ₗ[A] A) (ι Q), ?_⟩\n letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm\n letI : Invertible (2 : A ⊗[R] CliffordAlgebra Q) :=\n (Invertible.map (algebraMap R _) 2).copy 2 (map_ofNat _ _).symm\n suffices hpure_tensor : ∀ v w, (1 * 1) ⊗ₜ[R] (ι Q v * ι Q w) + (1 * 1) ⊗ₜ[R] (ι Q w * ι Q v) =\n QuadraticMap.polarBilin (Q.baseChange A) (1 ⊗ₜ[R] v) (1 ⊗ₜ[R] w) ⊗ₜ[R] 1 by\n -- the crux is that by converting to a statement about linear maps instead of quadratic forms,\n -- we then have access to all the partially-applied `ext` lemmas.\n rw [CliffordAlgebra.forall_mul_self_eq_iff (isUnit_of_invertible _)]\n refine TensorProduct.AlgebraTensorModule.curry_injective ?_\n ext v w\n dsimp\n exact hpure_tensor v w\n intro v w\n rw [← TensorProduct.tmul_add, CliffordAlgebra.ι_mul_ι_add_swap,\n QuadraticForm.polarBilin_baseChange, LinearMap.BilinForm.baseChange_tmul, one_mul,\n TensorProduct.smul_tmul, Algebra.algebraMap_eq_smul_one, QuadraticMap.polarBilin_apply_apply]\n\n@[simp] theorem toBaseChange_ι (Q : QuadraticForm R V) (z : A) (v : V) :\n toBaseChange A Q (ι (Q.baseChange A) (z ⊗ₜ v)) = z ⊗ₜ ι Q v :=\n CliffordAlgebra.lift_ι_apply _ _ _\n\ntheorem toBaseChange_comp_involute (Q : QuadraticForm R V) :\n (toBaseChange A Q).comp (involute : CliffordAlgebra (Q.baseChange A) →ₐ[A] _) =\n (Algebra.TensorProduct.map (AlgHom.id _ _) involute).comp (toBaseChange A Q) := by\n ext v\n change toBaseChange A Q (involute (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))\n = (Algebra.TensorProduct.map (AlgHom.id _ _) involute :\n A ⊗[R] CliffordAlgebra Q →ₐ[A] _)\n (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))\n rw [toBaseChange_ι, involute_ι, map_neg (toBaseChange A Q), toBaseChange_ι,\n Algebra.TensorProduct.map_tmul, AlgHom.id_apply, involute_ι, TensorProduct.tmul_neg]\n\n/-- The involution acts only on the right of the tensor product. -/\ntheorem toBaseChange_involute (Q : QuadraticForm R V) (x : CliffordAlgebra (Q.baseChange A)) :\n toBaseChange A Q (involute x) =\n TensorProduct.map LinearMap.id (involute.toLinearMap) (toBaseChange A Q x) :=\n DFunLike.congr_fun (toBaseChange_comp_involute A Q) x\n\nopen MulOpposite\n\n/-- Auxiliary theorem used to prove `toBaseChange_reverse` without needing induction. -/\ntheorem toBaseChange_comp_reverseOp (Q : QuadraticForm R V) :\n (toBaseChange A Q).op.comp reverseOp =\n ((Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q)).toAlgHom.comp <|\n (Algebra.TensorProduct.map\n (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q))).comp\n (toBaseChange A Q)) := by\n ext v\n change op (toBaseChange A Q (reverse (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))) =\n Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q)\n (Algebra.TensorProduct.map (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q))\n (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v))))\n rw [toBaseChange_ι, reverse_ι, toBaseChange_ι, Algebra.TensorProduct.map_tmul,\n Algebra.TensorProduct.opAlgEquiv_tmul, reverseOp_ι]\n rfl\n\n/-- `reverse` acts only on the right of the tensor product. -/\n\nTarget:\ntheorem toBaseChange_reverse (Q : QuadraticForm R V) (x : CliffordAlgebra (Q.baseChange A)) :\n toBaseChange A Q (reverse x) =\n TensorProduct.map LinearMap.id reverse (toBaseChange A Q x) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_bc78bf768f8b","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"cf61d182291764334c7c273c38ce5cb56b5fd22056dbf7b4478d503bb1efe0f0","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/CliffordAlgebra","family_id":"tobasechange_reverse","file_id":"mathlib/Mathlib/LinearAlgebra/CliffordAlgebra/BaseChange.lean","sample_id":"bc78bf768f8b4dd1496d36a83703054152a59db89d8cd0de9554de53327fee5a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5cf6a0d2e46e048d4d7e1c25b5e089b1205c69d56f8cec82499e91c9d0843d6d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f75de35859a6ab675379f98ae98d5c88e7efe5df65e1e22964037a6f30e1f6bd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"80128840662b22e53d1840a39802444548ca6c793df4148c58e604fe82cb2d91","source_sha256":"2c2718794f6ab5e1e4b2caadae5fbbfa623398ededcc8a106c24929950ce1748","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Algebra.smul_def, mul_smul]\n rfl","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":2,"token_jaccard":0.090909,"token_length_ratio":0.2},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"412ae1d76066afa86e7463447e4748396e870844b27790f0802d769d20881a6f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Tower\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# The `RestrictScalars` type alias\n\nSee the documentation attached to the `RestrictScalars` definition for advice on how and when to\nuse this type alias. As described there, it is often a better choice to use the `IsScalarTower`\ntypeclass instead.\n\n## Main definitions\n\n* `RestrictScalars R S M`: the `S`-module `M` viewed as an `R` module when `S` is an `R`-algebra.\n Note that by default we do *not* have a `Module S (RestrictScalars R S M)` instance\n for the original action.\n This is available as a def `RestrictScalars.moduleOrig` if really needed.\n* `RestrictScalars.addEquiv : RestrictScalars R S M ≃+ M`: the additive equivalence\n between the restricted and original space (in fact, they are definitionally equal,\n but sometimes it is helpful to avoid using this fact, to keep instances from leaking).\n* `RestrictScalars.ringEquiv : RestrictScalars R S A ≃+* A`: the ring equivalence\n between the restricted and original space when the module is an algebra.\n* `Module.restrictScalars R S M`, `Algebra.restrictScalars R S A`: non-instance definitions for\n `Module R M` and `Algebra R A`.\n\n## See also\n\nThere are many similarly-named definitions elsewhere which do not refer to this type alias. These\nrefer to restricting the scalar type in a bundled type, such as from `A →ₗ[R] B` to `A →ₗ[S] B`:\n\n* `LinearMap.restrictScalars`\n* `LinearEquiv.restrictScalars`\n* `AlgHom.restrictScalars`\n* `AlgEquiv.restrictScalars`\n* `Submodule.restrictScalars`\n* `Subalgebra.restrictScalars`\n-/\n\n@[expose] public section\n\n\nvariable (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 `RestrictScalars` 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\nvariable (R S M : Type*)\nvariable [CommSemiring R] [Semiring S] [Algebra R S] [AddCommMonoid 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`RestrictScalars` permits it to be written as:\n```lean\n-- an `R`-module structure on `M` is provided by `RestrictScalars` which is compatible\nexample : RestrictScalars R S M →ₗ[R] S := sorry\n```\nHowever, it is usually better just to add this extra structure as an argument:\n```lean\n-- an `R`-module structure on `M` and proof of its compatibility is provided by the user\nexample [Module R M] [IsScalarTower R S M] : M →ₗ[R] S := sorry\n```\nThe advantage of the second approach is that it defers the duty of providing the missing typeclasses\n`[Module R M] [IsScalarTower R S M]`. If some concrete `M` naturally carries these (as is often\nthe case) then we have avoided `RestrictScalars` entirely. If not, we can pass\n`RestrictScalars 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`IsScalarTower` rather than `RestrictScalars`.\n\nAn example of when one might want to use `RestrictScalars` would be if one has a vector space\nover a field of characteristic zero and wishes to make use of the `ℚ`-algebra structure. -/\n@[nolint unusedArguments]\ndef RestrictScalars (_R _S M : Type*) : Type _ := M\n\ninstance [I : Inhabited M] : Inhabited (RestrictScalars R S M) := I\n\ninstance [I : AddCommMonoid M] : AddCommMonoid (RestrictScalars R S M) := I\n\ninstance [I : AddCommGroup M] : AddCommGroup (RestrictScalars R S M) := I\n\nsection Module\n\nsection\n\nvariable [Semiring S] [AddCommMonoid M]\n\n/-- We temporarily install an action of the original ring on `RestrictScalars R S M`. -/\n@[instance_reducible]\ndef RestrictScalars.moduleOrig [I : Module S M] : Module S (RestrictScalars R S M) := I\n\nvariable [CommSemiring R] [Algebra R S]\n\nsection\n\nattribute [local instance] RestrictScalars.moduleOrig\n\n/-- When `M` is a module over a ring `S`, and `S` is an algebra over `R`, then `M` inherits a\nmodule structure over `R`. Not an instance because `S` cannot be inferred.\n\nThe preferred way of setting this up is `[Module R M] [Module S M] [IsScalarTower R S M]`.\n-/\nabbrev Module.restrictScalars [Module S M] : Module R M :=\n Module.compHom M (algebraMap R S)\n\n/-- When `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] [IsScalarTower R S M]`.\n-/\ninstance RestrictScalars.module [Module S M] : Module R (RestrictScalars R S M) :=\n Module.restrictScalars R S M\n\n/-- `Module.restrictScalars` forms a scalar tower. -/\ntheorem IsScalarTower.restrictScalars [Module S M] :\n letI := Module.restrictScalars R S M\n IsScalarTower R S M :=\n IsScalarTower.of_compHom R S M\n\n/-- This instance is only relevant when `RestrictScalars.moduleOrig` is available as an instance.\n-/\ninstance RestrictScalars.isScalarTower [Module S M] : IsScalarTower R S (RestrictScalars R S M) :=\n IsScalarTower.restrictScalars R S M\n\nend\n\n/-- When `M` is a right-module over a ring `S`, and `S` is an algebra over `R`, then `M` inherits a\nright-module structure over `R`.\nThe preferred way of setting this up is\n`[Module Rᵐᵒᵖ M] [Module Sᵐᵒᵖ M] [IsScalarTower Rᵐᵒᵖ Sᵐᵒᵖ M]`.\n-/\ninstance RestrictScalars.opModule [Module Sᵐᵒᵖ M] : Module Rᵐᵒᵖ (RestrictScalars R S M) :=\n letI : Module Sᵐᵒᵖ (RestrictScalars R S M) := ‹Module Sᵐᵒᵖ M›\n Module.compHom M (RingHom.op <| algebraMap R S)\n\ninstance RestrictScalars.isCentralScalar [Module S M] [Module Sᵐᵒᵖ M] [IsCentralScalar S M] :\n IsCentralScalar R (RestrictScalars R S M) where\n op_smul_eq_smul r _x := (op_smul_eq_smul (algebraMap R S r) (_ : M) :)\n\n/-- The `R`-algebra homomorphism from the original coefficient algebra `S` to endomorphisms\nof `RestrictScalars R S M`.\n-/\ndef RestrictScalars.lsmul [Module S M] : S →ₐ[R] Module.End R (RestrictScalars R S M) :=\n -- We use `RestrictScalars.moduleOrig` in the implementation,\n -- but not in the type.\n letI : Module S (RestrictScalars R S M) := RestrictScalars.moduleOrig R S M\n Algebra.lsmul R R (RestrictScalars R S M)\n\nend\n\nvariable [AddCommMonoid M]\n\n/-- `RestrictScalars.addEquiv` is the additive equivalence with the original module. -/\ndef RestrictScalars.addEquiv : RestrictScalars R S M ≃+ M :=\n AddEquiv.refl M\n\nvariable [CommSemiring R] [Semiring S] [Algebra R S] [Module S M]\n\ntheorem RestrictScalars.smul_def (c : R) (x : RestrictScalars R S M) :\n c • x = (RestrictScalars.addEquiv R S M).symm\n (algebraMap R S c • RestrictScalars.addEquiv R S M x) :=\n rfl\n\n@[simp]\ntheorem RestrictScalars.addEquiv_map_smul (c : R) (x : RestrictScalars R S M) :\n RestrictScalars.addEquiv R S M (c • x) = algebraMap R S c • RestrictScalars.addEquiv R S M x :=\n rfl\n\ntheorem RestrictScalars.addEquiv_symm_map_algebraMap_smul (r : R) (x : M) :\n (RestrictScalars.addEquiv R S M).symm (algebraMap R S r • x) =\n r • (RestrictScalars.addEquiv R S M).symm x :=\n rfl\n\nTarget:\ntheorem RestrictScalars.addEquiv_symm_map_smul_smul (r : R) (s : S) (x : M) :\n (RestrictScalars.addEquiv R S M).symm ((r • s) • x) =\n r • (RestrictScalars.addEquiv R S M).symm (s • x) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_80128840662b","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"30c0b0c27053fe050e8d17679cbca4735a28294f3a584045ae46c69448e18d45","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"restrictscalars","file_id":"mathlib/Mathlib/Algebra/Algebra/RestrictScalars.lean","sample_id":"80128840662b22e53d1840a39802444548ca6c793df4148c58e604fe82cb2d91"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"58dc36a533c41a174ff8b90602fdc9c1afaf0df2dcf8a4d066755a6957d2ca90","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf27d863d0a7ccaf644321e841c2aa5a4618841f2f7f1089ce62e166fa5434ad","source_sha256":"762d4efec1ee6a79a6c86c42986c8ac0f53471a532b94ae1f0d16f599c3f5f2f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let e := orderIsoIsTwoSided (R := R)\n simp_rw [isSimpleRing_iff, isSimpleOrder_iff, orderIsoRingCon.toEquiv.nontrivial_congr,\n RingCon.nontrivial_iff, e.forall_congr_left, Subtype.forall, ← e.injective.eq_iff]\n simp [e, Subtype.ext_iff]","hard_negative":false,"metrics":{"chosen_tokens":49,"rejected_tokens":3,"token_jaccard":0.033333,"token_length_ratio":0.061224},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"41311d2d92443c1b8f8d0a9fedba56c26f32f8d85046023219508aeaf80972cd","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.SimpleRing.Basic\npublic import Mathlib.RingTheory.TwoSidedIdeal.Operations\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n-/\n/-!\n# Simplicity is preserved by ring isomorphisms/surjective ring homomorphisms\n\nIf `R` is a simple (non-assoc) ring and there exists surjective `f : R →+* S` where `S` is\nnontrivial, then `S` is also simple.\nIf `R` is a simple (non-unital non-assoc) ring then any ring isomorphic to `R` is also simple.\n-/\n\npublic section\n\nnamespace IsSimpleRing\n\nlemma of_surjective {R S : Type*} [NonAssocRing R] [NonAssocRing S] [Nontrivial S]\n (f : R →+* S) (h : IsSimpleRing R) (hf : Function.Surjective f) : IsSimpleRing S where\n simple := OrderIso.isSimpleOrder (RingEquiv.ofBijective f\n ⟨RingHom.injective f, hf⟩).symm.mapTwoSidedIdeal\n\nlemma of_ringEquiv {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n (f : R ≃+* S) (h : IsSimpleRing R) : IsSimpleRing S where\n simple := OrderIso.isSimpleOrder f.symm.mapTwoSidedIdeal\n\nend IsSimpleRing\n\nopen TwoSidedIdeal in\n\nTarget:\ntheorem isSimpleRing_iff_isTwoSided_imp {R : Type*} [Ring R] :\n IsSimpleRing R ↔ Nontrivial R ∧ ∀ I : Ideal R, I.IsTwoSided → I = ⊥ ∨ I = ⊤ :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/SimpleRing","family_id":"issimplering_iff_istwosided_imp","file_id":"mathlib/Mathlib/RingTheory/SimpleRing/Congr.lean","sample_id":"cf27d863d0a7ccaf644321e841c2aa5a4618841f2f7f1089ce62e166fa5434ad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4a31c3694f0a700631e2f56726fd910eacab3c7a5db1e512c199ce266ebe78fe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"57ff12f2bd1bac31c21b6f1a4389f1274bdb0a450799cf2bb8a3db294da159c1","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b56bde4606c354af04f1cdcc49085c017324c540fef76bdd0096e6ba3c9e6565","source_sha256":"a7fe36236e2ed09f5c9d6f891e25635e8949de49ab4080f1346dbb2cc7d33457","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [support, Finsupp.notMem_support_iff]\n exact Iff.rfl","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.25,"token_length_ratio":0.230769},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"413c26059b8c9d2abb192d87beea6f675773830af0cbca5665103ffba969541e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.Module.End\npublic import Mathlib.GroupTheory.FreeAbelianGroup\n\nNamespace:\nFreeAbelianGroup\n\nLocal context:\n/-\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/-!\n# Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n\nIn this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`.\nWe use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`.\n\n## Main declarations\n\n- `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n- `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X`\n- `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X`\n-/\n\n@[expose] public section\n\nassert_not_exists Cardinal Module.Basis\n\nnoncomputable section\n\nvariable {X : Type*}\n\n/-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/\ndef FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ :=\n FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ)\n\n/-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/\ndef Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X :=\n Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x)\n\n@[simp] lemma FreeAbelianGroup.toFinsupp_of (x : X) : toFinsupp (of x) = .single x 1 := by\n simp [toFinsupp]\n\n@[simp] lemma Finsupp.toFreeAbelianGroup_single (x : X) (n : ℤ) :\n toFreeAbelianGroup (single x n) = n • .of x := by simp [toFreeAbelianGroup]\n\nopen Finsupp FreeAbelianGroup\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) :\n Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) =\n (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) :=\n AddMonoidHom.ext <| toFreeAbelianGroup_single _\n\n@[simp]\ntheorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup :\n toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) := by\n ext\n simp\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_toFinsupp :\n toFreeAbelianGroup.comp toFinsupp = AddMonoidHom.id (FreeAbelianGroup X) := by\n ext\n rw [toFreeAbelianGroup, toFinsupp, AddMonoidHom.comp_apply, lift_apply_of,\n liftAddHom_apply_single, AddMonoidHom.flip_apply, smulAddHom_apply, one_smul,\n AddMonoidHom.id_apply]\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_toFinsupp {X} (x : FreeAbelianGroup X) :\n Finsupp.toFreeAbelianGroup (FreeAbelianGroup.toFinsupp x) = x := by\n rw [← AddMonoidHom.comp_apply, Finsupp.toFreeAbelianGroup_comp_toFinsupp, AddMonoidHom.id_apply]\n\nnamespace FreeAbelianGroup\n\nopen Finsupp\n\n@[simp]\ntheorem toFinsupp_toFreeAbelianGroup (f : X →₀ ℤ) :\n FreeAbelianGroup.toFinsupp (Finsupp.toFreeAbelianGroup f) = f := by\n rw [← AddMonoidHom.comp_apply, toFinsupp_comp_toFreeAbelianGroup, AddMonoidHom.id_apply]\n\nvariable (X)\n\n/-- The additive equivalence between `FreeAbelianGroup X` and `(X →₀ ℤ)`. -/\n@[simps!]\ndef equivFinsupp : FreeAbelianGroup X ≃+ (X →₀ ℤ) where\n toFun := toFinsupp\n invFun := toFreeAbelianGroup\n left_inv := toFreeAbelianGroup_toFinsupp\n right_inv := toFinsupp_toFreeAbelianGroup\n map_add' := toFinsupp.map_add\n\nvariable {X}\n\n/-- `coeff x` is the additive group homomorphism `FreeAbelianGroup X →+ ℤ`\nthat sends `a` to the multiplicity of `x : X` in `a`. -/\ndef coeff (x : X) : FreeAbelianGroup X →+ ℤ :=\n (Finsupp.applyAddHom x).comp toFinsupp\n\n/-- `support a` for `a : FreeAbelianGroup X` is the finite set of `x : X`\nthat occur in the formal sum `a`. -/\ndef support (a : FreeAbelianGroup X) : Finset X :=\n a.toFinsupp.support\n\n@[simp]\ntheorem mem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∈ a.support ↔ coeff x a ≠ 0 := by\n rw [support, Finsupp.mem_support_iff]\n exact Iff.rfl\n\nTarget:\ntheorem notMem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∉ a.support ↔ coeff x a = 0 :=\n\nProof body:\n","rejected":"by\n exact notMem_support_iff","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"4b8681dd99292ea2d77bc7e6c8a79b2f142ffbe27864c085cfd50ff125ab938d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAbelianGroup","family_id":"notmem_support_iff","file_id":"mathlib/Mathlib/Algebra/FreeAbelianGroup/Finsupp.lean","sample_id":"b56bde4606c354af04f1cdcc49085c017324c540fef76bdd0096e6ba3c9e6565"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"44e5ddd2baf0c2961be4d908f5f5aa690e26d21071f58e7a235f570f61fcd36f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"689f5626aa30aec2375a22ea7dc32e340ff635eb9500889ac917bdcdb4517985","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cd56beece6e3260785012905a7333440a52277cc36934bf7fb02c903e3482ee5","source_sha256":"3feee154a2a7cd94b37d0dc241c9f413d5c37bf8c3d535669868301ff8953cf3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← IsIso.eq_inv_comp, Limits.comp_zero]","hard_negative":true,"metrics":{"chosen_tokens":12,"rejected_tokens":2,"token_jaccard":0.083333,"token_length_ratio":0.166667},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"422503abd053cee3cc53c0ed6e1261c63102c424ffc427104b7d5411361b4079","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TransferInstance\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.Algebra.Group.Action.Units\npublic import Mathlib.CategoryTheory.Endomorphism\npublic import Mathlib.CategoryTheory.Limits.Shapes.Kernels\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Defs\npublic import Mathlib.Algebra.Module.NatInt\n\nNamespace:\nCategoryTheory.Preadditive.IsIso\n\nLocal context:\n/-\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-/\n/-!\n# Preadditive categories\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\n@[expose] public section\n\n\nuniverse v u\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory\n\nvariable (C : Type u) [Category.{v} C]\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\nlinear in both variables. -/\n@[stacks 00ZY]\nclass Preadditive where\n homGroup : ∀ P Q : C, AddCommGroup (P ⟶ Q) := by infer_instance\n add_comp : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R), (f + f') ≫ g = f ≫ g + f' ≫ g := by\n cat_disch\n comp_add : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R), f ≫ (g + g') = f ≫ g + f ≫ g' := by\n cat_disch\n\nattribute [inherit_doc Preadditive] Preadditive.homGroup Preadditive.add_comp Preadditive.comp_add\n\nattribute [instance_reducible, instance] Preadditive.homGroup\n\n-- simp can already prove reassoc version\nattribute [reassoc, simp] Preadditive.add_comp\n\nattribute [reassoc] Preadditive.comp_add\n\nattribute [simp] Preadditive.comp_add\n\nend CategoryTheory\n\nopen CategoryTheory\n\nnamespace CategoryTheory\n\nnamespace Preadditive\n\nsection Preadditive\n\nopen AddMonoidHom\n\nvariable {C : Type u} [Category.{v} C] [Preadditive C]\n\nsection InducedCategory\n\nuniverse u'\n\nvariable {D : Type u'} (F : D → C)\n\ninstance inducedCategory : Preadditive.{v} (InducedCategory C F) where\n homGroup P Q := InducedCategory.homEquiv.addCommGroup\n add_comp _ _ _ _ _ _ := by ext; apply add_comp\n comp_add _ _ _ _ _ _ := by ext; apply comp_add\n\nvariable {F} in\n/-- The additive equivalence `(X ⟶ Y) ≃+ (F X ⟶ F Y)` when `F : D → C` and\n`C` is a preadditive category. -/\n@[simps!]\ndef _root_.CategoryTheory.InducedCategory.homAddEquiv\n {X Y : InducedCategory C F} :\n (X ⟶ Y) ≃+ (F X ⟶ F Y) where\n toEquiv := InducedCategory.homEquiv\n map_add' := by aesop_cat\n\nend InducedCategory\n\ninstance fullSubcategory (Z : ObjectProperty C) : Preadditive Z.FullSubcategory where\n homGroup P Q := {\n -- Note: Add zero field explicitly for a better transparency of definitional properties\n zero := Z.homMk 0\n __ := InducedCategory.homEquiv.addCommGroup }\n add_comp _ _ _ _ _ _ := by ext; apply add_comp\n comp_add _ _ _ _ _ _ := by ext; apply comp_add\n\ninstance (X : C) : AddCommGroup (End X) :=\n inferInstanceAs <| AddCommGroup (X ⟶ X)\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef leftComp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=\n mk' (fun g => f ≫ g) fun g g' => by simp\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef rightComp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=\n mk' (fun f => f ≫ g) fun f f' => by simp\n\nvariable {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef compHom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) :=\n AddMonoidHom.mk' (fun f => leftComp _ f) fun f₁ f₂ =>\n AddMonoidHom.ext fun g => (rightComp _ g).map_add f₁ f₂\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem sub_comp : (f - f') ≫ g = f ≫ g - f' ≫ g :=\n map_sub (rightComp P g) f f'\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem comp_sub : f ≫ (g - g') = f ≫ g - f ≫ g' :=\n map_sub (leftComp R f) g g'\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem neg_comp : (-f) ≫ g = -f ≫ g :=\n map_neg (rightComp P g) f\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem comp_neg : f ≫ (-g) = -f ≫ g :=\n map_neg (leftComp R f) g\n\n@[reassoc]\ntheorem neg_comp_neg : (-f) ≫ (-g) = f ≫ g := by simp\n\ntheorem nsmul_comp (n : ℕ) : (n • f) ≫ g = n • f ≫ g :=\n map_nsmul (rightComp P g) n f\n\ntheorem comp_nsmul (n : ℕ) : f ≫ (n • g) = n • f ≫ g :=\n map_nsmul (leftComp R f) n g\n\ntheorem zsmul_comp (n : ℤ) : (n • f) ≫ g = n • f ≫ g :=\n map_zsmul (rightComp P g) n f\n\ntheorem comp_zsmul (n : ℤ) : f ≫ (n • g) = n • f ≫ g :=\n map_zsmul (leftComp R f) n g\n\n@[reassoc]\ntheorem comp_sum {P Q R : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n (f ≫ ∑ j ∈ s, g j) = ∑ j ∈ s, f ≫ g j :=\n map_sum (leftComp R f) _ _\n\n@[reassoc]\ntheorem sum_comp {P Q R : C} {J : Type*} (s : Finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) :\n (∑ j ∈ s, f j) ≫ g = ∑ j ∈ s, f j ≫ g :=\n map_sum (rightComp P g) _ _\n\n@[reassoc]\ntheorem sum_comp' {P Q R S : C} {J : Type*} (s : Finset J) (f : J → (P ⟶ Q)) (g : J → (Q ⟶ R))\n (h : R ⟶ S) : (∑ j ∈ s, f j ≫ g j) ≫ h = ∑ j ∈ s, f j ≫ g j ≫ h := by\n simp only [← Category.assoc]\n apply sum_comp\n\ninstance {P Q : C} {f : P ⟶ Q} [Epi f] : Epi (-f) :=\n ⟨fun g g' H => by rwa [neg_comp, neg_comp, ← comp_neg, ← comp_neg, cancel_epi, neg_inj] at H⟩\n\ninstance {P Q : C} {f : P ⟶ Q} [Mono f] : Mono (-f) :=\n ⟨fun g g' H => by rwa [comp_neg, comp_neg, ← neg_comp, ← neg_comp, cancel_mono, neg_inj] at H⟩\n\ninstance (priority := 100) preadditiveHasZeroMorphisms : HasZeroMorphisms C where\n zero := inferInstance\n comp_zero f R := show leftComp R f 0 = 0 from map_zero _\n zero_comp P _ _ f := show rightComp P f 0 = 0 from map_zero _\n\n/-- This instance is split off from the `Ring (End X)` instance to speed up instance search. -/\ninstance {X : C} : Semiring (End X) :=\n { End.monoid with\n zero_mul := fun f => by dsimp [mul]; exact HasZeroMorphisms.comp_zero f _\n mul_zero := fun f => by dsimp [mul]; exact HasZeroMorphisms.zero_comp _ f\n left_distrib := fun f g h => Preadditive.add_comp X X X g h f\n right_distrib := fun f g h => Preadditive.comp_add X X X h f g }\n\ninstance {X : C} : Ring (End X) :=\n { (inferInstance : Semiring (End X)),\n (inferInstance : AddCommGroup (End X)) with\n neg_add_cancel := neg_add_cancel }\n\ninstance moduleEndRight {X Y : C} : Module (End Y) (X ⟶ Y) where\n smul_add _ _ _ := add_comp _ _ _ _ _ _\n smul_zero _ := zero_comp\n add_smul _ _ _ := comp_add _ _ _ _ _ _\n zero_smul _ := comp_zero\n\ntheorem mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :\n Mono f where\n right_cancellation := fun {Z} g₁ g₂ hg =>\n sub_eq_zero.1 <| h _ <| (map_sub (rightComp Z f) g₁ g₂).trans <| sub_eq_zero.2 hg\n\ntheorem mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :\n Mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n ⟨fun _ _ _ => zero_of_comp_mono _, mono_of_cancel_zero f⟩\n\ntheorem mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [HasLimit (parallelPair f 0)]\n (w : kernel.ι f = 0) : Mono f :=\n mono_of_cancel_zero f fun g h => by rw [← kernel.lift_ι f g h, w, Limits.comp_zero]\n\nlemma mono_of_isZero_kernel' {X Y : C} {f : X ⟶ Y} (c : KernelFork f) (hc : IsLimit c)\n (h : IsZero c.pt) : Mono f := mono_of_cancel_zero _ (fun g hg => by\n obtain ⟨a, ha⟩ := KernelFork.IsLimit.lift' hc _ hg\n rw [← ha, h.eq_of_tgt a 0, Limits.zero_comp])\n\nlemma mono_iff_isZero_kernel' {X Y : C} {f : X ⟶ Y} (c : KernelFork f) (hc : IsLimit c) :\n Mono f ↔ IsZero c.pt :=\n ⟨fun _ ↦ KernelFork.IsLimit.isZero_of_mono hc, mono_of_isZero_kernel' c hc⟩\n\nlemma mono_of_isZero_kernel {X Y : C} (f : X ⟶ Y) [HasKernel f] (h : IsZero (kernel f)) :\n Mono f :=\n mono_of_isZero_kernel' _ (kernelIsKernel _) h\n\nlemma mono_iff_isZero_kernel {X Y : C} (f : X ⟶ Y) [HasKernel f] :\n Mono f ↔ IsZero (kernel f) :=\n mono_iff_isZero_kernel' _ (limit.isLimit _)\n\ntheorem epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :\n Epi f :=\n ⟨fun {Z} g g' hg =>\n sub_eq_zero.1 <| h _ <| (map_sub (leftComp Z f) g g').trans <| sub_eq_zero.2 hg⟩\n\ntheorem epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :\n Epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n ⟨fun _ _ _ => zero_of_epi_comp _, epi_of_cancel_zero f⟩\n\ntheorem epi_of_cokernel_zero {X Y : C} {f : X ⟶ Y} [HasColimit (parallelPair f 0)]\n (w : cokernel.π f = 0) : Epi f :=\n epi_of_cancel_zero f fun g h => by rw [← cokernel.π_desc f g h, w, Limits.zero_comp]\n\nlemma epi_of_isZero_cokernel' {X Y : C} {f : X ⟶ Y} (c : CokernelCofork f) (hc : IsColimit c)\n (h : IsZero c.pt) : Epi f := epi_of_cancel_zero _ (fun g hg => by\n obtain ⟨a, ha⟩ := CokernelCofork.IsColimit.desc' hc _ hg\n rw [← ha, h.eq_of_src a 0, Limits.comp_zero])\n\nlemma epi_iff_isZero_cokernel' {X Y : C} {f : X ⟶ Y} (c : CokernelCofork f) (hc : IsColimit c) :\n Epi f ↔ IsZero c.pt :=\n ⟨fun _ ↦ CokernelCofork.IsColimit.isZero_of_epi hc, epi_of_isZero_cokernel' c hc⟩\n\nlemma epi_of_isZero_cokernel {X Y : C} (f : X ⟶ Y) [HasCokernel f] (h : IsZero (cokernel f)) :\n Epi f :=\n epi_of_isZero_cokernel' _ (cokernelIsCokernel _) h\n\nlemma epi_iff_isZero_cokernel {X Y : C} (f : X ⟶ Y) [HasCokernel f] :\n Epi f ↔ IsZero (cokernel f) :=\n epi_iff_isZero_cokernel' _ (colimit.isColimit _)\n\nnamespace IsIso\n\n@[simp]\n\nTarget:\ntheorem comp_left_eq_zero [IsIso f] : f ≫ g = 0 ↔ g = 0 :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_cd56beece6e3","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"e837652974f2e3331aa7797bacb9a8000dfe6c9ae152915daa195795272383d9","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Preadditive","family_id":"comp_left_eq_zero","file_id":"mathlib/Mathlib/CategoryTheory/Preadditive/Basic.lean","sample_id":"cd56beece6e3260785012905a7333440a52277cc36934bf7fb02c903e3482ee5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"31c8302c65cc713d1319f3775f244828470b3a29f6da40c394ffd32649721f63","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b29251e7e93e835cd9694257415f919509e8b460ab58a86d503228ee36d39f16","source_sha256":"11984ab44ec3ab55f5eefa6541171d5214f132d73abb95541a36a4e5c9cd422e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let f₀ : 𝓞 K ≃ₗ[ℤ] 𝓞 L := (f.restrictScalars ℤ).mapIntegralClosure.toLinearEquiv\n rw [← Rat.intCast_inj, coe_discr, Algebra.discr_eq_discr_of_algEquiv (integralBasis K) f,\n ← discr_eq_discr L ((RingOfIntegers.basis K).map f₀)]\n change _ = algebraMap ℤ ℚ _\n rw [← Algebra.discr_localizationLocalization ℤ (nonZeroDivisors ℤ) L]\n congr 1\n ext\n simp only [Function.comp_apply, integralBasis_apply, Basis.localizationLocalization_apply,\n Basis.map_apply]\n rfl","hard_negative":false,"metrics":{"chosen_tokens":100,"rejected_tokens":3,"token_jaccard":0.018519,"token_length_ratio":0.03},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"425fe3a648c125cc34152e0aa8b24e9e2a1ac24f83173629d0362360523ff94d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.NumberField.Basic\npublic import Mathlib.RingTheory.Localization.NormTrace\n\nNamespace:\nNumberField\n\nLocal context:\n/-\nCopyright (c) 2023 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Xavier Roblot\n-/\n/-!\n# Number field discriminant\nThis file defines the discriminant of a number field.\n\n## Main definitions\n\n* `NumberField.discr`: the absolute discriminant of a number field.\n\n## Tags\nnumber field, discriminant\n-/\n\npublic section\n\nopen Module\n\n-- TODO: Rewrite some of the FLT results on the discriminant using the definitions and results of\n-- this file\n\nnamespace NumberField\n\nvariable (K : Type*) [Field K] [NumberField K]\n\n/-- The absolute discriminant of a number field. -/\nnoncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K)\n\ntheorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) :=\n (Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm\n\ntheorem discr_ne_zero : discr K ≠ 0 := by\n rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr]\n exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K)\n\ntheorem discr_eq_discr {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι ℤ (𝓞 K)) :\n Algebra.discr ℤ b = discr K := by\n let b₀ := Basis.reindex (RingOfIntegers.basis K) (Basis.indexEquiv (RingOfIntegers.basis K) b)\n rw [Algebra.discr_eq_discr (𝓞 K) b b₀, Basis.coe_reindex, Algebra.discr_reindex]\n\nTarget:\ntheorem discr_eq_discr_of_algEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃ₐ[ℚ] L) :\n discr K = discr L :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/NumberField","family_id":"discr_eq_discr_of_algequiv","file_id":"mathlib/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean","sample_id":"b29251e7e93e835cd9694257415f919509e8b460ab58a86d503228ee36d39f16"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"31b53b83857b2764a4c499ba44fa0769b2eba5152cf998d7a92f770e73297265","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9c8edab97c79bebf800cbc9186a0e374764dc4595456fd8777a1183512f91191","source_sha256":"1faf6bf14995586c5a25e6d1eed31a0c7a16ba7df5002c406b8252e96909714f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← PiLp.proj_apply (𝕜 := ℝ) q E i (∫ x, f x ∂μ), ← ContinuousLinearMap.integral_comp_comm]\n · simp\n exact Integrable.of_eval_piLp hf","hard_negative":true,"metrics":{"chosen_tokens":37,"rejected_tokens":8,"token_jaccard":0.057143,"token_length_ratio":0.216216},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"42791c5a6b3336ba29d9f8ec91a857cf6306e11120a10183d45515f67b434037","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Normed.Lp.PiLp\npublic import Mathlib.MeasureTheory.SpecificCodomains.Pi\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Etienne Marion. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Etienne Marion\n-/\n/-!\n# Integrability in `WithLp`\n\nWe prove that `f : X → PiLp q E` is in `Lᵖ` if and only if for all `i`, `f · i` is in `Lᵖ`.\nWe do the same for `f : X → WithLp q (E × F)`.\n-/\n\npublic section\n\nopen scoped ENNReal\n\nnamespace MeasureTheory\n\nvariable {X : Type*} {mX : MeasurableSpace X} {μ : Measure X} {p q : ℝ≥0∞} [Fact (1 ≤ q)]\n\nsection Pi\n\nvariable {ι : Type*} [Fintype ι] {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] {f : X → PiLp q E}\n\nlemma memLp_piLp_iff : MemLp f p μ ↔ ∀ i, MemLp (f · i) p μ := by\n simp_rw [← memLp_pi_iff, ← Function.comp_apply (f := WithLp.ofLp)]\n exact (PiLp.lipschitzWith_ofLp q E).memLp_comp_iff_of_antilipschitz\n (PiLp.antilipschitzWith_ofLp q E) (by simp) |>.symm\n\nalias ⟨MemLp.eval_piLp, MemLp.of_eval_piLp⟩ := memLp_piLp_iff\n\nlemma integrable_piLp_iff : Integrable f μ ↔ ∀ i, Integrable (f · i) μ := by\n simp_rw [← memLp_one_iff_integrable, memLp_piLp_iff]\n\nalias ⟨Integrable.eval_piLp, Integrable.of_eval_piLp⟩ := integrable_piLp_iff\n\nvariable [∀ i, NormedSpace ℝ (E i)] [∀ i, CompleteSpace (E i)]\n\nTarget:\nlemma eval_integral_piLp (hf : ∀ i, Integrable (f · i) μ) (i : ι) :\n (∫ x, f x ∂μ) i = ∫ x, f x i ∂μ :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"13b76737b0fbbd33af62b03c3058e90a06e999a9c0f8e107336d2b8435e99004","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/SpecificCodomains","family_id":"eval_integral_pilp","file_id":"mathlib/Mathlib/MeasureTheory/SpecificCodomains/WithLp.lean","sample_id":"9c8edab97c79bebf800cbc9186a0e374764dc4595456fd8777a1183512f91191"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"19cafd6eb0e18f6bd0d779fcdb8a60d79941b3ac55ca2293115640d385a5403c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"61edb107e4410d1c6e3c7d14ba3c27121b18ccb05d2782ec9d08f03ebfc5b362","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext a\n exact DistribMulActionHom.congr_fun h a","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":8,"token_jaccard":0.071429,"token_length_ratio":0.888889},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"42829bfda9a17558c826746ba20af32eb0fa7e38e0ef574231a8d32c11c98fab","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\nTarget:\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"8c5f412b9503ce45fdf23f7fae42584b0d43768ef2097bffd3c1347c2c3d2290","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"to_distribmulactionhom_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"61edb107e4410d1c6e3c7d14ba3c27121b18ccb05d2782ec9d08f03ebfc5b362"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bb8f6cde9d567711fa35573d789e30ab2515f10274fbeb0cf4e134f652ea803f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"79ece06be4d7d2e6219a31b4a8ad7c08e58da07f5ba53833aec9f377094f8c3e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"789be66cfcfca70a08f19d2db15da4c28ba9c70e08a73feae4cdff08db1338d8","source_sha256":"cf9f07826f15801d5e4d123ed051af6f5fff90fb4e87201d2c41c9a18629b3e1","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n convert! cutExpand_add_left t using 2 <;> apply add_comm","hard_negative":true,"metrics":{"chosen_tokens":12,"rejected_tokens":3,"token_jaccard":0.071429,"token_length_ratio":0.25},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"42bef6b51c0e607b4c12bb0871f6ff57da59d01d637bd5a4c11fc800facd6ecb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finsupp.Lex\npublic import Mathlib.Data.Finsupp.Multiset\npublic import Mathlib.Order.GameAdd\n\nNamespace:\nRelation\n\nLocal context:\n/-\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/-!\n# Termination of a hydra game\n\nThis file deals with the following version of the hydra game: each head of the hydra is\nlabelled by an element in a type `α`, and when you cut off one head with label `a`, it\ngrows back an arbitrary but finite number of heads, all labelled by elements smaller than\n`a` with respect to a well-founded relation `r` on `α`. We show that no matter how (in\nwhat order) you choose cut off the heads, the game always terminates, i.e. all heads will\neventually be cut off (but of course it can last arbitrarily long, i.e. takes an\narbitrary finite number of steps).\n\nThis result is stated as the well-foundedness of the `CutExpand` relation defined in\nthis file: we model the heads of the hydra as a multiset of elements of `α`, and the\nvalid \"moves\" of the game are modelled by the relation `CutExpand r` on `Multiset α`:\n`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a ∈ s` and\nadding back an arbitrary multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`.\n\nWe follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.\n\nTODO: formalize the relations corresponding to more powerful (e.g. Kirby–Paris and Buchholz)\nhydras, and prove their well-foundedness.\n-/\n\n@[expose] public section\n\n\nnamespace Relation\n\nopen Multiset Prod\n\nvariable {α : Type*}\n\n/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`\n means that `s'` is obtained by removing one head `a ∈ s` and adding back an arbitrary\n multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`.\n\n This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires\n `DecidableEq α`, so we use the equivalent condition `s' + {a} = s + t` instead, which\n is also easier to verify for explicit multisets `s'`, `s` and `t`.\n\n We also don't include the condition `a ∈ s` because `s' + {a} = s + t` already\n guarantees `a ∈ s + t`, and if `r` is irreflexive then `a ∉ t`, which is the\n case when `r` is well-founded, the case we are primarily interested in.\n\n The lemma `Relation.cutExpand_iff` below converts between this convenient definition\n and the direct translation when `r` is irreflexive. -/\ndef CutExpand (r : α → α → Prop) (s' s : Multiset α) : Prop :=\n ∃ (t : Multiset α) (a : α), (∀ a' ∈ t, r a' a) ∧ s' + {a} = s + t\n\nvariable {r : α → α → Prop}\n\ntheorem cutExpand_le_invImage_lex [DecidableEq α] [Std.Irrefl r] :\n CutExpand r ≤ InvImage (Finsupp.Lex (rᶜ ⊓ (· ≠ ·)) (· < ·)) toFinsupp := by\n rintro s t ⟨u, a, hr, he⟩\n replace hr := fun a' ↦ mt (hr a')\n classical\n refine ⟨a, fun b h ↦ ?_, ?_⟩ <;> simp_rw [toFinsupp_apply]\n · apply_fun count b at he\n simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]\n using he\n · apply_fun count a at he\n simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),\n add_zero] at he\n exact he ▸ Nat.lt_succ_self _\n\ntheorem cutExpand_singleton {s x} (h : ∀ x' ∈ s, r x' x) : CutExpand r s {x} :=\n ⟨s, x, h, add_comm s _⟩\n\ntheorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=\n cutExpand_singleton fun a h ↦ by rwa [mem_singleton.1 h]\n\ntheorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) ↔ CutExpand r t u :=\n exists₂_congr fun _ _ ↦ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]\n\nTarget:\nlemma cutExpand_add_right {s' s} (t) : CutExpand r (s' + t) (s + t) ↔ CutExpand r s' s :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_789be66cfcfc","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a0ecc6f403651daf7a11877a2f4bb193edf14fb462b668dffd0ec76f52540967","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic","family_id":"cutexpand_add_right","file_id":"mathlib/Mathlib/Logic/Hydra.lean","sample_id":"789be66cfcfca70a08f19d2db15da4c28ba9c70e08a73feae4cdff08db1338d8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dd1601ad60125ec24e550b2694b504c419cd4b1f3ae173271e54395b0bb23c45","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a42b889a6692b4db9475ffdf38d28c80c391b2620cfeed1446b0f0c0fe264747","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"75086fd7bc4840e9a5faef44b6f920c1488a21e796312c9d358a9ed15d88136f","source_sha256":"39c30fd995f1c9f0b8e74b8d494ee14295763c6d290c46b81af97a15d6bc3764","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [divInt_eq_div, cast_div, cast_intCast]","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":3,"token_jaccard":0.090909,"token_length_ratio":0.3},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"4507719d8d5fb63a06ba740387c7892412510ce3e0325b9a0f8ef96d7ed66321","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.GroupWithZero.Units.Lemmas\npublic import Mathlib.Data.Rat.Cast.Defs\n\nNamespace:\nRat\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Casts of rational numbers into characteristic zero fields (or division rings).\n-/\n\n@[expose] public section\n\nopen Function\n\nvariable {F ι α β : Type*}\n\nnamespace Rat\nvariable [DivisionRing α] [CharZero α] {p q : ℚ}\n\n@[stacks 09FR \"Characteristic zero case.\"]\nlemma cast_injective : Injective ((↑) : ℚ → α)\n | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩, h => by\n have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0\n have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0\n rw [mk_eq_divInt, mk_eq_divInt] at h ⊢\n rw [cast_divInt_of_ne_zero _ (by simpa), cast_divInt_of_ne_zero _ (by simpa)] at h\n norm_cast at h\n rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq,\n ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_natCast d₁,\n ← Int.cast_mul, ← Int.cast_natCast d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0]\n at h\n\n@[simp, norm_cast] lemma cast_inj : (p : α) = q ↔ p = q := cast_injective.eq_iff\n\n@[simp, norm_cast] lemma cast_eq_zero : (p : α) = 0 ↔ p = 0 := cast_injective.eq_iff' cast_zero\nlemma cast_ne_zero : (p : α) ≠ 0 ↔ p ≠ 0 := cast_eq_zero.ne\n\n@[simp, norm_cast] lemma cast_add (p q : ℚ) : ↑(p + q) = (p + q : α) :=\n cast_add_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_sub (p q : ℚ) : ↑(p - q) = (p - q : α) :=\n cast_sub_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_mul (p q : ℚ) : ↑(p * q) = (p * q : α) :=\n cast_mul_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\nvariable (α) in\n/-- Coercion `ℚ → α` as a `RingHom`. -/\ndef castHom : ℚ →+* α where\n toFun := (↑)\n map_one' := cast_one\n map_mul' := cast_mul\n map_zero' := cast_zero\n map_add' := cast_add\n\n@[simp] lemma coe_castHom : ⇑(castHom α) = ((↑) : ℚ → α) := rfl\n\n@[simp, norm_cast] lemma cast_inv (p : ℚ) : ↑(p⁻¹) = (p⁻¹ : α) := map_inv₀ (castHom α) _\n@[simp, norm_cast] lemma cast_div (p q : ℚ) : ↑(p / q) = (p / q : α) := map_div₀ (castHom α) ..\n\n@[simp, norm_cast]\nlemma cast_zpow (p : ℚ) (n : ℤ) : ↑(p ^ n) = (p ^ n : α) := map_zpow₀ (castHom α) ..\n\n@[norm_cast]\n\nTarget:\ntheorem cast_divInt (a b : ℤ) : (a /. b : α) = a / b :=\n\nProof body:\n","rejected":"by\n exact cast_divInt","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"1d43742aa7809b28ebeebac638b6573264aa4046a718d2504b96016971ff0d1f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Rat","family_id":"cast_divint","file_id":"mathlib/Mathlib/Data/Rat/Cast/CharZero.lean","sample_id":"75086fd7bc4840e9a5faef44b6f920c1488a21e796312c9d358a9ed15d88136f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8a12836c9b440860e51cc07ca0fc539df9b6adb2f57bdb7930f62da8346e7681","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"db3dfc5277a0915a12247568e996a83a891ce75295d16b497c6a698d89c5755a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"edc2135002541915231c0224ca364c3d0a60b89c6b08437b7d0942c0e460c2ff","source_sha256":"7b261493fb95075ca2d1b5990fccb0ceaaa4dbde63a52fb2337aa202b5b048ff","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply (iSup₂_le _).antisymm ((one_le_netMaxcard_iff T F U 0).2 h)\n intro s ⟨_, s_net⟩\n simp only [ball, dynEntourage_zero, preimage_univ] at s_net\n norm_cast\n refine Finset.card_le_one.2 fun x x_s y y_s ↦ ?_\n exact PairwiseDisjoint.elim_set s_net x_s y_s x (mem_univ x) (mem_univ x)","hard_negative":true,"metrics":{"chosen_tokens":71,"rejected_tokens":5,"token_jaccard":0.0625,"token_length_ratio":0.070423},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"45475c74c9b70a765fdb35ceeff9bb2ec63e9e8aa11ccba06c11687000f1eb34","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.TopologicalEntropy.CoverEntropy\n\nNamespace:\nDynamics\n\nLocal context:\n/-\nCopyright (c) 2024 Damien Thomine. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damien Thomine, Pietro Monticone\n-/\n/-!\n# Topological entropy via nets\nWe implement Bowen-Dinaburg's definitions of the topological entropy, via nets.\n\nThe major design decisions are the same as in\n`Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean`, and are explained in detail there:\nuse of uniform spaces, definition of the topological entropy of a subset, and values taken in\n`EReal`.\n\nGiven a map `T : X → X` and a subset `F ⊆ X`, the topological entropy is loosely defined using\nnets as the exponential growth (in `n`) of the number of distinguishable orbits of length `n`\nstarting from `F`. More precisely, given an entourage `U`, two orbits of length `n` can be\ndistinguished if there exists some index `k < n` such that `T^[k] x` and `T^[k] y` are far enough\n(i.e. `(T^[k] x, T^[k] y)` is not in `U`). The maximal number of distinguishable orbits of\nlength `n` is `netMaxcard T F U n`, and its exponential growth `netEntropyEntourage T F U`. This\nquantity increases when `U` decreases, and a definition of the topological entropy is\n`⨆ U ∈ 𝓤 X, netEntropyInfEntourage T F U`.\n\nThe definition of topological entropy using nets coincides with the definition using covers.\nInstead of defining a new notion of topological entropy, we prove that\n`coverEntropy` coincides with `⨆ U ∈ 𝓤 X, netEntropyEntourage T F U`.\n\n## Main definitions\n- `IsDynNetIn`: property that dynamical balls centered on a subset `s` of `F` are disjoint.\n- `netMaxcard`: maximal cardinality of a dynamical net. Takes values in `ℕ∞`.\n- `netEntropyInfEntourage`/`netEntropyEntourage`: exponential growth of `netMaxcard`. The former is\n defined with a `liminf`, the latter with a `limsup`. Take values in `EReal`.\n\n## Implementation notes\nAs when using covers, there are two competing definitions `netEntropyInfEntourage` and\n`netEntropyEntourage` in this file: one uses a `liminf`, the other a `limsup`. When using covers,\nwe chose the `limsup` definition as the default.\n\n## Main results\n- `coverEntropy_eq_iSup_netEntropyEntourage`: equality between the notions of topological entropy\n defined with covers and with nets. Has a variant for `coverEntropyInf`.\n\n## Tags\nnet, entropy\n\n## TODO\nGet versions of the topological entropy on (pseudo-e)metric spaces.\n-/\n\n@[expose] public section\n\nopen Set Uniformity UniformSpace\nopen scoped SetRel\n\nnamespace Dynamics\n\nvariable {X : Type*} {T : X → X} {U V : SetRel X X} {m n : ℕ} {F s : Set X} {x : X}\n\n/-! ### Dynamical nets -/\n\n/-- Given a subset `F`, an entourage `U` and an integer `n`, a subset `s` of `F` is a\n`(U, n)`-dynamical net of `F` if no two orbits of length `n` of points in `s` shadow each other. -/\ndef IsDynNetIn (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) (s : Set X) : Prop :=\n s ⊆ F ∧ s.PairwiseDisjoint fun x : X ↦ ball x (dynEntourage T U n)\n\nlemma IsDynNetIn.of_le (m_n : m ≤ n) (h : IsDynNetIn T F U m s) : IsDynNetIn T F U n s :=\n ⟨h.1, PairwiseDisjoint.mono h.2 fun x ↦ ball_mono (dynEntourage_antitone T U m_n) x⟩\n\nlemma IsDynNetIn.of_entourage_subset (U_V : U ⊆ V) (h : IsDynNetIn T F V n s) :\n IsDynNetIn T F U n s :=\n ⟨h.1, PairwiseDisjoint.mono h.2 fun x ↦ ball_mono (dynEntourage_monotone T n U_V) x⟩\n\nlemma isDynNetIn_empty : IsDynNetIn T F U n ∅ := ⟨empty_subset F, pairwise_empty _⟩\n\nlemma isDynNetIn_singleton (T : X → X) (U : SetRel X X) (n : ℕ) (h : x ∈ F) :\n IsDynNetIn T F U n {x} :=\n ⟨singleton_subset_iff.2 h, pairwise_singleton x _⟩\n\n/-- Given an entourage `U` and a time `n`, a dynamical net has a smaller cardinality than\n a dynamical cover. This lemma is the first of two key results to compare two versions of\n topological entropy: with cover and with nets, the second being `coverMincard_le_netMaxcard`. -/\nlemma IsDynNetIn.card_le_card_of_isDynCoverOf {s t : Finset X}\n (hs : IsDynNetIn T F U n s) (ht : IsDynCoverOf T F U n t) :\n s.card ≤ t.card := by\n have (x : X) (x_s : x ∈ s) : ∃ z ∈ t, z ∈ ball x (dynEntourage T U n) := by\n simpa using! ht (hs.1 x_s)\n choose! F s_t using this\n apply Finset.card_le_card_of_injOn F fun x x_s ↦ (s_t x x_s).1\n exact fun x x_s y y_s Fx_Fy ↦\n PairwiseDisjoint.elim_set hs.2 x_s y_s (F x) (s_t x x_s).2 (Fx_Fy ▸ (s_t y y_s).2)\n\n/-! ### Maximal cardinality of dynamical nets -/\n\n/-- The largest cardinality of a `(U, n)`-dynamical net of `F`. Takes values in `ℕ∞`, and is\ninfinite if and only if `F` admits nets of arbitrarily large size. -/\nnoncomputable def netMaxcard (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) : ℕ∞ :=\n ⨆ (s : Finset X) (_ : IsDynNetIn T F U n s), (s.card : ℕ∞)\n\nlemma IsDynNetIn.card_le_netMaxcard {s : Finset X} (h : IsDynNetIn T F U n s) :\n s.card ≤ netMaxcard T F U n :=\n le_iSup₂ (α := ℕ∞) s h\n\nlemma netMaxcard_monotone_time (T : X → X) (F : Set X) (U : SetRel X X) :\n Monotone fun n : ℕ ↦ netMaxcard T F U n :=\n fun _ _ m_n ↦ biSup_mono fun _ h ↦ h.of_le m_n\n\nlemma netMaxcard_antitone (T : X → X) (F : Set X) (n : ℕ) :\n Antitone fun U : SetRel X X ↦ netMaxcard T F U n :=\n fun _ _ U_V ↦ biSup_mono fun _ h ↦ h.of_entourage_subset U_V\n\nset_option backward.isDefEq.respectTransparency false in\nlemma netMaxcard_finite_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n netMaxcard T F U n < ⊤ ↔\n ∃ s : Finset X, IsDynNetIn T F U n s ∧ (s.card : ℕ∞) = netMaxcard T F U n := by\n apply Iff.intro <;> intro h\n · obtain ⟨k, k_max⟩ := WithTop.ne_top_iff_exists.1 h.ne\n rw [← k_max]\n simp only [ENat.some_eq_coe, Nat.cast_inj]\n -- The criterion we want to use is `Nat.sSup_mem`. We rewrite `netMaxcard` with an `sSup`,\n -- then check its `BddAbove` and `Nonempty` hypotheses.\n have : netMaxcard T F U n\n = sSup (WithTop.some '' Finset.card '' {s : Finset X | IsDynNetIn T F U n s}) := by\n rw [netMaxcard, ← image_comp, sSup_image]\n simp only [mem_setOf_eq, ENat.some_eq_coe, Function.comp_apply]\n rw [this] at k_max\n have h_bdda : BddAbove (Finset.card '' {s : Finset X | IsDynNetIn T F U n s}) := by\n refine ⟨k, mem_upperBounds.2 ?_⟩\n simp only [mem_image, mem_setOf_eq, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n intro s h\n rw [← WithTop.coe_le_coe, k_max]\n apply le_sSup\n simp only [ENat.some_eq_coe, mem_image, mem_setOf_eq, Nat.cast_inj, exists_eq_right]\n exact Filter.frequently_principal.mp fun a ↦ a h rfl\n have h_nemp : (Finset.card '' {s : Finset X | IsDynNetIn T F U n s}).Nonempty := by\n refine ⟨0, ?_⟩\n simp only [mem_image, mem_setOf_eq, Finset.card_eq_zero, exists_eq_right, Finset.coe_empty]\n exact isDynNetIn_empty\n rw [← WithTop.coe_sSup' h_bdda, ENat.some_eq_coe, Nat.cast_inj] at k_max\n have key := Nat.sSup_mem h_nemp h_bdda\n rw [← k_max, mem_image] at key\n simp only [mem_setOf_eq] at key\n exact key\n · obtain ⟨s, _, s_card⟩ := h\n rw [← s_card]\n exact WithTop.coe_lt_top s.card\n\n@[simp]\nlemma netMaxcard_empty : netMaxcard T ∅ U n = 0 := by\n rw [netMaxcard, ← bot_eq_zero, iSup₂_eq_bot]\n intro s s_net\n replace s_net := subset_empty_iff.1 s_net.1\n norm_cast at s_net\n rw [s_net, Finset.card_empty, CharP.cast_eq_zero, bot_eq_zero']\n\nlemma netMaxcard_eq_zero_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n netMaxcard T F U n = 0 ↔ F = ∅ := by\n refine ⟨fun h ↦ ?_, fun h ↦ by rw [h, netMaxcard_empty]⟩\n rw [eq_empty_iff_forall_notMem]\n intro x x_F\n have key := isDynNetIn_singleton T U n x_F\n rw [← Finset.coe_singleton] at key\n replace key := key.card_le_netMaxcard\n rw [Finset.card_singleton, Nat.cast_one, h] at key\n exact key.not_gt zero_lt_one\n\nlemma one_le_netMaxcard_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) :\n 1 ≤ netMaxcard T F U n ↔ F.Nonempty := by\n rw [Order.one_le_iff_ne_zero, nonempty_iff_ne_empty]\n exact not_iff_not.2 (netMaxcard_eq_zero_iff T F U n)\n\nTarget:\nlemma netMaxcard_zero (T : X → X) (h : F.Nonempty) (U : SetRel X X) : netMaxcard T F U 0 = 1 :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_edc213500254","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a05682dd5cef1280d7d27e30e1064daf15a15572a7dcdbc65430ef049425c453","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/TopologicalEntropy","family_id":"netmaxcard_zero","file_id":"mathlib/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean","sample_id":"edc2135002541915231c0224ca364c3d0a60b89c6b08437b7d0942c0e460c2ff"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b2aca3b4f39f802af0731bbfab213936c8527e00bde887ca09c9bb79f9d8e3ac","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5517a4dbd67677c4883e38ab697621a61d29f071e9329f6548fc7ae999e28ada","source_sha256":"ea49da8fadbef6df5542f48b737813b13b1fd6e8a00c791df91871e459b5fa18","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext y; simp [cylinder, Set.pi]","hard_negative":false,"metrics":{"chosen_tokens":12,"rejected_tokens":5,"token_jaccard":0.0625,"token_length_ratio":0.416667},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"45abf9f0fa30f83624fdad04ee9c4b9d4185b6603204e555df3d0d829d5dabaa","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Separation.Basic\n\nNamespace:\nSymbolicDynamics.FullShift\n\nLocal context:\n/-\nCopyright (c) 2025 Silvère Gangloff. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Silvère Gangloff\n-/\n/-!\n# Symbolic dynamics on cancellative monoids\n\nThis file develops a minimal API for symbolic dynamics over a\n**left-cancellative monoid** `G`—formally, a structure carrying `[Monoid G]`\nand `[IsLeftCancelMul G]` (which becomes `[AddMonoid G]` and\n`[IsLeftCancelAdd G]` in the additive form). Throughout the documentation we use the\n**additive** notations, which are the most common in symbolic dynamics, although\nall the notions introduced are defined in the multiplicative notations and adapted\nto the additive notation.\n\nGiven a finite alphabet `A`, the ambient configuration space is the set of\nfunctions `G → A`, endowed with the product topology. We define the\nleft-translation action, cylinders, finite patterns, their occurrences,\nforbidden sets, and subshifts (closed, shift-invariant subsets). Basic\ntopological facts (e.g. cylinders are clopen, occurrence sets are clopen,\nforbidden sets are closed) are proved under discreteness assumptions on\nthe alphabet.\n\nThe development is generic for left-cancellative monoids. This covers both\ngroups (the standard setting of symbolic dynamics) and more general monoids\nwhere cancellation holds but inverses may not exist. Geometry specific to\n`ℤ^d` (boxes/cubes and the box-based entropy) is deferred to a separate\nspecialization.\n\n## Why cancellativity?\n\nSome constructions, such as translating a finite pattern to occur at a point `v`,\nrequire solving equations of the form `w + v = h`. For this to have a unique\nsolution `w` given `h` and `v`, we assume **left-cancellation**:\nif `v + a = v + b` then `a = b`. This allows us to define\n`Pattern.shift` (which shifts a pattern) without using inverses,\nso that the theory works not only for groups but also for cancellative monoids.\n\n## Main definitions\n\n* `shift g x` — left translation: in additive notation `(shift v x) u = x (v + u)` (using the\n**left** action of `G` on configurations).\n* `cylinder U x` — configurations agreeing with `x` on a finite set `U ⊆ G`.\n* `Pattern A G` — a configuration which takes\ndefault value outside of a finite support, together with this support.\n* `Pattern.occursInAt p x g` — occurrence of `p` in `x` at translate `g`.\n* `forbidden F` — configurations avoiding every pattern in `F`.\n* `Subshift A G` — closed, shift-invariant subsets of the full shift.\n* `MulSubshift.ofForbidden F` — the subshift defined by forbidding a family of patterns.\n* `subshift_of_finite_type F` — a subshift of finite type defined by a finite set of\nforbidden patterns.\n* `languageOn X U` — the set of patterns of shape `U` obtained by restricting some `x ∈ X`.\n\n## Design choice: ambient vs. inner (subshift-relative) viewpoint\n\nAll core notions (shift, cylinder, occurrence, language, …) are defined **in the\nambient full shift** `G → A`. A subshift is then a closed, invariant subset,\nbundled as `Subshift A G`. Working inside a subshift is done by restriction.\n\n**Motivation.**\n\nIf cylinders and shifts were defined only *inside* a subshift, local ergonomics\nwould improve but global operations would become awkward. For instance, to prove\nthat for finite shape `U`:\n\n`languageOn (X ∪ Y) U = languageOn X U ∪ languageOn Y U,`\n\none must eventually move both sides to the ambient pattern type. Similar issues\narise for intersections, factors, and products. By contrast, with ambient\ndefinitions these set-theoretic identities are tautological.\nThus the file develops the theory ambiently, and subshifts reuse it by restriction.\n\n**Working inside a subshift.**\n\nFor `Y : Subshift A G`, cylinders and occurrence sets *inside `Y`* are simply\npreimages of the ambient ones under the inclusion `Y → (G → A)`. For example:\n\n`{ y : Y | ∀ i ∈ U, (y : G → A) i = (x : G → A) i } = (Subtype.val) ⁻¹' (cylinder U (x : G → A)).`\n\nShift invariance guarantees that the ambient shift restricts to `Y`.\n\n**Ergonomics.**\n\nThin wrappers (e.g. `Subshift.shift`, `Subshift.cylinder`, `Subshift.languageOn`)\nmay be added for convenience. They introduce no new theory and unfold to the\nambient definitions.\n\n## Namespacing policy\n\nAll ambient definitions live under the namespace `SymbolicDynamics.FullShift`.\nIf inner, subshift-relative wrappers are provided, they will be placed in the\nsubnamespace `SymbolicDynamics.Subshift`. This separation avoids name clashes\nbetween the two viewpoints, since both may naturally want to reuse names like\n`cylinder`, `shift`, `occursAt`, or `languageOn`.\n\n## Implementation notes\n\n* Openness results for cylinders and occurrence sets use\n `[DiscreteTopology A]`. Closeness results use `[T1Space A]`.\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Set Topology\n\nnamespace SymbolicDynamics\n\nnamespace FullShift\n\n/-! ## Full shift and shift action -/\n\nsection ShiftDefinition\n\nvariable {A G : Type*} [Monoid G]\n\n/-- The **left-translation shift** on configurations.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the monoid, the shifted configuration\n`mulShift g x` is defined by `(mulShift g x) h = x (g * h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g * h` in the original one.\n\nFor example, if `G = ℤ` (with addition) and `A = {0, 1}`, then\n`mulShift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/\n@[to_additive /-- The **left-translation shift** on configurations, in additive notation.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the additive monoid,\nthe shifted configuration `shift g x` is defined by `(shift g x) h = x (g + h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g + h` in the original one.\n\nFor example, if `G = ℤ` and `A = {0, 1}`, then\n`shift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/]\ndef mulShift (g : G) (x : G → A) : G → A :=\n fun h => x (g * h)\n\n@[to_additive (attr := simp)] lemma mulShift_apply (g : G) (x : G → A) (h : G) :\n mulShift g x h = x (g * h) := rfl\n\n@[to_additive (attr := simp)] lemma mulShift_one (x : G → A) : mulShift (1 : G) x = x := by\n ext h; simp [mulShift]\n\n/-- Composition of left-translation shifts corresponds to multiplication in the monoid `G`. -/\n@[to_additive] lemma mulShift_mul (g₁ g₂ : G) (x : G → A) :\n mulShift (g₁ * g₂) x = mulShift g₂ (mulShift g₁ x) := by\n ext h; simp [mulShift, mul_assoc]\n\nvariable [TopologicalSpace A]\n\n/-- The left-translation shift is continuous. -/\n@[to_additive (attr := fun_prop)] lemma continuous_mulShift (g : G) :\n Continuous (mulShift (A := A) g) := by\n -- coordinate projections are continuous; composition preserves continuity\n unfold mulShift\n fun_prop\n\nend ShiftDefinition\n\n/-! ## Cylinders -/\n\nsection Cylinders\n\nvariable {A G : Type*}\n\n/-- A *cylinder set* is the set of all configurations that agree with a given\nreference configuration `x` on a fixed finite subset `U` of the index set `G`.\n\nThe set `U` is called the *support* of the cylinder.\n\nIntuitively, cylinders specify the \"letters\" on finitely many coordinates, while\nleaving all other coordinates free. For example, in the full shift `{0, 1}^ℤ`,\nthe cylinder determined by `U = {0, 1}` and `x 0 = 1, x 1 = 0` consists of all\nbi-infinite sequences of `0`s and `1`s whose entries on positions `0` and `1`\nrespectively are `1` and `0`.\n\nWhen `A` has the discrete topology, cylinder sets form a basis of clopen sets\nfor the product topology on `G → A`. -/\ndef cylinder (U : Finset G) (x : G → A) : Set (G → A) :=\n { y | ∀ i ∈ U, y i = x i }\n\n/-- A cylinder set on `U` is the `Set.pi` over `U` of the singletons `{x i}`,\nviewed as a subset of `G → A`. Equivalently, it is the preimage of that product\nof singletons in `U → A` under the restriction map `(G → A) → (U → A)`. -/\n\nTarget:\nlemma cylinder_eq_set_pi (U : Finset G) (x : G → A) :\n cylinder U x = Set.pi (↑U : Set G) (fun i => ({x i} : Set A)) :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/SymbolicDynamics","family_id":"cylinder_eq_set_pi","file_id":"mathlib/Mathlib/Dynamics/SymbolicDynamics/Basic.lean","sample_id":"5517a4dbd67677c4883e38ab697621a61d29f071e9329f6548fc7ae999e28ada"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ba26f65f5dc1563877b3c0401eab0a8e8bc886e50bc464785b0f979599e7091d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"3d78a54c4e987ef791fe445b3ed850ee097e2e7b0ff91e6c96fe583267ed4077","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"16e7737fd96f6e7a33e5121240c5eb654485ce01158b7b4d817076e7704c0dd1","source_sha256":"5252581a03c05b29d2c6b097493100e8b021df5941541f10a645d410d9cd2563","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [isProbabilityMeasure_iff, measure_univ] using hμ.mem_extremePoints_measure_univ_eq","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.153846},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"4756333b6d36573e5ab27ea314514264f511fb25cf9eeaf37400b1b2693f7996","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Convex.Extreme\npublic import Mathlib.Dynamics.Ergodic.Function\npublic import Mathlib.Dynamics.Ergodic.RadonNikodym\npublic import Mathlib.Probability.ConditionalProbability\n\nNamespace:\nErgodic\n\nLocal context:\n/-\nCopyright (c) 2025 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Ergodic measures as extreme points\n\nIn this file we prove that a finite measure `μ` is an ergodic measure for a self-map `f`\niff it is an extreme point of the set of invariant measures of `f` with the same total volume.\nWe also specialize this result to probability measures.\n-/\n\npublic section\n\nopen Filter Set Function MeasureTheory Measure ProbabilityTheory\nopen scoped NNReal ENNReal Topology\n\nvariable {X : Type*} {m : MeasurableSpace X} {μ ν : Measure X} {f : X → X}\n\nnamespace Ergodic\n\n/-- Given a constant `c ≠ ∞`, an extreme point of the set of measures that are invariant under `f`\nand have total mass `c` is an ergodic measure. -/\ntheorem of_mem_extremePoints_measure_univ_eq {c : ℝ≥0∞} (hc : c ≠ ∞)\n (h : μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ ν univ = c}) : Ergodic f μ := by\n have hf : MeasurePreserving f μ μ := h.1.1\n rcases eq_or_ne c 0 with rfl | hc₀\n · convert! zero_measure hf.measurable\n rw [← measure_univ_eq_zero, h.1.2]\n · refine ⟨hf, ⟨?_⟩⟩\n have : IsFiniteMeasure μ := by\n constructor\n rwa [h.1.2, lt_top_iff_ne_top]\n set S := {ν | MeasurePreserving f ν ν ∧ ν univ = c}\n have {s : Set X} (hsm : MeasurableSet s) (hfs : f ⁻¹' s = s) (hμs : μ s ≠ 0) :\n c • μ[|s] ∈ S := by\n refine ⟨.smul_measure (.smul_measure ?_ _) c, ?_⟩\n · convert! hf.restrict_preimage hsm\n exact hfs.symm\n · rw [Measure.smul_apply, (cond_isProbabilityMeasure hμs).1, smul_eq_mul, mul_one]\n intro s hsm hfs\n by_contra H\n obtain ⟨hs, hs'⟩ : μ s ≠ 0 ∧ μ sᶜ ≠ 0 := by\n simpa [eventuallyConst_set, ae_iff, and_comm] using! H\n have hcond : c • μ[|s] = μ := by\n apply h.2 (this hsm hfs hs) (this hsm.compl (by rw [preimage_compl, hfs]) hs')\n refine ⟨μ s / c, μ sᶜ / c, ENNReal.div_pos hs hc, ENNReal.div_pos hs' hc, ?_, ?_⟩\n · rw [← ENNReal.add_div, measure_add_measure_compl hsm, h.1.2, ENNReal.div_self hc₀ hc]\n · simp [ProbabilityTheory.cond, smul_smul, ← mul_assoc, ENNReal.div_mul_cancel,\n ENNReal.mul_inv_cancel, *]\n rw [← hcond] at hs'\n simp [ProbabilityTheory.cond_apply, hsm] at hs'\n\n/-- An extreme point of the set of invariant probability measures is an ergodic measure. -/\ntheorem of_mem_extremePoints\n (h : μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ IsProbabilityMeasure ν}) :\n Ergodic f μ :=\n .of_mem_extremePoints_measure_univ_eq ENNReal.one_ne_top <| by\n simpa only [isProbabilityMeasure_iff] using h\n\n-- TODO: do we need `IsFiniteMeasure ν` here?\ntheorem eq_smul_of_absolutelyContinuous [IsFiniteMeasure μ] [IsFiniteMeasure ν] (hμ : Ergodic f μ)\n (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) : ∃ c : ℝ≥0∞, ν = c • μ := by\n have := hfν.rnDeriv_comp_aeEq hμ.toMeasurePreserving\n obtain ⟨c, hc⟩ := hμ.ae_eq_const_of_ae_eq_comp₀ (measurable_rnDeriv _ _).nullMeasurable this\n use c\n ext s hs\n calc\n ν s = ∫⁻ a in s, ν.rnDeriv μ a ∂μ := .symm <| setLIntegral_rnDeriv hνμ _\n _ = ∫⁻ _ in s, c ∂μ := lintegral_congr_ae <| hc.filter_mono <| ae_mono restrict_le_self\n _ = (c • μ) s := by simp\n\ntheorem eq_of_absolutelyContinuous_measure_univ_eq [IsFiniteMeasure μ] [IsFiniteMeasure ν]\n (hμ : Ergodic f μ) (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) (huniv : ν univ = μ univ) :\n ν = μ := by\n rcases hμ.eq_smul_of_absolutelyContinuous hfν hνμ with ⟨c, rfl⟩\n rcases eq_or_ne μ 0 with rfl | hμ₀\n · simp\n · simp_all [ENNReal.mul_eq_right]\n\ntheorem eq_of_absolutelyContinuous [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]\n (hμ : Ergodic f μ) (hfν : MeasurePreserving f ν ν) (hνμ : ν ≪ μ) : ν = μ :=\n eq_of_absolutelyContinuous_measure_univ_eq hμ hfν hνμ <| by simp\n\ntheorem mem_extremePoints_measure_univ_eq [IsFiniteMeasure μ] (hμ : Ergodic f μ) :\n μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ ν univ = μ univ} := by\n rw [mem_extremePoints_iff_left]\n refine ⟨⟨hμ.toMeasurePreserving, rfl⟩, ?_⟩\n rintro ν₁ ⟨hfν₁, hν₁μ⟩ ν₂ ⟨hfν₂, hν₂μ⟩ ⟨a, b, ha, hb, hab, rfl⟩\n have : IsFiniteMeasure ν₁ := ⟨by rw [hν₁μ]; apply measure_lt_top⟩\n apply hμ.eq_of_absolutelyContinuous_measure_univ_eq hfν₁ (.add_right _ _) hν₁μ\n apply absolutelyContinuous_smul ha.ne'\n\nTarget:\ntheorem mem_extremePoints [IsProbabilityMeasure μ] (hμ : Ergodic f μ) :\n μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ IsProbabilityMeasure ν} :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_16e7737fd96f","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"8f99605b4bf6ca3840df093a9f5b342108f3eed62a55eda10823a60c6db5009b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/Ergodic","family_id":"mem_extremepoints","file_id":"mathlib/Mathlib/Dynamics/Ergodic/Extreme.lean","sample_id":"16e7737fd96f6e7a33e5121240c5eb654485ce01158b7b4d817076e7704c0dd1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"20520ce19c4f598c908e4d36d327798a9e8496da73d6ca49739202a8af4adf56","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"08a6544a9be6f6b7b2a6bd92e39cfab0c66f4a9347ba14bb193b935c4ce47782","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d3e1feb970de1f47ed34d5ed579d7a21a0a27e50b73499c15c6a6fbb5fc9c261","source_sha256":"ca26128848cc1b74ed4b1ae483833cc8e4d0beb45b9d3c1cf73700271a77bdb4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← mk_uLift, ← mk_uLift]\n choose g hg₁ hg₂ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop\n refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_\n rw [lift_le_aleph0, le_aleph0_iff_set_countable]\n suffices MapsTo (↑) (g ⁻¹' {f}) (f.rootSet A) from\n this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable\n rintro x (rfl : g x = f)\n exact mem_rootSet.2 ⟨hg₁ x, hg₂ x⟩","hard_negative":true,"metrics":{"chosen_tokens":106,"rejected_tokens":5,"token_jaccard":0.050847,"token_length_ratio":0.04717},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"4786932e250d607f362e32906488eee3c081b3cf4bc4f3a227e5898adbf6d52f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Polynomial.Cardinal\npublic import Mathlib.RingTheory.Algebraic.Basic\n\nNamespace:\nAlgebraic\n\nLocal context:\n/-\nCopyright (c) 2022 Violeta Hernández Palacios. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Violeta Hernández Palacios\n-/\n/-!\n### Cardinality of algebraic numbers\n\nIn this file, we prove variants of the following result: the cardinality of algebraic numbers under\nan R-algebra is at most `#R[X] * ℵ₀`.\n\nAlthough this can be used to prove that real or complex transcendental numbers exist, a more direct\nproof is given by `Liouville.transcendental`.\n-/\n\npublic section\n\n\nuniverse u v\n\nopen Cardinal Polynomial Set\n\nopen Cardinal Polynomial\n\nnamespace Algebraic\n\ntheorem infinite_of_charZero (R A : Type*) [CommRing R] [Ring A] [Algebra R A]\n [CharZero A] : { x : A | IsAlgebraic R x }.Infinite := by\n letI := MulActionWithZero.nontrivial R A\n exact infinite_of_injective_forall_mem Nat.cast_injective isAlgebraic_nat\n\ntheorem aleph0_le_cardinalMk_of_charZero (R A : Type*) [CommRing R] [Ring A]\n [Algebra R A] [CharZero A] : ℵ₀ ≤ #{ x : A // IsAlgebraic R x } :=\n infinite_iff.1 (Set.infinite_coe_iff.2 <| infinite_of_charZero R A)\n\nsection lift\n\nvariable (R : Type u) (A : Type v) [CommRing R] [IsDomain R] [CommRing A] [IsDomain A] [Algebra R A]\n [Module.IsTorsionFree R A]\n\nTarget:\ntheorem cardinalMk_lift_le_mul :\n Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } ≤ Cardinal.lift.{v} #R[X] * ℵ₀ :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_d3e1feb970de","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"e7312a17a4fa68b7894b6ef285ed9838dfdb3e1bd314cb2ff0c620565d98d4e3","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra","family_id":"cardinalmk_lift_le_mul","file_id":"mathlib/Mathlib/Algebra/AlgebraicCard.lean","sample_id":"d3e1feb970de1f47ed34d5ed579d7a21a0a27e50b73499c15c6a6fbb5fc9c261"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2a283e91ec47213d9b00885fb6817a970c1be05f6de5a84eb7a81d6f8423a9f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fe2b13876b16b4afb4cf2811b9967967940960a8e84f197baf09a94be712ab1d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5e424902350257d28f8d0de8d4216b305427715a24efd145390730ba5c4764ec","source_sha256":"dcc76d9c7855f20ba96b35eb6c6801e17ffbb55864d7bbfc3fd5a5468d4f4c8d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨M⟩ ⟨N⟩ hM hN\n let _ := fieldOfModelACF p M\n have := modelField_of_modelACF p M\n let _ := compatibleRingOfModelField M\n have := isAlgClosed_of_model_ACF p M\n have := charP_of_model_fieldOfChar p M\n let _ := fieldOfModelACF p N\n have := modelField_of_modelACF p N\n let _ := compatibleRingOfModelField N\n have := isAlgClosed_of_model_ACF p N\n have := charP_of_model_fieldOfChar p N\n constructor\n refine languageEquivEquivRingEquiv.symm ?_\n apply Classical.choice\n refine IsAlgClosed.ringEquiv_of_equiv_of_char_eq p ?_ ?_\n · rw [hM]; exact hκ\n · rw [← Cardinal.eq, hM, hN]","hard_negative":true,"metrics":{"chosen_tokens":103,"rejected_tokens":2,"token_jaccard":0.02381,"token_length_ratio":0.019417},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"48b261cfef14e3c461b59ee08f906bc32a797c43efbf88fc8c9f46971165376c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure\npublic import Mathlib.FieldTheory.IsAlgClosed.Classification\npublic import Mathlib.ModelTheory.Algebra.Field.CharP\npublic import Mathlib.ModelTheory.Satisfiability\n\nNamespace:\nFirstOrder.Field\n\nLocal context:\n/-\nCopyright (c) 2023 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\n/-!\n\n# The First-Order Theory of Algebraically Closed Fields\n\nThis file defines the theory of algebraically closed fields of characteristic `p`, as well\nas proving completeness of the theory and the Lefschetz Principle.\n\n## Main definitions\n\n* `FirstOrder.Language.Theory.ACF p` : the theory of algebraically closed fields of characteristic\n `p` as a theory over the language of rings.\n* `FirstOrder.Field.ACF_isComplete` : the theory of algebraically closed fields of characteristic\n `p` is complete whenever `p` is prime or zero.\n* `FirstOrder.Field.ACF_zero_realize_iff_infinite_ACF_prime_realize` : the Lefschetz principle.\n\n## Implementation details\n\nTo apply a theorem about the model theory of algebraically closed fields to a specific\nalgebraically closed field `K` which does not have a `Language.ring.Structure` instance,\nyou must introduce the local instance `compatibleRingOfRing K`. Theorems whose statement requires\nboth a `Language.ring.Structure` instance and a `Field` instance will all be stated with the\nassumption `Field K`, `CharP K p`, `IsAlgClosed K` and `CompatibleRing K` and there are instances\ndefined saying that these assumptions imply `Theory.field.Model K` and `(Theory.ACF p).Model K`\n\n## References\n\nThe first-order theory of algebraically closed fields, along with the Lefschetz Principle and\nthe Ax-Grothendieck Theorem were first formalized in Lean 3 by Joseph Hua\n[here](https://github.com/Jlh18/ModelTheoryInLean8) with the master's thesis\n[here](https://github.com/Jlh18/ModelTheory8Report)\n\n-/\n\n@[expose] public section\n\nvariable {K : Type*}\n\nnamespace FirstOrder\n\nnamespace Field\n\nopen Ring FreeCommRing Polynomial Language\n\n/-- A generic monic polynomial of degree `n` as an element of the\nfree commutative ring in `n + 1` variables, with a variable for each\nof the `n` non-leading coefficients of the polynomial and one variable (`Fin.last n`)\nfor `X`. -/\nnoncomputable def genericMonicPoly (n : ℕ) : FreeCommRing (Fin (n + 1)) :=\n of (Fin.last _) ^ n + ∑ i : Fin n, of i.castSucc * of (Fin.last _) ^ (i : ℕ)\n\ntheorem lift_genericMonicPoly [CommRing K] [Nontrivial K] {n : ℕ} (v : Fin (n + 1) → K) :\n FreeCommRing.lift v (genericMonicPoly n) =\n (((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv).symm (v ∘ Fin.castSucc)).1.eval\n (v (Fin.last _)) := by\n simp [genericMonicPoly, monicEquivDegreeLT, degreeLTEquiv, eval_finsetSum]\n\n/-- A sentence saying every monic polynomial of degree `n` has a root. -/\nnoncomputable def genericMonicPolyHasRoot (n : ℕ) : Language.ring.Sentence :=\n (∃' ((termOfFreeCommRing (genericMonicPoly n)).relabel Sum.inr =' 0)).alls\n\ntheorem realize_genericMonicPolyHasRoot [Field K] [CompatibleRing K] (n : ℕ) :\n K ⊨ genericMonicPolyHasRoot n ↔\n ∀ p : { p : K[X] // p.Monic ∧ p.natDegree = n }, ∃ x, p.1.eval x = 0 := by\n rw [Equiv.forall_congr_left ((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv)]\n simp [Sentence.Realize, genericMonicPolyHasRoot, lift_genericMonicPoly]\n\n/-- The theory of algebraically closed fields of characteristic `p` as a theory over\nthe language of rings -/\ndef _root_.FirstOrder.Language.Theory.ACF (p : ℕ) : Theory .ring :=\n Theory.fieldOfChar p ∪ genericMonicPolyHasRoot '' {n | 0 < n}\n\ninstance [Language.ring.Structure K] (p : ℕ) [h : (Theory.ACF p).Model K] :\n (Theory.fieldOfChar p).Model K :=\n Theory.Model.mono h Set.subset_union_left\n\ninstance [Field K] [CompatibleRing K] {p : ℕ} [CharP K p] [IsAlgClosed K] :\n (Theory.ACF p).Model K := by\n refine Theory.model_union_iff.2 ⟨inferInstance, ?_⟩\n simp only [Theory.model_iff, Set.mem_image,\n forall_exists_index, and_imp]\n rintro _ n hn0 rfl\n simp only [realize_genericMonicPolyHasRoot]\n rintro ⟨p, _, rfl⟩\n exact IsAlgClosed.exists_root p (ne_of_gt\n (natDegree_pos_iff_degree_pos.1 hn0))\n\ntheorem modelField_of_modelACF (p : ℕ) (K : Type*) [Language.ring.Structure K]\n [h : (Theory.ACF p).Model K] : Theory.field.Model K :=\n Theory.Model.mono h (Set.subset_union_of_subset_left Set.subset_union_left _)\n\n/-- A model for the Theory of algebraically closed fields is a Field. After introducing\nthis as a local instance on a particular Type, you should usually also introduce\n`modelField_of_modelACF p M`, `compatibleRingOfModelField` and `isAlgClosed_of_model_ACF` -/\n@[reducible]\nnoncomputable def fieldOfModelACF (p : ℕ) (K : Type*)\n [Language.ring.Structure K]\n [h : (Theory.ACF p).Model K] : Field K := by\n have := modelField_of_modelACF p K\n exact fieldOfModelField K\n\ntheorem isAlgClosed_of_model_ACF (p : ℕ) (K : Type*)\n [Field K] [CompatibleRing K] [h : (Theory.ACF p).Model K] :\n IsAlgClosed K := by\n refine IsAlgClosed.of_exists_root _ ?_\n intro p hpm hpi\n have h : K ⊨ genericMonicPolyHasRoot '' {n | 0 < n} :=\n Theory.Model.mono h (by simp [Theory.ACF])\n simp only [Theory.model_iff, Set.mem_image,\n forall_exists_index, and_imp] at h\n have := h _ p.natDegree (natDegree_pos_iff_degree_pos.2\n (degree_pos_of_irreducible hpi)) rfl\n rw [realize_genericMonicPolyHasRoot] at this\n exact this ⟨_, hpm, rfl⟩\n\ntheorem ACF_isSatisfiable {p : ℕ} (hp : p.Prime ∨ p = 0) :\n (Theory.ACF p).IsSatisfiable := by\n cases hp with\n | inl hp =>\n have : Fact p.Prime := ⟨hp⟩\n let _ := compatibleRingOfRing (AlgebraicClosure (ZMod p))\n exact ⟨⟨AlgebraicClosure (ZMod p)⟩⟩\n | inr hp =>\n subst hp\n let _ := compatibleRingOfRing (AlgebraicClosure ℚ)\n exact ⟨⟨AlgebraicClosure ℚ⟩⟩\n\nopen Cardinal\n\n/-- The Theory `Theory.ACF p` is `κ`-categorical whenever `κ` is an uncountable cardinal. -/\n\nTarget:\ntheorem ACF_categorical {p : ℕ} (κ : Cardinal) (hκ : ℵ₀ < κ) :\n Categorical κ (Theory.ACF p) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_5e4249023502","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"3f4da14d74c9ac5062bed88e9eddc19d26990363b088dc6ebaee2ccdca24335e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"ModelTheory/Algebra","family_id":"acf_categorical","file_id":"mathlib/Mathlib/ModelTheory/Algebra/Field/IsAlgClosed.lean","sample_id":"5e424902350257d28f8d0de8d4216b305427715a24efd145390730ba5c4764ec"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"eaccf4f10bf570c90d2b3d8beb83a4c95905301b785beb07c71582c6a01de46a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"adcb4435987d31a857d485cac4c863eba52c3fd245538c2d18dcd29350783d48","source_sha256":"43ea0181376ff1f89cc7c8eb911300f2c583a8b06779ef72e8198444b04b5bf5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← lowerSemicontinuous_restrict_iff, restrict_eq,\n lowerSemicontinuous_iff_isOpen_preimage, preimage_comp, isOpen_induced_iff,\n Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm]","hard_negative":false,"metrics":{"chosen_tokens":21,"rejected_tokens":3,"token_jaccard":0.055556,"token_length_ratio":0.142857},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"49689165d5e0a54645811fc5d47b0e70e962a2609820fb9895685c924c934ffc","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Semicontinuity.Defs\npublic import Mathlib.Algebra.GroupWithZero.Indicator\npublic import Mathlib.Topology.Piecewise\npublic import Mathlib.Topology.Algebra.InfiniteSum.ENNReal\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Antoine Chambert-Loir, Anatole Dedecker\n-/\n/-!\n# Lower and Upper Semicontinuity\n\nThis file develops key properties of upper and lower semicontinuous functions.\n\n## Main definitions and results\n\nWe have some equivalent definitions of lower- and upper-semicontinuity (under certain\nrestrictions on the order on the codomain):\n* `lowerSemicontinuous_iff_isOpen_preimage` in a linear order;\n* `lowerSemicontinuous_iff_isClosed_preimage` in a linear order;\n* `lowerSemicontinuousAt_iff_le_liminf` in a complete linear order;\n* `lowerSemicontinuous_iff_isClosed_epigraph` in a linear order with the order\n topology.\n\nWe also prove:\n\n* `indicator s (fun _ ↦ y)` is lower semicontinuous when `s` is open and `0 ≤ y`,\n or when `s` is closed and `y ≤ 0`;\n* continuous functions are lower semicontinuous;\n* left composition with a continuous monotone functions maps lower semicontinuous functions to lower\n semicontinuous functions. If the function is anti-monotone, it instead maps lower semicontinuous\n functions to upper semicontinuous functions;\n* a sum of two (or finitely many) lower semicontinuous functions is lower semicontinuous;\n* a supremum of a family of lower semicontinuous functions is lower semicontinuous;\n* An infinite sum of `ℝ≥0∞`-valued lower semicontinuous functions is lower semicontinuous.\n\nSimilar results are stated and proved for upper semicontinuity.\n\nWe also prove that a function is continuous if and only if it is both lower and upper\nsemicontinuous.\n\n## Implementation details\n\nAll the nontrivial results for upper semicontinuous functions are deduced from the corresponding\nones for lower semicontinuous functions using `OrderDual`.\n\n## References\n\n* \n* \n\n\n+ lower and upper semicontinuity correspond to `r := (f · > ·)` and `r := (f · < ·)`;\n+ lower and upper hemicontinuity correspond to `r := (fun x s ↦ IsOpen s ∧ ((f x) ∩ s).Nonempty)`\n and `r := (fun x s ↦ s ∈ 𝓝ˢ (f x))`, respectively.\n-/\n\npublic section\n\nopen Topology ENNReal\n\nopen Set Function Filter\n\nvariable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace γ] {f : α → β} {s t : Set α}\n {x : α} {y z : β}\n\n/-! ### lower bounds -/\n\nsection\n\nvariable [LinearOrder β]\n\n/-- A lower semicontinuous function attains its lower bound on a nonempty compact set. -/\ntheorem LowerSemicontinuousOn.exists_isMinOn {s : Set α} (ne_s : s.Nonempty)\n (hs : IsCompact s) (hf : LowerSemicontinuousOn f s) :\n ∃ a ∈ s, IsMinOn f s a := by\n simp only [isMinOn_iff]\n have _ : Nonempty α := Exists.nonempty ne_s\n have _ : Nonempty s := Nonempty.to_subtype ne_s\n let φ : β → Filter α := fun b ↦ 𝓟 (s ∩ f ⁻¹' Iic b)\n let ℱ : Filter α := ⨅ a : s, φ (f a)\n have : ℱ.NeBot := by\n apply iInf_neBot_of_directed _ _\n · change Directed GE.ge (fun x ↦ (φ ∘ (fun (a : s) ↦ f ↑a)) x)\n exact Directed.mono_comp GE.ge (fun x y hxy ↦\n principal_mono.mpr (inter_subset_inter_right _ (preimage_mono <| Iic_subset_Iic.mpr hxy)))\n (Std.Total.directed _)\n · intro x\n have : (pure x : Filter α) ≤ φ (f x) := le_principal_iff.mpr ⟨x.2, le_refl (f x)⟩\n exact neBot_of_le this\n have hℱs : ℱ ≤ 𝓟 s :=\n iInf_le_of_le (Classical.choice inferInstance) (principal_mono.mpr <| inter_subset_left)\n have hℱ (x) (hx : x ∈ s) : ∀ᶠ y in ℱ, f y ≤ f x :=\n mem_iInf_of_mem ⟨x, hx⟩ (by apply inter_subset_right)\n obtain ⟨a, ha, h⟩ := hs hℱs\n refine ⟨a, ha, fun x hx ↦ le_of_not_gt fun hxa ↦ ?_⟩\n let _ : (𝓝 a ⊓ ℱ).NeBot := h\n suffices ∀ᶠ _ in 𝓝 a ⊓ ℱ, False by rwa [eventually_const] at this\n filter_upwards [(hf a ha (f x) hxa).filter_mono (inf_le_inf_left _ hℱs),\n (hℱ x hx).filter_mono (inf_le_right : 𝓝 a ⊓ ℱ ≤ ℱ)] using fun y h₁ h₂ ↦ not_le_of_gt h₁ h₂\n\n/-- A lower semicontinuous function is bounded below on a compact set. -/\ntheorem LowerSemicontinuousOn.bddBelow_of_isCompact [Nonempty β] {s : Set α} (hs : IsCompact s)\n (hf : LowerSemicontinuousOn f s) : BddBelow (f '' s) := by\n cases s.eq_empty_or_nonempty with\n | inl h =>\n simp only [h, Set.image_empty]\n exact bddBelow_empty\n | inr h =>\n obtain ⟨a, _, has⟩ := LowerSemicontinuousOn.exists_isMinOn h hs hf\n exact has.bddBelow\n\nend\n\n/-! #### Indicators -/\n\n\nsection\n\nvariable [Zero β] [Preorder β]\n\ntheorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuous (indicator s fun _x => y) := by\n intro x z hz\n by_cases h : x ∈ s <;> simp [h] at hz\n · filter_upwards [hs.mem_nhds h]\n simp +contextual [hz]\n · refine Filter.Eventually.of_forall fun x' => ?_\n by_cases h' : x' ∈ s <;> simp [h', hz.trans_le hy, hz]\n\ntheorem IsOpen.lowerSemicontinuousOn_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousOn (indicator s fun _x => y) t :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t\n\ntheorem IsOpen.lowerSemicontinuousAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousAt (indicator s fun _x => y) x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x\n\ntheorem IsOpen.lowerSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x\n\ntheorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuous (indicator s fun _x => y) := by\n intro x z hz\n by_cases h : x ∈ s <;> simp [h] at hz\n · refine Filter.Eventually.of_forall fun x' => ?_\n by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy]\n · filter_upwards [hs.isOpen_compl.mem_nhds h]\n simp +contextual [hz]\n\ntheorem IsClosed.lowerSemicontinuousOn_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousOn (indicator s fun _x => y) t :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t\n\ntheorem IsClosed.lowerSemicontinuousAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousAt (indicator s fun _x => y) x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x\n\ntheorem IsClosed.lowerSemicontinuousWithinAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x\n\nend\n\n/-! #### Relationship with continuity -/\n\nsection\n\nvariable [Preorder β]\n\ntheorem lowerSemicontinuous_iff_isOpen_preimage :\n LowerSemicontinuous f ↔ ∀ y, IsOpen (f ⁻¹' Ioi y) :=\n ⟨fun H y => isOpen_iff_mem_nhds.2 fun x hx => H x y hx, fun H _x y y_lt =>\n IsOpen.mem_nhds (H y) y_lt⟩\n\ntheorem LowerSemicontinuous.isOpen_preimage (hf : LowerSemicontinuous f) (y : β) :\n IsOpen (f ⁻¹' Ioi y) :=\n lowerSemicontinuous_iff_isOpen_preimage.1 hf y\n\nTarget:\ntheorem lowerSemicontinuousOn_iff_preimage_Ioi :\n LowerSemicontinuousOn f s ↔ ∀ b, ∃ u, IsOpen u ∧ s ∩ f ⁻¹' Set.Ioi b = s ∩ u :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Semicontinuity","family_id":"lowersemicontinuouson_iff_preimage_ioi","file_id":"mathlib/Mathlib/Topology/Semicontinuity/Basic.lean","sample_id":"adcb4435987d31a857d485cac4c863eba52c3fd245538c2d18dcd29350783d48"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"037b47616acfc5282eb1307b03a18e6c8c2e46a8eaf3f992b640589523528564","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"980252f41f9516a267975b8ca87c6fc909f394912871a5726991e50ea98b140d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4b303755cfa10c54252467c66159dfa004258b7d9d21b85b36400aa2e5cd9c72","source_sha256":"e108d8d20cce1de062fbe2b0d5a5e3bcaba7779c013849c00560d4b462914e41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [hasSum_iff_tendsto_nat_of_nonneg (fun n ↦ term_nonneg (n + 1) 1)]\n change Tendsto (fun N ↦ termSum 1 N) atTop _\n simp_rw [termSum_one, sub_eq_neg_add]\n refine Tendsto.add ?_ tendsto_const_nhds\n have := (tendsto_eulerMascheroniSeq'.comp (tendsto_add_atTop_nat 1)).neg\n refine this.congr' (Eventually.of_forall (fun n ↦ ?_))\n simp_rw [Function.comp_apply, eulerMascheroniSeq', reduceCtorEq, if_false]\n push_cast\n abel","hard_negative":true,"metrics":{"chosen_tokens":85,"rejected_tokens":3,"token_jaccard":0.021277,"token_length_ratio":0.035294},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"4b955e545da976c70ca75cdf9166ed94e1ba10b3a491064a0c78bc9a326b77c2","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.LSeries.RiemannZeta\npublic import Mathlib.NumberTheory.Harmonic.GammaDeriv\n\nNamespace:\nZetaAsymptotics\n\nLocal context:\n/-\nCopyright (c) 2024 David Loeffler. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Loeffler\n-/\n/-!\n# Asymptotics of `ζ s` as `s → 1` or `s → 0`\n\nThe goal of this file is to evaluate the limit of `ζ s - 1 / (s - 1)` as `s → 1`.\n\n### Main results\n\n* `tendsto_riemannZeta_sub_one_div`: the limit of `ζ s - 1 / (s - 1)`, at the filter of punctured\n neighbourhoods of 1 in `ℂ`, exists and is equal to the Euler-Mascheroni constant `γ`.\n* `deriv_riemannZeta_zero`: `ζ'(0) = -log(2π) / 2`, which derives from the above.\n* `riemannZeta_one_ne_zero`: with our definition of `ζ 1` (which is characterised as the limit of\n `ζ s - 1 / (s - 1) / Gammaℝ s` as `s → 1`), we have `ζ 1 ≠ 0`.\n\n### Outline of arguments\n\nWe consider the sum `F s = ∑' n : ℕ, f (n + 1) s`, where `s` is a real variable and\n`f n s = ∫ x in n..(n + 1), (x - n) / x ^ (s + 1)`. We show that `F s` is continuous on `[1, ∞)`,\nthat `F 1 = 1 - γ`, and that `F s = 1 / (s - 1) - ζ s / s` for `1 < s`.\n\nBy combining these formulae, one deduces that the limit of `ζ s - 1 / (s - 1)` at `𝓝[>] (1 : ℝ)`\nexists and is equal to `γ`. Finally, using this and the Riemann removable singularity criterion\nwe obtain the limit along punctured neighbourhoods of 1 in `ℂ`.\n-/\n\n@[expose] public section\n\nopen Set MeasureTheory Filter Topology\n\n@[inherit_doc] local notation \"γ\" => Real.eulerMascheroniConstant\n\nnamespace ZetaAsymptotics\n\n-- since the intermediate lemmas are of little interest in themselves we put them in a namespace\n\nopen Real\n\n/-!\n## Definitions\n-/\n\n/-- Auxiliary function used in studying zeta-function asymptotics. -/\nnoncomputable def term (n : ℕ) (s : ℝ) : ℝ := ∫ x : ℝ in n..(n + 1), (x - n) / x ^ (s + 1)\n\n/-- Sum of finitely many `term`s. -/\nnoncomputable def termSum (s : ℝ) (N : ℕ) : ℝ := ∑ n ∈ Finset.range N, term (n + 1) s\n\n/-- Topological sum of `term`s. -/\nnoncomputable def termTSum (s : ℝ) : ℝ := ∑' n, term (n + 1) s\n\n@[deprecated (since := \"2026-05-27\")] alias term_sum := termSum\n@[deprecated (since := \"2026-05-27\")] alias term_tsum := termTSum\n\nlemma term_nonneg (n : ℕ) (s : ℝ) : 0 ≤ term n s := by\n rw [term, intervalIntegral.integral_of_le (by simp)]\n refine setIntegral_nonneg measurableSet_Ioc (fun x hx ↦ ?_)\n refine div_nonneg ?_ (rpow_nonneg ?_ _)\n all_goals linarith [hx.1]\n\nlemma term_welldef {n : ℕ} (hn : 0 < n) {s : ℝ} (hs : 0 < s) :\n IntervalIntegrable (fun x : ℝ ↦ (x - n) / x ^ (s + 1)) volume n (n + 1) := by\n rw [intervalIntegrable_iff_integrableOn_Icc_of_le (by linarith)]\n refine (continuousOn_of_forall_continuousAt fun x hx ↦ ContinuousAt.div ?_ ?_ ?_).integrableOn_Icc\n · fun_prop\n · apply continuousAt_id.rpow_const (Or.inr <| by linarith)\n · exact (rpow_pos_of_pos ((Nat.cast_pos.mpr hn).trans_le hx.1) _).ne'\n\nsection s_eq_one\n\n/-!\n## Evaluation of the sum for `s = 1`\n-/\n\nlemma term_one {n : ℕ} (hn : 0 < n) :\n term n 1 = (log (n + 1) - log n) - 1 / (n + 1) := by\n have hv : ∀ x ∈ uIcc (n : ℝ) (n + 1), 0 < x := by\n intro x hx\n rw [uIcc_of_le (by simp only [le_add_iff_nonneg_right, zero_le_one])] at hx\n exact (Nat.cast_pos.mpr hn).trans_le hx.1\n calc term n 1\n _ = ∫ x : ℝ in n..(n + 1), (x - n) / x ^ 2 := by\n simp_rw [term, one_add_one_eq_two, ← Nat.cast_two (R := ℝ), rpow_natCast]\n _ = ∫ x : ℝ in n..(n + 1), (1 / x - n / x ^ 2) :=\n intervalIntegral.integral_congr (fun x hx ↦ by field)\n _ = (∫ x : ℝ in n..(n + 1), 1 / x) - n * ∫ x : ℝ in n..(n + 1), 1 / x ^ 2 := by\n simp_rw [← mul_one_div (n : ℝ)]\n rw [intervalIntegral.integral_sub]\n · simp_rw [intervalIntegral.integral_const_mul]\n · exact intervalIntegral.intervalIntegrable_one_div (fun x hx ↦ (hv x hx).ne') (by fun_prop)\n · exact (intervalIntegral.intervalIntegrable_one_div\n (fun x hx ↦ (sq_pos_of_pos (hv x hx)).ne') (by fun_prop)).const_mul _\n _ = (log (↑n + 1) - log ↑n) - n * ∫ x : ℝ in n..(n + 1), 1 / x ^ 2 := by\n congr 1\n rw [integral_one_div_of_pos, log_div]\n all_goals positivity\n _ = (log (↑n + 1) - log ↑n) - n * ∫ x : ℝ in n..(n + 1), x ^ (-2 : ℝ) := by\n congr 2\n refine intervalIntegral.integral_congr (fun x hx ↦ ?_)\n rw [rpow_neg, one_div, ← Nat.cast_two (R := ℝ), rpow_natCast]\n exact (hv x hx).le\n _ = log (↑n + 1) - log ↑n - n * (1 / n - 1 / (n + 1)) := by\n rw [integral_rpow]\n · simp_rw [sub_div, (by norm_num : (-2 : ℝ) + 1 = -1), div_neg, div_one, neg_sub_neg,\n rpow_neg_one, ← one_div]\n · refine Or.inr ⟨by simp, notMem_uIcc_of_lt ?_ ?_⟩\n all_goals positivity\n _ = log (↑n + 1) - log ↑n - 1 / (↑n + 1) := by\n congr 1\n simp [field]\n\nlemma termSum_one (N : ℕ) : termSum 1 N = log (N + 1) - harmonic (N + 1) + 1 := by\n induction N with\n | zero =>\n simp_rw [termSum, Finset.sum_range_zero, harmonic_succ, harmonic_zero,\n Nat.cast_zero, zero_add, Nat.cast_one, inv_one, Rat.cast_one, log_one, sub_add_cancel]\n | succ N hN =>\n unfold termSum at hN ⊢\n rw [Finset.sum_range_succ, hN, harmonic_succ (N + 1),\n term_one (by positivity : 0 < N + 1)]\n push_cast\n ring_nf\n\n@[deprecated (since := \"2026-05-27\")] alias term_sum_one := termSum_one\n\n/-- The topological sum of `ZetaAsymptotics.term (n + 1) 1` over all `n : ℕ` is `1 - γ`. This is\nproved by directly evaluating the sum of the first `N` terms and using the limit definition of `γ`.\n-/\n\nTarget:\nlemma term_tsum_one : HasSum (fun n ↦ term (n + 1) 1) (1 - γ) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_4b303755cfa1","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"6badb7785b6b90fe79fb7ba44c30a709170bae14d3cfbd0e9b28109e249d6995","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Harmonic","family_id":"term_tsum_one","file_id":"mathlib/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean","sample_id":"4b303755cfa10c54252467c66159dfa004258b7d9d21b85b36400aa2e5cd9c72"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"35fe7827c3ae92271ac656c21126b3e74bb2af16e6d44afa3425ecfe12db8823","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b0454f139b85bee17728da424d48afb51211e609c12ebed89ebfb6674db382dd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"661b11ed491669a87dc9e4c839c3f0fea5cc231d981b2423d46f2806e8cb5ec9","source_sha256":"18568baeeffeaaa701b9fde364e1ec597e66170a4d12d2f9f2bfbc098c10a0b6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := ratSqrt_sq_le (x := x) h\n have : (x.ratSqrt prec ^ 2 : ℝ) ≤ ↑x := by norm_cast\n have := Real.sqrt_monotone this\n rwa [Real.sqrt_sq] at this\n simpa only [Rat.cast_nonneg] using ratSqrt_nonneg _ _","hard_negative":false,"metrics":{"chosen_tokens":53,"rejected_tokens":58,"token_jaccard":0.891892,"token_length_ratio":1.09434},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"4c14e6e998910134b60558e7f55967fb0061e84ce7d69c2a141e73e8439db08e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Real.Sqrt\npublic import Mathlib.Data.Rat.NatSqrt.Defs\n\nNamespace:\nNat\n\nLocal context:\n/-\nCopyright (c) 2025 Lean FRO, LLC. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\nComparisons between rational approximations to the square root of a natural number\nand the real square root.\n-/\n\npublic section\n\nnamespace Nat\n\nTarget:\ntheorem ratSqrt_le_realSqrt (x : ℕ) {prec : ℕ} (h : 0 < prec) : ratSqrt x prec ≤ √x :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n have := ratSqrt_sq_le (x := x) h\n have : (x.ratSqrt prec ^ 2 : ℝ) ≤ ↑x := by norm_cast\n have := Real.sqrt_monotone this\n rwa [Real.sqrt_sq] at this\n simpa only [Rat.cast_nonneg] using ratSqrt_nonneg _ _","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Rat","family_id":"ratsqrt_le_realsqrt","file_id":"mathlib/Mathlib/Analysis/Rat/NatSqrt/Real.lean","sample_id":"661b11ed491669a87dc9e4c839c3f0fea5cc231d981b2423d46f2806e8cb5ec9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"558366532443c10e8642207576c008e53da35c4d87815099d9d4e82ce1c2f146","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"dfc13c6e426dc923aa9ea73767ab8095dcdb6cdac5908c8c33c763c046928568","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a6ee80262e49ce214623008850bfa1d620c7f34c79c0a368ec60fc7393ba68dc","source_sha256":"ea708406b6484e91e56b8bdc3f2dba09e17fe9bba92bc78c394fdb116a849211","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun s ↦ ⟨fun hs ↦ ?_, fun ⟨u, hu⟩ ↦ mem_nhds_iff.mpr ⟨u, hu.2, hu.1.1, hu.1.2.1⟩⟩⟩\n have ⟨u, hus, hu, hxu⟩ := mem_nhds_iff.mp hs\n exact ⟨pathComponentIn u x, ⟨hu.pathComponentIn _, ⟨mem_pathComponentIn_self hxu,\n isPathConnected_pathComponentIn hxu⟩⟩, pathComponentIn_subset.trans hus⟩","hard_negative":true,"metrics":{"chosen_tokens":87,"rejected_tokens":5,"token_jaccard":0.09375,"token_length_ratio":0.057471},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"4c4a41d25ff8f939c12192a89b9f242064da01343ce6dabaa7fc1a3da2329ade","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Connected.PathConnected\npublic import Mathlib.Topology.AlexandrovDiscrete\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Ben Eltschig\n-/\n/-!\n# Locally path-connected spaces\n\nThis file defines `LocPathConnectedSpace X`, a predicate class asserting that `X` is locally\npath-connected, in that each point has a basis of path-connected neighborhoods.\n\n## Main results\n\n* `IsOpen.pathComponent` / `IsClosed.pathComponent`: in locally path-connected spaces,\n path-components are both open and closed.\n* `pathComponent_eq_connectedComponent`: in locally path-connected spaces, path-components and\n connected components agree.\n* `pathConnectedSpace_iff_connectedSpace`: locally path-connected spaces are path-connected iff they\n are connected.\n* `instLocallyConnectedSpace`: locally path-connected spaces are also locally connected.\n* `IsOpen.locPathConnectedSpace`: open subsets of locally path-connected spaces are\n locally path-connected.\n* `LocPathConnectedSpace.coinduced` / `Quotient.locPathConnectedSpace`: quotients of locally\n path-connected spaces are locally path-connected.\n* `Sum.locPathConnectedSpace` / `Sigma.locPathConnectedSpace`: disjoint unions of locally\n path-connected spaces are locally path-connected.\n\nAbstractly, this also shows that locally path-connected spaces form a coreflective subcategory of\nthe category of topological spaces, although we do not prove that in this form here.\n\n## Implementation notes\n\nIn the definition of `LocPathConnectedSpace X` we require neighbourhoods in the basis to be\npath-connected, but not necessarily open; that they can also be required to be open is shown as\na theorem in `isOpen_isPathConnected_basis`.\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology Filter unitInterval Set Function\n\nvariable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {x y z : X} {ι : Type*} {F : Set X}\n\nsection LocPathConnectedSpace\n\n/-- A topological space is locally path connected if, at every point, path connected\nneighborhoods form a neighborhood basis. -/\nclass LocPathConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where\n /-- Each neighborhood filter has a basis of path-connected neighborhoods. -/\n path_connected_basis : ∀ x : X, (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s) id\n\nexport LocPathConnectedSpace (path_connected_basis)\n\ntheorem LocPathConnectedSpace.of_bases {p : X → ι → Prop} {s : X → ι → Set X}\n (h : ∀ x, (𝓝 x).HasBasis (p x) (s x)) (h' : ∀ x i, p x i → IsPathConnected (s x i)) :\n LocPathConnectedSpace X where\n path_connected_basis x := by\n rw [hasBasis_self]\n intro t ht\n rcases (h x).mem_iff.mp ht with ⟨i, hpi, hi⟩\n exact ⟨s x i, (h x).mem_of_mem hpi, h' x i hpi, hi⟩\n\nvariable [LocPathConnectedSpace X]\n\nprotected theorem IsOpen.pathComponentIn (hF : IsOpen F) (x : X) :\n IsOpen (pathComponentIn F x) := by\n rw [isOpen_iff_mem_nhds]\n intro y hy\n let ⟨s, hs⟩ := (path_connected_basis y).mem_iff.mp (hF.mem_nhds (pathComponentIn_subset hy))\n exact mem_of_superset hs.1.1 <| pathComponentIn_congr hy ▸\n hs.1.2.subset_pathComponentIn (mem_of_mem_nhds hs.1.1) hs.2\n\n/-- In a locally path connected space, each path component is an open set. -/\nprotected theorem IsOpen.pathComponent (x : X) : IsOpen (pathComponent x) := by\n rw [← pathComponentIn_univ]\n exact isOpen_univ.pathComponentIn _\n\n/-- In a locally path connected space, each path component is a closed set. -/\nprotected theorem IsClosed.pathComponent (x : X) : IsClosed (pathComponent x) := by\n rw [← isOpen_compl_iff, isOpen_iff_mem_nhds]\n intro y hxy\n rcases (path_connected_basis y).ex_mem with ⟨V, hVy, hVc⟩\n filter_upwards [hVy] with z hz hxz\n exact hxy <| hxz.trans (hVc.joinedIn _ hz _ (mem_of_mem_nhds hVy)).joined\n\n/-- In a locally path connected space, each path component is a clopen set. -/\nprotected theorem IsClopen.pathComponent (x : X) : IsClopen (pathComponent x) :=\n ⟨.pathComponent x, .pathComponent x⟩\n\nlemma pathComponentIn_mem_nhds (hF : F ∈ 𝓝 x) : pathComponentIn F x ∈ 𝓝 x := by\n let ⟨u, huF, hu, hxu⟩ := mem_nhds_iff.mp hF\n exact mem_nhds_iff.mpr ⟨pathComponentIn u x, pathComponentIn_mono huF,\n hu.pathComponentIn x, mem_pathComponentIn_self hxu⟩\n\ntheorem PathConnectedSpace.of_locPathConnectedSpace [ConnectedSpace X] : PathConnectedSpace X :=\n ⟨inferInstance, by simp [← mem_pathComponent_iff, IsClopen.pathComponent _ |>.eq_univ]⟩\n\ntheorem pathConnectedSpace_iff_connectedSpace : PathConnectedSpace X ↔ ConnectedSpace X :=\n ⟨fun _ ↦ inferInstance, fun _ ↦ .of_locPathConnectedSpace⟩\n\ntheorem pathComponent_eq_connectedComponent (x : X) : pathComponent x = connectedComponent x :=\n (pathComponent_subset_component x).antisymm <|\n (IsClopen.pathComponent x).connectedComponent_subset (mem_pathComponent_self _)\n\ntheorem connectedComponent_eq_iff_joined (x y : X) :\n connectedComponent x = connectedComponent y ↔ Joined x y := by\n rw [← mem_pathComponent_iff, pathComponent_eq_connectedComponent, eq_comm]\n exact connectedComponent_eq_iff_mem\n\ntheorem connectedComponentSetoid_eq_pathSetoid : connectedComponentSetoid X = pathSetoid X :=\n Setoid.ext connectedComponent_eq_iff_joined\n\n/-- In a locally path-connected space, connected components and path-connected components align -/\ndef connectedComponentsEquivZerothHomotopy : ConnectedComponents X ≃ ZerothHomotopy X where\n toFun := Quotient.map id (connectedComponent_eq_iff_joined · · |>.mp ·)\n invFun := ZerothHomotopy.toConnectedComponents\n left_inv := Quot.ind <| congrFun rfl\n right_inv := Quot.ind <| congrFun rfl\n\n@[simp]\nlemma connectedComponentsEquivZerothHomotopy_apply (x : X) :\n connectedComponentsEquivZerothHomotopy ⟦x⟧ = (.mk x) :=\n rfl\n\n@[simp]\nlemma coe_connectedComponentsEquivZerothHomotopy_symm :\n ⇑connectedComponentsEquivZerothHomotopy.symm = ZerothHomotopy.toConnectedComponents (X := X) :=\n rfl\n\nlemma connectedComponentsEquivZerothHomotopy_symm_apply (x : X) :\n connectedComponentsEquivZerothHomotopy.symm (.mk x) = ⟦x⟧ :=\n rfl\n\ntheorem pathConnected_subset_basis {U : Set X} (h : IsOpen U) (hx : x ∈ U) :\n (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsPathConnected s ∧ s ⊆ U) id :=\n (path_connected_basis x).hasBasis_self_subset (IsOpen.mem_nhds h hx)\n\nTarget:\ntheorem isOpen_isPathConnected_basis (x : X) :\n (𝓝 x).HasBasis (fun s : Set X ↦ IsOpen s ∧ x ∈ s ∧ IsPathConnected s) id :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_a6ee80262e49","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"c7377bd7052ed4f88a3fb98693b9de5fb54b2b8513512fc5893a0beeb7d9a18c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Connected","family_id":"isopen_ispathconnected_basis","file_id":"mathlib/Mathlib/Topology/Connected/LocPathConnected.lean","sample_id":"a6ee80262e49ce214623008850bfa1d620c7f34c79c0a368ec60fc7393ba68dc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6b9ba8ebfcb9049b64569a7db30b67163c838c32da10d030480628c29d1eff28","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2badcddf25c1f03f29d721414c902d1c044dac044da630c34686bf1a87f102ce","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"243c98229641e910a0850d437221c871bd2ed1b94fc5341b71a80727fd9cec39","source_sha256":"db51e70d893ac72ef745f06c7b126a15551165b529f4f81338b62c90aa8f3470","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩\n rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩\n exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)","hard_negative":true,"metrics":{"chosen_tokens":39,"rejected_tokens":2,"token_jaccard":0.04,"token_length_ratio":0.051282},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"4dc8a9f14bfce175b06c8fc5bec5a8622058bf0c046e3a3400f063bf910bc793","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Interval.Set.OrdConnectedComponent\npublic import Mathlib.Topology.Order.Basic\npublic import Mathlib.Topology.Separation.Regular\n\nNamespace:\nSet\n\nLocal context:\n/-\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/-!\n# Linear order is a completely normal Hausdorff topological space\n\nIn this file we prove that a linear order with order topology is a completely normal Hausdorff\ntopological space.\n-/\n\npublic section\n\n\nopen Filter Set Function OrderDual Topology Interval\n\nvariable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a : X} {s t : Set X}\n\nnamespace Set\n\n@[simp]\n\nTarget:\ntheorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_243c98229641","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"f641fb82aae8344459a2419ea8c6835e52a25e9cf8b3d0bc2bf6be9809980b42","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Order","family_id":"ordconnectedcomponent_mem_nhds","file_id":"mathlib/Mathlib/Topology/Order/T5.lean","sample_id":"243c98229641e910a0850d437221c871bd2ed1b94fc5341b71a80727fd9cec39"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"049cec324945f12ffba7399c360e05a07919a6d1a773c6d93c4a1a8114edc258","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"16163911999832f8d2f55105be9fcf68726f3e64b0ce60d0149501a7213ff4a0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dc237fee9a01f721e3a2e7346681c0340a16b09a4bff536ceed7bf17412ca041","source_sha256":"8e667d45959923a4720fe5c44df65ca7c34aebce53072a9647abd3ed6428ad7b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine strictAntiOn_of_deriv_neg (convex_Icc ..) continuous_mul_log.continuousOn fun x hx ↦ ?_\n have hgt : x < rexp (-1) := by simp_all [interior_Icc, mem_Ioo]\n have hpos : 0 < x := by simp_all [interior_Icc, mem_Ioo]\n grind [deriv_mul_log, Real.log_lt_iff_lt_exp hpos |>.mpr hgt]","hard_negative":true,"metrics":{"chosen_tokens":63,"rejected_tokens":2,"token_jaccard":0.025641,"token_length_ratio":0.031746},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"4dd608dff85990cc85cc0239bea729bab27b2335c7c56cccfde6e3ec68e330db","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.SpecialFunctions.Pow.Real\npublic import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2021 Bolton Bailey. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bolton Bailey\n-/\n/-!\n# Logarithm Tonality\n\nIn this file we describe the tonality of the logarithm function when multiplied by functions of the\nform `x ^ a`.\n\n## Tags\n\nlogarithm, tonality\n-/\n\npublic section\n\n\nopen Set Filter Function\n\nopen Topology\n\nnoncomputable section\n\nnamespace Real\n\ntheorem mul_log_strictMonoOn : StrictMonoOn (fun x ↦ x * log x) <| .Ici <| exp (-1) := by\n refine strictMonoOn_of_deriv_pos (convex_Ici _) continuous_mul_log.continuousOn fun x hx ↦ ?_\n have hlt : rexp (-1) < x := by simpa using hx\n have hpos : 0 < x := by grind [Real.exp_pos]\n grind [deriv_mul_log, Real.lt_log_iff_exp_lt hpos |>.mpr hlt]\n\n@[deprecated Real.mul_log_strictMonoOn (since := \"2026-04-07\")]\ntheorem log_mul_self_monotoneOn : MonotoneOn (fun x : ℝ => log x * x) { x | 1 ≤ x } := by\n grind [mul_log_strictMonoOn.monotoneOn, MonotoneOn.mono, show exp (-1) < 1 by norm_num]\n\nTarget:\ntheorem mul_log_strictAntiOn :\n StrictAntiOn (fun x : ℝ ↦ x * log x) <| .Icc 0 (exp (-1)) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_dc237fee9a01","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"a630979991cfa6f701f5ed87cbcfa65ab6cfb98571e7294dbd0a3e721a44c04d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/SpecialFunctions","family_id":"mul_log_strictantion","file_id":"mathlib/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean","sample_id":"dc237fee9a01f721e3a2e7346681c0340a16b09a4bff536ceed7bf17412ca041"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f5e1a01169553de0e268c2d9fa23ab619e6ea420b718a07f31006bc810b0837c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e3116ddc18b0406d7892ac8baff1c44cdec8ee5b347f37b308138a3022c7ece3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e67fbd8fa7119d4589c790cca327cd3cc10be94a9ff804cf1a763f257fd55a16","source_sha256":"b24eb617305399f294446a5c66b94cf584b9f3b9c862321e20281c76b3bd96da","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mul_comm] at h\n exact h.of_add_mul_left_right","hard_negative":true,"metrics":{"chosen_tokens":11,"rejected_tokens":3,"token_jaccard":0.181818,"token_length_ratio":0.272727},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"4dff36b9dcb0c3a7220e7d59cd3ece2c768ed8c99548858cc2e6b3dd95c14d56","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Units\npublic import Mathlib.Algebra.Group.Nat.Units\npublic import Mathlib.Algebra.GroupWithZero.Associated\npublic import Mathlib.Algebra.Ring.Divisibility.Basic\npublic import Mathlib.Algebra.Ring.Hom.Defs\npublic import Mathlib.Logic.Basic\npublic import Mathlib.Tactic.CrossRefAttribute\npublic import Mathlib.Tactic.Ring\n\nNamespace:\n(root)\n\nLocal context:\n/-\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-/\n/-!\n# Coprime elements of a ring or monoid\n\n## Main definition\n\n* `IsCoprime x y`: that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\n that `a * x + b * y = 1`. Note that elements with no common divisors (`IsRelPrime`) are not\n necessarily coprime, e.g., the multivariate polynomials `x₁` and `x₂` are not coprime.\n The two notions are equivalent in Bézout rings, see `isRelPrime_iff_isCoprime`.\n\nThis file also contains lemmas about `IsRelPrime` parallel to `IsCoprime`.\n\nSee also `RingTheory.Coprime.Lemmas` for further development of coprime elements.\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nsection CommSemiring\n\nvariable {R : Type u} [CommSemiring R] (x y z w : R)\n\n/-- The proposition that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\nthat `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,\ne.g., the multivariate polynomials `x₁` and `x₂` are not coprime. -/\n@[wikidata Q104752]\ndef IsCoprime : Prop :=\n ∃ a b, a * x + b * y = 1\n\nvariable {x y z w}\n\n@[symm]\ntheorem IsCoprime.symm (H : IsCoprime x y) : IsCoprime y x :=\n let ⟨a, b, H⟩ := H\n ⟨b, a, by rw [add_comm, H]⟩\n\ntheorem isCoprime_comm : IsCoprime x y ↔ IsCoprime y x :=\n ⟨IsCoprime.symm, IsCoprime.symm⟩\n\ntheorem isCoprime_self : IsCoprime x x ↔ IsUnit x :=\n ⟨fun ⟨a, b, h⟩ => .of_mul_eq_one (a + b) <| by rwa [mul_comm, add_mul], fun h =>\n let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 h\n ⟨b, 0, by rwa [zero_mul, add_zero]⟩⟩\n\ntheorem isCoprime_zero_left : IsCoprime 0 x ↔ IsUnit x :=\n ⟨fun ⟨a, b, H⟩ => .of_mul_eq_one b <| by rwa [mul_zero, zero_add, mul_comm] at H, fun H =>\n let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 H\n ⟨1, b, by rwa [one_mul, zero_add]⟩⟩\n\ntheorem isCoprime_zero_right : IsCoprime x 0 ↔ IsUnit x :=\n isCoprime_comm.trans isCoprime_zero_left\n\ntheorem not_isCoprime_zero_zero [Nontrivial R] : ¬IsCoprime (0 : R) 0 :=\n mt isCoprime_zero_right.mp not_isUnit_zero\n\nlemma IsCoprime.intCast {R : Type*} [CommRing R] {a b : ℤ} (h : IsCoprime a b) :\n IsCoprime (a : R) (b : R) := by\n rcases h with ⟨u, v, H⟩\n use u, v\n rw_mod_cast [H]\n exact Int.cast_one\n\n/-- If a 2-vector `p` satisfies `IsCoprime (p 0) (p 1)`, then `p ≠ 0`. -/\ntheorem IsCoprime.ne_zero [Nontrivial R] {p : Fin 2 → R} (h : IsCoprime (p 0) (p 1)) : p ≠ 0 := by\n rintro rfl\n exact not_isCoprime_zero_zero h\n\ntheorem IsCoprime.ne_zero_or_ne_zero [Nontrivial R] (h : IsCoprime x y) : x ≠ 0 ∨ y ≠ 0 := by\n apply not_or_of_imp\n rintro rfl rfl\n exact not_isCoprime_zero_zero h\n\ntheorem isCoprime_one_left : IsCoprime 1 x :=\n ⟨1, 0, by rw [one_mul, zero_mul, add_zero]⟩\n\ntheorem isCoprime_one_right : IsCoprime x 1 :=\n ⟨0, 1, by rw [one_mul, zero_mul, zero_add]⟩\n\ntheorem IsCoprime.dvd_of_dvd_mul_right (H1 : IsCoprime x z) (H2 : x ∣ y * z) : x ∣ y := by\n let ⟨a, b, H⟩ := H1\n rw [← mul_one y, ← H, mul_add, ← mul_assoc, mul_left_comm]\n exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)\n\ntheorem IsCoprime.dvd_of_dvd_mul_left (H1 : IsCoprime x y) (H2 : x ∣ y * z) : x ∣ z := by\n let ⟨a, b, H⟩ := H1\n rw [← one_mul z, ← H, add_mul, mul_right_comm, mul_assoc b]\n exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)\n\ntheorem IsCoprime.mul_left (H1 : IsCoprime x z) (H2 : IsCoprime y z) : IsCoprime (x * y) z :=\n let ⟨a, b, h1⟩ := H1\n let ⟨c, d, h2⟩ := H2\n ⟨a * c, a * x * d + b * c * y + b * d * z,\n calc a * c * (x * y) + (a * x * d + b * c * y + b * d * z) * z\n _ = (a * x + b * z) * (c * y + d * z) := by ring\n _ = 1 := by rw [h1, h2, mul_one]\n ⟩\n\ntheorem IsCoprime.mul_right (H1 : IsCoprime x y) (H2 : IsCoprime x z) : IsCoprime x (y * z) := by\n rw [isCoprime_comm] at H1 H2 ⊢\n exact H1.mul_left H2\n\ntheorem IsCoprime.mul_dvd (H : IsCoprime x y) (H1 : x ∣ z) (H2 : y ∣ z) : x * y ∣ z := by\n obtain ⟨a, b, h⟩ := H\n rw [← mul_one z, ← h, mul_add]\n apply dvd_add\n · rw [mul_comm z, mul_assoc]\n exact (mul_dvd_mul_left _ H2).mul_left _\n · rw [mul_comm b, ← mul_assoc]\n exact (mul_dvd_mul_right H1 _).mul_right _\n\ntheorem IsCoprime.of_mul_left_left (H : IsCoprime (x * y) z) : IsCoprime x z :=\n let ⟨a, b, h⟩ := H\n ⟨a * y, b, by rwa [mul_right_comm, mul_assoc]⟩\n\ntheorem IsCoprime.of_mul_left_right (H : IsCoprime (x * y) z) : IsCoprime y z := by\n rw [mul_comm] at H\n exact H.of_mul_left_left\n\ntheorem IsCoprime.of_mul_right_left (H : IsCoprime x (y * z)) : IsCoprime x y := by\n rw [isCoprime_comm] at H ⊢\n exact H.of_mul_left_left\n\ntheorem IsCoprime.of_mul_right_right (H : IsCoprime x (y * z)) : IsCoprime x z := by\n rw [mul_comm] at H\n exact H.of_mul_right_left\n\ntheorem IsCoprime.mul_left_iff : IsCoprime (x * y) z ↔ IsCoprime x z ∧ IsCoprime y z :=\n ⟨fun H => ⟨H.of_mul_left_left, H.of_mul_left_right⟩, fun ⟨H1, H2⟩ => H1.mul_left H2⟩\n\ntheorem IsCoprime.mul_right_iff : IsCoprime x (y * z) ↔ IsCoprime x y ∧ IsCoprime x z := by\n rw [isCoprime_comm, IsCoprime.mul_left_iff, isCoprime_comm, @isCoprime_comm _ _ z]\n\ntheorem IsCoprime.of_isCoprime_of_dvd_left (h : IsCoprime y z) (hdvd : x ∣ y) : IsCoprime x z := by\n obtain ⟨d, rfl⟩ := hdvd\n exact IsCoprime.of_mul_left_left h\n\ntheorem IsCoprime.of_isCoprime_of_dvd_right (h : IsCoprime z y) (hdvd : x ∣ y) : IsCoprime z x :=\n (h.symm.of_isCoprime_of_dvd_left hdvd).symm\n\n@[gcongr]\ntheorem IsCoprime.mono (h₁ : x ∣ y) (h₂ : z ∣ w) (h : IsCoprime y w) : IsCoprime x z :=\n h.of_isCoprime_of_dvd_left h₁ |>.of_isCoprime_of_dvd_right h₂\n\ntheorem IsCoprime.isUnit_of_dvd (H : IsCoprime x y) (d : x ∣ y) : IsUnit x :=\n let ⟨k, hk⟩ := d\n isCoprime_self.1 <| IsCoprime.of_mul_right_left <| show IsCoprime x (x * k) from hk ▸ H\n\ntheorem IsCoprime.isUnit_of_associated {x y : R} (h₁ : IsCoprime x y) (h₂ : Associated x y) :\n IsUnit x ∧ IsUnit y :=\n ⟨h₁.isUnit_of_dvd (h₂.dvd), h₁.symm.isUnit_of_dvd (h₂.dvd')⟩\n\ntheorem IsCoprime.isUnit_of_dvd' {a b x : R} (h : IsCoprime a b) (ha : x ∣ a) (hb : x ∣ b) :\n IsUnit x :=\n (h.of_isCoprime_of_dvd_left ha).isUnit_of_dvd hb\n\ntheorem IsCoprime.isRelPrime {a b : R} (h : IsCoprime a b) : IsRelPrime a b :=\n fun _ ↦ h.isUnit_of_dvd'\n\ntheorem IsCoprime.map (H : IsCoprime x y) {S : Type v} [CommSemiring S] (f : R →+* S) :\n IsCoprime (f x) (f y) :=\n let ⟨a, b, h⟩ := H\n ⟨f a, f b, by rw [← f.map_mul, ← f.map_mul, ← f.map_add, h, f.map_one]⟩\n\ntheorem IsCoprime.of_add_mul_left_left (h : IsCoprime (x + y * z) y) : IsCoprime x y :=\n let ⟨a, b, H⟩ := h\n ⟨a, a * z + b, by\n simpa only [add_mul, mul_add, add_assoc, add_comm, add_left_comm, mul_assoc, mul_comm,\n mul_left_comm] using H⟩\n\ntheorem IsCoprime.of_add_mul_right_left (h : IsCoprime (x + z * y) y) : IsCoprime x y := by\n rw [mul_comm] at h\n exact h.of_add_mul_left_left\n\ntheorem IsCoprime.of_add_mul_left_right (h : IsCoprime x (y + x * z)) : IsCoprime x y := by\n rw [isCoprime_comm] at h ⊢\n exact h.of_add_mul_left_left\n\nTarget:\ntheorem IsCoprime.of_add_mul_right_right (h : IsCoprime x (y + z * x)) : IsCoprime x y :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_e67fbd8fa711","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"378f8522e40a733deb1bda52d472c4afdcf58042319125975dc8a8e222a258ff","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Coprime","family_id":"iscoprime","file_id":"mathlib/Mathlib/RingTheory/Coprime/Basic.lean","sample_id":"e67fbd8fa7119d4589c790cca327cd3cc10be94a9ff804cf1a763f257fd55a16"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4a44785a09d00583d0a2883ace933a9a1a54511e619ea74fa77bdba1468dfd34","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"af9494883fe94d295f241aa211d9277760ea07464a3ef910246c5069ddb43c90","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"752ce8369192939adc72ab17549364fbc0f233d3f70f2ac0b1ccc05a31dd39c2","source_sha256":"90c64177e9fa7320c5cf96c0ae3a1383ca6bb2e38ff9d15f6eac1d27c5994294","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n algebraize [f, g, g.comp f]\n exact Algebra.EssFiniteType.comp_iff R S T","hard_negative":true,"metrics":{"chosen_tokens":21,"rejected_tokens":3,"token_jaccard":0.117647,"token_length_ratio":0.142857},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"4f64ef16ddd9b8b461b09e96bd33b9f6994997cfddc207dbb2a852691c3595d1","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.EssentialFiniteness\npublic import Mathlib.RingTheory.Localization.AtPrime.Basic\npublic import Mathlib.RingTheory.LocalRing.ResidueField.Basic\npublic import Mathlib.RingTheory.LocalProperties.Basic\n\nNamespace:\nRingHom.EssFiniteType\n\nLocal context:\n/-\nCopyright (c) 2026 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten\n-/\n/-!\n# Meta properties of essentially of finite type ring homomorphisms\n-/\n\npublic section\n\nnamespace RingHom.EssFiniteType\n\nvariable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]\n\nlemma comp {f : R →+* S} {g : S →+* T} (hf : f.EssFiniteType) (hg : g.EssFiniteType) :\n (g.comp f).EssFiniteType := by\n algebraize [f, g, g.comp f]\n exact Algebra.EssFiniteType.comp R S T\n\nTarget:\nlemma comp_iff {f : R →+* S} {g : S →+* T} (hf : f.EssFiniteType) :\n (g.comp f).EssFiniteType ↔ g.EssFiniteType :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_752ce8369192","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"4ad18aa3f2009922243dfb1114e1e8639ee0685bbfcfc59da24259f7b9495834","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RingHom","family_id":"comp_iff","file_id":"mathlib/Mathlib/RingTheory/RingHom/EssFiniteType.lean","sample_id":"752ce8369192939adc72ab17549364fbc0f233d3f70f2ac0b1ccc05a31dd39c2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a99eaa929f1571061af5dfc1d3cfb5de03b1c0fe6cc9ea4eea006d79d50ed5e9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d6f3807fdb3546c64b02683a0fb1347711c9d14b38bd4ee99fe739f4f0753f8c","source_sha256":"456308686f66aa5de2ab2b8c42c79fb06947ad9dfe96a33de3e67849016cad10","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases eventually_norm_mfderiv_extChartAt_lt I x with ⟨C, C_pos, hC⟩\n lift C to ℝ≥0 using C_pos.le\n simp only [gt_iff_lt, NNReal.coe_pos] at C_pos\n refine ⟨C, C_pos, ?_⟩\n filter_upwards [hC] with y hy\n simp only [enorm, nnnorm]\n exact_mod_cast hy","hard_negative":true,"metrics":{"chosen_tokens":59,"rejected_tokens":8,"token_jaccard":0.023256,"token_length_ratio":0.135593},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"501d740c929a4d46a8125d309c7e96f585915be02152afe84c9b2ceea181c213","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Manifold.MFDeriv.Atlas\npublic import Mathlib.Geometry.Manifold.Riemannian.PathELength\npublic import Mathlib.Geometry.Manifold.VectorBundle.Riemannian\npublic import Mathlib.Geometry.Manifold.VectorBundle.Tangent\npublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.ContDiff\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-! # Riemannian manifolds\n\nA Riemannian manifold `M` is a real manifold such that its tangent spaces are endowed with an\ninner product, depending smoothly on the point, and such that `M` has an emetric space\nstructure for which the distance is the infimum of lengths of paths.\n\nWe register a Prop-valued typeclass `IsRiemannianManifold I M` recording this fact, building on top\nof `[EMetricSpace M] [RiemannianBundle (fun (x : M) ↦ TangentSpace I x)]`.\n\nWe show that an inner product vector space, with the associated canonical Riemannian metric,\nsatisfies the predicate `IsRiemannianManifold 𝓘(ℝ, E) E`.\n\nIn a general manifold with a Riemannian metric, we define the associated extended distance in the\nmanifold, and show that it defines the same topology as the pre-existing one. Therefore, one\nmay endow the manifold with an emetric space structure, see `EMetricSpace.ofRiemannianMetric`.\nBy definition, it then satisfies the predicate `IsRiemannianManifold I M`.\n\nThe following code block is the standard way to say \"Let `M` be a `C^∞` Riemannian manifold\".\n```\nopen scoped Bundle\nvariable\n {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H}\n {M : Type*} [EMetricSpace M] [ChartedSpace H M] [IsManifold I ∞ M]\n [RiemannianBundle (fun (x : M) ↦ TangentSpace I x)]\n [IsContMDiffRiemannianBundle I ∞ E (fun (x : M) ↦ TangentSpace I x)]\n [IsRiemannianManifold I M]\n```\nTo register a `C^n` manifold for a general `n`, one should replace `[IsManifold I ∞ M]` with\n`[IsManifold I n M] [IsManifold I 1 M]`, where the second one is needed to ensure that the\ntangent bundle is well behaved (not necessary when `n` is concrete like 2 or 3 as there are\nautomatic instances for these cases). One can require whatever regularity one wants in the\n`IsContMDiffRiemannianBundle` instance above, for example\n`[IsContMDiffRiemannianBundle I n E (fun (x : M) ↦ TangentSpace I x)]`, and one should also add\n`[IsContinuousRiemannianBundle E (fun (x : M) ↦ TangentSpace I x)]` (as above, Lean cannot infer\nthe latter from the former as it cannot guess `n`).\n-/\n\n@[expose] public section\n\nopen Bundle Bornology Set MeasureTheory Manifold Filter\nopen scoped ENNReal ContDiff Topology\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner ℝ x y\n\nnoncomputable section\n\nvariable\n {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {n : ℕ∞ω}\n {M : Type*} [TopologicalSpace M] [ChartedSpace H M]\n\nsection\n\nvariable [PseudoEMetricSpace M] [ChartedSpace H M]\n [RiemannianBundle (fun (x : M) ↦ TangentSpace% x)]\n\nvariable (I M) in\n/-- Consider a manifold in which the tangent spaces are already endowed with an inner product, and\nthe space is already endowed with an extended distance. We say that this is a Riemannian manifold\nif the distance is given by the infimum of the lengths of `C^1` paths, measured using the norm in\nthe tangent spaces.\n\nThis is a `Prop`-valued typeclass, on top of existing data.\n\nIf you need to *construct* a distance using a Riemannian structure,\nsee `EMetricSpace.ofRiemannianMetric`. -/\nclass IsRiemannianManifold : Prop where\n out (x y : M) : edist x y = riemannianEDist I x y\n\nend\n\nsection\n\n/-!\n### Riemannian structure on an inner product vector space\n\nWe endow an inner product vector space with the canonical Riemannian metric, given by the\ninner product of the vector space in each of the tangent spaces, and we show that this construction\nsatisfies the `IsRiemannianManifold 𝓘(ℝ, E) E` predicate, i.e., the extended distance between\ntwo points is the infimum of the length of paths between these points.\n-/\n\nvariable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]\n\nset_option backward.isDefEq.respectTransparency false in\nvariable (F) in\n/-- The standard Riemannian metric on a vector space with an inner product, given by this inner\nproduct on each tangent space. -/\nnoncomputable def riemannianMetricVectorSpace :\n ContMDiffRiemannianMetric 𝓘(ℝ, F) ω F (fun (x : F) ↦ TangentSpace% x) where\n inner x := (innerSL ℝ (E := F) : F →L[ℝ] F →L[ℝ] ℝ)\n symm x v w := real_inner_comm _ _\n pos x v hv := real_inner_self_pos.2 hv\n isVonNBounded x := by\n change IsVonNBounded ℝ {v : F | ⟪v, v⟫ < 1}\n have : Metric.ball (0 : F) 1 = {v : F | ⟪v, v⟫ < 1} := by\n ext v\n simp only [Metric.mem_ball, dist_zero_right, norm_eq_sqrt_re_inner (𝕜 := ℝ),\n RCLike.re_to_real, Set.mem_setOf_eq]\n conv_lhs => rw [show (1 : ℝ) = √1 by simp]\n rw [Real.sqrt_lt_sqrt_iff]\n exact real_inner_self_nonneg\n rw [← this]\n exact NormedSpace.isVonNBounded_ball ℝ F 1\n contMDiff := by\n intro x\n rw [contMDiffAt_section]\n convert! contMDiffAt_const (c := innerSL ℝ)\n ext v w\n simp [hom_trivializationAt_apply, ContinuousLinearMap.inCoordinates, TangentSpace]\n\nnoncomputable instance : RiemannianBundle (fun (x : F) ↦ TangentSpace% x) :=\n ⟨(riemannianMetricVectorSpace F).toRiemannianMetric⟩\n\nset_option backward.isDefEq.respectTransparency false in\nlemma norm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖ = ‖letI V : F := v; V‖ := by\n rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner]\n\nlemma nnnorm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖₊ = ‖letI V : F := v; V‖₊ := by\n simp [nnnorm, norm_tangentSpace_vectorSpace]\n\nlemma enorm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖ₑ = ‖letI V : F := v; V‖ₑ := by\n simp [enorm, nnnorm_tangentSpace_vectorSpace]\n\nopen MeasureTheory Measure\n\nlemma lintegral_fderiv_lineMap_eq_edist {x y : E} :\n ∫⁻ t in Icc 0 1, ‖fderivWithin ℝ (ContinuousAffineMap.lineMap (R := ℝ) x y) (Icc 0 1) t 1‖ₑ\n = edist x y := by\n have : edist x y = ∫⁻ t in Icc (0 : ℝ) 1, ‖y - x‖ₑ := by\n simp [edist_comm x y, edist_eq_enorm_sub]\n rw [this]\n apply setLIntegral_congr_fun measurableSet_Icc (fun z hz ↦ ?_)\n rw [show y - x = fderiv ℝ (ContinuousAffineMap.lineMap (R := ℝ) x y) z 1 by simp]\n congr\n exact fderivWithin_eq_fderiv (uniqueDiffOn_Icc zero_lt_one _ hz)\n (ContinuousAffineMap.differentiableAt _)\n\n/-- An inner product vector space is a Riemannian manifold, i.e., the distance between two points\nis the infimum of the lengths of paths between these points. -/\ninstance : IsRiemannianManifold 𝓘(ℝ, F) F := by\n refine ⟨fun x y ↦ le_antisymm ?_ ?_⟩\n · simp only [riemannianEDist, le_iInf_iff]\n intro γ hγ\n let e : ℝ → F := γ ∘ (projIcc 0 1 zero_le_one)\n have D : ContDiffOn ℝ 1 e (Icc 0 1) :=\n contMDiffOn_iff_contDiffOn.mp (hγ.comp_contMDiffOn contMDiffOn_projIcc)\n rw [lintegral_norm_mfderiv_Icc_eq_pathELength_projIcc,\n pathELength_eq_lintegral_mfderivWithin_Icc]\n simp only [mfderivWithin_eq_fderivWithin, enorm_tangentSpace_vectorSpace]\n conv_lhs =>\n rw [edist_comm, edist_eq_enorm_sub, show x = e 0 by simp [e], show y = e 1 by simp [e]]\n exact (enorm_sub_le_lintegral_derivWithin_Icc_of_contDiffOn_Icc D zero_le_one).trans_eq rfl\n · let γ := ContinuousAffineMap.lineMap (R := ℝ) x y\n have : riemannianEDist 𝓘(ℝ, F) x y ≤ pathELength 𝓘(ℝ, F) γ 0 1 := by\n apply riemannianEDist_le_pathELength ?_ (by simp [γ, ContinuousAffineMap.coe_lineMap_eq])\n (by simp [γ, ContinuousAffineMap.coe_lineMap_eq]) zero_le_one\n rw [contMDiffOn_iff_contDiffOn]\n exact γ.contDiff.contDiffOn\n apply this.trans_eq\n rw [pathELength_eq_lintegral_mfderivWithin_Icc]\n simp only [mfderivWithin_eq_fderivWithin, enorm_tangentSpace_vectorSpace]\n exact lintegral_fderiv_lineMap_eq_edist\n\nend\n\nsection\n\n/-!\n### Constructing a distance from a Riemannian structure\n\nLet `M` be a real manifold with a Riemannian structure. We construct the associated distance and\nshow that the associated topology coincides with the pre-existing topology. Therefore, one may\nendow `M` with an emetric space structure, called `EMetricSpace.ofRiemannianMetric`.\nMoreover, we show that in this case the resulting emetric space satisfies the predicate\n`IsRiemannianManifold I M`.\n\nShowing that the distance topology coincides with the pre-existing topology is not trivial. The\ntwo inclusions are proved respectively in `eventually_riemannianEDist_lt` and\n`setOf_riemannianEDist_lt_subset_nhds`.\n\nFor the first one, we have to show that points which are close for the topology are at small\ndistance. For this, we use the path between the two points which is the pullback of the segment\nin the extended chart, and argue that it is short because the images are close in the extended\nchart.\n\nFor the second one, we have to show that any neighborhood of `x` contains all the points `y`\nwith `riemannianEDist x y < c` for some `c > 0`. For this, we argue that a short path from `x`\nto `y` remains short in the extended chart, and therefore it doesn't have the time to exit\nthe image of the neighborhood in the extended chart.\n-/\n\nopen Manifold Metric\nopen scoped NNReal\n\nvariable [RiemannianBundle (fun (x : M) ↦ TangentSpace% x)]\n [IsManifold I 1 M] [IsContinuousRiemannianBundle E (fun (x : M) ↦ TangentSpace% x)]\n\n/-- Register on the tangent space to a normed vector space the same `NormedAddCommGroup` structure\nas in the vector space.\n\nShould not be a global instance, as it does not coincide definitionally with the Riemannian\nstructure for inner product spaces, but can be activated locally. -/\n@[instance_reducible]\ndef normedAddCommGroupTangentSpaceVectorSpace (x : E) :\n NormedAddCommGroup (TangentSpace% x) :=\n inferInstanceAs (NormedAddCommGroup E)\n\nattribute [local instance] normedAddCommGroupTangentSpaceVectorSpace\n\n/-- Register on the tangent space to a normed vector space the same `NormedSpace` structure\nas in the vector space.\n\nShould not be a global instance, as it does not coincide definitionally with the Riemannian\nstructure for inner product spaces, but can be activated locally. -/\n@[instance_reducible]\ndef normedSpaceTangentSpaceVectorSpace (x : E) : NormedSpace ℝ (TangentSpace% x) :=\n inferInstanceAs (NormedSpace ℝ E)\n\nattribute [local instance] normedSpaceTangentSpaceVectorSpace\n\nvariable (I)\n\nset_option backward.isDefEq.respectTransparency false in\nlemma eventually_norm_mfderiv_extChartAt_lt (x : M) :\n ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ < C := by\n rcases eventually_norm_trivializationAt_lt E (fun (x : M) ↦ TangentSpace% x) x\n with ⟨C, C_pos, hC⟩\n refine ⟨C, C_pos, ?_⟩\n have hx : (chartAt H x).source ∈ 𝓝 x := chart_source_mem_nhds H x\n filter_upwards [hC, hx] with y hy h'y\n rwa [← TangentBundle.continuousLinearMapAt_trivializationAt h'y]\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma eventually_enorm_mfderiv_extChartAt_lt (x : M) :\n ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ₑ < C :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"c44ab7d4c7bdbda5386edb23dbfb6ba04decb7a2b1df6f2a96393f03992a5d4e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Manifold","family_id":"eventually_enorm_mfderiv_extchartat_lt","file_id":"mathlib/Mathlib/Geometry/Manifold/Riemannian/Basic.lean","sample_id":"d6f3807fdb3546c64b02683a0fb1347711c9d14b38bd4ee99fe739f4f0753f8c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dbfb47395ef398e947f71379cc7f492edfa1e8a2486b71d17d0fa84edf275e35","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ceb0338ec877442fa29454b57c2408792f66e9edee93853db204471fc07e420a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"08d54790790b4504427f1034b404bc383b9faf0c3904a832d988759582c2ba11","source_sha256":"ad7723f259d906404f2439f75ed42dbf632d4e1b3851e9262d6a24c449189a41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n calc\n Module.rank ℝ (span ℝ (-x +ᵥ s)) ≤\n Module.rank ℝ (span ℝ\n (-x +ᵥ affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) : Set V)) := by\n push_cast\n refine Submodule.rank_mono ?_\n gcongr\n exact (subset_convexHull ..).trans <| hs.convexHull_subset_affineSpan_isVisible hx\n _ = Module.rank ℝ (span ℝ (-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y})) := by\n suffices h :\n -x +ᵥ (affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) : Set V) =\n span ℝ (-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) by\n rw [AffineSubspace.coe_pointwise_vadd, h, span_span]\n simp [← AffineSubspace.coe_pointwise_vadd, AffineSubspace.pointwise_vadd_span,\n vadd_set_insert, -coe_affineSpan, affineSpan_insert_zero]\n _ ≤ #(-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) := rank_span_le _\n _ = #{y ∈ s | IsVisible ℝ (convexHull ℝ s) x y} := by simp","hard_negative":true,"metrics":{"chosen_tokens":251,"rejected_tokens":5,"token_jaccard":0.048387,"token_length_ratio":0.01992},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"5032519fd0986436e6330d364865695d044e8a1a9a6f073e28b550263f73d122","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Algebra.Group.Pointwise.Set.Card\npublic import Mathlib.Analysis.Convex.Between\npublic import Mathlib.Analysis.Convex.Combination\npublic import Mathlib.Topology.Algebra.Affine\npublic import Mathlib.Topology.MetricSpace.Pseudo.Lemmas\npublic import Mathlib.Topology.Order.Monotone\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\n/-!\n# Points in sight\n\nThis file defines the relation of visibility with respect to a set, and lower bounds how many\nelements of a set a point sees in terms of the dimension of that set.\n\n## TODO\n\nThe art gallery problem can be stated using the visibility predicate: A set `A` (the art gallery) is\nguarded by a finite set `G` (the guards) iff `∀ a ∈ A, ∃ g ∈ G, IsVisible ℝ sᶜ a g`.\n-/\n\n@[expose] public section\n\nopen AffineMap Filter Finset Set\nopen scoped Cardinal Pointwise Topology\n\nvariable {𝕜 V P : Type*}\n\nsection AddTorsor\nvariable [Field 𝕜] [LinearOrder 𝕜] [IsOrderedRing 𝕜]\n [AddCommGroup V] [Module 𝕜 V] [AddTorsor V P]\n {s t : Set P} {x y z : P}\n\nomit [IsOrderedRing 𝕜] in\nvariable (𝕜) in\n/-- Two points are visible to each other through a set if no point of that set lies strictly\nbetween them.\n\nBy convention, a point `x` sees itself through any set `s`, even when `x ∈ s`. -/\ndef IsVisible (s : Set P) (x y : P) : Prop := ∀ ⦃z⦄, z ∈ s → ¬ Sbtw 𝕜 x z y\n\n@[simp, refl]\nlemma IsVisible.rfl : IsVisible 𝕜 s x x := by simp [IsVisible]\n\nlemma isVisible_comm : IsVisible 𝕜 s x y ↔ IsVisible 𝕜 s y x := by\n simp [IsVisible, sbtw_comm]\n\n@[symm] alias ⟨IsVisible.symm, _⟩ := isVisible_comm\n\nomit [IsOrderedRing 𝕜] in\nlemma IsVisible.mono (hst : s ⊆ t) (ht : IsVisible 𝕜 t x y) : IsVisible 𝕜 s x y :=\n fun _z hz ↦ ht <| hst hz\n\nlemma isVisible_iff_lineMap (hxy : x ≠ y) :\n IsVisible 𝕜 s x y ↔ ∀ δ ∈ Set.Ioo (0 : 𝕜) 1, lineMap x y δ ∉ s := by\n simp [IsVisible, sbtw_iff_mem_image_Ioo_and_ne, hxy]\n aesop\n\nend AddTorsor\n\nsection Module\nvariable [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜]\n [AddCommGroup V] [Module 𝕜 V] {s : Set V} {x y z : V}\n\n/-- If a point `x` sees a convex combination of points of a set `s` through `convexHull ℝ s ∌ x`,\nthen it sees all terms of that combination.\n\nNote that the converse does not hold. -/\nlemma IsVisible.of_convexHull_of_pos {ι : Type*} {t : Finset ι} {a : ι → V} {w : ι → 𝕜}\n (hw₀ : ∀ i ∈ t, 0 ≤ w i) (hw₁ : ∑ i ∈ t, w i = 1) (ha : ∀ i ∈ t, a i ∈ s)\n (hx : x ∉ convexHull 𝕜 s) (hw : IsVisible 𝕜 (convexHull 𝕜 s) x (∑ i ∈ t, w i • a i)) {i : ι}\n (hi : i ∈ t) (hwi : 0 < w i) : IsVisible 𝕜 (convexHull 𝕜 s) x (a i) := by\n classical\n obtain hwi | hwi : w i = 1 ∨ w i < 1 := eq_or_lt_of_le <| (single_le_sum hw₀ hi).trans_eq hw₁\n · convert! hw\n rw [← one_smul 𝕜 (a i), ← hwi, eq_comm]\n rw [← hwi, ← sub_eq_zero, ← sum_erase_eq_sub hi,\n sum_eq_zero_iff_of_nonneg fun j hj ↦ hw₀ _ <| erase_subset _ _ hj] at hw₁\n refine sum_eq_single _ (fun j hj hji ↦ ?_) (by simp [hi])\n rw [hw₁ _ <| mem_erase.2 ⟨hji, hj⟩, zero_smul]\n rintro _ hε ⟨⟨ε, ⟨hε₀, hε₁⟩, rfl⟩, h⟩\n replace hε₀ : 0 < ε := hε₀.lt_of_ne <| by rintro rfl; simp at h\n replace hε₁ : ε < 1 := hε₁.lt_of_ne <| by rintro rfl; simp at h\n have : 0 < 1 - ε := by linarith\n have hwi : 0 < 1 - w i := by linarith\n refine hw (z := lineMap x (∑ j ∈ t, w j • a j) ((w i)⁻¹ / ((1 - ε) / ε + (w i)⁻¹)))\n ?_ <| sbtw_lineMap_iff.2 ⟨(ne_of_mem_of_not_mem ((convex_convexHull ..).sum_mem hw₀ hw₁\n fun i hi ↦ subset_convexHull _ _ <| ha _ hi) hx).symm, by positivity,\n (div_lt_one <| by positivity).2 ?_⟩\n · have : Wbtw 𝕜\n (lineMap x (a i) ε)\n (lineMap x (∑ j ∈ t, w j • a j) ((w i)⁻¹ / ((1 - ε) / ε + (w i)⁻¹)))\n (∑ j ∈ t.erase i, (w j / (1 - w i)) • a j) := by\n refine ⟨((1 - w i) / w i) / ((1 - ε) / ε + (1 - w i) / w i + 1), ⟨by positivity, ?_⟩, ?_⟩\n · refine (div_le_one <| by positivity).2 ?_\n calc\n (1 - w i) / w i = 0 + (1 - w i) / w i + 0 := by simp\n _ ≤ (1 - ε) / ε + (1 - w i) / w i + 1 := by gcongr <;> positivity\n have :\n w i • a i + (1 - w i) • ∑ j ∈ t.erase i, (w j / (1 - w i)) • a j = ∑ j ∈ t, w j • a j := by\n rw [smul_sum]\n simp_rw [smul_smul, mul_div_cancel₀ _ hwi.ne']\n exact add_sum_erase _ (fun i ↦ w i • a i) hi\n simp_rw [lineMap_apply_module, ← this]\n match_scalars <;> field\n refine (convex_convexHull _ _).mem_of_wbtw this hε <| (convex_convexHull _ _).sum_mem ?_ ?_ ?_\n · intro j hj\n positivity [hw₀ j <| erase_subset _ _ hj]\n · rw [← sum_div, sum_erase_eq_sub hi, hw₁, div_self hwi.ne']\n · exact fun j hj ↦ subset_convexHull _ _ <| ha _ <| erase_subset _ _ hj\n · exact lt_add_of_pos_left _ <| by positivity\n\nvariable [TopologicalSpace 𝕜] [OrderTopology 𝕜] [TopologicalSpace V] [IsTopologicalAddGroup V]\n [ContinuousSMul 𝕜 V]\n\n/-- One cannot see any point in the interior of a set. -/\nlemma IsVisible.eq_of_mem_interior (hsxy : IsVisible 𝕜 s x y) (hy : y ∈ interior s) :\n x = y := by\n by_contra! hxy\n suffices h : ∀ᶠ (_δ : 𝕜) in 𝓝[>] 0, False by obtain ⟨_, ⟨⟩⟩ := h.exists\n have hmem : ∀ᶠ (δ : 𝕜) in 𝓝[>] 0, lineMap y x δ ∈ s :=\n lineMap_continuous.continuousWithinAt.eventually_mem\n (by simpa using mem_interior_iff_mem_nhds.1 hy)\n filter_upwards [hmem, Ioo_mem_nhdsGT zero_lt_one] with δ hmem hsbt using hsxy.symm hmem (by aesop)\n\n/-- One cannot see any point of an open set. -/\nlemma IsOpen.eq_of_isVisible_of_left_mem (hs : IsOpen s) (hsxy : IsVisible 𝕜 s x y) (hy : y ∈ s) :\n x = y :=\n hsxy.eq_of_mem_interior (by simpa [hs.interior_eq])\n\nend Module\n\nsection Real\nvariable [AddCommGroup V] [Module ℝ V] {s : Set V} {x y z : V}\n\n/-- All points of the convex hull of a set `s` visible from a point `x ∉ convexHull ℝ s` lie in the\nconvex hull of such points that actually lie in `s`.\n\nNote that the converse does not hold. -/\nlemma IsVisible.mem_convexHull_isVisible (hx : x ∉ convexHull ℝ s) (hy : y ∈ convexHull ℝ s)\n (hxy : IsVisible ℝ (convexHull ℝ s) x y) :\n y ∈ convexHull ℝ {z ∈ s | IsVisible ℝ (convexHull ℝ s) x z} := by\n classical\n obtain ⟨ι, _, w, a, hw₀, hw₁, ha, rfl⟩ := mem_convexHull_iff_exists_fintype.1 hy\n rw [← Fintype.sum_subset (s := {i | w i ≠ 0})\n fun i hi ↦ mem_filter.2 ⟨mem_univ _, left_ne_zero_of_smul hi⟩]\n exact (convex_convexHull ..).sum_mem (fun i _ ↦ hw₀ _) (by rwa [sum_filter_ne_zero])\n fun i hi ↦ subset_convexHull _ _ ⟨ha _, IsVisible.of_convexHull_of_pos (fun _ _ ↦ hw₀ _) hw₁\n (by simpa) hx hxy (mem_univ _) <| (hw₀ _).lt_of_ne' (mem_filter.1 hi).2⟩\n\nvariable [TopologicalSpace V] [IsTopologicalAddGroup V] [ContinuousSMul ℝ V]\n\n/-- If `s` is a closed set, then any point `x` sees some point of `s` in any direction where there\nis something to see. -/\nlemma IsClosed.exists_wbtw_isVisible (hs : IsClosed s) (hy : y ∈ s) (x : V) :\n ∃ z ∈ s, Wbtw ℝ x z y ∧ IsVisible ℝ s x z := by\n let t : Set ℝ := Ici 0 ∩ lineMap x y ⁻¹' s\n have ht₁ : 1 ∈ t := by simpa [t]\n have ht : BddBelow t := bddBelow_Ici.inter_of_left\n let δ : ℝ := sInf t\n have hδ₁ : δ ≤ 1 := csInf_le ht ht₁\n obtain ⟨hδ₀, hδ⟩ : 0 ≤ δ ∧ lineMap x y δ ∈ s :=\n (isClosed_Ici.inter <| hs.preimage lineMap_continuous).csInf_mem ⟨1, ht₁⟩ ht\n refine ⟨lineMap x y δ, hδ, wbtw_lineMap_iff.2 <| .inr ⟨hδ₀, hδ₁⟩, ?_⟩\n rintro _ hε ⟨⟨ε, ⟨hε₀, hε₁⟩, rfl⟩, -, h⟩\n replace hδ₀ : 0 < δ := hδ₀.lt_of_ne' <| by rintro hδ₀; simp [hδ₀] at h\n replace hε₁ : ε < 1 := hε₁.lt_of_ne <| by rintro rfl; simp at h\n rw [lineMap_lineMap_right] at hε\n exact (csInf_le ht ⟨mul_nonneg hε₀ hδ₀.le, hε⟩).not_gt <| mul_lt_of_lt_one_left hδ₀ hε₁\n\n-- TODO: Once we have cone hulls, the RHS can be strengthened to\n-- `coneHull ℝ x {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}`\n/-- A set whose convex hull is closed lies in the cone based at a point `x` generated by its points\nvisible from `x` through its convex hull. -/\nlemma IsClosed.convexHull_subset_affineSpan_isVisible (hs : IsClosed (convexHull ℝ s))\n (hx : x ∉ convexHull ℝ s) :\n convexHull ℝ s ⊆ affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) := by\n rintro y hy\n obtain ⟨z, hz, hxzy, hxz⟩ := hs.exists_wbtw_isVisible hy x\n -- TODO: `calc` doesn't work with `∈` :(\n exact AffineSubspace.right_mem_of_wbtw hxzy (subset_affineSpan _ _ <| subset_union_left rfl)\n (affineSpan_mono _ subset_union_right <| convexHull_subset_affineSpan _ <|\n hxz.mem_convexHull_isVisible hx hz) (ne_of_mem_of_not_mem hz hx).symm\n\nopen Submodule in\n/-- If `s` is a closed set of dimension `d` and `x` is a point outside of its convex hull,\nthen `x` sees at least `d` points of the convex hull of `s` that actually lie in `s`. -/\n\nTarget:\nlemma rank_le_card_isVisible (hs : IsClosed (convexHull ℝ s)) (hx : x ∉ convexHull ℝ s) :\n Module.rank ℝ (span ℝ (-x +ᵥ s)) ≤ #{y ∈ s | IsVisible ℝ (convexHull ℝ s) x y} :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_08d54790790b","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"65abf98bd48d8c856508da7e0c646e07916add54d0fdf18220cabe0a5b16af06","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Convex","family_id":"rank_le_card_isvisible","file_id":"mathlib/Mathlib/Analysis/Convex/Visible.lean","sample_id":"08d54790790b4504427f1034b404bc383b9faf0c3904a832d988759582c2ba11"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1a4f85515bab94ebedb0653eaef526303090ac4170d93ee5d3f143fddf238577","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"179213b4b1790f814f6bef379a7f4b83d4841a44c03880c362f9560867a1f49c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6ded992d9dff50ff1f7713cf83e3d3d46911843ee49f5692a23de0fb332e63ed","source_sha256":"dadd27768139699caee7d5df148073f0d11219956d3bdcf7101de781c664a7fc","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← LinearMap.range_eq_top,\n ← (Submodule.map_injective_of_injective h1Cotangentι_injective).eq_iff,\n ← LinearMap.range_comp, ← P.h1CotangentEquivCotangent_comp_map, LinearMap.range_comp,\n ← (Algebra.H1Cotangent.exact_map_δ R P.Ring S).linearMap_ker_eq, Submodule.map_top,\n ← exact_hCotangentι_cotangentComplex.linearMap_ker_eq, Submodule.map_equiv_eq_comap_symm,\n LinearMap.ker, LinearMap.ker, ← Submodule.comap_comp]\n congr\n rw [LinearEquiv.comp_toLinearMap_symm_eq, P.cotangentComplex_comp_h1CotangentEquivCotangent]","hard_negative":true,"metrics":{"chosen_tokens":90,"rejected_tokens":5,"token_jaccard":0.075,"token_length_ratio":0.055556},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"5188c6efbd51880f386855e3cadceb1ede5a9ff6be00ce0cb3a40a44838a5db9","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.JacobiZariski\n\nNamespace:\nAlgebra.Extension\n\nLocal context:\n/-\nCopyright (c) 2024 Bingyu Xia. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bingyu Xia\n-/\n/-!\n# Extension of Scalars for Algebra Extensions\n\nThis file provides APIs for extending the base ring of an algebra extension `P : Extension R S`\nto its own extension ring `P.Ring`. We introduce canonical maps and isomorphisms between\nthe cotangent spaces and the first homology of naive cotangent complex associated with\n`P.extendScalars` and `P`. We provide commutativity results of these maps and ismorphisms\n(See https://github.com/leanprover-community/mathlib4/pull/39520 for an image of the full diagram).\nIn particular, we show the boundary map of the Jacobi-Zariski sequence of `R → P.Ring → S`\ncoincides with `P.cotangentComplex` via a canonical isomorphism `P.h1CotangentEquivCotangent`.\n\n## Main definitions and results\n\n- `extendScalars`: Views `P : Extension R S` as `Extension P.Ring S`.\n- `toExtendScalars`: The canonical homomorphism from `P` to `P.extendScalars` induced by\n the identity map on the underlying extension rings.\n- `cotangentExtendScalarsEquiv` : The linear equivalence between the cotangent spaces of\n `P.extensScalars` and `P` induced by the identity map.\n- `h1CotangentExtendScalarsEquiv`: `P.extensScalars` can be used to compute the first homology of\n the naive cotangent complex of `S` over `P.Ring`.\n- `h1CotangentEquivOfSurjective`: If `R → P.Ring` is surjective, this is the linear isomorphism\n induced by `P.h1Cotangentι`.\n- `h1CotangentEquivCotangent`: This is the linear equivalence between `H1Cotangent P.Ring S` and\n `P.Cotangent` defined by the composition of `h1CotangentExtendScalarsEquiv.symm`,\n `h1CotangentEquivOfSurjective` and `cotangentExtendScalarsEquiv`.\n- `cotangentComplex_comp_h1CotangentEquivCotangent`,\n `h1CotangentEquivCotangent_comp_map`: commutativity results.\n\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential\n\nnamespace Algebra.Extension\n\nuniverse w v u\n\nvariable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n\n/-- Given an extension `P` of `S` over `R`, `P.extendScalars` is the same extension\nbut viewed as an extension of `S` over `P.Ring`. -/\n@[simps]\ndef extendScalars {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n (P : Extension.{w} R S) : Extension P.Ring S where\n Ring := P.Ring\n σ := P.σ\n algebraMap_σ := P.algebraMap_σ\n\nset_option backward.isDefEq.respectTransparency false in\nset_option backward.defeqAttrib.useBackward true in\n/-- The canonical homomorphism from `P` to `P.extendScalars` induced by the identity map\non the underlying extension rings. -/\n@[simps!]\nnoncomputable\ndef toExtendScalars {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n (P : Extension.{w} R S) : P.Hom P.extendScalars :=\n .ofAlgHom (IsScalarTower.toAlgHom R P.Ring P.extendScalars.Ring)\n (by dsimp; ext; simp)\n\n/-- `Extension.extendScalars` does not change the cotangent space of an extension. -/\nnoncomputable\ndef cotangentExtendScalarsEquiv {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n P.extendScalars.Cotangent ≃ₗ[S] P.Cotangent :=\n LinearEquiv.refl _ _\n\n@[simp]\nlemma cotangentExtendScalarsEquiv_symm_toLinearMap (P : Extension.{w} R S) :\n P.cotangentExtendScalarsEquiv.symm.toLinearMap = Cotangent.map P.toExtendScalars := by\n ext x\n obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x\n rfl\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem H1Cotangent.map_toExtendScalars_injective (P : Extension.{w} R S) :\n Function.Injective (H1Cotangent.map P.toExtendScalars) := by\n rw [← LinearMap.ker_eq_bot, H1Cotangent.map, LinearMap.ker_restrict,\n ← cotangentExtendScalarsEquiv_symm_toLinearMap, LinearEquiv.ker,\n Submodule.comap_bot, Submodule.ker_subtype]\n\n/-- The first homology of the naive cotangent complex of `P.extendScalars` is\nlinearly equivalent to that of `S` over `P.Ring`. -/\n@[simps! toLinearMap]\nnoncomputable\ndef h1CotangentExtendScalarsEquiv {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n P.extendScalars.H1Cotangent ≃ₗ[S] H1Cotangent P.Ring S :=\n Extension.H1Cotangent.equiv\n (.ofAlgHom (Algebra.ofId _ _) (by ext)) P.extendScalars.defaultHom\n\n@[simp]\nlemma h1CotangentExtendScalarsEquiv_symm_toLinearMap (P : Extension.{w} R S) :\n P.h1CotangentExtendScalarsEquiv.symm = H1Cotangent.map P.extendScalars.defaultHom := rfl\n\n/-- Given an extension `P` of `S` over `R` such that `algebraMap R P.Ring` is surjective,\nthis is the equivalence induced by `P.h1Cotangentι`. -/\n@[simps! toLinearMap]\nnoncomputable\ndef h1CotangentEquivOfSurjective {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) (h : Function.Surjective (algebraMap R P.Ring)) :\n P.H1Cotangent ≃ₗ[S] P.Cotangent where\n __ := P.h1Cotangentι\n invFun x := ⟨x, by\n have : Subsingleton Ω[P.Ring⁄R] := subsingleton_of_surjective R P.Ring h\n exact Subsingleton.elim _ _⟩\n\n/-- Given an extension `P : Extension R S`, this is the linear equivalence between\nthe first homology of the naive cotangent complex of `S` over `P.Ring` and\nthe cotangent space of `P`. -/\nnoncomputable\ndef h1CotangentEquivCotangent {R : Type u} {S : Type v} [CommRing R] [CommRing S]\n [Algebra R S] (P : Extension.{w} R S) :\n H1Cotangent P.Ring S ≃ₗ[S] P.Cotangent :=\n P.h1CotangentExtendScalarsEquiv.symm ≪≫ₗ\n P.extendScalars.h1CotangentEquivOfSurjective Function.surjective_id ≪≫ₗ\n P.cotangentExtendScalarsEquiv\n\ntheorem cotangentComplex_comp_h1CotangentEquivCotangent (P : Extension.{w} R S) :\n P.cotangentComplex.comp P.h1CotangentEquivCotangent.toLinearMap =\n H1Cotangent.δ R P.Ring S := by\n rw [h1CotangentEquivCotangent, LinearEquiv.coe_trans, LinearEquiv.coe_trans,\n h1CotangentEquivOfSurjective_toLinearMap, ← LinearMap.comp_assoc, ← LinearMap.comp_assoc,\n LinearEquiv.comp_toLinearMap_symm_eq, LinearMap.comp_assoc,\n h1CotangentExtendScalarsEquiv_toLinearMap]\n ext ⟨x, _⟩\n obtain ⟨⟨x : P.Ring, x_in : x ∈ P.ker⟩, rfl⟩ := Cotangent.mk_surjective x\n trans 1 ⊗ₜ[P.Ring] D R P.Ring x; · exact cotangentComplex_mk P ⟨x, x_in⟩\n let u : (Generators.self P.Ring S).toExtension.ker :=\n ⟨algebraMap P.Ring (Generators.self P.Ring S).toExtension.Ring x, by\n rwa [← Ideal.mem_comap, RingHom.comap_ker, ← IsScalarTower.algebraMap_eq]⟩\n rw [← Generators.H1Cotangent.δ_C _ _ u.prop]\n congr\n\ntheorem h1CotangentEquivCotangent_comp_map (P : Extension.{w} R S) :\n P.h1CotangentEquivCotangent.toLinearMap.comp (Algebra.H1Cotangent.map R P.Ring S S) =\n h1Cotangentι.comp (H1Cotangent.map P.defaultHom) := by\n rw [h1CotangentEquivCotangent, LinearEquiv.coe_trans, LinearEquiv.coe_trans,\n h1CotangentExtendScalarsEquiv_symm_toLinearMap, h1CotangentEquivOfSurjective_toLinearMap,\n LinearMap.comp_assoc, LinearMap.comp_assoc, Algebra.H1Cotangent.map,\n ← (H1Cotangent.map P.extendScalars.defaultHom).restrictScalars_self, ← H1Cotangent.map_comp,\n eq_comm, ← LinearEquiv.toLinearMap_symm_comp_eq, cotangentExtendScalarsEquiv_symm_toLinearMap,\n ← LinearMap.comp_assoc, Cotangent.map_comp_h1Cotangentι, LinearMap.restrictScalars_self,\n LinearMap.comp_assoc, ← (H1Cotangent.map P.toExtendScalars).restrictScalars_self,\n ← H1Cotangent.map_comp, H1Cotangent.map_eq]\n\nTarget:\ntheorem H1Cotangent.map_defaultHom_surjective (P : Extension.{w} R S) :\n Function.Surjective (H1Cotangent.map P.defaultHom) :=\n\nProof body:\n","rejected":"by\n exact H1Cotangent.map_defaultHom_surjective","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"459cf937892d1ca405731986022a5413b2fb9785a29cad813f9035a990717df8","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Extension","family_id":"h1cotangent","file_id":"mathlib/Mathlib/RingTheory/Extension/ExtendScalars.lean","sample_id":"6ded992d9dff50ff1f7713cf83e3d3d46911843ee49f5692a23de0fb332e63ed"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3216557a3aff7a0388936ef882d87a370b33bad5f6db61e7be3c432b34ecca90","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"95b3480b2958894df77fe8ba9af6a5b995d19b3b37678394328dd576fb5750cc","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8e0c0563df1280eaca460eabfa177c0aa9b5168635cf8293cca1d2c06361b3a0","source_sha256":"2a118611f2c24b41d1413bb14336c2f80a467287b119c0d8a05360e212cf41d2","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [fromNondegComplex, fullyFaithfulToKaroubi,\n cofan, IndexSet.id, IndexSet.e]","hard_negative":false,"metrics":{"chosen_tokens":17,"rejected_tokens":21,"token_jaccard":0.8,"token_length_ratio":1.235294},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"51f9b8143bd199b6cff6a74ba51c65b541c0cdada0f6ace8640d7bc2407a87ad","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicTopology.DoldKan.Degeneracies\npublic import Mathlib.AlgebraicTopology.DoldKan.HomotopyEquivalence\npublic import Mathlib.AlgebraicTopology.SimplicialObject.Split\n\nNamespace:\nCategoryTheory.SimplicialObject.Splitting\n\nLocal context:\n/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n\n# Split simplicial objects in preadditive categories\n\nIn this file we define a functor `nondegComplex : SimplicialObject.Split C ⥤ ChainComplex C ℕ`\nwhen `C` is a preadditive category with finite coproducts, and get an isomorphism\n`toKaroubiNondegComplexFunctorIsoN₁ : nondegComplex ⋙ toKaroubi _ ≅ forget C ⋙ DoldKan.N₁`.\n\n(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)\n\n-/\n\n@[expose] public section\n\n\nnamespace CategoryTheory.SimplicialObject\n\nopen AlgebraicTopology Limits Category Preadditive Idempotents Opposite DoldKan Simplicial\n\nnamespace Splitting\n\nvariable {C : Type*} [Category* C] {X : SimplicialObject C}\n (s : Splitting X)\n\n/-- The projection on a summand of the coproduct decomposition given\nby a splitting of a simplicial object. -/\nnoncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :\n X.obj Δ ⟶ s.N A.1.unop.len :=\n s.desc Δ (fun B => by\n by_cases h : B = A\n · exact eqToHom (by subst h; rfl)\n · exact 0)\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :\n (s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by\n simp [πSummand]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ)\n (h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by\n dsimp [πSummand]\n rw [ι_desc, dif_neg h.symm]\n\nvariable [Preadditive C]\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem decomposition_id (Δ : SimplexCategoryᵒᵖ) :\n 𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by\n apply s.hom_ext'\n intro A\n dsimp\n erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc]\n · intro B _ h₂\n rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp]\n · simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) :\n X.σ i ≫ s.πSummand (IndexSet.id (op ⦋n + 1⦌)) = 0 := by\n apply s.hom_ext'\n intro A\n dsimp only [SimplicialObject.σ]\n rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op,\n cofan_inj_πSummand_eq_zero]\n rw [ne_comm]\n change ¬(A.epiComp (SimplexCategory.σ i).op).EqId\n rw [IndexSet.eqId_iff_len_eq]\n have h := SimplexCategory.len_le_of_epi A.e\n dsimp at h ⊢\n lia\n\nset_option backward.isDefEq.respectTransparency false in\n/-- If a simplicial object `X` in an additive category is split,\nthen `PInfty` vanishes on all the summands of `X _⦋n⦌` which do\nnot correspond to the identity of `⦋n⦌`. -/\ntheorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X)\n {n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op ⦋n⦌)) (hA : ¬A.EqId) :\n (s.cofan _).inj A ≫ PInfty.f n = 0 := by\n rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA\n rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem comp_PInfty_eq_zero_iff {Z : C} {n : ℕ} (f : Z ⟶ X _⦋n⦌) :\n f ≫ PInfty.f n = 0 ↔ f ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = 0 := by\n constructor\n · intro h\n rcases n with _ | n\n · dsimp at h\n rw [comp_id] at h\n rw [h, zero_comp]\n · have h' := f ≫= PInfty_f_add_QInfty_f (n + 1)\n dsimp at h'\n rw [comp_id, comp_add, h, zero_add] at h'\n rw [← h', assoc, QInfty_f, decomposition_Q, Preadditive.sum_comp, Preadditive.comp_sum,\n Finset.sum_eq_zero]\n intro i _\n simp only [assoc, σ_comp_πSummand_id_eq_zero, comp_zero]\n · intro h\n rw [← comp_id f, assoc, s.decomposition_id, Preadditive.sum_comp, Preadditive.comp_sum,\n Fintype.sum_eq_zero]\n intro A\n by_cases hA : A.EqId\n · dsimp at hA\n subst hA\n rw [assoc, reassoc_of% h, zero_comp]\n · simp only [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem PInfty_comp_πSummand_id (n : ℕ) :\n PInfty.f n ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = s.πSummand (IndexSet.id (op ⦋n⦌)) := by\n conv_rhs => rw [← id_comp (s.πSummand _)]\n symm\n rw [← sub_eq_zero, ← sub_comp, ← comp_PInfty_eq_zero_iff, sub_comp, id_comp, PInfty_f_idem,\n sub_self]\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc (attr := simp)]\ntheorem πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty (n : ℕ) :\n s.πSummand (IndexSet.id (op ⦋n⦌)) ≫ (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n =\n PInfty.f n := by\n conv_rhs => rw [← id_comp (PInfty.f n)]\n dsimp only [AlternatingFaceMapComplex.obj_X]\n rw [s.decomposition_id, Preadditive.sum_comp]\n rw [Fintype.sum_eq_single (IndexSet.id (op ⦋n⦌)), assoc]\n rintro A (hA : ¬A.EqId)\n rw [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]\n\n/-- The differentials `s.d i j : s.N i ⟶ s.N j` on nondegenerate simplices of a split\nsimplicial object are induced by the differentials on the alternating face map complex. -/\n@[simp]\nnoncomputable def d (i j : ℕ) : s.N i ⟶ s.N j :=\n (s.cofan _).inj (IndexSet.id (op ⦋i⦌)) ≫ K[X].d i j ≫ s.πSummand (IndexSet.id (op ⦋j⦌))\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem ιSummand_comp_d_comp_πSummand_eq_zero (j k : ℕ) (A : IndexSet (op ⦋j⦌)) (hA : ¬A.EqId) :\n (s.cofan _).inj A ≫ K[X].d j k ≫ s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by\n rw [A.eqId_iff_mono] at hA\n rw [← assoc, ← s.comp_PInfty_eq_zero_iff, assoc, ← PInfty.comm j k, s.cofan_inj_eq, assoc,\n degeneracy_comp_PInfty_assoc X j A.e hA, zero_comp, comp_zero]\n\nset_option backward.isDefEq.respectTransparency false in\n/-- If `s` is a splitting of a simplicial object `X` in a preadditive category,\n`s.nondegComplex` is a chain complex which is given in degree `n` by\nthe nondegenerate `n`-simplices of `X`. This chain complex should be thought\nas the normalized chain complex of `X` because of the isomorphism\n`toKaroubiNondegComplexIsoN₁`. -/\n@[simps]\nnoncomputable def nondegComplex : ChainComplex C ℕ where\n X := s.N\n d := s.d\n shape i j hij := by simp only [d, K[X].shape i j hij, zero_comp, comp_zero]\n d_comp_d' i j k _ _ := by\n simp only [d, assoc]\n have eq : K[X].d i j ≫ 𝟙 (X.obj (op ⦋j⦌)) ≫ K[X].d j k ≫\n s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by\n simp\n rw [s.decomposition_id] at eq\n classical\n rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op ⦋j⦌)), add_comp, comp_add, assoc,\n Preadditive.sum_comp, Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq\n swap\n · intro A hA\n simp only [Finset.mem_compl, Finset.mem_singleton] at hA\n simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]\n rw [eq, comp_zero]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- The chain complex `s.nondegComplex` attached to a splitting of a simplicial object `X`\nbecomes isomorphic to the normalized Moore complex `N₁.obj X` defined as a formal direct\nfactor in the category `Karoubi (ChainComplex C ℕ)`. -/\n@[simps]\nnoncomputable def toKaroubiNondegComplexIsoN₁ :\n (toKaroubi _).obj s.nondegComplex ≅ N₁.obj X where\n hom :=\n { f :=\n { f := fun n => (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n\n comm' := fun i j _ => by\n dsimp\n rw [assoc, assoc, assoc, πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty,\n HomologicalComplex.Hom.comm] }\n comm := by\n ext n\n dsimp\n rw [id_comp, assoc, PInfty_f_idem] }\n inv :=\n { f :=\n { f := fun n => s.πSummand (IndexSet.id (op ⦋n⦌))\n comm' := fun i j _ => by\n dsimp\n slice_rhs 1 1 => rw [← id_comp (K[X].d i j)]\n dsimp only [AlternatingFaceMapComplex.obj_X]\n rw [s.decomposition_id, sum_comp, sum_comp, Finset.sum_eq_single (IndexSet.id (op ⦋i⦌)),\n assoc, assoc]\n · intro A _ hA\n simp only [assoc, s.ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ hA, comp_zero]\n · simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff] }\n comm := by\n ext n\n dsimp\n simp only [comp_id, PInfty_comp_πSummand_id] }\n hom_inv_id := by\n ext n\n simp only [assoc, PInfty_comp_πSummand_id, Karoubi.comp_f, HomologicalComplex.comp_f,\n cofan_inj_πSummand_eq_id]\n rfl\n inv_hom_id := by\n ext n\n simp only [πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty, Karoubi.comp_f,\n HomologicalComplex.comp_f, N₁_obj_p, Karoubi.id_f]\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma toKaroubiNondegComplexIsoN₁_hom_f_PInfty :\n dsimp% s.toKaroubiNondegComplexIsoN₁.hom.f ≫ PInfty =\n s.toKaroubiNondegComplexIsoN₁.hom.f := by\n simpa using s.toKaroubiNondegComplexIsoN₁.hom.comm\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma toKaroubiNondegComplexIsoN₁_hom_inv_id_f :\n dsimp% s.toKaroubiNondegComplexIsoN₁.hom.f ≫ s.toKaroubiNondegComplexIsoN₁.inv.f = 𝟙 _ := by\n rw [← dsimp% [-Karoubi.comp_f] Karoubi.comp_f s.toKaroubiNondegComplexIsoN₁.hom\n s.toKaroubiNondegComplexIsoN₁.inv, Iso.hom_inv_id]\n simp\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Given a splitting `s` of a simplicial object `X` in a preadditive category,\nthis is the split epimorphism from the alternating face map complex of `X` to the chain\ncomplex `s.nondegComplex`. -/\n@[no_expose]\nnoncomputable def toNondegComplex : K[X] ⟶ s.nondegComplex :=\n (fullyFaithfulToKaroubi _).preimage\n ({ f := by exact PInfty } ≫ s.toKaroubiNondegComplexIsoN₁.inv)\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Given a splitting `s` of a simplicial object `X` in a preadditive category,\nthis is the split monomormphism from the chain complex `s.nondegComplex` to\nthe alternating face map complex fo `X`. -/\n@[no_expose]\nnoncomputable def fromNondegComplex : s.nondegComplex ⟶ K[X] :=\n (fullyFaithfulToKaroubi _).preimage\n (s.toKaroubiNondegComplexIsoN₁.hom ≫ { f := PInfty })\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma PInfty_toNondegComplex : PInfty ≫ s.toNondegComplex = s.toNondegComplex :=\n (toKaroubi _).map_injective (by simp [toNondegComplex])\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc (attr := simp)]\nlemma fromNondegComplex_toNondegComplex :\n s.fromNondegComplex ≫ s.toNondegComplex = 𝟙 _ :=\n (toKaroubi _).map_injective (by simp [toNondegComplex, fromNondegComplex])\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc]\nlemma toNondegComplex_f (n : ℕ) :\n s.toNondegComplex.f n = PInfty.f n ≫ s.toKaroubiNondegComplexIsoN₁.inv.f.f n := by\n simp [toNondegComplex, fullyFaithfulToKaroubi]\n\nset_option backward.defeqAttrib.useBackward true in\n@[reassoc]\n\nTarget:\nlemma fromNondegComplex_f (n : ℕ) :\n s.fromNondegComplex.f n = s.ι n ≫ PInfty.f n :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n simp [fromNondegComplex, fullyFaithfulToKaroubi,\n cofan, IndexSet.id, IndexSet.e]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/DoldKan","family_id":"fromnondegcomplex_f","file_id":"mathlib/Mathlib/AlgebraicTopology/DoldKan/SplitSimplicialObject.lean","sample_id":"8e0c0563df1280eaca460eabfa177c0aa9b5168635cf8293cca1d2c06361b3a0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"db709b9557b7edfb820f6282a17c5246567430a010a339154efd985351bee30d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"eac5a4fea11a8c13f1d57d8116ad127301563307b7eb33350d74d4e3f3014980","source_sha256":"4c0d6362d88633d87b94227be85c3259bd3147b3bcd830b894bbdd5c5e741fdb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain rfl | hz := eq_or_ne z 0; · simp\n ext p\n rw [mem_primeFactors, mem_normalizedFactors_iff' hz, irreducible_iff_prime,\n Int.nonneg_iff_normalize_eq_self, Finset.mem_map, Function.Embedding.coeFn_mk]\n refine ⟨fun ⟨pp, nnp, dp⟩ ↦ ?_, fun h ↦ ?_⟩\n · lift p to ℕ using nnp\n rw [← Nat.prime_iff_prime_int] at pp\n rw [Int.natCast_dvd] at dp\n exact ⟨p, by simp_all, rfl⟩\n · simp_rw [Nat.mem_primeFactors, Function.Embedding.toFun_eq_coe, Nat.castEmbedding_apply] at h\n obtain ⟨n, ⟨pn, dn, -⟩, rfl⟩ := h\n rw [Int.natCast_dvd, ← Nat.prime_iff_prime_int]\n exact ⟨pn, by simp, dn⟩","hard_negative":false,"metrics":{"chosen_tokens":145,"rejected_tokens":2,"token_jaccard":0.016949,"token_length_ratio":0.013793},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"52134969797a8901242f8cae00745b14e66f8c95c63d2305700ee2e9515c4340","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.EuclideanDomain.Int\npublic import Mathlib.Algebra.GCDMonoid.Nat\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.RingTheory.PrincipalIdealDomain\npublic import Mathlib.RingTheory.Radical.Basic\npublic import Mathlib.RingTheory.UniqueFactorizationDomain.Nat\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Arend Mellendijk, Jeremy Tan\n-/\n/-!\n# The radical in `ℕ` and `ℤ`\n\n## Declarations for `ℕ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors`: The prime factors of a natural number\n are the same as the prime factors defined in `Nat.primeFactors`.\n- `Nat.radical_eq_prod_primeFactors`: The radical is computable for natural numbers.\n- `Nat.radical_le_self_iff`: if `n ≠ 0`, `radical n ≤ n`.\n- `Nat.two_le_radical_iff`: `2 ≤ n.radical` iff `2 ≤ n`.\n\n## Declarations for `ℤ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs`: The prime factors of an integer\n are the same as the prime factors of its absolute value.\n- `Int.radical_eq_prod_primeFactors`: The radical is computable for integers.\n-/\n\n@[expose] public section\n\nopen UniqueFactorizationMonoid\n\n/-! ### Lemmas about natural numbers -/\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors :\n primeFactors = Nat.primeFactors := by\n ext n : 1\n rw [primeFactors, Nat.factors_eq, Nat.primeFactors]\n -- this convert is necessary because of the different DecidableEq instances\n convert! List.toFinset_coe _\n\nnamespace Nat\n\nvariable {n : ℕ}\n\nlemma radical_eq_prod_primeFactors : radical n = ∏ p ∈ n.primeFactors, p := by\n simp [radical, primeFactors_eq_natPrimeFactors]\n\nlemma radical_pos (n) : 0 < radical n := pos_of_ne_zero radical_ne_zero\n\n@[simp] lemma one_lt_radical_iff : 1 < radical n ↔ 1 < n := by\n have pp (p) (h : p ∈ n.primeFactors) : 1 ≤ p := pos_of_mem_primeFactors h\n rw [radical_eq_prod_primeFactors, ← @nonempty_primeFactors n, Finset.one_lt_prod_iff_of_one_le pp]\n exact ⟨fun ⟨p, h⟩ ↦ ⟨p, h.1⟩, fun ⟨p, h⟩ ↦ ⟨p, h, (mem_primeFactors.mp h).1.one_lt⟩⟩\n\n@[simp] lemma two_le_radical_iff : 2 ≤ radical n ↔ 2 ≤ n := one_lt_radical_iff\n\n@[simp] lemma radical_le_one_iff : radical n ≤ 1 ↔ n ≤ 1 := by\n simpa only [not_lt] using one_lt_radical_iff.not\n\n@[simp] lemma radical_eq_one_iff : radical n = 1 ↔ n ≤ 1 := by\n rw [← radical_le_one_iff]\n grind [radical_pos n]\n\n@[simp] lemma radical_le_self_iff : radical n ≤ n ↔ n ≠ 0 :=\n ⟨by aesop, fun h ↦ Nat.le_of_dvd (by lia) radical_dvd_self⟩\n\n@[simp] lemma self_lt_radical_iff : n < radical n ↔ n = 0 := by\n simpa only [not_le, not_not] using radical_le_self_iff.not\n\nopen Qq Lean Mathlib.Meta Finset\n\nnamespace Mathlib.Meta.Positivity\nopen Positivity\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- Positivity extension for radical. Proves radicals are nonzero. -/\n@[positivity UniqueFactorizationMonoid.radical _]\nmeta def evalRadical : PositivityExt where eval {u α} _ _ e := do\n match e with\n | ~q(@radical _ $inst $inst' $inst'' $n) =>\n have _ := ← synthInstanceQ q(Nontrivial $α)\n assertInstancesCommute\n return .nonzero q(radical_ne_zero)\n | _ => throwError \"not radical\"\n\nexample : 0 < radical 100 := by positivity\n\nend Mathlib.Meta.Positivity\n\nend Nat\n\n/-! ### Lemmas about integers -/\n\nvariable {z : ℤ}\n\nTarget:\nlemma UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs :\n primeFactors z = z.natAbs.primeFactors.map Nat.castEmbedding :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Radical","family_id":"uniquefactorizationmonoid","file_id":"mathlib/Mathlib/RingTheory/Radical/NatInt.lean","sample_id":"eac5a4fea11a8c13f1d57d8116ad127301563307b7eb33350d74d4e3f3014980"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3c3ac14425b980afe99cd5c2de5d3558064742f67e49e0d7c12287314690c533","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"819fbb3c55af36935e785313ab0f6f54a3ff89f9c275d6a0eca91ff841251b44","source_sha256":"7b71466fe661edbc6adc5c50b7417cb616e3f9824d1c6bd340a7fc9d6d0eafd0","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have aux (n : ℕ) : injectiveDimension M ≤ n → injectiveDimension (M.localizedModule S) ≤ n := by\n simp only [injectiveDimension_le_iff]\n intro h\n exact M.localizedModule_hasInjectiveDimensionLE n S\n refine le_of_forall_ge (fun N ↦ ?_)\n induction N with\n | bot =>\n simp only [le_bot_iff, injectiveDimension_eq_bot_iff, ModuleCat.isZero_iff_subsingleton,\n ModuleCat.localizedModule, ← Equiv.subsingleton_congr (equivShrink _)]\n intro _\n apply LocalizedModule.instSubsingleton _\n | coe N =>\n induction N with\n | top => simp\n | coe n => simpa using aux n","hard_negative":false,"metrics":{"chosen_tokens":103,"rejected_tokens":3,"token_jaccard":0.056604,"token_length_ratio":0.029126},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"5281ddda3c2bae67a94d2003ae5362bcdeea1f294a161f2257176b56f4fda29e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Grp.Zero\npublic import Mathlib.Algebra.Category.ModuleCat.EnoughInjectives\npublic import Mathlib.Algebra.Category.ModuleCat.Localization\npublic import Mathlib.Algebra.Category.ModuleCat.Projective\npublic import Mathlib.Algebra.Homology.DerivedCategory.Ext.EnoughInjectives\npublic import Mathlib.Algebra.Homology.ShortComplex.ModuleCat\npublic import Mathlib.Algebra.Module.LocalizedModule.Exact\npublic import Mathlib.CategoryTheory.Abelian.Injective.Dimension\npublic import Mathlib.CategoryTheory.Preadditive.Injective.Preserves\npublic import Mathlib.LinearAlgebra.Dimension.Finite\npublic import Mathlib.RingTheory.LocalProperties.Injective\n\nNamespace:\nModuleCat\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n\n# Relation of Injective Dimension with Localizations\n\n-/\n\npublic section\n\nuniverse v u\n\nnamespace ModuleCat\n\nvariable {R : Type u} [CommRing R]\n\nopen CategoryTheory Limits\n\nset_option backward.isDefEq.respectTransparency false in\ninstance [Small.{v} R] [IsNoetherianRing R] (S : Submonoid R) :\n (ModuleCat.localizedModuleFunctor.{v} S).PreservesInjectiveObjects where\n injective_obj X {inj} := by\n let _ : Small.{v, u} (Localization S) := small_of_surjective Localization.mkHom_surjective\n rw [← Module.injective_iff_injective_object] at inj ⊢\n simpa [ModuleCat.localizedModuleFunctor] using\n Module.injective_of_isLocalizedModule S (X.localizedModuleMkLinearMap S)\n\nlemma localizedModule_hasInjectiveDimensionLE [Small.{v, u} R] [IsNoetherianRing R] (n : ℕ)\n (S : Submonoid R) (M : ModuleCat.{v} R) [HasInjectiveDimensionLE M n] :\n HasInjectiveDimensionLE (M.localizedModule S) n := by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n induction n generalizing M with\n | zero =>\n have injle : HasInjectiveDimensionLE M 0 := ‹_›\n simp only [HasInjectiveDimensionLE, zero_add, ← injective_iff_hasInjectiveDimensionLT_one]\n at injle ⊢\n rw [← Module.injective_iff_injective_object] at injle ⊢\n exact Module.injective_of_isLocalizedModule S (M.localizedModuleMkLinearMap S)\n | succ n ih =>\n have ei : EnoughInjectives (ModuleCat.{v} R) := inferInstance\n rcases ei.1 M with ⟨I, inj, f, monof⟩\n let T := ShortComplex.mk f (cokernel.π f) (cokernel.condition f)\n have T_exact : T.ShortExact := { exact := ShortComplex.exact_cokernel f }\n have T_exact' : Function.Exact (ConcreteCategory.hom T.f) (ConcreteCategory.hom T.g) :=\n (ShortComplex.ShortExact.moduleCat_exact_iff_function_exact _).mp T_exact.1\n have TS_exact' := IsLocalizedModule.map_exact S (T.X₁.localizedModuleMkLinearMap S)\n (T.X₂.localizedModuleMkLinearMap S) (T.X₃.localizedModuleMkLinearMap S) _ _ T_exact'\n let TS := T.map (ModuleCat.localizedModuleFunctor S)\n have TS_exact : TS.ShortExact := T_exact.map_of_exact (ModuleCat.localizedModuleFunctor S)\n let _ := (T_exact.hasInjectiveDimensionLT_X₃_iff n ‹_›).mpr ‹_›\n let _ : Injective TS.X₂ := (ModuleCat.localizedModuleFunctor.{v} S).injective_obj _\n exact (TS_exact.hasInjectiveDimensionLT_X₃_iff n ‹_›).mp (ih T.X₃)\n\nopen Limits in\n\nTarget:\nlemma injectiveDimension_le_injectiveDimension_of_isLocalizedModule [Small.{v, u} R]\n [IsNoetherianRing R] (S : Submonoid R) (M : ModuleCat.{v} R) :\n injectiveDimension (M.localizedModule S) ≤ injectiveDimension M :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/LocalProperties","family_id":"injectivedimension_le_injectivedimension_of_islocalizedmodule","file_id":"mathlib/Mathlib/RingTheory/LocalProperties/InjectiveDimension.lean","sample_id":"819fbb3c55af36935e785313ab0f6f54a3ff89f9c275d6a0eca91ff841251b44"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"037b47616acfc5282eb1307b03a18e6c8c2e46a8eaf3f992b640589523528564","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4b303755cfa10c54252467c66159dfa004258b7d9d21b85b36400aa2e5cd9c72","source_sha256":"e108d8d20cce1de062fbe2b0d5a5e3bcaba7779c013849c00560d4b462914e41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [hasSum_iff_tendsto_nat_of_nonneg (fun n ↦ term_nonneg (n + 1) 1)]\n change Tendsto (fun N ↦ termSum 1 N) atTop _\n simp_rw [termSum_one, sub_eq_neg_add]\n refine Tendsto.add ?_ tendsto_const_nhds\n have := (tendsto_eulerMascheroniSeq'.comp (tendsto_add_atTop_nat 1)).neg\n refine this.congr' (Eventually.of_forall (fun n ↦ ?_))\n simp_rw [Function.comp_apply, eulerMascheroniSeq', reduceCtorEq, if_false]\n push_cast\n abel","hard_negative":false,"metrics":{"chosen_tokens":85,"rejected_tokens":2,"token_jaccard":0.021739,"token_length_ratio":0.023529},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"52db118db005b00ad6bad125def8bdec7a28c5d8d258d992926a03a2790a3e84","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.LSeries.RiemannZeta\npublic import Mathlib.NumberTheory.Harmonic.GammaDeriv\n\nNamespace:\nZetaAsymptotics\n\nLocal context:\n/-\nCopyright (c) 2024 David Loeffler. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Loeffler\n-/\n/-!\n# Asymptotics of `ζ s` as `s → 1` or `s → 0`\n\nThe goal of this file is to evaluate the limit of `ζ s - 1 / (s - 1)` as `s → 1`.\n\n### Main results\n\n* `tendsto_riemannZeta_sub_one_div`: the limit of `ζ s - 1 / (s - 1)`, at the filter of punctured\n neighbourhoods of 1 in `ℂ`, exists and is equal to the Euler-Mascheroni constant `γ`.\n* `deriv_riemannZeta_zero`: `ζ'(0) = -log(2π) / 2`, which derives from the above.\n* `riemannZeta_one_ne_zero`: with our definition of `ζ 1` (which is characterised as the limit of\n `ζ s - 1 / (s - 1) / Gammaℝ s` as `s → 1`), we have `ζ 1 ≠ 0`.\n\n### Outline of arguments\n\nWe consider the sum `F s = ∑' n : ℕ, f (n + 1) s`, where `s` is a real variable and\n`f n s = ∫ x in n..(n + 1), (x - n) / x ^ (s + 1)`. We show that `F s` is continuous on `[1, ∞)`,\nthat `F 1 = 1 - γ`, and that `F s = 1 / (s - 1) - ζ s / s` for `1 < s`.\n\nBy combining these formulae, one deduces that the limit of `ζ s - 1 / (s - 1)` at `𝓝[>] (1 : ℝ)`\nexists and is equal to `γ`. Finally, using this and the Riemann removable singularity criterion\nwe obtain the limit along punctured neighbourhoods of 1 in `ℂ`.\n-/\n\n@[expose] public section\n\nopen Set MeasureTheory Filter Topology\n\n@[inherit_doc] local notation \"γ\" => Real.eulerMascheroniConstant\n\nnamespace ZetaAsymptotics\n\n-- since the intermediate lemmas are of little interest in themselves we put them in a namespace\n\nopen Real\n\n/-!\n## Definitions\n-/\n\n/-- Auxiliary function used in studying zeta-function asymptotics. -/\nnoncomputable def term (n : ℕ) (s : ℝ) : ℝ := ∫ x : ℝ in n..(n + 1), (x - n) / x ^ (s + 1)\n\n/-- Sum of finitely many `term`s. -/\nnoncomputable def termSum (s : ℝ) (N : ℕ) : ℝ := ∑ n ∈ Finset.range N, term (n + 1) s\n\n/-- Topological sum of `term`s. -/\nnoncomputable def termTSum (s : ℝ) : ℝ := ∑' n, term (n + 1) s\n\n@[deprecated (since := \"2026-05-27\")] alias term_sum := termSum\n@[deprecated (since := \"2026-05-27\")] alias term_tsum := termTSum\n\nlemma term_nonneg (n : ℕ) (s : ℝ) : 0 ≤ term n s := by\n rw [term, intervalIntegral.integral_of_le (by simp)]\n refine setIntegral_nonneg measurableSet_Ioc (fun x hx ↦ ?_)\n refine div_nonneg ?_ (rpow_nonneg ?_ _)\n all_goals linarith [hx.1]\n\nlemma term_welldef {n : ℕ} (hn : 0 < n) {s : ℝ} (hs : 0 < s) :\n IntervalIntegrable (fun x : ℝ ↦ (x - n) / x ^ (s + 1)) volume n (n + 1) := by\n rw [intervalIntegrable_iff_integrableOn_Icc_of_le (by linarith)]\n refine (continuousOn_of_forall_continuousAt fun x hx ↦ ContinuousAt.div ?_ ?_ ?_).integrableOn_Icc\n · fun_prop\n · apply continuousAt_id.rpow_const (Or.inr <| by linarith)\n · exact (rpow_pos_of_pos ((Nat.cast_pos.mpr hn).trans_le hx.1) _).ne'\n\nsection s_eq_one\n\n/-!\n## Evaluation of the sum for `s = 1`\n-/\n\nlemma term_one {n : ℕ} (hn : 0 < n) :\n term n 1 = (log (n + 1) - log n) - 1 / (n + 1) := by\n have hv : ∀ x ∈ uIcc (n : ℝ) (n + 1), 0 < x := by\n intro x hx\n rw [uIcc_of_le (by simp only [le_add_iff_nonneg_right, zero_le_one])] at hx\n exact (Nat.cast_pos.mpr hn).trans_le hx.1\n calc term n 1\n _ = ∫ x : ℝ in n..(n + 1), (x - n) / x ^ 2 := by\n simp_rw [term, one_add_one_eq_two, ← Nat.cast_two (R := ℝ), rpow_natCast]\n _ = ∫ x : ℝ in n..(n + 1), (1 / x - n / x ^ 2) :=\n intervalIntegral.integral_congr (fun x hx ↦ by field)\n _ = (∫ x : ℝ in n..(n + 1), 1 / x) - n * ∫ x : ℝ in n..(n + 1), 1 / x ^ 2 := by\n simp_rw [← mul_one_div (n : ℝ)]\n rw [intervalIntegral.integral_sub]\n · simp_rw [intervalIntegral.integral_const_mul]\n · exact intervalIntegral.intervalIntegrable_one_div (fun x hx ↦ (hv x hx).ne') (by fun_prop)\n · exact (intervalIntegral.intervalIntegrable_one_div\n (fun x hx ↦ (sq_pos_of_pos (hv x hx)).ne') (by fun_prop)).const_mul _\n _ = (log (↑n + 1) - log ↑n) - n * ∫ x : ℝ in n..(n + 1), 1 / x ^ 2 := by\n congr 1\n rw [integral_one_div_of_pos, log_div]\n all_goals positivity\n _ = (log (↑n + 1) - log ↑n) - n * ∫ x : ℝ in n..(n + 1), x ^ (-2 : ℝ) := by\n congr 2\n refine intervalIntegral.integral_congr (fun x hx ↦ ?_)\n rw [rpow_neg, one_div, ← Nat.cast_two (R := ℝ), rpow_natCast]\n exact (hv x hx).le\n _ = log (↑n + 1) - log ↑n - n * (1 / n - 1 / (n + 1)) := by\n rw [integral_rpow]\n · simp_rw [sub_div, (by norm_num : (-2 : ℝ) + 1 = -1), div_neg, div_one, neg_sub_neg,\n rpow_neg_one, ← one_div]\n · refine Or.inr ⟨by simp, notMem_uIcc_of_lt ?_ ?_⟩\n all_goals positivity\n _ = log (↑n + 1) - log ↑n - 1 / (↑n + 1) := by\n congr 1\n simp [field]\n\nlemma termSum_one (N : ℕ) : termSum 1 N = log (N + 1) - harmonic (N + 1) + 1 := by\n induction N with\n | zero =>\n simp_rw [termSum, Finset.sum_range_zero, harmonic_succ, harmonic_zero,\n Nat.cast_zero, zero_add, Nat.cast_one, inv_one, Rat.cast_one, log_one, sub_add_cancel]\n | succ N hN =>\n unfold termSum at hN ⊢\n rw [Finset.sum_range_succ, hN, harmonic_succ (N + 1),\n term_one (by positivity : 0 < N + 1)]\n push_cast\n ring_nf\n\n@[deprecated (since := \"2026-05-27\")] alias term_sum_one := termSum_one\n\n/-- The topological sum of `ZetaAsymptotics.term (n + 1) 1` over all `n : ℕ` is `1 - γ`. This is\nproved by directly evaluating the sum of the first `N` terms and using the limit definition of `γ`.\n-/\n\nTarget:\nlemma term_tsum_one : HasSum (fun n ↦ term (n + 1) 1) (1 - γ) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Harmonic","family_id":"term_tsum_one","file_id":"mathlib/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean","sample_id":"4b303755cfa10c54252467c66159dfa004258b7d9d21b85b36400aa2e5cd9c72"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"22b3bc3a5f291ce1fc7ad01b37d4a5bbe57149530b2b1efd68e2dda3f7a4f1aa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"34dcfd7baa45b79cf991eca05297781722f8401ae7acfec487c1013229df17c7","source_sha256":"256cf4f88d33f6a5c2ae62a506182b48c7c21aa38bae757b66e9c4f9c05af2eb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← Presieve.ofArrows_pUnit.{_, _, 0}, ofArrows_mem_precoverage_iff]\n aesop","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.105263},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"5372bba5158cae1e3a11d0b93a34b4de94dede0fcb35ce06a18f0ae40f3cb0d2","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.OpenImmersion\npublic import Mathlib.CategoryTheory.MorphismProperty.Limits\npublic import Mathlib.CategoryTheory.Sites.JointlySurjective\npublic import Mathlib.CategoryTheory.Sites.MorphismProperty\n\nNamespace:\nAlgebraicGeometry.Scheme\n\nLocal context:\n/-\nCopyright (c) 2024 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten, Joël Riou, Adam Topaz\n-/\n/-!\n\n# Site defined by a morphism property\n\nGiven a multiplicative morphism property `P` that is stable under base change, we define the\nassociated precoverage on the category of schemes, where coverings are given\nby jointly surjective families of morphisms satisfying `P`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nopen CategoryTheory MorphismProperty Limits\n\nnamespace AlgebraicGeometry\n\nnamespace Scheme\n\n/-- A morphism property of schemes is said to preserve joint surjectivity, if\nfor any pair of morphisms `f : X ⟶ S` and `g : Y ⟶ S` where `g` satisfies `P`,\nany pair of points `x : X` and `y : Y` with `f x = g y` can be lifted to a point\nof `X ×[S] Y`.\n\nIn later files, this will be automatic, since this holds for any morphism `g`\n(see `AlgebraicGeometry.Scheme.isJointlySurjectivePreserving`). But at\nthis early stage in the import tree, we only know it for open immersions. -/\nclass IsJointlySurjectivePreserving (P : MorphismProperty Scheme.{u}) where\n exists_preimage_fst_triplet_of_prop {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]\n (hg : P g) (x : X) (y : Y) (h : f x = g y) :\n ∃ a : ↑(pullback f g), pullback.fst f g a = x\n\nvariable {P : MorphismProperty Scheme.{u}}\n\nlemma IsJointlySurjectivePreserving.exists_preimage_snd_triplet_of_prop\n [IsJointlySurjectivePreserving P] {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]\n (hf : P f) (x : X) (y : Y) (h : f x = g y) :\n ∃ a : ↑(pullback f g), pullback.snd f g a = y := by\n let iso := pullbackSymmetry f g\n haveI : HasPullback g f := hasPullback_symmetry f g\n obtain ⟨a, ha⟩ := exists_preimage_fst_triplet_of_prop hf y x h.symm\n use (pullbackSymmetry f g).inv a\n rwa [← Scheme.Hom.comp_apply, pullbackSymmetry_inv_comp_snd]\n\ninstance : IsJointlySurjectivePreserving @IsOpenImmersion where\n exists_preimage_fst_triplet_of_prop {X Y S f g} _ hg x y h := by\n rw [← show _ = (pullback.fst _ _ : pullback f g ⟶ _).base from\n PreservesPullback.iso_hom_fst Scheme.forgetToTop f g]\n have : x ∈ Set.range (pullback.fst f.base g.base) := by\n rw [TopCat.pullback_fst_range f.base g.base]\n use y\n obtain ⟨a, ha⟩ := this\n use (PreservesPullback.iso Scheme.forgetToTop f g).inv a\n rwa [← TopCat.comp_app, Iso.inv_hom_id_assoc]\n\n/-- The precoverage on `Scheme` of jointly surjective families. -/\nabbrev jointlySurjectivePrecoverage : Precoverage Scheme.{u} :=\n Types.jointlySurjectivePrecoverage.comap Scheme.forget\n\nvariable (P : MorphismProperty Scheme.{u})\n\n/-- The precoverage on `Scheme` induced by `P` is given by jointly surjective families of\n`P`-morphisms. -/\ndef precoverage : Precoverage Scheme.{u} :=\n jointlySurjectivePrecoverage ⊓ P.precoverage\n\n@[simp]\nlemma ofArrows_mem_precoverage_iff {S : Scheme.{u}} {ι : Type*} {X : ι → Scheme.{u}}\n {f : ∀ i, X i ⟶ S} :\n .ofArrows X f ∈ precoverage P S ↔ (∀ x, ∃ i, x ∈ Set.range (f i)) ∧ ∀ i, P (f i) := by\n simp_rw [← Scheme.forget_map', ← Scheme.forget_obj,\n ← Presieve.ofArrows_mem_comap_jointlySurjectivePrecoverage_iff]\n exact ⟨fun hmem ↦ ⟨hmem.1, fun i ↦ hmem.2 ⟨i⟩⟩, fun h ↦ ⟨h.1, fun {Y} g ⟨i⟩ ↦ h.2 i⟩⟩\n\n@[simp]\n\nTarget:\nlemma singleton_mem_precoverage_iff {X S : Scheme.{u}} (f : X ⟶ S) :\n Presieve.singleton f ∈ precoverage P S ↔ Function.Surjective f.base ∧ P f :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Sites","family_id":"singleton_mem_precoverage_iff","file_id":"mathlib/Mathlib/AlgebraicGeometry/Sites/MorphismProperty.lean","sample_id":"34dcfd7baa45b79cf991eca05297781722f8401ae7acfec487c1013229df17c7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a8eb3c5891260403cb7ab35d3f5a3988827b89009dfef4f81dbe53a8bc63f578","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"83d41d4e90794ec9a50328b7b597433db214a3dbf8844254a1227e6d439f57bc","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d8b24639b34779d57bd85557d3fc1543fd94c60c3e248f88189ff1b262443415","source_sha256":"38d64e4f1a0e05f9858787ff51b94222506a7fd69d13ef99d2c65865e8c1dd3f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases x with - | x <;> simp! [*, functor_norm, Option.traverse]","hard_negative":true,"metrics":{"chosen_tokens":21,"rejected_tokens":5,"token_jaccard":0.090909,"token_length_ratio":0.238095},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"53b30c43348511ea3010e8053ed9b0c8bce8138035fd3be667cc96c0ac296e84","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Applicative\npublic import Mathlib.Control.Traversable.Basic\npublic import Mathlib.Data.List.Forall2\npublic import Mathlib.Data.Set.Functor\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# LawfulTraversable instances\n\nThis file provides instances of `LawfulTraversable` for types from the core library: `Option`,\n`List` and `Sum`.\n-/\n\npublic section\n\n\nuniverse u v\n\nsection Option\n\nopen Functor\n\nvariable {F G : Type u → Type u}\nvariable [Applicative F] [Applicative G]\nvariable [LawfulApplicative G]\n\ntheorem Option.id_traverse {α} (x : Option α) : Option.traverse (pure : α → Id α) x = pure x := by\n cases x <;> rfl\n\ntheorem Option.comp_traverse {α β γ} (f : β → F γ) (g : α → G β) (x : Option α) :\n Option.traverse (Comp.mk ∘ (f <$> ·) ∘ g) x =\n Comp.mk (Option.traverse f <$> Option.traverse g x) := by\n cases x <;> (simp [Option.traverse, Option.mapM, functor_norm] <;> rfl)\n\ntheorem Option.traverse_eq_map_id {α β} (f : α → β) (x : Option α) :\n Option.traverse ((pure : _ → Id _) ∘ f) x = (pure : _ → Id _) (f <$> x) := by cases x <;> rfl\n\nvariable (η : ApplicativeTransformation F G)\n\nTarget:\ntheorem Option.naturality [LawfulApplicative F] {α β} (f : α → F β) (x : Option α) :\n η (Option.traverse f x) = Option.traverse (@η _ ∘ f) x :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_d8b24639b347","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5bc5a1d5b8bb90742704581d1ba46976b475c1ebc2469af9f120849207b537c1","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Control/Traversable","family_id":"option","file_id":"mathlib/Mathlib/Control/Traversable/Instances.lean","sample_id":"d8b24639b34779d57bd85557d3fc1543fd94c60c3e248f88189ff1b262443415"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9a597798e23027467755033b7c532f49bb048325c5a4361045132a050119c42b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"be7a458613b75972abe0800583b34c60316f1609084fbfec35a03e14ad2f1ae6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"baf09fd31930da8436e42cdf5076d03d01ed740f4b890b2663390ab1a5e552e7","source_sha256":"554896e06372c48698215f4d70f9de2025a1d3d47dcc6253d5e671f520e21386","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [avgRisk, ← Measure.lintegral_compProd (f := fun θy ↦ ℓ θy.1 θy.2) (by fun_prop)]\n congr\n calc π ⊗ₘ (κ ∘ₖ P) = (Kernel.id ∥ₖ κ) ∘ₘ (π ⊗ₘ P) := Measure.parallelComp_comp_compProd.symm\n _ = (Kernel.id ∥ₖ κ) ∘ₘ ((P†π) ×ₖ Kernel.id) ∘ₘ P ∘ₘ π := by rw [posterior_prod_id_comp]\n _ = ((P†π) ×ₖ κ) ∘ₘ P ∘ₘ π := by\n rw [Measure.comp_assoc, Kernel.parallelComp_comp_prod, Kernel.id_comp, Kernel.comp_id]","hard_negative":true,"metrics":{"chosen_tokens":139,"rejected_tokens":3,"token_jaccard":0.021277,"token_length_ratio":0.021583},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"53eb53e36810e5fc6620039c717f4325b4631439dba02a0e049d5122417b54c8","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Decision.Risk.Defs\npublic import Mathlib.Probability.Kernel.Posterior\nimport Mathlib.Probability.Decision.Risk.Basic\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne, Lorenzo Luccioli\n-/\n/-!\n# Bayes estimator\n\nLet `Θ` be a parameter space, `𝓧` a data space, `𝓨` a prediction space, `P : Kernel Θ 𝓧` a\ndata generating kernel, `π` a prior on the parameter space, and `ℓ : Θ → 𝓨 → ℝ≥0∞` a loss function.\n\nAn estimator (a `Kernel 𝓧 𝓨`) is said to be a Bayes estimator if it attains the Bayes risk for\nthe estimation problem.\nIt can be written as a measurable function `x ↦ argmin_y P†π(x)[θ ↦ ℓ θ y]`\nfor `(P ∘ₘ π)`-almost every `x`, where `P†π` is the posterior kernel, whenever we can select\nthe argmin in a measurable way.\n\n## Main definitions\n\n* `IsBayesEstimator`: an estimator is a Bayes estimator if it attains the Bayes risk for the prior.\n* `IsArgminEstimator`: a measurable function `f : 𝓧 → 𝓨` is an argmin estimator\n if for `(P ∘ₘ π)`-almost every `x` the value `f x` belongs to `argmin_y P†π(x)[θ ↦ ℓ θ y]`.\n* `HasArgminEstimator`: the estimation problem admits an argmin estimator.\n That is, we can choose the argmin of the posterior expected loss in a measurable way.\n\n## Main statements\n\n* `lintegral_iInf_posterior_le_bayesRisk`: the Bayes risk with respect to a prior is bounded\n from below by the integral over the data (with distribution `P ∘ₘ π`) of the infimum over the\n possible predictions `y` of the posterior loss `∫⁻ θ, ℓ θ y ∂((P†π) x)`:\n `∫⁻ x, ⨅ y : 𝓨, ∫⁻ θ, ℓ θ y ∂((P†π) x) ∂(P ∘ₘ π) ≤ bayesRisk ℓ P π`\n* `IsArgminEstimator.isBayesEstimator`: an argmin Bayes estimator is a Bayes estimator.\n That is, it minimizes the Bayesian risk.\n* `bayesRisk_eq_of_hasArgminEstimator`: if the estimation problem admits an argmin estimator,\n then the Bayesian risk attains the risk lower bound `∫⁻ x, ⨅ y, ∫⁻ θ, ℓ θ y ∂(P†π) x ∂(P ∘ₘ π)`.\n\n## TODO\n\nOnce Mathlib has measurable selection theorems, we will be able to prove `HasArgminEstimator` under\ngeneral conditions on the measurable spaces `𝓧` and/or `𝓨`.\n\n-/\n\n@[expose] public section\n\nopen MeasureTheory\nopen scoped ENNReal NNReal\n\nnamespace ProbabilityTheory\n\nvariable {Θ 𝓧 𝓨 : Type*} {mΘ : MeasurableSpace Θ} {m𝓧 : MeasurableSpace 𝓧} {m𝓨 : MeasurableSpace 𝓨}\n {ℓ : Θ → 𝓨 → ℝ≥0∞} {P : Kernel Θ 𝓧} {κ : Kernel 𝓧 𝓨} {π : Measure Θ}\n\nsection Posterior\n\nvariable [StandardBorelSpace Θ] [Nonempty Θ]\n\n/-- The average risk of an estimator `κ` with respect to a prior `π` can be expressed as\nan integral in the following way: `R_π(κ) = ((P†π × κ) ∘ P ∘ π)[(θ, y) ↦ ℓ θ y]`. -/\n\nTarget:\nlemma avgRisk_eq_lintegral_posterior_prod\n (hl : Measurable (Function.uncurry ℓ)) (P : Kernel Θ 𝓧) [IsFiniteKernel P]\n (κ : Kernel 𝓧 𝓨) [IsSFiniteKernel κ] (π : Measure Θ) [IsFiniteMeasure π] :\n avgRisk ℓ P κ π = ∫⁻ θy, ℓ θy.1 θy.2 ∂(((P†π) ×ₖ κ) ∘ₘ (P ∘ₘ π)) :=\n\nProof body:\n","rejected":"by\n exact avgRisk_eq_lintegral_posterior_prod","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"4bc70822d473b9dd7f5f4a17467f35ffa64bc8729a5c879642d945df833e10dd","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Decision","family_id":"avgrisk_eq_lintegral_posterior_prod","file_id":"mathlib/Mathlib/Probability/Decision/BayesEstimator.lean","sample_id":"baf09fd31930da8436e42cdf5076d03d01ed740f4b890b2663390ab1a5e552e7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"cb5f18aeb2545cfc76615042fd99b583010c639a411dd9dcf4f2ac7ec217bf46","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b7a8822a55a80be5f30df2196ff4050013740954c8a655dfcfa0081d53cccedb","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"af90891060c5b030be0e66f95d300af7b6d41f4eb2f21042f429abe316422ed9","source_sha256":"ab3a4ef1b8c38b799b25430e9a4ec638aa3aad5e1f7012ae3a71c9c1d9c7668c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨n, m, hn, hm, ⟨iso1⟩⟩ := hAB\n obtain ⟨p, q, hp, hq, ⟨iso2⟩⟩ := hBC\n exact ⟨p * n, m * q, by simp_all, by simp_all,\n ⟨reindexAlgEquiv _ _ finProdFinEquiv |>.symm.trans <| compAlgEquiv _ _ _ _|>.symm.trans <|\n iso1.mapMatrix (m := Fin p)|>.trans <| compAlgEquiv _ _ _ _|>.trans <|\n reindexAlgEquiv K B (.prodComm (Fin p) (Fin m))|>.trans <| compAlgEquiv _ _ _ _|>.symm.trans <|\n iso2.mapMatrix.trans <| compAlgEquiv _ _ _ _|>.trans <| reindexAlgEquiv _ _ finProdFinEquiv⟩⟩","hard_negative":true,"metrics":{"chosen_tokens":159,"rejected_tokens":5,"token_jaccard":0.075,"token_length_ratio":0.031447},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"542f21d4aac5aa136e803396cf93485a9e2b6f0fe6644b20176cf97f029547de","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.AlgCat.Basic\npublic import Mathlib.Algebra.Central.Defs\npublic import Mathlib.LinearAlgebra.FiniteDimensional.Defs\npublic import Mathlib.LinearAlgebra.Matrix.Reindex\n\nNamespace:\nIsBrauerEquivalent\n\nLocal context:\n/-\nCopyright (c) 2025 Yunzhou Xie. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yunzhou Xie, Jujian Zhang\n-/\n/-!\n# Definition of Brauer group of a field K\n\nWe introduce the definition of Brauer group of a field K, which is the quotient of the set of\nall finite-dimensional central simple algebras over K modulo the Brauer Equivalence where two\ncentral simple algebras `A` and `B` are Brauer Equivalent if there exist `n, m ∈ ℕ+` such\nthat `Mₙ(A) ≃ₐ[K] Mₘ(B)`.\n\n## TODOs\n1. Prove that the Brauer group is an abelian group where multiplication is defined as tensor\n product.\n2. Prove that the Brauer group is a functor from the category of fields to the category of groups.\n3. Prove that over a field, being Brauer equivalent is the same as being Morita equivalent.\n\n## References\n* [Algebraic Number Theory, *J.W.S Cassels*][cassels1967algebraic]\n\n## Tags\nBrauer group, Central simple algebra, Galois Cohomology\n-/\n\n@[expose] public section\n\nuniverse u v\n\n/-- `CSA` is the set of all finite-dimensional central simple algebras over a field `K`. For the\ngeneralization to a `CommRing`, see `IsAzumaya` in `Mathlib/Algebra/Azumaya/Defs.lean`. -/\nstructure CSA (K : Type u) [Field K] extends AlgCat.{v} K where\n /-- Any member of `CSA` is central. -/\n [isCentral : Algebra.IsCentral K carrier]\n /-- Any member of `CSA` is simple. -/\n [isSimple : IsSimpleRing carrier]\n /-- Any member of `CSA` is finite-dimensional. -/\n [fin_dim : FiniteDimensional K carrier]\n\nvariable {K : Type u} [Field K]\n\ninstance : CoeSort (CSA.{u, v} K) (Type v) := ⟨(·.carrier)⟩\n\nattribute [instance] CSA.isCentral CSA.isSimple CSA.fin_dim\n\n/-- Two finite-dimensional central simple algebras `A` and `B` are Brauer equivalent\n if there exist `n, m ∈ ℕ+` such that `Mₙ(A) ≃ₐ[K] Mₘ(B)`. -/\nabbrev IsBrauerEquivalent (A B : CSA K) : Prop :=\n ∃ n m : ℕ, n ≠ 0 ∧ m ≠ 0 ∧ (Nonempty <| Matrix (Fin n) (Fin n) A ≃ₐ[K] Matrix (Fin m) (Fin m) B)\n\nnamespace IsBrauerEquivalent\n\n@[refl]\nlemma refl (A : CSA K) : IsBrauerEquivalent A A :=\n ⟨1, 1, one_ne_zero, one_ne_zero, ⟨AlgEquiv.refl⟩⟩\n\n@[symm]\nlemma symm {A B : CSA K} (h : IsBrauerEquivalent A B) : IsBrauerEquivalent B A :=\n let ⟨n, m, hn, hm, ⟨iso⟩⟩ := h\n ⟨m, n, hm, hn, ⟨iso.symm⟩⟩\n\nopen Matrix in\n@[trans]\n\nTarget:\nlemma trans {A B C : CSA K} (hAB : IsBrauerEquivalent A B) (hBC : IsBrauerEquivalent B C) :\n IsBrauerEquivalent A C :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_af90891060c5","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"638acd090a43751434cf01b5dd1e6413b778ff32ac0500a26185bfc837655acd","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/BrauerGroup","family_id":"trans","file_id":"mathlib/Mathlib/Algebra/BrauerGroup/Defs.lean","sample_id":"af90891060c5b030be0e66f95d300af7b6d41f4eb2f21042f429abe316422ed9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a9779047fa7876991256a33bdb3e59e4b9e741463a906593ac6cdb02c52b9b9b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa8622e4654fc596914560a34e89d20db8c2ad34a6ad4dad32b4200c14e665f6","source_sha256":"fba9f03949fb71c822ca9bce084299af5da1008b68ee86b47a488c537325bc59","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine Set.Finite.subset hfg fun _ ha ↦ Set.mem_setOf.mpr fun H ↦ Set.mem_setOf.mp ha ?_\n grind\n\n-- The additive version is a special case of `Function.HasFiniteSupport.smul_left`.","hard_negative":false,"metrics":{"chosen_tokens":47,"rejected_tokens":3,"token_jaccard":0.064516,"token_length_ratio":0.06383},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"544f9b419ba8091254322bc0a0f83e42b4d480b4410f29d952368c8aabf89d62","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmas\npublic import Mathlib.Algebra.FiniteSupport.Defs\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.GroupWithZero.Action.Defs\npublic import Mathlib.Algebra.Order.Group.Indicator\npublic import Mathlib.Data.Set.Finite.Lattice\nimport Mathlib.Algebra.GroupWithZero.Indicator\nimport Mathlib.Algebra.Module.Basic\n\nNamespace:\nFunction\n\nLocal context:\n/-\nCopyright (c) 2026 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Make `fun_prop` work for finite (multiplicative) support\n\nWe provide API lemmas for the predicate `HasFiniteMulSupport` (and its additivized version\n`HasFiniteSupport`) on functions so that `fun_prop` can prove it for functions that are\nbuilt from other functions with finite multiplicative support.\n-/\n\npublic section\n\nnamespace Function\n\nvariable {α M : Type*} [One M]\n\n@[to_additive (attr := fun_prop)]\nlemma hasFiniteMulSupport_fun_one : HasFiniteMulSupport (1 : α → M) := by\n simp [HasFiniteMulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport fun a ↦ g (f a) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport (g ∘ f) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fst {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).fst :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.snd {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).snd :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prodMk {M' : Type*} [One M'] {f : α → M} {g : α → M'}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ (f a, g a) := by\n simp only [HasFiniteMulSupport] at hf hg ⊢\n rw [mulSupport_prodMk f g]\n exact hf.union hg\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.mul {M : Type*} [MulOneClass M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f * g) :=\n (hf.union hg).subset <| mulSupport_mul ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.inv {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport f⁻¹ :=\n hf.comp inv_one\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prod {M : Type*} [CommMonoid M] {ι : Type*} {f : ι → α → M}\n (hf : ∀ i, HasFiniteMulSupport (f i)) (s : Finset ι) :\n HasFiniteMulSupport fun a ↦ ∏ i ∈ s, f i a :=\n (s.finite_toSet.biUnion fun i _ ↦ hf i).subset <| s.mulSupport_prod f\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.div {M : Type*} [DivisionMonoid M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f / g) :=\n (hf.union hg).subset <| mulSupport_div ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.pow {M : Type*} [Monoid M] {f : α → M} (hf : HasFiniteMulSupport f)\n (n : ℕ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_pow n)\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.zpow {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) (n : ℤ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_zpow n)\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.max [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ max (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_max ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.min [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ min (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_min ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup [SemilatticeSup M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊔ g a :=\n (hf.union hg).subset <| mulSupport_sup ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf [SemilatticeInf M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊓ g a :=\n (hf.union hg).subset <| mulSupport_inf ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iSup [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨆ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iSup f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iInf [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨅ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iInf f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.pi {ι : Type*} [Finite α] {f : ι → α → M}\n (hf : ∀ a, HasFiniteMulSupport (f · a)) :\n HasFiniteMulSupport f := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (Set.finite_iUnion hf).subset fun i hi ↦ ?_\n simp only [mem_mulSupport, Set.mem_iUnion] at hi ⊢\n exact ne_iff.mp hi\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup' [SemilatticeSup M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.sup' hs (f · a) := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.sup'_eq_of_forall hs (fun x ↦ f x a) ha\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf' [SemilatticeInf M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.inf' hs (f · a) := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.inf'_eq_of_forall hs (fun x ↦ f x a) ha\n\nvariable {β : Type*} {f : β → M} {g : α → β}\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp_of_injective (hg : Injective g) (hf : f.HasFiniteMulSupport) :\n (f ∘ g).HasFiniteMulSupport := by\n refine Set.Finite.of_injOn ?_ (Set.injOn_of_injective hg) hf\n grind [Set.mapsTo_iff_subset_preimage, Function.mulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp_of_injective (hg : Injective g) (hf : f.HasFiniteMulSupport) :\n (fun a ↦ f (g a)).HasFiniteMulSupport :=\n hf.comp_of_injective hg\n\n@[to_additive]\n\nTarget:\nlemma HasFiniteMulSupport.of_comp [One β] (hfg : (f ∘ g).HasFiniteMulSupport) (h : f 1 = 1)\n (hf : Injective f) :\n g.HasFiniteMulSupport :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FiniteSupport","family_id":"hasfinitemulsupport","file_id":"mathlib/Mathlib/Algebra/FiniteSupport/Basic.lean","sample_id":"fa8622e4654fc596914560a34e89d20db8c2ad34a6ad4dad32b4200c14e665f6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3c3ac14425b980afe99cd5c2de5d3558064742f67e49e0d7c12287314690c533","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"1b1816635ec9b5f4532bacab93a619d260f406d16d5320338c20d172825a4143","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"819fbb3c55af36935e785313ab0f6f54a3ff89f9c275d6a0eca91ff841251b44","source_sha256":"7b71466fe661edbc6adc5c50b7417cb616e3f9824d1c6bd340a7fc9d6d0eafd0","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have aux (n : ℕ) : injectiveDimension M ≤ n → injectiveDimension (M.localizedModule S) ≤ n := by\n simp only [injectiveDimension_le_iff]\n intro h\n exact M.localizedModule_hasInjectiveDimensionLE n S\n refine le_of_forall_ge (fun N ↦ ?_)\n induction N with\n | bot =>\n simp only [le_bot_iff, injectiveDimension_eq_bot_iff, ModuleCat.isZero_iff_subsingleton,\n ModuleCat.localizedModule, ← Equiv.subsingleton_congr (equivShrink _)]\n intro _\n apply LocalizedModule.instSubsingleton _\n | coe N =>\n induction N with\n | top => simp\n | coe n => simpa using aux n","hard_negative":true,"metrics":{"chosen_tokens":103,"rejected_tokens":3,"token_jaccard":0.037037,"token_length_ratio":0.029126},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"55195849e36188776fa6f3b05d056e36b0c33de4520e1a4f900ebdf797bf7856","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Grp.Zero\npublic import Mathlib.Algebra.Category.ModuleCat.EnoughInjectives\npublic import Mathlib.Algebra.Category.ModuleCat.Localization\npublic import Mathlib.Algebra.Category.ModuleCat.Projective\npublic import Mathlib.Algebra.Homology.DerivedCategory.Ext.EnoughInjectives\npublic import Mathlib.Algebra.Homology.ShortComplex.ModuleCat\npublic import Mathlib.Algebra.Module.LocalizedModule.Exact\npublic import Mathlib.CategoryTheory.Abelian.Injective.Dimension\npublic import Mathlib.CategoryTheory.Preadditive.Injective.Preserves\npublic import Mathlib.LinearAlgebra.Dimension.Finite\npublic import Mathlib.RingTheory.LocalProperties.Injective\n\nNamespace:\nModuleCat\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n\n# Relation of Injective Dimension with Localizations\n\n-/\n\npublic section\n\nuniverse v u\n\nnamespace ModuleCat\n\nvariable {R : Type u} [CommRing R]\n\nopen CategoryTheory Limits\n\nset_option backward.isDefEq.respectTransparency false in\ninstance [Small.{v} R] [IsNoetherianRing R] (S : Submonoid R) :\n (ModuleCat.localizedModuleFunctor.{v} S).PreservesInjectiveObjects where\n injective_obj X {inj} := by\n let _ : Small.{v, u} (Localization S) := small_of_surjective Localization.mkHom_surjective\n rw [← Module.injective_iff_injective_object] at inj ⊢\n simpa [ModuleCat.localizedModuleFunctor] using\n Module.injective_of_isLocalizedModule S (X.localizedModuleMkLinearMap S)\n\nlemma localizedModule_hasInjectiveDimensionLE [Small.{v, u} R] [IsNoetherianRing R] (n : ℕ)\n (S : Submonoid R) (M : ModuleCat.{v} R) [HasInjectiveDimensionLE M n] :\n HasInjectiveDimensionLE (M.localizedModule S) n := by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n induction n generalizing M with\n | zero =>\n have injle : HasInjectiveDimensionLE M 0 := ‹_›\n simp only [HasInjectiveDimensionLE, zero_add, ← injective_iff_hasInjectiveDimensionLT_one]\n at injle ⊢\n rw [← Module.injective_iff_injective_object] at injle ⊢\n exact Module.injective_of_isLocalizedModule S (M.localizedModuleMkLinearMap S)\n | succ n ih =>\n have ei : EnoughInjectives (ModuleCat.{v} R) := inferInstance\n rcases ei.1 M with ⟨I, inj, f, monof⟩\n let T := ShortComplex.mk f (cokernel.π f) (cokernel.condition f)\n have T_exact : T.ShortExact := { exact := ShortComplex.exact_cokernel f }\n have T_exact' : Function.Exact (ConcreteCategory.hom T.f) (ConcreteCategory.hom T.g) :=\n (ShortComplex.ShortExact.moduleCat_exact_iff_function_exact _).mp T_exact.1\n have TS_exact' := IsLocalizedModule.map_exact S (T.X₁.localizedModuleMkLinearMap S)\n (T.X₂.localizedModuleMkLinearMap S) (T.X₃.localizedModuleMkLinearMap S) _ _ T_exact'\n let TS := T.map (ModuleCat.localizedModuleFunctor S)\n have TS_exact : TS.ShortExact := T_exact.map_of_exact (ModuleCat.localizedModuleFunctor S)\n let _ := (T_exact.hasInjectiveDimensionLT_X₃_iff n ‹_›).mpr ‹_›\n let _ : Injective TS.X₂ := (ModuleCat.localizedModuleFunctor.{v} S).injective_obj _\n exact (TS_exact.hasInjectiveDimensionLT_X₃_iff n ‹_›).mp (ih T.X₃)\n\nopen Limits in\n\nTarget:\nlemma injectiveDimension_le_injectiveDimension_of_isLocalizedModule [Small.{v, u} R]\n [IsNoetherianRing R] (S : Submonoid R) (M : ModuleCat.{v} R) :\n injectiveDimension (M.localizedModule S) ≤ injectiveDimension M :=\n\nProof body:\n","rejected":"by\n exact injectiveDimension_le_injectiveDimension_of_isLocalizedModule","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"f2396429760b99c32eb9e895c57247d4de2750e13e710b72eafb000ede48350b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/LocalProperties","family_id":"injectivedimension_le_injectivedimension_of_islocalizedmodule","file_id":"mathlib/Mathlib/RingTheory/LocalProperties/InjectiveDimension.lean","sample_id":"819fbb3c55af36935e785313ab0f6f54a3ff89f9c275d6a0eca91ff841251b44"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"86be2fb4446f54e9492e321be49c049da5cb8ccb99e4df8748bd638740696585","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e99e8d259642e35c0011d73c3322c31ff1685803fa550c31af3f59e41cc006c5","source_sha256":"67cc6b7ca466b4df61acd757fae3e65f0f6ce1aa35615c76c69b2b6131234dd3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [isNilpotent_iff]\n refine exists_congr fun n ↦ ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · simp [← Subgroup.comap_top e.symm.toMonoidHom, ← h]\n · simp [← Subgroup.comap_top e.toMonoidHom, ← h]","hard_negative":false,"metrics":{"chosen_tokens":53,"rejected_tokens":2,"token_jaccard":0.08,"token_length_ratio":0.037736},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"55d1bdf7a345d5b098bc9e7678f810ca883d297261c19e22f1c95399d199c0f7","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.GroupTheory.Solvable\npublic import Mathlib.GroupTheory.Sylow\npublic import Mathlib.Algebra.Group.Subgroup.Order\npublic import Mathlib.GroupTheory.Commutator.Finite\n\nNamespace:\nGroup\n\nLocal context:\n/-\nCopyright (c) 2021 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Ines Wright, Joachim Breitner\n-/\n/-!\n\n# Nilpotent groups\n\nAn API for nilpotent groups, that is, groups for which the upper central series\nreaches `⊤`.\n\n## Main definitions\n\nRecall that if `H K : Subgroup G` then `⁅H, K⁆ : Subgroup G` is the subgroup of `G` generated\nby the commutators `hkh⁻¹k⁻¹`. Recall also Lean's conventions that `⊤` denotes the\nsubgroup `G` of `G`, and `⊥` denotes the trivial subgroup `{1}`.\n\n* `Subgroup.upperCentralSeries G : ℕ → Subgroup G` : the upper central series of a group `G`.\n This is an increasing sequence of characteristic subgroups `H n` of `G` with `H 0 = ⊥` and\n `H (n + 1) / H n` is the centre of `G / H n`.\n* `Subgroup.lowerCentralSeries (S : Subgroup G) : ℕ → Subgroup G` : the lower central series of `S`,\n computed in the ambient group `G`. This is the iterated commutator\n `S, ⁅S, S⁆, ⁅⁅S, S⁆, S⁆, …`. The classical lower central series of `G` is the case\n `S = ⊤`.\n* `IsNilpotent` : A group G is nilpotent if its upper central series reaches `⊤`, or\n equivalently if its lower central series reaches `⊥`.\n* `Group.nilpotencyClass` : the length of the upper central series of a nilpotent group.\n* `IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop` and\n* `IsDescendingCentralSeries (H : ℕ → Subgroup G) : Prop` : Note that in the literature\n a \"central series\" for a group is usually defined to be a *finite* sequence of normal subgroups\n `H 0`, `H 1`, ..., starting at `⊤`, finishing at `⊥`, and with each `H n / H (n + 1)`\n central in `G / H (n + 1)`. In this formalisation it is convenient to have two weaker predicates\n on an infinite sequence of subgroups `H n` of `G`: we say a sequence is a *descending central\n series* if it starts at `G` and `⁅H n, ⊤⁆ ⊆ H (n + 1)` for all `n`. Note that this series\n may not terminate at `⊥`, and the `H i` need not be normal. Similarly a sequence is an\n *ascending central series* if `H 0 = ⊥` and `⁅H (n + 1), ⊤⁆ ⊆ H n` for all `n`, again with no\n requirement that the series reaches `⊤` or that the `H i` are normal.\n\n## Main theorems\n\n`G` is *defined* to be nilpotent if the upper central series reaches `⊤`.\n* `nilpotent_iff_finite_ascending_central_series` : `G` is nilpotent iff some ascending central\n series reaches `⊤`.\n* `nilpotent_iff_finite_descending_central_series` : `G` is nilpotent iff some descending central\n series reaches `⊥`.\n* `nilpotent_iff_lower` : `G` is nilpotent iff the lower central series reaches `⊥`.\n* The `Group.nilpotencyClass` can likewise be obtained from these equivalent\n definitions, see `least_ascending_central_series_length_eq_nilpotencyClass`,\n `least_descending_central_series_length_eq_nilpotencyClass` and\n `lowerCentralSeries_length_eq_nilpotencyClass`.\n* If `G` is nilpotent, then so are its subgroups, images, quotients and preimages.\n Binary and finite products of nilpotent groups are nilpotent.\n Infinite products are nilpotent if their nilpotent class is bounded.\n Corresponding lemmas about the `Group.nilpotencyClass` are provided.\n* The `Group.nilpotencyClass` of `G ⧸ center G` is given explicitly, and an induction principle\n is derived from that.\n* `IsNilpotent.to_isSolvable`: If `G` is nilpotent, it is solvable.\n\n\n## Warning\n\nA \"central series\" is usually defined to be a finite sequence of normal subgroups going\nfrom `⊥` to `⊤` with the property that each subquotient is contained within the centre of\nthe associated quotient of `G`. This means that if `G` is not nilpotent, then\nnone of what we have called `upperCentralSeries G`, `(⊤ : Subgroup G).lowerCentralSeries` or\nthe sequences satisfying `IsAscendingCentralSeries` or `IsDescendingCentralSeries`\nare actually central series. Note that the fact that the upper and lower central series\nare not central series if `G` is not nilpotent is a standard abuse of notation.\n\n-/\n\n@[expose] public section\n\n\nopen commutatorElement Subgroup\n\nsection WithGroup\n\nvariable {G : Type*} [Group G] (N : Subgroup G) [Normal N]\n\nnamespace Subgroup\n\n/-- If `N` is a normal subgroup of `G`, then the set `{x : G | ∀ y : G, x*y*x⁻¹*y⁻¹ ∈ N}`\nis a subgroup of `G` (because it is the preimage in `G` of the centre of the\nquotient group `G/N`.)\n-/\n@[to_additive /-- If `N` is a normal additive subgroup of `G`, then the set\n`{x : G | ∀ y : G, x + y -x - y ∈ N}` is an additive subgroup of `G`\n(because it is the preimage in `G` of the centre of the additive quotient group `G/N`.) -/]\ndef upperCentralSeriesStep : Subgroup G where\n carrier := { x : G | ∀ y : G, ⁅x, y⁆ ∈ N }\n one_mem' y := by simp\n mul_mem' {a b} ha hb y := by\n convert! Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1\n group\n inv_mem' {x} hx y := by\n specialize hx y⁻¹\n rw [commutatorElement_def, mul_assoc, inv_inv] at hx ⊢\n exact Subgroup.Normal.mem_comm inferInstance hx\n\n@[to_additive]\ntheorem mem_upperCentralSeriesStep (x : G) :\n x ∈ upperCentralSeriesStep N ↔ ∀ y, ⁅x, y⁆ ∈ N := Iff.rfl\n\nopen QuotientGroup\n\n/-- The proof that `upperCentralSeriesStep N` is the preimage of the centre of `G/N` under\nthe canonical surjection. -/\n@[to_additive /-- The proof that `upperCentralSeriesStep N` is the preimage of the centre of `G/N`\\\nunder the canonical surjection. -/]\ntheorem upperCentralSeriesStep_eq_comap_center :\n upperCentralSeriesStep N = Subgroup.comap (mk' N) (center (G ⧸ N)) := by\n ext\n rw [mem_comap, mem_center_iff, forall_mk]\n refine forall_congr' fun y => ?_\n rw [coe_mk', ← QuotientGroup.mk_mul, ← QuotientGroup.mk_mul, eq_comm, eq_iff_div_mem,\n div_eq_mul_inv, mul_inv_rev, commutatorElement_def]\n simp_rw [mul_assoc]\n\n@[to_additive]\ninstance [N.Characteristic] : Characteristic (upperCentralSeriesStep N) :=\n (upperCentralSeriesStep_eq_comap_center N) ▸ Characteristic.comap_quotient_mk centerCharacteristic\n\nvariable (G)\n\n/-- An auxiliary type-theoretic definition defining both the upper central series of\na group, and a proof that it is characteristic, all in one go. -/\ndef upperCentralSeriesAux : ℕ → Σ' H : Subgroup G, Characteristic H\n | 0 => ⟨⊥, inferInstance⟩\n | n + 1 =>\n let un := upperCentralSeriesAux n\n let _un_characteristic := un.2\n ⟨upperCentralSeriesStep un.1, inferInstance⟩\n\n/-- An auxiliary type-theoretic definition defining both the upper central series of\nan additive group, and a proof that it is characteristic, all in one go. -/\ndef _root_.AddSubgroup.upperCentralSeriesAux (G : Type*) [AddGroup G] :\n ℕ → Σ' H : AddSubgroup G, H.Characteristic\n | 0 => ⟨⊥, inferInstance⟩\n | n + 1 =>\n let un := upperCentralSeriesAux G n\n let _un_characteristic := un.2\n ⟨AddSubgroup.upperCentralSeriesStep un.1, inferInstance⟩\n\nattribute [to_additive existing] upperCentralSeriesAux\n\n/-- `upperCentralSeries G n` is the `n`th term in the upper central series of `G`.\n\nThis is the increasing chain of subgroups of `G` that starts with the trivial subgroup `⊥` of `G`\nand then continues defining `upperCentralSeries G (n + 1)` to be all the elements of `G`\nthat, modulo `upperCentralSeries G n`, belong to the center of the quotient\n`G ⧸ upperCentralSeries G n`.\n\nIn particular, the identities\n* `upperCentralSeries G 0 = ⊥` (`upperCentralSeries_zero`);\n* `upperCentralSeries G 1 = center G` (`upperCentralSeries_one`);\n\nhold.\n-/\n@[to_additive\n/-- `upperCentralSeries G n` is the `n`th term in the upper central series of `G`.\n\nThis is the increasing chain of additive subgroups of `G` that starts with the trivial additive\nsubgroup `⊥` of `G` and then continues defining `upperCentralSeries G (n + 1)` to be all the\nelements of `G` that, modulo `upperCentralSeries G n`, belong to the center of the additive quotient\n`G ⧸ upperCentralSeries G n`.\n\nIn particular, the identities\n* `upperCentralSeries G 0 = ⊥` (`upperCentralSeries_zero`);\n* `upperCentralSeries G 1 = center G` (`upperCentralSeries_one`);\n\nhold.\n-/]\ndef upperCentralSeries (n : ℕ) : Subgroup G :=\n (upperCentralSeriesAux G n).1\n\n@[to_additive]\ninstance (n : ℕ) : Characteristic (upperCentralSeries G n) :=\n (upperCentralSeriesAux G n).2\n\n@[to_additive (attr := simp)]\ntheorem upperCentralSeries_zero : upperCentralSeries G 0 = ⊥ := rfl\n\ntheorem upperCentralSeries_one : upperCentralSeries G 1 = center G := by\n ext\n simp only [upperCentralSeries, upperCentralSeriesAux, upperCentralSeriesStep, mem_bot, mem_mk,\n Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_setOf_eq, mem_center_iff]\n exact forall_congr' fun y => by\n rw [commutatorElement_def, mul_inv_eq_one, mul_inv_eq_iff_eq_mul, eq_comm]\n\ntheorem _root_.AddSubgroup.upperCentralSeries_one (G : Type*) [AddGroup G] :\n AddSubgroup.upperCentralSeries G 1 = AddSubgroup.center G := by\n ext\n simp only [AddSubgroup.upperCentralSeries, AddSubgroup.upperCentralSeriesAux,\n AddSubgroup.upperCentralSeriesStep, AddSubgroup.mem_bot, AddSubgroup.mem_mk,\n AddSubmonoid.mem_mk, AddSubsemigroup.mem_mk, Set.mem_setOf_eq, AddSubgroup.mem_center_iff]\n exact forall_congr' fun y => by\n rw [addCommutatorElement_def, add_neg_eq_zero, add_neg_eq_iff_eq_add, eq_comm]\n\nattribute [to_additive existing (attr := simp) AddSubgroup.upperCentralSeries_one]\n upperCentralSeries_one\n\nvariable {G}\n\n/-- The `n+1`st term of the upper central series `H i` has underlying set equal to the `x` such\nthat `⁅x,G⁆ ⊆ H n`. -/\n@[to_additive /-- The `n+1`st term of the upper central series `H i` has underlying set equal to\nthe `x` such that `⁅x,G⁆ ⊆ H n`. -/]\ntheorem mem_upperCentralSeries_succ_iff {n : ℕ} {x : G} :\n x ∈ upperCentralSeries G (n + 1) ↔ ∀ y : G, ⁅x, y⁆ ∈ upperCentralSeries G n :=\n Iff.rfl\n\n@[to_additive (attr := simp)]\nlemma comap_upperCentralSeries {H : Type*} [Group H] (e : H ≃* G) :\n ∀ n, (upperCentralSeries G n).comap e = upperCentralSeries H n\n | 0 => by simpa [MonoidHom.ker_eq_bot_iff] using e.injective\n | n + 1 => by\n ext\n simp [mem_upperCentralSeries_succ_iff, ← comap_upperCentralSeries e n,\n ← e.toEquiv.forall_congr_right, commutatorElement_def]\n\nend Subgroup\n\nnamespace Group\n\nvariable (G) in\n-- `IsNilpotent` is already defined in the root namespace (for elements of rings).\n-- TODO: Rename it to `IsNilpotentElement`?\n/-- A group `G` is nilpotent if its upper central series is eventually `G`. -/\n@[mk_iff, wikidata Q1755242]\nclass IsNilpotent (G : Type*) [Group G] : Prop where\n nilpotent' : ∃ n : ℕ, upperCentralSeries G n = ⊤\n\nvariable (G) in\n-- `IsNilpotent` is already defined in the root namespace (for elements of rings).\n-- TODO: Rename it to `IsNilpotentElement`?\n/-- An additive group `G` is nilpotent if its upper central series is eventually `G`. -/\n@[mk_iff]\nclass _root_.AddGroup.IsNilpotent (G : Type*) [AddGroup G] : Prop where\n nilpotent' : ∃ n : ℕ, AddSubgroup.upperCentralSeries G n = ⊤\n\n@[to_additive]\nlemma IsNilpotent.nilpotent (G : Type*) [Group G] [IsNilpotent G] :\n ∃ n : ℕ, upperCentralSeries G n = ⊤ := Group.IsNilpotent.nilpotent'\n\n@[to_additive]\n\nTarget:\nlemma isNilpotent_congr {H : Type*} [Group H] (e : G ≃* H) : IsNilpotent G ↔ IsNilpotent H :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory","family_id":"isnilpotent_congr","file_id":"mathlib/Mathlib/GroupTheory/Nilpotent.lean","sample_id":"e99e8d259642e35c0011d73c3322c31ff1685803fa550c31af3f59e41cc006c5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"33ca22f3b5bf5fc06222f4523b841e69cdf5f12cc093fd3d894334378b9f1819","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"98ba47977d6575dce7c82daa1f201918aff6d509ee1f3f9c7ef1102f57f9cfe3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"71d40dbf91009a8d289f32f35fd098eb312b3c5f7d77a88722243c78657ed903","source_sha256":"3b2fe3ce97a7f385df1705afa4e64183ee3b93d50020ad74beb0ced8ddd98b80","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Module.Relations.Solution.isPresentation_iff]\n constructor\n · rw [← Module.Relations.Solution.surjective_π_iff_span_eq_top, ← comm₂₃]\n exact Extension.toKaehler_surjective.comp pres.cotangentSpaceBasis.repr.symm.surjective\n · rw [← Module.Relations.range_map]\n exact Function.Exact.linearMap_ker_eq\n ((LinearMap.exact_iff_of_surjective_of_bijective_of_injective\n _ _ _ _ (hom₁ pres)\n pres.cotangentSpaceBasis.repr.symm.toLinearMap .id\n (comm₁₂ pres) (by simpa using comm₂₃ pres) (surjective_hom₁ pres)\n (LinearEquiv.bijective _) (Equiv.refl _).injective).2\n pres.toExtension.exact_cotangentComplex_toKaehler)\n\n/-- The presentation of the `S`-module `Ω[S⁄R]` deduced from a presentation\nof `S` as an `R`-algebra. -/\nnoncomputable def differentials : Module.Presentation S Ω[S⁄R] where\n G := ι\n R := σ\n relation := _\n toSolution := differentialsSolution pres\n toIsPresentation := pres.differentialsSolution_isPresentation","hard_negative":false,"metrics":{"chosen_tokens":201,"rejected_tokens":206,"token_jaccard":0.965909,"token_length_ratio":1.024876},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"56372a461ae549c2bb00e4afc8213852fb09caa780cfd522d5dd5fab0970f229","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.Presentation.Basic\npublic import Mathlib.RingTheory.Kaehler.Polynomial\npublic import Mathlib.RingTheory.Extension.Cotangent.Basic\npublic import Mathlib.RingTheory.Extension.Presentation.Basic\n\nNamespace:\nAlgebra.Presentation\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Presentation of the module of differentials\n\nGiven a presentation of an `R`-algebra `S`, we obtain a presentation\nof the `S`-module `Ω[S⁄R]`.\n\nAssume `pres : Algebra.Presentation R S` is a presentation of `S` as an `R`-algebra.\nWe then have a type `ι` for the generators, a type `σ` for the relations,\nand for each `r : σ` we have the relation `pres.relation r` in `pres.Ring` (which is\na ring of polynomials over `R` with variables indexed by `ι`).\nThen, `Ω[pres.Ring⁄R]` identifies to the free module on the type `ι`, and\nfor each `r : σ`, we may consider the image of the differential of `pres.relation r`\nin this free module, and by using the (surjective) map `pres.Ring → S`, we obtain\nan element `pres.differentialsRelations.relation r` in the free `S`-module on `ι`.\nThe main result in this file is that `Ω[S⁄R]` identifies to the quotient of the\nfree `S`-module on `ι` by the submodule generated by these\nelements `pres.differentialsRelations.relation r`. We show this as a consequence\nof `Algebra.Extension.exact_cotangentComplex_toKaehler`\nfrom the file `Mathlib/RingTheory/Extension/Cotangent/Basic.lean`.\n\n-/\n\n@[expose] public section\n\nopen Module\n\nuniverse w' t w u v\n\nnamespace Algebra.Presentation\n\nopen KaehlerDifferential\n\nvariable {R : Type u} {S : Type v} {ι : Type w} {σ : Type t} [CommRing R] [CommRing S] [Algebra R S]\n (pres : Algebra.Presentation R S ι σ)\n\n/-- The shape of the presentation by generators and relations of the `S`-module `Ω[S⁄R]`\nthat is obtained from a presentation of `S` as an `R`-algebra. -/\n@[simps G R]\nnoncomputable def differentialsRelations : Module.Relations S where\n G := ι\n R := σ\n relation r :=\n Finsupp.mapRange (algebraMap pres.Ring S) (by simp)\n ((mvPolynomialBasis R ι).repr (D _ _ (pres.relation r)))\n\nnamespace differentials\n\n/-! We obtain here a few compatibilities which allow to compare the two sequences\n`(σ →₀ S) → (ι →₀ S) → Ω[S⁄R]` and\n`pres.toExtension.Cotangent →ₗ[S] pres.toExtension.CotangentSpace → Ω[S⁄R]`.\nIndeed, there is commutative diagram with a surjective map\n`hom₁ : (σ →₀ S) →ₗ[S] pres.toExtension.Cotangent` on the left and\nbijections on the middle and on the right. Then, the exactness of the first\nsequence shall follow from the exactness of the second which is\n`Algebra.Extension.exact_cotangentComplex_toKaehler`. -/\n\n/-- Same as `comm₂₃` below, but here we have not yet constructed `differentialsSolution`. -/\nlemma comm₂₃' : pres.toExtension.toKaehler.comp pres.cotangentSpaceBasis.repr.symm.toLinearMap =\n Finsupp.linearCombination S (fun g ↦ D _ _ (pres.val g)) := by\n ext\n simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- The canonical map `(σ →₀ S) →ₗ[S] pres.toExtension.Cotangent`. -/\nnoncomputable def hom₁ : (σ →₀ S) →ₗ[S] pres.toExtension.Cotangent :=\n Finsupp.linearCombination S (fun r ↦ Extension.Cotangent.mk ⟨pres.relation r, by simp⟩)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma hom₁_single (r : σ) :\n hom₁ pres (Finsupp.single r 1) = Extension.Cotangent.mk ⟨pres.relation r, by simp⟩ := by\n simp [hom₁]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma surjective_hom₁ : Function.Surjective (hom₁ pres) := by\n let φ : (σ →₀ S) →ₗ[pres.Ring] pres.toExtension.Cotangent :=\n { toFun := hom₁ pres\n map_add' := by simp\n map_smul' := by simp }\n change Function.Surjective φ\n have h₁ := Algebra.Extension.Cotangent.mk_surjective (P := pres.toExtension)\n have h₂ : Submodule.span pres.Ring\n (Set.range (fun r ↦ (⟨pres.relation r, by simp⟩ : pres.ker))) = ⊤ := by\n refine Submodule.map_injective_of_injective (f := Submodule.subtype pres.ker)\n Subtype.coe_injective ?_\n rw [Submodule.map_top, Submodule.range_subtype, Submodule.map_span,\n Submodule.coe_subtype, Ideal.submodule_span_eq]\n simp only [← pres.span_range_relation_eq_ker]\n congr\n aesop\n rw [← LinearMap.range_eq_top] at h₁ ⊢\n rw [← top_le_iff, ← h₁, LinearMap.range_eq_map, ← h₂]\n dsimp\n rw [Submodule.map_span_le]\n rintro _ ⟨r, rfl⟩\n simp only [LinearMap.mem_range]\n refine ⟨Finsupp.single r 1, ?_⟩\n simp only [LinearMap.coe_mk, AddHom.coe_mk, hom₁_single, φ]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma comm₁₂_single (r : σ) :\n pres.toExtension.cotangentComplex (hom₁ pres (Finsupp.single r 1)) =\n pres.cotangentSpaceBasis.repr.symm ((differentialsRelations pres).relation r) := by\n simp only [hom₁, Finsupp.linearCombination_single, one_smul, differentialsRelations,\n Basis.repr_symm_apply, Extension.cotangentComplex_mk]\n exact pres.cotangentSpaceBasis.repr.injective (by ext; simp)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma comm₁₂ : pres.toExtension.cotangentComplex.comp (hom₁ pres) =\n pres.cotangentSpaceBasis.repr.symm.comp (differentialsRelations pres).map := by\n ext r\n have := (differentialsRelations pres).map_single\n dsimp at this ⊢\n rw [comm₁₂_single, this]\n\nend differentials\n\nset_option backward.isDefEq.respectTransparency false in\nopen differentials in\n/-- The `S`-module `Ω[S⁄R]` contains an obvious solution to the system of linear\nequations `pres.differentialsRelations.Solution` when `pres` is a presentation\nof `S` as an `R`-algebra. -/\nnoncomputable def differentialsSolution :\n pres.differentialsRelations.Solution Ω[S⁄R] where\n var g := D _ _ (pres.val g)\n linearCombination_var_relation r := by\n simp only [LinearMap.coe_comp, LinearEquiv.coe_coe,\n Function.comp_apply, ← comm₂₃', ← comm₁₂_single]\n apply DFunLike.congr_fun (Function.Exact.linearMap_comp_eq_zero\n (pres.toExtension.exact_cotangentComplex_toKaehler))\n\nlemma differentials.comm₂₃ :\n pres.toExtension.toKaehler.comp pres.cotangentSpaceBasis.repr.symm.toLinearMap =\n pres.differentialsSolution.π :=\n comm₂₃' pres\n\nopen differentials in\n\nTarget:\nlemma differentialsSolution_isPresentation :\n pres.differentialsSolution.IsPresentation :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n rw [Module.Relations.Solution.isPresentation_iff]\n constructor\n · rw [← Module.Relations.Solution.surjective_π_iff_span_eq_top, ← comm₂₃]\n exact Extension.toKaehler_surjective.comp pres.cotangentSpaceBasis.repr.symm.surjective\n · rw [← Module.Relations.range_map]\n exact Function.Exact.linearMap_ker_eq\n ((LinearMap.exact_iff_of_surjective_of_bijective_of_injective\n _ _ _ _ (hom₁ pres)\n pres.cotangentSpaceBasis.repr.symm.toLinearMap .id\n (comm₁₂ pres) (by simpa using comm₂₃ pres) (surjective_hom₁ pres)\n (LinearEquiv.bijective _) (Equiv.refl _).injective).2\n pres.toExtension.exact_cotangentComplex_toKaehler)\n\n/-- The presentation of the `S`-module `Ω[S⁄R]` deduced from a presentation\nof `S` as an `R`-algebra. -/\nnoncomputable def differentials : Module.Presentation S Ω[S⁄R] where\n G := ι\n R := σ\n relation := _\n toSolution := differentialsSolution pres\n toIsPresentation := pres.differentialsSolution_isPresentation","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Module","family_id":"differentialssolution_ispresentation","file_id":"mathlib/Mathlib/Algebra/Module/Presentation/Differentials.lean","sample_id":"71d40dbf91009a8d289f32f35fd098eb312b3c5f7d77a88722243c78657ed903"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"44e5ddd2baf0c2961be4d908f5f5aa690e26d21071f58e7a235f570f61fcd36f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cd56beece6e3260785012905a7333440a52277cc36934bf7fb02c903e3482ee5","source_sha256":"3feee154a2a7cd94b37d0dc241c9f413d5c37bf8c3d535669868301ff8953cf3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← IsIso.eq_inv_comp, Limits.comp_zero]","hard_negative":false,"metrics":{"chosen_tokens":12,"rejected_tokens":2,"token_jaccard":0.083333,"token_length_ratio":0.166667},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"57a24f58c16bd7e0aa7beceaf10d34eade608efcf8d5ee097787d906b4c1f413","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TransferInstance\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.Algebra.Group.Action.Units\npublic import Mathlib.CategoryTheory.Endomorphism\npublic import Mathlib.CategoryTheory.Limits.Shapes.Kernels\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Defs\npublic import Mathlib.Algebra.Module.NatInt\n\nNamespace:\nCategoryTheory.Preadditive.IsIso\n\nLocal context:\n/-\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-/\n/-!\n# Preadditive categories\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\n@[expose] public section\n\n\nuniverse v u\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory\n\nvariable (C : Type u) [Category.{v} C]\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\nlinear in both variables. -/\n@[stacks 00ZY]\nclass Preadditive where\n homGroup : ∀ P Q : C, AddCommGroup (P ⟶ Q) := by infer_instance\n add_comp : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R), (f + f') ≫ g = f ≫ g + f' ≫ g := by\n cat_disch\n comp_add : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R), f ≫ (g + g') = f ≫ g + f ≫ g' := by\n cat_disch\n\nattribute [inherit_doc Preadditive] Preadditive.homGroup Preadditive.add_comp Preadditive.comp_add\n\nattribute [instance_reducible, instance] Preadditive.homGroup\n\n-- simp can already prove reassoc version\nattribute [reassoc, simp] Preadditive.add_comp\n\nattribute [reassoc] Preadditive.comp_add\n\nattribute [simp] Preadditive.comp_add\n\nend CategoryTheory\n\nopen CategoryTheory\n\nnamespace CategoryTheory\n\nnamespace Preadditive\n\nsection Preadditive\n\nopen AddMonoidHom\n\nvariable {C : Type u} [Category.{v} C] [Preadditive C]\n\nsection InducedCategory\n\nuniverse u'\n\nvariable {D : Type u'} (F : D → C)\n\ninstance inducedCategory : Preadditive.{v} (InducedCategory C F) where\n homGroup P Q := InducedCategory.homEquiv.addCommGroup\n add_comp _ _ _ _ _ _ := by ext; apply add_comp\n comp_add _ _ _ _ _ _ := by ext; apply comp_add\n\nvariable {F} in\n/-- The additive equivalence `(X ⟶ Y) ≃+ (F X ⟶ F Y)` when `F : D → C` and\n`C` is a preadditive category. -/\n@[simps!]\ndef _root_.CategoryTheory.InducedCategory.homAddEquiv\n {X Y : InducedCategory C F} :\n (X ⟶ Y) ≃+ (F X ⟶ F Y) where\n toEquiv := InducedCategory.homEquiv\n map_add' := by aesop_cat\n\nend InducedCategory\n\ninstance fullSubcategory (Z : ObjectProperty C) : Preadditive Z.FullSubcategory where\n homGroup P Q := {\n -- Note: Add zero field explicitly for a better transparency of definitional properties\n zero := Z.homMk 0\n __ := InducedCategory.homEquiv.addCommGroup }\n add_comp _ _ _ _ _ _ := by ext; apply add_comp\n comp_add _ _ _ _ _ _ := by ext; apply comp_add\n\ninstance (X : C) : AddCommGroup (End X) :=\n inferInstanceAs <| AddCommGroup (X ⟶ X)\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef leftComp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=\n mk' (fun g => f ≫ g) fun g g' => by simp\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef rightComp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=\n mk' (fun f => f ≫ g) fun f f' => by simp\n\nvariable {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef compHom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) :=\n AddMonoidHom.mk' (fun f => leftComp _ f) fun f₁ f₂ =>\n AddMonoidHom.ext fun g => (rightComp _ g).map_add f₁ f₂\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem sub_comp : (f - f') ≫ g = f ≫ g - f' ≫ g :=\n map_sub (rightComp P g) f f'\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem comp_sub : f ≫ (g - g') = f ≫ g - f ≫ g' :=\n map_sub (leftComp R f) g g'\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem neg_comp : (-f) ≫ g = -f ≫ g :=\n map_neg (rightComp P g) f\n\n-- simp can prove the reassoc version\n@[reassoc, simp]\ntheorem comp_neg : f ≫ (-g) = -f ≫ g :=\n map_neg (leftComp R f) g\n\n@[reassoc]\ntheorem neg_comp_neg : (-f) ≫ (-g) = f ≫ g := by simp\n\ntheorem nsmul_comp (n : ℕ) : (n • f) ≫ g = n • f ≫ g :=\n map_nsmul (rightComp P g) n f\n\ntheorem comp_nsmul (n : ℕ) : f ≫ (n • g) = n • f ≫ g :=\n map_nsmul (leftComp R f) n g\n\ntheorem zsmul_comp (n : ℤ) : (n • f) ≫ g = n • f ≫ g :=\n map_zsmul (rightComp P g) n f\n\ntheorem comp_zsmul (n : ℤ) : f ≫ (n • g) = n • f ≫ g :=\n map_zsmul (leftComp R f) n g\n\n@[reassoc]\ntheorem comp_sum {P Q R : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n (f ≫ ∑ j ∈ s, g j) = ∑ j ∈ s, f ≫ g j :=\n map_sum (leftComp R f) _ _\n\n@[reassoc]\ntheorem sum_comp {P Q R : C} {J : Type*} (s : Finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) :\n (∑ j ∈ s, f j) ≫ g = ∑ j ∈ s, f j ≫ g :=\n map_sum (rightComp P g) _ _\n\n@[reassoc]\ntheorem sum_comp' {P Q R S : C} {J : Type*} (s : Finset J) (f : J → (P ⟶ Q)) (g : J → (Q ⟶ R))\n (h : R ⟶ S) : (∑ j ∈ s, f j ≫ g j) ≫ h = ∑ j ∈ s, f j ≫ g j ≫ h := by\n simp only [← Category.assoc]\n apply sum_comp\n\ninstance {P Q : C} {f : P ⟶ Q} [Epi f] : Epi (-f) :=\n ⟨fun g g' H => by rwa [neg_comp, neg_comp, ← comp_neg, ← comp_neg, cancel_epi, neg_inj] at H⟩\n\ninstance {P Q : C} {f : P ⟶ Q} [Mono f] : Mono (-f) :=\n ⟨fun g g' H => by rwa [comp_neg, comp_neg, ← neg_comp, ← neg_comp, cancel_mono, neg_inj] at H⟩\n\ninstance (priority := 100) preadditiveHasZeroMorphisms : HasZeroMorphisms C where\n zero := inferInstance\n comp_zero f R := show leftComp R f 0 = 0 from map_zero _\n zero_comp P _ _ f := show rightComp P f 0 = 0 from map_zero _\n\n/-- This instance is split off from the `Ring (End X)` instance to speed up instance search. -/\ninstance {X : C} : Semiring (End X) :=\n { End.monoid with\n zero_mul := fun f => by dsimp [mul]; exact HasZeroMorphisms.comp_zero f _\n mul_zero := fun f => by dsimp [mul]; exact HasZeroMorphisms.zero_comp _ f\n left_distrib := fun f g h => Preadditive.add_comp X X X g h f\n right_distrib := fun f g h => Preadditive.comp_add X X X h f g }\n\ninstance {X : C} : Ring (End X) :=\n { (inferInstance : Semiring (End X)),\n (inferInstance : AddCommGroup (End X)) with\n neg_add_cancel := neg_add_cancel }\n\ninstance moduleEndRight {X Y : C} : Module (End Y) (X ⟶ Y) where\n smul_add _ _ _ := add_comp _ _ _ _ _ _\n smul_zero _ := zero_comp\n add_smul _ _ _ := comp_add _ _ _ _ _ _\n zero_smul _ := comp_zero\n\ntheorem mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :\n Mono f where\n right_cancellation := fun {Z} g₁ g₂ hg =>\n sub_eq_zero.1 <| h _ <| (map_sub (rightComp Z f) g₁ g₂).trans <| sub_eq_zero.2 hg\n\ntheorem mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :\n Mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n ⟨fun _ _ _ => zero_of_comp_mono _, mono_of_cancel_zero f⟩\n\ntheorem mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [HasLimit (parallelPair f 0)]\n (w : kernel.ι f = 0) : Mono f :=\n mono_of_cancel_zero f fun g h => by rw [← kernel.lift_ι f g h, w, Limits.comp_zero]\n\nlemma mono_of_isZero_kernel' {X Y : C} {f : X ⟶ Y} (c : KernelFork f) (hc : IsLimit c)\n (h : IsZero c.pt) : Mono f := mono_of_cancel_zero _ (fun g hg => by\n obtain ⟨a, ha⟩ := KernelFork.IsLimit.lift' hc _ hg\n rw [← ha, h.eq_of_tgt a 0, Limits.zero_comp])\n\nlemma mono_iff_isZero_kernel' {X Y : C} {f : X ⟶ Y} (c : KernelFork f) (hc : IsLimit c) :\n Mono f ↔ IsZero c.pt :=\n ⟨fun _ ↦ KernelFork.IsLimit.isZero_of_mono hc, mono_of_isZero_kernel' c hc⟩\n\nlemma mono_of_isZero_kernel {X Y : C} (f : X ⟶ Y) [HasKernel f] (h : IsZero (kernel f)) :\n Mono f :=\n mono_of_isZero_kernel' _ (kernelIsKernel _) h\n\nlemma mono_iff_isZero_kernel {X Y : C} (f : X ⟶ Y) [HasKernel f] :\n Mono f ↔ IsZero (kernel f) :=\n mono_iff_isZero_kernel' _ (limit.isLimit _)\n\ntheorem epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :\n Epi f :=\n ⟨fun {Z} g g' hg =>\n sub_eq_zero.1 <| h _ <| (map_sub (leftComp Z f) g g').trans <| sub_eq_zero.2 hg⟩\n\ntheorem epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :\n Epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n ⟨fun _ _ _ => zero_of_epi_comp _, epi_of_cancel_zero f⟩\n\ntheorem epi_of_cokernel_zero {X Y : C} {f : X ⟶ Y} [HasColimit (parallelPair f 0)]\n (w : cokernel.π f = 0) : Epi f :=\n epi_of_cancel_zero f fun g h => by rw [← cokernel.π_desc f g h, w, Limits.zero_comp]\n\nlemma epi_of_isZero_cokernel' {X Y : C} {f : X ⟶ Y} (c : CokernelCofork f) (hc : IsColimit c)\n (h : IsZero c.pt) : Epi f := epi_of_cancel_zero _ (fun g hg => by\n obtain ⟨a, ha⟩ := CokernelCofork.IsColimit.desc' hc _ hg\n rw [← ha, h.eq_of_src a 0, Limits.comp_zero])\n\nlemma epi_iff_isZero_cokernel' {X Y : C} {f : X ⟶ Y} (c : CokernelCofork f) (hc : IsColimit c) :\n Epi f ↔ IsZero c.pt :=\n ⟨fun _ ↦ CokernelCofork.IsColimit.isZero_of_epi hc, epi_of_isZero_cokernel' c hc⟩\n\nlemma epi_of_isZero_cokernel {X Y : C} (f : X ⟶ Y) [HasCokernel f] (h : IsZero (cokernel f)) :\n Epi f :=\n epi_of_isZero_cokernel' _ (cokernelIsCokernel _) h\n\nlemma epi_iff_isZero_cokernel {X Y : C} (f : X ⟶ Y) [HasCokernel f] :\n Epi f ↔ IsZero (cokernel f) :=\n epi_iff_isZero_cokernel' _ (colimit.isColimit _)\n\nnamespace IsIso\n\n@[simp]\n\nTarget:\ntheorem comp_left_eq_zero [IsIso f] : f ≫ g = 0 ↔ g = 0 :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Preadditive","family_id":"comp_left_eq_zero","file_id":"mathlib/Mathlib/CategoryTheory/Preadditive/Basic.lean","sample_id":"cd56beece6e3260785012905a7333440a52277cc36934bf7fb02c903e3482ee5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2f76c51c32719c58f7a246aeb323456f8c04db74bb33152ed213568652545d30","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"68b57d794a812e719ed6e45c34ad7de9fb39f4959cb25367bb9ee4b681d8aa20","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"013d95430e408261d11725749ed9aa9e9841193495abbf4b162833542e0a3f59","source_sha256":"b74e0d0a25eea38e205e7058febbec527fe2a67d460dce70d42dabde5febca9c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n dsimp [double]\n rw [if_neg h₀, if_neg h₁]\n exact Limits.isZero_zero C\n\n/-- The isomorphism `(double f hi₀₁).X i₀ ≅ X₀`. -/\nnoncomputable def doubleXIso₀ : (double f hi₀₁).X i₀ ≅ X₀ :=\n eqToIso (dif_pos rfl)\n\n/-- The isomorphism `(double f hi₀₁).X i₁ ≅ X₁`. -/\nnoncomputable def doubleXIso₁ (h : i₀ ≠ i₁) : (double f hi₀₁).X i₁ ≅ X₁ :=\n eqToIso (by\n dsimp [double]\n rw [if_neg h.symm, if_pos rfl])","hard_negative":true,"metrics":{"chosen_tokens":140,"rejected_tokens":2,"token_jaccard":0.025,"token_length_ratio":0.014286},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"57f67261463d45ba2a7df26f5df6db68cff4b611ac97142f5fa0bcea3592bd7f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.HasNoLoop\npublic import Mathlib.Algebra.Homology.Single\npublic import Mathlib.CategoryTheory.Yoneda\n\nNamespace:\nHomologicalComplex\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# A homological complex lying in two degrees\n\nGiven `c : ComplexShape ι`, distinct indices `i₀` and `i₁` such that `hi₀₁ : c.Rel i₀ i₁`,\nwe construct a homological complex `double f hi₀₁` for any morphism `f : X₀ ⟶ X₁`.\nIt consists of the objects `X₀` and `X₁` in degrees `i₀` and `i₁`, respectively,\nwith the differential `X₀ ⟶ X₁` given by `f`, and zero everywhere else.\n\n-/\n\n@[expose] public section\n\nopen CategoryTheory Category Limits ZeroObject Opposite\n\nnamespace HomologicalComplex\n\nvariable {C : Type*} [Category* C] [HasZeroMorphisms C] [HasZeroObject C]\n\nsection\n\nvariable {X₀ X₁ : C} (f : X₀ ⟶ X₁) {ι : Type*} {c : ComplexShape ι}\n {i₀ i₁ : ι} (hi₀₁ : c.Rel i₀ i₁)\n\nopen Classical in\n/-- Given a complex shape `c`, two indices `i₀` and `i₁` such that `c.Rel i₀ i₁`,\nand `f : X₀ ⟶ X₁`, this is the homological complex which, if `i₀ ≠ i₁`, only\nconsists of the map `f` in degrees `i₀` and `i₁`, and zero everywhere else. -/\nnoncomputable def double : HomologicalComplex C c where\n X k := if k = i₀ then X₀ else if k = i₁ then X₁ else 0\n d k k' :=\n if hk : k = i₀ ∧ k' = i₁ ∧ i₀ ≠ i₁ then\n eqToHom (if_pos hk.1) ≫ f ≫ eqToHom (by\n rw [if_neg, if_pos hk.2.1]\n aesop)\n else 0\n d_comp_d' := by\n rintro i j k hij hjk\n dsimp\n by_cases hi : i = i₀\n · subst hi\n by_cases hj : j = i₁\n · subst hj\n nth_rw 2 [dif_neg (by tauto)]\n rw [comp_zero]\n · rw [dif_neg (by tauto), zero_comp]\n · rw [dif_neg (by tauto), zero_comp]\n shape i j hij := dif_neg (by aesop)\n\nTarget:\nlemma isZero_double_X (k : ι) (h₀ : k ≠ i₀) (h₁ : k ≠ i₁) :\n IsZero ((double f hi₀₁).X k) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_013d95430e40","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"5817bebd84cbb4d48671df892ad02865d6beefafa7c5c19650354bb26fb0d828","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Homology","family_id":"iszero_double_x","file_id":"mathlib/Mathlib/Algebra/Homology/Double.lean","sample_id":"013d95430e408261d11725749ed9aa9e9841193495abbf4b162833542e0a3f59"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8a84c81913dd9ed876efa9df2ecaec5ab37a508ba6133e7e130e79a418fc0c5c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"333195ce4a4964559d747a2db00ae4e4744155206df3c15c00afa3023ea766d8","source_sha256":"1ea87511faa4a09576c2d6c82d012e31d7cfe664d9616e16ba1fd01753abb77e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases mk_surjective m with ⟨x, rfl⟩\n induction x using FreeMonoid.inductionOn' with\n | one => exact one\n | mul_of x xs ih =>\n cases x with\n | inl m => simpa using inl_mul m _ ih\n | inr n => simpa using inr_mul n _ ih","hard_negative":false,"metrics":{"chosen_tokens":51,"rejected_tokens":2,"token_jaccard":0.032258,"token_length_ratio":0.039216},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"5892ab9abbab4d301326fbc24158db7fcfbc74228ebfb85041ffdefd9a7acf20","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.PUnit\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.Algebra.Group.Submonoid.Membership\npublic import Mathlib.GroupTheory.Congruence.Basic\n\nNamespace:\nMonoid.Coprod\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Coproduct (free product) of two monoids or groups\n\nIn this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)\nto be the coproduct (a.k.a. free product) of two monoids.\nThe same type is used for the coproduct of two monoids and for the coproduct of two groups.\n\nThe coproduct `M ∗ N` has the following universal property:\nfor any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,\nthere exists a unique homomorphism `fg : M ∗ N →* P`\nsuch that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,\nwhere `Monoid.Coprod.inl : M →* M ∗ N`\nand `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.\nThis homomorphism `fg` is given by `Monoid.Coprod.lift f g`.\n\nWe also define some homomorphisms and isomorphisms about `M ∗ N`,\nand provide additive versions of all definitions and theorems.\n\n## Main definitions\n\n### Types\n\n* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):\n the free product (a.k.a. coproduct) of two monoids `M` and `N`.\n* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.\n\nIn other sections, we only list multiplicative definitions.\n\n### Instances\n\n* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.\n\n### Monoid homomorphisms\n\n* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.\n\n* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.\n\n* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`\n from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.\n\n* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`\n that allows the user to control the computational behavior.\n\n* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`\n into `M ∗ M' →* N ∗ N'`.\n\n* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.\n\n* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:\n natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.\n\n### Monoid isomorphisms\n\n* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.\n* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.\n* `MulEquiv.coprodAssoc`: associativity of the coproduct.\n* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:\n free product by `PUnit` on the left or on the right is isomorphic to the original monoid.\n\n## Main results\n\nThe universal property of the coproduct\nis given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.\n\nWe also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`\nfor homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.\n\n## Implementation details\n\nThe definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.\nWhile mathematically `M ∗ N` is a particular case\nof the coproduct of an indexed family of monoids,\nit is easier to build API from scratch instead of using something like\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI ![M, N]\n```\n\nor\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)\n```\n\nThere are several reasons to build an API from scratch.\n\n- API about `Con` makes it easy to define the required type and prove the universal property,\n so there is little overhead compared to transferring API from `Monoid.CoprodI`.\n- If `M` and `N` live in different universes, then the definition has to add `ULift`s;\n this makes it harder to transfer API and definitions.\n- As of now, we have no way\n to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`\n from `[Monoid M]` and `[Monoid N]`,\n not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.\n- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`\n as the underlying type makes it possible to write computationally effective code\n (though this point is not tested yet).\n\n## TODO\n\n- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and\n `Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.\n\n## Tags\n\ngroup, monoid, coproduct, free product\n-/\n\n@[expose] public section\n\nassert_not_exists MonoidWithZero\n\nopen FreeMonoid Function List Set\n\nnamespace Monoid\n\n/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`\nsuch that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms\nto the quotient by `c`. -/\n@[to_additive /-- The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`\nsuch that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`\nare additive monoid homomorphisms to the quotient by `c`. -/]\ndef coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=\n sInf {c |\n (∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))\n ∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))\n ∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}\n\n/-- Coproduct of two monoids or groups. -/\n@[to_additive /-- Coproduct of two additive monoids or groups. -/]\ndef Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient\n\nnamespace Coprod\n\n@[inherit_doc]\nscoped infix:30 \" ∗ \" => Coprod\n\nsection MulOneClass\n\nvariable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']\n [MulOneClass P]\n\n@[to_additive] protected instance : MulOneClass (M ∗ N) :=\n inferInstanceAs <| MulOneClass (coprodCon M N).Quotient\n\n/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/\n@[to_additive /-- The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`. -/]\ndef mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _\n\n@[to_additive (attr := simp)]\ntheorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _\n\n@[to_additive]\ntheorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective\n\n@[to_additive (attr := simp)]\ntheorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'\n\n@[to_additive]\ntheorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _\n\n/-- The natural embedding `M →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `M →+ AddMonoid.Coprod M N`. -/]\ndef inl : M →* M ∗ N where\n toFun := fun x => mk (of (.inl x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y\n\n/-- The natural embedding `N →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `N →+ AddMonoid.Coprod M N`. -/]\ndef inr : N →* M ∗ N where\n toFun := fun x => mk (of (.inr x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl\n\n@[to_additive (attr := elab_as_elim)]\n\nTarget:\ntheorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)\n (one : C 1)\n (inl_mul : ∀ m x, C x → C (inl m * x))\n (inr_mul : ∀ n x, C x → C (inr n * x)) : C m :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory/Coprod","family_id":"induction_on","file_id":"mathlib/Mathlib/GroupTheory/Coprod/Basic.lean","sample_id":"333195ce4a4964559d747a2db00ae4e4744155206df3c15c00afa3023ea766d8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"22b3bc3a5f291ce1fc7ad01b37d4a5bbe57149530b2b1efd68e2dda3f7a4f1aa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fa7956a938b3e9ccf3af472830b0d6f643c5ff232a9c89809446c9cbc30628fb","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"34dcfd7baa45b79cf991eca05297781722f8401ae7acfec487c1013229df17c7","source_sha256":"256cf4f88d33f6a5c2ae62a506182b48c7c21aa38bae757b66e9c4f9c05af2eb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← Presieve.ofArrows_pUnit.{_, _, 0}, ofArrows_mem_precoverage_iff]\n aesop","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":3,"token_jaccard":0.058824,"token_length_ratio":0.157895},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"59346c9aacebe7b7eb8b47f3754542999d087e4bb15b9e038d105491d10d41b5","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.OpenImmersion\npublic import Mathlib.CategoryTheory.MorphismProperty.Limits\npublic import Mathlib.CategoryTheory.Sites.JointlySurjective\npublic import Mathlib.CategoryTheory.Sites.MorphismProperty\n\nNamespace:\nAlgebraicGeometry.Scheme\n\nLocal context:\n/-\nCopyright (c) 2024 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten, Joël Riou, Adam Topaz\n-/\n/-!\n\n# Site defined by a morphism property\n\nGiven a multiplicative morphism property `P` that is stable under base change, we define the\nassociated precoverage on the category of schemes, where coverings are given\nby jointly surjective families of morphisms satisfying `P`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nopen CategoryTheory MorphismProperty Limits\n\nnamespace AlgebraicGeometry\n\nnamespace Scheme\n\n/-- A morphism property of schemes is said to preserve joint surjectivity, if\nfor any pair of morphisms `f : X ⟶ S` and `g : Y ⟶ S` where `g` satisfies `P`,\nany pair of points `x : X` and `y : Y` with `f x = g y` can be lifted to a point\nof `X ×[S] Y`.\n\nIn later files, this will be automatic, since this holds for any morphism `g`\n(see `AlgebraicGeometry.Scheme.isJointlySurjectivePreserving`). But at\nthis early stage in the import tree, we only know it for open immersions. -/\nclass IsJointlySurjectivePreserving (P : MorphismProperty Scheme.{u}) where\n exists_preimage_fst_triplet_of_prop {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]\n (hg : P g) (x : X) (y : Y) (h : f x = g y) :\n ∃ a : ↑(pullback f g), pullback.fst f g a = x\n\nvariable {P : MorphismProperty Scheme.{u}}\n\nlemma IsJointlySurjectivePreserving.exists_preimage_snd_triplet_of_prop\n [IsJointlySurjectivePreserving P] {X Y S : Scheme.{u}} {f : X ⟶ S} {g : Y ⟶ S} [HasPullback f g]\n (hf : P f) (x : X) (y : Y) (h : f x = g y) :\n ∃ a : ↑(pullback f g), pullback.snd f g a = y := by\n let iso := pullbackSymmetry f g\n haveI : HasPullback g f := hasPullback_symmetry f g\n obtain ⟨a, ha⟩ := exists_preimage_fst_triplet_of_prop hf y x h.symm\n use (pullbackSymmetry f g).inv a\n rwa [← Scheme.Hom.comp_apply, pullbackSymmetry_inv_comp_snd]\n\ninstance : IsJointlySurjectivePreserving @IsOpenImmersion where\n exists_preimage_fst_triplet_of_prop {X Y S f g} _ hg x y h := by\n rw [← show _ = (pullback.fst _ _ : pullback f g ⟶ _).base from\n PreservesPullback.iso_hom_fst Scheme.forgetToTop f g]\n have : x ∈ Set.range (pullback.fst f.base g.base) := by\n rw [TopCat.pullback_fst_range f.base g.base]\n use y\n obtain ⟨a, ha⟩ := this\n use (PreservesPullback.iso Scheme.forgetToTop f g).inv a\n rwa [← TopCat.comp_app, Iso.inv_hom_id_assoc]\n\n/-- The precoverage on `Scheme` of jointly surjective families. -/\nabbrev jointlySurjectivePrecoverage : Precoverage Scheme.{u} :=\n Types.jointlySurjectivePrecoverage.comap Scheme.forget\n\nvariable (P : MorphismProperty Scheme.{u})\n\n/-- The precoverage on `Scheme` induced by `P` is given by jointly surjective families of\n`P`-morphisms. -/\ndef precoverage : Precoverage Scheme.{u} :=\n jointlySurjectivePrecoverage ⊓ P.precoverage\n\n@[simp]\nlemma ofArrows_mem_precoverage_iff {S : Scheme.{u}} {ι : Type*} {X : ι → Scheme.{u}}\n {f : ∀ i, X i ⟶ S} :\n .ofArrows X f ∈ precoverage P S ↔ (∀ x, ∃ i, x ∈ Set.range (f i)) ∧ ∀ i, P (f i) := by\n simp_rw [← Scheme.forget_map', ← Scheme.forget_obj,\n ← Presieve.ofArrows_mem_comap_jointlySurjectivePrecoverage_iff]\n exact ⟨fun hmem ↦ ⟨hmem.1, fun i ↦ hmem.2 ⟨i⟩⟩, fun h ↦ ⟨h.1, fun {Y} g ⟨i⟩ ↦ h.2 i⟩⟩\n\n@[simp]\n\nTarget:\nlemma singleton_mem_precoverage_iff {X S : Scheme.{u}} (f : X ⟶ S) :\n Presieve.singleton f ∈ precoverage P S ↔ Function.Surjective f.base ∧ P f :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_34dcfd7baa45","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"8a7a278f0c4efea3623f5215fa9c57dab51e3f25ca35595991d3e547990ac03d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Sites","family_id":"singleton_mem_precoverage_iff","file_id":"mathlib/Mathlib/AlgebraicGeometry/Sites/MorphismProperty.lean","sample_id":"34dcfd7baa45b79cf991eca05297781722f8401ae7acfec487c1013229df17c7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"29cbf6536cd871792336e3f798e7da0fa885f82547b3fd12dd9e1aa846d6c449","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"82255e2f34c8bd869145c6aef2277f38ae065d62ce5efa8852e09b8aec94c904","source_sha256":"da26ee3ca6f797a2045e4655669aba812359acecd55f37e00aa473ba109b6040","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n suffices decodeSum n = none by\n change (decodeSum n).bind _ = none\n rw [this]\n rfl\n have : 1 ≤ n / 2 := by\n rw [Nat.le_div_iff_mul_le]\n exacts [h, by decide]\n obtain ⟨m, e⟩ := exists_eq_succ_of_ne_zero (_root_.ne_of_gt this)\n simp only [decodeSum, div2_val]; cases bodd n <;> simp [e]\n\nnoncomputable instance _root_.Prop.encodable : Encodable Prop :=\n ofEquiv Bool Equiv.propEquivBool","hard_negative":true,"metrics":{"chosen_tokens":92,"rejected_tokens":8,"token_jaccard":0.068966,"token_length_ratio":0.086957},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"5acc37c054817e90186426379b31d9ad15b66463d38a571cc483b3a3ee1c2aae","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Countable.Defs\npublic import Mathlib.Data.Fin.Basic\npublic import Mathlib.Data.Nat.Find\npublic import Mathlib.Data.PNat.Equiv\npublic import Mathlib.Logic.Equiv.Nat\npublic import Mathlib.Order.Directed\npublic import Mathlib.Order.RelIso.Basic\n\nNamespace:\nEncodable\n\nLocal context:\n/-\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/-!\n# Encodable types\n\nThis file defines encodable (constructively countable) types as a typeclass.\nThis is used to provide explicit encode/decode functions from and to `ℕ`, with the information that\nthose functions are inverses of each other.\nThe difference with `Denumerable` is that finite types are encodable. For infinite types,\n`Encodable` and `Denumerable` agree.\n\n## Main declarations\n\n* `Encodable α`: States that there exists an explicit encoding function `encode : α → ℕ` with a\n partial inverse `decode : ℕ → Option α`.\n* `decode₂`: Version of `decode` that is equal to `none` outside of the range of `encode`. Useful as\n we do not require this in the definition of `decode`.\n* `ULower α`: Any encodable type has an equivalent type living in the lowest universe, namely a\n subtype of `ℕ`. `ULower α` finds it.\n\n## Implementation notes\n\nThe point of asking for an explicit partial inverse `decode : ℕ → Option α` to `encode : α → ℕ` is\nto make the range of `encode` decidable even when the finiteness of `α` is not.\n-/\n\n@[expose] public section\n\nassert_not_exists Monoid\n\n-- We want the theorems in this file to be constructive.\nset_option linter.unusedDecidableInType false\n\nopen Option List Nat Function\n\n/-- Constructively countable type. Made from an explicit injection `encode : α → ℕ` and a partial\ninverse `decode : ℕ → Option α`. Note that finite types *are* countable. See `Denumerable` if you\nwish to enforce infiniteness. -/\nclass Encodable (α : Type*) where\n /-- Encoding from Type α to ℕ -/\n encode : α → ℕ\n /-- Decoding from ℕ to Option α -/\n decode : ℕ → Option α\n /-- Invariant relationship between encoding and decoding -/\n encodek : ∀ a, decode (encode a) = some a\n\nattribute [simp] Encodable.encodek\n\nnamespace Encodable\n\nvariable {α : Type*} {β : Type*}\n\nuniverse u\n\ntheorem encode_injective [Encodable α] : Function.Injective (@encode α _)\n | x, y, e => Option.some.inj <| by rw [← encodek, e, encodek]\n\n@[simp]\ntheorem encode_inj [Encodable α] {a b : α} : encode a = encode b ↔ a = b :=\n encode_injective.eq_iff\n\n-- The priority of the instance below is less than the priorities of `Subtype.Countable`\n-- and `Quotient.Countable`\ninstance (priority := 400) countable [Encodable α] : Countable α where\n exists_injective_nat' := ⟨_,encode_injective⟩\n\ntheorem surjective_decode_getD (α : Type*) [Encodable α] (d : α) :\n Surjective fun n => (Encodable.decode n).getD d := fun x =>\n ⟨Encodable.encode x, by simp_rw [Encodable.encodek]; rfl⟩\n\n@[deprecated surjective_decode_getD (since := \"2026-01-05\")]\ntheorem surjective_decode_iget (α : Type*) [Encodable α] [Inhabited α] :\n Surjective fun n => ((Encodable.decode n).getD default : α) :=\n surjective_decode_getD α default\n\n/-- An encodable type has decidable equality. Not set as an instance because this is usually not the\nbest way to infer decidability. -/\n@[instance_reducible]\ndef decidableEqOfEncodable (α) [Encodable α] : DecidableEq α\n | _, _ => decidable_of_iff _ encode_inj\n\n/-- If `α` is encodable and there is an injection `f : β → α`, then `β` is encodable as well. -/\n@[implicit_reducible]\ndef ofLeftInjection [Encodable α] (f : β → α) (finv : α → Option β)\n (linv : ∀ b, finv (f b) = some b) : Encodable β :=\n ⟨fun b => encode (f b), fun n => (decode n).bind finv, fun b => by\n simp [Encodable.encodek, linv]⟩\n\n/-- If `α` is encodable and `f : β → α` is invertible, then `β` is encodable as well. -/\n@[implicit_reducible]\ndef ofLeftInverse [Encodable α] (f : β → α) (finv : α → β) (linv : ∀ b, finv (f b) = b) :\n Encodable β :=\n ofLeftInjection f (some ∘ finv) fun b => congr_arg some (linv b)\n\n/-- Encodability is preserved by equivalence. -/\n@[implicit_reducible]\ndef ofEquiv (α) [Encodable α] (e : β ≃ α) : Encodable β :=\n ofLeftInverse e e.symm e.left_inv\n\ntheorem encode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (b : β) :\n @encode _ (ofEquiv _ e) b = encode (e b) :=\n rfl\n\ntheorem decode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (n : ℕ) :\n @decode _ (ofEquiv _ e) n = (decode n).map e.symm :=\n show Option.bind _ _ = Option.map _ _\n by rw [Option.map_eq_bind]\n\ninstance _root_.Nat.encodable : Encodable ℕ :=\n ⟨id, some, fun _ => rfl⟩\n\n@[simp]\ntheorem encode_nat (n : ℕ) : encode n = n :=\n rfl\n\n@[simp 1100]\ntheorem decode_nat (n : ℕ) : decode n = some n :=\n rfl\n\ninstance (priority := 100) _root_.IsEmpty.toEncodable [IsEmpty α] : Encodable α :=\n ⟨isEmptyElim, fun _ => none, isEmptyElim⟩\n\ninstance _root_.PUnit.encodable : Encodable PUnit :=\n ⟨fun _ => 0, fun n => Nat.casesOn n (some PUnit.unit) fun _ => none, fun _ => by simp⟩\n\n@[simp]\ntheorem encode_star : encode PUnit.unit = 0 :=\n rfl\n\n@[simp]\ntheorem decode_unit_zero : decode 0 = some PUnit.unit :=\n rfl\n\n@[simp]\ntheorem decode_unit_succ (n) : decode (succ n) = (none : Option PUnit) :=\n rfl\n\n/-- If `α` is encodable, then so is `Option α`. -/\ninstance _root_.Option.encodable {α : Type*} [h : Encodable α] : Encodable (Option α) :=\n ⟨fun o => Option.casesOn o Nat.zero fun a => succ (encode a), fun n =>\n Nat.casesOn n (some none) fun m => (decode m).map some, fun o => by\n cases o <;> simp [encodek]⟩\n\n@[simp]\ntheorem encode_none [Encodable α] : encode (@none α) = 0 :=\n rfl\n\n@[simp]\ntheorem encode_some [Encodable α] (a : α) : encode (some a) = succ (encode a) :=\n rfl\n\n@[simp]\ntheorem decode_option_zero [Encodable α] : (decode 0 : Option (Option α)) = some none :=\n rfl\n\n@[simp]\ntheorem decode_option_succ [Encodable α] (n) :\n (decode (succ n) : Option (Option α)) = (decode n).map some :=\n rfl\n\n/-- Failsafe variant of `decode`. `decode₂ α n` returns the preimage of `n` under `encode` if it\nexists, and returns `none` if it doesn't. This requirement could be imposed directly on `decode` but\nis not to help make the definition easier to use. -/\ndef decode₂ (α) [Encodable α] (n : ℕ) : Option α :=\n (decode n).bind (Option.guard fun a => encode a = n)\n\ntheorem mem_decode₂' [Encodable α] {n : ℕ} {a : α} :\n a ∈ decode₂ α n ↔ a ∈ decode n ∧ encode a = n := by\n simp [decode₂, Option.bind_eq_some_iff]\n\ntheorem mem_decode₂ [Encodable α] {n : ℕ} {a : α} : a ∈ decode₂ α n ↔ encode a = n :=\n mem_decode₂'.trans (and_iff_right_of_imp fun e => e ▸ encodek _)\n\ntheorem decode₂_eq_some [Encodable α] {n : ℕ} {a : α} : decode₂ α n = some a ↔ encode a = n :=\n mem_decode₂\n\n@[simp]\ntheorem decode₂_encode [Encodable α] (a : α) : decode₂ α (encode a) = some a := by\n simp [decode₂_eq_some]\n\ntheorem decode₂_ne_none_iff [Encodable α] {n : ℕ} :\n decode₂ α n ≠ none ↔ n ∈ Set.range (encode : α → ℕ) := by\n simp_rw [Set.range, Set.mem_setOf_eq, Ne, Option.eq_none_iff_forall_not_mem,\n Encodable.mem_decode₂, not_forall, not_not]\n\ntheorem decode₂_isPartialInv [Encodable α] : IsPartialInv encode (decode₂ α) := fun _ _ =>\n mem_decode₂\n\n@[deprecated (since := \"2026-03-11\")] alias decode₂_is_partial_inv := decode₂_isPartialInv\n\ntheorem decode₂_inj [Encodable α] {n : ℕ} {a₁ a₂ : α} (h₁ : a₁ ∈ decode₂ α n)\n (h₂ : a₂ ∈ decode₂ α n) : a₁ = a₂ :=\n encode_injective <| (mem_decode₂.1 h₁).trans (mem_decode₂.1 h₂).symm\n\ntheorem encodek₂ [Encodable α] (a : α) : decode₂ α (encode a) = some a :=\n mem_decode₂.2 rfl\n\n/-- The encoding function has decidable range. -/\n@[instance_reducible]\ndef decidableRangeEncode (α : Type*) [Encodable α] : DecidablePred (· ∈ Set.range (@encode α _)) :=\n fun x =>\n decidable_of_iff (Option.isSome (decode₂ α x))\n ⟨fun h => ⟨Option.get _ h, by rw [← decode₂_isPartialInv (Option.get _ h), Option.some_get]⟩,\n fun ⟨n, hn⟩ => by rw [← hn, encodek₂]; exact rfl⟩\n\n/-- An encodable type is equivalent to the range of its encoding function. -/\ndef equivRangeEncode (α : Type*) [Encodable α] : α ≃ Set.range (@encode α _) where\n toFun a := ⟨encode a, Set.mem_range_self _⟩\n invFun n :=\n Option.get _\n (show isSome (decode₂ α n.1) by obtain ⟨x, hx⟩ := n.2; rw [← hx, encodek₂]; exact rfl)\n left_inv _ := by dsimp; rw [← Option.some_inj, Option.some_get, encodek₂]\n right_inv _ := Subtype.ext <| decode₂_isPartialInv.get_eq _ _\n\n/-- A type with unique element is encodable. This is not an instance to avoid diamonds. -/\n@[implicit_reducible]\ndef _root_.Unique.encodable [Unique α] : Encodable α :=\n ⟨fun _ => 0, fun _ => some default, Unique.forall_iff.2 rfl⟩\n\nsection Sum\n\nvariable [Encodable α] [Encodable β]\n\n/-- Explicit encoding function for the sum of two encodable types. -/\ndef encodeSum : α ⊕ β → ℕ\n | Sum.inl a => 2 * encode a\n | Sum.inr b => 2 * encode b + 1\n\n/-- Explicit decoding function for the sum of two encodable types. -/\ndef decodeSum (n : ℕ) : Option (α ⊕ β) :=\n match bodd n, div2 n with\n | false, m => (decode m : Option α).map Sum.inl\n | _, m => (decode m : Option β).map Sum.inr\n\n/-- If `α` and `β` are encodable, then so is their sum. -/\ninstance _root_.Sum.encodable : Encodable (α ⊕ β) :=\n ⟨encodeSum, decodeSum, fun s => by cases s <;> simp [encodeSum, div2_val, decodeSum, encodek]⟩\n\n@[simp]\ntheorem encode_inl (a : α) : @encode (α ⊕ β) _ (Sum.inl a) = 2 * (encode a) :=\n rfl\n\n@[simp]\ntheorem encode_inr (b : β) : @encode (α ⊕ β) _ (Sum.inr b) = 2 * (encode b) + 1 :=\n rfl\n\n@[simp]\ntheorem decode_sum_val (n : ℕ) : (decode n : Option (α ⊕ β)) = decodeSum n :=\n rfl\n\nend Sum\n\ninstance _root_.Bool.encodable : Encodable Bool :=\n ofEquiv (Unit ⊕ Unit) Equiv.boolEquivPUnitSumPUnit\n\n@[simp]\ntheorem encode_true : encode true = 1 :=\n rfl\n\n@[simp]\ntheorem encode_false : encode false = 0 :=\n rfl\n\n@[simp]\ntheorem decode_zero : (decode 0 : Option Bool) = some false :=\n rfl\n\n@[simp]\ntheorem decode_one : (decode 1 : Option Bool) = some true :=\n rfl\n\nTarget:\ntheorem decode_ge_two (n) (h : 2 ≤ n) : (decode n : Option Bool) = none :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"d8ee3611d7e9f3c24bd2e4aadc8bcc1197e7b9ab278543debff932d4a1f35f6a","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Encodable","family_id":"decode_ge_two","file_id":"mathlib/Mathlib/Logic/Encodable/Basic.lean","sample_id":"82255e2f34c8bd869145c6aef2277f38ae065d62ce5efa8852e09b8aec94c904"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d835b98c41d2ea2cf7885bf49be82e2844c91e6d84f2c7ed7bfe87e6530b1fe1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ccf67f8fde38de25066c7db4307fe1192696bb4784ab9db48a15c07e9bf132a1","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4bb4374eba1b571bf2e8fbbef04861793160f8d0fe4c97086c83d35e9439a582","source_sha256":"991a8724fd4dbc8b903c21c214ce00ffc92ff1fb34fc1f773e7d34149514f251","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨a, rfl⟩ := h\n simp","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":15,"token_jaccard":0.666667,"token_length_ratio":1.5},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"5b0cc8acc7db448289fdbeb55840ef0ec3553d6316b467bf8aeea347a527442c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.KrullDimension.NonZeroDivisors\npublic import Mathlib.RingTheory.Length\npublic import Mathlib.RingTheory.HopkinsLevitzki\npublic import Mathlib.Algebra.Ring.Hom.InjSurj\npublic import Mathlib.RingTheory.Ideal.Quotient.Noetherian\n\nNamespace:\nRing\n\nLocal context:\n/-\nCopyright (c) 2025 Raphael Douglas Giles. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Raphael Douglas Giles\n-/\n/-!\n# Order of vanishing\n\nThis file defines the order of vanishing of an element of a ring as the length of the quotient of\nthe ring by the ideal generated by that element. We also define the extension of this notion to the\nfield of fractions\n-/\n\n@[expose] public section\n\nopen LinearMap Pointwise IsLocalization Ideal WithZero\n\nvariable {R : Type*} {M : Type*} [AddCommMonoid M]\n\nnamespace Ring\n\nvariable (R) [Ring R]\n/--\nOrder of vanishing function for elements of a ring.\n-/\n@[stacks 02MD]\nnoncomputable\ndef ord (x : R) : ℕ∞ := Module.length R (R ⧸ Ideal.span {x})\n\n@[simp]\nlemma ord_one : ord R 1 = 0 := by\n simp_all [ord,\n Ideal.span_singleton_one, Submodule.Quotient.subsingleton_iff]\n\nend Ring\n\nvariable [CommRing R] [Module R M]\n\n/--\nThe map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a`\n-/\ndef Ideal.mulQuot (a : R) (I : Ideal R) :\n R ⧸ I →ₗ[R] R ⧸ (a • I) :=\n Submodule.mapQ _ _ (LinearMap.mul R R a) (Submodule.le_comap_map _ _)\n\n/--\nThe map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a` is injective if `a` is\na nonzero divisor.\n-/\nlemma Ideal.mulQuot_injective {a : R} (I : Ideal R) (ha : a ∈ nonZeroDivisors R) :\n Function.Injective (Ideal.mulQuot a I) := by\n simp only [mulQuot, Submodule.mapQ, ← ker_eq_bot]\n apply Submodule.ker_liftQ_eq_bot'\n apply le_antisymm\n · have : Submodule.map (mul R R a) I = a • I := rfl\n rw [le_ker_iff_map, Submodule.map_comp, this, Submodule.mkQ_map_self]\n · have m : I = Submodule.comap (mul R R a) (a • I) := by\n ext b\n exact (Submodule.mul_mem_smul_iff ha).symm\n simp [← m, ker_comp]\n\n/--\nThe quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})`.\n-/\ndef Ideal.quotOfMul (a : R) (I : Ideal R) :\n (R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a}) :=\n Submodule.factor <| Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I\n\n/--\nThe quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})` is surjective.\n-/\nlemma Ideal.quotOfMul_surjective {a : R} (I : Ideal R) :\n Function.Surjective (Ideal.quotOfMul a I) := by\n simp only [Ideal.quotOfMul]\n exact Submodule.factor_surjective <|\n Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I\n\n/--\nThe sequence `R ⧸ I →ₗ[R] R ⧸ (a • I) →ₗ[R] R ⧸ (Ideal.span {a})` given by multiplication\nby `a` then quotienting by the ideal generated by `a` is exact.\n-/\nlemma Ideal.exact_mulQuot_quotOfMul {a : R} (I : Ideal R) :\n Function.Exact (Ideal.mulQuot a I) (Ideal.quotOfMul a I) := by\n simp only [exact_iff]\n have : ker (Ideal.quotOfMul a I) = a • ⊤ := by\n simp only [← submodule_span_eq, quotOfMul, Submodule.factor, Submodule.mapQ, comp_id,\n Submodule.ker_liftQ, Submodule.ker_mkQ, Submodule.map_span, Submodule.mkQ_apply,\n Quotient.mk_eq_mk, Set.image_singleton, Quotient.smul_top]\n simp [this, Ideal.mulQuot, Submodule.mapQ.eq_1, Submodule.range_liftQ,\n range_comp, Ideal.Quotient.smul_top, ← Ideal.submodule_span_eq, LinearMap.map_span]\n\nnamespace Ring\nvariable (R)\n/--\nThe order of vanishing of `a * b` is the order of vanishing of `a` plus the order\nof vanishing of `b`.\n-/\ntheorem ord_mul {a b : R} (hb : b ∈ nonZeroDivisors R) :\n ord R (a * b) = ord R a + ord R b := by\n have := Module.length_eq_add_of_exact (Ideal.mulQuot b (Ideal.span {a}))\n (Ideal.quotOfMul b (Ideal.span {a})) (Ideal.mulQuot_injective (Ideal.span {a}) hb)\n (Ideal.quotOfMul_surjective (Ideal.span {a}))\n (Ideal.exact_mulQuot_quotOfMul (Ideal.span {a}))\n simp only [Ring.ord, ← this]\n have lem : (({b} : Set R) • Ideal.span {a}) = Ideal.span {b * a} := by\n simp [← Ideal.submodule_span_eq, Submodule.set_smul_span]\n have : (({b} : Set R) • Ideal.span {a}) = b • Ideal.span {a} := Submodule.singleton_set_smul\n (Ideal.span {a}) b\n rw [this] at lem\n rw [lem, mul_comm]\n\n/--\nVariation of `ord_mul` where the user has to show the first input is a non\nzero divisor rather than the second.\n-/\nlemma ord_mul' {a b : R} (ha : a ∈ nonZeroDivisors R) :\n ord R (a * b) = ord R a + ord R b := by\n rw [mul_comm, ord_mul R ha, add_comm]\n\n/--\nThe order of zero is `Module.length R R`. Use this when it is necessary to unfold the definition\nof `ord` to avoid annoyances of working with `R ⧸ Ideal.span {0}` instead of `R`.\n-/\nlemma ord_zero : ord R 0 = Module.length R R := by\n simp only [ord]\n let m := (Submodule.quotEquivOfEqBot (Ideal.span {0} : Submodule R R) (span_singleton_zero))\n exact le_antisymm (Module.length_le_of_injective m m.injective)\n (Module.length_le_of_surjective m m.surjective)\n\nvariable {R}\n/--\nFor `x : R` a non zero divisor, `ord R (x ^ n) = n • ord R x`.\n-/\n@[simp]\ntheorem ord_pow {x : R} (hx : x ∈ nonZeroDivisors R) (n : ℕ) : ord R (x ^ n) = n • ord R x := by\n induction n with\n | zero => simp\n | succ n ih =>\n rw [pow_succ, ord_mul, ih, succ_nsmul]\n exact hx\n\n@[simp]\nlemma ord_mul_of_isUnit_left {a : R} (h : IsUnit a) (x : R) : ord R (a * x) = ord R x := by\n rw [ord, ord, Ideal.span_singleton_mul_left_unit h x]\n\n@[simp]\nlemma ord_mul_of_isUnit_right {a : R} (h : IsUnit a) (x : R) : ord R (x * a) = ord R x := by\n rw [ord, ord, Ideal.span_singleton_mul_right_unit h x]\n\nTarget:\nlemma ord_eq_of_associated {x y : R} (h : Associated x y) : ord R x = ord R y :=\n\nProof body:\n","rejected":"by\n obtain ⟨a, rfl⟩ := h\n simp\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/OrderOfVanishing","family_id":"ord_eq_of_associated","file_id":"mathlib/Mathlib/RingTheory/OrderOfVanishing/Basic.lean","sample_id":"4bb4374eba1b571bf2e8fbbef04861793160f8d0fe4c97086c83d35e9439a582"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4fc177b6d5b081353da1b81f66c18abbb24bb5d7456c41e3694dbd485ce5afbb","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cfbd3621442d441f43bde0c1fea523f1801da257a98e4e648ca796e216d45485","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f62415822810b2b44b8d599ff65f8714ae872abc95184812b190d9e64e8ee70c","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]","hard_negative":true,"metrics":{"chosen_tokens":20,"rejected_tokens":3,"token_jaccard":0.055556,"token_length_ratio":0.15},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"5d0871a9d24236c1f9cb9da731ffc995c7ef7325b2c2995c506d985dc62f9e35","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nTarget:\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_f62415822810","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"defbb7989470cbd7bc320693f3176f81fb24b472caeb18e30bceb641c5310638","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"restrictscalars_mul","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"f62415822810b2b44b8d599ff65f8714ae872abc95184812b190d9e64e8ee70c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dc1bca91413146246510c9f2bcf86578204390b2f28c1c915349bb5070439d6f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ae56e6dd296ca18f7fc53d500ab1f37eaed14230bbf8964e05b1016617a6ce1e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dd5dda343143c8547708c93efe6437d75765097ec9bba5770558209c4666433d","source_sha256":"3da6bfff8077a4de2d75547c2533816fed03dfd5c1acc867b6989c25e9e68a21","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [e.symm.image_eq_preimage_symm]; rfl","hard_negative":true,"metrics":{"chosen_tokens":11,"rejected_tokens":5,"token_jaccard":0.153846,"token_length_ratio":0.454545},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"5d3ab0c5ad64caf6e1829b32f167f12ac2be146ac1dc08fff16324e0b5386de9","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Directed\npublic import Mathlib.Order.RelIso.Basic\npublic import Mathlib.Logic.Embedding.Set\npublic import Mathlib.Logic.Equiv.Set\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Interactions between relation homomorphisms and sets\n\nIt is likely that there are better homes for many of these statement,\nin files further down the import graph.\n-/\n\n@[expose] public section\n\n\nopen Function\n\nuniverse u v w\n\nvariable {α β : Type*} {r : α → α → Prop} {s : β → β → Prop}\n\nnamespace RelHomClass\n\nvariable {F : Type*}\n\ntheorem map_inf [SemilatticeInf α] [LinearOrder β] [FunLike F β α]\n [RelHomClass F (· < ·) (· < ·)] (a : F) (m n : β) :\n a (m ⊓ n) = a m ⊓ a n :=\n (StrictMono.monotone fun _ _ => map_rel a).map_inf m n\n\ntheorem map_sup [SemilatticeSup α] [LinearOrder β] [FunLike F β α]\n [RelHomClass F (· > ·) (· > ·)] (a : F) (m n : β) :\n a (m ⊔ n) = a m ⊔ a n :=\n map_inf (α := αᵒᵈ) (β := βᵒᵈ) _ _ _\n\ntheorem directed [FunLike F α β] [RelHomClass F r s] {ι : Sort*} {a : ι → α} {f : F}\n (ha : Directed r a) : Directed s (f ∘ a) :=\n ha.mono_comp _ fun _ _ h ↦ map_rel f h\n\ntheorem directedOn [FunLike F α β] [RelHomClass F r s] {f : F}\n {t : Set α} (hs : DirectedOn r t) : DirectedOn s (f '' t) :=\n hs.mono_comp fun _ _ h ↦ map_rel f h\n\nend RelHomClass\n\nnamespace RelIso\n\ntheorem range_eq (e : r ≃r s) : Set.range e = Set.univ := by simp\n\nend RelIso\n\n/-- `Subrel r p` is the inherited relation on a subtype.\n\nWe could also consider a Set.Subrel r s variant for dot notation, but this ends up interacting\npoorly with `simpNF`. -/\ndef Subrel (r : α → α → Prop) (p : α → Prop) : Subtype p → Subtype p → Prop :=\n Subtype.val ⁻¹'o r\n\n@[simp]\ntheorem subrel_val (r : α → α → Prop) (p : α → Prop) {a b} : Subrel r p a b ↔ r a.1 b.1 :=\n Iff.rfl\n\nnamespace Subrel\n\n/-- The relation embedding from the inherited relation on a subset. -/\nprotected def relEmbedding (r : α → α → Prop) (p : α → Prop) : Subrel r p ↪r r :=\n ⟨Embedding.subtype _, Iff.rfl⟩\n\n@[simp]\ntheorem relEmbedding_apply (r : α → α → Prop) (p a) : Subrel.relEmbedding r p a = a.1 :=\n rfl\n\n/-- `Set.inclusion` as a relation embedding. -/\nprotected def inclusionEmbedding (r : α → α → Prop) {s t : Set α} (h : s ⊆ t) :\n Subrel r (· ∈ s) ↪r Subrel r (· ∈ t) where\n toFun := Set.inclusion h\n inj' _ _ h := (Set.inclusion_inj _).mp h\n map_rel_iff' := Iff.rfl\n\n@[simp]\ntheorem coe_inclusionEmbedding (r : α → α → Prop) {s t : Set α} (h : s ⊆ t) :\n (Subrel.inclusionEmbedding r h : s → t) = Set.inclusion h :=\n rfl\n\ninstance (r : α → α → Prop) [Std.Refl r] (p : α → Prop) : Std.Refl (Subrel r p) :=\n ⟨fun x => Std.Refl.refl (r := r) x⟩\n\ninstance (r : α → α → Prop) [Std.Symm r] (p : α → Prop) : Std.Symm (Subrel r p) :=\n ⟨fun x y => Std.Symm.symm (r := r) x y⟩\n\ninstance (r : α → α → Prop) [Std.Asymm r] (p : α → Prop) : Std.Asymm (Subrel r p) :=\n ⟨fun x y => Std.Asymm.asymm (r := r) x y⟩\n\ninstance (r : α → α → Prop) [IsTrans α r] (p : α → Prop) : IsTrans _ (Subrel r p) :=\n ⟨fun x y z => IsTrans.trans (r := r) x y z⟩\n\ninstance (r : α → α → Prop) [Std.Irrefl r] (p : α → Prop) : Std.Irrefl (Subrel r p) :=\n ⟨fun x => Std.Irrefl.irrefl (r := r) x⟩\n\ninstance (r : α → α → Prop) [Std.Trichotomous r] (p : α → Prop) : Std.Trichotomous (Subrel r p) :=\n ⟨fun x y => by rw [Subtype.ext_iff]; exact @Std.Trichotomous.trichotomous α r _ x y⟩\n\ninstance (r : α → α → Prop) [IsWellFounded α r] (p : α → Prop) : IsWellFounded _ (Subrel r p) :=\n (Subrel.relEmbedding r p).isWellFounded\n\ninstance (r : α → α → Prop) [IsPreorder α r] (p : α → Prop) : IsPreorder _ (Subrel r p) where\ninstance (r : α → α → Prop) [IsStrictOrder α r] (p : α → Prop) : IsStrictOrder _ (Subrel r p) where\ninstance (r : α → α → Prop) [IsWellOrder α r] (p : α → Prop) : IsWellOrder _ (Subrel r p) where\n\nend Subrel\n\n/-- If a proposition holds for all elements, then the `Subrel` is equivalent to the original\nrelation. -/\n@[simps! apply symm_apply]\ndef RelIso.subrelUnivIso {p : α → Prop} (h : ∀ x, p x) : Subrel r p ≃r r where\n toEquiv := Equiv.subtypeUnivEquiv h\n map_rel_iff' := by simp\n\n/-- Restrict the codomain of a relation embedding. -/\ndef RelEmbedding.codRestrict (p : Set β) (f : r ↪r s) (H : ∀ a, f a ∈ p) : r ↪r Subrel s (· ∈ p) :=\n ⟨f.toEmbedding.codRestrict p H, f.map_rel_iff'⟩\n\n@[simp]\ntheorem RelEmbedding.codRestrict_apply (p) (f : r ↪r s) (H a) :\n RelEmbedding.codRestrict p f H a = ⟨f a, H a⟩ :=\n rfl\n\nsection image\n\ntheorem RelIso.image_eq_preimage_symm (e : r ≃r s) (t : Set α) : e '' t = e.symm ⁻¹' t :=\n e.toEquiv.image_eq_preimage_symm t\n\nTarget:\ntheorem RelIso.preimage_eq_image_symm (e : r ≃r s) (t : Set β) : e ⁻¹' t = e.symm '' t :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_dd5dda343143","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a2502cb394d6083f28feade21e7175ffc7923dde1979156a58401e870d59e66b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/RelIso","family_id":"reliso","file_id":"mathlib/Mathlib/Order/RelIso/Set.lean","sample_id":"dd5dda343143c8547708c93efe6437d75765097ec9bba5770558209c4666433d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1c42cc069aa56a2bf1a7b2b1c15ee26e179c971ab71c67e215f9ba4cb1625d4a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fb88080af6f22f4a9c54def3d9626310c1868fdacdfa6a87155ac0f2ed05a2f6","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext a\n exact DFunLike.congr_fun h a","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":2,"token_jaccard":0.111111,"token_length_ratio":0.222222},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"5d788710d3337d699b98c88eb7dffe232b3d2647585b7f5fdcd70212d20b70fb","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\nTarget:\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"to_mulhom_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"fb88080af6f22f4a9c54def3d9626310c1868fdacdfa6a87155ac0f2ed05a2f6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e82e08ef144d565e1c376295ce50ac6ef4301c0767aa14c0314503288fad8a54","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"20930719e5be8d87f86fd90247567f53f0277a8531a4b484d7428f4a9fe93cfb","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"11f23baef49a098a7d1f6ccdc22c013017dff9dd746cd6f024880be58eedb02f","source_sha256":"98ab40b848c3a9b869e560fc0ac9ad03c46286d47046f58fc1a9867b1fe3c8a8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext v\n simp_rw [continuousLinearMapCoordChange, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.arrowCongrSL_apply, continuousLinearMap_apply,\n continuousLinearMap_symm_apply' σ e₁ e₂ hb.1, comp_apply, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.symm_symm, Trivialization.continuousLinearMapAt_apply,\n Trivialization.symmL_apply]\n rw [e₂.coordChangeL_apply e₂', e₁'.coordChangeL_apply e₁, e₁.coe_linearMapAt_of_mem hb.1.1,\n e₂'.coe_linearMapAt_of_mem hb.2.2]\n exacts [⟨hb.2.1, hb.1.1⟩, ⟨hb.1.2, hb.2.2⟩]","hard_negative":true,"metrics":{"chosen_tokens":114,"rejected_tokens":2,"token_jaccard":0.029412,"token_length_ratio":0.017544},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"5e8b35551672177065301ee024032753cdcc4338d56853e37aaed7d5ac142de7","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.VectorBundle.Basic\n\nNamespace:\nBundle.Pretrivialization\n\nLocal context:\n/-\nCopyright (c) 2022 Heather Macbeth. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Heather Macbeth, Floris van Doorn\n-/\n/-!\n# The vector bundle of continuous (semi)linear maps\n\nWe define the (topological) vector bundle of continuous (semi)linear maps between two vector bundles\nover the same base.\n\nGiven bundles `E₁ E₂ : B → Type*`, normed spaces `F₁` and `F₂`, and a ring-homomorphism `σ` between\ntheir respective scalar fields, we define a vector bundle with fiber `E₁ x →SL[σ] E₂ x`.\nIf the `E₁` and `E₂` are vector bundles with model fibers `F₁` and `F₂`, then this will be a\nvector bundle with fiber `F₁ →SL[σ] F₂`.\n\nThe topology on the total space is constructed from the trivializations for `E₁` and `E₂` and the\nnorm-topology on the model fiber `F₁ →SL[𝕜] F₂` using the `VectorPrebundle` construction. This is\na bit awkward because it introduces a dependence on the normed space structure of the model fibers,\nrather than just their topological vector space structure; it is not clear whether this is\nnecessary.\n\nSimilar constructions should be possible (but are yet to be formalized) for tensor products of\ntopological vector bundles, exterior algebras, and so on, where again the topology can be defined\nusing a norm on the fiber model if this helps.\n-/\n\n@[expose] public section\n\n\nnoncomputable section\n\nopen Bundle Set ContinuousLinearMap Topology\nopen scoped Bundle\n\nvariable {𝕜₁ : Type*} [NontriviallyNormedField 𝕜₁] {𝕜₂ : Type*} [NontriviallyNormedField 𝕜₂]\n (σ : 𝕜₁ →+* 𝕜₂)\n\nvariable {B : Type*}\nvariable {F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜₁ F₁] (E₁ : B → Type*)\n [∀ x, AddCommGroup (E₁ x)] [∀ x, Module 𝕜₁ (E₁ x)] [TopologicalSpace (TotalSpace F₁ E₁)]\n\nvariable {F₂ : Type*} [NormedAddCommGroup F₂] [NormedSpace 𝕜₂ F₂] (E₂ : B → Type*)\n [∀ x, AddCommGroup (E₂ x)] [∀ x, Module 𝕜₂ (E₂ x)] [TopologicalSpace (TotalSpace F₂ E₂)]\n\nvariable {E₁ E₂}\nvariable [TopologicalSpace B] (e₁ e₁' : Trivialization F₁ (π F₁ E₁))\n (e₂ e₂' : Trivialization F₂ (π F₂ E₂))\n\nnamespace Bundle.Pretrivialization\n\n/-- Assume `eᵢ` and `eᵢ'` are trivializations of the bundles `Eᵢ` over base `B` with fiber `Fᵢ`\n(`i ∈ {1,2}`), then `Pretrivialization.continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂'` is the\ncoordinate change function between the two induced (pre)trivializations\n`Pretrivialization.continuousLinearMap σ e₁ e₂` and\n`Pretrivialization.continuousLinearMap σ e₁' e₂'` of the bundle of continuous linear maps. -/\ndef continuousLinearMapCoordChange [e₁.IsLinear 𝕜₁] [e₁'.IsLinear 𝕜₁] [e₂.IsLinear 𝕜₂]\n [e₂'.IsLinear 𝕜₂] (b : B) : (F₁ →SL[σ] F₂) →L[𝕜₂] F₁ →SL[σ] F₂ :=\n ((e₁'.coordChangeL 𝕜₁ e₁ b).symm.arrowCongrSL (e₂.coordChangeL 𝕜₂ e₂' b) :\n (F₁ →SL[σ] F₂) ≃L[𝕜₂] F₁ →SL[σ] F₂)\n\nvariable {σ e₁ e₁' e₂ e₂'}\nvariable [∀ x, TopologicalSpace (E₁ x)] [FiberBundle F₁ E₁]\nvariable [∀ x, TopologicalSpace (E₂ x)] [FiberBundle F₂ E₂]\n\nset_option backward.defeqAttrib.useBackward true in\ntheorem continuousOn_continuousLinearMapCoordChange [RingHomIsometric σ]\n [VectorBundle 𝕜₁ F₁ E₁] [VectorBundle 𝕜₂ F₂ E₂]\n [MemTrivializationAtlas e₁] [MemTrivializationAtlas e₁'] [MemTrivializationAtlas e₂]\n [MemTrivializationAtlas e₂'] :\n ContinuousOn (continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂')\n (e₁.baseSet ∩ e₂.baseSet ∩ (e₁'.baseSet ∩ e₂'.baseSet)) := by\n have h₁ := (compSL F₁ F₂ F₂ σ (RingHom.id 𝕜₂)).continuous\n have h₂ := (ContinuousLinearMap.flip (compSL F₁ F₁ F₂ (RingHom.id 𝕜₁) σ)).continuous\n have h₃ := continuousOn_coordChange 𝕜₁ e₁' e₁\n have h₄ := continuousOn_coordChange 𝕜₂ e₂ e₂'\n refine ((h₁.comp_continuousOn (h₄.mono ?_)).clm_comp (h₂.comp_continuousOn (h₃.mono ?_))).congr ?_\n · mfld_set_tac\n · mfld_set_tac\n · intro b _\n ext L v\n dsimp [continuousLinearMapCoordChange]\n\nvariable (σ e₁ e₁' e₂ e₂')\nvariable [e₁.IsLinear 𝕜₁] [e₁'.IsLinear 𝕜₁] [e₂.IsLinear 𝕜₂] [e₂'.IsLinear 𝕜₂]\n\n/-- Given trivializations `e₁`, `e₂` for vector bundles `E₁`, `E₂` over a base `B`,\n`Pretrivialization.continuousLinearMap σ e₁ e₂` is the induced pretrivialization for the\ncontinuous `σ`-semilinear maps from `E₁` to `E₂`. That is, the map which will later become a\ntrivialization, after the bundle of continuous semilinear maps is equipped with the right\ntopological vector bundle structure. -/\ndef continuousLinearMap :\n Pretrivialization (F₁ →SL[σ] F₂) (π (F₁ →SL[σ] F₂) (fun x ↦ E₁ x →SL[σ] E₂ x)) where\n toFun p := ⟨p.1, .comp (e₂.continuousLinearMapAt 𝕜₂ p.1) (p.2.comp (e₁.symmL 𝕜₁ p.1))⟩\n invFun p := ⟨p.1, .comp (e₂.symmL 𝕜₂ p.1) (p.2.comp (e₁.continuousLinearMapAt 𝕜₁ p.1))⟩\n source := Bundle.TotalSpace.proj ⁻¹' (e₁.baseSet ∩ e₂.baseSet)\n target := (e₁.baseSet ∩ e₂.baseSet) ×ˢ Set.univ\n map_source' := fun ⟨_, _⟩ h ↦ ⟨h, Set.mem_univ _⟩\n map_target' := fun ⟨_, _⟩ h ↦ h.1\n left_inv' := fun ⟨x, L⟩ ⟨h₁, h₂⟩ ↦ by\n simp only [TotalSpace.mk_inj]\n ext (v : E₁ x)\n dsimp only [comp_apply]\n rw [Trivialization.symmL_continuousLinearMapAt, Trivialization.symmL_continuousLinearMapAt]\n exacts [h₁, h₂]\n right_inv' := fun ⟨x, f⟩ ⟨⟨h₁, h₂⟩, _⟩ ↦ by\n simp only [Prod.mk_right_inj]\n ext v\n dsimp only [comp_apply]\n rw [Trivialization.continuousLinearMapAt_symmL, Trivialization.continuousLinearMapAt_symmL]\n exacts [h₁, h₂]\n open_target := (e₁.open_baseSet.inter e₂.open_baseSet).prod isOpen_univ\n baseSet := e₁.baseSet ∩ e₂.baseSet\n open_baseSet := e₁.open_baseSet.inter e₂.open_baseSet\n source_eq := rfl\n target_eq := rfl\n proj_toFun _ _ := rfl\n\n-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215):\n-- TODO: see if Lean 4 can generate this instance without a hint\ninstance continuousLinearMap.isLinear [∀ x, ContinuousAdd (E₂ x)] [∀ x, ContinuousSMul 𝕜₂ (E₂ x)] :\n (Pretrivialization.continuousLinearMap σ e₁ e₂).IsLinear 𝕜₂ where\n linear x _ :=\n { map_add L L' := by simp [continuousLinearMap, Pretrivialization.toFun']\n map_smul c L := by simp [continuousLinearMap, Pretrivialization.toFun'] }\n\ntheorem continuousLinearMap_apply (p : TotalSpace (F₁ →SL[σ] F₂) fun x ↦ E₁ x →SL[σ] E₂ x) :\n (continuousLinearMap σ e₁ e₂) p =\n ⟨p.1, .comp (e₂.continuousLinearMapAt 𝕜₂ p.1) (p.2.comp (e₁.symmL 𝕜₁ p.1))⟩ :=\n rfl\n\ntheorem continuousLinearMap_symm_apply (p : B × (F₁ →SL[σ] F₂)) :\n (continuousLinearMap σ e₁ e₂).toPartialEquiv.symm p =\n ⟨p.1, .comp (e₂.symmL 𝕜₂ p.1) (p.2.comp (e₁.continuousLinearMapAt 𝕜₁ p.1))⟩ :=\n rfl\n\ntheorem continuousLinearMap_symm_apply' {b : B} (hb : b ∈ e₁.baseSet ∩ e₂.baseSet)\n (L : F₁ →SL[σ] F₂) :\n (continuousLinearMap σ e₁ e₂).symm b L =\n (e₂.symmL 𝕜₂ b).comp (L.comp <| e₁.continuousLinearMapAt 𝕜₁ b) := by\n rw [symm_apply]\n · rfl\n · exact hb\n\nTarget:\ntheorem continuousLinearMapCoordChange_apply (b : B)\n (hb : b ∈ e₁.baseSet ∩ e₂.baseSet ∩ (e₁'.baseSet ∩ e₂'.baseSet)) (L : F₁ →SL[σ] F₂) :\n continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂' b L =\n (continuousLinearMap σ e₁' e₂' ⟨b, (continuousLinearMap σ e₁ e₂).symm b L⟩).2 :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_11f23baef49a","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"f876d7d4a908ebe2c0f30dab10324415f1b333d9d91a7385ac29c60d86c2f8a5","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/VectorBundle","family_id":"continuouslinearmapcoordchange_apply","file_id":"mathlib/Mathlib/Topology/VectorBundle/Hom.lean","sample_id":"11f23baef49a098a7d1f6ccdc22c013017dff9dd746cd6f024880be58eedb02f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0899b18df743631c4399d57209590382d7b2e9e3a847090548d5e404d07daf6d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4e0643ed342157b454698b88f13138db1a0caa45526eeac574e5f5b754a35c03","source_sha256":"ccfd4dd3593c6c1f210133749c73e4a778fa70e4772e48b50cde116f0b334020","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine (continuousAt_const : ContinuousAt (fun _ => (1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩","hard_negative":false,"metrics":{"chosen_tokens":56,"rejected_tokens":5,"token_jaccard":0.076923,"token_length_ratio":0.089286},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"5ea11f42a61b0e1cbaa539d876b9dde65446909c3328ba214e6e15d9c0ad3bf8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Sign.Defs\npublic import Mathlib.Topology.Order.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Topology on `SignType`\n\nThis file gives `SignType` the discrete topology, and proves continuity results for `SignType.sign`\nin an `OrderTopology`.\n-/\n\npublic section\n\ninstance : TopologicalSpace SignType :=\n ⊥\n\ninstance : DiscreteTopology SignType :=\n ⟨rfl⟩\n\nvariable {α : Type*} [Zero α] [TopologicalSpace α]\n\nsection PartialOrder\n\nvariable [PartialOrder α] [DecidableLT α] [OrderTopology α]\n\nTarget:\ntheorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Instances","family_id":"continuousat_sign_of_pos","file_id":"mathlib/Mathlib/Topology/Instances/Sign.lean","sample_id":"4e0643ed342157b454698b88f13138db1a0caa45526eeac574e5f5b754a35c03"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dbfb47395ef398e947f71379cc7f492edfa1e8a2486b71d17d0fa84edf275e35","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"08d54790790b4504427f1034b404bc383b9faf0c3904a832d988759582c2ba11","source_sha256":"ad7723f259d906404f2439f75ed42dbf632d4e1b3851e9262d6a24c449189a41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n calc\n Module.rank ℝ (span ℝ (-x +ᵥ s)) ≤\n Module.rank ℝ (span ℝ\n (-x +ᵥ affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) : Set V)) := by\n push_cast\n refine Submodule.rank_mono ?_\n gcongr\n exact (subset_convexHull ..).trans <| hs.convexHull_subset_affineSpan_isVisible hx\n _ = Module.rank ℝ (span ℝ (-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y})) := by\n suffices h :\n -x +ᵥ (affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) : Set V) =\n span ℝ (-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) by\n rw [AffineSubspace.coe_pointwise_vadd, h, span_span]\n simp [← AffineSubspace.coe_pointwise_vadd, AffineSubspace.pointwise_vadd_span,\n vadd_set_insert, -coe_affineSpan, affineSpan_insert_zero]\n _ ≤ #(-x +ᵥ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) := rank_span_le _\n _ = #{y ∈ s | IsVisible ℝ (convexHull ℝ s) x y} := by simp","hard_negative":false,"metrics":{"chosen_tokens":251,"rejected_tokens":2,"token_jaccard":0.033333,"token_length_ratio":0.007968},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"5eb70c8f0fd2f32815c7ee24f47b875de97a25c15279c6a56a5c694cfc55df73","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Algebra.Group.Pointwise.Set.Card\npublic import Mathlib.Analysis.Convex.Between\npublic import Mathlib.Analysis.Convex.Combination\npublic import Mathlib.Topology.Algebra.Affine\npublic import Mathlib.Topology.MetricSpace.Pseudo.Lemmas\npublic import Mathlib.Topology.Order.Monotone\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\n/-!\n# Points in sight\n\nThis file defines the relation of visibility with respect to a set, and lower bounds how many\nelements of a set a point sees in terms of the dimension of that set.\n\n## TODO\n\nThe art gallery problem can be stated using the visibility predicate: A set `A` (the art gallery) is\nguarded by a finite set `G` (the guards) iff `∀ a ∈ A, ∃ g ∈ G, IsVisible ℝ sᶜ a g`.\n-/\n\n@[expose] public section\n\nopen AffineMap Filter Finset Set\nopen scoped Cardinal Pointwise Topology\n\nvariable {𝕜 V P : Type*}\n\nsection AddTorsor\nvariable [Field 𝕜] [LinearOrder 𝕜] [IsOrderedRing 𝕜]\n [AddCommGroup V] [Module 𝕜 V] [AddTorsor V P]\n {s t : Set P} {x y z : P}\n\nomit [IsOrderedRing 𝕜] in\nvariable (𝕜) in\n/-- Two points are visible to each other through a set if no point of that set lies strictly\nbetween them.\n\nBy convention, a point `x` sees itself through any set `s`, even when `x ∈ s`. -/\ndef IsVisible (s : Set P) (x y : P) : Prop := ∀ ⦃z⦄, z ∈ s → ¬ Sbtw 𝕜 x z y\n\n@[simp, refl]\nlemma IsVisible.rfl : IsVisible 𝕜 s x x := by simp [IsVisible]\n\nlemma isVisible_comm : IsVisible 𝕜 s x y ↔ IsVisible 𝕜 s y x := by\n simp [IsVisible, sbtw_comm]\n\n@[symm] alias ⟨IsVisible.symm, _⟩ := isVisible_comm\n\nomit [IsOrderedRing 𝕜] in\nlemma IsVisible.mono (hst : s ⊆ t) (ht : IsVisible 𝕜 t x y) : IsVisible 𝕜 s x y :=\n fun _z hz ↦ ht <| hst hz\n\nlemma isVisible_iff_lineMap (hxy : x ≠ y) :\n IsVisible 𝕜 s x y ↔ ∀ δ ∈ Set.Ioo (0 : 𝕜) 1, lineMap x y δ ∉ s := by\n simp [IsVisible, sbtw_iff_mem_image_Ioo_and_ne, hxy]\n aesop\n\nend AddTorsor\n\nsection Module\nvariable [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜]\n [AddCommGroup V] [Module 𝕜 V] {s : Set V} {x y z : V}\n\n/-- If a point `x` sees a convex combination of points of a set `s` through `convexHull ℝ s ∌ x`,\nthen it sees all terms of that combination.\n\nNote that the converse does not hold. -/\nlemma IsVisible.of_convexHull_of_pos {ι : Type*} {t : Finset ι} {a : ι → V} {w : ι → 𝕜}\n (hw₀ : ∀ i ∈ t, 0 ≤ w i) (hw₁ : ∑ i ∈ t, w i = 1) (ha : ∀ i ∈ t, a i ∈ s)\n (hx : x ∉ convexHull 𝕜 s) (hw : IsVisible 𝕜 (convexHull 𝕜 s) x (∑ i ∈ t, w i • a i)) {i : ι}\n (hi : i ∈ t) (hwi : 0 < w i) : IsVisible 𝕜 (convexHull 𝕜 s) x (a i) := by\n classical\n obtain hwi | hwi : w i = 1 ∨ w i < 1 := eq_or_lt_of_le <| (single_le_sum hw₀ hi).trans_eq hw₁\n · convert! hw\n rw [← one_smul 𝕜 (a i), ← hwi, eq_comm]\n rw [← hwi, ← sub_eq_zero, ← sum_erase_eq_sub hi,\n sum_eq_zero_iff_of_nonneg fun j hj ↦ hw₀ _ <| erase_subset _ _ hj] at hw₁\n refine sum_eq_single _ (fun j hj hji ↦ ?_) (by simp [hi])\n rw [hw₁ _ <| mem_erase.2 ⟨hji, hj⟩, zero_smul]\n rintro _ hε ⟨⟨ε, ⟨hε₀, hε₁⟩, rfl⟩, h⟩\n replace hε₀ : 0 < ε := hε₀.lt_of_ne <| by rintro rfl; simp at h\n replace hε₁ : ε < 1 := hε₁.lt_of_ne <| by rintro rfl; simp at h\n have : 0 < 1 - ε := by linarith\n have hwi : 0 < 1 - w i := by linarith\n refine hw (z := lineMap x (∑ j ∈ t, w j • a j) ((w i)⁻¹ / ((1 - ε) / ε + (w i)⁻¹)))\n ?_ <| sbtw_lineMap_iff.2 ⟨(ne_of_mem_of_not_mem ((convex_convexHull ..).sum_mem hw₀ hw₁\n fun i hi ↦ subset_convexHull _ _ <| ha _ hi) hx).symm, by positivity,\n (div_lt_one <| by positivity).2 ?_⟩\n · have : Wbtw 𝕜\n (lineMap x (a i) ε)\n (lineMap x (∑ j ∈ t, w j • a j) ((w i)⁻¹ / ((1 - ε) / ε + (w i)⁻¹)))\n (∑ j ∈ t.erase i, (w j / (1 - w i)) • a j) := by\n refine ⟨((1 - w i) / w i) / ((1 - ε) / ε + (1 - w i) / w i + 1), ⟨by positivity, ?_⟩, ?_⟩\n · refine (div_le_one <| by positivity).2 ?_\n calc\n (1 - w i) / w i = 0 + (1 - w i) / w i + 0 := by simp\n _ ≤ (1 - ε) / ε + (1 - w i) / w i + 1 := by gcongr <;> positivity\n have :\n w i • a i + (1 - w i) • ∑ j ∈ t.erase i, (w j / (1 - w i)) • a j = ∑ j ∈ t, w j • a j := by\n rw [smul_sum]\n simp_rw [smul_smul, mul_div_cancel₀ _ hwi.ne']\n exact add_sum_erase _ (fun i ↦ w i • a i) hi\n simp_rw [lineMap_apply_module, ← this]\n match_scalars <;> field\n refine (convex_convexHull _ _).mem_of_wbtw this hε <| (convex_convexHull _ _).sum_mem ?_ ?_ ?_\n · intro j hj\n positivity [hw₀ j <| erase_subset _ _ hj]\n · rw [← sum_div, sum_erase_eq_sub hi, hw₁, div_self hwi.ne']\n · exact fun j hj ↦ subset_convexHull _ _ <| ha _ <| erase_subset _ _ hj\n · exact lt_add_of_pos_left _ <| by positivity\n\nvariable [TopologicalSpace 𝕜] [OrderTopology 𝕜] [TopologicalSpace V] [IsTopologicalAddGroup V]\n [ContinuousSMul 𝕜 V]\n\n/-- One cannot see any point in the interior of a set. -/\nlemma IsVisible.eq_of_mem_interior (hsxy : IsVisible 𝕜 s x y) (hy : y ∈ interior s) :\n x = y := by\n by_contra! hxy\n suffices h : ∀ᶠ (_δ : 𝕜) in 𝓝[>] 0, False by obtain ⟨_, ⟨⟩⟩ := h.exists\n have hmem : ∀ᶠ (δ : 𝕜) in 𝓝[>] 0, lineMap y x δ ∈ s :=\n lineMap_continuous.continuousWithinAt.eventually_mem\n (by simpa using mem_interior_iff_mem_nhds.1 hy)\n filter_upwards [hmem, Ioo_mem_nhdsGT zero_lt_one] with δ hmem hsbt using hsxy.symm hmem (by aesop)\n\n/-- One cannot see any point of an open set. -/\nlemma IsOpen.eq_of_isVisible_of_left_mem (hs : IsOpen s) (hsxy : IsVisible 𝕜 s x y) (hy : y ∈ s) :\n x = y :=\n hsxy.eq_of_mem_interior (by simpa [hs.interior_eq])\n\nend Module\n\nsection Real\nvariable [AddCommGroup V] [Module ℝ V] {s : Set V} {x y z : V}\n\n/-- All points of the convex hull of a set `s` visible from a point `x ∉ convexHull ℝ s` lie in the\nconvex hull of such points that actually lie in `s`.\n\nNote that the converse does not hold. -/\nlemma IsVisible.mem_convexHull_isVisible (hx : x ∉ convexHull ℝ s) (hy : y ∈ convexHull ℝ s)\n (hxy : IsVisible ℝ (convexHull ℝ s) x y) :\n y ∈ convexHull ℝ {z ∈ s | IsVisible ℝ (convexHull ℝ s) x z} := by\n classical\n obtain ⟨ι, _, w, a, hw₀, hw₁, ha, rfl⟩ := mem_convexHull_iff_exists_fintype.1 hy\n rw [← Fintype.sum_subset (s := {i | w i ≠ 0})\n fun i hi ↦ mem_filter.2 ⟨mem_univ _, left_ne_zero_of_smul hi⟩]\n exact (convex_convexHull ..).sum_mem (fun i _ ↦ hw₀ _) (by rwa [sum_filter_ne_zero])\n fun i hi ↦ subset_convexHull _ _ ⟨ha _, IsVisible.of_convexHull_of_pos (fun _ _ ↦ hw₀ _) hw₁\n (by simpa) hx hxy (mem_univ _) <| (hw₀ _).lt_of_ne' (mem_filter.1 hi).2⟩\n\nvariable [TopologicalSpace V] [IsTopologicalAddGroup V] [ContinuousSMul ℝ V]\n\n/-- If `s` is a closed set, then any point `x` sees some point of `s` in any direction where there\nis something to see. -/\nlemma IsClosed.exists_wbtw_isVisible (hs : IsClosed s) (hy : y ∈ s) (x : V) :\n ∃ z ∈ s, Wbtw ℝ x z y ∧ IsVisible ℝ s x z := by\n let t : Set ℝ := Ici 0 ∩ lineMap x y ⁻¹' s\n have ht₁ : 1 ∈ t := by simpa [t]\n have ht : BddBelow t := bddBelow_Ici.inter_of_left\n let δ : ℝ := sInf t\n have hδ₁ : δ ≤ 1 := csInf_le ht ht₁\n obtain ⟨hδ₀, hδ⟩ : 0 ≤ δ ∧ lineMap x y δ ∈ s :=\n (isClosed_Ici.inter <| hs.preimage lineMap_continuous).csInf_mem ⟨1, ht₁⟩ ht\n refine ⟨lineMap x y δ, hδ, wbtw_lineMap_iff.2 <| .inr ⟨hδ₀, hδ₁⟩, ?_⟩\n rintro _ hε ⟨⟨ε, ⟨hε₀, hε₁⟩, rfl⟩, -, h⟩\n replace hδ₀ : 0 < δ := hδ₀.lt_of_ne' <| by rintro hδ₀; simp [hδ₀] at h\n replace hε₁ : ε < 1 := hε₁.lt_of_ne <| by rintro rfl; simp at h\n rw [lineMap_lineMap_right] at hε\n exact (csInf_le ht ⟨mul_nonneg hε₀ hδ₀.le, hε⟩).not_gt <| mul_lt_of_lt_one_left hδ₀ hε₁\n\n-- TODO: Once we have cone hulls, the RHS can be strengthened to\n-- `coneHull ℝ x {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}`\n/-- A set whose convex hull is closed lies in the cone based at a point `x` generated by its points\nvisible from `x` through its convex hull. -/\nlemma IsClosed.convexHull_subset_affineSpan_isVisible (hs : IsClosed (convexHull ℝ s))\n (hx : x ∉ convexHull ℝ s) :\n convexHull ℝ s ⊆ affineSpan ℝ ({x} ∪ {y ∈ s | IsVisible ℝ (convexHull ℝ s) x y}) := by\n rintro y hy\n obtain ⟨z, hz, hxzy, hxz⟩ := hs.exists_wbtw_isVisible hy x\n -- TODO: `calc` doesn't work with `∈` :(\n exact AffineSubspace.right_mem_of_wbtw hxzy (subset_affineSpan _ _ <| subset_union_left rfl)\n (affineSpan_mono _ subset_union_right <| convexHull_subset_affineSpan _ <|\n hxz.mem_convexHull_isVisible hx hz) (ne_of_mem_of_not_mem hz hx).symm\n\nopen Submodule in\n/-- If `s` is a closed set of dimension `d` and `x` is a point outside of its convex hull,\nthen `x` sees at least `d` points of the convex hull of `s` that actually lie in `s`. -/\n\nTarget:\nlemma rank_le_card_isVisible (hs : IsClosed (convexHull ℝ s)) (hx : x ∉ convexHull ℝ s) :\n Module.rank ℝ (span ℝ (-x +ᵥ s)) ≤ #{y ∈ s | IsVisible ℝ (convexHull ℝ s) x y} :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Convex","family_id":"rank_le_card_isvisible","file_id":"mathlib/Mathlib/Analysis/Convex/Visible.lean","sample_id":"08d54790790b4504427f1034b404bc383b9faf0c3904a832d988759582c2ba11"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2a283e91ec47213d9b00885fb6817a970c1be05f6de5a84eb7a81d6f8423a9f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"3712c2c05ed70516535788c13ca4886422df3efac33614daede8abdc359a1174","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5e424902350257d28f8d0de8d4216b305427715a24efd145390730ba5c4764ec","source_sha256":"dcc76d9c7855f20ba96b35eb6c6801e17ffbb55864d7bbfc3fd5a5468d4f4c8d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨M⟩ ⟨N⟩ hM hN\n let _ := fieldOfModelACF p M\n have := modelField_of_modelACF p M\n let _ := compatibleRingOfModelField M\n have := isAlgClosed_of_model_ACF p M\n have := charP_of_model_fieldOfChar p M\n let _ := fieldOfModelACF p N\n have := modelField_of_modelACF p N\n let _ := compatibleRingOfModelField N\n have := isAlgClosed_of_model_ACF p N\n have := charP_of_model_fieldOfChar p N\n constructor\n refine languageEquivEquivRingEquiv.symm ?_\n apply Classical.choice\n refine IsAlgClosed.ringEquiv_of_equiv_of_char_eq p ?_ ?_\n · rw [hM]; exact hκ\n · rw [← Cardinal.eq, hM, hN]","hard_negative":false,"metrics":{"chosen_tokens":103,"rejected_tokens":110,"token_jaccard":0.953488,"token_length_ratio":1.067961},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"5ed409a539e1d2a8c1744b0e95fe2b6ca1790af9657791961cdd94a1435726d0","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure\npublic import Mathlib.FieldTheory.IsAlgClosed.Classification\npublic import Mathlib.ModelTheory.Algebra.Field.CharP\npublic import Mathlib.ModelTheory.Satisfiability\n\nNamespace:\nFirstOrder.Field\n\nLocal context:\n/-\nCopyright (c) 2023 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\n/-!\n\n# The First-Order Theory of Algebraically Closed Fields\n\nThis file defines the theory of algebraically closed fields of characteristic `p`, as well\nas proving completeness of the theory and the Lefschetz Principle.\n\n## Main definitions\n\n* `FirstOrder.Language.Theory.ACF p` : the theory of algebraically closed fields of characteristic\n `p` as a theory over the language of rings.\n* `FirstOrder.Field.ACF_isComplete` : the theory of algebraically closed fields of characteristic\n `p` is complete whenever `p` is prime or zero.\n* `FirstOrder.Field.ACF_zero_realize_iff_infinite_ACF_prime_realize` : the Lefschetz principle.\n\n## Implementation details\n\nTo apply a theorem about the model theory of algebraically closed fields to a specific\nalgebraically closed field `K` which does not have a `Language.ring.Structure` instance,\nyou must introduce the local instance `compatibleRingOfRing K`. Theorems whose statement requires\nboth a `Language.ring.Structure` instance and a `Field` instance will all be stated with the\nassumption `Field K`, `CharP K p`, `IsAlgClosed K` and `CompatibleRing K` and there are instances\ndefined saying that these assumptions imply `Theory.field.Model K` and `(Theory.ACF p).Model K`\n\n## References\n\nThe first-order theory of algebraically closed fields, along with the Lefschetz Principle and\nthe Ax-Grothendieck Theorem were first formalized in Lean 3 by Joseph Hua\n[here](https://github.com/Jlh18/ModelTheoryInLean8) with the master's thesis\n[here](https://github.com/Jlh18/ModelTheory8Report)\n\n-/\n\n@[expose] public section\n\nvariable {K : Type*}\n\nnamespace FirstOrder\n\nnamespace Field\n\nopen Ring FreeCommRing Polynomial Language\n\n/-- A generic monic polynomial of degree `n` as an element of the\nfree commutative ring in `n + 1` variables, with a variable for each\nof the `n` non-leading coefficients of the polynomial and one variable (`Fin.last n`)\nfor `X`. -/\nnoncomputable def genericMonicPoly (n : ℕ) : FreeCommRing (Fin (n + 1)) :=\n of (Fin.last _) ^ n + ∑ i : Fin n, of i.castSucc * of (Fin.last _) ^ (i : ℕ)\n\ntheorem lift_genericMonicPoly [CommRing K] [Nontrivial K] {n : ℕ} (v : Fin (n + 1) → K) :\n FreeCommRing.lift v (genericMonicPoly n) =\n (((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv).symm (v ∘ Fin.castSucc)).1.eval\n (v (Fin.last _)) := by\n simp [genericMonicPoly, monicEquivDegreeLT, degreeLTEquiv, eval_finsetSum]\n\n/-- A sentence saying every monic polynomial of degree `n` has a root. -/\nnoncomputable def genericMonicPolyHasRoot (n : ℕ) : Language.ring.Sentence :=\n (∃' ((termOfFreeCommRing (genericMonicPoly n)).relabel Sum.inr =' 0)).alls\n\ntheorem realize_genericMonicPolyHasRoot [Field K] [CompatibleRing K] (n : ℕ) :\n K ⊨ genericMonicPolyHasRoot n ↔\n ∀ p : { p : K[X] // p.Monic ∧ p.natDegree = n }, ∃ x, p.1.eval x = 0 := by\n rw [Equiv.forall_congr_left ((monicEquivDegreeLT n).trans (degreeLTEquiv K n).toEquiv)]\n simp [Sentence.Realize, genericMonicPolyHasRoot, lift_genericMonicPoly]\n\n/-- The theory of algebraically closed fields of characteristic `p` as a theory over\nthe language of rings -/\ndef _root_.FirstOrder.Language.Theory.ACF (p : ℕ) : Theory .ring :=\n Theory.fieldOfChar p ∪ genericMonicPolyHasRoot '' {n | 0 < n}\n\ninstance [Language.ring.Structure K] (p : ℕ) [h : (Theory.ACF p).Model K] :\n (Theory.fieldOfChar p).Model K :=\n Theory.Model.mono h Set.subset_union_left\n\ninstance [Field K] [CompatibleRing K] {p : ℕ} [CharP K p] [IsAlgClosed K] :\n (Theory.ACF p).Model K := by\n refine Theory.model_union_iff.2 ⟨inferInstance, ?_⟩\n simp only [Theory.model_iff, Set.mem_image,\n forall_exists_index, and_imp]\n rintro _ n hn0 rfl\n simp only [realize_genericMonicPolyHasRoot]\n rintro ⟨p, _, rfl⟩\n exact IsAlgClosed.exists_root p (ne_of_gt\n (natDegree_pos_iff_degree_pos.1 hn0))\n\ntheorem modelField_of_modelACF (p : ℕ) (K : Type*) [Language.ring.Structure K]\n [h : (Theory.ACF p).Model K] : Theory.field.Model K :=\n Theory.Model.mono h (Set.subset_union_of_subset_left Set.subset_union_left _)\n\n/-- A model for the Theory of algebraically closed fields is a Field. After introducing\nthis as a local instance on a particular Type, you should usually also introduce\n`modelField_of_modelACF p M`, `compatibleRingOfModelField` and `isAlgClosed_of_model_ACF` -/\n@[reducible]\nnoncomputable def fieldOfModelACF (p : ℕ) (K : Type*)\n [Language.ring.Structure K]\n [h : (Theory.ACF p).Model K] : Field K := by\n have := modelField_of_modelACF p K\n exact fieldOfModelField K\n\ntheorem isAlgClosed_of_model_ACF (p : ℕ) (K : Type*)\n [Field K] [CompatibleRing K] [h : (Theory.ACF p).Model K] :\n IsAlgClosed K := by\n refine IsAlgClosed.of_exists_root _ ?_\n intro p hpm hpi\n have h : K ⊨ genericMonicPolyHasRoot '' {n | 0 < n} :=\n Theory.Model.mono h (by simp [Theory.ACF])\n simp only [Theory.model_iff, Set.mem_image,\n forall_exists_index, and_imp] at h\n have := h _ p.natDegree (natDegree_pos_iff_degree_pos.2\n (degree_pos_of_irreducible hpi)) rfl\n rw [realize_genericMonicPolyHasRoot] at this\n exact this ⟨_, hpm, rfl⟩\n\ntheorem ACF_isSatisfiable {p : ℕ} (hp : p.Prime ∨ p = 0) :\n (Theory.ACF p).IsSatisfiable := by\n cases hp with\n | inl hp =>\n have : Fact p.Prime := ⟨hp⟩\n let _ := compatibleRingOfRing (AlgebraicClosure (ZMod p))\n exact ⟨⟨AlgebraicClosure (ZMod p)⟩⟩\n | inr hp =>\n subst hp\n let _ := compatibleRingOfRing (AlgebraicClosure ℚ)\n exact ⟨⟨AlgebraicClosure ℚ⟩⟩\n\nopen Cardinal\n\n/-- The Theory `Theory.ACF p` is `κ`-categorical whenever `κ` is an uncountable cardinal. -/\n\nTarget:\ntheorem ACF_categorical {p : ℕ} (κ : Cardinal) (hκ : ℵ₀ < κ) :\n Categorical κ (Theory.ACF p) :=\n\nProof body:\n","rejected":"```lean\nby\n rintro ⟨M⟩ ⟨N⟩ hM hN\n let _ := fieldOfModelACF p M\n have := modelField_of_modelACF p M\n let _ := compatibleRingOfModelField M\n have := isAlgClosed_of_model_ACF p M\n have := charP_of_model_fieldOfChar p M\n let _ := fieldOfModelACF p N\n have := modelField_of_modelACF p N\n let _ := compatibleRingOfModelField N\n have := isAlgClosed_of_model_ACF p N\n have := charP_of_model_fieldOfChar p N\n constructor\n refine languageEquivEquivRingEquiv.symm ?_\n apply Classical.choice\n refine IsAlgClosed.ringEquiv_of_equiv_of_char_eq p ?_ ?_\n · rw [hM]; exact hκ\n · rw [← Cardinal.eq, hM, hN]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"ModelTheory/Algebra","family_id":"acf_categorical","file_id":"mathlib/Mathlib/ModelTheory/Algebra/Field/IsAlgClosed.lean","sample_id":"5e424902350257d28f8d0de8d4216b305427715a24efd145390730ba5c4764ec"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d7573e98ab467c9ebb0ea890ea601c33d6bf0baa129280ebf592e621a6c225ee","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c5cad4216866365ae0ea54d13266b73c5ad56f1d75ce0919d93719df0fd07b38","source_sha256":"1772ebc6d5f489fb8a42b880ceafc783ce77133acd1e06ebadf2800bb4211ccd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · intro _ φ\n have sq : CommSq φ.left i p φ.right := CommSq.mk φ.w\n exact ⟨{ l := sq.lift }⟩\n · intro h\n exact ⟨fun {f g} sq ↦ ⟨h (Arrow.homMk f g sq.w)⟩⟩","hard_negative":false,"metrics":{"chosen_tokens":61,"rejected_tokens":3,"token_jaccard":0.057143,"token_length_ratio":0.04918},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"5ef8e7da8b60de1cb2defa1024256d64f4e2f4437e998fe6ba0ad1c38cff026b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.CommSq\npublic import Mathlib.CategoryTheory.Retract\n\nNamespace:\nCategoryTheory.Arrow\n\nLocal context:\n/-\nCopyright (c) 2021 Jakob Scholbach. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob Scholbach, Joël Riou\n-/\n/-!\n# Lifting properties\n\nThis file defines the lifting property of two morphisms in a category and\nshows basic properties of this notion.\n\n## Main results\n- `HasLiftingProperty`: the definition of the lifting property\n\n## Tags\nlifting property\n\n## TODO\n1) direct/inverse images, adjunctions\n\n-/\n\n@[expose] public section\n\nuniverse v\n\nnamespace CategoryTheory\n\nopen Category\n\nvariable {C : Type*} [Category* C] {A B B' X Y Y' : C} (i : A ⟶ B) (i' : B ⟶ B') (p : X ⟶ Y)\n (p' : Y ⟶ Y')\n\n/-- `HasLiftingProperty i p` means that `i` has the left lifting\nproperty with respect to `p`, or equivalently that `p` has\nthe right lifting property with respect to `i`. -/\n@[to_dual self (reorder := A Y, B X, i p)]\nclass HasLiftingProperty : Prop where\n /-- Unique field expressing that any commutative square built from `f` and `g` has a lift -/\n sq_hasLift : ∀ {f : A ⟶ X} {g : B ⟶ Y} (sq : CommSq f i p g), sq.HasLift\n\nattribute [to_dual self] HasLiftingProperty.sq_hasLift\nattribute [to_dual self (reorder := A Y, B X, i p, sq_hasLift (f g))] HasLiftingProperty.mk\n\n@[to_dual self]\ninstance (priority := 100) sq_hasLift_of_hasLiftingProperty {f : A ⟶ X} {g : B ⟶ Y}\n (sq : CommSq f i p g) [hip : HasLiftingProperty i p] : sq.HasLift := hip.sq_hasLift _\n\nnamespace HasLiftingProperty\n\nvariable {i p}\n\n@[to_dual self]\ntheorem op (h : HasLiftingProperty i p) : HasLiftingProperty p.op i.op :=\n ⟨fun {f} {g} sq => by\n simp only [CommSq.HasLift.iff_unop, Quiver.Hom.unop_op]\n infer_instance⟩\n\n@[to_dual self]\ntheorem unop {A B X Y : Cᵒᵖ} {i : A ⟶ B} {p : X ⟶ Y} (h : HasLiftingProperty i p) :\n HasLiftingProperty p.unop i.unop :=\n ⟨fun {f} {g} sq => by\n rw [CommSq.HasLift.iff_op]\n simp only [Quiver.Hom.op_unop]\n infer_instance⟩\n\n@[to_dual self]\ntheorem iff_op : HasLiftingProperty i p ↔ HasLiftingProperty p.op i.op :=\n ⟨op, unop⟩\n\n@[to_dual self]\ntheorem iff_unop {A B X Y : Cᵒᵖ} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty p.unop i.unop :=\n ⟨unop, op⟩\n\nvariable (i p)\n\n@[to_dual of_right_iso]\ninstance (priority := 100) of_left_iso [IsIso i] : HasLiftingProperty i p :=\n ⟨fun {f} {g} sq =>\n CommSq.HasLift.mk'\n { l := inv i ≫ f\n fac_left := by simp only [IsIso.hom_inv_id_assoc]\n fac_right := by simp only [sq.w, assoc, IsIso.inv_hom_id_assoc] }⟩\n\n@[to_dual of_comp_right]\ninstance of_comp_left [HasLiftingProperty i p] [HasLiftingProperty i' p] :\n HasLiftingProperty (i ≫ i') p :=\n ⟨fun {f} {g} sq => by\n have fac := sq.w\n rw [assoc] at fac\n exact\n CommSq.HasLift.mk'\n { l := (CommSq.mk (CommSq.mk fac).fac_right).lift\n fac_left := by simp only [assoc, CommSq.fac_left]\n fac_right := by simp only [CommSq.fac_right] }⟩\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) [hip : HasLiftingProperty i p] :\n HasLiftingProperty i' p := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') [hip : HasLiftingProperty i p] : HasLiftingProperty i p' := by\n rw [Arrow.iso_w' e]\n infer_instance\n\ntheorem iff_of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty i' p := by\n constructor <;> intro\n exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]\n\ntheorem iff_of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') : HasLiftingProperty i p ↔ HasLiftingProperty i p' := by\n constructor <;> intro\n exacts [of_arrow_iso_right i e, of_arrow_iso_right i e.symm]\n\nend HasLiftingProperty\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma RetractArrow.leftLiftingProperty\n {X Y Z W Z' W' : C} {g : Z ⟶ W} {g' : Z' ⟶ W'}\n (h : RetractArrow g' g) (f : X ⟶ Y) [HasLiftingProperty g f] : HasLiftingProperty g' f where\n sq_hasLift := fun {u v} sq ↦ by\n have sq' : CommSq (h.r.left ≫ u) g f (h.r.right ≫ v) := by simp only [Arrow.mk_left,\n Arrow.mk_right, Category.assoc, sq.w, Arrow.w_mk_right_assoc, Arrow.mk_hom, CommSq.mk]\n exact\n ⟨⟨{ l := h.i.right ≫ sq'.lift\n fac_left := by\n simp only [← h.i_w_assoc, sq'.fac_left, h.retract_left_assoc,\n Arrow.mk_left, Category.id_comp]}⟩⟩\n\nset_option backward.isDefEq.respectTransparency false in\nlemma RetractArrow.rightLiftingProperty\n {X Y Z W X' Y' : C} {f : X ⟶ Y} {f' : X' ⟶ Y'}\n (h : RetractArrow f' f) (g : Z ⟶ W) [HasLiftingProperty g f] : HasLiftingProperty g f' where\n sq_hasLift := fun {u v} sq ↦\n have sq' : CommSq (u ≫ h.i.left) g f (v ≫ h.i.right) :=\n ⟨by rw [← Category.assoc, ← sq.w, Category.assoc, RetractArrow.i_w, Category.assoc]⟩\n ⟨⟨{ l := sq'.lift ≫ h.r.left}⟩⟩\n\nnamespace Arrow\n\n/-- Given a morphism `φ : f ⟶ g` in the category `Arrow C`, this is an\nabbreviation for the `CommSq.LiftStruct` structure for\nthe square corresponding to `φ`. -/\nabbrev LiftStruct {f g : Arrow C} (φ : f ⟶ g) := (CommSq.mk φ.w).LiftStruct\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma hasLiftingProperty_iff {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔\n ∀ (φ : Arrow.mk i ⟶ Arrow.mk p), Nonempty (LiftStruct φ) :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/LiftingProperties","family_id":"hasliftingproperty_iff","file_id":"mathlib/Mathlib/CategoryTheory/LiftingProperties/Basic.lean","sample_id":"c5cad4216866365ae0ea54d13266b73c5ad56f1d75ce0919d93719df0fd07b38"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b2b45bfa4e251883ab7a5e0cbd8618eb6f23a0fac262eba0c4598d338a105687","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"134fa4fdbd843d071105bda31cac83dcad1a138f21728802c1b581e7e2cb62aa","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"24c06f9821ae0c44026381d19c9a7d6637451f360d79555039e9eed1830bf721","source_sha256":"b902977d92fdb60e75262beb7f7dae55dab7502621bf1ab6ee39012ed97a51a9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases e\n cases e'\n subst h\n rfl","hard_negative":false,"metrics":{"chosen_tokens":8,"rejected_tokens":13,"token_jaccard":0.583333,"token_length_ratio":1.625},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"603491e07763783a85f6843637255fa0af6029347f6dbb71360d99766d42200c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Category.Preorder\npublic import Mathlib.CategoryTheory.Functor.Category\npublic import Mathlib.CategoryTheory.Types.Basic\npublic import Mathlib.Order.SuccPred.Limit\n\nNamespace:\nCategoryTheory.Functor.WellOrderInductionData.Extension\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Limits of inverse systems indexed by well-ordered types\n\nGiven a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type,\nwe introduce a structure `F.WellOrderInductionData` which allows\nto show that the map `F.sections → F.obj (op ⊥)` is surjective.\n\nThe data and properties in `F.WellOrderInductionData` consist of a\nsection to the maps `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal,\nand, when `j` is limit, a section to the canonical map from `F.obj (op j)`\nto the type of compatible families of elements in `F.obj (op i)` for `i < j`.\n\nIn other words, from `val₀ : F.obj (op ⊥)`, a term `d : F.WellOrderInductionData`\nallows the construction, by transfinite induction, of a section of `F`\nwhich restricts to `val₀`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nnamespace CategoryTheory\n\nopen Opposite\n\nnamespace Functor\n\nvariable {J : Type u} [LinearOrder J] [SuccOrder J] (F : Jᵒᵖ ⥤ Type v)\n\n/-- Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type, this data\nallows to construct a section of `F` from an element in `F.obj (op ⊥)`,\nsee `WellOrderInductionData.sectionsMk`. -/\nstructure WellOrderInductionData where\n /-- A section `F.obj (op j) → F.obj (op (Order.succ j))` to the restriction\n `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal. -/\n succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) : F.obj (op (Order.succ j))\n map_succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) :\n F.map (homOfLE (Order.le_succ j)).op (succ j hj x) = x\n /-- When `j` is a limit element, and `x` is a compatible family of elements\n in `F.obj (op i)` for all `i < j`, this is a lifting to `F.obj (op j)`. -/\n lift (j : J) (hj : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections) :\n F.obj (op j)\n map_lift (j : J) (hj : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections)\n (i : J) (hi : i < j) :\n F.map (homOfLE hi.le).op (lift j hj x) = x.val (op ⟨i, hi⟩)\n\nnamespace WellOrderInductionData\n\nvariable {F} in\n/-- Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type,\nthis is a constructor for `F.WellOrderInductionData` which does not take\ndata as inputs but proofs of the existence of certain elements. -/\nnoncomputable def ofExists\n (h₁ : ∀ (j : J) (_ : ¬IsMax j), Function.Surjective (F.map (homOfLE (Order.le_succ j)).op))\n (h₂ : ∀ (j : J) (_ : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections),\n ∃ (y : F.obj (op j)), ∀ (i : J) (hi : i < j),\n F.map (homOfLE hi.le).op y = x.val (op ⟨i, hi⟩)) :\n F.WellOrderInductionData where\n succ j hj x := (h₁ j hj x).choose\n map_succ j hj x := (h₁ j hj x).choose_spec\n lift j hj x := (h₂ j hj x).choose\n map_lift j hj x := (h₂ j hj x).choose_spec\n\nvariable {F} (d : F.WellOrderInductionData) [OrderBot J]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- Given `d : F.WellOrderInductionData`, `val₀ : F.obj (op ⊥)` and `j : J`,\nthis is the data of an element `val : F.obj (op j)` such that the induced\ncompatible family of elements in all `F.obj (op i)` for `i ≤ j`\nis determined by `val₀` and the choice of \"liftings\" given by `d`. -/\nstructure Extension (val₀ : F.obj (op ⊥)) (j : J) where\n /-- An element in `F.obj (op j)`, which, by restriction, induces elements\n in `F.obj (op i)` for all `i ≤ j`. -/\n val : F.obj (op j)\n map_zero : F.map (homOfLE bot_le).op val = val₀\n map_succ (i : J) (hi : i < j) :\n F.map (homOfLE (Order.succ_le_of_lt hi)).op val =\n d.succ i (not_isMax_iff.2 ⟨_, hi⟩) (F.map (homOfLE hi.le).op val)\n map_limit (i : J) (hi : Order.IsSuccLimit i) (hij : i ≤ j) :\n F.map (homOfLE hij).op val = d.lift i hi\n { val := fun ⟨⟨k, hk⟩⟩ ↦ F.map (homOfLE (hk.le.trans hij)).op val\n property := fun f ↦ by\n dsimp\n rw [← comp_apply, ← map_comp]\n rfl }\n\nnamespace Extension\n\nvariable {d} {val₀ : F.obj (op ⊥)}\n\n/-- An element in `d.Extension val₀ j` induces an element in `d.Extension val₀ i` when `i ≤ j`. -/\n@[simps]\ndef ofLE {j : J} (e : d.Extension val₀ j) {i : J} (hij : i ≤ j) : d.Extension val₀ i where\n val := F.map (homOfLE hij).op e.val\n map_zero := by\n rw [← comp_apply, ← map_comp]\n exact e.map_zero\n map_succ k hk := by\n rw [← comp_apply, ← map_comp, ← comp_apply, ← map_comp, ← op_comp, ← op_comp,\n homOfLE_comp, homOfLE_comp, e.map_succ k (lt_of_lt_of_le hk hij)]\n map_limit k hk hki := by\n rw [← comp_apply, ← map_comp, ← op_comp, homOfLE_comp,\n e.map_limit k hk (hki.trans hij)]\n congr\n ext ⟨l, hl⟩\n dsimp\n rw [← comp_apply, ← map_comp]\n rfl\n\nTarget:\nlemma val_injective {j : J} {e e' : d.Extension val₀ j} (h : e.val = e'.val) : e = e' :=\n\nProof body:\n","rejected":"by\n cases e\n cases e'\n subst h\n rfl\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/SmallObject","family_id":"val_injective","file_id":"mathlib/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean","sample_id":"24c06f9821ae0c44026381d19c9a7d6637451f360d79555039e9eed1830bf721"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b07da493aef42dcb65829c07e1ff4bc0526efd92ad0c23db6a3eafe98a05cab2","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ee0d60117e2bd6b50781085cb3777fe25d3de0a7b2ab516ed7096cf33c67614b","source_sha256":"2eab1d38ccdaa92e1a432add87cdb2bed24c758ae0a16e06939eabd2b19764ab","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases h₁.lt_or_gt with h₁ | h₁\n · have : 1 - x ^ 2 < 0 := by nlinarith [h₁]\n rw [sqrt_eq_zero'.2 this.le, div_zero]\n have : arcsin =ᶠ[𝓝 x] fun _ => -(π / 2) :=\n (gt_mem_nhds h₁).mono fun y hy => arcsin_of_le_neg_one hy.le\n exact ⟨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,\n contDiffAt_const.congr_of_eventuallyEq this⟩\n rcases h₂.lt_or_gt with h₂ | h₂\n · have : 0 < √(1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h₁, h₂])\n simp only [← cos_arcsin, one_div] at this ⊢\n exact ⟨sinPartialHomeomorph.hasStrictDerivAt_symm ⟨h₁, h₂⟩ this.ne' (hasStrictDerivAt_sin _),\n sinPartialHomeomorph.contDiffAt_symm_deriv this.ne' ⟨h₁, h₂⟩ (hasDerivAt_sin _)\n contDiff_sin.contDiffAt⟩\n · have : 1 - x ^ 2 < 0 := by nlinarith [h₂]\n rw [sqrt_eq_zero'.2 this.le, div_zero]\n have : arcsin =ᶠ[𝓝 x] fun _ => π / 2 := (lt_mem_nhds h₂).mono fun y hy => arcsin_of_one_le hy.le\n exact ⟨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,\n contDiffAt_const.congr_of_eventuallyEq this⟩","hard_negative":true,"metrics":{"chosen_tokens":260,"rejected_tokens":8,"token_jaccard":0.054054,"token_length_ratio":0.030769},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"618bd42a669c68ec090cfdafb48f6fdc142bdcf3a4bb5d81d9b35cdf60ed4937","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse\npublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson\n-/\n/-!\n# derivatives of the inverse trigonometric functions\n\nDerivatives of `arcsin` and `arccos`.\n-/\n\npublic section\n\nnoncomputable section\n\nopen scoped Topology Filter Real ContDiff\nopen Set\n\nnamespace Real\n\nsection Arcsin\n\nTarget:\ntheorem deriv_arcsin_aux {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n HasStrictDerivAt arcsin (1 / √(1 - x ^ 2)) x ∧ ContDiffAt ℝ ω arcsin x :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"bb4fa57691239a0819cff3447d834c95488902a6252e3a6067cdfeb6a2584127","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/SpecialFunctions","family_id":"deriv_arcsin_aux","file_id":"mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean","sample_id":"ee0d60117e2bd6b50781085cb3777fe25d3de0a7b2ab516ed7096cf33c67614b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6b9ba8ebfcb9049b64569a7db30b67163c838c32da10d030480628c29d1eff28","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c1f16364ffdc2c1a01f042273d62c386b6e7ece026f68536c84200e35187712","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"243c98229641e910a0850d437221c871bd2ed1b94fc5341b71a80727fd9cec39","source_sha256":"db51e70d893ac72ef745f06c7b126a15551165b529f4f81338b62c90aa8f3470","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩\n rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩\n exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)","hard_negative":false,"metrics":{"chosen_tokens":39,"rejected_tokens":46,"token_jaccard":0.923077,"token_length_ratio":1.179487},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"622af26bc9b1330894127db61579761027f1ff9cd4a8613d75cbe0f4c6ece400","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Interval.Set.OrdConnectedComponent\npublic import Mathlib.Topology.Order.Basic\npublic import Mathlib.Topology.Separation.Regular\n\nNamespace:\nSet\n\nLocal context:\n/-\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/-!\n# Linear order is a completely normal Hausdorff topological space\n\nIn this file we prove that a linear order with order topology is a completely normal Hausdorff\ntopological space.\n-/\n\npublic section\n\n\nopen Filter Set Function OrderDual Topology Interval\n\nvariable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a : X} {s t : Set X}\n\nnamespace Set\n\n@[simp]\n\nTarget:\ntheorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a :=\n\nProof body:\n","rejected":"```lean\nby\n refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩\n rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩\n exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Order","family_id":"ordconnectedcomponent_mem_nhds","file_id":"mathlib/Mathlib/Topology/Order/T5.lean","sample_id":"243c98229641e910a0850d437221c871bd2ed1b94fc5341b71a80727fd9cec39"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"571f2e4ca0c2a7aa28375a5ba134134b5e2d37b43c06df4d4a6341a7a5173f4b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"108e07c7e23e8be21847410919137b4a5ae3c4446d0fe652a7c4666ca98bf98a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fba8170fa1ee067a248954d66a9ec3494bcb3555899fd1dc4f88beebd98dbd49","source_sha256":"31511787b8ee979ad68b270d70d53565c4f726a4fcbb6bab5c8059163486f498","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp","hard_negative":false,"metrics":{"chosen_tokens":26,"rejected_tokens":33,"token_jaccard":0.909091,"token_length_ratio":1.269231},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"62e57c6424e33e6416e99308f7da7a246f39fa424e7239ed2147b80c96b912a9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Finite\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.GroupTheory.Coset.Defs\n\nNamespace:\nDiscreteTiling.PlacedTile\n\nLocal context:\n/-\nCopyright (c) 2026 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Tiles for tilings\n\nThis file defines some basic concepts related to individual tiles for tilings in a discrete context\n(with definitions in a continuous context to be developed separately but analogously).\n\nWork in the field of tilings does not generally try to define or state things in any kind of maximal\ngenerality, so it is necessary to adapt definitions and statements from the literature to produce\nsomething that seems appropriately general for mathlib, covering a wide range of tiling-related\nconcepts found in the literature. Nevertheless, further generalization may prove of use as this work\nis extended in future.\n\nWe work in the context of a space `X` acted on by a group `G`; the action is not required to be\nfaithful, although typically it is. In a discrete context, tiles are expected to cover the space, or\na subset of it being tiled when working with tilings not of the whole space, and the tiles are\npairwise disjoint. In a continuous context, definitions in the literature vary; the tiles may be\nclosed and cover the space with interiors required to be disjoint (as used by Grünbaum and Shephard\nor Goodman-Strauss), or they may be required to be measurable and to partition it up to null sets\n(as used by Greenfeld and Tao).\n\nIn general we are concerned not with a tiling in isolation but with tilings by some protoset of\ntiles; thus we make definitions in the context of such a protoset, where copies of the tiles in the\ntiling must be images of those tiles under the action of an element of the given group.\n\nWhere there are matching rules that say what combinations of tiles are considered as valid, these\nare provided as separate hypotheses where required. Tiles in a protoset are commonly considered in\nthe literature to be marked in some way. When this is simply to distinguish two otherwise identical\ntiles, this is represented by the use of different indices in the protoset. When this is to give a\ntile fewer symmetries than it would otherwise have under the action of the given group, this is\nrepresented by the symmetries specified in the `Prototile` being less than its full stabilizer.\n\nThe group `G` is throughout here a multiplicative group. Additive groups are also used in the\nliterature, typically when based on `ℤ`; to support the use of additive groups, `to_additive` could\nbe used with the theory here.\n\n## Main definitions\n\n* `Prototile G X`: A prototile in `X` as acted on by `G`, carrying the information of a subgroup of\n the stabilizer that says when two copies of the prototile are considered the same.\n\n* `Protoset G X ιₚ`: An indexed family of prototiles.\n\n* `PlacedTile ps`: An image of a tile in the protoset `ps`.\n\n## References\n\n* [Branko Grünbaum and G. C. Shephard, *Tilings and Patterns*][GrunbaumShephard1987]\n* [Chaim Goodman-Strauss, *Open Questions in Tiling*][GoodmanStrauss2000]\n* [Rachel Greenfeld and Terence Tao, *A counterexample to the periodic tiling\n conjecture*][GreenfeldTao2024]\n-/\n\n\n@[expose] public section\n\nnamespace DiscreteTiling\n\nopen Function\nopen scoped Pointwise\n\nvariable {G X ιₚ : Type*} [Group G] [MulAction G X]\n\nvariable (G X) in\n/-- A `Prototile G X` describes a tile in `X`, copies of which under elements of `G` may be used in\ntilings. Two copies related by an element of `symmetries` are considered the same; two copies not so\nrelated, even if they have the same points, are considered distinct. -/\n@[ext] structure Prototile where\n /-- The points in the prototile. Use the coercion to `Set X`, or `∈` on the `Prototile`, rather\n than using `carrier` directly. The coercion cannot use `SetLike` because it does not satisfy\n `coe_injective`. -/\n carrier : Set X\n /-- The group elements considered to be symmetries of the prototile. -/\n symmetries : Subgroup (MulAction.stabilizer G carrier)\n\nnamespace Prototile\n\ninstance : Inhabited (Prototile G X) where\n default := ⟨∅, ⊥⟩\n\ninstance : CoeOut (Prototile G X) (Set X) where\n coe := Prototile.carrier\n\nattribute [coe] carrier\n\ninstance : Membership X (Prototile G X) where\n mem p x := x ∈ (p : Set X)\n\nlemma coe_mk (c s) : (⟨c, s⟩ : Prototile G X) = c := rfl\n\n@[simp] lemma mem_coe {x : X} {p : Prototile G X} : x ∈ (p : Set X) ↔ x ∈ p := Iff.rfl\n\nend Prototile\n\nvariable (G X ιₚ) in\n/-- A `Protoset G X ιₚ` is an indexed family of `Prototile G X`. This is a separate definition\nrather than just using plain functions to facilitate defining associated API that can be used with\ndot notation. -/\n@[ext] structure Protoset where\n /-- The tiles in the protoset. Use the coercion to a function rather than using `tiles`\n directly. -/\n tiles : ιₚ → Prototile G X\n\nnamespace Protoset\n\ninstance : Inhabited (Protoset G X ιₚ) where\n default := ⟨fun _ ↦ default⟩\n\ninstance : CoeFun (Protoset G X ιₚ) (fun _ ↦ ιₚ → Prototile G X) where\n coe := tiles\n\nattribute [coe] tiles\n\nlemma coe_mk (t) : (⟨t⟩ : Protoset G X ιₚ) = t := rfl\n\n@[simp, norm_cast] lemma coe_inj {ps₁ ps₂ : Protoset G X ιₚ} :\n (ps₁ : ιₚ → Prototile G X) = ps₂ ↔ ps₁ = ps₂ :=\n Protoset.ext_iff.symm\n\nlemma coe_injective : Injective (Protoset.tiles : Protoset G X ιₚ → ιₚ → Prototile G X) :=\n fun _ _ ↦ coe_inj.1\n\nend Protoset\n\nvariable {ps : Protoset G X ιₚ}\n\nvariable (ps) in\n/-- A `PlacedTile ps` is an image of a tile in the protoset `p` under an element of the group `G`.\nThis is represented using a quotient so that images under group elements differing only by a\nsymmetry of the tile are equal. -/\n@[ext] structure PlacedTile where\n /-- The index of the tile in the protoset. -/\n index : ιₚ\n /-- The group elements under which this tile is an image. -/\n groupElts : G ⧸ ((ps index).symmetries.map <| Subgroup.subtype _)\n\nnamespace PlacedTile\n\ninstance [Nonempty ιₚ] : Nonempty (PlacedTile ps) := ⟨⟨Classical.arbitrary _, (1 : G)⟩⟩\n\n/-- An induction principle to deduce results for `PlacedTile` from those given an index and an\nelement of `G`, used with `induction pt using PlacedTile.induction_on`. -/\n@[elab_as_elim] protected lemma induction_on {ppt : PlacedTile ps → Prop} (pt : PlacedTile ps)\n (h : ∀ i : ιₚ, ∀ gx : G, ppt ⟨i, gx⟩) : ppt pt := by\n rcases pt with ⟨i, gx⟩\n induction gx using Quotient.inductionOn\n apply h\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using existence of a\ncommon group element. -/\nlemma ext_iff_of_exists {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧ ∃ g, ⟦g⟧ = pt₁.groupElts ∧ ⟦g⟧ = pt₂.groupElts := by\n refine ⟨fun h ↦ ?_, fun ⟨h, g, hg₁, hg₂⟩ ↦ ?_⟩\n · subst h\n simp only [and_self, true_and]\n refine ⟨pt₁.groupElts.out, ?_⟩\n rw [Quotient.out_eq]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at h\n subst h\n ext\n · rfl\n · exact heq_of_eq (hg₁.symm.trans hg₂)\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using equality of\nquotient preimages. -/\nlemma ext_iff_of_preimage {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧\n (Quotient.mk _) ⁻¹' {pt₁.groupElts} = (Quotient.mk _) ⁻¹' {pt₂.groupElts} := by\n refine ⟨fun h ↦ ?_, fun ⟨hi, hq⟩ ↦ ?_⟩\n · subst h\n simp only [and_self]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at hi\n subst hi\n ext\n · rfl\n · exact heq_of_eq (Set.singleton_eq_singleton_iff.1\n ((Set.preimage_eq_preimage Quotient.mk''_surjective).1 hq))\n\n/-- Coercion from a `PlacedTile` to a set of points. Use the coercion rather than using `coeSet`\ndirectly. -/\n@[coe] def coeSet (pt : PlacedTile ps) : Set X :=\n Quotient.liftOn' pt.groupElts (fun g ↦ g • (ps pt.index : Set X))\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n rw [eq_comm, ← inv_smul_eq_iff, smul_smul, ← MulAction.mem_stabilizer_iff]\n exact SetLike.le_def.1 (Subgroup.map_subtype_le _) r\n\ninstance : CoeOut (PlacedTile ps) (Set X) where\n coe := coeSet\n\ninstance : Membership X (PlacedTile ps) where\n mem p x := x ∈ (p : Set X)\n\n@[simp] lemma mem_coe {x : X} {pt : PlacedTile ps} : x ∈ (pt : Set X) ↔ x ∈ pt := Iff.rfl\n\nlemma coe_mk_mk (i : ιₚ) (g : G) : (⟨i, ⟦g⟧⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_mk_coe (i : ιₚ) (g : G) : (⟨i, g⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nTarget:\nlemma coe_nonempty_iff {pt : PlacedTile ps} :\n (pt : Set X).Nonempty ↔ (ps pt.index : Set X).Nonempty :=\n\nProof body:\n","rejected":"```lean\nby\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Tiling","family_id":"coe_nonempty_iff","file_id":"mathlib/Mathlib/Combinatorics/Tiling/Tile.lean","sample_id":"fba8170fa1ee067a248954d66a9ec3494bcb3555899fd1dc4f88beebd98dbd49"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8c9ffbc471f68fc3f445ad52713700b4995dff84872f3c48386a0b12cb5d68cf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"22f376f9d565f15d4061f95d18809e55ffc0e90f2f3798a62d958675e8e569b3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c21a2a8a385ed1f82fa776c2dd121b8cd33ffa2ee66840e401e8610d14e4e6e5","source_sha256":"6ca40a9a028dbe37b0e6d35f519e15fb40bd243ba89a07bbe3689aea9c6deaf6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let e : R ≃ₐ[R] (Localization.AtPrime (maximalIdeal R)) :=\n IsLocalization.atUnits R (maximalIdeal R).primeCompl (fun x ↦ by simpa using! fun a ↦ a)\n exact IsRegularLocalRing.of_ringEquiv e.toRingEquiv.symm","hard_negative":true,"metrics":{"chosen_tokens":52,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.057692},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"633134e6e27113e90e7952c390bac03208b8b3b4a6d7da3b1debd14fabb081cd","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.SpanRankOperations\npublic import Mathlib.RingTheory.DedekindDomain.Dvr\npublic import Mathlib.RingTheory.Ideal.KrullsHeightTheorem\npublic import Mathlib.RingTheory.KrullDimension.Field\npublic import Mathlib.RingTheory.KrullDimension.PID\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# Regular local rings\n\nFor a Noetherian local ring `R`, we define `IsRegularLocalRing` as\n`(maximalIdeal R).spanFinrank = ringKrullDim R`. This definition is equivalent to\nthe dimension of the cotangent space over the residue field being equal to `ringKrullDim R`,\n(see `IsRegularLocalRing.iff_finrank_cotangentSpace`).\n\nFor the next section, we define regular rings as Noetherian rings whose localization at every prime\nare regular local rings.\n(Note that a regular local ring is a regular ring, but this is not immediate under this definition).\n\n# Main Definition and Results\n\n* `IsRegularLocalRing` : A Noetherian local ring is regular if\n `(maximalIdeal R).spanFinrank = ringKrullDim R`,\n i.e. its maximal ideal can be generated by `dim R` elements.\n\n* `IsRegularLocalRing.iff_finrank_cotangentSpace` : the equivalence of `IsRegularLocalRing` and\n `Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R`\n\n* `IsRegularRing` : A noetherian ring is regular if its localization at any prime\n `IsRegularLocalRing`.\n\n## TODO\nShow that regular local rings are regular under this definition.\nThis follows from localizations of regular local rings being regular (@Thmoas-Guan).\n\n-/\n\npublic section\n\nopen IsLocalRing\n\n/-- A Noetherian local ring is said to be regular if its maximal ideal\ncan be generated by `dim R` elements. -/\n@[stacks 00KU]\nclass IsRegularLocalRing (R : Type*) [CommRing R] : Prop extends\n IsLocalRing R, IsNoetherianRing R where\n spanFinrank_maximalIdeal : (maximalIdeal R).spanFinrank = ringKrullDim R\n\nvariable (R : Type*) [CommRing R]\n\nlemma isRegularLocalRing_iff [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ (maximalIdeal R).spanFinrank = ringKrullDim R :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nnamespace IsRegularLocalRing\n\nlemma of_spanFinrank_maximalIdeal_le [IsLocalRing R] [IsNoetherianRing R]\n (le : (maximalIdeal R).spanFinrank ≤ ringKrullDim R) : IsRegularLocalRing R :=\n (isRegularLocalRing_iff _).mpr (le_antisymm le (ringKrullDim_le_spanFinrank_maximalIdeal R))\n\nvariable {R} in\nlemma of_ringEquiv [IsRegularLocalRing R] {R' : Type*} [CommRing R']\n (e : R ≃+* R') : IsRegularLocalRing R' := by\n have := e.isLocalRing\n have := isNoetherianRing_of_ringEquiv R e\n rwa [isRegularLocalRing_iff, ← ringKrullDim_eq_of_ringEquiv e, ← map_ringEquiv_maximalIdeal e,\n Ideal.spanFinrank_map_eq_of_ringEquiv, ← isRegularLocalRing_iff]\n\nlemma iff_finrank_cotangentSpace [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R := by\n rw [isRegularLocalRing_iff, spanFinrank_maximalIdeal_eq_finrank_cotangentSpace]\n\ninstance [IsLocalRing R] [IsDomain R] [IsPrincipalIdealRing R] : IsRegularLocalRing R := by\n by_cases isf : IsField R\n · let := isf.toField\n simp [isRegularLocalRing_iff, maximalIdeal_eq_bot]\n · apply of_spanFinrank_maximalIdeal_le\n rcases IsPrincipalIdealRing.principal (maximalIdeal R) with ⟨x, hx⟩\n simpa only [(IsPrincipalIdealRing.ringKrullDim_eq_one R) isf,\n Nat.cast_le_one, ← Set.ncard_singleton x, hx] using\n Submodule.spanFinrank_span_le_ncard_of_finite (Set.finite_singleton x)\n\nend IsRegularLocalRing\n\n/-- A noetherian ring is regular if its localization at any prime `IsRegularLocalRing`. -/\nclass IsRegularRing (R : Type*) [CommRing R] : Prop extends IsNoetherianRing R where\n isRegularLocalRing_localization (p : Ideal R) [p.IsPrime] :\n IsRegularLocalRing (Localization.AtPrime p)\n\nattribute [instance low] IsRegularRing.isRegularLocalRing_localization\n\nsection IsRegularRing\n\nvariable {R} in\nlemma isRegularRing_iff [IsNoetherianRing R] : IsRegularRing R ↔\n ∀ (p : Ideal R) [p.IsPrime], IsRegularLocalRing (Localization.AtPrime p) :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nvariable {R} in\nlemma IsRegularRing.of_ringEquiv {R' : Type*} [CommRing R'] (e : R ≃+* R') [IsRegularRing R] :\n IsRegularRing R' := by\n have := isNoetherianRing_of_ringEquiv R e\n rw [isRegularRing_iff]\n intro p hp\n exact IsRegularLocalRing.of_ringEquiv <| IsLocalization.ringEquivOfRingEquiv\n (Localization.AtPrime (p.comap e)) (Localization.AtPrime p) e (e.map_primeCompl_comap_eq p)\n\nTarget:\nlemma IsRegularLocalRing.of_isRegularRing_of_isLocalRing [IsLocalRing R] [IsRegularRing R] :\n IsRegularLocalRing R :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_c21a2a8a385e","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"ff9ce561ccd89dc031c762e465cd301e65337a77483da8606276cef57dbc5a7f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RegularLocalRing","family_id":"isregularlocalring","file_id":"mathlib/Mathlib/RingTheory/RegularLocalRing/Defs.lean","sample_id":"c21a2a8a385ed1f82fa776c2dd121b8cd33ffa2ee66840e401e8610d14e4e6e5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2be18efe99c4ae42b8de0c676e58e87f9015e199d9133270c6a71b933331634b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cb9101111613f00a6ac629dd90521a727388dd85661ae651e274e0590fdb77bd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"985ba7346fccc1a65a8f480180d834413f4f20604bb2c10992ce8f009277a68e","source_sha256":"84b3eb51873c8f75cb452a06b56a659fd9d61a2ae61434709bf59a8c70a536c6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [uncountable_iff_not_countable]\n exact mt (@Countable.toSmall α) h","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":5,"token_jaccard":0.176471,"token_length_ratio":0.333333},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"63698393994d7f2e478dfdafe00b28bc1fe4559179bb41275a866278512daff3","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Small.Basic\npublic import Mathlib.Data.Countable.Defs\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# All countable types are small.\n\nThat is, any countable type is equivalent to a type in any universe.\n-/\n\npublic section\n\nuniverse w v\n\ninstance (priority := 100) Countable.toSmall (α : Type v) [Countable α] : Small.{w} α :=\n let ⟨_, hf⟩ := exists_injective_nat α\n small_of_injective hf\n\nTarget:\ntheorem Uncountable.of_not_small {α : Type v} (h : ¬ Small.{w} α) : Uncountable α :=\n\nProof body:\n","rejected":"by\n exact Uncountable.of_not_small","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"d39f770cce89a07ac65b30db29ab6ef309d1830f06477447d43015e54164cb13","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Countable","family_id":"uncountable","file_id":"mathlib/Mathlib/Data/Countable/Small.lean","sample_id":"985ba7346fccc1a65a8f480180d834413f4f20604bb2c10992ce8f009277a68e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0faf7a2130d4dc72923bc3359e764c29309cb12d71b9edde4640015b1814f981","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c693da27c01f2761aed66594d655f978980d479028970c91f11d6603ed2c2d04","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":true,"metrics":{"chosen_tokens":2,"rejected_tokens":3,"token_jaccard":0.25,"token_length_ratio":1.5},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"65c1f29040cb451bc62f67a9d64c03b1b90791b16b61f4bf0c6da72ffb8384ad","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g := by\n ext a\n exact DFunLike.congr_fun h a\n\n@[norm_cast]\ntheorem coe_distribMulActionHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₑ+[φ] B) = ⟨⟨f, h₁⟩, h₂, h₃⟩ := by\n rfl\n\n@[norm_cast]\n\nTarget:\ntheorem coe_mulHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₙ* B) = ⟨f, h₄⟩ :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_c693da27c01f","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"7b91f94cfb4fb09c65a7ee1e0d45fd566db6c13c4c72a9ae7de2cb124ee989c9","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_mulhom_mk","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"c693da27c01f2761aed66594d655f978980d479028970c91f11d6603ed2c2d04"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"24e69b4a5d1f91b608cf803c12f8372842f93b3aebd0d01b7b5730b29bb344c6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d6254599aa2053b301466ff29689af55e56309108e98c7788811790f9dfc446f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b3f4512a8bcd1cc454eb7911d427168e1c28820898022e335d1ea5ef32a3f344","source_sha256":"d6b794456e23e246e8cc7c7bd63fa80b7c1aa31c3e4cd321a6c0cedd6df705b7","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · rintro rfl x\n exact (gc x y).symm\n · intro H\n exact ((H <| u y).mpr (gc.l_u_le y)).antisymm ((gc _ _).mp <| (H z).mp le_rfl)","hard_negative":true,"metrics":{"chosen_tokens":55,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.054545},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"65da30ac4fafd442d5e0af290654b6474194996d4b04ac954e8a47115e09cec7","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.BoundedOrder.Basic\npublic import Mathlib.Order.Monotone.Basic\n\nNamespace:\nGaloisConnection\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\n/-!\n# Galois connections, insertions and coinsertions\n\nGalois connections are order-theoretic adjoints, i.e. a pair of functions `u` and `l`,\nsuch that `∀ a b, l a ≤ b ↔ a ≤ u b`.\n\n## Main definitions\n\n* `GaloisConnection`: A Galois connection is a pair of functions `l` and `u` satisfying\n `l a ≤ b ↔ a ≤ u b`. They are special cases of adjoint functors in category theory,\n but do not depend on the category theory library in mathlib.\n* `GaloisInsertion`: A Galois insertion is a Galois connection where `l ∘ u = id`\n* `GaloisCoinsertion`: A Galois coinsertion is a Galois connection where `u ∘ l = id`\n-/\n\n@[expose] public section\n\nassert_not_exists CompleteLattice RelIso\n\nopen Function OrderDual Set\n\nuniverse u v w x\n\nvariable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {κ : ι → Sort*} {a₁ a₂ : α}\n {b₁ b₂ : β}\n\n/-- A Galois connection is a pair of functions `l` and `u` satisfying\n`l a ≤ b ↔ a ≤ u b`. They are special cases of adjoint functors in category theory,\nbut do not depend on the category theory library in mathlib. -/\n@[to_dual self (reorder := α β, 3 4, l u)]\ndef GaloisConnection [Preorder α] [Preorder β] (l : α → β) (u : β → α) :=\n ∀ a b, l a ≤ b ↔ a ≤ u b\n\nto_dual_insert_cast GaloisConnection := by\n rw [forall_comm]; simp only [Iff.comm]\n\nto_dual_name_hint U L\n\nnamespace GaloisConnection\n\nsection\n\nvariable [Preorder α] [Preorder β] {l : α → β} {u : β → α}\n\n@[to_dual self (reorder := α β, 3 4, l u, hu hl, h_u_l h_l_u)]\ntheorem monotone_intro (hu : Monotone u) (hl : Monotone l) (h_u_l : ∀ a, a ≤ u (l a))\n (h_l_u : ∀ a, l (u a) ≤ a) : GaloisConnection l u := fun _ _ =>\n ⟨fun h => (h_u_l _).trans (hu h), fun h => (hl h).trans (h_l_u _)⟩\n\n@[to_dual self]\nprotected theorem dual {l : α → β} {u : β → α} (gc : GaloisConnection l u) :\n GaloisConnection (OrderDual.toDual ∘ u ∘ OrderDual.ofDual)\n (OrderDual.toDual ∘ l ∘ OrderDual.ofDual) :=\n fun a b => (gc b a).symm\n\nvariable (gc : GaloisConnection l u)\ninclude gc\n\n@[to_dual none]\ntheorem le_iff_le {a : α} {b : β} : l a ≤ b ↔ a ≤ u b :=\n gc _ _\n\n@[to_dual le_u]\ntheorem l_le {a : α} {b : β} : a ≤ u b → l a ≤ b :=\n (gc _ _).mpr\n\n@[to_dual l_u_le]\ntheorem le_u_l (a) : a ≤ u (l a) :=\n gc.le_u <| le_rfl\n\n@[to_dual]\ntheorem monotone_u : Monotone u := fun a _ H => gc.le_u ((gc.l_u_le a).trans H)\n\n@[to_dual]\ntheorem monotone_l_comp_u : Monotone (l ∘ u) := gc.monotone_l.comp gc.monotone_u\n\n/-- If `(l, u)` is a Galois connection, then the relation `x ≤ u (l y)` is a transitive relation.\nIf `l` is a closure operator (`Submodule.span`, `Subgroup.closure`, ...) and `u` is the coercion to\n`Set`, this reads as \"if `U` is in the closure of `V` and `V` is in the closure of `W` then `U` is\nin the closure of `W`\". -/\n@[to_dual l_u_le_trans]\ntheorem le_u_l_trans {x y z : α} (hxy : x ≤ u (l y)) (hyz : y ≤ u (l z)) : x ≤ u (l z) :=\n hxy.trans (gc.monotone_u <| gc.l_le hyz)\n\nend\n\nsection PartialOrder\n\nvariable [PartialOrder α] [Preorder β] {l : α → β} {u : β → α} (gc : GaloisConnection l u)\ninclude gc\n\n@[to_dual]\ntheorem u_l_u_eq_u (b : β) : u (l (u b)) = u b :=\n (gc.monotone_u (gc.l_u_le _)).antisymm (gc.le_u_l _)\n\n@[to_dual]\ntheorem u_l_u_eq_u' : u ∘ l ∘ u = u :=\n funext gc.u_l_u_eq_u\n\n@[to_dual]\ntheorem u_unique {l' : α → β} {u' : β → α} (gc' : GaloisConnection l' u') (hl : ∀ a, l a = l' a)\n {b : β} : u b = u' b :=\n le_antisymm (gc'.le_u <| hl (u b) ▸ gc.l_u_le _) (gc.le_u <| (hl (u' b)).symm ▸ gc'.l_u_le _)\n\n/-- If there exists a `b` such that `a = u a`, then `b = l a` is one such element. -/\n@[to_dual /-- If there exists an `b` such that `a = l b`, then `b = u a` is one such element. -/]\ntheorem exists_eq_u (a : α) : (∃ b : β, a = u b) ↔ a = u (l a) :=\n ⟨fun ⟨_, hS⟩ => hS.symm ▸ (gc.u_l_u_eq_u _).symm, fun HI => ⟨_, HI⟩⟩\n\n@[to_dual]\n\nTarget:\ntheorem u_eq {z : α} {y : β} : u y = z ↔ ∀ x, x ≤ z ↔ l x ≤ y :=\n\nProof body:\n","rejected":"by\n exact u_eq","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"2180fda92523b00e0684280323792bf996b11f73be4fd5ec8a096c025285f39a","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/GaloisConnection","family_id":"u_eq","file_id":"mathlib/Mathlib/Order/GaloisConnection/Defs.lean","sample_id":"b3f4512a8bcd1cc454eb7911d427168e1c28820898022e335d1ea5ef32a3f344"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9ae2d83b6a808c7bae8375f991f38020fedde520026e77033201ea33c6afd882","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2cdcc1dd0c4f5dba1df2244028dbe522178ef51a9ac80121eb406c12d554155b","source_sha256":"b1a6de0bf7dd13eb86b75cd8d95aebb591d157a9fea40ceef9dbefb4524b23ba","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine eq_of_le_of_not_lt (krullDimLE_iff (n := 1).mp ?_) fun h ↦ ?_\n · exact krullDimLE_one_iff_of_isPrime_bot.mpr fun I hI hI' ↦ hI'.isMaximal hI\n · have : KrullDimLE 0 R := krullDimLE_iff.mpr (ENat.WithBot.lt_add_one_iff.mp h)\n exact IsDiscreteValuationRing.not_isField R KrullDimLE.isField_of_isDomain","hard_negative":false,"metrics":{"chosen_tokens":62,"rejected_tokens":2,"token_jaccard":0.057143,"token_length_ratio":0.032258},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"6696abc002a24c08c336a3ab2607572ce8750ee7a0dc1189d3400add0223e19b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.DedekindDomain.Basic\npublic import Mathlib.RingTheory.DiscreteValuationRing.Basic\npublic import Mathlib.RingTheory.Finiteness.Ideal\npublic import Mathlib.RingTheory.Ideal.Cotangent\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# Equivalent conditions for DVR\n\nIn `IsDiscreteValuationRing.TFAE`, we show that the following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n- `R` is a discrete valuation ring\n- `R` is a valuation ring\n- `R` is a Dedekind domain\n- `R` is integrally closed with a unique prime ideal\n- `m` is principal\n- `dimₖ m/m² = 1`\n- Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\npublic section\n\n\nvariable (R : Type*) [CommRing R]\n\nopen scoped Multiplicative\n\nopen IsLocalRing Module\n\ntheorem exists_maximalIdeal_pow_eq_of_principal [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h' : (maximalIdeal R).IsPrincipal) (I : Ideal R) (hI : I ≠ ⊥) :\n ∃ n : ℕ, I = maximalIdeal R ^ n := by\n by_cases h : IsField R\n · let _ := h.toField\n exact ⟨0, by simp [(eq_bot_or_eq_top I).resolve_left hI]⟩\n classical\n obtain ⟨x, hx : _ = Ideal.span _⟩ := h'\n by_cases hI' : I = ⊤\n · use 0; rw [pow_zero, hI', Ideal.one_eq_top]\n have H : ∀ r : R, ¬IsUnit r ↔ x ∣ r := fun r =>\n (SetLike.ext_iff.mp hx r).trans Ideal.mem_span_singleton\n have : x ≠ 0 := by\n rintro rfl\n apply Ring.ne_bot_of_isMaximal_of_not_isField (maximalIdeal.isMaximal R) h\n simp [hx]\n have hx' := IsDiscreteValuationRing.irreducible_of_span_eq_maximalIdeal x this hx\n have H' : ∀ r : R, r ≠ 0 → r ∈ nonunits R → ∃ n : ℕ, Associated (x ^ n) r := by\n intro r hr₁ hr₂\n obtain ⟨f, hf₁, rfl, hf₂⟩ := (WfDvdMonoid.not_unit_iff_exists_factors_eq r hr₁).mp hr₂\n have : ∀ b ∈ f, Associated x b := by\n intro b hb\n exact Irreducible.associated_of_dvd hx' (hf₁ b hb) ((H b).mp (hf₁ b hb).1)\n clear hr₁ hr₂ hf₁\n induction f using Multiset.induction with\n | empty => exact (hf₂ rfl).elim\n | cons fa fs fh => ?_\n rcases eq_or_ne fs ∅ with (rfl | hf')\n · use 1\n rw [pow_one, Multiset.prod_cons, Multiset.empty_eq_zero, Multiset.prod_zero, mul_one]\n exact this _ (Multiset.mem_cons_self _ _)\n · obtain ⟨n, hn⟩ := fh hf' fun b hb => this _ (Multiset.mem_cons_of_mem hb)\n use n + 1\n rw [pow_add, Multiset.prod_cons, mul_comm, pow_one]\n exact Associated.mul_mul (this _ (Multiset.mem_cons_self _ _)) hn\n have : ∃ n : ℕ, x ^ n ∈ I := by\n obtain ⟨r, hr₁, hr₂⟩ : ∃ r : R, r ∈ I ∧ r ≠ 0 := by\n by_contra! h; apply hI; rw [eq_bot_iff]; exact h\n obtain ⟨n, u, rfl⟩ := H' r hr₂ (le_maximalIdeal hI' hr₁)\n use n\n rwa [← I.unit_mul_mem_iff_mem u.isUnit, mul_comm]\n use Nat.find this\n apply le_antisymm\n · change ∀ s ∈ I, s ∈ _\n by_contra! ⟨s, hs₁, hs₂⟩\n apply hs₂\n by_cases hs₃ : s = 0; · rw [hs₃]; exact zero_mem _\n obtain ⟨n, u, rfl⟩ := H' s hs₃ (le_maximalIdeal hI' hs₁)\n rw [mul_comm, Ideal.unit_mul_mem_iff_mem _ u.isUnit] at hs₁ ⊢\n apply Ideal.pow_le_pow_right (Nat.find_min' this hs₁)\n apply Ideal.pow_mem_pow\n exact (H _).mpr (dvd_refl _)\n · rw [hx, Ideal.span_singleton_pow, Ideal.span_le, Set.singleton_subset_iff]\n exact Nat.find_spec this\n\ntheorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDedekindDomain R] :\n (maximalIdeal R).IsPrincipal := by\n classical\n by_cases ne_bot : maximalIdeal R = ⊥\n · rw [ne_bot]; infer_instance\n obtain ⟨a, ha₁, ha₂⟩ : ∃ a ∈ maximalIdeal R, a ≠ (0 : R) := by\n by_contra! h'; apply ne_bot; rwa [eq_bot_iff]\n have hle : Ideal.span {a} ≤ maximalIdeal R := by rwa [Ideal.span_le, Set.singleton_subset_iff]\n have : (Ideal.span {a}).radical = maximalIdeal R := by\n rw [Ideal.radical_eq_sInf]\n apply le_antisymm\n · exact sInf_le ⟨hle, inferInstance⟩\n · refine\n le_sInf fun I hI =>\n (eq_maximalIdeal <| hI.2.isMaximal (fun e => ha₂ ?_)).ge\n rw [← Ideal.span_singleton_eq_bot, eq_bot_iff, ← e]; exact hI.1\n have : ∃ n, maximalIdeal R ^ n ≤ Ideal.span {a} := by\n rw [← this]; apply Ideal.exists_radical_pow_le_of_fg; exact IsNoetherian.noetherian _\n rcases hn : Nat.find this with - | n\n · have := Nat.find_spec this\n rw [hn, pow_zero, Ideal.one_eq_top] at this\n exact (Ideal.IsMaximal.ne_top inferInstance (eq_top_iff.mpr <| this.trans hle)).elim\n obtain ⟨b, hb₁, hb₂⟩ : ∃ b ∈ maximalIdeal R ^ n, b ∉ Ideal.span {a} := by\n by_contra! h'; rw [Nat.find_eq_iff] at hn; exact hn.2 n n.lt_succ_self fun x hx => h' x hx\n have hb₃ : ∀ m ∈ maximalIdeal R, ∃ k : R, k * a = b * m := by\n intro m hm; rw [← Ideal.mem_span_singleton']; apply Nat.find_spec this\n rw [hn, pow_succ]; exact Ideal.mul_mem_mul hb₁ hm\n have hb₄ : b ≠ 0 := by rintro rfl; apply hb₂; exact zero_mem _\n let K := FractionRing R\n let x : K := algebraMap R K b / algebraMap R K a\n let M := Submodule.map (Algebra.linearMap R K) (maximalIdeal R)\n have ha₃ : algebraMap R K a ≠ 0 := IsFractionRing.to_map_eq_zero_iff.not.mpr ha₂\n by_cases hx : ∀ y ∈ M, x * y ∈ M\n · have := isIntegral_of_smul_mem_submodule M ?_ ?_ x hx\n · obtain ⟨y, e⟩ := IsIntegrallyClosed.algebraMap_eq_of_integral this\n refine (hb₂ (Ideal.mem_span_singleton'.mpr ⟨y, ?_⟩)).elim\n apply IsFractionRing.injective R K\n rw [map_mul, e, div_mul_cancel₀ _ ha₃]\n · rw [Submodule.ne_bot_iff]; refine ⟨_, ⟨a, ha₁, rfl⟩, ?_⟩\n exact (IsFractionRing.to_map_eq_zero_iff (K := K)).not.mpr ha₂\n · apply Submodule.FG.map; exact IsNoetherian.noetherian _\n · have :\n (M.map (DistribSMul.toLinearMap R K x)).comap (Algebra.linearMap R K) = ⊤ := by\n contrapose! hx with h\n rintro m' ⟨m, hm, rfl : algebraMap R K m = m'⟩\n obtain ⟨k, hk⟩ := hb₃ m hm\n have hk' : x * algebraMap R K m = algebraMap R K k := by\n rw [← mul_div_right_comm, ← map_mul, ← hk, map_mul, mul_div_cancel_right₀ _ ha₃]\n exact ⟨k, le_maximalIdeal h ⟨_, ⟨_, hm, rfl⟩, hk'⟩, hk'.symm⟩\n obtain ⟨y, hy₁, hy₂⟩ : ∃ y ∈ maximalIdeal R, b * y = a := by\n rw [Ideal.eq_top_iff_one, Submodule.mem_comap] at this\n obtain ⟨_, ⟨y, hy, rfl⟩, hy' : x * algebraMap R K y = algebraMap R K 1⟩ := this\n rw [map_one, ← mul_div_right_comm, div_eq_one_iff_eq ha₃, ← map_mul] at hy'\n exact ⟨y, hy, IsFractionRing.injective R K hy'⟩\n refine ⟨⟨y, ?_⟩⟩\n apply le_antisymm\n · intro m hm; obtain ⟨k, hk⟩ := hb₃ m hm; rw [← hy₂, mul_comm, mul_assoc] at hk\n rw [← mul_left_cancel₀ hb₄ hk, mul_comm]; exact Ideal.mem_span_singleton'.mpr ⟨_, rfl⟩\n · rwa [Submodule.span_le, Set.singleton_subset_iff]\n\n/--\nLet `(R, m, k)` be a Noetherian local domain (possibly a field).\nThe following are equivalent:\n0. `R` is a PID\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with at most one non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² ≤ 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `IsDiscreteValuationRing.TFAE` for a version assuming `¬ IsField R`.\n-/\ntheorem tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain\n [IsNoetherianRing R] [IsLocalRing R] [IsDomain R] :\n List.TFAE\n [IsPrincipalIdealRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∀ P : Ideal R, P ≠ ⊥ → P.IsPrime → P = maximalIdeal R,\n (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) ≤ 1,\n ∀ I ≠ ⊥, ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n tfae_have 1 → 2 := fun _ ↦ inferInstance\n tfae_have 2 → 1 := fun _ ↦ ((IsBezout.TFAE (R := R)).out 0 1).mp ‹_›\n tfae_have 1 → 4\n | H => ⟨inferInstance, fun P hP hP' ↦ eq_maximalIdeal (hP'.isMaximal hP)⟩\n tfae_have 4 → 3 :=\n fun ⟨h₁, h₂⟩ ↦ { h₁ with maximalOfPrime := (h₂ _ · · ▸ maximalIdeal.isMaximal R) }\n tfae_have 3 → 5 := fun h ↦ maximalIdeal_isPrincipal_of_isDedekindDomain R\n tfae_have 6 ↔ 5 := finrank_cotangentSpace_le_one_iff\n tfae_have 5 → 7 := exists_maximalIdeal_pow_eq_of_principal R\n tfae_have 7 → 2 := by\n rw [ValuationRing.iff_ideal_total]\n intro H\n constructor\n intro I J\n by_cases hI : I = ⊥; · order\n by_cases hJ : J = ⊥; · order\n obtain ⟨n, rfl⟩ := H I hI\n obtain ⟨m, rfl⟩ := H J hJ\n exact (le_total m n).imp Ideal.pow_le_pow_right Ideal.pow_le_pow_right\n tfae_finish\n\n/--\nThe following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n0. `R` is a discrete valuation ring\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with a unique non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² = 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\ntheorem IsDiscreteValuationRing.TFAE [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h : ¬IsField R) :\n List.TFAE\n [IsDiscreteValuationRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ P.IsPrime, (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) = 1,\n ∀ (I) (_ : I ≠ ⊥), ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n have : finrank (ResidueField R) (CotangentSpace R) = 1 ↔\n finrank (ResidueField R) (CotangentSpace R) ≤ 1 := by\n simp [Nat.le_one_iff_eq_zero_or_eq_one, finrank_cotangentSpace_eq_zero_iff, h]\n rw [this]\n have : maximalIdeal R ≠ ⊥ := isField_iff_maximalIdeal_eq.not.mp h\n convert! tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R\n · exact ⟨fun _ ↦ inferInstance, fun h ↦ { h with not_a_field' := this }⟩\n · exact ⟨fun h P h₁ h₂ ↦ h.unique ⟨h₁, h₂⟩ ⟨this, inferInstance⟩,\n fun H ↦ ⟨_, ⟨this, inferInstance⟩, fun P hP ↦ H P hP.1 hP.2⟩⟩\n\nvariable {R}\n\nlemma IsLocalRing.finrank_CotangentSpace_eq_one_iff [IsNoetherianRing R] [IsLocalRing R]\n [IsDomain R] : finrank (ResidueField R) (CotangentSpace R) = 1 ↔ IsDiscreteValuationRing R := by\n by_cases hR : IsField R\n · letI := hR.toField\n simp only [finrank_cotangentSpace_eq_zero, zero_ne_one, false_iff]\n exact fun h ↦ h.3 maximalIdeal_eq_bot\n · exact (IsDiscreteValuationRing.TFAE R hR).out 5 0\n\nvariable (R)\n\nlemma IsLocalRing.finrank_CotangentSpace_eq_one [IsDomain R] [IsDiscreteValuationRing R] :\n finrank (ResidueField R) (CotangentSpace R) = 1 :=\n finrank_CotangentSpace_eq_one_iff.mpr ‹_›\n\nopen Ring in\n\nTarget:\nlemma IsDiscreteValuationRing.ringKrullDim_eq_one [IsDomain R] [IsDiscreteValuationRing R] :\n ringKrullDim R = 1 :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/DiscreteValuationRing","family_id":"isdiscretevaluationring","file_id":"mathlib/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean","sample_id":"2cdcc1dd0c4f5dba1df2244028dbe522178ef51a9ac80121eb406c12d554155b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c948dce754d3463b63a73429781f379aa3b9b65e762651599ad88f0a6126a01","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"34c49f28cae851613a5b79e0be56c9af239882f0f83621fa52ad5d47dd55399e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa5d4ad8febc8ad6e8efc1d3b2fd172be63dca9ff05addec42710c7264a10137","source_sha256":"06aa772ac819c87b4401e8808cdb88bbb268afd121d0dfd2be4cac60857bbb95","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, Set.mem_sdiff,\n mem_singleton_iff, mem_ball, Real.dist_eq, and_comm]","hard_negative":false,"metrics":{"chosen_tokens":30,"rejected_tokens":35,"token_jaccard":0.807692,"token_length_ratio":1.166667},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"669a34648902319a2b2d2615d4ce5826b9bf6e1dbcc165583cd045df1d2b9cde","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.Transcendental.Liouville.Basic\npublic import Mathlib.Topology.Baire.Lemmas\npublic import Mathlib.Topology.Baire.LocallyCompactRegular\npublic import Mathlib.Topology.Instances.Irrational\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Density of Liouville numbers\n\nIn this file we prove that the set of Liouville numbers form a dense `Gδ` set. We also prove a\nsimilar statement about irrational numbers.\n-/\n\npublic section\n\n\nopen scoped Filter\n\nopen Filter Set Metric\n\nTarget:\ntheorem setOf_liouville_eq_iInter_iUnion :\n { x | Liouville x } =\n ⋂ n : ℕ, ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b),\n ball ((a : ℝ) / b) (1 / (b : ℝ) ^ n) \\ {(a : ℝ) / b} :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n ext x\n simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, Set.mem_sdiff,\n mem_singleton_iff, mem_ball, Real.dist_eq, and_comm]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Transcendental","family_id":"setof_liouville_eq_iinter_iunion","file_id":"mathlib/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean","sample_id":"fa5d4ad8febc8ad6e8efc1d3b2fd172be63dca9ff05addec42710c7264a10137"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"68c104da4cc327d3cbce10433708ceb988526741db2a9149c78e83d04499b44c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6d8bf0d2dcc47dd84e343933d598b89d5d7e2ab0f76d0f19f4d7520db1ced6e1","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]","hard_negative":true,"metrics":{"chosen_tokens":23,"rejected_tokens":8,"token_jaccard":0.142857,"token_length_ratio":0.347826},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"66fe386a88ecb28d64d8488f16b5b9c3e3967d46cfcc0a572c174bfd5258319d","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\n\nTarget:\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"064466f7903cbdfb4d2b7c709297d48e9048cbdc1cbcb27cf60360adfa633bdc","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"6d8bf0d2dcc47dd84e343933d598b89d5d7e2ab0f76d0f19f4d7520db1ced6e1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f2a437684fead703036873298a0ace34afe80682f6dc457c5baaff612f9fa32c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"60e1a407510c44cbd7b7e68a5c044fa552dc6a75c3cd628ebcf704c5de1b9ee1","source_sha256":"e88909466015ff2d4c0d5ff8a5e84a299fba6b9e7e753b82aadbaeb3e8ea93c9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n intro X Y f g\n simp only [← NatIso.naturality_1 e (f + g), map_add, Preadditive.add_comp,\n NatTrans.naturality, Preadditive.comp_add, Iso.inv_hom_id_app_assoc]\n\nomit [F.Additive] in","hard_negative":false,"metrics":{"chosen_tokens":46,"rejected_tokens":5,"token_jaccard":0.027778,"token_length_ratio":0.108696},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"68c1b63a82f52e5a359f5328e2db5204e3394258685ecebbbf12408c69c1cab9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Limits.ExactFunctor\npublic import Mathlib.CategoryTheory.Limits.Preserves.Finite\npublic import Mathlib.CategoryTheory.Preadditive.Biproducts\npublic import Mathlib.CategoryTheory.Preadditive.FunctorCategory\n\nNamespace:\nCategoryTheory.Functor\n\nLocal context:\n/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Kim Morrison\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.\nConversely, if `F : C ⥤ D` is a functor between preadditive categories, where `C` has binary\nbiproducts, and if `F` preserves binary biproducts, then `F` is additive.\n\nWe also define the category of bundled additive functors.\n\n## Implementation details\n\n`Functor.Additive` is a `Prop`-valued class, defined by saying that for every two objects `X` and\n`Y`, the map `F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of abelian groups.\n\n-/\n\n@[expose] public section\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnamespace CategoryTheory\n\n/-- A functor `F` is additive provided `F.map` is an additive homomorphism. -/\n@[stacks 00ZY]\nclass Functor.Additive {C D : Type*} [Category* C] [Category* D] [Preadditive C] [Preadditive D]\n (F : C ⥤ D) : Prop where\n /-- the addition of two morphisms is mapped to the sum of their images -/\n map_add : ∀ {X Y : C} {f g : X ⟶ Y}, F.map (f + g) = F.map f + F.map g := by cat_disch\n\nsection Preadditive\n\nnamespace Functor\n\nsection\n\nvariable {C D E : Type*} [Category* C] [Category* D] [Category* E]\n [Preadditive C] [Preadditive D] [Preadditive E] (F : C ⥤ D) [Functor.Additive F]\n\n@[simp]\ntheorem map_add {X Y : C} {f g : X ⟶ Y} : F.map (f + g) = F.map f + F.map g :=\n Functor.Additive.map_add\n\n/-- `F.mapAddHom` is an additive homomorphism whose underlying function is `F.map`. -/\n@[simps!]\ndef mapAddHom {X Y : C} : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y) :=\n AddMonoidHom.mk' (fun f => F.map f) fun _ _ => F.map_add\n\ntheorem coe_mapAddHom {X Y : C} : ⇑(F.mapAddHom : (X ⟶ Y) →+ _) = F.map :=\n rfl\n\ninstance (priority := 100) preservesZeroMorphisms_of_additive : PreservesZeroMorphisms F where\n map_zero _ _ := F.mapAddHom.map_zero\n\ninstance : Additive (𝟭 C) where\n\ninstance {E : Type*} [Category* E] [Preadditive E] (G : D ⥤ E) [Functor.Additive G] :\n Additive (F ⋙ G) where\n\ninstance {J : Type*} [Category* J] (j : J) : ((evaluation J C).obj j).Additive where\n\n@[simp]\ntheorem map_neg {X Y : C} {f : X ⟶ Y} : F.map (-f) = -F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_neg _\n\n@[simp]\ntheorem map_sub {X Y : C} {f g : X ⟶ Y} : F.map (f - g) = F.map f - F.map g :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_sub _ _\n\ntheorem map_nsmul {X Y : C} {f : X ⟶ Y} {n : ℕ} : F.map (n • f) = n • F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_nsmul _ _\n\n-- You can alternatively just use `Functor.map_smul` here, with an explicit `(r : ℤ)` argument.\ntheorem map_zsmul {X Y : C} {f : X ⟶ Y} {r : ℤ} : F.map (r • f) = r • F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_zsmul _ _\n\n@[simp]\nnonrec theorem map_sum {X Y : C} {α : Type*} (f : α → (X ⟶ Y)) (s : Finset α) :\n F.map (∑ a ∈ s, f a) = ∑ a ∈ s, F.map (f a) :=\n map_sum F.mapAddHom f s\n\nvariable {F}\n\nTarget:\nlemma additive_of_iso {G : C ⥤ D} (e : F ≅ G) : G.Additive :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Preadditive","family_id":"additive_of_iso","file_id":"mathlib/Mathlib/CategoryTheory/Preadditive/AdditiveFunctor.lean","sample_id":"60e1a407510c44cbd7b7e68a5c044fa552dc6a75c3cd628ebcf704c5de1b9ee1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f4fada5c5bff3d6bc9e29d14916de44cf82fcfaab68c0ed5737f190445d775d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fc8a87fbf987153a9f95d9d74c75f82e1fb755b3b65142ba97d0535c075a4809","source_sha256":"958c418e0895d6f0133c0f2d3fa1bc785024b3935ebe9bea89aa615109a727cf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n exact ⟨fun _ => h.symm.isOpenEmbedding.locallyCompactSpace,\n fun _ => h.isClosedEmbedding.locallyCompactSpace⟩","hard_negative":false,"metrics":{"chosen_tokens":23,"rejected_tokens":2,"token_jaccard":0.066667,"token_length_ratio":0.086957},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"692e218ddeaa1c483a01037568070e2f4abaad496c944f927b83f7eb56fd4def","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Equiv.Fin.Basic\npublic import Mathlib.Topology.Connected.LocallyConnected\npublic import Mathlib.Topology.DenseEmbedding\npublic import Mathlib.Topology.Connected.TotallyDisconnected\npublic import Mathlib.Topology.Baire.Lemmas\n\nNamespace:\nHomeomorph\n\nLocal context:\n/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\n/-!\n# Further properties of homeomorphisms\n\nThis file proves further properties of homeomorphisms between topological spaces.\nPretty much every topological property is preserved under homeomorphisms.\n\n-/\n\n@[expose] public section\n\nassert_not_exists Module MonoidWithZero\n\nopen Filter Function Set Topology\n\nvariable {X Y W Z : Type*}\n\nsection\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace W] [TopologicalSpace Z]\n {X' Y' : Type*} [TopologicalSpace X'] [TopologicalSpace Y']\n\nnamespace Homeomorph\n\nprotected theorem secondCountableTopology [SecondCountableTopology Y]\n (h : X ≃ₜ Y) : SecondCountableTopology X :=\n h.isInducing.secondCountableTopology\n\nprotected theorem baireSpace [BaireSpace X] (f : X ≃ₜ Y) : BaireSpace Y :=\n f.isOpenQuotientMap.baireSpace\n\n/-- If `h : X → Y` is a homeomorphism, `h(s)` is compact iff `s` is. -/\n@[simp]\ntheorem isCompact_image {s : Set X} (h : X ≃ₜ Y) : IsCompact (h '' s) ↔ IsCompact s :=\n h.isEmbedding.isCompact_iff.symm\n\n/-- If `h : X → Y` is a homeomorphism, `h⁻¹(s)` is compact iff `s` is. -/\n@[simp]\ntheorem isCompact_preimage {s : Set Y} (h : X ≃ₜ Y) : IsCompact (h ⁻¹' s) ↔ IsCompact s := by\n rw [← image_symm]; exact h.symm.isCompact_image\n\n/-- If `h : X → Y` is a homeomorphism, `s` is σ-compact iff `h(s)` is. -/\n@[simp]\ntheorem isSigmaCompact_image {s : Set X} (h : X ≃ₜ Y) :\n IsSigmaCompact (h '' s) ↔ IsSigmaCompact s :=\n h.isEmbedding.isSigmaCompact_iff.symm\n\n/-- If `h : X → Y` is a homeomorphism, `h⁻¹(s)` is σ-compact iff `s` is. -/\n@[simp]\ntheorem isSigmaCompact_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsSigmaCompact (h ⁻¹' s) ↔ IsSigmaCompact s := by\n rw [← image_symm]; exact h.symm.isSigmaCompact_image\n\n@[simp]\ntheorem isPreconnected_image {s : Set X} (h : X ≃ₜ Y) :\n IsPreconnected (h '' s) ↔ IsPreconnected s :=\n ⟨fun hs ↦ by simpa only [image_symm, preimage_image]\n using hs.image _ h.symm.continuous.continuousOn,\n fun hs ↦ hs.image _ h.continuous.continuousOn⟩\n\n@[simp]\ntheorem isPreconnected_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsPreconnected (h ⁻¹' s) ↔ IsPreconnected s := by\n rw [← image_symm, isPreconnected_image]\n\n@[simp]\ntheorem isConnected_image {s : Set X} (h : X ≃ₜ Y) :\n IsConnected (h '' s) ↔ IsConnected s :=\n image_nonempty.and h.isPreconnected_image\n\n@[simp]\ntheorem isConnected_preimage {s : Set Y} (h : X ≃ₜ Y) :\n IsConnected (h ⁻¹' s) ↔ IsConnected s := by\n rw [← image_symm, isConnected_image]\n\ntheorem image_connectedComponentIn {s : Set X} (h : X ≃ₜ Y) {x : X} (hx : x ∈ s) :\n h '' connectedComponentIn s x = connectedComponentIn (h '' s) (h x) := by\n refine (h.continuous.image_connectedComponentIn_subset hx).antisymm ?_\n have := h.symm.continuous.image_connectedComponentIn_subset (mem_image_of_mem h hx)\n rwa [image_subset_iff, h.preimage_symm, h.image_symm, h.preimage_image, h.symm_apply_apply]\n at this\n\n@[simp]\ntheorem comap_cocompact (h : X ≃ₜ Y) : comap h (cocompact Y) = cocompact X :=\n (comap_cocompact_le h.continuous).antisymm <|\n (hasBasis_cocompact.le_basis_iff (hasBasis_cocompact.comap h)).2 fun K hK =>\n ⟨h ⁻¹' K, h.isCompact_preimage.2 hK, Subset.rfl⟩\n\n@[simp]\ntheorem map_cocompact (h : X ≃ₜ Y) : map h (cocompact X) = cocompact Y := by\n rw [← h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected theorem compactSpace [CompactSpace X] (h : X ≃ₜ Y) : CompactSpace Y where\n isCompact_univ := h.symm.isCompact_preimage.2 isCompact_univ\n\ntheorem isDenseEmbedding (h : X ≃ₜ Y) : IsDenseEmbedding h :=\n { h.isEmbedding with dense := h.surjective.denseRange }\n\nprotected lemma totallyDisconnectedSpace (h : X ≃ₜ Y) [tdc : TotallyDisconnectedSpace X] :\n TotallyDisconnectedSpace Y :=\n (totallyDisconnectedSpace_iff Y).mpr\n (h.range_coe ▸ ((IsEmbedding.isTotallyDisconnected_range h.isEmbedding).mpr tdc))\n\n@[simp]\ntheorem map_punctured_nhds_eq (h : X ≃ₜ Y) (x : X) : map h (𝓝[≠] x) = 𝓝[≠] (h x) := by\n convert! h.isEmbedding.map_nhdsWithin_eq ({ x }ᶜ) x\n rw [h.image_compl, Set.image_singleton]\n\n@[simp]\ntheorem comap_coclosedCompact (h : X ≃ₜ Y) : comap h (coclosedCompact Y) = coclosedCompact X :=\n (hasBasis_coclosedCompact.comap h).eq_of_same_basis <| by\n simpa [comp_def] using hasBasis_coclosedCompact.comp_surjective h.injective.preimage_surjective\n\n@[simp]\ntheorem map_coclosedCompact (h : X ≃ₜ Y) : map h (coclosedCompact X) = coclosedCompact Y := by\n rw [← h.comap_coclosedCompact, map_comap_of_surjective h.surjective]\n\n/-- If the codomain of a homeomorphism is a locally connected space, then the domain is also\na locally connected space. -/\ntheorem locallyConnectedSpace [i : LocallyConnectedSpace Y] (h : X ≃ₜ Y) :\n LocallyConnectedSpace X := by\n have : ∀ x, (𝓝 x).HasBasis (fun s ↦ IsOpen s ∧ h x ∈ s ∧ IsConnected s)\n (h.symm '' ·) := fun x ↦ by\n rw [← h.symm_map_nhds_eq]\n exact (i.1 _).map _\n refine locallyConnectedSpace_of_connected_bases _ _ this fun _ _ hs ↦ ?_\n exact hs.2.2.2.image _ h.symm.continuous.continuousOn\n\n/-- The codomain of a homeomorphism is a locally compact space if and only if\nthe domain is a locally compact space. -/\n\nTarget:\ntheorem locallyCompactSpace_iff (h : X ≃ₜ Y) :\n LocallyCompactSpace X ↔ LocallyCompactSpace Y :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Homeomorph","family_id":"locallycompactspace_iff","file_id":"mathlib/Mathlib/Topology/Homeomorph/Lemmas.lean","sample_id":"fc8a87fbf987153a9f95d9d74c75f82e1fb755b3b65142ba97d0535c075a4809"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"dc04cf67d739b75311124ee06478269ff8329106640f43b029a8101fe94d8586","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e97ba48f8121881421b3500b68856ac7102c032733d54751cdad817ffe39bd7f","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":true,"metrics":{"chosen_tokens":2,"rejected_tokens":2,"token_jaccard":0.333333,"token_length_ratio":1.0},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"695b48f1847c1c0669d104d6db1ffa9b15823e2b3e975e3469de32a289b662eb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\n\nTarget:\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_e97ba48f8121","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"688ed57cf83e0d0d546e51f2e0708b6c0d032f02a25161a4afb695a5645a2f20","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"mk_coe","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"e97ba48f8121881421b3500b68856ac7102c032733d54751cdad817ffe39bd7f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9b04864f5019d5fcf223d79992fd2afb10fb0011642bb1afc6ab7980c57f9a80","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a62c8653422fa7a91a247015d43b86d07461f11a6ed40c8cdef84b45cb0f1e11","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ded6faa6d48b99d8145f41b676cb932b10ee82b07e71517181c782fc3638c0db","source_sha256":"10e25e11aaeed3e571034bb2dc616107c37c9ec1e439be369d5af752525aea30","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun hf ↦ ?_, fun hf ↦ (mem_smallGrothendieckTopology _ _).2 ?_⟩\n · obtain ⟨U, _, _, hU⟩ := (mem_smallGrothendieckTopology _ _).1 hf\n ext y\n simp only [Set.mem_iUnion, Set.mem_range, Set.mem_univ, iff_true]\n obtain ⟨i, ⟨u, rfl⟩⟩ := ((ofArrows_mem_precoverage_iff _).1 U.mem₀).1 y\n obtain ⟨_, b, _, ⟨j⟩, fac⟩ := hU _ _ ⟨i⟩\n replace fac : b.left ≫ (f j).left = U.f i :=\n (Etale.forget _ ⋙ CategoryTheory.Over.forget _).congr_map fac\n exact ⟨j, b.left u, by simp [← fac]⟩\n · have (w : W.left) : ∃ (i : ι), w ∈ Set.range (f i).left := by\n have := Set.mem_univ w\n simpa [← hf]\n choose i z hz using this\n let V : Cover (precoverage @Etale) W.left :=\n Cover.mkOfCovers W.left (fun w ↦ (Z (i w)).left)\n (fun w ↦ (f (i w)).left) (fun w ↦ ⟨_, _, hz w⟩) inferInstance\n letI : Cover.Over X V :=\n { over w := ⟨(Z (i w)).hom⟩\n isOver_map w := by cat_disch }\n have (w : W.left) : Etale (V.X w ↘ X) := (Z (i w)).prop\n refine ⟨V, inferInstance, inferInstance, ?_⟩\n rintro _ _ ⟨w⟩\n refine ⟨_, 𝟙 _, _, ⟨i w⟩, by cat_disch⟩","hard_negative":false,"metrics":{"chosen_tokens":358,"rejected_tokens":362,"token_jaccard":0.967033,"token_length_ratio":1.011173},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"6ad3f129117a80ec97df96b879ec27c452408d7e99eaaf8d0688fc4c7fff327d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.Morphisms.Etale\npublic import Mathlib.AlgebraicGeometry.Sites.BigZariski\npublic import Mathlib.AlgebraicGeometry.Sites.Small\npublic import Mathlib.CategoryTheory.Limits.Elements\npublic import Mathlib.CategoryTheory.Sites.Point.Basic\n\nNamespace:\nAlgebraicGeometry.Scheme\n\nLocal context:\n/-\nCopyright (c) 2024 Christian Merten. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christian Merten\n-/\n/-!\n\n# The étale site\n\nIn this file we define the big étale site, i.e. the étale topology as a Grothendieck topology\non the category of schemes.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nopen CategoryTheory MorphismProperty Limits\n\nnamespace AlgebraicGeometry.Scheme\n\n/-- Big étale site: the étale precoverage on the category of schemes. -/\ndef etalePrecoverage : Precoverage Scheme.{u} :=\n precoverage @Etale\n\n/-- Big étale site: the étale pretopology on the category of schemes. -/\ndef etalePretopology : Pretopology Scheme.{u} :=\n pretopology @Etale\n\n/-- Big étale site: the étale topology on the category of schemes. -/\nabbrev etaleTopology : GrothendieckTopology Scheme.{u} :=\n grothendieckTopology @Etale\n\nlemma zariskiTopology_le_etaleTopology : zariskiTopology ≤ etaleTopology := by\n apply grothendieckTopology_monotone\n intro X Y f hf\n infer_instance\n\n/-- The small étale site of a scheme is the Grothendieck topology on the\ncategory of schemes étale over `X` induced from the étale topology on `Scheme.{u}`. -/\ndef smallEtaleTopology (X : Scheme.{u}) : GrothendieckTopology X.Etale :=\n X.smallGrothendieckTopology (P := @Etale)\n\n/-- The pretopology generating the small étale site. -/\ndef smallEtalePretopology (X : Scheme.{u}) : Pretopology X.Etale :=\n X.smallPretopology (Q := @Etale) (P := @Etale)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma ofArrows_mem_smallEtaleTopology_iff\n {X : Scheme.{u}} {W : X.Etale} {ι : Type*}\n {Z : ι → X.Etale} (f : ∀ i, Z i ⟶ W) :\n Sieve.ofArrows _ f ∈ smallEtaleTopology _ _ ↔\n ⋃ i, Set.range (f i).left = .univ :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n refine ⟨fun hf ↦ ?_, fun hf ↦ (mem_smallGrothendieckTopology _ _).2 ?_⟩\n · obtain ⟨U, _, _, hU⟩ := (mem_smallGrothendieckTopology _ _).1 hf\n ext y\n simp only [Set.mem_iUnion, Set.mem_range, Set.mem_univ, iff_true]\n obtain ⟨i, ⟨u, rfl⟩⟩ := ((ofArrows_mem_precoverage_iff _).1 U.mem₀).1 y\n obtain ⟨_, b, _, ⟨j⟩, fac⟩ := hU _ _ ⟨i⟩\n replace fac : b.left ≫ (f j).left = U.f i :=\n (Etale.forget _ ⋙ CategoryTheory.Over.forget _).congr_map fac\n exact ⟨j, b.left u, by simp [← fac]⟩\n · have (w : W.left) : ∃ (i : ι), w ∈ Set.range (f i).left := by\n have := Set.mem_univ w\n simpa [← hf]\n choose i z hz using this\n let V : Cover (precoverage @Etale) W.left :=\n Cover.mkOfCovers W.left (fun w ↦ (Z (i w)).left)\n (fun w ↦ (f (i w)).left) (fun w ↦ ⟨_, _, hz w⟩) inferInstance\n letI : Cover.Over X V :=\n { over w := ⟨(Z (i w)).hom⟩\n isOver_map w := by cat_disch }\n have (w : W.left) : Etale (V.X w ↘ X) := (Z (i w)).prop\n refine ⟨V, inferInstance, inferInstance, ?_⟩\n rintro _ _ ⟨w⟩\n refine ⟨_, 𝟙 _, _, ⟨i w⟩, by cat_disch⟩","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Sites","family_id":"ofarrows_mem_smalletaletopology_iff","file_id":"mathlib/Mathlib/AlgebraicGeometry/Sites/Etale.lean","sample_id":"ded6faa6d48b99d8145f41b676cb932b10ee82b07e71517181c782fc3638c0db"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"83055cffab58b1007df9d9544341b0300c397e7831803c736cc144d4f0ae252c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fb5a95d053087f7dcb73196ca6aecaf07c0a6c2f3274ef2c5bba3dc312749da2","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cafbeebc9304f43f9f9b249d49762f5fe35eca5f6f277411f68a09a6065367b8","source_sha256":"70b655774553f5ec4eaa3d2beda50eafff09706ffc0381725295ff20fc05eaae","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro M N f₁ f₂ h\n ext ⟨X⟩ m\n obtain ⟨g, rfl⟩ := freeYonedaEquiv.surjective m\n exact congr_arg freeYonedaEquiv (h _ ⟨X⟩ g)","hard_negative":true,"metrics":{"chosen_tokens":36,"rejected_tokens":3,"token_jaccard":0.074074,"token_length_ratio":0.083333},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"6b1e14a2eb7ce4ba18572a2dc6a59b63d3a3d0f8f9f8fa2eeb8392343215382f","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.Abelian\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.EpiMono\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.Free\npublic import Mathlib.Algebra.Homology.ShortComplex.Exact\npublic import Mathlib.CategoryTheory.Elements\npublic import Mathlib.CategoryTheory.Generator.Basic\n\nNamespace:\nPresheafOfModules.freeYoneda\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Generators for the category of presheaves of modules\n\nIn this file, given a presheaf of rings `R` on a category `C`,\nwe study the set `freeYoneda R` of presheaves of modules\nof form `(free R).obj (yoneda.obj X)` for `X : C`, i.e.\nfree presheaves of modules generated by the Yoneda\npresheaf represented by some `X : C` (the functor\nrepresented by such a presheaf of modules is the evaluation\nfunctor `M ↦ M.obj (op X)`, see `freeYonedaEquiv`).\n\nLemmas `PresheafOfModules.freeYoneda.isSeparating` and\n`PresheafOfModules.freeYoneda.isDetecting` assert that this\nset `freeYoneda R` is separating and detecting.\nWe deduce that if `C : Type u` is a small category,\nand `R : Cᵒᵖ ⥤ RingCat.{u}`, then `PresheafOfModules.{u} R`\nis a well-powered category.\n\nFinally, given `M : PresheafOfModules.{u} R`, we consider\nthe canonical epimorphism of presheaves of modules\n`M.fromFreeYonedaCoproduct : M.freeYonedaCoproduct ⟶ M`\nwhere `M.freeYonedaCoproduct` is a coproduct indexed\nby elements of `M`, i.e. pairs `⟨X : Cᵒᵖ, a : M.obj X⟩`,\nof the objects `(free R).obj (yoneda.obj X.unop)`.\nThis is used in the definition\n`PresheafOfModules.isColimitFreeYonedaCoproductsCokernelCofork`\nin order to obtain that any presheaf of modules is a cokernel\nof a morphism between coproducts of objects in `freeYoneda R`.\n\n-/\n\n@[expose] public section\n\nuniverse v v₁ u u₁\n\nopen CategoryTheory Limits\n\nnamespace PresheafOfModules\n\nvariable {C : Type u} [Category.{v} C] {R : Cᵒᵖ ⥤ RingCat.{v}}\n\n/-- When `R : Cᵒᵖ ⥤ RingCat`, `M : PresheafOfModules R`, and `X : C`, this is the\nbijection `((free R).obj (yoneda.obj X) ⟶ M) ≃ M.obj (Opposite.op X)`. -/\nnoncomputable def freeYonedaEquiv {M : PresheafOfModules.{v} R} {X : C} :\n ((free R).obj (yoneda.obj X) ⟶ M) ≃ M.obj (Opposite.op X) :=\n freeHomEquiv.trans yonedaEquiv\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma freeYonedaEquiv_symm_app (M : PresheafOfModules.{v} R) (X : C)\n (x : M.obj (Opposite.op X)) :\n (freeYonedaEquiv.symm x).app (Opposite.op X) (ModuleCat.freeMk (𝟙 _)) = x := by\n simp [freeYonedaEquiv, freeHomEquiv, yonedaEquiv]\n\nlemma freeYonedaEquiv_comp {M N : PresheafOfModules.{v} R} {X : C}\n (m : ((free R).obj (yoneda.obj X) ⟶ M)) (φ : M ⟶ N) :\n freeYonedaEquiv (m ≫ φ) = φ.app _ (freeYonedaEquiv m) := rfl\n\nvariable (R) in\n/-- The set of `PresheafOfModules.{v} R` consisting of objects of the\nform `(free R).obj (yoneda.obj X)` for some `X`. -/\ndef freeYoneda : ObjectProperty (PresheafOfModules.{v} R) := .ofObj (yoneda ⋙ free R).obj\n\nnamespace freeYoneda\n\ninstance : ObjectProperty.Small.{u} (freeYoneda R) := by\n dsimp [freeYoneda]\n infer_instance\n\nvariable (R)\n\nTarget:\nlemma isSeparating : ObjectProperty.IsSeparating (freeYoneda R) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_cafbeebc9304","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"9608451770b6a9a0e91b4f85e99d494541659f0a196abe3dab690af57b19c58f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Category","family_id":"isseparating","file_id":"mathlib/Mathlib/Algebra/Category/ModuleCat/Presheaf/Generator.lean","sample_id":"cafbeebc9304f43f9f9b249d49762f5fe35eca5f6f277411f68a09a6065367b8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d6e86cd306d302771012f2d820e6a59c3e3d9e4c68bbf815be43378ad63c9dec","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"03b40b84651b58bf7925b46af980bbca86f9a834de4292f055006915a5991d95","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"88cff46317ce0e593fb1f210fa9b5188025d5fb51a9c19fd788c1b29b98f4e35","source_sha256":"18568baeeffeaaa701b9fde364e1ec597e66170a4d12d2f9f2bfbc098c10a0b6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := lt_ratSqrt_add_inv_prec_sq (x := x) h\n have : (x : ℝ) < ↑((x.ratSqrt prec + 1 / prec) ^ 2 : ℚ) := by norm_cast\n have := Real.sqrt_lt_sqrt (by simp) this\n rw [Rat.cast_pow, Real.sqrt_sq] at this\n · push_cast at this\n exact this\n · push_cast\n exact add_nonneg (by simpa using ratSqrt_nonneg _ _) (by simp)","hard_negative":true,"metrics":{"chosen_tokens":82,"rejected_tokens":5,"token_jaccard":0.068182,"token_length_ratio":0.060976},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"6b36490be282c65f0899fb77640ed045ee33e0434e15803fb59349d7ceb224ac","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Real.Sqrt\npublic import Mathlib.Data.Rat.NatSqrt.Defs\n\nNamespace:\nNat\n\nLocal context:\n/-\nCopyright (c) 2025 Lean FRO, LLC. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\nComparisons between rational approximations to the square root of a natural number\nand the real square root.\n-/\n\npublic section\n\nnamespace Nat\n\ntheorem ratSqrt_le_realSqrt (x : ℕ) {prec : ℕ} (h : 0 < prec) : ratSqrt x prec ≤ √x := by\n have := ratSqrt_sq_le (x := x) h\n have : (x.ratSqrt prec ^ 2 : ℝ) ≤ ↑x := by norm_cast\n have := Real.sqrt_monotone this\n rwa [Real.sqrt_sq] at this\n simpa only [Rat.cast_nonneg] using ratSqrt_nonneg _ _\n\nTarget:\ntheorem realSqrt_lt_ratSqrt_add_inv_prec (x : ℕ) {prec : ℕ} (h : 0 < prec) :\n √x < ratSqrt x prec + 1 / prec :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_88cff46317ce","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"9af5d5e3473e8f399f5705f5998af7d2442f1f6a97a6309ab5a0dd34c7e2206e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Rat","family_id":"realsqrt_lt_ratsqrt_add_inv_prec","file_id":"mathlib/Mathlib/Analysis/Rat/NatSqrt/Real.lean","sample_id":"88cff46317ce0e593fb1f210fa9b5188025d5fb51a9c19fd788c1b29b98f4e35"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"800309b9f05b3a4a83029438383e736bb796eae1a2ddf46badd79b778d22857d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"25fac9092685576971918ff441d34f921ba8e1015a1d3112c67732d897416eb1","source_sha256":"c16459d64473a740c6a3fea2e787f6e904d2ce7749fd9d22ca52f5ddd5d2abaf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases finite_or_infinite α\n · obtain ⟨_⟩ := nonempty_fintype α; letI := Classical.decEq α\n simp_rw [Nat.card_eq_fintype_card]\n exact card_subtype_not_diag\n · simp","hard_negative":false,"metrics":{"chosen_tokens":29,"rejected_tokens":2,"token_jaccard":0.04,"token_length_ratio":0.068966},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"6ba00dcd7d37bcd657bdd01a6710c3ac9209a375bb2f4341daf22617e0ddfc65","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Card\npublic import Mathlib.Data.Sym.Basic\npublic import Mathlib.Data.Sym.Sym2\nimport Mathlib.Data.Sym.Card\n\nNamespace:\nSym2\n\nLocal context:\n/-\nCopyright (c) 2026 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n/-!\n# `Nat.card` versions of `Fintype.card` lemmas on `Sym`\n\nEach of the lemmas assuming `[Fintype α]` and `Fintype.card` can be restated using `Nat.card` alone.\n-/\n\npublic section\n\nopen Nat\n\nvariable (α : Type*)\n\nnamespace Sym\n\ninstance {k : ℕ} [Infinite α] [NeZero k] : Infinite (Sym α k) :=\n .of_injective (Sym.replicate k) <| Sym.replicate_right_injective (NeZero.ne _)\n\n/-- A version of `card_sym_eq_multichoose` that does not need finiteness. -/\ntheorem natCard_sym_eq_multichoose (k : ℕ) :\n Nat.card (Sym α k) = multichoose (Nat.card α) k := by\n cases finite_or_infinite α\n · obtain ⟨_⟩ := nonempty_fintype α; letI := Classical.decEq α\n simp_rw [Nat.card_eq_fintype_card]\n exact card_sym_eq_multichoose _ _\n cases k <;> simp\n\n/-- A version of `card_sym_eq_choose` that does not need finiteness. -/\ntheorem natCard_sym_eq_choose (k : ℕ) :\n Nat.card (Sym α k) = (Nat.card α + k - 1).choose k := by\n rw [natCard_sym_eq_multichoose, Nat.multichoose_eq]\n\nend Sym\n\nnamespace Sym2\n\ninstance [Infinite α] : Infinite (Sym2 α) :=\n .of_injective Sym2.diag <| Sym2.diag_injective\n\ninstance [Infinite α] : Infinite {a : Sym2 α // a.IsDiag} :=\n .of_injective (fun a : α => ⟨.diag a, rfl⟩) fun _ _ h => Sym2.diag_injective congr($h)\n\ninstance [Infinite α] : Infinite {a : Sym2 α // ¬a.IsDiag} :=\n let e := Infinite.natEmbedding α\n .of_injective (fun n => ⟨s(e 0, e (n + 1)), by simp⟩) fun _ _ => by simp\n\ntheorem natCard_subtype_diag : Nat.card { a : Sym2 α // a.IsDiag } = Nat.card α :=\n Nat.card_congr diagElemEquiv\n\nTarget:\ntheorem natCard_subtype_not_diag :\n Nat.card { a : Sym2 α // ¬a.IsDiag } = (Nat.card α).choose 2 :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Sym","family_id":"natcard_subtype_not_diag","file_id":"mathlib/Mathlib/Data/Sym/NatCard.lean","sample_id":"25fac9092685576971918ff441d34f921ba8e1015a1d3112c67732d897416eb1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0712e7ba31f5be3678ad860748a6234697b82f97702f63a9123ea1ce7911c0a7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"528d779653be05f79b9d414c3bb7c0bd1efd3ac27077a9fe80d90b8423ce89c9","source_sha256":"01e2a9c85e681d1f70c567cdf153d1062a74083def837924a42e92331cebc99b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro h\n simp only [LinearMap.lcomp_apply', Set.mem_range]\n refine ⟨fun hh ↦ ?_, fun ⟨y, hy⟩ ↦ ?_⟩\n · use ((LinearMap.range f).liftQ h (LinearMap.range_le_ker_iff.mpr hh)).comp\n (exac.linearEquivOfSurjective surj).symm.toLinearMap\n ext x\n simp\n · rw [← hy, LinearMap.comp_assoc, exac.linearMap_comp_eq_zero, LinearMap.comp_zero y]","hard_negative":false,"metrics":{"chosen_tokens":87,"rejected_tokens":2,"token_jaccard":0.021739,"token_length_ratio":0.022989},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"6c20988dba72e7db5803aa4d13a49aa21b8e19c1e9dfcacd5b73a53828c5bfbe","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Exact.Basic\npublic import Mathlib.LinearAlgebra.BilinearMap\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# The Left Exactness of Hom\n\n\nIf `M1 → M2 → M3 → 0` is an exact sequence of `R`-modules and `N` is an `R`-module,\nthen `0 → (M3 →ₗ[R] N) → (M2 →ₗ[R] N) → (M1 →ₗ[R] N)` is exact. In this file, we\nshow the exactness at `M2 →ₗ[R] N` (`exact_lcomp_of_exact_of_surjective`);\nthe injectivity part is `LinearMap.lcomp_injective_of_surjective` in the file\n`Mathlib.LinearAlgebra.BilinearMap`.\n\n\n-/\n\npublic section\n\nnamespace LinearMap\n\nvariable {R : Type*} [CommRing R] {M1 M2 M3 : Type*} (N : Type*)\n [AddCommGroup M1] [AddCommGroup M2] [AddCommGroup M3] [AddCommGroup N]\n [Module R M1] [Module R M2] [Module R M3] [Module R N]\n\nTarget:\nlemma exact_lcomp_of_exact_of_surjective {f : M1 →ₗ[R] M2} {g : M2 →ₗ[R] M3}\n (exac : Function.Exact f g) (surj : Function.Surjective g) :\n Function.Exact (LinearMap.lcomp R N g) (LinearMap.lcomp R N f) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra","family_id":"exact_lcomp_of_exact_of_surjective","file_id":"mathlib/Mathlib/LinearAlgebra/LeftExact.lean","sample_id":"528d779653be05f79b9d414c3bb7c0bd1efd3ac27077a9fe80d90b8423ce89c9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c59cf4a976c6ebaba15a5a211143f07af456b539bb8982aa4b619de9ab0b62b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9a2a8e08b1878b261f2dbdaf80092a9ede57ca526695048c7cabe274bd3aed96","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f69cb48d5f3da74e8393ee14b006738f8e77058a49e0d10b154dc5f5a0f45cb8","source_sha256":"c85a66a7b2da657c514ab1819675b17454bf0e8632e863fa6dbc6785f28f26f6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have :\n ∏ i ∈ s with w i ≠ 0, z i ^ w i = ∑ i ∈ s with w i ≠ 0, w i * z i ↔\n ∀ j ∈ {x ∈ s | w x ≠ 0}, z j = ∑ i ∈ s with w i ≠ 0, w i * z i :=\n geom_mean_eq_arith_mean_weighted_iff_of_pos' _ w z (by grind)\n (sum_filter_ne_zero _ |>.trans hw') (hz _ <| mem_of_mem_filter · ·)\n grind [prod_filter_of_ne, sum_filter_of_ne, rpow_zero]","hard_negative":true,"metrics":{"chosen_tokens":102,"rejected_tokens":3,"token_jaccard":0.021739,"token_length_ratio":0.029412},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"6c565286e969bda145d729273a70730670b3a18f46af13a80690931fb12eab4b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Analysis.Convex.Jensen\npublic import Mathlib.Analysis.Convex.SpecificFunctions.Basic\npublic import Mathlib.Analysis.SpecialFunctions.Pow.NNReal\npublic import Mathlib.Data.Real.ConjExponents\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne, Jireh Loreaux\n-/\n/-!\n# Mean value inequalities\n\nIn this file we prove several inequalities for finite sums, including AM-GM inequality,\nHM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for\nintegrals of some of these inequalities are available in\n`Mathlib/MeasureTheory/Integral/MeanInequalities.lean`.\n\n## Main theorems\n\n### AM-GM inequality:\n\nThe inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal\nto their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two non-negative vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n\\prod_{i\\in s} z_i^{w_i} ≤ \\sum_{i\\in s} w_iz_i.\n$$\nThe classical version is a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nWe prove a few versions of this inequality. Each of the following lemmas comes in two versions:\na version for real-valued non-negative functions is in the `Real` namespace, and a version for\n`NNReal`-valued functions is in the `NNReal` namespace.\n\n- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s;\n- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;\n- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;\n- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.\n\n\n### HM-GM inequality:\n\nThe inequality says that the harmonic mean of a tuple of positive numbers is less than or equal\nto their geometric mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two positive vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n1/(\\sum_{i\\in s} w_i/z_i) ≤ \\prod_{i\\in s} z_i^{w_i}\n$$\nThe classical version is proven as a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nThe inequalities are proven only for real-valued positive functions on `Finset`s, and namespaced in\n`Real`. The weighted version follows as a corollary of the weighted AM-GM inequality.\n\n### Young's inequality\n\nYoung's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that\n$\\frac{1}{p}+\\frac{1}{q}=1$ we have\n$$\nab ≤ \\frac{a^p}{p} + \\frac{b^q}{q}.\n$$\n\nThis inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's\ninequality (see below).\n\n### Hölder's inequality\n\nThe inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers\nsuch that $\\frac{1}{p}+\\frac{1}{q}=1$) and any two non-negative vectors their inner product is\nless than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the\nsecond vector:\n$$\n\\sum_{i\\in s} a_ib_i ≤ \\sqrt[p]{\\sum_{i\\in s} a_i^p}\\sqrt[q]{\\sum_{i\\in s} b_i^q}.\n$$\n\nWe give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.\n\nThere are at least two short proofs of this inequality. In our proof we prenormalize both vectors,\nthen apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this\ninequality from the generalized mean inequality for well-chosen vectors and weights.\n\n### Minkowski's inequality\n\nThe inequality says that for `p ≥ 1` the function\n$$\n\\|a\\|_p=\\sqrt[p]{\\sum_{i\\in s} a_i^p}\n$$\nsatisfies the triangle inequality $\\|a+b\\|_p\\le \\|a\\|_p+\\|b\\|_p$.\n\nWe give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`.\n\nWe deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\\|a\\|_p$\nis the maximum of the inner product $\\sum_{i\\in s}a_ib_i$ over `b` such that $\\|b\\|_q\\le 1$. Now\nMinkowski's inequality follows from the fact that the maximum value of the sum of two functions is\nless than or equal to the sum of the maximum values of the summands.\n\n## TODO\n\n- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them\n is to define `StrictConvexOn` functions.\n- generalized mean inequality with any `p ≤ q`, including negative numbers;\n- prove that the power mean tends to the geometric mean as the exponent tends to zero.\n\n-/\n\npublic section\n\n\nuniverse u v\n\nopen Finset NNReal ENNReal\nopen scoped BigOperators\n\nnoncomputable section\n\nvariable {ι : Type u} (s : Finset ι)\n\nsection GeomMeanLEArithMean\n\n/-! ### AM-GM inequality -/\n\n\nnamespace Real\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted\nversion for real-valued nonnegative functions. -/\ntheorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by\n -- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.\n by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0\n · rcases A with ⟨i, his, hzi, hwi⟩\n rw [prod_eq_zero his]\n · exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)\n · rw [hzi]\n exact zero_rpow hwi\n -- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality\n -- for `exp` and numbers `log (z i)` with weights `w i`.\n · have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)\n simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this\n convert! this using 1 <;> [apply prod_congr rfl; apply sum_congr rfl] <;> intro i hi\n · rcases eq_or_lt_of_le (hz i hi) with hz | hz\n · simp [A i hi hz.symm]\n · exact rpow_def_of_pos hz _\n · rcases eq_or_lt_of_le (hz i hi) with hz | hz\n · simp [A i hi hz.symm]\n · rw [exp_log hz]\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean. -/\ntheorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)\n (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :\n (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by\n convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz\n · rw [← finsetProd_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]\n refine Finset.prod_congr rfl (fun _ ih => ?_)\n rw [div_eq_mul_inv, rpow_mul (hz _ ih)]\n · simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]\n · exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')\n · simp_rw [div_eq_mul_inv, ← Finset.sum_mul]\n exact mul_inv_cancel₀ (by linarith)\n\ntheorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = x :=\n calc\n ∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by\n refine prod_congr rfl fun i hi => ?_\n rcases eq_or_ne (w i) 0 with h₀ | h₀\n · rw [h₀, rpow_zero, rpow_zero]\n · rw [hx i hi h₀]\n _ = x := by\n rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]\n have : (∑ i ∈ s, w i) ≠ 0 := by\n rw [hw']\n exact one_ne_zero\n obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this\n rw [← hx i his hi]\n exact hz i his\n\ntheorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)\n (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=\n calc\n ∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by\n refine sum_congr rfl fun i hi => ?_\n rcases eq_or_ne (w i) 0 with hwi | hwi\n · rw [hwi, zero_mul, zero_mul]\n · rw [hx i hi hwi]\n _ = x := by rw [← sum_mul, hw', one_mul]\n\ntheorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by\n rw [geom_mean_weighted_of_constant, arith_mean_weighted_of_constant] <;> assumption\n\n/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the\n*positive* weighted version of the AM-GM inequality for real-valued nonnegative functions.\n\nThe condition is that all elements of `z` are equal to their center of mass `∑ i ∈ s, w i * z i`;\nsee `geom_mean_eq_arith_mean_weighted_iff_of_pos` for a version that compares the elements to each\nother instead. -/\ntheorem geom_mean_eq_arith_mean_weighted_iff_of_pos' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, z j = ∑ i ∈ s, w i * z i := by\n by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0\n · rcases A with ⟨i, his, hzi, hwi⟩\n rw [prod_eq_zero his]\n · constructor\n · intro h\n rw [← h]\n intro j hj\n apply eq_zero_of_ne_zero_of_mul_left_eq_zero (ne_of_lt (hw j hj)).symm\n apply (sum_eq_zero_iff_of_nonneg ?_).mp h.symm j hj\n exact fun i hi => (mul_nonneg_iff_of_pos_left (hw i hi)).mpr (hz i hi)\n · intro h\n convert! h i his\n exact hzi.symm\n · rw [hzi]\n exact zero_rpow hwi\n · have hz' := fun i h => lt_of_le_of_ne (hz i h) (fun a => (ne_of_gt (hw i h)) (A i h a.symm))\n have := strictConvexOn_exp.map_sum_eq_iff hw hw' fun i _ => Set.mem_univ <| log (z i)\n simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this\n convert! this using 1\n · apply Eq.congr <;>\n [apply prod_congr rfl; apply sum_congr rfl] <;>\n intro i hi <;>\n simp only [exp_mul, exp_log (hz' i hi)]\n · constructor <;> intro h j hj\n · rw [← arith_mean_weighted_of_constant s w _ (log (z j)) hw' fun i _ => congrFun rfl]\n apply sum_congr rfl\n intro x hx\n simp only [mul_comm, h j hj, h x hx]\n · rw [← arith_mean_weighted_of_constant s w _ (z j) hw' fun i _ => congrFun rfl]\n apply sum_congr rfl\n intro x hx\n simp only [log_injOn_pos (hz' j hj) (hz' x hx), h j hj, h x hx]\n\n@[deprecated (since := \"2026-06-07\")]\nalias geom_mean_eq_arith_mean_weighted_iff' := geom_mean_eq_arith_mean_weighted_iff_of_pos'\n\n/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the\nweighted version of the AM-GM inequality for real-valued nonnegative functions.\n\nThe condition is that all elements of `z` with a nonzero weight are equal to their center of mass\n`∑ i ∈ s, w i * z i`; see `geom_mean_eq_arith_mean_weighted_iff_of_nonneg` for a version that\ncompares the elements to each other instead. -/\n\nTarget:\ntheorem geom_mean_eq_arith_mean_weighted_iff_of_nonneg' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, w j ≠ 0 → z j = ∑ i ∈ s, w i * z i :=\n\nProof body:\n","rejected":"by\n exact geom_mean_eq_arith_mean_weighted_iff_of_nonneg","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5baf2e2e26a0b68ac66e2e177651b2cf54e2b0ed165cba815b6c908a91d0cc0d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis","family_id":"geom_mean_eq_arith_mean_weighted_iff_of_nonneg","file_id":"mathlib/Mathlib/Analysis/MeanInequalities.lean","sample_id":"f69cb48d5f3da74e8393ee14b006738f8e77058a49e0d10b154dc5f5a0f45cb8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"25285bb117855c2247c950210d465fbb991e444f5f49f7719dabed62d341df1d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"76d4e5d0ef729b7147b4052f71b58455e3f9da5556b436da682e738305f7a123","source_sha256":"c7f8b975f885dfe8e2a3866c7aecd0f7c16223863419d554634cf6ca861c1a6d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [balance]","hard_negative":false,"metrics":{"chosen_tokens":5,"rejected_tokens":2,"token_jaccard":0.166667,"token_length_ratio":0.4},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"6d3eddbad5dcd8a9119d8f0a10601787e01abaf1c6730311837dd0a850c2221c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Balance\npublic import Mathlib.Data.Complex.Basic\n\nNamespace:\nComplex\n\nLocal context:\n/-\nCopyright (c) 2017 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Mario Carneiro\n-/\n/-!\n# Finite sums and products of complex numbers\n-/\n\npublic section\n\nopen Fintype\nopen scoped BigOperators\n\nnamespace Complex\n\nvariable {α : Type*} (s : Finset α)\n\n@[simp, norm_cast]\ntheorem ofReal_prod (f : α → ℝ) : ((∏ i ∈ s, f i : ℝ) : ℂ) = ∏ i ∈ s, (f i : ℂ) :=\n map_prod ofRealHom _ _\n\n@[simp, norm_cast]\ntheorem ofReal_sum (f : α → ℝ) : ((∑ i ∈ s, f i : ℝ) : ℂ) = ∑ i ∈ s, (f i : ℂ) :=\n map_sum ofRealHom _ _\n\n@[simp, norm_cast]\nlemma ofReal_expect (f : α → ℝ) : (𝔼 i ∈ s, f i : ℝ) = 𝔼 i ∈ s, (f i : ℂ) :=\n map_expect ofRealHom ..\n\n@[simp, norm_cast]\n\nTarget:\nlemma ofReal_balance [Fintype α] (f : α → ℝ) (a : α) :\n ((balance f a : ℝ) : ℂ) = balance ((↑) ∘ f) a :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Complex","family_id":"ofreal_balance","file_id":"mathlib/Mathlib/Data/Complex/BigOperators.lean","sample_id":"76d4e5d0ef729b7147b4052f71b58455e3f9da5556b436da682e738305f7a123"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b7e2030a7ec47c7b71a48940b4f664219a5143ac729247364a10420a06ef146e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5de52c50b2eddaf2f88883702c8b9d6c2225dea85192213aa9a8033d5ad54366","source_sha256":"c176da80e4503efe6183e93024842ffebc5fe13ab472dafc9d3c186d0c4027cd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← not_lt, find_lt_iff, not_exists, not_and]","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.083333,"token_length_ratio":0.153846},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"6dcfc0e5e72a47cad9bb39ae1da4395610f7e5e660d3c243800d19a763c42a34","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Nat.Find\npublic import Mathlib.Data.PNat.Basic\n\nNamespace:\nPNat\n\nLocal context:\n/-\nCopyright (c) 2022 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky, Floris van Doorn\n-/\n/-!\n# Explicit least witnesses to existentials on positive natural numbers\n\nImplemented via calling out to `Nat.find`.\n\n-/\n\n@[expose] public section\n\n\nnamespace PNat\n\nvariable {p q : ℕ+ → Prop} [DecidablePred p] [DecidablePred q] (h : ∃ n, p n)\n\ninstance decidablePredExistsNat : DecidablePred fun n' : ℕ => ∃ (n : ℕ+) (_ : n' = n), p n :=\n fun n' =>\n decidable_of_iff' (∃ h : 0 < n', p ⟨n', h⟩) <|\n Subtype.exists.trans <| by\n simp_rw [mk_coe, @exists_comm (_ < _) (_ = _), exists_prop, exists_eq_left']\n\n/-- The `PNat` version of `Nat.findX` -/\nprotected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by\n have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩\n have n := Nat.findX this\n refine ⟨⟨n, ?_⟩, ?_, fun m hm pm => ?_⟩\n · obtain ⟨n', hn', -⟩ := n.prop.1\n rw [hn']\n exact n'.prop\n · obtain ⟨n', hn', pn'⟩ := n.prop.1\n simpa [hn', Subtype.coe_eta] using! pn'\n · exact n.prop.2 m hm ⟨m, rfl, pm⟩\n\n/-- If `p` is a (decidable) predicate on `ℕ+` and `hp : ∃ (n : ℕ+), p n` is a proof that\nthere exists some positive natural number satisfying `p`, then `PNat.find hp` is the\nsmallest positive natural number satisfying `p`. Note that `PNat.find` is protected,\nmeaning that you can't just write `find`, even if the `PNat` namespace is open.\n\nThe API for `PNat.find` is:\n\n* `PNat.find_spec` is the proof that `PNat.find hp` satisfies `p`.\n* `PNat.find_min` is the proof that if `m < PNat.find hp` then `m` does not satisfy `p`.\n* `PNat.find_min'` is the proof that if `m` does satisfy `p` then `PNat.find hp ≤ m`.\n-/\nprotected def find : ℕ+ :=\n PNat.findX h\n\nprotected theorem find_spec : p (PNat.find h) :=\n (PNat.findX h).prop.left\n\nprotected theorem find_min : ∀ {m : ℕ+}, m < PNat.find h → ¬p m :=\n @(PNat.findX h).prop.right\n\nprotected theorem find_min' {m : ℕ+} (hm : p m) : PNat.find h ≤ m :=\n le_of_not_gt fun l => PNat.find_min h l hm\n\nvariable {n m : ℕ+}\n\ntheorem find_eq_iff : PNat.find h = m ↔ p m ∧ ∀ n < m, ¬p n := by\n constructor\n · rintro rfl\n exact ⟨PNat.find_spec h, fun _ => PNat.find_min h⟩\n · rintro ⟨hm, hlt⟩\n exact le_antisymm (PNat.find_min' h hm) (not_lt.1 <| imp_not_comm.1 (hlt _) <| PNat.find_spec h)\n\n@[simp]\ntheorem find_lt_iff (n : ℕ+) : PNat.find h < n ↔ ∃ m < n, p m :=\n ⟨fun h2 => ⟨PNat.find h, h2, PNat.find_spec h⟩, fun ⟨_, hmn, hm⟩ =>\n (PNat.find_min' h hm).trans_lt hmn⟩\n\n@[simp]\ntheorem find_le_iff (n : ℕ+) : PNat.find h ≤ n ↔ ∃ m ≤ n, p m := by\n simp only [← lt_add_one_iff, find_lt_iff]\n\n@[simp]\n\nTarget:\ntheorem le_find_iff (n : ℕ+) : n ≤ PNat.find h ↔ ∀ m < n, ¬p m :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PNat","family_id":"le_find_iff","file_id":"mathlib/Mathlib/Data/PNat/Find.lean","sample_id":"5de52c50b2eddaf2f88883702c8b9d6c2225dea85192213aa9a8033d5ad54366"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1b6a1d9590da39c9820ca3e6ee567135761314ec1c8ac6d1a9385b82b6d745b7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e27c0fdc965e93b7112ac99f88b6b2a4ccb11147326df53b132e50f5a2ee2fac","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3a3d7287cfd08006945a34adccd4ff6c003953595820af331cea43fd089d1560","source_sha256":"380339d381ec2013c54136321e5c6043787ad5c08574d532f7b25cfd0cd49785","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [IsNonempty, Set.nonempty_iff_ne_empty, Hypergraph.ext_iff]\n grind [bot_vertexSet, bot_edgeSet]\n\nalias ⟨_, IsNonempty.ne_bot⟩ := ne_bot_iff","hard_negative":true,"metrics":{"chosen_tokens":29,"rejected_tokens":2,"token_jaccard":0.045455,"token_length_ratio":0.068966},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"6ee5054331272f039dcce1dee9d725301da2c58c06c3e69b47b422a48eb5be92","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Basic\npublic import Mathlib.Data.Set.Card\n\nNamespace:\nHypergraph\n\nLocal context:\n/-\nCopyright (c) 2026 Evan Spotte-Smith, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Evan Spotte-Smith, Bhavik Mehta\n-/\n/-!\n# Undirected hypergraphs\n\nAn *undirected hypergraph* (here abbreviated as *hypergraph*) `H` is a generalization of a graph\n(see `Mathlib.Combinatorics.Graph` or `Mathlib.Combinatorics.SimpleGraph`) and consists of a set of\n*vertices*, usually denoted `V` or `V(H)`, and a set of *hyperedges*, here called *edges* and\ndenoted `E` or `E(H)`. In contrast with a graph, where edges are unordered pairs of vertices, in\nhypergraphs, edges are unordered sets of vertices; i.e., they are subsets of the vertex set `V`.\n\nA hypergraph where `V = ∅` and `E = ∅` is *empty*, denoted `⊥`. A hypergraph with a nonempty\nvertex set (`V ≠ ∅`) and empty edge set is *trivial*. A hypergraph where the edge set is the power\nset of the vertex set (or, equivalently, where all possible subsets of the vertex sets are in the\nedge set) is *complete*.\n\nIf a edge `e` contains only one vertex (i.e., `|e| = 1`), then it is a *loop*.\n\nThis module defines `Hypergraph α` for a vertex type `α` (edges are defined as `Set (Set α)`).\n\n## Main definitions\n\n* `Hypergraph α` is the type of undirected hypergraphs with vertices of type `α` and edges of type\n `Set α`. In addition to vertices and hyperedges, a `Hypergraph` must have the property that all\n edges are subsets of the vertex set.\n\nFor `H : Hypergraph α`:\n\n* `H.vertexSet` (abbrev. `V(H)`) denotes the vertex set of `H` as a term in `Set α`.\n* `H.edgeSet` (abbrev. `E(H)`) denotes the edge set of `H` as a term in `Set (Set α)`. Hyperedges\n must be subsets of `V(H)`.\n* `H.Adj x y` means that there exists some edge containing both `x` and `y` (or, in other\n words, `x` and `y` are incident to some shared edge `e`).\n* `H.EAdj e f` means that there exists some vertex that is incident to the edges `e` and\n `f : Set α`.\n\n## Implementation details\n\nThis implementation is heavily inspired by Peter Nelson and Jun Kwon's `Graph` implementation,\nwhich was in turn inspired by `Matroid`.\n\nParaphrasing `Mathlib.Combinatorics.Graph.Basic`:\n\"The main tradeoff is that parts of the API will need to care about whether a term\n`x : α` or `e : Set α` is a 'real' vertex or edge of the graph, rather than something outside\nthe vertex or edge set. This is an issue, but is likely amenable to automation.\"\n\nBecause `edgeSet` is a `Set (Set α)`, rather than a multiset, here we are assuming that\nall hypergraphs are *without repeated edge*.\n\n-/\n\npublic section\n\nopen Set\n\nvariable {α β γ : Type*} {x y : α} {e e' f : Set α}\n\n/--\nAn undirected hypergraph with vertices of type `α` and edges of type `Set α`, as described by vertex\nand edge sets `vertexSet : Set α` and `edgeSet : Set (Set α)`.\n\nThe requirement `subset_vertexSet_of_mem_edgeSet` ensures that all vertices in edges are part of\n`vertexSet`, i.e., all edges are subsets of the `vertexSet`.\n-/\n@[ext]\nstructure Hypergraph (α : Type*) where\n /-- The vertex set -/\n vertexSet : Set α\n /-- The edge set -/\n edgeSet : Set (Set α)\n /-- All edges must be subsets of the vertex set -/\n subset_vertexSet_of_mem_edgeSet' : ∀ ⦃e⦄, e ∈ edgeSet → e ⊆ vertexSet\n\nnamespace Hypergraph\n\nvariable {H : Hypergraph α}\n\n/-! ## Notation -/\n\n/-- `V(H)` denotes the `vertexSet` of a hypergraph `H` -/\nscoped notation \"V(\" H \")\" => Hypergraph.vertexSet H\n\n/-- `E(H)` denotes the `edgeSet` of a hypergraph `H` -/\nscoped notation \"E(\" H \")\" => Hypergraph.edgeSet H\n\n\n/-! ## Vertex-Hyperedge Incidence -/\n\n@[simp]\nlemma subset_vertexSet_of_mem_edgeSet (he : e ∈ E(H)) : e ⊆ V(H) :=\n H.subset_vertexSet_of_mem_edgeSet' he\n\nalias _root_.Membership.mem.subset_vertexSet := subset_vertexSet_of_mem_edgeSet\n\nlemma edgeSet_subset_powerset_vertexSet {H : Hypergraph α} : E(H) ⊆ V(H).powerset :=\n fun _ ↦ subset_vertexSet_of_mem_edgeSet\n\nlemma mem_vertexSet_of_mem_edgeSet (he : e ∈ E(H)) (hx : x ∈ e) : x ∈ V(H) :=\n H.subset_vertexSet_of_mem_edgeSet he hx\n\nlemma edgeSet.ext_iff (he : e ∈ E(H)) (he' : e' ∈ E(H)) : e = e' ↔ ∀ x ∈ V(H), x ∈ e ↔ x ∈ e' := by\n grind [he.subset_vertexSet, he'.subset_vertexSet]\n\nlemma sUnion_edgeSet_subset_vertexSet : ⋃₀ E(H) ⊆ V(H) :=\n subset_powerset_iff.mp edgeSet_subset_powerset_vertexSet\n\n/-! ## Vertex and Hyperedge Adjacency -/\n\n/--\nPredicate for adjacency. Two vertices `x` and `y` are adjacent if there is some edge `e ∈ E(H)`\nwhere `x` and `y` are both incident to `e`.\n\nNote that we do not need to explicitly check that `x, y ∈ V(H)` here because a vertex that is not in\nthe vertex set cannot be incident to any edge.\n-/\n@[expose]\ndef Adj (H : Hypergraph α) (x : α) (y : α) : Prop :=\n ∃ e ∈ E(H), x ∈ e ∧ y ∈ e\n\nlemma Adj.symm (h : H.Adj x y) : H.Adj y x := by grind [Adj]\n\nlemma adj_comm (x y : α) : H.Adj x y ↔ H.Adj y x := ⟨.symm, .symm⟩\n\n/--\nPredicate for edge adjacency. Analogous to `Hypergraph.Adj`, edges `e` and `f` are\nadjacent if there is some vertex `x ∈ V(H)` where `x` is incident to both `e` and `f`.\n-/\n@[expose]\ndef EAdj (H : Hypergraph α) (e : Set α) (f : Set α) : Prop :=\n e ∈ E(H) ∧ f ∈ E(H) ∧ ∃ x, x ∈ e ∧ x ∈ f\n\nlemma EAdj.exists_vertex (h : H.EAdj e f) : ∃ x ∈ V(H), x ∈ e ∧ x ∈ f := by\n obtain ⟨x, hx⟩ := h.2.2\n exact ⟨x, mem_vertexSet_of_mem_edgeSet h.1 hx.1, hx⟩\n\nlemma EAdj.symm (h : H.EAdj e f) : H.EAdj f e := by grind [EAdj]\n\nlemma EAdj.inter_nonempty (hef : H.EAdj e f) : (e ∩ f).Nonempty :=\n Set.inter_nonempty.mpr hef.2.2\n\nlemma eAdj_comm (e f) : H.EAdj e f ↔ H.EAdj f e := ⟨.symm, .symm⟩\n\n/-! ## Basic Hypergraph Definitions & Predicates-/\n\n/-- The *image* of a hypergraph `H : Hypergraph α` under a function `f : α → β` is the hypergraph\n`Hᶠ : Hypergraph β` where the vertex set of `Hᶠ` is the image of `V(H)` under `f` and the edge set\nof `Hᶠ` is the set of images of the edges (subsets of vertices) in `E(H)`. -/\n@[simps, expose]\nprotected def image (H : Hypergraph α) (f : α → β) : Hypergraph β where\n vertexSet := V(H).image f\n edgeSet := E(H).image (Set.image f)\n subset_vertexSet_of_mem_edgeSet' := by\n rintro - ⟨e, he, rfl⟩\n exact image_mono he.subset_vertexSet\n\nlemma mem_edgeSet_image {f : α → β} {e : Set β} : e ∈ E(H.image f) ↔ ∃ e' ∈ E(H), f '' e' = e :=\n .rfl\n\nlemma image_mem_edgeSet_image {f : α → β} (he : e ∈ E(H)) : e.image f ∈ E(H.image f) :=\n mem_image_of_mem _ he\n\nlemma image_image {f : α → β} {g : β → γ} (H : Hypergraph α) :\n (H.image f).image g = H.image (g ∘ f) := by\n ext <;> simp [Set.image_image]\n\n/-- A vertex is isolated if it is not incident to any edges (including loops). -/\n@[expose]\ndef IsIsolated (H : Hypergraph α) (x : α) : Prop := ∀ e ∈ E(H), x ∉ e\n\nlemma sUnion_edgeSet_eq_vertexSet_iff_all_vertex_not_isolated :\n ⋃₀ E(H) = V(H) ↔ ∀ x ∈ V(H), ¬IsIsolated H x := by\n grind [IsIsolated, mem_vertexSet_of_mem_edgeSet]\n\n/-- A loop is an edge whose associated vertex subset consists of a single vertex. -/\n@[expose]\ndef IsLoop (H : Hypergraph α) (e : Set α) : Prop := e ∈ E(H) ∧ ∃ x, e = {x}\n\nlemma isLoop_iff_mem_edgeSet_and_singleton : H.IsLoop e ↔ (e ∈ E(H) ∧ ∃ x, e = {x}) := .rfl\n\nlemma isLoop_iff_mem_and_ncard_one : H.IsLoop e ↔ (e ∈ E(H) ∧ Set.ncard e = 1) := by\n grind [IsLoop, ncard_eq_one, mem_vertexSet_of_mem_edgeSet]\n\nlemma IsLoop.ncard_one (h : H.IsLoop e) : Set.ncard e = 1 := (isLoop_iff_mem_and_ncard_one.mp h).2\n\n/-- A hypergraph is nonempty if it has at least one vertex or at least one edge. -/\n@[expose]\ndef IsNonempty (H : Hypergraph α) : Prop := V(H).Nonempty ∨ E(H).Nonempty\n\n/-- The empty hypergraph (bottom) on a type. -/\n@[simps]\ninstance (α : Type*) : Bot (Hypergraph α) where\n bot.vertexSet := ∅\n bot.edgeSet := ∅\n bot.subset_vertexSet_of_mem_edgeSet' := by simp\n\n@[simp]\nlemma IsNonempty.of_nonempty_vertexSet (hV : V(H).Nonempty) : H.IsNonempty :=\n .inl hV\n\n@[simp]\nlemma IsNonempty.of_nonempty_edgeSet (hE : E(H).Nonempty) : H.IsNonempty :=\n .inr hE\n\n@[simp]\n\nTarget:\ntheorem ne_bot_iff : H ≠ ⊥ ↔ H.IsNonempty :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_3a3d7287cfd0","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"0dc72d85ab114ba70d34d866356270f26d53590959219b1c838c8f5a886e867c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Hypergraph","family_id":"ne_bot_iff","file_id":"mathlib/Mathlib/Combinatorics/Hypergraph/Basic.lean","sample_id":"3a3d7287cfd08006945a34adccd4ff6c003953595820af331cea43fd089d1560"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f254bd59e6f4fbdc15a246dde0e74d3848ca5347d0a25d1248674d1989415258","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b5b7733b31f61a4fb5a91fd63f6062b13954e2f433a6b8e11761963065060eb1","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"32215e9ee86a34a10891b4942cd1723e7567edc6448b3d96cb58a09a15c7ada1","source_sha256":"765132ee1c17dfe14fb0896007fdc73590153bf141bc5f6f17a4cfd84843c74f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using! congr($(f.hom.2 g) a)","hard_negative":true,"metrics":{"chosen_tokens":17,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.176471},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"6f12e84010085fb45f6ab1eeb7eb9a8f4f314af5a7ff31cdaf82ad742e160670","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Action.Basic\npublic import Mathlib.RepresentationTheory.Continuous.Basic\n\nNamespace:\nTopRep\n\nLocal context:\n/-\nCopyright (c) 2026 Yunzhou Xie. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Edison Xie, Richard Hill\n-/\n/-!\n# Topological representations\n\nThis file defines the category `TopRep k G` of topological representations of a monoid `G` over a\ntopological ring `k`, and shows that it is equivalent to the category `Action (TopModuleCat k) G`.\n-/\n\n@[expose] public section\n\nuniverse w u v\n\n/-- The category of topological representations of a monoid `G` over a topological ring `k`, and\ntheir morphisms. -/\nstructure TopRep (k : Type u) (G : Type v) [TopologicalSpace k] [Ring k]\n [IsTopologicalRing k] [Monoid G] where\n private mk ::\n /-- the underlying type of an object in `TopRep k G` -/\n V : Type w\n [hV1 : AddCommGroup V]\n [hV2 : Module k V]\n [hV3 : TopologicalSpace V]\n [hV4 : IsTopologicalAddGroup V]\n [hV5 : ContinuousSMul k V]\n /-- the underlying continuous representation of an object in `TopRep k G` -/\n ρ : ContRepresentation k G V\n\nnamespace TopRep\n\nvariable {k : Type u} {G : Type v} {X Y : Type w} [TopologicalSpace k] [Ring k]\n [IsTopologicalRing k] [Monoid G] [AddCommGroup X] [Module k X] [TopologicalSpace X]\n [IsTopologicalAddGroup X] [ContinuousSMul k X] [AddCommGroup Y] [Module k Y] [TopologicalSpace Y]\n [IsTopologicalAddGroup Y] [ContinuousSMul k Y] {ρ : ContRepresentation k G X}\n {σ : ContRepresentation k G Y}\n\nopen ContRepresentation CategoryTheory\n\nattribute [instance] hV1 hV2 hV3 hV4 hV5\n\ninitialize_simps_projections TopRep (-hV1, -hV2)\n\ninstance : CoeSort (TopRep k G) (Type w) := ⟨TopRep.V⟩\n\nattribute [coe] V\n\nvariable (ρ) in\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\n/-- The object in the category of topological representations associated to a type equipped with a\ncontinuous representation. This is the preferred way to construct a term of `TopRep k G`. -/\nabbrev of : TopRep k G := ⟨X, ρ⟩\n\nvariable (X ρ) in\nlemma of_V : (of ρ).V = X := by with_reducible rfl\n\nvariable (X ρ) in\nlemma of_ρ : (of ρ).ρ = ρ := by with_reducible rfl\n\nset_option backward.privateInPublic true in\n/-- The type of morphisms in `TopRep k G`. -/\n@[ext]\nstructure Hom (A B : TopRep k G) where\n private mk ::\n /-- The underlying `G`-equivariant linear map. -/\n hom' : A.ρ →ⁱL B.ρ\n\nvariable (A B C : TopRep.{w} k G)\n\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\ninstance : Category (TopRep.{w} k G) where\n Hom A B := Hom A B\n id A := ⟨.id (π₁ := A.ρ)⟩\n comp f g := ⟨g.hom'.comp f.hom'⟩\n\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\ninstance : ConcreteCategory (TopRep.{w} k G) (fun A B ↦ A.ρ →ⁱL B.ρ) where\n hom := Hom.hom'\n ofHom := Hom.mk\n\nvariable {A B} in\n/-- Turn a morphism in `TopRep` back into an `IntertwiningMap`. -/\nabbrev Hom.hom (f : Hom A B) := ConcreteCategory.hom (C := TopRep k G) f\n\nvariable {A B} in\n/-- Typecheck an `IntertwiningMap` as a morphism in `TopRep`. -/\nabbrev ofHom (f : ρ →ⁱL σ) : of ρ ⟶ of σ :=\n ConcreteCategory.ofHom (C := TopRep.{w} k G) f\n\n@[simp] lemma hom_ofHom (f : ρ →ⁱL σ) : (ofHom f).hom = f := rfl\n\n@[simp] lemma ofHom_hom (f : A ⟶ B) : ofHom f.hom = f := rfl\n\nvariable {A B} in\n/-- The morphism of topological modules underlying a morphism in `TopRep k G`. -/\nabbrev Hom.toTopModuleCatHom (f : Hom A B) :\n TopModuleCat.of k A ⟶ TopModuleCat.of k B :=\n TopModuleCat.ofHom f.hom.toContinuousLinearMap\n\n/-\nThe results below duplicate the `ConcreteCategory` simp lemmas, but we can keep them for `dsimp`.\n-/\n@[simp] lemma hom_id : (𝟙 A : A ⟶ A).hom = .id (π₁ := A.ρ) := rfl\n\n/- Provided for rewriting. -/\nlemma id_apply (a : A) : (𝟙 A : A ⟶ A) a = a := rfl\n\n@[simp] lemma hom_comp (f : A ⟶ B) (g : B ⟶ C) : (f ≫ g).hom = g.hom.comp f.hom := rfl\n\n/- Provided for rewriting. -/\nvariable {A B C} in\nlemma comp_apply (f : A ⟶ B) (g : B ⟶ C) (a : A) : (f ≫ g) a = g (f a) := rfl\n\nvariable {A B} in\n@[ext] lemma hom_ext {f g : A ⟶ B} (hf : f.hom = g.hom) : f = g := Hom.ext hf\n\nvariable {A B} in\n\nTarget:\nlemma hom_comm_apply (f : A ⟶ B) (g : G) (a : A) : f.hom (A.ρ g a) = B.ρ g (f.hom a) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_32215e9ee86a","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"18c7912e92a420711c960f02786346b9e7f149a3df4f6245f68e32c238e40733","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory/Continuous","family_id":"hom_comm_apply","file_id":"mathlib/Mathlib/RepresentationTheory/Continuous/TopRep.lean","sample_id":"32215e9ee86a34a10891b4942cd1723e7567edc6448b3d96cb58a09a15c7ada1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"219aabb3f49e8e9f29dd6b52b015615566d77a5e4b67b3d6ea17166f372f1304","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8f9a448dc9b00dff425f926c9b1ea2f761a8ce7098ac160a43b137dbdc55b364","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"548c1dc0c4573523f7f04a8c5e4c876bf6f8602d323840f2b69bf0e2529a3781","source_sha256":"5fe320cf8339285f3ebda4142570292583dc5699644499632f4faabcfba59b47","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [nhdsWithin, nhds_prod_eq, ← prod_inf_prod, prod_principal_principal]","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":18,"token_jaccard":0.6875,"token_length_ratio":1.384615},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"707a3ff9178752f802375266e1e34ce2e11bdcfbc9fe31dfde4a55d8da5999db","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homeomorph.Defs\npublic import Mathlib.Topology.Maps.Basic\npublic import Mathlib.Topology.Separation.SeparatedNhds\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\n/-!\n# Disjoint unions and products of topological spaces\n\nThis file constructs sums (disjoint unions) and products of topological spaces\nand sets up their basic theory, such as criteria for maps into or out of these\nconstructions to be continuous; descriptions of the open sets, neighborhood filters,\nand generators of these constructions; and their behavior with respect to embeddings\nand other specific classes of maps.\n\nWe also provide basic homeomorphisms, to show that sums and products are commutative, associative\nand distributive (up to homeomorphism).\n\n## Implementation note\n\nThe constructed topologies are defined using induced and coinduced topologies\nalong with the complete lattice structure on topologies. Their universal properties\n(for example, a map `X → Y × Z` is continuous if and only if both projections\n`X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of\ncontinuity. With more work we can also extract descriptions of the open sets,\nneighborhood filters and so on.\n\n## Tags\n\nproduct, sum, disjoint union\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology TopologicalSpace Set Filter Function\n\nuniverse u v u' v'\n\nvariable {X : Type u} {Y : Type v} {W Z ε ζ : Type*}\n\ninstance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X ⊕ Y) :=\n coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂\n\ninstance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X × Y) :=\n induced Prod.fst t₁ ⊓ induced Prod.snd t₂\n\nsection Prod\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W]\n [TopologicalSpace ε] [TopologicalSpace ζ]\n\n@[simp]\ntheorem continuous_prodMk {f : X → Y} {g : X → Z} :\n (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g :=\n continuous_inf_rng.trans <| continuous_induced_rng.and continuous_induced_rng\n\n@[continuity]\ntheorem continuous_fst : Continuous (@Prod.fst X Y) :=\n (continuous_prodMk.1 continuous_id).1\n\n/-- Postcomposing `f` with `Prod.fst` is continuous -/\n@[fun_prop]\ntheorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 :=\n continuous_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous -/\ntheorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst :=\n hf.comp continuous_fst\n\ntheorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p :=\n continuous_fst.continuousAt\n\n/-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).1) x :=\n continuousAt_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/\ntheorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X × Y => f x.fst) (x, y) :=\n ContinuousAt.comp hf continuousAt_fst\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) :\n ContinuousAt (fun x : X × Y => f x.fst) x :=\n hf.comp continuousAt_fst\n\ntheorem Filter.Tendsto.fst_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) :=\n continuousAt_fst.tendsto.comp h\n\n@[continuity]\ntheorem continuous_snd : Continuous (@Prod.snd X Y) :=\n (continuous_prodMk.1 continuous_id).2\n\n/-- Postcomposing `f` with `Prod.snd` is continuous -/\n@[fun_prop]\ntheorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 :=\n continuous_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous -/\ntheorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd :=\n hf.comp continuous_snd\n\ntheorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p :=\n continuous_snd.continuousAt\n\n/-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).2) x :=\n continuousAt_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/\ntheorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) :\n ContinuousAt (fun x : X × Y => f x.snd) (x, y) :=\n ContinuousAt.comp hf continuousAt_snd\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) :\n ContinuousAt (fun x : X × Y => f x.snd) x :=\n hf.comp continuousAt_snd\n\ntheorem Filter.Tendsto.snd_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) :=\n continuousAt_snd.tendsto.comp h\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous fun x => (f x, g x) :=\n continuous_prodMk.2 ⟨hf, hg⟩\n\n@[continuity]\ntheorem Continuous.prodMk_right (x : X) : Continuous fun y : Y => (x, y) := by fun_prop\n\n@[continuity]\ntheorem Continuous.prodMk_left (y : Y) : Continuous fun x : X => (x, y) := by fun_prop\n\n/-- If `f x y` is continuous in `x` for all `y ∈ s`,\nthen the set of `x` such that `f x` maps `s` to `t` is closed. -/\nlemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t)\n (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} := by\n simpa only [MapsTo, setOf_forall] using! isClosed_biInter fun y hy ↦ ht.preimage (hf y hy)\n\ntheorem Continuous.comp₂ {g : X × Y → Z} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) : Continuous fun w => g (e w, f w) :=\n hg.comp <| he.prodMk hf\n\ntheorem Continuous.comp₃ {g : X × Y × Z → ε} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) :\n Continuous fun w => g (e w, f w, k w) :=\n hg.comp₂ he <| hf.prodMk hk\n\ntheorem Continuous.comp₄ {g : X × Y × Z × ζ → ε} (hg : Continuous g) {e : W → X} (he : Continuous e)\n {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) {l : W → ζ}\n (hl : Continuous l) : Continuous fun w => g (e w, f w, k w, l w) :=\n hg.comp₃ he hf <| hk.prodMk hl\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMap {f : Z → X} {g : W → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous (Prod.map f g) :=\n hf.fst'.prodMk hg.snd'\n\n/-- A version of `continuous_inf_dom_left` for binary functions -/\ntheorem continuous_inf_dom_left₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X}\n {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z}\n (h : by haveI := ta1; haveI := tb1; exact Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by\n have ha := @continuous_inf_dom_left _ _ id ta1 ta2 ta1 (@continuous_id _ (id _))\n have hb := @continuous_inf_dom_left _ _ id tb1 tb2 tb1 (@continuous_id _ (id _))\n have h_continuous_id := @Continuous.prodMap _ _ _ _ ta1 tb1 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id\n\n/-- A version of `continuous_inf_dom_right` for binary functions -/\ntheorem continuous_inf_dom_right₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X}\n {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z}\n (h : by haveI := ta2; haveI := tb2; exact Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by\n have ha := @continuous_inf_dom_right _ _ id ta1 ta2 ta2 (@continuous_id _ (id _))\n have hb := @continuous_inf_dom_right _ _ id tb1 tb2 tb2 (@continuous_id _ (id _))\n have h_continuous_id := @Continuous.prodMap _ _ _ _ ta2 tb2 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id\n\n/-- A version of `continuous_sInf_dom` for binary functions -/\ntheorem continuous_sInf_dom₂ {X Y Z} {f : X → Y → Z} {tas : Set (TopologicalSpace X)}\n {tbs : Set (TopologicalSpace Y)} {tX : TopologicalSpace X} {tY : TopologicalSpace Y}\n {tc : TopologicalSpace Z} (hX : tX ∈ tas) (hY : tY ∈ tbs)\n (hf : Continuous fun p : X × Y => f p.1 p.2) : by\n haveI := sInf tas; haveI := sInf tbs\n exact @Continuous _ _ _ tc fun p : X × Y => f p.1 p.2 := by\n have hX := continuous_sInf_dom hX continuous_id\n have hY := continuous_sInf_dom hY continuous_id\n have h_continuous_id := @Continuous.prodMap _ _ _ _ tX tY (sInf tas) (sInf tbs) _ _ hX hY\n exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ hf h_continuous_id\n\ntheorem Filter.Eventually.prod_inl_nhds {p : X → Prop} {x : X} (h : ∀ᶠ x in 𝓝 x, p x) (y : Y) :\n ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).1 :=\n continuousAt_fst h\n\ntheorem Filter.Eventually.prod_inr_nhds {p : Y → Prop} {y : Y} (h : ∀ᶠ x in 𝓝 y, p x) (x : X) :\n ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).2 :=\n continuousAt_snd h\n\ntheorem Filter.Eventually.prodMk_nhds {px : X → Prop} {x} (hx : ∀ᶠ x in 𝓝 x, px x) {py : Y → Prop}\n {y} (hy : ∀ᶠ y in 𝓝 y, py y) : ∀ᶠ p in 𝓝 (x, y), px (p : X × Y).1 ∧ py p.2 :=\n (hx.prod_inl_nhds y).and (hy.prod_inr_nhds x)\n\n@[fun_prop]\ntheorem continuous_swap : Continuous (Prod.swap : X × Y → Y × X) :=\n continuous_snd.prodMk continuous_fst\n\nlemma isClosedMap_swap : IsClosedMap (Prod.swap : X × Y → Y × X) := fun s hs ↦ by\n rw [image_swap_eq_preimage_swap]\n exact hs.preimage continuous_swap\n\ntheorem Continuous.uncurry_left {f : X → Y → Z} (x : X) (h : Continuous (uncurry f)) :\n Continuous (f x) :=\n h.comp (.prodMk_right _)\n\ntheorem Continuous.uncurry_right {f : X → Y → Z} (y : Y) (h : Continuous (uncurry f)) :\n Continuous fun a => f a y :=\n h.comp (.prodMk_left _)\n\ntheorem continuous_curry {g : X × Y → Z} (x : X) (h : Continuous g) : Continuous (curry g x) :=\n Continuous.uncurry_left x h\n\ntheorem IsOpen.prod {s : Set X} {t : Set Y} (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ×ˢ t) :=\n (hs.preimage continuous_fst).inter (ht.preimage continuous_snd)\n\n-- Porting note: Lean fails to find `t₁` and `t₂` by unification\ntheorem nhds_prod_eq {x : X} {y : Y} : 𝓝 (x, y) = 𝓝 x ×ˢ 𝓝 y := by\n rw [prod_eq_inf, instTopologicalSpaceProd, nhds_inf (t₁ := TopologicalSpace.induced Prod.fst _)\n (t₂ := TopologicalSpace.induced Prod.snd _), nhds_induced, nhds_induced]\n\nTarget:\ntheorem nhdsWithin_prod_eq (x : X) (y : Y) (s : Set X) (t : Set Y) :\n 𝓝[s ×ˢ t] (x, y) = 𝓝[s] x ×ˢ 𝓝[t] y :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n simp only [nhdsWithin, nhds_prod_eq, ← prod_inf_prod, prod_principal_principal]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Constructions","family_id":"nhdswithin_prod_eq","file_id":"mathlib/Mathlib/Topology/Constructions/SumProd.lean","sample_id":"548c1dc0c4573523f7f04a8c5e4c876bf6f8602d323840f2b69bf0e2529a3781"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e850cb8690c0b3e0e15e79d7ff3e05e204dd3ab2deae96dc5125ed68cc44daaa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8cf03a7e58a6976d73ad4af13c25f696c710ed183164b463130da9c7e315b5b6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c50e7dfc15f5b03aac949d5d4c73b6d02918eb7ce6d372c202e9c6d7181bbde0","source_sha256":"8089e9bbcb1a48e8e29fbebba778eeb4b97519d0a41b768086dd5d1224f6551a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor <;> intro h\n · exact h 1 0\n · intro n₁ n₂ a₁ a₂\n have h' : ∀ n a₁ a₂, f^[n] (a₁ ⊔ a₂) ≤ f^[n] a₁ ⊔ a₂ := by\n intro n\n induction n with\n | zero => intro a₁ a₂; rfl\n | succ n ih =>\n intro a₁ a₂\n calc\n f^[n + 1] (a₁ ⊔ a₂) = f^[n] (f (a₁ ⊔ a₂)) := Function.iterate_succ_apply f n _\n _ ≤ f^[n] (f a₁ ⊔ a₂) := f.mono.iterate n (h a₁ a₂)\n _ ≤ f^[n] (f a₁) ⊔ a₂ := ih _ _\n _ = f^[n + 1] a₁ ⊔ a₂ := by rw [← Function.iterate_succ_apply]\n calc\n f^[n₁ + n₂] (a₁ ⊔ a₂) = f^[n₁] (f^[n₂] (a₁ ⊔ a₂)) :=\n Function.iterate_add_apply f n₁ n₂ _\n _ = f^[n₁] (f^[n₂] (a₂ ⊔ a₁)) := by rw [sup_comm]\n _ ≤ f^[n₁] (f^[n₂] a₂ ⊔ a₁) := f.mono.iterate n₁ (h' n₂ _ _)\n _ = f^[n₁] (a₁ ⊔ f^[n₂] a₂) := by rw [sup_comm]\n _ ≤ f^[n₁] a₁ ⊔ f^[n₂] a₂ := h' n₁ a₁ _","hard_negative":true,"metrics":{"chosen_tokens":358,"rejected_tokens":3,"token_jaccard":0.039216,"token_length_ratio":0.00838},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"71401e8e94814fc3b38bb6805b913474c91632c410e574cfee8fb12d9fdbdebb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Function.Iterate\npublic import Mathlib.Order.GaloisConnection.Basic\npublic import Mathlib.Order.Hom.Basic\n\nNamespace:\nOrderHom\n\nLocal context:\n/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Anne Baanen\n-/\n/-!\n# Lattice structure on order homomorphisms\n\nThis file defines the lattice structure on order homomorphisms, which are bundled\nmonotone functions.\n\n## Main definitions\n\n* `OrderHom.instCompleteLattice`: if `β` is a complete lattice, so is `α →o β`\n\n## Tags\n\nmonotone map, bundled morphism\n-/\n\npublic section\n\n\nnamespace OrderHom\n\nvariable {α β : Type*}\n\nsection Preorder\n\nvariable [Preorder α]\n\ninstance [SemilatticeSup β] : Max (α →o β) where\n max f g := ⟨fun a => f a ⊔ g a, f.mono.sup g.mono⟩\n\n@[simp] lemma coe_sup [SemilatticeSup β] (f g : α →o β) :\n ((f ⊔ g : α →o β) : α → β) = (f : α → β) ⊔ g := rfl\n\ninstance [SemilatticeSup β] : SemilatticeSup (α →o β) :=\n { (_ : PartialOrder (α →o β)) with\n sup := Max.max\n le_sup_left := fun _ _ _ => le_sup_left\n le_sup_right := fun _ _ _ => le_sup_right\n sup_le := fun _ _ _ h₀ h₁ x => sup_le (h₀ x) (h₁ x) }\n\ninstance [SemilatticeInf β] : Min (α →o β) where\n min f g := ⟨fun a => f a ⊓ g a, f.mono.inf g.mono⟩\n\n@[simp] lemma coe_inf [SemilatticeInf β] (f g : α →o β) :\n ((f ⊓ g : α →o β) : α → β) = (f : α → β) ⊓ g := rfl\n\ninstance [SemilatticeInf β] : SemilatticeInf (α →o β) :=\n { (_ : PartialOrder (α →o β)), (dualIso α β).symm.toGaloisInsertion.liftSemilatticeInf with\n inf := (· ⊓ ·) }\n\ninstance lattice [Lattice β] : Lattice (α →o β) :=\n { (_ : SemilatticeSup (α →o β)), (_ : SemilatticeInf (α →o β)) with }\n\n@[simps]\ninstance [Preorder β] [OrderBot β] : Bot (α →o β) where\n bot := const α ⊥\n\ninstance orderBot [Preorder β] [OrderBot β] : OrderBot (α →o β) where\n bot_le _ _ := bot_le\n\n@[simps]\ninstance instTopOrderHom [Preorder β] [OrderTop β] : Top (α →o β) where\n top := const α ⊤\n\ninstance orderTop [Preorder β] [OrderTop β] : OrderTop (α →o β) where\n le_top _ _ := le_top\n\ninstance [CompleteLattice β] : InfSet (α →o β) where\n sInf s := ⟨fun x => ⨅ f ∈ s, (f :) x, fun _ _ h => iInf₂_mono fun f _ => f.mono h⟩\n\n@[simp]\ntheorem sInf_apply [CompleteLattice β] (s : Set (α →o β)) (x : α) :\n sInf s x = ⨅ f ∈ s, (f :) x :=\n rfl\n\ntheorem iInf_apply {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) (x : α) :\n (⨅ i, f i) x = ⨅ i, f i x :=\n (sInf_apply _ _).trans iInf_range\n\n@[simp, norm_cast]\ntheorem coe_iInf {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) :\n ((⨅ i, f i : α →o β) : α → β) = ⨅ i, (f i : α → β) := by\n funext x; simp [iInf_apply]\n\ninstance [CompleteLattice β] : SupSet (α →o β) where\n sSup s := ⟨fun x => ⨆ f ∈ s, (f :) x, fun _ _ h => iSup₂_mono fun f _ => f.mono h⟩\n\n@[simp]\ntheorem sSup_apply [CompleteLattice β] (s : Set (α →o β)) (x : α) :\n sSup s x = ⨆ f ∈ s, (f :) x :=\n rfl\n\ntheorem iSup_apply {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) (x : α) :\n (⨆ i, f i) x = ⨆ i, f i x :=\n (sSup_apply _ _).trans iSup_range\n\n@[simp, norm_cast]\ntheorem coe_iSup {ι : Sort*} [CompleteLattice β] (f : ι → α →o β) :\n ((⨆ i, f i : α →o β) : α → β) = ⨆ i, (f i : α → β) := by\n funext x; simp [iSup_apply]\n\ninstance [CompleteLattice β] : CompleteLattice (α →o β) :=\n { (_ : Lattice (α →o β)), OrderHom.orderTop, OrderHom.orderBot with\n isLUB_sSup _ :=\n .of_image (f := (⇑)) coe_le_coe (by simp [isLUB_pi, Set.image_image, isLUB_biSup])\n isGLB_sInf _ :=\n .of_image (f := (⇑)) coe_le_coe (by simp [isGLB_pi, Set.image_image, isGLB_biInf]) }\n\nTarget:\ntheorem iterate_sup_le_sup_iff {α : Type*} [SemilatticeSup α] (f : α →o α) :\n (∀ n₁ n₂ a₁ a₂, f^[n₁ + n₂] (a₁ ⊔ a₂) ≤ f^[n₁] a₁ ⊔ f^[n₂] a₂) ↔\n ∀ a₁ a₂, f (a₁ ⊔ a₂) ≤ f a₁ ⊔ a₂ :=\n\nProof body:\n","rejected":"by\n exact iterate_sup_le_sup_iff","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"10c264f30d7026f048ab48e258e302f1f4e924b328877342a247ae63027b72ad","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Hom","family_id":"iterate_sup_le_sup_iff","file_id":"mathlib/Mathlib/Order/Hom/Order.lean","sample_id":"c50e7dfc15f5b03aac949d5d4c73b6d02918eb7ce6d372c202e9c6d7181bbde0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2fb41a11920e7a64cf69ef40df707f45d340eb3af6a90a5a64b84b9024b7c959","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b663d198ef407c5b92a67b9c3fd56fb4ff4e0621bfb0ab639566bc7d5958a0e8","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9e0c39962beb5317b152cb3d064fdb85b5f327aa606f8baa392b3d16453f5638","source_sha256":"20a887f2c3211ef38a58477ab820fa84339a67b3ed02ebf48f183d6247cffc1b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext j; simp [Algebra.algebraMap_eq_smul_one, ← hBi]","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.066667,"token_length_ratio":0.230769},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"715272a5c019ea6c3bf6a226bddd770c13c27955cbc29d33dfc296e1fca3ac64","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Module.Shrink\npublic import Mathlib.Algebra.Module.ULift\npublic import Mathlib.Data.Finsupp.Fintype\npublic import Mathlib.LinearAlgebra.Basis.Basic\npublic import Mathlib.Logic.Small.Basic\n\nNamespace:\nModule.Basis\n\nLocal context:\n/-\nCopyright (c) 2021 Riccardo Brasca. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Riccardo Brasca\n-/\n/-!\n# Free modules\n\nWe introduce a class `Module.Free R M`, for `R` a `Semiring` and `M` an `R`-module and we provide\nseveral basic instances for this class.\n\nUse `Finsupp.linearCombination_id_surjective` to prove that any module is the quotient of a free\nmodule.\n\n## Main definition\n\n* `Module.Free R M` : the class of free `R`-modules.\n-/\n\n@[expose] public section\n\nassert_not_exists DirectSum Matrix TensorProduct\n\nuniverse u v w z\n\nvariable {ι : Type*} (R : Type u) (M : Type v) (N : Type z)\n\nnamespace Module\nsection Basic\n\nvariable [Semiring R] [AddCommMonoid M] [Module R M]\n\n/-- `Module.Free R M` is the statement that the `R`-module `M` is free. -/\nclass Free (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where\n exists_basis (R M) : Nonempty <| (I : Type v) × Basis I R M\n\nlemma Free.exists_set [Free R M] : ∃ S : Set M, Nonempty (Basis S R M) :=\n let ⟨_I, b⟩ := exists_basis R M; ⟨Set.range b, ⟨b.reindexRange⟩⟩\n\ntheorem free_iff_set : Free R M ↔ ∃ S : Set M, Nonempty (Basis S R M) :=\n ⟨fun _ ↦ Free.exists_set .., fun ⟨S, hS⟩ ↦ ⟨nonempty_sigma.2 ⟨S, hS⟩⟩⟩\n\n/-- If `M` fits in universe `w`, then freeness is equivalent to existence of a basis in that\nuniverse.\n\nNote that if `M` does not fit in `w`, the reverse direction of this implication is still true as\n`Module.Free.of_basis`. -/\ntheorem free_def [Small.{w, v} M] : Free R M ↔ ∃ I : Type w, Nonempty (Basis I R M) where\n mp h :=\n ⟨Shrink (Set.range h.exists_basis.some.2),\n ⟨(Basis.reindexRange h.exists_basis.some.2).reindex (equivShrink _)⟩⟩\n mpr h := ⟨(nonempty_sigma.2 h).map fun ⟨_, b⟩ => ⟨Set.range b, b.reindexRange⟩⟩\n\nvariable {R M}\n\ntheorem Free.of_basis {ι : Type w} (b : Basis ι R M) : Free R M :=\n (free_def R M).2 ⟨Set.range b, ⟨b.reindexRange⟩⟩\n\nend Basic\n\nnamespace Free\n\nsection Semiring\n\nvariable [Semiring R] [AddCommMonoid M] [Module R M] [Module.Free R M]\nvariable [AddCommMonoid N] [Module R N]\n\n/-- If `Module.Free R M` then `ChooseBasisIndex R M` is the `ι` which indexes the basis\n `ι → M`. Note that this is defined such that this type is finite if `R` is trivial. -/\ndef ChooseBasisIndex : Type _ :=\n ((Module.free_iff_set R M).mp ‹_›).choose\n\n/-- There is no hope of computing this, but we add the instance anyway to avoid fumbling with\n`open scoped Classical`. -/\nnoncomputable instance : DecidableEq (ChooseBasisIndex R M) := Classical.decEq _\n\n/-- If `Module.Free R M` then `chooseBasis : ι → M` is the basis.\nHere `ι = ChooseBasisIndex R M`. -/\nnoncomputable def chooseBasis : Basis (ChooseBasisIndex R M) R M :=\n ((Module.free_iff_set R M).mp ‹_›).choose_spec.some\n\n/-- The universal property of free modules: giving a function `(ChooseBasisIndex R M) → N`, for `N`\nan `R`-module, is the same as giving an `R`-linear map `M →ₗ[R] N`.\n\nThis definition is parameterized over an extra `Semiring S`,\nsuch that `SMulCommClass R S M'` holds.\nIf `R` is commutative, you can set `S := R`; if `R` is not commutative,\nyou can recover an `AddEquiv` by setting `S := ℕ`.\nSee library note [bundled maps over different rings]. -/\nnoncomputable def constr {S : Type z} [Semiring S] [Module S N] [SMulCommClass R S N] :\n (ChooseBasisIndex R M → N) ≃ₗ[S] M →ₗ[R] N :=\n Basis.constr (chooseBasis R M) S\n\ninstance (priority := 100) instIsTorsionFree : IsTorsionFree R M :=\n let ⟨⟨_, b⟩⟩ := exists_basis (R := R) (M := M)\n b.isTorsionFree\n\ninstance [Nontrivial M] : Nonempty (Module.Free.ChooseBasisIndex R M) :=\n (Module.Free.chooseBasis R M).index_nonempty\n\ntheorem infinite [Infinite R] [Nontrivial M] : Infinite M :=\n (Equiv.infinite_iff (chooseBasis R M).repr.toEquiv).mpr Finsupp.infinite_of_right\n\ninstance [Nontrivial M] : FaithfulSMul R M :=\n .of_injective _ (chooseBasis R M).repr.symm.injective\n\nvariable {R M N}\n\nlemma of_equiv {R R' M M' : Type*} [Semiring R] [AddCommMonoid M] [Module R M]\n [Semiring R'] [AddCommMonoid M'] [Module R' M']\n {σ : R →+* R'} {σ' : R' →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]\n (e₂ : M ≃ₛₗ[σ] M') [Module.Free R M] :\n Module.Free R' M' := by\n let e₁ : R ≃+* R' := RingHomInvPair.toRingEquiv σ σ'\n let I := Module.Free.ChooseBasisIndex R M\n obtain ⟨e₃ : M ≃ₗ[R] I →₀ R⟩ := Module.Free.chooseBasis R M\n let e : M' ≃+ (I →₀ R') :=\n (e₂.symm.trans e₃).toAddEquiv.trans (Finsupp.mapRange.addEquiv (ι := I) e₁.toAddEquiv)\n have he (x) : e x = Finsupp.mapRange.addEquiv (ι := I) e₁.toAddEquiv (e₃ (e₂.symm x)) := rfl\n let e' : M' ≃ₗ[R'] (I →₀ R') :=\n { __ := e, map_smul' := fun m x ↦ Finsupp.ext fun i ↦ by simp [e₁, he, map_smulₛₗ] }\n exact of_basis (.ofRepr e')\n\n/-- A variation of `of_equiv`: the assumption `Module.Free R P` here is explicit rather than an\ninstance. -/\ntheorem of_equiv' {P : Type v} [AddCommMonoid P] [Module R P] (_ : Module.Free R P)\n (e : P ≃ₗ[R] N) : Module.Free R N :=\n of_equiv e\n\nlemma iff_of_equiv {R R' M M'} [Semiring R] [AddCommMonoid M] [Module R M]\n [Semiring R'] [AddCommMonoid M'] [Module R' M']\n {σ : R →+* R'} {σ' : R' →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]\n (e₂ : M ≃ₛₗ[σ] M') :\n Module.Free R M ↔ Module.Free R' M' :=\n ⟨fun _ ↦ of_equiv e₂, fun _ ↦ of_equiv e₂.symm⟩\n\n@[deprecated (since := \"2026-02-14\")] alias of_ringEquiv := of_equiv\n@[deprecated (since := \"2026-02-14\")] alias iff_of_ringEquiv := iff_of_equiv\n\ninstance shrink [Small.{w} M] : Module.Free R (Shrink.{w} M) :=\n Module.Free.of_equiv (Shrink.linearEquiv R M).symm\n\n@[deprecated (since := \"2026-04-18\")] alias Module.free_shrink := shrink\n\nvariable (R M N)\n\n/-- The module structure provided by `Semiring.toModule` is free. -/\ninstance self : Module.Free R R :=\n of_basis (Basis.singleton Unit R)\n\ninstance ulift : Free R (ULift M) := of_equiv ULift.moduleEquiv.symm\n\ninstance (priority := 100) of_subsingleton [Subsingleton N] : Module.Free R N :=\n of_basis.{u, z, z} (Basis.empty N : Basis PEmpty R N)\n\n-- This was previously a global instance,\n-- but it doesn't appear to be used and has been implicated in slow typeclass resolutions.\nlemma of_subsingleton' [Subsingleton R] : Module.Free R N :=\n letI := Module.subsingleton R N\n Module.Free.of_subsingleton R N\n\nend Semiring\n\nend Free\n\nnamespace Basis\n\nopen Finset\n\nvariable {S : Type*} [CommRing R] [Ring S] [Algebra R S]\n\nvariable {R} in\n/-- If `B` is a basis of the `R`-algebra `S` such that `B i = 1` for some index `i`, then\neach `r : R` gets represented as `s • B i` as an element of `S`. -/\n\nTarget:\ntheorem repr_algebraMap {ι : Type*} {B : Basis ι R S} {i : ι} (hBi : B i = 1) (r : R) :\n B.repr (algebraMap R S r) = Finsupp.single i r :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_9e0c39962beb","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"c00f9471d294f93b5bcd22534b8a0f5bd65e40bfb054172d85232cbe9513c4e8","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/FreeModule","family_id":"repr_algebramap","file_id":"mathlib/Mathlib/LinearAlgebra/FreeModule/Basic.lean","sample_id":"9e0c39962beb5317b152cb3d064fdb85b5f327aa606f8baa392b3d16453f5638"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"285c3f112f71c5567f33bffd1e4b5c727410fe5de46b42c4619a426f7c4e016f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cfe0ccc145fa33defc613542932e9763e6f39e2527a04429c1a24a1439938395","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1328d3491da93672dffa35377f20105d1b61a62bab6d7002554ed21b2d9cda8c","source_sha256":"ae5712c01e19ee9e698953ecf3438b05b54b2b04dda2e774200341d53bf92b5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n by_cases hmem : ⊤ ∈ s\n · exact sSup_of_top_mem hmem\n · exact if_neg hmem |>.trans <| if_neg h","hard_negative":true,"metrics":{"chosen_tokens":23,"rejected_tokens":5,"token_jaccard":0.157895,"token_length_ratio":0.217391},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"718a74f774e54900f376ba52f67b08e94939dc46f19cbc2ed8905a4b8c22aec7","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice\npublic import Mathlib.Order.ConditionallyCompleteLattice.Defs\npublic import Mathlib.Order.ConditionallyCompletePartialOrder.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-!\n# Theory of conditionally complete lattices\n\nA conditionally complete lattice is a lattice in which every non-empty bounded subset `s`\nhas a least upper bound and a greatest lower bound, denoted below by `sSup s` and `sInf s`.\nTypical examples are `ℝ`, `ℕ`, and `ℤ` with their usual orders.\n\nThe theory is very comparable to the theory of complete lattices, except that suitable\nboundedness and nonemptiness assumptions have to be added to most statements.\nWe express these using the `BddAbove` and `BddBelow` predicates, which we use to prove\nmost useful properties of `sSup` and `sInf` in conditionally complete lattices.\n\nTo differentiate the statements between complete lattices and conditionally complete\nlattices, we prefix `sInf` and `sSup` in the statements by `c`, giving `csInf` and `csSup`.\nFor instance, `sInf_le` is a statement in complete lattices ensuring `sInf s ≤ x`,\nwhile `csInf_le` is the same statement in conditionally complete lattices\nwith an additional assumption that `s` is bounded below.\n-/\n\n@[expose] public section\n\n-- Guard against import creep\nassert_not_exists Multiset\n\nopen Function OrderDual Set\n\nvariable {α β γ : Type*} {ι : Sort*}\n\nsection LE\n\n/-!\nExtension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α`\n-/\n\nvariable [LE α]\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instSupSet [SupSet α] :\n SupSet (WithTop α) :=\n ⟨fun S =>\n if ⊤ ∈ S then ⊤ else if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then\n ↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=\n ⟨fun S => if S ⊆ {⊤} ∨ ¬BddBelow S then ⊤ else ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩\n\n@[to_dual]\ntheorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)\n (hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=\n (if_neg hs).trans <| if_pos hs'\n\n@[to_dual]\ntheorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) :\n sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=\n if_neg <| by simp [hs, h's]\n\n@[simp]\ntheorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=\n if_pos <| by simp\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_singleton_top [InfSet α] : sInf ({⊤} : Set (WithTop α)) = ⊤ :=\n if_pos <| .inl subset_rfl\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sSup_of_top_mem [SupSet α] {s : Set (WithTop α)} (h : ⊤ ∈ s) : sSup s = ⊤ :=\n if_pos h\n\n@[to_dual]\ntheorem WithTop.sSup_singleton_top [SupSet α] : sSup ({⊤} : Set (WithTop α)) = ⊤ := by\n simp\n\n@[to_dual]\n\nTarget:\ntheorem WithTop.sSup_of_not_bddAbove [SupSet α] {s : Set (WithTop α)}\n (h : ¬BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ⊤ :=\n\nProof body:\n","rejected":"by\n exact WithTop.sSup_of_not_bddAbove","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"a270dc4f84b213fb9e5eab963d9f48f3d67dd8d0959606b9f211e47b4009b0a3","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/ConditionallyCompleteLattice","family_id":"withtop","file_id":"mathlib/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean","sample_id":"1328d3491da93672dffa35377f20105d1b61a62bab6d7002554ed21b2d9cda8c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca66b43720e5683a0decc46b77a69ad6752ea87269332f71cb4e174d0c4ba53f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"aa2bb60c91df4bf218df8cc3532844df906e9bcaa1fd9a1d6d272daaf40a0bb2","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c8607fdf15a4772063aecb4e30b0f647b6e32e9f052cd93c1524ccbf380858f4","source_sha256":"d4b08401005558805b5961b6d98688b799b79fc82584afe5bc0760ff0387492a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine hasFiniteIntegral_mkD_of_bound _ _ ?_ bound bound_int ?_\n · simpa [← continuousOn_iff_continuous_restrict]\n · simpa","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.105263},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"71e1ea8355558ec8327f1a64507dfe0865e0a9951ee38218ded29ed59e5ae370","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.ContinuousMap.Compact\npublic import Mathlib.Topology.ContinuousMap.Algebra\npublic import Mathlib.MeasureTheory.Integral.IntegrableOn\n\nNamespace:\nContinuousMap\n\nLocal context:\n/-\nCopyright (c) 2025 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\n/-!\n# Specific results about `ContinuousMap`-valued integration\n\nIn this file, we collect a few results regarding integrability, on a measure space `(X, μ)`,\nof a `C(Y, E)`-valued function, where `Y` is a compact topological space and `E` is a normed group.\n\nThese are all elementary from a mathematical point of view, but they require a bit of care in order\nto be conveniently usable. In particular, to accommodate the need of families `f : X → Y → E` such\nthat `f x` is only continuous for *almost every* `x`, we give a variety of results about the\nintegrability of `fun x ↦ ContinuousMap.mkD (f x) g` whose assumptions only mention `f` (so that\nusers don't have to convert between `f` and `fun x ↦ ContinuousMap.mkD (f x) g` by hand).\n\n## Main results\n\n* `hasFiniteIntegral_of_bound`: given `f : X → C(Y, E)`, the natural way to show\n `HasFiniteIntegral f` is to give a `bound : X → ℝ`, which itself has finite integral, and such\n that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.\n* `hasFiniteIntegral_mkD_of_bound` is the `mkD` analog of the above: given `f : X → Y → E` such\n that `f x` is continuous for almost every `x`, as well as a bound as above, we prove\n `HasFiniteIntegral (fun x ↦ mkD (f x) g)`. Note that, conveniently, `mkD` only appears in the\n result.\n* `aeStronglyMeasurable_mkD_of_uncurry`: if now `X` is a topological space with the Borel σ-algebra,\n and `f : X → Y → E` is continuous on `X × Y`, then `fun x ↦ mkD (f x) g` is\n `AEStronglyMeasurable`. Note that this is far from optimal: this function is in fact continuous,\n and one could avoid `mkD` entirely since `f x` is always continuous in that case. Nevertheless,\n this turns out to be most convenient, as we explain below.\n\n## Implementation Note\n\nWe claim that using \"constructors with default values\" such as `ContinuousMap.mkD` is the right way\nto approach integration valued in a functional space `ℱ`. More precisely:\n\n- if you happen to start from a bundled `f : X → ℱ` function, you should be able to use\n the general theory without any issues.\n- if instead you start with a family of bare functions `f : X → Y → E`, to integrate it in `ℱ`, you\n should always consider the family `fun x ↦ ℱ.mkD (f x) 0`, *even if your `f` always lands in `ℱ`*.\n This allows for a unified setting with the case where `f x` belongs to `ℱ` for *almost every `x`*,\n and also avoids entering dependent-types hell.\n\n-/\n\npublic section\n\nopen MeasureTheory\n\nnamespace ContinuousMap\n\nvariable {X Y : Type*} [MeasurableSpace X] {μ : Measure X} [TopologicalSpace Y]\nvariable {E : Type*} [NormedAddCommGroup E]\n\n/-- A natural criterion for `HasFiniteIntegral` of a `C(Y, E)`-valued function is the existence\nof some positive function with finite integral such that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.\nNote that there is no dominated convergence here (hence no first-countability assumption\non `Y`). We are just using the properties of Banach-space-valued integration. -/\nlemma hasFiniteIntegral_of_bound [CompactSpace Y] (f : X → C(Y, E)) (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral f μ := by\n rcases isEmpty_or_nonempty Y with (h | h)\n · simp\n · have bound_nonneg : 0 ≤ᵐ[μ] bound := by\n filter_upwards [bound_ge] with x bound_x using le_trans (norm_nonneg _) (bound_x h.some)\n refine .mono' bound_int ?_\n filter_upwards [bound_ge, bound_nonneg] with x bound_ge_x bound_nonneg_x\n exact ContinuousMap.norm_le _ bound_nonneg_x |>.mpr bound_ge_x\n\n/-- A variant of `ContinuousMap.hasFiniteIntegral_of_bound` spelled in terms of\n`ContinuousMap.mkD`. -/\nlemma hasFiniteIntegral_mkD_of_bound [CompactSpace Y] (f : X → Y → E) (g : C(Y, E))\n (f_ae_cont : ∀ᵐ x ∂μ, Continuous (f x))\n (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral (fun x ↦ mkD (f x) g) μ := by\n refine hasFiniteIntegral_of_bound _ bound bound_int ?_\n filter_upwards [bound_ge, f_ae_cont] with x bound_ge_x cont_x\n simpa only [mkD_apply_of_continuous cont_x] using bound_ge_x\n\n/-- A variant of `ContinuousMap.hasFiniteIntegral_mkD_of_bound` for a family of\nfunctions which are continuous on a compact set. -/\n\nTarget:\nlemma hasFiniteIntegral_mkD_restrict_of_bound {s : Set Y} [CompactSpace s]\n (f : X → Y → E) (g : C(s, E))\n (f_ae_contOn : ∀ᵐ x ∂μ, ContinuousOn (f x) s)\n (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y ∈ s, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral (fun x ↦ mkD (s.restrict (f x)) g) μ :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_c8607fdf15a4","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"65b2edff90a7e5efe40933ba5b7fd27a5bfa25a0bb06077dcc6d61510390631b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/SpecificCodomains","family_id":"hasfiniteintegral_mkd_restrict_of_bound","file_id":"mathlib/Mathlib/MeasureTheory/SpecificCodomains/ContinuousMap.lean","sample_id":"c8607fdf15a4772063aecb4e30b0f647b6e32e9f052cd93c1524ccbf380858f4"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a99eaa929f1571061af5dfc1d3cfb5de03b1c0fe6cc9ea4eea006d79d50ed5e9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"757245f2af58d1981398dbd9b4a4241b19f384ab6f71f207c1d533a159362947","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d6f3807fdb3546c64b02683a0fb1347711c9d14b38bd4ee99fe739f4f0753f8c","source_sha256":"456308686f66aa5de2ab2b8c42c79fb06947ad9dfe96a33de3e67849016cad10","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases eventually_norm_mfderiv_extChartAt_lt I x with ⟨C, C_pos, hC⟩\n lift C to ℝ≥0 using C_pos.le\n simp only [gt_iff_lt, NNReal.coe_pos] at C_pos\n refine ⟨C, C_pos, ?_⟩\n filter_upwards [hC] with y hy\n simp only [enorm, nnnorm]\n exact_mod_cast hy","hard_negative":false,"metrics":{"chosen_tokens":59,"rejected_tokens":64,"token_jaccard":0.880952,"token_length_ratio":1.084746},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"72e27040013b4dff9f30cb26429ab35a23399f186ac54e8bc28f684e2e5a5c29","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Manifold.MFDeriv.Atlas\npublic import Mathlib.Geometry.Manifold.Riemannian.PathELength\npublic import Mathlib.Geometry.Manifold.VectorBundle.Riemannian\npublic import Mathlib.Geometry.Manifold.VectorBundle.Tangent\npublic import Mathlib.MeasureTheory.Integral.IntervalIntegral.ContDiff\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-! # Riemannian manifolds\n\nA Riemannian manifold `M` is a real manifold such that its tangent spaces are endowed with an\ninner product, depending smoothly on the point, and such that `M` has an emetric space\nstructure for which the distance is the infimum of lengths of paths.\n\nWe register a Prop-valued typeclass `IsRiemannianManifold I M` recording this fact, building on top\nof `[EMetricSpace M] [RiemannianBundle (fun (x : M) ↦ TangentSpace I x)]`.\n\nWe show that an inner product vector space, with the associated canonical Riemannian metric,\nsatisfies the predicate `IsRiemannianManifold 𝓘(ℝ, E) E`.\n\nIn a general manifold with a Riemannian metric, we define the associated extended distance in the\nmanifold, and show that it defines the same topology as the pre-existing one. Therefore, one\nmay endow the manifold with an emetric space structure, see `EMetricSpace.ofRiemannianMetric`.\nBy definition, it then satisfies the predicate `IsRiemannianManifold I M`.\n\nThe following code block is the standard way to say \"Let `M` be a `C^∞` Riemannian manifold\".\n```\nopen scoped Bundle\nvariable\n {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H}\n {M : Type*} [EMetricSpace M] [ChartedSpace H M] [IsManifold I ∞ M]\n [RiemannianBundle (fun (x : M) ↦ TangentSpace I x)]\n [IsContMDiffRiemannianBundle I ∞ E (fun (x : M) ↦ TangentSpace I x)]\n [IsRiemannianManifold I M]\n```\nTo register a `C^n` manifold for a general `n`, one should replace `[IsManifold I ∞ M]` with\n`[IsManifold I n M] [IsManifold I 1 M]`, where the second one is needed to ensure that the\ntangent bundle is well behaved (not necessary when `n` is concrete like 2 or 3 as there are\nautomatic instances for these cases). One can require whatever regularity one wants in the\n`IsContMDiffRiemannianBundle` instance above, for example\n`[IsContMDiffRiemannianBundle I n E (fun (x : M) ↦ TangentSpace I x)]`, and one should also add\n`[IsContinuousRiemannianBundle E (fun (x : M) ↦ TangentSpace I x)]` (as above, Lean cannot infer\nthe latter from the former as it cannot guess `n`).\n-/\n\n@[expose] public section\n\nopen Bundle Bornology Set MeasureTheory Manifold Filter\nopen scoped ENNReal ContDiff Topology\n\nlocal notation \"⟪\" x \", \" y \"⟫\" => inner ℝ x y\n\nnoncomputable section\n\nvariable\n {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]\n {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {n : ℕ∞ω}\n {M : Type*} [TopologicalSpace M] [ChartedSpace H M]\n\nsection\n\nvariable [PseudoEMetricSpace M] [ChartedSpace H M]\n [RiemannianBundle (fun (x : M) ↦ TangentSpace% x)]\n\nvariable (I M) in\n/-- Consider a manifold in which the tangent spaces are already endowed with an inner product, and\nthe space is already endowed with an extended distance. We say that this is a Riemannian manifold\nif the distance is given by the infimum of the lengths of `C^1` paths, measured using the norm in\nthe tangent spaces.\n\nThis is a `Prop`-valued typeclass, on top of existing data.\n\nIf you need to *construct* a distance using a Riemannian structure,\nsee `EMetricSpace.ofRiemannianMetric`. -/\nclass IsRiemannianManifold : Prop where\n out (x y : M) : edist x y = riemannianEDist I x y\n\nend\n\nsection\n\n/-!\n### Riemannian structure on an inner product vector space\n\nWe endow an inner product vector space with the canonical Riemannian metric, given by the\ninner product of the vector space in each of the tangent spaces, and we show that this construction\nsatisfies the `IsRiemannianManifold 𝓘(ℝ, E) E` predicate, i.e., the extended distance between\ntwo points is the infimum of the length of paths between these points.\n-/\n\nvariable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]\n\nset_option backward.isDefEq.respectTransparency false in\nvariable (F) in\n/-- The standard Riemannian metric on a vector space with an inner product, given by this inner\nproduct on each tangent space. -/\nnoncomputable def riemannianMetricVectorSpace :\n ContMDiffRiemannianMetric 𝓘(ℝ, F) ω F (fun (x : F) ↦ TangentSpace% x) where\n inner x := (innerSL ℝ (E := F) : F →L[ℝ] F →L[ℝ] ℝ)\n symm x v w := real_inner_comm _ _\n pos x v hv := real_inner_self_pos.2 hv\n isVonNBounded x := by\n change IsVonNBounded ℝ {v : F | ⟪v, v⟫ < 1}\n have : Metric.ball (0 : F) 1 = {v : F | ⟪v, v⟫ < 1} := by\n ext v\n simp only [Metric.mem_ball, dist_zero_right, norm_eq_sqrt_re_inner (𝕜 := ℝ),\n RCLike.re_to_real, Set.mem_setOf_eq]\n conv_lhs => rw [show (1 : ℝ) = √1 by simp]\n rw [Real.sqrt_lt_sqrt_iff]\n exact real_inner_self_nonneg\n rw [← this]\n exact NormedSpace.isVonNBounded_ball ℝ F 1\n contMDiff := by\n intro x\n rw [contMDiffAt_section]\n convert! contMDiffAt_const (c := innerSL ℝ)\n ext v w\n simp [hom_trivializationAt_apply, ContinuousLinearMap.inCoordinates, TangentSpace]\n\nnoncomputable instance : RiemannianBundle (fun (x : F) ↦ TangentSpace% x) :=\n ⟨(riemannianMetricVectorSpace F).toRiemannianMetric⟩\n\nset_option backward.isDefEq.respectTransparency false in\nlemma norm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖ = ‖letI V : F := v; V‖ := by\n rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner]\n\nlemma nnnorm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖₊ = ‖letI V : F := v; V‖₊ := by\n simp [nnnorm, norm_tangentSpace_vectorSpace]\n\nlemma enorm_tangentSpace_vectorSpace {x : F} {v : TangentSpace% x} :\n ‖v‖ₑ = ‖letI V : F := v; V‖ₑ := by\n simp [enorm, nnnorm_tangentSpace_vectorSpace]\n\nopen MeasureTheory Measure\n\nlemma lintegral_fderiv_lineMap_eq_edist {x y : E} :\n ∫⁻ t in Icc 0 1, ‖fderivWithin ℝ (ContinuousAffineMap.lineMap (R := ℝ) x y) (Icc 0 1) t 1‖ₑ\n = edist x y := by\n have : edist x y = ∫⁻ t in Icc (0 : ℝ) 1, ‖y - x‖ₑ := by\n simp [edist_comm x y, edist_eq_enorm_sub]\n rw [this]\n apply setLIntegral_congr_fun measurableSet_Icc (fun z hz ↦ ?_)\n rw [show y - x = fderiv ℝ (ContinuousAffineMap.lineMap (R := ℝ) x y) z 1 by simp]\n congr\n exact fderivWithin_eq_fderiv (uniqueDiffOn_Icc zero_lt_one _ hz)\n (ContinuousAffineMap.differentiableAt _)\n\n/-- An inner product vector space is a Riemannian manifold, i.e., the distance between two points\nis the infimum of the lengths of paths between these points. -/\ninstance : IsRiemannianManifold 𝓘(ℝ, F) F := by\n refine ⟨fun x y ↦ le_antisymm ?_ ?_⟩\n · simp only [riemannianEDist, le_iInf_iff]\n intro γ hγ\n let e : ℝ → F := γ ∘ (projIcc 0 1 zero_le_one)\n have D : ContDiffOn ℝ 1 e (Icc 0 1) :=\n contMDiffOn_iff_contDiffOn.mp (hγ.comp_contMDiffOn contMDiffOn_projIcc)\n rw [lintegral_norm_mfderiv_Icc_eq_pathELength_projIcc,\n pathELength_eq_lintegral_mfderivWithin_Icc]\n simp only [mfderivWithin_eq_fderivWithin, enorm_tangentSpace_vectorSpace]\n conv_lhs =>\n rw [edist_comm, edist_eq_enorm_sub, show x = e 0 by simp [e], show y = e 1 by simp [e]]\n exact (enorm_sub_le_lintegral_derivWithin_Icc_of_contDiffOn_Icc D zero_le_one).trans_eq rfl\n · let γ := ContinuousAffineMap.lineMap (R := ℝ) x y\n have : riemannianEDist 𝓘(ℝ, F) x y ≤ pathELength 𝓘(ℝ, F) γ 0 1 := by\n apply riemannianEDist_le_pathELength ?_ (by simp [γ, ContinuousAffineMap.coe_lineMap_eq])\n (by simp [γ, ContinuousAffineMap.coe_lineMap_eq]) zero_le_one\n rw [contMDiffOn_iff_contDiffOn]\n exact γ.contDiff.contDiffOn\n apply this.trans_eq\n rw [pathELength_eq_lintegral_mfderivWithin_Icc]\n simp only [mfderivWithin_eq_fderivWithin, enorm_tangentSpace_vectorSpace]\n exact lintegral_fderiv_lineMap_eq_edist\n\nend\n\nsection\n\n/-!\n### Constructing a distance from a Riemannian structure\n\nLet `M` be a real manifold with a Riemannian structure. We construct the associated distance and\nshow that the associated topology coincides with the pre-existing topology. Therefore, one may\nendow `M` with an emetric space structure, called `EMetricSpace.ofRiemannianMetric`.\nMoreover, we show that in this case the resulting emetric space satisfies the predicate\n`IsRiemannianManifold I M`.\n\nShowing that the distance topology coincides with the pre-existing topology is not trivial. The\ntwo inclusions are proved respectively in `eventually_riemannianEDist_lt` and\n`setOf_riemannianEDist_lt_subset_nhds`.\n\nFor the first one, we have to show that points which are close for the topology are at small\ndistance. For this, we use the path between the two points which is the pullback of the segment\nin the extended chart, and argue that it is short because the images are close in the extended\nchart.\n\nFor the second one, we have to show that any neighborhood of `x` contains all the points `y`\nwith `riemannianEDist x y < c` for some `c > 0`. For this, we argue that a short path from `x`\nto `y` remains short in the extended chart, and therefore it doesn't have the time to exit\nthe image of the neighborhood in the extended chart.\n-/\n\nopen Manifold Metric\nopen scoped NNReal\n\nvariable [RiemannianBundle (fun (x : M) ↦ TangentSpace% x)]\n [IsManifold I 1 M] [IsContinuousRiemannianBundle E (fun (x : M) ↦ TangentSpace% x)]\n\n/-- Register on the tangent space to a normed vector space the same `NormedAddCommGroup` structure\nas in the vector space.\n\nShould not be a global instance, as it does not coincide definitionally with the Riemannian\nstructure for inner product spaces, but can be activated locally. -/\n@[instance_reducible]\ndef normedAddCommGroupTangentSpaceVectorSpace (x : E) :\n NormedAddCommGroup (TangentSpace% x) :=\n inferInstanceAs (NormedAddCommGroup E)\n\nattribute [local instance] normedAddCommGroupTangentSpaceVectorSpace\n\n/-- Register on the tangent space to a normed vector space the same `NormedSpace` structure\nas in the vector space.\n\nShould not be a global instance, as it does not coincide definitionally with the Riemannian\nstructure for inner product spaces, but can be activated locally. -/\n@[instance_reducible]\ndef normedSpaceTangentSpaceVectorSpace (x : E) : NormedSpace ℝ (TangentSpace% x) :=\n inferInstanceAs (NormedSpace ℝ E)\n\nattribute [local instance] normedSpaceTangentSpaceVectorSpace\n\nvariable (I)\n\nset_option backward.isDefEq.respectTransparency false in\nlemma eventually_norm_mfderiv_extChartAt_lt (x : M) :\n ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ < C := by\n rcases eventually_norm_trivializationAt_lt E (fun (x : M) ↦ TangentSpace% x) x\n with ⟨C, C_pos, hC⟩\n refine ⟨C, C_pos, ?_⟩\n have hx : (chartAt H x).source ∈ 𝓝 x := chart_source_mem_nhds H x\n filter_upwards [hC, hx] with y hy h'y\n rwa [← TangentBundle.continuousLinearMapAt_trivializationAt h'y]\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma eventually_enorm_mfderiv_extChartAt_lt (x : M) :\n ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ₑ < C :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n rcases eventually_norm_mfderiv_extChartAt_lt I x with ⟨C, C_pos, hC⟩\n lift C to ℝ≥0 using C_pos.le\n simp only [gt_iff_lt, NNReal.coe_pos] at C_pos\n refine ⟨C, C_pos, ?_⟩\n filter_upwards [hC] with y hy\n simp only [enorm, nnnorm]\n exact_mod_cast hy","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Manifold","family_id":"eventually_enorm_mfderiv_extchartat_lt","file_id":"mathlib/Mathlib/Geometry/Manifold/Riemannian/Basic.lean","sample_id":"d6f3807fdb3546c64b02683a0fb1347711c9d14b38bd4ee99fe739f4f0753f8c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2fb41a11920e7a64cf69ef40df707f45d340eb3af6a90a5a64b84b9024b7c959","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9e0c39962beb5317b152cb3d064fdb85b5f327aa606f8baa392b3d16453f5638","source_sha256":"20a887f2c3211ef38a58477ab820fa84339a67b3ed02ebf48f183d6247cffc1b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext j; simp [Algebra.algebraMap_eq_smul_one, ← hBi]","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.066667,"token_length_ratio":0.230769},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"7330740caa916cef83cf8039f82e5a11dc66c4e6fdeb2130a4b9a22453e6ffba","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Module.Shrink\npublic import Mathlib.Algebra.Module.ULift\npublic import Mathlib.Data.Finsupp.Fintype\npublic import Mathlib.LinearAlgebra.Basis.Basic\npublic import Mathlib.Logic.Small.Basic\n\nNamespace:\nModule.Basis\n\nLocal context:\n/-\nCopyright (c) 2021 Riccardo Brasca. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Riccardo Brasca\n-/\n/-!\n# Free modules\n\nWe introduce a class `Module.Free R M`, for `R` a `Semiring` and `M` an `R`-module and we provide\nseveral basic instances for this class.\n\nUse `Finsupp.linearCombination_id_surjective` to prove that any module is the quotient of a free\nmodule.\n\n## Main definition\n\n* `Module.Free R M` : the class of free `R`-modules.\n-/\n\n@[expose] public section\n\nassert_not_exists DirectSum Matrix TensorProduct\n\nuniverse u v w z\n\nvariable {ι : Type*} (R : Type u) (M : Type v) (N : Type z)\n\nnamespace Module\nsection Basic\n\nvariable [Semiring R] [AddCommMonoid M] [Module R M]\n\n/-- `Module.Free R M` is the statement that the `R`-module `M` is free. -/\nclass Free (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where\n exists_basis (R M) : Nonempty <| (I : Type v) × Basis I R M\n\nlemma Free.exists_set [Free R M] : ∃ S : Set M, Nonempty (Basis S R M) :=\n let ⟨_I, b⟩ := exists_basis R M; ⟨Set.range b, ⟨b.reindexRange⟩⟩\n\ntheorem free_iff_set : Free R M ↔ ∃ S : Set M, Nonempty (Basis S R M) :=\n ⟨fun _ ↦ Free.exists_set .., fun ⟨S, hS⟩ ↦ ⟨nonempty_sigma.2 ⟨S, hS⟩⟩⟩\n\n/-- If `M` fits in universe `w`, then freeness is equivalent to existence of a basis in that\nuniverse.\n\nNote that if `M` does not fit in `w`, the reverse direction of this implication is still true as\n`Module.Free.of_basis`. -/\ntheorem free_def [Small.{w, v} M] : Free R M ↔ ∃ I : Type w, Nonempty (Basis I R M) where\n mp h :=\n ⟨Shrink (Set.range h.exists_basis.some.2),\n ⟨(Basis.reindexRange h.exists_basis.some.2).reindex (equivShrink _)⟩⟩\n mpr h := ⟨(nonempty_sigma.2 h).map fun ⟨_, b⟩ => ⟨Set.range b, b.reindexRange⟩⟩\n\nvariable {R M}\n\ntheorem Free.of_basis {ι : Type w} (b : Basis ι R M) : Free R M :=\n (free_def R M).2 ⟨Set.range b, ⟨b.reindexRange⟩⟩\n\nend Basic\n\nnamespace Free\n\nsection Semiring\n\nvariable [Semiring R] [AddCommMonoid M] [Module R M] [Module.Free R M]\nvariable [AddCommMonoid N] [Module R N]\n\n/-- If `Module.Free R M` then `ChooseBasisIndex R M` is the `ι` which indexes the basis\n `ι → M`. Note that this is defined such that this type is finite if `R` is trivial. -/\ndef ChooseBasisIndex : Type _ :=\n ((Module.free_iff_set R M).mp ‹_›).choose\n\n/-- There is no hope of computing this, but we add the instance anyway to avoid fumbling with\n`open scoped Classical`. -/\nnoncomputable instance : DecidableEq (ChooseBasisIndex R M) := Classical.decEq _\n\n/-- If `Module.Free R M` then `chooseBasis : ι → M` is the basis.\nHere `ι = ChooseBasisIndex R M`. -/\nnoncomputable def chooseBasis : Basis (ChooseBasisIndex R M) R M :=\n ((Module.free_iff_set R M).mp ‹_›).choose_spec.some\n\n/-- The universal property of free modules: giving a function `(ChooseBasisIndex R M) → N`, for `N`\nan `R`-module, is the same as giving an `R`-linear map `M →ₗ[R] N`.\n\nThis definition is parameterized over an extra `Semiring S`,\nsuch that `SMulCommClass R S M'` holds.\nIf `R` is commutative, you can set `S := R`; if `R` is not commutative,\nyou can recover an `AddEquiv` by setting `S := ℕ`.\nSee library note [bundled maps over different rings]. -/\nnoncomputable def constr {S : Type z} [Semiring S] [Module S N] [SMulCommClass R S N] :\n (ChooseBasisIndex R M → N) ≃ₗ[S] M →ₗ[R] N :=\n Basis.constr (chooseBasis R M) S\n\ninstance (priority := 100) instIsTorsionFree : IsTorsionFree R M :=\n let ⟨⟨_, b⟩⟩ := exists_basis (R := R) (M := M)\n b.isTorsionFree\n\ninstance [Nontrivial M] : Nonempty (Module.Free.ChooseBasisIndex R M) :=\n (Module.Free.chooseBasis R M).index_nonempty\n\ntheorem infinite [Infinite R] [Nontrivial M] : Infinite M :=\n (Equiv.infinite_iff (chooseBasis R M).repr.toEquiv).mpr Finsupp.infinite_of_right\n\ninstance [Nontrivial M] : FaithfulSMul R M :=\n .of_injective _ (chooseBasis R M).repr.symm.injective\n\nvariable {R M N}\n\nlemma of_equiv {R R' M M' : Type*} [Semiring R] [AddCommMonoid M] [Module R M]\n [Semiring R'] [AddCommMonoid M'] [Module R' M']\n {σ : R →+* R'} {σ' : R' →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]\n (e₂ : M ≃ₛₗ[σ] M') [Module.Free R M] :\n Module.Free R' M' := by\n let e₁ : R ≃+* R' := RingHomInvPair.toRingEquiv σ σ'\n let I := Module.Free.ChooseBasisIndex R M\n obtain ⟨e₃ : M ≃ₗ[R] I →₀ R⟩ := Module.Free.chooseBasis R M\n let e : M' ≃+ (I →₀ R') :=\n (e₂.symm.trans e₃).toAddEquiv.trans (Finsupp.mapRange.addEquiv (ι := I) e₁.toAddEquiv)\n have he (x) : e x = Finsupp.mapRange.addEquiv (ι := I) e₁.toAddEquiv (e₃ (e₂.symm x)) := rfl\n let e' : M' ≃ₗ[R'] (I →₀ R') :=\n { __ := e, map_smul' := fun m x ↦ Finsupp.ext fun i ↦ by simp [e₁, he, map_smulₛₗ] }\n exact of_basis (.ofRepr e')\n\n/-- A variation of `of_equiv`: the assumption `Module.Free R P` here is explicit rather than an\ninstance. -/\ntheorem of_equiv' {P : Type v} [AddCommMonoid P] [Module R P] (_ : Module.Free R P)\n (e : P ≃ₗ[R] N) : Module.Free R N :=\n of_equiv e\n\nlemma iff_of_equiv {R R' M M'} [Semiring R] [AddCommMonoid M] [Module R M]\n [Semiring R'] [AddCommMonoid M'] [Module R' M']\n {σ : R →+* R'} {σ' : R' →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]\n (e₂ : M ≃ₛₗ[σ] M') :\n Module.Free R M ↔ Module.Free R' M' :=\n ⟨fun _ ↦ of_equiv e₂, fun _ ↦ of_equiv e₂.symm⟩\n\n@[deprecated (since := \"2026-02-14\")] alias of_ringEquiv := of_equiv\n@[deprecated (since := \"2026-02-14\")] alias iff_of_ringEquiv := iff_of_equiv\n\ninstance shrink [Small.{w} M] : Module.Free R (Shrink.{w} M) :=\n Module.Free.of_equiv (Shrink.linearEquiv R M).symm\n\n@[deprecated (since := \"2026-04-18\")] alias Module.free_shrink := shrink\n\nvariable (R M N)\n\n/-- The module structure provided by `Semiring.toModule` is free. -/\ninstance self : Module.Free R R :=\n of_basis (Basis.singleton Unit R)\n\ninstance ulift : Free R (ULift M) := of_equiv ULift.moduleEquiv.symm\n\ninstance (priority := 100) of_subsingleton [Subsingleton N] : Module.Free R N :=\n of_basis.{u, z, z} (Basis.empty N : Basis PEmpty R N)\n\n-- This was previously a global instance,\n-- but it doesn't appear to be used and has been implicated in slow typeclass resolutions.\nlemma of_subsingleton' [Subsingleton R] : Module.Free R N :=\n letI := Module.subsingleton R N\n Module.Free.of_subsingleton R N\n\nend Semiring\n\nend Free\n\nnamespace Basis\n\nopen Finset\n\nvariable {S : Type*} [CommRing R] [Ring S] [Algebra R S]\n\nvariable {R} in\n/-- If `B` is a basis of the `R`-algebra `S` such that `B i = 1` for some index `i`, then\neach `r : R` gets represented as `s • B i` as an element of `S`. -/\n\nTarget:\ntheorem repr_algebraMap {ι : Type*} {B : Basis ι R S} {i : ι} (hBi : B i = 1) (r : R) :\n B.repr (algebraMap R S r) = Finsupp.single i r :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/FreeModule","family_id":"repr_algebramap","file_id":"mathlib/Mathlib/LinearAlgebra/FreeModule/Basic.lean","sample_id":"9e0c39962beb5317b152cb3d064fdb85b5f327aa606f8baa392b3d16453f5638"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"231a4fe1e7c61172050d8b87bed8974d73dadd010c40cdb5e1b8e39c59ac51d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c73db545a51efe2e3357e57f22742af7e74965931ec9246b0552d5d428bd6242","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ef599e1e0926b4f16624577efbb1326a2099c7624b75050a46a0bf43275bdd76","source_sha256":"c30a3d4b1c42fcb7d8e6bf63ba23497757e589a03ca883e3c4dcb6c17db24a2c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext <;> simp [mapIsometry, DeloneSet.copy]","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":18,"token_jaccard":0.764706,"token_length_ratio":1.384615},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"7380fe4d83151008ab5a36a5b475f3177a781e6c7eff905122b68bc243e989e0","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.MetricSpace.Cover\n\nNamespace:\nDelone.DeloneSet\n\nLocal context:\n/-\nCopyright (c) 2026 Newell Jensen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Newell Jensen\n-/\n/-!\n# Delone sets\n\nA **Delone set** `D ⊆ X` in a metric space is a set which is both:\n\n* **Uniformly Discrete**: there exists `packingRadius > 0` such that distinct points of `D`\n are separated by a distance strictly greater than `packingRadius`;\n* **Relatively Dense**: there exists `coveringRadius > 0` such that every point of `X`\n lies within distance `coveringRadius` of some point of `D`.\n\nThe `DeloneSet` structure stores the set together with explicit radii witnessing\nthese properties. The definitions use metric entourages so that the theory fits\nnaturally into the uniformity framework.\n\nDelone sets appear in discrete geometry, crystallography, aperiodic order, and tiling theory.\n\n## Main definitions\n\n* `Delone.DeloneSet X`: The main structure representing a Delone set in a metric space `X`.\n* `DeloneSet.mapBilipschitz`: Transports a Delone set along a bilipschitz equivalence,\n scaling the radii.\n* `DeloneSet.mapIsometry` Preserves the packing and covering radii exactly.\n\n## Basic properties\n\n* `packingRadius_lt_dist_of_mem_ne` : Distinct points in a Delone set are further apart than\n the packing radius.\n* `exists_dist_le_coveringRadius` : Every point of the space lies within the covering radius\n of the set.\n* `subset_ball_singleton` : Any ball of sufficiently small radius contains at most one point of\n the set.\n\n## Implementation notes\n\n* **Bundled Structure**: `DeloneSet` is bundled as a structure rather than a predicate\n (e.g., `IsDelone`). This facilitates dynamical systems constructions like hulls and patches by\n ensuring operations automatically preserve the required properties, eliminating the need to\n manually pass around proofs that the set remains Delone.\n* **Explicit Data**: Since radii are stored as explicit data, the map from `DeloneSet X` to `Set X`\n is not injective. We provide a `Membership` instance and `mem_carrier` to allow the convenience\n of `∈` notation while ensuring radii remain bundled, computationally accessible, and tracked by\n extensionality.\n-/\n\n@[expose] public section\n\nopen Metric\nopen scoped NNReal\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nnamespace Delone\n\n/-- A **Delone set** consists of a set together with explicit radii\nwitnessing uniform discreteness and relative denseness. -/\n@[ext]\nstructure DeloneSet (X : Type*) [MetricSpace X] where\n /-- The underlying set. -/\n carrier : Set X\n /-- Radius such that distinct points of `carrier` are separated by more than `r`. -/\n packingRadius : ℝ≥0\n packingRadius_pos : 0 < packingRadius\n isSeparated_packingRadius : IsSeparated packingRadius carrier\n /-- Radius such that every point of the space is within `R` of `carrier`. -/\n coveringRadius : ℝ≥0\n coveringRadius_pos : 0 < coveringRadius\n isCover_coveringRadius : IsCover coveringRadius .univ carrier\n\nnamespace DeloneSet\n\n/-- The underlying set of points of a Delone set. -/\n@[coe] def toSet (D : DeloneSet X) : Set X := D.carrier\n\ninstance : Coe (DeloneSet X) (Set X) where\n coe := DeloneSet.toSet\n\ninstance : Membership X (DeloneSet X) where\n mem D x := x ∈ (D : Set X)\n\n@[simp, norm_cast]\nlemma mem_coe {D : DeloneSet X} {x : X} : x ∈ (D : Set X) ↔ x ∈ D := .rfl\n\n@[simp] lemma mem_carrier {D : DeloneSet X} {x : X} :\n x ∈ D.carrier ↔ x ∈ D := .rfl\n\nlemma nonempty [Nonempty X] (D : DeloneSet X) : (D : Set X).Nonempty :=\n D.isCover_coveringRadius.nonempty Set.univ_nonempty\n\n/-- Copy of a Delone set with new fields equal to the old ones.\nUseful to fix definitional equalities. -/\nprotected def copy (D : DeloneSet X) (carrier : Set X) (packingRadius coveringRadius : ℝ≥0)\n (h_carrier : carrier = D.carrier) (h_packing : packingRadius = D.packingRadius)\n (h_covering : coveringRadius = D.coveringRadius) :\n DeloneSet X where\n carrier := carrier\n packingRadius := packingRadius\n packingRadius_pos := by simpa [h_packing] using D.packingRadius_pos\n isSeparated_packingRadius := by\n simpa [h_carrier, h_packing] using D.isSeparated_packingRadius\n coveringRadius := coveringRadius\n coveringRadius_pos := by simpa [h_covering] using D.coveringRadius_pos\n isCover_coveringRadius := by\n simpa [h_carrier, h_covering] using D.isCover_coveringRadius\n\ntheorem copy_eq (D : DeloneSet X)\n (carrier packingRadius coveringRadius h_carrier h_packing h_covering) :\n D.copy carrier packingRadius coveringRadius h_carrier h_packing h_covering = D :=\n DeloneSet.ext h_carrier h_packing h_covering\n\nlemma packingRadius_lt_dist_of_mem_ne (D : DeloneSet X) {x y : X}\n (hx : x ∈ D) (hy : y ∈ D) (hne : x ≠ y) :\n D.packingRadius < dist x y := by\n have hsep : ENNReal.ofReal D.packingRadius < ENNReal.ofReal (dist x y) := by\n simpa [edist_dist] using D.isSeparated_packingRadius hx hy hne\n exact (ENNReal.ofReal_lt_ofReal_iff (h := dist_pos.mpr hne)).1 hsep\n\nlemma exists_dist_le_coveringRadius (D : DeloneSet X) (x : X) :\n ∃ y ∈ D, dist x y ≤ D.coveringRadius := by\n obtain ⟨y, hy, hdist⟩ := D.isCover_coveringRadius (x := x) (by trivial)\n exact ⟨y, hy, by simpa [edist_dist] using hdist⟩\n\nlemma eq_of_mem_ball (D : DeloneSet X) {r : ℝ≥0} (hr : r ≤ D.packingRadius / 2)\n {x y z : X} (hx : x ∈ D) (hy : y ∈ D) (hxz : x ∈ ball z r) (hyz : y ∈ ball z r) :\n x = y := by\n by_contra hne\n exact (D.packingRadius_lt_dist_of_mem_ne hx hy hne).not_gt <| calc\n dist x y ≤ dist x z + dist y z := dist_triangle_right x y z\n _ < r + r := by gcongr <;> simpa\n _ ≤ D.packingRadius := by rw [← add_halves D.packingRadius, NNReal.coe_add]; gcongr\n\n/-- There exists a radius `r > 0` such that any ball of radius `r`\ncentered at a point of `D` contains at most one point of `D`. -/\nlemma subset_ball_singleton (D : DeloneSet X) :\n ∃ r > 0, ∀ {x y z}, x ∈ D → y ∈ D → x ∈ ball z r → y ∈ ball z r → x = y :=\n ⟨D.packingRadius / 2, half_pos D.packingRadius_pos, fun hx hy => D.eq_of_mem_ball le_rfl hx hy⟩\n\n/-- Bilipschitz maps send Delone sets to Delone sets. -/\n@[simps]\nnoncomputable def mapBilipschitz (f : X ≃ Y) (K₁ K₂ : ℝ≥0) (hK₁ : 0 < K₁) (hK₂ : 0 < K₂)\n (hf₁ : AntilipschitzWith K₁ f) (hf₂ : LipschitzWith K₂ f) (D : DeloneSet X) : DeloneSet Y where\n carrier := f '' D.carrier\n packingRadius := D.packingRadius / K₁\n packingRadius_pos := div_pos D.packingRadius_pos hK₁\n isSeparated_packingRadius := D.isSeparated_packingRadius.image_antilipschitz hf₁ hK₁\n coveringRadius := K₂ * D.coveringRadius\n coveringRadius_pos := mul_pos hK₂ D.coveringRadius_pos\n isCover_coveringRadius := D.isCover_coveringRadius.image_lipschitz_of_surjective hf₂ f.surjective\n\n@[simp] lemma mapBilipschitz_refl (D : DeloneSet X) (hK1 hK2 hA hL) :\n D.mapBilipschitz (.refl X) 1 1 hK1 hK2 hA hL = D := by\n ext <;> simp only [mapBilipschitz, Equiv.refl_apply, Set.image_id', div_one, one_mul]\n\nlemma mapBilipschitz_trans {Z : Type*} [MetricSpace Z] (D : DeloneSet X)\n (f : X ≃ Y) (g : Y ≃ Z) (K₁f K₂f K₁g K₂g : ℝ≥0)\n (hf₁_pos : 0 < K₁f) (hf₂_pos : 0 < K₂f)\n (hg₁_pos : 0 < K₁g) (hg₂_pos : 0 < K₂g)\n (hf_anti : AntilipschitzWith K₁f f) (hf_lip : LipschitzWith K₂f f)\n (hg_anti : AntilipschitzWith K₁g g) (hg_lip : LipschitzWith K₂g g) :\n (D.mapBilipschitz f K₁f K₂f hf₁_pos hf₂_pos hf_anti hf_lip).mapBilipschitz\n g K₁g K₂g hg₁_pos hg₂_pos hg_anti hg_lip =\n D.mapBilipschitz (f.trans g) (K₁f * K₁g) (K₂g * K₂f)\n (mul_pos hf₁_pos hg₁_pos) (mul_pos hg₂_pos hf₂_pos)\n (hg_anti.comp hf_anti) (hg_lip.comp hf_lip) := by\n ext\n · simp only [mapBilipschitz_carrier, Equiv.trans_apply, Set.mem_image]\n exact exists_exists_and_eq_and\n · simp only [mapBilipschitz_packingRadius, NNReal.coe_div, div_div]\n · simp only [mapBilipschitz_coveringRadius, NNReal.coe_mul, mul_assoc]\n\n/-- The image of a Delone set under an isometry. This is a specialization of\n`DeloneSet.mapBilipschitz` where the packing and covering radii are preserved because the\nLipschitz constants are both 1. -/\n@[simps!]\nnoncomputable def mapIsometry (f : X ≃ᵢ Y) : DeloneSet X ≃ DeloneSet Y where\n toFun D := (D.mapBilipschitz f.toEquiv 1 1 zero_lt_one zero_lt_one\n f.isometry.antilipschitz f.isometry.lipschitz).copy (f '' D.carrier)\n D.packingRadius D.coveringRadius rfl (by simp [mapBilipschitz]) (by simp [mapBilipschitz])\n invFun D := (D.mapBilipschitz f.symm.toEquiv 1 1 zero_lt_one zero_lt_one\n f.symm.isometry.antilipschitz f.symm.isometry.lipschitz).copy (f.symm '' D.carrier)\n D.packingRadius D.coveringRadius rfl (by simp [mapBilipschitz]) (by simp [mapBilipschitz])\n left_inv D := by ext <;> simp [copy_eq]\n right_inv D := by ext <;> simp [copy_eq]\n\n@[simp] lemma mapIsometry_refl (D : DeloneSet X) : D.mapIsometry (.refl X) = D := by\n ext <;> simp [mapIsometry, IsometryEquiv.refl, DeloneSet.copy]\n\nlemma mapIsometry_symm (f : X ≃ᵢ Y) : (mapIsometry f).symm = mapIsometry f.symm := rfl\n\nTarget:\nlemma mapIsometry_trans {Z : Type*} [MetricSpace Z] (D : DeloneSet X) (f : X ≃ᵢ Y) (g : Y ≃ᵢ Z) :\n D.mapIsometry (f.trans g) = (D.mapIsometry f).mapIsometry g :=\n\nProof body:\n","rejected":"by\n ext <;> simp [mapIsometry, DeloneSet.copy]\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/AperiodicOrder","family_id":"mapisometry_trans","file_id":"mathlib/Mathlib/Analysis/AperiodicOrder/Delone/Basic.lean","sample_id":"ef599e1e0926b4f16624577efbb1326a2099c7624b75050a46a0bf43275bdd76"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a87755c7ff08764e6be4c6a0e3e2ca51b7a7fcc69b56648997d781554bde816b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7b6e5798fb01f5d57039217ed9c10498f339f78d55489e72cce49c284a570913","source_sha256":"2ad7529c6ca34a33092cc21bddd0d1e71ee1e7768fa0823e2ae39f94de46fb42","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro b hab\n obtain hb | hb' := hab\n · exact (h b hb).mono fun _ hx ↦ Or.inl hx\n · exact (h' b hb').mono fun _ hx ↦ Or.inr hx","hard_negative":false,"metrics":{"chosen_tokens":44,"rejected_tokens":2,"token_jaccard":0.04,"token_length_ratio":0.045455},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"738c199adb766744007e512857f5d1ee5895c767602d08aad42086f940feb6d9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Defs.Induced\npublic import Mathlib.Topology.Constructions.SumProd\nimport Mathlib.Topology.ContinuousOn\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Antoine Chambert-Loir, Anatole Dedecker, Jireh Loreaux\n-/\n/-!\n# Semicontinuous maps\n\nA function `f` from a topological space `α` to an ordered space `β` is *lower semicontinuous* at a\npoint `x` if, for any `y < f x`, for any `x'` close enough to `x`, one has `f x' > y`. In other\nwords, `f` can jump up, but it cannot jump down.\n\n*Upper semicontinuous* functions are defined similarly. Upper and lower hemicontinuity (of\nfunctions `f : α → Set β`) are often defined in terms of sequential characterizations, but\nhere we take an equivalent approach. `f : α → Set β` is *upper hemicontinuous* at `x` if for any\nneighborhood of `f x`, `f x'` is included in this neighborhood for all `x'` close enough to `x`.\n\nOf course, one can see a superficial similarity between upper semicontinuity and upper\nhemicontinuity. In fact, we can unify all of upper and lower semicontinuity and also upper and\nlower hemicontinuity under one umbrella, by considering a general relation `r : α → β → Prop` and\ndefining semicontinuity of this relation.\n\nThis file introduces these notions, and a basic API around them mimicking the API for continuous\nfunctions.\n\n## Main definitions and results\n\nWe introduce 4 generic definitions related to semicontinuity:\n* `SemicontinuousWithinAt r s x`\n* `SemicontinuousAt r x`\n* `SemicontinuousOn r s`\n* `Semicontinuous r`\n\nWe build a basic API using dot notation around these notions, and we prove that\n* constant functions are semicontinuous;\n* right composition with continuous functions preserves semicontinuity;\n\nWe also define lower and upper semicontinuity as abbreviations of these generic definitions\nand transfer the generic results to these notions.\n\nWe also define two useful notions for set-valued functions: `HasOpenLowerSections` (which says that\nfor `f : α → β` and for all `y ∈ β`, the set `{x | y ∈ f x}` is open. Similarly, we define\n`HasOpenCGraph` which says that the set of all pairs `(x, y) : α × β` with `y ∈ f x` is open.\nWe show that `HasOpenCGraph` implies `HasOpenLowerSections` (`HasOpenCGraph.hasOpenLowerSections`)\nwhich implies `LowerHemicontinuous` (`HasOpenLowerSections.lowerHemicontinuous`).\n\nWe also define variants of these two notions for `On`/`At`/`WithinAt`.\n\n## References\n\n* \n* \n\n-/\n\n@[expose] public section\n\nopen scoped Topology\n\nopen Set Function Filter\n\nvariable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace γ]\n\n/-! ## Main definitions -/\n\nsection Semicontinuous\n\n/-- A relation `r : α → β → Prop` is semicontinuous within `s` at `x : α`, if whenever `r x y`\nis true, it is also true for all `x'` sufficiently close to `x` within `s`.\n\nThis notion generalizes lower and upper semicontinuity of functions, as well as\nlower and upper hemicontinuity of set-valued correspondences. -/\ndef SemicontinuousWithinAt (r : α → β → Prop) (s : Set α) (x : α) :=\n ∀ y, r x y → ∀ᶠ x' in 𝓝[s] x, r x' y\n\n/-- A relation `r : α → β → Prop` is semicontinuous on `s` if it is semicontinuous within `s` at\neach `x ∈ s`. -/\ndef SemicontinuousOn (r : α → β → Prop) (s : Set α) :=\n ∀ x ∈ s, SemicontinuousWithinAt r s x\n\n/-- A relation `r : α → β → Prop` is semicontinuous at `x : α`, if whenever `r x y`\nis true, it is also true for all `x'` sufficiently close to `x`.\n\nThis notion generalizes lower and upper semicontinuity of functions, as well as\nlower and upper hemicontinuity of set-valued correspondences. -/\ndef SemicontinuousAt (r : α → β → Prop) (x : α) : Prop :=\n ∀ y, r x y → ∀ᶠ x' in 𝓝 x, r x' y\n\n/-- A relation `r : α → β → Prop` is semicontinuous if it is semicontinuous within `s` at each\n`x : α`. -/\ndef Semicontinuous (r : α → β → Prop) : Prop :=\n ∀ x, SemicontinuousAt r x\n\nvariable {r r' : α → β → Prop} {x : α} {s t : Set α}\n\nlemma semicontinuousWithinAt_iff_frequently :\n SemicontinuousWithinAt r s x ↔ ∀ y, (∃ᶠ x' in 𝓝[s] x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousWithinAt]\n\nlemma semicontinuousOn_iff_frequently :\n SemicontinuousOn r s ↔ ∀ x ∈ s, ∀ y, (∃ᶠ x' in 𝓝[s] x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousWithinAt, SemicontinuousOn]\n\nlemma semicontinuousAt_iff_frequently :\n SemicontinuousAt r x ↔ ∀ y, (∃ᶠ x' in 𝓝 x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, SemicontinuousAt]\n\nlemma semicontinuous_iff_frequently :\n Semicontinuous r ↔ ∀ x y, (∃ᶠ x' in 𝓝 x, ¬ r x' y) → ¬ r x y := by\n simp only [← not_eventually, not_imp_not, Semicontinuous, SemicontinuousAt]\n\ntheorem SemicontinuousWithinAt.mono (h : SemicontinuousWithinAt r s x) (hst : t ⊆ s) :\n SemicontinuousWithinAt r t x := fun y hy =>\n Filter.Eventually.filter_mono (nhdsWithin_mono _ hst) (h y hy)\n\ntheorem SemicontinuousWithinAt.congr_of_eventuallyEq {a : α}\n (h : SemicontinuousWithinAt r s a)\n (has : a ∈ s) (hfg : ∀ᶠ x in 𝓝[s] a, ∀ y, r x y ↔ r' x y) :\n SemicontinuousWithinAt r' s a := by\n intro b hb\n simp_rw [← propext_iff, ← funext_iff] at hfg\n rw [← Filter.EventuallyEq.eq_of_nhdsWithin hfg has] at hb\n filter_upwards [hfg, h b hb] with x hx hxb\n exact hx ▸ hxb\n\ntheorem semicontinuousWithinAt_univ_iff :\n SemicontinuousWithinAt r univ x ↔ SemicontinuousAt r x := by\n simp [SemicontinuousWithinAt, SemicontinuousAt, nhdsWithin_univ]\n\ntheorem SemicontinuousAt.semicontinuousWithinAt (s : Set α)\n (h : SemicontinuousAt r x) : SemicontinuousWithinAt r s x := fun y hy =>\n Filter.Eventually.filter_mono nhdsWithin_le_nhds (h y hy)\n\ntheorem SemicontinuousOn.semicontinuousWithinAt (h : SemicontinuousOn r s)\n (hx : x ∈ s) : SemicontinuousWithinAt r s x :=\n h x hx\n\ntheorem SemicontinuousOn.mono (h : SemicontinuousOn r s) (hst : t ⊆ s) :\n SemicontinuousOn r t := fun x hx => (h x (hst hx)).mono hst\n\ntheorem semicontinuousOn_univ_iff : SemicontinuousOn r univ ↔ Semicontinuous r := by\n simp [SemicontinuousOn, Semicontinuous, semicontinuousWithinAt_univ_iff]\n\n@[simp] theorem semicontinuous_restrict_iff :\n Semicontinuous (s.restrict r) ↔ SemicontinuousOn r s := by\n rw [SemicontinuousOn, Semicontinuous, SetCoe.forall]\n refine forall₂_congr fun a ha ↦ forall₂_congr fun b _ ↦ ?_\n simp only [nhdsWithin_eq_map_subtype_coe ha, eventually_map, restrict]\n\ntheorem Semicontinuous.semicontinuousAt (h : Semicontinuous r) (x : α) :\n SemicontinuousAt r x :=\n h x\n\ntheorem Semicontinuous.semicontinuousWithinAt (h : Semicontinuous r) (s : Set α)\n (x : α) : SemicontinuousWithinAt r s x :=\n (h x).semicontinuousWithinAt s\n\ntheorem Semicontinuous.semicontinuousOn (h : Semicontinuous r) (s : Set α) :\n SemicontinuousOn r s := fun x _hx => h.semicontinuousWithinAt s x\n\ntheorem semicontinuous_iff_isOpen : Semicontinuous r ↔ ∀ b, IsOpen {x | r x b} := by\n exact ⟨fun h b ↦ by simpa [isOpen_iff_mem_nhds, Filter.Eventually] using fun x hx ↦ h x b hx,\n fun h x b hbx ↦ (h b).mem_nhds hbx⟩\n\ntheorem Semicontinuous.isOpen (h : Semicontinuous r) (b : β) : IsOpen {x | r x b} :=\n semicontinuous_iff_isOpen.mp h b\n\ntheorem SemicontinuousWithinAt.inf {r' : α → β → Prop}\n (h : SemicontinuousWithinAt r s x) (h' : SemicontinuousWithinAt r' s x) :\n SemicontinuousWithinAt (r ⊓ r') s x := fun b ⟨hb, hb'⟩ ↦\n (h b hb).and (h' b hb')\n\ntheorem SemicontinuousWithinAt.sup {r' : α → β → Prop}\n (h : SemicontinuousWithinAt r s x) (h' : SemicontinuousWithinAt r' s x) :\n SemicontinuousWithinAt (r ⊔ r') s x := by\n intro b hab\n obtain hb | hb' := hab\n · exact (h b hb).mono fun _ hx ↦ Or.inl hx\n · exact (h' b hb').mono fun _ hx ↦ Or.inr hx\n\ntheorem SemicontinuousAt.inf {r' : α → β → Prop}\n (h : SemicontinuousAt r x) (h' : SemicontinuousAt r' x) :\n SemicontinuousAt (r ⊓ r') x := fun b ⟨hb, hb'⟩ ↦\n (h b hb).and (h' b hb')\n\nTarget:\ntheorem SemicontinuousAt.sup {r' : α → β → Prop}\n (h : SemicontinuousAt r x) (h' : SemicontinuousAt r' x) :\n SemicontinuousAt (r ⊔ r') x :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Semicontinuity","family_id":"semicontinuousat","file_id":"mathlib/Mathlib/Topology/Semicontinuity/Defs.lean","sample_id":"7b6e5798fb01f5d57039217ed9c10498f339f78d55489e72cce49c284a570913"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"19b90f49104298bf55068ae2e350172a63e652de1da4ae129a2ba0d4e16ad9da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a1564b83e194742c419707ef2c4e1d46de431b05110fe8e47f982f74e3fb6682","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"536eb9e8faf93f6440a7f3be49581c67d2ec61efdd731032fb0bc72a64cfe022","source_sha256":"8f6e1cc0d5e8bf0c658ed9049ca96f8833956a603531c0743e7d6a3cd38b05d8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n delta finsetIntegerMultiple commonDenom\n rw [Finset.coe_image]\n ext\n constructor\n · rintro ⟨_, ⟨x, -, rfl⟩, rfl⟩\n rw [map_integerMultiple]\n exact Set.mem_image_of_mem _ x.prop\n · rintro ⟨x, hx, rfl⟩\n exact ⟨_, ⟨⟨x, hx⟩, s.mem_attach _, rfl⟩, map_integerMultiple M s id _⟩","hard_negative":true,"metrics":{"chosen_tokens":73,"rejected_tokens":2,"token_jaccard":0.03125,"token_length_ratio":0.027397},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"749e67c99db7150d273d4f53990744e82bc55d7f0f0e86712ea9dd631a3649c4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Pointwise.Set.Scalar\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.RingTheory.Localization.Defs\n\nNamespace:\nIsLocalization\n\nLocal context:\n/-\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-/\n/-!\n# Integer elements of a localization\n\n## Main definitions\n\n* `IsLocalization.IsInteger` is a predicate stating that `x : S` is in the image of `R`\n\n## Implementation notes\n\nSee `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.\n\n## Tags\nlocalization, ring localization, commutative ring localization, characteristic predicate,\ncommutative ring, field of fractions\n-/\n\n@[expose] public section\n\n\nvariable {R : Type*} [CommSemiring R] {M : Submonoid R} {S : Type*} [CommSemiring S]\nvariable [Algebra R S] {P : Type*} [CommSemiring P]\n\nopen Function\n\nnamespace IsLocalization\n\nsection\n\nvariable (R)\n\n-- TODO: define a subalgebra of `IsInteger`s\n/-- Given `a : S`, `S` a localization of `R`, `IsInteger R a` iff `a` is in the image of\nthe localization map from `R` to `S`. -/\ndef IsInteger (a : S) : Prop :=\n a ∈ (algebraMap R S).rangeS\n\nend\n\ntheorem isInteger_zero : IsInteger R (0 : S) :=\n Subsemiring.zero_mem _\n\ntheorem isInteger_one : IsInteger R (1 : S) :=\n Subsemiring.one_mem _\n\ntheorem isInteger_add {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a + b) :=\n Subsemiring.add_mem _ ha hb\n\ntheorem isInteger_mul {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a * b) :=\n Subsemiring.mul_mem _ ha hb\n\ntheorem isInteger_smul {a : R} {b : S} (hb : IsInteger R b) : IsInteger R (a • b) := by\n rcases hb with ⟨b', hb⟩\n use a * b'\n rw [← hb, (algebraMap R S).map_mul, Algebra.smul_def]\n\nvariable (M)\nvariable [IsLocalization M S]\n\n/-- Each element `a : S` has an `M`-multiple which is an integer.\n\nThis version multiplies `a` on the right, matching the argument order in `LocalizationMap.surj`.\n-/\ntheorem exists_integer_multiple' (a : S) : ∃ b : M, IsInteger R (a * algebraMap R S b) :=\n let ⟨⟨Num, denom⟩, h⟩ := IsLocalization.surj _ a\n ⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩\n\n/-- Each element `a : S` has an `M`-multiple which is an integer.\n\nThis version multiplies `a` on the left, matching the argument order in the `SMul` instance.\n-/\ntheorem exists_integer_multiple (a : S) : ∃ b : M, IsInteger R ((b : R) • a) := by\n simp_rw [Algebra.smul_def, mul_comm _ a]\n apply exists_integer_multiple'\n\n/-- We can clear the denominators of a `Finset`-indexed family of fractions. -/\ntheorem exist_integer_multiples {ι : Type*} (s : Finset ι) (f : ι → S) :\n ∃ b : M, ∀ i ∈ s, IsLocalization.IsInteger R ((b : R) • f i) := by\n haveI := Classical.propDecidable\n refine ⟨∏ i ∈ s, (sec M (f i)).2, fun i hi => ⟨?_, ?_⟩⟩\n · exact (∏ j ∈ s.erase i, (sec M (f j)).2) * (sec M (f i)).1\n rw [map_mul, sec_spec', ← mul_assoc, ← (algebraMap R S).map_mul, ← Algebra.smul_def]\n congr 2\n refine _root_.trans ?_ (map_prod (Submonoid.subtype M) _ _).symm\n rw [mul_comm, Submonoid.coe_finsetProd,\n -- Porting note: explicitly supplied `f`\n ← Finset.prod_insert (f := fun i => ((sec M (f i)).snd : R)) (s.notMem_erase i),\n Finset.insert_erase hi]\n rfl\n\n/-- We can clear the denominators of a finite indexed family of fractions. -/\ntheorem exist_integer_multiples_of_finite {ι : Type*} [Finite ι] (f : ι → S) :\n ∃ b : M, ∀ i, IsLocalization.IsInteger R ((b : R) • f i) := by\n cases nonempty_fintype ι\n obtain ⟨b, hb⟩ := exist_integer_multiples M Finset.univ f\n exact ⟨b, fun i => hb i (Finset.mem_univ _)⟩\n\n/-- We can clear the denominators of a finite set of fractions. -/\ntheorem exist_integer_multiples_of_finset (s : Finset S) :\n ∃ b : M, ∀ a ∈ s, IsInteger R ((b : R) • a) :=\n exist_integer_multiples M s id\n\n/-- A choice of a common multiple of the denominators of a `Finset`-indexed family of fractions. -/\nnoncomputable def commonDenom {ι : Type*} (s : Finset ι) (f : ι → S) : M :=\n (exist_integer_multiples M s f).choose\n\n/-- The numerator of a fraction after clearing the denominators\nof a `Finset`-indexed family of fractions. -/\nnoncomputable def integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) : R :=\n ((exist_integer_multiples M s f).choose_spec i i.prop).choose\n\n@[simp]\ntheorem map_integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) :\n algebraMap R S (integerMultiple M s f i) = commonDenom M s f • f i :=\n ((exist_integer_multiples M s f).choose_spec _ i.prop).choose_spec\n\n/-- A choice of a common multiple of the denominators of a finite set of fractions. -/\nnoncomputable def commonDenomOfFinset (s : Finset S) : M :=\n commonDenom M s id\n\n/-- The finset of numerators after clearing the denominators of a finite set of fractions. -/\nnoncomputable def finsetIntegerMultiple [DecidableEq R] (s : Finset S) : Finset R :=\n s.attach.image fun t => integerMultiple M s id t\n\nopen scoped Pointwise\n\nTarget:\ntheorem finsetIntegerMultiple_image [DecidableEq R] (s : Finset S) :\n algebraMap R S '' finsetIntegerMultiple M s = commonDenomOfFinset M s • (s : Set S) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_536eb9e8faf9","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"05b0b3fc46b5c0a24661644bcb743a0c1f42e0dd366ee08f705888ece8631f3d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Localization","family_id":"finsetintegermultiple_image","file_id":"mathlib/Mathlib/RingTheory/Localization/Integer.lean","sample_id":"536eb9e8faf93f6440a7f3be49581c67d2ec61efdd731032fb0bc72a64cfe022"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fb62ea23cf66eede90bd2faf16ea04aba5b5b2fb23c9881807ebda46794d386b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5ccb544356f17f5e220f756afc871b86bc2a0126b2c684d29fa6f80c2f7158cd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4945b92a28e45b949748920df08f33c59e406c2154e81bbbeacdd8276c949faa","source_sha256":"d8a4525fe3eea1f2b42e402bc7c5b3087e18eabd74d9beea30d333f6129613f4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro x y h\n simp only [Subtype.ext_iff, AffineMap.restrict.coe_apply] at h ⊢\n exact hφ h","hard_negative":false,"metrics":{"chosen_tokens":25,"rejected_tokens":30,"token_jaccard":0.833333,"token_length_ratio":1.2},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"74daa8d6bbdfabf241ffb2d8e1b82eb0072947e3987cd3b0da65744323873ab8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\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@[expose] public section\n\n\nvariable {k V₁ P₁ V₂ P₂ : Type*} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁]\n [Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂]\n\ninstance AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E]\n {φ : P₁ →ᵃ[k] P₂} : Nonempty (E.map φ) := by\n obtain ⟨x, hx⟩ := id Ene\n exact ⟨⟨φ x, AffineSubspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩\n\n/-- Restrict domain and codomain of an affine map to the given subspaces. -/\ndef AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂}\n [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F := by\n refine ⟨?_, ?_, ?_⟩\n · exact fun x => ⟨φ x, hEF <| AffineSubspace.mem_map.mpr ⟨x, x.property, rfl⟩⟩\n · refine φ.linear.restrict (?_ : E.direction ≤ F.direction.comap φ.linear)\n rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n exact AffineSubspace.direction_le hEF\n · intro p v\n simp only [Subtype.ext_iff, AffineSubspace.coe_vadd]\n apply AffineMap.map_vadd\n\ntheorem AffineMap.restrict.coe_apply (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) (x : E) :\n ↑(φ.restrict hEF x) = φ x :=\n rfl\n\ntheorem AffineMap.restrict.linear_aux {φ : P₁ →ᵃ[k] P₂} {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} (hEF : E.map φ ≤ F) : E.direction ≤ F.direction.comap φ.linear := by\n rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n exact AffineSubspace.direction_le hEF\n\ntheorem AffineMap.restrict.linear (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) :\n (φ.restrict hEF).linear = φ.linear.restrict (AffineMap.restrict.linear_aux hEF) :=\n rfl\n\nTarget:\ntheorem AffineMap.restrict.injective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ)\n {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F]\n (hEF : E.map φ ≤ F) : Function.Injective (AffineMap.restrict φ hEF) :=\n\nProof body:\n","rejected":"by\n intro x y h\n simp only [Subtype.ext_iff, AffineMap.restrict.coe_apply] at h ⊢\n exact hφ h\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/AffineSpace","family_id":"affinemap","file_id":"mathlib/Mathlib/LinearAlgebra/AffineSpace/Restrict.lean","sample_id":"4945b92a28e45b949748920df08f33c59e406c2154e81bbbeacdd8276c949faa"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"060dddeef280a6dc6216754acde1d7a82b6261bb11566ff22b1c2132db22fefe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f4d5dbeb4ecbfce13f8303d07c10da1b35578c4c90953c6ec1ea9c00e130c216","source_sha256":"02d9d7bede062982511bfb44d2ffb029197390fd0d9b35d6bc34757ad110e59c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [avgRisk_fintype' hℓ]","hard_negative":false,"metrics":{"chosen_tokens":7,"rejected_tokens":2,"token_jaccard":0.125,"token_length_ratio":0.285714},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"74f5f2ea82c2d5197fcf14816f4ba9d2cf93ff040c62b3613e66bc3c4bd2ebd4","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Decision.Risk.Defs\nimport Mathlib.Probability.Decision.Risk.Basic\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Risk in countable spaces\n\nIn countable spaces, we can write integrals as sums, hence we can write the average or Bayes risk\nwith sums instead of integrals.\n\n-/\n\npublic section\n\nopen MeasureTheory Function\nopen scoped ENNReal NNReal\n\nnamespace ProbabilityTheory\n\nvariable {Θ Θ' 𝓧 𝓧' 𝓨 : Type*} {mΘ : MeasurableSpace Θ} {mΘ' : MeasurableSpace Θ'}\n {m𝓧 : MeasurableSpace 𝓧} {m𝓧' : MeasurableSpace 𝓧'} {m𝓨 : MeasurableSpace 𝓨}\n {ℓ : Θ → 𝓨 → ℝ≥0∞} {P : Kernel Θ 𝓧} {κ : Kernel 𝓧 𝓨} {π : Measure Θ}\n\nlemma avgRisk_countable [Countable Θ] [MeasurableSingletonClass Θ] :\n avgRisk ℓ P κ π = ∑' θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [avgRisk, lintegral_countable']\n\nlemma avgRisk_fintype [Fintype Θ] [MeasurableSingletonClass Θ] :\n avgRisk ℓ P κ π = ∑ θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [avgRisk, lintegral_fintype]\n\nlemma avgRisk_countable' [Countable 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n avgRisk ℓ P κ π = ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp only [avgRisk, lintegral_countable']\n rw [lintegral_tsum]\n · rfl\n · refine fun y ↦ Measurable.aemeasurable ?_\n exact Measurable.mul (by fun_prop) ((κ ∘ₖ P).measurable_coe (measurableSet_singleton y))\n\nlemma avgRisk_fintype' [Fintype 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n avgRisk ℓ P κ π = ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n rw [avgRisk_countable' hℓ, tsum_fintype]\n\nlemma bayesRisk_countable [Countable Θ] [MeasurableSingletonClass Θ] :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑' θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [bayesRisk, avgRisk_countable]\n\nlemma bayesRisk_fintype [Fintype Θ] [MeasurableSingletonClass Θ] :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑ θ, (∫⁻ y, ℓ θ y ∂((κ ∘ₖ P) θ)) * π {θ} := by\n simp [bayesRisk, avgRisk_fintype]\n\nlemma bayesRisk_countable' [Countable 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp [bayesRisk, avgRisk_countable' hℓ]\n\nlemma bayesRisk_fintype' [Fintype 𝓨] [MeasurableSingletonClass 𝓨] (hℓ : Measurable ℓ) :\n bayesRisk ℓ P π\n = ⨅ (κ : Kernel 𝓧 𝓨) (_ : IsMarkovKernel κ), ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ P θ) {y} ∂π := by\n simp [bayesRisk, avgRisk_fintype' hℓ]\n\nsection Const\n\nlemma avgRisk_const_of_countable [Countable 𝓨] [MeasurableSingletonClass 𝓨]\n (hℓ : Measurable ℓ) (μ : Measure 𝓧) (κ : Kernel 𝓧 𝓨) (π : Measure Θ) :\n avgRisk ℓ (Kernel.const Θ μ) κ π = ∑' y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ μ) {y} ∂π := by\n simp [avgRisk_countable' hℓ]\n\nTarget:\nlemma avgRisk_const_of_fintype [Fintype 𝓨] [MeasurableSingletonClass 𝓨]\n (hℓ : Measurable ℓ) (μ : Measure 𝓧) (κ : Kernel 𝓧 𝓨) (π : Measure Θ) :\n avgRisk ℓ (Kernel.const Θ μ) κ π = ∑ y, ∫⁻ θ, ℓ θ y * (κ ∘ₘ μ) {y} ∂π :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Decision","family_id":"avgrisk_const_of_fintype","file_id":"mathlib/Mathlib/Probability/Decision/Risk/Countable.lean","sample_id":"f4d5dbeb4ecbfce13f8303d07c10da1b35578c4c90953c6ec1ea9c00e130c216"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a62aa91b93568955f340d959cd2b5c79880851066cbeda03a56b07cb8e5dc4cb","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4d9f13b68e227cfe06c530fc001cc5222dd8381f432c7e1b98167da284911df3","source_sha256":"43af1408f2f686c32d7ad2107fd465552e62766c794081a786ef6955232c936d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let F : Bool → MvPolynomial σ K := fun b => cond b f₂ f₁\n have : (∑ b : Bool, (F b).totalDegree) < Fintype.card σ := (add_comm _ _).trans_lt h\n simpa only [Bool.forall_bool] using! char_dvd_card_solutions_of_fintype_sum_lt p this","hard_negative":false,"metrics":{"chosen_tokens":60,"rejected_tokens":3,"token_jaccard":0.023256,"token_length_ratio":0.05},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"760b0b25a31b3f9f8b85aa311297b49e70c99004d22930292825efa3a782167a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Finite.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# The Chevalley–Warning theorem\n\nThis file contains a proof of the Chevalley–Warning theorem.\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\n## Main results\n\n1. Let `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`)\n such that the total degree of `f` is less than `(q-1)` times the cardinality of `σ`.\n Then the evaluation of `f` on all points of `σ → K` (aka `K^σ`) sums to `0`.\n (`sum_eval_eq_zero`)\n2. The Chevalley–Warning theorem (`char_dvd_card_solutions_of_sum_lt`).\n Let `f i` be a finite family of multivariate polynomials\n in finitely many variables (`X s`, `s : σ`) such that\n the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\n Then the number of common solutions of the `f i`\n is divisible by the characteristic of `K`.\n\n## Notation\n\n- `K` is a finite field\n- `q` is notation for the cardinality of `K`\n- `σ` is the indexing type for the variables of a multivariate polynomial ring over `K`\n\n-/\n\npublic section\n\n\nuniverse u v\n\nsection FiniteField\n\nopen MvPolynomial\n\nopen Function hiding eval\n\nopen Finset FiniteField\n\nvariable {K σ ι : Type*} [Fintype K] [Field K] [Fintype σ] [DecidableEq σ]\n\nlocal notation \"q\" => Fintype.card K\n\ntheorem MvPolynomial.sum_eval_eq_zero (f : MvPolynomial σ K)\n (h : f.totalDegree < (q - 1) * Fintype.card σ) : ∑ x, eval x f = 0 := by\n haveI : DecidableEq K := Classical.decEq K\n calc\n ∑ x, eval x f = ∑ x : σ → K, ∑ d ∈ f.support, f.coeff d * ∏ i, x i ^ d i := by\n simp only [eval_eq']\n _ = ∑ d ∈ f.support, ∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i := sum_comm\n _ = 0 := sum_eq_zero ?_\n intro d hd\n obtain ⟨i, hi⟩ : ∃ i, d i < q - 1 := f.exists_degree_lt (q - 1) h hd\n calc\n (∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i) = f.coeff d * ∑ x : σ → K, ∏ i, x i ^ d i :=\n (mul_sum ..).symm\n _ = 0 := (mul_eq_zero.mpr ∘ Or.inr) ?_\n calc\n (∑ x : σ → K, ∏ i, x i ^ d i) =\n ∑ x₀ : { j // j ≠ i } → K, ∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j :=\n (Fintype.sum_fiberwise _ _).symm\n _ = 0 := Fintype.sum_eq_zero _ ?_\n intro x₀\n let e : K ≃ { x // x ∘ ((↑) : _ → σ) = x₀ } := (Equiv.subtypeEquivCodomain _).symm\n calc\n (∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j) =\n ∑ a : K, ∏ j : σ, (e a : σ → K) j ^ d j := (e.sum_comp _).symm\n _ = ∑ a : K, (∏ j, x₀ j ^ d j) * a ^ d i := Fintype.sum_congr _ _ ?_\n _ = (∏ j, x₀ j ^ d j) * ∑ a : K, a ^ d i := by rw [mul_sum]\n _ = 0 := by rw [sum_pow_lt_card_sub_one K _ hi, mul_zero]\n intro a\n let e' : { j // j = i } ⊕ { j // j ≠ i } ≃ σ := Equiv.sumCompl _\n letI : Unique { j // j = i } :=\n { default := ⟨i, rfl⟩\n uniq := fun ⟨j, h⟩ => Subtype.val_injective h }\n calc\n (∏ j : σ, (e a : σ → K) j ^ d j) =\n (e a : σ → K) i ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by\n rw [← e'.prod_comp, Fintype.prod_sum_type, univ_unique, prod_singleton]; rfl\n _ = a ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by\n rw [Equiv.subtypeEquivCodomain_symm_apply_eq]\n _ = a ^ d i * ∏ j, x₀ j ^ d j := congr_arg _ (Fintype.prod_congr _ _ ?_)\n -- see below\n _ = (∏ j, x₀ j ^ d j) * a ^ d i := mul_comm _ _\n -- the remaining step of the calculation above\n rintro ⟨j, hj⟩\n change (e a : σ → K) j ^ d j = x₀ ⟨j, hj⟩ ^ d j\n rw [Equiv.subtypeEquivCodomain_symm_apply_ne]\n\nvariable [DecidableEq K] (p : ℕ) [CharP K p]\n\n/-- The **Chevalley–Warning theorem**, finitary version.\nLet `(f i)` be a finite family of multivariate polynomials\nin finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`.\nAssume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f i` is divisible by `p`. -/\ntheorem char_dvd_card_solutions_of_sum_lt {s : Finset ι} {f : ι → MvPolynomial σ K}\n (h : (∑ i ∈ s, (f i).totalDegree) < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by\n have hq : 0 < q - 1 := by rw [← Fintype.card_units, Fintype.card_pos_iff]; exact ⟨1⟩\n let S : Finset (σ → K) := {x | ∀ i ∈ s, eval x (f i) = 0}\n have hS (x : σ → K) : x ∈ S ↔ ∀ i ∈ s, eval x (f i) = 0 := by simp [S]\n /- The polynomial `F = ∏ i ∈ s, (1 - (f i)^(q - 1))` has the nice property\n that it takes the value `1` on elements of `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}`\n while it is `0` outside that locus.\n Hence the sum of its values is equal to the cardinality of\n `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}` modulo `p`. -/\n let F : MvPolynomial σ K := ∏ i ∈ s, (1 - f i ^ (q - 1))\n have hF : ∀ x, eval x F = if x ∈ S then 1 else 0 := by\n intro x\n calc\n eval x F = ∏ i ∈ s, eval x (1 - f i ^ (q - 1)) := eval_prod s _ x\n _ = if x ∈ S then 1 else 0 := ?_\n simp only [(eval x).map_sub, (eval x).map_pow, (eval x).map_one]\n split_ifs with hx\n · apply Finset.prod_eq_one\n intro i hi\n rw [hS] at hx\n rw [hx i hi, zero_pow hq.ne', sub_zero]\n · obtain ⟨i, hi, hx⟩ : ∃ i ∈ s, eval x (f i) ≠ 0 := by\n simpa [hS, not_forall, Classical.not_imp] using hx\n apply Finset.prod_eq_zero hi\n rw [pow_card_sub_one_eq_one (eval x (f i)) hx, sub_self]\n -- In particular, we can now show:\n have key : ∑ x, eval x F = Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by\n rw [Fintype.card_of_subtype S hS, card_eq_sum_ones, Nat.cast_sum, Nat.cast_one, ←\n Fintype.sum_extend_by_zero S, sum_congr rfl fun x _ => hF x]\n -- With these preparations under our belt, we will approach the main goal.\n change p ∣ Fintype.card { x // ∀ i : ι, i ∈ s → eval x (f i) = 0 }\n rw [← CharP.cast_eq_zero_iff K, ← key]\n change (∑ x, eval x F) = 0\n -- We are now ready to apply the main machine, proven before.\n apply F.sum_eval_eq_zero\n -- It remains to verify the crucial assumption of this machine\n show F.totalDegree < (q - 1) * Fintype.card σ\n calc\n F.totalDegree ≤ ∑ i ∈ s, (1 - f i ^ (q - 1)).totalDegree := totalDegree_finsetProd s _\n _ ≤ ∑ i ∈ s, (q - 1) * (f i).totalDegree := sum_le_sum fun i _ => ?_\n -- see ↓\n _ = (q - 1) * ∑ i ∈ s, (f i).totalDegree := (mul_sum ..).symm\n _ < (q - 1) * Fintype.card σ := by gcongr\n -- Now we prove the remaining step from the preceding calculation\n change (1 - f i ^ (q - 1)).totalDegree ≤ (q - 1) * (f i).totalDegree\n calc\n (1 - f i ^ (q - 1)).totalDegree ≤\n max (1 : MvPolynomial σ K).totalDegree (f i ^ (q - 1)).totalDegree := totalDegree_sub _ _\n _ ≤ (f i ^ (q - 1)).totalDegree := by simp\n _ ≤ (q - 1) * (f i).totalDegree := totalDegree_pow _ _\n\n/-- The **Chevalley–Warning theorem**, `Fintype` version.\nLet `(f i)` be a finite family of multivariate polynomials\nin finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`.\nAssume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f i` is divisible by `p`. -/\ntheorem char_dvd_card_solutions_of_fintype_sum_lt [Fintype ι] {f : ι → MvPolynomial σ K}\n (h : (∑ i, (f i).totalDegree) < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // ∀ i, eval x (f i) = 0 } := by\n simpa using char_dvd_card_solutions_of_sum_lt p h\n\n/-- The **Chevalley–Warning theorem**, unary version.\nLet `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`)\nover a finite field of characteristic `p`.\nAssume that the total degree of `f` is less than the cardinality of `σ`.\nThen the number of solutions of `f` is divisible by `p`.\nSee `char_dvd_card_solutions_of_sum_lt` for a version that takes a family of polynomials `f i`. -/\ntheorem char_dvd_card_solutions {f : MvPolynomial σ K} (h : f.totalDegree < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // eval x f = 0 } := by\n let F : Unit → MvPolynomial σ K := fun _ => f\n have : (∑ i : Unit, (F i).totalDegree) < Fintype.card σ := h\n convert! char_dvd_card_solutions_of_sum_lt p this\n aesop\n\n/-- The **Chevalley–Warning theorem**, binary version.\nLet `f₁`, `f₂` be two multivariate polynomials in finitely many variables (`X s`, `s : σ`) over a\nfinite field of characteristic `p`.\nAssume that the sum of the total degrees of `f₁` and `f₂` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f₁` and `f₂` is divisible by `p`. -/\n\nTarget:\ntheorem char_dvd_card_solutions_of_add_lt {f₁ f₂ : MvPolynomial σ K}\n (h : f₁.totalDegree + f₂.totalDegree < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // eval x f₁ = 0 ∧ eval x f₂ = 0 } :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory","family_id":"char_dvd_card_solutions_of_add_lt","file_id":"mathlib/Mathlib/FieldTheory/ChevalleyWarning.lean","sample_id":"4d9f13b68e227cfe06c530fc001cc5222dd8381f432c7e1b98167da284911df3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca1dcd67cfdd60cbc4b2d15424590a3a4f4ff2107356c87664972f16169bd8bf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"88b36112641ff047ba015838e5303f0f47950c28aabc1fe796530f7d4bb7e171","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c15ff78bafeaf3a8bd67bcf30863b0235b5c68e08443e7038b8311fb84eab8e8","source_sha256":"4520455e04cb9adf9401fd1986b8a1189314f45434160dfa03eb1331410ec345","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← Finset.card_range m, ← Finset.prod_const]\n exact IsCoprime.prod_left fun _ _ ↦ H","hard_negative":true,"metrics":{"chosen_tokens":23,"rejected_tokens":5,"token_jaccard":0.210526,"token_length_ratio":0.217391},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"77ccba8c79ab17319f51b7d78e3c490133a27de5cf223c7811bd5b04d24a742a","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Data.Fintype.Basic\npublic import Mathlib.Data.Int.GCD\npublic import Mathlib.RingTheory.Coprime.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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-/\n/-!\n# Additional lemmas about elements of a ring satisfying `IsCoprime`\nand elements of a monoid satisfying `IsRelPrime`\n\nThese lemmas are in a separate file to the definition of `IsCoprime` or `IsRelPrime`\nas they require more imports.\n\nNotably, this includes lemmas about `Finset.prod` as this requires importing BigOperators, and\nlemmas about `Pow` since these are easiest to prove via `Finset.prod`.\n\n-/\n\npublic section\n\nuniverse u v\n\nopen scoped Function -- required for scoped `on` notation\n\nsection IsCoprime\n\nvariable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}\n\nsection\n\ntheorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by\n constructor\n · rintro ⟨a, b, h⟩\n refine Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, ?_⟩)\n rwa [mul_comm m, mul_comm n, eq_comm]\n · rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]\n intro h\n exact ⟨_, _, h⟩\n\ninstance : DecidableRel (IsCoprime : ℤ → ℤ → Prop) :=\n fun m n => decidable_of_iff (Int.gcd m n = 1) Int.isCoprime_iff_gcd_eq_one.symm\n\n@[simp, norm_cast]\ntheorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by\n rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]\n\nalias ⟨IsCoprime.natCoprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime\n\ntheorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :\n IsCoprime (a : R) (b : R) :=\n mod_cast h.isCoprime.intCast\n\ntheorem Rat.isCoprime_num_den (x : ℚ) : IsCoprime x.num x.den :=\n x.reduced.cast.of_isCoprime_of_dvd_left Int.dvd_natAbs_self\n\ntheorem Int.isCoprime_gcdA {x y : ℤ} (h : IsCoprime x y) : IsCoprime (x.gcdA y) y := by\n use x, x.gcdB y\n rwa [mul_comm _ y, ← Int.gcd_eq_gcd_ab, Nat.cast_eq_one, ← Int.isCoprime_iff_gcd_eq_one]\n\ntheorem Int.isCoprime_gcdB {x y : ℤ} (h : IsCoprime x y) : IsCoprime (x.gcdB y) x := by\n use y, x.gcdA y\n rwa [add_comm, mul_comm, ← Int.gcd_eq_gcd_ab, Nat.cast_eq_one, ← Int.isCoprime_iff_gcd_eq_one]\n\ntheorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}\n (h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=\n IsCoprime.ne_zero_or_ne_zero (R := A) <| by\n simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)\n\ntheorem IsCoprime.prod_left (h : ∀ i ∈ t, IsCoprime (s i) x) : IsCoprime (∏ i ∈ t, s i) x := by\n induction t using Finset.cons_induction with\n | empty => apply isCoprime_one_left\n | cons b t hbt ih =>\n rw [Finset.prod_cons]\n rw [Finset.forall_mem_cons] at h\n exact h.1.mul_left (ih h.2)\n\ntheorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by\n simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)\n\ntheorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by\n classical\n refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_\n rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert]\n\ntheorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by\n simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)\n\ntheorem IsCoprime.of_prod_left (H1 : IsCoprime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :\n IsCoprime (s i) x :=\n IsCoprime.prod_left_iff.1 H1 i hit\n\ntheorem IsCoprime.of_prod_right (H1 : IsCoprime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :\n IsCoprime x (s i) :=\n IsCoprime.prod_right_iff.1 H1 i hit\n\ntheorem Finset.prod_dvd_of_coprime\n (Hs : (t : Set I).Pairwise (IsCoprime on s)) (Hs1 : (∀ i ∈ t, s i ∣ z)) :\n (∏ x ∈ t, s x) ∣ z := by\n classical\n induction t using Finset.induction_on with\n | empty => simp\n | insert a r har ih =>\n rw [Finset.prod_insert har]\n refine IsCoprime.mul_dvd ?_ ?_ ?_\n · refine IsCoprime.prod_right fun i hir ↦ ?_\n exact Hs (by simp) (by simp [hir]) (ne_of_mem_of_not_mem hir har).symm\n · exact Hs1 a (Finset.mem_insert_self a r)\n · refine ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi\n simp only [Finset.coe_insert, Set.subset_insert]\n\ntheorem Fintype.prod_dvd_of_coprime [Fintype I] (Hs : Pairwise (IsCoprime on s))\n (Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=\n Finset.prod_dvd_of_coprime (Hs.set_pairwise _) fun i _ ↦ Hs1 i\n\nend\n\nopen Finset\n\ntheorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) :\n (∃ μ : I → R, (∑ i ∈ t, μ i * ∏ j ∈ t \\ {i}, s j) = 1) ↔\n Pairwise (IsCoprime on fun i : t ↦ s i) := by\n induction h using Finset.Nonempty.cons_induction with\n | singleton =>\n simp [exists_apply_eq, Pairwise, Function.onFun]\n | cons a t hat h ih =>\n rw [pairwise_cons']\n have mem : ∀ x ∈ t, a ∈ insert a t \\ {x} := fun x hx ↦ by\n rw [mem_sdiff, mem_singleton]\n exact ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩\n constructor\n · rintro ⟨μ, hμ⟩\n rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ\n refine ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩\n · rw [prod_eq_mul_prod_sdiff_singleton_of_mem h.choose_spec, ← mul_assoc, ←\n @if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ\n rw [← hμ, sum_congr rfl]\n intro x hx\n convert! add_mul (R := R) _ _ _ using 2\n · by_cases hx : x = h.choose\n · rw [hx, Pi.single_eq_same, Pi.single_eq_same]\n · rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]\n · convert! (mul_assoc _ _ _).symm\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx), mul_comm, sdiff_sdiff_comm,\n sdiff_singleton_eq_erase a, erase_insert hat]\n · have : IsCoprime (s b) (s a) :=\n ⟨μ a * ∏ i ∈ t \\ {b}, s i, ∑ i ∈ t, μ i * ∏ j ∈ t \\ {i}, s j, ?_⟩\n · exact ⟨this.symm, this⟩\n rw [mul_assoc, ← prod_eq_prod_sdiff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]\n intro x hx\n rw [mul_assoc]\n congr\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx) _]\n congr 2\n rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]\n · rintro ⟨hs, Hb⟩\n obtain ⟨μ, hμ⟩ := ih.mpr hs\n obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right\n use fun i ↦ if i = a then u else v * μ i\n have hμ' : (∑ i ∈ t, v * ((μ i * ∏ j ∈ t \\ {i}, s j) * s a)) = v * s a := by\n rw [← mul_sum, ← sum_mul, hμ, one_mul]\n rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat]\n simp only [↓reduceIte, ite_mul]\n rw [← huv, ← hμ', sum_congr rfl]\n intro x hx\n rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]\n rw [mul_assoc]\n congr\n rw [prod_eq_prod_sdiff_singleton_mul (mem x hx) _]\n congr 2\n rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]\n\ntheorem exists_sum_eq_one_iff_pairwise_coprime' [Fintype I] [Nonempty I] [DecidableEq I] :\n (∃ μ : I → R, (∑ i : I, μ i * ∏ j ∈ {i}ᶜ, s j) = 1) ↔ Pairwise (IsCoprime on s) := by\n convert! exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1\n simp only [pairwise_subtype_iff_pairwise_finset', coe_univ, Set.pairwise_univ]\n\ntheorem pairwise_coprime_iff_coprime_prod [DecidableEq I] :\n Pairwise (IsCoprime on fun i : t ↦ s i) ↔ ∀ i ∈ t, IsCoprime (s i) (∏ j ∈ t \\ {i}, s j) := by\n rw [Finset.pairwise_subtype_iff_pairwise_finset']\n refine ⟨fun hp i hi ↦ IsCoprime.prod_right_iff.mpr fun j hj ↦ ?_, fun hp ↦ ?_⟩\n · rw [Finset.mem_sdiff, Finset.mem_singleton] at hj\n exact (hp hj.1 hi hj.2).symm\n · rintro i hi j hj h\n apply IsCoprime.prod_right_iff.mp (hp i hi)\n exact Finset.mem_sdiff.mpr ⟨hj, fun f ↦ h (Finset.mem_singleton.mp f).symm⟩\n\nvariable {m n : ℕ}\n\nTarget:\ntheorem IsCoprime.pow_left (H : IsCoprime x y) : IsCoprime (x ^ m) y :=\n\nProof body:\n","rejected":"by\n exact IsCoprime.pow_left","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"f433dc92ba9db6213331c5863f98591cf98ad6e97b2a06ce4be0c07b5d8acbb3","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Coprime","family_id":"iscoprime","file_id":"mathlib/Mathlib/RingTheory/Coprime/Lemmas.lean","sample_id":"c15ff78bafeaf3a8bd67bcf30863b0235b5c68e08443e7038b8311fb84eab8e8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"58f322405e534f0d4cb401bb9744c33aeca82cada0493b153f18c04c49aae0c1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"483039e48e2da099ff0692e4d7d021895d6e250d5b5bf5d8df66c6ba8e765f8d","source_sha256":"ea49da8fadbef6df5542f48b737813b13b1fd6e8a00c791df91871e459b5fa18","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa [cylinder_eq_set_pi U x] using isClosed_set_pi (by simp)","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.153846},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"78708ca8875c61111fbbc32895cc1216d69d64ab93690ad6cd8c79d9036bae04","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Separation.Basic\n\nNamespace:\nSymbolicDynamics.FullShift\n\nLocal context:\n/-\nCopyright (c) 2025 Silvère Gangloff. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Silvère Gangloff\n-/\n/-!\n# Symbolic dynamics on cancellative monoids\n\nThis file develops a minimal API for symbolic dynamics over a\n**left-cancellative monoid** `G`—formally, a structure carrying `[Monoid G]`\nand `[IsLeftCancelMul G]` (which becomes `[AddMonoid G]` and\n`[IsLeftCancelAdd G]` in the additive form). Throughout the documentation we use the\n**additive** notations, which are the most common in symbolic dynamics, although\nall the notions introduced are defined in the multiplicative notations and adapted\nto the additive notation.\n\nGiven a finite alphabet `A`, the ambient configuration space is the set of\nfunctions `G → A`, endowed with the product topology. We define the\nleft-translation action, cylinders, finite patterns, their occurrences,\nforbidden sets, and subshifts (closed, shift-invariant subsets). Basic\ntopological facts (e.g. cylinders are clopen, occurrence sets are clopen,\nforbidden sets are closed) are proved under discreteness assumptions on\nthe alphabet.\n\nThe development is generic for left-cancellative monoids. This covers both\ngroups (the standard setting of symbolic dynamics) and more general monoids\nwhere cancellation holds but inverses may not exist. Geometry specific to\n`ℤ^d` (boxes/cubes and the box-based entropy) is deferred to a separate\nspecialization.\n\n## Why cancellativity?\n\nSome constructions, such as translating a finite pattern to occur at a point `v`,\nrequire solving equations of the form `w + v = h`. For this to have a unique\nsolution `w` given `h` and `v`, we assume **left-cancellation**:\nif `v + a = v + b` then `a = b`. This allows us to define\n`Pattern.shift` (which shifts a pattern) without using inverses,\nso that the theory works not only for groups but also for cancellative monoids.\n\n## Main definitions\n\n* `shift g x` — left translation: in additive notation `(shift v x) u = x (v + u)` (using the\n**left** action of `G` on configurations).\n* `cylinder U x` — configurations agreeing with `x` on a finite set `U ⊆ G`.\n* `Pattern A G` — a configuration which takes\ndefault value outside of a finite support, together with this support.\n* `Pattern.occursInAt p x g` — occurrence of `p` in `x` at translate `g`.\n* `forbidden F` — configurations avoiding every pattern in `F`.\n* `Subshift A G` — closed, shift-invariant subsets of the full shift.\n* `MulSubshift.ofForbidden F` — the subshift defined by forbidding a family of patterns.\n* `subshift_of_finite_type F` — a subshift of finite type defined by a finite set of\nforbidden patterns.\n* `languageOn X U` — the set of patterns of shape `U` obtained by restricting some `x ∈ X`.\n\n## Design choice: ambient vs. inner (subshift-relative) viewpoint\n\nAll core notions (shift, cylinder, occurrence, language, …) are defined **in the\nambient full shift** `G → A`. A subshift is then a closed, invariant subset,\nbundled as `Subshift A G`. Working inside a subshift is done by restriction.\n\n**Motivation.**\n\nIf cylinders and shifts were defined only *inside* a subshift, local ergonomics\nwould improve but global operations would become awkward. For instance, to prove\nthat for finite shape `U`:\n\n`languageOn (X ∪ Y) U = languageOn X U ∪ languageOn Y U,`\n\none must eventually move both sides to the ambient pattern type. Similar issues\narise for intersections, factors, and products. By contrast, with ambient\ndefinitions these set-theoretic identities are tautological.\nThus the file develops the theory ambiently, and subshifts reuse it by restriction.\n\n**Working inside a subshift.**\n\nFor `Y : Subshift A G`, cylinders and occurrence sets *inside `Y`* are simply\npreimages of the ambient ones under the inclusion `Y → (G → A)`. For example:\n\n`{ y : Y | ∀ i ∈ U, (y : G → A) i = (x : G → A) i } = (Subtype.val) ⁻¹' (cylinder U (x : G → A)).`\n\nShift invariance guarantees that the ambient shift restricts to `Y`.\n\n**Ergonomics.**\n\nThin wrappers (e.g. `Subshift.shift`, `Subshift.cylinder`, `Subshift.languageOn`)\nmay be added for convenience. They introduce no new theory and unfold to the\nambient definitions.\n\n## Namespacing policy\n\nAll ambient definitions live under the namespace `SymbolicDynamics.FullShift`.\nIf inner, subshift-relative wrappers are provided, they will be placed in the\nsubnamespace `SymbolicDynamics.Subshift`. This separation avoids name clashes\nbetween the two viewpoints, since both may naturally want to reuse names like\n`cylinder`, `shift`, `occursAt`, or `languageOn`.\n\n## Implementation notes\n\n* Openness results for cylinders and occurrence sets use\n `[DiscreteTopology A]`. Closeness results use `[T1Space A]`.\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Set Topology\n\nnamespace SymbolicDynamics\n\nnamespace FullShift\n\n/-! ## Full shift and shift action -/\n\nsection ShiftDefinition\n\nvariable {A G : Type*} [Monoid G]\n\n/-- The **left-translation shift** on configurations.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the monoid, the shifted configuration\n`mulShift g x` is defined by `(mulShift g x) h = x (g * h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g * h` in the original one.\n\nFor example, if `G = ℤ` (with addition) and `A = {0, 1}`, then\n`mulShift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/\n@[to_additive /-- The **left-translation shift** on configurations, in additive notation.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the additive monoid,\nthe shifted configuration `shift g x` is defined by `(shift g x) h = x (g + h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g + h` in the original one.\n\nFor example, if `G = ℤ` and `A = {0, 1}`, then\n`shift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/]\ndef mulShift (g : G) (x : G → A) : G → A :=\n fun h => x (g * h)\n\n@[to_additive (attr := simp)] lemma mulShift_apply (g : G) (x : G → A) (h : G) :\n mulShift g x h = x (g * h) := rfl\n\n@[to_additive (attr := simp)] lemma mulShift_one (x : G → A) : mulShift (1 : G) x = x := by\n ext h; simp [mulShift]\n\n/-- Composition of left-translation shifts corresponds to multiplication in the monoid `G`. -/\n@[to_additive] lemma mulShift_mul (g₁ g₂ : G) (x : G → A) :\n mulShift (g₁ * g₂) x = mulShift g₂ (mulShift g₁ x) := by\n ext h; simp [mulShift, mul_assoc]\n\nvariable [TopologicalSpace A]\n\n/-- The left-translation shift is continuous. -/\n@[to_additive (attr := fun_prop)] lemma continuous_mulShift (g : G) :\n Continuous (mulShift (A := A) g) := by\n -- coordinate projections are continuous; composition preserves continuity\n unfold mulShift\n fun_prop\n\nend ShiftDefinition\n\n/-! ## Cylinders -/\n\nsection Cylinders\n\nvariable {A G : Type*}\n\n/-- A *cylinder set* is the set of all configurations that agree with a given\nreference configuration `x` on a fixed finite subset `U` of the index set `G`.\n\nThe set `U` is called the *support* of the cylinder.\n\nIntuitively, cylinders specify the \"letters\" on finitely many coordinates, while\nleaving all other coordinates free. For example, in the full shift `{0, 1}^ℤ`,\nthe cylinder determined by `U = {0, 1}` and `x 0 = 1, x 1 = 0` consists of all\nbi-infinite sequences of `0`s and `1`s whose entries on positions `0` and `1`\nrespectively are `1` and `0`.\n\nWhen `A` has the discrete topology, cylinder sets form a basis of clopen sets\nfor the product topology on `G → A`. -/\ndef cylinder (U : Finset G) (x : G → A) : Set (G → A) :=\n { y | ∀ i ∈ U, y i = x i }\n\n/-- A cylinder set on `U` is the `Set.pi` over `U` of the singletons `{x i}`,\nviewed as a subset of `G → A`. Equivalently, it is the preimage of that product\nof singletons in `U → A` under the restriction map `(G → A) → (U → A)`. -/\nlemma cylinder_eq_set_pi (U : Finset G) (x : G → A) :\n cylinder U x = Set.pi (↑U : Set G) (fun i => ({x i} : Set A)) := by\n ext y; simp [cylinder, Set.pi]\n\nlemma mem_cylinder {U : Finset G} {x y : G → A} :\n y ∈ cylinder U x ↔ ∀ i ∈ U, y i = x i := Iff.rfl\n\nvariable [TopologicalSpace A]\n\n/-- Cylinders are open when `A` is discrete. -/\nlemma isOpen_cylinder [DiscreteTopology A] (U : Finset G) (x : G → A) :\n IsOpen (cylinder U x) := by\n simpa [cylinder_eq_set_pi U x] using isOpen_set_pi (U.finite_toSet) (by simp)\n\n/-- Cylinders are closed when `A` is a T1 Space. -/\n\nTarget:\nlemma isClosed_cylinder [T1Space A] (U : Finset G) (x : G → A) :\n IsClosed (cylinder U x) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/SymbolicDynamics","family_id":"isclosed_cylinder","file_id":"mathlib/Mathlib/Dynamics/SymbolicDynamics/Basic.lean","sample_id":"483039e48e2da099ff0692e4d7d021895d6e250d5b5bf5d8df66c6ba8e765f8d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7dbf6e986a353ed2a28665e4a4d20592bbe347b12df5fd5b5865ea74df58c540","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"543d76b6076e843b8bbf2e7701d81984147da6c7150e96a19e3272999e63ed8e","source_sha256":"768f43e7cd06fb0d9a653eb366ae837740338968f4d8754584874d036649ed6d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases x; cases y\n simp only [dvd_def, Prod.exists, Prod.mk_mul_mk, Prod.mk.injEq,\n exists_and_left, exists_and_right]","hard_negative":false,"metrics":{"chosen_tokens":29,"rejected_tokens":5,"token_jaccard":0.043478,"token_length_ratio":0.172414},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"78c543deea03b5141840830bb88b5562f3cb71456cfa16fc396a078f88f7d5a2","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Divisibility.Basic\npublic import Mathlib.Algebra.Group.Pi.Basic\npublic import Mathlib.Algebra.Group.Prod\npublic import Mathlib.Tactic.Common\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2023 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Lemmas about the divisibility relation in product (semi)groups\n-/\n\npublic section\n\nvariable {ι G₁ G₂ : Type*} {G : ι → Type*} [Semigroup G₁] [Semigroup G₂] [∀ i, Semigroup (G i)]\n\nTarget:\ntheorem prod_dvd_iff {x y : G₁ × G₂} :\n x ∣ y ↔ x.1 ∣ y.1 ∧ x.2 ∣ y.2 :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Divisibility","family_id":"prod_dvd_iff","file_id":"mathlib/Mathlib/Algebra/Divisibility/Prod.lean","sample_id":"543d76b6076e843b8bbf2e7701d81984147da6c7150e96a19e3272999e63ed8e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b76825397e63e5db910ed9ce861676c41de624845586a29c999cf5385a9fa38c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7b851fd2656f11d8d8aa0d4ee1fe2212f088e3ff5075841b53fce95ff807e9a6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5a6ac7caf5150468b380c4e0e02998d77af45490f9823a7727b0ef5ed26d00b2","source_sha256":"9fab1381fa124c77b2984ae6d7a34091cf75e467bd0bd60181fa1205c081c09e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← h]\n apply R.gc_leftDual_rightDual.monotone_l\n apply R.gc_leftDual_rightDual.monotone_u\n exact h₁","hard_negative":false,"metrics":{"chosen_tokens":21,"rejected_tokens":26,"token_jaccard":0.736842,"token_length_ratio":1.238095},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"78df4c5cce8a9114093000f22f74439c61c526cd297bc2e47780eb50857de2fd","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Rel\n\nNamespace:\nSetRel\n\nLocal context:\n/-\nCopyright (c) 2024 Lagrange Mathematics and Computing Research Center. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anthony Bordg\n-/\n/-!\n# The Galois Connection Induced by a Relation\n\nIn this file, we show that an arbitrary relation `R` between a pair of types `α` and `β` defines\na pair `toDual ∘ R.leftDual` and `R.rightDual ∘ ofDual` of adjoint order-preserving maps between the\ncorresponding posets `Set α` and `(Set β)ᵒᵈ`.\nWe define `R.leftFixedPoints` (resp. `R.rightFixedPoints`) as the set of fixed points `J`\n(resp. `I`) of `Set α` (resp. `Set β`) such that `rightDual (leftDual J) = J`\n(resp. `leftDual (rightDual I) = I`).\n\n## Main Results\n\n⋆ `Rel.gc_leftDual_rightDual`: we prove that the maps `toDual ∘ R.leftDual` and\n `R.rightDual ∘ ofDual` form a Galois connection.\n⋆ `Rel.equivFixedPoints`: we prove that the maps `R.leftDual` and `R.rightDual` induce inverse\n bijections between the sets of fixed points.\n\n## References\n\n⋆ Engendrement de topologies, démontrabilité et opérations sur les sous-topos, Olivia Caramello and\n Laurent Lafforgue (in preparation)\n\n## Tags\n\nrelation, Galois connection, induced bijection, fixed points\n-/\n\n@[expose] public section\n\nvariable {α β : Type*} (R : SetRel α β)\n\nnamespace SetRel\n\n/-! ### Pairs of adjoint maps defined by relations -/\n\nopen OrderDual\n\n/-- `leftDual` maps any set `J` of elements of type `α` to the set `{b : β | ∀ a ∈ J, a ~[R] b}` of\nelements `b` of type `β` such that `a ~[R] b` for every element `a` of `J`. -/\ndef leftDual (J : Set α) : Set β := {b : β | ∀ ⦃a⦄, a ∈ J → a ~[R] b}\n\n/-- `rightDual` maps any set `I` of elements of type `β` to the set `{a : α | ∀ b ∈ I, a ~[R] b}`\nof elements `a` of type `α` such that `a ~[R] b` for every element `b` of `I`. -/\ndef rightDual (I : Set β) : Set α := {a : α | ∀ ⦃b⦄, b ∈ I → a ~[R] b}\n\n/-- The pair of functions `toDual ∘ leftDual` and `rightDual ∘ ofDual` forms a Galois connection. -/\ntheorem gc_leftDual_rightDual : GaloisConnection (toDual ∘ R.leftDual) (R.rightDual ∘ ofDual) :=\n fun _ _ ↦ ⟨fun h _ ha _ hb ↦ h (by simpa) ha, fun h _ hb _ ha ↦ h (by simpa) hb⟩\n\n/-! ### Induced equivalences between fixed points -/\n\n/-- `leftFixedPoints` is the set of elements `J : Set α` satisfying `rightDual (leftDual J) = J`. -/\ndef leftFixedPoints := {J : Set α | R.rightDual (R.leftDual J) = J}\n\n/-- `rightFixedPoints` is the set of elements `I : Set β` satisfying `leftDual (rightDual I) = I`.\n-/\ndef rightFixedPoints := {I : Set β | R.leftDual (R.rightDual I) = I}\n\nopen GaloisConnection\n\n/-- `leftDual` maps every element `J` to `rightFixedPoints`. -/\ntheorem leftDual_mem_rightFixedPoint (J : Set α) : R.leftDual J ∈ R.rightFixedPoints := by\n apply le_antisymm\n · apply R.gc_leftDual_rightDual.monotone_l; exact R.gc_leftDual_rightDual.le_u_l J\n · exact R.gc_leftDual_rightDual.l_u_le (R.leftDual J)\n\n/-- `rightDual` maps every element `I` to `leftFixedPoints`. -/\ntheorem rightDual_mem_leftFixedPoint (I : Set β) : R.rightDual I ∈ R.leftFixedPoints := by\n apply le_antisymm\n · apply R.gc_leftDual_rightDual.monotone_u; exact R.gc_leftDual_rightDual.l_u_le I\n · exact R.gc_leftDual_rightDual.le_u_l (R.rightDual I)\n\n/-- The maps `leftDual` and `rightDual` induce inverse bijections between the sets of fixed points.\n-/\ndef equivFixedPoints : R.leftFixedPoints ≃ R.rightFixedPoints where\n toFun := fun ⟨J, _⟩ => ⟨R.leftDual J, R.leftDual_mem_rightFixedPoint J⟩\n invFun := fun ⟨I, _⟩ => ⟨R.rightDual I, R.rightDual_mem_leftFixedPoint I⟩\n left_inv J := by obtain ⟨J, hJ⟩ := J; rw [Subtype.mk.injEq, hJ]\n right_inv I := by obtain ⟨I, hI⟩ := I; rw [Subtype.mk.injEq, hI]\n\ntheorem rightDual_leftDual_le_of_le {J J' : Set α} (h : J' ∈ R.leftFixedPoints) (h₁ : J ≤ J') :\n R.rightDual (R.leftDual J) ≤ J' := by\n rw [← h]\n apply R.gc_leftDual_rightDual.monotone_u\n apply R.gc_leftDual_rightDual.monotone_l\n exact h₁\n\nTarget:\ntheorem leftDual_rightDual_le_of_le {I I' : Set β} (h : I' ∈ R.rightFixedPoints) (h₁ : I ≤ I') :\n R.leftDual (R.rightDual I) ≤ I' :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n rw [← h]\n apply R.gc_leftDual_rightDual.monotone_l\n apply R.gc_leftDual_rightDual.monotone_u\n exact h₁","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Rel","family_id":"leftdual_rightdual_le_of_le","file_id":"mathlib/Mathlib/Order/Rel/GaloisConnection.lean","sample_id":"5a6ac7caf5150468b380c4e0e02998d77af45490f9823a7727b0ef5ed26d00b2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5dbd71689158601c5789ec24cc14570ce28d27112ad7ed5d699e6e66523ae261","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0c3920a8fdf8971445628185598dc677c397e925560d772951b9774f97c709d7","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a596a1ccb0d0a918a560b38e1d029403d9f1e2e9bfaa6c957f03ddc8f0f8cd05","source_sha256":"f134e208ef1ed7469f55b728b3abbaf40d3b9460e8d396abbdb8740673919f45","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨f, -⟩ ⟨g, -⟩; simp","hard_negative":false,"metrics":{"chosen_tokens":14,"rejected_tokens":19,"token_jaccard":0.666667,"token_length_ratio":1.357143},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"78ea9f582207ebdd8c17ed617fb20de489be41c2c5a205d4be06b3c4826796d3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Embedding.Basic\npublic import Mathlib.Order.RelClasses\n\nNamespace:\nRelEmbedding\n\nLocal context:\n/-\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/-!\n# Relation homomorphisms, embeddings, isomorphisms\n\nThis file defines relation homomorphisms, embeddings, isomorphisms and order embeddings and\nisomorphisms.\n\n## Main declarations\n\n* `RelHom`: Relation homomorphism. A `RelHom r s` is a function `f : α → β` such that\n `r a b → s (f a) (f b)`.\n* `RelEmbedding`: Relation embedding. A `RelEmbedding r s` is an embedding `f : α ↪ β` such that\n `r a b ↔ s (f a) (f b)`.\n* `RelIso`: Relation isomorphism. A `RelIso r s` is an equivalence `f : α ≃ β` such that\n `r a b ↔ s (f a) (f b)`.\n* `sumLexCongr`, `prodLexCongr`: Creates a relation homomorphism between two `Sum.Lex` or two\n `Prod.Lex` from relation homomorphisms between their arguments.\n\n## Notation\n\n* `→r`: `RelHom`\n* `↪r`: `RelEmbedding`\n* `≃r`: `RelIso`\n-/\n\n@[expose] public section\n\nopen Function\n\nuniverse u v w\n\nvariable {α β γ δ : Type*} {r : α → α → Prop} {s : β → β → Prop}\n {t : γ → γ → Prop} {u : δ → δ → Prop}\n\n/-- A relation homomorphism with respect to a given pair of relations `r` and `s`\nis a function `f : α → β` such that `r a b → s (f a) (f b)`. -/\nstructure RelHom {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) where\n /-- The underlying function of a `RelHom` -/\n toFun : α → β\n /-- A `RelHom` sends related elements to related elements -/\n map_rel' : ∀ {a b}, r a b → s (toFun a) (toFun b)\n\n/-- A relation homomorphism with respect to a given pair of relations `r` and `s`\nis a function `f : α → β` such that `r a b → s (f a) (f b)`. -/\ninfixl:25 \" →r \" => RelHom\n\nsection\n\n/-- `RelHomClass F r s` asserts that `F` is a type of functions such that all `f : F`\nsatisfy `r a b → s (f a) (f b)`.\n\nThe relations `r` and `s` are `outParam`s since figuring them out from a goal is a higher-order\nmatching problem that Lean usually can't do unaided.\n-/\nclass RelHomClass (F : Type*) {α β : outParam Type*} (r : outParam <| α → α → Prop)\n (s : outParam <| β → β → Prop) [FunLike F α β] : Prop where\n /-- A `RelHomClass` sends related elements to related elements -/\n map_rel : ∀ (f : F) {a b}, r a b → s (f a) (f b)\n\nexport RelHomClass (map_rel)\n\nend\n\nnamespace RelHomClass\n\nvariable {F : Type*} [FunLike F α β]\n\nprotected theorem irrefl [RelHomClass F r s] (f : F) : ∀ [Std.Irrefl s], Std.Irrefl r\n | ⟨H⟩ => ⟨fun _ h => H _ (map_rel f h)⟩\n\n@[deprecated (since := \"2026-01-07\")] protected alias isIrrefl := RelHomClass.irrefl\n\nprotected theorem asymm [RelHomClass F r s] (f : F) : ∀ [Std.Asymm s], Std.Asymm r\n | ⟨H⟩ => ⟨fun _ _ h₁ h₂ => H _ _ (map_rel f h₁) (map_rel f h₂)⟩\n\n@[deprecated (since := \"2026-01-07\")] protected alias isAsymm := RelHomClass.asymm\n\nprotected theorem acc [RelHomClass F r s] (f : F) (a : α) : Acc s (f a) → Acc r a := by\n generalize h : f a = b\n intro ac\n induction ac generalizing a with | intro _ H IH => ?_\n subst h\n exact ⟨_, fun a' h => IH (f a') (map_rel f h) _ rfl⟩\n\nprotected theorem wellFounded [RelHomClass F r s] (f : F) : WellFounded s → WellFounded r\n | ⟨H⟩ => ⟨fun _ => RelHomClass.acc f _ (H _)⟩\n\nprotected theorem isWellFounded [RelHomClass F r s] (f : F) [IsWellFounded β s] :\n IsWellFounded α r :=\n ⟨RelHomClass.wellFounded f IsWellFounded.wf⟩\n\nend RelHomClass\n\nnamespace RelHom\n\ninstance : FunLike (r →r s) α β where\n coe o := o.toFun\n coe_injective f g h := by\n cases f\n cases g\n congr\n\ninstance : RelHomClass (r →r s) r s where\n map_rel := map_rel'\n\ninitialize_simps_projections RelHom (toFun → apply)\n\nprotected theorem map_rel (f : r →r s) {a b} : r a b → s (f a) (f b) :=\n f.map_rel'\n\n@[simp]\ntheorem coe_fn_toFun (f : r →r s) : f.toFun = (f : α → β) :=\n rfl\n\n@[simp]\ntheorem coeFn_mk (f : α → β) (h : ∀ {a b}, r a b → s (f a) (f b)) :\n RelHom.mk f @h = f :=\n rfl\n\n/-- The map `coe_fn : (r →r s) → (α → β)` is injective. -/\ntheorem coe_fn_injective : Injective fun (f : r →r s) => (f : α → β) :=\n DFunLike.coe_injective\n\n@[ext]\ntheorem ext ⦃f g : r →r s⦄ (h : ∀ x, f x = g x) : f = g :=\n DFunLike.ext f g h\n\n/-- Identity map is a relation homomorphism. -/\n@[refl, simps]\nprotected def id (r : α → α → Prop) : r →r r :=\n ⟨fun x => x, fun x => x⟩\n\n/-- Composition of two relation homomorphisms is a relation homomorphism. -/\n@[simps]\nprotected def comp (g : s →r t) (f : r →r s) : r →r t :=\n ⟨fun x => g (f x), fun h => g.2 (f.2 h)⟩\n\ntheorem comp_assoc (h : r →r s) (g : s →r t) (f : t →r u) :\n (f.comp g).comp h = f.comp (g.comp h) := rfl\n\n@[simp]\ntheorem comp_id (f : r →r s) : f.comp (RelHom.id r) = f := rfl\n\n@[simp]\ntheorem id_comp (f : r →r s) : (RelHom.id s).comp f = f := rfl\n\n/-- A relation homomorphism is also a relation homomorphism between dual relations. -/\n@[simps]\nprotected def swap (f : r →r s) : swap r →r swap s :=\n ⟨f, f.map_rel⟩\n\n/-- A function is a relation homomorphism from the preimage relation of `s` to `s`. -/\n@[simps]\ndef preimage (f : α → β) (s : β → β → Prop) : f ⁻¹'o s →r s :=\n ⟨f, id⟩\n\nend RelHom\n\n/-- An increasing function is injective -/\ntheorem injective_of_increasing (r : α → α → Prop) (s : β → β → Prop) [Std.Trichotomous r]\n [Std.Irrefl s] (f : α → β) (hf : ∀ {x y}, r x y → s (f x) (f y)) : Injective f := by\n intro x y hxy\n rcases trichotomous_of r x y with (h | h | h)\n · have := hf h\n rw [hxy] at this\n exfalso\n exact irrefl_of s (f y) this\n · exact h\n · have := hf h\n rw [hxy] at this\n exfalso\n exact irrefl_of s (f y) this\n\n/-- An increasing function is injective -/\ntheorem RelHom.injective_of_increasing [Std.Trichotomous r] [Std.Irrefl s] (f : r →r s) :\n Injective f :=\n _root_.injective_of_increasing r s f f.map_rel\n\ntheorem Function.Surjective.wellFounded_iff {f : α → β} (hf : Surjective f)\n (o : ∀ {a b}, r a b ↔ s (f a) (f b)) :\n WellFounded r ↔ WellFounded s :=\n Iff.intro\n (RelHomClass.wellFounded (⟨surjInv hf,\n fun h => by simpa only [o, surjInv_eq hf] using h⟩ : s →r r))\n (RelHomClass.wellFounded (⟨f, o.1⟩ : r →r s))\n\n/-- A relation embedding with respect to a given pair of relations `r` and `s`\nis an embedding `f : α ↪ β` such that `r a b ↔ s (f a) (f b)`. -/\nstructure RelEmbedding {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends α ↪ β where\n /-- Elements are related iff they are related after apply a `RelEmbedding` -/\n map_rel_iff' : ∀ {a b}, s (toEmbedding a) (toEmbedding b) ↔ r a b\n\n/-- A relation embedding with respect to a given pair of relations `r` and `s`\nis an embedding `f : α ↪ β` such that `r a b ↔ s (f a) (f b)`. -/\ninfixl:25 \" ↪r \" => RelEmbedding\n\ntheorem preimage_equivalence {α β} (f : α → β) {s : β → β → Prop} (hs : Equivalence s) :\n Equivalence (f ⁻¹'o s) :=\n ⟨fun _ => hs.1 _, fun h => hs.2 h, fun h₁ h₂ => hs.3 h₁ h₂⟩\n\nnamespace RelEmbedding\n\n/-- A relation embedding is also a relation homomorphism -/\n@[reducible]\ndef toRelHom (f : r ↪r s) : r →r s where\n toFun := f.toEmbedding.toFun\n map_rel' := (map_rel_iff' f).mpr\n\ninstance : Coe (r ↪r s) (r →r s) :=\n ⟨toRelHom⟩\n\ninstance : FunLike (r ↪r s) α β where\n coe x := x.toFun\n coe_injective f g h := by\n rcases f with ⟨⟨⟩⟩\n rcases g with ⟨⟨⟩⟩\n congr\n\ninstance : RelHomClass (r ↪r s) r s where\n map_rel f _ _ := Iff.mpr (map_rel_iff' f)\n\ninitialize_simps_projections RelEmbedding (toFun → apply)\n\ninstance : EmbeddingLike (r ↪r s) α β where\n injective' f := f.inj'\n\n@[simp]\ntheorem coe_toEmbedding {f : r ↪r s} : ((f : r ↪r s).toEmbedding : α → β) = f :=\n rfl\n\ntheorem coe_toRelHom {f : r ↪r s} : ((f : r ↪r s).toRelHom : α → β) = f :=\n rfl\n\nTarget:\ntheorem toEmbedding_injective : Injective (toEmbedding : r ↪r s → (α ↪ β)) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n rintro ⟨f, -⟩ ⟨g, -⟩; simp","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/RelIso","family_id":"toembedding_injective","file_id":"mathlib/Mathlib/Order/RelIso/Basic.lean","sample_id":"a596a1ccb0d0a918a560b38e1d029403d9f1e2e9bfaa6c957f03ddc8f0f8cd05"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0fc3ffde48221e0c6de049969eb07449fb8d0bef56191dde47b1c056396304fc","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d81b2abee0540c32988a1a319e970edaee20173c292d001e41edb11167988005","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8dfa4cbeabaa34a88c663ec293bcd521cf11a47da5dc596a9b5faad70653593f","source_sha256":"1dcf65c8ea7778a6ecd23b33c451f9deaac459a250401fe1c6886135569df43d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [fderiv_fun_pow n differentiableAt_fun_id, fderiv_fun_id]","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":5,"token_jaccard":0.076923,"token_length_ratio":0.555556},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"78f0cbd111427dc72e3c50c4158521338365ab202bfd8ddb9b3d2d8ad0dcf701","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Calculus.FDeriv.Mul\npublic import Mathlib.Analysis.Calculus.FDeriv.Comp\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n/-!\n# Fréchet Derivative of `f x ^ n`, `n : ℕ`\n\nIn this file we prove that the Fréchet derivative of `fun x => f x ^ n`,\nwhere `n` is a natural number, is `n • f x ^ (n - 1)) • f'`.\nAdditionally, we prove the case for non-commutative rings (with primed names like `fderiv_pow'`),\nwhere the result is instead `∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i`.\n\nFor detailed documentation of the Fréchet derivative,\nsee the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.\n\n## Keywords\n\nderivative, power\n-/\n\npublic section\n\nvariable {𝕜 𝔸 E : Type*}\n\nsection NormedRing\nvariable [NontriviallyNormedField 𝕜] [NormedRing 𝔸] [NormedAddCommGroup E]\nvariable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}\n\nopen scoped RightActions\n\nprivate theorem aux (f : E → 𝔸) (f' : E →L[𝕜] 𝔸) (x : E) (n : ℕ) :\n f x •> ∑ i ∈ Finset.range (n + 1), f x ^ ((n + 1).pred - i) •> f' <• f x ^ i\n + f' <• (f x ^ (n + 1)) =\n ∑ i ∈ Finset.range (n + 1 + 1), f x ^ ((n + 1 + 1).pred - i) •> f' <• f x ^ i := by\n rw [Finset.sum_range_succ _ (n + 1), Finset.smul_sum]\n simp only [Nat.pred_eq_sub_one, add_tsub_cancel_right, tsub_self, pow_zero, one_smul]\n simp_rw [smul_comm (_ : 𝔸) (_ : 𝔸ᵐᵒᵖ), smul_smul, ← pow_succ']\n congr! 5 with x hx\n simp only [Finset.mem_range, Nat.lt_succ_iff] at hx\n rw [tsub_add_eq_add_tsub hx]\n\n@[to_fun]\ntheorem HasStrictFDerivAt.pow' (h : HasStrictFDerivAt f f' x) (n : ℕ) :\n HasStrictFDerivAt (f ^ n)\n (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=\n match n with\n | 0 => by simpa using! hasStrictFDerivAt_const 1 x\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n refine this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasStrictFDerivAt_pow' (n : ℕ) {x : 𝔸} :\n HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=\n hasStrictFDerivAt_id _ |>.pow' n\n\n@[to_fun]\ntheorem HasFDerivWithinAt.pow' (h : HasFDerivWithinAt f f' s x) (n : ℕ) :\n HasFDerivWithinAt (f ^ n)\n (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) s x :=\n match n with\n | 0 => by simpa using! hasFDerivWithinAt_const 1 x s\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n exact this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasFDerivWithinAt_pow' (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n HasFDerivWithinAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) s x :=\n hasFDerivWithinAt_id _ _ |>.pow' n\n\n@[to_fun]\ntheorem HasFDerivAt.pow' (h : HasFDerivAt f f' x) (n : ℕ) :\n HasFDerivAt (f ^ n) (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=\n match n with\n | 0 => by simpa using! hasFDerivAt_const 1 x\n | 1 => by simpa using h\n | n + 1 + 1 => by\n have := h.mul' (h.pow' (n + 1))\n simp_rw [pow_succ' _ (n + 1)]\n exact this.congr_fderiv <| aux _ _ _ _\n\ntheorem hasFDerivAt_pow' (n : ℕ) {x : 𝔸} :\n HasFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)\n (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=\n hasFDerivAt_id _ |>.pow' n\n\n@[fun_prop]\ntheorem DifferentiableWithinAt.fun_pow (hf : DifferentiableWithinAt 𝕜 f s x) (n : ℕ) :\n DifferentiableWithinAt 𝕜 (fun x => f x ^ n) s x :=\n let ⟨_, hf'⟩ := hf; ⟨_, hf'.pow' n⟩\n\n@[fun_prop]\ntheorem DifferentiableWithinAt.pow (hf : DifferentiableWithinAt 𝕜 f s x) :\n ∀ n : ℕ, DifferentiableWithinAt 𝕜 (f ^ n) s x :=\n hf.fun_pow\n\ntheorem differentiableWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n DifferentiableWithinAt 𝕜 (fun x : 𝔸 => x ^ n) s x :=\n differentiableWithinAt_id.pow _\n\n@[to_fun (attr := simp, fun_prop)]\ntheorem DifferentiableAt.pow (hf : DifferentiableAt 𝕜 f x) (n : ℕ) :\n DifferentiableAt 𝕜 (f ^ n) x :=\n differentiableWithinAt_univ.mp <| hf.differentiableWithinAt.pow n\n\ntheorem differentiableAt_pow (n : ℕ) {x : 𝔸} : DifferentiableAt 𝕜 (fun x : 𝔸 => x ^ n) x :=\n differentiableAt_id.pow _\n\n@[to_fun (attr := fun_prop)]\ntheorem DifferentiableOn.pow (hf : DifferentiableOn 𝕜 f s) (n : ℕ) :\n DifferentiableOn 𝕜 (f ^ n) s := fun x h => (hf x h).pow n\n\ntheorem differentiableOn_pow (n : ℕ) {s : Set 𝔸} : DifferentiableOn 𝕜 (fun x : 𝔸 => x ^ n) s :=\n differentiableOn_id.pow n\n\n@[to_fun (attr := simp, fun_prop)]\ntheorem Differentiable.pow (hf : Differentiable 𝕜 f) (n : ℕ) : Differentiable 𝕜 (f ^ n) :=\n fun x => (hf x).pow n\n\ntheorem differentiable_pow (n : ℕ) : Differentiable 𝕜 fun x : 𝔸 => x ^ n :=\n differentiable_id.pow _\n\n@[to_fun fderiv_fun_pow']\ntheorem fderiv_pow' (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :\n fderiv 𝕜 (f ^ n) x\n = (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderiv 𝕜 f x <• f x ^ i) :=\n hf.hasFDerivAt.pow' n |>.fderiv\n\ntheorem fderiv_pow_ring' {x : 𝔸} (n : ℕ) :\n fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x\n = (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by\n rw [fderiv_fun_pow' n differentiableAt_fun_id, fderiv_fun_id]\n\n@[to_fun fderivWithin_fun_pow']\ntheorem fderivWithin_pow' (hxs : UniqueDiffWithinAt 𝕜 s x)\n (n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :\n fderivWithin 𝕜 (f ^ n) s x\n = (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderivWithin 𝕜 f s x <• f x ^ i) :=\n hf.hasFDerivWithinAt.pow' n |>.fderivWithin hxs\n\ntheorem fderivWithin_pow_ring' {s : Set 𝔸} {x : 𝔸} (n : ℕ) (hxs : UniqueDiffWithinAt 𝕜 s x) :\n fderivWithin 𝕜 (fun x : 𝔸 ↦ x ^ n) s x\n = (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by\n rw [fderivWithin_fun_pow' hxs n differentiableAt_fun_id.differentiableWithinAt,\n fderivWithin_fun_id hxs]\n\nend NormedRing\n\nsection NormedCommRing\nvariable [NontriviallyNormedField 𝕜] [NormedCommRing 𝔸] [NormedAddCommGroup E]\nvariable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}\n\nprivate theorem aux_sum_eq_pow (n : ℕ) :\n ∑ i ∈ Finset.range n, MulOpposite.op (f x ^ i) • f x ^ (n.pred - i) • f' =\n (n • f x ^ (n - 1)) • f' := by\n simp_rw [op_smul_eq_smul, smul_smul, ← pow_add, ← Finset.sum_smul]\n rw [Finset.sum_eq_card_nsmul, Finset.card_range, smul_assoc]\n intro a ha\n congr\n exact add_tsub_cancel_of_le (Nat.le_pred_of_lt <| Finset.mem_range.1 ha)\n\ntheorem HasStrictFDerivAt.pow (h : HasStrictFDerivAt f f' x) (n : ℕ) :\n HasStrictFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasStrictFDerivAt_pow (n : ℕ) {x : 𝔸} :\n HasStrictFDerivAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=\n hasStrictFDerivAt_id _ |>.pow n\n\ntheorem HasFDerivWithinAt.pow (h : HasFDerivWithinAt f f' s x) (n : ℕ) :\n HasFDerivWithinAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') s x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasFDerivWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :\n HasFDerivWithinAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) s x :=\n hasFDerivWithinAt_id _ _ |>.pow n\n\ntheorem HasFDerivAt.pow (h : HasFDerivAt f f' x) (n : ℕ) :\n HasFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=\n h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _\n\ntheorem hasFDerivAt_pow (n : ℕ) {x : 𝔸} :\n HasFDerivAt (𝕜 := 𝕜)\n (fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=\n hasFDerivAt_id _ |>.pow n\n\n@[to_fun fderiv_fun_pow]\ntheorem fderiv_pow (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :\n fderiv 𝕜 (f ^ n) x = (n • f x ^ (n - 1)) • fderiv 𝕜 f x :=\n hf.hasFDerivAt.pow n |>.fderiv\n\nTarget:\ntheorem fderiv_pow_ring {x : 𝔸} (n : ℕ) :\n fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x = (n • x ^ (n - 1)) • .id _ _ :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_8dfa4cbeabaa","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"4a8a8d1a181a55ec5209cb593020d34ee473e500939a03c4fc06cddc38eaa938","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Calculus","family_id":"fderiv_pow_ring","file_id":"mathlib/Mathlib/Analysis/Calculus/FDeriv/Pow.lean","sample_id":"8dfa4cbeabaa34a88c663ec293bcd521cf11a47da5dc596a9b5faad70653593f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"21197415fc76bbeec14284dfe5142af722642f83db976e5754f59667c59834da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c7dba750c2f9a85961ca6220766a4f9406f27c76c7a4e9e1a37f9d66b5fd8cd8","source_sha256":"f94ad482bdf55f9150f7a0c83c1bf04503493ff9c8ec82badf04c9b48a731d5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply Metric.ediam_le\n rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩\n exact hf.edist_le_mul_of_le (Metric.edist_le_ediam_of_mem hx hy)","hard_negative":false,"metrics":{"chosen_tokens":33,"rejected_tokens":5,"token_jaccard":0.130435,"token_length_ratio":0.151515},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"79456ab9235da206458f9ff4ba875943eab696a7c5faa2a1fa4ec084cbd2c779","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Tactic.Finiteness\npublic import Mathlib.Topology.EMetricSpace.Diam\n\nNamespace:\nLipschitzWith\n\nLocal context:\n/-\nCopyright (c) 2018 Rohan Mitta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov, Winston Yin\n-/\n/-!\n# Lipschitz continuous functions\n\nA map `f : α → β` between two (extended) metric spaces is called *Lipschitz continuous*\nwith constant `K ≥ 0` if for all `x, y` we have `edist (f x) (f y) ≤ K * edist x y`.\nFor a metric space, the latter inequality is equivalent to `dist (f x) (f y) ≤ K * dist x y`.\nThere is also a version asserting this inequality only for `x` and `y` in some set `s`.\nFinally, `f : α → β` is called *locally Lipschitz continuous* if each `x : α` has a neighbourhood\non which `f` is Lipschitz continuous (with some constant).\n\nIn this file we provide various ways to prove that various combinations of Lipschitz continuous\nfunctions are Lipschitz continuous. We also prove that Lipschitz continuous functions are\nuniformly continuous, and that locally Lipschitz functions are continuous.\n\n## Main definitions and lemmas\n\n* `LipschitzWith K f`: states that `f` is Lipschitz with constant `K : ℝ≥0`\n* `LipschitzOnWith K f s`: states that `f` is Lipschitz with constant `K : ℝ≥0` on a set `s`\n* `LipschitzWith.uniformContinuous`: a Lipschitz function is uniformly continuous\n* `LipschitzOnWith.uniformContinuousOn`: a function which is Lipschitz on a set `s` is uniformly\n continuous on `s`.\n* `LocallyLipschitz f`: states that `f` is locally Lipschitz\n* `LocallyLipschitzOn f s`: states that `f` is locally Lipschitz on `s`.\n* `LocallyLipschitz.continuous`: a locally Lipschitz function is continuous.\n\n\n## Implementation notes\n\nThe parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have\ncoercions both to `ℝ` and `ℝ≥0∞`. Constructors whose names end with `'` take `K : ℝ` as an\nargument, and return `LipschitzWith (Real.toNNReal K) f`.\n-/\n\n@[expose] public section\n\nuniverse u v w x\n\nopen Filter Function Set Topology NNReal ENNReal Bornology\n\nvariable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x}\n\nsection PseudoEMetricSpace\nvariable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {K : ℝ≥0} {s t : Set α} {f : α → β}\n\n/-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` if for all `x, y`\nwe have `dist (f x) (f y) ≤ K * dist x y`. -/\ndef LipschitzWith (K : ℝ≥0) (f : α → β) := ∀ x y, edist (f x) (f y) ≤ K * edist x y\n\n/-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` **on `s`** if\nfor all `x, y` in `s` we have `dist (f x) (f y) ≤ K * dist x y`. -/\ndef LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α) :=\n ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → edist (f x) (f y) ≤ K * edist x y\n\n/-- `f : α → β` is called **locally Lipschitz continuous** iff every point `x`\nhas a neighbourhood on which `f` is Lipschitz. -/\ndef LocallyLipschitz (f : α → β) : Prop := ∀ x, ∃ K, ∃ t ∈ 𝓝 x, LipschitzOnWith K f t\n\n/-- `f : α → β` is called **locally Lipschitz continuous** on `s` iff every point `x` of `s`\nhas a neighbourhood within `s` on which `f` is Lipschitz. -/\ndef LocallyLipschitzOn (s : Set α) (f : α → β) : Prop :=\n ∀ ⦃x⦄, x ∈ s → ∃ K, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t\n\n/-- Every function is Lipschitz on the empty set (with any Lipschitz constant). -/\n@[simp]\ntheorem lipschitzOnWith_empty (K : ℝ≥0) (f : α → β) : LipschitzOnWith K f ∅ := fun _ => False.elim\n\n@[simp] lemma locallyLipschitzOn_empty (f : α → β) : LocallyLipschitzOn ∅ f := fun _ ↦ False.elim\n\n/-- Being Lipschitz on a set is monotone w.r.t. that set. -/\ntheorem LipschitzOnWith.mono (hf : LipschitzOnWith K f t) (h : s ⊆ t) : LipschitzOnWith K f s :=\n fun _x x_in _y y_in => hf (h x_in) (h y_in)\n\nlemma LocallyLipschitzOn.mono (hf : LocallyLipschitzOn t f) (h : s ⊆ t) : LocallyLipschitzOn s f :=\n fun x hx ↦ by obtain ⟨K, u, hu, hfu⟩ := hf (h hx); exact ⟨K, u, nhdsWithin_mono _ h hu, hfu⟩\n\n/-- `f` is Lipschitz iff it is Lipschitz on the entire space. -/\n@[simp] lemma lipschitzOnWith_univ : LipschitzOnWith K f univ ↔ LipschitzWith K f := by\n simp [LipschitzOnWith, LipschitzWith]\n\n@[simp] lemma locallyLipschitzOn_univ : LocallyLipschitzOn univ f ↔ LocallyLipschitz f := by\n simp [LocallyLipschitzOn, LocallyLipschitz]\n\nprotected lemma LocallyLipschitz.locallyLipschitzOn (h : LocallyLipschitz f) :\n LocallyLipschitzOn s f := (locallyLipschitzOn_univ.2 h).mono s.subset_univ\n\ntheorem lipschitzOnWith_iff_restrict : LipschitzOnWith K f s ↔ LipschitzWith K (s.restrict f) := by\n simp [LipschitzOnWith, LipschitzWith]\n\nlemma lipschitzOnWith_restrict {t : Set s} :\n LipschitzOnWith K (s.restrict f) t ↔ LipschitzOnWith K f (s ∩ Subtype.val '' t) := by\n simp [LipschitzOnWith]\n\nlemma locallyLipschitzOn_iff_restrict :\n LocallyLipschitzOn s f ↔ LocallyLipschitz (s.restrict f) := by\n simp only [LocallyLipschitzOn, LocallyLipschitz, SetCoe.forall',\n lipschitzOnWith_restrict,\n nhds_subtype_eq_comap_nhdsWithin, mem_comap]\n congr! with x K\n constructor\n · rintro ⟨t, ht, hft⟩\n exact ⟨_, ⟨t, ht, Subset.rfl⟩, hft.mono <| inter_subset_right.trans <| image_preimage_subset ..⟩\n · rintro ⟨t, ⟨u, hu, hut⟩, hft⟩\n exact ⟨s ∩ u, Filter.inter_mem self_mem_nhdsWithin hu,\n hft.mono fun x hx ↦ ⟨hx.1, ⟨x, hx.1⟩, hut hx.2, rfl⟩⟩\n\nalias ⟨LipschitzOnWith.to_restrict, _⟩ := lipschitzOnWith_iff_restrict\nalias ⟨LocallyLipschitzOn.restrict, _⟩ := locallyLipschitzOn_iff_restrict\n\nlemma Set.MapsTo.lipschitzOnWith_iff_restrict {t : Set β} (h : MapsTo f s t) :\n LipschitzOnWith K f s ↔ LipschitzWith K (h.restrict f s t) :=\n _root_.lipschitzOnWith_iff_restrict\n\nalias ⟨LipschitzOnWith.mapsToRestrict, _⟩ := Set.MapsTo.lipschitzOnWith_iff_restrict\n\nend PseudoEMetricSpace\n\nnamespace LipschitzWith\n\nopen Metric\n\nvariable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]\nvariable {K : ℝ≥0} {f : α → β} {x y : α} {r : ℝ≥0∞} {s : Set α}\n\nprotected theorem lipschitzOnWith (h : LipschitzWith K f) : LipschitzOnWith K f s :=\n fun x _ y _ => h x y\n\ntheorem edist_le_mul (h : LipschitzWith K f) (x y : α) : edist (f x) (f y) ≤ K * edist x y :=\n h x y\n\ntheorem edist_le_mul_of_le (h : LipschitzWith K f) (hr : edist x y ≤ r) :\n edist (f x) (f y) ≤ K * r :=\n (h x y).trans <| mul_right_mono hr\n\ntheorem edist_lt_mul_of_lt (h : LipschitzWith K f) (hK : K ≠ 0) (hr : edist x y < r) :\n edist (f x) (f y) < K * r := by grw [h x y]; gcongr; simp\n\ntheorem mapsTo_closedEBall (h : LipschitzWith K f) (x : α) (r : ℝ≥0∞) :\n MapsTo f (closedEBall x r) (closedEBall (f x) (K * r)) := fun _y hy => h.edist_le_mul_of_le hy\n\n@[deprecated (since := \"2026-01-24\")]\nalias mapsTo_emetric_closedBall := mapsTo_closedEBall\n\ntheorem mapsTo_eball (h : LipschitzWith K f) (hK : K ≠ 0) (x : α) (r : ℝ≥0∞) :\n MapsTo f (eball x r) (eball (f x) (K * r)) := fun _y hy => h.edist_lt_mul_of_lt hK hy\n\n@[deprecated (since := \"2026-01-24\")]\nalias mapsTo_emetric_ball := mapsTo_eball\n\ntheorem edist_lt_top (hf : LipschitzWith K f) {x y : α} (h : edist x y ≠ ⊤) :\n edist (f x) (f y) < ⊤ :=\n (hf x y).trans_lt (by finiteness)\n\ntheorem mul_edist_le (h : LipschitzWith K f) (x y : α) :\n (K⁻¹ : ℝ≥0∞) * edist (f x) (f y) ≤ edist x y := by\n rw [mul_comm, ← div_eq_mul_inv]\n exact ENNReal.div_le_of_le_mul' (h x y)\n\nprotected theorem of_edist_le (h : ∀ x y, edist (f x) (f y) ≤ edist x y) : LipschitzWith 1 f :=\n fun x y => by simp only [ENNReal.coe_one, one_mul, h]\n\nprotected theorem weaken (hf : LipschitzWith K f) {K' : ℝ≥0} (h : K ≤ K') : LipschitzWith K' f :=\n fun x y => le_trans (hf x y) <| mul_left_mono (ENNReal.coe_le_coe.2 h)\n\nTarget:\ntheorem ediam_image_le (hf : LipschitzWith K f) (s : Set α) :\n Metric.ediam (f '' s) ≤ K * Metric.ediam s :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/EMetricSpace","family_id":"ediam_image_le","file_id":"mathlib/Mathlib/Topology/EMetricSpace/Lipschitz.lean","sample_id":"c7dba750c2f9a85961ca6220766a4f9406f27c76c7a4e9e1a37f9d66b5fd8cd8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c7ec1ced95ea630553477d9eb8c3247deb262c047f2bb2048c55bf4d5e2893c0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b9360ebe53660c7f43e1efc522a0b00ec25e80fa23fcbb8dff92cfbef6d60d19","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"37912b3f0151b80119703c8165d6a17ef16224c308db2e6e588ca3f111147549","source_sha256":"43583c3ac7bef530c0b3cbfe6dc114d31d1a19b81ff88819ab7ad0165c02c799","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n classical\n suffices ((Finsupp.lapply i).comp\n (mvPolynomialBasis R σ).repr.toLinearMap).compDer (D _ _) = MvPolynomial.pderiv i by\n rw [← this]; rfl\n apply MvPolynomial.derivation_ext\n simp [Finsupp.single_apply, Pi.single_apply]","hard_negative":false,"metrics":{"chosen_tokens":56,"rejected_tokens":61,"token_jaccard":0.894737,"token_length_ratio":1.089286},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"79b7556565f8c11395a22cf9e8acf88bbca035468ff465f2fa671ffb82da96bb","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.Basic\npublic import Mathlib.Algebra.MvPolynomial.PDeriv\npublic import Mathlib.Algebra.Polynomial.Derivation\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# The Kähler differential module of polynomial algebras\n-/\n\n@[expose] public section\n\nopen Algebra Module\nopen scoped TensorProduct\n\nuniverse u v\n\nvariable (R : Type u) [CommRing R]\n\nsuppress_compilation\n\nsection MvPolynomial\n\n/-- The relative differential module of a polynomial algebra `R[σ]` is the free module generated by\n`{ dx | x ∈ σ }`. Also see `KaehlerDifferential.mvPolynomialBasis`. -/\ndef KaehlerDifferential.mvPolynomialEquiv (σ : Type*) :\n Ω[MvPolynomial σ R⁄R] ≃ₗ[MvPolynomial σ R] σ →₀ MvPolynomial σ R where\n __ := (MvPolynomial.mkDerivation _ (Finsupp.single · 1)).liftKaehlerDifferential\n invFun := Finsupp.linearCombination (α := σ) _ (fun x ↦ D _ _ (MvPolynomial.X x))\n right_inv := by\n intro x\n induction x using Finsupp.induction_linear with\n | zero => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]; rw [map_zero, map_zero]\n | add => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, map_add] at *; simp only [*]\n | single a b => simp [-map_smul]\n left_inv := by\n intro x\n obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ x\n induction x using Finsupp.induction_linear with\n | zero =>\n simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]\n rw [map_zero, map_zero, map_zero]\n | add => simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom] at *; simp only [*]\n | single a b =>\n simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Finsupp.linearCombination_single,\n map_smul, Derivation.liftKaehlerDifferential_comp_D]\n congr 1\n induction a using MvPolynomial.induction_on\n · simp only [MvPolynomial.derivation_C, map_zero]\n · simp only [map_add, *]\n · simp [*]\n\n/-- `{ dx | x ∈ σ }` forms a basis of the relative differential module\nof a polynomial algebra `R[σ]`. -/\ndef KaehlerDifferential.mvPolynomialBasis (σ) :\n Basis σ (MvPolynomial σ R) Ω[MvPolynomial σ R⁄R] :=\n ⟨mvPolynomialEquiv R σ⟩\n\nlemma KaehlerDifferential.mvPolynomialBasis_repr_comp_D (σ) :\n (mvPolynomialBasis R σ).repr.toLinearMap.compDer (D _ _) =\n MvPolynomial.mkDerivation _ (Finsupp.single · 1) :=\n Derivation.liftKaehlerDifferential_comp _\n\nlemma KaehlerDifferential.mvPolynomialBasis_repr_D (σ) (x) :\n (mvPolynomialBasis R σ).repr (D _ _ x) =\n MvPolynomial.mkDerivation R (Finsupp.single · (1 : MvPolynomial σ R)) x :=\n Derivation.congr_fun (mvPolynomialBasis_repr_comp_D R σ) x\n\n@[simp]\nlemma KaehlerDifferential.mvPolynomialBasis_repr_D_X (σ) (i) :\n (mvPolynomialBasis R σ).repr (D _ _ (.X i)) = Finsupp.single i 1 := by\n simp [mvPolynomialBasis_repr_D]\n\n@[simp]\n\nTarget:\nlemma KaehlerDifferential.mvPolynomialBasis_repr_apply (σ) (x) (i) :\n (mvPolynomialBasis R σ).repr (D _ _ x) i = MvPolynomial.pderiv i x :=\n\nProof body:\n","rejected":"by\n classical\n suffices ((Finsupp.lapply i).comp\n (mvPolynomialBasis R σ).repr.toLinearMap).compDer (D _ _) = MvPolynomial.pderiv i by\n rw [← this]; rfl\n apply MvPolynomial.derivation_ext\n simp [Finsupp.single_apply, Pi.single_apply]\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Kaehler","family_id":"kaehlerdifferential","file_id":"mathlib/Mathlib/RingTheory/Kaehler/Polynomial.lean","sample_id":"37912b3f0151b80119703c8165d6a17ef16224c308db2e6e588ca3f111147549"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"50e1884f204fe9b0194be2baa5dce9eea0b7edf0ff4416c86d663c15e06a8313","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2eb94d3cffab4bffed4926ba1e4b8052833dce4efca752f00aa18e8581754037","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf27af568e5ddb49b9516f70bedf6915249cc5893f64759981a14879b4377b5b","source_sha256":"f7d1bebf16f480e84526d8880e653d41fa5a6f52a23418295c797275de9896c1","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n induction n with\n | zero => rfl\n | succ n hn =>\n rw [Finset.sum_range_succ, numDerangements_succ, hn, Finset.mul_sum, tsub_self,\n Nat.ascFactorial_zero, Int.ofNat_one, mul_one, pow_succ', neg_one_mul, sub_eq_add_neg,\n add_left_inj, Finset.sum_congr rfl]\n -- show that (n + 1) * (-1)^x * asc_fac x (n - x) = (-1)^x * asc_fac x (n.succ - x)\n intro x hx\n have h_le : x ≤ n := Finset.mem_range_succ_iff.mp hx\n rw [Nat.succ_sub h_le, Nat.ascFactorial_succ, add_right_comm, add_tsub_cancel_of_le h_le,\n Int.natCast_mul, Int.natCast_add, mul_left_comm, Nat.cast_one]","hard_negative":true,"metrics":{"chosen_tokens":139,"rejected_tokens":2,"token_jaccard":0.016667,"token_length_ratio":0.014388},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"79e09902492ae237933abf63c57ab7023290c7e6ffe7df6a6376e8945a8b1e97","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Combinatorics.Derangements.Basic\npublic import Mathlib.Data.Fintype.BigOperators\npublic import Mathlib.Tactic.Ring\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Henry Swanson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henry Swanson\n-/\n/-!\n# Derangements on fintypes\n\nThis file contains lemmas that describe the cardinality of `derangements α` when `α` is a fintype.\n\n## Main definitions\n\n* `card_derangements_invariant`: A lemma stating that the number of derangements on a type `α`\n depends only on the cardinality of `α`.\n* `numDerangements n`: The number of derangements on an n-element set, defined in a computation-\n friendly way.\n* `card_derangements_eq_numDerangements`: Proof that `numDerangements` really does compute the\n number of derangements.\n* `numDerangements_sum`: A lemma giving an expression for `numDerangements n` in terms of\n factorials.\n-/\n\n@[expose] public section\n\n\nopen derangements Equiv Fintype\n\nvariable {α : Type*} [DecidableEq α] [Fintype α]\n\ninstance : DecidablePred (· ∈ derangements α) := fun _ => Fintype.decidableForallFintype\n\ninstance : Fintype (derangements α) :=\n inferInstanceAs <| Fintype { f : Perm α | ∀ x : α, f x ≠ x }\n\n\ntheorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β]\n [DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) :=\n Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h)\n\ntheorem card_derangements_fin_add_two (n : ℕ) :\n card (derangements (Fin (n + 2))) =\n (n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by\n -- get some basic results about the size of Fin (n+1) plus or minus an element\n have h1 : ∀ a : Fin (n + 1), card ({a}ᶜ : Set (Fin (n + 1))) = card (Fin n) := by\n intro a\n rw [Fintype.card_compl_set]\n simp\n have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option]\n -- rewrite the LHS and substitute in our fintype-level equivalence\n simp only [card_derangements_invariant h2,\n card_congr\n (@derangementsRecursionEquiv (Fin (n + 1))\n _), -- push the cardinality through the Σ and ⊕ so that we can use `card_n`\n card_sigma,\n card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin,\n mul_add, Nat.cast_id]\n\n/-- The number of derangements of an `n`-element set. -/\ndef numDerangements : ℕ → ℕ\n | 0 => 1\n | 1 => 0\n | n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1))\n\n@[simp]\ntheorem numDerangements_zero : numDerangements 0 = 1 :=\n rfl\n\n@[simp]\ntheorem numDerangements_one : numDerangements 1 = 0 :=\n rfl\n\ntheorem numDerangements_add_two (n : ℕ) :\n numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) :=\n rfl\n\ntheorem numDerangements_succ (n : ℕ) :\n (numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by\n induction n with\n | zero => rfl\n | succ n hn =>\n simp only [numDerangements_add_two, hn, pow_succ, Int.natCast_mul, Int.natCast_add]\n ring\n\ntheorem card_derangements_fin_eq_numDerangements {n : ℕ} :\n card (derangements (Fin n)) = numDerangements n := by\n induction n using Nat.strongRecOn with | ind n hyp => _\n rcases n with _ | _ | n\n -- knock out cases 0 and 1\n · rfl\n · rfl\n -- now we have n ≥ 2. rewrite everything in terms of card_derangements, so that we can use\n -- `card_derangements_fin_add_two`\n rw [numDerangements_add_two, card_derangements_fin_add_two, mul_add, hyp, hyp] <;> lia\n\ntheorem card_derangements_eq_numDerangements (α : Type*) [Fintype α] [DecidableEq α] :\n card (derangements α) = numDerangements (card α) := by\n rw [← card_derangements_invariant (card_fin _)]\n exact card_derangements_fin_eq_numDerangements\n\nTarget:\ntheorem numDerangements_sum (n : ℕ) :\n (numDerangements n : ℤ) =\n ∑ k ∈ Finset.range (n + 1), (-1 : ℤ) ^ k * Nat.ascFactorial (k + 1) (n - k) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_cf27af568e5d","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"d3c7dfc48180013ccca03a9871307968b121484e3d53b9697656f6980f791e8f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Derangements","family_id":"numderangements_sum","file_id":"mathlib/Mathlib/Combinatorics/Derangements/Finite.lean","sample_id":"cf27af568e5ddb49b9516f70bedf6915249cc5893f64759981a14879b4377b5b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"571f2e4ca0c2a7aa28375a5ba134134b5e2d37b43c06df4d4a6341a7a5173f4b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e0652dfab90c3945582df3483cddf77da0e8bf24955d88330a44d12b6aabd486","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fba8170fa1ee067a248954d66a9ec3494bcb3555899fd1dc4f88beebd98dbd49","source_sha256":"31511787b8ee979ad68b270d70d53565c4f726a4fcbb6bab5c8059163486f498","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp","hard_negative":true,"metrics":{"chosen_tokens":26,"rejected_tokens":2,"token_jaccard":0.047619,"token_length_ratio":0.076923},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"7af9d0adcdde95a54fe9bda6512ccdc1c73e5ac05a29a2b2894d83c19adc24c4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Finite\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.GroupTheory.Coset.Defs\n\nNamespace:\nDiscreteTiling.PlacedTile\n\nLocal context:\n/-\nCopyright (c) 2026 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Tiles for tilings\n\nThis file defines some basic concepts related to individual tiles for tilings in a discrete context\n(with definitions in a continuous context to be developed separately but analogously).\n\nWork in the field of tilings does not generally try to define or state things in any kind of maximal\ngenerality, so it is necessary to adapt definitions and statements from the literature to produce\nsomething that seems appropriately general for mathlib, covering a wide range of tiling-related\nconcepts found in the literature. Nevertheless, further generalization may prove of use as this work\nis extended in future.\n\nWe work in the context of a space `X` acted on by a group `G`; the action is not required to be\nfaithful, although typically it is. In a discrete context, tiles are expected to cover the space, or\na subset of it being tiled when working with tilings not of the whole space, and the tiles are\npairwise disjoint. In a continuous context, definitions in the literature vary; the tiles may be\nclosed and cover the space with interiors required to be disjoint (as used by Grünbaum and Shephard\nor Goodman-Strauss), or they may be required to be measurable and to partition it up to null sets\n(as used by Greenfeld and Tao).\n\nIn general we are concerned not with a tiling in isolation but with tilings by some protoset of\ntiles; thus we make definitions in the context of such a protoset, where copies of the tiles in the\ntiling must be images of those tiles under the action of an element of the given group.\n\nWhere there are matching rules that say what combinations of tiles are considered as valid, these\nare provided as separate hypotheses where required. Tiles in a protoset are commonly considered in\nthe literature to be marked in some way. When this is simply to distinguish two otherwise identical\ntiles, this is represented by the use of different indices in the protoset. When this is to give a\ntile fewer symmetries than it would otherwise have under the action of the given group, this is\nrepresented by the symmetries specified in the `Prototile` being less than its full stabilizer.\n\nThe group `G` is throughout here a multiplicative group. Additive groups are also used in the\nliterature, typically when based on `ℤ`; to support the use of additive groups, `to_additive` could\nbe used with the theory here.\n\n## Main definitions\n\n* `Prototile G X`: A prototile in `X` as acted on by `G`, carrying the information of a subgroup of\n the stabilizer that says when two copies of the prototile are considered the same.\n\n* `Protoset G X ιₚ`: An indexed family of prototiles.\n\n* `PlacedTile ps`: An image of a tile in the protoset `ps`.\n\n## References\n\n* [Branko Grünbaum and G. C. Shephard, *Tilings and Patterns*][GrunbaumShephard1987]\n* [Chaim Goodman-Strauss, *Open Questions in Tiling*][GoodmanStrauss2000]\n* [Rachel Greenfeld and Terence Tao, *A counterexample to the periodic tiling\n conjecture*][GreenfeldTao2024]\n-/\n\n\n@[expose] public section\n\nnamespace DiscreteTiling\n\nopen Function\nopen scoped Pointwise\n\nvariable {G X ιₚ : Type*} [Group G] [MulAction G X]\n\nvariable (G X) in\n/-- A `Prototile G X` describes a tile in `X`, copies of which under elements of `G` may be used in\ntilings. Two copies related by an element of `symmetries` are considered the same; two copies not so\nrelated, even if they have the same points, are considered distinct. -/\n@[ext] structure Prototile where\n /-- The points in the prototile. Use the coercion to `Set X`, or `∈` on the `Prototile`, rather\n than using `carrier` directly. The coercion cannot use `SetLike` because it does not satisfy\n `coe_injective`. -/\n carrier : Set X\n /-- The group elements considered to be symmetries of the prototile. -/\n symmetries : Subgroup (MulAction.stabilizer G carrier)\n\nnamespace Prototile\n\ninstance : Inhabited (Prototile G X) where\n default := ⟨∅, ⊥⟩\n\ninstance : CoeOut (Prototile G X) (Set X) where\n coe := Prototile.carrier\n\nattribute [coe] carrier\n\ninstance : Membership X (Prototile G X) where\n mem p x := x ∈ (p : Set X)\n\nlemma coe_mk (c s) : (⟨c, s⟩ : Prototile G X) = c := rfl\n\n@[simp] lemma mem_coe {x : X} {p : Prototile G X} : x ∈ (p : Set X) ↔ x ∈ p := Iff.rfl\n\nend Prototile\n\nvariable (G X ιₚ) in\n/-- A `Protoset G X ιₚ` is an indexed family of `Prototile G X`. This is a separate definition\nrather than just using plain functions to facilitate defining associated API that can be used with\ndot notation. -/\n@[ext] structure Protoset where\n /-- The tiles in the protoset. Use the coercion to a function rather than using `tiles`\n directly. -/\n tiles : ιₚ → Prototile G X\n\nnamespace Protoset\n\ninstance : Inhabited (Protoset G X ιₚ) where\n default := ⟨fun _ ↦ default⟩\n\ninstance : CoeFun (Protoset G X ιₚ) (fun _ ↦ ιₚ → Prototile G X) where\n coe := tiles\n\nattribute [coe] tiles\n\nlemma coe_mk (t) : (⟨t⟩ : Protoset G X ιₚ) = t := rfl\n\n@[simp, norm_cast] lemma coe_inj {ps₁ ps₂ : Protoset G X ιₚ} :\n (ps₁ : ιₚ → Prototile G X) = ps₂ ↔ ps₁ = ps₂ :=\n Protoset.ext_iff.symm\n\nlemma coe_injective : Injective (Protoset.tiles : Protoset G X ιₚ → ιₚ → Prototile G X) :=\n fun _ _ ↦ coe_inj.1\n\nend Protoset\n\nvariable {ps : Protoset G X ιₚ}\n\nvariable (ps) in\n/-- A `PlacedTile ps` is an image of a tile in the protoset `p` under an element of the group `G`.\nThis is represented using a quotient so that images under group elements differing only by a\nsymmetry of the tile are equal. -/\n@[ext] structure PlacedTile where\n /-- The index of the tile in the protoset. -/\n index : ιₚ\n /-- The group elements under which this tile is an image. -/\n groupElts : G ⧸ ((ps index).symmetries.map <| Subgroup.subtype _)\n\nnamespace PlacedTile\n\ninstance [Nonempty ιₚ] : Nonempty (PlacedTile ps) := ⟨⟨Classical.arbitrary _, (1 : G)⟩⟩\n\n/-- An induction principle to deduce results for `PlacedTile` from those given an index and an\nelement of `G`, used with `induction pt using PlacedTile.induction_on`. -/\n@[elab_as_elim] protected lemma induction_on {ppt : PlacedTile ps → Prop} (pt : PlacedTile ps)\n (h : ∀ i : ιₚ, ∀ gx : G, ppt ⟨i, gx⟩) : ppt pt := by\n rcases pt with ⟨i, gx⟩\n induction gx using Quotient.inductionOn\n apply h\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using existence of a\ncommon group element. -/\nlemma ext_iff_of_exists {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧ ∃ g, ⟦g⟧ = pt₁.groupElts ∧ ⟦g⟧ = pt₂.groupElts := by\n refine ⟨fun h ↦ ?_, fun ⟨h, g, hg₁, hg₂⟩ ↦ ?_⟩\n · subst h\n simp only [and_self, true_and]\n refine ⟨pt₁.groupElts.out, ?_⟩\n rw [Quotient.out_eq]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at h\n subst h\n ext\n · rfl\n · exact heq_of_eq (hg₁.symm.trans hg₂)\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using equality of\nquotient preimages. -/\nlemma ext_iff_of_preimage {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧\n (Quotient.mk _) ⁻¹' {pt₁.groupElts} = (Quotient.mk _) ⁻¹' {pt₂.groupElts} := by\n refine ⟨fun h ↦ ?_, fun ⟨hi, hq⟩ ↦ ?_⟩\n · subst h\n simp only [and_self]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at hi\n subst hi\n ext\n · rfl\n · exact heq_of_eq (Set.singleton_eq_singleton_iff.1\n ((Set.preimage_eq_preimage Quotient.mk''_surjective).1 hq))\n\n/-- Coercion from a `PlacedTile` to a set of points. Use the coercion rather than using `coeSet`\ndirectly. -/\n@[coe] def coeSet (pt : PlacedTile ps) : Set X :=\n Quotient.liftOn' pt.groupElts (fun g ↦ g • (ps pt.index : Set X))\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n rw [eq_comm, ← inv_smul_eq_iff, smul_smul, ← MulAction.mem_stabilizer_iff]\n exact SetLike.le_def.1 (Subgroup.map_subtype_le _) r\n\ninstance : CoeOut (PlacedTile ps) (Set X) where\n coe := coeSet\n\ninstance : Membership X (PlacedTile ps) where\n mem p x := x ∈ (p : Set X)\n\n@[simp] lemma mem_coe {x : X} {pt : PlacedTile ps} : x ∈ (pt : Set X) ↔ x ∈ pt := Iff.rfl\n\nlemma coe_mk_mk (i : ιₚ) (g : G) : (⟨i, ⟦g⟧⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_mk_coe (i : ιₚ) (g : G) : (⟨i, g⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nTarget:\nlemma coe_nonempty_iff {pt : PlacedTile ps} :\n (pt : Set X).Nonempty ↔ (ps pt.index : Set X).Nonempty :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_fba8170fa1ee","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"9c5bea554ae1bb71e7bddec295f26f7ecc1421e21c4d3f8ac20daaab79ac8f83","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Tiling","family_id":"coe_nonempty_iff","file_id":"mathlib/Mathlib/Combinatorics/Tiling/Tile.lean","sample_id":"fba8170fa1ee067a248954d66a9ec3494bcb3555899fd1dc4f88beebd98dbd49"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"589d2bd934ad8a183e4b3780f6483bcfe39599e9a0c2e35df8adc8dbbaab4bed","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"880ae981d104590c309da35a4c4816eb8c470c8212a5a446d10b6ea98d0d9602","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ad2d7b0cfde55626bb20e49111367eba759d89a1d85c9ee4882d8a3ab0bc1a20","source_sha256":"1b475ae1c04af2e8dc43839d1384cf44772b61b4c52d624fb93de6266591f8c5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply padicNorm.not_int_of_not_padic_int 2\n rw [padicNorm.eq_zpow_of_nonzero (harmonic_pos (ne_zero_of_lt h)).ne',\n padicValRat_two_harmonic, neg_neg, zpow_natCast]\n exact one_lt_pow₀ one_lt_two (Nat.log_pos one_lt_two h).ne'","hard_negative":true,"metrics":{"chosen_tokens":40,"rejected_tokens":3,"token_jaccard":0.074074,"token_length_ratio":0.075},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"7b70e83b687a1e355c2315a1d39e6678338e58fb71a14c939d2af00442ef67bc","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.Harmonic.Defs\npublic import Mathlib.NumberTheory.Padics.PadicNumbers\npublic import Mathlib.Tactic.Positivity\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2023 Koundinya Vajjha. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Koundinya Vajjha, Thomas Browning\n-/\n/-!\n\nThe nth Harmonic number is not an integer. We formalize the proof using\n2-adic valuations. This proof is due to Kürschák.\n\nReference:\nhttps://kconrad.math.uconn.edu/blurbs/gradnumthy/padicharmonicsum.pdf\n\n-/\n\npublic section\n\nlemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n := by\n unfold harmonic\n rw [← Finset.nonempty_range_iff] at Hn\n positivity\n\n/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm of n. -/\ntheorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by\n induction n with\n | zero => simp\n | succ n ih =>\n rcases eq_or_ne n 0 with rfl | hn\n · simp\n rw [harmonic_succ]\n have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹ := by\n rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]\n exact Nat.log_ne_padicValNat_succ hn\n rw [padicValRat.add_eq_min (harmonic_succ n ▸ (harmonic_pos n.succ_ne_zero).ne')\n (harmonic_pos hn).ne' (inv_ne_zero (Nat.cast_ne_zero.mpr n.succ_ne_zero)) key, ih,\n padicValRat.inv, padicValRat.of_nat, min_neg_neg, neg_inj, ← Nat.cast_max, Nat.cast_inj]\n exact Nat.max_log_padicValNat_succ_eq_log_succ n\n\n/-- The 2-adic norm of the n-th harmonic number is 2 raised to the logarithm of n in base 2. -/\nlemma padicNorm_two_harmonic {n : ℕ} (hn : n ≠ 0) :\n ‖(harmonic n : ℚ_[2])‖ = 2 ^ (Nat.log 2 n) := by\n rw [Padic.eq_padicNorm, padicNorm.eq_zpow_of_nonzero (harmonic_pos hn).ne',\n padicValRat_two_harmonic, neg_neg, zpow_natCast, Rat.cast_pow, Rat.cast_natCast, Nat.cast_ofNat]\n\n/-- The n-th harmonic number is not an integer for n ≥ 2. -/\n\nTarget:\ntheorem harmonic_not_int {n : ℕ} (h : 2 ≤ n) : ¬ (harmonic n).isInt :=\n\nProof body:\n","rejected":"by\n exact harmonic_not_int","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"4bc642892d39431e5ba48bc60a6c9a0969fb3ff1ef9a45826e3f659937417d31","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Harmonic","family_id":"harmonic_not_int","file_id":"mathlib/Mathlib/NumberTheory/Harmonic/Int.lean","sample_id":"ad2d7b0cfde55626bb20e49111367eba759d89a1d85c9ee4882d8a3ab0bc1a20"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b8ad902050e495c9c6044daca69b6b535110214affffd080282c2a08b24973f5","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f22f80c1a43541829a9abfe45c501e2f08fb44de4c00bb183be36e65122cdf4f","source_sha256":"1184e00df794ae0cc3cb94d891a807375a55a88ac5b64d1a726798271ef9526a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : DistribSMul.toLinearMap k V a = a • LinearMap.id := by\n ext; simp\n simp [smul_eq_map, map_direction, this, Submodule.map_smul, ha]","hard_negative":true,"metrics":{"chosen_tokens":34,"rejected_tokens":8,"token_jaccard":0.137931,"token_length_ratio":0.235294},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"7b8422093f1b1532ec5a291be425364de970127fb6efa45514486cf643020a46","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic\n\nNamespace:\nAffineSubspace\n\nLocal context:\n/-\nCopyright (c) 2022 Hanting Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Hanting Zhang\n-/\n/-! # Pointwise instances on `AffineSubspace`s\n\nThis file provides the additive action `AffineSubspace.pointwiseAddAction` in the\n`Pointwise` locale.\n\n-/\n\n@[expose] public section\n\n\nopen Affine Pointwise\n\nopen Set\n\nvariable {M k V P V₁ P₁ V₂ P₂ : Type*}\n\nnamespace AffineSubspace\nsection Ring\nvariable [Ring k]\nvariable [AddCommGroup V] [Module k V] [AffineSpace V P]\nvariable [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁]\nvariable [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂]\n\n/-- The additive action on an affine subspace corresponding to applying the action to every element.\n\nThis is available as an instance in the `Pointwise` locale. -/\n@[instance_reducible]\nprotected def pointwiseVAdd : VAdd V (AffineSubspace k P) where\n vadd x s := s.map (AffineEquiv.constVAdd k P x)\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseVAdd\n\n@[simp, norm_cast] lemma coe_pointwise_vadd (v : V) (s : AffineSubspace k P) :\n ((v +ᵥ s : AffineSubspace k P) : Set P) = v +ᵥ (s : Set P) := rfl\n\n/-- The additive action on an affine subspace corresponding to applying the action to every element.\n\nThis is available as an instance in the `Pointwise` locale. -/\n@[instance_reducible]\nprotected def pointwiseAddAction : AddAction V (AffineSubspace k P) :=\n SetLike.coe_injective.addAction _ coe_pointwise_vadd\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseAddAction\n\ntheorem pointwise_vadd_eq_map (v : V) (s : AffineSubspace k P) :\n v +ᵥ s = s.map (AffineEquiv.constVAdd k P v) :=\n rfl\n\ntheorem vadd_mem_pointwise_vadd_iff {v : V} {s : AffineSubspace k P} {p : P} :\n v +ᵥ p ∈ v +ᵥ s ↔ p ∈ s :=\n vadd_mem_vadd_set_iff\n\n@[simp] theorem pointwise_vadd_bot (v : V) : v +ᵥ (⊥ : AffineSubspace k P) = ⊥ := by\n ext; simp [pointwise_vadd_eq_map, map_bot]\n\n@[simp] lemma pointwise_vadd_top (v : V) : v +ᵥ (⊤ : AffineSubspace k P) = ⊤ := by\n ext; simp [pointwise_vadd_eq_map, vadd_eq_iff_eq_neg_vadd]\n\ntheorem pointwise_vadd_direction (v : V) (s : AffineSubspace k P) :\n (v +ᵥ s).direction = s.direction := by\n rw [pointwise_vadd_eq_map, map_direction]\n exact Submodule.map_id _\n\ntheorem pointwise_vadd_span (v : V) (s : Set P) : v +ᵥ affineSpan k s = affineSpan k (v +ᵥ s) :=\n map_span _ s\n\ntheorem map_pointwise_vadd (f : P₁ →ᵃ[k] P₂) (v : V₁) (s : AffineSubspace k P₁) :\n (v +ᵥ s).map f = f.linear v +ᵥ s.map f := by\n rw [pointwise_vadd_eq_map, pointwise_vadd_eq_map, map_map, map_map]\n congr 1\n ext\n exact f.map_vadd _ _\n\nsection SMul\nvariable [DistribSMul M V] [SMulCommClass M k V] {a : M} {s : AffineSubspace k V}\n {p : V}\n\n/-- The multiplicative action on an affine subspace corresponding to applying the action to every\nelement.\n\nThis is available as an instance in the `Pointwise` locale.\n\nTODO: generalize to include `SMul (P ≃ᵃ[k] P) (AffineSubspace k P)`, which acts on `P` with a\n`VAdd` version of a `DistribMulAction`. -/\n@[instance_reducible]\nprotected def pointwiseSMul : SMul M (AffineSubspace k V) where\n smul a s := s.map (DistribSMul.toLinearMap k _ a).toAffineMap\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseSMul\n\n@[simp, norm_cast]\nlemma coe_smul (a : M) (s : AffineSubspace k V) : ↑(a • s) = a • (s : Set V) := rfl\n\nlemma smul_eq_map (a : M) (s : AffineSubspace k V) :\n a • s = s.map (DistribSMul.toLinearMap k _ a).toAffineMap := rfl\n\nlemma smul_mem_smul_iff {G : Type*} [Group G] [DistribMulAction G V] [SMulCommClass G k V] {a : G} :\n a • p ∈ a • s ↔ p ∈ s := smul_mem_smul_set_iff\n\n@[simp] lemma smul_bot (a : M) : a • (⊥ : AffineSubspace k V) = ⊥ := by\n ext; simp [smul_eq_map, map_bot]\n\nlemma smul_span (a : M) (s : Set V) : a • affineSpan k s = affineSpan k (a • s) := map_span _ s\n\nend SMul\n\nsection MulAction\nvariable [Monoid M] [DistribMulAction M V] [SMulCommClass M k V] {a : M} {s : AffineSubspace k V}\n {p : V}\n\n/-- The multiplicative action on an affine subspace corresponding to applying the action to every\nelement.\n\nThis is available as an instance in the `Pointwise` locale.\n\nTODO: generalize to include `SMul (P ≃ᵃ[k] P) (AffineSubspace k P)`, which acts on `P` with a\n`VAdd` version of a `DistribMulAction`. -/\n@[instance_reducible]\nprotected def mulAction : MulAction M (AffineSubspace k V) :=\n SetLike.coe_injective.mulAction _ coe_smul\n\nscoped[Pointwise] attribute [instance] AffineSubspace.mulAction\n\nlemma smul_mem_smul_iff_of_isUnit (ha : IsUnit a) : a • p ∈ a • s ↔ p ∈ s :=\n smul_mem_smul_iff (a := ha.unit)\n\nlemma smul_mem_smul_iff₀ {G₀ : Type*} [GroupWithZero G₀] [DistribMulAction G₀ V]\n [SMulCommClass G₀ k V] {a : G₀} (ha : a ≠ 0) : a • p ∈ a • s ↔ p ∈ s :=\n smul_mem_smul_iff_of_isUnit ha.isUnit\n\n@[simp] lemma smul_top (ha : IsUnit a) : a • (⊤ : AffineSubspace k V) = ⊤ := by\n ext x; simpa [smul_eq_map, map_top] using ⟨ha.unit⁻¹ • x, smul_inv_smul ha.unit _⟩\n\nend MulAction\n\nend Ring\n\nsection Field\nvariable [Field k] [AddCommGroup V] [Module k V] {a : k}\n\n@[simp]\n\nTarget:\nlemma direction_smul (ha : a ≠ 0) (s : AffineSubspace k V) : (a • s).direction = s.direction :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"cef61ae194256068e085fa7a2f4f4f29cdf32ef24bf3c830e89ff9b909ec4d7f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/AffineSpace","family_id":"direction_smul","file_id":"mathlib/Mathlib/LinearAlgebra/AffineSpace/Pointwise.lean","sample_id":"f22f80c1a43541829a9abfe45c501e2f08fb44de4c00bb183be36e65122cdf4f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8d2fa480514081d3b91e91ea88daea8af13410bf972221386a2911aeb59d5e6e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a7ffcfcb4216aa4deb42b85fd4d409513a4a8594c172a34b276ece4502a03a66","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"21f355198931c3293103244a9e0ebc3932f67eb05d14dfd941fa7c5e6f9f78c6","source_sha256":"a0c4f879a338ab6470bdd61aa6cb4790c1abee3840d61f2c802fcb6c81cb3ac9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro s\n refine ⟨?_, TensorProduct.includeLeftSubRight_zero_of_mem_range⟩\n intro hs\n use g s\n apply (TensorProduct.lid R S).symm.injective\n rw [TensorProduct.lid_symm_apply, TensorProduct.lid_symm_apply,\n ← mul_one ((Algebra.linearMap R S) _), Algebra.coe_linearMap, ← Algebra.smul_def,\n ← TensorProduct.smul_tmul, smul_eq_mul, mul_one, ← AlgHom.id_apply (R := R) (1 : S),\n ← TensorProduct.map_tmul,\n sub_eq_zero.mp ((TensorProduct.includeLeftSubRight_apply s).symm.trans hs),\n TensorProduct.map_tmul, map_one, AlgHom.id_apply]","hard_negative":true,"metrics":{"chosen_tokens":117,"rejected_tokens":2,"token_jaccard":0.021277,"token_length_ratio":0.017094},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"7be2a8b7cee8104c9bd58ed4ed1440fa666f7b25061a403d331ae541ee8495db","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Ring.Constructions\npublic import Mathlib.RingTheory.Flat.FaithfullyFlat.Algebra\n\nNamespace:\nAlgebra.IsEffective\n\nLocal context:\n/-\nCopyright (c) 2025 Yong-Gyu Choi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yong-Gyu Choi\n-/\n/-!\n# Exactness properties of the difference map on tensor products\n\nFor an `R`-algebra `S`, we collect some properties of the `R`-linear map `S →ₗ[R] S ⊗[R] S` given\nby `s ↦ s ⊗ₜ 1 - 1 ⊗ₜ s`.\n\n## Main definitions\n\n* `includeLeftSubRight`: The `R`-linear map sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`.\n* `IsEffective`: Exactness of the sequence `R → S → S ⊗[R] S` where the first map is\n `Algebra.linearMap R S` and the second map is `includeLeftSubRight`. When `R` and `S` are\n commutative rings, this is equivalent to the inclusion `im (algebraMap : R → S) → S` being an\n effective monomorphism in `CommRingCat`.\n\n## Main results\n\n* `IsEffective.of_faithfullyFlat`: `IsEffective R S` is true for any faithfully flat `R`-algebra `S`\n\n-/\n\n@[expose] public section\n\nopen scoped TensorProduct\n\nnamespace Algebra\n\nvariable {R : Type*} [CommSemiring R]\nvariable {S : Type*} [Ring S] [Algebra R S]\n\nnamespace TensorProduct\n\nsection IncludeLeftSubRight\n\nvariable (R S) in\n/-- The `R`-linear map `S →ₗ[R] S ⊗[R] S` sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`. -/\ndef includeLeftSubRight : S →ₗ[R] S ⊗[R] S :=\n includeLeft.toLinearMap - includeRight.toLinearMap\n\n@[simp]\nlemma includeLeftSubRight_apply (s : S) : includeLeftSubRight R S s = s ⊗ₜ[R] 1 - 1 ⊗ₜ[R] s :=\n rfl\n\n/-- `includeLeftSubRight R S` vanishes in the range of `algebraMap R S`. -/\nlemma includeLeftSubRight_zero_of_mem_range {s : S} (hs : s ∈ Set.range ⇑(algebraMap R S)) :\n includeLeftSubRight R S s = 0 := by\n obtain ⟨_, hr⟩ := Set.mem_range.mp hs\n simp [← hr, algebraMap_eq_smul_one]\n\n/-- `includeLeftSubRight R S` vanishes at `algebraMap R S r`. -/\nlemma includeLeftSubRight_algebraMap_zero (r : R) :\n includeLeftSubRight R S (algebraMap R S r) = 0 :=\n includeLeftSubRight_zero_of_mem_range (Set.mem_range.mp (exists_apply_eq_apply _ _))\n\n/-- `includeLeftSubRight` is compatible with `distribBaseChange` and `lTensor`. -/\nlemma distribBaseChange_comp_includeLeftSubRight (T : Type*) [CommRing T] [Algebra R T] :\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).restrictScalars R).toLinearMap ∘ₗ\n (includeLeftSubRight R S).lTensor T =\n (includeLeftSubRight T (T ⊗[R] S)).restrictScalars R := by\n ext\n simp [TensorProduct.tmul_sub, TensorProduct.one_def, tmul_one_tmul_one_tmul]\n\n@[simp]\nlemma distribBaseChange_includeLeftSubRight_apply (T : Type*) [CommRing T] [Algebra R T]\n (x : T ⊗[R] S) :\n TensorProduct.AlgebraTensorModule.distribBaseChange R T S S\n ((includeLeftSubRight R S).lTensor T x) =\n includeLeftSubRight T (T ⊗[R] S) x :=\n congr($(distribBaseChange_comp_includeLeftSubRight _) x)\n\nend IncludeLeftSubRight\n\nend TensorProduct\n\nvariable (R S) in\n/-- For an `R`-algebra `S`, this asserts that the maps `algebraMap : R → S` and\n`includeLeftSubRight R S : S → S ⊗[R] S` form an exact pair.\nWhen `R` and `S` are commutative rings, this is true if and only if the inclusion\n`im (algebraMap : R → S) → S` is an effective monomorphism in the category of commutative rings. -/\ndef IsEffective : Prop :=\n Function.Exact (Algebra.linearMap R S) (TensorProduct.includeLeftSubRight R S)\n\nnamespace IsEffective\n\n/-- If `IsEffective R S` is true, then the equalizer of `s ↦ s ⊗ₜ 1 : S →+* S ⊗[R] S` and\n`s ↦ 1 ⊗ₜ s : S →+* S ⊗[R] S` is the image of `algebraMap R S : R →+* S`. -/\nlemma eqLocus_includeLeft_includeRight (h : IsEffective R S) :\n TensorProduct.includeLeftRingHom.eqLocus TensorProduct.includeRight.toRingHom (S := S ⊗[R] S) =\n Set.range (algebraMap R S) := by\n ext s\n refine ⟨?_, fun ⟨_, hr⟩ ↦ by simp [← hr]⟩\n intro hs\n exact (h s).mp <| (TensorProduct.includeLeftSubRight_apply (R := R) s).symm ▸ sub_eq_zero.mpr hs\n\n/-- `IsEffective` is true for any `R`-algebra `S` having an `R`-algebra section of\n`Algebra.ofId _ _ : R →ₐ[R] S`. -/\n\nTarget:\nlemma of_section (g : S →ₐ[R] R) : IsEffective R S :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_21f355198931","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"29f07c9cf13e7d9c11459c00c517c827dee879ffa519338111321e77b4b67cea","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/TensorProduct","family_id":"of_section","file_id":"mathlib/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean","sample_id":"21f355198931c3293103244a9e0ebc3932f67eb05d14dfd941fa7c5e6f9f78c6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"18fa08cf6d80a8f5b43d1036f03329daf7943e5bd6d50fe11af9e19a0e41aa25","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7bf4bb97f899ca0caead7b59abc160b04832a4ec5bced7f71da0e351c8167adf","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7c33e64161ab0864bd6d70719c5e75272141a5097b243cdfc0a79459dd0943c9","source_sha256":"864bb4bb18dcd59ea0d99974e94e6f80f27ed7f81365f8520c597842fa036700","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [ker_comp, ker_mk'_eq]\n\n/-- Makes an isomorphism of quotients by two ring congruence\nrelations, given that the relations are equal. -/\nprotected def congr (h : c = d) :\n c.Quotient ≃+* d.Quotient :=\n { Quotient.congr (Equiv.refl M) <| by apply RingCon.ext_iff.mp h with\n map_add' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl\n map_mul' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl }","hard_negative":true,"metrics":{"chosen_tokens":109,"rejected_tokens":3,"token_jaccard":0.016129,"token_length_ratio":0.027523},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"7da8ed52175aa5ae032a1e7c7ce361105782f66223ef54acc28c52eee2fe82ac","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Subalgebra.Lattice\npublic import Mathlib.Algebra.Algebra.Subalgebra.Basic\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.RingTheory.Congruence.Basic\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.Algebra.Ring.Subring.Basic\npublic import Mathlib.Algebra.RingQuot\n\nNamespace:\nRingCon\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Congruence relations and ring homomorphisms\n\nThis file contains elementary definitions involving congruence\nrelations and morphisms for rings and semirings\n\n## Main definitions\n\n* `RingCon.ker`: the kernel of a monoid homomorphism as a congruence relation\n* `RingCon.lift`, `RingCon.liftₐ`: the homomorphism / the algebra morphism\n on the quotient given that the congruence is in the kernel\n* `RingCon.map`, `RingCon.mapₐ`: homomorphism / algebra morphism\n from a smaller to a larger quotient\n\n* `RingCon.quotientKerEquivRangeS`, `RingCon.quotientKerEquivRange`,\n `RingCon.quotientKerEquivRangeₐ` :\n the first isomorphism theorem for semirings (using `RingHom.rangeS`),\n rings (using `RingHom.range`) and algebras (using `AlgHom.range`).\n* `RingCon.comapQuotientEquivRangeS`, `RingCon.comapQuotientEquivRange`,\n `RingCon.comapQuotientEquivRangeₐ` : the second isomorphism theorem\n for semirings (using `RingHom.rangeS`), rings (using `RingHom.range`)\n and algebras (using `AlgHom.range`).\n\n* `RingCon.quotientQuotientEquivQuotient`, `RingCon.quotientQuotientEquivQuotientₐ` :\n the third isomorphism theorem for semirings (or rings) and algebras\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, ring,\nquotient ring\n-/\n\n@[expose] public section\n\nvariable {M : Type*} {N : Type*} {P : Type*}\n\nopen Function Setoid\n\nnamespace RingCon\n\nsection\n\nvariable [NonAssocSemiring M] [NonAssocSemiring N] [NonAssocSemiring P] {c d : RingCon M}\n\n/-- The kernel of a ring homomorphism as a ring congruence relation. -/\ndef ker (f : M →+* N) : RingCon M := comap ⊥ f\n\ntheorem comap_bot (f : M →+* N) : comap ⊥ f = ker f := rfl\n\n/-- The definition of the ring congruence relation defined by a ring homomorphism's kernel. -/\n@[simp]\ntheorem ker_apply (f : M →+* N) {x y} : ker f x y ↔ f x = f y :=\n Iff.rfl\n\n/-- The kernel of the quotient map induced by a ring congruence relation `c` equals `c`. -/\ntheorem ker_mk'_eq (c : RingCon M) : ker c.mk' = c :=\n ext fun _ _ => Quotient.eq''\n\ntheorem ker_comp {f : M →+* N} {g : N →+* P} :\n ker (g.comp f) = (ker g).comap f :=\n ext fun x y ↦ by simp [ker_apply, comap_rel]\n\nTarget:\ntheorem comap_eq {g : N →+* M} :\n c.comap g = ker (c.mk'.comp g) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_7c33e64161ab","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"45d17a76da29656e21b1dc691a38f0b1704f4a58b9cd2e519d966663f457104c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Congruence","family_id":"comap_eq","file_id":"mathlib/Mathlib/RingTheory/Congruence/Hom.lean","sample_id":"7c33e64161ab0864bd6d70719c5e75272141a5097b243cdfc0a79459dd0943c9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2f76c51c32719c58f7a246aeb323456f8c04db74bb33152ed213568652545d30","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"013d95430e408261d11725749ed9aa9e9841193495abbf4b162833542e0a3f59","source_sha256":"b74e0d0a25eea38e205e7058febbec527fe2a67d460dce70d42dabde5febca9c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n dsimp [double]\n rw [if_neg h₀, if_neg h₁]\n exact Limits.isZero_zero C\n\n/-- The isomorphism `(double f hi₀₁).X i₀ ≅ X₀`. -/\nnoncomputable def doubleXIso₀ : (double f hi₀₁).X i₀ ≅ X₀ :=\n eqToIso (dif_pos rfl)\n\n/-- The isomorphism `(double f hi₀₁).X i₁ ≅ X₁`. -/\nnoncomputable def doubleXIso₁ (h : i₀ ≠ i₁) : (double f hi₀₁).X i₁ ≅ X₁ :=\n eqToIso (by\n dsimp [double]\n rw [if_neg h.symm, if_pos rfl])","hard_negative":false,"metrics":{"chosen_tokens":140,"rejected_tokens":2,"token_jaccard":0.025,"token_length_ratio":0.014286},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"7dd05513380c4c3ef85f6b11dce8c79593f965f44808f21e4f34f21c82513b00","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.HasNoLoop\npublic import Mathlib.Algebra.Homology.Single\npublic import Mathlib.CategoryTheory.Yoneda\n\nNamespace:\nHomologicalComplex\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# A homological complex lying in two degrees\n\nGiven `c : ComplexShape ι`, distinct indices `i₀` and `i₁` such that `hi₀₁ : c.Rel i₀ i₁`,\nwe construct a homological complex `double f hi₀₁` for any morphism `f : X₀ ⟶ X₁`.\nIt consists of the objects `X₀` and `X₁` in degrees `i₀` and `i₁`, respectively,\nwith the differential `X₀ ⟶ X₁` given by `f`, and zero everywhere else.\n\n-/\n\n@[expose] public section\n\nopen CategoryTheory Category Limits ZeroObject Opposite\n\nnamespace HomologicalComplex\n\nvariable {C : Type*} [Category* C] [HasZeroMorphisms C] [HasZeroObject C]\n\nsection\n\nvariable {X₀ X₁ : C} (f : X₀ ⟶ X₁) {ι : Type*} {c : ComplexShape ι}\n {i₀ i₁ : ι} (hi₀₁ : c.Rel i₀ i₁)\n\nopen Classical in\n/-- Given a complex shape `c`, two indices `i₀` and `i₁` such that `c.Rel i₀ i₁`,\nand `f : X₀ ⟶ X₁`, this is the homological complex which, if `i₀ ≠ i₁`, only\nconsists of the map `f` in degrees `i₀` and `i₁`, and zero everywhere else. -/\nnoncomputable def double : HomologicalComplex C c where\n X k := if k = i₀ then X₀ else if k = i₁ then X₁ else 0\n d k k' :=\n if hk : k = i₀ ∧ k' = i₁ ∧ i₀ ≠ i₁ then\n eqToHom (if_pos hk.1) ≫ f ≫ eqToHom (by\n rw [if_neg, if_pos hk.2.1]\n aesop)\n else 0\n d_comp_d' := by\n rintro i j k hij hjk\n dsimp\n by_cases hi : i = i₀\n · subst hi\n by_cases hj : j = i₁\n · subst hj\n nth_rw 2 [dif_neg (by tauto)]\n rw [comp_zero]\n · rw [dif_neg (by tauto), zero_comp]\n · rw [dif_neg (by tauto), zero_comp]\n shape i j hij := dif_neg (by aesop)\n\nTarget:\nlemma isZero_double_X (k : ι) (h₀ : k ≠ i₀) (h₁ : k ≠ i₁) :\n IsZero ((double f hi₀₁).X k) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Homology","family_id":"iszero_double_x","file_id":"mathlib/Mathlib/Algebra/Homology/Double.lean","sample_id":"013d95430e408261d11725749ed9aa9e9841193495abbf4b162833542e0a3f59"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d7573e98ab467c9ebb0ea890ea601c33d6bf0baa129280ebf592e621a6c225ee","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9ea93b54d8505342da443bbb443c4e5aa5867d5df9eb08140d284ce935be815b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c5cad4216866365ae0ea54d13266b73c5ad56f1d75ce0919d93719df0fd07b38","source_sha256":"1772ebc6d5f489fb8a42b880ceafc783ce77133acd1e06ebadf2800bb4211ccd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · intro _ φ\n have sq : CommSq φ.left i p φ.right := CommSq.mk φ.w\n exact ⟨{ l := sq.lift }⟩\n · intro h\n exact ⟨fun {f g} sq ↦ ⟨h (Arrow.homMk f g sq.w)⟩⟩","hard_negative":true,"metrics":{"chosen_tokens":61,"rejected_tokens":3,"token_jaccard":0.057143,"token_length_ratio":0.04918},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"7ef851c6fe375095d3552d46edbd843d6552c71476f68a866b73b48791a11c27","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.CommSq\npublic import Mathlib.CategoryTheory.Retract\n\nNamespace:\nCategoryTheory.Arrow\n\nLocal context:\n/-\nCopyright (c) 2021 Jakob Scholbach. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob Scholbach, Joël Riou\n-/\n/-!\n# Lifting properties\n\nThis file defines the lifting property of two morphisms in a category and\nshows basic properties of this notion.\n\n## Main results\n- `HasLiftingProperty`: the definition of the lifting property\n\n## Tags\nlifting property\n\n## TODO\n1) direct/inverse images, adjunctions\n\n-/\n\n@[expose] public section\n\nuniverse v\n\nnamespace CategoryTheory\n\nopen Category\n\nvariable {C : Type*} [Category* C] {A B B' X Y Y' : C} (i : A ⟶ B) (i' : B ⟶ B') (p : X ⟶ Y)\n (p' : Y ⟶ Y')\n\n/-- `HasLiftingProperty i p` means that `i` has the left lifting\nproperty with respect to `p`, or equivalently that `p` has\nthe right lifting property with respect to `i`. -/\n@[to_dual self (reorder := A Y, B X, i p)]\nclass HasLiftingProperty : Prop where\n /-- Unique field expressing that any commutative square built from `f` and `g` has a lift -/\n sq_hasLift : ∀ {f : A ⟶ X} {g : B ⟶ Y} (sq : CommSq f i p g), sq.HasLift\n\nattribute [to_dual self] HasLiftingProperty.sq_hasLift\nattribute [to_dual self (reorder := A Y, B X, i p, sq_hasLift (f g))] HasLiftingProperty.mk\n\n@[to_dual self]\ninstance (priority := 100) sq_hasLift_of_hasLiftingProperty {f : A ⟶ X} {g : B ⟶ Y}\n (sq : CommSq f i p g) [hip : HasLiftingProperty i p] : sq.HasLift := hip.sq_hasLift _\n\nnamespace HasLiftingProperty\n\nvariable {i p}\n\n@[to_dual self]\ntheorem op (h : HasLiftingProperty i p) : HasLiftingProperty p.op i.op :=\n ⟨fun {f} {g} sq => by\n simp only [CommSq.HasLift.iff_unop, Quiver.Hom.unop_op]\n infer_instance⟩\n\n@[to_dual self]\ntheorem unop {A B X Y : Cᵒᵖ} {i : A ⟶ B} {p : X ⟶ Y} (h : HasLiftingProperty i p) :\n HasLiftingProperty p.unop i.unop :=\n ⟨fun {f} {g} sq => by\n rw [CommSq.HasLift.iff_op]\n simp only [Quiver.Hom.op_unop]\n infer_instance⟩\n\n@[to_dual self]\ntheorem iff_op : HasLiftingProperty i p ↔ HasLiftingProperty p.op i.op :=\n ⟨op, unop⟩\n\n@[to_dual self]\ntheorem iff_unop {A B X Y : Cᵒᵖ} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty p.unop i.unop :=\n ⟨unop, op⟩\n\nvariable (i p)\n\n@[to_dual of_right_iso]\ninstance (priority := 100) of_left_iso [IsIso i] : HasLiftingProperty i p :=\n ⟨fun {f} {g} sq =>\n CommSq.HasLift.mk'\n { l := inv i ≫ f\n fac_left := by simp only [IsIso.hom_inv_id_assoc]\n fac_right := by simp only [sq.w, assoc, IsIso.inv_hom_id_assoc] }⟩\n\n@[to_dual of_comp_right]\ninstance of_comp_left [HasLiftingProperty i p] [HasLiftingProperty i' p] :\n HasLiftingProperty (i ≫ i') p :=\n ⟨fun {f} {g} sq => by\n have fac := sq.w\n rw [assoc] at fac\n exact\n CommSq.HasLift.mk'\n { l := (CommSq.mk (CommSq.mk fac).fac_right).lift\n fac_left := by simp only [assoc, CommSq.fac_left]\n fac_right := by simp only [CommSq.fac_right] }⟩\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) [hip : HasLiftingProperty i p] :\n HasLiftingProperty i' p := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') [hip : HasLiftingProperty i p] : HasLiftingProperty i p' := by\n rw [Arrow.iso_w' e]\n infer_instance\n\ntheorem iff_of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty i' p := by\n constructor <;> intro\n exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]\n\ntheorem iff_of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') : HasLiftingProperty i p ↔ HasLiftingProperty i p' := by\n constructor <;> intro\n exacts [of_arrow_iso_right i e, of_arrow_iso_right i e.symm]\n\nend HasLiftingProperty\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma RetractArrow.leftLiftingProperty\n {X Y Z W Z' W' : C} {g : Z ⟶ W} {g' : Z' ⟶ W'}\n (h : RetractArrow g' g) (f : X ⟶ Y) [HasLiftingProperty g f] : HasLiftingProperty g' f where\n sq_hasLift := fun {u v} sq ↦ by\n have sq' : CommSq (h.r.left ≫ u) g f (h.r.right ≫ v) := by simp only [Arrow.mk_left,\n Arrow.mk_right, Category.assoc, sq.w, Arrow.w_mk_right_assoc, Arrow.mk_hom, CommSq.mk]\n exact\n ⟨⟨{ l := h.i.right ≫ sq'.lift\n fac_left := by\n simp only [← h.i_w_assoc, sq'.fac_left, h.retract_left_assoc,\n Arrow.mk_left, Category.id_comp]}⟩⟩\n\nset_option backward.isDefEq.respectTransparency false in\nlemma RetractArrow.rightLiftingProperty\n {X Y Z W X' Y' : C} {f : X ⟶ Y} {f' : X' ⟶ Y'}\n (h : RetractArrow f' f) (g : Z ⟶ W) [HasLiftingProperty g f] : HasLiftingProperty g f' where\n sq_hasLift := fun {u v} sq ↦\n have sq' : CommSq (u ≫ h.i.left) g f (v ≫ h.i.right) :=\n ⟨by rw [← Category.assoc, ← sq.w, Category.assoc, RetractArrow.i_w, Category.assoc]⟩\n ⟨⟨{ l := sq'.lift ≫ h.r.left}⟩⟩\n\nnamespace Arrow\n\n/-- Given a morphism `φ : f ⟶ g` in the category `Arrow C`, this is an\nabbreviation for the `CommSq.LiftStruct` structure for\nthe square corresponding to `φ`. -/\nabbrev LiftStruct {f g : Arrow C} (φ : f ⟶ g) := (CommSq.mk φ.w).LiftStruct\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma hasLiftingProperty_iff {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔\n ∀ (φ : Arrow.mk i ⟶ Arrow.mk p), Nonempty (LiftStruct φ) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_c5cad4216866","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"45fcb56485110796f7f42ad7c48fd30e51c96688029a2f89378f5423800da60f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/LiftingProperties","family_id":"hasliftingproperty_iff","file_id":"mathlib/Mathlib/CategoryTheory/LiftingProperties/Basic.lean","sample_id":"c5cad4216866365ae0ea54d13266b73c5ad56f1d75ce0919d93719df0fd07b38"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f4a938cf920b10ddd5b681c22011be436be65cbfda87e6aa9698f6088fa7837","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5202372db7ffcf9b53a940dee95fc9ef0766aab29a03bc1a6a3fb06c4b208171","source_sha256":"d13991b9cfa5aed210efd9dfa59ee78d50d7a73c6e7dcb74ea09b33b3785b547","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have h' : Cospherical ({a, c, b, d} : Set P) := by rwa [Set.insert_comm c b {d}]\n have hmul := mul_dist_eq_mul_dist_of_cospherical_of_angle_eq_pi h' hapc hbpd\n have hbp := left_dist_ne_zero_of_angle_eq_pi hbpd\n have h₁ : dist c d = dist c p / dist b p * dist a b := by\n rw [dist_mul_of_eq_angle_of_dist_mul b p a c p d, dist_comm a b]\n · rw [angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi hbpd hapc, angle_comm]\n all_goals simp [field, mul_comm, hmul]\n have h₂ : dist d a = dist a p / dist b p * dist b c := by\n rw [dist_mul_of_eq_angle_of_dist_mul c p b d p a, dist_comm c b]\n · rwa [angle_comm, angle_eq_angle_of_angle_eq_pi_of_angle_eq_pi]; rwa [angle_comm]\n all_goals simp [field, mul_comm, hmul]\n have h₃ : dist d p = dist a p * dist c p / dist b p := by simp [field, hmul]\n have h₄ : ∀ x y : ℝ, x * (y * x) = x * x * y := fun x y => by rw [mul_left_comm, mul_comm]\n simp [field, h₁, h₂, dist_eq_add_dist_of_angle_eq_pi hbpd, h₃, dist_comm a b, h₄, ← sq,\n dist_sq_mul_dist_add_dist_sq_mul_dist b, hapc]","hard_negative":false,"metrics":{"chosen_tokens":246,"rejected_tokens":5,"token_jaccard":0.015625,"token_length_ratio":0.020325},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"7f115bc7e00eb86556e90d40700efbe7f2ceb22336f268077ca62e3f1a8ecf27","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Euclidean.Sphere.Power\npublic import Mathlib.Geometry.Euclidean.Triangle\n\nNamespace:\nEuclideanGeometry\n\nLocal context:\n/-\nCopyright (c) 2021 Manuel Candales. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Manuel Candales, Benjamin Davidson\n-/\n/-!\n# Ptolemy's theorem\n\nThis file proves Ptolemy's theorem on the lengths of the diagonals and sides of a cyclic\nquadrilateral.\n\n## Main theorems\n\n* `mul_dist_add_mul_dist_eq_mul_dist_of_cospherical`: Ptolemy’s Theorem (Freek No. 95).\n\nTODO: The current statement of Ptolemy’s theorem works around the lack of a \"cyclic polygon\" concept\nin mathlib, which is what the theorem statement would naturally use (or two such concepts, since\nboth a strict version, where all vertices must be distinct, and a weak version, where consecutive\nvertices may be equal, would be useful; Ptolemy's theorem should then use the weak one).\n\nAn API needs to be built around that concept, which would include:\n- strict cyclic implies weak cyclic,\n- weak cyclic and consecutive points distinct implies strict cyclic,\n- weak/strict cyclic implies weak/strict cyclic for any subsequence,\n- any three points on a sphere are weakly or strictly cyclic according to whether they are distinct,\n- any number of points on a sphere intersected with a two-dimensional affine subspace are cyclic in\n some order,\n- a list of points is cyclic if and only if its reversal is,\n- a list of points is cyclic if and only if any cyclic permutation is, while other permutations\n are not when the points are distinct,\n- a point P where the diagonals of a cyclic polygon cross exists (and is unique) with weak/strict\n betweenness depending on weak/strict cyclicity,\n- four points on a sphere with such a point P are cyclic in the appropriate order,\n\nand so on.\n-/\n\npublic section\n\n\nopen Real\n\nopen scoped EuclideanGeometry RealInnerProductSpace Real\n\nnamespace EuclideanGeometry\n\nvariable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]\nvariable {P : Type*} [MetricSpace P] [NormedAddTorsor V P]\n\n/-- **Ptolemy’s Theorem**. -/\n\nTarget:\ntheorem mul_dist_add_mul_dist_eq_mul_dist_of_cospherical {a b c d p : P}\n (h : Cospherical ({a, b, c, d} : Set P)) (hapc : ∠ a p c = π) (hbpd : ∠ b p d = π) :\n dist a b * dist c d + dist b c * dist d a = dist a c * dist b d :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Euclidean","family_id":"mul_dist_add_mul_dist_eq_mul_dist_of_cospherical","file_id":"mathlib/Mathlib/Geometry/Euclidean/Sphere/Ptolemy.lean","sample_id":"5202372db7ffcf9b53a940dee95fc9ef0766aab29a03bc1a6a3fb06c4b208171"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ac855ef276ae2a2d20fcf02e7c20e07022ee4408c628a7a068780f5b01fcb1a3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fe1dd28514b96f2a1a54b0b87f4a1a6bdd1b7f235e1e6557ebd362eedb4330b7","source_sha256":"c8a33bb8cce3962f230d95a94382ba6537d37e619b16dfe9b8c1fe283237e032","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [iInf, coe_sInf, Set.biInter_range]","hard_negative":false,"metrics":{"chosen_tokens":12,"rejected_tokens":5,"token_jaccard":0.066667,"token_length_ratio":0.416667},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"7fdd2df23ff8b348a418f75514569bdd55cc9c296dd91dce4efaa1f73a001f4c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.GroupTheory.Subsemigroup.Center\npublic import Mathlib.RingTheory.NonUnitalSubring.Defs\npublic import Mathlib.RingTheory.NonUnitalSubsemiring.Basic\n\nNamespace:\nNonUnitalSubring\n\nLocal context:\n/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n/-!\n# `NonUnitalSubring`s\n\nLet `R` be a non-unital ring.\nWe prove that non-unital subrings 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 `NonUnitalSubring R`, sending a subset of\n`R` to the non-unital subring it generates, and prove that it is a Galois insertion.\n\n## Main definitions\n\nNotation used here:\n\n`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`\n`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`\n\n* `instance : CompleteLattice (NonUnitalSubring R)` : the complete lattice structure on the\n non-unital subrings.\n\n* `NonUnitalSubring.center` : the center of a non-unital ring `R`.\n\n* `NonUnitalSubring.closure` : non-unital subring closure of a set, i.e., the smallest\n non-unital subring that includes the set.\n\n* `NonUnitalSubring.gi` : `closure : Set M → NonUnitalSubring M` and coercion\n `coe : NonUnitalSubring M → Set M`\n form a `GaloisInsertion`.\n\n* `comap f B : NonUnitalSubring A` : the preimage of a non-unital subring `B` along the\n non-unital ring homomorphism `f`\n\n* `map f A : NonUnitalSubring B` : the image of a non-unital subring `A` along the\n non-unital ring homomorphism `f`.\n\n* `Prod A B : NonUnitalSubring (R × S)` : the product of non-unital subrings\n\n* `f.range : NonUnitalSubring B` : the range of the non-unital ring homomorphism `f`.\n\n* `eq_locus f g : NonUnitalSubring R` : given non-unital ring homomorphisms `f g : R →ₙ+* S`,\n the non-unital subring of `R` where `f x = g x`\n\n## Implementation notes\n\nA non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an\nadditive subgroup.\n\nLattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although\n`∈` is defined as membership of a non-unital subring's underlying set.\n\n## Tags\nnon-unital subring\n-/\n\n@[expose] public section\n\n\nuniverse u v w\n\nsection Basic\n\nvariable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]\n\nnamespace NonUnitalSubring\n\nvariable (s : NonUnitalSubring R)\n\n/-- Sum of a list of elements in a non-unital subring is in the non-unital subring. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=\n list_sum_mem\n\n/-- Sum of a multiset of elements in a `NonUnitalSubring` of a `NonUnitalRing` is\nin the `NonUnitalSubring`. -/\nprotected theorem multiset_sum_mem {R} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=\n multiset_sum_mem _\n\n/-- Sum of elements in a `NonUnitalSubring` of a `NonUnitalRing` indexed by a `Finset`\nis in the `NonUnitalSubring`. -/\nprotected theorem sum_mem {R : Type*} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n {ι : Type*} {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∑ i ∈ t, f i) ∈ s :=\n sum_mem h\n\n/-! ## top -/\n\n\n/-- The non-unital subring `R` of the ring `R`. -/\ninstance : Top (NonUnitalSubring R) :=\n ⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubgroup R) with }⟩\n\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubring R) :=\n Set.mem_univ x\n\n@[simp]\ntheorem coe_top : ((⊤ : NonUnitalSubring R) : Set R) = Set.univ :=\n rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_top : (⊤ : NonUnitalSubring R).toNonUnitalSubsemiring = ⊤ := rfl\n\n@[simp] lemma toAddSubgroup_top : (⊤ : NonUnitalSubring R).toAddSubgroup = ⊤ := rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_eq_top {S : NonUnitalSubring R} :\n S.toNonUnitalSubsemiring = ⊤ ↔ S = ⊤ := by simp [← SetLike.coe_set_eq]\n\n@[simp] lemma toAddSubgroup_eq_top {S : NonUnitalSubring R} : S.toAddSubgroup = ⊤ ↔ S = ⊤ := by\n simp [← SetLike.coe_set_eq]\n\n/-- The ring equiv between the top element of `NonUnitalSubring R` and `R`. -/\n@[simps!]\ndef topEquiv : (⊤ : NonUnitalSubring R) ≃+* R := NonUnitalSubsemiring.topEquiv\n\nend NonUnitalSubring\n\nend Basic\n\nsection Hom\n\nnamespace NonUnitalSubring\n\nvariable {F : Type w} {R : Type u} {S : Type v} {T : Type*}\n [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (s : NonUnitalSubring R)\n\n/-! ## comap -/\n\n\n/-- The preimage of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/\ndef comap {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring S) :\n NonUnitalSubring R :=\n { s.toSubsemigroup.comap (f : R →ₙ* S), s.toAddSubgroup.comap (f : R →+ S) with\n carrier := f ⁻¹' s.carrier }\n\n@[simp]\ntheorem coe_comap (s : NonUnitalSubring S) (f : F) : (s.comap f : Set R) = f ⁻¹' s :=\n rfl\n\n@[simp]\ntheorem mem_comap {s : NonUnitalSubring S} {f : F} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=\n Iff.rfl\n\ntheorem comap_comap (s : NonUnitalSubring T) (g : S →ₙ+* T) (f : R →ₙ+* S) :\n (s.comap g).comap f = s.comap (g.comp f) :=\n rfl\n\n/-! ## map -/\n\n/-- The image of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/\ndef map {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring R) :\n NonUnitalSubring S :=\n { s.toSubsemigroup.map (f : R →ₙ* S), s.toAddSubgroup.map (f : R →+ S) with\n carrier := f '' s.carrier }\n\n@[simp]\ntheorem coe_map (f : F) (s : NonUnitalSubring R) : (s.map f : Set S) = f '' s :=\n rfl\n\n@[simp]\ntheorem mem_map {f : F} {s : NonUnitalSubring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=\n Set.mem_image _ _ _\n\n@[simp]\ntheorem map_id : s.map (NonUnitalRingHom.id R) = s :=\n SetLike.coe_injective <| Set.image_id _\n\ntheorem map_map (g : S →ₙ+* T) (f : R →ₙ+* S) : (s.map f).map g = s.map (g.comp f) :=\n SetLike.coe_injective <| Set.image_image _ _ _\n\ntheorem map_le_iff_le_comap {f : F} {s : NonUnitalSubring R} {t : NonUnitalSubring S} :\n s.map f ≤ t ↔ s ≤ t.comap f :=\n Set.image_subset_iff\n\ntheorem gc_map_comap (f : F) :\n GaloisConnection (map f : NonUnitalSubring R → NonUnitalSubring S) (comap f) := fun _S _T =>\n map_le_iff_le_comap\n\n/-- A `NonUnitalSubring` is isomorphic to its image under an injective function -/\nnoncomputable def equivMapOfInjective (f : F) (hf : Function.Injective (f : R → S)) :\n s ≃+* s.map f :=\n {\n Equiv.Set.image f s\n hf with\n map_mul' := fun _ _ => Subtype.ext (map_mul f _ _)\n map_add' := fun _ _ => Subtype.ext (map_add f _ _) }\n\n@[simp]\ntheorem coe_equivMapOfInjective_apply (f : F) (hf : Function.Injective f) (x : s) :\n (equivMapOfInjective s f hf x : S) = f x :=\n rfl\n\nend NonUnitalSubring\n\nnamespace NonUnitalRingHom\n\nvariable {R : Type u} {S : Type v} {T : Type*}\n [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]\n (g : S →ₙ+* T) (f : R →ₙ+* S)\n\n/-! ## range -/\n\n/-- The range of a ring homomorphism, as a `NonUnitalSubring` of the target.\nSee Note [range copy pattern]. -/\ndef range {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n (f : R →ₙ+* S) : NonUnitalSubring S :=\n ((⊤ : NonUnitalSubring R).map f).copy (Set.range f) Set.image_univ.symm\n\n@[simp]\ntheorem coe_range : (f.range : Set S) = Set.range f :=\n rfl\n\n@[simp]\ntheorem mem_range {f : R →ₙ+* S} {y : S} : y ∈ f.range ↔ ∃ x, f x = y :=\n Iff.rfl\n\ntheorem range_eq_map (f : R →ₙ+* S) : f.range = NonUnitalSubring.map f ⊤ := by ext; simp\n\ntheorem mem_range_self (f : R →ₙ+* S) (x : R) : f x ∈ f.range :=\n mem_range.mpr ⟨x, rfl⟩\n\ntheorem map_range : f.range.map g = (g.comp f).range := by\n simpa only [range_eq_map] using (⊤ : NonUnitalSubring R).map_map g f\n\n/-- The range of a ring homomorphism 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 fintypeRange [Fintype R] [DecidableEq S] (f : R →ₙ+* S) : Fintype (range f) :=\n Set.fintypeRange f\n\nend NonUnitalRingHom\n\nnamespace NonUnitalSubring\n\nsection Order\n\nvariable {R : Type u} [NonUnitalNonAssocRing R]\n\n/-! ## bot -/\n\n\ninstance : Bot (NonUnitalSubring R) :=\n ⟨(0 : R →ₙ+* R).range⟩\n\ninstance : Inhabited (NonUnitalSubring R) :=\n ⟨⊥⟩\n\ntheorem coe_bot : ((⊥ : NonUnitalSubring R) : Set R) = {0} :=\n (NonUnitalRingHom.coe_range (0 : R →ₙ+* R)).trans (@Set.range_const R R _ 0)\n\ntheorem mem_bot {x : R} : x ∈ (⊥ : NonUnitalSubring R) ↔ x = 0 :=\n show x ∈ ((⊥ : NonUnitalSubring R) : Set R) ↔ x = 0 by rw [coe_bot, Set.mem_singleton_iff]\n\n/-! ## inf -/\n\n/-- The inf of two `NonUnitalSubring`s is their intersection. -/\ninstance : Min (NonUnitalSubring R) :=\n ⟨fun s t =>\n { s.toSubsemigroup ⊓ t.toSubsemigroup, s.toAddSubgroup ⊓ t.toAddSubgroup with\n carrier := s ∩ t }⟩\n\n@[simp]\ntheorem coe_inf (p p' : NonUnitalSubring R) :\n ((p ⊓ p' : NonUnitalSubring R) : Set R) = (p : Set R) ∩ p' :=\n rfl\n\n@[simp]\ntheorem mem_inf {p p' : NonUnitalSubring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n Iff.rfl\n\ninstance : InfSet (NonUnitalSubring R) :=\n ⟨fun s =>\n NonUnitalSubring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, NonUnitalSubring.toSubsemigroup t)\n (⨅ t ∈ s, NonUnitalSubring.toAddSubgroup t) (by simp) (by simp)⟩\n\n@[simp, norm_cast]\ntheorem coe_sInf (S : Set (NonUnitalSubring R)) :\n ((sInf S : NonUnitalSubring R) : Set R) = ⋂ s ∈ S, ↑s :=\n rfl\n\n@[simp]\ntheorem mem_sInf {S : Set (NonUnitalSubring R)} {x : R} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=\n Set.mem_iInter₂\n\n@[simp, norm_cast]\n\nTarget:\ntheorem coe_iInf {ι : Sort*} {S : ι → NonUnitalSubring R} : (↑(⨅ i, S i) : Set R) = ⋂ i, S i :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/NonUnitalSubring","family_id":"coe_iinf","file_id":"mathlib/Mathlib/RingTheory/NonUnitalSubring/Basic.lean","sample_id":"fe1dd28514b96f2a1a54b0b87f4a1a6bdd1b7f235e1e6557ebd362eedb4330b7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"cb5f18aeb2545cfc76615042fd99b583010c639a411dd9dcf4f2ac7ec217bf46","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"af90891060c5b030be0e66f95d300af7b6d41f4eb2f21042f429abe316422ed9","source_sha256":"ab3a4ef1b8c38b799b25430e9a4ec638aa3aad5e1f7012ae3a71c9c1d9c7668c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨n, m, hn, hm, ⟨iso1⟩⟩ := hAB\n obtain ⟨p, q, hp, hq, ⟨iso2⟩⟩ := hBC\n exact ⟨p * n, m * q, by simp_all, by simp_all,\n ⟨reindexAlgEquiv _ _ finProdFinEquiv |>.symm.trans <| compAlgEquiv _ _ _ _|>.symm.trans <|\n iso1.mapMatrix (m := Fin p)|>.trans <| compAlgEquiv _ _ _ _|>.trans <|\n reindexAlgEquiv K B (.prodComm (Fin p) (Fin m))|>.trans <| compAlgEquiv _ _ _ _|>.symm.trans <|\n iso2.mapMatrix.trans <| compAlgEquiv _ _ _ _|>.trans <| reindexAlgEquiv _ _ finProdFinEquiv⟩⟩","hard_negative":false,"metrics":{"chosen_tokens":159,"rejected_tokens":2,"token_jaccard":0.025641,"token_length_ratio":0.012579},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"7ff02dedc16b203747a4eaee5c4ccc5fddd6739fc897b72f637fcf98c18d564b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.AlgCat.Basic\npublic import Mathlib.Algebra.Central.Defs\npublic import Mathlib.LinearAlgebra.FiniteDimensional.Defs\npublic import Mathlib.LinearAlgebra.Matrix.Reindex\n\nNamespace:\nIsBrauerEquivalent\n\nLocal context:\n/-\nCopyright (c) 2025 Yunzhou Xie. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yunzhou Xie, Jujian Zhang\n-/\n/-!\n# Definition of Brauer group of a field K\n\nWe introduce the definition of Brauer group of a field K, which is the quotient of the set of\nall finite-dimensional central simple algebras over K modulo the Brauer Equivalence where two\ncentral simple algebras `A` and `B` are Brauer Equivalent if there exist `n, m ∈ ℕ+` such\nthat `Mₙ(A) ≃ₐ[K] Mₘ(B)`.\n\n## TODOs\n1. Prove that the Brauer group is an abelian group where multiplication is defined as tensor\n product.\n2. Prove that the Brauer group is a functor from the category of fields to the category of groups.\n3. Prove that over a field, being Brauer equivalent is the same as being Morita equivalent.\n\n## References\n* [Algebraic Number Theory, *J.W.S Cassels*][cassels1967algebraic]\n\n## Tags\nBrauer group, Central simple algebra, Galois Cohomology\n-/\n\n@[expose] public section\n\nuniverse u v\n\n/-- `CSA` is the set of all finite-dimensional central simple algebras over a field `K`. For the\ngeneralization to a `CommRing`, see `IsAzumaya` in `Mathlib/Algebra/Azumaya/Defs.lean`. -/\nstructure CSA (K : Type u) [Field K] extends AlgCat.{v} K where\n /-- Any member of `CSA` is central. -/\n [isCentral : Algebra.IsCentral K carrier]\n /-- Any member of `CSA` is simple. -/\n [isSimple : IsSimpleRing carrier]\n /-- Any member of `CSA` is finite-dimensional. -/\n [fin_dim : FiniteDimensional K carrier]\n\nvariable {K : Type u} [Field K]\n\ninstance : CoeSort (CSA.{u, v} K) (Type v) := ⟨(·.carrier)⟩\n\nattribute [instance] CSA.isCentral CSA.isSimple CSA.fin_dim\n\n/-- Two finite-dimensional central simple algebras `A` and `B` are Brauer equivalent\n if there exist `n, m ∈ ℕ+` such that `Mₙ(A) ≃ₐ[K] Mₘ(B)`. -/\nabbrev IsBrauerEquivalent (A B : CSA K) : Prop :=\n ∃ n m : ℕ, n ≠ 0 ∧ m ≠ 0 ∧ (Nonempty <| Matrix (Fin n) (Fin n) A ≃ₐ[K] Matrix (Fin m) (Fin m) B)\n\nnamespace IsBrauerEquivalent\n\n@[refl]\nlemma refl (A : CSA K) : IsBrauerEquivalent A A :=\n ⟨1, 1, one_ne_zero, one_ne_zero, ⟨AlgEquiv.refl⟩⟩\n\n@[symm]\nlemma symm {A B : CSA K} (h : IsBrauerEquivalent A B) : IsBrauerEquivalent B A :=\n let ⟨n, m, hn, hm, ⟨iso⟩⟩ := h\n ⟨m, n, hm, hn, ⟨iso.symm⟩⟩\n\nopen Matrix in\n@[trans]\n\nTarget:\nlemma trans {A B C : CSA K} (hAB : IsBrauerEquivalent A B) (hBC : IsBrauerEquivalent B C) :\n IsBrauerEquivalent A C :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/BrauerGroup","family_id":"trans","file_id":"mathlib/Mathlib/Algebra/BrauerGroup/Defs.lean","sample_id":"af90891060c5b030be0e66f95d300af7b6d41f4eb2f21042f429abe316422ed9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0712e7ba31f5be3678ad860748a6234697b82f97702f63a9123ea1ce7911c0a7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"92104f844e0602b98421a3efbc5f809737d878c58525acfb55afdc0def92d600","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"528d779653be05f79b9d414c3bb7c0bd1efd3ac27077a9fe80d90b8423ce89c9","source_sha256":"01e2a9c85e681d1f70c567cdf153d1062a74083def837924a42e92331cebc99b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro h\n simp only [LinearMap.lcomp_apply', Set.mem_range]\n refine ⟨fun hh ↦ ?_, fun ⟨y, hy⟩ ↦ ?_⟩\n · use ((LinearMap.range f).liftQ h (LinearMap.range_le_ker_iff.mpr hh)).comp\n (exac.linearEquivOfSurjective surj).symm.toLinearMap\n ext x\n simp\n · rw [← hy, LinearMap.comp_assoc, exac.linearMap_comp_eq_zero, LinearMap.comp_zero y]","hard_negative":true,"metrics":{"chosen_tokens":87,"rejected_tokens":3,"token_jaccard":0.021277,"token_length_ratio":0.034483},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"80744b3506903545937ccb3da561af54a7a5bff1b610a2d6f545e0fbf9e4b4cc","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Exact.Basic\npublic import Mathlib.LinearAlgebra.BilinearMap\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# The Left Exactness of Hom\n\n\nIf `M1 → M2 → M3 → 0` is an exact sequence of `R`-modules and `N` is an `R`-module,\nthen `0 → (M3 →ₗ[R] N) → (M2 →ₗ[R] N) → (M1 →ₗ[R] N)` is exact. In this file, we\nshow the exactness at `M2 →ₗ[R] N` (`exact_lcomp_of_exact_of_surjective`);\nthe injectivity part is `LinearMap.lcomp_injective_of_surjective` in the file\n`Mathlib.LinearAlgebra.BilinearMap`.\n\n\n-/\n\npublic section\n\nnamespace LinearMap\n\nvariable {R : Type*} [CommRing R] {M1 M2 M3 : Type*} (N : Type*)\n [AddCommGroup M1] [AddCommGroup M2] [AddCommGroup M3] [AddCommGroup N]\n [Module R M1] [Module R M2] [Module R M3] [Module R N]\n\nTarget:\nlemma exact_lcomp_of_exact_of_surjective {f : M1 →ₗ[R] M2} {g : M2 →ₗ[R] M3}\n (exac : Function.Exact f g) (surj : Function.Surjective g) :\n Function.Exact (LinearMap.lcomp R N g) (LinearMap.lcomp R N f) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_528d779653be","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"2dbc54113da1f306029ee158d8fc6ca98227578782a8f810d06f575e0de55e09","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra","family_id":"exact_lcomp_of_exact_of_surjective","file_id":"mathlib/Mathlib/LinearAlgebra/LeftExact.lean","sample_id":"528d779653be05f79b9d414c3bb7c0bd1efd3ac27077a9fe80d90b8423ce89c9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c59cf4a976c6ebaba15a5a211143f07af456b539bb8982aa4b619de9ab0b62b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a8879bb3188cb84be512c0810f3347effd43037e4eeab3f88edcc084d90d31f0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f69cb48d5f3da74e8393ee14b006738f8e77058a49e0d10b154dc5f5a0f45cb8","source_sha256":"c85a66a7b2da657c514ab1819675b17454bf0e8632e863fa6dbc6785f28f26f6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have :\n ∏ i ∈ s with w i ≠ 0, z i ^ w i = ∑ i ∈ s with w i ≠ 0, w i * z i ↔\n ∀ j ∈ {x ∈ s | w x ≠ 0}, z j = ∑ i ∈ s with w i ≠ 0, w i * z i :=\n geom_mean_eq_arith_mean_weighted_iff_of_pos' _ w z (by grind)\n (sum_filter_ne_zero _ |>.trans hw') (hz _ <| mem_of_mem_filter · ·)\n grind [prod_filter_of_ne, sum_filter_of_ne, rpow_zero]","hard_negative":false,"metrics":{"chosen_tokens":102,"rejected_tokens":106,"token_jaccard":0.93617,"token_length_ratio":1.039216},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"80ed24e273b81e1e29a3eb308c644c7f1d3fdd891fc3dd2b24151965f285b7db","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.BigOperators.Field\npublic import Mathlib.Analysis.Convex.Jensen\npublic import Mathlib.Analysis.Convex.SpecificFunctions.Basic\npublic import Mathlib.Analysis.SpecialFunctions.Pow.NNReal\npublic import Mathlib.Data.Real.ConjExponents\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne, Jireh Loreaux\n-/\n/-!\n# Mean value inequalities\n\nIn this file we prove several inequalities for finite sums, including AM-GM inequality,\nHM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for\nintegrals of some of these inequalities are available in\n`Mathlib/MeasureTheory/Integral/MeanInequalities.lean`.\n\n## Main theorems\n\n### AM-GM inequality:\n\nThe inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal\nto their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two non-negative vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n\\prod_{i\\in s} z_i^{w_i} ≤ \\sum_{i\\in s} w_iz_i.\n$$\nThe classical version is a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nWe prove a few versions of this inequality. Each of the following lemmas comes in two versions:\na version for real-valued non-negative functions is in the `Real` namespace, and a version for\n`NNReal`-valued functions is in the `NNReal` namespace.\n\n- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s;\n- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;\n- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;\n- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.\n\n\n### HM-GM inequality:\n\nThe inequality says that the harmonic mean of a tuple of positive numbers is less than or equal\nto their geometric mean. We prove the weighted version of this inequality: if $w$ and $z$\nare two positive vectors and $\\sum_{i\\in s} w_i=1$, then\n$$\n1/(\\sum_{i\\in s} w_i/z_i) ≤ \\prod_{i\\in s} z_i^{w_i}\n$$\nThe classical version is proven as a special case of this inequality for $w_i=\\frac{1}{n}$.\n\nThe inequalities are proven only for real-valued positive functions on `Finset`s, and namespaced in\n`Real`. The weighted version follows as a corollary of the weighted AM-GM inequality.\n\n### Young's inequality\n\nYoung's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that\n$\\frac{1}{p}+\\frac{1}{q}=1$ we have\n$$\nab ≤ \\frac{a^p}{p} + \\frac{b^q}{q}.\n$$\n\nThis inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's\ninequality (see below).\n\n### Hölder's inequality\n\nThe inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers\nsuch that $\\frac{1}{p}+\\frac{1}{q}=1$) and any two non-negative vectors their inner product is\nless than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the\nsecond vector:\n$$\n\\sum_{i\\in s} a_ib_i ≤ \\sqrt[p]{\\sum_{i\\in s} a_i^p}\\sqrt[q]{\\sum_{i\\in s} b_i^q}.\n$$\n\nWe give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.\n\nThere are at least two short proofs of this inequality. In our proof we prenormalize both vectors,\nthen apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this\ninequality from the generalized mean inequality for well-chosen vectors and weights.\n\n### Minkowski's inequality\n\nThe inequality says that for `p ≥ 1` the function\n$$\n\\|a\\|_p=\\sqrt[p]{\\sum_{i\\in s} a_i^p}\n$$\nsatisfies the triangle inequality $\\|a+b\\|_p\\le \\|a\\|_p+\\|b\\|_p$.\n\nWe give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`.\n\nWe deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\\|a\\|_p$\nis the maximum of the inner product $\\sum_{i\\in s}a_ib_i$ over `b` such that $\\|b\\|_q\\le 1$. Now\nMinkowski's inequality follows from the fact that the maximum value of the sum of two functions is\nless than or equal to the sum of the maximum values of the summands.\n\n## TODO\n\n- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them\n is to define `StrictConvexOn` functions.\n- generalized mean inequality with any `p ≤ q`, including negative numbers;\n- prove that the power mean tends to the geometric mean as the exponent tends to zero.\n\n-/\n\npublic section\n\n\nuniverse u v\n\nopen Finset NNReal ENNReal\nopen scoped BigOperators\n\nnoncomputable section\n\nvariable {ι : Type u} (s : Finset ι)\n\nsection GeomMeanLEArithMean\n\n/-! ### AM-GM inequality -/\n\n\nnamespace Real\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted\nversion for real-valued nonnegative functions. -/\ntheorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by\n -- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.\n by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0\n · rcases A with ⟨i, his, hzi, hwi⟩\n rw [prod_eq_zero his]\n · exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)\n · rw [hzi]\n exact zero_rpow hwi\n -- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality\n -- for `exp` and numbers `log (z i)` with weights `w i`.\n · have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)\n simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this\n convert! this using 1 <;> [apply prod_congr rfl; apply sum_congr rfl] <;> intro i hi\n · rcases eq_or_lt_of_le (hz i hi) with hz | hz\n · simp [A i hi hz.symm]\n · exact rpow_def_of_pos hz _\n · rcases eq_or_lt_of_le (hz i hi) with hz | hz\n · simp [A i hi hz.symm]\n · rw [exp_log hz]\n\n/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean. -/\ntheorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)\n (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :\n (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by\n convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz\n · rw [← finsetProd_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]\n refine Finset.prod_congr rfl (fun _ ih => ?_)\n rw [div_eq_mul_inv, rpow_mul (hz _ ih)]\n · simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]\n · exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')\n · simp_rw [div_eq_mul_inv, ← Finset.sum_mul]\n exact mul_inv_cancel₀ (by linarith)\n\ntheorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = x :=\n calc\n ∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by\n refine prod_congr rfl fun i hi => ?_\n rcases eq_or_ne (w i) 0 with h₀ | h₀\n · rw [h₀, rpow_zero, rpow_zero]\n · rw [hx i hi h₀]\n _ = x := by\n rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]\n have : (∑ i ∈ s, w i) ≠ 0 := by\n rw [hw']\n exact one_ne_zero\n obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this\n rw [← hx i his hi]\n exact hz i his\n\ntheorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)\n (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=\n calc\n ∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by\n refine sum_congr rfl fun i hi => ?_\n rcases eq_or_ne (w i) 0 with hwi | hwi\n · rw [hwi, zero_mul, zero_mul]\n · rw [hx i hi hwi]\n _ = x := by rw [← sum_mul, hw', one_mul]\n\ntheorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by\n rw [geom_mean_weighted_of_constant, arith_mean_weighted_of_constant] <;> assumption\n\n/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the\n*positive* weighted version of the AM-GM inequality for real-valued nonnegative functions.\n\nThe condition is that all elements of `z` are equal to their center of mass `∑ i ∈ s, w i * z i`;\nsee `geom_mean_eq_arith_mean_weighted_iff_of_pos` for a version that compares the elements to each\nother instead. -/\ntheorem geom_mean_eq_arith_mean_weighted_iff_of_pos' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, z j = ∑ i ∈ s, w i * z i := by\n by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0\n · rcases A with ⟨i, his, hzi, hwi⟩\n rw [prod_eq_zero his]\n · constructor\n · intro h\n rw [← h]\n intro j hj\n apply eq_zero_of_ne_zero_of_mul_left_eq_zero (ne_of_lt (hw j hj)).symm\n apply (sum_eq_zero_iff_of_nonneg ?_).mp h.symm j hj\n exact fun i hi => (mul_nonneg_iff_of_pos_left (hw i hi)).mpr (hz i hi)\n · intro h\n convert! h i his\n exact hzi.symm\n · rw [hzi]\n exact zero_rpow hwi\n · have hz' := fun i h => lt_of_le_of_ne (hz i h) (fun a => (ne_of_gt (hw i h)) (A i h a.symm))\n have := strictConvexOn_exp.map_sum_eq_iff hw hw' fun i _ => Set.mem_univ <| log (z i)\n simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this\n convert! this using 1\n · apply Eq.congr <;>\n [apply prod_congr rfl; apply sum_congr rfl] <;>\n intro i hi <;>\n simp only [exp_mul, exp_log (hz' i hi)]\n · constructor <;> intro h j hj\n · rw [← arith_mean_weighted_of_constant s w _ (log (z j)) hw' fun i _ => congrFun rfl]\n apply sum_congr rfl\n intro x hx\n simp only [mul_comm, h j hj, h x hx]\n · rw [← arith_mean_weighted_of_constant s w _ (z j) hw' fun i _ => congrFun rfl]\n apply sum_congr rfl\n intro x hx\n simp only [log_injOn_pos (hz' j hj) (hz' x hx), h j hj, h x hx]\n\n@[deprecated (since := \"2026-06-07\")]\nalias geom_mean_eq_arith_mean_weighted_iff' := geom_mean_eq_arith_mean_weighted_iff_of_pos'\n\n/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the\nweighted version of the AM-GM inequality for real-valued nonnegative functions.\n\nThe condition is that all elements of `z` with a nonzero weight are equal to their center of mass\n`∑ i ∈ s, w i * z i`; see `geom_mean_eq_arith_mean_weighted_iff_of_nonneg` for a version that\ncompares the elements to each other instead. -/\n\nTarget:\ntheorem geom_mean_eq_arith_mean_weighted_iff_of_nonneg' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)\n (hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :\n ∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, w j ≠ 0 → z j = ∑ i ∈ s, w i * z i :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n have :\n ∏ i ∈ s with w i ≠ 0, z i ^ w i = ∑ i ∈ s with w i ≠ 0, w i * z i ↔\n ∀ j ∈ {x ∈ s | w x ≠ 0}, z j = ∑ i ∈ s with w i ≠ 0, w i * z i :=\n geom_mean_eq_arith_mean_weighted_iff_of_pos' _ w z (by grind)\n (sum_filter_ne_zero _ |>.trans hw') (hz _ <| mem_of_mem_filter · ·)\n grind [prod_filter_of_ne, sum_filter_of_ne, rpow_zero]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis","family_id":"geom_mean_eq_arith_mean_weighted_iff_of_nonneg","file_id":"mathlib/Mathlib/Analysis/MeanInequalities.lean","sample_id":"f69cb48d5f3da74e8393ee14b006738f8e77058a49e0d10b154dc5f5a0f45cb8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f8a398c775cdfbad2e386f235b1aa221b80f09e334a924b4c948d46c7f364040","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a93c8deaf18a57ea7eb188ad78df710464dffeb90776aa1626fc3d22ea26ee2e","source_sha256":"8fa72a43e680b83403f64aed4f242d29897ff5dbd1caf9a8138cd5ff2f09e69b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mul_iInf]\n exact le_ciInf H","hard_negative":false,"metrics":{"chosen_tokens":8,"rejected_tokens":2,"token_jaccard":0.111111,"token_length_ratio":0.25},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"81a5e3fd208f4d4dcd8a9ab8911ec5f72ee7fff40d17f133b9afb2e9123a654f","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.Order.BigOperators.Group.Finset\npublic import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset\npublic import Mathlib.Algebra.Order.Field.Canonical\npublic import Mathlib.Algebra.Order.Nonneg.Floor\npublic import Mathlib.Data.Real.Pointwise\npublic import Mathlib.Data.NNReal.Defs\npublic import Mathlib.Order.ConditionallyCompleteLattice.Group\npublic import Mathlib.Order.Lattice.Nat\n\nNamespace:\nNNReal\n\nLocal context:\n/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Basic results on nonnegative real numbers\n\nThis file contains all results on `NNReal` that do not directly follow from its basic structure.\nAs a consequence, it is a bit of a random collection of results, and is a good target for cleanup.\n\n## Notation\n\nThis file uses `ℝ≥0` as a localized notation for `NNReal`.\n-/\n\npublic section\n\nassert_not_exists TrivialStar\n\nopen Function Set\nopen scoped BigOperators\n\nnamespace NNReal\nvariable {M : Type*} [Zero M]\n\nnoncomputable instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)\n\n@[simp, norm_cast]\ntheorem coe_mulIndicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.mulIndicator f a : ℝ≥0) : ℝ) = s.mulIndicator (fun x => ↑(f x)) a :=\n map_mulIndicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_indicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.indicator f a : ℝ≥0) : ℝ) = s.indicator (fun x => ↑(f x)) a :=\n map_indicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_mulSingle {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.mulSingle a b : α → ℝ≥0) c : ℝ) = (Pi.mulSingle a b : α → ℝ) c := by\n simpa using coe_mulIndicator {a} (fun _ ↦ b) c\n\n@[simp, norm_cast]\ntheorem coe_single {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.single a b : α → ℝ≥0) c : ℝ) = (Pi.single a b : α → ℝ) c := by\n simpa using coe_indicator {a} (fun _ ↦ b) c\n\n@[norm_cast]\ntheorem coe_list_sum (l : List ℝ≥0) : ((l.sum : ℝ≥0) : ℝ) = (l.map (↑)).sum :=\n map_list_sum toRealHom l\n\n@[norm_cast]\ntheorem coe_list_prod (l : List ℝ≥0) : ((l.prod : ℝ≥0) : ℝ) = (l.map (↑)).prod :=\n map_list_prod toRealHom l\n\n@[norm_cast]\ntheorem coe_multiset_sum (s : Multiset ℝ≥0) : ((s.sum : ℝ≥0) : ℝ) = (s.map (↑)).sum :=\n map_multiset_sum toRealHom s\n\n@[norm_cast]\ntheorem coe_multiset_prod (s : Multiset ℝ≥0) : ((s.prod : ℝ≥0) : ℝ) = (s.map (↑)).prod :=\n map_multiset_prod toRealHom s\n\nvariable {ι : Type*} {s : Finset ι} {f : ι → ℝ}\n\n@[simp, norm_cast]\ntheorem coe_sum (s : Finset ι) (f : ι → ℝ≥0) : ∑ i ∈ s, f i = ∑ i ∈ s, (f i : ℝ) :=\n map_sum toRealHom _ _\n\n@[simp, norm_cast]\nlemma toReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.sum g = f.sum (fun i m ↦ toReal (g i m)) := map_finsuppSum toRealHom ..\n\n@[simp, norm_cast]\nlemma toReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.prod g = f.prod (fun i m ↦ toReal (g i m)) := map_finsuppProd toRealHom ..\n\n@[simp, norm_cast]\nlemma coe_expect (s : Finset ι) (f : ι → ℝ≥0) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : ℝ) :=\n map_expect toRealHom ..\n\ntheorem _root_.Real.toNNReal_sum_of_nonneg (hf : ∀ i ∈ s, 0 ≤ f i) :\n Real.toNNReal (∑ a ∈ s, f a) = ∑ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)]\n exact Finset.sum_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\n@[simp, norm_cast]\ntheorem coe_prod (s : Finset ι) (f : ι → ℝ≥0) : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ) :=\n map_prod toRealHom _ _\n\ntheorem _root_.Real.toNNReal_prod_of_nonneg (hf : ∀ a, a ∈ s → 0 ≤ f a) :\n Real.toNNReal (∏ a ∈ s, f a) = ∏ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]\n exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\ntheorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}\n {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j := by\n rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]\n exact le_ciInf_add_ciInf h\n\ntheorem mul_finset_sup {α} (r : ℝ≥0) (s : Finset α) (f : α → ℝ≥0) :\n r * s.sup f = s.sup fun a => r * f a :=\n Finset.apply_sup_eq_sup_comp _ (NNReal.mul_sup r) (mul_zero r)\n\ntheorem finset_sup_mul {α} (s : Finset α) (f : α → ℝ≥0) (r : ℝ≥0) :\n s.sup f * r = s.sup fun a => f a * r :=\n Finset.apply_sup_eq_sup_comp (· * r) (fun x y => NNReal.sup_mul x y r) (zero_mul r)\n\ntheorem finset_sup_div {α} {f : α → ℝ≥0} {s : Finset α} (r : ℝ≥0) :\n s.sup f / r = s.sup fun a => f a / r := by simp only [div_eq_inv_mul, mul_finset_sup]\n\nsection Set\n\n@[simp] lemma bddAbove_natCast_image_iff {s : Set ℕ} : BddAbove ((↑) '' s : Set ℝ≥0) ↔ BddAbove s :=\n ⟨.imp' Nat.floor (by simp [upperBounds, Nat.le_floor_iff]), .imp' (↑) (by simp [upperBounds])⟩\n\n@[simp, norm_cast] lemma bddAbove_range_natCast_iff {ι : Sort*} (f : ι → ℕ) :\n BddAbove (Set.range (f ·) : Set NNReal) ↔ BddAbove (Set.range f) := by\n rw [← bddAbove_natCast_image_iff, ← Set.range_comp]\n rfl\n\nend Set\n\nopen Real\n\nsection Sub\n\n/-!\n### Lemmas about subtraction\n\nIn this section we provide a few lemmas about subtraction that do not fit well into any other\ntypeclass. For lemmas about subtraction and addition see lemmas about `OrderedSub` in the file\n`Mathlib/Algebra/Order/Sub/Basic.lean`. See also `mul_tsub` and `tsub_mul`.\n-/\n\ntheorem sub_div (a b c : ℝ≥0) : (a - b) / c = a / c - b / c :=\n tsub_div _ _ _\n\n/-- This lemma is needed for the `norm_cast` simp set. Outside of this use case `Nat.coe_sub`\nshould be used. -/\n@[norm_cast]\nprotected theorem coe_sub_of_lt {a b : ℝ≥0} (h : a < b) :\n ((b - a : ℝ≥0) : ℝ) = b - a := NNReal.coe_sub h.le\n\nend Sub\n\nsection Csupr\n\nopen Set\n\nvariable {ι : Sort*} {f : ι → ℝ≥0}\n\ntheorem iInf_mul (f : ι → ℝ≥0) (a : ℝ≥0) : iInf f * a = ⨅ i, f i * a := by\n rw [← coe_inj, NNReal.coe_mul, coe_iInf, coe_iInf]\n exact Real.iInf_mul_of_nonneg (NNReal.coe_nonneg _) _\n\ntheorem mul_iInf (f : ι → ℝ≥0) (a : ℝ≥0) : a * iInf f = ⨅ i, a * f i := by\n simpa only [mul_comm] using iInf_mul f a\n\ntheorem mul_iSup (f : ι → ℝ≥0) (a : ℝ≥0) : (a * ⨆ i, f i) = ⨆ i, a * f i := by\n rw [← coe_inj, NNReal.coe_mul, NNReal.coe_iSup, NNReal.coe_iSup]\n exact Real.mul_iSup_of_nonneg (NNReal.coe_nonneg _) _\n\ntheorem iSup_mul (f : ι → ℝ≥0) (a : ℝ≥0) : (⨆ i, f i) * a = ⨆ i, f i * a := by\n rw [mul_comm, mul_iSup]\n simp_rw [mul_comm]\n\ntheorem iSup_div (f : ι → ℝ≥0) (a : ℝ≥0) : (⨆ i, f i) / a = ⨆ i, f i / a := by\n simp only [div_eq_mul_inv, iSup_mul]\n\ntheorem mul_iSup_le {a : ℝ≥0} {g : ℝ≥0} {h : ι → ℝ≥0} (H : ∀ j, g * h j ≤ a) : g * iSup h ≤ a := by\n rw [mul_iSup]\n exact ciSup_le' H\n\ntheorem iSup_mul_le {a : ℝ≥0} {g : ι → ℝ≥0} {h : ℝ≥0} (H : ∀ i, g i * h ≤ a) : iSup g * h ≤ a := by\n rw [iSup_mul]\n exact ciSup_le' H\n\ntheorem iSup_mul_iSup_le {a : ℝ≥0} {g h : ι → ℝ≥0} (H : ∀ i j, g i * h j ≤ a) :\n iSup g * iSup h ≤ a :=\n iSup_mul_le fun _ => mul_iSup_le <| H _\n\nvariable [Nonempty ι]\n\nTarget:\ntheorem le_mul_iInf {a : ℝ≥0} {g : ℝ≥0} {h : ι → ℝ≥0} (H : ∀ j, a ≤ g * h j) : a ≤ g * iInf h :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/NNReal","family_id":"le_mul_iinf","file_id":"mathlib/Mathlib/Data/NNReal/Basic.lean","sample_id":"a93c8deaf18a57ea7eb188ad78df710464dffeb90776aa1626fc3d22ea26ee2e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a2602fcb0f851fb8f71b48522066956561749031a457acc0bb80c3e8d5266e5a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2055ee66436ccf1e341a93b3d35e160435c522b0de826a586243bcd4e363a96c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da3ecd97ba2e623f6c548fe5685cd572e1f5aa21d590419b2463bcb667e9a8ce","source_sha256":"f39a78c281935d81de36ca9564987ad4a6cf6b74a66133b16f897a6f004c581d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [isConjRoot_def, minpoly.neg x, minpoly.neg y, h]","hard_negative":true,"metrics":{"chosen_tokens":17,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.117647},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"8207a8d555de69b4c8ba2451db825510b2822f705447a8fcc5f9cd334ff9680c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Extension\npublic import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic\npublic import Mathlib.FieldTheory.Minpoly.Basic\npublic import Mathlib.FieldTheory.Normal.Defs\n\nNamespace:\nIsConjRoot\n\nLocal context:\n/-\nCopyright (c) 2024 Jiedong Jiang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jiedong Jiang\n-/\n/-!\n# Conjugate roots\n\nGiven two elements `x` and `y` of some `K`-algebra, these two elements are *conjugate roots*\nover `K` if they have the same minimal polynomial over `K`.\n\n## Main definitions\n\n* `IsConjRoot`: `IsConjRoot K x y` means `y` is a conjugate root of `x` over `K`.\n\n## Main results\n\n* `isConjRoot_iff_exists_algEquiv`: Let `L / K` be a normal field extension. For any two elements\n `x` and `y` in `L`, `IsConjRoot K x y` is equivalent to the existence of an algebra equivalence\n `σ : Gal(L/K)` such that `y = σ x`.\n* `notMem_iff_exists_ne_and_isConjRoot`: Let `L / K` be a field extension. If `x` is a separable\n element over `K` and the minimal polynomial of `x` splits in `L`, then `x` is not in the `K` iff\n there exists a different conjugate root of `x` in `L` over `K`.\n\n## TODO\n* Move `IsConjRoot` to earlier files and refactor the theorems in field theory using `IsConjRoot`.\n\n* Prove `IsConjRoot.smul`, if `x` and `y` are conjugate roots, then so are `r • x` and `r • y`.\n\n## Tags\nconjugate root, minimal polynomial\n-/\n\n@[expose] public section\n\n\nopen Polynomial minpoly Module IntermediateField\n\nvariable {R K L S A B : Type*} [CommRing R] [CommRing S] [Ring A] [Ring B] [Field K] [Field L]\nvariable [Algebra R S] [Algebra R A] [Algebra R B]\nvariable [Algebra K S] [Algebra K L] [Algebra K A] [Algebra L S]\n\nvariable (R) in\n/--\nWe say that `y` is a conjugate root of `x` over `K` if the minimal polynomial of `x` is the\nsame as the minimal polynomial of `y`.\n-/\ndef IsConjRoot (x y : A) : Prop := minpoly R x = minpoly R y\n\n/--\nThe definition of conjugate roots.\n-/\ntheorem isConjRoot_def {x y : A} : IsConjRoot R x y ↔ minpoly R x = minpoly R y := Iff.rfl\n\nnamespace IsConjRoot\n\n/--\nEvery element is a conjugate root of itself.\n-/\n@[refl] theorem refl {x : A} : IsConjRoot R x x := rfl\n\n/--\nIf `y` is a conjugate root of `x`, then `x` is also a conjugate root of `y`.\n-/\n@[symm] theorem symm {x y : A} (h : IsConjRoot R x y) : IsConjRoot R y x := Eq.symm h\n\n/--\nIf `y` is a conjugate root of `x` and `z` is a conjugate root of `y`, then `z` is a conjugate\nroot of `x`.\n-/\n@[trans] theorem trans {x y z : A} (h₁ : IsConjRoot R x y) (h₂ : IsConjRoot R y z) :\n IsConjRoot R x z := Eq.trans h₁ h₂\n\nvariable (R A) in\n/--\nThe setoid structure on `A` defined by the equivalence relation of `IsConjRoot R · ·`.\n-/\n@[implicit_reducible]\ndef setoid : Setoid A where\n r := IsConjRoot R\n iseqv := ⟨fun _ => refl, symm, trans⟩\n\ntheorem comm {x y : A} : IsConjRoot R x y ↔ IsConjRoot R y x :=\n ⟨symm, symm⟩\n\n/--\nLet `p` be the minimal polynomial of `x`. If `y` is a conjugate root of `x`, then `p y = 0`.\n-/\ntheorem aeval_eq_zero {x y : A} (h : IsConjRoot R x y) : aeval y (minpoly R x) = 0 :=\n h ▸ minpoly.aeval R y\n\n/--\nLet `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y + r` is a\nconjugate root of `x + r`.\n-/\ntheorem add_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) :\n IsConjRoot K (x + algebraMap K S r) (y + algebraMap K S r) := by\n rw [isConjRoot_def, minpoly.add_algebraMap x r, minpoly.add_algebraMap y r, h]\n\n/--\nLet `r` be an element of the base ring. If `y` is a conjugate root of `x`, then `y - r` is a\nconjugate root of `x - r`.\n-/\ntheorem sub_algebraMap {x y : S} (r : K) (h : IsConjRoot K x y) :\n IsConjRoot K (x - algebraMap K S r) (y - algebraMap K S r) := by\n simpa only [sub_eq_add_neg, map_neg] using add_algebraMap (-r) h\n\n/--\nIf `y` is a conjugate root of `x`, then `-y` is a conjugate root of `-x`.\n-/\n\nTarget:\ntheorem neg {x y : S} (h : IsConjRoot K x y) :\n IsConjRoot K (-x) (-y) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_da3ecd97ba2e","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"156c15feeca1d141541bbbec98e88a12dd6e6e63c318ce92d808e626c7d4f643","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory/Minpoly","family_id":"neg","file_id":"mathlib/Mathlib/FieldTheory/Minpoly/IsConjRoot.lean","sample_id":"da3ecd97ba2e623f6c548fe5685cd572e1f5aa21d590419b2463bcb667e9a8ce"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"88f51ddb8bf50f920612fb0fba6cd209ba21aa09029a7eb34c037af95f86b2e6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2916c0f61a0c6852174e29edd69e2dfe293c585cb0b84d43d10f47d92b6f71fa","source_sha256":"5a346381a7b32deaa54f8cf8c13708605ef18202eb02667b8a6aad13ac97c12f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [treesOfNumNodesEq]\n ext\n simp","hard_negative":true,"metrics":{"chosen_tokens":7,"rejected_tokens":8,"token_jaccard":0.076923,"token_length_ratio":1.142857},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"82c7a49b485ee47be81a8f3b2983b27120134e486178ea43aedaf0a8977f8e71","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Defs\npublic import Mathlib.Combinatorics.Enumerative.Catalan.Basic\npublic import Mathlib.Data.Finset.NatAntidiagonal\npublic import Mathlib.Data.Nat.Choose.Central\nimport Mathlib.Algebra.BigOperators.Fin\nimport Mathlib.Algebra.BigOperators.NatAntidiagonal\nimport Mathlib.Tactic.Field\n\nNamespace:\nBinaryTree\n\nLocal context:\n/-\nCopyright (c) 2022 Julian Kuelshammer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julian Kuelshammer\n-/\n/-!\n## Main results\n* `treesOfNumNodesEq_card_eq_catalan`: The number of binary trees with `n` internal nodes\n is `catalan n`\n\n-/\n\n@[expose] public section\n\nopen Finset\n\nopen Finset.antidiagonal (fst_le snd_le)\n\nnamespace BinaryTree\n\n/-- Given two finsets, find all trees that can be formed with\n left child in `a` and right child in `b` -/\nabbrev pairwiseNode (a b : Finset (BinaryTree Unit)) : Finset (BinaryTree Unit) :=\n (a ×ˢ b).map ⟨fun x => x.1 △ x.2, fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ => fun h => by simpa using h⟩\n\n/-- A Finset of all trees with `n` nodes. See `mem_treesOfNodesEq` -/\ndef treesOfNumNodesEq : ℕ → Finset (BinaryTree Unit)\n | 0 => {nil}\n | n + 1 =>\n (antidiagonal n).attach.biUnion fun ijh =>\n pairwiseNode (treesOfNumNodesEq ijh.1.1) (treesOfNumNodesEq ijh.1.2)\n decreasing_by\n · simp_wf; have := fst_le ijh.2; lia\n · simp_wf; have := snd_le ijh.2; lia\n\nset_option linter.deprecated false in\n/-- **Alias** of `BinaryTree.treesOfNumNodesEq`. -/\n@[deprecated BinaryTree.treesOfNumNodesEq (since := \"2026-06-07\")]\nabbrev _root_.Tree.treesOfNumNodesEq : ℕ → Finset (Tree Unit) :=\n BinaryTree.treesOfNumNodesEq\n\n@[simp]\ntheorem treesOfNumNodesEq_zero : treesOfNumNodesEq 0 = {nil} := by rw [treesOfNumNodesEq]\n\nTarget:\ntheorem treesOfNumNodesEq_succ (n : ℕ) :\n treesOfNumNodesEq (n + 1) =\n (antidiagonal n).biUnion fun ij =>\n pairwiseNode (treesOfNumNodesEq ij.1) (treesOfNumNodesEq ij.2) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"616930e1e2ca3be693ec7b57035122ab411698578efc70ae03e8648ea483b925","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Enumerative","family_id":"treesofnumnodeseq_succ","file_id":"mathlib/Mathlib/Combinatorics/Enumerative/Catalan/Tree.lean","sample_id":"2916c0f61a0c6852174e29edd69e2dfe293c585cb0b84d43d10f47d92b6f71fa"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5a85d26b86ddf2f74915bdec71c3437727410190652cd57dd0255d39ab75018a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4f87257324df665d9debff8ca9d6a0ef1f5b0744b7fac7ec6bc51e6c735c540d","source_sha256":"efebd44e71fcef2bd69a9d7802ed9c86042b0931e37af3daaa195109d5ee3e6a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [edist_comm y]; apply edist_triangle","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":2,"token_jaccard":0.1,"token_length_ratio":0.222222},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"854213610b80ff750909e39dc2cb7cb363e21b77088ec28d315b665576b3e653","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ENNReal.Inv\npublic import Mathlib.Topology.UniformSpace.Basic\npublic import Mathlib.Topology.UniformSpace.OfFun\n\nNamespace:\n(root)\n\nLocal context:\n/-\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, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel\n-/\n/-!\n# Extended metric spaces\n\nThis file is devoted to the definition and study of `EMetricSpace`s, i.e., metric\nspaces in which the distance is allowed to take the value ∞. This extended distance is\ncalled `edist`, and takes values in `ℝ≥0∞`.\n\nMany definitions and theorems expected on emetric spaces are already introduced on uniform spaces\nand topological spaces. For example: open and closed sets, compactness, completeness, continuity and\nuniform continuity.\n\nThe class `EMetricSpace` therefore extends `UniformSpace` (and `TopologicalSpace`).\n\nSince a lot of elementary properties don't require `eq_of_edist_eq_zero` we start setting up the\ntheory of `PseudoEMetricSpace`, where we don't require `edist x y = 0 → x = y` and we specialize\nto `EMetricSpace` at the end.\n-/\n\n@[expose] public section\n\n\nassert_not_exists Nat.instLocallyFiniteOrder IsUniformEmbedding.prod TendstoUniformlyOnFilter\n\nopen Filter Set Topology Set.Notation\n\nuniverse u v w\n\nvariable {α : Type u} {β : Type v} {X : Type*}\n\n/-- Characterizing uniformities associated to a (generalized) distance function `D`\nin terms of the elements of the uniformity. -/\ntheorem uniformity_dist_of_mem_uniformity [LT β] {U : Filter (α × α)} (z : β)\n (D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) :\n U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } :=\n HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩\n\nopen scoped Uniformity Topology Filter NNReal ENNReal Pointwise\n\n/-- `EDist α` means that `α` is equipped with an extended distance. -/\n@[ext]\nclass EDist (α : Type*) where\n /-- Extended distance between two points -/\n edist : α → α → ℝ≥0∞\n\nexport EDist (edist)\n\nsection\n\nvariable {x y z : α} {ε : ℝ≥0∞} [EDist α]\n\n/-- `EMetric.ball x ε` is the set of all points `y` with `edist y x < ε` -/\ndef Metric.eball (x : α) (ε : ℝ≥0∞) : Set α :=\n { y | edist y x < ε }\n\n@[simp] theorem Metric.mem_eball {x y : α} {ε : ℝ≥0∞} : y ∈ eball x ε ↔ edist y x < ε := Iff.rfl\n\nend\n\n/-- Creating a uniform space from an extended distance. -/\n@[reducible]\nnoncomputable def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0)\n (edist_comm : ∀ x y : α, edist x y = edist y x)\n (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α :=\n .ofFun edist edist_self edist_comm edist_triangle fun ε ε0 =>\n ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>\n (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩\n\n/-- Creating a uniform space from an extended distance. We assume that\nthere is a preexisting topology, for which the neighborhoods can be expressed using the distance,\nand we make sure that the uniform space structure we construct has a topology which is defeq\nto the original one. -/\n@[reducible] noncomputable def uniformSpaceOfEDistOfHasBasis [TopologicalSpace α]\n (edist : α → α → ℝ≥0∞)\n (edist_self : ∀ x : α, edist x x = 0)\n (edist_comm : ∀ x y : α, edist x y = edist y x)\n (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z)\n (basis : ∀ x, (𝓝 x).HasBasis (fun c ↦ 0 < c) (fun c ↦ {y | edist x y < c})) :\n UniformSpace α :=\n .ofFunOfHasBasis edist edist_self edist_comm edist_triangle (fun ε ε0 =>\n ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>\n (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩) basis\n\n/-- A pseudo extended metric space is a type endowed with a `ℝ≥0∞`-valued distance `edist`\nsatisfying reflexivity `edist x x = 0`, commutativity `edist x y = edist y x`, and the triangle\ninequality `edist x z ≤ edist x y + edist y z`.\n\nNote that we do not require `edist x y = 0 → x = y`. See extended metric spaces (`EMetricSpace`) for\nthe similar class with that stronger assumption.\n\nAny pseudo extended metric space is a topological space and a uniform space (see `TopologicalSpace`,\n`UniformSpace`), where the topology and uniformity come from the metric.\nNote that a T1 pseudo extended metric space is just an extended metric space.\n\nWe make the uniformity/topology part of the data instead of deriving it from the metric. This e.g.\nensures that we do not get a diamond when doing\n`[PseudoEMetricSpace α] [PseudoEMetricSpace β] : TopologicalSpace (α × β)`:\nThe product metric and product topology agree, but not definitionally so.\nSee Note [forgetful inheritance]. -/\nclass PseudoEMetricSpace (α : Type u) : Type u extends EDist α where\n edist_self : ∀ x : α, edist x x = 0\n edist_comm : ∀ x y : α, edist x y = edist y x\n edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z\n toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle\n uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl\n\nattribute [instance_reducible, instance] PseudoEMetricSpace.toUniformSpace\n\n/- Pseudoemetric spaces are less common than metric spaces. Therefore, we work in a dedicated\nnamespace, while notions associated to metric spaces are mostly in the root namespace. -/\n\n/-- Two pseudo emetric space structures with the same edistance function coincide. -/\n@[ext]\nprotected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α}\n (h : m.toEDist = m'.toEDist) : m = m' := by\n obtain ⟨_, _, _, U, hU⟩ := m; rename EDist α => ed\n obtain ⟨_, _, _, U', hU'⟩ := m'; rename EDist α => ed'\n congr 1\n exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm)\n\nvariable [PseudoEMetricSpace α]\n\nexport PseudoEMetricSpace (edist_self edist_comm edist_triangle)\n\nattribute [simp] edist_self\n\n/-- Triangle inequality for the extended distance -/\ntheorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by\n rw [edist_comm z]; apply edist_triangle\n\nTarget:\ntheorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/EMetricSpace","family_id":"edist_triangle_right","file_id":"mathlib/Mathlib/Topology/EMetricSpace/Defs.lean","sample_id":"4f87257324df665d9debff8ca9d6a0ef1f5b0744b7fac7ec6bc51e6c735c540d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8e0b5a57a1cdde1645596eb1594f8a0f8afcf9ccd1e789d96515f6929a83487b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"22eb6f2d61023dd23dc7b24e712ee2a8ae267a1df6ed9817184f87d0f6e9d144","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"52e69e942ad6cdbe562009dc71073e2843a675af6d08ef474d3e5afa92251338","source_sha256":"38d64e4f1a0e05f9858787ff51b94222506a7fd69d13ef99d2c65865e8c1dd3f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cases x <;> rfl\n\nvariable (η : ApplicativeTransformation F G)","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":5,"token_jaccard":0.052632,"token_length_ratio":0.333333},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"854339f4c331d292369e8f3072a4d62308e1f574302041fa835f85cb44c96f63","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Applicative\npublic import Mathlib.Control.Traversable.Basic\npublic import Mathlib.Data.List.Forall2\npublic import Mathlib.Data.Set.Functor\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# LawfulTraversable instances\n\nThis file provides instances of `LawfulTraversable` for types from the core library: `Option`,\n`List` and `Sum`.\n-/\n\npublic section\n\n\nuniverse u v\n\nsection Option\n\nopen Functor\n\nvariable {F G : Type u → Type u}\nvariable [Applicative F] [Applicative G]\nvariable [LawfulApplicative G]\n\ntheorem Option.id_traverse {α} (x : Option α) : Option.traverse (pure : α → Id α) x = pure x := by\n cases x <;> rfl\n\ntheorem Option.comp_traverse {α β γ} (f : β → F γ) (g : α → G β) (x : Option α) :\n Option.traverse (Comp.mk ∘ (f <$> ·) ∘ g) x =\n Comp.mk (Option.traverse f <$> Option.traverse g x) := by\n cases x <;> (simp [Option.traverse, Option.mapM, functor_norm] <;> rfl)\n\nTarget:\ntheorem Option.traverse_eq_map_id {α β} (f : α → β) (x : Option α) :\n Option.traverse ((pure : _ → Id _) ∘ f) x = (pure : _ → Id _) (f <$> x) :=\n\nProof body:\n","rejected":"by\n exact Option.traverse_eq_map_id","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"c8daa2d5c366ea3be1a8f5154292ddde10d91ea9a2484f9905b209c75bd97b89","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Control/Traversable","family_id":"option","file_id":"mathlib/Mathlib/Control/Traversable/Instances.lean","sample_id":"52e69e942ad6cdbe562009dc71073e2843a675af6d08ef474d3e5afa92251338"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f194b7d6eac4e2d6633da0a5617552c227efdbfa726721214ee562dea2432d2d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"83f48d6abb23b174e2aa46e03053169c10b461ad625051fb476a138c68bf8e87","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3a5018e6c1566751dbdf9f58dd1239c8644e55701a13fb33847400d3465f55c4","source_sha256":"31511787b8ee979ad68b270d70d53565c4f726a4fcbb6bab5c8059163486f498","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [← mem_coe, coe_smul, Set.mem_inv_smul_set_iff]","hard_negative":true,"metrics":{"chosen_tokens":12,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.25},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"870a3ef9ff1d80419f40c38e5d74f8f7b9463c6283b43d69e7b2c7bd8bbd6453","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Finite\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.GroupTheory.Coset.Defs\n\nNamespace:\nDiscreteTiling.PlacedTile\n\nLocal context:\n/-\nCopyright (c) 2026 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Tiles for tilings\n\nThis file defines some basic concepts related to individual tiles for tilings in a discrete context\n(with definitions in a continuous context to be developed separately but analogously).\n\nWork in the field of tilings does not generally try to define or state things in any kind of maximal\ngenerality, so it is necessary to adapt definitions and statements from the literature to produce\nsomething that seems appropriately general for mathlib, covering a wide range of tiling-related\nconcepts found in the literature. Nevertheless, further generalization may prove of use as this work\nis extended in future.\n\nWe work in the context of a space `X` acted on by a group `G`; the action is not required to be\nfaithful, although typically it is. In a discrete context, tiles are expected to cover the space, or\na subset of it being tiled when working with tilings not of the whole space, and the tiles are\npairwise disjoint. In a continuous context, definitions in the literature vary; the tiles may be\nclosed and cover the space with interiors required to be disjoint (as used by Grünbaum and Shephard\nor Goodman-Strauss), or they may be required to be measurable and to partition it up to null sets\n(as used by Greenfeld and Tao).\n\nIn general we are concerned not with a tiling in isolation but with tilings by some protoset of\ntiles; thus we make definitions in the context of such a protoset, where copies of the tiles in the\ntiling must be images of those tiles under the action of an element of the given group.\n\nWhere there are matching rules that say what combinations of tiles are considered as valid, these\nare provided as separate hypotheses where required. Tiles in a protoset are commonly considered in\nthe literature to be marked in some way. When this is simply to distinguish two otherwise identical\ntiles, this is represented by the use of different indices in the protoset. When this is to give a\ntile fewer symmetries than it would otherwise have under the action of the given group, this is\nrepresented by the symmetries specified in the `Prototile` being less than its full stabilizer.\n\nThe group `G` is throughout here a multiplicative group. Additive groups are also used in the\nliterature, typically when based on `ℤ`; to support the use of additive groups, `to_additive` could\nbe used with the theory here.\n\n## Main definitions\n\n* `Prototile G X`: A prototile in `X` as acted on by `G`, carrying the information of a subgroup of\n the stabilizer that says when two copies of the prototile are considered the same.\n\n* `Protoset G X ιₚ`: An indexed family of prototiles.\n\n* `PlacedTile ps`: An image of a tile in the protoset `ps`.\n\n## References\n\n* [Branko Grünbaum and G. C. Shephard, *Tilings and Patterns*][GrunbaumShephard1987]\n* [Chaim Goodman-Strauss, *Open Questions in Tiling*][GoodmanStrauss2000]\n* [Rachel Greenfeld and Terence Tao, *A counterexample to the periodic tiling\n conjecture*][GreenfeldTao2024]\n-/\n\n\n@[expose] public section\n\nnamespace DiscreteTiling\n\nopen Function\nopen scoped Pointwise\n\nvariable {G X ιₚ : Type*} [Group G] [MulAction G X]\n\nvariable (G X) in\n/-- A `Prototile G X` describes a tile in `X`, copies of which under elements of `G` may be used in\ntilings. Two copies related by an element of `symmetries` are considered the same; two copies not so\nrelated, even if they have the same points, are considered distinct. -/\n@[ext] structure Prototile where\n /-- The points in the prototile. Use the coercion to `Set X`, or `∈` on the `Prototile`, rather\n than using `carrier` directly. The coercion cannot use `SetLike` because it does not satisfy\n `coe_injective`. -/\n carrier : Set X\n /-- The group elements considered to be symmetries of the prototile. -/\n symmetries : Subgroup (MulAction.stabilizer G carrier)\n\nnamespace Prototile\n\ninstance : Inhabited (Prototile G X) where\n default := ⟨∅, ⊥⟩\n\ninstance : CoeOut (Prototile G X) (Set X) where\n coe := Prototile.carrier\n\nattribute [coe] carrier\n\ninstance : Membership X (Prototile G X) where\n mem p x := x ∈ (p : Set X)\n\nlemma coe_mk (c s) : (⟨c, s⟩ : Prototile G X) = c := rfl\n\n@[simp] lemma mem_coe {x : X} {p : Prototile G X} : x ∈ (p : Set X) ↔ x ∈ p := Iff.rfl\n\nend Prototile\n\nvariable (G X ιₚ) in\n/-- A `Protoset G X ιₚ` is an indexed family of `Prototile G X`. This is a separate definition\nrather than just using plain functions to facilitate defining associated API that can be used with\ndot notation. -/\n@[ext] structure Protoset where\n /-- The tiles in the protoset. Use the coercion to a function rather than using `tiles`\n directly. -/\n tiles : ιₚ → Prototile G X\n\nnamespace Protoset\n\ninstance : Inhabited (Protoset G X ιₚ) where\n default := ⟨fun _ ↦ default⟩\n\ninstance : CoeFun (Protoset G X ιₚ) (fun _ ↦ ιₚ → Prototile G X) where\n coe := tiles\n\nattribute [coe] tiles\n\nlemma coe_mk (t) : (⟨t⟩ : Protoset G X ιₚ) = t := rfl\n\n@[simp, norm_cast] lemma coe_inj {ps₁ ps₂ : Protoset G X ιₚ} :\n (ps₁ : ιₚ → Prototile G X) = ps₂ ↔ ps₁ = ps₂ :=\n Protoset.ext_iff.symm\n\nlemma coe_injective : Injective (Protoset.tiles : Protoset G X ιₚ → ιₚ → Prototile G X) :=\n fun _ _ ↦ coe_inj.1\n\nend Protoset\n\nvariable {ps : Protoset G X ιₚ}\n\nvariable (ps) in\n/-- A `PlacedTile ps` is an image of a tile in the protoset `p` under an element of the group `G`.\nThis is represented using a quotient so that images under group elements differing only by a\nsymmetry of the tile are equal. -/\n@[ext] structure PlacedTile where\n /-- The index of the tile in the protoset. -/\n index : ιₚ\n /-- The group elements under which this tile is an image. -/\n groupElts : G ⧸ ((ps index).symmetries.map <| Subgroup.subtype _)\n\nnamespace PlacedTile\n\ninstance [Nonempty ιₚ] : Nonempty (PlacedTile ps) := ⟨⟨Classical.arbitrary _, (1 : G)⟩⟩\n\n/-- An induction principle to deduce results for `PlacedTile` from those given an index and an\nelement of `G`, used with `induction pt using PlacedTile.induction_on`. -/\n@[elab_as_elim] protected lemma induction_on {ppt : PlacedTile ps → Prop} (pt : PlacedTile ps)\n (h : ∀ i : ιₚ, ∀ gx : G, ppt ⟨i, gx⟩) : ppt pt := by\n rcases pt with ⟨i, gx⟩\n induction gx using Quotient.inductionOn\n apply h\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using existence of a\ncommon group element. -/\nlemma ext_iff_of_exists {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧ ∃ g, ⟦g⟧ = pt₁.groupElts ∧ ⟦g⟧ = pt₂.groupElts := by\n refine ⟨fun h ↦ ?_, fun ⟨h, g, hg₁, hg₂⟩ ↦ ?_⟩\n · subst h\n simp only [and_self, true_and]\n refine ⟨pt₁.groupElts.out, ?_⟩\n rw [Quotient.out_eq]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at h\n subst h\n ext\n · rfl\n · exact heq_of_eq (hg₁.symm.trans hg₂)\n\n/-- An alternative extensionality principle for `PlacedTile` that avoids `HEq`, using equality of\nquotient preimages. -/\nlemma ext_iff_of_preimage {pt₁ pt₂ : PlacedTile ps} :\n pt₁ = pt₂ ↔ pt₁.index = pt₂.index ∧\n (Quotient.mk _) ⁻¹' {pt₁.groupElts} = (Quotient.mk _) ⁻¹' {pt₂.groupElts} := by\n refine ⟨fun h ↦ ?_, fun ⟨hi, hq⟩ ↦ ?_⟩\n · subst h\n simp only [and_self]\n · rcases pt₁ with ⟨i₁, g₁⟩\n rcases pt₂ with ⟨i₂, g₂⟩\n dsimp only at hi\n subst hi\n ext\n · rfl\n · exact heq_of_eq (Set.singleton_eq_singleton_iff.1\n ((Set.preimage_eq_preimage Quotient.mk''_surjective).1 hq))\n\n/-- Coercion from a `PlacedTile` to a set of points. Use the coercion rather than using `coeSet`\ndirectly. -/\n@[coe] def coeSet (pt : PlacedTile ps) : Set X :=\n Quotient.liftOn' pt.groupElts (fun g ↦ g • (ps pt.index : Set X))\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n rw [eq_comm, ← inv_smul_eq_iff, smul_smul, ← MulAction.mem_stabilizer_iff]\n exact SetLike.le_def.1 (Subgroup.map_subtype_le _) r\n\ninstance : CoeOut (PlacedTile ps) (Set X) where\n coe := coeSet\n\ninstance : Membership X (PlacedTile ps) where\n mem p x := x ∈ (p : Set X)\n\n@[simp] lemma mem_coe {x : X} {pt : PlacedTile ps} : x ∈ (pt : Set X) ↔ x ∈ pt := Iff.rfl\n\nlemma coe_mk_mk (i : ιₚ) (g : G) : (⟨i, ⟦g⟧⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_mk_coe (i : ιₚ) (g : G) : (⟨i, g⟩ : PlacedTile ps) = g • (ps i : Set X) := rfl\n\nlemma coe_nonempty_iff {pt : PlacedTile ps} :\n (pt : Set X).Nonempty ↔ (ps pt.index : Set X).Nonempty := by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp\n\n@[simp] lemma coe_mk_nonempty_iff {i : ιₚ} (g) :\n ((⟨i, g⟩ : PlacedTile ps) : Set X).Nonempty ↔ (ps i : Set X).Nonempty :=\n coe_nonempty_iff\n\nlemma coe_finite_iff {pt : PlacedTile ps} :\n (pt : Set X).Finite ↔ (ps pt.index : Set X).Finite := by\n rcases pt with ⟨index, groupElts⟩\n simp only [coeSet]\n rw [← groupElts.out_eq', Quotient.liftOn'_mk'']\n simp\n\n@[simp] lemma coe_mk_finite_iff {i : ιₚ} (g) :\n ((⟨i, g⟩ : PlacedTile ps) : Set X).Finite ↔ (ps i : Set X).Finite :=\n coe_finite_iff\n\ninstance : SMul G (PlacedTile ps) where\n smul g pt := Quotient.liftOn' pt.groupElts (fun h ↦ ⟨pt.index, g * h⟩)\n fun a b r ↦ by\n rw [QuotientGroup.leftRel_eq] at r\n refine PlacedTile.ext rfl ?_\n simpa [QuotientGroup.eq, ← mul_assoc] using r\n\n@[simp] lemma smul_mk_mk (g h : G) (i : ιₚ) : g • (⟨i, ⟦h⟧⟩ : PlacedTile ps) = ⟨i, g * h⟩ := rfl\n\n@[simp] lemma smul_mk_coe (g h : G) (i : ιₚ) : g • (⟨i, h⟩ : PlacedTile ps) = ⟨i, g * h⟩ := rfl\n\n@[simp] lemma smul_index (g : G) (pt : PlacedTile ps) : (g • pt).index = pt.index := by\n induction pt using PlacedTile.induction_on\n rfl\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp] lemma coe_smul (g : G) (pt : PlacedTile ps) :\n (g • pt : PlacedTile ps) = g • (pt : Set X) := by\n induction pt using PlacedTile.induction_on\n simp [coeSet, mul_smul]\n\ninstance : MulAction G (PlacedTile ps) where\n __ : SMul G (PlacedTile ps) := inferInstance\n one_smul pt := by\n induction pt using PlacedTile.induction_on\n simp\n mul_smul x y pt := by\n induction pt using PlacedTile.induction_on\n simp [mul_assoc]\n\n@[simp] lemma smul_mem_smul_iff (g : G) {x : X} {pt : PlacedTile ps} : g • x ∈ g • pt ↔ x ∈ pt := by\n rw [← mem_coe, coe_smul, Set.smul_mem_smul_set_iff, mem_coe]\n\nlemma mem_smul_iff_smul_inv_mem {g : G} {x : X} {pt : PlacedTile ps} :\n x ∈ g • pt ↔ g⁻¹ • x ∈ pt := by\n simp_rw [← mem_coe, coe_smul, Set.mem_smul_set_iff_inv_smul_mem]\n\nTarget:\nlemma mem_inv_smul_iff_smul_mem {g : G} {x : X} {pt : PlacedTile ps} :\n x ∈ g⁻¹ • pt ↔ g • x ∈ pt :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_3a5018e6c156","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a7dc72c1221d999f1beed31a69e4e94ce118d5505ebb4e8d7844ed8d5391025c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Tiling","family_id":"mem_inv_smul_iff_smul_mem","file_id":"mathlib/Mathlib/Combinatorics/Tiling/Tile.lean","sample_id":"3a5018e6c1566751dbdf9f58dd1239c8644e55701a13fb33847400d3465f55c4"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"411a5bfe7dfec463be4c77a8daf57a2d4eb6f232a55e44356ce54600db8f639f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9648fbea398684421d97b4a243c69910d96408272f4d0818f549a44c2cd46c30","source_sha256":"fc0ac08ee048884ba7583061a8f6eb20240cc276d11413f308115f01831f8e03","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n by_cases hRS : Function.Injective (algebraMap R S)\n on_goal 2 => exact (Algebra.isAlgebraic_of_not_injective\n fun h ↦ hRS <| .of_comp (IsScalarTower.algebraMap_eq R S A ▸ h)).1 _\n have := hRS.noZeroDivisors _ (map_zero _) (map_mul _)\n have ⟨s, hs, int_s⟩ := h.exists_integral_multiple\n cases subsingleton_or_nontrivial R\n · have := Module.subsingleton R S\n exact (is_transcendental_of_subsingleton _ _ h).elim\n have ⟨r, hr, _, e⟩ := (int.1 s).isAlgebraic.exists_nonzero_dvd (mem_nonZeroDivisors_of_ne_zero hs)\n refine .of_smul_isIntegral (y := r) (by rwa [isNilpotent_iff_eq_zero]) ?_\n rw [Algebra.smul_def, IsScalarTower.algebraMap_apply R S,\n e, ← Algebra.smul_def, mul_comm, mul_smul]\n exact isIntegral_trans _ (int_s.smul _)","hard_negative":true,"metrics":{"chosen_tokens":162,"rejected_tokens":8,"token_jaccard":0.053333,"token_length_ratio":0.049383},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"8813f98d9dd07c54638d6d06108bbee50ed7d99dba8ad12af2a670af2beda879","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.Dimension.Localization\npublic import Mathlib.RingTheory.Algebraic.Basic\npublic import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic\npublic import Mathlib.RingTheory.Localization.BaseChange\nimport Mathlib.RingTheory.Polynomial.Subring\n\nNamespace:\nIsAlgebraic\n\nLocal context:\n/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Algebraic elements and integral elements\n\nThis file relates algebraic and integral elements of an algebra, by proving every integral element\nis algebraic and that every algebraic element over a field is integral.\n\n## Main results\n\n* `IsIntegral.isAlgebraic`, `Algebra.IsIntegral.isAlgebraic`: integral implies algebraic.\n* `isAlgebraic_iff_isIntegral`, `Algebra.isAlgebraic_iff_isIntegral`: integral iff algebraic\n over a field.\n* `IsAlgebraic.of_finite`, `Algebra.IsAlgebraic.of_finite`: finite-dimensional (as module) implies\n algebraic.\n* `IsAlgebraic.exists_integral_multiple`: an algebraic element has a multiple which is integral\n* `IsAlgebraic.iff_exists_smul_integral`: If `R` is reduced and `S` is an `R`-algebra with\n injective `algebraMap`, then an element of `S` is algebraic over `R` iff some `R`-multiple\n is integral over `R`.\n* `Algebra.IsAlgebraic.trans`: If `A/S/R` is a tower of algebras and both `A/S` and `S/R` are\n algebraic, then `A/R` is also algebraic, provided that `S` has no zero divisors.\n* `Subalgebra.algebraicClosure`: If `R` is a domain and `S` is an arbitrary `R`-algebra,\n then the elements of `S` that are algebraic over `R` form a subalgebra.\n* `Transcendental.extendScalars`: an element of an `R`-algebra that is transcendental over `R`\n remains transcendental over any algebraic `R`-subalgebra that has no zero divisors.\n-/\n\n@[expose] public section\n\nassert_not_exists IsLocalRing\n\nuniverse u v w\n\nopen Polynomial\n\nsection zero_ne_one\n\nvariable {R : Type u} {S : Type*} {A : Type v} [CommRing R]\nvariable [CommRing S] [Ring A] [Algebra R A] [Algebra R S] [Algebra S A]\nvariable [IsScalarTower R S A]\n\n/-- An integral element of an algebra is algebraic. -/\ntheorem IsIntegral.isAlgebraic [Nontrivial R] {x : A} : IsIntegral R x → IsAlgebraic R x :=\n fun ⟨p, hp, hpx⟩ => ⟨p, hp.ne_zero, hpx⟩\n\ninstance Algebra.IsIntegral.isAlgebraic [Nontrivial R] [Algebra.IsIntegral R A] :\n Algebra.IsAlgebraic R A := ⟨fun a ↦ (Algebra.IsIntegral.isIntegral a).isAlgebraic⟩\n\nend zero_ne_one\n\nsection Field\n\nvariable {K : Type u} {A : Type v} [Field K] [Ring A] [Algebra K A]\n\n/-- An element of an algebra over a field is algebraic if and only if it is integral. -/\ntheorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by\n refine ⟨?_, IsIntegral.isAlgebraic⟩\n rintro ⟨p, hp, hpx⟩\n refine ⟨_, monic_mul_leadingCoeff_inv hp, ?_⟩\n rw [← aeval_def, map_mul, hpx, zero_mul]\n\nprotected theorem Algebra.isAlgebraic_iff_isIntegral :\n Algebra.IsAlgebraic K A ↔ Algebra.IsIntegral K A := by\n rw [Algebra.isAlgebraic_def, Algebra.isIntegral_def,\n forall_congr' fun _ ↦ isAlgebraic_iff_isIntegral]\n\nalias ⟨IsAlgebraic.isIntegral, _⟩ := isAlgebraic_iff_isIntegral\n\n/-- This used to be an `alias` of `Algebra.isAlgebraic_iff_isIntegral` but that would make\n`Algebra.IsAlgebraic K A` an explicit parameter instead of instance implicit. -/\nprotected instance Algebra.IsAlgebraic.isIntegral [Algebra.IsAlgebraic K A] :\n Algebra.IsIntegral K A := Algebra.isAlgebraic_iff_isIntegral.mp ‹_›\n\ntheorem Algebra.IsAlgebraic.of_isIntegralClosure (R B C : Type*) [CommRing R] [Nontrivial R]\n [CommRing B] [CommRing C] [Algebra R B] [Algebra R C] [Algebra B C]\n [IsScalarTower R B C] [IsIntegralClosure B R C] : Algebra.IsAlgebraic R B :=\n have := IsIntegralClosure.isIntegral_algebra R (A := B) C\n inferInstance\n\nend Field\n\nsection\n\nvariable (K L R : Type*) {A : Type*}\n\nsection Ring\n\nvariable [CommRing R] [Nontrivial R] [Ring A] [Algebra R A]\n\ntheorem IsAlgebraic.of_finite (e : A) [Module.Finite R A] : IsAlgebraic R e :=\n (IsIntegral.of_finite R e).isAlgebraic\n\nvariable (A)\n\n/-- A field extension is algebraic if it is finite. -/\n@[stacks 09GG \"first part\"]\ninstance Algebra.IsAlgebraic.of_finite [Module.Finite R A] : Algebra.IsAlgebraic R A :=\n (IsIntegral.of_finite R A).isAlgebraic\n\nend Ring\n\nsection Field\n\nvariable {K L} [Field K] [Ring A] [Algebra K A]\n\n/-- If `K` is a field, `r : A` and `f : K[X]`, then `Polynomial.aeval r f` is\ntranscendental over `K` if and only if `r` and `f` are both transcendental over `K`.\nSee also `Transcendental.aeval_of_transcendental` and `Transcendental.of_aeval`. -/\n@[simp]\ntheorem transcendental_aeval_iff {r : A} {f : K[X]} :\n Transcendental K (Polynomial.aeval r f) ↔ Transcendental K r ∧ Transcendental K f := by\n refine ⟨fun h ↦ ⟨?_, h.of_aeval⟩, fun ⟨h1, h2⟩ ↦ h1.aeval_of_transcendental h2⟩\n rw [Transcendental] at h ⊢\n contrapose h\n rw [isAlgebraic_iff_isIntegral] at h ⊢\n exact .of_mem_of_fg _ h.fg_adjoin_singleton _ (aeval_mem_adjoin_singleton _ _)\n\nvariable [Field L] [Algebra K L]\n\ntheorem AlgHom.bijective [FiniteDimensional K L] (ϕ : L →ₐ[K] L) : Function.Bijective ϕ :=\n (Algebra.IsAlgebraic.of_finite K L).algHom_bijective ϕ\n\nvariable (K L) in\n/-- Bijection between algebra equivalences and algebra homomorphisms -/\nnoncomputable abbrev algEquivEquivAlgHom [FiniteDimensional K L] :\n (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) :=\n Algebra.IsAlgebraic.algEquivEquivAlgHom K L\n\nend Field\n\nend\n\nvariable {R S A : Type*} [CommRing R] [CommRing S] [Ring A]\nvariable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A]\nvariable {z : A} {z' : S}\n\nnamespace IsAlgebraic\n\ntheorem exists_integral_multiple (hz : IsAlgebraic R z) : ∃ y ≠ (0 : R), IsIntegral R (y • z) := by\n by_cases inj : Function.Injective (algebraMap R A); swap\n · rw [injective_iff_map_eq_zero] at inj; push Not at inj\n have ⟨r, eq, ne⟩ := inj\n exact ⟨r, ne, by simpa [← algebraMap_smul A, eq, zero_smul] using isIntegral_zero⟩\n have ⟨p, p_ne_zero, px⟩ := hz\n set a := p.leadingCoeff\n have a_ne_zero : a ≠ 0 := mt Polynomial.leadingCoeff_eq_zero.mp p_ne_zero\n have x_integral : IsIntegral R (algebraMap R A a * z) :=\n ⟨p.integralNormalization, monic_integralNormalization p_ne_zero,\n integralNormalization_aeval_eq_zero px fun _ ↦ (map_eq_zero_iff _ inj).mp⟩\n exact ⟨_, a_ne_zero, Algebra.smul_def a z ▸ x_integral⟩\n\nvariable (R) in\ntheorem _root_.Algebra.IsAlgebraic.exists_integral_multiples [NoZeroDivisors R]\n [alg : Algebra.IsAlgebraic R A] (s : Finset A) :\n ∃ y ≠ (0 : R), ∀ z ∈ s, IsIntegral R (y • z) := by\n have := Algebra.IsAlgebraic.nontrivial R A\n choose r hr int using fun x ↦ (alg.1 x).exists_integral_multiple\n refine ⟨∏ x ∈ s, r x, Finset.prod_ne_zero_iff.mpr fun _ _ ↦ hr _, fun _ h ↦ ?_⟩\n classical rw [← Finset.prod_erase_mul _ _ h, mul_smul]\n exact (int _).smul _\n\ntheorem of_smul_isIntegral {y : R} (hy : ¬ IsNilpotent y)\n (h : IsIntegral R (y • z)) : IsAlgebraic R z := by\n have ⟨p, monic, eval0⟩ := h\n refine ⟨p.comp (C y * X), fun h ↦ ?_, by simpa [aeval_comp, Algebra.smul_def] using! eval0⟩\n apply_fun (coeff · p.natDegree) at h\n have hy0 : y ≠ 0 := by rintro rfl; exact hy .zero\n rw [coeff_zero, ← mul_one p.natDegree, ← natDegree_C_mul_X y hy0,\n coeff_comp_degree_mul_degree, monic, one_mul, leadingCoeff_C_mul_X] at h\n · exact hy ⟨_, h⟩\n · rw [natDegree_C_mul_X _ hy0]; rintro ⟨⟩\n\ntheorem of_smul {y : R} (hy : y ∈ nonZeroDivisors R)\n (h : IsAlgebraic R (y • z)) : IsAlgebraic R z :=\n have ⟨p, hp, eval0⟩ := h\n ⟨_, mt (comp_C_mul_X_eq_zero_iff hy).mp hp, by simpa [aeval_comp, Algebra.smul_def] using eval0⟩\n\ntheorem iff_exists_smul_integral [IsReduced R] :\n IsAlgebraic R z ↔ ∃ y ≠ (0 : R), IsIntegral R (y • z) :=\n ⟨(exists_integral_multiple ·), fun ⟨_, hy, int⟩ ↦\n of_smul_isIntegral (by rwa [isNilpotent_iff_eq_zero]) int⟩\n\nsection integralClosure\n\nvariable {K : Type*} [CommRing K] [Algebra S K] [Algebra R K] [IsIntegralClosure S R K]\n\nvariable (S)\n\nomit [Algebra R S] in\n/-- If `x : K` is algebraic over some ring `R`, then a nonzero `R`-multiple of it is contained\nin the integral closure of `R` in `K`. -/\nlemma exists_smul_eq {x : K} (hx : IsAlgebraic R x) :\n ∃ (r : R) (s : S), r ≠ 0 ∧ r • x = algebraMap S K s := by\n obtain ⟨r, hr, h⟩ := hx.exists_integral_multiple\n obtain ⟨s, hs⟩ := IsIntegralClosure.isIntegral_iff (A := S) |>.mp h\n exact ⟨r, s, hr, hs.symm⟩\n\n/-- If `x : K` is algebraic over `ℤ`, then a nonzero `ℕ`-multiple of it is contained in the\nintegral closure of `ℤ` in `K`. -/\nlemma exists_nsmul_eq [IsIntegralClosure S ℤ K] {x : K} (hx : IsAlgebraic ℤ x) :\n ∃ (m : ℕ) (s : S), m ≠ 0 ∧ m • x = algebraMap S K s := by\n obtain ⟨a, s, ha, h⟩ := hx.exists_smul_eq S\n obtain ⟨n, rfl | rfl⟩ := a.eq_nat_or_neg\n · exact ⟨n, s, mod_cast ha, mod_cast h⟩\n · exact ⟨n, -s, by simpa using ha, by simp [← h]⟩\n\nend integralClosure\n\nsection restrictScalars\n\nvariable (R) [NoZeroDivisors S]\n\n/-!\nThe next theorem may fail if only `R` is assumed to be a domain but `S` is not: for example, let\n`S = R[X] ⧸ (X² - X)` and let `A` be the subalgebra of `S[Y]` generated by `XY`.\n`A` is algebraic over `S` because any element `∑ᵢ sᵢ(XY)ⁱ` is a root of the polynomial\n`(X - 1)(Z - s₀)` in `S[Z]`, because `X(X - 1) = X² - X = 0` in `S`.\nHowever, `XY` is a transcendental element in `A` over `R`, because `∑ᵢ rᵢ(XY)ⁱ = 0` in `S[Y]`\nimplies all `rᵢXⁱ = 0` (i.e., `r₀ = 0` and `rᵢX = 0` for `i > 0`) in `S`,\nwhich implies `rᵢ = 0` in `R`. This example is inspired by the comment\nhttps://mathoverflow.net/questions/482944/when-do-algebraic-elements-form-a-subalgebra#comment1257632_482944. -/\n\nTarget:\ntheorem restrictScalars_of_isIntegral [int : Algebra.IsIntegral R S]\n {a : A} (h : IsAlgebraic S a) : IsAlgebraic R a :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"ff1a46b704f82ed3ffc056edbbcbb597b420ec2d4fc818cbe7cc6da9f323d652","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Algebraic","family_id":"restrictscalars_of_isintegral","file_id":"mathlib/Mathlib/RingTheory/Algebraic/Integral.lean","sample_id":"9648fbea398684421d97b4a243c69910d96408272f4d0818f549a44c2cd46c30"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d6511976df7e33b01f5be5817df063fa6f90f8ea751edc85352d73d9680330a5","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"58a167ae94ce0ada3e21225e94dbd281eb6ba283434cb9eca7cb26f5063d76dd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f5726a7b2cb27007273d6cba2c3dd38b66525c1fe46302d591cb944f321877e0","source_sha256":"a61ca7aaba44c7a3be6f604ec88e48f92b91afdcb314b3da2da645358b30973a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ h1 p₀,\n weightedVSubOfPoint_apply, dist_vadd_left]\n simp_rw [dist_eq_norm_vsub] at hp\n exact norm_sum_lt_of_strictConvexSpace h0 h1 hi hj (by simpa using hij) hi0 hj0 hp","hard_negative":true,"metrics":{"chosen_tokens":36,"rejected_tokens":3,"token_jaccard":0.068966,"token_length_ratio":0.083333},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"8923ea92b4fc50c0a2081e140430b456c800477c80e0765fe6181a09691bfc8b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Convex.StrictConvexSpace\npublic import Mathlib.Analysis.Normed.Group.AddTorsor\npublic import Mathlib.LinearAlgebra.AffineSpace.Simplex.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Convex combinations in strictly convex sets and spaces.\n\nThis file proves lemmas about convex combinations of points in strictly convex sets and strictly\nconvex spaces.\n\n-/\n\npublic section\n\n\nopen Finset Metric\n\nvariable {R V P ι : Type*}\n\nsection Set\n\nvariable [Field R] [LinearOrder R] [IsStrictOrderedRing R] [TopologicalSpace V] [AddCommGroup V]\nvariable [Module R V]\n\nlemma StrictConvex.centerMass_mem_interior {s : Set V} {t : Finset ι} {w : ι → R} {z : ι → V}\n (hs : StrictConvex R s) :\n (∀ i ∈ t, 0 ≤ w i) → ∀ i j, i ∈ t → j ∈ t → z i ≠ z j → w i ≠ 0 → w j ≠ 0 →\n (∀ i ∈ t, z i ∈ s) → t.centerMass w z ∈ interior s := by\n classical\n induction t using Finset.induction with\n | empty => simp\n | insert i t hi ht =>\n intro h₀ i' j' hi' hj' hi'j' hi'0 hj'0 hmem\n have zi : z i ∈ s := hmem _ (mem_insert_self _ _)\n have hs₀ : ∀ j ∈ t, 0 ≤ w j := fun j hj => h₀ j <| mem_insert_of_mem hj\n by_cases hsum_t : ∑ j ∈ t, w j = 0\n · have ws : ∀ j ∈ t, w j = 0 := (sum_eq_zero_iff_of_nonneg hs₀).1 hsum_t\n have h : i' ∈ t ∨ j' ∈ t := by grind\n exfalso\n rcases h with h | h\n · exact hi'0 (ws _ h)\n · exact hj'0 (ws _ h)\n rw [Finset.centerMass_insert _ _ _ hi hsum_t]\n by_cases hi : w i = 0\n · simp only [hi, zero_add, zero_div, zero_smul, ne_eq, hsum_t, not_false_eq_true, div_self,\n one_smul]\n grind\n by_cases hzi : z i = t.centerMass w z\n · have hwi : w i + ∑ j ∈ t, w j ≠ 0 := by\n refine LT.lt.ne' ?_\n have hwi : 0 < w i := by grind\n grw [hwi]\n simp only [lt_add_iff_pos_right]\n exact (sum_nonneg hs₀).lt_of_ne' hsum_t\n simp only [hzi, ← add_smul, ← add_div, ne_eq, hwi, not_false_eq_true, div_self, one_smul]\n by_cases! hijt : ∃ i'' j'', i'' ∈ t ∧ j'' ∈ t ∧ z i'' ≠ z j'' ∧ w i'' ≠ 0 ∧ w j'' ≠ 0\n · grind\n · exfalso\n obtain ⟨i'', hi'', hwi''⟩ : ∃ i'' ∈ t, w i'' ≠ 0 := by grind\n have hijt' : ∀ j'', j'' ∈ t → w j'' ≠ 0 → z j'' = Function.const _ (z i'') j'' := by\n grind\n have hi : i = i' ∨ i = j' := by grind\n have hzi'' : t.centerMass w z = z i'' := by\n rw [t.centerMass_congr_fun hijt', t.centerMass_const hsum_t]\n grind\n · exact strictConvex_iff_div.1 hs zi\n (hs.convex.centerMass_mem hs₀ (lt_of_le_of_ne (sum_nonneg hs₀) (Ne.symm hsum_t))\n (fun j hj ↦ hmem j (mem_insert_of_mem hj))) hzi (by grind)\n ((sum_nonneg hs₀).lt_of_ne' hsum_t)\n\nlemma StrictConvex.sum_mem_interior {s : Set V} {t : Finset ι} {w : ι → R} {z : ι → V}\n (hs : StrictConvex R s) (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι}\n (hi : i ∈ t) (hj : j ∈ t) (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0)\n (hz : ∀ i ∈ t, z i ∈ s) : ∑ k ∈ t, w k • z k ∈ interior s := by\n rw [← t.centerMass_eq_of_sum_1 _ h1]\n exact hs.centerMass_mem_interior h0 i j hi hj hij hi0 hj0 hz\n\nend Set\n\nsection Space\n\nvariable [NormedAddCommGroup V] [NormedSpace ℝ V] [StrictConvexSpace ℝ V]\n\nlemma centerMass_mem_ball_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p : V} {r : ℝ}\n {z : ι → V} (h0 : ∀ i ∈ t, 0 ≤ w i) {i j : ι} (hi : i ∈ t) (hj : j ∈ t) (hij : z i ≠ z j)\n (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, z i ∈ closedBall p r) :\n t.centerMass w z ∈ ball p r := by\n rcases eq_or_ne r 0 with (rfl | hr)\n · simp_all\n · rw [← interior_closedBall _ hr]\n exact (strictConvex_closedBall _ _ _).centerMass_mem_interior h0 i j hi hj hij hi0 hj0 hz\n\nlemma sum_mem_ball_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p : V} {r : ℝ} {z : ι → V}\n (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t) (hj : j ∈ t)\n (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, z i ∈ closedBall p r) :\n ∑ k ∈ t, w k • z k ∈ ball p r := by\n rw [← t.centerMass_eq_of_sum_1 _ h1]\n exact centerMass_mem_ball_of_strictConvexSpace h0 hi hj hij hi0 hj0 hz\n\nlemma norm_sum_lt_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {r : ℝ} {z : ι → V}\n (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t) (hj : j ∈ t)\n (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, ‖z i‖ ≤ r) :\n ‖∑ k ∈ t, w k • z k‖ < r := by\n simp_rw [← mem_closedBall_zero_iff] at hz\n rw [← mem_ball_zero_iff]\n exact sum_mem_ball_of_strictConvexSpace h0 h1 hi hj hij hi0 hj0 hz\n\nvariable [PseudoMetricSpace P] [NormedAddTorsor V P]\n\nTarget:\nlemma dist_affineCombination_lt_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p₀ : P} {r : ℝ}\n {p : ι → P} (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t)\n (hj : j ∈ t) (hij : p i ≠ p j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0)\n (hp : ∀ i ∈ t, dist (p i) p₀ ≤ r) :\n dist (t.affineCombination ℝ p w) p₀ < r :=\n\nProof body:\n","rejected":"by\n exact dist_affineCombination_lt_of_strictConvexSpace","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"bf00b5475a4cc225c8e271df687686c89f9c4a850a04a68258c3200998b6e4da","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Convex","family_id":"dist_affinecombination_lt_of_strictconvexspace","file_id":"mathlib/Mathlib/Analysis/Convex/StrictCombination.lean","sample_id":"f5726a7b2cb27007273d6cba2c3dd38b66525c1fe46302d591cb944f321877e0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7c0c52b15fb2f94fa2a802697aa2899dd41c24e1f114cafb8fd48cbfd3dc3e1c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"53651b5c475b1cb11c0ac0b467e7c6a6028c3ebbf94a6f92ff3b171fb44dd052","source_sha256":"b34eef023ab6ef628d571767fa05dc0fcdd990b68e93c669c9937c956b66c50d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← map_preimage_eq_image_map _ _ a, mk_image]","hard_negative":false,"metrics":{"chosen_tokens":11,"rejected_tokens":2,"token_jaccard":0.090909,"token_length_ratio":0.181818},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"896957f1eae29aa2aa8bc8e2c5311537ff57a4f2f2d3aca169f46b62a8915d92","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Insert\n\nNamespace:\nFunction.Fiber\n\nLocal context:\n/-\nCopyright (c) 2024 Dagur Asgeirsson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Dagur Asgeirsson\n-/\n/-!\n\nThis file defines the type `f.Fiber` of fibers of a function `f : Y → Z`, and provides some API\nto work with and construct terms of this type.\n\nNote: this API is designed to be useful when defining the counit of the adjunction between\nthe functor which takes a set to the condensed set corresponding to locally constant maps to that\nset, and the forgetful functor from the category of condensed sets to the category of sets\n(see PR https://github.com/leanprover-community/mathlib4/pull/14027).\n-/\n\n@[expose] public section\n\nassert_not_exists RelIso\n\nvariable {X Y Z : Type*}\n\nnamespace Function\n\n/-- The indexing set of the partition. -/\ndef Fiber (f : Y → Z) : Type _ := Set.range (fun (x : Set.range f) ↦ f ⁻¹' {x.val})\n\nnamespace Fiber\n\n/--\nAny `a : Fiber f` is of the form `f ⁻¹' {x}` for some `x` in the image of `f`. We define `a.image`\nas an arbitrary such `x`.\n-/\nnoncomputable def image (f : Y → Z) (a : Fiber f) : Z := a.2.choose.1\n\nlemma eq_fiber_image (f : Y → Z) (a : Fiber f) : a.1 = f ⁻¹' {a.image} := a.2.choose_spec.symm\n\n/--\nGiven `y : Y`, `Fiber.mk f y` is the fiber of `f` that `y` belongs to, as an element of `Fiber f`.\n-/\ndef mk (f : Y → Z) (y : Y) : Fiber f := ⟨f ⁻¹' {f y}, by simp⟩\n\n/-- `y : Y` as a term of the type `Fiber.mk f y` -/\ndef mkSelf (f : Y → Z) (y : Y) : (mk f y).val := ⟨y, rfl⟩\n\nlemma map_eq_image (f : Y → Z) (a : Fiber f) (x : a.1) : f x = a.image := by\n have := a.2.choose_spec\n rw [← Set.mem_singleton_iff, ← Set.mem_preimage]\n convert! x.prop\n\nlemma mk_image (f : Y → Z) (y : Y) : (Fiber.mk f y).image = f y :=\n (map_eq_image (x := mkSelf f y)).symm\n\nlemma mem_iff_eq_image (f : Y → Z) (y : Y) (a : Fiber f) : y ∈ a.val ↔ f y = a.image :=\n ⟨fun h ↦ a.map_eq_image _ ⟨y, h⟩, fun h ↦ by rw [a.eq_fiber_image]; exact h⟩\n\n/-- An arbitrary element of `a : Fiber f`. -/\nnoncomputable def preimage (f : Y → Z) (a : Fiber f) : Y := a.2.choose.2.choose\n\nlemma map_preimage_eq_image (f : Y → Z) (a : Fiber f) : f a.preimage = a.image :=\n a.2.choose.2.choose_spec\n\nlemma fiber_nonempty (f : Y → Z) (a : Fiber f) : Set.Nonempty a.val := by\n refine ⟨preimage f a, ?_⟩\n rw [mem_iff_eq_image, ← map_preimage_eq_image]\n\nlemma map_preimage_eq_image_map {W : Type*} (f : Y → Z) (g : Z → W) (a : Fiber (g ∘ f)) :\n g (f a.preimage) = a.image := by rw [← map_preimage_eq_image, comp_apply]\n\nTarget:\nlemma image_eq_image_mk (f : Y → Z) (g : X → Y) (a : Fiber (f ∘ g)) :\n a.image = (Fiber.mk f (g (a.preimage _))).image :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Function","family_id":"image_eq_image_mk","file_id":"mathlib/Mathlib/Logic/Function/FiberPartition.lean","sample_id":"53651b5c475b1cb11c0ac0b467e7c6a6028c3ebbf94a6f92ff3b171fb44dd052"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"15a9473f1155664d5857c91af11e1c2b9dce6d1c4264e93243e8a452450cf472","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a3e87275df696e9de385e5e1e4e98515585b397b78c578d3231872b0510fb66f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"13761ac07584773ef45f8b932e4b9f0e9de357d763e2a247f2b92df80cf1b745","source_sha256":"1cc189218e3cc07e383205c72ab25062d8480a810582580bf68ae9b7f20cf48f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n -- A useful inequality to keep at hand\n have me0 : 0 < max (1 / ε) M := lt_max_iff.mpr (Or.inl (one_div_pos.mpr e0))\n -- The maximum between `1 / ε` and `M` works\n refine ⟨max (1 / ε) M, me0, fun z a => ?_⟩\n -- First, let's deal with the easy case in which we are far away from `α`\n by_cases dm1 : 1 ≤ dist α (j z a) * max (1 / ε) M\n · exact one_le_mul_of_one_le_of_one_le (d0 a) dm1\n · -- `j z a = z / (a + 1)`: we prove that this ratio is close to `α`\n have : j z a ∈ closedBall α ε := by\n refine mem_closedBall'.mp (le_trans ?_ ((one_div_le me0 e0).mpr (le_max_left _ _)))\n exact (le_div_iff₀ me0).mpr (not_le.mp dm1).le\n -- use the \"separation from `1`\" (assumption `L`) for numerators,\n refine (L this).trans ?_\n -- remove a common factor and use the Lipschitz assumption `B`\n gcongr\n · exact zero_le_one.trans (d0 a)\n · refine (B this).trans ?_\n gcongr\n apply le_max_right","hard_negative":true,"metrics":{"chosen_tokens":263,"rejected_tokens":5,"token_jaccard":0.027778,"token_length_ratio":0.019011},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"899153dd1af6afccb1721a228956accb8e31be37923b0e9d8a8e3f3574cf0067","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Polynomial.DenomsClearable\npublic import Mathlib.Analysis.Calculus.MeanValue\npublic import Mathlib.Analysis.Calculus.Deriv.Polynomial\npublic import Mathlib.NumberTheory.Real.Irrational\npublic import Mathlib.Topology.Algebra.Polynomial\nimport Mathlib.Algebra.Order.Interval.Set.Group\n\nNamespace:\nLiouville\n\nLocal context:\n/-\nCopyright (c) 2020 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damiano Testa, Jujian Zhang\n-/\n/-!\n\n# Liouville's theorem\n\nThis file contains a proof of Liouville's theorem stating that all Liouville numbers are\ntranscendental.\n\nTo obtain this result, there is first a proof that Liouville numbers are irrational and two\ntechnical lemmas. These lemmas exploit the fact that a polynomial with integer coefficients\ntakes integer values at integers. When evaluating at a rational number, we can clear denominators\nand obtain precise inequalities that ultimately allow us to prove transcendence of\nLiouville numbers.\n-/\n\n@[expose] public section\n\n\n/-- A Liouville number is a real number `x` such that for every natural number `n`, there exist\n`a, b ∈ ℤ` with `1 < b` such that `0 < |x - a/b| < 1/bⁿ`.\nIn the implementation, the condition `x ≠ a/b` replaces the traditional equivalent `0 < |x - a/b|`.\n-/\ndef Liouville (x : ℝ) :=\n ∀ n : ℕ, ∃ a b : ℤ, 1 < b ∧ x ≠ a / b ∧ |x - a / b| < 1 / (b : ℝ) ^ n\n\nnamespace Liouville\n\nprotected theorem irrational {x : ℝ} (h : Liouville x) : Irrational x := by\n -- By contradiction, `x = a / b`, with `a ∈ ℤ`, `0 < b ∈ ℕ` is a Liouville number,\n rintro ⟨⟨a, b, bN0, cop⟩, rfl⟩\n -- clear up the mess of constructions of rationals\n rw [Rat.cast_mk'] at h\n -- Since `a / b` is a Liouville number, there are `p, q ∈ ℤ`, with `q1 : 1 < q`,∈\n -- `a0 : a / b ≠ p / q` and `a1 : |a / b - p / q| < 1 / q ^ (b + 1)`\n rcases h (b + 1) with ⟨p, q, q1, a0, a1⟩\n -- A few useful inequalities\n have qR0 : (0 : ℝ) < q := Int.cast_pos.mpr (zero_lt_one.trans q1)\n have b0 : (b : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr bN0\n have bq0 : (0 : ℝ) < b * q := mul_pos (Nat.cast_pos.mpr bN0.bot_lt) qR0\n -- At a1, clear denominators...\n replace a1 : |a * q - b * p| * q ^ (b + 1) < b * q := by\n rw [div_sub_div _ _ b0 qR0.ne', abs_div, div_lt_div_iff₀ (abs_pos.mpr bq0.ne') (pow_pos qR0 _),\n abs_of_pos bq0, one_mul] at a1\n exact mod_cast a1\n -- At a0, clear denominators...\n replace a0 : a * q - ↑b * p ≠ 0 := by\n rw [Ne, div_eq_div_iff b0 qR0.ne', mul_comm (p : ℝ), ← sub_eq_zero] at a0\n exact mod_cast a0\n -- Actually, `q` is a natural number\n lift q to ℕ using (zero_lt_one.trans q1).le\n -- Looks innocuous, but we now have an integer with non-zero absolute value: this is at\n -- least one away from zero. The gain here is what gets the proof going.\n have ap : 0 < |a * ↑q - ↑b * p| := abs_pos.mpr a0\n -- Actually, the absolute value of an integer is a natural number\n -- FIXME: This `lift` call duplicates the hypotheses `a1` and `ap`\n lift |a * ↑q - ↑b * p| to ℕ using abs_nonneg (a * ↑q - ↑b * p) with e he\n norm_cast at a1 ap q1\n -- Recall this is by contradiction: we obtained the inequality `b * q ≤ x * q ^ (b + 1)`, so\n -- we are done.\n exact not_le.mpr a1 (Nat.mul_lt_mul_pow_succ ap q1).le\n\nopen Polynomial Metric Set Real RingHom\n\nopen scoped Polynomial\n\n/-- Let `Z, N` be types, let `R` be a metric space, let `α : R` be a point and let\n`j : Z → N → R` be a function. We aim to estimate how close we can get to `α`, while staying\nin the image of `j`. The points `j z a` of `R` in the image of `j` come with a \"cost\" equal to\n`d a`. As we get closer to `α` while staying in the image of `j`, we are interested in bounding\nthe quantity `d a * dist α (j z a)` from below by a strictly positive amount `1 / A`: the intuition\nis that approximating well `α` with the points in the image of `j` should come at a high cost. The\nhypotheses on the function `f : R → R` provide us with sufficient conditions to ensure our goal.\nThe first hypothesis is that `f` is Lipschitz at `α`: this yields a bound on the distance.\nThe second hypothesis is specific to the Liouville argument and provides the missing bound\ninvolving the cost function `d`.\n\nThis lemma collects the properties used in the proof of `exists_pos_real_of_irrational_root`.\nIt is stated in more general form than needed: in the intended application, `Z = ℤ`, `N = ℕ`,\n`R = ℝ`, `d a = (a + 1) ^ f.nat_degree`, `j z a = z / (a + 1)`, `f ∈ ℤ[x]`, `α` is an irrational\nroot of `f`, `ε` is small, `M` is a bound on the Lipschitz constant of `f` near `α`, `n` is\nthe degree of the polynomial `f`.\n-/\n\nTarget:\ntheorem exists_one_le_pow_mul_dist {Z N R : Type*} [PseudoMetricSpace R] {d : N → ℝ}\n {j : Z → N → R} {f : R → R} {α : R} {ε M : ℝ}\n -- denominators are positive\n (d0 : ∀ a : N, 1 ≤ d a)\n (e0 : 0 < ε)\n -- function is Lipschitz at α\n (B : ∀ ⦃y : R⦄, y ∈ closedBall α ε → dist (f α) (f y) ≤ dist α y * M)\n -- clear denominators\n (L : ∀ ⦃z : Z⦄, ∀ ⦃a : N⦄, j z a ∈ closedBall α ε → 1 ≤ d a * dist (f α) (f (j z a))) :\n ∃ A : ℝ, 0 < A ∧ ∀ z : Z, ∀ a : N, 1 ≤ d a * (dist α (j z a) * A) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_13761ac07584","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"44167e282e31c331dc592ac9c9f556716b7df949d00b6e2c97f7491abe58d760","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Transcendental","family_id":"exists_one_le_pow_mul_dist","file_id":"mathlib/Mathlib/NumberTheory/Transcendental/Liouville/Basic.lean","sample_id":"13761ac07584773ef45f8b932e4b9f0e9de357d763e2a247f2b92df80cf1b745"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5b68973d577a7df983355402c2b7ad133d41f3e14965e3a437184a500045ba4c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"08eb7982f363fc4703c08c5d24e59b2cd7584c8ae91ead88bb2524d4febf3516","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"493545b9c2069943f4007d11768a53e173a4fed3ce9a31371188b630f37911dd","source_sha256":"2e83127f408dd9b7499f56658794729b64a5f794f647d03785288fb13377bdec","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine Quot.addMonoidHom_ext F (fun j x ↦ ?_)\n rw [AddMonoidHom.comp_apply, ι_desc]\n change (c.ι.app j ≫ hc.desc (toCocone F f)) _ = _\n rw [hc.fac]\n simp","hard_negative":false,"metrics":{"chosen_tokens":51,"rejected_tokens":55,"token_jaccard":0.916667,"token_length_ratio":1.078431},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"8b76269a7cd30ea6b273ec742e7163a331e6447b8228261025c9ccce9d2f548a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Grp.Preadditive\npublic import Mathlib.Algebra.Group.Shrink\npublic import Mathlib.CategoryTheory.ConcreteCategory.Elementwise\npublic import Mathlib.Data.DFinsupp.BigOperators\npublic import Mathlib.Data.DFinsupp.Small\npublic import Mathlib.GroupTheory.QuotientGroup.Defs\n\nNamespace:\nAddCommGrpCat.Colimits\n\nLocal context:\n/-\nCopyright (c) 2019 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison, Sophie Morel\n-/\n/-!\n# The category of additive commutative groups has all colimits.\n\nThis file constructs colimits in the category of additive commutative groups, as\nquotients of finitely supported functions.\n\n-/\n\n@[expose] public section\n\nuniverse u' w u v\n\nopen CategoryTheory Limits\n\nnamespace AddCommGrpCat\n\nvariable {J : Type u} [Category.{v} J] (F : J ⥤ AddCommGrpCat.{w})\n\nnamespace Colimits\n\n/-!\nWe build the colimit of a diagram in `AddCommGrpCat` by constructing the\nfree group on the disjoint union of all the abelian groups in the diagram,\nthen taking the quotient by the abelian group laws within each abelian group,\nand the identifications given by the morphisms in the diagram.\n-/\n\n/--\nThe relations between elements of the direct sum of the `F.obj j` given by the\nmorphisms in the diagram `J`.\n-/\nabbrev Relations [DecidableEq J] : AddSubgroup (DFinsupp (fun j ↦ F.obj j)) :=\n AddSubgroup.closure {x | ∃ (j j' : J) (u : j ⟶ j') (a : F.obj j),\n x = DFinsupp.single j' (F.map u a) - DFinsupp.single j a}\n\n/--\nThe candidate for the colimit of `F`, defined as the quotient of the direct sum\nof the commutative groups `F.obj j` by the relations given by the morphisms in\nthe diagram.\n-/\ndef Quot [DecidableEq J] : Type (max u w) :=\n DFinsupp (fun j ↦ F.obj j) ⧸ Relations F\n\ninstance [DecidableEq J] : AddCommGroup (Quot F) :=\n QuotientAddGroup.Quotient.addCommGroup (Relations F)\n\n/-- Inclusion of `F.obj j` into the candidate colimit.\n-/\ndef Quot.ι [DecidableEq J] (j : J) : F.obj j →+ Quot F :=\n (QuotientAddGroup.mk' _).comp (DFinsupp.singleAddHom (fun j ↦ F.obj j) j)\n\nlemma Quot.addMonoidHom_ext [DecidableEq J] {α : Type*} [AddMonoid α] {f g : Quot F →+ α}\n (h : ∀ (j : J) (x : F.obj j), f (Quot.ι F j x) = g (Quot.ι F j x)) : f = g :=\n QuotientAddGroup.addMonoidHom_ext _ (DFinsupp.addHom_ext h)\n\nvariable (c : Cocone F)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- (implementation detail) Part of the universal property of the colimit cocone, but without\nassuming that `Quot F` lives in the correct universe. -/\ndef Quot.desc [DecidableEq J] : Quot.{w} F →+ c.pt := by\n refine QuotientAddGroup.lift _ (DFinsupp.sumAddHom fun x => (c.ι.app x).hom) ?_\n dsimp\n rw [AddSubgroup.closure_le]\n intro _ ⟨_, _, _, _, eq⟩\n rw [eq]\n simp only [SetLike.mem_coe, AddMonoidHom.mem_ker, map_sub, DFinsupp.sumAddHom_single]\n change (F.map _ ≫ c.ι.app _) _ - _ = 0\n rw [c.ι.naturality]\n simp only [Functor.const_obj_obj, Functor.const_obj_map, Category.comp_id, sub_self]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma Quot.ι_desc [DecidableEq J] (j : J) (x : F.obj j) :\n Quot.desc F c (Quot.ι F j x) = c.ι.app j x := by\n dsimp [desc, ι]\n erw [QuotientAddGroup.lift_mk']\n simp\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma Quot.map_ι [DecidableEq J] {j j' : J} {f : j ⟶ j'} (x : F.obj j) :\n Quot.ι F j' (F.map f x) = Quot.ι F j x := by\n dsimp [ι]\n refine eq_of_sub_eq_zero ?_\n erw [← (QuotientAddGroup.mk' (Relations F)).map_sub, ← AddMonoidHom.mem_ker]\n rw [QuotientAddGroup.ker_mk']\n simp only [DFinsupp.singleAddHom_apply]\n exact AddSubgroup.subset_closure ⟨j, j', f, x, rfl⟩\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/--\nThe obvious additive map from `Quot F` to `Quot (F ⋙ uliftFunctor.{u'})`.\n-/\ndef quotToQuotUlift [DecidableEq J] : Quot F →+ Quot (F ⋙ uliftFunctor.{u'}) := by\n refine QuotientAddGroup.lift (Relations F) (DFinsupp.sumAddHom (fun j ↦ (Quot.ι _ j).comp\n AddEquiv.ulift.symm.toAddMonoidHom)) ?_\n rw [AddSubgroup.closure_le]\n intro _ hx\n obtain ⟨j, j', u, a, rfl⟩ := hx\n rw [SetLike.mem_coe, AddMonoidHom.mem_ker, map_sub, DFinsupp.sumAddHom_single,\n DFinsupp.sumAddHom_single]\n change Quot.ι (F ⋙ uliftFunctor) j' ((F ⋙ uliftFunctor).map u (AddEquiv.ulift.symm a)) - _ = _\n rw [Quot.map_ι]\n dsimp\n rw [sub_self]\n\nlemma quotToQuotUlift_ι [DecidableEq J] (j : J) (x : F.obj j) :\n quotToQuotUlift F (Quot.ι F j x) = Quot.ι _ j (ULift.up x) := by\n dsimp [quotToQuotUlift, Quot.ι]\n conv_lhs => erw [AddMonoidHom.comp_apply (QuotientAddGroup.mk' (Relations F))\n (DFinsupp.singleAddHom _ j), QuotientAddGroup.lift_mk']\n simp only [DFinsupp.singleAddHom_apply, DFinsupp.sumAddHom_single, AddMonoidHom.coe_comp,\n Function.comp_apply]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/--\nThe obvious additive map from `Quot (F ⋙ uliftFunctor.{u'})` to `Quot F`.\n-/\ndef quotUliftToQuot [DecidableEq J] : Quot (F ⋙ uliftFunctor.{u'}) →+ Quot F := by\n refine QuotientAddGroup.lift (Relations (F ⋙ uliftFunctor))\n (DFinsupp.sumAddHom (fun j ↦ (Quot.ι _ j).comp AddEquiv.ulift.toAddMonoidHom)) ?_\n rw [AddSubgroup.closure_le]\n intro _ hx\n obtain ⟨j, j', u, a, rfl⟩ := hx\n simp\n\nlemma quotUliftToQuot_ι [DecidableEq J] (j : J) (x : (F ⋙ uliftFunctor.{u'}).obj j) :\n quotUliftToQuot F (Quot.ι _ j x) = Quot.ι F j x.down := by\n dsimp [quotUliftToQuot, Quot.ι]\n conv_lhs => erw [AddMonoidHom.comp_apply (QuotientAddGroup.mk' (Relations (F ⋙ uliftFunctor)))\n (DFinsupp.singleAddHom _ j), QuotientAddGroup.lift_mk']\n simp only [DFinsupp.singleAddHom_apply,\n DFinsupp.sumAddHom_single, AddMonoidHom.coe_comp, Function.comp_apply]\n rfl\n\n/--\nThe additive equivalence between `Quot F` and `Quot (F ⋙ uliftFunctor.{u'})`.\n-/\n@[simp]\ndef quotQuotUliftAddEquiv [DecidableEq J] : Quot F ≃+ Quot (F ⋙ uliftFunctor.{u'}) where\n toFun := quotToQuotUlift F\n invFun := quotUliftToQuot F\n left_inv x := by\n conv_rhs => rw [← AddMonoidHom.id_apply _ x]\n rw [← AddMonoidHom.comp_apply, Quot.addMonoidHom_ext F (f := (quotUliftToQuot F).comp\n (quotToQuotUlift F)) (fun j a ↦ ?_)]\n rw [AddMonoidHom.comp_apply, AddMonoidHom.id_apply, quotToQuotUlift_ι, quotUliftToQuot_ι]\n right_inv x := by\n conv_rhs => rw [← AddMonoidHom.id_apply _ x]\n rw [← AddMonoidHom.comp_apply, Quot.addMonoidHom_ext _ (f := (quotToQuotUlift F).comp\n (quotUliftToQuot F)) (fun j a ↦ ?_)]\n rw [AddMonoidHom.comp_apply, AddMonoidHom.id_apply, quotUliftToQuot_ι, quotToQuotUlift_ι]\n rfl\n map_add' _ _ := by simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma Quot.desc_quotQuotUliftAddEquiv [DecidableEq J] (c : Cocone F) :\n (Quot.desc (F ⋙ uliftFunctor.{u'}) (uliftFunctor.{u'}.mapCocone c)).comp\n (quotQuotUliftAddEquiv F).toAddMonoidHom =\n AddEquiv.ulift.symm.toAddMonoidHom.comp (Quot.desc F c) := by\n refine Quot.addMonoidHom_ext _ (fun j a ↦ ?_)\n dsimp\n simp only [quotToQuotUlift_ι, Functor.comp_obj, uliftFunctor_obj, ι_desc, Functor.const_obj_obj,\n ι_desc]\n erw [Quot.ι_desc]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\n/-- (implementation detail) A morphism of commutative additive groups `Quot F →+ A`\ninduces a cocone on `F` as long as the universes work out.\n-/\n@[simps]\ndef toCocone [DecidableEq J] {A : Type w} [AddCommGroup A] (f : Quot F →+ A) : Cocone F where\n pt := AddCommGrpCat.of A\n ι.app j := ofHom <| f.comp (Quot.ι F j)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma Quot.desc_toCocone_desc [DecidableEq J] {A : Type w} [AddCommGroup A] (f : Quot F →+ A)\n (hc : IsColimit c) : (hc.desc (toCocone F f)).hom.comp (Quot.desc F c) = f :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n refine Quot.addMonoidHom_ext F (fun j x ↦ ?_)\n rw [AddMonoidHom.comp_apply, ι_desc]\n change (c.ι.app j ≫ hc.desc (toCocone F f)) _ = _\n rw [hc.fac]\n simp","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Category","family_id":"quot","file_id":"mathlib/Mathlib/Algebra/Category/Grp/Colimits.lean","sample_id":"493545b9c2069943f4007d11768a53e173a4fed3ce9a31371188b630f37911dd"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5b68973d577a7df983355402c2b7ad133d41f3e14965e3a437184a500045ba4c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"35e55827012aaa2f579480e8277339274d65fc2851b7cad86cbaf31577f78436","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"493545b9c2069943f4007d11768a53e173a4fed3ce9a31371188b630f37911dd","source_sha256":"2e83127f408dd9b7499f56658794729b64a5f794f647d03785288fb13377bdec","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine Quot.addMonoidHom_ext F (fun j x ↦ ?_)\n rw [AddMonoidHom.comp_apply, ι_desc]\n change (c.ι.app j ≫ hc.desc (toCocone F f)) _ = _\n rw [hc.fac]\n simp","hard_negative":true,"metrics":{"chosen_tokens":51,"rejected_tokens":5,"token_jaccard":0.085714,"token_length_ratio":0.098039},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"8ba3f476c644c545a8f6416b99c4ad9e704224a38411083944726fe48a2bac73","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Grp.Preadditive\npublic import Mathlib.Algebra.Group.Shrink\npublic import Mathlib.CategoryTheory.ConcreteCategory.Elementwise\npublic import Mathlib.Data.DFinsupp.BigOperators\npublic import Mathlib.Data.DFinsupp.Small\npublic import Mathlib.GroupTheory.QuotientGroup.Defs\n\nNamespace:\nAddCommGrpCat.Colimits\n\nLocal context:\n/-\nCopyright (c) 2019 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison, Sophie Morel\n-/\n/-!\n# The category of additive commutative groups has all colimits.\n\nThis file constructs colimits in the category of additive commutative groups, as\nquotients of finitely supported functions.\n\n-/\n\n@[expose] public section\n\nuniverse u' w u v\n\nopen CategoryTheory Limits\n\nnamespace AddCommGrpCat\n\nvariable {J : Type u} [Category.{v} J] (F : J ⥤ AddCommGrpCat.{w})\n\nnamespace Colimits\n\n/-!\nWe build the colimit of a diagram in `AddCommGrpCat` by constructing the\nfree group on the disjoint union of all the abelian groups in the diagram,\nthen taking the quotient by the abelian group laws within each abelian group,\nand the identifications given by the morphisms in the diagram.\n-/\n\n/--\nThe relations between elements of the direct sum of the `F.obj j` given by the\nmorphisms in the diagram `J`.\n-/\nabbrev Relations [DecidableEq J] : AddSubgroup (DFinsupp (fun j ↦ F.obj j)) :=\n AddSubgroup.closure {x | ∃ (j j' : J) (u : j ⟶ j') (a : F.obj j),\n x = DFinsupp.single j' (F.map u a) - DFinsupp.single j a}\n\n/--\nThe candidate for the colimit of `F`, defined as the quotient of the direct sum\nof the commutative groups `F.obj j` by the relations given by the morphisms in\nthe diagram.\n-/\ndef Quot [DecidableEq J] : Type (max u w) :=\n DFinsupp (fun j ↦ F.obj j) ⧸ Relations F\n\ninstance [DecidableEq J] : AddCommGroup (Quot F) :=\n QuotientAddGroup.Quotient.addCommGroup (Relations F)\n\n/-- Inclusion of `F.obj j` into the candidate colimit.\n-/\ndef Quot.ι [DecidableEq J] (j : J) : F.obj j →+ Quot F :=\n (QuotientAddGroup.mk' _).comp (DFinsupp.singleAddHom (fun j ↦ F.obj j) j)\n\nlemma Quot.addMonoidHom_ext [DecidableEq J] {α : Type*} [AddMonoid α] {f g : Quot F →+ α}\n (h : ∀ (j : J) (x : F.obj j), f (Quot.ι F j x) = g (Quot.ι F j x)) : f = g :=\n QuotientAddGroup.addMonoidHom_ext _ (DFinsupp.addHom_ext h)\n\nvariable (c : Cocone F)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- (implementation detail) Part of the universal property of the colimit cocone, but without\nassuming that `Quot F` lives in the correct universe. -/\ndef Quot.desc [DecidableEq J] : Quot.{w} F →+ c.pt := by\n refine QuotientAddGroup.lift _ (DFinsupp.sumAddHom fun x => (c.ι.app x).hom) ?_\n dsimp\n rw [AddSubgroup.closure_le]\n intro _ ⟨_, _, _, _, eq⟩\n rw [eq]\n simp only [SetLike.mem_coe, AddMonoidHom.mem_ker, map_sub, DFinsupp.sumAddHom_single]\n change (F.map _ ≫ c.ι.app _) _ - _ = 0\n rw [c.ι.naturality]\n simp only [Functor.const_obj_obj, Functor.const_obj_map, Category.comp_id, sub_self]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma Quot.ι_desc [DecidableEq J] (j : J) (x : F.obj j) :\n Quot.desc F c (Quot.ι F j x) = c.ι.app j x := by\n dsimp [desc, ι]\n erw [QuotientAddGroup.lift_mk']\n simp\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma Quot.map_ι [DecidableEq J] {j j' : J} {f : j ⟶ j'} (x : F.obj j) :\n Quot.ι F j' (F.map f x) = Quot.ι F j x := by\n dsimp [ι]\n refine eq_of_sub_eq_zero ?_\n erw [← (QuotientAddGroup.mk' (Relations F)).map_sub, ← AddMonoidHom.mem_ker]\n rw [QuotientAddGroup.ker_mk']\n simp only [DFinsupp.singleAddHom_apply]\n exact AddSubgroup.subset_closure ⟨j, j', f, x, rfl⟩\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/--\nThe obvious additive map from `Quot F` to `Quot (F ⋙ uliftFunctor.{u'})`.\n-/\ndef quotToQuotUlift [DecidableEq J] : Quot F →+ Quot (F ⋙ uliftFunctor.{u'}) := by\n refine QuotientAddGroup.lift (Relations F) (DFinsupp.sumAddHom (fun j ↦ (Quot.ι _ j).comp\n AddEquiv.ulift.symm.toAddMonoidHom)) ?_\n rw [AddSubgroup.closure_le]\n intro _ hx\n obtain ⟨j, j', u, a, rfl⟩ := hx\n rw [SetLike.mem_coe, AddMonoidHom.mem_ker, map_sub, DFinsupp.sumAddHom_single,\n DFinsupp.sumAddHom_single]\n change Quot.ι (F ⋙ uliftFunctor) j' ((F ⋙ uliftFunctor).map u (AddEquiv.ulift.symm a)) - _ = _\n rw [Quot.map_ι]\n dsimp\n rw [sub_self]\n\nlemma quotToQuotUlift_ι [DecidableEq J] (j : J) (x : F.obj j) :\n quotToQuotUlift F (Quot.ι F j x) = Quot.ι _ j (ULift.up x) := by\n dsimp [quotToQuotUlift, Quot.ι]\n conv_lhs => erw [AddMonoidHom.comp_apply (QuotientAddGroup.mk' (Relations F))\n (DFinsupp.singleAddHom _ j), QuotientAddGroup.lift_mk']\n simp only [DFinsupp.singleAddHom_apply, DFinsupp.sumAddHom_single, AddMonoidHom.coe_comp,\n Function.comp_apply]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/--\nThe obvious additive map from `Quot (F ⋙ uliftFunctor.{u'})` to `Quot F`.\n-/\ndef quotUliftToQuot [DecidableEq J] : Quot (F ⋙ uliftFunctor.{u'}) →+ Quot F := by\n refine QuotientAddGroup.lift (Relations (F ⋙ uliftFunctor))\n (DFinsupp.sumAddHom (fun j ↦ (Quot.ι _ j).comp AddEquiv.ulift.toAddMonoidHom)) ?_\n rw [AddSubgroup.closure_le]\n intro _ hx\n obtain ⟨j, j', u, a, rfl⟩ := hx\n simp\n\nlemma quotUliftToQuot_ι [DecidableEq J] (j : J) (x : (F ⋙ uliftFunctor.{u'}).obj j) :\n quotUliftToQuot F (Quot.ι _ j x) = Quot.ι F j x.down := by\n dsimp [quotUliftToQuot, Quot.ι]\n conv_lhs => erw [AddMonoidHom.comp_apply (QuotientAddGroup.mk' (Relations (F ⋙ uliftFunctor)))\n (DFinsupp.singleAddHom _ j), QuotientAddGroup.lift_mk']\n simp only [DFinsupp.singleAddHom_apply,\n DFinsupp.sumAddHom_single, AddMonoidHom.coe_comp, Function.comp_apply]\n rfl\n\n/--\nThe additive equivalence between `Quot F` and `Quot (F ⋙ uliftFunctor.{u'})`.\n-/\n@[simp]\ndef quotQuotUliftAddEquiv [DecidableEq J] : Quot F ≃+ Quot (F ⋙ uliftFunctor.{u'}) where\n toFun := quotToQuotUlift F\n invFun := quotUliftToQuot F\n left_inv x := by\n conv_rhs => rw [← AddMonoidHom.id_apply _ x]\n rw [← AddMonoidHom.comp_apply, Quot.addMonoidHom_ext F (f := (quotUliftToQuot F).comp\n (quotToQuotUlift F)) (fun j a ↦ ?_)]\n rw [AddMonoidHom.comp_apply, AddMonoidHom.id_apply, quotToQuotUlift_ι, quotUliftToQuot_ι]\n right_inv x := by\n conv_rhs => rw [← AddMonoidHom.id_apply _ x]\n rw [← AddMonoidHom.comp_apply, Quot.addMonoidHom_ext _ (f := (quotToQuotUlift F).comp\n (quotUliftToQuot F)) (fun j a ↦ ?_)]\n rw [AddMonoidHom.comp_apply, AddMonoidHom.id_apply, quotUliftToQuot_ι, quotToQuotUlift_ι]\n rfl\n map_add' _ _ := by simp\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma Quot.desc_quotQuotUliftAddEquiv [DecidableEq J] (c : Cocone F) :\n (Quot.desc (F ⋙ uliftFunctor.{u'}) (uliftFunctor.{u'}.mapCocone c)).comp\n (quotQuotUliftAddEquiv F).toAddMonoidHom =\n AddEquiv.ulift.symm.toAddMonoidHom.comp (Quot.desc F c) := by\n refine Quot.addMonoidHom_ext _ (fun j a ↦ ?_)\n dsimp\n simp only [quotToQuotUlift_ι, Functor.comp_obj, uliftFunctor_obj, ι_desc, Functor.const_obj_obj,\n ι_desc]\n erw [Quot.ι_desc]\n rfl\n\nset_option backward.defeqAttrib.useBackward true in\n/-- (implementation detail) A morphism of commutative additive groups `Quot F →+ A`\ninduces a cocone on `F` as long as the universes work out.\n-/\n@[simps]\ndef toCocone [DecidableEq J] {A : Type w} [AddCommGroup A] (f : Quot F →+ A) : Cocone F where\n pt := AddCommGrpCat.of A\n ι.app j := ofHom <| f.comp (Quot.ι F j)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\nlemma Quot.desc_toCocone_desc [DecidableEq J] {A : Type w} [AddCommGroup A] (f : Quot F →+ A)\n (hc : IsColimit c) : (hc.desc (toCocone F f)).hom.comp (Quot.desc F c) = f :=\n\nProof body:\n","rejected":"by\n exact Quot.desc_toCocone_desc","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"e7e90cb8516b3bcec576da2b9514274176a4e2ed05a5c191a36a7fc219e2e7ba","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Category","family_id":"quot","file_id":"mathlib/Mathlib/Algebra/Category/Grp/Colimits.lean","sample_id":"493545b9c2069943f4007d11768a53e173a4fed3ce9a31371188b630f37911dd"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"122d88b22b305010f599cae4b327be37510a882fffbdcbed2ed49af2bbb54d69","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2333e8e5edf608ffc9b4c4b665c8a4dde5dcba713cefda673126e630b25cd9e1","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7cb33889170a70f2f9d7186b8adb11f6a2457abe4e2813fb79657e1dd80bb758","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff","hard_negative":true,"metrics":{"chosen_tokens":8,"rejected_tokens":2,"token_jaccard":0.125,"token_length_ratio":0.25},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"8c32e86258a20b65f24234725a61fadb3432daa6c1ecd5869eb6701b853da415","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nTarget:\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_7cb33889170a","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"454ef16ff6fed9aa523b9c38946b1624e5cfff893f51301b57b67ee24edc654d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"7cb33889170a70f2f9d7186b8adb11f6a2457abe4e2813fb79657e1dd80bb758"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8bd307b8cc9c99cbc4bc3592dc0b57d7d573a0a2f38015d6a57bbe306ee61b93","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7059151f34bc945e562dce80b98f7f51c5a276cb560d7c8aa287c62ddc31e825","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a435ccdd383599bddc503b771663e3c57c997f89c0cbac7d6a0a3dcc2c74b5cb","source_sha256":"da4cd279b2edf42975da9f895fb47e84796c353c7d0f3ffb104f564078fc4165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n induction Δ' using SimplexCategory.rec with | _ m\n obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i fun h => by\n rw [← h] at h₁\n exact h₁ rfl)\n rcases k with _ | k\n · change n = m + 1 at hk\n subst hk\n obtain ⟨j, rfl⟩ := eq_δ_of_mono i\n rw [Isδ₀.iff] at h₂\n have h₃ : 1 ≤ (j : ℕ) := by\n by_contra h\n exact h₂ (by simpa only [Fin.ext_iff, not_le, Nat.lt_one_iff] using! h)\n exact (HigherFacesVanish.of_P (m + 1) m).comp_δ_eq_zero j h₂ (by lia)\n · simp only [← add_assoc] at hk\n clear h₂ hi\n subst hk\n obtain ⟨j₁ : Fin (_ + 1), i, rfl⟩ :=\n eq_comp_δ_of_not_surjective i fun h => by\n rw [← SimplexCategory.epi_iff_surjective] at h\n grind [→ le_of_epi]\n obtain ⟨j₂, i, rfl⟩ :=\n eq_comp_δ_of_not_surjective i fun h => by\n rw [← SimplexCategory.epi_iff_surjective] at h\n grind [→ le_of_epi]\n by_cases hj₁ : j₁ = 0\n · subst hj₁\n rw [assoc, ← SimplexCategory.δ_comp_δ'' (Fin.zero_le _)]\n simp only [op_comp, X.map_comp, assoc, PInfty_f]\n erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ j₂.succ_ne_zero, zero_comp]\n simp only [Fin.succ]\n lia\n · simp only [op_comp, X.map_comp, assoc, PInfty_f]\n erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ hj₁, zero_comp]\n by_contra\n exact hj₁ (by simp only [Fin.ext_iff, Fin.val_zero]; lia)","hard_negative":true,"metrics":{"chosen_tokens":353,"rejected_tokens":3,"token_jaccard":0.020408,"token_length_ratio":0.008499},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"911eb605d8b4ce91405c90527f6f05dd790980f2dd31619cfe120bd8984278ce","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicTopology.DoldKan.GammaCompN\npublic import Mathlib.AlgebraicTopology.DoldKan.NReflectsIso\n\nNamespace:\nAlgebraicTopology.DoldKan\n\nLocal context:\n/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-! # The unit isomorphism of the Dold-Kan equivalence\n\nIn order to construct the unit isomorphism of the Dold-Kan equivalence,\nwe first construct natural transformations\n`Γ₂N₁.natTrans : N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)` and\n`Γ₂N₂.natTrans : N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`.\nIt is then shown that `Γ₂N₂.natTrans` is an isomorphism by using\nthat it becomes an isomorphism after the application of the functor\n`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`\nwhich reflects isomorphisms.\n\n(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)\n\n-/\n\n@[expose] public section\n\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents\n SimplexCategory Opposite SimplicialObject Simplicial DoldKan\n\nnamespace AlgebraicTopology\n\nnamespace DoldKan\n\nvariable {C : Type*} [Category* C] [Preadditive C]\n\nTarget:\ntheorem PInfty_comp_map_mono_eq_zero (X : SimplicialObject C) {n : ℕ} {Δ' : SimplexCategory}\n (i : Δ' ⟶ ⦋n⦌) [hi : Mono i] (h₁ : Δ'.len ≠ n) (h₂ : ¬Isδ₀ i) :\n PInfty.f n ≫ X.map i.op = 0 :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_a435ccdd3835","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"00105e77ab9e97a966d2f7a8b7f94e14b09bf37c2dcf41bbe801419e65be1026","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/DoldKan","family_id":"pinfty_comp_map_mono_eq_zero","file_id":"mathlib/Mathlib/AlgebraicTopology/DoldKan/NCompGamma.lean","sample_id":"a435ccdd383599bddc503b771663e3c57c997f89c0cbac7d6a0a3dcc2c74b5cb"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"790c5aaab79f4f715145265a6ef8df9f564a0559edc4261cfb98800ae2d78271","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"793e693d90ab67d9e0d5ee5dd4ffe6bd0abcc56a8405ed1090263465696fa76f","source_sha256":"8556868e97c2f0a55cbc6fdeb87479062f2695e69c83e5f32206d26061a5f4d3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun h ↦ ?_, isEpi_of_surjective_algebraMap R A⟩\n let R' := (Algebra.linearMap R A).range\n rcases subsingleton_or_nontrivial (A ⧸ R') with h | _\n · rwa [Submodule.Quotient.subsingleton_iff, LinearMap.range_eq_top] at h\n have : Subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R')) := by\n refine subsingleton_of_forall_eq 0 fun y ↦ ?_\n induction y with\n | zero => rfl\n | add a b e₁ e₂ => rwa [e₁, zero_add]\n | tmul x y =>\n obtain ⟨x, rfl⟩ := R'.mkQ_surjective x\n obtain ⟨y, rfl⟩ := R'.mkQ_surjective y\n obtain ⟨s, hs⟩ : ∃ s, 1 ⊗ₜ[R] s = x ⊗ₜ[R] y := by\n use x * y\n trans x ⊗ₜ 1 * 1 ⊗ₜ y\n · simp [(isEpi_iff_forall_one_tmul_eq R A).mp]\n · simp\n have : R'.mkQ 1 = 0 := (Submodule.Quotient.mk_eq_zero R').mpr ⟨1, map_one (algebraMap R A)⟩\n rw [← map_tmul R'.mkQ R'.mkQ, ← hs, map_tmul, this, zero_tmul]\n cases false_of_nontrivial_of_subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R'))","hard_negative":true,"metrics":{"chosen_tokens":251,"rejected_tokens":8,"token_jaccard":0.046512,"token_length_ratio":0.031873},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"9150417ac4f8583910175a71781d402df0a1281d14336bf89a5871dfb568cddb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Bilinear\npublic import Mathlib.LinearAlgebra.TensorProduct.Tower\npublic import Mathlib.RingTheory.Localization.FractionRing\npublic import Mathlib.RingTheory.TensorProduct.Finite\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2026 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\n/-!\n# Algebras which are commutative ring epimorphisms\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Function TensorProduct\n\nnamespace Algebra\n\nsection Semiring\n\nvariable (R A : Type*) [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- A commutative `R`-algebra `A` is epi, if the multiplication map `A ⊗[R] A → A` is injective. -/\nprotected class IsEpi : Prop where\n injective_lift_mul : Injective <| lift <| LinearMap.mul R A\n\n/-- See also `CommRingCat.epi_iff_epi`. -/\nlemma isEpi_iff_forall_one_tmul_eq :\n Algebra.IsEpi R A ↔ ∀ a : A, 1 ⊗ₜ[R] a = a ⊗ₜ[R] 1 := by\n refine ⟨fun h a ↦ IsEpi.injective_lift_mul <| by simp, fun h ↦ ⟨fun x y hxy ↦ ?_⟩⟩\n have h' (x : A ⊗[R] A) : ∃ a : A, x = a ⊗ₜ 1 := by\n induction x using TensorProduct.induction_on with\n | zero => exact ⟨0, by simp⟩\n | tmul u v =>\n use u * v\n calc u ⊗ₜ[R] v = u ⊗ₜ[R] 1 * 1 ⊗ₜ[R] v := by simp\n _ = u ⊗ₜ[R] 1 * v ⊗ₜ[R] 1 := by rw [h]\n _ = (u * v) ⊗ₜ[R] 1 := by simp\n | add u v hu hv =>\n obtain ⟨u, rfl⟩ := hu\n obtain ⟨v, rfl⟩ := hv\n exact ⟨u + v, by simp [add_tmul]⟩\n obtain ⟨a, rfl⟩ := h' x\n obtain ⟨b, rfl⟩ := h' y\n aesop\n\n/-- See also `Algebra.isEpi_iff_surjective_algebraMap_of_finite`. -/\nlemma isEpi_of_surjective_algebraMap (h : Surjective (algebraMap R A)) :\n Algebra.IsEpi R A := by\n refine (isEpi_iff_forall_one_tmul_eq R A).mpr fun a ↦ ?_\n obtain ⟨r, rfl⟩ := h a\n rw [algebraMap_eq_smul_one, smul_tmul]\n\nend Semiring\n\n-- TODO Generalise to any localization\ninstance (R A : Type*) [CommRing R] [IsDomain R] [Field A] [Algebra R A] [IsFractionRing R A] :\n Algebra.IsEpi R A := by\n refine (isEpi_iff_forall_one_tmul_eq R A).mpr fun x ↦ ?_\n obtain ⟨a, b, hb, rfl⟩ := IsFractionRing.div_surjective R x\n set f := algebraMap R A with hf\n replace hb : f b ≠ 0 := by aesop\n calc 1 ⊗ₜ[R] (f a / f b)\n = 1 ⊗ₜ[R] (a • (1 / f b)) := by rw [← smul_div_assoc, algebraMap_eq_smul_one a]\n _ = f a ⊗ₜ[R] (1 / f b) := by rw [← smul_tmul, algebraMap_eq_smul_one a]\n _ = (b • (f a / f b)) ⊗ₜ[R] (1 / f b) := by rw [smul_def, mul_div_cancel₀ _ hb]\n _ = (f a / f b) ⊗ₜ[R] (b • (1 / f b)) := by rw [smul_tmul]\n _ = (f a / f b) ⊗ₜ[R] 1 := by rw [smul_def, mul_div_cancel₀ _ hb]\n\nsection Ring\n\nvariable {R A : Type*} [CommRing R] [Ring A] [Algebra R A]\n\nTarget:\nlemma isEpi_iff_surjective_algebraMap_of_finite [Module.Finite R A] :\n Algebra.IsEpi R A ↔ Surjective (algebraMap R A) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"12f00c7ad970f5f82d82fd236e6a0ee75e627ce4e63da23acc4af796a5fd54ba","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Algebra","family_id":"isepi_iff_surjective_algebramap_of_finite","file_id":"mathlib/Mathlib/Algebra/Algebra/Epi.lean","sample_id":"793e693d90ab67d9e0d5ee5dd4ffe6bd0abcc56a8405ed1090263465696fa76f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e6c9973add2c55eb451a24c7a6914e454c6fdef9a6fc1767e9b32475061ed644","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"382406412876020ac0f92ec573aa37ef717e2c08fc415a1738bb950d5ab0dd97","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f59f776c9473025e81d7ec9f41a8f825d6029f48b5179462995f7613d2346168","source_sha256":"651dce3b94e5b311088fa509a50eb8110baabffebf693d59dd3bad38cea600c6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [Set.mem_prod, Prod.fst_neg, Set.mem_pi, Set.mem_univ, Pi.neg_apply,\n mem_ball_zero_iff, norm_neg, Real.norm_eq_abs, forall_true_left, Subtype.forall,\n Prod.snd_neg] at hx ⊢\n exact hx","hard_negative":true,"metrics":{"chosen_tokens":47,"rejected_tokens":5,"token_jaccard":0.103448,"token_length_ratio":0.106383},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"9214cc5e62339a5bbaa29d9499d237e13fdd98957b0eb0ddc0ec69c03d7cef42","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.Group.GeometryOfNumbers\npublic import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls\npublic import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic\npublic import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup\n\nNamespace:\nNumberField.mixedEmbedding\n\nLocal context:\n/-\nCopyright (c) 2022 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Xavier Roblot\n-/\n/-!\n# Convex Bodies\n\nThe file contains the definitions of several convex bodies lying in the mixed space `ℝ^r₁ × ℂ^r₂`\nassociated to a number field of signature `K` and proves several existence theorems by applying\n*Minkowski Convex Body Theorem* to those.\n\n## Main definitions and results\n\n* `NumberField.mixedEmbedding.convexBodyLT`: The set of points `x` such that `‖x w‖ < f w` for all\n infinite places `w` with `f : InfinitePlace K → ℝ≥0`.\n\n* `NumberField.mixedEmbedding.convexBodySum`: The set of points `x` such that\n `∑ w real, ‖x w‖ + 2 * ∑ w complex, ‖x w‖ ≤ B`\n\n* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_lt`: Let `I` be a fractional ideal of `K`.\n Assume that `f` is such that `minkowskiBound K I < volume (convexBodyLT K f)`, then there exists a\n nonzero algebraic number `a` in `I` such that `w a < f w` for all infinite places `w`.\n\n* `NumberField.mixedEmbedding.exists_ne_zero_mem_ideal_of_norm_le`: Let `I` be a fractional ideal\n of `K`. Assume that `B` is such that `minkowskiBound K I < volume (convexBodySum K B)` (see\n `convexBodySum_volume` for the computation of this volume), then there exists a nonzero algebraic\n number `a` in `I` such that `|Norm a| < (B / d) ^ d` where `d` is the degree of `K`.\n\n## Tags\n\nnumber field, infinite places\n-/\n\n@[expose] public section\n\nvariable (K : Type*) [Field K]\n\nnamespace NumberField.mixedEmbedding\n\nopen NumberField NumberField.InfinitePlace Module\n\nsection convexBodyLT\n\nopen Metric NNReal\n\nvariable (f : InfinitePlace K → ℝ≥0)\n\n/-- The convex body defined by `f`: the set of points `x : E` such that `‖x w‖ < f w` for all\ninfinite places `w`. -/\nabbrev convexBodyLT : Set (mixedSpace K) :=\n (Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } => ball 0 (f w))) ×ˢ\n (Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } => ball 0 (f w)))\n\ntheorem convexBodyLT_mem {x : K} :\n mixedEmbedding K x ∈ (convexBodyLT K f) ↔ ∀ w : InfinitePlace K, w x < f w := by\n simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,\n forall_true_left, mem_ball_zero_iff, RingHom.pi_apply, ← Complex.norm_real,\n embedding_of_isReal_apply, Subtype.forall, ← forall₂_or_left, ← not_isReal_iff_isComplex, em,\n forall_true_left, norm_embedding_eq]\n\nTarget:\ntheorem convexBodyLT_neg_mem (x : mixedSpace K) (hx : x ∈ (convexBodyLT K f)) :\n -x ∈ (convexBodyLT K f) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_f59f776c9473","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"712ca3a1d768aff146532ebf671af6f8dff82ad439ef3644090c6c599d6d46e7","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/NumberField","family_id":"convexbodylt_neg_mem","file_id":"mathlib/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean","sample_id":"f59f776c9473025e81d7ec9f41a8f825d6029f48b5179462995f7613d2346168"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"40613eb9d4b1a9cee266cfcfe5d41e6bfa505fbe3cec0f632fa9e5cf3496237f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff3ef85326780ec04f162693b7f81032494a8a92b52b64d72381cd7bdcb29635","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr","hard_negative":false,"metrics":{"chosen_tokens":31,"rejected_tokens":2,"token_jaccard":0.083333,"token_length_ratio":0.064516},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"952f46c71f33cb49b1b4446c60580020cb7a9267e769deaa43ac7241c472e2f9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\nTarget:\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"ff3ef85326780ec04f162693b7f81032494a8a92b52b64d72381cd7bdcb29635"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"907633de4129302813f759b855a8876e4ea997f756c4c3eaa0b174c693d9f3a2","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e905c7d00efe611a65686aeaafc68dd8014ade808292dce1567b2e3e2bf45c54","source_sha256":"594526dd0b78e6f5230ed2942c4aa65bf99f40b1c821a95454182a610e50cd9a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun _ ↦ ?_, fun hf ↦ homotopyEquivalences_le_quasiIso _ _ _ hf⟩\n rw [← HomotopyCategory.inverseImage_quotient_isomorphisms,\n MorphismProperty.inverseImage_iff, MorphismProperty.isomorphisms.iff]\n obtain ⟨g, hg⟩ := (Qh_map_bijective _ _).surjective\n ((quotientCompQhIso C).hom.app L ≫ inv (Q.map f) ≫ (quotientCompQhIso C).inv.app K)\n refine ⟨g, (Qh_map_bijective _ _).injective ?_, (Qh_map_bijective _ _).injective ?_⟩\n · simp [hg]; rfl\n · simp [hg, ← quotientCompQhIso_inv_naturality, -NatTrans.naturality]; rfl","hard_negative":true,"metrics":{"chosen_tokens":124,"rejected_tokens":8,"token_jaccard":0.036364,"token_length_ratio":0.064516},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"9553e331ab412618d1d13ad7d212f748b4276af060ec2a1ea897cfd289d6ce7e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.DerivedCategory.SmallShiftedHom\npublic import Mathlib.Algebra.Homology.HomotopyCategory.KInjective\npublic import Mathlib.Algebra.Homology.Embedding.ExtendHomotopy\n\nNamespace:\nCochainComplex.IsKInjective\n\nLocal context:\n/-\nCopyright (c) 2025 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Morphisms to K-injective complexes in the derived category\n\nIn this file, we show that if `L : CochainComplex C ℤ` is K-injective,\nthen for any `K : HomotopyCategory C (.up ℤ)`, the functor `DerivedCategory.Qh`\ninduces a bijection from the type of morphisms `K ⟶ (HomotopyCategory.quotient _ _).obj L)`\n(i.e. homotopy classes of morphisms of cochain complexes) to the type of\nmorphisms in the derived category.\nWe obtain that a morphism between `K`-injective cochain complexes is a quasi-isomorphism\niff it is a homotopy equivalence. In particular, a morphism between cochain complexes\nindexed by `ℕ` which consist of injective objects is a quasi-isomorphism iff\nit is a homotopy equivalence.\n\n-/\n\n@[expose] public section\n\nuniverse w v u\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] [Abelian C]\n\nopen CategoryTheory Localization DerivedCategory\n\nnamespace CochainComplex\n\nnamespace IsKInjective\n\nlemma Qh_map_bijective [HasDerivedCategory C]\n (K : HomotopyCategory C (ComplexShape.up ℤ))\n (L : CochainComplex C ℤ) [L.IsKInjective] :\n Function.Bijective (DerivedCategory.Qh.map :\n (K ⟶ (HomotopyCategory.quotient _ _).obj L) → _) :=\n (CochainComplex.IsKInjective.rightOrthogonal L).map_bijective_of_isTriangulated _ _\n\nset_option backward.isDefEq.respectTransparency false in\nopen HomologicalComplex in\nattribute [local instance] HasDerivedCategory.standard in\n\nTarget:\nlemma quasiIso_iff {K L : CochainComplex C ℤ} [K.IsKInjective] [L.IsKInjective] (f : K ⟶ L) :\n QuasiIso f ↔ homotopyEquivalences C (.up ℤ) f :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"927f77b59e425d3308f2d2fe824cc149df65bbda86f6e1da64d8e1d40e7e0c94","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Homology","family_id":"quasiiso_iff","file_id":"mathlib/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean","sample_id":"e905c7d00efe611a65686aeaafc68dd8014ade808292dce1567b2e3e2bf45c54"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"eb30d3ad95b52463de71194a78ec81212add641f0c9704c3cf7d39f339950416","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"354c6ab9240d489d760785405022488141481fc93a2bd2a7c656b6c3a3e54013","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by ext; simp","hard_negative":false,"metrics":{"chosen_tokens":4,"rejected_tokens":2,"token_jaccard":0.2,"token_length_ratio":0.5},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"962c52396549b415cf9e41c1b9889f00508e2f26645fa6bf2538c0bbb86a0107","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x := by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective\n\nTarget:\ntheorem toSpanSingleton_one_eq_algebraLinearMap :\n toSpanSingleton R A 1 = Algebra.linearMap R A :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"tospansingleton_one_eq_algebralinearmap","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"354c6ab9240d489d760785405022488141481fc93a2bd2a7c656b6c3a3e54013"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bb2bbade796218fc602cae73b83839fef9caa5d8cd70cea38cea67788bdd4ad8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d1dbab6d531d2409109ce1cd5d2f43ef978ecebab2e551a8f5f4ae20169ca22f","source_sha256":"b1ad611057493f75821a824485b9f5ad1e1b6dd4eaa317b9db2936b30ae77c1d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [Perm.subtypeCongr.apply, h]","hard_negative":true,"metrics":{"chosen_tokens":11,"rejected_tokens":8,"token_jaccard":0.0625,"token_length_ratio":0.727273},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"96458d9c2ccc4b51a334b3c100f2ca1662c730b47801398efba055d2be2b3654","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Equiv.Option\npublic import Mathlib.Logic.Equiv.Sum\npublic import Mathlib.Logic.Function.Conjugate\npublic import Mathlib.Tactic.Lift\npublic import Mathlib.Data.Int.Notation\n\nNamespace:\nEquiv\n\nLocal context:\n/-\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/-!\n# Equivalence between types\n\nIn this file we continue the work on equivalences begun in `Mathlib/Logic/Equiv/Defs.lean`, defining\na lot of equivalences between various types and operations on these equivalences.\n\nMore definitions of this kind can be found in other files.\nE.g., `Mathlib/Algebra/Group/TransferInstance.lean` does it for `Group`,\n`Mathlib/Algebra/Module/TransferInstance.lean` does it for `Module`, and similar files exist for\nother algebraic type classes.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n@[expose] public section\n\nuniverse u v w z\n\nopen Function\n\n-- Unless required to be `Type*`, all variables in this file are `Sort*`\nvariable {α α₁ α₂ β β₁ β₂ γ δ : Sort*}\n\nnamespace Equiv\n\n/-- The product over `Option α` of `β a` is the binary product of the\nproduct over `α` of `β (some α)` and `β none` -/\n@[simps]\ndef piOptionEquivProd {α} {β : Option α → Type*} :\n (∀ a : Option α, β a) ≃ β none × ∀ a : α, β (some a) 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\nsection subtypeCongr\n\n/-- Combines an `Equiv` between two subtypes with an `Equiv` between their complements to form a\n permutation. -/\ndef subtypeCongr {α} {p q : α → Prop} [DecidablePred p] [DecidablePred q]\n (e : { x // p x } ≃ { x // q x }) (f : { x // ¬p x } ≃ { x // ¬q x }) : Perm α :=\n (sumCompl p).symm.trans ((sumCongr e f).trans (sumCompl q))\n\nvariable {ε : Type*} {p : ε → Prop} [DecidablePred p]\nvariable (ep ep' : Perm { a // p a }) (en en' : Perm { a // ¬p a })\n\n/-- Combining permutations on `ε` that permute only inside or outside the subtype\nsplit induced by `p : ε → Prop` constructs a permutation on `ε`. -/\ndef Perm.subtypeCongr : Equiv.Perm ε :=\n permCongr (sumCompl p) (sumCongr ep en)\n\ntheorem Perm.subtypeCongr.apply (a : ε) : ep.subtypeCongr en a =\n if h : p a then (ep ⟨a, h⟩ : ε) else en ⟨a, h⟩ := by\n by_cases h : p a <;> simp [Perm.subtypeCongr, h]\n\n@[simp]\n\nTarget:\ntheorem Perm.subtypeCongr.left_apply {a : ε} (h : p a) : ep.subtypeCongr en a = ep ⟨a, h⟩ :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"79b0086e6b9bbda661abfd5e04fe06f04cf059cc5443c0807edc1f9a70faa6de","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Equiv","family_id":"perm","file_id":"mathlib/Mathlib/Logic/Equiv/Basic.lean","sample_id":"d1dbab6d531d2409109ce1cd5d2f43ef978ecebab2e551a8f5f4ae20169ca22f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1b6a1d9590da39c9820ca3e6ee567135761314ec1c8ac6d1a9385b82b6d745b7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"92b24806db92f8b9cddd8dbca3ef6bd04352dbaa0df13cc32ccbcfc86fd8a0e3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3a3d7287cfd08006945a34adccd4ff6c003953595820af331cea43fd089d1560","source_sha256":"380339d381ec2013c54136321e5c6043787ad5c08574d532f7b25cfd0cd49785","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [IsNonempty, Set.nonempty_iff_ne_empty, Hypergraph.ext_iff]\n grind [bot_vertexSet, bot_edgeSet]\n\nalias ⟨_, IsNonempty.ne_bot⟩ := ne_bot_iff","hard_negative":false,"metrics":{"chosen_tokens":29,"rejected_tokens":36,"token_jaccard":0.913043,"token_length_ratio":1.241379},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"98e1554a8f1b7083ff395be87786a9e456b4a6fb34e9fab5cd5ca5b0e2f2019e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Basic\npublic import Mathlib.Data.Set.Card\n\nNamespace:\nHypergraph\n\nLocal context:\n/-\nCopyright (c) 2026 Evan Spotte-Smith, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Evan Spotte-Smith, Bhavik Mehta\n-/\n/-!\n# Undirected hypergraphs\n\nAn *undirected hypergraph* (here abbreviated as *hypergraph*) `H` is a generalization of a graph\n(see `Mathlib.Combinatorics.Graph` or `Mathlib.Combinatorics.SimpleGraph`) and consists of a set of\n*vertices*, usually denoted `V` or `V(H)`, and a set of *hyperedges*, here called *edges* and\ndenoted `E` or `E(H)`. In contrast with a graph, where edges are unordered pairs of vertices, in\nhypergraphs, edges are unordered sets of vertices; i.e., they are subsets of the vertex set `V`.\n\nA hypergraph where `V = ∅` and `E = ∅` is *empty*, denoted `⊥`. A hypergraph with a nonempty\nvertex set (`V ≠ ∅`) and empty edge set is *trivial*. A hypergraph where the edge set is the power\nset of the vertex set (or, equivalently, where all possible subsets of the vertex sets are in the\nedge set) is *complete*.\n\nIf a edge `e` contains only one vertex (i.e., `|e| = 1`), then it is a *loop*.\n\nThis module defines `Hypergraph α` for a vertex type `α` (edges are defined as `Set (Set α)`).\n\n## Main definitions\n\n* `Hypergraph α` is the type of undirected hypergraphs with vertices of type `α` and edges of type\n `Set α`. In addition to vertices and hyperedges, a `Hypergraph` must have the property that all\n edges are subsets of the vertex set.\n\nFor `H : Hypergraph α`:\n\n* `H.vertexSet` (abbrev. `V(H)`) denotes the vertex set of `H` as a term in `Set α`.\n* `H.edgeSet` (abbrev. `E(H)`) denotes the edge set of `H` as a term in `Set (Set α)`. Hyperedges\n must be subsets of `V(H)`.\n* `H.Adj x y` means that there exists some edge containing both `x` and `y` (or, in other\n words, `x` and `y` are incident to some shared edge `e`).\n* `H.EAdj e f` means that there exists some vertex that is incident to the edges `e` and\n `f : Set α`.\n\n## Implementation details\n\nThis implementation is heavily inspired by Peter Nelson and Jun Kwon's `Graph` implementation,\nwhich was in turn inspired by `Matroid`.\n\nParaphrasing `Mathlib.Combinatorics.Graph.Basic`:\n\"The main tradeoff is that parts of the API will need to care about whether a term\n`x : α` or `e : Set α` is a 'real' vertex or edge of the graph, rather than something outside\nthe vertex or edge set. This is an issue, but is likely amenable to automation.\"\n\nBecause `edgeSet` is a `Set (Set α)`, rather than a multiset, here we are assuming that\nall hypergraphs are *without repeated edge*.\n\n-/\n\npublic section\n\nopen Set\n\nvariable {α β γ : Type*} {x y : α} {e e' f : Set α}\n\n/--\nAn undirected hypergraph with vertices of type `α` and edges of type `Set α`, as described by vertex\nand edge sets `vertexSet : Set α` and `edgeSet : Set (Set α)`.\n\nThe requirement `subset_vertexSet_of_mem_edgeSet` ensures that all vertices in edges are part of\n`vertexSet`, i.e., all edges are subsets of the `vertexSet`.\n-/\n@[ext]\nstructure Hypergraph (α : Type*) where\n /-- The vertex set -/\n vertexSet : Set α\n /-- The edge set -/\n edgeSet : Set (Set α)\n /-- All edges must be subsets of the vertex set -/\n subset_vertexSet_of_mem_edgeSet' : ∀ ⦃e⦄, e ∈ edgeSet → e ⊆ vertexSet\n\nnamespace Hypergraph\n\nvariable {H : Hypergraph α}\n\n/-! ## Notation -/\n\n/-- `V(H)` denotes the `vertexSet` of a hypergraph `H` -/\nscoped notation \"V(\" H \")\" => Hypergraph.vertexSet H\n\n/-- `E(H)` denotes the `edgeSet` of a hypergraph `H` -/\nscoped notation \"E(\" H \")\" => Hypergraph.edgeSet H\n\n\n/-! ## Vertex-Hyperedge Incidence -/\n\n@[simp]\nlemma subset_vertexSet_of_mem_edgeSet (he : e ∈ E(H)) : e ⊆ V(H) :=\n H.subset_vertexSet_of_mem_edgeSet' he\n\nalias _root_.Membership.mem.subset_vertexSet := subset_vertexSet_of_mem_edgeSet\n\nlemma edgeSet_subset_powerset_vertexSet {H : Hypergraph α} : E(H) ⊆ V(H).powerset :=\n fun _ ↦ subset_vertexSet_of_mem_edgeSet\n\nlemma mem_vertexSet_of_mem_edgeSet (he : e ∈ E(H)) (hx : x ∈ e) : x ∈ V(H) :=\n H.subset_vertexSet_of_mem_edgeSet he hx\n\nlemma edgeSet.ext_iff (he : e ∈ E(H)) (he' : e' ∈ E(H)) : e = e' ↔ ∀ x ∈ V(H), x ∈ e ↔ x ∈ e' := by\n grind [he.subset_vertexSet, he'.subset_vertexSet]\n\nlemma sUnion_edgeSet_subset_vertexSet : ⋃₀ E(H) ⊆ V(H) :=\n subset_powerset_iff.mp edgeSet_subset_powerset_vertexSet\n\n/-! ## Vertex and Hyperedge Adjacency -/\n\n/--\nPredicate for adjacency. Two vertices `x` and `y` are adjacent if there is some edge `e ∈ E(H)`\nwhere `x` and `y` are both incident to `e`.\n\nNote that we do not need to explicitly check that `x, y ∈ V(H)` here because a vertex that is not in\nthe vertex set cannot be incident to any edge.\n-/\n@[expose]\ndef Adj (H : Hypergraph α) (x : α) (y : α) : Prop :=\n ∃ e ∈ E(H), x ∈ e ∧ y ∈ e\n\nlemma Adj.symm (h : H.Adj x y) : H.Adj y x := by grind [Adj]\n\nlemma adj_comm (x y : α) : H.Adj x y ↔ H.Adj y x := ⟨.symm, .symm⟩\n\n/--\nPredicate for edge adjacency. Analogous to `Hypergraph.Adj`, edges `e` and `f` are\nadjacent if there is some vertex `x ∈ V(H)` where `x` is incident to both `e` and `f`.\n-/\n@[expose]\ndef EAdj (H : Hypergraph α) (e : Set α) (f : Set α) : Prop :=\n e ∈ E(H) ∧ f ∈ E(H) ∧ ∃ x, x ∈ e ∧ x ∈ f\n\nlemma EAdj.exists_vertex (h : H.EAdj e f) : ∃ x ∈ V(H), x ∈ e ∧ x ∈ f := by\n obtain ⟨x, hx⟩ := h.2.2\n exact ⟨x, mem_vertexSet_of_mem_edgeSet h.1 hx.1, hx⟩\n\nlemma EAdj.symm (h : H.EAdj e f) : H.EAdj f e := by grind [EAdj]\n\nlemma EAdj.inter_nonempty (hef : H.EAdj e f) : (e ∩ f).Nonempty :=\n Set.inter_nonempty.mpr hef.2.2\n\nlemma eAdj_comm (e f) : H.EAdj e f ↔ H.EAdj f e := ⟨.symm, .symm⟩\n\n/-! ## Basic Hypergraph Definitions & Predicates-/\n\n/-- The *image* of a hypergraph `H : Hypergraph α` under a function `f : α → β` is the hypergraph\n`Hᶠ : Hypergraph β` where the vertex set of `Hᶠ` is the image of `V(H)` under `f` and the edge set\nof `Hᶠ` is the set of images of the edges (subsets of vertices) in `E(H)`. -/\n@[simps, expose]\nprotected def image (H : Hypergraph α) (f : α → β) : Hypergraph β where\n vertexSet := V(H).image f\n edgeSet := E(H).image (Set.image f)\n subset_vertexSet_of_mem_edgeSet' := by\n rintro - ⟨e, he, rfl⟩\n exact image_mono he.subset_vertexSet\n\nlemma mem_edgeSet_image {f : α → β} {e : Set β} : e ∈ E(H.image f) ↔ ∃ e' ∈ E(H), f '' e' = e :=\n .rfl\n\nlemma image_mem_edgeSet_image {f : α → β} (he : e ∈ E(H)) : e.image f ∈ E(H.image f) :=\n mem_image_of_mem _ he\n\nlemma image_image {f : α → β} {g : β → γ} (H : Hypergraph α) :\n (H.image f).image g = H.image (g ∘ f) := by\n ext <;> simp [Set.image_image]\n\n/-- A vertex is isolated if it is not incident to any edges (including loops). -/\n@[expose]\ndef IsIsolated (H : Hypergraph α) (x : α) : Prop := ∀ e ∈ E(H), x ∉ e\n\nlemma sUnion_edgeSet_eq_vertexSet_iff_all_vertex_not_isolated :\n ⋃₀ E(H) = V(H) ↔ ∀ x ∈ V(H), ¬IsIsolated H x := by\n grind [IsIsolated, mem_vertexSet_of_mem_edgeSet]\n\n/-- A loop is an edge whose associated vertex subset consists of a single vertex. -/\n@[expose]\ndef IsLoop (H : Hypergraph α) (e : Set α) : Prop := e ∈ E(H) ∧ ∃ x, e = {x}\n\nlemma isLoop_iff_mem_edgeSet_and_singleton : H.IsLoop e ↔ (e ∈ E(H) ∧ ∃ x, e = {x}) := .rfl\n\nlemma isLoop_iff_mem_and_ncard_one : H.IsLoop e ↔ (e ∈ E(H) ∧ Set.ncard e = 1) := by\n grind [IsLoop, ncard_eq_one, mem_vertexSet_of_mem_edgeSet]\n\nlemma IsLoop.ncard_one (h : H.IsLoop e) : Set.ncard e = 1 := (isLoop_iff_mem_and_ncard_one.mp h).2\n\n/-- A hypergraph is nonempty if it has at least one vertex or at least one edge. -/\n@[expose]\ndef IsNonempty (H : Hypergraph α) : Prop := V(H).Nonempty ∨ E(H).Nonempty\n\n/-- The empty hypergraph (bottom) on a type. -/\n@[simps]\ninstance (α : Type*) : Bot (Hypergraph α) where\n bot.vertexSet := ∅\n bot.edgeSet := ∅\n bot.subset_vertexSet_of_mem_edgeSet' := by simp\n\n@[simp]\nlemma IsNonempty.of_nonempty_vertexSet (hV : V(H).Nonempty) : H.IsNonempty :=\n .inl hV\n\n@[simp]\nlemma IsNonempty.of_nonempty_edgeSet (hE : E(H).Nonempty) : H.IsNonempty :=\n .inr hE\n\n@[simp]\n\nTarget:\ntheorem ne_bot_iff : H ≠ ⊥ ↔ H.IsNonempty :=\n\nProof body:\n","rejected":"```lean\nby\n simp [IsNonempty, Set.nonempty_iff_ne_empty, Hypergraph.ext_iff]\n grind [bot_vertexSet, bot_edgeSet]\n\nalias ⟨_, IsNonempty.ne_bot⟩ := ne_bot_iff\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Hypergraph","family_id":"ne_bot_iff","file_id":"mathlib/Mathlib/Combinatorics/Hypergraph/Basic.lean","sample_id":"3a3d7287cfd08006945a34adccd4ff6c003953595820af331cea43fd089d1560"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f2aef0814f0203717bab6778c3e9bf91fbf8a44936fb1cc7bc30f47f2dbb07f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f68c548154fe92816303a255d4668adcb39aa6326d9a3826c40d1e21acb0930b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e61605c632db87c588307f1db5335cc30d2f905e1cf43f63f119ba678f181bf9","source_sha256":"5fe320cf8339285f3ebda4142570292583dc5699644499632f4faabcfba59b47","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [MapsTo, setOf_forall] using! isClosed_biInter fun y hy ↦ ht.preimage (hf y hy)","hard_negative":true,"metrics":{"chosen_tokens":23,"rejected_tokens":5,"token_jaccard":0.083333,"token_length_ratio":0.217391},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"991abe122445bcfbc9124c79f5e1e30ed89383b207e084e3ac2bc9a1635edcdd","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homeomorph.Defs\npublic import Mathlib.Topology.Maps.Basic\npublic import Mathlib.Topology.Separation.SeparatedNhds\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\n/-!\n# Disjoint unions and products of topological spaces\n\nThis file constructs sums (disjoint unions) and products of topological spaces\nand sets up their basic theory, such as criteria for maps into or out of these\nconstructions to be continuous; descriptions of the open sets, neighborhood filters,\nand generators of these constructions; and their behavior with respect to embeddings\nand other specific classes of maps.\n\nWe also provide basic homeomorphisms, to show that sums and products are commutative, associative\nand distributive (up to homeomorphism).\n\n## Implementation note\n\nThe constructed topologies are defined using induced and coinduced topologies\nalong with the complete lattice structure on topologies. Their universal properties\n(for example, a map `X → Y × Z` is continuous if and only if both projections\n`X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of\ncontinuity. With more work we can also extract descriptions of the open sets,\nneighborhood filters and so on.\n\n## Tags\n\nproduct, sum, disjoint union\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Topology TopologicalSpace Set Filter Function\n\nuniverse u v u' v'\n\nvariable {X : Type u} {Y : Type v} {W Z ε ζ : Type*}\n\ninstance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X ⊕ Y) :=\n coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂\n\ninstance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] :\n TopologicalSpace (X × Y) :=\n induced Prod.fst t₁ ⊓ induced Prod.snd t₂\n\nsection Prod\n\nvariable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W]\n [TopologicalSpace ε] [TopologicalSpace ζ]\n\n@[simp]\ntheorem continuous_prodMk {f : X → Y} {g : X → Z} :\n (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g :=\n continuous_inf_rng.trans <| continuous_induced_rng.and continuous_induced_rng\n\n@[continuity]\ntheorem continuous_fst : Continuous (@Prod.fst X Y) :=\n (continuous_prodMk.1 continuous_id).1\n\n/-- Postcomposing `f` with `Prod.fst` is continuous -/\n@[fun_prop]\ntheorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 :=\n continuous_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous -/\ntheorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst :=\n hf.comp continuous_fst\n\ntheorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p :=\n continuous_fst.continuousAt\n\n/-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).1) x :=\n continuousAt_fst.comp hf\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/\ntheorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X × Y => f x.fst) (x, y) :=\n ContinuousAt.comp hf continuousAt_fst\n\n/-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) :\n ContinuousAt (fun x : X × Y => f x.fst) x :=\n hf.comp continuousAt_fst\n\ntheorem Filter.Tendsto.fst_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) :=\n continuousAt_fst.tendsto.comp h\n\n@[continuity]\ntheorem continuous_snd : Continuous (@Prod.snd X Y) :=\n (continuous_prodMk.1 continuous_id).2\n\n/-- Postcomposing `f` with `Prod.snd` is continuous -/\n@[fun_prop]\ntheorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 :=\n continuous_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous -/\ntheorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd :=\n hf.comp continuous_snd\n\ntheorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p :=\n continuous_snd.continuousAt\n\n/-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/\n@[fun_prop]\ntheorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) :\n ContinuousAt (fun x : X => (f x).2) x :=\n continuousAt_snd.comp hf\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/\ntheorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) :\n ContinuousAt (fun x : X × Y => f x.snd) (x, y) :=\n ContinuousAt.comp hf continuousAt_snd\n\n/-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/\ntheorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) :\n ContinuousAt (fun x : X × Y => f x.snd) x :=\n hf.comp continuousAt_snd\n\ntheorem Filter.Tendsto.snd_nhds {X} {l : Filter X} {f : X → Y × Z} {p : Y × Z}\n (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) :=\n continuousAt_snd.tendsto.comp h\n\n@[continuity, fun_prop]\ntheorem Continuous.prodMk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) :\n Continuous fun x => (f x, g x) :=\n continuous_prodMk.2 ⟨hf, hg⟩\n\n@[continuity]\ntheorem Continuous.prodMk_right (x : X) : Continuous fun y : Y => (x, y) := by fun_prop\n\n@[continuity]\ntheorem Continuous.prodMk_left (y : Y) : Continuous fun x : X => (x, y) := by fun_prop\n\n/-- If `f x y` is continuous in `x` for all `y ∈ s`,\nthen the set of `x` such that `f x` maps `s` to `t` is closed. -/\n\nTarget:\nlemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t)\n (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_e61605c632db","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5715ecefb89d73ad87c4e5689acdb0db1f0da1fde164363585cd4777ecad319e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Constructions","family_id":"isclosed","file_id":"mathlib/Mathlib/Topology/Constructions/SumProd.lean","sample_id":"e61605c632db87c588307f1db5335cc30d2f905e1cf43f63f119ba678f181bf9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"df7fc3d0ee9e66586c63b5b29d742f6bdd373f08c808dcf9a1665939392bfaad","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f900c4905bcccf7cab99aaf2498c05a1343d32af1b35424ba41c7c427d729fb0","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective","hard_negative":true,"metrics":{"chosen_tokens":17,"rejected_tokens":8,"token_jaccard":0.05,"token_length_ratio":0.470588},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"996fb90a8885c536895f626f4d538512b1ccb6eec9c7476dd0b782c83d3d08e1","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\nTarget:\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"44e905839df0e3cd392e70a54abe5a0d6d728d9ef387ff4a95052eb3a362260f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"f900c4905bcccf7cab99aaf2498c05a1343d32af1b35424ba41c7c427d729fb0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7c0c52b15fb2f94fa2a802697aa2899dd41c24e1f114cafb8fd48cbfd3dc3e1c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f042f6f14c0eba757626a5b5dae22ad4b703d3c0a90c2d58032d2646f65484a3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"53651b5c475b1cb11c0ac0b467e7c6a6028c3ebbf94a6f92ff3b171fb44dd052","source_sha256":"b34eef023ab6ef628d571767fa05dc0fcdd990b68e93c669c9937c956b66c50d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← map_preimage_eq_image_map _ _ a, mk_image]","hard_negative":true,"metrics":{"chosen_tokens":11,"rejected_tokens":5,"token_jaccard":0.071429,"token_length_ratio":0.454545},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"99c13e2e3859e62316a0995b1952786f63d7810bad403211e5d0f2f158caae9d","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Insert\n\nNamespace:\nFunction.Fiber\n\nLocal context:\n/-\nCopyright (c) 2024 Dagur Asgeirsson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Dagur Asgeirsson\n-/\n/-!\n\nThis file defines the type `f.Fiber` of fibers of a function `f : Y → Z`, and provides some API\nto work with and construct terms of this type.\n\nNote: this API is designed to be useful when defining the counit of the adjunction between\nthe functor which takes a set to the condensed set corresponding to locally constant maps to that\nset, and the forgetful functor from the category of condensed sets to the category of sets\n(see PR https://github.com/leanprover-community/mathlib4/pull/14027).\n-/\n\n@[expose] public section\n\nassert_not_exists RelIso\n\nvariable {X Y Z : Type*}\n\nnamespace Function\n\n/-- The indexing set of the partition. -/\ndef Fiber (f : Y → Z) : Type _ := Set.range (fun (x : Set.range f) ↦ f ⁻¹' {x.val})\n\nnamespace Fiber\n\n/--\nAny `a : Fiber f` is of the form `f ⁻¹' {x}` for some `x` in the image of `f`. We define `a.image`\nas an arbitrary such `x`.\n-/\nnoncomputable def image (f : Y → Z) (a : Fiber f) : Z := a.2.choose.1\n\nlemma eq_fiber_image (f : Y → Z) (a : Fiber f) : a.1 = f ⁻¹' {a.image} := a.2.choose_spec.symm\n\n/--\nGiven `y : Y`, `Fiber.mk f y` is the fiber of `f` that `y` belongs to, as an element of `Fiber f`.\n-/\ndef mk (f : Y → Z) (y : Y) : Fiber f := ⟨f ⁻¹' {f y}, by simp⟩\n\n/-- `y : Y` as a term of the type `Fiber.mk f y` -/\ndef mkSelf (f : Y → Z) (y : Y) : (mk f y).val := ⟨y, rfl⟩\n\nlemma map_eq_image (f : Y → Z) (a : Fiber f) (x : a.1) : f x = a.image := by\n have := a.2.choose_spec\n rw [← Set.mem_singleton_iff, ← Set.mem_preimage]\n convert! x.prop\n\nlemma mk_image (f : Y → Z) (y : Y) : (Fiber.mk f y).image = f y :=\n (map_eq_image (x := mkSelf f y)).symm\n\nlemma mem_iff_eq_image (f : Y → Z) (y : Y) (a : Fiber f) : y ∈ a.val ↔ f y = a.image :=\n ⟨fun h ↦ a.map_eq_image _ ⟨y, h⟩, fun h ↦ by rw [a.eq_fiber_image]; exact h⟩\n\n/-- An arbitrary element of `a : Fiber f`. -/\nnoncomputable def preimage (f : Y → Z) (a : Fiber f) : Y := a.2.choose.2.choose\n\nlemma map_preimage_eq_image (f : Y → Z) (a : Fiber f) : f a.preimage = a.image :=\n a.2.choose.2.choose_spec\n\nlemma fiber_nonempty (f : Y → Z) (a : Fiber f) : Set.Nonempty a.val := by\n refine ⟨preimage f a, ?_⟩\n rw [mem_iff_eq_image, ← map_preimage_eq_image]\n\nlemma map_preimage_eq_image_map {W : Type*} (f : Y → Z) (g : Z → W) (a : Fiber (g ∘ f)) :\n g (f a.preimage) = a.image := by rw [← map_preimage_eq_image, comp_apply]\n\nTarget:\nlemma image_eq_image_mk (f : Y → Z) (g : X → Y) (a : Fiber (f ∘ g)) :\n a.image = (Fiber.mk f (g (a.preimage _))).image :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_53651b5c475b","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"05c8c1b124337c400144bfd85d5c0ac1d3e6b097904c4697812864b239bc361f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Function","family_id":"image_eq_image_mk","file_id":"mathlib/Mathlib/Logic/Function/FiberPartition.lean","sample_id":"53651b5c475b1cb11c0ac0b467e7c6a6028c3ebbf94a6f92ff3b171fb44dd052"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"55bc562d9fd0b1c2c50e31f3a6f0beaf9317e203f31595fc6e175c69e8889603","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6b604ba9601769e59189903a4fe30f6ec49506245a7fc463c625cd2c63916f9b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"374c11cbff3300b3c3e7ffa6df8b6a3e7ec2b9539d9534511078400bd59abdde","source_sha256":"8fa72a43e680b83403f64aed4f242d29897ff5dbd1caf9a8138cd5ff2f09e69b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]\n exact le_ciInf_add_ciInf h","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":3,"token_jaccard":0.133333,"token_length_ratio":0.157895},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"9aa1559726758e9c7a9df11674e261fc6b2d068a6c0172530723e143e6882a3e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.Order.BigOperators.Group.Finset\npublic import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset\npublic import Mathlib.Algebra.Order.Field.Canonical\npublic import Mathlib.Algebra.Order.Nonneg.Floor\npublic import Mathlib.Data.Real.Pointwise\npublic import Mathlib.Data.NNReal.Defs\npublic import Mathlib.Order.ConditionallyCompleteLattice.Group\npublic import Mathlib.Order.Lattice.Nat\n\nNamespace:\nNNReal\n\nLocal context:\n/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Basic results on nonnegative real numbers\n\nThis file contains all results on `NNReal` that do not directly follow from its basic structure.\nAs a consequence, it is a bit of a random collection of results, and is a good target for cleanup.\n\n## Notation\n\nThis file uses `ℝ≥0` as a localized notation for `NNReal`.\n-/\n\npublic section\n\nassert_not_exists TrivialStar\n\nopen Function Set\nopen scoped BigOperators\n\nnamespace NNReal\nvariable {M : Type*} [Zero M]\n\nnoncomputable instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)\n\n@[simp, norm_cast]\ntheorem coe_mulIndicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.mulIndicator f a : ℝ≥0) : ℝ) = s.mulIndicator (fun x => ↑(f x)) a :=\n map_mulIndicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_indicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.indicator f a : ℝ≥0) : ℝ) = s.indicator (fun x => ↑(f x)) a :=\n map_indicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_mulSingle {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.mulSingle a b : α → ℝ≥0) c : ℝ) = (Pi.mulSingle a b : α → ℝ) c := by\n simpa using coe_mulIndicator {a} (fun _ ↦ b) c\n\n@[simp, norm_cast]\ntheorem coe_single {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.single a b : α → ℝ≥0) c : ℝ) = (Pi.single a b : α → ℝ) c := by\n simpa using coe_indicator {a} (fun _ ↦ b) c\n\n@[norm_cast]\ntheorem coe_list_sum (l : List ℝ≥0) : ((l.sum : ℝ≥0) : ℝ) = (l.map (↑)).sum :=\n map_list_sum toRealHom l\n\n@[norm_cast]\ntheorem coe_list_prod (l : List ℝ≥0) : ((l.prod : ℝ≥0) : ℝ) = (l.map (↑)).prod :=\n map_list_prod toRealHom l\n\n@[norm_cast]\ntheorem coe_multiset_sum (s : Multiset ℝ≥0) : ((s.sum : ℝ≥0) : ℝ) = (s.map (↑)).sum :=\n map_multiset_sum toRealHom s\n\n@[norm_cast]\ntheorem coe_multiset_prod (s : Multiset ℝ≥0) : ((s.prod : ℝ≥0) : ℝ) = (s.map (↑)).prod :=\n map_multiset_prod toRealHom s\n\nvariable {ι : Type*} {s : Finset ι} {f : ι → ℝ}\n\n@[simp, norm_cast]\ntheorem coe_sum (s : Finset ι) (f : ι → ℝ≥0) : ∑ i ∈ s, f i = ∑ i ∈ s, (f i : ℝ) :=\n map_sum toRealHom _ _\n\n@[simp, norm_cast]\nlemma toReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.sum g = f.sum (fun i m ↦ toReal (g i m)) := map_finsuppSum toRealHom ..\n\n@[simp, norm_cast]\nlemma toReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.prod g = f.prod (fun i m ↦ toReal (g i m)) := map_finsuppProd toRealHom ..\n\n@[simp, norm_cast]\nlemma coe_expect (s : Finset ι) (f : ι → ℝ≥0) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : ℝ) :=\n map_expect toRealHom ..\n\ntheorem _root_.Real.toNNReal_sum_of_nonneg (hf : ∀ i ∈ s, 0 ≤ f i) :\n Real.toNNReal (∑ a ∈ s, f a) = ∑ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)]\n exact Finset.sum_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\n@[simp, norm_cast]\ntheorem coe_prod (s : Finset ι) (f : ι → ℝ≥0) : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ) :=\n map_prod toRealHom _ _\n\ntheorem _root_.Real.toNNReal_prod_of_nonneg (hf : ∀ a, a ∈ s → 0 ≤ f a) :\n Real.toNNReal (∏ a ∈ s, f a) = ∏ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]\n exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\nTarget:\ntheorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}\n {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j :=\n\nProof body:\n","rejected":"by\n exact le_iInf_add_iInf","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"0302774282dbb00f4fb714c5c010ea8a721319b134c85bbc8668850d6e472a05","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/NNReal","family_id":"le_iinf_add_iinf","file_id":"mathlib/Mathlib/Data/NNReal/Basic.lean","sample_id":"374c11cbff3300b3c3e7ffa6df8b6a3e7ec2b9539d9534511078400bd59abdde"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c9af3828351cdcb9c346e255d24532e228a2c8bbafe6f19f8418eb4e0579d645","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"747210a4594e2503a2358e5528af75b8e40e99402e55088570c8b06a23a04532","source_sha256":"5b986032a9bb23c7f5acc31aea0498304b096282f4eef9a81528e2e193e09dc8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n induction n generalizing M with\n | zero =>\n have projle : HasProjectiveDimensionLE M 0 := ‹_›\n simp only [HasProjectiveDimensionLE, zero_add] at projle ⊢\n rw [← projective_iff_hasProjectiveDimensionLT_one, ← IsProjective.iff_projective] at projle ⊢\n exact Module.projective_of_isLocalizedModule S (M.localizedModuleMkLinearMap S)\n | succ n ih =>\n rcases ModuleCat.enoughProjectives.1 M with ⟨⟨P, f⟩⟩\n let T := ShortComplex.mk (kernel.ι f) f (kernel.condition f)\n have T_exact : T.ShortExact := { exact := ShortComplex.exact_kernel f }\n let TS := T.map (ModuleCat.localizedModuleFunctor S)\n have TS_exact : TS.ShortExact := T_exact.map_of_exact (ModuleCat.localizedModuleFunctor S)\n have : Projective TS.X₂ := (ModuleCat.localizedModuleFunctor.{v} S).projective_obj _\n have := (T_exact.hasProjectiveDimensionLT_X₃_iff n ‹_›).mp ‹_›\n exact (TS_exact.hasProjectiveDimensionLT_X₃_iff n ‹_›).mpr (ih (kernel f))","hard_negative":false,"metrics":{"chosen_tokens":211,"rejected_tokens":2,"token_jaccard":0.012346,"token_length_ratio":0.009479},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"9ad388e092280070f5d6457d417e8a329cf84c9780ea4b31c7445350c9dee3ff","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.ModuleCat.Localization\npublic import Mathlib.Algebra.Category.ModuleCat.Projective\npublic import Mathlib.CategoryTheory.Abelian.Projective.Dimension\npublic import Mathlib.CategoryTheory.Preadditive.Projective.Preserves\npublic import Mathlib.RingTheory.LocalProperties.Projective\n\nNamespace:\nModuleCat\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# The Projective Dimension Equal to Supremum over Localizations\n\nIn this file, we proved that projective dimension equal to supremum over localizations\n\n## Main definition and results\n\n-/\n\npublic section\n\nuniverse v u\n\nvariable {R : Type u} [CommRing R]\n\nnamespace ModuleCat\n\nopen CategoryTheory\n\nset_option backward.isDefEq.respectTransparency false in\ninstance [Small.{v} R] (S : Submonoid R) :\n (ModuleCat.localizedModuleFunctor.{v} S).PreservesProjectiveObjects where\n projective_obj X {proj} := by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n rw [← IsProjective.iff_projective] at proj ⊢\n simpa [ModuleCat.localizedModuleFunctor] using\n Module.projective_of_isLocalizedModule S (X.localizedModuleMkLinearMap S)\n\nopen Limits in\n\nTarget:\nlemma localizedModule_hasProjectiveDimensionLE [Small.{v, u} R] (n : ℕ) (S : Submonoid R)\n (M : ModuleCat.{v} R) [HasProjectiveDimensionLE M n] :\n HasProjectiveDimensionLE (M.localizedModule S) n :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/LocalProperties","family_id":"localizedmodule_hasprojectivedimensionle","file_id":"mathlib/Mathlib/RingTheory/LocalProperties/ProjectiveDimension.lean","sample_id":"747210a4594e2503a2358e5528af75b8e40e99402e55088570c8b06a23a04532"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ee16869d7bd3de840ebf805ea8a50302c7f8e78f8d08cfc4b7268a631ce6d845","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b73640c450bff4364b4b15da6baace277d7957ab0529751bc0d892cc40b11e4e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"610c4a344d5ed7b4f1c72f6c26c7ad6e868225689c28d1b2546fb73aa5d83d1c","source_sha256":"ccfd4dd3593c6c1f210133749c73e4a778fa70e4772e48b50cde116f0b334020","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases h.lt_or_gt with (h_neg | h_pos)\n · exact continuousAt_sign_of_neg h_neg\n · exact continuousAt_sign_of_pos h_pos","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.105263},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"9b092be676643c77e04498a2f0adf6a9cb57f51256486df7b167815d346c8840","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Sign.Defs\npublic import Mathlib.Topology.Order.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Topology on `SignType`\n\nThis file gives `SignType` the discrete topology, and proves continuity results for `SignType.sign`\nin an `OrderTopology`.\n-/\n\npublic section\n\ninstance : TopologicalSpace SignType :=\n ⊥\n\ninstance : DiscreteTopology SignType :=\n ⟨rfl⟩\n\nvariable {α : Type*} [Zero α] [TopologicalSpace α]\n\nsection PartialOrder\n\nvariable [PartialOrder α] [DecidableLT α] [OrderTopology α]\n\ntheorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a := by\n refine (continuousAt_const : ContinuousAt (fun _ => (1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩\n\ntheorem continuousAt_sign_of_neg {a : α} (h : a < 0) : ContinuousAt SignType.sign a := by\n refine (continuousAt_const : ContinuousAt (fun x => (-1 : SignType)) a).congr ?_\n rw [Filter.EventuallyEq, eventually_nhds_iff]\n exact ⟨{ x | x < 0 }, fun x hx => (sign_neg hx).symm, isOpen_gt' 0, h⟩\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderTopology α]\n\nTarget:\ntheorem continuousAt_sign_of_ne_zero {a : α} (h : a ≠ 0) : ContinuousAt SignType.sign a :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_610c4a344d5e","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"ba77961bcc24084557c836b921495abf5237ad3518dadd4723bdcc1aeb537b16","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Instances","family_id":"continuousat_sign_of_ne_zero","file_id":"mathlib/Mathlib/Topology/Instances/Sign.lean","sample_id":"610c4a344d5ed7b4f1c72f6c26c7ad6e868225689c28d1b2546fb73aa5d83d1c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"169443bd50fb3007af7ae30e31b0786d51408d48fbbf5619398e4e891414f8f7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"960289581702b50678786972be7f1d71715ca95fb59e231f5d92330cd277ab5b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0c6985683c5f2680db7766ea60023550d843b5f77c91fdc3643720dcc0a5e17a","source_sha256":"9eb3a898d17f149f89609c4384085a509c1a0c8bba0a0563578a9597f032ec50","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [eventually_atTop]\n obtain ⟨n, terminatedAt_n⟩ : ∃ n, (of v).TerminatedAt n := terminates\n use n\n intro m m_geq_n\n rw [convs_stable_of_terminated m_geq_n terminatedAt_n]\n exact of_correctness_of_terminatedAt terminatedAt_n","hard_negative":false,"metrics":{"chosen_tokens":38,"rejected_tokens":42,"token_jaccard":0.903226,"token_length_ratio":1.105263},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"9b55863db2e5d77e8b9696af4a8e30b8efb6bd2e1065cc4fc111c62c59f7e835","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.ContinuedFractions.Computation.Translations\npublic import Mathlib.Algebra.ContinuedFractions.TerminatedStable\npublic import Mathlib.Algebra.ContinuedFractions.ContinuantsRecurrence\npublic import Mathlib.Order.Filter.AtTopBot.Basic\npublic import Mathlib.Tactic.FieldSimp\npublic import Mathlib.Tactic.Ring\n\nNamespace:\nGenContFract\n\nLocal context:\n/-\nCopyright (c) 2020 Kevin Kappelmann. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Kappelmann\n-/\n/-!\n# Correctness of Terminating Continued Fraction Computations (`GenContFract.of`)\n\n## Summary\n\nWe show the correctness of the algorithm computing continued fractions (`GenContFract.of`)\nin case of termination in the following sense:\n\nAt every step `n : ℕ`, we can obtain the value `v` by adding a specific residual term to the last\ndenominator of the fraction described by `(GenContFract.of v).convs' n`.\nThe residual term will be zero exactly when the continued fraction terminated; otherwise, the\nresidual term will be given by the fractional part stored in `GenContFract.IntFractPair.stream v n`.\n\nFor an example, refer to\n`GenContFract.compExactValue_correctness_of_stream_eq_some` and for more\ninformation about the computation process, refer to `Algebra.ContinuedFractions.Computation.Basic`.\n\n## Main definitions\n\n- `GenContFract.compExactValue` can be used to compute the exact value approximated by the\n continued fraction `GenContFract.of v` by adding a residual term as described in the summary.\n\n## Main Theorems\n\n- `GenContFract.compExactValue_correctness_of_stream_eq_some` shows that\n `GenContFract.compExactValue` indeed returns the value `v` when given the convergent and\n fractional part as described in the summary.\n- `GenContFract.of_correctness_of_terminatedAt` shows the equality\n `v = (GenContFract.of v).convs n` if `GenContFract.of v` terminated at position `n`.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nnamespace GenContFract\n\nopen GenContFract (of)\n\n-- `compExactValue_correctness_of_stream_eq_some` does not trivially generalize to `DivisionRing`\nvariable {K : Type*} [Field K] [LinearOrder K] {v : K} {n : ℕ}\n\n/-- Given two continuants `pconts` and `conts` and a value `fr`, this function returns\n- `conts.a / conts.b` if `fr = 0`\n- `exactConts.a / exactConts.b` where `exactConts = nextConts 1 fr⁻¹ pconts conts`\n otherwise.\n\nThis function can be used to compute the exact value approximated by a continued fraction\n`GenContFract.of v` as described in lemma `compExactValue_correctness_of_stream_eq_some`.\n-/\nprotected def compExactValue (pconts conts : Pair K) (fr : K) : K :=\n -- if the fractional part is zero, we exactly approximated the value by the last continuants\n if fr = 0 then\n conts.a / conts.b\n else -- otherwise, we have to include the fractional part in a final continuants step.\n letI exactConts := nextConts 1 fr⁻¹ pconts conts\n exactConts.a / exactConts.b\n\nvariable [FloorRing K]\n\n/-- Just a computational lemma we need for the next main proof. -/\nprotected theorem compExactValue_correctness_of_stream_eq_some_aux_comp {a : K} (b c : K)\n (fract_a_ne_zero : Int.fract a ≠ 0) :\n ((⌊a⌋ : K) * b + c) / Int.fract a + b = (b * a + c) / Int.fract a := by\n field_simp\n rw [Int.fract]\n ring\n\nopen GenContFract\n (compExactValue compExactValue_correctness_of_stream_eq_some_aux_comp)\n\n/-- Shows the correctness of `compExactValue` in case the continued fraction\n`GenContFract.of v` did not terminate at position `n`. That is, we obtain the\nvalue `v` if we pass the two successive (auxiliary) continuants at positions `n` and `n + 1` as well\nas the fractional part at `IntFractPair.stream n` to `compExactValue`.\n\nThe correctness might be seen more readily if one uses `convs'` to evaluate the continued\nfraction. Here is an example to illustrate the idea:\n\nLet `(v : ℚ) := 3.4`. We have\n- `GenContFract.IntFractPair.stream v 0 = some ⟨3, 0.4⟩`, and\n- `GenContFract.IntFractPair.stream v 1 = some ⟨2, 0.5⟩`.\n\nNow `(GenContFract.of v).convs' 1 = 3 + 1/2`, and our fractional term at position `2` is `0.5`.\nWe hence have `v = 3 + 1/(2 + 0.5) = 3 + 1/2.5 = 3.4`.\nThis computation corresponds exactly to the one using the recurrence equation in `compExactValue`.\n-/\ntheorem compExactValue_correctness_of_stream_eq_some :\n ∀ {ifp_n : IntFractPair K}, IntFractPair.stream v n = some ifp_n →\n v = compExactValue ((of v).contsAux n) ((of v).contsAux <| n + 1) ifp_n.fr := by\n let g := of v\n induction n with\n | zero =>\n intro ifp_zero stream_zero_eq\n obtain rfl : IntFractPair.of v = ifp_zero := by\n simpa only [IntFractPair.stream, Option.some.injEq] using stream_zero_eq\n cases eq_or_ne (Int.fract v) 0 with\n | inl fract_eq_zero =>\n -- Int.fract v = 0; we must then have `v = ⌊v⌋`\n suffices v = ⌊v⌋ by\n simpa [compExactValue, IntFractPair.of, fract_eq_zero]\n calc\n v = Int.fract v + ⌊v⌋ := by rw [Int.fract_add_floor]\n _ = ⌊v⌋ := by simp [fract_eq_zero]\n | inr fract_ne_zero =>\n -- Int.fract v ≠ 0; the claim then easily follows by unfolding a single computation step\n simp [field, contsAux, nextConts, nextNum, nextDen, of_h_eq_floor, compExactValue,\n IntFractPair.of, fract_ne_zero]\n | succ n IH =>\n intro ifp_succ_n succ_nth_stream_eq\n obtain ⟨ifp_n, nth_stream_eq, nth_fract_ne_zero, -⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧\n ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=\n IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq\n -- introduce some notation\n let conts := g.contsAux (n + 2)\n set pconts := g.contsAux (n + 1) with pconts_eq\n set ppconts := g.contsAux n with ppconts_eq\n cases eq_or_ne ifp_succ_n.fr 0 with\n | inl ifp_succ_n_fr_eq_zero =>\n -- ifp_succ_n.fr = 0\n suffices v = conts.a / conts.b by simpa [compExactValue, ifp_succ_n_fr_eq_zero]\n -- use the IH and the fact that ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ to prove this case\n obtain ⟨ifp_n', nth_stream_eq', ifp_n_fract_inv_eq_floor⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ :=\n IntFractPair.exists_succ_nth_stream_of_fr_zero succ_nth_stream_eq ifp_succ_n_fr_eq_zero\n obtain rfl : ifp_n = ifp_n' := by injection Eq.trans nth_stream_eq.symm nth_stream_eq'\n have s_nth_eq : g.s.get? n = some ⟨1, ⌊ifp_n.fr⁻¹⌋⟩ :=\n get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero nth_stream_eq nth_fract_ne_zero\n rw [← ifp_n_fract_inv_eq_floor] at s_nth_eq\n suffices v = compExactValue ppconts pconts ifp_n.fr by\n simpa [conts, contsAux, s_nth_eq, compExactValue, nth_fract_ne_zero] using this\n exact IH nth_stream_eq\n | inr ifp_succ_n_fr_ne_zero =>\n -- ifp_succ_n.fr ≠ 0\n -- use the IH to show that the following equality suffices\n suffices\n compExactValue ppconts pconts ifp_n.fr = compExactValue pconts conts ifp_succ_n.fr by grind\n -- get the correspondence between ifp_n and ifp_succ_n\n obtain ⟨ifp_n', nth_stream_eq', ifp_n_fract_ne_zero, ⟨rfl⟩⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧\n ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=\n IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq\n obtain rfl : ifp_n = ifp_n' := by injection Eq.trans nth_stream_eq.symm nth_stream_eq'\n -- get the correspondence between ifp_n and g.s.nth n\n have s_nth_eq : g.s.get? n = some ⟨1, (⌊ifp_n.fr⁻¹⌋ : K)⟩ :=\n get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero nth_stream_eq ifp_n_fract_ne_zero\n -- the claim now follows by unfolding the definitions and tedious calculations\n -- some shorthand notation\n let ppA := ppconts.a\n let ppB := ppconts.b\n let pA := pconts.a\n let pB := pconts.b\n have : compExactValue ppconts pconts ifp_n.fr =\n (ppA + ifp_n.fr⁻¹ * pA) / (ppB + ifp_n.fr⁻¹ * pB) := by\n -- unfold compExactValue and the convergent computation once\n grind [compExactValue, nextConts, nextNum, nextDen]\n rw [this]\n -- two calculations needed to show the claim\n have tmp_calc :=\n compExactValue_correctness_of_stream_eq_some_aux_comp pA ppA ifp_succ_n_fr_ne_zero\n have tmp_calc' :=\n compExactValue_correctness_of_stream_eq_some_aux_comp pB ppB ifp_succ_n_fr_ne_zero\n let f := Int.fract (1 / ifp_n.fr)\n -- now unfold the recurrence one step and simplify both sides to arrive at the conclusion\n dsimp only [conts, pconts, ppconts]\n have hfr : (IntFractPair.of (1 / ifp_n.fr)).fr = f := rfl\n simp [compExactValue, contsAux_recurrence s_nth_eq ppconts_eq pconts_eq,\n nextConts, nextNum, nextDen]\n grind\n\nopen GenContFract (of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none)\n\n/-- The convergent of `GenContFract.of v` at step `n - 1` is exactly `v` if the\n`IntFractPair.stream` of the corresponding continued fraction terminated at step `n`. -/\ntheorem of_correctness_of_nth_stream_eq_none (nth_stream_eq_none : IntFractPair.stream v n = none) :\n v = (of v).convs (n - 1) := by\n induction n with\n | zero => contradiction\n -- IntFractPair.stream v 0 ≠ none\n | succ n IH =>\n let g := of v\n change v = g.convs n\n obtain ⟨nth_stream_eq_none⟩ | ⟨ifp_n, nth_stream_eq, nth_stream_fr_eq_zero⟩ :\n IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 :=\n IntFractPair.succ_nth_stream_eq_none_iff.1 nth_stream_eq_none\n · cases n with\n | zero => contradiction\n | succ n' =>\n -- IntFractPair.stream v 0 ≠ none\n have : g.TerminatedAt n' :=\n of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none.2\n nth_stream_eq_none\n have : g.convs (n' + 1) = g.convs n' :=\n convs_stable_of_terminated n'.le_succ this\n rw [this]\n exact IH nth_stream_eq_none\n · simpa [nth_stream_fr_eq_zero, compExactValue] using!\n compExactValue_correctness_of_stream_eq_some nth_stream_eq\n\n/-- If `GenContFract.of v` terminated at step `n`, then the `n`th convergent is exactly `v`. -/\ntheorem of_correctness_of_terminatedAt (terminatedAt_n : (of v).TerminatedAt n) :\n v = (of v).convs n :=\n have : IntFractPair.stream v (n + 1) = none :=\n of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none.1 terminatedAt_n\n of_correctness_of_nth_stream_eq_none this\n\n/-- If `GenContFract.of v` terminates, then there is `n : ℕ` such that the `n`th convergent is\nexactly `v`.\n-/\ntheorem of_correctness_of_terminates (terminates : (of v).Terminates) :\n ∃ n : ℕ, v = (of v).convs n :=\n Exists.elim terminates fun n terminatedAt_n =>\n Exists.intro n (of_correctness_of_terminatedAt terminatedAt_n)\n\nopen Filter\n\n/-- If `GenContFract.of v` terminates, then its convergents will eventually always be `v`. -/\n\nTarget:\ntheorem of_correctness_atTop_of_terminates (terminates : (of v).Terminates) :\n ∀ᶠ n in atTop, v = (of v).convs n :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [eventually_atTop]\n obtain ⟨n, terminatedAt_n⟩ : ∃ n, (of v).TerminatedAt n := terminates\n use n\n intro m m_geq_n\n rw [convs_stable_of_terminated m_geq_n terminatedAt_n]\n exact of_correctness_of_terminatedAt terminatedAt_n","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/ContinuedFractions","family_id":"of_correctness_attop_of_terminates","file_id":"mathlib/Mathlib/Algebra/ContinuedFractions/Computation/CorrectnessTerminating.lean","sample_id":"0c6985683c5f2680db7766ea60023550d843b5f77c91fdc3643720dcc0a5e17a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1b90a250e54b92951ccc4d61111ac3f46abf97a771520f182d61738db8a90ab9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5f10613ba10e43b0c5867c0b48a57c47d5e824a091305fb5a8fc67a6fcee7879","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fcf5cfabac742406d5ab6acc96e0b5d1aa34978258a92e717b9ce21022ce8ba3","source_sha256":"4b78d0cacf95758052e21397c90cec6d556c443e38295ccd9ec4e6362c99bb6e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let Ω : Type u := AlgebraicClosure K\n let g : Spec (.of Ω) ⟶ Spec (.of K) := Spec.map (CommRingCat.ofHom <| algebraMap K Ω)\n apply MorphismProperty.of_pullback_snd_of_descendsAlong\n (Q := @Surjective ⊓ @Flat ⊓ @QuasiCompact) (g := g)\n · exact ⟨⟨inferInstance, inferInstance⟩, inferInstance⟩\n · let : GrpObj (Over.mk (Limits.pullback.snd f g)) := Over.grpObjMkPullbackSnd\n exact smooth_of_grpObj_of_isAlgClosed _","hard_negative":true,"metrics":{"chosen_tokens":96,"rejected_tokens":5,"token_jaccard":0.061224,"token_length_ratio":0.052083},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"9b91d473b49fdd85422c9651304e102ce1ec6cf75a6a13663555b216ae3cffc2","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.AlgClosed.Basic\npublic import Mathlib.AlgebraicGeometry.Morphisms.LocalFlatDescent\npublic import Mathlib.AlgebraicGeometry.Geometrically.Reduced\npublic import Mathlib.CategoryTheory.Monoidal.Grp\n\nNamespace:\nAlgebraicGeometry\n\nLocal context:\n/-\nCopyright (c) 2026 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# Smoothness of group schemes\n\n## Main results\n- `AlgebraicGeometry.smooth_of_grpObj`:\n If `G` is a group scheme over a field `k` that is geometrically reduced and locally\n of finite type, then `G` is smooth over `k`.\n-/\n\npublic section\n\nopen CategoryTheory\n\nnamespace AlgebraicGeometry\n\nuniverse u\n\nvariable {K : Type u} [Field K] {G : Scheme} (f : G ⟶ Spec (.of K))\n [LocallyOfFiniteType f] [GrpObj (Over.mk f)]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nopen MonObj MonoidalCategory CartesianMonoidalCategory in\n/--\nIf `G` is a group scheme over an algebraically closed field `k` that is reduced and locally\nof finite type, then `G` is smooth over `k`.\n-/\nprivate lemma smooth_of_grpObj_of_isAlgClosed [IsReduced G] [IsAlgClosed K] : Smooth f := by\n have := LocallyOfFiniteType.jacobsonSpace f\n have : Nonempty G := ⟨η[Over.mk f].1 (IsLocalRing.closedPoint _)⟩\n rw [← Scheme.Hom.smoothLocus_eq_top_iff, ← TopologicalSpace.Opens.coe_eq_univ,\n ← not_ne_iff, ← Set.nonempty_compl]\n intro H\n obtain ⟨x, hx, hxc⟩ :=\n nonempty_inter_closedPoints H f.smoothLocus.2.isClosed_compl.isLocallyClosed\n obtain ⟨y, hy : y ∈ f.smoothLocus, hyc⟩ := nonempty_inter_closedPoints\n f.dense_smoothLocus_of_perfectField.nonempty f.smoothLocus.2.isLocallyClosed\n let x' : 𝟙_ _ ⟶ Over.mk f := Over.homMk _ ((pointEquivClosedPoint f).symm ⟨x, hxc⟩).2\n let y' : 𝟙_ _ ⟶ Over.mk f := Over.homMk _ ((pointEquivClosedPoint f).symm ⟨y, hyc⟩).2\n let α := (GrpObj.mulRight (A := Over.mk f) x').symm ≪≫\n (GrpObj.mulRight (A := Over.mk f) y')\n have hα : x' ≫ α.hom = y' := by\n dsimp only [Iso.trans_hom, Iso.symm_hom, α]\n rw [← Category.assoc, ← Iso.eq_comp_inv]\n simp [comp_lift_assoc]\n have hα' : α.hom.left x = y := by\n simpa [x', y', pointEquivClosedPoint] using congr(($hα).left (IsLocalRing.closedPoint K))\n rw! [← hα', ← α.hom.left.mem_preimage, Scheme.Hom.preimage_smoothLocus_eq,\n show α.hom.left ≫ f = f from α.hom.w] at hy\n exact hx hy\n\nTarget:\nlemma smooth_of_grpObj [GeometricallyReduced f] : Smooth f :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_fcf5cfabac74","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"05d25f2ba527c31aaab6be20c949198602ad1d53175f028008646fa6508bee2e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Group","family_id":"smooth_of_grpobj","file_id":"mathlib/Mathlib/AlgebraicGeometry/Group/Smooth.lean","sample_id":"fcf5cfabac742406d5ab6acc96e0b5d1aa34978258a92e717b9ce21022ce8ba3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1a219e2219222afc82f6522a0211999bd464c68a577ba9f95c5d96036573d1de","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4e3671a92b7157957d4f92ffebf2f271f222554aaaf55345092e61c95f24ab99","source_sha256":"fd7f00f8de4f342fd9976c499e2c0f694fe1007205cad97c0fd674aa814b979f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : ∀ ω, ((ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω) →\n (ε : ℝ) ≤ stoppedValue f (fun ω ↦ (hittingBtwn f {y : ℝ | ε ≤ y} 0 n ω : ℕ)) ω := by\n intro x hx\n simp_rw [le_sup'_iff, mem_range, Nat.lt_succ_iff] at hx\n refine stoppedValue_hittingBtwn_mem ?_\n simp only [Set.mem_Icc, zero_le, true_and, Set.mem_setOf_eq]\n exact\n let ⟨j, hj₁, hj₂⟩ := hx\n ⟨j, hj₁, hj₂⟩\n have h := setIntegral_ge_of_const_le_real (measurableSet_le measurable_const\n (measurable_range_sup'' fun n _ => (hsub.stronglyMeasurable n).measurable.le (𝒢.le n)))\n (measure_ne_top _ _) this (Integrable.integrableOn (hsub.integrable_stoppedValue\n (hsub.stronglyAdapted.adapted.isStoppingTime_hittingBtwn measurableSet_Ici)\n (mod_cast hittingBtwn_le)))\n rw [ENNReal.le_ofReal_iff_toReal_le, ENNReal.toReal_smul]\n · exact h\n · exact ENNReal.mul_ne_top (by simp) (measure_ne_top _ _)\n · exact le_trans (mul_nonneg ε.coe_nonneg ENNReal.toReal_nonneg) h","hard_negative":true,"metrics":{"chosen_tokens":223,"rejected_tokens":8,"token_jaccard":0.041237,"token_length_ratio":0.035874},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"9c89db2260208e8a214872db9e28c38c711810f106f2b47bfaea7ea8ce588227","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Notation\npublic import Mathlib.Probability.Process.HittingTime\npublic import Mathlib.Probability.Martingale.Basic\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2022 Kexing Ying. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kexing Ying\n-/\n/-! # Optional stopping theorem (fair game theorem)\n\nThe optional stopping theorem states that a strongly adapted integrable process `f` is a\nsubmartingale if and only if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`.\n\nThis file also contains Doob's maximal inequality: given a non-negative submartingale `f`, for all\n`ε : ℝ≥0`, we have `ε • μ {ε ≤ f* n} ≤ ∫ ω in {ε ≤ f* n}, f n` where `f * n ω = max_{k ≤ n}, f k ω`.\n\n### Main results\n\n* `MeasureTheory.submartingale_iff_expected_stoppedValue_mono`: the optional stopping theorem.\n* `MeasureTheory.Submartingale.stoppedProcess`: the stopped process of a submartingale with\n respect to a stopping time is a submartingale.\n* `MeasureTheory.maximal_ineq`: Doob's maximal inequality.\n\n-/\n\npublic section\n\n\nopen scoped NNReal ENNReal MeasureTheory ProbabilityTheory\n\nnamespace MeasureTheory\n\nvariable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {𝒢 : Filtration ℕ m0} {f : ℕ → Ω → ℝ}\n {τ π : Ω → ℕ∞}\n\n/-- Given a submartingale `f` and bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nexpectation of `stoppedValue f τ` is less than or equal to the expectation of `stoppedValue f π`.\nThis is the forward direction of the optional stopping theorem. -/\ntheorem Submartingale.expected_stoppedValue_mono {E : Type*} [NormedAddCommGroup E]\n [NormedSpace ℝ E] [CompleteSpace E] [PartialOrder E] [IsOrderedAddMonoid E]\n [IsOrderedModule ℝ E] [ClosedIciTopology E] [SigmaFiniteFiltration μ 𝒢] {f : ℕ → Ω → E}\n (hf : Submartingale f 𝒢 μ) (hτ : IsStoppingTime 𝒢 τ) (hπ : IsStoppingTime 𝒢 π) (hle : τ ≤ π)\n {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) : μ[stoppedValue f τ] ≤ μ[stoppedValue f π] := by\n rw [← sub_nonneg, ← integral_sub', stoppedValue_sub_eq_sum' hle hbdd]\n · simp only [Finset.sum_apply]\n have : ∀ i, MeasurableSet[𝒢 i] {ω : Ω | τ ω ≤ i ∧ i < π ω} := by\n intro i\n refine (hτ i).inter ?_\n convert! (hπ i).compl using 1\n ext x\n simp; rfl\n rw [integral_finsetSum]\n · refine Finset.sum_nonneg fun i _ => ?_\n rw [integral_indicator (𝒢.le _ _ (this _)), integral_sub', sub_nonneg]\n · exact hf.setIntegral_le (Nat.le_succ i) (this _)\n · exact (hf.integrable _).integrableOn\n · exact (hf.integrable _).integrableOn\n intro i _\n exact Integrable.indicator (Integrable.sub (hf.integrable _) (hf.integrable _))\n (𝒢.le _ _ (this _))\n · exact hf.integrable_stoppedValue hπ hbdd\n · exact hf.integrable_stoppedValue hτ fun ω => le_trans (hle ω) (hbdd ω)\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The converse direction of the optional stopping theorem, i.e. a strongly adapted integrable\nprocess `f` is a submartingale if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`. -/\ntheorem submartingale_of_expected_stoppedValue_mono [SigmaFiniteFiltration μ 𝒢]\n (hadp : StronglyAdapted 𝒢 f)\n (hint : ∀ i, Integrable (f i) μ) (hf : ∀ τ π : Ω → ℕ∞, IsStoppingTime 𝒢 τ → IsStoppingTime 𝒢 π →\n τ ≤ π → (∃ N : ℕ, ∀ ω, π ω ≤ N) → μ[stoppedValue f τ] ≤ μ[stoppedValue f π]) :\n Submartingale f 𝒢 μ := by\n refine submartingale_of_setIntegral_le hadp hint fun i j hij s hs => ?_\n classical\n specialize hf (s.piecewise (fun _ => i) fun _ => j) _ (isStoppingTime_piecewise_const hij hs)\n (isStoppingTime_const 𝒢 j) ?_\n ⟨j, fun _ => le_rfl⟩\n · intro ω\n simp only [Set.piecewise, ENat.some_eq_coe]\n split_ifs with hω\n · exact mod_cast hij\n · norm_cast\n · rwa [stoppedValue_const, ← ENat.some_eq_coe, stoppedValue_piecewise_const,\n integral_piecewise (𝒢.le _ _ hs) (hint _).integrableOn (hint _).integrableOn, ←\n integral_add_compl (𝒢.le _ _ hs) (hint j), add_le_add_iff_right] at hf\n\n/-- **The optional stopping theorem** (fair game theorem): a strongly adapted integrable process `f`\nis a submartingale if and only if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`. -/\ntheorem submartingale_iff_expected_stoppedValue_mono [SigmaFiniteFiltration μ 𝒢]\n (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) :\n Submartingale f 𝒢 μ ↔ ∀ τ π : Ω → ℕ∞, IsStoppingTime 𝒢 τ → IsStoppingTime 𝒢 π →\n τ ≤ π → (∃ N : ℕ, ∀ x, π x ≤ N) → μ[stoppedValue f τ] ≤ μ[stoppedValue f π] :=\n ⟨fun hf _ _ hτ hπ hle ⟨_, hN⟩ => hf.expected_stoppedValue_mono hτ hπ hle hN,\n submartingale_of_expected_stoppedValue_mono hadp hint⟩\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The stopped process of a submartingale with respect to a stopping time is a submartingale. -/\nprotected theorem Submartingale.stoppedProcess [SigmaFiniteFiltration μ 𝒢]\n (h : Submartingale f 𝒢 μ) (hτ : IsStoppingTime 𝒢 τ) :\n Submartingale (stoppedProcess f τ) 𝒢 μ := by\n rw [submartingale_iff_expected_stoppedValue_mono]\n · intro σ π hσ hπ hσ_le_π hπ_bdd\n simp_rw [stoppedValue_stoppedProcess]\n obtain ⟨n, hπ_le_n⟩ := hπ_bdd\n have hπ_top ω : π ω ≠ ⊤ := ne_top_of_le_ne_top (by simp) (hπ_le_n ω)\n have hσ_top ω : σ ω ≠ ⊤ := ne_top_of_le_ne_top (hπ_top ω) (hσ_le_π ω)\n simp only [ne_eq, hσ_top, not_false_eq_true, ↓reduceIte, hπ_top, ge_iff_le]\n exact h.expected_stoppedValue_mono (hσ.min hτ) (hπ.min hτ)\n (fun ω => min_le_min (hσ_le_π ω) le_rfl) fun ω => (min_le_left _ _).trans (hπ_le_n ω)\n · exact StronglyAdapted.stoppedProcess_of_discrete h.stronglyAdapted hτ\n · exact fun i =>\n h.integrable_stoppedValue ((isStoppingTime_const _ i).min hτ) fun ω => min_le_left _ _\n\nsection Maximal\n\nopen Finset\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\ntheorem smul_le_stoppedValue_hittingBtwn [IsFiniteMeasure μ] (hsub : Submartingale f 𝒢 μ) {ε : ℝ≥0}\n (n : ℕ) : ε • μ {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω} ≤\n ENNReal.ofReal\n (∫ ω in {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω},\n stoppedValue f (fun ω ↦ (hittingBtwn f {y : ℝ | ε ≤ y} 0 n ω : ℕ)) ω ∂μ) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"3ea7fbfec8e5108666ccc2b46e652bf2accfcb5a4584d0fb9626485d41d2bf33","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Martingale","family_id":"smul_le_stoppedvalue_hittingbtwn","file_id":"mathlib/Mathlib/Probability/Martingale/OptionalStopping.lean","sample_id":"4e3671a92b7157957d4f92ffebf2f271f222554aaaf55345092e61c95f24ab99"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f254bd59e6f4fbdc15a246dde0e74d3848ca5347d0a25d1248674d1989415258","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"32215e9ee86a34a10891b4942cd1723e7567edc6448b3d96cb58a09a15c7ada1","source_sha256":"765132ee1c17dfe14fb0896007fdc73590153bf141bc5f6f17a4cfd84843c74f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using! congr($(f.hom.2 g) a)","hard_negative":false,"metrics":{"chosen_tokens":17,"rejected_tokens":2,"token_jaccard":0.066667,"token_length_ratio":0.117647},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"9ca3564c6a9bcaf3d9e51f2cc450761316e1e0f513984cce81b8cc0d73869692","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Action.Basic\npublic import Mathlib.RepresentationTheory.Continuous.Basic\n\nNamespace:\nTopRep\n\nLocal context:\n/-\nCopyright (c) 2026 Yunzhou Xie. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Edison Xie, Richard Hill\n-/\n/-!\n# Topological representations\n\nThis file defines the category `TopRep k G` of topological representations of a monoid `G` over a\ntopological ring `k`, and shows that it is equivalent to the category `Action (TopModuleCat k) G`.\n-/\n\n@[expose] public section\n\nuniverse w u v\n\n/-- The category of topological representations of a monoid `G` over a topological ring `k`, and\ntheir morphisms. -/\nstructure TopRep (k : Type u) (G : Type v) [TopologicalSpace k] [Ring k]\n [IsTopologicalRing k] [Monoid G] where\n private mk ::\n /-- the underlying type of an object in `TopRep k G` -/\n V : Type w\n [hV1 : AddCommGroup V]\n [hV2 : Module k V]\n [hV3 : TopologicalSpace V]\n [hV4 : IsTopologicalAddGroup V]\n [hV5 : ContinuousSMul k V]\n /-- the underlying continuous representation of an object in `TopRep k G` -/\n ρ : ContRepresentation k G V\n\nnamespace TopRep\n\nvariable {k : Type u} {G : Type v} {X Y : Type w} [TopologicalSpace k] [Ring k]\n [IsTopologicalRing k] [Monoid G] [AddCommGroup X] [Module k X] [TopologicalSpace X]\n [IsTopologicalAddGroup X] [ContinuousSMul k X] [AddCommGroup Y] [Module k Y] [TopologicalSpace Y]\n [IsTopologicalAddGroup Y] [ContinuousSMul k Y] {ρ : ContRepresentation k G X}\n {σ : ContRepresentation k G Y}\n\nopen ContRepresentation CategoryTheory\n\nattribute [instance] hV1 hV2 hV3 hV4 hV5\n\ninitialize_simps_projections TopRep (-hV1, -hV2)\n\ninstance : CoeSort (TopRep k G) (Type w) := ⟨TopRep.V⟩\n\nattribute [coe] V\n\nvariable (ρ) in\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\n/-- The object in the category of topological representations associated to a type equipped with a\ncontinuous representation. This is the preferred way to construct a term of `TopRep k G`. -/\nabbrev of : TopRep k G := ⟨X, ρ⟩\n\nvariable (X ρ) in\nlemma of_V : (of ρ).V = X := by with_reducible rfl\n\nvariable (X ρ) in\nlemma of_ρ : (of ρ).ρ = ρ := by with_reducible rfl\n\nset_option backward.privateInPublic true in\n/-- The type of morphisms in `TopRep k G`. -/\n@[ext]\nstructure Hom (A B : TopRep k G) where\n private mk ::\n /-- The underlying `G`-equivariant linear map. -/\n hom' : A.ρ →ⁱL B.ρ\n\nvariable (A B C : TopRep.{w} k G)\n\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\ninstance : Category (TopRep.{w} k G) where\n Hom A B := Hom A B\n id A := ⟨.id (π₁ := A.ρ)⟩\n comp f g := ⟨g.hom'.comp f.hom'⟩\n\nset_option backward.privateInPublic true in\nset_option backward.privateInPublic.warn false in\ninstance : ConcreteCategory (TopRep.{w} k G) (fun A B ↦ A.ρ →ⁱL B.ρ) where\n hom := Hom.hom'\n ofHom := Hom.mk\n\nvariable {A B} in\n/-- Turn a morphism in `TopRep` back into an `IntertwiningMap`. -/\nabbrev Hom.hom (f : Hom A B) := ConcreteCategory.hom (C := TopRep k G) f\n\nvariable {A B} in\n/-- Typecheck an `IntertwiningMap` as a morphism in `TopRep`. -/\nabbrev ofHom (f : ρ →ⁱL σ) : of ρ ⟶ of σ :=\n ConcreteCategory.ofHom (C := TopRep.{w} k G) f\n\n@[simp] lemma hom_ofHom (f : ρ →ⁱL σ) : (ofHom f).hom = f := rfl\n\n@[simp] lemma ofHom_hom (f : A ⟶ B) : ofHom f.hom = f := rfl\n\nvariable {A B} in\n/-- The morphism of topological modules underlying a morphism in `TopRep k G`. -/\nabbrev Hom.toTopModuleCatHom (f : Hom A B) :\n TopModuleCat.of k A ⟶ TopModuleCat.of k B :=\n TopModuleCat.ofHom f.hom.toContinuousLinearMap\n\n/-\nThe results below duplicate the `ConcreteCategory` simp lemmas, but we can keep them for `dsimp`.\n-/\n@[simp] lemma hom_id : (𝟙 A : A ⟶ A).hom = .id (π₁ := A.ρ) := rfl\n\n/- Provided for rewriting. -/\nlemma id_apply (a : A) : (𝟙 A : A ⟶ A) a = a := rfl\n\n@[simp] lemma hom_comp (f : A ⟶ B) (g : B ⟶ C) : (f ≫ g).hom = g.hom.comp f.hom := rfl\n\n/- Provided for rewriting. -/\nvariable {A B C} in\nlemma comp_apply (f : A ⟶ B) (g : B ⟶ C) (a : A) : (f ≫ g) a = g (f a) := rfl\n\nvariable {A B} in\n@[ext] lemma hom_ext {f g : A ⟶ B} (hf : f.hom = g.hom) : f = g := Hom.ext hf\n\nvariable {A B} in\n\nTarget:\nlemma hom_comm_apply (f : A ⟶ B) (g : G) (a : A) : f.hom (A.ρ g a) = B.ρ g (f.hom a) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory/Continuous","family_id":"hom_comm_apply","file_id":"mathlib/Mathlib/RepresentationTheory/Continuous/TopRep.lean","sample_id":"32215e9ee86a34a10891b4942cd1723e7567edc6448b3d96cb58a09a15c7ada1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"eaccf4f10bf570c90d2b3d8beb83a4c95905301b785beb07c71582c6a01de46a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c094a00555c2f947fa6dc1a0d0fa8e67995fa44856af1be349ea6fdb4a5ce08c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"adcb4435987d31a857d485cac4c863eba52c3fd245538c2d18dcd29350783d48","source_sha256":"43ea0181376ff1f89cc7c8eb911300f2c583a8b06779ef72e8198444b04b5bf5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← lowerSemicontinuous_restrict_iff, restrict_eq,\n lowerSemicontinuous_iff_isOpen_preimage, preimage_comp, isOpen_induced_iff,\n Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm]","hard_negative":true,"metrics":{"chosen_tokens":21,"rejected_tokens":3,"token_jaccard":0.055556,"token_length_ratio":0.142857},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"9ccdcb619f1f3638776037ee5d66388bebc168e6147353f27870207bbf73b631","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Semicontinuity.Defs\npublic import Mathlib.Algebra.GroupWithZero.Indicator\npublic import Mathlib.Topology.Piecewise\npublic import Mathlib.Topology.Algebra.InfiniteSum.ENNReal\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Antoine Chambert-Loir, Anatole Dedecker\n-/\n/-!\n# Lower and Upper Semicontinuity\n\nThis file develops key properties of upper and lower semicontinuous functions.\n\n## Main definitions and results\n\nWe have some equivalent definitions of lower- and upper-semicontinuity (under certain\nrestrictions on the order on the codomain):\n* `lowerSemicontinuous_iff_isOpen_preimage` in a linear order;\n* `lowerSemicontinuous_iff_isClosed_preimage` in a linear order;\n* `lowerSemicontinuousAt_iff_le_liminf` in a complete linear order;\n* `lowerSemicontinuous_iff_isClosed_epigraph` in a linear order with the order\n topology.\n\nWe also prove:\n\n* `indicator s (fun _ ↦ y)` is lower semicontinuous when `s` is open and `0 ≤ y`,\n or when `s` is closed and `y ≤ 0`;\n* continuous functions are lower semicontinuous;\n* left composition with a continuous monotone functions maps lower semicontinuous functions to lower\n semicontinuous functions. If the function is anti-monotone, it instead maps lower semicontinuous\n functions to upper semicontinuous functions;\n* a sum of two (or finitely many) lower semicontinuous functions is lower semicontinuous;\n* a supremum of a family of lower semicontinuous functions is lower semicontinuous;\n* An infinite sum of `ℝ≥0∞`-valued lower semicontinuous functions is lower semicontinuous.\n\nSimilar results are stated and proved for upper semicontinuity.\n\nWe also prove that a function is continuous if and only if it is both lower and upper\nsemicontinuous.\n\n## Implementation details\n\nAll the nontrivial results for upper semicontinuous functions are deduced from the corresponding\nones for lower semicontinuous functions using `OrderDual`.\n\n## References\n\n* \n* \n\n\n+ lower and upper semicontinuity correspond to `r := (f · > ·)` and `r := (f · < ·)`;\n+ lower and upper hemicontinuity correspond to `r := (fun x s ↦ IsOpen s ∧ ((f x) ∩ s).Nonempty)`\n and `r := (fun x s ↦ s ∈ 𝓝ˢ (f x))`, respectively.\n-/\n\npublic section\n\nopen Topology ENNReal\n\nopen Set Function Filter\n\nvariable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace γ] {f : α → β} {s t : Set α}\n {x : α} {y z : β}\n\n/-! ### lower bounds -/\n\nsection\n\nvariable [LinearOrder β]\n\n/-- A lower semicontinuous function attains its lower bound on a nonempty compact set. -/\ntheorem LowerSemicontinuousOn.exists_isMinOn {s : Set α} (ne_s : s.Nonempty)\n (hs : IsCompact s) (hf : LowerSemicontinuousOn f s) :\n ∃ a ∈ s, IsMinOn f s a := by\n simp only [isMinOn_iff]\n have _ : Nonempty α := Exists.nonempty ne_s\n have _ : Nonempty s := Nonempty.to_subtype ne_s\n let φ : β → Filter α := fun b ↦ 𝓟 (s ∩ f ⁻¹' Iic b)\n let ℱ : Filter α := ⨅ a : s, φ (f a)\n have : ℱ.NeBot := by\n apply iInf_neBot_of_directed _ _\n · change Directed GE.ge (fun x ↦ (φ ∘ (fun (a : s) ↦ f ↑a)) x)\n exact Directed.mono_comp GE.ge (fun x y hxy ↦\n principal_mono.mpr (inter_subset_inter_right _ (preimage_mono <| Iic_subset_Iic.mpr hxy)))\n (Std.Total.directed _)\n · intro x\n have : (pure x : Filter α) ≤ φ (f x) := le_principal_iff.mpr ⟨x.2, le_refl (f x)⟩\n exact neBot_of_le this\n have hℱs : ℱ ≤ 𝓟 s :=\n iInf_le_of_le (Classical.choice inferInstance) (principal_mono.mpr <| inter_subset_left)\n have hℱ (x) (hx : x ∈ s) : ∀ᶠ y in ℱ, f y ≤ f x :=\n mem_iInf_of_mem ⟨x, hx⟩ (by apply inter_subset_right)\n obtain ⟨a, ha, h⟩ := hs hℱs\n refine ⟨a, ha, fun x hx ↦ le_of_not_gt fun hxa ↦ ?_⟩\n let _ : (𝓝 a ⊓ ℱ).NeBot := h\n suffices ∀ᶠ _ in 𝓝 a ⊓ ℱ, False by rwa [eventually_const] at this\n filter_upwards [(hf a ha (f x) hxa).filter_mono (inf_le_inf_left _ hℱs),\n (hℱ x hx).filter_mono (inf_le_right : 𝓝 a ⊓ ℱ ≤ ℱ)] using fun y h₁ h₂ ↦ not_le_of_gt h₁ h₂\n\n/-- A lower semicontinuous function is bounded below on a compact set. -/\ntheorem LowerSemicontinuousOn.bddBelow_of_isCompact [Nonempty β] {s : Set α} (hs : IsCompact s)\n (hf : LowerSemicontinuousOn f s) : BddBelow (f '' s) := by\n cases s.eq_empty_or_nonempty with\n | inl h =>\n simp only [h, Set.image_empty]\n exact bddBelow_empty\n | inr h =>\n obtain ⟨a, _, has⟩ := LowerSemicontinuousOn.exists_isMinOn h hs hf\n exact has.bddBelow\n\nend\n\n/-! #### Indicators -/\n\n\nsection\n\nvariable [Zero β] [Preorder β]\n\ntheorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuous (indicator s fun _x => y) := by\n intro x z hz\n by_cases h : x ∈ s <;> simp [h] at hz\n · filter_upwards [hs.mem_nhds h]\n simp +contextual [hz]\n · refine Filter.Eventually.of_forall fun x' => ?_\n by_cases h' : x' ∈ s <;> simp [h', hz.trans_le hy, hz]\n\ntheorem IsOpen.lowerSemicontinuousOn_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousOn (indicator s fun _x => y) t :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t\n\ntheorem IsOpen.lowerSemicontinuousAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousAt (indicator s fun _x => y) x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x\n\ntheorem IsOpen.lowerSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) :\n LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x\n\ntheorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuous (indicator s fun _x => y) := by\n intro x z hz\n by_cases h : x ∈ s <;> simp [h] at hz\n · refine Filter.Eventually.of_forall fun x' => ?_\n by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy]\n · filter_upwards [hs.isOpen_compl.mem_nhds h]\n simp +contextual [hz]\n\ntheorem IsClosed.lowerSemicontinuousOn_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousOn (indicator s fun _x => y) t :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t\n\ntheorem IsClosed.lowerSemicontinuousAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousAt (indicator s fun _x => y) x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x\n\ntheorem IsClosed.lowerSemicontinuousWithinAt_indicator (hs : IsClosed s) (hy : y ≤ 0) :\n LowerSemicontinuousWithinAt (indicator s fun _x => y) t x :=\n (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x\n\nend\n\n/-! #### Relationship with continuity -/\n\nsection\n\nvariable [Preorder β]\n\ntheorem lowerSemicontinuous_iff_isOpen_preimage :\n LowerSemicontinuous f ↔ ∀ y, IsOpen (f ⁻¹' Ioi y) :=\n ⟨fun H y => isOpen_iff_mem_nhds.2 fun x hx => H x y hx, fun H _x y y_lt =>\n IsOpen.mem_nhds (H y) y_lt⟩\n\ntheorem LowerSemicontinuous.isOpen_preimage (hf : LowerSemicontinuous f) (y : β) :\n IsOpen (f ⁻¹' Ioi y) :=\n lowerSemicontinuous_iff_isOpen_preimage.1 hf y\n\nTarget:\ntheorem lowerSemicontinuousOn_iff_preimage_Ioi :\n LowerSemicontinuousOn f s ↔ ∀ b, ∃ u, IsOpen u ∧ s ∩ f ⁻¹' Set.Ioi b = s ∩ u :=\n\nProof body:\n","rejected":"by\n exact lowerSemicontinuousOn_iff_preimage_Ioi","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"6c8586e001f66f12d6a205fc8558551874444493c7c30dd1631d81b2842b663a","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Semicontinuity","family_id":"lowersemicontinuouson_iff_preimage_ioi","file_id":"mathlib/Mathlib/Topology/Semicontinuity/Basic.lean","sample_id":"adcb4435987d31a857d485cac4c863eba52c3fd245538c2d18dcd29350783d48"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e9c639cb14e1b7dc55b43203e26652461236741a959d7df156742cc9bb47b669","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0cef499e90b430b45b14a96b6d959191b4212735d70a024d220719066c9cc7b6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c536256fd5617a20a1f13fac5d41e784b6e0dff1b04749d89bae53f7731311d9","source_sha256":"1772ebc6d5f489fb8a42b880ceafc783ce77133acd1e06ebadf2800bb4211ccd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor <;> intro\n exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]","hard_negative":true,"metrics":{"chosen_tokens":18,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.111111},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"9e5a61f41909c11f5645e47e7dd48d9667cd026e1599e50709c789d39a2a4493","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.CommSq\npublic import Mathlib.CategoryTheory.Retract\n\nNamespace:\nCategoryTheory.HasLiftingProperty\n\nLocal context:\n/-\nCopyright (c) 2021 Jakob Scholbach. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob Scholbach, Joël Riou\n-/\n/-!\n# Lifting properties\n\nThis file defines the lifting property of two morphisms in a category and\nshows basic properties of this notion.\n\n## Main results\n- `HasLiftingProperty`: the definition of the lifting property\n\n## Tags\nlifting property\n\n## TODO\n1) direct/inverse images, adjunctions\n\n-/\n\n@[expose] public section\n\nuniverse v\n\nnamespace CategoryTheory\n\nopen Category\n\nvariable {C : Type*} [Category* C] {A B B' X Y Y' : C} (i : A ⟶ B) (i' : B ⟶ B') (p : X ⟶ Y)\n (p' : Y ⟶ Y')\n\n/-- `HasLiftingProperty i p` means that `i` has the left lifting\nproperty with respect to `p`, or equivalently that `p` has\nthe right lifting property with respect to `i`. -/\n@[to_dual self (reorder := A Y, B X, i p)]\nclass HasLiftingProperty : Prop where\n /-- Unique field expressing that any commutative square built from `f` and `g` has a lift -/\n sq_hasLift : ∀ {f : A ⟶ X} {g : B ⟶ Y} (sq : CommSq f i p g), sq.HasLift\n\nattribute [to_dual self] HasLiftingProperty.sq_hasLift\nattribute [to_dual self (reorder := A Y, B X, i p, sq_hasLift (f g))] HasLiftingProperty.mk\n\n@[to_dual self]\ninstance (priority := 100) sq_hasLift_of_hasLiftingProperty {f : A ⟶ X} {g : B ⟶ Y}\n (sq : CommSq f i p g) [hip : HasLiftingProperty i p] : sq.HasLift := hip.sq_hasLift _\n\nnamespace HasLiftingProperty\n\nvariable {i p}\n\n@[to_dual self]\ntheorem op (h : HasLiftingProperty i p) : HasLiftingProperty p.op i.op :=\n ⟨fun {f} {g} sq => by\n simp only [CommSq.HasLift.iff_unop, Quiver.Hom.unop_op]\n infer_instance⟩\n\n@[to_dual self]\ntheorem unop {A B X Y : Cᵒᵖ} {i : A ⟶ B} {p : X ⟶ Y} (h : HasLiftingProperty i p) :\n HasLiftingProperty p.unop i.unop :=\n ⟨fun {f} {g} sq => by\n rw [CommSq.HasLift.iff_op]\n simp only [Quiver.Hom.op_unop]\n infer_instance⟩\n\n@[to_dual self]\ntheorem iff_op : HasLiftingProperty i p ↔ HasLiftingProperty p.op i.op :=\n ⟨op, unop⟩\n\n@[to_dual self]\ntheorem iff_unop {A B X Y : Cᵒᵖ} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty p.unop i.unop :=\n ⟨unop, op⟩\n\nvariable (i p)\n\n@[to_dual of_right_iso]\ninstance (priority := 100) of_left_iso [IsIso i] : HasLiftingProperty i p :=\n ⟨fun {f} {g} sq =>\n CommSq.HasLift.mk'\n { l := inv i ≫ f\n fac_left := by simp only [IsIso.hom_inv_id_assoc]\n fac_right := by simp only [sq.w, assoc, IsIso.inv_hom_id_assoc] }⟩\n\n@[to_dual of_comp_right]\ninstance of_comp_left [HasLiftingProperty i p] [HasLiftingProperty i' p] :\n HasLiftingProperty (i ≫ i') p :=\n ⟨fun {f} {g} sq => by\n have fac := sq.w\n rw [assoc] at fac\n exact\n CommSq.HasLift.mk'\n { l := (CommSq.mk (CommSq.mk fac).fac_right).lift\n fac_left := by simp only [assoc, CommSq.fac_left]\n fac_right := by simp only [CommSq.fac_right] }⟩\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) [hip : HasLiftingProperty i p] :\n HasLiftingProperty i' p := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') [hip : HasLiftingProperty i p] : HasLiftingProperty i p' := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nTarget:\ntheorem iff_of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty i' p :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_c536256fd561","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"c957284382598edc8b24191338be24f0831558ec87825040bd4bb21c6b366c93","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/LiftingProperties","family_id":"iff_of_arrow_iso_left","file_id":"mathlib/Mathlib/CategoryTheory/LiftingProperties/Basic.lean","sample_id":"c536256fd5617a20a1f13fac5d41e784b6e0dff1b04749d89bae53f7731311d9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8b81a5f6b795898182cb6620f9c33ac98b8724c109323d039d890dbed2337d7b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"3350b3927abc2c50037846ae710b114deb5515e51cf24b36aa7736df5d64efa9","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5985be8a58d477ae297cb867a8ae68ed309961c3f0afb9f562631189369f931b","source_sha256":"bdfd7123efa6932f7f417fb21d899a1972d4f19df96a39961e46ce27a071ef94","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [equivariantProjection_apply]\n simp only [conjugate_i π i h]\n rw [Finset.sum_const, Finset.card_univ, ← Nat.cast_smul_eq_nsmul k, smul_smul,\n Fintype.card_eq_nat_card, Ring.inverse_mul_cancel _ hcard, one_smul]","hard_negative":false,"metrics":{"chosen_tokens":43,"rejected_tokens":50,"token_jaccard":0.933333,"token_length_ratio":1.162791},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"9fc3b9f9a86da568105e475f50d141da92fa411c75ea8787e4b3792b74411ac1","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TypeTags.Finite\npublic import Mathlib.Algebra.MonoidAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Basis.VectorSpace\npublic import Mathlib.RingTheory.SimpleModule.Basic\npublic import Mathlib.RepresentationTheory.Semisimple\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# Maschke's theorem\n\nWe prove **Maschke's theorem** for finite groups,\nin the formulation that every submodule of a `k[G]` module has a complement,\nwhen `k` is a field with `Fintype.card G` invertible in `k`.\n\nWe do the core computation in greater generality.\nFor any commutative ring `k` in which `Fintype.card G` is invertible,\nand a `k[G]`-linear map `i : V → W` which admits a `k`-linear retraction `π`,\nwe produce a `k[G]`-linear retraction by\ntaking the average over `G` of the conjugates of `π`.\n\n## Implementation Notes\n\n* These results assume `IsUnit (Fintype.card G : k)` which is equivalent to the more\n familiar `¬(ringChar k ∣ Fintype.card G)`.\n\n## Future work\nIt's not so far to give the usual statement, that every finite-dimensional representation\nof a finite group is semisimple (i.e. a direct sum of irreducibles).\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Module MonoidAlgebra\nopen scoped Ring\n\n/-!\nWe now do the key calculation in Maschke's theorem.\n\nGiven `V → W`, an inclusion of `k[G]` modules,\nassume we have some retraction `π` (i.e. `∀ v, π (i v) = v`),\njust as a `k`-linear map.\n(When `k` is a field, this will be available cheaply, by choosing a basis.)\n\nWe now construct a retraction of the inclusion as a `k[G]`-linear map,\nby the formula\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\n\nnamespace LinearMap\n\n\n-- At first we work with any `[CommRing k]`, and add the assumption that\n-- `IsUnit (Fintype.card G : k)` when it is required.\nvariable {k : Type*} [CommRing k] {G : Type*} [Group G]\nvariable {V : Type*} [AddCommGroup V] [Module k V] [Module k[G] V] [IsScalarTower k k[G] V]\nvariable {W : Type*} [AddCommGroup W] [Module k W] [Module k[G] W] [IsScalarTower k k[G] W]\nvariable (π : W →ₗ[k] V)\n\n/-- We define the conjugate of `π` by `g`, as a `k`-linear map. -/\ndef conjugate (g : G) : W →ₗ[k] V :=\n GroupSMul.linearMap k V g⁻¹ ∘ₗ π ∘ₗ GroupSMul.linearMap k W g\n\ntheorem conjugate_apply (g : G) (v : W) :\n π.conjugate g v = MonoidAlgebra.single g⁻¹ (1 : k) • π (MonoidAlgebra.single g (1 : k) • v) :=\n rfl\n\nvariable (i : V →ₗ[k[G]] W)\n\nsection\n\ntheorem conjugate_i (h : ∀ v : V, π (i v) = v) (g : G) (v : V) :\n (conjugate π g : W → V) (i v) = v := by\n rw [conjugate_apply, ← i.map_smul, h, ← mul_smul, single_mul_single, mul_one, inv_mul_cancel,\n ← one_def, one_smul]\n\nend\n\nvariable (G) [Fintype G]\n\n/-- The sum of the conjugates of `π` by each element `g : G`, as a `k`-linear map.\n\n(We postpone dividing by the size of the group as long as possible.)\n-/\ndef sumOfConjugates : W →ₗ[k] V :=\n ∑ g : G, π.conjugate g\n\nlemma sumOfConjugates_apply (v : W) : π.sumOfConjugates G v = ∑ g : G, π.conjugate g v :=\n LinearMap.sum_apply _ _ _\n\n/-- In fact, the sum over `g : G` of the conjugate of `π` by `g` is a `k[G]`-linear map.\n-/\ndef sumOfConjugatesEquivariant : W →ₗ[k[G]] V :=\n MonoidAlgebra.equivariantOfLinearOfComm (π.sumOfConjugates G) fun g v => by\n simp only [sumOfConjugates_apply, Finset.smul_sum, conjugate_apply]\n refine Fintype.sum_bijective (· * g) (Group.mulRight_bijective g) _ _ fun i ↦ ?_\n simp only [smul_smul, single_mul_single, mul_inv_rev, mul_inv_cancel_left, one_mul]\n\ntheorem sumOfConjugatesEquivariant_apply (v : W) :\n π.sumOfConjugatesEquivariant G v = ∑ g : G, π.conjugate g v :=\n π.sumOfConjugates_apply G v\n\nsection\n\n/-- We construct our `k[G]`-linear retraction of `i` as\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\ndef equivariantProjection : W →ₗ[k[G]] V :=\n (Fintype.card G : k)⁻¹ʳ • π.sumOfConjugatesEquivariant G\n\ntheorem equivariantProjection_apply (v : W) :\n π.equivariantProjection G v = (Nat.card G : k)⁻¹ʳ • ∑ g : G, π.conjugate g v := by\n simp only [equivariantProjection, smul_apply, sumOfConjugatesEquivariant_apply,\n Fintype.card_eq_nat_card]\n\nTarget:\ntheorem equivariantProjection_condition (hcard : IsUnit (Nat.card G : k))\n (h : ∀ v : V, π (i v) = v) (v : V) : (π.equivariantProjection G) (i v) = v :=\n\nProof body:\n","rejected":"```lean\nby\n rw [equivariantProjection_apply]\n simp only [conjugate_i π i h]\n rw [Finset.sum_const, Finset.card_univ, ← Nat.cast_smul_eq_nsmul k, smul_smul,\n Fintype.card_eq_nat_card, Ring.inverse_mul_cancel _ hcard, one_smul]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory","family_id":"equivariantprojection_condition","file_id":"mathlib/Mathlib/RepresentationTheory/Maschke.lean","sample_id":"5985be8a58d477ae297cb867a8ae68ed309961c3f0afb9f562631189369f931b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"35fe7827c3ae92271ac656c21126b3e74bb2af16e6d44afa3425ecfe12db8823","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"661b11ed491669a87dc9e4c839c3f0fea5cc231d981b2423d46f2806e8cb5ec9","source_sha256":"18568baeeffeaaa701b9fde364e1ec597e66170a4d12d2f9f2bfbc098c10a0b6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := ratSqrt_sq_le (x := x) h\n have : (x.ratSqrt prec ^ 2 : ℝ) ≤ ↑x := by norm_cast\n have := Real.sqrt_monotone this\n rwa [Real.sqrt_sq] at this\n simpa only [Rat.cast_nonneg] using ratSqrt_nonneg _ _","hard_negative":true,"metrics":{"chosen_tokens":53,"rejected_tokens":8,"token_jaccard":0.111111,"token_length_ratio":0.150943},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"9fc80b056d8373774bcc7ef60c8e684f5d66912d7d2386f4df136d20d9e6d3c5","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Real.Sqrt\npublic import Mathlib.Data.Rat.NatSqrt.Defs\n\nNamespace:\nNat\n\nLocal context:\n/-\nCopyright (c) 2025 Lean FRO, LLC. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\nComparisons between rational approximations to the square root of a natural number\nand the real square root.\n-/\n\npublic section\n\nnamespace Nat\n\nTarget:\ntheorem ratSqrt_le_realSqrt (x : ℕ) {prec : ℕ} (h : 0 < prec) : ratSqrt x prec ≤ √x :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"7884e5bedcf8a6a91217698c0e223fda43ac524c20bd9d21c16f62ebfb47569b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Rat","family_id":"ratsqrt_le_realsqrt","file_id":"mathlib/Mathlib/Analysis/Rat/NatSqrt/Real.lean","sample_id":"661b11ed491669a87dc9e4c839c3f0fea5cc231d981b2423d46f2806e8cb5ec9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"68f4be1a74b4ebf33651430b328acfd5b503c8c14886762241b2eb6d133671d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"43adac10f15ae35c696f15ed8cf025b8e7497b105ad64f7bbec50ac8a9b95aa7","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2c93ae538bb5314f013ad26261bdad9269517948b7e335c42f5739ceaba15a2c","source_sha256":"d958937be9af4a6b0fb8e729ceaf03c04a4a5d4477d0d9768e44a20281735051","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← not_countable_iff, countable_iff_nonempty_embedding, not_nonempty_iff]","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":5,"token_jaccard":0.076923,"token_length_ratio":0.5},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"a0210ed23f89c8d0915bd2ff29ab403e0c0ef931de95564745470f20f7c5c476","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Countable.Defs\npublic import Mathlib.Data.Fin.Tuple.Basic\npublic import Mathlib.Data.ENat.Defs\npublic import Mathlib.Logic.Equiv.Nat\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Countable types\n\nIn this file we provide basic instances of the `Countable` typeclass defined elsewhere.\n-/\n\npublic section\n\nassert_not_exists Monoid\n\nuniverse u v w\n\nopen Function\n\ninstance : Countable ℤ :=\n Countable.of_equiv ℕ Equiv.intEquivNat.symm\n\n/-!\n### Definition in terms of `Function.Embedding`\n-/\n\nsection Embedding\n\nvariable {α : Sort u} {β : Sort v}\n\ntheorem countable_iff_nonempty_embedding : Countable α ↔ Nonempty (α ↪ ℕ) :=\n ⟨fun ⟨⟨f, hf⟩⟩ => ⟨⟨f, hf⟩⟩, fun ⟨f⟩ => ⟨⟨f, f.2⟩⟩⟩\n\nTarget:\ntheorem uncountable_iff_isEmpty_embedding : Uncountable α ↔ IsEmpty (α ↪ ℕ) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_2c93ae538bb5","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"288c82237074d8c38fdc3a11eaeaaa859a9b901e54f832a428a356046e649c6c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Countable","family_id":"uncountable_iff_isempty_embedding","file_id":"mathlib/Mathlib/Data/Countable/Basic.lean","sample_id":"2c93ae538bb5314f013ad26261bdad9269517948b7e335c42f5739ceaba15a2c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4d5b45b69ab3c62a4548e2cb469ea9c53a099ca2ae47db5b75c64800be36cbfe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cdec5f9eb18d68c299a4d3c311a051c2af449bc934a19bb8d3f0cfafc1742324","source_sha256":"95d50974f2281ad2a4ec76fe3c119af793109b3fa6e188801eaecdf86f226a41","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n rcases eq_or_ne x c with rfl | hx; · simp [dist_comm]\n rw [mem_preimage, mem_sphere, ← inversion_mem_perpBisector_inversion_iff hR] <;> simp [*]","hard_negative":false,"metrics":{"chosen_tokens":34,"rejected_tokens":2,"token_jaccard":0.037037,"token_length_ratio":0.058824},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"a03c3ed5eb3a6de4389c6506148b41965b0c0009407b954d2e5fedf8438e1ef3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Geometry.Euclidean.Inversion.Basic\npublic import Mathlib.Geometry.Euclidean.PerpBisector\n\nNamespace:\nEuclideanGeometry\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Image of a hyperplane under inversion\n\nIn this file we prove that the inversion with center `c` and radius `R ≠ 0` maps a sphere passing\nthrough the center to a hyperplane, and vice versa. More precisely, it maps a sphere with center\n`y ≠ c` and radius `dist y c` to the hyperplane\n`AffineSubspace.perpBisector c (EuclideanGeometry.inversion c R y)`.\n\nThe exact statements are a little more complicated because `EuclideanGeometry.inversion c R` sends\nthe center to itself, not to a point at infinity.\n\nWe also prove that the inversion sends an affine subspace passing through the center to itself.\n\n## Keywords\n\ninversion\n-/\n\npublic section\n\nopen Metric Function AffineMap Set AffineSubspace\nopen scoped Topology\n\nvariable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P] {c x y : P} {R : ℝ}\n\nnamespace EuclideanGeometry\n\n-- see https://github.com/leanprover-community/mathlib4/issues/29041\nset_option linter.unusedSimpArgs false in\n/-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a\nhyperplane. -/\ntheorem inversion_mem_perpBisector_inversion_iff (hR : R ≠ 0) (hx : x ≠ c) (hy : y ≠ c) :\n inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c := by\n rw [mem_perpBisector_iff_dist_eq, dist_inversion_inversion hx hy, dist_inversion_center]\n simp [field, eq_comm, ↓hx, ↓hy]\n\n/-- The inversion with center `c` and radius `R` maps a sphere passing through the center to a\nhyperplane. -/\ntheorem inversion_mem_perpBisector_inversion_iff' (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R x ∈ perpBisector c (inversion c R y) ↔ dist x y = dist y c ∧ x ≠ c := by\n rcases eq_or_ne x c with rfl | hx\n · simp [*]\n · simp [inversion_mem_perpBisector_inversion_iff hR hx hy, hx]\n\ntheorem preimage_inversion_perpBisector_inversion (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' perpBisector c (inversion c R y) = sphere y (dist y c) \\ {c} :=\n Set.ext fun _ ↦ inversion_mem_perpBisector_inversion_iff' hR hy\n\ntheorem preimage_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \\ {c} := by\n rw [← dist_inversion_center, ← preimage_inversion_perpBisector_inversion hR,\n inversion_inversion] <;> simp [*]\n\ntheorem image_inversion_perpBisector (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R '' perpBisector c y = sphere (inversion c R y) (R ^ 2 / dist y c) \\ {c} := by\n rw [image_eq_preimage_of_inverse (inversion_involutive _ hR) (inversion_involutive _ hR),\n preimage_inversion_perpBisector hR hy]\n\nTarget:\ntheorem preimage_inversion_sphere_dist_center (hR : R ≠ 0) (hy : y ≠ c) :\n inversion c R ⁻¹' sphere y (dist y c) =\n insert c (perpBisector c (inversion c R y) : Set P) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Geometry/Euclidean","family_id":"preimage_inversion_sphere_dist_center","file_id":"mathlib/Mathlib/Geometry/Euclidean/Inversion/ImageHyperplane.lean","sample_id":"cdec5f9eb18d68c299a4d3c311a051c2af449bc934a19bb8d3f0cfafc1742324"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dc1bca91413146246510c9f2bcf86578204390b2f28c1c915349bb5070439d6f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8ccbf2f390405d3fbc9bc6f7d4932ab6dc670c1f0fa60ca8e707640aec1a4b71","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dd5dda343143c8547708c93efe6437d75765097ec9bba5770558209c4666433d","source_sha256":"3da6bfff8077a4de2d75547c2533816fed03dfd5c1acc867b6989c25e9e68a21","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [e.symm.image_eq_preimage_symm]; rfl","hard_negative":false,"metrics":{"chosen_tokens":11,"rejected_tokens":16,"token_jaccard":0.714286,"token_length_ratio":1.454545},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"a08e0cf4fc25173c5d838494d45f80b92824b8e35a88f01a5a6e9a79825b52da","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Directed\npublic import Mathlib.Order.RelIso.Basic\npublic import Mathlib.Logic.Embedding.Set\npublic import Mathlib.Logic.Equiv.Set\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Interactions between relation homomorphisms and sets\n\nIt is likely that there are better homes for many of these statement,\nin files further down the import graph.\n-/\n\n@[expose] public section\n\n\nopen Function\n\nuniverse u v w\n\nvariable {α β : Type*} {r : α → α → Prop} {s : β → β → Prop}\n\nnamespace RelHomClass\n\nvariable {F : Type*}\n\ntheorem map_inf [SemilatticeInf α] [LinearOrder β] [FunLike F β α]\n [RelHomClass F (· < ·) (· < ·)] (a : F) (m n : β) :\n a (m ⊓ n) = a m ⊓ a n :=\n (StrictMono.monotone fun _ _ => map_rel a).map_inf m n\n\ntheorem map_sup [SemilatticeSup α] [LinearOrder β] [FunLike F β α]\n [RelHomClass F (· > ·) (· > ·)] (a : F) (m n : β) :\n a (m ⊔ n) = a m ⊔ a n :=\n map_inf (α := αᵒᵈ) (β := βᵒᵈ) _ _ _\n\ntheorem directed [FunLike F α β] [RelHomClass F r s] {ι : Sort*} {a : ι → α} {f : F}\n (ha : Directed r a) : Directed s (f ∘ a) :=\n ha.mono_comp _ fun _ _ h ↦ map_rel f h\n\ntheorem directedOn [FunLike F α β] [RelHomClass F r s] {f : F}\n {t : Set α} (hs : DirectedOn r t) : DirectedOn s (f '' t) :=\n hs.mono_comp fun _ _ h ↦ map_rel f h\n\nend RelHomClass\n\nnamespace RelIso\n\ntheorem range_eq (e : r ≃r s) : Set.range e = Set.univ := by simp\n\nend RelIso\n\n/-- `Subrel r p` is the inherited relation on a subtype.\n\nWe could also consider a Set.Subrel r s variant for dot notation, but this ends up interacting\npoorly with `simpNF`. -/\ndef Subrel (r : α → α → Prop) (p : α → Prop) : Subtype p → Subtype p → Prop :=\n Subtype.val ⁻¹'o r\n\n@[simp]\ntheorem subrel_val (r : α → α → Prop) (p : α → Prop) {a b} : Subrel r p a b ↔ r a.1 b.1 :=\n Iff.rfl\n\nnamespace Subrel\n\n/-- The relation embedding from the inherited relation on a subset. -/\nprotected def relEmbedding (r : α → α → Prop) (p : α → Prop) : Subrel r p ↪r r :=\n ⟨Embedding.subtype _, Iff.rfl⟩\n\n@[simp]\ntheorem relEmbedding_apply (r : α → α → Prop) (p a) : Subrel.relEmbedding r p a = a.1 :=\n rfl\n\n/-- `Set.inclusion` as a relation embedding. -/\nprotected def inclusionEmbedding (r : α → α → Prop) {s t : Set α} (h : s ⊆ t) :\n Subrel r (· ∈ s) ↪r Subrel r (· ∈ t) where\n toFun := Set.inclusion h\n inj' _ _ h := (Set.inclusion_inj _).mp h\n map_rel_iff' := Iff.rfl\n\n@[simp]\ntheorem coe_inclusionEmbedding (r : α → α → Prop) {s t : Set α} (h : s ⊆ t) :\n (Subrel.inclusionEmbedding r h : s → t) = Set.inclusion h :=\n rfl\n\ninstance (r : α → α → Prop) [Std.Refl r] (p : α → Prop) : Std.Refl (Subrel r p) :=\n ⟨fun x => Std.Refl.refl (r := r) x⟩\n\ninstance (r : α → α → Prop) [Std.Symm r] (p : α → Prop) : Std.Symm (Subrel r p) :=\n ⟨fun x y => Std.Symm.symm (r := r) x y⟩\n\ninstance (r : α → α → Prop) [Std.Asymm r] (p : α → Prop) : Std.Asymm (Subrel r p) :=\n ⟨fun x y => Std.Asymm.asymm (r := r) x y⟩\n\ninstance (r : α → α → Prop) [IsTrans α r] (p : α → Prop) : IsTrans _ (Subrel r p) :=\n ⟨fun x y z => IsTrans.trans (r := r) x y z⟩\n\ninstance (r : α → α → Prop) [Std.Irrefl r] (p : α → Prop) : Std.Irrefl (Subrel r p) :=\n ⟨fun x => Std.Irrefl.irrefl (r := r) x⟩\n\ninstance (r : α → α → Prop) [Std.Trichotomous r] (p : α → Prop) : Std.Trichotomous (Subrel r p) :=\n ⟨fun x y => by rw [Subtype.ext_iff]; exact @Std.Trichotomous.trichotomous α r _ x y⟩\n\ninstance (r : α → α → Prop) [IsWellFounded α r] (p : α → Prop) : IsWellFounded _ (Subrel r p) :=\n (Subrel.relEmbedding r p).isWellFounded\n\ninstance (r : α → α → Prop) [IsPreorder α r] (p : α → Prop) : IsPreorder _ (Subrel r p) where\ninstance (r : α → α → Prop) [IsStrictOrder α r] (p : α → Prop) : IsStrictOrder _ (Subrel r p) where\ninstance (r : α → α → Prop) [IsWellOrder α r] (p : α → Prop) : IsWellOrder _ (Subrel r p) where\n\nend Subrel\n\n/-- If a proposition holds for all elements, then the `Subrel` is equivalent to the original\nrelation. -/\n@[simps! apply symm_apply]\ndef RelIso.subrelUnivIso {p : α → Prop} (h : ∀ x, p x) : Subrel r p ≃r r where\n toEquiv := Equiv.subtypeUnivEquiv h\n map_rel_iff' := by simp\n\n/-- Restrict the codomain of a relation embedding. -/\ndef RelEmbedding.codRestrict (p : Set β) (f : r ↪r s) (H : ∀ a, f a ∈ p) : r ↪r Subrel s (· ∈ p) :=\n ⟨f.toEmbedding.codRestrict p H, f.map_rel_iff'⟩\n\n@[simp]\ntheorem RelEmbedding.codRestrict_apply (p) (f : r ↪r s) (H a) :\n RelEmbedding.codRestrict p f H a = ⟨f a, H a⟩ :=\n rfl\n\nsection image\n\ntheorem RelIso.image_eq_preimage_symm (e : r ≃r s) (t : Set α) : e '' t = e.symm ⁻¹' t :=\n e.toEquiv.image_eq_preimage_symm t\n\nTarget:\ntheorem RelIso.preimage_eq_image_symm (e : r ≃r s) (t : Set β) : e ⁻¹' t = e.symm '' t :=\n\nProof body:\n","rejected":"by\n rw [e.symm.image_eq_preimage_symm]; rfl\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/RelIso","family_id":"reliso","file_id":"mathlib/Mathlib/Order/RelIso/Set.lean","sample_id":"dd5dda343143c8547708c93efe6437d75765097ec9bba5770558209c4666433d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b15c75b86cf707fcab5e6ebde44ef13e53518470fce8dd2bee06daea8b2ae81a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"23f21a25563f16af680ef8080d884dc90928aa2a7ff70b8b49d561b5eef2bb9e","source_sha256":"80e36a31fdad7f596e8087d0eff022ff75293f4eb9ca06fcd55ecdd117822a69","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro s\n set S := fun (i : ι) => Localization (M.map (Pi.evalRingHom R i))\n obtain ⟨r, hr⟩ :=\n surjective_piRingHom_algebraMap_comp_piEvalRingHom\n S M ((lift (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) s)\n refine ⟨r, (bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom R S _ M).injective ?_⟩\n rwa [lift_eq (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M) r]","hard_negative":false,"metrics":{"chosen_tokens":75,"rejected_tokens":3,"token_jaccard":0.025,"token_length_ratio":0.04},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"a10e225137d3ea86327605cf6c00bf89ccab52fcc5c98affb6fd3379804250b9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Pi\npublic import Mathlib.Algebra.BigOperators.Pi\npublic import Mathlib.Algebra.Divisibility.Prod\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.RingTheory.Localization.Basic\npublic import Mathlib.Algebra.Group.Pi.Units\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\nIsLocalization\n\nLocal context:\n/-\nCopyright (c) 2024 Madison Crim. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Madison Crim\n-/\n/-!\n# Localizing a product of commutative rings\n\n## Main Result\n\n* `bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom`: the canonical map from a\n localization of a finite product of rings `R i` at a monoid `M` to the direct product of\n localizations `R i` at the projection of `M` onto each corresponding factor is bijective.\n\n## Implementation notes\n\nSee `Mathlib/RingTheory/Localization/Defs.lean` for a design overview.\n\n## Tags\nlocalization, commutative ring\n-/\n\npublic section\n\nnamespace IsLocalization\n\nvariable {ι : Type*} (R S : ι → Type*)\n [Π i, CommSemiring (R i)] [Π i, CommSemiring (S i)] [Π i, Algebra (R i) (S i)]\n\n/-- If `S i` is a localization of `R i` at the submonoid `M i` for each `i`,\nthen `Π i, S i` is a localization of `Π i, R i` at the product submonoid. -/\ninstance (M : Π i, Submonoid (R i)) [∀ i, IsLocalization (M i) (S i)] :\n IsLocalization (.pi .univ M) (Π i, S i) where\n map_units m := Pi.isUnit_iff.mpr fun i ↦ map_units _ ⟨m.1 i, m.2 i ⟨⟩⟩\n surj z := by\n choose rm h using fun i ↦ surj (M := M i) (z i)\n exact ⟨(fun i ↦ (rm i).1, ⟨_, fun i _ ↦ (rm i).2.2⟩), funext h⟩\n exists_of_eq {x y} eq := by\n choose c hc using fun i ↦ exists_of_eq (M := M i) (congr_fun eq i)\n exact ⟨⟨_, fun i _ ↦ (c i).2⟩, funext hc⟩\n\nvariable (S' : Type*) [CommSemiring S'] [Algebra (Π i, R i) S'] (M : Submonoid (Π i, R i))\n\ntheorem iff_map_piEvalRingHom [Finite ι] :\n IsLocalization M S' ↔ IsLocalization (.pi .univ fun i ↦ M.map (Pi.evalRingHom R i)) S' :=\n iff_of_le_of_exists_dvd M _ (fun m hm i _ ↦ ⟨m, hm, rfl⟩) fun n hn ↦ by\n choose m mem eq using hn\n have := Fintype.ofFinite ι\n refine ⟨∏ i, m i ⟨⟩, prod_mem fun i _ ↦ mem i _, pi_dvd_iff.mpr fun i ↦ ?_⟩\n rw [Fintype.prod_apply]\n exact (eq i ⟨⟩).symm.dvd.trans (Finset.dvd_prod_of_mem _ <| Finset.mem_univ _)\n\nvariable [∀ i, IsLocalization (M.map (Pi.evalRingHom R i)) (S i)]\n\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote\nthe projection of `M` onto each corresponding factor. Given a ring homomorphism from the direct\nproduct `Π i, R i` to the product of the localizations of each `R i` at `M' i`, every `y : M`\nmaps to a unit under this homomorphism. -/\nlemma isUnit_piRingHom_algebraMap_comp_piEvalRingHom (y : M) :\n IsUnit ((RingHom.pi fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i)) y) :=\n Pi.isUnit_iff.mpr fun i ↦ map_units _ (⟨y.1 i, y, y.2, rfl⟩ : M.map (Pi.evalRingHom R i))\n\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote\nthe projection of `M` onto each factor. Then the canonical map from the localization of the direct\nproduct `Π i, R i` at `M` to the direct product of the localizations of each `R i` at `M' i`\nis bijective. -/\ntheorem bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom [IsLocalization M S'] [Finite ι] :\n Function.Bijective (lift (S := S') (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) :=\n have := (iff_map_piEvalRingHom R (Π i, S i) M).mpr inferInstance\n (ringEquivOfRingEquiv (M := M) (T := M) _ _ (.refl _) <|\n Submonoid.map_equiv_eq_comap_symm _ _).bijective\n\nopen Function Ideal\n\ninclude M in\nvariable {R} in\nlemma surjective_piRingHom_algebraMap_comp_piEvalRingHom\n [∀ i, Ring.KrullDimLE 0 (R i)] [∀ i, IsLocalRing (R i)] :\n Surjective (RingHom.pi (fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i))) := by\n apply Surjective.piMap (fun i ↦ ?_)\n by_cases h₀ : (0 : R i) ∈ (M.map (Pi.evalRingHom R i))\n · have := uniqueOfZeroMem h₀ (S := (S i))\n exact surjective_to_subsingleton (algebraMap (R i) (S i))\n · exact (IsLocalization.atUnits _ _ (by simpa)).surjective\n\nvariable {R} in\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`.\nIf each `R i` has maximal nilradical then the direct product `∏ R i` surjects onto the\nlocalization of `∏ R i` at `M`. -/\n\nTarget:\nlemma algebraMap_pi_surjective_of_isLocalization [∀ i, Ring.KrullDimLE 0 (R i)]\n [∀ i, IsLocalRing (R i)] [IsLocalization M S']\n [Finite ι] : Surjective (algebraMap (Π i, R i) S') :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Localization","family_id":"algebramap_pi_surjective_of_islocalization","file_id":"mathlib/Mathlib/RingTheory/Localization/Pi.lean","sample_id":"23f21a25563f16af680ef8080d884dc90928aa2a7ff70b8b49d561b5eef2bb9e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b7f886df9fb4fe0abcfe75238d8f52ebc93d445ab828aef157afbafb7a7f0b7e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3af3be70409014e98ae5467d92ac5d27ac7a9e99f78a6f0af568e4c4ee2c3ff8","source_sha256":"01d22f0e482b6f1141c70e715d8575d3ad6707cda65b154f72f0567903aa642b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [isPurelyInseparable_iff]\n refine ⟨fun h x ↦ ?_, fun h x ↦ ?_⟩\n · obtain ⟨g, h1, n, h2⟩ := (minpoly.irreducible (h x).1).hasSeparableContraction q\n exact ⟨n, (h _).2 <| h1.of_dvd <| minpoly.dvd F _ <| by\n simpa only [expand_aeval, minpoly.aeval] using congr_arg (aeval x) h2⟩\n have hdeg := (minpoly.natSepDegree_eq_one_iff_pow_mem q).2 (h x)\n have halg : IsIntegral F x := by_contra fun h' ↦ by\n simp only [minpoly.eq_zero h', natSepDegree_zero, zero_ne_one] at hdeg\n refine ⟨halg, fun hsep ↦ ?_⟩\n rwa [hsep.natSepDegree_eq_natDegree, minpoly.natDegree_eq_one_iff] at hdeg","hard_negative":false,"metrics":{"chosen_tokens":152,"rejected_tokens":3,"token_jaccard":0.05,"token_length_ratio":0.019737},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"a15df0f59d45b46fba6cbd5e93584b203a81d7736145fba72bc72f4169c56e2a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.CharP.IntermediateField\npublic import Mathlib.FieldTheory.IsSepClosed\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n\n# Basic results about purely inseparable extensions\n\nThis file contains basic definitions and results about purely inseparable extensions.\n\n## Main definitions\n\n- `IsPurelyInseparable`: typeclass for purely inseparable field extensions: an algebraic extension\n `E / F` is purely inseparable if and only if the minimal polynomial of every element of `E ∖ F`\n is not separable.\n\n## Main results\n\n- `IsPurelyInseparable.surjective_algebraMap_of_isSeparable`,\n `IsPurelyInseparable.bijective_algebraMap_of_isSeparable`,\n `IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable`:\n if `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective\n (hence bijective). In particular, if an intermediate field of `E / F` is both purely inseparable\n and separable, then it is equal to `F`.\n\n- `isPurelyInseparable_iff_pow_mem`: a field extension `E / F` of exponential characteristic `q` is\n purely inseparable if and only if for every element `x` of `E`, there exists a natural number `n`\n such that `x ^ (q ^ n)` is contained in `F`.\n\n- `IsPurelyInseparable.trans`: if `E / F` and `K / E` are both purely inseparable extensions, then\n `K / F` is also purely inseparable.\n\n- `isPurelyInseparable_iff_natSepDegree_eq_one`: `E / F` is purely inseparable if and only if for\n every element `x` of `E`, its minimal polynomial has separable degree one.\n\n- `isPurelyInseparable_iff_minpoly_eq_X_pow_sub_C`: a field extension `E / F` of exponential\n characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal\n polynomial of `x` over `F` is of form `X ^ (q ^ n) - y` for some natural number `n` and some\n element `y` of `F`.\n\n- `isPurelyInseparable_iff_minpoly_eq_X_sub_C_pow`: a field extension `E / F` of exponential\n characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal\n polynomial of `x` over `F` is of form `(X - x) ^ (q ^ n)` for some natural number `n`.\n\n- `isPurelyInseparable_iff_finSepDegree_eq_one`: an extension is purely inseparable\n if and only if it has finite separable degree (`Field.finSepDegree`) one.\n\n- `IsPurelyInseparable.normal`: a purely inseparable extension is normal.\n\n- `separableClosure.isPurelyInseparable`: if `E / F` is algebraic, then `E` is purely inseparable\n over the separable closure of `F` in `E`.\n\n- `separableClosure_le_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` contains\n the separable closure of `F` in `E` if and only if `E` is purely inseparable over it.\n\n- `eq_separableClosure_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` is equal\n to the separable closure of `F` in `E` if and only if it is separable over `F`, and `E`\n is purely inseparable over it.\n\n- `IsPurelyInseparable.injective_comp_algebraMap`: if `E / F` is purely inseparable, then for any\n reduced ring `L`, the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective.\n In particular, a purely inseparable field extension is an epimorphism in the category of fields.\n\n- `IsPurelyInseparable.of_injective_comp_algebraMap`: if `L` is an algebraically closed field\n containing `E`, such that the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is\n injective, then `E / F` is purely inseparable. As a corollary, epimorphisms in the category of\n fields must be purely inseparable extensions.\n\n- `Field.finSepDegree_eq`: if `E / F` is algebraic, then the `Field.finSepDegree F E` is equal to\n `Field.sepDegree F E` as a natural number. This means that the cardinality of `Field.Emb F E`\n and the degree of `(separableClosure F E) / F` are both finite or infinite, and when they are\n finite, they coincide.\n\n- `Field.finSepDegree_mul_finInsepDegree`: the finite separable degree multiply by the finite\n inseparable degree is equal to the (finite) field extension degree.\n\n## Tags\n\nseparable degree, degree, separable closure, purely inseparable\n\n-/\n\n@[expose] public section\n\nopen Module Polynomial IntermediateField Field\n\nnoncomputable section\n\nuniverse u v w\n\nsection General\n\nvariable (F E : Type*) [CommRing F] [Ring E] [Algebra F E]\nvariable (K : Type*) [Ring K] [Algebra F K]\n\n/-- Typeclass for purely inseparable field extensions: an algebraic extension `E / F` is purely\ninseparable if and only if the minimal polynomial of every element of `E ∖ F` is not separable.\n\nWe define this for general (commutative) rings and only assume `F` and `E` are fields\nif this is needed for a proof. -/\nclass IsPurelyInseparable : Prop where\n isIntegral : Algebra.IsIntegral F E\n inseparable' (x : E) : IsSeparable F x → x ∈ (algebraMap F E).range\n\nattribute [instance] IsPurelyInseparable.isIntegral\n\nvariable {E} in\ntheorem IsPurelyInseparable.isIntegral' [IsPurelyInseparable F E] (x : E) : IsIntegral F x :=\n Algebra.IsIntegral.isIntegral _\n\ntheorem IsPurelyInseparable.isAlgebraic [Nontrivial F] [IsPurelyInseparable F E] :\n Algebra.IsAlgebraic F E := inferInstance\n\nvariable {E}\n\ntheorem IsPurelyInseparable.inseparable [IsPurelyInseparable F E] :\n ∀ x : E, IsSeparable F x → x ∈ (algebraMap F E).range :=\n IsPurelyInseparable.inseparable'\n\nvariable {F}\n\ntheorem isPurelyInseparable_iff : IsPurelyInseparable F E ↔ ∀ x : E,\n IsIntegral F x ∧ (IsSeparable F x → x ∈ (algebraMap F E).range) :=\n ⟨fun h x ↦ ⟨h.isIntegral' _ x, h.inseparable' x⟩, fun h ↦ ⟨⟨fun x ↦ (h x).1⟩, fun x ↦ (h x).2⟩⟩\n\nvariable {K}\n\n/-- Transfer `IsPurelyInseparable` across an `AlgEquiv`. -/\ntheorem AlgEquiv.isPurelyInseparable (e : K ≃ₐ[F] E) [IsPurelyInseparable F K] :\n IsPurelyInseparable F E := by\n refine ⟨⟨fun _ ↦ by rw [← isIntegral_algEquiv e.symm]; exact IsPurelyInseparable.isIntegral' F _⟩,\n fun x h ↦ ?_⟩\n rw [IsSeparable, ← minpoly.algEquiv_eq e.symm] at h\n simpa only [RingHom.mem_range, algebraMap_eq_apply] using IsPurelyInseparable.inseparable F _ h\n\ntheorem AlgEquiv.isPurelyInseparable_iff (e : K ≃ₐ[F] E) :\n IsPurelyInseparable F K ↔ IsPurelyInseparable F E :=\n ⟨fun _ ↦ e.isPurelyInseparable, fun _ ↦ e.symm.isPurelyInseparable⟩\n\n/-- If `E / F` is an algebraic extension, `F` is separably closed,\nthen `E / F` is purely inseparable. -/\ninstance Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed\n {F : Type u} {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E]\n [Algebra.IsAlgebraic F E] [IsSepClosed F] : IsPurelyInseparable F E :=\n ⟨inferInstance, fun x h ↦ minpoly.mem_range_of_degree_eq_one F x <|\n IsSepClosed.degree_eq_one_of_irreducible F (minpoly.irreducible\n (Algebra.IsIntegral.isIntegral _)) h⟩\n\nvariable (F E K)\n\n/-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective. -/\ntheorem IsPurelyInseparable.surjective_algebraMap_of_isSeparable\n [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Surjective (algebraMap F E) :=\n fun x ↦ IsPurelyInseparable.inseparable F x (Algebra.IsSeparable.isSeparable F x)\n\n/-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is bijective. -/\ntheorem IsPurelyInseparable.bijective_algebraMap_of_isSeparable\n [Nontrivial E] [IsDomain F] [IsTorsionFree F E]\n [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Bijective (algebraMap F E) :=\n ⟨FaithfulSMul.algebraMap_injective F E, surjective_algebraMap_of_isSeparable F E⟩\n\nvariable {F E} in\n/-- If a subalgebra of `E / F` is both purely inseparable and separable, then it is equal\nto `F`. -/\ntheorem Subalgebra.eq_bot_of_isPurelyInseparable_of_isSeparable (L : Subalgebra F E)\n [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by\n obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩\n exact ⟨y, congr_arg (Subalgebra.val _) hy⟩\n\n/-- If an intermediate field of `E / F` is both purely inseparable and separable, then it is equal\nto `F`. -/\ntheorem IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable\n {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] (L : IntermediateField F E)\n [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by\n obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩\n exact ⟨y, congr_arg (algebraMap L E) hy⟩\n\n/-- If `E / F` is purely inseparable, then the separable closure of `F` in `E` is\nequal to `F`. -/\ntheorem separableClosure.eq_bot_of_isPurelyInseparable\n (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] [IsPurelyInseparable F E] :\n separableClosure F E = ⊥ :=\n bot_unique fun x h ↦ IsPurelyInseparable.inseparable F x (mem_separableClosure_iff.1 h)\n\n/-- If `E / F` is an algebraic extension, then the separable closure of `F` in `E` is\nequal to `F` if and only if `E / F` is purely inseparable. -/\ntheorem separableClosure.eq_bot_iff\n {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] [Algebra.IsAlgebraic F E] :\n separableClosure F E = ⊥ ↔ IsPurelyInseparable F E :=\n ⟨fun h ↦ isPurelyInseparable_iff.2 fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, fun hs ↦ by\n simpa only [h] using! mem_separableClosure_iff.2 hs⟩, fun _ ↦ eq_bot_of_isPurelyInseparable F E⟩\n\ninstance isPurelyInseparable_self : IsPurelyInseparable F F :=\n ⟨inferInstance, fun x _ ↦ ⟨x, rfl⟩⟩\n\nsection\n\nvariable (F : Type u) {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E]\nvariable (q : ℕ) [ExpChar F q] (x : E)\n\n/-- A field extension `E / F` of exponential characteristic `q` is purely inseparable\nif and only if for every element `x` of `E`, there exists a natural number `n` such that\n`x ^ (q ^ n)` is contained in `F`. -/\n@[stacks 09HE]\n\nTarget:\ntheorem isPurelyInseparable_iff_pow_mem :\n IsPurelyInseparable F E ↔ ∀ x : E, ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory/PurelyInseparable","family_id":"ispurelyinseparable_iff_pow_mem","file_id":"mathlib/Mathlib/FieldTheory/PurelyInseparable/Basic.lean","sample_id":"3af3be70409014e98ae5467d92ac5d27ac7a9e99f78a6f0af568e4c4ee2c3ff8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0fc725d5dcd81120698ac855465cd02f9ea230705aced56562338bc198bfb1db","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"1c38db4046fb7189f73f9a805f7d642a011d226d1f82b14a64ce7a85ea5b1439","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf84818bad60b740e5413a27332cd137949ed179c618a42f3b9b61cefa96c51a","source_sha256":"a7fe36236e2ed09f5c9d6f891e25635e8949de49ab4080f1346dbb2cc7d33457","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext\n simp","hard_negative":true,"metrics":{"chosen_tokens":3,"rejected_tokens":5,"token_jaccard":0.142857,"token_length_ratio":1.666667},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"a1a9edcb1bc23ff3ae29a6d5adbd11a15bd3bca6f78416cf60eb359097698bf8","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.Module.End\npublic import Mathlib.GroupTheory.FreeAbelianGroup\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n\nIn this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`.\nWe use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`.\n\n## Main declarations\n\n- `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n- `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X`\n- `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X`\n-/\n\n@[expose] public section\n\nassert_not_exists Cardinal Module.Basis\n\nnoncomputable section\n\nvariable {X : Type*}\n\n/-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/\ndef FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ :=\n FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ)\n\n/-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/\ndef Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X :=\n Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x)\n\n@[simp] lemma FreeAbelianGroup.toFinsupp_of (x : X) : toFinsupp (of x) = .single x 1 := by\n simp [toFinsupp]\n\n@[simp] lemma Finsupp.toFreeAbelianGroup_single (x : X) (n : ℤ) :\n toFreeAbelianGroup (single x n) = n • .of x := by simp [toFreeAbelianGroup]\n\nopen Finsupp FreeAbelianGroup\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) :\n Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) =\n (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) :=\n AddMonoidHom.ext <| toFreeAbelianGroup_single _\n\n@[simp]\n\nTarget:\ntheorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup :\n toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_cf84818bad60","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"268653f51d99c12985348abf572bd249ba353c030410344430e708230b7eaa1e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAbelianGroup","family_id":"freeabeliangroup","file_id":"mathlib/Mathlib/Algebra/FreeAbelianGroup/Finsupp.lean","sample_id":"cf84818bad60b740e5413a27332cd137949ed179c618a42f3b9b61cefa96c51a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c05a1e39daa1a561345cd85a8a9b701f48abf0d4a469b90dbd41e82d57a4413f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"76acc838a559cc1509c93a3083a0c6ecb4fc1ff26a3ac571e674d55392c12302","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"13dfd26511ea3b4847dc39b1b14f55e9065d2f9e9aad0db1b23286301fe51274","source_sha256":"6b90f6a07ea7967a8b0e6217e9cc629276d38fc3d07cfd25540e4e2638f8f231","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · rintro ⟨u, xeq, yeq⟩\n rcases h : u with ⟨a, f⟩\n use a, fun i j => (f i j).val.fst, fun i j => (f i j).val.snd\n constructor\n · rw [← xeq, h]\n rfl\n constructor\n · rw [← yeq, h]\n rfl\n intro i j\n exact (f i j).property\n rintro ⟨a, f₀, f₁, xeq, yeq, h⟩\n exact ⟨⟨a, fun i j => ⟨(f₀ i j, f₁ i j), h i j⟩⟩, xeq.symm, yeq.symm⟩","hard_negative":false,"metrics":{"chosen_tokens":134,"rejected_tokens":139,"token_jaccard":0.904762,"token_length_ratio":1.037313},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"a28c3662d7c81660a46aeb3f9efded6c7803df26b81c0e6c2fb10fce72a42023","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Functor.Multivariate\npublic import Mathlib.Data.PFunctor.Univariate.Basic\n\nNamespace:\nMvPFunctor\n\nLocal context:\n/-\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/-!\n# Multivariate polynomial functors.\n\nMultivariate polynomial functors are used for defining M-types and W-types.\nThey map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and\n`B : A → TypeVec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `α` are positive.\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nopen MvFunctor\n\n/-- multivariate polynomial functors\n-/\n@[pp_with_univ]\nstructure MvPFunctor (n : ℕ) where\n /-- The head type -/\n A : Type u\n /-- The child family of types -/\n B : A → TypeVec.{u} n\n\nnamespace MvPFunctor\n\nopen MvFunctor (LiftP LiftR)\n\nvariable {n m : ℕ} (P : MvPFunctor.{u} n)\n\n/-- Applying `P` to an object of `Type` -/\n@[coe]\ndef Obj (α : TypeVec.{u} n) : Type u :=\n Σ a : P.A, P.B a ⟹ α\n\ninstance : CoeFun (MvPFunctor.{u} n) (fun _ => TypeVec.{u} n → Type u) where\n coe := Obj\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {α β : TypeVec n} (f : α ⟹ β) : P α → P β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩\n\ninstance : Inhabited (MvPFunctor n) :=\n ⟨⟨default, default⟩⟩\n\ninstance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] :\n Inhabited (P α) :=\n ⟨⟨default, fun _ _ => default⟩⟩\n\ninstance : MvFunctor.{u} P.Obj :=\n ⟨@MvPFunctor.map n P⟩\n\ntheorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) :\n @MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ :=\n rfl\n\ntheorem id_map {α : TypeVec n} : ∀ x : P α, TypeVec.id <$$> x = x\n | ⟨_, _⟩ => rfl\n\ntheorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) :\n ∀ x : P α, (g ⊚ f) <$$> x = g <$$> f <$$> x\n | ⟨_, _⟩ => rfl\n\ninstance : LawfulMvFunctor.{u} P.Obj where\n id_map := @id_map _ P\n comp_map := @comp_map _ P\n\n/-- Constant functor where the input object does not affect the output -/\ndef const (n : ℕ) (A : Type u) : MvPFunctor n :=\n { A\n B := fun _ _ => PEmpty }\n\nsection Const\n\nvariable (n) {A : Type u} {α β : TypeVec.{u} n}\n\n/-- Constructor for the constant functor -/\ndef const.mk (x : A) {α} : const n A α :=\n ⟨x, fun _ a => PEmpty.elim a⟩\n\nvariable {n}\n\n/-- Destructor for the constant functor -/\ndef const.get (x : const n A α) : A :=\n x.1\n\n@[simp]\ntheorem const.get_map (f : α ⟹ β) (x : const n A α) : const.get (f <$$> x) = const.get x := by\n cases x\n rfl\n\n@[simp]\ntheorem const.get_mk (x : A) : const.get (const.mk n x : const n A α) = x := rfl\n\n@[simp]\ntheorem const.mk_get (x : const n A α) : const.mk n (const.get x) = x := by\n cases x\n dsimp [const.get, const.mk]\n congr with (_⟨⟩)\n\nend Const\n\n/-- Functor composition on polynomial functors -/\ndef comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m where\n A := Σ a₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1\n B a i := Σ (j : _) (b : P.2 a.1 j), (Q j).2 (a.snd j b) i\n\nvariable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m}\n\n/-- Constructor for functor composition -/\ndef comp.mk (x : P (fun i => Q i α)) : comp P Q α :=\n ⟨⟨x.1, fun _ a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩\n\n/-- Destructor for functor composition -/\ndef comp.get (x : comp P Q α) : P (fun i => Q i α) :=\n ⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩\n\ntheorem comp.get_map (f : α ⟹ β) (x : comp P Q α) :\n comp.get (f <$$> x) = (fun i (x : Q i α) => f <$$> x) <$$> comp.get x := by\n rfl\n\n@[simp]\ntheorem comp.get_mk (x : P (fun i => Q i α)) : comp.get (comp.mk x) = x := by\n rfl\n\n@[simp]\ntheorem comp.mk_get (x : comp P Q α) : comp.mk (comp.get x) = x := by\n rfl\n\n/-\nlifting predicates and relations\n-/\ntheorem liftP_iff {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (x : P α) :\n LiftP p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i j, p (f i j) := by\n constructor\n · rintro ⟨y, hy⟩\n rcases h : y with ⟨a, f⟩\n refine ⟨a, fun i j => (f i j).val, ?_, fun i j => (f i j).property⟩\n rw [← hy, h, map_eq]\n rfl\n rintro ⟨a, f, xeq, pf⟩\n use ⟨a, fun i j => ⟨f i j, pf i j⟩⟩\n rw [xeq]; rfl\n\ntheorem liftP_iff' {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (a : P.A) (f : P.B a ⟹ α) :\n @LiftP.{u} _ P.Obj _ α p ⟨a, f⟩ ↔ ∀ i x, p (f i x) := by\n simp only [liftP_iff]; constructor\n · rintro ⟨_, _, ⟨⟩, _⟩\n assumption\n · intro\n repeat' first | constructor | assumption\n\nTarget:\ntheorem liftR_iff {α : TypeVec n} (r : ∀ ⦃i⦄, α i → α i → Prop) (x y : P α) :\n LiftR @r x y ↔ ∃ a f₀ f₁, x = ⟨a, f₀⟩ ∧ y = ⟨a, f₁⟩ ∧ ∀ i j, r (f₀ i j) (f₁ i j) :=\n\nProof body:\n","rejected":"by\n constructor\n · rintro ⟨u, xeq, yeq⟩\n rcases h : u with ⟨a, f⟩\n use a, fun i j => (f i j).val.fst, fun i j => (f i j).val.snd\n constructor\n · rw [← xeq, h]\n rfl\n constructor\n · rw [← yeq, h]\n rfl\n intro i j\n exact (f i j).property\n rintro ⟨a, f₀, f₁, xeq, yeq, h⟩\n exact ⟨⟨a, fun i j => ⟨(f₀ i j, f₁ i j), h i j⟩⟩, xeq.symm, yeq.symm⟩\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PFunctor","family_id":"liftr_iff","file_id":"mathlib/Mathlib/Data/PFunctor/Multivariate/Basic.lean","sample_id":"13dfd26511ea3b4847dc39b1b14f55e9065d2f9e9aad0db1b23286301fe51274"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c05a1e39daa1a561345cd85a8a9b701f48abf0d4a469b90dbd41e82d57a4413f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2c1be5d7d12837f4e18e29f134290a1fbacba9c0b7f98c74978d24e0f5ba4ece","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"13dfd26511ea3b4847dc39b1b14f55e9065d2f9e9aad0db1b23286301fe51274","source_sha256":"6b90f6a07ea7967a8b0e6217e9cc629276d38fc3d07cfd25540e4e2638f8f231","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · rintro ⟨u, xeq, yeq⟩\n rcases h : u with ⟨a, f⟩\n use a, fun i j => (f i j).val.fst, fun i j => (f i j).val.snd\n constructor\n · rw [← xeq, h]\n rfl\n constructor\n · rw [← yeq, h]\n rfl\n intro i j\n exact (f i j).property\n rintro ⟨a, f₀, f₁, xeq, yeq, h⟩\n exact ⟨⟨a, fun i j => ⟨(f₀ i j, f₁ i j), h i j⟩⟩, xeq.symm, yeq.symm⟩","hard_negative":true,"metrics":{"chosen_tokens":134,"rejected_tokens":5,"token_jaccard":0.075,"token_length_ratio":0.037313},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"a485e854388d97eaecf33ee1d74fdbcff4c81a529522541ae114d312dc06d0a2","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Functor.Multivariate\npublic import Mathlib.Data.PFunctor.Univariate.Basic\n\nNamespace:\nMvPFunctor\n\nLocal context:\n/-\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/-!\n# Multivariate polynomial functors.\n\nMultivariate polynomial functors are used for defining M-types and W-types.\nThey map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and\n`B : A → TypeVec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `α` are positive.\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nopen MvFunctor\n\n/-- multivariate polynomial functors\n-/\n@[pp_with_univ]\nstructure MvPFunctor (n : ℕ) where\n /-- The head type -/\n A : Type u\n /-- The child family of types -/\n B : A → TypeVec.{u} n\n\nnamespace MvPFunctor\n\nopen MvFunctor (LiftP LiftR)\n\nvariable {n m : ℕ} (P : MvPFunctor.{u} n)\n\n/-- Applying `P` to an object of `Type` -/\n@[coe]\ndef Obj (α : TypeVec.{u} n) : Type u :=\n Σ a : P.A, P.B a ⟹ α\n\ninstance : CoeFun (MvPFunctor.{u} n) (fun _ => TypeVec.{u} n → Type u) where\n coe := Obj\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {α β : TypeVec n} (f : α ⟹ β) : P α → P β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩\n\ninstance : Inhabited (MvPFunctor n) :=\n ⟨⟨default, default⟩⟩\n\ninstance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] :\n Inhabited (P α) :=\n ⟨⟨default, fun _ _ => default⟩⟩\n\ninstance : MvFunctor.{u} P.Obj :=\n ⟨@MvPFunctor.map n P⟩\n\ntheorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) :\n @MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ :=\n rfl\n\ntheorem id_map {α : TypeVec n} : ∀ x : P α, TypeVec.id <$$> x = x\n | ⟨_, _⟩ => rfl\n\ntheorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) :\n ∀ x : P α, (g ⊚ f) <$$> x = g <$$> f <$$> x\n | ⟨_, _⟩ => rfl\n\ninstance : LawfulMvFunctor.{u} P.Obj where\n id_map := @id_map _ P\n comp_map := @comp_map _ P\n\n/-- Constant functor where the input object does not affect the output -/\ndef const (n : ℕ) (A : Type u) : MvPFunctor n :=\n { A\n B := fun _ _ => PEmpty }\n\nsection Const\n\nvariable (n) {A : Type u} {α β : TypeVec.{u} n}\n\n/-- Constructor for the constant functor -/\ndef const.mk (x : A) {α} : const n A α :=\n ⟨x, fun _ a => PEmpty.elim a⟩\n\nvariable {n}\n\n/-- Destructor for the constant functor -/\ndef const.get (x : const n A α) : A :=\n x.1\n\n@[simp]\ntheorem const.get_map (f : α ⟹ β) (x : const n A α) : const.get (f <$$> x) = const.get x := by\n cases x\n rfl\n\n@[simp]\ntheorem const.get_mk (x : A) : const.get (const.mk n x : const n A α) = x := rfl\n\n@[simp]\ntheorem const.mk_get (x : const n A α) : const.mk n (const.get x) = x := by\n cases x\n dsimp [const.get, const.mk]\n congr with (_⟨⟩)\n\nend Const\n\n/-- Functor composition on polynomial functors -/\ndef comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m where\n A := Σ a₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1\n B a i := Σ (j : _) (b : P.2 a.1 j), (Q j).2 (a.snd j b) i\n\nvariable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m}\n\n/-- Constructor for functor composition -/\ndef comp.mk (x : P (fun i => Q i α)) : comp P Q α :=\n ⟨⟨x.1, fun _ a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩\n\n/-- Destructor for functor composition -/\ndef comp.get (x : comp P Q α) : P (fun i => Q i α) :=\n ⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩\n\ntheorem comp.get_map (f : α ⟹ β) (x : comp P Q α) :\n comp.get (f <$$> x) = (fun i (x : Q i α) => f <$$> x) <$$> comp.get x := by\n rfl\n\n@[simp]\ntheorem comp.get_mk (x : P (fun i => Q i α)) : comp.get (comp.mk x) = x := by\n rfl\n\n@[simp]\ntheorem comp.mk_get (x : comp P Q α) : comp.mk (comp.get x) = x := by\n rfl\n\n/-\nlifting predicates and relations\n-/\ntheorem liftP_iff {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (x : P α) :\n LiftP p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i j, p (f i j) := by\n constructor\n · rintro ⟨y, hy⟩\n rcases h : y with ⟨a, f⟩\n refine ⟨a, fun i j => (f i j).val, ?_, fun i j => (f i j).property⟩\n rw [← hy, h, map_eq]\n rfl\n rintro ⟨a, f, xeq, pf⟩\n use ⟨a, fun i j => ⟨f i j, pf i j⟩⟩\n rw [xeq]; rfl\n\ntheorem liftP_iff' {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (a : P.A) (f : P.B a ⟹ α) :\n @LiftP.{u} _ P.Obj _ α p ⟨a, f⟩ ↔ ∀ i x, p (f i x) := by\n simp only [liftP_iff]; constructor\n · rintro ⟨_, _, ⟨⟩, _⟩\n assumption\n · intro\n repeat' first | constructor | assumption\n\nTarget:\ntheorem liftR_iff {α : TypeVec n} (r : ∀ ⦃i⦄, α i → α i → Prop) (x y : P α) :\n LiftR @r x y ↔ ∃ a f₀ f₁, x = ⟨a, f₀⟩ ∧ y = ⟨a, f₁⟩ ∧ ∀ i j, r (f₀ i j) (f₁ i j) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_13dfd26511ea","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"df903a280df76f4a41a78b11bae5ad09c28305581591b606774f0a29e4f734b2","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PFunctor","family_id":"liftr_iff","file_id":"mathlib/Mathlib/Data/PFunctor/Multivariate/Basic.lean","sample_id":"13dfd26511ea3b4847dc39b1b14f55e9065d2f9e9aad0db1b23286301fe51274"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c3f11db7ab5d163f14cbaaa5746cf94a537b03dd2731b398924cb43f5341ea8f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8fba53f509cbcaa7077e1b9aaefbeecf912a8e10535c22fd02c1ba65487eb495","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":true,"metrics":{"chosen_tokens":2,"rejected_tokens":3,"token_jaccard":0.25,"token_length_ratio":1.5},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"a5cd7e3b2a484f6d6c3ec78141962e147a45d7836f95fc74592493294bee20aa","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g := by\n ext a\n exact DFunLike.congr_fun h a\n\n@[norm_cast]\n\nTarget:\ntheorem coe_distribMulActionHom_mk (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) :\n ((⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) : A →ₑ+[φ] B) = ⟨⟨f, h₁⟩, h₂, h₃⟩ :=\n\nProof body:\n","rejected":"by\n exact coe_distribMulActionHom_mk","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"c777484e14230b0c0629941d34beb4ed89c8d1ec8615713b25da094970688cda","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_distribmulactionhom_mk","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"8fba53f509cbcaa7077e1b9aaefbeecf912a8e10535c22fd02c1ba65487eb495"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4fc177b6d5b081353da1b81f66c18abbb24bb5d7456c41e3694dbd485ce5afbb","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f62415822810b2b44b8d599ff65f8714ae872abc95184812b190d9e64e8ee70c","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]","hard_negative":false,"metrics":{"chosen_tokens":20,"rejected_tokens":2,"token_jaccard":0.058824,"token_length_ratio":0.1},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"a670a37f251d6c76ac94368a51341ce2791e229a8d99556c09af5fc1d291e481","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nTarget:\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"restrictscalars_mul","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"f62415822810b2b44b8d599ff65f8714ae872abc95184812b190d9e64e8ee70c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4d9fc79d10e1f6cb1bece30ad581c5e9a4c8ed212136bc32f05d6fe6801040d3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff0d0cdb5305b4521e38ab8e2a66557ca4113d303b26bfc8037a5fa896f22a1c","source_sha256":"79322b0ce86dce1bd44237d38805d8410f0a2666387db3473ce98af0009c270a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using inclusion_exclusion_sum_inf_compl (G := ℤ) s S (f := 1)","hard_negative":false,"metrics":{"chosen_tokens":16,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.125},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"a6fff112d00728a85b74b8d3dd0603a6e5028c32c758f2761690a85916decc98","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Pi\npublic import Mathlib.Algebra.BigOperators.Ring.Finset\npublic import Mathlib.Algebra.Module.BigOperators\n\nNamespace:\nFinset\n\nLocal context:\n/-\nCopyright (c) 2024 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\n/-!\n# Inclusion-exclusion principle\n\nThis file proves several variants of the inclusion-exclusion principle.\n\nThe inclusion-exclusion principle says that the sum/integral of a function over a finite union of\nsets can be calculated as the alternating sum over `n > 0` of the sum/integral of the function over\nthe intersection of `n` of the sets.\n\nBy taking complements, it also says that the sum/integral of a function over a finite intersection\nof complements of sets can be calculated as the alternating sum over `n ≥ 0` of the sum/integral of\nthe function over the intersection of `n` of the sets.\n\nBy taking the function to be constant `1`, we instead get a result about the cardinality/measure of\nthe sets.\n\n## Main declarations\n\nPer the above explanation, this file contains the following variants of inclusion-exclusion:\n* `Finset.inclusion_exclusion_sum_biUnion`: Sum of a function over a finite union of sets\n* `Finset.inclusion_exclusion_card_biUnion`: Cardinality of a finite union of sets\n* `Finset.inclusion_exclusion_sum_inf_compl`: Sum of a function over a finite intersection of\n complements of sets\n* `Finset.inclusion_exclusion_card_inf_compl`: Cardinality of a finite intersection of\n complements of sets\n\nSee also `MeasureTheory.integral_biUnion_eq_sum_powerset` for the version with integrals, and\n`MeasureTheory.measureReal_biUnion_eq_sum_powerset` for the version with measures.\n\n## TODO\n\n* Prove that truncating the series alternatively gives an upper/lower bound to the true value.\n-/\n\npublic section\n\nassert_not_exists Field\n\nnamespace Finset\nvariable {ι α G : Type*} [AddCommGroup G] {s : Finset ι}\n\nlemma prod_indicator_biUnion_sub_indicator (hs : s.Nonempty) (S : ι → Set α) (a : α) :\n ∏ i ∈ s, (Set.indicator (⋃ i ∈ s, S i) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by\n by_cases ha : a ∈ ⋃ i ∈ s, S i\n · have ha' := ha\n simp only [Set.mem_iUnion, exists_prop] at ha\n obtain ⟨i, hi, ha⟩ := ha\n apply prod_eq_zero hi (by simp [ha, ha'])\n · obtain ⟨i, hi⟩ := hs\n have ha : a ∉ S i := by aesop\n exact prod_eq_zero hi <| by simp [*, -coe_biUnion]\n\n/-- **Inclusion-exclusion principle**, indicator version over a finite union of sets. -/\nlemma indicator_biUnion_eq_sum_powerset (s : Finset ι) (S : ι → Set α) (f : α → G) (a : α) :\n Set.indicator (⋃ i ∈ s, S i) f a = ∑ t ∈ s.powerset with t.Nonempty,\n (-1) ^ (#t + 1) • Set.indicator (⋂ i ∈ t, S i) f a := by\n classical\n by_cases ha : a ∈ ⋃ i ∈ s, S i; swap\n · simp only [ha, not_false_eq_true, Set.indicator_of_notMem, Int.reduceNeg, pow_succ, mul_neg,\n mul_one, neg_smul]\n symm\n apply sum_eq_zero\n simp only [Int.reduceNeg, neg_eq_zero, mem_filter, mem_powerset, and_imp]\n intro t hts ht\n rw [Set.indicator_of_notMem]\n · simp\n · contrapose ha\n simp only [Set.mem_iInter] at ha\n rcases ht with ⟨i, hi⟩\n simp only [Set.mem_iUnion, exists_prop]\n exact ⟨i, hts hi, ha _ hi⟩\n rw [← sub_eq_zero]\n calc\n Set.indicator (⋃ i ∈ s, S i) f a - ∑ t ∈ s.powerset with t.Nonempty,\n (-1) ^ (#t + 1) • Set.indicator (⋂ i ∈ t.1, S i) f a\n _ = ∑ t ∈ s.powerset with t.Nonempty, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a +\n ∑ t ∈ s.powerset with ¬ t.Nonempty, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a := by\n simp [sub_eq_neg_add, ← sum_neg_distrib, filter_eq', pow_succ, ha]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t • Set.indicator (⋂ i ∈ t, S i) f a := by\n rw [sum_filter_add_sum_filter_not]\n _ = (∏ i ∈ s, (1 - Set.indicator (S i) 1 a : ℤ)) • f a := by\n simp only [Int.reduceNeg, prod_sub, prod_const_one, mul_one, sum_smul]\n congr! 1 with t\n simp only [prod_const_one, prod_indicator_apply]\n simp [Set.indicator]\n _ = 0 := by\n have : Set.indicator (⋃ i ∈ s, S i) 1 a = (1 : ℤ) := Set.indicator_of_mem ha 1\n rw [← this, prod_indicator_biUnion_sub_indicator, zero_smul]\n simp only [Set.mem_iUnion, exists_prop] at ha\n rcases ha with ⟨i, hi, -⟩\n exact ⟨i, hi⟩\n\nvariable [DecidableEq α]\n\nlemma prod_indicator_biUnion_finset_sub_indicator (hs : s.Nonempty) (S : ι → Finset α) (a : α) :\n ∏ i ∈ s, (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by\n convert! prod_indicator_biUnion_sub_indicator hs (fun i ↦ S i) a\n simp\n\n/-- **Inclusion-exclusion principle** for the sum of a function over a union.\n\nThe sum of a function `f` over the union of the `S i` over `i ∈ s` is the alternating sum of the\nsums of `f` over the intersections of the `S i`. -/\ntheorem inclusion_exclusion_sum_biUnion (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.biUnion S, f a = ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ (#t.1 + 1) • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a := by\n classical\n rw [← sub_eq_zero]\n calc\n ∑ a ∈ s.biUnion S, f a - ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ (#t.1 + 1) • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a\n = ∑ t : s.powerset.filter (·.Nonempty),\n (-1) ^ #t.1 • ∑ a ∈ t.1.inf' (mem_filter.1 t.2).2 S, f a +\n ∑ t ∈ s.powerset.filter (¬ ·.Nonempty), (-1) ^ #t • ∑ a ∈ s.biUnion S, f a := by\n simp [sub_eq_neg_add, ← sum_neg_distrib, filter_eq', pow_succ]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t •\n if ht : t.Nonempty then ∑ a ∈ t.inf' ht S, f a else ∑ a ∈ s.biUnion S, f a := by\n rw [← sum_attach (filter ..)]; simp [sum_dite]\n _ = ∑ a ∈ s.biUnion S, (∏ i ∈ s, (1 - Set.indicator (S i) 1 a : ℤ)) • f a := by\n simp only [Int.reduceNeg, prod_sub, sum_comm (s := s.biUnion S), sum_smul, mul_assoc]\n congr! with t\n split_ifs with ht\n · obtain ⟨i, hi⟩ := ht\n simp only [prod_const_one, prod_indicator_apply]\n simp only [smul_sum, Set.indicator, Set.mem_iInter, mem_coe, Pi.one_apply, mul_ite, mul_one,\n mul_zero, ite_smul, zero_smul, sum_ite, not_forall, sum_const_zero, add_zero]\n congr\n aesop\n · obtain rfl := not_nonempty_iff_eq_empty.1 ht\n simp\n _ = ∑ a ∈ s.biUnion S, (∏ i ∈ s,\n (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) : ℤ) • f a := by\n congr! with t; rw [Set.indicator_of_mem ‹_›, Pi.one_apply]\n _ = 0 := by\n obtain rfl | hs := s.eq_empty_or_nonempty <;>\n simp [-coe_biUnion, prod_indicator_biUnion_finset_sub_indicator, *]\n\n/-- **Inclusion-exclusion principle** for the cardinality of a union.\n\nThe cardinality of the union of the `S i` over `i ∈ s` is the alternating sum of the cardinalities\nof the intersections of the `S i`. -/\ntheorem inclusion_exclusion_card_biUnion (s : Finset ι) (S : ι → Finset α) :\n #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),\n (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S) := by\n simpa using inclusion_exclusion_sum_biUnion (G := ℤ) s S (f := 1)\n\nvariable [Fintype α]\n\n/-- **Inclusion-exclusion principle** for the sum of a function over an intersection of complements.\n\nThe sum of a function `f` over the intersection of the complements of the `S i` over `i ∈ s` is the\nalternating sum of the sums of `f` over the intersections of the `S i`. -/\ntheorem inclusion_exclusion_sum_inf_compl (s : Finset ι) (S : ι → Finset α) (f : α → G) :\n ∑ a ∈ s.inf fun i ↦ (S i)ᶜ, f a = ∑ t ∈ s.powerset, (-1) ^ #t • ∑ a ∈ t.inf S, f a := by\n classical\n calc\n ∑ a ∈ s.inf fun i ↦ (S i)ᶜ, f a\n = ∑ a, f a - ∑ a ∈ s.biUnion S, f a := by\n rw [← Finset.compl_sup, sup_eq_biUnion, eq_sub_iff_add_eq, sum_compl_add_sum]\n _ = ∑ t ∈ s.powerset.filter (¬ ·.Nonempty), (-1) ^ #t • ∑ a ∈ t.inf S, f a\n + ∑ t ∈ s.powerset.filter (·.Nonempty), (-1) ^ #t • ∑ a ∈ t.inf S, f a := by\n simp [← sum_attach (filter ..), inclusion_exclusion_sum_biUnion, inf'_eq_inf, filter_eq',\n sub_eq_add_neg, pow_succ]\n _ = ∑ t ∈ s.powerset, (-1) ^ #t • ∑ a ∈ t.inf S, f a := sum_filter_not_add_sum_filter ..\n\n/-- **Inclusion-exclusion principle** for the cardinality of an intersection of complements.\n\nThe cardinality of the intersection of the complements of the `S i` over `i ∈ s` is the\nalternating sum of the cardinalities of the intersections of the `S i`. -/\n\nTarget:\ntheorem inclusion_exclusion_card_inf_compl (s : Finset ι) (S : ι → Finset α) :\n #(s.inf fun i ↦ (S i)ᶜ) = ∑ t ∈ s.powerset, (-1 : ℤ) ^ #t * #(t.inf S) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Enumerative","family_id":"inclusion_exclusion_card_inf_compl","file_id":"mathlib/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean","sample_id":"ff0d0cdb5305b4521e38ab8e2a66557ca4113d303b26bfc8037a5fa896f22a1c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2de83d28727f5c6b623d7b558d43a3730b0b8baa0c147649925b0fc0c6b6ee06","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2d0a39395c9041b4207ccd98cb82e134f84668e6b2b32d3795eb91a204033ee8","source_sha256":"ae5712c01e19ee9e698953ecf3438b05b54b2b04dda2e774200341d53bf92b5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n classical\n change _ = ite _ _ _\n rw [if_neg, preimage_image_eq, if_pos hs]\n · exact Option.some_injective _\n · rintro ⟨x, _, ⟨⟩⟩","hard_negative":false,"metrics":{"chosen_tokens":34,"rejected_tokens":2,"token_jaccard":0.041667,"token_length_ratio":0.058824},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"a725480fcea7e57e49c86087c85d5603550d65f6f7540c987ff5fde65363947f","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice\npublic import Mathlib.Order.ConditionallyCompleteLattice.Defs\npublic import Mathlib.Order.ConditionallyCompletePartialOrder.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-!\n# Theory of conditionally complete lattices\n\nA conditionally complete lattice is a lattice in which every non-empty bounded subset `s`\nhas a least upper bound and a greatest lower bound, denoted below by `sSup s` and `sInf s`.\nTypical examples are `ℝ`, `ℕ`, and `ℤ` with their usual orders.\n\nThe theory is very comparable to the theory of complete lattices, except that suitable\nboundedness and nonemptiness assumptions have to be added to most statements.\nWe express these using the `BddAbove` and `BddBelow` predicates, which we use to prove\nmost useful properties of `sSup` and `sInf` in conditionally complete lattices.\n\nTo differentiate the statements between complete lattices and conditionally complete\nlattices, we prefix `sInf` and `sSup` in the statements by `c`, giving `csInf` and `csSup`.\nFor instance, `sInf_le` is a statement in complete lattices ensuring `sInf s ≤ x`,\nwhile `csInf_le` is the same statement in conditionally complete lattices\nwith an additional assumption that `s` is bounded below.\n-/\n\n@[expose] public section\n\n-- Guard against import creep\nassert_not_exists Multiset\n\nopen Function OrderDual Set\n\nvariable {α β γ : Type*} {ι : Sort*}\n\nsection LE\n\n/-!\nExtension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α`\n-/\n\nvariable [LE α]\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instSupSet [SupSet α] :\n SupSet (WithTop α) :=\n ⟨fun S =>\n if ⊤ ∈ S then ⊤ else if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then\n ↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=\n ⟨fun S => if S ⊆ {⊤} ∨ ¬BddBelow S then ⊤ else ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩\n\n@[to_dual]\ntheorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)\n (hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=\n (if_neg hs).trans <| if_pos hs'\n\n@[to_dual]\ntheorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) :\n sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=\n if_neg <| by simp [hs, h's]\n\n@[simp]\ntheorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=\n if_pos <| by simp\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_singleton_top [InfSet α] : sInf ({⊤} : Set (WithTop α)) = ⊤ :=\n if_pos <| .inl subset_rfl\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sSup_of_top_mem [SupSet α] {s : Set (WithTop α)} (h : ⊤ ∈ s) : sSup s = ⊤ :=\n if_pos h\n\n@[to_dual]\ntheorem WithTop.sSup_singleton_top [SupSet α] : sSup ({⊤} : Set (WithTop α)) = ⊤ := by\n simp\n\n@[to_dual]\ntheorem WithTop.sSup_of_not_bddAbove [SupSet α] {s : Set (WithTop α)}\n (h : ¬BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ⊤ := by\n by_cases hmem : ⊤ ∈ s\n · exact sSup_of_top_mem hmem\n · exact if_neg hmem |>.trans <| if_neg h\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_of_not_bddBelow [InfSet α] {s : Set (WithTop α)} (h : ¬BddBelow s) :\n sInf s = ⊤ :=\n if_pos <| .inr h\n\n@[to_dual (attr := norm_cast)]\n\nTarget:\ntheorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) :\n ↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithTop α) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/ConditionallyCompleteLattice","family_id":"withtop","file_id":"mathlib/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean","sample_id":"2d0a39395c9041b4207ccd98cb82e134f84668e6b2b32d3795eb91a204033ee8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6238dae871a296f5e13851c3d38a0c20f6f9539aba325619937fae86bc5871f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c5241ce1ccecef4ec1d4fbcd8263de7296bd4d2fc3a2b3d99fc3d7aa5ffb510c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0a56db36734f14b85df87590a36534279f8f1cd9baf6e3f7a3ccb5678f4cff8a","source_sha256":"e0cf750bab33871fed957f97175dd226e5ce595b457c9b4990b817b841e6f95b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have Y_sq : mk W' Y ^ 2 = mk W' (C (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆) -\n C (C W'.a₁ * X + C W'.a₃) * Y) := AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [polynomial]; ring1⟩\n simp only [smul, add_mul, mul_assoc, ← sq, Y_sq, map_sub, map_mul]\n ring1\n\nvariable (W') in\n/-- The ring homomorphism `R[W] →+* S[W.map f]` induced by a ring homomorphism `f : R →+* S`. -/\nnoncomputable def map (f : R →+* S) : W'.CoordinateRing →+* (W'.map f).CoordinateRing :=\n AdjoinRoot.lift ((AdjoinRoot.of _).comp <| mapRingHom f) (AdjoinRoot.root (W'.map f).polynomial)\n (by rw [← eval₂_map, ← map_polynomial, AdjoinRoot.eval₂_root])","hard_negative":false,"metrics":{"chosen_tokens":220,"rejected_tokens":227,"token_jaccard":0.987179,"token_length_ratio":1.031818},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"a7845ff803bc0377df79884083feff006ffe45c5163ce268eb0915597feadd4f","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula\npublic import Mathlib.LinearAlgebra.FreeModule.Norm\npublic import Mathlib.RingTheory.ClassGroup.Basic\npublic import Mathlib.RingTheory.Polynomial.UniqueFactorization\n\nNamespace:\nWeierstrassCurve.Affine.CoordinateRing\n\nLocal context:\n/-\nCopyright (c) 2025 David Kurniadi Angdinata. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Kurniadi Angdinata\n-/\n/-!\n# Nonsingular points and the group law in affine coordinates\n\nLet `W` be a Weierstrass curve over a field `F` given by a Weierstrass equation `W(X, Y) = 0` in\naffine coordinates. The type of nonsingular points in affine coordinates is an inductive, consisting\nof the unique point at infinity `𝓞` and nonsingular affine points `(x, y)`. It can be endowed with a\ngroup law, with `𝓞` as the identity nonsingular point, which is uniquely determined by the formulae\nin `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`.\n\nWith this description, there is an addition-preserving injection from the nonsingular points to the\nideal class group of the *affine coordinate ring* `F[W] := F[X, Y] / ⟨W(X, Y)⟩`. This is given by\nmapping `𝓞` to the trivial ideal class and a nonsingular affine point `(x, y)` to the ideal class of\nthe invertible ideal `⟨X - x, Y - y⟩`. Proving that this is well-defined and preserves addition\nreduces to equalities of ideals checked in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_neg_mul`\nand in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_mul_XYIdeal` via explicit ideal computations.\nNow `F[W]` is a free rank two `F[X]`-algebra with basis `{1, Y}`, so every element of `F[W]` is of\nthe form `p + qY` for some `p, q` in `F[X]`, and there is an algebra norm `N : F[W] → F[X]`.\nInjectivity can then be shown by computing the degree of such a norm `N(p + qY)` in two different\nways, which is done in `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis` and in the\nauxiliary lemmas in the proof of `WeierstrassCurve.Affine.Point.instAddCommGroup`.\n\nThis file defines the group law on nonsingular points in affine coordinates.\n\n## Main definitions\n\n* `WeierstrassCurve.Affine.CoordinateRing`: the affine coordinate ring `F[W]`.\n* `WeierstrassCurve.Affine.CoordinateRing.basis`: the power basis of `F[W]` over `F[X]`.\n* `WeierstrassCurve.Affine.Point`: a nonsingular point in affine coordinates.\n* `WeierstrassCurve.Affine.Point.neg`: the negation of a nonsingular point in affine coordinates.\n* `WeierstrassCurve.Affine.Point.add`: the addition of a nonsingular point in affine coordinates.\n\n## Main statements\n\n* `WeierstrassCurve.Affine.CoordinateRing.instIsDomainCoordinateRing`: the affine coordinate ring\n of a Weierstrass curve is an integral domain.\n* `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis`: the degree of the norm of an\n element in the affine coordinate ring in terms of its power basis.\n* `WeierstrassCurve.Affine.Point.instAddCommGroup`: the type of nonsingular points in affine\n coordinates forms an abelian group under addition.\n\n## References\n\n* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]\n* https://drops.dagstuhl.de/storage/00lipics/lipics-vol268-itp2023/LIPIcs.ITP.2023.6/LIPIcs.ITP.2023.6.pdf\n\n## Tags\n\nelliptic curve, affine, point, group law, class group\n-/\n\n@[expose] public section\n\nopen FractionalIdeal (coeIdeal_mul)\n\nopen Ideal hiding map_mul\n\nopen Module Polynomial\n\nopen scoped nonZeroDivisors Polynomial.Bivariate\n\nlocal macro \"C_simp\" : tactic =>\n `(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])\n\nuniverse r s u v w\n\nnamespace WeierstrassCurve\n\nvariable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} {L : Type w} [CommRing R]\n [CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] [Field L] {W' : Affine R}\n {W : Affine F}\n\nnamespace Affine\n\n/-! ## The affine coordinate ring -/\n\nvariable (W') in\n/-- The affine coordinate ring `R[W] := R[X, Y] / ⟨W(X, Y)⟩` of a Weierstrass curve `W`. -/\nabbrev CoordinateRing : Type r :=\n AdjoinRoot W'.polynomial\n\nvariable (W') in\n/-- The function field `R(W) := Frac(R[W])` of a Weierstrass curve `W`. -/\nabbrev FunctionField : Type r :=\n FractionRing W'.CoordinateRing\n\nnamespace CoordinateRing\n\nnoncomputable instance : Algebra R W'.CoordinateRing := inferInstance\n\nnoncomputable instance : Algebra R[X] W'.CoordinateRing := inferInstance\n\ninstance : IsScalarTower R R[X] W'.CoordinateRing := inferInstance\n\ninstance [Subsingleton R] : Subsingleton W'.CoordinateRing :=\n Module.subsingleton R[X] _\n\nvariable (W') in\n/-- The natural ring homomorphism mapping `R[X][Y]` to `R[W]`. -/\nnoncomputable abbrev mk : R[X][Y] →+* W'.CoordinateRing :=\n AdjoinRoot.mk W'.polynomial\n\nopen scoped Classical in\nvariable (W') in\n/-- The power basis `{1, Y}` for `R[W]` over `R[X]`. -/\nprotected noncomputable def basis : Basis (Fin 2) R[X] W'.CoordinateRing :=\n (subsingleton_or_nontrivial R).by_cases (fun _ => default) fun _ =>\n (AdjoinRoot.powerBasis' monic_polynomial).basis.reindex <| finCongr natDegree_polynomial\n\nlemma basis_apply (n : Fin 2) :\n CoordinateRing.basis W' n = (AdjoinRoot.powerBasis' monic_polynomial).gen ^ (n : ℕ) := by\n classical\n nontriviality R\n rw [CoordinateRing.basis, Or.by_cases, dif_neg <| not_subsingleton R, Basis.reindex_apply,\n PowerBasis.basis_eq_pow, finCongr_symm_apply, Fin.val_cast]\n\n@[simp]\nlemma basis_zero : CoordinateRing.basis W' 0 = 1 := by\n simpa only [basis_apply] using! pow_zero _\n\n@[simp]\nlemma basis_one : CoordinateRing.basis W' 1 = mk W' Y := by\n simpa only [basis_apply] using! pow_one _\n\nlemma coe_basis : (CoordinateRing.basis W' : Fin 2 → W'.CoordinateRing) = ![1, mk W' Y] := by\n ext n\n fin_cases n\n exacts [basis_zero, basis_one]\n\nlemma smul (x : R[X]) (y : W'.CoordinateRing) : x • y = mk W' (C x) * y :=\n (algebraMap_smul W'.CoordinateRing x y).symm\n\nlemma smul_basis_eq_zero {p q : R[X]} (hpq : p • (1 : W'.CoordinateRing) + q • mk W' Y = 0) :\n p = 0 ∧ q = 0 := by\n have h := Fintype.linearIndependent_iff.mp (CoordinateRing.basis W').linearIndependent ![p, q]\n rw [Fin.sum_univ_succ, basis_zero, Fin.sum_univ_one, Fin.succ_zero_eq_one, basis_one] at h\n exact ⟨h hpq 0, h hpq 1⟩\n\nlemma exists_smul_basis_eq (x : W'.CoordinateRing) :\n ∃ p q : R[X], p • (1 : W'.CoordinateRing) + q • mk W' Y = x := by\n have h := (CoordinateRing.basis W').sum_equivFun x\n rw [Fin.sum_univ_succ, Fin.sum_univ_one, basis_zero, Fin.succ_zero_eq_one, basis_one] at h\n exact ⟨_, _, h⟩\n\nlemma smul_basis_mul_C (y : R[X]) (p q : R[X]) :\n (p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' (C y) =\n (p * y) • (1 : W'.CoordinateRing) + (q * y) • mk W' Y := by\n simp only [smul, map_mul]\n ring1\n\nTarget:\nlemma smul_basis_mul_Y (p q : R[X]) : (p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' Y =\n (q * (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆)) • (1 : W'.CoordinateRing) +\n (p - q * (C W'.a₁ * X + C W'.a₃)) • mk W' Y :=\n\nProof body:\n","rejected":"```lean\nby\n have Y_sq : mk W' Y ^ 2 = mk W' (C (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆) -\n C (C W'.a₁ * X + C W'.a₃) * Y) := AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [polynomial]; ring1⟩\n simp only [smul, add_mul, mul_assoc, ← sq, Y_sq, map_sub, map_mul]\n ring1\n\nvariable (W') in\n/-- The ring homomorphism `R[W] →+* S[W.map f]` induced by a ring homomorphism `f : R →+* S`. -/\nnoncomputable def map (f : R →+* S) : W'.CoordinateRing →+* (W'.map f).CoordinateRing :=\n AdjoinRoot.lift ((AdjoinRoot.of _).comp <| mapRingHom f) (AdjoinRoot.root (W'.map f).polynomial)\n (by rw [← eval₂_map, ← map_polynomial, AdjoinRoot.eval₂_root])\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/EllipticCurve","family_id":"smul_basis_mul_y","file_id":"mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean","sample_id":"0a56db36734f14b85df87590a36534279f8f1cd9baf6e3f7a3ccb5678f4cff8a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"319f6ac955e575559439fedf3cac20ae9eb65063681438ffd25e13bb38098f66","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d70f34487328e99a30a560f02631189afa1a646502885e66404981b091603afd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"740e5b4e77128b04b71b3b4978c0507a9c180b9a1765f1d450102f9709a92c61","source_sha256":"d3537788b47974177b54c7d51489ff341785d6598c87247ef75965ad61b95597","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨(V : SetRel X X), hV, hVsymm, hVU⟩ := symm_of_uniformity U_uni\n have uni_ite := dynEntourage_mem_uniformity h hV n\n let openCover x := ball x (dynEntourage T V n)\n obtain ⟨s, _, s_cover⟩ := F_comp.elim_nhds_subcover openCover fun x _ ↦ ball_mem_nhds x uni_ite\n exact ⟨s, .of_entourage_subset hVU <| .of_subset_iUnion_ball s_cover⟩","hard_negative":true,"metrics":{"chosen_tokens":72,"rejected_tokens":3,"token_jaccard":0.046512,"token_length_ratio":0.041667},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"a99797f8ba995b2a1b40608fe7517344e182408d73e0eb372cb9518f3099d6c0","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Asymptotics.ExpGrowth\npublic import Mathlib.Data.ENat.Lattice\npublic import Mathlib.Dynamics.TopologicalEntropy.DynamicalEntourage\n\nNamespace:\nDynamics\n\nLocal context:\n/-\nCopyright (c) 2024 Damien Thomine. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damien Thomine, Pietro Monticone\n-/\n/-!\n# Topological entropy via covers\nWe implement Bowen-Dinaburg's definitions of the topological entropy, via covers.\n\nAll is stated in the vocabulary of uniform spaces. For compact spaces, the uniform structure\nis canonical, so the topological entropy depends only on the topological structure. This will give\na clean proof that the topological entropy is a topological invariant of the dynamics.\n\nA notable choice is that we define the topological entropy of a subset `F` of the whole space.\nUsually, one defines the entropy of an invariant subset `F` as the entropy of the restriction of the\ntransformation to `F`. We avoid the latter definition as it would involve frequent manipulation of\nsubtypes. Our version directly gives a meaning to the topological entropy of a subsystem, and a\nsingle theorem (`subset_restriction_entropy` in `TopologicalEntropy.Semiconj`) will give the\nequivalence between both versions.\n\nAnother choice is to give a meaning to the entropy of `∅` (it must be `-∞` to stay coherent) and to\nkeep the possibility for the entropy to be infinite. Hence, the entropy takes values in the extended\nreals `[-∞, +∞]`. The consequence is that we use `ℕ∞`, `ℝ≥0∞` and `EReal` numbers.\n\n## Main definitions\n- `IsDynCoverOf`: property that dynamical balls centered on a subset `s` cover a subset `F`.\n- `coverMincard`: minimal cardinality of a dynamical cover. Takes values in `ℕ∞`.\n- `coverEntropyInfEntourage`/`coverEntropyEntourage`: exponential growth of `coverMincard`.\n The former is defined with a `liminf`, the later with a `limsup`. Take values in `EReal`.\n- `coverEntropyInf`/`coverEntropy`: supremum of `coverEntropyInfEntourage`/`coverEntropyEntourage`\n over all entourages (or limit as the entourages go to the diagonal). These are Bowen-Dinaburg's\n versions of the topological entropy with covers. Take values in `EReal`.\n\n## Implementation notes\nThere are two competing definitions of topological entropy in this file: one uses a `liminf`,\nthe other a `limsup`. These two topological entropies are equal as soon as they are applied to an\ninvariant subset by theorem `coverEntropyInf_eq_coverEntropy`. We choose the default definition\nto be the definition using a `limsup`, and give it the simpler name `coverEntropy` (instead of\n`coverEntropySup`). Theorems about the topological entropy of invariant subsets will be stated\nusing only `coverEntropy`.\n\n## Main results\n- `IsDynCoverOf.iterate_le_pow`: given a dynamical cover at time `n`, creates dynamical covers\n at all iterates `n * m` with controlled cardinality.\n- `IsDynCoverOf.coverEntropyEntourage_le_log_card_div`: upper bound on `coverEntropyEntourage`\n given any dynamical cover.\n- `coverEntropyInf_eq_coverEntropy`: equality between the notions of topological entropy defined\n with a `liminf` and a `limsup`.\n\n## Tags\ncover, entropy\n\n## TODO\nGet versions of the topological entropy on (pseudo-e)metric spaces.\n-/\n\n@[expose] public section\n\nopen Set SetRel Uniformity UniformSpace\nopen scoped Finset\n\nnamespace Dynamics\n\nvariable {X : Type*} {T : X → X} {U V : SetRel X X} {n : ℕ} {F s : Set X} {m n : ℕ}\n\n/-! ### Dynamical covers -/\n\n/-- Given a subset `F`, an entourage `U` and an integer `n`, a subset `s` is a `(U, n)`-\ndynamical cover of `F` if any orbit of length `n` in `F` is `U`-shadowed by an orbit of length `n`\nof a point in `s`. -/\ndef IsDynCoverOf (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) (s : Set X) : Prop :=\n IsCover (dynEntourage T U n) F s\n\nlemma IsDynCoverOf.of_le (m_n : m ≤ n) (h : IsDynCoverOf T F U n s) : IsDynCoverOf T F U m s :=\n h.mono_entourage <| by gcongr\n\nlemma IsDynCoverOf.of_entourage_subset (U_V : U ⊆ V) (h : IsDynCoverOf T F U n s) :\n IsDynCoverOf T F V n s := h.mono_entourage <| by gcongr\n\n@[simp] lemma isDynCoverOf_empty : IsDynCoverOf T ∅ U n s := .empty\n\n@[simp] lemma isDynCoverOf_empty_right : IsDynCoverOf T F U n ∅ ↔ F = ∅ := by simp [IsDynCoverOf]\n\nnonrec lemma IsDynCoverOf.nonempty (h : F.Nonempty) (h' : IsDynCoverOf T F U n s) : s.Nonempty :=\n h'.nonempty h\n\nlemma isDynCoverOf_zero (T : X → X) (F : Set X) (U : SetRel X X) (h : s.Nonempty) :\n IsDynCoverOf T F U 0 s := by simp [IsDynCoverOf, h]\n\nlemma isDynCoverOf_univ (T : X → X) (F : Set X) (n : ℕ) (h : s.Nonempty) :\n IsDynCoverOf T F univ n s := by simp [IsDynCoverOf, h]\n\nlemma IsDynCoverOf.nonempty_inter [U.IsSymm] {s : Finset X} (h : IsDynCoverOf T F U n s) :\n ∃ t : Finset X, IsDynCoverOf T F U n t ∧ #t ≤ #s ∧\n ∀ x ∈ t, (ball x (dynEntourage T U n) ∩ F).Nonempty := by\n classical\n use {x ∈ s | (ball x (dynEntourage T U n) ∩ F).Nonempty}\n simp only [Finset.coe_filter, Finset.mem_filter, and_imp, imp_self, implies_true, and_true]\n refine ⟨fun y y_F ↦ ?_, Finset.card_mono (Finset.filter_subset _ s)⟩\n obtain ⟨z, z_s, y_Bz⟩ := h y_F\n exact ⟨z, ⟨z_s, _, (dynEntourage T U n).symm y_Bz, y_F⟩, y_Bz⟩\n\n/-- From a dynamical cover `s` with entourage `U` and time `m`, we construct covers with entourage\n`U ○ U` and any multiple `m * n` of `m` with controlled cardinality. This lemma is the first step\nin a submultiplicative-like property of `coverMincard`, with consequences such as explicit bounds\nfor the topological entropy (`coverEntropyInfEntourage_le_card_div`) and an equality between\ntwo notions of topological entropy (`coverEntropyInf_eq_coverEntropySup_of_inv`). -/\nlemma IsDynCoverOf.iterate_le_pow (F_inv : MapsTo T F F) [U.IsSymm] (n : ℕ) {s : Finset X}\n (h : IsDynCoverOf T F U m s) :\n ∃ t : Finset X, IsDynCoverOf T F (U ○ U) (m * n) t ∧ t.card ≤ s.card ^ n := by\n classical\n -- Deal with the edge cases: `F = ∅` or `m = 0`.\n rcases F.eq_empty_or_nonempty with rfl | F_nemp\n · exact ⟨∅, by simp⟩\n have _ : Nonempty X := F_nemp.nonempty\n have s_nemp := h.nonempty F_nemp\n obtain ⟨x, x_F⟩ := F_nemp\n rcases m.eq_zero_or_pos with rfl | m_pos\n · use {x}\n simp only [zero_mul, Finset.coe_singleton, Finset.card_singleton]\n exact ⟨isDynCoverOf_zero T F (U ○ U) (singleton_nonempty x),\n one_le_pow_of_one_le' (Nat.one_le_of_lt (Finset.Nonempty.card_pos s_nemp)) n⟩\n -- The proof goes as follows. Given an orbit of length `(m * n)` starting from `y`, each of its\n -- iterates `y`, `T^[m] y`, `T^[m]^[2] y` ... is `(dynEntourage T U m)`-close to a point of `s`.\n -- Conversely, given a sequence `t 0`, `t 1`, `t 2` of points in `s`, we choose a point\n -- `z = dyncover t` such that `z`, `T^[m] z`, `T^[m]^[2] z` ... are `(dynEntourage T U m)`-close\n -- to `t 0`, `t 1`, `t 2`... Then `y`, `T^[m] y`, `T^[m]^[2] y` ... are\n -- `(dynEntourage T (U ○ U) m)`-close to `z`, `T^[m] z`, `T^[m]^[2] z`, so that the union of such\n -- `z` provides the desired cover. Since there are at most `s.card ^ n` sequences of\n -- length `n` with values in `s`, we get the upper bound we want on the cardinality.\n -- First step: construct `dyncover`. Given `t 0`, `t 1`, `t 2`, if we cannot find such a point\n -- `dyncover t`, we use the dummy `x`.\n have (t : Fin n → s) : ∃ y : X, (⋂ k : Fin n, T^[m * k] ⁻¹' ball (t k) (dynEntourage T U m)) ⊆\n ball y (dynEntourage T (U ○ U) (m * n)) := by\n rcases (⋂ k : Fin n, T^[m * k] ⁻¹' ball (t k) (dynEntourage T U m)).eq_empty_or_nonempty\n with inter_empt | inter_nemp\n · exact inter_empt ▸ ⟨x, empty_subset _⟩\n · obtain ⟨y, y_int⟩ := inter_nemp\n refine ⟨y, fun z z_int ↦ ?_⟩\n simp only [ball, dynEntourage, Prod.map_iterate, mem_iInter, Set.mem_preimage, Prod.map_apply,\n mem_comp] at y_int z_int ⊢\n intro k k_mn\n replace k_mn := Nat.div_lt_of_lt_mul k_mn\n specialize z_int ⟨(k / m), k_mn⟩ (k % m) (Nat.mod_lt k m_pos)\n specialize y_int ⟨(k / m), k_mn⟩ (k % m) (Nat.mod_lt k m_pos)\n rw [← Function.iterate_add_apply T (k % m) (m * (k / m)), Nat.mod_add_div k m] at y_int z_int\n exact mem_comp_of_mem_ball y_int z_int\n choose! dyncover h_dyncover using this\n -- The cover we want is the set of all `dyncover t`, that is, `range dyncover`. We need to check\n -- that it is indeed a `(U ○ U, m * n)` cover, and that its cardinality is at most `card s ^ n`.\n -- Only the first point requires significant work.\n let sn := range dyncover\n refine ⟨sn.toFinset, ?_, ?_⟩\n · -- We implement the argument at the beginning: given `y ∈ F`, we extract `t 0`, `t 1`, `t 2`\n -- such that `y`, `T^[m] y`, `T^[m]^[2] y` ... is `(dynEntourage T U m)`-close to `t 0`, `t 1`,\n -- `t 2`... Then `dyncover t` is a point of `range dyncover` which satisfies the conclusion\n -- of the lemma.\n rw [Finset.coe_nonempty] at s_nemp\n have _ : Nonempty s := Finset.Nonempty.coe_sort s_nemp\n intro y y_F\n have key : ∀ k : Fin n, ∃ z : s, y ∈ T^[m * k] ⁻¹' ball z (dynEntourage T U m) := by\n intro k\n have := h (MapsTo.iterate F_inv (m * k) y_F)\n simp only [Finset.mem_coe] at this\n obtain ⟨z, z_s, hz⟩ := this\n exact ⟨⟨z, z_s⟩, (dynEntourage T U m).symm hz⟩\n choose! t ht using key\n simp only [toFinset_range, Finset.coe_image, Finset.coe_univ, image_univ, mem_range,\n exists_exists_eq_and, sn]\n refine ⟨t, (dynEntourage T (U ○ U) (m * n)).symm <| h_dyncover t <| by simpa using ht⟩\n · rw [toFinset_card]\n apply (Fintype.card_range_le dyncover).trans\n simp only [Fintype.card_fun, Fintype.card_coe, Fintype.card_fin, le_refl]\n\nTarget:\nlemma exists_isDynCoverOf_of_isCompact_uniformContinuous [UniformSpace X]\n (F_comp : IsCompact F) (h : UniformContinuous T) (U_uni : U ∈ 𝓤 X) (n : ℕ) :\n ∃ s : Finset X, IsDynCoverOf T F U n s :=\n\nProof body:\n","rejected":"by\n exact exists_isDynCoverOf_of_isCompact_uniformContinuous","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"8dbce51eeed4c078bbdeac0bf6c72cd4bd9088fca8560bfbb766869d5622f987","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/TopologicalEntropy","family_id":"exists_isdyncoverof_of_iscompact_uniformcontinuous","file_id":"mathlib/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean","sample_id":"740e5b4e77128b04b71b3b4978c0507a9c180b9a1765f1d450102f9709a92c61"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d6e86cd306d302771012f2d820e6a59c3e3d9e4c68bbf815be43378ad63c9dec","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a5c557a1aa527c9ebddee0a77b8435068cdd533ccd5e5ab2e14b5a9cdccd62ec","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"88cff46317ce0e593fb1f210fa9b5188025d5fb51a9c19fd788c1b29b98f4e35","source_sha256":"18568baeeffeaaa701b9fde364e1ec597e66170a4d12d2f9f2bfbc098c10a0b6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := lt_ratSqrt_add_inv_prec_sq (x := x) h\n have : (x : ℝ) < ↑((x.ratSqrt prec + 1 / prec) ^ 2 : ℚ) := by norm_cast\n have := Real.sqrt_lt_sqrt (by simp) this\n rw [Rat.cast_pow, Real.sqrt_sq] at this\n · push_cast at this\n exact this\n · push_cast\n exact add_nonneg (by simpa using ratSqrt_nonneg _ _) (by simp)","hard_negative":false,"metrics":{"chosen_tokens":82,"rejected_tokens":87,"token_jaccard":0.913043,"token_length_ratio":1.060976},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"a9f0c01c207df8aa16a10310d5f8a2b7908750e61a02d31e152120a54de5becd","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Real.Sqrt\npublic import Mathlib.Data.Rat.NatSqrt.Defs\n\nNamespace:\nNat\n\nLocal context:\n/-\nCopyright (c) 2025 Lean FRO, LLC. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\nComparisons between rational approximations to the square root of a natural number\nand the real square root.\n-/\n\npublic section\n\nnamespace Nat\n\ntheorem ratSqrt_le_realSqrt (x : ℕ) {prec : ℕ} (h : 0 < prec) : ratSqrt x prec ≤ √x := by\n have := ratSqrt_sq_le (x := x) h\n have : (x.ratSqrt prec ^ 2 : ℝ) ≤ ↑x := by norm_cast\n have := Real.sqrt_monotone this\n rwa [Real.sqrt_sq] at this\n simpa only [Rat.cast_nonneg] using ratSqrt_nonneg _ _\n\nTarget:\ntheorem realSqrt_lt_ratSqrt_add_inv_prec (x : ℕ) {prec : ℕ} (h : 0 < prec) :\n √x < ratSqrt x prec + 1 / prec :=\n\nProof body:\n","rejected":"by\n have := lt_ratSqrt_add_inv_prec_sq (x := x) h\n have : (x : ℝ) < ↑((x.ratSqrt prec + 1 / prec) ^ 2 : ℚ) := by norm_cast\n have := Real.sqrt_lt_sqrt (by simp) this\n rw [Rat.cast_pow, Real.sqrt_sq] at this\n · push_cast at this\n exact this\n · push_cast\n exact add_nonneg (by simpa using ratSqrt_nonneg _ _) (by simp)\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Rat","family_id":"realsqrt_lt_ratsqrt_add_inv_prec","file_id":"mathlib/Mathlib/Analysis/Rat/NatSqrt/Real.lean","sample_id":"88cff46317ce0e593fb1f210fa9b5188025d5fb51a9c19fd788c1b29b98f4e35"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f38421dbf56e9414828dc26da62046e34f3c258b42e8ce3616b9e9520ca3ef8f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f5900eb320ba46328433db0bfaf3b7af6a3240ffec38a3e2af382f807a90e687","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"780560cffdada05dfb27b3b88a728de7a9c86e00d7d1be5929197237453d4aad","source_sha256":"142a86ea03a643e752f8050977d944e0fb955878f79a76cd95728b7f95d9b51b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [isHausdorff_iff, ← Ideal.map_pow, ← SModEq.restrictScalars R,\n restrictScalars_map_smul_eq]","hard_negative":true,"metrics":{"chosen_tokens":18,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.166667},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"ab201255396c876ac0bb93cb0a3268882838dbb65f9ec3dd12621fd64fe31fcc","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Ring.GeomSum\npublic import Mathlib.LinearAlgebra.SModEq.Basic\npublic import Mathlib.RingTheory.Ideal.Quotient.PowTransition\npublic import Mathlib.RingTheory.Jacobson.Ideal\npublic import Mathlib.Tactic.SuppressCompilation\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Judith Ludwig, Christian Merten, Jiedong Jiang\n-/\n/-!\n# Completion of a module with respect to an ideal.\n\nIn this file we define the notions of Hausdorff, precomplete, and complete for an `R`-module `M`\nwith respect to an ideal `I`:\n\n## Main definitions\n\n- `IsHausdorff I M`: this says that the intersection of `I^n M` is `0`.\n- `IsPrecomplete I M`: this says that every Cauchy sequence converges.\n- `IsAdicComplete I M`: this says that `M` is Hausdorff and precomplete.\n- `Hausdorffification I M`: this is the universal Hausdorff module with a map from `M`.\n- `AdicCompletion I M`: if `I` is finitely generated, then this is the universal complete module\n with a linear map `AdicCompletion.lift` from `M`. This map is injective iff `M` is Hausdorff\n and surjective iff `M` is precomplete.\n- `IsAdicComplete.lift`: if `N` is `I`-adically complete, then a compatible family of\n linear maps `M →ₗ[R] N ⧸ (I ^ n • ⊤)` can be lifted to a unique linear map `M →ₗ[R] N`.\n Together with `mk_lift_apply` and `eq_lift`, it gives the universal property of being\n `I`-adically complete.\n-/\n\n@[expose] public section\n\nsuppress_compilation\n\nopen Submodule Ideal Quotient\n\nvariable {R S T : Type*} [CommRing R] (I : Ideal R)\nvariable (M : Type*) [AddCommGroup M] [Module R M]\nvariable {N : Type*} [AddCommGroup N] [Module R N]\n\n/-- A module `M` is Hausdorff with respect to an ideal `I` if `⋂ I^n M = 0`. -/\nclass IsHausdorff : Prop where\n haus' : ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0\n\n/-- A module `M` is precomplete with respect to an ideal `I` if every Cauchy sequence converges. -/\nclass IsPrecomplete : Prop where\n prec' : ∀ f : ℕ → M, (∀ {m n}, m ≤ n → f m ≡ f n [SMOD (I ^ m • ⊤ : Submodule R M)]) →\n ∃ L : M, ∀ n, f n ≡ L [SMOD (I ^ n • ⊤ : Submodule R M)]\n\n/-- A module `M` is `I`-adically complete if it is Hausdorff and precomplete. -/\n@[mk_iff, stacks 0317 \"see also `IsAdicComplete.of_bijective_iff`\"]\nclass IsAdicComplete : Prop extends IsHausdorff I M, IsPrecomplete I M\n\nvariable {I M}\n\ntheorem IsHausdorff.haus (_ : IsHausdorff I M) :\n ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0 :=\n IsHausdorff.haus'\n\ntheorem isHausdorff_iff :\n IsHausdorff I M ↔ ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0 :=\n ⟨IsHausdorff.haus, fun h => ⟨h⟩⟩\n\ntheorem IsHausdorff.eq_iff_smodEq [IsHausdorff I M] {x y : M} :\n x = y ↔ ∀ n, x ≡ y [SMOD (I ^ n • ⊤ : Submodule R M)] := by\n refine ⟨fun h _ ↦ h ▸ rfl, fun h ↦ ?_⟩\n rw [← sub_eq_zero]\n apply IsHausdorff.haus' (I := I) (x - y)\n simpa [SModEq.sub_mem] using h\n\nTarget:\ntheorem IsHausdorff.map_algebraMap_iff [CommRing S] [Module S M] [Algebra R S]\n [IsScalarTower R S M] : IsHausdorff (I.map (algebraMap R S)) M ↔ IsHausdorff I M :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_780560cffdad","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"9ec5845aa0c7a771fe9fa526413b81e1c70e364ef6bb3f8eda81c6051a8f2289","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/AdicCompletion","family_id":"ishausdorff","file_id":"mathlib/Mathlib/RingTheory/AdicCompletion/Basic.lean","sample_id":"780560cffdada05dfb27b3b88a728de7a9c86e00d7d1be5929197237453d4aad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"021186df91df0216ba94186a36abd33fd1bfc10e88295c5baa9b3160e99602a6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"4d28fa4900da8dd5a7002b8f14f5e326e35d83561d95067973c01b460b9e0341","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"429778af4db70d39feb49b6e7b7edd4a27f7102f9ea8ed95f66c2687b1a4ab12","source_sha256":"ec72b205c7193e28bfc129d0a079e5a35f0db46566eba3abee8190af9187973c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [j, c₄_of_isShortNF_of_char_three]; simp","hard_negative":true,"metrics":{"chosen_tokens":11,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.272727},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"ab888530ca3e6467492bdbd14fff77d529893e9a031c89a76ef7379393dd9f0b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange\npublic import Mathlib.Algebra.CharP.Defs\n\nNamespace:\nWeierstrassCurve\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n\n# Some normal forms of elliptic curves\n\nThis file defines some normal forms of Weierstrass equations of elliptic curves.\n\n## Main definitions and results\n\nThe following normal forms are in [silverman2009], section III.1, page 42.\n\n- `WeierstrassCurve.IsCharNeTwoNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₂X² + a₄X + a₆`. It is the normal form of characteristic ≠ 2.\n\n If 2 is invertible in the ring (for example, if it is a field of characteristic ≠ 2),\n then for any `WeierstrassCurve` there exists a change of variables which will change\n it into such normal form (`WeierstrassCurve.exists_variableChange_isCharNeTwoNF`).\n See also `WeierstrassCurve.toCharNeTwoNF` and `WeierstrassCurve.toCharNeTwoNF_spec`.\n\nThe following normal forms are in [silverman2009], Appendix A, Proposition 1.1.\n\n- `WeierstrassCurve.IsShortNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₄X + a₆`. It is the normal form of characteristic ≠ 2 or 3, and\n also the normal form of characteristic = 3 and j = 0.\n\n If 2 and 3 are invertible in the ring (for example, if it is a field of characteristic ≠ 2 or 3),\n then for any `WeierstrassCurve` there exists a change of variables which will change\n it into such normal form (`WeierstrassCurve.exists_variableChange_isShortNF`).\n See also `WeierstrassCurve.toShortNF` and `WeierstrassCurve.toShortNF_spec`.\n\n If the ring is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ = 0` (for an\n elliptic curve, this is equivalent to j = 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toShortNFOfCharThree`\n and `WeierstrassCurve.toShortNFOfCharThree_spec`).\n\n- `WeierstrassCurve.IsCharThreeJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² = X³ + a₂X² + a₆`. It is the normal form of characteristic = 3 and j ≠ 0.\n\n If the field is of characteristic = 3, then for any `WeierstrassCurve` with `b₂ ≠ 0` (for an\n elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharThreeNF`\n and `WeierstrassCurve.toCharThreeNF_spec_of_b₂_ne_zero`).\n\n- `WeierstrassCurve.IsCharThreeNF` is the combination of the above two, that is, asserts that\n a `WeierstrassCurve` is of form `Y² = X³ + a₂X² + a₆` or `Y² = X³ + a₄X + a₆`.\n It is the normal form of characteristic = 3.\n\n If the field is of characteristic = 3, then for any `WeierstrassCurve` there exists a change of\n variables which will change it into such normal form\n (`WeierstrassCurve.exists_variableChange_isCharThreeNF`).\n See also `WeierstrassCurve.toCharThreeNF` and `WeierstrassCurve.toCharThreeNF_spec`.\n\n- `WeierstrassCurve.IsCharTwoJEqZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2 and j = 0.\n\n If the ring is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ = 0` (for an\n elliptic curve, this is equivalent to j = 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharTwoJEqZeroNF`\n and `WeierstrassCurve.toCharTwoJEqZeroNF_spec`).\n\n- `WeierstrassCurve.IsCharTwoJNeZeroNF` is a type class which asserts that a `WeierstrassCurve` is\n of form `Y² + XY = X³ + a₂X² + a₆`. It is the normal form of characteristic = 2 and j ≠ 0.\n\n If the field is of characteristic = 2, then for any `WeierstrassCurve` with `a₁ ≠ 0` (for an\n elliptic curve, this is equivalent to j ≠ 0), there exists a change of variables which will\n change it into such normal form (see `WeierstrassCurve.toCharTwoJNeZeroNF`\n and `WeierstrassCurve.toCharTwoJNeZeroNF_spec`).\n\n- `WeierstrassCurve.IsCharTwoNF` is the combination of the above two, that is, asserts that\n a `WeierstrassCurve` is of form `Y² + XY = X³ + a₂X² + a₆` or\n `Y² + a₃Y = X³ + a₄X + a₆`. It is the normal form of characteristic = 2.\n\n If the field is of characteristic = 2, then for any `WeierstrassCurve` there exists a change of\n variables which will change it into such normal form\n (`WeierstrassCurve.exists_variableChange_isCharTwoNF`).\n See also `WeierstrassCurve.toCharTwoNF` and `WeierstrassCurve.toCharTwoNF_spec`.\n\n## References\n\n* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]\n\n## Tags\n\nelliptic curve, weierstrass equation, normal form\n\n-/\n\n@[expose] public section\n\nvariable {R : Type*} [CommRing R] {F : Type*} [Field F] (W : WeierstrassCurve R)\n\nnamespace WeierstrassCurve\n\n/-! ## Normal forms of characteristic ≠ 2 -/\n\n/-- A `WeierstrassCurve` is in normal form of characteristic ≠ 2, if its `a₁, a₃ = 0`.\nIn other words it is `Y² = X³ + a₂X² + a₄X + a₆`. -/\n@[mk_iff]\nclass IsCharNeTwoNF : Prop where\n a₁ : W.a₁ = 0\n a₃ : W.a₃ = 0\n\nsection Quantity\n\nvariable [W.IsCharNeTwoNF]\n\n@[simp]\ntheorem a₁_of_isCharNeTwoNF : W.a₁ = 0 := IsCharNeTwoNF.a₁\n\n@[simp]\ntheorem a₃_of_isCharNeTwoNF : W.a₃ = 0 := IsCharNeTwoNF.a₃\n\n@[simp]\ntheorem b₂_of_isCharNeTwoNF : W.b₂ = 4 * W.a₂ := by\n rw [b₂, a₁_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₄_of_isCharNeTwoNF : W.b₄ = 2 * W.a₄ := by\n rw [b₄, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₆_of_isCharNeTwoNF : W.b₆ = 4 * W.a₆ := by\n rw [b₆, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem b₈_of_isCharNeTwoNF : W.b₈ = 4 * W.a₂ * W.a₆ - W.a₄ ^ 2 := by\n rw [b₈, a₁_of_isCharNeTwoNF, a₃_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem c₄_of_isCharNeTwoNF : W.c₄ = 16 * W.a₂ ^ 2 - 48 * W.a₄ := by\n rw [c₄, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem c₆_of_isCharNeTwoNF : W.c₆ = -64 * W.a₂ ^ 3 + 288 * W.a₂ * W.a₄ - 864 * W.a₆ := by\n rw [c₆, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF]\n ring1\n\n@[simp]\ntheorem Δ_of_isCharNeTwoNF : W.Δ = -64 * W.a₂ ^ 3 * W.a₆ + 16 * W.a₂ ^ 2 * W.a₄ ^ 2 - 64 * W.a₄ ^ 3\n - 432 * W.a₆ ^ 2 + 288 * W.a₂ * W.a₄ * W.a₆ := by\n rw [Δ, b₂_of_isCharNeTwoNF, b₄_of_isCharNeTwoNF, b₆_of_isCharNeTwoNF, b₈_of_isCharNeTwoNF]\n ring1\n\nend Quantity\n\nsection VariableChange\n\nvariable [Invertible (2 : R)]\n\n/-- There is an explicit change of variables of a `WeierstrassCurve` to\na normal form of characteristic ≠ 2, provided that 2 is invertible in the ring. -/\n@[simps]\ndef toCharNeTwoNF : VariableChange R := ⟨1, 0, ⅟2 * -W.a₁, ⅟2 * -W.a₃⟩\n\ninstance toCharNeTwoNF_spec : (W.toCharNeTwoNF • W).IsCharNeTwoNF := by\n constructor <;> simp [variableChange_a₁, variableChange_a₃]\n\ntheorem exists_variableChange_isCharNeTwoNF : ∃ C : VariableChange R, (C • W).IsCharNeTwoNF :=\n ⟨_, W.toCharNeTwoNF_spec⟩\n\nend VariableChange\n\n/-! ## Short normal form -/\n\n/-- A `WeierstrassCurve` is in short normal form, if its `a₁, a₂, a₃ = 0`.\nIn other words it is `Y² = X³ + a₄X + a₆`.\n\nThis is the normal form of characteristic ≠ 2 or 3, and\nalso the normal form of characteristic = 3 and j = 0. -/\n@[mk_iff]\nclass IsShortNF : Prop where\n a₁ : W.a₁ = 0\n a₂ : W.a₂ = 0\n a₃ : W.a₃ = 0\n\nsection Quantity\n\nvariable [W.IsShortNF]\n\ninstance isCharNeTwoNF_of_isShortNF : W.IsCharNeTwoNF := ⟨IsShortNF.a₁, IsShortNF.a₃⟩\n\ntheorem a₁_of_isShortNF : W.a₁ = 0 := IsShortNF.a₁\n\n@[simp]\ntheorem a₂_of_isShortNF : W.a₂ = 0 := IsShortNF.a₂\n\ntheorem a₃_of_isShortNF : W.a₃ = 0 := IsShortNF.a₃\n\ntheorem b₂_of_isShortNF : W.b₂ = 0 := by\n simp\n\ntheorem b₄_of_isShortNF : W.b₄ = 2 * W.a₄ := W.b₄_of_isCharNeTwoNF\n\ntheorem b₆_of_isShortNF : W.b₆ = 4 * W.a₆ := W.b₆_of_isCharNeTwoNF\n\ntheorem b₈_of_isShortNF : W.b₈ = -W.a₄ ^ 2 := by\n simp\n\ntheorem c₄_of_isShortNF : W.c₄ = -48 * W.a₄ := by\n simp\n\ntheorem c₆_of_isShortNF : W.c₆ = -864 * W.a₆ := by\n simp\n\ntheorem Δ_of_isShortNF : W.Δ = -16 * (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by\n rw [Δ_of_isCharNeTwoNF, a₂_of_isShortNF]\n ring1\n\nvariable [CharP R 3]\n\ntheorem b₄_of_isShortNF_of_char_three : W.b₄ = -W.a₄ := by\n rw [b₄_of_isShortNF]\n linear_combination W.a₄ * CharP.cast_eq_zero R 3\n\ntheorem b₆_of_isShortNF_of_char_three : W.b₆ = W.a₆ := by\n rw [b₆_of_isShortNF]\n linear_combination W.a₆ * CharP.cast_eq_zero R 3\n\ntheorem c₄_of_isShortNF_of_char_three : W.c₄ = 0 := by\n rw [c₄_of_isShortNF]\n linear_combination -16 * W.a₄ * CharP.cast_eq_zero R 3\n\ntheorem c₆_of_isShortNF_of_char_three : W.c₆ = 0 := by\n rw [c₆_of_isShortNF]\n linear_combination -288 * W.a₆ * CharP.cast_eq_zero R 3\n\ntheorem Δ_of_isShortNF_of_char_three : W.Δ = -W.a₄ ^ 3 := by\n rw [Δ_of_isShortNF]\n linear_combination (-21 * W.a₄ ^ 3 - 144 * W.a₆ ^ 2) * CharP.cast_eq_zero R 3\n\nvariable (W : WeierstrassCurve F) [W.IsElliptic] [W.IsShortNF]\n\ntheorem j_of_isShortNF : W.j = 6912 * W.a₄ ^ 3 / (4 * W.a₄ ^ 3 + 27 * W.a₆ ^ 2) := by\n have h := W.Δ'.ne_zero\n rw [coe_Δ', Δ_of_isShortNF] at h\n rw [j, Units.val_inv_eq_inv_val, ← div_eq_inv_mul, coe_Δ',\n c₄_of_isShortNF, Δ_of_isShortNF, div_eq_div_iff h (right_ne_zero_of_mul h)]\n ring1\n\n@[simp]\n\nTarget:\ntheorem j_of_isShortNF_of_char_three [CharP F 3] : W.j = 0 :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_429778af4db7","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"c4cffd4b32645f1ba918e45be1e4855f7f403c25b8b3afeab72c4ef96bf0d813","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/EllipticCurve","family_id":"j_of_isshortnf_of_char_three","file_id":"mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/NormalForms.lean","sample_id":"429778af4db70d39feb49b6e7b7edd4a27f7102f9ea8ed95f66c2687b1a4ab12"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d6511976df7e33b01f5be5817df063fa6f90f8ea751edc85352d73d9680330a5","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f5726a7b2cb27007273d6cba2c3dd38b66525c1fe46302d591cb944f321877e0","source_sha256":"a61ca7aaba44c7a3be6f604ec88e48f92b91afdcb314b3da2da645358b30973a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one _ _ _ h1 p₀,\n weightedVSubOfPoint_apply, dist_vadd_left]\n simp_rw [dist_eq_norm_vsub] at hp\n exact norm_sum_lt_of_strictConvexSpace h0 h1 hi hj (by simpa using hij) hi0 hj0 hp","hard_negative":false,"metrics":{"chosen_tokens":36,"rejected_tokens":3,"token_jaccard":0.068966,"token_length_ratio":0.083333},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"adc42d7ee5651b1e4e63d68d9dbbe852d1e574241c42ed5d70278c1208a4a1b3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Convex.StrictConvexSpace\npublic import Mathlib.Analysis.Normed.Group.AddTorsor\npublic import Mathlib.LinearAlgebra.AffineSpace.Simplex.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\n/-!\n# Convex combinations in strictly convex sets and spaces.\n\nThis file proves lemmas about convex combinations of points in strictly convex sets and strictly\nconvex spaces.\n\n-/\n\npublic section\n\n\nopen Finset Metric\n\nvariable {R V P ι : Type*}\n\nsection Set\n\nvariable [Field R] [LinearOrder R] [IsStrictOrderedRing R] [TopologicalSpace V] [AddCommGroup V]\nvariable [Module R V]\n\nlemma StrictConvex.centerMass_mem_interior {s : Set V} {t : Finset ι} {w : ι → R} {z : ι → V}\n (hs : StrictConvex R s) :\n (∀ i ∈ t, 0 ≤ w i) → ∀ i j, i ∈ t → j ∈ t → z i ≠ z j → w i ≠ 0 → w j ≠ 0 →\n (∀ i ∈ t, z i ∈ s) → t.centerMass w z ∈ interior s := by\n classical\n induction t using Finset.induction with\n | empty => simp\n | insert i t hi ht =>\n intro h₀ i' j' hi' hj' hi'j' hi'0 hj'0 hmem\n have zi : z i ∈ s := hmem _ (mem_insert_self _ _)\n have hs₀ : ∀ j ∈ t, 0 ≤ w j := fun j hj => h₀ j <| mem_insert_of_mem hj\n by_cases hsum_t : ∑ j ∈ t, w j = 0\n · have ws : ∀ j ∈ t, w j = 0 := (sum_eq_zero_iff_of_nonneg hs₀).1 hsum_t\n have h : i' ∈ t ∨ j' ∈ t := by grind\n exfalso\n rcases h with h | h\n · exact hi'0 (ws _ h)\n · exact hj'0 (ws _ h)\n rw [Finset.centerMass_insert _ _ _ hi hsum_t]\n by_cases hi : w i = 0\n · simp only [hi, zero_add, zero_div, zero_smul, ne_eq, hsum_t, not_false_eq_true, div_self,\n one_smul]\n grind\n by_cases hzi : z i = t.centerMass w z\n · have hwi : w i + ∑ j ∈ t, w j ≠ 0 := by\n refine LT.lt.ne' ?_\n have hwi : 0 < w i := by grind\n grw [hwi]\n simp only [lt_add_iff_pos_right]\n exact (sum_nonneg hs₀).lt_of_ne' hsum_t\n simp only [hzi, ← add_smul, ← add_div, ne_eq, hwi, not_false_eq_true, div_self, one_smul]\n by_cases! hijt : ∃ i'' j'', i'' ∈ t ∧ j'' ∈ t ∧ z i'' ≠ z j'' ∧ w i'' ≠ 0 ∧ w j'' ≠ 0\n · grind\n · exfalso\n obtain ⟨i'', hi'', hwi''⟩ : ∃ i'' ∈ t, w i'' ≠ 0 := by grind\n have hijt' : ∀ j'', j'' ∈ t → w j'' ≠ 0 → z j'' = Function.const _ (z i'') j'' := by\n grind\n have hi : i = i' ∨ i = j' := by grind\n have hzi'' : t.centerMass w z = z i'' := by\n rw [t.centerMass_congr_fun hijt', t.centerMass_const hsum_t]\n grind\n · exact strictConvex_iff_div.1 hs zi\n (hs.convex.centerMass_mem hs₀ (lt_of_le_of_ne (sum_nonneg hs₀) (Ne.symm hsum_t))\n (fun j hj ↦ hmem j (mem_insert_of_mem hj))) hzi (by grind)\n ((sum_nonneg hs₀).lt_of_ne' hsum_t)\n\nlemma StrictConvex.sum_mem_interior {s : Set V} {t : Finset ι} {w : ι → R} {z : ι → V}\n (hs : StrictConvex R s) (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι}\n (hi : i ∈ t) (hj : j ∈ t) (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0)\n (hz : ∀ i ∈ t, z i ∈ s) : ∑ k ∈ t, w k • z k ∈ interior s := by\n rw [← t.centerMass_eq_of_sum_1 _ h1]\n exact hs.centerMass_mem_interior h0 i j hi hj hij hi0 hj0 hz\n\nend Set\n\nsection Space\n\nvariable [NormedAddCommGroup V] [NormedSpace ℝ V] [StrictConvexSpace ℝ V]\n\nlemma centerMass_mem_ball_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p : V} {r : ℝ}\n {z : ι → V} (h0 : ∀ i ∈ t, 0 ≤ w i) {i j : ι} (hi : i ∈ t) (hj : j ∈ t) (hij : z i ≠ z j)\n (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, z i ∈ closedBall p r) :\n t.centerMass w z ∈ ball p r := by\n rcases eq_or_ne r 0 with (rfl | hr)\n · simp_all\n · rw [← interior_closedBall _ hr]\n exact (strictConvex_closedBall _ _ _).centerMass_mem_interior h0 i j hi hj hij hi0 hj0 hz\n\nlemma sum_mem_ball_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p : V} {r : ℝ} {z : ι → V}\n (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t) (hj : j ∈ t)\n (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, z i ∈ closedBall p r) :\n ∑ k ∈ t, w k • z k ∈ ball p r := by\n rw [← t.centerMass_eq_of_sum_1 _ h1]\n exact centerMass_mem_ball_of_strictConvexSpace h0 hi hj hij hi0 hj0 hz\n\nlemma norm_sum_lt_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {r : ℝ} {z : ι → V}\n (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t) (hj : j ∈ t)\n (hij : z i ≠ z j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0) (hz : ∀ i ∈ t, ‖z i‖ ≤ r) :\n ‖∑ k ∈ t, w k • z k‖ < r := by\n simp_rw [← mem_closedBall_zero_iff] at hz\n rw [← mem_ball_zero_iff]\n exact sum_mem_ball_of_strictConvexSpace h0 h1 hi hj hij hi0 hj0 hz\n\nvariable [PseudoMetricSpace P] [NormedAddTorsor V P]\n\nTarget:\nlemma dist_affineCombination_lt_of_strictConvexSpace {t : Finset ι} {w : ι → ℝ} {p₀ : P} {r : ℝ}\n {p : ι → P} (h0 : ∀ i ∈ t, 0 ≤ w i) (h1 : ∑ i ∈ t, w i = 1) {i j : ι} (hi : i ∈ t)\n (hj : j ∈ t) (hij : p i ≠ p j) (hi0 : w i ≠ 0) (hj0 : w j ≠ 0)\n (hp : ∀ i ∈ t, dist (p i) p₀ ≤ r) :\n dist (t.affineCombination ℝ p w) p₀ < r :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/Convex","family_id":"dist_affinecombination_lt_of_strictconvexspace","file_id":"mathlib/Mathlib/Analysis/Convex/StrictCombination.lean","sample_id":"f5726a7b2cb27007273d6cba2c3dd38b66525c1fe46302d591cb944f321877e0"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bc6bccb9b53f0aea87e3ff70b0fee0d7ff91211b7d513c0514c4f25d69141d7e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"996ef0fc43b9d238ad4dc38d81dff235fa426376704148a699ce1af41712651f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"30e2a93d6c5c253b618378c8ebd7416505c8a671a9a2c650a99f668268e190a6","source_sha256":"0cf09afc554d4b34ede5bb7d07487b45c06cc9c6ecd78129ff0a0d2baecc7f10","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨r, m⟩ := x\n simp only [kerIdeal, RingHom.mem_ker, fstHom_apply, fst_mk]\n exact ⟨fun hr => by rw [hr]; rfl, fun hrm => by rw [← fst_mk r m, hrm, fst_inr]⟩","hard_negative":false,"metrics":{"chosen_tokens":51,"rejected_tokens":55,"token_jaccard":0.90625,"token_length_ratio":1.078431},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"addc80791b96516876d4242760351d1697ea33b93cee1bb4671afeae9de69a96","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.TrivSqZeroExt.Basic\npublic import Mathlib.RingTheory.Ideal.Maps\n\nNamespace:\nTrivSqZeroExt\n\nLocal context:\n/-\nCopyright (c) 2026 Antoine Chambert-Loir, María-Inés de Frutos-Fernández. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir, María-Inés de Frutos-Fernández\n-/\n/-!\n# The square zero ideal of the trivial square-zero extension\n\n- `TrivSqZeroExt.kerIdeal`: the ideal in the trivial square-zero extension\n\n- `TrivSqZeroExt.kerIdeal_sq `: this ideal has square zero.\n\n-/\n\n@[expose] public section\n\nnamespace TrivSqZeroExt\n\nopen Ideal\n\nvariable (R M : Type*)\n [CommSemiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] [IsCentralScalar R M]\n\n/-- The kernel of the `AlgHom` `fstHom R R M` -/\ndef kerIdeal : Ideal (TrivSqZeroExt R M) := RingHom.ker (fstHom R R M)\n\nTarget:\ntheorem mem_kerIdeal_iff_inr (x : TrivSqZeroExt R M) : x ∈ kerIdeal R M ↔ x = inr x.snd :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n obtain ⟨r, m⟩ := x\n simp only [kerIdeal, RingHom.mem_ker, fstHom_apply, fst_mk]\n exact ⟨fun hr => by rw [hr]; rfl, fun hrm => by rw [← fst_mk r m, hrm, fst_inr]⟩","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/TrivSqZeroExt","family_id":"mem_kerideal_iff_inr","file_id":"mathlib/Mathlib/Algebra/TrivSqZeroExt/Ideal.lean","sample_id":"30e2a93d6c5c253b618378c8ebd7416505c8a671a9a2c650a99f668268e190a6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fb62ea23cf66eede90bd2faf16ea04aba5b5b2fb23c9881807ebda46794d386b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"4a580bd1b58021f9b33f06b628f83fffb8f7004a732984ef0e0b7e9c52501c4b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4945b92a28e45b949748920df08f33c59e406c2154e81bbbeacdd8276c949faa","source_sha256":"d8a4525fe3eea1f2b42e402bc7c5b3087e18eabd74d9beea30d333f6129613f4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro x y h\n simp only [Subtype.ext_iff, AffineMap.restrict.coe_apply] at h ⊢\n exact hφ h","hard_negative":true,"metrics":{"chosen_tokens":25,"rejected_tokens":5,"token_jaccard":0.136364,"token_length_ratio":0.2},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"afc614067d2cdd67610ff3b266800083bb5a0fb3443fa221d626fcd09fc01ff9","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\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@[expose] public section\n\n\nvariable {k V₁ P₁ V₂ P₂ : Type*} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁]\n [Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂]\n\ninstance AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E]\n {φ : P₁ →ᵃ[k] P₂} : Nonempty (E.map φ) := by\n obtain ⟨x, hx⟩ := id Ene\n exact ⟨⟨φ x, AffineSubspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩\n\n/-- Restrict domain and codomain of an affine map to the given subspaces. -/\ndef AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂}\n [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F := by\n refine ⟨?_, ?_, ?_⟩\n · exact fun x => ⟨φ x, hEF <| AffineSubspace.mem_map.mpr ⟨x, x.property, rfl⟩⟩\n · refine φ.linear.restrict (?_ : E.direction ≤ F.direction.comap φ.linear)\n rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n exact AffineSubspace.direction_le hEF\n · intro p v\n simp only [Subtype.ext_iff, AffineSubspace.coe_vadd]\n apply AffineMap.map_vadd\n\ntheorem AffineMap.restrict.coe_apply (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) (x : E) :\n ↑(φ.restrict hEF x) = φ x :=\n rfl\n\ntheorem AffineMap.restrict.linear_aux {φ : P₁ →ᵃ[k] P₂} {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} (hEF : E.map φ ≤ F) : E.direction ≤ F.direction.comap φ.linear := by\n rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n exact AffineSubspace.direction_le hEF\n\ntheorem AffineMap.restrict.linear (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) :\n (φ.restrict hEF).linear = φ.linear.restrict (AffineMap.restrict.linear_aux hEF) :=\n rfl\n\nTarget:\ntheorem AffineMap.restrict.injective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ)\n {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F]\n (hEF : E.map φ ≤ F) : Function.Injective (AffineMap.restrict φ hEF) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_4945b92a28e4","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"b746cbcdb531d79fbeb3a24c638cb05b1aa084a12f81f3991fe034c747745c5b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/AffineSpace","family_id":"affinemap","file_id":"mathlib/Mathlib/LinearAlgebra/AffineSpace/Restrict.lean","sample_id":"4945b92a28e45b949748920df08f33c59e406c2154e81bbbeacdd8276c949faa"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"01079e9ab62b24ad092f4002968409b301457dea6b33d77faa44a19222419aff","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"97299de3034f3b67ed9d3c56ddd2ae718c51ada021c62810088e39dd915ef7f0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"74ad69d06c197527d7c00c4fd3dff023e710c362b7d895ddcb9f119a35d037be","source_sha256":"bdfd7123efa6932f7f417fb21d899a1972d4f19df96a39961e46ce27a071ef94","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [equivariantProjection, smul_apply, sumOfConjugatesEquivariant_apply,\n Fintype.card_eq_nat_card]","hard_negative":true,"metrics":{"chosen_tokens":14,"rejected_tokens":3,"token_jaccard":0.071429,"token_length_ratio":0.214286},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"b0aa577e6c9676d4e13abcda8b72ad8adcf6d05a4bd978ad4fd581d37063b1fe","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TypeTags.Finite\npublic import Mathlib.Algebra.MonoidAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Basis.VectorSpace\npublic import Mathlib.RingTheory.SimpleModule.Basic\npublic import Mathlib.RepresentationTheory.Semisimple\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# Maschke's theorem\n\nWe prove **Maschke's theorem** for finite groups,\nin the formulation that every submodule of a `k[G]` module has a complement,\nwhen `k` is a field with `Fintype.card G` invertible in `k`.\n\nWe do the core computation in greater generality.\nFor any commutative ring `k` in which `Fintype.card G` is invertible,\nand a `k[G]`-linear map `i : V → W` which admits a `k`-linear retraction `π`,\nwe produce a `k[G]`-linear retraction by\ntaking the average over `G` of the conjugates of `π`.\n\n## Implementation Notes\n\n* These results assume `IsUnit (Fintype.card G : k)` which is equivalent to the more\n familiar `¬(ringChar k ∣ Fintype.card G)`.\n\n## Future work\nIt's not so far to give the usual statement, that every finite-dimensional representation\nof a finite group is semisimple (i.e. a direct sum of irreducibles).\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Module MonoidAlgebra\nopen scoped Ring\n\n/-!\nWe now do the key calculation in Maschke's theorem.\n\nGiven `V → W`, an inclusion of `k[G]` modules,\nassume we have some retraction `π` (i.e. `∀ v, π (i v) = v`),\njust as a `k`-linear map.\n(When `k` is a field, this will be available cheaply, by choosing a basis.)\n\nWe now construct a retraction of the inclusion as a `k[G]`-linear map,\nby the formula\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\n\nnamespace LinearMap\n\n\n-- At first we work with any `[CommRing k]`, and add the assumption that\n-- `IsUnit (Fintype.card G : k)` when it is required.\nvariable {k : Type*} [CommRing k] {G : Type*} [Group G]\nvariable {V : Type*} [AddCommGroup V] [Module k V] [Module k[G] V] [IsScalarTower k k[G] V]\nvariable {W : Type*} [AddCommGroup W] [Module k W] [Module k[G] W] [IsScalarTower k k[G] W]\nvariable (π : W →ₗ[k] V)\n\n/-- We define the conjugate of `π` by `g`, as a `k`-linear map. -/\ndef conjugate (g : G) : W →ₗ[k] V :=\n GroupSMul.linearMap k V g⁻¹ ∘ₗ π ∘ₗ GroupSMul.linearMap k W g\n\ntheorem conjugate_apply (g : G) (v : W) :\n π.conjugate g v = MonoidAlgebra.single g⁻¹ (1 : k) • π (MonoidAlgebra.single g (1 : k) • v) :=\n rfl\n\nvariable (i : V →ₗ[k[G]] W)\n\nsection\n\ntheorem conjugate_i (h : ∀ v : V, π (i v) = v) (g : G) (v : V) :\n (conjugate π g : W → V) (i v) = v := by\n rw [conjugate_apply, ← i.map_smul, h, ← mul_smul, single_mul_single, mul_one, inv_mul_cancel,\n ← one_def, one_smul]\n\nend\n\nvariable (G) [Fintype G]\n\n/-- The sum of the conjugates of `π` by each element `g : G`, as a `k`-linear map.\n\n(We postpone dividing by the size of the group as long as possible.)\n-/\ndef sumOfConjugates : W →ₗ[k] V :=\n ∑ g : G, π.conjugate g\n\nlemma sumOfConjugates_apply (v : W) : π.sumOfConjugates G v = ∑ g : G, π.conjugate g v :=\n LinearMap.sum_apply _ _ _\n\n/-- In fact, the sum over `g : G` of the conjugate of `π` by `g` is a `k[G]`-linear map.\n-/\ndef sumOfConjugatesEquivariant : W →ₗ[k[G]] V :=\n MonoidAlgebra.equivariantOfLinearOfComm (π.sumOfConjugates G) fun g v => by\n simp only [sumOfConjugates_apply, Finset.smul_sum, conjugate_apply]\n refine Fintype.sum_bijective (· * g) (Group.mulRight_bijective g) _ _ fun i ↦ ?_\n simp only [smul_smul, single_mul_single, mul_inv_rev, mul_inv_cancel_left, one_mul]\n\ntheorem sumOfConjugatesEquivariant_apply (v : W) :\n π.sumOfConjugatesEquivariant G v = ∑ g : G, π.conjugate g v :=\n π.sumOfConjugates_apply G v\n\nsection\n\n/-- We construct our `k[G]`-linear retraction of `i` as\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\ndef equivariantProjection : W →ₗ[k[G]] V :=\n (Fintype.card G : k)⁻¹ʳ • π.sumOfConjugatesEquivariant G\n\nTarget:\ntheorem equivariantProjection_apply (v : W) :\n π.equivariantProjection G v = (Nat.card G : k)⁻¹ʳ • ∑ g : G, π.conjugate g v :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_74ad69d06c19","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"30851b97d48d255cbbb6292de437c123e17b12bb847e43fc5afa136a06b2f960","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory","family_id":"equivariantprojection_apply","file_id":"mathlib/Mathlib/RepresentationTheory/Maschke.lean","sample_id":"74ad69d06c197527d7c00c4fd3dff023e710c362b7d895ddcb9f119a35d037be"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e2c3f03502a36f2d3357f89030ca66dd887fbc9daafefb793c746e731117f866","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6ce42c31a56552f229ae0a765abbf2e90e6a434f41c75cd66be66721f93f1685","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6bf1c58c486e033e9ca4b8d0f8d314f8788d09995ff244a4d844d5f6b7a86e07","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Algebra.algebraMap_eq_smul_one]\n exact IsStrictlyPositive.smul hc isStrictlyPositive_one","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":5,"token_jaccard":0.214286,"token_length_ratio":0.384615},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"b2e04ad267a12a9ce7dd2ebc029ec73b071be1b16efc235c06b1346a807e5401","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]\n\n@[aesop safe apply]\ntheorem conjugate_of_isUnit_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) (ha : IsStrictlyPositive a := by cfc_tac) :\n IsStrictlyPositive (b * a * b) :=\n (hb.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint _ _ hb₂).mpr ha\n\nend StarOrderedRing\n\nsection Algebra\n\nvariable {𝕜 : Type*} [Ring A] [PartialOrder A]\n\n@[grind ←, aesop safe apply]\nprotected lemma smul [Semifield 𝕜] [PartialOrder 𝕜] [Algebra 𝕜 A] [PosSMulMono 𝕜 A] {c : 𝕜}\n (hc : 0 < c) {a : A} (ha : IsStrictlyPositive a) :\n IsStrictlyPositive (c • a) := by\n have hunit : IsUnit (c • a) :=\n isUnit_iff_exists.mpr ⟨c⁻¹ • ha.isUnit.unit⁻¹, by simp [(ne_of_lt hc).symm]⟩\n exact hunit.isStrictlyPositive (smul_nonneg hc.le ha.nonneg)\n\n@[grind ←, aesop safe apply]\n\nTarget:\nlemma _root_.isStrictlyPositive_algebraMap [ZeroLEOneClass A] [Semifield 𝕜] [PartialOrder 𝕜]\n [Algebra 𝕜 A] [PosSMulMono 𝕜 A] {c : 𝕜} (hc : 0 < c) :\n IsStrictlyPositive (algebraMap 𝕜 A c) :=\n\nProof body:\n","rejected":"by\n exact _root_.isStrictlyPositive_algebraMap","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a9246cd2a4d1ab1ab59036e2ca76c1e1ff079eaba75e6de044c9d1c85d8373aa","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"6bf1c58c486e033e9ca4b8d0f8d314f8788d09995ff244a4d844d5f6b7a86e07"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"31c8302c65cc713d1319f3775f244828470b3a29f6da40c394ffd32649721f63","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cd1d24fd45244339a0e15ebe8444b5e122cde04a6a58280601681358b3e72052","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b29251e7e93e835cd9694257415f919509e8b460ab58a86d503228ee36d39f16","source_sha256":"11984ab44ec3ab55f5eefa6541171d5214f132d73abb95541a36a4e5c9cd422e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let f₀ : 𝓞 K ≃ₗ[ℤ] 𝓞 L := (f.restrictScalars ℤ).mapIntegralClosure.toLinearEquiv\n rw [← Rat.intCast_inj, coe_discr, Algebra.discr_eq_discr_of_algEquiv (integralBasis K) f,\n ← discr_eq_discr L ((RingOfIntegers.basis K).map f₀)]\n change _ = algebraMap ℤ ℚ _\n rw [← Algebra.discr_localizationLocalization ℤ (nonZeroDivisors ℤ) L]\n congr 1\n ext\n simp only [Function.comp_apply, integralBasis_apply, Basis.localizationLocalization_apply,\n Basis.map_apply]\n rfl","hard_negative":true,"metrics":{"chosen_tokens":100,"rejected_tokens":3,"token_jaccard":0.037736,"token_length_ratio":0.03},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"b3104771067fdffd1fd2ec55eecb40ec75e6523774f52be98180bfa451dfbeeb","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.NumberField.Basic\npublic import Mathlib.RingTheory.Localization.NormTrace\n\nNamespace:\nNumberField\n\nLocal context:\n/-\nCopyright (c) 2023 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Xavier Roblot\n-/\n/-!\n# Number field discriminant\nThis file defines the discriminant of a number field.\n\n## Main definitions\n\n* `NumberField.discr`: the absolute discriminant of a number field.\n\n## Tags\nnumber field, discriminant\n-/\n\npublic section\n\nopen Module\n\n-- TODO: Rewrite some of the FLT results on the discriminant using the definitions and results of\n-- this file\n\nnamespace NumberField\n\nvariable (K : Type*) [Field K] [NumberField K]\n\n/-- The absolute discriminant of a number field. -/\nnoncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K)\n\ntheorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) :=\n (Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm\n\ntheorem discr_ne_zero : discr K ≠ 0 := by\n rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr]\n exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K)\n\ntheorem discr_eq_discr {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι ℤ (𝓞 K)) :\n Algebra.discr ℤ b = discr K := by\n let b₀ := Basis.reindex (RingOfIntegers.basis K) (Basis.indexEquiv (RingOfIntegers.basis K) b)\n rw [Algebra.discr_eq_discr (𝓞 K) b b₀, Basis.coe_reindex, Algebra.discr_reindex]\n\nTarget:\ntheorem discr_eq_discr_of_algEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃ₐ[ℚ] L) :\n discr K = discr L :=\n\nProof body:\n","rejected":"by\n exact discr_eq_discr_of_algEquiv","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"d6cf7191ac1d6d6d717613aef668b16dbf7d9356712242b6b2d4e22d42c6ef46","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/NumberField","family_id":"discr_eq_discr_of_algequiv","file_id":"mathlib/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean","sample_id":"b29251e7e93e835cd9694257415f919509e8b460ab58a86d503228ee36d39f16"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e7ed32928de4181c53cd444ef5a831958803b39ca121aa3f2b67ce53087bd0cd","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6152d5655c585b7c74e75404cfbf6461904dfa7058d1cae29efa7832837a8706","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"eb5f04f544cd1d4a8851f4c94907b459bed35e1b206435064d049d3ba2df1474","source_sha256":"887fd310386a65e61a82345a65129f3ea180e0f162b8057a46e309be54e27cf5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext\n have : Subsingleton (Lp ℝ 2 (0 : Measure E)) := ⟨fun x y ↦ Lp.ext_iff.2 rfl⟩\n simp [uncenteredCovarianceBilinDual, Subsingleton.eq_zero (StrongDual.toLp 0 2)]","hard_negative":false,"metrics":{"chosen_tokens":44,"rejected_tokens":48,"token_jaccard":0.911765,"token_length_ratio":1.090909},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"b35cef0afd2102ae303583a1fc5b6d987b8a9f88461c460177bde0d6f9c0e019","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.LocallyConvex.ContinuousOfBounded\npublic import Mathlib.LinearAlgebra.BilinearForm.Properties\npublic import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap\npublic import Mathlib.Probability.Moments.Variance\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Covariance in Banach spaces\n\nWe define the covariance of a finite measure in a Banach space `E`,\nas a continuous bilinear form on `Dual ℝ E`.\n\n## Main definitions\n\nLet `μ` be a finite measure on a normed space `E` with the Borel σ-algebra. We then define\n\n* `Dual.toLp`: the function `MemLp.toLp` as a continuous linear map from `Dual 𝕜 E` (for `RCLike 𝕜`)\n into the space `Lp 𝕜 p μ` for `p ≥ 1`. This needs a hypothesis `MemLp id p μ` (we set it to the\n junk value 0 if that's not the case).\n* `covarianceBilinDual` : covariance of a measure `μ` with `∫ x, ‖x‖^2 ∂μ < ∞` on a Banach space,\n as a continuous bilinear form `Dual ℝ E →L[ℝ] Dual ℝ E →L[ℝ] ℝ`.\n If the second moment of `μ` is not finite, we set `covarianceBilinDual μ = 0`.\n\n## Main statements\n\n* `covarianceBilinDual_apply` : the covariance of `μ` on `L₁, L₂ : Dual ℝ E` is equal to\n `∫ x, (L₁ x - μ[L₁]) * (L₂ x - μ[L₂]) ∂μ`.\n* `covarianceBilinDual_same_eq_variance`: `covarianceBilinDual μ L L = Var[L; μ]`.\n\n## Implementation notes\n\nThe hypothesis that `μ` has a second moment is written as `MemLp id 2 μ` in the code.\n\n-/\n\n@[expose] public section\n\n\nopen MeasureTheory ProbabilityTheory Complex NormedSpace\nopen scoped ENNReal NNReal Real Topology\n\nvariable {E : Type*} [NormedAddCommGroup E] {mE : MeasurableSpace E} {μ : Measure E} {p : ℝ≥0∞}\n\nnamespace StrongDual\n\nsection LinearMap\n\nvariable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]\n\nopen Classical in\n/-- Linear map from the dual to `Lp` equal to `MemLp.toLp` if `MemLp id p μ` and to 0 otherwise. -/\nnoncomputable\ndef toLpₗ (μ : Measure E) (p : ℝ≥0∞) :\n StrongDual 𝕜 E →ₗ[𝕜] Lp 𝕜 p μ :=\n if h_Lp : MemLp id p μ then\n { toFun := fun L ↦ MemLp.toLp L (h_Lp.continuousLinearMap_comp L)\n map_add' u v := by push_cast; rw [MemLp.toLp_add]\n map_smul' c L := by push_cast; rw [MemLp.toLp_const_smul]; rfl }\n else 0\n\n@[simp]\nlemma toLpₗ_apply (h_Lp : MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLpₗ μ p = MemLp.toLp L (h_Lp.continuousLinearMap_comp L) := by\n simp [toLpₗ, dif_pos h_Lp]\n\n@[simp]\nlemma toLpₗ_of_not_memLp (h_Lp : ¬ MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLpₗ μ p = 0 := by\n simp [toLpₗ, dif_neg h_Lp]\n\nlemma norm_toLpₗ_le [OpensMeasurableSpace E] (L : StrongDual 𝕜 E) :\n ‖L.toLpₗ μ p‖ ≤ ‖L‖ * (eLpNorm id p μ).toReal := by\n by_cases h_Lp : MemLp id p μ\n swap\n · simp only [h_Lp, not_false_eq_true, toLpₗ_of_not_memLp, Lp.norm_zero]\n positivity\n by_cases hp : p = 0\n · simp only [h_Lp, toLpₗ_apply, Lp.norm_toLp]\n simp [hp]\n by_cases hp_top : p = ∞\n · simp only [hp_top, StrongDual.toLpₗ_apply h_Lp, Lp.norm_toLp, eLpNorm_exponent_top] at h_Lp ⊢\n simp only [eLpNormEssSup, id_eq]\n suffices (essSup (fun x ↦ ‖L x‖ₑ) μ).toReal ≤ (essSup (fun x ↦ ‖L‖ₑ * ‖x‖ₑ) μ).toReal by\n rwa [ENNReal.essSup_const_mul, ENNReal.toReal_mul, toReal_enorm] at this\n gcongr\n · rw [ENNReal.essSup_const_mul]\n exact ENNReal.mul_ne_top (by simp) h_Lp.eLpNorm_ne_top\n · exact essSup_mono_ae <| ae_of_all _ L.le_opNorm_enorm\n have h0 : 0 < p.toReal := by simp [ENNReal.toReal_pos_iff, pos_iff_ne_zero, hp, Ne.lt_top hp_top]\n suffices ‖L.toLpₗ μ p‖\n ≤ (‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ).toReal ^ p.toReal⁻¹ by\n refine this.trans_eq ?_\n simp only [ENNReal.toReal_mul]\n rw [← ENNReal.toReal_rpow, Real.mul_rpow (by positivity) (by positivity),\n ← Real.rpow_mul (by positivity), mul_inv_cancel₀ h0.ne', Real.rpow_one, toReal_enorm]\n rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top, ENNReal.toReal_rpow]\n simp\n rw [StrongDual.toLpₗ_apply h_Lp, Lp.norm_toLp,\n eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top]\n simp only [one_div]\n refine ENNReal.toReal_le_of_le_ofReal (by positivity) ?_\n suffices ∫⁻ x, ‖L x‖ₑ ^ p.toReal ∂μ ≤ ‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ by\n rw [← ENNReal.ofReal_rpow_of_nonneg (by positivity) (by positivity)]\n gcongr\n rwa [ENNReal.ofReal_toReal]\n refine ENNReal.mul_ne_top (by simp) ?_\n have h := h_Lp.eLpNorm_ne_top\n rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top] at h\n simpa [h0] using h\n calc ∫⁻ x, ‖L x‖ₑ ^ p.toReal ∂μ\n _ ≤ ∫⁻ x, ‖L‖ₑ ^ p.toReal * ‖x‖ₑ ^ p.toReal ∂μ := by\n refine lintegral_mono fun x ↦ ?_\n rw [← ENNReal.mul_rpow_of_nonneg]\n swap; · positivity\n gcongr\n exact L.le_opNorm_enorm x\n _ = ‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ := by rw [lintegral_const_mul]; fun_prop\n\nend LinearMap\n\nsection ContinuousLinearMap\n\nvariable {𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 E] [OpensMeasurableSpace E]\n\n/-- Continuous linear map from the dual to `Lp` equal to `MemLp.toLp` if `MemLp id p μ`\nand to 0 otherwise. -/\nnoncomputable\ndef toLp (μ : Measure E) (p : ℝ≥0∞) [Fact (1 ≤ p)] :\n StrongDual 𝕜 E →L[𝕜] Lp 𝕜 p μ where\n toLinearMap := StrongDual.toLpₗ μ p\n cont := by\n refine LinearMap.continuous_of_locally_bounded _ fun s hs ↦ ?_\n rw [image_isVonNBounded_iff]\n simp_rw [isVonNBounded_iff'] at hs\n obtain ⟨r, hxr⟩ := hs\n refine ⟨r * (eLpNorm id p μ).toReal, fun L hLs ↦ ?_⟩\n specialize hxr L hLs\n refine (StrongDual.norm_toLpₗ_le L).trans ?_\n gcongr\n\n@[simp]\nlemma toLp_apply [Fact (1 ≤ p)] (h_Lp : MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLp μ p = MemLp.toLp L (h_Lp.continuousLinearMap_comp L) := by\n simp [toLp, h_Lp]\n\n@[simp]\nlemma toLp_of_not_memLp [Fact (1 ≤ p)] (h_Lp : ¬ MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLp μ p = 0 := by\n simp [toLp, h_Lp]\n\nend ContinuousLinearMap\n\nend StrongDual\n\nnamespace ProbabilityTheory\n\nsection Centered\n\nvariable [NormedSpace ℝ E] [OpensMeasurableSpace E]\n\n/-- Continuous bilinear form with value `∫ x, L₁ x * L₂ x ∂μ` on `(L₁, L₂)`.\nThis is equal to the covariance only if `μ` is centered. -/\nnoncomputable\ndef uncenteredCovarianceBilinDual (μ : Measure E) : StrongDual ℝ E →L[ℝ] StrongDual ℝ E →L[ℝ] ℝ :=\n ContinuousLinearMap.bilinearComp (isBoundedBilinearMap_inner (𝕜 := ℝ)).toContinuousLinearMap\n (StrongDual.toLp μ 2) (StrongDual.toLp μ 2)\n\nlemma uncenteredCovarianceBilinDual_apply (h : MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :\n uncenteredCovarianceBilinDual μ L₁ L₂ = ∫ x, L₁ x * L₂ x ∂μ := by\n simp only [uncenteredCovarianceBilinDual, ContinuousLinearMap.bilinearComp_apply,\n StrongDual.toLp_apply h, L2.inner_def, RCLike.inner_apply, conj_trivial]\n refine integral_congr_ae ?_\n filter_upwards [MemLp.coeFn_toLp (h.continuousLinearMap_comp L₁),\n MemLp.coeFn_toLp (h.continuousLinearMap_comp L₂)] with x hxL₁ hxL₂\n simp only [id_eq] at hxL₁ hxL₂\n rw [hxL₁, hxL₂, mul_comm]\n\nlemma uncenteredCovarianceBilinDual_of_not_memLp (h : ¬ MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :\n uncenteredCovarianceBilinDual μ L₁ L₂ = 0 := by\n simp [uncenteredCovarianceBilinDual, StrongDual.toLp_of_not_memLp h]\n\n@[simp]\n\nTarget:\nlemma uncenteredCovarianceBilinDual_zero : uncenteredCovarianceBilinDual (0 : Measure E) = 0 :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n ext\n have : Subsingleton (Lp ℝ 2 (0 : Measure E)) := ⟨fun x y ↦ Lp.ext_iff.2 rfl⟩\n simp [uncenteredCovarianceBilinDual, Subsingleton.eq_zero (StrongDual.toLp 0 2)]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Moments","family_id":"uncenteredcovariancebilindual_zero","file_id":"mathlib/Mathlib/Probability/Moments/CovarianceBilinDual.lean","sample_id":"eb5f04f544cd1d4a8851f4c94907b459bed35e1b206435064d049d3ba2df1474"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c7ec1ced95ea630553477d9eb8c3247deb262c047f2bb2048c55bf4d5e2893c0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"780c4dd1fbf70c3e278cfdc92f5527918565109d24127e13cbbc005c15d0b467","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"37912b3f0151b80119703c8165d6a17ef16224c308db2e6e588ca3f111147549","source_sha256":"43583c3ac7bef530c0b3cbfe6dc114d31d1a19b81ff88819ab7ad0165c02c799","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n classical\n suffices ((Finsupp.lapply i).comp\n (mvPolynomialBasis R σ).repr.toLinearMap).compDer (D _ _) = MvPolynomial.pderiv i by\n rw [← this]; rfl\n apply MvPolynomial.derivation_ext\n simp [Finsupp.single_apply, Pi.single_apply]","hard_negative":true,"metrics":{"chosen_tokens":56,"rejected_tokens":5,"token_jaccard":0.054054,"token_length_ratio":0.089286},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"b3ea2952e87a505f24aacce4db8b481409936b746cba7cd35774f7d59d9c12f5","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.Basic\npublic import Mathlib.Algebra.MvPolynomial.PDeriv\npublic import Mathlib.Algebra.Polynomial.Derivation\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# The Kähler differential module of polynomial algebras\n-/\n\n@[expose] public section\n\nopen Algebra Module\nopen scoped TensorProduct\n\nuniverse u v\n\nvariable (R : Type u) [CommRing R]\n\nsuppress_compilation\n\nsection MvPolynomial\n\n/-- The relative differential module of a polynomial algebra `R[σ]` is the free module generated by\n`{ dx | x ∈ σ }`. Also see `KaehlerDifferential.mvPolynomialBasis`. -/\ndef KaehlerDifferential.mvPolynomialEquiv (σ : Type*) :\n Ω[MvPolynomial σ R⁄R] ≃ₗ[MvPolynomial σ R] σ →₀ MvPolynomial σ R where\n __ := (MvPolynomial.mkDerivation _ (Finsupp.single · 1)).liftKaehlerDifferential\n invFun := Finsupp.linearCombination (α := σ) _ (fun x ↦ D _ _ (MvPolynomial.X x))\n right_inv := by\n intro x\n induction x using Finsupp.induction_linear with\n | zero => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]; rw [map_zero, map_zero]\n | add => simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, map_add] at *; simp only [*]\n | single a b => simp [-map_smul]\n left_inv := by\n intro x\n obtain ⟨x, rfl⟩ := linearCombination_surjective _ _ x\n induction x using Finsupp.induction_linear with\n | zero =>\n simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]\n rw [map_zero, map_zero, map_zero]\n | add => simp only [map_add, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom] at *; simp only [*]\n | single a b =>\n simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Finsupp.linearCombination_single,\n map_smul, Derivation.liftKaehlerDifferential_comp_D]\n congr 1\n induction a using MvPolynomial.induction_on\n · simp only [MvPolynomial.derivation_C, map_zero]\n · simp only [map_add, *]\n · simp [*]\n\n/-- `{ dx | x ∈ σ }` forms a basis of the relative differential module\nof a polynomial algebra `R[σ]`. -/\ndef KaehlerDifferential.mvPolynomialBasis (σ) :\n Basis σ (MvPolynomial σ R) Ω[MvPolynomial σ R⁄R] :=\n ⟨mvPolynomialEquiv R σ⟩\n\nlemma KaehlerDifferential.mvPolynomialBasis_repr_comp_D (σ) :\n (mvPolynomialBasis R σ).repr.toLinearMap.compDer (D _ _) =\n MvPolynomial.mkDerivation _ (Finsupp.single · 1) :=\n Derivation.liftKaehlerDifferential_comp _\n\nlemma KaehlerDifferential.mvPolynomialBasis_repr_D (σ) (x) :\n (mvPolynomialBasis R σ).repr (D _ _ x) =\n MvPolynomial.mkDerivation R (Finsupp.single · (1 : MvPolynomial σ R)) x :=\n Derivation.congr_fun (mvPolynomialBasis_repr_comp_D R σ) x\n\n@[simp]\nlemma KaehlerDifferential.mvPolynomialBasis_repr_D_X (σ) (i) :\n (mvPolynomialBasis R σ).repr (D _ _ (.X i)) = Finsupp.single i 1 := by\n simp [mvPolynomialBasis_repr_D]\n\n@[simp]\n\nTarget:\nlemma KaehlerDifferential.mvPolynomialBasis_repr_apply (σ) (x) (i) :\n (mvPolynomialBasis R σ).repr (D _ _ x) i = MvPolynomial.pderiv i x :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_37912b3f0151","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"327ecec1a86fd6c6027b83d8fccaba22eb9a27fb622ff46bb7e6687401a2cbeb","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Kaehler","family_id":"kaehlerdifferential","file_id":"mathlib/Mathlib/RingTheory/Kaehler/Polynomial.lean","sample_id":"37912b3f0151b80119703c8165d6a17ef16224c308db2e6e588ca3f111147549"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1a219e2219222afc82f6522a0211999bd464c68a577ba9f95c5d96036573d1de","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4e3671a92b7157957d4f92ffebf2f271f222554aaaf55345092e61c95f24ab99","source_sha256":"fd7f00f8de4f342fd9976c499e2c0f694fe1007205cad97c0fd674aa814b979f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : ∀ ω, ((ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω) →\n (ε : ℝ) ≤ stoppedValue f (fun ω ↦ (hittingBtwn f {y : ℝ | ε ≤ y} 0 n ω : ℕ)) ω := by\n intro x hx\n simp_rw [le_sup'_iff, mem_range, Nat.lt_succ_iff] at hx\n refine stoppedValue_hittingBtwn_mem ?_\n simp only [Set.mem_Icc, zero_le, true_and, Set.mem_setOf_eq]\n exact\n let ⟨j, hj₁, hj₂⟩ := hx\n ⟨j, hj₁, hj₂⟩\n have h := setIntegral_ge_of_const_le_real (measurableSet_le measurable_const\n (measurable_range_sup'' fun n _ => (hsub.stronglyMeasurable n).measurable.le (𝒢.le n)))\n (measure_ne_top _ _) this (Integrable.integrableOn (hsub.integrable_stoppedValue\n (hsub.stronglyAdapted.adapted.isStoppingTime_hittingBtwn measurableSet_Ici)\n (mod_cast hittingBtwn_le)))\n rw [ENNReal.le_ofReal_iff_toReal_le, ENNReal.toReal_smul]\n · exact h\n · exact ENNReal.mul_ne_top (by simp) (measure_ne_top _ _)\n · exact le_trans (mul_nonneg ε.coe_nonneg ENNReal.toReal_nonneg) h","hard_negative":false,"metrics":{"chosen_tokens":223,"rejected_tokens":5,"token_jaccard":0.03125,"token_length_ratio":0.022422},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"b4296e22e65e4d33a0aad79bdcb7cf0914bd12b49806d4fbad9ec36b67659635","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Notation\npublic import Mathlib.Probability.Process.HittingTime\npublic import Mathlib.Probability.Martingale.Basic\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2022 Kexing Ying. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kexing Ying\n-/\n/-! # Optional stopping theorem (fair game theorem)\n\nThe optional stopping theorem states that a strongly adapted integrable process `f` is a\nsubmartingale if and only if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`.\n\nThis file also contains Doob's maximal inequality: given a non-negative submartingale `f`, for all\n`ε : ℝ≥0`, we have `ε • μ {ε ≤ f* n} ≤ ∫ ω in {ε ≤ f* n}, f n` where `f * n ω = max_{k ≤ n}, f k ω`.\n\n### Main results\n\n* `MeasureTheory.submartingale_iff_expected_stoppedValue_mono`: the optional stopping theorem.\n* `MeasureTheory.Submartingale.stoppedProcess`: the stopped process of a submartingale with\n respect to a stopping time is a submartingale.\n* `MeasureTheory.maximal_ineq`: Doob's maximal inequality.\n\n-/\n\npublic section\n\n\nopen scoped NNReal ENNReal MeasureTheory ProbabilityTheory\n\nnamespace MeasureTheory\n\nvariable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {𝒢 : Filtration ℕ m0} {f : ℕ → Ω → ℝ}\n {τ π : Ω → ℕ∞}\n\n/-- Given a submartingale `f` and bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nexpectation of `stoppedValue f τ` is less than or equal to the expectation of `stoppedValue f π`.\nThis is the forward direction of the optional stopping theorem. -/\ntheorem Submartingale.expected_stoppedValue_mono {E : Type*} [NormedAddCommGroup E]\n [NormedSpace ℝ E] [CompleteSpace E] [PartialOrder E] [IsOrderedAddMonoid E]\n [IsOrderedModule ℝ E] [ClosedIciTopology E] [SigmaFiniteFiltration μ 𝒢] {f : ℕ → Ω → E}\n (hf : Submartingale f 𝒢 μ) (hτ : IsStoppingTime 𝒢 τ) (hπ : IsStoppingTime 𝒢 π) (hle : τ ≤ π)\n {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) : μ[stoppedValue f τ] ≤ μ[stoppedValue f π] := by\n rw [← sub_nonneg, ← integral_sub', stoppedValue_sub_eq_sum' hle hbdd]\n · simp only [Finset.sum_apply]\n have : ∀ i, MeasurableSet[𝒢 i] {ω : Ω | τ ω ≤ i ∧ i < π ω} := by\n intro i\n refine (hτ i).inter ?_\n convert! (hπ i).compl using 1\n ext x\n simp; rfl\n rw [integral_finsetSum]\n · refine Finset.sum_nonneg fun i _ => ?_\n rw [integral_indicator (𝒢.le _ _ (this _)), integral_sub', sub_nonneg]\n · exact hf.setIntegral_le (Nat.le_succ i) (this _)\n · exact (hf.integrable _).integrableOn\n · exact (hf.integrable _).integrableOn\n intro i _\n exact Integrable.indicator (Integrable.sub (hf.integrable _) (hf.integrable _))\n (𝒢.le _ _ (this _))\n · exact hf.integrable_stoppedValue hπ hbdd\n · exact hf.integrable_stoppedValue hτ fun ω => le_trans (hle ω) (hbdd ω)\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The converse direction of the optional stopping theorem, i.e. a strongly adapted integrable\nprocess `f` is a submartingale if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`. -/\ntheorem submartingale_of_expected_stoppedValue_mono [SigmaFiniteFiltration μ 𝒢]\n (hadp : StronglyAdapted 𝒢 f)\n (hint : ∀ i, Integrable (f i) μ) (hf : ∀ τ π : Ω → ℕ∞, IsStoppingTime 𝒢 τ → IsStoppingTime 𝒢 π →\n τ ≤ π → (∃ N : ℕ, ∀ ω, π ω ≤ N) → μ[stoppedValue f τ] ≤ μ[stoppedValue f π]) :\n Submartingale f 𝒢 μ := by\n refine submartingale_of_setIntegral_le hadp hint fun i j hij s hs => ?_\n classical\n specialize hf (s.piecewise (fun _ => i) fun _ => j) _ (isStoppingTime_piecewise_const hij hs)\n (isStoppingTime_const 𝒢 j) ?_\n ⟨j, fun _ => le_rfl⟩\n · intro ω\n simp only [Set.piecewise, ENat.some_eq_coe]\n split_ifs with hω\n · exact mod_cast hij\n · norm_cast\n · rwa [stoppedValue_const, ← ENat.some_eq_coe, stoppedValue_piecewise_const,\n integral_piecewise (𝒢.le _ _ hs) (hint _).integrableOn (hint _).integrableOn, ←\n integral_add_compl (𝒢.le _ _ hs) (hint j), add_le_add_iff_right] at hf\n\n/-- **The optional stopping theorem** (fair game theorem): a strongly adapted integrable process `f`\nis a submartingale if and only if for all bounded stopping times `τ` and `π` such that `τ ≤ π`, the\nstopped value of `f` at `τ` has expectation smaller than its stopped value at `π`. -/\ntheorem submartingale_iff_expected_stoppedValue_mono [SigmaFiniteFiltration μ 𝒢]\n (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) :\n Submartingale f 𝒢 μ ↔ ∀ τ π : Ω → ℕ∞, IsStoppingTime 𝒢 τ → IsStoppingTime 𝒢 π →\n τ ≤ π → (∃ N : ℕ, ∀ x, π x ≤ N) → μ[stoppedValue f τ] ≤ μ[stoppedValue f π] :=\n ⟨fun hf _ _ hτ hπ hle ⟨_, hN⟩ => hf.expected_stoppedValue_mono hτ hπ hle hN,\n submartingale_of_expected_stoppedValue_mono hadp hint⟩\n\nset_option backward.isDefEq.respectTransparency false in\n/-- The stopped process of a submartingale with respect to a stopping time is a submartingale. -/\nprotected theorem Submartingale.stoppedProcess [SigmaFiniteFiltration μ 𝒢]\n (h : Submartingale f 𝒢 μ) (hτ : IsStoppingTime 𝒢 τ) :\n Submartingale (stoppedProcess f τ) 𝒢 μ := by\n rw [submartingale_iff_expected_stoppedValue_mono]\n · intro σ π hσ hπ hσ_le_π hπ_bdd\n simp_rw [stoppedValue_stoppedProcess]\n obtain ⟨n, hπ_le_n⟩ := hπ_bdd\n have hπ_top ω : π ω ≠ ⊤ := ne_top_of_le_ne_top (by simp) (hπ_le_n ω)\n have hσ_top ω : σ ω ≠ ⊤ := ne_top_of_le_ne_top (hπ_top ω) (hσ_le_π ω)\n simp only [ne_eq, hσ_top, not_false_eq_true, ↓reduceIte, hπ_top, ge_iff_le]\n exact h.expected_stoppedValue_mono (hσ.min hτ) (hπ.min hτ)\n (fun ω => min_le_min (hσ_le_π ω) le_rfl) fun ω => (min_le_left _ _).trans (hπ_le_n ω)\n · exact StronglyAdapted.stoppedProcess_of_discrete h.stronglyAdapted hτ\n · exact fun i =>\n h.integrable_stoppedValue ((isStoppingTime_const _ i).min hτ) fun ω => min_le_left _ _\n\nsection Maximal\n\nopen Finset\n\nset_option backward.isDefEq.respectTransparency false in\n\nTarget:\ntheorem smul_le_stoppedValue_hittingBtwn [IsFiniteMeasure μ] (hsub : Submartingale f 𝒢 μ) {ε : ℝ≥0}\n (n : ℕ) : ε • μ {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω} ≤\n ENNReal.ofReal\n (∫ ω in {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_add_one fun k => f k ω},\n stoppedValue f (fun ω ↦ (hittingBtwn f {y : ℝ | ε ≤ y} 0 n ω : ℕ)) ω ∂μ) :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Martingale","family_id":"smul_le_stoppedvalue_hittingbtwn","file_id":"mathlib/Mathlib/Probability/Martingale/OptionalStopping.lean","sample_id":"4e3671a92b7157957d4f92ffebf2f271f222554aaaf55345092e61c95f24ab99"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e7ed32928de4181c53cd444ef5a831958803b39ca121aa3f2b67ce53087bd0cd","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"bc7b25c4eb054d9ef6ac14c1cb3705b9045954ce516160e5c71906c3264fc850","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"eb5f04f544cd1d4a8851f4c94907b459bed35e1b206435064d049d3ba2df1474","source_sha256":"887fd310386a65e61a82345a65129f3ea180e0f162b8057a46e309be54e27cf5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext\n have : Subsingleton (Lp ℝ 2 (0 : Measure E)) := ⟨fun x y ↦ Lp.ext_iff.2 rfl⟩\n simp [uncenteredCovarianceBilinDual, Subsingleton.eq_zero (StrongDual.toLp 0 2)]","hard_negative":true,"metrics":{"chosen_tokens":44,"rejected_tokens":3,"token_jaccard":0.030303,"token_length_ratio":0.068182},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"b66edb067a602f47b6727cc5f6d690cb22305a5e0c85049236af100481bfd0f3","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.LocallyConvex.ContinuousOfBounded\npublic import Mathlib.LinearAlgebra.BilinearForm.Properties\npublic import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap\npublic import Mathlib.Probability.Moments.Variance\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Covariance in Banach spaces\n\nWe define the covariance of a finite measure in a Banach space `E`,\nas a continuous bilinear form on `Dual ℝ E`.\n\n## Main definitions\n\nLet `μ` be a finite measure on a normed space `E` with the Borel σ-algebra. We then define\n\n* `Dual.toLp`: the function `MemLp.toLp` as a continuous linear map from `Dual 𝕜 E` (for `RCLike 𝕜`)\n into the space `Lp 𝕜 p μ` for `p ≥ 1`. This needs a hypothesis `MemLp id p μ` (we set it to the\n junk value 0 if that's not the case).\n* `covarianceBilinDual` : covariance of a measure `μ` with `∫ x, ‖x‖^2 ∂μ < ∞` on a Banach space,\n as a continuous bilinear form `Dual ℝ E →L[ℝ] Dual ℝ E →L[ℝ] ℝ`.\n If the second moment of `μ` is not finite, we set `covarianceBilinDual μ = 0`.\n\n## Main statements\n\n* `covarianceBilinDual_apply` : the covariance of `μ` on `L₁, L₂ : Dual ℝ E` is equal to\n `∫ x, (L₁ x - μ[L₁]) * (L₂ x - μ[L₂]) ∂μ`.\n* `covarianceBilinDual_same_eq_variance`: `covarianceBilinDual μ L L = Var[L; μ]`.\n\n## Implementation notes\n\nThe hypothesis that `μ` has a second moment is written as `MemLp id 2 μ` in the code.\n\n-/\n\n@[expose] public section\n\n\nopen MeasureTheory ProbabilityTheory Complex NormedSpace\nopen scoped ENNReal NNReal Real Topology\n\nvariable {E : Type*} [NormedAddCommGroup E] {mE : MeasurableSpace E} {μ : Measure E} {p : ℝ≥0∞}\n\nnamespace StrongDual\n\nsection LinearMap\n\nvariable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]\n\nopen Classical in\n/-- Linear map from the dual to `Lp` equal to `MemLp.toLp` if `MemLp id p μ` and to 0 otherwise. -/\nnoncomputable\ndef toLpₗ (μ : Measure E) (p : ℝ≥0∞) :\n StrongDual 𝕜 E →ₗ[𝕜] Lp 𝕜 p μ :=\n if h_Lp : MemLp id p μ then\n { toFun := fun L ↦ MemLp.toLp L (h_Lp.continuousLinearMap_comp L)\n map_add' u v := by push_cast; rw [MemLp.toLp_add]\n map_smul' c L := by push_cast; rw [MemLp.toLp_const_smul]; rfl }\n else 0\n\n@[simp]\nlemma toLpₗ_apply (h_Lp : MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLpₗ μ p = MemLp.toLp L (h_Lp.continuousLinearMap_comp L) := by\n simp [toLpₗ, dif_pos h_Lp]\n\n@[simp]\nlemma toLpₗ_of_not_memLp (h_Lp : ¬ MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLpₗ μ p = 0 := by\n simp [toLpₗ, dif_neg h_Lp]\n\nlemma norm_toLpₗ_le [OpensMeasurableSpace E] (L : StrongDual 𝕜 E) :\n ‖L.toLpₗ μ p‖ ≤ ‖L‖ * (eLpNorm id p μ).toReal := by\n by_cases h_Lp : MemLp id p μ\n swap\n · simp only [h_Lp, not_false_eq_true, toLpₗ_of_not_memLp, Lp.norm_zero]\n positivity\n by_cases hp : p = 0\n · simp only [h_Lp, toLpₗ_apply, Lp.norm_toLp]\n simp [hp]\n by_cases hp_top : p = ∞\n · simp only [hp_top, StrongDual.toLpₗ_apply h_Lp, Lp.norm_toLp, eLpNorm_exponent_top] at h_Lp ⊢\n simp only [eLpNormEssSup, id_eq]\n suffices (essSup (fun x ↦ ‖L x‖ₑ) μ).toReal ≤ (essSup (fun x ↦ ‖L‖ₑ * ‖x‖ₑ) μ).toReal by\n rwa [ENNReal.essSup_const_mul, ENNReal.toReal_mul, toReal_enorm] at this\n gcongr\n · rw [ENNReal.essSup_const_mul]\n exact ENNReal.mul_ne_top (by simp) h_Lp.eLpNorm_ne_top\n · exact essSup_mono_ae <| ae_of_all _ L.le_opNorm_enorm\n have h0 : 0 < p.toReal := by simp [ENNReal.toReal_pos_iff, pos_iff_ne_zero, hp, Ne.lt_top hp_top]\n suffices ‖L.toLpₗ μ p‖\n ≤ (‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ).toReal ^ p.toReal⁻¹ by\n refine this.trans_eq ?_\n simp only [ENNReal.toReal_mul]\n rw [← ENNReal.toReal_rpow, Real.mul_rpow (by positivity) (by positivity),\n ← Real.rpow_mul (by positivity), mul_inv_cancel₀ h0.ne', Real.rpow_one, toReal_enorm]\n rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top, ENNReal.toReal_rpow]\n simp\n rw [StrongDual.toLpₗ_apply h_Lp, Lp.norm_toLp,\n eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top]\n simp only [one_div]\n refine ENNReal.toReal_le_of_le_ofReal (by positivity) ?_\n suffices ∫⁻ x, ‖L x‖ₑ ^ p.toReal ∂μ ≤ ‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ by\n rw [← ENNReal.ofReal_rpow_of_nonneg (by positivity) (by positivity)]\n gcongr\n rwa [ENNReal.ofReal_toReal]\n refine ENNReal.mul_ne_top (by simp) ?_\n have h := h_Lp.eLpNorm_ne_top\n rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by simp [hp]) hp_top] at h\n simpa [h0] using h\n calc ∫⁻ x, ‖L x‖ₑ ^ p.toReal ∂μ\n _ ≤ ∫⁻ x, ‖L‖ₑ ^ p.toReal * ‖x‖ₑ ^ p.toReal ∂μ := by\n refine lintegral_mono fun x ↦ ?_\n rw [← ENNReal.mul_rpow_of_nonneg]\n swap; · positivity\n gcongr\n exact L.le_opNorm_enorm x\n _ = ‖L‖ₑ ^ p.toReal * ∫⁻ x, ‖x‖ₑ ^ p.toReal ∂μ := by rw [lintegral_const_mul]; fun_prop\n\nend LinearMap\n\nsection ContinuousLinearMap\n\nvariable {𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 E] [OpensMeasurableSpace E]\n\n/-- Continuous linear map from the dual to `Lp` equal to `MemLp.toLp` if `MemLp id p μ`\nand to 0 otherwise. -/\nnoncomputable\ndef toLp (μ : Measure E) (p : ℝ≥0∞) [Fact (1 ≤ p)] :\n StrongDual 𝕜 E →L[𝕜] Lp 𝕜 p μ where\n toLinearMap := StrongDual.toLpₗ μ p\n cont := by\n refine LinearMap.continuous_of_locally_bounded _ fun s hs ↦ ?_\n rw [image_isVonNBounded_iff]\n simp_rw [isVonNBounded_iff'] at hs\n obtain ⟨r, hxr⟩ := hs\n refine ⟨r * (eLpNorm id p μ).toReal, fun L hLs ↦ ?_⟩\n specialize hxr L hLs\n refine (StrongDual.norm_toLpₗ_le L).trans ?_\n gcongr\n\n@[simp]\nlemma toLp_apply [Fact (1 ≤ p)] (h_Lp : MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLp μ p = MemLp.toLp L (h_Lp.continuousLinearMap_comp L) := by\n simp [toLp, h_Lp]\n\n@[simp]\nlemma toLp_of_not_memLp [Fact (1 ≤ p)] (h_Lp : ¬ MemLp id p μ) (L : StrongDual 𝕜 E) :\n L.toLp μ p = 0 := by\n simp [toLp, h_Lp]\n\nend ContinuousLinearMap\n\nend StrongDual\n\nnamespace ProbabilityTheory\n\nsection Centered\n\nvariable [NormedSpace ℝ E] [OpensMeasurableSpace E]\n\n/-- Continuous bilinear form with value `∫ x, L₁ x * L₂ x ∂μ` on `(L₁, L₂)`.\nThis is equal to the covariance only if `μ` is centered. -/\nnoncomputable\ndef uncenteredCovarianceBilinDual (μ : Measure E) : StrongDual ℝ E →L[ℝ] StrongDual ℝ E →L[ℝ] ℝ :=\n ContinuousLinearMap.bilinearComp (isBoundedBilinearMap_inner (𝕜 := ℝ)).toContinuousLinearMap\n (StrongDual.toLp μ 2) (StrongDual.toLp μ 2)\n\nlemma uncenteredCovarianceBilinDual_apply (h : MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :\n uncenteredCovarianceBilinDual μ L₁ L₂ = ∫ x, L₁ x * L₂ x ∂μ := by\n simp only [uncenteredCovarianceBilinDual, ContinuousLinearMap.bilinearComp_apply,\n StrongDual.toLp_apply h, L2.inner_def, RCLike.inner_apply, conj_trivial]\n refine integral_congr_ae ?_\n filter_upwards [MemLp.coeFn_toLp (h.continuousLinearMap_comp L₁),\n MemLp.coeFn_toLp (h.continuousLinearMap_comp L₂)] with x hxL₁ hxL₂\n simp only [id_eq] at hxL₁ hxL₂\n rw [hxL₁, hxL₂, mul_comm]\n\nlemma uncenteredCovarianceBilinDual_of_not_memLp (h : ¬ MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :\n uncenteredCovarianceBilinDual μ L₁ L₂ = 0 := by\n simp [uncenteredCovarianceBilinDual, StrongDual.toLp_of_not_memLp h]\n\n@[simp]\n\nTarget:\nlemma uncenteredCovarianceBilinDual_zero : uncenteredCovarianceBilinDual (0 : Measure E) = 0 :=\n\nProof body:\n","rejected":"by\n exact uncenteredCovarianceBilinDual_zero","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"a051409235640870ecfd6a738992dd557c3ccbc47894168da3cc6e6448db92e1","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Moments","family_id":"uncenteredcovariancebilindual_zero","file_id":"mathlib/Mathlib/Probability/Moments/CovarianceBilinDual.lean","sample_id":"eb5f04f544cd1d4a8851f4c94907b459bed35e1b206435064d049d3ba2df1474"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"feafaa3bb07bd5457e9a390cbaab0163ff18cc790026c510e20f83437d157626","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5fd439a1cd2857ee1e8affa38b35e8013e317069286000ff0661c193f6b64dc9","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"bc78bf768f8b4dd1496d36a83703054152a59db89d8cd0de9554de53327fee5a","source_sha256":"c8dece265e2164323e741d2898bece661865ebee891ab28a390ba26cfdb86441","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have := DFunLike.congr_fun (toBaseChange_comp_reverseOp A Q) x\n refine (congr_arg unop this).trans ?_; clear this\n refine (LinearMap.congr_fun (TensorProduct.AlgebraTensorModule.map_comp _ _ _ _).symm _).trans ?_\n rw [reverse, AlgEquiv.toAlgHom_toLinearMap, AlgEquiv.toLinearEquiv_toOpposite]\n dsimp\n -- `simp` fails here due to a timeout looking for a `Subsingleton` instance!?\n rw [LinearEquiv.self_trans_symm]\n rfl","hard_negative":false,"metrics":{"chosen_tokens":89,"rejected_tokens":96,"token_jaccard":0.981132,"token_length_ratio":1.078652},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"b6f915da92168126c2f153d7d81adaeea4cd0736e265e7e720132fb5f9c4dc62","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.QuadraticForm.TensorProduct\npublic import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation\npublic import Mathlib.LinearAlgebra.TensorProduct.Opposite\npublic import Mathlib.RingTheory.TensorProduct.Basic\n\nNamespace:\nCliffordAlgebra\n\nLocal context:\n/-\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/-!\n# The base change of a clifford algebra\n\nIn this file we show the isomorphism\n\n* `CliffordAlgebra.equivBaseChange A Q` :\n `CliffordAlgebra (Q.baseChange A) ≃ₐ[A] (A ⊗[R] CliffordAlgebra Q)`\n with forward direction `CliffordAlgebra.toBaseChange A Q` and reverse direction\n `CliffordAlgebra.ofBaseChange A Q`.\n\nThis covers a more general case of the complexification of clifford algebras (as described in §2.2\nof https://empg.maths.ed.ac.uk/Activities/Spin/Lecture2.pdf), where ℂ and ℝ are replaced by an\n`R`-algebra `A` (where `2 : R` is invertible).\n\nWe show the additional results:\n\n* `CliffordAlgebra.toBaseChange_ι`: the effect of base-changing pure vectors.\n* `CliffordAlgebra.ofBaseChange_tmul_ι`: the effect of un-base-changing a tensor of a pure vectors.\n* `CliffordAlgebra.toBaseChange_involute`: the effect of base-changing an involution.\n* `CliffordAlgebra.toBaseChange_reverse`: the effect of base-changing a reversal.\n-/\n\n@[expose] public section\n\nvariable {R A V : Type*}\nvariable [CommRing R] [CommRing A] [AddCommGroup V]\nvariable [Algebra R A] [Module R V]\nvariable [Invertible (2 : R)]\n\nopen scoped TensorProduct\n\nnamespace CliffordAlgebra\n\nvariable (A)\n\nset_option backward.isDefEq.respectTransparency false in\n/-- Auxiliary construction: note this is really just a heterobasic `CliffordAlgebra.map`. -/\ndef ofBaseChangeAux (Q : QuadraticForm R V) :\n CliffordAlgebra Q →ₐ[R] CliffordAlgebra (Q.baseChange A) :=\n CliffordAlgebra.lift Q <| by\n refine ⟨(ι (Q.baseChange A)).restrictScalars R ∘ₗ TensorProduct.mk R A V 1, fun v => ?_⟩\n refine (CliffordAlgebra.ι_sq_scalar (Q.baseChange A) (1 ⊗ₜ v)).trans ?_\n rw [QuadraticForm.baseChange_tmul, one_mul, ← Algebra.algebraMap_eq_smul_one,\n ← IsScalarTower.algebraMap_apply]\n\n@[simp] theorem ofBaseChangeAux_ι (Q : QuadraticForm R V) (v : V) :\n ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (1 ⊗ₜ v) :=\n CliffordAlgebra.lift_ι_apply _ _ v\n\nset_option backward.isDefEq.respectTransparency false in\n/-- Convert from the base-changed clifford algebra to the clifford algebra over a base-changed\nmodule. -/\ndef ofBaseChange (Q : QuadraticForm R V) :\n A ⊗[R] CliffordAlgebra Q →ₐ[A] CliffordAlgebra (Q.baseChange A) :=\n Algebra.TensorProduct.lift (Algebra.ofId _ _) (ofBaseChangeAux A Q)\n fun _a _x => Algebra.commutes _ _\n\n@[simp] theorem ofBaseChange_tmul_ι (Q : QuadraticForm R V) (z : A) (v : V) :\n ofBaseChange A Q (z ⊗ₜ ι Q v) = ι (Q.baseChange A) (z ⊗ₜ v) := by\n change algebraMap _ _ z * ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (z ⊗ₜ[R] v)\n rw [ofBaseChangeAux_ι, ← Algebra.smul_def, ← map_smul, TensorProduct.smul_tmul', smul_eq_mul,\n mul_one]\n\n@[simp] theorem ofBaseChange_tmul_one (Q : QuadraticForm R V) (z : A) :\n ofBaseChange A Q (z ⊗ₜ 1) = algebraMap _ _ z := by\n change algebraMap _ _ z * ofBaseChangeAux A Q 1 = _\n rw [map_one, mul_one]\n\nset_option backward.defeqAttrib.useBackward true in\n/-- Convert from the clifford algebra over a base-changed module to the base-changed clifford\nalgebra. -/\ndef toBaseChange (Q : QuadraticForm R V) :\n CliffordAlgebra (Q.baseChange A) →ₐ[A] A ⊗[R] CliffordAlgebra Q :=\n CliffordAlgebra.lift _ <| by\n refine ⟨TensorProduct.AlgebraTensorModule.map (LinearMap.id : A →ₗ[A] A) (ι Q), ?_⟩\n letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm\n letI : Invertible (2 : A ⊗[R] CliffordAlgebra Q) :=\n (Invertible.map (algebraMap R _) 2).copy 2 (map_ofNat _ _).symm\n suffices hpure_tensor : ∀ v w, (1 * 1) ⊗ₜ[R] (ι Q v * ι Q w) + (1 * 1) ⊗ₜ[R] (ι Q w * ι Q v) =\n QuadraticMap.polarBilin (Q.baseChange A) (1 ⊗ₜ[R] v) (1 ⊗ₜ[R] w) ⊗ₜ[R] 1 by\n -- the crux is that by converting to a statement about linear maps instead of quadratic forms,\n -- we then have access to all the partially-applied `ext` lemmas.\n rw [CliffordAlgebra.forall_mul_self_eq_iff (isUnit_of_invertible _)]\n refine TensorProduct.AlgebraTensorModule.curry_injective ?_\n ext v w\n dsimp\n exact hpure_tensor v w\n intro v w\n rw [← TensorProduct.tmul_add, CliffordAlgebra.ι_mul_ι_add_swap,\n QuadraticForm.polarBilin_baseChange, LinearMap.BilinForm.baseChange_tmul, one_mul,\n TensorProduct.smul_tmul, Algebra.algebraMap_eq_smul_one, QuadraticMap.polarBilin_apply_apply]\n\n@[simp] theorem toBaseChange_ι (Q : QuadraticForm R V) (z : A) (v : V) :\n toBaseChange A Q (ι (Q.baseChange A) (z ⊗ₜ v)) = z ⊗ₜ ι Q v :=\n CliffordAlgebra.lift_ι_apply _ _ _\n\ntheorem toBaseChange_comp_involute (Q : QuadraticForm R V) :\n (toBaseChange A Q).comp (involute : CliffordAlgebra (Q.baseChange A) →ₐ[A] _) =\n (Algebra.TensorProduct.map (AlgHom.id _ _) involute).comp (toBaseChange A Q) := by\n ext v\n change toBaseChange A Q (involute (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))\n = (Algebra.TensorProduct.map (AlgHom.id _ _) involute :\n A ⊗[R] CliffordAlgebra Q →ₐ[A] _)\n (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))\n rw [toBaseChange_ι, involute_ι, map_neg (toBaseChange A Q), toBaseChange_ι,\n Algebra.TensorProduct.map_tmul, AlgHom.id_apply, involute_ι, TensorProduct.tmul_neg]\n\n/-- The involution acts only on the right of the tensor product. -/\ntheorem toBaseChange_involute (Q : QuadraticForm R V) (x : CliffordAlgebra (Q.baseChange A)) :\n toBaseChange A Q (involute x) =\n TensorProduct.map LinearMap.id (involute.toLinearMap) (toBaseChange A Q x) :=\n DFunLike.congr_fun (toBaseChange_comp_involute A Q) x\n\nopen MulOpposite\n\n/-- Auxiliary theorem used to prove `toBaseChange_reverse` without needing induction. -/\ntheorem toBaseChange_comp_reverseOp (Q : QuadraticForm R V) :\n (toBaseChange A Q).op.comp reverseOp =\n ((Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q)).toAlgHom.comp <|\n (Algebra.TensorProduct.map\n (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q))).comp\n (toBaseChange A Q)) := by\n ext v\n change op (toBaseChange A Q (reverse (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))) =\n Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q)\n (Algebra.TensorProduct.map (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q))\n (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v))))\n rw [toBaseChange_ι, reverse_ι, toBaseChange_ι, Algebra.TensorProduct.map_tmul,\n Algebra.TensorProduct.opAlgEquiv_tmul, reverseOp_ι]\n rfl\n\n/-- `reverse` acts only on the right of the tensor product. -/\n\nTarget:\ntheorem toBaseChange_reverse (Q : QuadraticForm R V) (x : CliffordAlgebra (Q.baseChange A)) :\n toBaseChange A Q (reverse x) =\n TensorProduct.map LinearMap.id reverse (toBaseChange A Q x) :=\n\nProof body:\n","rejected":"```lean\nby\n have := DFunLike.congr_fun (toBaseChange_comp_reverseOp A Q) x\n refine (congr_arg unop this).trans ?_; clear this\n refine (LinearMap.congr_fun (TensorProduct.AlgebraTensorModule.map_comp _ _ _ _).symm _).trans ?_\n rw [reverse, AlgEquiv.toAlgHom_toLinearMap, AlgEquiv.toLinearEquiv_toOpposite]\n dsimp\n -- `simp` fails here due to a timeout looking for a `Subsingleton` instance!?\n rw [LinearEquiv.self_trans_symm]\n rfl\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/CliffordAlgebra","family_id":"tobasechange_reverse","file_id":"mathlib/Mathlib/LinearAlgebra/CliffordAlgebra/BaseChange.lean","sample_id":"bc78bf768f8b4dd1496d36a83703054152a59db89d8cd0de9554de53327fee5a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"35ab53fe79d4113d65c677290358d579efd748d687233a57bc7ee95525ee31ae","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"793da31efec3ccfa93d53da4f691d872a202e756714f84dc9db74210ad30d996","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0f9a99abd92dd5aece612a161e2ac094ccc406554e08311119408b5083b26bf1","source_sha256":"8e40b01e7ccf6ab3c48f4a90d26615e74e27bf1ea1850224aad736249f560b66","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using lift_cardinalMk_adjoin_le R s","hard_negative":true,"metrics":{"chosen_tokens":6,"rejected_tokens":5,"token_jaccard":0.1,"token_length_ratio":0.833333},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"b7b81186adfe2b0c5730e830240227b79bd638016951cea0743067bc1c6a9b18","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.FreeAlgebra\npublic import Mathlib.SetTheory.Cardinal.Free\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n# Cardinality of free algebras\n\nThis file contains some results about the cardinality of `FreeAlgebra`,\nparallel to that of `MvPolynomial`.\n-/\n\npublic section\n\nuniverse u v\n\nvariable (R : Type u) [CommSemiring R]\n\nopen Cardinal\n\nnamespace FreeAlgebra\n\nvariable (X : Type v)\n\n@[simp]\ntheorem cardinalMk_eq_max_lift [Nonempty X] [Nontrivial R] :\n #(FreeAlgebra R X) = Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n have hX := mk_freeMonoid X\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra,\n mk_finsupp_lift_of_infinite, hX, lift_max, lift_aleph0, sup_comm, ← sup_assoc]\n\n@[simp]\ntheorem cardinalMk_eq_lift [IsEmpty X] : #(FreeAlgebra R X) = Cardinal.lift.{v} #R := by\n have := lift_mk_eq'.2 ⟨show (FreeMonoid X →₀ R) ≃ R from Finsupp.uniqueEquiv 1⟩\n rw [lift_id'.{u, v}, lift_umax] at this\n rwa [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra]\n\n@[nontriviality]\ntheorem cardinalMk_eq_one [Subsingleton R] : #(FreeAlgebra R X) = 1 := by\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra, mk_eq_one]\n\ntheorem cardinalMk_le_max_lift :\n #(FreeAlgebra R X) ≤ Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n cases subsingleton_or_nontrivial R\n · exact (cardinalMk_eq_one R X).trans_le (le_max_of_le_right one_le_aleph0)\n cases isEmpty_or_nonempty X\n · exact (cardinalMk_eq_lift R X).trans_le (le_max_of_le_left <| le_max_left _ _)\n · exact (cardinalMk_eq_max_lift R X).le\n\nvariable (X : Type u)\n\ntheorem cardinalMk_eq_max [Nonempty X] [Nontrivial R] : #(FreeAlgebra R X) = #R ⊔ #X ⊔ ℵ₀ := by\n simp\n\ntheorem cardinalMk_eq [IsEmpty X] : #(FreeAlgebra R X) = #R := by\n simp\n\ntheorem cardinalMk_le_max : #(FreeAlgebra R X) ≤ #R ⊔ #X ⊔ ℵ₀ := by\n simpa using cardinalMk_le_max_lift R X\n\nend FreeAlgebra\n\nnamespace Algebra\n\ntheorem lift_cardinalMk_adjoin_le {A : Type v} [Semiring A] [Algebra R A] (s : Set A) :\n lift.{u} #(adjoin R s) ≤ lift.{v} #R ⊔ lift.{u} #s ⊔ ℵ₀ := by\n have H := mk_range_le_lift (f := FreeAlgebra.lift R ((↑) : s → A))\n rw [lift_umax, lift_id'.{v, u}] at H\n rw [Algebra.adjoin_eq_range_freeAlgebra_lift]\n exact H.trans (FreeAlgebra.cardinalMk_le_max_lift R s)\n\nTarget:\ntheorem cardinalMk_adjoin_le {A : Type u} [Semiring A] [Algebra R A] (s : Set A) :\n #(adjoin R s) ≤ #R ⊔ #s ⊔ ℵ₀ :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_0f9a99abd92d","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"f0856b033000885c3c172111b4f575599bc709ae0e5a6371412c36a0c53cd069","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAlgebra","family_id":"cardinalmk_adjoin_le","file_id":"mathlib/Mathlib/Algebra/FreeAlgebra/Cardinality.lean","sample_id":"0f9a99abd92dd5aece612a161e2ac094ccc406554e08311119408b5083b26bf1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f2a437684fead703036873298a0ace34afe80682f6dc457c5baaff612f9fa32c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"60e1a407510c44cbd7b7e68a5c044fa552dc6a75c3cd628ebcf704c5de1b9ee1","source_sha256":"e88909466015ff2d4c0d5ff8a5e84a299fba6b9e7e753b82aadbaeb3e8ea93c9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n intro X Y f g\n simp only [← NatIso.naturality_1 e (f + g), map_add, Preadditive.add_comp,\n NatTrans.naturality, Preadditive.comp_add, Iso.inv_hom_id_app_assoc]\n\nomit [F.Additive] in","hard_negative":true,"metrics":{"chosen_tokens":46,"rejected_tokens":8,"token_jaccard":0.026316,"token_length_ratio":0.173913},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"b7d1513fa2fc2908447f7e7a25db464198bfebfc7eef975d666e1bfd707995be","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Limits.ExactFunctor\npublic import Mathlib.CategoryTheory.Limits.Preserves.Finite\npublic import Mathlib.CategoryTheory.Preadditive.Biproducts\npublic import Mathlib.CategoryTheory.Preadditive.FunctorCategory\n\nNamespace:\nCategoryTheory.Functor\n\nLocal context:\n/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Kim Morrison\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.\nConversely, if `F : C ⥤ D` is a functor between preadditive categories, where `C` has binary\nbiproducts, and if `F` preserves binary biproducts, then `F` is additive.\n\nWe also define the category of bundled additive functors.\n\n## Implementation details\n\n`Functor.Additive` is a `Prop`-valued class, defined by saying that for every two objects `X` and\n`Y`, the map `F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of abelian groups.\n\n-/\n\n@[expose] public section\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnamespace CategoryTheory\n\n/-- A functor `F` is additive provided `F.map` is an additive homomorphism. -/\n@[stacks 00ZY]\nclass Functor.Additive {C D : Type*} [Category* C] [Category* D] [Preadditive C] [Preadditive D]\n (F : C ⥤ D) : Prop where\n /-- the addition of two morphisms is mapped to the sum of their images -/\n map_add : ∀ {X Y : C} {f g : X ⟶ Y}, F.map (f + g) = F.map f + F.map g := by cat_disch\n\nsection Preadditive\n\nnamespace Functor\n\nsection\n\nvariable {C D E : Type*} [Category* C] [Category* D] [Category* E]\n [Preadditive C] [Preadditive D] [Preadditive E] (F : C ⥤ D) [Functor.Additive F]\n\n@[simp]\ntheorem map_add {X Y : C} {f g : X ⟶ Y} : F.map (f + g) = F.map f + F.map g :=\n Functor.Additive.map_add\n\n/-- `F.mapAddHom` is an additive homomorphism whose underlying function is `F.map`. -/\n@[simps!]\ndef mapAddHom {X Y : C} : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y) :=\n AddMonoidHom.mk' (fun f => F.map f) fun _ _ => F.map_add\n\ntheorem coe_mapAddHom {X Y : C} : ⇑(F.mapAddHom : (X ⟶ Y) →+ _) = F.map :=\n rfl\n\ninstance (priority := 100) preservesZeroMorphisms_of_additive : PreservesZeroMorphisms F where\n map_zero _ _ := F.mapAddHom.map_zero\n\ninstance : Additive (𝟭 C) where\n\ninstance {E : Type*} [Category* E] [Preadditive E] (G : D ⥤ E) [Functor.Additive G] :\n Additive (F ⋙ G) where\n\ninstance {J : Type*} [Category* J] (j : J) : ((evaluation J C).obj j).Additive where\n\n@[simp]\ntheorem map_neg {X Y : C} {f : X ⟶ Y} : F.map (-f) = -F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_neg _\n\n@[simp]\ntheorem map_sub {X Y : C} {f g : X ⟶ Y} : F.map (f - g) = F.map f - F.map g :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_sub _ _\n\ntheorem map_nsmul {X Y : C} {f : X ⟶ Y} {n : ℕ} : F.map (n • f) = n • F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_nsmul _ _\n\n-- You can alternatively just use `Functor.map_smul` here, with an explicit `(r : ℤ)` argument.\ntheorem map_zsmul {X Y : C} {f : X ⟶ Y} {r : ℤ} : F.map (r • f) = r • F.map f :=\n (F.mapAddHom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_zsmul _ _\n\n@[simp]\nnonrec theorem map_sum {X Y : C} {α : Type*} (f : α → (X ⟶ Y)) (s : Finset α) :\n F.map (∑ a ∈ s, f a) = ∑ a ∈ s, F.map (f a) :=\n map_sum F.mapAddHom f s\n\nvariable {F}\n\nTarget:\nlemma additive_of_iso {G : C ⥤ D} (e : F ≅ G) : G.Additive :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"3cfccadde03f189210a4dea1f5380453e65060595e48e738d02bc77f53f21260","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Preadditive","family_id":"additive_of_iso","file_id":"mathlib/Mathlib/CategoryTheory/Preadditive/AdditiveFunctor.lean","sample_id":"60e1a407510c44cbd7b7e68a5c044fa552dc6a75c3cd628ebcf704c5de1b9ee1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c7447d6b7ef5b2499552f0a9ea2c10ee3982f942ee24fb3733f29cf9d6fb4bcc","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"70890f91bf9e8348ffdb01133182598dc44b473f88c975a8178b394dbb2376aa","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3ce96acfb04dbc12ad341c07ff30b17b76c023a8f28c2048ea4a7e7e61f94a7d","source_sha256":"c8a33bb8cce3962f230d95a94382ba6537d37e619b16dfe9b8c1fe283237e032","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [← SetLike.coe_set_eq]","hard_negative":true,"metrics":{"chosen_tokens":8,"rejected_tokens":2,"token_jaccard":0.111111,"token_length_ratio":0.25},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"b7e06d87a7a9e77e297de69faf8fdbf9d4be0222878a55c5b05907db4b20e3a6","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.GroupTheory.Subsemigroup.Center\npublic import Mathlib.RingTheory.NonUnitalSubring.Defs\npublic import Mathlib.RingTheory.NonUnitalSubsemiring.Basic\n\nNamespace:\nNonUnitalSubring\n\nLocal context:\n/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n/-!\n# `NonUnitalSubring`s\n\nLet `R` be a non-unital ring.\nWe prove that non-unital subrings 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 `NonUnitalSubring R`, sending a subset of\n`R` to the non-unital subring it generates, and prove that it is a Galois insertion.\n\n## Main definitions\n\nNotation used here:\n\n`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`\n`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`\n\n* `instance : CompleteLattice (NonUnitalSubring R)` : the complete lattice structure on the\n non-unital subrings.\n\n* `NonUnitalSubring.center` : the center of a non-unital ring `R`.\n\n* `NonUnitalSubring.closure` : non-unital subring closure of a set, i.e., the smallest\n non-unital subring that includes the set.\n\n* `NonUnitalSubring.gi` : `closure : Set M → NonUnitalSubring M` and coercion\n `coe : NonUnitalSubring M → Set M`\n form a `GaloisInsertion`.\n\n* `comap f B : NonUnitalSubring A` : the preimage of a non-unital subring `B` along the\n non-unital ring homomorphism `f`\n\n* `map f A : NonUnitalSubring B` : the image of a non-unital subring `A` along the\n non-unital ring homomorphism `f`.\n\n* `Prod A B : NonUnitalSubring (R × S)` : the product of non-unital subrings\n\n* `f.range : NonUnitalSubring B` : the range of the non-unital ring homomorphism `f`.\n\n* `eq_locus f g : NonUnitalSubring R` : given non-unital ring homomorphisms `f g : R →ₙ+* S`,\n the non-unital subring of `R` where `f x = g x`\n\n## Implementation notes\n\nA non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an\nadditive subgroup.\n\nLattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although\n`∈` is defined as membership of a non-unital subring's underlying set.\n\n## Tags\nnon-unital subring\n-/\n\n@[expose] public section\n\n\nuniverse u v w\n\nsection Basic\n\nvariable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]\n\nnamespace NonUnitalSubring\n\nvariable (s : NonUnitalSubring R)\n\n/-- Sum of a list of elements in a non-unital subring is in the non-unital subring. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=\n list_sum_mem\n\n/-- Sum of a multiset of elements in a `NonUnitalSubring` of a `NonUnitalRing` is\nin the `NonUnitalSubring`. -/\nprotected theorem multiset_sum_mem {R} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=\n multiset_sum_mem _\n\n/-- Sum of elements in a `NonUnitalSubring` of a `NonUnitalRing` indexed by a `Finset`\nis in the `NonUnitalSubring`. -/\nprotected theorem sum_mem {R : Type*} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n {ι : Type*} {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∑ i ∈ t, f i) ∈ s :=\n sum_mem h\n\n/-! ## top -/\n\n\n/-- The non-unital subring `R` of the ring `R`. -/\ninstance : Top (NonUnitalSubring R) :=\n ⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubgroup R) with }⟩\n\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubring R) :=\n Set.mem_univ x\n\n@[simp]\ntheorem coe_top : ((⊤ : NonUnitalSubring R) : Set R) = Set.univ :=\n rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_top : (⊤ : NonUnitalSubring R).toNonUnitalSubsemiring = ⊤ := rfl\n\n@[simp] lemma toAddSubgroup_top : (⊤ : NonUnitalSubring R).toAddSubgroup = ⊤ := rfl\n\n@[simp]\n\nTarget:\nlemma toNonUnitalSubsemiring_eq_top {S : NonUnitalSubring R} :\n S.toNonUnitalSubsemiring = ⊤ ↔ S = ⊤ :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_3ce96acfb04d","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"342f42287e5b5ec0d9616c7d1cc69ad36ef70bf2f61c80b23120a1adabb2c8b7","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/NonUnitalSubring","family_id":"tononunitalsubsemiring_eq_top","file_id":"mathlib/Mathlib/RingTheory/NonUnitalSubring/Basic.lean","sample_id":"3ce96acfb04dbc12ad341c07ff30b17b76c023a8f28c2048ea4a7e7e61f94a7d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a663b4e75d9f1596287537a4a62875a72ffff913179559355bffea345ae7886c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa8af9b43eb1670040004fd1c0fa9b87db2f7ae969e8fb8ad8b2681f76bf7062","source_sha256":"1b04fd9daf3044c08d9f2cf2b300a5656d02c1209b70e4ca6f56f26097a25af2","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let f := Spec.map (CommRingCat.ofHom <| algebraMap K (AlgebraicClosure K))\n let G' := (Over.pullback f).obj G\n have : IsProper G'.hom := by dsimp [G']; infer_instance\n have : IsIntegral (G' ⊗ G').left := by dsimp [G']; infer_instance\n let : GrpObj G' := Functor.grpObjObj\n have := isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed G'\n rw [isCommMonObj_iff_commutator_eq_toUnit_η] at this ⊢\n apply (Over.pullback f).map_injective\n rw [← cancel_epi (Functor.Monoidal.μIso (Over.pullback f) G G).hom]\n dsimp [GrpObj.commutator] at this ⊢\n simpa only [Functor.map_mul, one_eq_one, comp_one, Functor.map_one, Functor.map_inv',\n comp_mul, GrpObj.comp_inv, Functor.Monoidal.μ_fst, Functor.Monoidal.μ_snd]","hard_negative":true,"metrics":{"chosen_tokens":164,"rejected_tokens":8,"token_jaccard":0.060606,"token_length_ratio":0.04878},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"b7e157af4e3b15fde5a3fd984997eb52277bc218a7f89a2a0776d3f75e963975","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.AlgClosed.Basic\npublic import Mathlib.AlgebraicGeometry.Geometrically.Integral\npublic import Mathlib.AlgebraicGeometry.ZariskisMainTheorem\npublic import Mathlib.CategoryTheory.Monoidal.Cartesian.Grp\n\nNamespace:\nAlgebraicGeometry\n\nLocal context:\n/-\nCopyright (c) 2026 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang, Christian Merten\n-/\n/-!\n# Abelian varieties\n\n## Main results\n- `AlgebraicGeometry.isCommMonObj_of_isProper_of_geometricallyIntegral`:\n A proper geometrically integral group scheme over a field is commutative.\n\n-/\n\npublic section\n\nopen CategoryTheory Limits\n\nnamespace AlgebraicGeometry\n\nuniverse u\n\nvariable {K : Type u} [Field K] {X : Scheme.{u}}\n\nopen MonoidalCategory CartesianMonoidalCategory MonObj\n\nset_option backward.isDefEq.respectTransparency false in\ninstance (G : Over (Spec (.of K))) [GrpObj G] : IsClosedImmersion η[G].left :=\n isClosedImmersion_of_comp_eq_id (Y := Spec (.of K)) G.hom η[G].left (by simp)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\ntheorem isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed [IsAlgClosed K]\n (G : Over (Spec (.of K))) [IsProper G.hom] [IsIntegral (G ⊗ G).left] [GrpObj G] :\n IsCommMonObj G := by\n let S := Spec (.of K)\n let point : S := IsLocalRing.closedPoint K\n have hpoint : IsClosed {point} := isClosed_discrete _\n have : Nonempty G.left := ⟨η[G].left point⟩\n have : IsProper (G ⊗ G).hom := by dsimp; infer_instance\n have : JacobsonSpace (G ⊗ G).left := LocallyOfFiniteType.jacobsonSpace (Y := Spec _) (G ⊗ G).hom\n have : Surjective G.hom := ⟨Function.surjective_to_subsingleton (α := G.left) (β := Spec _) _⟩\n have : IsProper (fst G G).left := by dsimp; infer_instance\n have : Surjective (fst G G).left := by dsimp; infer_instance\n have : IsProper ((GrpObj.commutator G).left ≫ G.hom) := by rw [Over.w]; infer_instance\n have : IsClosedImmersion ((lift η[G] η[G]).left ≫ (fst G G).left) := by\n simpa using inferInstanceAs (IsClosedImmersion η[G].left)\n have : IsClosedImmersion (lift η[G] η[G]).left := .of_comp _ (g := (fst G G).left)\n let γ : G ⊗ G ⟶ G ⊗ G := lift (fst _ _) (GrpObj.commutator _)\n have : IsProper (γ.left ≫ (fst G G).left) := by simpa [γ]\n have : IsProper γ.left := .of_comp _ (fst G G).left\n -- It suffices to check that `γ : (x, y) ↦ x * y * x⁻¹ * y⁻¹` is constantly `1`.\n rw [isCommMonObj_iff_commutator_eq_toUnit_η]\n ext1\n have H : γ.left '' ((fst G G).left ⁻¹' {η[G].left point}) ⊆ {(lift η[G] η[G]).left point} := by\n rw [Set.image_subset_iff, ← Set.sdiff_eq_empty, ← Set.not_nonempty_iff_eq_empty]\n intro H\n obtain ⟨c₀, ⟨hc₁, hc₂⟩, hc₃⟩ := nonempty_inter_closedPoints H <| by\n rw [Set.sdiff_eq_compl_inter, ← Set.image_singleton, ← Set.image_singleton];\n refine (IsOpen.isLocallyClosed ?_).inter (IsClosed.isLocallyClosed ?_)\n · exact (((lift η[G] η[G]).left.isClosedMap _ hpoint).preimage γ.left.continuous).isOpen_compl\n · exact (η[G].left.isClosedMap _ hpoint).preimage (fst G G).left.continuous\n obtain ⟨⟨c, hc⟩, e⟩ := (pointEquivClosedPoint (G ⊗ G).hom).surjective ⟨c₀, hc₃⟩\n obtain rfl : c point = c₀ := congr(($e).1)\n let fc : 𝟙_ (Over S) ⟶ 𝟙_ (Over S) ⊗ G := lift (𝟙 _) (Over.homMk c hc ≫ snd G G)\n have : c ≫ pullback.fst G.hom G.hom = η[G].left :=\n ext_of_apply_closedPoint_eq G.hom (by simpa) (by simp) (by simpa)\n have H₁ : c = fc.left ≫ (η[G] ▷ G).left := by dsimp; ext <;> simp [fc, S, this]\n have H₂ : fc ≫ η ▷ G ≫ γ = lift η η := by ext1 <;> simp [fc, γ, S]\n exact hc₂ <| by simp [H₁, H₂, ← Scheme.Hom.comp_apply, Category.assoc, ← Over.comp_left]\n -- Since the image of `y ↦ γ(e, y)` is finite, by Zariski Main, there exists an open\n -- `1 ∈ U ⊆ G` such that `γ ∣_ U` factors through a finite scheme over `U`.\n obtain ⟨U, hηU, H⟩ := exists_finite_imageι_comp_morphismRestrict_of_finite_image_preimage\n γ.left (fst G G).left (η[G].left point) (by\n dsimp [-Scheme.Hom.comp_base, γ]\n simp only [pullback.lift_fst]\n exact (Set.finite_singleton _).subset H)\n have H (x : U) : ((pullback.fst G.hom G.hom) ⁻¹' {x.1} ∩ Set.range ⇑γ.left).Finite := by\n refine ((((γ.left.imageι ≫ (fst G G).left) ∣_ U).finite_preimage_singleton x).image\n (Scheme.Opens.ι _ ≫ γ.left.imageι)).subset ?_\n have : U.ι ⁻¹' {x.1} = {x} := by ext; simp\n rw [← this, ← Set.preimage_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base,\n morphismRestrict_ι, ← Category.assoc, Scheme.Hom.comp_base (_ ≫ _) (fst G G).left,\n TopCat.coe_comp, Set.preimage_comp, Set.image_preimage_eq_inter_range]\n simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp, Scheme.Opens.range_ι]\n dsimp\n rw [Set.image_preimage_eq_inter_range, Scheme.IdealSheafData.range_subschemeι,\n Scheme.Hom.support_ker, ← Set.inter_assoc, ← Set.preimage_inter,\n Set.singleton_inter_of_mem x.2, IsClosed.closure_eq\n (by exact γ.left.isClosedMap.isClosed_range)]\n -- It suffices to check set-theoretic equality on closed points of `U ×[k] G`.\n refine ext_of_apply_eq G.hom _\n ((fst G G).left ⁻¹ᵁ U).isOpen.isLocallyClosed\n (((fst G G).left ⁻¹ᵁ U).isOpen.dense ?_) ?_ ?_\n · exact .preimage ⟨_, hηU⟩ (fst G G).left.surjective\n · intro y hyU hy\n have hx : IsClosed {(fst G G).left y} := by simpa using (fst G G).left.isClosedMap _ hy\n let x : 𝟙_ _ ⟶ G := Over.homMk (pointOfClosedPoint G.hom _ hx) (by simp)\n let xe : (G ⊗ G).left := (fst G G ≫ (ρ_ _).inv ≫ G ◁ η[G]).left y\n have : γ.left y = xe := by\n -- By the choice of `U`, the set `γ({y} ×[k] G)` is finite and hence, by irreducibility,\n -- a singleton.\n refine subsingleton_image_closure_of_finite_of_isPreirreducible\n (hx.preimage (fst G G).left.continuous).isLocallyClosed ?_ γ.left.continuous\n γ.left.isClosedMap ((H ⟨_, hyU⟩).subset (Set.image_subset_iff.mpr fun _ ↦ by\n simp [← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base, γ])) ?_ ?_\n · let α : G ⊗ G ⟶ G ⊗ G := toUnit _ ≫ x ⊗ₘ 𝟙 _\n convert!\n ((IrreducibleSpace.isIrreducible_univ _).image α.left\n α.left.continuous.continuousOn).isPreirreducible\n rw [Over.tensorHom_left]\n simp [Set.range_comp, Scheme.Pullback.range_map, x]\n · exact ⟨y, subset_closure (by simp), rfl⟩\n · refine ⟨xe, subset_closure ?_, ?_⟩\n · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base]\n · simp only [xe, γ, ← Scheme.Hom.comp_apply, ← Over.comp_left]\n congr 6; ext <;> simp\n convert! congr((snd G G).left $this) using 1\n · simp [γ, ← Scheme.Hom.comp_apply]\n · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base]\n · simp\n\nset_option backward.defeqAttrib.useBackward true in\n/-- A proper geometrically integral group scheme over a field is commutative. -/\n@[stacks 0BFD]\n\nTarget:\ntheorem isCommMonObj_of_isProper_of_geometricallyIntegral\n (G : Over (Spec (.of K))) [IsProper G.hom] [GeometricallyIntegral G.hom] [GrpObj G] :\n IsCommMonObj G :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"72726ce37c9e2fe16e120bdb92181bf7c048c1605a3c6b151242812980b8651a","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Group","family_id":"iscommmonobj_of_isproper_of_geometricallyintegral","file_id":"mathlib/Mathlib/AlgebraicGeometry/Group/Abelian.lean","sample_id":"fa8af9b43eb1670040004fd1c0fa9b87db2f7ae969e8fb8ad8b2681f76bf7062"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8e0b5a57a1cdde1645596eb1594f8a0f8afcf9ccd1e789d96515f6929a83487b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"52e69e942ad6cdbe562009dc71073e2843a675af6d08ef474d3e5afa92251338","source_sha256":"38d64e4f1a0e05f9858787ff51b94222506a7fd69d13ef99d2c65865e8c1dd3f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cases x <;> rfl\n\nvariable (η : ApplicativeTransformation F G)","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":3,"token_jaccard":0.058824,"token_length_ratio":0.2},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"b89125de9524b8f93b550fde7f6fbeceee42f42f7d1b169cb5419e4fb3c28448","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Control.Applicative\npublic import Mathlib.Control.Traversable.Basic\npublic import Mathlib.Data.List.Forall2\npublic import Mathlib.Data.Set.Functor\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# LawfulTraversable instances\n\nThis file provides instances of `LawfulTraversable` for types from the core library: `Option`,\n`List` and `Sum`.\n-/\n\npublic section\n\n\nuniverse u v\n\nsection Option\n\nopen Functor\n\nvariable {F G : Type u → Type u}\nvariable [Applicative F] [Applicative G]\nvariable [LawfulApplicative G]\n\ntheorem Option.id_traverse {α} (x : Option α) : Option.traverse (pure : α → Id α) x = pure x := by\n cases x <;> rfl\n\ntheorem Option.comp_traverse {α β γ} (f : β → F γ) (g : α → G β) (x : Option α) :\n Option.traverse (Comp.mk ∘ (f <$> ·) ∘ g) x =\n Comp.mk (Option.traverse f <$> Option.traverse g x) := by\n cases x <;> (simp [Option.traverse, Option.mapM, functor_norm] <;> rfl)\n\nTarget:\ntheorem Option.traverse_eq_map_id {α β} (f : α → β) (x : Option α) :\n Option.traverse ((pure : _ → Id _) ∘ f) x = (pure : _ → Id _) (f <$> x) :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Control/Traversable","family_id":"option","file_id":"mathlib/Mathlib/Control/Traversable/Instances.lean","sample_id":"52e69e942ad6cdbe562009dc71073e2843a675af6d08ef474d3e5afa92251338"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"68c104da4cc327d3cbce10433708ceb988526741db2a9149c78e83d04499b44c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ac9ac3500f687b9445a8138f2c6a989bcc646e5941eeeb34f232905d349f7a8a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6d8bf0d2dcc47dd84e343933d598b89d5d7e2ab0f76d0f19f4d7520db1ced6e1","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]","hard_negative":false,"metrics":{"chosen_tokens":23,"rejected_tokens":28,"token_jaccard":0.809524,"token_length_ratio":1.217391},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"b9216a2c2a775fbd97be327cc9c4119fb4719c2d384f939eaae07a014121ec21","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\n\nTarget:\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b :=\n\nProof body:\n","rejected":"Here is the proof:\nby cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"6d8bf0d2dcc47dd84e343933d598b89d5d7e2ab0f76d0f19f4d7520db1ced6e1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5ae92dbfddfe819bfac27021f8580f504cd4c2ea6824b19ea7e75584b3176d0d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a7c1840aac08b7c7618ba7412af752fff45612a6f1d11279ea5ad78f222d2002","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7f8f2d49d19fbcf3691e83a8cf398c0ac6cc521fafb9109ebc077a79f1434b69","source_sha256":"0cf246dc3c2cbecf11bebc087d277ba7f05345ab88d2c3bf6b111583252fdecf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩","hard_negative":false,"metrics":{"chosen_tokens":22,"rejected_tokens":26,"token_jaccard":0.833333,"token_length_ratio":1.181818},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"b92c15386cd508f14ba17f4d3815efb3e58d3d2819cfcf60f67f7a4cb86a3104","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Combinatorics.Digraph.Basic\npublic import Mathlib.Combinatorics.SimpleGraph.Basic\n\nNamespace:\nDigraph\n\nLocal context:\n/-\nCopyright (c) 2024 Rida Hamadani. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rida Hamadani\n-/\n/-!\n\n# Graph Orientation\n\nThis module introduces conversion operations between `Digraph`s and `SimpleGraph`s, by forgetting\nthe edge orientations of `Digraph`.\n\n## Main Definitions\n\n- `Digraph.toSimpleGraphInclusive`: Converts a `Digraph` to a `SimpleGraph` by creating an\n undirected edge if either orientation exists in the digraph.\n- `Digraph.toSimpleGraphStrict`: Converts a `Digraph` to a `SimpleGraph` by creating an undirected\n edge only if both orientations exist in the digraph.\n\n## TODO\n\n- Show that there is an isomorphism between loopless complete digraphs and oriented graphs.\n- Define more ways to orient a `SimpleGraph`.\n- Provide lemmas on how `toSimpleGraphInclusive` and `toSimpleGraphStrict` relate to other lattice\n structures on `SimpleGraph`s and `Digraph`s.\n\n## Tags\n\ndigraph, simple graph, oriented graphs\n-/\n\n@[expose] public section\n\nvariable {V : Type*}\n\nnamespace Digraph\n\nsection toSimpleGraph\n\n/-! ### Orientation-forgetting maps on digraphs -/\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\neither orientation is present.\n-/\ndef toSimpleGraphInclusive (G : Digraph V) : SimpleGraph V := SimpleGraph.fromRel G.Adj\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\nboth orientations are present.\n-/\ndef toSimpleGraphStrict (G : Digraph V) : SimpleGraph V where\n Adj v w := v ≠ w ∧ G.Adj v w ∧ G.Adj w v\n\nlemma toSimpleGraphStrict_subgraph_toSimpleGraphInclusive (G : Digraph V) :\n G.toSimpleGraphStrict ≤ G.toSimpleGraphInclusive :=\n fun _ _ h ↦ ⟨h.1, Or.inl h.2.1⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphInclusive_mono : Monotone (toSimpleGraphInclusive : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₂.2.imp (@h₁ _ _) (@h₁ _ _)⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphStrict_mono : Monotone (toSimpleGraphStrict : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₁ h₂.2.1, h₁ h₂.2.2⟩\n\n@[simp]\nlemma toSimpleGraphInclusive_top : (⊤ : Digraph V).toSimpleGraphInclusive = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, Or.inl trivial⟩⟩\n\n@[simp]\n\nTarget:\nlemma toSimpleGraphStrict_top : (⊤ : Digraph V).toSimpleGraphStrict = ⊤ :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Digraph","family_id":"tosimplegraphstrict_top","file_id":"mathlib/Mathlib/Combinatorics/Digraph/Orientation.lean","sample_id":"7f8f2d49d19fbcf3691e83a8cf398c0ac6cc521fafb9109ebc077a79f1434b69"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"88f51ddb8bf50f920612fb0fba6cd209ba21aa09029a7eb34c037af95f86b2e6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2916c0f61a0c6852174e29edd69e2dfe293c585cb0b84d43d10f47d92b6f71fa","source_sha256":"5a346381a7b32deaa54f8cf8c13708605ef18202eb02667b8a6aad13ac97c12f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [treesOfNumNodesEq]\n ext\n simp","hard_negative":false,"metrics":{"chosen_tokens":7,"rejected_tokens":5,"token_jaccard":0.090909,"token_length_ratio":0.714286},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"b95f5f68072e4e4d62c9f6b33414847b52a9d42138f2c372efbec0a25a3de788","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Defs\npublic import Mathlib.Combinatorics.Enumerative.Catalan.Basic\npublic import Mathlib.Data.Finset.NatAntidiagonal\npublic import Mathlib.Data.Nat.Choose.Central\nimport Mathlib.Algebra.BigOperators.Fin\nimport Mathlib.Algebra.BigOperators.NatAntidiagonal\nimport Mathlib.Tactic.Field\n\nNamespace:\nBinaryTree\n\nLocal context:\n/-\nCopyright (c) 2022 Julian Kuelshammer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julian Kuelshammer\n-/\n/-!\n## Main results\n* `treesOfNumNodesEq_card_eq_catalan`: The number of binary trees with `n` internal nodes\n is `catalan n`\n\n-/\n\n@[expose] public section\n\nopen Finset\n\nopen Finset.antidiagonal (fst_le snd_le)\n\nnamespace BinaryTree\n\n/-- Given two finsets, find all trees that can be formed with\n left child in `a` and right child in `b` -/\nabbrev pairwiseNode (a b : Finset (BinaryTree Unit)) : Finset (BinaryTree Unit) :=\n (a ×ˢ b).map ⟨fun x => x.1 △ x.2, fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ => fun h => by simpa using h⟩\n\n/-- A Finset of all trees with `n` nodes. See `mem_treesOfNodesEq` -/\ndef treesOfNumNodesEq : ℕ → Finset (BinaryTree Unit)\n | 0 => {nil}\n | n + 1 =>\n (antidiagonal n).attach.biUnion fun ijh =>\n pairwiseNode (treesOfNumNodesEq ijh.1.1) (treesOfNumNodesEq ijh.1.2)\n decreasing_by\n · simp_wf; have := fst_le ijh.2; lia\n · simp_wf; have := snd_le ijh.2; lia\n\nset_option linter.deprecated false in\n/-- **Alias** of `BinaryTree.treesOfNumNodesEq`. -/\n@[deprecated BinaryTree.treesOfNumNodesEq (since := \"2026-06-07\")]\nabbrev _root_.Tree.treesOfNumNodesEq : ℕ → Finset (Tree Unit) :=\n BinaryTree.treesOfNumNodesEq\n\n@[simp]\ntheorem treesOfNumNodesEq_zero : treesOfNumNodesEq 0 = {nil} := by rw [treesOfNumNodesEq]\n\nTarget:\ntheorem treesOfNumNodesEq_succ (n : ℕ) :\n treesOfNumNodesEq (n + 1) =\n (antidiagonal n).biUnion fun ij =>\n pairwiseNode (treesOfNumNodesEq ij.1) (treesOfNumNodesEq ij.2) :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Enumerative","family_id":"treesofnumnodeseq_succ","file_id":"mathlib/Mathlib/Combinatorics/Enumerative/Catalan/Tree.lean","sample_id":"2916c0f61a0c6852174e29edd69e2dfe293c585cb0b84d43d10f47d92b6f71fa"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"53047500b7c382ff7eb46afaca5559abff17a015ca4956ed5b93309713ab7a37","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ab32576cc1adc558b742b4ad3aa43dc260f4cb46ab4eb75d1944a10bbee4b6d7","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8e52f7e7d4abc1cbadcfeac6b0697214ff0be1711917c1f7f7c52bd06eea013c","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]","hard_negative":true,"metrics":{"chosen_tokens":33,"rejected_tokens":3,"token_jaccard":0.041667,"token_length_ratio":0.090909},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"b99cbeab6c7d8ddd08ef504ff8847c7760bb96c8cba56904e88f7008bc125d7b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nTarget:\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_8e52f7e7d4ab","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5b1c802eddcb2ab73d2d93d39141f792d088b39a64639e57979467fc37d6a8e6","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"8e52f7e7d4abc1cbadcfeac6b0697214ff0be1711917c1f7f7c52bd06eea013c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fc7ffae2f05d47d1966ca2bf59252faf9200a6b414ba1d76553ef9f66ce51aa8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6b0182816ab85d12002a58a45fa6c14113456d5c2543da4146daa190ecc6530f","source_sha256":"d98c949bc540d9d1f0da4b83503468df3afb83ea6b2904bc8e06fc7ecb85d421","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [totallySeparatedSpace_iff, IsTotallySeparated, Set.Pairwise, mem_univ, true_implies]\n refine forall₃_congr fun x y _ ↦\n ⟨fun ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ ↦ ?_, fun ⟨U, hU, Ux, Ucy⟩ ↦ ?_⟩\n · exact ⟨U, isClopen_of_disjoint_cover_open f hU hV disj,\n Ux, fun Uy ↦ Set.disjoint_iff.mp disj ⟨Uy, Vy⟩⟩\n · exact ⟨U, Uᶜ, hU.2, hU.compl.2, Ux, Ucy, (Set.union_compl_self U).ge, disjoint_compl_right⟩","hard_negative":true,"metrics":{"chosen_tokens":123,"rejected_tokens":8,"token_jaccard":0.018519,"token_length_ratio":0.065041},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"b9ed4cfe220329581bdc5fc2ff152bdf624d2e13aeb4b3ed8892316abb84d064","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Connected.Clopen\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Patrick Massot, Yury Kudryashov\n-/\n/-!\n# Totally disconnected and totally separated topological spaces\n\n## Main definitions\nWe define the following properties for sets in a topological space:\n\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 both of these definitions, we also have a class stating that the whole space\nsatisfies that property: `TotallyDisconnectedSpace`, `TotallySeparatedSpace`.\n-/\n\n@[expose] public section\n\nopen Function Set Topology\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v} {ι : Type*} {X : ι → Type*} [TopologicalSpace α]\n {s t u v : Set α}\n\nsection TotallyDisconnected\n\n/-- A set `s` is called totally disconnected if every subset `t ⊆ s` which is preconnected is\na subsingleton, i.e. either empty or a singleton. -/\ndef IsTotallyDisconnected (s : Set α) : Prop :=\n ∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton\n\ntheorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ =>\n (ht x_in).elim\n\ntheorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ =>\n subsingleton_singleton.anti ht\n\n/-- A space is totally disconnected if all of its connected components are singletons. -/\n@[mk_iff]\nclass TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where\n /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/\n isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α)\n\ntheorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α}\n (h : IsPreconnected s) : s.Subsingleton :=\n TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h\n\n-- note: making this an instance breaks downstream files\ntheorem subsingleton_of_preconnected_totallyDisconnected\n [PreconnectedSpace α] [TotallyDisconnectedSpace α] : Subsingleton α :=\n Set.subsingleton_of_univ_subsingleton isPreconnected_univ.subsingleton\n\ninstance Pi.totallyDisconnectedSpace {α : Type*} {β : α → Type*}\n [∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] :\n TotallyDisconnectedSpace (∀ a : α, β a) :=\n ⟨fun t _ h2 =>\n have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a =>\n h2.image (fun x => x a) (continuous_apply a).continuousOn\n fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩\n\ninstance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α]\n [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) :=\n ⟨fun t _ h2 =>\n have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn\n have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn\n fun x hx y hy =>\n Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)\n (H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩\n\ninstance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] :\n TotallyDisconnectedSpace (α ⊕ β) := by\n refine ⟨fun s _ hs => ?_⟩\n obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs\n · exact ht.subsingleton.image _\n · exact ht.subsingleton.image _\n\ninstance [∀ i, TopologicalSpace (X i)] [∀ i, TotallyDisconnectedSpace (X i)] :\n TotallyDisconnectedSpace (Σ i, X i) := by\n refine ⟨fun s _ hs => ?_⟩\n obtain rfl | h := s.eq_empty_or_nonempty\n · exact subsingleton_empty\n · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩\n exact ht.isPreconnected.subsingleton.image _\n\n/-- A space is totally disconnected iff its connected components are subsingletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_subsingleton :\n TotallyDisconnectedSpace α ↔ ∀ x : α, (connectedComponent x).Subsingleton := by\n constructor\n · intro h x\n apply h.1\n · exact subset_univ _\n exact isPreconnected_connectedComponent\n intro h; constructor\n intro s s_sub hs\n rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩)\n · exact subsingleton_empty\n · exact (h x).anti (hs.subset_connectedComponent x_in)\n\n/-- A space is totally disconnected iff its connected components are singletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_singleton :\n TotallyDisconnectedSpace α ↔ ∀ x : α, connectedComponent x = {x} := by\n rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton]\n refine forall_congr' fun x => ?_\n rw [subsingleton_iff_singleton]\n exact mem_connectedComponent\n\n@[simp] theorem connectedComponent_eq_singleton [TotallyDisconnectedSpace α] (x : α) :\n connectedComponent x = {x} :=\n totallyDisconnectedSpace_iff_connectedComponent_singleton.1 ‹_› x\n\n/-- The image of a connected component in a totally disconnected space is a singleton. -/\n@[simp]\ntheorem Continuous.image_connectedComponent_eq_singleton {β : Type*} [TopologicalSpace β]\n [TotallyDisconnectedSpace β] {f : α → β} (h : Continuous f) (a : α) :\n f '' connectedComponent a = {f a} :=\n (Set.subsingleton_iff_singleton <| mem_image_of_mem f mem_connectedComponent).mp\n (isPreconnected_connectedComponent.image f h.continuousOn).subsingleton\n\ntheorem isTotallyDisconnected_of_totallyDisconnectedSpace [TotallyDisconnectedSpace α] (s : Set α) :\n IsTotallyDisconnected s := fun t _ ht =>\n TotallyDisconnectedSpace.isTotallyDisconnected_univ _ t.subset_univ ht\n\nlemma TotallyDisconnectedSpace.eq_of_continuous [TopologicalSpace β]\n [PreconnectedSpace α] [TotallyDisconnectedSpace β] (f : α → β) (hf : Continuous f)\n (i j : α) : f i = f j :=\n (isPreconnected_univ.image f hf.continuousOn).subsingleton ⟨i, trivial, rfl⟩ ⟨j, trivial, rfl⟩\n\n/-- The bijection `C(X, Y) ≃ Y` when `Y` is totally disconnected and `X` is connected. -/\n@[simps! symm_apply_apply]\nnoncomputable def TotallyDisconnectedSpace.continuousMapEquivOfConnectedSpace\n (X Y : Type*) [TopologicalSpace X]\n [TopologicalSpace Y] [TotallyDisconnectedSpace Y] [ConnectedSpace X] :\n C(X, Y) ≃ Y where\n toFun f := f (Classical.arbitrary _)\n invFun y := ⟨fun _ ↦ y, by fun_prop⟩\n left_inv f := ContinuousMap.ext (TotallyDisconnectedSpace.eq_of_continuous _ f.2 _)\n right_inv _ := rfl\n\ntheorem isTotallyDisconnected_of_image [TopologicalSpace β] {f : α → β} (hf : ContinuousOn f s)\n (hf' : Injective f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n fun _t hts ht _x x_in _y y_in =>\n hf' <|\n h _ (image_mono hts) (ht.image f <| hf.mono hts) (mem_image_of_mem f x_in)\n (mem_image_of_mem f y_in)\n\nlemma Topology.IsEmbedding.isTotallyDisconnected [TopologicalSpace β] {f : α → β} {s : Set α}\n (hf : IsEmbedding f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n isTotallyDisconnected_of_image hf.continuous.continuousOn hf.injective h\n\nlemma Topology.IsEmbedding.isTotallyDisconnected_image [TopologicalSpace β] {f : α → β} {s : Set α}\n (hf : IsEmbedding f) : IsTotallyDisconnected (f '' s) ↔ IsTotallyDisconnected s := by\n refine ⟨hf.isTotallyDisconnected, fun hs u hus hu ↦ ?_⟩\n obtain ⟨v, hvs, rfl⟩ : ∃ v, v ⊆ s ∧ f '' v = u :=\n ⟨f ⁻¹' u ∩ s, inter_subset_right, by rwa [image_preimage_inter, inter_eq_left]⟩\n rw [hf.isInducing.isPreconnected_image] at hu\n exact (hs v hvs hu).image _\n\nlemma Topology.IsEmbedding.isTotallyDisconnected_range [TopologicalSpace β] {f : α → β}\n (hf : IsEmbedding f) : IsTotallyDisconnected (range f) ↔ TotallyDisconnectedSpace α := by\n rw [totallyDisconnectedSpace_iff, ← image_univ, hf.isTotallyDisconnected_image]\n\nlemma totallyDisconnectedSpace_subtype_iff {s : Set α} :\n TotallyDisconnectedSpace s ↔ IsTotallyDisconnected s := by\n rw [← IsEmbedding.subtypeVal.isTotallyDisconnected_range, Subtype.range_val]\n\ninstance Subtype.totallyDisconnectedSpace {α : Type*} {p : α → Prop} [TopologicalSpace α]\n [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Subtype p) :=\n totallyDisconnectedSpace_subtype_iff.2 (isTotallyDisconnected_of_totallyDisconnectedSpace _)\n\ninstance [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Additive α) :=\n ‹TotallyDisconnectedSpace α›\n\ninstance [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Multiplicative α) :=\n ‹TotallyDisconnectedSpace α›\n\nend TotallyDisconnected\n\nsection TotallySeparated\n\n/-- A set `s` is called totally separated if any two points of this set can be separated\nby two disjoint open sets covering `s`. -/\ndef IsTotallySeparated (s : Set α) : Prop :=\n Set.Pairwise s fun x y =>\n ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ s ⊆ u ∪ v ∧ Disjoint u v\n\ntheorem isTotallySeparated_empty : IsTotallySeparated (∅ : Set α) := fun _ => False.elim\n\ntheorem isTotallySeparated_singleton {x} : IsTotallySeparated ({x} : Set α) := fun _ hp _ hq hpq =>\n (hpq <| (eq_of_mem_singleton hp).symm ▸ (eq_of_mem_singleton hq).symm).elim\n\ntheorem isTotallyDisconnected_of_isTotallySeparated {s : Set α} (H : IsTotallySeparated s) :\n IsTotallyDisconnected s := by\n intro t hts ht x x_in y y_in\n by_contra h\n obtain\n ⟨u : Set α, v : Set α, hu : IsOpen u, hv : IsOpen v, hxu : x ∈ u, hyv : y ∈ v, hs : s ⊆ u ∪ v,\n huv⟩ :=\n H (hts x_in) (hts y_in) h\n refine (ht _ _ hu hv (hts.trans hs) ⟨x, x_in, hxu⟩ ⟨y, y_in, hyv⟩).ne_empty ?_\n rw [huv.inter_eq, inter_empty]\n\nalias IsTotallySeparated.isTotallyDisconnected := isTotallyDisconnected_of_isTotallySeparated\n\n/-- A space is totally separated if any two points can be separated by two disjoint open sets\ncovering the whole space. -/\n@[mk_iff] class TotallySeparatedSpace (α : Type u) [TopologicalSpace α] : Prop where\n /-- The universal set `Set.univ` in a totally separated space is totally separated. -/\n isTotallySeparated_univ : IsTotallySeparated (univ : Set α)\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.totallyDisconnectedSpace (α : Type u)\n [TopologicalSpace α] [TotallySeparatedSpace α] : TotallyDisconnectedSpace α :=\n ⟨TotallySeparatedSpace.isTotallySeparated_univ.isTotallyDisconnected⟩\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.of_discrete (α : Type*) [TopologicalSpace α]\n [DiscreteTopology α] : TotallySeparatedSpace α :=\n ⟨fun _ _ b _ h => ⟨{b}ᶜ, {b}, isOpen_discrete _, isOpen_discrete _, h, rfl,\n (compl_union_self _).symm.subset, disjoint_compl_left⟩⟩\n\nTarget:\ntheorem totallySeparatedSpace_iff_exists_isClopen {α : Type*} [TopologicalSpace α] :\n TotallySeparatedSpace α ↔ Pairwise (∃ U : Set α, IsClopen U ∧ · ∈ U ∧ · ∈ Uᶜ) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"1b968982ce81b1307989cb947b8468075ff86639a5dc39a537fe114b8a7c2651","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Connected","family_id":"totallyseparatedspace_iff_exists_isclopen","file_id":"mathlib/Mathlib/Topology/Connected/TotallyDisconnected.lean","sample_id":"6b0182816ab85d12002a58a45fa6c14113456d5c2543da4146daa190ecc6530f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"21197415fc76bbeec14284dfe5142af722642f83db976e5754f59667c59834da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c7dba750c2f9a85961ca6220766a4f9406f27c76c7a4e9e1a37f9d66b5fd8cd8","source_sha256":"f94ad482bdf55f9150f7a0c83c1bf04503493ff9c8ec82badf04c9b48a731d5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply Metric.ediam_le\n rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩\n exact hf.edist_le_mul_of_le (Metric.edist_le_ediam_of_mem hx hy)","hard_negative":true,"metrics":{"chosen_tokens":33,"rejected_tokens":8,"token_jaccard":0.037037,"token_length_ratio":0.242424},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"bb1fb0f56b5e77565ecf96d1d02d7be56b63e91b22792a935db56f8478967014","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Tactic.Finiteness\npublic import Mathlib.Topology.EMetricSpace.Diam\n\nNamespace:\nLipschitzWith\n\nLocal context:\n/-\nCopyright (c) 2018 Rohan Mitta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov, Winston Yin\n-/\n/-!\n# Lipschitz continuous functions\n\nA map `f : α → β` between two (extended) metric spaces is called *Lipschitz continuous*\nwith constant `K ≥ 0` if for all `x, y` we have `edist (f x) (f y) ≤ K * edist x y`.\nFor a metric space, the latter inequality is equivalent to `dist (f x) (f y) ≤ K * dist x y`.\nThere is also a version asserting this inequality only for `x` and `y` in some set `s`.\nFinally, `f : α → β` is called *locally Lipschitz continuous* if each `x : α` has a neighbourhood\non which `f` is Lipschitz continuous (with some constant).\n\nIn this file we provide various ways to prove that various combinations of Lipschitz continuous\nfunctions are Lipschitz continuous. We also prove that Lipschitz continuous functions are\nuniformly continuous, and that locally Lipschitz functions are continuous.\n\n## Main definitions and lemmas\n\n* `LipschitzWith K f`: states that `f` is Lipschitz with constant `K : ℝ≥0`\n* `LipschitzOnWith K f s`: states that `f` is Lipschitz with constant `K : ℝ≥0` on a set `s`\n* `LipschitzWith.uniformContinuous`: a Lipschitz function is uniformly continuous\n* `LipschitzOnWith.uniformContinuousOn`: a function which is Lipschitz on a set `s` is uniformly\n continuous on `s`.\n* `LocallyLipschitz f`: states that `f` is locally Lipschitz\n* `LocallyLipschitzOn f s`: states that `f` is locally Lipschitz on `s`.\n* `LocallyLipschitz.continuous`: a locally Lipschitz function is continuous.\n\n\n## Implementation notes\n\nThe parameter `K` has type `ℝ≥0`. This way we avoid conjunction in the definition and have\ncoercions both to `ℝ` and `ℝ≥0∞`. Constructors whose names end with `'` take `K : ℝ` as an\nargument, and return `LipschitzWith (Real.toNNReal K) f`.\n-/\n\n@[expose] public section\n\nuniverse u v w x\n\nopen Filter Function Set Topology NNReal ENNReal Bornology\n\nvariable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x}\n\nsection PseudoEMetricSpace\nvariable [PseudoEMetricSpace α] [PseudoEMetricSpace β] {K : ℝ≥0} {s t : Set α} {f : α → β}\n\n/-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` if for all `x, y`\nwe have `dist (f x) (f y) ≤ K * dist x y`. -/\ndef LipschitzWith (K : ℝ≥0) (f : α → β) := ∀ x y, edist (f x) (f y) ≤ K * edist x y\n\n/-- A function `f` is **Lipschitz continuous** with constant `K ≥ 0` **on `s`** if\nfor all `x, y` in `s` we have `dist (f x) (f y) ≤ K * dist x y`. -/\ndef LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α) :=\n ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → edist (f x) (f y) ≤ K * edist x y\n\n/-- `f : α → β` is called **locally Lipschitz continuous** iff every point `x`\nhas a neighbourhood on which `f` is Lipschitz. -/\ndef LocallyLipschitz (f : α → β) : Prop := ∀ x, ∃ K, ∃ t ∈ 𝓝 x, LipschitzOnWith K f t\n\n/-- `f : α → β` is called **locally Lipschitz continuous** on `s` iff every point `x` of `s`\nhas a neighbourhood within `s` on which `f` is Lipschitz. -/\ndef LocallyLipschitzOn (s : Set α) (f : α → β) : Prop :=\n ∀ ⦃x⦄, x ∈ s → ∃ K, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t\n\n/-- Every function is Lipschitz on the empty set (with any Lipschitz constant). -/\n@[simp]\ntheorem lipschitzOnWith_empty (K : ℝ≥0) (f : α → β) : LipschitzOnWith K f ∅ := fun _ => False.elim\n\n@[simp] lemma locallyLipschitzOn_empty (f : α → β) : LocallyLipschitzOn ∅ f := fun _ ↦ False.elim\n\n/-- Being Lipschitz on a set is monotone w.r.t. that set. -/\ntheorem LipschitzOnWith.mono (hf : LipschitzOnWith K f t) (h : s ⊆ t) : LipschitzOnWith K f s :=\n fun _x x_in _y y_in => hf (h x_in) (h y_in)\n\nlemma LocallyLipschitzOn.mono (hf : LocallyLipschitzOn t f) (h : s ⊆ t) : LocallyLipschitzOn s f :=\n fun x hx ↦ by obtain ⟨K, u, hu, hfu⟩ := hf (h hx); exact ⟨K, u, nhdsWithin_mono _ h hu, hfu⟩\n\n/-- `f` is Lipschitz iff it is Lipschitz on the entire space. -/\n@[simp] lemma lipschitzOnWith_univ : LipschitzOnWith K f univ ↔ LipschitzWith K f := by\n simp [LipschitzOnWith, LipschitzWith]\n\n@[simp] lemma locallyLipschitzOn_univ : LocallyLipschitzOn univ f ↔ LocallyLipschitz f := by\n simp [LocallyLipschitzOn, LocallyLipschitz]\n\nprotected lemma LocallyLipschitz.locallyLipschitzOn (h : LocallyLipschitz f) :\n LocallyLipschitzOn s f := (locallyLipschitzOn_univ.2 h).mono s.subset_univ\n\ntheorem lipschitzOnWith_iff_restrict : LipschitzOnWith K f s ↔ LipschitzWith K (s.restrict f) := by\n simp [LipschitzOnWith, LipschitzWith]\n\nlemma lipschitzOnWith_restrict {t : Set s} :\n LipschitzOnWith K (s.restrict f) t ↔ LipschitzOnWith K f (s ∩ Subtype.val '' t) := by\n simp [LipschitzOnWith]\n\nlemma locallyLipschitzOn_iff_restrict :\n LocallyLipschitzOn s f ↔ LocallyLipschitz (s.restrict f) := by\n simp only [LocallyLipschitzOn, LocallyLipschitz, SetCoe.forall',\n lipschitzOnWith_restrict,\n nhds_subtype_eq_comap_nhdsWithin, mem_comap]\n congr! with x K\n constructor\n · rintro ⟨t, ht, hft⟩\n exact ⟨_, ⟨t, ht, Subset.rfl⟩, hft.mono <| inter_subset_right.trans <| image_preimage_subset ..⟩\n · rintro ⟨t, ⟨u, hu, hut⟩, hft⟩\n exact ⟨s ∩ u, Filter.inter_mem self_mem_nhdsWithin hu,\n hft.mono fun x hx ↦ ⟨hx.1, ⟨x, hx.1⟩, hut hx.2, rfl⟩⟩\n\nalias ⟨LipschitzOnWith.to_restrict, _⟩ := lipschitzOnWith_iff_restrict\nalias ⟨LocallyLipschitzOn.restrict, _⟩ := locallyLipschitzOn_iff_restrict\n\nlemma Set.MapsTo.lipschitzOnWith_iff_restrict {t : Set β} (h : MapsTo f s t) :\n LipschitzOnWith K f s ↔ LipschitzWith K (h.restrict f s t) :=\n _root_.lipschitzOnWith_iff_restrict\n\nalias ⟨LipschitzOnWith.mapsToRestrict, _⟩ := Set.MapsTo.lipschitzOnWith_iff_restrict\n\nend PseudoEMetricSpace\n\nnamespace LipschitzWith\n\nopen Metric\n\nvariable [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]\nvariable {K : ℝ≥0} {f : α → β} {x y : α} {r : ℝ≥0∞} {s : Set α}\n\nprotected theorem lipschitzOnWith (h : LipschitzWith K f) : LipschitzOnWith K f s :=\n fun x _ y _ => h x y\n\ntheorem edist_le_mul (h : LipschitzWith K f) (x y : α) : edist (f x) (f y) ≤ K * edist x y :=\n h x y\n\ntheorem edist_le_mul_of_le (h : LipschitzWith K f) (hr : edist x y ≤ r) :\n edist (f x) (f y) ≤ K * r :=\n (h x y).trans <| mul_right_mono hr\n\ntheorem edist_lt_mul_of_lt (h : LipschitzWith K f) (hK : K ≠ 0) (hr : edist x y < r) :\n edist (f x) (f y) < K * r := by grw [h x y]; gcongr; simp\n\ntheorem mapsTo_closedEBall (h : LipschitzWith K f) (x : α) (r : ℝ≥0∞) :\n MapsTo f (closedEBall x r) (closedEBall (f x) (K * r)) := fun _y hy => h.edist_le_mul_of_le hy\n\n@[deprecated (since := \"2026-01-24\")]\nalias mapsTo_emetric_closedBall := mapsTo_closedEBall\n\ntheorem mapsTo_eball (h : LipschitzWith K f) (hK : K ≠ 0) (x : α) (r : ℝ≥0∞) :\n MapsTo f (eball x r) (eball (f x) (K * r)) := fun _y hy => h.edist_lt_mul_of_lt hK hy\n\n@[deprecated (since := \"2026-01-24\")]\nalias mapsTo_emetric_ball := mapsTo_eball\n\ntheorem edist_lt_top (hf : LipschitzWith K f) {x y : α} (h : edist x y ≠ ⊤) :\n edist (f x) (f y) < ⊤ :=\n (hf x y).trans_lt (by finiteness)\n\ntheorem mul_edist_le (h : LipschitzWith K f) (x y : α) :\n (K⁻¹ : ℝ≥0∞) * edist (f x) (f y) ≤ edist x y := by\n rw [mul_comm, ← div_eq_mul_inv]\n exact ENNReal.div_le_of_le_mul' (h x y)\n\nprotected theorem of_edist_le (h : ∀ x y, edist (f x) (f y) ≤ edist x y) : LipschitzWith 1 f :=\n fun x y => by simp only [ENNReal.coe_one, one_mul, h]\n\nprotected theorem weaken (hf : LipschitzWith K f) {K' : ℝ≥0} (h : K ≤ K') : LipschitzWith K' f :=\n fun x y => le_trans (hf x y) <| mul_left_mono (ENNReal.coe_le_coe.2 h)\n\nTarget:\ntheorem ediam_image_le (hf : LipschitzWith K f) (s : Set α) :\n Metric.ediam (f '' s) ≤ K * Metric.ediam s :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"51f91635bec3251450a60019a2e4654657351dbfceaad8722dc646fde4125477","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/EMetricSpace","family_id":"ediam_image_le","file_id":"mathlib/Mathlib/Topology/EMetricSpace/Lipschitz.lean","sample_id":"c7dba750c2f9a85961ca6220766a4f9406f27c76c7a4e9e1a37f9d66b5fd8cd8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"231a4fe1e7c61172050d8b87bed8974d73dadd010c40cdb5e1b8e39c59ac51d7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"88db50bd0c653dbad4697b31fe743baecf1e056ade12422f5984075c4bb4e009","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ef599e1e0926b4f16624577efbb1326a2099c7624b75050a46a0bf43275bdd76","source_sha256":"c30a3d4b1c42fcb7d8e6bf63ba23497757e589a03ca883e3c4dcb6c17db24a2c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext <;> simp [mapIsometry, DeloneSet.copy]","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":5,"token_jaccard":0.125,"token_length_ratio":0.384615},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"bb88dd368744791f668a9694facdfad266603f41b1ac20b824d81da0a1b9dade","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.MetricSpace.Cover\n\nNamespace:\nDelone.DeloneSet\n\nLocal context:\n/-\nCopyright (c) 2026 Newell Jensen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Newell Jensen\n-/\n/-!\n# Delone sets\n\nA **Delone set** `D ⊆ X` in a metric space is a set which is both:\n\n* **Uniformly Discrete**: there exists `packingRadius > 0` such that distinct points of `D`\n are separated by a distance strictly greater than `packingRadius`;\n* **Relatively Dense**: there exists `coveringRadius > 0` such that every point of `X`\n lies within distance `coveringRadius` of some point of `D`.\n\nThe `DeloneSet` structure stores the set together with explicit radii witnessing\nthese properties. The definitions use metric entourages so that the theory fits\nnaturally into the uniformity framework.\n\nDelone sets appear in discrete geometry, crystallography, aperiodic order, and tiling theory.\n\n## Main definitions\n\n* `Delone.DeloneSet X`: The main structure representing a Delone set in a metric space `X`.\n* `DeloneSet.mapBilipschitz`: Transports a Delone set along a bilipschitz equivalence,\n scaling the radii.\n* `DeloneSet.mapIsometry` Preserves the packing and covering radii exactly.\n\n## Basic properties\n\n* `packingRadius_lt_dist_of_mem_ne` : Distinct points in a Delone set are further apart than\n the packing radius.\n* `exists_dist_le_coveringRadius` : Every point of the space lies within the covering radius\n of the set.\n* `subset_ball_singleton` : Any ball of sufficiently small radius contains at most one point of\n the set.\n\n## Implementation notes\n\n* **Bundled Structure**: `DeloneSet` is bundled as a structure rather than a predicate\n (e.g., `IsDelone`). This facilitates dynamical systems constructions like hulls and patches by\n ensuring operations automatically preserve the required properties, eliminating the need to\n manually pass around proofs that the set remains Delone.\n* **Explicit Data**: Since radii are stored as explicit data, the map from `DeloneSet X` to `Set X`\n is not injective. We provide a `Membership` instance and `mem_carrier` to allow the convenience\n of `∈` notation while ensuring radii remain bundled, computationally accessible, and tracked by\n extensionality.\n-/\n\n@[expose] public section\n\nopen Metric\nopen scoped NNReal\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nnamespace Delone\n\n/-- A **Delone set** consists of a set together with explicit radii\nwitnessing uniform discreteness and relative denseness. -/\n@[ext]\nstructure DeloneSet (X : Type*) [MetricSpace X] where\n /-- The underlying set. -/\n carrier : Set X\n /-- Radius such that distinct points of `carrier` are separated by more than `r`. -/\n packingRadius : ℝ≥0\n packingRadius_pos : 0 < packingRadius\n isSeparated_packingRadius : IsSeparated packingRadius carrier\n /-- Radius such that every point of the space is within `R` of `carrier`. -/\n coveringRadius : ℝ≥0\n coveringRadius_pos : 0 < coveringRadius\n isCover_coveringRadius : IsCover coveringRadius .univ carrier\n\nnamespace DeloneSet\n\n/-- The underlying set of points of a Delone set. -/\n@[coe] def toSet (D : DeloneSet X) : Set X := D.carrier\n\ninstance : Coe (DeloneSet X) (Set X) where\n coe := DeloneSet.toSet\n\ninstance : Membership X (DeloneSet X) where\n mem D x := x ∈ (D : Set X)\n\n@[simp, norm_cast]\nlemma mem_coe {D : DeloneSet X} {x : X} : x ∈ (D : Set X) ↔ x ∈ D := .rfl\n\n@[simp] lemma mem_carrier {D : DeloneSet X} {x : X} :\n x ∈ D.carrier ↔ x ∈ D := .rfl\n\nlemma nonempty [Nonempty X] (D : DeloneSet X) : (D : Set X).Nonempty :=\n D.isCover_coveringRadius.nonempty Set.univ_nonempty\n\n/-- Copy of a Delone set with new fields equal to the old ones.\nUseful to fix definitional equalities. -/\nprotected def copy (D : DeloneSet X) (carrier : Set X) (packingRadius coveringRadius : ℝ≥0)\n (h_carrier : carrier = D.carrier) (h_packing : packingRadius = D.packingRadius)\n (h_covering : coveringRadius = D.coveringRadius) :\n DeloneSet X where\n carrier := carrier\n packingRadius := packingRadius\n packingRadius_pos := by simpa [h_packing] using D.packingRadius_pos\n isSeparated_packingRadius := by\n simpa [h_carrier, h_packing] using D.isSeparated_packingRadius\n coveringRadius := coveringRadius\n coveringRadius_pos := by simpa [h_covering] using D.coveringRadius_pos\n isCover_coveringRadius := by\n simpa [h_carrier, h_covering] using D.isCover_coveringRadius\n\ntheorem copy_eq (D : DeloneSet X)\n (carrier packingRadius coveringRadius h_carrier h_packing h_covering) :\n D.copy carrier packingRadius coveringRadius h_carrier h_packing h_covering = D :=\n DeloneSet.ext h_carrier h_packing h_covering\n\nlemma packingRadius_lt_dist_of_mem_ne (D : DeloneSet X) {x y : X}\n (hx : x ∈ D) (hy : y ∈ D) (hne : x ≠ y) :\n D.packingRadius < dist x y := by\n have hsep : ENNReal.ofReal D.packingRadius < ENNReal.ofReal (dist x y) := by\n simpa [edist_dist] using D.isSeparated_packingRadius hx hy hne\n exact (ENNReal.ofReal_lt_ofReal_iff (h := dist_pos.mpr hne)).1 hsep\n\nlemma exists_dist_le_coveringRadius (D : DeloneSet X) (x : X) :\n ∃ y ∈ D, dist x y ≤ D.coveringRadius := by\n obtain ⟨y, hy, hdist⟩ := D.isCover_coveringRadius (x := x) (by trivial)\n exact ⟨y, hy, by simpa [edist_dist] using hdist⟩\n\nlemma eq_of_mem_ball (D : DeloneSet X) {r : ℝ≥0} (hr : r ≤ D.packingRadius / 2)\n {x y z : X} (hx : x ∈ D) (hy : y ∈ D) (hxz : x ∈ ball z r) (hyz : y ∈ ball z r) :\n x = y := by\n by_contra hne\n exact (D.packingRadius_lt_dist_of_mem_ne hx hy hne).not_gt <| calc\n dist x y ≤ dist x z + dist y z := dist_triangle_right x y z\n _ < r + r := by gcongr <;> simpa\n _ ≤ D.packingRadius := by rw [← add_halves D.packingRadius, NNReal.coe_add]; gcongr\n\n/-- There exists a radius `r > 0` such that any ball of radius `r`\ncentered at a point of `D` contains at most one point of `D`. -/\nlemma subset_ball_singleton (D : DeloneSet X) :\n ∃ r > 0, ∀ {x y z}, x ∈ D → y ∈ D → x ∈ ball z r → y ∈ ball z r → x = y :=\n ⟨D.packingRadius / 2, half_pos D.packingRadius_pos, fun hx hy => D.eq_of_mem_ball le_rfl hx hy⟩\n\n/-- Bilipschitz maps send Delone sets to Delone sets. -/\n@[simps]\nnoncomputable def mapBilipschitz (f : X ≃ Y) (K₁ K₂ : ℝ≥0) (hK₁ : 0 < K₁) (hK₂ : 0 < K₂)\n (hf₁ : AntilipschitzWith K₁ f) (hf₂ : LipschitzWith K₂ f) (D : DeloneSet X) : DeloneSet Y where\n carrier := f '' D.carrier\n packingRadius := D.packingRadius / K₁\n packingRadius_pos := div_pos D.packingRadius_pos hK₁\n isSeparated_packingRadius := D.isSeparated_packingRadius.image_antilipschitz hf₁ hK₁\n coveringRadius := K₂ * D.coveringRadius\n coveringRadius_pos := mul_pos hK₂ D.coveringRadius_pos\n isCover_coveringRadius := D.isCover_coveringRadius.image_lipschitz_of_surjective hf₂ f.surjective\n\n@[simp] lemma mapBilipschitz_refl (D : DeloneSet X) (hK1 hK2 hA hL) :\n D.mapBilipschitz (.refl X) 1 1 hK1 hK2 hA hL = D := by\n ext <;> simp only [mapBilipschitz, Equiv.refl_apply, Set.image_id', div_one, one_mul]\n\nlemma mapBilipschitz_trans {Z : Type*} [MetricSpace Z] (D : DeloneSet X)\n (f : X ≃ Y) (g : Y ≃ Z) (K₁f K₂f K₁g K₂g : ℝ≥0)\n (hf₁_pos : 0 < K₁f) (hf₂_pos : 0 < K₂f)\n (hg₁_pos : 0 < K₁g) (hg₂_pos : 0 < K₂g)\n (hf_anti : AntilipschitzWith K₁f f) (hf_lip : LipschitzWith K₂f f)\n (hg_anti : AntilipschitzWith K₁g g) (hg_lip : LipschitzWith K₂g g) :\n (D.mapBilipschitz f K₁f K₂f hf₁_pos hf₂_pos hf_anti hf_lip).mapBilipschitz\n g K₁g K₂g hg₁_pos hg₂_pos hg_anti hg_lip =\n D.mapBilipschitz (f.trans g) (K₁f * K₁g) (K₂g * K₂f)\n (mul_pos hf₁_pos hg₁_pos) (mul_pos hg₂_pos hf₂_pos)\n (hg_anti.comp hf_anti) (hg_lip.comp hf_lip) := by\n ext\n · simp only [mapBilipschitz_carrier, Equiv.trans_apply, Set.mem_image]\n exact exists_exists_and_eq_and\n · simp only [mapBilipschitz_packingRadius, NNReal.coe_div, div_div]\n · simp only [mapBilipschitz_coveringRadius, NNReal.coe_mul, mul_assoc]\n\n/-- The image of a Delone set under an isometry. This is a specialization of\n`DeloneSet.mapBilipschitz` where the packing and covering radii are preserved because the\nLipschitz constants are both 1. -/\n@[simps!]\nnoncomputable def mapIsometry (f : X ≃ᵢ Y) : DeloneSet X ≃ DeloneSet Y where\n toFun D := (D.mapBilipschitz f.toEquiv 1 1 zero_lt_one zero_lt_one\n f.isometry.antilipschitz f.isometry.lipschitz).copy (f '' D.carrier)\n D.packingRadius D.coveringRadius rfl (by simp [mapBilipschitz]) (by simp [mapBilipschitz])\n invFun D := (D.mapBilipschitz f.symm.toEquiv 1 1 zero_lt_one zero_lt_one\n f.symm.isometry.antilipschitz f.symm.isometry.lipschitz).copy (f.symm '' D.carrier)\n D.packingRadius D.coveringRadius rfl (by simp [mapBilipschitz]) (by simp [mapBilipschitz])\n left_inv D := by ext <;> simp [copy_eq]\n right_inv D := by ext <;> simp [copy_eq]\n\n@[simp] lemma mapIsometry_refl (D : DeloneSet X) : D.mapIsometry (.refl X) = D := by\n ext <;> simp [mapIsometry, IsometryEquiv.refl, DeloneSet.copy]\n\nlemma mapIsometry_symm (f : X ≃ᵢ Y) : (mapIsometry f).symm = mapIsometry f.symm := rfl\n\nTarget:\nlemma mapIsometry_trans {Z : Type*} [MetricSpace Z] (D : DeloneSet X) (f : X ≃ᵢ Y) (g : Y ≃ᵢ Z) :\n D.mapIsometry (f.trans g) = (D.mapIsometry f).mapIsometry g :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_ef599e1e0926","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"ba1603a40eb472e145043a99c852b0c5cb6e844586512e64a8f86c4b64e6ec58","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/AperiodicOrder","family_id":"mapisometry_trans","file_id":"mathlib/Mathlib/Analysis/AperiodicOrder/Delone/Basic.lean","sample_id":"ef599e1e0926b4f16624577efbb1326a2099c7624b75050a46a0bf43275bdd76"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1b90a250e54b92951ccc4d61111ac3f46abf97a771520f182d61738db8a90ab9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f873967d9b90e90dcdb09dd23995c71c99fed1808275d0e0d3cd37474d136213","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fcf5cfabac742406d5ab6acc96e0b5d1aa34978258a92e717b9ce21022ce8ba3","source_sha256":"4b78d0cacf95758052e21397c90cec6d556c443e38295ccd9ec4e6362c99bb6e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let Ω : Type u := AlgebraicClosure K\n let g : Spec (.of Ω) ⟶ Spec (.of K) := Spec.map (CommRingCat.ofHom <| algebraMap K Ω)\n apply MorphismProperty.of_pullback_snd_of_descendsAlong\n (Q := @Surjective ⊓ @Flat ⊓ @QuasiCompact) (g := g)\n · exact ⟨⟨inferInstance, inferInstance⟩, inferInstance⟩\n · let : GrpObj (Over.mk (Limits.pullback.snd f g)) := Over.grpObjMkPullbackSnd\n exact smooth_of_grpObj_of_isAlgClosed _","hard_negative":false,"metrics":{"chosen_tokens":96,"rejected_tokens":101,"token_jaccard":0.921569,"token_length_ratio":1.052083},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"bbb59522a890e88c18d08ea8547ba59b218accad6b3aedf7cb24e0c9ede38a93","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.AlgClosed.Basic\npublic import Mathlib.AlgebraicGeometry.Morphisms.LocalFlatDescent\npublic import Mathlib.AlgebraicGeometry.Geometrically.Reduced\npublic import Mathlib.CategoryTheory.Monoidal.Grp\n\nNamespace:\nAlgebraicGeometry\n\nLocal context:\n/-\nCopyright (c) 2026 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# Smoothness of group schemes\n\n## Main results\n- `AlgebraicGeometry.smooth_of_grpObj`:\n If `G` is a group scheme over a field `k` that is geometrically reduced and locally\n of finite type, then `G` is smooth over `k`.\n-/\n\npublic section\n\nopen CategoryTheory\n\nnamespace AlgebraicGeometry\n\nuniverse u\n\nvariable {K : Type u} [Field K] {G : Scheme} (f : G ⟶ Spec (.of K))\n [LocallyOfFiniteType f] [GrpObj (Over.mk f)]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nopen MonObj MonoidalCategory CartesianMonoidalCategory in\n/--\nIf `G` is a group scheme over an algebraically closed field `k` that is reduced and locally\nof finite type, then `G` is smooth over `k`.\n-/\nprivate lemma smooth_of_grpObj_of_isAlgClosed [IsReduced G] [IsAlgClosed K] : Smooth f := by\n have := LocallyOfFiniteType.jacobsonSpace f\n have : Nonempty G := ⟨η[Over.mk f].1 (IsLocalRing.closedPoint _)⟩\n rw [← Scheme.Hom.smoothLocus_eq_top_iff, ← TopologicalSpace.Opens.coe_eq_univ,\n ← not_ne_iff, ← Set.nonempty_compl]\n intro H\n obtain ⟨x, hx, hxc⟩ :=\n nonempty_inter_closedPoints H f.smoothLocus.2.isClosed_compl.isLocallyClosed\n obtain ⟨y, hy : y ∈ f.smoothLocus, hyc⟩ := nonempty_inter_closedPoints\n f.dense_smoothLocus_of_perfectField.nonempty f.smoothLocus.2.isLocallyClosed\n let x' : 𝟙_ _ ⟶ Over.mk f := Over.homMk _ ((pointEquivClosedPoint f).symm ⟨x, hxc⟩).2\n let y' : 𝟙_ _ ⟶ Over.mk f := Over.homMk _ ((pointEquivClosedPoint f).symm ⟨y, hyc⟩).2\n let α := (GrpObj.mulRight (A := Over.mk f) x').symm ≪≫\n (GrpObj.mulRight (A := Over.mk f) y')\n have hα : x' ≫ α.hom = y' := by\n dsimp only [Iso.trans_hom, Iso.symm_hom, α]\n rw [← Category.assoc, ← Iso.eq_comp_inv]\n simp [comp_lift_assoc]\n have hα' : α.hom.left x = y := by\n simpa [x', y', pointEquivClosedPoint] using congr(($hα).left (IsLocalRing.closedPoint K))\n rw! [← hα', ← α.hom.left.mem_preimage, Scheme.Hom.preimage_smoothLocus_eq,\n show α.hom.left ≫ f = f from α.hom.w] at hy\n exact hx hy\n\nTarget:\nlemma smooth_of_grpObj [GeometricallyReduced f] : Smooth f :=\n\nProof body:\n","rejected":"by\n let Ω : Type u := AlgebraicClosure K\n let g : Spec (.of Ω) ⟶ Spec (.of K) := Spec.map (CommRingCat.ofHom <| algebraMap K Ω)\n apply MorphismProperty.of_pullback_snd_of_descendsAlong\n (Q := @Surjective ⊓ @Flat ⊓ @QuasiCompact) (g := g)\n · exact ⟨⟨inferInstance, inferInstance⟩, inferInstance⟩\n · let : GrpObj (Over.mk (Limits.pullback.snd f g)) := Over.grpObjMkPullbackSnd\n exact smooth_of_grpObj_of_isAlgClosed _\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Group","family_id":"smooth_of_grpobj","file_id":"mathlib/Mathlib/AlgebraicGeometry/Group/Smooth.lean","sample_id":"fcf5cfabac742406d5ab6acc96e0b5d1aa34978258a92e717b9ce21022ce8ba3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5baa8fd8d5b48b149bf21a6d58219128080c5e1ffeb44f557218583cce3b249b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9924b14e596b2478e18d8d3a8db493d39e893e432df655d49ca742b3dc936c54","source_sha256":"0b42aa0f0b2580e1dee118f374ef5324e4aee9624b44ec312c1fe8242e99f19b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← f.symm_symm, ← image_eq_preimage_symm, isLUB_image]","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.230769},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"bc0dc015dd07668a95fb9e6fafa271fa977c2632b1943de2783b936a5b48df2a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Bounds.Image\npublic import Mathlib.Order.Hom.Set\n\nNamespace:\nOrderIso\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov\n-/\n/-!\n# Order isomorphisms and bounds.\n-/\n\npublic section\n\nopen Set\n\nnamespace OrderIso\n\nvariable {α β : Type*} [Preorder α] [Preorder β] (f : α ≃o β)\n\ntheorem upperBounds_image {s : Set α} : upperBounds (f '' s) = f '' upperBounds s :=\n Subset.antisymm\n (fun x hx =>\n ⟨f.symm x, fun _ hy => f.le_symm_apply.2 (hx <| mem_image_of_mem _ hy), f.apply_symm_apply x⟩)\n f.monotone.image_upperBounds_subset_upperBounds_image\n\ntheorem lowerBounds_image {s : Set α} : lowerBounds (f '' s) = f '' lowerBounds s :=\n @upperBounds_image αᵒᵈ βᵒᵈ _ _ f.dual _\n\n@[simp]\ntheorem isLUB_image {s : Set α} {x : β} : IsLUB (f '' s) x ↔ IsLUB s (f.symm x) :=\n ⟨fun h => IsLUB.of_image (by simp) ((f.apply_symm_apply x).symm ▸ h), fun h =>\n (IsLUB.of_image (by simp)) <| (f.symm_image_image s).symm ▸ h⟩\n\ntheorem isLUB_image' {s : Set α} {x : α} : IsLUB (f '' s) (f x) ↔ IsLUB s x := by\n rw [isLUB_image, f.symm_apply_apply]\n\n@[simp]\ntheorem isGLB_image {s : Set α} {x : β} : IsGLB (f '' s) x ↔ IsGLB s (f.symm x) :=\n f.dual.isLUB_image\n\ntheorem isGLB_image' {s : Set α} {x : α} : IsGLB (f '' s) (f x) ↔ IsGLB s x :=\n f.dual.isLUB_image'\n\n@[simp]\n\nTarget:\ntheorem isLUB_preimage {s : Set β} {x : α} : IsLUB (f ⁻¹' s) x ↔ IsLUB s (f x) :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Bounds","family_id":"islub_preimage","file_id":"mathlib/Mathlib/Order/Bounds/OrderIso.lean","sample_id":"9924b14e596b2478e18d8d3a8db493d39e893e432df655d49ca742b3dc936c54"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b2b45bfa4e251883ab7a5e0cbd8618eb6f23a0fac262eba0c4598d338a105687","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"8a5d0605f070530e8fe29d227dc8928737b42c2f0e723773cdf6dd97d148b646","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"24c06f9821ae0c44026381d19c9a7d6637451f360d79555039e9eed1830bf721","source_sha256":"b902977d92fdb60e75262beb7f7dae55dab7502621bf1ab6ee39012ed97a51a9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases e\n cases e'\n subst h\n rfl","hard_negative":true,"metrics":{"chosen_tokens":8,"rejected_tokens":5,"token_jaccard":0.090909,"token_length_ratio":0.625},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"bc300c5a8ff7855c0e55366fe678480868a1812e7bbc12f008f2131e156656f4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.Category.Preorder\npublic import Mathlib.CategoryTheory.Functor.Category\npublic import Mathlib.CategoryTheory.Types.Basic\npublic import Mathlib.Order.SuccPred.Limit\n\nNamespace:\nCategoryTheory.Functor.WellOrderInductionData.Extension\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Limits of inverse systems indexed by well-ordered types\n\nGiven a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type,\nwe introduce a structure `F.WellOrderInductionData` which allows\nto show that the map `F.sections → F.obj (op ⊥)` is surjective.\n\nThe data and properties in `F.WellOrderInductionData` consist of a\nsection to the maps `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal,\nand, when `j` is limit, a section to the canonical map from `F.obj (op j)`\nto the type of compatible families of elements in `F.obj (op i)` for `i < j`.\n\nIn other words, from `val₀ : F.obj (op ⊥)`, a term `d : F.WellOrderInductionData`\nallows the construction, by transfinite induction, of a section of `F`\nwhich restricts to `val₀`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nnamespace CategoryTheory\n\nopen Opposite\n\nnamespace Functor\n\nvariable {J : Type u} [LinearOrder J] [SuccOrder J] (F : Jᵒᵖ ⥤ Type v)\n\n/-- Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type, this data\nallows to construct a section of `F` from an element in `F.obj (op ⊥)`,\nsee `WellOrderInductionData.sectionsMk`. -/\nstructure WellOrderInductionData where\n /-- A section `F.obj (op j) → F.obj (op (Order.succ j))` to the restriction\n `F.obj (op (Order.succ j)) → F.obj (op j)` when `j` is not maximal. -/\n succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) : F.obj (op (Order.succ j))\n map_succ (j : J) (hj : ¬IsMax j) (x : F.obj (op j)) :\n F.map (homOfLE (Order.le_succ j)).op (succ j hj x) = x\n /-- When `j` is a limit element, and `x` is a compatible family of elements\n in `F.obj (op i)` for all `i < j`, this is a lifting to `F.obj (op j)`. -/\n lift (j : J) (hj : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections) :\n F.obj (op j)\n map_lift (j : J) (hj : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections)\n (i : J) (hi : i < j) :\n F.map (homOfLE hi.le).op (lift j hj x) = x.val (op ⟨i, hi⟩)\n\nnamespace WellOrderInductionData\n\nvariable {F} in\n/-- Given a functor `F : Jᵒᵖ ⥤ Type v` where `J` is a well-ordered type,\nthis is a constructor for `F.WellOrderInductionData` which does not take\ndata as inputs but proofs of the existence of certain elements. -/\nnoncomputable def ofExists\n (h₁ : ∀ (j : J) (_ : ¬IsMax j), Function.Surjective (F.map (homOfLE (Order.le_succ j)).op))\n (h₂ : ∀ (j : J) (_ : Order.IsSuccLimit j)\n (x : ((OrderHom.Subtype.val (· ∈ Set.Iio j)).monotone.functor.op ⋙ F).sections),\n ∃ (y : F.obj (op j)), ∀ (i : J) (hi : i < j),\n F.map (homOfLE hi.le).op y = x.val (op ⟨i, hi⟩)) :\n F.WellOrderInductionData where\n succ j hj x := (h₁ j hj x).choose\n map_succ j hj x := (h₁ j hj x).choose_spec\n lift j hj x := (h₂ j hj x).choose\n map_lift j hj x := (h₂ j hj x).choose_spec\n\nvariable {F} (d : F.WellOrderInductionData) [OrderBot J]\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n/-- Given `d : F.WellOrderInductionData`, `val₀ : F.obj (op ⊥)` and `j : J`,\nthis is the data of an element `val : F.obj (op j)` such that the induced\ncompatible family of elements in all `F.obj (op i)` for `i ≤ j`\nis determined by `val₀` and the choice of \"liftings\" given by `d`. -/\nstructure Extension (val₀ : F.obj (op ⊥)) (j : J) where\n /-- An element in `F.obj (op j)`, which, by restriction, induces elements\n in `F.obj (op i)` for all `i ≤ j`. -/\n val : F.obj (op j)\n map_zero : F.map (homOfLE bot_le).op val = val₀\n map_succ (i : J) (hi : i < j) :\n F.map (homOfLE (Order.succ_le_of_lt hi)).op val =\n d.succ i (not_isMax_iff.2 ⟨_, hi⟩) (F.map (homOfLE hi.le).op val)\n map_limit (i : J) (hi : Order.IsSuccLimit i) (hij : i ≤ j) :\n F.map (homOfLE hij).op val = d.lift i hi\n { val := fun ⟨⟨k, hk⟩⟩ ↦ F.map (homOfLE (hk.le.trans hij)).op val\n property := fun f ↦ by\n dsimp\n rw [← comp_apply, ← map_comp]\n rfl }\n\nnamespace Extension\n\nvariable {d} {val₀ : F.obj (op ⊥)}\n\n/-- An element in `d.Extension val₀ j` induces an element in `d.Extension val₀ i` when `i ≤ j`. -/\n@[simps]\ndef ofLE {j : J} (e : d.Extension val₀ j) {i : J} (hij : i ≤ j) : d.Extension val₀ i where\n val := F.map (homOfLE hij).op e.val\n map_zero := by\n rw [← comp_apply, ← map_comp]\n exact e.map_zero\n map_succ k hk := by\n rw [← comp_apply, ← map_comp, ← comp_apply, ← map_comp, ← op_comp, ← op_comp,\n homOfLE_comp, homOfLE_comp, e.map_succ k (lt_of_lt_of_le hk hij)]\n map_limit k hk hki := by\n rw [← comp_apply, ← map_comp, ← op_comp, homOfLE_comp,\n e.map_limit k hk (hki.trans hij)]\n congr\n ext ⟨l, hl⟩\n dsimp\n rw [← comp_apply, ← map_comp]\n rfl\n\nTarget:\nlemma val_injective {j : J} {e e' : d.Extension val₀ j} (h : e.val = e'.val) : e = e' :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_24c06f9821ae","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"1c4e0fb41e9191213b664aa6f30e1b10c0195bbf40bc47ba5e37fcaeabeaff77","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/SmallObject","family_id":"val_injective","file_id":"mathlib/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean","sample_id":"24c06f9821ae0c44026381d19c9a7d6637451f360d79555039e9eed1830bf721"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c948dce754d3463b63a73429781f379aa3b9b65e762651599ad88f0a6126a01","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa5d4ad8febc8ad6e8efc1d3b2fd172be63dca9ff05addec42710c7264a10137","source_sha256":"06aa772ac819c87b4401e8808cdb88bbb268afd121d0dfd2be4cac60857bbb95","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext x\n simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, Set.mem_sdiff,\n mem_singleton_iff, mem_ball, Real.dist_eq, and_comm]","hard_negative":true,"metrics":{"chosen_tokens":30,"rejected_tokens":8,"token_jaccard":0.037037,"token_length_ratio":0.266667},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"bcecf35d163d049afb79e47e493b5c6af512e41787817b297ca838fe1918b806","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.Transcendental.Liouville.Basic\npublic import Mathlib.Topology.Baire.Lemmas\npublic import Mathlib.Topology.Baire.LocallyCompactRegular\npublic import Mathlib.Topology.Instances.Irrational\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n# Density of Liouville numbers\n\nIn this file we prove that the set of Liouville numbers form a dense `Gδ` set. We also prove a\nsimilar statement about irrational numbers.\n-/\n\npublic section\n\n\nopen scoped Filter\n\nopen Filter Set Metric\n\nTarget:\ntheorem setOf_liouville_eq_iInter_iUnion :\n { x | Liouville x } =\n ⋂ n : ℕ, ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b),\n ball ((a : ℝ) / b) (1 / (b : ℝ) ^ n) \\ {(a : ℝ) / b} :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"4fa860c6203ebb5cd4c4459db450bf3d5732ff3dc4d07523bdd9fbea148bd2c4","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Transcendental","family_id":"setof_liouville_eq_iinter_iunion","file_id":"mathlib/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean","sample_id":"fa5d4ad8febc8ad6e8efc1d3b2fd172be63dca9ff05addec42710c7264a10137"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8a84c81913dd9ed876efa9df2ecaec5ab37a508ba6133e7e130e79a418fc0c5c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"61e75a249a638ada3f782b98aaadd5dea945d8ca66b12dc795c3f9865de45029","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"333195ce4a4964559d747a2db00ae4e4744155206df3c15c00afa3023ea766d8","source_sha256":"1ea87511faa4a09576c2d6c82d012e31d7cfe664d9616e16ba1fd01753abb77e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases mk_surjective m with ⟨x, rfl⟩\n induction x using FreeMonoid.inductionOn' with\n | one => exact one\n | mul_of x xs ih =>\n cases x with\n | inl m => simpa using inl_mul m _ ih\n | inr n => simpa using inr_mul n _ ih","hard_negative":true,"metrics":{"chosen_tokens":51,"rejected_tokens":5,"token_jaccard":0.09375,"token_length_ratio":0.098039},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"be8e40196fb3a0e7d337058946415dc2106a5fce6c5afafd5ef24a50f5a3718e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.PUnit\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.Algebra.Group.Submonoid.Membership\npublic import Mathlib.GroupTheory.Congruence.Basic\n\nNamespace:\nMonoid.Coprod\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Coproduct (free product) of two monoids or groups\n\nIn this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)\nto be the coproduct (a.k.a. free product) of two monoids.\nThe same type is used for the coproduct of two monoids and for the coproduct of two groups.\n\nThe coproduct `M ∗ N` has the following universal property:\nfor any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,\nthere exists a unique homomorphism `fg : M ∗ N →* P`\nsuch that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,\nwhere `Monoid.Coprod.inl : M →* M ∗ N`\nand `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.\nThis homomorphism `fg` is given by `Monoid.Coprod.lift f g`.\n\nWe also define some homomorphisms and isomorphisms about `M ∗ N`,\nand provide additive versions of all definitions and theorems.\n\n## Main definitions\n\n### Types\n\n* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):\n the free product (a.k.a. coproduct) of two monoids `M` and `N`.\n* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.\n\nIn other sections, we only list multiplicative definitions.\n\n### Instances\n\n* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.\n\n### Monoid homomorphisms\n\n* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.\n\n* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.\n\n* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`\n from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.\n\n* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`\n that allows the user to control the computational behavior.\n\n* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`\n into `M ∗ M' →* N ∗ N'`.\n\n* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.\n\n* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:\n natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.\n\n### Monoid isomorphisms\n\n* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.\n* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.\n* `MulEquiv.coprodAssoc`: associativity of the coproduct.\n* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:\n free product by `PUnit` on the left or on the right is isomorphic to the original monoid.\n\n## Main results\n\nThe universal property of the coproduct\nis given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.\n\nWe also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`\nfor homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.\n\n## Implementation details\n\nThe definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.\nWhile mathematically `M ∗ N` is a particular case\nof the coproduct of an indexed family of monoids,\nit is easier to build API from scratch instead of using something like\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI ![M, N]\n```\n\nor\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)\n```\n\nThere are several reasons to build an API from scratch.\n\n- API about `Con` makes it easy to define the required type and prove the universal property,\n so there is little overhead compared to transferring API from `Monoid.CoprodI`.\n- If `M` and `N` live in different universes, then the definition has to add `ULift`s;\n this makes it harder to transfer API and definitions.\n- As of now, we have no way\n to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`\n from `[Monoid M]` and `[Monoid N]`,\n not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.\n- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`\n as the underlying type makes it possible to write computationally effective code\n (though this point is not tested yet).\n\n## TODO\n\n- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and\n `Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.\n\n## Tags\n\ngroup, monoid, coproduct, free product\n-/\n\n@[expose] public section\n\nassert_not_exists MonoidWithZero\n\nopen FreeMonoid Function List Set\n\nnamespace Monoid\n\n/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`\nsuch that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms\nto the quotient by `c`. -/\n@[to_additive /-- The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`\nsuch that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`\nare additive monoid homomorphisms to the quotient by `c`. -/]\ndef coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=\n sInf {c |\n (∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))\n ∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))\n ∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}\n\n/-- Coproduct of two monoids or groups. -/\n@[to_additive /-- Coproduct of two additive monoids or groups. -/]\ndef Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient\n\nnamespace Coprod\n\n@[inherit_doc]\nscoped infix:30 \" ∗ \" => Coprod\n\nsection MulOneClass\n\nvariable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']\n [MulOneClass P]\n\n@[to_additive] protected instance : MulOneClass (M ∗ N) :=\n inferInstanceAs <| MulOneClass (coprodCon M N).Quotient\n\n/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/\n@[to_additive /-- The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`. -/]\ndef mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _\n\n@[to_additive (attr := simp)]\ntheorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _\n\n@[to_additive]\ntheorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective\n\n@[to_additive (attr := simp)]\ntheorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'\n\n@[to_additive]\ntheorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _\n\n/-- The natural embedding `M →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `M →+ AddMonoid.Coprod M N`. -/]\ndef inl : M →* M ∗ N where\n toFun := fun x => mk (of (.inl x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y\n\n/-- The natural embedding `N →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `N →+ AddMonoid.Coprod M N`. -/]\ndef inr : N →* M ∗ N where\n toFun := fun x => mk (of (.inr x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl\n\n@[to_additive (attr := elab_as_elim)]\n\nTarget:\ntheorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)\n (one : C 1)\n (inl_mul : ∀ m x, C x → C (inl m * x))\n (inr_mul : ∀ n x, C x → C (inr n * x)) : C m :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_333195ce4a49","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"f8865a54fdb45c5eac3216b4dd587a3b6a13f624d76af9489ca77d8b031da9aa","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory/Coprod","family_id":"induction_on","file_id":"mathlib/Mathlib/GroupTheory/Coprod/Basic.lean","sample_id":"333195ce4a4964559d747a2db00ae4e4744155206df3c15c00afa3023ea766d8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f8acf0e73117bc5ca7d7bd9991122534f2ac979976c9881ebac1cb80ac751f3b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5c8e210502ad87905c94c6f7a2a4eb3be6971e1ba00b12807176f08e3394331f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"756c833bb1403a31b9b4a213930da4b0d915305ddd84c92a8d7e783da3ae3d26","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]","hard_negative":true,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.133333},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"bef7759d1683574c6629b518bd58fa57226e28c63eb14ef524399fde6956ff84","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\nTarget:\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_756c833bb140","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"84c091e22497ad5e81953648cd17ffeefa5588f25c51915330762b114edadaa0","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"lift_lsmul_mul_eq_lsmul_lift_lsmul","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"756c833bb1403a31b9b4a213930da4b0d915305ddd84c92a8d7e783da3ae3d26"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2dd26aa16922b4b1730a990a8f4281058b74eb64cb8af6e51735f7cf7cc0a7da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"74d6185445236635fdd438cb4d4e206399bb8d675c78a4157c9ba5965363ce71","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e076da205af4fb3a325ff5f9c19c6b5ee67ed1606d459a6b768a83543c4ea749","source_sha256":"2ab3c6bb05b55d8a4fa84cd2cd336003b6ff429674fec08decf3b8e5d2ab8013","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [liftp_iff]; constructor <;> intro h\n · rcases h with ⟨a', f', heq, h'⟩\n cases heq\n assumption\n repeat' first | constructor | assumption","hard_negative":false,"metrics":{"chosen_tokens":35,"rejected_tokens":40,"token_jaccard":0.84375,"token_length_ratio":1.142857},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"bf16acdc742499f3a4634b5ae6a864fd6ec1fe03cffa1d94bd24b796e66afe0a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.W.Basic\n\nNamespace:\nPFunctor\n\nLocal context:\n/-\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/-!\n# Polynomial Functors\n\nThis file defines polynomial functors and the W-type construction as a polynomial functor.\n(For the M-type construction, see `Mathlib/Data/PFunctor/Univariate/M.lean`.)\n-/\n\n@[expose] public section\n\nuniverse u v uA uB uA₁ uB₁ uA₂ uB₂ v₁ v₂ v₃\n\nset_option linter.checkUnivs false in\n/-- A polynomial functor `P` is given by a type `A` and a family `B` of types over `A`. `P` maps\nany type `α` to a new type `P α`, which is defined as the sigma type `Σ x, P.B x → α`.\n\nAn element of `P α` is a pair `⟨a, f⟩`, where `a` is an element of a type `A` and\n`f : B a → α`. Think of `a` as the shape of the object and `f` as an index to the relevant\nelements of `α`.\n-/\n-- Note: `nolint checkUnivs` should not apply here, we really do want two separate universe levels\n@[pp_with_univ, nolint checkUnivs]\nstructure PFunctor where\n /-- The head type -/\n A : Type uA\n /-- The child family of types -/\n B : A → Type uB\n\nnamespace PFunctor\n\ninstance : Inhabited PFunctor :=\n ⟨⟨default, default⟩⟩\n\nvariable (P : PFunctor.{uA, uB}) {α : Type v₁} {β : Type v₂} {γ : Type v₃}\n\n/-- Applying `P` to an object of `Type` -/\n@[coe]\ndef Obj (α : Type v) : Type (max v uA uB) :=\n Σ x : P.A, P.B x → α\n\ninstance : CoeFun PFunctor.{uA, uB} (fun _ => Type v → Type (max v uA uB)) where\n coe := Obj\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map (f : α → β) : P α → P β :=\n fun ⟨a, g⟩ => ⟨a, f ∘ g⟩\n\ninstance Obj.inhabited [Inhabited P.A] [Inhabited α] : Inhabited (P α) :=\n ⟨⟨default, default⟩⟩\n\ninstance : Functor P.Obj where map := @map P\n\n/-- We prefer `PFunctor.map` to `Functor.map` because it is universe-polymorphic. -/\n@[simp]\ntheorem map_eq_map {α β : Type v} (f : α → β) (x : P α) : f <$> x = P.map f x :=\n rfl\n\n@[simp]\nprotected theorem map_eq (f : α → β) (a : P.A) (g : P.B a → α) :\n P.map f ⟨a, g⟩ = ⟨a, f ∘ g⟩ :=\n rfl\n\n@[simp]\nprotected theorem id_map : ∀ x : P α, P.map id x = x := fun ⟨_, _⟩ => rfl\n\n@[simp]\nprotected theorem map_map (f : α → β) (g : β → γ) :\n ∀ x : P α, P.map g (P.map f x) = P.map (g ∘ f) x := fun ⟨_, _⟩ => rfl\n\ninstance : LawfulFunctor (Obj.{v} P) where\n map_const := rfl\n id_map x := P.id_map x\n comp_map f g x := P.map_map f g x |>.symm\n\n/-- Re-export existing definition of W-types and adapt it to a packaged definition of polynomial\nfunctor. -/\ndef W : Type (max uA uB) :=\n WType P.B\n\n/- Inhabitants of W types is awkward to encode as an instance assumption because there needs to be a\nvalue `a : P.A` such that `P.B a` is empty to yield a finite tree. -/\n\nvariable {P}\n\n/-- The root element of a W tree -/\ndef W.head : W P → P.A\n | ⟨a, _f⟩ => a\n\n/-- The children of the root of a W tree -/\ndef W.children : ∀ x : W P, P.B (W.head x) → W P\n | ⟨_a, f⟩ => f\n\n/-- The destructor for W-types -/\ndef W.dest : W P → P (W P)\n | ⟨a, f⟩ => ⟨a, f⟩\n\n/-- The constructor for W-types -/\ndef W.mk : P (W P) → W P\n | ⟨a, f⟩ => ⟨a, f⟩\n\n@[simp]\ntheorem W.dest_mk (p : P (W P)) : W.dest (W.mk p) = p := by cases p; rfl\n\n@[simp]\ntheorem W.mk_dest (p : W P) : W.mk (W.dest p) = p := by cases p; rfl\n\nvariable (P)\n\n/-- `Idx` identifies a location inside the application of a polynomial functor. For `F : PFunctor`,\n`x : F α` and `i : F.Idx`, `i` can designate one part of `x` or is invalid, if `i.1 ≠ x.1`. -/\ndef Idx : Type (max uA uB) :=\n Σ x : P.A, P.B x\n\ninstance Idx.inhabited [Inhabited P.A] [Inhabited (P.B default)] : Inhabited P.Idx :=\n ⟨⟨default, default⟩⟩\n\nvariable {P}\n\n/-- `x.iget i` takes the component of `x` designated by `i` if any is or returns a default value -/\ndef Obj.iget [DecidableEq P.A] {α} [Inhabited α] (x : P α) (i : P.Idx) : α :=\n if h : i.1 = x.1 then x.2 (cast (congr_arg _ h) i.2) else default\n\n@[simp]\ntheorem fst_map (x : P α) (f : α → β) : (P.map f x).1 = x.1 := by cases x; rfl\n\n@[simp]\ntheorem iget_map [DecidableEq P.A] [Inhabited α] [Inhabited β] (x : P α)\n (f : α → β) (i : P.Idx) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by\n simp only [Obj.iget, fst_map, *, dif_pos]\n cases x\n rfl\n\nend PFunctor\n\n/-\nComposition of polynomial functors.\n-/\nnamespace PFunctor\n\n/-- Composition for polynomial functors -/\ndef comp (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) :\n PFunctor.{max uA₁ uA₂ uB₂, max uB₁ uB₂} :=\n ⟨Σ a₂ : P₂.1, P₂.2 a₂ → P₁.1, fun a₂a₁ => Σ u : P₂.2 a₂a₁.1, P₁.2 (a₂a₁.2 u)⟩\n\n/-- Constructor for composition -/\ndef comp.mk (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) {α : Type v} (x : P₂ (P₁ α)) :\n comp P₂ P₁ α :=\n ⟨⟨x.1, Sigma.fst ∘ x.2⟩, fun a₂a₁ => (x.2 a₂a₁.1).2 a₂a₁.2⟩\n\n/-- Destructor for composition -/\ndef comp.get (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) {α : Type v} (x : comp P₂ P₁ α) :\n P₂ (P₁ α) :=\n ⟨x.1.1, fun a₂ => ⟨x.1.2 a₂, fun a₁ => x.2 ⟨a₂, a₁⟩⟩⟩\n\nend PFunctor\n\n/-\nLifting predicates and relations.\n-/\nnamespace PFunctor\n\nvariable {P : PFunctor.{uA, uB}}\n\nopen Functor\n\ntheorem liftp_iff {α : Type u} (p : α → Prop) (x : P α) :\n Liftp p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i, p (f i) := by\n constructor\n · rintro ⟨y, hy⟩\n rcases h : y with ⟨a, f⟩\n refine ⟨a, fun i => (f i).val, ?_, fun i => (f i).property⟩\n rw [← hy, h, map_eq_map, PFunctor.map_eq]\n congr\n rintro ⟨a, f, xeq, pf⟩\n use ⟨a, fun i => ⟨f i, pf i⟩⟩\n rw [xeq]; rfl\n\nTarget:\ntheorem liftp_iff' {α : Type u} (p : α → Prop) (a : P.A) (f : P.B a → α) :\n @Liftp.{u} P.Obj _ α p ⟨a, f⟩ ↔ ∀ i, p (f i) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n simp only [liftp_iff]; constructor <;> intro h\n · rcases h with ⟨a', f', heq, h'⟩\n cases heq\n assumption\n repeat' first | constructor | assumption","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PFunctor","family_id":"liftp_iff","file_id":"mathlib/Mathlib/Data/PFunctor/Univariate/Basic.lean","sample_id":"e076da205af4fb3a325ff5f9c19c6b5ee67ed1606d459a6b768a83543c4ea749"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f6a95f4339fc29a09b4741866c8c9952b0e0943a519e29b54d2a8433b0a98cf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f8fdb999101ce33755577e7c01c87bfcc89f8fbf7457a90335f5ab67dc267963","source_sha256":"8e40b01e7ccf6ab3c48f4a90d26615e74e27bf1ea1850224aad736249f560b66","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases subsingleton_or_nontrivial R\n · exact (cardinalMk_eq_one R X).trans_le (le_max_of_le_right one_le_aleph0)\n cases isEmpty_or_nonempty X\n · exact (cardinalMk_eq_lift R X).trans_le (le_max_of_le_left <| le_max_left _ _)\n · exact (cardinalMk_eq_max_lift R X).le\n\nvariable (X : Type u)","hard_negative":true,"metrics":{"chosen_tokens":53,"rejected_tokens":8,"token_jaccard":0.0625,"token_length_ratio":0.150943},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"bf427bb5c62a814cd86a27f5344c64304b6a973d83d17c93b74b831cc7c84b77","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.FreeAlgebra\npublic import Mathlib.SetTheory.Cardinal.Free\n\nNamespace:\nFreeAlgebra\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n# Cardinality of free algebras\n\nThis file contains some results about the cardinality of `FreeAlgebra`,\nparallel to that of `MvPolynomial`.\n-/\n\npublic section\n\nuniverse u v\n\nvariable (R : Type u) [CommSemiring R]\n\nopen Cardinal\n\nnamespace FreeAlgebra\n\nvariable (X : Type v)\n\n@[simp]\ntheorem cardinalMk_eq_max_lift [Nonempty X] [Nontrivial R] :\n #(FreeAlgebra R X) = Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n have hX := mk_freeMonoid X\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra,\n mk_finsupp_lift_of_infinite, hX, lift_max, lift_aleph0, sup_comm, ← sup_assoc]\n\n@[simp]\ntheorem cardinalMk_eq_lift [IsEmpty X] : #(FreeAlgebra R X) = Cardinal.lift.{v} #R := by\n have := lift_mk_eq'.2 ⟨show (FreeMonoid X →₀ R) ≃ R from Finsupp.uniqueEquiv 1⟩\n rw [lift_id'.{u, v}, lift_umax] at this\n rwa [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra]\n\n@[nontriviality]\ntheorem cardinalMk_eq_one [Subsingleton R] : #(FreeAlgebra R X) = 1 := by\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra, mk_eq_one]\n\nTarget:\ntheorem cardinalMk_le_max_lift :\n #(FreeAlgebra R X) ≤ Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"b3a6bd1a967ba3b8c516227b36ccbbf3f8ab507700426a108e3f06bd3a67d519","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAlgebra","family_id":"cardinalmk_le_max_lift","file_id":"mathlib/Mathlib/Algebra/FreeAlgebra/Cardinality.lean","sample_id":"f8fdb999101ce33755577e7c01c87bfcc89f8fbf7457a90335f5ab67dc267963"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8c9ffbc471f68fc3f445ad52713700b4995dff84872f3c48386a0b12cb5d68cf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c21a2a8a385ed1f82fa776c2dd121b8cd33ffa2ee66840e401e8610d14e4e6e5","source_sha256":"6ca40a9a028dbe37b0e6d35f519e15fb40bd243ba89a07bbe3689aea9c6deaf6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let e : R ≃ₐ[R] (Localization.AtPrime (maximalIdeal R)) :=\n IsLocalization.atUnits R (maximalIdeal R).primeCompl (fun x ↦ by simpa using! fun a ↦ a)\n exact IsRegularLocalRing.of_ringEquiv e.toRingEquiv.symm","hard_negative":false,"metrics":{"chosen_tokens":52,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.057692},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"c04db68be2a69c92aece7cccca7a5f8a05cf6d590d7812d60b254ba15c7d92ba","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.SpanRankOperations\npublic import Mathlib.RingTheory.DedekindDomain.Dvr\npublic import Mathlib.RingTheory.Ideal.KrullsHeightTheorem\npublic import Mathlib.RingTheory.KrullDimension.Field\npublic import Mathlib.RingTheory.KrullDimension.PID\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# Regular local rings\n\nFor a Noetherian local ring `R`, we define `IsRegularLocalRing` as\n`(maximalIdeal R).spanFinrank = ringKrullDim R`. This definition is equivalent to\nthe dimension of the cotangent space over the residue field being equal to `ringKrullDim R`,\n(see `IsRegularLocalRing.iff_finrank_cotangentSpace`).\n\nFor the next section, we define regular rings as Noetherian rings whose localization at every prime\nare regular local rings.\n(Note that a regular local ring is a regular ring, but this is not immediate under this definition).\n\n# Main Definition and Results\n\n* `IsRegularLocalRing` : A Noetherian local ring is regular if\n `(maximalIdeal R).spanFinrank = ringKrullDim R`,\n i.e. its maximal ideal can be generated by `dim R` elements.\n\n* `IsRegularLocalRing.iff_finrank_cotangentSpace` : the equivalence of `IsRegularLocalRing` and\n `Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R`\n\n* `IsRegularRing` : A noetherian ring is regular if its localization at any prime\n `IsRegularLocalRing`.\n\n## TODO\nShow that regular local rings are regular under this definition.\nThis follows from localizations of regular local rings being regular (@Thmoas-Guan).\n\n-/\n\npublic section\n\nopen IsLocalRing\n\n/-- A Noetherian local ring is said to be regular if its maximal ideal\ncan be generated by `dim R` elements. -/\n@[stacks 00KU]\nclass IsRegularLocalRing (R : Type*) [CommRing R] : Prop extends\n IsLocalRing R, IsNoetherianRing R where\n spanFinrank_maximalIdeal : (maximalIdeal R).spanFinrank = ringKrullDim R\n\nvariable (R : Type*) [CommRing R]\n\nlemma isRegularLocalRing_iff [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ (maximalIdeal R).spanFinrank = ringKrullDim R :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nnamespace IsRegularLocalRing\n\nlemma of_spanFinrank_maximalIdeal_le [IsLocalRing R] [IsNoetherianRing R]\n (le : (maximalIdeal R).spanFinrank ≤ ringKrullDim R) : IsRegularLocalRing R :=\n (isRegularLocalRing_iff _).mpr (le_antisymm le (ringKrullDim_le_spanFinrank_maximalIdeal R))\n\nvariable {R} in\nlemma of_ringEquiv [IsRegularLocalRing R] {R' : Type*} [CommRing R']\n (e : R ≃+* R') : IsRegularLocalRing R' := by\n have := e.isLocalRing\n have := isNoetherianRing_of_ringEquiv R e\n rwa [isRegularLocalRing_iff, ← ringKrullDim_eq_of_ringEquiv e, ← map_ringEquiv_maximalIdeal e,\n Ideal.spanFinrank_map_eq_of_ringEquiv, ← isRegularLocalRing_iff]\n\nlemma iff_finrank_cotangentSpace [IsLocalRing R] [IsNoetherianRing R] :\n IsRegularLocalRing R ↔ Module.finrank (ResidueField R) (CotangentSpace R) = ringKrullDim R := by\n rw [isRegularLocalRing_iff, spanFinrank_maximalIdeal_eq_finrank_cotangentSpace]\n\ninstance [IsLocalRing R] [IsDomain R] [IsPrincipalIdealRing R] : IsRegularLocalRing R := by\n by_cases isf : IsField R\n · let := isf.toField\n simp [isRegularLocalRing_iff, maximalIdeal_eq_bot]\n · apply of_spanFinrank_maximalIdeal_le\n rcases IsPrincipalIdealRing.principal (maximalIdeal R) with ⟨x, hx⟩\n simpa only [(IsPrincipalIdealRing.ringKrullDim_eq_one R) isf,\n Nat.cast_le_one, ← Set.ncard_singleton x, hx] using\n Submodule.spanFinrank_span_le_ncard_of_finite (Set.finite_singleton x)\n\nend IsRegularLocalRing\n\n/-- A noetherian ring is regular if its localization at any prime `IsRegularLocalRing`. -/\nclass IsRegularRing (R : Type*) [CommRing R] : Prop extends IsNoetherianRing R where\n isRegularLocalRing_localization (p : Ideal R) [p.IsPrime] :\n IsRegularLocalRing (Localization.AtPrime p)\n\nattribute [instance low] IsRegularRing.isRegularLocalRing_localization\n\nsection IsRegularRing\n\nvariable {R} in\nlemma isRegularRing_iff [IsNoetherianRing R] : IsRegularRing R ↔\n ∀ (p : Ideal R) [p.IsPrime], IsRegularLocalRing (Localization.AtPrime p) :=\n ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩\n\nvariable {R} in\nlemma IsRegularRing.of_ringEquiv {R' : Type*} [CommRing R'] (e : R ≃+* R') [IsRegularRing R] :\n IsRegularRing R' := by\n have := isNoetherianRing_of_ringEquiv R e\n rw [isRegularRing_iff]\n intro p hp\n exact IsRegularLocalRing.of_ringEquiv <| IsLocalization.ringEquivOfRingEquiv\n (Localization.AtPrime (p.comap e)) (Localization.AtPrime p) e (e.map_primeCompl_comap_eq p)\n\nTarget:\nlemma IsRegularLocalRing.of_isRegularRing_of_isLocalRing [IsLocalRing R] [IsRegularRing R] :\n IsRegularLocalRing R :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/RegularLocalRing","family_id":"isregularlocalring","file_id":"mathlib/Mathlib/RingTheory/RegularLocalRing/Defs.lean","sample_id":"c21a2a8a385ed1f82fa776c2dd121b8cd33ffa2ee66840e401e8610d14e4e6e5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d835b98c41d2ea2cf7885bf49be82e2844c91e6d84f2c7ed7bfe87e6530b1fe1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"27260096916ee0cf671ba979cd65cd932c4925b4beb3209bedd05394d562f2b0","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4bb4374eba1b571bf2e8fbbef04861793160f8d0fe4c97086c83d35e9439a582","source_sha256":"991a8724fd4dbc8b903c21c214ce00ffc92ff1fb34fc1f773e7d34149514f251","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨a, rfl⟩ := h\n simp","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":5,"token_jaccard":0.071429,"token_length_ratio":0.5},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"c0a61d96410e2d35a0823922ca4e4f9cc49796d984dd70a4c7abac02d8173c3b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.KrullDimension.NonZeroDivisors\npublic import Mathlib.RingTheory.Length\npublic import Mathlib.RingTheory.HopkinsLevitzki\npublic import Mathlib.Algebra.Ring.Hom.InjSurj\npublic import Mathlib.RingTheory.Ideal.Quotient.Noetherian\n\nNamespace:\nRing\n\nLocal context:\n/-\nCopyright (c) 2025 Raphael Douglas Giles. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Raphael Douglas Giles\n-/\n/-!\n# Order of vanishing\n\nThis file defines the order of vanishing of an element of a ring as the length of the quotient of\nthe ring by the ideal generated by that element. We also define the extension of this notion to the\nfield of fractions\n-/\n\n@[expose] public section\n\nopen LinearMap Pointwise IsLocalization Ideal WithZero\n\nvariable {R : Type*} {M : Type*} [AddCommMonoid M]\n\nnamespace Ring\n\nvariable (R) [Ring R]\n/--\nOrder of vanishing function for elements of a ring.\n-/\n@[stacks 02MD]\nnoncomputable\ndef ord (x : R) : ℕ∞ := Module.length R (R ⧸ Ideal.span {x})\n\n@[simp]\nlemma ord_one : ord R 1 = 0 := by\n simp_all [ord,\n Ideal.span_singleton_one, Submodule.Quotient.subsingleton_iff]\n\nend Ring\n\nvariable [CommRing R] [Module R M]\n\n/--\nThe map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a`\n-/\ndef Ideal.mulQuot (a : R) (I : Ideal R) :\n R ⧸ I →ₗ[R] R ⧸ (a • I) :=\n Submodule.mapQ _ _ (LinearMap.mul R R a) (Submodule.le_comap_map _ _)\n\n/--\nThe map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a` is injective if `a` is\na nonzero divisor.\n-/\nlemma Ideal.mulQuot_injective {a : R} (I : Ideal R) (ha : a ∈ nonZeroDivisors R) :\n Function.Injective (Ideal.mulQuot a I) := by\n simp only [mulQuot, Submodule.mapQ, ← ker_eq_bot]\n apply Submodule.ker_liftQ_eq_bot'\n apply le_antisymm\n · have : Submodule.map (mul R R a) I = a • I := rfl\n rw [le_ker_iff_map, Submodule.map_comp, this, Submodule.mkQ_map_self]\n · have m : I = Submodule.comap (mul R R a) (a • I) := by\n ext b\n exact (Submodule.mul_mem_smul_iff ha).symm\n simp [← m, ker_comp]\n\n/--\nThe quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})`.\n-/\ndef Ideal.quotOfMul (a : R) (I : Ideal R) :\n (R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a}) :=\n Submodule.factor <| Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I\n\n/--\nThe quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})` is surjective.\n-/\nlemma Ideal.quotOfMul_surjective {a : R} (I : Ideal R) :\n Function.Surjective (Ideal.quotOfMul a I) := by\n simp only [Ideal.quotOfMul]\n exact Submodule.factor_surjective <|\n Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I\n\n/--\nThe sequence `R ⧸ I →ₗ[R] R ⧸ (a • I) →ₗ[R] R ⧸ (Ideal.span {a})` given by multiplication\nby `a` then quotienting by the ideal generated by `a` is exact.\n-/\nlemma Ideal.exact_mulQuot_quotOfMul {a : R} (I : Ideal R) :\n Function.Exact (Ideal.mulQuot a I) (Ideal.quotOfMul a I) := by\n simp only [exact_iff]\n have : ker (Ideal.quotOfMul a I) = a • ⊤ := by\n simp only [← submodule_span_eq, quotOfMul, Submodule.factor, Submodule.mapQ, comp_id,\n Submodule.ker_liftQ, Submodule.ker_mkQ, Submodule.map_span, Submodule.mkQ_apply,\n Quotient.mk_eq_mk, Set.image_singleton, Quotient.smul_top]\n simp [this, Ideal.mulQuot, Submodule.mapQ.eq_1, Submodule.range_liftQ,\n range_comp, Ideal.Quotient.smul_top, ← Ideal.submodule_span_eq, LinearMap.map_span]\n\nnamespace Ring\nvariable (R)\n/--\nThe order of vanishing of `a * b` is the order of vanishing of `a` plus the order\nof vanishing of `b`.\n-/\ntheorem ord_mul {a b : R} (hb : b ∈ nonZeroDivisors R) :\n ord R (a * b) = ord R a + ord R b := by\n have := Module.length_eq_add_of_exact (Ideal.mulQuot b (Ideal.span {a}))\n (Ideal.quotOfMul b (Ideal.span {a})) (Ideal.mulQuot_injective (Ideal.span {a}) hb)\n (Ideal.quotOfMul_surjective (Ideal.span {a}))\n (Ideal.exact_mulQuot_quotOfMul (Ideal.span {a}))\n simp only [Ring.ord, ← this]\n have lem : (({b} : Set R) • Ideal.span {a}) = Ideal.span {b * a} := by\n simp [← Ideal.submodule_span_eq, Submodule.set_smul_span]\n have : (({b} : Set R) • Ideal.span {a}) = b • Ideal.span {a} := Submodule.singleton_set_smul\n (Ideal.span {a}) b\n rw [this] at lem\n rw [lem, mul_comm]\n\n/--\nVariation of `ord_mul` where the user has to show the first input is a non\nzero divisor rather than the second.\n-/\nlemma ord_mul' {a b : R} (ha : a ∈ nonZeroDivisors R) :\n ord R (a * b) = ord R a + ord R b := by\n rw [mul_comm, ord_mul R ha, add_comm]\n\n/--\nThe order of zero is `Module.length R R`. Use this when it is necessary to unfold the definition\nof `ord` to avoid annoyances of working with `R ⧸ Ideal.span {0}` instead of `R`.\n-/\nlemma ord_zero : ord R 0 = Module.length R R := by\n simp only [ord]\n let m := (Submodule.quotEquivOfEqBot (Ideal.span {0} : Submodule R R) (span_singleton_zero))\n exact le_antisymm (Module.length_le_of_injective m m.injective)\n (Module.length_le_of_surjective m m.surjective)\n\nvariable {R}\n/--\nFor `x : R` a non zero divisor, `ord R (x ^ n) = n • ord R x`.\n-/\n@[simp]\ntheorem ord_pow {x : R} (hx : x ∈ nonZeroDivisors R) (n : ℕ) : ord R (x ^ n) = n • ord R x := by\n induction n with\n | zero => simp\n | succ n ih =>\n rw [pow_succ, ord_mul, ih, succ_nsmul]\n exact hx\n\n@[simp]\nlemma ord_mul_of_isUnit_left {a : R} (h : IsUnit a) (x : R) : ord R (a * x) = ord R x := by\n rw [ord, ord, Ideal.span_singleton_mul_left_unit h x]\n\n@[simp]\nlemma ord_mul_of_isUnit_right {a : R} (h : IsUnit a) (x : R) : ord R (x * a) = ord R x := by\n rw [ord, ord, Ideal.span_singleton_mul_right_unit h x]\n\nTarget:\nlemma ord_eq_of_associated {x y : R} (h : Associated x y) : ord R x = ord R y :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_4bb4374eba1b","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"21f5d3fa9909a3edff0f39eab2e864f8a0bc5efcff5ffcc9ab0997a2f238438b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/OrderOfVanishing","family_id":"ord_eq_of_associated","file_id":"mathlib/Mathlib/RingTheory/OrderOfVanishing/Basic.lean","sample_id":"4bb4374eba1b571bf2e8fbbef04861793160f8d0fe4c97086c83d35e9439a582"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e82e08ef144d565e1c376295ce50ac6ef4301c0767aa14c0314503288fad8a54","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"eeba7ab75fd247f2f2c68f85fa4664c9b7a7a287729ab06261d1005e46da3142","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"11f23baef49a098a7d1f6ccdc22c013017dff9dd746cd6f024880be58eedb02f","source_sha256":"98ab40b848c3a9b869e560fc0ac9ad03c46286d47046f58fc1a9867b1fe3c8a8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext v\n simp_rw [continuousLinearMapCoordChange, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.arrowCongrSL_apply, continuousLinearMap_apply,\n continuousLinearMap_symm_apply' σ e₁ e₂ hb.1, comp_apply, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.symm_symm, Trivialization.continuousLinearMapAt_apply,\n Trivialization.symmL_apply]\n rw [e₂.coordChangeL_apply e₂', e₁'.coordChangeL_apply e₁, e₁.coe_linearMapAt_of_mem hb.1.1,\n e₂'.coe_linearMapAt_of_mem hb.2.2]\n exacts [⟨hb.2.1, hb.1.1⟩, ⟨hb.1.2, hb.2.2⟩]","hard_negative":false,"metrics":{"chosen_tokens":114,"rejected_tokens":121,"token_jaccard":0.942857,"token_length_ratio":1.061404},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"c305dd7234443c82b387b6724ef10b0de702bb2de49a653ee2507f860555f54b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.VectorBundle.Basic\n\nNamespace:\nBundle.Pretrivialization\n\nLocal context:\n/-\nCopyright (c) 2022 Heather Macbeth. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Heather Macbeth, Floris van Doorn\n-/\n/-!\n# The vector bundle of continuous (semi)linear maps\n\nWe define the (topological) vector bundle of continuous (semi)linear maps between two vector bundles\nover the same base.\n\nGiven bundles `E₁ E₂ : B → Type*`, normed spaces `F₁` and `F₂`, and a ring-homomorphism `σ` between\ntheir respective scalar fields, we define a vector bundle with fiber `E₁ x →SL[σ] E₂ x`.\nIf the `E₁` and `E₂` are vector bundles with model fibers `F₁` and `F₂`, then this will be a\nvector bundle with fiber `F₁ →SL[σ] F₂`.\n\nThe topology on the total space is constructed from the trivializations for `E₁` and `E₂` and the\nnorm-topology on the model fiber `F₁ →SL[𝕜] F₂` using the `VectorPrebundle` construction. This is\na bit awkward because it introduces a dependence on the normed space structure of the model fibers,\nrather than just their topological vector space structure; it is not clear whether this is\nnecessary.\n\nSimilar constructions should be possible (but are yet to be formalized) for tensor products of\ntopological vector bundles, exterior algebras, and so on, where again the topology can be defined\nusing a norm on the fiber model if this helps.\n-/\n\n@[expose] public section\n\n\nnoncomputable section\n\nopen Bundle Set ContinuousLinearMap Topology\nopen scoped Bundle\n\nvariable {𝕜₁ : Type*} [NontriviallyNormedField 𝕜₁] {𝕜₂ : Type*} [NontriviallyNormedField 𝕜₂]\n (σ : 𝕜₁ →+* 𝕜₂)\n\nvariable {B : Type*}\nvariable {F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜₁ F₁] (E₁ : B → Type*)\n [∀ x, AddCommGroup (E₁ x)] [∀ x, Module 𝕜₁ (E₁ x)] [TopologicalSpace (TotalSpace F₁ E₁)]\n\nvariable {F₂ : Type*} [NormedAddCommGroup F₂] [NormedSpace 𝕜₂ F₂] (E₂ : B → Type*)\n [∀ x, AddCommGroup (E₂ x)] [∀ x, Module 𝕜₂ (E₂ x)] [TopologicalSpace (TotalSpace F₂ E₂)]\n\nvariable {E₁ E₂}\nvariable [TopologicalSpace B] (e₁ e₁' : Trivialization F₁ (π F₁ E₁))\n (e₂ e₂' : Trivialization F₂ (π F₂ E₂))\n\nnamespace Bundle.Pretrivialization\n\n/-- Assume `eᵢ` and `eᵢ'` are trivializations of the bundles `Eᵢ` over base `B` with fiber `Fᵢ`\n(`i ∈ {1,2}`), then `Pretrivialization.continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂'` is the\ncoordinate change function between the two induced (pre)trivializations\n`Pretrivialization.continuousLinearMap σ e₁ e₂` and\n`Pretrivialization.continuousLinearMap σ e₁' e₂'` of the bundle of continuous linear maps. -/\ndef continuousLinearMapCoordChange [e₁.IsLinear 𝕜₁] [e₁'.IsLinear 𝕜₁] [e₂.IsLinear 𝕜₂]\n [e₂'.IsLinear 𝕜₂] (b : B) : (F₁ →SL[σ] F₂) →L[𝕜₂] F₁ →SL[σ] F₂ :=\n ((e₁'.coordChangeL 𝕜₁ e₁ b).symm.arrowCongrSL (e₂.coordChangeL 𝕜₂ e₂' b) :\n (F₁ →SL[σ] F₂) ≃L[𝕜₂] F₁ →SL[σ] F₂)\n\nvariable {σ e₁ e₁' e₂ e₂'}\nvariable [∀ x, TopologicalSpace (E₁ x)] [FiberBundle F₁ E₁]\nvariable [∀ x, TopologicalSpace (E₂ x)] [FiberBundle F₂ E₂]\n\nset_option backward.defeqAttrib.useBackward true in\ntheorem continuousOn_continuousLinearMapCoordChange [RingHomIsometric σ]\n [VectorBundle 𝕜₁ F₁ E₁] [VectorBundle 𝕜₂ F₂ E₂]\n [MemTrivializationAtlas e₁] [MemTrivializationAtlas e₁'] [MemTrivializationAtlas e₂]\n [MemTrivializationAtlas e₂'] :\n ContinuousOn (continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂')\n (e₁.baseSet ∩ e₂.baseSet ∩ (e₁'.baseSet ∩ e₂'.baseSet)) := by\n have h₁ := (compSL F₁ F₂ F₂ σ (RingHom.id 𝕜₂)).continuous\n have h₂ := (ContinuousLinearMap.flip (compSL F₁ F₁ F₂ (RingHom.id 𝕜₁) σ)).continuous\n have h₃ := continuousOn_coordChange 𝕜₁ e₁' e₁\n have h₄ := continuousOn_coordChange 𝕜₂ e₂ e₂'\n refine ((h₁.comp_continuousOn (h₄.mono ?_)).clm_comp (h₂.comp_continuousOn (h₃.mono ?_))).congr ?_\n · mfld_set_tac\n · mfld_set_tac\n · intro b _\n ext L v\n dsimp [continuousLinearMapCoordChange]\n\nvariable (σ e₁ e₁' e₂ e₂')\nvariable [e₁.IsLinear 𝕜₁] [e₁'.IsLinear 𝕜₁] [e₂.IsLinear 𝕜₂] [e₂'.IsLinear 𝕜₂]\n\n/-- Given trivializations `e₁`, `e₂` for vector bundles `E₁`, `E₂` over a base `B`,\n`Pretrivialization.continuousLinearMap σ e₁ e₂` is the induced pretrivialization for the\ncontinuous `σ`-semilinear maps from `E₁` to `E₂`. That is, the map which will later become a\ntrivialization, after the bundle of continuous semilinear maps is equipped with the right\ntopological vector bundle structure. -/\ndef continuousLinearMap :\n Pretrivialization (F₁ →SL[σ] F₂) (π (F₁ →SL[σ] F₂) (fun x ↦ E₁ x →SL[σ] E₂ x)) where\n toFun p := ⟨p.1, .comp (e₂.continuousLinearMapAt 𝕜₂ p.1) (p.2.comp (e₁.symmL 𝕜₁ p.1))⟩\n invFun p := ⟨p.1, .comp (e₂.symmL 𝕜₂ p.1) (p.2.comp (e₁.continuousLinearMapAt 𝕜₁ p.1))⟩\n source := Bundle.TotalSpace.proj ⁻¹' (e₁.baseSet ∩ e₂.baseSet)\n target := (e₁.baseSet ∩ e₂.baseSet) ×ˢ Set.univ\n map_source' := fun ⟨_, _⟩ h ↦ ⟨h, Set.mem_univ _⟩\n map_target' := fun ⟨_, _⟩ h ↦ h.1\n left_inv' := fun ⟨x, L⟩ ⟨h₁, h₂⟩ ↦ by\n simp only [TotalSpace.mk_inj]\n ext (v : E₁ x)\n dsimp only [comp_apply]\n rw [Trivialization.symmL_continuousLinearMapAt, Trivialization.symmL_continuousLinearMapAt]\n exacts [h₁, h₂]\n right_inv' := fun ⟨x, f⟩ ⟨⟨h₁, h₂⟩, _⟩ ↦ by\n simp only [Prod.mk_right_inj]\n ext v\n dsimp only [comp_apply]\n rw [Trivialization.continuousLinearMapAt_symmL, Trivialization.continuousLinearMapAt_symmL]\n exacts [h₁, h₂]\n open_target := (e₁.open_baseSet.inter e₂.open_baseSet).prod isOpen_univ\n baseSet := e₁.baseSet ∩ e₂.baseSet\n open_baseSet := e₁.open_baseSet.inter e₂.open_baseSet\n source_eq := rfl\n target_eq := rfl\n proj_toFun _ _ := rfl\n\n-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215):\n-- TODO: see if Lean 4 can generate this instance without a hint\ninstance continuousLinearMap.isLinear [∀ x, ContinuousAdd (E₂ x)] [∀ x, ContinuousSMul 𝕜₂ (E₂ x)] :\n (Pretrivialization.continuousLinearMap σ e₁ e₂).IsLinear 𝕜₂ where\n linear x _ :=\n { map_add L L' := by simp [continuousLinearMap, Pretrivialization.toFun']\n map_smul c L := by simp [continuousLinearMap, Pretrivialization.toFun'] }\n\ntheorem continuousLinearMap_apply (p : TotalSpace (F₁ →SL[σ] F₂) fun x ↦ E₁ x →SL[σ] E₂ x) :\n (continuousLinearMap σ e₁ e₂) p =\n ⟨p.1, .comp (e₂.continuousLinearMapAt 𝕜₂ p.1) (p.2.comp (e₁.symmL 𝕜₁ p.1))⟩ :=\n rfl\n\ntheorem continuousLinearMap_symm_apply (p : B × (F₁ →SL[σ] F₂)) :\n (continuousLinearMap σ e₁ e₂).toPartialEquiv.symm p =\n ⟨p.1, .comp (e₂.symmL 𝕜₂ p.1) (p.2.comp (e₁.continuousLinearMapAt 𝕜₁ p.1))⟩ :=\n rfl\n\ntheorem continuousLinearMap_symm_apply' {b : B} (hb : b ∈ e₁.baseSet ∩ e₂.baseSet)\n (L : F₁ →SL[σ] F₂) :\n (continuousLinearMap σ e₁ e₂).symm b L =\n (e₂.symmL 𝕜₂ b).comp (L.comp <| e₁.continuousLinearMapAt 𝕜₁ b) := by\n rw [symm_apply]\n · rfl\n · exact hb\n\nTarget:\ntheorem continuousLinearMapCoordChange_apply (b : B)\n (hb : b ∈ e₁.baseSet ∩ e₂.baseSet ∩ (e₁'.baseSet ∩ e₂'.baseSet)) (L : F₁ →SL[σ] F₂) :\n continuousLinearMapCoordChange σ e₁ e₁' e₂ e₂' b L =\n (continuousLinearMap σ e₁' e₂' ⟨b, (continuousLinearMap σ e₁ e₂).symm b L⟩).2 :=\n\nProof body:\n","rejected":"```lean\nby\n ext v\n simp_rw [continuousLinearMapCoordChange, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.arrowCongrSL_apply, continuousLinearMap_apply,\n continuousLinearMap_symm_apply' σ e₁ e₂ hb.1, comp_apply, ContinuousLinearEquiv.coe_coe,\n ContinuousLinearEquiv.symm_symm, Trivialization.continuousLinearMapAt_apply,\n Trivialization.symmL_apply]\n rw [e₂.coordChangeL_apply e₂', e₁'.coordChangeL_apply e₁, e₁.coe_linearMapAt_of_mem hb.1.1,\n e₂'.coe_linearMapAt_of_mem hb.2.2]\n exacts [⟨hb.2.1, hb.1.1⟩, ⟨hb.1.2, hb.2.2⟩]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/VectorBundle","family_id":"continuouslinearmapcoordchange_apply","file_id":"mathlib/Mathlib/Topology/VectorBundle/Hom.lean","sample_id":"11f23baef49a098a7d1f6ccdc22c013017dff9dd746cd6f024880be58eedb02f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b15c75b86cf707fcab5e6ebde44ef13e53518470fce8dd2bee06daea8b2ae81a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c4ce80c33e6b5bb75bbe3f0ab38644b2b9897e69f19928043fd51d97d586218c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"23f21a25563f16af680ef8080d884dc90928aa2a7ff70b8b49d561b5eef2bb9e","source_sha256":"80e36a31fdad7f596e8087d0eff022ff75293f4eb9ca06fcd55ecdd117822a69","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro s\n set S := fun (i : ι) => Localization (M.map (Pi.evalRingHom R i))\n obtain ⟨r, hr⟩ :=\n surjective_piRingHom_algebraMap_comp_piEvalRingHom\n S M ((lift (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) s)\n refine ⟨r, (bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom R S _ M).injective ?_⟩\n rwa [lift_eq (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M) r]","hard_negative":true,"metrics":{"chosen_tokens":75,"rejected_tokens":3,"token_jaccard":0.025,"token_length_ratio":0.04},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"c464756a37c27f97b8367efab519557c35642f16efcd7690d60b3519a41bde6a","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Pi\npublic import Mathlib.Algebra.BigOperators.Pi\npublic import Mathlib.Algebra.Divisibility.Prod\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.RingTheory.Localization.Basic\npublic import Mathlib.Algebra.Group.Pi.Units\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\nIsLocalization\n\nLocal context:\n/-\nCopyright (c) 2024 Madison Crim. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Madison Crim\n-/\n/-!\n# Localizing a product of commutative rings\n\n## Main Result\n\n* `bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom`: the canonical map from a\n localization of a finite product of rings `R i` at a monoid `M` to the direct product of\n localizations `R i` at the projection of `M` onto each corresponding factor is bijective.\n\n## Implementation notes\n\nSee `Mathlib/RingTheory/Localization/Defs.lean` for a design overview.\n\n## Tags\nlocalization, commutative ring\n-/\n\npublic section\n\nnamespace IsLocalization\n\nvariable {ι : Type*} (R S : ι → Type*)\n [Π i, CommSemiring (R i)] [Π i, CommSemiring (S i)] [Π i, Algebra (R i) (S i)]\n\n/-- If `S i` is a localization of `R i` at the submonoid `M i` for each `i`,\nthen `Π i, S i` is a localization of `Π i, R i` at the product submonoid. -/\ninstance (M : Π i, Submonoid (R i)) [∀ i, IsLocalization (M i) (S i)] :\n IsLocalization (.pi .univ M) (Π i, S i) where\n map_units m := Pi.isUnit_iff.mpr fun i ↦ map_units _ ⟨m.1 i, m.2 i ⟨⟩⟩\n surj z := by\n choose rm h using fun i ↦ surj (M := M i) (z i)\n exact ⟨(fun i ↦ (rm i).1, ⟨_, fun i _ ↦ (rm i).2.2⟩), funext h⟩\n exists_of_eq {x y} eq := by\n choose c hc using fun i ↦ exists_of_eq (M := M i) (congr_fun eq i)\n exact ⟨⟨_, fun i _ ↦ (c i).2⟩, funext hc⟩\n\nvariable (S' : Type*) [CommSemiring S'] [Algebra (Π i, R i) S'] (M : Submonoid (Π i, R i))\n\ntheorem iff_map_piEvalRingHom [Finite ι] :\n IsLocalization M S' ↔ IsLocalization (.pi .univ fun i ↦ M.map (Pi.evalRingHom R i)) S' :=\n iff_of_le_of_exists_dvd M _ (fun m hm i _ ↦ ⟨m, hm, rfl⟩) fun n hn ↦ by\n choose m mem eq using hn\n have := Fintype.ofFinite ι\n refine ⟨∏ i, m i ⟨⟩, prod_mem fun i _ ↦ mem i _, pi_dvd_iff.mpr fun i ↦ ?_⟩\n rw [Fintype.prod_apply]\n exact (eq i ⟨⟩).symm.dvd.trans (Finset.dvd_prod_of_mem _ <| Finset.mem_univ _)\n\nvariable [∀ i, IsLocalization (M.map (Pi.evalRingHom R i)) (S i)]\n\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote\nthe projection of `M` onto each corresponding factor. Given a ring homomorphism from the direct\nproduct `Π i, R i` to the product of the localizations of each `R i` at `M' i`, every `y : M`\nmaps to a unit under this homomorphism. -/\nlemma isUnit_piRingHom_algebraMap_comp_piEvalRingHom (y : M) :\n IsUnit ((RingHom.pi fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i)) y) :=\n Pi.isUnit_iff.mpr fun i ↦ map_units _ (⟨y.1 i, y, y.2, rfl⟩ : M.map (Pi.evalRingHom R i))\n\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote\nthe projection of `M` onto each factor. Then the canonical map from the localization of the direct\nproduct `Π i, R i` at `M` to the direct product of the localizations of each `R i` at `M' i`\nis bijective. -/\ntheorem bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom [IsLocalization M S'] [Finite ι] :\n Function.Bijective (lift (S := S') (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) :=\n have := (iff_map_piEvalRingHom R (Π i, S i) M).mpr inferInstance\n (ringEquivOfRingEquiv (M := M) (T := M) _ _ (.refl _) <|\n Submonoid.map_equiv_eq_comap_symm _ _).bijective\n\nopen Function Ideal\n\ninclude M in\nvariable {R} in\nlemma surjective_piRingHom_algebraMap_comp_piEvalRingHom\n [∀ i, Ring.KrullDimLE 0 (R i)] [∀ i, IsLocalRing (R i)] :\n Surjective (RingHom.pi (fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i))) := by\n apply Surjective.piMap (fun i ↦ ?_)\n by_cases h₀ : (0 : R i) ∈ (M.map (Pi.evalRingHom R i))\n · have := uniqueOfZeroMem h₀ (S := (S i))\n exact surjective_to_subsingleton (algebraMap (R i) (S i))\n · exact (IsLocalization.atUnits _ _ (by simpa)).surjective\n\nvariable {R} in\n/-- Let `M` be a submonoid of a direct product of commutative rings `R i`.\nIf each `R i` has maximal nilradical then the direct product `∏ R i` surjects onto the\nlocalization of `∏ R i` at `M`. -/\n\nTarget:\nlemma algebraMap_pi_surjective_of_isLocalization [∀ i, Ring.KrullDimLE 0 (R i)]\n [∀ i, IsLocalRing (R i)] [IsLocalization M S']\n [Finite ι] : Surjective (algebraMap (Π i, R i) S') :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_23f21a25563f","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"e80c3519f1411de2f5146560a2c6bf09a4953a75d38673c3a252c6dd3e9425ce","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Localization","family_id":"algebramap_pi_surjective_of_islocalization","file_id":"mathlib/Mathlib/RingTheory/Localization/Pi.lean","sample_id":"23f21a25563f16af680ef8080d884dc90928aa2a7ff70b8b49d561b5eef2bb9e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"40613eb9d4b1a9cee266cfcfe5d41e6bfa505fbe3cec0f632fa9e5cf3496237f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b55d2bfa78f45ed09ca1dbceaaa1a2efeaade8330558ae96ab56e1cfecfbc16e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ff3ef85326780ec04f162693b7f81032494a8a92b52b64d72381cd7bdcb29635","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr","hard_negative":true,"metrics":{"chosen_tokens":31,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.096774},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"c464f9104fe9c58f9bbe2549e177337bddffdf12bb9703b51b4048a349ee120c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\nTarget:\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_ff3ef8532678","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"230f8b2f07e3333c4dff45dee3b381519d9caa67da80b6decc9837968398df5c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"coe_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"ff3ef85326780ec04f162693b7f81032494a8a92b52b64d72381cd7bdcb29635"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0a786c63a29f8f8a6ad111cc9d2cf6858a7e8f212b31cf748094b97c30c37643","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2ed243bb84deafa9b180ec260be025dbb1241b5a84fe979099b6acebc44bd76f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"97745478c40faafd4cfc44e547295322c87fa94f88a62a3b71d18cdea8c1ea36","source_sha256":"664243cc517bfe84fcfa2881fa7e4b33cbb4a93e56372a947fb2d4d35413e37d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using Monoid.FG.fg_top.finite_irreducible_mem_submonoidClosure","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":15,"token_jaccard":0.666667,"token_length_ratio":1.5},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"c489b89f04368892258936b03bc8fc8209a72edea619e35adf9272fb1d8b3722","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Irreducible.Defs\npublic import Mathlib.GroupTheory.Finiteness\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Yaël Dillies, Patrick Luo. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Patrick Luo\n-/\n/-!\n# An affine monoid with no non-trivial unit is generated by its irreducible elements\n\nThis file proves that an additive cancellative monoid with no non-trivial unit unit is generated by\nits irreducible elements.\n-/\n\npublic section\n\nvariable {M : Type*}\n\nsection CommMonoid\nvariable [CommMonoid M] [Subsingleton Mˣ] {S : Set M}\n\n/-- Any set `S` inside a monoid with a single unit contains the irreducible elements of the\nsubmonoid it generates. -/\n@[to_additive /-- Any set `S` inside an additive monoid with a single unit contains the irreducible\nelements of the submonoid it generates. -/]\nlemma irreducible_mem_submonoidClosure_subset : {p ∈ Submonoid.closure S | Irreducible p} ⊆ S := by\n refine fun x hx ↦\n Submonoid.closure_induction (s := S) (motive := fun x _ ↦ (Irreducible x → x ∈ S))\n (fun _ hx _ ↦ hx) (by simp) (fun a b _ _ ha hb h ↦ ?_) hx.1 hx.2\n obtain rfl | rfl := h.eq_one_or_eq_one <;> simp_all\n\n/-- In a monoid with a single unit, irreducible elements lie in all generating sets. -/\n@[to_additive\n/-- In an additive monoid with a single unit, irreducible elements lie in all generating sets. -/]\nlemma irreducible_subset_of_submonoidClosure_eq_top (hS : Submonoid.closure S = ⊤) :\n {p | Irreducible p} ⊆ S := by\n simpa [hS] using irreducible_mem_submonoidClosure_subset (S := S)\n\n/-- A finitely generated submonoid of a monoid with a single unit has finitely many irreducible\nelements. -/\n@[to_additive\n/-- A finitely generated submonoid of an additive monoid with a single unit has finitely many\nirreducible elements. -/]\nlemma Submonoid.FG.finite_irreducible_mem_submonoidClosure {S : Submonoid M} (hS : S.FG) :\n {p ∈ S | Irreducible p}.Finite := by\n obtain ⟨T, hT⟩ := hS; exact T.finite_toSet.subset <| hT ▸ irreducible_mem_submonoidClosure_subset\n\nvariable [Monoid.FG M]\n\n/-- A finitely generated monoid with a single unit has finitely many irreducible elements. -/\n@[to_additive\n/-- A finitely generated additive monoid with a single unit has finitely many irreducible\nelements. -/]\n\nTarget:\nlemma finite_irreducible : {p : M | Irreducible p}.Finite :=\n\nProof body:\n","rejected":"by\n simpa using Monoid.FG.fg_top.finite_irreducible_mem_submonoidClosure\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"finite_irreducible","file_id":"mathlib/Mathlib/Algebra/AffineMonoid/Irreducible.lean","sample_id":"97745478c40faafd4cfc44e547295322c87fa94f88a62a3b71d18cdea8c1ea36"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"26663fc1bf6b4e5aefb65660a393c53e27dfaf28983bb18a6c7510bb8a675597","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e36908c324774f29f6484fb0c5b911d33e69af46cbe4f258ec2985e6af53883e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e279e1822904168067ecd9997a88ad6f26de6f6b0101216ed184ae97359d0b3e","source_sha256":"22fa7dc543ea04781c497c923ce59749d770278f4d57644a7a47b8e8d1036d31","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases t\n apply Nat.succ_pos","hard_negative":false,"metrics":{"chosen_tokens":7,"rejected_tokens":12,"token_jaccard":0.636364,"token_length_ratio":1.714286},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"c61e359e47ac73c803bc507ed59c2629fea7da760fd5850c7229b8392de165ac","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finset.Lattice.Fold\npublic import Mathlib.Logic.Encodable.Pi\n\nNamespace:\nWType\n\nLocal context:\n/-\nCopyright (c) 2019 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad\n-/\n/-!\n# W types\n\nGiven `α : Type` and `β : α → Type`, the W type determined by this data, `WType β`, is the\ninductively defined type of trees where the nodes are labeled by elements of `α` and the children of\na node labeled `a` are indexed by elements of `β a`.\n\nThis file is currently a stub, awaiting a full development of the theory. Currently, the main result\nis that if `α` is an encodable fintype and `β a` is encodable for every `a : α`, then `WType β` 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 `WType` is somewhat verbose, it is preferable to putting a single character\nidentifier `W` in the root namespace.\n-/\n\n@[expose] public section\n\n-- For \"W_type\"\n\n/--\nGiven `β : α → Type*`, `WType β` is the type of finitely branching trees where nodes are labeled by\nelements of `α` and the children of a node labeled `a` are indexed by elements of `β a`.\n-/\ninductive WType {α : Type*} (β : α → Type*)\n | mk (a : α) (f : β a → WType β) : WType β\n\ninstance : Inhabited (WType fun _ : Unit => Empty) :=\n ⟨WType.mk Unit.unit Empty.elim⟩\n\nnamespace WType\n\nvariable {α : Type*} {β : α → Type*}\n\n/-- The canonical map to the corresponding sigma type, returning the label of a node as an\n element `a` of `α`, and the children of the node as a function `β a → WType β`. -/\ndef toSigma : WType β → Σ a : α, β a → WType β\n | ⟨a, f⟩ => ⟨a, f⟩\n\n/-- The canonical map from the sigma type into a `WType`. Given a node `a : α`, and\n its children as a function `β a → WType β`, return the corresponding tree. -/\ndef ofSigma : (Σ a : α, β a → WType β) → WType β\n | ⟨a, f⟩ => WType.mk a f\n\n@[simp]\ntheorem ofSigma_toSigma : ∀ w : WType β, ofSigma (toSigma w) = w\n | ⟨_, _⟩ => rfl\n\n@[simp]\ntheorem toSigma_ofSigma : ∀ s : Σ a : α, β a → WType β, toSigma (ofSigma s) = s\n | ⟨_, _⟩ => rfl\n\nvariable (β) in\n/-- The canonical bijection with the sigma type, showing that `WType` is a fixed point of\n the polynomial functor `X ↦ Σ a : α, β a → X`. -/\n@[simps]\ndef equivSigma : WType β ≃ Σ a : α, β a → WType β where\n toFun := toSigma\n invFun := ofSigma\n left_inv := ofSigma_toSigma\n right_inv := toSigma_ofSigma\n\n/-- The canonical map from `WType β` into any type `γ` given a map `(Σ a : α, β a → γ) → γ`. -/\ndef elim (γ : Type*) (fγ : (Σ a : α, β a → γ) → γ) : WType β → γ\n | ⟨a, f⟩ => fγ ⟨a, fun b => elim γ fγ (f b)⟩\n\ntheorem elim_injective (γ : Type*) (fγ : (Σ a : α, β a → γ) → γ)\n (fγ_injective : Function.Injective fγ) : Function.Injective (elim γ fγ)\n | ⟨a₁, f₁⟩, ⟨a₂, f₂⟩, h => by\n obtain ⟨rfl, h⟩ := Sigma.mk.inj_iff.mp (fγ_injective h)\n congr with x\n exact elim_injective γ fγ fγ_injective (congr_fun (eq_of_heq h) x :)\n\ninstance [hα : IsEmpty α] : IsEmpty (WType β) :=\n ⟨fun w => WType.recOn w (IsEmpty.elim hα)⟩\n\ntheorem infinite_of_nonempty_of_isEmpty (a b : α) [ha : Nonempty (β a)] [he : IsEmpty (β b)] :\n Infinite (WType β) :=\n ⟨by\n intro hf\n have hba : b ≠ a := fun h => ha.elim (IsEmpty.elim' (show IsEmpty (β a) from h ▸ he))\n refine\n not_injective_infinite_finite\n (fun n : ℕ =>\n show WType β from Nat.recOn n ⟨b, IsEmpty.elim' he⟩ fun _ ih => ⟨a, fun _ => ih⟩)\n ?_\n intro n m h\n induction n generalizing m with\n | zero => rcases m with - | m <;> simp_all\n | succ n ih =>\n rcases m with - | m\n · simp_all\n · refine congr_arg Nat.succ (ih ?_)\n simp_all [funext_iff]⟩\n\nvariable [∀ a : α, Fintype (β a)]\n\n/-- The depth of a finitely branching tree. -/\ndef depth : WType β → ℕ\n | ⟨_, f⟩ => (Finset.sup Finset.univ fun n => depth (f n)) + 1\n\nTarget:\ntheorem depth_pos (t : WType β) : 0 < t.depth :=\n\nProof body:\n","rejected":"by\n cases t\n apply Nat.succ_pos\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/W","family_id":"depth_pos","file_id":"mathlib/Mathlib/Data/W/Basic.lean","sample_id":"e279e1822904168067ecd9997a88ad6f26de6f6b0101216ed184ae97359d0b3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b8ad902050e495c9c6044daca69b6b535110214affffd080282c2a08b24973f5","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fded65ddb83631c3f2b8c3a750b24c663d46cd088afbc4514295b63b81534fcf","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f22f80c1a43541829a9abfe45c501e2f08fb44de4c00bb183be36e65122cdf4f","source_sha256":"1184e00df794ae0cc3cb94d891a807375a55a88ac5b64d1a726798271ef9526a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : DistribSMul.toLinearMap k V a = a • LinearMap.id := by\n ext; simp\n simp [smul_eq_map, map_direction, this, Submodule.map_smul, ha]","hard_negative":false,"metrics":{"chosen_tokens":34,"rejected_tokens":39,"token_jaccard":0.866667,"token_length_ratio":1.147059},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"c7361d9053f77ea66a40710d31fe8b077cad48c33acee054aea2d2d213400be8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic\npublic import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic\n\nNamespace:\nAffineSubspace\n\nLocal context:\n/-\nCopyright (c) 2022 Hanting Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Hanting Zhang\n-/\n/-! # Pointwise instances on `AffineSubspace`s\n\nThis file provides the additive action `AffineSubspace.pointwiseAddAction` in the\n`Pointwise` locale.\n\n-/\n\n@[expose] public section\n\n\nopen Affine Pointwise\n\nopen Set\n\nvariable {M k V P V₁ P₁ V₂ P₂ : Type*}\n\nnamespace AffineSubspace\nsection Ring\nvariable [Ring k]\nvariable [AddCommGroup V] [Module k V] [AffineSpace V P]\nvariable [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁]\nvariable [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂]\n\n/-- The additive action on an affine subspace corresponding to applying the action to every element.\n\nThis is available as an instance in the `Pointwise` locale. -/\n@[instance_reducible]\nprotected def pointwiseVAdd : VAdd V (AffineSubspace k P) where\n vadd x s := s.map (AffineEquiv.constVAdd k P x)\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseVAdd\n\n@[simp, norm_cast] lemma coe_pointwise_vadd (v : V) (s : AffineSubspace k P) :\n ((v +ᵥ s : AffineSubspace k P) : Set P) = v +ᵥ (s : Set P) := rfl\n\n/-- The additive action on an affine subspace corresponding to applying the action to every element.\n\nThis is available as an instance in the `Pointwise` locale. -/\n@[instance_reducible]\nprotected def pointwiseAddAction : AddAction V (AffineSubspace k P) :=\n SetLike.coe_injective.addAction _ coe_pointwise_vadd\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseAddAction\n\ntheorem pointwise_vadd_eq_map (v : V) (s : AffineSubspace k P) :\n v +ᵥ s = s.map (AffineEquiv.constVAdd k P v) :=\n rfl\n\ntheorem vadd_mem_pointwise_vadd_iff {v : V} {s : AffineSubspace k P} {p : P} :\n v +ᵥ p ∈ v +ᵥ s ↔ p ∈ s :=\n vadd_mem_vadd_set_iff\n\n@[simp] theorem pointwise_vadd_bot (v : V) : v +ᵥ (⊥ : AffineSubspace k P) = ⊥ := by\n ext; simp [pointwise_vadd_eq_map, map_bot]\n\n@[simp] lemma pointwise_vadd_top (v : V) : v +ᵥ (⊤ : AffineSubspace k P) = ⊤ := by\n ext; simp [pointwise_vadd_eq_map, vadd_eq_iff_eq_neg_vadd]\n\ntheorem pointwise_vadd_direction (v : V) (s : AffineSubspace k P) :\n (v +ᵥ s).direction = s.direction := by\n rw [pointwise_vadd_eq_map, map_direction]\n exact Submodule.map_id _\n\ntheorem pointwise_vadd_span (v : V) (s : Set P) : v +ᵥ affineSpan k s = affineSpan k (v +ᵥ s) :=\n map_span _ s\n\ntheorem map_pointwise_vadd (f : P₁ →ᵃ[k] P₂) (v : V₁) (s : AffineSubspace k P₁) :\n (v +ᵥ s).map f = f.linear v +ᵥ s.map f := by\n rw [pointwise_vadd_eq_map, pointwise_vadd_eq_map, map_map, map_map]\n congr 1\n ext\n exact f.map_vadd _ _\n\nsection SMul\nvariable [DistribSMul M V] [SMulCommClass M k V] {a : M} {s : AffineSubspace k V}\n {p : V}\n\n/-- The multiplicative action on an affine subspace corresponding to applying the action to every\nelement.\n\nThis is available as an instance in the `Pointwise` locale.\n\nTODO: generalize to include `SMul (P ≃ᵃ[k] P) (AffineSubspace k P)`, which acts on `P` with a\n`VAdd` version of a `DistribMulAction`. -/\n@[instance_reducible]\nprotected def pointwiseSMul : SMul M (AffineSubspace k V) where\n smul a s := s.map (DistribSMul.toLinearMap k _ a).toAffineMap\n\nscoped[Pointwise] attribute [instance] AffineSubspace.pointwiseSMul\n\n@[simp, norm_cast]\nlemma coe_smul (a : M) (s : AffineSubspace k V) : ↑(a • s) = a • (s : Set V) := rfl\n\nlemma smul_eq_map (a : M) (s : AffineSubspace k V) :\n a • s = s.map (DistribSMul.toLinearMap k _ a).toAffineMap := rfl\n\nlemma smul_mem_smul_iff {G : Type*} [Group G] [DistribMulAction G V] [SMulCommClass G k V] {a : G} :\n a • p ∈ a • s ↔ p ∈ s := smul_mem_smul_set_iff\n\n@[simp] lemma smul_bot (a : M) : a • (⊥ : AffineSubspace k V) = ⊥ := by\n ext; simp [smul_eq_map, map_bot]\n\nlemma smul_span (a : M) (s : Set V) : a • affineSpan k s = affineSpan k (a • s) := map_span _ s\n\nend SMul\n\nsection MulAction\nvariable [Monoid M] [DistribMulAction M V] [SMulCommClass M k V] {a : M} {s : AffineSubspace k V}\n {p : V}\n\n/-- The multiplicative action on an affine subspace corresponding to applying the action to every\nelement.\n\nThis is available as an instance in the `Pointwise` locale.\n\nTODO: generalize to include `SMul (P ≃ᵃ[k] P) (AffineSubspace k P)`, which acts on `P` with a\n`VAdd` version of a `DistribMulAction`. -/\n@[instance_reducible]\nprotected def mulAction : MulAction M (AffineSubspace k V) :=\n SetLike.coe_injective.mulAction _ coe_smul\n\nscoped[Pointwise] attribute [instance] AffineSubspace.mulAction\n\nlemma smul_mem_smul_iff_of_isUnit (ha : IsUnit a) : a • p ∈ a • s ↔ p ∈ s :=\n smul_mem_smul_iff (a := ha.unit)\n\nlemma smul_mem_smul_iff₀ {G₀ : Type*} [GroupWithZero G₀] [DistribMulAction G₀ V]\n [SMulCommClass G₀ k V] {a : G₀} (ha : a ≠ 0) : a • p ∈ a • s ↔ p ∈ s :=\n smul_mem_smul_iff_of_isUnit ha.isUnit\n\n@[simp] lemma smul_top (ha : IsUnit a) : a • (⊤ : AffineSubspace k V) = ⊤ := by\n ext x; simpa [smul_eq_map, map_top] using ⟨ha.unit⁻¹ • x, smul_inv_smul ha.unit _⟩\n\nend MulAction\n\nend Ring\n\nsection Field\nvariable [Field k] [AddCommGroup V] [Module k V] {a : k}\n\n@[simp]\n\nTarget:\nlemma direction_smul (ha : a ≠ 0) (s : AffineSubspace k V) : (a • s).direction = s.direction :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n have : DistribSMul.toLinearMap k V a = a • LinearMap.id := by\n ext; simp\n simp [smul_eq_map, map_direction, this, Submodule.map_smul, ha]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/AffineSpace","family_id":"direction_smul","file_id":"mathlib/Mathlib/LinearAlgebra/AffineSpace/Pointwise.lean","sample_id":"f22f80c1a43541829a9abfe45c501e2f08fb44de4c00bb183be36e65122cdf4f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e9c639cb14e1b7dc55b43203e26652461236741a959d7df156742cc9bb47b669","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ba86fbaad8706e20269d79ad727497427be872a1fc9a26c6f4522d2def1b9330","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c536256fd5617a20a1f13fac5d41e784b6e0dff1b04749d89bae53f7731311d9","source_sha256":"1772ebc6d5f489fb8a42b880ceafc783ce77133acd1e06ebadf2800bb4211ccd","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor <;> intro\n exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]","hard_negative":false,"metrics":{"chosen_tokens":18,"rejected_tokens":25,"token_jaccard":0.882353,"token_length_ratio":1.388889},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"c799dac9ebad187c3dc0f26049f3a82d4c8fde38305a7687ef90e7a492af8ea7","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.CategoryTheory.CommSq\npublic import Mathlib.CategoryTheory.Retract\n\nNamespace:\nCategoryTheory.HasLiftingProperty\n\nLocal context:\n/-\nCopyright (c) 2021 Jakob Scholbach. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob Scholbach, Joël Riou\n-/\n/-!\n# Lifting properties\n\nThis file defines the lifting property of two morphisms in a category and\nshows basic properties of this notion.\n\n## Main results\n- `HasLiftingProperty`: the definition of the lifting property\n\n## Tags\nlifting property\n\n## TODO\n1) direct/inverse images, adjunctions\n\n-/\n\n@[expose] public section\n\nuniverse v\n\nnamespace CategoryTheory\n\nopen Category\n\nvariable {C : Type*} [Category* C] {A B B' X Y Y' : C} (i : A ⟶ B) (i' : B ⟶ B') (p : X ⟶ Y)\n (p' : Y ⟶ Y')\n\n/-- `HasLiftingProperty i p` means that `i` has the left lifting\nproperty with respect to `p`, or equivalently that `p` has\nthe right lifting property with respect to `i`. -/\n@[to_dual self (reorder := A Y, B X, i p)]\nclass HasLiftingProperty : Prop where\n /-- Unique field expressing that any commutative square built from `f` and `g` has a lift -/\n sq_hasLift : ∀ {f : A ⟶ X} {g : B ⟶ Y} (sq : CommSq f i p g), sq.HasLift\n\nattribute [to_dual self] HasLiftingProperty.sq_hasLift\nattribute [to_dual self (reorder := A Y, B X, i p, sq_hasLift (f g))] HasLiftingProperty.mk\n\n@[to_dual self]\ninstance (priority := 100) sq_hasLift_of_hasLiftingProperty {f : A ⟶ X} {g : B ⟶ Y}\n (sq : CommSq f i p g) [hip : HasLiftingProperty i p] : sq.HasLift := hip.sq_hasLift _\n\nnamespace HasLiftingProperty\n\nvariable {i p}\n\n@[to_dual self]\ntheorem op (h : HasLiftingProperty i p) : HasLiftingProperty p.op i.op :=\n ⟨fun {f} {g} sq => by\n simp only [CommSq.HasLift.iff_unop, Quiver.Hom.unop_op]\n infer_instance⟩\n\n@[to_dual self]\ntheorem unop {A B X Y : Cᵒᵖ} {i : A ⟶ B} {p : X ⟶ Y} (h : HasLiftingProperty i p) :\n HasLiftingProperty p.unop i.unop :=\n ⟨fun {f} {g} sq => by\n rw [CommSq.HasLift.iff_op]\n simp only [Quiver.Hom.op_unop]\n infer_instance⟩\n\n@[to_dual self]\ntheorem iff_op : HasLiftingProperty i p ↔ HasLiftingProperty p.op i.op :=\n ⟨op, unop⟩\n\n@[to_dual self]\ntheorem iff_unop {A B X Y : Cᵒᵖ} (i : A ⟶ B) (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty p.unop i.unop :=\n ⟨unop, op⟩\n\nvariable (i p)\n\n@[to_dual of_right_iso]\ninstance (priority := 100) of_left_iso [IsIso i] : HasLiftingProperty i p :=\n ⟨fun {f} {g} sq =>\n CommSq.HasLift.mk'\n { l := inv i ≫ f\n fac_left := by simp only [IsIso.hom_inv_id_assoc]\n fac_right := by simp only [sq.w, assoc, IsIso.inv_hom_id_assoc] }⟩\n\n@[to_dual of_comp_right]\ninstance of_comp_left [HasLiftingProperty i p] [HasLiftingProperty i' p] :\n HasLiftingProperty (i ≫ i') p :=\n ⟨fun {f} {g} sq => by\n have fac := sq.w\n rw [assoc] at fac\n exact\n CommSq.HasLift.mk'\n { l := (CommSq.mk (CommSq.mk fac).fac_right).lift\n fac_left := by simp only [assoc, CommSq.fac_left]\n fac_right := by simp only [CommSq.fac_right] }⟩\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) [hip : HasLiftingProperty i p] :\n HasLiftingProperty i' p := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nset_option backward.isDefEq.respectTransparency false in\ntheorem of_arrow_iso_right {A B X Y X' Y' : C} (i : A ⟶ B) {p : X ⟶ Y} {p' : X' ⟶ Y'}\n (e : Arrow.mk p ≅ Arrow.mk p') [hip : HasLiftingProperty i p] : HasLiftingProperty i p' := by\n rw [Arrow.iso_w' e]\n infer_instance\n\nTarget:\ntheorem iff_of_arrow_iso_left {A B A' B' X Y : C} {i : A ⟶ B} {i' : A' ⟶ B'}\n (e : Arrow.mk i ≅ Arrow.mk i') (p : X ⟶ Y) :\n HasLiftingProperty i p ↔ HasLiftingProperty i' p :=\n\nProof body:\n","rejected":"```lean\nby\n constructor <;> intro\n exacts [of_arrow_iso_left e p, of_arrow_iso_left e.symm p]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/LiftingProperties","family_id":"iff_of_arrow_iso_left","file_id":"mathlib/Mathlib/CategoryTheory/LiftingProperties/Basic.lean","sample_id":"c536256fd5617a20a1f13fac5d41e784b6e0dff1b04749d89bae53f7731311d9"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"24e69b4a5d1f91b608cf803c12f8372842f93b3aebd0d01b7b5730b29bb344c6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0f867321c41aa75165e9d76b09befa3bea6a2d60dfcb507fe37b62954dc2cbbc","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b3f4512a8bcd1cc454eb7911d427168e1c28820898022e335d1ea5ef32a3f344","source_sha256":"d6b794456e23e246e8cc7c7bd63fa80b7c1aa31c3e4cd321a6c0cedd6df705b7","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n constructor\n · rintro rfl x\n exact (gc x y).symm\n · intro H\n exact ((H <| u y).mpr (gc.l_u_le y)).antisymm ((gc _ _).mp <| (H z).mp le_rfl)","hard_negative":false,"metrics":{"chosen_tokens":55,"rejected_tokens":59,"token_jaccard":0.892857,"token_length_ratio":1.072727},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"c83dbfb2ff6154829c0619a699225b4567d8d317312dbb9d21623f6b0a66713e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.BoundedOrder.Basic\npublic import Mathlib.Order.Monotone.Basic\n\nNamespace:\nGaloisConnection\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\n/-!\n# Galois connections, insertions and coinsertions\n\nGalois connections are order-theoretic adjoints, i.e. a pair of functions `u` and `l`,\nsuch that `∀ a b, l a ≤ b ↔ a ≤ u b`.\n\n## Main definitions\n\n* `GaloisConnection`: A Galois connection is a pair of functions `l` and `u` satisfying\n `l a ≤ b ↔ a ≤ u b`. They are special cases of adjoint functors in category theory,\n but do not depend on the category theory library in mathlib.\n* `GaloisInsertion`: A Galois insertion is a Galois connection where `l ∘ u = id`\n* `GaloisCoinsertion`: A Galois coinsertion is a Galois connection where `u ∘ l = id`\n-/\n\n@[expose] public section\n\nassert_not_exists CompleteLattice RelIso\n\nopen Function OrderDual Set\n\nuniverse u v w x\n\nvariable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {κ : ι → Sort*} {a₁ a₂ : α}\n {b₁ b₂ : β}\n\n/-- A Galois connection is a pair of functions `l` and `u` satisfying\n`l a ≤ b ↔ a ≤ u b`. They are special cases of adjoint functors in category theory,\nbut do not depend on the category theory library in mathlib. -/\n@[to_dual self (reorder := α β, 3 4, l u)]\ndef GaloisConnection [Preorder α] [Preorder β] (l : α → β) (u : β → α) :=\n ∀ a b, l a ≤ b ↔ a ≤ u b\n\nto_dual_insert_cast GaloisConnection := by\n rw [forall_comm]; simp only [Iff.comm]\n\nto_dual_name_hint U L\n\nnamespace GaloisConnection\n\nsection\n\nvariable [Preorder α] [Preorder β] {l : α → β} {u : β → α}\n\n@[to_dual self (reorder := α β, 3 4, l u, hu hl, h_u_l h_l_u)]\ntheorem monotone_intro (hu : Monotone u) (hl : Monotone l) (h_u_l : ∀ a, a ≤ u (l a))\n (h_l_u : ∀ a, l (u a) ≤ a) : GaloisConnection l u := fun _ _ =>\n ⟨fun h => (h_u_l _).trans (hu h), fun h => (hl h).trans (h_l_u _)⟩\n\n@[to_dual self]\nprotected theorem dual {l : α → β} {u : β → α} (gc : GaloisConnection l u) :\n GaloisConnection (OrderDual.toDual ∘ u ∘ OrderDual.ofDual)\n (OrderDual.toDual ∘ l ∘ OrderDual.ofDual) :=\n fun a b => (gc b a).symm\n\nvariable (gc : GaloisConnection l u)\ninclude gc\n\n@[to_dual none]\ntheorem le_iff_le {a : α} {b : β} : l a ≤ b ↔ a ≤ u b :=\n gc _ _\n\n@[to_dual le_u]\ntheorem l_le {a : α} {b : β} : a ≤ u b → l a ≤ b :=\n (gc _ _).mpr\n\n@[to_dual l_u_le]\ntheorem le_u_l (a) : a ≤ u (l a) :=\n gc.le_u <| le_rfl\n\n@[to_dual]\ntheorem monotone_u : Monotone u := fun a _ H => gc.le_u ((gc.l_u_le a).trans H)\n\n@[to_dual]\ntheorem monotone_l_comp_u : Monotone (l ∘ u) := gc.monotone_l.comp gc.monotone_u\n\n/-- If `(l, u)` is a Galois connection, then the relation `x ≤ u (l y)` is a transitive relation.\nIf `l` is a closure operator (`Submodule.span`, `Subgroup.closure`, ...) and `u` is the coercion to\n`Set`, this reads as \"if `U` is in the closure of `V` and `V` is in the closure of `W` then `U` is\nin the closure of `W`\". -/\n@[to_dual l_u_le_trans]\ntheorem le_u_l_trans {x y z : α} (hxy : x ≤ u (l y)) (hyz : y ≤ u (l z)) : x ≤ u (l z) :=\n hxy.trans (gc.monotone_u <| gc.l_le hyz)\n\nend\n\nsection PartialOrder\n\nvariable [PartialOrder α] [Preorder β] {l : α → β} {u : β → α} (gc : GaloisConnection l u)\ninclude gc\n\n@[to_dual]\ntheorem u_l_u_eq_u (b : β) : u (l (u b)) = u b :=\n (gc.monotone_u (gc.l_u_le _)).antisymm (gc.le_u_l _)\n\n@[to_dual]\ntheorem u_l_u_eq_u' : u ∘ l ∘ u = u :=\n funext gc.u_l_u_eq_u\n\n@[to_dual]\ntheorem u_unique {l' : α → β} {u' : β → α} (gc' : GaloisConnection l' u') (hl : ∀ a, l a = l' a)\n {b : β} : u b = u' b :=\n le_antisymm (gc'.le_u <| hl (u b) ▸ gc.l_u_le _) (gc.le_u <| (hl (u' b)).symm ▸ gc'.l_u_le _)\n\n/-- If there exists a `b` such that `a = u a`, then `b = l a` is one such element. -/\n@[to_dual /-- If there exists an `b` such that `a = l b`, then `b = u a` is one such element. -/]\ntheorem exists_eq_u (a : α) : (∃ b : β, a = u b) ↔ a = u (l a) :=\n ⟨fun ⟨_, hS⟩ => hS.symm ▸ (gc.u_l_u_eq_u _).symm, fun HI => ⟨_, HI⟩⟩\n\n@[to_dual]\n\nTarget:\ntheorem u_eq {z : α} {y : β} : u y = z ↔ ∀ x, x ≤ z ↔ l x ≤ y :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n constructor\n · rintro rfl x\n exact (gc x y).symm\n · intro H\n exact ((H <| u y).mpr (gc.l_u_le y)).antisymm ((gc _ _).mp <| (H z).mp le_rfl)","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/GaloisConnection","family_id":"u_eq","file_id":"mathlib/Mathlib/Order/GaloisConnection/Defs.lean","sample_id":"b3f4512a8bcd1cc454eb7911d427168e1c28820898022e335d1ea5ef32a3f344"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"15a9473f1155664d5857c91af11e1c2b9dce6d1c4264e93243e8a452450cf472","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"474de6fb54f22929b6aed7b5ec6d4fb320efe5406cd7b0372ccb903c0cd7cac2","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"13761ac07584773ef45f8b932e4b9f0e9de357d763e2a247f2b92df80cf1b745","source_sha256":"1cc189218e3cc07e383205c72ab25062d8480a810582580bf68ae9b7f20cf48f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n -- A useful inequality to keep at hand\n have me0 : 0 < max (1 / ε) M := lt_max_iff.mpr (Or.inl (one_div_pos.mpr e0))\n -- The maximum between `1 / ε` and `M` works\n refine ⟨max (1 / ε) M, me0, fun z a => ?_⟩\n -- First, let's deal with the easy case in which we are far away from `α`\n by_cases dm1 : 1 ≤ dist α (j z a) * max (1 / ε) M\n · exact one_le_mul_of_one_le_of_one_le (d0 a) dm1\n · -- `j z a = z / (a + 1)`: we prove that this ratio is close to `α`\n have : j z a ∈ closedBall α ε := by\n refine mem_closedBall'.mp (le_trans ?_ ((one_div_le me0 e0).mpr (le_max_left _ _)))\n exact (le_div_iff₀ me0).mpr (not_le.mp dm1).le\n -- use the \"separation from `1`\" (assumption `L`) for numerators,\n refine (L this).trans ?_\n -- remove a common factor and use the Lipschitz assumption `B`\n gcongr\n · exact zero_le_one.trans (d0 a)\n · refine (B this).trans ?_\n gcongr\n apply le_max_right","hard_negative":false,"metrics":{"chosen_tokens":263,"rejected_tokens":268,"token_jaccard":0.972477,"token_length_ratio":1.019011},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"c873006e4869c97e3f8def5d55de08d09273d560b17364135a68d4c857c54f4d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Polynomial.DenomsClearable\npublic import Mathlib.Analysis.Calculus.MeanValue\npublic import Mathlib.Analysis.Calculus.Deriv.Polynomial\npublic import Mathlib.NumberTheory.Real.Irrational\npublic import Mathlib.Topology.Algebra.Polynomial\nimport Mathlib.Algebra.Order.Interval.Set.Group\n\nNamespace:\nLiouville\n\nLocal context:\n/-\nCopyright (c) 2020 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damiano Testa, Jujian Zhang\n-/\n/-!\n\n# Liouville's theorem\n\nThis file contains a proof of Liouville's theorem stating that all Liouville numbers are\ntranscendental.\n\nTo obtain this result, there is first a proof that Liouville numbers are irrational and two\ntechnical lemmas. These lemmas exploit the fact that a polynomial with integer coefficients\ntakes integer values at integers. When evaluating at a rational number, we can clear denominators\nand obtain precise inequalities that ultimately allow us to prove transcendence of\nLiouville numbers.\n-/\n\n@[expose] public section\n\n\n/-- A Liouville number is a real number `x` such that for every natural number `n`, there exist\n`a, b ∈ ℤ` with `1 < b` such that `0 < |x - a/b| < 1/bⁿ`.\nIn the implementation, the condition `x ≠ a/b` replaces the traditional equivalent `0 < |x - a/b|`.\n-/\ndef Liouville (x : ℝ) :=\n ∀ n : ℕ, ∃ a b : ℤ, 1 < b ∧ x ≠ a / b ∧ |x - a / b| < 1 / (b : ℝ) ^ n\n\nnamespace Liouville\n\nprotected theorem irrational {x : ℝ} (h : Liouville x) : Irrational x := by\n -- By contradiction, `x = a / b`, with `a ∈ ℤ`, `0 < b ∈ ℕ` is a Liouville number,\n rintro ⟨⟨a, b, bN0, cop⟩, rfl⟩\n -- clear up the mess of constructions of rationals\n rw [Rat.cast_mk'] at h\n -- Since `a / b` is a Liouville number, there are `p, q ∈ ℤ`, with `q1 : 1 < q`,∈\n -- `a0 : a / b ≠ p / q` and `a1 : |a / b - p / q| < 1 / q ^ (b + 1)`\n rcases h (b + 1) with ⟨p, q, q1, a0, a1⟩\n -- A few useful inequalities\n have qR0 : (0 : ℝ) < q := Int.cast_pos.mpr (zero_lt_one.trans q1)\n have b0 : (b : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr bN0\n have bq0 : (0 : ℝ) < b * q := mul_pos (Nat.cast_pos.mpr bN0.bot_lt) qR0\n -- At a1, clear denominators...\n replace a1 : |a * q - b * p| * q ^ (b + 1) < b * q := by\n rw [div_sub_div _ _ b0 qR0.ne', abs_div, div_lt_div_iff₀ (abs_pos.mpr bq0.ne') (pow_pos qR0 _),\n abs_of_pos bq0, one_mul] at a1\n exact mod_cast a1\n -- At a0, clear denominators...\n replace a0 : a * q - ↑b * p ≠ 0 := by\n rw [Ne, div_eq_div_iff b0 qR0.ne', mul_comm (p : ℝ), ← sub_eq_zero] at a0\n exact mod_cast a0\n -- Actually, `q` is a natural number\n lift q to ℕ using (zero_lt_one.trans q1).le\n -- Looks innocuous, but we now have an integer with non-zero absolute value: this is at\n -- least one away from zero. The gain here is what gets the proof going.\n have ap : 0 < |a * ↑q - ↑b * p| := abs_pos.mpr a0\n -- Actually, the absolute value of an integer is a natural number\n -- FIXME: This `lift` call duplicates the hypotheses `a1` and `ap`\n lift |a * ↑q - ↑b * p| to ℕ using abs_nonneg (a * ↑q - ↑b * p) with e he\n norm_cast at a1 ap q1\n -- Recall this is by contradiction: we obtained the inequality `b * q ≤ x * q ^ (b + 1)`, so\n -- we are done.\n exact not_le.mpr a1 (Nat.mul_lt_mul_pow_succ ap q1).le\n\nopen Polynomial Metric Set Real RingHom\n\nopen scoped Polynomial\n\n/-- Let `Z, N` be types, let `R` be a metric space, let `α : R` be a point and let\n`j : Z → N → R` be a function. We aim to estimate how close we can get to `α`, while staying\nin the image of `j`. The points `j z a` of `R` in the image of `j` come with a \"cost\" equal to\n`d a`. As we get closer to `α` while staying in the image of `j`, we are interested in bounding\nthe quantity `d a * dist α (j z a)` from below by a strictly positive amount `1 / A`: the intuition\nis that approximating well `α` with the points in the image of `j` should come at a high cost. The\nhypotheses on the function `f : R → R` provide us with sufficient conditions to ensure our goal.\nThe first hypothesis is that `f` is Lipschitz at `α`: this yields a bound on the distance.\nThe second hypothesis is specific to the Liouville argument and provides the missing bound\ninvolving the cost function `d`.\n\nThis lemma collects the properties used in the proof of `exists_pos_real_of_irrational_root`.\nIt is stated in more general form than needed: in the intended application, `Z = ℤ`, `N = ℕ`,\n`R = ℝ`, `d a = (a + 1) ^ f.nat_degree`, `j z a = z / (a + 1)`, `f ∈ ℤ[x]`, `α` is an irrational\nroot of `f`, `ε` is small, `M` is a bound on the Lipschitz constant of `f` near `α`, `n` is\nthe degree of the polynomial `f`.\n-/\n\nTarget:\ntheorem exists_one_le_pow_mul_dist {Z N R : Type*} [PseudoMetricSpace R] {d : N → ℝ}\n {j : Z → N → R} {f : R → R} {α : R} {ε M : ℝ}\n -- denominators are positive\n (d0 : ∀ a : N, 1 ≤ d a)\n (e0 : 0 < ε)\n -- function is Lipschitz at α\n (B : ∀ ⦃y : R⦄, y ∈ closedBall α ε → dist (f α) (f y) ≤ dist α y * M)\n -- clear denominators\n (L : ∀ ⦃z : Z⦄, ∀ ⦃a : N⦄, j z a ∈ closedBall α ε → 1 ≤ d a * dist (f α) (f (j z a))) :\n ∃ A : ℝ, 0 < A ∧ ∀ z : Z, ∀ a : N, 1 ≤ d a * (dist α (j z a) * A) :=\n\nProof body:\n","rejected":"by\n -- A useful inequality to keep at hand\n have me0 : 0 < max (1 / ε) M := lt_max_iff.mpr (Or.inl (one_div_pos.mpr e0))\n -- The maximum between `1 / ε` and `M` works\n refine ⟨max (1 / ε) M, me0, fun z a => ?_⟩\n -- First, let's deal with the easy case in which we are far away from `α`\n by_cases dm1 : 1 ≤ dist α (j z a) * max (1 / ε) M\n · exact one_le_mul_of_one_le_of_one_le (d0 a) dm1\n · -- `j z a = z / (a + 1)`: we prove that this ratio is close to `α`\n have : j z a ∈ closedBall α ε := by\n refine mem_closedBall'.mp (le_trans ?_ ((one_div_le me0 e0).mpr (le_max_left _ _)))\n exact (le_div_iff₀ me0).mpr (not_le.mp dm1).le\n -- use the \"separation from `1`\" (assumption `L`) for numerators,\n refine (L this).trans ?_\n -- remove a common factor and use the Lipschitz assumption `B`\n gcongr\n · exact zero_le_one.trans (d0 a)\n · refine (B this).trans ?_\n gcongr\n apply le_max_right\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Transcendental","family_id":"exists_one_le_pow_mul_dist","file_id":"mathlib/Mathlib/NumberTheory/Transcendental/Liouville/Basic.lean","sample_id":"13761ac07584773ef45f8b932e4b9f0e9de357d763e2a247f2b92df80cf1b745"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca0ece37f538648c8bd2cc3bd8b01496760c6e681882d406aa385f8c498005e3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"34512ef9c43843c8d9d70235b98e79ba12d9dc4ff3f53677162a62f55f62f9aa","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ae55631f784367385dffe461cfa2e1835f933b3727a81e9f4fdd21cf0578608c","source_sha256":"665254822d507fb5efa98cde8b21daf33fea93a04c746a97b8407d629ce02c74","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [projectiveFamilyFun_congr hP (empty_mem_measurableCylinders α) (cylinder_empty ∅).symm\n MeasurableSet.empty, measure_empty]","hard_negative":false,"metrics":{"chosen_tokens":21,"rejected_tokens":28,"token_jaccard":0.9,"token_length_ratio":1.333333},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"c894261ae545bf8965cd311287c2bba3480338e3d7de4afdd25d76d582342ab7","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.Constructions.Projective\npublic import Mathlib.MeasureTheory.Measure.AddContent\npublic import Mathlib.MeasureTheory.SetAlgebra\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne, Peter Pfaffelhuber\n-/\n/-!\n# Additive content built from a projective family of measures\n\nLet `P` be a projective family of measures on a family of measurable spaces indexed by `ι`.\nThat is, for each finite set `I` of indices, `P I` is a measure on `Π j : I, α j`, and for `J ⊆ I`,\nthe projection from `Π i : I, α i` to `Π i : J, α i` maps `P I` to `P J`.\n\nWe build an additive content `projectiveFamilyContent` on the measurable cylinders, by setting\n`projectiveFamilyContent s = P I S` for `s = cylinder I S`, where `I` is a finite set of indices\nand `S` is a measurable set in `Π i : I, α i`.\n\nThis content will be used to define the projective limit of the family of measures `P`.\nFor a countable index set and a projective family given by a sequence of kernels,\nthe projective limit is given by the Ionescu-Tulcea theorem.\nFor an arbitrary index set but under topological conditions on the spaces, this is the result of\nthe Kolmogorov extension theorem.\n(both results are not yet in Mathlib)\n\n## Main definitions\n\n* `projectiveFamilyContent`: additive content on the measurable cylinders, defined from a projective\n family of measures.\n\n-/\n\n@[expose] public section\n\n\nopen Finset\n\nopen scoped ENNReal\n\nnamespace MeasureTheory\n\nvariable {ι : Type*} {α : ι → Type*} {mα : ∀ i, MeasurableSpace (α i)}\n {P : ∀ J : Finset ι, Measure (Π j : J, α j)} {s t : Set (Π i, α i)} {I : Finset ι}\n {S : Set (Π i : I, α i)}\n\nsection MeasurableCylinders\n\nlemma isSetAlgebra_measurableCylinders : IsSetAlgebra (measurableCylinders α) where\n empty_mem := empty_mem_measurableCylinders α\n compl_mem _ := compl_mem_measurableCylinders\n union_mem _ _ := union_mem_measurableCylinders\n\nlemma isSetRing_measurableCylinders : IsSetRing (measurableCylinders α) :=\n isSetAlgebra_measurableCylinders.isSetRing\n\nlemma isSetSemiring_measurableCylinders : MeasureTheory.IsSetSemiring (measurableCylinders α) :=\n isSetRing_measurableCylinders.isSetSemiring\n\nend MeasurableCylinders\n\nsection ProjectiveFamilyFun\n\nopen Classical in\n/-- For `P` a family of measures, with `P J` a measure on `Π j : J, α j`, we define a function\n`projectiveFamilyFun P s` by setting it to `P I S` if `s = cylinder I S` for a measurable `S` and\nto 0 if `s` is not a measurable cylinder. -/\nnoncomputable def projectiveFamilyFun (P : ∀ J : Finset ι, Measure (Π j : J, α j))\n (s : Set (Π i, α i)) : ℝ≥0∞ :=\n if hs : s ∈ measurableCylinders α\n then P (measurableCylinders.finset hs) (measurableCylinders.set hs) else 0\n\nlemma projectiveFamilyFun_congr (hP : IsProjectiveMeasureFamily P)\n (hs : s ∈ measurableCylinders α) (hs_eq : s = cylinder I S) (hS : MeasurableSet S) :\n projectiveFamilyFun P s = P I S := by\n rw [projectiveFamilyFun, dif_pos hs]\n exact hP.congr_cylinder (measurableCylinders.measurableSet hs) hS\n ((measurableCylinders.eq_cylinder hs).symm.trans hs_eq)\n\nTarget:\nlemma projectiveFamilyFun_empty (hP : IsProjectiveMeasureFamily P) :\n projectiveFamilyFun P ∅ = 0 :=\n\nProof body:\n","rejected":"```lean\nby\n rw [projectiveFamilyFun_congr hP (empty_mem_measurableCylinders α) (cylinder_empty ∅).symm\n MeasurableSet.empty, measure_empty]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/Constructions","family_id":"projectivefamilyfun_empty","file_id":"mathlib/Mathlib/MeasureTheory/Constructions/ProjectiveFamilyContent.lean","sample_id":"ae55631f784367385dffe461cfa2e1835f933b3727a81e9f4fdd21cf0578608c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8d2fa480514081d3b91e91ea88daea8af13410bf972221386a2911aeb59d5e6e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"21f355198931c3293103244a9e0ebc3932f67eb05d14dfd941fa7c5e6f9f78c6","source_sha256":"a0c4f879a338ab6470bdd61aa6cb4790c1abee3840d61f2c802fcb6c81cb3ac9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro s\n refine ⟨?_, TensorProduct.includeLeftSubRight_zero_of_mem_range⟩\n intro hs\n use g s\n apply (TensorProduct.lid R S).symm.injective\n rw [TensorProduct.lid_symm_apply, TensorProduct.lid_symm_apply,\n ← mul_one ((Algebra.linearMap R S) _), Algebra.coe_linearMap, ← Algebra.smul_def,\n ← TensorProduct.smul_tmul, smul_eq_mul, mul_one, ← AlgHom.id_apply (R := R) (1 : S),\n ← TensorProduct.map_tmul,\n sub_eq_zero.mp ((TensorProduct.includeLeftSubRight_apply s).symm.trans hs),\n TensorProduct.map_tmul, map_one, AlgHom.id_apply]","hard_negative":false,"metrics":{"chosen_tokens":117,"rejected_tokens":2,"token_jaccard":0.021277,"token_length_ratio":0.017094},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"c96a54b9bffe3efb46fc532a579734d195d23289fb357151fa0aec80d3bd8a11","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.Ring.Constructions\npublic import Mathlib.RingTheory.Flat.FaithfullyFlat.Algebra\n\nNamespace:\nAlgebra.IsEffective\n\nLocal context:\n/-\nCopyright (c) 2025 Yong-Gyu Choi. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yong-Gyu Choi\n-/\n/-!\n# Exactness properties of the difference map on tensor products\n\nFor an `R`-algebra `S`, we collect some properties of the `R`-linear map `S →ₗ[R] S ⊗[R] S` given\nby `s ↦ s ⊗ₜ 1 - 1 ⊗ₜ s`.\n\n## Main definitions\n\n* `includeLeftSubRight`: The `R`-linear map sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`.\n* `IsEffective`: Exactness of the sequence `R → S → S ⊗[R] S` where the first map is\n `Algebra.linearMap R S` and the second map is `includeLeftSubRight`. When `R` and `S` are\n commutative rings, this is equivalent to the inclusion `im (algebraMap : R → S) → S` being an\n effective monomorphism in `CommRingCat`.\n\n## Main results\n\n* `IsEffective.of_faithfullyFlat`: `IsEffective R S` is true for any faithfully flat `R`-algebra `S`\n\n-/\n\n@[expose] public section\n\nopen scoped TensorProduct\n\nnamespace Algebra\n\nvariable {R : Type*} [CommSemiring R]\nvariable {S : Type*} [Ring S] [Algebra R S]\n\nnamespace TensorProduct\n\nsection IncludeLeftSubRight\n\nvariable (R S) in\n/-- The `R`-linear map `S →ₗ[R] S ⊗[R] S` sending `s : S` to `s ⊗ₜ 1 - 1 ⊗ₜ s`. -/\ndef includeLeftSubRight : S →ₗ[R] S ⊗[R] S :=\n includeLeft.toLinearMap - includeRight.toLinearMap\n\n@[simp]\nlemma includeLeftSubRight_apply (s : S) : includeLeftSubRight R S s = s ⊗ₜ[R] 1 - 1 ⊗ₜ[R] s :=\n rfl\n\n/-- `includeLeftSubRight R S` vanishes in the range of `algebraMap R S`. -/\nlemma includeLeftSubRight_zero_of_mem_range {s : S} (hs : s ∈ Set.range ⇑(algebraMap R S)) :\n includeLeftSubRight R S s = 0 := by\n obtain ⟨_, hr⟩ := Set.mem_range.mp hs\n simp [← hr, algebraMap_eq_smul_one]\n\n/-- `includeLeftSubRight R S` vanishes at `algebraMap R S r`. -/\nlemma includeLeftSubRight_algebraMap_zero (r : R) :\n includeLeftSubRight R S (algebraMap R S r) = 0 :=\n includeLeftSubRight_zero_of_mem_range (Set.mem_range.mp (exists_apply_eq_apply _ _))\n\n/-- `includeLeftSubRight` is compatible with `distribBaseChange` and `lTensor`. -/\nlemma distribBaseChange_comp_includeLeftSubRight (T : Type*) [CommRing T] [Algebra R T] :\n ((TensorProduct.AlgebraTensorModule.distribBaseChange R T S S).restrictScalars R).toLinearMap ∘ₗ\n (includeLeftSubRight R S).lTensor T =\n (includeLeftSubRight T (T ⊗[R] S)).restrictScalars R := by\n ext\n simp [TensorProduct.tmul_sub, TensorProduct.one_def, tmul_one_tmul_one_tmul]\n\n@[simp]\nlemma distribBaseChange_includeLeftSubRight_apply (T : Type*) [CommRing T] [Algebra R T]\n (x : T ⊗[R] S) :\n TensorProduct.AlgebraTensorModule.distribBaseChange R T S S\n ((includeLeftSubRight R S).lTensor T x) =\n includeLeftSubRight T (T ⊗[R] S) x :=\n congr($(distribBaseChange_comp_includeLeftSubRight _) x)\n\nend IncludeLeftSubRight\n\nend TensorProduct\n\nvariable (R S) in\n/-- For an `R`-algebra `S`, this asserts that the maps `algebraMap : R → S` and\n`includeLeftSubRight R S : S → S ⊗[R] S` form an exact pair.\nWhen `R` and `S` are commutative rings, this is true if and only if the inclusion\n`im (algebraMap : R → S) → S` is an effective monomorphism in the category of commutative rings. -/\ndef IsEffective : Prop :=\n Function.Exact (Algebra.linearMap R S) (TensorProduct.includeLeftSubRight R S)\n\nnamespace IsEffective\n\n/-- If `IsEffective R S` is true, then the equalizer of `s ↦ s ⊗ₜ 1 : S →+* S ⊗[R] S` and\n`s ↦ 1 ⊗ₜ s : S →+* S ⊗[R] S` is the image of `algebraMap R S : R →+* S`. -/\nlemma eqLocus_includeLeft_includeRight (h : IsEffective R S) :\n TensorProduct.includeLeftRingHom.eqLocus TensorProduct.includeRight.toRingHom (S := S ⊗[R] S) =\n Set.range (algebraMap R S) := by\n ext s\n refine ⟨?_, fun ⟨_, hr⟩ ↦ by simp [← hr]⟩\n intro hs\n exact (h s).mp <| (TensorProduct.includeLeftSubRight_apply (R := R) s).symm ▸ sub_eq_zero.mpr hs\n\n/-- `IsEffective` is true for any `R`-algebra `S` having an `R`-algebra section of\n`Algebra.ofId _ _ : R →ₐ[R] S`. -/\n\nTarget:\nlemma of_section (g : S →ₐ[R] R) : IsEffective R S :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/TensorProduct","family_id":"of_section","file_id":"mathlib/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean","sample_id":"21f355198931c3293103244a9e0ebc3932f67eb05d14dfd941fa7c5e6f9f78c6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"26bc9fb87fe788f151e695b88add74d504fa3115b8affe9069b99e07bbd8c054","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"34c29c5acb24acd2a7dc614f43883c593d4788ce1271877f54c85f0ba0521e6b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da1bef5e53f16752ac8b7c2236f25380b32f5d66fd1e520850abd9d3a7231cf5","source_sha256":"1ea87511faa4a09576c2d6c82d012e31d7cfe664d9616e16ba1fd01753abb77e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← mrange_mk, MonoidHom.mrange_eq_map, ← closure_range_of, MonoidHom.map_mclosure,\n ← range_comp, Sum.range_eq]; rfl","hard_negative":true,"metrics":{"chosen_tokens":26,"rejected_tokens":3,"token_jaccard":0.052632,"token_length_ratio":0.115385},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"c9bdd7448fd20d9fce6aa7b1414c82beaa32ac31e9dda10a4f53d0758cfc9953","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.PUnit\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.Algebra.Group.Submonoid.Membership\npublic import Mathlib.GroupTheory.Congruence.Basic\n\nNamespace:\nMonoid.Coprod\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Coproduct (free product) of two monoids or groups\n\nIn this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)\nto be the coproduct (a.k.a. free product) of two monoids.\nThe same type is used for the coproduct of two monoids and for the coproduct of two groups.\n\nThe coproduct `M ∗ N` has the following universal property:\nfor any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,\nthere exists a unique homomorphism `fg : M ∗ N →* P`\nsuch that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,\nwhere `Monoid.Coprod.inl : M →* M ∗ N`\nand `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.\nThis homomorphism `fg` is given by `Monoid.Coprod.lift f g`.\n\nWe also define some homomorphisms and isomorphisms about `M ∗ N`,\nand provide additive versions of all definitions and theorems.\n\n## Main definitions\n\n### Types\n\n* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):\n the free product (a.k.a. coproduct) of two monoids `M` and `N`.\n* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.\n\nIn other sections, we only list multiplicative definitions.\n\n### Instances\n\n* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.\n\n### Monoid homomorphisms\n\n* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.\n\n* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.\n\n* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`\n from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.\n\n* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`\n that allows the user to control the computational behavior.\n\n* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`\n into `M ∗ M' →* N ∗ N'`.\n\n* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.\n\n* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:\n natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.\n\n### Monoid isomorphisms\n\n* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.\n* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.\n* `MulEquiv.coprodAssoc`: associativity of the coproduct.\n* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:\n free product by `PUnit` on the left or on the right is isomorphic to the original monoid.\n\n## Main results\n\nThe universal property of the coproduct\nis given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.\n\nWe also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`\nfor homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.\n\n## Implementation details\n\nThe definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.\nWhile mathematically `M ∗ N` is a particular case\nof the coproduct of an indexed family of monoids,\nit is easier to build API from scratch instead of using something like\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI ![M, N]\n```\n\nor\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)\n```\n\nThere are several reasons to build an API from scratch.\n\n- API about `Con` makes it easy to define the required type and prove the universal property,\n so there is little overhead compared to transferring API from `Monoid.CoprodI`.\n- If `M` and `N` live in different universes, then the definition has to add `ULift`s;\n this makes it harder to transfer API and definitions.\n- As of now, we have no way\n to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`\n from `[Monoid M]` and `[Monoid N]`,\n not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.\n- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`\n as the underlying type makes it possible to write computationally effective code\n (though this point is not tested yet).\n\n## TODO\n\n- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and\n `Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.\n\n## Tags\n\ngroup, monoid, coproduct, free product\n-/\n\n@[expose] public section\n\nassert_not_exists MonoidWithZero\n\nopen FreeMonoid Function List Set\n\nnamespace Monoid\n\n/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`\nsuch that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms\nto the quotient by `c`. -/\n@[to_additive /-- The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`\nsuch that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`\nare additive monoid homomorphisms to the quotient by `c`. -/]\ndef coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=\n sInf {c |\n (∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))\n ∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))\n ∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}\n\n/-- Coproduct of two monoids or groups. -/\n@[to_additive /-- Coproduct of two additive monoids or groups. -/]\ndef Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient\n\nnamespace Coprod\n\n@[inherit_doc]\nscoped infix:30 \" ∗ \" => Coprod\n\nsection MulOneClass\n\nvariable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']\n [MulOneClass P]\n\n@[to_additive] protected instance : MulOneClass (M ∗ N) :=\n inferInstanceAs <| MulOneClass (coprodCon M N).Quotient\n\n/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/\n@[to_additive /-- The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`. -/]\ndef mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _\n\n@[to_additive (attr := simp)]\ntheorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _\n\n@[to_additive]\ntheorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective\n\n@[to_additive (attr := simp)]\ntheorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'\n\n@[to_additive]\ntheorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _\n\n/-- The natural embedding `M →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `M →+ AddMonoid.Coprod M N`. -/]\ndef inl : M →* M ∗ N where\n toFun := fun x => mk (of (.inl x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y\n\n/-- The natural embedding `N →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `N →+ AddMonoid.Coprod M N`. -/]\ndef inr : N →* M ∗ N where\n toFun := fun x => mk (of (.inr x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl\n\n@[to_additive (attr := elab_as_elim)]\ntheorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)\n (one : C 1)\n (inl_mul : ∀ m x, C x → C (inl m * x))\n (inr_mul : ∀ n x, C x → C (inr n * x)) : C m := by\n rcases mk_surjective m with ⟨x, rfl⟩\n induction x using FreeMonoid.inductionOn' with\n | one => exact one\n | mul_of x xs ih =>\n cases x with\n | inl m => simpa using inl_mul m _ ih\n | inr n => simpa using inr_mul n _ ih\n\n@[to_additive (attr := elab_as_elim)]\ntheorem induction_on {C : M ∗ N → Prop} (m : M ∗ N)\n (inl : ∀ m, C (inl m)) (inr : ∀ n, C (inr n)) (mul : ∀ x y, C x → C y → C (x * y)) : C m :=\n induction_on' m (by simpa using inl 1) (fun _ _ ↦ mul _ _ (inl _)) fun _ _ ↦ mul _ _ (inr _)\n\n/-- Lift a monoid homomorphism `FreeMonoid (M ⊕ N) →* P` satisfying additional properties to\n`M ∗ N →* P`. In many cases, `Coprod.lift` is more convenient.\n\nCompared to `Coprod.lift`,\nthis definition allows a user to provide a custom computational behavior.\nAlso, it only needs `MulOneClass` assumptions while `Coprod.lift` needs a `Monoid` structure.\n-/\n@[to_additive /-- Lift an additive monoid homomorphism `FreeAddMonoid (M ⊕ N) →+ P` satisfying\nadditional properties to `AddMonoid.Coprod M N →+ P`.\n\nCompared to `AddMonoid.Coprod.lift`,\nthis definition allows a user to provide a custom computational behavior.\nAlso, it only needs `AddZeroClass` assumptions\nwhile `AddMonoid.Coprod.lift` needs an `AddMonoid` structure. -/]\ndef clift (f : FreeMonoid (M ⊕ N) →* P)\n (hM₁ : f (of (.inl 1)) = 1) (hN₁ : f (of (.inr 1)) = 1)\n (hM : ∀ x y, f (of (.inl (x * y))) = f (of (.inl x) * of (.inl y)))\n (hN : ∀ x y, f (of (.inr (x * y))) = f (of (.inr x) * of (.inr y))) :\n M ∗ N →* P :=\n Con.lift _ f <| sInf_le ⟨hM, hN, hM₁.trans (map_one f).symm, hN₁.trans (map_one f).symm⟩\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_inl (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : M) :\n clift f hM₁ hN₁ hM hN (inl x) = f (of (.inl x)) :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_inr (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : N) :\n clift f hM₁ hN₁ hM hN (inr x) = f (of (.inr x)) :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN w) :\n clift f hM₁ hN₁ hM hN (mk w) = f w :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_comp_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) :\n (clift f hM₁ hN₁ hM hN).comp mk = f :=\n DFunLike.ext' rfl\n\n@[to_additive (attr := simp)]\n\nTarget:\ntheorem mclosure_range_inl_union_inr :\n Submonoid.closure (range (inl : M →* M ∗ N) ∪ range (inr : N →* M ∗ N)) = ⊤ :=\n\nProof body:\n","rejected":"by\n exact mclosure_range_inl_union_inr","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"8e04eba0adf60e490fbf004ac8b26ad8957dd109996cb8072834f4ccd19306de","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory/Coprod","family_id":"mclosure_range_inl_union_inr","file_id":"mathlib/Mathlib/GroupTheory/Coprod/Basic.lean","sample_id":"da1bef5e53f16752ac8b7c2236f25380b32f5d66fd1e520850abd9d3a7231cf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4340b8178dce658187fe2d00cc40731483c2db0d7d0d6a3155533ff967498f19","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"46af4ca4ab3e86dea3f8c8aff4337c27204798977f53f0257d844dc75ccebf2f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"890232717f85060b74a3ee0f5945cfb30376f59193c213d21fc2e6e77bfa7a61","source_sha256":"864bb4bb18dcd59ea0d99974e94e6f80f27ed7f81365f8520c597842fa036700","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine le_antisymm ?_ <| (RingCon.gi N).gc.le_u_l _\n have := Relation.map_equivalence c.toSetoid.2 _ hf h\n intro _ _ hg\n induction hg with\n | of _ _ a => exact a\n | refl x => exact this.refl x\n | symm _ h => exact this.symm h\n | trans _ _ h₁ h₂ => exact this.trans h₁ h₂\n | add _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a + p, b + q, c.add h1 h2, map_add f _ _, map_add f _ _⟩\n | mul _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a * p, b * q, c.mul h1 h2, map_mul f _ _, map_mul f _ _⟩","hard_negative":false,"metrics":{"chosen_tokens":212,"rejected_tokens":219,"token_jaccard":0.965517,"token_length_ratio":1.033019},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"ca30e3c125ef2342633e1e1e3d21e21270850658b74da6c748ff005ad23c0d5b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Subalgebra.Lattice\npublic import Mathlib.Algebra.Algebra.Subalgebra.Basic\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Group.Hom.Defs\npublic import Mathlib.RingTheory.Congruence.Basic\npublic import Mathlib.Algebra.Ring.Subsemiring.Basic\npublic import Mathlib.Algebra.Ring.Subring.Basic\npublic import Mathlib.Algebra.RingQuot\n\nNamespace:\nRingCon\n\nLocal context:\n/-\nCopyright (c) 2025 Antoine Chambert-Loir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir\n-/\n/-!\n# Congruence relations and ring homomorphisms\n\nThis file contains elementary definitions involving congruence\nrelations and morphisms for rings and semirings\n\n## Main definitions\n\n* `RingCon.ker`: the kernel of a monoid homomorphism as a congruence relation\n* `RingCon.lift`, `RingCon.liftₐ`: the homomorphism / the algebra morphism\n on the quotient given that the congruence is in the kernel\n* `RingCon.map`, `RingCon.mapₐ`: homomorphism / algebra morphism\n from a smaller to a larger quotient\n\n* `RingCon.quotientKerEquivRangeS`, `RingCon.quotientKerEquivRange`,\n `RingCon.quotientKerEquivRangeₐ` :\n the first isomorphism theorem for semirings (using `RingHom.rangeS`),\n rings (using `RingHom.range`) and algebras (using `AlgHom.range`).\n* `RingCon.comapQuotientEquivRangeS`, `RingCon.comapQuotientEquivRange`,\n `RingCon.comapQuotientEquivRangeₐ` : the second isomorphism theorem\n for semirings (using `RingHom.rangeS`), rings (using `RingHom.range`)\n and algebras (using `AlgHom.range`).\n\n* `RingCon.quotientQuotientEquivQuotient`, `RingCon.quotientQuotientEquivQuotientₐ` :\n the third isomorphism theorem for semirings (or rings) and algebras\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, ring,\nquotient ring\n-/\n\n@[expose] public section\n\nvariable {M : Type*} {N : Type*} {P : Type*}\n\nopen Function Setoid\n\nnamespace RingCon\n\nsection\n\nvariable [NonAssocSemiring M] [NonAssocSemiring N] [NonAssocSemiring P] {c d : RingCon M}\n\n/-- The kernel of a ring homomorphism as a ring congruence relation. -/\ndef ker (f : M →+* N) : RingCon M := comap ⊥ f\n\ntheorem comap_bot (f : M →+* N) : comap ⊥ f = ker f := rfl\n\n/-- The definition of the ring congruence relation defined by a ring homomorphism's kernel. -/\n@[simp]\ntheorem ker_apply (f : M →+* N) {x y} : ker f x y ↔ f x = f y :=\n Iff.rfl\n\n/-- The kernel of the quotient map induced by a ring congruence relation `c` equals `c`. -/\ntheorem ker_mk'_eq (c : RingCon M) : ker c.mk' = c :=\n ext fun _ _ => Quotient.eq''\n\ntheorem ker_comp {f : M →+* N} {g : N →+* P} :\n ker (g.comp f) = (ker g).comap f :=\n ext fun x y ↦ by simp [ker_apply, comap_rel]\n\ntheorem comap_eq {g : N →+* M} :\n c.comap g = ker (c.mk'.comp g) := by\n rw [ker_comp, ker_mk'_eq]\n\n/-- Makes an isomorphism of quotients by two ring congruence\nrelations, given that the relations are equal. -/\nprotected def congr (h : c = d) :\n c.Quotient ≃+* d.Quotient :=\n { Quotient.congr (Equiv.refl M) <| by apply RingCon.ext_iff.mp h with\n map_add' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl\n map_mul' x y := by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl }\n\n@[simp] theorem congr_mk (h : c = d) (a : M) :\n RingCon.congr h (a : c.Quotient) = (a : d.Quotient) := rfl\n\n/-- Given a function `f`, the smallest ring congruence relation containing the binary\nrelation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to\nthe elements of `f⁻¹(y)` by a ring congruence relation `c`.' -/\ndef mapGen {c : RingCon M} (f : M → N) : RingCon N :=\n ringConGen <| Relation.Map c f f\n\n/-- If `c` is a ring congruence on `M`, then the smallest ring\ncongruence relation on `N` deduced from `c` by a ring homomorphism\nfrom `M` to `N` is the relation deduced from `c`. -/\n\nTarget:\ntheorem mapGen_eq_map_of_surjective\n {c : RingCon M} (f : M →+* N) (h : ker f ≤ c) (hf : Surjective f) :\n c.mapGen f = Relation.Map c f f :=\n\nProof body:\n","rejected":"```lean\nby\n refine le_antisymm ?_ <| (RingCon.gi N).gc.le_u_l _\n have := Relation.map_equivalence c.toSetoid.2 _ hf h\n intro _ _ hg\n induction hg with\n | of _ _ a => exact a\n | refl x => exact this.refl x\n | symm _ h => exact this.symm h\n | trans _ _ h₁ h₂ => exact this.trans h₁ h₂\n | add _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a + p, b + q, c.add h1 h2, map_add f _ _, map_add f _ _⟩\n | mul _ _ h₁ h₂ =>\n rcases h₁ with ⟨a, b, h1, rfl, rfl⟩\n rcases h₂ with ⟨p, q, h2, rfl, rfl⟩\n exact ⟨a * p, b * q, c.mul h1 h2, map_mul f _ _, map_mul f _ _⟩\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Congruence","family_id":"mapgen_eq_map_of_surjective","file_id":"mathlib/Mathlib/RingTheory/Congruence/Hom.lean","sample_id":"890232717f85060b74a3ee0f5945cfb30376f59193c213d21fc2e6e77bfa7a61"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"58dc36a533c41a174ff8b90602fdc9c1afaf0df2dcf8a4d066755a6957d2ca90","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7ff0fc2a0a97237c08f673950d8990d8c2dcbebec0d71f8138d18d20141cef8a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cf27d863d0a7ccaf644321e841c2aa5a4618841f2f7f1089ce62e166fa5434ad","source_sha256":"762d4efec1ee6a79a6c86c42986c8ac0f53471a532b94ae1f0d16f599c3f5f2f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let e := orderIsoIsTwoSided (R := R)\n simp_rw [isSimpleRing_iff, isSimpleOrder_iff, orderIsoRingCon.toEquiv.nontrivial_congr,\n RingCon.nontrivial_iff, e.forall_congr_left, Subtype.forall, ← e.injective.eq_iff]\n simp [e, Subtype.ext_iff]","hard_negative":true,"metrics":{"chosen_tokens":49,"rejected_tokens":3,"token_jaccard":0.033333,"token_length_ratio":0.061224},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"ca3fd4faac61df5d1a392899ee125cd0ebeed8e2a1ba9dd54ef8da33cb012591","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.SimpleRing.Basic\npublic import Mathlib.RingTheory.TwoSidedIdeal.Operations\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2025 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n-/\n/-!\n# Simplicity is preserved by ring isomorphisms/surjective ring homomorphisms\n\nIf `R` is a simple (non-assoc) ring and there exists surjective `f : R →+* S` where `S` is\nnontrivial, then `S` is also simple.\nIf `R` is a simple (non-unital non-assoc) ring then any ring isomorphic to `R` is also simple.\n-/\n\npublic section\n\nnamespace IsSimpleRing\n\nlemma of_surjective {R S : Type*} [NonAssocRing R] [NonAssocRing S] [Nontrivial S]\n (f : R →+* S) (h : IsSimpleRing R) (hf : Function.Surjective f) : IsSimpleRing S where\n simple := OrderIso.isSimpleOrder (RingEquiv.ofBijective f\n ⟨RingHom.injective f, hf⟩).symm.mapTwoSidedIdeal\n\nlemma of_ringEquiv {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n (f : R ≃+* S) (h : IsSimpleRing R) : IsSimpleRing S where\n simple := OrderIso.isSimpleOrder f.symm.mapTwoSidedIdeal\n\nend IsSimpleRing\n\nopen TwoSidedIdeal in\n\nTarget:\ntheorem isSimpleRing_iff_isTwoSided_imp {R : Type*} [Ring R] :\n IsSimpleRing R ↔ Nontrivial R ∧ ∀ I : Ideal R, I.IsTwoSided → I = ⊥ ∨ I = ⊤ :=\n\nProof body:\n","rejected":"by\n exact isSimpleRing_iff_isTwoSided_imp","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"dc8d02e28e65dd357995dc1745d349a2d7a31b2af0c41dc30299e99592367567","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/SimpleRing","family_id":"issimplering_iff_istwosided_imp","file_id":"mathlib/Mathlib/RingTheory/SimpleRing/Congr.lean","sample_id":"cf27d863d0a7ccaf644321e841c2aa5a4618841f2f7f1089ce62e166fa5434ad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a8e3d8fb688ab1229bd8cd7bcfe5f7d9e7e2758bf845ae01e3eb2f6b658975ff","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6d2093bbe881216b7accab5fcc348aac399f23c381d948de399abfefa6c8a543","source_sha256":"fba9f03949fb71c822ca9bce084299af5da1008b68ee86b47a488c537325bc59","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (s.finite_toSet.biUnion hf).subset fun a ha ↦ ?_\n simp only [mem_mulSupport, SetLike.mem_coe, Set.mem_iUnion, exists_prop] at ha ⊢\n contrapose! ha\n exact Finset.sup'_eq_of_forall hs (fun x ↦ f x a) ha","hard_negative":false,"metrics":{"chosen_tokens":61,"rejected_tokens":2,"token_jaccard":0.052632,"token_length_ratio":0.032787},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"cbd0bb64bff89f02b7b6d3b58e4dec58fe2d4f7aa1d9423fdfb089113574ed49","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmas\npublic import Mathlib.Algebra.FiniteSupport.Defs\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.GroupWithZero.Action.Defs\npublic import Mathlib.Algebra.Order.Group.Indicator\npublic import Mathlib.Data.Set.Finite.Lattice\nimport Mathlib.Algebra.GroupWithZero.Indicator\nimport Mathlib.Algebra.Module.Basic\n\nNamespace:\nFunction\n\nLocal context:\n/-\nCopyright (c) 2026 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Make `fun_prop` work for finite (multiplicative) support\n\nWe provide API lemmas for the predicate `HasFiniteMulSupport` (and its additivized version\n`HasFiniteSupport`) on functions so that `fun_prop` can prove it for functions that are\nbuilt from other functions with finite multiplicative support.\n-/\n\npublic section\n\nnamespace Function\n\nvariable {α M : Type*} [One M]\n\n@[to_additive (attr := fun_prop)]\nlemma hasFiniteMulSupport_fun_one : HasFiniteMulSupport (1 : α → M) := by\n simp [HasFiniteMulSupport]\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fun_comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport fun a ↦ g (f a) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.comp {N : Type*} [One N] {g : M → N} {f : α → M}\n (hf : HasFiniteMulSupport f) (hg : g 1 = 1) :\n HasFiniteMulSupport (g ∘ f) :=\n hf.subset <| mulSupport_comp_subset hg f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.fst {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).fst :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.snd {M' : Type*} [One M'] {f : α → M × M'} (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport fun a ↦ (f a).snd :=\n hf.comp rfl\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prodMk {M' : Type*} [One M'] {f : α → M} {g : α → M'}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ (f a, g a) := by\n simp only [HasFiniteMulSupport] at hf hg ⊢\n rw [mulSupport_prodMk f g]\n exact hf.union hg\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.mul {M : Type*} [MulOneClass M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f * g) :=\n (hf.union hg).subset <| mulSupport_mul ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.inv {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) :\n HasFiniteMulSupport f⁻¹ :=\n hf.comp inv_one\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.prod {M : Type*} [CommMonoid M] {ι : Type*} {f : ι → α → M}\n (hf : ∀ i, HasFiniteMulSupport (f i)) (s : Finset ι) :\n HasFiniteMulSupport fun a ↦ ∏ i ∈ s, f i a :=\n (s.finite_toSet.biUnion fun i _ ↦ hf i).subset <| s.mulSupport_prod f\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.div {M : Type*} [DivisionMonoid M] {f g : α → M}\n (hf : HasFiniteMulSupport f) (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport (f / g) :=\n (hf.union hg).subset <| mulSupport_div ..\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.pow {M : Type*} [Monoid M] {f : α → M} (hf : HasFiniteMulSupport f)\n (n : ℕ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_pow n)\n\n@[to_additive (attr := to_fun (attr := fun_prop))]\nlemma HasFiniteMulSupport.zpow {M : Type*} [DivisionMonoid M] {f : α → M}\n (hf : HasFiniteMulSupport f) (n : ℤ) :\n HasFiniteMulSupport (f ^ n) :=\n hf.comp (one_zpow n)\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.max [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ max (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_max ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.min [LinearOrder M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ min (f a) (g a) :=\n (hf.union hg).subset <| mulSupport_min ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.sup [SemilatticeSup M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊔ g a :=\n (hf.union hg).subset <| mulSupport_sup ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.inf [SemilatticeInf M] {f g : α → M} (hf : HasFiniteMulSupport f)\n (hg : HasFiniteMulSupport g) :\n HasFiniteMulSupport fun a ↦ f a ⊓ g a :=\n (hf.union hg).subset <| mulSupport_inf ..\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iSup [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨆ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iSup f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.iInf [ConditionallyCompleteLattice M] {ι : Sort*} [Nonempty ι]\n [Finite ι] {f : ι → α → M} (hf : ∀ i, HasFiniteMulSupport (f i)) :\n HasFiniteMulSupport fun a ↦ ⨅ i, f i a :=\n (Set.finite_iUnion hf).subset <| mulSupport_iInf f\n\n@[to_additive (attr := fun_prop)]\nlemma HasFiniteMulSupport.pi {ι : Type*} [Finite α] {f : ι → α → M}\n (hf : ∀ a, HasFiniteMulSupport (f · a)) :\n HasFiniteMulSupport f := by\n simp only [HasFiniteMulSupport] at hf ⊢\n refine (Set.finite_iUnion hf).subset fun i hi ↦ ?_\n simp only [mem_mulSupport, Set.mem_iUnion] at hi ⊢\n exact ne_iff.mp hi\n\n@[to_additive (attr := fun_prop)]\n\nTarget:\nlemma HasFiniteMulSupport.sup' [SemilatticeSup M] {ι : Type*} {f : ι → α → M}\n (s : Finset ι) (hf : ∀ i ∈ s, HasFiniteMulSupport (f i)) (hs : s.Nonempty) :\n HasFiniteMulSupport fun a ↦ s.sup' hs (f · a) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FiniteSupport","family_id":"hasfinitemulsupport","file_id":"mathlib/Mathlib/Algebra/FiniteSupport/Basic.lean","sample_id":"6d2093bbe881216b7accab5fcc348aac399f23c381d948de399abfefa6c8a543"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"58f322405e534f0d4cb401bb9744c33aeca82cada0493b153f18c04c49aae0c1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2e64f99f622cb61b8c65a684b0fcf1eba8006194457e33fcefa20430142a57ad","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"483039e48e2da099ff0692e4d7d021895d6e250d5b5bf5d8df66c6ba8e765f8d","source_sha256":"ea49da8fadbef6df5542f48b737813b13b1fd6e8a00c791df91871e459b5fa18","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa [cylinder_eq_set_pi U x] using isClosed_set_pi (by simp)","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.153846},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"cc53e3656c2a7975b4c2cab691f9497dfbf0f1a5eb5d1f39e67806036206706c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Separation.Basic\n\nNamespace:\nSymbolicDynamics.FullShift\n\nLocal context:\n/-\nCopyright (c) 2025 Silvère Gangloff. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Silvère Gangloff\n-/\n/-!\n# Symbolic dynamics on cancellative monoids\n\nThis file develops a minimal API for symbolic dynamics over a\n**left-cancellative monoid** `G`—formally, a structure carrying `[Monoid G]`\nand `[IsLeftCancelMul G]` (which becomes `[AddMonoid G]` and\n`[IsLeftCancelAdd G]` in the additive form). Throughout the documentation we use the\n**additive** notations, which are the most common in symbolic dynamics, although\nall the notions introduced are defined in the multiplicative notations and adapted\nto the additive notation.\n\nGiven a finite alphabet `A`, the ambient configuration space is the set of\nfunctions `G → A`, endowed with the product topology. We define the\nleft-translation action, cylinders, finite patterns, their occurrences,\nforbidden sets, and subshifts (closed, shift-invariant subsets). Basic\ntopological facts (e.g. cylinders are clopen, occurrence sets are clopen,\nforbidden sets are closed) are proved under discreteness assumptions on\nthe alphabet.\n\nThe development is generic for left-cancellative monoids. This covers both\ngroups (the standard setting of symbolic dynamics) and more general monoids\nwhere cancellation holds but inverses may not exist. Geometry specific to\n`ℤ^d` (boxes/cubes and the box-based entropy) is deferred to a separate\nspecialization.\n\n## Why cancellativity?\n\nSome constructions, such as translating a finite pattern to occur at a point `v`,\nrequire solving equations of the form `w + v = h`. For this to have a unique\nsolution `w` given `h` and `v`, we assume **left-cancellation**:\nif `v + a = v + b` then `a = b`. This allows us to define\n`Pattern.shift` (which shifts a pattern) without using inverses,\nso that the theory works not only for groups but also for cancellative monoids.\n\n## Main definitions\n\n* `shift g x` — left translation: in additive notation `(shift v x) u = x (v + u)` (using the\n**left** action of `G` on configurations).\n* `cylinder U x` — configurations agreeing with `x` on a finite set `U ⊆ G`.\n* `Pattern A G` — a configuration which takes\ndefault value outside of a finite support, together with this support.\n* `Pattern.occursInAt p x g` — occurrence of `p` in `x` at translate `g`.\n* `forbidden F` — configurations avoiding every pattern in `F`.\n* `Subshift A G` — closed, shift-invariant subsets of the full shift.\n* `MulSubshift.ofForbidden F` — the subshift defined by forbidding a family of patterns.\n* `subshift_of_finite_type F` — a subshift of finite type defined by a finite set of\nforbidden patterns.\n* `languageOn X U` — the set of patterns of shape `U` obtained by restricting some `x ∈ X`.\n\n## Design choice: ambient vs. inner (subshift-relative) viewpoint\n\nAll core notions (shift, cylinder, occurrence, language, …) are defined **in the\nambient full shift** `G → A`. A subshift is then a closed, invariant subset,\nbundled as `Subshift A G`. Working inside a subshift is done by restriction.\n\n**Motivation.**\n\nIf cylinders and shifts were defined only *inside* a subshift, local ergonomics\nwould improve but global operations would become awkward. For instance, to prove\nthat for finite shape `U`:\n\n`languageOn (X ∪ Y) U = languageOn X U ∪ languageOn Y U,`\n\none must eventually move both sides to the ambient pattern type. Similar issues\narise for intersections, factors, and products. By contrast, with ambient\ndefinitions these set-theoretic identities are tautological.\nThus the file develops the theory ambiently, and subshifts reuse it by restriction.\n\n**Working inside a subshift.**\n\nFor `Y : Subshift A G`, cylinders and occurrence sets *inside `Y`* are simply\npreimages of the ambient ones under the inclusion `Y → (G → A)`. For example:\n\n`{ y : Y | ∀ i ∈ U, (y : G → A) i = (x : G → A) i } = (Subtype.val) ⁻¹' (cylinder U (x : G → A)).`\n\nShift invariance guarantees that the ambient shift restricts to `Y`.\n\n**Ergonomics.**\n\nThin wrappers (e.g. `Subshift.shift`, `Subshift.cylinder`, `Subshift.languageOn`)\nmay be added for convenience. They introduce no new theory and unfold to the\nambient definitions.\n\n## Namespacing policy\n\nAll ambient definitions live under the namespace `SymbolicDynamics.FullShift`.\nIf inner, subshift-relative wrappers are provided, they will be placed in the\nsubnamespace `SymbolicDynamics.Subshift`. This separation avoids name clashes\nbetween the two viewpoints, since both may naturally want to reuse names like\n`cylinder`, `shift`, `occursAt`, or `languageOn`.\n\n## Implementation notes\n\n* Openness results for cylinders and occurrence sets use\n `[DiscreteTopology A]`. Closeness results use `[T1Space A]`.\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Set Topology\n\nnamespace SymbolicDynamics\n\nnamespace FullShift\n\n/-! ## Full shift and shift action -/\n\nsection ShiftDefinition\n\nvariable {A G : Type*} [Monoid G]\n\n/-- The **left-translation shift** on configurations.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the monoid, the shifted configuration\n`mulShift g x` is defined by `(mulShift g x) h = x (g * h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g * h` in the original one.\n\nFor example, if `G = ℤ` (with addition) and `A = {0, 1}`, then\n`mulShift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/\n@[to_additive /-- The **left-translation shift** on configurations, in additive notation.\n\nWe call *configuration* an element of `G → A`.\n\nGiven a configuration `x : G → A` and an element `g : G` of the additive monoid,\nthe shifted configuration `shift g x` is defined by `(shift g x) h = x (g + h)`.\n\nIntuitively, this moves the whole configuration \"in the direction of `g`\": the value\nat position `h` in the shifted configuration is the value that was at position\n`g + h` in the original one.\n\nFor example, if `G = ℤ` and `A = {0, 1}`, then\n`shift 1 x` is the sequence obtained from `x` by shifting every symbol one\nstep to the left. -/]\ndef mulShift (g : G) (x : G → A) : G → A :=\n fun h => x (g * h)\n\n@[to_additive (attr := simp)] lemma mulShift_apply (g : G) (x : G → A) (h : G) :\n mulShift g x h = x (g * h) := rfl\n\n@[to_additive (attr := simp)] lemma mulShift_one (x : G → A) : mulShift (1 : G) x = x := by\n ext h; simp [mulShift]\n\n/-- Composition of left-translation shifts corresponds to multiplication in the monoid `G`. -/\n@[to_additive] lemma mulShift_mul (g₁ g₂ : G) (x : G → A) :\n mulShift (g₁ * g₂) x = mulShift g₂ (mulShift g₁ x) := by\n ext h; simp [mulShift, mul_assoc]\n\nvariable [TopologicalSpace A]\n\n/-- The left-translation shift is continuous. -/\n@[to_additive (attr := fun_prop)] lemma continuous_mulShift (g : G) :\n Continuous (mulShift (A := A) g) := by\n -- coordinate projections are continuous; composition preserves continuity\n unfold mulShift\n fun_prop\n\nend ShiftDefinition\n\n/-! ## Cylinders -/\n\nsection Cylinders\n\nvariable {A G : Type*}\n\n/-- A *cylinder set* is the set of all configurations that agree with a given\nreference configuration `x` on a fixed finite subset `U` of the index set `G`.\n\nThe set `U` is called the *support* of the cylinder.\n\nIntuitively, cylinders specify the \"letters\" on finitely many coordinates, while\nleaving all other coordinates free. For example, in the full shift `{0, 1}^ℤ`,\nthe cylinder determined by `U = {0, 1}` and `x 0 = 1, x 1 = 0` consists of all\nbi-infinite sequences of `0`s and `1`s whose entries on positions `0` and `1`\nrespectively are `1` and `0`.\n\nWhen `A` has the discrete topology, cylinder sets form a basis of clopen sets\nfor the product topology on `G → A`. -/\ndef cylinder (U : Finset G) (x : G → A) : Set (G → A) :=\n { y | ∀ i ∈ U, y i = x i }\n\n/-- A cylinder set on `U` is the `Set.pi` over `U` of the singletons `{x i}`,\nviewed as a subset of `G → A`. Equivalently, it is the preimage of that product\nof singletons in `U → A` under the restriction map `(G → A) → (U → A)`. -/\nlemma cylinder_eq_set_pi (U : Finset G) (x : G → A) :\n cylinder U x = Set.pi (↑U : Set G) (fun i => ({x i} : Set A)) := by\n ext y; simp [cylinder, Set.pi]\n\nlemma mem_cylinder {U : Finset G} {x y : G → A} :\n y ∈ cylinder U x ↔ ∀ i ∈ U, y i = x i := Iff.rfl\n\nvariable [TopologicalSpace A]\n\n/-- Cylinders are open when `A` is discrete. -/\nlemma isOpen_cylinder [DiscreteTopology A] (U : Finset G) (x : G → A) :\n IsOpen (cylinder U x) := by\n simpa [cylinder_eq_set_pi U x] using isOpen_set_pi (U.finite_toSet) (by simp)\n\n/-- Cylinders are closed when `A` is a T1 Space. -/\n\nTarget:\nlemma isClosed_cylinder [T1Space A] (U : Finset G) (x : G → A) :\n IsClosed (cylinder U x) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_483039e48e2d","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"c1474673e6cb3303b8b946b63a13eb42f7d4c3725c6052a2daecf1a64fff70bb","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/SymbolicDynamics","family_id":"isclosed_cylinder","file_id":"mathlib/Mathlib/Dynamics/SymbolicDynamics/Basic.lean","sample_id":"483039e48e2da099ff0692e4d7d021895d6e250d5b5bf5d8df66c6ba8e765f8d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca66b43720e5683a0decc46b77a69ad6752ea87269332f71cb4e174d0c4ba53f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c8607fdf15a4772063aecb4e30b0f647b6e32e9f052cd93c1524ccbf380858f4","source_sha256":"d4b08401005558805b5961b6d98688b799b79fc82584afe5bc0760ff0387492a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine hasFiniteIntegral_mkD_of_bound _ _ ?_ bound bound_int ?_\n · simpa [← continuousOn_iff_continuous_restrict]\n · simpa","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.071429,"token_length_ratio":0.105263},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"cdc5fc5da9330cc5e25c5d1e49792e8ee0caa7da4a4ca85a20e2fb4615aae1da","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.ContinuousMap.Compact\npublic import Mathlib.Topology.ContinuousMap.Algebra\npublic import Mathlib.MeasureTheory.Integral.IntegrableOn\n\nNamespace:\nContinuousMap\n\nLocal context:\n/-\nCopyright (c) 2025 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\n/-!\n# Specific results about `ContinuousMap`-valued integration\n\nIn this file, we collect a few results regarding integrability, on a measure space `(X, μ)`,\nof a `C(Y, E)`-valued function, where `Y` is a compact topological space and `E` is a normed group.\n\nThese are all elementary from a mathematical point of view, but they require a bit of care in order\nto be conveniently usable. In particular, to accommodate the need of families `f : X → Y → E` such\nthat `f x` is only continuous for *almost every* `x`, we give a variety of results about the\nintegrability of `fun x ↦ ContinuousMap.mkD (f x) g` whose assumptions only mention `f` (so that\nusers don't have to convert between `f` and `fun x ↦ ContinuousMap.mkD (f x) g` by hand).\n\n## Main results\n\n* `hasFiniteIntegral_of_bound`: given `f : X → C(Y, E)`, the natural way to show\n `HasFiniteIntegral f` is to give a `bound : X → ℝ`, which itself has finite integral, and such\n that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.\n* `hasFiniteIntegral_mkD_of_bound` is the `mkD` analog of the above: given `f : X → Y → E` such\n that `f x` is continuous for almost every `x`, as well as a bound as above, we prove\n `HasFiniteIntegral (fun x ↦ mkD (f x) g)`. Note that, conveniently, `mkD` only appears in the\n result.\n* `aeStronglyMeasurable_mkD_of_uncurry`: if now `X` is a topological space with the Borel σ-algebra,\n and `f : X → Y → E` is continuous on `X × Y`, then `fun x ↦ mkD (f x) g` is\n `AEStronglyMeasurable`. Note that this is far from optimal: this function is in fact continuous,\n and one could avoid `mkD` entirely since `f x` is always continuous in that case. Nevertheless,\n this turns out to be most convenient, as we explain below.\n\n## Implementation Note\n\nWe claim that using \"constructors with default values\" such as `ContinuousMap.mkD` is the right way\nto approach integration valued in a functional space `ℱ`. More precisely:\n\n- if you happen to start from a bundled `f : X → ℱ` function, you should be able to use\n the general theory without any issues.\n- if instead you start with a family of bare functions `f : X → Y → E`, to integrate it in `ℱ`, you\n should always consider the family `fun x ↦ ℱ.mkD (f x) 0`, *even if your `f` always lands in `ℱ`*.\n This allows for a unified setting with the case where `f x` belongs to `ℱ` for *almost every `x`*,\n and also avoids entering dependent-types hell.\n\n-/\n\npublic section\n\nopen MeasureTheory\n\nnamespace ContinuousMap\n\nvariable {X Y : Type*} [MeasurableSpace X] {μ : Measure X} [TopologicalSpace Y]\nvariable {E : Type*} [NormedAddCommGroup E]\n\n/-- A natural criterion for `HasFiniteIntegral` of a `C(Y, E)`-valued function is the existence\nof some positive function with finite integral such that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.\nNote that there is no dominated convergence here (hence no first-countability assumption\non `Y`). We are just using the properties of Banach-space-valued integration. -/\nlemma hasFiniteIntegral_of_bound [CompactSpace Y] (f : X → C(Y, E)) (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral f μ := by\n rcases isEmpty_or_nonempty Y with (h | h)\n · simp\n · have bound_nonneg : 0 ≤ᵐ[μ] bound := by\n filter_upwards [bound_ge] with x bound_x using le_trans (norm_nonneg _) (bound_x h.some)\n refine .mono' bound_int ?_\n filter_upwards [bound_ge, bound_nonneg] with x bound_ge_x bound_nonneg_x\n exact ContinuousMap.norm_le _ bound_nonneg_x |>.mpr bound_ge_x\n\n/-- A variant of `ContinuousMap.hasFiniteIntegral_of_bound` spelled in terms of\n`ContinuousMap.mkD`. -/\nlemma hasFiniteIntegral_mkD_of_bound [CompactSpace Y] (f : X → Y → E) (g : C(Y, E))\n (f_ae_cont : ∀ᵐ x ∂μ, Continuous (f x))\n (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral (fun x ↦ mkD (f x) g) μ := by\n refine hasFiniteIntegral_of_bound _ bound bound_int ?_\n filter_upwards [bound_ge, f_ae_cont] with x bound_ge_x cont_x\n simpa only [mkD_apply_of_continuous cont_x] using bound_ge_x\n\n/-- A variant of `ContinuousMap.hasFiniteIntegral_mkD_of_bound` for a family of\nfunctions which are continuous on a compact set. -/\n\nTarget:\nlemma hasFiniteIntegral_mkD_restrict_of_bound {s : Set Y} [CompactSpace s]\n (f : X → Y → E) (g : C(s, E))\n (f_ae_contOn : ∀ᵐ x ∂μ, ContinuousOn (f x) s)\n (bound : X → ℝ)\n (bound_int : HasFiniteIntegral bound μ)\n (bound_ge : ∀ᵐ x ∂μ, ∀ y ∈ s, ‖f x y‖ ≤ bound x) :\n HasFiniteIntegral (fun x ↦ mkD (s.restrict (f x)) g) μ :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/SpecificCodomains","family_id":"hasfiniteintegral_mkd_restrict_of_bound","file_id":"mathlib/Mathlib/MeasureTheory/SpecificCodomains/ContinuousMap.lean","sample_id":"c8607fdf15a4772063aecb4e30b0f647b6e32e9f052cd93c1524ccbf380858f4"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a10105848e4bffb1795b5dc079306ee66c220f6a62d93d28fb5548635276786e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e027f8537814d1c302ee9207d8eac0e77ae2540d9e1014ed7468692c29d3edaf","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ec4f96f91a09dbf29e1f7b52148becbb79f68ade3baa7edeb9ce6bbae0b8528a","source_sha256":"fa786fdfdd4a74d50a5a2889ef1a1e8a8dcab254efa8b824a0f56b7cd2d5e90c","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n exact _root_.Quotient.exact h","hard_negative":false,"metrics":{"chosen_tokens":8,"rejected_tokens":13,"token_jaccard":0.545455,"token_length_ratio":1.625},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"cdf5edb98f8958b0d455f9feae65d751334bd68beac52439a1425d67556d573a","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Homotopy.Basic\npublic import Mathlib.Topology.Connected.PathConnected\npublic import Mathlib.Analysis.Convex.Basic\n\nNamespace:\nHomotopic.Quotient\n\nLocal context:\n/-\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/-!\n# Homotopy between paths\n\nIn this file, we define a `Homotopy` between two `Path`s. In addition, we define a relation\n`Homotopic` on `Path`s, and prove that it is an equivalence relation.\n\n## Definitions\n\n* `Path.Homotopy p₀ p₁` is the type of homotopies between paths `p₀` and `p₁`\n* `Path.Homotopy.refl p` is the constant homotopy between `p` and itself\n* `Path.Homotopy.symm F` is the `Path.Homotopy p₁ p₀` defined by reversing the homotopy\n* `Path.Homotopy.trans F G`, where `F : Path.Homotopy p₀ p₁`, `G : Path.Homotopy p₁ p₂` is the\n `Path.Homotopy p₀ p₂` defined by putting the first homotopy on `[0, 1/2]` and the second on\n `[1/2, 1]`\n* `Path.Homotopy.hcomp F G`, where `F : Path.Homotopy p₀ q₀` and `G : Path.Homotopy p₁ q₁` is\n a `Path.Homotopy (p₀.trans p₁) (q₀.trans q₁)`\n* `Path.Homotopic p₀ p₁` is the relation saying that there is a homotopy between `p₀` and `p₁`\n* `Path.Homotopic.setoid x₀ x₁` is the setoid on `Path`s from `Path.Homotopic`\n* `Path.Homotopic.Quotient x₀ x₁` is the quotient type from `Path x₀ x₀` by `Path.Homotopic.setoid`\n\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nvariable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]\nvariable {x₀ x₁ x₂ x₃ : X}\n\nnoncomputable section\n\nopen unitInterval\n\nnamespace Path\n\n/-- The type of homotopies between two paths.\n-/\nabbrev Homotopy (p₀ p₁ : Path x₀ x₁) :=\n ContinuousMap.HomotopyRel p₀.toContinuousMap p₁.toContinuousMap {0, 1}\n\nnamespace Homotopy\n\nsection\n\nvariable {p₀ p₁ : Path x₀ x₁}\n\ntheorem coeFn_injective : @Function.Injective (Homotopy p₀ p₁) (I × I → X) (⇑) :=\n DFunLike.coe_injective\n\n@[simp]\ntheorem source (F : Homotopy p₀ p₁) (t : I) : F (t, 0) = x₀ :=\n calc F (t, 0) = p₀ 0 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inl rfl)\n _ = x₀ := p₀.source\n\n@[simp]\ntheorem target (F : Homotopy p₀ p₁) (t : I) : F (t, 1) = x₁ :=\n calc F (t, 1) = p₀ 1 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inr rfl)\n _ = x₁ := p₀.target\n\n/-- Evaluating a path homotopy at an intermediate point, giving us a `Path`.\n-/\n@[simps]\ndef eval (F : Homotopy p₀ p₁) (t : I) : Path x₀ x₁ where\n toFun := F.toHomotopy.curry t\n source' := by simp\n target' := by simp\n\n@[simp]\ntheorem eval_zero (F : Homotopy p₀ p₁) : F.eval 0 = p₀ := by\n ext t\n simp\n\n@[simp]\ntheorem eval_one (F : Homotopy p₀ p₁) : F.eval 1 = p₁ := by\n ext t\n simp\n\nend\n\nsection\n\nvariable {p₀ p₁ p₂ : Path x₀ x₁}\n\n/-- Given a path `p`, we can define a `Homotopy p p` by `F (t, x) = p x`.\n-/\n@[simps!]\ndef refl (p : Path x₀ x₁) : Homotopy p p :=\n ContinuousMap.HomotopyRel.refl p.toContinuousMap {0, 1}\n\n/-- Given a `Homotopy p₀ p₁`, we can define a `Homotopy p₁ p₀` by reversing the homotopy.\n-/\n@[simps!]\ndef symm (F : Homotopy p₀ p₁) : Homotopy p₁ p₀ :=\n ContinuousMap.HomotopyRel.symm F\n\n@[simp]\ntheorem symm_symm (F : Homotopy p₀ p₁) : F.symm.symm = F :=\n ContinuousMap.HomotopyRel.symm_symm F\n\ntheorem symm_bijective : Function.Bijective (Homotopy.symm : Homotopy p₀ p₁ → Homotopy p₁ p₀) :=\n Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩\n\n/--\nGiven `Homotopy p₀ p₁` and `Homotopy p₁ p₂`, we can define a `Homotopy p₀ p₂` by putting the first\nhomotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) : Homotopy p₀ p₂ :=\n ContinuousMap.HomotopyRel.trans F G\n\ntheorem trans_apply (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) (x : I × I) :\n (F.trans G) x =\n if h : (x.1 : ℝ) ≤ 1 / 2 then\n F (⟨2 * x.1, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2)\n else\n G (⟨2 * x.1 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) :=\n ContinuousMap.HomotopyRel.trans_apply _ _ _\n\ntheorem symm_trans (F : Homotopy p₀ p₁) (G : Homotopy p₁ p₂) :\n (F.trans G).symm = G.symm.trans F.symm :=\n ContinuousMap.HomotopyRel.symm_trans _ _\n\n/-- Casting a `Homotopy p₀ p₁` to a `Homotopy q₀ q₁` where `p₀ = q₀` and `p₁ = q₁`. -/\n@[simps!]\ndef cast {p₀ p₁ q₀ q₁ : Path x₀ x₁} (F : Homotopy p₀ p₁) (h₀ : p₀ = q₀) (h₁ : p₁ = q₁) :\n Homotopy q₀ q₁ :=\n ContinuousMap.HomotopyRel.cast F (congr_arg _ h₀) (congr_arg _ h₁)\n\n/-- If paths `p` and `q` are homotopic as paths `x ⟶ y`,\nthen they are homotopic as paths `x' ⟶ y'`, where `x' = x` and `y' = y`. -/\n@[simp]\ndef pathCast {x x' y y' : X} {p q : Path x y} (F : p.Homotopy q) (hx : x' = x) (hy : y' = y) :\n (p.cast hx hy).Homotopy (q.cast hx hy) :=\n F\n\nend\n\nsection\n\nvariable {p₀ q₀ : Path x₀ x₁} {p₁ q₁ : Path x₁ x₂}\n\n/-- Suppose `p₀` and `q₀` are paths from `x₀` to `x₁`, `p₁` and `q₁` are paths from `x₁` to `x₂`.\nFurthermore, suppose `F : Homotopy p₀ q₀` and `G : Homotopy p₁ q₁`. Then we can define a homotopy\nfrom `p₀.trans p₁` to `q₀.trans q₁`.\n-/\ndef hcomp (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) : Homotopy (p₀.trans p₁) (q₀.trans q₁) where\n toFun x :=\n if (x.2 : ℝ) ≤ 1 / 2 then (F.eval x.1).extend (2 * x.2) else (G.eval x.1).extend (2 * x.2 - 1)\n continuous_toFun := continuous_if_le (continuous_induced_dom.comp continuous_snd) continuous_const\n (F.toHomotopy.continuous.comp (by fun_prop)).continuousOn\n (G.toHomotopy.continuous.comp (by fun_prop)).continuousOn fun x hx ↦ by norm_num [hx]\n map_zero_left x := by simp [Path.trans]\n map_one_left x := by simp [Path.trans]\n prop' x t ht := by\n rcases ht with ht | ht\n · norm_num [ht]\n · rw [Set.mem_singleton_iff] at ht\n norm_num [ht]\n\ntheorem hcomp_apply (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (x : I × I) :\n F.hcomp G x =\n if h : (x.2 : ℝ) ≤ 1 / 2 then\n F.eval x.1 ⟨2 * x.2, (unitInterval.mul_pos_mem_iff zero_lt_two).2 ⟨x.2.2.1, h⟩⟩\n else\n G.eval x.1\n ⟨2 * x.2 - 1, unitInterval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.2.2.2⟩⟩ :=\n show ite _ _ _ = _ by split_ifs <;> exact Path.extend_apply _ _\n\ntheorem hcomp_half (F : Homotopy p₀ q₀) (G : Homotopy p₁ q₁) (t : I) :\n F.hcomp G (t, ⟨1 / 2, by norm_num, by norm_num⟩) = x₁ :=\n show ite _ _ _ = _ by norm_num\n\nend\n\n/--\nSuppose `p` is a path, then we have a homotopy from `p` to `p.reparam f` by the convexity of `I`.\n-/\ndef reparam (p : Path x₀ x₁) (f : I → I) (hf : Continuous f) (hf₀ : f 0 = 0) (hf₁ : f 1 = 1) :\n Homotopy p (p.reparam f hf hf₀ hf₁) where\n toFun x := p ⟨σ x.1 * x.2 + x.1 * f x.2,\n show (σ x.1 : ℝ) • (x.2 : ℝ) + (x.1 : ℝ) • (f x.2 : ℝ) ∈ I from\n convex_Icc _ _ x.2.2 (f x.2).2 (by unit_interval) (by unit_interval) (by simp)⟩\n map_zero_left x := by norm_num\n map_one_left x := by norm_num\n prop' t x hx := by\n rcases hx with hx | hx\n · rw [hx]\n simp [hf₀]\n · rw [Set.mem_singleton_iff] at hx\n rw [hx]\n simp [hf₁]\n continuous_toFun := by fun_prop\n\n/-- Suppose `F : Homotopy p q`. Then we have a `Homotopy p.symm q.symm` by reversing the second\nargument.\n-/\n@[simps]\ndef symm₂ {p q : Path x₀ x₁} (F : p.Homotopy q) : p.symm.Homotopy q.symm where\n toFun x := F ⟨x.1, σ x.2⟩\n map_zero_left := by simp [Path.symm]\n map_one_left := by simp [Path.symm]\n prop' t x hx := by\n rcases hx with hx | hx\n · rw [hx]\n simp\n · rw [Set.mem_singleton_iff] at hx\n rw [hx]\n simp\n\n/--\nGiven `F : Homotopy p q`, and `f : C(X, Y)`, we can define a homotopy from `p.map f.continuous` to\n`q.map f.continuous`.\n-/\n@[simps]\ndef map {p q : Path x₀ x₁} (F : p.Homotopy q) (f : C(X, Y)) :\n Homotopy (p.map f.continuous) (q.map f.continuous) where\n toFun := f ∘ F\n map_zero_left := by simp\n map_one_left := by simp\n prop' t x hx := by\n rcases hx with hx | hx\n · simp [hx]\n · rw [Set.mem_singleton_iff] at hx\n simp [hx]\n\nend Homotopy\n\n/-- Two paths `p₀` and `p₁` are `Path.Homotopic` if there exists a `Homotopy` between them.\n-/\ndef Homotopic (p₀ p₁ : Path x₀ x₁) : Prop :=\n Nonempty (p₀.Homotopy p₁)\n\nnamespace Homotopic\n\n@[refl]\ntheorem refl (p : Path x₀ x₁) : p.Homotopic p :=\n ⟨Homotopy.refl p⟩\n\n@[symm]\ntheorem symm ⦃p₀ p₁ : Path x₀ x₁⦄ (h : p₀.Homotopic p₁) : p₁.Homotopic p₀ :=\n h.map Homotopy.symm\n\ntheorem symm₂ {p q : Path x₀ x₁} (h : p.Homotopic q) : p.symm.Homotopic q.symm :=\n h.map Homotopy.symm₂\n\n@[trans]\ntheorem trans ⦃p₀ p₁ p₂ : Path x₀ x₁⦄ (h₀ : p₀.Homotopic p₁) (h₁ : p₁.Homotopic p₂) :\n p₀.Homotopic p₂ :=\n h₀.map2 Homotopy.trans h₁\n\ntheorem equivalence : Equivalence (@Homotopic X _ x₀ x₁) :=\n ⟨refl, (symm ·), (trans · ·)⟩\n\ninstance : IsEquiv (Path x₀ x₁) Homotopic where\n refl := refl\n symm := symm\n trans := trans\n\nnonrec theorem map {p q : Path x₀ x₁} (h : p.Homotopic q) (f : C(X, Y)) :\n Homotopic (p.map f.continuous) (q.map f.continuous) :=\n h.map fun F => F.map f\n\ntheorem hcomp {p₀ p₁ : Path x₀ x₁} {q₀ q₁ : Path x₁ x₂} (hp : p₀.Homotopic p₁)\n (hq : q₀.Homotopic q₁) : (p₀.trans q₀).Homotopic (p₁.trans q₁) :=\n hp.map2 Homotopy.hcomp hq\n\n/-- If paths `p` and `q` are homotopic as paths `x ⟶ y`,\nthen they are homotopic as paths `x' ⟶ y'`, where `x' = x` and `y' = y`. -/\ntheorem pathCast {p q : Path x₀ x₁} (hpq : p.Homotopic q) (hsource : x₂ = x₀) (htarget : x₃ = x₁) :\n (p.cast hsource htarget).Homotopic (q.cast hsource htarget) :=\n hpq\n\n/--\nThe setoid on `Path`s defined by the equivalence relation `Path.Homotopic`. That is, two paths are\nequivalent if there is a `Homotopy` between them.\n-/\n@[instance_reducible]\nprotected def setoid (x₀ x₁ : X) : Setoid (Path x₀ x₁) :=\n ⟨Homotopic, equivalence⟩\n\n/-- The quotient on `Path x₀ x₁` by the equivalence relation `Path.Homotopic`.\n-/\nprotected def Quotient (x₀ x₁ : X) :=\n Quotient (Homotopic.setoid x₀ x₁)\n\nattribute [local instance] Homotopic.setoid\n\ninstance : Inhabited (Homotopic.Quotient () ()) :=\n ⟨Quotient.mk' <| Path.refl ()⟩\n\nnamespace Quotient\n\n/-- The canonical map from `Path x₀ x₁` to `Path.Homotopic.Quotient x₀ x₁`. -/\ndef mk (p : Path x₀ x₁) : Path.Homotopic.Quotient x₀ x₁ :=\n Quotient.mk' p\n\ntheorem mk_surjective : Function.Surjective (@mk X _ x₀ x₁) :=\n Quotient.mk'_surjective\n\n/-- `Path.Homotopic.Quotient.mk` is the simp normal form. -/\n@[simp] theorem mk'_eq_mk (p : Path x₀ x₁) : Quotient.mk' p = mk p := rfl\n@[simp] theorem mk''_eq_mk (p : Path x₀ x₁) : Quotient.mk'' p = mk p := rfl\n\nTarget:\ntheorem exact {p q : Path x₀ x₁} (h : Quotient.mk p = Quotient.mk q) :\n Homotopic p q :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n exact _root_.Quotient.exact h","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Homotopy","family_id":"exact","file_id":"mathlib/Mathlib/Topology/Homotopy/Path.lean","sample_id":"ec4f96f91a09dbf29e1f7b52148becbb79f68ade3baa7edeb9ce6bbae0b8528a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ac855ef276ae2a2d20fcf02e7c20e07022ee4408c628a7a068780f5b01fcb1a3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fe1dd28514b96f2a1a54b0b87f4a1a6bdd1b7f235e1e6557ebd362eedb4330b7","source_sha256":"c8a33bb8cce3962f230d95a94382ba6537d37e619b16dfe9b8c1fe283237e032","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [iInf, coe_sInf, Set.biInter_range]","hard_negative":true,"metrics":{"chosen_tokens":12,"rejected_tokens":8,"token_jaccard":0.058824,"token_length_ratio":0.666667},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"ce69b9b0ae9a6967561ea1c62bd51741e4a633fa55eb18d794af5ba5640defcd","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Subgroup.Basic\npublic import Mathlib.Algebra.Group.Submonoid.BigOperators\npublic import Mathlib.GroupTheory.Subsemigroup.Center\npublic import Mathlib.RingTheory.NonUnitalSubring.Defs\npublic import Mathlib.RingTheory.NonUnitalSubsemiring.Basic\n\nNamespace:\nNonUnitalSubring\n\nLocal context:\n/-\nCopyright (c) 2023 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n-/\n/-!\n# `NonUnitalSubring`s\n\nLet `R` be a non-unital ring.\nWe prove that non-unital subrings 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 `NonUnitalSubring R`, sending a subset of\n`R` to the non-unital subring it generates, and prove that it is a Galois insertion.\n\n## Main definitions\n\nNotation used here:\n\n`(R : Type u) [NonUnitalRing R] (S : Type u) [NonUnitalRing S] (f g : R →ₙ+* S)`\n`(A : NonUnitalSubring R) (B : NonUnitalSubring S) (s : Set R)`\n\n* `instance : CompleteLattice (NonUnitalSubring R)` : the complete lattice structure on the\n non-unital subrings.\n\n* `NonUnitalSubring.center` : the center of a non-unital ring `R`.\n\n* `NonUnitalSubring.closure` : non-unital subring closure of a set, i.e., the smallest\n non-unital subring that includes the set.\n\n* `NonUnitalSubring.gi` : `closure : Set M → NonUnitalSubring M` and coercion\n `coe : NonUnitalSubring M → Set M`\n form a `GaloisInsertion`.\n\n* `comap f B : NonUnitalSubring A` : the preimage of a non-unital subring `B` along the\n non-unital ring homomorphism `f`\n\n* `map f A : NonUnitalSubring B` : the image of a non-unital subring `A` along the\n non-unital ring homomorphism `f`.\n\n* `Prod A B : NonUnitalSubring (R × S)` : the product of non-unital subrings\n\n* `f.range : NonUnitalSubring B` : the range of the non-unital ring homomorphism `f`.\n\n* `eq_locus f g : NonUnitalSubring R` : given non-unital ring homomorphisms `f g : R →ₙ+* S`,\n the non-unital subring of `R` where `f x = g x`\n\n## Implementation notes\n\nA non-unital subring is implemented as a `NonUnitalSubsemiring` which is also an\nadditive subgroup.\n\nLattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although\n`∈` is defined as membership of a non-unital subring's underlying set.\n\n## Tags\nnon-unital subring\n-/\n\n@[expose] public section\n\n\nuniverse u v w\n\nsection Basic\n\nvariable {R : Type u} {S : Type v} [NonUnitalNonAssocRing R]\n\nnamespace NonUnitalSubring\n\nvariable (s : NonUnitalSubring R)\n\n/-- Sum of a list of elements in a non-unital subring is in the non-unital subring. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=\n list_sum_mem\n\n/-- Sum of a multiset of elements in a `NonUnitalSubring` of a `NonUnitalRing` is\nin the `NonUnitalSubring`. -/\nprotected theorem multiset_sum_mem {R} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=\n multiset_sum_mem _\n\n/-- Sum of elements in a `NonUnitalSubring` of a `NonUnitalRing` indexed by a `Finset`\nis in the `NonUnitalSubring`. -/\nprotected theorem sum_mem {R : Type*} [NonUnitalNonAssocRing R] (s : NonUnitalSubring R)\n {ι : Type*} {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∑ i ∈ t, f i) ∈ s :=\n sum_mem h\n\n/-! ## top -/\n\n\n/-- The non-unital subring `R` of the ring `R`. -/\ninstance : Top (NonUnitalSubring R) :=\n ⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubgroup R) with }⟩\n\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubring R) :=\n Set.mem_univ x\n\n@[simp]\ntheorem coe_top : ((⊤ : NonUnitalSubring R) : Set R) = Set.univ :=\n rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_top : (⊤ : NonUnitalSubring R).toNonUnitalSubsemiring = ⊤ := rfl\n\n@[simp] lemma toAddSubgroup_top : (⊤ : NonUnitalSubring R).toAddSubgroup = ⊤ := rfl\n\n@[simp]\nlemma toNonUnitalSubsemiring_eq_top {S : NonUnitalSubring R} :\n S.toNonUnitalSubsemiring = ⊤ ↔ S = ⊤ := by simp [← SetLike.coe_set_eq]\n\n@[simp] lemma toAddSubgroup_eq_top {S : NonUnitalSubring R} : S.toAddSubgroup = ⊤ ↔ S = ⊤ := by\n simp [← SetLike.coe_set_eq]\n\n/-- The ring equiv between the top element of `NonUnitalSubring R` and `R`. -/\n@[simps!]\ndef topEquiv : (⊤ : NonUnitalSubring R) ≃+* R := NonUnitalSubsemiring.topEquiv\n\nend NonUnitalSubring\n\nend Basic\n\nsection Hom\n\nnamespace NonUnitalSubring\n\nvariable {F : Type w} {R : Type u} {S : Type v} {T : Type*}\n [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (s : NonUnitalSubring R)\n\n/-! ## comap -/\n\n\n/-- The preimage of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/\ndef comap {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring S) :\n NonUnitalSubring R :=\n { s.toSubsemigroup.comap (f : R →ₙ* S), s.toAddSubgroup.comap (f : R →+ S) with\n carrier := f ⁻¹' s.carrier }\n\n@[simp]\ntheorem coe_comap (s : NonUnitalSubring S) (f : F) : (s.comap f : Set R) = f ⁻¹' s :=\n rfl\n\n@[simp]\ntheorem mem_comap {s : NonUnitalSubring S} {f : F} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=\n Iff.rfl\n\ntheorem comap_comap (s : NonUnitalSubring T) (g : S →ₙ+* T) (f : R →ₙ+* S) :\n (s.comap g).comap f = s.comap (g.comp f) :=\n rfl\n\n/-! ## map -/\n\n/-- The image of a `NonUnitalSubring` along a ring homomorphism is a `NonUnitalSubring`. -/\ndef map {F : Type w} {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n [FunLike F R S] [NonUnitalRingHomClass F R S] (f : F) (s : NonUnitalSubring R) :\n NonUnitalSubring S :=\n { s.toSubsemigroup.map (f : R →ₙ* S), s.toAddSubgroup.map (f : R →+ S) with\n carrier := f '' s.carrier }\n\n@[simp]\ntheorem coe_map (f : F) (s : NonUnitalSubring R) : (s.map f : Set S) = f '' s :=\n rfl\n\n@[simp]\ntheorem mem_map {f : F} {s : NonUnitalSubring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=\n Set.mem_image _ _ _\n\n@[simp]\ntheorem map_id : s.map (NonUnitalRingHom.id R) = s :=\n SetLike.coe_injective <| Set.image_id _\n\ntheorem map_map (g : S →ₙ+* T) (f : R →ₙ+* S) : (s.map f).map g = s.map (g.comp f) :=\n SetLike.coe_injective <| Set.image_image _ _ _\n\ntheorem map_le_iff_le_comap {f : F} {s : NonUnitalSubring R} {t : NonUnitalSubring S} :\n s.map f ≤ t ↔ s ≤ t.comap f :=\n Set.image_subset_iff\n\ntheorem gc_map_comap (f : F) :\n GaloisConnection (map f : NonUnitalSubring R → NonUnitalSubring S) (comap f) := fun _S _T =>\n map_le_iff_le_comap\n\n/-- A `NonUnitalSubring` is isomorphic to its image under an injective function -/\nnoncomputable def equivMapOfInjective (f : F) (hf : Function.Injective (f : R → S)) :\n s ≃+* s.map f :=\n {\n Equiv.Set.image f s\n hf with\n map_mul' := fun _ _ => Subtype.ext (map_mul f _ _)\n map_add' := fun _ _ => Subtype.ext (map_add f _ _) }\n\n@[simp]\ntheorem coe_equivMapOfInjective_apply (f : F) (hf : Function.Injective f) (x : s) :\n (equivMapOfInjective s f hf x : S) = f x :=\n rfl\n\nend NonUnitalSubring\n\nnamespace NonUnitalRingHom\n\nvariable {R : Type u} {S : Type v} {T : Type*}\n [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] [NonUnitalNonAssocRing T]\n (g : S →ₙ+* T) (f : R →ₙ+* S)\n\n/-! ## range -/\n\n/-- The range of a ring homomorphism, as a `NonUnitalSubring` of the target.\nSee Note [range copy pattern]. -/\ndef range {R : Type u} {S : Type v} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]\n (f : R →ₙ+* S) : NonUnitalSubring S :=\n ((⊤ : NonUnitalSubring R).map f).copy (Set.range f) Set.image_univ.symm\n\n@[simp]\ntheorem coe_range : (f.range : Set S) = Set.range f :=\n rfl\n\n@[simp]\ntheorem mem_range {f : R →ₙ+* S} {y : S} : y ∈ f.range ↔ ∃ x, f x = y :=\n Iff.rfl\n\ntheorem range_eq_map (f : R →ₙ+* S) : f.range = NonUnitalSubring.map f ⊤ := by ext; simp\n\ntheorem mem_range_self (f : R →ₙ+* S) (x : R) : f x ∈ f.range :=\n mem_range.mpr ⟨x, rfl⟩\n\ntheorem map_range : f.range.map g = (g.comp f).range := by\n simpa only [range_eq_map] using (⊤ : NonUnitalSubring R).map_map g f\n\n/-- The range of a ring homomorphism 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 fintypeRange [Fintype R] [DecidableEq S] (f : R →ₙ+* S) : Fintype (range f) :=\n Set.fintypeRange f\n\nend NonUnitalRingHom\n\nnamespace NonUnitalSubring\n\nsection Order\n\nvariable {R : Type u} [NonUnitalNonAssocRing R]\n\n/-! ## bot -/\n\n\ninstance : Bot (NonUnitalSubring R) :=\n ⟨(0 : R →ₙ+* R).range⟩\n\ninstance : Inhabited (NonUnitalSubring R) :=\n ⟨⊥⟩\n\ntheorem coe_bot : ((⊥ : NonUnitalSubring R) : Set R) = {0} :=\n (NonUnitalRingHom.coe_range (0 : R →ₙ+* R)).trans (@Set.range_const R R _ 0)\n\ntheorem mem_bot {x : R} : x ∈ (⊥ : NonUnitalSubring R) ↔ x = 0 :=\n show x ∈ ((⊥ : NonUnitalSubring R) : Set R) ↔ x = 0 by rw [coe_bot, Set.mem_singleton_iff]\n\n/-! ## inf -/\n\n/-- The inf of two `NonUnitalSubring`s is their intersection. -/\ninstance : Min (NonUnitalSubring R) :=\n ⟨fun s t =>\n { s.toSubsemigroup ⊓ t.toSubsemigroup, s.toAddSubgroup ⊓ t.toAddSubgroup with\n carrier := s ∩ t }⟩\n\n@[simp]\ntheorem coe_inf (p p' : NonUnitalSubring R) :\n ((p ⊓ p' : NonUnitalSubring R) : Set R) = (p : Set R) ∩ p' :=\n rfl\n\n@[simp]\ntheorem mem_inf {p p' : NonUnitalSubring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n Iff.rfl\n\ninstance : InfSet (NonUnitalSubring R) :=\n ⟨fun s =>\n NonUnitalSubring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, NonUnitalSubring.toSubsemigroup t)\n (⨅ t ∈ s, NonUnitalSubring.toAddSubgroup t) (by simp) (by simp)⟩\n\n@[simp, norm_cast]\ntheorem coe_sInf (S : Set (NonUnitalSubring R)) :\n ((sInf S : NonUnitalSubring R) : Set R) = ⋂ s ∈ S, ↑s :=\n rfl\n\n@[simp]\ntheorem mem_sInf {S : Set (NonUnitalSubring R)} {x : R} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=\n Set.mem_iInter₂\n\n@[simp, norm_cast]\n\nTarget:\ntheorem coe_iInf {ι : Sort*} {S : ι → NonUnitalSubring R} : (↑(⨅ i, S i) : Set R) = ⋂ i, S i :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"71223f2a28acc44c094f2e86bab6f7790e41c531fab0e2e783b1e89d0cbea6ba","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/NonUnitalSubring","family_id":"coe_iinf","file_id":"mathlib/Mathlib/RingTheory/NonUnitalSubring/Basic.lean","sample_id":"fe1dd28514b96f2a1a54b0b87f4a1a6bdd1b7f235e1e6557ebd362eedb4330b7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"aee59ddfe6958b15038f19255036946319da0f5a08aa7e5d278dbbe06ab56ff4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b0718baa876c9dd678e1d33e539f7cba4cff55e27f7a792063751fb24b49bb24","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a0be12b25531ea1b915fbec47e5b007039e62415b37090bd30cbde3be74f5a3e","source_sha256":"2e9a501203fcdaedf24b8cbbdb6811adf4ee5e6975f40ec706beec7ece81c5a4","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [LinearEquiv.finrank_eq <| quotientEquivDirectSum F b h, Module.finrank_directSum]","hard_negative":true,"metrics":{"chosen_tokens":17,"rejected_tokens":2,"token_jaccard":0.058824,"token_length_ratio":0.117647},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"cee213643605b8447d9408ae3cb2d5215dedad26061cd8c407b3c981ed8427ea","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.ZMod.QuotientRing\npublic import Mathlib.LinearAlgebra.Dimension.Constructions\npublic import Mathlib.LinearAlgebra.FreeModule.PID\npublic import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition\npublic import Mathlib.LinearAlgebra.Quotient.Pi\n\nNamespace:\nSubmodule\n\nLocal context:\n/-\nCopyright (c) 2025 Xavier Roblot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Xavier Roblot\n-/\n/-! # Quotient of submodules of full rank in free finite modules over PIDs\n\n## Main results\n\n* `Submodule.quotientEquivPiSpan`: `M ⧸ N`, if `M` is free finite module over a PID `R` and `N`\n is a submodule of full rank, can be written as a product of quotients of `R` by principal ideals.\n\n-/\n\n@[expose] public section\n\nopen Module\nopen scoped DirectSum\n\nnamespace Submodule\n\nvariable {ι R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]\nvariable [IsDomain R] [IsPrincipalIdealRing R] [Finite ι]\n\n/--\nWe can write the quotient by a submodule of full rank over a PID as a product of quotients\nby principal ideals.\n-/\nnoncomputable def quotientEquivPiSpan (N : Submodule R M) (b : Basis ι R M)\n (h : Module.finrank R N = Module.finrank R M) :\n (M ⧸ N) ≃ₗ[R] Π i, R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R) := by\n haveI := Fintype.ofFinite ι\n -- Choose `e : M ≃ₗ N` and a basis `b'` for `M` that turns the map\n -- `f := ((Submodule.subtype N).comp e` into a diagonal matrix:\n -- there is an `a : ι → ℤ` such that `f (b' i) = a i • b' i`.\n let a := smithNormalFormCoeffs b h\n let b' := smithNormalFormTopBasis b h\n let ab := smithNormalFormBotBasis b h\n have ab_eq := smithNormalFormBotBasis_def b h\n have mem_I_iff : ∀ x, x ∈ N ↔ ∀ i, a i ∣ b'.repr x i := by\n intro x\n simp_rw [ab.mem_submodule_iff', ab, ab_eq]\n have : ∀ (c : ι → R) (i), b'.repr (∑ j : ι, c j • a j • b' j) i = a i * c i := by\n intro c i\n simp only [← mul_smul, b'.repr_sum_self, mul_comm]\n constructor\n · rintro ⟨c, rfl⟩ i\n exact ⟨c i, this c i⟩\n · rintro ha\n choose c hc using ha\n exact ⟨c, b'.ext_elem fun i => Eq.trans (hc i) (this c i).symm⟩\n -- Now we map everything through the linear equiv `M ≃ₗ (ι → R)`,\n -- which maps `N` to `N' := Π i, a i ℤ`.\n let N' : Submodule R (ι → R) := Submodule.pi Set.univ fun i => span R ({a i} : Set R)\n have : Submodule.map (b'.equivFun : M →ₗ[R] ι → R) N = N' := by\n ext x\n simp only [N', Submodule.mem_map, Submodule.mem_pi, mem_span_singleton, Set.mem_univ,\n mem_I_iff, smul_eq_mul, forall_true_left, LinearEquiv.coe_coe,\n Basis.equivFun_apply, mul_comm _ (a _), eq_comm (b := (x _))]\n constructor\n · rintro ⟨y, hy, rfl⟩ i\n exact hy i\n · rintro hdvd\n refine ⟨∑ i, x i • b' i, fun i => ?_, ?_⟩ <;> rw [b'.repr_sum_self]\n · exact hdvd i\n refine (Submodule.Quotient.equiv N N' b'.equivFun this).trans (re₂₃ := inferInstance)\n (re₃₂ := inferInstance) ?_\n classical\n exact Submodule.quotientPi (show _ → Submodule R R from fun i => span R ({a i} : Set R))\n\n/--\nQuotients by submodules of full rank of free finite `ℤ`-modules are isomorphic\nto a direct product of `ZMod`.\n-/\nnoncomputable def quotientEquivPiZMod (N : Submodule ℤ M) (b : Basis ι ℤ M)\n (h : Module.finrank ℤ N = Module.finrank ℤ M) :\n M ⧸ N ≃+ Π i, ZMod (smithNormalFormCoeffs b h i).natAbs :=\n let a := smithNormalFormCoeffs b h\n let e := N.quotientEquivPiSpan b h\n let e' : (∀ i : ι, ℤ ⧸ Ideal.span ({a i} : Set ℤ)) ≃+ ∀ i : ι, ZMod (a i).natAbs :=\n AddEquiv.piCongrRight fun i => ↑(Int.quotientSpanEquivZMod (a i))\n (↑(e : (M ⧸ N) ≃ₗ[ℤ] _) : M ⧸ N ≃+ _).trans e'\n\n/--\nA submodule of full rank of a free finite `ℤ`-module has a finite quotient.\nIt can't be an instance because of the side condition `Module.finrank ℤ N = Module.finrank ℤ M`.\n-/\ntheorem finiteQuotientOfFreeOfRankEq [Module.Free ℤ M] [Module.Finite ℤ M]\n (N : Submodule ℤ M) (h : Module.finrank ℤ N = Module.finrank ℤ M) : Finite (M ⧸ N) := by\n let b := Module.Free.chooseBasis ℤ M\n let a := smithNormalFormCoeffs b h\n let e := N.quotientEquivPiZMod b h\n have : ∀ i, NeZero (a i).natAbs := fun i ↦\n ⟨Int.natAbs_ne_zero.mpr (smithNormalFormCoeffs_ne_zero b h i)⟩\n exact Finite.of_equiv (Π i, ZMod (a i).natAbs) e.symm\n\ntheorem finiteQuotient_iff [Module.Free ℤ M] [Module.Finite ℤ M] (N : Submodule ℤ M) :\n Finite (M ⧸ N) ↔ Module.finrank ℤ N = Module.finrank ℤ M := by\n refine ⟨fun h ↦ le_antisymm (finrank_le N) <|\n ((LinearMap.lsmul ℤ M (Nat.card (M ⧸ N))).codRestrict N\n fun x ↦ ?_).finrank_le_finrank_of_injective ?_, fun h ↦ finiteQuotientOfFreeOfRankEq N h⟩\n · simpa using! AddSubgroup.nsmul_index_mem N.toAddSubgroup x\n · refine (LinearMap.lsmul_injective ?_).codRestrict _\n exact Int.ofNat_ne_zero.mpr <| Nat.card_ne_zero.mpr\n ⟨Set.nonempty_iff_univ_nonempty.mpr Set.univ_nonempty, h⟩\n\nvariable (F : Type*) [CommRing F] [Algebra F R] [Module F M] [IsScalarTower F R M]\n (b : Basis ι R M) {N : Submodule R M}\n\n/-- Decompose `M⧸N` as a direct sum of cyclic `R`-modules\n (quotients by the ideals generated by Smith coefficients of `N`). -/\nnoncomputable def quotientEquivDirectSum (h : Module.finrank R N = Module.finrank R M) :\n (M ⧸ N) ≃ₗ[F] ⨁ i, R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R) := by\n haveI := Fintype.ofFinite ι\n exact ((N.quotientEquivPiSpan b _).restrictScalars F).trans\n (DirectSum.linearEquivFunOnFintype _ _ _).symm\n\nTarget:\ntheorem finrank_quotient_eq_sum {ι} [Fintype ι] (b : Basis ι R M) [Nontrivial F]\n (h : Module.finrank R N = Module.finrank R M)\n [∀ i, Module.Free F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R))]\n [∀ i, Module.Finite F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R))] :\n Module.finrank F (M ⧸ N) =\n ∑ i, Module.finrank F (R ⧸ Ideal.span ({smithNormalFormCoeffs b h i} : Set R)) :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_a0be12b25531","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"aeeb69ce1afd6e38f4a9353003fd0437569ba28500663c3644dae2c2310a2db8","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"LinearAlgebra/FreeModule","family_id":"finrank_quotient_eq_sum","file_id":"mathlib/Mathlib/LinearAlgebra/FreeModule/Finite/Quotient.lean","sample_id":"a0be12b25531ea1b915fbec47e5b007039e62415b37090bd30cbde3be74f5a3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"29cbf6536cd871792336e3f798e7da0fa885f82547b3fd12dd9e1aa846d6c449","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2708abfd6b0d0bcd292542fc518d1cf5dbecea6f769e67cf40477d6a096adaa6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"82255e2f34c8bd869145c6aef2277f38ae065d62ce5efa8852e09b8aec94c904","source_sha256":"da26ee3ca6f797a2045e4655669aba812359acecd55f37e00aa473ba109b6040","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n suffices decodeSum n = none by\n change (decodeSum n).bind _ = none\n rw [this]\n rfl\n have : 1 ≤ n / 2 := by\n rw [Nat.le_div_iff_mul_le]\n exacts [h, by decide]\n obtain ⟨m, e⟩ := exists_eq_succ_of_ne_zero (_root_.ne_of_gt this)\n simp only [decodeSum, div2_val]; cases bodd n <;> simp [e]\n\nnoncomputable instance _root_.Prop.encodable : Encodable Prop :=\n ofEquiv Bool Equiv.propEquivBool","hard_negative":false,"metrics":{"chosen_tokens":92,"rejected_tokens":97,"token_jaccard":0.932203,"token_length_ratio":1.054348},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"d03f87cd7ce5a116aaec690479060c536999496d24bd95795577ad4bf5e2a23b","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Countable.Defs\npublic import Mathlib.Data.Fin.Basic\npublic import Mathlib.Data.Nat.Find\npublic import Mathlib.Data.PNat.Equiv\npublic import Mathlib.Logic.Equiv.Nat\npublic import Mathlib.Order.Directed\npublic import Mathlib.Order.RelIso.Basic\n\nNamespace:\nEncodable\n\nLocal context:\n/-\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/-!\n# Encodable types\n\nThis file defines encodable (constructively countable) types as a typeclass.\nThis is used to provide explicit encode/decode functions from and to `ℕ`, with the information that\nthose functions are inverses of each other.\nThe difference with `Denumerable` is that finite types are encodable. For infinite types,\n`Encodable` and `Denumerable` agree.\n\n## Main declarations\n\n* `Encodable α`: States that there exists an explicit encoding function `encode : α → ℕ` with a\n partial inverse `decode : ℕ → Option α`.\n* `decode₂`: Version of `decode` that is equal to `none` outside of the range of `encode`. Useful as\n we do not require this in the definition of `decode`.\n* `ULower α`: Any encodable type has an equivalent type living in the lowest universe, namely a\n subtype of `ℕ`. `ULower α` finds it.\n\n## Implementation notes\n\nThe point of asking for an explicit partial inverse `decode : ℕ → Option α` to `encode : α → ℕ` is\nto make the range of `encode` decidable even when the finiteness of `α` is not.\n-/\n\n@[expose] public section\n\nassert_not_exists Monoid\n\n-- We want the theorems in this file to be constructive.\nset_option linter.unusedDecidableInType false\n\nopen Option List Nat Function\n\n/-- Constructively countable type. Made from an explicit injection `encode : α → ℕ` and a partial\ninverse `decode : ℕ → Option α`. Note that finite types *are* countable. See `Denumerable` if you\nwish to enforce infiniteness. -/\nclass Encodable (α : Type*) where\n /-- Encoding from Type α to ℕ -/\n encode : α → ℕ\n /-- Decoding from ℕ to Option α -/\n decode : ℕ → Option α\n /-- Invariant relationship between encoding and decoding -/\n encodek : ∀ a, decode (encode a) = some a\n\nattribute [simp] Encodable.encodek\n\nnamespace Encodable\n\nvariable {α : Type*} {β : Type*}\n\nuniverse u\n\ntheorem encode_injective [Encodable α] : Function.Injective (@encode α _)\n | x, y, e => Option.some.inj <| by rw [← encodek, e, encodek]\n\n@[simp]\ntheorem encode_inj [Encodable α] {a b : α} : encode a = encode b ↔ a = b :=\n encode_injective.eq_iff\n\n-- The priority of the instance below is less than the priorities of `Subtype.Countable`\n-- and `Quotient.Countable`\ninstance (priority := 400) countable [Encodable α] : Countable α where\n exists_injective_nat' := ⟨_,encode_injective⟩\n\ntheorem surjective_decode_getD (α : Type*) [Encodable α] (d : α) :\n Surjective fun n => (Encodable.decode n).getD d := fun x =>\n ⟨Encodable.encode x, by simp_rw [Encodable.encodek]; rfl⟩\n\n@[deprecated surjective_decode_getD (since := \"2026-01-05\")]\ntheorem surjective_decode_iget (α : Type*) [Encodable α] [Inhabited α] :\n Surjective fun n => ((Encodable.decode n).getD default : α) :=\n surjective_decode_getD α default\n\n/-- An encodable type has decidable equality. Not set as an instance because this is usually not the\nbest way to infer decidability. -/\n@[instance_reducible]\ndef decidableEqOfEncodable (α) [Encodable α] : DecidableEq α\n | _, _ => decidable_of_iff _ encode_inj\n\n/-- If `α` is encodable and there is an injection `f : β → α`, then `β` is encodable as well. -/\n@[implicit_reducible]\ndef ofLeftInjection [Encodable α] (f : β → α) (finv : α → Option β)\n (linv : ∀ b, finv (f b) = some b) : Encodable β :=\n ⟨fun b => encode (f b), fun n => (decode n).bind finv, fun b => by\n simp [Encodable.encodek, linv]⟩\n\n/-- If `α` is encodable and `f : β → α` is invertible, then `β` is encodable as well. -/\n@[implicit_reducible]\ndef ofLeftInverse [Encodable α] (f : β → α) (finv : α → β) (linv : ∀ b, finv (f b) = b) :\n Encodable β :=\n ofLeftInjection f (some ∘ finv) fun b => congr_arg some (linv b)\n\n/-- Encodability is preserved by equivalence. -/\n@[implicit_reducible]\ndef ofEquiv (α) [Encodable α] (e : β ≃ α) : Encodable β :=\n ofLeftInverse e e.symm e.left_inv\n\ntheorem encode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (b : β) :\n @encode _ (ofEquiv _ e) b = encode (e b) :=\n rfl\n\ntheorem decode_ofEquiv {α β} [Encodable α] (e : β ≃ α) (n : ℕ) :\n @decode _ (ofEquiv _ e) n = (decode n).map e.symm :=\n show Option.bind _ _ = Option.map _ _\n by rw [Option.map_eq_bind]\n\ninstance _root_.Nat.encodable : Encodable ℕ :=\n ⟨id, some, fun _ => rfl⟩\n\n@[simp]\ntheorem encode_nat (n : ℕ) : encode n = n :=\n rfl\n\n@[simp 1100]\ntheorem decode_nat (n : ℕ) : decode n = some n :=\n rfl\n\ninstance (priority := 100) _root_.IsEmpty.toEncodable [IsEmpty α] : Encodable α :=\n ⟨isEmptyElim, fun _ => none, isEmptyElim⟩\n\ninstance _root_.PUnit.encodable : Encodable PUnit :=\n ⟨fun _ => 0, fun n => Nat.casesOn n (some PUnit.unit) fun _ => none, fun _ => by simp⟩\n\n@[simp]\ntheorem encode_star : encode PUnit.unit = 0 :=\n rfl\n\n@[simp]\ntheorem decode_unit_zero : decode 0 = some PUnit.unit :=\n rfl\n\n@[simp]\ntheorem decode_unit_succ (n) : decode (succ n) = (none : Option PUnit) :=\n rfl\n\n/-- If `α` is encodable, then so is `Option α`. -/\ninstance _root_.Option.encodable {α : Type*} [h : Encodable α] : Encodable (Option α) :=\n ⟨fun o => Option.casesOn o Nat.zero fun a => succ (encode a), fun n =>\n Nat.casesOn n (some none) fun m => (decode m).map some, fun o => by\n cases o <;> simp [encodek]⟩\n\n@[simp]\ntheorem encode_none [Encodable α] : encode (@none α) = 0 :=\n rfl\n\n@[simp]\ntheorem encode_some [Encodable α] (a : α) : encode (some a) = succ (encode a) :=\n rfl\n\n@[simp]\ntheorem decode_option_zero [Encodable α] : (decode 0 : Option (Option α)) = some none :=\n rfl\n\n@[simp]\ntheorem decode_option_succ [Encodable α] (n) :\n (decode (succ n) : Option (Option α)) = (decode n).map some :=\n rfl\n\n/-- Failsafe variant of `decode`. `decode₂ α n` returns the preimage of `n` under `encode` if it\nexists, and returns `none` if it doesn't. This requirement could be imposed directly on `decode` but\nis not to help make the definition easier to use. -/\ndef decode₂ (α) [Encodable α] (n : ℕ) : Option α :=\n (decode n).bind (Option.guard fun a => encode a = n)\n\ntheorem mem_decode₂' [Encodable α] {n : ℕ} {a : α} :\n a ∈ decode₂ α n ↔ a ∈ decode n ∧ encode a = n := by\n simp [decode₂, Option.bind_eq_some_iff]\n\ntheorem mem_decode₂ [Encodable α] {n : ℕ} {a : α} : a ∈ decode₂ α n ↔ encode a = n :=\n mem_decode₂'.trans (and_iff_right_of_imp fun e => e ▸ encodek _)\n\ntheorem decode₂_eq_some [Encodable α] {n : ℕ} {a : α} : decode₂ α n = some a ↔ encode a = n :=\n mem_decode₂\n\n@[simp]\ntheorem decode₂_encode [Encodable α] (a : α) : decode₂ α (encode a) = some a := by\n simp [decode₂_eq_some]\n\ntheorem decode₂_ne_none_iff [Encodable α] {n : ℕ} :\n decode₂ α n ≠ none ↔ n ∈ Set.range (encode : α → ℕ) := by\n simp_rw [Set.range, Set.mem_setOf_eq, Ne, Option.eq_none_iff_forall_not_mem,\n Encodable.mem_decode₂, not_forall, not_not]\n\ntheorem decode₂_isPartialInv [Encodable α] : IsPartialInv encode (decode₂ α) := fun _ _ =>\n mem_decode₂\n\n@[deprecated (since := \"2026-03-11\")] alias decode₂_is_partial_inv := decode₂_isPartialInv\n\ntheorem decode₂_inj [Encodable α] {n : ℕ} {a₁ a₂ : α} (h₁ : a₁ ∈ decode₂ α n)\n (h₂ : a₂ ∈ decode₂ α n) : a₁ = a₂ :=\n encode_injective <| (mem_decode₂.1 h₁).trans (mem_decode₂.1 h₂).symm\n\ntheorem encodek₂ [Encodable α] (a : α) : decode₂ α (encode a) = some a :=\n mem_decode₂.2 rfl\n\n/-- The encoding function has decidable range. -/\n@[instance_reducible]\ndef decidableRangeEncode (α : Type*) [Encodable α] : DecidablePred (· ∈ Set.range (@encode α _)) :=\n fun x =>\n decidable_of_iff (Option.isSome (decode₂ α x))\n ⟨fun h => ⟨Option.get _ h, by rw [← decode₂_isPartialInv (Option.get _ h), Option.some_get]⟩,\n fun ⟨n, hn⟩ => by rw [← hn, encodek₂]; exact rfl⟩\n\n/-- An encodable type is equivalent to the range of its encoding function. -/\ndef equivRangeEncode (α : Type*) [Encodable α] : α ≃ Set.range (@encode α _) where\n toFun a := ⟨encode a, Set.mem_range_self _⟩\n invFun n :=\n Option.get _\n (show isSome (decode₂ α n.1) by obtain ⟨x, hx⟩ := n.2; rw [← hx, encodek₂]; exact rfl)\n left_inv _ := by dsimp; rw [← Option.some_inj, Option.some_get, encodek₂]\n right_inv _ := Subtype.ext <| decode₂_isPartialInv.get_eq _ _\n\n/-- A type with unique element is encodable. This is not an instance to avoid diamonds. -/\n@[implicit_reducible]\ndef _root_.Unique.encodable [Unique α] : Encodable α :=\n ⟨fun _ => 0, fun _ => some default, Unique.forall_iff.2 rfl⟩\n\nsection Sum\n\nvariable [Encodable α] [Encodable β]\n\n/-- Explicit encoding function for the sum of two encodable types. -/\ndef encodeSum : α ⊕ β → ℕ\n | Sum.inl a => 2 * encode a\n | Sum.inr b => 2 * encode b + 1\n\n/-- Explicit decoding function for the sum of two encodable types. -/\ndef decodeSum (n : ℕ) : Option (α ⊕ β) :=\n match bodd n, div2 n with\n | false, m => (decode m : Option α).map Sum.inl\n | _, m => (decode m : Option β).map Sum.inr\n\n/-- If `α` and `β` are encodable, then so is their sum. -/\ninstance _root_.Sum.encodable : Encodable (α ⊕ β) :=\n ⟨encodeSum, decodeSum, fun s => by cases s <;> simp [encodeSum, div2_val, decodeSum, encodek]⟩\n\n@[simp]\ntheorem encode_inl (a : α) : @encode (α ⊕ β) _ (Sum.inl a) = 2 * (encode a) :=\n rfl\n\n@[simp]\ntheorem encode_inr (b : β) : @encode (α ⊕ β) _ (Sum.inr b) = 2 * (encode b) + 1 :=\n rfl\n\n@[simp]\ntheorem decode_sum_val (n : ℕ) : (decode n : Option (α ⊕ β)) = decodeSum n :=\n rfl\n\nend Sum\n\ninstance _root_.Bool.encodable : Encodable Bool :=\n ofEquiv (Unit ⊕ Unit) Equiv.boolEquivPUnitSumPUnit\n\n@[simp]\ntheorem encode_true : encode true = 1 :=\n rfl\n\n@[simp]\ntheorem encode_false : encode false = 0 :=\n rfl\n\n@[simp]\ntheorem decode_zero : (decode 0 : Option Bool) = some false :=\n rfl\n\n@[simp]\ntheorem decode_one : (decode 1 : Option Bool) = some true :=\n rfl\n\nTarget:\ntheorem decode_ge_two (n) (h : 2 ≤ n) : (decode n : Option Bool) = none :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n suffices decodeSum n = none by\n change (decodeSum n).bind _ = none\n rw [this]\n rfl\n have : 1 ≤ n / 2 := by\n rw [Nat.le_div_iff_mul_le]\n exacts [h, by decide]\n obtain ⟨m, e⟩ := exists_eq_succ_of_ne_zero (_root_.ne_of_gt this)\n simp only [decodeSum, div2_val]; cases bodd n <;> simp [e]\n\nnoncomputable instance _root_.Prop.encodable : Encodable Prop :=\n ofEquiv Bool Equiv.propEquivBool","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Encodable","family_id":"decode_ge_two","file_id":"mathlib/Mathlib/Logic/Encodable/Basic.lean","sample_id":"82255e2f34c8bd869145c6aef2277f38ae065d62ce5efa8852e09b8aec94c904"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5baa8fd8d5b48b149bf21a6d58219128080c5e1ffeb44f557218583cce3b249b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"b6167882afe23654f488ada2d4980448cde13464f6de3b6ceb89fd9d3bc88afb","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9924b14e596b2478e18d8d3a8db493d39e893e432df655d49ca742b3dc936c54","source_sha256":"0b42aa0f0b2580e1dee118f374ef5324e4aee9624b44ec312c1fe8242e99f19b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← f.symm_symm, ← image_eq_preimage_symm, isLUB_image]","hard_negative":true,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.076923,"token_length_ratio":0.230769},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"d08606011e4317eed8e1b4abe81ac5692b1eba128387bc35adcf44399bd06f02","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Order.Bounds.Image\npublic import Mathlib.Order.Hom.Set\n\nNamespace:\nOrderIso\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov\n-/\n/-!\n# Order isomorphisms and bounds.\n-/\n\npublic section\n\nopen Set\n\nnamespace OrderIso\n\nvariable {α β : Type*} [Preorder α] [Preorder β] (f : α ≃o β)\n\ntheorem upperBounds_image {s : Set α} : upperBounds (f '' s) = f '' upperBounds s :=\n Subset.antisymm\n (fun x hx =>\n ⟨f.symm x, fun _ hy => f.le_symm_apply.2 (hx <| mem_image_of_mem _ hy), f.apply_symm_apply x⟩)\n f.monotone.image_upperBounds_subset_upperBounds_image\n\ntheorem lowerBounds_image {s : Set α} : lowerBounds (f '' s) = f '' lowerBounds s :=\n @upperBounds_image αᵒᵈ βᵒᵈ _ _ f.dual _\n\n@[simp]\ntheorem isLUB_image {s : Set α} {x : β} : IsLUB (f '' s) x ↔ IsLUB s (f.symm x) :=\n ⟨fun h => IsLUB.of_image (by simp) ((f.apply_symm_apply x).symm ▸ h), fun h =>\n (IsLUB.of_image (by simp)) <| (f.symm_image_image s).symm ▸ h⟩\n\ntheorem isLUB_image' {s : Set α} {x : α} : IsLUB (f '' s) (f x) ↔ IsLUB s x := by\n rw [isLUB_image, f.symm_apply_apply]\n\n@[simp]\ntheorem isGLB_image {s : Set α} {x : β} : IsGLB (f '' s) x ↔ IsGLB s (f.symm x) :=\n f.dual.isLUB_image\n\ntheorem isGLB_image' {s : Set α} {x : α} : IsGLB (f '' s) (f x) ↔ IsGLB s x :=\n f.dual.isLUB_image'\n\n@[simp]\n\nTarget:\ntheorem isLUB_preimage {s : Set β} {x : α} : IsLUB (f ⁻¹' s) x ↔ IsLUB s (f x) :=\n\nProof body:\n","rejected":"by\n exact isLUB_preimage","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"b7b2c6f2398c14a88f099883654c61ff309e0ce0e8833c501591e819d73e9bbb","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Bounds","family_id":"islub_preimage","file_id":"mathlib/Mathlib/Order/Bounds/OrderIso.lean","sample_id":"9924b14e596b2478e18d8d3a8db493d39e893e432df655d49ca742b3dc936c54"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"6238dae871a296f5e13851c3d38a0c20f6f9539aba325619937fae86bc5871f8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ea5b1067db59555cdd9ad22b3afbd762e30ca316a2d41fdc6f1b43d455f2d6fa","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0a56db36734f14b85df87590a36534279f8f1cd9baf6e3f7a3ccb5678f4cff8a","source_sha256":"e0cf750bab33871fed957f97175dd226e5ce595b457c9b4990b817b841e6f95b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have Y_sq : mk W' Y ^ 2 = mk W' (C (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆) -\n C (C W'.a₁ * X + C W'.a₃) * Y) := AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [polynomial]; ring1⟩\n simp only [smul, add_mul, mul_assoc, ← sq, Y_sq, map_sub, map_mul]\n ring1\n\nvariable (W') in\n/-- The ring homomorphism `R[W] →+* S[W.map f]` induced by a ring homomorphism `f : R →+* S`. -/\nnoncomputable def map (f : R →+* S) : W'.CoordinateRing →+* (W'.map f).CoordinateRing :=\n AdjoinRoot.lift ((AdjoinRoot.of _).comp <| mapRingHom f) (AdjoinRoot.root (W'.map f).polynomial)\n (by rw [← eval₂_map, ← map_polynomial, AdjoinRoot.eval₂_root])","hard_negative":true,"metrics":{"chosen_tokens":220,"rejected_tokens":2,"token_jaccard":0.012821,"token_length_ratio":0.009091},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"d4b2fbb40bdb104866affa944e1d598ca4ef37d0cb1d8e51dc21ed30b8301e9d","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula\npublic import Mathlib.LinearAlgebra.FreeModule.Norm\npublic import Mathlib.RingTheory.ClassGroup.Basic\npublic import Mathlib.RingTheory.Polynomial.UniqueFactorization\n\nNamespace:\nWeierstrassCurve.Affine.CoordinateRing\n\nLocal context:\n/-\nCopyright (c) 2025 David Kurniadi Angdinata. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Kurniadi Angdinata\n-/\n/-!\n# Nonsingular points and the group law in affine coordinates\n\nLet `W` be a Weierstrass curve over a field `F` given by a Weierstrass equation `W(X, Y) = 0` in\naffine coordinates. The type of nonsingular points in affine coordinates is an inductive, consisting\nof the unique point at infinity `𝓞` and nonsingular affine points `(x, y)`. It can be endowed with a\ngroup law, with `𝓞` as the identity nonsingular point, which is uniquely determined by the formulae\nin `Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean`.\n\nWith this description, there is an addition-preserving injection from the nonsingular points to the\nideal class group of the *affine coordinate ring* `F[W] := F[X, Y] / ⟨W(X, Y)⟩`. This is given by\nmapping `𝓞` to the trivial ideal class and a nonsingular affine point `(x, y)` to the ideal class of\nthe invertible ideal `⟨X - x, Y - y⟩`. Proving that this is well-defined and preserves addition\nreduces to equalities of ideals checked in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_neg_mul`\nand in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_mul_XYIdeal` via explicit ideal computations.\nNow `F[W]` is a free rank two `F[X]`-algebra with basis `{1, Y}`, so every element of `F[W]` is of\nthe form `p + qY` for some `p, q` in `F[X]`, and there is an algebra norm `N : F[W] → F[X]`.\nInjectivity can then be shown by computing the degree of such a norm `N(p + qY)` in two different\nways, which is done in `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis` and in the\nauxiliary lemmas in the proof of `WeierstrassCurve.Affine.Point.instAddCommGroup`.\n\nThis file defines the group law on nonsingular points in affine coordinates.\n\n## Main definitions\n\n* `WeierstrassCurve.Affine.CoordinateRing`: the affine coordinate ring `F[W]`.\n* `WeierstrassCurve.Affine.CoordinateRing.basis`: the power basis of `F[W]` over `F[X]`.\n* `WeierstrassCurve.Affine.Point`: a nonsingular point in affine coordinates.\n* `WeierstrassCurve.Affine.Point.neg`: the negation of a nonsingular point in affine coordinates.\n* `WeierstrassCurve.Affine.Point.add`: the addition of a nonsingular point in affine coordinates.\n\n## Main statements\n\n* `WeierstrassCurve.Affine.CoordinateRing.instIsDomainCoordinateRing`: the affine coordinate ring\n of a Weierstrass curve is an integral domain.\n* `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis`: the degree of the norm of an\n element in the affine coordinate ring in terms of its power basis.\n* `WeierstrassCurve.Affine.Point.instAddCommGroup`: the type of nonsingular points in affine\n coordinates forms an abelian group under addition.\n\n## References\n\n* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]\n* https://drops.dagstuhl.de/storage/00lipics/lipics-vol268-itp2023/LIPIcs.ITP.2023.6/LIPIcs.ITP.2023.6.pdf\n\n## Tags\n\nelliptic curve, affine, point, group law, class group\n-/\n\n@[expose] public section\n\nopen FractionalIdeal (coeIdeal_mul)\n\nopen Ideal hiding map_mul\n\nopen Module Polynomial\n\nopen scoped nonZeroDivisors Polynomial.Bivariate\n\nlocal macro \"C_simp\" : tactic =>\n `(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])\n\nuniverse r s u v w\n\nnamespace WeierstrassCurve\n\nvariable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} {L : Type w} [CommRing R]\n [CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] [Field L] {W' : Affine R}\n {W : Affine F}\n\nnamespace Affine\n\n/-! ## The affine coordinate ring -/\n\nvariable (W') in\n/-- The affine coordinate ring `R[W] := R[X, Y] / ⟨W(X, Y)⟩` of a Weierstrass curve `W`. -/\nabbrev CoordinateRing : Type r :=\n AdjoinRoot W'.polynomial\n\nvariable (W') in\n/-- The function field `R(W) := Frac(R[W])` of a Weierstrass curve `W`. -/\nabbrev FunctionField : Type r :=\n FractionRing W'.CoordinateRing\n\nnamespace CoordinateRing\n\nnoncomputable instance : Algebra R W'.CoordinateRing := inferInstance\n\nnoncomputable instance : Algebra R[X] W'.CoordinateRing := inferInstance\n\ninstance : IsScalarTower R R[X] W'.CoordinateRing := inferInstance\n\ninstance [Subsingleton R] : Subsingleton W'.CoordinateRing :=\n Module.subsingleton R[X] _\n\nvariable (W') in\n/-- The natural ring homomorphism mapping `R[X][Y]` to `R[W]`. -/\nnoncomputable abbrev mk : R[X][Y] →+* W'.CoordinateRing :=\n AdjoinRoot.mk W'.polynomial\n\nopen scoped Classical in\nvariable (W') in\n/-- The power basis `{1, Y}` for `R[W]` over `R[X]`. -/\nprotected noncomputable def basis : Basis (Fin 2) R[X] W'.CoordinateRing :=\n (subsingleton_or_nontrivial R).by_cases (fun _ => default) fun _ =>\n (AdjoinRoot.powerBasis' monic_polynomial).basis.reindex <| finCongr natDegree_polynomial\n\nlemma basis_apply (n : Fin 2) :\n CoordinateRing.basis W' n = (AdjoinRoot.powerBasis' monic_polynomial).gen ^ (n : ℕ) := by\n classical\n nontriviality R\n rw [CoordinateRing.basis, Or.by_cases, dif_neg <| not_subsingleton R, Basis.reindex_apply,\n PowerBasis.basis_eq_pow, finCongr_symm_apply, Fin.val_cast]\n\n@[simp]\nlemma basis_zero : CoordinateRing.basis W' 0 = 1 := by\n simpa only [basis_apply] using! pow_zero _\n\n@[simp]\nlemma basis_one : CoordinateRing.basis W' 1 = mk W' Y := by\n simpa only [basis_apply] using! pow_one _\n\nlemma coe_basis : (CoordinateRing.basis W' : Fin 2 → W'.CoordinateRing) = ![1, mk W' Y] := by\n ext n\n fin_cases n\n exacts [basis_zero, basis_one]\n\nlemma smul (x : R[X]) (y : W'.CoordinateRing) : x • y = mk W' (C x) * y :=\n (algebraMap_smul W'.CoordinateRing x y).symm\n\nlemma smul_basis_eq_zero {p q : R[X]} (hpq : p • (1 : W'.CoordinateRing) + q • mk W' Y = 0) :\n p = 0 ∧ q = 0 := by\n have h := Fintype.linearIndependent_iff.mp (CoordinateRing.basis W').linearIndependent ![p, q]\n rw [Fin.sum_univ_succ, basis_zero, Fin.sum_univ_one, Fin.succ_zero_eq_one, basis_one] at h\n exact ⟨h hpq 0, h hpq 1⟩\n\nlemma exists_smul_basis_eq (x : W'.CoordinateRing) :\n ∃ p q : R[X], p • (1 : W'.CoordinateRing) + q • mk W' Y = x := by\n have h := (CoordinateRing.basis W').sum_equivFun x\n rw [Fin.sum_univ_succ, Fin.sum_univ_one, basis_zero, Fin.succ_zero_eq_one, basis_one] at h\n exact ⟨_, _, h⟩\n\nlemma smul_basis_mul_C (y : R[X]) (p q : R[X]) :\n (p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' (C y) =\n (p * y) • (1 : W'.CoordinateRing) + (q * y) • mk W' Y := by\n simp only [smul, map_mul]\n ring1\n\nTarget:\nlemma smul_basis_mul_Y (p q : R[X]) : (p • (1 : W'.CoordinateRing) + q • mk W' Y) * mk W' Y =\n (q * (X ^ 3 + C W'.a₂ * X ^ 2 + C W'.a₄ * X + C W'.a₆)) • (1 : W'.CoordinateRing) +\n (p - q * (C W'.a₁ * X + C W'.a₃)) • mk W' Y :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_0a56db36734f","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"5a64cb93e7419f10e0fdaa8eba3acea9f58a4a5bbafc6f68d91d4fb6d47e079b","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/EllipticCurve","family_id":"smul_basis_mul_y","file_id":"mathlib/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean","sample_id":"0a56db36734f14b85df87590a36534279f8f1cd9baf6e3f7a3ccb5678f4cff8a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"414f3043171e88a003ffe9fb6e79021da834dc6bfc40d83e9a6e3fb508f24e29","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"dbd658f044dd3787e502738df4280923dc621c6214589a052e24a7c684b213f6","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"025ea6bc4b689a5e0068ab86c471873a7cfcb310a85f88cab7a08a145748ff30","source_sha256":"96b93e774d7f2071797742aab74d7371dec26b20348c9f93cd322847a9ed2c09","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [ofUnitHom]\n\n/-- The equivalence between multiplicative characters and homomorphisms of unit groups. -/\nnoncomputable def equivToUnitHom : MulChar R R' ≃ (Rˣ →* R'ˣ) where\n toFun := toUnitHom\n invFun := ofUnitHom\n left_inv := by\n intro χ\n ext x\n rw [ofUnitHom_coe, coe_toUnitHom]\n right_inv := by\n intro f\n ext x\n simp only [coe_toUnitHom, ofUnitHom_coe]","hard_negative":false,"metrics":{"chosen_tokens":71,"rejected_tokens":76,"token_jaccard":0.923077,"token_length_ratio":1.070423},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"d4e970102cfda24adfbdb7fbf6a86076c41c881d67e76553de5b930a5bf6e75c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.CharP.Basic\npublic import Mathlib.Algebra.CharP.Lemmas\npublic import Mathlib.Algebra.Group.Submonoid.Units\npublic import Mathlib.Algebra.GroupWithZero.Units.Fintype\npublic import Mathlib.GroupTheory.OrderOfElement\n\nNamespace:\nMulChar\n\nLocal context:\n/-\nCopyright (c) 2022 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Multiplicative characters of finite rings and fields\n\nLet `R` and `R'` be commutative rings.\nA *multiplicative character* of `R` with values in `R'` is a morphism of\nmonoids from the multiplicative monoid of `R` into that of `R'`\nthat sends non-units to zero.\n\nWe use the namespace `MulChar` for the definitions and results.\n\n## Main results\n\nWe show that the multiplicative characters form a group (if `R'` is commutative);\nsee `MulChar.commGroup`. We also provide an equivalence with the\nhomomorphisms `Rˣ →* R'ˣ`; see `MulChar.equivToUnitHom`.\n\nWe define a multiplicative character to be *quadratic* if its values\nare among `0`, `1` and `-1`, and we prove some properties of quadratic characters.\n\nFinally, we show that the sum of all values of a nontrivial multiplicative\ncharacter vanishes; see `MulChar.IsNontrivial.sum_eq_zero`.\n\n## Tags\n\nmultiplicative character\n-/\n\n@[expose] public section\n\nopen scoped Ring\n\n\n/-!\n### Definitions related to multiplicative characters\n\nEven though the intended use is when domain and target of the characters\nare commutative rings, we define them in the more general setting when\nthe domain is a commutative monoid and the target is a commutative monoid\nwith zero. (We need a zero in the target, since non-units are supposed\nto map to zero.)\n\nIn this setting, there is an equivalence between multiplicative characters\n`R → R'` and group homomorphisms `Rˣ → R'ˣ`, and the multiplicative characters\nhave a natural structure as a commutative group.\n-/\n\n\nsection Defi\n\n-- The domain of our multiplicative characters\nvariable (R : Type*) [CommMonoid R]\n\n-- The target\nvariable (R' : Type*) [CommMonoidWithZero R']\n\n/-- Define a structure for multiplicative characters.\nA multiplicative character from a commutative monoid `R` to a commutative monoid with zero `R'`\nis a homomorphism of (multiplicative) monoids that sends non-units to zero. -/\nstructure MulChar extends MonoidHom R R' where\n map_nonunit' : ∀ a : R, ¬IsUnit a → toFun a = 0\n\ninstance MulChar.instFunLike : FunLike (MulChar R R') R R' :=\n ⟨fun χ => χ.toFun,\n fun χ₀ χ₁ h => by cases χ₀; cases χ₁; congr; apply MonoidHom.ext (fun _ => congr_fun h _)⟩\n\n/-- This is the corresponding extension of `MonoidHomClass`. -/\nclass MulCharClass (F : Type*) (R R' : outParam Type*) [CommMonoid R]\n [CommMonoidWithZero R'] [FunLike F R R'] : Prop extends MonoidHomClass F R R' where\n map_nonunit : ∀ (χ : F) {a : R} (_ : ¬IsUnit a), χ a = 0\n\ninitialize_simps_projections MulChar (toFun → apply, -toMonoidHom)\n\nend Defi\n\nnamespace MulChar\n\nattribute [scoped simp] MulCharClass.map_nonunit\n\nsection Group\n\n-- The domain of our multiplicative characters\nvariable {R : Type*} [CommMonoid R]\n\n-- The target\nvariable {R' : Type*} [CommMonoidWithZero R']\n\nvariable (R R') in\n/-- The trivial multiplicative character. It takes the value `0` on non-units and\nthe value `1` on units. -/\n@[simps]\nnoncomputable def trivial : MulChar R R' where\n toFun := by classical exact fun x => if IsUnit x then 1 else 0\n map_nonunit' := by\n intro a ha\n simp only [ha, if_false]\n map_one' := by simp only [isUnit_one, if_true]\n map_mul' := by\n intro x y\n classical\n simp only [IsUnit.mul_iff, boole_mul]\n split_ifs <;> tauto\n\n@[simp]\ntheorem coe_mk (f : R →* R') (hf) : (MulChar.mk f hf : R → R') = f :=\n rfl\n\n/-- Extensionality. See `ext` below for the version that will actually be used. -/\ntheorem ext' {χ χ' : MulChar R R'} (h : ∀ a, χ a = χ' a) : χ = χ' := DFunLike.ext _ _ h\n\ninstance : MulCharClass (MulChar R R') R R' where\n map_mul χ := χ.map_mul'\n map_one χ := χ.map_one'\n map_nonunit χ := χ.map_nonunit' _\n\ntheorem map_nonunit (χ : MulChar R R') {a : R} (ha : ¬IsUnit a) : χ a = 0 :=\n χ.map_nonunit' a ha\n\n/-- Extensionality. Since `MulChar`s always take the value zero on non-units, it is sufficient\nto compare the values on units. -/\n@[ext]\ntheorem ext {χ χ' : MulChar R R'} (h : ∀ a : Rˣ, χ a = χ' a) : χ = χ' := by\n apply ext'\n intro a\n by_cases ha : IsUnit a\n · exact h ha.unit\n · rw [map_nonunit χ ha, map_nonunit χ' ha]\n\n/-!\n### Equivalence of multiplicative characters with homomorphisms on units\n\nWe show that restriction / extension by zero gives an equivalence\nbetween `MulChar R R'` and `Rˣ →* R'ˣ`.\n-/\n\n\n/-- Turn a `MulChar` into a homomorphism between the unit groups. -/\ndef toUnitHom (χ : MulChar R R') : Rˣ →* R'ˣ :=\n Units.map χ\n\ntheorem coe_toUnitHom (χ : MulChar R R') (a : Rˣ) : ↑(χ.toUnitHom a) = χ a :=\n rfl\n\n/-- Turn a homomorphism between unit groups into a `MulChar`. -/\nnoncomputable def ofUnitHom (f : Rˣ →* R'ˣ) : MulChar R R' where\n toFun := by classical exact fun x => if hx : IsUnit x then f hx.unit else 0\n map_one' := by\n have h1 : (isUnit_one.unit : Rˣ) = 1 := Units.ext rfl\n simp only [h1, dif_pos, Units.val_eq_one, map_one, isUnit_one]\n map_mul' := by\n classical\n intro x y\n by_cases hx : IsUnit x\n · simp only [hx, IsUnit.mul_iff, true_and, dif_pos]\n by_cases hy : IsUnit y\n · simp only [hy, dif_pos]\n have hm : (hx.mul hy).unit = hx.unit * hy.unit := Units.ext rfl\n rw [hm, map_mul]\n norm_cast\n · simp only [hy, not_false_iff, dif_neg, mul_zero]\n · simp only [hx, IsUnit.mul_iff, false_and, not_false_iff, dif_neg, zero_mul]\n map_nonunit' := by\n intro a ha\n simp only [ha, not_false_iff, dif_neg]\n\nTarget:\ntheorem ofUnitHom_coe (f : Rˣ →* R'ˣ) (a : Rˣ) : ofUnitHom f ↑a = f a :=\n\nProof body:\n","rejected":"by simp [ofUnitHom]\n\n/-- The equivalence between multiplicative characters and homomorphisms of unit groups. -/\nnoncomputable def equivToUnitHom : MulChar R R' ≃ (Rˣ →* R'ˣ) where\n toFun := toUnitHom\n invFun := ofUnitHom\n left_inv := by\n intro χ\n ext x\n rw [ofUnitHom_coe, coe_toUnitHom]\n right_inv := by\n intro f\n ext x\n simp only [coe_toUnitHom, ofUnitHom_coe]\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/MulChar","family_id":"ofunithom_coe","file_id":"mathlib/Mathlib/NumberTheory/MulChar/Basic.lean","sample_id":"025ea6bc4b689a5e0068ab86c471873a7cfcb310a85f88cab7a08a145748ff30"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"19cafd6eb0e18f6bd0d779fcdb8a60d79941b3ac55ca2293115640d385a5403c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"61edb107e4410d1c6e3c7d14ba3c27121b18ccb05d2782ec9d08f03ebfc5b362","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext a\n exact DistribMulActionHom.congr_fun h a","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":5,"token_jaccard":0.181818,"token_length_ratio":0.555556},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"d5d476664ff9420675126d336ef1443d833472de60f40b5c914a596a5e5f3907","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\nTarget:\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"to_distribmulactionhom_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"61edb107e4410d1c6e3c7d14ba3c27121b18ccb05d2782ec9d08f03ebfc5b362"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"55bc562d9fd0b1c2c50e31f3a6f0beaf9317e203f31595fc6e175c69e8889603","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"4edc663c8fd5b1bb7d40033f6036173cb00f7976a13696e364607d8a795c9525","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"374c11cbff3300b3c3e7ffa6df8b6a3e7ec2b9539d9534511078400bd59abdde","source_sha256":"8fa72a43e680b83403f64aed4f242d29897ff5dbd1caf9a8138cd5ff2f09e69b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]\n exact le_ciInf_add_ciInf h","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":23,"token_jaccard":0.823529,"token_length_ratio":1.210526},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"d75e7d735aa7f55c34f889027903e02493ad775ceea95fa62c1d3a8db82be857","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.BigOperators.Expect\npublic import Mathlib.Algebra.Order.BigOperators.Group.Finset\npublic import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset\npublic import Mathlib.Algebra.Order.Field.Canonical\npublic import Mathlib.Algebra.Order.Nonneg.Floor\npublic import Mathlib.Data.Real.Pointwise\npublic import Mathlib.Data.NNReal.Defs\npublic import Mathlib.Order.ConditionallyCompleteLattice.Group\npublic import Mathlib.Order.Lattice.Nat\n\nNamespace:\nNNReal\n\nLocal context:\n/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Basic results on nonnegative real numbers\n\nThis file contains all results on `NNReal` that do not directly follow from its basic structure.\nAs a consequence, it is a bit of a random collection of results, and is a good target for cleanup.\n\n## Notation\n\nThis file uses `ℝ≥0` as a localized notation for `NNReal`.\n-/\n\npublic section\n\nassert_not_exists TrivialStar\n\nopen Function Set\nopen scoped BigOperators\n\nnamespace NNReal\nvariable {M : Type*} [Zero M]\n\nnoncomputable instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)\n\n@[simp, norm_cast]\ntheorem coe_mulIndicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.mulIndicator f a : ℝ≥0) : ℝ) = s.mulIndicator (fun x => ↑(f x)) a :=\n map_mulIndicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_indicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :\n ((s.indicator f a : ℝ≥0) : ℝ) = s.indicator (fun x => ↑(f x)) a :=\n map_indicator toRealHom _ _ _\n\n@[simp, norm_cast]\ntheorem coe_mulSingle {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.mulSingle a b : α → ℝ≥0) c : ℝ) = (Pi.mulSingle a b : α → ℝ) c := by\n simpa using coe_mulIndicator {a} (fun _ ↦ b) c\n\n@[simp, norm_cast]\ntheorem coe_single {α} [DecidableEq α] (a : α) (b : ℝ≥0) (c : α) :\n ((Pi.single a b : α → ℝ≥0) c : ℝ) = (Pi.single a b : α → ℝ) c := by\n simpa using coe_indicator {a} (fun _ ↦ b) c\n\n@[norm_cast]\ntheorem coe_list_sum (l : List ℝ≥0) : ((l.sum : ℝ≥0) : ℝ) = (l.map (↑)).sum :=\n map_list_sum toRealHom l\n\n@[norm_cast]\ntheorem coe_list_prod (l : List ℝ≥0) : ((l.prod : ℝ≥0) : ℝ) = (l.map (↑)).prod :=\n map_list_prod toRealHom l\n\n@[norm_cast]\ntheorem coe_multiset_sum (s : Multiset ℝ≥0) : ((s.sum : ℝ≥0) : ℝ) = (s.map (↑)).sum :=\n map_multiset_sum toRealHom s\n\n@[norm_cast]\ntheorem coe_multiset_prod (s : Multiset ℝ≥0) : ((s.prod : ℝ≥0) : ℝ) = (s.map (↑)).prod :=\n map_multiset_prod toRealHom s\n\nvariable {ι : Type*} {s : Finset ι} {f : ι → ℝ}\n\n@[simp, norm_cast]\ntheorem coe_sum (s : Finset ι) (f : ι → ℝ≥0) : ∑ i ∈ s, f i = ∑ i ∈ s, (f i : ℝ) :=\n map_sum toRealHom _ _\n\n@[simp, norm_cast]\nlemma toReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.sum g = f.sum (fun i m ↦ toReal (g i m)) := map_finsuppSum toRealHom ..\n\n@[simp, norm_cast]\nlemma toReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :\n f.prod g = f.prod (fun i m ↦ toReal (g i m)) := map_finsuppProd toRealHom ..\n\n@[simp, norm_cast]\nlemma coe_expect (s : Finset ι) (f : ι → ℝ≥0) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : ℝ) :=\n map_expect toRealHom ..\n\ntheorem _root_.Real.toNNReal_sum_of_nonneg (hf : ∀ i ∈ s, 0 ≤ f i) :\n Real.toNNReal (∑ a ∈ s, f a) = ∑ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_sum, Real.coe_toNNReal _ (Finset.sum_nonneg hf)]\n exact Finset.sum_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\n@[simp, norm_cast]\ntheorem coe_prod (s : Finset ι) (f : ι → ℝ≥0) : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ) :=\n map_prod toRealHom _ _\n\ntheorem _root_.Real.toNNReal_prod_of_nonneg (hf : ∀ a, a ∈ s → 0 ≤ f a) :\n Real.toNNReal (∏ a ∈ s, f a) = ∏ a ∈ s, Real.toNNReal (f a) := by\n rw [← coe_inj, NNReal.coe_prod, Real.coe_toNNReal _ (Finset.prod_nonneg hf)]\n exact Finset.prod_congr rfl fun x hxs => by rw [Real.coe_toNNReal _ (hf x hxs)]\n\nTarget:\ntheorem le_iInf_add_iInf {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0} {g : ι' → ℝ≥0}\n {a : ℝ≥0} (h : ∀ i j, a ≤ f i + g j) : a ≤ (⨅ i, f i) + ⨅ j, g j :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [← NNReal.coe_le_coe, NNReal.coe_add, coe_iInf, coe_iInf]\n exact le_ciInf_add_ciInf h","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/NNReal","family_id":"le_iinf_add_iinf","file_id":"mathlib/Mathlib/Data/NNReal/Basic.lean","sample_id":"374c11cbff3300b3c3e7ffa6df8b6a3e7ec2b9539d9534511078400bd59abdde"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"eb30d3ad95b52463de71194a78ec81212add641f0c9704c3cf7d39f339950416","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a798017481316815a1a4249d25febbcb464077661863b00806c43b9bf66968fd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"354c6ab9240d489d760785405022488141481fc93a2bd2a7c656b6c3a3e54013","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by ext; simp","hard_negative":true,"metrics":{"chosen_tokens":4,"rejected_tokens":5,"token_jaccard":0.125,"token_length_ratio":1.25},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"d7b134a978701b6350d28c6637ba5433c39b296baecdbdfc1e9c97ac3a9ec37e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x := by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective\n\nTarget:\ntheorem toSpanSingleton_one_eq_algebraLinearMap :\n toSpanSingleton R A 1 = Algebra.linearMap R A :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_354c6ab9240d","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"d0adb4f4b08047d199184eaa0d718621a001a23eb73451cecfa26a6919d0597d","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"tospansingleton_one_eq_algebralinearmap","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"354c6ab9240d489d760785405022488141481fc93a2bd2a7c656b6c3a3e54013"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"790c5aaab79f4f715145265a6ef8df9f564a0559edc4261cfb98800ae2d78271","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"66d4b7c19b4e4d9dc312bb2dfef75336c9e377ea5b1e2cb3a5583b0be9334e8a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"793e693d90ab67d9e0d5ee5dd4ffe6bd0abcc56a8405ed1090263465696fa76f","source_sha256":"8556868e97c2f0a55cbc6fdeb87479062f2695e69c83e5f32206d26061a5f4d3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n refine ⟨fun h ↦ ?_, isEpi_of_surjective_algebraMap R A⟩\n let R' := (Algebra.linearMap R A).range\n rcases subsingleton_or_nontrivial (A ⧸ R') with h | _\n · rwa [Submodule.Quotient.subsingleton_iff, LinearMap.range_eq_top] at h\n have : Subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R')) := by\n refine subsingleton_of_forall_eq 0 fun y ↦ ?_\n induction y with\n | zero => rfl\n | add a b e₁ e₂ => rwa [e₁, zero_add]\n | tmul x y =>\n obtain ⟨x, rfl⟩ := R'.mkQ_surjective x\n obtain ⟨y, rfl⟩ := R'.mkQ_surjective y\n obtain ⟨s, hs⟩ : ∃ s, 1 ⊗ₜ[R] s = x ⊗ₜ[R] y := by\n use x * y\n trans x ⊗ₜ 1 * 1 ⊗ₜ y\n · simp [(isEpi_iff_forall_one_tmul_eq R A).mp]\n · simp\n have : R'.mkQ 1 = 0 := (Submodule.Quotient.mk_eq_zero R').mpr ⟨1, map_one (algebraMap R A)⟩\n rw [← map_tmul R'.mkQ R'.mkQ, ← hs, map_tmul, this, zero_tmul]\n cases false_of_nontrivial_of_subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R'))","hard_negative":false,"metrics":{"chosen_tokens":251,"rejected_tokens":256,"token_jaccard":0.954023,"token_length_ratio":1.01992},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"d7b894bde18b03a74c4dcde51440338366d29dd6b41bee3afcd0c5b21b7c57f2","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Bilinear\npublic import Mathlib.LinearAlgebra.TensorProduct.Tower\npublic import Mathlib.RingTheory.Localization.FractionRing\npublic import Mathlib.RingTheory.TensorProduct.Finite\n\nNamespace:\nAlgebra\n\nLocal context:\n/-\nCopyright (c) 2026 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\n/-!\n# Algebras which are commutative ring epimorphisms\n-/\n\n@[expose] public section\n\nnoncomputable section\nopen Function TensorProduct\n\nnamespace Algebra\n\nsection Semiring\n\nvariable (R A : Type*) [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- A commutative `R`-algebra `A` is epi, if the multiplication map `A ⊗[R] A → A` is injective. -/\nprotected class IsEpi : Prop where\n injective_lift_mul : Injective <| lift <| LinearMap.mul R A\n\n/-- See also `CommRingCat.epi_iff_epi`. -/\nlemma isEpi_iff_forall_one_tmul_eq :\n Algebra.IsEpi R A ↔ ∀ a : A, 1 ⊗ₜ[R] a = a ⊗ₜ[R] 1 := by\n refine ⟨fun h a ↦ IsEpi.injective_lift_mul <| by simp, fun h ↦ ⟨fun x y hxy ↦ ?_⟩⟩\n have h' (x : A ⊗[R] A) : ∃ a : A, x = a ⊗ₜ 1 := by\n induction x using TensorProduct.induction_on with\n | zero => exact ⟨0, by simp⟩\n | tmul u v =>\n use u * v\n calc u ⊗ₜ[R] v = u ⊗ₜ[R] 1 * 1 ⊗ₜ[R] v := by simp\n _ = u ⊗ₜ[R] 1 * v ⊗ₜ[R] 1 := by rw [h]\n _ = (u * v) ⊗ₜ[R] 1 := by simp\n | add u v hu hv =>\n obtain ⟨u, rfl⟩ := hu\n obtain ⟨v, rfl⟩ := hv\n exact ⟨u + v, by simp [add_tmul]⟩\n obtain ⟨a, rfl⟩ := h' x\n obtain ⟨b, rfl⟩ := h' y\n aesop\n\n/-- See also `Algebra.isEpi_iff_surjective_algebraMap_of_finite`. -/\nlemma isEpi_of_surjective_algebraMap (h : Surjective (algebraMap R A)) :\n Algebra.IsEpi R A := by\n refine (isEpi_iff_forall_one_tmul_eq R A).mpr fun a ↦ ?_\n obtain ⟨r, rfl⟩ := h a\n rw [algebraMap_eq_smul_one, smul_tmul]\n\nend Semiring\n\n-- TODO Generalise to any localization\ninstance (R A : Type*) [CommRing R] [IsDomain R] [Field A] [Algebra R A] [IsFractionRing R A] :\n Algebra.IsEpi R A := by\n refine (isEpi_iff_forall_one_tmul_eq R A).mpr fun x ↦ ?_\n obtain ⟨a, b, hb, rfl⟩ := IsFractionRing.div_surjective R x\n set f := algebraMap R A with hf\n replace hb : f b ≠ 0 := by aesop\n calc 1 ⊗ₜ[R] (f a / f b)\n = 1 ⊗ₜ[R] (a • (1 / f b)) := by rw [← smul_div_assoc, algebraMap_eq_smul_one a]\n _ = f a ⊗ₜ[R] (1 / f b) := by rw [← smul_tmul, algebraMap_eq_smul_one a]\n _ = (b • (f a / f b)) ⊗ₜ[R] (1 / f b) := by rw [smul_def, mul_div_cancel₀ _ hb]\n _ = (f a / f b) ⊗ₜ[R] (b • (1 / f b)) := by rw [smul_tmul]\n _ = (f a / f b) ⊗ₜ[R] 1 := by rw [smul_def, mul_div_cancel₀ _ hb]\n\nsection Ring\n\nvariable {R A : Type*} [CommRing R] [Ring A] [Algebra R A]\n\nTarget:\nlemma isEpi_iff_surjective_algebraMap_of_finite [Module.Finite R A] :\n Algebra.IsEpi R A ↔ Surjective (algebraMap R A) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n refine ⟨fun h ↦ ?_, isEpi_of_surjective_algebraMap R A⟩\n let R' := (Algebra.linearMap R A).range\n rcases subsingleton_or_nontrivial (A ⧸ R') with h | _\n · rwa [Submodule.Quotient.subsingleton_iff, LinearMap.range_eq_top] at h\n have : Subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R')) := by\n refine subsingleton_of_forall_eq 0 fun y ↦ ?_\n induction y with\n | zero => rfl\n | add a b e₁ e₂ => rwa [e₁, zero_add]\n | tmul x y =>\n obtain ⟨x, rfl⟩ := R'.mkQ_surjective x\n obtain ⟨y, rfl⟩ := R'.mkQ_surjective y\n obtain ⟨s, hs⟩ : ∃ s, 1 ⊗ₜ[R] s = x ⊗ₜ[R] y := by\n use x * y\n trans x ⊗ₜ 1 * 1 ⊗ₜ y\n · simp [(isEpi_iff_forall_one_tmul_eq R A).mp]\n · simp\n have : R'.mkQ 1 = 0 := (Submodule.Quotient.mk_eq_zero R').mpr ⟨1, map_one (algebraMap R A)⟩\n rw [← map_tmul R'.mkQ R'.mkQ, ← hs, map_tmul, this, zero_tmul]\n cases false_of_nontrivial_of_subsingleton ((A ⧸ R') ⊗[R] (A ⧸ R'))","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Algebra","family_id":"isepi_iff_surjective_algebramap_of_finite","file_id":"mathlib/Mathlib/Algebra/Algebra/Epi.lean","sample_id":"793e693d90ab67d9e0d5ee5dd4ffe6bd0abcc56a8405ed1090263465696fa76f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5a761837ffec5e8a77b1f2327450071cb981ebac00b45daf2e26ebda06d2cb51","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e24732b0f9210e3970530279fd8af200c184f576c489cb66cd869725d4803016","source_sha256":"506091950f9a5ddd7bcf057ff1f552335cf3d11ecb0050a4aad97186871b2737","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa only [smul_one_smul] using SMulInvariantMeasure.measure_preimage_smul (c • 1 : N) hsm\n aeconst_of_forall_preimage_smul_ae_eq {s} hsm hs := by\n refine aeconst_of_dense_setOf_preimage_smul_ae (M := N) hsm.nullMeasurableSet ?_\n refine (MulAction.dense_orbit M 1).mono ?_\n rintro _ ⟨g, rfl⟩\n simpa using hs g","hard_negative":true,"metrics":{"chosen_tokens":61,"rejected_tokens":8,"token_jaccard":0.069767,"token_length_ratio":0.131148},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"d7e2aa43b7a8e64de82d63a9ab1fd92e94b045ab22b959fc981efc0bcdae6a08","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Dynamics.Ergodic.Action.Regular\npublic import Mathlib.MeasureTheory.Measure.ContinuousPreimage\npublic import Mathlib.MeasureTheory.Measure.Haar.Unique\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Ergodicity from minimality\n\nIn this file we prove that the left shift `(a * ·)` on a compact topological group `G`\nis ergodic with respect to the Haar measure if and only if it is minimal,\ni.e., the powers `a ^ n` are dense in `G`.\n\nThe proof of the more difficult \"if minimal, then ergodic\" implication\nis based on the ergodicity of the left action of a group on itself\nand the following fact that we prove in `ergodic_smul_of_denseRange_pow` below:\n\nIf a monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural powers are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the scalar multiplication by `g` is an ergodic map.\n\nWe also prove that a continuous monoid homomorphism `f : G →* G` is ergodic,\nif it is surjective and the preimages of `1` under iterations of `f` are dense in the group.\nThis theorem applies, e.g., to the map `z ↦ n • z` on the additive circle or a torus.\n-/\n\npublic section\n\nopen MeasureTheory Filter Set Function\nopen scoped Pointwise Topology\n\nsection SMul\n\nvariable {M : Type*} [TopologicalSpace M]\n {X : Type*} [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]\n [SMul M X] [ContinuousSMul M X]\n {μ : Measure X} [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] {s : Set X}\n\n/-- Let `M` act continuously on an R₁ topological space `X`.\nLet `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.\nIf a null measurable set `s` is a.e. equal\nto its preimages under the action of a dense set of elements of `M`,\nthen it is either null or conull. -/\n@[to_additive /-- Let `M` act continuously on an R₁ topological space `X`.\nLet `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.\nIf a null measurable set `s` is a.e. equal\nto its preimages under the action of a dense set of elements of `M`,\nthen it is either null or conull. -/]\ntheorem aeconst_of_dense_setOf_preimage_smul_ae (hsm : NullMeasurableSet s μ)\n (hd : Dense {g : M | (g • ·) ⁻¹' s =ᵐ[μ] s}) : EventuallyConst s (ae μ) := by\n borelize M\n refine aeconst_of_forall_preimage_smul_ae_eq M hsm ?_\n rwa [dense_iff_closure_eq, IsClosed.closure_eq, eq_univ_iff_forall] at hd\n let f : C(M × X, X) := ⟨(· • ·).uncurry, continuous_smul⟩\n exact isClosed_setOf_preimage_ae_eq f.curry.continuous (measurePreserving_smul · μ) _ hsm\n (measure_ne_top _ _)\n\n@[to_additive]\ntheorem aeconst_of_dense_setOf_preimage_smul_eq (hsm : NullMeasurableSet s μ)\n (hd : Dense {g : M | (g • ·) ⁻¹' s = s}) : EventuallyConst s (ae μ) :=\n aeconst_of_dense_setOf_preimage_smul_ae hsm <| hd.mono fun _ h ↦ mem_setOf.2 <| .of_eq h\n\n/-- If a monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural powers are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the scalar multiplication by `g` is an ergodic map. -/\n@[to_additive /-- If an additive monoid `M` continuously acts on an R₁ topological space `X`,\n`g` is an element of `M` such that its natural multiples are dense in `M`,\nand `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,\nthen the vector addition of `g` is an ergodic map. -/]\ntheorem ergodic_smul_of_denseRange_pow {M : Type*} [Monoid M] [TopologicalSpace M]\n [MulAction M X] [ContinuousSMul M X] {g : M} (hg : DenseRange (g ^ · : ℕ → M))\n (μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] :\n Ergodic (g • ·) μ := by\n borelize M\n refine ⟨measurePreserving_smul _ _, ⟨fun s hsm hs ↦ ?_⟩⟩\n refine aeconst_of_dense_setOf_preimage_smul_eq hsm.nullMeasurableSet (hg.mono ?_)\n refine range_subset_iff.2 fun n ↦ ?_\n rw [mem_setOf, ← smul_iterate, preimage_iterate_eq, iterate_fixed hs]\n\nend SMul\n\nsection IsScalarTower\n\nvariable {M X : Type*} [Monoid M] [SMul M X]\n [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]\n (μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular]\n\n/-- If `N` acts continuously and ergodically on `X` and `M` acts minimally on `N`,\nthen the corresponding action of `M` on `X` is ergodic. -/\n@[to_additive\n /-- If `N` acts additively continuously and ergodically on `X` and `M` acts minimally on `N`,\nthen the corresponding action of `M` on `X` is ergodic. -/]\n\nTarget:\ntheorem ErgodicSMul.trans_isMinimal (N : Type*) [MulAction M N]\n [Monoid N] [TopologicalSpace N] [MulAction.IsMinimal M N]\n [MulAction N X] [IsScalarTower M N X] [ContinuousSMul N X] [ErgodicSMul N X μ] :\n ErgodicSMul M X μ where\n measure_preimage_smul c s hsm :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"351ec3730b51741350879b4fbd6831c323a214ebc696fb73db462b7e04b6096e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/Ergodic","family_id":"ergodicsmul","file_id":"mathlib/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean","sample_id":"e24732b0f9210e3970530279fd8af200c184f576c489cb66cd869725d4803016"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e463c0a51ae47a64bfacbe44ee3286b4937f046e3fd0e78fa6ba8aac816150fa","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d37839532a84c2d07a0730fd769a564b1722feba2c9b6fd17a5620baffb9e3a3","source_sha256":"f80f4ba6dd3c9529c67233c78268f6288754ad7511c9d37d6a6f6a1690fb2af0","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← fst_compEquiv, ← compEquiv_symm_inr]\n conv_rhs => rw [← LinearEquiv.symm_symm (compEquiv Q P)]\n rw [LinearEquiv.conj_exact_iff_exact]\n exact Function.Exact.inr_fst","hard_negative":true,"metrics":{"chosen_tokens":35,"rejected_tokens":8,"token_jaccard":0.034483,"token_length_ratio":0.228571},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"d81126701535b6246a3d803cfff5751543dcf659c78efe25bb59a1aa3e2b5f4a","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Extension.Cotangent.Basic\npublic import Mathlib.RingTheory.Extension.Generators\npublic import Mathlib.Algebra.Module.SnakeLemma\n\nNamespace:\nAlgebra.Generators\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n\n# The Jacobi-Zariski exact sequence\n\nGiven `R → S → T`, the Jacobi-Zariski exact sequence is\n```\nH¹(L_{T/R}) → H¹(L_{T/S}) → T ⊗[S] Ω[S/R] → Ω[T/R] → Ω[T/S] → 0\n```\nThe maps are\n- `Algebra.H1Cotangent.map`\n- `Algebra.H1Cotangent.δ`\n- `KaehlerDifferential.mapBaseChange`\n- `KaehlerDifferential.map`\n\nand the exactness lemmas are\n- `Algebra.H1Cotangent.exact_map_δ`\n- `Algebra.H1Cotangent.exact_δ_mapBaseChange`\n- `KaehlerDifferential.exact_mapBaseChange_map`\n- `KaehlerDifferential.map_surjective`\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential Module MvPolynomial TensorProduct\n\nnamespace Algebra\n\n-- `Generators.{w, u₁, u₂}` depends on three universe variables and\n-- to improve performance of universe unification, it should hold that\n-- `w > u₁` and `w > u₂` in the lexicographic order. For more details\n-- see https://github.com/leanprover-community/mathlib4/issues/26018\n-- TODO: this remains an unsolved problem, ideally the lexicographic\n-- order does not affect performance\nuniverse w₁ w₂ w₃ w₄ w₅ u₁ u₂ u₃\n\nvariable {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] [Algebra R S]\nvariable {T : Type u₃} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]\nvariable {ι : Type w₁} {ι' : Type w₃} {σ : Type w₂} {σ' : Type w₄} {τ : Type w₅}\nvariable (Q : Generators S T ι) (P : Generators R S σ)\nvariable (Q' : Generators S T ι') (P' : Generators R S σ') (W : Generators R T τ)\n\nattribute [local instance] SMulCommClass.of_commMonoid\n\nnamespace Generators\n\nset_option backward.isDefEq.respectTransparency false in\nlemma Cotangent.surjective_map_ofComp :\n Function.Surjective (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by\n intro x\n obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n have : x ∈ Q.ker := hx\n rw [← map_ofComp_ker Q P, Ideal.mem_map_iff_of_surjective\n _ (toAlgHom_ofComp_surjective Q P)] at this\n obtain ⟨x, hx', rfl⟩ := this\n exact ⟨.mk ⟨x, hx'⟩, Extension.Cotangent.map_mk _ _⟩\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nopen Extension.Cotangent in\n/--\nGiven representations `0 → I → R[X] → S → 0` and `0 → K → S[Y] → T → 0`,\nwe may consider the induced representation `0 → J → R[X, Y] → T → 0`, and the sequence\n`T ⊗[S] (I/I²) → J/J² → K/K²` is exact.\n-/\nlemma Cotangent.exact :\n Function.Exact\n ((Extension.Cotangent.map (Q.toComp P).toExtensionHom).liftBaseChange T)\n (Extension.Cotangent.map (Q.ofComp P).toExtensionHom) := by\n apply LinearMap.exact_of_comp_of_mem_range\n · rw [LinearMap.liftBaseChange_comp, ← Extension.Cotangent.map_comp,\n EmbeddingLike.map_eq_zero_iff]\n ext x\n obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n simp only [map_mk, val_mk, LinearMap.zero_apply, val_zero]\n convert! Q.ker.toCotangent.map_zero\n trans ((IsScalarTower.toAlgHom R _ _).comp (IsScalarTower.toAlgHom R P.Ring S)) x\n · congr\n refine MvPolynomial.algHom_ext fun i ↦ ?_\n change (Q.ofComp P).toAlgHom ((Q.toComp P).toAlgHom (X i)) = _\n simp\n · simp [aeval_val_eq_zero hx]\n · intro x hx\n obtain ⟨⟨x : (Q.comp P).Ring, hx'⟩, rfl⟩ := Extension.Cotangent.mk_surjective x\n replace hx : (Q.ofComp P).toAlgHom x ∈ Q.ker ^ 2 := by\n simpa only [map_mk, val_mk, val_zero, Ideal.toCotangent_eq_zero] using! congr(($hx).val)\n rw [pow_two, ← map_ofComp_ker (P := P), ← Ideal.map_mul, Ideal.mem_map_iff_of_surjective\n _ (toAlgHom_ofComp_surjective Q P)] at hx\n obtain ⟨y, hy, e⟩ := hx\n rw [eq_comm, ← sub_eq_zero, ← map_sub, ← RingHom.mem_ker, ← map_toComp_ker] at e\n rw [LinearMap.range_liftBaseChange]\n let z : (Q.comp P).ker := ⟨x - y, Ideal.sub_mem _ hx' (Ideal.mul_le_left hy)⟩\n have hz : z.1 ∈ P.ker.map (Q.toComp P).toAlgHom.toRingHom := e\n have : Extension.Cotangent.mk (P := (Q.comp P).toExtension) ⟨x, hx'⟩ =\n Extension.Cotangent.mk z := by\n ext; simpa only [val_mk, Ideal.toCotangent_eq, sub_sub_cancel, pow_two, z]\n rw [this, ← Submodule.restrictScalars_mem (Q.comp P).Ring, ← Submodule.mem_comap,\n ← Submodule.span_singleton_le_iff_mem, ← Submodule.map_le_map_iff_of_injective\n (f := Submodule.subtype _) Subtype.val_injective, Submodule.map_subtype_span_singleton,\n Submodule.span_singleton_le_iff_mem]\n refine (show Ideal.map (Q.toComp P).toAlgHom.toRingHom P.ker ≤ _ from ?_) hz\n rw [Ideal.map_le_iff_le_comap]\n rintro w hw\n simp only [AlgHom.toRingHom_eq_coe, Ideal.mem_comap, RingHom.coe_coe,\n Submodule.mem_map, Submodule.mem_comap, Submodule.restrictScalars_mem, Submodule.coe_subtype,\n Subtype.exists, exists_and_right, exists_eq_right,\n toExtension_Ring]\n refine ⟨?_, Submodule.subset_span ⟨Extension.Cotangent.mk ⟨w, hw⟩, ?_⟩⟩\n · simp only [ker_eq_ker_aeval_val, RingHom.mem_ker, Hom.algebraMap_toAlgHom]\n rw [aeval_val_eq_zero hw, map_zero]\n · rw [map_mk]\n rfl\n\n/-- Given `R[X] → S` and `S[Y] → T`, the cotangent space of `R[X][Y] → T` is isomorphic\nto the direct product of the cotangent space of `S[Y] → T` and `R[X] → S` (base changed to `T`). -/\nnoncomputable\ndef CotangentSpace.compEquiv :\n (Q.comp P).toExtension.CotangentSpace ≃ₗ[T]\n Q.toExtension.CotangentSpace × (T ⊗[S] P.toExtension.CotangentSpace) :=\n (Q.comp P).cotangentSpaceBasis.repr.trans\n (Q.cotangentSpaceBasis.prod (P.cotangentSpaceBasis.baseChange T)).repr.symm\n\nsection instanceProblem\n\n-- Note: these instances are needed to prevent instance search timeouts.\nattribute [local instance 999999] Zero.toOfNat0 SemilinearMapClass.distribMulActionSemiHomClass\n SemilinearEquivClass.instSemilinearMapClass instAddZeroClassTensorProduct AddZero.toZero\n\nlemma CotangentSpace.compEquiv_symm_inr :\n (compEquiv Q P).symm.toLinearMap ∘ₗ\n LinearMap.inr T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) =\n (Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T := by\n classical\n apply (P.cotangentSpaceBasis.baseChange T).ext\n intro i\n apply (Q.comp P).cotangentSpaceBasis.repr.injective\n ext j\n simp only [compEquiv, LinearEquiv.trans_symm, LinearEquiv.symm_symm,\n Basis.baseChange_apply, LinearMap.coe_comp, LinearEquiv.coe_coe, LinearMap.coe_inr,\n Function.comp_apply, LinearEquiv.trans_apply, Basis.repr_symm_apply, pderiv_X, toComp_val,\n Basis.repr_linearCombination, LinearMap.liftBaseChange_tmul, one_smul, repr_CotangentSpaceMap]\n obtain (j | j) := j <;>\n simp only [Basis.prod_repr_inr, Basis.baseChange_repr_tmul,\n Basis.repr_self, Basis.prod_repr_inl, map_zero, Finsupp.coe_zero,\n Pi.zero_apply, ne_eq, not_false_eq_true, Pi.single_eq_of_ne, Pi.single_apply,\n Finsupp.single_apply, ite_smul, one_smul, zero_smul, Sum.inr.injEq,\n MonoidWithZeroHom.map_ite_one_zero, reduceCtorEq]\n\nlemma CotangentSpace.compEquiv_symm_zero (x) :\n (compEquiv Q P).symm (0, x) =\n (Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T x :=\n DFunLike.congr_fun (compEquiv_symm_inr Q P) x\n\nlemma CotangentSpace.fst_compEquiv :\n LinearMap.fst T Q.toExtension.CotangentSpace (T ⊗[S] P.toExtension.CotangentSpace) ∘ₗ\n (compEquiv Q P).toLinearMap = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom := by\n classical\n apply (Q.comp P).cotangentSpaceBasis.ext\n intro i\n apply Q.cotangentSpaceBasis.repr.injective\n ext j\n simp only [compEquiv, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, ofComp_val,\n LinearEquiv.trans_apply, Basis.repr_self, LinearMap.fst_apply, repr_CotangentSpaceMap]\n obtain (i | i) := i <;>\n simp only [Basis.repr_symm_apply, Finsupp.linearCombination_single, Basis.prod_apply,\n LinearMap.coe_inl, LinearMap.coe_inr, Sum.elim_inl, Function.comp_apply, one_smul,\n Basis.repr_self, Finsupp.single_apply, pderiv_X, Pi.single_apply,\n Sum.elim_inr, Function.comp_apply, Basis.baseChange_apply, one_smul,\n MonoidWithZeroHom.map_ite_one_zero, map_zero, Finsupp.coe_zero, Pi.zero_apply, derivation_C]\n\nlemma CotangentSpace.fst_compEquiv_apply (x) :\n (compEquiv Q P x).1 = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom x :=\n DFunLike.congr_fun (fst_compEquiv Q P) x\n\nlemma CotangentSpace.map_toComp_injective :\n Function.Injective\n ((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T) := by\n rw [← compEquiv_symm_inr]\n apply (compEquiv Q P).symm.injective.comp\n exact Prod.mk_right_injective _\n\nlemma CotangentSpace.map_ofComp_surjective :\n Function.Surjective (Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) := by\n rw [← fst_compEquiv]\n exact (Prod.fst_surjective).comp (compEquiv Q P).surjective\n\n/-!\nGiven representations `R[X] → S` and `S[Y] → T`, the sequence\n`T ⊗[S] (⨁ₓ S dx) → (⨁ₓ T dx) ⊕ (⨁ᵧ T dy) → ⨁ᵧ T dy`\nis exact.\n-/\n\nTarget:\nlemma CotangentSpace.exact :\n Function.Exact ((Extension.CotangentSpace.map (Q.toComp P).toExtensionHom).liftBaseChange T)\n (Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"e0a038419df7ddbdba1ab2c763b49411bd0c3dccce15300ef77ab379e90a7adf","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Kaehler","family_id":"cotangentspace","file_id":"mathlib/Mathlib/RingTheory/Kaehler/JacobiZariski.lean","sample_id":"d37839532a84c2d07a0730fd769a564b1722feba2c9b6fd17a5620baffb9e3a3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f8a3be005e07f4608168ca5a3704fb12ee35073f36312b4b6deb828da5b5823","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a168c382b264dfbd01bed2e01c46444c5115a9486bcf7fae6ef576d5a49c0db","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"faf1008b28f1769ca1b08d394a375ac1236d7fad5271d304f8c4f07a9814d473","source_sha256":"59dce65aa1439ac03aa82f10431e6a4e6f8904739a4f8662c4d13bfb37f0673a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa [GaloisConnection, subset_def, mem_upperBounds, mem_lowerBounds]\n using fun S T ↦ forall₂_comm","hard_negative":true,"metrics":{"chosen_tokens":19,"rejected_tokens":5,"token_jaccard":0.047619,"token_length_ratio":0.263158},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"d83e01e21c4e5568d0e7aeaee4028218f1d48269b89fb771ba3e6069e611c6b4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice.Image\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Christopher Hoskin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christopher Hoskin\n-/\n/-!\n# Unions and intersections of bounds\n\nSome results about upper and lower bounds over collections of sets.\n\n## Implementation notes\n\nIn a separate file as we need to import `Mathlib/Data/Set/Lattice.lean`.\n\n-/\n\npublic section\n\nvariable {α : Type*} [Preorder α] {ι : Sort*} {s : ι → Set α}\n\nopen Set\n\n@[to_dual]\n\nTarget:\ntheorem gc_upperBounds_lowerBounds : GaloisConnection\n (OrderDual.toDual ∘ upperBounds : Set α → (Set α)ᵒᵈ)\n (lowerBounds ∘ OrderDual.ofDual : (Set α)ᵒᵈ → Set α) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_faf1008b28f1","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"4802dbb7ba22bbd112462a9235468496116ef787081af58c3e853c53ffc24bbf","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Bounds","family_id":"gc_upperbounds_lowerbounds","file_id":"mathlib/Mathlib/Order/Bounds/Lattice.lean","sample_id":"faf1008b28f1769ca1b08d394a375ac1236d7fad5271d304f8c4f07a9814d473"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f8acf0e73117bc5ca7d7bd9991122534f2ac979976c9881ebac1cb80ac751f3b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"756c833bb1403a31b9b4a213930da4b0d915305ddd84c92a8d7e783da3ae3d26","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.133333},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"d8527de0ce32a10ad70078dc8064159bb1ca4d35d9c3c1b524a422c4a08270c3","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\nTarget:\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"lift_lsmul_mul_eq_lsmul_lift_lsmul","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"756c833bb1403a31b9b4a213930da4b0d915305ddd84c92a8d7e783da3ae3d26"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"83055cffab58b1007df9d9544341b0300c397e7831803c736cc144d4f0ae252c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cafbeebc9304f43f9f9b249d49762f5fe35eca5f6f277411f68a09a6065367b8","source_sha256":"70b655774553f5ec4eaa3d2beda50eafff09706ffc0381725295ff20fc05eaae","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n intro M N f₁ f₂ h\n ext ⟨X⟩ m\n obtain ⟨g, rfl⟩ := freeYonedaEquiv.surjective m\n exact congr_arg freeYonedaEquiv (h _ ⟨X⟩ g)","hard_negative":false,"metrics":{"chosen_tokens":36,"rejected_tokens":2,"token_jaccard":0.037037,"token_length_ratio":0.055556},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"d9ab3f51f1bff34ab6841bf5663a4004adf4341a20b9b1ce3d3fb1a60616c058","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.Abelian\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.EpiMono\npublic import Mathlib.Algebra.Category.ModuleCat.Presheaf.Free\npublic import Mathlib.Algebra.Homology.ShortComplex.Exact\npublic import Mathlib.CategoryTheory.Elements\npublic import Mathlib.CategoryTheory.Generator.Basic\n\nNamespace:\nPresheafOfModules.freeYoneda\n\nLocal context:\n/-\nCopyright (c) 2024 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Generators for the category of presheaves of modules\n\nIn this file, given a presheaf of rings `R` on a category `C`,\nwe study the set `freeYoneda R` of presheaves of modules\nof form `(free R).obj (yoneda.obj X)` for `X : C`, i.e.\nfree presheaves of modules generated by the Yoneda\npresheaf represented by some `X : C` (the functor\nrepresented by such a presheaf of modules is the evaluation\nfunctor `M ↦ M.obj (op X)`, see `freeYonedaEquiv`).\n\nLemmas `PresheafOfModules.freeYoneda.isSeparating` and\n`PresheafOfModules.freeYoneda.isDetecting` assert that this\nset `freeYoneda R` is separating and detecting.\nWe deduce that if `C : Type u` is a small category,\nand `R : Cᵒᵖ ⥤ RingCat.{u}`, then `PresheafOfModules.{u} R`\nis a well-powered category.\n\nFinally, given `M : PresheafOfModules.{u} R`, we consider\nthe canonical epimorphism of presheaves of modules\n`M.fromFreeYonedaCoproduct : M.freeYonedaCoproduct ⟶ M`\nwhere `M.freeYonedaCoproduct` is a coproduct indexed\nby elements of `M`, i.e. pairs `⟨X : Cᵒᵖ, a : M.obj X⟩`,\nof the objects `(free R).obj (yoneda.obj X.unop)`.\nThis is used in the definition\n`PresheafOfModules.isColimitFreeYonedaCoproductsCokernelCofork`\nin order to obtain that any presheaf of modules is a cokernel\nof a morphism between coproducts of objects in `freeYoneda R`.\n\n-/\n\n@[expose] public section\n\nuniverse v v₁ u u₁\n\nopen CategoryTheory Limits\n\nnamespace PresheafOfModules\n\nvariable {C : Type u} [Category.{v} C] {R : Cᵒᵖ ⥤ RingCat.{v}}\n\n/-- When `R : Cᵒᵖ ⥤ RingCat`, `M : PresheafOfModules R`, and `X : C`, this is the\nbijection `((free R).obj (yoneda.obj X) ⟶ M) ≃ M.obj (Opposite.op X)`. -/\nnoncomputable def freeYonedaEquiv {M : PresheafOfModules.{v} R} {X : C} :\n ((free R).obj (yoneda.obj X) ⟶ M) ≃ M.obj (Opposite.op X) :=\n freeHomEquiv.trans yonedaEquiv\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\nlemma freeYonedaEquiv_symm_app (M : PresheafOfModules.{v} R) (X : C)\n (x : M.obj (Opposite.op X)) :\n (freeYonedaEquiv.symm x).app (Opposite.op X) (ModuleCat.freeMk (𝟙 _)) = x := by\n simp [freeYonedaEquiv, freeHomEquiv, yonedaEquiv]\n\nlemma freeYonedaEquiv_comp {M N : PresheafOfModules.{v} R} {X : C}\n (m : ((free R).obj (yoneda.obj X) ⟶ M)) (φ : M ⟶ N) :\n freeYonedaEquiv (m ≫ φ) = φ.app _ (freeYonedaEquiv m) := rfl\n\nvariable (R) in\n/-- The set of `PresheafOfModules.{v} R` consisting of objects of the\nform `(free R).obj (yoneda.obj X)` for some `X`. -/\ndef freeYoneda : ObjectProperty (PresheafOfModules.{v} R) := .ofObj (yoneda ⋙ free R).obj\n\nnamespace freeYoneda\n\ninstance : ObjectProperty.Small.{u} (freeYoneda R) := by\n dsimp [freeYoneda]\n infer_instance\n\nvariable (R)\n\nTarget:\nlemma isSeparating : ObjectProperty.IsSeparating (freeYoneda R) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Category","family_id":"isseparating","file_id":"mathlib/Mathlib/Algebra/Category/ModuleCat/Presheaf/Generator.lean","sample_id":"cafbeebc9304f43f9f9b249d49762f5fe35eca5f6f277411f68a09a6065367b8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7425bcdb7155248a01a05c66e195a60382e1936bea653d7c78fca4c9e3190e4b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"806d86021563d0848d2ee8be77a068205fd21b50c613a62d7bd7afefe1b4d10f","source_sha256":"6d09d445f3f033f859d77c9787c93d39447dddcb241c9f314d0f8ee75fb436ec","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [borel_eq_generateFrom_Ioi]\n refine le_antisymm ?_ ?_\n · refine MeasurableSpace.generateFrom_le fun t ht => ?_\n obtain ⟨u, rfl⟩ := ht\n rw [← compl_Iic]\n exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl\n · refine MeasurableSpace.generateFrom_le fun t ht => ?_\n obtain ⟨u, rfl⟩ := ht\n rw [← compl_Ioi]\n exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl","hard_negative":false,"metrics":{"chosen_tokens":95,"rejected_tokens":3,"token_jaccard":0.057143,"token_length_ratio":0.031579},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"dbd749a3790ca0663340757737984e521cdf1881564270153bb5713c1976dfad","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Semicontinuity.Basic\npublic import Mathlib.MeasureTheory.Function.AEMeasurableSequence\npublic import Mathlib.MeasureTheory.Order.Lattice\npublic import Mathlib.Topology.Order.Lattice\npublic import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov, Kexing Ying\n-/\n/-!\n# Borel sigma algebras on spaces with orders\n\n## Main statements\n\n* `borel_eq_generateFrom_Ixx` (where Ixx is one of `{Iio, Ioi, Iic, Ici, Ico, Ioc}`):\n The Borel sigma algebra of a linear order topology is generated by intervals of the given kind.\n* `Dense.borel_eq_generateFrom_Ico_mem`, `Dense.borel_eq_generateFrom_Ioc_mem`:\n The Borel sigma algebra of a dense linear order topology is generated by intervals of a given\n kind, with endpoints from dense subsets.\n* `ext_of_Ico`, `ext_of_Ioc`:\n A locally finite Borel measure on a second countable conditionally complete linear order is\n characterized by the measures of intervals of the given kind.\n* `ext_of_Iic`, `ext_of_Ici`:\n A finite Borel measure on a second countable linear order is characterized by the measures of\n intervals of the given kind.\n* `UpperSemicontinuous.measurable`, `LowerSemicontinuous.measurable`:\n Semicontinuous functions are measurable.\n* `Measurable.iSup`, `Measurable.iInf`, `Measurable.sSup`, `Measurable.sInf`:\n Countable supremums and infimums of measurable functions to conditionally complete linear orders\n are measurable.\n* `Measurable.liminf`, `Measurable.limsup`:\n Countable liminfs and limsups of measurable functions to conditionally complete linear orders\n are measurable.\n\n-/\n\npublic section\n\nopen Set Filter MeasureTheory MeasurableSpace TopologicalSpace\n\nopen scoped Topology NNReal ENNReal MeasureTheory\n\nuniverse u v w x y\n\nvariable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α}\n\nsection OrderTopology\n\nvariable (α)\nvariable [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α]\n\ntheorem borel_eq_generateFrom_Iio : borel α = .generateFrom (range Iio) := by\n refine le_antisymm ?_ (generateFrom_le ?_)\n · rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals α _ _ _)]\n letI : MeasurableSpace α := MeasurableSpace.generateFrom (range Iio)\n have H : ∀ a : α, MeasurableSet (Iio a) := fun a => GenerateMeasurable.basic _ ⟨_, rfl⟩\n refine generateFrom_le ?_\n rintro _ ⟨a, rfl | rfl⟩\n · rcases em (∃ b, a ⋖ b) with ⟨b, hb⟩ | hcovBy\n · rw [hb.Ioi_eq, ← compl_Iio]\n exact (H _).compl\n · rcases isOpen_biUnion_countable (Ioi a) Ioi fun _ _ ↦ isOpen_Ioi with ⟨t, hat, htc, htU⟩\n have : Ioi a = ⋃ b ∈ t, Ici b := by\n refine Subset.antisymm ?_ <| iUnion₂_subset fun b hb ↦ Ici_subset_Ioi.2 (hat hb)\n refine Subset.trans ?_ <| iUnion₂_mono fun _ _ ↦ Ioi_subset_Ici_self\n simpa [CovBy, htU, subset_def] using hcovBy\n simp only [this, ← compl_Iio]\n exact .biUnion htc <| fun _ _ ↦ (H _).compl\n · apply H\n · rw [forall_mem_range]\n intro a\n exact GenerateMeasurable.basic _ isOpen_Iio\n\ntheorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) :=\n @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _\n\nTarget:\ntheorem borel_eq_generateFrom_Iic :\n borel α = MeasurableSpace.generateFrom (range Iic) :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/Constructions","family_id":"borel_eq_generatefrom_iic","file_id":"mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean","sample_id":"806d86021563d0848d2ee8be77a068205fd21b50c613a62d7bd7afefe1b4d10f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"31b53b83857b2764a4c499ba44fa0769b2eba5152cf998d7a92f770e73297265","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9c8edab97c79bebf800cbc9186a0e374764dc4595456fd8777a1183512f91191","source_sha256":"1faf6bf14995586c5a25e6d1eed31a0c7a16ba7df5002c406b8252e96909714f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← PiLp.proj_apply (𝕜 := ℝ) q E i (∫ x, f x ∂μ), ← ContinuousLinearMap.integral_comp_comm]\n · simp\n exact Integrable.of_eval_piLp hf","hard_negative":false,"metrics":{"chosen_tokens":37,"rejected_tokens":5,"token_jaccard":0.060606,"token_length_ratio":0.135135},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"dcc659373e1e95273b134a6cc397653f054076c376036bda985c2cf5325bfb6e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Normed.Lp.PiLp\npublic import Mathlib.MeasureTheory.SpecificCodomains.Pi\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Etienne Marion. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Etienne Marion\n-/\n/-!\n# Integrability in `WithLp`\n\nWe prove that `f : X → PiLp q E` is in `Lᵖ` if and only if for all `i`, `f · i` is in `Lᵖ`.\nWe do the same for `f : X → WithLp q (E × F)`.\n-/\n\npublic section\n\nopen scoped ENNReal\n\nnamespace MeasureTheory\n\nvariable {X : Type*} {mX : MeasurableSpace X} {μ : Measure X} {p q : ℝ≥0∞} [Fact (1 ≤ q)]\n\nsection Pi\n\nvariable {ι : Type*} [Fintype ι] {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] {f : X → PiLp q E}\n\nlemma memLp_piLp_iff : MemLp f p μ ↔ ∀ i, MemLp (f · i) p μ := by\n simp_rw [← memLp_pi_iff, ← Function.comp_apply (f := WithLp.ofLp)]\n exact (PiLp.lipschitzWith_ofLp q E).memLp_comp_iff_of_antilipschitz\n (PiLp.antilipschitzWith_ofLp q E) (by simp) |>.symm\n\nalias ⟨MemLp.eval_piLp, MemLp.of_eval_piLp⟩ := memLp_piLp_iff\n\nlemma integrable_piLp_iff : Integrable f μ ↔ ∀ i, Integrable (f · i) μ := by\n simp_rw [← memLp_one_iff_integrable, memLp_piLp_iff]\n\nalias ⟨Integrable.eval_piLp, Integrable.of_eval_piLp⟩ := integrable_piLp_iff\n\nvariable [∀ i, NormedSpace ℝ (E i)] [∀ i, CompleteSpace (E i)]\n\nTarget:\nlemma eval_integral_piLp (hf : ∀ i, Integrable (f · i) μ) (i : ι) :\n (∫ x, f x ∂μ) i = ∫ x, f x i ∂μ :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/SpecificCodomains","family_id":"eval_integral_pilp","file_id":"mathlib/Mathlib/MeasureTheory/SpecificCodomains/WithLp.lean","sample_id":"9c8edab97c79bebf800cbc9186a0e374764dc4595456fd8777a1183512f91191"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"800309b9f05b3a4a83029438383e736bb796eae1a2ddf46badd79b778d22857d","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"7bfc4a188b9fa1ab0f462d7f9b246256c10c3b7d1514ca9e81d769fecc1cff3d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"25fac9092685576971918ff441d34f921ba8e1015a1d3112c67732d897416eb1","source_sha256":"c16459d64473a740c6a3fea2e787f6e904d2ce7749fd9d22ca52f5ddd5d2abaf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases finite_or_infinite α\n · obtain ⟨_⟩ := nonempty_fintype α; letI := Classical.decEq α\n simp_rw [Nat.card_eq_fintype_card]\n exact card_subtype_not_diag\n · simp","hard_negative":true,"metrics":{"chosen_tokens":29,"rejected_tokens":2,"token_jaccard":0.04,"token_length_ratio":0.068966},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"dd12c68970fb8cece5e7f9befdfd98ded63221695f490cb4e71ce51ab9bf2aba","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Card\npublic import Mathlib.Data.Sym.Basic\npublic import Mathlib.Data.Sym.Sym2\nimport Mathlib.Data.Sym.Card\n\nNamespace:\nSym2\n\nLocal context:\n/-\nCopyright (c) 2026 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n/-!\n# `Nat.card` versions of `Fintype.card` lemmas on `Sym`\n\nEach of the lemmas assuming `[Fintype α]` and `Fintype.card` can be restated using `Nat.card` alone.\n-/\n\npublic section\n\nopen Nat\n\nvariable (α : Type*)\n\nnamespace Sym\n\ninstance {k : ℕ} [Infinite α] [NeZero k] : Infinite (Sym α k) :=\n .of_injective (Sym.replicate k) <| Sym.replicate_right_injective (NeZero.ne _)\n\n/-- A version of `card_sym_eq_multichoose` that does not need finiteness. -/\ntheorem natCard_sym_eq_multichoose (k : ℕ) :\n Nat.card (Sym α k) = multichoose (Nat.card α) k := by\n cases finite_or_infinite α\n · obtain ⟨_⟩ := nonempty_fintype α; letI := Classical.decEq α\n simp_rw [Nat.card_eq_fintype_card]\n exact card_sym_eq_multichoose _ _\n cases k <;> simp\n\n/-- A version of `card_sym_eq_choose` that does not need finiteness. -/\ntheorem natCard_sym_eq_choose (k : ℕ) :\n Nat.card (Sym α k) = (Nat.card α + k - 1).choose k := by\n rw [natCard_sym_eq_multichoose, Nat.multichoose_eq]\n\nend Sym\n\nnamespace Sym2\n\ninstance [Infinite α] : Infinite (Sym2 α) :=\n .of_injective Sym2.diag <| Sym2.diag_injective\n\ninstance [Infinite α] : Infinite {a : Sym2 α // a.IsDiag} :=\n .of_injective (fun a : α => ⟨.diag a, rfl⟩) fun _ _ h => Sym2.diag_injective congr($h)\n\ninstance [Infinite α] : Infinite {a : Sym2 α // ¬a.IsDiag} :=\n let e := Infinite.natEmbedding α\n .of_injective (fun n => ⟨s(e 0, e (n + 1)), by simp⟩) fun _ _ => by simp\n\ntheorem natCard_subtype_diag : Nat.card { a : Sym2 α // a.IsDiag } = Nat.card α :=\n Nat.card_congr diagElemEquiv\n\nTarget:\ntheorem natCard_subtype_not_diag :\n Nat.card { a : Sym2 α // ¬a.IsDiag } = (Nat.card α).choose 2 :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_25fac9092685","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"45f274956b380236f171a9e0bad7646684b099d88027c3dd275839a9e8a6fa4f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Sym","family_id":"natcard_subtype_not_diag","file_id":"mathlib/Mathlib/Data/Sym/NatCard.lean","sample_id":"25fac9092685576971918ff441d34f921ba8e1015a1d3112c67732d897416eb1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"122d88b22b305010f599cae4b327be37510a882fffbdcbed2ed49af2bbb54d69","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"58f7493683f9cffcc25cb0ea61ed6eb5c8defdfe60af5cc9ddddf5ae13c97428","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"7cb33889170a70f2f9d7186b8adb11f6a2457abe4e2813fb79657e1dd80bb758","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff","hard_negative":false,"metrics":{"chosen_tokens":8,"rejected_tokens":15,"token_jaccard":0.777778,"token_length_ratio":1.875},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"dde39ca26d80cdf1c41757e45b84ac7fc37f6d324887529716740111918bb1b8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nTarget:\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a :=\n\nProof body:\n","rejected":"```lean\nby\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"7cb33889170a70f2f9d7186b8adb11f6a2457abe4e2813fb79657e1dd80bb758"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"832049157307cc225d58dab58d29e0bf5f150755460fd0809b4fe329a5c57cc4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d0bd3bf98f4e5399ba6da987fba318355cd836f14323d98bf4d064e8b3953690","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a4d87dbf774b4797d3a25e3d1c0c1ab09a9ddc2ae451217d30f7280723179ffc","source_sha256":"13c7a1629af24e2f099064a1f2c061026ffee34b15e2fe588217126c2c5d8aab","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n dsimp [singularChainComplexFunctorAdjunction, Adjunction.ofNatIsoRight,\n Adjunction.equivHomsetRightOfNatIso, Adjunction.homEquiv,\n Adjunction.comp, singularChainComplexFunctor,\n SSet.chainComplexFunctorAdjunction, SSet.chainComplexFunctor]\n simp [stdSimplexToTop]\n rfl","hard_negative":false,"metrics":{"chosen_tokens":36,"rejected_tokens":40,"token_jaccard":0.863636,"token_length_ratio":1.111111},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"de2556a4b351f8a294c03b84ad92d427cf1aa502338c9a525883cce5b2dedec6","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.AlternatingConst\npublic import Mathlib.AlgebraicTopology.SimplicialSet.Homology.Basic\npublic import Mathlib.AlgebraicTopology.SingularSet\npublic import Mathlib.CategoryTheory.Adjunction.Whiskering\npublic import Mathlib.CategoryTheory.Limits.MonoCoprod\n\nNamespace:\nAlgebraicTopology\n\nLocal context:\n/-\nCopyright (c) 2025 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# Singular homology\n\nIn this file, we define the singular chain complex and singular homology of a topological space.\nWe also calculate the homology of a totally disconnected space as an example.\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nnamespace AlgebraicTopology\n\nopen CategoryTheory Limits\n\nuniverse w v u\n\nvariable (C : Type u) [Category.{v} C] [HasCoproducts.{w} C]\nvariable [Preadditive C] (n : ℕ)\n\n/-- The singular chain complex functor with coefficients in `C`. -/\ndef singularChainComplexFunctor :\n C ⥤ TopCat.{w} ⥤ ChainComplex C ℕ :=\n SSet.chainComplexFunctor.{w} C ⋙ (Functor.whiskeringLeft _ _ _).obj TopCat.toSSet.{w}\n\ninstance : (singularChainComplexFunctor C).Additive := by\n delta singularChainComplexFunctor\n infer_instance\n\nset_option backward.defeqAttrib.useBackward true in\ninstance [Limits.HasPullbacks C] {X : C} :\n ((singularChainComplexFunctor C).obj X).PreservesMonomorphisms where\n preserves f _ := by\n dsimp [singularChainComplexFunctor, SSet.chainComplexFunctor]\n apply +allowSynthFailures Functor.map_mono\n apply +allowSynthFailures Functor.map_mono\n dsimp [SSet, SimplicialObject.whiskering, SimplicialObject]\n infer_instance\n\n/-- The `n`-th singular homology functor with coefficients in `C`. -/\ndef singularHomologyFunctor [CategoryWithHomology C] : C ⥤ TopCat.{w} ⥤ C :=\n singularChainComplexFunctor C ⋙\n (Functor.whiskeringRight _ _ _).obj (HomologicalComplex.homologyFunctor _ _ n)\n\nsection Adjunction\n\nopen Limits _root_.SSet\nopen scoped Simplicial\nopen HomologicalComplex (eval)\n\n/-- The adjunction `Hom(Cⁿ(-, X), F) ≃ Hom(X, F(Δ[n]))` for `X : C` and `F : Top ⥤ C`. -/\ndef singularChainComplexFunctorAdjunction : (Functor.postcompose₂.obj (eval _ _ n)).obj\n (singularChainComplexFunctor C) ⊣ (evaluation _ _).obj (SimplexCategory.toTop.obj ⦋n⦌) :=\n ((SSet.chainComplexFunctorAdjunction C n).comp (sSetTopAdj.whiskerLeft _)).ofNatIsoRight\n ((evaluation TopCat C).mapIso (SSet.toTopSimplex.app _))\n\nset_option backward.defeqAttrib.useBackward true in\n\nTarget:\nlemma singularChainComplexFunctorAdjunction_unit_app (R : C) :\n (singularChainComplexFunctorAdjunction C n).unit.app R =\n Sigma.ι (fun _ ↦ R) ((stdSimplexToTop.app ⦋n⦌).app (.op ⦋n⦌)\n (SSet.stdSimplex.objEquiv.symm (𝟙 ⦋n⦌))) :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n dsimp [singularChainComplexFunctorAdjunction, Adjunction.ofNatIsoRight,\n Adjunction.equivHomsetRightOfNatIso, Adjunction.homEquiv,\n Adjunction.comp, singularChainComplexFunctor,\n SSet.chainComplexFunctorAdjunction, SSet.chainComplexFunctor]\n simp [stdSimplexToTop]\n rfl","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/SingularHomology","family_id":"singularchaincomplexfunctoradjunction_unit_app","file_id":"mathlib/Mathlib/AlgebraicTopology/SingularHomology/Basic.lean","sample_id":"a4d87dbf774b4797d3a25e3d1c0c1ab09a9ddc2ae451217d30f7280723179ffc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bc6bccb9b53f0aea87e3ff70b0fee0d7ff91211b7d513c0514c4f25d69141d7e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"67d025efb0d750c332cefc9e5983dc9279ca46503281a5e66daedb3e37963911","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"30e2a93d6c5c253b618378c8ebd7416505c8a671a9a2c650a99f668268e190a6","source_sha256":"0cf09afc554d4b34ede5bb7d07487b45c06cc9c6ecd78129ff0a0d2baecc7f10","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨r, m⟩ := x\n simp only [kerIdeal, RingHom.mem_ker, fstHom_apply, fst_mk]\n exact ⟨fun hr => by rw [hr]; rfl, fun hrm => by rw [← fst_mk r m, hrm, fst_inr]⟩","hard_negative":true,"metrics":{"chosen_tokens":51,"rejected_tokens":3,"token_jaccard":0.066667,"token_length_ratio":0.058824},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"de4e3462f43937266da4b207c9044d2d44252561831ab133f981cddf9ba5af84","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.TrivSqZeroExt.Basic\npublic import Mathlib.RingTheory.Ideal.Maps\n\nNamespace:\nTrivSqZeroExt\n\nLocal context:\n/-\nCopyright (c) 2026 Antoine Chambert-Loir, María-Inés de Frutos-Fernández. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Chambert-Loir, María-Inés de Frutos-Fernández\n-/\n/-!\n# The square zero ideal of the trivial square-zero extension\n\n- `TrivSqZeroExt.kerIdeal`: the ideal in the trivial square-zero extension\n\n- `TrivSqZeroExt.kerIdeal_sq `: this ideal has square zero.\n\n-/\n\n@[expose] public section\n\nnamespace TrivSqZeroExt\n\nopen Ideal\n\nvariable (R M : Type*)\n [CommSemiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] [IsCentralScalar R M]\n\n/-- The kernel of the `AlgHom` `fstHom R R M` -/\ndef kerIdeal : Ideal (TrivSqZeroExt R M) := RingHom.ker (fstHom R R M)\n\nTarget:\ntheorem mem_kerIdeal_iff_inr (x : TrivSqZeroExt R M) : x ∈ kerIdeal R M ↔ x = inr x.snd :=\n\nProof body:\n","rejected":"by\n exact mem_kerIdeal_iff_inr","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"b177c62429391bb140545b1c52fdba15044651ce495863624b7bcb7665327185","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/TrivSqZeroExt","family_id":"mem_kerideal_iff_inr","file_id":"mathlib/Mathlib/Algebra/TrivSqZeroExt/Ideal.lean","sample_id":"30e2a93d6c5c253b618378c8ebd7416505c8a671a9a2c650a99f668268e190a6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a663b4e75d9f1596287537a4a62875a72ffff913179559355bffea345ae7886c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6d4d141896782c7cd011ab2059449731caede18a0ed7a5ad8a483dc61d15692c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fa8af9b43eb1670040004fd1c0fa9b87db2f7ae969e8fb8ad8b2681f76bf7062","source_sha256":"1b04fd9daf3044c08d9f2cf2b300a5656d02c1209b70e4ca6f56f26097a25af2","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let f := Spec.map (CommRingCat.ofHom <| algebraMap K (AlgebraicClosure K))\n let G' := (Over.pullback f).obj G\n have : IsProper G'.hom := by dsimp [G']; infer_instance\n have : IsIntegral (G' ⊗ G').left := by dsimp [G']; infer_instance\n let : GrpObj G' := Functor.grpObjObj\n have := isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed G'\n rw [isCommMonObj_iff_commutator_eq_toUnit_η] at this ⊢\n apply (Over.pullback f).map_injective\n rw [← cancel_epi (Functor.Monoidal.μIso (Over.pullback f) G G).hom]\n dsimp [GrpObj.commutator] at this ⊢\n simpa only [Functor.map_mul, one_eq_one, comp_one, Functor.map_one, Functor.map_inv',\n comp_mul, GrpObj.comp_inv, Functor.Monoidal.μ_fst, Functor.Monoidal.μ_snd]","hard_negative":false,"metrics":{"chosen_tokens":164,"rejected_tokens":169,"token_jaccard":0.940299,"token_length_ratio":1.030488},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"df93b56af14e9b0856bcef8201e1f2bb2bfc7c7d55d3b09dd36876567febab3c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.AlgebraicGeometry.AlgClosed.Basic\npublic import Mathlib.AlgebraicGeometry.Geometrically.Integral\npublic import Mathlib.AlgebraicGeometry.ZariskisMainTheorem\npublic import Mathlib.CategoryTheory.Monoidal.Cartesian.Grp\n\nNamespace:\nAlgebraicGeometry\n\nLocal context:\n/-\nCopyright (c) 2026 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang, Christian Merten\n-/\n/-!\n# Abelian varieties\n\n## Main results\n- `AlgebraicGeometry.isCommMonObj_of_isProper_of_geometricallyIntegral`:\n A proper geometrically integral group scheme over a field is commutative.\n\n-/\n\npublic section\n\nopen CategoryTheory Limits\n\nnamespace AlgebraicGeometry\n\nuniverse u\n\nvariable {K : Type u} [Field K] {X : Scheme.{u}}\n\nopen MonoidalCategory CartesianMonoidalCategory MonObj\n\nset_option backward.isDefEq.respectTransparency false in\ninstance (G : Over (Spec (.of K))) [GrpObj G] : IsClosedImmersion η[G].left :=\n isClosedImmersion_of_comp_eq_id (Y := Spec (.of K)) G.hom η[G].left (by simp)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\ntheorem isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed [IsAlgClosed K]\n (G : Over (Spec (.of K))) [IsProper G.hom] [IsIntegral (G ⊗ G).left] [GrpObj G] :\n IsCommMonObj G := by\n let S := Spec (.of K)\n let point : S := IsLocalRing.closedPoint K\n have hpoint : IsClosed {point} := isClosed_discrete _\n have : Nonempty G.left := ⟨η[G].left point⟩\n have : IsProper (G ⊗ G).hom := by dsimp; infer_instance\n have : JacobsonSpace (G ⊗ G).left := LocallyOfFiniteType.jacobsonSpace (Y := Spec _) (G ⊗ G).hom\n have : Surjective G.hom := ⟨Function.surjective_to_subsingleton (α := G.left) (β := Spec _) _⟩\n have : IsProper (fst G G).left := by dsimp; infer_instance\n have : Surjective (fst G G).left := by dsimp; infer_instance\n have : IsProper ((GrpObj.commutator G).left ≫ G.hom) := by rw [Over.w]; infer_instance\n have : IsClosedImmersion ((lift η[G] η[G]).left ≫ (fst G G).left) := by\n simpa using inferInstanceAs (IsClosedImmersion η[G].left)\n have : IsClosedImmersion (lift η[G] η[G]).left := .of_comp _ (g := (fst G G).left)\n let γ : G ⊗ G ⟶ G ⊗ G := lift (fst _ _) (GrpObj.commutator _)\n have : IsProper (γ.left ≫ (fst G G).left) := by simpa [γ]\n have : IsProper γ.left := .of_comp _ (fst G G).left\n -- It suffices to check that `γ : (x, y) ↦ x * y * x⁻¹ * y⁻¹` is constantly `1`.\n rw [isCommMonObj_iff_commutator_eq_toUnit_η]\n ext1\n have H : γ.left '' ((fst G G).left ⁻¹' {η[G].left point}) ⊆ {(lift η[G] η[G]).left point} := by\n rw [Set.image_subset_iff, ← Set.sdiff_eq_empty, ← Set.not_nonempty_iff_eq_empty]\n intro H\n obtain ⟨c₀, ⟨hc₁, hc₂⟩, hc₃⟩ := nonempty_inter_closedPoints H <| by\n rw [Set.sdiff_eq_compl_inter, ← Set.image_singleton, ← Set.image_singleton];\n refine (IsOpen.isLocallyClosed ?_).inter (IsClosed.isLocallyClosed ?_)\n · exact (((lift η[G] η[G]).left.isClosedMap _ hpoint).preimage γ.left.continuous).isOpen_compl\n · exact (η[G].left.isClosedMap _ hpoint).preimage (fst G G).left.continuous\n obtain ⟨⟨c, hc⟩, e⟩ := (pointEquivClosedPoint (G ⊗ G).hom).surjective ⟨c₀, hc₃⟩\n obtain rfl : c point = c₀ := congr(($e).1)\n let fc : 𝟙_ (Over S) ⟶ 𝟙_ (Over S) ⊗ G := lift (𝟙 _) (Over.homMk c hc ≫ snd G G)\n have : c ≫ pullback.fst G.hom G.hom = η[G].left :=\n ext_of_apply_closedPoint_eq G.hom (by simpa) (by simp) (by simpa)\n have H₁ : c = fc.left ≫ (η[G] ▷ G).left := by dsimp; ext <;> simp [fc, S, this]\n have H₂ : fc ≫ η ▷ G ≫ γ = lift η η := by ext1 <;> simp [fc, γ, S]\n exact hc₂ <| by simp [H₁, H₂, ← Scheme.Hom.comp_apply, Category.assoc, ← Over.comp_left]\n -- Since the image of `y ↦ γ(e, y)` is finite, by Zariski Main, there exists an open\n -- `1 ∈ U ⊆ G` such that `γ ∣_ U` factors through a finite scheme over `U`.\n obtain ⟨U, hηU, H⟩ := exists_finite_imageι_comp_morphismRestrict_of_finite_image_preimage\n γ.left (fst G G).left (η[G].left point) (by\n dsimp [-Scheme.Hom.comp_base, γ]\n simp only [pullback.lift_fst]\n exact (Set.finite_singleton _).subset H)\n have H (x : U) : ((pullback.fst G.hom G.hom) ⁻¹' {x.1} ∩ Set.range ⇑γ.left).Finite := by\n refine ((((γ.left.imageι ≫ (fst G G).left) ∣_ U).finite_preimage_singleton x).image\n (Scheme.Opens.ι _ ≫ γ.left.imageι)).subset ?_\n have : U.ι ⁻¹' {x.1} = {x} := by ext; simp\n rw [← this, ← Set.preimage_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base,\n morphismRestrict_ι, ← Category.assoc, Scheme.Hom.comp_base (_ ≫ _) (fst G G).left,\n TopCat.coe_comp, Set.preimage_comp, Set.image_preimage_eq_inter_range]\n simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp, Scheme.Opens.range_ι]\n dsimp\n rw [Set.image_preimage_eq_inter_range, Scheme.IdealSheafData.range_subschemeι,\n Scheme.Hom.support_ker, ← Set.inter_assoc, ← Set.preimage_inter,\n Set.singleton_inter_of_mem x.2, IsClosed.closure_eq\n (by exact γ.left.isClosedMap.isClosed_range)]\n -- It suffices to check set-theoretic equality on closed points of `U ×[k] G`.\n refine ext_of_apply_eq G.hom _\n ((fst G G).left ⁻¹ᵁ U).isOpen.isLocallyClosed\n (((fst G G).left ⁻¹ᵁ U).isOpen.dense ?_) ?_ ?_\n · exact .preimage ⟨_, hηU⟩ (fst G G).left.surjective\n · intro y hyU hy\n have hx : IsClosed {(fst G G).left y} := by simpa using (fst G G).left.isClosedMap _ hy\n let x : 𝟙_ _ ⟶ G := Over.homMk (pointOfClosedPoint G.hom _ hx) (by simp)\n let xe : (G ⊗ G).left := (fst G G ≫ (ρ_ _).inv ≫ G ◁ η[G]).left y\n have : γ.left y = xe := by\n -- By the choice of `U`, the set `γ({y} ×[k] G)` is finite and hence, by irreducibility,\n -- a singleton.\n refine subsingleton_image_closure_of_finite_of_isPreirreducible\n (hx.preimage (fst G G).left.continuous).isLocallyClosed ?_ γ.left.continuous\n γ.left.isClosedMap ((H ⟨_, hyU⟩).subset (Set.image_subset_iff.mpr fun _ ↦ by\n simp [← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base, γ])) ?_ ?_\n · let α : G ⊗ G ⟶ G ⊗ G := toUnit _ ≫ x ⊗ₘ 𝟙 _\n convert!\n ((IrreducibleSpace.isIrreducible_univ _).image α.left\n α.left.continuous.continuousOn).isPreirreducible\n rw [Over.tensorHom_left]\n simp [Set.range_comp, Scheme.Pullback.range_map, x]\n · exact ⟨y, subset_closure (by simp), rfl⟩\n · refine ⟨xe, subset_closure ?_, ?_⟩\n · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base]\n · simp only [xe, γ, ← Scheme.Hom.comp_apply, ← Over.comp_left]\n congr 6; ext <;> simp\n convert! congr((snd G G).left $this) using 1\n · simp [γ, ← Scheme.Hom.comp_apply]\n · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base]\n · simp\n\nset_option backward.defeqAttrib.useBackward true in\n/-- A proper geometrically integral group scheme over a field is commutative. -/\n@[stacks 0BFD]\n\nTarget:\ntheorem isCommMonObj_of_isProper_of_geometricallyIntegral\n (G : Over (Spec (.of K))) [IsProper G.hom] [GeometricallyIntegral G.hom] [GrpObj G] :\n IsCommMonObj G :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n let f := Spec.map (CommRingCat.ofHom <| algebraMap K (AlgebraicClosure K))\n let G' := (Over.pullback f).obj G\n have : IsProper G'.hom := by dsimp [G']; infer_instance\n have : IsIntegral (G' ⊗ G').left := by dsimp [G']; infer_instance\n let : GrpObj G' := Functor.grpObjObj\n have := isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed G'\n rw [isCommMonObj_iff_commutator_eq_toUnit_η] at this ⊢\n apply (Over.pullback f).map_injective\n rw [← cancel_epi (Functor.Monoidal.μIso (Over.pullback f) G G).hom]\n dsimp [GrpObj.commutator] at this ⊢\n simpa only [Functor.map_mul, one_eq_one, comp_one, Functor.map_one, Functor.map_inv',\n comp_mul, GrpObj.comp_inv, Functor.Monoidal.μ_fst, Functor.Monoidal.μ_snd]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicGeometry/Group","family_id":"iscommmonobj_of_isproper_of_geometricallyintegral","file_id":"mathlib/Mathlib/AlgebraicGeometry/Group/Abelian.lean","sample_id":"fa8af9b43eb1670040004fd1c0fa9b87db2f7ae969e8fb8ad8b2681f76bf7062"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a4afcfeafb65c35a791387820a78793ccb06aa6e4c9194772166334f528b1da6","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0ac1a3dd33839e1cdf5946d42abc39431d5fd65e074198696a3a18cf5b3bf239","source_sha256":"8c1834cbc470868957d2c382f59c5cbb2b41442470cd514155de91f952bc7a9f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rintro ⟨_, rfl⟩\n have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n))\n exact ⟨this, by simp⟩","hard_negative":false,"metrics":{"chosen_tokens":35,"rejected_tokens":3,"token_jaccard":0.086957,"token_length_ratio":0.085714},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"e0a43a12dfd225b68e2bb1ec979764bc1802f420144aa2e0a68d5f8f852c6a6e","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Rat.Cast.CharZero\npublic import Mathlib.Tactic.NormNum.Basic\n\nNamespace:\nMathlib.Meta.NormNum\n\nLocal context:\n/-\nCopyright (c) 2022 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\n/-!\n# `norm_num` plugins for `Rat.cast` and `⁻¹`.\n-/\n\npublic meta section\n\nvariable {u : Lean.Level}\n\nnamespace Mathlib.Meta.NormNum\n\nopen Lean.Meta Qq\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`. -/\ndef inferCharZeroOfRing {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :\n MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero ring\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Ring α`, if it exists. -/\ndef inferCharZeroOfRing? {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :\n MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`. -/\ndef inferCharZeroOfAddMonoidWithOne {α : Q(Type u)}\n (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero AddMonoidWithOne\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`, if it\nexists. -/\ndef inferCharZeroOfAddMonoidWithOne? {α : Q(Type u)}\n (_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) :\n MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`. -/\ndef inferCharZeroOfDivisionRing {α : Q(Type u)}\n (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=\n return ← synthInstanceQ q(CharZero $α) <|>\n throwError \"not a characteristic zero division ring\"\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `Divisionsemiring α`, if it\nexists. -/\ndef inferCharZeroOfDivisionSemiring? {α : Q(Type u)}\n (_i : Q(DivisionSemiring $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption\n\n/-- Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`, if it\nexists. -/\ndef inferCharZeroOfDivisionRing? {α : Q(Type u)}\n (_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=\n return (← trySynthInstanceQ q(CharZero $α)).toOption\n\ntheorem isRat_mkRat : {a na n : ℤ} → {b nb d : ℕ} → IsInt a na → IsNat b nb →\n IsRat (na / nb : ℚ) n d → IsRat (mkRat a b) n d\n | _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [Rat.mkRat_eq_div]; exact ⟨_, h⟩\n\ntheorem isNNRat_divNat : {a na n : ℕ} → {b nb d : ℕ} → IsNat a na → IsNat b nb →\n IsNNRat (na / nb : ℚ≥0) n d → IsNNRat (NNRat.divNat a b) n d\n | _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [NNRat.divNat_eq_div]; exact ⟨_, h⟩\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- The `norm_num` extension which identifies expressions of the form `mkRat a b`,\nsuch that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. -/\n@[norm_num mkRat _ _]\ndef evalMkRat : NormNumExt where eval {u α} (e : Q(ℚ)) : MetaM (Result e) := do\n let .app (.app (.const ``mkRat _) (a : Q(ℤ))) (b : Q(ℕ)) ← whnfR e | failure\n haveI' : $e =Q mkRat $a $b := ⟨⟩\n let ra ← derive a\n let some ⟨_, na, pa⟩ := ra.toInt (q(Int.instRing) : Q(Ring Int)) | failure\n let ⟨nb, pb⟩ ← deriveNat q($b) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let rab ← derive q($na / $nb : Rat)\n let ⟨q, n, d, p⟩ ← rab.toRat' q(Rat.instDivisionRing)\n return .isRat _ q n d q(isRat_mkRat $pa $pb $p)\n\n/-- The `norm_num` extension which identifies expressions of the form `NNRat.divNat a b`,\nsuch that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. -/\n@[norm_num NNRat.divNat _ _]\ndef evalNNRatDivNat : NormNumExt where eval {u α} (e : Q(ℚ≥0)) : MetaM (Result e) := do\n let .app (.app (.const ``NNRat.divNat _) (a : Q(ℕ))) (b : Q(ℕ)) ← whnfR e | failure\n haveI' : $e =Q NNRat.divNat $a $b := ⟨⟩\n let ra ← derive q($a)\n let ⟨na, pa⟩ ← deriveNat q($a) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let ⟨nb, pb⟩ ← deriveNat q($b) q(AddCommMonoidWithOne.toAddMonoidWithOne)\n let rab ← derive q($na / $nb : NNRat)\n let some ⟨q, n, d, p⟩ := rab.toNNRat' q(NNRat.instSemifield.toDivisionSemiring) | failure\n return .isNNRat _ q n d q(isNNRat_divNat $pa $pb $p)\n\ntheorem isNat_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℕ} →\n IsNat q n → IsNat (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isNat_nnratCast {R : Type*} [DivisionSemiring R] : {q : ℚ≥0} → {n : ℕ} →\n IsNat q n → IsNat (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isInt_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℤ} →\n IsInt q n → IsInt (q : R) n\n | _, _, ⟨rfl⟩ => ⟨by simp⟩\n\ntheorem isNNRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℕ} → {d : ℕ} →\n IsNNRat q n d → IsNNRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\ntheorem isNNRat_nnratCast {R : Type*} [DivisionSemiring R] [CharZero R] : {q : ℚ≥0} → {n : ℕ} →\n {d : ℕ} → IsNNRat q n d → IsNNRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\ntheorem isRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℤ} → {d : ℕ} →\n IsRat q n d → IsRat (q : R) n d\n | _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩\n\n/-- The `norm_num` extension which identifies an expression `RatCast.ratCast q` where `norm_num`\nrecognizes `q`, returning the cast of `q`. -/\n@[norm_num Rat.cast _, RatCast.ratCast _] def evalRatCast : NormNumExt where eval {u α} e := do\n let dα ← inferDivisionRing α\n let .app r (a : Q(ℚ)) ← whnfR e | failure\n guard <|← withNewMCtxDepth <| isDefEq r q(Rat.cast (K := $α))\n let r ← derive q($a)\n haveI' : $e =Q Rat.cast $a := ⟨⟩\n match r with\n | .isNat _ na pa =>\n assumeInstancesCommute\n return .isNat _ na q(isNat_ratCast $pa)\n | .isNegNat _ na pa =>\n assumeInstancesCommute\n return .isNegNat _ na q(isInt_ratCast $pa)\n | .isNNRat _ qa na da pa =>\n assumeInstancesCommute\n let i ← inferCharZeroOfDivisionRing dα\n return .isNNRat q(inferInstance) qa na da q(isNNRat_ratCast $pa)\n | .isNegNNRat _ qa na da pa =>\n assumeInstancesCommute\n let i ← inferCharZeroOfDivisionRing dα\n return .isNegNNRat dα qa na da q(isRat_ratCast $pa)\n | _ => failure\n\n/-- The `norm_num` extension which identifies an expression `NNRat.cast q` where `norm_num`\nrecognizes `q`, returning the cast of `q`. -/\n@[norm_num NNRat.cast _, NNRatCast.nnratCast _]\ndef evalNNRatCast : NormNumExt where eval {u α} e := do\n let dα ← inferDivisionSemiring α\n let ~q(@NNRat.cast _ $dα' $a) := e | failure\n guard <| ← matchesInstance dα' q(@DivisionSemiring.toNNRatCast _ $dα)\n match ← derive q($a) with\n | .isNat _ na pa =>\n assumeInstancesCommute\n return .isNat _ na q(isNat_nnratCast $pa)\n | .isNNRat _ qa na da pa =>\n assumeInstancesCommute\n let some _ ← inferCharZeroOfDivisionSemiring? dα | failure\n return .isNNRat q(inferInstance) qa na da q(isNNRat_nnratCast $pa)\n | _ => failure\n\nTarget:\ntheorem isNNRat_inv_pos {α} [DivisionSemiring α] [CharZero α] {a : α} {n d : ℕ} :\n IsNNRat a (Nat.succ n) d → IsNNRat a⁻¹ d (Nat.succ n) :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/NormNum","family_id":"isnnrat_inv_pos","file_id":"mathlib/Mathlib/Tactic/NormNum/Inv.lean","sample_id":"0ac1a3dd33839e1cdf5946d42abc39431d5fd65e074198696a3a18cf5b3bf239"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"0e121e69e933498eda1d470b6a56289810b90b4630837893f096bf538b327d3c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2c3ffd691783d055e5f97934bda872cfad2079905461ee1702141a27728d78ab","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5ead7c6d304f6128d5ce7a1f1318a0e4120c41e938959f50a1ef8d65051dd5d7","source_sha256":"bf16fcfb1dfc63e4dd62a210f9db2b7f6873dc4a7240ee55394377c58fa8cf79","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [GroupFilterBasis.nhds_one_eq]\n constructor\n · rintro ⟨-, ⟨-, ⟨E, fin, rfl⟩, rfl⟩, hE⟩\n exact ⟨E, fin, hE⟩\n · rintro ⟨E, fin, hE⟩\n exact ⟨E.fixingSubgroup, ⟨E.fixingSubgroup, ⟨E, fin, rfl⟩, rfl⟩, hE⟩","hard_negative":true,"metrics":{"chosen_tokens":70,"rejected_tokens":2,"token_jaccard":0.047619,"token_length_ratio":0.028571},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"e0ee08aa97c39eb26a00c71828bfab9a4593e931fe20422718804c00fe3fad2b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Galois.Basic\npublic import Mathlib.Topology.Algebra.FilterBasis\npublic import Mathlib.Topology.Algebra.OpenSubgroup\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2022 Sebastian Monnet. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sebastian Monnet\n-/\n/-!\n# Krull topology\n\nWe define the Krull topology on `Gal(L/K)` for an arbitrary field extension `L/K`. In order to do\nthis, we first define a `GroupFilterBasis` on `Gal(L/K)`, whose sets are `E.fixingSubgroup` for\nall intermediate fields `E` with `E/K` finite dimensional.\n\n## Main Definitions\n\n- `finiteExts K L`. Given a field extension `L/K`, this is the set of intermediate fields that are\n finite-dimensional over `K`.\n\n- `fixedByFinite K L`. Given a field extension `L/K`, `fixedByFinite K L` is the set of\n subsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite\n\n- `galBasis K L`. Given a field extension `L/K`, this is the filter basis on `Gal(L/K)` whose\n sets are `Gal(L/E)` for intermediate fields `E` with `E/K` finite.\n\n- `galGroupBasis K L`. This is the same as `galBasis K L`, but with the added structure\n that it is a group filter basis on `Gal(L/K)`, rather than just a filter basis.\n\n- `krullTopology K L`. Given a field extension `L/K`, this is the topology on `Gal(L/K)`, induced\n by the group filter basis `galGroupBasis K L`.\n\n## Main Results\n\n- `krullTopology_t2 K L`. For an integral field extension `L/K`, the topology `krullTopology K L`\n is Hausdorff.\n\n- `krullTopology_isTotallySeparated K L`. For an integral field extension `L/K`, the topology\n `krullTopology K L` is totally separated.\n\n- `stabilizer_isOpen_of_isIntegral`: For an integral field extension `L/K`, the stabilizer\n in `Gal(L/K)` of any element in `L` is open for the Krull topology.\n\n- `IntermediateField.finrank_eq_fixingSubgroup_index`: given a Galois extension `K/k` and an\n intermediate field `L`, the `[L : k]` as a natural number is equal to the index of the\n fixing subgroup of `L`.\n\n## Notation\n\n- In docstrings, we will write `Gal(L/E)` to denote the fixing subgroup of an intermediate field\n `E`. That is, `Gal(L/E)` is the subgroup of `Gal(L/K)` consisting of automorphisms that fix\n every element of `E`. In particular, we distinguish between `Gal(L/E)` and `Gal(L/E)`, since the\n former is defined to be a subgroup of `Gal(L/K)`, while the latter is a group in its own right.\n\n## Implementation Notes\n\n- `krullTopology K L` is defined as an instance for type class inference.\n-/\n\n@[expose] public section\n\nopen scoped Pointwise\n\n/-- Given a field extension `L/K`, `finiteExts K L` is the set of\nintermediate field extensions `L/E/K` such that `E/K` is finite. -/\ndef finiteExts (K : Type*) [Field K] (L : Type*) [Field L] [Algebra K L] :\n Set (IntermediateField K L) :=\n {E | FiniteDimensional K E}\n\n/-- Given a field extension `L/K`, `fixedByFinite K L` is the set of\nsubsets `Gal(L/E)` of `Gal(L/K)`, where `E/K` is finite. -/\ndef fixedByFinite (K L : Type*) [Field K] [Field L] [Algebra K L] : Set (Subgroup Gal(L/K)) :=\n IntermediateField.fixingSubgroup '' finiteExts K L\n\n/-- If `L/K` is a field extension, then we have `Gal(L/K) ∈ fixedByFinite K L`. -/\ntheorem top_fixedByFinite {K L : Type*} [Field K] [Field L] [Algebra K L] :\n ⊤ ∈ fixedByFinite K L :=\n ⟨⊥, IntermediateField.instFiniteSubtypeMemBot K, IntermediateField.fixingSubgroup_bot⟩\n\n/-- Given a field extension `L/K`, `galBasis K L` is the filter basis on `Gal(L/K)` whose sets\nare `Gal(L/E)` for intermediate fields `E` with `E/K` finite dimensional. -/\ndef galBasis (K L : Type*) [Field K] [Field L] [Algebra K L] : FilterBasis Gal(L/K) where\n sets := (fun g => g.carrier) '' fixedByFinite K L\n nonempty := ⟨⊤, ⊤, top_fixedByFinite, rfl⟩\n inter_sets := by\n rintro _ _ ⟨_, ⟨E1, h_E1, rfl⟩, rfl⟩ ⟨_, ⟨E2, h_E2, rfl⟩, rfl⟩\n have : FiniteDimensional K E1 := h_E1\n have : FiniteDimensional K E2 := h_E2\n refine ⟨(E1 ⊔ E2).fixingSubgroup.carrier, ⟨_, ⟨_, E1.finiteDimensional_sup E2, rfl⟩, rfl⟩, ?_⟩\n exact Set.subset_inter (E1.fixingSubgroup_le le_sup_left) (E2.fixingSubgroup_le le_sup_right)\n\n/-- A subset of `Gal(L/K)` is a member of `galBasis K L` if and only if it is the underlying set\nof `Gal(L/E)` for some finite subextension `E/K`. -/\ntheorem mem_galBasis_iff (K L : Type*) [Field K] [Field L] [Algebra K L] (U : Set Gal(L/K)) :\n U ∈ galBasis K L ↔ U ∈ (fun g => g.carrier) '' fixedByFinite K L :=\n Iff.rfl\n\n/-- For a field extension `L/K`, `galGroupBasis K L` is the group filter basis on `Gal(L/K)`\nwhose sets are `Gal(L/E)` for finite subextensions `E/K`. -/\n@[implicit_reducible]\ndef galGroupBasis (K L : Type*) [Field K] [Field L] [Algebra K L] :\n GroupFilterBasis Gal(L/K) where\n toFilterBasis := galBasis K L\n one' := fun ⟨H, _, h2⟩ => h2 ▸ H.one_mem\n mul' {U} hU :=\n ⟨U, hU, by\n rcases hU with ⟨H, _, rfl⟩\n rintro x ⟨a, haH, b, hbH, rfl⟩\n exact H.mul_mem haH hbH⟩\n inv' {U} hU :=\n ⟨U, hU, by\n rcases hU with ⟨H, _, rfl⟩\n exact fun _ => H.inv_mem'⟩\n conj' := by\n rintro σ U ⟨H, ⟨E, hE, rfl⟩, rfl⟩\n let F : IntermediateField K L := E.map σ.symm.toAlgHom\n refine ⟨F.fixingSubgroup.carrier, ⟨⟨F.fixingSubgroup, ⟨F, ?_, rfl⟩, rfl⟩, fun g hg => ?_⟩⟩\n · have : FiniteDimensional K E := hE\n exact IntermediateField.finiteDimensional_map σ.symm.toAlgHom\n change σ * g * σ⁻¹ ∈ E.fixingSubgroup\n rw [IntermediateField.mem_fixingSubgroup_iff]\n intro x hx\n change σ (g (σ⁻¹ x)) = x\n have h_in_F : σ⁻¹ x ∈ F := ⟨x, hx, by dsimp⟩\n have h_g_fix : g (σ⁻¹ x) = σ⁻¹ x := by\n rw [Subgroup.mem_carrier, IntermediateField.mem_fixingSubgroup_iff F g] at hg\n exact hg (σ⁻¹ x) h_in_F\n rw [h_g_fix]\n change σ (σ⁻¹ x) = x\n exact AlgEquiv.apply_symm_apply σ x\n\n/-- For a field extension `L/K`, `krullTopology K L` is the topological space structure on\n`Gal(L/K)` induced by the group filter basis `galGroupBasis K L`. -/\ninstance krullTopology (K L : Type*) [Field K] [Field L] [Algebra K L] :\n TopologicalSpace Gal(L/K) :=\n GroupFilterBasis.topology (galGroupBasis K L)\n\n/-- For a field extension `L/K`, the Krull topology on `Gal(L/K)` makes it a topological group. -/\n@[stacks 0BMJ \"We define Krull topology directly without proving the universal property\"]\ninstance (K L : Type*) [Field K] [Field L] [Algebra K L] : IsTopologicalGroup Gal(L/K) :=\n GroupFilterBasis.isTopologicalGroup (galGroupBasis K L)\n\nopen scoped Topology in\n\nTarget:\nlemma krullTopology_mem_nhds_one_iff (K L : Type*) [Field K] [Field L] [Algebra K L]\n (s : Set Gal(L/K)) : s ∈ 𝓝 1 ↔ ∃ E : IntermediateField K L,\n FiniteDimensional K E ∧ (E.fixingSubgroup : Set Gal(L/K)) ⊆ s :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_5ead7c6d304f","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"91a1b21961a801db665a3d60e0d3f19b28a2a3bc72320cafd87c3bec82d642fa","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory","family_id":"krulltopology_mem_nhds_one_iff","file_id":"mathlib/Mathlib/FieldTheory/KrullTopology.lean","sample_id":"5ead7c6d304f6128d5ce7a1f1318a0e4120c41e938959f50a1ef8d65051dd5d7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"26bc9fb87fe788f151e695b88add74d504fa3115b8affe9069b99e07bbd8c054","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"da1bef5e53f16752ac8b7c2236f25380b32f5d66fd1e520850abd9d3a7231cf5","source_sha256":"1ea87511faa4a09576c2d6c82d012e31d7cfe664d9616e16ba1fd01753abb77e","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← mrange_mk, MonoidHom.mrange_eq_map, ← closure_range_of, MonoidHom.map_mclosure,\n ← range_comp, Sum.range_eq]; rfl","hard_negative":false,"metrics":{"chosen_tokens":26,"rejected_tokens":3,"token_jaccard":0.052632,"token_length_ratio":0.115385},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"e132e48ae314cafe053ddd15992bf37dfecc238f85cac3a8371481329c8de5eb","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.PUnit\npublic import Mathlib.Algebra.Group.Subgroup.Ker\npublic import Mathlib.Algebra.Group.Submonoid.Membership\npublic import Mathlib.GroupTheory.Congruence.Basic\n\nNamespace:\nMonoid.Coprod\n\nLocal context:\n/-\nCopyright (c) 2023 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Coproduct (free product) of two monoids or groups\n\nIn this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)\nto be the coproduct (a.k.a. free product) of two monoids.\nThe same type is used for the coproduct of two monoids and for the coproduct of two groups.\n\nThe coproduct `M ∗ N` has the following universal property:\nfor any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,\nthere exists a unique homomorphism `fg : M ∗ N →* P`\nsuch that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,\nwhere `Monoid.Coprod.inl : M →* M ∗ N`\nand `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.\nThis homomorphism `fg` is given by `Monoid.Coprod.lift f g`.\n\nWe also define some homomorphisms and isomorphisms about `M ∗ N`,\nand provide additive versions of all definitions and theorems.\n\n## Main definitions\n\n### Types\n\n* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):\n the free product (a.k.a. coproduct) of two monoids `M` and `N`.\n* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.\n\nIn other sections, we only list multiplicative definitions.\n\n### Instances\n\n* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.\n\n### Monoid homomorphisms\n\n* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.\n\n* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.\n\n* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`\n from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.\n\n* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`\n that allows the user to control the computational behavior.\n\n* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`\n into `M ∗ M' →* N ∗ N'`.\n\n* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.\n\n* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:\n natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.\n\n### Monoid isomorphisms\n\n* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.\n* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.\n* `MulEquiv.coprodAssoc`: associativity of the coproduct.\n* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:\n free product by `PUnit` on the left or on the right is isomorphic to the original monoid.\n\n## Main results\n\nThe universal property of the coproduct\nis given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.\n\nWe also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`\nfor homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.\n\n## Implementation details\n\nThe definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.\nWhile mathematically `M ∗ N` is a particular case\nof the coproduct of an indexed family of monoids,\nit is easier to build API from scratch instead of using something like\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI ![M, N]\n```\n\nor\n\n```\ndef Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)\n```\n\nThere are several reasons to build an API from scratch.\n\n- API about `Con` makes it easy to define the required type and prove the universal property,\n so there is little overhead compared to transferring API from `Monoid.CoprodI`.\n- If `M` and `N` live in different universes, then the definition has to add `ULift`s;\n this makes it harder to transfer API and definitions.\n- As of now, we have no way\n to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`\n from `[Monoid M]` and `[Monoid N]`,\n not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.\n- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`\n as the underlying type makes it possible to write computationally effective code\n (though this point is not tested yet).\n\n## TODO\n\n- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and\n `Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.\n\n## Tags\n\ngroup, monoid, coproduct, free product\n-/\n\n@[expose] public section\n\nassert_not_exists MonoidWithZero\n\nopen FreeMonoid Function List Set\n\nnamespace Monoid\n\n/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`\nsuch that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms\nto the quotient by `c`. -/\n@[to_additive /-- The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`\nsuch that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`\nare additive monoid homomorphisms to the quotient by `c`. -/]\ndef coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=\n sInf {c |\n (∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))\n ∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))\n ∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}\n\n/-- Coproduct of two monoids or groups. -/\n@[to_additive /-- Coproduct of two additive monoids or groups. -/]\ndef Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient\n\nnamespace Coprod\n\n@[inherit_doc]\nscoped infix:30 \" ∗ \" => Coprod\n\nsection MulOneClass\n\nvariable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']\n [MulOneClass P]\n\n@[to_additive] protected instance : MulOneClass (M ∗ N) :=\n inferInstanceAs <| MulOneClass (coprodCon M N).Quotient\n\n/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/\n@[to_additive /-- The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`. -/]\ndef mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _\n\n@[to_additive (attr := simp)]\ntheorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _\n\n@[to_additive]\ntheorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective\n\n@[to_additive (attr := simp)]\ntheorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'\n\n@[to_additive]\ntheorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _\n\n/-- The natural embedding `M →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `M →+ AddMonoid.Coprod M N`. -/]\ndef inl : M →* M ∗ N where\n toFun := fun x => mk (of (.inl x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y\n\n/-- The natural embedding `N →* M ∗ N`. -/\n@[to_additive /-- The natural embedding `N →+ AddMonoid.Coprod M N`. -/]\ndef inr : N →* M ∗ N where\n toFun := fun x => mk (of (.inr x))\n map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2\n map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl\n\n@[to_additive (attr := simp)]\ntheorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl\n\n@[to_additive (attr := elab_as_elim)]\ntheorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)\n (one : C 1)\n (inl_mul : ∀ m x, C x → C (inl m * x))\n (inr_mul : ∀ n x, C x → C (inr n * x)) : C m := by\n rcases mk_surjective m with ⟨x, rfl⟩\n induction x using FreeMonoid.inductionOn' with\n | one => exact one\n | mul_of x xs ih =>\n cases x with\n | inl m => simpa using inl_mul m _ ih\n | inr n => simpa using inr_mul n _ ih\n\n@[to_additive (attr := elab_as_elim)]\ntheorem induction_on {C : M ∗ N → Prop} (m : M ∗ N)\n (inl : ∀ m, C (inl m)) (inr : ∀ n, C (inr n)) (mul : ∀ x y, C x → C y → C (x * y)) : C m :=\n induction_on' m (by simpa using inl 1) (fun _ _ ↦ mul _ _ (inl _)) fun _ _ ↦ mul _ _ (inr _)\n\n/-- Lift a monoid homomorphism `FreeMonoid (M ⊕ N) →* P` satisfying additional properties to\n`M ∗ N →* P`. In many cases, `Coprod.lift` is more convenient.\n\nCompared to `Coprod.lift`,\nthis definition allows a user to provide a custom computational behavior.\nAlso, it only needs `MulOneClass` assumptions while `Coprod.lift` needs a `Monoid` structure.\n-/\n@[to_additive /-- Lift an additive monoid homomorphism `FreeAddMonoid (M ⊕ N) →+ P` satisfying\nadditional properties to `AddMonoid.Coprod M N →+ P`.\n\nCompared to `AddMonoid.Coprod.lift`,\nthis definition allows a user to provide a custom computational behavior.\nAlso, it only needs `AddZeroClass` assumptions\nwhile `AddMonoid.Coprod.lift` needs an `AddMonoid` structure. -/]\ndef clift (f : FreeMonoid (M ⊕ N) →* P)\n (hM₁ : f (of (.inl 1)) = 1) (hN₁ : f (of (.inr 1)) = 1)\n (hM : ∀ x y, f (of (.inl (x * y))) = f (of (.inl x) * of (.inl y)))\n (hN : ∀ x y, f (of (.inr (x * y))) = f (of (.inr x) * of (.inr y))) :\n M ∗ N →* P :=\n Con.lift _ f <| sInf_le ⟨hM, hN, hM₁.trans (map_one f).symm, hN₁.trans (map_one f).symm⟩\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_inl (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : M) :\n clift f hM₁ hN₁ hM hN (inl x) = f (of (.inl x)) :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_inr (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : N) :\n clift f hM₁ hN₁ hM hN (inr x) = f (of (.inr x)) :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_apply_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN w) :\n clift f hM₁ hN₁ hM hN (mk w) = f w :=\n rfl\n\n@[to_additive (attr := simp)]\ntheorem clift_comp_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) :\n (clift f hM₁ hN₁ hM hN).comp mk = f :=\n DFunLike.ext' rfl\n\n@[to_additive (attr := simp)]\n\nTarget:\ntheorem mclosure_range_inl_union_inr :\n Submonoid.closure (range (inl : M →* M ∗ N) ∪ range (inr : N →* M ∗ N)) = ⊤ :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory/Coprod","family_id":"mclosure_range_inl_union_inr","file_id":"mathlib/Mathlib/GroupTheory/Coprod/Basic.lean","sample_id":"da1bef5e53f16752ac8b7c2236f25380b32f5d66fd1e520850abd9d3a7231cf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2be18efe99c4ae42b8de0c676e58e87f9015e199d9133270c6a71b933331634b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"985ba7346fccc1a65a8f480180d834413f4f20604bb2c10992ce8f009277a68e","source_sha256":"84b3eb51873c8f75cb452a06b56a659fd9d61a2ae61434709bf59a8c70a536c6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [uncountable_iff_not_countable]\n exact mt (@Countable.toSmall α) h","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":3,"token_jaccard":0.125,"token_length_ratio":0.2},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"e1e51f432f8d7df3791c23f1168e8d65c22cf814d9c9bd56db8bf2d1703b6b01","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Logic.Small.Basic\npublic import Mathlib.Data.Countable.Defs\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2021 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# All countable types are small.\n\nThat is, any countable type is equivalent to a type in any universe.\n-/\n\npublic section\n\nuniverse w v\n\ninstance (priority := 100) Countable.toSmall (α : Type v) [Countable α] : Small.{w} α :=\n let ⟨_, hf⟩ := exists_injective_nat α\n small_of_injective hf\n\nTarget:\ntheorem Uncountable.of_not_small {α : Type v} (h : ¬ Small.{w} α) : Uncountable α :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Countable","family_id":"uncountable","file_id":"mathlib/Mathlib/Data/Countable/Small.lean","sample_id":"985ba7346fccc1a65a8f480180d834413f4f20604bb2c10992ce8f009277a68e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f6c9c283d4acd50fcc2c27a0de1087861e3d20f5652a0f2a0c411719160916a1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5faf2206ebbffa834cf41c93349e8eb22a67ad60a3e621bb03b013895150626d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d65ea34e7c6de56d28e43cd82be8846165fd225bc64f1fd5bc16e04be298bc0d","source_sha256":"4123b423d4ccc708b4b1a3b56340ef36fdd81734c2f664d52dcec25eff24b129","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [ih_η, ih_θ]","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":3,"token_jaccard":0.1,"token_length_ratio":0.333333},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"e24166c81e5c4dc85a4bf858076899055adb8592f016758ad9302355405bdb38","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes\npublic import Mathlib.Tactic.CategoryTheory.MonoidalComp\n\nNamespace:\nMathlib.Tactic.Monoidal\n\nLocal context:\n/-\nCopyright (c) 2024 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n-/\npublic meta import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes\n\n/-!\n# Expressions for monoidal categories\n\nThis file converts lean expressions representing morphisms in monoidal categories into `Mor₂Iso`\nor `Mor` terms. The converted expressions are used in the coherence tactics and the string diagram\nwidgets.\n\n-/\n\npublic meta section\n\nopen Lean Meta Elab Qq\nopen CategoryTheory Mathlib.Tactic.BicategoryLike MonoidalCategory\n\nnamespace Mathlib.Tactic.Monoidal\n\n/-- The domain of a morphism. -/\ndef srcExpr (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, f, _]) => return f\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The codomain of a morphism. -/\ndef tgtExpr (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, _, g]) => return g\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The domain of an isomorphism. -/\ndef srcExprOfIso (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Iso, #[_, _, f, _]) => return f\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The codomain of an isomorphism. -/\ndef tgtExprOfIso (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Iso, #[_, _, _, g]) => return g\n | _ => throwError m!\"{η} is not a morphism\"\n\ninitialize registerTraceClass `monoidal\n\n/-- The context for evaluating expressions. -/\nstructure Context where\n /-- The level for morphisms. -/\n level₂ : Level\n /-- The level for objects. -/\n level₁ : Level\n /-- The expression for the underlying category. -/\n C : Q(Type level₁)\n /-- The category instance. -/\n instCat : Q(Category.{level₂, level₁} $C)\n /-- The monoidal category instance. -/\n instMonoidal? : Option Q(MonoidalCategory.{level₂, level₁} $C)\n\n/-- Populate a `context` object for evaluating `e`. -/\ndef mkContext? (e : Expr) : MetaM (Option Context) := do\n let e ← instantiateMVars e\n let type ← instantiateMVars <| ← inferType e\n match (← whnfR type).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, f, _]) =>\n let C ← instantiateMVars <| ← inferType f\n let .succ level₁ ← getLevel C | return none\n let .succ level₂ ← getLevel type | return none\n let some instCat ← synthInstance?\n (mkAppN (.const ``Category [level₂, level₁]) #[C]) | return none\n let instMonoidal? ← synthInstance?\n (mkAppN (.const ``MonoidalCategory [level₂, level₁]) #[C, instCat])\n return some ⟨level₂, level₁, C, instCat, instMonoidal?⟩\n | _ => return none\n\ninstance : BicategoryLike.Context Monoidal.Context where\n mkContext? := Monoidal.mkContext?\n\n/-- The monad for the normalization of 2-morphisms. -/\nabbrev MonoidalM := CoherenceM Context\n\n/-- Throw an error if the monoidal category instance is not found. -/\ndef synthMonoidalError {α : Type} : MetaM α := do\n throwError \"failed to find monoidal category instance\"\n\ninstance : MonadMor₁ MonoidalM where\n id₁M a := do\n let ctx ← read\n let some _monoidal := ctx.instMonoidal? | synthMonoidalError\n return .id (q(𝟙_ _) : Q($ctx.C)) a\n comp₁M f g := do\n let ctx ← read\n let some _monoidal := ctx.instMonoidal? | synthMonoidalError\n let f_e : Q($ctx.C) := f.e\n let g_e : Q($ctx.C) := g.e\n return .comp (q($f_e ⊗ $g_e)) f g\n\nsection\n\nuniverse v u\nvariable {C : Type u} [Category.{v} C]\n\nTarget:\ntheorem structuralIsoOfExpr_comp {f g h : C}\n (η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η)\n (θ : g ⟶ h) (θ' : g ≅ h) (ih_θ : θ'.hom = θ) :\n (η' ≪≫ θ').hom = η ≫ θ :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_d65ea34e7c6d","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"d39ea8f1cb9afac2ea48bc6a29349d87b12e28a64202736114e015acbe6fb4e3","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/CategoryTheory","family_id":"structuralisoofexpr_comp","file_id":"mathlib/Mathlib/Tactic/CategoryTheory/Monoidal/Datatypes.lean","sample_id":"d65ea34e7c6de56d28e43cd82be8846165fd225bc64f1fd5bc16e04be298bc0d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ed7f1f542771eb5fddb7734bfde55d1376aed730f064c0316496915624dd1e22","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1939e07ffc3a746055b1935b8ac9b00f5226d7dbcaf252ce02d76282f9e08cce","source_sha256":"c1d40ca8793192b2a1e02b083144d77da7c781464bb316546f36e29eac1559fe","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← nonpos_iff_eq_zero, ← measure_limsup_cofinite_eq_zero h]\n exact measure_mono liminf_le_limsup","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.153846},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"e2cb3a101672c53474c166257f114c024da452ba000ecf8fefb133910759dafa","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.OuterMeasure.AE\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Yury Kudryashov\n-/\n/-!\n# Borel-Cantelli lemma, part 1\n\nIn this file we show one implication of the **Borel-Cantelli lemma**:\nif `s i` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen a.e. all points belong to finitely many sets of the family.\n\nWe prove several versions of this lemma:\n\n- `MeasureTheory.ae_finite_setOf_mem`: as stated above;\n- `MeasureTheory.measure_limsup_cofinite_eq_zero`:\n in terms of `Filter.limsup` along `Filter.cofinite`;\n- `MeasureTheory.measure_limsup_atTop_eq_zero`:\n in terms of `Filter.limsup` along `(Filter.atTop : Filter ℕ)`.\n\nFor the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`.\n-/\n\npublic section\n\nopen Filter Set\nopen scoped ENNReal Topology\n\nnamespace MeasureTheory\n\nvariable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] [Countable ι] {μ : F}\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen the limit superior of the `s i` along the cofinite filter is a null set.\n\nNote: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`. -/\ntheorem measure_limsup_cofinite_eq_zero {s : ι → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :\n μ (limsup s cofinite) = 0 := by\n refine bot_unique <| ge_of_tendsto' (ENNReal.tendsto_tsum_compl_atTop_zero hs) fun t ↦ ?_\n calc\n μ (limsup s cofinite) ≤ μ (⋃ i : {i // i ∉ t}, s i) := by\n gcongr\n rw [hasBasis_cofinite.limsup_eq_iInf_iSup, iUnion_subtype]\n exact iInter₂_subset _ t.finite_toSet\n _ ≤ ∑' i : {i // i ∉ t}, μ (s i) := measure_iUnion_le _\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a sequence of sets such that `∑' i, μ (s i)` is finite,\nthen the limit superior of the `s i` along the `atTop` filter is a null set.\n\nNote: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),\nsee `ProbabilityTheory.measure_limsup_eq_one`. -/\ntheorem measure_limsup_atTop_eq_zero {s : ℕ → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :\n μ (limsup s atTop) = 0 := by\n rw [← Nat.cofinite_eq_atTop, measure_limsup_cofinite_eq_zero hs]\n\n/-- One direction of the **Borel-Cantelli lemma**\n(sometimes called the \"*first* Borel-Cantelli lemma\"):\nif `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,\nthen a.e. all points belong to finitely many sets of the family. -/\ntheorem ae_finite_setOf_mem {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :\n ∀ᵐ x ∂μ, {i | x ∈ s i}.Finite := by\n rw [ae_iff, ← measure_limsup_cofinite_eq_zero h]\n congr 1 with x\n simp [mem_limsup_iff_frequently_mem, Filter.Frequently]\n\n/-- A version of the **Borel-Cantelli lemma**: if `pᵢ` is a sequence of predicates such that\n`∑' i, μ {x | pᵢ x}` is finite, then the measure of `x` such that `pᵢ x` holds frequently as `i → ∞`\n(or equivalently, `pᵢ x` holds for infinitely many `i`) is equal to zero. -/\ntheorem measure_setOf_frequently_eq_zero {p : ℕ → α → Prop} (hp : ∑' i, μ { x | p i x } ≠ ∞) :\n μ { x | ∃ᶠ n in atTop, p n x } = 0 := by\n simpa only [limsup_eq_iInf_iSup_of_nat, frequently_atTop, ← bex_def, setOf_forall,\n setOf_exists] using! measure_limsup_atTop_eq_zero hp\n\n/-- A version of the **Borel-Cantelli lemma**: if `sᵢ` is a sequence of sets such that\n`∑' i, μ sᵢ` is finite, then for almost all `x`, `x` does not belong to `sᵢ` for large `i`. -/\ntheorem ae_eventually_notMem {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :\n ∀ᵐ x ∂μ, ∀ᶠ n in atTop, x ∉ s n :=\n measure_setOf_frequently_eq_zero hs\n\nTarget:\ntheorem measure_liminf_cofinite_eq_zero [Infinite ι] {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :\n μ (liminf s cofinite) = 0 :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/OuterMeasure","family_id":"measure_liminf_cofinite_eq_zero","file_id":"mathlib/Mathlib/MeasureTheory/OuterMeasure/BorelCantelli.lean","sample_id":"1939e07ffc3a746055b1935b8ac9b00f5226d7dbcaf252ce02d76282f9e08cce"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"285c3f112f71c5567f33bffd1e4b5c727410fe5de46b42c4619a426f7c4e016f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"1328d3491da93672dffa35377f20105d1b61a62bab6d7002554ed21b2d9cda8c","source_sha256":"ae5712c01e19ee9e698953ecf3438b05b54b2b04dda2e774200341d53bf92b5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n by_cases hmem : ⊤ ∈ s\n · exact sSup_of_top_mem hmem\n · exact if_neg hmem |>.trans <| if_neg h","hard_negative":false,"metrics":{"chosen_tokens":23,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.130435},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"e2d169fb734f65986e936b17231fbf29a6ba177b16ee0485613896bbffe922d9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice\npublic import Mathlib.Order.ConditionallyCompleteLattice.Defs\npublic import Mathlib.Order.ConditionallyCompletePartialOrder.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-!\n# Theory of conditionally complete lattices\n\nA conditionally complete lattice is a lattice in which every non-empty bounded subset `s`\nhas a least upper bound and a greatest lower bound, denoted below by `sSup s` and `sInf s`.\nTypical examples are `ℝ`, `ℕ`, and `ℤ` with their usual orders.\n\nThe theory is very comparable to the theory of complete lattices, except that suitable\nboundedness and nonemptiness assumptions have to be added to most statements.\nWe express these using the `BddAbove` and `BddBelow` predicates, which we use to prove\nmost useful properties of `sSup` and `sInf` in conditionally complete lattices.\n\nTo differentiate the statements between complete lattices and conditionally complete\nlattices, we prefix `sInf` and `sSup` in the statements by `c`, giving `csInf` and `csSup`.\nFor instance, `sInf_le` is a statement in complete lattices ensuring `sInf s ≤ x`,\nwhile `csInf_le` is the same statement in conditionally complete lattices\nwith an additional assumption that `s` is bounded below.\n-/\n\n@[expose] public section\n\n-- Guard against import creep\nassert_not_exists Multiset\n\nopen Function OrderDual Set\n\nvariable {α β γ : Type*} {ι : Sort*}\n\nsection LE\n\n/-!\nExtension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α`\n-/\n\nvariable [LE α]\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instSupSet [SupSet α] :\n SupSet (WithTop α) :=\n ⟨fun S =>\n if ⊤ ∈ S then ⊤ else if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then\n ↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=\n ⟨fun S => if S ⊆ {⊤} ∨ ¬BddBelow S then ⊤ else ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩\n\n@[to_dual]\ntheorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)\n (hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=\n (if_neg hs).trans <| if_pos hs'\n\n@[to_dual]\ntheorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) :\n sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=\n if_neg <| by simp [hs, h's]\n\n@[simp]\ntheorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=\n if_pos <| by simp\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_singleton_top [InfSet α] : sInf ({⊤} : Set (WithTop α)) = ⊤ :=\n if_pos <| .inl subset_rfl\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sSup_of_top_mem [SupSet α] {s : Set (WithTop α)} (h : ⊤ ∈ s) : sSup s = ⊤ :=\n if_pos h\n\n@[to_dual]\ntheorem WithTop.sSup_singleton_top [SupSet α] : sSup ({⊤} : Set (WithTop α)) = ⊤ := by\n simp\n\n@[to_dual]\n\nTarget:\ntheorem WithTop.sSup_of_not_bddAbove [SupSet α] {s : Set (WithTop α)}\n (h : ¬BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ⊤ :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/ConditionallyCompleteLattice","family_id":"withtop","file_id":"mathlib/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean","sample_id":"1328d3491da93672dffa35377f20105d1b61a62bab6d7002554ed21b2d9cda8c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4a31c3694f0a700631e2f56726fd910eacab3c7a5db1e512c199ce266ebe78fe","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b56bde4606c354af04f1cdcc49085c017324c540fef76bdd0096e6ba3c9e6565","source_sha256":"a7fe36236e2ed09f5c9d6f891e25635e8949de49ab4080f1346dbb2cc7d33457","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [support, Finsupp.notMem_support_iff]\n exact Iff.rfl","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":3,"token_jaccard":0.153846,"token_length_ratio":0.230769},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"e32eb2a76aade2550fa8958da1760e960e0aaa705b4827cf36202cc6bb92e174","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Finsupp.Basic\npublic import Mathlib.Algebra.Module.End\npublic import Mathlib.GroupTheory.FreeAbelianGroup\n\nNamespace:\nFreeAbelianGroup\n\nLocal context:\n/-\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/-!\n# Isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n\nIn this file we construct the canonical isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`.\nWe use this to transport the notion of `support` from `Finsupp` to `FreeAbelianGroup`.\n\n## Main declarations\n\n- `FreeAbelianGroup.equivFinsupp`: group isomorphism between `FreeAbelianGroup X` and `X →₀ ℤ`\n- `FreeAbelianGroup.coeff`: the multiplicity of `x : X` in `a : FreeAbelianGroup X`\n- `FreeAbelianGroup.support`: the finset of `x : X` that occur in `a : FreeAbelianGroup X`\n-/\n\n@[expose] public section\n\nassert_not_exists Cardinal Module.Basis\n\nnoncomputable section\n\nvariable {X : Type*}\n\n/-- The group homomorphism `FreeAbelianGroup X →+ (X →₀ ℤ)`. -/\ndef FreeAbelianGroup.toFinsupp : FreeAbelianGroup X →+ X →₀ ℤ :=\n FreeAbelianGroup.lift fun x => Finsupp.single x (1 : ℤ)\n\n/-- The group homomorphism `(X →₀ ℤ) →+ FreeAbelianGroup X`. -/\ndef Finsupp.toFreeAbelianGroup : (X →₀ ℤ) →+ FreeAbelianGroup X :=\n Finsupp.liftAddHom fun x => (smulAddHom ℤ (FreeAbelianGroup X)).flip (FreeAbelianGroup.of x)\n\n@[simp] lemma FreeAbelianGroup.toFinsupp_of (x : X) : toFinsupp (of x) = .single x 1 := by\n simp [toFinsupp]\n\n@[simp] lemma Finsupp.toFreeAbelianGroup_single (x : X) (n : ℤ) :\n toFreeAbelianGroup (single x n) = n • .of x := by simp [toFreeAbelianGroup]\n\nopen Finsupp FreeAbelianGroup\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_singleAddHom (x : X) :\n Finsupp.toFreeAbelianGroup.comp (Finsupp.singleAddHom x) =\n (smulAddHom ℤ (FreeAbelianGroup X)).flip (of x) :=\n AddMonoidHom.ext <| toFreeAbelianGroup_single _\n\n@[simp]\ntheorem FreeAbelianGroup.toFinsupp_comp_toFreeAbelianGroup :\n toFinsupp.comp toFreeAbelianGroup = AddMonoidHom.id (X →₀ ℤ) := by\n ext\n simp\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_comp_toFinsupp :\n toFreeAbelianGroup.comp toFinsupp = AddMonoidHom.id (FreeAbelianGroup X) := by\n ext\n rw [toFreeAbelianGroup, toFinsupp, AddMonoidHom.comp_apply, lift_apply_of,\n liftAddHom_apply_single, AddMonoidHom.flip_apply, smulAddHom_apply, one_smul,\n AddMonoidHom.id_apply]\n\n@[simp]\ntheorem Finsupp.toFreeAbelianGroup_toFinsupp {X} (x : FreeAbelianGroup X) :\n Finsupp.toFreeAbelianGroup (FreeAbelianGroup.toFinsupp x) = x := by\n rw [← AddMonoidHom.comp_apply, Finsupp.toFreeAbelianGroup_comp_toFinsupp, AddMonoidHom.id_apply]\n\nnamespace FreeAbelianGroup\n\nopen Finsupp\n\n@[simp]\ntheorem toFinsupp_toFreeAbelianGroup (f : X →₀ ℤ) :\n FreeAbelianGroup.toFinsupp (Finsupp.toFreeAbelianGroup f) = f := by\n rw [← AddMonoidHom.comp_apply, toFinsupp_comp_toFreeAbelianGroup, AddMonoidHom.id_apply]\n\nvariable (X)\n\n/-- The additive equivalence between `FreeAbelianGroup X` and `(X →₀ ℤ)`. -/\n@[simps!]\ndef equivFinsupp : FreeAbelianGroup X ≃+ (X →₀ ℤ) where\n toFun := toFinsupp\n invFun := toFreeAbelianGroup\n left_inv := toFreeAbelianGroup_toFinsupp\n right_inv := toFinsupp_toFreeAbelianGroup\n map_add' := toFinsupp.map_add\n\nvariable {X}\n\n/-- `coeff x` is the additive group homomorphism `FreeAbelianGroup X →+ ℤ`\nthat sends `a` to the multiplicity of `x : X` in `a`. -/\ndef coeff (x : X) : FreeAbelianGroup X →+ ℤ :=\n (Finsupp.applyAddHom x).comp toFinsupp\n\n/-- `support a` for `a : FreeAbelianGroup X` is the finite set of `x : X`\nthat occur in the formal sum `a`. -/\ndef support (a : FreeAbelianGroup X) : Finset X :=\n a.toFinsupp.support\n\n@[simp]\ntheorem mem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∈ a.support ↔ coeff x a ≠ 0 := by\n rw [support, Finsupp.mem_support_iff]\n exact Iff.rfl\n\nTarget:\ntheorem notMem_support_iff (x : X) (a : FreeAbelianGroup X) : x ∉ a.support ↔ coeff x a = 0 :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAbelianGroup","family_id":"notmem_support_iff","file_id":"mathlib/Mathlib/Algebra/FreeAbelianGroup/Finsupp.lean","sample_id":"b56bde4606c354af04f1cdcc49085c017324c540fef76bdd0096e6ba3c9e6565"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2dd26aa16922b4b1730a990a8f4281058b74eb64cb8af6e51735f7cf7cc0a7da","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e076da205af4fb3a325ff5f9c19c6b5ee67ed1606d459a6b768a83543c4ea749","source_sha256":"2ab3c6bb05b55d8a4fa84cd2cd336003b6ff429674fec08decf3b8e5d2ab8013","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [liftp_iff]; constructor <;> intro h\n · rcases h with ⟨a', f', heq, h'⟩\n cases heq\n assumption\n repeat' first | constructor | assumption","hard_negative":true,"metrics":{"chosen_tokens":35,"rejected_tokens":8,"token_jaccard":0.030303,"token_length_ratio":0.228571},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"e4f7f02cdb23ac9429e2f0a98f5a3600e67dbbf4d096ced43603646586aab222","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.W.Basic\n\nNamespace:\nPFunctor\n\nLocal context:\n/-\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/-!\n# Polynomial Functors\n\nThis file defines polynomial functors and the W-type construction as a polynomial functor.\n(For the M-type construction, see `Mathlib/Data/PFunctor/Univariate/M.lean`.)\n-/\n\n@[expose] public section\n\nuniverse u v uA uB uA₁ uB₁ uA₂ uB₂ v₁ v₂ v₃\n\nset_option linter.checkUnivs false in\n/-- A polynomial functor `P` is given by a type `A` and a family `B` of types over `A`. `P` maps\nany type `α` to a new type `P α`, which is defined as the sigma type `Σ x, P.B x → α`.\n\nAn element of `P α` is a pair `⟨a, f⟩`, where `a` is an element of a type `A` and\n`f : B a → α`. Think of `a` as the shape of the object and `f` as an index to the relevant\nelements of `α`.\n-/\n-- Note: `nolint checkUnivs` should not apply here, we really do want two separate universe levels\n@[pp_with_univ, nolint checkUnivs]\nstructure PFunctor where\n /-- The head type -/\n A : Type uA\n /-- The child family of types -/\n B : A → Type uB\n\nnamespace PFunctor\n\ninstance : Inhabited PFunctor :=\n ⟨⟨default, default⟩⟩\n\nvariable (P : PFunctor.{uA, uB}) {α : Type v₁} {β : Type v₂} {γ : Type v₃}\n\n/-- Applying `P` to an object of `Type` -/\n@[coe]\ndef Obj (α : Type v) : Type (max v uA uB) :=\n Σ x : P.A, P.B x → α\n\ninstance : CoeFun PFunctor.{uA, uB} (fun _ => Type v → Type (max v uA uB)) where\n coe := Obj\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map (f : α → β) : P α → P β :=\n fun ⟨a, g⟩ => ⟨a, f ∘ g⟩\n\ninstance Obj.inhabited [Inhabited P.A] [Inhabited α] : Inhabited (P α) :=\n ⟨⟨default, default⟩⟩\n\ninstance : Functor P.Obj where map := @map P\n\n/-- We prefer `PFunctor.map` to `Functor.map` because it is universe-polymorphic. -/\n@[simp]\ntheorem map_eq_map {α β : Type v} (f : α → β) (x : P α) : f <$> x = P.map f x :=\n rfl\n\n@[simp]\nprotected theorem map_eq (f : α → β) (a : P.A) (g : P.B a → α) :\n P.map f ⟨a, g⟩ = ⟨a, f ∘ g⟩ :=\n rfl\n\n@[simp]\nprotected theorem id_map : ∀ x : P α, P.map id x = x := fun ⟨_, _⟩ => rfl\n\n@[simp]\nprotected theorem map_map (f : α → β) (g : β → γ) :\n ∀ x : P α, P.map g (P.map f x) = P.map (g ∘ f) x := fun ⟨_, _⟩ => rfl\n\ninstance : LawfulFunctor (Obj.{v} P) where\n map_const := rfl\n id_map x := P.id_map x\n comp_map f g x := P.map_map f g x |>.symm\n\n/-- Re-export existing definition of W-types and adapt it to a packaged definition of polynomial\nfunctor. -/\ndef W : Type (max uA uB) :=\n WType P.B\n\n/- Inhabitants of W types is awkward to encode as an instance assumption because there needs to be a\nvalue `a : P.A` such that `P.B a` is empty to yield a finite tree. -/\n\nvariable {P}\n\n/-- The root element of a W tree -/\ndef W.head : W P → P.A\n | ⟨a, _f⟩ => a\n\n/-- The children of the root of a W tree -/\ndef W.children : ∀ x : W P, P.B (W.head x) → W P\n | ⟨_a, f⟩ => f\n\n/-- The destructor for W-types -/\ndef W.dest : W P → P (W P)\n | ⟨a, f⟩ => ⟨a, f⟩\n\n/-- The constructor for W-types -/\ndef W.mk : P (W P) → W P\n | ⟨a, f⟩ => ⟨a, f⟩\n\n@[simp]\ntheorem W.dest_mk (p : P (W P)) : W.dest (W.mk p) = p := by cases p; rfl\n\n@[simp]\ntheorem W.mk_dest (p : W P) : W.mk (W.dest p) = p := by cases p; rfl\n\nvariable (P)\n\n/-- `Idx` identifies a location inside the application of a polynomial functor. For `F : PFunctor`,\n`x : F α` and `i : F.Idx`, `i` can designate one part of `x` or is invalid, if `i.1 ≠ x.1`. -/\ndef Idx : Type (max uA uB) :=\n Σ x : P.A, P.B x\n\ninstance Idx.inhabited [Inhabited P.A] [Inhabited (P.B default)] : Inhabited P.Idx :=\n ⟨⟨default, default⟩⟩\n\nvariable {P}\n\n/-- `x.iget i` takes the component of `x` designated by `i` if any is or returns a default value -/\ndef Obj.iget [DecidableEq P.A] {α} [Inhabited α] (x : P α) (i : P.Idx) : α :=\n if h : i.1 = x.1 then x.2 (cast (congr_arg _ h) i.2) else default\n\n@[simp]\ntheorem fst_map (x : P α) (f : α → β) : (P.map f x).1 = x.1 := by cases x; rfl\n\n@[simp]\ntheorem iget_map [DecidableEq P.A] [Inhabited α] [Inhabited β] (x : P α)\n (f : α → β) (i : P.Idx) (h : i.1 = x.1) : (P.map f x).iget i = f (x.iget i) := by\n simp only [Obj.iget, fst_map, *, dif_pos]\n cases x\n rfl\n\nend PFunctor\n\n/-\nComposition of polynomial functors.\n-/\nnamespace PFunctor\n\n/-- Composition for polynomial functors -/\ndef comp (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) :\n PFunctor.{max uA₁ uA₂ uB₂, max uB₁ uB₂} :=\n ⟨Σ a₂ : P₂.1, P₂.2 a₂ → P₁.1, fun a₂a₁ => Σ u : P₂.2 a₂a₁.1, P₁.2 (a₂a₁.2 u)⟩\n\n/-- Constructor for composition -/\ndef comp.mk (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) {α : Type v} (x : P₂ (P₁ α)) :\n comp P₂ P₁ α :=\n ⟨⟨x.1, Sigma.fst ∘ x.2⟩, fun a₂a₁ => (x.2 a₂a₁.1).2 a₂a₁.2⟩\n\n/-- Destructor for composition -/\ndef comp.get (P₂ : PFunctor.{uA₂, uB₂}) (P₁ : PFunctor.{uA₁, uB₁}) {α : Type v} (x : comp P₂ P₁ α) :\n P₂ (P₁ α) :=\n ⟨x.1.1, fun a₂ => ⟨x.1.2 a₂, fun a₁ => x.2 ⟨a₂, a₁⟩⟩⟩\n\nend PFunctor\n\n/-\nLifting predicates and relations.\n-/\nnamespace PFunctor\n\nvariable {P : PFunctor.{uA, uB}}\n\nopen Functor\n\ntheorem liftp_iff {α : Type u} (p : α → Prop) (x : P α) :\n Liftp p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i, p (f i) := by\n constructor\n · rintro ⟨y, hy⟩\n rcases h : y with ⟨a, f⟩\n refine ⟨a, fun i => (f i).val, ?_, fun i => (f i).property⟩\n rw [← hy, h, map_eq_map, PFunctor.map_eq]\n congr\n rintro ⟨a, f, xeq, pf⟩\n use ⟨a, fun i => ⟨f i, pf i⟩⟩\n rw [xeq]; rfl\n\nTarget:\ntheorem liftp_iff' {α : Type u} (p : α → Prop) (a : P.A) (f : P.B a → α) :\n @Liftp.{u} P.Obj _ α p ⟨a, f⟩ ↔ ∀ i, p (f i) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"22aa4f136533399e6df3847267473b0dc7455563ce0085190c091383add7ae32","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/PFunctor","family_id":"liftp_iff","file_id":"mathlib/Mathlib/Data/PFunctor/Univariate/Basic.lean","sample_id":"e076da205af4fb3a325ff5f9c19c6b5ee67ed1606d459a6b768a83543c4ea749"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f7e98285d54ed438b66b5fa3b3ec01a93901428fb62dffe9d958e186c396e8d4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d3b2355c76a7ea31e7c4c7e43b01c435ca6e1a718bfb5f964e8166713a42f89f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"cead6dd50e97e63a22930509dad26949a52479242dfd79be2acbe7afd3d8de3e","source_sha256":"70a5b82da05fcedf5f71e60cf25a2a57b4c0e22c0f3c87605458658cd985002a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mem_invtSubmodule, Submodule.span_le, Submodule.comap_coe]\n intro y hy\n simp only [Set.mem_preimage, DistribSMul.toLinearMap_apply, SetLike.mem_coe]\n exact Submodule.subset_span <| MulAction.mem_orbit_of_mem_orbit g hy","hard_negative":false,"metrics":{"chosen_tokens":42,"rejected_tokens":47,"token_jaccard":0.875,"token_length_ratio":1.119048},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"e59e128a5dde2670f784ebac3874e65394716d30425b18cb4dcf4693fb188e54","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Defs\npublic import Mathlib.Algebra.Module.Equiv.Basic\npublic import Mathlib.Algebra.Module.Submodule.Map\npublic import Mathlib.LinearAlgebra.Span.Defs\npublic import Mathlib.Order.Sublattice\n\nNamespace:\nModule.End\n\nLocal context:\n/-\nCopyright (c) 2024 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\n/-!\n# The lattice of invariant submodules\n\nIn this file we defined the type `Module.End.invtSubmodule`, associated to a linear endomorphism of\na module. Its utility stems primarily from those occasions on which we wish to take advantage of the\nlattice structure of invariant submodules.\n\nSee also `Mathlib/Algebra/Polynomial/Module/AEval.lean`.\n\n-/\n\n@[expose] public section\n\nopen Submodule (span)\n\nnamespace Module.End\n\nvariable {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] (f g : End R M)\n\n/-- Given an endomorphism, `f` of some module, this is the sublattice of all `f`-invariant\nsubmodules. -/\ndef invtSubmodule : Sublattice (Submodule R M) where\n carrier := {p : Submodule R M | p ≤ p.comap f}\n supClosed' p hp q hq := sup_le_iff.mpr\n ⟨le_trans hp <| Submodule.comap_mono le_sup_left,\n le_trans hq <| Submodule.comap_mono le_sup_right⟩\n infClosed' p hp q hq := by\n simp only [Set.mem_setOf_eq, Submodule.comap_inf, le_inf_iff]\n exact ⟨inf_le_of_left_le hp, inf_le_of_right_le hq⟩\n\nlemma mem_invtSubmodule {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ p ≤ p.comap f :=\n Iff.rfl\n\n/-- `p` is `f` invariant if and only if `p.map f ≤ p`. -/\ntheorem mem_invtSubmodule_iff_map_le {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ p.map f ≤ p := Submodule.map_le_iff_le_comap.symm\n\n/-- `p` is `f` invariant if and only if `Set.MapsTo f p p`. -/\ntheorem mem_invtSubmodule_iff_mapsTo {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ Set.MapsTo f p p := Iff.rfl\n\nalias ⟨_, _root_.Set.Mapsto.mem_invtSubmodule⟩ := mem_invtSubmodule_iff_mapsTo\n\ntheorem mem_invtSubmodule_iff_forall_mem_of_mem {p : Submodule R M} :\n p ∈ f.invtSubmodule ↔ ∀ x ∈ p, f x ∈ p :=\n Iff.rfl\n\n/-- `p` is `f.symm` invariant if and only if `p ≤ p.map f`. -/\nlemma mem_invtSubmodule_symm_iff_le_map {f : M ≃ₗ[R] M} {p : Submodule R M} :\n p ∈ invtSubmodule f.symm ↔ p ≤ p.map (f : M →ₗ[R] M) :=\n (mem_invtSubmodule_iff_map_le _).trans (f.toEquiv.symm.subset_symm_image _ _).symm\n\nlemma invtSubmodule_inf_invtSubmodule_le_invtSubmodule_add :\n f.invtSubmodule ⊓ g.invtSubmodule ≤ (f + g).invtSubmodule :=\n fun p ⟨hfp, hgp⟩ _ hx ↦ p.add_mem (hfp hx) (hgp hx)\n\nsection CommRing\n\nvariable {R S : Type*} [Semiring R] [Semiring S] [Module R M] [Module S M]\n [DistribSMul S R] [SMulCommClass R S M] [IsScalarTower S R M] (f : End R M)\n\nlemma invtSubmodule_le_invtSubmodule_smul (c : S) : f.invtSubmodule ≤ (c • f).invtSubmodule :=\n fun p hfp _ hx ↦ p.smul_of_tower_mem c (hfp hx)\n\n@[simp]\nlemma invtSubmodule_smul (c : Sˣ) : (c • f).invtSubmodule = f.invtSubmodule := by\n apply le_antisymm ?_ (invtSubmodule_le_invtSubmodule_smul f c.1)\n grw [invtSubmodule_le_invtSubmodule_smul (c.1 • f) c⁻¹.1]\n simp [smul_smul]\n\nend CommRing\n\nnamespace invtSubmodule\n\nvariable {f}\n\nlemma inf_mem {p q : Submodule R M} (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n p ⊓ q ∈ f.invtSubmodule :=\n Sublattice.inf_mem hp hq\n\nlemma sup_mem {p q : Submodule R M} (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n p ⊔ q ∈ f.invtSubmodule :=\n Sublattice.sup_mem hp hq\n\nvariable (f)\n\n@[simp]\nprotected lemma top_mem : ⊤ ∈ f.invtSubmodule := by simp [invtSubmodule]\n\n@[simp]\nprotected lemma bot_mem : ⊥ ∈ f.invtSubmodule := by simp [invtSubmodule]\n\ninstance : BoundedOrder (f.invtSubmodule) where\n top := ⟨⊤, invtSubmodule.top_mem f⟩\n bot := ⟨⊥, invtSubmodule.bot_mem f⟩\n le_top := fun ⟨p, hp⟩ ↦ by simp\n bot_le := fun ⟨p, hp⟩ ↦ by simp\n\n@[simp]\nprotected lemma zero :\n (0 : End R M).invtSubmodule = ⊤ :=\n eq_top_iff.mpr fun x ↦ by simp [invtSubmodule]\n\n@[simp]\nprotected lemma id :\n invtSubmodule (LinearMap.id : End R M) = ⊤ :=\n eq_top_iff.mpr fun x ↦ by simp [invtSubmodule]\n\n@[simp]\nprotected lemma one :\n invtSubmodule (1 : End R M) = ⊤ :=\n invtSubmodule.id\n\nprotected lemma mk_eq_bot_iff {p : Submodule R M} (hp : p ∈ f.invtSubmodule) :\n (⟨p, hp⟩ : f.invtSubmodule) = ⊥ ↔ p = ⊥ :=\n Subtype.mk_eq_bot_iff (by simp [invtSubmodule]) _\n\nprotected lemma mk_eq_top_iff {p : Submodule R M} (hp : p ∈ f.invtSubmodule) :\n (⟨p, hp⟩ : f.invtSubmodule) = ⊤ ↔ p = ⊤ :=\n Subtype.mk_eq_top_iff (by simp [invtSubmodule]) _\n\n@[simp]\nprotected lemma disjoint_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n Disjoint (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ Disjoint p q := by\n rw [disjoint_iff, disjoint_iff, Sublattice.mk_inf_mk,\n Subtype.mk_eq_bot_iff (⊥ : f.invtSubmodule).property]\n\nprotected lemma disjoint_iff {p q : f.invtSubmodule} :\n Disjoint p q ↔ Disjoint (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\n@[simp]\nprotected lemma codisjoint_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n Codisjoint (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ Codisjoint p q := by\n rw [codisjoint_iff, codisjoint_iff, Sublattice.mk_sup_mk,\n Subtype.mk_eq_top_iff (⊤ : f.invtSubmodule).property]\n\nprotected lemma codisjoint_iff {p q : f.invtSubmodule} :\n Codisjoint p q ↔ Codisjoint (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\n@[simp]\nprotected lemma isCompl_mk_iff {p q : Submodule R M}\n (hp : p ∈ f.invtSubmodule) (hq : q ∈ f.invtSubmodule) :\n IsCompl (α := f.invtSubmodule) ⟨p, hp⟩ ⟨q, hq⟩ ↔ IsCompl p q := by\n simp [isCompl_iff]\n\nprotected lemma isCompl_iff {p q : f.invtSubmodule} :\n IsCompl p q ↔ IsCompl (p : Submodule R M) (q : Submodule R M) := by\n obtain ⟨p, hp⟩ := p\n obtain ⟨q, hq⟩ := q\n simp\n\nlemma map_subtype_mem_of_mem_invtSubmodule {p : Submodule R M} (hp : p ∈ f.invtSubmodule)\n {q : Submodule R p} (hq : q ∈ invtSubmodule (LinearMap.restrict f hp)) :\n Submodule.map p.subtype q ∈ f.invtSubmodule := by\n rintro - ⟨⟨x, hx⟩, hx', rfl⟩\n specialize hq hx'\n rw [Submodule.mem_comap, LinearMap.restrict_apply] at hq\n simpa [hq] using hp hx\n\nprotected lemma comp {p : Submodule R M} {g : End R M}\n (hf : p ∈ f.invtSubmodule) (hg : p ∈ g.invtSubmodule) :\n p ∈ invtSubmodule (f ∘ₗ g) :=\n fun _ hx ↦ hf (hg hx)\n\n@[simp] lemma _root_.LinearEquiv.map_mem_invtSubmodule_conj_iff {R M N : Type*} [CommSemiring R]\n [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] {f : End R M}\n {e : M ≃ₗ[R] N} {p : Submodule R M} :\n p.map (e : M →ₗ[R] N) ∈ (e.conj f).invtSubmodule ↔ p ∈ f.invtSubmodule := by\n have : e.symm.toLinearMap ∘ₗ ((e ∘ₗ f) ∘ₗ e.symm.toLinearMap) ∘ₗ e = f := by ext; simp\n rw [LinearEquiv.conj_apply, mem_invtSubmodule, mem_invtSubmodule, Submodule.map_le_iff_le_comap,\n Submodule.map_equiv_eq_comap_symm, ← Submodule.comap_comp, ← Submodule.comap_comp, this]\n\nlemma _root_.LinearEquiv.map_mem_invtSubmodule_iff {R M N : Type*} [CommSemiring R]\n [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] {f : End R N}\n {e : M ≃ₗ[R] N} {p : Submodule R M} :\n p.map (e : M →ₗ[R] N) ∈ f.invtSubmodule ↔ p ∈ (e.symm.conj f).invtSubmodule := by\n simp [← e.map_mem_invtSubmodule_conj_iff]\n\nend invtSubmodule\n\nvariable (R) in\n\nTarget:\nlemma span_orbit_mem_invtSubmodule {G : Type*}\n [Monoid G] [DistribMulAction G M] [SMulCommClass G R M] (x : M) (g : G) :\n span R (MulAction.orbit G x) ∈ invtSubmodule (DistribSMul.toLinearMap R M g) :=\n\nProof body:\n","rejected":"by\n rw [mem_invtSubmodule, Submodule.span_le, Submodule.comap_coe]\n intro y hy\n simp only [Set.mem_preimage, DistribSMul.toLinearMap_apply, SetLike.mem_coe]\n exact Submodule.subset_span <| MulAction.mem_orbit_of_mem_orbit g hy\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Module","family_id":"span_orbit_mem_invtsubmodule","file_id":"mathlib/Mathlib/Algebra/Module/Submodule/Invariant.lean","sample_id":"cead6dd50e97e63a22930509dad26949a52479242dfd79be2acbe7afd3d8de3e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"bb8f6cde9d567711fa35573d789e30ab2515f10274fbeb0cf4e134f652ea803f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"789be66cfcfca70a08f19d2db15da4c28ba9c70e08a73feae4cdff08db1338d8","source_sha256":"cf9f07826f15801d5e4d123ed051af6f5fff90fb4e87201d2c41c9a18629b3e1","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n convert! cutExpand_add_left t using 2 <;> apply add_comm","hard_negative":false,"metrics":{"chosen_tokens":12,"rejected_tokens":3,"token_jaccard":0.071429,"token_length_ratio":0.25},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"e636d06dbee95f5d4d231ecab6e5cfbe493e97ec96705526ae5a8274540c7497","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Finsupp.Lex\npublic import Mathlib.Data.Finsupp.Multiset\npublic import Mathlib.Order.GameAdd\n\nNamespace:\nRelation\n\nLocal context:\n/-\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/-!\n# Termination of a hydra game\n\nThis file deals with the following version of the hydra game: each head of the hydra is\nlabelled by an element in a type `α`, and when you cut off one head with label `a`, it\ngrows back an arbitrary but finite number of heads, all labelled by elements smaller than\n`a` with respect to a well-founded relation `r` on `α`. We show that no matter how (in\nwhat order) you choose cut off the heads, the game always terminates, i.e. all heads will\neventually be cut off (but of course it can last arbitrarily long, i.e. takes an\narbitrary finite number of steps).\n\nThis result is stated as the well-foundedness of the `CutExpand` relation defined in\nthis file: we model the heads of the hydra as a multiset of elements of `α`, and the\nvalid \"moves\" of the game are modelled by the relation `CutExpand r` on `Multiset α`:\n`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a ∈ s` and\nadding back an arbitrary multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`.\n\nWe follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.\n\nTODO: formalize the relations corresponding to more powerful (e.g. Kirby–Paris and Buchholz)\nhydras, and prove their well-foundedness.\n-/\n\n@[expose] public section\n\n\nnamespace Relation\n\nopen Multiset Prod\n\nvariable {α : Type*}\n\n/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`\n means that `s'` is obtained by removing one head `a ∈ s` and adding back an arbitrary\n multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`.\n\n This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires\n `DecidableEq α`, so we use the equivalent condition `s' + {a} = s + t` instead, which\n is also easier to verify for explicit multisets `s'`, `s` and `t`.\n\n We also don't include the condition `a ∈ s` because `s' + {a} = s + t` already\n guarantees `a ∈ s + t`, and if `r` is irreflexive then `a ∉ t`, which is the\n case when `r` is well-founded, the case we are primarily interested in.\n\n The lemma `Relation.cutExpand_iff` below converts between this convenient definition\n and the direct translation when `r` is irreflexive. -/\ndef CutExpand (r : α → α → Prop) (s' s : Multiset α) : Prop :=\n ∃ (t : Multiset α) (a : α), (∀ a' ∈ t, r a' a) ∧ s' + {a} = s + t\n\nvariable {r : α → α → Prop}\n\ntheorem cutExpand_le_invImage_lex [DecidableEq α] [Std.Irrefl r] :\n CutExpand r ≤ InvImage (Finsupp.Lex (rᶜ ⊓ (· ≠ ·)) (· < ·)) toFinsupp := by\n rintro s t ⟨u, a, hr, he⟩\n replace hr := fun a' ↦ mt (hr a')\n classical\n refine ⟨a, fun b h ↦ ?_, ?_⟩ <;> simp_rw [toFinsupp_apply]\n · apply_fun count b at he\n simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]\n using he\n · apply_fun count a at he\n simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),\n add_zero] at he\n exact he ▸ Nat.lt_succ_self _\n\ntheorem cutExpand_singleton {s x} (h : ∀ x' ∈ s, r x' x) : CutExpand r s {x} :=\n ⟨s, x, h, add_comm s _⟩\n\ntheorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=\n cutExpand_singleton fun a h ↦ by rwa [mem_singleton.1 h]\n\ntheorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) ↔ CutExpand r t u :=\n exists₂_congr fun _ _ ↦ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]\n\nTarget:\nlemma cutExpand_add_right {s' s} (t) : CutExpand r (s' + t) (s + t) ↔ CutExpand r s' s :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic","family_id":"cutexpand_add_right","file_id":"mathlib/Mathlib/Logic/Hydra.lean","sample_id":"789be66cfcfca70a08f19d2db15da4c28ba9c70e08a73feae4cdff08db1338d8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"414f3043171e88a003ffe9fb6e79021da834dc6bfc40d83e9a6e3fb508f24e29","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"51d0ccc17e59bf6c2b05c869d7ae03172e1bb45f7415b196ed3b8feed5ff27cd","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"025ea6bc4b689a5e0068ab86c471873a7cfcb310a85f88cab7a08a145748ff30","source_sha256":"96b93e774d7f2071797742aab74d7371dec26b20348c9f93cd322847a9ed2c09","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by simp [ofUnitHom]\n\n/-- The equivalence between multiplicative characters and homomorphisms of unit groups. -/\nnoncomputable def equivToUnitHom : MulChar R R' ≃ (Rˣ →* R'ˣ) where\n toFun := toUnitHom\n invFun := ofUnitHom\n left_inv := by\n intro χ\n ext x\n rw [ofUnitHom_coe, coe_toUnitHom]\n right_inv := by\n intro f\n ext x\n simp only [coe_toUnitHom, ofUnitHom_coe]","hard_negative":true,"metrics":{"chosen_tokens":71,"rejected_tokens":5,"token_jaccard":0.039216,"token_length_ratio":0.070423},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"e6db2b63e621d48e2a54ab58ea4bac5a1c9887a51c407e84dc4847a9b3cc43d1","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.CharP.Basic\npublic import Mathlib.Algebra.CharP.Lemmas\npublic import Mathlib.Algebra.Group.Submonoid.Units\npublic import Mathlib.Algebra.GroupWithZero.Units.Fintype\npublic import Mathlib.GroupTheory.OrderOfElement\n\nNamespace:\nMulChar\n\nLocal context:\n/-\nCopyright (c) 2022 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Multiplicative characters of finite rings and fields\n\nLet `R` and `R'` be commutative rings.\nA *multiplicative character* of `R` with values in `R'` is a morphism of\nmonoids from the multiplicative monoid of `R` into that of `R'`\nthat sends non-units to zero.\n\nWe use the namespace `MulChar` for the definitions and results.\n\n## Main results\n\nWe show that the multiplicative characters form a group (if `R'` is commutative);\nsee `MulChar.commGroup`. We also provide an equivalence with the\nhomomorphisms `Rˣ →* R'ˣ`; see `MulChar.equivToUnitHom`.\n\nWe define a multiplicative character to be *quadratic* if its values\nare among `0`, `1` and `-1`, and we prove some properties of quadratic characters.\n\nFinally, we show that the sum of all values of a nontrivial multiplicative\ncharacter vanishes; see `MulChar.IsNontrivial.sum_eq_zero`.\n\n## Tags\n\nmultiplicative character\n-/\n\n@[expose] public section\n\nopen scoped Ring\n\n\n/-!\n### Definitions related to multiplicative characters\n\nEven though the intended use is when domain and target of the characters\nare commutative rings, we define them in the more general setting when\nthe domain is a commutative monoid and the target is a commutative monoid\nwith zero. (We need a zero in the target, since non-units are supposed\nto map to zero.)\n\nIn this setting, there is an equivalence between multiplicative characters\n`R → R'` and group homomorphisms `Rˣ → R'ˣ`, and the multiplicative characters\nhave a natural structure as a commutative group.\n-/\n\n\nsection Defi\n\n-- The domain of our multiplicative characters\nvariable (R : Type*) [CommMonoid R]\n\n-- The target\nvariable (R' : Type*) [CommMonoidWithZero R']\n\n/-- Define a structure for multiplicative characters.\nA multiplicative character from a commutative monoid `R` to a commutative monoid with zero `R'`\nis a homomorphism of (multiplicative) monoids that sends non-units to zero. -/\nstructure MulChar extends MonoidHom R R' where\n map_nonunit' : ∀ a : R, ¬IsUnit a → toFun a = 0\n\ninstance MulChar.instFunLike : FunLike (MulChar R R') R R' :=\n ⟨fun χ => χ.toFun,\n fun χ₀ χ₁ h => by cases χ₀; cases χ₁; congr; apply MonoidHom.ext (fun _ => congr_fun h _)⟩\n\n/-- This is the corresponding extension of `MonoidHomClass`. -/\nclass MulCharClass (F : Type*) (R R' : outParam Type*) [CommMonoid R]\n [CommMonoidWithZero R'] [FunLike F R R'] : Prop extends MonoidHomClass F R R' where\n map_nonunit : ∀ (χ : F) {a : R} (_ : ¬IsUnit a), χ a = 0\n\ninitialize_simps_projections MulChar (toFun → apply, -toMonoidHom)\n\nend Defi\n\nnamespace MulChar\n\nattribute [scoped simp] MulCharClass.map_nonunit\n\nsection Group\n\n-- The domain of our multiplicative characters\nvariable {R : Type*} [CommMonoid R]\n\n-- The target\nvariable {R' : Type*} [CommMonoidWithZero R']\n\nvariable (R R') in\n/-- The trivial multiplicative character. It takes the value `0` on non-units and\nthe value `1` on units. -/\n@[simps]\nnoncomputable def trivial : MulChar R R' where\n toFun := by classical exact fun x => if IsUnit x then 1 else 0\n map_nonunit' := by\n intro a ha\n simp only [ha, if_false]\n map_one' := by simp only [isUnit_one, if_true]\n map_mul' := by\n intro x y\n classical\n simp only [IsUnit.mul_iff, boole_mul]\n split_ifs <;> tauto\n\n@[simp]\ntheorem coe_mk (f : R →* R') (hf) : (MulChar.mk f hf : R → R') = f :=\n rfl\n\n/-- Extensionality. See `ext` below for the version that will actually be used. -/\ntheorem ext' {χ χ' : MulChar R R'} (h : ∀ a, χ a = χ' a) : χ = χ' := DFunLike.ext _ _ h\n\ninstance : MulCharClass (MulChar R R') R R' where\n map_mul χ := χ.map_mul'\n map_one χ := χ.map_one'\n map_nonunit χ := χ.map_nonunit' _\n\ntheorem map_nonunit (χ : MulChar R R') {a : R} (ha : ¬IsUnit a) : χ a = 0 :=\n χ.map_nonunit' a ha\n\n/-- Extensionality. Since `MulChar`s always take the value zero on non-units, it is sufficient\nto compare the values on units. -/\n@[ext]\ntheorem ext {χ χ' : MulChar R R'} (h : ∀ a : Rˣ, χ a = χ' a) : χ = χ' := by\n apply ext'\n intro a\n by_cases ha : IsUnit a\n · exact h ha.unit\n · rw [map_nonunit χ ha, map_nonunit χ' ha]\n\n/-!\n### Equivalence of multiplicative characters with homomorphisms on units\n\nWe show that restriction / extension by zero gives an equivalence\nbetween `MulChar R R'` and `Rˣ →* R'ˣ`.\n-/\n\n\n/-- Turn a `MulChar` into a homomorphism between the unit groups. -/\ndef toUnitHom (χ : MulChar R R') : Rˣ →* R'ˣ :=\n Units.map χ\n\ntheorem coe_toUnitHom (χ : MulChar R R') (a : Rˣ) : ↑(χ.toUnitHom a) = χ a :=\n rfl\n\n/-- Turn a homomorphism between unit groups into a `MulChar`. -/\nnoncomputable def ofUnitHom (f : Rˣ →* R'ˣ) : MulChar R R' where\n toFun := by classical exact fun x => if hx : IsUnit x then f hx.unit else 0\n map_one' := by\n have h1 : (isUnit_one.unit : Rˣ) = 1 := Units.ext rfl\n simp only [h1, dif_pos, Units.val_eq_one, map_one, isUnit_one]\n map_mul' := by\n classical\n intro x y\n by_cases hx : IsUnit x\n · simp only [hx, IsUnit.mul_iff, true_and, dif_pos]\n by_cases hy : IsUnit y\n · simp only [hy, dif_pos]\n have hm : (hx.mul hy).unit = hx.unit * hy.unit := Units.ext rfl\n rw [hm, map_mul]\n norm_cast\n · simp only [hy, not_false_iff, dif_neg, mul_zero]\n · simp only [hx, IsUnit.mul_iff, false_and, not_false_iff, dif_neg, zero_mul]\n map_nonunit' := by\n intro a ha\n simp only [ha, not_false_iff, dif_neg]\n\nTarget:\ntheorem ofUnitHom_coe (f : Rˣ →* R'ˣ) (a : Rˣ) : ofUnitHom f ↑a = f a :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_025ea6bc4b68","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"e84abf2d4826b57d7c31314bc8a61ae12c1edbc63663b96256c0b83b490b9a53","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/MulChar","family_id":"ofunithom_coe","file_id":"mathlib/Mathlib/NumberTheory/MulChar/Basic.lean","sample_id":"025ea6bc4b689a5e0068ab86c471873a7cfcb310a85f88cab7a08a145748ff30"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"85696dea5504cd1164ffc3684a5e36e714466d554e3b0ae16af94b2f33819e59","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e3651abb98a9e4138a6fe48b841c7029c7c8d0f375ffa6c162d66151aae5632b","source_sha256":"4aa6d5f205e5da21fe6cb14e97e5791ceca9066a3371d5af97c468fa8d297973","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← smul_one_mul, mul_top']\n simp_rw [smul_eq_zero, or_iff_left one_ne_zero]","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.076923,"token_length_ratio":0.133333},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"e7bcce1209ca91caa519047372afaa3e6e8d5cc4eee82f7917514bb6b9382c01","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Module.Torsion.Field\npublic import Mathlib.Algebra.Order.AddTorsor\npublic import Mathlib.Data.ENNReal.Operations\n\nNamespace:\nENNReal\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov\n-/\n/-!\n# Scalar multiplication on `ℝ≥0∞`.\n\nThis file defines basic scalar actions on extended nonnegative reals, showing that\n`MulAction`s, `DistribMulAction`s, `Module`s and `Algebra`s restrict from `ℝ≥0∞` to `ℝ≥0`.\n-/\n\n@[expose] public section\n\nopen Set NNReal ENNReal\n\nnamespace ENNReal\n\nvariable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}\n\n-- TODO: generalize some of these to `WithTop α`\nsection Actions\n\nnoncomputable instance {M : Type*} [MulAction ℝ≥0∞ M] : SMul ℝ≥0 M :=\n ⟨fun c m ↦ (c : ℝ≥0∞) • m⟩\n\n/-- A `MulAction` over `ℝ≥0∞` restricts to a `MulAction` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [MulAction ℝ≥0∞ M] : MulAction ℝ≥0 M :=\n fast_instance% MulAction.compHom M ofNNRealHom.toMonoidHom\n\ntheorem smul_def {M : Type*} [MulAction ℝ≥0∞ M] (c : ℝ≥0) (x : M) : c • x = (c : ℝ≥0∞) • x :=\n rfl\n\n@[simp]\ntheorem smul_one (c : ℝ≥0) : c • (1 : ℝ≥0∞) = (c : ℝ≥0∞) := by simp [smul_def]\n\ninstance {M N : Type*} [MulAction ℝ≥0∞ M] [MulAction ℝ≥0∞ N] [SMul M N] [IsScalarTower ℝ≥0∞ M N] :\n IsScalarTower ℝ≥0 M N where smul_assoc r := smul_assoc (r : ℝ≥0∞)\n\ninstance smulCommClass_left {M N : Type*} [MulAction ℝ≥0∞ N] [SMul M N] [SMulCommClass ℝ≥0∞ M N] :\n SMulCommClass ℝ≥0 M N where smul_comm r := smul_comm (r : ℝ≥0∞)\n\ninstance smulCommClass_right {M N : Type*} [MulAction ℝ≥0∞ N] [SMul M N] [SMulCommClass M ℝ≥0∞ N] :\n SMulCommClass M ℝ≥0 N where smul_comm m r := smul_comm m (r : ℝ≥0∞)\n\n/-- A `DistribMulAction` over `ℝ≥0∞` restricts to a `DistribMulAction` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [AddMonoid M] [DistribMulAction ℝ≥0∞ M] :\n DistribMulAction ℝ≥0 M :=\n fast_instance% DistribMulAction.compHom M ofNNRealHom.toMonoidHom\n\n/-- A `Module` over `ℝ≥0∞` restricts to a `Module` over `ℝ≥0`. -/\nnoncomputable instance {M : Type*} [AddCommMonoid M] [Module ℝ≥0∞ M] : Module ℝ≥0 M :=\n fast_instance% Module.compHom M ofNNRealHom\n\n/-- An `Algebra` over `ℝ≥0∞` restricts to an `Algebra` over `ℝ≥0`. -/\nnoncomputable instance {A : Type*} [Semiring A] [Algebra ℝ≥0∞ A] : Algebra ℝ≥0 A where\n commutes' r x := by simp [Algebra.commutes]\n smul_def' r x := by simp [← Algebra.smul_def (r : ℝ≥0∞) x, smul_def]\n algebraMap := (algebraMap ℝ≥0∞ A).comp (ofNNRealHom : ℝ≥0 →+* ℝ≥0∞)\n\n-- verify that the above produces instances we might care about\nnoncomputable example : Algebra ℝ≥0 ℝ≥0∞ := inferInstance\n\nnoncomputable example : DistribMulAction ℝ≥0ˣ ℝ≥0∞ := inferInstance\n\ntheorem coe_smul {R} (r : R) (s : ℝ≥0) [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0]\n [IsScalarTower R ℝ≥0 ℝ≥0∞] : (↑(r • s) : ℝ≥0∞) = (r : R) • (s : ℝ≥0∞) := by\n rw [← smul_one_smul ℝ≥0 r (s : ℝ≥0∞), smul_def, smul_eq_mul, ← ENNReal.coe_mul, smul_mul_assoc,\n one_mul]\n\nTarget:\ntheorem smul_top {R : Type*} [Semiring R] [IsDomain R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]\n [Module.IsTorsionFree R ℝ≥0∞] [DecidableEq R] (c : R) :\n c • ∞ = if c = 0 then 0 else ∞ :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/ENNReal","family_id":"smul_top","file_id":"mathlib/Mathlib/Data/ENNReal/Action.lean","sample_id":"e3651abb98a9e4138a6fe48b841c7029c7c8d0f375ffa6c162d66151aae5632b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"86be2fb4446f54e9492e321be49c049da5cb8ccb99e4df8748bd638740696585","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"07be9a90b06d8ec37d49da0518163247b1a115abf6504b390d325f0cdfb15722","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e99e8d259642e35c0011d73c3322c31ff1685803fa550c31af3f59e41cc006c5","source_sha256":"67cc6b7ca466b4df61acd757fae3e65f0f6ce1aa35615c76c69b2b6131234dd3","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp_rw [isNilpotent_iff]\n refine exists_congr fun n ↦ ⟨fun h ↦ ?_, fun h ↦ ?_⟩\n · simp [← Subgroup.comap_top e.symm.toMonoidHom, ← h]\n · simp [← Subgroup.comap_top e.toMonoidHom, ← h]","hard_negative":true,"metrics":{"chosen_tokens":53,"rejected_tokens":5,"token_jaccard":0.071429,"token_length_ratio":0.09434},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"e8042d01e71bcd4398e79d62844869441b3d8cf0c957d155763c1400e0937133","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.GroupTheory.Solvable\npublic import Mathlib.GroupTheory.Sylow\npublic import Mathlib.Algebra.Group.Subgroup.Order\npublic import Mathlib.GroupTheory.Commutator.Finite\n\nNamespace:\nGroup\n\nLocal context:\n/-\nCopyright (c) 2021 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Ines Wright, Joachim Breitner\n-/\n/-!\n\n# Nilpotent groups\n\nAn API for nilpotent groups, that is, groups for which the upper central series\nreaches `⊤`.\n\n## Main definitions\n\nRecall that if `H K : Subgroup G` then `⁅H, K⁆ : Subgroup G` is the subgroup of `G` generated\nby the commutators `hkh⁻¹k⁻¹`. Recall also Lean's conventions that `⊤` denotes the\nsubgroup `G` of `G`, and `⊥` denotes the trivial subgroup `{1}`.\n\n* `Subgroup.upperCentralSeries G : ℕ → Subgroup G` : the upper central series of a group `G`.\n This is an increasing sequence of characteristic subgroups `H n` of `G` with `H 0 = ⊥` and\n `H (n + 1) / H n` is the centre of `G / H n`.\n* `Subgroup.lowerCentralSeries (S : Subgroup G) : ℕ → Subgroup G` : the lower central series of `S`,\n computed in the ambient group `G`. This is the iterated commutator\n `S, ⁅S, S⁆, ⁅⁅S, S⁆, S⁆, …`. The classical lower central series of `G` is the case\n `S = ⊤`.\n* `IsNilpotent` : A group G is nilpotent if its upper central series reaches `⊤`, or\n equivalently if its lower central series reaches `⊥`.\n* `Group.nilpotencyClass` : the length of the upper central series of a nilpotent group.\n* `IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop` and\n* `IsDescendingCentralSeries (H : ℕ → Subgroup G) : Prop` : Note that in the literature\n a \"central series\" for a group is usually defined to be a *finite* sequence of normal subgroups\n `H 0`, `H 1`, ..., starting at `⊤`, finishing at `⊥`, and with each `H n / H (n + 1)`\n central in `G / H (n + 1)`. In this formalisation it is convenient to have two weaker predicates\n on an infinite sequence of subgroups `H n` of `G`: we say a sequence is a *descending central\n series* if it starts at `G` and `⁅H n, ⊤⁆ ⊆ H (n + 1)` for all `n`. Note that this series\n may not terminate at `⊥`, and the `H i` need not be normal. Similarly a sequence is an\n *ascending central series* if `H 0 = ⊥` and `⁅H (n + 1), ⊤⁆ ⊆ H n` for all `n`, again with no\n requirement that the series reaches `⊤` or that the `H i` are normal.\n\n## Main theorems\n\n`G` is *defined* to be nilpotent if the upper central series reaches `⊤`.\n* `nilpotent_iff_finite_ascending_central_series` : `G` is nilpotent iff some ascending central\n series reaches `⊤`.\n* `nilpotent_iff_finite_descending_central_series` : `G` is nilpotent iff some descending central\n series reaches `⊥`.\n* `nilpotent_iff_lower` : `G` is nilpotent iff the lower central series reaches `⊥`.\n* The `Group.nilpotencyClass` can likewise be obtained from these equivalent\n definitions, see `least_ascending_central_series_length_eq_nilpotencyClass`,\n `least_descending_central_series_length_eq_nilpotencyClass` and\n `lowerCentralSeries_length_eq_nilpotencyClass`.\n* If `G` is nilpotent, then so are its subgroups, images, quotients and preimages.\n Binary and finite products of nilpotent groups are nilpotent.\n Infinite products are nilpotent if their nilpotent class is bounded.\n Corresponding lemmas about the `Group.nilpotencyClass` are provided.\n* The `Group.nilpotencyClass` of `G ⧸ center G` is given explicitly, and an induction principle\n is derived from that.\n* `IsNilpotent.to_isSolvable`: If `G` is nilpotent, it is solvable.\n\n\n## Warning\n\nA \"central series\" is usually defined to be a finite sequence of normal subgroups going\nfrom `⊥` to `⊤` with the property that each subquotient is contained within the centre of\nthe associated quotient of `G`. This means that if `G` is not nilpotent, then\nnone of what we have called `upperCentralSeries G`, `(⊤ : Subgroup G).lowerCentralSeries` or\nthe sequences satisfying `IsAscendingCentralSeries` or `IsDescendingCentralSeries`\nare actually central series. Note that the fact that the upper and lower central series\nare not central series if `G` is not nilpotent is a standard abuse of notation.\n\n-/\n\n@[expose] public section\n\n\nopen commutatorElement Subgroup\n\nsection WithGroup\n\nvariable {G : Type*} [Group G] (N : Subgroup G) [Normal N]\n\nnamespace Subgroup\n\n/-- If `N` is a normal subgroup of `G`, then the set `{x : G | ∀ y : G, x*y*x⁻¹*y⁻¹ ∈ N}`\nis a subgroup of `G` (because it is the preimage in `G` of the centre of the\nquotient group `G/N`.)\n-/\n@[to_additive /-- If `N` is a normal additive subgroup of `G`, then the set\n`{x : G | ∀ y : G, x + y -x - y ∈ N}` is an additive subgroup of `G`\n(because it is the preimage in `G` of the centre of the additive quotient group `G/N`.) -/]\ndef upperCentralSeriesStep : Subgroup G where\n carrier := { x : G | ∀ y : G, ⁅x, y⁆ ∈ N }\n one_mem' y := by simp\n mul_mem' {a b} ha hb y := by\n convert! Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1\n group\n inv_mem' {x} hx y := by\n specialize hx y⁻¹\n rw [commutatorElement_def, mul_assoc, inv_inv] at hx ⊢\n exact Subgroup.Normal.mem_comm inferInstance hx\n\n@[to_additive]\ntheorem mem_upperCentralSeriesStep (x : G) :\n x ∈ upperCentralSeriesStep N ↔ ∀ y, ⁅x, y⁆ ∈ N := Iff.rfl\n\nopen QuotientGroup\n\n/-- The proof that `upperCentralSeriesStep N` is the preimage of the centre of `G/N` under\nthe canonical surjection. -/\n@[to_additive /-- The proof that `upperCentralSeriesStep N` is the preimage of the centre of `G/N`\\\nunder the canonical surjection. -/]\ntheorem upperCentralSeriesStep_eq_comap_center :\n upperCentralSeriesStep N = Subgroup.comap (mk' N) (center (G ⧸ N)) := by\n ext\n rw [mem_comap, mem_center_iff, forall_mk]\n refine forall_congr' fun y => ?_\n rw [coe_mk', ← QuotientGroup.mk_mul, ← QuotientGroup.mk_mul, eq_comm, eq_iff_div_mem,\n div_eq_mul_inv, mul_inv_rev, commutatorElement_def]\n simp_rw [mul_assoc]\n\n@[to_additive]\ninstance [N.Characteristic] : Characteristic (upperCentralSeriesStep N) :=\n (upperCentralSeriesStep_eq_comap_center N) ▸ Characteristic.comap_quotient_mk centerCharacteristic\n\nvariable (G)\n\n/-- An auxiliary type-theoretic definition defining both the upper central series of\na group, and a proof that it is characteristic, all in one go. -/\ndef upperCentralSeriesAux : ℕ → Σ' H : Subgroup G, Characteristic H\n | 0 => ⟨⊥, inferInstance⟩\n | n + 1 =>\n let un := upperCentralSeriesAux n\n let _un_characteristic := un.2\n ⟨upperCentralSeriesStep un.1, inferInstance⟩\n\n/-- An auxiliary type-theoretic definition defining both the upper central series of\nan additive group, and a proof that it is characteristic, all in one go. -/\ndef _root_.AddSubgroup.upperCentralSeriesAux (G : Type*) [AddGroup G] :\n ℕ → Σ' H : AddSubgroup G, H.Characteristic\n | 0 => ⟨⊥, inferInstance⟩\n | n + 1 =>\n let un := upperCentralSeriesAux G n\n let _un_characteristic := un.2\n ⟨AddSubgroup.upperCentralSeriesStep un.1, inferInstance⟩\n\nattribute [to_additive existing] upperCentralSeriesAux\n\n/-- `upperCentralSeries G n` is the `n`th term in the upper central series of `G`.\n\nThis is the increasing chain of subgroups of `G` that starts with the trivial subgroup `⊥` of `G`\nand then continues defining `upperCentralSeries G (n + 1)` to be all the elements of `G`\nthat, modulo `upperCentralSeries G n`, belong to the center of the quotient\n`G ⧸ upperCentralSeries G n`.\n\nIn particular, the identities\n* `upperCentralSeries G 0 = ⊥` (`upperCentralSeries_zero`);\n* `upperCentralSeries G 1 = center G` (`upperCentralSeries_one`);\n\nhold.\n-/\n@[to_additive\n/-- `upperCentralSeries G n` is the `n`th term in the upper central series of `G`.\n\nThis is the increasing chain of additive subgroups of `G` that starts with the trivial additive\nsubgroup `⊥` of `G` and then continues defining `upperCentralSeries G (n + 1)` to be all the\nelements of `G` that, modulo `upperCentralSeries G n`, belong to the center of the additive quotient\n`G ⧸ upperCentralSeries G n`.\n\nIn particular, the identities\n* `upperCentralSeries G 0 = ⊥` (`upperCentralSeries_zero`);\n* `upperCentralSeries G 1 = center G` (`upperCentralSeries_one`);\n\nhold.\n-/]\ndef upperCentralSeries (n : ℕ) : Subgroup G :=\n (upperCentralSeriesAux G n).1\n\n@[to_additive]\ninstance (n : ℕ) : Characteristic (upperCentralSeries G n) :=\n (upperCentralSeriesAux G n).2\n\n@[to_additive (attr := simp)]\ntheorem upperCentralSeries_zero : upperCentralSeries G 0 = ⊥ := rfl\n\ntheorem upperCentralSeries_one : upperCentralSeries G 1 = center G := by\n ext\n simp only [upperCentralSeries, upperCentralSeriesAux, upperCentralSeriesStep, mem_bot, mem_mk,\n Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_setOf_eq, mem_center_iff]\n exact forall_congr' fun y => by\n rw [commutatorElement_def, mul_inv_eq_one, mul_inv_eq_iff_eq_mul, eq_comm]\n\ntheorem _root_.AddSubgroup.upperCentralSeries_one (G : Type*) [AddGroup G] :\n AddSubgroup.upperCentralSeries G 1 = AddSubgroup.center G := by\n ext\n simp only [AddSubgroup.upperCentralSeries, AddSubgroup.upperCentralSeriesAux,\n AddSubgroup.upperCentralSeriesStep, AddSubgroup.mem_bot, AddSubgroup.mem_mk,\n AddSubmonoid.mem_mk, AddSubsemigroup.mem_mk, Set.mem_setOf_eq, AddSubgroup.mem_center_iff]\n exact forall_congr' fun y => by\n rw [addCommutatorElement_def, add_neg_eq_zero, add_neg_eq_iff_eq_add, eq_comm]\n\nattribute [to_additive existing (attr := simp) AddSubgroup.upperCentralSeries_one]\n upperCentralSeries_one\n\nvariable {G}\n\n/-- The `n+1`st term of the upper central series `H i` has underlying set equal to the `x` such\nthat `⁅x,G⁆ ⊆ H n`. -/\n@[to_additive /-- The `n+1`st term of the upper central series `H i` has underlying set equal to\nthe `x` such that `⁅x,G⁆ ⊆ H n`. -/]\ntheorem mem_upperCentralSeries_succ_iff {n : ℕ} {x : G} :\n x ∈ upperCentralSeries G (n + 1) ↔ ∀ y : G, ⁅x, y⁆ ∈ upperCentralSeries G n :=\n Iff.rfl\n\n@[to_additive (attr := simp)]\nlemma comap_upperCentralSeries {H : Type*} [Group H] (e : H ≃* G) :\n ∀ n, (upperCentralSeries G n).comap e = upperCentralSeries H n\n | 0 => by simpa [MonoidHom.ker_eq_bot_iff] using e.injective\n | n + 1 => by\n ext\n simp [mem_upperCentralSeries_succ_iff, ← comap_upperCentralSeries e n,\n ← e.toEquiv.forall_congr_right, commutatorElement_def]\n\nend Subgroup\n\nnamespace Group\n\nvariable (G) in\n-- `IsNilpotent` is already defined in the root namespace (for elements of rings).\n-- TODO: Rename it to `IsNilpotentElement`?\n/-- A group `G` is nilpotent if its upper central series is eventually `G`. -/\n@[mk_iff, wikidata Q1755242]\nclass IsNilpotent (G : Type*) [Group G] : Prop where\n nilpotent' : ∃ n : ℕ, upperCentralSeries G n = ⊤\n\nvariable (G) in\n-- `IsNilpotent` is already defined in the root namespace (for elements of rings).\n-- TODO: Rename it to `IsNilpotentElement`?\n/-- An additive group `G` is nilpotent if its upper central series is eventually `G`. -/\n@[mk_iff]\nclass _root_.AddGroup.IsNilpotent (G : Type*) [AddGroup G] : Prop where\n nilpotent' : ∃ n : ℕ, AddSubgroup.upperCentralSeries G n = ⊤\n\n@[to_additive]\nlemma IsNilpotent.nilpotent (G : Type*) [Group G] [IsNilpotent G] :\n ∃ n : ℕ, upperCentralSeries G n = ⊤ := Group.IsNilpotent.nilpotent'\n\n@[to_additive]\n\nTarget:\nlemma isNilpotent_congr {H : Type*} [Group H] (e : G ≃* H) : IsNilpotent G ↔ IsNilpotent H :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_e99e8d259642","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a8e53df7e27fccc5318520e8e3d677456aaec733fba0a1183850d41aa19a77c4","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"GroupTheory","family_id":"isnilpotent_congr","file_id":"mathlib/Mathlib/GroupTheory/Nilpotent.lean","sample_id":"e99e8d259642e35c0011d73c3322c31ff1685803fa550c31af3f59e41cc006c5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ca0ece37f538648c8bd2cc3bd8b01496760c6e681882d406aa385f8c498005e3","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"eb310185b074f550bff288c99580fd028bc862bf0f605e8e1959380efe9e96cf","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ae55631f784367385dffe461cfa2e1835f933b3727a81e9f4fdd21cf0578608c","source_sha256":"665254822d507fb5efa98cde8b21daf33fea93a04c746a97b8407d629ce02c74","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [projectiveFamilyFun_congr hP (empty_mem_measurableCylinders α) (cylinder_empty ∅).symm\n MeasurableSet.empty, measure_empty]","hard_negative":true,"metrics":{"chosen_tokens":21,"rejected_tokens":2,"token_jaccard":0.052632,"token_length_ratio":0.095238},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"e86e92f77de52fc34e44cc55097e223aa2fd56587cc60cd62ce1cc1df7c7b911","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.MeasureTheory.Constructions.Projective\npublic import Mathlib.MeasureTheory.Measure.AddContent\npublic import Mathlib.MeasureTheory.SetAlgebra\n\nNamespace:\nMeasureTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne, Peter Pfaffelhuber\n-/\n/-!\n# Additive content built from a projective family of measures\n\nLet `P` be a projective family of measures on a family of measurable spaces indexed by `ι`.\nThat is, for each finite set `I` of indices, `P I` is a measure on `Π j : I, α j`, and for `J ⊆ I`,\nthe projection from `Π i : I, α i` to `Π i : J, α i` maps `P I` to `P J`.\n\nWe build an additive content `projectiveFamilyContent` on the measurable cylinders, by setting\n`projectiveFamilyContent s = P I S` for `s = cylinder I S`, where `I` is a finite set of indices\nand `S` is a measurable set in `Π i : I, α i`.\n\nThis content will be used to define the projective limit of the family of measures `P`.\nFor a countable index set and a projective family given by a sequence of kernels,\nthe projective limit is given by the Ionescu-Tulcea theorem.\nFor an arbitrary index set but under topological conditions on the spaces, this is the result of\nthe Kolmogorov extension theorem.\n(both results are not yet in Mathlib)\n\n## Main definitions\n\n* `projectiveFamilyContent`: additive content on the measurable cylinders, defined from a projective\n family of measures.\n\n-/\n\n@[expose] public section\n\n\nopen Finset\n\nopen scoped ENNReal\n\nnamespace MeasureTheory\n\nvariable {ι : Type*} {α : ι → Type*} {mα : ∀ i, MeasurableSpace (α i)}\n {P : ∀ J : Finset ι, Measure (Π j : J, α j)} {s t : Set (Π i, α i)} {I : Finset ι}\n {S : Set (Π i : I, α i)}\n\nsection MeasurableCylinders\n\nlemma isSetAlgebra_measurableCylinders : IsSetAlgebra (measurableCylinders α) where\n empty_mem := empty_mem_measurableCylinders α\n compl_mem _ := compl_mem_measurableCylinders\n union_mem _ _ := union_mem_measurableCylinders\n\nlemma isSetRing_measurableCylinders : IsSetRing (measurableCylinders α) :=\n isSetAlgebra_measurableCylinders.isSetRing\n\nlemma isSetSemiring_measurableCylinders : MeasureTheory.IsSetSemiring (measurableCylinders α) :=\n isSetRing_measurableCylinders.isSetSemiring\n\nend MeasurableCylinders\n\nsection ProjectiveFamilyFun\n\nopen Classical in\n/-- For `P` a family of measures, with `P J` a measure on `Π j : J, α j`, we define a function\n`projectiveFamilyFun P s` by setting it to `P I S` if `s = cylinder I S` for a measurable `S` and\nto 0 if `s` is not a measurable cylinder. -/\nnoncomputable def projectiveFamilyFun (P : ∀ J : Finset ι, Measure (Π j : J, α j))\n (s : Set (Π i, α i)) : ℝ≥0∞ :=\n if hs : s ∈ measurableCylinders α\n then P (measurableCylinders.finset hs) (measurableCylinders.set hs) else 0\n\nlemma projectiveFamilyFun_congr (hP : IsProjectiveMeasureFamily P)\n (hs : s ∈ measurableCylinders α) (hs_eq : s = cylinder I S) (hS : MeasurableSet S) :\n projectiveFamilyFun P s = P I S := by\n rw [projectiveFamilyFun, dif_pos hs]\n exact hP.congr_cylinder (measurableCylinders.measurableSet hs) hS\n ((measurableCylinders.eq_cylinder hs).symm.trans hs_eq)\n\nTarget:\nlemma projectiveFamilyFun_empty (hP : IsProjectiveMeasureFamily P) :\n projectiveFamilyFun P ∅ = 0 :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_ae55631f7843","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"4165fc033d4280371924e928b953a1650f01fe7800fa89b7c4ea1110ebda9659","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/Constructions","family_id":"projectivefamilyfun_empty","file_id":"mathlib/Mathlib/MeasureTheory/Constructions/ProjectiveFamilyContent.lean","sample_id":"ae55631f784367385dffe461cfa2e1835f933b3727a81e9f4fdd21cf0578608c"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"ebc48890c3ae78ed36c04e75d23bfb79cdc9858a1639886a8e7520e88c2a6dbf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"975f2393856df943a6b8c869594b08cc9e3a6df82aca394df0da942bc9b864e2","source_sha256":"3fa27d4724df81d3aa4e7bd288a473172f238ad50a2de2c3cbb8ac8e2dec37a9","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [jacobiSum, MulChar.ringHomComp, MulChar.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk,\n map_sum, map_mul]","hard_negative":true,"metrics":{"chosen_tokens":26,"rejected_tokens":8,"token_jaccard":0.047619,"token_length_ratio":0.307692},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"e94c785cd9509ce62bcf5989361339f69378c82df68aa4944d9222f718799b6d","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.GaussSum\npublic import Mathlib.NumberTheory.MulChar.Lemmas\npublic import Mathlib.RingTheory.RootsOfUnity.Lemmas\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Jacobi Sums\n\nThis file defines the *Jacobi sum* of two multiplicative characters `χ` and `ψ` on a finite\ncommutative ring `R` with values in another commutative ring `R'`:\n\n`jacobiSum χ ψ = ∑ x : R, χ x * ψ (1 - x)`\n\n(see `jacobiSum`) and provides some basic results and API lemmas on Jacobi sums.\n\n## References\n\nWe essentially follow\n* [K. Ireland, M. Rosen, *A classical introduction to modern number theory*\n (Section 8.3)][IrelandRosen1990]\n\nbut generalize where appropriate.\n\nThis is based on Lean code written as part of the bachelor's thesis of Alexander Spahl.\n-/\n\n@[expose] public section\n\nopen Finset\n\n/-!\n### Jacobi sums: definition and first properties\n-/\n\nsection Def\n\n-- need `Fintype` instead of `Finite` to make `jacobiSum` computable.\nvariable {R R' : Type*} [CommRing R] [Fintype R] [CommRing R']\n\n/-- The *Jacobi sum* of two multiplicative characters on a finite commutative ring. -/\ndef jacobiSum (χ ψ : MulChar R R') : R' :=\n ∑ x : R, χ x * ψ (1 - x)\n\nlemma jacobiSum_comm (χ ψ : MulChar R R') : jacobiSum χ ψ = jacobiSum ψ χ := by\n simp only [jacobiSum, mul_comm (χ _)]\n rw [← (Equiv.subLeft 1).sum_comp]\n simp only [Equiv.subLeft_apply, sub_sub_cancel]\n\n/-- The Jacobi sum is compatible with ring homomorphisms. -/\n\nTarget:\nlemma jacobiSum_ringHomComp {R'' : Type*} [CommRing R''] (χ ψ : MulChar R R') (f : R' →+* R'') :\n jacobiSum (χ.ringHomComp f) (ψ.ringHomComp f) = f (jacobiSum χ ψ) :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"03f3997188fba72a3ce246b30d282ca6552f722fad5c67109722c6e88d867730","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/JacobiSum","family_id":"jacobisum_ringhomcomp","file_id":"mathlib/Mathlib/NumberTheory/JacobiSum/Basic.lean","sample_id":"975f2393856df943a6b8c869594b08cc9e3a6df82aca394df0da942bc9b864e2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"691b1fefb19774703ba0da236f43d75a9d1f0b1c59002daa309bfac351b1f1b9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ee502198e79361b3769a06efad05a3a0e0dd1865e81dfbf05f149da4db4bf55e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c90c23334e026050c80f802c56492155a41fc40ab2e2d1bfb4570af88050ded5","source_sha256":"976709af1494098e2290d3c3a6a052dad499a43ec44c3bd6016d3ce147bb9165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using map_add_zsmul f 0 n","hard_negative":true,"metrics":{"chosen_tokens":7,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.428571},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"eae729259acda2b30d5b9f237302b0c2120fa1ae74989812e37f193547ef1dbe","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Algebra.Module.NatInt\npublic import Mathlib.Algebra.Order.Archimedean.Basic\nimport Mathlib.Algebra.Order.Group.Basic\n\nNamespace:\nAddConstMapClass\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Maps (semi)conjugating a shift to a shift\n\nDenote by $S^1$ the unit circle `UnitAddCircle`.\nA common way to study a self-map $f\\colon S^1\\to S^1$ of degree `1`\nis to lift it to a map $\\tilde f\\colon \\mathbb R\\to \\mathbb R$\nsuch that $\\tilde f(x + 1) = \\tilde f(x)+1$ for all `x`.\n\nIn this file we define a structure and a typeclass\nfor bundled maps satisfying `f (x + a) = f x + b`.\n\nWe use parameters `a` and `b` instead of `1` to accommodate for two use cases:\n\n- maps between circles of different lengths;\n- self-maps $f\\colon S^1\\to S^1$ of degree other than one,\n including orientation-reversing maps.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nopen Function Set\n\n/-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`,\ndenoted as `f : G →+c[a, b] H`.\n\nOne can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/\nstructure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where\n /-- The underlying function of an `AddConstMap`.\n Use automatic coercion to function instead. -/\n protected toFun : G → H\n /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/\n map_add_const' (x : G) : toFun (x + a) = toFun x + b\n\n@[inherit_doc]\nscoped[AddConstMap] notation:25 G \" →+c[\" a \", \" b \"] \" H => AddConstMap G H a b\n\n/-- Typeclass for maps satisfying `f (x + a) = f x + b`.\n\nNote that `a` and `b` are `outParam`s,\nso one should not add instances like\n`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/\nclass AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]\n (a : outParam G) (b : outParam H) [FunLike F G H] : Prop where\n /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:\n `∀ x, f (x + a) = f x + b`. -/\n map_add_const (f : F) (x : G) : f (x + a) = f x + b\n\nnamespace AddConstMapClass\n\n/-!\n### Properties of `AddConstMapClass` maps\n\nIn this section we prove properties like `f (x + n • a) = f x + n • b`.\n-/\n\nscoped[AddConstMapClass] attribute [simp] map_add_const\n\nvariable {F G H : Type*} [FunLike F G H] {a : G} {b : H}\n\nprotected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n Semiconj f (· + a) (· + b) :=\n map_add_const f\n\n@[scoped simp]\ntheorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by\n simpa using (AddConstMapClass.semiconj f).iterate_right n x\n\n@[scoped simp]\ntheorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul]\n\ntheorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x\n\n@[scoped simp]\ntheorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + (ofNat(n) : ℕ) • b :=\n map_add_nat' f x n\n\ntheorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp\n\ntheorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n\n\n@[scoped simp]\ntheorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n f a = f 0 + b := by\n simpa using map_add_const f 0\n\ntheorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) :\n f 1 = f 0 + b :=\n map_const f\n\n@[scoped simp]\ntheorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (n : ℕ) : f (n • a) = f 0 + n • b := by\n simpa using map_add_nsmul f 0 n\n\n@[scoped simp]\ntheorem map_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) : f n = f 0 + n • b := by\n simpa using map_add_nat' f 0 n\n\ntheorem map_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) [n.AtLeastTwo] :\n f (ofNat(n)) = f 0 + (ofNat(n) : ℕ) • b :=\n map_nat' f n\n\ntheorem map_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) : f n = f 0 + n := by simp\n\ntheorem map_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) [n.AtLeastTwo] :\n f ofNat(n) = f 0 + ofNat(n) := map_nat f n\n\n@[scoped simp]\ntheorem map_const_add [AddCommMagma G] [Add H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : f (a + x) = f x + b := by\n rw [add_comm, map_add_const]\n\ntheorem map_one_add [AddCommMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (1 + x) = f x + b := map_const_add f x\n\n@[scoped simp]\ntheorem map_nsmul_add [AddCommMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (n : ℕ) (x : G) : f (n • a + x) = f x + n • b := by\n rw [add_comm, map_add_nsmul]\n\n@[scoped simp]\ntheorem map_nat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n • b := by\n simpa using map_nsmul_add f n x\n\ntheorem map_ofNat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :\n f (ofNat(n) + x) = f x + ofNat(n) • b :=\n map_nat_add' f n x\n\ntheorem map_nat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n := by simp\n\ntheorem map_ofNat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :\n f (ofNat(n) + x) = f x + ofNat(n) :=\n map_nat_add f n x\n\n@[scoped simp]\ntheorem map_sub_nsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x - n • a) = f x - n • b := by\n conv_rhs => rw [← sub_add_cancel x (n • a), map_add_nsmul, add_sub_cancel_right]\n\n@[scoped simp]\ntheorem map_sub_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : f (x - a) = f x - b := by\n simpa using map_sub_nsmul f x 1\n\ntheorem map_sub_one [AddGroup G] [One G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x - 1) = f x - b :=\n map_sub_const f x\n\n@[scoped simp]\ntheorem map_sub_nat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x - n) = f x - n • b := by\n simpa using map_sub_nsmul f x n\n\n@[scoped simp]\ntheorem map_sub_ofNat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x - ofNat(n)) = f x - ofNat(n) • b :=\n map_sub_nat' f x n\n\n@[scoped simp]\ntheorem map_add_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : ∀ n : ℤ, f (x + n • a) = f x + n • b\n | (n : ℕ) => by simp\n | .negSucc n => by simp [← sub_eq_add_neg]\n\n@[scoped simp]\n\nTarget:\ntheorem map_zsmul_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (n : ℤ) : f (n • a) = f 0 + n • b :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_c90c23334e02","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"ede164d68d7936a6810793952cfc2f4ecfe0280c2ece39d307715b7cf874a994","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/AddConstMap","family_id":"map_zsmul_const","file_id":"mathlib/Mathlib/Algebra/AddConstMap/Basic.lean","sample_id":"c90c23334e026050c80f802c56492155a41fc40ab2e2d1bfb4570af88050ded5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"02cbebe28206c613191b8a691427b5b0241913279e5e25084b9c45a100c81f6e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"fd37d260edc2e62962b9aa0b900afa7fc08d4528ed6173fa9f800544f89b9f2f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b8d84457ed5626a8763dcffe3d0369c2c9e378c1b1bc236062b7f6bdd4789af1","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [mul', lift_comp_comm_eq]","hard_negative":true,"metrics":{"chosen_tokens":7,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.428571},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"eafd4ee74d18811a9583c6a537b46a0530669a0a57c5d266335e0dc59f850c8b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x := by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective\n\ntheorem toSpanSingleton_one_eq_algebraLinearMap :\n toSpanSingleton R A 1 = Algebra.linearMap R A := by ext; simp\n\n@[deprecated (since := \"2025-12-30\")] alias toSpanSingleton_eq_algebra_linearMap :=\n toSpanSingleton_one_eq_algebraLinearMap\n\nvariable (R A) in\n/-- The multiplication map on an `R`-algebra, as an `A`-linear map from `A ⊗[R] A` to `A`. -/\n@[simps!] def mul'' : A ⊗[R] A →ₗ[A] A where\n __ := mul' R A\n map_smul' a x := x.induction_on (by simp) (by simp +contextual [mul', smul_tmul', mul_assoc])\n (by simp +contextual [mul_add])\n\nend Semiring\n\nsection CommSemiring\n-- TODO: Generalise to `NonUnitalNonAssocCommSemiring`. This can't currently be done\n-- because there is no instance **to** `NonUnitalNonAssocCommSemiring`.\nvariable [CommSemiring R] [NonUnitalCommSemiring A]\n [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]\n\n@[simp] lemma flip_mul : (mul R A).flip = mul R A := by ext; simp [mul_comm]\n\nTarget:\nlemma mul'_comp_comm : mul' R A ∘ₗ TensorProduct.comm R A A = mul' R A :=\n\nProof body:\n","rejected":"by\n exact mul'_comp_comm","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"6839961ed8cfe20dcb301d056b32672e7e45613b080934210441670b8136579c","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"mul'_comp_comm","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"b8d84457ed5626a8763dcffe3d0369c2c9e378c1b1bc236062b7f6bdd4789af1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"319f6ac955e575559439fedf3cac20ae9eb65063681438ffd25e13bb38098f66","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"740e5b4e77128b04b71b3b4978c0507a9c180b9a1765f1d450102f9709a92c61","source_sha256":"d3537788b47974177b54c7d51489ff341785d6598c87247ef75965ad61b95597","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨(V : SetRel X X), hV, hVsymm, hVU⟩ := symm_of_uniformity U_uni\n have uni_ite := dynEntourage_mem_uniformity h hV n\n let openCover x := ball x (dynEntourage T V n)\n obtain ⟨s, _, s_cover⟩ := F_comp.elim_nhds_subcover openCover fun x _ ↦ ball_mem_nhds x uni_ite\n exact ⟨s, .of_entourage_subset hVU <| .of_subset_iUnion_ball s_cover⟩","hard_negative":false,"metrics":{"chosen_tokens":72,"rejected_tokens":3,"token_jaccard":0.046512,"token_length_ratio":0.041667},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"ebc7fb0514a5c7cee2a1d9c2584804bf0b92b9e535a2c07859b71e5f883815e8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.Asymptotics.ExpGrowth\npublic import Mathlib.Data.ENat.Lattice\npublic import Mathlib.Dynamics.TopologicalEntropy.DynamicalEntourage\n\nNamespace:\nDynamics\n\nLocal context:\n/-\nCopyright (c) 2024 Damien Thomine. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Damien Thomine, Pietro Monticone\n-/\n/-!\n# Topological entropy via covers\nWe implement Bowen-Dinaburg's definitions of the topological entropy, via covers.\n\nAll is stated in the vocabulary of uniform spaces. For compact spaces, the uniform structure\nis canonical, so the topological entropy depends only on the topological structure. This will give\na clean proof that the topological entropy is a topological invariant of the dynamics.\n\nA notable choice is that we define the topological entropy of a subset `F` of the whole space.\nUsually, one defines the entropy of an invariant subset `F` as the entropy of the restriction of the\ntransformation to `F`. We avoid the latter definition as it would involve frequent manipulation of\nsubtypes. Our version directly gives a meaning to the topological entropy of a subsystem, and a\nsingle theorem (`subset_restriction_entropy` in `TopologicalEntropy.Semiconj`) will give the\nequivalence between both versions.\n\nAnother choice is to give a meaning to the entropy of `∅` (it must be `-∞` to stay coherent) and to\nkeep the possibility for the entropy to be infinite. Hence, the entropy takes values in the extended\nreals `[-∞, +∞]`. The consequence is that we use `ℕ∞`, `ℝ≥0∞` and `EReal` numbers.\n\n## Main definitions\n- `IsDynCoverOf`: property that dynamical balls centered on a subset `s` cover a subset `F`.\n- `coverMincard`: minimal cardinality of a dynamical cover. Takes values in `ℕ∞`.\n- `coverEntropyInfEntourage`/`coverEntropyEntourage`: exponential growth of `coverMincard`.\n The former is defined with a `liminf`, the later with a `limsup`. Take values in `EReal`.\n- `coverEntropyInf`/`coverEntropy`: supremum of `coverEntropyInfEntourage`/`coverEntropyEntourage`\n over all entourages (or limit as the entourages go to the diagonal). These are Bowen-Dinaburg's\n versions of the topological entropy with covers. Take values in `EReal`.\n\n## Implementation notes\nThere are two competing definitions of topological entropy in this file: one uses a `liminf`,\nthe other a `limsup`. These two topological entropies are equal as soon as they are applied to an\ninvariant subset by theorem `coverEntropyInf_eq_coverEntropy`. We choose the default definition\nto be the definition using a `limsup`, and give it the simpler name `coverEntropy` (instead of\n`coverEntropySup`). Theorems about the topological entropy of invariant subsets will be stated\nusing only `coverEntropy`.\n\n## Main results\n- `IsDynCoverOf.iterate_le_pow`: given a dynamical cover at time `n`, creates dynamical covers\n at all iterates `n * m` with controlled cardinality.\n- `IsDynCoverOf.coverEntropyEntourage_le_log_card_div`: upper bound on `coverEntropyEntourage`\n given any dynamical cover.\n- `coverEntropyInf_eq_coverEntropy`: equality between the notions of topological entropy defined\n with a `liminf` and a `limsup`.\n\n## Tags\ncover, entropy\n\n## TODO\nGet versions of the topological entropy on (pseudo-e)metric spaces.\n-/\n\n@[expose] public section\n\nopen Set SetRel Uniformity UniformSpace\nopen scoped Finset\n\nnamespace Dynamics\n\nvariable {X : Type*} {T : X → X} {U V : SetRel X X} {n : ℕ} {F s : Set X} {m n : ℕ}\n\n/-! ### Dynamical covers -/\n\n/-- Given a subset `F`, an entourage `U` and an integer `n`, a subset `s` is a `(U, n)`-\ndynamical cover of `F` if any orbit of length `n` in `F` is `U`-shadowed by an orbit of length `n`\nof a point in `s`. -/\ndef IsDynCoverOf (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) (s : Set X) : Prop :=\n IsCover (dynEntourage T U n) F s\n\nlemma IsDynCoverOf.of_le (m_n : m ≤ n) (h : IsDynCoverOf T F U n s) : IsDynCoverOf T F U m s :=\n h.mono_entourage <| by gcongr\n\nlemma IsDynCoverOf.of_entourage_subset (U_V : U ⊆ V) (h : IsDynCoverOf T F U n s) :\n IsDynCoverOf T F V n s := h.mono_entourage <| by gcongr\n\n@[simp] lemma isDynCoverOf_empty : IsDynCoverOf T ∅ U n s := .empty\n\n@[simp] lemma isDynCoverOf_empty_right : IsDynCoverOf T F U n ∅ ↔ F = ∅ := by simp [IsDynCoverOf]\n\nnonrec lemma IsDynCoverOf.nonempty (h : F.Nonempty) (h' : IsDynCoverOf T F U n s) : s.Nonempty :=\n h'.nonempty h\n\nlemma isDynCoverOf_zero (T : X → X) (F : Set X) (U : SetRel X X) (h : s.Nonempty) :\n IsDynCoverOf T F U 0 s := by simp [IsDynCoverOf, h]\n\nlemma isDynCoverOf_univ (T : X → X) (F : Set X) (n : ℕ) (h : s.Nonempty) :\n IsDynCoverOf T F univ n s := by simp [IsDynCoverOf, h]\n\nlemma IsDynCoverOf.nonempty_inter [U.IsSymm] {s : Finset X} (h : IsDynCoverOf T F U n s) :\n ∃ t : Finset X, IsDynCoverOf T F U n t ∧ #t ≤ #s ∧\n ∀ x ∈ t, (ball x (dynEntourage T U n) ∩ F).Nonempty := by\n classical\n use {x ∈ s | (ball x (dynEntourage T U n) ∩ F).Nonempty}\n simp only [Finset.coe_filter, Finset.mem_filter, and_imp, imp_self, implies_true, and_true]\n refine ⟨fun y y_F ↦ ?_, Finset.card_mono (Finset.filter_subset _ s)⟩\n obtain ⟨z, z_s, y_Bz⟩ := h y_F\n exact ⟨z, ⟨z_s, _, (dynEntourage T U n).symm y_Bz, y_F⟩, y_Bz⟩\n\n/-- From a dynamical cover `s` with entourage `U` and time `m`, we construct covers with entourage\n`U ○ U` and any multiple `m * n` of `m` with controlled cardinality. This lemma is the first step\nin a submultiplicative-like property of `coverMincard`, with consequences such as explicit bounds\nfor the topological entropy (`coverEntropyInfEntourage_le_card_div`) and an equality between\ntwo notions of topological entropy (`coverEntropyInf_eq_coverEntropySup_of_inv`). -/\nlemma IsDynCoverOf.iterate_le_pow (F_inv : MapsTo T F F) [U.IsSymm] (n : ℕ) {s : Finset X}\n (h : IsDynCoverOf T F U m s) :\n ∃ t : Finset X, IsDynCoverOf T F (U ○ U) (m * n) t ∧ t.card ≤ s.card ^ n := by\n classical\n -- Deal with the edge cases: `F = ∅` or `m = 0`.\n rcases F.eq_empty_or_nonempty with rfl | F_nemp\n · exact ⟨∅, by simp⟩\n have _ : Nonempty X := F_nemp.nonempty\n have s_nemp := h.nonempty F_nemp\n obtain ⟨x, x_F⟩ := F_nemp\n rcases m.eq_zero_or_pos with rfl | m_pos\n · use {x}\n simp only [zero_mul, Finset.coe_singleton, Finset.card_singleton]\n exact ⟨isDynCoverOf_zero T F (U ○ U) (singleton_nonempty x),\n one_le_pow_of_one_le' (Nat.one_le_of_lt (Finset.Nonempty.card_pos s_nemp)) n⟩\n -- The proof goes as follows. Given an orbit of length `(m * n)` starting from `y`, each of its\n -- iterates `y`, `T^[m] y`, `T^[m]^[2] y` ... is `(dynEntourage T U m)`-close to a point of `s`.\n -- Conversely, given a sequence `t 0`, `t 1`, `t 2` of points in `s`, we choose a point\n -- `z = dyncover t` such that `z`, `T^[m] z`, `T^[m]^[2] z` ... are `(dynEntourage T U m)`-close\n -- to `t 0`, `t 1`, `t 2`... Then `y`, `T^[m] y`, `T^[m]^[2] y` ... are\n -- `(dynEntourage T (U ○ U) m)`-close to `z`, `T^[m] z`, `T^[m]^[2] z`, so that the union of such\n -- `z` provides the desired cover. Since there are at most `s.card ^ n` sequences of\n -- length `n` with values in `s`, we get the upper bound we want on the cardinality.\n -- First step: construct `dyncover`. Given `t 0`, `t 1`, `t 2`, if we cannot find such a point\n -- `dyncover t`, we use the dummy `x`.\n have (t : Fin n → s) : ∃ y : X, (⋂ k : Fin n, T^[m * k] ⁻¹' ball (t k) (dynEntourage T U m)) ⊆\n ball y (dynEntourage T (U ○ U) (m * n)) := by\n rcases (⋂ k : Fin n, T^[m * k] ⁻¹' ball (t k) (dynEntourage T U m)).eq_empty_or_nonempty\n with inter_empt | inter_nemp\n · exact inter_empt ▸ ⟨x, empty_subset _⟩\n · obtain ⟨y, y_int⟩ := inter_nemp\n refine ⟨y, fun z z_int ↦ ?_⟩\n simp only [ball, dynEntourage, Prod.map_iterate, mem_iInter, Set.mem_preimage, Prod.map_apply,\n mem_comp] at y_int z_int ⊢\n intro k k_mn\n replace k_mn := Nat.div_lt_of_lt_mul k_mn\n specialize z_int ⟨(k / m), k_mn⟩ (k % m) (Nat.mod_lt k m_pos)\n specialize y_int ⟨(k / m), k_mn⟩ (k % m) (Nat.mod_lt k m_pos)\n rw [← Function.iterate_add_apply T (k % m) (m * (k / m)), Nat.mod_add_div k m] at y_int z_int\n exact mem_comp_of_mem_ball y_int z_int\n choose! dyncover h_dyncover using this\n -- The cover we want is the set of all `dyncover t`, that is, `range dyncover`. We need to check\n -- that it is indeed a `(U ○ U, m * n)` cover, and that its cardinality is at most `card s ^ n`.\n -- Only the first point requires significant work.\n let sn := range dyncover\n refine ⟨sn.toFinset, ?_, ?_⟩\n · -- We implement the argument at the beginning: given `y ∈ F`, we extract `t 0`, `t 1`, `t 2`\n -- such that `y`, `T^[m] y`, `T^[m]^[2] y` ... is `(dynEntourage T U m)`-close to `t 0`, `t 1`,\n -- `t 2`... Then `dyncover t` is a point of `range dyncover` which satisfies the conclusion\n -- of the lemma.\n rw [Finset.coe_nonempty] at s_nemp\n have _ : Nonempty s := Finset.Nonempty.coe_sort s_nemp\n intro y y_F\n have key : ∀ k : Fin n, ∃ z : s, y ∈ T^[m * k] ⁻¹' ball z (dynEntourage T U m) := by\n intro k\n have := h (MapsTo.iterate F_inv (m * k) y_F)\n simp only [Finset.mem_coe] at this\n obtain ⟨z, z_s, hz⟩ := this\n exact ⟨⟨z, z_s⟩, (dynEntourage T U m).symm hz⟩\n choose! t ht using key\n simp only [toFinset_range, Finset.coe_image, Finset.coe_univ, image_univ, mem_range,\n exists_exists_eq_and, sn]\n refine ⟨t, (dynEntourage T (U ○ U) (m * n)).symm <| h_dyncover t <| by simpa using ht⟩\n · rw [toFinset_card]\n apply (Fintype.card_range_le dyncover).trans\n simp only [Fintype.card_fun, Fintype.card_coe, Fintype.card_fin, le_refl]\n\nTarget:\nlemma exists_isDynCoverOf_of_isCompact_uniformContinuous [UniformSpace X]\n (F_comp : IsCompact F) (h : UniformContinuous T) (U_uni : U ∈ 𝓤 X) (n : ℕ) :\n ∃ s : Finset X, IsDynCoverOf T F U n s :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Dynamics/TopologicalEntropy","family_id":"exists_isdyncoverof_of_iscompact_uniformcontinuous","file_id":"mathlib/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean","sample_id":"740e5b4e77128b04b71b3b4978c0507a9c180b9a1765f1d450102f9709a92c61"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fc7ffae2f05d47d1966ca2bf59252faf9200a6b414ba1d76553ef9f66ce51aa8","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"d2338a2956990285c4b90f7d38eb52ecb58a3cbbfa36ca3381040ede51b4b97d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6b0182816ab85d12002a58a45fa6c14113456d5c2543da4146daa190ecc6530f","source_sha256":"d98c949bc540d9d1f0da4b83503468df3afb83ea6b2904bc8e06fc7ecb85d421","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [totallySeparatedSpace_iff, IsTotallySeparated, Set.Pairwise, mem_univ, true_implies]\n refine forall₃_congr fun x y _ ↦\n ⟨fun ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ ↦ ?_, fun ⟨U, hU, Ux, Ucy⟩ ↦ ?_⟩\n · exact ⟨U, isClopen_of_disjoint_cover_open f hU hV disj,\n Ux, fun Uy ↦ Set.disjoint_iff.mp disj ⟨Uy, Vy⟩⟩\n · exact ⟨U, Uᶜ, hU.2, hU.compl.2, Ux, Ucy, (Set.union_compl_self U).ge, disjoint_compl_right⟩","hard_negative":false,"metrics":{"chosen_tokens":123,"rejected_tokens":128,"token_jaccard":0.90566,"token_length_ratio":1.04065},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"ebe7208788e791811830f058d15ea190bb546dba2a3e9d333f6ede7ea4b51edb","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Connected.Clopen\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Patrick Massot, Yury Kudryashov\n-/\n/-!\n# Totally disconnected and totally separated topological spaces\n\n## Main definitions\nWe define the following properties for sets in a topological space:\n\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 both of these definitions, we also have a class stating that the whole space\nsatisfies that property: `TotallyDisconnectedSpace`, `TotallySeparatedSpace`.\n-/\n\n@[expose] public section\n\nopen Function Set Topology\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v} {ι : Type*} {X : ι → Type*} [TopologicalSpace α]\n {s t u v : Set α}\n\nsection TotallyDisconnected\n\n/-- A set `s` is called totally disconnected if every subset `t ⊆ s` which is preconnected is\na subsingleton, i.e. either empty or a singleton. -/\ndef IsTotallyDisconnected (s : Set α) : Prop :=\n ∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton\n\ntheorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ =>\n (ht x_in).elim\n\ntheorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ =>\n subsingleton_singleton.anti ht\n\n/-- A space is totally disconnected if all of its connected components are singletons. -/\n@[mk_iff]\nclass TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where\n /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/\n isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α)\n\ntheorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α}\n (h : IsPreconnected s) : s.Subsingleton :=\n TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h\n\n-- note: making this an instance breaks downstream files\ntheorem subsingleton_of_preconnected_totallyDisconnected\n [PreconnectedSpace α] [TotallyDisconnectedSpace α] : Subsingleton α :=\n Set.subsingleton_of_univ_subsingleton isPreconnected_univ.subsingleton\n\ninstance Pi.totallyDisconnectedSpace {α : Type*} {β : α → Type*}\n [∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] :\n TotallyDisconnectedSpace (∀ a : α, β a) :=\n ⟨fun t _ h2 =>\n have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a =>\n h2.image (fun x => x a) (continuous_apply a).continuousOn\n fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩\n\ninstance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α]\n [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) :=\n ⟨fun t _ h2 =>\n have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn\n have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn\n fun x hx y hy =>\n Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)\n (H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩\n\ninstance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] :\n TotallyDisconnectedSpace (α ⊕ β) := by\n refine ⟨fun s _ hs => ?_⟩\n obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs\n · exact ht.subsingleton.image _\n · exact ht.subsingleton.image _\n\ninstance [∀ i, TopologicalSpace (X i)] [∀ i, TotallyDisconnectedSpace (X i)] :\n TotallyDisconnectedSpace (Σ i, X i) := by\n refine ⟨fun s _ hs => ?_⟩\n obtain rfl | h := s.eq_empty_or_nonempty\n · exact subsingleton_empty\n · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩\n exact ht.isPreconnected.subsingleton.image _\n\n/-- A space is totally disconnected iff its connected components are subsingletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_subsingleton :\n TotallyDisconnectedSpace α ↔ ∀ x : α, (connectedComponent x).Subsingleton := by\n constructor\n · intro h x\n apply h.1\n · exact subset_univ _\n exact isPreconnected_connectedComponent\n intro h; constructor\n intro s s_sub hs\n rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩)\n · exact subsingleton_empty\n · exact (h x).anti (hs.subset_connectedComponent x_in)\n\n/-- A space is totally disconnected iff its connected components are singletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_singleton :\n TotallyDisconnectedSpace α ↔ ∀ x : α, connectedComponent x = {x} := by\n rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton]\n refine forall_congr' fun x => ?_\n rw [subsingleton_iff_singleton]\n exact mem_connectedComponent\n\n@[simp] theorem connectedComponent_eq_singleton [TotallyDisconnectedSpace α] (x : α) :\n connectedComponent x = {x} :=\n totallyDisconnectedSpace_iff_connectedComponent_singleton.1 ‹_› x\n\n/-- The image of a connected component in a totally disconnected space is a singleton. -/\n@[simp]\ntheorem Continuous.image_connectedComponent_eq_singleton {β : Type*} [TopologicalSpace β]\n [TotallyDisconnectedSpace β] {f : α → β} (h : Continuous f) (a : α) :\n f '' connectedComponent a = {f a} :=\n (Set.subsingleton_iff_singleton <| mem_image_of_mem f mem_connectedComponent).mp\n (isPreconnected_connectedComponent.image f h.continuousOn).subsingleton\n\ntheorem isTotallyDisconnected_of_totallyDisconnectedSpace [TotallyDisconnectedSpace α] (s : Set α) :\n IsTotallyDisconnected s := fun t _ ht =>\n TotallyDisconnectedSpace.isTotallyDisconnected_univ _ t.subset_univ ht\n\nlemma TotallyDisconnectedSpace.eq_of_continuous [TopologicalSpace β]\n [PreconnectedSpace α] [TotallyDisconnectedSpace β] (f : α → β) (hf : Continuous f)\n (i j : α) : f i = f j :=\n (isPreconnected_univ.image f hf.continuousOn).subsingleton ⟨i, trivial, rfl⟩ ⟨j, trivial, rfl⟩\n\n/-- The bijection `C(X, Y) ≃ Y` when `Y` is totally disconnected and `X` is connected. -/\n@[simps! symm_apply_apply]\nnoncomputable def TotallyDisconnectedSpace.continuousMapEquivOfConnectedSpace\n (X Y : Type*) [TopologicalSpace X]\n [TopologicalSpace Y] [TotallyDisconnectedSpace Y] [ConnectedSpace X] :\n C(X, Y) ≃ Y where\n toFun f := f (Classical.arbitrary _)\n invFun y := ⟨fun _ ↦ y, by fun_prop⟩\n left_inv f := ContinuousMap.ext (TotallyDisconnectedSpace.eq_of_continuous _ f.2 _)\n right_inv _ := rfl\n\ntheorem isTotallyDisconnected_of_image [TopologicalSpace β] {f : α → β} (hf : ContinuousOn f s)\n (hf' : Injective f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n fun _t hts ht _x x_in _y y_in =>\n hf' <|\n h _ (image_mono hts) (ht.image f <| hf.mono hts) (mem_image_of_mem f x_in)\n (mem_image_of_mem f y_in)\n\nlemma Topology.IsEmbedding.isTotallyDisconnected [TopologicalSpace β] {f : α → β} {s : Set α}\n (hf : IsEmbedding f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n isTotallyDisconnected_of_image hf.continuous.continuousOn hf.injective h\n\nlemma Topology.IsEmbedding.isTotallyDisconnected_image [TopologicalSpace β] {f : α → β} {s : Set α}\n (hf : IsEmbedding f) : IsTotallyDisconnected (f '' s) ↔ IsTotallyDisconnected s := by\n refine ⟨hf.isTotallyDisconnected, fun hs u hus hu ↦ ?_⟩\n obtain ⟨v, hvs, rfl⟩ : ∃ v, v ⊆ s ∧ f '' v = u :=\n ⟨f ⁻¹' u ∩ s, inter_subset_right, by rwa [image_preimage_inter, inter_eq_left]⟩\n rw [hf.isInducing.isPreconnected_image] at hu\n exact (hs v hvs hu).image _\n\nlemma Topology.IsEmbedding.isTotallyDisconnected_range [TopologicalSpace β] {f : α → β}\n (hf : IsEmbedding f) : IsTotallyDisconnected (range f) ↔ TotallyDisconnectedSpace α := by\n rw [totallyDisconnectedSpace_iff, ← image_univ, hf.isTotallyDisconnected_image]\n\nlemma totallyDisconnectedSpace_subtype_iff {s : Set α} :\n TotallyDisconnectedSpace s ↔ IsTotallyDisconnected s := by\n rw [← IsEmbedding.subtypeVal.isTotallyDisconnected_range, Subtype.range_val]\n\ninstance Subtype.totallyDisconnectedSpace {α : Type*} {p : α → Prop} [TopologicalSpace α]\n [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Subtype p) :=\n totallyDisconnectedSpace_subtype_iff.2 (isTotallyDisconnected_of_totallyDisconnectedSpace _)\n\ninstance [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Additive α) :=\n ‹TotallyDisconnectedSpace α›\n\ninstance [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Multiplicative α) :=\n ‹TotallyDisconnectedSpace α›\n\nend TotallyDisconnected\n\nsection TotallySeparated\n\n/-- A set `s` is called totally separated if any two points of this set can be separated\nby two disjoint open sets covering `s`. -/\ndef IsTotallySeparated (s : Set α) : Prop :=\n Set.Pairwise s fun x y =>\n ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ s ⊆ u ∪ v ∧ Disjoint u v\n\ntheorem isTotallySeparated_empty : IsTotallySeparated (∅ : Set α) := fun _ => False.elim\n\ntheorem isTotallySeparated_singleton {x} : IsTotallySeparated ({x} : Set α) := fun _ hp _ hq hpq =>\n (hpq <| (eq_of_mem_singleton hp).symm ▸ (eq_of_mem_singleton hq).symm).elim\n\ntheorem isTotallyDisconnected_of_isTotallySeparated {s : Set α} (H : IsTotallySeparated s) :\n IsTotallyDisconnected s := by\n intro t hts ht x x_in y y_in\n by_contra h\n obtain\n ⟨u : Set α, v : Set α, hu : IsOpen u, hv : IsOpen v, hxu : x ∈ u, hyv : y ∈ v, hs : s ⊆ u ∪ v,\n huv⟩ :=\n H (hts x_in) (hts y_in) h\n refine (ht _ _ hu hv (hts.trans hs) ⟨x, x_in, hxu⟩ ⟨y, y_in, hyv⟩).ne_empty ?_\n rw [huv.inter_eq, inter_empty]\n\nalias IsTotallySeparated.isTotallyDisconnected := isTotallyDisconnected_of_isTotallySeparated\n\n/-- A space is totally separated if any two points can be separated by two disjoint open sets\ncovering the whole space. -/\n@[mk_iff] class TotallySeparatedSpace (α : Type u) [TopologicalSpace α] : Prop where\n /-- The universal set `Set.univ` in a totally separated space is totally separated. -/\n isTotallySeparated_univ : IsTotallySeparated (univ : Set α)\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.totallyDisconnectedSpace (α : Type u)\n [TopologicalSpace α] [TotallySeparatedSpace α] : TotallyDisconnectedSpace α :=\n ⟨TotallySeparatedSpace.isTotallySeparated_univ.isTotallyDisconnected⟩\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.of_discrete (α : Type*) [TopologicalSpace α]\n [DiscreteTopology α] : TotallySeparatedSpace α :=\n ⟨fun _ _ b _ h => ⟨{b}ᶜ, {b}, isOpen_discrete _, isOpen_discrete _, h, rfl,\n (compl_union_self _).symm.subset, disjoint_compl_left⟩⟩\n\nTarget:\ntheorem totallySeparatedSpace_iff_exists_isClopen {α : Type*} [TopologicalSpace α] :\n TotallySeparatedSpace α ↔ Pairwise (∃ U : Set α, IsClopen U ∧ · ∈ U ∧ · ∈ Uᶜ) :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n simp only [totallySeparatedSpace_iff, IsTotallySeparated, Set.Pairwise, mem_univ, true_implies]\n refine forall₃_congr fun x y _ ↦\n ⟨fun ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ ↦ ?_, fun ⟨U, hU, Ux, Ucy⟩ ↦ ?_⟩\n · exact ⟨U, isClopen_of_disjoint_cover_open f hU hV disj,\n Ux, fun Uy ↦ Set.disjoint_iff.mp disj ⟨Uy, Vy⟩⟩\n · exact ⟨U, Uᶜ, hU.2, hU.compl.2, Ux, Ucy, (Set.union_compl_self U).ge, disjoint_compl_right⟩","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/Connected","family_id":"totallyseparatedspace_iff_exists_isclopen","file_id":"mathlib/Mathlib/Topology/Connected/TotallyDisconnected.lean","sample_id":"6b0182816ab85d12002a58a45fa6c14113456d5c2543da4146daa190ecc6530f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"9a597798e23027467755033b7c532f49bb048325c5a4361045132a050119c42b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5d467fb78e02ded44ff4047d7e7478d6be98a7efd087aec2adadbfaee301e006","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"baf09fd31930da8436e42cdf5076d03d01ed740f4b890b2663390ab1a5e552e7","source_sha256":"554896e06372c48698215f4d70f9de2025a1d3d47dcc6253d5e671f520e21386","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [avgRisk, ← Measure.lintegral_compProd (f := fun θy ↦ ℓ θy.1 θy.2) (by fun_prop)]\n congr\n calc π ⊗ₘ (κ ∘ₖ P) = (Kernel.id ∥ₖ κ) ∘ₘ (π ⊗ₘ P) := Measure.parallelComp_comp_compProd.symm\n _ = (Kernel.id ∥ₖ κ) ∘ₘ ((P†π) ×ₖ Kernel.id) ∘ₘ P ∘ₘ π := by rw [posterior_prod_id_comp]\n _ = ((P†π) ×ₖ κ) ∘ₘ P ∘ₘ π := by\n rw [Measure.comp_assoc, Kernel.parallelComp_comp_prod, Kernel.id_comp, Kernel.comp_id]","hard_negative":false,"metrics":{"chosen_tokens":139,"rejected_tokens":143,"token_jaccard":0.9375,"token_length_ratio":1.028777},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"ec481d2111f6b9bf170256c166f64e68e586592f573fb7619215928cf9e7a124","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Decision.Risk.Defs\npublic import Mathlib.Probability.Kernel.Posterior\nimport Mathlib.Probability.Decision.Risk.Basic\n\nNamespace:\nProbabilityTheory\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne, Lorenzo Luccioli\n-/\n/-!\n# Bayes estimator\n\nLet `Θ` be a parameter space, `𝓧` a data space, `𝓨` a prediction space, `P : Kernel Θ 𝓧` a\ndata generating kernel, `π` a prior on the parameter space, and `ℓ : Θ → 𝓨 → ℝ≥0∞` a loss function.\n\nAn estimator (a `Kernel 𝓧 𝓨`) is said to be a Bayes estimator if it attains the Bayes risk for\nthe estimation problem.\nIt can be written as a measurable function `x ↦ argmin_y P†π(x)[θ ↦ ℓ θ y]`\nfor `(P ∘ₘ π)`-almost every `x`, where `P†π` is the posterior kernel, whenever we can select\nthe argmin in a measurable way.\n\n## Main definitions\n\n* `IsBayesEstimator`: an estimator is a Bayes estimator if it attains the Bayes risk for the prior.\n* `IsArgminEstimator`: a measurable function `f : 𝓧 → 𝓨` is an argmin estimator\n if for `(P ∘ₘ π)`-almost every `x` the value `f x` belongs to `argmin_y P†π(x)[θ ↦ ℓ θ y]`.\n* `HasArgminEstimator`: the estimation problem admits an argmin estimator.\n That is, we can choose the argmin of the posterior expected loss in a measurable way.\n\n## Main statements\n\n* `lintegral_iInf_posterior_le_bayesRisk`: the Bayes risk with respect to a prior is bounded\n from below by the integral over the data (with distribution `P ∘ₘ π`) of the infimum over the\n possible predictions `y` of the posterior loss `∫⁻ θ, ℓ θ y ∂((P†π) x)`:\n `∫⁻ x, ⨅ y : 𝓨, ∫⁻ θ, ℓ θ y ∂((P†π) x) ∂(P ∘ₘ π) ≤ bayesRisk ℓ P π`\n* `IsArgminEstimator.isBayesEstimator`: an argmin Bayes estimator is a Bayes estimator.\n That is, it minimizes the Bayesian risk.\n* `bayesRisk_eq_of_hasArgminEstimator`: if the estimation problem admits an argmin estimator,\n then the Bayesian risk attains the risk lower bound `∫⁻ x, ⨅ y, ∫⁻ θ, ℓ θ y ∂(P†π) x ∂(P ∘ₘ π)`.\n\n## TODO\n\nOnce Mathlib has measurable selection theorems, we will be able to prove `HasArgminEstimator` under\ngeneral conditions on the measurable spaces `𝓧` and/or `𝓨`.\n\n-/\n\n@[expose] public section\n\nopen MeasureTheory\nopen scoped ENNReal NNReal\n\nnamespace ProbabilityTheory\n\nvariable {Θ 𝓧 𝓨 : Type*} {mΘ : MeasurableSpace Θ} {m𝓧 : MeasurableSpace 𝓧} {m𝓨 : MeasurableSpace 𝓨}\n {ℓ : Θ → 𝓨 → ℝ≥0∞} {P : Kernel Θ 𝓧} {κ : Kernel 𝓧 𝓨} {π : Measure Θ}\n\nsection Posterior\n\nvariable [StandardBorelSpace Θ] [Nonempty Θ]\n\n/-- The average risk of an estimator `κ` with respect to a prior `π` can be expressed as\nan integral in the following way: `R_π(κ) = ((P†π × κ) ∘ P ∘ π)[(θ, y) ↦ ℓ θ y]`. -/\n\nTarget:\nlemma avgRisk_eq_lintegral_posterior_prod\n (hl : Measurable (Function.uncurry ℓ)) (P : Kernel Θ 𝓧) [IsFiniteKernel P]\n (κ : Kernel 𝓧 𝓨) [IsSFiniteKernel κ] (π : Measure Θ) [IsFiniteMeasure π] :\n avgRisk ℓ P κ π = ∫⁻ θy, ℓ θy.1 θy.2 ∂(((P†π) ×ₖ κ) ∘ₘ (P ∘ₘ π)) :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [avgRisk, ← Measure.lintegral_compProd (f := fun θy ↦ ℓ θy.1 θy.2) (by fun_prop)]\n congr\n calc π ⊗ₘ (κ ∘ₖ P) = (Kernel.id ∥ₖ κ) ∘ₘ (π ⊗ₘ P) := Measure.parallelComp_comp_compProd.symm\n _ = (Kernel.id ∥ₖ κ) ∘ₘ ((P†π) ×ₖ Kernel.id) ∘ₘ P ∘ₘ π := by rw [posterior_prod_id_comp]\n _ = ((P†π) ×ₖ κ) ∘ₘ P ∘ₘ π := by\n rw [Measure.comp_assoc, Kernel.parallelComp_comp_prod, Kernel.id_comp, Kernel.comp_id]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Decision","family_id":"avgrisk_eq_lintegral_posterior_prod","file_id":"mathlib/Mathlib/Probability/Decision/BayesEstimator.lean","sample_id":"baf09fd31930da8436e42cdf5076d03d01ed740f4b890b2663390ab1a5e552e7"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"dd1601ad60125ec24e550b2694b504c419cd4b1f3ae173271e54395b0bb23c45","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"be5246747d188a717354e58da8c65abdc2b54dcfd2235f64bde4f40db2e270de","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"75086fd7bc4840e9a5faef44b6f920c1488a21e796312c9d358a9ed15d88136f","source_sha256":"39c30fd995f1c9f0b8e74b8d494ee14295763c6d290c46b81af97a15d6bc3764","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [divInt_eq_div, cast_div, cast_intCast]","hard_negative":false,"metrics":{"chosen_tokens":10,"rejected_tokens":14,"token_jaccard":0.692308,"token_length_ratio":1.4},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"ecf1928244a3c53d69ee6c560f7ceb1a8bf5099335eb1eaada8bcc50ce4ed558","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.GroupWithZero.Units.Lemmas\npublic import Mathlib.Data.Rat.Cast.Defs\n\nNamespace:\nRat\n\nLocal context:\n/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n/-!\n# Casts of rational numbers into characteristic zero fields (or division rings).\n-/\n\n@[expose] public section\n\nopen Function\n\nvariable {F ι α β : Type*}\n\nnamespace Rat\nvariable [DivisionRing α] [CharZero α] {p q : ℚ}\n\n@[stacks 09FR \"Characteristic zero case.\"]\nlemma cast_injective : Injective ((↑) : ℚ → α)\n | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩, h => by\n have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0\n have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0\n rw [mk_eq_divInt, mk_eq_divInt] at h ⊢\n rw [cast_divInt_of_ne_zero _ (by simpa), cast_divInt_of_ne_zero _ (by simpa)] at h\n norm_cast at h\n rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq,\n ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_natCast d₁,\n ← Int.cast_mul, ← Int.cast_natCast d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0]\n at h\n\n@[simp, norm_cast] lemma cast_inj : (p : α) = q ↔ p = q := cast_injective.eq_iff\n\n@[simp, norm_cast] lemma cast_eq_zero : (p : α) = 0 ↔ p = 0 := cast_injective.eq_iff' cast_zero\nlemma cast_ne_zero : (p : α) ≠ 0 ↔ p ≠ 0 := cast_eq_zero.ne\n\n@[simp, norm_cast] lemma cast_add (p q : ℚ) : ↑(p + q) = (p + q : α) :=\n cast_add_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_sub (p q : ℚ) : ↑(p - q) = (p - q : α) :=\n cast_sub_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\n@[simp, norm_cast] lemma cast_mul (p q : ℚ) : ↑(p * q) = (p * q : α) :=\n cast_mul_of_ne_zero (Nat.cast_ne_zero.2 p.pos.ne') (Nat.cast_ne_zero.2 q.pos.ne')\n\nvariable (α) in\n/-- Coercion `ℚ → α` as a `RingHom`. -/\ndef castHom : ℚ →+* α where\n toFun := (↑)\n map_one' := cast_one\n map_mul' := cast_mul\n map_zero' := cast_zero\n map_add' := cast_add\n\n@[simp] lemma coe_castHom : ⇑(castHom α) = ((↑) : ℚ → α) := rfl\n\n@[simp, norm_cast] lemma cast_inv (p : ℚ) : ↑(p⁻¹) = (p⁻¹ : α) := map_inv₀ (castHom α) _\n@[simp, norm_cast] lemma cast_div (p q : ℚ) : ↑(p / q) = (p / q : α) := map_div₀ (castHom α) ..\n\n@[simp, norm_cast]\nlemma cast_zpow (p : ℚ) (n : ℤ) : ↑(p ^ n) = (p ^ n : α) := map_zpow₀ (castHom α) ..\n\n@[norm_cast]\n\nTarget:\ntheorem cast_divInt (a b : ℤ) : (a /. b : α) = a / b :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n simp only [divInt_eq_div, cast_div, cast_intCast]","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Data/Rat","family_id":"cast_divint","file_id":"mathlib/Mathlib/Data/Rat/Cast/CharZero.lean","sample_id":"75086fd7bc4840e9a5faef44b6f920c1488a21e796312c9d358a9ed15d88136f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1f66f63cfdbcd2444e0f4e89907aec65e5445cb49f773bf2c2befba0b4b40f14","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e97ba48f8121881421b3500b68856ac7102c032733d54751cdad817ffe39bd7f","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rfl","hard_negative":false,"metrics":{"chosen_tokens":2,"rejected_tokens":2,"token_jaccard":0.333333,"token_length_ratio":1.0},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"ee6288af9d8e1d0615f056641a071eaba332fe18b44322c78311a5a2a9f200c6","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\n\nTarget:\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"mk_coe","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"e97ba48f8121881421b3500b68856ac7102c032733d54751cdad817ffe39bd7f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"977d78234735bfa5d4d34b3bd8d433f93c7fb84667b44174c0e1307b6298157b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c1d8adcd1dc14fbe13ce66f52a3923797e65f8ed46f53c24f6fa8d7484a01062","source_sha256":"b1a6de0bf7dd13eb86b75cd8d95aebb591d157a9fea40ceef9dbefb4524b23ba","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : finrank (ResidueField R) (CotangentSpace R) = 1 ↔\n finrank (ResidueField R) (CotangentSpace R) ≤ 1 := by\n simp [Nat.le_one_iff_eq_zero_or_eq_one, finrank_cotangentSpace_eq_zero_iff, h]\n rw [this]\n have : maximalIdeal R ≠ ⊥ := isField_iff_maximalIdeal_eq.not.mp h\n convert! tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R\n · exact ⟨fun _ ↦ inferInstance, fun h ↦ { h with not_a_field' := this }⟩\n · exact ⟨fun h P h₁ h₂ ↦ h.unique ⟨h₁, h₂⟩ ⟨this, inferInstance⟩,\n fun H ↦ ⟨_, ⟨this, inferInstance⟩, fun P hP ↦ H P hP.1 hP.2⟩⟩\n\nvariable {R}","hard_negative":false,"metrics":{"chosen_tokens":135,"rejected_tokens":3,"token_jaccard":0.036364,"token_length_ratio":0.022222},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"eecc284961f129c52456949404cbe374c594eadedf504bda1a3813d07e6a3577","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.DedekindDomain.Basic\npublic import Mathlib.RingTheory.DiscreteValuationRing.Basic\npublic import Mathlib.RingTheory.Finiteness.Ideal\npublic import Mathlib.RingTheory.Ideal.Cotangent\npublic import Mathlib.RingTheory.KrullDimension.Zero\n\nNamespace:\n(root)\n\nLocal context:\n/-\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/-!\n\n# Equivalent conditions for DVR\n\nIn `IsDiscreteValuationRing.TFAE`, we show that the following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n- `R` is a discrete valuation ring\n- `R` is a valuation ring\n- `R` is a Dedekind domain\n- `R` is integrally closed with a unique prime ideal\n- `m` is principal\n- `dimₖ m/m² = 1`\n- Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\npublic section\n\n\nvariable (R : Type*) [CommRing R]\n\nopen scoped Multiplicative\n\nopen IsLocalRing Module\n\ntheorem exists_maximalIdeal_pow_eq_of_principal [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h' : (maximalIdeal R).IsPrincipal) (I : Ideal R) (hI : I ≠ ⊥) :\n ∃ n : ℕ, I = maximalIdeal R ^ n := by\n by_cases h : IsField R\n · let _ := h.toField\n exact ⟨0, by simp [(eq_bot_or_eq_top I).resolve_left hI]⟩\n classical\n obtain ⟨x, hx : _ = Ideal.span _⟩ := h'\n by_cases hI' : I = ⊤\n · use 0; rw [pow_zero, hI', Ideal.one_eq_top]\n have H : ∀ r : R, ¬IsUnit r ↔ x ∣ r := fun r =>\n (SetLike.ext_iff.mp hx r).trans Ideal.mem_span_singleton\n have : x ≠ 0 := by\n rintro rfl\n apply Ring.ne_bot_of_isMaximal_of_not_isField (maximalIdeal.isMaximal R) h\n simp [hx]\n have hx' := IsDiscreteValuationRing.irreducible_of_span_eq_maximalIdeal x this hx\n have H' : ∀ r : R, r ≠ 0 → r ∈ nonunits R → ∃ n : ℕ, Associated (x ^ n) r := by\n intro r hr₁ hr₂\n obtain ⟨f, hf₁, rfl, hf₂⟩ := (WfDvdMonoid.not_unit_iff_exists_factors_eq r hr₁).mp hr₂\n have : ∀ b ∈ f, Associated x b := by\n intro b hb\n exact Irreducible.associated_of_dvd hx' (hf₁ b hb) ((H b).mp (hf₁ b hb).1)\n clear hr₁ hr₂ hf₁\n induction f using Multiset.induction with\n | empty => exact (hf₂ rfl).elim\n | cons fa fs fh => ?_\n rcases eq_or_ne fs ∅ with (rfl | hf')\n · use 1\n rw [pow_one, Multiset.prod_cons, Multiset.empty_eq_zero, Multiset.prod_zero, mul_one]\n exact this _ (Multiset.mem_cons_self _ _)\n · obtain ⟨n, hn⟩ := fh hf' fun b hb => this _ (Multiset.mem_cons_of_mem hb)\n use n + 1\n rw [pow_add, Multiset.prod_cons, mul_comm, pow_one]\n exact Associated.mul_mul (this _ (Multiset.mem_cons_self _ _)) hn\n have : ∃ n : ℕ, x ^ n ∈ I := by\n obtain ⟨r, hr₁, hr₂⟩ : ∃ r : R, r ∈ I ∧ r ≠ 0 := by\n by_contra! h; apply hI; rw [eq_bot_iff]; exact h\n obtain ⟨n, u, rfl⟩ := H' r hr₂ (le_maximalIdeal hI' hr₁)\n use n\n rwa [← I.unit_mul_mem_iff_mem u.isUnit, mul_comm]\n use Nat.find this\n apply le_antisymm\n · change ∀ s ∈ I, s ∈ _\n by_contra! ⟨s, hs₁, hs₂⟩\n apply hs₂\n by_cases hs₃ : s = 0; · rw [hs₃]; exact zero_mem _\n obtain ⟨n, u, rfl⟩ := H' s hs₃ (le_maximalIdeal hI' hs₁)\n rw [mul_comm, Ideal.unit_mul_mem_iff_mem _ u.isUnit] at hs₁ ⊢\n apply Ideal.pow_le_pow_right (Nat.find_min' this hs₁)\n apply Ideal.pow_mem_pow\n exact (H _).mpr (dvd_refl _)\n · rw [hx, Ideal.span_singleton_pow, Ideal.span_le, Set.singleton_subset_iff]\n exact Nat.find_spec this\n\ntheorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDedekindDomain R] :\n (maximalIdeal R).IsPrincipal := by\n classical\n by_cases ne_bot : maximalIdeal R = ⊥\n · rw [ne_bot]; infer_instance\n obtain ⟨a, ha₁, ha₂⟩ : ∃ a ∈ maximalIdeal R, a ≠ (0 : R) := by\n by_contra! h'; apply ne_bot; rwa [eq_bot_iff]\n have hle : Ideal.span {a} ≤ maximalIdeal R := by rwa [Ideal.span_le, Set.singleton_subset_iff]\n have : (Ideal.span {a}).radical = maximalIdeal R := by\n rw [Ideal.radical_eq_sInf]\n apply le_antisymm\n · exact sInf_le ⟨hle, inferInstance⟩\n · refine\n le_sInf fun I hI =>\n (eq_maximalIdeal <| hI.2.isMaximal (fun e => ha₂ ?_)).ge\n rw [← Ideal.span_singleton_eq_bot, eq_bot_iff, ← e]; exact hI.1\n have : ∃ n, maximalIdeal R ^ n ≤ Ideal.span {a} := by\n rw [← this]; apply Ideal.exists_radical_pow_le_of_fg; exact IsNoetherian.noetherian _\n rcases hn : Nat.find this with - | n\n · have := Nat.find_spec this\n rw [hn, pow_zero, Ideal.one_eq_top] at this\n exact (Ideal.IsMaximal.ne_top inferInstance (eq_top_iff.mpr <| this.trans hle)).elim\n obtain ⟨b, hb₁, hb₂⟩ : ∃ b ∈ maximalIdeal R ^ n, b ∉ Ideal.span {a} := by\n by_contra! h'; rw [Nat.find_eq_iff] at hn; exact hn.2 n n.lt_succ_self fun x hx => h' x hx\n have hb₃ : ∀ m ∈ maximalIdeal R, ∃ k : R, k * a = b * m := by\n intro m hm; rw [← Ideal.mem_span_singleton']; apply Nat.find_spec this\n rw [hn, pow_succ]; exact Ideal.mul_mem_mul hb₁ hm\n have hb₄ : b ≠ 0 := by rintro rfl; apply hb₂; exact zero_mem _\n let K := FractionRing R\n let x : K := algebraMap R K b / algebraMap R K a\n let M := Submodule.map (Algebra.linearMap R K) (maximalIdeal R)\n have ha₃ : algebraMap R K a ≠ 0 := IsFractionRing.to_map_eq_zero_iff.not.mpr ha₂\n by_cases hx : ∀ y ∈ M, x * y ∈ M\n · have := isIntegral_of_smul_mem_submodule M ?_ ?_ x hx\n · obtain ⟨y, e⟩ := IsIntegrallyClosed.algebraMap_eq_of_integral this\n refine (hb₂ (Ideal.mem_span_singleton'.mpr ⟨y, ?_⟩)).elim\n apply IsFractionRing.injective R K\n rw [map_mul, e, div_mul_cancel₀ _ ha₃]\n · rw [Submodule.ne_bot_iff]; refine ⟨_, ⟨a, ha₁, rfl⟩, ?_⟩\n exact (IsFractionRing.to_map_eq_zero_iff (K := K)).not.mpr ha₂\n · apply Submodule.FG.map; exact IsNoetherian.noetherian _\n · have :\n (M.map (DistribSMul.toLinearMap R K x)).comap (Algebra.linearMap R K) = ⊤ := by\n contrapose! hx with h\n rintro m' ⟨m, hm, rfl : algebraMap R K m = m'⟩\n obtain ⟨k, hk⟩ := hb₃ m hm\n have hk' : x * algebraMap R K m = algebraMap R K k := by\n rw [← mul_div_right_comm, ← map_mul, ← hk, map_mul, mul_div_cancel_right₀ _ ha₃]\n exact ⟨k, le_maximalIdeal h ⟨_, ⟨_, hm, rfl⟩, hk'⟩, hk'.symm⟩\n obtain ⟨y, hy₁, hy₂⟩ : ∃ y ∈ maximalIdeal R, b * y = a := by\n rw [Ideal.eq_top_iff_one, Submodule.mem_comap] at this\n obtain ⟨_, ⟨y, hy, rfl⟩, hy' : x * algebraMap R K y = algebraMap R K 1⟩ := this\n rw [map_one, ← mul_div_right_comm, div_eq_one_iff_eq ha₃, ← map_mul] at hy'\n exact ⟨y, hy, IsFractionRing.injective R K hy'⟩\n refine ⟨⟨y, ?_⟩⟩\n apply le_antisymm\n · intro m hm; obtain ⟨k, hk⟩ := hb₃ m hm; rw [← hy₂, mul_comm, mul_assoc] at hk\n rw [← mul_left_cancel₀ hb₄ hk, mul_comm]; exact Ideal.mem_span_singleton'.mpr ⟨_, rfl⟩\n · rwa [Submodule.span_le, Set.singleton_subset_iff]\n\n/--\nLet `(R, m, k)` be a Noetherian local domain (possibly a field).\nThe following are equivalent:\n0. `R` is a PID\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with at most one non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² ≤ 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `IsDiscreteValuationRing.TFAE` for a version assuming `¬ IsField R`.\n-/\ntheorem tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain\n [IsNoetherianRing R] [IsLocalRing R] [IsDomain R] :\n List.TFAE\n [IsPrincipalIdealRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∀ P : Ideal R, P ≠ ⊥ → P.IsPrime → P = maximalIdeal R,\n (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) ≤ 1,\n ∀ I ≠ ⊥, ∃ n : ℕ, I = maximalIdeal R ^ n] := by\n tfae_have 1 → 2 := fun _ ↦ inferInstance\n tfae_have 2 → 1 := fun _ ↦ ((IsBezout.TFAE (R := R)).out 0 1).mp ‹_›\n tfae_have 1 → 4\n | H => ⟨inferInstance, fun P hP hP' ↦ eq_maximalIdeal (hP'.isMaximal hP)⟩\n tfae_have 4 → 3 :=\n fun ⟨h₁, h₂⟩ ↦ { h₁ with maximalOfPrime := (h₂ _ · · ▸ maximalIdeal.isMaximal R) }\n tfae_have 3 → 5 := fun h ↦ maximalIdeal_isPrincipal_of_isDedekindDomain R\n tfae_have 6 ↔ 5 := finrank_cotangentSpace_le_one_iff\n tfae_have 5 → 7 := exists_maximalIdeal_pow_eq_of_principal R\n tfae_have 7 → 2 := by\n rw [ValuationRing.iff_ideal_total]\n intro H\n constructor\n intro I J\n by_cases hI : I = ⊥; · order\n by_cases hJ : J = ⊥; · order\n obtain ⟨n, rfl⟩ := H I hI\n obtain ⟨m, rfl⟩ := H J hJ\n exact (le_total m n).imp Ideal.pow_le_pow_right Ideal.pow_le_pow_right\n tfae_finish\n\n/--\nThe following are equivalent for a\nNoetherian local domain that is not a field `(R, m, k)`:\n0. `R` is a discrete valuation ring\n1. `R` is a valuation ring\n2. `R` is a Dedekind domain\n3. `R` is integrally closed with a unique non-zero prime ideal\n4. `m` is principal\n5. `dimₖ m/m² = 1`\n6. Every nonzero ideal is a power of `m`.\n\nAlso see `tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain` for a version without `¬ IsField R`.\n-/\n\nTarget:\ntheorem IsDiscreteValuationRing.TFAE [IsNoetherianRing R] [IsLocalRing R] [IsDomain R]\n (h : ¬IsField R) :\n List.TFAE\n [IsDiscreteValuationRing R, ValuationRing R, IsDedekindDomain R,\n IsIntegrallyClosed R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ P.IsPrime, (maximalIdeal R).IsPrincipal,\n finrank (ResidueField R) (CotangentSpace R) = 1,\n ∀ (I) (_ : I ≠ ⊥), ∃ n : ℕ, I = maximalIdeal R ^ n] :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/DiscreteValuationRing","family_id":"isdiscretevaluationring","file_id":"mathlib/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean","sample_id":"c1d8adcd1dc14fbe13ce66f52a3923797e65f8ed46f53c24f6fa8d7484a01062"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"02cbebe28206c613191b8a691427b5b0241913279e5e25084b9c45a100c81f6e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"704efeeee592c3ee6480336bbb69c4f75dd795846a471cd26e230716ffdaed02","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b8d84457ed5626a8763dcffe3d0369c2c9e378c1b1bc236062b7f6bdd4789af1","source_sha256":"b5f215cf4eadac7c6f9754350b2eea8e0f5d2135c14ced3b4efe579b04b26116","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [mul', lift_comp_comm_eq]","hard_negative":false,"metrics":{"chosen_tokens":7,"rejected_tokens":3,"token_jaccard":0.111111,"token_length_ratio":0.428571},"negative_category":"by_exact_placeholder","negative_mode":"exact?","pair_id":"f00d956e1bf2d0b99e22c921132e275d6c7b7565e12d70b3567dce477566faa8","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.NonUnitalHom\npublic import Mathlib.LinearAlgebra.TensorProduct.Map\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\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/-!\n# Facts about algebras involving bilinear maps and tensor products\n\nWe move a few basic statements about algebras out of `Algebra.Algebra.Basic`,\nin order to avoid importing `LinearAlgebra.BilinearMap` and\n`LinearAlgebra.TensorProduct` unnecessarily.\n-/\n\n@[expose] public section\n\nopen TensorProduct Module\n\nvariable {R A B : Type*}\n\nnamespace LinearMap\n\nsection NonUnitalNonAssoc\n\nvariable (R A) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\n\n/-- The multiplication in a non-unital non-associative algebra is a bilinear map.\n\nA weaker version of this for semirings exists as `AddMonoidHom.mul`. -/\n@[instance_reducible, simps!]\ndef mul : A →ₗ[R] A →ₗ[R] A :=\n LinearMap.mk₂ R (· * ·) add_mul smul_mul_assoc mul_add mul_smul_comm\n\n/-- The multiplication map on a non-unital algebra, as an `R`-linear map from `A ⊗[R] A` to `A`. -/\ndef mul' : A ⊗[R] A →ₗ[R] A :=\n TensorProduct.lift (mul R A)\n\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ\" => LinearMap.mul' _ _\n@[inherit_doc] scoped[RingTheory.LinearMap] notation \"μ[\" R \"]\" => LinearMap.mul' R _\n\nvariable {A R}\n\n@[simp]\ntheorem mul_apply' (a b : A) : mul R A a b = a * b :=\n rfl\n\n@[simp]\ntheorem mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=\n rfl\n\nlemma restrictScalars_mul {S : Type*} [CommSemiring S] [Module S A] [SMulCommClass S A A]\n [IsScalarTower S A A] [CompatibleSMul A A R S] (a : A) :\n LinearMap.restrictScalars R (LinearMap.mul S A a) = LinearMap.mul R A a := by\n ext x\n simp\n\nvariable {M : Type*} [AddCommMonoid M] [Module R M]\n\ntheorem lift_lsmul_mul_eq_lsmul_lift_lsmul {r : R} :\n lift (lsmul R M ∘ₗ mul R R r) = lsmul R M r ∘ₗ lift (lsmul R M) := by\n apply TensorProduct.ext'\n intro x a\n simp [← mul_smul, mul_comm]\n\nend NonUnitalNonAssoc\n\nsection NonUnital\n\nvariable [CommSemiring R] [NonUnitalSemiring A] [NonUnitalSemiring B] [Module R B] [Module R A]\nvariable [SMulCommClass R A A] [IsScalarTower R A A]\nvariable [SMulCommClass R B B] [IsScalarTower R B B]\n\nvariable (R A) in\n/-- The multiplication in a non-unital algebra is a bilinear map.\n\nA weaker version of this for non-unital non-associative algebras exists as `LinearMap.mul`. -/\ndef _root_.NonUnitalAlgHom.lmul : A →ₙₐ[R] End R A where\n __ := mul R A\n map_mul' := mulLeft_mul _ _\n map_zero' := mulLeft_zero_eq_zero _ _\n\n@[simp]\ntheorem _root_.NonUnitalAlgHom.coe_lmul_eq_mul : ⇑(NonUnitalAlgHom.lmul R A) = mul R A :=\n rfl\n\ntheorem commute_mulLeft_right (a b : A) : Commute (mulLeft R a) (mulRight R b) := by\n ext c\n exact (mul_assoc a c b).symm\n\n/-- A `LinearMap` preserves multiplication if pre- and post- composition with `LinearMap.mul` are\nequivalent. By converting the statement into an equality of `LinearMap`s, this lemma allows various\nspecialized `ext` lemmas about `→ₗ[R]` to then be applied.\n\nThis is the `LinearMap` version of `AddMonoidHom.map_mul_iff`. -/\ntheorem map_mul_iff (f : A →ₗ[R] B) :\n (∀ x y, f (x * y) = f x * f y) ↔\n (LinearMap.mul R A).compr₂ f = (LinearMap.mul R B ∘ₗ f).compl₂ f :=\n Iff.symm LinearMap.ext_iff₂\n\nend NonUnital\n\nsection Semiring\n\nvariable (R A)\nsection one_side\nvariable [Semiring R] [Semiring A]\n\nsection left\nvariable [Module R A] [SMulCommClass R A A]\n\n@[simp]\ntheorem pow_mulLeft (a : A) (n : ℕ) : mulLeft R a ^ n = mulLeft R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulLeft_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ, mulLeft_mul, Module.End.mul_eq_comp, pow_mulLeft]\n\nend left\n\nsection right\nvariable [Module R A] [IsScalarTower R A A]\n\n@[simp]\ntheorem pow_mulRight (a : A) (n : ℕ) : mulRight R a ^ n = mulRight R (a ^ n) :=\n match n with\n | 0 => by rw [pow_zero, pow_zero, mulRight_one, Module.End.one_eq_id]\n | (n + 1) => by rw [pow_succ, pow_succ', mulRight_mul, Module.End.mul_eq_comp, pow_mulRight]\n\nend right\n\nend one_side\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n/-- The multiplication in an algebra is an algebra homomorphism into the endomorphisms on\nthe algebra.\n\nA weaker version of this for non-unital algebras exists as `NonUnitalAlgHom.lmul`. -/\ndef _root_.Algebra.lmul : A →ₐ[R] End R A where\n __ := NonUnitalAlgHom.lmul R A\n map_one' := mulLeft_one _ _\n commutes' r := ext fun a => (Algebra.smul_def r a).symm\n\nvariable {R A}\n\n@[simp]\ntheorem _root_.Algebra.coe_lmul_eq_mul : ⇑(Algebra.lmul R A) = mul R A :=\n rfl\n\ntheorem _root_.Algebra.lmul_injective : Function.Injective (Algebra.lmul R A) :=\n fun a₁ a₂ h ↦ by simpa using DFunLike.congr_fun h 1\n\ntheorem _root_.Algebra.lmul_isUnit_iff {x : A} :\n IsUnit (Algebra.lmul R A x) ↔ IsUnit x := by\n rw [Module.End.isUnit_iff, Iff.comm]\n exact IsUnit.isUnit_iff_mulLeft_bijective\n\ntheorem toSpanSingleton_one_eq_algebraLinearMap :\n toSpanSingleton R A 1 = Algebra.linearMap R A := by ext; simp\n\n@[deprecated (since := \"2025-12-30\")] alias toSpanSingleton_eq_algebra_linearMap :=\n toSpanSingleton_one_eq_algebraLinearMap\n\nvariable (R A) in\n/-- The multiplication map on an `R`-algebra, as an `A`-linear map from `A ⊗[R] A` to `A`. -/\n@[simps!] def mul'' : A ⊗[R] A →ₗ[A] A where\n __ := mul' R A\n map_smul' a x := x.induction_on (by simp) (by simp +contextual [mul', smul_tmul', mul_assoc])\n (by simp +contextual [mul_add])\n\nend Semiring\n\nsection CommSemiring\n-- TODO: Generalise to `NonUnitalNonAssocCommSemiring`. This can't currently be done\n-- because there is no instance **to** `NonUnitalNonAssocCommSemiring`.\nvariable [CommSemiring R] [NonUnitalCommSemiring A]\n [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]\n\n@[simp] lemma flip_mul : (mul R A).flip = mul R A := by ext; simp [mul_comm]\n\nTarget:\nlemma mul'_comp_comm : mul' R A ∘ₗ TensorProduct.comm R A A = mul' R A :=\n\nProof body:\n","rejected":"by\n exact?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"mul'_comp_comm","file_id":"mathlib/Mathlib/Algebra/Algebra/Bilinear.lean","sample_id":"b8d84457ed5626a8763dcffe3d0369c2c9e378c1b1bc236062b7f6bdd4789af1"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2de83d28727f5c6b623d7b558d43a3730b0b8baa0c147649925b0fc0c6b6ee06","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"890bc23852214086d6478b594f7059bd2dc0b78c7a65a955ff1366a07d5e60da","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"2d0a39395c9041b4207ccd98cb82e134f84668e6b2b32d3795eb91a204033ee8","source_sha256":"ae5712c01e19ee9e698953ecf3438b05b54b2b04dda2e774200341d53bf92b5f","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n classical\n change _ = ite _ _ _\n rw [if_neg, preimage_image_eq, if_pos hs]\n · exact Option.some_injective _\n · rintro ⟨x, _, ⟨⟩⟩","hard_negative":true,"metrics":{"chosen_tokens":34,"rejected_tokens":5,"token_jaccard":0.12,"token_length_ratio":0.147059},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"f090e42e7067b179a77581f879e419838a3727ca22ccb73206f9bbc1ff97370a","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice\npublic import Mathlib.Order.ConditionallyCompleteLattice.Defs\npublic import Mathlib.Order.ConditionallyCompletePartialOrder.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\n/-!\n# Theory of conditionally complete lattices\n\nA conditionally complete lattice is a lattice in which every non-empty bounded subset `s`\nhas a least upper bound and a greatest lower bound, denoted below by `sSup s` and `sInf s`.\nTypical examples are `ℝ`, `ℕ`, and `ℤ` with their usual orders.\n\nThe theory is very comparable to the theory of complete lattices, except that suitable\nboundedness and nonemptiness assumptions have to be added to most statements.\nWe express these using the `BddAbove` and `BddBelow` predicates, which we use to prove\nmost useful properties of `sSup` and `sInf` in conditionally complete lattices.\n\nTo differentiate the statements between complete lattices and conditionally complete\nlattices, we prefix `sInf` and `sSup` in the statements by `c`, giving `csInf` and `csSup`.\nFor instance, `sInf_le` is a statement in complete lattices ensuring `sInf s ≤ x`,\nwhile `csInf_le` is the same statement in conditionally complete lattices\nwith an additional assumption that `s` is bounded below.\n-/\n\n@[expose] public section\n\n-- Guard against import creep\nassert_not_exists Multiset\n\nopen Function OrderDual Set\n\nvariable {α β γ : Type*} {ι : Sort*}\n\nsection LE\n\n/-!\nExtension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α`\n-/\n\nvariable [LE α]\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instSupSet [SupSet α] :\n SupSet (WithTop α) :=\n ⟨fun S =>\n if ⊤ ∈ S then ⊤ else if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then\n ↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩\n\nopen Classical in\n@[to_dual]\nnoncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) :=\n ⟨fun S => if S ⊆ {⊤} ∨ ¬BddBelow S then ⊤ else ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩\n\n@[to_dual]\ntheorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s)\n (hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) :=\n (if_neg hs).trans <| if_pos hs'\n\n@[to_dual]\ntheorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) :\n sInf s = ↑(sInf ((↑) ⁻¹' s) : α) :=\n if_neg <| by simp [hs, h's]\n\n@[simp]\ntheorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ :=\n if_pos <| by simp\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_singleton_top [InfSet α] : sInf ({⊤} : Set (WithTop α)) = ⊤ :=\n if_pos <| .inl subset_rfl\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sSup_of_top_mem [SupSet α] {s : Set (WithTop α)} (h : ⊤ ∈ s) : sSup s = ⊤ :=\n if_pos h\n\n@[to_dual]\ntheorem WithTop.sSup_singleton_top [SupSet α] : sSup ({⊤} : Set (WithTop α)) = ⊤ := by\n simp\n\n@[to_dual]\ntheorem WithTop.sSup_of_not_bddAbove [SupSet α] {s : Set (WithTop α)}\n (h : ¬BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ⊤ := by\n by_cases hmem : ⊤ ∈ s\n · exact sSup_of_top_mem hmem\n · exact if_neg hmem |>.trans <| if_neg h\n\n@[to_dual (attr := simp)]\ntheorem WithTop.sInf_of_not_bddBelow [InfSet α] {s : Set (WithTop α)} (h : ¬BddBelow s) :\n sInf s = ⊤ :=\n if_pos <| .inr h\n\n@[to_dual (attr := norm_cast)]\n\nTarget:\ntheorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) :\n ↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithTop α) :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_2d0a39395c90","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"a661698d6f5c331f56b86a26401795e13642c70f6d1e41b0c6f119b878c93106","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/ConditionallyCompleteLattice","family_id":"withtop","file_id":"mathlib/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean","sample_id":"2d0a39395c9041b4207ccd98cb82e134f84668e6b2b32d3795eb91a204033ee8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b7f886df9fb4fe0abcfe75238d8f52ebc93d445ab828aef157afbafb7a7f0b7e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ff1db6d87e8e53f58d104a950ac5647ce78be5709d0c518dcf9e983afc7e0ac1","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"3af3be70409014e98ae5467d92ac5d27ac7a9e99f78a6f0af568e4c4ee2c3ff8","source_sha256":"01d22f0e482b6f1141c70e715d8575d3ad6707cda65b154f72f0567903aa642b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [isPurelyInseparable_iff]\n refine ⟨fun h x ↦ ?_, fun h x ↦ ?_⟩\n · obtain ⟨g, h1, n, h2⟩ := (minpoly.irreducible (h x).1).hasSeparableContraction q\n exact ⟨n, (h _).2 <| h1.of_dvd <| minpoly.dvd F _ <| by\n simpa only [expand_aeval, minpoly.aeval] using congr_arg (aeval x) h2⟩\n have hdeg := (minpoly.natSepDegree_eq_one_iff_pow_mem q).2 (h x)\n have halg : IsIntegral F x := by_contra fun h' ↦ by\n simp only [minpoly.eq_zero h', natSepDegree_zero, zero_ne_one] at hdeg\n refine ⟨halg, fun hsep ↦ ?_⟩\n rwa [hsep.natSepDegree_eq_natDegree, minpoly.natDegree_eq_one_iff] at hdeg","hard_negative":true,"metrics":{"chosen_tokens":152,"rejected_tokens":3,"token_jaccard":0.032787,"token_length_ratio":0.019737},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"f097c39c6e7d31e72a0907fd163a569e08971d57daa1ac0f7b277798c61e30d9","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.CharP.IntermediateField\npublic import Mathlib.FieldTheory.IsSepClosed\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n\n# Basic results about purely inseparable extensions\n\nThis file contains basic definitions and results about purely inseparable extensions.\n\n## Main definitions\n\n- `IsPurelyInseparable`: typeclass for purely inseparable field extensions: an algebraic extension\n `E / F` is purely inseparable if and only if the minimal polynomial of every element of `E ∖ F`\n is not separable.\n\n## Main results\n\n- `IsPurelyInseparable.surjective_algebraMap_of_isSeparable`,\n `IsPurelyInseparable.bijective_algebraMap_of_isSeparable`,\n `IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable`:\n if `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective\n (hence bijective). In particular, if an intermediate field of `E / F` is both purely inseparable\n and separable, then it is equal to `F`.\n\n- `isPurelyInseparable_iff_pow_mem`: a field extension `E / F` of exponential characteristic `q` is\n purely inseparable if and only if for every element `x` of `E`, there exists a natural number `n`\n such that `x ^ (q ^ n)` is contained in `F`.\n\n- `IsPurelyInseparable.trans`: if `E / F` and `K / E` are both purely inseparable extensions, then\n `K / F` is also purely inseparable.\n\n- `isPurelyInseparable_iff_natSepDegree_eq_one`: `E / F` is purely inseparable if and only if for\n every element `x` of `E`, its minimal polynomial has separable degree one.\n\n- `isPurelyInseparable_iff_minpoly_eq_X_pow_sub_C`: a field extension `E / F` of exponential\n characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal\n polynomial of `x` over `F` is of form `X ^ (q ^ n) - y` for some natural number `n` and some\n element `y` of `F`.\n\n- `isPurelyInseparable_iff_minpoly_eq_X_sub_C_pow`: a field extension `E / F` of exponential\n characteristic `q` is purely inseparable if and only if for every element `x` of `E`, the minimal\n polynomial of `x` over `F` is of form `(X - x) ^ (q ^ n)` for some natural number `n`.\n\n- `isPurelyInseparable_iff_finSepDegree_eq_one`: an extension is purely inseparable\n if and only if it has finite separable degree (`Field.finSepDegree`) one.\n\n- `IsPurelyInseparable.normal`: a purely inseparable extension is normal.\n\n- `separableClosure.isPurelyInseparable`: if `E / F` is algebraic, then `E` is purely inseparable\n over the separable closure of `F` in `E`.\n\n- `separableClosure_le_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` contains\n the separable closure of `F` in `E` if and only if `E` is purely inseparable over it.\n\n- `eq_separableClosure_iff`: if `E / F` is algebraic, then an intermediate field of `E / F` is equal\n to the separable closure of `F` in `E` if and only if it is separable over `F`, and `E`\n is purely inseparable over it.\n\n- `IsPurelyInseparable.injective_comp_algebraMap`: if `E / F` is purely inseparable, then for any\n reduced ring `L`, the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is injective.\n In particular, a purely inseparable field extension is an epimorphism in the category of fields.\n\n- `IsPurelyInseparable.of_injective_comp_algebraMap`: if `L` is an algebraically closed field\n containing `E`, such that the map `(E →+* L) → (F →+* L)` induced by `algebraMap F E` is\n injective, then `E / F` is purely inseparable. As a corollary, epimorphisms in the category of\n fields must be purely inseparable extensions.\n\n- `Field.finSepDegree_eq`: if `E / F` is algebraic, then the `Field.finSepDegree F E` is equal to\n `Field.sepDegree F E` as a natural number. This means that the cardinality of `Field.Emb F E`\n and the degree of `(separableClosure F E) / F` are both finite or infinite, and when they are\n finite, they coincide.\n\n- `Field.finSepDegree_mul_finInsepDegree`: the finite separable degree multiply by the finite\n inseparable degree is equal to the (finite) field extension degree.\n\n## Tags\n\nseparable degree, degree, separable closure, purely inseparable\n\n-/\n\n@[expose] public section\n\nopen Module Polynomial IntermediateField Field\n\nnoncomputable section\n\nuniverse u v w\n\nsection General\n\nvariable (F E : Type*) [CommRing F] [Ring E] [Algebra F E]\nvariable (K : Type*) [Ring K] [Algebra F K]\n\n/-- Typeclass for purely inseparable field extensions: an algebraic extension `E / F` is purely\ninseparable if and only if the minimal polynomial of every element of `E ∖ F` is not separable.\n\nWe define this for general (commutative) rings and only assume `F` and `E` are fields\nif this is needed for a proof. -/\nclass IsPurelyInseparable : Prop where\n isIntegral : Algebra.IsIntegral F E\n inseparable' (x : E) : IsSeparable F x → x ∈ (algebraMap F E).range\n\nattribute [instance] IsPurelyInseparable.isIntegral\n\nvariable {E} in\ntheorem IsPurelyInseparable.isIntegral' [IsPurelyInseparable F E] (x : E) : IsIntegral F x :=\n Algebra.IsIntegral.isIntegral _\n\ntheorem IsPurelyInseparable.isAlgebraic [Nontrivial F] [IsPurelyInseparable F E] :\n Algebra.IsAlgebraic F E := inferInstance\n\nvariable {E}\n\ntheorem IsPurelyInseparable.inseparable [IsPurelyInseparable F E] :\n ∀ x : E, IsSeparable F x → x ∈ (algebraMap F E).range :=\n IsPurelyInseparable.inseparable'\n\nvariable {F}\n\ntheorem isPurelyInseparable_iff : IsPurelyInseparable F E ↔ ∀ x : E,\n IsIntegral F x ∧ (IsSeparable F x → x ∈ (algebraMap F E).range) :=\n ⟨fun h x ↦ ⟨h.isIntegral' _ x, h.inseparable' x⟩, fun h ↦ ⟨⟨fun x ↦ (h x).1⟩, fun x ↦ (h x).2⟩⟩\n\nvariable {K}\n\n/-- Transfer `IsPurelyInseparable` across an `AlgEquiv`. -/\ntheorem AlgEquiv.isPurelyInseparable (e : K ≃ₐ[F] E) [IsPurelyInseparable F K] :\n IsPurelyInseparable F E := by\n refine ⟨⟨fun _ ↦ by rw [← isIntegral_algEquiv e.symm]; exact IsPurelyInseparable.isIntegral' F _⟩,\n fun x h ↦ ?_⟩\n rw [IsSeparable, ← minpoly.algEquiv_eq e.symm] at h\n simpa only [RingHom.mem_range, algebraMap_eq_apply] using IsPurelyInseparable.inseparable F _ h\n\ntheorem AlgEquiv.isPurelyInseparable_iff (e : K ≃ₐ[F] E) :\n IsPurelyInseparable F K ↔ IsPurelyInseparable F E :=\n ⟨fun _ ↦ e.isPurelyInseparable, fun _ ↦ e.symm.isPurelyInseparable⟩\n\n/-- If `E / F` is an algebraic extension, `F` is separably closed,\nthen `E / F` is purely inseparable. -/\ninstance Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed\n {F : Type u} {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E]\n [Algebra.IsAlgebraic F E] [IsSepClosed F] : IsPurelyInseparable F E :=\n ⟨inferInstance, fun x h ↦ minpoly.mem_range_of_degree_eq_one F x <|\n IsSepClosed.degree_eq_one_of_irreducible F (minpoly.irreducible\n (Algebra.IsIntegral.isIntegral _)) h⟩\n\nvariable (F E K)\n\n/-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is surjective. -/\ntheorem IsPurelyInseparable.surjective_algebraMap_of_isSeparable\n [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Surjective (algebraMap F E) :=\n fun x ↦ IsPurelyInseparable.inseparable F x (Algebra.IsSeparable.isSeparable F x)\n\n/-- If `E / F` is both purely inseparable and separable, then `algebraMap F E` is bijective. -/\ntheorem IsPurelyInseparable.bijective_algebraMap_of_isSeparable\n [Nontrivial E] [IsDomain F] [IsTorsionFree F E]\n [IsPurelyInseparable F E] [Algebra.IsSeparable F E] : Function.Bijective (algebraMap F E) :=\n ⟨FaithfulSMul.algebraMap_injective F E, surjective_algebraMap_of_isSeparable F E⟩\n\nvariable {F E} in\n/-- If a subalgebra of `E / F` is both purely inseparable and separable, then it is equal\nto `F`. -/\ntheorem Subalgebra.eq_bot_of_isPurelyInseparable_of_isSeparable (L : Subalgebra F E)\n [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by\n obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩\n exact ⟨y, congr_arg (Subalgebra.val _) hy⟩\n\n/-- If an intermediate field of `E / F` is both purely inseparable and separable, then it is equal\nto `F`. -/\ntheorem IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable\n {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] (L : IntermediateField F E)\n [IsPurelyInseparable F L] [Algebra.IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by\n obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩\n exact ⟨y, congr_arg (algebraMap L E) hy⟩\n\n/-- If `E / F` is purely inseparable, then the separable closure of `F` in `E` is\nequal to `F`. -/\ntheorem separableClosure.eq_bot_of_isPurelyInseparable\n (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] [IsPurelyInseparable F E] :\n separableClosure F E = ⊥ :=\n bot_unique fun x h ↦ IsPurelyInseparable.inseparable F x (mem_separableClosure_iff.1 h)\n\n/-- If `E / F` is an algebraic extension, then the separable closure of `F` in `E` is\nequal to `F` if and only if `E / F` is purely inseparable. -/\ntheorem separableClosure.eq_bot_iff\n {F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] [Algebra.IsAlgebraic F E] :\n separableClosure F E = ⊥ ↔ IsPurelyInseparable F E :=\n ⟨fun h ↦ isPurelyInseparable_iff.2 fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, fun hs ↦ by\n simpa only [h] using! mem_separableClosure_iff.2 hs⟩, fun _ ↦ eq_bot_of_isPurelyInseparable F E⟩\n\ninstance isPurelyInseparable_self : IsPurelyInseparable F F :=\n ⟨inferInstance, fun x _ ↦ ⟨x, rfl⟩⟩\n\nsection\n\nvariable (F : Type u) {E : Type v} [Field F] [Ring E] [IsDomain E] [Algebra F E]\nvariable (q : ℕ) [ExpChar F q] (x : E)\n\n/-- A field extension `E / F` of exponential characteristic `q` is purely inseparable\nif and only if for every element `x` of `E`, there exists a natural number `n` such that\n`x ^ (q ^ n)` is contained in `F`. -/\n@[stacks 09HE]\n\nTarget:\ntheorem isPurelyInseparable_iff_pow_mem :\n IsPurelyInseparable F E ↔ ∀ x : E, ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range :=\n\nProof body:\n","rejected":"by\n exact isPurelyInseparable_iff_pow_mem","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"e7164fc6161345b82d5d085d1619e8edbb10c0c5a3ccaf230c20265824870caa","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":true},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory/PurelyInseparable","family_id":"ispurelyinseparable_iff_pow_mem","file_id":"mathlib/Mathlib/FieldTheory/PurelyInseparable/Basic.lean","sample_id":"3af3be70409014e98ae5467d92ac5d27ac7a9e99f78a6f0af568e4c4ee2c3ff8"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d8eab85b06a4dec1573915379171a55d25a2102b8f22818ef294368125112d57","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0b9bc54168c2d1e585f9593d75df9cecffce95d15dfbeb2315335851f9bee1e3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8f35db6307434332a4c7dc19c905321231603f7c32c517fb1c50208185f01852","source_sha256":"194206bb2f0ba4529dcefcd99a93348b595c99eb311c8226ee03a1f371a82e74","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x\n rw [cotangentComplex_mk, map_tmul, map_one, Cotangent.map_mk, cotangentComplex_mk]","hard_negative":true,"metrics":{"chosen_tokens":26,"rejected_tokens":3,"token_jaccard":0.05,"token_length_ratio":0.115385},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"f13f90540ae8e2e076806b2bd66603fcae981ceae20e788045783a987907cd6c","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.Polynomial\npublic import Mathlib.Algebra.Module.FinitePresentation\npublic import Mathlib.RingTheory.Extension.Presentation.Basic\n\nNamespace:\nAlgebra.Extension.CotangentSpace\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n\n# Naive cotangent complex associated to a presentation.\n\nGiven a presentation `0 → I → R[x₁,...,xₙ] → S → 0` (or equivalently a closed embedding `S ↪ Aⁿ`\ndefined by `I`), we may define the (naive) cotangent complex `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R] → 0`.\n\n## Main results\n- `Algebra.Extension.Cotangent`: The conormal space `I/I²`. (Defined in `Generators/Basic`)\n- `Algebra.Extension.CotangentSpace`: The cotangent space `⨁ᵢ S dxᵢ`.\n- `Algebra.Generators.cotangentSpaceBasis`: The canonical basis on `⨁ᵢ S dxᵢ`.\n- `Algebra.Extension.CotangentComplex`: The map `I/I² → ⨁ᵢ S dxᵢ`.\n- `Algebra.Extension.toKaehler`: The projection `⨁ᵢ S dxᵢ → Ω[S/R]`.\n- `Algebra.Extension.toKaehler_surjective`: The map `⨁ᵢ S dxᵢ → Ω[S/R]` is surjective.\n- `Algebra.Extension.exact_cotangentComplex_toKaehler`: `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R]` is exact.\n- `Algebra.Extension.Hom.Sub`: If `f` and `g` are two maps between presentations, `f - g` induces\n a map `⨁ᵢ S dxᵢ → I/I²` that makes `f` and `g` homotopic.\n- `Algebra.Extension.H1Cotangent`: The first homology of the (naive) cotangent complex\n of `S` over `R`, induced by a given presentation.\n- `Algebra.H1Cotangent`: `H¹(L_{S/R})`,\n the first homology of the (naive) cotangent complex of `S` over `R`.\n\n## Implementation detail\nWe actually develop these material for general extensions (i.e. surjection `P → S`) so that we can\napply them to infinitesimal smooth (or versal) extensions later.\n\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential Module MvPolynomial TensorProduct\n\nnamespace Algebra\n\nuniverse w u v\n\nvariable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n\nnamespace Extension\n\nvariable (P : Extension.{w} R S)\n\n/--\nThe cotangent space on `P = R[X]`.\nThis is isomorphic to `Sⁿ` with `n` being the number of variables of `P`.\n-/\nabbrev CotangentSpace : Type _ := S ⊗[P.Ring] Ω[P.Ring⁄R]\n\n/-- The cotangent complex given by a presentation `R[X] → S` (i.e. a closed embedding `S ↪ Aⁿ`). -/\nnoncomputable\ndef cotangentComplex : P.Cotangent →ₗ[S] P.CotangentSpace :=\n letI f : P.Cotangent ≃ₗ[P.Ring] P.ker.Cotangent :=\n { __ := AddEquiv.refl _, map_smul' := Cotangent.val_smul' }\n (kerCotangentToTensor R P.Ring S ∘ₗ f).extendScalarsOfSurjective P.algebraMap_surjective\n\n@[simp]\nlemma cotangentComplex_mk (x) : P.cotangentComplex (.mk x) = 1 ⊗ₜ .D _ _ x :=\n rfl\n\nlemma Cotangent.mk_C_mem_ker_cotangentComplex {σ : Type*} (G : Generators R S σ)\n {r : R} (hr : C r ∈ G.ker) :\n Extension.Cotangent.mk ⟨C r, hr⟩ ∈ G.toExtension.cotangentComplex.ker := by\n have : D R G.toExtension.Ring (C r) = 0 := Derivation.map_algebraMap ..\n simp [this]\n\nsection baseChange\n\nvariable {A : Type*} [CommRing A] [Algebra S A] [Algebra P.Ring A] [IsScalarTower P.Ring S A]\n\nvariable (R S) in\n/-- This is (isomorphic to) the base change of the cotangent complex to `A`, but\nthe domain and codomains of this are more manageable. -/\nnoncomputable\ndef _root_.KaehlerDifferential.cotangentComplexBaseChange\n (P A : Type*) [CommRing P] [CommRing A] [Algebra P S] [Algebra P A]\n [Algebra R P] [Algebra S A] [IsScalarTower P S A] :\n A ⊗[P] RingHom.ker (algebraMap P S) →ₗ[A] A ⊗[P] Ω[P⁄R] :=\n LinearMap.liftBaseChange _ (KaehlerDifferential.kerToTensor _ _ _ ∘ₗ Submodule.inclusion\n (by rw [IsScalarTower.algebraMap_eq P S A]; intro; aesop))\n\nomit [Algebra R S] in\nlemma _root_.KaehlerDifferential.cotangentComplexBaseChange_tmul\n {P A : Type*} [CommRing P] [CommRing A] [Algebra P S]\n [Algebra P A] [Algebra R P] [Algebra S A] [IsScalarTower P S A] (a b) :\n cotangentComplexBaseChange R S P A (a ⊗ₜ b) =\n a • kerToTensor R P A ⟨b.1, by rw [IsScalarTower.algebraMap_eq P S A]; aesop⟩ := rfl\n\nvariable (A) in\nlemma cotangentComplexBaseChange_eq_lTensor_cotangentComplex :\n cotangentComplexBaseChange R S P.Ring A =\n AlgebraTensorModule.cancelBaseChange P.Ring S A A Ω[P.Ring⁄R] ∘ₗ\n P.cotangentComplex.baseChange A ∘ₗ\n ((AlgebraTensorModule.cancelBaseChange P.Ring S A A P.ker).symm ≪≫ₗ\n P.cotangentEquiv.baseChange (A := A)) := by\n ext x\n simp [LinearEquiv.baseChange, cotangentComplexBaseChange_tmul]\n\nvariable (A) in\nlemma lTensor_cotangentComplex_eq_cotangentComplexBaseChange :\n P.cotangentComplex.baseChange A =\n (AlgebraTensorModule.cancelBaseChange P.Ring S A A Ω[P.Ring⁄R]).symm ∘ₗ\n cotangentComplexBaseChange R S P.Ring A ∘ₗ\n ((AlgebraTensorModule.cancelBaseChange P.Ring S A A P.ker).symm ≪≫ₗ\n P.cotangentEquiv.baseChange (A := A)).symm := by\n apply LinearMap.coe_injective\n dsimp\n rw [LinearEquiv.eq_symm_comp, ← LinearEquiv.comp_symm_eq]\n exact congr(($(cotangentComplexBaseChange_eq_lTensor_cotangentComplex P A) : _ → _)).symm\n\nend baseChange\n\nuniverse w' u' v'\n\nvariable {R' : Type u'} {S' : Type v'} [CommRing R'] [CommRing S'] [Algebra R' S']\nvariable (P' : Extension.{w'} R' S')\nvariable [Algebra R R'] [Algebra S S'] [Algebra R S'] [IsScalarTower R R' S']\n\nattribute [local instance] SMulCommClass.of_commMonoid\n\nvariable {P P'}\n\nuniverse w'' u'' v''\n\nvariable {R'' : Type u''} {S'' : Type v''} [CommRing R''] [CommRing S''] [Algebra R'' S'']\nvariable {P'' : Extension.{w''} R'' S''}\nvariable [Algebra R R''] [Algebra S S''] [Algebra R S'']\n [IsScalarTower R R'' S'']\nvariable [Algebra R' R''] [Algebra S' S''] [Algebra R' S'']\n [IsScalarTower R' R'' S'']\nvariable [IsScalarTower R R' R''] [IsScalarTower S S' S'']\n\nnamespace CotangentSpace\n\n/--\nThis is the map on the cotangent space associated to a map of presentation.\nThe matrix associated to this map is the Jacobian matrix. See `CotangentSpace.repr_map`.\n-/\nprotected noncomputable\ndef map (f : Hom P P') : P.CotangentSpace →ₗ[S] P'.CotangentSpace := by\n letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra\n haveI : IsScalarTower P.Ring S S' := IsScalarTower.of_algebraMap_eq' rfl\n letI := f.toAlgHom.toAlgebra\n haveI : IsScalarTower P.Ring P'.Ring S' :=\n IsScalarTower.of_algebraMap_eq (fun x ↦ (f.algebraMap_toRingHom x).symm)\n apply LinearMap.liftBaseChange\n refine (TensorProduct.mk _ _ _ 1).restrictScalars _ ∘ₗ KaehlerDifferential.map R R' P.Ring P'.Ring\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma map_tmul (f : Hom P P') (x y) :\n CotangentSpace.map f (x ⊗ₜ .D _ _ y) = (algebraMap _ _ x) ⊗ₜ .D _ _ (f.toAlgHom y) := by\n simp only [CotangentSpace.map, AlgHom.toRingHom_eq_coe, LinearMap.liftBaseChange_tmul,\n LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, map_D, mk_apply]\n rw [smul_tmul', ← Algebra.algebraMap_eq_smul_one]\n rfl\n\nlemma map_tmul_eq_tmul_map (f : P.Hom P') (x : S) (y : Ω[P.Ring⁄R]) :\n letI : Algebra P.Ring P'.Ring := f.toAlgHom.toAlgebra\n (CotangentSpace.map f) (x ⊗ₜ[P.Ring] y) =\n (algebraMap S S') x ⊗ₜ[P'.Ring] KaehlerDifferential.map _ _ _ _ y := by\n rw [CotangentSpace.map, LinearMap.liftBaseChange_tmul, LinearMap.coe_comp, Function.comp_apply,\n LinearMap.restrictScalars_apply, mk_apply, smul_tmul', Algebra.smul_def, mul_one]\n\n@[simp]\nlemma map_id :\n CotangentSpace.map (.id P) = LinearMap.id := by ext; simp\n\nlemma map_comp (f : Hom P P') (g : Hom P' P'') :\n CotangentSpace.map (g.comp f) =\n (CotangentSpace.map g).restrictScalars S ∘ₗ CotangentSpace.map f := by\n ext x\n induction x using TensorProduct.induction_on with\n | zero =>\n simp only [map_zero]\n | add =>\n simp only [map_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, *]\n | tmul x y =>\n obtain ⟨y, rfl⟩ := KaehlerDifferential.tensorProductTo_surjective _ _ y\n induction y with\n | zero => simp only [map_zero, tmul_zero]\n | add => simp only [map_add, tmul_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars,\n Function.comp_apply, *]\n | tmul => simp only [Derivation.tensorProductTo_tmul, tmul_smul, smul_tmul', map_tmul,\n Hom.toAlgHom_apply, Hom.comp_toRingHom, RingHom.coe_comp, Function.comp_apply,\n LinearMap.coe_comp, LinearMap.coe_restrictScalars,\n ← IsScalarTower.algebraMap_apply S S' S'']\n\nlemma map_comp_apply (f : Hom P P') (g : Hom P' P'') (x) :\n CotangentSpace.map (g.comp f) x = .map g (.map f x) :=\n DFunLike.congr_fun (map_comp f g) x\n\nTarget:\nlemma map_cotangentComplex (f : Hom P P') (x) :\n CotangentSpace.map f (P.cotangentComplex x) = P'.cotangentComplex (.map f x) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_8f35db630743","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"5eaaacc2ccb475dfe38bda86b8078d8ae0d905acddb04406e5933e00a8d5cc2e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Extension","family_id":"map_cotangentcomplex","file_id":"mathlib/Mathlib/RingTheory/Extension/Cotangent/Basic.lean","sample_id":"8f35db6307434332a4c7dc19c905321231603f7c32c517fb1c50208185f01852"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"fb6d9ad21d798130f93cce38e40fc5f8b53e8db782bb3d5f7d2838f6433452b1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"b0692eabc0c31660fdc5eb22cd5140790caef341f52b22645412e7622dc52bd5","source_sha256":"6c7073e5e01a46e3eeb41e7b78026bf34b3b5442b0dd2251d80491d13afb5e57","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [ContinuousLinearMap.ext_iff, ContinuousLinearMap.coe_prodMap']\n rintro ⟨v₁, v₂⟩\n change\n (e₁.prod e₂).coordChangeL 𝕜 (e₁'.prod e₂') b (v₁, v₂) =\n (e₁.coordChangeL 𝕜 e₁' b v₁, e₂.coordChangeL 𝕜 e₂' b v₂)\n rw [e₁.coordChangeL_apply e₁', e₂.coordChangeL_apply e₂', (e₁.prod e₂).coordChangeL_apply']\n exacts [rfl, hb, ⟨hb.1.2, hb.2.2⟩, ⟨hb.1.1, hb.2.1⟩]\n\nvariable {e₁ e₂} [∀ x : B, TopologicalSpace (E₁ x)] [∀ x : B, TopologicalSpace (E₂ x)]\n [FiberBundle F₁ E₁] [FiberBundle F₂ E₂]","hard_negative":false,"metrics":{"chosen_tokens":185,"rejected_tokens":3,"token_jaccard":0.022222,"token_length_ratio":0.016216},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"f1b7147868ce9febb65ba237faccea716759951b484fbd675798207fc0c3fdee","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.FiberBundle.Constructions\npublic import Mathlib.Topology.VectorBundle.Basic\npublic import Mathlib.Analysis.Normed.Operator.Prod\n\nNamespace:\nBundle.Trivialization\n\nLocal context:\n/-\nCopyright (c) 2022 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri, Sébastien Gouëzel, Heather Macbeth, Floris van Doorn\n-/\n/-!\n# Standard constructions on vector bundles\n\nThis file contains several standard constructions on vector bundles:\n\n* `Bundle.Trivial.vectorBundle 𝕜 B F`: the trivial vector bundle with scalar field `𝕜` and model\n fiber `F` over the base `B`\n\n* `VectorBundle.prod`: for vector bundles `E₁` and `E₂` with scalar field `𝕜` over a common base,\n a vector bundle structure on their direct sum `E₁ ×ᵇ E₂` (the notation stands for\n `fun x ↦ E₁ x × E₂ x`).\n\n* `VectorBundle.pullback`: for a vector bundle `E` over `B`, a vector bundle structure on its\n pullback `f *ᵖ E` by a map `f : B' → B` (the notation is a type synonym for `E ∘ f`).\n\n## Tags\nVector bundle, direct sum, pullback\n-/\n\npublic section\n\nnoncomputable section\n\nopen Bundle Set FiberBundle\n\n/-! ### The trivial vector bundle -/\n\nnamespace Bundle.Trivial\n\nvariable (𝕜 : Type*) (B : Type*) (F : Type*) [NontriviallyNormedField 𝕜] [NormedAddCommGroup F]\n [NormedSpace 𝕜 F] [TopologicalSpace B]\n\ninstance trivialization.isLinear : (trivialization B F).IsLinear 𝕜 where\n linear _ _ := ⟨fun _ _ => rfl, fun _ _ => rfl⟩\n\nvariable {𝕜} in\ntheorem trivialization.coordChangeL (b : B) :\n (trivialization B F).coordChangeL 𝕜 (trivialization B F) b =\n ContinuousLinearEquiv.refl 𝕜 F := by\n ext v\n rw [Trivialization.coordChangeL_apply']\n exacts [rfl, ⟨mem_univ _, mem_univ _⟩]\n\ninstance vectorBundle : VectorBundle 𝕜 F (Bundle.Trivial B F) where\n trivialization_linear' e he := by\n rw [eq_trivialization B F e]\n infer_instance\n continuousOn_coordChange' e e' he he' := by\n obtain rfl := eq_trivialization B F e\n obtain rfl := eq_trivialization B F e'\n simp only [trivialization.coordChangeL]\n exact continuous_const.continuousOn\n\n@[simp] lemma linearMapAt_trivialization (x : B) :\n (trivialization B F).linearMapAt 𝕜 x = LinearMap.id := by\n ext v\n rw [Trivialization.coe_linearMapAt_of_mem _ (by simp)]\n rfl\n\n@[simp] lemma continuousLinearMapAt_trivialization (x : B) :\n (trivialization B F).continuousLinearMapAt 𝕜 x = ContinuousLinearMap.id 𝕜 F := by\n ext; simp\n\n@[simp] lemma symmₗ_trivialization (x : B) :\n (trivialization B F).symmₗ 𝕜 x = LinearMap.id := by\n ext; simp [Trivialization.coe_symmₗ, trivialization_symm_apply B F]\n\n@[simp] lemma symmL_trivialization (x : B) :\n (trivialization B F).symmL 𝕜 x = ContinuousLinearMap.id 𝕜 F := by\n ext; simp [trivialization_symm_apply B F]\n\n@[simp] lemma continuousLinearEquivAt_trivialization (x : B) :\n (trivialization B F).continuousLinearEquivAt 𝕜 x (mem_univ _) =\n ContinuousLinearEquiv.refl 𝕜 F := by\n ext; simp\n\nend Bundle.Trivial\n\n/-! ### Direct sum of two vector bundles -/\n\nsection\n\nvariable (𝕜 : Type*) {B : Type*} [NontriviallyNormedField 𝕜] [TopologicalSpace B] (F₁ : Type*)\n [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] (E₁ : B → Type*) [TopologicalSpace (TotalSpace F₁ E₁)]\n (F₂ : Type*) [NormedAddCommGroup F₂] [NormedSpace 𝕜 F₂] (E₂ : B → Type*)\n [TopologicalSpace (TotalSpace F₂ E₂)]\n\nnamespace Bundle.Trivialization\n\nvariable {F₁ E₁ F₂ E₂}\nvariable [∀ x, AddCommMonoid (E₁ x)] [∀ x, Module 𝕜 (E₁ x)]\n [∀ x, AddCommMonoid (E₂ x)] [∀ x, Module 𝕜 (E₂ x)] (e₁ e₁' : Trivialization F₁ (π F₁ E₁))\n (e₂ e₂' : Trivialization F₂ (π F₂ E₂))\n\ninstance prod.isLinear [e₁.IsLinear 𝕜] [e₂.IsLinear 𝕜] : (e₁.prod e₂).IsLinear 𝕜 where\n linear := fun _ ⟨h₁, h₂⟩ =>\n (((e₁.linear 𝕜 h₁).mk' _).prodMap ((e₂.linear 𝕜 h₂).mk' _)).isLinear\n\n@[simp]\n\nTarget:\ntheorem coordChangeL_prod [e₁.IsLinear 𝕜] [e₁'.IsLinear 𝕜] [e₂.IsLinear 𝕜] [e₂'.IsLinear 𝕜] ⦃b⦄\n (hb : (b ∈ e₁.baseSet ∧ b ∈ e₂.baseSet) ∧ b ∈ e₁'.baseSet ∧ b ∈ e₂'.baseSet) :\n ((e₁.prod e₂).coordChangeL 𝕜 (e₁'.prod e₂') b : F₁ × F₂ →L[𝕜] F₁ × F₂) =\n (e₁.coordChangeL 𝕜 e₁' b : F₁ →L[𝕜] F₁).prodMap (e₂.coordChangeL 𝕜 e₂' b) :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Topology/VectorBundle","family_id":"coordchangel_prod","file_id":"mathlib/Mathlib/Topology/VectorBundle/Constructions.lean","sample_id":"b0692eabc0c31660fdc5eb22cd5140790caef341f52b22645412e7622dc52bd5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f6a95f4339fc29a09b4741866c8c9952b0e0943a519e29b54d2a8433b0a98cf","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"547cb9ada346d8e8f510536405fb597d72ed20ebab88f22d67927754fda3d678","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"f8fdb999101ce33755577e7c01c87bfcc89f8fbf7457a90335f5ab67dc267963","source_sha256":"8e40b01e7ccf6ab3c48f4a90d26615e74e27bf1ea1850224aad736249f560b66","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases subsingleton_or_nontrivial R\n · exact (cardinalMk_eq_one R X).trans_le (le_max_of_le_right one_le_aleph0)\n cases isEmpty_or_nonempty X\n · exact (cardinalMk_eq_lift R X).trans_le (le_max_of_le_left <| le_max_left _ _)\n · exact (cardinalMk_eq_max_lift R X).le\n\nvariable (X : Type u)","hard_negative":false,"metrics":{"chosen_tokens":53,"rejected_tokens":58,"token_jaccard":0.870968,"token_length_ratio":1.09434},"negative_category":"markdown_preamble_trailing","negative_mode":"preamble","pair_id":"f2f2941195dd8ca2d454af92da360978b1520eb9140ebed7174930e145512e97","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.FreeAlgebra\npublic import Mathlib.SetTheory.Cardinal.Free\n\nNamespace:\nFreeAlgebra\n\nLocal context:\n/-\nCopyright (c) 2024 Jz Pan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jz Pan\n-/\n/-!\n# Cardinality of free algebras\n\nThis file contains some results about the cardinality of `FreeAlgebra`,\nparallel to that of `MvPolynomial`.\n-/\n\npublic section\n\nuniverse u v\n\nvariable (R : Type u) [CommSemiring R]\n\nopen Cardinal\n\nnamespace FreeAlgebra\n\nvariable (X : Type v)\n\n@[simp]\ntheorem cardinalMk_eq_max_lift [Nonempty X] [Nontrivial R] :\n #(FreeAlgebra R X) = Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ := by\n have hX := mk_freeMonoid X\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra,\n mk_finsupp_lift_of_infinite, hX, lift_max, lift_aleph0, sup_comm, ← sup_assoc]\n\n@[simp]\ntheorem cardinalMk_eq_lift [IsEmpty X] : #(FreeAlgebra R X) = Cardinal.lift.{v} #R := by\n have := lift_mk_eq'.2 ⟨show (FreeMonoid X →₀ R) ≃ R from Finsupp.uniqueEquiv 1⟩\n rw [lift_id'.{u, v}, lift_umax] at this\n rwa [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra]\n\n@[nontriviality]\ntheorem cardinalMk_eq_one [Subsingleton R] : #(FreeAlgebra R X) = 1 := by\n rw [equivMonoidAlgebraFreeMonoid.toEquiv.cardinal_eq, MonoidAlgebra, mk_eq_one]\n\nTarget:\ntheorem cardinalMk_le_max_lift :\n #(FreeAlgebra R X) ≤ Cardinal.lift.{v} #R ⊔ Cardinal.lift.{u} #X ⊔ ℵ₀ :=\n\nProof body:\n","rejected":"Here is the proof:\nby\n cases subsingleton_or_nontrivial R\n · exact (cardinalMk_eq_one R X).trans_le (le_max_of_le_right one_le_aleph0)\n cases isEmpty_or_nonempty X\n · exact (cardinalMk_eq_lift R X).trans_le (le_max_of_le_left <| le_max_left _ _)\n · exact (cardinalMk_eq_max_lift R X).le\n\nvariable (X : Type u)","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/FreeAlgebra","family_id":"cardinalmk_le_max_lift","file_id":"mathlib/Mathlib/Algebra/FreeAlgebra/Cardinality.lean","sample_id":"f8fdb999101ce33755577e7c01c87bfcc89f8fbf7457a90335f5ab67dc267963"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"a62aa91b93568955f340d959cd2b5c79880851066cbeda03a56b07cb8e5dc4cb","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"a0049d4b4dd31a81a136890aadbd380a897bb586a50189bed309541813696779","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"4d9f13b68e227cfe06c530fc001cc5222dd8381f432c7e1b98167da284911df3","source_sha256":"43af1408f2f686c32d7ad2107fd465552e62766c794081a786ef6955232c936d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n let F : Bool → MvPolynomial σ K := fun b => cond b f₂ f₁\n have : (∑ b : Bool, (F b).totalDegree) < Fintype.card σ := (add_comm _ _).trans_lt h\n simpa only [Bool.forall_bool] using! char_dvd_card_solutions_of_fintype_sum_lt p this","hard_negative":true,"metrics":{"chosen_tokens":60,"rejected_tokens":3,"token_jaccard":0.023256,"token_length_ratio":0.05},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"f327d71ad5f47bcd09c5193735bbf8f6949d85c930c9b436cfaf84f0632b959e","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Finite.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# The Chevalley–Warning theorem\n\nThis file contains a proof of the Chevalley–Warning theorem.\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\n## Main results\n\n1. Let `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`)\n such that the total degree of `f` is less than `(q-1)` times the cardinality of `σ`.\n Then the evaluation of `f` on all points of `σ → K` (aka `K^σ`) sums to `0`.\n (`sum_eval_eq_zero`)\n2. The Chevalley–Warning theorem (`char_dvd_card_solutions_of_sum_lt`).\n Let `f i` be a finite family of multivariate polynomials\n in finitely many variables (`X s`, `s : σ`) such that\n the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\n Then the number of common solutions of the `f i`\n is divisible by the characteristic of `K`.\n\n## Notation\n\n- `K` is a finite field\n- `q` is notation for the cardinality of `K`\n- `σ` is the indexing type for the variables of a multivariate polynomial ring over `K`\n\n-/\n\npublic section\n\n\nuniverse u v\n\nsection FiniteField\n\nopen MvPolynomial\n\nopen Function hiding eval\n\nopen Finset FiniteField\n\nvariable {K σ ι : Type*} [Fintype K] [Field K] [Fintype σ] [DecidableEq σ]\n\nlocal notation \"q\" => Fintype.card K\n\ntheorem MvPolynomial.sum_eval_eq_zero (f : MvPolynomial σ K)\n (h : f.totalDegree < (q - 1) * Fintype.card σ) : ∑ x, eval x f = 0 := by\n haveI : DecidableEq K := Classical.decEq K\n calc\n ∑ x, eval x f = ∑ x : σ → K, ∑ d ∈ f.support, f.coeff d * ∏ i, x i ^ d i := by\n simp only [eval_eq']\n _ = ∑ d ∈ f.support, ∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i := sum_comm\n _ = 0 := sum_eq_zero ?_\n intro d hd\n obtain ⟨i, hi⟩ : ∃ i, d i < q - 1 := f.exists_degree_lt (q - 1) h hd\n calc\n (∑ x : σ → K, f.coeff d * ∏ i, x i ^ d i) = f.coeff d * ∑ x : σ → K, ∏ i, x i ^ d i :=\n (mul_sum ..).symm\n _ = 0 := (mul_eq_zero.mpr ∘ Or.inr) ?_\n calc\n (∑ x : σ → K, ∏ i, x i ^ d i) =\n ∑ x₀ : { j // j ≠ i } → K, ∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j :=\n (Fintype.sum_fiberwise _ _).symm\n _ = 0 := Fintype.sum_eq_zero _ ?_\n intro x₀\n let e : K ≃ { x // x ∘ ((↑) : _ → σ) = x₀ } := (Equiv.subtypeEquivCodomain _).symm\n calc\n (∑ x : { x : σ → K // x ∘ (↑) = x₀ }, ∏ j, (x : σ → K) j ^ d j) =\n ∑ a : K, ∏ j : σ, (e a : σ → K) j ^ d j := (e.sum_comp _).symm\n _ = ∑ a : K, (∏ j, x₀ j ^ d j) * a ^ d i := Fintype.sum_congr _ _ ?_\n _ = (∏ j, x₀ j ^ d j) * ∑ a : K, a ^ d i := by rw [mul_sum]\n _ = 0 := by rw [sum_pow_lt_card_sub_one K _ hi, mul_zero]\n intro a\n let e' : { j // j = i } ⊕ { j // j ≠ i } ≃ σ := Equiv.sumCompl _\n letI : Unique { j // j = i } :=\n { default := ⟨i, rfl⟩\n uniq := fun ⟨j, h⟩ => Subtype.val_injective h }\n calc\n (∏ j : σ, (e a : σ → K) j ^ d j) =\n (e a : σ → K) i ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by\n rw [← e'.prod_comp, Fintype.prod_sum_type, univ_unique, prod_singleton]; rfl\n _ = a ^ d i * ∏ j : { j // j ≠ i }, (e a : σ → K) j ^ d j := by\n rw [Equiv.subtypeEquivCodomain_symm_apply_eq]\n _ = a ^ d i * ∏ j, x₀ j ^ d j := congr_arg _ (Fintype.prod_congr _ _ ?_)\n -- see below\n _ = (∏ j, x₀ j ^ d j) * a ^ d i := mul_comm _ _\n -- the remaining step of the calculation above\n rintro ⟨j, hj⟩\n change (e a : σ → K) j ^ d j = x₀ ⟨j, hj⟩ ^ d j\n rw [Equiv.subtypeEquivCodomain_symm_apply_ne]\n\nvariable [DecidableEq K] (p : ℕ) [CharP K p]\n\n/-- The **Chevalley–Warning theorem**, finitary version.\nLet `(f i)` be a finite family of multivariate polynomials\nin finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`.\nAssume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f i` is divisible by `p`. -/\ntheorem char_dvd_card_solutions_of_sum_lt {s : Finset ι} {f : ι → MvPolynomial σ K}\n (h : (∑ i ∈ s, (f i).totalDegree) < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by\n have hq : 0 < q - 1 := by rw [← Fintype.card_units, Fintype.card_pos_iff]; exact ⟨1⟩\n let S : Finset (σ → K) := {x | ∀ i ∈ s, eval x (f i) = 0}\n have hS (x : σ → K) : x ∈ S ↔ ∀ i ∈ s, eval x (f i) = 0 := by simp [S]\n /- The polynomial `F = ∏ i ∈ s, (1 - (f i)^(q - 1))` has the nice property\n that it takes the value `1` on elements of `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}`\n while it is `0` outside that locus.\n Hence the sum of its values is equal to the cardinality of\n `{x : σ → K // ∀ i ∈ s, (f i).eval x = 0}` modulo `p`. -/\n let F : MvPolynomial σ K := ∏ i ∈ s, (1 - f i ^ (q - 1))\n have hF : ∀ x, eval x F = if x ∈ S then 1 else 0 := by\n intro x\n calc\n eval x F = ∏ i ∈ s, eval x (1 - f i ^ (q - 1)) := eval_prod s _ x\n _ = if x ∈ S then 1 else 0 := ?_\n simp only [(eval x).map_sub, (eval x).map_pow, (eval x).map_one]\n split_ifs with hx\n · apply Finset.prod_eq_one\n intro i hi\n rw [hS] at hx\n rw [hx i hi, zero_pow hq.ne', sub_zero]\n · obtain ⟨i, hi, hx⟩ : ∃ i ∈ s, eval x (f i) ≠ 0 := by\n simpa [hS, not_forall, Classical.not_imp] using hx\n apply Finset.prod_eq_zero hi\n rw [pow_card_sub_one_eq_one (eval x (f i)) hx, sub_self]\n -- In particular, we can now show:\n have key : ∑ x, eval x F = Fintype.card { x : σ → K // ∀ i ∈ s, eval x (f i) = 0 } := by\n rw [Fintype.card_of_subtype S hS, card_eq_sum_ones, Nat.cast_sum, Nat.cast_one, ←\n Fintype.sum_extend_by_zero S, sum_congr rfl fun x _ => hF x]\n -- With these preparations under our belt, we will approach the main goal.\n change p ∣ Fintype.card { x // ∀ i : ι, i ∈ s → eval x (f i) = 0 }\n rw [← CharP.cast_eq_zero_iff K, ← key]\n change (∑ x, eval x F) = 0\n -- We are now ready to apply the main machine, proven before.\n apply F.sum_eval_eq_zero\n -- It remains to verify the crucial assumption of this machine\n show F.totalDegree < (q - 1) * Fintype.card σ\n calc\n F.totalDegree ≤ ∑ i ∈ s, (1 - f i ^ (q - 1)).totalDegree := totalDegree_finsetProd s _\n _ ≤ ∑ i ∈ s, (q - 1) * (f i).totalDegree := sum_le_sum fun i _ => ?_\n -- see ↓\n _ = (q - 1) * ∑ i ∈ s, (f i).totalDegree := (mul_sum ..).symm\n _ < (q - 1) * Fintype.card σ := by gcongr\n -- Now we prove the remaining step from the preceding calculation\n change (1 - f i ^ (q - 1)).totalDegree ≤ (q - 1) * (f i).totalDegree\n calc\n (1 - f i ^ (q - 1)).totalDegree ≤\n max (1 : MvPolynomial σ K).totalDegree (f i ^ (q - 1)).totalDegree := totalDegree_sub _ _\n _ ≤ (f i ^ (q - 1)).totalDegree := by simp\n _ ≤ (q - 1) * (f i).totalDegree := totalDegree_pow _ _\n\n/-- The **Chevalley–Warning theorem**, `Fintype` version.\nLet `(f i)` be a finite family of multivariate polynomials\nin finitely many variables (`X s`, `s : σ`) over a finite field of characteristic `p`.\nAssume that the sum of the total degrees of the `f i` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f i` is divisible by `p`. -/\ntheorem char_dvd_card_solutions_of_fintype_sum_lt [Fintype ι] {f : ι → MvPolynomial σ K}\n (h : (∑ i, (f i).totalDegree) < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // ∀ i, eval x (f i) = 0 } := by\n simpa using char_dvd_card_solutions_of_sum_lt p h\n\n/-- The **Chevalley–Warning theorem**, unary version.\nLet `f` be a multivariate polynomial in finitely many variables (`X s`, `s : σ`)\nover a finite field of characteristic `p`.\nAssume that the total degree of `f` is less than the cardinality of `σ`.\nThen the number of solutions of `f` is divisible by `p`.\nSee `char_dvd_card_solutions_of_sum_lt` for a version that takes a family of polynomials `f i`. -/\ntheorem char_dvd_card_solutions {f : MvPolynomial σ K} (h : f.totalDegree < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // eval x f = 0 } := by\n let F : Unit → MvPolynomial σ K := fun _ => f\n have : (∑ i : Unit, (F i).totalDegree) < Fintype.card σ := h\n convert! char_dvd_card_solutions_of_sum_lt p this\n aesop\n\n/-- The **Chevalley–Warning theorem**, binary version.\nLet `f₁`, `f₂` be two multivariate polynomials in finitely many variables (`X s`, `s : σ`) over a\nfinite field of characteristic `p`.\nAssume that the sum of the total degrees of `f₁` and `f₂` is less than the cardinality of `σ`.\nThen the number of common solutions of the `f₁` and `f₂` is divisible by `p`. -/\n\nTarget:\ntheorem char_dvd_card_solutions_of_add_lt {f₁ f₂ : MvPolynomial σ K}\n (h : f₁.totalDegree + f₂.totalDegree < Fintype.card σ) :\n p ∣ Fintype.card { x : σ → K // eval x f₁ = 0 ∧ eval x f₂ = 0 } :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_4d9f13b68e22","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"51447ac6d374492c01085a18228e0142f9da00f1a605eb3c161306779bdb6027","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"FieldTheory","family_id":"char_dvd_card_solutions_of_add_lt","file_id":"mathlib/Mathlib/FieldTheory/ChevalleyWarning.lean","sample_id":"4d9f13b68e227cfe06c530fc001cc5222dd8381f432c7e1b98167da284911df3"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1432092ec00658210991ef62fdf17b3098cf9ea9d7bc68a7a025aabc5d08061e","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"aa723eecf685cfd6fc5271833b0e86ca29cc0c5f663b3df66652e4aa2b6b5178","source_sha256":"8c28bee61c275be882f91a7d90b8745fd8945186718df7d844b9acdb9fd9341b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp only [← map_mul, sum_characters_eq, ZMod.inv_mul_eq_one_of_isUnit ha]","hard_negative":false,"metrics":{"chosen_tokens":14,"rejected_tokens":5,"token_jaccard":0.058824,"token_length_ratio":0.357143},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"f335b531f1aff1df0803393c82c9a1bbbd214a976e307f20e6fae8ebff8abc93","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.FieldTheory.Finite.Basic\npublic import Mathlib.NumberTheory.DirichletCharacter.Basic\npublic import Mathlib.NumberTheory.MulChar.Duality\n\nNamespace:\nDirichletCharacter\n\nLocal context:\n/-\nCopyright (c) 2024 Michael Stoll. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Stoll\n-/\n/-!\n# Orthogonality relations for Dirichlet characters\n\nLet `n` be a positive natural number. The main result of this file is\n`DirichletCharacter.sum_char_inv_mul_char_eq`, which says that when `a : ZMod n` is a unit\nand `b : ZMod n`, then the sum `∑ χ : DirichletCharacter R n, χ a⁻¹ * χ b` vanishes\nwhen `a ≠ b` and has the value `n.totient` otherwise. This requires `R` to have\nenough roots of unity (e.g., `R` could be an algebraically closed field of characteristic zero).\n-/\n\npublic section\n\nnamespace DirichletCharacter\n\n-- This is needed to be able to write down sums over characters.\nnoncomputable instance fintype {R : Type*} [CommRing R] [IsDomain R] {n : ℕ} :\n Fintype (DirichletCharacter R n) := .ofFinite _\n\nvariable (R : Type*) [CommRing R] (n : ℕ) [NeZero n]\n [HasEnoughRootsOfUnity R (Monoid.exponent (ZMod n)ˣ)]\n\n/-- The group of Dirichlet characters mod `n` with values in a ring `R` that has enough\nroots of unity is (noncanonically) isomorphic to `(ZMod n)ˣ`. -/\nlemma mulEquiv_units : Nonempty (DirichletCharacter R n ≃* (ZMod n)ˣ) :=\n MulChar.mulEquiv_units ..\n\n/-- There are `n.totient` Dirichlet characters mod `n` with values in a ring that has enough\nroots of unity. -/\nlemma card_eq_totient_of_hasEnoughRootsOfUnity :\n Nat.card (DirichletCharacter R n) = n.totient := by\n rw [← ZMod.card_units_eq_totient n, ← Nat.card_eq_fintype_card]\n exact Nat.card_congr (mulEquiv_units R n).some.toEquiv\n\nvariable {n}\n\n/-- If `R` is a ring that has enough roots of unity and `n ≠ 0`, then for each\n`a ≠ 1` in `ZMod n`, there exists a Dirichlet character `χ` mod `n` with values in `R`\nsuch that `χ a ≠ 1`. -/\ntheorem exists_apply_ne_one_of_hasEnoughRootsOfUnity [Nontrivial R] ⦃a : ZMod n⦄ (ha : a ≠ 1) :\n ∃ χ : DirichletCharacter R n, χ a ≠ 1 :=\n MulChar.exists_apply_ne_one_of_hasEnoughRootsOfUnity (ZMod n) R ha\n\nvariable [IsDomain R]\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then\nfor each `a ≠ 1` in `ZMod n`, the sum of `χ a` over all Dirichlet characters mod `n`\nwith values in `R` vanishes. -/\ntheorem sum_characters_eq_zero ⦃a : ZMod n⦄ (ha : a ≠ 1) :\n ∑ χ : DirichletCharacter R n, χ a = 0 := by\n obtain ⟨χ, hχ⟩ := exists_apply_ne_one_of_hasEnoughRootsOfUnity R ha\n refine eq_zero_of_mul_eq_self_left hχ ?_\n simp only [Finset.mul_sum, ← MulChar.mul_apply]\n exact Fintype.sum_bijective _ (Group.mulLeft_bijective χ) _ _ fun χ' ↦ rfl\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then\nfor `a` in `ZMod n`, the sum of `χ a` over all Dirichlet characters mod `n`\nwith values in `R` vanishes if `a ≠ 1` and has the value `n.totient` if `a = 1`. -/\ntheorem sum_characters_eq (a : ZMod n) :\n ∑ χ : DirichletCharacter R n, χ a = if a = 1 then (n.totient : R) else 0 := by\n split_ifs with ha\n · simpa only [ha, map_one, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one,\n ← Nat.card_eq_fintype_card]\n using congrArg Nat.cast <| card_eq_totient_of_hasEnoughRootsOfUnity R n\n · exact sum_characters_eq_zero R ha\n\n/-- If `R` is an integral domain that has enough roots of unity and `n ≠ 0`, then for `a` and `b`\nin `ZMod n` with `a` a unit, the sum of `χ a⁻¹ * χ b` over all Dirichlet characters\nmod `n` with values in `R` vanishes if `a ≠ b` and has the value `n.totient` if `a = b`. -/\n\nTarget:\ntheorem sum_char_inv_mul_char_eq {a : ZMod n} (ha : IsUnit a) (b : ZMod n) :\n ∑ χ : DirichletCharacter R n, χ a⁻¹ * χ b = if a = b then (n.totient : R) else 0 :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/DirichletCharacter","family_id":"sum_char_inv_mul_char_eq","file_id":"mathlib/Mathlib/NumberTheory/DirichletCharacter/Orthogonality.lean","sample_id":"aa723eecf685cfd6fc5271833b0e86ca29cc0c5f663b3df66652e4aa2b6b5178"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"3d672b5fcbfc441a03f02b841c7530642ee083d80e7d67ae94b2026d6a5a2ff0","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c641c3a440e74e4625110563d50a864df264ff1a4060896fd5801c4b02e1cdbf","source_sha256":"4c0d6362d88633d87b94227be85c3259bd3147b3bcd830b894bbdd5c5e741fdb","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [← radical_natAbs_eq_radical, natCast_pos]\n exact Nat.radical_pos _","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":5,"token_jaccard":0.2,"token_length_ratio":0.384615},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"f37f8d18cb5c2b8e56e0c18823d3fd629ab8f282f3a185458dd9d19751a072ab","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.EuclideanDomain.Int\npublic import Mathlib.Algebra.GCDMonoid.Nat\npublic import Mathlib.Data.Nat.Prime.Int\npublic import Mathlib.Data.Nat.PrimeFin\npublic import Mathlib.RingTheory.PrincipalIdealDomain\npublic import Mathlib.RingTheory.Radical.Basic\npublic import Mathlib.RingTheory.UniqueFactorizationDomain.Nat\n\nNamespace:\nInt\n\nLocal context:\n/-\nCopyright (c) 2025 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Arend Mellendijk, Jeremy Tan\n-/\n/-!\n# The radical in `ℕ` and `ℤ`\n\n## Declarations for `ℕ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors`: The prime factors of a natural number\n are the same as the prime factors defined in `Nat.primeFactors`.\n- `Nat.radical_eq_prod_primeFactors`: The radical is computable for natural numbers.\n- `Nat.radical_le_self_iff`: if `n ≠ 0`, `radical n ≤ n`.\n- `Nat.two_le_radical_iff`: `2 ≤ n.radical` iff `2 ≤ n`.\n\n## Declarations for `ℤ`\n\n- `UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs`: The prime factors of an integer\n are the same as the prime factors of its absolute value.\n- `Int.radical_eq_prod_primeFactors`: The radical is computable for integers.\n-/\n\n@[expose] public section\n\nopen UniqueFactorizationMonoid\n\n/-! ### Lemmas about natural numbers -/\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors :\n primeFactors = Nat.primeFactors := by\n ext n : 1\n rw [primeFactors, Nat.factors_eq, Nat.primeFactors]\n -- this convert is necessary because of the different DecidableEq instances\n convert! List.toFinset_coe _\n\nnamespace Nat\n\nvariable {n : ℕ}\n\nlemma radical_eq_prod_primeFactors : radical n = ∏ p ∈ n.primeFactors, p := by\n simp [radical, primeFactors_eq_natPrimeFactors]\n\nlemma radical_pos (n) : 0 < radical n := pos_of_ne_zero radical_ne_zero\n\n@[simp] lemma one_lt_radical_iff : 1 < radical n ↔ 1 < n := by\n have pp (p) (h : p ∈ n.primeFactors) : 1 ≤ p := pos_of_mem_primeFactors h\n rw [radical_eq_prod_primeFactors, ← @nonempty_primeFactors n, Finset.one_lt_prod_iff_of_one_le pp]\n exact ⟨fun ⟨p, h⟩ ↦ ⟨p, h.1⟩, fun ⟨p, h⟩ ↦ ⟨p, h, (mem_primeFactors.mp h).1.one_lt⟩⟩\n\n@[simp] lemma two_le_radical_iff : 2 ≤ radical n ↔ 2 ≤ n := one_lt_radical_iff\n\n@[simp] lemma radical_le_one_iff : radical n ≤ 1 ↔ n ≤ 1 := by\n simpa only [not_lt] using one_lt_radical_iff.not\n\n@[simp] lemma radical_eq_one_iff : radical n = 1 ↔ n ≤ 1 := by\n rw [← radical_le_one_iff]\n grind [radical_pos n]\n\n@[simp] lemma radical_le_self_iff : radical n ≤ n ↔ n ≠ 0 :=\n ⟨by aesop, fun h ↦ Nat.le_of_dvd (by lia) radical_dvd_self⟩\n\n@[simp] lemma self_lt_radical_iff : n < radical n ↔ n = 0 := by\n simpa only [not_le, not_not] using radical_le_self_iff.not\n\nopen Qq Lean Mathlib.Meta Finset\n\nnamespace Mathlib.Meta.Positivity\nopen Positivity\n\nattribute [local instance] monadLiftOptionMetaM in\n/-- Positivity extension for radical. Proves radicals are nonzero. -/\n@[positivity UniqueFactorizationMonoid.radical _]\nmeta def evalRadical : PositivityExt where eval {u α} _ _ e := do\n match e with\n | ~q(@radical _ $inst $inst' $inst'' $n) =>\n have _ := ← synthInstanceQ q(Nontrivial $α)\n assertInstancesCommute\n return .nonzero q(radical_ne_zero)\n | _ => throwError \"not radical\"\n\nexample : 0 < radical 100 := by positivity\n\nend Mathlib.Meta.Positivity\n\nend Nat\n\n/-! ### Lemmas about integers -/\n\nvariable {z : ℤ}\n\nlemma UniqueFactorizationMonoid.primeFactors_eq_primeFactors_natAbs :\n primeFactors z = z.natAbs.primeFactors.map Nat.castEmbedding := by\n obtain rfl | hz := eq_or_ne z 0; · simp\n ext p\n rw [mem_primeFactors, mem_normalizedFactors_iff' hz, irreducible_iff_prime,\n Int.nonneg_iff_normalize_eq_self, Finset.mem_map, Function.Embedding.coeFn_mk]\n refine ⟨fun ⟨pp, nnp, dp⟩ ↦ ?_, fun h ↦ ?_⟩\n · lift p to ℕ using nnp\n rw [← Nat.prime_iff_prime_int] at pp\n rw [Int.natCast_dvd] at dp\n exact ⟨p, by simp_all, rfl⟩\n · simp_rw [Nat.mem_primeFactors, Function.Embedding.toFun_eq_coe, Nat.castEmbedding_apply] at h\n obtain ⟨n, ⟨pn, dn, -⟩, rfl⟩ := h\n rw [Int.natCast_dvd, ← Nat.prime_iff_prime_int]\n exact ⟨pn, by simp, dn⟩\n\nnamespace Int\n\n@[simp] lemma radical_natAbs_eq_radical : radical z.natAbs = radical z := by\n rw [Nat.radical_eq_prod_primeFactors, radical]\n simp [primeFactors_eq_primeFactors_natAbs]\n\nlemma radical_eq_prod_primeFactors : radical z = ∏ p ∈ z.natAbs.primeFactors, p := by\n rw [← radical_natAbs_eq_radical, Nat.radical_eq_prod_primeFactors]\n\nTarget:\nlemma radical_pos (z : ℤ) : 0 < radical z :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Radical","family_id":"radical_pos","file_id":"mathlib/Mathlib/RingTheory/Radical/NatInt.lean","sample_id":"c641c3a440e74e4625110563d50a864df264ff1a4060896fd5801c4b02e1cdbf"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"411a5bfe7dfec463be4c77a8daf57a2d4eb6f232a55e44356ce54600db8f639f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"9648fbea398684421d97b4a243c69910d96408272f4d0818f549a44c2cd46c30","source_sha256":"fc0ac08ee048884ba7583061a8f6eb20240cc276d11413f308115f01831f8e03","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n by_cases hRS : Function.Injective (algebraMap R S)\n on_goal 2 => exact (Algebra.isAlgebraic_of_not_injective\n fun h ↦ hRS <| .of_comp (IsScalarTower.algebraMap_eq R S A ▸ h)).1 _\n have := hRS.noZeroDivisors _ (map_zero _) (map_mul _)\n have ⟨s, hs, int_s⟩ := h.exists_integral_multiple\n cases subsingleton_or_nontrivial R\n · have := Module.subsingleton R S\n exact (is_transcendental_of_subsingleton _ _ h).elim\n have ⟨r, hr, _, e⟩ := (int.1 s).isAlgebraic.exists_nonzero_dvd (mem_nonZeroDivisors_of_ne_zero hs)\n refine .of_smul_isIntegral (y := r) (by rwa [isNilpotent_iff_eq_zero]) ?_\n rw [Algebra.smul_def, IsScalarTower.algebraMap_apply R S,\n e, ← Algebra.smul_def, mul_comm, mul_smul]\n exact isIntegral_trans _ (int_s.smul _)","hard_negative":false,"metrics":{"chosen_tokens":162,"rejected_tokens":5,"token_jaccard":0.040541,"token_length_ratio":0.030864},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"f3897eecf370db320ccc396df7fff067f314a64bf375b14b67c3e7771e25fcc2","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.LinearAlgebra.Dimension.Localization\npublic import Mathlib.RingTheory.Algebraic.Basic\npublic import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic\npublic import Mathlib.RingTheory.Localization.BaseChange\nimport Mathlib.RingTheory.Polynomial.Subring\n\nNamespace:\nIsAlgebraic\n\nLocal context:\n/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Algebraic elements and integral elements\n\nThis file relates algebraic and integral elements of an algebra, by proving every integral element\nis algebraic and that every algebraic element over a field is integral.\n\n## Main results\n\n* `IsIntegral.isAlgebraic`, `Algebra.IsIntegral.isAlgebraic`: integral implies algebraic.\n* `isAlgebraic_iff_isIntegral`, `Algebra.isAlgebraic_iff_isIntegral`: integral iff algebraic\n over a field.\n* `IsAlgebraic.of_finite`, `Algebra.IsAlgebraic.of_finite`: finite-dimensional (as module) implies\n algebraic.\n* `IsAlgebraic.exists_integral_multiple`: an algebraic element has a multiple which is integral\n* `IsAlgebraic.iff_exists_smul_integral`: If `R` is reduced and `S` is an `R`-algebra with\n injective `algebraMap`, then an element of `S` is algebraic over `R` iff some `R`-multiple\n is integral over `R`.\n* `Algebra.IsAlgebraic.trans`: If `A/S/R` is a tower of algebras and both `A/S` and `S/R` are\n algebraic, then `A/R` is also algebraic, provided that `S` has no zero divisors.\n* `Subalgebra.algebraicClosure`: If `R` is a domain and `S` is an arbitrary `R`-algebra,\n then the elements of `S` that are algebraic over `R` form a subalgebra.\n* `Transcendental.extendScalars`: an element of an `R`-algebra that is transcendental over `R`\n remains transcendental over any algebraic `R`-subalgebra that has no zero divisors.\n-/\n\n@[expose] public section\n\nassert_not_exists IsLocalRing\n\nuniverse u v w\n\nopen Polynomial\n\nsection zero_ne_one\n\nvariable {R : Type u} {S : Type*} {A : Type v} [CommRing R]\nvariable [CommRing S] [Ring A] [Algebra R A] [Algebra R S] [Algebra S A]\nvariable [IsScalarTower R S A]\n\n/-- An integral element of an algebra is algebraic. -/\ntheorem IsIntegral.isAlgebraic [Nontrivial R] {x : A} : IsIntegral R x → IsAlgebraic R x :=\n fun ⟨p, hp, hpx⟩ => ⟨p, hp.ne_zero, hpx⟩\n\ninstance Algebra.IsIntegral.isAlgebraic [Nontrivial R] [Algebra.IsIntegral R A] :\n Algebra.IsAlgebraic R A := ⟨fun a ↦ (Algebra.IsIntegral.isIntegral a).isAlgebraic⟩\n\nend zero_ne_one\n\nsection Field\n\nvariable {K : Type u} {A : Type v} [Field K] [Ring A] [Algebra K A]\n\n/-- An element of an algebra over a field is algebraic if and only if it is integral. -/\ntheorem isAlgebraic_iff_isIntegral {x : A} : IsAlgebraic K x ↔ IsIntegral K x := by\n refine ⟨?_, IsIntegral.isAlgebraic⟩\n rintro ⟨p, hp, hpx⟩\n refine ⟨_, monic_mul_leadingCoeff_inv hp, ?_⟩\n rw [← aeval_def, map_mul, hpx, zero_mul]\n\nprotected theorem Algebra.isAlgebraic_iff_isIntegral :\n Algebra.IsAlgebraic K A ↔ Algebra.IsIntegral K A := by\n rw [Algebra.isAlgebraic_def, Algebra.isIntegral_def,\n forall_congr' fun _ ↦ isAlgebraic_iff_isIntegral]\n\nalias ⟨IsAlgebraic.isIntegral, _⟩ := isAlgebraic_iff_isIntegral\n\n/-- This used to be an `alias` of `Algebra.isAlgebraic_iff_isIntegral` but that would make\n`Algebra.IsAlgebraic K A` an explicit parameter instead of instance implicit. -/\nprotected instance Algebra.IsAlgebraic.isIntegral [Algebra.IsAlgebraic K A] :\n Algebra.IsIntegral K A := Algebra.isAlgebraic_iff_isIntegral.mp ‹_›\n\ntheorem Algebra.IsAlgebraic.of_isIntegralClosure (R B C : Type*) [CommRing R] [Nontrivial R]\n [CommRing B] [CommRing C] [Algebra R B] [Algebra R C] [Algebra B C]\n [IsScalarTower R B C] [IsIntegralClosure B R C] : Algebra.IsAlgebraic R B :=\n have := IsIntegralClosure.isIntegral_algebra R (A := B) C\n inferInstance\n\nend Field\n\nsection\n\nvariable (K L R : Type*) {A : Type*}\n\nsection Ring\n\nvariable [CommRing R] [Nontrivial R] [Ring A] [Algebra R A]\n\ntheorem IsAlgebraic.of_finite (e : A) [Module.Finite R A] : IsAlgebraic R e :=\n (IsIntegral.of_finite R e).isAlgebraic\n\nvariable (A)\n\n/-- A field extension is algebraic if it is finite. -/\n@[stacks 09GG \"first part\"]\ninstance Algebra.IsAlgebraic.of_finite [Module.Finite R A] : Algebra.IsAlgebraic R A :=\n (IsIntegral.of_finite R A).isAlgebraic\n\nend Ring\n\nsection Field\n\nvariable {K L} [Field K] [Ring A] [Algebra K A]\n\n/-- If `K` is a field, `r : A` and `f : K[X]`, then `Polynomial.aeval r f` is\ntranscendental over `K` if and only if `r` and `f` are both transcendental over `K`.\nSee also `Transcendental.aeval_of_transcendental` and `Transcendental.of_aeval`. -/\n@[simp]\ntheorem transcendental_aeval_iff {r : A} {f : K[X]} :\n Transcendental K (Polynomial.aeval r f) ↔ Transcendental K r ∧ Transcendental K f := by\n refine ⟨fun h ↦ ⟨?_, h.of_aeval⟩, fun ⟨h1, h2⟩ ↦ h1.aeval_of_transcendental h2⟩\n rw [Transcendental] at h ⊢\n contrapose h\n rw [isAlgebraic_iff_isIntegral] at h ⊢\n exact .of_mem_of_fg _ h.fg_adjoin_singleton _ (aeval_mem_adjoin_singleton _ _)\n\nvariable [Field L] [Algebra K L]\n\ntheorem AlgHom.bijective [FiniteDimensional K L] (ϕ : L →ₐ[K] L) : Function.Bijective ϕ :=\n (Algebra.IsAlgebraic.of_finite K L).algHom_bijective ϕ\n\nvariable (K L) in\n/-- Bijection between algebra equivalences and algebra homomorphisms -/\nnoncomputable abbrev algEquivEquivAlgHom [FiniteDimensional K L] :\n (L ≃ₐ[K] L) ≃* (L →ₐ[K] L) :=\n Algebra.IsAlgebraic.algEquivEquivAlgHom K L\n\nend Field\n\nend\n\nvariable {R S A : Type*} [CommRing R] [CommRing S] [Ring A]\nvariable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A]\nvariable {z : A} {z' : S}\n\nnamespace IsAlgebraic\n\ntheorem exists_integral_multiple (hz : IsAlgebraic R z) : ∃ y ≠ (0 : R), IsIntegral R (y • z) := by\n by_cases inj : Function.Injective (algebraMap R A); swap\n · rw [injective_iff_map_eq_zero] at inj; push Not at inj\n have ⟨r, eq, ne⟩ := inj\n exact ⟨r, ne, by simpa [← algebraMap_smul A, eq, zero_smul] using isIntegral_zero⟩\n have ⟨p, p_ne_zero, px⟩ := hz\n set a := p.leadingCoeff\n have a_ne_zero : a ≠ 0 := mt Polynomial.leadingCoeff_eq_zero.mp p_ne_zero\n have x_integral : IsIntegral R (algebraMap R A a * z) :=\n ⟨p.integralNormalization, monic_integralNormalization p_ne_zero,\n integralNormalization_aeval_eq_zero px fun _ ↦ (map_eq_zero_iff _ inj).mp⟩\n exact ⟨_, a_ne_zero, Algebra.smul_def a z ▸ x_integral⟩\n\nvariable (R) in\ntheorem _root_.Algebra.IsAlgebraic.exists_integral_multiples [NoZeroDivisors R]\n [alg : Algebra.IsAlgebraic R A] (s : Finset A) :\n ∃ y ≠ (0 : R), ∀ z ∈ s, IsIntegral R (y • z) := by\n have := Algebra.IsAlgebraic.nontrivial R A\n choose r hr int using fun x ↦ (alg.1 x).exists_integral_multiple\n refine ⟨∏ x ∈ s, r x, Finset.prod_ne_zero_iff.mpr fun _ _ ↦ hr _, fun _ h ↦ ?_⟩\n classical rw [← Finset.prod_erase_mul _ _ h, mul_smul]\n exact (int _).smul _\n\ntheorem of_smul_isIntegral {y : R} (hy : ¬ IsNilpotent y)\n (h : IsIntegral R (y • z)) : IsAlgebraic R z := by\n have ⟨p, monic, eval0⟩ := h\n refine ⟨p.comp (C y * X), fun h ↦ ?_, by simpa [aeval_comp, Algebra.smul_def] using! eval0⟩\n apply_fun (coeff · p.natDegree) at h\n have hy0 : y ≠ 0 := by rintro rfl; exact hy .zero\n rw [coeff_zero, ← mul_one p.natDegree, ← natDegree_C_mul_X y hy0,\n coeff_comp_degree_mul_degree, monic, one_mul, leadingCoeff_C_mul_X] at h\n · exact hy ⟨_, h⟩\n · rw [natDegree_C_mul_X _ hy0]; rintro ⟨⟩\n\ntheorem of_smul {y : R} (hy : y ∈ nonZeroDivisors R)\n (h : IsAlgebraic R (y • z)) : IsAlgebraic R z :=\n have ⟨p, hp, eval0⟩ := h\n ⟨_, mt (comp_C_mul_X_eq_zero_iff hy).mp hp, by simpa [aeval_comp, Algebra.smul_def] using eval0⟩\n\ntheorem iff_exists_smul_integral [IsReduced R] :\n IsAlgebraic R z ↔ ∃ y ≠ (0 : R), IsIntegral R (y • z) :=\n ⟨(exists_integral_multiple ·), fun ⟨_, hy, int⟩ ↦\n of_smul_isIntegral (by rwa [isNilpotent_iff_eq_zero]) int⟩\n\nsection integralClosure\n\nvariable {K : Type*} [CommRing K] [Algebra S K] [Algebra R K] [IsIntegralClosure S R K]\n\nvariable (S)\n\nomit [Algebra R S] in\n/-- If `x : K` is algebraic over some ring `R`, then a nonzero `R`-multiple of it is contained\nin the integral closure of `R` in `K`. -/\nlemma exists_smul_eq {x : K} (hx : IsAlgebraic R x) :\n ∃ (r : R) (s : S), r ≠ 0 ∧ r • x = algebraMap S K s := by\n obtain ⟨r, hr, h⟩ := hx.exists_integral_multiple\n obtain ⟨s, hs⟩ := IsIntegralClosure.isIntegral_iff (A := S) |>.mp h\n exact ⟨r, s, hr, hs.symm⟩\n\n/-- If `x : K` is algebraic over `ℤ`, then a nonzero `ℕ`-multiple of it is contained in the\nintegral closure of `ℤ` in `K`. -/\nlemma exists_nsmul_eq [IsIntegralClosure S ℤ K] {x : K} (hx : IsAlgebraic ℤ x) :\n ∃ (m : ℕ) (s : S), m ≠ 0 ∧ m • x = algebraMap S K s := by\n obtain ⟨a, s, ha, h⟩ := hx.exists_smul_eq S\n obtain ⟨n, rfl | rfl⟩ := a.eq_nat_or_neg\n · exact ⟨n, s, mod_cast ha, mod_cast h⟩\n · exact ⟨n, -s, by simpa using ha, by simp [← h]⟩\n\nend integralClosure\n\nsection restrictScalars\n\nvariable (R) [NoZeroDivisors S]\n\n/-!\nThe next theorem may fail if only `R` is assumed to be a domain but `S` is not: for example, let\n`S = R[X] ⧸ (X² - X)` and let `A` be the subalgebra of `S[Y]` generated by `XY`.\n`A` is algebraic over `S` because any element `∑ᵢ sᵢ(XY)ⁱ` is a root of the polynomial\n`(X - 1)(Z - s₀)` in `S[Z]`, because `X(X - 1) = X² - X = 0` in `S`.\nHowever, `XY` is a transcendental element in `A` over `R`, because `∑ᵢ rᵢ(XY)ⁱ = 0` in `S[Y]`\nimplies all `rᵢXⁱ = 0` (i.e., `r₀ = 0` and `rᵢX = 0` for `i > 0`) in `S`,\nwhich implies `rᵢ = 0` in `R`. This example is inspired by the comment\nhttps://mathoverflow.net/questions/482944/when-do-algebraic-elements-form-a-subalgebra#comment1257632_482944. -/\n\nTarget:\ntheorem restrictScalars_of_isIntegral [int : Algebra.IsIntegral R S]\n {a : A} (h : IsAlgebraic S a) : IsAlgebraic R a :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Algebraic","family_id":"restrictscalars_of_isintegral","file_id":"mathlib/Mathlib/RingTheory/Algebraic/Integral.lean","sample_id":"9648fbea398684421d97b4a243c69910d96408272f4d0818f549a44c2cd46c30"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c9dbd881a5ed47f31840c085355e71ed7e291a1211ad303c942b7229e665977","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"86265336ed7210717f68a213b1a47f0e9c086c699f4cffa880808738e4fb050d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"70715065c8baaa52e3064ea8d7edcf518d16d6d17d8c5de1a85ed448cd5718fc","source_sha256":"489e94b5a0fdc1e85b9de912615179de095084afc00e827ea680f3735104c593","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Perm.subsingleton_eq_refl e, coe_refl]","hard_negative":true,"metrics":{"chosen_tokens":10,"rejected_tokens":5,"token_jaccard":0.153846,"token_length_ratio":0.5},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"f3af138f29442b5bf0a21af922537e507bb20dd52dedfa6240abcbc963cacfd9","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.FunLike.Equiv\npublic import Mathlib.Data.Quot\npublic import Mathlib.Data.Subtype\npublic import Mathlib.Logic.Unique\npublic import Mathlib.Tactic.Simps.Basic\npublic import Mathlib.Tactic.Substs\nimport Mathlib.Tactic.Attr.Register\n\nNamespace:\nEquiv\n\nLocal context:\n/-\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/-!\n# Equivalence between types\n\nIn this file we define two types:\n\n* `Equiv α β` a.k.a. `α ≃ β`: a bijective map `α → β` bundled with its inverse map; we use this (and\n not equality!) to express that various `Type`s or `Sort`s are equivalent.\n\n* `Equiv.Perm α`: the group of permutations `α ≃ α`. More lemmas about `Equiv.Perm` can be found in\n `Mathlib/GroupTheory/Perm/`.\n\nThen we define\n\n* canonical isomorphisms between various types: e.g.,\n\n - `Equiv.refl α` is the identity map interpreted as `α ≃ α`;\n\n* operations on equivalences: e.g.,\n\n - `Equiv.symm e : β ≃ α` is the inverse of `e : α ≃ β`;\n\n - `Equiv.trans e₁ e₂ : α ≃ γ` is the composition of `e₁ : α ≃ β` and `e₂ : β ≃ γ` (note the order\n of the arguments!);\n\n* definitions that transfer some instances along an equivalence. By convention, we transfer\n instances from right to left.\n\n - `Equiv.inhabited` takes `e : α ≃ β` and `[Inhabited β]` and returns `Inhabited α`;\n - `Equiv.unique` takes `e : α ≃ β` and `[Unique β]` and returns `Unique α`;\n - `Equiv.decidableEq` takes `e : α ≃ β` and `[DecidableEq β]` and returns `DecidableEq α`.\n\n More definitions of this kind can be found in other files.\n E.g., `Mathlib/Algebra/Group/TransferInstance.lean` does it for `Group`,\n `Mathlib/Algebra/Module/TransferInstance.lean` does it for `Module`, and similar files exist for\n other algebraic type classes.\n\nMany more such isomorphisms and operations are defined in `Mathlib/Logic/Equiv/Basic.lean`.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n@[expose] public section\n\nopen Function\n\nuniverse u v w z\n\nvariable {α : Sort u} {β : Sort v} {γ : Sort w}\n\n/-- `α ≃ β` is the type of functions from `α → β` with a two-sided inverse. -/\nstructure Equiv (α : Sort*) (β : Sort _) where\n /-- The forward map of an equivalence.\n\n Do NOT use directly. Use the coercion instead. -/\n protected toFun : α → β\n /-- The backward map of an equivalence.\n\n Do NOT use `e.invFun` directly. Use the coercion of `e.symm` instead. -/\n protected invFun : β → α\n protected left_inv : LeftInverse invFun toFun := by intro; first | rfl | ext <;> rfl\n protected right_inv : RightInverse invFun toFun := by intro; first | rfl | ext <;> rfl\n\n@[inherit_doc]\ninfixl:25 \" ≃ \" => Equiv\n\n/-- Turn an element of a type `F` satisfying `EquivLike F α β` into an actual\n`Equiv`. This is declared as the default coercion from `F` to `α ≃ β`. -/\n@[coe]\ndef EquivLike.toEquiv {F} [EquivLike F α β] (f : F) : α ≃ β where\n toFun := f\n invFun := EquivLike.inv f\n left_inv := EquivLike.left_inv f\n right_inv := EquivLike.right_inv f\n\n/-- Any type satisfying `EquivLike` can be cast into `Equiv` via `EquivLike.toEquiv`. -/\ninstance {F} [EquivLike F α β] : CoeTC F (α ≃ β) :=\n ⟨EquivLike.toEquiv⟩\n\n/-- `Perm α` is the type of bijections from `α` to itself. -/\nabbrev Equiv.Perm (α : Sort*) :=\n Equiv α α\n\nnamespace Equiv\n\ninstance : EquivLike (α ≃ β) α β where\n coe := Equiv.toFun\n inv := Equiv.invFun\n left_inv := Equiv.left_inv\n right_inv := Equiv.right_inv\n coe_injective' e₁ e₂ h₁ h₂ := by cases e₁; cases e₂; congr\n\n@[simp, norm_cast]\nlemma _root_.EquivLike.coe_coe {F} [EquivLike F α β] (e : F) :\n ((e : α ≃ β) : α → β) = e := rfl\n\n@[simp, grind =] theorem coe_fn_mk (f : α → β) (g l r) : (Equiv.mk f g l r : α → β) = f :=\n rfl\n\n/-- The map `(r ≃ s) → (r → s)` is injective. -/\ntheorem coe_fn_injective : @Function.Injective (α ≃ β) (α → β) (fun e => e) :=\n DFunLike.coe_injective\n\nprotected theorem coe_inj {e₁ e₂ : α ≃ β} : (e₁ : α → β) = e₂ ↔ e₁ = e₂ :=\n @DFunLike.coe_fn_eq _ _ _ _ e₁ e₂\n\n@[ext, grind ext] theorem ext {f g : Equiv α β} (H : ∀ x, f x = g x) : f = g := DFunLike.ext f g H\n\nprotected theorem congr_arg {f : Equiv α β} {x x' : α} : x = x' → f x = f x' :=\n DFunLike.congr_arg f\n\nprotected theorem congr_fun {f g : Equiv α β} (h : f = g) (x : α) : f x = g x :=\n DFunLike.congr_fun h x\n\n@[ext] theorem Perm.ext {σ τ : Equiv.Perm α} (H : ∀ x, σ x = τ x) : σ = τ := Equiv.ext H\n\nprotected theorem Perm.congr_arg {f : Equiv.Perm α} {x x' : α} : x = x' → f x = f x' :=\n Equiv.congr_arg\n\nprotected theorem Perm.congr_fun {f g : Equiv.Perm α} (h : f = g) (x : α) : f x = g x :=\n Equiv.congr_fun h x\n\n/-- Any type is equivalent to itself. -/\n@[refl] protected def refl (α : Sort*) : α ≃ α := ⟨id, id, fun _ => rfl, fun _ => rfl⟩\n\ninstance inhabited' : Inhabited (α ≃ α) := ⟨Equiv.refl α⟩\n\n/-- Inverse of an equivalence `e : α ≃ β`. -/\n@[symm]\nprotected def symm (e : α ≃ β) : β ≃ α := ⟨e.invFun, e.toFun, e.right_inv, e.left_inv⟩\n\n/-- See Note [custom simps projection] -/\ndef Simps.symm_apply (e : α ≃ β) : β → α := e.symm\n\ninitialize_simps_projections Equiv (toFun → apply, invFun → symm_apply)\n\n/-- Restatement of `Equiv.left_inv` in terms of `Function.LeftInverse`. -/\ntheorem left_inv' (e : α ≃ β) : Function.LeftInverse e.symm e := e.left_inv\n/-- Restatement of `Equiv.right_inv` in terms of `Function.RightInverse`. -/\ntheorem right_inv' (e : α ≃ β) : Function.RightInverse e.symm e := e.right_inv\n\n@[simp] lemma symm_mk (f : α → β) (g hl hr) : (mk f g hl hr).symm = mk g f hr hl := rfl\n\n/-- Composition of equivalences `e₁ : α ≃ β` and `e₂ : β ≃ γ`. -/\n@[trans]\nprotected def trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=\n ⟨e₂ ∘ e₁, e₁.symm ∘ e₂.symm, e₂.left_inv.comp e₁.left_inv, e₂.right_inv.comp e₁.right_inv⟩\n\n@[simps]\ninstance : Trans Equiv Equiv Equiv where\n trans := Equiv.trans\n\n/-- `Equiv.symm` defines an equivalence between `α ≃ β` and `β ≃ α`. -/\n@[simps! (attr := grind =)]\ndef symmEquiv (α β : Sort*) : (α ≃ β) ≃ (β ≃ α) where\n toFun := .symm\n invFun := .symm\n\n@[simp, mfld_simps] theorem toFun_as_coe (e : α ≃ β) : e.toFun = e := rfl\n\n@[simp, mfld_simps] theorem invFun_as_coe (e : α ≃ β) : e.invFun = e.symm := rfl\n\nprotected theorem injective (e : α ≃ β) : Injective e := EquivLike.injective e\n\nprotected theorem surjective (e : α ≃ β) : Surjective e := EquivLike.surjective e\n\nprotected theorem bijective (e : α ≃ β) : Bijective e := EquivLike.bijective e\n\nprotected theorem subsingleton (e : α ≃ β) [Subsingleton β] : Subsingleton α :=\n e.injective.subsingleton\n\nprotected theorem subsingleton.symm (e : α ≃ β) [Subsingleton α] : Subsingleton β :=\n e.symm.injective.subsingleton\n\ntheorem subsingleton_congr (e : α ≃ β) : Subsingleton α ↔ Subsingleton β :=\n ⟨fun _ => e.symm.subsingleton, fun _ => e.subsingleton⟩\n\ninstance equiv_subsingleton_cod [Subsingleton β] : Subsingleton (α ≃ β) :=\n ⟨fun _ _ => Equiv.ext fun _ => Subsingleton.elim _ _⟩\n\ninstance equiv_subsingleton_dom [Subsingleton α] : Subsingleton (α ≃ β) :=\n ⟨fun f _ => Equiv.ext fun _ => @Subsingleton.elim _ (Equiv.subsingleton.symm f) _ _⟩\n\ninstance permUnique [Subsingleton α] : Unique (Perm α) :=\n uniqueOfSubsingleton (Equiv.refl α)\n\ntheorem Perm.subsingleton_eq_refl [Subsingleton α] (e : Perm α) : e = Equiv.refl α :=\n Subsingleton.elim _ _\n\nprotected theorem nontrivial {α β} (e : α ≃ β) [Nontrivial β] : Nontrivial α :=\n e.surjective.nontrivial\n\ntheorem nontrivial_congr {α β} (e : α ≃ β) : Nontrivial α ↔ Nontrivial β :=\n ⟨fun _ ↦ e.symm.nontrivial, fun _ ↦ e.nontrivial⟩\n\n/-- Transfer `DecidableEq` across an equivalence. -/\nprotected abbrev decidableEq (e : α ≃ β) [DecidableEq β] : DecidableEq α :=\n e.injective.decidableEq\n\ntheorem nonempty_congr (e : α ≃ β) : Nonempty α ↔ Nonempty β := Nonempty.congr e e.symm\n\nprotected theorem nonempty (e : α ≃ β) [Nonempty β] : Nonempty α := e.nonempty_congr.mpr ‹_›\n\n/-- If `α ≃ β` and `β` is inhabited, then so is `α`. -/\nprotected abbrev inhabited [Inhabited β] (e : α ≃ β) : Inhabited α := ⟨e.symm default⟩\n\n/-- If `α ≃ β` and `β` is a singleton type, then so is `α`. -/\nprotected abbrev unique [Unique β] (e : α ≃ β) : Unique α := e.symm.surjective.unique\n\n/-- Equivalence between equal types. -/\nprotected def cast {α β : Sort _} (h : α = β) : α ≃ β where\n toFun := cast h\n invFun := cast h.symm\n left_inv := by grind\n right_inv := by grind\n\n@[simp] theorem coe_fn_symm_mk (f : α → β) (g l r) : ((Equiv.mk f g l r).symm : β → α) = g := rfl\n\n@[simp] theorem coe_refl : (Equiv.refl α : α → α) = id := rfl\n\n/-- This cannot be a `simp` lemmas as it incorrectly matches against `e : α ≃ synonym α`, when\n`synonym α` is semireducible. This makes a mess of `Multiplicative.ofAdd` etc. -/\n\nTarget:\ntheorem Perm.coe_subsingleton {α : Type*} [Subsingleton α] (e : Perm α) : (e : α → α) = id :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_70715065c8ba","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"3e05ecd0fb2d7432ea56fdef2c020342de7b843c59c9dd7c7fd0aa74074c6b9f","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Logic/Equiv","family_id":"perm","file_id":"mathlib/Mathlib/Logic/Equiv/Defs.lean","sample_id":"70715065c8baaa52e3064ea8d7edcf518d16d6d17d8c5de1a85ed448cd5718fc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d62c14bdae60057b28370351a0b86a71b3c2207758aa2837b15ccae4509ec197","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"c9d53b75ff94d9ba91ecd885af73f8533c42e1c175a62180c1762b72f137eff3","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"76b153c82addb4b4abe8baeee56a920e4e2f119e3ed0118bf67b947a0ced663a","source_sha256":"4449401fdf20870ca4f9ac299173a0357ae475a7bad6ab7ca2a374a91c09001b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨d, rfl⟩ := h\n use d\n rw [mul_assoc]","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":2,"token_jaccard":0.066667,"token_length_ratio":0.133333},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"admit","pair_id":"f4fc2f0d8c8a55cb7d24fcd8173856364bcc78c7e5dc389fa5a6d1267a9ca211","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Basic\npublic import Mathlib.Tactic.Common\npublic import Batteries.Tactic.SeqFocus\n\nNamespace:\n(root)\n\nLocal context:\n/-\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, Amelia Livingston, Yury Kudryashov,\nNeil Strickland, Aaron Anderson\n-/\n/-!\n# Divisibility\n\nThis file defines the basics of the divisibility relation in the context of `(Comm)` `Monoid`s.\n\n## Main definitions\n\n* `semigroupDvd`\n\n## Implementation notes\n\nThe divisibility relation is defined for all monoids, and as such, depends on the order of\n multiplication if the monoid is not commutative. There are two possible conventions for\n divisibility in the noncommutative context, and this relation follows the convention for ordinals,\n so `a | b` is defined as `∃ c, b = a * c`.\n\n## Tags\n\ndivisibility, divides\n-/\n\n@[expose] public section\n\n\nvariable {α : Type*}\n\nsection Semigroup\n\nvariable [Semigroup α] {a b c : α}\n\n/-- There are two possible conventions for divisibility, which coincide in a `CommMonoid`.\nThis matches the convention for ordinals. -/\ninstance (priority := 100) semigroupDvd : Dvd α :=\n Dvd.mk fun a b => ∃ c, b = a * c\n\n-- TODO: this used to not have `c` explicit, but that seems to be important\n-- for use with tactics, similar to `Exists.intro`\ntheorem Dvd.intro (c : α) (h : a * c = b) : a ∣ b :=\n Exists.intro c h.symm\n\nalias dvd_of_mul_right_eq := Dvd.intro\n\ntheorem exists_eq_mul_right_of_dvd (h : a ∣ b) : ∃ c, b = a * c :=\n h\n\ntheorem dvd_def : a ∣ b ↔ ∃ c, b = a * c :=\n Iff.rfl\n\nalias dvd_iff_exists_eq_mul_right := dvd_def\n\ntheorem Dvd.elim {P : Prop} {a b : α} (H₁ : a ∣ b) (H₂ : ∀ c, b = a * c → P) : P :=\n Exists.elim H₁ H₂\n\nattribute [local simp] mul_assoc mul_comm mul_left_comm\n\n@[trans]\ntheorem dvd_trans : a ∣ b → b ∣ c → a ∣ c\n | ⟨d, h₁⟩, ⟨e, h₂⟩ => ⟨d * e, h₁ ▸ h₂.trans <| mul_assoc a d e⟩\n\nalias Dvd.dvd.trans := dvd_trans\n\n/-- Transitivity of `|` for use in `calc` blocks. -/\ninstance : IsTrans α Dvd.dvd :=\n ⟨fun _ _ _ => dvd_trans⟩\n\n@[simp]\ntheorem dvd_mul_right (a b : α) : a ∣ a * b :=\n Dvd.intro b rfl\n\ntheorem dvd_mul_of_dvd_left (h : a ∣ b) (c : α) : a ∣ b * c :=\n h.trans (dvd_mul_right b c)\n\nalias Dvd.dvd.mul_right := dvd_mul_of_dvd_left\n\ntheorem dvd_of_mul_right_dvd (h : a * b ∣ c) : a ∣ c :=\n (dvd_mul_right a b).trans h\n\n/-- An element `a` in a semigroup is primal if whenever `a` is a divisor of `b * c`, it can be\nfactored as the product of a divisor of `b` and a divisor of `c`. -/\ndef IsPrimal (a : α) : Prop := ∀ ⦃b c⦄, a ∣ b * c → ∃ a₁ a₂, a₁ ∣ b ∧ a₂ ∣ c ∧ a = a₁ * a₂\n\nvariable (α) in\n/-- A monoid is a decomposition monoid if every element is primal. An integral domain whose\nmultiplicative monoid is a decomposition monoid, is called a pre-Schreier domain; it is a\nSchreier domain if it is moreover integrally closed. -/\n@[mk_iff] class DecompositionMonoid : Prop where\n primal (a : α) : IsPrimal a\n\ntheorem exists_dvd_and_dvd_of_dvd_mul [DecompositionMonoid α] {b c a : α} (H : a ∣ b * c) :\n ∃ a₁ a₂, a₁ ∣ b ∧ a₂ ∣ c ∧ a = a₁ * a₂ := DecompositionMonoid.primal a H\n\n@[gcongr]\n\nTarget:\ntheorem mul_dvd_mul_left (a : α) (h : b ∣ c) : a * b ∣ a * c :=\n\nProof body:\n","rejected":"by\n admit","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Divisibility","family_id":"mul_dvd_mul_left","file_id":"mathlib/Mathlib/Algebra/Divisibility/Basic.lean","sample_id":"76b153c82addb4b4abe8baeee56a920e4e2f119e3ed0118bf67b947a0ced663a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"169443bd50fb3007af7ae30e31b0786d51408d48fbbf5619398e4e891414f8f7","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"09acf3e9d3ef455b83bf3d9b6cc4ce6b3f308b4071a2b1c3951a771cba763403","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0c6985683c5f2680db7766ea60023550d843b5f77c91fdc3643720dcc0a5e17a","source_sha256":"9eb3a898d17f149f89609c4384085a509c1a0c8bba0a0563578a9597f032ec50","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [eventually_atTop]\n obtain ⟨n, terminatedAt_n⟩ : ∃ n, (of v).TerminatedAt n := terminates\n use n\n intro m m_geq_n\n rw [convs_stable_of_terminated m_geq_n terminatedAt_n]\n exact of_correctness_of_terminatedAt terminatedAt_n","hard_negative":true,"metrics":{"chosen_tokens":38,"rejected_tokens":3,"token_jaccard":0.068966,"token_length_ratio":0.078947},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"f521e04f7a854feb7e1c75dfd3764935701c03a6fdae124c4d2f3c5420ff1323","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.ContinuedFractions.Computation.Translations\npublic import Mathlib.Algebra.ContinuedFractions.TerminatedStable\npublic import Mathlib.Algebra.ContinuedFractions.ContinuantsRecurrence\npublic import Mathlib.Order.Filter.AtTopBot.Basic\npublic import Mathlib.Tactic.FieldSimp\npublic import Mathlib.Tactic.Ring\n\nNamespace:\nGenContFract\n\nLocal context:\n/-\nCopyright (c) 2020 Kevin Kappelmann. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Kappelmann\n-/\n/-!\n# Correctness of Terminating Continued Fraction Computations (`GenContFract.of`)\n\n## Summary\n\nWe show the correctness of the algorithm computing continued fractions (`GenContFract.of`)\nin case of termination in the following sense:\n\nAt every step `n : ℕ`, we can obtain the value `v` by adding a specific residual term to the last\ndenominator of the fraction described by `(GenContFract.of v).convs' n`.\nThe residual term will be zero exactly when the continued fraction terminated; otherwise, the\nresidual term will be given by the fractional part stored in `GenContFract.IntFractPair.stream v n`.\n\nFor an example, refer to\n`GenContFract.compExactValue_correctness_of_stream_eq_some` and for more\ninformation about the computation process, refer to `Algebra.ContinuedFractions.Computation.Basic`.\n\n## Main definitions\n\n- `GenContFract.compExactValue` can be used to compute the exact value approximated by the\n continued fraction `GenContFract.of v` by adding a residual term as described in the summary.\n\n## Main Theorems\n\n- `GenContFract.compExactValue_correctness_of_stream_eq_some` shows that\n `GenContFract.compExactValue` indeed returns the value `v` when given the convergent and\n fractional part as described in the summary.\n- `GenContFract.of_correctness_of_terminatedAt` shows the equality\n `v = (GenContFract.of v).convs n` if `GenContFract.of v` terminated at position `n`.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nnamespace GenContFract\n\nopen GenContFract (of)\n\n-- `compExactValue_correctness_of_stream_eq_some` does not trivially generalize to `DivisionRing`\nvariable {K : Type*} [Field K] [LinearOrder K] {v : K} {n : ℕ}\n\n/-- Given two continuants `pconts` and `conts` and a value `fr`, this function returns\n- `conts.a / conts.b` if `fr = 0`\n- `exactConts.a / exactConts.b` where `exactConts = nextConts 1 fr⁻¹ pconts conts`\n otherwise.\n\nThis function can be used to compute the exact value approximated by a continued fraction\n`GenContFract.of v` as described in lemma `compExactValue_correctness_of_stream_eq_some`.\n-/\nprotected def compExactValue (pconts conts : Pair K) (fr : K) : K :=\n -- if the fractional part is zero, we exactly approximated the value by the last continuants\n if fr = 0 then\n conts.a / conts.b\n else -- otherwise, we have to include the fractional part in a final continuants step.\n letI exactConts := nextConts 1 fr⁻¹ pconts conts\n exactConts.a / exactConts.b\n\nvariable [FloorRing K]\n\n/-- Just a computational lemma we need for the next main proof. -/\nprotected theorem compExactValue_correctness_of_stream_eq_some_aux_comp {a : K} (b c : K)\n (fract_a_ne_zero : Int.fract a ≠ 0) :\n ((⌊a⌋ : K) * b + c) / Int.fract a + b = (b * a + c) / Int.fract a := by\n field_simp\n rw [Int.fract]\n ring\n\nopen GenContFract\n (compExactValue compExactValue_correctness_of_stream_eq_some_aux_comp)\n\n/-- Shows the correctness of `compExactValue` in case the continued fraction\n`GenContFract.of v` did not terminate at position `n`. That is, we obtain the\nvalue `v` if we pass the two successive (auxiliary) continuants at positions `n` and `n + 1` as well\nas the fractional part at `IntFractPair.stream n` to `compExactValue`.\n\nThe correctness might be seen more readily if one uses `convs'` to evaluate the continued\nfraction. Here is an example to illustrate the idea:\n\nLet `(v : ℚ) := 3.4`. We have\n- `GenContFract.IntFractPair.stream v 0 = some ⟨3, 0.4⟩`, and\n- `GenContFract.IntFractPair.stream v 1 = some ⟨2, 0.5⟩`.\n\nNow `(GenContFract.of v).convs' 1 = 3 + 1/2`, and our fractional term at position `2` is `0.5`.\nWe hence have `v = 3 + 1/(2 + 0.5) = 3 + 1/2.5 = 3.4`.\nThis computation corresponds exactly to the one using the recurrence equation in `compExactValue`.\n-/\ntheorem compExactValue_correctness_of_stream_eq_some :\n ∀ {ifp_n : IntFractPair K}, IntFractPair.stream v n = some ifp_n →\n v = compExactValue ((of v).contsAux n) ((of v).contsAux <| n + 1) ifp_n.fr := by\n let g := of v\n induction n with\n | zero =>\n intro ifp_zero stream_zero_eq\n obtain rfl : IntFractPair.of v = ifp_zero := by\n simpa only [IntFractPair.stream, Option.some.injEq] using stream_zero_eq\n cases eq_or_ne (Int.fract v) 0 with\n | inl fract_eq_zero =>\n -- Int.fract v = 0; we must then have `v = ⌊v⌋`\n suffices v = ⌊v⌋ by\n simpa [compExactValue, IntFractPair.of, fract_eq_zero]\n calc\n v = Int.fract v + ⌊v⌋ := by rw [Int.fract_add_floor]\n _ = ⌊v⌋ := by simp [fract_eq_zero]\n | inr fract_ne_zero =>\n -- Int.fract v ≠ 0; the claim then easily follows by unfolding a single computation step\n simp [field, contsAux, nextConts, nextNum, nextDen, of_h_eq_floor, compExactValue,\n IntFractPair.of, fract_ne_zero]\n | succ n IH =>\n intro ifp_succ_n succ_nth_stream_eq\n obtain ⟨ifp_n, nth_stream_eq, nth_fract_ne_zero, -⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧\n ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=\n IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq\n -- introduce some notation\n let conts := g.contsAux (n + 2)\n set pconts := g.contsAux (n + 1) with pconts_eq\n set ppconts := g.contsAux n with ppconts_eq\n cases eq_or_ne ifp_succ_n.fr 0 with\n | inl ifp_succ_n_fr_eq_zero =>\n -- ifp_succ_n.fr = 0\n suffices v = conts.a / conts.b by simpa [compExactValue, ifp_succ_n_fr_eq_zero]\n -- use the IH and the fact that ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ to prove this case\n obtain ⟨ifp_n', nth_stream_eq', ifp_n_fract_inv_eq_floor⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ :=\n IntFractPair.exists_succ_nth_stream_of_fr_zero succ_nth_stream_eq ifp_succ_n_fr_eq_zero\n obtain rfl : ifp_n = ifp_n' := by injection Eq.trans nth_stream_eq.symm nth_stream_eq'\n have s_nth_eq : g.s.get? n = some ⟨1, ⌊ifp_n.fr⁻¹⌋⟩ :=\n get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero nth_stream_eq nth_fract_ne_zero\n rw [← ifp_n_fract_inv_eq_floor] at s_nth_eq\n suffices v = compExactValue ppconts pconts ifp_n.fr by\n simpa [conts, contsAux, s_nth_eq, compExactValue, nth_fract_ne_zero] using this\n exact IH nth_stream_eq\n | inr ifp_succ_n_fr_ne_zero =>\n -- ifp_succ_n.fr ≠ 0\n -- use the IH to show that the following equality suffices\n suffices\n compExactValue ppconts pconts ifp_n.fr = compExactValue pconts conts ifp_succ_n.fr by grind\n -- get the correspondence between ifp_n and ifp_succ_n\n obtain ⟨ifp_n', nth_stream_eq', ifp_n_fract_ne_zero, ⟨rfl⟩⟩ :\n ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧\n ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n :=\n IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq\n obtain rfl : ifp_n = ifp_n' := by injection Eq.trans nth_stream_eq.symm nth_stream_eq'\n -- get the correspondence between ifp_n and g.s.nth n\n have s_nth_eq : g.s.get? n = some ⟨1, (⌊ifp_n.fr⁻¹⌋ : K)⟩ :=\n get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero nth_stream_eq ifp_n_fract_ne_zero\n -- the claim now follows by unfolding the definitions and tedious calculations\n -- some shorthand notation\n let ppA := ppconts.a\n let ppB := ppconts.b\n let pA := pconts.a\n let pB := pconts.b\n have : compExactValue ppconts pconts ifp_n.fr =\n (ppA + ifp_n.fr⁻¹ * pA) / (ppB + ifp_n.fr⁻¹ * pB) := by\n -- unfold compExactValue and the convergent computation once\n grind [compExactValue, nextConts, nextNum, nextDen]\n rw [this]\n -- two calculations needed to show the claim\n have tmp_calc :=\n compExactValue_correctness_of_stream_eq_some_aux_comp pA ppA ifp_succ_n_fr_ne_zero\n have tmp_calc' :=\n compExactValue_correctness_of_stream_eq_some_aux_comp pB ppB ifp_succ_n_fr_ne_zero\n let f := Int.fract (1 / ifp_n.fr)\n -- now unfold the recurrence one step and simplify both sides to arrive at the conclusion\n dsimp only [conts, pconts, ppconts]\n have hfr : (IntFractPair.of (1 / ifp_n.fr)).fr = f := rfl\n simp [compExactValue, contsAux_recurrence s_nth_eq ppconts_eq pconts_eq,\n nextConts, nextNum, nextDen]\n grind\n\nopen GenContFract (of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none)\n\n/-- The convergent of `GenContFract.of v` at step `n - 1` is exactly `v` if the\n`IntFractPair.stream` of the corresponding continued fraction terminated at step `n`. -/\ntheorem of_correctness_of_nth_stream_eq_none (nth_stream_eq_none : IntFractPair.stream v n = none) :\n v = (of v).convs (n - 1) := by\n induction n with\n | zero => contradiction\n -- IntFractPair.stream v 0 ≠ none\n | succ n IH =>\n let g := of v\n change v = g.convs n\n obtain ⟨nth_stream_eq_none⟩ | ⟨ifp_n, nth_stream_eq, nth_stream_fr_eq_zero⟩ :\n IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 :=\n IntFractPair.succ_nth_stream_eq_none_iff.1 nth_stream_eq_none\n · cases n with\n | zero => contradiction\n | succ n' =>\n -- IntFractPair.stream v 0 ≠ none\n have : g.TerminatedAt n' :=\n of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none.2\n nth_stream_eq_none\n have : g.convs (n' + 1) = g.convs n' :=\n convs_stable_of_terminated n'.le_succ this\n rw [this]\n exact IH nth_stream_eq_none\n · simpa [nth_stream_fr_eq_zero, compExactValue] using!\n compExactValue_correctness_of_stream_eq_some nth_stream_eq\n\n/-- If `GenContFract.of v` terminated at step `n`, then the `n`th convergent is exactly `v`. -/\ntheorem of_correctness_of_terminatedAt (terminatedAt_n : (of v).TerminatedAt n) :\n v = (of v).convs n :=\n have : IntFractPair.stream v (n + 1) = none :=\n of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none.1 terminatedAt_n\n of_correctness_of_nth_stream_eq_none this\n\n/-- If `GenContFract.of v` terminates, then there is `n : ℕ` such that the `n`th convergent is\nexactly `v`.\n-/\ntheorem of_correctness_of_terminates (terminates : (of v).Terminates) :\n ∃ n : ℕ, v = (of v).convs n :=\n Exists.elim terminates fun n terminatedAt_n =>\n Exists.intro n (of_correctness_of_terminatedAt terminatedAt_n)\n\nopen Filter\n\n/-- If `GenContFract.of v` terminates, then its convergents will eventually always be `v`. -/\n\nTarget:\ntheorem of_correctness_atTop_of_terminates (terminates : (of v).Terminates) :\n ∀ᶠ n in atTop, v = (of v).convs n :=\n\nProof body:\n","rejected":"by\n exact of_correctness_atTop_of_terminates","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"62b9174a0a2f39e0e11ddbaeb2400bc7b0b5719a30089a4d282d599e66da2b8e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/ContinuedFractions","family_id":"of_correctness_attop_of_terminates","file_id":"mathlib/Mathlib/Algebra/ContinuedFractions/Computation/CorrectnessTerminating.lean","sample_id":"0c6985683c5f2680db7766ea60023550d843b5f77c91fdc3643720dcc0a5e17a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f5e1a01169553de0e268c2d9fa23ab619e6ea420b718a07f31006bc810b0837c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e67fbd8fa7119d4589c790cca327cd3cc10be94a9ff804cf1a763f257fd55a16","source_sha256":"b24eb617305399f294446a5c66b94cf584b9f3b9c862321e20281c76b3bd96da","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [mul_comm] at h\n exact h.of_add_mul_left_right","hard_negative":false,"metrics":{"chosen_tokens":11,"rejected_tokens":2,"token_jaccard":0.090909,"token_length_ratio":0.181818},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"f58ae908d524f2f5b9abf295132362038378c7d4beb256bab3eab90052f95885","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Units\npublic import Mathlib.Algebra.Group.Nat.Units\npublic import Mathlib.Algebra.GroupWithZero.Associated\npublic import Mathlib.Algebra.Ring.Divisibility.Basic\npublic import Mathlib.Algebra.Ring.Hom.Defs\npublic import Mathlib.Logic.Basic\npublic import Mathlib.Tactic.CrossRefAttribute\npublic import Mathlib.Tactic.Ring\n\nNamespace:\n(root)\n\nLocal context:\n/-\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-/\n/-!\n# Coprime elements of a ring or monoid\n\n## Main definition\n\n* `IsCoprime x y`: that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\n that `a * x + b * y = 1`. Note that elements with no common divisors (`IsRelPrime`) are not\n necessarily coprime, e.g., the multivariate polynomials `x₁` and `x₂` are not coprime.\n The two notions are equivalent in Bézout rings, see `isRelPrime_iff_isCoprime`.\n\nThis file also contains lemmas about `IsRelPrime` parallel to `IsCoprime`.\n\nSee also `RingTheory.Coprime.Lemmas` for further development of coprime elements.\n-/\n\n@[expose] public section\n\n\nuniverse u v\n\nsection CommSemiring\n\nvariable {R : Type u} [CommSemiring R] (x y z w : R)\n\n/-- The proposition that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\nthat `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,\ne.g., the multivariate polynomials `x₁` and `x₂` are not coprime. -/\n@[wikidata Q104752]\ndef IsCoprime : Prop :=\n ∃ a b, a * x + b * y = 1\n\nvariable {x y z w}\n\n@[symm]\ntheorem IsCoprime.symm (H : IsCoprime x y) : IsCoprime y x :=\n let ⟨a, b, H⟩ := H\n ⟨b, a, by rw [add_comm, H]⟩\n\ntheorem isCoprime_comm : IsCoprime x y ↔ IsCoprime y x :=\n ⟨IsCoprime.symm, IsCoprime.symm⟩\n\ntheorem isCoprime_self : IsCoprime x x ↔ IsUnit x :=\n ⟨fun ⟨a, b, h⟩ => .of_mul_eq_one (a + b) <| by rwa [mul_comm, add_mul], fun h =>\n let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 h\n ⟨b, 0, by rwa [zero_mul, add_zero]⟩⟩\n\ntheorem isCoprime_zero_left : IsCoprime 0 x ↔ IsUnit x :=\n ⟨fun ⟨a, b, H⟩ => .of_mul_eq_one b <| by rwa [mul_zero, zero_add, mul_comm] at H, fun H =>\n let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 H\n ⟨1, b, by rwa [one_mul, zero_add]⟩⟩\n\ntheorem isCoprime_zero_right : IsCoprime x 0 ↔ IsUnit x :=\n isCoprime_comm.trans isCoprime_zero_left\n\ntheorem not_isCoprime_zero_zero [Nontrivial R] : ¬IsCoprime (0 : R) 0 :=\n mt isCoprime_zero_right.mp not_isUnit_zero\n\nlemma IsCoprime.intCast {R : Type*} [CommRing R] {a b : ℤ} (h : IsCoprime a b) :\n IsCoprime (a : R) (b : R) := by\n rcases h with ⟨u, v, H⟩\n use u, v\n rw_mod_cast [H]\n exact Int.cast_one\n\n/-- If a 2-vector `p` satisfies `IsCoprime (p 0) (p 1)`, then `p ≠ 0`. -/\ntheorem IsCoprime.ne_zero [Nontrivial R] {p : Fin 2 → R} (h : IsCoprime (p 0) (p 1)) : p ≠ 0 := by\n rintro rfl\n exact not_isCoprime_zero_zero h\n\ntheorem IsCoprime.ne_zero_or_ne_zero [Nontrivial R] (h : IsCoprime x y) : x ≠ 0 ∨ y ≠ 0 := by\n apply not_or_of_imp\n rintro rfl rfl\n exact not_isCoprime_zero_zero h\n\ntheorem isCoprime_one_left : IsCoprime 1 x :=\n ⟨1, 0, by rw [one_mul, zero_mul, add_zero]⟩\n\ntheorem isCoprime_one_right : IsCoprime x 1 :=\n ⟨0, 1, by rw [one_mul, zero_mul, zero_add]⟩\n\ntheorem IsCoprime.dvd_of_dvd_mul_right (H1 : IsCoprime x z) (H2 : x ∣ y * z) : x ∣ y := by\n let ⟨a, b, H⟩ := H1\n rw [← mul_one y, ← H, mul_add, ← mul_assoc, mul_left_comm]\n exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)\n\ntheorem IsCoprime.dvd_of_dvd_mul_left (H1 : IsCoprime x y) (H2 : x ∣ y * z) : x ∣ z := by\n let ⟨a, b, H⟩ := H1\n rw [← one_mul z, ← H, add_mul, mul_right_comm, mul_assoc b]\n exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)\n\ntheorem IsCoprime.mul_left (H1 : IsCoprime x z) (H2 : IsCoprime y z) : IsCoprime (x * y) z :=\n let ⟨a, b, h1⟩ := H1\n let ⟨c, d, h2⟩ := H2\n ⟨a * c, a * x * d + b * c * y + b * d * z,\n calc a * c * (x * y) + (a * x * d + b * c * y + b * d * z) * z\n _ = (a * x + b * z) * (c * y + d * z) := by ring\n _ = 1 := by rw [h1, h2, mul_one]\n ⟩\n\ntheorem IsCoprime.mul_right (H1 : IsCoprime x y) (H2 : IsCoprime x z) : IsCoprime x (y * z) := by\n rw [isCoprime_comm] at H1 H2 ⊢\n exact H1.mul_left H2\n\ntheorem IsCoprime.mul_dvd (H : IsCoprime x y) (H1 : x ∣ z) (H2 : y ∣ z) : x * y ∣ z := by\n obtain ⟨a, b, h⟩ := H\n rw [← mul_one z, ← h, mul_add]\n apply dvd_add\n · rw [mul_comm z, mul_assoc]\n exact (mul_dvd_mul_left _ H2).mul_left _\n · rw [mul_comm b, ← mul_assoc]\n exact (mul_dvd_mul_right H1 _).mul_right _\n\ntheorem IsCoprime.of_mul_left_left (H : IsCoprime (x * y) z) : IsCoprime x z :=\n let ⟨a, b, h⟩ := H\n ⟨a * y, b, by rwa [mul_right_comm, mul_assoc]⟩\n\ntheorem IsCoprime.of_mul_left_right (H : IsCoprime (x * y) z) : IsCoprime y z := by\n rw [mul_comm] at H\n exact H.of_mul_left_left\n\ntheorem IsCoprime.of_mul_right_left (H : IsCoprime x (y * z)) : IsCoprime x y := by\n rw [isCoprime_comm] at H ⊢\n exact H.of_mul_left_left\n\ntheorem IsCoprime.of_mul_right_right (H : IsCoprime x (y * z)) : IsCoprime x z := by\n rw [mul_comm] at H\n exact H.of_mul_right_left\n\ntheorem IsCoprime.mul_left_iff : IsCoprime (x * y) z ↔ IsCoprime x z ∧ IsCoprime y z :=\n ⟨fun H => ⟨H.of_mul_left_left, H.of_mul_left_right⟩, fun ⟨H1, H2⟩ => H1.mul_left H2⟩\n\ntheorem IsCoprime.mul_right_iff : IsCoprime x (y * z) ↔ IsCoprime x y ∧ IsCoprime x z := by\n rw [isCoprime_comm, IsCoprime.mul_left_iff, isCoprime_comm, @isCoprime_comm _ _ z]\n\ntheorem IsCoprime.of_isCoprime_of_dvd_left (h : IsCoprime y z) (hdvd : x ∣ y) : IsCoprime x z := by\n obtain ⟨d, rfl⟩ := hdvd\n exact IsCoprime.of_mul_left_left h\n\ntheorem IsCoprime.of_isCoprime_of_dvd_right (h : IsCoprime z y) (hdvd : x ∣ y) : IsCoprime z x :=\n (h.symm.of_isCoprime_of_dvd_left hdvd).symm\n\n@[gcongr]\ntheorem IsCoprime.mono (h₁ : x ∣ y) (h₂ : z ∣ w) (h : IsCoprime y w) : IsCoprime x z :=\n h.of_isCoprime_of_dvd_left h₁ |>.of_isCoprime_of_dvd_right h₂\n\ntheorem IsCoprime.isUnit_of_dvd (H : IsCoprime x y) (d : x ∣ y) : IsUnit x :=\n let ⟨k, hk⟩ := d\n isCoprime_self.1 <| IsCoprime.of_mul_right_left <| show IsCoprime x (x * k) from hk ▸ H\n\ntheorem IsCoprime.isUnit_of_associated {x y : R} (h₁ : IsCoprime x y) (h₂ : Associated x y) :\n IsUnit x ∧ IsUnit y :=\n ⟨h₁.isUnit_of_dvd (h₂.dvd), h₁.symm.isUnit_of_dvd (h₂.dvd')⟩\n\ntheorem IsCoprime.isUnit_of_dvd' {a b x : R} (h : IsCoprime a b) (ha : x ∣ a) (hb : x ∣ b) :\n IsUnit x :=\n (h.of_isCoprime_of_dvd_left ha).isUnit_of_dvd hb\n\ntheorem IsCoprime.isRelPrime {a b : R} (h : IsCoprime a b) : IsRelPrime a b :=\n fun _ ↦ h.isUnit_of_dvd'\n\ntheorem IsCoprime.map (H : IsCoprime x y) {S : Type v} [CommSemiring S] (f : R →+* S) :\n IsCoprime (f x) (f y) :=\n let ⟨a, b, h⟩ := H\n ⟨f a, f b, by rw [← f.map_mul, ← f.map_mul, ← f.map_add, h, f.map_one]⟩\n\ntheorem IsCoprime.of_add_mul_left_left (h : IsCoprime (x + y * z) y) : IsCoprime x y :=\n let ⟨a, b, H⟩ := h\n ⟨a, a * z + b, by\n simpa only [add_mul, mul_add, add_assoc, add_comm, add_left_comm, mul_assoc, mul_comm,\n mul_left_comm] using H⟩\n\ntheorem IsCoprime.of_add_mul_right_left (h : IsCoprime (x + z * y) y) : IsCoprime x y := by\n rw [mul_comm] at h\n exact h.of_add_mul_left_left\n\ntheorem IsCoprime.of_add_mul_left_right (h : IsCoprime x (y + x * z)) : IsCoprime x y := by\n rw [isCoprime_comm] at h ⊢\n exact h.of_add_mul_left_left\n\nTarget:\ntheorem IsCoprime.of_add_mul_right_right (h : IsCoprime x (y + z * x)) : IsCoprime x y :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Coprime","family_id":"iscoprime","file_id":"mathlib/Mathlib/RingTheory/Coprime/Basic.lean","sample_id":"e67fbd8fa7119d4589c790cca327cd3cc10be94a9ff804cf1a763f257fd55a16"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"4815aeb2672e30c1806bf7cd4715d59757508ece8b29a80697b8616581ac7a88","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"35db60c2733598ed4931ff1339b1e19ec57f35aff3079e50a87adcb6e8207eab","source_sha256":"0cf246dc3c2cbecf11bebc087d277ba7f05345ab88d2c3bf6b111583252fdecf","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext; exact ⟨fun ⟨_, h⟩ ↦ by tauto, False.elim⟩","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.0625,"token_length_ratio":0.105263},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"f5d830be0cb96b0bf83b1a782bff18b3c3ea77c00d215eedf628d20adab321c1","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Combinatorics.Digraph.Basic\npublic import Mathlib.Combinatorics.SimpleGraph.Basic\n\nNamespace:\nDigraph\n\nLocal context:\n/-\nCopyright (c) 2024 Rida Hamadani. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rida Hamadani\n-/\n/-!\n\n# Graph Orientation\n\nThis module introduces conversion operations between `Digraph`s and `SimpleGraph`s, by forgetting\nthe edge orientations of `Digraph`.\n\n## Main Definitions\n\n- `Digraph.toSimpleGraphInclusive`: Converts a `Digraph` to a `SimpleGraph` by creating an\n undirected edge if either orientation exists in the digraph.\n- `Digraph.toSimpleGraphStrict`: Converts a `Digraph` to a `SimpleGraph` by creating an undirected\n edge only if both orientations exist in the digraph.\n\n## TODO\n\n- Show that there is an isomorphism between loopless complete digraphs and oriented graphs.\n- Define more ways to orient a `SimpleGraph`.\n- Provide lemmas on how `toSimpleGraphInclusive` and `toSimpleGraphStrict` relate to other lattice\n structures on `SimpleGraph`s and `Digraph`s.\n\n## Tags\n\ndigraph, simple graph, oriented graphs\n-/\n\n@[expose] public section\n\nvariable {V : Type*}\n\nnamespace Digraph\n\nsection toSimpleGraph\n\n/-! ### Orientation-forgetting maps on digraphs -/\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\neither orientation is present.\n-/\ndef toSimpleGraphInclusive (G : Digraph V) : SimpleGraph V := SimpleGraph.fromRel G.Adj\n\n/--\nOrientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if\nboth orientations are present.\n-/\ndef toSimpleGraphStrict (G : Digraph V) : SimpleGraph V where\n Adj v w := v ≠ w ∧ G.Adj v w ∧ G.Adj w v\n\nlemma toSimpleGraphStrict_subgraph_toSimpleGraphInclusive (G : Digraph V) :\n G.toSimpleGraphStrict ≤ G.toSimpleGraphInclusive :=\n fun _ _ h ↦ ⟨h.1, Or.inl h.2.1⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphInclusive_mono : Monotone (toSimpleGraphInclusive : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₂.2.imp (@h₁ _ _) (@h₁ _ _)⟩\n\n@[gcongr, mono]\nlemma toSimpleGraphStrict_mono : Monotone (toSimpleGraphStrict : _ → SimpleGraph V) :=\n fun _ _ h₁ _ _ h₂ ↦ ⟨h₂.1, h₁ h₂.2.1, h₁ h₂.2.2⟩\n\n@[simp]\nlemma toSimpleGraphInclusive_top : (⊤ : Digraph V).toSimpleGraphInclusive = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, Or.inl trivial⟩⟩\n\n@[simp]\nlemma toSimpleGraphStrict_top : (⊤ : Digraph V).toSimpleGraphStrict = ⊤ := by\n ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩\n\n@[simp]\n\nTarget:\nlemma toSimpleGraphInclusive_bot : (⊥ : Digraph V).toSimpleGraphInclusive = ⊥ :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Combinatorics/Digraph","family_id":"tosimplegraphinclusive_bot","file_id":"mathlib/Mathlib/Combinatorics/Digraph/Orientation.lean","sample_id":"35db60c2733598ed4931ff1339b1e19ec57f35aff3079e50a87adcb6e8207eab"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"01400d4c9d2d9d2d5931cd47105d99e1eb32289a9c912524894e9aeeceb8d336","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"f650cda0843f2a1d97cc17eeaec83d11e74ebc76aa45cd3b6c2d05e01f0d4eb2","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"e33ed1887f5738b4833bcae3bd11de96fa1adc451e3c174db53c9ab0ddfd8c95","source_sha256":"8889e08ccb62ae20505e23db3758a48b309775542abaa43a2ae2c2cddeb30453","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [hom',\n HomologicalComplex.extendMap_f _ ComplexShape.embeddingUpNat (i := m) (i' := n) (by simpa),\n cochainComplexXIso]","hard_negative":true,"metrics":{"chosen_tokens":29,"rejected_tokens":3,"token_jaccard":0.043478,"token_length_ratio":0.103448},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"f5f7838e33cb70bd32a0317979db9b8368daf275cf9072512d1a2946ff8afdac","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.Embedding.CochainComplex\npublic import Mathlib.CategoryTheory.Preadditive.Injective.Resolution\n\nNamespace:\nCategoryTheory.InjectiveResolution.Hom\n\nLocal context:\n/-\nCopyright (c) 2025 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n/-!\n# Injective resolutions as cochain complexes indexed by the integers\n\nGiven an injective resolution `R` of an object `X` in an abelian category `C`,\nwe define `R.cochainComplex : CochainComplex C ℤ`, which is the extension\nof `R.cocomplex : CochainComplex C ℕ`, and the quasi-isomorphism\n`R.ι' : (CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex`.\n\n-/\n\n@[expose] public section\n\nuniverse v u\n\nnamespace CategoryTheory\n\nopen Limits\n\nvariable {C : Type u} [Category.{v} C]\n\nnamespace InjectiveResolution\n\nsection\n\nvariable [HasZeroObject C] [Preadditive C] {X : C}\n (R : InjectiveResolution X)\n\n/-- If `R : InjectiveResolution X`, this is the cochain complex indexed by `ℤ`\nobtained by extending by zero the cochain complex `R.cocomplex` indexed by `ℕ`. -/\nnoncomputable def cochainComplex : CochainComplex C ℤ :=\n R.cocomplex.extend ComplexShape.embeddingUpNat\n\ninstance : R.cochainComplex.IsStrictlyGE 0 := by\n dsimp [cochainComplex]\n infer_instance\n\n/-- If `R : InjectiveResolution X`, then `R.cochainComplex.X n` (with `n : ℕ`)\nis isomorphic to `R.cocomplex.X k` (with `k : ℕ`) when `k = n`. -/\nnoncomputable def cochainComplexXIso (n : ℤ) (k : ℕ) (h : k = n) :\n R.cochainComplex.X n ≅ R.cocomplex.X k :=\n HomologicalComplex.extendXIso _ _ h\n\n@[reassoc]\nlemma cochainComplex_d (n₁ n₂ : ℤ) (k₁ k₂ : ℕ) (h₁ : k₁ = n₁) (h₂ : k₂ = n₂) :\n R.cochainComplex.d n₁ n₂ = (cochainComplexXIso _ _ _ h₁).hom ≫\n R.cocomplex.d k₁ k₂ ≫ (cochainComplexXIso _ _ _ h₂).inv :=\n HomologicalComplex.extend_d_eq _ _ h₁ h₂\n\ninstance : R.cochainComplex.IsStrictlyGE 0 := by\n dsimp [cochainComplex]\n infer_instance\n\ninstance (n : ℤ) : Injective (R.cochainComplex.X n) := by\n by_cases hn : 0 ≤ n\n · obtain ⟨k, rfl⟩ := Int.eq_ofNat_of_zero_le hn\n exact Injective.of_iso (R.cochainComplexXIso _ _ rfl).symm inferInstance\n · exact IsZero.injective (CochainComplex.isZero_of_isStrictlyGE _ 0 _ (by lia))\n\n/-- The quasi-isomorphism `(CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex`\nin `CochainComplex C ℤ` when `R` is an injective resolution of `X`. -/\nnoncomputable def ι' : (CochainComplex.singleFunctor C 0).obj X ⟶ R.cochainComplex :=\n (HomologicalComplex.extendSingleIso _ _ _ _ (by simp)).inv ≫\n (ComplexShape.embeddingUpNat.extendFunctor C).map R.ι\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc]\nlemma ι'_f_zero :\n R.ι'.f 0 = (HomologicalComplex.singleObjXSelf (.up ℤ) 0 X).hom ≫ R.ι.f 0 ≫\n (R.cochainComplexXIso _ _ (by simp)).inv := by\n dsimp [ι']\n rw [HomologicalComplex.extendMap_f _ _ (i := 0) (by simp),\n HomologicalComplex.extendSingleIso_inv_f]\n cat_disch\n\nend\n\nvariable [Abelian C] {X : C} (R : InjectiveResolution X)\n\nset_option backward.defeqAttrib.useBackward true in\nset_option backward.isDefEq.respectTransparency false in\ninstance : QuasiIso R.ι' := by dsimp [ι']; infer_instance\n\ninstance : R.cochainComplex.IsLE 0 := by\n simp only [← HomologicalComplex.isSupported_iff_of_quasiIso R.ι']\n infer_instance\n\nnamespace Hom\n\nvariable {R} {X' : C} {R' : InjectiveResolution X'} {f : X ⟶ X'}\n (φ : Hom R R' f)\n\n/-- The morphism on cochain complexes indexed by `ℤ` that is induced by\nan (heterogeneous) morphism of injective resolutions. -/\nnoncomputable def hom' : R.cochainComplex ⟶ R'.cochainComplex :=\n HomologicalComplex.extendMap φ.hom _\n\nset_option backward.isDefEq.respectTransparency false in\n@[reassoc]\n\nTarget:\nlemma hom'_f (n : ℤ) (m : ℕ) (h : m = n) :\n φ.hom'.f n =\n (R.cochainComplexXIso n m h).hom ≫ φ.hom.f m ≫ (R'.cochainComplexXIso n m h).inv :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_e33ed1887f57","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"55ab2ade67b0d1189fff20db674991069ba6d78f1f6667f0b7513599ce65f462","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"CategoryTheory/Abelian","family_id":"hom'_f","file_id":"mathlib/Mathlib/CategoryTheory/Abelian/Injective/Extend.lean","sample_id":"e33ed1887f5738b4833bcae3bd11de96fa1adc451e3c174db53c9ab0ddfd8c95"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f6c9c283d4acd50fcc2c27a0de1087861e3d20f5652a0f2a0c411719160916a1","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"d65ea34e7c6de56d28e43cd82be8846165fd225bc64f1fd5bc16e04be298bc0d","source_sha256":"4123b423d4ccc708b4b1a3b56340ef36fdd81734c2f664d52dcec25eff24b129","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [ih_η, ih_θ]","hard_negative":false,"metrics":{"chosen_tokens":9,"rejected_tokens":3,"token_jaccard":0.1,"token_length_ratio":0.333333},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"f6219e41ea771ebbd693fe94a87a68a31f8cfd47158024679ed909428c0ac017","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes\npublic import Mathlib.Tactic.CategoryTheory.MonoidalComp\n\nNamespace:\nMathlib.Tactic.Monoidal\n\nLocal context:\n/-\nCopyright (c) 2024 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n-/\npublic meta import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes\n\n/-!\n# Expressions for monoidal categories\n\nThis file converts lean expressions representing morphisms in monoidal categories into `Mor₂Iso`\nor `Mor` terms. The converted expressions are used in the coherence tactics and the string diagram\nwidgets.\n\n-/\n\npublic meta section\n\nopen Lean Meta Elab Qq\nopen CategoryTheory Mathlib.Tactic.BicategoryLike MonoidalCategory\n\nnamespace Mathlib.Tactic.Monoidal\n\n/-- The domain of a morphism. -/\ndef srcExpr (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, f, _]) => return f\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The codomain of a morphism. -/\ndef tgtExpr (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, _, g]) => return g\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The domain of an isomorphism. -/\ndef srcExprOfIso (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Iso, #[_, _, f, _]) => return f\n | _ => throwError m!\"{η} is not a morphism\"\n\n/-- The codomain of an isomorphism. -/\ndef tgtExprOfIso (η : Expr) : MetaM Expr := do\n match (← whnfR (← inferType η)).getAppFnArgs with\n | (``Iso, #[_, _, _, g]) => return g\n | _ => throwError m!\"{η} is not a morphism\"\n\ninitialize registerTraceClass `monoidal\n\n/-- The context for evaluating expressions. -/\nstructure Context where\n /-- The level for morphisms. -/\n level₂ : Level\n /-- The level for objects. -/\n level₁ : Level\n /-- The expression for the underlying category. -/\n C : Q(Type level₁)\n /-- The category instance. -/\n instCat : Q(Category.{level₂, level₁} $C)\n /-- The monoidal category instance. -/\n instMonoidal? : Option Q(MonoidalCategory.{level₂, level₁} $C)\n\n/-- Populate a `context` object for evaluating `e`. -/\ndef mkContext? (e : Expr) : MetaM (Option Context) := do\n let e ← instantiateMVars e\n let type ← instantiateMVars <| ← inferType e\n match (← whnfR type).getAppFnArgs with\n | (``Quiver.Hom, #[_, _, f, _]) =>\n let C ← instantiateMVars <| ← inferType f\n let .succ level₁ ← getLevel C | return none\n let .succ level₂ ← getLevel type | return none\n let some instCat ← synthInstance?\n (mkAppN (.const ``Category [level₂, level₁]) #[C]) | return none\n let instMonoidal? ← synthInstance?\n (mkAppN (.const ``MonoidalCategory [level₂, level₁]) #[C, instCat])\n return some ⟨level₂, level₁, C, instCat, instMonoidal?⟩\n | _ => return none\n\ninstance : BicategoryLike.Context Monoidal.Context where\n mkContext? := Monoidal.mkContext?\n\n/-- The monad for the normalization of 2-morphisms. -/\nabbrev MonoidalM := CoherenceM Context\n\n/-- Throw an error if the monoidal category instance is not found. -/\ndef synthMonoidalError {α : Type} : MetaM α := do\n throwError \"failed to find monoidal category instance\"\n\ninstance : MonadMor₁ MonoidalM where\n id₁M a := do\n let ctx ← read\n let some _monoidal := ctx.instMonoidal? | synthMonoidalError\n return .id (q(𝟙_ _) : Q($ctx.C)) a\n comp₁M f g := do\n let ctx ← read\n let some _monoidal := ctx.instMonoidal? | synthMonoidalError\n let f_e : Q($ctx.C) := f.e\n let g_e : Q($ctx.C) := g.e\n return .comp (q($f_e ⊗ $g_e)) f g\n\nsection\n\nuniverse v u\nvariable {C : Type u} [Category.{v} C]\n\nTarget:\ntheorem structuralIsoOfExpr_comp {f g h : C}\n (η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η)\n (θ : g ⟶ h) (θ' : g ≅ h) (ih_θ : θ'.hom = θ) :\n (η' ≪≫ θ').hom = η ≫ θ :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/CategoryTheory","family_id":"structuralisoofexpr_comp","file_id":"mathlib/Mathlib/Tactic/CategoryTheory/Monoidal/Datatypes.lean","sample_id":"d65ea34e7c6de56d28e43cd82be8846165fd225bc64f1fd5bc16e04be298bc0d"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"63ce9f5d229d076f6b1feea387f33aeafb59c154a1fb79abb4591af50fa89186","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"29cd142c172f5aba9cc6d673320cf7ee217f1c7b3b0b068f7a2f6518e13fb657","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"382c48d722d549904c67f1ae0a3a50e4630c4bc177d12d2792657a18fa311cf5","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cfc_tac) (ha : IsStrictlyPositive a := by cfc_tac) :\n IsStrictlyPositive (b * a * b) :=\n (hb.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint _ _ hb₂).mpr ha","hard_negative":true,"metrics":{"chosen_tokens":34,"rejected_tokens":5,"token_jaccard":0.1,"token_length_ratio":0.147059},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"f630b8b41977da2fa44dd90a173dd65a765f597f76fda181b1606a6d28e5f713","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]\n\n@[aesop safe apply]\n\nTarget:\ntheorem conjugate_of_isUnit_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_382c48d722d5","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"bc5a5407aaaff68741814e9dc15a4eecd39f6e32aa333dc0cd9aaca1a661d315","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"conjugate_of_isunit_of_isselfadjoint","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"382c48d722d549904c67f1ae0a3a50e4630c4bc177d12d2792657a18fa311cf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1bc65818fb02e7713e68737362a7b391023f8ba3f1dc7e6b575b0f2fd0af5940","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"35be515d91265d7717db411ee0c81c5bd5b7a5650addcb2a58336a5e4573931c","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"dd284ce40872189e36817d75ed4ce2dd3378a4fab7a93f26cda064c455bcada2","source_sha256":"976709af1494098e2290d3c3a6a052dad499a43ec44c3bd6016d3ce147bb9165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using map_add_const f 0","hard_negative":true,"metrics":{"chosen_tokens":6,"rejected_tokens":3,"token_jaccard":0.125,"token_length_ratio":0.5},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"f797fab5720a7dd5f1cb02ad61d97afa193e105e3d79da176fbfb0e6c97c2d03","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Algebra.Module.NatInt\npublic import Mathlib.Algebra.Order.Archimedean.Basic\nimport Mathlib.Algebra.Order.Group.Basic\n\nNamespace:\nAddConstMapClass\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Maps (semi)conjugating a shift to a shift\n\nDenote by $S^1$ the unit circle `UnitAddCircle`.\nA common way to study a self-map $f\\colon S^1\\to S^1$ of degree `1`\nis to lift it to a map $\\tilde f\\colon \\mathbb R\\to \\mathbb R$\nsuch that $\\tilde f(x + 1) = \\tilde f(x)+1$ for all `x`.\n\nIn this file we define a structure and a typeclass\nfor bundled maps satisfying `f (x + a) = f x + b`.\n\nWe use parameters `a` and `b` instead of `1` to accommodate for two use cases:\n\n- maps between circles of different lengths;\n- self-maps $f\\colon S^1\\to S^1$ of degree other than one,\n including orientation-reversing maps.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nopen Function Set\n\n/-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`,\ndenoted as `f : G →+c[a, b] H`.\n\nOne can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/\nstructure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where\n /-- The underlying function of an `AddConstMap`.\n Use automatic coercion to function instead. -/\n protected toFun : G → H\n /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/\n map_add_const' (x : G) : toFun (x + a) = toFun x + b\n\n@[inherit_doc]\nscoped[AddConstMap] notation:25 G \" →+c[\" a \", \" b \"] \" H => AddConstMap G H a b\n\n/-- Typeclass for maps satisfying `f (x + a) = f x + b`.\n\nNote that `a` and `b` are `outParam`s,\nso one should not add instances like\n`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/\nclass AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]\n (a : outParam G) (b : outParam H) [FunLike F G H] : Prop where\n /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:\n `∀ x, f (x + a) = f x + b`. -/\n map_add_const (f : F) (x : G) : f (x + a) = f x + b\n\nnamespace AddConstMapClass\n\n/-!\n### Properties of `AddConstMapClass` maps\n\nIn this section we prove properties like `f (x + n • a) = f x + n • b`.\n-/\n\nscoped[AddConstMapClass] attribute [simp] map_add_const\n\nvariable {F G H : Type*} [FunLike F G H] {a : G} {b : H}\n\nprotected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n Semiconj f (· + a) (· + b) :=\n map_add_const f\n\n@[scoped simp]\ntheorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by\n simpa using (AddConstMapClass.semiconj f).iterate_right n x\n\n@[scoped simp]\ntheorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul]\n\ntheorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x\n\n@[scoped simp]\ntheorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + (ofNat(n) : ℕ) • b :=\n map_add_nat' f x n\n\ntheorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp\n\ntheorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n\n\n@[scoped simp]\n\nTarget:\ntheorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n f a = f 0 + b :=\n\nProof body:\n","rejected":"by\n exact map_const","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"1a459e9924891af22775626da59f27a10067c1b4d1b9c0386932098e1acf3c67","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/AddConstMap","family_id":"map_const","file_id":"mathlib/Mathlib/Algebra/AddConstMap/Basic.lean","sample_id":"dd284ce40872189e36817d75ed4ce2dd3378a4fab7a93f26cda064c455bcada2"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"832049157307cc225d58dab58d29e0bf5f150755460fd0809b4fe329a5c57cc4","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"17c9dfcd143ab187f566e25ee78b2d9b1d1f0ea2350433fd7189f4eab2b3a338","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"a4d87dbf774b4797d3a25e3d1c0c1ab09a9ddc2ae451217d30f7280723179ffc","source_sha256":"13c7a1629af24e2f099064a1f2c061026ffee34b15e2fe588217126c2c5d8aab","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n dsimp [singularChainComplexFunctorAdjunction, Adjunction.ofNatIsoRight,\n Adjunction.equivHomsetRightOfNatIso, Adjunction.homEquiv,\n Adjunction.comp, singularChainComplexFunctor,\n SSet.chainComplexFunctorAdjunction, SSet.chainComplexFunctor]\n simp [stdSimplexToTop]\n rfl","hard_negative":true,"metrics":{"chosen_tokens":36,"rejected_tokens":3,"token_jaccard":0.047619,"token_length_ratio":0.083333},"negative_category":"circular_dependency","negative_mode":"circular_dependency","pair_id":"f8347f68b5e2fffd245f38baf436ae66acc8c905a72250dfa5437abbd1372057","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Homology.AlternatingConst\npublic import Mathlib.AlgebraicTopology.SimplicialSet.Homology.Basic\npublic import Mathlib.AlgebraicTopology.SingularSet\npublic import Mathlib.CategoryTheory.Adjunction.Whiskering\npublic import Mathlib.CategoryTheory.Limits.MonoCoprod\n\nNamespace:\nAlgebraicTopology\n\nLocal context:\n/-\nCopyright (c) 2025 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n# Singular homology\n\nIn this file, we define the singular chain complex and singular homology of a topological space.\nWe also calculate the homology of a totally disconnected space as an example.\n\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nnamespace AlgebraicTopology\n\nopen CategoryTheory Limits\n\nuniverse w v u\n\nvariable (C : Type u) [Category.{v} C] [HasCoproducts.{w} C]\nvariable [Preadditive C] (n : ℕ)\n\n/-- The singular chain complex functor with coefficients in `C`. -/\ndef singularChainComplexFunctor :\n C ⥤ TopCat.{w} ⥤ ChainComplex C ℕ :=\n SSet.chainComplexFunctor.{w} C ⋙ (Functor.whiskeringLeft _ _ _).obj TopCat.toSSet.{w}\n\ninstance : (singularChainComplexFunctor C).Additive := by\n delta singularChainComplexFunctor\n infer_instance\n\nset_option backward.defeqAttrib.useBackward true in\ninstance [Limits.HasPullbacks C] {X : C} :\n ((singularChainComplexFunctor C).obj X).PreservesMonomorphisms where\n preserves f _ := by\n dsimp [singularChainComplexFunctor, SSet.chainComplexFunctor]\n apply +allowSynthFailures Functor.map_mono\n apply +allowSynthFailures Functor.map_mono\n dsimp [SSet, SimplicialObject.whiskering, SimplicialObject]\n infer_instance\n\n/-- The `n`-th singular homology functor with coefficients in `C`. -/\ndef singularHomologyFunctor [CategoryWithHomology C] : C ⥤ TopCat.{w} ⥤ C :=\n singularChainComplexFunctor C ⋙\n (Functor.whiskeringRight _ _ _).obj (HomologicalComplex.homologyFunctor _ _ n)\n\nsection Adjunction\n\nopen Limits _root_.SSet\nopen scoped Simplicial\nopen HomologicalComplex (eval)\n\n/-- The adjunction `Hom(Cⁿ(-, X), F) ≃ Hom(X, F(Δ[n]))` for `X : C` and `F : Top ⥤ C`. -/\ndef singularChainComplexFunctorAdjunction : (Functor.postcompose₂.obj (eval _ _ n)).obj\n (singularChainComplexFunctor C) ⊣ (evaluation _ _).obj (SimplexCategory.toTop.obj ⦋n⦌) :=\n ((SSet.chainComplexFunctorAdjunction C n).comp (sSetTopAdj.whiskerLeft _)).ofNatIsoRight\n ((evaluation TopCat C).mapIso (SSet.toTopSimplex.app _))\n\nset_option backward.defeqAttrib.useBackward true in\n\nTarget:\nlemma singularChainComplexFunctorAdjunction_unit_app (R : C) :\n (singularChainComplexFunctorAdjunction C n).unit.app R =\n Sigma.ι (fun _ ↦ R) ((stdSimplexToTop.app ⦋n⦌).app (.op ⦋n⦌)\n (SSet.stdSimplex.objEquiv.symm (𝟙 ⦋n⦌))) :=\n\nProof body:\n","rejected":"by\n exact singularChainComplexFunctorAdjunction_unit_app","rejection":{"accepted":false,"failure_type":"lean_elaboration_error","output_sha256":"6596524a15aca87ca17d9d0a4c2c1800b9ed0f6eca8359a14c41c80367061e4e","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"AlgebraicTopology/SingularHomology","family_id":"singularchaincomplexfunctoradjunction_unit_app","file_id":"mathlib/Mathlib/AlgebraicTopology/SingularHomology/Basic.lean","sample_id":"a4d87dbf774b4797d3a25e3d1c0c1ab09a9ddc2ae451217d30f7280723179ffc"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7425bcdb7155248a01a05c66e195a60382e1936bea653d7c78fca4c9e3190e4b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"cb1926d75dc62ee9841aad2da82d798f7198ae549604c79071c1fdb5c842fa1a","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"806d86021563d0848d2ee8be77a068205fd21b50c613a62d7bd7afefe1b4d10f","source_sha256":"6d09d445f3f033f859d77c9787c93d39447dddcb241c9f314d0f8ee75fb436ec","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [borel_eq_generateFrom_Ioi]\n refine le_antisymm ?_ ?_\n · refine MeasurableSpace.generateFrom_le fun t ht => ?_\n obtain ⟨u, rfl⟩ := ht\n rw [← compl_Iic]\n exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl\n · refine MeasurableSpace.generateFrom_le fun t ht => ?_\n obtain ⟨u, rfl⟩ := ht\n rw [← compl_Ioi]\n exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl","hard_negative":true,"metrics":{"chosen_tokens":95,"rejected_tokens":3,"token_jaccard":0.057143,"token_length_ratio":0.031579},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"f88663c20e301757a1cfd055053791e965e52df735b909dda6d3ded6314da44a","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Topology.Semicontinuity.Basic\npublic import Mathlib.MeasureTheory.Function.AEMeasurableSequence\npublic import Mathlib.MeasureTheory.Order.Lattice\npublic import Mathlib.Topology.Order.Lattice\npublic import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov, Kexing Ying\n-/\n/-!\n# Borel sigma algebras on spaces with orders\n\n## Main statements\n\n* `borel_eq_generateFrom_Ixx` (where Ixx is one of `{Iio, Ioi, Iic, Ici, Ico, Ioc}`):\n The Borel sigma algebra of a linear order topology is generated by intervals of the given kind.\n* `Dense.borel_eq_generateFrom_Ico_mem`, `Dense.borel_eq_generateFrom_Ioc_mem`:\n The Borel sigma algebra of a dense linear order topology is generated by intervals of a given\n kind, with endpoints from dense subsets.\n* `ext_of_Ico`, `ext_of_Ioc`:\n A locally finite Borel measure on a second countable conditionally complete linear order is\n characterized by the measures of intervals of the given kind.\n* `ext_of_Iic`, `ext_of_Ici`:\n A finite Borel measure on a second countable linear order is characterized by the measures of\n intervals of the given kind.\n* `UpperSemicontinuous.measurable`, `LowerSemicontinuous.measurable`:\n Semicontinuous functions are measurable.\n* `Measurable.iSup`, `Measurable.iInf`, `Measurable.sSup`, `Measurable.sInf`:\n Countable supremums and infimums of measurable functions to conditionally complete linear orders\n are measurable.\n* `Measurable.liminf`, `Measurable.limsup`:\n Countable liminfs and limsups of measurable functions to conditionally complete linear orders\n are measurable.\n\n-/\n\npublic section\n\nopen Set Filter MeasureTheory MeasurableSpace TopologicalSpace\n\nopen scoped Topology NNReal ENNReal MeasureTheory\n\nuniverse u v w x y\n\nvariable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α}\n\nsection OrderTopology\n\nvariable (α)\nvariable [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α]\n\ntheorem borel_eq_generateFrom_Iio : borel α = .generateFrom (range Iio) := by\n refine le_antisymm ?_ (generateFrom_le ?_)\n · rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals α _ _ _)]\n letI : MeasurableSpace α := MeasurableSpace.generateFrom (range Iio)\n have H : ∀ a : α, MeasurableSet (Iio a) := fun a => GenerateMeasurable.basic _ ⟨_, rfl⟩\n refine generateFrom_le ?_\n rintro _ ⟨a, rfl | rfl⟩\n · rcases em (∃ b, a ⋖ b) with ⟨b, hb⟩ | hcovBy\n · rw [hb.Ioi_eq, ← compl_Iio]\n exact (H _).compl\n · rcases isOpen_biUnion_countable (Ioi a) Ioi fun _ _ ↦ isOpen_Ioi with ⟨t, hat, htc, htU⟩\n have : Ioi a = ⋃ b ∈ t, Ici b := by\n refine Subset.antisymm ?_ <| iUnion₂_subset fun b hb ↦ Ici_subset_Ioi.2 (hat hb)\n refine Subset.trans ?_ <| iUnion₂_mono fun _ _ ↦ Ioi_subset_Ici_self\n simpa [CovBy, htU, subset_def] using hcovBy\n simp only [this, ← compl_Iio]\n exact .biUnion htc <| fun _ _ ↦ (H _).compl\n · apply H\n · rw [forall_mem_range]\n intro a\n exact GenerateMeasurable.basic _ isOpen_Iio\n\ntheorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) :=\n @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _\n\nTarget:\ntheorem borel_eq_generateFrom_Iic :\n borel α = MeasurableSpace.generateFrom (range Iic) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_806d86021563","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"c919554d2e28b2288955bba912de8527cdfeebbed21f6627b0c0207aafc96b92","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"MeasureTheory/Constructions","family_id":"borel_eq_generatefrom_iic","file_id":"mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean","sample_id":"806d86021563d0848d2ee8be77a068205fd21b50c613a62d7bd7afefe1b4d10f"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"d8eab85b06a4dec1573915379171a55d25a2102b8f22818ef294368125112d57","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"8f35db6307434332a4c7dc19c905321231603f7c32c517fb1c50208185f01852","source_sha256":"194206bb2f0ba4529dcefcd99a93348b595c99eb311c8226ee03a1f371a82e74","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n obtain ⟨x, rfl⟩ := Cotangent.mk_surjective x\n rw [cotangentComplex_mk, map_tmul, map_one, Cotangent.map_mk, cotangentComplex_mk]","hard_negative":false,"metrics":{"chosen_tokens":26,"rejected_tokens":2,"token_jaccard":0.052632,"token_length_ratio":0.076923},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"f948e2cc488afde545b0b8d0e81209606fe121c734df0a7b501b9cabf7f23cf5","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.RingTheory.Kaehler.Polynomial\npublic import Mathlib.Algebra.Module.FinitePresentation\npublic import Mathlib.RingTheory.Extension.Presentation.Basic\n\nNamespace:\nAlgebra.Extension.CotangentSpace\n\nLocal context:\n/-\nCopyright (c) 2024 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\n/-!\n\n# Naive cotangent complex associated to a presentation.\n\nGiven a presentation `0 → I → R[x₁,...,xₙ] → S → 0` (or equivalently a closed embedding `S ↪ Aⁿ`\ndefined by `I`), we may define the (naive) cotangent complex `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R] → 0`.\n\n## Main results\n- `Algebra.Extension.Cotangent`: The conormal space `I/I²`. (Defined in `Generators/Basic`)\n- `Algebra.Extension.CotangentSpace`: The cotangent space `⨁ᵢ S dxᵢ`.\n- `Algebra.Generators.cotangentSpaceBasis`: The canonical basis on `⨁ᵢ S dxᵢ`.\n- `Algebra.Extension.CotangentComplex`: The map `I/I² → ⨁ᵢ S dxᵢ`.\n- `Algebra.Extension.toKaehler`: The projection `⨁ᵢ S dxᵢ → Ω[S/R]`.\n- `Algebra.Extension.toKaehler_surjective`: The map `⨁ᵢ S dxᵢ → Ω[S/R]` is surjective.\n- `Algebra.Extension.exact_cotangentComplex_toKaehler`: `I/I² → ⨁ᵢ S dxᵢ → Ω[S/R]` is exact.\n- `Algebra.Extension.Hom.Sub`: If `f` and `g` are two maps between presentations, `f - g` induces\n a map `⨁ᵢ S dxᵢ → I/I²` that makes `f` and `g` homotopic.\n- `Algebra.Extension.H1Cotangent`: The first homology of the (naive) cotangent complex\n of `S` over `R`, induced by a given presentation.\n- `Algebra.H1Cotangent`: `H¹(L_{S/R})`,\n the first homology of the (naive) cotangent complex of `S` over `R`.\n\n## Implementation detail\nWe actually develop these material for general extensions (i.e. surjection `P → S`) so that we can\napply them to infinitesimal smooth (or versal) extensions later.\n\n-/\n\n@[expose] public section\n\nopen KaehlerDifferential Module MvPolynomial TensorProduct\n\nnamespace Algebra\n\nuniverse w u v\n\nvariable {R : Type u} {S : Type v} [CommRing R] [CommRing S] [Algebra R S]\n\nnamespace Extension\n\nvariable (P : Extension.{w} R S)\n\n/--\nThe cotangent space on `P = R[X]`.\nThis is isomorphic to `Sⁿ` with `n` being the number of variables of `P`.\n-/\nabbrev CotangentSpace : Type _ := S ⊗[P.Ring] Ω[P.Ring⁄R]\n\n/-- The cotangent complex given by a presentation `R[X] → S` (i.e. a closed embedding `S ↪ Aⁿ`). -/\nnoncomputable\ndef cotangentComplex : P.Cotangent →ₗ[S] P.CotangentSpace :=\n letI f : P.Cotangent ≃ₗ[P.Ring] P.ker.Cotangent :=\n { __ := AddEquiv.refl _, map_smul' := Cotangent.val_smul' }\n (kerCotangentToTensor R P.Ring S ∘ₗ f).extendScalarsOfSurjective P.algebraMap_surjective\n\n@[simp]\nlemma cotangentComplex_mk (x) : P.cotangentComplex (.mk x) = 1 ⊗ₜ .D _ _ x :=\n rfl\n\nlemma Cotangent.mk_C_mem_ker_cotangentComplex {σ : Type*} (G : Generators R S σ)\n {r : R} (hr : C r ∈ G.ker) :\n Extension.Cotangent.mk ⟨C r, hr⟩ ∈ G.toExtension.cotangentComplex.ker := by\n have : D R G.toExtension.Ring (C r) = 0 := Derivation.map_algebraMap ..\n simp [this]\n\nsection baseChange\n\nvariable {A : Type*} [CommRing A] [Algebra S A] [Algebra P.Ring A] [IsScalarTower P.Ring S A]\n\nvariable (R S) in\n/-- This is (isomorphic to) the base change of the cotangent complex to `A`, but\nthe domain and codomains of this are more manageable. -/\nnoncomputable\ndef _root_.KaehlerDifferential.cotangentComplexBaseChange\n (P A : Type*) [CommRing P] [CommRing A] [Algebra P S] [Algebra P A]\n [Algebra R P] [Algebra S A] [IsScalarTower P S A] :\n A ⊗[P] RingHom.ker (algebraMap P S) →ₗ[A] A ⊗[P] Ω[P⁄R] :=\n LinearMap.liftBaseChange _ (KaehlerDifferential.kerToTensor _ _ _ ∘ₗ Submodule.inclusion\n (by rw [IsScalarTower.algebraMap_eq P S A]; intro; aesop))\n\nomit [Algebra R S] in\nlemma _root_.KaehlerDifferential.cotangentComplexBaseChange_tmul\n {P A : Type*} [CommRing P] [CommRing A] [Algebra P S]\n [Algebra P A] [Algebra R P] [Algebra S A] [IsScalarTower P S A] (a b) :\n cotangentComplexBaseChange R S P A (a ⊗ₜ b) =\n a • kerToTensor R P A ⟨b.1, by rw [IsScalarTower.algebraMap_eq P S A]; aesop⟩ := rfl\n\nvariable (A) in\nlemma cotangentComplexBaseChange_eq_lTensor_cotangentComplex :\n cotangentComplexBaseChange R S P.Ring A =\n AlgebraTensorModule.cancelBaseChange P.Ring S A A Ω[P.Ring⁄R] ∘ₗ\n P.cotangentComplex.baseChange A ∘ₗ\n ((AlgebraTensorModule.cancelBaseChange P.Ring S A A P.ker).symm ≪≫ₗ\n P.cotangentEquiv.baseChange (A := A)) := by\n ext x\n simp [LinearEquiv.baseChange, cotangentComplexBaseChange_tmul]\n\nvariable (A) in\nlemma lTensor_cotangentComplex_eq_cotangentComplexBaseChange :\n P.cotangentComplex.baseChange A =\n (AlgebraTensorModule.cancelBaseChange P.Ring S A A Ω[P.Ring⁄R]).symm ∘ₗ\n cotangentComplexBaseChange R S P.Ring A ∘ₗ\n ((AlgebraTensorModule.cancelBaseChange P.Ring S A A P.ker).symm ≪≫ₗ\n P.cotangentEquiv.baseChange (A := A)).symm := by\n apply LinearMap.coe_injective\n dsimp\n rw [LinearEquiv.eq_symm_comp, ← LinearEquiv.comp_symm_eq]\n exact congr(($(cotangentComplexBaseChange_eq_lTensor_cotangentComplex P A) : _ → _)).symm\n\nend baseChange\n\nuniverse w' u' v'\n\nvariable {R' : Type u'} {S' : Type v'} [CommRing R'] [CommRing S'] [Algebra R' S']\nvariable (P' : Extension.{w'} R' S')\nvariable [Algebra R R'] [Algebra S S'] [Algebra R S'] [IsScalarTower R R' S']\n\nattribute [local instance] SMulCommClass.of_commMonoid\n\nvariable {P P'}\n\nuniverse w'' u'' v''\n\nvariable {R'' : Type u''} {S'' : Type v''} [CommRing R''] [CommRing S''] [Algebra R'' S'']\nvariable {P'' : Extension.{w''} R'' S''}\nvariable [Algebra R R''] [Algebra S S''] [Algebra R S'']\n [IsScalarTower R R'' S'']\nvariable [Algebra R' R''] [Algebra S' S''] [Algebra R' S'']\n [IsScalarTower R' R'' S'']\nvariable [IsScalarTower R R' R''] [IsScalarTower S S' S'']\n\nnamespace CotangentSpace\n\n/--\nThis is the map on the cotangent space associated to a map of presentation.\nThe matrix associated to this map is the Jacobian matrix. See `CotangentSpace.repr_map`.\n-/\nprotected noncomputable\ndef map (f : Hom P P') : P.CotangentSpace →ₗ[S] P'.CotangentSpace := by\n letI := ((algebraMap S S').comp (algebraMap P.Ring S)).toAlgebra\n haveI : IsScalarTower P.Ring S S' := IsScalarTower.of_algebraMap_eq' rfl\n letI := f.toAlgHom.toAlgebra\n haveI : IsScalarTower P.Ring P'.Ring S' :=\n IsScalarTower.of_algebraMap_eq (fun x ↦ (f.algebraMap_toRingHom x).symm)\n apply LinearMap.liftBaseChange\n refine (TensorProduct.mk _ _ _ 1).restrictScalars _ ∘ₗ KaehlerDifferential.map R R' P.Ring P'.Ring\n\nset_option backward.isDefEq.respectTransparency false in\n@[simp]\nlemma map_tmul (f : Hom P P') (x y) :\n CotangentSpace.map f (x ⊗ₜ .D _ _ y) = (algebraMap _ _ x) ⊗ₜ .D _ _ (f.toAlgHom y) := by\n simp only [CotangentSpace.map, AlgHom.toRingHom_eq_coe, LinearMap.liftBaseChange_tmul,\n LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, map_D, mk_apply]\n rw [smul_tmul', ← Algebra.algebraMap_eq_smul_one]\n rfl\n\nlemma map_tmul_eq_tmul_map (f : P.Hom P') (x : S) (y : Ω[P.Ring⁄R]) :\n letI : Algebra P.Ring P'.Ring := f.toAlgHom.toAlgebra\n (CotangentSpace.map f) (x ⊗ₜ[P.Ring] y) =\n (algebraMap S S') x ⊗ₜ[P'.Ring] KaehlerDifferential.map _ _ _ _ y := by\n rw [CotangentSpace.map, LinearMap.liftBaseChange_tmul, LinearMap.coe_comp, Function.comp_apply,\n LinearMap.restrictScalars_apply, mk_apply, smul_tmul', Algebra.smul_def, mul_one]\n\n@[simp]\nlemma map_id :\n CotangentSpace.map (.id P) = LinearMap.id := by ext; simp\n\nlemma map_comp (f : Hom P P') (g : Hom P' P'') :\n CotangentSpace.map (g.comp f) =\n (CotangentSpace.map g).restrictScalars S ∘ₗ CotangentSpace.map f := by\n ext x\n induction x using TensorProduct.induction_on with\n | zero =>\n simp only [map_zero]\n | add =>\n simp only [map_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply, *]\n | tmul x y =>\n obtain ⟨y, rfl⟩ := KaehlerDifferential.tensorProductTo_surjective _ _ y\n induction y with\n | zero => simp only [map_zero, tmul_zero]\n | add => simp only [map_add, tmul_add, LinearMap.coe_comp, LinearMap.coe_restrictScalars,\n Function.comp_apply, *]\n | tmul => simp only [Derivation.tensorProductTo_tmul, tmul_smul, smul_tmul', map_tmul,\n Hom.toAlgHom_apply, Hom.comp_toRingHom, RingHom.coe_comp, Function.comp_apply,\n LinearMap.coe_comp, LinearMap.coe_restrictScalars,\n ← IsScalarTower.algebraMap_apply S S' S'']\n\nlemma map_comp_apply (f : Hom P P') (g : Hom P' P'') (x) :\n CotangentSpace.map (g.comp f) x = .map g (.map f x) :=\n DFunLike.congr_fun (map_comp f g) x\n\nTarget:\nlemma map_cotangentComplex (f : Hom P P') (x) :\n CotangentSpace.map f (P.cotangentComplex x) = P'.cotangentComplex (.map f x) :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/Extension","family_id":"map_cotangentcomplex","file_id":"mathlib/Mathlib/RingTheory/Extension/Cotangent/Basic.lean","sample_id":"8f35db6307434332a4c7dc19c905321231603f7c32c517fb1c50208185f01852"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1c42cc069aa56a2bf1a7b2b1c15ee26e179c971ab71c67e215f9ba4cb1625d4a","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"3291883ef3402351aedd2cfc850918597718cf39aa2f58428fd638707c6a8b28","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"fb88080af6f22f4a9c54def3d9626310c1868fdacdfa6a87155ac0f2ed05a2f6","source_sha256":"929fc720c21b33e33bbf0a692c3be55b0da352771a5dbb4e09a095c80437d1a6","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n ext a\n exact DFunLike.congr_fun h a","hard_negative":true,"metrics":{"chosen_tokens":9,"rejected_tokens":5,"token_jaccard":0.3,"token_length_ratio":0.555556},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"f96399b460a0f7d66b346a2a70861e9f99803d3a8b957f512fb6612825130400","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Hom\npublic import Mathlib.Algebra.GroupWithZero.Action.Prod\n\nNamespace:\nNonUnitalAlgHom\n\nLocal context:\n/-\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/-!\n# Morphisms of non-unital algebras\n\nThis file defines morphisms between two types, each of which carries:\n* an addition,\n* an additive zero,\n* a multiplication,\n* a scalar action.\n\nThe multiplications are not assumed to be associative or unital, or even to be compatible with the\nscalar actions. In a typical application, the operations will satisfy compatibility conditions\nmaking them into algebras (albeit possibly non-associative and/or non-unital) but such conditions\nare not required to make this definition.\n\nThis notion of morphism should be useful for any category of non-unital algebras. The motivating\napplication at the time it was introduced was to be able to state the adjunction property for\nmagma algebras. These are non-unital, non-associative algebras obtained by applying the\ngroup-algebra construction except where we take a type carrying just `Mul` instead of `Group`.\n\nFor a plausible future application, one could take the non-unital algebra of compactly-supported\nfunctions on a non-compact topological space. A proper map between a pair of such spaces\n(contravariantly) induces a morphism between their algebras of compactly-supported functions which\nwill be a `NonUnitalAlgHom`.\n\nTODO: add `NonUnitalAlgEquiv` when needed.\n\n## Main definitions\n\n * `NonUnitalAlgHom`\n * `AlgHom.toNonUnitalAlgHom`\n\n## Tags\n\nnon-unital, algebra, morphism\n-/\n\n@[expose] public section\n\nuniverse u u₁ v w w₁ w₂ w₃\n\nvariable {R : Type u} {S : Type u₁}\n\n/-- A morphism respecting addition, multiplication, and scalar multiplication\n(denoted as `A →ₛₙₐ[φ] B`, or `A →ₙₐ[R] B` when `φ` is the identity on `R`).\nWhen these arise from algebra structures, this is the same\nas a not-necessarily-unital morphism of algebras. -/\nstructure NonUnitalAlgHom [Monoid R] [Monoid S] (φ : R →* S) (A : Type v) (B : Type w)\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] extends A →ₑ+[φ] B, A →ₙ* B\n\n@[inherit_doc NonUnitalAlgHom]\ninfixr:25 \" →ₙₐ \" => NonUnitalAlgHom _\n\n@[inherit_doc]\nnotation:25 A \" →ₛₙₐ[\" φ \"] \" B => NonUnitalAlgHom φ A B\n\n@[inherit_doc]\nnotation:25 A \" →ₙₐ[\" R \"] \" B => NonUnitalAlgHom (MonoidHom.id R) A B\n\nattribute [nolint docBlame] NonUnitalAlgHom.toMulHom\n\n/-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are equivariant with respect to `φ`. -/\nclass NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S]\n (φ : outParam (R →* S)) (A B : outParam Type*)\n [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction S B] [FunLike F A B] : Prop\n extends DistribMulActionSemiHomClass F φ A B, MulHomClass F A B\n\n/-- `NonUnitalAlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B` which are `R`-linear.\n\n This is an abbreviation to `NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B` -/\nabbrev NonUnitalAlgHomClass (F : Type*) (R A B : outParam Type*)\n [Monoid R] [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B]\n [DistribMulAction R A] [DistribMulAction R B] [FunLike F A B] :=\n NonUnitalAlgSemiHomClass F (MonoidHom.id R) A B\n\nnamespace NonUnitalAlgHomClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) toNonUnitalRingHomClass\n {F R S A B : Type*} {_ : Monoid R} {_ : Monoid S} {φ : outParam (R →* S)}\n {_ : NonUnitalNonAssocSemiring A} [DistribMulAction R A]\n {_ : NonUnitalNonAssocSemiring B} [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] : NonUnitalRingHomClass F A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with }\n\nvariable [Semiring R] [Semiring S] {φ : R →+* S}\n {A B : Type*} [NonUnitalNonAssocSemiring A] [Module R A]\n [NonUnitalNonAssocSemiring B] [Module S B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F R S A B : Type*}\n {_ : Semiring R} {_ : Semiring S} {φ : R →+* S}\n {_ : NonUnitalSemiring A} {_ : NonUnitalSemiring B} [Module R A] [Module S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass (R := R) (S := S) F φ A B] :\n SemilinearMapClass F φ A B :=\n { ‹NonUnitalAlgSemiHomClass F φ A B› with map_smulₛₗ := map_smulₛₗ }\n\ninstance (priority := 100) {F : Type*} [FunLike F A B] [Module R B] [NonUnitalAlgHomClass F R A B] :\n LinearMapClass F R A B :=\n { ‹NonUnitalAlgHomClass F R A B› with map_smulₛₗ := map_smulₛₗ }\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgSemiHomClass F φ A B` into an actual\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[φ] B`. -/\n@[coe]\ndef toNonUnitalAlgSemiHom {F R S : Type*} [Monoid R] [Monoid S] {φ : R →* S} {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) : A →ₛₙₐ[φ] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R S A B : Type*} [Monoid R] [Monoid S] {φ : R →* S}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction S B] [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] :\n CoeTC F (A →ₛₙₐ[φ] B) :=\n ⟨toNonUnitalAlgSemiHom⟩\n\n/-- Turn an element of a type `F` satisfying `NonUnitalAlgHomClass F R A B` into an actual\n@[coe]\n`NonUnitalAlgHom`. This is declared as the default coercion from `F` to `A →ₛₙₐ[R] B`. -/\ndef toNonUnitalAlgHom {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] (f : F) : A →ₙₐ[R] B :=\n { (f : A →ₙ+* B) with\n toFun := f\n map_smul' := map_smulₛₗ f }\n\ninstance {F R : Type*} [Monoid R] {A B : Type*}\n [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\n [NonUnitalNonAssocSemiring B] [DistribMulAction R B]\n [FunLike F A B] [NonUnitalAlgHomClass F R A B] :\n CoeTC F (A →ₙₐ[R] B) :=\n ⟨toNonUnitalAlgHom⟩\n\nend NonUnitalAlgHomClass\n\nnamespace NonUnitalAlgHom\n\nvariable {T : Type*} [Monoid R] [Monoid S] [Monoid T] (φ : R →* S)\nvariable (A : Type v) (B : Type w) (C : Type w₁)\nvariable [NonUnitalNonAssocSemiring A] [DistribMulAction R A]\nvariable [NonUnitalNonAssocSemiring B] [DistribMulAction S B]\nvariable [NonUnitalNonAssocSemiring C] [DistribMulAction T C]\n\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\n\n@[simp]\ntheorem toFun_eq_coe (f : A →ₛₙₐ[φ] B) : f.toFun = ⇑f :=\n rfl\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (f : A →ₛₙₐ[φ] B) : A → B := f\n\ninitialize_simps_projections NonUnitalAlgHom\n (toDistribMulActionHom_toMulActionHom_toFun → apply, -toDistribMulActionHom)\n\nvariable {φ A B C}\n@[simp]\nprotected theorem coe_coe {F : Type*} [FunLike F A B]\n [NonUnitalAlgSemiHomClass F φ A B] (f : F) :\n ⇑(f : A →ₛₙₐ[φ] B) = f :=\n rfl\n\ntheorem coe_injective : @Function.Injective (A →ₛₙₐ[φ] B) (A → B) (↑) := by\n rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h; congr\ninstance : FunLike (A →ₛₙₐ[φ] B) A B where\n coe f := f.toFun\n coe_injective := coe_injective\n\ninstance : NonUnitalAlgSemiHomClass (A →ₛₙₐ[φ] B) φ A B where\n map_add f := f.map_add'\n map_zero f := f.map_zero'\n map_mul f := f.map_mul'\n map_smulₛₗ f := f.map_smul'\n\n@[ext]\ntheorem ext {f g : A →ₛₙₐ[φ] B} (h : ∀ x, f x = g x) : f = g :=\n coe_injective <| funext h\n\ntheorem congr_fun {f g : A →ₛₙₐ[φ] B} (h : f = g) (x : A) : f x = g x :=\n h ▸ rfl\n\n@[simp]\ntheorem coe_mk (f : A → B) (h₁ h₂ h₃ h₄) : ⇑(⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f :=\n rfl\n\n@[simp]\ntheorem mk_coe (f : A →ₛₙₐ[φ] B) (h₁ h₂ h₃ h₄) : (⟨⟨⟨f, h₁⟩, h₂, h₃⟩, h₄⟩ : A →ₛₙₐ[φ] B) = f := by\n rfl\n\n@[simp] lemma addHomMk_coe (f : A →ₛₙₐ[φ] B) : AddHom.mk f (map_add f) = f := rfl\n\n@[simp]\ntheorem toDistribMulActionHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toDistribMulActionHom = ↑f :=\n rfl\n\n@[simp]\ntheorem toMulHom_eq_coe (f : A →ₛₙₐ[φ] B) : f.toMulHom = ↑f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_distribMulActionHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₑ+[φ] B) = f :=\n rfl\n\n@[simp, norm_cast]\ntheorem coe_to_mulHom (f : A →ₛₙₐ[φ] B) : ⇑(f : A →ₙ* B) = f :=\n rfl\n\ntheorem to_distribMulActionHom_injective {f g : A →ₛₙₐ[φ] B}\n (h : (f : A →ₑ+[φ] B) = (g : A →ₑ+[φ] B)) : f = g := by\n ext a\n exact DistribMulActionHom.congr_fun h a\n\nTarget:\ntheorem to_mulHom_injective {f g : A →ₛₙₐ[φ] B} (h : (f : A →ₙ* B) = (g : A →ₙ* B)) : f = g :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_fb88080af6f2","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"7207e2c5807429a8817478540b6ddfe997f0b4eba82241b90139a71a241f6e62","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"to_mulhom_injective","file_id":"mathlib/Mathlib/Algebra/Algebra/NonUnitalHom.lean","sample_id":"fb88080af6f22f4a9c54def3d9626310c1868fdacdfa6a87155ac0f2ed05a2f6"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"63ce9f5d229d076f6b1feea387f33aeafb59c154a1fb79abb4591af50fa89186","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"432e9cde4c8278c543af16f5b27145cc6aba7b5c4e58f10d2ab4446307b7570b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"382c48d722d549904c67f1ae0a3a50e4630c4bc177d12d2792657a18fa311cf5","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by cfc_tac) (ha : IsStrictlyPositive a := by cfc_tac) :\n IsStrictlyPositive (b * a * b) :=\n (hb.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint _ _ hb₂).mpr ha","hard_negative":false,"metrics":{"chosen_tokens":34,"rejected_tokens":39,"token_jaccard":0.809524,"token_length_ratio":1.147059},"negative_category":"markdown_preamble_trailing","negative_mode":"trailing","pair_id":"fa293a6caeda9ac20b0eb985e5e2aa890cc8b3c02364863e1cbba8efd4961cc9","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]\n\n@[aesop safe apply]\n\nTarget:\ntheorem conjugate_of_isUnit_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b :=\n\nProof body:\n","rejected":"by cfc_tac) (ha : IsStrictlyPositive a := by cfc_tac) :\n IsStrictlyPositive (b * a * b) :=\n (hb.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint _ _ hb₂).mpr ha\nThis completes the proof.","rejection":{"accepted":false,"all_failure_types":["prose_or_trailing_explanation"],"failure_type":"prose_or_trailing_explanation","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"conjugate_of_isunit_of_isselfadjoint","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"382c48d722d549904c67f1ae0a3a50e4630c4bc177d12d2792657a18fa311cf5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"5f8a3be005e07f4608168ca5a3704fb12ee35073f36312b4b6deb828da5b5823","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"6a0f03b458ed50734a3025d61af53351276c215c38aa315f74b586dfa99d0d93","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"faf1008b28f1769ca1b08d394a375ac1236d7fad5271d304f8c4f07a9814d473","source_sha256":"59dce65aa1439ac03aa82f10431e6a4e6f8904739a4f8662c4d13bfb37f0673a","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa [GaloisConnection, subset_def, mem_upperBounds, mem_lowerBounds]\n using fun S T ↦ forall₂_comm","hard_negative":false,"metrics":{"chosen_tokens":19,"rejected_tokens":2,"token_jaccard":0.055556,"token_length_ratio":0.105263},"negative_category":"by_exact_placeholder","negative_mode":"by?","pair_id":"fab23f83910ebafd6d73d4af7797df82e51b5d8fa9ce29977f1d23c3f0a2434c","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Data.Set.Lattice.Image\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2024 Christopher Hoskin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Christopher Hoskin\n-/\n/-!\n# Unions and intersections of bounds\n\nSome results about upper and lower bounds over collections of sets.\n\n## Implementation notes\n\nIn a separate file as we need to import `Mathlib/Data/Set/Lattice.lean`.\n\n-/\n\npublic section\n\nvariable {α : Type*} [Preorder α] {ι : Sort*} {s : ι → Set α}\n\nopen Set\n\n@[to_dual]\n\nTarget:\ntheorem gc_upperBounds_lowerBounds : GaloisConnection\n (OrderDual.toDual ∘ upperBounds : Set α → (Set α)ᵒᵈ)\n (lowerBounds ∘ OrderDual.ofDual : (Set α)ᵒᵈ → Set α) :=\n\nProof body:\n","rejected":"by?","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Order/Bounds","family_id":"gc_upperbounds_lowerbounds","file_id":"mathlib/Mathlib/Order/Bounds/Lattice.lean","sample_id":"faf1008b28f1769ca1b08d394a375ac1236d7fad5271d304f8c4f07a9814d473"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"7dbf6e986a353ed2a28665e4a4d20592bbe347b12df5fd5b5865ea74df58c540","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"0d002db9cc8388d0bb048c967b6cc0ba1b001333a19addabc857b0bfa660e31e","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"543d76b6076e843b8bbf2e7701d81984147da6c7150e96a19e3272999e63ed8e","source_sha256":"768f43e7cd06fb0d9a653eb366ae837740338968f4d8754584874d036649ed6d","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n cases x; cases y\n simp only [dvd_def, Prod.exists, Prod.mk_mul_mk, Prod.mk.injEq,\n exists_and_left, exists_and_right]","hard_negative":true,"metrics":{"chosen_tokens":29,"rejected_tokens":8,"token_jaccard":0.04,"token_length_ratio":0.275862},"negative_category":"unsolved_goals","negative_mode":"unsolved_goals","pair_id":"fac7228819081a8d555f6c623f2c85089922427addc18536d8e2c12212fb811b","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Divisibility.Basic\npublic import Mathlib.Algebra.Group.Pi.Basic\npublic import Mathlib.Algebra.Group.Prod\npublic import Mathlib.Tactic.Common\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2023 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n/-!\n# Lemmas about the divisibility relation in product (semi)groups\n-/\n\npublic section\n\nvariable {ι G₁ G₂ : Type*} {G : ι → Type*} [Semigroup G₁] [Semigroup G₂] [∀ i, Semigroup (G i)]\n\nTarget:\ntheorem prod_dvd_iff {x y : G₁ × G₂} :\n x ∣ y ↔ x.1 ∣ y.1 ∧ x.2 ∣ y.2 :=\n\nProof body:\n","rejected":"by\n have __oprover_safe_h : True := by trivial","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"e752ff9aa10bf3526edddecae0aaac0e70865656b80398a62885173e7b84cc5a","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/Divisibility","family_id":"prod_dvd_iff","file_id":"mathlib/Mathlib/Algebra/Divisibility/Prod.lean","sample_id":"543d76b6076e843b8bbf2e7701d81984147da6c7150e96a19e3272999e63ed8e"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"c9af3828351cdcb9c346e255d24532e228a2c8bbafe6f19f8418eb4e0579d645","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2ba9e88236525bfbfff0093b9830342a19ba71600a32a2a8dec2e1289e978842","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"747210a4594e2503a2358e5528af75b8e40e99402e55088570c8b06a23a04532","source_sha256":"5b986032a9bb23c7f5acc31aea0498304b096282f4eef9a81528e2e193e09dc8","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n induction n generalizing M with\n | zero =>\n have projle : HasProjectiveDimensionLE M 0 := ‹_›\n simp only [HasProjectiveDimensionLE, zero_add] at projle ⊢\n rw [← projective_iff_hasProjectiveDimensionLT_one, ← IsProjective.iff_projective] at projle ⊢\n exact Module.projective_of_isLocalizedModule S (M.localizedModuleMkLinearMap S)\n | succ n ih =>\n rcases ModuleCat.enoughProjectives.1 M with ⟨⟨P, f⟩⟩\n let T := ShortComplex.mk (kernel.ι f) f (kernel.condition f)\n have T_exact : T.ShortExact := { exact := ShortComplex.exact_kernel f }\n let TS := T.map (ModuleCat.localizedModuleFunctor S)\n have TS_exact : TS.ShortExact := T_exact.map_of_exact (ModuleCat.localizedModuleFunctor S)\n have : Projective TS.X₂ := (ModuleCat.localizedModuleFunctor.{v} S).projective_obj _\n have := (T_exact.hasProjectiveDimensionLT_X₃_iff n ‹_›).mp ‹_›\n exact (TS_exact.hasProjectiveDimensionLT_X₃_iff n ‹_›).mpr (ih (kernel f))","hard_negative":true,"metrics":{"chosen_tokens":211,"rejected_tokens":5,"token_jaccard":0.036585,"token_length_ratio":0.023697},"negative_category":"wrong_namespace_qualification","negative_mode":"wrong_namespace_qualification","pair_id":"fbb1df47905796b0d973e452a04124563007035743e49225110d7e5354c72364","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Category.ModuleCat.Localization\npublic import Mathlib.Algebra.Category.ModuleCat.Projective\npublic import Mathlib.CategoryTheory.Abelian.Projective.Dimension\npublic import Mathlib.CategoryTheory.Preadditive.Projective.Preserves\npublic import Mathlib.RingTheory.LocalProperties.Projective\n\nNamespace:\nModuleCat\n\nLocal context:\n/-\nCopyright (c) 2025 Nailin Guan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nailin Guan\n-/\n/-!\n# The Projective Dimension Equal to Supremum over Localizations\n\nIn this file, we proved that projective dimension equal to supremum over localizations\n\n## Main definition and results\n\n-/\n\npublic section\n\nuniverse v u\n\nvariable {R : Type u} [CommRing R]\n\nnamespace ModuleCat\n\nopen CategoryTheory\n\nset_option backward.isDefEq.respectTransparency false in\ninstance [Small.{v} R] (S : Submonoid R) :\n (ModuleCat.localizedModuleFunctor.{v} S).PreservesProjectiveObjects where\n projective_obj X {proj} := by\n have : Small.{v} (Localization S) := small_of_surjective Localization.mkHom_surjective\n rw [← IsProjective.iff_projective] at proj ⊢\n simpa [ModuleCat.localizedModuleFunctor] using\n Module.projective_of_isLocalizedModule S (X.localizedModuleMkLinearMap S)\n\nopen Limits in\n\nTarget:\nlemma localizedModule_hasProjectiveDimensionLE [Small.{v, u} R] (n : ℕ) (S : Submonoid R)\n (M : ModuleCat.{v} R) [HasProjectiveDimensionLE M n] :\n HasProjectiveDimensionLE (M.localizedModule S) n :=\n\nProof body:\n","rejected":"by\n exact OProverMissing.missing_747210a4594e","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"7d9f916b20b7af5bdc0e845f329c00b2d24385f85632fc30a351c093d9991b36","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/LocalProperties","family_id":"localizedmodule_hasprojectivedimensionle","file_id":"mathlib/Mathlib/RingTheory/LocalProperties/ProjectiveDimension.lean","sample_id":"747210a4594e2503a2358e5528af75b8e40e99402e55088570c8b06a23a04532"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"f38421dbf56e9414828dc26da62046e34f3c258b42e8ce3616b9e9520ca3ef8f","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"148d4bb481d5fb6dd96abb5cffc2629c9e26450cf546a2d15ee9ec7face5cf4f","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"780560cffdada05dfb27b3b88a728de7a9c86e00d7d1be5929197237453d4aad","source_sha256":"142a86ea03a643e752f8050977d944e0fb955878f79a76cd95728b7f95d9b51b","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simp [isHausdorff_iff, ← Ideal.map_pow, ← SModEq.restrictScalars R,\n restrictScalars_map_smul_eq]","hard_negative":false,"metrics":{"chosen_tokens":18,"rejected_tokens":3,"token_jaccard":0.0625,"token_length_ratio":0.166667},"negative_category":"by_exact_placeholder","negative_mode":"placeholder","pair_id":"fc3a2b7a9efa2bcdec9dbbe262afafbefbe2507abb6827b8adc31f17d4419145","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Ring.GeomSum\npublic import Mathlib.LinearAlgebra.SModEq.Basic\npublic import Mathlib.RingTheory.Ideal.Quotient.PowTransition\npublic import Mathlib.RingTheory.Jacobson.Ideal\npublic import Mathlib.Tactic.SuppressCompilation\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Judith Ludwig, Christian Merten, Jiedong Jiang\n-/\n/-!\n# Completion of a module with respect to an ideal.\n\nIn this file we define the notions of Hausdorff, precomplete, and complete for an `R`-module `M`\nwith respect to an ideal `I`:\n\n## Main definitions\n\n- `IsHausdorff I M`: this says that the intersection of `I^n M` is `0`.\n- `IsPrecomplete I M`: this says that every Cauchy sequence converges.\n- `IsAdicComplete I M`: this says that `M` is Hausdorff and precomplete.\n- `Hausdorffification I M`: this is the universal Hausdorff module with a map from `M`.\n- `AdicCompletion I M`: if `I` is finitely generated, then this is the universal complete module\n with a linear map `AdicCompletion.lift` from `M`. This map is injective iff `M` is Hausdorff\n and surjective iff `M` is precomplete.\n- `IsAdicComplete.lift`: if `N` is `I`-adically complete, then a compatible family of\n linear maps `M →ₗ[R] N ⧸ (I ^ n • ⊤)` can be lifted to a unique linear map `M →ₗ[R] N`.\n Together with `mk_lift_apply` and `eq_lift`, it gives the universal property of being\n `I`-adically complete.\n-/\n\n@[expose] public section\n\nsuppress_compilation\n\nopen Submodule Ideal Quotient\n\nvariable {R S T : Type*} [CommRing R] (I : Ideal R)\nvariable (M : Type*) [AddCommGroup M] [Module R M]\nvariable {N : Type*} [AddCommGroup N] [Module R N]\n\n/-- A module `M` is Hausdorff with respect to an ideal `I` if `⋂ I^n M = 0`. -/\nclass IsHausdorff : Prop where\n haus' : ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0\n\n/-- A module `M` is precomplete with respect to an ideal `I` if every Cauchy sequence converges. -/\nclass IsPrecomplete : Prop where\n prec' : ∀ f : ℕ → M, (∀ {m n}, m ≤ n → f m ≡ f n [SMOD (I ^ m • ⊤ : Submodule R M)]) →\n ∃ L : M, ∀ n, f n ≡ L [SMOD (I ^ n • ⊤ : Submodule R M)]\n\n/-- A module `M` is `I`-adically complete if it is Hausdorff and precomplete. -/\n@[mk_iff, stacks 0317 \"see also `IsAdicComplete.of_bijective_iff`\"]\nclass IsAdicComplete : Prop extends IsHausdorff I M, IsPrecomplete I M\n\nvariable {I M}\n\ntheorem IsHausdorff.haus (_ : IsHausdorff I M) :\n ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0 :=\n IsHausdorff.haus'\n\ntheorem isHausdorff_iff :\n IsHausdorff I M ↔ ∀ x : M, (∀ n : ℕ, x ≡ 0 [SMOD (I ^ n • ⊤ : Submodule R M)]) → x = 0 :=\n ⟨IsHausdorff.haus, fun h => ⟨h⟩⟩\n\ntheorem IsHausdorff.eq_iff_smodEq [IsHausdorff I M] {x y : M} :\n x = y ↔ ∀ n, x ≡ y [SMOD (I ^ n • ⊤ : Submodule R M)] := by\n refine ⟨fun h _ ↦ h ▸ rfl, fun h ↦ ?_⟩\n rw [← sub_eq_zero]\n apply IsHausdorff.haus' (I := I) (x - y)\n simpa [SModEq.sub_mem] using h\n\nTarget:\ntheorem IsHausdorff.map_algebraMap_iff [CommRing S] [Module S M] [Algebra R S]\n [IsScalarTower R S M] : IsHausdorff (I.map (algebraMap R S)) M ↔ IsHausdorff I M :=\n\nProof body:\n","rejected":"by\n exact placeholder","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RingTheory/AdicCompletion","family_id":"ishausdorff","file_id":"mathlib/Mathlib/RingTheory/AdicCompletion/Basic.lean","sample_id":"780560cffdada05dfb27b3b88a728de7a9c86e00d7d1be5929197237453d4aad"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"e2c3f03502a36f2d3357f89030ca66dd887fbc9daafefb793c746e731117f866","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"2af75a321b916b3337f89da8b79bae729de74613c321038fc2fb61a0642cab4d","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"6bf1c58c486e033e9ca4b8d0f8d314f8788d09995ff244a4d844d5f6b7a86e07","source_sha256":"a9f5a2e040db478eb9f090e7d70b777b335932049f29e1fe5943dbeb9bc624ee","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [Algebra.algebraMap_eq_smul_one]\n exact IsStrictlyPositive.smul hc isStrictlyPositive_one","hard_negative":false,"metrics":{"chosen_tokens":13,"rejected_tokens":17,"token_jaccard":0.8,"token_length_ratio":1.307692},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"fcd14be5e626ba2065987f5114408bad97202a24f8c0b8af10953d967cc7d312","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum\npublic import Mathlib.Algebra.Order.Star.Basic\npublic import Mathlib.Algebra.Order.Module.Defs\npublic import Mathlib.Tactic.ContinuousFunctionalCalculus\n\nNamespace:\nIsStrictlyPositive\n\nLocal context:\n/-\nCopyright (c) 2025 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\n/-!\n# Strictly positive elements of an algebra\n\nThis file introduces strictly positive elements of an algebra (also known as positive definite\nelements). This is mostly used for C⋆-algebras, but the basic definition makes sense in a more\ngeneral context.\n\n## Implementation notes\n\nNote that, while the current definition is adequate in the unital case, it will eventually be\nreplaced by a definition that makes sense in the non-unital case (an element is strictly\npositive if the hereditary C⋆-subalgebra generated by that element is the whole algebra).\nThus, it is best to avoid unfolding the definition and only use the API provided.\n\n## TODO\n\n+ Generalize the definition to non-unital algebras.\n-/\n\n@[expose] public section\n\n/-- An element of an ordered algebra is *strictly positive* if it is nonnegative and invertible.\n\nNOTE: This definition will be generalized to the non-unital case in the future; do not unfold\nthe definition and use the API provided instead to avoid breakage when the refactor happens. -/\ndef IsStrictlyPositive {A : Type*} [LE A] [Monoid A] [Zero A] (a : A) : Prop :=\n 0 ≤ a ∧ IsUnit a\n\nvariable {A : Type*}\n\nnamespace IsStrictlyPositive\n\nsection basic\n\n@[grind _=_]\nlemma iff_of_unital [LE A] [Monoid A] [Zero A] {a : A} :\n IsStrictlyPositive a ↔ 0 ≤ a ∧ IsUnit a := Iff.rfl\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma nonneg [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n 0 ≤ a := ha.1\n\n@[aesop 20% apply (rule_sets := [CStarAlgebra])]\nprotected lemma isUnit [LE A] [Monoid A] [Zero A] {a : A} (ha : IsStrictlyPositive a) :\n IsUnit a := ha.2\n\nlemma _root_.IsUnit.isStrictlyPositive [LE A] [Monoid A] [Zero A]\n {a : A} (ha : IsUnit a) (ha₀ : 0 ≤ a) : IsStrictlyPositive a := iff_of_unital.mpr ⟨ha₀, ha⟩\n\n@[grind →]\nlemma isSelfAdjoint [Semiring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] {a : A}\n (ha : IsStrictlyPositive a) : IsSelfAdjoint a := ha.nonneg.isSelfAdjoint\n\n@[simp, grind .]\nlemma _root_.isStrictlyPositive_one [LE A] [Monoid A] [Zero A] [ZeroLEOneClass A] :\n IsStrictlyPositive (1 : A) := iff_of_unital.mpr ⟨zero_le_one, isUnit_one⟩\n\n@[grind =]\nlemma _root_.Units.isStrictlyPositive_iff [LE A] [Monoid A] [Zero A] {a : Aˣ} :\n IsStrictlyPositive (a : A) ↔ (0 : A) ≤ a :=\n ⟨fun h => h.nonneg, fun h => iff_of_unital.mp ⟨h, a.isUnit⟩⟩\n\n@[aesop safe apply]\nlemma _root_.Units.isStrictlyPositive_of_le [LE A] [Monoid A] [Zero A] {a : Aˣ}\n (h : (0 : A) ≤ a) : IsStrictlyPositive (a : A) := a.isStrictlyPositive_iff.mpr h\n\n@[nontriviality]\nprotected lemma of_subsingleton [PartialOrder A] [Monoid A] [Zero A] [Subsingleton A]\n {a : A} : IsStrictlyPositive a :=\n iff_of_unital.mpr ⟨by simp, isUnit_of_subsingleton _⟩\n\nend basic\n\nsection StarOrderedRing\nvariable [Semiring A] [StarRing A] [PartialOrder A] [StarOrderedRing A]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_right_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (u * a * star u) ↔ IsStrictlyPositive a := by\n simp_rw [IsStrictlyPositive.iff_of_unital, hu.star_right_conjugate_nonneg_iff]\n lift u to Aˣ using hu\n rw [← Units.coe_star, Units.isUnit_mul_units, Units.isUnit_units_mul]\n\nlemma _root_.IsUnit.isStrictlyPositive_star_left_conjugate_iff {u a : A} (hu : IsUnit u) :\n IsStrictlyPositive (star u * a * u) ↔ IsStrictlyPositive a := by\n simpa using hu.star.isStrictlyPositive_star_right_conjugate_iff\n\n@[grind =]\ntheorem _root_.IsUnit.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) :\n IsStrictlyPositive (b * a * b) ↔ IsStrictlyPositive a := by\n grind [hb.isStrictlyPositive_star_left_conjugate_iff]\n\n@[aesop safe apply]\ntheorem conjugate_of_isUnit_of_isSelfAdjoint (a b : A) (hb : IsUnit b)\n (hb₂ : IsSelfAdjoint b := by cfc_tac) (ha : IsStrictlyPositive a := by cfc_tac) :\n IsStrictlyPositive (b * a * b) :=\n (hb.isStrictlyPositive_iff_conjugate_of_isSelfAdjoint _ _ hb₂).mpr ha\n\nend StarOrderedRing\n\nsection Algebra\n\nvariable {𝕜 : Type*} [Ring A] [PartialOrder A]\n\n@[grind ←, aesop safe apply]\nprotected lemma smul [Semifield 𝕜] [PartialOrder 𝕜] [Algebra 𝕜 A] [PosSMulMono 𝕜 A] {c : 𝕜}\n (hc : 0 < c) {a : A} (ha : IsStrictlyPositive a) :\n IsStrictlyPositive (c • a) := by\n have hunit : IsUnit (c • a) :=\n isUnit_iff_exists.mpr ⟨c⁻¹ • ha.isUnit.unit⁻¹, by simp [(ne_of_lt hc).symm]⟩\n exact hunit.isStrictlyPositive (smul_nonneg hc.le ha.nonneg)\n\n@[grind ←, aesop safe apply]\n\nTarget:\nlemma _root_.isStrictlyPositive_algebraMap [ZeroLEOneClass A] [Semifield 𝕜] [PartialOrder 𝕜]\n [Algebra 𝕜 A] [PosSMulMono 𝕜 A] {c : 𝕜} (hc : 0 < c) :\n IsStrictlyPositive (algebraMap 𝕜 A c) :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n rw [Algebra.algebraMap_eq_smul_one]\n exact IsStrictlyPositive.smul hc isStrictlyPositive_one","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"","family_id":"root","file_id":"mathlib/Mathlib/Algebra/Algebra/StrictPositivity.lean","sample_id":"6bf1c58c486e033e9ca4b8d0f8d314f8788d09995ff244a4d844d5f6b7a86e07"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"691b1fefb19774703ba0da236f43d75a9d1f0b1c59002daa309bfac351b1f1b9","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"9c73f768c6b902af55b2843988f629261dd4578a5cd1d557b1db1ff4ef22ed0b","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"c90c23334e026050c80f802c56492155a41fc40ab2e2d1bfb4570af88050ded5","source_sha256":"976709af1494098e2290d3c3a6a052dad499a43ec44c3bd6016d3ce147bb9165","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n simpa using map_add_zsmul f 0 n","hard_negative":false,"metrics":{"chosen_tokens":7,"rejected_tokens":2,"token_jaccard":0.125,"token_length_ratio":0.285714},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorry","pair_id":"fd467c5c17aaae5a80c623fd180359eaa78a33739b1aadd6e7f80315401bef00","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.Action.Pi\npublic import Mathlib.Algebra.Group.End\npublic import Mathlib.Algebra.Module.NatInt\npublic import Mathlib.Algebra.Order.Archimedean.Basic\nimport Mathlib.Algebra.Order.Group.Basic\n\nNamespace:\nAddConstMapClass\n\nLocal context:\n/-\nCopyright (c) 2024 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\n/-!\n# Maps (semi)conjugating a shift to a shift\n\nDenote by $S^1$ the unit circle `UnitAddCircle`.\nA common way to study a self-map $f\\colon S^1\\to S^1$ of degree `1`\nis to lift it to a map $\\tilde f\\colon \\mathbb R\\to \\mathbb R$\nsuch that $\\tilde f(x + 1) = \\tilde f(x)+1$ for all `x`.\n\nIn this file we define a structure and a typeclass\nfor bundled maps satisfying `f (x + a) = f x + b`.\n\nWe use parameters `a` and `b` instead of `1` to accommodate for two use cases:\n\n- maps between circles of different lengths;\n- self-maps $f\\colon S^1\\to S^1$ of degree other than one,\n including orientation-reversing maps.\n-/\n\n@[expose] public section\n\nassert_not_exists Finset\n\nopen Function Set\n\n/-- A bundled map `f : G → H` such that `f (x + a) = f x + b` for all `x`,\ndenoted as `f : G →+c[a, b] H`.\n\nOne can think about `f` as a lift to `G` of a map between two `AddCircle`s. -/\nstructure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where\n /-- The underlying function of an `AddConstMap`.\n Use automatic coercion to function instead. -/\n protected toFun : G → H\n /-- An `AddConstMap` satisfies `f (x + a) = f x + b`. Use `map_add_const` instead. -/\n map_add_const' (x : G) : toFun (x + a) = toFun x + b\n\n@[inherit_doc]\nscoped[AddConstMap] notation:25 G \" →+c[\" a \", \" b \"] \" H => AddConstMap G H a b\n\n/-- Typeclass for maps satisfying `f (x + a) = f x + b`.\n\nNote that `a` and `b` are `outParam`s,\nso one should not add instances like\n`[AddConstMapClass F G H a b] : AddConstMapClass F G H (-a) (-b)`. -/\nclass AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H]\n (a : outParam G) (b : outParam H) [FunLike F G H] : Prop where\n /-- A map of `AddConstMapClass` class semiconjugates shift by `a` to the shift by `b`:\n `∀ x, f (x + a) = f x + b`. -/\n map_add_const (f : F) (x : G) : f (x + a) = f x + b\n\nnamespace AddConstMapClass\n\n/-!\n### Properties of `AddConstMapClass` maps\n\nIn this section we prove properties like `f (x + n • a) = f x + n • b`.\n-/\n\nscoped[AddConstMapClass] attribute [simp] map_add_const\n\nvariable {F G H : Type*} [FunLike F G H] {a : G} {b : H}\n\nprotected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n Semiconj f (· + a) (· + b) :=\n map_add_const f\n\n@[scoped simp]\ntheorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by\n simpa using (AddConstMapClass.semiconj f).iterate_right n x\n\n@[scoped simp]\ntheorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by simp [← map_add_nsmul]\n\ntheorem map_add_one [AddMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x + 1) = f x + b := map_add_const f x\n\n@[scoped simp]\ntheorem map_add_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + (ofNat(n) : ℕ) • b :=\n map_add_nat' f x n\n\ntheorem map_add_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n := by simp\n\ntheorem map_add_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x + ofNat(n)) = f x + ofNat(n) := map_add_nat f x n\n\n@[scoped simp]\ntheorem map_const [AddZeroClass G] [Add H] [AddConstMapClass F G H a b] (f : F) :\n f a = f 0 + b := by\n simpa using map_add_const f 0\n\ntheorem map_one [AddZeroClass G] [One G] [Add H] [AddConstMapClass F G H 1 b] (f : F) :\n f 1 = f 0 + b :=\n map_const f\n\n@[scoped simp]\ntheorem map_nsmul_const [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (n : ℕ) : f (n • a) = f 0 + n • b := by\n simpa using map_add_nsmul f 0 n\n\n@[scoped simp]\ntheorem map_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) : f n = f 0 + n • b := by\n simpa using map_add_nat' f 0 n\n\ntheorem map_ofNat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) [n.AtLeastTwo] :\n f (ofNat(n)) = f 0 + (ofNat(n) : ℕ) • b :=\n map_nat' f n\n\ntheorem map_nat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) : f n = f 0 + n := by simp\n\ntheorem map_ofNat [AddMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) [n.AtLeastTwo] :\n f ofNat(n) = f 0 + ofNat(n) := map_nat f n\n\n@[scoped simp]\ntheorem map_const_add [AddCommMagma G] [Add H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : f (a + x) = f x + b := by\n rw [add_comm, map_add_const]\n\ntheorem map_one_add [AddCommMonoidWithOne G] [Add H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (1 + x) = f x + b := map_const_add f x\n\n@[scoped simp]\ntheorem map_nsmul_add [AddCommMonoid G] [AddMonoid H] [AddConstMapClass F G H a b]\n (f : F) (n : ℕ) (x : G) : f (n • a + x) = f x + n • b := by\n rw [add_comm, map_add_nsmul]\n\n@[scoped simp]\ntheorem map_nat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n • b := by\n simpa using map_nsmul_add f n x\n\ntheorem map_ofNat_add' [AddCommMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b]\n (f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :\n f (ofNat(n) + x) = f x + ofNat(n) • b :=\n map_nat_add' f n x\n\ntheorem map_nat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) (x : G) : f (↑n + x) = f x + n := by simp\n\ntheorem map_ofNat_add [AddCommMonoidWithOne G] [AddMonoidWithOne H] [AddConstMapClass F G H 1 1]\n (f : F) (n : ℕ) [n.AtLeastTwo] (x : G) :\n f (ofNat(n) + x) = f x + ofNat(n) :=\n map_nat_add f n x\n\n@[scoped simp]\ntheorem map_sub_nsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) (n : ℕ) : f (x - n • a) = f x - n • b := by\n conv_rhs => rw [← sub_add_cancel x (n • a), map_add_nsmul, add_sub_cancel_right]\n\n@[scoped simp]\ntheorem map_sub_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : f (x - a) = f x - b := by\n simpa using map_sub_nsmul f x 1\n\ntheorem map_sub_one [AddGroup G] [One G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) : f (x - 1) = f x - b :=\n map_sub_const f x\n\n@[scoped simp]\ntheorem map_sub_nat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) : f (x - n) = f x - n • b := by\n simpa using map_sub_nsmul f x n\n\n@[scoped simp]\ntheorem map_sub_ofNat' [AddGroupWithOne G] [AddGroup H] [AddConstMapClass F G H 1 b]\n (f : F) (x : G) (n : ℕ) [n.AtLeastTwo] :\n f (x - ofNat(n)) = f x - ofNat(n) • b :=\n map_sub_nat' f x n\n\n@[scoped simp]\ntheorem map_add_zsmul [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (x : G) : ∀ n : ℤ, f (x + n • a) = f x + n • b\n | (n : ℕ) => by simp\n | .negSucc n => by simp [← sub_eq_add_neg]\n\n@[scoped simp]\n\nTarget:\ntheorem map_zsmul_const [AddGroup G] [AddGroup H] [AddConstMapClass F G H a b]\n (f : F) (n : ℤ) : f (n • a) = f 0 + n • b :=\n\nProof body:\n","rejected":"by\n sorry","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Algebra/AddConstMap","family_id":"map_zsmul_const","file_id":"mathlib/Mathlib/Algebra/AddConstMap/Basic.lean","sample_id":"c90c23334e026050c80f802c56492155a41fc40ab2e2d1bfb4570af88050ded5"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"1ac71a1335fae03f9ab4015f0cbc3ac0d6dcc2e5c97110e96fdcbcf709f6b896","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"ea345e91a65af4ef990588fa9afee203262d2dd25f650177b79e2e2b94589052","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"0bea8797c6d495662c882fbef1ee471c2eff47dfde392f3050e338bb7b68ba59","source_sha256":"041ed7418835f513eaa8645f42a9c7a8b7fd952d76bd23f080a507a71e985240","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by rw [pn.out, Nat.cast_zero, Multiset.range_zero]","hard_negative":false,"metrics":{"chosen_tokens":15,"rejected_tokens":22,"token_jaccard":0.857143,"token_length_ratio":1.466667},"negative_category":"markdown_preamble_trailing","negative_mode":"fence","pair_id":"fe51072a38f4b0c72e62e765fc3e293f576b175e4264583f73d109fc8beecd34","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.BigOperators.Group.Finset.Basic -- shake: keep (Qq dependency)\npublic import Mathlib.Tactic.NormNum.Basic\n\nNamespace:\nMathlib.Meta\n\nLocal context:\n/-\nCopyright (c) 2023 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Floris van Doorn\n-/\n/-!\n# `norm_num` plugin for big operators\n\nThis file adds `norm_num` plugins for `Finset.prod` and `Finset.sum`.\n\nThe driving part of this plugin is `Mathlib.Meta.NormNum.evalFinsetBigop`.\nWe repeatedly use `Finset.proveEmptyOrCons` to try to find a proof that the given set is empty,\nor that it consists of one element inserted into a strict subset, and evaluate the big operator\non that subset until the set is completely exhausted.\n\n## See also\n\n* The `fin_cases` tactic has similar scope: splitting out a finite collection into its elements.\n\n## Porting notes\n\nThis plugin is noticeably less powerful than the equivalent version in Mathlib 3: the design of\n`norm_num` means plugins have to return numerals, rather than a generic expression.\nIn particular, we can't use the plugin on sums containing variables.\n(See also the TODO note \"To support variables\".)\n\n## TODO\n\n* Support intervals: `Finset.Ico`, `Finset.Icc`, ...\n* To support variables, like in Mathlib 3, turn this into a standalone tactic that unfolds\n the sum/prod, without computing its numeric value (using the `ring` tactic to do some\n normalization?)\n-/\n\npublic meta section\n\nnamespace Mathlib.Meta\n\nopen Lean\nopen Meta\nopen Qq\n\nvariable {u v : Level}\n\n/-- This represents the result of trying to determine whether the given expression `n : Q(ℕ)`\nis either `zero` or `succ`. -/\ninductive Nat.UnifyZeroOrSuccResult (n : Q(ℕ))\n /-- `n` unifies with `0` -/\n | zero (pf : $n =Q 0)\n /-- `n` unifies with `succ n'` for this specific `n'` -/\n | succ (n' : Q(ℕ)) (pf : $n =Q Nat.succ $n')\n\n/-- Determine whether the expression `n : Q(ℕ)` unifies with `0` or `Nat.succ n'`.\n\nWe do not use `norm_num` functionality because we want definitional equality,\nnot propositional equality, for use in dependent types.\n\nFails if neither of the options succeed.\n-/\ndef Nat.unifyZeroOrSucc (n : Q(ℕ)) : MetaM (Nat.UnifyZeroOrSuccResult n) := do\n match ← isDefEqQ n q(0) with\n | .defEq pf => return .zero pf\n | .notDefEq => do\n let n' : Q(ℕ) ← mkFreshExprMVar q(ℕ)\n let ⟨(_pf : $n =Q Nat.succ $n')⟩ ← assertDefEqQ n q(Nat.succ $n')\n let (.some (n'_val : Q(ℕ))) ← getExprMVarAssignment? n'.mvarId! |\n throwError \"could not figure out value of `?n` from `{n} =?= Nat.succ ?n`\"\n pure (.succ n'_val ⟨⟩)\n\n/-- This represents the result of trying to determine whether the given expression\n`s : Q(List $α)` is either empty or consists of an element inserted into a strict subset. -/\ninductive List.ProveNilOrConsResult {α : Q(Type u)} (s : Q(List $α))\n /-- The set is Nil. -/\n | nil (pf : Q($s = []))\n /-- The set equals `a` inserted into the strict subset `s'`. -/\n | cons (a : Q($α)) (s' : Q(List $α)) (pf : Q($s = List.cons $a $s'))\n\n/-- If `s` unifies with `t`, convert a result for `s` to a result for `t`.\n\nIf `s` does not unify with `t`, this results in a type-incorrect proof.\n-/\ndef List.ProveNilOrConsResult.uncheckedCast {α : Q(Type u)} {β : Q(Type v)}\n (s : Q(List $α)) (t : Q(List $β)) :\n List.ProveNilOrConsResult s → List.ProveNilOrConsResult t\n | .nil pf => .nil pf\n | .cons a s' pf => .cons a s' pf\n\n/-- If `s = t` and we can get the result for `t`, then we can get the result for `s`.\n-/\ndef List.ProveNilOrConsResult.eq_trans {α : Q(Type u)} {s t : Q(List $α)}\n (eq : Q($s = $t)) :\n List.ProveNilOrConsResult t → List.ProveNilOrConsResult s\n | .nil pf => .nil q(Eq.trans $eq $pf)\n | .cons a s' pf => .cons a s' q(Eq.trans $eq $pf)\n\nlemma List.range_zero' {n : ℕ} (pn : NormNum.IsNat n 0) :\n List.range n = [] := by rw [pn.out, Nat.cast_zero, List.range_zero]\n\nlemma List.range_succ_eq_map' {n nn n' : ℕ} (pn : NormNum.IsNat n nn) (pn' : nn = Nat.succ n') :\n List.range n = 0 :: List.map Nat.succ (List.range n') := by\n rw [pn.out, Nat.cast_id, pn', List.range_succ_eq_map]\n\nset_option linter.unusedVariables false in\n/-- Either show the expression `s : Q(List α)` is Nil, or remove one element from it.\n\nFails if we cannot determine which of the alternatives apply to the expression.\n-/\npartial def List.proveNilOrCons {u : Level} {α : Q(Type u)} (s : Q(List $α)) :\n MetaM (List.ProveNilOrConsResult s) :=\n s.withApp fun e a =>\n match (e, e.constName, a) with\n | (_, ``EmptyCollection.emptyCollection, _) => haveI : $s =Q {} := ⟨⟩; pure (.nil q(.refl []))\n | (_, ``List.nil, _) => haveI : $s =Q [] := ⟨⟩; pure (.nil q(rfl))\n | (_, ``List.cons, #[_, (a : Q($α)), (s' : Q(List $α))]) =>\n haveI : $s =Q $a :: $s' := ⟨⟩; pure (.cons a s' q(rfl))\n | (_, ``List.range, #[(n : Q(ℕ))]) =>\n have s : Q(List ℕ) := s; .uncheckedCast _ _ <$> show MetaM (ProveNilOrConsResult s) from do\n let ⟨nn, pn⟩ ← NormNum.deriveNat n _\n haveI' : $s =Q .range $n := ⟨⟩\n let nnL := nn.natLit!\n if nnL = 0 then\n haveI' : $nn =Q 0 := ⟨⟩\n return .nil q(List.range_zero' $pn)\n else\n have n' : Q(ℕ) := mkRawNatLit (nnL - 1)\n have : $nn =Q .succ $n' := ⟨⟩\n return .cons _ _ q(List.range_succ_eq_map' $pn (.refl $nn))\n | (_, ``List.finRange, #[(n : Q(ℕ))]) =>\n have s : Q(List (Fin $n)) := s\n .uncheckedCast _ _ <$> show MetaM (ProveNilOrConsResult s) from do\n haveI' : $s =Q .finRange $n := ⟨⟩\n return match ← Nat.unifyZeroOrSucc n with -- We want definitional equality on `n`.\n | .zero _pf => .nil q(List.finRange_zero)\n | .succ n' _pf => .cons _ _ q(List.finRange_succ)\n | (.const ``List.map [v, _], _, #[(β : Q(Type v)), _, (f : Q($β → $α)), (xxs : Q(List $β))]) => do\n haveI' : $s =Q ($xxs).map $f := ⟨⟩\n return match ← List.proveNilOrCons xxs with\n | .nil pf => .nil q(($pf ▸ List.map_nil : List.map _ _ = _))\n | .cons x xs pf => .cons q($f $x) q(($xs).map $f)\n q(($pf ▸ List.map_cons : List.map _ _ = _))\n | (_, fn, args) =>\n throwError \"List.proveNilOrCons: unsupported List expression {s} ({fn}, {args})\"\n\n/-- This represents the result of trying to determine whether the given expression\n`s : Q(Multiset $α)` is either empty or consists of an element inserted into a strict subset. -/\ninductive Multiset.ProveZeroOrConsResult {α : Q(Type u)} (s : Q(Multiset $α))\n /-- The set is zero. -/\n | zero (pf : Q($s = 0))\n /-- The set equals `a` inserted into the strict subset `s'`. -/\n | cons (a : Q($α)) (s' : Q(Multiset $α)) (pf : Q($s = Multiset.cons $a $s'))\n\n/-- If `s` unifies with `t`, convert a result for `s` to a result for `t`.\n\nIf `s` does not unify with `t`, this results in a type-incorrect proof.\n-/\ndef Multiset.ProveZeroOrConsResult.uncheckedCast {α : Q(Type u)} {β : Q(Type v)}\n (s : Q(Multiset $α)) (t : Q(Multiset $β)) :\n Multiset.ProveZeroOrConsResult s → Multiset.ProveZeroOrConsResult t\n | .zero pf => .zero pf\n | .cons a s' pf => .cons a s' pf\n\n/-- If `s = t` and we can get the result for `t`, then we can get the result for `s`.\n-/\ndef Multiset.ProveZeroOrConsResult.eq_trans {α : Q(Type u)} {s t : Q(Multiset $α)}\n (eq : Q($s = $t)) :\n Multiset.ProveZeroOrConsResult t → Multiset.ProveZeroOrConsResult s\n | .zero pf => .zero q(Eq.trans $eq $pf)\n | .cons a s' pf => .cons a s' q(Eq.trans $eq $pf)\n\nlemma Multiset.insert_eq_cons {α : Type*} (a : α) (s : Multiset α) :\n insert a s = Multiset.cons a s :=\n rfl\n\nTarget:\nlemma Multiset.range_zero' {n : ℕ} (pn : NormNum.IsNat n 0) :\n Multiset.range n = 0 :=\n\nProof body:\n","rejected":"```lean\nby rw [pn.out, Nat.cast_zero, Multiset.range_zero]\n```","rejection":{"accepted":false,"all_failure_types":["markdown_fence","not_exact_by_body"],"failure_type":"markdown_fence","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Tactic/NormNum","family_id":"multiset","file_id":"mathlib/Mathlib/Tactic/NormNum/BigOperators.lean","sample_id":"0bea8797c6d495662c882fbef1ee471c2eff47dfde392f3050e338bb7b68ba59"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"b07da493aef42dcb65829c07e1ff4bc0526efd92ad0c23db6a3eafe98a05cab2","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"e6432d29ef4ba24cfd7ea5c2ca105f906cb2d6c17cea1ff2533b15568a777269","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ee0d60117e2bd6b50781085cb3777fe25d3de0a7b2ab516ed7096cf33c67614b","source_sha256":"2eab1d38ccdaa92e1a432add87cdb2bed24c758ae0a16e06939eabd2b19764ab","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rcases h₁.lt_or_gt with h₁ | h₁\n · have : 1 - x ^ 2 < 0 := by nlinarith [h₁]\n rw [sqrt_eq_zero'.2 this.le, div_zero]\n have : arcsin =ᶠ[𝓝 x] fun _ => -(π / 2) :=\n (gt_mem_nhds h₁).mono fun y hy => arcsin_of_le_neg_one hy.le\n exact ⟨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,\n contDiffAt_const.congr_of_eventuallyEq this⟩\n rcases h₂.lt_or_gt with h₂ | h₂\n · have : 0 < √(1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h₁, h₂])\n simp only [← cos_arcsin, one_div] at this ⊢\n exact ⟨sinPartialHomeomorph.hasStrictDerivAt_symm ⟨h₁, h₂⟩ this.ne' (hasStrictDerivAt_sin _),\n sinPartialHomeomorph.contDiffAt_symm_deriv this.ne' ⟨h₁, h₂⟩ (hasDerivAt_sin _)\n contDiff_sin.contDiffAt⟩\n · have : 1 - x ^ 2 < 0 := by nlinarith [h₂]\n rw [sqrt_eq_zero'.2 this.le, div_zero]\n have : arcsin =ᶠ[𝓝 x] fun _ => π / 2 := (lt_mem_nhds h₂).mono fun y hy => arcsin_of_one_le hy.le\n exact ⟨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,\n contDiffAt_const.congr_of_eventuallyEq this⟩","hard_negative":false,"metrics":{"chosen_tokens":260,"rejected_tokens":5,"token_jaccard":0.041096,"token_length_ratio":0.019231},"negative_category":"sorry_admit_sorryAx_proof_hole","negative_mode":"sorryAx","pair_id":"fecb635c969e20ba98dff4b469937422fc1dfda9440dbf0ff24c4b30abacda4d","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse\npublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv\n\nNamespace:\nReal\n\nLocal context:\n/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson\n-/\n/-!\n# derivatives of the inverse trigonometric functions\n\nDerivatives of `arcsin` and `arccos`.\n-/\n\npublic section\n\nnoncomputable section\n\nopen scoped Topology Filter Real ContDiff\nopen Set\n\nnamespace Real\n\nsection Arcsin\n\nTarget:\ntheorem deriv_arcsin_aux {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n HasStrictDerivAt arcsin (1 / √(1 - x ^ 2)) x ∧ ContDiffAt ℝ ω arcsin x :=\n\nProof body:\n","rejected":"by\n exact sorryAx _ true","rejection":{"accepted":false,"all_failure_types":["proof_hole_or_search_placeholder"],"failure_type":"proof_hole_or_search_placeholder","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Analysis/SpecialFunctions","family_id":"deriv_arcsin_aux","file_id":"mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean","sample_id":"ee0d60117e2bd6b50781085cb3777fe25d3de0a7b2ab516ed7096cf33c67614b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"2c9ba50e9e1bb70040fd117a7261d87360d04aa82494173dae5e3edcb8ee182c","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"537311d6634f3b1f0da218b2dcbd0d3d3cd9a6256cd19d7500df7e3fb4c45046","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"151bd6343ce6efc88f7c7af395fa56b97569a0eb6c7ed6b43645660f392cf13a","source_sha256":"5b8c2af2d3decf7ecd5055a9af72eebcb8ad7bb17d12bd917e766de67c6175aa","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n have h_int := h.integrable_exp_mul 1\n simpa using (aemeasurable_of_aemeasurable_exp h_int.1.aemeasurable).aestronglyMeasurable","hard_negative":true,"metrics":{"chosen_tokens":20,"rejected_tokens":3,"token_jaccard":0.058824,"token_length_ratio":0.15},"negative_category":"unknown_identifier","negative_mode":"unknown_identifier","pair_id":"fecd2c2917176705c1f1945137a8034a2401172ecad13185a71672b6abb53204","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Probability.Kernel.Condexp\npublic import Mathlib.Probability.Moments.MGFAnalytic\npublic import Mathlib.Probability.Moments.Tilted\n\nNamespace:\nProbabilityTheory.Kernel.HasSubgaussianMGF\n\nLocal context:\n/-\nCopyright (c) 2025 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n/-!\n# Sub-Gaussian random variables\n\nThis presentation of sub-Gaussian random variables is inspired by section 2.5 of\n[vershynin2018high]. Let `X` be a random variable. Consider the following five properties, in which\n`Kᵢ` are positive reals,\n* (i) for all `t ≥ 0`, `ℙ(|X| ≥ t) ≤ 2 * exp(-t^2 / K₁^2)`,\n* (ii) for all `p : ℕ` with `1 ≤ p`, `𝔼[|X|^p]^(1/p) ≤ K₂ sqrt(p)`,\n* (iii) for all `|t| ≤ 1/K₃`, `𝔼[exp (t^2 * X^2)] ≤ exp (K₃^2 * t^2)`,\n* (iv) `𝔼[exp(X^2 / K₄)] ≤ 2`,\n* (v) for all `t : ℝ`, `𝔼[exp (t * X)] ≤ exp (K₅ * t^2 / 2)`.\n\nProperties (i) to (iv) are equivalent, in the sense that there exists a constant `C` such that\nif `X` satisfies one of those properties with constant `K`, then it satisfies any other one with\nconstant at most `CK`.\n\nIf `𝔼[X] = 0` then properties (i)-(iv) are equivalent to (v) in that same sense.\nProperty (v) implies that `X` has expectation zero.\n\nThe name sub-Gaussian is used by various authors to refer to any one of (i)-(v). We will say that a\nrandom variable has sub-Gaussian moment-generating function (mgf) with constant `K₅` to mean that\nproperty (v) holds with that constant. The function `exp (K₅ * t^2 / 2)` which appears in\nproperty (v) is the mgf of a Gaussian with variance `K₅`.\nThat property (v) is the most convenient one to work with if one wants to prove concentration\ninequalities using Chernoff's method.\n\nTODO: implement definitions for (i)-(iv) when it makes sense. For example the maximal constant `K₄`\nsuch that (iv) is true is an Orlicz norm. Prove relations between those properties.\n\n### Conditionally sub-Gaussian random variables and kernels\n\nA related notion to sub-Gaussian random variables is that of conditionally sub-Gaussian random\nvariables. A random variable `X` is conditionally sub-Gaussian in the sense of (v) with respect to\na sigma-algebra `m` and a measure `μ` if for all `t : ℝ`, `exp (t * X)` is `μ`-integrable and\nthe conditional mgf of `X` conditioned on `m` is almost surely bounded by `exp (c * t^2 / 2)`\nfor some constant `c`.\n\nAs in other parts of Mathlib's probability library (notably the independence and conditional\nindependence definitions), we express both sub-Gaussian and conditionally sub-Gaussian properties\nas special cases of a notion of sub-Gaussianity with respect to a kernel and a measure.\n\n## Main definitions\n\n* `Kernel.HasSubgaussianMGF`: a random variable `X` has a sub-Gaussian moment-generating function\n with parameter `c` with respect to a kernel `κ` and a measure `ν` if for `ν`-almost all `ω'`,\n for all `t : ℝ`, the moment-generating function of `X` with respect to `κ ω'` is bounded by\n `exp (c * t ^ 2 / 2)`.\n* `HasCondSubgaussianMGF`: a random variable `X` has a conditionally sub-Gaussian moment-generating\n function with parameter `c` with respect to a sigma-algebra `m` and a measure `μ` if for all\n `t : ℝ`, `exp (t * X)` is `μ`-integrable and the moment-generating function of `X` conditioned\n on `m` is almost surely bounded by `exp (c * t ^ 2 / 2)` for all `t : ℝ`.\n The actual definition uses `Kernel.HasSubgaussianMGF`: `HasCondSubgaussianMGF` is defined as\n sub-Gaussian with respect to the conditional expectation kernel for `m` and the restriction of `μ`\n to the sigma-algebra `m`.\n* `HasSubgaussianMGF`: a random variable `X` has a sub-Gaussian moment-generating function\n with parameter `c` with respect to a measure `μ` if for all `t : ℝ`, `exp (t * X)`\n is `μ`-integrable and the moment-generating function of `X` is bounded by `exp (c * t ^ 2 / 2)`\n for all `t : ℝ`.\n This is equivalent to `Kernel.HasSubgaussianMGF` with a constant kernel.\n See `HasSubgaussianMGF_iff_kernel`.\n\n## Main statements\n\n* `measure_sum_ge_le_of_iIndepFun`: Hoeffding's inequality for sums of independent sub-Gaussian\n random variables.\n* `hasSubgaussianMGF_of_mem_Icc_of_integral_eq_zero`: Hoeffding's lemma for random variables with\n expectation zero.\n* `measure_sum_ge_le_of_HasCondSubgaussianMGF`: the Azuma-Hoeffding inequality for sub-Gaussian\n random variables.\n\n## Implementation notes\n\n### Definition of `Kernel.HasSubgaussianMGF`\n\nThe definition of sub-Gaussian with respect to a kernel and a measure is the following:\n```\nstructure Kernel.HasSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0)\n (κ : Kernel Ω' Ω) (ν : Measure Ω' := by volume_tac) : Prop where\n integrable_exp_mul : ∀ t, Integrable (fun ω ↦ exp (t * X ω)) (κ ∘ₘ ν)\n mgf_le : ∀ᵐ ω' ∂ν, ∀ t, mgf X (κ ω') t ≤ exp (c * t ^ 2 / 2)\n```\nAn interesting point is that the integrability condition is not integrability of `exp (t * X)`\nwith respect to `κ ω'` for `ν`-almost all `ω'`, but integrability with respect to `κ ∘ₘ ν`.\nThis is a stronger condition, as the weaker one did not allow to prove interesting results about\nthe sum of two sub-Gaussian random variables.\n\nFor the conditional case, that integrability condition reduces to integrability of `exp (t * X)`\nwith respect to `μ`.\n\n### Definition of `HasCondSubgaussianMGF`\n\nWe define `HasCondSubgaussianMGF` as a special case of `Kernel.HasSubgaussianMGF` with the\nconditional expectation kernel for `m`, `condExpKernel μ m`, and the restriction of `μ` to `m`,\n`μ.trim hm` (where `hm` states that `m` is a sub-sigma-algebra).\nNote that `condExpKernel μ m ∘ₘ μ.trim hm = μ`. The definition is equivalent to the two\nconditions\n* for all `t`, `exp (t * X)` is `μ`-integrable,\n* for `μ.trim hm`-almost all `ω`, for all `t`, the mgf with respect to the conditional\n distribution `condExpKernel μ m ω` is bounded by `exp (c * t ^ 2 / 2)`.\n\nFor any `t`, we can write the mgf of `X` with respect to the conditional expectation kernel as\na conditional expectation, `(μ.trim hm)`-almost surely:\n`mgf X (condExpKernel μ m ·) t =ᵐ[μ.trim hm] μ[fun ω' ↦ exp (t * X ω') | m]`.\n\n## References\n\n* [R. Vershynin, *High-dimensional probability: An introduction with applications in data\n science*][vershynin2018high]\n\n-/\n\n@[expose] public section\n\nopen MeasureTheory Real\n\nopen scoped ENNReal NNReal Topology\n\nnamespace ProbabilityTheory\n\nsection Kernel\n\nvariable {Ω Ω' : Type*} {mΩ : MeasurableSpace Ω} {mΩ' : MeasurableSpace Ω'}\n {ν : Measure Ω'} {κ : Kernel Ω' Ω} {X : Ω → ℝ} {c : ℝ≥0}\n\n/-! ### Sub-Gaussian with respect to a kernel and a measure -/\n\n/-- A random variable `X` has a sub-Gaussian moment-generating function with parameter `c`\nwith respect to a kernel `κ` and a measure `ν` if for `ν`-almost all `ω'`, for all `t : ℝ`,\nthe moment-generating function of `X` with respect to `κ ω'` is bounded by `exp (c * t ^ 2 / 2)`.\nThis implies in particular that `X` has expectation 0. -/\nstructure Kernel.HasSubgaussianMGF (X : Ω → ℝ) (c : ℝ≥0)\n (κ : Kernel Ω' Ω) (ν : Measure Ω' := by volume_tac) : Prop where\n integrable_exp_mul : ∀ t, Integrable (fun ω ↦ exp (t * X ω)) (κ ∘ₘ ν)\n mgf_le : ∀ᵐ ω' ∂ν, ∀ t, mgf X (κ ω') t ≤ exp (c * t ^ 2 / 2)\n\nnamespace Kernel.HasSubgaussianMGF\n\nsection BasicProperties\n\nTarget:\nlemma aestronglyMeasurable (h : HasSubgaussianMGF X c κ ν) :\n AEStronglyMeasurable X (κ ∘ₘ ν) :=\n\nProof body:\n","rejected":"by\n exact __oprover_missing_151bd6343ce6","rejection":{"accepted":false,"failure_type":"unknown_identifier","output_sha256":"248af51eef5326f740191d5549e9360169a08eeaf9e1dfc92680b136296e9bc2","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"Probability/Moments","family_id":"aestronglymeasurable","file_id":"mathlib/Mathlib/Probability/Moments/SubGaussian.lean","sample_id":"151bd6343ce6efc88f7c7af395fa56b97569a0eb6c7ed6b43645660f392cf13a"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"8b81a5f6b795898182cb6620f9c33ac98b8724c109323d039d890dbed2337d7b","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"88283b37a04386cb160513ebfaafecb1486fb3bc80adf75260ada64e58dd8ad7","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"5985be8a58d477ae297cb867a8ae68ed309961c3f0afb9f562631189369f931b","source_sha256":"bdfd7123efa6932f7f417fb21d899a1972d4f19df96a39961e46ce27a071ef94","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n rw [equivariantProjection_apply]\n simp only [conjugate_i π i h]\n rw [Finset.sum_const, Finset.card_univ, ← Nat.cast_smul_eq_nsmul k, smul_smul,\n Fintype.card_eq_nat_card, Ring.inverse_mul_cancel _ hcard, one_smul]","hard_negative":true,"metrics":{"chosen_tokens":43,"rejected_tokens":2,"token_jaccard":0.034483,"token_length_ratio":0.046512},"negative_category":"invalid_tactic","negative_mode":"invalid_tactic","pair_id":"fefdae3080e78d432724ebb1bc192d6141626268f69c4ce127e099eadc161dc4","pair_index":1,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.Algebra.Group.TypeTags.Finite\npublic import Mathlib.Algebra.MonoidAlgebra.Basic\npublic import Mathlib.LinearAlgebra.Basis.VectorSpace\npublic import Mathlib.RingTheory.SimpleModule.Basic\npublic import Mathlib.RepresentationTheory.Semisimple\n\nNamespace:\nLinearMap\n\nLocal context:\n/-\nCopyright (c) 2020 Kim Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kim Morrison\n-/\n/-!\n# Maschke's theorem\n\nWe prove **Maschke's theorem** for finite groups,\nin the formulation that every submodule of a `k[G]` module has a complement,\nwhen `k` is a field with `Fintype.card G` invertible in `k`.\n\nWe do the core computation in greater generality.\nFor any commutative ring `k` in which `Fintype.card G` is invertible,\nand a `k[G]`-linear map `i : V → W` which admits a `k`-linear retraction `π`,\nwe produce a `k[G]`-linear retraction by\ntaking the average over `G` of the conjugates of `π`.\n\n## Implementation Notes\n\n* These results assume `IsUnit (Fintype.card G : k)` which is equivalent to the more\n familiar `¬(ringChar k ∣ Fintype.card G)`.\n\n## Future work\nIt's not so far to give the usual statement, that every finite-dimensional representation\nof a finite group is semisimple (i.e. a direct sum of irreducibles).\n-/\n\n@[expose] public section\n\nnoncomputable section\n\nopen Module MonoidAlgebra\nopen scoped Ring\n\n/-!\nWe now do the key calculation in Maschke's theorem.\n\nGiven `V → W`, an inclusion of `k[G]` modules,\nassume we have some retraction `π` (i.e. `∀ v, π (i v) = v`),\njust as a `k`-linear map.\n(When `k` is a field, this will be available cheaply, by choosing a basis.)\n\nWe now construct a retraction of the inclusion as a `k[G]`-linear map,\nby the formula\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\n\nnamespace LinearMap\n\n\n-- At first we work with any `[CommRing k]`, and add the assumption that\n-- `IsUnit (Fintype.card G : k)` when it is required.\nvariable {k : Type*} [CommRing k] {G : Type*} [Group G]\nvariable {V : Type*} [AddCommGroup V] [Module k V] [Module k[G] V] [IsScalarTower k k[G] V]\nvariable {W : Type*} [AddCommGroup W] [Module k W] [Module k[G] W] [IsScalarTower k k[G] W]\nvariable (π : W →ₗ[k] V)\n\n/-- We define the conjugate of `π` by `g`, as a `k`-linear map. -/\ndef conjugate (g : G) : W →ₗ[k] V :=\n GroupSMul.linearMap k V g⁻¹ ∘ₗ π ∘ₗ GroupSMul.linearMap k W g\n\ntheorem conjugate_apply (g : G) (v : W) :\n π.conjugate g v = MonoidAlgebra.single g⁻¹ (1 : k) • π (MonoidAlgebra.single g (1 : k) • v) :=\n rfl\n\nvariable (i : V →ₗ[k[G]] W)\n\nsection\n\ntheorem conjugate_i (h : ∀ v : V, π (i v) = v) (g : G) (v : V) :\n (conjugate π g : W → V) (i v) = v := by\n rw [conjugate_apply, ← i.map_smul, h, ← mul_smul, single_mul_single, mul_one, inv_mul_cancel,\n ← one_def, one_smul]\n\nend\n\nvariable (G) [Fintype G]\n\n/-- The sum of the conjugates of `π` by each element `g : G`, as a `k`-linear map.\n\n(We postpone dividing by the size of the group as long as possible.)\n-/\ndef sumOfConjugates : W →ₗ[k] V :=\n ∑ g : G, π.conjugate g\n\nlemma sumOfConjugates_apply (v : W) : π.sumOfConjugates G v = ∑ g : G, π.conjugate g v :=\n LinearMap.sum_apply _ _ _\n\n/-- In fact, the sum over `g : G` of the conjugate of `π` by `g` is a `k[G]`-linear map.\n-/\ndef sumOfConjugatesEquivariant : W →ₗ[k[G]] V :=\n MonoidAlgebra.equivariantOfLinearOfComm (π.sumOfConjugates G) fun g v => by\n simp only [sumOfConjugates_apply, Finset.smul_sum, conjugate_apply]\n refine Fintype.sum_bijective (· * g) (Group.mulRight_bijective g) _ _ fun i ↦ ?_\n simp only [smul_smul, single_mul_single, mul_inv_rev, mul_inv_cancel_left, one_mul]\n\ntheorem sumOfConjugatesEquivariant_apply (v : W) :\n π.sumOfConjugatesEquivariant G v = ∑ g : G, π.conjugate g v :=\n π.sumOfConjugates_apply G v\n\nsection\n\n/-- We construct our `k[G]`-linear retraction of `i` as\n$$ \\frac{1}{|G|} \\sum_{g \\in G} g⁻¹ • π(g • -). $$\n-/\ndef equivariantProjection : W →ₗ[k[G]] V :=\n (Fintype.card G : k)⁻¹ʳ • π.sumOfConjugatesEquivariant G\n\ntheorem equivariantProjection_apply (v : W) :\n π.equivariantProjection G v = (Nat.card G : k)⁻¹ʳ • ∑ g : G, π.conjugate g v := by\n simp only [equivariantProjection, smul_apply, sumOfConjugatesEquivariant_apply,\n Fintype.card_eq_nat_card]\n\nTarget:\ntheorem equivariantProjection_condition (hcard : IsUnit (Nat.card G : k))\n (h : ∀ v : V, π (i v) = v) (v : V) : (π.equivariantProjection G) (i v) = v :=\n\nProof body:\n","rejected":"by\n __oprover_invalid_tactic_5985be8a58d4","rejection":{"accepted":false,"failure_type":"unsolved_goals","output_sha256":"41b4c06195176e1f1083f7eb109cb0726c18dc6464ee16432a5644a078d09ef1","rejection_layer":"lean","returncode":1,"timed_out":false,"warning":false},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"RepresentationTheory","family_id":"equivariantprojection_condition","file_id":"mathlib/Mathlib/RepresentationTheory/Maschke.lean","sample_id":"5985be8a58d477ae297cb867a8ae68ed309961c3f0afb9f562631189369f931b"},"split":"holdout"} {"binding":{"chosen_proof_sha256":"589d2bd934ad8a183e4b3780f6483bcfe39599e9a0c2e35df8adc8dbbaab4bed","mathlib_revision":"360da6fa66c1273b76b6b2d8c5666fd5ac2e3b56","negative_generator_hash":"8285991fca7eded1551939aba257955b2916c5e9006a0b0c6c621296d1e6c2d9","rejected_proof_sha256":"5f0962133e4f2c572246127a78ca7e58ef750699b5c04f5115af66edc21768af","source_artifact_hash":"5ebec3f7ed71d0af202924ea9d5ca12a857c5363b89b028dbf74268bf2e32f24","source_sample_id":"ad2d7b0cfde55626bb20e49111367eba759d89a1d85c9ee4882d8a3ab0bc1a20","source_sha256":"1b475ae1c04af2e8dc43839d1384cf44772b61b4c52d624fb93de6266591f8c5","toolchain":"leanprover/lean4:v4.32.0-rc1"},"chosen":"by\n apply padicNorm.not_int_of_not_padic_int 2\n rw [padicNorm.eq_zpow_of_nonzero (harmonic_pos (ne_zero_of_lt h)).ne',\n padicValRat_two_harmonic, neg_neg, zpow_natCast]\n exact one_lt_pow₀ one_lt_two (Nat.log_pos one_lt_two h).ne'","hard_negative":false,"metrics":{"chosen_tokens":40,"rejected_tokens":44,"token_jaccard":0.896552,"token_length_ratio":1.1},"negative_category":"missing_wrong_import","negative_mode":"import","pair_id":"ff31c4fe35532a6d74397adfe59de60667bf302051c278ac73d092ac375ce2ea","pair_index":0,"prompt":"Return exactly one Lean proof body beginning with `by`. Do not emit prose, fences, declarations, sorry, admit, by?, or warnings.\n\nImports:\npublic import Mathlib.NumberTheory.Harmonic.Defs\npublic import Mathlib.NumberTheory.Padics.PadicNumbers\npublic import Mathlib.Tactic.Positivity\n\nNamespace:\n(root)\n\nLocal context:\n/-\nCopyright (c) 2023 Koundinya Vajjha. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Koundinya Vajjha, Thomas Browning\n-/\n/-!\n\nThe nth Harmonic number is not an integer. We formalize the proof using\n2-adic valuations. This proof is due to Kürschák.\n\nReference:\nhttps://kconrad.math.uconn.edu/blurbs/gradnumthy/padicharmonicsum.pdf\n\n-/\n\npublic section\n\nlemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n := by\n unfold harmonic\n rw [← Finset.nonempty_range_iff] at Hn\n positivity\n\n/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm of n. -/\ntheorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by\n induction n with\n | zero => simp\n | succ n ih =>\n rcases eq_or_ne n 0 with rfl | hn\n · simp\n rw [harmonic_succ]\n have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹ := by\n rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]\n exact Nat.log_ne_padicValNat_succ hn\n rw [padicValRat.add_eq_min (harmonic_succ n ▸ (harmonic_pos n.succ_ne_zero).ne')\n (harmonic_pos hn).ne' (inv_ne_zero (Nat.cast_ne_zero.mpr n.succ_ne_zero)) key, ih,\n padicValRat.inv, padicValRat.of_nat, min_neg_neg, neg_inj, ← Nat.cast_max, Nat.cast_inj]\n exact Nat.max_log_padicValNat_succ_eq_log_succ n\n\n/-- The 2-adic norm of the n-th harmonic number is 2 raised to the logarithm of n in base 2. -/\nlemma padicNorm_two_harmonic {n : ℕ} (hn : n ≠ 0) :\n ‖(harmonic n : ℚ_[2])‖ = 2 ^ (Nat.log 2 n) := by\n rw [Padic.eq_padicNorm, padicNorm.eq_zpow_of_nonzero (harmonic_pos hn).ne',\n padicValRat_two_harmonic, neg_neg, zpow_natCast, Rat.cast_pow, Rat.cast_natCast, Nat.cast_ofNat]\n\n/-- The n-th harmonic number is not an integer for n ≥ 2. -/\n\nTarget:\ntheorem harmonic_not_int {n : ℕ} (h : 2 ≤ n) : ¬ (harmonic n).isInt :=\n\nProof body:\n","rejected":"import Mathlib.WrongImport\nby\n apply padicNorm.not_int_of_not_padic_int 2\n rw [padicNorm.eq_zpow_of_nonzero (harmonic_pos (ne_zero_of_lt h)).ne',\n padicValRat_two_harmonic, neg_neg, zpow_natCast]\n exact one_lt_pow₀ one_lt_two (Nat.log_pos one_lt_two h).ne'","rejection":{"accepted":false,"all_failure_types":["not_exact_by_body","top_level_command"],"failure_type":"not_exact_by_body","rejection_layer":"strict_parser"},"safe_lean_text_only":true,"schema_version":1,"source":{"dependency_family_id":"NumberTheory/Harmonic","family_id":"harmonic_not_int","file_id":"mathlib/Mathlib/NumberTheory/Harmonic/Int.lean","sample_id":"ad2d7b0cfde55626bb20e49111367eba759d89a1d85c9ee4882d8a3ab0bc1a20"},"split":"holdout"}