Discrete Structures CSC 281

Slides:



Advertisements
Similar presentations
1 Discrete Structures CS 2800 Prof. Bart Selman Module Logic (part 1)
Advertisements

Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Discrete Mathematics Math 6A Instructor: M. Welling.
CS 4700: Foundations of Artificial Intelligence
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
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.
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.
Fall 2002CMSC Discrete Structures1 Let’s get started with... Logic !
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
SSK3003 DISCRETE STRUCTURES
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.
January 30, 2002Applied Discrete Mathematics Week 1: Logic and Sets 1 Let’s Talk About Logic Logic is a system based on propositions.Logic is a system.
1 Info 2950 Prof. Carla Gomes Module Logic (part 1) Rosen, Chapter 1.
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
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
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.
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.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
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.
1 Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 3-1 Logic Based Reasoning.
Chapter 1 Logic and proofs
Ch01-Logic 1. Logic Crucial for mathematical reasoningCrucial for mathematical reasoning Used for designing electronic circuitryUsed for designing electronic.
Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]
2. The Logic of Compound Statements Summary
Advanced Algorithms Analysis and Design
CSE15 Discrete Mathematics 01/23/17
Discrete Mathematics Lecture 1 Logic of Compound Statements
CSNB 143 Discrete Mathematical Structures
Lecture 1 – Formal Logic.
Knowledge Representation and Reasoning
Discrete Mathematics Logic.
CS 202, Spring 2008 Epp, sections 1.1 and 1.2
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.
CPCS222 Discrete Structures I
The Propositional Calculus
Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]
CMSC Discrete Structures
The Foundations: Logic and Proofs
CSCI 3310 Mathematical Foundation of Computer Science
Propositional Calculus: Boolean Algebra and Simplification
CS100: Discrete structures
Information Technology Department
CS 220: Discrete Structures and their Applications
CHAPTER 1: LOGICS AND PROOF
CS201: Data Structures and Discrete Mathematics I
Discrete Structures CS 23022
CMSC Discrete Structures
Applied Discrete Mathematics Week 1: Logic
Back to “Serious” Topics…
Discrete Mathematics and Its Applications Kenneth H
Computer Security: Art and Science, 2nd Edition
Discrete Mathematics Logic.
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Cs Discrete Mathematics
Predicates and Quantifiers
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
Presentation transcript:

Discrete Structures CSC 281 Yuan Tian ytian@ksu.edu.sa Logic Module (Part 1)

Acknowledgement Most of these slides were either created by Professor Bart Selman at Cornell University or else are modifications of his slides

Logic in general Logics are formal languages for formalizing reasoning, in particular for representing information such that conclusions can be drawn A logic involves: A language with a syntax for specifying what is a legal expression in the language; syntax defines well formed sentences in the language Semantics for associating elements of the language with elements of some subject matter. Semantics defines the "meaning" of sentences (link to the world); i.e., semantics defines the truth of a sentence with respect to each possible world Inference rules for manipulating sentences in the language Original motivation: Early Greeks settled arguments based on purely rigorous (symbolic/syntactic) reasoning starting from a given set of premises.

Example of a formal language: Arithmetic E.g., the language of arithmetic x+2 ≥ y is a sentence; 2x+y > {} is not a sentence x+2 ≥ y is true iff the number x+2 is no less than the number y x+2 ≥ y is true in a world where x = 7, y = 1 x+2 ≥ y is false in a world where x = 0, y = 6

Simple Robot Domain Consider a robot that is able to lift a block, if that block is liftable (i.e., not too heavy), and if the robot’s battery power is adequate. If both of these conditions are satisfied, then when the robot tries to lift a block it is holding, its arm moves. block Feature 1: BatIsOk (True or False) Feature 2: BlockLiftable (True or False) Feature 3: RobotMoves (True or False)

Simple Robot Domain We need a language to express block We need a language to express the features/properties/assertions and constraints among them; also inference mechanisms, i.e, principled ways of performing reasoning. Example - logical statement about the robot: (BatIsOk and BlockLiftable) implies RobotMoves

