Document 13127329

advertisement
Introduction & propositional calculus
Predicate calculus
Other topics
Introduction & propositional calculus
Predicate calculus
Other topics
Contents
Lect.
Logic
http://www.ida.liu.se/∼TDDD72/
1
2
Andrzej Szalas
3
IDA, University of Linköping
Recommended book:
M. Ben-Ari: Mathematical Logic for Computer Science
4
5
6
⊲ Note that there are substantial additions during each lecture ⊳
7
8
9
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Contents
Introduction to logics
Propositional calculus.
Propositional calculus: tableaux,
other deductive systems.
Propositional calculus: resolution.
Applications.
Predicate calculus, tableaux
Predicate calculus: deductive systems.
Predicate calculus: resolution.
Applications.
Deductive databases.
Modal logics and Temporal logics.
Repetition
Slide 1 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Modeling
Book chapter
2nd ed. 3rd ed.
—
1
2
2
2
2
3
3
4
4
—
—
5
7
6
8
7
10
—
—
—
—
11
13
—
—
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 2 of 226
Lecture I: introduction
Lecture II: deductive systems
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
R ÅÆ⁀ooΛiTY
...
K2
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.
a designer’s point of view: e.g., model of aerodynamical flows,
models of materials’ strength, etc.
REALITY
REALITY
REALITY
REALITY
a dealer’s point of view: shape, color, price, etc.
Andrzej Szalas
Slide 3 of 226
Andrzej Szalas
Slide 4 of 226
perception
language
logic
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Quantitative and symbolic reasoning
analytical/numerical methods
probabilistic/statistical methods
fuzzy logic.
Symbolic reasoning
classical logic and logic programming
three- and many-valued logics
modal and temporal logics
nonmonotonic reasoning
approximate reasoning
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 5 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
What are logics?
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
From sensors to higher level reasoning
✻
Quantitative reasoning
algorithmic methods
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics




Incomplete, 
inconsistent 

data 











Noisy, 

incomplete


data 








✻
✻ ...
✻
✻
✻
Qualitative reasoning
✻


 Qualitative
Databases


✻
...
✻
✻
Quantitative reasoning
✻
✻
...
✣
✣
✣
❪
❪
...
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics





Quantitative

Databases



)
Sensors,
cameras,...
Slide 6 of 226
Lecture I: introduction
Lecture II: deductive systems
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
Slide 7 of 226
investigate the reality solely through the level of truth of the
expressed properties.
Andrzej Szalas
Slide 8 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Fixing the language
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Semantical presentation of logics
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Semantical presentation depends on choosing models and
attaching interpretation of formulas in models.
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 that M |= S implies that M |= A.
Slide 9 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 10 of 226
Lecture I: introduction
Lecture II: deductive systems
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.
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:
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
M |= red or brown
M 6|= if car then brown
Andrzej Szalas
Logical language is defined by fixing logical connectives, operators,
dictionaries and syntax rules how to form formulas. Logical
connectives and operators have a fixed meaning. Dictionaries
reflect concepts of a given application area and are flexible.
relation symbols, representing relations,
– e.g., =, ≤, Slide 11 of 226
Andrzej Szalas
Slide 12 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Logical language
Elements of a logical language – continued
individual constants (constants), representing objects
– e.g., 0, 1, John
Why “function/relation symbols” rather
than “functions/relations”?
individual variables, representing objects, e.g., x, y , m, n
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.
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
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 13 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Bnf notation
S ::= S1 | . . . | Sn
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 14 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Propositional calculus
Bnf notation allows us to define syntax of languages. There are
two forms of rules:
rule
S ::= S1 . . . Sn
Andrzej Szalas
meaning
symbol S may be replaced by sequence
S1 . . . Sn
symbol S may be replaced by one of
S1 , . . . , Sn
Andrzej Szalas
Slide 15 of 226
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 ]
Convention
Brackets are used to make the notation unambiguous. To simplify
notation we often omit brackets, assuming that the order of
precedence from high to low is: ¬, ∧, ∨, ↔, →.
¬D ↔
For example,A ∨ ¬B
! ∧ C → E ∨ F abbreviates
A ∨ (¬B) ∧ C → (¬D) ↔ (E ∨ F ) .
Andrzej Szalas
Slide 16 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Propositional calculus
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Truth tables
Examples of propositional formulas
break pedal pressed → slow down

engine on

→ motion
∧ gear on

