Skip to content

feat: to_dual attribute - #21719

Closed
bryangingechen wants to merge 85 commits into
masterfrom
bgc-order-dual-scratch-0
Closed

bryangingechen wants to merge 85 commits into
masterfrom
bgc-order-dual-scratch-0

Conversation

@bryangingechen

@bryangingechen bryangingechen commented Feb 11, 2025 •

Copy link
Copy Markdown
Contributor

The attribute to_dual can be used to automatically transport theorems
and definitions (but not inductive types and structures) to their dual version.
It uses the same implementation as to_additive.

Related (mathlib3) issues:


#21696 was an attempt to split out some of the to_additive changes, but the code here has diverged, so I'm abandoning that one.

Open in Gitpod

@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Feb 11, 2025
@github-actions

github-actions Bot commented Feb 11, 2025 •

Copy link
Copy Markdown

PR summary d5d137aecc

Import changes exceeding 2%

% File
+4.42% Mathlib.CategoryTheory.Category.Basic
+4.38% Mathlib.CategoryTheory.Functor.Basic
+3.99% Mathlib.CategoryTheory.Iso
+3.99% Mathlib.CategoryTheory.NatTrans
+11.03% Mathlib.Combinatorics.Quiver.Basic
+10.95% Mathlib.Combinatorics.Quiver.Prefunctor
+15.79% Mathlib.Order.Basic
+45.45% Mathlib.Order.Defs.LinearOrder
+48.08% Mathlib.Order.Defs.PartialOrder
+71.79% Mathlib.Order.Notation
+70.00% Mathlib.Order.TypeTags
+7.14% Mathlib.Order.WithBot
+4.00% Mathlib.Tactic.CategoryTheory.Reassoc

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Order.Notation 39 67 +28 (+71.79%)
Mathlib.Order.TypeTags 40 68 +28 (+70.00%)
Mathlib.Order.Defs.PartialOrder 52 77 +25 (+48.08%)
Mathlib.Order.Defs.LinearOrder 55 80 +25 (+45.45%)
Mathlib.Order.Basic 114 132 +18 (+15.79%)
Mathlib.Combinatorics.Quiver.Basic 136 151 +15 (+11.03%)
Mathlib.Combinatorics.Quiver.Prefunctor 137 152 +15 (+10.95%)
Mathlib.Order.WithBot 196 210 +14 (+7.14%)
Mathlib.CategoryTheory.Category.Basic 294 307 +13 (+4.42%)
Mathlib.CategoryTheory.Functor.Basic 297 310 +13 (+4.38%)
Mathlib.Tactic.CategoryTheory.Reassoc 300 312 +12 (+4.00%)
Mathlib.CategoryTheory.Iso 301 313 +12 (+3.99%)
Mathlib.CategoryTheory.NatTrans 301 313 +12 (+3.99%)
Mathlib.Tactic.ToAdditive.Frontend 61 59 -2 (-3.28%)
Import changes for all files
Files Import difference
64 files Mathlib.Algebra.BigOperators.Group.List.Defs Mathlib.Algebra.CharZero.Defs Mathlib.Algebra.Field.Defs Mathlib.Algebra.Field.MinimalAxioms Mathlib.Algebra.Group.Basic Mathlib.Algebra.Group.Commutator Mathlib.Algebra.Group.Commute.Basic Mathlib.Algebra.Group.Commute.Defs Mathlib.Algebra.Group.Commute.Hom Mathlib.Algebra.Group.Defs Mathlib.Algebra.Group.Ext Mathlib.Algebra.Group.Hom.Basic Mathlib.Algebra.Group.Hom.CompTypeclasses Mathlib.Algebra.Group.Hom.Defs Mathlib.Algebra.Group.Hom.End Mathlib.Algebra.Group.Hom.Instances Mathlib.Algebra.Group.Idempotent Mathlib.Algebra.Group.InjSurj Mathlib.Algebra.Group.Int.Defs Mathlib.Algebra.Group.Int.Units Mathlib.Algebra.Group.Invertible.Defs Mathlib.Algebra.Group.Irreducible.Defs Mathlib.Algebra.Group.MinimalAxioms Mathlib.Algebra.Group.Nat.Defs Mathlib.Algebra.Group.Nat.Units Mathlib.Algebra.Group.PUnit Mathlib.Algebra.Group.Pi.Basic Mathlib.Algebra.Group.Semiconj.Basic Mathlib.Algebra.Group.Semiconj.Defs Mathlib.Algebra.Group.Torsion Mathlib.Algebra.Group.Units.Defs Mathlib.Algebra.GroupWithZero.Defs Mathlib.Algebra.GroupWithZero.Idempotent Mathlib.Algebra.GroupWithZero.Nat Mathlib.Algebra.GroupWithZero.Pi Mathlib.Algebra.Homology.ComplexShape Mathlib.Algebra.Homology.HasNoLoop Mathlib.Algebra.Notation.Defs Mathlib.Algebra.Notation.Lemmas Mathlib.Algebra.Notation.Pi Mathlib.Algebra.Notation.Prod Mathlib.Algebra.Notation Mathlib.Algebra.PEmptyInstances Mathlib.Algebra.Regular.Basic Mathlib.Algebra.Ring.Defs Mathlib.Algebra.Ring.Ext Mathlib.Algebra.Ring.MinimalAxioms Mathlib.Algebra.Ring.Nat Mathlib.Algebra.Ring.PUnit Mathlib.Algebra.Ring.Semiconj Mathlib.Control.Applicative Mathlib.Control.Traversable.Lemmas Mathlib.Data.Int.Cast.Defs Mathlib.Data.List.EditDistance.Defs Mathlib.Data.Matrix.DMatrix Mathlib.Data.Nat.Cast.Defs Mathlib.Data.Nat.Cast.NeZero Mathlib.Data.Tree.Traversable Mathlib.GroupTheory.EckmannHilton Mathlib.RingTheory.LocalRing.Defs Mathlib.Tactic.DeriveTraversable Mathlib.Tactic.Measurability Mathlib.Tactic.ToAdditive.Frontend Mathlib.Tactic.ToAdditive
-2
108 files Mathlib.AlgebraicTopology.DoldKan.Compatibility Mathlib.AlgebraicTopology.ModelCategory.CategoryWithCofibrations Mathlib.AlgebraicTopology.SimplexCategory.Defs Mathlib.CategoryTheory.Balanced Mathlib.CategoryTheory.Bicategory.Adjunction.Basic Mathlib.CategoryTheory.Bicategory.Adjunction.Mate Mathlib.CategoryTheory.Bicategory.Basic Mathlib.CategoryTheory.Bicategory.End Mathlib.CategoryTheory.Bicategory.Functor.Prelax Mathlib.CategoryTheory.Bicategory.LocallyDiscrete Mathlib.CategoryTheory.Bicategory.Strict Mathlib.CategoryTheory.CatCommSq Mathlib.CategoryTheory.Category.Preorder Mathlib.CategoryTheory.Category.ULift Mathlib.CategoryTheory.CommSq Mathlib.CategoryTheory.Comma.Arrow Mathlib.CategoryTheory.Comma.Basic Mathlib.CategoryTheory.ConnectedComponents Mathlib.CategoryTheory.DinatTrans Mathlib.CategoryTheory.Discrete.Basic Mathlib.CategoryTheory.Discrete.SumsProducts Mathlib.CategoryTheory.EpiMono Mathlib.CategoryTheory.EqToHom Mathlib.CategoryTheory.Equivalence Mathlib.CategoryTheory.EssentialImage Mathlib.CategoryTheory.FiberedCategory.BasedCategory Mathlib.CategoryTheory.FiberedCategory.Cartesian Mathlib.CategoryTheory.FiberedCategory.Cocartesian Mathlib.CategoryTheory.FiberedCategory.Fiber Mathlib.CategoryTheory.FiberedCategory.Fibered Mathlib.CategoryTheory.FiberedCategory.HasFibers Mathlib.CategoryTheory.FiberedCategory.HomLift Mathlib.CategoryTheory.FinCategory.AsType Mathlib.CategoryTheory.FinCategory.Basic Mathlib.CategoryTheory.FullSubcategory Mathlib.CategoryTheory.Functor.Category Mathlib.CategoryTheory.Functor.Const Mathlib.CategoryTheory.Functor.CurryingThree Mathlib.CategoryTheory.Functor.Currying Mathlib.CategoryTheory.Functor.FullyFaithful Mathlib.CategoryTheory.Functor.OfSequence Mathlib.CategoryTheory.Functor.ReflectsIso.Basic Mathlib.CategoryTheory.Functor.Trifunctor Mathlib.CategoryTheory.Functor.TwoSquare Mathlib.CategoryTheory.Groupoid.Basic Mathlib.CategoryTheory.Groupoid.Discrete Mathlib.CategoryTheory.Groupoid.FreeGroupoid Mathlib.CategoryTheory.Groupoid Mathlib.CategoryTheory.HomCongr Mathlib.CategoryTheory.InducedCategory Mathlib.CategoryTheory.IsConnected Mathlib.CategoryTheory.Iso Mathlib.CategoryTheory.Join.Basic Mathlib.CategoryTheory.Join.Opposites Mathlib.CategoryTheory.Join.Sum Mathlib.CategoryTheory.LiftingProperties.Basic Mathlib.CategoryTheory.Limits.Shapes.Pullback.Categorical.Basic Mathlib.CategoryTheory.Limits.Shapes.Pullback.Categorical.CatCospanTransform Mathlib.CategoryTheory.Limits.Shapes.StrongEpi Mathlib.CategoryTheory.Monad.Basic Mathlib.CategoryTheory.Monoidal.Action.Basic Mathlib.CategoryTheory.Monoidal.Action.LinearFunctor Mathlib.CategoryTheory.Monoidal.Category Mathlib.CategoryTheory.Monoidal.CoherenceLemmas Mathlib.CategoryTheory.MorphismProperty.Basic Mathlib.CategoryTheory.MorphismProperty.Composition Mathlib.CategoryTheory.MorphismProperty.Factorization Mathlib.CategoryTheory.MorphismProperty.IsInvertedBy Mathlib.CategoryTheory.MorphismProperty.IsSmall Mathlib.CategoryTheory.MorphismProperty.Retract Mathlib.CategoryTheory.NatIso Mathlib.CategoryTheory.NatTrans Mathlib.CategoryTheory.ObjectProperty.Basic Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms Mathlib.CategoryTheory.ObjectProperty.FullSubcategory Mathlib.CategoryTheory.Opposites Mathlib.CategoryTheory.PEmpty Mathlib.CategoryTheory.PUnit Mathlib.CategoryTheory.PathCategory.Basic Mathlib.CategoryTheory.PathCategory.MorphismProperty Mathlib.CategoryTheory.Pi.Basic Mathlib.CategoryTheory.Products.Associator Mathlib.CategoryTheory.Products.Basic Mathlib.CategoryTheory.Products.Bifunctor Mathlib.CategoryTheory.Products.Unitor Mathlib.CategoryTheory.Quotient Mathlib.CategoryTheory.Retract Mathlib.CategoryTheory.Sigma.Basic Mathlib.CategoryTheory.Square Mathlib.CategoryTheory.Sums.Associator Mathlib.CategoryTheory.Sums.Basic Mathlib.CategoryTheory.Sums.Products Mathlib.CategoryTheory.Thin Mathlib.CategoryTheory.Whiskering Mathlib.CategoryTheory.Widesubcategory Mathlib.Tactic.CategoryTheory.BicategoricalComp Mathlib.Tactic.CategoryTheory.Bicategory.Basic Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes Mathlib.Tactic.CategoryTheory.Bicategory.Normalize Mathlib.Tactic.CategoryTheory.Bicategory.PureCoherence Mathlib.Tactic.CategoryTheory.IsoReassoc Mathlib.Tactic.CategoryTheory.Monoidal.Basic Mathlib.Tactic.CategoryTheory.Monoidal.Datatypes Mathlib.Tactic.CategoryTheory.Monoidal.Normalize Mathlib.Tactic.CategoryTheory.Monoidal.PureCoherence Mathlib.Tactic.CategoryTheory.MonoidalComp Mathlib.Tactic.CategoryTheory.Reassoc Mathlib.Tactic.Widget.StringDiagram
12
196 files Mathlib.Algebra.Order.Nonneg.Lattice Mathlib.Algebra.Quotient Mathlib.CategoryTheory.Category.Basic Mathlib.CategoryTheory.Category.KleisliCat Mathlib.CategoryTheory.Functor.Basic Mathlib.CategoryTheory.Functor.Functorial Mathlib.Combinatorics.Quiver.Covering Mathlib.Combinatorics.SetFamily.Intersecting Mathlib.Control.Bifunctor Mathlib.Control.Bitraversable.Basic Mathlib.Control.Bitraversable.Lemmas Mathlib.Control.EquivFunctor.Instances Mathlib.Control.Functor.Multivariate Mathlib.Data.Fin.Basic Mathlib.Data.Fin.Embedding Mathlib.Data.Fin.Fin2 Mathlib.Data.Fin.FlagRange Mathlib.Data.Fin.Pigeonhole Mathlib.Data.Fin.Rev Mathlib.Data.Fin.SuccPred Mathlib.Data.Fin.Tuple.Basic Mathlib.Data.Fin.Tuple.Curry Mathlib.Data.Fin.Tuple.Embedding Mathlib.Data.Fin.Tuple.Take Mathlib.Data.Fin.VecNotation Mathlib.Data.Finite.Set Mathlib.Data.Finset.Attach Mathlib.Data.Finset.Basic Mathlib.Data.Finset.BooleanAlgebra Mathlib.Data.Finset.Card Mathlib.Data.Finset.Dedup Mathlib.Data.Finset.Defs Mathlib.Data.Finset.Disjoint Mathlib.Data.Finset.Empty Mathlib.Data.Finset.Erase Mathlib.Data.Finset.Filter Mathlib.Data.Finset.Fin Mathlib.Data.Finset.Fold Mathlib.Data.Finset.Image Mathlib.Data.Finset.Insert Mathlib.Data.Finset.Lattice.Basic Mathlib.Data.Finset.Lattice.Lemmas Mathlib.Data.Finset.Order Mathlib.Data.Finset.Piecewise Mathlib.Data.Finset.Range Mathlib.Data.Finset.SDiff Mathlib.Data.Finset.SymmDiff Mathlib.Data.Fintype.Basic Mathlib.Data.Fintype.Card Mathlib.Data.Fintype.Defs Mathlib.Data.Fintype.EquivFin Mathlib.Data.Fintype.Inv Mathlib.Data.Fintype.OfMap Mathlib.Data.Fintype.Sets Mathlib.Data.Fintype.Shrink Mathlib.Data.Int.Sqrt Mathlib.Data.List.AList Mathlib.Data.List.Basic Mathlib.Data.List.ChainOfFn Mathlib.Data.List.Chain Mathlib.Data.List.Count Mathlib.Data.List.Dedup Mathlib.Data.List.Destutter Mathlib.Data.List.DropRight Mathlib.Data.List.Duplicate Mathlib.Data.List.Enum Mathlib.Data.List.FinRange Mathlib.Data.List.Forall2 Mathlib.Data.List.Indexes Mathlib.Data.List.Induction Mathlib.Data.List.Infix Mathlib.Data.List.InsertIdx Mathlib.Data.List.InsertNth Mathlib.Data.List.Intervals Mathlib.Data.List.Lattice Mathlib.Data.List.Lemmas Mathlib.Data.List.Lex Mathlib.Data.List.Map2 Mathlib.Data.List.MinMax Mathlib.Data.List.NatAntidiagonal Mathlib.Data.List.NodupEquivFin Mathlib.Data.List.Nodup Mathlib.Data.List.OfFn Mathlib.Data.List.Palindrome Mathlib.Data.List.Perm.Basic Mathlib.Data.List.Perm.Lattice Mathlib.Data.List.Perm.Subperm Mathlib.Data.List.Permutation Mathlib.Data.List.ProdSigma Mathlib.Data.List.Range Mathlib.Data.List.ReduceOption Mathlib.Data.List.Rotate Mathlib.Data.List.Sections Mathlib.Data.List.Sigma Mathlib.Data.List.Sort Mathlib.Data.List.SplitBy Mathlib.Data.List.SplitOn Mathlib.Data.List.Sublists Mathlib.Data.List.TakeDrop Mathlib.Data.List.Zip Mathlib.Data.MLList.BestFirst Mathlib.Data.Multiset.AddSub Mathlib.Data.Multiset.Basic Mathlib.Data.Multiset.Count Mathlib.Data.Multiset.Dedup Mathlib.Data.Multiset.Defs Mathlib.Data.Multiset.Filter Mathlib.Data.Multiset.FinsetOps Mathlib.Data.Multiset.Fold Mathlib.Data.Multiset.Lattice Mathlib.Data.Multiset.MapFold Mathlib.Data.Multiset.NatAntidiagonal Mathlib.Data.Multiset.Pairwise Mathlib.Data.Multiset.Range Mathlib.Data.Multiset.Replicate Mathlib.Data.Multiset.Sort Mathlib.Data.Multiset.UnionInter Mathlib.Data.Multiset.ZeroCons Mathlib.Data.Nat.Choose.Basic Mathlib.Data.Nat.Factorial.Basic Mathlib.Data.Prod.TProd Mathlib.Data.Seq.Computation Mathlib.Data.Seq.Parallel Mathlib.Data.Seq.Seq Mathlib.Data.Seq.WSeq Mathlib.Data.Set.Constructions Mathlib.Data.Set.Finite.Basic Mathlib.Data.Set.Finite.Range Mathlib.Data.Set.Pairwise.List Mathlib.Data.Stream.Init Mathlib.Data.TypeVec Mathlib.Data.Vector.Defs Mathlib.Data.Vector3 Mathlib.Data.WSeq.Basic Mathlib.Data.WSeq.Defs Mathlib.Data.WSeq.Productive Mathlib.Data.WSeq.Relation Mathlib.Logic.Equiv.Fin.Basic Mathlib.Logic.Equiv.Fintype Mathlib.Logic.Equiv.Functor Mathlib.Logic.Function.FromTypes Mathlib.Logic.Function.OfArity Mathlib.Order.Atoms Mathlib.Order.CompleteLatticeIntervals Mathlib.Order.Cover Mathlib.Order.DirectedInverseSystem Mathlib.Order.Fin.Basic Mathlib.Order.Fin.Finset Mathlib.Order.Fin.SuccAboveOrderIso Mathlib.Order.Fin.Tuple Mathlib.Order.Heyting.Boundary Mathlib.Order.InitialSeg Mathlib.Order.Interval.Set.Fin Mathlib.Order.Interval.Set.Infinite Mathlib.Order.Interval.Set.InitialSeg Mathlib.Order.Interval.Set.Limit Mathlib.Order.Interval.Set.Monotone Mathlib.Order.Interval.Set.OrdConnectedComponent Mathlib.Order.Interval.Set.OrdConnected Mathlib.Order.Interval.Set.OrderEmbedding Mathlib.Order.Interval.Set.ProjIcc Mathlib.Order.Interval.Set.SuccOrder Mathlib.Order.Interval.Set.SuccPred Mathlib.Order.Interval.Set.Union Mathlib.Order.Interval.Set.UnorderedInterval Mathlib.Order.IsNormal Mathlib.Order.ModularLattice Mathlib.Order.PiLex Mathlib.Order.Preorder.Finite Mathlib.Order.Radical Mathlib.Order.Shrink Mathlib.Order.SuccPred.Archimedean Mathlib.Order.SuccPred.Basic Mathlib.Order.SuccPred.CompleteLinearOrder Mathlib.Order.SuccPred.InitialSeg Mathlib.Order.SuccPred.IntervalSucc Mathlib.Order.SuccPred.Limit Mathlib.Order.SuccPred.Relation Mathlib.Order.SuccPred.Tree Mathlib.Order.SuccPred.WithBot Mathlib.Order.TransfiniteIteration Mathlib.Order.UpperLower.Basic Mathlib.Order.UpperLower.Closure Mathlib.Order.UpperLower.CompleteLattice Mathlib.Order.UpperLower.Fibration Mathlib.Order.UpperLower.Hom Mathlib.Order.UpperLower.Principal Mathlib.Order.UpperLower.Prod Mathlib.Order.ZornAtoms Mathlib.SetTheory.ZFC.Basic Mathlib.Tactic.CategoryTheory.CheckCompositions Mathlib.Tactic.CategoryTheory.Coherence.Basic Mathlib.Tactic.CategoryTheory.Slice Mathlib.Tactic.Common Mathlib.Tactic.FinCases Mathlib.Tactic.Widget.CommDiag
13
160 files Mathlib.Combinatorics.Quiver.Arborescence Mathlib.Combinatorics.Quiver.Cast Mathlib.Combinatorics.Quiver.ConnectedComponent Mathlib.Combinatorics.Quiver.Path Mathlib.Combinatorics.Quiver.SingleObj Mathlib.Combinatorics.Quiver.Symmetric Mathlib.Control.EquivFunctor Mathlib.Data.Bool.Set Mathlib.Data.Bundle Mathlib.Data.Countable.Small Mathlib.Data.Nat.Log Mathlib.Data.Nat.Order.Lemmas Mathlib.Data.Nat.Set Mathlib.Data.PEquiv Mathlib.Data.PNat.Equiv Mathlib.Data.PSigma.Order Mathlib.Data.Prod.Lex Mathlib.Data.Rel Mathlib.Data.Semiquot Mathlib.Data.Set.Accumulate Mathlib.Data.Set.Basic Mathlib.Data.Set.BoolIndicator Mathlib.Data.Set.BooleanAlgebra Mathlib.Data.Set.Disjoint Mathlib.Data.Set.Function Mathlib.Data.Set.Functor Mathlib.Data.Set.Image Mathlib.Data.Set.Inclusion Mathlib.Data.Set.Insert Mathlib.Data.Set.Lattice.Image Mathlib.Data.Set.Lattice Mathlib.Data.Set.List Mathlib.Data.Set.Monotone Mathlib.Data.Set.NAry Mathlib.Data.Set.Order Mathlib.Data.Set.Pairwise.Basic Mathlib.Data.Set.Pairwise.Lattice Mathlib.Data.Set.Piecewise Mathlib.Data.Set.Prod Mathlib.Data.Set.Restrict Mathlib.Data.Set.Sigma Mathlib.Data.Set.Subset Mathlib.Data.Set.Subsingleton Mathlib.Data.Set.SymmDiff Mathlib.Data.Set.UnionLift Mathlib.Data.SetLike.Basic Mathlib.Data.Setoid.Basic Mathlib.Data.Sigma.Order Mathlib.Data.Sum.Lattice Mathlib.Data.Sum.Order Mathlib.Data.ULift Mathlib.Logic.Embedding.Basic Mathlib.Logic.Embedding.Set Mathlib.Logic.Equiv.Basic Mathlib.Logic.Equiv.Embedding Mathlib.Logic.Equiv.Option Mathlib.Logic.Equiv.PartialEquiv Mathlib.Logic.Equiv.Set Mathlib.Logic.Function.DependsOn Mathlib.Logic.Function.FiberPartition Mathlib.Logic.Small.Basic Mathlib.Logic.Small.Set Mathlib.Order.Antichain Mathlib.Order.Antisymmetrization Mathlib.Order.BooleanAlgebra.Basic Mathlib.Order.BooleanAlgebra.Defs Mathlib.Order.BooleanAlgebra.Set Mathlib.Order.BooleanAlgebra Mathlib.Order.Booleanisation Mathlib.Order.BoundedOrder.Basic Mathlib.Order.BoundedOrder.Lattice Mathlib.Order.BoundedOrder.Monotone Mathlib.Order.Bounded Mathlib.Order.Bounds.Basic Mathlib.Order.Bounds.Image Mathlib.Order.Bounds.Lattice Mathlib.Order.Bounds.OrderIso Mathlib.Order.Chain Mathlib.Order.Circular Mathlib.Order.Closure Mathlib.Order.Cofinal Mathlib.Order.Comparable Mathlib.Order.Compare Mathlib.Order.CompleteBooleanAlgebra Mathlib.Order.CompleteLattice.Basic Mathlib.Order.CompleteLattice.Chain Mathlib.Order.CompleteLattice.Defs Mathlib.Order.CompleteLattice.Lemmas Mathlib.Order.Concept Mathlib.Order.ConditionallyCompleteLattice.Basic Mathlib.Order.ConditionallyCompleteLattice.Defs Mathlib.Order.ConditionallyCompleteLattice.Indexed Mathlib.Order.Copy Mathlib.Order.Directed Mathlib.Order.Disjoint Mathlib.Order.Estimator Mathlib.Order.Extension.Linear Mathlib.Order.Filter.Defs Mathlib.Order.GaloisConnection.Basic Mathlib.Order.GaloisConnection.Defs Mathlib.Order.Heyting.Basic Mathlib.Order.Heyting.Hom Mathlib.Order.Heyting.Regular Mathlib.Order.Hom.Basic Mathlib.Order.Hom.BoundedLattice Mathlib.Order.Hom.Bounded Mathlib.Order.Hom.CompleteLattice Mathlib.Order.Hom.Lattice Mathlib.Order.Hom.Lex Mathlib.Order.Hom.Order Mathlib.Order.Hom.Set Mathlib.Order.Hom.WithTopBot Mathlib.Order.Interval.Basic Mathlib.Order.Interval.Lex Mathlib.Order.Interval.Set.Basic Mathlib.Order.Interval.Set.Disjoint Mathlib.Order.Interval.Set.Image Mathlib.Order.Interval.Set.LinearOrder Mathlib.Order.Interval.Set.OrderIso Mathlib.Order.Interval.Set.SurjOn Mathlib.Order.Interval.Set.WithBotTop Mathlib.Order.Iterate Mathlib.Order.LatticeIntervals Mathlib.Order.Lattice Mathlib.Order.Max Mathlib.Order.MinMax Mathlib.Order.Minimal Mathlib.Order.Monotone.Basic Mathlib.Order.Monotone.Extension Mathlib.Order.Monotone.Monovary Mathlib.Order.Monotone.Union Mathlib.Order.Nat Mathlib.Order.Nucleus Mathlib.Order.OrdContinuous Mathlib.Order.Preorder.Chain Mathlib.Order.Prod.Lex.Hom Mathlib.Order.PropInstances Mathlib.Order.Rel.GaloisConnection Mathlib.Order.RelClasses Mathlib.Order.RelIso.Basic Mathlib.Order.RelIso.Set Mathlib.Order.ScottContinuity Mathlib.Order.SetIsMax Mathlib.Order.Set Mathlib.Order.SymmDiff Mathlib.Order.Synonym Mathlib.Order.UpperLower.Relative Mathlib.Order.WellFounded Mathlib.Order.WithBot Mathlib.Order.Zorn Mathlib.SetTheory.Cardinal.Defs Mathlib.SetTheory.PGame.Basic Mathlib.SetTheory.ZFC.PSet Mathlib.Tactic.ApplyFun Mathlib.Tactic.Order.CollectFacts Mathlib.Tactic.Order.Graph.Basic Mathlib.Tactic.Order.Graph.Tarjan Mathlib.Tactic.Order.Preprocessing Mathlib.Tactic.Order Mathlib.Tactic.TautoSet
14
17 files Mathlib.Combinatorics.Quiver.Basic Mathlib.Combinatorics.Quiver.Prefunctor Mathlib.Combinatorics.Quiver.Push Mathlib.Combinatorics.Quiver.Subquiver Mathlib.Control.Monad.Basic Mathlib.Data.Countable.Defs Mathlib.Data.Erased Mathlib.Data.Finite.Defs Mathlib.Data.Opposite Mathlib.Data.Set.Opposite Mathlib.Logic.Equiv.Defs Mathlib.Logic.Equiv.Prod Mathlib.Logic.Equiv.Sum Mathlib.Logic.Small.Defs Mathlib.Logic.UnivLE Mathlib.Tactic.ProdAssoc Mathlib.Tactic.ProxyType
15
8 files Mathlib.Algebra.Order.ZeroLEOne Mathlib.Data.List.Scan Mathlib.Data.List.TakeWhile Mathlib.Data.PNat.Defs Mathlib.Order.Basic Mathlib.Order.Monotone.Defs Mathlib.Order.ULift Mathlib.Testing.Plausible.Sampleable
18
4 files Mathlib.Data.Set.Notation Mathlib.Data.Set.Operations Mathlib.Lean.Expr.ExtraRecognizers Mathlib.Order.SetNotation
19
Mathlib.Data.Nat.Bits 20
Mathlib.Data.Int.Basic 21
8 files Mathlib.Data.Bool.Basic Mathlib.Data.Char Mathlib.Data.Nat.Basic Mathlib.Data.Nat.Find Mathlib.Data.Nat.Sqrt Mathlib.Logic.Nontrivial.Basic Mathlib.Tactic.Nontriviality.Core Mathlib.Tactic.Nontriviality
22
5 files Mathlib.Algebra.NeZero Mathlib.Data.Int.Order.Basic Mathlib.Tactic.ByContra Mathlib.Tactic.Contrapose Mathlib.Tactic.Push
24
3 files Mathlib.Order.Defs.LinearOrder Mathlib.Order.Defs.PartialOrder Mathlib.Order.Interval.Set.Defs
25
Mathlib.Data.ENat.Defs 27
Mathlib.Order.Notation Mathlib.Order.TypeTags 28
Mathlib.Tactic.ToAdditive.ToDual (new file) 60
Mathlib.Tactic.ToDual (new file) 61

