Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 4b890a2

Browse files
committed
feat(*): make int.nonneg irreducible (#4601)
In #4474, `int.lt` was made irreducible. We make `int.nonneg` irreducible, which is stronger as `int.lt` is expressed in terms of `int.nonneg`.
1 parent d174295 commit 4b890a2

File tree

13 files changed

+20
-11
lines changed

13 files changed

+20
-11
lines changed

src/algebra/field_power.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ lemma one_lt_pow {K} [linear_ordered_semiring K] {p : K} (hp : 1 < p) : ∀ {n :
9090
end
9191

9292
section
93-
local attribute [semireducible] int.lt
93+
local attribute [semireducible] int.nonneg
9494
lemma one_lt_fpow {K} [discrete_linear_ordered_field K] {p : K} (hp : 1 < p) :
9595
∀ z : ℤ, 0 < z → 1 < p ^ z
9696
| (int.of_nat n) h := one_lt_pow hp (nat.succ_le_of_lt (int.lt_of_coe_nat_lt_coe_nat h))

src/data/int/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,4 +1238,4 @@ end classical
12381238

12391239
end int
12401240

1241-
attribute [irreducible] int.lt
1241+
attribute [irreducible] int.nonneg

src/data/int/range.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import data.list.range
88

99
namespace int
1010

11+
local attribute [semireducible] int.nonneg
12+
1113
/-- List enumerating `[m, n)`. -/
1214
def range (m n : ℤ) : list ℤ :=
1315
(list.range (to_nat (n-m))).map $ λ r, m+r
@@ -32,8 +34,6 @@ instance decidable_le_le (P : int → Prop) [decidable_pred P] (m n : ℤ) :
3234
decidable (∀ r, m ≤ r → r ≤ n → P r) :=
3335
decidable_of_iff (∀ r ∈ range m (n+1), P r) $ by simp only [mem_range_iff, and_imp, lt_add_one_iff]
3436

35-
local attribute [semireducible] int.lt
36-
3737
instance decidable_lt_lt (P : int → Prop) [decidable_pred P] (m n : ℤ) :
3838
decidable (∀ r, m < r → r < n → P r) :=
3939
int.decidable_le_lt P _ _

src/data/int/sqrt.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ theorem exists_mul_self (x : ℤ) :
2222
⟨λ ⟨n, hn⟩, by rw [← hn, sqrt_eq, ← int.coe_nat_mul, nat_abs_mul_self],
2323
λ h, ⟨sqrt x, h⟩⟩
2424

25-
theorem sqrt_nonneg (n : ℤ) : 0 ≤ sqrt n := trivial
25+
theorem sqrt_nonneg (n : ℤ) : 0 ≤ sqrt n := coe_nat_nonneg _
2626

2727
end int

src/data/nat/modeq.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ by rw [modeq_iff_dvd] at *; exact dvd.trans (dvd_mul_left (n : ℤ) (m : ℤ)) h
9696
theorem modeq_of_modeq_mul_right (m : ℕ) : a ≡ b [MOD n * m] → a ≡ b [MOD n] :=
9797
mul_comm m n ▸ modeq_of_modeq_mul_left _
9898

99+
local attribute [semireducible] int.nonneg
100+
99101
/-- The natural number less than `n*m` congruent to `a` mod `n` and `b` mod `m` -/
100102
def chinese_remainder (co : coprime n m) (a b : ℕ) : {k // k ≡ a [MOD n] ∧ k ≡ b [MOD m]} :=
101103
let (c, d) := xgcd n m in int.to_nat ((b * c * n + a * d * m) % (n * m)), begin

src/data/rat/sqrt.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ theorem exists_mul_self (x : ℚ) : (∃ q, q * q = x) ↔ rat.sqrt x * rat.sqrt
2727

2828
theorem sqrt_nonneg (q : ℚ) : 0 ≤ rat.sqrt q :=
2929
nonneg_iff_zero_le.1 $ (mk_nonneg _ $ int.coe_nat_pos.2 $
30-
nat.pos_of_ne_zero $ λ H, nat.pos_iff_ne_zero.1 q.pos $ nat.sqrt_eq_zero.1 H).2 trivial
30+
nat.pos_of_ne_zero $ λ H, nat.pos_iff_ne_zero.1 q.pos $ nat.sqrt_eq_zero.1 H).2
31+
$ int.coe_nat_nonneg _
3132

3233
end rat

src/data/zmod/basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ begin
428428
apply int.modeq.mod_modeq,
429429
end
430430

431+
local attribute [semireducible] int.nonneg
432+
431433
@[simp] lemma coe_to_nat (p : ℕ) :
432434
∀ {z : ℤ} (h : 0 ≤ z), (z.to_nat : zmod p) = z
433435
| (n : ℕ) h := by simp only [int.cast_coe_nat, int.to_nat_coe_nat]

src/data/zsqrtd/gaussian_int.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ by rw [norm, norm_sq]; simp
9090
@[simp] lemma nat_cast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = (x : ℂ).norm_sq :=
9191
by cases x; rw [norm, norm_sq]; simp
9292

93-
lemma norm_nonneg (x : ℤ[i]) : 0 ≤ norm x := norm_nonneg trivial _
93+
lemma norm_nonneg (x : ℤ[i]) : 0 ≤ norm x := norm_nonneg (by norm_num) _
9494

9595
@[simp] lemma norm_eq_zero {x : ℤ[i]} : norm x = 0 ↔ x = 0 :=
9696
by rw [← @int.cast_inj ℝ _ _ _]; simp

src/number_theory/lucas_lehmer.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ end
9393
lemma s_mod_nonneg (p : ℕ) (w : 0 < p) (i : ℕ) : 0 ≤ s_mod p i :=
9494
begin
9595
cases i; dsimp [s_mod],
96-
{ trivial, },
96+
{ exact sup_eq_left.mp rfl },
9797
{ apply int.mod_nonneg, exact mersenne_int_ne_zero p w },
9898
end
9999

src/tactic/omega/eq_elim.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (2 * (i % j)) < j
2525
then i % j
2626
else (i % j) - j
2727

28-
local attribute [semireducible] int.lt
28+
local attribute [semireducible] int.nonneg
2929
lemma symmod_add_one_self {i : int} :
3030
0 < i → symmod i (i+1) = -1 :=
3131
begin

0 commit comments

Comments
 (0)