Module #1 - Logic 2016/7/91 Module #1: Logic (Textbook: §1.1~1.4) Dr. Chih-Wei Yi Department of Computer Science National Chiao Tung University.

Slides:



Advertisements
Similar presentations
CS 285- Discrete Mathematics
Advertisements

Foundations of Logic Mathematical Logic is a tool for working with elaborate compound statements. It includes: A formal language for expressing them.
2009/91 Predicates and Quantifiers (§1.3) In the sentence “x is greater than 3”: The phrase “x” denotes the subject - the object or entity that the sentence.
1 Predicate Logic Rosen 6 th ed., § Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Logic Chapter 2. Proposition "Proposition" can be defined as a declarative statement having a specific truth-value, true or false. Examples: 2 is a odd.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
First Order Logic. Propositional Logic A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not.
Logic Truth Tables, Propositions, Implications. Statements Logic is the tool for reasoning about the truth or falsity of statements. –Propositional logic.
The Foundations: Logic and Proofs
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
Logical Equivalence & Predicate Logic
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
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.
CompSci 102 Discrete Math for Computer Science January 17, 2012 Prof. Rodger.
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.
1 Propositional Logic Rosen 5 th ed., § Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence.
Propositional Logic Foundations of Logic: Overview Propositional logic (§ ): – Basic definitions. (§1.1) – Equivalence rules & derivations. (§1.2)
CS 285- Discrete Mathematics Lecture 2. Section 1.1 Propositional Logic Propositions Conditional Statements Truth Tables of Compound Propositions Translating.
Chapter 1: The Foundations: Logic and Proofs
1.1 CompSci 102© Michael Frank Today’s topics Propositional equivalencesPropositional equivalences Predicate logicPredicate logic Reading: Sections Reading:
Review I Rosen , 3.1 Know your definitions!
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Predicates and Quantified Statements
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.
Chapter 1: The Foundations: Logic and Proofs
The Foundations: Logic and Proof, Sets, and Foundations PROPOSITIONS A proposition is a declarative sentence that is either True or False, but not the.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
CSci 2011 Recap ^Propositional operation summary not andorconditionalBi-conditional pq ppqqpqpqpqpqpqpqpqpq TTFFTTTT TFFTFTFF FTTFFTTF FFTTFFTT.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Chapter 1. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
Logic I 권태경 To do so, it should include a language to express statements, a notation to simplify expressions. Logic Mathematical Logic.
Simple Logic.
Discrete Structures for Computer Science Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #1: Introduction, Propositional Logic August.
Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]
Propositional Logic.
Advanced Algorithms Analysis and Design
CSNB 143 Discrete Mathematical Structures
Lecture 1 – Formal Logic.
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
6/20/2018 Discrete Math A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different.
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.
Ch.1 (Part 1): The Foundations: Logic and Proofs
Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]
Mathematics for Computing
Propositional Logic (§1.1)
CMSC Discrete Structures
The Foundations: Logic and Proofs
Principles of Computing – UFCFA3-30-1
Copyright © Cengage Learning. All rights reserved.
CSCI 3310 Mathematical Foundation of Computer Science
CS100: Discrete structures
Information Technology Department
Propositional Equivalence (§1.2)
CS 220: Discrete Structures and their Applications
CHAPTER 1: LOGICS AND PROOF
Discrete Mathematics and its Applications
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Cs Discrete Mathematics
Predicates and Quantifiers
Copyright © Cengage Learning. All rights reserved.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Discrete Structures Prepositional Logic 2
The Foundations: Logic and Proofs
Presentation transcript:

Module #1 - Logic 2016/7/91 Module #1: Logic (Textbook: §1.1~1.4) Dr. Chih-Wei Yi Department of Computer Science National Chiao Tung University

Module #1 - Logic 2016/7/92 Definition of a Proposition A proposition (p, q, r, …) is 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). However, you might not know the actual truth value, and it might be situation-dependent.

Module #1 - Logic 2016/7/93 Examples of Propositions “It is raining.” (In a given situation.) “Washington D.C. is the capital of China.” “1 + 2 = 3” But, the following are NOT propositions: “Who’s there?” (interrogative, question) “La la la la la.” (meaningless interjection) “Just do it!” (imperative, command) “1 + 2” (expression with a non-true/false value)

Module #1 - Logic 2016/7/94 Some Popular Boolean Operators Formal NameNicknameAritySymbol Negation operatorNOTUnary¬ Conjunction operatorANDBinary  Disjunction operatorORBinary  Exclusive-OR operatorXORBinary  Implication operatorIMPLIESBinary  Biconditional operatorIFFBinary↔

