I am studying Curry–Howard correspondence.
Given propositional logic statement: ¬(p ∨ q) -> (¬p ∧ ¬q).
I need to define a type (as proposition) and a function (as a proof) in OCaml.
I have defined type but do not know how to implement function:
type empty = |
type ('a , 'b) coprod = Left of 'a | Right of 'b
let ex513: (('p, 'q) coprod -> empty) -> ('p -> empty) * ('q -> empty) = fun ?
What I did before posting a question:
- I have verified that this statement is provable in intuitionistic logic.
- Tried to understand constructively: if there is
function1that converts proof of p or proof of q to ⊥ then we can construct tuple (function2that converts proof of p to ⊥,function3that converts proof of q to ⊥). Implementation(function1(p), function1(q)) - Implemented similar task to better understand the problem:
p ∨ q -> ¬(¬p ∧ ¬q).
code:
let func1: ('p, 'q) coprod -> ('p-> empty) * ('q-> empty) -> empty = fun x (f, g)->
match x with
| Left x -> f(x)
| Right x -> g(x)
Defining
for the sake of concision, it is indeed a good idea to write a function
and
Once you have defined both functions (in other words proved the corresponding lemma), the solution can be reached by applying both lemma:
If you have trouble writing the
left_branch(or right function), remember thathas type
'a -> ('a,'any) coprod.