Download Logic - United States Naval Academy

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Law of thought wikipedia , lookup

Gödel's incompleteness theorems wikipedia , lookup

Inquiry wikipedia , lookup

Propositional calculus wikipedia , lookup

Modal logic wikipedia , lookup

Analytic–synthetic distinction wikipedia , lookup

Laws of Form wikipedia , lookup

Syllogism wikipedia , lookup

Natural deduction wikipedia , lookup

Argument wikipedia , lookup

Truth wikipedia , lookup

Propositional formula wikipedia , lookup

Meaning (philosophy of language) wikipedia , lookup

Interpretation (logic) wikipedia , lookup

Falsifiability wikipedia , lookup

Principia Mathematica wikipedia , lookup

Accessibility relation wikipedia , lookup

Truth-bearer wikipedia , lookup

Transcript
SM242 Week 1 (Notes based on Epp Text, Chapter 1)
I. Logic
Are there "rules" or "laws" that govern proper reasoning? Can we prove, mathematically, that a particular
argument is valid? To what extent can reasoning be automated?
1. Statement (proposition): a sentence that is either true or false, but not both.
Example. Determine if each of the following sentences is a statement.
a. 5 + 3 = 7
b. 21 / 7 = 3
c. MIDN Miller is President of the United States
d. Ah,…the joy of SM242!
e. He is a midshipman
f. MIDN Avworo has written C++ programs.
g. Baltimore is the capital of Maryland.
h. 3 * z < 9
i. Every even integer greater than 2 is the sum of two primes
j. This sentence is false.
2. Compound Statements: a more complex statement composed of simpler statements. The truthvalue of a compound statement depends on the truth values of the simpler component statements.
The component statements in a compound statement are often referred to as statement variables.
A compound statement usually consists of statement variables joined by logical connectives.
3. Logical Connectives:
A.
Not (negation)
1.
2.
3.
4.
5.
Mathematical symbol: ~
~p means "it is not the case that p" where p is some statement.
Other notations:  p , p
C++ notation:
The negation of a statement has the opposite truth-value from the statement. If p is true,
~p is false.
6. The definition of negation is displayed in a truth table
1
B.
p
~p
F
T
T
F
And (conjunction)
1. Mathematical symbol: 
2. p  q means “it is the case that p and q are true.”
3. C++ notation:
4. The conjunction of two statements p and q is true when and only when both p and q are
both true.
5. The definition of conjunction is displayed in a truth table
pq
p q
F F
F T
T F
T T
6. Example
p:
MIDN Berrios is an officer
q:
MIDN Berrios is a gentleman
p q:
C.
Or (disjunction)
Mathematical Symbol:  
Also called "inclusive or"
C++ notation:
The disjunction of two statements p  q is true if either p or q is true, or if both p and q
are true.
5. The definition of disjunction is displayed in a truth table
1.
2.
3.
4.
p
q
pq
6. Example
p:
it is rainy
q:
it is cold
p q:
2
D.
Exclusive or
1. Mathematical Symbol:  , XOR
2. p  q is true if either p is true or q is true, but not both.
3. The definition of exclusive or is displayed in a truth table
p
E.
pq
q
Precedence of logical connectives
Negation has higher precedence than conjunction(  ) and disjunction(  ). Conjunction and
disjunction are usually considered to have the same precedence. Note that this differs from
the C++ high-level language, in which conjunction has a higher precedence than disjunction.
Example:
~ p  q is performed as
Parenthesis can be used to override normal precedence. Example:
It is important that we use parenthesis to avoid ambiguity
Example: Consider p  q   r . Is this (p  q)  r or p  (q  r) ?
4. Translating English into symbolic logic statements
A.
Example
Let p = “It is chilly” and q = “It is overcast” . Translate each of the following compound
statements into a mathematical statement using symbolic logic.
B.

It is not chilly but it is overcast

It is not both chilly and overcast

It is neither chilly nor overcast
Example
Let p = “0 < x” , q = “x < 2” and r = “x = 2”. Translate each of the following compound
statements into a mathematical statement using symbolic logic, given that x is a particular
real number.