Module #1 - Logic 2016/7/95 Precedence of Logical Operators Use parentheses to group sub- expressions, for example “I just saw my old friend, and either he’s grown or I’ve shrunk.” = f  (g  s) (f  g)  s would mean something different f  g  s would be ambiguous By convention, “¬” takes precedence over both “  ” and “  ”. ¬s  f means (¬s)  f, not ¬ (s  f)

Module #1 - Logic 2016/7/96 A Simple Exercise Let p = “It rained last night.”, q = “The sprinklers came on last night.”, and r = “The lawn was wet this morning.” Translate each of the following into English: ¬p= r  ¬p= ¬ r  p  q= “It didn’t rain last night.” “The lawn was wet this morning, and it didn’t rain last night.” “Either the lawn wasn’t wet this morning, or it rained last night, or the sprinklers came on last night.”

Module #1 - Logic 2016/7/97 The Exclusive Or Operator The binary exclusive-or operator “  ” (XOR) combines two propositions to form their logical “exclusive or” (exjunction?). p = “I will earn an A in this course,” q = “I will drop this course,” p  q = “I will either earn an A for this course, or I will drop it (but not both!)”

Module #1 - Logic 2016/7/98 Note that p  q means that p is true, or q is true, but not both! This operation is called exclusive or, because it excludes the possibility that both p and q are true. “¬” and “  ” together are not universal. Exclusive-Or Truth Table Note difference from OR.

Module #1 - Logic 2016/7/99 Note that English “or” can be ambiguous regarding the “both” case! “Pat is a singer or Pat is a writer.” - “Pat is a man or Pat is a woman.” - Need context to disambiguate the meaning! For this class, assume “or” means inclusive. Natural Language is Ambiguous  

Module #1 - Logic 2016/7/910 The Implication Operator The implication p  q states that p implies q. In other words, if p is true, then q is true; but if p is not true, then q could be either true or false. For example, let p = “You study hard.” and q = “You will get a good grade.”. Then p  q = “If you study hard, then you will get a good grade.” (else, it could go either way) antecedentconsequent

Module #1 - Logic 2016/7/911 Implication Truth Table p  q is false only when p is true but q is not true. p  q does not say that p causes q! p  q does not require that p or q are ever true! e.g. “(1=0)  pigs can fly” is TRUE! The only False case!

Module #1 - Logic 2016/7/912 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?

Module #1 - Logic 2016/7/913 Why does this seem wrong? Consider a sentence like, “If I wear a red shirt tomorrow, then the U.S. will attack Iraq the same day.” In logic, we consider the sentence True so long as either I don’t wear a red shirt, or the US attacks. But in normal English conversation, if I were to make this claim, you would think I was lying. Why this discrepancy between logic & language?

Module #1 - Logic 2016/7/914 Resolving the Discrepancy In English, a sentence “if p then q” usually really implicitly means something like, “In all possible situations, if p then q.” That is, “For p to be true and q false is impossible.” Or, “I guarantee that no matter what, if p, then q.” This can be expressed in predicate logic as: “For all situations s, if p is true in situation s, then q is also true in situation s” Formally, we could write:  s, P(s) → Q(s) This sentence is logically False in our example, because for me to wear a red shirt and the U.S. not to attack Iraq is a possible (even if not actual) situation. Natural language and logic then agree with each other.

Module #1 - Logic 2016/7/915 English Phrases Meaning p  q “p implies q” “if p, then q” “if p, q” “when p, q” “whenever p, q” “q if p” “q when p” “q whenever p” “p only if q” “p is sufficient for q” “q is necessary for p” “q follows from p” “q is implied by p” We will see some equivalent logic expressions later.

Module #1 - Logic 2016/7/916 Converse, Inverse, Contrapositive Some terminology, for an implication p  q: Its converse is: 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?

Module #1 - Logic 2016/7/917 How do we know for sure? Proving the equivalence of p  q and its contrapositive using truth tables:

Module #1 - Logic 2016/7/918 The biconditional operator The biconditional p  q states that p is true if and only if (IFF) q is true. For example, p = “Bush wins the 2004 election.” q = “Bush will be president for all of 2005.” p  q = “If, and only if, Bush wins the 2004 election, Bush will be president for all of 2005.” 2004 I’m still here! 2005

Module #1 - Logic 2016/7/919 Biconditional Truth Table p  q means that p and q have the same truth value. Note this truth table is the exact opposite of  ’s! p  q means ¬(p  q) p  q does not imply p and q are true, or cause each other.

Module #1 - Logic 2016/7/920 Equivalence Laws 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.

Module #1 - Logic 2016/7/921 Equivalence Laws - Examples Identity:p  T  p;p  F  p Domination:p  T  T;p  F  F Idempotent:p  p  p;p  p  p Double negation:  p  p Commutative:p  q  q  p; p  q  q  p Associative:(p  q)  r  p  (q  r) (p  q)  r  p  (q  r)

