Document 13142014

advertisement
Introduction & propositional calculus
First-order logic
Miscellaneous
Introduction & propositional calculus
First-order logic
Miscellaneous
Organization
Logic
http://www.ida.liu.se/∼TDDD72/
Andrzej Szalas
IDA, University of Linköping
December 11, 2015
Lectures, seminars, exam
9 lectures (the whole necessary material included in slides);
9 seminars (an ebook containing exercises with detailed
solutions);
written exam.
Material
Sides for lectures and an ebook for seminars can be
downloaded from the course website.
A broader material is included in many books on logics, e.g.,
M. Ben-Ari: Mathematical Logic for Computer Science.
Andrzej Szalas
Slide 1 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Introduction & propositional calculus
First-order logic
Miscellaneous
Course Contents
Lecture
1
2
3
4
5
6
7
8
9
Andrzej Szalas
Slide 2 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
The problem
Contents
Introduction to logics. Propositional calculus.
Propositional calculus: tableaux, satisfiability.
Propositional calculus: resolution.
First order logic: introduction.
First order logic: tableaux.
First order logic: resolution.
Deductive databases.
Sequent calculus, questions
Repetition (exam-like exercises).
Andrzej Szalas
Slide 3 of 337
General problem
Modeling human-like reasoning.
Specific subproblems
Modeling the world.
Correct (and possibly complete) reasoning.
Automated tools.
Andrzej Szalas
Slide 4 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Modeling
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Typical environments of intelligent systems
Modeling
A good model is a more or less simplified description of reality.
It should allow to derive conclusions valid in the modeled reality.
Usually the goal is to use as elementary formal tools as possible
to specify the model at the required level of simplification.
K1
...
K2
R ÅÆ⁀ooΛiTY
Kn
EaLity
Re Al i t y
Example
Model of a car:
a driver’s point of view: e.g., steering wheel, gears, starter,
light switches, etc.
perception
language
logic
REALITY
a designer’s point of view: e.g., model of aerodynamical flows,
models of materials’ strength, etc.
REALITY
REALITY
REALITY
a dealer’s point of view: shape, color, price, etc.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 5 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Quantitative and symbolic reasoning
Quantitative reasoning
Algorithmic methods.
Probabilistic/statistical methods.
Fuzzy logic.
Symbolic reasoning
Classical logic and logic programming.
Three- and many-valued logics.
Modal and temporal logics.
Commonsense reasoning.
Approximate reasoning.
Fuzzy logic.
Slide 7 of 337
Slide 6 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
From sensors to higher level reasoning
✻
Analytical/numerical methods.
Andrzej Szalas
Andrzej Szalas




Incomplete, 
inconsistent 

data 











Noisy, 

incomplete


data 








✻
✻ ...
✻
✻
✻
Qualitative reasoning
✻


 Qualitative
Databases


✻
...
✻
✻
Quantitative reasoning
✻
✻
...
✣
✣
✣
❪
...
Andrzej Szalas
Slide 8 of 337
❪





Quantitative

Databases



)
Sensors,
cameras,...
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What are logics?
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Modeling in logics
Logic (approximately) is the tool allowing us to perceive (specify
and reason about) the world through truth level of properties
(formulas) expressed in a given language with well defined syntax
and semantics.
Fix a formal language (dictionary, grammar).
Fix methods of correct reasoning.
Specify properties of the investigated reality in the chosen
language – obtaining a model.
Test the model by reasoning about properties of the reality.
Logic
≈ language + semantics/models (semantically)
≈ language + deduction
(syntactically)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 9 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Fixing the language
Investigate the reality solely through the level of truth
of the expressed properties.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 10 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Semantical presentation of logics
Semantical presentation depends on choosing models and
attaching interpretation of formulas in models.
The language is adjusted to a given application area. For example,
1
talking about politics we use concepts like “political party”,
“prime minister”, “parliament”, “program”, etc.
2
talking about computer science we use concepts like
“software”, “database”, “program”, etc.
We may have different vocabularies, although some names can be
the same having different meanings.
Definitions
If A is a formula and M is a model then we write M |= A
to indicate that A is true in M and M 6|= A to indicate that
A is not true in M.
If S is a set of formulas then M |= S denotes the fact that
for all A ∈ S, M |= A.
We say that a formula A is a consequence of a set
of formulas S if for any model M we have:
M |= S implies that M |= A.
Andrzej Szalas
Slide 11 of 337
Andrzej Szalas
Slide 12 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Logical language
Assume that in a model M we have three objects: o1 being a red
car, o2 being a brown car and o3 being a red bicycle. Assume
further that in our language we have propositions:
car , bicycle, red, brown.
Logical language is defined by fixing logical connectives, operators,
vocabularies and syntax rules how to form formulas.
Logical connectives and operators have a fixed meaning.
Let proposition car be T for o1 , o2 , bicycle be T for o3 , red be T
for o1 , o3 and brown be true for o2 .
Then:
Vocabularies reflect concepts of a given application area and
are flexible.
M |= red or brown
M 6|= if car then brown
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 13 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Logical language
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 14 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Logical language
Elements of a logical language – continued
Elements of a logical language
Logical constants: true, false, denoting logical values T, F.
sometimes also another,
– e.g., Unknown, Inconsistent.
Logical (propositional) variables (letters, atoms),
representing logical unknowns, e.g., p, q.
Relation symbols, representing relations, e.g., =, ≤, .
Individual constants (constants), representing objects
– e.g., 0, 1, John.
Individual variables, representing objects, e.g., x, y , m, n.
Function symbols, representing functions, e.g., +, ∗, father ().
Propositional connectives and operators allow one to create
more complex formulas from simpler formulas,
– examples of connectives: “and”, “or”, “implies”,
– examples of operators: “for all”, “exists”, “knows”,
“always”.
Auxiliary symbols, making notation easier to read
– examples: “(”, “)”, “[”, “]”.
Andrzej Szalas
Slide 15 of 337
Andrzej Szalas
Slide 16 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Bnf notation
Why “function/relation symbols” rather
than “functions/relations”?
In natural language names are not objects they denote.
In logics symbols correspond to names.
Function/relation symbol is not a function/relation,
but a name.
Comparing to natural language, – in logic:
a symbol denotes a unique object.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 17 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus
rule
S ::= S1 . . . Sn
S ::= S1 | . . . | Sn
meaning
symbol S may be replaced by sequence
S1 . . . Sn
symbol S may be replaced by one of
S1 , . . . , Sn
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 18 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus
Propositional calculus investigates the validity of complex
sentences on the basis of truth values of sub-sentences.
Let P denote the set of propositional variables.
Truth values: T, F
Formulas:
fml ::= P | ¬fml | fml ∨ fml | fml ∧ fml |
fml → fml | fml ↔ fml | (fml ) | [fml ]
Andrzej Szalas
Bnf notation allows us to define syntax of languages. There are
two forms of rules:
Slide 19 of 337
Propositional calculus investigates the validity of complex
sentences on the basis of truth values of sub-sentences.
Let P denote the set of propositional variables.
Truth values: T, F
Formulas:
fml ::= P | ¬fml | fml ∨ fml | fml ∧ fml |
fml → fml | fml ↔ fml | (fml ) | [fml ]
Andrzej Szalas
Slide 20 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus
To simplify notation we often omit brackets, assuming that
the order of precedence from high to low is: ¬, ∧, ∨, ↔, →.
Example
A ∨ ¬B ∧ C → ¬D ↔ E ∨ F
abbreviates:
!
A ∨ (¬B) ∧ C → (¬D) ↔ (E ∨ F ) .
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus
Convention
Brackets are used to make the notation unambiguous.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Examples of propositional formulas
break pedal pressed → slow down

engine on

→ motion
∧ gear on

