CS203 Discrete Mathematical Structures

Slides:



Advertisements
Similar presentations
CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Advertisements

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.
Propositional Equivalences. L32 Agenda Tautologies Logical Equivalences.
UNIT-I Statements and Notations Connectives Normal Forms
1 Section 1.2 Propositional Equivalences. 2 Equivalent Propositions Have the same truth table Can be used interchangeably For example, exclusive or and.
1 Math 306 Foundations of Mathematics I Math 306 Foundations of Mathematics I Goals of this class Introduction to important mathematical concepts Development.
EE1J2 – Discrete Maths Lecture 5
Discussion #10 1/16 Discussion #10 Logical Equivalences.
Chapter 2: The Logic of Compound Statements 2.1 Logical Forms and Equivalence 12.1 Logical Forms and Equivalences Logic is a science of the necessary laws.
Adapted from Discrete Math
3.2 – Truth Tables and Equivalent Statements
TRUTH TABLES. Introduction Statements have truth values They are either true or false but not both Statements may be simple or compound Compound statements.
Normal or Canonical Forms Rosen 1.2 (exercises). Logical Operators  - Disjunction  - Conjunction  - Negation  - Implication p  q   p  q  - Exclusive.
The Foundations: Logic and Proofs
Chapter 1 Section 1.4 More on Conditionals. There are three statements that are related to a conditional statement. They are called the converse, inverse.
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
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
Discrete Maths 2. Propositional Logic Objective
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.
BY: MISS FARAH ADIBAH ADNAN IMK. CHAPTER OUTLINE: PART III 1.3 ELEMENTARY LOGIC INTRODUCTION PROPOSITION COMPOUND STATEMENTS LOGICAL.
CSci 2011 Textbook ^Discrete Mathematics and Its Applications,  Rosen  6th Edition  McGraw Hill  2006.
Chap. 2 Fundamentals of Logic. Proposition Proposition (or statement): an declarative sentence that is either true or false, but not both. e.g. –Margret.
Chapter 5 – Logic CSNB 143 Discrete Mathematical Structures.
Fall 2002CMSC Discrete Structures1 Let’s get started with... Logic !
Discrete Mathematics Lecture1 Miss.Amal Alshardy.
CSNB143 – Discrete Structure LOGIC. Learning Outcomes Student should be able to know what is it means by statement. Students should be able to identify.
Tautologies, contradictions, contingencies
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.
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.
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.
Chapter 7 Logic, Sets, and Counting
Chapter 3: Introduction to Logic. Logic Main goal: use logic to analyze arguments (claims) to see if they are valid or invalid. This is useful for math.
Propositional Logic. Propositions Any statement that is either True (T) or False (F) is a proposition Propositional variables: a variable that can assume.
CS1022 Computer Programming & Principles Lecture 1 Logic and Proof.
Lecture 9 Conditional Statements CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
How do I show that two compound propositions are logically equivalent?
Chapter 7 Logic, Sets, and Counting Section 1 Logic.
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Logical Form and Logical Equivalence M Logical Form Example 1 If the syntax is faulty or execution results in division by zero, then the program.
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.
Section 1.1. Section Summary Propositions Connectives Negation Conjunction Disjunction Implication; contrapositive, inverse, converse Biconditional Truth.
CSNB143 – Discrete Structure Topic 4 – Logic. Learning Outcomes Students should be able to define statement. Students should be able to identify connectives.
Propositional Equivalence A needed step towards proofs Copyright © 2014 Curt Hill.
Joan Ridgway. If a proposition is not indeterminate then it is either true (T) or false (F). True and False are complementary events. For two propositions,
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
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.
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.
Mathematics for Computing Lecture 2: Computer Logic and Truth Tables Dr Andrew Purkiss-Trew Cancer Research UK
TRUTH TABLES Edited from the original by: Mimi Opkins CECS 100 Fall 2011 Thanks for the ppt.
Spring 2003CMSC Discrete Structures1 Let’s get started with... Logic !
3/6/20161 Let’s get started with... Logic !. 3/6/20162 Logic Crucial for mathematical reasoningCrucial for mathematical reasoning Used for designing electronic.
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. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
Chapter 1 Logic and proofs
Propositional Logic.
Semantic Web Logic.
(CSC 102) Discrete Structures Lecture 2.
Propositional Calculus: Boolean Algebra and Simplification
Information Technology Department
Propositional Equivalence (§1.2)
Lecture 2: Propositional Equivalences
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Presentation transcript:

CS203 Discrete Mathematical Structures Logic Proposition logic

