Presentation is loading. Please wait.

Presentation is loading. Please wait.

資訊科學數學 4 : More About Logic 陳光琦助理教授 (Kuang-Chi Chen)

Similar presentations


Presentation on theme: "資訊科學數學 4 : More About Logic 陳光琦助理教授 (Kuang-Chi Chen)"— 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)). 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 Formal Name NicknameSymbol Conjunction operator AND Disjunction operator OR Exclusive-OR operator XOR Implication operator IMPLIES Biconditional operator IFF↔

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

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

7 Converse, Inverse, Contrapositive Some terminology, for an implication p  q: Its converse is: q  p. ( 逆命題 ) Its converse is: q  p. ( 逆命題 ) Its inverse is: ¬p  ¬q. ( 反逆命題 ) Its inverse is: ¬p  ¬q. ( 反逆命題 ) Its contrapositive:¬q  ¬ p. ( 變換命題 ) Its contrapositive:¬q  ¬ p. ( 變換命題 ) One of these three has the same meaning (same truth table) as p  q. Can you get it? One of these three has the same meaning (same truth table) as p  q. Can you get it? Contrapositive ! Contrapositive !

8 Some Alternative Notations

9 Bits & Bit Operations A bit is a binary (base 2) digit: 0 or 1. A bit is a binary (base 2) digit: 0 or 1. Bits may be used to represent truth values. Bits may be used to represent truth values. By convention: 0 represents “false”, 1 represents “true”. 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”. 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 true no matter what the truth values of its atomic propositions are! A tautology is a compound proposition that is true no matter what the truth values of its atomic propositions are! Eg., p   p. Eg., p   p. A contradiction is a compound proposition that is false no matter what! A contradiction is a compound proposition that is false no matter what! Eg., p   p. Eg., p   p. Other compound propositions are contingencies. Other compound propositions are contingencies.

11 Tautology & Contradiction Def. A compound statement is called a tautology if 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 T 0 and F 0 to represent any tautology and contradiction, resp. Throughout this course we will use T 0 and F 0 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 , T 0 );若複合敘 述對其敘述的所有真假值均為假,則被稱為 矛盾( contradiction , F 0 )。 若複合敘述對其敘述的所有真假值均為真, 則被稱為重言( tautology , T 0 );若複合敘 述對其敘述的所有真假值均為假,則被稱為 矛盾( contradiction , F 0 )。 # 在資訊科學,使用 重言 及 蘊含 的概念來描述一個 “ 有效的論證( valid argument ) ” 。

13 Logical Equivalence: The Laws of Logic Logical Equivalence: The Laws of Logic

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

15 Logically Equivalent Logically Equivalent ( ⇔, ≡ ) 邏輯相等、實質相同、邏輯等價 邏輯相等、實質相同、邏輯等價 兩敘述若邏輯等價 (logically equivalent) , s 1 ⇔ s 2 , 意謂 “ 當 敘述 s 1 為真時,若且唯若 敘述 s 2 為真 ” , “ 當 敘述 s 1 為假時,若且唯若 敘述 s 2 為假 ” 。 兩敘述若邏輯等價 (logically equivalent) , s 1 ⇔ s 2 , 意謂 “ 當 敘述 s 1 為真時,若且唯若 敘述 s 2 為真 ” , “ 當 敘述 s 1 為假時,若且唯若 敘述 s 2 為假 ” 。 E.g., ( p→q ) ⇔ (~ p ⅴ q ) E.g., ( p→q ) ⇔ (~ p ⅴ q ) ( p↔q ) ⇔ ( p→q ) ^ ( q→p ) ( p↔q ) ⇔ ( p→q ) ^ ( q→p ) ( 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) (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. 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. 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. 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 Begin x : = z – i ; x : = z – i ; y : = z + 3*i ; y : = z + 3*i ; If (( x > 0 ) and ( y > 0 )) then If (( x > 0 ) and ( y > 0 )) then Writeln (‘ The value of the sum x + y is ’, x + y ) Writeln (‘ The value of the sum x + y is ’, x + y ) End; End;

22 Example 1 (cont’d) Part (b) z : = 4 ; For i : = 1 to 10 do Begin Begin x : = z – i ; x : = z – i ; y : = z + 3*i ; y : = z + 3*i ; If x > 0 then If x > 0 then If y > 0 then If y > 0 then Writeln (‘ The value of the sum x + y is ’, x + y ) Writeln (‘ The value of the sum x + y is ’, x + y ) End; 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 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 (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. 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). 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 T 1 and T 2. In such a network, and switch is either open (0), or closed (1). A switching network is made up of wires and switches connecting two terminals T 1 and T 2. 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. 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): Part (a): Part (b): Part (c):

28 Example 3 (cont’d) For part (a), a network with one switch. For part (a), a network with one switch. For part (b), current flows from T 1 to T 2 if either of the switches p or q is closed. We call this a parallel network and represent it by p ⅴ q. For part (b), current flows from T 1 to T 2 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 T 1 to T 2. Here the switches are in series, and this network is represented by p ^ q. For part (c), it requires that each of the switches p, q be closed in order for current to flow from T 1 to T 2. 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. 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

32 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) Exclusive or : p  q ≡ (p  q)  (p  q) p  q ≡ (p  q)  (q  p) Implies : p  q ≡  p  q Implies : p  q ≡  p  q Biconditional : p  q ≡ (p  q)  (q  p) 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, … Atomic propositions: p, q, r, … Boolean operators:       Boolean operators:       Compound propositions: s :  (p   q)  r Compound propositions: s :  (p   q)  r Equivalences: p   q   (p  q) Equivalences: p   q   (p  q) Proof of equivalence: Proof of equivalence: – Truth tables. – Symbolic derivations. p  q  r …

35 Logical Implication: Rules of Inference Logical Implication: Rules of Inference

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

37 A Valid Argument (cont’d) # In fact, if any one of p 1, p 2, p 3,..., p n is false, then the hypothesis p 1  p 2  p 3  …  p n is false and the implication (p 1  p 2  p 3  …  p n ) → q is automatically TRUE, regardless of the truth value of q. 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 (p 1  p 2  p 3  …  p n ) → q is Hence, one way to establish the validity of a given argument is to show that the statements (p 1  p 2  p 3  …  p n ) → q is a TAUTOLOGY. (all truths) a TAUTOLOGY. (all truths)

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

39 Example (cont’d) To do so, we rewrite p 1, p 2, p 3 as p 1 : p→r ; p 1 : p→r ; p 2 : ~q →p ; p 2 : ~q →p ; p 3 : ~r. p 3 : ~r. and examine the truth table for the implication (p 1  p 2  p 3 ) → q (p 1  p 2  p 3 ) → 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. 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 implication p→q tells 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 ? 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. 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. 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.

44


Download ppt "資訊科學數學 4 : More About Logic 陳光琦助理教授 (Kuang-Chi Chen)"

Similar presentations


Ads by Google