∧ gas pedal pressed
!
!
¬gear on → ¬motion ∨ slow down
...
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
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.
Connective “not”
Connective not, denoted by ¬, expresses the negation
of a sentence.
Truth table for negation
A
F
T
Slide 17 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Truth tables: conjunction
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 18 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
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
¬A
T
F
B
F
T
F
T
Andrzej Szalas
A∧B
F
F
F
T
Slide 19 of 226
Andrzej Szalas
Slide 20 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Truth tables: disjunction
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Examples
Connective “or”
Connective or, denoted by ∨, expresses the disjunction
of sentences.
Truth table for disjunction
A
F
F
T
T
Introduction & propositional calculus
Predicate calculus
Other topics
B
F
T
F
T
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
A∨B
F
T
T
T
Slide 21 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Truth tables: implication
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
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 22 of 226
Lecture I: introduction
Lecture II: deductive systems
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
A→B
T
T
F
T
Slide 23 of 226
A
F
F
T
T
B
F
T
F
T
Andrzej Szalas
A↔B
T
F
F
T
Slide 24 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Truth table method
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
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).
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
Predicate calculus
Other topics
Slide 25 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
A tautology is a formula which is T for all possible
assignments of truth values to atomic sentences.
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
a counter-tautology.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 26 of 226
Lecture I: introduction
Lecture II: deductive systems
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 stands for
“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 our initial formula is a tautology.
Andrzej Szalas
Slide 27 of 226
Andrzej Szalas
Slide 28 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Checking satisfiability
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
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 29 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Example: DeMorgan’s laws
Slide 30 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example: DeMorgan’s laws
DeMorgan’s laws are:
[¬(A ∧ B)] ↔ (¬A ∨ ¬B)
(3)
[¬(A ∨ B)] ↔ (¬A ∧ ¬B)
The following truth table proves (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
The following truth table proves (4):
(4)
¬(A ∧ B)
T
T
T
F
Slide 31 of 226
¬A ∨ ¬B
T
T
T
F
(3)
T
T
T
T
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 32 of 226
¬A ∧ ¬B
T
F
F
F
(4)
T
T
T
T
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Example: implication laws
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
(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 33 of 226
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 35 of 226
¬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: deductive systems
Lecture III: resolution
Example: three atomic sentences
Andrzej Szalas
¬(A → B) ↔ (A ∧ ¬B)
Introduction & propositional calculus
Predicate calculus
Other topics
(6)
T
T
T
T
Slide 34 of 226
Lecture I: introduction
Lecture II: deductive systems
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 36 of 226
2’
T
F
F
F
T
T
T
T
1′ ↔ 2′
T
T
T
T
T
T
T
T
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Summary
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
What is correct reasoning?
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.
the notion of a logic
modeling in logic
semantical presentation of logics
elements of a logical language
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.
propositional calculus
truth table method.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 37 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Examples
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 38 of 226
Lecture I: introduction
Lecture II: deductive systems
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 39 of 226
Andrzej Szalas
Slide 40 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
What is a proof system?
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
Slide 41 of 226
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
Slide 42 of 226
Lecture I: introduction
Lecture II: deductive systems
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 43 of 226
⊢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 44 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
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 a theorem 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.
Slide 45 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 46 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Hilbert proof system H for propositional calculus
Some meta-properties
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.
Assume a logic is given by its semantics S and by a proof system
P. Then we say that:
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.
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
Slide 47 of 226
axioms:
⊢A
! → (B → A) !
⊢ A → (B → C ) → (A → B) → (A → C )
⊢ (¬B → ¬A) → (A → B)
rule (modus ponens):
⊢A
⊢A→B
⊢B
Soundness and completeness of H
The proof system H is sound,
i.e., any formula provable in H is a tautology.
The proof system H is complete,
i.e., any tautology is provable in H.
Andrzej Szalas
Slide 48 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example
3
4
5
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Propositional calculus: tableaux
We prove ⊢ A → A.
!
!
1 ⊢ A → ((A → A) → A) → (A → (A → A)) → (A → A)
(axiom 2 with B replaced by (A → A)) and C replaced by A
2
Introduction & propositional calculus
Predicate calculus
Other topics
⊢ A → ((A → A) → A) (axiom 1 with B replaced by
(A → A))
⊢ (A → (A → A)) → (A → A) (MP applied to 1, 2)
⊢ A → (A → A) (axiom 1 with B replaced by A)
⊢ A → A (MP applied to 3, 4).
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 49 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example
A literal is an atom or negation of an atom.
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.
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 50 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
α-formulas and β-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 51 of 226
α
α1
α2
¬¬A1
A1
A1 ∧ A2
A1
A2
¬(A1 ∨ A2 ) ¬A1
¬A2
¬(A1→A2 )
A1
¬A2
A1↔A2
A1→A2 A2→A1
Andrzej Szalas
β
β1
β2
¬(B1 ∧ B2 )
¬B1
¬B2
B1 ∨ B2
B1
B2
B1→B2
¬B1
B2
¬(B1↔B2 ) ¬(B1→B2 ) ¬(B2→B1 )
Slide 52 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Closed and open leaves
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Construction of a semantic tableau for a formula C
A leaf is called closed if it contains a complementary pair of literals.
Observe that our definition of a closed leaf differs a bit from
the one given in the book. We do not require that it contains
literals only so this definition leads to a more efficient construction.
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 53 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example
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
S
−
{D}
∪ {β1 } and the second one
first one labeled
with
!
labeled with S − {D} ∪ {β2 }.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 54 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Important properties
(¬p ∨ ¬q) ∧ p ∧ q
↓
(¬p ∨ ¬q), p ∧ q
↓
(¬p ∨ ¬q), p, q
ւ
ց
¬p, p, q
¬q, p, q
Andrzej Szalas
Slide 55 of 226
Soundness and completeness
The construction of a tableau always terminates and leads to
a completed tableau. A completed tableau is closed iff all its leaves
are closed.
Let T be a completed tableau for a formula A.
Then A is unsatisfiable iff T is closed.
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
Slide 56 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
The Gentzen system G
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
Introduction & propositional calculus
Predicate calculus
Other topics
Gentzen systems are dual to tableaux in the sense that we directly
prove validity rather than unsatisfiability of formulas. Here we shall
concentrate on Gentzen systems, as defined originally.
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.
Slide 57 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
The Gentzen system G
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 58 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Sequent-based rules and axioms
General form of rules
Examples of sequents
1
2
p, q ⇒ ¬r represents [p ∧ q] → ¬r
p, q ⇒ r , ¬s, t represents
[p ∧ q] → [r ∨ ¬s ∨ t].
Fact
If A ∩ B 6= ∅ then A ⇒ B represents a tautology.
Andrzej Szalas
Slide 59 of 226
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
Note that we present rules “upside down”, which better reflects
construction of proofs.
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 60 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Gentzen-like proofs
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Rules
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 otherwise it is not a tautology.
(¬l )
A, ¬B, C ⇒ D
A, C ⇒ B, D
Introduction & propositional calculus
Predicate calculus
Other topics
(∧l )
A, B ∧ C , D ⇒ E
A, B, C , D ⇒ E
A ⇒ B, C ∧ D, E
A ⇒ B, C , E ; A ⇒ B, D, E
Slide 61 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Rules
A ⇒ B, ¬C , D
A, C ⇒ B, D
Conjunction
(∧r )
Andrzej Szalas
(¬r )
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 62 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Examples
Proof of P → (P ∨ Q)
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
We do not have rules for implication, so replace it using a suitable
implication law and start with ¬P ∨ (P ∨ Q):
∅ ⇒ ¬P ∨ (P ∨ Q)
(∨r )
∅ ⇒ ¬P, P ∨ Q
(∨r )
∅ ⇒ ¬P, P, Q
(¬r )
P ⇒ P, Q
Proof of (P ∧ Q) → P
We use a suitable implication law and start with ¬(P ∧ Q) ∨ P:
∅ ⇒ ¬(P ∧ Q) ∨ P
(∨r )
∅ ⇒ ¬(P ∧ Q), P
(¬r )
P ∧Q ⇒P
(∧l )
P, Q ⇒ P
Andrzej Szalas
Slide 63 of 226
Andrzej Szalas
Slide 64 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Derived rules for definable connectives
Introduction & propositional calculus
Predicate calculus
Other topics
Derived rules for definable connectives
Example: rule (→ l ) for implication
Example: rule (→ r )
Consider first A, B → C , D ⇒ E :
Consider now A ⇒ B, C → D, E :
(def )
A, B → C , D ⇒ E
A, ¬B ∨ C , D ⇒ E
(∨l )
A, ¬B, D ⇒ E
; A, C , D ⇒ E
(¬l )
A, D ⇒ B, E
Thus we have the following derived rule for implication:
(→ l )
(def )
A ⇒ B, C → D, E
A ⇒ B, ¬C ∨ D, E
(∨r )
A ⇒ B, ¬C , D, E
(¬r )
A, C ⇒ B, D, E
Thus we have the following derived rule:
A, B → C , D ⇒ E
A, D ⇒ B, E ; A, C , D ⇒ E
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
A ⇒ B, C → D, E
A, C ⇒ B, D, E
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 66 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Summary
The provided Gentzen proof system G 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 above concerns formulas containing only connectives for
which we have rules or definitions which use such connectives.)
Andrzej Szalas
(→ r )
Slide 65 of 226
Soundness and completeness
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Slide 67 of 226
proof systems
soundness and completeness
Hilbert-like proof systems, system H
tableaux for propositional calculus
Gentzen system G for propositional calculus
derived rules.
Andrzej Szalas
Slide 68 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
NNF: Negation Normal Form
Examples
2
3
4
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Transforming formulas into NNF
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.
1
Introduction & propositional calculus
Predicate calculus
Other topics
(p ∨ ¬q ∧ s) ∨ ¬t is in Nnf
(p ∨ ¬¬q ∧ s) ∨ ¬t is not in Nnf
r ∧ ¬q ∧ ¬s ∧ t is in 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)
Replaced by
(¬A ∨ B) ∧ (A ∨ ¬B)
¬A ∨ B
A
¬A ∧ ¬B
¬A ∨ ¬B
r ∧ ¬q ∧ ¬[¬s ∧ t] is not in Nnf.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 69 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Transforming formulas into NNF
Example
¬[(¬p ∧ r ) → (¬(q ∨ r ))]
¬[¬(¬p ∧ r ) ∨ (¬(q ∨ r ))]
(2)
←→
(4)
←→
(3)
¬(¬(¬p ∧ r )) ∧ ¬(¬(q ∨ r )) ←→
(¬p ∧ r ) ∧ ¬(¬(q ∨ r ))
(¬p ∧ r ) ∧ (q ∨ r ).
Andrzej Szalas
(3)
←→
Slide 71 of 226
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 70 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
CNF: Conjunctive Normal Form
A clause is any formula of the form A1 ∨ A2 ∨ . . . ∨ Ak , where
k ≥ 1 and A1 , A2 , . . . , Ak are literals
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).
Andrzej Szalas
Slide 72 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Examples
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Why Horn clauses are important?
Any Horn clause can be transformed into the form of implication:
1
2
3
4
5
6
[A1 ∧ A2 ∧ . . . ∧ Al ] → B,
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
Introduction & propositional calculus
Predicate calculus
Other topics
where all A1 , A2 , . . . , Al , B are positive literals. Such implications
are frequently used in everyday reasoning, expert systems,
deductive database queries, etc.
Examples
rain → take umbrella,
(snow ∧ ice) → cold weather,
(starterProblem ∧ cold weather) → chargeBattery.
Slide 73 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Non-Horn clauses
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 74 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Transforming formulas into CNF
In the case of more positive literals a clause is equivalent to:
[A1 ∧ A2 ∧ . . . ∧ Al ] → [B1 ∨ B2 ∨ . . . ∨ Bn ],
where all literals A1 , . . . , Al , B1 , . . . , Bn are positive.
Disjunction at the righthand side of implication causes
serious complexity problems.
Andrzej Szalas
Slide 75 of 226
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.
Rule
6
7
Subformula
(A ∧ B) ∨ C
C ∨ (A ∧ B)
Andrzej Szalas
Replaced by
(A ∨ C ) ∧ (B ∨ C )
(C ∨ A) ∧ (C ∨ B)
Slide 76 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Example
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Applications of CNF
(¬fastFood ∧ ¬restaurant) ∨ (walk ∧ park)
←→
(¬restaurant ∨ (walk ∧ park))
(¬fastFood ∨ walk) ∧ (¬fastFood ∨ park)∧
(¬restaurant ∨ walk) ∧ (¬restaurant ∨ park)
←→
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
(7)
tautology checking.
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.
Examples:
1
2
(p ∨ q ∨ ¬p) ∧ (p ∨ ¬q ∨ r ∨ q) is a tautology
(p ∨ q ∨ ¬p) ∧ (p ∨ ¬q ∨ r ) is not a tautology.
Slide 77 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
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.
The empty clause is equivalent to F.
Andrzej Szalas
logic programming and deductive databases
(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.
rule-based reasoning and expert systems
(6)
Slide 79 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 78 of 226
Lecture I: introduction
Lecture II: deductive systems
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
In the book an abbreviated notation is used:
L̄ M1 . . . Ml
L1 . . . Lk−1 L,
L1 . . . Lk M1 . . . Ml
and duplicates in the result are assumed to be removed. We
will formulate this principle as a separate rule called (fctr ).
Andrzej Szalas
Slide 80 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Examples
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Factorization rule for propositional calculus
Factorization rule, denoted by (fctr ):
Remove from a clause all repetitions of literals.
John sleeps ∨ John works,
John sleeps ∨ John doesn’t work
John sleeps
Example
¬Q ∨ S ∨ T
P ∨ Q,
P ∨S ∨T
P ∨ P ∨ ¬Q ∨ P ∨ ¬Q
P ∨ ¬Q
¬Q ∨ P,
S ∨T ∨Q
P ∨S ∨T
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Resolution rule preserves satisfiability, while factorization preserves
equivalence.
Slide 81 of 226
Andrzej Szalas
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Resolution method
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 82 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example
The method, where formula A is to be proved
1
2
transform ¬A into the conjunctive normal form
try to derive the empty clause F 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.
Soundness and completeness
Resolution method is sound: deriving F for ¬A proves that A is
a tautology. It is complete: if a formula A is a tautology then there
is a derivation of F using the resolution method.
Andrzej Szalas
Slide 83 of 226
Prove that formula [(A ∨ B) ∧ (¬A)] → B is a tautology:
1
2
negate: (A ∨ B) ∧ (¬A) ∧ ¬B – this formula is in the Cnf
obtaining the empty clause F:
1.
2.
3.
4.
5.
A∨B
¬A
¬B
B
F
the first clause
the second clause
the third clause
(res): 1, 2
(res): 3, 4
Andrzej Szalas
Slide 84 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
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
Predicate calculus
Other topics
Slide 86 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example continued
Translation of the considered sentences
1 (¬ir ) → (ge ∨ un)
3
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example continued
Slide 85 of 226
Example continued
2
Introduction & propositional calculus
Predicate calculus
Other topics
(¬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 87 of 226
Andrzej Szalas
Cnf:
[ir ∨ ge ∨ un]
∧ [ge ∨ tx]
∧ [¬tx ∨ ir ∨ ¬un]
∧ ¬ir
∧ ¬ge
Slide 88 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example continued
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Example continued
The second task (do (1), (2) and (4) imply (3)?)

[(¬ir ) → (ge ∨ un)] 
∧ [(¬ge) → tx]
→ [(tx ∧ ¬ir ) → ¬un]

∧ [(¬ir ) → ge]
Proof of the first implication
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Introduction & propositional calculus
Predicate calculus
Other topics
ir ∨ ge ∨ un
ge ∨ tx
¬tx ∨ ir ∨ ¬un
¬ir
¬ge
¬tx ∨ ¬un
ge ∨ ¬un
ge ∨ un
ge ∨ ge
ge
F
Negated
(res) : 3, 4
(res) : 2, 6
(res) : 1, 4
(res) : 7, 8
(fctr ) : 9
(res) : 5, 10
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
[ir ∨ ge ∨ un]
∧ [ge ∨ tx]
∧ [ir ∨ ge]
∧ tx
∧ ¬ir
∧ un
No matter how (res) and (fctr ) are applied, F cannot be derived.
[(¬ir ) → (ge ∨ un)]
∧ [(¬ge) → tx]
∧ [(¬ir ) → ge]
Cnf:
∧ [tx ∧ ¬ir ]
∧ un
Slide 89 of 226
Lecture I: introduction
Lecture II: deductive systems
Lecture III: resolution
Summary
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 90 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Quantifiers
In the classical logic we have two quantifiers:
negation normal form
conjunctive and clausal normal form
Horn clauses
resolution and factorization rules
resolution method.
Andrzej Szalas
Slide 91 of 226
the existential quantifier
“there exists an individual x such that ...”,
denoted by ∃x
the universal quantifier
“for all individuals x ...”,
denoted by ∀x.
Andrzej Szalas
Slide 92 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
1
It is important that variables under quantifiers represent
individuals. In fact, we have the following hierarchy of logics:
“Everybody loves somebody”:
“Relation R is reflexive”:
0
zero-order logic (propositional), where we do not allow neither
variables representing domain elements nor quantifiers
1
first-order logic, where we allow variables representing domain
elements and quantifiers over domain elements (in this case
quantifiers are called first-order quantifiers)
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),
3
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)
4
etc.
∀x R(x, x)
3
“Relation R is symmetric”:
∀x∀y R(x, y ) → R(y , x)
4
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
A hierarchy of logics
∀x∃y loves(x, y )
2
Introduction & propositional calculus
Predicate calculus
Other topics
“Relation R is transitive”:
∀x∀y ∀z ((R(x, y ) ∧ R(y , z)) → R(x, z))
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 93 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Higher-order formulas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 94 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Syntax of predicate calculus
Examples
1
“To like is to be pleased with”: likes → pleased
– a formula of the zero-order logic
2
“John likes everybody”: ∀x likes(John, x)
– a formula of the first-order logic
3
“John has no relationships with anybody”: ¬∃R∃x R(John, x)
– a formula of the 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 the third-order logic.
Andrzej Szalas
Andrzej Szalas
Slide 95 of 226
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
Slide 96 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
The scope of quantifiers
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 97 of 226