Binary valued featured descriptions Consider the following description: The router can send packets to the edge system only if it supports the new address space. For the router to support the new address space it is necessary that the latest software release be installed. The router can send packets to the edge system if the latest software release is installed. The router does not support the new address space. Features: Router Feature 1 – router can send packets to the edge of system Feature 2 – router supports the new address space Latest software release Feature 3 – latest software release is installed

Binary valued featured descriptions Constraints: The router can send packets to the edge system only if it supports the new address space. (constraint between feature 1 and feature 2); It is necessary that the latest software release be installed for the router to support the new address space . (constraint between feature 2 and feature 3); The router can send packets to the edge system if the latest software release is installed. (constraint between feature 1 and feature 3); How can we write these specifications in a formal language and reason about the system? (will be explained in the following slides)

1.1 Propositional Logic

Logic Crucial for mathematical reasoning Used for designing electronic circuitry Logic is a system based on propositions. A proposition is a statement that is either true or false (not both). We say that the truth value of a proposition is either true (T) or false (F). Corresponds to 1 and 0 in digital circuits 12/1/2018

The Statement/Proposition Game “Elephants are bigger than mice.” Is this a statement? yes Is this a proposition? yes What is the truth value of the proposition? true 12/1/2018

The Statement/Proposition Game “520 < 111” Is this a statement? yes Is this a proposition? yes What is the truth value of the proposition? false 12/1/2018

The Statement/Proposition Game Is irrational. 1+1=5. Julius Caesar had 2 eggs for breakfast on his 10th birthday. John is a programmer. These statements are all propositions 12/1/2018

The Statement/Proposition Game “y > 5” Is this a statement? yes Is this a proposition? no Its truth value depends on the value of y, but this value is not specified. We call this type of statement a propositional function or open sentence. 12/1/2018

The Statement/Proposition Game 2+2. x2+3x = 5. I wish I were wise. These statements are clearly not propositions 12/1/2018

The Statement/Proposition Game “Today is January 1 and 99 < 5.” Is this a statement? yes Is this a proposition? yes What is the truth value of the proposition? false 12/1/2018

The Statement/Proposition Game “Please do not fall asleep.” Is this a statement? no It’s a request. Is this a proposition? no Only statements can be propositions. 12/1/2018

The Statement/Proposition Game “If elephants were red, they could hide in cherry trees.” Is this a statement? yes Is this a proposition? yes What is the truth value of the proposition? probably false 12/1/2018

The Statement/Proposition Game “x < y if and only if y > x.” Is this a statement? yes Is this a proposition? yes … because its truth value does not depend on specific values of x and y. What is the truth value of the proposition? true 12/1/2018

Propositional Logic: Syntax vs. Semantics Syntax involves whether notation is correctly formed Semantics has to do with “meaning”: it associates the elements of a logical language with the elements of a domain of discourse. Propositional Logic – involves associating atoms with propositions or assertions about the world (therefore called “propositional logic”).

Sematics Example We might associate the atom (just a symbol!) BlockIsRed with the proposition: “The block is Red”, However, we could also associate it with the proposition “The block is Black” even though this would be quite confusing… BlockIsRed has value True just in the case the block is red; otherwise BlockIsRed is False. Computers manipulate symbols. The string “BlockIsRed” does not “mean” anything to the computer. Meaning has to come from how to come from relations to other symbols and the “external world”. Hmm

Sematics Example (cont.) How can a computer / robot obtain the meaning ``The block is Red’’? The fact that computers only “push around symbols” led to quite a bit of confusion in the early days or Artificial Intelligence, Robotics, and natural language understanding.

Syntax: Elements of the language Primitive propositions --- statements like: Bob loves Alice Alice loves Bob P Q Propositional Symbols (atomic propositions) One or more propositions can be combined to form a single compound proposition. Compound propositions Bob loves Alice and Alice loves Bob P  Q ( - stands for and)

