我是Mathematica(v8)的新手,正在使用它來編程命題邏輯。Mathematica If-then vs. Implies
我想知道If
和Implies
運營商之間有什麼區別。例如,
If[p,q]
和Implies[p,q]
返回q
對於p=True
(如預期)。
但是,當我試圖獲得SatisfiabilityInstances,我得到如下:
SatisfiabilityInstances[If[p, q], {p, q}]
(*
{{True, True}}
*)
,除非我問它的多個實例:
SatisfiabilityInstances[If[p, q], {p, q}, All]
SatisfiabilityInstances :: BOOLV:「如果[P ,q]不是布爾值{False,True}。
但是:
SatisfiabilityInstances[Implies[p, q], {p, q}, All]
返回預期出:
(* {{True, True}, {False, True}, {False, False}} *)
是什麼原因造成的產出這種差異?
,你能告訴我一個很好的教程?我讀過Mathematica文檔,但並不知道可以給出'If'四個值(if-else只有三個)。 '如果[a,b,c,d]'沒有賦予任何真值,返回'd' - 爲什麼? @Dims – QuietThud
@QuietThud'如果[條件,真子句,假子句,非真或假子句]' –
謝謝@belisarius。 =)我會很感激推薦一個數學。程序設計學習資源 - 文檔可以更好地作爲參考。 – QuietThud