the scope of ∃y
z
}|

{



∀x 
R(x) ∨ ∃y R(x) → S(x, y ) 



|
}

the scope of ∃y
}|
{





∀x R(x) ∨ ∃y ∃x R(x) → T (x, y , z) 


{z
}
|
the scope of ∃x
|
{z
}
the scope of ∀x

z
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Semantics of predicate calculus
{z
the scope of ∀x
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 98 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
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
Slide 99 of 226
hN , {≤}, {0}i, hN , {≥}, {3}i, hN , {>}, {1}i,
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, ∀x[0 ≤ x]).
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
Slide 100 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Semantics of predicate calculus
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Semantic analysis: examples
Semantics
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
Formula ∀x∀y [p(x, y ) → p(y , x)] is T, e.g., in an
interpretation, where p is assigned the relation = and is F in
an interpretation, where p is assigned the relation parent
between persons.
let A = p(c1 , . . . , cn ) be an atomic formula, where each ci is
either a variable xi or a constant ai . vσI (A) = T iff
(d1 , . . . , dn ) ∈ R, where R is the relation assigned by I to p
and di ∈ D is assigned to ci either by I (if ci is a constant) or
by σI (if ci is a variable)
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 ≤ and is F 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
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
Predicate calculus
Other topics
Slide 101 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Restricted quantifiers
2
3
4
“all P’s are Q’s”
i.e., all individuals 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
“no P’s are Q’s”
i.e., no individuals satisfying P satisfy Q
“some P’s are not Q’s”
i.e., some individuals satisfying P do not satisfy Q.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 102 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Aristotelian forms
Aristotelian forms
The four Aristotelian forms of quantification are:
1
Andrzej Szalas
Slide 103 of 226
Examples
1
“All students have to learn.”
2
“Some students have jobs.”
3
“No students are illiterate.”
4
“Some students do not like math.”
Translation of Aristotelian forms into quantified formulas
1
2
3
4
“all P’s are Q’s” translates into ∀x [P(x) → Q(x)]
“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)].
Andrzej Szalas
Slide 104 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
1
Introduction & propositional calculus
Predicate calculus
Other topics
Translating natural language sentences
“All students have to learn” translates into:
We integrate information from two sources:
1 vocabulary (words in the sentence); here we get:
∀x [student(x) → hasToLearn(x)]
2
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.
“Some students work” translates into:
∃x [student(x) ∧ hasJob(x)]
3
“No students are illiterate” translates into:
∀x [student(x) → ¬illiterate(x)]
4
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
2
syntactic structure of the sentence; here we get:
“Some students do not like math” translates into:
knowledge about logical operators appearing in the sentence,
like connectives and quantifiers
knowledge how to combine constants, variables, concepts and
other relations.
∃x [student(x) ∧ ¬likes(x, math)]
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 105 of 226
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 106 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
DeMorgan’s laws for quantifiers
DeMorgan laws for quantifiers are:
1
“Eve is a student”
constants: Eve, variables: none
concepts: student
other relations: none.
2
Translation: student(Eve).
“Eve is the best student”
constants: Eve, variable: x (needed in quantification)
concepts: student
other relations: two-argument relation betterStudent.
Translation:
student(Eve) ∧ ¬∃x[student(x) ∧ betterStudent(x, Eve)]
Andrzej Szalas
Slide 107 of 226
[¬∀x A(x)] ↔ [∃x ¬A(x)]
[¬∃x A(x)] ↔ [∀x ¬A(x)]
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 ∀z [friend(x, y ) ∧ likes(y , z)]
is equivalent to ∃x∀y ∃z ¬[friend(x, y ) ∧ likes(y , z)].
4
What is the negation of “Everybody loves somebody” and
of “Everybody loves somebody sometimes”?
Andrzej Szalas
Slide 108 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Analogies between quantifiers and propositional
connectives
“For all individuals x relation R(x) holds” is equivalent to
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:
∀x ∈ U [R(x)] ↔ [R(u1 ) ∧ R(u2 ) ∧ R(u3 ) ∧ . . .]
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
2
3
4
2
2
∀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)].
∀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)]
However observe that:
1
2
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:
∃x ∈ U [R(x)] ↔ [R(u1 ) ∨ R(u2 ) ∨ R(u3 ) ∨ . . .]
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 110 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Tableaux
Pushing quantifiers past connectives:
1
Similarly, “Exists an individual x such that relation R(x) holds” is
equivalent to
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Null quantification.
Assume variable x is not free in formula P. Then:
1
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Analogies between quantifiers and propositional
connectives
Slide 109 of 226
Other laws for quantifiers
1
Introduction & propositional calculus
Predicate calculus
Other topics
∀x[P(x) ∨ Q(x)] is not equivalent to ∀x[P(x)] ∨ ∀x[Q(x)]
γ and δ formulas
γ
∀x A(x)
¬∃x A(x)
γ(a)
A(a)
¬A(a)
δ
∃x A(x)
¬∀x A(x)
δ(a)
A(a)
¬A(a)
Semantic tableau
A semantic tableau for formula A is a tree T each node of which is
labeled with a set of formulas. The tableau construction extends
the construction given for propositional calculus (see slides 50 –
54).
∃x[P(x) ∧ Q(x)] is not equivalent to ∃x[P(x)] ∧ ∃x[Q(x)]
Andrzej Szalas
Slide 111 of 226
Andrzej Szalas
Slide 112 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Tableaux
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Soundness and completeness
Construction of a semantic tableau for formula A
Initially T consists of a single node labeled with {A}. Until
possible choose an unmarked leaf l labeled with U(l ) and apply:
if U(l ) contains a pair of complementary literals
{p(a1 , . . . , ak ), ¬p(a1 , . . . , ak ))} then mark the leaf closed
if U(l ) does not contain a pair of complementary literals and
contains non-literals, choose a non-literal A ∈ U(l )
if A is an α or β formula, apply rules provided in slide 54
if A is a γ formula, create a child node l ′ for l and label l ′ with
U(l ′ ) = U(l) ∪ {γ(a)}, where a preferably is a constant
appearing in U(l).
If U(l) consists of literals and γ formulas only and for all
choices of a, U(l) = U(l ′ ) then mark the leaf as open
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
Predicate calculus
Other topics
Closed and open branches
A branch in a tableau is closed if it terminates in a leaf marked
closed. Otherwise (it is infinite or terminates in a leaf marked
open), the branch is open.
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 113 of 226
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Example
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 114 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Summary
Proof of ∀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[p(x) ∧ q(x)], ¬p(a)
∀x[p(x) ∧ q(x)], ¬q(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 115 of 226
quantifiers, the scope of a quantifier
free and bound variables
syntax and semantics of predicate calculus
restricted quantifiers
translating natural language into predicate calculus
laws for quantifiers
tableaux.
Andrzej Szalas
Slide 116 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
The Gentzen system G
where it is assumed that the empty disjunction is F and the
empty conjunction is T.
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Rules
There is a close correspondence between Gentzen system and
tableaux. It is explored in the book by Ben Ari. Here we follow the
original style of presentation of G.
We define sequent calculus for the predicate calculus by accepting
axioms and rules as given for propositional calculus in slides 58 –
67. We have to provide rules for quantifiers.
Recall that 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 ,
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 117 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Example
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, ∀x C (x), D, C (a)
where, in application of (∀r ), a is a fresh constant.
Existential 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, ∃x C (x), D, C (a)
where, in application of (∃l ), a is a fresh constant.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 118 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Soundness and completeness
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), ∀x Q(x), Q(a)
∀x[P(x) ∨ Q(x)] ⇒ ∃x P(x), ∀x Q(x), Q(a), P(a)
∀x[P(x) ∨ Q(x)], P(a) ∨ Q(a) ⇒ ∃x P(x), ∀x Q(x), Q(a), P(a)
Now applying (∨l ) creates two leaves:
∀x[P(x) ∨ Q(x)], P(a) ⇒ ∃x P(x), ∀x Q(x), Q(a), P(a)
∀x[P(x) ∨ Q(x)], Q(a) ⇒ ∃x P(x), ∀x Q(x), Q(a), P(a),
Soundness
The provided Gentzen proof system G is sound: if all leaves of
a derivation tree of ∅ ⇒ A are axioms then A is a tautology.
Completeness
G is complete: if A is a tautology then there is a derivation tree for
∅ ⇒ A with all leaves containing axioms.
each containing an axiom.
Andrzej Szalas
Slide 119 of 226
Andrzej Szalas
Slide 120 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
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.
Translation into logic
Assumptions:
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
Predicate calculus
Other topics
Slide 121 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
The Hilbert system H for predicate calculus
We extend the proof system H defined in slide 48 for propositional
calculus by adding axioms:
[∀x A(x)] → A(a)
∀x[A → B(x)] → [A → ∀x B(x)], provided that x is not free
in A
and the inference rule reflecting generalization:
⊢ A(a)
.
⊢ ∀x A(x)
Note that in presence of assumptions U, this rule is formulated as
U ⊢ A(a)
,
U ⊢ ∀x A(x)
where a does not appear in U.
Andrzej Szalas
Slide 123 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Example of practical reasoning
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 122 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Some properties of H
Deduction theorem
The following rule can be derived, where A contains no free
variables:
U ∪ {A} ⊢ B
.
U⊢A→B
Soundness
The proof system H is sound, i.e., any formula of predicate
calculus provable in H is a tautology.
Completeness
The proof system H is complete, i.e., any tautology of predicate
calculus is provable in H.
Andrzej Szalas
Slide 124 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
2
3
2
3
Proof of ∀x[A(x) → B(x)] → [∀x A(x) → ∀x B(x)]
⊢ ∀x¬A(x) → ¬A(a)
(axiom)
(PC)
2
⊢ A(a) → ∃xA(x)
(deMorgan, PC)
3
⊢ A(a) → ¬∀x¬A(x)
1
4
Proof of ∀x A(x) → ∃x A(x)
1
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
Proof of A(a) → ∃x A(x)
1
Introduction & propositional calculus
Predicate calculus
Other topics
⊢ ∀x A(x) → A(a)
⊢ A(a) → ∃x A(x)
⊢ ∀x A(x) → ∃x A(x)
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
5
(axiom)
6
(proof above)
7
(generalization).
8
∀x[A(x) → B(x)], ∀x A(x) ⊢ ∀x A(x)
∀x[A(x) → B(x)], ∀x A(x) ⊢ A(a)
(axiom)
∀x[A(x) → B(x)], ∀x A(x) ⊢ ∀x[A(x) → B(x)] (assumption)
∀x[A(x) → B(x)], ∀x A(x) ⊢ A(a) → B(a)
∀x[A(x) → B(x)], ∀x A(x) ⊢ B(a)
(axiom)
(PC)
∀x[A(x) → B(x)], ∀x A(x) ⊢ ∀x B(x)
(generalization)
∀x[A(x) → B(x)] ⊢ ∀x A(x) → ∀x B(x)
(deduction)
⊢ ∀x[A(x) → B(x)] → [∀x A(x) → ∀x B(x)]
Slide 125 of 226
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
(assumption)
Introduction & propositional calculus
Predicate calculus
Other topics
(deduction).
Slide 126 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
Derived rule: generalization 1
Using modus ponens and the reasoning from slide 126, we have
the following derived rule:
⊢ A(x) → B(x)
.
⊢ ∀x A(x) → ∀x B(x)
Proof of ∃x∀y A(x, y ) → ∀y ∃xA(x, y )
1
2
3
4
5
6
7
Andrzej Szalas
Slide 127 of 226
⊢ A(a, b) → ∃x A(x, b)
(proved)
⊢ ∀y A(a, y ) → ∀y ∃x A(x, y )
(generalization 1)
⊢ ¬∀y ∃x A(x, y ) → ¬∀y A(a, y )
(PC)
⊢ ∀x[¬∀y ∃x A(x, y ) → ¬∀y A(x, y )]
⊢ ¬∀y ∃xA(x, y ) → ∀x¬∀y A(x, y )
⊢ ¬∀x¬∀y A(x, y ) → ∀y ∃xA(x, y )
(generalization)
(axiom)
(PC)
⊢ ∃x∀y A(x, y ) → ∀y ∃xA(x, y )
Andrzej Szalas
Slide 128 of 226
(deMorgan).
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Summary
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
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:
Q1 x1 Q2 x2 . . . Qn xn [A(x1 , x2 , . . . , xn )],
Gentzen proof system G.
where n ≥ 0, Q1 , Q2 , . . . , Qn are quantifiers (∀, ∃) and A is
quantifier-free.
Hilbert proof system H.
Examples
1
2
3
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Subformula
Qx A(x), A(x) without variable z
∀x A(x) ∧ ∀x B(x)
∃x A(x) ∨ ∃x B(x)
A ∨ Qx B, where A contains no x
A ∧ Qx B, where A contains no x
Slide 131 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 130 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Example
Replace subformulas according to the table below, until Pnf
is obtained, where Q denotes any quantifier, ∀ or ∃.
Andrzej Szalas
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
Any predicate formula can be equivalently transformed into the
Pnf
1 Transform the formula into Nnf
Rule
12
13
14
15
16
∀x∃y [A(x) ∧ B(x, y ) ∧ ¬C (y )] is in Pnf
Slide 129 of 226
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 132 of 226
(12)
←→
(15)
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Functions and terms
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
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.
Standard notation: name(expr1 , . . . , exprn ) denotes a function
value, where name is a function name and expr1 , . . . , exprn are
function arguments. The number of arguments is called the arity
of the function. 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.
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.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
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);
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.
4
Slide 133 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Functions and terms
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 134 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Semantics
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 list
::= term, term list
for any p ∈ P.
atomic formula ::= p(term list)
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. 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 .
Examples
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)).
Andrzej Szalas
Slide 135 of 226
Andrzej Szalas
Slide 136 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Semantics
1
vσI (ai ) = di
2
vσI (x) = σI (x), where x ∈ V
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:
vσI (fi (t1 , . . . , tn )) = Fi (vσI (t1 ), . . . , vσI (tn )).
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.
For atomic formulas:
vσI (pi (t1 , . . . , tn )) = T iff (vσI (t1 ), . . . , vσI (tn )) ∈ Ri .
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 137 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Skolem normal form
2
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 138 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Generalizing resolution to predicate calculus
Consider the following two formulas:
Example
1
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Skolem normal form
Let t be a term, I an interpretation and σI an assignment. The
value of t under σI , denoted by vσI (t) is defined by
3
Introduction & propositional calculus
Predicate calculus
Other topics
∀x [rare(x) → expensive(x)]
∀y [expensive(y ) → guarded(y )]
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 is satisfiable iff its Skolem normal form is satisfiable.
Andrzej Szalas
Slide 139 of 226
Clause form:
¬rare(x) ∨ expensive(x)
¬expensive(y ) ∨ guarded(y )
Can we apply (res)? NO! Because “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 140 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Generalizing resolution to predicate calculus
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Unification
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.
Consider:
¬rare(x) ∨ expensive(x)
rare(VermeerPainting )
Examples
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.
1
2
3
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 141 of 226
Expressions father (x) and mother (father (John)) cannot be
unified.
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Expression trees
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 142 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
The unification algorithm
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
x
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
h
y
f
v
Slide 143 of 226
1
2
3
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
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)
z
In order to unify expressions we have to detect nonidentical
sub-trees and try to make them identical.
Andrzej Szalas
Input: expressions e, e ′
Output: substitution of variables which makes e and e ′ identical
or inform that such a substitution does not exist.
4
change the trees, according to the substitution determined in
the previous step and repeat from step 2.
Andrzej Szalas
Slide 144 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Resolution rule for the predicate calculus
′
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
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 145 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Factorization rule for the predicate calculus
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 )
Andrzej Szalas
Slide 147 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Examples
Resolution rule, denoted by (res), is formulated for first-order
clauses as follows:
L1 (t¯1 ) ∨ . . . ∨ Lk−1 (t̄k−1 ) ∨ Lk (t̄k )
¬Lk (t¯k′ ) ∨ M1 (s̄1 ) ∨ . . . ∨ Ml (s̄l )
Introduction & propositional calculus
Predicate calculus
Other topics
(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
Predicate calculus
Other topics
Slide 146 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Example of proof by resolution
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
Slide 148 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Example of proof by resolution
Example of proof by resolution
We consider implication:
Proof
1 ¬med (x) ∨ ¬attends(x, y ) ∨ likes(x, y ) ∨ obliged (x, y )
∆ → obliged (John, math)
2
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).
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
3
med (John)
4
attends(John, math)
5
¬obliged(John, math)
6
¬med (x) ∨ ¬attends(x, math) ∨ ¬med(x) ∨ obliged (x, math)
(res): 1, 2 with y = math
7
¬med (x) ∨ ¬attends(x, math) ∨ obliged(x, math) (fctr ): 6
8
¬attends(John, math) ∨ obliged(John, math) (res): 3, 7 with
x = John
9
obliged (John, math) (res): 4, 8
10
F
(res): 5, 9.
Andrzej Szalas
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 150 of 226
Lecture IV: introduction & tableaux
Lecture V: deductive systems
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))).
We start with negating the above implication, transforming it to
the clausal form and then try to derive F.
2
¬likes(x, math) ∨ ¬med(x)
3
Slide 149 of 226
Example
1
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
P(a, x ′ , x ′ )
– for clarity x is renamed
1
¬P(x, y , z) ∨ P(f (x), y , f (z))
2
¬P(f (a), z, f (f (a)))
(x ′ ))
4
P(f
(a), x ′ , f
5
F
– (res): 3, 4 with x ′ = z = f (a)
– (res): 1, 2 with x = a, y =
Andrzej Szalas
Prove that ∀x∀y [P(x, y ) ∨ P(a, y )] implies ∃x∀yP(x, y )
We start with negating the above implication, transforming it to
the clausal form and then try to derive F.
Slide 151 of 226
x ′, z
=
x′
P(x, y ) ∨ P(a, y )
¬P(x ′ , g (x ′ ))
3
P(a, y )
4
F
– g is a Skolem function and x is renamed
– (fctr ): 1 with x = a
– (res) with x ′ = a and y = g (a).
Andrzej Szalas
Slide 152 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture IV: introduction & tableaux
Lecture V: deductive systems
Lecture VI: resolution
Summary
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
What is a database?
A database is any finite collection of related data.
Examples
prenex normal form
functions and terms
Skolem normal form
unification
resolution for predicate calculus
factorization for predicate calculus
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 153 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
A closer look at databases
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
Predicate calculus
Other topics
Slide 154 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
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
1
Representation in logic
an element
of a domain (universe)
a fact
a relation
an extensional database
= a collection of relations
+ formulas
Slide 155 of 226
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 156 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Introduction & propositional calculus
Predicate calculus
Other topics
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 157 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
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: modal and temporal logics
Lecture IX: repetition
Introduction & propositional calculus
Predicate calculus
Other topics
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 158 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Common assumptions
intensional databases











Integrity

constraints 








}|
z
Extensional
Database
s
◆
{
.....
✰
deduction mechanisms
✻
.....





✠






✴








❄
(
Andrzej Szalas










❪






■




Slide 159 of 226
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 160 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Datalog
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Atomic queries about facts
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.
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).
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
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).
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.
Slide 161 of 226
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Rules in Datalog
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 162 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Rules in Datalog
Rules in Datalog are expressed in the form of (a syntactic variant
of) Horn clauses:
R(Z̄ ):−R1 (Z̄1 ), . . . , Rk (Z̄k )
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 on the righthand side of
the rule (called the body of the rule).
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.
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
Slide 163 of 226
Andrzej Szalas
Slide 164 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example of Datalog facts and rules
Facts
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example of Datalog facts and rules – continued
Rules
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).
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
canSwim(X):- isA(X,fish).
canSwim(X):- lives(X,inWater).
Based on the above facts and rules, can one derive that:
Slide 165 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Datalog queries
1
a whale can swim?
2
a frog can swim?
3
a salmon can swim?
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 166 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example: authors database
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
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:
if a query contains variables, then the result consists of all
assignments of values to variables, making the query T.
A(N, Id ) means that the author whose name is N has its
identification number Id
T (Id, Ttl ) means that the author whose identification number
is Id is a (co-) author of the book entitled Ttl .
Examples
1
isA(X,mammal) returns all X’s stored as mammals
2
isA(X,mammal), can swim(X)
returns all mammals listed in the database that can swim.
Andrzej Szalas
Slide 167 of 226
Andrzej Szalas
Slide 168 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
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:
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
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
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 169 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Predicate logic as a query language
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 170 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example: train and bus connections
Assume we have relations:
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.
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 .
We define a new relation connected(p1 , p2 ) meaning that places p1
and p2 are connected by train/bus connections, perhaps indirectly
(changes of busses and trains might be necessary):
def
connected (p1 , p2 ) ↔ [bus(p1 , p2 ) ∨ train(p1 , p2 )∨
∃q(connected (p1 , q) ∧ connected (q, p2 ))].
Andrzej Szalas
Slide 171 of 226
Andrzej Szalas
Slide 172 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exam-like exercise
2
all events later than 2006-02-03, whose duration 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
Predicate calculus
Other topics
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: modal and temporal logics
Lecture IX: repetition
Queries
1 Event(N,D,U), D>‘2006-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 173 of 226
Exam-like exercise – continued
2
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
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
Predicate calculus
Other topics
Slide 175 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 174 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Summary
logical (deductive) database
extensional and intensional databases
integrity constraints
UNA, DCA and CWA
Datalog
querying deductive databases.
Andrzej Szalas
Slide 176 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Modal logics
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Modalities
Extensional and Intensional operators
Extensional operators allow to substitute equal by equal and
equivalent by equivalent. Intensional operators violate this
principle. Intensional operators give rise to so-called modal
operators (modalities, in short). Logics allowing such operators are
called modal logics and sometimes intensional logics.
Example
Consider the operator Knows(x, y ) meaning that person x knows
who is person y . Assume that ¬Knows(Jack, X ) and that
Knows(Jack, Mary ). Here we assume that X is a masked person.
It might, however, happen that Mary = X . If expression Knows
was extensional, one could then replace X by Mary and obtain
¬Knows(Jack, Mary ) leading to an obvious contradiction.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 177 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Readings of modalities
Boxes and diamonds
In the simplest case one deals with a single one-argument modality
def
and its dual ♦, i.e., ♦A ↔ ¬¬A.
Example
Suppose that the intended meaning of A is “A is sure”.
Then its dual, ♦A, is defined to be:
def
♦A ↔
⇔
⇔
⇔
⇔
¬¬A
¬“(¬A) is sure”
“(¬A) is not sure”
“(¬A) is doubtful”
“A is doubtful”
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 178 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Types of modal logics
Modalities and ♦ have many possible readings, dependent on
a particular application. The following table summarizes the most
frequent readings of modalities.
The types of modal logics reflect the possible readings of
modalities. The following table summarizes types of logics
corresponding to the possible readings of modalities.
a possible reading of A
a possible reading of ♦A
Reading of modalities
A is necessary
A is obligatory
always A
in the next time moment A
A is known
all program states satisfy A
A is provable
A is possible
A is allowed
sometimes A
in the next time momentA
A is believed
some program state satisfies A
A is not provable
necessary, possible
obligatory, allowed
always, sometimes, in the next time
known, believed
all (some) states of a program satisfy
(un)provable
Andrzej Szalas
Slide 179 of 226
Andrzej Szalas
Type of modal logic
aletic logics
deontic logics
temporal logics
epistemic logics
logics of programs
provability logics
Slide 180 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
How to chose/design a logic for a particular application
Recall that there are two approaches to defining logics, the
semantical and syntactical approach. In consequence there are two
approaches to choosing/defining modal logics suitable for a given
application:
1
2
syntactical approach, which depends on providing a set
of axioms describing the desired properties of modal operators
semantical approach, which starts with suitable models and
then develops syntactic characterization of modalities.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 181 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example: syntactical approach
Suppose we are interested in formalizing knowledge operator. One
can postulate, or instance, the following properties:
1
2
3
⊢ A → ♦A — if A is known then A is believed
⊢ A → A — if A is known then it actually holds
⊢ A → ♦A — if A holds then it is believed.
There are many important questions at this point, including:
are the properties consistent?
do the properties express all the desired phenomena?
is a property a consequence of another property?
Usually answers to such questions are given by semantic
investigations.
Andrzej Szalas
Slide 183 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
How to chose/design a logic for a particular application
The applications might, e.g., be:
temporal reasoning
understanding (fragments of) natural language
commonsense reasoning
specification and verification of software
understanding law and legal reasoning
etc.
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 182 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example: semantical approach
Consider temporal logic, where A means “always A” and ♦A
means “sometimes A”.
In order to define meaning of and ♦ we first have to decide what
is the time structure, e.g.,
consisting of points or intervals?
continuous or discrete?
linear or branching?
is there the earliest moment (starting point) or there is an
unbounded past?
is there the latest moment (end point) or there is an
unbounded future?
Andrzej Szalas
Slide 184 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example: semantical approach
-2
-1
0
1
2
...
Now “always A” and “sometimes A” can be more or less be
defined as follows:
“always A”
def
↔ ∀i [A is satisfied at time point i ]
def
“sometimes A” ↔ ∃i [A is satisfied at time point i ]
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 185 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Lemmon’s classification of modal logics
Some well-known axioms
D
T
4
E
def
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Lemmon’s classification of modal logics
D comes from deontic
def
⊢ A → A
E comes from Euclidean (it is often denoted by 5)
⊢ A → ♦A
M comes after McKinsey
⊢ ♦A → ♦A
Grz comes after Grzegorczyk
⊢ ((A → A) → A) → (♦A → A)
W comes from reverse well founded (it is also known as the
Löb axiom).
↔
↔
def
↔
M
W
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 186 of 226
T is a traditional name of the axiom (after Feys)
def
def
Dum
Andrzej Szalas
⊢ A → ♦A
def
Grz
Lemmon introduced a widely accepted classification of modal
logics, defined below.
The basis for Lemmon’s classification is the logic K.
K is defined to extend the classical propositional logic
by adding rules:
⊢ (A → B)
1 rule (K):
⊢ A → B
⊢A
2 rule (Gen):
⊢ A
Other normal modal logics are defined by additional axioms
expressing the desired properties of modalities.
↔
B
G
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Lemmon’s classification of modal logics
Assume that time is discrete and linear, with time points labeled
by integers, as in the figure below.
...
Introduction & propositional calculus
Predicate calculus
Other topics
↔
↔
def
↔
def
↔
def
↔
def
↔
⊢ A → A
4 is characteristic for logic S4 of Lewis
⊢ ♦A → ♦A
B comes after Brouwer
⊢ ♦A → ♦A
G comes after Geach
⊢ ((A → A) → A) → A
Dum comes after Dummett
⊢ (A → A) → A.
Andrzej Szalas
Slide 187 of 226
Andrzej Szalas
Slide 188 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Lemmon’s classification of modal logics
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Lemmon’s classification of modal logics
In Lemmon’s classification KX0 ...Xm denotes the logic extending
K in which formulas X0 , ..., Xm are accepted as axioms.
Some well-known modal logics
Some well-known modal logics
KT
KT4
KT4B
K4E
KD
KD4
KD4B
KTB
=
=
=
=
=
=
=
=
T = logic of Gödel/Feys/Von Wright
S4
KT4E = S5
K45
deontic T
deontic S4
deontic S5
Brouwer logic
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
KT4M
KT4G
KT4H
KT4Dum
KT4Grz
K4W
=
=
=
=
=
=
S4.1
S4.2
S4.3
D = Prior logic
KGrz = Grzegorczyk logic
KW = Löb logic.
Slide 189 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Kripke semantics for modal logics
Possible worlds
The basis for the Kripke semantics (in fact, similar semantics has
been defined a couple of years earlier by Kanger. Also, in the same
year, a similar semantics has been given by Hintikka and by
Guillaume) is the universe of possible worlds (states). Formulas are
evaluated in the so-called actual world. The other worlds,
alternatives to the actual world correspond to possible situations.
Modalities and ♦ have the following intuitive meaning:
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 190 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Kripke semantics for modal logics
?
A
A
❃
✿ A
♦A
...
s
❃
✿ A
...
s
A
formula A holds in a given world w , if A holds in all worlds
alternative for w
formula ♦A holds in a given world w , if A holds in some world
alternative for w .
Andrzej Szalas
Slide 191 of 226
Andrzej Szalas
Slide 192 of 226
?
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Example – continued
Consider the situation where one drops a coin twice.
The following Kripke structure describes all possible situations.
✯
H
✯
S❘
1
2
3
T
H
H = “head”
T = “tail”
S = “start”
q
T
✶H
❥
✯
H
✯
S
T
does ♦T hold?
does H hold?
does ♦♦H hold?
❘
H
H
q
T
✶ H
❥
T
What are answers to the same questions for the above structure?
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 193 of 226
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Commonsense implication
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 194 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Multimodal logics
Definition by Lewis
def
(A ֒→ B) ↔ (A → B)
In many applications one needs to introduce many modalities. In
such a case we have multimodal logics.
Examples
What modalities appear in the following sentences:
Example
“Sun is yellow” ֒→ “Jack lives in Linköping”
Possible worlds:
1
“When it rains one ought to take umbrella”.
2
“It is necessary that anyone should be allowed to have right to
vote”.
3
“If you know what I believe to, then you might be wiser than
myself”.
“Sun is yellow”, “Jack lives in Linköping”;
“Sun is yellow”, “Jack doesn’t live in Linköping”.
!
Here “Sun is yellow” → “Jack lives in Linköping” is not true,
so “Sun is yellow” ֒→ “Jack lives in Linköping” is not true, too.
Andrzej Szalas
Slide 195 of 226
Andrzej Szalas
Slide 196 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Temporal logics
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Temporal properties of programs
Invariance (safety) properties
Interpretation of , ♦
In temporal logics:
A is interpreted as “A always holds
♦A is interpreted as “A eventually holds.
Examples
(failure → alarm)
Introduction & propositional calculus
Predicate calculus
Other topics
(atFirst → p) → (atEnd → q) (partial correctness w.r.t
conditions p and q, where propositional variable atFirst is true
only at the beginning of the specified program, while atEnd is
true only when the program reaches its terminal state)
(¬q ∨ ¬p) (the program cannot enter critical regions p and
q simultaneously (mutual exclusion)).
(requestPrint → ♦print).
Andrzej Szalas
p → q (all states reached by a program after the state
satisfying p will satisfy q)
Slide 197 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Temporal properties of programs
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 198 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Models of time
Interpretations
We characterize time by interpretations hS, ρi, where
Eventuality properties
p → ♦q (there is a program state satisfying q reached by a
program after the state satisfying p)
(atFirst → p) → ♦(atEnd ∧ q) (total correctness w.r.t.
conditions p and q)
♦p → ♦q (repeating a request p will force a response q)
p → ♦q (permanent holding a request p will force a
response q).
S = {s1 , . . . , sn } is a set of states (worlds)
ρ is a binary relation on S; the intended meaning of ρ(s, s ′ ) is
that s ′ is a “future” of s. We often write s ′ ∈ ρ(s) to indicate
that ρ(s, s ′ ) holds.
Time is usually characterized semantically. Axioms reflect the
required properties.
Examples of correspondences between axioms and time structure
⊢ A → A – relation ρ is reflexive
⊢ A → A – relation ρ is transitive.
Andrzej Szalas
Slide 199 of 226
Andrzej Szalas
Slide 200 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Operator “nexttime”
s, τ |= A iff there is s ′ ∈ τ (s) such that s ′ , τ |= A.
We define ρ to be the reflexive and transitive closure of τ . In such
a case we have:
|= p → p
|= p → ♦p.
Linear time is characterized by axiom ⊢ A ↔ ¬ ¬A.
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Semantic tableaux
Assume we have a binary relation τ on states. The intended
meaning of s ′ ∈ τ (s) is that the state s ′ occurs in the next time
moment. The nexttime operator, denoted by is defined by
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
α-, β- and X -rules
We add the following rules to tableaux rules for classical
propositional calculus (recall that α-rules have a conjunctive flavor
and β-rules have a disjunctive flavor):
α
A
¬♦A
α1
A
¬A
α2
A
¬ ♦A
Semantic tableaux
β1
A
¬A
β2
♦A
¬ A
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 202 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
A problem
Building semantic tableaux
For classical propositional connectives and temporal α- and
β-formulas the construction is analogous to traditional tableau
rules.
If all formulas in a leaf l , beginning with or ¬, are:
A1 , . . . , Am , ¬ Am+1 , . . . , ¬ An ,
then create a new successor node containing formulas:
A tableau for p
p ✛
↓
p, p
6↓
p
A1 , . . . , Am , ¬Am+1 , . . . , ¬An
(observe that we do not include formulas being outside
of scope of or ¬).
Andrzej Szalas
Slide 203 of 226
X
A
¬A
The status of X -rules
X -rules are used to build the contents of the next node.
Slide 201 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
β
♦A
¬A
Andrzej Szalas
Slide 204 of 226
X1
A
¬A
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Introduction & propositional calculus
Predicate calculus
Other topics
Discussion
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Semantic tableaux – continued
Remark
Using the tableau from slide 204 one can construct a model
for p by transforming the cycle into an infinite branch. If
such a loop appears, one can stop the algorithm and answer
that the input formula is not a tautology.
To make this principle working we need to really make the
branch a model also when formulas of the form ♦p (or ¬p)
appear in the cycle. Namely, whenever such formula appears
in a node, there should be a “future” node containing p
(respectively, ¬p).
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 205 of 226
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Introduction & propositional calculus
Predicate calculus
Other topics
Completed and closed tableaux
′
Slide 207 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Definition
A semantic tableau is closed if all its leaves contain a formula and
its negation.
n contains ♦A then there is a node n
along the path and containing A
n contains ¬A then there is a node n′
along the path and containing ¬A.
Andrzej Szalas
Slide 206 of 226
Semantic tableaux: soundness and completeness
Definition
A semantic tableau is completed if:
– all its leaves contain a formula and its negation
or
– tableau rules do not create new nodes.
A path is called fulfilling if:
whenever a node
reachable from n
whenever a node
reachable from n
Building semantic tableaux: avoiding loops
Whenever the contents of a newly created successor node for node
l is the same as the contents of a node l ′ being an ancestor of l
then, rather then creating the new node, make l ′ a successor of l .
Soundness and completeness
A formula A is unsatisfiable iff there is a closed tableau for A with
all cycles unfulfilling.
Andrzej Szalas
Slide 208 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Semantic tableaux: example
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Semantic tableaux: example
(p ∧ q) → (p ∧ q)
!
¬ (p ∧ q) → (p ∧ q)
↓
(p ∧ q), ¬(p ∧ q)
ւ
ց
(p ∧ q), ¬ p
(p ∧ q), ¬ q
↓
↓
p ∧ q, ¬p
p ∧ q, ¬q
↓
↓
p, q, ¬p
p, q, ¬q
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
(p ∧ q) → p
!
¬ (p ∧ q) → p
↓
✛
(p ∧ q), ¬p
↓
p ∧ q, (p ∧ q), ¬p
↓
p, q, (p ∧ q), ¬p
ւ
ց
p, q, (p ∧ q), ¬p
p, q, (p ∧ q), ¬ p
6↓
(p ∧ q), ¬p
Slide 209 of 226
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Summary
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 210 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 1
modal operators (modalities)
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.
possible readings of modalities
frequently considered types of modal logics
Lemmon’s classification of modal logics
multi-modal logics
temporal logics
properties expressible by temporal formulas
Semantic tableaux for temporal logic of linear time.
Andrzej Szalas
Slide 211 of 226
Andrzej Szalas
Slide 212 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 1 - solution
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 1 - solution
Hypothesis
After a semantical considerations one can state the hypothesis that
the robot should go to the right (expressed by right).
Translation
(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
Predicate calculus
Other topics
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 213 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 2
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 214 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 2 - solution of 1
Consider a binary relation R.
1
Check semantically whether transitivity, symmetry and
seriality of R together imply reflexivity of R.
2
Check semantically whether transitivity, reflexivity and seriality
of R together imply symmetry of R.
3
Introduction & propositional calculus
Predicate calculus
Other topics
Prove your claims obtained in (1) and (2) syntactically using
chosen proof systems.
Definitions
R is reflexive iff ∀x[R(x, x)]
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
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 )].
Andrzej Szalas
Semantical check
Will be carried out during the lecture.
Slide 215 of 226
∀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 216 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 2 - solution of 1
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 2 - solution of 2
Semantical check
The answer is no. Will be carried out during the lecture.
Proof of 1
1.
2.
3.
4.
5.
6.
7.
8.
¬R(x, y ) ∨ ¬R(y , z) ∨ R(x, z)
¬R(x, y ) ∨ R(y , x)
R(x, f (x))
¬R(a, a)
¬R(f (x), z) ∨ R(x, z)
R(f (x), x)
R(x, x)
F
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Formulation of 2
(res) : 1, 3
(res) : 2, 3
(res) : 5, 6
(res) : 4, 8
with
with
with
with
y
y
z
x
= f (x)
= f (x)
=x
= a.
2
3
Proof of 2 by resolution - negated
∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)]
∀x[R(x, x)]
∀x∃y [R(x, y )]
∃x∃y [R(x, y ) ∧ ¬R(y , x)]
— to be continued during the lecture
Slide 217 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 3
1

