Negation
Contents
{-# OPTIONS --without-K --safe #-} module negation where
Double and Triple Negation
First, let us import our skeleton Martin-LΓΆf Type Theory.open import mlttRecall that we defined maps to the empty type to indicate that either a type is empty or that the proposition it represents is false:
Β¬ A = A β π
. Iterating, we have the double and triple negation:
¬¬ : β {β} (A : Set β) β Set β ¬¬ A = Β¬ (Β¬ A)If
A
has a term, then it is non-empty: namely if a : A
then we are able to construct a term of ¬¬ A = (A β π) β π
¬¬-intro : β {β} {A : Set β} β A β (¬¬ A) ¬¬-intro a = Ξ» x β x aThere is no general procedure to implement the converse.1 In general this would amount to be able to choose, for each non-empty type
A
a term in it: this a form of global choice, ultimately, if assumed as a postulate, incompatible with univalence. Going further, the following is the straightforward contrapositive.
contra : β {β β'} {A : Set β} {B : Set β'} β (A β B) β (Β¬ B β Β¬ A) contra f = Ξ» y a β y (f a)
Note the proof: if a : A
, i.e.Β A
has a term, then so does B
via f
, and hence, by evaluating y : B β π
at it, we get a contradiction, i.e.Β something in π
.
¬¬¬ : β {β} (A : Set β) β Set β ¬¬¬ A = Β¬ (¬¬ A)and notice that three negation imply just one:
three-to-oneΒ¬ : β {β} {A : Set β} β ¬¬¬ A β Β¬ A three-to-oneΒ¬ = contra ( ¬¬-intro )In fact, an easy application of the
¬¬-intro
gives the converse to this statement:
one-to-threeΒ¬ : β {β} {A : Set β} β Β¬ A β ¬¬¬ A one-to-threeΒ¬ = Ξ» x β ¬¬-intro xThe type
(A β B) Γ (B β A)
corresponds to the logical equivalence of A
and B
. Formally:
_βΊ_ : β {β β'} β Set β β Set β' β Set (β β β') A βΊ B = (A β B) Γ (B β A)We can summarize the above by the statement
three-is-oneΒ¬ : β {β} (A : Set β) β Β¬ A ⺠¬¬¬ A Ξ£.fst (three-is-oneΒ¬ A) = one-to-threeΒ¬ {A = A} Ξ£.snd (three-is-oneΒ¬ A) = three-to-oneΒ¬ {A = A}
Negation of Equality
_β’_ : β {β} {A : Set β} β A β A β Set β x β’ y = Β¬ (x β‘ y)
Inequality also satisfies a symmetry condition analogous to β‘-inv = . β»ΒΉ
β’-inv : β {β} {A : Set β} {x y : A} β x β’ y β y β’ x β’-inv u = Ξ» p β u (p β»ΒΉ)
In the proof, given u : x β‘ y β π
, and given p : y β‘ x
, we evaluate u
at the inverse of p
.
Equality of Types and Function Types
Consider, for two typesA B : Set β
, the identity type A β‘ B
(note that A β‘ B : Set (lsuc β)
. This turns into (there is a map to) the type of functions, or implications, A β B
.
Id-to-Fun : β {β} {A B : Set β} β A β‘ B β A β B Id-to-Fun {β} {A} {.A} refl = id
By induction on p : A β‘ B
, we prove the statement by assigning to the reflexivity term of A
the identity function id : A β A
.
transport
function defined in MLTT.
Id-to-Fun' : β {β} {A B : Set β} β A β‘ B β A β B Id-to-Fun' {β} = transport (id {A = Set β})When we introduce the univalence principle, this correspondence will be part of a more interesting, or more complete, one between
A β‘ B
and the type of weak equivalences between A
and B
. The two versions agree:
Id-to-Fun-agree : β {β} {A B : Set β} (p : A β‘ B) β Id-to-Fun p β‘ Id-to-Fun' p Id-to-Fun-agree refl = idp (id )
Following are some interesting applications: we can prove that π β’ π
and that the terms β : π
and β : π
are not equal.
For the fact that π β’ π
, if p : π β‘ π
is a potential identification, then Id-to-Fun p : π β π
, and evaluating that at the sole constructor of π
derives a contradiction, i.e.Β something in π
.
one-is-not-zero : π β’ π one-is-not-zero = Ξ» p β Id-to-Fun p *As for the proving that
β : π
and β : π
are not equal, we can reduce it to the previous case: if p : β β‘ β
, we can map it to an identification q : π β‘ π
, which gives the sought-after contradiction:
β-is-not-β : β β’ β β-is-not-β p = one-is-not-zero q where q : π β‘ π q = ap (π-to-dep π π) pIn effect this in an instance of a more general statement, namely that in a sum type (disjoint union) the left and right constructors are not equal. That is, we have
inl-is-not-inr : β{β β'} {A : Set β} {B : Set β'} {a : A} {b : B} β inl a β’ inr b inl-is-not-inr {β} {β'} {A} {B} p = one-is-not-zero q where -- assign π to A and π to B f : A + B β Set f (inl a) = π f (inr b) = π q : π β‘ π q = ap f pOn the other hand, Agdaβs absurd pattern allows us to obtain a fast proof:
inl-is-not-inr' : β{β β'} {A : Set β} {B : Set β'} {a : A} {b : B} β inl a β’ inr b inl-is-not-inr' ()
Decidability
Alternative between A
and Β¬ A
:
decidable : β {β} β Set β β Set β decidable A = A + Β¬ A decidable-equality : β {β} β Set β β Set β decidable-equality A = (x y : A) β decidable (x β‘ y) -- Alternatively, write as: -- Ξ [ x β A ] Ξ [ y β A ] decidable (x β‘ y) -- Ξ [ xy β A Γ A ] decidable ( Οβ x β‘ Οβ y)
Formally, decidable equality states that for any two terms of a given type they either are equal, in the sense that there exists an identification, or not.
As an experiment, let us check that π
has a decidable equality:
π-decidable-equality : decidable-equality π π-decidable-equality β β = inl (idp β) π-decidable-equality β β = inr (β’-inv β-is-not-β) π-decidable-equality β β = inr (β-is-not-β) π-decidable-equality β β = inl (idp β)