簡體   English   中英

使用 Curry-Howard 對應來證明下一個命題邏輯陳述的正確方法是什么?

[英]What is a correct way to prove the next propositional logic statement using Curry–Howard correspondence?

我正在研究庫里-霍華德函授。

給定命題邏輯語句: (¬p -> q) -> ((¬p -> ¬q) -> p)

我需要在 OCaml 中定義一個類型(作為命題)和一個 function(作為證明)。

我想出了下一個代碼並卡住了:

type empty = | ;; 
let ex58: (('p->empty) -> 'q) -> (('p->empty) -> ('q->empty)) -> 'p = fun f g -> g(f)

錯誤:

This expression has type ('p -> empty) -> 'q but an expression was expected of type 'p -> empty.

在進行此練習時,從為not引入類型構造函數開始可能會更容易:

type empty = |
type 'a not = 'a -> empty

然后使用明確的全稱量化來重寫練習:

let proof_by_contradiction: type p q. (p not -> q) -> (p not -> q not) -> p =
   ...

這應該會稍微改善錯誤消息

錯誤:此表達式的類型為 p not -> q 但預期的表達式類型為 p not = p -> empty

在開始這個練習之前,嘗試一下可能會很有用

let proof_by_negation:  type p q. (p -> q) -> (p -> q not) -> p not =
  ...

第一的。

我很確定這不是建設性的證明。

首先,請注意

¬¬p -> (¬p -> a)

成立(從¬¬p¬p您首先獲得虛假證明,然后通過 ex falso quodlibet 您獲得任何a )。

特別是,對於任何q

    ¬¬p -> ((¬p -> q) /\ (¬p -> ¬q))             // ("lemma")

成立(將先前的語句應用於a = qa = ¬q )。

現在,如果你的原始陳述((¬p -> q) /\ (¬p -> ¬q)) -> p是真的,那么你可以預先組合¬¬p -> ((¬p -> q) /\ (¬p -> ¬q)) ,因此獲得¬¬p -> p 但這是雙重否定消除,眾所周知,這是不可建設性地證明的。

這是 Scala 3 中的完整結構(與 OCaml 有點密切相關;這里使用的語言子集應該很容易翻譯成 OCaml):

type ¬[A] = A => Nothing                               // negation
type /\[A, B] = (A, B)                                 // conjunction / product
type Claim[P, Q] = (¬[P] => Q) => (¬[P] => ¬[Q]) => P  // your claim
type DoubleNegationElimination[P] = ¬[¬[P]] => P

/** Ex falso quodlibet. */
def efq[X]: Nothing => X = f => f

/** Lemma, as explained above. */
def lemma[P, Q](a: ¬[¬[P]]): (¬[P] => Q) /\ (¬[P] => ¬[Q]) =
  val left: ¬[P] => Q = notP => efq(a(notP))
  val right: ¬[P] => ¬[Q] = notP => efq(a(notP))
  (left, right)

/** This shows that if you could prove your claim for any `P`, `Q`,
  * then you would also be able to prove double negation elimination
  * for `P`.
  */
def claimImpliesDoubleNegationElimination[P, Q](
  c: Claim[P, Q]
): DoubleNegationElimination[P] =
  notNotP => {
    val (left, right) = lemma[P, Q](notNotP)
    c(left)(right)
  }

/** This is an (incomplete, because impossible) proof of the double
  * negation elimination for any `P`. It is incomplete, because it
  * relies on the validity of your original claim.
  */
def doubleNegationElimination[P]: DoubleNegationElimination[P] =
  claimImpliesDoubleNegationElimination(claim[P, Unit])

/** There cannot be a constructive proof of this, because otherwise
  * we would obtain a constructive proof of `doubleNegationElimination`.
  */
def claim[P, Q]: Claim[P, Q] = ???

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM