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

Slides:



Advertisements
Similar presentations
Chapter 2 Fundamentals of Logic Dept of Information management National Central University Yen-Liang Chen.
Advertisements

CS128 – Discrete Mathematics for Computer Science
Chapter 2 Fundamentals of Logic
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
From Chapter 4 Formal Specification using Z David Lightfoot
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Propositional Calculus Math Foundations of Computer Science.
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction Assume that we are given an infinite supply of stamps of two different denominations, 3 cents and and 5 cents. Prove using mathematical.
Adapted from Discrete Math
Methods of Proof & Proof Strategies
Propositions and Truth Tables
1.1 Sets and Logic Set – a collection of objects. Set brackets {} are used to enclose the elements of a set. Example: {1, 2, 5, 9} Elements – objects inside.
Chapter 2 – Fundamentals of Logic. Outline Basic Connectives and Truth Tables Logical Equivalence: The Laws of Logic Ligical Implication: Rules of Inference.
2009/9 1 Logic and Proofs §1.1 Introduction §1.2 Propositional Equivalences §1.3 Predicates and Quantifiers §1.4 Nested Quantifiers §1.5~7 Methods of Proofs.
Discrete Maths 2. Propositional Logic Objective
Discrete Mathematics and Its Applications
2009/9 1 Logic and Proofs §1.1 Introduction §1.2 Propositional Equivalences §1.3 Predicates and Quantifiers §1.4 Nested Quantifiers §1.5~7 Methods of.
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Chapter 1: The Foundations: Logic and Proofs
Discrete Mathematics Chapter 1 The Foundations : Logic and Proofs 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
Review I Rosen , 3.1 Know your definitions!
Chap. 2 Fundamentals of Logic. Proposition Proposition (or statement): an declarative sentence that is either true or false, but not both. e.g. –Margret.
2.3Logical Implication: Rules of Inference From the notion of a valid argument, we begin a formal study of what we shall mean by an argument and when such.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 7 Review Important Terms, Symbols, Concepts 7.1. Logic A proposition is a statement (not a question.
Lecture 4. CONDITIONAL STATEMENTS: Consider the statement: "If you earn an A in Math, then I'll buy you a computer." This statement is made up of two.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Reading: Chapter 4 (44-59) from the text book
SSK3003 DISCRETE STRUCTURES
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems or solving problems, creativity and insight.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Chapter 7 Logic, Sets, and Counting
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Chapter 7 Logic, Sets, and Counting Section 1 Logic.
Section 1.2: Propositional Equivalences In the process of reasoning, we often replace a known statement with an equivalent statement that more closely.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
LOGIC AND QUANTIFIERS. INTRODUCTION Many algorithms and proofs use logical expressions such as: “IF p THEN q” or “If p1 AND p2, THEN q1 OR q2” Therefore.
Chapter 1: The Foundations: Logic and Proofs
Logic UNIT 1.
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU1 Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems.
Chapter 1 Logic and proofs
Logical Operators (Connectives) We will examine the following logical operators: Negation (NOT,  ) Negation (NOT,  ) Conjunction (AND,  ) Conjunction.
Chapter 1 Propositional Logic
Logic.
2. The Logic of Compound Statements Summary
DISCRETE MATHEMATICS CHAPTER I.
CSNB 143 Discrete Mathematical Structures
Discrete Mathematics Logic.
6/20/2018 Arab Open University Faculty of Computer Studies M131 - Discrete Mathematics 6/20/2018.
COT 3100, Spr Applications of Discrete Structures
(CSC 102) Discrete Structures Lecture 2.
The Foundations: Logic and Proofs
Principles of Computing – UFCFA3-30-1
Chapter 8 Logic Topics
Propositional Calculus: Boolean Algebra and Simplification
Information Technology Department
Propositional Equivalence (§1.2)
Applied Discrete Mathematics Week 1: Logic
Discrete Mathematics and Its Applications Kenneth H
Discrete Mathematics Logic.
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Cs Discrete Mathematics
Foundations of Discrete Mathematics
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
The Foundations: Logic and Proofs
Presentation transcript:

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

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)).

Basic Connectives & Truth Tables

Logical Connectives Formal Name NicknameSymbol Conjunction operator AND Disjunction operator OR Exclusive-OR operator XOR Implication operator IMPLIES Biconditional operator IFF↔

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”

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 ” 。

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 !

Some Alternative Notations

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.

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.

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.

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

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

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.

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 )

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)

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.

Logic Law (p.1)

Logic Law (p.2)

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.

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;

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;

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.

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).

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

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.

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

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.

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.

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.

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.

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)

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 …

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

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.

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)

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.

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.

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.

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.

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 ?

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.