fact stringlengths 6 3.84k | type stringclasses 11
values | library stringclasses 32
values | imports listlengths 1 14 | filename stringlengths 20 95 | symbolic_name stringlengths 1 90 | docstring stringlengths 7 20k ⌀ |
|---|---|---|---|---|---|---|
private int_div_nonneg_of_nonneg_of_pos {a b : ℤ} (ha : 0 ≤ a) (hb : 0 < b) : 0 ≤ a / b :=
Int.ediv_nonneg ha hb.le | lemma | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | int_div_nonneg_of_nonneg_of_pos | null |
private int_div_nonneg_of_pos_of_pos {a b : ℤ} (ha : 0 < a) (hb : 0 < b) : 0 ≤ a / b :=
Int.ediv_nonneg ha.le hb.le | lemma | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | int_div_nonneg_of_pos_of_pos | null |
@[positivity (_ : ℤ) / (_ : ℤ)] evalIntDiv : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℤ), ~q($a / $b) =>
let ra ← core q(inferInstance) q(inferInstance) a
let rb ← core q(inferInstance) q(inferInstance) b
assertInstancesCommute
match ra, rb with
| .positive (pa : Q(0... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalIntDiv | The `positivity` extension which identifies expressions of the form `a / b`,
where `a` and `b` are integers. |
private pow_zero_pos [Semiring α] [PartialOrder α] [IsOrderedRing α] [Nontrivial α]
(a : α) : 0 < a ^ 0 :=
zero_lt_one.trans_le (pow_zero a).ge | theorem | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | pow_zero_pos | null |
@[positivity _ ^ (0 : ℕ)]
evalPowZeroNat : PositivityExt where eval {u α} _zα _pα e := do
let .app (.app _ (a : Q($α))) _ ← withReducible (whnf e) | throwError "not ^"
let _a ← synthInstanceQ q(Semiring $α)
let _a ← synthInstanceQ q(PartialOrder $α)
let _a ← synthInstanceQ q(IsOrderedRing $α)
_ ← synthInstanc... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalPowZeroNat | The `positivity` extension which identifies expressions of the form `a ^ (0 : ℕ)`.
This extension is run in addition to the general `a ^ b` extension (they are overlapping). |
@[positivity _ ^ (_ : ℕ)]
evalPow : PositivityExt where eval {u α} zα pα e := do
let .app (.app _ (a : Q($α))) (b : Q(ℕ)) ← withReducible (whnf e) | throwError "not ^"
let result ← catchNone do
let .true := b.isAppOfArity ``OfNat.ofNat 3 | throwError "not a ^ n where n is a literal"
let some n := (b.getRevA... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalPow | The `positivity` extension which identifies expressions of the form `a ^ (b : ℕ)`,
such that `positivity` successfully recognises both `a` and `b`. |
private abs_pos_of_ne_zero {α : Type*} [AddGroup α] [LinearOrder α]
[AddLeftMono α] {a : α} : a ≠ 0 → 0 < |a| := abs_pos.mpr | theorem | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | abs_pos_of_ne_zero | null |
@[positivity |_|]
evalAbs : PositivityExt where eval {_u} (α zα pα) (e : Q($α)) := do
let ~q(@abs _ (_) (_) $a) := e | throwError "not |·|"
try
match ← core zα pα a with
| .positive pa =>
let pa' ← mkAppM ``abs_pos_of_pos #[pa]
pure (.positive pa')
| .nonzero pa =>
let pa' ← mkAppM ``a... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalAbs | The `positivity` extension which identifies expressions of the form `|a|`. |
private int_natAbs_pos {n : ℤ} (hn : 0 < n) : 0 < n.natAbs :=
Int.natAbs_pos.mpr hn.ne' | theorem | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | int_natAbs_pos | null |
@[positivity Int.natAbs _]
evalNatAbs : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Int.natAbs $a) =>
let zα' : Q(Zero Int) := q(inferInstance)
let pα' : Q(PartialOrder Int) := q(inferInstance)
let ra ← core zα' pα' a
match ra with
| .positive pa =>
ass... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatAbs | Extension for the `positivity` tactic: `Int.natAbs` is positive when its input is.
Since the output type of `Int.natAbs` is `ℕ`, the nonnegative case is handled by the default
`positivity` tactic. |
@[positivity Nat.cast _]
evalNatCast : PositivityExt where eval {u α} _zα _pα e := do
let ~q(@Nat.cast _ (_) ($a : ℕ)) := e | throwError "not Nat.cast"
let zα' : Q(Zero Nat) := q(inferInstance)
let pα' : Q(PartialOrder Nat) := q(inferInstance)
let (_i1 : Q(AddMonoidWithOne $α)) ← synthInstanceQ q(AddMonoidWithO... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatCast | Extension for the `positivity` tactic: `Nat.cast` is always non-negative,
and positive when its input is. |
@[positivity Int.cast _]
evalIntCast : PositivityExt where eval {u α} _zα _pα e := do
let ~q(@Int.cast _ (_) ($a : ℤ)) := e | throwError "not Int.cast"
let zα' : Q(Zero Int) := q(inferInstance)
let pα' : Q(PartialOrder Int) := q(inferInstance)
let ra ← core zα' pα' a
match ra with
| .positive pa =>
let ... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalIntCast | Extension for the `positivity` tactic: `Int.cast` is positive (resp. non-negative)
if its input is. |
@[positivity Nat.succ _]
evalNatSucc : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.succ $a) =>
assertInstancesCommute
pure (.positive q(Nat.succ_pos $a))
| _, _, _ => throwError "not Nat.succ" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatSucc | Extension for `Nat.succ`. |
@[positivity PNat.val _]
evalPNatVal : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℕ), ~q(PNat.val $a) =>
assertInstancesCommute
pure (.positive q(PNat.pos $a))
| _, _, _ => throwError "not PNat.val" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalPNatVal | Extension for `PNat.val`. |
@[positivity Nat.factorial _]
evalFactorial : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.factorial $a) =>
assertInstancesCommute
pure (.positive q(Nat.factorial_pos $a))
| _, _, _ => throwError "failed to match Nat.factorial" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalFactorial | Extension for `Nat.factorial`. |
@[positivity Nat.ascFactorial _ _]
evalAscFactorial : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.ascFactorial ($n + 1) $k) =>
assertInstancesCommute
pure (.positive q(Nat.ascFactorial_pos $n $k))
| _, _, _ => throwError "failed to match Nat.ascFactorial" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalAscFactorial | Extension for `Nat.ascFactorial`. |
@[positivity Nat.gcd _ _]
evalNatGCD : PositivityExt where eval {u α} z p e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.gcd $a $b) =>
assertInstancesCommute
match ← core z p a with
| .positive pa => return .positive q(Nat.gcd_pos_of_pos_left $b $pa)
| _ =>
match ← core z p b with
| .posi... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatGCD | Extension for `Nat.gcd`.
Uses positivity of the left term, if available, then tries the right term.
The implementation relies on the fact that `Positivity.core` on `ℕ` never returns `nonzero`. |
@[positivity Nat.lcm _ _]
evalNatLCM : PositivityExt where eval {u α} z p e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.lcm $a $b) =>
assertInstancesCommute
match ← core z p a with
| .positive pa =>
match ← core z p b with
| .positive pb =>
return .positive q(Nat.lcm_pos $pa $pb)
... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatLCM | Extension for `Nat.lcm`. |
@[positivity Nat.sqrt _]
evalNatSqrt : PositivityExt where eval {u α} z p e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Nat.sqrt $n) =>
assumeInstancesCommute
match ← core z p n with
| .positive pa => return .positive q(Nat.sqrt_pos.mpr $pa)
| _ => failure
| _, _, _ => throwError "not Nat.sqrt" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNatSqrt | Extension for `Nat.sqrt`. |
@[positivity Int.gcd _ _]
evalIntGCD : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Int.gcd $a $b) =>
let z ← synthInstanceQ (q(Zero ℤ) : Q(Type))
let p ← synthInstanceQ (q(PartialOrder ℤ) : Q(Type))
assertInstancesCommute
match (← catchNone (core z p a)).toNonzero wi... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalIntGCD | Extension for `Int.gcd`.
Uses positivity of the left term, if available, then tries the right term. |
@[positivity Int.lcm _ _]
evalIntLCM : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Int.lcm $a $b) =>
let z ← synthInstanceQ (q(Zero ℤ) : Q(Type))
let p ← synthInstanceQ (q(PartialOrder ℤ) : Q(Type))
assertInstancesCommute
match (← core z p a).toNonzero with
| som... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalIntLCM | Extension for `Int.lcm`. |
@[positivity NNRat.num _]
evalNNRatNum : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(NNRat.num $a) =>
let zα : Q(Zero ℚ≥0) := q(inferInstance)
let pα : Q(PartialOrder ℚ≥0) := q(inferInstance)
assumeInstancesCommute
match ← core zα pα a with
| .positive pa => retu... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNNRatNum | The `positivity` extension which identifies expressions of the form `NNRat.num q`,
such that `positivity` successfully recognises `q`. |
@[positivity NNRat.den _]
evalNNRatDen : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(NNRat.den $a) =>
assumeInstancesCommute
return .positive q(den_pos $a)
| _, _, _ => throwError "not NNRat.den"
variable {q : ℚ≥0} | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNNRatDen | The `positivity` extension which identifies expressions of the form `Rat.den a`. |
@[positivity Rat.num _]
evalRatNum : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℤ), ~q(Rat.num $a) =>
let zα : Q(Zero ℚ) := q(inferInstance)
let pα : Q(PartialOrder ℚ) := q(inferInstance)
assumeInstancesCommute
match ← core zα pα a with
| .positive pa => pure <| .posit... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalRatNum | The `positivity` extension which identifies expressions of the form `Rat.num a`,
such that `positivity` successfully recognises `a`. |
@[positivity Rat.den _]
evalRatDen : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Rat.den $a) =>
assumeInstancesCommute
pure <| .positive q(den_pos $a)
| _, _ => throwError "not Rat.num" | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalRatDen | The `positivity` extension which identifies expressions of the form `Rat.den a`. |
@[positivity _⁺]
evalPosPart : PositivityExt where eval {u α} zα pα e := do
match e with
| ~q(@posPart _ $instαpospart $a) =>
let _instαlat ← synthInstanceQ q(Lattice $α)
let _instαgrp ← synthInstanceQ q(AddGroup $α)
assertInstancesCommute
match ← catchNone (core zα pα a) with
| .positive pf => ... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalPosPart | Extension for `posPart`. `a⁺` is always nonnegative, and positive if `a` is. |
@[positivity _⁻]
evalNegPart : PositivityExt where eval {u α} _ _ e := do
match e with
| ~q(@negPart _ $instαnegpart $a) =>
let _instαlat ← synthInstanceQ q(Lattice $α)
let _instαgrp ← synthInstanceQ q(AddGroup $α)
assertInstancesCommute
return .nonnegative q(negPart_nonneg $a)
| _ => throwError "... | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalNegPart | Extension for `negPart`. `a⁻` is always nonnegative. |
@[positivity DFunLike.coe _ _]
evalMap : PositivityExt where eval {_ β} _ _ e := do
let .app (.app _ f) a ← whnfR e
| throwError "not ↑f · where f is of NonnegHomClass"
let pa ← mkAppOptM ``apply_nonneg #[none, none, β, none, none, none, none, f, a]
pure (.nonnegative pa) | def | Tactic | [
"Mathlib.Algebra.Order.Group.PosPart",
"Mathlib.Algebra.Order.Ring.Basic",
"Mathlib.Algebra.Order.Hom.Basic",
"Mathlib.Data.Int.CharZero",
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Data.NNRat.Defs",
"Mathlib.Data.PNat.Defs",
"Mathlib.Tactic.Positivity.Core",
"Qq"
] | Mathlib/Tactic/Positivity/Basic.lean | evalMap | Extension for the `positivity` tactic: nonnegative maps take nonnegative values. |
Strictness (e : Q($α)) where
| positive (pf : Q(0 < $e))
| nonnegative (pf : Q(0 ≤ $e))
| nonzero (pf : Q($e ≠ 0))
| none
deriving Repr | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Strictness | Attribute for identifying `positivity` extensions. -/
syntax (name := positivity) "positivity " term,+ : attr
lemma ne_of_ne_of_eq' {α : Sort*} {a c b : α} (hab : (a : α) ≠ c) (hbc : a = b) : b ≠ c := hbc ▸ hab
namespace Mathlib.Meta.Positivity
variable {u : Level} {α : Q(Type u)} (zα : Q(Zero $α)) (pα : Q(PartialOr... |
Strictness.toString {e : Q($α)} : Strictness zα pα e → String
| positive _ => "positive"
| nonnegative _ => "nonnegative"
| nonzero _ => "nonzero"
| none => "none" | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Strictness.toString | Gives a generic description of the `positivity` result. |
Strictness.toPositive {e} : Strictness zα pα e → Option Q(0 < $e)
| .positive pf => some pf
| _ => .none | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Strictness.toPositive | Extract a proof that `e` is positive, if possible, from `Strictness` information about `e`. |
Strictness.toNonneg {e} : Strictness zα pα e → Option Q(0 ≤ $e)
| .positive pf => some q(le_of_lt $pf)
| .nonnegative pf => some pf
| _ => .none | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Strictness.toNonneg | Extract a proof that `e` is nonnegative, if possible, from `Strictness` information about `e`. |
Strictness.toNonzero {e} : Strictness zα pα e → Option Q($e ≠ 0)
| .positive pf => some q(ne_of_gt $pf)
| .nonzero pf => some pf
| _ => .none | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Strictness.toNonzero | Extract a proof that `e` is nonzero, if possible, from `Strictness` information about `e`. |
PositivityExt where
/-- Attempts to prove an expression `e : α` is `>0`, `≥0`, or `≠0`. -/
eval {u : Level} {α : Q(Type u)} (zα : Q(Zero $α)) (pα : Q(PartialOrder $α)) (e : Q($α)) :
MetaM (Strictness zα pα e) | structure | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | PositivityExt | An extension for `positivity`. |
mkPositivityExt (n : Name) : ImportM PositivityExt := do
let { env, opts, .. } ← read
IO.ofExcept <| unsafe env.evalConstCheck PositivityExt opts ``PositivityExt n | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | mkPositivityExt | Read a `positivity` extension from a declaration of the right type. |
Entry := Array (Array DiscrTree.Key) × Name | abbrev | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | Entry | Each `positivity` extension is labelled with a collection of patterns
which determine the expressions to which it should be applied. |
catchNone {e : Q($α)} (t : MetaM (Strictness zα pα e)) : MetaM (Strictness zα pα e) :=
try t catch e =>
trace[Tactic.positivity.failure] "{e.toMessageData}"
pure .none
variable {zα pα} in | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | catchNone | Environment extensions for `positivity` declarations -/
initialize positivityExt : PersistentEnvExtension Entry (Entry × PositivityExt)
(List Entry × DiscrTree PositivityExt) ←
-- we only need this to deduplicate entries in the DiscrTree
have : BEq PositivityExt := ⟨fun _ _ => false⟩
let insert kss v dt := ks... |
throwNone {m : Type → Type*} {e : Q($α)} [Monad m] [Alternative m]
(t : m (Strictness zα pα e)) : m (Strictness zα pα e) := do
match ← t with
| .none => failure
| r => pure r | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | throwNone | Converts a `MetaM Strictness` which can return `.none`
into one which never returns `.none` but fails instead. |
normNumPositivity (e : Q($α)) : MetaM (Strictness zα pα e) := catchNone do
match ← NormNum.derive e with
| .isBool .. => failure
| .isNat _ lit p =>
if 0 < lit.natLit! then
try
let _a ← synthInstanceQ q(Semiring $α)
let _a ← synthInstanceQ q(PartialOrder $α)
let _a ← synthInstanc... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | normNumPositivity | Attempts to prove a `Strictness` result when `e` evaluates to a literal number. |
positivityCanon (e : Q($α)) : MetaM (Strictness zα pα e) := do
let _add ← synthInstanceQ q(AddMonoid $α)
let _le ← synthInstanceQ q(PartialOrder $α)
let _i ← synthInstanceQ q(CanonicallyOrderedAdd $α)
assumeInstancesCommute
pure (.nonnegative q(zero_le $e)) | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | positivityCanon | Attempts to prove that `e ≥ 0` using `zero_le` in a `CanonicallyOrderedAdd` monoid. |
compareHypLE (lo e : Q($α)) (p₂ : Q($lo ≤ $e)) : MetaM (Strictness zα pα e) := do
match ← normNumPositivity zα pα lo with
| .positive p₁ => pure (.positive q(lt_of_lt_of_le $p₁ $p₂))
| .nonnegative p₁ => pure (.nonnegative q(le_trans $p₁ $p₂))
| _ => pure .none | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | compareHypLE | A variation on `assumption` when the hypothesis is `lo ≤ e` where `lo` is a numeral. |
compareHypLT (lo e : Q($α)) (p₂ : Q($lo < $e)) : MetaM (Strictness zα pα e) := do
match ← normNumPositivity zα pα lo with
| .positive p₁ => pure (.positive q(lt_trans $p₁ $p₂))
| .nonnegative p₁ => pure (.positive q(lt_of_le_of_lt $p₁ $p₂))
| _ => pure .none | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | compareHypLT | A variation on `assumption` when the hypothesis is `lo < e` where `lo` is a numeral. |
compareHypEq (e x : Q($α)) (p₂ : Q($x = $e)) : MetaM (Strictness zα pα e) := do
match ← normNumPositivity zα pα x with
| .positive p₁ => pure (.positive q(lt_of_lt_of_eq $p₁ $p₂))
| .nonnegative p₁ => pure (.nonnegative q(le_of_le_of_eq $p₁ $p₂))
| .nonzero p₁ => pure (.nonzero q(ne_of_ne_of_eq' $p₁ $p₂))
| .... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | compareHypEq | A variation on `assumption` when the hypothesis is `x = e` where `x` is a numeral. |
compareHyp (e : Q($α)) (ldecl : LocalDecl) : MetaM (Strictness zα pα e) := do
have e' : Q(Prop) := ldecl.type
let p : Q($e') := .fvar ldecl.fvarId
match e' with
| ~q(@LE.le.{u} $β $_le $lo $hi) =>
let .defEq (_ : $α =Q $β) ← isDefEqQ α β | return .none
let .defEq _ ← isDefEqQ e hi | return .none
mat... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | compareHyp | A variation on `assumption` which checks if the hypothesis `ldecl` is `a [</≤/=] e`
where `a` is a numeral. |
orElse {e : Q($α)} (t₁ : Strictness zα pα e) (t₂ : MetaM (Strictness zα pα e)) :
MetaM (Strictness zα pα e) := do
match t₁ with
| .none => catchNone t₂
| p@(.positive _) => pure p
| .nonnegative p₁ =>
match ← catchNone t₂ with
| p@(.positive _) => pure p
| .nonzero p₂ => pure (.positive q(lt_of_... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | orElse | The main combinator which combines multiple `positivity` results.
It assumes `t₁` has already been run for a result, and runs `t₂` and takes the best result.
It will skip `t₂` if `t₁` is already a proof of `.positive`, and can also combine
`.nonnegative` and `.nonzero` to produce a `.positive` result. |
core (e : Q($α)) : MetaM (Strictness zα pα e) := do
let mut result := .none
trace[Tactic.positivity] "trying to prove positivity of {e}"
for ext in ← (positivityExt.getState (← getEnv)).2.getMatch e do
try
result ← orElse result <| ext.eval zα pα e
catch err =>
trace[Tactic.positivity] "{e} fa... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | core | Run each registered `positivity` extension on an expression, returning a `NormNum.Result`. |
private OrderRel : Type
| le : OrderRel -- `0 ≤ a`
| lt : OrderRel -- `0 < a`
| ne : OrderRel -- `a ≠ 0`
| ne' : OrderRel -- `0 ≠ a` | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | OrderRel | null |
bestResult (e : Expr) : MetaM (Bool × Expr) := do
let ⟨u, α, _⟩ ← inferTypeQ' e
let zα ← synthInstanceQ q(Zero $α)
let pα ← synthInstanceQ q(PartialOrder $α)
match ← try? (Meta.Positivity.core zα pα e) with
| some (.positive pf) => pure (true, pf)
| some (.nonnegative pf) => pure (false, pf)
| _ => throwE... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | bestResult | Given an expression `e`, use the core method of the `positivity` tactic to prove it positive,
or, failing that, nonnegative; return a Boolean (signalling whether the strict or non-strict
inequality was established) together with the proof as an expression. |
proveNonneg (e : Expr) : MetaM Expr := do
let (strict, pf) ← bestResult e
if strict then mkAppM ``le_of_lt #[pf] else pure pf | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | proveNonneg | Given an expression `e`, use the core method of the `positivity` tactic to prove it nonnegative. |
solve (t : Q(Prop)) : MetaM Expr := do
let rest {u : Level} (α : Q(Type u)) z e (relDesired : OrderRel) : MetaM Expr := do
let zα ← synthInstanceQ q(Zero $α)
assumeInstancesCommute
let .true ← isDefEq z q(0 : $α) | throwError "not a positivity goal"
let pα ← synthInstanceQ q(PartialOrder $α)
assum... | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | solve | An auxiliary entry point to the `positivity` tactic. Given a proposition `t` of the form
`0 [≤/</≠] e`, attempts to recurse on the structure of `t` to prove it. It returns a proof
or fails. |
positivity (goal : MVarId) : MetaM Unit := do
let t : Q(Prop) ← withReducible goal.getType'
let p ← solve t
goal.assign p | def | Tactic | [
"Mathlib.Tactic.NormNum.Core",
"Mathlib.Tactic.HaveI",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Ring.Cast",
"Mathlib.Control.Basic",
"Mathlib.Data.Nat.Cast.Basic",
"Qq"
] | Mathlib/Tactic/Positivity/Core.lean | positivity | The main entry point to the `positivity` tactic. Given a goal `goal` of the form `0 [≤/</≠] e`,
attempts to recurse on the structure of `e` to prove the goal.
It will either close `goal` or fail. |
@[positivity Finset.card _]
evalFinsetCard : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(Finset.card $s) =>
let some ps ← proveFinsetNonempty s | return .none
assertInstancesCommute
return .positive q(Finset.Nonempty.card_pos $ps)
| _ => throwError "not Finset.card" | def | Tactic | [
"Mathlib.Algebra.Order.BigOperators.Group.Finset",
"Mathlib.Data.Finset.Density",
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Tactic.Positivity.Core"
] | Mathlib/Tactic/Positivity/Finset.lean | evalFinsetCard | Extension for `Finset.card`. `#s` is positive if `s` is nonempty.
It calls `Mathlib.Meta.proveFinsetNonempty` to attempt proving that the finset is nonempty. |
@[positivity Fintype.card _]
evalFintypeCard : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℕ), ~q(@Fintype.card $β $instβ) =>
let instβno ← synthInstanceQ q(Nonempty $β)
assumeInstancesCommute
return .positive q(@Fintype.card_pos $β $instβ $instβno)
| _ => throwError "not Fin... | def | Tactic | [
"Mathlib.Algebra.Order.BigOperators.Group.Finset",
"Mathlib.Data.Finset.Density",
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Tactic.Positivity.Core"
] | Mathlib/Tactic/Positivity/Finset.lean | evalFintypeCard | Extension for `Fintype.card`. `Fintype.card α` is positive if `α` is nonempty. |
@[positivity Finset.dens _]
evalFinsetDens : PositivityExt where eval {u 𝕜} _ _ e := do
match u, 𝕜, e with
| 0, ~q(ℚ≥0), ~q(@Finset.dens $α $instα $s) =>
let some ps ← proveFinsetNonempty s | return .none
assumeInstancesCommute
return .positive q(@Nonempty.dens_pos $α $instα $s $ps)
| _, _, _ => thr... | def | Tactic | [
"Mathlib.Algebra.Order.BigOperators.Group.Finset",
"Mathlib.Data.Finset.Density",
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Tactic.Positivity.Core"
] | Mathlib/Tactic/Positivity/Finset.lean | evalFinsetDens | Extension for `Finset.dens`. `s.dens` is positive if `s` is nonempty.
It calls `Mathlib.Meta.proveFinsetNonempty` to attempt proving that the finset is nonempty. |
@[positivity Finset.sum _ _]
evalFinsetSum : PositivityExt where eval {u α} zα pα e := do
match e with
| ~q(@Finset.sum $ι _ $instα $s $f) =>
let i : Q($ι) ← mkFreshExprMVarQ q($ι) .syntheticOpaque
have body : Q($α) := .betaRev f #[i]
let rbody ← core zα pα body
let p_pos : Option Q(0 < $e) := ← (do... | def | Tactic | [
"Mathlib.Algebra.Order.BigOperators.Group.Finset",
"Mathlib.Data.Finset.Density",
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Tactic.Positivity.Core"
] | Mathlib/Tactic/Positivity/Finset.lean | evalFinsetSum | The `positivity` extension which proves that `∑ i ∈ s, f i` is nonnegative if `f` is, and
positive if each `f i` is and `s` is nonempty.
TODO: The following example does not work
```
example (s : Finset ℕ) (f : ℕ → ℤ) (hf : ∀ n, 0 ≤ f n) : 0 ≤ s.sum f := by positivity
```
because `compareHyp` can't look for assumption... |
Head where
| const (c : Name)
| lambda
| forall
deriving Inhabited, BEq | inductive | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | Head | The type for a constant to be pushed by `push`. |
Head.toString : Head → String
| .const c => c.toString
| .lambda => "fun"
| .forall => "Forall" | def | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | Head.toString | Converts a `Head` to a string. |
Head.ofExpr? : Expr → Option Head
| .app f _ => f.getAppFn.constName?.map .const
| .lam .. => some .lambda
| .forallE .. => some .forall
| _ => none | def | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | Head.ofExpr | Returns the head of an expression. |
isPullThm (declName : Name) (inv : Bool) : MetaM (Option Head) := do
let cinfo ← getConstInfo declName
forallTelescope cinfo.type fun _ type => do
let some (lhs, rhs) := type.eqOrIff? | return none
let (lhs, rhs) := if inv then (rhs, lhs) else (lhs, rhs)
let some head := Head.ofExpr? rhs | return none
... | def | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | isPullThm | The `push` environment extension -/
initialize pushExt : SimpleScopedEnvExtension SimpTheorem (DiscrTree SimpTheorem) ←
registerSimpleScopedEnvExtension {
initial := {}
addEntry := fun d e => d.insertCore e.keys e
}
/--
Checks if the theorem is suitable for the `pull` tactic. That is,
check if it is of th... |
PullTheorem := SimpTheorem × Head | abbrev | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | PullTheorem | A theorem for the `pull` tactic |
@[push] log_mul (hx : x ≠ 0) (hy : y ≠ 0) : log (x * y) = log x + log y
@[push] theorem log_abs : log |x| = log x
@[push] theorem not_imp (p q : Prop) : ¬(p → q) ↔ p ∧ ¬q
@[push] theorem not_iff (p q : Prop) : ¬(p ↔ q) ↔ (p ∧ ¬q) ∨ (¬p ∧ q)
@[push] theorem not_not (p : Prop) : ¬ ¬p ↔ p
@[push] theorem not_le : ¬a ≤ b ↔... | theorem | Tactic | [
"Mathlib.Lean.Expr.Basic"
] | Mathlib/Tactic/Push/Attr.lean | log_mul | null |
rflTac : TacticM Unit :=
withMainContext do liftMetaFinishingTactic (·.applyRfl) | def | Tactic | [
"Mathlib.Init",
"Lean.Meta.Tactic.Rfl"
] | Mathlib/Tactic/Relation/Rfl.lean | rflTac | This tactic applies to a goal whose target has the form `x ~ x`, where `~` is a reflexive
relation, that is, a relation which has a reflexive lemma tagged with the attribute [refl]. |
_root_.Lean.Expr.relSidesIfRefl? (e : Expr) : MetaM (Option (Name × Expr × Expr)) := do
if let some (_, lhs, rhs) := e.eq? then
return (``Eq, lhs, rhs)
if let some (lhs, rhs) := e.iff? then
return (``Iff, lhs, rhs)
if let some (_, lhs, _, rhs) := e.heq? then
return (``HEq, lhs, rhs)
if let .app (.ap... | def | Tactic | [
"Mathlib.Init",
"Lean.Meta.Tactic.Rfl"
] | Mathlib/Tactic/Relation/Rfl.lean | _root_.Lean.Expr.relSidesIfRefl | If `e` is the form `@R .. x y`, where `R` is a reflexive
relation, return `some (R, x, y)`.
As a special case, if `e` is `@HEq α a β b`, return ``some (`HEq, a, b)``. |
_root_.Lean.Expr.relSidesIfSymm? (e : Expr) : MetaM (Option (Name × Expr × Expr)) := do
if let some (_, lhs, rhs) := e.eq? then
return (``Eq, lhs, rhs)
if let some (lhs, rhs) := e.iff? then
return (``Iff, lhs, rhs)
if let some (_, lhs, _, rhs) := e.heq? then
return (``HEq, lhs, rhs)
if let .app (.ap... | def | Tactic | [
"Mathlib.Init",
"Lean.Meta.Tactic.Symm"
] | Mathlib/Tactic/Relation/Symm.lean | _root_.Lean.Expr.relSidesIfSymm | If `e` is the form `@R .. x y`, where `R` is a symmetric
relation, return `some (R, x, y)`.
As a special case, if `e` is `@HEq α a β b`, return ``some (`HEq, a, b)``. |
instCommSemiringNat : CommSemiring ℕ := inferInstance | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | instCommSemiringNat | A shortcut instance for `CommSemiring ℕ` used by ring. |
instCommSemiringInt : CommSemiring ℤ := inferInstance | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | instCommSemiringInt | A shortcut instance for `CommSemiring ℤ` used by ring. |
sℕ : Q(CommSemiring ℕ) := q(instCommSemiringNat) | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | sℕ | A typed expression of type `CommSemiring ℕ` used when we are working on
ring subexpressions of type `ℕ`. |
sℤ : Q(CommSemiring ℤ) := q(instCommSemiringInt)
mutual | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | sℤ | A typed expression of type `CommSemiring ℤ` used when we are working on
ring subexpressions of type `ℤ`. |
ExBase : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/--
An atomic expression `e` with id `id`.
Atomic expressions are those which `ring` cannot parse any further.
For instance, `a + (a % b)` has `a` and `(a % b)` as atoms.
The `ring1` tactic does not normalize the subexpressio... | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExBase | The base `e` of a normalized exponent expression. |
ExProd : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/-- A coefficient `value`, which must not be `0`. `e` is a raw rat cast.
If `value` is not an integer, then `hyp` should be a proof of `(value.den : α) ≠ 0`. -/
| const {sα} {e} (value : ℚ) (hyp : Option Expr := none) : ExProd sα... | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd | A monomial, which is a product of powers of `ExBase` expressions,
terminated by a (nonzero) constant coefficient. |
ExSum : ∀ {u : Lean.Level} {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
/-- Zero is a polynomial. `e` is the expression `0`. -/
| zero {u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} : ExSum sα q(0 : $α)
/-- A sum `a + b` is a polynomial if `a` is a monomial and `b` is another polynomial. -... | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExSum | A polynomial expression, which is a sum of monomials. |
partial ExBase.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExBase sα a → ExBase sα b → Bool
| .atom i, .atom j => i == j
| .sum a, .sum b => a.eq b
| _, _ => false
@[inherit_doc ExBase.eq] | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExBase.eq | Equality test for expressions. This is not a `BEq` instance because it is heterogeneous. |
partial ExProd.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExProd sα b → Bool
| .const i _, .const j _ => i == j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => a₁.eq b₁ && a₂.eq b₂ && a₃.eq b₃
| _, _ => false
@[inherit_doc ExBase.eq] | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.eq | null |
partial ExSum.eq
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExSum sα a → ExSum sα b → Bool
| .zero, .zero => true
| .add a₁ a₂, .add b₁ b₂ => a₁.eq b₁ && a₂.eq b₂
| _, _ => false | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExSum.eq | null |
partial ExBase.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExBase sα a → ExBase sα b → Ordering
| .atom i, .atom j => compare i j
| .sum a, .sum b => a.cmp b
| .atom .., .sum .. => .lt
| .sum .., .atom .. => .gt
@[inherit_doc ExBase.cmp] | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExBase.cmp | A total order on normalized expressions.
This is not an `Ord` instance because it is heterogeneous. |
partial ExProd.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExProd sα b → Ordering
| .const i _, .const j _ => compare i j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => (a₁.cmp b₁).then (a₂.cmp b₂) |>.then (a₃.cmp b₃)
| .const _ _, .mul .. => .lt
| .mul .., .const _ _... | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.cmp | null |
partial ExSum.cmp
{u : Lean.Level} {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExSum sα a → ExSum sα b → Ordering
| .zero, .zero => .eq
| .add a₁ a₂, .add b₁ b₂ => (a₁.cmp b₁).then (a₂.cmp b₂)
| .zero, .add .. => .lt
| .add .., .zero => .gt | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExSum.cmp | null |
partial ExBase.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExBase sα a → Σ a, ExBase sβ a
| .atom i => ⟨a, .atom i⟩
| .sum a => let ⟨_, vb⟩ := a.cast; ⟨_, .sum vb⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExBase.cast | Converts `ExBase sα` to `ExBase sβ`, assuming `sα` and `sβ` are defeq. |
partial ExProd.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExProd sα a → Σ a, ExProd sβ a
| .const i h => ⟨a, .const i h⟩
| .mul a₁ a₂ a₃ => ⟨_, .mul a₁.cast.2 a₂ a₃.cast.2⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.cast | Converts `ExProd sα` to `ExProd sβ`, assuming `sα` and `sβ` are defeq. |
partial ExSum.cast
{v : Lean.Level} {β : Q(Type v)} {sβ : Q(CommSemiring $β)} {a : Q($α)} :
ExSum sα a → Σ a, ExSum sβ a
| .zero => ⟨_, .zero⟩
| .add a₁ a₂ => ⟨_, .add a₁.cast.2 a₂.cast.2⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExSum.cast | Converts `ExSum sα` to `ExSum sβ`, assuming `sα` and `sβ` are defeq. |
Result {α : Q(Type u)} (E : Q($α) → Type) (e : Q($α)) where
/-- The normalized result. -/
expr : Q($α)
/-- The data associated to the normalization. -/
val : E expr
/-- A proof that the original expression is equal to the normalized result. -/
proof : Q($e = $expr) | structure | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | Result | The result of evaluating an (unnormalized) expression `e` into the type family `E`
(one of `ExSum`, `ExProd`, `ExBase`) is a (normalized) element `e'`
and a representation `E e'` for it, and a proof of `e = e'`. |
ExProd.mkNat (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q(($lit).rawCast : $α), .const n none⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.mkNat | Constructs the expression corresponding to `.const n`.
(The `.const` constructor does not check that the expression is correct.) |
ExProd.mkNegNat (_ : Q(Ring $α)) (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q((Int.negOfNat $lit).rawCast : $α), .const (-n) none⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.mkNegNat | Constructs the expression corresponding to `.const (-n)`.
(The `.const` constructor does not check that the expression is correct.) |
ExProd.mkNNRat (_ : Q(DivisionSemiring $α)) (q : ℚ) (n : Q(ℕ)) (d : Q(ℕ)) (h : Expr) :
(e : Q($α)) × ExProd sα e :=
⟨q(NNRat.rawCast $n $d : $α), .const q h⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.mkNNRat | Constructs the expression corresponding to `.const q h` for `q = n / d`
and `h` a proof that `(d : α) ≠ 0`.
(The `.const` constructor does not check that the expression is correct.) |
ExProd.mkNegNNRat (_ : Q(DivisionRing $α)) (q : ℚ) (n : Q(ℕ)) (d : Q(ℕ)) (h : Expr) :
(e : Q($α)) × ExProd sα e :=
⟨q(Rat.rawCast (.negOfNat $n) $d : $α), .const q h⟩ | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.mkNegNNRat | Constructs the expression corresponding to `.const q h` for `q = -(n / d)`
and `h` a proof that `(d : α) ≠ 0`.
(The `.const` constructor does not check that the expression is correct.) |
ExBase.toProd {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a : Q($α)} {b : Q(ℕ)}
(va : ExBase sα a) (vb : ExProd sℕ b) :
ExProd sα q($a ^ $b * (nat_lit 1).rawCast) := .mul va vb (.const 1 none) | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExBase.toProd | Embed an exponent (an `ExBase, ExProd` pair) as an `ExProd` by multiplying by 1. |
ExProd.toSum {sα : Q(CommSemiring $α)} {e : Q($α)} (v : ExProd sα e) : ExSum sα q($e + 0) :=
.add v .zero | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.toSum | Embed `ExProd` in `ExSum` by adding 0. |
ExProd.coeff {sα : Q(CommSemiring $α)} {e : Q($α)} : ExProd sα e → ℚ
| .const q _ => q
| .mul _ _ v => v.coeff | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | ExProd.coeff | Get the leading coefficient of an `ExProd`. |
Overlap (e : Q($α)) where
/-- The expression `e` (the sum of monomials) is equal to `0`. -/
| zero (_ : Q(IsNat $e (nat_lit 0)))
/-- The expression `e` (the sum of monomials) is equal to another monomial
(with nonzero leading coefficient). -/
| nonzero (_ : Result (ExProd sα) e)
variable {a a' a₁ a₂ a₃ b b' b... | inductive | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | Overlap | Two monomials are said to "overlap" if they differ by a constant factor, in which case the
constants just add. When this happens, the constant may be either zero (if the monomials cancel)
or nonzero (if they add up); the zero case is handled specially. |
add_overlap_pf (x : R) (e) (pq_pf : a + b = c) :
x ^ e * a + x ^ e * b = x ^ e * c := by subst_vars; simp [mul_add] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_overlap_pf | null |
add_overlap_pf_zero (x : R) (e) :
IsNat (a + b) (nat_lit 0) → IsNat (x ^ e * a + x ^ e * b) (nat_lit 0)
| ⟨h⟩ => ⟨by simp [h, ← mul_add]⟩
private local instance {m} [Pure m] : MonadLift Option (OptionT m) where
monadLift f := .mk <| pure f | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_overlap_pf_zero | null |
evalAddOverlap {a b : Q($α)} (va : ExProd sα a) (vb : ExProd sα b) :
OptionT MetaM (Overlap sα q($a + $b)) := do
Lean.Core.checkSystem decl_name%.toString
match va, vb with
| .const za ha, .const zb hb => do
let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb
let res ← ra.add rb
m... | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | evalAddOverlap | Given monomials `va, vb`, attempts to add them together to get another monomial.
If the monomials are not compatible, returns `none`.
For example, `xy + 2xy = 3xy` is a `.nonzero` overlap, while `xy + xz` returns `none`
and `xy + -xy = 0` is a `.zero` overlap. |
add_pf_zero_add (b : R) : 0 + b = b := by simp | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_zero_add | null |
add_pf_add_zero (a : R) : a + 0 = a := by simp | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_add_zero | null |
add_pf_add_overlap
(_ : a₁ + b₁ = c₁) (_ : a₂ + b₂ = c₂) : (a₁ + a₂ : R) + (b₁ + b₂) = c₁ + c₂ := by
subst_vars; simp [add_assoc, add_left_comm] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_add_overlap | null |
add_pf_add_overlap_zero
(h : IsNat (a₁ + b₁) (nat_lit 0)) (h₄ : a₂ + b₂ = c) : (a₁ + a₂ : R) + (b₁ + b₂) = c := by
subst_vars; rw [add_add_add_comm, h.1, Nat.cast_zero, add_pf_zero_add] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_add_overlap_zero | null |
add_pf_add_lt (a₁ : R) (_ : a₂ + b = c) : (a₁ + a₂) + b = a₁ + c := by simp [*, add_assoc] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_add_lt | null |
add_pf_add_gt (b₁ : R) (_ : a + b₂ = c) : a + (b₁ + b₂) = b₁ + c := by
subst_vars; simp [add_left_comm] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | add_pf_add_gt | null |
partial evalAdd {a b : Q($α)} (va : ExSum sα a) (vb : ExSum sα b) :
MetaM <| Result (ExSum sα) q($a + $b) := do
Lean.Core.checkSystem decl_name%.toString
match va, vb with
| .zero, vb => return ⟨b, vb, q(add_pf_zero_add $b)⟩
| va, .zero => return ⟨a, va, q(add_pf_add_zero $a)⟩
| .add (a := a₁) (b := _a₂) ... | def | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | evalAdd | Adds two polynomials `va, vb` together to get a normalized result polynomial.
* `0 + b = b`
* `a + 0 = a`
* `a * x + a * y = a * (x + y)` (for `x`, `y` coefficients; uses `evalAddOverlap`)
* `(a₁ + a₂) + (b₁ + b₂) = a₁ + (a₂ + (b₁ + b₂))` (if `a₁.lt b₁`)
* `(a₁ + a₂) + (b₁ + b₂) = b₁ + ((a₁ + a₂) + b₂)` (if not `a₁.lt... |
one_mul (a : R) : (nat_lit 1).rawCast * a = a := by simp [Nat.rawCast] | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Inv",
"Mathlib.Tactic.NormNum.Pow",
"Mathlib.Util.AtomM"
] | Mathlib/Tactic/Ring/Basic.lean | one_mul | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.