∧ gas pedal pressed
!
!
¬gear on → ¬motion ∨ slow down
...
Slide 21 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 22 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables
Truth tables
Truth tables provide us with a semantics of logical connectives.
Truth table consists of columns representing arguments
of a connective and one (last) column representing the logical
value of the sentence built from arguments, using the connective.
Andrzej Szalas
Slide 23 of 337
Connective “not”
Connective not, denoted by ¬, expresses the negation
of a sentence.
Truth table for negation
A
F
T
Andrzej Szalas
¬A
T
F
Slide 24 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables: conjunction
Introduction & propositional calculus
First-order logic
Miscellaneous
Examples
Connective “and”
Connective and, denoted by ∧, expresses the conjunction
of sentences.
1
“Eve is a student and works part-time in a lab.”
This sentence is true when both “Eve is a student”
and “Eve works part-time in a lab” are true.
If one of these sentences if false, the whole conjunction is
false, too.
2
“Students and pupils read books” translates into
“Students read books and pupils read books.”
3
“Marc is a driver who likes his job” translates into the
conjunction “Marc is a driver and Marc likes his job”, so
connective “and” does not have to be explicit.
Truth table for conjunction
A
F
F
T
T
B
F
T
F
T
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
A∧B
F
F
F
T
Slide 25 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables: disjunction
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 26 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples
Connective “or”
Connective or, denoted by ∨, expresses the disjunction
of sentences.
Truth table for disjunction
A
F
F
T
T
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
B
F
T
F
T
Andrzej Szalas
A∨B
F
T
T
T
Slide 27 of 337
1
Sentence “Marc went to a cinema or to a shop” is false only
when Marc went neither to a cinema nor to a shop.
2
“Students and pupils read books” translates into
“If a person is a student or is a pupil then (s)he reads books”
– compare this with the translation given previously and try
to check whether these translations are equivalent.
Andrzej Szalas
Slide 28 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables: implication
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth tables: equivalence
Connective “implies”
Connective implies, denoted by →, expresses the implication of
sentences (“if then”).
Connective “equivalent to”
Connective equivalent to, denoted by ↔, expresses the equivalence
of sentences (“if and only if”).
Truth table for implication
Truth table for equivalence
A
F
F
T
T
B
F
T
F
T
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
A→B
T
T
F
T
A
F
F
T
T
Slide 29 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Satisfiability, validity
B
F
T
F
T
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
A↔B
T
F
F
T
Slide 30 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Satisfiability, validity
A tautology is a formula which is T for all possible
assignments of truth values to atomic sentences.
Tautologies are also called (valid formulas).
A formula is satisfiable if it is T for at lest one such
assignment.
A formula which is F for all such assignments is called
unsatisfiable or a counter-tautology.
Andrzej Szalas
Slide 31 of 337
z
Satisfiable
All formulas
}|
Tautologies
q
valid
Andrzej Szalas
Unsatisfiable
q
counter-tautologies
Slide 32 of 337
{
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth table method
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Truth table method
The method
Truth table method is the proof method based on truth tables.
It is also called the 0-1 method, since truth values F and T are
often denoted by 0 and 1, respectively).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 33 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Construction of truth tables for formulas
Rows: all possible assignments of F, T to atomic sentences
Columns:
first columns correspond to all “atomic sentences”, i.e.,
sentences not involving connectives;
next columns correspond to sub-formulas involving one
connective, if any;
next columns correspond to sub-formulas involving two
connectives, if any;
etc.
the last column corresponds to the whole formula.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 34 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Consider sentence
It is not the case that John does not have a daughter.
Therefore John has a daughter.
The structure of this sentence is [¬(¬A)] → A, where A
abbreviates “John has a daughter”.
Truth table for [¬(¬A)] → A
A
F
T
¬A
T
F
¬(¬A)
F
T
[¬(¬A)] → A
T
T
The same applies to any formula of the shape [¬(¬A)] → A,
no matter what A is!
For example,
“It is not true that I do not say that John is a good
candidate for this position”
implies
“I do say that John is a good candidate for this
position”.
Thus formula [¬(¬A)] → A is a tautology.
Andrzej Szalas
Slide 35 of 337
Andrzej Szalas
Slide 36 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Checking satisfiability
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Verifying counter-tautologies
Recall that a formula is satisfiable if there is at least one row in its
truth table, where it obtains value T.
Recall that a formula is a counter-tautology if in all rows in its
truth table it obtains value F.
Example
Check whether the following formula is satisfiable:
Example
Check whether the following formula is a counter-tautology:
A → [(A ∨ B) ∧ ¬B]
We construct the following truth table:
A
F
F
T
T
B
F
T
F
T
¬B
T
F
T
F
A∨B
F
T
T
T
(1)
(A ∨ B) ∧ ¬B
F
F
T
F
A
F
F
T
T
(1)
T
T
T
F
Introduction & propositional calculus
First-order logic
Miscellaneous
B
F
T
F
T
B →A
T
F
T
T
(2)
A → (B → A)
T
T
T
T
(2)
F
F
F
F
Formula (2) is F in all rows, thus it is a counter-tautology.
There are rows, where (1) is T, thus (1) is satisfiable.
Andrzej Szalas
¬[A → (B → A)]
We construct the following truth table:
Slide 37 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Example: DeMorgan’s laws
Slide 38 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: DeMorgan’s laws
DeMorgan’s laws are:
[¬(A ∧ B)] ↔ (¬A ∨ ¬B)
(3)
[¬(A ∨ B)] ↔ (¬A ∧ ¬B)
(4)
Truth table for (3)
A
F
F
T
T
B
F
T
F
T
¬A
T
T
F
F
¬B
T
F
T
F
A∧B
F
F
F
T
Andrzej Szalas
¬(A ∧ B)
T
T
T
F
Slide 39 of 337
¬A ∨ ¬B
T
T
T
F
(3)
T
T
T
T
Truth table for (4)
A
F
F
T
T
B
F
T
F
T
¬A
T
T
F
F
¬B
T
F
T
F
A∨B
F
T
T
T
Andrzej Szalas
¬(A ∨ B)
T
F
F
F
Slide 40 of 337
¬A ∧ ¬B
T
F
F
F
(4)
T
T
T
T
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Example: implication laws
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: implication laws
Consider:
Consider:
(A → B) ↔ (¬A ∨ B)
(5)
Let us check whether it is a tautology.
The following table does the job.
A
F
F
T
T
B
F
T
F
T
¬A
T
T
F
F
A→B
T
T
F
T
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(6)
Let us check whether it is a tautology.
The following table does the job.
¬A ∨ B
T
T
F
T
(5)
T
T
T
T
A
F
F
T
T
B
F
T
F
T
Slide 41 of 337
Let us return to the question about equivalence of two translations
of the sentence:
“Students and pupils read books”.
The two translations were:
1
“Students read books and pupils read books”
2
“If a person is a student or is a pupil then (s)he reads books”.
Translating those sentences into logic results in:
1’. [s → r ] ∧ [p → r ]
2’. [s ∨ p] → r ,
Slide 43 of 337
¬B
T
F
T
F
A→B
T
T
F
T
¬(A → B) A ∧ ¬B
F
F
F
F
T
T
F
F
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: three atomic sentences
Andrzej Szalas
¬(A → B) ↔ (A ∧ ¬B)
Introduction & propositional calculus
First-order logic
Miscellaneous
(6)
T
T
T
T
Slide 42 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: three atomic sentences (continued)
We check the equivalence 1′ ↔ 2′ :
s
F
T
F
T
F
T
F
T
p
F
F
T
T
F
F
T
T
r
F
F
F
F
T
T
T
T
s→r
T
F
T
F
T
T
T
T
p→r
T
T
F
F
T
T
T
T
Andrzej Szalas
s ∨p
F
T
T
T
F
T
T
T
1’
T
F
F
F
T
T
T
T
Slide 44 of 337
2’
T
F
F
F
T
T
T
T
1′ ↔ 2′
T
T
T
T
T
T
T
T
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Summary
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
The problem
The notion of a logic.
General problem
Modeling in logic.
Complexity of resoning.
Semantical presentation of logics.
Specific subproblems
What is the complexity of truth tables method?
Elements of a logical language.
Propositional calculus.
Can we do better?
Truth table method.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 45 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What is the complexity of truth table method?
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 46 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What is the complexity of truth table method?
Construction of truth tables
Construction of truth tables
A
One variable: 2 (= 21 ) rows: T
F
...
...
...
Three variables: 8 (= 2 ∗ 22 = 23 ) rows:
Construction of truth tables
Two variables: 4 (= 2 ∗ 2 = 22 ) rows:
Andrzej Szalas
A
T
F
T
F
B
T
T
F
F
Slide 47 of 337
...
...
...
...
...
A
T
F
T
F
T
F
T
F
B
T
T
F
F
T
T
F
F
C
T
T
T
T
F
F
F
F
...
...
...
...
...
...
...
...
...
In general
Whenever a new variable is added, one doubles the number of rows.
So, n variables result in 2n rows.
Andrzej Szalas
Slide 48 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What is the complexity of truth table method?
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What is correct reasoning?
The problem
How long will it take to generate 2100 rows when a computer can
generate 1015 rows per second?
A correct reasoning is based on correct (sound) arguments.
A correct (sound) argument is one in which anyone who
accepts its premises should also accept its conclusions.
2100
1015
≫ 1015 seconds
15
1015
= 10
60 ≫ 102
13
1013
= 10
60 ≫ 102
11
1011
= 10
≫
24
102
9
10 ≫ 109
= 365
103
= 1013 minutes
= 1011 hours
To see whether an argument is correct, one does not judge
whether there are good reasons for accepting the premisses,
but whether person who accepted the premisses, for whatever
reasons, good or bad, ought also accept the conclusion.
= 109 days (plus nights)
= 106 years
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 49 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 50 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Proof systems
Examples of correct arguments
if x is a parent of y , and y is a parent of z,
then x is a grandparent of z
if A and B is true, then A is true.
Proof systems allow us to formalize correct reasoning. There are
many ways to define them. For example:
analytic tableaux (Beth, Smullyan);
Gentzen-like proof systems (natural deduction);
Examples of incorrect arguments
if A implies B then B implies A
Hilbert-like systems;
resolution (Robinson).
if A or B is true, then A is true.
Andrzej Szalas
Slide 51 of 337
Andrzej Szalas
Slide 52 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
What is a proof system?
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Proof rules
Hilbert-like proof systems
Let us first illustrate the idea by Hilbert-like proof systems.
Hilbert-like proof systems consist of:
a set of axioms (i.e. “obvious” formulas accepted without
proof)
a set of proof rules (called also derivation or inference rules),
where any rule allows one to prove new formulas on the basis
of formulas proved already.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 53 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples of known rules
Proof rules are usually formulated according
to the following scheme:
if all formulas from a set of formulas F are proved
then formula A is proved, too.
Such a rule is denoted by F ⊢ A, often by ⊢ F .
⊢A
Formulas from set F are called premises (assumptions) and
formula A is called the conclusion of the rule.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 54 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples of invalid rules
Affirming the consequent
Modus ponens (MP)
⊢A
⊢A→B
⊢B
— John is a student.
— If John is a student then John learns a lot.
— Therefore, John learns a lot.
⊢A→B
⊢B
⊢A
— if there is fire here, then there is oxygen here.
— There is oxygen here.
— Therefore, there is fire here.
Denying the antecedent
Modus tollens
⊢A→B
⊢ ¬B
⊢ ¬A
— if there is fire here, then there is oxygen here.
— There is no oxygen here.
— Therefore, there is no fire here.
Andrzej Szalas
Slide 55 of 337
⊢A→B
⊢ ¬A
⊢ ¬B
— if there is fire here, then there is oxygen here.
— There is no fire here.
— Therefore, there is no oxygen here.
Andrzej Szalas
Slide 56 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Hilbert-like formal proofs
every axiom is provable
if the premises of a rule are provable then its conclusion
is provable, too.
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 57 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Hilbert-like formal proofs
The process of proving theorems can be formulated as the
following (nondeterministic) procedure, where formula A is the one
to be proved valid:
— if A is an axiom or is already proved, then the proof
is done; otherwise:
— select a set of axioms or theorems proved already
— select an applicable proof rule
— apply the selected rule and accept its conclusion
as a new theorem
— repeat the described procedure from the beginning.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 58 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Some meta-properties
Remarks
Hilbert-like prof systems reflect human-like reasoning.
They are used in mathematics and other sciences.
However, it is hard to automatize them.
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Hilbert-like formal proofs
The set of provable formulas is defined as the (smallest) set
of formulas satisfying the following conditions:
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 59 of 337
A meta-property is a property of logic rather than
of the reality the logic describes.
There are two important meta-properties relating syntactical
and semantical approaches, namely soundness (also called
correctness) and completeness of a proof system wrt a given
semantics.
Andrzej Szalas
Slide 60 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Soundness and completeness
proof system P is sound (correct) wrt the semantics S
iff every property that can be inferred using P
is true under semantics S,
proof system P is complete wrt the semantics S
iff every property that is true under semantics S
can be inferred using P.
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus: tableaux
Assume a logic is given by its semantics S and by a proof system
P. Then we say that:
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Semantic tableau for a formula A
A semantic tableau T is a tree with each node labeled with
a set of formulas, where T represents A in such a way that
A is equivalent to the disjunction of formulas appearing in all
leaves, assuming that sets of formulas labeling leaves are
interpreted as conjunctions of their members.
Slide 61 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 62 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
α-formulas
The tableau:
D, E , F , G
A
↓
B, C
ւ ց
E , H, I , J, K
represents:
D ∧E ∧F ∧G ∨ E ∧H ∧I ∧J ∧K
|
{z
} |
{z
}
the first branch
the second branch
Andrzej Szalas
Slide 63 of 337
Rule
(¬¬)
(∧)
(¬∨)
(¬ →)
(↔)
α
¬¬A1
A1 ∧ A2
¬(A1 ∨ A2 )
¬(A1 → A2 )
A1 ↔ A2
α1
A1
A1
¬A1
A1
A1 → A2
Factorization
Rule (fctr): remove redundant duplicates.
E.g. p, q, p, r , r is simplified to p, q, r .
Andrzej Szalas
Slide 64 of 337
α2
A2
¬A2
¬A2
A2 → A1
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Literals and complementary formulas
β-formulas
A literal is an atom (propositional variable) or the negation
of an atom. Atoms are called positive literals and their
negations are called negative literals.
Rule
β
(¬∧) ¬(B1 ∧ B2 )
(∨)
B1 ∨ B2
(→)
B1 → B2
(¬ ↔) ¬(B1 ↔ B2 )
β1
¬B1
B1
¬B1
¬(B1 → B2 )
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
β2
¬B2
B2
B2
¬(B2 → B1 )
Slide 65 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Closed and open leaves
For any formula A, {A, ¬A} is a complementary pair
of formulas.
A is the complement of ¬A and ¬A is the complement of A.
Remark
Observe that the conjunction of a complementary pair of formulas
is equivalent to false.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 66 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Construction of a semantic tableau for a formula C
A leaf is called closed if it contains a complementary
pair of formulas.
If a leaf consists of literals only and contains no
complementary pair of literals then we call it open.
A tableau is completed if all its leaves are open or closed.
Initially, T consists of a single node labeled with {C }.
If T is completed then no further construction is possible.
Otherwise chose a leaf, say l , labeled with S containing
a non-literal and chose from S a formula D which is not
a literal and:
if D is
then create a successor of l and label it
! an α-formula
with S − {D} ∪ {α1 , α2 }
if D is a β-formula then
! create two
new successors of l , the
first one labeled
! with S − {D} ∪ {β1 } and the second one
labeled with S − {D} ∪ {β2 }.
Andrzej Szalas
Slide 67 of 337
Andrzej Szalas
Slide 68 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Important properties
(¬p ∨ ¬q) ∧ p ∧ q
↓ (∧)
(¬p ∨ ¬q), p ∧ q
↓ (∧)
(¬p ∨ ¬q), p, q
ւ
ց (∨)
¬p, p, q
¬q, p, q
| {z }
| {z }
closed
closed
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Soundness and completeness
Let T be a completed tableau for a formula A.
Then A is unsatisfiable iff T is closed.
Slide 69 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Proving with semantic tableaux
To prove that a formula A is a tautology we construct
a completed tableau for its negation ¬A.
If the tableau is closed then A is a tautology
(its negation is not satisfiable).
Otherwise A is not a tautology.
Andrzej Szalas
The construction of a tableau always terminates and leads to
a completed tableau. A completed tableau is closed iff all its leaves
are closed.
Slide 71 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 70 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
!
To prove (p → q) → p → p we construct a closed tableau for its
negation:
!
¬ (p → q) → p → p
↓ (¬ →)
!
(p → q) → p , ¬p
ւ
ց (→)
¬(p → q), ¬p
p, ¬p
| {z }
↓ (¬ →)
closed
p, ¬q, ¬p
| {z }
closed
Andrzej Szalas
Slide 72 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Tableaux: an application
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Concepts as sets
A concept can be identified with a set of objects belonging
to the concept.
A problem
Consider the following relationships among concepts:
Humans enrolled in university courses are students.
(7)
A student can be a male or a female.
(8)
Examples
The concept of animals can be identified with a set of animals.
Good students include active students having high grades. (9)
The concept large can be identified with a set of large objects.
Good students are students.
The concept of large animals can be identified with a set
of large animals (being the intersection of large objects and
animals).
(10)
Express the resulting concept relationships (taxonomy).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 73 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Expressing concept relationships
Set-based semantics for propositional formulas
Let U be a set of objects and P be a set of propositional variables.
The set-based semantics is defined by means of a mapping ·U
assigning to each propositional variable a subset of U
(intuitively, the set of objects satisfying a given proposition).
Examples
Proposition red may denote red objects.
Proposition large may denote large objects.
Andrzej Szalas
Slide 75 of 337
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 74 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Expressing concept relationships
Set-based semantics for propositional formulas
The semantics is extended for all formulas as follows:
def
(¬A)U = U − AU
(A ∧
(A ∨
def
B)U =
AU
def
B)U =
AU
(A →
(A ↔
def
B)U ↔
def
B)U ↔
(complement)
∩
∪
AU
AU
BU
(intersection)
BU
(union)
⊆
=
BU
(inclusion)
BU
(equality)
Andrzej Szalas
Slide 76 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Expressing concept relationships
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Expressing given concept relationships
Concepts as sets
(7): (human ∩ enr ) ⊆ stud
Remarks
Set-based semantics of propositional calculus shows close
relationship between connectives and operations on sets
(thus on concepts, too).
Propositional calculus can serve as a tool for designing
and verifying taxonomies.
(8): stud ⊆ (male ∪ female)
(9): (active ∩ highG ) ⊆ goodStud
(10): goodStud ⊆ stud .
Concepts expressed in logic
(7): (human ∧ enr ) → stud
(8): stud → (male ∨ female)
(9): (active ∧ highG ) → goodStud
(10): goodStud → stud .
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 77 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Propositional calculus: terminological knowledge
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 78 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the first query using tableaux
goodStud → (male ∨ female)
Remarks
Terminological knowledge is used in knowledge representation
and Semantic Web.
Properties of taxonomies are typically investigated using
tableaux.
Sample queries
Does our taxonomy imply that good students are males
or females?
Does our taxonomy imply that good students are humans?
Andrzej Szalas
Slide 79 of 337
¬ ((human ∧ enr ) → stud ) ∧ (stud → (male ∨ female))∧
((active ∧ highG ) → goodStud ) ∧ (goodStud
→ stud) →
(goodStud → (male ∨ female))
↓ (¬ →)
((human ∧ enr ) → stud ) ∧ (stud → (male ∨ female))∧
((active ∧ highG ) → goodStud) ∧ (goodStud → stud ),
¬(goodStud → (male ∨ female))
↓ (¬ →)
((human ∧ enr ) → stud ) ∧ (stud → (male ∨ female))∧
((active ∧ highG ) → goodStud) ∧ (goodStud → stud ),
goodStud, ¬(male ∨ female)
↓ (¬∨)
Andrzej Szalas
Slide 80 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the first query using tableaux: continued
((human ∧ enr ) → stud ) ∧ (stud → (male ∨ female))∧
((active ∧ highG ) → goodStud) ∧ (goodStud → stud ),
goodStud, ¬male, ¬female
↓ (∧ – 3 times)
(human ∧ enr ) → stud , stud → (male ∨ female),
(active ∧ highG ) → goodStud , goodStud → stud ,
goodStud, ¬male, ¬female
ւ
ց (→)
(∗)
(∗∗)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 81 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the first query using tableaux: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the first query using tableaux: continued
(∗)
(human ∧ enr ) → stud , ¬stud,
(active ∧ highG ) → goodStud , goodStud → stud ,
goodStud, ¬male, ¬female
ւ
ց (→)
. . . , ¬goodStud, . . .
. . . , stud , . . .
|
|
{z
}
{z
}
closed
closed
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 82 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Tableaux: an application
(∗∗)
(human ∧ enr ) → stud, male ∨ female,
(active ∧ highG ) → goodStud, goodStud → stud,
goodStud, ¬male, ¬female
ւ
ց (∨)
. . . , female, . . .
. . . , male, . . .
{z
}
|
{z
}
|
closed
closed
A problem
How to verify the correctness of proof rules like modus ponens, etc.
The metod
Frequently, proof rules can be translated into formulas and verified
using proof systems.
Conclusion
The tableau is closed, so our taxonomy implies that good students
are males or females.
Andrzej Szalas
Slide 83 of 337
Andrzej Szalas
Slide 84 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: continued
Tableau
Modus ponens
The rule:
can be translated into:
⊢A
¬ [A ∧ (A → B)] → B
↓ (¬ →)
A ∧ (A → B), ¬B
↓ (∧)
A, A → B, ¬B
ւ
ց (→)
A, B, ¬B
A, ¬A, ¬B
| {z }
| {z }
closed
closed
⊢A→B
⊢B
[A ∧ (A → B)] → B.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 85 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 86 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: continued
Affirming the consequent
The rule:
⊢A→B
⊢A
can be translated into:
Tableau
⊢B
[(A → B) ∧ B] → A.
¬ [(A → B) ∧ B] → A
↓ (¬ →)
(A → B) ∧ B, ¬A
↓ (∧)
A → B, B, ¬A
ւ
ց (→)
B, B, ¬A
¬A, B, ¬A
| {z }
| {z }
not closed
Andrzej Szalas
Slide 87 of 337
Andrzej Szalas
not closed
Slide 88 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Summary
Conclusion
The tableau is not closed. Open leaves provide a counterexample
for the formula:
¬A, B, ¬A: we set A being false and B being true.
B, B, ¬A: the same as above.
Indeed, in such a case, premisses of the rule (A → B and B)
are both true while the conclusion A is false.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Proof systems.
Soundness and completeness.
Hilbert-like proof systems.
Tableaux for propositional calculus.
Concepts and set-based semantics for propositional calculus.
Verification of rules.
Slide 89 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Reasoning from knowledge bases
General problem
Reasoning with tableaux is efficient for certain classes of
formulas. Can we do better for other classes of formulas?
How to reason from knowledge bases?
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 90 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Reasoning from knowledge bases
Knowledge base
Model of the reality expressed by formulas.
Examples
A building map for rescue robots.
Symptoms of illnesses for medical diagnosis.
Economic model for decision making.
Etc.
Andrzej Szalas
Slide 91 of 337
Andrzej Szalas
Slide 92 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Reasoning from knowledge bases
The method
Let ∆ be a propositional database. We are interested in checking
whether a given formula A is a consequence of ∆, i.e., whether
∆ → A.
Introduction & propositional calculus
First-order logic
Miscellaneous
Reasoning from knowledge bases
The method
Being interested whether ∆ → A:
we first negate it (as done in tableaux);
next, we use the implication law:
!
!
¬ ∆ → A ↔ ∆ ∧ ¬A ,
Example
Let ∆ be a medical database with symptoms. We may be
interested whether sore throat, fever, headache and muscle aches
imply flu or cold.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
finally, we try to show that it leads to contradiction
(meaning that ∆ ∪ {¬A} it is unsatisfiable).
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 94 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
NNF: Negation Normal Form
Recall that a literal is a formula of the form A or ¬A,
where A is an atomic formula.
A literal of the form A is called positive
and of the form ¬A is called negative.
We say that formula A is in negation normal form,
abbreviated by Nnf, iff it contains no other connectives than
∧, ∨, ¬, and the negation sign ¬ appears in literals only.
Andrzej Szalas
and add ¬A to ∆;
Slide 93 of 337
NNF: Negation Normal Form
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Slide 95 of 337
Examples
1
2
3
4
(p ∨ ¬q ∧ s) ∨ ¬t is in Nnf;
(p ∨ ¬¬q ∧ s) ∨ ¬t is not in Nnf;
r ∧ ¬q ∧ ¬s ∧ t is in Nnf;
r ∧ ¬q ∧ ¬[¬s ∧ t] is not in Nnf.
Andrzej Szalas
Slide 96 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Transforming formulas into NNF
Any propositional formula can be equivalently transformed into the
Nnf by replacing subformulas according to the table below, until
Nnf is obtained.
Rule
1
2
3
4
5
Subformula
A↔B
A→B
¬¬A
¬(A ∨ B)
¬(A ∧ B)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Example
¬[(¬p ∧ r ) → (¬(q ∨ r ))]
¬[¬(¬p ∧ r ) ∨ (¬(q ∨ r ))]
(¬p ∧ r ) ∧ ¬(¬(q ∨ r ))
(¬p ∧ r ) ∧ (q ∨ r ).
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
The empty clause (when k = 0), denoted by ∅, is equivalent
to F.
A Horn clause is a clause in which at most one literal is
positive.
Formula A is in conjunctive normal form, abbreviated by Cnf,
if it is a conjunction of clauses. It is in clausal form if it is
a set of clauses (considered to be an implicit conjunction of
clauses).
Slide 99 of 337
(2)
←→
(4)
←→
(3)
¬(¬(¬p ∧ r )) ∧ ¬(¬(q ∨ r )) ←→
Slide 97 of 337
A clause is any formula of the form A1 ∨ A2 ∨ . . . ∨ Ak , where
k ≥ 0 and A1 , A2 , . . . , Ak are literals.
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Transforming formulas into NNF
Replaced by
(¬A ∨ B) ∧ (A ∨ ¬B)
¬A ∨ B
A
¬A ∧ ¬B
¬A ∨ ¬B
CNF: Conjunctive Normal Form
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Introduction & propositional calculus
First-order logic
Miscellaneous
(3)
←→
Slide 98 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples
1
2
3
4
5
6
p ∨ q ∨ ¬r is a clause but not a Horn clause
¬p ∨ q ∨ ¬r as well as ¬p ∨ ¬q ∨ ¬r are Horn clauses
(p ∨ q ∨ t) ∧ (s ∨ ¬t) ∧ (¬p ∨ ¬s ∨ ¬t) is in Cnf
{(p ∨ q ∨ t), (s ∨ ¬t), (¬p ∨ ¬s ∨ ¬t)} is in clausal form
(p ∧ q ∨ t) ∧ (s ∨ ¬t) ∧ (¬p ∨ ¬s ∨ ¬t) is not in Cnf
{(p ∧ q ∨ t), (s ∨ ¬t), (¬p ∨ ¬s ∨ ¬t)} is not in clausal form.
Andrzej Szalas
Slide 100 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Why Horn clauses are important?
Any Horn clause can be transformed into the form of implication:
[A1 ∧ A2 ∧ . . . ∧ Al ] → B,
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Non-Horn clauses
In the case of more positive literals a clause is equivalent to:
[A1 ∧ A2 ∧ . . . ∧ Al ] → [B1 ∨ B2 ∨ . . . ∨ Bn ],
where all A1 , A2 , . . . , Al , B are positive literals. Such implications
are frequently used in everyday reasoning, expert systems,
deductive database queries, etc.
where all literals A1 , . . . , Al , B1 , . . . , Bn are positive.
Disjunction at the righthand side of implication causes
serious complexity problems.
Examples
rain → take umbrella,
(snow ∧ ice) → cold weather,
(starterProblem ∧ cold weather) → chargeBattery.
Example
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 101 of 337
Any propositional formula can be equivalently transformed into the
Cnf:
1
Transform the formula into Nnf
2
Replace subformulas according to the table below, until Cnf
is obtained.
Subformula
(A ∧ B) ∨ C
C ∨ (A ∧ B)
Andrzej Szalas
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Transforming formulas into CNF
Rule
6
7
(sore throat ∧ fever ∧ headache ∧ muscle aches) → (flu ∨ cold)
Replaced by
(A ∨ C ) ∧ (B ∨ C )
(C ∨ A) ∧ (C ∨ B)
Slide 103 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 102 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
(6)
(¬fastFood ∧ ¬restaurant) ∨ (walk ∧ park)
←→
(¬restaurant ∨ (walk ∧ park))
(¬fastFood ∨ walk) ∧ (¬fastFood ∨ park)∧
(¬restaurant ∨ walk) ∧ (¬restaurant ∨ park)
←→
(7)
(¬fastFood ∨ (walk ∧ park)) ∧ (¬restaurant ∨ (walk ∧ park)) ←→
(¬fastFood ∨ walk) ∧ (¬fastFood ∨ park)∧
We then have the following conjunction of implications:

 fastFood → walk