What is logic? The branch of philosophy concerned with analysing the patterns of reasoning by which a conclusion is drawn from a set of premises, without reference to meaning or context (Collins English Dictionary)

Digital Logic

Propositional logic Simple types of statements, called propositions, are treated as atomic building blocks for more complex statements 1) Alexandria is a port or a holiday resort. 2) Alexandria is not a port. Therefore, Alexandria is a holiday resort

Basic connectives and truth tables statements (propositions): declarative sentences that are either true or false--but not both. Eg. Ahmed Hassan wrote Gone with the Wind. 2+3=5. not statements: What a beautiful morning! Get up and do your exercises.

Statement (Proposition) A Statement is a sentence that is either True or False 2 + 2 = 4 True Examples: 3 x 3 = 8 False 787009911 is a prime Today is Tuesday. Non-examples: x+y>0 x2+y2=z2 They are true for some values of x and y but are false for some other values of x and y.

Propositional connectives Propositional logic has four connectives Name Read as Symbol negation ‘not’  conjunction ‘and’  disjunction ‘or’  implication ‘if…then…’ 

Logical Operators About a dozen logical operators Similar to algebraic operators + * - / In the following examples, p = “Today is Friday” q = “Today is my birthday”

Logical operators: Not A “not” operation switches (negates) the truth value Symbol:  or ~ p = “Today is not Friday” p p T F

Logical operators: And An “and” operation is true if both operands are true Symbol:  It’s like the ‘A’ in And pq = “Today is Friday and today is my birthday” p q pq T F

Logical operators: Or An “or” operation is true if either operands are true Symbol:  pq = “Today is Friday or today is my birthday (or possibly both)” p q pq T F

Logical operators: Conditional A conditional means “if p then q” Symbol:  pq = “If today is Friday, then today is my birthday” p→q=¬pq p q pq T F

Logical operators: Bi-conditional A bi-conditional means “p if and only if q” Symbol:  Alternatively, it means “(if p then q) and (if q then p)” Note that a bi-conditional has the opposite truth values of the exclusive or p q pq T F

Boolean operators summary not and or xor conditional Bi-conditional p q p q pq pq pq pq pq T F Learn what they mean, don’t just memorize the table!

Precedence of operators Just as in algebra, operators have precedence 4+3*2 = 4+(3*2), not (4+3)*2 Precedence order (from highest to lowest): ¬   → ↔ The first three are the most important This means that p  q  ¬r → s ↔ t yields: (p  (q  (¬r)) → s) ↔ (t) Not is always performed before any other operation

Example s: Aya goes out for a walk. t: The moon is out. u: It is snowing. : If the moon is out and it is not snowing, then Aya goes out for a walk. If it is snowing and the moon is not out, then Aya will not go out for a walk.

Translating English Sentences p = “It is below freezing” q = “It is snowing” It is below freezing and it is snowing It is below freezing but not snowing It is not below freezing and it is not snowing It is either snowing or below freezing (or both) If it is below freezing, it is also snowing It is either below freezing or it is snowing, but it is not snowing if it is below freezing That it is below freezing is necessary and sufficient for it to be snowing pq p¬q ¬p¬q pq p→q ((pq)¬(pq))(p→¬q) p↔q

Logical Equivalence p q 1 1 1 1 1

Tables of Logical Equivalences Identity laws Like adding 0 Domination laws Like multiplying by 0 Idempotent laws Delete redundancies Double negation “I don’t like you, not” Commutativity Like “x+y = y+x” Associativity Like “(x+y)+z = y+(x+z)” Distributivity Like “(x+y)z = xz+yz” De Morgan L3

Tables of Logical Equivalences Excluded middle Negating creates opposite Definition of implication in terms of Not and Or

Fundamentals of Logic A compound statement is called a tautology(T0) if it is true for all truth value assignments for its component statements. If a compound statement is false for all such assignments, then it is called a contradiction(F0). : tautology : contradiction

Propositional Logic - 2 more defn… A tautology is a proposition that’s always TRUE. A contradiction is a proposition that’s always FALSE. p p p  p p  p T F T F

Tautology example Demonstrate that [¬p (p q )]q is a tautology in two ways: Using a truth table – show that [¬p (p q )]q is always true Using a proof (will get to this later).

Tautology by truth table p q ¬p p q ¬p (p q ) [¬p (p q )]q T F

Tautology by truth table p q ¬p p q ¬p (p q ) [¬p (p q )]q T F

Tautology by truth table p q ¬p p q ¬p (p q ) [¬p (p q )]q T F

Tautology by truth table p q ¬p p q ¬p (p q ) [¬p (p q )]q T F

Tautology by truth table p q ¬p p q ¬p (p q ) [¬p (p q )]q T F

