Download 1A. Propositional Logic

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

Boolean satisfiability problem wikipedia , lookup

Canonical normal form wikipedia , lookup

Transcript
1 Propositional Logic
Required reading: Foundations of Computation. Sections 1.1 and 1.2.
1. Introduction to Logic
a. Logical consequences. If you know all humans are mortal, and you know that you are human, then
in a sense you know that you are mortal. This is an example of logical deduction. There are two
premises, and one conclusion that is deduced by logic.
b. Logic is a kind of computation. You apply rules of logic to a set of premises. Different rules can
lead you to a number of different conclusions.
c. Knowing the conclusion from the set of of premises is not always trivial. The art of logic is to find
an interesting conclusion and a chain of logical deductions from the premises to that conclusion.
d. Logic is a branch of mathematics. It has symbols, formulas, and rules of computation.
e. Our objective for this unit will be to learn those rules, and to understand why they are valid, and to
develop skill in applying them.
2. Introduction to Propositions
a. The fundamental element of thought is the proposition.
b. A proposition is a statement that has a truth value: It is either true or false.
i. “Grass is green” and “2+2=5” are propositions.
c. Propositional logic takes propositions as basic and considers how they can be combined and
manipulated.
d. In English, a proposition is expressed as a sentence, and as you know from studying grammar,
sentences have parts. “Grass is green.” There’s a subject (the grass) and a predicate (is green).
The sentence says something about the subject.
e. We can create propositions using quantifiers like “all,” “some,” and “no.” “Johnny is above
average.” “Some children are above average.”
f. Logical deduction (or proof) usually deals with quantified statements.
3. Mathematical generality
a. Since this is mathematics, we need to be able to talk about propositions without saying which
particular propositions we are talking about.
b. So we’ll use symbolic names to represent them. Usually lowercase letters: p, q, r to represent
propositions. Propositional variable.
c. p can represent any statement, and the discussion will be valid no matter which statement it
represents.
4. Logical operators
a. We combine propositions with logical operators.
b. A logical operator can be applied to one or more propositions to produce a new proposition.
c. The truth value of the new propositions is completely determined by the truth values of the
propositions to which it is applied.
d. In English, those operators are usually “and,” “or,” and “not.” “I wanted to leave and I left.”
e. English is much richer, and therefore often includes ambiguity into the propositions. In
mathematical logic, we use symbols which will eliminate all ambiguity.
i. Let p and q be propositions.
ii. Conjunction (and) operator: p ∧ q is true when both p is true and q is true, and in no other
case.
iii.Disjunction (or) operator: p ∨ q is true when either p is true, or q is true, or both p and q are
true, and in not other case.
iv.Negation (not) operator: ¬p is true when p is false, and in no other case.
5. Compound propositions
a. Operators can be used to create more complex expressions: p ∧ q (¬q) or (p ∨ q) ∧ (q ∨ r).
b. Parentheses are used to indicate the order of evaluation.
c. In the absence of parentheses, the order of evaluation is determined by precedence rules.
i. For the logical operators above, rules are: first ¬ , then ∧ , last ∨.
ii. E.g., ¬ p ∨ q ∧ r is equivalent to (¬ p) ∨ (q ∧ r).
iii.Let them work out an example: YYY
d. It is always better to put in parentheses to make up your own expressions.
i. E.g., ¬ p ∧ q versus ¬ (p ∧ q)
e. Finally, when several operators of equal precedence occur in the absence of parentheses, they are
evaluated from left to right.
i. p ∧ q ∧ r is equivalent to (p ∧ q) ∧ r [although in this case, it doesn’t matter because ∧ is an
associative operation, more on this later.]
f. Suppose we want to verify that, in fact, (p ∧ q) ∧ r and p ∧ (q ∧ r) do always have the same value.
For this we have to consider all possible combinations of values of p, q, and r.
6. Truth tables.
a. Table that shows the value of one or more compound propositions for each possible combination of
values of the propositional variables that they contain.
b. Work out example on the board together, for:
i. p ; q ; r ; p ∧ q ; q ∧ r ; (p ∧ q) ∧ r ; p ∧ (q ∧ r)
ii. The fact that the values of the two last column are identical, shows that those two expressions
are logically equivalent.
c. Obviously, hand-made truth tables only work for expressions with a relatively small number of
propositional variables.
7. Conditional operators: p → q
a. Also called implication. Read p implies q. In English, if p then q.
b. For example, p represents “Bill Gates is poor.” q represents “the moon is made of green cheese”,
then p → q would read as: “If Bill Gates is poor, then the moon is made of green cheese.”
c. In this example, p is false and q is also false. When we check the definition, p → q is a true
statement.
d. Work out a few intuitive examples.
i. From another perspective, if you know p → q, and you know q is false, then you know p must
be false.
ii. From another perspective, if you know p → q, and you know p is true, then q must be true.
iii.(¬q) → (¬p) is called the contrapositive of p → q
1. E.g., “If this is Tuesday, then we are in Belgium.” is “If we aren’t in Belgium, then this
isn’t Tuesday.”
iv. Converse: p → q is not logically equivalent to q → p
1. E.g., “If this is Tuesday, then we are in Belgium.” “If we are in Belgium, then this is
Tuesday.”
2. Both don’t have to be true, but they could be. In English, we say, “If we are in Belgium,
then this is Tuesday, and conversely.”
3. (p → q) ∧ (q → p)
v. That’s what the biconditional operator is: p ↔ q.
8. Biconditional operator: p ↔ q.
a. Check with truth tables.
b. Reads: p if and only if q.
c. Often in English, “if .. then” really means “if and only if.”
9. Exclusive OR.
a. In English, or is ambiguous, but usually means the nonexclusive: p ∨ q can be expressed as p or q,
or both. While p ⨁ q stands for p or q, but not both.
10. Precedence rules:
a. ⨁same as ∨.
b. → lower than ∧, ∨, and ¬
c. ↔ lowest precedence.
d. Work out example: p → q ∧ r ↔ ¬ p ⨁ s
e. Answer: (p → (q ∧ r)) ↔ ((¬ p) ⨁ s)
11.Any compound proposition that uses any of these operators: →, ↔, ⨁ can be written as a logically
equivalent proposition that uses only ∧, ∨, ¬.
a. Check by using truth tables:
i. p → q is logically equivalent to (¬ p) ∨ q
ii. p ↔ q is logically equivalent to ((¬ p) ∨ q) ∧ ((¬ q) ∨ p)
iii.p ⨁ q is logically equivalent to (p ∨ q) ∧ (¬ (p ∧ q)) [check]
12.Tautologies and contradictions.
a. A compound proposition is said to be a tautology if and only if it is true for all possible
combinations of truth values of the propositional variables which it contains.
i. Check ((p ∨ q) ∧ ¬ q) → p is a tautology using truth table.
ii. The fact that all entries in the last column are true tells us that the expression is a tautology.
b. A compound proposition is said to be a contradiction if and only if it is false for all possible
combinations of truth values of the propositional values which it contains.
c. Consequently, for any compound proposition P that is a tautology, ¬ P is a contradiction.
d. Two compound propositions P and Q are said to be logically equivalent (≣) if and only if the
proposition P ↔ Q is a tautology.
13.Boolean algebra
a. We have discussed how to write and interpret propositions. Boolean algebra deals with
manipulating propositions.
b. Ordinary algebra is about manipulating variables representing numbers (e.g., +, ×).
c. An algebra that deals with boolean (true/false) values. (after George Boole, 1854).
d. The algebra of numbers includes a large number of rules for manipulating expressions. E.g.,
Distributive law: x (y + z) = xy + xz.
e. This is true no matter what the values for x, y, and z are.
f. In Boolean algebra, we work with only two logical values: true and false.
g. Many of the rules of Boolean algebra are fairly obvious. Those that are not obvious can be verified
easily with a truth table. Some of the most important are:
i. Double negation: ¬ ( ¬ p ) ≣ p (e.g., “I can’t get no satisfaction.”)
ii. Excluded middle contradiction: p ∨ ¬p ≣ T , p ∧ ¬p ≣ F
iii.Identity laws: T ∧ p ≣ p , F ∨ p ≣ p
iv.Idempotent laws: p ∧ p ≣ p
v. Commutative laws: p ∨ p ≣ p
vi.Associative laws: (p ∧ q) ∧ r ≣ p ∧ (q ∧ r) , (p ∨ q) ∨ r ≣ p ∨ (q ∨ r)
vii.Distributive laws: p ∧ (q ∨ r) ≣ (p ∧ q) ∨ (p ∧ r) , p ∨ (q ∧ r) ≣ (p ∨ q) ∧ (p ∨ r)
viii.DeMorgan’s laws: ¬(p ∧ q) ≣ (¬p) ∨ (¬q) , ¬(p ∨ q) ≣ (¬p) ∧ (¬q)
h. We can verify these rules using truth tables (despite how obvious they may seem in English).
14.Substitution
a. Remember that propositional variables can stand for any propositions.
b. Therefore, you can substitute propositional variables.
c. First Substitution Law.
i. E.g., You can substitute p → q for p in the law of double negations. This allows you to simplify
expressions, with confidence that the resulting expression has the same logical value.
d. Second Substitution Law.
i. You can substitute an expression for a logically equivalent expression, wherever it occurs.
ii. Note you are not required to substitute all occurrences.
iii.We have to be careful with parenthesis.
1. The fact that p ∨ p ≣ p , does not allow us to rewrite q ∧ p ∨ p ∧ r , as q ∧ p ∧ r. Given
the order of precedence, the first proposition means: (q ∧ p) ∨ (p ∧ r). Such that p ∨ p is
not an available subexpression.
15.We can chain logical equivalences together.
a. From P ≣ Q and Q ≣ R, it follows that P ≣ R.
b. This is a consequence of the second law of substitution.
c. This means that we can show that two compound propositions are logically equivalent by finding a
chain of logical equivalences that lead from one to the other.
d. For example,
i. p ∧ (p → q) ≣ p ∧ (¬ p ∨ q)
definition of p → q
ii.
≣ (p ∧ ¬p) ∨ (p ∧ q) distributive law
iii.
≣ F ∨ (p ∧ q)
law of contradiction
iv.
≣ (p ∧ q)
identity law
e. Each step in the chain has its own justification.
f. The chain of equivalences in the above example allows us to conclude that p ∧ (p → q) is logically
equivalent to p ∧ q.
g. This means that if you were to make a truth table for these two expressions, the truth values in both
columns would be identical.
h. Another example, a compound proposition is a tautology if it’s true for all possible combinations
of truth values of the propositional variables that it contains.
i. ((p ∨ q) ∧ ¬p) → q ≣
ii.
≣
iii.... (p. 15).
16.Knowing what rules to apply is not always trivial. This is what makes algebra something of an art.
a. Rules can be combined to create rule variants. Example: Applying the commutative law to other
rules.
b. Rules can be applied in both directions.
c. For them to be useful, it’s important to understand the reasoning behind each of the rules, and not
just to know them by memory.