^
fastFood → park
restaurant
→ walk



restaurant → park.
Andrzej Szalas
Slide 104 of 337
(7)
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Applications of CNF
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Testing validity of formulas in CNF
A formula in Cnf can easily be tested for validity, since in this
case we have the following simple criterion:
if each clause contains a literal together with its
negation, then the formula is a tautology, otherwise
it is not a tautology.
Rule-based reasoning and expert systems.
Logic programming and deductive databases.
Tautology checking.
Examples
1
2
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(p ∨ q ∨ ¬p) ∧ (p ∨ ¬q ∨ r ) is not a tautology.
Slide 105 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Resolution rule for propositional calculus
Resolution method has been introduced by Robinson (1965) and
is considered the most powerful automated proving technique.
Resolution rule, denoted by (res), is formulated as follows:
α ∨ L,
¬L ∨ β
α∨β
where L is a literal and α, β are clauses.
The position of L and ¬L in clauses does not matter.
Andrzej Szalas
(p ∨ q ∨ ¬p) ∧ (p ∨ ¬q ∨ r ∨ q) is a tautology
Slide 107 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 106 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Remarks
Resolution rule reflects the transitivity of implication
Resolution rule can be formulated equivalently as:
(¬α) → L,
L→β
(¬α) → β
reflecting the transitivity of implication.
Presenting α, β as clauses, the resolution rule takes the form:
L1 ∨ . . . ∨ Lk ∨ L,
¬L ∨ M1 ∨ . . . ∨ Ml
L1 ∨ . . . ∨ Lk ∨ M1 ∨ . . . ∨ Ml
Andrzej Szalas
Slide 108 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Examples
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Factorization rule for propositional calculus
John sleeps ∨ John works,
John sleeps ∨ John doesn’t work
John sleeps
¬Q ∨ S ∨ T
P ∨ Q,
P ∨S ∨T
Reminder
Factorization rule, denoted by (fctr ):
Remove from a clause redundant repetitions
of literals.
Example
P ∨ P ∨ ¬Q ∨ P ∨ ¬Q
P ∨ ¬Q
¬Q ∨ P,
S ∨T ∨Q
P ∨S ∨T
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 109 of 337
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Factorization rule
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 110 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Resolution method
Resolution rule preserves satisfiability, while factorization preserves
equivalence.
The method, where formula A is to be proved
1
2
(A ∨ L) ∧ (¬L ∨ B) is not equivalent to A ∨ B.
The counterexample: A = L = T and B = F.
(A ∨ A) ↔ A is a tautology.
Andrzej Szalas
Slide 111 of 337
transform ¬A into the conjunctive normal form
try to derive the empty clause ∅ by applying resolution (res)
and factorization (fctr ):
if the empty clause is obtained then A is a tautology,
if the empty clause cannot be obtained no matter how (res)
and (fctr ) are applied, then conclude that A is not a tautology.
Andrzej Szalas
Slide 112 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Resolution method
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Prove that formula [(A ∨ B) ∧ (¬A)] → B is a tautology:
1
Soundness and completeness
Resolution method is sound: deriving ∅ for ¬A proves
that A is a tautology.
2
negate: (A ∨ B) ∧ (¬A) ∧ ¬B – this formula is in the Cnf
obtaining the empty clause ∅:
1.
2.
3.
4.
5.
Resolution method is complete: if a formula A is a tautology
then there is a derivation of ∅ using the method.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 113 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 114 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Using factorization
Verify whether formula (A ∨ B) → B is a tautology:
2
the first clause
the second clause
the third clause
(res): 1, 2
(res): 3, 4
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
1
A∨B
¬A
¬B
B
∅
negate: (A ∨ B) ∧ ¬B – this formula is in the Cnf
trying to obtain the empty clause ∅:
1. A ∨ B the first clause
2. ¬B
the second clause
4. A
(res): 1, 2
The empty clause cannot be obtained, so the formula is not
a tautology.
Andrzej Szalas
Slide 115 of 337
Derive ∅ from (p ∨ p) ∧ (¬p ∨ ¬p):
1.
2.
3.
4.
5.
p∨p
¬p ∨ ¬p
p
(fctr): 1
¬p
(fctr): 2
∅
(res): 4, 5
Note that without factorization the empty clause cannot be
obtained.
Andrzej Szalas
Slide 116 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the first query (slide 79) using resolution
goodStud → (male ∨ female)
(we add its negation goodStud ∧ ¬male ∧ ¬female)
On slide 78:
(human ∧ enr ) → stud
stud → (male ∨ female)
(active ∧ highG ) → goodStud
goodStud → stud.
Transformed to Cnf (knowledge base)
¬human ∨ ¬enr ∨ stud
¬stud ∨ male ∨ female
¬active ∨ ¬highG ∨ goodStud
¬goodStud ∨ stud.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 117 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the second query (slide 79) using resolution
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
¬human ∨ ¬enr ∨ stud
¬stud ∨ male ∨ female
¬active ∨ ¬highG ∨ goodStud
¬goodStud ∨ stud
goodStud
¬male
¬female
stud
male ∨ female
female
∅
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(res) : 4, 5
(res) : 2, 8
(res) : 6, 9
(res) : 7, 10
Slide 118 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Checking the second query
goodStud → human (we add its negation goodStud ∧ ¬human)
1.
2.
3.
4.
5.
6.
7.
8.
9.
¬human ∨ ¬enr ∨ stud
¬stud ∨ male ∨ female
¬active ∨ ¬highG ∨ goodStud
¬goodStud ∨ stud
goodStud
¬human
stud
(res) : 4, 5
male ∨ female
(res) : 2, 7
etc. (until no further resolution
steps are possible)
Andrzej Szalas
Slide 119 of 337
What happened?
The second query does not follow from the taxonomy.
This means that the specification of taxonomy is too weak.
We can extend the taxonomy, e.g., by formulas:
stud → (human ∧ enr )
goodStud → (active ∧ highG ).
Andrzej Szalas
Slide 120 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example of application of propositional reasoning
Consider the following sentences:
1
if the interest rate of the central bank will not be changed
then government expenses will be increased or new
unemployment will arise
2
if the government expenses will not be increased then taxes
will be reduced
3
if taxes will be reduced and the interest rate of the central
bank will not be changed then new unemployment will not
arise
4
if the interest rate of the central bank will not be changed
then the government expenses will be increased.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
4
The task
(i) the conjunction of (1), (2) and (3) implies (4);
(ii) the conjunction of (1), (2) and (4) implies (3).
Atomic sentences
ir – standing for “interest rate of the central bank will be
changed”;
ge – standing for “government expenses will be increased”;
un – standing for “new unemployment will arise”;
tx – standing for “taxes will be reduced”.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 122 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example continued
Translation of the considered sentences
1 (¬ir ) → (ge ∨ un)
3
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example continued
Slide 121 of 337
Example continued
2
Introduction & propositional calculus
First-order logic
Miscellaneous
(¬ge) → tx
(tx ∧ ¬ir ) → ¬un
Our first task is then to check whether the conjunction of (1), (2)
and (3) implies (4), i.e., whether:

[(¬ir ) → (ge ∨ un)] 
∧ [(¬ge) → tx]
→ [(¬ir ) → ge]

∧ [(tx ∧ ¬ir ) → ¬un]
Negation of the above formula
(¬ir ) → ge.
[(¬ir ) → (ge ∨ un)]
∧ [(¬ge) → tx]
∧ [(tx ∧ ¬ir ) → ¬un]
∧ ¬ir
∧ ¬ge
Andrzej Szalas
Slide 123 of 337
Andrzej Szalas
Cnf:
[ir ∨ ge ∨ un]
∧ [ge ∨ tx]
∧ [¬tx ∨ ir ∨ ¬un]
∧ ¬ir
∧ ¬ge
Slide 124 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example continued
ir ∨ ge ∨ un
ge ∨ tx
¬tx ∨ ir ∨ ¬un
¬ir
¬ge
¬tx ∨ ¬un
ge ∨ ¬un
ge ∨ un
ge ∨ ge
ge
∅
The second task (do (1), (2) and (4) imply (3)?)

[(¬ir ) → (ge ∨ un)] 
∧ [(¬ge) → tx]
→ [(tx ∧ ¬ir ) → ¬un]

∧ [(¬ir ) → ge]
Negated
(res) : 3, 4
(res) : 2, 6
(res) : 1, 4
(res) : 7, 8
(fctr ) : 9
(res) : 5, 10
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Andrzej Szalas
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
[ir ∨ ge ∨ un]
∧ [ge ∨ tx]
∧ [ir ∨ ge]
∧ tx
∧ ¬ir
∧ un
Slide 126 of 337
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Resolution
ir ∨ ge ∨ un
ge ∨ tx
ir ∨ ge
tx
¬ir
un
ge ∨ un
(res): 1, 5
No matter how (res) and (fctr ) are applied, ∅ cannot be derived.
Andrzej Szalas
[(¬ir ) → (ge ∨ un)]
∧ [(¬ge) → tx]
∧ [(¬ir ) → ge]
Cnf:
∧ [tx ∧ ¬ir ]
∧ un
Slide 125 of 337
The second task: continued
1.
2.
3.
4.
5.
6.
7.
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example continued
Proof of the first implication
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 127 of 337
Verification of modus ponens
The translation:
[A ∧ (A → B)] → B.
Negation: [A ∧ (A → B)] ∧ ¬B.
Resolution:
1.
2.
3.
4.
5.
A
¬A ∨ B
¬B
¬A
∅
(res): 2, 3
(res): 1, 4
Andrzej Szalas
Slide 128 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Example
Lecture I: introduction
Lecture II: tableaux, satisfiability
Lecture III: resolution
Summary
Verification of affirming the consequent
The translation:
[(A → B) ∧ B] → A.
Negation: [(A → B) ∧ B] ∧ ¬A.
Resolution:
1.
2.
3.
Introduction & propositional calculus
First-order logic
Miscellaneous
Negation normal form.
Conjunctive and clausal normal form.
Horn clauses.
¬A ∨ B
B
¬A
Resolution and factorization rules.
Resolution method.
No resolution steps are possible, so the translation is not
a tautology.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 129 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The problem
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 130 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Benefits of first-order logic
General problem
Expressiveness of propositional calculus insufficient
in many application areas.
S. Russell, 2014
The key benefit of first-order logic is its expressive power,
which leads to concise – and hence easily learnable – models.
For example, the rules of chess occupy:
100 pages in first-order logic;
Specific subproblems
How to express properties like:
“there are objects satisfying . . . ”.
How to express properties like:
“all objects satisfy . . . ”.
Andrzej Szalas
Slide 131 of 337
105 pages in propositional logic;
1038 pages in the language of finite automata.
The power comes from separating predicates from their arguments
and quantifying over those arguments: so one can write rules about
On(p, c, x, y , t) (piece p of colour c is on square x, y at move t)
without having to fill in each specific value for c, p, x, y , and t.
Andrzej Szalas
Slide 132 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Expressing concepts
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Quantifiers
Remark
In propositional calculus we can express basic concepts (via
propositional variables), concept complements, intersections,
unions, inclusions and equalities – see slide 76. However, we
cannot express properties like:
In the classical logic we have two quantifiers:
the existential quantifier
“there exists an individual x such that ...”,
denoted by ∃x
the universal quantifier
“for all individuals x ...”,
denoted by ∀x.
“John is a father of Mary”;
“Mother is a female who has a child”;
Etc.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 133 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Relations
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 134 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
In mathematics
Examples: <, ≤, >, ≥, =, . . .
In other areas
Examples:
1
“John is a father of Mary”: father (John, Mary );
2
“Mother is a female who has a child”:
!
mother (x) ↔ female(x) ∧ ∃y (child(y , x)) ;
3
close(x, y ) – x is close to y ;
child(x, y ) – x is child of y ;
judge(x, y , z) – x is a judge in a match between y and z.
Andrzej Szalas
Slide 135 of 337
“Siblings are persons having both parents in common:
!
sibling (x, y ) ↔ ∃p1 ∃p2 parent(p1 , x) ∧ parent(p1 , y )∧
parent(p2 , x) ∧ parent(p2 , y )∧
p1 6= p2 .
Andrzej Szalas
Slide 136 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
1
“Everybody loves somebody”:
It is important that variables under quantifiers represent
individuals. In fact, we have the following hierarchy of logics:
“Relation R is reflexive”:
0
zero-order logic (propositional calculus), where we do not
allow neither variables representing domain elements nor
quantifiers;
1
first-order logic (traditionally called predicate calculus),
where we allow variables representing domain elements
and quantifiers over domain elements
(in this case quantifiers are called first-order quantifiers);
∀x R(x, x);
3
“Relation R is symmetric”:
∀x∀y R(x, y ) → R(y , x);
4
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
A hierarchy of logics
∀x∃y loves(x, y );
2
Introduction & propositional calculus
First-order logic
Miscellaneous
“Relation R is transitive”:
∀x∀y ∀z ((R(x, y ) ∧ R(y , z)) → R(x, z));
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 137 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
A hierarchy of logics: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 138 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Zero-, first-, second- and higher-order formulas
Examples
0
1
2
second-order logic, where we additionally allow variables
representing sets of domain elements and quantifiers over sets
of elements (so-called second-order quantifiers);,
third-order logic, where we additionally allow variables
representing sets of sets of domain elements and quantifiers
over sets of sets of elements (so-called third-order quantifiers)
etc.
Andrzej Szalas
Slide 139 of 337
1
“To like is to be pleased with”: likes → pleased
– a formula of zero-order logic;
2
“John likes everybody”: ∀x likes(John, x)
– a formula of first-order logic;
3
“John has no relationships with anybody”: ¬∃R∃x R(John, x)
– a formula of second-order logic;
4
“No matter how the word good is understood,
John has no good
! relationships with anybody”:
∀Good¬∃R∃x Good(R) ∧ R(John, x)
– a formula of third-order logic.
Andrzej Szalas
Slide 140 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Syntax of predicate calculus
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The scope of quantifiers
Let x stands for an individual variable, a stands for a constant
symbol and p sands for a relation symbol.
argument
argument
argument list
argument list
atomic formula
formula
formula
formula
formula
formula
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
x
a
argument
argument, argument list
p | p(argument list)
atomic formula
¬formula
formula ∨ formula
∀x formula
∃x formula
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
The scope of a quantifier is the portion of a formula
where it binds its variables.
If a variable is in the scope of a quantifier then
it is bound by the quantifier.
Free variables are variables which are not in the scope
of a quantifier (i.e., are not bound).
Slide 141 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 142 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example

the scope of ∃y
z
}|

{



R(x)
∨
∃y
R(x)
→
S(x,
y
)
∀x 





|
{z
the scope of ∀x
Andrzej Szalas
}
Slide 143 of 337

the scope of ∃y
z }|

