Title: Elementary Logic
1Elementary Logic
- CS311
- Western Washington University
2A Philosophical Question
How do we reason? What a silly question for a
computer science course! We need to study this
because computer programming is all about
translating reason into specific programming
languages. In English therefore, thus, whence,
so, ergo, hence, it follows that Whenever we
state a conclusion, we are applying a rule of
logic called an inference rule.
3Inference Rules
- Modus ponens
- Let A and B be statements
- Assume A and A ? B are true
- Then we can infer that B is true
- If my homework is late, it will be marked down 15
points. - My homework is late.
- Therefore it will be marked down 15 points.
- Modus tolens
- Let A and B be statements
- If A ? B is true, and the statement B is false
- Then we infer that A is false
- If I stay up all night, I am cranky.
- Im not cranky.
- Therefore I did not stay up all night.
4- Non sequitur
- false reasoningliterally it does not follow
- Several true statements followed by a conclusion
that has nothing to do with the assumptions - Mike can run.
- Mikes dog can run.
- Therefore Mike is a dog.
To answer the question.How do we reason In
general, we apply inference rules to sentences
that we assume are true, generating new
sentences that we conclude are true. We each
develop a personal reasoning system, hopefully
based on modus ponens and modus tolens, and NOT
non sequitor!
5What is a Calculus?
A math course I took as a freshman that I
dont remember? Close. Generally speaking, a
calculus is a language of expressions of some
kind, consisting of definite rules for forming
the expressions. Additionally, there are
values, associated with the expressions, and
there are definite rules for transforming one
expression into another expression having the
same value. Is the English language a
calculus? Almost.
6What is meant by the mathematics
course Calculus? It is the calculus of real
functions. Does this fit the general definition
of a calculus? Yes. It contains definite rules
for forming the expressions. And there are
definite rules for transforming expressions into
equivalent expressions. What is a logical
calculus? There are definite rules for forming
expressions, the values of the expressions are
related to the concepts of true and false, and
there are rules for transforming one expression
into another.
7Propositional Calculus
To be a legitimate calculus, we need to
first come up with some rules and notation about
sentences. A proposition is a sentence that is
either true or false. Sample propositions The
sky is blue. Grass is green. Cafeteria food is
the best. Mean people suck. Propositions are
typically denoted by the letters P, Q, and R.
8Combining Propositions
We can combine propositions to form more
complicated propositions. Combining operations
are called connectives, and are represented by
the following symbols ? not, negation ? and,
conjunction ? or, disjunction ? conditional,
implication A truth table can be used to define
the operators for all possible values of their
operands.
9Well-formed Formulas
A Well-formed formulawffis a syntactically
correct expression. To determine if an
expression is a wff, we need to explicitly define
the syntax rules for the formation of a wff in
our language. In order to define the syntax, we
need to define the alphabet truth symbols
true, false connectives
?, ?, ?, ? propositional variables Capital
letters like P, Q, R punctuation symbols ( ,
) .
10Which expressionssentencesform wffs? Well use
an inductive definition ltwffgt lttruth symbolgt
ltpropositional lettergt ? ltwffgt
ltwffgt ? ltwffgt ltwffgt ? ltwffgt ltwffgt ?
ltwffgt ( ltwffgt ) Some examples P false Q ?
R P?(?Q) P?true Hierarchy of connective
evaluation ?, ?, ?, ?
11- Any wff has a natural syntax tree which shows
- the hierarchy of the connectives.
- ?P ? Q ? R ? P
- Each wff has a unique truth table.
- What are the semantics of a wff?
- The meaning of the truth symbols true and
- false are true and false respectively.
- The meaning of all other wffs is their truth
table. - A tautology is a wff where all truth table values
are true. - P ? ?P
- A contradiction is a wff where all truth table
- values are false.
12Equivalences
Some wffs have the same meaning, even though they
are composed of different expressions. wffs
are considered equivalent if they have the same
semanticsthey have the same truth
tables. Equivalence is expressed using the ?
symbol A ? B A ? B iff (A ? B) ? (B ? A) is a
tautology Basic equivalences are found in table
6.3 p. 314. Any equivalence can be verified using
truth tables. Equivalences can also be verified
by using other proven equivalences
13- Properties of an equivalence
- Since an equivalence is a relation, it satisfies
the - reflexive, symmetric, and transitive properties.
- A ? A
- A ? B ? B ? A
- If A ? B and B ? C then A ? C
- The Replacement Rule for an equivalence
- Any subwff of a wff can be replaced by an
- equivalent wff without changing the truth value
- of the original wff.
- Prove the following equivalence
- A ? (B ? C) ? B ?(A ? C)
14Classifying a wff
Suppose we want to classify a wff as a
tautology, a contradiction, or a
contingency. One approach is to use a truth
table. But for a proposition with n letters, the
truth table is size 2n. Another approach is to
use equivalences to solve the problem. W is a
tautology iff W(A/true) and W(A/false) are
tautologies. Is the following wff a
tautology? ((A ? B ? C) ? (A ? B)) ? (A ?
C) Use Quines method.
15Truth Functions
A truth function is a function whose arguments
can take only the values true and false, and
whose value evaluates to true and false. g(P,Q)
P ? Q is a truth function. Every wff
defines a truth function, AND every truth
function defines a wff. Let f be the following
truth function f(P,Q,R) true if either P Q
false or Q R true Identify an equivalent
wff. Every truth function is equivalent to a
propositional wff.
16Disjunctive Normal Form
Terminology A literal is a propositional letter
or its negation. P ?P Q ?Q A fundamental
conjunction is either a literal or a conjunction
of two or more literals. P P ? ? Q A disjunctive
normal form is either a fundamental conjunction
or a disjunction of two of more fundamental
conjunctions. P ? (? P ? Q) (P ? Q) ? (? Q ?
P) We can construct an equivalent DNF for any
wff. Every wff is equivalent to a DNF.
17Transforming wffs
One approach is to write out its truth
table. Another way is to use equivalences. When
using the equivalence approach First remove
all occurrences of the ? connective. Next move
all negations in side to create literals by
using DeMorgans law. Then, apply the
distributive equivalences. Construct a DNF for
the wff ((P ? Q) ? R) ? S
18Full Disjunctive Normal Form
If W is a wff containing n distinct
propositional letters, a DNF for W is called a
full disjunctive normal form if each
fundamental conjunction has exactly n literals,
one for each of the n letters appearing in
W. (P ? Q ? R) ? (? P ? Q ? R) Using truth
tables to construct DNFs will automatically
build a full DNF. Every wff that is not a
contradiction is equivalent to a full DNF.
19Conjunctive Normal Form
Analogous to fundamental conjunctions
and disjunctive normal form, there also
exists fundamental disjunctions,
conjunctive normal form, and full conjunctive
normal form.. A fundamental disjunction is a
literal or the disjunction of two or more
literals. A conjunctive normal form(CNF) is
either a fundamental disjunction or a
conjunction of two or more fundamental
disjunctions. P ? (? P ? Q) (P ? Q) ? (? Q ?
P)
20Full Conjunctive Normal Form
If W is a wff containing n distinct
propositional letters, a CNF for W is called a
full conjunctive normal form if each
fundamental disjunction has exactly n literals,
one for each of the n letters appearing in
W. (P ? Q ? R) ? (? P ? Q ? R) Every wff is
equivalent to a CNF. Every wff that is not a
tautology is equivalent to a full CNF.
21Constructing Full Normal Forms
Without constructing truth tables! To find a
full DNF,first construct a DNF from the wff. P ?
(Q ?R) ? P ? (?Q ?R) ? (P
? ?Q) ? (P ?R) Now we need to the extra
letters into each fundamental conjunction. To
add a letter to a fundamental conjunction C,
without changing the value of C, use the
following equivalence C ? C ? true ? C ?
(letter ? ?letter). Find a full DNF for the wff
P ? Q.
22To add a letter to a fundamental,
disjunction, apply an analogous process, but use
the following equivalence D ? D ? false ? D ?
(letter ? ?letter) Construct a full CNF for (P
? (Q ? R)) ? (P ? Q)