1

There is a similar question here Is there an intuitionist (i.e., constructive) proof of the infinitude of primes? , but the answers aren't complete enough for me.

In the proof, we say that n+1 has a prime divisor. The way I would prove it classically is, if n+1 is prime then it's its own divisor, and if not then it has a divisor which by induction has a prime divisor.

However, this seems to require the assumption $p(n+1) \lor \lnot p(n+1)$ where $p(x)$ is the statement of primarility.

It seems it should be constructively valid since it's easy to compute whether a number is prime (by checking all pairs of numbers below it). However, even with a proof that $p(x)$ is equivalent to a statement with "quantifiers bounded" in $x$, I don't know how to get the excluded middle.

Can it be proven (in Peano axioms with constructive logic) without adding an extra rule that the excluded middle holds if all quantifiers are bounded?

  • 1
    There is n9 way to prove the infinity of primes constructively, because "infinite" is a negative term, literally meaning non-dinite. Euclid's proof constructively finds another prime given any finite set of primes, but you will always need proof my contradiction to show a set is infinite. – Thomas Andrews Aug 10 '24 at 01:43
  • 1
    You don't need to separate cases $n+1$ prime nd $n+1$ composite. You can just prove that the smallest factor of $n+1$ other than $1$ is always prime. – Thomas Andrews Aug 10 '24 at 01:45
  • @ThomasAndrews seems that the smallest factor has a similar problem as a prime one, would need excluded middle for "there is a smaller factor of n+1" – antilope Aug 10 '24 at 02:27
  • hmm maybe we can get it by induction on the bound of the quantifier – antilope Aug 10 '24 at 02:59
  • 4
    You can find a constructive proof of the statement $\forall n \in \mathbb{N}. p(n) \vee \neg p(n)$, formally checked by the Agda proof assistant, here. One can read this proof and turn it into a readable informal argument with the same conclusion, it goes through in e.g. Heyting arithmetic. (Note to mods: I won't post an answer. This reads like a classic I've tried nothing and I'm out of ideas question to me. Basically, I doubt any answer I'd write can ever be "complete enough" for the author). – Z. A. K. Aug 10 '24 at 05:09
  • 2
    Here's another Agda proof that primality is decidable. – Naïm Camille Favier Aug 10 '24 at 14:30
  • Is Euclid's proof not constructive? Iterating it allows you to form unboundedly large primes. If that's not enough, the Sieve of Eratosthenes constructs all primes and implies infinitude of primes. – Eric Snyder Aug 11 '24 at 01:19
  • 1
    @EricSnyder - how does the Sieve of Eratosthenes imply an infinitude of primes? I see nothing in it that guarantees that after each step there must be some remaining numbers. – Paul Sinclair Aug 12 '24 at 16:21
  • @PaulSinclair I think I mistyped--I thought I'd seen a proof of IP via just Eratosthenes, but I don't remember where and can't find it. That said, the Sieve is constructive and, when combined with Euclid's proof, together should be enough for a constructive proof, no? – Eric Snyder Aug 14 '24 at 01:23
  • @EricSnyder - What Euclid actually proves is that for any finite set of primes, there is a prime outside that set. This much is constructive. The remaining implication, that this means the set of primes is infinite, involves the law of the excluded middle, which is what antilope is trying to avoid. – Paul Sinclair Aug 14 '24 at 03:34

1 Answers1

6

I was going to let this one lie as well, but people keep commenting with incorrect statements about constructive mathematics. So...

Here is a formalization of Euclid's proof that the prime numbers are list avoiding (see below) in Agda. It uses machinery that the Agda standard library already had for calculating prime factorizations. Agda is constructive. The only way you can use classical reasoning is with an explicit hypothesis or by adding a postulate, the latter of which would cause errors with the --safe flag enabled. If you decide to try it out yourself, you'll see it has neither.

I simplified the argument a bit, too (at least, relative to what wikipedia gives). You can always just consider the first element in the prime factorization, because it can't divide the product of the original list, by Euclid's argument. If $1 + \prod_i^n p_i$ is prime, then it will just happen to be the only element of the prime factorization (but we don't actually care).

After that, I use a formalization of three different notions of 'infinite' to show that primes satisfy all three. They are:

  1. 'list avoiding' - there is a map from lists of values to values not in the list
  2. 'infinite'1 - there is an injection from the natural numbers to the type
  3. 'not finite' - there is no (finite) list that contains all values

I believe they are listed above in order of decreasing constructive strength. Every list avoiding type is infinite, and every infinite type is not finite, as demonstrated in that file (although the latter just appeals to the proof already in the standard library). This is all constructive.

It is just not correct to say that 'negative' statements are not constructive. Constructively, negation is usually defined as $¬P = P → ⊥$, where $⊥$ is the trivially false proposition. Proving a negative statement $¬P$ 'by contradiction' by e.g. showing that $P → Q$ and $P → ¬Q$, is just modus ponens. You can also look at it as negation introduction being fine, even though double negation elimination is (in general) not. This distinction is often not taught well (or at all), but it is significant.

I suppose one could say that proofs of negatives do not construct numbers, and this is true. But, for instance, proofs of $∀$ statements do not construct numbers for the quantifier, either. Proofs of negatives and $∀$ are supposed to accept an input and demonstrate something based on it, not produce a number.

Even stronger, it makes little sense to claim that infinitude of primes is not provable constructively because, as mentioned, the usual arguments prove something that is better suited to be the meaning of 'infinite' constructively than simply 'not finite.' What is often the case in constructive mathematics is that negative statements are weak. From knowing that a type is, 'not finite,' we cannot necessarily enumerate distinct values, or find a value distinct from some that are given.2 But Euclid's argument does prove that these are possible.

Lastly, just because excluded middle is not assumed to be a valid reasoning principle does not mean that it is false.3 What it means is that any instances you want to use must be proved. For many statements in number theory, their instance of excluded middle is provable using induction, or consequences thereof. This corresponds roughly to the statement being decidable by recursive algorithms. And of course, this includes primality, as mentioned in the comments.

[1] This is the typical constructive definition of, "infinite," because "not finite" is less useful. Just because "infinite" sounds negative doesn't mean it is actually taken to be a negated proposition. For instance, "inconsistent," is usually the positive statement, "there is a proof of ⊥," and, "consistent," is its negation.

[2] In cases like primality that are decidable, these notions of infinitude collapse somewhat. Depending on what principles you consider constructive, they might all be equivalent for decidable subsets of $ℕ$ (though not in general).

[3] In fact, excluded middle is provably not false in constructive mathematics. Both $¬¬(P ∨ ¬P)$ and $¬¬(¬¬P → P)$ are intuitionistic theorems.

Dan Doel
  • 4,608
  • I'm not sure how to edit the above answer to fix this, but there is one nit-pick to make in [3] above. Although ¬¬(∨¬) is an intuitionistic theorem, that's for a given proposition P. Whereas ¬¬EM would mean across all theorems, and that isn't provable. (Sources: https://us.metamath.org/ileuni/nndc.html or https://mathoverflow.net/questions/452678/does-negative-trichotomy-hold-for-constructive-ordinals/475265#475265 ). – Jim Kingdon Sep 10 '24 at 04:09
  • The answer already includes unambiguous symbolic clarifications of what I meant by the English statement. It is the actually relevant information, as well, since it is attempting to dispel the common, naive idea that excluded middle is false for particular propositions $P$ in constructive mathematics. – Dan Doel Sep 10 '24 at 05:08
  • If we are talking about a particular proposition P there is no problem, so I won't belabor the point. – Jim Kingdon Sep 11 '24 at 14:50