{



R(x)
∨
∃y
∀x 
∃x
R(x)
→
T
(x,
y
,
z)



{z
}
|
the scope of ∃x
{z
}
|
the scope of ∀x

Andrzej Szalas
Slide 144 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics of predicate calculus
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics of predicate calculus
Example
Interpretations for the formula ∀x[p(a, x)] can be:
Interpretations
Let U be a set of formulas such that {p1 , . . . , pm } are all relation
symbols and {a1 , . . . , ak } are all constant symbols appearing in U.
An interpretation is a triple hD, {R1 , . . . , Rm }, {d1 , . . . , dk }i,
where:
D is a non-empty domain
Ri is an assignment of a relation on D to pi
di ∈ D is an assignment of an element of D to ai .
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 145 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics of predicate calculus
where N is the set of natural numbers.
In the first case ∀x[p(a, x)] is interpreted as “∀x[≤ (0, x)]”
(or, in a bit more readable infix notation, as “∀x[0 ≤ x]”).
In the second case ∀x[p(a, x)] is interpreted as “∀x[≥ (3, x)]”
(or, in infix notation, as “∀x[3 ≥ x]”).
In the third case ∀x[p(a, x)] is interpreted as “∀x[> (1, x)]”
(or, in infix notation, as “∀x[1 > x]”).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 146 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics of predicate calculus
Atomic formulas
Let A be a formula, I an interpretation and σI an assignment.
The value of A under σI , denoted by vσI (A) is defined by
Assignments
Let V be the set of variables.
An assignment σI : V −→ D is a function which maps every
variable to an element of the domain of I.
By σI [xi ← di ] we denote the assignment the same as σI
except that xi is mapped to di .
Andrzej Szalas
hN , {≤}, {0}i, hN , {≥}, {3}i, hN , {>}, {1}i,
Slide 147 of 337
let A = p(c1 , . . . , cn ) be an atomic formula, where each ci
is either a variable xi or a constant ai .
Then vσI (A) = T iff R(d1 , . . . , dn ) holds, where:
R is the relation assigned by I to p;
di ∈ D is assigned to ci either by I (if ci is a constant)
or by σI (if ci is a variable);
Andrzej Szalas
Slide 148 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics of predicate calculus
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics: examples
Formula ∀x∀y [p(x, y ) → p(y , x)] is:
Complex formulas
T, e.g., in an interpretation, where p is assigned the relation
=;
vσI (¬A) = T iff vσI (A) = F;
vσI (A1 ∨ A2 ) = T iff vσI (A1 ) = T or vσI (A2 ) = T;
F, e.g., in an interpretation, where p is assigned the relation
parent between persons.
vσI (A1 ∧ A2 ) = T iff vσI (A1 ) = T and vσI (A2 ) = T;
vσI (A1 → A2 ) = T iff vσI (A1 ) = F or vσI (A2 ) = T;
vσI (A1 ↔ A2 ) = T iff vσI (A1 ) = vσI (A2 );
Formula ∃x∀y [p(x, y )] is:
T, e.g., in an interpretation with natural numbers as the
domain, where p is assigned the relation ≤;
vσI (∀x A) = T iff vσI [x←d] (A) = T for all d ∈ D;
vσI (∃x A) = T iff vσI [x←d] (A) = T for some d ∈ D.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
F in an interpretation with natural numbers as the domain,
where p is assigned the relation >.
Slide 149 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Restricted quantifiers
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 150 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Aristotelian forms
Aristotelian forms
The four Aristotelian forms of quantification are:
1
2
“all P’s are Q’s”, i.e.,
all objects satisfying P satisfy Q –
this form is also called the restricted universal quantification;
“some P’s are Q’s”, i.e.,
some individuals satisfying P satisfy Q –
this form is also called the restricted existential quantification;
3
“no P’s are Q’s”,i.e.,
no individuals satisfying P satisfy Q;
4
“some P’s are not Q’s”, i.e.,
some individuals satisfying P do not satisfy Q.
Andrzej Szalas
Slide 151 of 337
Examples
1
“All students have to learn.”
2
“Some students have jobs.”
3
“No students are illiterate.”
4
“Some students do not like math.”
Andrzej Szalas
Slide 152 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Aristotelian forms
2
3
4
“some P’s are Q’s” translates into ∃x [P(x) ∧ Q(x)];
“no P’s are Q’s” translates into ∀x [P(x) → ¬Q(x)];
“some P’s are not Q’s” translates into ∃x [P(x) ∧ ¬Q(x)].
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 153 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
“All students have to learn” translates into:
∀x [student(x) → hasToLearn(x)].
2
“Some students work” translates into:
∃x [student(x) ∧ hasJob(x)].
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 154 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Translating natural language sentences
“No students are illiterate” translates into:
∀x [student(x) → ¬illiterate(x)].
2
1
“all P’s are Q’s” translates into ∀x [P(x) → Q(x)];
Andrzej Szalas
1
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
Translation of Aristotelian forms into quantified formulas
1
Introduction & propositional calculus
First-order logic
Miscellaneous
“Some students do not like math” translates into:
∃x [student(x) ∧ ¬likes(x, math)].
Andrzej Szalas
Slide 155 of 337
General problem
How to translate natural language into logic.
Specific subproblems
What operators can be translated?
Where specific vocabularies come from?
Andrzej Szalas
Slide 156 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Translating natural language sentences
The approach
We integrate information from two sources:
1 vocabulary (words in the sentence); here we get:
constants (names of individuals), e.g., “Eve”, John”;
variables (representing indefinite individuals), e.g.,
corresponding to “a”, “one”, or appearing within
quantifiers “all”, “some”, etc.;
concepts (sets of individuals), e.g., “man”, “animal”,
“furniture”; these are represented by one argument relation
symbols (e.g., man(x) means that x is a man);
relations (other than those formalizing concepts) showing
the relationships between constant and concepts.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Introduction & propositional calculus
First-order logic
Miscellaneous
Translating natural language sentences
We integrate information from two sources:
2 syntactic structure of the sentence; here we get:
knowledge about logical operators appearing in the sentence,
like connectives and quantifiers;
knowledge how to combine constants, variables, concepts and
other relations.
Slide 157 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 158 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
“Eve is a student”
constants: Eve, variables: none
concepts: student
“Eve is the best student”
constants: Eve, variable: x (needed in quantification)
concepts: student
other relations: two-argument relation betterStudent.
other relations: none.
Translation
Translation
student(Eve)
Andrzej Szalas
Slide 159 of 337
student(Eve) ∧ ¬∃x[student(x) ∧ betterStudent(x, Eve)]
Andrzej Szalas
Slide 160 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Comment
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Reasoning in first-order logic
The last sentence could also be translated into:
bestStudent(Eve),
assuming bestStudent is in the vocabulary.
Where vocabulary comes from?
Typically, vocabulary is suitably chosen by a knowledge base
designer.
For example, having bestStudent is in the vocabulary could
be not suitable for knowledge base updates.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Some problems
How to reason in first-order logic.
Can propositional-like techniques be used?
Slide 161 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
DeMorgan’s laws for quantifiers
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 162 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
DeMorgan laws for quantifiers are:
[¬∀x A(x)] ↔ [∃x ¬A(x)]
The negation of “Everybody loves somebody”
[¬∃x A(x)] ↔ [∀x ¬A(x)]
Translation of “Everybody loves somebody”: ∀x∃y loves(x, y ).
Negation:
Examples
1
“It is not the case that all animals are large”
is equivalent to “Some animals are not large”.
2
“It is not the case that some animals are plants”
is equivalent to “All animals are not plants”.
3
¬∀x∃y loves(x, y ) ↔
∃x¬∃y loves(x, y ) ↔
∃x∀y ¬loves(x, y ).
Which can be translated back into: “Somebody loves nobody”.
¬∀x∃y ∀z [friend(x, y ) ∧ likes(y , z)]
is equivalent to ∃x∀y ∃z ¬[friend (x, y ) ∧ likes(y , z)].
Andrzej Szalas
Slide 163 of 337
Andrzej Szalas
Slide 164 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Analogies between quantifiers and propositional
connectives
The negation of “Everybody loves somebody sometimes”
Translation of “Everybody loves somebody sometimes”:
∀x∃y ∃t loves(x, y , t).
Negation:
¬∀x∃y ∃t loves(x, y , t) ↔
∃x¬∃y ∃t loves(x, y , t) ↔
∃x∀y ¬∃t loves(x, y , t) ↔
∃x∀y ∀t ¬loves(x, y , t).
Introduction & propositional calculus
First-order logic
Miscellaneous
R holds for the first individual
and R holds for the second individual
and R holds for the third individual
and . . .
Given a fixed set of individuals U = {u1 , u2 , u3 , . . .} we then have
that:
Which can be translated back into:
“Somebody never loves anybody”.
Andrzej Szalas
“For all individuals x relation R(x) holds” is equivalent to
∀x ∈ U [R(x)] ↔ [R(u1 ) ∧ R(u2 ) ∧ R(u3 ) ∧ . . .]
Slide 165 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Analogies between quantifiers and propositional
connectives
Similarly, “Exists an individual x such that relation R(x) holds” is
equivalent to
R holds for the first individual
or R holds for the second individual
or R holds for the third individual
or . . .
Given a fixed set of individuals U = {u1 , u2 , u3 , . . .} we then have
that:
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 166 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
∀x∃y loves(x, y )
Let the domain be {Eve, Jack}. Then the formula is equivalent to:
∀x∃y
↔
! loves(x, y )
∀x
loves(x,
Eve)
∨
loves(x,
Jack)
↔
!
loves(Eve,
Eve)
∨
loves(Eve,
Jack)
∧
!
loves(Jack, Eve) ∨ loves(Jack, Jack) .
∃x ∈ U [R(x)] ↔ [R(u1 ) ∨ R(u2 ) ∨ R(u3 ) ∨ . . .]
Andrzej Szalas
Slide 167 of 337
Andrzej Szalas
Slide 168 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Other laws for quantifiers
∀x∃y loves(x, y )
1
Let the domain be as before. Lets start with replacing the
universal quantifier:
∀x∃y loves(x, y )
↔
∃y
loves(Eve,
y
)
∧
∃y
loves(Jack,
y
)
↔
!
loves(Eve,
Eve) ∨ loves(Eve, Jack) ∧
!
loves(Jack, Eve) ∨ loves(Jack, Jack) .
1
2
3
4
2
2
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 169 of 337
Let us show that ∀x[P(x) ∧ Q(x)] ↔ ∀x[P(x)] ∧ ∀x[Q(x)] .
(→)
Let M be an arbitrary interpretation.
Assume that M |= ∀x[P(x) ∧ Q(x)].
!
That is, for every valuation v , P M (v (x)) ∧ Q M (v (x)) = T.
Therefore, for every valuation v , P M (v (x)) = T, so M |= ∀x P(x).
Similarly, for every valuation v , Q M (v (x)) = T, so M |= ∀x Q(x).
We then conclude that M |= ∀x P(x) ∧ ∀x Q(x).
Andrzej Szalas
Slide 171 of 337
∀x[P(x) ∧ Q(x)] is equivalent to ∀x[P(x)] ∧ ∀x[Q(x)];
∃x[P(x) ∨ Q(x)] is equivalent to ∃x[P(x)] ∨ ∃x[Q(x)]
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of (partly informal) proof
∀x[P] is equivalent to P;
∃x[P] is equivalent to P;
∀x[P ∨ Q(x)] is equivalent to P ∨ ∀x[Q(x)];
∃x[P ∧ Q(x)] is equivalent to P ∧ ∃x[Q(x)].
Pushing quantifiers past connectives:
1
The order of replacing quantifiers does not matter.
Andrzej Szalas
Null quantification.
Assume variable x is not free in formula P. Then:
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 170 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of (partly informal) proof: continued
(←)
Let M be an arbitrary interpretation.
Assume that M |= ∀x P(x) ∧ ∀x Q(x).
That is, for every valuation v , P M (v (x)) = T and,
for every valuation v , Q M (v (x))
! = T.
Therefore, for every valuation v , P M (v (x)) ∧ Q M (v (x)) = T.
We then conclude that M |= ∀x[P(x) ∧ Q(x)].
Andrzej Szalas
Slide 172 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Laws for quantifiers
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Counterexamples
∀x[P(x) ∨ Q(x)] and ∀x[P(x)] ∨ ∀x[Q(x)]
However
1 ∀x[P(x) ∨ Q(x)] is not equivalent to ∀x[P(x)] ∨ ∀x[Q(x)];
2
∃x[P(x) ∧ Q(x)] is not equivalent to ∃x[P(x)] ∧ ∃x[Q(x)].
Consider an interpretation M with the domain consisting
of children and adults.
!
We have M |= ∀x adult(x) ∨ ¬adult(x) .
However, M 6|= ∀x adult(x) ∨ ∀x ¬adult(x).
∃x[P(x) ∧ Q(x)] and ∃x[P(x)] ∧ ∃x[Q(x)]
Consider again the interpretation M.
Of course, M 6|= ∃x[adult(x) ∧ ¬adult(x)].
On the other hand, M |= ∃x adult(x) ∧ ∃x ¬adult(x).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 173 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of practical reasoning
The scenario
Assumptions:
Car c is older than car d.
Every car older than d is cheap.
Car e is older than car c.
Every car older than c is older than d.
Conclusion: Car e is cheap.
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 175 of 337
Slide 174 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of practical reasoning
Informal reasoning
Note that, by 3, car e is older than car c so, by 4, it is older than
car d. By 2, every car older than d is cheap, in particular this
applies to car e.
A bit more formal reasoning
1.
2.
3.
4.
5.
6.
Translation into logic
Assumptions:
1. O(c, d)
2. ∀x[O(x, d) → C (x)]
3. O(e, c)
4. ∀x[O(x, c) → O(x, d)].
Conclusion: C (e).
Andrzej Szalas
Andrzej Szalas
O(c, d)
∀x[O(x, d) → C (x)]
O(e, c)
∀x[O(x, c) → O(x, d)]
O(e, d)
C (e)
so O(e, d) → C (e)
so O(e, c) → O(e, d)
modus ponens applied to 3, 4
modus ponens applied to 2, 5.
Andrzej Szalas
Slide 176 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Summary
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The problem
Quantifiers, the scope of a quantifier.
Free and bound variables.
Syntax and semantics of first-order logic.
How to automatize proofs in first-order logic.
Restricted quantifiers.
How about satisfiability?
Translating natural language into first-order logic.
Laws for quantifiers.
Informal reasoning.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 177 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Complexity of first-order logic
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 178 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Tableaux
Tautology checking
Not computable, i.e., there is no algorithm which,
given a first-order formula, always stops and verifies
whether the formula is a tautology.
Partially computable: when a formula is a tautology,
it can be verified, if not – suitable algorithms may give
no answer (e.g., looping forever).
Semantic tableau
A semantic tableau for formula A is a tree T with nodes
labeled with a set of formulas.
Tableau construction extends the construction given for
propositional calculus (see slides 62 – 68).
Satisfiability
Checking whether a formula of first-order logic is satisfiable
is not partially computable.
Andrzej Szalas
Slide 179 of 337
Andrzej Szalas
Slide 180 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
γ-formulas
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
δ-formulas
Rule
(∀)
(¬∃)
γ
∀x A(x)
¬∃x A(x)
γ(a)
A(a)
¬A(a)
δ-formulas
Rule
(∃)
(¬∀)
where a is an arbitrary constant.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
δ(a)
A(a)
¬A(a)
where a is a fresh constant.
Slide 181 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Tableaux
δ
∃x A(x)
¬∀x A(x)
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 182 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Tableaux
Closed and open leaves
Recall that for any formula A, {A, ¬A} is a complementary
pair of formulas.
A positive literal is an expression of the form p(u1 , . . . , uk ),
where u1 , . . . , uk are constants or variables.
A negative literal is of the form ¬p(u1 , . . . , uk ).
A node is closed if it contains a pair of complementary
formulas.
Andrzej Szalas
Slide 183 of 337
Construction of a semantic tableau for formula A
Initially T consists of a single unmarked node labeled with {A}.
Until possible choose anon-closed leaf l labeled with U(l ) and
apply:
if U(l ) contains a pair of complementary formulas then mark
the leaf closed;
otherwise:
Andrzej Szalas
Slide 184 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Tableaux
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Soundness and completeness
Construction of a semantic tableau for formula A
if U(l ) does not contain a pair of complementary literals
and contains non-literals, choose a non-literal A ∈ U(l )
or a γ-formula from any node on the path from l
to the root, and:
if A is an α- or β-formula, apply rules provided in slide 68;
if A is a γ-formula, create a child node l ′ for l and label l ′
with U(l ′ ) = (U(l) − {A}) ∪ {γ(a)}, where a preferably
is a constant appearing in U(l);
if A is a δ-formula, create a child node l ′ for l and label l ′
with U(l ′ ) = (U(l) − {A}) ∪ {δ(a)}, where a is a constant
not appearing in U(l).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Soundness
Let A be a formula and let T be a tableau for A. If all branches
of T are closed then A is unsatisfiable (equivalent to F).
Completeness
Let A be a valid formula (equivalent to T).
Then there is a tableau T for ¬A with all branches closed.
Slide 185 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Partial algorithm for tautologies
Soundness and completeness provide us with the following
partial algorithm for checking whether a given first-order
formula A is a tautology:
Try to construct a closed tableau for ¬A.
If the construction is successful then A is a tautology.
Note that whenever A is a tautology, a closed tableau for A exists
(by completeness).
Andrzej Szalas
Closed branches
A branch in a tableau is closed if it terminates in a leaf marked
closed.
Slide 187 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 186 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
!
Prove ∀x A(x) → A(b)
¬[∀x A(x) → A(b)]
↓ (¬ →)
∀x A(x), ¬A(b)
↓ (∀x with x = b)
A(b), ¬A(b)
{z
}
|
closed
Andrzej Szalas
Slide 188 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
!
Prove unsatisfiability of ∀x ¬A(x) ∧ (A(a) ∨ A(b))
!
∀x ¬A(x) ∧ (A(a) ∨ A(b))
↓ (∀x with x = a)
¬A(a) ∧ (A(a) ∨ A(b))
↓ (∧)
¬A(a), A(a) ∨ A(b)
ւ
ց (∨)
¬A(a), A(a) ¬A(a), A(b)
{z
}
|
↓ (∀x with x = b)
closed
¬A(a), A(b), ¬A(b) ∧ (A(a) ∨ A(b))
↓ (∧)
¬A(a), A(b), ¬A(b), (A(a) ∨ A(b))
|
{z
}
closed
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
!
Prove ∀x A(x) → ∃x A(x)
¬[∀x A(x) → ∃x A(x)]
↓ (¬ →)
∀x A(x), ¬∃x A(x)
↓ (∀x with x = b)
A(b), ¬∃x A(x)
↓ (¬∃x with x = b)
A(b), ¬A(b)
|
{z
}
closed
Slide 189 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 190 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Prove ∀x[p(x) ∧ q(x)] → [∀xp(x) ∧ ∀xq(x)]
!
¬ ∀x[p(x) ∧ q(x)] → [∀xp(x) ∧ ∀xq(x)]
↓ (¬ →)
∀x[p(x) ∧ q(x)], ¬[∀xp(x) ∧ ∀xq(x)]
ւ
ց (¬∧)
∀x[p(x) ∧ q(x)], ¬∀xp(x)
∀x[p(x) ∧ q(x)], ¬∀xq(x)
↓ (¬∀x with x = a)
↓ (¬∀x with x = b)
∀x[p(x) ∧ q(x)], ¬p(a)
∀x[p(x) ∧ q(x)], ¬q(b)
↓ (∀x with x = a)
↓ (∀x with x = b)
p(a) ∧ q(a), ¬p(a)
p(b) ∧ q(b), ¬q(b)
↓ (∧)
↓ (∧)
p(b), q(b), ¬q(b)
p(a), q(a), ¬p(a)
{z
}
{z
}
|
|
closed
closed
Andrzej Szalas
Slide 191 of 337
Lets prove the conclusion obtained in the scenario considered in
slide 175:
Knowledge base:
O(c, d), ∀x[O(x, d) → C (x)], O(e, c), ∀x[O(x, c) → O(x, d)].
Conclusion: C (e).
Remark
Observe that commas among formulas correspond to ∧.
To simplify the constructed tableau we will avoid translating
them into ∧ and then back into commas using the (∧) rule.
Andrzej Szalas
Slide 192 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
The tableau: continued
The tableau
!
¬ O(c, d), ∀x[O(x, d) → C (x)], O(e,
c),
∀x[O(x, c) → O(x, d)] → C (e)
↓ (¬ →)
O(c, d), ∀x[O(x, d) → C (x)], O(e, c),
∀x[O(x, c) → O(x, d)], ¬C (e)
↓ (∀x with x = e)
O(c, d), O(e, d) → C (e), O(e, c),
∀x[O(x, c) → O(x, d), ¬C (e)
↓ (∀x with x = e)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
O(c, d), O(e, d) → C (e), O(e, c),
O(e, c) → O(e, d), ¬C (e)
ւ
ց (→)
O(c, d), O(e, d) → C (e),
O(c, d), O(e, d) → C (e),
O(e, c), ¬O(e, c), ¬C (e)
O(e, c), O(e, d ), ¬C (e)
|
{z
}
ւ
ց (→)
closed
O(c, d), ¬O(e, d),
O(c, d ), C (e),
O(e, c), O(e, d), ¬C (e)
O(e, c), O(e, d), ¬C (e)
|
{z
} |
{z
}
closed
closed
Slide 193 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 194 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Consider:
1.
2.
∀x R(x, x)
(reflexivity)
∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )] (Euclidicity)
Remarks
Look quite abstract.
Do 1., 2. imply the symmetry of R?
Symmetry: ∀x∀y [R(x, y ) → R(y , x)].
For example, we would like to have:
∀x∀y [similar (x, y ) → similar (y , x)].
However, reflect important properties.
E.g., do we want similarity to satisfy 1., 2.?
Andrzej Szalas
Slide 195 of 337
Andrzej Szalas
Slide 196 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Remarks
Since we have no guarantee that the considered implication
is a tautology, it is better to first attempt to construct
a counterexample or prove more ore less informally that the
implication is valid.
Typically, informal proofs provide hints how to construct
a tableau (by indicating substitutions of quantified variables
by constants).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Informal proof
Take any objects a, b such that R(a, b) holds.
From 2. (with x = y = a and z = b) we derive:
(R(a, a) ∧ R(a, b)) → R(b, a)
From 1. we deduce R(a, a). Premisses of implication are satisfied,
so the conclusion R(b, a) should be satisfied, too. Therefore the
symmetry holds.
Slide 197 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 198 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Tableau
Tableau: continued
!
¬ ∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z))
→
R(z,
y
)]
→ ∀x∀y [R(x, y ) → R(y , x)]
↓ (¬ →)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
¬∀x∀y [R(x, y ) → R(y , x)]
↓ (¬∀x with x = a)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
¬∀y [R(a, y ) → R(y , a)]
↓ (¬∀y with y = b)
Andrzej Szalas
Slide 199 of 337
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
¬[R(a, b) → R(b, a)]
↓ (¬ →)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
R(a, b), ¬R(b, a)
↓ (∀x with x = a)
R(a, a), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
R(a, b), ¬R(b, a)
↓ (∀x with x = a)
Andrzej Szalas
Slide 200 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Tableau: continued (∗)
Tableau: continued
R(a, a), ∀y ∀z[(R(a, y ) ∧ R(a, z)) → R(z, y )],
R(a, b), ¬R(b, a)
↓ (∀y with y = a)
R(a, a), ∀z[(R(a, a) ∧ R(a, z)) → R(z, a)],
R(a, b), ¬R(b, a)
↓ (∀z with z = b)
R(a, a), (R(a, a) ∧ R(a, b)) → R(b, a), R(a, b), ¬R(b, a)
ւ
ց (→)
(∗)
(∗∗)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
R(a, a), ¬(R(a, a) ∧ R(a, b)), R(a, b), ¬R(b, a)
ւ
ց (¬∧)
R(a, a),¬R(a, a),R(a, b),¬R(b, a) R(a, a),¬R(a, b),R(a, b),¬R(b, a)
|
{z
} |
{z
}
closed
closed
Tableau: continued (∗∗)
R(a, a), R(b, a), R(a, b), ¬R(b, a)
|
{z
}
closed
Slide 201 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 202 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Informal proof
Do 1., 2. impliy the transitivity of R?
Transitivity: ∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)].
For example, we would not like to have:
∀x∀y ∀z[(similar (x, y ) ∧ similar (y , z)) → similar (x, z)].
Andrzej Szalas
Slide 203 of 337
Take any objects a, b, c such that R(a, b) and R(b, c) hold.
We already know that 1. and 2. imply the symmetry of R,
so we conclude that R(b, a) holds.
From 2. we then have R(c, a), so by the symmetry, also R(a, c).
Therefore, R is transitive (which, e.g., means that 1., 2. are too
strong to formalize properties of similarity).
Andrzej Szalas
Slide 204 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Justification
An optimization
Observe that in the proof presented above we used symmetry.
In tableaux we can use symmetry by adding formula
∀x∀y [R(x, y ) → R(y , x)] to the knowledge base.
To simplify tableaux we can also add suitable consequences
directly. Namely, given R(a, b), where a, b are constants,
we can add R(b, a) to a given node.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
. . . , R(a, b), ∀x∀y [R(x, y ) → R(y , x)], . . .
↓ (∀x with x = a)
. . . , R(a, b), ∀y [R(a, y ) → R(y , a)], . . .
↓ (∀y with y = b)
. . . , R(a, b), R(a, b) → R(b, a), . . .
ւ
ց (→)
. . . , R(a, b), R(b, a), . . .
. . . , R(a, b), ¬R(a, b), . . .
|
{z
}
closed
Slide 205 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 206 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Tableau: continued
Tableau
!
¬ ∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z,
y
)]
→ ∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)]
↓ (¬ →)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
¬∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)]
↓ (¬∀x∀y ∀z with x = a, y = b, z = c)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
¬[(R(a, b) ∧ R(b, c)) → R(a, c)]
↓ (¬ →)
Andrzej Szalas
Slide 207 of 337
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
R(a, b) ∧ R(b, c), ¬R(a, c)
↓ (∧)
∀x R(x, x), ∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )],
R(a, b), R(b, c), ¬R(a, c)
↓ (∀x∀y ∀z with x = b, y = a, z = c)
∀x R(x, x), (R(b, a) ∧ R(b, c)) → R(c, a),
R(a, b), R(b, c), ¬R(a, c)
ւ
ց (→)
(∗)
(∗∗)
Andrzej Szalas
Slide 208 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Tableau: continued (∗)
∀x R(x, x), ¬(R(b, a) ∧ R(b, c)),
R(a, b), R(b, c), ¬R(a, c)
ւ
ց (¬∧)
∀x R(x, x), ¬R(b, a),
∀x R(x, x), ¬R(b, c),
R(a, b), R(b, c), ¬R(a, c)
R(a, b), R(b, c), ¬R(a, c)
|
{z
}
↓ (symmetry)
closed
∀x R(x, x), ¬R(b, a),
R(a, b), R(b, a), R(b, c), ¬R(a, c)
{z
}
|
closed
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Tableau: continued (∗∗)
∀x R(x, x), R(c, a), R(a, b), R(b, c), ¬R(a, c)
↓ (symmetry)
∀x R(x, x), R(c, a), R(a, c), R(a, b), R(b, c), ¬R(a, c)
|
{z
}
closed
Slide 209 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The order of rules
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 210 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The order of rules
Example: ∀x∃y (R(x, y ) ∧ ¬R(y , x))
Important
Always apply rules to quantifiers starting with the outermost
quantifier.
Example: ∀x∃y (R(x, y ) ∧ ¬R(y , x))
The formula is satisfiable. A model:
domain: {a, b, c};
R(a, b), R(b, c), R(c, a) are true, all other literals are false.
Andrzej Szalas
Slide 211 of 337
However, using a wrong order of rules we can show a closed
tableau, showing unsatisfiability of the formula:
∀x∃y (R(x, y ) ∧ ¬R(y , x))
↓ (∃y ) ← wrong!
∀x(R(x, a) ∧ ¬R(a, x))
↓ (∀x)
R(a, a) ∧ ¬R(a, a)
↓ (∧)
R(a, a), ¬R(a, a)
|
{z
}
closed
Andrzej Szalas
Slide 212 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The order of rules
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Summary
Example: ∀x∃y (R(x, y ) ∧ ¬R(y , x))
With a correct order:
∀x∃y (R(x, y ) ∧ ¬R(y , x))
↓ (∀x)
∃y (R(a, y ) ∧ ¬R(y , a))
↓ (∃y )
R(a, b) ∧ ¬R(b, a)
↓ (∧)
R(a, b), ¬R(b, a)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Complexity of first-order logic.
Tableaux for first-order logic.
Proving formulas using tableaux.
Slide 213 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
The problem
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 214 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Transforming formulas into NNF
NNF: Negation Normal Form
General problem
In tableaux we had to guess substitutions of quantified variables by
constants. Can we do better?
Specific subproblems
Can substitutions be goal directed?
Can they be automatized?
Andrzej Szalas
Recall (see Slide 95) that in negation normal form, Nnf, negation
ca appear only before atoms.
Any first-order formula can be equivalently transformed into the
Nnf by replacing subformulas according to the table given in
Slide 97 and rules given below.
Rule
6’
7’
Slide 215 of 337
Subformula
¬∀x A(x)
¬∃x A(x)
Andrzej Szalas
Replaced by
∃x[¬A(x)]
∀x[¬A(x)]
Slide 216 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Example
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
PNF: Prenex Normal Form
We say A is in prenex normal form, abbreviated by Pnf, if all its
quantifiers (if any) are in its prefix, i.e., it has the form:
Transforming into NNF
Q1 x1 Q2 x2 . . . Qn xn [A(x1 , x2 , . . . , xn )],
¬ ∀x(R(x, x) ∧ ¬S(x)) ∨ ∃y (¬R(y , y ) ∨ S(y ))
¬∀x(R(x, x) ∧ ¬S(x)) ∧ ¬∃y (¬R(y , y ) ∨ S(y ))
∃x[¬(R(x, x) ∧ ¬S(x))] ∧ ∀y [¬(¬R(y , y ) ∨ S(y ))]
∃x[¬R(x, x) ∨ ¬¬S(x)] ∧ ∀y [¬¬R(y , y ) ∧ ¬S(y )]
∃x[¬R(x, x) ∨ S(x)] ∧ ∀y [R(y , y ) ∧ ¬S(y )].
↔
↔
↔
↔
where n ≥ 0, Q1 , Q2 , . . . , Qn are quantifiers (∀, ∃) and A is
quantifier-free.
Examples
1
2
3
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
A(x) ∧ ∀x [B(x, y ) ∧ ¬C (y )] as well as
∀x [A(x) ∧ B(x, y ) ∧ ¬∃yC (y )] are not in Pnf.
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Replace subformulas according to the table below, until Pnf
is obtained, where Q denotes any quantifier, ∀ or ∃.
Rule
Subformula
12 Qx[A(x)], A(x) without variable z
13
∀x A(x) ∧ ∀x B(x)
14
∃x A(x) ∨ ∃x B(x)
15 A ∨ Qx B, where A contains no x
16 A ∧ Qx B, where A contains no x
Slide 219 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 218 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Any predicate formula can be equivalently transformed into the
Pnf
1 Transform the formula into Nnf;
Andrzej Szalas
∀x∃y [A(x) ∧ B(x, y ) ∧ ¬C (y )] is in Pnf
Slide 217 of 337
Transforming formulas into PNF
2
A(x) ∧ B(x, y ) ∧ ¬C (y ) is in Pnf
Replaced by
Qz[A(z)]
∀x [A(x) ∧ B(x)]
∃x [A(x) ∨ B(x)]
Qx (A ∨ B)
Qx (A ∧ B)
Transforming a formula into Pnf
A(z) ∨ ∀x [B(x, u) ∧ ∃yC (x, y ) ∧ ∀z D(z)]
∀x {A(z) ∨ [B(x, u) ∧ ∃yC (x, y ) ∧ ∀z D(z)]}
(15)
←→
(16)
←→
(15)
∀x {A(z) ∨ ∃y [B(x, u) ∧ C (x, y ) ∧ ∀z D(z)]} ←→
(16)
∀x∃y {A(z) ∨ [B(x, u) ∧ C (x, y ) ∧ ∀z D(z)]}
←→
∀x∃y {A(z) ∨ ∀t [B(x, u) ∧ C (x, y ) ∧ D(t)]}
∀x∃y ∀t {A(z) ∨ [B(x, u) ∧ C (x, y ) ∧ D(t)]}.
←→
∀x∃y {A(z) ∨ ∀z [B(x, u) ∧ C (x, y ) ∧ D(z)]}
Andrzej Szalas
Slide 220 of 337
(12)
←→
(15)
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Functions and terms
Standard notation: name(expr1 , . . . , exprn ) denotes a function
value, where name is a function name and expr1 , . . . , exprn
are function arguments.
We write
name : U1 × U2 × . . . × Un −→ U
meaning that the first argument takes a value from U1 ,
the second from U2 , . . ., the n-th from Un and the result is
from U.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Functions
The number of arguments is called the arity of the function.
A two-argument function id called binary and a one-argument
function is called unary. For binary functions one often uses
infix notation.
Some functions have traditionally accepted special notations.
Slide 221 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Functions and terms
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 222 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Functions and terms
Examples
1
Let mother : Persons −→ Persons have the commonsense
meaning. Then mother (x) is a function.
2
son(x) is not a function (why?).
3
x + y , x ∗ y (infix notation).
5
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Functions and terms
Functions
A function is a special type of relation. It takes a sequence
of arguments and returns a unique value.
4
Introduction & propositional calculus
First-order logic
Miscellaneous
What notation “+ : [0, 1] × [2, 5] −→ [2, 6]” means?
√
x + y , 2x 2 + 3x + 7, x 2 + 2xy + y 3 are examples of special
notations.
Andrzej Szalas
Slide 223 of 337
Terms
Let F be a set of function symbols. The following grammar
defines terms. The rule for atomic formula is modified to take
a term list as its argument.
term
::= x
for any x ∈ V
term
::= a
for any a ∈ A
term
::= f (term list)
for any f ∈ F
::= term
term list
::= term, term list
term list
atomic formula ::= p(term list)
for any p ∈ P.
Andrzej Szalas
Slide 224 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Functions and terms
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics
Interpretations
Let U be a set of formulas such that {p1 , . . . , pm } are all relation
symbols, {f1 , . . . , fl } are all the function symbols and {a1 , . . . , ak }
are all constant symbols appearing in U.
Examples of terms
a, x, f (a, x), f (g (x), y ), g (f (a, g (b))).
Examples of atomic formulas
p(a, b), p(g (f (a, g (b)), f (a, x)).
An interpretation is a tuple:
hD, {R1 , . . . , Rm }, {F1 , . . . , Fl }, {d1 , . . . , dk }i,
where:
D is a non-empty domain;
Ri is an assignment of a relation on D to pi ;
Fi is an assignment of a function on D to fi ;
di ∈ D is an assignment of an element of D to ai .
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 225 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 226 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Semantics
Values of terms
Let I an interpretation and σI an assignment.
The value of a term under σI , denoted by vσI (term) is defined by:
1
vσI (ai ) = di ;
2
vσI (x) = σI (x), where x ∈ V;
3
Andrzej Szalas
vσI (fi (t1 , . . . , tn )) = Fi (vσI (t1 ), . . . , vσI (tn )).
Andrzej Szalas
Slide 227 of 337
Values of atomic formulas
vσI (pi (t1 , . . . , tn )) = T iff Ri (vσI (t1 ), . . . , vσI (tn )) holds.
Values of complex formulas
The definition for connectives and quantifiers is usual
(see Slide 149).
Andrzej Szalas
Slide 228 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Skolem normal form
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Skolem normal form
A formula is in the Skolem normal form iff it is in the Pnf and
contains no existential quantifiers.
Transforming formulas into the Skolem normal form
Eliminate existential quantifiers from left to right:
1
when we have ∃xA(x) then remove ∃x and replace x in A
by a new constant symbol
2
when we have ∀x1 . . . ∀xk ∃xA(x1 , . . . , xk , x) then remove ∃x
and replace x in A by a term f (x1 , . . . , xk ), where f is a new
function symbol.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 229 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Generalizing resolution to predicate calculus
A problem
Consider the following two formulas:
∀x [rare(x) → expensive(x)]
∀y [expensive(y ) → guarded(y )]
Clause form:
¬rare(x) ∨ expensive(x)
¬expensive(y ) ∨ guarded(y )
Example
1
2
Skolem normal form for
∃x∀y ∀z∃u[R(x, y , z, u)]
is ∀y ∀z[R(a, y , z, f (y , z)]
Skolem normal form for
∃x∀y ∃z∀u∃w [R(x, y , z, u, w )]
is ∀y ∀u[R(a, y , g (y ), u, h(y , u)].
Important
A formula and its Skolem normal form are equisatisfiable,
i.e., they are both satisfiable or both unsatisfiable.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 230 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Generalizing resolution to predicate calculus
The problem: continued
Consider:
¬rare(x) ∨ expensive(x)
rare(VermeerPainting )
We would like to conclude expensive(VermeerPainting ).
But again (res) cannot be applied.
We need a general method to solve such problems.
It is offered by unification.
Can we apply (res)?
NO!: “expensive(x)” and “expensive(y )” are not the same!
On the other hand, ∀y could equivalently be replaced by ∀x
and resolution could be applied.
Andrzej Szalas
Slide 231 of 337
Andrzej Szalas
Slide 232 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Unification
Introduction & propositional calculus
First-order logic
Miscellaneous
Expression trees
Given two expressions, unification depends on substituting variables
by expressions so that both input expressions become identical.
If this is possible, the given expressions are said to be unifiable.
Expressions can be represented as trees. For example, expressions
f (g (x, h(y ))) and f (g (f (v ), z)) can be represented as:
f (g (x, h(y )))
f (g (f (v ), z))
f
g
f
g
Examples
1
2
3
To unify expressions father (x) and father (mother (John)),
it suffices to substitute x by expression mother (John).
√
To unify expressions (x + f (y√
)) and ( 2 ∗ z + f (3)),
it suffices to substitute x by 2 ∗ z and y by 3.
Expressions father (x) and mother (father (John))
cannot be unified.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
3
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
z
Slide 234 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Resolution rule, denoted by (res), is formulated for first-order
clauses as follows:
traverse trees corresponding to expressions e, e ′ ;
if the trees are identical then stop;
let t and t ′ be subtrees that have to be identical, but are not:
change the trees, according to the substitution determined in
the previous step and repeat from step 2.
Andrzej Szalas
f
v
Resolution rule for the predicate calculus
if t and t ′ are function symbols/constants then conclude that
the substitutions do not exist and stop;
otherwise t or t ′ is a variable; let t be a variable, then
substitute all occurrences of t by the expression represented by
t ′ assuming that t does not occur in t ′ (if it occurs then
conclude that the substitutions do not exist and stop);
4
h
y
In order to unify expressions we have to detect nonidentical
sub-trees and try to make them identical.
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Input: expressions e, e ′
Output: substitution of variables which makes e and e ′ identical
or inform that such a substitution does not exist.
2
x
Slide 233 of 337
The unification algorithm
1
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Slide 235 of 337
L1 (t¯1 ) ∨ . . . ∨ Lk−1 (t̄k−1 ) ∨ Lk (t̄k )
¬Lk (t¯k′ ) ∨ M1 (s̄1 ) ∨ . . . ∨ Ml (s̄l )
′
L1 (t¯1 ′ ) ∨ . . . ∨ Lk−1 (t̄k−1
) ∨ M1 (s̄1′ ) ∨ . . . ∨ Ml (s̄l′ )
,
where:
L1 , . . . , Lk , M1 , . . . , Ml are literals;
tk and tk′ are unifiable;
primed expressions are obtained from non-primed expressions
by applying substitutions unifying tk and tk′ .
Andrzej Szalas
Slide 236 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Examples
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Factorization rule for the predicate calculus
(res) with x = John, y = Mary :
¬parent(x, y ) ∨ x = father (y ) ∨ x = mother (y )
parent(John, Mary )
John = father (Mary ) ∨ John = mother (Mary )
(res) with y = x:
¬rare(x) ∨ expensive(x), ¬expensive(y ) ∨ guarded(y )
¬rare(x) ∨ guarded(x)
(res) with x = VermeerPainting :
¬rare(x) ∨ expensive(x), rare(VermeerPainting )
expensive(VermeerPainting )
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
The rule
Factorization rule, denoted by (fctr ):
Unify some terms in a clause and remove from the
clause all repetitions of literals.
Examples
1
2
(fctr ) with x = Jack, y = mother (Eve):
parent(x, y ) ∨ parent(Jack, mother (Eve))
parent(Jack, mother (Eve))
(fctr ) with z = x, u = y :
P(x, y ) ∨ S(y , z, u) ∨ P(z, u)
P(x, y ) ∨ S(y , x, y )
Slide 237 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Renaming variables
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 238 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Renaming variables
A problem
Consider:
1. P(f (x))
2. ¬P(x).
Expressions 1 and 2 cannot be unified, so resolution cannot be
applied.
On the other hand, both clauses are universally quantified by ∀x
and quantified variables can be renamed, e.g.:
1. P(f (x1 ))
A convention
We require that variables within clauses are renamed to make
them different from variables in all other clauses.
The convention applies both to initial clauses and all derived
clauses.
We use notation x/y to indicate that variable x
is renamed to y .
2. ¬P(x2 ).
Now resolution is possible (with unification x2 = f (x1 )) and results
in the empty clause ∅.
Andrzej Szalas
Slide 239 of 337
Andrzej Szalas
Slide 240 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of proof by resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of proof by resolution
We consider implication:
Consider the following formulas, where med stands for “medicine
student” (recall that clauses are assumed to be implicitly
universally quantified):

[med (x) ∧ attends(x, y )] → [likes(x, y ) ∨ obliged(x, y )]



likes(x, math) → ¬med(x)
∆=
med(John)



attends(John, math)
Do the above formulas imply that John is obliged to take math?
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
∆ → obliged(John, math)
To apply the resolution method we negate this formula and obtain
∆ ∧ ¬obliged(John, math),
i.e.,
[med(x) ∧ attends(x, y )] → [likes(x, y ) ∨ obliged (x, y )]
likes(x, math) → ¬med(x)
med (John)
attends(John, math)
¬obliged(John, math).
Slide 241 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example of proof by resolution
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 242 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Proof
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
¬med (x1 ) ∨ ¬attends(x1 , y1 ) ∨ likes(x1 , y1 ) ∨ obliged (x1 , y1 )
¬likes(x2 , math) ∨ ¬med(x2 )
med(John)
attends(John, math)
¬obliged(John, math)
¬med(x6 )∨¬attends(x6 , math)∨¬med (x6 )∨obliged (x6 , math)
(res) : 1, 2 with x1 = x2 , y1 = math and renaming x2 /x6
¬med (x7 ) ∨ ¬attends(x7 , math) ∨ obliged(x7 , math)
(fctr ) : 6 and renaming x6 /x7
¬attends(John, math) ∨ obliged(John, math)
(res) : 3, 7 with x7 = John
obliged (John, math) − (res) : 4, 8
∅ − (res) : 5, 9.
Andrzej Szalas
Slide 243 of 337
Prove that ∀x∀y [P(x, y ) ∨ P(a, y )] implies ∃x∀yP(x, y )
We start with negating the above implication and
it to the clausal form.
¬ ∀x∀y [P(x, y ) ∨ P(a, y )] → ∃x∀yP(x, y )
∀x∀y [P(x, y ) ∨ P(a, y )] ∧ ¬∃x∀yP(x, y )
∀x∀y [P(x, y ) ∨ P(a, y )] ∧ ∀x¬∀yP(x, y )
∀x∀y [P(x, y ) ∨ P(a, y )] ∧ ∀x∃y [¬P(x, y )].
Clauses
P(x1 , y1 ) ∨ P(a, y1 )
¬P(x2 , g (x2 ))
− g is a Skolem function.
Andrzej Szalas
Slide 244 of 337
transforming
↔
↔
↔
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Prove that ∀xP(a, x, x) ∧ ¬∃x∃y ∃z[P(x, y , z) ∧ ¬P(f (x), y , f (z))]
implies ∃zP(f (a), z, f (f (a)))
Proof by resolution
1.
2.
3.
4.
P(x1 , y1 ) ∨ P(a, y1 )
¬P(x2 , g (x2 ))
P(a, y3 ) − (fctr ) : 1 with x1 = a and renaming y1 /y3
∅ − (res) : 2, 3 with x2 = a and y3 = g (a).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
We start with negating the above implication and transforming
it to the clausal form.
¬ ∀xP(a, x, x) ∧ ¬∃x∃y ∃z[P(x, y , z) ∧ ¬P(f
(x), y , f (z))]
→ ∃zP(f (a), z, f (f (a)))
↔
∀xP(a, x, x) ∧ ¬∃x∃y ∃z[P(x, y , z) ∧ ¬P(f (x), y , f (z))]
∧¬∃zP(f (a), z, f (f (a)))
↔
∀xP(a, x, x) ∧ ∀x∀y ∀z¬[P(x, y , z) ∧ ¬P(f (x), y , f (z))]
∧∀z¬P(f (a), z, f (f (a)))
↔
∀xP(a, x, x) ∧ ∀x∀y ∀z[¬P(x, y , z) ∨ ¬¬P(f (x), y , f (z))]
∧∀z¬P(f (a), z, f (f (a))).
Slide 245 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 246 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Proof by resolution
Clausal form
1.
2.
3.
P(a, x1 , x1 )
¬P(x2 , y2 , z2 ) ∨ P(f (x2 ), y2 , f (z2 ))
¬P(f (a), z3 , f (f (a))).
1.
2.
3.
4.
5.
Andrzej Szalas
Slide 247 of 337
P(a, x1 , x1 )
¬P(x2 , y2 , z2 ) ∨ P(f (x2 ), y2 , f (z2 ))
¬P(f (a), z3 , f (f (a)))
P(f (a), z4 , f (z4 )) − (res) : 1, 2 with x2 = a, x1 = y2 = z2
and renaming z2 /z4
∅ − (res) : 3, 4 with z3 = z4 = f (a).
Andrzej Szalas
Slide 248 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example:continued
Resolution proof
Lets prove the conclusion obtained in the scenario considered in
slide 175:
Knowledge base:
O(c, d), ∀x[O(x, d) → C (x)], O(e, c), ∀x[O(x, c) → O(x, d)].
Conclusion: C (e).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
O(c, d)
¬O(x2 , d) ∨ C (x2 )
O(e, c)
¬O(x4 , c) ∨ O(x4 , d)
¬C (e)
¬O(e, d)
¬O(e, c)
∅
Slide 249 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
–
–
–
–
negated conclusion
(res) : 2, 5 with x2 = e
(res) : 4, 6 with x4 = e
(res) : 3, 7.
Slide 250 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Consider formulas from Slide 195:
∀x R(x, x)
∀x∀y ∀z[(R(x, y ) ∧ R(x, z)) → R(z, y )]
Clausal form
1.
2.
1.
2.
3.
4.
5.
6.
7.
8.
R(x1, x1 )
¬R(x2, y2 ) ∨ ¬R(x2 , z2 ) ∨ R(z2 , y2 )
Andrzej Szalas
Slide 251 of 337
Do the clauses imply symmetry?
Negated symmetry:
¬∀x∀y [R(x, y ) → R(y , x)] ↔
∃x∃y ¬[R(x, y ) → R(y , x)] ↔
∃x∃y [R(x, y ) ∧ ¬R(y , x)].
Skolemized:
R(a, b) ∧ ¬R(b, a).
Andrzej Szalas
Slide 252 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
6.
7.
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Resolution proof
1.
2.
3.
4.
5.
Introduction & propositional calculus
First-order logic
Miscellaneous
R(x1, x1 )
¬R(x2, y2 ) ∨ ¬R(x2 , z2 ) ∨ R(z2 , y2 )
R(a, b)
¬R(b, a)
¬R(x5, a) ∨ ¬R(x5 , b) – (res): 2, 4 with z2 = b, y2 = a
and renaming x2 /x5
¬R(a, a) – (res): 3, 5 with x5 = a
∅ – (res): 1, 6 with x1 = a
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Do the clauses imply transitivity?
Negated transitivity:
¬∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)] ↔
∃x∃y ∃z¬[(R(x, y ) ∧ R(y , z)) → R(x, z)] ↔
∃x∃y ∃z[R(x, y ) ∧ R(y , z) ∧ ¬R(x, z)].
Skolemized:
R(a, b) ∧ R(b, c) ∧ ¬R(a, c).
Slide 253 of 337
Andrzej Szalas
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Example: continued
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 254 of 337
Lecture IV: introduction
Lecture V: tableaux
Lecture VI: resolution
Summary
Resolution proof
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
R(x1 , x1 )
¬R(x2 , y2 ) ∨ ¬R(x2, z2 ) ∨ R(z2 , y2 )
R(a, b)
R(b, c)
¬R(a, c)
¬R(x6 , c) ∨ ¬R(x6 , a) – (res): 2, 5 with z2 = a, y2 = c
and renaming x2 /x6
¬R(b, a) – (res): 4, 6 with x6 = b
¬R(x8 , a) ∨ ¬R(x8 , b) – (res): 2, 7 with z2 = b, y2 = a
and renaming x2 /x8
¬R(a, a) – (res): 3, 8 with x8 = a
∅ – (res): 1, 9 with x1 = a
Andrzej Szalas
Slide 255 of 337
Prenex normal form.
Functions and terms.
Skolem normal form.
Unification.
Resolution for predicate calculus.
Factorization for predicate calculus.
Andrzej Szalas
Slide 256 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Deductive databases
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
What is a database?
A database is any finite collection of related data.
General problem
Reasoning in first-order logic is complex. How can it
be used in practice?
Specific subproblems
How to restrict formulas in knowledge bases to make
reasoning efficient?
How does reasoning in logic compare to other database
languages?
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 257 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
A closer look at databases
1
A figure illustrating dependencies between shapes on a plane.
2
A phone book.
3
A Swedish-to-English dictionary.
4
A library.
5
An electronic mailbox.
6
A personnel database of a department.
7
An accounting database.
8
A flight reservation database.
9
...
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 258 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
A closer look at databases
Database
an atomic data item
= number, letter, etc.
a record
= a tuple of atomic data items
a table
= a collection of “compatible” records
a relational database
= a collection of tables
+ integrity constraints
Andrzej Szalas
Examples
Representation in logic
an element
of a domain (universe)
a fact
a relation
an extensional database
= a collection of relations
+ formulas
Slide 259 of 337
Database
a deductive database
= relational database
+ deduction mechanism
a database query
a linguistic tool for selecting
pieces of information
Representation in logic
a deductive database
= extensional database
+ intensional database
(rules)
a formula
Integrity constraints
An integrity constraint of a database is a constraint that
has to be satisfied by any instance of the database.
Andrzej Szalas
Slide 260 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Introduction & propositional calculus
First-order logic
Miscellaneous
Example: a mobile phone book
Database
atomic data:
= first&last name,
phone number
a record:
{Eve Lin, 0701 334567}
a table:
{Eve Lin, 0701 334567}
{John Smith, 0701 334555}
...
Example: a mobile phone book – continued
Representation in logic
domains:
Names,
Numbers
a fact:
PN(′ Eve Lin′ , 0701 334567)
a relation:
PN(′ Eve Lin′ , 0701 334567)
PN(′ JohnSmith′ , 0701 334555)
...
Andrzej Szalas
Slide 261 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Database
a relational database:
the above table + constraints
e.g., “different persons have
different phone numbers”
a database query:
“find phone numbers
of Eve Lin”
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Introduction & propositional calculus
First-order logic
Miscellaneous
The architecture of deductive databases
Representation in logic
the extensional database:
the above relation +
∀x, y ∈ Names ∀n, m ∈ Numbers
[PN(x, n) ∧ PN(y , m) ∧ x 6= y ] →
n 6= m
formula:
PN(′ Eve Lin′ , X )
Slide 262 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Common assumptions
intensional databases











Integrity

constraints 








}|
z
Extensional
Database
s
◆
{
.....
✰
deduction mechanisms
✻
.....





✠






✴








❄
(
Andrzej Szalas










❪






■




Slide 263 of 337
If c1 , . . . , cn are all constant symbols appearing
in the database, then it is assumed that:
Queries
UNA (Unique Names Axiom):
for all 1 ≤ i 6= j ≤ n we have that ci 6= cj
DCA (Domain Closure Axiom):
∀x [x = c1 ∨ . . . ∨ x = cn ]
CWA (Closed World Assumption):
if R(ā1 ), . . . , R(āk ) are all facts about R stored in the
database then we have:
∀x̄ [R(x̄) → (x̄ = ā1 ∨ . . . ∨ x̄ = āk )].
Andrzej Szalas
Slide 264 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Datalog
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Datalog
Extensional databases, integrity constraints and queries are
present in traditional database management systems.
Deductive databases offer means to store deductive rules
(intensional databases) and provide a deduction machinery.
The basic language for deductive databases is Datalog.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Facts in Datalog
Facts in Datalog are represented in the form of relations
name(arg1 , . . . , argk ), where name is a name of a relation
and arg1 , . . . , argk are constants.
Examples
1
address(John, ’Kungsgatan 12′ )
2
likes(John, Marc).
Slide 265 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Atomic queries about facts
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 266 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Rules in Datalog
Atomic queries are of the form
name(arg1 , . . . , argk ),
where arg1 , . . . , argk are constants or variables, where ‘ ’ is also
a variable (without a name, “do-not-care” variable).
Rules in Datalog are expressed in the form of (a syntactic variant
of) Horn clauses:
R(Z̄ ):−R1 (Z̄1 ), . . . , Rk (Z̄k )
Examples
1
likes(John, Marc) – does John like Marc?
2
likes(X , Marc) – who likes Marc?
(compute X ’s satisfying likes(X , Marc))
3
likes(John, X ) – whom likes John?
4
likes(X , Y ) – compute all pairs hX , Y i such that likes(X , Y )
holds.
Andrzej Szalas
Slide 267 of 337
where Z̄ , Z̄1 , . . . , Z̄k are vectors of variable or constant symbols
such that any variable appearing on the lefthand side
of ‘:−’ (called the head of the rule) appears also at the righthand
side of the rule (called the body of the rule).
Andrzej Szalas
Slide 268 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Rules in Datalog
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Semantics
The intended meaning of the rule is that
[R1 (Z̄1 ) ∧ . . . ∧ Rk (Z̄k )] → R(Z̄ ),
where all variables that appear both in the rule’s head and body
are universally quantified, while those appearing only in the rule’s
body, are existentially quantified.
1
Select basic concepts.
2
Select derived concepts.
3
Provide integrity constraints
4
Provide rules defining derived concepts.
Example
Rule: R(X , c):−Q(X , Z ), S(Z , X ) denotes implication:
∀X {∃Z [Q(X , Z ) ∧ S(Z , X )] → R(X , c)}.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 269 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Andrzej Szalas
Slide 270 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Example: family database
1
Basic concepts: parent, male, female (note that we do not
allow negation, so male and female are not mutually
definable);
2
Derived concepts: mother , father , brother , sister ,
grandparent, ancestor , . . .
3
Integrity constraint: ∀X [male(X ) ↔ ¬female(X )]
(important: this is not a rule and does not produce new facts.
It does not allow to have both male(X ) and female(X )
for the same person X ).
Andrzej Szalas
Slide 271 of 337
Sample rules for family database
mother(X,Y)
father(X,Y)
grandparent(X,Y)
ancestor(X,Y)
ancestor(X,Y)
:−
:−
:−
:−
:−
Andrzej Szalas
parent(X,Y),
parent(X,Y),
parent(X,Z),
parent(X,Y).
parent(X,Z),
Slide 272 of 337
female(X).
male(X).
parent(Z,Y).
ancestor(Z,Y).
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Remark
Note that there are two rules with the same head ancestor(X,Y).
The meaning: disjunction, since rules with the same head:
Remark
One also often uses the following tautology:
[(b → h1) ∧ (b → h2)] ↔ [b → (h1 ∧ h2)].
It allows to substitute:
h:−b1.
h:−b2.
h1 ∧ h2:−b
are equivalent to (b1 → h) ∧ (b2 → h) which, in turn, is equivalent
to: (b1 ∨ b2) → h.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 273 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
by two rules:
h1:−b.
h2:−b.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 274 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Example
Formula:
Remark
Recall rules for ancestor:
∀x[dog (x) ∨ cat(x)] → [animal (x) ∧ fourLegs(x)]
can be expressed by rules:
animal(X)
animal(X)
fourLegs(X)
fourLegs(X)
Introduction & propositional calculus
First-order logic
Miscellaneous
:−
:−
:−
:−
The second rule is recursive: ancestor(X,Y) is being defined
and, at the same time, uses ancestor(Z,Y) in its definition
(i.e., body of the rule).
dog(X).
cat(X).
dog(X).
cat(X).
Andrzej Szalas
ancestor(X,Y) :− parent(X,Y).
ancestor(X,Y) :− parent(X,Z), ancestor(Z,Y).
Slide 275 of 337
Andrzej Szalas
Slide 276 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Designing Datalog databases
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example of Datalog facts and rules
Computing recursive rules: example
Assume we have facts: parent(Eve,Jack), parent(Eve,Mary),
parent(Jack,John), parent(John,Marc).
Computation of ancestor:
1
ancestor(Eve,Jack), ancestor(Eve,Mary),
ancestor(Jack,John), ancestor(John,Marc)
– using the first rule;
2
ancestor(Eve,John), ancestor(Jack,Marc)
– using the second rule;
3
ancestor(Eve,Marc) – using the second rule.
Facts
isA(zebra,mammal).
isA(whale,mammal).
isA(herring,fish).
isA(shark,fish).
lives(zebra,onLand).
lives(whale,inWater).
lives(frog,onLand).
lives(frog,inWater).
lives(shark,inWater).
Nothing new can be derived and the computation stops.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 277 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example of Datalog facts and rules – continued
Rules
canSwim(X):- isA(X,fish).
canSwim(X):- lives(X,inWater).
Based on the above facts and rules, can one derive that:
1
a whale can swim?
2
a frog can swim?
3
a salmon can swim?
Andrzej Szalas
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 278 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Datalog queries
A Datalog query is a conjunction of literals (conjunction is denoted
by comma). Assumptions UNA, DCA and CWA allow one to
formally define the meaning of queries as minimal relations which
make queries logical consequences of facts and rules stored
in the database. Intuitively,
if a query does not have free variables, then the answer
is either T or F dependently on the database contents;
if a query contains variables, then the result consists of all
assignments of values to variables, making the query T.
Slide 279 of 337
Andrzej Szalas
Slide 280 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Datalog queries
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example: authors database
1
isA(X,mammal) returns all X’s stored as mammals;
2
isA(salmon,X) returns all X’s representing type(s) of X;
The scenario
Consider a database containing information about book authors.
It is reasonable to store authors in one relation, say A, and book
titles in another relation, say T . The intended meaning of relations
is the following:
3
isA(X,mammal), can swim(X)
returns all mammals listed in the database that can swim.
A(N, Id ) means that the author whose name is N has its
identification number Id
Examples
T (Id, Ttl ) means that the author whose identification number
is Id is a (co-) author of the book entitled Ttl .
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 281 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example: authors database – continued
The scenario
Now, for example, one can define a new relation Co(N1, N2),
meaning that authors N1 and N2 co-authored a book:
Co(N1,N2):- A(N1,Id1), T(Id1,B),
A(N2,Id2), T(Id2,B), N1=/= N2.
Note that the above rule reflects the intended meaning provided
that authors have unique Id numbers, i.e., that the following
integrity constraint holds:
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 282 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example: authors database – continued
Querying the author database
In the authors database:
Co(‘Widom’,‘Ullman’) returns T iff the database contains
a book co-authored by Widom and Ullman
Co(N,‘Ullman’) returns a unary relation consisting of all
co-authors of Ullman.
∀n, m, i , j
[(A(n, i ) ∧ A(n, j)) → i = j]∧
[(A(n, i ) ∧ A(m, i )) → n = m]
Andrzej Szalas
Slide 283 of 337
Andrzej Szalas
Slide 284 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Predicate logic as a query language
In fact, query language can easily be made more general by
allowing all first-order formulas to be database queries.
For example, query:
∀X ∀Y [T (X , Y ) → ∃Z (T (X , Z ) ∧ Z 6= Y )]
returns T iff any person in the database is an author of at least
two books.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Introduction & propositional calculus
First-order logic
Miscellaneous
Example: train and bus connections
Given a database of direct train and bus connections, find places
connected directly or indirectly (changes of busses and trains might
be necessary).
Necessary relations
bus(p1 , p2 ) meaning that there is a direct bus connection
between places p1 and p2
train(p1 , p2 ) meaning that there is a direct train connection
between places p1 and p2 .
Slide 285 of 337
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example: train and bus connections – continued
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 286 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example: train and bus connections – continued
Rules
We define a new relation connected (p1 , p2 ) meaning that places p1
and p2 are connected by train/bus connections, perhaps indirectly:
def
connected (p1 , p2 ) ↔ [bus(p1 , p2 ) ∨ train(p1, p2 )∨
∃q(connected(p1 , q) ∧ connected (q, p2 ))].
Andrzej Szalas
Slide 287 of 337
connected(P1,P2):- bus(P1,P2).
connected(P1,P2):- train(P1,P2).
connected(P1,P2):connected(P1,Q),connected(Q,P2).
Andrzej Szalas
Slide 288 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exam-like exercise
2
all events later than 2012-02-03, whose duration is greater
than 10 and which are related to an event named “project
evaluation”;
all events related (maybe indirectly) to a given event (a given
event E is indirectly related to an event F if there are events
E1 , . . . , Ek with k ≥ 1 such that E is related to E1 , E1 is
related to E2 , . . ., Ek is related to F .
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Related(N1,N2) – meaning that events N1 and N2 are
related to each other.
Integrity constraints
Related (N1, N2) → Related (N2, N1)
∀N∀D∀U∀D ′∀U ′
[(Event(N, D, U) ∧ Event(N, D ′ , U ′ )) → (D = D ′ ∧ U = U ′ )]
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Queries
1 Event(N,D,U), D>‘2012-02-03’, U>10,
Related(N,‘project evaluation’).
We need a new relation “related directly or indirectly”:
diRelated(N1,N2):- Related(N1,N2)
diRelated(N1,N2):- Related(N1,N3),
diRelated(N3,N2).
The required query:
diRelated(N1,given),
where given is the name of the given event.
Andrzej Szalas
Relations
Event(N,D,U) – meaning that an event named N occurred in
date D and it’s duration has been U;
Slide 289 of 337
Exam-like exercise – continued
2
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exam-like exercise – continued
The scenario
Design a Datalog database for storing information about events.
Each event is characterized by its name, date and duration. In
addition, for each event the database contains information about
a number of related events. Formulate in logic queries selecting:
1
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 291 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 290 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Summary
Logical (deductive) databases.
Extensional and intensional databases.
Integrity constraints.
UNA, DCA and CWA.
Datalog.
Designing and querying deductive databases.
Andrzej Szalas
Slide 292 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
The problem
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
The Gentzen system for propositional calculus
Gentzen systems are dual to tableaux or resolution in the sense that
we directly prove validity rather than unsatisfiability of formulas.
Resolution and tableaux are based on the reduction to
absurdity paradigm.
For proof assistants/checkers we often prefer to present users
direct proofs, where steps lead to smaller subproblems
(lemmas) to be proved in order to prove the initial property.
Are there direct proof techniques supporting this approach?
Sequents
By a sequent we understand any expression of the form
A ⇒ B, where A, B are finite sets of formulas.
Let A = {A1 , . . . , Ak } and B = {B1 , . . . , Bm }.
Then the sequent A ⇒ B represents:
A1 ∧ . . . ∧ Ak → B1 ∨ . . . ∨ Bm ,
where it is assumed that the empty disjunction is F and the
empty conjunction is T.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 293 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
The Gentzen system for propositional calculus
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 294 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Sequent-based rules and axioms
General form of rules
Examples of sequents
1
2
3
p, q ⇒ ¬r represents [p ∧ q] → ¬r ;
p, q ⇒ r , ¬s, t represents [p ∧ q] → [r ∨ ¬s ∨ t];
soar throat, feaver ⇒ flu, cold represents
[soar throat ∧ feaver ] → [flu ∨ cold ].
Fact
If A ∩ B 6= ∅ then A ⇒ B represents a tautology.
Andrzej Szalas
Slide 295 of 337
A⇒B
− from A ⇒ B derive C ⇒ D
C ⇒D
A⇒B
from A ⇒ B derive conjunction
−
C ⇒ D and E ⇒ F
C ⇒ D; E ⇒ F
Axioms
Axioms are of the form A, B, C ⇒ D, B, E ,
i.e., the same formula appears at both sides of ⇒.
Andrzej Szalas
Slide 296 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen-like proofs
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Rules for propositional connectives
Negation
We shall always have two rules for each connective or operator,
one when it appears at the lefthand side of the sequent and one
when it appears at the righthand side of the sequent.
By a sequent proof of a formula A we shall understand the
derivation starting from ∅ ⇒ A and ending up in sequents for
which rules are no longer applicable.
If all such final sequents are axioms then A is a tautology.
(¬l )
A, ¬B, C ⇒ D
A, C ⇒ B, D
Introduction & propositional calculus
First-order logic
Miscellaneous
(∧l )
Slide 297 of 337
Disjunction
(∨l )
A, B ∨ C , D ⇒ E
A, B, D ⇒ E ; A, C , D ⇒ E
(∨r )
A ⇒ B, C ∨ D, E
A ⇒ B, C , D, E
Andrzej Szalas
Slide 299 of 337
A, B ∧ C , D ⇒ E
A, B, C , D ⇒ E
A ⇒ B, C ∧ D, E
A ⇒ B, C , E ; A ⇒ B, D, E
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Rules for propositional connectives
A ⇒ B, ¬C , D
A, C ⇒ B, D
Conjunction
(∧r )
Andrzej Szalas
(¬r )
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 298 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Proof of ¬(P ∧ Q) ∨ P
(∨r )
∅ ⇒ ¬(P ∧ Q) ∨ P
∅ ⇒ ¬(P ∧ Q), P
(¬r )
P ∧Q ⇒P
(∧l )
P, Q ⇒ P
| {z }
axiom
Andrzej Szalas
Slide 300 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Derived rules for definable connectives
Example: rule (→ l ) for implication
Consider first A, B → C , D ⇒ E :
Proof of (P ∧ Q) ∨ ¬P ∨ ¬Q
∅ ⇒ (P ∧ Q) ∨ ¬P ∨ ¬Q
(∨r )
∅ ⇒ (P ∧ Q), ¬P ∨ ¬Q
(∨r )
∅ ⇒ (P ∧ Q), ¬P, ¬Q
(¬r )
P ⇒ (P ∧ Q), ¬Q
(¬r )
P, Q ⇒ P ∧ Q
(∧r )
P, Q ⇒ P P, Q ⇒ Q
| {z } | {z }
axiom
axiom
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(def )
A, B → C , D ⇒ E
A, ¬B ∨ C , D ⇒ E
(∨l )
A, ¬B, D ⇒ E
(¬l )
; A, C , D ⇒ E
A, D ⇒ B, E
Example: rule (→ l ) for implication
Thus we have the following derived rule for implication:
(→ l )
A, B → C , D ⇒ E
A, D ⇒ B, E ; A, C , D ⇒ E
Slide 301 of 337
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Derived rules for definable connectives
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 302 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Example: rule (→ r )
Consider now A ⇒ B, C → D, E :
(def )
A ⇒ B, C → D, E
A ⇒ B, ¬C ∨ D, E
(∨r )
A ⇒ B, ¬C , D, E
(¬r )
A, C ⇒ B, D, E
Example: rule (→ r )
Thus we have the following derived rule:
(→ r )
Proof of P → (P ∨ Q)
(→ r )
∅ ⇒ P → (P ∨ Q)
P ⇒P ∨Q
(∨r )
P ⇒ P, Q
| {z }
axiom
A ⇒ B, C → D, E
A, C ⇒ B, D, E
Andrzej Szalas
Slide 303 of 337
Andrzej Szalas
Slide 304 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Counterexamples via the Gentzen system
The idea
When a leaf is not an axiom then we can assign:
T to propositions at the lefthand side;
F to propositions at the righthand side.
Proof of (P ∧ Q) → P
(→ r )
This provides a counterexample for the initial formula
(the values of propositions not appearing in the sequent do
not matter).
∅ ⇒ (P ∧ Q) → P
P ∧Q ⇒P
(∧l )
P, Q ⇒ P
| {z }
axiom
For example, having:
P, Q ⇒ R, S,
we assign T to P and Q, and F to R and S.
The sequent is equivalent to (P ∧ Q) → (R ∨ S), so its value
is F (and the value F is propagated to the initial formula).
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 305 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Counterexamples via the Gentzen system
Example: (P ∨ Q) → (P ∨ R)
(→ r ) ∅ ⇒ (P ∨ Q) → (P ∨ R)
P ∨Q ⇒ P ∨R
(∨r )
(∨l )
P ∨ Q ⇒ P, R
P ⇒ P, R
| {z }
axiom
Q ⇒ P, R
The non-axiom in the second leaf, containing Q ⇒ P, R, provides
a counterexample with Q being T and P, R being F.
Andrzej Szalas
Slide 307 of 337
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 306 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Satisfiability via the Gentzen system
The idea
We try to prove that the considered formula is
a counter-tautology and look for counterexamples.
To prove that formula A is a counter-tautology we
start proof with the sequent:
A ⇒ ∅,
representing A → F.
Andrzej Szalas
Slide 308 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Satisfiability via the Gentzen system
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Soundness and completeness: propositional case
Example: (P ∨ Q) → ¬P
(→ l )
(P ∨ Q) → ¬P ⇒ ∅
(∨r ) ∅ ⇒ (P ∨ Q)
∅ ⇒ P, Q
(¬l ) ¬P ⇒ ∅
∅⇒P
Each leaf provides a counterexample:
∅ ⇒ P, Q: P, Q being F;
The provided Gentzen proof system is sound:
if all leaves of a derivation tree of ∅ ⇒ A are axioms
then A is a tautology.
It is complete: if A is a tautology then there is a derivation
tree for ∅ ⇒ A with all leaves containing axioms.
The construction of any derivation tree always stops.
∅ ⇒ P: P being F (no matter what the value of Q is).
Both satisfy the initial formula (P ∨ Q) → ¬P.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 309 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen rules for quantifiers
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 310 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen rules for quantifiers
(∀l ): informal explanation
Universal quantifier
(∀l )
A, ∀x B(x), C ⇒ D
A, ∀x B(x), C , B(a) ⇒ D
(∀r )
A ⇒ B, ∀x C (x), D
A ⇒ B, C (a), D
where, in application of (∀r ), a is a fresh constant.
Let a1 , a2 . . . be constants representing elements of the domain.
Then:
A, ∀x B(x), C ⇒ D
A, B(a1 ) ∧ B(a2 ) ∧ . . . , C ⇒ D
A, B(a1), B(a2 ), . . . , C ⇒ D
A, ∀x B(x), C , B(a) ⇒ D
where a ∈ {a1 , a2 , . . .}.
Andrzej Szalas
Slide 311 of 337
Andrzej Szalas
Slide 312 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen rules for quantifiers
Existential quantifier
A ⇒ B, ∀x C (x), D
.
A ⇒ B, C (a), D
Since a is a fresh constant, its value is unconstrained.
Therefore, if A ⇒ B, C (a), D represents a tautology
then C (a) holds for every a.
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen rules for quantifiers
(∀r ): informal explanation
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(∃l )
(∃r )
A ⇒ B, ∃x C (x), D
A ⇒ B, ∃x C (x), D, C (a)
where, in application of (∃l ), a is a fresh constant.
Slide 313 of 337
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Gentzen rules for quantifiers
A, ∃x B(x), C ⇒ D
A, B(a), C ⇒ D
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 314 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Proof of formula [∀x P(x)] → [∃x P(x)]
Remarks
For clarity we sometimes do not repeat formulas starting from
∀ or ∃ in conclusions of rules.
Note that proofs may loop generating fresh constants.
Andrzej Szalas
Slide 315 of 337
(→ r ) ∅ ⇒ [∀x P(x)] → [∃x P(x)]
∀x P(x) ⇒ ∃x P(x)
(∀l )
P(a) ⇒ ∃x P(x)
(∃r )
P(a) ⇒ P(a)
|
{z
}
axiom
Andrzej Szalas
Slide 316 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Proof of formula [∀x P(x) ∧ ∀x Q(x)] → ∀x[P(x) ∧ Q(x)]
(→ r )
∅ ⇒ [∀x P(x) ∧ ∀x Q(x)] → ∀x[P(x) ∧ Q(x)]
(∧l ) ∀x P(x) ∧ ∀x Q(x) ⇒ ∀x[P(x) ∧ Q(x)]
(∀r ) ∀x P(x), ∀x Q(x) ⇒ ∀x[P(x) ∧ Q(x)]
(∧r )
(∀l ) ∀x P(x), ∀x Q(x) ⇒ P(a) ∧ Q(a)
P(a), ∀x Q(x) ⇒ P(a) ∧ Q(a)
(∀l )
P(a), Q(a) ⇒ P(a) ∧ Q(a)
P(a), Q(a) ⇒ P(a)
|
{z
}
axiom
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
P(a), Q(a) ⇒ Q(a)
{z
}
|
axiom
Slide 317 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example
Proof of formula ∀x[P(x) ∧ Q(x)] → [∀x P(x) ∧ ∀x Q(x)]
(→ r )
(∧r )
(∀r )
∅ ⇒ ∀x[P(x) ∧ Q(x)] → [∀x P(x) ∧ ∀x Q(x)]
∀x[P(x) ∧ Q(x)] ⇒ ∀x P(x) ∧ ∀x Q(x)
∀x[P(x) ∧ Q(x)] ⇒ ∀x P(x)
(∀l ) ∀x[P(x) ∧ Q(x)] ⇒ P(a)
(∧l ) P(a) ∧ Q(a) ⇒ P(a)
P(a), Q(a) ⇒ P(a)
{z
}
|
axiom
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(∀r )
∀x[P(x) ∧ Q(x)] ⇒ ∀x Q(x)
(∀l ) ∀x[P(x) ∧ Q(x)] ⇒ Q(b)
(∧l ) P(b) ∧ Q(b) ⇒ Q(b)
P(b), Q(b) ⇒ Q(b)
|
{z
}
axiom
Slide 318 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Soundness and completeness: first-order case
Proof of formula ∀x[P(x) ∨ Q(x)] → [∃x P(x) ∨ ∀x Q(x)]
∅ ⇒ ∀x[P(x) ∨ Q(x)] → [∃x P(x) ∨ ∀x Q(x)]
∀x[P(x) ∨ Q(x)] ⇒ ∃x P(x) ∨ ∀x Q(x)
∀x[P(x) ∨ Q(x)] ⇒ ∃x P(x), ∀x Q(x)
∀x[P(x) ∨ Q(x)] ⇒ ∃x P(x), Q(a)
∀x[P(x) ∨ Q(x)] ⇒ P(a), Q(a)
P(a) ∨ Q(a) ⇒ Q(a), P(a)
Q(a) ⇒ Q(a), P(a)
P(a) ⇒ Q(a), P(a)
{z
}
{z
}
|
|
axiom
axiom
Andrzej Szalas
Slide 319 of 337
The provided Gentzen proof system is sound:
if all leaves of a derivation tree of ∅ ⇒ A are axioms
then A is a tautology.
It is complete: if A is a tautology then there is a derivation
tree for ∅ ⇒ A with all leaves containing axioms.
The construction of derivation tree may loop forever.
Andrzej Szalas
Slide 320 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example of practical reasoning
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Example of practical reasoning
The scenario – see slide 175
Assumptions:
Car c is older than car d.
Every car older than d is cheap.
Car e is older than car c.
Every car older than c is older than d .
Conclusion: Car e is cheap.
Introduction & propositional calculus
First-order logic
Miscellaneous
Translation
O(c, d)
∀x[O(x, d) → C (x)]
O(e, c)
∀x[O(x, c) → O(x, d)]
C (e)
Proof
One has to prove:
O(c, d),∀x[O(x, d) → C (x)], O(e, c),∀x[O(x, c) → O(x, d)] ⇒ C (e)
Hint: use rule (∀l ) to obtain intermediate sequent (below
redundant formulas are omitted):
O(c, d), O(e, d) → C (e), O(e, c), O(e, c) → O(e, d) ⇒ C (e).
Next, applications of (∨l ) and then of (¬l ) result in leaves
containing axioms.
Slide 321 of 337
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Summary
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 322 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 1
1
Translate the following sentences and assumptions concerning
a robot behavior into a set of propositional formulas:
“It is possible to go to the left or to the center or to the right.
Video camera detects an obstacle in the center or to the right.
It also detects that to the left there is an obstacle or
a shadow. There is a shadow to the left of any obstacle.
Do not go towards a shadow nor towards an obstacle.”
2
What directions can be chosen in (1) assuming that a robot
can chose only one direction? Prove your claim syntactically
using a chosen proof system.
Gentzen system for propositional calculus.
Derived rules.
Gentzen system for first-order logic.
Andrzej Szalas
Slide 323 of 337
Andrzej Szalas
Slide 324 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 1 - solution
(1)left ∨ center ∨ right
(2)obstacleCenter ∨ obstacleRight
(3)obstacleLeft ∨ shadowLeft
(4)obstacleCenter → shadowLeft
(5)obstacleRight → shadowCenter
(6)obstacleLeft → ¬left
(7)obstacleCenter → ¬center
(8)obstacleRight → ¬right
(9)shadowLeft → ¬left
(10)shadowCenter → ¬center
(11)shadowRight → ¬right
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Hypothesis
After a semantical considerations one can state the hypothesis that
the robot should go to the right (expressed by right).
One direction only:
(a)left → (¬center ∧ ¬right)
(b)center → (¬left ∧ ¬right)
(c)right → (¬left ∧ ¬center )
Proof
Will be carried out during the lecture.
Hint: it suffices to use resolution to chosen clauses, e.g.:
from (3) and (6) deduce shadowLeft ∨ ¬left, so using (9)
deduce ¬left;
from (2) and (5) deduce obstacleCenter ∨ shadowCenter ,
so using (7) deduce shadowCenter ∨ ¬center which, together
with (10), gives ¬center ;
using (1) together with ¬left and then with ¬center deduce
right.
Slide 325 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 2
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 326 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 2 - solution of 1
Semantical check
Will be carried out during the lecture.
Definitions
R is reflexive iff ∀x[R(x, x)];
R is transitive iff ∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)];
R is symmetric iff ∀x∀y [R(x, y ) → R(y , x)];
R is serial iff ∀x∃y [R(x, y )].
Consider a binary relation R.
2
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 1 - solution
Translation
1
Introduction & propositional calculus
First-order logic
Miscellaneous
Check semantically whether transitivity, symmetry and
seriality of R together imply reflexivity of R.
Prove your claims obtained in (1) syntactically using a chosen
proof systems.
Andrzej Szalas
Slide 327 of 337
Formulation of 1

∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)] 
∀x∀y [R(x, y ) → R(y , x)]
→ ∀x[R(x, x)]