Tautologies, contradictions and programming Tautologies and contradictions in your code usually correspond to poor programming design. EG: while(x <= 3 || x > 3) x++; if(x > y) if(x == y) return “never got here”;

dual Let s be a statement. If s contains no logical connectives other than and , then the dual of s, denoted sd, is the statement obtained from s by replacing each occurrence of and by and , respectively, and each occurrence of T and F by F and T, respectively. Eg. The dual of is

The Principle of Duality Theorem () Let s and t be statements. If , then . First Substitution Rule (replace each p by another statement q) Ex. is a tautology. Replace each occurrence of p by is also a tautology.

Converse The converse of a logical implication is the reversal of the implication. I.e. the converse of p q is q p. EG: The converse of “If Donald is a duck then Donald is a bird.” is “If Donald is a bird then Donald is a duck.” p q and q p are not logically equivalent.

Converse p q p q q p (p q)  (q p)

Converse p q p q q p (p q)  (q p) T F

Logical Non-Equivalence of Conditional and Converse p q p q q p (p q)  (q p) T F

Logical Non-Equivalence of Conditional and Converse p q p q q p (p q)  (q p) T F

Logical Non-Equivalence of Conditional and Converse p q p q q p (p q)  (q p) T F

Fundamentals of Logic Compare the efficiency of two program segments. z:=4; for i:=1 to 10 do begin x:=z-1; y:=z+3*i; if ((x>0) and (y>0)) then writeln(‘The value of the sum x+y is’, x+y) end . if x>0 then if y>0 then … Number of comparisons? 20 vs. 10+3=13 logically equivalent

Derivational Proof Techniques When compound propositions involve more and more atomic components, the size of the truth table for the compound propositions increases Q1: How many rows are required to construct the truth-table of: ( (q(pr ))  ((sr)t) )  (qr ) Q2: How many rows are required to construct the truth-table of a proposition involving n atomic components?

Derivational Proof Techniques A1: 32 rows, each additional variable doubles the number of rows A2: In general, 2n rows Therefore, as compound propositions grow in complexity, truth tables become more and more unwieldy. Checking for tautologies/logical equivalences of complex propositions can become a chore, especially if the problem is obvious.

Derivational Proof Techniques EG: consider the compound proposition (p p )  ((sr)t) )  (qr ) Q: Why is this a tautology? L3

Derivational Proof Techniques A: Part of it is a tautology (p p ) and the disjunction of True with any other compound proposition is still True: (p p )  ((sr)t ))  (qr ) T  ((sr)t ))  (qr ) T Derivational techniques formalize the intuition of this example. L3

Propositional Logic - an unfamous  if NOT (blue AND NOT red) OR red then… (p  q)  q  p  q (p  q)  q  (p  q)  q DeMorgan’s (p  q)  q Double negation p  (q  q) Associativity p  q Idempotent

Tautology by proof [¬p (p q )]q L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan  [p  ¬q ]  q Double Negation L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan  [p  ¬q ]  q Double Negation  p  [¬q q ] Associative L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan  [p  ¬q ]  q Double Negation  p  [¬q q ] Associative  p  [q ¬q ] Commutative L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan  [p  ¬q ]  q Double Negation  p  [¬q q ] Associative  p  [q ¬q ] Commutative  p  T ULE L3

Tautology by proof [¬p (p q )]q  [(¬p p)(¬p q)]q Distributive  [ F  (¬p q)]q ULE  [¬p q ]q Identity  ¬ [¬p q ]  q ULE  [¬(¬p) ¬q ]  q DeMorgan  [p  ¬q ]  q Double Negation  p  [¬q q ] Associative  p  [q ¬q ] Commutative  p  T ULE  T Domination L3

Writing Logical Formula for a Truth Table Digital logic: Given a digital circuit, we can construct the truth table. Now, suppose we are given only the truth table (i.e. the specification, e.g. the specification of the majority function), how can we construct a digital circuit (i.e. formula) using only simple gates (such as AND, OR, NOT) that has the same function?

Examples “I don’t study well and fail” is logically equivalent to “If I study well, then I don’t fail” Write a C program that represents the compound proposition (pq)r

Decide whether the following statements are tautologies or contradictions or neither 1. (p  q)  (q  p). 2. (p  q)  (q  ¬p). 3. p  ¬p. 4. (p  ¬q)  (q  ¬p).

Use truth table to find - P  Q  P  R P  -Q  R  P  R  - Q A  B  -C  D  E  F (P ↔ Q)  (P˅ Q) [P ˄ (P  Q)]  Q

Which of the following equivalent to -(P˄Q)