Download duality of quantifiers ¬8xA(x) 9x¬A(x) ¬9xA(x) 8x¬A(x)

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

Model theory wikipedia , lookup

Structure (mathematical logic) wikipedia , lookup

Modal logic wikipedia , lookup

Quantum logic wikipedia , lookup

History of logic wikipedia , lookup

Propositional calculus wikipedia , lookup

Syllogism wikipedia , lookup

Combinatory logic wikipedia , lookup

Curry–Howard correspondence wikipedia , lookup

Laws of Form wikipedia , lookup

Law of thought wikipedia , lookup

Mathematical logic wikipedia , lookup

Interpretation (logic) wikipedia , lookup

History of the Church–Turing thesis wikipedia , lookup

Algorithm characterizations wikipedia , lookup

Intuitionistic logic wikipedia , lookup

Algorithm wikipedia , lookup

First-order logic wikipedia , lookup

Transcript
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
Recall
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
Resolution for first-order predicate logic
- proof systems for first-order predicate logic
- convert to clause form
- natural deduction — this is sound and complete
- convert to prenex CNF
- resolution
- apply Skolemization
- do resolution on the clauses
CS 245 / Winter 2015
Predicate Logic
Identities
identities for first-order predicate logic
commutativity of quantifiers
8x8yA(x, y) ⌘ 8y8xA(x, y)
9x9yA(x, y) ⌘ 9y9xA(x, y)
9x8yA(x, y) |= 8y9xA(x, y) but not the converse
distributivity of quantifiers
9x(A(x) _ B(x)) ⌘ 9xA(x) _ 9xB(x)
8x(A(x) ^ B(x)) ⌘ 8xA(x) ^ 8xB(x)
9x(A(x) ^ B(x)) |= 9xA(x) ^ 9xB(x) but not the conve
8x(A(x) _ B(x)) |= 8xA(x) _ 8xB(x) but not the conve
CS 245 W15
Lecture 8
A. Lubiw, U. Waterloo
distributivity of quantifiers when no variable is in scope
Lecture 16
9x(A(x)
_ B) ⌘ 9xA(x)A._Lubiw,
B U. Waterloo
9x(A(x) ^ B) ⌘ 9xA(x) ^ B
8x(A(x)
_ B) to
⌘ prenex
8xA(x)
How to convert any first-order
logic formula
CNF_ B
8x(A(x) ^ B) ⌘ 8xA(x) ^ B
CS 245 W15
1. eliminate → using α → β ≡ ¬ α ⋁ β
8x(A(x) ! B) ⌘ 9xA(x) ! B
A ! 8xB(x)
2. push negations through
to predicates
using
8x(A
! B(x))
⌘
- De Morgan’s laws
- quantifier duality
duality of quantifiers
¬8xA(x) ⌘ 9x¬A(x)
¬9xA(x) ⌘ 8x¬A(x)
3. rename variables so each quantifier has a unique variable
4. pull quantifiers to the front — see next slides
At this point we have prenex form (all quantifiers in front).
5. Convert the quantifier-free subformula to CNF (use propositional
logic method) — see next slides
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
Resolution for first-order predicate logic
Skolemization
- for ∃ x not in the scope of any ∀, replace x by a new constant
- convert to clause form
- for ∃ x in the scope of ∀ y1 ∀ y2 . . . ∀ yk, replace x by a new function
- convert to prenex CNF
f(y1, y2, .. , yk)
- apply Skolemization
- do resolution on the clauses
in fact, we can apply Skolemization before pulling quantifiers to the
front, and this is more efficient (if you do this on an assignment,
state it clearly)
Theorem. If A is a sentence of first-order predicate logic and S is the
result of Skolemizing A then A is satisfiable iff S is satisfiable.
Also true for a set of sentences.
Examples
CS 245 W15
Resolving clauses
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
Q(x) means x is a rational number
R(x)
means x is a real number Lecture 17
CS 245 W15
Z(x) means x is an integer
A. Lubiw, U. Waterloo
(c) [4 marks]
Prove
Natural
Deduction:
example
of by
resultion,
start
to finish,
Resolving clauses
use example from Assign 7 2(c)
8x(A(x) ^ B(x) ! C(x)), 9x(B(x) ^ ¬C(x)) ` 9x(¬A(x))
to resolve two clauses of predicate logic,
one containing literal P( . . . )
and one containing literal ¬P( . . . ), where P is some predicate
we must unify their arguments by making substitutions
Notation for substitution: [t1/x1; t2/x2; . . . tn/xn]
where ti is a term and xi is a variable.
Meaning: replace xi by ti
Note that all the substitutions happen simultaneously.
We will not give details of the unification algorithm.
We will stick to easy examples.
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
Bigger examples of resolution.
“Schubert’s steamroller”
Wolves, foxes, birds, caterpillars, and snails are animals, and there are
some of each of them. Also there are some grains, and grains are
plants. Every animal either likes to eat all plants or all animals much
smaller than itself that like to eat some plants. Caterpillars and snails
are much smaller than birds, which are much smaller than foxes, which
in turn are much smaller than wolves. Wolves do not like to eat foxes
or grains, while birds like to eat caterpillars but not snails. Caterpillars
and snails like to eat some plants. Therefore there is an animal that
likes to eat a grain-eating animal.
3
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
Large resolution example
1. No one likes anyone of whom they are afraid.
2. No one likes anyone who does not like them.
3. All paranoids are afraid of everyone except their friends.
4. There is a paranoid, and all of his friends are also paranoid.
5. Therefore. There someone whom all non-paranoids dislike.
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 16
A. Lubiw, U. Waterloo
Trickier situations for unification
CS 245 W15
Lecture 8
A. Lubiw, U. Waterloo
Resolution for set of clauses in first-order predicate logic:
input: set of clauses C1, C2 , . . . , Cn
S = {C1, C2 , . . . , Cn}
CS 245 W15
Lecture 16
Is there an algorithm to do the following:
Input: set of first-order predicate clauses
Output: Are the clauses satisfiable, yes or no
repeat, trying to get ⊥:
choose two clauses s.t. one has literal P(..)
and the other has literal ¬P( . . . )
NO, there is no such algorithm.
if these can be unified, then resolve the two clauses, and call the result C
Is there an algorithm to do the following:
if C is ⊥ then output “unsatisfiable”
else add C to S
This is not an algorithm because we haven’t said how to make choices, and
there is no point at which we decide “satisfiable”.
Input: a formula in first-order predicate logic
Output: Is the formula valid, yes or no
NO, there is no such algorithm.
Theorem. Resolution refutation is sound and complete. Equivalently:
If output “unsatisfiable” then S is unsatisfiable.
If S is unsatisfiable, then some sequence of choices will output “unsatisfiable”.
Topic: undecidability.
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 1
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
Undecidability
Formal Logic — correctness
There are problems that cannot be solved by computer programs
(i.e. algorithms) even assuming unlimited time and space.
Computational Logic — efficiency
The big questions: (formulated by Hilbert, early 20th century)
— is there a logic system to capture all of mathematics,
with axioms and rules of deduction
— in which everything we prove is true,
and everything that is true can be proved
— is there an algorithm to prove statements from the axioms?
Proved by Alan Turing, 1936
(also by Alonzo Church)
no, Gödel
Alan Turing
1912 − 1954
no, Turing
This was before there were electronic computers.
"Once a logical formalism is established one can expect that a
systematic, so-to-say computational, treatment of logic formulas is
possible, which would somewhat correspond to the theory of
equations in algebra." Hilbert
further reading
CS 245 W15
Lecture 17
Turing’s idea of a “computer program” was a list of instructions that a
person could follow.
“computer” in early usage meant “one who computes"
http://en.wikipedia.org/wiki/Hilbert's_program
A. Lubiw, U. Waterloo
human computers, Harvard, 1890,
processing astronomy data
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
There are problems that cannot be solved by computer programs
(i.e. algorithms) even assuming unlimited time and space.
What is an “algorithm”?
The following are all equivalent:
- C programs, scheme programs, Java programs . . .
- Turing machines (Turing’s idea of an “algorithm”)
- high-level pseudo-code
human computers,
U. Pennsylvania 1940’s
computing ballistics
trajectories
We can use any of these as our definition of an algorithm.
We say that an algorithm “solves” a problem if for any input, the
algorithm produces the correct output.
e.g. an algorithm to decide if a formula is valid, must output the
correct answer (yes or no) for every input formula.
note: as a preliminary step, must be able to tell if input is a formula
(versus a garbage string). This is easy (parsing).
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
There are problems that cannot be solved by computer programs
(i.e. algorithms) even assuming unlimited time and space.
A decision problem has yes/no answers.
A decision problem that has no algorithm is called undecidable.
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
Halting Problem: Given a program P (e.g. in Scheme or Python) and
an input x, does P halt on input x?
examples
Some undecidable problems:
Validity (=provability) of a formula in first order logic: Given a
formula, is it valid?
Halting Problem: Given a program P (e.g. in Scheme or Python) and
an input x, does P halt on input x?
Program Verification: Given a specification of inputs and
corresponding outputs, and given a program P, does P meet the
specification?
Program Equivalence: Given two programs, do they produce the same
output for every input?
CS 245 W15
examples
Lecture 17
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
Proof that the Halting Problem is undecidable.
Main idea used in the proof: self-reference to get a contradiction as in
Russell’s paradox (the set of all sets that do not contain themselves).
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo
What I expect you to know/do:
- do resolution refutation for first-order logic
- understand the concept of undecidability, know some undecidable
problems
CS 245 W15
Lecture 17
A. Lubiw, U. Waterloo