∀x∃y [R(x, y )]
Proof of 1 by resolution - negated
∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)]
∀x∀y [R(x, y ) → R(y , x)]
∀x∃y [R(x, y )]
∃x[¬R(x, x)]
Andrzej Szalas
Slide 328 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 2 - solution of 1
Introduction & propositional calculus
First-order logic
Miscellaneous
Exercise 3
Proof of 1
1
¬R(x1 , y1 ) ∨ ¬R(y1 , z1 ) ∨ R(x1 , z1 )
¬R(x2 , y2 ) ∨ R(y2 , x2 )
R(x3 , f (x3 ))
¬R(a, a)
¬R(f (x5 ), z5 ) ∨ R(x5 , z5 )
−(res) : 1, 3 with x1 = x3 , y1 = f (x3 ), x3 /x5 , z1 /z5
6. R(f (x6 ), x6 ) − (res) : 2, 3 with x2 = x3 , y2 = f (x3 ), x3 /x6
7. R(x7 , x7 ) − (res) : 5, 6 with x5 = z5 = x6 , x6 /x7
8. ∅ − (res) : 4, 7 with x7 = a.
1.
2.
3.
4.
5.
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
2
3
Translate into quantified (first-order) formulas:
“Every considered item is red, green or blue.”
“If an item x is over an item y then it is not below y .”
“Red items are over green items.”
“Item a is below item b.”
“Item b is green.”
“Item a is not green.”
Prove semantically that the conjunction of formulas in (1)
implies “Item a is blue.”
Prove (2) syntactically using a chosen proof system.
Slide 329 of 337
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 3 - solution
Introduction & propositional calculus
First-order logic
Miscellaneous
Slide 330 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 3 - solution
Translation
∀x[red(x) ∨ green(x) ∨ blue(x)]
∀x∀y [over (x, y ) → ¬below (x, y )]
∀x∀y [(red(x) ∧ green(y )) → over (x, y )]
below (a, b)
green(b)
¬gren(a)
Semantical proof
Will be carried out during the lecture.
Andrzej Szalas















