norm_num
handling for expressions of the form a ^ b % m
. #
These expressions can often be evaluated efficiently in cases where first evaluating a ^ b
and
then reducing mod m
is not feasible. We provide a function evalNatPowMod
which is used by the
reduce_mod_char
tactic to efficiently evaluate powers in rings with positive characteristic.
The approach taken here is identical to (and copied from) the development in NormNum/Pow.lean
.
TODO #
- Adapt the
norm_num
extensions forNat.mod
andInt.emod
to efficiently evaluate expressions of the forma ^ b % m
usingevalNatPowMod
.
theorem
Mathlib.Meta.NormNum.IsNatPowModT.trans
{p : Prop}
{a b m c b' c' : ℕ}
(h1 : IsNatPowModT p a b m c)
(h2 : IsNatPowModT ((a.pow b).mod m = c) a b' m c')
:
IsNatPowModT p a b' m c'
partial def
Mathlib.Meta.NormNum.evalNatPowMod.go
(depth : ℕ)
(a m b₀ c₀ b : Q(ℕ))
(p : Q(Prop))
(hp : «$p» =Q ((«$a».pow «$b₀»).mod «$m» = «$c₀»))
:
(c : Q(ℕ)) × Q(IsNatPowModT «$p» «$a» «$b» «$m» «$c»)
Invariants: a ^ b₀ % m = c₀
, depth > 0
, b >>> depth = b₀