Documentation

Mathlib.Tactic.Ring.RingNF

ring_nf tactic #

A tactic which uses ring to rewrite expressions. This can be used non-terminally to normalize ring expressions in the goal such as ⊒ P (x + x + x) ~> ⊒ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

def Mathlib.Tactic.Ring.ExBase.isAtom {u : Lean.Level} {arg : Q(Type u)} {sΞ± : Q(CommSemiring Β«$argΒ»)} {a : Q(Β«$argΒ»)} :
ExBase sΞ± a β†’ Bool

True if this represents an atomic expression.

Instances For
    def Mathlib.Tactic.Ring.ExProd.isAtom {u : Lean.Level} {arg : Q(Type u)} {sΞ± : Q(CommSemiring Β«$argΒ»)} {a : Q(Β«$argΒ»)} :
    ExProd sΞ± a β†’ Bool

    True if this represents an atomic expression.

    Instances For
      def Mathlib.Tactic.Ring.ExSum.isAtom {u : Lean.Level} {arg : Q(Type u)} {sΞ± : Q(CommSemiring Β«$argΒ»)} {a : Q(Β«$argΒ»)} :
      ExSum sΞ± a β†’ Bool

      True if this represents an atomic expression.

      Instances For

        The normalization style for ring_nf.

        • SOP : RingMode

          Sum-of-products form, like x + x * y * 2 + z ^ 2.

        • raw : RingMode

          Raw form: the representation ring uses internally.

        Instances For
          def Mathlib.Tactic.RingNF.instReprRingMode.repr :
          RingMode β†’ β„• β†’ Std.Format
          Instances For

            Configuration for ring_nf.

            • red : Lean.Meta.TransparencyMode
            • zetaDelta : Bool
            • contextual : Bool
            • failIfUnchanged : Bool

              if true, then fail if no progress is made

            • mode : RingMode

              The normalization style.

            Instances For
              def Mathlib.Tactic.RingNF.instReprConfig.repr :
              Config β†’ β„• β†’ Std.Format
              Instances For
                def Mathlib.Tactic.RingNF.elabConfig :
                Lean.Syntax β†’ Lean.Elab.Tactic.TacticM Config

                Function elaborating RingNF.Config.

                Instances For
                  def Mathlib.Tactic.RingNF.evalExpr (e : Lean.Expr) :
                  AtomM Lean.Meta.Simp.Result

                  Evaluates an expression e into a normalized representation as a polynomial.

                  This is a variant of Mathlib.Tactic.Ring.eval, the main driver of the ring tactic. It differs in

                  • operating on Expr (input) and Simp.Result (output), rather than typed Qq versions of these;
                  • throwing an error if the expression e is an atom for the ring tactic.
                  Instances For
                    theorem Mathlib.Tactic.RingNF.add_assoc_rev {R : Type u_1} [CommSemiring R] (a b c : R) :
                    a + (b + c) = a + b + c
                    theorem Mathlib.Tactic.RingNF.mul_assoc_rev {R : Type u_1} [CommSemiring R] (a b c : R) :
                    a * (b * c) = a * b * c
                    theorem Mathlib.Tactic.RingNF.mul_neg {R : Type u_2} [Ring R] (a b : R) :
                    a * -b = -(a * b)
                    theorem Mathlib.Tactic.RingNF.add_neg {R : Type u_2} [Ring R] (a b : R) :
                    a + -b = a - b
                    theorem Mathlib.Tactic.RingNF.nat_rawCast_2 {R : Type u_1} [CommSemiring R] {n : β„•} [n.AtLeastTwo] :
                    n.rawCast = OfNat.ofNat n
                    theorem Mathlib.Tactic.RingNF.int_rawCast_neg {n : β„•} {R : Type u_2} [Ring R] :
                    (Int.negOfNat n).rawCast = -n.rawCast
                    theorem Mathlib.Tactic.RingNF.rat_rawCast_neg {n d : β„•} {R : Type u_2} [DivisionRing R] :
                    Rat.rawCast (Int.negOfNat n) d = (Int.negOfNat n).rawCast / d.rawCast
                    def Mathlib.Tactic.RingNF.cleanup (cfg : Config) (r : Lean.Meta.Simp.Result) :
                    Lean.MetaM Lean.Meta.Simp.Result

                    A cleanup routine, which simplifies normalized polynomials to a more human-friendly format.

                    Instances For
                      def Mathlib.Tactic.RingNF.ringNF :
                      Lean.ParserDescr

                      ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

                      ring_nf works as both a tactic and a conv tactic.

                      See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

                      • ring_nf! will use a more aggressive reducibility setting to identify atoms.
                      • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
                        • red: the reducibility setting (overridden by !)
                        • zetaDelta: if true, local let variables can be unfolded (overridden by !)
                        • recursive: if true, ring_nf will also recurse into atoms
                      • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

                      Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊒ P (x + x + x) ~> ⊒ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

                      Instances For

                        ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

                        ring_nf works as both a tactic and a conv tactic.

                        See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

                        • ring_nf! will use a more aggressive reducibility setting to identify atoms.
                        • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
                          • red: the reducibility setting (overridden by !)
                          • zetaDelta: if true, local let variables can be unfolded (overridden by !)
                          • recursive: if true, ring_nf will also recurse into atoms
                        • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

                        Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊒ P (x + x + x) ~> ⊒ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

                        Instances For
                          def Mathlib.Tactic.RingNF.ringNFConv :
                          Lean.ParserDescr

                          ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

                          ring_nf works as both a tactic and a conv tactic.

                          See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

                          • ring_nf! will use a more aggressive reducibility setting to identify atoms.
                          • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
                            • red: the reducibility setting (overridden by !)
                            • zetaDelta: if true, local let variables can be unfolded (overridden by !)
                            • recursive: if true, ring_nf will also recurse into atoms
                          • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

                          Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊒ P (x + x + x) ~> ⊒ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

                          Instances For
                            def Mathlib.Tactic.RingNF.ring1NF :
                            Lean.ParserDescr

                            ring1 solves the goal when it is an equality in commutative (semi)rings, allowing variables in the exponent.

                            This version of ring fails if the target is not an equality.

                            • ring1! uses a more aggressive reducibility setting to determine equality of atoms.

                            Extensions:

                              • ring1_nf additionally uses ring_nf to simplify in atoms.
                              • ring1_nf! will use a more aggressive reducibility setting to determine equality of atoms.
                            Instances For

                              ring1 solves the goal when it is an equality in commutative (semi)rings, allowing variables in the exponent.

                              This version of ring fails if the target is not an equality.

                              • ring1! uses a more aggressive reducibility setting to determine equality of atoms.

                              Extensions:

                                • ring1_nf additionally uses ring_nf to simplify in atoms.
                                • ring1_nf! will use a more aggressive reducibility setting to determine equality of atoms.
                              Instances For
                                def Mathlib.Tactic.RingNF.elabRingNFConv :
                                Lean.Elab.Tactic.Tactic

                                Elaborator for the ring_nf tactic.

                                Instances For

                                  ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

                                  ring_nf works as both a tactic and a conv tactic.

                                  See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

                                  • ring_nf! will use a more aggressive reducibility setting to identify atoms.
                                  • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
                                    • red: the reducibility setting (overridden by !)
                                    • zetaDelta: if true, local let variables can be unfolded (overridden by !)
                                    • recursive: if true, ring_nf will also recurse into atoms
                                  • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

                                  Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊒ P (x + x + x) ~> ⊒ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

                                  Instances For
                                    def Mathlib.Tactic.RingNF.ring :
                                    Lean.ParserDescr

                                    ring solves equations in commutative (semi)rings, allowing for variables in the exponent. If the goal is not appropriate for ring (e.g. not an equality) ring_nf will be suggested. See also ring1, which fails if the goal is not an equality.

                                    • ring! will use a more aggressive reducibility setting to determine equality of atoms.

                                    Examples:

                                    example (n : β„•) (m : β„€) : 2^(n+1) * m = 2 * 2^n * m := by ring
                                    example (a b : β„€) (n : β„•) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring
                                    example (x y : β„•) : x + id y = y + id x := by ring!
                                    example (x : β„•) (h : x * 2 > 5): x + x > 5 := by ring; assumption -- suggests ring_nf
                                    
                                    Instances For
                                      def Mathlib.Tactic.RingNF.tacticRing! :
                                      Lean.ParserDescr

                                      ring solves equations in commutative (semi)rings, allowing for variables in the exponent. If the goal is not appropriate for ring (e.g. not an equality) ring_nf will be suggested. See also ring1, which fails if the goal is not an equality.

                                      • ring! will use a more aggressive reducibility setting to determine equality of atoms.

                                      Examples:

                                      example (n : β„•) (m : β„€) : 2^(n+1) * m = 2 * 2^n * m := by ring
                                      example (a b : β„€) (n : β„•) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring
                                      example (x y : β„•) : x + id y = y + id x := by ring!
                                      example (x : β„•) (h : x * 2 > 5): x + x > 5 := by ring; assumption -- suggests ring_nf
                                      
                                      Instances For
                                        def Mathlib.Tactic.RingNF.ringConv :
                                        Lean.ParserDescr

                                        The tactic ring evaluates expressions in commutative (semi)rings. This is the conv tactic version, which rewrites a target which is a ring equality to True.

                                        See also the ring tactic.

                                        Instances For
                                          def Mathlib.Tactic.RingNF.convRing! :
                                          Lean.ParserDescr

                                          The tactic ring evaluates expressions in commutative (semi)rings. This is the conv tactic version, which rewrites a target which is a ring equality to True.

                                          See also the ring tactic.

                                          Instances For

                                            We register ring with the hint tactic.