Slide 331 of 337
Proof by resolution - negated
→ blue(a)
∀x[red(x) ∨ green(x) ∨ blue(x)]
∀x∀y [over (x, y ) → ¬below (x, y )]
∀x∀y [(red(x) ∧ green(y )) → over (x, y )]
below (a, b)
green(b)
¬gren(a)
¬blue(a)
Andrzej Szalas
Slide 332 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 3 - solution
Proof
red(x1 ) ∨ green(x1 ) ∨ blue(x1 )
¬over (x2 , y2 ) ∨ ¬below (x2 , y2 )
¬red(x3 ) ∨ ¬green(y3 ) ∨ over (x3 , y3 )
below (a, b)
green(b)
¬gren(a)
¬blue(a)
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
2
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
2
red(a) ∨ green(a)
red(a)
¬over (a, b)
¬red(x11 ) ∨ over (x11 , b)
over (a, b)
∅
Andrzej Szalas
Introduction & propositional calculus
First-order logic
Miscellaneous
(res) : 1, 7 with: x1 = a
(res) : 6, 8
(res) : 2, 4 with: x2 = a, y2 = b
(res) : 3, 5 with: y3 = b, x3 /x11
(res) : 9, 11 with: x11 = a
(res) : 10, 12
Slide 334 of 337
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 4 - solution
Design a Datalog database for storing information about
regions on a screen. Each region is characterized by its shape,
size and color. In addition, for each pair of regions c1 , c2 ,
the database contains information whether c1 intersects c2 .
Formulate in logic queries selecting:
1
8.
9.
10.
11.
12.
13.
Slide 333 of 337
Exercise 4
1
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 3 - solution
Clausal form
1.
2.
3.
4.
5.
6.
7.
Introduction & propositional calculus
First-order logic
Miscellaneous
all pairs consisting of intersecting regions, first of which
is small and the second is round and green
all medium regions from which there is a path to a large region,
assuming that a path between regions c and d is a sequence
of regions r1 , . . . , rk (k ≥ 1) such that r1 = c, rk = d and for
each i such that 1 ≤ i ≤ k − 1, we have that ri intersects ri +1 .
Database design
Relations:
region(id, shape, size, color ) – id is a unique id of the region
intersects(id1, id2) – region id1 intersects region id2.
Integrity constraint “every region has a unique shape, size and
color”:
∀x, y , y ′ , z, z ′ , u, u ′
[(region(x, y , z, u) ∧ region(x, y ′ , z ′ , u ′ )) →
(y = y ′ ∧ z = z ′ ∧ u = u ′ )].
Integrity constraint “intersects is reflexive and symmetric”:
∀x[intersects(x, x)]∧∀x∀y [intersects(x, y ) → intersects(y , x)].
Andrzej Szalas
Slide 335 of 337
Andrzej Szalas
Slide 336 of 337
Introduction & propositional calculus
First-order logic
Miscellaneous
Lecture VII: deductive databases
Lecture VIII: sequent calculus
Lecture IX: repetition
Exercise 4 - solution
Index
Queries
1 all pairs consisting of intersecting regions, first of which
is small and the second is round and green:
answer (X , Y ) : − region(X , , ‘small ′ , ),
region(Y , ‘round ′ , , ‘green′ ),
intersects(X , Y ).
2
all medium regions from which there is a path to a large
region:
path(X , Y ) : − intersects(X , Y ).
path(X , Y ) : − intersects(X , Z ), path(Z , Y ).
answer (X )
: − region(X , , ‘medium′ , ),
region(Y , , ‘large ′ , ), path(X , Y ).
α-formula, 64
β-formula, 65
δ-formula, 182
γ-formula, 181
0-1 method, 33
assumption, 54
atomic
query, 267
auxiliary symbol, 16
axiom, 53
affirming the consequent, 56
analytic tableaux, 52
Aristotelian form, 151
Aristotle, 151
arity
of a function, 222
assignment, 147
Beth, 52
binary
function, 222
body of a rule, 268
bound variable, 142
branch
closed, 186
338
Andrzej Szalas
Slide 337 of 337
clausal form, 99
completeness, 60, 61
clause, 99
conclusion, 54
empty, 99
conjunction, 25
Horn, 99
conjunctive normal form, 99
closed
connective
branch, 186
and, 25
leaf, 67
equivalent to, 30
node, 183
implies, 29
tableau, 70
not, 24
closed world assumption, 264
or, 27
CNF, 99
consequence, 12
complement, 76
constant, 16
of a formula, 66
individual, 16
complementary formulas, 66, 183
logical, 15
complete proof system, 61
correct
completed tableau, 67
argument, 50
339
proof system, 61
reasoning, 50
correctness, 60
counter-tautology, 31
CWA, 264
rule, 53
derived rule, 302
disjunction, 27
domain, 145, 226
closure axiom, 264
database, 258
Datalog, 265, 266
query, 280
DCA, 264
deductive database, 259
DeMorgan, 39
laws for quantifiers, 163
DeMorgan’s laws, 39
denying the antecedent, 56
derivation, 57
empty clause, 99
equality, 76
equisatisfiable formulas, 230
equivalence, 30
Euclidicity, 195
existential
quantifier, 134
extensional
database, 259
fact, 259
340
in Datalog, 266
factorization, 64, 110
rule, 110, 238
first-order
logic, 138
quantifier, 138
formal proof, 57
free variable, 142
function, 221, 222
argument, 221
name, 221
symbol, 16, 224
value, 221
Gentzen, 52
Gentzen system
for first-order logic, 311
for propositional calculus, 294
head of a rule, 268
Hilbert, 52
Horn, 99
clause, 99
implication, 29
laws, 41, 42
inclusion, 76
inference, 57
rule, 53
integrity constraint, 260
intensional
database, 259
interpretation, 145, 226
intersection, 76
knowledge base, 92
language, 14
leaf
closed, 67
open, 67
literal, 66, 95
negative, 66, 95, 183
positive, 66, 95, 183
logic, 9
logical
operator, 16
meta-property, 60
341
PNF, 218
positive
literal, 66, 183
positive literal, 95
predicate calculus, 138
premise, 54
prenex normal form, 218
proof, 57
rule, 53
system, 52, 53
propositional
atom, 15
connective, 16
letter, 15
variable, 15
provable formula, 57
quantifier, 134
recursive rule, 276
reflexivity, 137, 195, 327
relation
symbol, 15
renaming, 239
resolution, 52, 107
method, 112, 113
rule, 107, 236
restricted
existential quantification, 151
quantifier, 151
universal quantification, 151
Robinson, 52, 107
rule
343
in Datalog, 268
recursive, 276
model, 5
modus
ponens, 55
tollens, 55
MP, 55
natural deduction, 52
negation, 24
normal form, 95, 96, 216
negative
literal, 66, 183
negative literal, 95
NNF, 95, 96, 216
node
closed, 183
open leaf, 67
342
for negation, 298
for universal quantifier, 311
seriality, 327
set-based semantics, 75, 76
Skolem normal form, 229
Smullyan, 52
sound
argument, 50
proof system, 61
soundness, 60, 61
standard notation, 221
symmetry, 137, 196, 327
satisfiable, 31
scope of a quantifier, 142
second-order
logic, 139
quantifier, 139
semantic tableau, 62, 180
semantical presentation, 12
sequent, 294
proof, 297
sequent-based rule, 296
for conjunction, 298
tableau
for disjunction, 299
closed, 70
completed, 67
for existential quantifier, 314
344
tautology, 31
taxonomy, 73
term, 224
third-order
logic, 139
quantifier, 139
transitivity, 137, 203
truth
table, 23
for conjunction, 25
for disjunction, 27
for equivalence, 30
for implication, 29
for negation, 24
truth table method, 33, 34
UNA, 264
unary
function, 222
unifiable expressions, 233
unification, 233
algorithm, 235
union, 76
unique names axiom, 264
universal
quantifier, 134
unsatisfiable, 31
propositional, 15
zero-order logic, 138
valid formula, 31
variable, 16
individual, 16
logical, 15
345
346
Download