Module #1 - Logic 2016/7/922 More Equivalence Laws Distributive: p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r) De Morgan’s:  (p  q)   p   q  (p  q)   p   q Trivial tautology/contradiction: p   p  T p   p  F

Module #1 - Logic 2016/7/923 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)

Module #1 - Logic 2016/7/924 An Example Problem Check using a symbolic derivation whether (p   q)  (p  r)   p  q   r. (p   q)  (p  r) [Expand definition of  ]   (p   q)  (p  r) [Definition of  ]   (p   q)  ((p  r)   (p  r)) [DeMorgan’s Law]  (  p  q)  ((p  r)   (p  r)) [  commutes]  (q   p)  ((p  r)   (p  r))

Module #1 - Logic 2016/7/925 Example Continued... [  associative]  q  (  p  ((p  r)   (p  r))) [distrib.  over  ]  q  (((  p  (p  r))  (  p   (p  r))) [assoc.]  q  (((  p  p)  r)  (  p   (p  r))) [trivial taut.]  q  ((T  r)  (  p   (p  r))) [domination]  q  (T  (  p   (p  r))) [identity]  q  (  p   (p  r))

Module #1 - Logic 2016/7/926 End of Long Example [DeMorgan’s]  q  (  p  (  p   r)) [Assoc.]  q  ((  p   p)   r) [Idempotent]  q  (  p   r) [Assoc.]  (q   p)   r [Commut.]   p  q   r (Which was to be shown.)

Module #1 - Logic 2016/7/927 Quantifier Expressions Quantifiers provide a notation that allows us to quantify (count) how many objects in the univ. of disc. satisfy a given predicate. “  ” is the FOR  LL or universal quantifier.  x P(x) means for all x in the u.d., P holds. “  ” is the  XISTS or existential quantifier.  x P(x) means there exists an x in the u.d. (that is, 1 or more) such that P(x) is true. Topic #3 – Predicate Logic

Module #1 - Logic 2016/7/928 The Universal Quantifier  Example: Let the u.d. of x be parking spaces at NCTU. Let P(x) be the predicate “x is full.” Then the universal quantification of P(x),  x P(x), is the proposition: “All parking spaces at NCTU are full.” “Every parking space at NCTU is full.” “For each parking space at NCTU, that space is full.”

Module #1 - Logic 2016/7/929 Examples of the Universal Quantifier Let Q(x) be the statement “ x<2 ”. What is the truth value of the quantification  x Q(x), where the domain consists of all real numbers? Suppose that P(x) is “ x 2 >0 ”. Show that the statement  x P(x) is false where the universe of discourse consists of all integers. Quiz: What is the outcome if the domain is an empty set?

Module #1 - Logic 2016/7/930 The Existential Quantifier  Example: Let the u.d. of x be parking spaces at NCTU. Let P(x) be the predicate “x is full.” Then the existential quantification of P(x),  x P(x), is the proposition: “Some parking space at NCTU is full.” “There is a parking space at NCTU that is full.” “At least one parking space at NCTU is full.”

Module #1 - Logic 2016/7/931 Examples of the Existential Quantifier Let P(x) denote the statement “ x>2 ”. What is the truth value of the quantification  x P(x), where the domain consists of all real numbers? Suppose that Q(x) is “ x=x+1 ”. What is the truth value of the quantification  x Q(x), where the domain consists of all real numbers? Quiz: What is the outcome if the domain is an empty set?

Module #1 - Logic 2016/7/932 Quantifier Exercise If R(x,y)=“x relies upon y,” express the following in unambiguous English:  x(  y R(x,y))=  y(  x R(x,y))=  x(  y R(x,y))=  y(  x R(x,y))=  x(  y R(x,y))= Everyone has someone to rely on. There’s a poor overburdened soul whom everyone relies upon (including himself)! There’s some needy person who relies upon everybody (including himself). Everyone has someone who relies upon them. Everyone relies upon everybody, (including themselves)!

Module #1 - Logic 2016/7/933 Natural language is ambiguous! “Everybody likes somebody.” For everybody, there is somebody they like,  x  y Likes(x,y) or, there is somebody (a popular person) whom everyone likes?  y  x Likes(x,y) “Somebody likes everybody.” Same problem: Depends on context, emphasis. [Probably more likely.]

Module #1 - Logic 2016/7/934 Goldbach’s Conjecture (unproven) Using E(x) and P(x) from previous slide,  E(x>2):  P(p),P(q): p+q = x or, with more explicit notation:  x [x>2  E(x)] →  p  q P(p)  P(q)  p+q = x. “Every even number greater than 2 is the sum of two primes.”