Upload
baldwin-lester
View
214
Download
0
Embed Size (px)
Citation preview
Logic
Reading: Chapter 4 (44-59) from the text book
1
Propositions
• In arithmetic we work with numbers
• Similarly, the fundamental objects in logic are propositions
• Definition: A proposition is a statement that is either true or false. Whichever of these is the case, it is called truth value of the proposition.
2
Examples
1. “1 Omani Rial = 300 Bisas”2. “The pass mark of IDM course is 50”3. “7 is greater than 5”4. “There are 8 days in a week”(2) & (3) are true – (1) & (4) are false
1. “Stop talking”2. “What day of the week is it today”(1) is a command & (2) is a question so neither is proposition.
3
Predicates
• ‘x > 5’ is an example of a predicate.
• A predicate is a statement which contain one or more variables; it cannot be assigned a truth value until the value of the variables are specified.
• e.g. if x=7, the sentence is true, but if x=2, it is false.
4
Logical Structure of Propositions
• In logic, we will study propositions such as:‘If the door and the window are not both closed, then the door is
not closed or the window is not closed’
• This proposition is true because of its logical structure.
• As well, any sentence with the same logical structure must also be true.
5
Connectives
• The statement: ‘If the door and the window are not both closed, then the
door is not closed or the window is not closed’
is a compound proposition.
• It is built up from atomic proposition: ‘the door is closed’ & ‘the window is closed’
using the words and, or, not & if-then
• These words are called connectives.6
Notation for Basic Connectives
• To identify the connectives and, or, not, etc.., we will underline them (and, or, not, etc…)
• Note that if-then is also known as implies and if-and-only-if is also known as is-equivalent-to
• The 5 connectives we will use, and their symbols are given in the following table:
7
Table of Connectives
8
Connective Symbol
and
or
not
If-then (or implies)
if-and-only-if (or is-equivalent-to)
Example of Notation• Let p be the proposition
‘Cows are animals’ • And let q denote:
‘Cows produce milk’. • Then:
p q denotes the proposition ‘Cows are animals and cows produce milk’
p means ‘Cows are not animals’
Exercise : Let p and q denote respectively the propositions 'It is snowing' 'I will go skiing'.
Write down English sentence corresponding to the proposition Express the proposition: ‘If I will not go skiing then it is snowing’
in symbolic form.9
qp
The Connective ‘and’
• The everyday understanding of the term ‘and’ is that for p q to be true, p & q must both be true.
• If p is false, or q is false, or both are false, then p q is false
• This everyday understanding leads to the following truth table
10
Truth Table for ‘and’
11
p q p q
T
T
F
F
T
F
T
F
T
F
F
F
The Connective ‘or’
In everyday language, ‘or’ has two meanings
• In ‘Ali will pass or fail’, it means the result will be either a pass or a fail, but not both.
• Here, ‘or’ is used exclusively –the possibility of both outcomes is excluded
• In logic, or means the inclusive ‘or’ –i.e. p q means ‘p or q or both’
12
Truth Table for ‘or’
13
p q p q
T
T
F
F
T
F
T
F
T
T
T
F
The Connectives ‘not’ & ‘if-then’
• The truth table for not is straightforward. i.e. ifp is T then p is F & if p is F then p is T
• Now look at the connective if-then• Suppose p is the propn ‘Fatima attends tutorials’,
& q is the propn ‘Fatima will pass Discrete Maths’
• Then p q is the propn ‘If Fatima attends tutorials, then she will pass Discrete Maths’
14
The Connective ‘if-then’
• The claim is certainly true if Fatima attends tutorials & passes, so p q is T if p is T & q is T
• However, if Fatima attends tutorials and doesn’t pass, the claim is false, so p q is F if p is T & q is F
• What if p is false –i.e. Fatima doesn’t attend tutorials?
• The claim is true, because it says only what would happen if Fatima attended tutorials.
• Thus p q is true whenever p is false. 15
Truth Table for ‘if-then’
16
p q p q
T
T
F
F
T
F
T
F
T
F
T
T
The Connective ‘if-then’
• The truth table can be interpreted as:‘The only time the implication is false is if the premise is true & the conclusion is false’
• Are the following propositions true or false?:‘If the sky is yellow then cows have 6 legs’‘If the sky is blue then cows have 6 legs’
17
The Connective ‘if-and-only-if’
• The connective is defined to be true precisely when the 2 propositions it connects have the same truth value.
• i.e. p q is true whenever p & q are both true or p & q are both false.
• Thus the proposition ‘Al-Aqsa is in India if and only if apples are blue’ is true.
18
Truth Table for ‘if-and-only-if’
19
p q p q
T
T
F
F
T
F
T
F
T
F
F
T
Compound Propositions
• A compound proposition is a proposition built up from atomic (i.e. basic) propositions
• Example: Write in symbols: ‘Either Thomas Edison or Alexander Bell invented the telephone’
• Solution: Firstly define the atomic propositions:p is ‘Thomas Edison invented the telephone’q is ‘Alexander Bell invented the telephone’
Then the proposition is (p q) (p q)20
Logical Expressions
• With (p q) (p q) we could find its truth value if we knew the truth values of:
p = ‘Thomas Edison invented the telephone’q = ‘Alexander Bell invented the telephone’
• In logic, we will study expressions such as (p q) (p q), where p & q are regarded as variables, rather than specific propositions
21
Logical Expressions and Truth Tables
• If this is done, (p q) (p q) is a logical expression –it becomes a proposition only when p & q are replaced by propositions.
• This is exactly the same as algebra, x2 – 4 becomes a number only when x is replaced by a number
• The logical expression(p ∨ q) ¬(∧ p ∧ q)
can be analyzed using a truth table 22
Truth Table – Basic Connectives
23
p q p q p q p p q p q
T
T
F
F
T
F
T
F
T
F
F
F
T
T
T
F
F
F
T
T
T
F
T
T
T
F
F
T
Truth Table for (p q) (p q)
24
p q p q p q (p q) (p ∨ q) ¬(∧ p ∧ q)
T
T
F
F
T
F
T
F
T
T
T
F
T
F
F
F
F
T
T
T
F
T
T
F
Truth Tables
• If a logical expression has 2 variables, its truth table will have 4 rows (as in the example)
• If an expression has 3 variables (p, q, r), its truth table will have 8 rows – i.e. 1 row for each of the 8 ways of allocating truth values to p, q & r
25
Tautologies
• Recall the proposition:‘If the door and the window are not both closed, then the door is not closed or the window is not closed’
• If p denotes ‘the door is closed’ & q is ‘the window is
closed’, this proposition is ¬(p ∧ q) → (¬p ¬∨ q)
• The truth table for this logical expression shows that it is always true, irrespective of the truth values of p and q
• Such an expression is called a tautology 26
Contradictions• Consider the proposition
p ¬(∧ p ∨ q)
• The truth table for this logical expression shows that it is always false, irrespective of the truth values of p and q.
• Such an expression is called a contradiction.
• Exercise: Is the proposition p (¬∧ p ¬∨ q)a contradiction?
27
Logical Equivalence
• The table shows that for every combination of the truth values of p & q, the truth values of:
p ∧ q and q (∧ p ¬∨ q) are the same.
• The expressions: p ∧ q and q (∧ p ¬∨ q)
are said to be logically equivalent.28
Definition of Logical Equivalence
• Definition: 2 expressions are logically equivalent if they have the same truth values for every combination of the truth values of the variables.
• Exercise: Use a truth table to show that ¬(p ∨ q) and ¬p ¬∧ q are logically equivalent (so it doesn’t matter which expression is used for theproposition) 29
Logical Equivalence & Tautology
• If the two expressions A and B are logically equivalent, they always have the same truth values, this means that A ↔ B is always true.
• Therefore A ↔ B is a tautology
• So another way of saying that A and B are logically equivalent is to say that A ↔ B is a tautology
30
Implications
• Recall that if-then is also known as implies• i.e. p → q can be read as ‘if p then q’ or ‘p
implies q’• Expressions of the type p → q are called
implications
• The converse of p → q is q → p• The contrapositive of p → q is ¬q → ¬p
31
The Converse and Contrapositive
• Example: Consider the implication ‘If I am in Salalah, then I am in Oman’
• Its converse is: ‘If I am in Oman, then I am in Salalah’
• Its contrapositive is: ‘If I am not in Oman, then I am not in Salalah’
• In this example, the original proposition is a true sentence, its converse is false, and its contrapositive is true
32
Truth Table for Converse & Contrapositive
• Now use a truth table to investigate the expressions p → q, q → p and ¬q → ¬p
33
p q p q q p q p ¬q p
T
T
F
F
T
F
T
F
T
F
T
T
T
T
F
T
F
T
F
T
F
F
T
T
T
F
T
T
Converse and Contrapositive
• The truth table shows (by columns 3 & 7):an implication and its contrapositive are logically equivalent.
• However (by columns 3 & 4): an implication and its converse are not logically equivalent.
• Thus the results of the Salalah/Oman example aren’t surprising. 34
Arguments in Logic
• The argument consists of some premises & a conclusion which is supposed to be a consequence of the premises
• An argument has the logical expression(P1 ∧ P2) → Q
• In (P1 ∧ P2) → Q, P1 and P2are the premises and Q is the conclusion 35
Validity of an Argument
• If the argument is valid, the conclusion should be true whenever all the premises are true
• This means that if P1 ∧ P2 is true, then Q must also be true
• Thus the argument is valid provided that(P1 ∧ P2) → Q is a tautology
36
Testing the Validity of an Argument
• Let’s test the validity of the argument:[(p → q) ¬∧ p] → ¬q
• Is [(p → q) ¬∧ p] → ¬q a tautology?
• To answer this, we’ll use a truth table, though the laws of logic could also be used
37
Truth Table for the Argument
38
p q
P1p q
P2p
P1 P2(pq)p
Q
q(P1 P2) Q
[(pq) p] q
T
T
F
F
T
F
T
F
T
F
T
T
F
F
T
T
F
F
T
T
F
T
F
T
T
T
F
T
Conclusion from the Truth Table
• By the truth table, (P1 ∧ P2) → Q is not always true (i.e. it’s not a tautology), so the original argument is not valid
• In fact, row 3 of the truth table tells us why the argument is not valid:
• The premises of the argument are satisfied, but the conclusion is not satisfied
39
Laws of Logic• In a previous slide we showed:
q (p ¬q) ∧ ∨ and p q ∧ are logically equivalent
• Thus the more complicated expression can be replaced by the simpler expression without affecting the truth value
40
Laws of Logic
• Aim to simplify logical expressions effectively• Example: q (p ¬q) ≡ p q∧ ∨ ∧• The symbol ≡ means ‘is logically equivalent to’
• To do this, we establish a list of key pairs of expressions that are logically equivalent.
• The most important laws of logic follow
41
Laws of Logic
42
Law(s) of Logic Name
p ↔ q ≡ (p → q) (q → p)∧
p → q ≡ ¬p q∨
¬¬p ≡ p
equivalence
implication
double negation
p p ≡ p
p q ≡ q p
(p q) r ≡ p (q r)
p (q r) ≡ (p q) (p r)
¬(p q) ≡ ¬p ¬q
p T ≡ p
p F ≡ F
p ¬p ≡ F
p (p q) ≡ p
p p ≡ p
p q ≡ q p
(p q) r ≡ p (q r)
p (q r) ≡ (p q) (p ∧ r)
¬(p q) ≡ ¬p ¬q
p F ≡ p
p T ≡ T
p ¬p ≡ T
p (p q) ≡ p
idempotent
commutative
associative
distributive
de Morgan’s
identity
annihilation
inverse
absorption
The Laws of Logic
• The first two laws allow for the connectives ↔ and → to be removed from any expression
• All remaining laws involve just and, or & not
• Apart from the double negation law, all these remaining laws occur in pairs
43
Using the Laws of Logic• We could use the laws of logic to simplify logical
expressions
• Example: Use the laws of logic to simplify the expression: (p ¬∧ q) ∨ q
• Solution: (p ∧ ¬q) ∨ q≡ q ∨ (p ∧ ¬q) (2nd commutative
law)≡ (q ∨ p) ∧ (q ∨ ¬q) (2nd distributive law)≡ (q ∨ p) ∧ T (2nd inverse law)≡ q ∨ p (1st identity law)≡ p ∨ q (2nd commutative
law)
Therefore (p ∧ ¬q)∨ q ≡ p∨ q 44
Why not Use Truth Tables?
• Note that we could not have used truth tables in the previous example.
• Truth tables can be used to verify logical equivalences, but the laws of logic are needed to determine the equivalences in the first place.
• Thus truth tables could be used to answer the question “Verify (p ¬∧ q) ∨ q ≡ p ∨ q”
45
How to decide which law(s) to use
• There are no fixed rules to determine which law(s) to use when simplifying expressions
• However, begin by eliminating ↔ and → (if they appear) using the first 2 laws
• After this, try a law to see if it helps to simplify theexpression – if it doesn’t, then try another law
• The process gets easier with practice!46
Another Example
• Example: Simplify the expression ¬(p → ¬q) ∧ p
• Solution: ¬(p → ¬q) ∧ p≡ ¬(¬p ¬∨ q) ∧ p (implication law)≡ (¬¬p ¬¬∧ q) ∧ p (2nd de Morgan’s law)≡ (p ∧ q) ∧ p (double negation law)≡ p (∧ p ∧ q) (1st commutative law)≡ (p ∧ p) ∧ q (1st associative law)≡ p ∧ q (1st idempotent law)
47
Yet More Examples
• Exercise: Simplify the logical expression¬(p → ¬q) ¬∧ p
• Example: Use truth tables to verify thatp → q ≡ ¬p ∨ q
• Using truth tables may be a lengthy method, but it is a mechanical process that will always work.
• Using the laws of logic is usually shorter, but often it’s not easy to know which law to apply.
48