The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.NormNum.Pow

31 declarations. Mathlib docs · Source

norm_num plugin for ^.

theorem Mathlib.Meta.NormNum.natPow_zero E1 #

∀ {a : ℕ}, a.pow 0 = 1

theorem Mathlib.Meta.NormNum.natPow_one E1 #

∀ {a : ℕ}, a.pow 1 = a

theorem Mathlib.Meta.NormNum.zero_natPow E1 #

∀ {b : ℕ}, Nat.pow 0 b.succ = 0

theorem Mathlib.Meta.NormNum.one_natPow E1 #

∀ {b : ℕ}, Nat.pow 1 b = 1

structure Mathlib.Meta.NormNum.IsNatPowT E1 #

Prop → ℕ → ℕ → ℕ → Prop

This is an opaque wrapper around Nat.pow to prevent lean from unfolding the definition of Nat.pow on numerals. The arbitrary precondition p is actually a formula of the form Nat.pow a' b' = c' but we usually don't care to unfold this proposition so we just carry a reference to it.

ctor Mathlib.Meta.NormNum.IsNatPowT.mk E0 #

∀ {p : Prop} {a b c : ℕ}, (p → a.pow b = c) → Mathlib.Meta.NormNum.IsNatPowT p a b c

theorem Mathlib.Meta.NormNum.IsNatPowT.run' E1 #

∀ {p : Prop} {a b c : ℕ}, Mathlib.Meta.NormNum.IsNatPowT p a b c → p → a.pow b = c

Unfolds the assertion.

theorem Mathlib.Meta.NormNum.IsNatPowT.run E1 #

∀ {a b c : ℕ}, Mathlib.Meta.NormNum.IsNatPowT (a.pow 1 = a) a b c → a.pow b = c

theorem Mathlib.Meta.NormNum.IsNatPowT.trans E1 #

∀ {a b c : ℕ} {p : Prop} {b' c' : ℕ},
  Mathlib.Meta.NormNum.IsNatPowT p a b c →
    Mathlib.Meta.NormNum.IsNatPowT (a.pow b = c) a b' c' → Mathlib.Meta.NormNum.IsNatPowT p a b' c'

This is the key to making the proof proceed as a balanced tree of applications instead of a linear sequence. It is just modus ponens after unwrapping the definitions.

theorem Mathlib.Meta.NormNum.IsNatPowT.bit0 E1 #

∀ {a b c : ℕ}, Mathlib.Meta.NormNum.IsNatPowT (a.pow b = c) a (2 * b) (c.mul c)

theorem Mathlib.Meta.NormNum.IsNatPowT.bit1 E1 #

∀ {a b c : ℕ}, Mathlib.Meta.NormNum.IsNatPowT (a.pow b = c) a (2 * b + 1) (c.mul (c.mul a))

def Mathlib.Meta.NormNum.evalNatPow E1 #

(a b : Q(ℕ)) → OptionT Lean.CoreM ((c : Q(ℕ)) × Q(«$a».pow «$b» = «$c»))

Proves Nat.pow a b = c where a and b are raw nat literals. This could be done by just rfl but the kernel does not have a special case implementation for Nat.pow so this would proceed by unary recursion on b, which is too slow and also leads to deep recursion.

We instead do the proof by binary recursion, but this can still lead to deep recursion, so we use an additional trick to do binary subdivision on log2 b. As a result this produces a proof of depth log (log b) which will essentially never overflow before the numbers involved themselves exceed memory limits.

theorem Mathlib.Meta.NormNum.intPow_ofNat E1 #

∀ {a b c : ℕ}, a.pow b = c → (Int.ofNat a).pow b = Int.ofNat c

theorem Mathlib.Meta.NormNum.intPow_negOfNat_bit0 E1 #

∀ {a b c b' c' : ℕ}, a.pow b' = c' → 2 * b' = b → c' * c' = c → (Int.negOfNat a).pow b = Int.ofNat c

theorem Mathlib.Meta.NormNum.intPow_negOfNat_bit1 E1 #

