1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Goals Determine the true value of statements with AND, OR, IF..THEN. Negate statements with the connectives above Construct truth tables Understand when.
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.
Discrete Mathematics Lecture 1 Logic of Compound Statements Harper Langston New York University.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Introduction to Logic Sections 1.1 and 1.2 of Rosen Spring 2010
From Chapter 4 Formal Specification using Z David Lightfoot
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.
Discrete Mathematics Math 6A Instructor: M. Welling.
Introduction to Logic Sections 1.1 and 1.2 of Rosen Fall 2010 CSCE 235 Introduction to Discrete Structures URL: cse.unl.edu/~cse235 Questions:
CSE115/ENGR160 Discrete Mathematics 01/17/12 Ming-Hsuan Yang UC Merced 1.
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.
Adapted from Discrete Math
Chapter 1, Part I: Propositional Logic With Question/Answer Animations.
The Foundations: Logic and Proofs
Discrete Mathematics Goals of a Discrete Mathematics Learn how to think mathematically 1. Mathematical Reasoning Foundation for discussions of methods.
Propositions and Truth Tables
Chapter 2 – Fundamentals of Logic. Outline Basic Connectives and Truth Tables Logical Equivalence: The Laws of Logic Ligical Implication: Rules of Inference.
The Foundations: Logic and Proofs
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 Mathematics and Its Applications
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
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
CS 103 Discrete Structures Lecture 02
BY: MISS FARAH ADIBAH ADNAN IMK. CHAPTER OUTLINE: PART III 1.3 ELEMENTARY LOGIC INTRODUCTION PROPOSITION COMPOUND STATEMENTS LOGICAL.
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.
Lecture Propositional Equivalences. Compound Propositions Compound propositions are made by combining existing propositions using logical operators.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Reading: Chapter 4 (44-59) from the text book
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
LOGIC Lesson 2.1. What is an on-the-spot Quiz  This quiz is defined by me.  While I’m having my lectures, you have to be alert.  Because there are.
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Section 1.2: Propositional Equivalences In the process of reasoning, we often replace a known statement with an equivalent statement that more closely.
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Chapter 1: The Foundations: Logic and Proofs
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
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.
Symbolic Logic The Following slide were written using materials from the Book: The Following slide were written using materials from the Book: Discrete.
LECTURE 1. Disrete mathematics and its application by rosen 7 th edition THE FOUNDATIONS: LOGIC AND PROOFS 1.1 PROPOSITIONAL LOGIC.
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Conditional statement or implication IF p then q is denoted p ⇒ q p is the antecedent or hypothesis q is the consequent or conclusion ⇒ means IF…THEN.
CS104 The Foundations: Logic and Proof 1. 2 What is Discrete Structure?  Discrete Objects  Separated from each other (Opposite of continuous)  e.g.,
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. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
Chapter 1 Propositional Logic
2. The Logic of Compound Statements Summary
CSNB 143 Discrete Mathematical Structures
Lecture 1 – Formal Logic.
CSCE 235 Introduction to Discrete Structures
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
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
Propositional Calculus: Boolean Algebra and Simplification
Information Technology Department
CS201: Data Structures and Discrete Mathematics I
MAT 3100 Introduction to Proof
Cs Discrete Mathematics
The Foundations: Logic and Proofs
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
CS201: Data Structures and Discrete Mathematics I
The Foundations: Logic and Proofs
Propositional Logic Computational Logic Lecture 2
Presentation transcript:

1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac CS1050: Understanding and Constructing Proofs Spring

2 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture Objectives Terminology Operators and their properties Converting English into Logic Propositions Understand some applications Tools for verifying equivalences of propositions

3 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Motivation Proofs are important in most CS applications Be able to judge whether whether a mathematical argument (proof) is correct (valid) Learn tools for constructing correct arguments (logic)

4 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What is a proposition? Declarative sentence that is either true or false, but not both –Propositions: 1+1=2 (true) 2+2=3 (false) –Not propositions What time is it? (question) Eat! (not declarative) x:=x+1; (computer instruction) y=2x+4 (constraint, implicit equation that may be verified by some pairs)

5 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac How do we denote propositions? Use letters: p, q, r, s… –Let p denote “It is raining today” –Let q denote “I will be wet”

6 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What is the truth value of a proposition? The truth values of a true proposition is “true” and is denoted T –Let p be “x 2  0”. The truth value of p is T The truth value of a false proposition is “false” and is denoted F –Let q be “–x 2  0”. The truth value of q is F

7 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are compound propositions? Formed by transforming or combining other propositions –Proposition p: “Today is Tuesday” –Proposition q: “I am teaching today” –Compound propositions: “Today is not Friday” (negation) “Today is not Friday” AND “I am teaching today”(conjunction) Reasoning about compound propositions is called propositional calculus or propositional logic

8 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are the main logical operators? Connectives that transform or combine propositions –Proposition p: “Today is Tuesday” –Proposition q: “I am teaching today” Negation (  p). Read “Not p” –“Today is not Tuesday” Conjunction (p  q). Read “p and q” –“Today is Tuesday” AND “I am teaching today” Disjunction (p  q). Read “p or q (or both)” –“Today is Tuesday” OR “I am teaching today”

9 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What is the Exclusive Or? XOR (p  q). Read “exclusive or” –Interpret as “p and q have different truth values” –EITHER “Today is Tuesday” OR “I am teaching today”, NOT BOTH –In English, “or” may mean inclusive OR (  ) or exclusive OR (  ) –“Would you like tea or coffee?”…”Yes, please” XOR (p  q) is the same as DIFFERENT (p ≠ q) –“The truth values of p and q are different” Team exercise: –What does (p  q)  (r  s) express? –Is it the same as ((p  q)  r)  s ?

10 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are implications? Implication (p  q) is false only when p is true and q false –p is the hypothesis or premise –q is the conclusion or consequence Many equivalent ways to interpret p  q –“If p, then q”, “p implies q”, “q follows from p”, “p is sufficient for q”, –“q is necessary for p”, “p only if q” Implications are propositions (they need not be true) –“If today is Friday, then 2+3=5” is true everyday except Friday Do not confuse implications with IF-THEN statements –if (x>3) {x=3;};// caps x at 3

11 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are the derivatives of an implication? Consider the Implication proposition p  q –“We win whenever it is raining” –IF “it is raining” THEN “we win” –IF p THEN q Its contrapositive is  q   p –IF “we do not win” THEN “it is not raining” –Note that it say the same thing (equivalent to the implication p  q Its converse is q  p –IF “we win” THEN “it is raining” –Note that it is not equivalent to the implication p  q Its inverse is  p   q –IF “it is not raining” THEN “we don’t win” –Note that it is equivalent to the converse q  p

12 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are biconditionals (iff)? The biconditional p  q is the proposition that is true if and only if p and q have the same truth value –p  q is true if and only if both p  q and q  p are true –p  q can be written as (p  q)  (q  p) –I like to denote it by “p==q”, as in several programming languages p  q should be read as –“p is necessary and sufficient for q” –“if p, then q, and conversely” –“p implies q and vice versa” –“p when q” –“q iff q” (“iff” stands for “if and only if”)

13 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are truth tables? A compound proposition may, but needs not be true. –Its true value depends on the true values of its primitive propositions pq pppqpqpqpqp  q p ≠ q pqpqp  q p==q p  q p–q TTFTTFTTF TFFFTTFFT FTTFTTTFF FFTFFFTTF

14 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Precedence of logical operators To reduce the number of parentheses, we use the following precedence: 1)  Negation 2) , Conjunction, 3) ,  Disjunction, Xor 4) ,  Implications Example: –p  q  s  t  p  t –Is interpreted as:

15 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Translating English into Logic This is not easy! (Study examples p 10-11) Do not attempt it at home! Your family may not appreciate it. Take a complex declarative English sentence –“You may access the Internet on campus only if you are a computer science major or if you are not a freshman.” Separate it into parts and assign them variable names –a stands for “you may access the Internet on campus” –c stands for “you are a computer science major –f stands for “you are a freshman” Combine using logical connective to capture the meaning –(a  c   f)

16 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac When are system specifications consistent? Software or hardware requirements are often specified using a natural language. System and software engineers translate each requirement into logical propositions. Then, one wishes to build a system that satisfies ALL of the requirements (i.e., assign values to all variables so that all requirements are met). A system specification is consistent if there exists an assignment of truth values to all variables that satisfies all propositions (make them true)

17 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are tautologies and contradictions? A compound proposition that is always true is a tautology (p  p) A compound proposition that is always false is a contradiction (p  p) A compound proposition that is neither a contradiction nor a tautology is a contingency

18 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac When are two propositions equivalent? When they have the same truth tables –Denoted (p  q) or (p  q) p and q are logically equivalent if p  q is a tautology Examples The implication and its contrapositive are equivalent (  q   p)  (p  q) The converse and inverse of an implication are equivalent (  p   q)  (q  p) An implication is not equivalent to its converse (p  q) !  (q  p)

