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 ⌀ |
|---|---|---|---|---|---|---|
isNat_lt_true [Semiring α] [PartialOrder α] [IsOrderedRing α] [CharZero α] :
{a b : α} → {a' b' : ℕ} →
IsNat a a' → IsNat b b' → Nat.ble b' a' = false → a < b
| _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, h =>
Nat.cast_lt.2 <| ble_eq_false.1 h | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isNat_lt_true | null |
isNat_le_false [Semiring α] [PartialOrder α] [IsOrderedRing α] [CharZero α]
{a b : α} {a' b' : ℕ}
(ha : IsNat a a') (hb : IsNat b b') (h : Nat.ble a' b' = false) : ¬a ≤ b :=
not_le_of_gt (isNat_lt_true hb ha h) | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isNat_le_false | null |
isInt_le_true [Ring α] [PartialOrder α] [IsOrderedRing α] : {a b : α} → {a' b' : ℤ} →
IsInt a a' → IsInt b b' → decide (a' ≤ b') → a ≤ b
| _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, h => Int.cast_mono <| of_decide_eq_true h | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isInt_le_true | null |
isInt_lt_true [Ring α] [PartialOrder α] [IsOrderedRing α] [Nontrivial α] :
{a b : α} → {a' b' : ℤ} →
IsInt a a' → IsInt b b' → decide (a' < b') → a < b
| _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, h => Int.cast_lt.2 <| of_decide_eq_true h | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isInt_lt_true | null |
isInt_le_false [Ring α] [PartialOrder α] [IsOrderedRing α] [Nontrivial α]
{a b : α} {a' b' : ℤ}
(ha : IsInt a a') (hb : IsInt b b') (h : decide (b' < a')) : ¬a ≤ b :=
not_le_of_gt (isInt_lt_true hb ha h) | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isInt_le_false | null |
isInt_lt_false [Ring α] [PartialOrder α] [IsOrderedRing α] {a b : α} {a' b' : ℤ}
(ha : IsInt a a') (hb : IsInt b b') (h : decide (b' ≤ a')) : ¬a < b :=
not_lt_of_ge (isInt_le_true hb ha h)
attribute [local instance] monadLiftOptionMetaM in | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | isInt_lt_false | null |
@[norm_num _ ≤ _] evalLE : NormNumExt where eval {v β} e := do
haveI' : v =QL 0 := ⟨⟩; haveI' : $β =Q Prop := ⟨⟩
let .app (.app f a) b ← whnfR e | failure
let ⟨u, α, a⟩ ← inferTypeQ' a
have b : Q($α) := b
let ra ← derive a; let rb ← derive b
let lα ← synthInstanceQ q(LE $α)
guard <|← withNewMCtxDepth <| i... | def | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | evalLE | The `norm_num` extension which identifies expressions of the form `a ≤ b`,
such that `norm_num` successfully recognises both `a` and `b`. |
@[norm_num _ < _] evalLT : NormNumExt where eval {v β} e := do
haveI' : v =QL 0 := ⟨⟩; haveI' : $β =Q Prop := ⟨⟩
let .app (.app f a) b ← whnfR e | failure
let ⟨u, α, a⟩ ← inferTypeQ' a
have b : Q($α) := b
let ra ← derive a; let rb ← derive b
let lα ← synthInstanceQ q(LT $α)
guard <|← withNewMCtxDepth <| i... | def | Tactic | [
"Mathlib.Tactic.NormNum.Eq",
"Mathlib.Algebra.Order.Field.Defs",
"Mathlib.Algebra.Order.Invertible",
"Mathlib.Algebra.Order.Monoid.WithTop",
"Mathlib.Algebra.Order.Ring.Cast"
] | Mathlib/Tactic/NormNum/Ineq.lean | evalLT | The `norm_num` extension which identifies expressions of the form `a < b`,
such that `norm_num` successfully recognises both `a` and `b`. |
inferCharZeroOfRing {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :
MetaM Q(CharZero $α) :=
return ← synthInstanceQ q(CharZero $α) <|>
throwError "not a characteristic zero ring" | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfRing | Helper function to synthesize a typed `CharZero α` expression given `Ring α`. |
inferCharZeroOfRing? {α : Q(Type u)} (_i : Q(Ring $α) := by with_reducible assumption) :
MetaM (Option Q(CharZero $α)) :=
return (← trySynthInstanceQ q(CharZero $α)).toOption | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfRing | Helper function to synthesize a typed `CharZero α` expression given `Ring α`, if it exists. |
inferCharZeroOfAddMonoidWithOne {α : Q(Type u)}
(_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=
return ← synthInstanceQ q(CharZero $α) <|>
throwError "not a characteristic zero AddMonoidWithOne" | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfAddMonoidWithOne | Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`. |
inferCharZeroOfAddMonoidWithOne? {α : Q(Type u)}
(_i : Q(AddMonoidWithOne $α) := by with_reducible assumption) :
MetaM (Option Q(CharZero $α)) :=
return (← trySynthInstanceQ q(CharZero $α)).toOption | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfAddMonoidWithOne | Helper function to synthesize a typed `CharZero α` expression given `AddMonoidWithOne α`, if it
exists. |
inferCharZeroOfDivisionRing {α : Q(Type u)}
(_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM Q(CharZero $α) :=
return ← synthInstanceQ q(CharZero $α) <|>
throwError "not a characteristic zero division ring" | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfDivisionRing | Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`. |
inferCharZeroOfDivisionSemiring? {α : Q(Type u)}
(_i : Q(DivisionSemiring $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=
return (← trySynthInstanceQ (q(CharZero $α) : Q(Prop))).toOption | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfDivisionSemiring | Helper function to synthesize a typed `CharZero α` expression given `Divisionsemiring α`, if it
exists. |
inferCharZeroOfDivisionRing? {α : Q(Type u)}
(_i : Q(DivisionRing $α) := by with_reducible assumption) : MetaM (Option Q(CharZero $α)) :=
return (← trySynthInstanceQ q(CharZero $α)).toOption | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | inferCharZeroOfDivisionRing | Helper function to synthesize a typed `CharZero α` expression given `DivisionRing α`, if it
exists. |
isRat_mkRat : {a na n : ℤ} → {b nb d : ℕ} → IsInt a na → IsNat b nb →
IsRat (na / nb : ℚ) n d → IsRat (mkRat a b) n d
| _, _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, ⟨_, h⟩ => by rw [Rat.mkRat_eq_div]; exact ⟨_, h⟩
attribute [local instance] monadLiftOptionMetaM in | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isRat_mkRat | null |
@[norm_num mkRat _ _]
evalMkRat : NormNumExt where eval {u α} (e : Q(ℚ)) : MetaM (Result e) := do
let .app (.app (.const ``mkRat _) (a : Q(ℤ))) (b : Q(ℕ)) ← whnfR e | failure
haveI' : $e =Q mkRat $a $b := ⟨⟩
let ra ← derive a
let some ⟨_, na, pa⟩ := ra.toInt (q(Int.instRing) : Q(Ring Int)) | failure
let ⟨nb, ... | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | evalMkRat | The `norm_num` extension which identifies expressions of the form `mkRat a b`,
such that `norm_num` successfully recognises both `a` and `b`, and returns `a / b`. |
isNat_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℕ} →
IsNat q n → IsNat (q : R) n
| _, _, ⟨rfl⟩ => ⟨by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isNat_ratCast | null |
isInt_ratCast {R : Type*} [DivisionRing R] : {q : ℚ} → {n : ℤ} →
IsInt q n → IsInt (q : R) n
| _, _, ⟨rfl⟩ => ⟨by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isInt_ratCast | null |
isNNRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℕ} → {d : ℕ} →
IsNNRat q n d → IsNNRat (q : R) n d
| _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isNNRat_ratCast | null |
isRat_ratCast {R : Type*} [DivisionRing R] [CharZero R] : {q : ℚ} → {n : ℤ} → {d : ℕ} →
IsRat q n d → IsRat (q : R) n d
| _, _, _, ⟨⟨qi,_,_⟩, rfl⟩ => ⟨⟨qi, by norm_cast, by norm_cast⟩, by simp only; norm_cast⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isRat_ratCast | null |
@[norm_num Rat.cast _, RatCast.ratCast _] evalRatCast : NormNumExt where eval {u α} e := do
let dα ← inferDivisionRing α
let .app r (a : Q(ℚ)) ← whnfR e | failure
guard <|← withNewMCtxDepth <| isDefEq r q(Rat.cast (K := $α))
let r ← derive q($a)
haveI' : $e =Q Rat.cast $a := ⟨⟩
match r with
| .isNat _ na ... | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | evalRatCast | The `norm_num` extension which identifies an expression `RatCast.ratCast q` where `norm_num`
recognizes `q`, returning the cast of `q`. |
isNNRat_inv_pos {α} [DivisionSemiring α] [CharZero α] {a : α} {n d : ℕ} :
IsNNRat a (Nat.succ n) d → IsNNRat a⁻¹ d (Nat.succ n) := by
rintro ⟨_, rfl⟩
have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n))
exact ⟨this, by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isNNRat_inv_pos | null |
isRat_inv_pos {α} [DivisionRing α] [CharZero α] {a : α} {n d : ℕ} :
IsRat a (.ofNat (Nat.succ n)) d → IsRat a⁻¹ (.ofNat d) (Nat.succ n) := by
rintro ⟨_, rfl⟩
have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n))
exact ⟨this, by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isRat_inv_pos | null |
isNat_inv_one {α} [DivisionSemiring α] : {a : α} →
IsNat a (nat_lit 1) → IsNat a⁻¹ (nat_lit 1)
| _, ⟨rfl⟩ => ⟨by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isNat_inv_one | null |
isNat_inv_zero {α} [DivisionSemiring α] : {a : α} →
IsNat a (nat_lit 0) → IsNat a⁻¹ (nat_lit 0)
| _, ⟨rfl⟩ => ⟨by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isNat_inv_zero | null |
isInt_inv_neg_one {α} [DivisionRing α] : {a : α} →
IsInt a (.negOfNat (nat_lit 1)) → IsInt a⁻¹ (.negOfNat (nat_lit 1))
| _, ⟨rfl⟩ => ⟨by simp⟩ | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isInt_inv_neg_one | null |
isRat_inv_neg {α} [DivisionRing α] [CharZero α] {a : α} {n d : ℕ} :
IsRat a (.negOfNat (Nat.succ n)) d → IsRat a⁻¹ (.negOfNat d) (Nat.succ n) := by
rintro ⟨_, rfl⟩
simp only [Int.negOfNat_eq]
have := invertibleOfNonzero (α := α) (Nat.cast_ne_zero.2 (Nat.succ_ne_zero n))
generalize Nat.succ n = n at *
use ... | theorem | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | isRat_inv_neg | null |
Result.inv {u : Level} {α : Q(Type u)} {a : Q($α)} (ra : Result a)
(dsα : Q(DivisionSemiring $α)) (czα? : Option Q(CharZero $α)) :
MetaM (Result q($a⁻¹)) := do
if let .some ⟨qa, na, da, pa⟩ := ra.toNNRat' dsα then
let qb := qa⁻¹
if qa > 0 then
if let some _i := czα? then
have lit2 : Q(ℕ)... | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | Result.inv | The result of inverting a norm_num result. |
@[norm_num _⁻¹] evalInv : NormNumExt where eval {u α} e := do
let .app f (a : Q($α)) ← whnfR e | failure
let ra ← derive a
let dsα ← inferDivisionSemiring α
guard <| ← withNewMCtxDepth <| isDefEq f q(Inv.inv (α := $α))
haveI' : $e =Q $a⁻¹ := ⟨⟩
assumeInstancesCommute
ra.inv q($dsα) (← inferCharZeroOfDivis... | def | Tactic | [
"Mathlib.Tactic.NormNum.Basic",
"Mathlib.Data.Rat.Cast.CharZero",
"Mathlib.Algebra.Field.Basic"
] | Mathlib/Tactic/NormNum/Inv.lean | evalInv | The `norm_num` extension which identifies expressions of the form `a⁻¹`,
such that `norm_num` successfully recognises `a`. |
private irrational_rpow_rat_of_not_power {q : ℚ} {a b : ℕ}
(h : ∀ p : ℚ, q ^ a ≠ p ^ b) (hb : 0 < b) (hq : 0 ≤ q) :
Irrational (Real.rpow q (a / b : ℚ)) := by
simp only [Irrational, Rat.cast_div, Rat.cast_natCast, Real.rpow_eq_pow, Set.mem_range,
not_exists]
intro x hx
absurd h x
rify
rw [hx, ← Re... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_rpow_rat_of_not_power | null |
private not_power_nat_pow {n p q : ℕ}
(h_coprime : p.Coprime q)
(hq : 0 < q)
(h : ∀ m, n ≠ m ^ q) (m : ℕ) :
n ^ p ≠ m ^ q := by
by_cases hn : n = 0
· specialize h 0
simp [hn, zero_pow hq.ne.symm] at h
contrapose! h
apply_fun Nat.factorization at h
simp only [Nat.factorization_pow] at h
s... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | not_power_nat_pow | null |
private not_power_nat_of_bounds {n k d : ℕ}
(h_left : k ^ d < n) (h_right : n < (k + 1) ^ d) {m : ℕ} :
n ≠ m ^ d := by
intro h
rw [h] at h_left h_right
have : k < m := lt_of_pow_lt_pow_left' d h_left
have : m < k + 1 := lt_of_pow_lt_pow_left' d h_right
cutsat | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | not_power_nat_of_bounds | null |
private not_power_nat_pow_of_bounds {n k p q : ℕ}
(hq : 0 < q) (h_coprime : p.Coprime q) (h_left : k ^ q < n) (h_right : n < (k + 1) ^ q)
(m : ℕ) :
n ^ p ≠ m ^ q := by
apply not_power_nat_pow h_coprime hq
intro m
apply not_power_nat_of_bounds h_left h_right | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | not_power_nat_pow_of_bounds | null |
private eq_of_mul_eq_mul_of_coprime_aux {a b x y : ℕ} (hab : a.Coprime b)
(h : a * x = b * y) : a ∣ y := Nat.Coprime.dvd_of_dvd_mul_left hab (Dvd.intro x h) | lemma | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | eq_of_mul_eq_mul_of_coprime_aux | null |
private eq_of_mul_eq_mul_of_coprime {a b x y : ℕ} (hab : a.Coprime b) (hxy : x.Coprime y)
(h : a * x = b * y) : a = y := by
apply Nat.dvd_antisymm
· exact eq_of_mul_eq_mul_of_coprime_aux hab h
· exact eq_of_mul_eq_mul_of_coprime_aux (x := b) hxy.symm (by rw [mul_comm, ← h, mul_comm]) | lemma | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | eq_of_mul_eq_mul_of_coprime | null |
private not_power_rat_of_num_aux {a b d : ℕ}
(h_coprime : a.Coprime b) (ha : ∀ x, a ≠ x ^ d) {q : ℚ} (hq : 0 ≤ q) :
(a / b : ℚ) ≠ q ^ d := by
by_cases hb_zero : b = 0
· subst hb_zero
contrapose! ha
simp only [Nat.coprime_zero_right] at h_coprime
subst h_coprime
use 1
simp
by_contra! h
... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | not_power_rat_of_num_aux | Weaker version of `not_power_rat_of_num` with extra `q ≥ 0` assumption. |
private not_power_rat_of_num {a b d : ℕ}
(h_coprime : a.Coprime b) (ha : ∀ x, a ≠ x ^ d) (q : ℚ) :
(a / b : ℚ) ≠ q ^ d := by
by_cases hq : 0 ≤ q
· apply not_power_rat_of_num_aux h_coprime ha hq
rcases d.even_or_odd with (h_even | h_odd)
· have := not_power_rat_of_num_aux h_coprime (q := -q) ha (by linar... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | not_power_rat_of_num | null |
private irrational_rpow_rat_rat_of_num {x y : ℝ} {x_num x_den y_num y_den k_num : ℕ}
(hx_isNNRat : IsNNRat x x_num x_den)
(hy_isNNRat : IsNNRat y y_num y_den)
(hx_coprime : Nat.Coprime x_num x_den)
(hy_coprime : Nat.Coprime y_num y_den)
(hn1 : k_num ^ y_den < x_num)
(hn2 : x_num < (k_num + 1) ^ ... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_rpow_rat_rat_of_num | null |
private irrational_rpow_rat_rat_of_den {x y : ℝ} {x_num x_den y_num y_den k_den : ℕ}
(hx_isNNRat : IsNNRat x x_num x_den)
(hy_isNNRat : IsNNRat y y_num y_den)
(hx_coprime : Nat.Coprime x_num x_den)
(hy_coprime : Nat.Coprime y_num y_den)
(hd1 : k_den ^ y_den < x_den)
(hd2 : x_den < (k_den + 1) ^ ... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_rpow_rat_rat_of_den | null |
private irrational_rpow_nat_rat {x y : ℝ} {x_num y_num y_den k : ℕ}
(hx_isNat : IsNat x x_num)
(hy_isNNRat : IsNNRat y y_num y_den)
(hy_coprime : Nat.Coprime y_num y_den)
(hn1 : k ^ y_den < x_num)
(hn2 : x_num < (k + 1) ^ y_den) :
Irrational (x ^ y) :=
irrational_rpow_rat_rat_of_num hx_isNat.t... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_rpow_nat_rat | null |
private irrational_sqrt_rat_of_num {x : ℝ} {num den num_k : ℕ}
(hx_isNNRat : IsNNRat x num den)
(hx_coprime : Nat.Coprime num den)
(hn1 : num_k ^ 2 < num)
(hn2 : num < (num_k + 1) ^ 2) :
Irrational (Real.sqrt x) := by
rw [Real.sqrt_eq_rpow]
apply irrational_rpow_rat_rat_of_num hx_isNNRat (y_num ... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_sqrt_rat_of_num | null |
private irrational_sqrt_rat_of_den {x : ℝ} {num den den_k : ℕ}
(hx_isNNRat : IsNNRat x num den)
(hx_coprime : Nat.Coprime num den)
(hd1 : den_k ^ 2 < den)
(hd2 : den < (den_k + 1) ^ 2) :
Irrational (Real.sqrt x) := by
rw [Real.sqrt_eq_rpow]
apply irrational_rpow_rat_rat_of_den hx_isNNRat (y_num ... | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_sqrt_rat_of_den | null |
private irrational_sqrt_nat {x : ℝ} {n k : ℕ}
(hx_isNat : IsNat x n)
(hn1 : k ^ 2 < n)
(hn2 : n < (k + 1) ^ 2) :
Irrational (Real.sqrt x) :=
irrational_sqrt_rat_of_num hx_isNat.to_isNNRat (by simp) hn1 hn2 | theorem | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | irrational_sqrt_nat | null |
NotPowerCertificate (m n : Q(ℕ)) where
/-- Natural `k` such that `k ^ n < m < (k + 1) ^ n`. -/
k : Q(ℕ)
/-- Proof of `k ^ n < m`. -/
pf_left : Q($k ^ $n < $m)
/-- Proof of `m < (k + 1) ^ n`. -/
pf_right : Q($m < ($k + 1) ^ $n) | structure | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | NotPowerCertificate | To prove that `m` is not `n`-power (and thus `m ^ (1/n)` is irrational), we find `k` such that
`k ^ n < m < (k + 1) ^ n`. |
findNotPowerCertificateCore (m n : ℕ) : Option ℕ := Id.run do
let mut left := 0
let mut right := m + 1
while right - left > 1 do
let middle := (left + right) / 2
if middle ^ n ≤ m then
left := middle
else
right := middle
if left ^ n < m then
return some left
return none | def | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | findNotPowerCertificateCore | Finds `k` such that `k ^ n < m < (k + 1) ^ n` using bisection method. It assumes `n > 0`. |
findNotPowerCertificate (m n : Q(ℕ)) : MetaM (NotPowerCertificate m n) := do
let .isNat (_ : Q(AddMonoidWithOne ℕ)) m _ := ← derive m | failure
let .isNat (_ : Q(AddMonoidWithOne ℕ)) n _ := ← derive n | failure
let mVal := m.natLit!
let nVal := n.natLit!
let some k := findNotPowerCertificateCore mVal nVal | f... | def | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | findNotPowerCertificate | Finds `NotPowerCertificate` showing that `m` is not `n`-power. |
@[norm_num Irrational (_ ^ (_ : ℝ))]
evalIrrationalRpow : NormNumExt where eval {u α} e := do
let 0 := u | failure
let ~q(Prop) := α | failure
let ~q(Irrational (($x : ℝ) ^ ($y : ℝ))) := e | failure
let .isNNRat sℝ _ y_num y_den y_isNNRat ← derive y | failure
let ⟨gy, hy_coprime⟩ := proveNatGCD y_num y_den
... | def | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | evalIrrationalRpow | `norm_num` extension that proves `Irrational x ^ y` for rational `y`. `x` may be
natural or rational. |
@[norm_num Irrational (Real.sqrt _)]
evalIrrationalSqrt : NormNumExt where eval {u α} e := do
let 0 := u | failure
let ~q(Prop) := α | failure
let ~q(Irrational (√$x)) := e | failure
match ← derive x with
| .isNat sℝ ex pf =>
let cert ← findNotPowerCertificate ex q(nat_lit 2)
assumeInstancesCommute
... | def | Tactic | [
"Mathlib.Analysis.SpecialFunctions.Pow.Real",
"Mathlib.Data.Real.Irrational",
"Mathlib.Tactic.NormNum.GCD",
"Mathlib.Tactic.Rify"
] | Mathlib/Tactic/NormNum/Irrational.lean | evalIrrationalSqrt | `norm_num` extension that proves `Irrational √x` for rational `x`. |
int_not_isCoprime_helper (x y : ℤ) (d : ℕ) (hd : Int.gcd x y = d)
(h : Nat.beq d 1 = false) : ¬ IsCoprime x y := by
rw [Int.isCoprime_iff_gcd_eq_one, hd]
exact Nat.ne_of_beq_eq_false h | theorem | Tactic | [
"Mathlib.RingTheory.Coprime.Lemmas",
"Mathlib.Tactic.NormNum.GCD"
] | Mathlib/Tactic/NormNum/IsCoprime.lean | int_not_isCoprime_helper | null |
isInt_isCoprime : {x y nx ny : ℤ} →
IsInt x nx → IsInt y ny → IsCoprime nx ny → IsCoprime x y
| _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, h => h | theorem | Tactic | [
"Mathlib.RingTheory.Coprime.Lemmas",
"Mathlib.Tactic.NormNum.GCD"
] | Mathlib/Tactic/NormNum/IsCoprime.lean | isInt_isCoprime | null |
isInt_not_isCoprime : {x y nx ny : ℤ} →
IsInt x nx → IsInt y ny → ¬ IsCoprime nx ny → ¬ IsCoprime x y
| _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, h => h | theorem | Tactic | [
"Mathlib.RingTheory.Coprime.Lemmas",
"Mathlib.Tactic.NormNum.GCD"
] | Mathlib/Tactic/NormNum/IsCoprime.lean | isInt_not_isCoprime | null |
proveIntIsCoprime (ex ey : Q(ℤ)) : Q(IsCoprime $ex $ey) ⊕ Q(¬ IsCoprime $ex $ey) :=
let ⟨ed, pf⟩ := proveIntGCD ex ey
if ed.natLit! = 1 then
have pf' : Q(Int.gcd $ex $ey = 1) := pf
Sum.inl q(Int.isCoprime_iff_gcd_eq_one.mpr $pf')
else
have h : Q(Nat.beq $ed 1 = false) := (q(Eq.refl false) : Expr)
... | def | Tactic | [
"Mathlib.RingTheory.Coprime.Lemmas",
"Mathlib.Tactic.NormNum.GCD"
] | Mathlib/Tactic/NormNum/IsCoprime.lean | proveIntIsCoprime | Evaluates `IsCoprime` for the given integer number literals.
Panics if `ex` or `ey` aren't integer number literals. |
@[norm_num IsCoprime (_ : ℤ) (_ : ℤ)]
evalIntIsCoprime : NormNumExt where eval {_ _} e := do
let .app (.app _ (x : Q(ℤ))) (y : Q(ℤ)) ← Meta.whnfR e | failure
let ⟨ex, p⟩ ← deriveInt x _
let ⟨ey, q⟩ ← deriveInt y _
match proveIntIsCoprime ex ey with
| .inl pf =>
have pf' : Q(IsCoprime $x $y) := q(isInt_isC... | def | Tactic | [
"Mathlib.RingTheory.Coprime.Lemmas",
"Mathlib.Tactic.NormNum.GCD"
] | Mathlib/Tactic/NormNum/IsCoprime.lean | evalIntIsCoprime | Evaluates the `IsCoprime` predicate over `ℤ`. |
jacobiSymNat (a b : ℕ) : ℤ :=
jacobiSym a b
/-! | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat | The Jacobi symbol restricted to natural numbers in both arguments. |
jacobiSymNat.zero_right (a : ℕ) : jacobiSymNat a 0 = 1 := by
rw [jacobiSymNat, jacobiSym.zero_right] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.zero_right | Base cases: `b = 0`, `b = 1`, `a = 0`, `a = 1`. |
jacobiSymNat.one_right (a : ℕ) : jacobiSymNat a 1 = 1 := by
rw [jacobiSymNat, jacobiSym.one_right] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.one_right | null |
jacobiSymNat.zero_left (b : ℕ) (hb : Nat.beq (b / 2) 0 = false) : jacobiSymNat 0 b = 0 := by
rw [jacobiSymNat, Nat.cast_zero, jacobiSym.zero_left ?_]
calc
1 < 2 * 1 := by decide
_ ≤ 2 * (b / 2) :=
Nat.mul_le_mul_left _ (Nat.succ_le.mpr (Nat.pos_of_ne_zero (Nat.ne_of_beq_eq_false hb)))
_ ≤ b ... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.zero_left | null |
jacobiSymNat.one_left (b : ℕ) : jacobiSymNat 1 b = 1 := by
rw [jacobiSymNat, Nat.cast_one, jacobiSym.one_left] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.one_left | null |
LegendreSym.to_jacobiSym (p : ℕ) (pp : Fact p.Prime) (a r : ℤ)
(hr : IsInt (jacobiSym a p) r) : IsInt (legendreSym p a) r := by
rwa [@jacobiSym.legendreSym.to_jacobiSym p pp a] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | LegendreSym.to_jacobiSym | Turn a Legendre symbol into a Jacobi symbol. |
JacobiSym.mod_left (a : ℤ) (b ab' : ℕ) (ab r b' : ℤ) (hb' : (b : ℤ) = b')
(hab : a % b' = ab) (h : (ab' : ℤ) = ab) (hr : jacobiSymNat ab' b = r) : jacobiSym a b = r := by
rw [← hr, jacobiSymNat, jacobiSym.mod_left, hb', hab, ← h] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | JacobiSym.mod_left | The value depends only on the residue class of `a` mod `b`. |
jacobiSymNat.mod_left (a b ab : ℕ) (r : ℤ) (hab : a % b = ab) (hr : jacobiSymNat ab b = r) :
jacobiSymNat a b = r := by
rw [← hr, jacobiSymNat, jacobiSymNat, _root_.jacobiSym.mod_left a b, ← hab]; rfl | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.mod_left | null |
jacobiSymNat.even_even (a b : ℕ) (hb₀ : Nat.beq (b / 2) 0 = false) (ha : a % 2 = 0)
(hb₁ : b % 2 = 0) : jacobiSymNat a b = 0 := by
refine jacobiSym.eq_zero_iff.mpr
⟨ne_of_gt ((Nat.pos_of_ne_zero (Nat.ne_of_beq_eq_false hb₀)).trans_le (Nat.div_le_self b 2)),
fun hf => ?_⟩
have h : 2 ∣ a.gcd b := Nat.dv... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.even_even | The symbol vanishes when both entries are even (and `b / 2 ≠ 0`). |
jacobiSymNat.odd_even (a b c : ℕ) (r : ℤ) (ha : a % 2 = 1) (hb : b % 2 = 0) (hc : b / 2 = c)
(hr : jacobiSymNat a c = r) : jacobiSymNat a b = r := by
have ha' : legendreSym 2 a = 1 := by
simp only [legendreSym.mod 2 a, Int.ofNat_mod_ofNat, ha]
decide
rcases eq_or_ne c 0 with (rfl | hc')
· rw [← hr, Na... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.odd_even | When `a` is odd and `b` is even, we can replace `b` by `b / 2`. |
jacobiSymNat.double_even (a b c : ℕ) (r : ℤ) (ha : a % 4 = 0) (hb : b % 2 = 1)
(hc : a / 4 = c) (hr : jacobiSymNat c b = r) : jacobiSymNat a b = r := by
simp only [jacobiSymNat, ← hr, ← hc, Int.natCast_ediv, Nat.cast_ofNat]
exact (jacobiSym.div_four_left (mod_cast ha) hb).symm | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.double_even | If `a` is divisible by `4` and `b` is odd, then we can remove the factor `4` from `a`. |
jacobiSymNat.even_odd₁ (a b c : ℕ) (r : ℤ) (ha : a % 2 = 0) (hb : b % 8 = 1)
(hc : a / 2 = c) (hr : jacobiSymNat c b = r) : jacobiSymNat a b = r := by
simp only [jacobiSymNat, ← hr, ← hc, Int.natCast_ediv, Nat.cast_ofNat]
rw [← jacobiSym.even_odd (mod_cast ha), if_neg (by simp [hb])]
rw [← Nat.mod_mod_of_dvd,... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.even_odd₁ | If `a` is even and `b` is odd, then we can remove a factor `2` from `a`,
but we may have to change the sign, depending on `b % 8`.
We give one version for each of the four odd residue classes mod `8`. |
jacobiSymNat.even_odd₇ (a b c : ℕ) (r : ℤ) (ha : a % 2 = 0) (hb : b % 8 = 7)
(hc : a / 2 = c) (hr : jacobiSymNat c b = r) : jacobiSymNat a b = r := by
simp only [jacobiSymNat, ← hr, ← hc, Int.natCast_ediv, Nat.cast_ofNat]
rw [← jacobiSym.even_odd (mod_cast ha), if_neg (by simp [hb])]
rw [← Nat.mod_mod_of_dvd,... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.even_odd₇ | null |
jacobiSymNat.even_odd₃ (a b c : ℕ) (r : ℤ) (ha : a % 2 = 0) (hb : b % 8 = 3)
(hc : a / 2 = c) (hr : jacobiSymNat c b = r) : jacobiSymNat a b = -r := by
simp only [jacobiSymNat, ← hr, ← hc, Int.natCast_ediv, Nat.cast_ofNat]
rw [← jacobiSym.even_odd (mod_cast ha), if_pos (by simp [hb])]
rw [← Nat.mod_mod_of_dvd... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.even_odd₃ | null |
jacobiSymNat.even_odd₅ (a b c : ℕ) (r : ℤ) (ha : a % 2 = 0) (hb : b % 8 = 5)
(hc : a / 2 = c) (hr : jacobiSymNat c b = r) : jacobiSymNat a b = -r := by
simp only [jacobiSymNat, ← hr, ← hc, Int.natCast_ediv, Nat.cast_ofNat]
rw [← jacobiSym.even_odd (mod_cast ha), if_pos (by simp [hb])]
rw [← Nat.mod_mod_of_dvd... | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.even_odd₅ | null |
jacobiSymNat.qr₁ (a b : ℕ) (r : ℤ) (ha : a % 4 = 1) (hb : b % 2 = 1)
(hr : jacobiSymNat b a = r) : jacobiSymNat a b = r := by
rwa [jacobiSymNat, jacobiSym.quadratic_reciprocity_one_mod_four ha (Nat.odd_iff.mpr hb)] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₁ | Use quadratic reciprocity to reduce to smaller `b`. |
jacobiSymNat.qr₁_mod (a b ab : ℕ) (r : ℤ) (ha : a % 4 = 1) (hb : b % 2 = 1)
(hab : b % a = ab) (hr : jacobiSymNat ab a = r) : jacobiSymNat a b = r :=
jacobiSymNat.qr₁ _ _ _ ha hb <| jacobiSymNat.mod_left _ _ ab r hab hr | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₁_mod | null |
jacobiSymNat.qr₁' (a b : ℕ) (r : ℤ) (ha : a % 2 = 1) (hb : b % 4 = 1)
(hr : jacobiSymNat b a = r) : jacobiSymNat a b = r := by
rwa [jacobiSymNat, ← jacobiSym.quadratic_reciprocity_one_mod_four hb (Nat.odd_iff.mpr ha)] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₁' | null |
jacobiSymNat.qr₁'_mod (a b ab : ℕ) (r : ℤ) (ha : a % 2 = 1) (hb : b % 4 = 1)
(hab : b % a = ab) (hr : jacobiSymNat ab a = r) : jacobiSymNat a b = r :=
jacobiSymNat.qr₁' _ _ _ ha hb <| jacobiSymNat.mod_left _ _ ab r hab hr | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₁'_mod | null |
jacobiSymNat.qr₃ (a b : ℕ) (r : ℤ) (ha : a % 4 = 3) (hb : b % 4 = 3)
(hr : jacobiSymNat b a = r) : jacobiSymNat a b = -r := by
rwa [jacobiSymNat, jacobiSym.quadratic_reciprocity_three_mod_four ha hb, neg_inj] | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₃ | null |
jacobiSymNat.qr₃_mod (a b ab : ℕ) (r : ℤ) (ha : a % 4 = 3) (hb : b % 4 = 3)
(hab : b % a = ab) (hr : jacobiSymNat ab a = r) : jacobiSymNat a b = -r :=
jacobiSymNat.qr₃ _ _ _ ha hb <| jacobiSymNat.mod_left _ _ ab r hab hr | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | jacobiSymNat.qr₃_mod | null |
isInt_jacobiSym : {a na : ℤ} → {b nb : ℕ} → {r : ℤ} →
IsInt a na → IsNat b nb → jacobiSym na nb = r → IsInt (jacobiSym a b) r
| _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, rfl => ⟨rfl⟩ | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | isInt_jacobiSym | null |
isInt_jacobiSymNat : {a na : ℕ} → {b nb : ℕ} → {r : ℤ} →
IsNat a na → IsNat b nb → jacobiSymNat na nb = r → IsInt (jacobiSymNat a b) r
| _, _, _, _, _, ⟨rfl⟩, ⟨rfl⟩, rfl => ⟨rfl⟩ | theorem | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | isInt_jacobiSymNat | null |
partial proveJacobiSymOdd (ea eb : Q(ℕ)) : (er : Q(ℤ)) × Q(jacobiSymNat $ea $eb = $er) :=
match eb.natLit! with
| 1 =>
haveI : $eb =Q 1 := ⟨⟩
⟨mkRawIntLit 1, q(jacobiSymNat.one_right $ea)⟩
| b =>
match ea.natLit! with
| 0 =>
haveI : $ea =Q 0 := ⟨⟩
have hb : Q(Nat.beq ($eb / 2) 0 = fals... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | proveJacobiSymOdd | This evaluates `r := jacobiSymNat a b` recursively using quadratic reciprocity
and produces a proof term for the equality, assuming that `a < b` and `b` is odd. |
partial proveJacobiSymNat (ea eb : Q(ℕ)) : (er : Q(ℤ)) × Q(jacobiSymNat $ea $eb = $er) :=
match eb.natLit! with
| 0 =>
haveI : $eb =Q 0 := ⟨⟩
⟨mkRawIntLit 1, q(jacobiSymNat.zero_right $ea)⟩
| 1 =>
haveI : $eb =Q 1 := ⟨⟩
⟨mkRawIntLit 1, q(jacobiSymNat.one_right $ea)⟩
| b =>
match b % 2 with
... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | proveJacobiSymNat | This evaluates `r := jacobiSymNat a b` and produces a proof term for the equality
by removing powers of `2` from `b` and then calling `proveJacobiSymOdd`. |
partial proveJacobiSym (ea : Q(ℤ)) (eb : Q(ℕ)) : (er : Q(ℤ)) × Q(jacobiSym $ea $eb = $er) :=
match eb.natLit! with
| 0 =>
haveI : $eb =Q 0 := ⟨⟩
⟨mkRawIntLit 1, q(jacobiSym.zero_right $ea)⟩
| 1 =>
haveI : $eb =Q 1 := ⟨⟩
⟨mkRawIntLit 1, q(jacobiSym.one_right $ea)⟩
| b =>
have eb' := mkRawIntL... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | proveJacobiSym | This evaluates `r := jacobiSym a b` and produces a proof term for the equality.
This is done by reducing to `r := jacobiSymNat (a % b) b`. |
@[norm_num jacobiSym _ _]
evalJacobiSym : NormNumExt where eval {u α} e := do
let .app (.app _ (a : Q(ℤ))) (b : Q(ℕ)) ← Meta.whnfR e | failure
let ⟨ea, pa⟩ ← deriveInt a _
let ⟨eb, pb⟩ ← deriveNat b _
haveI' : u =QL 0 := ⟨⟩ haveI' : $α =Q ℤ := ⟨⟩
have ⟨er, pr⟩ := proveJacobiSym ea eb
haveI' : $e... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | evalJacobiSym | This is the `norm_num` plug-in that evaluates Jacobi symbols. |
@[norm_num jacobiSymNat _ _]
evalJacobiSymNat : NormNumExt where eval {u α} e := do
let .app (.app _ (a : Q(ℕ))) (b : Q(ℕ)) ← Meta.whnfR e | failure
let ⟨ea, pa⟩ ← deriveNat a _
let ⟨eb, pb⟩ ← deriveNat b _
haveI' : u =QL 0 := ⟨⟩ haveI' : $α =Q ℤ := ⟨⟩
have ⟨er, pr⟩ := proveJacobiSymNat ea eb
ha... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | evalJacobiSymNat | This is the `norm_num` plug-in that evaluates Jacobi symbols on natural numbers. |
@[norm_num legendreSym _ _]
evalLegendreSym : NormNumExt where eval {u α} e := do
let .app (.app (.app _ (p : Q(ℕ))) (fp : Q(Fact (Nat.Prime $p)))) (a : Q(ℤ)) ← Meta.whnfR e |
failure
let ⟨ea, pa⟩ ← deriveInt a _
let ⟨ep, pp⟩ ← deriveNat p _
haveI' : u =QL 0 := ⟨⟩ haveI' : $α =Q ℤ := ⟨⟩
have ⟨... | def | Tactic | [
"Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol"
] | Mathlib/Tactic/NormNum/LegendreSymbol.lean | evalLegendreSym | This is the `norm_num` plug-in that evaluates Legendre symbols. |
evalNatModEq : NormNumExt where eval {u αP} e := do
match u, αP, e with
| 0, ~q(Prop), ~q($a ≡ $b [MOD $n]) =>
let ⟨b, pb⟩ ← deriveBoolOfIff _ e q(Nat.modEq_iff_dvd.symm)
return .ofBoolResult pb
| _, _, _ => failure | def | Tactic | [
"Mathlib.Tactic.NormNum.DivMod",
"Mathlib.Data.Int.ModEq"
] | Mathlib/Tactic/NormNum/ModEq.lean | evalNatModEq | null |
evalIntModEq : NormNumExt where eval {u αP} e := do
match u, αP, e with
| 0, ~q(Prop), ~q($a ≡ $b [ZMOD $n]) =>
let ⟨b, pb⟩ ← deriveBoolOfIff _ e q(Int.modEq_iff_dvd.symm)
return .ofBoolResult pb
| _, _, _ => failure | def | Tactic | [
"Mathlib.Tactic.NormNum.DivMod",
"Mathlib.Data.Int.ModEq"
] | Mathlib/Tactic/NormNum/ModEq.lean | evalIntModEq | null |
asc_factorial_aux (n l m a b : ℕ) (h₁ : n.ascFactorial l = a)
(h₂ : (n + l).ascFactorial m = b) : n.ascFactorial (l + m) = a * b := by
rw [← h₁, ← h₂]
symm
apply ascFactorial_mul_ascFactorial | lemma | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | asc_factorial_aux | null |
partial proveAscFactorial (n l : ℕ) (en el : Q(ℕ)) :
ℕ × (eresult : Q(ℕ)) × Q(($en).ascFactorial $el = $eresult) :=
if l ≤ 50 then
have res : ℕ := n.ascFactorial l
have eres : Q(ℕ) := mkRawNatLit (n.ascFactorial l)
have : ($en).ascFactorial $el =Q $eres := ⟨⟩
⟨res, eres, q(Eq.refl $eres)⟩
else
... | def | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | proveAscFactorial | Calculate `n.ascFactorial l` and return this value along with a proof of the result. |
isNat_factorial {n x : ℕ} (h₁ : IsNat n x) (a : ℕ) (h₂ : (1).ascFactorial x = a) :
IsNat (n !) a := by
constructor
simp only [h₁.out, cast_id, ← h₂, one_ascFactorial] | lemma | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | isNat_factorial | null |
@[nolint unusedHavesSuffices, norm_num Nat.factorial _]
evalNatFactorial : NormNumExt where eval {u α} e := do
let .app _ (x : Q(ℕ)) ← Meta.whnfR e | failure
have : u =QL 0 := ⟨⟩; have : $α =Q ℕ := ⟨⟩; have : $e =Q Nat.factorial $x := ⟨⟩
let sℕ : Q(AddMonoidWithOne ℕ) := q(instAddMonoidWithOneNat)
let ⟨ex, p⟩ ←... | def | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | evalNatFactorial | Evaluates the `Nat.factorial` function. |
isNat_ascFactorial {n x l y : ℕ} (h₁ : IsNat n x) (h₂ : IsNat l y) (a : ℕ)
(p : x.ascFactorial y = a) : IsNat (n.ascFactorial l) a := by
constructor
simp [h₁.out, h₂.out, ← p] | lemma | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | isNat_ascFactorial | null |
@[nolint unusedHavesSuffices, norm_num Nat.ascFactorial _ _]
evalNatAscFactorial : NormNumExt where eval {u α} e := do
let .app (.app _ (x : Q(ℕ))) (y : Q(ℕ)) ← Meta.whnfR e | failure
have : u =QL 0 := ⟨⟩; have : $α =Q ℕ := ⟨⟩; have : $e =Q Nat.ascFactorial $x $y := ⟨⟩
let sℕ : Q(AddMonoidWithOne ℕ) := q(instAddM... | def | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | evalNatAscFactorial | Evaluates the Nat.ascFactorial function. |
isNat_descFactorial {n x l y : ℕ} (z : ℕ) (h₁ : IsNat n x) (h₂ : IsNat l y)
(h₃ : x = z + y) (a : ℕ) (p : (z + 1).ascFactorial y = a) : IsNat (n.descFactorial l) a := by
constructor
simpa [h₁.out, h₂.out, ← p, h₃] using Nat.add_descFactorial_eq_ascFactorial _ _ | lemma | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | isNat_descFactorial | null |
isNat_descFactorial_zero {n x l y : ℕ} (z : ℕ) (h₁ : IsNat n x) (h₂ : IsNat l y)
(h₃ : y = z + x + 1) : IsNat (n.descFactorial l) 0 := by
constructor
simp [h₁.out, h₂.out, h₃]
private partial def evalNatDescFactorialNotZero {x' y' : Q(ℕ)} (x y z : Q(ℕ))
(_hx : $x =Q $z + $y)
(px : Q(IsNat $x' $x)) (py :... | lemma | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | isNat_descFactorial_zero | null |
@[nolint unusedHavesSuffices, norm_num Nat.descFactorial _ _]
evalNatDescFactorial : NormNumExt where eval {u α} e := do
let .app (.app _ (x' : Q(ℕ))) (y' : Q(ℕ)) ← Meta.whnfR e | failure
have : u =QL 0 := ⟨⟩
have : $α =Q ℕ := ⟨⟩
have : $e =Q Nat.descFactorial $x' $y' := ⟨⟩
let sℕ : Q(AddMonoidWithOne ℕ) := q... | def | Tactic | [
"Mathlib.Data.Nat.Factorial.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFactorial.lean | evalNatDescFactorial | Evaluates the `Nat.descFactorial` function. |
IsFibAux (n a b : ℕ) :=
fib n = a ∧ fib (n + 1) = b | def | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | IsFibAux | Auxiliary definition for `proveFib` extension. |
isFibAux_zero : IsFibAux 0 0 1 :=
⟨fib_zero, fib_one⟩ | theorem | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | isFibAux_zero | null |
isFibAux_one : IsFibAux 1 1 1 :=
⟨fib_one, fib_two⟩ | theorem | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | isFibAux_one | null |
isFibAux_two_mul {n a b n' a' b' : ℕ} (H : IsFibAux n a b)
(hn : 2 * n = n') (h1 : a * (2 * b - a) = a') (h2 : a * a + b * b = b') :
IsFibAux n' a' b' :=
⟨by rw [← hn, fib_two_mul, H.1, H.2, ← h1],
by rw [← hn, fib_two_mul_add_one, H.1, H.2, pow_two, pow_two, add_comm, h2]⟩ | theorem | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | isFibAux_two_mul | null |
isFibAux_two_mul_add_one {n a b n' a' b' : ℕ} (H : IsFibAux n a b)
(hn : 2 * n + 1 = n') (h1 : a * a + b * b = a') (h2 : b * (2 * a + b) = b') :
IsFibAux n' a' b' :=
⟨by rw [← hn, fib_two_mul_add_one, H.1, H.2, pow_two, pow_two, add_comm, h1],
by rw [← hn, fib_two_mul_add_two, H.1, H.2, h2]⟩ | theorem | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | isFibAux_two_mul_add_one | null |
partial proveNatFibAux (en' : Q(ℕ)) : (ea' eb' : Q(ℕ)) × Q(IsFibAux $en' $ea' $eb') :=
match en'.natLit! with
| 0 =>
have : $en' =Q nat_lit 0 := ⟨⟩;
⟨q(nat_lit 0), q(nat_lit 1), q(isFibAux_zero)⟩
| 1 =>
have : $en' =Q nat_lit 1 := ⟨⟩;
⟨q(nat_lit 1), q(nat_lit 1), q(isFibAux_one)⟩
| n' =>
hav... | def | Tactic | [
"Mathlib.Data.Nat.Fib.Basic",
"Mathlib.Tactic.NormNum"
] | Mathlib/Tactic/NormNum/NatFib.lean | proveNatFibAux | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.