Vous êtes sur la page 1sur 23

CS2100: Discrete Mathematics

Propositional Logic

John Augustine

CS2100 (Odd 2012): Propositional Logic

Why Logic?

Logic is a science of the necessary laws of thought, without which no employment of the understanding and the reason takes place. (Immanuel Kant, 1785) Logic is the glue for mathematics. It helps us put together correct arguments that prove our claims. Mathematics can be thought of as the logical consequence of a few basic premises. But why logic or mathematics for CSE? We need to give guarantees that our programs and computer systems work correctly.

CS2100 (Odd 2012): Propositional Logic

Lets argue

An assertion is a statement that you claim to be true. But why should I believe you? An argument is a sequence of statements aimed at demonstrating the truth of an assertion. The last assertion is called the conclusion. The preceding assertions are called premises. premise is either a statement that we agree is true, or, a statement that follows from preceding premises. Each

CS2100 (Odd 2012): Propositional Logic

Example 1. S1: If the program syntax is incorrect or there is a division by zero, then the computer will display an error message. S2: The computer does not display an error message. S3: Therefore, the program syntax is correct and there is no division by zero. What are the premises and what is the conclusion? Is the argument correct? If so, why? If not, why not? Example 2. S1: If x < 2 or if x > 2, then x2 > 4. S2: x2 4. S3: Therefore, x > 2 and if x < 2.

CS2100 (Odd 2012): Propositional Logic

Form and Content


To a careful observer, there is some fundamental similarity between Examples 1 and 2. Lets explore that similarity carefully. Lets assign letters to each component statement in Example 1. p: the program syntax is incorrect q: there is a division by zero r: the computer will display an error message Now Example 1 becomes If p or q, then r. It is not r Therefore, p and q. Notice that this skeleton or form of our argument is not dependent on the content added in Example 1. In fact, Example 2 follows the same form, but with dierent content.
CS2100 (Odd 2012): Propositional Logic 4

Proposition

A statement or a proposition is a declarative sentence that is either true or false, but not both. Each proposition is denoted by a variable It can be true (denoted T) or false (denoted F) The negation of p is it is not the case that p. The negation of a proposition p is denoted p A compound proposition or compound statement is obtained by combining two or more propositions.

CS2100 (Odd 2012): Propositional Logic

The conjunction of p and q is p and q. It is denoted p q. Table 1: Truth Table for p q p q pq T T T T F F F T F F F F The disjunction of p and q is p or q. It is denoted p q. Table 2: Truth Table for p q p q pq T T T T F T F T T F F F

CS2100 (Odd 2012): Propositional Logic

The exclusive nor of p and q is true if exactly one of p or q is true. It is denoted by p q. Table 3: Truth Table for p q p q pq T T F T F T F T T F F F

CS2100 (Odd 2012): Propositional Logic

Conditional Statement

The conditional statement p q if the proposition if p, then q. It is false when p is true and q is false; otherwise it is true. In p q, p is called the hypothesis or antecedent or premise and q is called the conclusion. Its Propositional form is p q. Table 4: p q T T T F F T F F Truth Table for p q p p q p q F T T F F F T T T T T T
8

CS2100 (Odd 2012): Propositional Logic

Consider p q. It can be stated in many ways in English. E.g., If p, then q or if p, q p implies q p only if q p is sucient for q q is a necessary condition for p q unless p When the hypothesis is false, the conditional statement is said to be vacuously true. Why is it true? Why not false?

CS2100 (Odd 2012): Propositional Logic

Converse: q p Contrapositive: q p Inverse: p q. Question. Which of the above is true if p q?

A biconditional statement p q is the proposition p if and only if q. Table 5: Truth Table for p q p q pq T T T T F F F T F F F T

CS2100 (Odd 2012): Propositional Logic

10

Evaluating Propositional Form


Exercise 3. Can you denote the exclusive or operator using only , , and ? Exercise 4. Can you construct the truth table for (p q) p?

Operator Precedence must be observed to avoid ambiguity. 1. Negation 2. Logical And 3. Logical Or 4. Conditional 5. Bi-conditional

CS2100 (Odd 2012): Propositional Logic

11

Logical Equivalence

A compound proposition is a a tautology if it is always true a contradiction if it is always false a contingency if it is neither.

Table 6: Truth Table illustrating a tautology and a contradiction. p p p p p p T F T F F T T F The compound propositions p and q are logically equivalent if p q is a tautology. It is denoted by p q.
CS2100 (Odd 2012): Propositional Logic 12

Testing Logical Equivalence

1. Construct truth table for both p and q. 2. If all corresponding truth values for p and q are the same, then p q. Otherwise, p q. Example 5. Is (p q) p q? Table 7: Truth Table illustrating (p q) p q. p T T F F q T F T F p F F T T q F T F T pq T F F F (p q) F T T T p q F F F T

= =

CS2100 (Odd 2012): Propositional Logic

13

Well-known Logical Equivalences

Commutative Laws: (i) p q q p and (ii) p q qp Associative Laws: (i) p (q r) (p q) r and (ii) with Distributive Laws: (i) p (q r) (p q) (p r) and (ii) p (q r) (p q) (p r) Identity Laws: (i) p T p and (ii) p F p. Negation Law: (i) p p T Double Negation Law: (p) p Idempotent Laws: (i) p p p and (ii) p p p De Morgans Laws: (i) (p q) p q and (ii) (p q) p q Universal Bounds Laws: (i) p T T and (ii) p FF Absorption Laws: (i) p (p q) p and (ii) p (p q) p

CS2100 (Odd 2012): Propositional Logic

14

Exercise 6. Write the negation of the following. 1. It was hot and it was humid. 2. Ram is wet from the rain or he just completed his daily jog.

Exercise proposition

7. Simplify the following compound (p q) (p q).

CS2100 (Odd 2012): Propositional Logic

15

Lets Argue Again

Recall that an argument is a sequence of statements or propositions. An argument form is a sequence of propositional forms. You can think of the argument form as the skeleton of an argument. When an argument form is eshed in with propositions (i.e., actual statements that can be either true or false), you get an argument. The last proposition is called the conclusion. The other propositions are called premises. A argument form is valid if for every truth assignment that renders all premises to be true, the conclusion is also true. An argument is valid if its argument form is valid. Counterintuitive Note: A valid argument does not necessarily imply that the conclusion is true. The make matters worse, an invalid argument could end with a true conclusion.
CS2100 (Odd 2012): Propositional Logic 16

Example 8. The following is an argument. S1: If the network is congested, then your message will be lost. S2: Your message was lost. Conclusion: The network is congested. The argument form of the above argument is: S1 : p q S2 : q Conclusion : p

Is the above example of an argument valid? No! When we set p to be false and q to be true, all the premises are true, but the conclusion is false.

CS2100 (Odd 2012): Propositional Logic

17

Rules of Inference
Any valid argument form is a rule of inference, but we will highlight a few named rules of inference. Modus Ponens or Method of Arming. pq p q Modus Tollens or Method of Denying. pq q p Generalization. p pq
CS2100 (Odd 2012): Propositional Logic 18

Specialization. pq p Elimination. pq q p Transitivity. pq qr pr

CS2100 (Odd 2012): Propositional Logic

19

Conjunction. p q pq Resolution Principle. pq =pr qr

CS2100 (Odd 2012): Propositional Logic

20

Common Fallacies
Fallacies are errors in reasoning. Converse Error or Fallacy of Arming the Consequent. pq q p Inverse Error or Fallacy of Denying the Hypothesis.

pq p q Begging the Question or Circular Reasoning. Using the conclusion to prove the conclusion. Ambiguous Premises. Jumping to a Conclusion.
CS2100 (Odd 2012): Propositional Logic 21

Hypothesis Testing

When we seek to solve problems using logic, we can postulate a hypothesis and see if it leads to a contradiction. If it does lead to a contradiction, we can assume that our hypothesis is false. Postulating a hypothesis is just a fancy phrase for setting the truth value of a proposition.

CS2100 (Odd 2012): Propositional Logic

22

Vous aimerez peut-être aussi