Declarations diff

+ BundledExtensions
+ Category.assoc_rev
+ LinearOrder.toDecidableGE
+ LinearOrder.toDecidableGT
+ NatTrans.naturality'
+ _root_.WithTop.recTopCoe
+ fixAbbreviation
+ instance (priority := 10) _root_.WithTop.le : LE (WithTop α)
+ instance (priority := 900) instTransGE : @Trans α α α GE.ge GE.ge GE.ge := ⟨ge_trans⟩
+ instance (priority := 900) instTransGEGT : @Trans α α α GE.ge GT.gt GT.gt := ⟨lt_of_le_of_lt'⟩
+ instance (priority := 900) instTransGT : @Trans α α α GT.gt GT.gt GT.gt := ⟨gt_trans⟩
+ instance (priority := 900) instTransGTGE : @Trans α α α GT.gt GE.ge GT.gt := ⟨lt_of_lt_of_le'⟩
+ instance (priority := 900) instTransLE : @Trans α α α LE.le LE.le LE.le := ⟨le_trans⟩
+ instance (priority := 900) instTransLELT : @Trans α α α LE.le LT.lt LT.lt := ⟨lt_of_le_of_lt⟩
+ instance (priority := 900) instTransLT : @Trans α α α LT.lt LT.lt LT.lt := ⟨lt_trans⟩
+ instance (priority := 900) instTransLTLE : @Trans α α α LT.lt LE.le LT.lt := ⟨lt_of_lt_of_le⟩
+ instance [Quiver.IsThin C] (f : X ⟶ Y) : Epi f
+ min_le_left
+ min_self
+ nameDict
+ replaceRecM
+ toAdditiveBundle
+ toDualBundle
++ max_comm'
- Eq.ge
- Eq.not_gt
- LE.le.antisymm'
- LE.le.eq_or_lt'
- LE.le.lt_of_ne'
- LE.le.lt_or_eq'
- LE.le.trans'
- LE.le.trans_lt'
- LT.lt.trans'
- LT.lt.trans_le'
- Ne.lt_of_le'
- WithTop
- _root_.Equiv.withTopSubtypeNe
- bot_eq_coe
- canLift
- cancel_mono
- cancel_mono_assoc_iff
- cancel_mono_id
- coeTC
- coe_bot
- coe_eq_bot
- coe_eq_coe
- coe_inj
- coe_injective
- coe_le_coe
- coe_ne_top
- coe_untop
- comp_dite
- comp_hom_eq_id
- comp_inv_eq
- comp_inv_eq_id
- comp_ite
- eq_comp_inv
- eq_max
- eq_of_comp_right_eq
- eq_of_comp_right_eq'
- eq_of_le_of_not_lt'
- eq_or_lt_of_le'
- eq_or_lt_of_not_gt
- eq_untop_iff
- forall_ge_iff_le
- ge_antisymm
- ge_iff_eq'
- ge_of_eq
- ge_trans
- gt_irrefl
- gt_trans
- id_of_comp_right_id
- inhabited
- instBot
- instance (X : C) : Mono (𝟙 X)
- instance (priority := 10) le : LE (WithTop α)
- instance (priority := 100) bot_nonempty (α : Type*) [Bot α] : Nonempty α
- instance (priority := 900) : @Trans α α α GE.ge GE.ge GE.ge := ⟨ge_trans⟩
- instance (priority := 900) : @Trans α α α GE.ge GT.gt GT.gt := ⟨lt_of_le_of_lt'⟩
- instance (priority := 900) : @Trans α α α GT.gt GE.ge GT.gt := ⟨lt_of_lt_of_le'⟩
- instance (priority := 900) : @Trans α α α GT.gt GT.gt GT.gt := ⟨gt_trans⟩
- instance (priority := 900) : @Trans α α α LE.le LE.le LE.le := ⟨le_trans⟩
- instance (priority := 900) : @Trans α α α LE.le LT.lt LT.lt := ⟨lt_of_le_of_lt⟩
- instance (priority := 900) : @Trans α α α LT.lt LE.le LT.lt := ⟨lt_of_lt_of_le⟩
- instance (priority := 900) : @Trans α α α LT.lt LT.lt LT.lt := ⟨lt_trans⟩
- instance : Epi f
- instance : Mono f
- instance [Repr α] : Repr (WithTop α)
- le_def
- le_imp_eq_iff_le_imp_ge'
- le_max_left
- le_max_right
- le_of_forall_ge
- lt_iff_ne'
- lt_of_le_of_lt'
- lt_of_le_of_ne'
- lt_of_lt_of_le'
- lt_or_eq_of_le'
- map
- map_coe
- map_comm
- map_eq_some_iff
- map_eq_top_iff
- map_injective
- map_top
- map₂
- map₂_coe_coe
- map₂_eq_top_iff
- map₂_top_left
- map₂_top_right
- max_assoc
- max_comm
- max_eq_left
- max_eq_left_of_lt
- max_eq_right
- max_eq_right_of_lt
- max_le
- max_left_comm
- max_lt
- max_self
- mono_comp
- mono_comp'
- mono_of_mono
- mono_of_mono_fac
- ne'
- ne_of_gt
- ne_top_iff_exists
- none_eq_top
- nontrivial
- not_lt_iff_eq'
- recTopCoe
- recTopCoe_coe
- recTopCoe_top
- self_symm_id
- some
- some_eq_coe
- some_eq_map_iff
- top
- top_ne_coe
- trans_refl
- untop
- untopD
- untopD_coe
- untopD_eq_iff
- untopD_eq_self_iff
- untopD_eq_untopD_iff
- untopD_top
- untop_coe
- untop_eq_iff
- whisker_eq
- «exists»
- «forall»
-+- map₂_coe_left
-+- map₂_coe_right

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