Syntax Atomic sentences are wffs: Syntax of Well Formed Formulas (wffs) or sentences Atomic sentences are wffs: Examples: P, Q, R, BlockIsRed; SeasonIsWinter; Complex or compound wffs examples, assuming that w1 and w2 are wwfs:  w1 (negation) (w1  w2) (conjunction) (w1  w2) (disjunction) (w1  w2) (implication; w1 is the antecedent; w2 is the consequent) (w1  w2) (biconditional)

Connectives ¬ - not - Negation  - and - Conjunction  - or - Disjunction  - implies - Implication  - equivalent (if and only if) - Biconditional

Propositional logic: Examples Additional Examples of wffs P  Q (P  Q)  R P  Q  P (P  Q)  (Q  P)  P Comments: Atoms or negated atoms are called literals; Examples: p and p are literals. P  Q is a compound statement or compound proposition. Parentheses are important to ensure that the syntax is unambiguous. Quite often parentheses are omitted; The order of precedence in propositional logic is (from highest to lowest):  ,, , , 

p:\msoffice\My Projects\Rosen 6e 2007\Imagebank\JPEGs07-24-06\ch01\jpeg\t01_1_008.jpg

Unary Operator, Symbol:  Negation (NOT) Unary Operator, Symbol:  P P true (T) false (F) ~p is false when p is true, ~p is true when p is false Example: p = "John is a programmer“ ~p = "It is not true that John is a programmer" 12/1/2018

Conjunction (AND) Binary Operator, Symbol:  P Q PQ T F p ^ q is true only when both p and q are true. 12/1/2018

Example Let p = “Tigers are wild animals” Let q = “Dubai is the capital of KSA” p ^ q = "Tigers are wild animals and Dubai is the capital of KSA" p ^ q is false. Why? 12/1/2018

Binary Operator, Symbol:  Disjunction (OR) Binary Operator, Symbol:  P Q PQ T F p v q is false only when both p and q are false Example: p = "John is a programmer", q = "Mary is a lawyer“ p v q = "John is a programmer or Mary is a lawyer" 12/1/2018

Exclusive Or (XOR) Binary Operator, Symbol:  or (p  q) P Q PQ T F p  q is true only when p is true and q is false, or p is false and q is true. Example: p = "John is programmer, q = "Mary is a lawyer" p v q = "Either John is a programmer or Mary is a lawyer" 12/1/2018

Implication (if - then) Binary Operator, Symbol:  P  Q (P implies Q) This is the same as “If P, then Q.” P Q PQ T F 12/1/2018

Implication (p  q) This is only False (violated) when q is False and p is True. Related implications: Converse: q  p; Contra-positive: q   p; Inverse  p   q; Important: only the contra-positive of p  q is equivalent to p  q (i.e., has the same truth values in all models); the converse and the inverse are equivalent;

Implication (p  q) Implication plays an important role in reasoning. A variety of terminologies are used to refer to implication: conditional statement if p then q if p, q p is sufficient for q q if p q when p a necessary condition for p is q (*) p implies q p only if q (*) a sufficient condition for q is p q whenever p q is necessary for p (*) q follows from p Note: the mathematical concept of implication is independent of a cause and effect relationship between the hypothesis (p) and the conclusion (q), that is normally present when we use implication in English. Note: Focus on the case, when is the statement False. That is, p is True and q is False, should be the only case that makes the statement false. (*) assuming the statement true, for p to be true, q has to be true

Implication Questions Let p be the statement “Nora learns discrete mathematics” and q the statement “Nora will find a good job”. Express pq as a statement in English. You can access the internet from campus only if you are a computer science major or you are not a freshman

Implication Question (cont.) Let p be the statement “Nora learns discrete mathematics” and q the statement “Nora will find a good job”. Express pq as a statement in English. Solution: Any of the following. If Nora learns discrete mathematics, then she will find a good job. Nora will find a good job when she learns discrete mathematics For Nora to get a good job, it is sufficient for her to learn discrete mathematics.

Second Conditional Question You can access the internet from campus only if you are a computer science major or you are not a freshman. Solution: Let a, c and f represent “you can access the Internet from campus” , “you are a computer science major”, and “you are a freshman”. Then above statement can be stated more simply as “You can access the internet implies that you are a computer science major major or you are not a freshman a(c  f)