∀x∀y ∀z[(R(x, y ) ∧ R(y , z)) → R(x, z)] 
∀x∀y [R(x, y ) →
∀x[R(x, x)]
→
R(y , x)]

∀x∃y [R(x, y )]
Andrzej Szalas
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 218 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 3 - solution
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.
Andrzej Szalas
Slide 219 of 226
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 220 of 226
→ blue(a)
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 3 - solution
Introduction & propositional calculus
Predicate calculus
Other topics
Exercise 3 - solution
Proof by resolution - negated
Clausal form
∀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
Introduction & propositional calculus
Predicate calculus
Other topics
1.
2.
3.
4.
5.
6.
7.
red(x) ∨ green(x) ∨ blue(x)
¬over (x, y ) ∨ ¬below (x, y )
¬red (x) ∨ ¬green(y ) ∨ over (x, y )
below (a, b)
green(b)
¬gren(a)
¬blue(a)
Slide 221 of 226
Andrzej Szalas
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 3 - solution
Introduction & propositional calculus
Predicate calculus
Other topics
Slide 222 of 226
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 4
1
Proof
8.
9.
10.
11.
12.
13.
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
red(a) ∨ green(a)
red(a)
¬over (a, b)
¬red (x) ∨ over (x, b)
over (a, b)
F
(res) : 1, 7 with: x = a
(res) : 6, 8
(res) : 2, 4 with: x = a, y = b
(res) : 3, 5 with: y = b
(res) : 9, 11 with: x = a
(res) : 10, 12
Andrzej Szalas
Slide 223 of 226
2
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
2
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 .
Andrzej Szalas
Slide 224 of 226
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 4 - solution
Introduction & propositional calculus
Predicate calculus
Other topics
Lecture VII: deductive databases
Lecture VIII: modal and temporal logics
Lecture IX: repetition
Exercise 4 - solution
Database design
Relations:
region(id, shape, size, color ) – id is a unique id of the region
intersects(id 1, id 2) – region id1 intersects region id 2.
Integrity constraint (ids are unique):
∀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 225 of 226
Queries
1 all pairs consisting of intersecting regions, first of which is
small and the second is round and green:
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 ).
aux(X , Y )
answer (X )
: − region(X , , ‘medium′ , ),
region(Y , , ‘large ′ , ), path(X , Y ).
: − aux(X , ).
Andrzej Szalas
Slide 226 of 226
Download