Presentation is loading. Please wait.

Presentation is loading. Please wait.

Principles of Computing – UFCFA3-30-1

Similar presentations


Presentation on theme: "Principles of Computing – UFCFA3-30-1"— Presentation transcript:

1 Principles of Computing – UFCFA3-30-1
Week-6 Logic and Proposition Instructor : Mazhar H Malik Global College of Engineering and Technology

2 With Question/Answer Animations

3

4 Chapter Summary Propositional Logic Predicate Logic
The Language of Propositions Applications Logical Equivalences Predicate Logic

5 Section 1.1

6 Section Summary Propositions Connectives Truth Tables Negation
Conjunction Disjunction Implication; contrapositive, inverse, converse Biconditional Truth Tables

7 Propositions A proposition is a declarative sentence that is either true or false. Examples of propositions: The Moon is made of green cheese. Trenton is the capital of New Jersey. Toronto is the capital of Canada. d) = 1 e) = 2 Examples that are not propositions. Sit down! What time is it? c) x + 1 = 2 d) x + y = z

8 Propositional Logic Constructing Propositions
Propositional Variables: p, q, r, s, … The proposition that is always true is denoted by T and the proposition that is always false is denoted by F. Compound Propositions; constructed from logical connectives and other propositions Negation ¬ Conjunction ∧ Disjunction ∨ Implication → Biconditional ↔

9 Compound Propositions: Negation
The negation of a proposition p is denoted by ¬p and has this truth table: p ¬p T F Example: If p denotes “The earth is round.”, then ¬p denotes “It is not the case that the earth is round,” or more simply “The earth is not round.”

10 Conjunction The conjunction of propositions p and q is denoted by p ∧ q and has this truth table: p q p ∧ q T F Example: If p denotes “I am at home.” and q denotes “It is raining.” then p ∧q is raining.” denotes “I am at home and it

11 Disjunction The disjunction of propositions p and q is denoted
by p ∨q and has this truth table: is denoted p q p ∨q T F Example: If p denotes “I am at home.” and q denotes “It is raining.” then p ∨q denotes “I am at home or it is raining.”

12 The Connective Or in English
In English “or” has two distinct meanings. “Inclusive Or” - In the sentence “Students who have taken CS202 or Math120 may take this class,” we assume that students need to have taken one of the prerequisites, but may have taken both. This is the meaning of disjunction. For p ∨q to be true, either one or both of p and q must be true. “Exclusive Or” - When reading the sentence “Soup or salad comes with this entrée,” we do not expect to be able to get both soup and salad. This is the meaning of Exclusive Or (Xor). In p ⊕ q , one of p and q must be true, but not both. The truth table for ⊕ is: p q p ⊕q T F

13 Implication If p and q are propositions, then p →q is a conditional statement or implication which is read as “if p, then q ” and has this truth table: p q p →q T F Example: If p denotes “I am at home.” and q denotes “It is raining.” then p →q denotes “If I am at home then it is raining.” Example: “If I am elected, then I will lower taxes.” In p →q , p is the hypothesis (antecedent or premise) and q is the conclusion (or consequence).

14 Different Ways of Expressing p →q
if p, then q if p, q q unless ¬p q if p q whenever p q follows from p p implies q p only if q q when p p is sufficient for q q is necessary for p a necessary condition for p is q a sufficient condition for q is p

15 Definition 1. Negation of p
Let p be a proposition. The statement “It is not the case that p” is also a proposition, called the “negation of p” or ¬p (read “not p”) Table 1. The Truth Table for the Negation of a Proposition p ¬p T F F T p = The sky is blue. p = It is not the case that the sky is blue. p = The sky is not blue.

16 Definition 2. Conjunction of p and q
Let p and q be propositions. The proposition “p and q,” denoted by pq is true when both p and q are true and is false otherwise. This is called the conjunction of p and q. Table 2. The Truth Table for the Conjunction of two propositions p q pq T T T T F F F T F F F F

17 Definition 3. Disjunction of p and q
Let p and q be propositions. The proposition “p or q,” denoted by pq, is the proposition that is false when p and q are both false and true otherwise. Table 3. The Truth Table for the Disjunction of two propositions p q pq T T T T F T F T T F F F

18 Definition 4. Exclusive or of p and q
Let p and q be propositions. The exclusive or of p and q, denoted by pq, is the proposition that is true when exactly one of p and q is true and is false otherwise. Table 4. The Truth Table for the Exclusive OR of two propositions p q pq T T F T F T F T T F F F

19 Definition 5. Implication pq
Let p and q be propositions. The implication pq is the proposition that is false when p is true and q is false, and true otherwise. In this implication p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or consequence). Table 5. The Truth Table for the Implication of pq. p q pq T T T T F F F T T F F T

20 Definition 6. Biconditional
Let p and q be propositions. The biconditional pq is the proposition that is true when p and q have the same truth values and is false otherwise. “p if and only if q, p is necessary and sufficient for q” Table 6. The Truth Table for the biconditional pq. p q pq T T T T F F F T F F F T

21 Prove that (pq)  (p  q)

22 Example: DeMorgans Prove that (pq)  (p  q) T T T F F T F F
p q (pq) (pq) p q (p  q) T T T F F T F F T F F F F T F F T F T F T F F F T T T T

23 Converse, Contrapositive, and Inverse

24 Converse, Contrapositive, and Inverse
From p →q we can form new conditional statements . q →p ¬q → ¬ p ¬ p → ¬ q is the converse of p →q is the contrapositive of p →q is the inverse of p →q Example: Find the converse, inverse, and contrapositive of “It raining is a sufficient condition for my not going to town.” Or If it is raining than I do not go to town. Solution: converse: If I do not go to town, then it is raining. contrapositive: If I go to town, then it is not raining. inverse: If it is not raining, then I will go to town.

25 Biconditional p p ↔q denotes
If p and q are propositions, then we can form the biconditional proposition p ↔q , read as “p if and only if q .” The biconditional ↔q denotes the proposition with this truth table: p p q p ↔q T F If p denotes “It is fish.” and q denotes “It lives in water” p ↔q denotes “It’s fish if and only if it lives in water.” If p denotes “I am at home.” and q denotes “It is raining.” then p ↔q denotes “I am at home if and only if it is raining.”

26 Expressing the Biconditional
Some alternative ways “p if and only if q” is expressed in English: p is necessary and sufficient for q if p then q , and conversely p iff q

27 Truth Tables For Compound Propositions
Construction of a truth table: Rows Need a row for every possible combination of values for the atomic propositions. Columns Need a column for the compound proposition (usually at far right) Need a column for the truth value of each expression that occurs in the compound proposition as it is built up. This includes the atomic propositions

28 Example Truth Table Construct a truth table for p q r r p  q

29 Equivalent Propositions
Two propositions are equivalent if they always have the same truth value. Example: Show using a truth table that the conditional is equivalent to the contrapositive. Solution: p q ¬ p ¬ q p →q ¬q → ¬ p T F

30 Using a Truth Table to Show Non- Equivalence
Example: Show using truth tables that neither the converse nor inverse of an implication are not equivalent to the implication. Solution: p q ¬ p ¬ q p →q ¬ p →¬ q q → p T F

31 Precedence of Logical Operators
1 2 3 4 5 p q  r is equivalent to (p q)  r If the intended meaning is p (q  r ) then parentheses must be used.

32 Excercise Show that ¬(p ∨ q) and ¬p ∧¬q are logically equivalent.

33 Exercise: Fill up the rest of Table
q ¬q p ∨¬q p ∧ q (p ∨¬q) → (p ∧ q) T F

34 Premises, conclusion and argument
An argument in propositional logic is a sequence of propositions. All but the final proposition in the argument are called premises and the final proposition is called the conclusion. Consider these statements. The first two are called premises and the third is called the conclusion. The entire set is called an argument. “All lions are fierce.” “Some lions do not drink coffee.” “Some fierce creatures do not drink coffee

35 Addition Rule

36 Simplification Rule

37 Hypothetical syllogism

38 Hypothetical Syllogism

39 P = “You send me an e-mail message,”
Show that the premises “If you send me an message, then I will finish writing the program,” “If you do not send me an message, then I will go to sleep early,” and “If I go to sleep early, then I will wake up feeling refreshed” lead to the conclusion “If I do not finish writing the program, then I will wake up feeling refreshed.” Let P = “You send me an message,” q = “I will finish writing the program,” r = “I will go to sleep early,” s = “I will wake up feeling refreshed.” Then the premises are p → q, ¬p → r, r → s. The desired conclusion is ¬q → s. We need to give a valid argument with premises p → q, ¬p → r, and r → s and conclusion ¬q → s. Step Reason p → q 2. ¬q →¬p ¬p → r ¬q → r r → s ¬q → s Premise Contrapositive of (1) Premise Hypothetical syllogism using (2) and (3) Premise Hypothetical syllogism using (4) and (5)

40


Download ppt "Principles of Computing – UFCFA3-30-1"

Similar presentations


Ads by Google