【发布时间】:2022-01-26 13:43:10
【问题描述】:
我正在研究库里-霍华德的对应关系。
给定命题逻辑语句:¬(p ∨ q) -> (¬p ∧ ¬q)。
我需要在 OCaml 中定义一个类型(作为命题)和一个函数(作为证明)。
我已经定义了类型但不知道如何实现功能:
type empty = |
type ('a , 'b) coprod = Left of 'a | Right of 'b
let ex513: (('p, 'q) coprod -> empty) -> ('p -> empty) * ('q -> empty) = fun ?
在发布问题之前我做了什么:
- I have verified 这个陈述在直觉逻辑中是可以证明的。
- 试图建设性地理解:如果有
function1将p的证明或q的证明转换为⊥,那么我们可以构造元组(function2将p的证明转换为⊥,function3将q的证明转换为到⊥)。执行(function1(p), function1(q)) - 实施了类似的任务以更好地理解问题:
p ∨ q -> ¬(¬p ∧ ¬q)。
代码:
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)
【问题讨论】:
标签: types functional-programming ocaml type-inference curry-howard