Bi-Conditionals (p  q) Variety of terminology : p is necessary and sufficient for q if p then q, and conversely p if and only if q p iff q p  q is equivalent to (pq)  (q p) Note: the if and only if construction used in biconditionals is rarely used in common language; Example: “if you finish your meal, then you can play;” really means: “If you finish your meal, then you can play” and ”You can play, only if you finish your meal”.

p  q is logically equivalent to (p  q)^(q  p) Double implication The double implication “p if and only if q” is defined in symbols as p  q p q p  q (p  q) ^ (q  p) T F p  q is logically equivalent to (p  q)^(q  p) 12/1/2018

More compound statements Let p, q, r be simple statements We can form other compound statements, such as (pq)^r p(q^r) (~p)(~q) (pq)^(~r) and many others… 12/1/2018

Example: truth table of (pq)^r 12/1/2018

Statements and Operators Statements and operators can be combined in any way to form new statements. P Q P Q (P)(Q) T F 12/1/2018

Statements and Operations Statements and operators can be combined in any way to form new statements. P Q PQ  (PQ) (P)(Q) T F 12/1/2018

Equivalent Statements P Q (PQ) (P)(Q) (PQ)(P)(Q) T F The statements (PQ) and (P)  (Q) are logically equivalent, since (PQ)  (P)  (Q) is always true. 12/1/2018

De Morgan’s laws for logic The following pairs of propositions are logically equivalent: ~ (p  q) and (~p)^(~q) ~ (p ^ q) and (~p)  (~q) 12/1/2018

Tautology A proposition is a tautology if its truth table contains only true values for every case Example: p  p v q p q p  p v q T F 12/1/2018

Tautologies and Contradictions A tautology is a statement that is always true. Examples: R(R) (PQ)(P)(Q) If ST is a tautology, we write ST. If ST is a tautology, we write ST. 12/1/2018

Tautologies and Contradictions A contradiction is a statement that is always false. Examples: R(R) ((PQ)(P)(Q)) The negation of any tautology is a contradiction, and the negation of any contradiction is a tautology. 12/1/2018

Binary valued featured descriptions Example: Consider the following description: The router can send packets to the edge system only if it supports the new address space. For the router to support the new address space it is necessary that the latest software release be installed. The router can send packets to the edge system if the latest software release is installed. The router does not support the new address space. Features: Router P - router can send packets to the edge of system Q - router supports the new address space Latest software release R – latest software release is installed

The router can send packets to the edge system only if it supports Formal: The router can send packets to the edge system only if it supports the new address space. (constraint between feature 1 and feature 2) If Feature 1 (P) (router can send packets to the edge of system) then P  Q Feature 2 (Q) (router supports the new address space ) For the router to support the new address space it is necessary that the latest software release be installed. (constraint between feature 2 and feature 3); If Feature 2 (Q) (router supports the new address space ) then Feature 3 (R) (latest software release is installed) Q  R The router can send packets to the edge system if the latest software release is installed. (constraint between feature 1 and feature 3); If Feature 3 (R) (latest software release is installed) then Feature 1 (P) (router can send packets to the edge of system) R  P The router does not support the new address space. ¬ Q

Propositional Functions Propositional function (open sentence): statement involving one or more variables, e.g.: x-3 > 5. Let us call this propositional function P(x), where P is the predicate and x is the variable. What is the truth value of P(2) ? false What is the truth value of P(8) ? false What is the truth value of P(9) ? true 12/1/2018

Propositional Functions Let us consider the propositional function Q(x, y, z) defined as: x + y = z. Here, Q is the predicate and x, y, and z are the variables. What is the truth value of Q(2, 3, 5) ? true What is the truth value of Q(0, 1, 2) ? false What is the truth value of Q(9, -9, 0) ? true 12/1/2018

1.2 Quantifiers

