Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL.

Similar presentations


Presentation on theme: "Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL."— Presentation transcript:

1 Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL

2 Logical Inference Why do we study propositional logic? – We want to use them to solve problems. – To solve a problem using the propositional logic, we often need to start from some “premises,” and obtain a certain “conclusion” using inferences. Example: Computer scientists often need to verify the correctness of a program. – One possible approach is to prove the program is correct. – So one can start from the program and the semantics of the used programming language (i.e., the premise), and use inference to obtain a conclusion that the program does the right job. DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

3 Logical Inference Deriving a logical conclusion by combining many propositions and using formal logic: hence, determining the truth of arguments. An argument is a sequence of statements in which the conjunction of the initial statements (called the premises/hypotheses) is said to imply the final statement (called the conclusion). An argument can be presented symbolically as (P 1 Λ P 2 Λ... Λ P n )  Q where P 1, P 2,..., P n represent the hypotheses and Q represents the conclusion. DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

4 Valid Argument What is a valid argument?  When does Q logically follow from P 1, P 2,..., P n. Informal answer: Whenever the truth of hypotheses leads to the conclusion Note: We need to focus on the relationship of the conclusion to the hypotheses and not just any knowledge we might have about the conclusion Q. Example: – P 1 : Neil Armstrong was the first human to step on the moon. – P 2 : Mars is a red planet And the conclusion – Q: No human has ever been to Mars. – P 1 Λ P 2  Q is not a tautology DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

5 Valid Argument An argument is valid if whenever the hypotheses are all true, the conclusion must also be true. A valid argument is intrinsically true, i.e. (P 1 Λ P 2 Λ... Λ P n )  Q is a tautology. How to arrive at a valid argument? – Using a proof sequence It is a sequence of propositional formulas in which each formula is either a hypothesis or the result of applying one of the formal system’s derivation rules to earlier formulas in the sequence. Generally speaking, in inference, we can always replace a logic formula with another one that is logically equivalent, just as we have seen for the implication rule. DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

6 Rules for Propositional Logic DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Derivation rules for propositional logic Equivalence RulesInference Rules Allows individual formulas to be rewritten Allows new formulas to be derived Truth preserving rulesWork only in one direction

7 Implication Rule DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic The first, and simplest, rule is: P P → Q ------------- Q This rule is called Modus ponens. Intuitively, if we have the condition of an implication, then we can obtain its consequence. Example If you study the BİM122 material, then you will pass You study the BİM122 material ______________  You will pass

8 Another Implication Rule DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Recall that P → Q   P  Q   Q →  P. The implication rule just studied tells us that  Q  Q →  P -------------  P If we replace  Q →  P in the above with P → Q, then we get another implication rule (Modus tonens):  Q P → Q -------------  P

9 Yet Another Implication Rule DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic We have: P → Q Q → R ----------  P → R Intuitively, if P implies Q and Q implies R, then we can get that P implies R. This rule is called Hypothetical syllogism. Example: P → Q means “if there is a storm, then the office is closed.” Q → R means “if the office is closed, then I don’t go to work.” P → R means “if there is a storm, then I don’t go to work.”

10 Conjunction and Simplification Rules DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Rules are not restricted to implications. For example, we have a conjunction rule: P Q ----  P  Q Intuitively, this means when you have P and Q both being true, then P  Q is also true. A closely related rule (simplification): P  Q ------  P Intuitively, this means when you have P  Q being true, clearly P is also true.

11 Disjunction Rules DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic One is (Disjunctive syllogism): P  Q  P --------  Q Another is (Addition rule): P ---------  P  Q

12 Resolution Rule DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Third disjunction rule (Resolution rule): P  Q  P  R -------------  Q  R It plays an important role in AI systems. Intuitively, it means: if P implies R and  P implies Q (why? Where do we get these implications?), then we must have either Q or R. Clearly, this is true since one of P and  P must be true.

13 Other Rules DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic We can have more rules like: P  Q P → R Q → S -------------  R  S Intuitively it means we can do inference in each of two cases (P or Q) independently.

14 Rules of Inference or Method of Proof DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Rule of InferenceTautology (Deduction Theorem)Name P  P  Q P  (P  Q) Addition P  Q  P (P  Q)  P Simplification P Q  P  Q [(P)  (Q)]  (P  Q) Conjunction P P  Q  Q [(P)  (P  Q)]  P Modus Ponens  Q P  Q   P [(  Q)  (P  Q)]   P Modus Tollens P  Q Q  R  P  R [(P  Q)  (Q  R)]  (P  R) Hypothetical Syllogism (“chaining”) P  Q  P  Q [(P  Q)  (  P)]  Q Disjunctive syllogism P  Q  P  R  Q  R [(P  Q)  (  P  R)]  (Q  R) Resolution

