Vous êtes sur la page 1sur 30

Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logic

CS2311 Spring 2019

Gorkem Asilioglu
(Slides modified from: Laura E. Brown)

Mar. 4, 2019

1 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logic
The ability to express logical statements and reason about them is
important for virtually every area of computer science.
Learning Goals:
Usage Convert logical statements from informal language to
propositional and predicate logic expressions.
Usage Apply formal methods of symbolic propositional and
predicate logic, e.g., validity of formulae.
Usage Use the rules of inference to construct proofs in propositional
and predicate logic.
Usage Describe how symbolic logic can be used to model real-life
situations or applications.
Usage Apply formal logic proofs and/or informal but rigorous,
logical reasoning to problems.
Familiarity Describe the strengths and limitations of
propositional and predicate logic.
2 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logics

A logic is a systematic way of building a valid argument.


A logic has two parts:
language, also with two parts
syntax: rules for forming legal expressions (well-formed
sentences/formulae)
semantics: meaning of the legal expressions
rules, the set of rules are used to generate true expressions
(conclusions) from expressions taken to be true (premises)
In propositional logic, the expressions are called propositions, and
the meaning of each proposition is its truth value.

3 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logic

The atomic elements of propositional logic are:


variables (representing propositions and compound
propositions): p, q, r , . . .
connectives (logical operators): ¬ negation, ∧ conjunction, ∨
disjunction, → implication, ↔ biconditional

Also, the following definitions were covered previously:


converse, contrapositive, inverse
truth tables

4 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Key Definitions
Each combination of possible truth values for a statement
(compound proposition) is model.

Definition 1
Two compound propositions p and q are logically equivalent if
p ↔ q is a tautology (the propositions have all the same truth
values). Logical equivalence is denoted as p ≡ q. (Rosen Ch 1.3,
p. 25)

Definition 1a. If two statements have the same truth value in


every model, the statements are logically equivalent.

5 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Key Definitions

Definition 2
A compound proposition that is always true is called a tautology.
(Rosen Ch 1.3, p. 25)

Definition 2a. If a statement is true for all possible models, the


statement is valid.
Definition 3
A compound proposition that is always false is called a
contradiction. (Rosen Ch 1.3, p. 25)

Definition 3a. If a statement is not true for any models, the


statement is unsatisfiable.

6 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Key Definitions

Definition 4
A compound proposition that is neither a tautology nor a
contradiction is called a contingency. (Rosen Ch 1.3, p. 25)

Definition 4a. If a statement is true for at least one model, the


statement is satisfiable

7 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example

Example 1
Determine if the following expression is a tautology, contradiction,
or contingency.

(¬p ∧ (p ∨ q)) → q
p q ¬p p∨q ¬p ∧ (p ∨ q) (¬p ∧ (p ∨ q)) → q
T T
T F
F T
F F

8 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Equivalences

Example 2
Use a truth table to show that ¬(p ∧ q) and ¬p ∨ ¬q are
equivalent.
p q p ∧ q ¬(p ∧ q) ¬p ¬q ¬p ∨ ¬q
T T
T F
F T
F F

9 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Equivalence Laws


Table 6, 7, and 8 (p. 27-28 of Rosen) introduce several logical
equivalences that you will use repeatedly through the course.
Equivalence Law
p∧T≡p Identity laws
p∨F≡p
p∨T≡T Domination laws
p∧F≡F
p∨p ≡p Idempotent laws
p∧p ≡p
¬(¬p) ≡ p Double negation laws
The symbol T denotes the compound propositions that is always
true.
Similarly, F denotes the compound proposition that is always
false.
10 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Equivalence Laws


Equivalence Law
p∨q ≡q∨p Commutative laws
p∧q ≡q∧p
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r ) Associative laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r )
p ∨ (q ∧ r ) ≡ (p ∨ q) ∧ (p ∨ r ) Distributive laws
p ∧ (q ∨ r ) ≡ (p ∧ q) ∨ (p ∧ r )
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧ ¬q
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
p ∨ ¬p ≡ T Negation laws
p ∧ ¬p ≡ F

11 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Equivalence Laws


Logical Equivalence with
Conditional Statements
p → q ≡ ¬p ∨ q Table 7.1
p → q ≡ ¬q → ¬p Table 7.2
p ∨ q ≡ ¬p → q Table 7.3
p ∧ q ≡ ¬(p → ¬q) Table 7.4
¬(p → q) ≡ p ∧ ¬q Table 7.5
(p → q) ∧ (p → r ) ≡ p → (q ∧ r ) Table 7.6
(p → r ) ∧ (q → r ) ≡ (p ∨ q) → r Table 7.7
(p → q) ∨ (p → r ) ≡ p → (q ∨ r ) Table 7.8
(p → r ) ∨ (q → r ) ≡ (p ∧ q) → r Table 7.9
p ↔ q ≡ (p → q) ∧ (q → p) Table 8.1
p ↔ q ≡ ¬p ↔ ¬q Table 8.2
p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q) Table 8.3
¬(p ↔ q) ≡ p ↔ ¬q Table 8.4
12 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example Problems
Example 3
Show two expressions are logically equivalent using laws.
¬(q ∧ ¬p) ∨ p ≡ ¬q ∨ p

13 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example Problems
Example 4
Show two expressions are logically equivalent using laws
(p ∨ ¬q) ∧ (q ∨ ¬p) ≡ (q ∧ p) ∨ (¬p ∧ ¬q).

14 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Terminology

Definition 5
An argument is a sequence of statements that ends with a
conclusion. (Rosen, Ch 1.6, p. 69)

Definition 6
An argument is valid if the conclusion (final statement) must follow
from the truth of the preceding statements. (Rosen, Ch 1.6, p. 69)

A proof is a valid argument to cement the truth of mathematical


statements.

15 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Valid Arguments in Propositional Logic


Consider the following sequence of propositions:
“If you have a valid access card, then you can enter the computer lab.”
“You have a valid access card.”
Therefore,
“You can enter the computer lab.”

This same sequence of statements could be written, where


p represents “You have a valid access card” and
q represents “You can enter the computer lab.”
p→q
p
q

16 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Valid Arguments in Propositional Logic


p→q
p
q
If p and q are propositional variables, then

((p → q) ∧ p) → q

is a tautology.
Arguments of this form are valid.
This particular rule of inference is called modus ponens.

17 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Entailment

Definition 7
The proposition p logically entails q, denoted as p |= q, if and only
if the proposition p → q is a tautology.

Informally, if q is true in every model where p is true, then p |= q,


or p entails q.

Or, given a set of propositional statements, a knowledge base


(KB), we can show,

KB |= p
that is p follows from the KB.

18 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Rules of Inference
Templates for a Valid Argument

Modus ponens Modus tollens


p ¬q
p→q p→q
q ¬p

Hypothetical syllogism Disjunctive syllogism


p→q p∨q
q→r ¬p
p→r q

19 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Rules of Inference
Templates for a Valid Argument

Addition Simplification
p p∧q
p∨q p

Conjunction Resolution
p p∨q
q ¬p ∨ r
p∧q q∨r

20 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Logical Inference
Definition 8
If we can use the knowledge base KB to derive (or prove)
proposition p, then the KB infers p, or p is inferred from KB,
denoted as KB ` p.

To infer statements with a computer, we use inference algorithms.


For an inference algorithm i:
i is sound if whenever KB `i α, it is also true that KB |= α

i is complete if whenever KB |= α, it is also true that KB `i α

21 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example of Valid Argument


Example 5
Given the premises
1. If today is Saturday, then there are no classes today.
2. If there are no classes today, then I watch TV.
Show it leads to the conclusion
If today is Saturday, then I watch TV.

22 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example of Valid Argument


Example 5
Given the premises
1. If today is Saturday, then there are no classes today.
2. If there are no classes today, then I watch TV.
Show it leads to the conclusion
If today is Saturday, then I watch TV.

Procedure:
A Identify premises and conclusions
B Express formally (translate into logic)
C Apply rules of inference

23 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example of Valid Argument


Example 5
Given the premises
1. If today is Saturday, then there are no classes today.
2. If there are no classes today, then I watch TV.
Show it leads to the conclusion
If today is Saturday, then I watch TV.

24 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Fallacies
Is the following argument valid?
“If you have a valid access card, then you can enter the lab.”
“You can enter the lab.”
Therefore,
“You have a valid access card.”

25 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Fallacies
Is the following argument valid?
“If you have a valid access card, then you can enter the lab.”
“You do not have a valid access card.”
Therefore,
“You can not enter the lab.”

26 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example of Valid Arguments


Example 6
Given the premises
1. Programmers are dumb or programmers get jobs easily.
2. Programmers are dumb or programmers make a lot of money.
3. Programmers are not dumb.
Show it leads to the conclusion
Programmers get jobs easily and programmers make a lot of money.

27 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

28 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

Example of Valid Arguments


Example 7
Given the premises
1. If you send me a text, then I will complete the program.
2. If you do not send me a text, then I will go to sleep early.
3. If I go to sleep early, then I will wake up refreshed.
Show it leads to the conclusion
If I do not complete the program, then I will wake up feeling refreshed.

29 / 30
Introduction Logical Equivalence Laws Rules of Inference Examples Fallacies Examples

30 / 30

Vous aimerez peut-être aussi