1 / 44

資訊科學數學 4 : More About Logic

資訊科學數學 4 : More About Logic. 陳光琦助理教授 (Kuang-Chi Chen) chichen6@mail.tcu.edu.tw. Logic - review.

mburgos
Télécharger la présentation

資訊科學數學 4 : More About 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. 資訊科學數學4:More About Logic 陳光琦助理教授 (Kuang-Chi Chen) chichen6@mail.tcu.edu.tw

  2. Logic - review Def. A proposition (p, q, r, …) is simply a statement (i.e., a declarative sentence) with a definite meaning, having a truth value that’s either true (T) or false (F) (never both, neither, or somewhere in between). • The unary negation operator “¬” (NOT) transforms a proposition into its logical negation. ¬p can be stated as “It’s not the case that p” ( ~p、~q(¬q)).

  3. Basic Connectives& Truth Tables

  4. Logical Connectives

  5. Meaning of Implication • “q is implied by p” • “q follows from p” • “q if p” • “q when p” • “q whenever p” • “q is necessary for p” • “p implies q” • “if p, then q” • “if p, q” • “when p, q” • “whenever p, q” • “p only if q” • “p is sufficient for q”

  6. Implication Implication: p→q,p 蘊含 q。 • “若 p則 q ” (if - then)。 • “p 對 q是充分的”or “p 是 q的充分條件”。 • “q 對 p是必要的”or “q 是 p的必要條件”。? • “p唯若 q ”。

  7. 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 get it? Contrapositive !

  8. Some Alternative Notations

  9. Bits & 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”. • More details later.

  10. Tautology & Contradiction • A tautology is a compound proposition that is trueno matter what the truth values of its atomic propositions are! Eg.,p  p. • A contradictionis a compound proposition that is false no matter what! Eg.,p  p. • Other compound propositions are contingencies.

  11. Tautology & Contradiction Def. A compound statement is called a tautologyif it is true for all truth value assignments for its component statement. If a compound statement is false for all such assignments, then it is called a contradiction. • Throughout this course we will use T0 and F0 to represent any tautology and contradiction, resp. # We use the ideas of tautology and implication to describe what we mean by a valid argument.

  12. Tautology & Contradiction • 若複合敘述對其敘述的所有真假值均為真,則被稱為重言(tautology,T0);若複合敘述對其敘述的所有真假值均為假,則被稱為矛盾(contradiction,F0 )。 # 在資訊科學,使用 重言 及 蘊含 的概念來描述一個 “有效的論證(valid argument)”。

  13. Logical Equivalence:The Laws of Logic

  14. Logical Equivalence • Compound proposition p is logically equivalentto compound proposition q, written p≡ q, IFFthe compound proposition pqis a tautology. • Compound propositions p and q are logically equivalent to each otherIFFp and q contain the same truth values as each other in all rows of their truth tables.

  15. Logically Equivalent Logically Equivalent (⇔, ≡) • 邏輯相等、實質相同、邏輯等價 • 兩敘述若邏輯等價 (logically equivalent),s1⇔s2,意謂 “當 敘述 s1為真時,若且唯若 敘述 s2為真”,“當 敘述 s1為假時,若且唯若 敘述 s2為假”。 • E.g., (p→q) ⇔ (~pⅴq) (p↔q) ⇔ (p→q) ^ (q→p) (p↔q) ⇔ (~pⅴq) ^ (~qⅴp)

  16. Example E.g., (p→q) ⇔ (~pⅴq) (p↔q) ⇔ (p→q) ^ (q→p) (p↔q) ⇔ (~pⅴq) ^ (~qⅴp)

  17. Equivalence Law • These are similar to the arithmetic identities you may have learned in algebra, but for propositional equivalences instead. • They provide a pattern or template that can be used to match all or part of a much more complicated proposition and to find an equivalence for it.

  18. Logic Law (p.1)

  19. Logic Law (p.2)

  20. Example 1 • In Pascal program segments shown below, x, y, z, and i are integer variables.

  21. Example 1 (cont’d) Part (a) z : = 4 ; For i : = 1 to 10 do Begin x : = z – i ; y : = z + 3*i ; If (( x > 0 ) and ( y > 0 )) then Writeln (‘ The value of the sum x + y is ’, x + y ) End;

  22. Example 1 (cont’d) Part (b) z : = 4 ; For i : = 1 to 10 do Begin x : = z – i ; y : = z + 3*i ; If x > 0 then If y > 0 then Writeln (‘ The value of the sum x + y is ’, x + y ) End;

  23. Example 1 (cont’d) • Part (a) use a decision structure comparable to a statement of the form (p ^ q)→r. • In part (b), we have p: x>0, q: y>0, which are statements when the variables x, y are assigned the values 4 – i (for x) and 4 + 3*i (for y). • Now, the letter r denotes the Writeln statement, an “executable statement” that is actually not a statement in the usual sense of a declarative sentence, which can be labeled true or false.

  24. Example 1 (cont’d) • In part (a), the total number of comparisons, (x > 0) and (y > 0), is 10 (for x > 0) + 10 (for y > 0) = 20. • In part (b), it’s the nested implications p→ (q→ r), therefore, (y > 0) is not executed unless the comparison (x > 0) is executed and evaluated as true. The total number of comparisons is 10 (for x > 0) + 3 (for y > 0, as i = 1, 2, 3) = 13. • Hence, program (b) is more efficient than (a).

  25. Example 2 Find a simpler way of the compound statement. Hence, we see that (pⅴq)^ ~(~p ^ q) ⇔ p .

  26. Example 3 • A switching network is made up of wires and switches connecting two terminals T1 and T2. In such a network, and switch is either open (0), or closed (1). • We have three networks. Part (a) contains one switch, and each of parts (b) and (c) contains two (independent) switches.

  27. Example 3 (cont’d) • Part (a): Part (b): Part (c):

  28. Example 3 (cont’d) • For part (a), a network with one switch. • For part (b), current flows from T1to T2 if either of the switches p or q is closed. We call this a parallel network and represent it by pⅴq. • For part (c), it requires that each of the switches p, q be closed in order for current to flow from T1 to T2. Here the switches are in series, and this network is represented by p ^ q.

  29. Example 4 • The switches in a network need not act independently of each other.

  30. Example 4 (cont’d) • The network is represented the corresponding statement (pⅴqⅴr)^(pⅴtⅴ~q)^(pⅴ~tⅴr). Using the laws of logic, we can find a simpler statement.

  31. Example 4 (cont’d)

  32. Example 4 (cont’d) • Hence (pⅴqⅴr)^(pⅴtⅴ~q)^(pⅴ~tⅴr) ⇔ pⅴ[(tⅴ~q) ^ r], and the new network shown below, which is equivalent to the original one. • This one has only four switches, five fewer than the original one.

  33. Defining Operators via Equivalences Using equivalences, we can define operators in terms of other operators. • Exclusive or : pq≡ (pq)(pq)pq≡ (pq)(qp) • Implies : pq ≡ p  q • Biconditional : pq ≡ (pq) (qp)pq ≡ (pq)

  34. Summary of Propositional Logic • Atomic propositions: p, q, r, … • Boolean operators:       • Compound propositions: s : (p q)  r • Equivalences:p q  (p  q) • Proof of equivalence: • Truth tables. • Symbolic derivations. p q  r …

  35. Logical Implication:Rules of Inference

  36. A Valid Argument Helping in proving theorems through the texts. • The general form of an argument: e.g., the implication: (p1 p2 p3 … pn)→ q . • Here n is a positive integer, the statements p1, p2, p3, …,pn are called the premises of the argument, and the statement q is conclusion for the argument. • The argument is valid if whenever : • Each premise p1, p2, p3, ..., pn is true, • then the conclusion q is likewise true.

  37. A Valid Argument (cont’d) # In fact, if any one of p1, p2, p3, ..., pn is false, then the hypothesis p1 p2 p3 … pn is false and the implication (p1 p2 p3 … pn)→ qis automatically TRUE, regardless of the truth value of q. • Hence, one way to establish the validity of a given argument is to show that the statements (p1 p2 p3 … pn)→ qis a TAUTOLOGY. (all truths)

  38. Example Let p, q, r be the primitive statements given as • p: Roger studies; q: Roger plays tennis; r: Roger passes discrete mathematics. Now, let p1,p2, p3 denote the premises • p1: If Roger studies, then he will pass discrete math. • p2: If Roger doesn’t play tennis, then he’ll study. • p3: Roger failed discrete math. Q: We want to determine whether the argument (p1 p2 p3)→ q is valid.

  39. Example (cont’d) To do so, we rewrite p1,p2, p3 as • p1: p→r ; • p2: ~q→p ; • p3: ~r . and examine the truth table for the implication (p1 p2 p3) → q i.e.,[(p→r)  (~q→p )  ~r] → q .

  40. Example (cont’d) Since the final column contains all 1’s, the implication is a tautology. Hence (p1 p2 p3)→ q is a valid argument.

  41. Logically Implication Def. If p, q are arbitrary statements such that p→q is a tautology, then we say that p logically implies q and we write p⇒q to denote this situation. • When p, q are any statements and p⇒q, the implication p→q is a tautology, and we refer to p →q as a logical implication. # We can avoid dealing with the idea of a tautology here by saying that p⇒q (i.e., p logically implies q) if q is true whenever p is true.

  42. Logically Implication (cont’d) Let p, q be arbitrary statements. 1) If p⇔q, then the statement p↔q is a tautology, so the statements have the same truth values. Under the conditions the statements p→q, q→p are tautologies, and we have p⇒q and q⇒p. 2) Conversely, suppose that p⇒q and q⇒p. The logical implicationp→qtells us that we never have statement p with the truth value 1 and q with the truth value 0. But could we have q with the truth value 1 and p with the truth value 0 ?

  43. Logically Implication (cont’d) • If this occurred, we could not have the logical implication q→p. Therefore, when p⇒q and q⇒p, the statements p, q have the same truth values and p⇔q. • Finally, the notation p⇒q is used to indicate that p→q is not a tautology – so the given implication (p→q) is not a logical implication.

More Related