x2

0<x<2

0<x  3
3
5. Assigning truth values to compound statements
We know the truth table for p  q and s  r. But what is the truth table for a compound statement,
such as ~(p  q)  (s  r)?
To develop the truth table for a complex statement we must consider each combination of truth
values for the component statements.
A.
Example: Write the truth table for ~ p  q
Start by making columns for p and q, considering all possible combinations of true and false.
p
q
Now, use the definition of ~ to write a column for ~p. Then, write a column for ~ p  q
using the definition of disjunction.
p
B.
q
~p
~ pq
Example Write a truth table for (p  q)  ~(p  q)
p
q
Have you seen this truth table before?
4
C.
Example Write a truth table for ( p  q )  ~ r
6. Logical Equivalence
Two (compound) expressions are logically equivalent if and only if they have identical truth values
for all possible combinations of truth values for the sub-expressions. If A and B are logically
equivalent, we write A  B . (Another notation for logical equivalence is  ; that is, if A and B are
logically equivalent then A  B .)
To test if A and B and logically equivalent, construct truth tables for A and B. If the truth values of A
and B match for all rows in the truth table, then A  B .
A.
B.
Example: Are p and ~ (~ p)
p
~p
F
T
T
F
Example: Are ~  p  q  and
logically equivalent?
~ (~ p)
F
T
~ p  ~q logically equivalent?
p
q
pq
F
F
T
T
F
T
F
T
F
F
F
T
~  p  q
T
T
T
F
5
~p
T
T
F
F
~q
T
F
T
F
~ p  ~q
T
F
F
F
7. DeMorgan’s Laws
A.
Example. Show that ~( p  q)
 ~p  ~q
Think about this equivalence. Does it make sense?
Consider the compound statement: MIDN Mincks is 20 years old and he is in the Navy.
For this to be true, it must be the case that it is true that MIDN Mincks is 20 years old and it
is true that MIDN Mincks is in the Navy.
Now think of the negation of this compound statement. For this to be false, one or both of
the parts of the compound statement must be false.
So, the negation of “MIDN Mincks is 20 years old and he is in the Navy” is
B.
We can also slow that ~( p  q )
 ~p  ~q
C.
DeMorgan’s Laws
~( p  q)
~( p  q )
D.
Example: What is the negation of the statement: “It is cold or it is raining.”
 ~p  ~q
 ~p  ~q
8. Tautologies A tautology is a statement that is always true.
Example: Consider p  ~ p
p
~p
p ~ p
F
T
T
F
T
T
6
9. Contradictions A contradiction is a statement that is always false.
Example: Consider
p ~p
p
~p
p ~p
F
T
T
F
F
F
10. Summary of Logical Equivalences (Text Chapter 1 page 14)
11. Using logical equivalences to simplify statements
We can use the table on page 14 of the text to simplify statements.
A.
Example. Simplify the following compound statement:
( p  ~q )  [ ( p  q )  q ]
Applying the Absorption Law to the right side (the side in square brackets), we have:
( p  ~q )  q
Then applying the Distributive Law, we have:
( p  q )  ( ~q  q )
Then, using the Negation Law, we have:
(p  q)  T
where T is “true.” Then, using the Identity Law, we finally have:
(p  q)
or, since parenthesis aren’t needed, p  q.
B.
Example. Simplify the following compound statement: ~(~p  q)   p  q 
7
12. Implication We want to be able to reason from a hypothesis to a conclusion. We want to be able
to say “If p is true, then q must be true.” or, more compactly
“if p, then q.”
  