Decrease in tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type
1441 -1 porting notes

Current commit 0ea51c590e
Reference commit d5d137aecc

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Feb 11, 2025
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 12, 2025
@grunweg grunweg added the t-meta Tactics, attributes or user commands label Feb 15, 2025
@JovanGerb

Copy link
Copy Markdown
Contributor

From the fixes you made, it looks like I messed up the lemmas Eq.trans_ge and LE.le.trans_eq?

@JovanGerb

Copy link
Copy Markdown
Contributor

The calc failure must be related to the Trans instances. There are 8 instances and I made it so that the dual ones are generated by to_dual. But I guess that didn't work correctly.

@bryangingechen

bryangingechen commented Jul 29, 2025 •

Copy link
Copy Markdown
Contributor Author

I went ahead and tried to fix the to_dual labeling in Order.Basic that led to these fixes. Hopefully I didn't mess the names up...

Along the way I noticed some strange behavior. If you try to apply reorder to le_of_eq_of_le in Order.Basic, you get the following error message, which I find rather inscrutable:

@[to_dual (reorder := 2) Eq.trans_ge']
alias Eq.trans_le := le_of_eq_of_le
/-
the permutation
[[1]]
provided by the reorder config option is too large, the function
  @le_of_eq_of_le
has only 0 arguments
-/

You get a similar error message for every value up to 7, then beyond that the function in the error message changes:

@[to_dual (reorder := 8) Eq.trans_ge']
alias Eq.trans_le := le_of_eq_of_le
/-
the permutation
[[7]]
provided by the reorder config option is too large, the type
  ∀ {α : Type u_1} {a b c : α} [inst : LE α], a = b → b ≤ c → a ≤ c
has only 7 arguments
-/

Comment thread Mathlib/Order/Defs/PartialOrder.lean Outdated
Comment on lines +123 to +126
@[to_dual instTransGE] instance instTransLE : @Trans α α α LE.le LE.le LE.le := ⟨le_trans⟩
@[to_dual instTransGT] instance instTransLT : @Trans α α α LT.lt LT.lt LT.lt := ⟨lt_trans⟩
@[to_dual instTransGTGE] instance instTransLTLE : @Trans α α α LT.lt LE.le LT.lt := ⟨lt_of_lt_of_le⟩
@[to_dual instTransGEGT] instance instTransLELT : @Trans α α α LE.le LT.lt LT.lt := ⟨lt_of_le_of_lt⟩

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about the way calc works to know if this matters, but it looks like the conclusions of the previous instances print like Trans GE.ge GE.ge GE.ge , whereas the conclusions of the new instances print like Trans (fun a a_1 ↦ a_1 ≤ a) (fun a a_1 ↦ a_1 ≤ a) fun a a_1 ↦ a_1 ≤ a (without GE.ge / GT.gt).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing a new instance with GE.ge explicitly makes calc blocks work again, so I'll revert the change around here for now and leave a comment.

@bryangingechen bryangingechen changed the title to_dual attribute feat: to_dual attribute Jul 30, 2025
@JovanGerb

Copy link
Copy Markdown
Contributor

Firstly, the (reorder := ...) syntax uses cycle notation to specify permutation, so (reorder := 3) won't do anything. There should be a clearer error message for this.

The error message you are getting is coming from the fact that the proof is not a lambda, but a constant (since you use alias). So it cannot reorder the arguments of the lambda without first creating the lambda by eta-expansion. I think this should also be fixed.

@JovanGerb

Copy link
Copy Markdown
Contributor

I've now opened a PR for both: #27693 and #27692

@bryangingechen

Copy link
Copy Markdown
Contributor Author

Ah, for the first one, I was aware of that, I just wanted to minimize my example (I was playing around with (reorder := 2 3) and (reorder := 3 4) to see if I could get the types to match, but they didn't). Thanks for the fixes!

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 31, 2025
@leanprover-community-bot-assistant

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 2, 2025
@github-actions github-actions Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 2, 2025
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 2, 2025
@bryangingechen

Copy link
Copy Markdown
Contributor Author

It seems this will be continued in #27887.

@YaelDillies
YaelDillies deleted the bgc-order-dual-scratch-0 branch August 15, 2025 16:40
mathlib-bors Bot pushed a commit that referenced this pull request Nov 13, 2025
This PR defines the `to_dual` attribute for translating lemmas to their dual. This is useful in order theory and in category theory. It is built on top of the `to_additive` machinery.

This PR only adds `@[to_dual]` tags in files that directly need to import `ToDual`, namely `Order/Defs/PartialOrder`, `Order/Notation` and `Combinatorics/Quiver/Basic`. Further tagging is left for (many) future PRs.

This PR continues the work from #21719

Related (mathlib3) issues: 
- leanprover-community/mathlib3#13461
- leanprover-community/mathlib3#7691

Co-authored-by: @bryangingechen
Co-authored-by: Bryan Gin-ge Chen <[email protected]>
mathlib-bors Bot pushed a commit that referenced this pull request Nov 13, 2025
This PR defines the `to_dual` attribute for translating lemmas to their dual. This is useful in order theory and in category theory. It is built on top of the `to_additive` machinery.

This PR only adds `@[to_dual]` tags in files that directly need to import `ToDual`, namely `Order/Defs/PartialOrder`, `Order/Notation` and `Combinatorics/Quiver/Basic`. Further tagging is left for (many) future PRs.

This PR continues the work from #21719

Related (mathlib3) issues: 
- leanprover-community/mathlib3#13461
- leanprover-community/mathlib3#7691

Co-authored-by: @bryangingechen
Co-authored-by: Bryan Gin-ge Chen <[email protected]>
thorimur pushed a commit to thorimur/mathlib4 that referenced this pull request Nov 16, 2025
This PR defines the `to_dual` attribute for translating lemmas to their dual. This is useful in order theory and in category theory. It is built on top of the `to_additive` machinery.

This PR only adds `@[to_dual]` tags in files that directly need to import `ToDual`, namely `Order/Defs/PartialOrder`, `Order/Notation` and `Combinatorics/Quiver/Basic`. Further tagging is left for (many) future PRs.

This PR continues the work from leanprover-community#21719

Related (mathlib3) issues: 
- leanprover-community/mathlib3#13461
- leanprover-community/mathlib3#7691

Co-authored-by: @bryangingechen
Co-authored-by: Bryan Gin-ge Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-import Automatically added label for PRs with a significant increase in transitive imports t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants