Skip to content

Conversation

@qlbrpl
Copy link

@qlbrpl qlbrpl commented Jul 16, 2025

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!

@felixwellen
Copy link
Collaborator

Hi @qlbrpl , thanks for contributing!

Copy link
Collaborator

@felixwellen felixwellen left a 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.

@felixwellen felixwellen self-assigned this Jul 16, 2025
Copy link
Contributor

@anshwad10 anshwad10 left a 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
Copy link
Contributor

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
Copy link
Contributor

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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@qlbrpl
Copy link
Author

qlbrpl commented Aug 24, 2025

@felixwellen Are there any more changes you're looking for on this, or is it ready to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants