CompSci 102 Discrete Math for Computer Science January 17, 2012 Prof. Rodger.

Slides:



Advertisements
Similar presentations
Af2 Introduction. What’s the course about? Discrete Mathematics The mathematics that underpins computer science and other sciences as well.
Advertisements

Grading Lecture attendance: -1% per 2 unexcused absences
1. Propositions A proposition is a declarative sentence that is either true or false. Examples of propositions: The Moon is made of green cheese. Trenton.
CSE 311 Foundations of Computing I Spring 2013 Lecture 1 Propositional Logic.
Foundations of Logic Mathematical Logic is a tool for working with elaborate compound statements. It includes: A formal language for expressing them.
CSE 311 Foundations of Computing I Autumn 2011 Lecture 1 Propositional Logic.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
1 Section 1.1 Logic. 2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller.
Module #1 - Logic Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen 1 Module.
CSE115/ENGR160 Discrete Mathematics 01/17/12 Ming-Hsuan Yang UC Merced 1.
Adapted from Discrete Math
Logic A statement is a sentence that is either true or false (its truth value). Logically speaking, a statement is either true or false. What are the values.
CSCI2110 – Discrete Mathematics Tutorial 8 Propositional Logic Wong Chung Hoi (Hollis)
The Foundations: Logic and Proofs
Discrete Mathematics Lecture 2.
Propositions and Truth Tables
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
CSE 311 Foundations of Computing I Autumn 2012 Lecture 1 Propositional Logic 1.
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.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Ch.1 (Part 1): The Foundations: Logic and Proofs Introduction.
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
CompSci Welcome! Discrete Mathematics for Computer Science CompSci 102 D243 LSRC M, W 10:05-11:20 Professor: Jeffrey Forbes.
Copyright © Curt Hill Mathematical Logic An Introduction.
Discrete Structures – CS Text Discrete Mathematics and Its Applications Kenneth H. Rosen (7 th Edition) Chapter 1 The Foundations: Logic and Proofs.
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.
1/10/ Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007 Suprakash Datta Office: CSEB 3043 Phone:
Chapter 1: The Foundations: Logic and Proofs
Section 1.1. Section Summary Propositions Connectives Negation Conjunction Disjunction Implication; contrapositive, inverse, converse Biconditional Truth.
Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.
Fall 2013 Foundations of Logic
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
Section 1.1. Propositions A proposition is a declarative sentence that is either true or false. Examples of propositions: a) The Moon is made of green.
University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner Adapted from Michael P. Frank ' s course based on the text.
Learning Objectives  To define a proposition  To form a compound proposition using connectives  To determine the truth values of compound propositions.
Discrete Mathematics Lecture # 4. Conditional Statements or Implication  If p and q are statement variables, the conditional of q by p is “If p then.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
CS104 The Foundations: Logic and Proof 1. 2 What is Discrete Structure?  Discrete Objects  Separated from each other (Opposite of continuous)  e.g.,
Chapter 1. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
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.
Propositional Logic. Logic Logic: the science of reasoning, proof, thinking or inference. Logic allows us to analyze a piece of reasoning and determine.
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.
Chapter 1 Propositional Logic
Discrete Mathematical
CSNB 143 Discrete Mathematical Structures
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.
Logic.
COT 3100, Spr Applications of Discrete Structures
Ch.1 (Part 1): The Foundations: Logic and Proofs
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Propositional Logic (§1.1)
The Foundations: Logic and Proofs
Principles of Computing – UFCFA3-30-1
Information Technology Department
Discrete Mathematics and Its Applications Kenneth H
MAT 3100 Introduction to Proof
Cs Discrete Mathematics
Logic of Informatics Introduction.
The Foundations: Logic and Proofs
Presentation transcript:

CompSci 102 Discrete Math for Computer Science January 17, 2012 Prof. Rodger

Announcements Read for next time Chap Recitations start Friday Added everyone to Piazza ACM Distinguished Speaker tonight –Dilma Da Silva, IBM –System Software for Cloud Computing –6pm tonight in LSRC D106 with Pizza!

Logic R

How old ….. Aristotle developed propositional logic over 2000 years ago…. George Boole wrote “The Mathematical Analysis of Logic” in 1848

Proposition A proposition is a sentence that declares a fact that is true or false A theorem is a proposition that is guaranteed by a proof

Examples of Propositions Which are propositions? What is their value? 1.Duke won the NCAA men’s basketball title in x > 2 3.Clean up after yourself. 4.Durham is the capital of NC. 5.Pepsi was invented in New Bern NC in = 11 6

1.7 CompSci 102© Michael Frank A Proof Example Theorem: (Pythagorean Theorem of Euclidean geometry) For any real numbers a, b, and c, if a and b are the base-length and height of a right triangle, and c is the length of its hypo- tenuse, then a 2 + b 2 = c 2.Theorem: (Pythagorean Theorem of Euclidean geometry) For any real numbers a, b, and c, if a and b are the base-length and height of a right triangle, and c is the length of its hypo- tenuse, then a 2 + b 2 = c 2. Proof?Proof? a b Pythagoras of Samos (ca B.C.)

1.8 CompSci 102© Michael Frank Proof of Pythagorean Theorem Proof. Consider the below diagram:Proof. Consider the below diagram: –Exterior square area = c 2, the sum of the following regions: The area of the 4 triangles = 4(½ab) = 2abThe area of the 4 triangles = 4(½ab) = 2ab The area of the small interior square = (b−a) 2 = b 2 −2ab+a 2.The area of the small interior square = (b−a) 2 = b 2 −2ab+a 2. –Thus, c 2 = 2ab + (b 2 −2ab+a 2 ) = a 2 + b 2. ■ c c c c a a a a b b b b (b−a)2(b−a)2 Note: It is easy to show that the exterior and interior quadrilaterals in this construction are indeed squares, and that the side length of the internal square is indeed b−a (where b is defined as the length of the longer of the two perpendicular sides of the triangle). These steps would also need to be included in a more complete proof. ½ab Areas in this diagram are in boldface; lengths are in a normal font weight.

1.9 CompSci 102© Michael Frank An operator or connective combines one or more operand expressions into a larger expression. (E.g., “+” in numeric exprs.) Unary operators take 1 operand (e.g., −3); binary operators take 2 operands (eg 3  4).Unary operators take 1 operand (e.g., −3); binary operators take 2 operands (eg 3  4). Propositional or Boolean operators operate on propositions (or their truth values) instead of on numbers.Propositional or Boolean operators operate on propositions (or their truth values) instead of on numbers. Operators / Connectives Topic #1.0 – Propositional Logic: Operators

1.10 CompSci 102© Michael Frank Some Popular Boolean Operators Formal Name NicknameAritySymbol Negation operator NOTUnary¬ Conjunction operator ANDBinary Disjunction operator ORBinary Exclusive-OR operator XORBinary Implication operator IMPLIESBinary Biconditional operator IFFBinary↔ Topic #1.0 – Propositional Logic: Operators

1.11 CompSci 102© Michael Frank The Negation Operator The unary negation operator “¬” (NOT) transforms a prop. into its logical negation. E.g. If p = “I have brown hair.” then ¬p = “I do not have brown hair.” then ¬p = “I do not have brown hair.” The truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” Operand column Result column Topic #1.0 – Propositional Logic: Operators

1.12 CompSci 102© Michael Frank The Conjunction Operator The binary conjunction operator “  ” (AND) combines two propositions to form their logical conjunction. E.g. If p=“I will have salad for lunch.” and q=“I will have steak for dinner.”, then p  q=“I will have salad for lunch and I will have steak for dinner.”  ” points up like an “A”, and it means “  ND ” Remember: “  ” points up like an “A”, and it means “  ND ”  ND Topic #1.0 – Propositional Logic: Operators

1.13 CompSci 102Modified from © Michael Frank A conjunction p 1  p 2  …  p n of n propositions will have how many rows in its truth table?A conjunction p 1  p 2  …  p n of n propositions will have how many rows in its truth table? Note: ¬ and  operations together are suffi-cient to express any Boolean truth table!Note: ¬ and  operations together are suffi-cient to express any Boolean truth table! Conjunction Truth Table Operand columns Topic #1.0 – Propositional Logic: Operators

1.14 CompSci 102© Michael Frank The Disjunction Operator The binary disjunction operator “  ” (OR) combines two propositions to form their logical disjunction. p=“My car has a bad engine.” q=“My car has a bad carburetor.” p  q=“Either my car has a bad engine, or my car has a bad carburetor.”  ” splits the wood, you can take 1 piece OR the other, or both. After the downward- pointing “axe” of “  ” splits the wood, you can take 1 piece OR the other, or both.  Topic #1.0 – Propositional Logic: Operators Meaning is like “and/or” in English.

1.15 CompSci 102© Michael Frank Note that p  q means that p is true, or q is true, or both are true!Note that p  q means that p is true, or q is true, or both are true! So, this operation is also called inclusive or, because it includes the possibility that both p and q are true.So, this operation is also called inclusive or, because it includes the possibility that both p and q are true. “¬” and “  ” together are also universal.“¬” and “  ” together are also universal. Disjunction Truth Table Note difference from AND Topic #1.0 – Propositional Logic: Operators

1.16 CompSci 102© Michael Frank Nested Propositional Expressions Use parentheses to group sub-expressions: “I just saw my old friend, and either he’s grown or I’ve shrunk.” = f  (g  s)Use parentheses to group sub-expressions: “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 “  ”.By convention, “¬” takes precedence over both “  ” and “  ”. – ¬s  f means (¬s)  f, not ¬ (s  f) Topic #1.0 – Propositional Logic: Operators

1.17 CompSci 102© Michael Frank A Simple Exercise Let p=“It rained last night”, q=“The sprinklers came on last night,” 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.” Topic #1.0 – Propositional Logic: Operators

1.18 CompSci 102© Michael Frank 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 in this course, or I will drop it (but not both!)” Topic #1.0 – Propositional Logic: Operators

1.19 CompSci 102© Michael Frank Note that p  q means that p is true, or q is true, but not both!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.This operation is called exclusive or, because it excludes the possibility that both p and q are true. “¬” and “  ” together are not universal.“¬” and “  ” together are not universal. Exclusive-Or Truth Table Note difference from OR. Topic #1.0 – Propositional Logic: Operators

1.20 CompSci 102© Michael Frank 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   Topic #1.0 – Propositional Logic: Operators

1.21 CompSci 102© Michael Frank The Implication Operator The implication p  q states that p implies q. I.e., If p is true, then q is true; but if p is not true, then q could be either true or false. 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) Topic #1.0 – Propositional Logic: Operators antecedentconsequent

1.22 CompSci 102© Michael Frank Implication Truth Table p  q is false only when p is true but q is not true.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 say that p causes q! p  q does not require that p or q are ever true!p  q does not require that p or q are ever true! E.g. “(1=0)  pigs can fly” is TRUE!E.g. “(1=0)  pigs can fly” is TRUE! The only False case! Topic #1.0 – Propositional Logic: Operators

1.23 CompSci 102© Michael Frank Examples of Implications “If this lecture ever ends, then the sun will rise tomorrow.” True or False?“If this lecture ever 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 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 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?“If the moon is made of green cheese, then I am richer than Bill Gates.” True or False? Topic #1.0 – Propositional Logic: Operators

1.24 CompSci 102© Michael Frank Why does this seem wrong? Consider a sentence like,Consider a sentence like, –“If I wear a red shirt tomorrow, then I will win the lottery!” In logic, we consider the sentence True so long as either I don’t wear a red shirt, or I win the lottery.In logic, we consider the sentence True so long as either I don’t wear a red shirt, or I win the lottery. But, in normal English conversation, if I were to make this claim, you would think that I was lying.But, in normal English conversation, if I were to make this claim, you would think that I was lying. –Why this discrepancy between logic & language?

1.25 CompSci 102© Michael Frank Resolving the Discrepancy In English, a sentence “if p then q” usually really implicitly means something like,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.”That is, “For p to be true and q false is impossible.” Or, “I guarantee that no matter what, if p, then q.”Or, “I guarantee that no matter what, if p, then q.” This can be expressed in predicate logic as: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) That sentence is logically False in our example, because for me to wear a red shirt and for me to not win the lottery is a possible (even if not actual) situation.That sentence is logically False in our example, because for me to wear a red shirt and for me to not win the lottery is a possible (even if not actual) situation. –Natural language and logic then agree with each other.

1.26 CompSci 102© Michael Frank English Phrases Meaning p  q “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” “q if p”“q if p” “q when p”“q when p” “q whenever 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. Topic #1.0 – Propositional Logic: Operators

1.27 CompSci 102© Michael Frank 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 figure out which?One of these three has the same meaning (same truth table) as p  q. Can you figure out which? Topic #1.0 – Propositional Logic: Operators

1.28 CompSci 102© Michael Frank How do we know for sure? Proving the equivalence of p  q and its contrapositive using truth tables: Topic #1.0 – Propositional Logic: Operators

1.29 CompSci 102© Michael Frank The biconditional operator The biconditional p  q states that p is true if and only if (IFF) q is true. When we say P if and only if q, we are saying that P says the same thing as Q. Examples? Truth table? Topic #1.0 – Propositional Logic: Operators

1.30 CompSci 102© Michael Frank Biconditional Truth Table p  q means that p and q have the same truth value.p  q means that p and q have the same truth value. Note this truth table is the exact opposite of  ’s!Note this truth table is the exact opposite of  ’s! Thus, p  q means ¬(p  q) p  q does not imply that p and q are true, or that either of them causes the other, or that they have a common cause.p  q does not imply that p and q are true, or that either of them causes the other, or that they have a common cause. Topic #1.0 – Propositional Logic: Operators

1.31 CompSci 102Modified © Michael Frank Boolean Operations Summary We have seen 1 unary operator and 5 binary operators. Their truth tables are below.We have seen 1 unary operator and 5 binary operators. Their truth tables are below. Topic #1.0 – Propositional Logic: Operators

1.32 CompSci 102© Michael Frank Some Alternative Notations Topic #1.0 – Propositional Logic: Operators