Quantifiers A propositional function P(x) is a statement involving a variable x For example: P(x): 2x is an even integer x is an element of a set D For example, x is an element of the set of integers D is called the domain of P(x) 12/1/2018

Universal Quantification Let P(x) be a propositional function. Universally quantified sentence: For all x in the universe of discourse P(x) is true. Using the universal quantifier : x P(x) “for all x P(x)” or “for every x P(x)” (Note: x P(x) is either true or false, so it is a proposition, not a propositional function.) 12/1/2018

Universal Quantification Example: S(x): x is a KSU student. G(x): x is a genius. What does x (S(x)  G(x)) mean ? “If x is a KSU student, then x is a genius.” or “All KSU students are geniuses.” 12/1/2018

Existential quantifier For some x  D, P(x) is true if there exists an element x in the domain D for which P(x) is true. In symbols: x, P(x) The symbol  is called the existential quantifier. 12/1/2018

Existential Quantification Existentially quantified sentence: There exists an x in the universe of discourse for which P(x) is true. Using the existential quantifier : x P(x) “There is an x such that P(x).” “There is at least one x such that P(x).” (Note: x P(x) is either true or false, so it is a proposition, but no propositional function.) 12/1/2018

Existential Quantification Example: P(x): x is a KSU professor. G(x): x is a genius. What does x (P(x)  G(x)) mean ? “There is an x such that x is a KSU professor and x is a genius.” or “At least one KSU professor is a genius.” 12/1/2018

Quantification Another example: Let the universe of discourse be the real numbers. What does xy (x + y = 320) mean ? “For every x there exists a y so that x + y = 320.” Is it true? yes Is it true for the natural numbers? no 12/1/2018

Disproof by Counterexample A counterexample to x P(x) is an object c so that P(c) is false. Statements such as x (P(x)  Q(x)) can be disproved by simply providing a counterexample. Statement: “All birds can fly.” Disproved by counterexample: Penguin. 12/1/2018

Counterexample The universal statement x P(x) is false if x  D such that P(x) is false. The value x that makes P(x) false is called a counterexample to the statement x P(x). Example: P(x) = "every x is a prime number", for every integer x. But if x = 4 (an integer) this x is not a primer number. Then 4 is a counterexample to P(x) being true. 12/1/2018

Generalized De Morgan’s laws for Logic If P(x) is a propositional function, then each pair of propositions in a) and b) below have the same truth values: a) ~(x P(x)) and x: ~P(x) "It is not true that for every x, P(x) holds" is equivalent to "There exists an x for which P(x) is not true" b) ~(x P(x)) and x: ~P(x) "It is not true that there exists an x for which P(x) is true" is equivalent to "For all x, P(x) is not true" 12/1/2018

(p  q)  (q  p) and (p  q)  (q  p). Logical Equivalences Identity Laws: p  T  p and p  F  p. Domination Laws: p  T  T and p  F  F. Idempotent Laws: p  p  p and p  p  p. Double Negation Law: ( p)  p. Commutative Laws: (p  q)  (q  p) and (p  q)  (q  p). Associative Laws: (p  q)  r  p  (q  r) and (p  q)  r  p  (q  r). 12/1/2018

Summary of propositional logic In order to prove the universally quantified statement x P(x) is true It is not enough to show P(x) true for some x  D You must show P(x) is true for every x  D In order to prove the universally quantified statement x P(x) is false It is enough to exhibit some x  D for which P(x) is false This x is called the counterexample to the statement x P(x) is true 12/1/2018

Logical Equivalences Distributive Laws: p  (q  r)  (p  q)  (p  r) and p  (q  r)  (p  q)  (p  r). DeMorgan’s Laws: (p  q)  ( p   q) and (p  q)  ( p   q). Absorption Laws: p  (p  q)  p and p  (p  q)  p. Negation Laws: p   p  T and p   p  F. 12/1/2018

Examples Find the truth table of [p  (q  r)]. (An important Theorem) Show that: p  q  p  q. Show the Corollary: (p  q)  p  q. Verify the Absorption Laws: p  (p  q)  p, and p  (p  q)  p. 12/1/2018