File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/Lean/Meta/Tactic/Grind/Arith Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,18 @@ builtin_simproc_decl normIntCastNum (IntCast.intCast _) := fun e => do
168168 let h := mkApp4 (mkConst ``Grind.Ring.intCast_eq_ofNat_of_nonneg us) α ringInst a eagerReflBoolTrue
169169 return .done { expr := n, proof? := some h }
170170
171+ builtin_dsimproc [simp, seval] normPowRatInt ((_ : Rat) ^ (_ : Int)) := fun e => do
172+ let_expr HPow.hPow _ _ _ _ a b ← e | return .continue
173+ let some v₁ ← getRatValue? a | return .continue
174+ let some v₂ ← getIntValue? b | return .continue
175+ let warning := (← Simp.getConfig).warnExponents
176+ unless (← checkExponent v₂.natAbs (warning := warning)) do return .continue
177+ if v₂ < 0 then
178+ -- **Note** : we use `Rat.zpow_neg` as a normalization rule
179+ return .continue
180+ else
181+ return .done <| toExpr (v₁ ^ v₂)
182+
171183/-!
172184Add additional arithmetic simprocs
173185-/
@@ -193,6 +205,7 @@ def addSimproc (s : Simprocs) : CoreM Simprocs := do
193205 let s ← s.add ``normIntOfNatInst (post := false )
194206 let s ← s.add ``normNatCastNum (post := false )
195207 let s ← s.add ``normIntCastNum (post := false )
208+ let s ← s.add ``normPowRatInt (post := false )
196209 return s
197210
198211end Lean.Meta.Grind.Arith
Original file line number Diff line number Diff line change 1+ example : (2 / 3 : Rat) ≤ (0 .67 : Rat) := by grind
2+ example : (1 .2 : Rat) ≤ (1 .21 : Rat) := by grind
3+ example : (2 / 3 : Rat) ≤ (67 / 100 : Rat) := by grind
4+ example : (2 / 3 : Rat) ≤ (67 * 10 ^ (-2 ) : Rat) := by grind
5+ example : (2 / 3 : Rat) ≤ (67 / 10 ^ 2 : Rat) := by grind
6+ example : (2 / 3 : Rat) ≤ (67 / 10 ^ (2 :Int) : Rat) := by grind
7+ example : (1 .2345 : Rat) ≤ (1 .2346 : Rat) := by grind
8+ example : (1 .2345 : Rat) ≤ (1 .234501 : Rat) := by grind
9+ example : (2 .3 : Rat) ≤ (4 .5 : Rat) := by grind
10+ example : (2 .3 : Rat) ≤ (5 /2 : Rat) := by grind
You can’t perform that action at this time.
0 commit comments