∀ {a b c b' c' : ℕ}, a.pow b' = c' → 2 * b' + 1 = b → c' * (c' * a) = c → (Int.negOfNat a).pow b = Int.negOfNat c

def Mathlib.Meta.NormNum.evalIntPow E1 #

ℤ → (a : Q(ℤ)) → (b : Q(ℕ)) → OptionT Lean.CoreM (ℤ × (c : Q(ℤ)) × Q(«$a».pow «$b» = «$c»))

Evaluates Int.pow a b = c where a and b are raw integer literals.

theorem Mathlib.Meta.NormNum.isNat_pow E1 #

∀ {α : Type u_1} [inst : Semiring α] {f : α → ℕ → α} {a : α} {b a' b' c : ℕ},
  f = HPow.hPow →
    Mathlib.Meta.NormNum.IsNat a a' →
      Mathlib.Meta.NormNum.IsNat b b' → a'.pow b' = c → Mathlib.Meta.NormNum.IsNat (f a b) c

theorem Mathlib.Meta.NormNum.isInt_pow E1 #

∀ {α : Type u_1} [inst : Ring α] {f : α → ℕ → α} {a : α} {b : ℕ} {a' : ℤ} {b' : ℕ} {c : ℤ},
  f = HPow.hPow →
    Mathlib.Meta.NormNum.IsInt a a' →
      Mathlib.Meta.NormNum.IsNat b b' → a'.pow b' = c → Mathlib.Meta.NormNum.IsInt (f a b) c

theorem Mathlib.Meta.NormNum.isRat_pow E1 #

∀ {α : Type u_1} [inst : Ring α] {f : α → ℕ → α} {a : α} {an cn : ℤ} {ad b b' cd : ℕ},
  f = HPow.hPow →
    Mathlib.Meta.NormNum.IsRat a an ad →
      Mathlib.Meta.NormNum.IsNat b b' → an.pow b' = cn → ad.pow b' = cd → Mathlib.Meta.NormNum.IsRat (f a b) cn cd

theorem Mathlib.Meta.NormNum.isNNRat_pow E1 #

∀ {α : Type u_1} [inst : Semiring α] {f : α → ℕ → α} {a : α} {an cn ad b b' cd : ℕ},
  f = HPow.hPow →
    Mathlib.Meta.NormNum.IsNNRat a an ad →
      Mathlib.Meta.NormNum.IsNat b b' → an.pow b' = cn → ad.pow b' = cd → Mathlib.Meta.NormNum.IsNNRat (f a b) cn cd

def Mathlib.Meta.NormNum.evalPow.core E1 #

{u : Lean.Level} →
  {α : Q(Type u)} →
    (e : Q(«$α»)) →
      Q(«$α» → ℕ → «$α») →
        (a : Q(«$α»)) →
          (b nb : Q(ℕ)) →
            Q(Mathlib.Meta.NormNum.IsNat «$b» «$nb») →
              Q(Semiring «$α») → Mathlib.Meta.NormNum.Result a → OptionT Lean.CoreM (Mathlib.Meta.NormNum.Result e)

Main part of evalPow.

def Mathlib.Meta.NormNum.evalPow E1 #

Mathlib.Meta.NormNum.NormNumExt

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

theorem Mathlib.Meta.NormNum.isNat_zpow_pos E1 #

∀ {α : Type u_1} [inst : DivisionSemiring α] {a : α} {b : ℤ} {nb ne : ℕ},
  Mathlib.Meta.NormNum.IsNat b nb → Mathlib.Meta.NormNum.IsNat (a ^ nb) ne → Mathlib.Meta.NormNum.IsNat (a ^ b) ne

theorem Mathlib.Meta.NormNum.isNat_zpow_neg E1 #

∀ {α : Type u_1} [inst : DivisionSemiring α] {a : α} {b : ℤ} {nb ne : ℕ},
  Mathlib.Meta.NormNum.IsInt b (Int.negOfNat nb) →
    Mathlib.Meta.NormNum.IsNat (a ^ nb)⁻¹ ne → Mathlib.Meta.NormNum.IsNat (a ^ b) ne

theorem Mathlib.Meta.NormNum.isInt_zpow_pos E1 #

∀ {α : Type u_1} [inst : DivisionRing α] {a : α} {b : ℤ} {nb ne : ℕ},
  Mathlib.Meta.NormNum.IsNat b nb →
    Mathlib.Meta.NormNum.IsInt (a ^ nb) (Int.negOfNat ne) → Mathlib.Meta.NormNum.IsInt (a ^ b) (Int.negOfNat ne)

theorem Mathlib.Meta.NormNum.isInt_zpow_neg E1 #

∀ {α : Type u_1} [inst : DivisionRing α] {a : α} {b : ℤ} {nb ne : ℕ},
  Mathlib.Meta.NormNum.IsInt b (Int.negOfNat nb) →
    Mathlib.Meta.NormNum.IsInt (a ^ nb)⁻¹ (Int.negOfNat ne) → Mathlib.Meta.NormNum.IsInt (a ^ b) (Int.negOfNat ne)

theorem Mathlib.Meta.NormNum.isNNRat_zpow_pos E1 #

∀ {α : Type u_1} [inst : DivisionSemiring α] {a : α} {b : ℤ} {nb num den : ℕ},
  Mathlib.Meta.NormNum.IsNat b nb →
    Mathlib.Meta.NormNum.IsNNRat (a ^ nb) num den → Mathlib.Meta.NormNum.IsNNRat (a ^ b) num den

theorem Mathlib.Meta.NormNum.isNNRat_zpow_neg E1 #

∀ {α : Type u_1} [inst : DivisionSemiring α] {a : α} {b : ℤ} {nb num den : ℕ},
  Mathlib.Meta.NormNum.IsInt b (Int.negOfNat nb) →
    Mathlib.Meta.NormNum.IsNNRat (a ^ nb)⁻¹ num den → Mathlib.Meta.NormNum.IsNNRat (a ^ b) num den

theorem Mathlib.Meta.NormNum.isRat_zpow_pos E1 #

∀ {α : Type u_1} [inst : DivisionRing α] {a : α} {b : ℤ} {nb : ℕ} {num : ℤ} {den : ℕ},
  Mathlib.Meta.NormNum.IsNat b nb →
    Mathlib.Meta.NormNum.IsRat (a ^ nb) num den → Mathlib.Meta.NormNum.IsRat (a ^ b) num den

theorem Mathlib.Meta.NormNum.isRat_zpow_neg E1 #

∀ {α : Type u_1} [inst : DivisionRing α] {a : α} {b : ℤ} {nb : ℕ} {num : ℤ} {den : ℕ},
  Mathlib.Meta.NormNum.IsInt b (Int.negOfNat nb) →
    Mathlib.Meta.NormNum.IsRat (a ^ nb)⁻¹ num den → Mathlib.Meta.NormNum.IsRat (a ^ b) num den

def Mathlib.Meta.NormNum.evalZPow E1 #

Mathlib.Meta.NormNum.NormNumExt

The norm_num extension which identifies expressions of the form a ^ b, such that norm_num successfully recognises both a and b, with b : ℤ.