This is written symbolically as pq. This is also called a “conditional.”
A. Examples:
If MIDN Collard is a midshipman then MIDN Collard is in the Navy.
If x > 2 then x > 0.
If snow accumulation exceeds 50 inches then classes are canceled.
B. Truth table for pq.
p
F
F
T
T
q
F
T
F
T
pq
Suppose I tell you,
“If you have a 95 average then you will get an A.”
hypothesis
conclusion
When is this sentence false?
Answer:
p
F
F
T
T
q
F
T
F
T
pq
If we have statements p and q, then pq is read “p implies q” and means that pq is true.
C. Precedence: In expressions that contain “”, the “” is evaluated last.
D. English expressions which mean 
In addition to expressing pq as “if p then q,” the following English expressions are also used
(note that these expressions parallel the normal English meaning of “if p then q”):
if p, q
p implies q
q if p
8
q whenever p
E. Example.
Construct a truth table for the statement
p  ~ q  ~ p
F. Example: Show that the conditional pq is logically equivalent to that statement ~ p  q. That is,
show pq  ~ p  q
G. Example. Prove that ~( pq ) is logically equivalent to p  ~q.
(Do on your own!)
13. The contrapositive: The contrapositive of pq is ~ q ~ p.
A. A conditional statement is logically equivalent to its contrapositive.
B. Examples: Write each of the following in its equivalent contrapositive form.

If today is Wednesday then tomorrow is Thursday.

If the temperature goes up then it will be hotter.

If today is Friday then I have a quiz today
9
C. Suppose we have the conditional p  q . The contrapositive is ~ q ~ p which, in English, is
Think about this sentence. It says if q does not occur, then p does not occur. This means that p can only
occur if q occurs. Or, to put it more succinctly:
To summarize, the following are all equivalent:









if p then q
if p, q
q if p
q whenever p
p implies q
p q
if not q then not p
~ q ~ p
p only if q
14. Example
Let
a = “You can access the Internet from Bancroft Hall”
c = “You are a computer science major”
f = “You are a plebe”
Translate the following English sentence to a logical expression:
“You can access the Internet from Bancroft Hall only if you are a computer science major or
you are not a plebe.”
15. Necessary and sufficient conditions
Consider the sentence “p is a sufficient condition for q.” Isn’t this what we normally mean in English
when we say “if p then q”? Hopefully you answered “yes,” and so we have yet another meaning for p
 q, namely: “p is a sufficient condition for q.”
Try to hang on for one more! Consider the sentence “q is a necessary condition for p.” To say that q is
a necessary condition for p means the occurrence of q is necessary for p to occur; if q does not occur
then p can’t occur: ~ q  ~ p (if not q, then not p).
But considering the contrapositive, this is the same as p  q
10
(i.e., if p then q).
So, to summarize again, the following are all equivalent:











if p then q
if p, q
q if p
q whenever p
p implies q
p q
if not q then not p
~ q ~ p
p only if q
p is a sufficient condition for q
q is a necessary condition for p
16. Review
Question 1. Consider the sentence: MIDN Craner will get an A only if he hands in all his homework.
(a) Express this as if A then B.
(b) What would be an alternative equivalent way to express this?
(c) Is this a third way to express the original sentence?
homework, then he received an A.
If MIDN Craner handed in all his
(d) Express the original sentence as Blah is a necessary condition for Bleh.
(e) Express the original sentence as Blah is a sufficient condition for Bleh.
(f) Given the original sentence, can I conclude that MIDN Craner having handed in all his
homework is a sufficient condition for his having received an A?
11
Question 2. Consider the sentence: If MIDN O’Brien is a midshipman at the USNA, then he is not
married.
(a) Express this as Blah is a necessary condition for Bleh.
(b) Is this correct: Being a midshipman at USNA is a necessary condition for MIDN O’Brien to be
unmarried.
(c) Express the original sentence as Blah is a sufficient condition for Bleh.
(d) From the original sentence, is it correct to conclude: Being unmarried is a sufficient condition
for me to conclude that MIDN O’Brien is a USNA midshipman.
(e) Express the original sentence as p only if q.
Question 3. Consider the sentence:
The fact that MIDN Cunha lives in Bancroft Hall is a sufficient condition for me to conclude
that he is a midshipman.
(a) Convert this statement to if p then q:
(b) Express this as Blah is a necessary condition for Bleh.
(c) From the original sentence, is it correct to conclude that living in Bancroft Hall is a necessary
condition for being a midshipman?
(d) Express the original sentence as p only if q.
Question 4. Consider the sentence:
MIDN Harrison’s being a senior is a necessary condition for him to be Brigade Commander.
(a) Convert this statement to if p then q:
(b) Convert this statement to an alternative form of if p then q:
12
(c) Express the original sentence as Blah is a sufficient condition for Bleh.
Question 5. What is the truth value of this statement: If 2 + 2 = 5 then MIDN Tublin is a deity.
Question 6. What is the negation of the following statement: If MIDN Hess is a senior then she is
cynical.
Question 7. Suppose p and q are statements and p → q is known to be false. What is the value of p  q?
Question 8. What is the negation of the following statement:
If n is prime then n is odd or n is two.
Question 9. Suppose Midshipman Regulations are modified such that midshipmen can own pets (and
harbor them in their Bancroft Hall room). However, Regulation 143.46.51 Section 15, Paragraph 5,
Subparagraph 3, Subsection 400, says:
“It is against regulation for any midshipman to keep more than 2 dogs and 2 cats in
his room in Bancroft Hall.”
Midshipman Marsal is found to be keeping 38 dogs and no cats in his room. Is he in violation of the
aforementioned regulation? Explain.
13
Question 10. What is the negation of the statement “ x < 5 or x is odd” ?
Question 11. Your Company Officer tells you that he will make you Company Commander only if by
senior year you have a CQPR greater than 2.8 and a military QPR greater than 3.0. When you reach
senior year your CQPR is 3.5 and your military QPR is 3.6 but your Company Officer does not make
you Company Commander. Did your Company Officer lie to you? Explain.
17. The converse: The converse of p → q is q → p.
In other words, the converse of if p then q is if q then p.
A. The converse of a statement is not logically equivalent to the statement. If a conditional statement is
true, its converse may or may not be true.
B. Examples: What is the converse of the following statements?

If today is Wednesday then tomorrow is Thursday.

If today is Labor Day, then today is a holiday.

If I can run 2 miles, then I can run 1 mile.

If I turned on the light switch, then the light came on.
14
18. The inverse: The inverse of p  q is ~ p  ~ q.
In other words, the inverse of if p then q is if ~p then ~q.
A. The inverse of a statement is not logically equivalent to the statement. If a conditional statement is
true, its inverse may or may not be true.
B. Examples. What is the inverse of the statements in the last example?




C. Answer the following three True/False questions.
i) A conditional statement and its converse are logically equivalent.
ii) A conditional statement and its inverse are logically equivalent.
iii) The converse and the inverse of a conditional statement are logically equivalent to each
other.
D. Example. For each of the following statements, write the contrapositive, converse and inverse

If he is an Ensign, then he is a naval officer.
Contrapositive:
Converse:
Inverse:

If n is divisible by 10, then n is divisible by 5 and n is divisible by 2
Contrapositive: If n is not divisible by 5 or n is not divisible by 2, then n is not divisible by
10.
Converse: If n is divisible by 5 and n is divisible by 2 then n is divisible by 10.
Inverse: If n is not divisible by 10 then n is not divisible by 5 or n is not divisible by 2.
15
19. The biconditional
A. Given two statements p and q, the biconditional p ↔ q, read “p if and only if q,” is the statement that
is true if p and q have the same truth values and is false if p and q have opposite truth values.
p
q
p↔q
Thus, the statement “p if and only if q” is really saying two things:


So saying “p if and only q” is saying:
or, symbolically
B. Again, p ↔ q is logically equivalent to the conjunction of p  q and q  p. But we already said
that p  q is equivalent to the statement that
Similarly, we said that q  p is equivalent to the statement
Taking the conjunction of these two statement we have p ↔ q is equivalent to saying
C. The following is an example of a biconditional: An integer is even if and only if it is divisible by 2.
D. To summarize, the following are all equivalent

p↔q

(pq )  (q p)

p is a necessary and sufficient condition for q

p if and only if q

E. Example: Express the statement “I am happy if and only if I have found true love” as the
conjunction of two if-then statements.
F. Notation. From now on, we will very often abbreviate “if and only if” as iff.
16