module Padova2025.ProvingBasics.Connectives.Disjunction where
Disjunction
In the previous couple sections, we have already stated and proved quite a few results. But we are still lacking the means to express other, quite basic, assertions, such as the following:
Every natural number is even or odd.
β(nββββ).Β (Even(n)β β¨β Odd(n))Every prime number greater than three is one more or one less than a multiple of six.
β(pββββ).Β (pβ>β3βββ(6β β£β pβ ββ 1β β¨β 6β β£β pβ +β 1))Beyond every natural number, there is a prime number.
β(nββββ).Β β(pββββ).Β (pβ>βnβ β§β pββββ)
The purpose of this module and the next ones is to fill this gap, and
introduce disjunction (β¨), conjunction (β§) and existential
quantification (β). Following the propositions as
types philosophy, we should for instance introduce a suitable type
of witnesses that a given number n
is even or odd. The
first result above would then be formalized by a function which reads an
arbitrary number n
as input and outputs such a kind of
witness.
Definition: Disjoint union
For expressing disjunction (β¨), for given types A
and
B
we introduce their disjoint union A β B
:
infixr 1 _β_ data _β_ (A : Set) (B : Set) : Set where left : A β A β B right : B β A β B -- In Haskell, `A β B` is known as `Either A B`.
In other words, the elements of A β B
are of the form
left x
for some x : A
, or right y
for some y : B
. The computational reading is that
left
is a function which inputs an element of type
A
and outputs an element of type A β B
, and
similarly with right
. The logical reading is that
A
implies A or B
. The type of witnesses that a
number n
is even or odd is then
Even n β Odd n
.
Exercise: Tautologies involving disjunction
open import Padova2025.ProvingBasics.Negation
β¨-comm : {A B : Set} β A β B β B β A β¨-comm = {!!}
β¨-assoc : {A B C : Set} β (A β B) β C β A β (B β C) β¨-assoc = {!!}
β¨-elim : {A B C : Set} β (A β C) β (B β C) β A β B β C β¨-elim = {!!}
β¨-map : {A A' B B' : Set} β (A β A') β (B β B') β A β B β A' β B' β¨-map = {!!}
β¨-codiag : {A : Set} β A β A β A β¨-codiag = {!!}
β¨-notβ : {A : Set} β A β β₯ β A β¨-notβ = {!!}
β¨-notβ : {A B : Set} β A β B β Β¬ B β A β¨-notβ = {!!}
Exercise: Even or odd
open import Padova2025.ProgrammingBasics.Naturals.Base open import Padova2025.ProvingBasics.EvenOdd
even-or-odd : (x : β) β Even x β Odd x even-or-odd = {!!}
not-odd-implies-even : (x : β) β Β¬ Odd x β Even x not-odd-implies-even = {!!}
Exercise: Successor of predecessor, revisited
open import Padova2025.ProgrammingBasics.Naturals.Arithmetic open import Padova2025.ProvingBasics.Equality.Base
We have already examined the equation succ(pred(a))β=βa, which only holds for positive natural numbers. Let us now prove the following variant:
lemma-succ-pred'' : (a : β) β succ (pred a) β‘ a β a β‘ zero lemma-succ-pred'' = {!!}
Exercise: Decidability of equality
open import Padova2025.ProvingBasics.Equality.General open import Padova2025.ProvingBasics.Equality.NaturalNumbers open import Padova2025.ProgrammingBasics.HigherOrder
Every natural number is either zero, or not. This assertion is trivial in classical mathematics for general logical reasons, as it is just an instance of the law of excluded middle (Aβ β¨β Β¬A). But there is also a direct proof, a proof which we can implement in Agda without having to postulate the law of excluded middle and thereby destroying Agdaβs by-default constructive mode.
zero? : (x : β) β (x β‘ zero) β Β¬ (x β‘ zero) zero? = {!!}
Unlike a proof relying on the law of excluded middle, this proof can
be runβtry it, within the Agda editing session, press
C-c C-v
and then input something like
zero? four
. The zero?
function will then
determine whether four
is zero, and compute a corresponding
witness.
This proof is a rare instance of an induction proof where the induction step does not use the induction hypothesis.
More generally, we have the result that any two numbers are equal or not:
eq? : (a b : β) β (a β‘ b) β Β¬ (a β‘ b) eq? = {!!}
Exercise: An oracle in the double negation monad
The following two tautologies are of supreme importance for the purpose of extracting constructive content from classical proofs, and also quite cryptic on first encounter.
¬¬-oracle : {A : Set} β Β¬ Β¬ (A β Β¬ A) ¬¬-oracle = {!!}
¬¬-bind : {A B : Set} β Β¬ Β¬ A β (A β Β¬ Β¬ B) β Β¬ Β¬ B ¬¬-bind = {!!}
Exercise: Law of excluded middle and double negation elimination
LEMβDNE : ((A : Set) β A β Β¬ A) β ((B : Set) β Β¬ Β¬ B β B) LEMβDNE = {!!}
DNEβLEM : ((B : Set) β Β¬ Β¬ B β B) β ((A : Set) β A β Β¬ A) DNEβLEM = {!!}