15 Inference Example Prove P Λ  P  Q (called Inconsistency) 1. P premise 1 2.  P premise 2 3. P V Q1, addition 4. Q V P3, commutativity 5.  (  Q) V P4, double negation 6.  Q  P5, implication 7.  (  Q)2, 6, Modus Tollens 8. Q7, double negation DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

16 Inference Example Suppose: (1) If it is Saturday today, then we play football or basketball. (2) If the football field is occupied, we don’t play football. (3) It is Saturday today, and the football field is occupied. Prove that we play basketball or volleyball. First we formalize the problem : P: It is Saturday today. Q: We play football. R: We play basketball. S: The football field is occupied. T: We play volleyball. Our premise : P  (Q  R), S  Q, P, S Need to prove : R  T DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic (1) P  (Q  R) Premise 1 (2) P Premise 2 (3) Q  R 1, 2, Implication (4) S   Q Premise 3 (5) S Premise 4 (6)  Q 3, 4, Implication (7) R 3, 6, Disjunction (8) R  T 7, Addition

17 Predicates DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Propositional logic cannot adequately express the meaning of all statements in mathematics and in natural language. For example, suppose that we know that “Every computer connected to the university network is functioning properly.” No rules of propositional logic allow us to conclude the truth of the statement “Computer3 is functioning properly,” where Computer3 is one of the computers connected to the university network. Likewise, we cannot use the rules of propositional logic to conclude from the statement “CS2 is under attack by an intruder,” where CS2 is a computer on the university network, to conclude the truth of “There is a computer on the university network that is under attack by an intruder.”

18 Predicates 18 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Statements involving variables, such as “x > 3,” “x = y + 3,” “x + y = z,” “computer x is under attack by an intruder,” “computer x is functioning properly,” are often found in mathematical assertions, in computer programs, and in system specifications. These statements are neither true nor false when the values of the variables are not specified. The statement “x is greater than 3” has two parts. The first part, the variable x, is the subject of the statement. The second part—the predicate, “is greater than 3”—refers to a property that the subject of the statement can have: P(x): “x is greater than 3” where P denotes the predicate “is greater than 3” and x is the variable. Once a value has been assigned to the variable x, the statement P(x) becomes a proposition and has a truth value.

19 Predicates 19 Example: Let P(x) denote the statement “x > 3.” What are the truth values of P(4) and P(2)? Solution: We obtain the statement P(4) by setting x = 4 in the statement “x > 3.” Hence, P(4), which is the statement “4 > 3,” is true. However, P(2), which is the statement “2 > 3,” is false. Example: Let A(x) denote the statement “Computer x is under attack by an intruder.” Suppose that of the computers on campus, only CS2 and MATH1 are currently under attack by intruders. What are truth values of A(CS1), A(CS2), and A(MATH1)? Solution: We obtain the statement A(CS1) by setting x = CS1 in the statement “Computer x is under attack by an intruder.” Because CS1 is not on the list of computers currently under attack, we conclude that A(CS1) is false. Similarly, because CS2 and MATH1 are on the list of computers under attack, we know that A(CS2) and A(MATH1) are true. DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

20 Predicates 20 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic A predicate is a property or description of subjects in the universe of discourse. The following predicates are all italicized : Ahmet is tall. The bridge is structurally sound. 17 is a prime number. By taking a variable subject denoted by symbols such as x, y, z, and applying a predicate one obtains a propositional function (or formula). When an object from the universe is plugged in for x, y, etc. a truth value results: x is tall. …e.g. plug in x = Ahmet y is structurally sound. …e.g. plug in y = FSM n is a prime number. …e.g. plug in n = 111

21 Multivariable Predicates 21 Multivariable predicates generalize predicates to allow descriptions of relationships between subjects. These subjects may or may not even be in the same universe of discourse. For example: – Ahmet is taller than Burak. – 17 is greater than one of 12, 45. – Ahmet is at least 5 centimeters taller than Burak. Q: What universes of discourse are involved? The multivariable predicates, together with their variables create multivariable propositional functions. In the above examples, we have the following generalizations: – x is taller than y – a is greater than one of b, c – x is at least n inches taller than y DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

22 Quantifiers 22 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Existential Quantifier “  ” reads “there exists” Universal Quantifier “  ” reads “for all” “  x P (x)” is true when an instance can be found which when plugged in for x makes P (x) true Like disjunctioning over entire universe  x P (x )  P (x 1 )  P (x 2 )  P (x 3 )  … “  x P (x)” true when every instance of x makes P (x) true when plugged in Like conjunctioning over entire universe  x P (x )  P (x 1 )  P (x 2 )  P (x 3 )  …

23 Predicates and Quantifiers 23 Example: Let P(x) be the statement “x + 1 > x.” What is the truth value of the quantification ∀ xP(x), where the domain consists of all real numbers? Solution: Because P(x) is true for all real numbers x, the quantification ∀ xP(x) is true. Example: Let Q(x) be the statement “x < 2.” What is the truth value of the quantification ∀ xQ(x), where the domain consists of all real numbers? Solution: Q(x) is not true for every real number x, because, for instance, Q(3) is false. That is, x = 3 is a counterexample for the statement ∀ xQ(x). Thus ∀ xQ(x) is false. DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

24 Predicates and Quantifiers 24 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic Example: Let P(x) denote the statement “x > 3.” What is the truth value of the quantification ∃ xP(x), where the domain consists of all real numbers? Solution: Because “x > 3” is sometimes true, for instance, when x = 4, the existential quantification of P(x), which is ∃ xP(x), is true. Example: Let Q(x) denote the statement “x = x + 1.”What is the truth value of the quantification ∃ xQ(x), where the domain consists of all real numbers? Solution: Because Q(x) is false for every real number x, the existential quantification of Q(x), which is ∃ xQ(x), is false.

25 Multivariate Quantification 25 Quantification involving only one variable is fairly straightforward. Just a bunch of OR’s or a bunch of AND’s. When two or more variables are involved each of which is bound by a quantifier, the order of the binding is important and the meaning often requires some thought. When evaluating an expression such as  x  y  z P (x,y,z ) translate the proposition in the same order to English: There is an x such that for all y there is a z such that P (x,y,z) holds: P (x,y,z ) = “y - x ≥ z ” 1. There is an x such that for all y there is a z such that y - x ≥ z. 2. There is some number x which when subtracted from any number y results in a number bigger than some number z. Q: If the universe of discourse for x, y, and z is the natural numbers {0,1,2,3,4,5,6,7,…} what’s the truth value of  x  y  z P (x,y,z )? DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

26 Multivariate Quantification 26 Set the universe of discourse to be all natural numbers {0, 1, 2, 3, … }. Let R (x,y ) = “x < y”. Q1: What does  x  y R (x,y ) mean? Q2: What does  y  x R (x,y ) mean? A1:  x  y R (x,y ): “All numbers x admit a bigger number y ” A2:  y  x R (x,y ): “Some number y is bigger than all x” Q: What’s the true value of each expression? A: 1 is true and 2 is false.  x  y R (x,y ): “All numbers x admit a bigger number y ” just set y = x + 1  y  x R (x,y ): “Some number y is bigger than all numbers x” y is never bigger than itself, so setting x = y is a counterexample So the order is important! DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

27 Logical Equivalence with Formulas Two logical expressions possibly involving propositional formulas and quantifiers are said to be logically equivalent if no matter what universe and what particular propositional formulas are plugged in, the expressions always have the same truth value. –  x  y Q (x,y ) and  y  x Q (y,x ) are equivalent: names of variables don’t matter. –  x  y Q (x,y ) and  y  x Q (x,y ) are not! Recall DeMorgan’s identities: Conjunctional negation:  (p 1  p 2  …  p n )  (  p 1  p 2  …  p n ) Disjunctional negation:  (p 1  p 2  …  p n )  (  p 1  p 2  …  p n ) 27 L2 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

28 Logical Equivalence with Formulas Since the quantifiers are the same as taking a bunch of AND’s (  ) or OR’s (  ) we have: Universal negation:   x P(x )   x  P(x ) Existential negation:   x P(x )   x  P(x ) Compute:   x  y x 2  y In English, we are trying to find the opposite of “every x admits a y greater or equal to x’s square”. The opposite is that “some x does not admit a y greater or equal to x’s square” Algebraically, one just flips all quantifiers from  to  and vice versa, and negates the interior propositional function. In our case we get:  x  y  ( x 2  y )   x  y x 2 > y 28 L2 DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic


Download ppt "Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL."

Similar presentations


Ads by Google