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

Commit 004e0b3

Browse files
NeilStricklandChrisHughes24
authored andcommitted
feat (data/pnat): extensions to pnat (#1073)
* Extended API, especially divisibility and primes * Positive euclidean algorithm * Disambiguate overloaded :: * Tweak broken proof of flip_is_special * Change to mathlib style * Update src/data/pnat.lean Co-Authored-By: Johan Commelin <johan@commelin.net> * Update src/data/pnat.lean Co-Authored-By: Johan Commelin <johan@commelin.net> * Adjust style for mathlib * Moved and renamed * Move some material from basic.lean to prime.lean * Move some material from basic.lean to factors.lean * Update import to data.pnat.basic. * Update import to data.pnat.basic * Fix import of data.pnat.basic * Use monoid.pow instead of nat.pow * Fix pnat.pow_succ -> pow_succ; stylistic changes * More systematic use of coercion * More consistent use of coercion * Formatting; change flip' to prod.swap
1 parent 3f9916e commit 004e0b3

File tree

9 files changed

+1073
-85
lines changed

9 files changed

+1073
-85
lines changed

src/data/hash_map.lean

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Leonardo de Moura, Mario Carneiro
55
-/
6-
import data.list.basic data.pnat data.array.lemmas
6+
import data.list.basic data.pnat.basic data.array.lemmas
77
logic.basic algebra.group
88
data.list.defs data.nat.basic data.option.basic
99
data.bool data.prod
@@ -227,13 +227,13 @@ theorem valid.replace_aux (a : α) (b : β a) : Π (l : list (Σ a, β a)), a
227227
| (⟨a', b'⟩::t) := begin
228228
by_cases e : a' = a,
229229
{ subst a',
230-
suffices : ∃ u w (b'' : β a),
231-
sigma.mk a b' :: t = u ++ ⟨a, b''⟩ :: w ∧
230+
suffices : ∃ (u w : list Σ a, β a) (b'' : β a),
231+
(sigma.mk a b') :: t = u ++ ⟨a, b''⟩ :: w ∧
232232
replace_aux a b (⟨a, b'⟩ :: t) = u ++ ⟨a, b⟩ :: w, {simpa},
233233
refine ⟨[], t, b', _⟩, simp [replace_aux] },
234234
{ suffices : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (b'' : β a),
235-
sigma.mk a' b' :: t = u ++ ⟨a, b''⟩ :: w ∧
236-
sigma.mk a' b' :: replace_aux a b t = u ++ ⟨a, b⟩ :: w,
235+
(sigma.mk a' b') :: t = u ++ ⟨a, b''⟩ :: w ∧
236+
(sigma.mk a' b') :: (replace_aux a b t) = u ++ ⟨a, b⟩ :: w,
237237
{ simpa [replace_aux, ne.symm e, e] },
238238
intros x m,
239239
have IH : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (b'' : β a),
@@ -282,11 +282,12 @@ theorem valid.erase_aux (a : α) : Π (l : list (Σ a, β a)), a ∈ l.map sigma
282282
by_cases e : a' = a,
283283
{ subst a',
284284
simpa [erase_aux, and_comm] using show ∃ u w (x : β a),
285-
t = u ++ w ∧ sigma.mk a b' :: t = u ++ ⟨a, x⟩ :: w, from ⟨[], t, b', by simp⟩ },
285+
t = u ++ w ∧ (sigma.mk a b') :: t = u ++ ⟨a, x⟩ :: w,
286+
from ⟨[], t, b', by simp⟩ },
286287
{ simp [erase_aux, e, ne.symm e],
287288
suffices : ∀ (b : β a) (_ : sigma.mk a b ∈ t), ∃ u w (x : β a),
288-
sigma.mk a' b' :: t = u ++ ⟨a, x⟩ :: w ∧
289-
sigma.mk a' b' :: erase_aux a t = u ++ w,
289+
(sigma.mk a' b') :: t = u ++ ⟨a, x⟩ :: w ∧
290+
(sigma.mk a' b') :: (erase_aux a t) = u ++ w,
290291
{ simpa [replace_aux, ne.symm e, e] },
291292
intros b m,
292293
have IH : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (x : β a),

src/data/nat/prime.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,18 @@ show p^k*p ∣ m ∨ p^l*p ∣ n, from
421421
(assume : p ∣ m / p ^ k, or.inl $ mul_dvd_of_dvd_div hpm this)
422422
(assume : p ∣ n / p ^ l, or.inr $ mul_dvd_of_dvd_div hpn this)
423423

424+
/-- The type of prime numbers -/
425+
def primes := {p : ℕ // p.prime}
426+
427+
namespace primes
428+
429+
instance : has_repr nat.primes := ⟨λ p, repr p.val⟩
430+
431+
instance coe_nat : has_coe nat.primes ℕ := ⟨subtype.val⟩
432+
433+
theorem coe_nat_inj (p q : nat.primes) : (p : ℕ) = (q : ℕ) → p = q :=
434+
λ h, subtype.eq h
435+
436+
end primes
437+
424438
end nat

src/data/pnat.lean

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)