Documentation

Mathlib.Tactic.NormNum.Basic

norm_num basic plugins #

This file adds norm_num plugins for

See other files in this directory for many more plugins.

Constructors and constants #

The norm_num extension which identifies the expression Zero.zero, returning 0.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    The norm_num extension which identifies the expression One.one, returning 1.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Mathlib.Meta.NormNum.isNat_ofNat (α : Type u) [AddMonoidWithOne α] {a : α} {n : } (h : n = a) :
      IsNat a n

      The norm_num extension which identifies an expression OfNat.ofNat n, returning n.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The norm_num extension which identifies the constructor application Int.ofNat n such that norm_num successfully recognizes n, returning n.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The norm_num extension which identifies the expression Int.natAbs n such that norm_num successfully recognizes n.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Casts #

            theorem Mathlib.Meta.NormNum.isNat_natCast {R : Type u_1} [AddMonoidWithOne R] (n m : ) :
            IsNat n mIsNat (↑n) m

            The norm_num extension which identifies an expression Nat.cast n, returning n.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Mathlib.Meta.NormNum.isNat_intCast {R : Type u_1} [Ring R] (n : ) (m : ) :
              IsNat n mIsNat (↑n) m
              theorem Mathlib.Meta.NormNum.isintCast {R : Type u_1} [Ring R] (n m : ) :
              IsInt n mIsInt (↑n) m

              The norm_num extension which identifies an expression Int.cast n, returning n.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Arithmetic #

                Note: Many of the lemmas in this file use a function equality hypothesis like f = HAdd.hAdd below. The reason for this is that when this is applied, to prove e.g. 100 + 200 = 300, the + here is HAdd.hAdd with an instance that may not be syntactically equal to the one supplied by the AddMonoidWithOne instance, and rather than attempting to prove the instances equal lean will sometimes decide to evaluate 100 + 200 directly (into whatever + is defined to do in this ring), which is definitely not what we want; if the subterms are expensive to kernel-reduce then this could cause a (kernel) deep recursion detected error (see https://github.com/leanprover/lean4/issues/2171, https://github.com/leanprover-community/mathlib4/pull/4048).

                By using an equality for the unapplied + function and proving it by rfl we take away the opportunity for lean to unfold the numerals (and the instance defeq problem is usually comparatively easy).

                Equations
                Instances For
                  theorem Mathlib.Meta.NormNum.isNat_add {α : Type u_1} [AddMonoidWithOne α] {f : ααα} {a b : α} {a' b' c : } :
                  f = HAdd.hAddIsNat a a'IsNat b b'a'.add b' = cIsNat (f a b) c
                  theorem Mathlib.Meta.NormNum.isInt_add {α : Type u_1} [Ring α] {f : ααα} {a b : α} {a' b' c : } :
                  f = HAdd.hAddIsInt a a'IsInt b b'a'.add b' = cIsInt (f a b) c
                  def Mathlib.Meta.NormNum.invertibleOfMul {α : Type u_1} [Semiring α] (k : ) (b a : α) [Invertible a] :
                  a = k * bInvertible b

                  If b divides a and a is invertible, then b is invertible.

                  Equations
                  Instances For
                    def Mathlib.Meta.NormNum.invertibleOfMul' {α : Type u_1} [Semiring α] {a k b : } [Invertible a] (h : a = k * b) :

                    If b divides a and a is invertible, then b is invertible.

                    Equations
                    Instances For
                      theorem Mathlib.Meta.NormNum.isNNRat_add {α : Type u_1} [Semiring α] {f : ααα} {a b : α} {na nb nc da db dc k : } :
                      f = HAdd.hAddIsNNRat a na daIsNNRat b nb db(na.mul db).add (nb.mul da) = k.mul ncda.mul db = k.mul dcIsNNRat (f a b) nc dc
                      theorem Mathlib.Meta.NormNum.isRat_add {α : Type u_1} [Ring α] {f : ααα} {a b : α} {na nb nc : } {da db dc k : } :
                      f = HAdd.hAddIsRat a na daIsRat b nb db(na.mul db).add (nb.mul da) = (↑k).mul ncda.mul db = k.mul dcIsRat (f a b) nc dc

                      Consider an Option as an object in the MetaM monad, by throwing an error on none.

                      Equations
                      Instances For
                        def Mathlib.Meta.NormNum.Result.add {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Add «$α») := by exact q(delta% inferInstance)) :
                        Lean.MetaM (Result q(«$a» + «$b»))

                        The result of adding two norm_num results.

                        Instances For
                          def Mathlib.Meta.NormNum.Result.add.intArm {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Add «$α»)) ( : Q(Ring «$α»)) :
                          Lean.MetaM (Result q(«$a» + «$b»))
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Mathlib.Meta.NormNum.Result.add.nnratArm {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Add «$α»)) (dsα : Q(DivisionSemiring «$α»)) :
                            Lean.MetaM (Result q(«$a» + «$b»))
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def Mathlib.Meta.NormNum.Result.add.ratArm {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Add «$α»)) ( : Q(DivisionRing «$α»)) :
                              Lean.MetaM (Result q(«$a» + «$b»))
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                The norm_num extension which identifies expressions of the form a + b, such that norm_num successfully recognises both a and b.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem Mathlib.Meta.NormNum.isInt_neg {α : Type u_1} [Ring α] {f : αα} {a : α} {a' b : } :
                                  f = Neg.negIsInt a a'a'.neg = bIsInt (-a) b
                                  theorem Mathlib.Meta.NormNum.isRat_neg {α : Type u_1} [Ring α] {f : αα} {a : α} {n n' : } {d : } :
                                  f = Neg.negIsRat a n dn.neg = n'IsRat (-a) n' d
                                  def Mathlib.Meta.NormNum.Result.neg {u : Lean.Level} {α : Q(Type u)} {a : Q(«$α»)} (ra : Result q(«$a»)) ( : Q(Ring «$α») := by exact q(delta% inferInstance)) :
                                  Lean.MetaM (Result q(-«$a»))

                                  The result of negating a norm_num result.

                                  Equations
                                  Instances For

                                    The norm_num extension which identifies expressions of the form -a, such that norm_num successfully recognises a.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      theorem Mathlib.Meta.NormNum.isInt_sub {α : Type u_1} [Ring α] {f : ααα} {a b : α} {a' b' c : } :
                                      f = HSub.hSubIsInt a a'IsInt b b'a'.sub b' = cIsInt (f a b) c
                                      theorem Mathlib.Meta.NormNum.isRat_sub {α : Type u_1} [Ring α] {f : ααα} {a b : α} {na nb nc : } {da db dc k : } (hf : f = HSub.hSub) (ra : IsRat a na da) (rb : IsRat b nb db) (h₁ : (na.mul db).sub (nb.mul da) = (↑k).mul nc) (h₂ : da.mul db = k.mul dc) :
                                      IsRat (f a b) nc dc
                                      def Mathlib.Meta.NormNum.Result.sub {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Ring «$α») := by exact q(delta% inferInstance)) :
                                      Lean.MetaM (Result q(«$a» - «$b»))

                                      The result of subtracting two norm_num results.

                                      Equations
                                      Instances For

                                        The norm_num extension which identifies expressions of the form a - b in a ring, such that norm_num successfully recognises both a and b.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          theorem Mathlib.Meta.NormNum.isNat_mul {α : Type u_1} [Semiring α] {f : ααα} {a b : α} {a' b' c : } :
                                          f = HMul.hMulIsNat a a'IsNat b b'a'.mul b' = cIsNat (a * b) c
                                          theorem Mathlib.Meta.NormNum.isInt_mul {α : Type u_1} [Ring α] {f : ααα} {a b : α} {a' b' c : } :
                                          f = HMul.hMulIsInt a a'IsInt b b'a'.mul b' = cIsInt (a * b) c
                                          theorem Mathlib.Meta.NormNum.isNNRat_mul {α : Type u_1} [Semiring α] {f : ααα} {a b : α} {na nb nc da db dc k : } :
                                          f = HMul.hMulIsNNRat a na daIsNNRat b nb dbna.mul nb = k.mul ncda.mul db = k.mul dcIsNNRat (f a b) nc dc
                                          theorem Mathlib.Meta.NormNum.isRat_mul {α : Type u_1} [Ring α] {f : ααα} {a b : α} {na nb nc : } {da db dc k : } :
                                          f = HMul.hMulIsRat a na daIsRat b nb dbna.mul nb = (↑k).mul ncda.mul db = k.mul dcIsRat (f a b) nc dc
                                          def Mathlib.Meta.NormNum.Result.mul {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Semiring «$α») := by exact q(delta% inferInstance)) :
                                          Lean.MetaM (Result q(«$a» * «$b»))

                                          The result of multiplying two norm_num results.

                                          Instances For
                                            def Mathlib.Meta.NormNum.Result.mul.ratArm {u : Lean.Level} {α : Q(Type u)} {a b : Q(«$α»)} (ra : Result q(«$a»)) (rb : Result q(«$b»)) (inst : Q(Semiring «$α»)) ( : Q(DivisionRing «$α»)) :
                                            Option (Result q(«$a» * «$b»))
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              The norm_num extension which identifies expressions of the form a * b, such that norm_num successfully recognises both a and b.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                theorem Mathlib.Meta.NormNum.isNNRat_div {α : Type u} [DivisionSemiring α] {a b : α} {cn cd : } :
                                                IsNNRat (a * b⁻¹) cn cdIsNNRat (a / b) cn cd
                                                theorem Mathlib.Meta.NormNum.isRat_div {α : Type u} [DivisionRing α] {a b : α} {cn : } {cd : } :
                                                IsRat (a * b⁻¹) cn cdIsRat (a / b) cn cd

                                                Helper function to synthesize a typed DivisionSemiring α expression.

                                                Equations
                                                Instances For

                                                  Helper function to synthesize a typed DivisionRing α expression.

                                                  Equations
                                                  Instances For

                                                    The norm_num extension which identifies expressions of the form a / b, such that norm_num successfully recognises both a and b.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For

                                                      Logic #

                                                      The norm_num extension which identifies True.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        The norm_num extension which identifies False.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For

                                                          The norm_num extension which identifies expressions of the form ¬a, such that norm_num successfully recognises a.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For

                                                            (In)equalities #

                                                            theorem Mathlib.Meta.NormNum.isNat_eq_true {α : Type u} [AddMonoidWithOne α] {a b : α} {c : } :
                                                            IsNat a cIsNat b ca = b
                                                            theorem Mathlib.Meta.NormNum.isInt_eq_true {α : Type u} [Ring α] {a b : α} {z : } :
                                                            IsInt a zIsInt b za = b
                                                            theorem Mathlib.Meta.NormNum.isNNRat_eq_true {α : Type u} [Semiring α] {a b : α} {n d : } :
                                                            IsNNRat a n dIsNNRat b n da = b
                                                            theorem Mathlib.Meta.NormNum.isRat_eq_true {α : Type u} [Ring α] {a b : α} {n : } {d : } :
                                                            IsRat a n dIsRat b n da = b
                                                            theorem Mathlib.Meta.NormNum.eq_of_true {a b : Prop} (ha : a) (hb : b) :
                                                            a = b
                                                            theorem Mathlib.Meta.NormNum.ne_of_false_of_true {a b : Prop} (ha : ¬a) (hb : b) :
                                                            a b
                                                            theorem Mathlib.Meta.NormNum.ne_of_true_of_false {a b : Prop} (ha : a) (hb : ¬b) :
                                                            a b
                                                            theorem Mathlib.Meta.NormNum.eq_of_false {a b : Prop} (ha : ¬a) (hb : ¬b) :
                                                            a = b

                                                            Nat operations #

                                                            theorem Mathlib.Meta.NormNum.isNat_natSucc {a a' c : } :
                                                            IsNat a a'a'.succ = cIsNat a.succ c

                                                            The norm_num extension which identifies expressions of the form Nat.succ a, such that norm_num successfully recognises a.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              theorem Mathlib.Meta.NormNum.isNat_natSub {a b a' b' c : } :
                                                              IsNat a a'IsNat b b'a'.sub b' = cIsNat (a - b) c

                                                              The norm_num extension which identifies expressions of the form Nat.sub a b, such that norm_num successfully recognises both a and b.

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                theorem Mathlib.Meta.NormNum.isNat_natMod {a b a' b' c : } :
                                                                IsNat a a'IsNat b b'a'.mod b' = cIsNat (a % b) c

                                                                The norm_num extension which identifies expressions of the form Nat.mod a b, such that norm_num successfully recognises both a and b.

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  theorem Mathlib.Meta.NormNum.isNat_natDiv {a b a' b' c : } :
                                                                  IsNat a a'IsNat b b'a'.div b' = cIsNat (a / b) c

                                                                  The norm_num extension which identifies expressions of the form Nat.div a b, such that norm_num successfully recognises both a and b.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For
                                                                    theorem Mathlib.Meta.NormNum.isNat_dvd_true {a b a' b' : } :
                                                                    IsNat a a'IsNat b b'b'.mod a' = 0a b
                                                                    theorem Mathlib.Meta.NormNum.isNat_dvd_false {a b a' b' c : } :
                                                                    IsNat a a'IsNat b b'b'.mod a' = c.succ¬a b

                                                                    The norm_num extension which identifies expressions of the form (a : ℕ) | b, such that norm_num successfully recognises both a and b.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For