Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Structures CSC 281

Similar presentations


Presentation on theme: "Discrete Structures CSC 281"— Presentation transcript:

1 Discrete Structures CSC 281
Yuan Tian Logic Module (Part 1)

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

3 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.

4 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

5 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)

6 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

7 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

8 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)

9 1.1 Propositional Logic

10 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

11 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

12 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

13 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

14 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

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

16 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

17 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

18 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

19 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

20 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”).

21 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

22 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.

23 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)

24 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)

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

26 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):  ,, , , 

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

28 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

29 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

30 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

31 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

32 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

33 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

34 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;

35 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

36 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

37 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.

38 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)

39 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”.

40 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

41 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

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

43 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

44 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

45 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

46 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

47 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

48 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

49 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

50 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

51 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

52 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

53 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

54 1.2 Quantifiers

55 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

56 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

57 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

58 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

59 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

60 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

61 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

62 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

63 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

64 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

65 (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

66 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

67 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

68 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


Download ppt "Discrete Structures CSC 281"

Similar presentations


Ads by Google