19 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are other useful logical equivalences? Idempotence: p  p  p, p  p  p Negation: p  p  F, p  p  T Identity: p  T  p, p  F  p Domination: p  F  F, p  T  T Double negation:  (  p)  p Negation of disjunction (DeMorgan):  (p  q)   p  q Negation of conjunction (DeMorgan):  (p  q)   p  q Commutativity: p  q  q  p, p  q  q  p Associativity: (p  q)  r  q  (p  r), (p  q)  r  q  (p  r) Distributivity: (p  q)  r  (q  r)  (q  r), (p  q)  r  q  r  q  r Absorption: (p  q)  p  p, (p  q)  p  p

20 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What equivalences involve implications? p  q   p  q p  q   p  q p  q   (p   q)  (p  q)  p  q (p  q)  (p  r)  p  (q  r) (p  q)  (p  r)  p  (q  r) (p  r)  (q  r)  p  q  r (p  r)  (q  r)  p  q  r p  q  (p  q)  (q  p) p  q   p   q p  q  p  q   p  q  (p  q)  p   q

21 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Show that p  q  p  q is a tautology We want to demonstrate that p  q  p  q  T –p  q   p  q # equivalence law p  q  p  q   (p  q)  (p  q) –  (p  q)   p  q # DeMorgan p  q  p  q  (  p  q)  (p  q) –p  q  q  p # commute p  q  p  q   p  p  q  q –p  p  T # negation p  q  p  q  T  T –p  T  T# domination p  q  p  q  T

22 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are the logical operators in Processing? Boolean variables may be combined using logical operators –!pmeans NOT p –p && qmeans p AND q (p  q) –p || qmeans p OR q (p  q) –p != qmeans p XOR q (p  q, p ≠ q) –p == qmeans p iff q (p  q) –p&& ! qmeans p AND NOT q (p  q)

23 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac What are logical operators on bit strings A Boolean variable may be represented by 1 bit –1 means true, 0 means false A bit string S is an ordered sequence of bits The length of S is the number of bits it has We can perform operations on bit-strings S and T –By performing the operations on all pairs of corresponding bits S | T performs a bitwise OR (at least one bit has to be 1) S & T performs a bitwise AND (both have to be 1) S << 3shifts all bits left and inserts three 0 on the right In processing, these operations work on –intintegers –bytestrings of 8 bits –charbinary representations of characters See

24 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Reading assignment Sections 1.1 and 1.2 for this class Sections 1.3 and 1.4 for the next class

25 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Assigned Exercises for Lecture 1 You must know how to solve the following exercises for the quiz on lecture 2 – e on p 1-17 – f on p 1-18 – b on p 1-18 – on p 1-19 – d on p 1-19 – on p 1-20 –1.2-9 on p 1-26

26 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Logical operators (summary) T, Ftrue, false ¬p, !p,  p not p p  qp and q p  qp or q p  q, p ≠ q p xor q p  qp implies q p  q, p==q p same as q p  q, p  qp equivalent to q  nfor each n  nfor at least one n   empty set s  Ss is an element of S  S elements not in S S  Telements in S and T S  Telements in S or T S–TS  T S  T S  T – S  T S=TS equals T S  TS included in T PropositionsSets S | T bitwise OR S & T bitwise AND S << nshift left by n bits Bit strings

27 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Work to do before the next lecture (part 1) Get the book and study sections 1.1 and 1.2 Study these slides by looking at the question in the slide title and trying to answer it without looking –Mark what you do not understand and check it in the book Do the exercises assigned for sections 1.1 and 1.2 –Do other exercises as needed for practice Learn how to solve these exercises by heart –We will have a practice quiz during the next lecture –It will cover these slides, the reading, and the exercises

28 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Work to do before the next lecture (part 2) Read Sections 1.3 and 1.4 –One question on the practice quiz will be on Sections 1.3 or 1.4 Print and study the slides (L02) for lecture 2 –See if you can answer the questions (slide titles) –Write down what you do not understand Try to do the exercises assigned in the slides for lecture 2 –Mark what you have trouble with Bring it all to lecture 2 As a Team (only due Tu Jan 17, but START NOW!!!) –Print the slides (P0) for project 0 –Follow the instructions and install Processing –Play with it, write your question, problems –Try to complete P0 (including posting a web page and doing your PPP)