-
Notifications
You must be signed in to change notification settings - Fork 156
Prime (and composite) numbers #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @qlbrpl , thanks for contributing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! I only have minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my own two cents
| decToN (yes _) = 1 | ||
| decToN (no _) = 0 | ||
|
|
||
| data All {A : Type ℓ} (P : A → Type ℓ') : List A → Type (ℓ-max ℓ ℓ') where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be a private definition here because it's useful in other places, you should move it to Data.List
| mapAll f [] = [] | ||
| mapAll f (Px ∷ Pxs) = f Px ∷ mapAll f Pxs | ||
|
|
||
| add-equations : ∀ {a} {b} {c} {d} → a ≡ b → c ≡ d → a + c ≡ b + d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cong₂ _+_ (cong₂ is defined in the prelude)
| <≠ {m = m} m<n m=n = <-asym m<n (0 , sym m=n) | ||
|
|
||
|
|
||
| DecProd-aux : {A : Type ℓ} (P : A → Type ℓ') (Q : A → Type ℓ'') → ∀ {a} → |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be in Cubical.Relation.Nullary.DecidablePropositions
| q1=q2 : q1 ≡ q2 | ||
| q1=q2 = inj-·0< q1 q2 (<-weaken 1<p1) (pq=n ∙ sym (subst (λ x → x · q2 ≡ n) (sym p1=p2) pq=n')) | ||
|
|
||
| leastProp : ∀ x → isProp ((p2' : ℕ) → 1 < p2' → p2' ∣ n → x ≤ p2') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this could also be useful elsewhere, you might want to extract this out (or make it a named where block so the definitions are accessible outside)
|
|
||
| step→ : {A : Type ℓ} (B : Type ℓ') → (A → B) → A → B | ||
| step→ _ f = f | ||
| step⇒ : {A : Type ℓ} (B : Type ℓ') → (A → B) → A → B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't related to primes, and it could be useful in other places so this could be moved to Foundations.Function
| -- All and mapAll | ||
| -- All | ||
|
|
||
| data All {A : Type ℓ} (P : A → Type ℓ') : List A → Type (ℓ-max ℓ ℓ') where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated in Data.Nat.Count
|
@felixwellen Are there any more changes you're looking for on this, or is it ready to be merged? |
Defined and formalized a bunch of properties of prime and composite numbers, all working up to the ultimate result of proving that ℕ is isomorphic to Σ ℕ isPrime. This is my first pull request, and I only started learning Agda about a month ago; constructive criticism of any sort is very much appreciated!