module Padova2025.ProvingBasics.Negation where
Negation
In mathematical logic, the negation Β¬P of a proposition P is defined as βassuming P implies a contradictionβ, that is as the implication (Pββββ―).
To adopt this definition in Agda, we introduce a type β₯
which does not have any inhabitants:
data β₯ : Set where -- enter `β₯` by `\bot` -- no constructors, so the type `β₯` is manifestly empty
Hence proving a negation Β¬P
in Agda means to construct a function which maps witnesses of P to witnesses of β―, i.e.Β to values
of type β₯
.
We can also introduce the negation symbol in Agda:
Β¬_ : Set β Set -- enter `Β¬` as `\neg` Β¬ P = (P β β₯)
Exercise: One is not even
open import Padova2025.ProgrammingBasics.Naturals.Base open import Padova2025.ProvingBasics.EvenOdd
An immediate consequence from the definition of Even
,
but nevertheless quite instructive at this point, is the result that the
number one
is not even.
one-not-even : Even one β β₯ one-not-even = {!!}
- As usual, introduce a variable on the left of the
=
sign:one-not-even p = {!!}
- Then, also as usual, press
C-c C-c
to ask Agda to do a case split onp
. - Agda will then notice that there are no possible cases and indicate
this observation with the empty pattern
()
.
Exercise: No simultaneously even and odd numbers
even-and-odd : {a : β} β Even a β Odd a β β₯ even-and-odd = {!!}
Exercise: An inductive type without a base case
Let us consider the following variant of the definition of the natural numbers:
data Weird : Set where succ : Weird β Weird
How many values of type Weird
are there?
Given an inhabitant x
of type Weird
, its
sole constructor succ
could be used to obtain the further
inhabitant succ x
. Applying succ
again would
result in yet another inhabitant, and so on. But we do not have any
inhabitants to start with; the constructor succ
is of no
use; the type Weird
is empty.
What about the infinite expression
succ (succ (succ (...)))
? Does this expression not denote a
value of type Weird
?
No β non-terminating expressions like these are not allowed for datatypes. Try it:
loop : Weird
loop = succ loop
Specific kinds of non-terminating expressions are possible for so-called co-datatypes, but we will not discuss those here.
We can formalize this observation in Agda as follows, expressing the
following implication: If there would be an inhabitant of
Weird
, then a contradiction would ensue.
Weird-is-empty : Weird β β₯ Weird-is-empty = {!!}
Exercise: Ex falso quodlibet
In (both classical and intutionistic, but not minimal) logic, from a
contradiction any statement follows. In Agda, we have the parallel fact
we have a function β₯ β A
for any type A
:
β₯-elim : {A : Set} β β₯ β A β₯-elim = {!!}