> {-# LANGUAGE RankNTypes #-}
I was wondering if there was a way to represent the axiom of choice in haskell and/or some other functional programming language.
As we know, false is represented by the type with no values (Void
in haskell).
> import Data.Void
We can represent negation like so
> type Not a = a -> Void
We can express the law of excluded middle for a type a
like so
> type LEM a = Either a (Not a)
This means we can make classical logic into a Reader
monad
> type Classical a = (forall r. LEM r) -> a
We can, for example, do double negation elimination in it
> doubleneg :: Classical (Not (Not a) -> a)
> doubleneg = \lem nna -> either id (absurd . nna) lem
We can also have a monad where the law of excluded middle fails
> type AntiClassical a = Not (forall r. LEM r) -> a
Now the question is, how can we make a type that represents the axiom of choice? The axiom of choice talks about sets of sets. This implies we would need types of types or something. Is there something equivalent to the axiom of choice that could be encoded? (If you can encode the negation, just combine it with the law of excluded middle). Maybe trickery would allow us to have types of types.
Note: Ideally, it should be a version of the axiom of choice that works with Diaconescu's theorem.
This is just a hint.
The axiom of choice can be expressed as:
More precisely
given
Above,
choice
is indeed provable. Indeed,h
assigns to eachx
a (dependent) pair whose first componenty
is an element ofA
and the second component is a proof that the first indeed satisfiesP x y
. Instead, thef
in the thesis must assign tox
onlyy
, without any proof.As you see, obtaining the choice function
f
fromh
is just a matter of discarding the proof component in the pair.There's no need to extend Agda with LEM or any other axiom to prove this. The above proof is entirely constructive.
If we were using Coq, note that Coq forbids to eliminate a proof (such as
h : ... -> Prop
) to construct a non-proof (f
), so translating this into Coq directly fails. (This is to allow program extraction.) However, if we avoid theProp
sort of Coq and useType
directly, then the above can be translated.You may want to use the following projections for this exercise: