[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"0jbssKmlFE":3},"# AutoGeneralization\n\n`AutoGeneralization` finds weaker, kernel-checked type class assumptions for\nLean theorems.\n\n## Install\n\nAdd the package to your project's `lakefile.toml`:\n\n```toml\n[[require]]\nname = \"AutoGeneralization\"\ngit = \"https://github.com/pelicanhere/AutoGeneralization\"\nrev = \"master\"\n```\n\nThen run:\n\n```bash\nlake update AutoGeneralization\n```\n\n## Use\n\n```lean\nimport AutoGeneralization\n\n#autogeneralize theoremName\n#autogeneralize! theoremName\n#lint only generalizeTypeClass\n```\n\n`#autogeneralize` proposes one-step generalizations, while\n`#autogeneralize!` repeats until the signature stops changing. Apply a\ncommand's code action to insert the generated theorem.\n\nTo analyze an imported theorem, use `import all Module.Name`.\n\n## Examples\n\nRegistered instance conversions can expose weaker assumptions:\n\n```lean\nimport Mathlib.RingTheory.Coprime.Basic\nimport AutoGeneralization\n\ntheorem coprimeIffOverField {R : Type*} [Field R] {m n : R} :\n    IsCoprime m n ↔ m ≠ 0 ∨ n ≠ 0 :=\n  Semifield.isCoprime_iff\n\n#autogeneralize coprimeIffOverField\n-- [Field R] → [Semifield R]\n```\n\nEvidence stored by a retained class is re-synthesized after generalization:\n\n```lean\nimport Mathlib.Algebra.Star.SelfAdjoint\nimport AutoGeneralization\n\ntheorem selfAdjointDivOverField {R : Type*} [Field R] [StarRing R] {x y : R}\n    (hx : IsSelfAdjoint x) (hy : IsSelfAdjoint y) : IsSelfAdjoint (x / y) :=\n  IsSelfAdjoint.div hx hy\n\n#autogeneralize selfAdjointDivOverField\n-- [Field R] → [Semifield R], retaining [StarRing R]\n```\n\nOne class can split into several independent capabilities:\n\n```lean\nimport Mathlib.Data.Prod.Lex\nimport AutoGeneralization\n\nopen Prod\n\ntheorem lexicographicSelf {α : Type} [Preorder α] {x y : α × α} :\n    toLex x ≤ toLex y ↔ x.1 \u003C y.1 ∨ x.1 = y.1 ∧ x.2 ≤ y.2 :=\n  Prod.Lex.toLex_le_toLex\n\n#autogeneralize lexicographicSelf\n-- [Preorder α] → [LT α] [LE α]\n```\n\n`#autogeneralize!` applies every available step:\n\n```lean\nimport Mathlib.Topology.Algebra.Group.Basic\nimport AutoGeneralization\n\nopen Set Topology\n\ntheorem topologicalInvComponent {G : Type} [TopologicalSpace G] [Group G]\n    [IsTopologicalGroup G] {g : G} (hg : g ∈ connectedComponent (1 : G)) :\n    g⁻¹ ∈ connectedComponent (1 : G) :=\n  inv_mem_connectedComponent_one hg\n\n#autogeneralize! topologicalInvComponent\n-- [IsTopologicalGroup G] → [ContinuousInv G]\n-- [Group G] → [DivisionMonoid G]\n```\n\nSee [`AutoGeneralizationTest/Examples.lean`](AutoGeneralizationTest/Examples.lean)\nfor checked examples and [`docs/ALGORITHM.md`](docs/ALGORITHM.md) for the\nalgorithm.\n\n## Development\n\n```bash\nlake test\n```\n",1785960028343]