1 / 72

邏輯的世界 Logic

邏輯的世界 Logic. 陳鍾誠 2006 年於金門. 大綱 Outline. Boolean Logic ( 布林邏輯 ) First-Order Logic ( 一階邏輯 ). 何謂邏輯 ? What is Logic ?. A world of true and false. Data T , F. Function And (&) Or (|) Not (-). 邏輯系統的種類 Types of Logic. Propositional logic ( 命題邏輯 )

mcghees
Download Presentation

邏輯的世界 Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 邏輯的世界Logic 陳鍾誠 2006 年於金門

  2. 大綱Outline • Boolean Logic (布林邏輯) • First-Order Logic (一階邏輯)

  3. 何謂邏輯?What is Logic ? • A world of true and false. • Data • T , F • Function • And (&) • Or (|) • Not (-)

  4. 邏輯系統的種類Types of Logic • Propositional logic (命題邏輯) • Also known as Boolean Logic (§1.1-1.2): • Basic definitions. (§1.1) • Equivalence rules & derivations. (§1.2) • Predicate logic (述詞邏輯 或 謂詞邏輯) • Also known as First-Order Logic (§1.3-1.4) • Predicates. • Quantified predicate expressions. • Equivalences & derivations.

  5. 述詞邏輯Propositional Logic Propositional Logic is the logic of compound statements built from simpler statements using so-called Booleanconnectives. Some applications in computer science: • Design of digital electronic circuits. • Expressing conditions in programs. • Queries to databases & search engines. George Boole(1815-1864)

  6. 述詞邏輯的基本運算Propositional Logic – Operators

  7. 運算一:反相Negation operator - NOT

  8. 運算二:及Conjunction operator – AND

  9. 運算三:或Disjunction operator – OR

  10. 述詞邏輯的表示式Expressions of Propositional Logic • Use parentheses to group sub-expressions • Example : • m : male • c : child • m  c : male child (boy) • Example : • f (g  s)

  11. 運算四:互斥或Exclusive-Or – XOR

  12. 自然語言的語義不清楚Natural Language is Ambiguous Note that English “or” can be ambiguous regarding the “both” case! “Pat is a singer orPat is a writer.” - “Pat is a man orPat is a woman.” - Need context to disambiguate the meaning! For this class, assume “or” means inclusive.

  13. 運算五:導致The Implication Operator • p  q means p implies q. • If p is true, then q is true; • but if p is not true, then q could be either true or false. • Example : • E.g., let p = “You study hard.”q = “You will get a good grade.” • p  q = “If you study hard, then you will get a good grade.” (else, it could go either way)

  14. pq 的真值表Implication Truth Table • p  q is falseonly whenp is true but q is not true. • p  q does not saythat pcausesq! • p  q does not requirethat p or qare ever true! • E.g. “(1=0)  pigs can fly” is TRUE!

  15. Imply 運算  的範例Examples of Implications • “If this lecture ends, then the sun will rise tomorrow.” True or False? • “If Tuesday is a day of the week, then I am a penguin.” True or False? • “If 1+1=6, then Bush is president.” True or False? • “If the moon is made of green cheese, then I am richer than Bill Gates.” True or False?

  16. 三種反運算Converse, Inverse, Contrapositive Some terminology, for an implication p  q: • Its converseis: q  p. • Its inverse is: ¬p ¬q. • Its contrapositive: ¬q  ¬p. • One of these three has the same meaning (same truth table) as p q. Can you figure out which?

  17. p  q = -q  -p 兩者相等 How do we know for sure? Proving the equivalence of p  q and its contrapositive using truth tables:

  18. p q = p + q = p+q 利用真值表來證明Proving Equivalence via Truth Tables • -(-p-q) = pq Ex. Prove that pq  (p  q). F T T T F T T F F T T F T F T T F F F T • Demorgan’s Theorem : (笛摩根定律)

  19. p q 的真值表Biconditional Truth Table • p  q means that p and qhave the same truth value. • Note this truth table is theexact opposite of ’s! • p  q means ¬(p  q) • p  q does not implyp and q are true, or cause each other.

  20. 布林運算總整理Boolean Operations Summary • We have seen 1 unary operator (out of the 4 possible) and 5 binary operators (out of the 16 possible). Their truth tables are below.

  21. 布林運算的幾種符號表達法Some Alternative Notations

  22. Boolean Algebra- 把布林邏輯轉換為代數 陳鍾誠 2006 年於金門

  23. 位元運算Bits and Bit Operations • A bit is a binary (base 2) digit: 0 or 1. • Bits may be used to represent truth values. • By convention: 0 represents “false”; 1 represents “true”. • Boolean algebra is like ordinary algebra except that variables stand for bits, + means “or”, and multiplication means “and”. • See chapter 10 for more details. John Tukey(1915-2000)

  24. 布林代數的基本運算Boolean Operator • Boolean Complement (-) 1=0 0=1 • Boolean Sum (+) • Boolean Product (‧) 1‧1=1 1‧0=0 0‧1=0 0‧0=0 1+1=1 1+0=1 0+1=1 0+0=0

  25. 布林集合Boolean Set • Boolean Set : B • B = {0,1} • Example : 0 • n tuple boolean set • Bn = {(x1, x2, …, xn)| xiB for 1  i n} • Example : • (0,0) • (0,1) • (1,0) • (1,1)

  26. 布林變數Boolean Variable • The variable x is called a boolean variable if it assume values only from B, that is , if its only possible value are 0 and 1.

  27. 布林代數式Boolean Expression • Boolean expression • 0,1,x1,x2,…,xn • If E1 and E2 are Boolean expression, then the following expressions are boolean expressions • E1 • (E1E2) • (E1+E2) • Example : • 0 • x • (1+x) • (x+y)(zy) Counter example (反例) xy+)(+z

  28. 布林函數Boolean Function (1) • Boolean function of degree n • A function mapping from Bn to B • Example : • f(x,y) = xy

  29. 布林函數Boolean Function (2) • Drawing the truth table of • f(x,y,z) = xy + z

  30. Some Applications of Boolean Logic 陳鍾誠 2006 年於金門

  31. 布林邏輯的應用Applications of Boolean Logic • Circuit Design : • Building Truth Table • Minimizing the number of circuit • By Karnaugh Maps (卡諾圖) • Database Querying • Logical Inference in Artificial Intelligence • An extension of Boolean Logic called First-Order Logic • Example : Prolog,

  32. 電路設計中的布林代數Boolean Algebra in Circuit Design • Truth Table (真值表) • Karnaugh Maps (卡諾圖)

  33. 卡諾圖化簡方法Karnaugh Maps

  34. QM布林化簡法Quine-McCluskey Method • Minimizing the boolean expression with any number of variable (10.4, pp. 727).

  35. Circuit Design - Adder

  36. 邏輯推論Logical Reasoning 陳鍾誠 2006 年於金門

  37. 問題Question • 要幾條邏輯推論規則才能推出所有真理呢 ? p  T  p p  F  p p  T  T p  F  F p  p  p p  p  p p  p p  q  q  p p  q  q  p (p  q)  r  p  (q  r) (p  q)  r  p  (q  r) p(qr)  (pq)(pr) p(qr)  (pq)(pr) (pq)  p  q (pq)  p  q ….

  38. 邏輯推論的歷史History of Proof System • Aristotle • Boole • Hilbert • Gentzen • Robinson

  39. 亞里斯多德Aristotle • 三段論 • http://zh.wikipedia.org/wiki/%E9%A1%B9%E9%80%BB%E8%BE%91

  40. 經典範例1 • 這個例子是亞里士多德給出的經典的 "Barbara" 三段論: • 如果所有人(M)都是必死的(P), (大前提) • 並且所有希臘人(S)都是人(M), (小前提) • 那麼所有希臘人(S)都是必死的(P). (結論)

  41. 經典範例2 • 還有, • 所有人都是必死的. (普遍原理) • 蘇格拉底是人. (特殊陳述) • 蘇格拉底是必死的. (把特殊(小)代換入一般(大))

  42. 型式 1 • P  Q • Q  R • PR

  43. 型式 2 • P • P  Q • Q

  44. Mr. 洪Mr. Horn • Horn Clause • P1  …  Pk Q • P1 • … • Pk • Q

  45. 布爾George Boole • 真值表 • 從真值表可推出三段論嗎 ? • P • P  Q • Q

  46. Modus Ponens Hilbert

  47. Hilbert’s Axiom

  48. Axioms and Rules of Inference Gentzen

  49. Disjunction rules Conjunction rules Gentzen’s Rules (1)

  50. Gentzen’ Rules (2) • Implication rules • Negation rule

More Related