Knowledge Lecture 1: Lecture 2 · This leads to PROLOG as an efficient inference engine for...
Transcript of Knowledge Lecture 1: Lecture 2 · This leads to PROLOG as an efficient inference engine for...
Modeling the Dynamics ofKnowledge
Jürgen Dix and Wojtek Jamroga
Department of Computer ScienceClausthal University of Technology, Germany
ESSLLI(Dublin 2007)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 1/456
Lecture Overview
Lecture 1: Chapter 1: Basics about Knowledge.Lecture 2: Chapter 2: Answer Set Programming.Lecture 3: Chapter 3: Modal Logic.
Chapter 4: Logics of Action and Time (1).
Lecture 4: Chapter 4: Logics of Action and Time (2).Chapter 5: Knowledge in Flux.
Lecture 5: Chapter 6: Combining Knowledge and Time.Chapter 7: Modalities in Action.Chapter 8: Where the two frameworks meet.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 2/456
1. Basics about Logic
Chapter 1. Basics about Logic
Basics about Logic1.1 Why Logic?1.2 Sentential Logic (SL)1.3 Examples1.4 Calculi1.5 First-Order Logic (FOL)1.6 Logic Programming (LP)1.7 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 3/456
1. Basics about Logic
We make the case for using logics as a representationformalism for reasoning about the world.While almost everything can be done with logic, theformalization is often awkward and cumbersome. Weillustrate this with theWumpus world andSudoku-puzzles.We introduce two sorts of calculi for propositionallogics: a Hilbert type and a resolution calculus.We introduce first-order logic (FOL) and reconsider theWumpus world. The dynamics of the changing worldcan be modeled with the terms: they enable us toexplicitly denote the situation we are in and to reasonabout it: McCarthy's situation calculus.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 4/456
1. Basics about Logic
One of the main features is to ask queries of the formDφpxq to a theory T . We expect not just a “yes/no”answer, but an instantiation of the variable x. Thiscan be achieved with the resolution calculus for FOL.While resolution is much more efficientlyimplementable (compared to Hilbert-type calculi), thesearch space is still huge. Thus it was suggested torestrict resolution and apply it to a smaller class offormulae: Horn clauses.This leads to PROLOG as an efficient inference enginefor definite logic programs. However, fulldeclarativeness is lost and PROLOG is not (yet) theanswer: emphasis is put on computing answersubstitutions.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 5/456
1. Basics about Logic 1. Why Logic?
1.1 Why Logic?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 6/456
1. Basics about Logic 1. Why Logic?
Why logic at all?
framework for thinking about systems,makes one realise hidden assumptions,. . . and then we can:investigate them, accept or reject them,relax some of them and still use a part of theformal and conceptual machinery,
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 7/456
1. Basics about Logic 1. Why Logic?
Why logic at all?
verification: check specification againstimplementation,executable specification,
planning as model checking
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 8/456
1. Basics about Logic 1. Why Logic?
Symbolic AI: Symbolic representation,e.g. sentential or first order logic.Agent as a theorem prover.
Traditional: Theory about agents.Implementation as stepwise process(Software Engineering) over manyabstractions.
Symbolic AI: View the theory itself asexecutable specification.Internal state: Knowledge Base (KB),often simply called D (database).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 9/456
1. Basics about Logic 2. Sentential Logic (SL)
1.2 Sentential Logic (SL)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 10/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.1 (Sentential Logic LSL, Language L � LSL)
The language LSL of propositional (or sentential) logicconsists of
l and J: the constants falsum and verum,p,q,r,x1,x2, . . .xn, . . .: a countable set AT ofSL-constants, , ^, _,Ñ: the sentential connectives ( is unary, allothers are binary operators),p, q: the parentheses to help readability.
In most cases we consider only a finite set of SL-constants.They define a language L � LSL. The set of L-formulaeFmlL is defined inductively.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 11/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.2 (Semantics, Valuation, Model)
A valuation v for a language L � LSL is a mapping fromthe set of SL-constants defined by L into the setttrue, falseu with vplq � false, vpJq � true.Each valuation v can be uniquely extended to a functionv̄ : FmlL Ñ ttrue, falseu so that:
v̄p pq �"
true, if v̄ppq � false,false, if v̄ppq � true.
v̄pϕ^ γq �
"true, if v̄pϕq � true and v̄pγq � true,false, else
v̄pϕ_ γq �
"true, if v̄pϕq � true or v̄pγq � true,false, else
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 12/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition (continued)v̄pϕÑ γq �"
true, if v̄pϕq � false or (v̄pϕq � true and v̄pγq � trueq,false, else
Thus each valuation v uniquely defines a v̄. We call v̄L-structure.A structure determines for each formula if it is true or false.If a formula φ is true in structure v̄ we also say Av is amodel of φ. From now on we will speak of models,structures and valuations synonymously.
SemanticsThe process of mapping a set of L-formulae intottrue, falseu is called semantics.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 13/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.3 (Validity of a Formula, Tautology)
1 A formula ϕ P FmlL holds under thevaluation v if v̄pϕq � true. We also write v̄ |ù ϕ
or simply v |ù ϕ. v̄ is a model of ϕ.2 A theory is a set of formulae: T � FmlL . vsatisfies T if v̄pϕq � true for all ϕ� T . We writev |ù T .
3 A L-formula ϕ is called L-tautology if for allpossible valuations v in L v |ù ϕ holds.
From now on we suppress the language L, because it isobvious from context. Nevertheless it needs to be carefullydefined.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 14/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.4 (Consequence Set CnpT q)
A formula ϕ follows from T if for all models v ofT (i.e. v |ù T ) also v |ù ϕ holds. We write: T |ù ϕ.We call
CnLpT q �def tϕ P FmlL : T |ù ϕu,
or simply CnpT q, the semantic consequenceoperator.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 15/456
1. Basics about Logic 2. Sentential Logic (SL)
Lemma 1.5 (Properties of CnpT q)The semantic consequence operator has the followingproperties:1 T -extension: T �CnpT q,2 Monotony: T � T 1 ñ CnpT q �CnpT 1q,3 Closure: CnpCnpT qq �CnpT q.
Lemma 1.6 (ϕ R Cn(T))ϕ RCnpT q if and only if there is a model v with
v |ù T and v̄pϕq � false.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 16/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.7 (MOD(T), CnpUq)
If T � FmlL then we denote withMODpT q the set of allL-structures A which are models of T :
MODpT q �def tA : A |ù Tu.
If U is a set of models, we consider all those sentences,which are valid in all models of U. We call this set CnpUq:
CnpUq �def tϕ P FmlL : @v PU : v̄pϕq � trueu.
MOD is obviously dual to Cn:
CnpMODpT qq �CnpT q, MODpCnpT qq �MODpT q.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 17/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.8 (Completeness of a Theory T )
T is called complete if for each formula ϕ P Fml: T |ù ϕ orT |ù ϕ holds.
Attention:Do not mix up this last condition with the property of avaluation (model) v: each model is complete in theabove sense.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 18/456
1. Basics about Logic 2. Sentential Logic (SL)
Definition 1.9 (Consistency of a Theory)
T is called consistent if there is a valuation (model) v withv̄pϕq � true for all ϕ P T .
Lemma 1.10 (Ex Falso Quodlibet)T is consistent if and only if CnpT q � FmlL .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 19/456
1. Basics about Logic 3. Examples
1.3 Examples
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 20/456
1. Basics about Logic 3. Examples
Wumpus World
Breeze Breeze
Breeze
BreezeBreeze
Stench
Stench
BreezePIT
PIT
PIT
1 2 3 4
1
2
3
4
START
Gold�
Stench
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 21/456
1. Basics about Logic 3. Examples
A�
B�
G
P�
S
W�
= Agent = Breeze = Glitter, Gold
= Pit = Stench
= Wumpus
OK = Safe square
V�
= Visited
A�
OK
1,1 2,1 3,1 4,1
1,2 2,2 3,2 4,2
1,3 2,3 3,3 4,3
1,4 2,4 3,4 4,4
OKOKB
�
P?�
P?�
A�
OK OK
OK
1,1 2,1 3,1 4,1
1,2 2,2 3,2 4,2
1,3 2,3 3,3 4,3
1,4 2,4 3,4 4,4
V�
(a)�
(b)�
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 22/456
1. Basics about Logic 3. Examples
B�
B�
P!�
A�
OK OK
OK
1,1 2,1 3,1 4,1
1,2 2,2 3,2 4,2
1,3 2,3 3,3 4,3
1,4 2,4 3,4 4,4
V�
OK
W!�
V�
P!�
A�
OK OK
OK
1,1 2,1 3,1 4,1
1,2 2,2 3,2 4,2
1,3 2,3 3,3 4,3
1,4 2,4 3,4 4,4
V�
S
OK
W!�
V�
V�
V�
B�
S G
P?�
P?�
(b)(a)�
S
A�
B�
G
P�
S
W�
= Agent = Breeze = Glitter, Gold
= Pit = Stench
= Wumpus
OK = Safe square
V�
= Visited
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 23/456
1. Basics about Logic 3. Examples
Language definition:Si, j stenchBi, j breezePiti, j is a pitGli, j glittersWi, j contains Wumpus
General knowledge: S1,1 ÝÑ p W1,1^ W1,2^ W2,1q S2,1 ÝÑ p W1,1^ W2,1^ W2,2^ W3,1q S1,2 ÝÑ p W1,1^ W1,2^ W2,2^ W1,3q
S1,2 ÝÑ pW1,3_W1,2_W2,2_W1,1q
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 24/456
1. Basics about Logic 3. Examples
Knowledge after the 3rd move:
S1,1^ S2,1^S1,2^ B1,1^ B2,1^ B1,2
Question:Can we deduce that the wumpus is located at (1,3)?
Answer:Yes. Either via resolution or using a Hilbert-calculus.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 25/456
1. Basics about Logic 3. Examples
Problem:We want more: given a certain situation we would like todetermine the best action, i.e. to ask a query which givesus back such an action. This is impossible in SL: we canonly check for each action whether it is good or not andthen, by comparison, try to find the best action.
But we can check for each action if it should be done ornot. Therefore we need additional axioms:A1,1^East^W2,1 ÝÑ ForwardA1,1^East^Pit2,1 ÝÑ ForwardAi, j^Gli, j ÝÑ TakeGold
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 26/456
1. Basics about Logic 3. Examples
Breeze Breeze
Breeze
BreezeBreeze
Stench
Stench
BreezePIT
PIT
PIT
1 2 3 4
1
2
3
4
START
Gold�
Stench
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 27/456
1. Basics about Logic 3. Examples
Disadvantages
actions can only be guesseddatabase must be changed continuouslythe set of rules becomes very big becausethere are no variables
Using an appropriate formalisation (additionalaxioms) we can check if
KB $ action or KB $ action
But it can happen that neither one nor theother is deducible.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 28/456
1. Basics about Logic 3. Examples
Example 1.11 (CLIMA/Agent Contest)
A simple grid where agents are supposed tocollect gold. Maze-like environments. Differentroles of agents: scouts, collectors. Evaluatingand testing MAS.
2005: http://clima.deis.unibo.it/contest.html2006: http://cig.in.tu-clausthal.de/CLIMAContest/2007: http://cig.in.tu-clausthal.de/index.php?id=agentcontest07
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 29/456
1. Basics about Logic 3. Examples
Sudoku
Since some time, Sudoku puzzles are becomingquite famous.
Table 1: A simple Sudoku (S1)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 30/456
1. Basics about Logic 3. Examples
Can they be solved with sentential logic?
Idea: Given a Sudoku-Puzzle S, construct alanguage LSudoku and a theory TS � FmlLSudokusuch that
MODpTSq � Solutions of the puzzle S
Solution
In fact, we construct a theory TSudoku and foreach (partial) instance of a 9�9 puzzle S aparticular theory TS such that
MODpTSudoku Y TSq � tS : S is a solution of SuASP
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 31/456
1. Basics about Logic 3. Examples
We introduce the following language LSudoku:1 einsi, j, 1¤ i, j ¤ 9,2 zweii, j, 1¤ i, j ¤ 9,3 dreii, j, 1¤ i, j ¤ 9,4 vieri, j, 1¤ i, j ¤ 9,5 fuenfi, j, 1¤ i, j ¤ 9,6 sechsi, j, 1¤ i, j ¤ 9,7 siebeni, j, 1¤ i, j ¤ 9,8 achti, j, 1¤ i, j ¤ 9,9 neuni, j, 1¤ i, j ¤ 9.
This completes the language, the syntax.
How many symbols are these?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 32/456
1. Basics about Logic 3. Examples
We distinguished between the puzzle S and asolution S of it.What is a model (or valuation) in the sense ofDefinition 1.2?
Table 2: How to construct a model S?Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 33/456
1. Basics about Logic 3. Examples
We have to give our symbols a meaning: thesemantics!
einsi, j means i, j contains a 1zweii, j means i, j contains a 2
...neuni, j means i, j contains a 9
To be precise: given a 9�9 square that iscompletely filled out, we define our valuation vas follows (for all 1¤ i, j ¤ 9).
vpeinsi, jq �
"true, if 1 is at position pi, jq,false, else .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 34/456
1. Basics about Logic 3. Examples
vpzweii, jq �
"true, if 2 is at position pi, jq,false, else .
vpdreii, jq �
"true, if 3 is at position pi, jq,false, else .
vpvieri, jq �
"true, if 4 is at position pi, jq,false, else .
etc.
vpneuni, jq �
"true, if 9 is at position pi, jq,false, else .
Therefore any 9�9 square can be seen as amodel or valuation with respect to the languageLSudoku.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 35/456
1. Basics about Logic 3. Examples
How does TS look like?
TS � t eins1,4,eins5,8,eins6,6,zwei2,2,zwei4,8,
drei6,8,drei8,3,drei9,4,
vier1,7,vier2,5,vier3,1,vier4,3,vier8,2,vier9,8,...neun3,4,neun5,2,neun6,9,
u
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 36/456
1. Basics about Logic 3. Examples
How should the theory TSudoku look like (s.t.models of TSudokuYTS correspond to solutions of thepuzzle)?First square: T11 eins1,1 _ . . . _ eins3,32 zwei1,1 _ . . . _ zwei3,33 drei1,1 _ . . . _ drei3,34 vier1,1 _ . . . _ vier3,35 fuenf1,1 _ . . . _ fuenf3,36 sechs1,1 _ . . . _ sechs3,37 sieben1,1 _ . . . _ sieben3,38 acht1,1 _ . . . _ acht3,39 neun1,1 _ . . . _ neun3,3
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 37/456
1. Basics about Logic 3. Examples
The formulae on the last slide are saying, that1 The number 1must appear somewhere in thefirst square.
2 The number 2must appear somewhere in thefirst square.
3 The number 3must appear somewhere in thefirst square.
4 etcDoes that mean, that each number 1, . . . , 9occurs exactly once in the first square?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 38/456
1. Basics about Logic 3. Examples
No! We have to say, that each number occursonly once:
T 11:1 peinsi, j ^ zweii, jq, 1¤ i, j ¤ 3,2 peinsi, j ^ dreii, jq, 1¤ i, j ¤ 3,3 peinsi, j ^ vieri, jq, 1¤ i, j ¤ 3,4 etc5 pzweii, j ^ dreii, jq, 1¤ i, j ¤ 3,6 pzweii, j ^ vieri, jq, 1¤ i, j ¤ 3,7 pzweii, j ^ fuenfi, jq, 1¤ i, j ¤ 3,8 etcHow many formulae are these?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 39/456
1. Basics about Logic 3. Examples
Second square: T21 eins1,4 _ . . . _ eins3,62 zwei1,4 _ . . . _ zwei3,63 drei1,4 _ . . . _ drei3,64 vier1,4 _ . . . _ vier3,65 fuenf1,4 _ . . . _ fuenf3,66 sechs1,4 _ . . . _ sechs3,67 sieben1,4 _ . . . _ sieben3,68 acht1,4 _ . . . _ acht3,69 neun1,4 _ . . . _ neun3,6
And all the other formulae from the previousslides (adapted to this case): T 1
2
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 40/456
1. Basics about Logic 3. Examples
The same has to be done for all 9 squares.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 41/456
1. Basics about Logic 3. Examples
What is still missing:
Rows: Each row should contain exactly thenumbers from 1 to 9 (no numbertwice).
Columns: Each column should contain exactlythe numbers from 1 to 9 (no numbertwice).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 42/456
1. Basics about Logic 3. Examples
First Row: TRow 11 eins1,1 _ eins1,2 _ . . . _ eins1,9
2 zwei1,1 _ zwei1,2 _ . . . _ zwei1,9
3 drei1,1 _ drei1,2 _ . . . _ drei1,9
4 vier1,1 _ vier1,2 _ . . . _ vier1,9
5 fuenf1,1 _ fuenf1,2 _ . . . _ fuenf1,9
6 sechs1,1 _ sechs1,2 _ . . . _ sechs1,9
7 sieben1,1 _ sieben1,2 _ . . . _ sieben1,9
8 acht1,1 _ acht1,2 _ . . . _ acht1,9
9 neun1,1 _ neun1,2 _ . . . _ neun1,9
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 43/456
1. Basics about Logic 3. Examples
Analogously for all other rows, eg.Ninth Row: TRow 91 eins9,1 _ eins9,2 _ . . . _ eins9,92 zwei9,1 _ zwei9,2 _ . . . _ zwei9,93 drei9,1 _ drei9,2 _ . . . _ drei9,94 vier9,1 _ vier9,2 _ . . . _ vier9,95 fuenf9,1 _ fuenf9,2 _ . . . _ fuenf9,96 sechs9,1 _ sechs9,2 _ . . . _ sechs9,97 sieben9,1 _ sieben9,2 _ . . . _ sieben9,98 acht9,1 _ acht9,2 _ . . . _ acht9,99 neun9,1 _ neun9,2 _ . . . _ neun9,9
Is that sufficient? What if a row containsseveral 1's?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 44/456
1. Basics about Logic 3. Examples
First Column: TColumn 11 eins1,1 _ eins2,1 _ . . . _ eins9,12 zwei1,1 _ zwei2,1 _ . . . _ zwei9,13 drei1,1 _ drei2,1 _ . . . _ drei9,14 vier1,1 _ vier2,1 _ . . . _ vier9,15 fuenf1,1 _ fuenf2,1 _ . . . _ fuenf9,16 sechs1,1 _ sechs2,1 _ . . . _ sechs9,17 sieben1,1 _ sieben2,1 _ . . . _ sieben9,18 acht1,1 _ acht2,1 _ . . . _ acht9,19 neun1,1 _ neun2,1 _ . . . _ neun9,1
Analogously for all other columns.
Is that sufficient? What if a column containsseveral 1's?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 45/456
1. Basics about Logic 3. Examples
All put together:
TSudoku � T1YT 11 Y . . . Y T9YT 1
9TRow 1Y . . .YTRow 9TColumn 1Y . . .YTColumn 9
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 46/456
1. Basics about Logic 3. Examples
Here is a more difficult one.
Table 3: A difficult Sudoku Sdifficult
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 47/456
1. Basics about Logic 4. Calculi
1.4 Calculi
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 48/456
1. Basics about Logic 4. Calculi
A general notion of a certain sort of calculi.
Definition 1.12 (Hilbert-Type Calculi)
A Hilbert-Type calculus over a language L is a pairxAx,Infy where
Ax: is a subset of FmlL , the set of well-formedformulae in L: they are called axioms,
Inf: is a set of pairs written in the formφ1,φ2, . . . ,φn
ψ
where φ1,φ2, . . . ,φn,ψ are L-formulae: they arecalled inference rules.
Intuitively, one can assume all axioms as “true formulae”(tautologies) and then use the inference rules to deriveeven more new formulae.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 49/456
1. Basics about Logic 4. Calculi
We now define a particular instance of our general notion.
Definition 1.13 (Calculus for Sentential Logic SL)
We define HilbertSLL � xAxSL
L ,tMPuy, the Hilbert-Typecalculus, as follows. The underlying language is L � LSLwith the wellformed formulae FmlL as defined inDefinition 1.1.Axioms in SL (AxSL
L ) are the following formulae:1 φÑJ, lÑ φ, JÑl, lÑ J,2 pφ^ψq Ñ φ, pφ^ψq Ñ ψ,3 φÑ pφ_ψq, ψÑ pφ_ψq,4 φÑ φ, pφÑ ψq Ñ ppφÑ ψq Ñ φq,5 φÑ pψÑ φq, φÑ pψÑ pφ^ψqq.
φ,ψ stand for arbitrarily complex formulae (not just constants). Theyrepresent schemata, rather than formulae in the language.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 50/456
1. Basics about Logic 4. Calculi
Definition (continued)
The only inference rule in SL ismodus ponens:
MP : Fml�Fml Ñ Fml : pϕ,ϕÑ ψq ÞÑ ψ.
or short
(MP)ϕ, ϕÑ ψ
ψ.
(ϕ,ψ are arbitrarily complex formulae).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 51/456
1. Basics about Logic 4. Calculi
Definition 1.14 (Proof)
A proof of a formula ϕ from a theory T � FmlL isa sequence ϕ1, . . . ,ϕn of formulae such thatϕn � ϕ and for all i with 1¤ i¤ n one of thefollowing conditions holds:
ϕi is substitution instance of an axiom,ϕi P T ,there is ϕl,ϕk � pϕl Ñ ϕiq with l,k i. Then ϕiis the result of the application of modusponens on the predecessor-formulae of ϕi.
We write: T $ ϕ (ϕ can be derived from T ).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 52/456
1. Basics about Logic 4. Calculi
We have now introduced two important notions:Syntactic derivability $: the notion that certain
formulae can be derived from otherformulae using a certain calculus,
Semantic validity |ù: the notion that certainformulae follow from other formulaebased on the semantic notion of amodel.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 53/456
1. Basics about Logic 4. Calculi
Definition 1.15 (Correct-, Completeness for a calculus)Given an arbitrary calculus (which defines a notion $) anda semantics based on certain models (which defines arelation |ù), we say that
Correctness: The calculus is correct with respect to thesemantics, if the following holds:
Φ$ φ implies Φ |ù φ.
Completeness: The calculus is complete with respect tothe semantics, if the following holds:
Φ |ù φ implies Φ$ φ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 54/456
1. Basics about Logic 4. Calculi
Theorem 1.16 (Correct-, Completeness for HilbertSLL )
A formula follows semantically from a theory Tif and only if it can be derived:
T |ù ϕ if and only if T $ ϕ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 55/456
1. Basics about Logic 4. Calculi
Theorem 1.17 (Compactness for HilbertSLL )
A formula follows from a theory T if and only ifit follows from a finite subset of T :
CnpT q �¤tCnpT 1q : T 1 � T, T 1finiteu.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 56/456
1. Basics about Logic 4. Calculi
It is well-known, that any formula φ can bewritten as a conjunction of disjunctions
n©i�1
miªj�1
φi, j
The φi, j are just constants or negated constants.The n disjunctions
�mij�1 φi, j are called clauses of
φ.Normalform
Instead of working on arbitrary formulae, it isoften easier to work on finite sets of clauses.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 57/456
1. Basics about Logic 4. Calculi
A resolution calculus for SL
The resolution calculus is defined over thelanguage Lres � LSL where the set ofwell-formed formulae FmlRes
Lres consists of alldisjunctions of the following form
A_ B_C_ . . ._ E,
i.e. the disjuncts are only constants or theirnegations. No implications or conjunctions areallowed. These formulae are called clauses.l is also a clause: the empty disjunction.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 58/456
1. Basics about Logic 4. Calculi
Set-notation of clauses
A disjunction A_ B_C_ . . ._ E is oftenwritten as a set
tA, B,C, . . . , Eu.
Thus the set-theoretic union of such setscorresponds again to a clause: tA, Bu YtA, Curepresents A_ B_ C. Note that the empty setH is identified with l.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 59/456
1. Basics about Logic 4. Calculi
We define the following inference rule onFmlRes
Lres:
Definition 1.18 (SL resolution)
Let C1,C2 be clauses (disjunctions). Deduce theclause C1_C2 from C1_A and C2_ A:
(Res)C1_A, C2_ A
C1_C2
If C1 �C2 �H, then C1_C2 � l.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 60/456
1. Basics about Logic 4. Calculi
If we use the set-notation for clauses, we canformulate the inference rule as follows:Definition 1.19 (SL resolution (Set notation))
Deduce the clause C1YC2 from C1YtAu andC2Yt Au:
(Res)C1YtAu, C2Yt Au
C1YC2
Again, we identify the empty setH with l.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 61/456
1. Basics about Logic 4. Calculi
Definition 1.20 (Resolution Calculus for SL)
We define the resolution calculusRobinsonSL
Lres � xH,tResuy as follows. Theunderlying language is Lres � LSL defined onSlide 58 together with the well-formed formulaeFmlRes
Lres.
Thus there are no axioms and only one inferencerule. The well-formed formulae are just clauses.Question:
Is this calculus correct and complete?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 62/456
1. Basics about Logic 4. Calculi
Answer:It is correct, but it is not complete!
But every problem of the kind “T |ù φ” is equivalent to“T Yt φu is unsatisfiable”
or rather toT Yt φu $ l
($ stands for the calculus introduced above).
Theorem 1.21 (Completeness of Resolution Refutation)If M is an unsatisfiable set of clauses then the empty clausel can be derived in RobinsonSL
Lres.
We also say that resolution is refutation complete.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 63/456
1. Basics about Logic 5. First-Order Logic (FOL)
1.5 First-Order Logic (FOL)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 64/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.22 (First order logic LFOL, L � LFOL)
The language LFOL of first order logic (Praedikatenlogikerster Stufe) is:
x,y,z,x1,x2, . . . ,xn, . . .: a countable set Var of variablesfor each k P N0: Pk
1 ,Pk2 , . . . ,Pk
n , . . . a countable set Predk
of k-dimensional predicate symbols (the 0-dimensionalpredicate symbols are the propositional logicconstants from At of LSL). We suppose that l and Jare available.for each k P N0: f k
1 , f k2 , . . . , f k
n , . . . a countable set Functk
of k-dimensional function symbols , ^, _,Ñ: the sentential connectivesp, q: the parentheses@, D: quantifiers
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 65/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)The 0-dimensional function symbols are calledindividuum constants – we leave out the parentheses. Ingeneral we will need – as in propositional logic – only acertain subset of the predicate or function symbols.
These define a language L � LFOL (analogously todefinition 1.1 on page 2). The used set of predicate andfunction symbols is also called signature Σ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 66/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)The concept of an L-term t and an L-formula ϕ aredefined inductively:
Term: L-terms t are defined as follows:1 each variable is a L-term.2 if f k is a k-dimensional function symbol from L and t1,. . . ,tk are L-terms, then f kpt1, . . . , tkq is a L-Term.
The set of all L-terms that one can create from the setX � Var is called TermLpXq or TermΣpXq. Using X �H weget the set of basic terms TermLpHq, short: TermL .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 67/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)Formula: L-formulae ϕ are also defined inductively:1 if Pk is a k-dimensional predicate symbol from L and t1,. . . ,tk are L-terms then Pkpt1, . . . , tkq is a L-formula
2 for all L-formulae ϕ is p ϕq a L-formula3 for all L-formulae ϕ and ψ are pϕ^ψq and pϕ_ψq
L-formulae.4 if x is a variable and ϕ a L-formula then are pDxϕq andp@xϕq L-formulae.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 68/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)Atomic L-formulae are those which are composedaccording to 1., we call them AtLpXq (X � Var). The set ofall L-formulae in respect to X is called FmlLpXq.
Positive formulae (Fml�L pXq) are those which arecomposed using only 1, 3. and 4.
If ϕ is a L-formula and is part of an other L-formula ψ thenϕ is called sub-formula of ψ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 69/456
1. Basics about Logic 5. First-Order Logic (FOL)
An illustrating example
Example 1.23 (From semigroups to rings)
We consider L � t0,1,�, �,¤,�u, where 0,1 are constants,�, � binary operations and ¤,� binary relations. What canbe expressed in this language?
Ax 1: @x@y@z x�py� zq � px� yq� zAx 2: @x px�0� 0� xq ^ p0� x� xqAx 3: @xDy px� y� 0q ^ py� x� 0qAx 4: @x@y x� y� y� xAx 5: @x@y@z x � py � zq � px � yq � zAx 6: @x@y@z x � py� zq � x � y� x � zAx 7: @x@y@z py� zq � x� y � x� z � x
Axiom 1 describes an semigroup, the axioms 1-2 describe amonoid, the axioms 1-3 a group, and the axioms 1-7 a ring.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 70/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.24 (L-structure A � pUA , IAq)
A L-structure or a L-interpretation is a pairA �def pUA , IAq withUA being an arbitrary non-empty set,which is called the basic set (the universe or theindividuum range) of A. Further IA is a mapping whichassigns to each k-dimensional predicate symbol Pk in La k-dimensional predicate overUAassigns to each k-dimensional function symbol f k in La k-dimensional function onUA
In other words: the domain of IA is exactly the set ofpredicate and function symbols of L.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 71/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)The range of IA consists of the predicates and functions onUA . We write:
IApPq � PA , IAp f q � f A .
ϕ be a L1-formula and A �def pUA , IAq a L-structure. A iscalledmatching with ϕ if IA is defined for all predicateand function symbols which appear in ϕ, i.e. if L1 � L.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 72/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.25 (Variable assignment ρ)
A variable assignment ρ over a L-structureA � pUA , IAq is a function
ρ : Var Ñ UA ; x ÞÑ ρpxq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 73/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.26 (Semantics of FOL, Model A)Let ϕ be a formula, A a structure matching with ϕ and ρ avariable assignment over A. For each term t, which can bebuilt from components of ϕ, we define inductively thevalue of t in the structure A, we call Aptq.1 for a variable x is Apxq �def ρpxq.
2 if t has the form t � f kpt1, . . . , tkq, with t1, . . . , tk beingterms and f k a k-dimensional function symbol, thenAptq �def f ApApt1q, . . . ,Aptkqq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 74/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)We define inductively the logical value of a formula ϕ inA:1. if ϕ�def Pkpt1, . . . , tkq with the terms t1, . . . , tk and the
k-dimensional predicate symbol Pk, then
Apϕq �def
"true, i f pApt1q, . . . ,Aptkqq P PA ,false, else.
2. if ϕ�def ψ, then
Apϕq �def
"true, i f Apψq � false,false, else.
3. if ϕ�def pψ^ηq, then
Apϕq �def
"true, i f Apψq � true and Apηq � true,false, else.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 75/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)4. if ϕ�def pψ_ηq, then
Apϕq �def
"true, i f Apψq � true or Apηq � true,false, else.
5. if ϕ�def @xψ, then
Apϕq �def
"true, i f @ d PUA : Arx{dspψq � true,false, else.
6. if ϕ�def Dxψ, then
Apϕq �def
"true, i f Dd PUA : Arx{dspψq � true,false, else.
In the cases 5. and 6. the notation rx{ds was used. It isdefined as follows: For d PUA let Arx{ds be the structure A 1,which is identical to A except for the definition of xA 1
:xA 1
�def d (whether IA is defined for x or not).Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 76/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition (continued)We write:
A |ù ϕrρs for Apϕq � true: A is amodel for ϕ withrespect to ρ.If ϕ does not contain free variables, then A |ù ϕrρs isindependent from ρ. We simply leave out ρ.If there is at least one model for ϕ , then ϕ is calledsatisfiable or consistent.
A free variable is a variable which is not in the scope of aquantifier. For instance, z is a free variable of @xPpx,zq butnot free (or bounded) in @zDxPpx,zq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 77/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.27 (Tautology)
1 A theory is a set of formulae without freevariables: T � FmlL . The structure A satisfiesT if A |ù ϕ holds for all ϕ P T . We write A |ù Tand call A a model of T .
2 A L-formula ϕ is called L-tautology, if for allmatching L-structures A the followingholds: A |ù ϕ.
From now on we suppress the language L,because it is obvious from context. Neverthelessit has to be defined.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 78/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.28 (Consequence set CnpT q)
A formula ϕ follows semantically from T , if forall structures A with A |ù T also A |ù ϕ holds.We write: T |ù ϕ.
In other words: all models of T do also satisfy ϕ.
We denote by CnLpT q �def tϕ P FmlL : T |ù ϕu, orsimply CnpT q, the semantic consequenceoperator.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 79/456
1. Basics about Logic 5. First-Order Logic (FOL)
Lemma 1.29 (Properties of CnpT q)
The semantic consequence operator has thefollowing properties1 T -extension: T �CnpT q,2 Monotony: T � T 1 ñ CnpT q �CnpT 1q,3 Closure: CnpCnpT qq �CnpT q.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 80/456
1. Basics about Logic 5. First-Order Logic (FOL)
Lemma 1.30 (ϕ R Cn(T))
ϕ RCnpT q if and only if there is a structure A withA |ù T and A |ù ϕ.
In other words: ϕ RCnpT q if and only if there is acounterexample: a model of T in which ϕ is nottrue.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 81/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.31 (MODpT q, CnpUq)
If T � FmlL , then we denote byMODpT q the setof all L-structures A which are models of T :
MODpT q �def tA : A |ù Tu.
If U is a set of structures then we can consider allsentences, which are true in all structures. Wecall this set also CnpUq:
CnpUq �def tϕ P FmlL : @A PU : A |ù ϕu.
MOD is obviously dual to Cn:
CnpMODpT qq �CnpT q, MODpCnpT qq �MODpT q.Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 82/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.32 (Completeness of a theory T )
T is called complete, if for each formula ϕ P FmlL : T |ù ϕ
or T |ù ϕ holds.
Attention:Do not mix up this last condition with the property of astructure v (or a model): each structure is complete inthe above sense.
Lemma 1.33 (Ex Falso Quodlibet)T is consistent if and only if CnpT q � FmlL .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 83/456
1. Basics about Logic 5. First-Order Logic (FOL)
An illustrating example
Example 1.34 (Natural numbers in different languages)
NPr � pN0,0N ,�N ,�N q („Presburger Arithmetic”),
NPA � pN0,0N ,�N , �N ,�N q („Peano Arithmetic”),
NPA1 � pN0,0N ,1N ,�N , �N ,�N q (variant of NPA).
These sets each define the natural numbers, but indifferent languages.
Question:If the language bigger is bigger then we can express more.Is LPA1 more expressive then LPA?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 84/456
1. Basics about Logic 5. First-Order Logic (FOL)
Answer:
No, because one can replace the 1N by aLPA-formula: there is a LPA-formula φpxq so thatfor each variable assignment ρ the followingholds:
NPA1 |ùρ φpxq if and only if ρpxq � 1N
Thus we can define a macro for 1.Each formula of LPA1 can be transformed intoan equivalent formula of LPA.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 85/456
1. Basics about Logic 5. First-Order Logic (FOL)
Question:
Is LPA perhaps more expressive than LPr, or canthe multiplication be defined somehow?
We will see later that LPA is indeed moreexpressive:the set of sentences valid in NPr is decidable,whereasthe set of sentences valid in NPA is not evenrecursively enumerable.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 86/456
1. Basics about Logic 5. First-Order Logic (FOL)
As for sentential logic, formulae can be derivedfrom a given theory and they can also(semantically) follow from it.Syntactic derivability $: the notion that certain
formulae can be derived from otherformulae using a certain calculus,
Semantic validity |ù: the notion that certainformulae follow from other formulaebased on the semantic notion of amodel.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 87/456
1. Basics about Logic 5. First-Order Logic (FOL)
Definition 1.35 (Correct-, Completeness for a calculus)Given an arbitrary calculus (which defines a notion $) anda semantics based on certain models (which defines arelation |ù), we say that
Correctness: The calculus is correct with respect to thesemantics, if the following holds:
Φ$ φ implies Φ |ù φ.
Completeness: The calculus is complete with respect tothe semantics, if the following holds:
Φ |ù φ implies Φ$ φ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 88/456
1. Basics about Logic 5. First-Order Logic (FOL)
We have already defined a complete and correct calculusfor sentential logic LSL. Such calculi also exist for firstorder logic LFOL.
Theorem 1.36 (Correct-, Completeness of FOL)
A formula follows semantically from a theory T if and only ifit can be derived:
T $ ϕ if and only if T |ù ϕ
Theorem 1.37 (Compactness of FOL)
A formula follows from a theory T if and only if it followsfrom a finite subset of T :
CnpT q �¤tCnpT 1q : T 1 � T, T 1 finiteu.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 89/456
1. Basics about Logic 5. First-Order Logic (FOL)
The introduced relation T |ù φ says that eachmodel of T is also a model of φ. But becausethere are many models with very large universesthe following question arises: can we restrict toparticular models ?
Theorem 1.38 (Löwenheim-Skolem)
T |ù φ holds if and only if φ holds in allcountable models of T .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 90/456
1. Basics about Logic 5. First-Order Logic (FOL)
Quite often the universes of models we are interested inconsist exactly of the basic terms TermLpHq. This leads to
Definition 1.39 (Herbrand model)
A model A is called Herbrand model with respect to alanguage if the universe of A consists exactly of TermLpHqand the function symbols f k
i are interpreted as follows:
f ki
A : TermLpHq� . . .�TermLpHq Ñ TermLpHq;pt1, . . . , tkq ÞÑ f k
i pt1, . . . , tkq
We write T |ùHerb φ if each Herbrand model of T is also amodel of φ.
A Herbrand model is uniquely determined by thepredicates that are true in it. The whole set BL of allground instances of predicates over the Herbrand universeis called Herbrand base.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 91/456
1. Basics about Logic 5. First-Order Logic (FOL)
Theorem 1.40 (Reduction to Herbrand models)
If T is universal and φ existential, then thefollowing holds:
T |ù φ if and only if T |ùHerb φ
Question:
Is T |ùHerb φ not much easier, because we have toconsider only Herbrand models? Is it perhapsdecidable?
No, truth in Herbrand models is highlyundecidable.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 92/456
1. Basics about Logic 5. First-Order Logic (FOL)
Wumpus world reconsidered in FOL
Question:
How do we axiomatize the Wumpus-world inFOL?
function KB-AGENT( percept) returns an actionstatic: KB, a knowledge base
t, a counter, initially 0, indicating time
TELL(KB, MAKE-PERCEPT-SENTENCE( percept, t))action � ASK(KB, MAKE-ACTION-QUERY(t))TELL(KB, MAKE-ACTION-SENTENCE(action, t))t � t + 1return action
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 93/456
1. Basics about Logic 5. First-Order Logic (FOL)
Idea:In order to describe actions or their effects consistently weconsider the world as a sequence of situations (snapshotsof the world). Therefore we have to extend eachpredicate by an additional argument.
We use the function symbol
resultpaction,situationq
as the term for the situation which emerges when theaction action is executed in the situation situation.
Actions: Turn_right, Turn_le f t, Foreward, Shoot, Grab,Release, Climb.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 94/456
1. Basics about Logic 5. First-Order Logic (FOL)
PIT
PIT
PIT
Gold
PIT
PIT
PIT
Gold
PIT
PIT
PIT
Gold
PIT
PIT
PIT
Gold
Forward
S0
Forward
Turn (Right)S1
S0S2
S3
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 95/456
1. Basics about Logic 5. First-Order Logic (FOL)
We also need amemory, a predicate
Atpperson, location,situationq
with person being eitherWumpus or Agent and locationbeing the actual position (stored as pair [i,j]).
Important axioms are the so called successor-stateaxioms, they describe how actions effect situations. Themost general form of these axioms is
true afterwards ðñ an action made it trueor it is already true andno action made it false
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 96/456
1. Basics about Logic 5. First-Order Logic (FOL)
Successor State Axiom
Axioms about Atpp, l,sq:Atpp, l,resultpForward,sqqØppl .
� location_aheadpp,sq^ Wallplqq
Atpp, l,sq ÑLocation_aheadpp,sq .�
Location_towardpl,Orient.pp,sqqWallprx,ysq Øpx .
� 0_ x .� 5_ y .
� 0_ y .� 5q
This lead to the programming language GOLOG.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 97/456
1. Basics about Logic 6. Logic Programming (LP)
1.6 Logic Programming (LP)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 98/456
1. Basics about Logic 6. Logic Programming (LP)
The following theorem is the basic result for applyingresolution. It states that FOL can be reduced to SL.
Theorem 1.41 (Herbrand)Let T be universal and φ does not contain quantifiers. Then:
T |ù Dφ if and only if there is t1, . . . , tn P TermLpHqwith: T |ù φpt1q_ . . ._φptnq
Or: Let M be a set of clauses of FOL (formulae in the formP1pt1q_ P2pt2q_ . . ._Pnptnq with ti P TermLpXq). Then:
M is unsatisfiableif and only if
there is a finite and unsatisfiable set Minstof ground instances of M.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 99/456
1. Basics about Logic 6. Logic Programming (LP)
Our general goal is to derive an existentiallyquantified formula from a set of formulae:
M $ Dϕ.
To use resolution we must form MYt Dϕu andput it into the form of clauses. This set is calledinput.Instead of allowing arbitrary resolvents, we tryto restrict the search space.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 100/456
1. Basics about Logic 6. Logic Programming (LP)
Definition 1.42 (Most general unifier: mgU)Given a finite set of equations between terms or equationsbetween literals.Then there is an algorithm which calculates amostgeneral solution substitution (i.e. a substitution of theinvolved variables so that the left sides of all equations aresyntactically identical to the right sides) or which returnsfail.In the first case themost general solution substitution isdefined (up to renaming of variables): it is called
mgU, most general unifier
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 101/456
1. Basics about Logic 6. Logic Programming (LP)
ppx,aq � qpy,bq.ppgpaq, f pxqq � ppgpyq,zq.
Basic substitutions Θ are:ry{a,x{a,z{ f paqs, ry{a,x{ f paq,z{ f p f paqqs, . . .The mgU is: ry{a,z{ f pxqs .ppxq � pp f pxqq.
Occur-check, Prolog II.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 102/456
1. Basics about Logic 6. Logic Programming (LP)
We outline the mentioned algorithm using an example.
Given: f px,gphpyq,yqq � f px,gpz,aqq
The algorithm successively calculates the following sets ofequations:
t x� x, gphpyq,yq � gpz,aq ut gphpyq,yq � gpz,aq ut hpyq � z, y� a ut z� hpyq, y� a ut z� hpaq, y� a u
Thus the mgU Θ is: Θ� rx{x,y{a,z{hpaqs.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 103/456
1. Basics about Logic 6. Logic Programming (LP)
A resolution calculus for FOLThe resolution calculus is defined over the languageLres � LFOL where the set of well-formed formulae FmlRes
Lres
consists of all disjunctions of the following formA_ B_C_ . . ._ E,
i.e. the disjuncts are only atoms or there negations. Noimplications or conjunctions are allowed. These formulaeare also called clauses.Such a clause is also written as the set
tA, B,C, . . . , Eu.
This means that the set-theoretic union of such setscorresponds again to a clause.Note: a clause now consists of atoms rather thanconstants (as it was the case for SL).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 104/456
1. Basics about Logic 6. Logic Programming (LP)
Definition 1.43 (Robinson’s resolution for FOL)
The resolution calculus consists of two rules:
(Res)C1YtA1u C2Yt A2u
pC1YC2qmgUpA1,A2q
where C1YtA1u and C2YtA2u are assumed to be disjunctwrt the variables, and the factorization rule
(Fac)C1YtL1,L2u
pC1YtL1uqmgUpL1,L2q
Consider for example M � trpxq_ ppxq, ppaq,spaqu and thequestion M |ù Dxpspxq^ rpxqq?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 105/456
1. Basics about Logic 6. Logic Programming (LP)
Definition 1.44 (Resolution Calculus for FOL)
We define the resolution calculusRobinsonFOL
Lres � xH,tRes,Facuy as follows. Theunderlying language is Lres � LFOL defined onSlide 104 together with the set of well-formedformulae FmlRes
Lres.
Thus there are no axioms and only two inferencerules. The well-formed formulae are just clauses.Question:
Is this calculus correct and complete?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 106/456
1. Basics about Logic 6. Logic Programming (LP)
Question:
Why do we need factorization?
Answer:
Consider
M � tspx1q_ spx2q, spy1q_ spy2qu
Resolving both clauses gives
tspx1quYt spy1qu
or variants of it.Resolving this new clause with one in M onlyleads to variants of the respective clause in M.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 107/456
1. Basics about Logic 6. Logic Programming (LP)
Answer (continued):
l can never be derived (using resolution only).
Factorization instantly solves the problem, wecan deduce both spxq and spyq, and from therethe empty clause.
Theorem 1.45 (Resolution is refutation complete)
Robinsons resolution calculus RobinsonFOLLres is
refutation complete: given an unsatisfiable set,the empty clause can be derived using resolutionand factorization.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 108/456
1. Basics about Logic 6. Logic Programming (LP)
Example 1.46 (Unlimited Resolution)
Let M :� trpxq_ ppxq, ppaq, spaqu andlÐ spxq^ rpxq the query.An unlimited resolution might look like this:
rpxq_ ppxq ppaq
rpaq
spaq spxq_ rpxq
rpaq
l
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 109/456
1. Basics about Logic 6. Logic Programming (LP)
Input resolution: in each resolution step one of the twoparent clauses must be from the input. Inour example:
spxq_ rpxq spaq
rpaqrpxq_ ppxq
ppaqppaq
l
Linear resolution: in each resolution step one of the twoparent clauses must either be from theinput or must be a successor of the otherparent clause.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 110/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.47 (Completeness of resolution variants)
Linear resolution is refutation complete.Input resolution is correct but not refutationcomplete.
Idea:
Maybe input resolution is complete for arestricted class of formulae.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 111/456
1. Basics about Logic 6. Logic Programming (LP)
Definition 1.48 (Horn clause)
A clause is called Horn clause if it contains atmost one positive atom.
A Horn clause is called definite if it containsexactly one positive atom. It has the form
Aptq Ð A1pt1q, . . . ,Anptnq.
A Horn clause without positive atom is calledquery:
lÐ A1pt1q, . . . ,Anptnq.
Often, one also calls the body of the above rulequery Q: lÐ Qpx1, . . . ,xnq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 112/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.49 (Input resolution for Horn clauses)
Input resolution for Horn clauses is refutationcomplete.
From now on, we call a finite set of definiteHorn clauses a definite logic program or justdefinite program.Each definite program P defines a languageLP, determined by all symbols occurring in P.We denote the Herbrand base of thislanguage by BP.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 113/456
1. Basics about Logic 6. Logic Programming (LP)
Definition 1.50 (SLD resolution wrt P and query Q)
SLD resolution with respect to a definiteprogram P and the query Q is input resolutionbeginning with the query lÐ A1, . . . ,An.
Then one Ai is chosen and resolved with aclause of the program.A new query emerges, which is treated asbefore.If the empty clause lÐ can be derived, thenSLD resolution was successful and theinstantiation of the variables is calledcomputed answer.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 114/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.51 (Correctness of SLD resolution)
Let P be a definite program and Q a query. Then eachcomputed answer (for P wrt Q) is correct.
Question:Is SLD completely instantiated?
Definition 1.52 (Computation rule)
A computation rule R is a function which assigns an atomAi P tA1, . . . ,Anu to each query lÐ A1, . . . ,An. This Ai is thechosen atom against which we will resolve in the nextstep.
Note:PROLOG always uses the leftmost atom.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 115/456
1. Basics about Logic 6. Logic Programming (LP)
Example 1.53 (SLD-Resolution)
Let the definite program PSLD consist of thefollowing three clauses
p1q ppx,zq Ð qpx,yq, ppy,zqp2q ppx,xqp3q qpa,bq
The query Q we are interested in is given byppx,bq. I.e. we are looking for all substitutions Θ
for x such that ppx,bqΘ follows from P.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 116/456
1. Basics about Logic 6. Logic Programming (LP)
Ð ppx,bq
Ð qpx,yq, ppy,bq
Ð ppb,bq
Ð qpb,uq, ppu,bq
l
rx{bs“Success”
“Failure”
l
“Success”rx{as
��
��
��
��
@@
@@
@@
@@
1
1
2
2
3
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 117/456
1. Basics about Logic 6. Logic Programming (LP)
Ð ppx,bq
Ð qpx,yq, ppy,bq
Ð qpx,yq,qpy,uq, ppu,bq Ð qpx,bq
Ð qpx,yq,qpy,uq,qpu,vq, ppv,bq Ð qpx,yq,qpy,bq
Ð qpx,aq
l
rx{bs
“Success”
“Failure”
l
“Success”
l
“Success”
rx{as
��
��
��
��
��
��
��
��
��
@@
@@
@@
@@
@@
@@
@@
@@
@@...
.
.
.
1
1
1
1
2
2
2
2
3
3
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 118/456
1. Basics about Logic 6. Logic Programming (LP)
A SLD tree may have three different kinds ofbranches:1 infinite ones,2 branches ending with the empty clause(and leading to an answer) and
3 failing branches (dead ends).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 119/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.54 (Independence of computation rule)
Let R be a computation rule and σ an answercalculated wrt R (i.e. there is a successful SLDresolution). Then there is a successful SLDresolution for each other computation rule R'and the answer σ1 belonging to R’ is a variant of σ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 120/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.55 (Completeness of SLD resolution)
Each correct answer substitution is subsumed bya calculated answer substitution. I.e.:
P |ù @QΘ
impliesSLD computes an answer τ with: Dσ : Qτσ� QΘ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 121/456
1. Basics about Logic 6. Logic Programming (LP)
Question:
How to find successful branches in a SLD tree?
Definition 1.56 (Search rule)
A search rule is a strategy to search forsuccessful branches in SLD trees.
Note:
PROLOG uses depth-first-search.
A SLD resolution is determined by acomputation rule and a search rule.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 122/456
1. Basics about Logic 6. Logic Programming (LP)
SLD trees for PYtQu are determined by thecomputation rule.
PROLOG is incomplete because of two reasons:depth-first-searchincorrect unification (no occur check).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 123/456
1. Basics about Logic 6. Logic Programming (LP)
A third reason comes up if we also ask for finiteand failed SLD resolutions:the computation rule must be fair, i.e. itmust be guaranteed that every atom on thelist of goals is eventually chosen.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 124/456
1. Basics about Logic 6. Logic Programming (LP)
Are definite programs too restricted wrt. expressivity?
No! They are Turing complete: all r.e. sets can beexpressed by definite programs. To be more precise: leta language with at least one constant, one unary functionsymbol and a binary relation symbol be given. We alsoassume there is a distingushed unary relation symbol p.Then the Herbrand universe is infinite and for each r.e. setM of this universe there is a definite program P suchthat
M � tpptq : P |ù pptqu.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 125/456
1. Basics about Logic 6. Logic Programming (LP)
Are function symbols really necessary?
Yes! Otherwise higher order objects could notbe defined (the Herbrand universe would befinite).
An important example is the list constructor r�|�s.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 126/456
1. Basics about Logic 6. Logic Programming (LP)
Order of atoms
Example 1.57 (Termination depends on the order)Consider the following two programs:
p1q reverseprX |Y s,Zq :� appendpU, rXs,Zq,reversepY,Uqp2q reverseprX |Y s,Zq :� reversepY,Uq,appendpU, rXs,Zq
together with a definition for append
appendprs,X ,Xq :�appendprX |Y s,Z, rX |T sq :� appendpY,Z,T q
and the query “Q� reversepra|Xs, rb,c,d,bsq”.
(1) Q1 � appendpU, ras, rb,c,d,bsq, reversepX ,Uq(2) Q1 � reversepX ,Uq, appendpU, ras, rb,c,d,bsq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 127/456
1. Basics about Logic 6. Logic Programming (LP)
Obviously, (1) and (2) are equivalent (from alogical point of view).Asking the query Q wrt (1) yields a “fail”.Asking the query Q wrt (2) yields anon-terminating computation.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 128/456
1. Basics about Logic 6. Logic Programming (LP)
Example 1.58 (TP)
Given a definite program P let TP: 2BP ÞÝÑ 2BP; I ÞÝÑ TPpI q
TPpI q :� tA P BP : there is an instantiation of a rule in Ps.t. A is the head of this rule and allbody-atoms are contained in I u
It turns out that TP is monotone and continuous: so that
Theorem 1.59 (TP and MP)
MP � TPÒω� l f ppTPq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 129/456
1. Basics about Logic 6. Logic Programming (LP)
Theorem 1.60 (Soundness and Completeness of SLD)
The following properties are equivalent for adefinite program P and a query Q:
P |ù @ QΘ, i.e. @ QΘ is true in all models of P,MP |ù @ QΘ,SLD computes an answer τ that subsumes Θ
wrt Q (i.e. Dσ : Qτσ � QΘ.)
Note that not just some correct answer iscomputed: the most general one is.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 130/456
1. Basics about Logic 6. Logic Programming (LP)
An important feature of SLD-Resolution is itsGoal-Orientedness, also called Relevance.
Lemma 1.61 (Goal-Orientedness, Relevance)
Given a program P and a query Qpxq, only the callgraph below Q (i.e. the relevant part of P wrt. Q)is necessary to answer this query.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 131/456
1. Basics about Logic 6. Logic Programming (LP)
Principle 1.1 (PROLOG Paradigm)
Given a definite program P and a query, theproofs of this query (and the computed answers)represent the solutions of the formalizedproblem.It is important that function symbols be used.Given a query, only the relevant part of theprogram is considered.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 132/456
1. Basics about Logic 6. Logic Programming (LP)
Programming versus knowledge engineeringprogramming knowledge engineeringchoose language choose logicwrite program define knowledge basewrite compiler implement calculusrun program derive new facts
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 133/456
1. Basics about Logic 7. References
1.7 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 134/456
1. Basics about Logic 7. References
[Apt and Bol, 1994] Krzysztof R. Apt and Roland N. Bol.Logic programming and negation: A survey.19/20:9–71, 1994.
[Brewka and Dix, 2005] Gerhard Brewka and Jürgen Dix.Knowledge representation with extended logic programs.In D. Gabbay and F. Guenthner, editors, Handbook ofPhilosophical Logic, volume 12, chapter 1, pages 1–85. ReidelPubl., 2. edition, 2005.Shortened version also appeared in Dix, Pereira, Przymusinski(Eds.), Logic Programming and Knowledge Representation,Springer LNAI 1471, pages 1–55, 1998.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 135/456
1. Basics about Logic 7. References
[Brewka et al., 1997] Gerhard Brewka, Jürgen Dix, and Kurt Konolige.Nonmonotonic Reasoning: An Overview., volume 73.CSLI Publications, Stanford, CA, 1997.
[Dastani et al., 2007] Mehdi Dastani, Jürgen Dix and Peter Novak.The Second Contest on Multi-Agent Systems based on,Computational Logic.In K. Inoue, K. Satoh and F. Toni, editors, Proceedings of CLIMA’06, Revised Selected and Invited Papers, pages 266–283. LectureNotes in Artificial Intelligence 4371, 2007.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 136/456
1. Basics about Logic 7. References
[Dix et al., 2001] Jürgen Dix, Ulrich Furbach, and Ilkka Niemelä.Nonmonotonic reasoning: Towards efficient calculi andimplementations.In John Alan Robinson and Andrei Voronkov, editors, Handbookof Automated Reasoning (in 2 volumes), pages 1241–1354.Elsevier and MIT Press, 2001.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 137/456
2. Answer Set Programming (ASP)
Chapter 2. Answer SetProgramming (ASP)
Answer Set Programming (ASP)2.1 Motivating Examples2.2 Semantics2.3 Properties2.4 ASP engines2.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 138/456
2. Answer Set Programming (ASP)
In the previous lecture we have introduced SLDresolution as an efficient procedural mechanism forHorn programs. A nice property was Relevance andthe fact, that a unique Herbrand model exists.Starting with Slide 142 we discuss some famousimportant problems in knowledge representation andpresent several motivating running examples.Although Horn programs are Turing complete, theyare too restricted as a framework for KR. We motivateto use programs with negation as an appropriate toolto formalize problems. But how should the semanticslook like?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 139/456
2. Answer Set Programming (ASP)
We show (starting with Slide 156) that by assuming afew interesting properties (Red, GPPE, Sub, TAUT,CONTRA), only one canonical semantics survives:answer sets. This leads to the ASP paradigm:representing problems by logic programs withnegation under the ASP semantics.In contrast to PROLOG, ASP is purely declarative anduses efficient database techniques. The declarativenessof ASP can be shown on the greatest common divisorexample.A program with negation determines a set of sets:any NP-problem (resp. Σ2-problem) can be uniformlyrepresented.There exist many efficient implementations of ASP.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 140/456
2. Answer Set Programming (ASP) 1. Motivating Examples
2.1 Motivating Examples
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 141/456
2. Answer Set Programming (ASP) 1. Motivating Examples
The main idea of PROLOG was to describe the givenproblem in logic and leave its solution to the underlyingresolution procedure.
Example 2.1 (Greatest Common Divisor (1), see alsoSlide 186)
Given two integers n,m, how can we compute the greatestcommon divisor with PROLOG?An answer is to apply Euclids algorithm and to writedown a recursive definition for the predicate
gcdpT,X ,Y q: T is the greatest common divisor of X ,Y .
gcdpX ,X ,Xq :� #intpXq,X ¡ 0.gcdpT,X ,Y q :� X Y,gcdpT,X ,Y 1q,Y � Y 1�X .gcdpT,X ,Y q :� X ¡ Y,gcdpT,X1,Y q,X � X1�Y.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 142/456
2. Answer Set Programming (ASP) 1. Motivating Examples
This is not declarative: It assumes a lot ofmathematical insight. Namely an algorithmand the fact that it is correct and complete.Could we also just describe the properties,without explicitly giving an algorithm?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 143/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Important problems of knowledgerepresentation
There are three very important representation-problemsconcerning the axiomatization of a changing world:
Frame problem: most actions change only little – weneedmany actions to describe invariantproperties.It would be ideal to axiomatize only whatdoes not change and to add a proposition like“nothing else changes”.
Ramification problem: How should we handle implicitconsequences of actions? For exampleGrabpGoldq: Gold can be contaminated. ThenGrabpGoldq is not optimal.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 144/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Qualification problem: In logic, it is necessary toenumerate all conditions under which anaction is executed successfully.
@x pBirdpxq ^ Penguinpxq^ Deadpxq^^ Ostrichpxq^ BrokenWingpxq^^ . . . q
ÝÑ FliespxqIt would be ideal to say birds normally fly.The most natural way is to use “not”
φ Ð ψ, not abwhere ab stands for abnormality. Obviously,this forces us to extend definite programs bynegative atoms.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 145/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Example 2.2 (Inheritance Hierachies)
Suppose we know that birds typically fly and penguins arenon-flying birds. We also know that Tweety is a bird. Nowan agent is hired to build a cage for Tweety.
Should the agent put a roof on the cage?
After all it could be still the case that Tweety is a penguinand therefore can not fly, in which case we would not liketo pay for the unneccessary roof. But under normalconditions, it is obvious that one should conclude thatTweety is flying.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 146/456
2. Answer Set Programming (ASP) 1. Motivating Examples
A natural axiomatization is given as follows:
PInheritance : f liespxq Ð birdpxq, not abpr1,xqbirdpxq Ð penguinpxqabpr1,xq Ð penguinpxqmake_toppxq Ð f liespxq
together with some particular facts, likebirdpTweetyq and penguinpSamq.For the query “make_toppTweetyq” we expect the answer“yes” while for “make_toppSamq” we expect the answer“no”.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 147/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Nonmonotonicity
The last example shows that we need a nonmonotoniclogic:From T should follow make_toppTweetyq.From T YtpenguinpTweetyqu should not followmake_toppTweetyq.
Is SLD a nonmonotonic mechanism?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 148/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Example 2.3 (The Transitive Closure)
Assume we are given a graph consisting of nodes andedges between some of them. We want to know whichnodes are reachable from a given one. A naturalformalization of the property “reachable” would be
reachablepxq Ð edgepx,yq,reachablepyq.
What happens if we are given the following facts
edgepa,bq, edgepb,aq, edgepc,dq
and reachablepcq?
We expect that neither a nor b are reachable becausethere is no path from c to either a or b.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 149/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Example 2.4 (Van Gelder’s Example)
Assume we are describing a two-players game likecheckers. The two players alternately move a stone on aboard. The moving player wins when his opponent has nomore move to make. This is formalized by
winspxq Ðmove_from_to(x,y), not wins(y)meaning thatthe situation x is won (for the moving player A), if hecan lead over (with the help of a regular move, givenby the relation move_ f rom_top,q) to a situation y thatcan never be won for B.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 150/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Assume we also have the facts
move_ f rom_topa,bqmove_ f rom_topb,aqmove_ f rom_topb,cqmove_ f rom_topc,dq.
Our query to this program Pgame is ?-winspbq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 151/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Can we derive negative information at allfrom a definite program P using SLD?First answer: No, because the wholeHerbrand base is always a model of P.Second answer: Well, but there is the leastHerbrand model MP. So we declaresomething false, if it is not contained in MP.Good try, but while MP is r.e., its complementis not!But in some situations, it is obvious that aquery always fails, then we can safelyconclude that it is false.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 152/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Negation as finite-failure
We consider a definite program and a query Q.If the resulting SLD tree is finite with only failingbranches, then the query fails.
We consider again Example 1.53 from Slide 116:
p1q ppx,zq Ð qpx,yq, ppy,zqp2q ppx,xqp3q qpa,bq
and ask the query ?-ppb,aq. What do we get?
Can we extend SLD to a procedure SLDNF?Is SLDNF a nonmonotonic mechanism?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 153/456
2. Answer Set Programming (ASP) 1. Motivating Examples
Example 2.5 (SLDNF vs. NMR)
PKR : p Ð pq Ð not p
?-q: No termin. (SLDNF).Yes (KR).
P1KR : p Ð p
q Ð not pr Ð not r
?-p: No termin. (SLDNF).No (KR).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 154/456
2. Answer Set Programming (ASP) 2. Semantics
2.2 Semantics
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 155/456
2. Answer Set Programming (ASP) 2. Semantics
Instead of giving a definition out of Pandora’s box, we tryto start with a general notion and list properties that asemantics should satisfy.
Definition 2.6 (SEM)A semantics SEM is a mapping from the class of allprograms into the powerset of the set of all 3-valuedstructures. SEM assigns to every program P a set of3-valued models of P:
SEMpPq � MODLP3-valpPq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 156/456
2. Answer Set Programming (ASP) 2. Semantics
Formally, we can associate to any semantics SEM in thesense of Definition 2.6 two entailment relationssceptical: SEMsceptpPq is the set of all atoms or default
atoms that are true in all models of SEMpPq.credulous: SEMcredpPq is the set of all atoms or default
atoms that are true in at least one model ofSEMpPq.
When there is only one model, we will omit the outerbrackets and write (instead of SEMpPq � tMu)
SEMpPq �M.
We will also slightly abuse notation and write l P SEMpPqas an abbreviation for l PM for all M P SEMpPq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 157/456
2. Answer Set Programming (ASP) 2. Semantics
Here is the first principle we would like to have(which already distinguishes FOL from LP).Principle 2.1 (Reduction)
Suppose we are given a program P with possiblydefault-atoms in its body. If a ground atom A doesnot unify with any head of the rules of P, then wecan delete in every rule any occurrence of “not A”without changing the semantics.Dually, if there is an instance of a rule of the form“BÐ ” then we can delete all rules that contain“not B” in their bodies.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 158/456
2. Answer Set Programming (ASP) 2. Semantics
Extending SLD to SLDNF
How should we handle default-atoms?If we reach “not A” as a subgoal, we keep the currentSLD-tree in mind and start a new SLD-tree by trying tosolve “A”.If this succeeds, then we falsified “not A”, the currentbranch is failing and we have to backtrack andconsider a different subquery.But it can also happen that the SLD-tree for “A” isfinite with only failing branches. Then we say that Afinitely fails, we turn back to our original SLD-tree,consider the subgoal “not A” as successfully solved andgo on with the next subgoal in the current list.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 159/456
2. Answer Set Programming (ASP) 2. Semantics
Principle 2.2 (A “Naive” SLDNF-Resolution)
If in the construction of an SLDNF-tree a default-atom not Li jis selected in the list Li � tLi1,Li2, . . .u, then we try to proveLi j.If this fails finitely (it fails because the generated subtree isfinite and failing), then we take not Li j as proved and we goon to prove Lip j�1q.If Li j succeeds, then not Li j fails and we have to backtrack tothe list Li�1 of preliminary subgoals (the next rule is applied:backtracking).
SLDNF properly handles our Example 2.2.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 160/456
2. Answer Set Programming (ASP) 2. Semantics
SLDNF answers quite easily our requirements ofa semantics SEM (stated explicitly in Definition 2.6).
Lemma 2.7SLDNF satisfies Reduction.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 161/456
2. Answer Set Programming (ASP) 2. Semantics
Up to now it seems that SLDNF-resolution solvesall our problems. It handles our examplescorrectly, and is defined by a procedural calculusstrongly related to SLD.
There are two main problems with SLDNF:SLDNF can not handle free variables innegative subgoals (floundering),SLDNF is still too weak for KnowledgeRepresentation.
The latter problem is the most important one.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 162/456
2. Answer Set Programming (ASP) 2. Semantics
When we consider rules of the form “pÐ p”, then SLDresolution gets into an infinite loop and no answer to thequery ?- p can be obtained. This has often the effect thatwhen we enter into negation-as-failure mode, theSLD-tree to be constructed is infinite, although it is notsuccessful and therefore should be considered asfailed.Principle 2.3 (Elimination of Tautologies)
Suppose a program P has a rule which contains the sameatom in its body as well as in its head (i.e. the head consistsof exactly this atom). Then we can eliminate this rulewithout changing the semantics.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 163/456
2. Answer Set Programming (ASP) 2. Semantics
What does SLDNF do on Example 2.3?
reachablepxq Ð edgepx,yq,reachablepyq,
together with the facts
edgepa,bq, edgepb,aq, edgepc,dq
and reachablepcq?
SLDNF-Resolution does not derive�not reachablepaq�!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 164/456
2. Answer Set Programming (ASP) 2. Semantics
Partial EvaluationThe query “not reachablepaq” leads to the rule“reachablepaq Ð edgepa,bq,reachablepbq” and “reachablepbq”leads to “reachablepbq Ð edgepb,aq,reachablepaq”. Bothrules are definitions for reachablepaq and reachablepbq. Sowe can replace the body atoms of reachable by theirdefinitions:
reachablepaq Ð edgepa,bq, edgepb,aq,reachablepaq
reachablepbq Ð edgepb,aq, edgepa,bq,reachablepbq
that can both be eliminated by applying Principle 2.3.So we end up with a program that does neither containreachablepaq nor reachablepbq in one of the heads.Therefore, according to Principle 2.1 both atoms should beconsidered false.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 165/456
2. Answer Set Programming (ASP) 2. Semantics
Definition 2.8 (GPPE)
A semantics SEM satisfies GPPE if the followingtransformation does not change SEM:Replace a rule AÐ B�^not B� where B� contains anatom B by the rules
A �B�ztBu
�YB�
i ^ not�B�YB�
i�pi� 1, . . . ,nq
where BÐ B�i ^not B�
i (i� 1, . . . ,n) are all rules with headB.B Ð not EB Ð D,notC1
A Ð B,notC ÞÑ A Ð D,notC1,notCA Ð not E,notC
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 166/456
2. Answer Set Programming (ASP) 2. Semantics
We reconsider Example 2.5. The semantics of SLDNFcorresponds to Clark’s completion comp.
Example 2.9 (COMP vs. KR (revisited))
PKR : p Ð pq Ð not p
comppPKRq : p � pq � p
?-q: No (COMP).Yes (KR).
P1KR : p Ð p
q Ð not pr Ð not r
comppP1KRq : p � p
q � pr � r
?-p: Yes (COMP).No (KR).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 167/456
2. Answer Set Programming (ASP) 2. Semantics
Note that any semantics SEM satsfying GPPE andElimination of Tautologies can be seen asextending SLD by doing some Loop-checking.We will call such semantics KR-semantics inorder to distinguish them from the classicalLP-semantic which are based on SLDNF orvariants of Clark’s completion comppPq:KR-Semantics = SLDNF + Loop-check.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 168/456
2. Answer Set Programming (ASP) 2. Semantics
The last principle in this section is related toSubsumption: we can get rid of non-minimalrules by simply deleting them.Principle 2.4 (Subsumption)
In a program P we can delete a ruleAÐ B�^not B� whenever there is another ruleAÐ B 1�^not B 1� with
B 1� � B� and B 1� � B�.
A Ð D,not E,not FA Ð D,not F
ÞÑ A Ð D,not F
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 169/456
2. Answer Set Programming (ASP) 2. Semantics
Wellfounded Semantics: WFSWe call a semantics SEM1 weaker than SEM2, if for allprograms P and all atoms or default-atoms l the followingholds: SEM1pPq |ù l implies SEM2pPq |ù l.I.e. all (default-) atoms derivable from SEM1 with respectto P are also derivable from SEM2.
Theorem 2.10 (WFS)
There exists the weakest semantics satisfying our fourprinciples Elimination of Tautologies, Subsumption,Reduction, and GPPE. This semantics is called wellfoundedsemantics WFS.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 170/456
2. Answer Set Programming (ASP) 2. Semantics
Theorem 2.11 (Confluent Calculus for WFS)
The calculus consisting of these four transformations isconfluent, i.e. whenever we arrive at an irreducibleprogram, it is uniquely determined. The order of thetransformations does not matter.For finite propositional programs, it is also stronglyterminating for fair sequences: any program P is thereforeassociated a unique normalform respPq. The wellfoundedsemantics of P can be read off from respPq as follows
WFSpPq � tA : AÐ P respPquY tnot A : A is in no head of respPqu
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 171/456
2. Answer Set Programming (ASP) 2. Semantics
What about van Gelder’s Example 2.4winspxq Ðmove_from_to(x,y), not wins(y)move_ f rom_topa,bq, move_ f rom_topb,aq,move_ f rom_topb,cq, move_ f rom_topc,dq.
Here we have no problems with floundering, butusing SLDNF we get an infinite sequence ofoscillating SLD-trees (none of which finitelyfails).
WFSpPgameq � tnot winspcq,winspbq,not winspaqu
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 172/456
2. Answer Set Programming (ASP) 2. Semantics
Contradictions
Some semantics associates to a program P a set of2-valued models. Such semantics satisfy
Principle 2.5 (Elimination of Contradictions)
Suppose a program P has a rule which contains the sameatom A and not A in its body. Then we can eliminate this rulewithout changing the semantics.
Contradiction: A Ð C,D,notC
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 173/456
2. Answer Set Programming (ASP) 2. Semantics
Theorem 2.12 (Answer Sets)
There exists the weakest semantics satisfying our fiveprinciples Elimination of Tautologies, Subsumption,Reduction, GPPE and Elimination of Contradictions.This semantics assigns to each program P a set of answersets, also called stable models.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 174/456
2. Answer Set Programming (ASP) 2. Semantics
Answer Sets
The underlying idea is that any atom in an intended modelshould have a definite reason to be true or false.Gelfond-Lifschitz transformation: for a program P and amodel N � BP we define
PN :� truleN : rule P Pu
where rule :� AÐ B1, . . . ,Bn,notC1, . . . ,notCm istransformed as follows
pruleqN :�"
AÐ B1, . . . ,Bn, if @ j : C j R N,t, otherwise.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 175/456
2. Answer Set Programming (ASP) 2. Semantics
Note that PN is always a definite program. Wecan therefore compute its least Herbrand modelMPN and check whether it coincides with themodel N with which we started:Definition 2.13 (Answer Sets)
N is called an answer seta of P, if MPN � N.aNote that we only consider Herbrand models.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 176/456
2. Answer Set Programming (ASP) 2. Semantics
Relationship between ASP and WFS
They are based on similar principles.Stable models N extend WFS: l PWFSpPqimplies N |ù l.If WFS(P) is two-valued, then WFS(P) is theunique stable model.
For Example 2.4 we have two stable models:twinspaq, winspcqu and twinspbq, winspcqu andtherefore
WFSpPq � twinspcq, not winspdqu �£
N a stable model of P
N .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 177/456
2. Answer Set Programming (ASP) 2. Semantics
Example 2.14 (Reasoning by cases)
Psplitting : a Ð not bb Ð not ap Ð ap Ð b
Although neither a, nor b can be derived in any semanticsbased on two-valued models (as ASP for example), thedisjunction a_b, thus also p, is true. In this way theexample is handled by the SLDNF semantics, too. WFS(P),however, is empty; if the WFS cannot decide between a ornot a, then a is undefined.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 178/456
2. Answer Set Programming (ASP) 2. Semantics
Example 2.15 (ASP is not Goal-Oriented)
Prelpaq : a Ð not bb Ð not a P : a Ð not b
b Ð not ap Ð not pp Ð a
Prelpaq is the subprogram of P that consists of all rules thatare relevant to answer the query ?- a. It has two stablemodels tau and tbu — a is not true in all of them. But theprogram P has the unique stable model tp,au, so a is truein all stable models of P.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 179/456
2. Answer Set Programming (ASP) 3. Properties
2.3 Properties
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 180/456
2. Answer Set Programming (ASP) 3. Properties
The results above also apply to disjunctive programs.Some modifications have to be made (the uniqueHerbrand model of a definite program has to be replacedby the set of all minimal modles of a positive disjunctiveprogram). We just state the following
Theorem 2.16 (Characterization of ASP)
Let SEM be a semantics for disjunctive logic programssatisfying GPPE, Elimination of Tautologies, andElimination of Contradictions.Then: SEMpPq � ASPpPq.Moreover, ASP is the weakest semantics satisfyingthese properties.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 181/456
2. Answer Set Programming (ASP) 3. Properties
Declarativeness
Lemma 2.17 (ASP is Declarative)In contrast to PROLOG, ASP programs do neither depend onthe (1) order of program clauses, nor on the (2) order ofliterals within each clause.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 182/456
2. Answer Set Programming (ASP) 3. Properties
Killer-clausesFor quite some time, the problem of ASP to handle oddloops was considered a drawback: Programs with rules ofthe form pÐ not p (and where p can not be derivedotherwise) do not possess answer sets.
Lemma 2.18 (Constraints)Suppose the program P does not contain the predicate p.Then the answer sets of the programPYtpÐ not p,q1, . . .qn,not r1, . . . ,not rmu are exactly those ofP except the answer sets that contain tq1, . . .qnu and do notcontain tr1, . . .rmu.Thus adding this clause can be seen as a constraint and canbe used for efficient computation.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 183/456
2. Answer Set Programming (ASP) 3. Properties
Example 2.19 (3-colorability)Given an undirected graph, assign 3 colors to the nodes,such that no adjacent nodes have the same color.Using the predicates nodepxq, edgepx,yq we can write thefollowing program:
colorpX ,rq_ colorpX ,gq_ colorpX ,bq :� nodepXq:� edgepX ,Y q,colpX ,Cq,colpY,Cq
The first rule can also be written as follows (if nodisjunction _ is available):
colorpX ,rq :� nodepXq,not colorpX ,gq,not colorpX ,bqcolorpX ,bq :� nodepXq,not colorpX ,rq,not colorpX ,gqcolorpX ,gq :� nodepXq,not colorpX ,rq,not colorpX ,bq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 184/456
2. Answer Set Programming (ASP) 3. Properties
Example 2.20 (Hamiltonian Path)The input is a directed graph represented by predicatesnodep�q (unary), arcp�, �q (binary) and a starting nodestartp�q (unary). Output should be a path that starts withthe start node and contains all nodes of the graph (eachexactly once).
inPathpX ,Y q_outPathpX ,Y q :� arcpX ,Y q:� inPathpX ,Y q, inPathpX ,Y 1q,Y ¡ Y 1:� inPathpX ,Y q, inPathpX1,Y q,X ¡ X1:� nodepXq,not reachedpXq
reachedpXq :� startpXqreachedpXq :� reachedpY q, inPathpY,Xq
The first rule guesses all possibilities, the remaining rulescheck whether the guess was correct and a hamiltonianpath was found.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 185/456
2. Answer Set Programming (ASP) 3. Properties
Example 2.21 (Greatest Common Divisor (2), see alsoSlide 142)
Given two integers n,m, how can we compute the greatestcommon divisor?
% Declare when T divides NdivisorpT,Nq :� #intpT q,#intpNq,#intpMq,N � T �M.% Declare common divisorscdpT,N1,N2q :� divisorpT,N1q,divisorpT,N2q.% Single out non-maximal common divisors Tlarger_cdpT,N1,N2q :� cdpT,N1,N2q,cdpT 1,N1,N2q,T T 1.% Apply double negation: take non non-maximal divisorgcdpT,N1,N2q :� cdpT,N1,N2q,not larger_cdpT,N1,N2q.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 186/456
2. Answer Set Programming (ASP) 3. Properties
Definition 2.22 (Search Problem)
A search problem S is a pair xInst,tSolI : I P Instuy where1 Inst is an (infinite) set of finite objects, calledinstances, and
2 for each I, SolI is a finite set (called set of solutions).
An algorithm A solves a search problem S , if thefollowing holds: for each I P Inst"
A returns “No” , if SolI �H;A returns any S P SolI, otherwise.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 187/456
2. Answer Set Programming (ASP) 3. Properties
Definition 2.23 (NP-Search)
A search problem is in the class NP-Search, if there is anondeterministic Turingmachine that runs in polynomialtime and satisfiesfor every instance I P Inst, exactly SolI is written on thetape (when accepting computations for I terminate).
NP is usually defined as the class of decision problems.Obviously, all decision problems are contained inNP-Search.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 188/456
2. Answer Set Programming (ASP) 3. Properties
Separating Data from the Problem
We would like to separate the search problem itself fromthe representation of its instances (see Slide 31).
Definition 2.24 (Uniform Representation)
A search problem S can be represented uniformly inASP, if1 there is a finite program P,2 for each instance I P Inst a finite set MI of groundatoms (and this set can be efficiently encoded)
3 such that SolI � ASPpPYMIq or the solutions can beefficiently reconstructed from the answer sets ofPYMI.
Sudoku
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 189/456
2. Answer Set Programming (ASP) 3. Properties
Principle 2.6 (ASP Paradigm)
The set of all answer sets of a programrepresents the solution of a problem.
nondisjunctive: The class of problems that canbe uniformly represented in ASP isNP-search.
disjunctive: The class of problems that can beuniformly represented in ASP isΣ2-search.
Note that there are no function symbols inASP.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 190/456
2. Answer Set Programming (ASP) 3. Properties
Very important properties of ASP:Variables: although there are no function
symbols, variables are allowed (but thegrounding is finite),
Predicates: also predicates are allowed andfacilitate concise formalizations,
Modularity: global models should becomposed of local components,
Semantics: there should be an intuitivemethodology to formalise problems.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 191/456
2. Answer Set Programming (ASP) 4. ASP engines
2.4 ASP engines
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 192/456
2. Answer Set Programming (ASP) 4. ASP engines
Many links can be obtained fromWASP: Working Group on Answer SetProgramming (2001-2005)http://wasp.unime.it(FP 6: IST-FET 2001-37004)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 193/456
2. Answer Set Programming (ASP) 4. ASP engines
Definition 2.25 (AnsProlognot , AnsProlog_ ,AnsProlog_ ,not )
The language AnsProlognot consists of rules of the form
AÐ B1, . . . ,Bm,notC1, . . .notCn
where A,B1, . . . ,Bm,C1, . . .Cn are positive atoms which may contain freevariables, like ppX ,Y,cq). When A is absent (resp. identical to K): thenwe call the language AnsProlognot ,K.The language AnsProlog_ consist of rules of the form
A1_ A2_ . . ._ An Ð B1, . . . ,Bm,notC1, . . .notCn
where Ai,Bi,Ci are positive atoms, which may contain free variables,like ppX ,Y,cq). Similar to the above, we define AnsProlog_ ,K.Finally the language AnsProlog_ ,not (resp. AnsProlog_ ,not ,K) consistsof rules where we allow both disjunctions in the head as well asnegations in the body.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 194/456
2. Answer Set Programming (ASP) 4. ASP engines
Some implementations
SModels: http://www.tcs.hut.fi/Software/smodels/
DLV: http://www.dbai.tuwien.ac.at/proj/dlv/
GnT: http://www.tcs.hut.fi/Software/gnt/
Cmodels (1, 2): http://www.cs.utexas.edu/users/tag/cmodels/
ASSAT: http://assat.cs.ust.hk/
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 195/456
2. Answer Set Programming (ASP) 4. ASP engines
aspps: http://www.cs.engr.uky.edu/ai/aspps/
NoMore: http://www.cs.uni-potsdam.de/.linke/nomore/
ccalc: http://www.cs.utexas.edu/users/tag/cc/
XASP: distributed with XSB v2.6http://xsb.sourceforge.net
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 196/456
2. Answer Set Programming (ASP) 4. ASP engines
Disjunction: DLV is designed for fullAnsProlog_ ,not ,K, while smodels isdesigned for AnsProlognot ,K. smodelshas only primitive functionality for _.
Grounding: Both systems compute intelligentgroundings, trying to avoidunnecessary instances.
Relational DB: DLV can be seen as an extensionto SQL3 and thus has functionality foranswering SQL3 queries.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 197/456
2. Answer Set Programming (ASP) 4. ASP engines
Queries: DLV allows brave and cautiousreasoning: queries can be specifiedand tested for truth in in at least oneor in all answer sets.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 198/456
2. Answer Set Programming (ASP) 4. ASP engines
Allowedness: In smodels each variable in a rule mustoccur in a positive domain predicate on theright hand side of this rule. A domain predicateis one with the following property: each pathin the dependency graph of the programstarting with this predicate does not gothrough a negative cycle. This property is alsocalled strongly range restricted. The idea isthat domain predicates can be efficientlycomputed (no recursion through negation).In DLV this is more relaxed: each variable mustoccur in a positive predicate on the right handside.
Special Constraints: smodels allows weight and cardinalityconstraints, while DLV allows weak constraints.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 199/456
2. Answer Set Programming (ASP) 4. ASP engines
Arithmetic: smodels allows rules of the formppT �1q Ð ppT q.In DLV this must be written asppT 1q Ð ppT q,T 1 � T �1.
Classical Negation: In our definition of an answer set(Definition 2.13) and also in the definition ofAnsProlog_ ,not ,K, we did not allow atoms thatare classically negated. In fact, in severalformalisations we used predicates of the formnot_predicate which, intuitively represented thenegation of the predicate predicate. We did thismainly to avoid any confusion with classicalnegation.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 200/456
2. Answer Set Programming (ASP) 4. ASP engines
Cardinality Constraints: smodels allowscardinality constraints to ensure thatan answer set contains at least and atmost a certain number of prespecifiedatoms.
1 {a,b,notc} 2
This means that we are looking foranswer sets which contain at least onebut at most two of the atoms a,b, not c.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 201/456
2. Answer Set Programming (ASP) 4. ASP engines
Formalizing Sudoku
smodels uses the following constructs:1 row(0..8) is a shorthand for row(0),row(1), ..., row(8).
2 val(1..9) is a shorthand for val(1),val(2), ..., val(9).
3 The constants 1, ..., 9 will be treated asnumbers (so there are operations available toadd, subtract or divide them).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 202/456
2. Answer Set Programming (ASP) 4. ASP engines
The theoryppX,Y,5q :- rowpXq,colpYq
means that the whole grid is filled with 5’sand only with 5's: eg. ppX ,Y,1q is true for allX ,Y , as well as ppX ,Y,2q etc. because of thePrinciple 2.1 that holds for ASP.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 203/456
2. Answer Set Programming (ASP) 4. ASP engines
More constructs in smodels1 { p(X,Y,A) : val(A) } 1
:- row(X), col(Y)this makes sure that in all entries of the grid,exactly one number (val()) is contained.1 { p(X,Y,A) : row(X) : col(Y)
: eq(div(X,3), div(R,3)): eq(div(Y,3), div(C,3) } 1
:- val(A), row(R), col(C)this rule ensures that in each of the 9 squareseach number from 1 to 9 occurs only once.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 204/456
2. Answer Set Programming (ASP) 4. ASP engines
Sudoku formalization
row(0..8).col(0..8).val(1..9).
1 { p(X,Y,A) : val(A) } 1 :- row(X), col(Y).1 { p(X,Y,A) : row(X) } 1 :- val(A), col(Y).1 { p(X,Y,A) : col(Y) } 1 :- row(X), val(A).
1 { p(X,Y,A) : row(X) : col(Y): eq(div(X,3),div(R,3)) : eq(div(Y,3),div(C,3)) } 1:- row(R), col(C), val(A).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 205/456
2. Answer Set Programming (ASP) 5. References
2.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 206/456
2. Answer Set Programming (ASP) 5. References
[Brass and Dix, 1999] Stefan Brass and Jürgen Dix.Semantics of (disjunctive) logic programs based on partialevaluation.J. Log. Program., 40(1):1–46, 1999.
[Brewka and Dix, 2005] Gerhard Brewka and Jürgen Dix.Knowledge representation with extended logic programs.In D. Gabbay and F. Guenthner, editors, Handbook ofPhilosophical Logic, volume 12, chapter 1, pages 1–85. ReidelPubl., 2. edition, 2005.Shortened version also appeared in Dix, Pereira, Przymusinski(Eds.), Logic Programming and Knowledge Representation,Springer LNAI 1471, pages 1–55, 1998.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 207/456
2. Answer Set Programming (ASP) 5. References
[Eiter et al., 2003] Thomas Eiter, Wolfgang Faber, Nicola Leone,Gerald Pfeifer, and Axel Polleres.A logic programming approach to knowledge-state planning, ii:The dlvk system.Artif. Intell., 144(1-2):157–211, 2003.
[Marek and Truszczynski, 1998] Victor W. Marek and MiroslawTruszczynski.Stable models and an alternative logic programming paradigm.CoRR, cs.LO/9809032, 1998.
[Niemelä, 1999] Ilkka Niemelä.Logic programs with stable model semantics as a constraintprogramming paradigm.Ann. Math. Artif. Intell., 25(3-4):241–273, 1999.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 208/456
2. Answer Set Programming (ASP) 5. References
[Simons et al., 2002] Patrik Simons, Ilkka Niemelä, and TimoSoininen.Extending and implementing the stable model semantics.Artif. Intell., 138(1-2):181–234, 2002.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 209/456
3. Modal Logic
Chapter 3. Modal Logic
Modal Logic3.1 Reasoning about Knowledge3.2 Kripke Semantics3.3 Reasoning about Muddy Children3.4 Axioms for Modal Logics3.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 210/456
3. Modal Logic
The first two lectures showed how classical logic anda nonmonotonic version of logic programming canbe used to describe/specify problems and their(desired) solutions.Rephrasing slightly the above: we saw how(nonmonotonic) logic can be used to describe what weknow about the world. The main intuition is that whatwe know is described by a closed set of classicalformulae (in other words, by a theory).Logic programs are used to represent these theoriesin a compact way. The actual knowledge staterepresented by program P is, by definition, the set ofanswer sets of P.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 211/456
3. Modal Logic
We have also seen how these descriptions can be set towork, i.e., used to compute actual models that satisfyour needs.
In this lecture, we present another logic-basedtradition of modeling the world (and reasoning aboutit), namely modal logic. We focus especially onepistemic logic, i.e., the modal logic of knowledge.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 212/456
3. Modal Logic
Modal logic is an extension of classical logic bynew connectiveslll and ♦♦♦: necessity andpossibility.
lllp: p is necessarily true♦♦♦p: p is possibly true
Independently of the precise definition:
♦pØ l p
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 213/456
3. Modal Logic
Definition 3.1 (Modal Logic with nmodalities)
The language Lmodaln of modal logic with nmodal operators l1, . . . ,ln is the smallest setcontaining the propositional constants of L, andwith formulae ϕ,ψ also the formulaeliϕ, ϕ,ϕ^ψ. We treat _,Ñ,Ø,♦ as macros(defined as usual).
Note that the l operators can be nested:
pl1l2l1pq _ l3 p
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 214/456
3. Modal Logic
Modal logic can be translated to classical logic;
. . . but it looks horribly UGLY then;
. . . and in most cases it’s not automatizableany more.
Remember Frege’s notation of predicate logic:
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 215/456
3. Modal Logic
Good to know:MSPASS is a theorem prover implementingmany modal logics,also description logics, relational calculus, etcbuilt upon SPASS, a resolution prover forfirst-order logic with equality,check outhttp://www.cs.man.ac.uk/~schmidt/mspass/.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 216/456
3. Modal Logic 1. Reasoning about Knowledge
3.1 Reasoning about Knowledge
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 217/456
3. Modal Logic 1. Reasoning about Knowledge
Example 3.2 (Muddy children – Shoham’s version)A group of n children enters the house after having playedin the mud outside. They are greeted by their father, whonotices that k of them have mud on their foreheads (no kidcan see whether she herself has a muddy forehead, butthey can see all other foreheads).Can the kids determine by pure thinking wether theyhave a muddy forehead?The father announces: At least one of you has mud onher forehead.He also says If you know (can prove) that your forehead ismuddy, then raise your hands now.Nothing happens. The father keeps repeating thequestion.After exactly k rounds, all the children with muddyforeheads raise their hands.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 218/456
3. Modal Logic 1. Reasoning about Knowledge
How is that possible? The announcement of thefather does not reveal anything, or does it?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 219/456
3. Modal Logic 1. Reasoning about Knowledge
Definition 3.3 (Partition Model)
An n-agent partition model over language L is a tuple
xW ,I1, . . . ,Iny, where
W : a set of possible worlds;w PW : an L-structure (each L sentence ϕ is either true
or false in w);Ii: each Ii is a partition ofW :
Ii � tWi1,Wi2, . . . ,Wiru withWi j XWik �H forj � k and
�1¤ j¤r Wi j �W .
The worlds inW can be propositional valuations or evenfirst-order structures. In this lecture, we will mainlyconsider the propositional version.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 220/456
3. Modal Logic 1. Reasoning about Knowledge
Additionally we define:Iipwq: all worlds in partition Ii containingworld w
Iipwq :� tw1 : w PWi j and w1 PWi ju
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 221/456
3. Modal Logic 1. Reasoning about Knowledge
Example: Robots and Carriage
1 2
1
2
1
2
pos0
pos1pos2
1 21
2
1
2
pos0
pos1pos2
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 222/456
3. Modal Logic 1. Reasoning about Knowledge
Example: Robots and Carriage
1 2
1
2
1
2
pos0
pos1pos2
1 2
1
2
1
2
pos0
pos1pos2
1 2
1
2
1
2
pos0
pos1pos2
q0
q2 q1
pos0
pos1pos2
q0
q2 q1
1pos0
pos1pos2
q0
q2 q1
1 2pos0
pos1pos2
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 223/456
3. Modal Logic 1. Reasoning about Knowledge
How can we formalise the notion of one agentknowing something? And reason about whatagents know and draw conclusions?
We introduce new operators Ki
Kiϕ: “agent i knows that ϕ holds”
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 224/456
3. Modal Logic 1. Reasoning about Knowledge
Definition 3.4 (Semantics for partition models)
Let A � pW ,I1, . . . ,Inq be an n-agent partitionmodel over L.for ϕ P L: A ,w |ù ϕ if and only if w |ù ϕ,A ,w |ùKiϕ if and only if for all worlds w1, ifw1 P Iipwq then A ,w1 |ù ϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 225/456
3. Modal Logic 1. Reasoning about Knowledge
Example: Robots and Carriage
q0
q2 q1
1 2pos0
pos1pos2
pos1 Ñ K1pos1pos2 Ñ K1pos2pos2 Ñ K1 pos1pos2 Ñ K2K1 pos1pos2 Ñ K1K2K1 pos1
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 226/456
3. Modal Logic 2. Kripke Semantics
3.2 Kripke Semantics
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 227/456
3. Modal Logic 2. Kripke Semantics
A slight generalisation of partition models leadsto Kripke semantics.
How can one look at a partition model? It is likea set of equivalence classes: for agent i, allworlds in one partition are equivalent.
So let’s generalise and introduce a binaryrelation R on all worlds: w1Rw2 meaning thatworld w2 can be accessed (is reachable) fromworld w1.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 228/456
3. Modal Logic 2. Kripke Semantics
Definition 3.5 (Kripke Structure)
A Kripke structurexW ,Ry
is a set of possible worldsW plus a binary relationR�W �W (the accessibility relation)
Note that:Elements ofW are now abstract entities: we assumethat they do not carry any internal structure!Still, we would like to see them as classical (e.g.,propositional) models. How can that be achieved?Let Π be the set of all propositional symbols. Apropositional model can be represented as a list ofpropositions πpwq �Π that hold in world w.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 229/456
3. Modal Logic 2. Kripke Semantics
Definition 3.6 (Kripke Model / Possible World Model)
The truth of formulae is evaluated with respectto a Kripke model (possible world model):
xW ,R,πy,
that is, a Kripke structure plus a valuation ofpropositions π : W Ñ P pΠq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 230/456
3. Modal Logic 2. Kripke Semantics
Definition 3.7 (Kripke Semantics of Modal Logic)
Given a Kripke model M � xW ,R,πy, and a worldw PW , we define the satisfaction relationM,w |ù φ as follows:
M,w |ù p iff p P πpwqM,w |ù ϕ^ψ iff M,w |ù ϕ and M,w |ù ψ
M,w |ù ϕ iff not M,w |ù ϕ
M,w |ùlϕ iff for every w1 PW with wRw1 wehave that M,w1 |ù ϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 231/456
3. Modal Logic 2. Kripke Semantics
What if we want multiple modalitiesl1, . . . ,lk?
Then, we need multiple accessibility relationsR1, . . . ,Rk �W �W , one per modality.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 232/456
3. Modal Logic 2. Kripke Semantics
Definition 3.8 (Kripke Semantics of Multi-modal Logic)
Given a Kripke model M � xW ,R1, . . . ,Rk,πy,and a world w PW , we define:
M,w |ùliϕ iff for every w1 PW with wRiw1 wehave that M,w1 |ù ϕ.
For knowledge modalities Ki, we assume thatthe corresponding relation Ri is anequivalence.Note: Ki is a “modal box” operator!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 233/456
3. Modal Logic 2. Kripke Semantics
Example: Robots and Carriage
21q0
q2 q1
pos0
pos1pos2
1q0
q2 q1
pos0
pos1pos2
q0
q2 q1
pos0
pos1pos2
1 1
2q0
q2 q1
1 1
pos0
pos1pos2
q0
q2 q1
1 1
22
pos0
pos1pos2
pos1 Ñ K1pos1pos2 Ñ K1pos2pos2 Ñ K1 pos1pos2 Ñ K2K1 pos1pos2 Ñ K1K2K1 pos1
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 234/456
3. Modal Logic 3. Reasoning about Muddy Children
3.3 Reasoning about MuddyChildren
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 235/456
3. Modal Logic 3. Reasoning about Muddy Children
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
mm
c
mm
c
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
mc
m
3
3
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
mud1 P πpwq iff w� mxxmud2 P πpwq iff w� xmxmud3 P πpwq iff w� xxm
M,mmc |ùmud1^mud2^ mud3
M,mmc |ù K1mud1^K1mud2
M,mmc |ù K1K3mud2^K1 K2mud2
. . .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 236/456
3. Modal Logic 3. Reasoning about Muddy Children
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
3
3
1
2
mm
c
mm
c
mm
m
mm
m1
2
cm
m
cm
m
mc
m1
2
3
3
3
mm
c
mm
c
mm
m
mm
m1
2
cm
m
cm
m
mc
m
Father: “At least one of you is muddy” K1mud1^ K2mud2^ K3mud3
Father: “If you know that you’remuddy, raise your hand”
Nothing happensK1mud1^K2mud2^ K3mud3
Father: “If you know that you’remuddy, raise your hand”
1 and 2 raise their hands!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 237/456
3. Modal Logic 4. Axioms for Modal Logics
3.4 Axioms for Modal Logics
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 238/456
3. Modal Logic 4. Axioms for Modal Logics
As in classical logic, one can ask about acomplete axiom system. Is there a calculus thatallows to derive all sentences true in all Kripkemodels?
Definition 3.9 (System K)
The system K is an extension of thepropositional calculus by the axiom
Axiom K plϕ^lpϕÑ ψqq Ñlψ
and the inference rule
(Necessitation)ϕ
lϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 239/456
3. Modal Logic 4. Axioms for Modal Logics
Theorem 3.10 (Soundness/completeness of System K)
System K is sound and complete with respect toarbitrary Kripke models.
If we allow nmodalities, the theorem as well asthe definitions extend in an obvious way. Thecalculus is then called System Kn to account forthe nmodalities.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 240/456
3. Modal Logic 4. Axioms for Modal Logics
Note that we have not assumed anyproperties of the accessibility relation R: it isjust any binary relation.
Assuming that R is an equivalence relation,which additional statements (axioms) aretrue in all Kripke models?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 241/456
3. Modal Logic 4. Axioms for Modal Logics
To which axioms do the following propertieslead?Reflexivity: xRx for all x.Transitivity: xRy and yRz implies xRz for all x,y,z.Euclidean: xRy and xRz implies yRz for all for all
x,y,z.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 242/456
3. Modal Logic 4. Axioms for Modal Logics
Lemma 3.11
A binary relation is an equivalence relation if andonly if it is reflexive, transitive and euclidean.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 243/456
3. Modal Logic 4. Axioms for Modal Logics
Definition 3.12 (Extending K by Axioms D, T, 4,5)The system K is often extended by (a subset of) thefollowing axioms:
K pKiϕ^KipϕÑ ψqq ÑKiψ [logical omniscience]D Kipϕ^ ϕq [consistency]T KiϕÑ ϕ [truth]4 KiϕÑKiKiϕ [positive introspection]5 KiϕÑKi Kiϕ [negative introspection]
The system consisting of KT45 is also called S5.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 244/456
3. Modal Logic 4. Axioms for Modal Logics
Theorem 3.13 (Sound/complete Subsystems of KDT45)
Let X be any subset of tD,T,4,5u and let X be anysubset of tserial,re f lexive, transitive,euclideanucorresponding to X.Then KYX is sound and complete with respect toKripke structures the accessibility relation of whichsatisfies X .
Corollary 3.14 (Sound-, completeness of KT45 (S5))
System KT45 is sound and complete with respectto Kripke structures with equivalenceaccessibility relations.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 245/456
3. Modal Logic 4. Axioms for Modal Logics
Exercise: Show that1 The axiom D follows from KT45.2 Show that KD45 is not equivalent to K45:axiom D does not follow from K45.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 246/456
3. Modal Logic 4. Axioms for Modal Logics
Up to now we were thinking of Kiϕ (the boxoperator li) as agent i knows that ϕ. What ifwe interpret the operator as belief?Under such an interpretation axiom T has to bedropped. But all other axioms make sense.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 247/456
3. Modal Logic 5. References
3.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 248/456
3. Modal Logic 5. References
[aqvist84] Åqvist, L. (1984).Deontic logic.In D. M. Gabbay and F. Guenther (Eds.), Handbook ofPhilosophical Logic, Vol II, pp. 605–714. Reidel.
[Fagin et al. 1995] Fagin, R., Halpern, J. Y., Moses, Y. & Vardi, M. Y.Reasoning about Knowledge.MIT Press: Cambridge, MA.
[fipa] Foundation for Intelligent Physical Agents.FIPA home page.http://www.fipa.org/.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 249/456
3. Modal Logic 5. References
[fipa-acl] Foundation for Intelligent Physical Agents (2002).FIPA ACL message structure specification.Approved for standard, 2002-12-06.http://www.fipa.org/specs/fipa00061/.
[HiDBoHoMe98] Hindriks, K. V., F. S. de Boer, H. Hoek, and J.-J. C.Meyer (1998).Formal semantics of the core of AGENT-0.In ECAI’98 Workshop on Practical Reasoning and Rationality, pp.20–29.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 250/456
3. Modal Logic 5. References
[kripke63b] Kripke, S. (1963a).Semantical analysis of modal logic I. Normal propositionalcalculi.Zeitschrift fur math. Logik und Grundlagen der Mathematik 9,67–96.
[kripke63a] Kripke, S. (1963b).Semantical considerations on modal logic.Acta Philosophica Fennica 16, 83–94.
[kripke65] Kripke, S. (1965).Semantical analysis of modal logic II. Non-normal modalpropositional calculi.In Addison, Henkin, and Tarski (Eds.), The theory of models,Amsterdam, North-Holland, pp. 206–220.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 251/456
4. Action and Time
Chapter 4. Action and Time
Action and Time4.1 Dynamic Logic4.2 Temporal Logic4.3 Linear Time Logic4.4 Computation Tree Logic4.5 ATL4.6 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 252/456
4. Action and Time
In the previous lecture, we presented the basic idea ofmodal logic, and showed that it can be used to reasonabout agents’ knowledge in a natural way.Now, we show that modal logic is a genericframework that can be used to reason about otherdimensions of systems, too.In particular, we show how one can use modal logic toreason about time, action, and strategic abilities ofagents.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 253/456
4. Action and Time
First, we present an overview of Propositional DynamicLogic, which can be used for reasoning about actionsand their outcomes.Then, we switch to temporal logic, where actions arenot mentioned explicitly, but instead one can usethem to reason about evolution of systems over alonger (possibly infinite) timeline. We present twomost popular variants of temporal logic: linear timelogic LTL and branching time logic CTL.Finally, we briefly present the logic of ATL whichextends branching-time temporal logic with the gametheoretical notion of a strategy.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 254/456
4. Action and Time
Modal logic is a generic framework.
Various modal logics:knowledge epistemic logic,beliefs doxastic logic,obligations deontic logic,actions dynamic logic,time temporal logic,ability strategic logic,and combinations of the above
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 255/456
4. Action and Time
Until now:Several operators Ki, each definesan epistemic/doxastic relation onworlds.Description of static systems: nopossibility of change
But:computational systems aredynamic!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 256/456
4. Action and Time 1. Dynamic Logic
4.1 Dynamic Logic
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 257/456
4. Action and Time 1. Dynamic Logic
1st idea: Consider actions or programs α. Eachsuch α defines a transition (accessibilityrelation) from worlds into worlds.
2nd idea: We need statements about theoutcome of actions:rαsϕ: “after every execution of α,ϕ holds,xαyϕ: “after some executions of α,ϕ holds.
As usual, xαyϕ� rαs ϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 258/456
4. Action and Time 1. Dynamic Logic
3rd idea: Programs/actions can be combined(sequentially, nondeterministically,iteratively), e.g.:rα;βsϕ
would mean “after every execution ofα and then β, formula ϕ holds”.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 259/456
4. Action and Time 1. Dynamic Logic
Definition 4.1 (Labelled Transition System)
A labelled transition system is a pair
xQ,tαÝÑ: α P Luy
where Q is a non-empty set of states and L is anon-empty set of labels and for each α P L:
αÝÑ� Q�Q.
Definition 4.2 (Dynamic Logic: Models)
A model of propositional dynamic logic is givenby a labelled transition systems and anevaluation of propositions.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 260/456
4. Action and Time 1. Dynamic Logic
Definition 4.3 (Semantics of DL)
M ,s |ù rαsϕ iff for every t such that s αÝÑ t, we
haveM , t |ù ϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 261/456
4. Action and Time 1. Dynamic Logic
q0 q1
haltstart
waittry
wait
q0 q1
haltstart
waittry
wait
startÑ xtryyhaltstartÑ rtryshalt
startÑ xtryyrwaitshalt
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 262/456
4. Action and Time 1. Dynamic Logic
Definition 4.4 (Composite labels)
The set of labels forms a Kleene algebraxL, ;,YYY,���y. In addition, the set of labels containsconstructs of the form “ϕ?”, whenever ϕ is aformula not involving any modalities.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 263/456
4. Action and Time 1. Dynamic Logic
“;” means sequential composition,YYYmeans nondeterministic choice,���means finite iteration (regular expr.),rϕ?smeans test.
Thus we assume that the labels obey thefollowing conditions:
sα;βÝÑ t iff s α
ÝÑ s1 and s1βÝÑ t,
sαYβÝÑ t iff s α
ÝÑ t or sβÝÑ t,
s α�
ÝÑ t is the reflexive and transitive closure ofs αÝÑ t,
sϕ?ÝÑ s iff s |ùM ϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 264/456
4. Action and Time 1. Dynamic Logic
What has this to do with programs?
if ϕ then a else b pϕ?;aq Y p ϕ?;bq
while ϕ do a pϕ?;aq� ; ϕ?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 265/456
4. Action and Time 1. Dynamic Logic
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
fuel
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 266/456
4. Action and Time 1. Dynamic Logic
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
load
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 267/456
4. Action and Time 1. Dynamic Logic
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
(nofuel?;fuel)�(fuelOK?;load)
caRÑ rpno f uel?; f uelqYp f uelOK?; loadqscaR
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 268/456
4. Action and Time 2. Temporal Logic
4.2 Temporal Logic
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 269/456
4. Action and Time 2. Temporal Logic
Ideas:The accessibility relation can be seen asrepresenting time.time: linear vs. branching
start
start
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 270/456
4. Action and Time 2. Temporal Logic
Typical temporal operators
©ϕ ϕ is true in the nextmoment in timelϕ ϕ is true in all future moments♦ϕ ϕ is true in some future momentϕU ψ ϕ is true until the moment when ψ
becomes true
sendpmsg, rcvrq Ñ ♦receivepmsg, rcvrq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 271/456
4. Action and Time 2. Temporal Logic
Temporal logic was originally developed in orderto represent tense in natural language.
Within Computer Science, it has a significantrole in the formal specification and verificationof concurrent and distributed systems.
Much of this popularity has been achieved as anumber of useful concepts can be formally, andconcisely, specified using temporal logics, e.g.
safety propertiesliveness propertiesfairness properties
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 272/456
4. Action and Time 2. Temporal Logic
Safety:“something bad will not happen”“something good will always hold”
Typical examples:
l bankruptlpfuelOK_©fuelOKqand so on . . .
Usually: l ....
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 273/456
4. Action and Time 2. Temporal Logic
Liveness:“something good will happen”
Typical examples:
♦rich
rocketLondonÑ ♦rocketParis
and so on . . .
Usually: ♦....
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 274/456
4. Action and Time 2. Temporal Logic
Combinations of safety and liveness possible:
♦lrich
l♦rich fairness
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 275/456
4. Action and Time 2. Temporal Logic
Strong fairness:
“if something is attempted/requested, thenit will be successful/allocated”
Typical examples:lpattempt Ñ ♦successq
l♦attempt Ñ l♦success
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 276/456
4. Action and Time 2. Temporal Logic
Fairness:
Useful when scheduling processes,responding to messages, etc.Good for specifying properties of theenvironment.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 277/456
4. Action and Time 3. Linear Time Logic
4.3 Linear Time Logic
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 278/456
4. Action and Time 3. Linear Time Logic
Linear Time: LTL
LTL: Linear Time Logic
Reasoning about a particular computationof a systemTime is linear: just one possible future path isincluded!Models: paths
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 279/456
4. Action and Time 3. Linear Time Logic
Definition 4.5 (Models of LTL)
A model of LTL is a sequence of time moments(states). We call such models paths, and denotethem by λ.Evaluation of atomic propositions at particulartime moments is also needed.
Notation:λris: ith time momentλri . . . js: all time moments between i and jλri . . .8s: all timepoints from i on
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 280/456
4. Action and Time 3. Linear Time Logic
Important: computational vs. behavioral structure
System Computational str.
1 2
1
2
1
2
pos0
pos1pos2
q0
q2 q1
pos0
pos1pos2
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 281/456
4. Action and Time 3. Linear Time Logic
Important: computational vs. behavioral structure
Computational str. Behavioral str.
q0
q2 q1
pos0
pos1pos2
q0
q q0 0
q q q0 0 1
....
pos0
pos0
pos1
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 282/456
4. Action and Time 3. Linear Time Logic
LTL models are defined as behavioral structures!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 283/456
4. Action and Time 3. Linear Time Logic
Definition 4.6 (Semantics of LTL)
λ |ù p iff p is true at moment λr0s;λ |ù©ϕ iff λr1..8s |ù ϕ;λ |ù ♦ϕ iff λri..8s |ù ϕ for some i¥ 0;λ |ùlϕ iff λri..8s |ù ϕ for all i¥ 0;λ |ù ϕU ψ iff λri..8s |ù ψ for some i ¥ 0, and
λr j..8s |ù ϕ for all 0¤ j ¤ i.
Note that:lϕ� ♦ ϕ
♦ϕ� l ϕ
♦ϕ� JU ϕ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 284/456
4. Action and Time 3. Linear Time Logic
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�'�'
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�'[0]�'[0]
λ |ù ♦pos1
λ1 � λr1..8s |ù pos1pos1 P πpλ1r0sq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 285/456
4. Action and Time 3. Linear Time Logic
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[0.. ]��[0.. ]�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[0.. ]��[0.. ]�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[1.. ]��[1.. ]�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[1.. ]��[1.. ]�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[2.. ]��[2.. ]�
q0
....
pos0
q1
pos1
q2
pos2
q0
pos0
q1
pos1
q2
pos2
�[2.. ]��[2.. ]�
λ |ùl♦pos1
λr0..8s |ù ♦pos1λr1..8s |ù ♦pos1λr2..8s |ù ♦pos1
. . .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 286/456
4. Action and Time 4. Computation Tree Logic
4.4 Computation Tree Logic
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 287/456
4. Action and Time 4. Computation Tree Logic
Branching Time: CTL
CTL: Computation Tree Logic.Reasoning about possible computations of asystemTime is branching: we want all alternativepaths included!Models: states (time points, situations),transitions (changes)Paths: courses of action, computations.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 288/456
4. Action and Time 4. Computation Tree Logic
Path quantifiers: A (for all paths), E (there isa path);Temporal operators: © (nexttime), ♦(sometime), l (always) and U (until);
“Vanilla” CTL: every temporal operator mustbe immediately preceded by exactly one pathquantifier;CTL*: no syntactic restrictions;Reasoning in “vanilla” CTL can beautomatized.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 289/456
4. Action and Time 4. Computation Tree Logic
Definition 4.7 (CTL models: transition systems)
A transition system is a pair
xQ,ÝÑy
where:Q is a non-empty set of states,ÝÑ� Q�Q is a transition relation.
Note that, formally, transition relation is just amodal accessibility relation.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 290/456
4. Action and Time 4. Computation Tree Logic
Important: computational vs. behavioral structure
Computational str. Behavioral str.
q0
q2 q1
pos0
pos1pos2
q0
q q0 0 q q0 1
q q q0 1 1 q q q0 1 2q q q0 0 0 q q q0 0 1
.... ....
pos0
pos0
pos0 pos1
pos1
pos1
pos2
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 291/456
4. Action and Time 4. Computation Tree Logic
CTL models are defined as computationalstructures!
Definition 4.8 (Paths in a model)
A path λ is a sequence of states.A path must be full, i.e. either infinite, or endingin a state with no outgoing transition.
Usually, we assume that the transition relation isserial (time flows forever).Then, all paths are infinite.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 292/456
4. Action and Time 4. Computation Tree Logic
Example: Rocket and Cargo
A rocket and a cargo,The rocket can be moved between London(proposition roL) and Paris (proposition roP),The cargo can be in London (caL), Paris (caP),or inside the rocket (caR),The rocket can be moved only if it has its fueltank full (fuelOK),When it moves, it consumes fuel, and nofuelholds after each flight.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 293/456
4. Action and Time 4. Computation Tree Logic
Example: Rocket and Cargo
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
roLÑ E♦roP
AlproL_ roPq
roLÑ A© proPÑ nofuelq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 294/456
4. Action and Time 4. Computation Tree Logic
Definition 4.9 (Semantics of CTL*: state formulae)
M,q |ù Eϕ iff there is a path λ, starting from q,such that M,λ |ù ϕ;
M,q |ù Aϕ iff for all paths λ, starting from q, wehave M,λ |ù ϕ.
Definition 4.10 (Semantics of CTL*: path formulae)
Exactly like LTL!M,λ |ù©ϕ iff M,λr1...8s |ù ϕ;M,λ |ù ϕU ψ iff M,λri...8s |ù ψ for some i ¥ 0,
andM,λr j...8s |ù ϕ for all 0¤ j ¤i.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 295/456
4. Action and Time 4. Computation Tree Logic
Example: Rocket and Cargo
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
3
E♦caP
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 296/456
4. Action and Time 4. Computation Tree Logic
Exercise:
How to express that there is no possibility of adeadlock?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 297/456
4. Action and Time 5. ATL
4.5 ATL
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 298/456
4. Action and Time 5. ATL
ATL: What Agents Can Achieve
ATL: Agent Temporal Logic [Alur et al. 1997]Temporal logic meets game theoryMain idea: cooperation modalities
xxAyyΦ: coalition A has a collective strategy toenforce Φ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 299/456
4. Action and Time 5. ATL
xx jamesbondyy♦win:“James Bond has an infallible plan toeventually win”xx jamesbond,bondsgirlyyfunU shot:“James Bond and his girlfriend are able tohave fun until someone shoots at them”
“Vanilla” ATL: every temporal operatorpreceded by exactly one cooperationmodality;ATL*: no syntactic restrictions;
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 300/456
4. Action and Time 5. ATL
ATL Models: Concurrent Game Structures
Agents, actions, transitions, atomicpropositionsAtomic propositions + interpretationActions are abstract
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 301/456
4. Action and Time 5. ATL
Definition 4.11 (Concurrent Game Structure)
A concurrent game structure is a tupleM � xAgt,Q,π,Act,d,oy, where:
Agt: a finite set of all agentsQ: a set of statesπ: a valuation of propositionsAct: a finite set of (atomic) actionsd : Agt�QÑ P pActq defines actions availableto an agent in a stateo: a deterministic transition function thatassigns outcome states q1 � opq,α1, . . . ,αkq tostates and tuples of actions
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 302/456
4. Action and Time 5. ATL
Example: Robots and Carriage
1 2
1
2
1
2
pos0
pos1pos2
q0
q2 q1
pos0
pos1
wait,wait
wait,waitwait,wait
push,push
push,pushpush,push
push,w
ait
push,wait
push,w
ait
wait,push
pos2
wait,p
ush
wait,p
ush
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 303/456
4. Action and Time 5. ATL
Definition 4.12 (Strategy)
A strategy is a conditional plan.We represent strategies by functions sa : QÑ Act.
Function outpq,SAq returns the set of all pathsthat may result from agents A executingstrategy SA from state q onward.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 304/456
4. Action and Time 5. ATL
Definition 4.13 (Semantics of ATL)
M,q |ù xxAyyΦ iff there is a collective strategySA such that, for every path λ Poutpq,SAq, we have M,λ |ùΦ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 305/456
4. Action and Time 5. ATL
Example: Robots and Carriage
q0
q2 q1
pos0
pos1
wait,wait
wait,waitwait,wait
push,push
push,pushpush,push
push,w
ait
push,wait
wait,p
ush
push,w
ait
wait,push
wait,p
ush
pos2
q0
q2 q1
pos0
pos1
wait,wait
wait,waitwait,wait
push,push
push,pushpush,push
push,w
ait
push,wait
push,w
ait
wait,push
pos2
wait,p
ush
wait,p
ush
q0
q2 q1
pos0
pos1
wait,wait
wait,waitwait,wait
push,push
push,pushpush,push
push,w
ait
push,wait
wait,p
ush
push,w
ait
wait,push
wait,p
ush
pos2
wait
waitpush
q0
q2 q1
pos0
pos1
wait,waitwait
wait,wait wait,waitwait
push,push
push,pushpush,push
push
,wait
push
push,wait
wait
,push
wait
push,w
ait
wait,push
wai
t,push
wai
t
pos2
q0
q2 q1
pos0
pos1
wait,waitwait
wait,wait wait,waitwait
push,push
push,pushpush,push
push
,wait
push
push,wait
wait
,push
wait
push,w
ait
wait,push
wai
t,push
wai
t
pos2
q0
q2 q1
pos0
pos1
wait,waitwait,wait
wait,wait wait,waitwait,wait
push,push
push,pushpush,pushpush,push
push
,wait
push
,wait
push,wait
wait
,push
wait
,push
push,w
ait
wait,push
wai
t,push
wai
t,push
pos2
q0
q2 q1q1
pos0
pos1pos1
wait,waitwait,wait
wait,wait wait,waitwait,wait
push,push
push,pushpush,pushpush,push
push
,wait
push
,wait
push,wait
wait
,push
wait
,push
push,w
ait
wait,push
wai
t,push
wai
t,push
pos2
pos0 Ñ xx1yyl pos1
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 306/456
4. Action and Time 5. ATL
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
< >load ,nop ,fuel1 2
< >unload ,unload ,fuel1 2
< >nop ,nop ,1 2 nop3< >load ,unload ,1 2 nop3
< >nop ,unload ,load1 2 3
< >unload ,unload ,1 2 nop3
< >unload ,nop ,1 2 nop3
< >unload ,nop ,fuel1 2
< >load ,unload ,fuel1 2
< >nop ,nop ,fuel1 2
< >nop ,unload ,fuel1 2
< >nop ,nop ,load1 2 3< >load ,nop ,load1 2 3
< >load ,unload ,load1 2 3
< >load ,nop ,1 2 nop3
nofuelÑ xx3yylnofuel
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 307/456
4. Action and Time 5. ATL
Practical Importance of Temporal and Dynamic Logics:
Automatic verification in principle possible(model checking).Can be used for automated planning.Executable specifications can be used forprogramming.
Note:
When we combine time (actions, strategies) withknowledge (beliefs, desires, intentions,obligations...), we finally obtain a fairly realisticmodel of MAS.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 308/456
4. Action and Time 6. References
4.6 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 309/456
4. Action and Time 6. References
[Alur et al., 2002] Alur, R., Henzinger, T. A., and Kupferman, O.(2002).Alternating-time Temporal Logic.Journal of the ACM, 49:672–713.
[Emerson 1990] E. A. Emerson.Temporal and modal logic.Handbook of Theoretical Computer Science, volume B, 995–1072.Elsevier, 1990.
[Fisher 2006] Fisher, M. (2006).Temporal Logics.Kluwer.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 310/456
4. Action and Time 6. References
[Huth00] Huth, M. & Ryan, M.Logic in Computer Science: Modeling and reasoning aboutsystems.Cambridge University Press.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 311/456
5. Knowledge in Flux
Chapter 5. Knowledge in Flux
Knowledge in Flux5.1 Revising or Updating Beliefs?5.2 Updates of Logic Programs5.3 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 312/456
5. Knowledge in Flux
We have seen in the first lecture that although logicitself is static, it can be made dynamic with thesituation calculus: terms denote situations.Now we introduce the machinery of belief revision.Again, we take an abstract point of view andinvestigate which properties should (or not) besatisfied for a revision operator �: the AGM approach.While belief revision is suitable for changes in a staticworld, it is not for describing dynamically changingworlds: Updating is based on different principles.Both belief revision and updating are not well suitedfor nonmonotonic logics. Therefore we present amethod for updates of logic programs and a languageto express them.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 313/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
5.1 Revising or Updating Beliefs?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 314/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
The AGM approach
AGM: Alchourron/Gärdenfors/Makinson.Seminal paper in 1985: [Alchourrón et al.,1985].
Given: A (propositional or first-order) theory K, andsome new information φ.
Wanted: A revision operator � that revises a set ofbeliefs K in the light of new information φ.
Problem: If K |ù φ, then we have no problems:K �φ�CnpKq.If φ is consistent with K, then we can simplydefine K �φ�CnpKYtφuq.What to do when K |ù φ?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 315/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Example 5.1 (Swans: white or black?)α: All European swans are white.β: The bird caught in the trap is a swan.γ: The bird caught in the trap comes from Sweden.δ: Sweden is part of Europe.ε: The bird caught in the trap is white.
ε can be derived from the rest.Now we discover that the bird caught in the trap isblack!
This means we want to revise tα,β,γ,δu by ε.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 316/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Shall we give up α but keep some of itsconsequences?
All European swans except the one caught inthe trap are white.All European swans except some of theswedish are white.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 317/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Some assumptions
Closure: Belief sets K are logically closed:K �CnpKq.
Expansion: Add a sentence φ to K.K�φ :� tψ : KYtφu |ù ψu.
Contraction: Remove a sentence φ from K.K�φ: difficult! Principle of economy:no belief should be given upunneccessarily.
Revision: Revise K by φ. We assume that foreach K and φ there is a unique K �φ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 318/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Axioms about �
K �1: CnpK �φq � K �φ
K �2: φ P K �φ
K �3: K �φ� K�φ
K �4: If φ R K then K�φ� K �φ.K �5: K �φ is inconsistent if and only if φ is a
tautology.K �6: If |ù φØ ψ then K �φ� K �ψ.K �7: K � pφ^ψq � pK �φq�ψ
K �8: If ψ R K �φ, thenpK �φq�ψ� K � pφ^ψq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 319/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Axioms about �
K�1: CnpK�φq � K�φ
K�2: K�φ� KK�3: If φ R K then K�φ� K.K�4: If not |ù φ then φ R K�φ.K�5: If φ P K then K � pK�φq�φ.K�6: If |ù φØ ψ then K�φ� K�ψ.K�7: pK�φqXpK�ψq � K� pφ^ψq.K�8: If φ R K� pφ^ψq, then
K� pφ^ψq � K�ψ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 320/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Interdefinability of � and �
Harper identity: Define � using �:K�φ� pK � φqXK
Levi identity: Define � using �:K �φ� pK� φq�φ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 321/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Are our choices correct?
Theorem 5.2 (From � to � and back)
If a contraction function � satisfies K�1–K�4and K�6, then the revision function � defined bythe Levi identity satisfies K �1–K �6. If in additionK�7 or K�8 is satisfied, then so are K �7 or K �8.
If a revision function � satisfies K �1-K �6, thenthe contraction function � defined by the Harperidentity satisfies K�1-K�6. If in addition K �7 orK �8 is satisfied, then so are K�7 or K�8.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 322/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Problems with AGM (1)
Belief set vs base: Up to now: K �CnpKq. Butbeliefs are usually given by a finite setonly (a base). So there are basic beliefswhich, should be more persistent thanderived beliefs.
Katsuno/Mendelzon consider thenotion of a base, represented by onesingle formula and use anotheroperator � to distinguish it from �:
ψ�µ Ñ φ iff φ PCnptψuq �µ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 323/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Lemma 5.3 ([Katsuno and Mendelzon, 1992])
AGM postulates pK �1q�pK �8q formulated forfinite sets (bases) are equivalent to thefollowing1 ψ�µÑ µ,2 If ψ^µ is satisfiable then ψ�µØ ψ^µ.3 If µ is satisfiable then ψ�µ is also satisfiable.4 If ψØ ψ1 and µØ µ1 then ψ�µØ ψ1^µ1.5 pψ�µq^φ Ñ ψ� pµ^φq
6 If pψ�µq^φ is satisfiable, thenψ� pµ^φq Ñ pψ�µq^φ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 324/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Problems with AGM (2)
Revision vs update: Distinguish new informationabout a static world (revision) fromnew information on changes broughtabout by an agent (updating).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 325/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Example 5.4 (Updating [Winslett, 1988])
1 There is a book, a table and a magazine.2 Either the book or the magazine is on thetable, but not both.
Let β: the book is on the table, and µ: themagazine is on the table. Then a robot isordered to put the book on the table.According to K �4 (if φ R K then K�φ� K �φ),we should end up in the state Cnptβ, µuq.
But why conclude that the magazine is not onthe table?
This is called a dynamically changing world.Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 326/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Revision vs updates
We distinguish between revising a static worldand updating a dynamically changing world:Updating does not satisfy K �4.
However, updating satisfies the following:
pα^α1qfφ� pαfφq^pα1fφq
which is not valid in the AGM approach.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 327/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Problems with AGM (3)
Informational Economy: This tells us that we should keepas many beliefs as possible. But if we also insiston one single revised theory, this might betoo strong an assumption. Hans Rott provedthe following. Given a theory K and a formulaα we call a theory Γ with (1) Γ�CnpΓq � Fmland (2) α P Γ a candidate revision of K by α.
Lemma 5.5 (Rott)Let α P K and K1, K2 be two candidate revisions. Thenneither K1zK � K2zK nor K1zK � K2zK.
Therefore we can’t prefer one to the other.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 328/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Problems with AGM (4)
Violation of K �3: Suppose we interpret the revision of Kby α_β as all we know about the statementsα,β is that α_β. Then, if K � tαu (before therevision, we knew that α), then
K � pα_βq �Cnptα_βuq.
Therefore, under such an interpretation, eventhe following postulate (implied by K �3) isviolated:If γ P K then K � γ� K.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 329/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Problems with AGM (5)
Iteration: AGM did not consider any iteration of therevision process. This, however, introducesmany new problems. Should more recentinformation be handled differently fromolder one? What about revisions of the type:
pK�αq �α?
While it seems obvious at first sight, thatK�α�α� K, under the above interpretationof all we know is α, this axiom is certainly notfulfilled.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 330/456
5. Knowledge in Flux 1. Revising or Updating Beliefs?
Example 5.6 (Hansson)
Let K �CnptS,Duq, where Smeans Cleopatra had(at least) a son and D stands for Cleopatra had(at least) a daughter. Then you learn thatCleopatra had no children at all:CnptS,Duq�S_D. Finally you are told that shehad at least one child, but it is not knownwhether it was a boy or a girl (or several):
pCnptS,Duq�S_Dq �S_D.
Certainly, you should end up with CnptS_Duq,and not with the original CnptS,Duq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 331/456
5. Knowledge in Flux 2. Updates of Logic Programs
5.2 Updates of Logic Programs
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 332/456
5. Knowledge in Flux 2. Updates of Logic Programs
A logic program represents a static world. Byadding new facts, some dynamic change canbe incorporated, but only to a limited extent.What, if new knowledge emerges, that forcesus to change the underlying program? Thiscan be seen as an update of the program.Why not simply applying the theory of beliefrevision or updates (last section)? Theupdate theory does not work well fornonmonotonic semantics!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 333/456
5. Knowledge in Flux 2. Updates of Logic Programs
In this subsection we discuss the work of [Alferes et al.,2002], [Alferes and Pereira, 2002], [Leite et al., 2001], [Alferes et al.,
2004].They have developed a language to formulateknowledge updates, LUPS.They have also developed a theory of dynamic logicprogramming: given a sequence of logic programs Pi,what is the semantics of the program P1`P2` . . .`Pn,the update of P1 by the successive updates P2, . . .Pn?The semantics of LUPS is reduced to the semantics ofP1`P2` . . .`Pn. This latter construction is out of thescope of this lecture. We concentrate on formulatinglogic program updates.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 334/456
5. Knowledge in Flux 2. Updates of Logic Programs
Example 5.7 ([Alferes et al., 2002])
Consider the logic program
f ree Ð not jailjail Ð abortion
We update this program with the newinformationU1 : abortionÐ . After a while, welearn thatU2 : not jail Ð abortion .
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 335/456
5. Knowledge in Flux 2. Updates of Logic Programs
Classical update-approaches update specific models.
They consider the model t f ree,abortionu as asuitable update (after learning thatU1).However, the model tabortion, jailu is a betterchoice.After updateU2, jail should become false andf ree again true. Again, update approaches donot get these results.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 336/456
5. Knowledge in Flux 2. Updates of Logic Programs
LUPS- an update language
Definition 5.8 (Knowledge state)
A knowledge state KS is a set of rules (a logicprogram). An atom holds in s if it is true in allstable models (answer sets) of KS.
The idea is that successive updatesU1,U2, . . .Unare applied to the initial knowledge state KS0and result in the final state KSn � KS0rU1s . . . rUns.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 337/456
5. Knowledge in Flux 2. Updates of Logic Programs
UpdatesUi
Each setUi consists of (finitely many) update commands ofthe following form:1 assert LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.2 assert event LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.3 always LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.4 always event LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.5 retract LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.6 cancel LÐ L1, . . . ,Ln when Lk�1, . . . ,Lm.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 338/456
5. Knowledge in Flux 2. Updates of Logic Programs
1 assert: such rules are added to the KS andpersist.
2 event: to avoid persistence of rules (only addit in the successor state), discard it later.
3 always: while assert rules are added onlyonce, always rules can be automaticallyadded at each step (if the precondition issatisfied). Thus, even without any newupdates, these rules might fire.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 339/456
5. Knowledge in Flux 2. Updates of Logic Programs
Example 5.7 in this terminology:KS0 :� t f reeÐ not jail, jail Ð abortionu
KS � KS0rassert abortionsrassert not jail Ð abortions
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 340/456
5. Knowledge in Flux 2. Updates of Logic Programs
Definition 5.9 (LUPS)
An update program in LUPS is a finite sequenceof update commands of the form mentioned onthe previous slide.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 341/456
5. Knowledge in Flux 2. Updates of Logic Programs
Example 5.10 (Parallel updates [Alferes et al., 2002])A suitcase with two latches opens only when both latchesare up. A toggling action is available (and can be appliedto each latch). This can be represented by
always open Ð uppl1q,uppl2qalways uppLq when not uppLq, togglepLqalways not uppLq when uppLq, togglepLq
Suppose in the initial situation l1 is down and l2 is up, thesuitcase is closed. Then there are two toggling actions(one for each latch). And then a toggling action only for l2.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 342/456
5. Knowledge in Flux 2. Updates of Logic Programs
U1 � tassert not uppl1q,assert uppl2q,assert not openuU2 � tassert event togglepl1q, assert event togglepl2quU3 � tassert event togglepl2qu
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 343/456
5. Knowledge in Flux 3. References
5.3 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 344/456
5. Knowledge in Flux 3. References
[Alchourrón et al., 1985] Carlos E. Alchourrón, Peter Gärdenfors, andDavid Makinson.On the logic of theory change: Partial meet contraction andrevision functions.50(2):510–530, 1985.
[Alferes and Pereira, 2002] José Júlio Alferes and Luís Moniz Pereira.Logic programming updating - a guided approach.In Antonis C. Kakas and Fariba Sadri, editors, ComputationalLogic: Logic Programming and Beyond, Essays in Honour of RobertA. Kowalski, Part II, pages 382–412. Springer, 2002.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 345/456
5. Knowledge in Flux 3. References
[Alferes et al., 2002] José Júlio Alferes, Luís Moniz Pereira, HalinaPrzymusinska, and Teodor C. Przymusinski.Lupsa language for updating logic programs.138(1-2):87–116, 2002.
[Alferes et al., 2004] José Júlio Alferes, Federico Banti, Antonio Brogi,and João Alexandre Leite.Semantics for dynamic logic programming: A principle-basedapproach.In Vladimir Lifschitz and Ilkka Niemelä, editors, LogicProgramming and Nonmonotonic Reasoning, 7th InternationalConference, LPNMR 2004, Fort Lauderdale, FL, USA, January 6-8,2004, Proceedings, pages 8–20. Springer, 2004.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 346/456
5. Knowledge in Flux 3. References
[Katsuno and Mendelzon, 1992] Hirofumi Katsuno and Alberto O.Mendelzon.Propositional knowledge base revision and minimal change.52(3):263–294, 1992.
[Leite et al., 2001] João Alexandre Leite, José Júlio Alferes, andLuís Moniz Pereira.Multi-dimensional dynamic knowledge representation.In Thomas Eiter, Wolfgang Faber, and Miroslaw Truszczynski,editors, Logic Programming and Nonmonotonic Reasoning, 6thInternational Conference, LPNMR 2001, Vienna, Austria, September17-19, 2001, Proceedings, pages 365–378. Springer, 2001.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 347/456
5. Knowledge in Flux 3. References
[Winslett, 1988] Marianne Winslett.A framework for comparison of update semantics.In Proceedings of the Seventh ACM SIGACT-SIGMOD-SIGARTSymposium on Principles of Database Systems, March 21-23, 1988,Austin, Texas, pages 315–324. ACM, 1988.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 348/456
6. Combining Knowledge and Time
Chapter 6. CombiningKnowledge and Time
Combining Knowledge and Time6.1 CTLK6.2 Interpreted Systems6.3 BDI6.4 What’s the Use?6.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 349/456
6. Combining Knowledge and Time
The world is dynamic, and agents’ knowledge/beliefsshould evolve accordingly (see previous chapter). Weshowed how modal logic can be used to modelknowledge and time separately. In this chapter, weshow how these two dimensions can be combined toobtained a better model of an agent.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 350/456
6. Combining Knowledge and Time
We present CTLK, which is a straightforwardcombination of CTL and standard epistemic logic.We use the Muddy Children puzzle to argue that evensuch a simple idea is a powerful tool for reasoningabout evolution of knowledge.Then, we talk about interpreted systems, a wellknown formalism that have been successfully appliedto modeling synchrony and asynchrony, perfectrecall,message passing systems, knowledge bases,distributed systems etc.Finally, we briefly mention two propositional variantsof the BDI framework of beliefs, desires andintentions.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 351/456
6. Combining Knowledge and Time 1. CTLK
6.1 CTLK
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 352/456
6. Combining Knowledge and Time 1. CTLK
Simple idea: straightforward combination oftemporal and epistemic logic.Language includes both kinds of operatorsModels include both kinds of modal relationsSemantics: union of semantic clauses
Example:
CTLK = CTL + Knowledge
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 353/456
6. Combining Knowledge and Time 1. CTLK
Muddy Children revisited
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m
mc
m1
2
3
3
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m
mc
m1
2
3
3
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m
mc
m1
2
3
3
3
mm
c
mm
c
mm
m
mm
m1
2
cm
m
cm
m
mc
m
mc
m
3
1
2
mm
c
mm
c
cm
c
cm
c
cc
c
cc
c
mc
c
mc
c1
2
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m1
2
3
33
3
1
2
mm
c
mm
c
cm
c
cm
c
mc
c
mc
c
mm
m
mm
m1
2
cm
m
cm
m
cc
m
cc
m
mc
m
mc
m1
2
3
3
3
mm
c
mm
c
mm
m
mm
m1
2
cm
m
cm
m
mc
m
mc
m
mudi Ñ E♦Kimudi
mudi Ñ Al Ki mudi
mudi Ñ Alp Ki mudi^ Kimudiq
mudi Ñ KiE♦Kimudi
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 354/456
6. Combining Knowledge and Time 1. CTLK
Robots and Carriage revisited
q0
q2 q1
pos0
pos1pos2
1
2
E♦p�
i K1posi^�
i K2posi^�
i K3posiq
Ep♦�
i K1posi^♦�
i K2posi^♦�
i K3posiqNote: the latter is a CTLK* property!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 355/456
6. Combining Knowledge and Time 2. Interpreted Systems
6.2 Interpreted Systems
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 356/456
6. Combining Knowledge and Time 2. Interpreted Systems
More grounded notion of epistemic stateGlobal states are tuples of local statesQi: set of local states of agent iGlobal states: Q� Q1��� ��Qk�QenvEpistemic relations are based on local states:
xq1, ...,qky �i xq11, ...,q1ky iff qi � q1i
Temporal dimension: runs (paths)
Interpreted systems have been applied tomodeling of synchrony and asynchrony,perfect recall,message passing systems,knowledge bases, distributed systems etc.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 357/456
6. Combining Knowledge and Time 2. Interpreted Systems
Definition 6.1 (System)
A system is a set of runs.
Note: a set of runs can as well be seen as abranching-time tree!
Definition 6.2 (Interpreted system)
An interpreted system I is a set of runs R plusvaluation of propositions: π : QÑ P pΠq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 358/456
6. Combining Knowledge and Time 2. Interpreted Systems
Reasoning about dynamics of knowledge:LTL+Knowledge.Formulae evaluated wrt time points xr,my: arun r plus a time moment m.That is,W � R �N.Epistemic equivalence between points:
xr,my �i xr1,m1y iff rm �i r1m1.
Knowledge interpreted as before:I ,r,m |ù Kiϕ iff I ,r1,m1 |ù ϕ for every xr1,m1ysuch that xr,my �i xr1,m1y.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 359/456
6. Combining Knowledge and Time 2. Interpreted Systems
Interpretation of LTL operators:I ,r,m |ù©ϕ iff I ,r,m�1 |ù ϕ,I ,r,m |ù ϕU ψ iff I ,r,m1 |ù ψ for some m1 ¡ mand I ,r,m2 |ù ϕ for all m2 such thatm¤ m2 m1.
What about path quantifiers?
I ,r,m |ù Eϕ iff there is r1 such thatr1r0...ms � rr0...ms and I ,r1,m |ù ϕ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 360/456
6. Combining Knowledge and Time 3. BDI
6.3 BDI
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 361/456
6. Combining Knowledge and Time 3. BDI
BDI = Beliefs, Desires, and Intentions
BDI according to Cohen and Levesque:Mental primitives: beliefs and goals,Separate operators and relations for eachagent
Time and action: LTL and DL.
Altogether: multi-modal logic
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 362/456
6. Combining Knowledge and Time 3. BDI
Operator MeaningBeliϕ agent i believes ϕ
Goaliϕ agent i has goal of ϕ©©©α action α will happen nextDoneα action α has just happened
Additionally:Action constructors “;” and “?”, as in DL;Derived operators: ♦α (sometime α), lα
(always α), pLaterϕq: strict sometime,pBeforeϕ , ψq: ϕ holds before ψ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 363/456
6. Combining Knowledge and Time 3. BDI
Examples:
Goalcitizenlsafecitizen
GoalpoliceBelcitizenlsafecitizen
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 364/456
6. Combining Knowledge and Time 3. BDI
BDI according to Rao and Georgeff:Mental primitives: beliefs, desires andintentionsTime: CTLSophisticated semantic structure
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 365/456
6. Combining Knowledge and Time 3. BDI
Example: Card Play
win
AK1
q0 q0
AQ1
AK2QK
2 AQ2 KQ2 win
hasA hasA
hasA hasAwin
AK1
q0
AK2
hasA
hasA
Ba
q0
AQ1
win KQ2
hasA
hasA
Bopt Bopt
DaDa
W1
W2
W3
W4
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 366/456
6. Combining Knowledge and Time 3. BDI
BelaE©win : Agent A believes that there is away to win in one stepDesaA©win : the agent desires that everypath leads to a victory, so he does not have toworry about his decisionsHowever, he does not believe it is possible: BelaA©winOn the other hand, he believes that a realoptimist would believe that winning forever isinevitable: BelaBeloptA©lwin.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 367/456
6. Combining Knowledge and Time 3. BDI
Of course, it is possible to extend BDI:
horizontally: with other modal dimensions(e.g., BOID);
vertically: to a language of higher order (e.g.,LORA).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 368/456
6. Combining Knowledge and Time 4. What’s the Use?
6.4 What’s the Use?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 369/456
6. Combining Knowledge and Time 4. What’s the Use?
What do we use these frameworks for?
Analysis & Design
Modeling systems (the frameworks provideintuitive conceptual structures, and asystematic approach);Specifying desireable properties of systems.
Verification & Exploration
Reasoning about concrete systems;Correctness testing.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 370/456
6. Combining Knowledge and Time 4. What’s the Use?
What do we use these frameworks for?
Automatic Generation of Behaviours
Programming with executable specifications;Automatic planning.
Philosophy of Mind and Agency
Characterization of mental attitudes;Discussion of rational agents;Testing rationality assumptions.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 371/456
6. Combining Knowledge and Time 4. What’s the Use?
Beware!
Not all modal dimensions are independent!
Example: abilities and knowledge
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 372/456
6. Combining Knowledge and Time 5. References
6.5 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 373/456
6. Combining Knowledge and Time 5. References
[Broersen et al., 2001a] Broersen, J., Dastani, M., Huang, Z., andvan der Torre, L. (2001a).The BOID architecture: conflicts between beliefs, obligations,intentions and desires.In Müller, J., Andre, E., Sen, S., and Frasson, C., editors,Proceedings of the Fifth International Conference on AutonomousAgents, pages 9–16. ACM Press.
[Cohen and Levesque, 1990] Cohen, P. and Levesque, H. (1990).Intention is choice with commitment.Artificial Intelligence, 42:213–261.
[Fagin et al. 1995] Fagin, R., Halpern, J. Y., Moses, Y. & Vardi, M. Y.Reasoning about Knowledge.MIT Press: Cambridge, MA.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 374/456
6. Combining Knowledge and Time 5. References
[Rao and Georgeff1991] Rao, A. S. and M. Georgeff (1991).Modeling Rational Agents within a BDI-Architecture.In J. F. Allen, R. Fikes, and E. Sandewall (Eds.), Proceedings of theInternational Conference on Knowledge Representation andReasoning, Cambridge, MA, pp. 473–484. Morgan Kaufmann.
[Wooldridge, 2000] Wooldridge, M. (2000).Reasoning about Rational Agents.MIT Press: Cambridge, Mass.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 375/456
7. Modalities in Action
Chapter 7. Modalities in Action
Modalities in Action7.1 Verification7.2 Complexity7.3 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 376/456
7. Modalities in Action
In this section, we discuss one particular class ofapplications of modal logics, namely verificationthroughmodel checking.We demonstrate a simple algorithm for modelchecking CTLK, discuss complexity of the problem forvarious temporal logics, and present how theMCMASmodel-checker can be used to verifytemporal-epistemic properties of agentscommunicating via the alernating bit protocol.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 377/456
7. Modalities in Action 1. Verification
7.1 Verification
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 378/456
7. Modalities in Action 1. Verification
Model checking: Does ϕ hold in modelMand state q?Global model checking: Return the exact setof states q in M such that ϕ holds inM ,q
Verification example: we want to make surethat the cargo can be always moved to theother location.
Al�
caLÑ E♦caP
^ caPÑ E♦caL
^ caRÑ pE♦caL_E♦caPq�
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 379/456
7. Modalities in Action 1. Verification
Two perspectives to model checking MAS:Verification
Model represents the view of an objectiveobserver
Formula: specification to be met
Planning
Models represent the subjective view of anagentFormula: goal to be achieved
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 380/456
7. Modalities in Action 1. Verification
function mcheckpM ,ϕq.Model checking formulae of CTLK.Returns the exact subset of Q for which formula ϕ holds.case ϕ� p : return tq P Q | p P πpqqucase ϕ� ψ : return QzmcheckpM ,ψqcase ϕ� ψ1^ψ2 : return mcheckpM ,ψ1qXmcheckpM ,ψ2qcase ϕ� E©ψ : return prepmcheckpM ,ψqqcase ϕ� Elψ :
Q1 :� Q; Q2 :� Q3 :� mcheckpM ,ψq;while Q1 � Q2 do Q1 :� Q1XQ2; Q2 :� prepQ1qXQ3 od;return Q1case ϕ� Eψ1 U ψ2 :
Q1 :�H; Q2 :� mcheckpM ,ψ2q; Q3 :� mcheckpM ,ψ1q;while Q2 � Q1 do Q1 :� Q1YQ2; Q2 :� prepQ1qXQ3 od;return Q1case ϕ� Kiψ :return tq | imgpq,�aq � mcheckpM,ψqu; end case
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 381/456
7. Modalities in Action 1. Verification
Example: Modified Rocket Domain, E♦caL
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 382/456
7. Modalities in Action 1. Verification
Nice result: model checking CTLK is tractable!
Theorem (Clarke, Emerson & Sistla 1986)
CTL model checking is P-complete, and can bedone in time linear in the size of the modeland the length of the formula.
Extending the result to CTLK is straightforward.
So... Let’s model-check!
Not as easy as it seems...
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 383/456
7. Modalities in Action 2. Complexity
7.2 Complexity
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 384/456
7. Modalities in Action 2. Complexity
Some Complexity Classes
P: problems solvable in polynomial time bya deterministic Turing machineNP: problems solvable in polynomial timeby a non-deterministic Turing machinePSPACE: problems solvable in polynomialspaceEXPTIME: problems solvable in exponentialtime
What is this about?
Scalability!Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 385/456
7. Modalities in Action 2. Complexity
Complexity of Model Checking Temporal andStrategic Logics
m, lCTL P-completeLTL PSPACE-completeCTL* PSPACE-complete
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 386/456
7. Modalities in Action 2. Complexity
Nice result: model checking CTL istractable.But: the result is relative to the size of themodel and the formula
Well known catch (CTL): size of models isexponential wrt a higher-level description
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 387/456
7. Modalities in Action 2. Complexity
k attributes . . . at least 2k states
nofuelroL
caR
fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
nofuel fuelOK nofuel fuelOK
1
5 6
2
3 4
87
9 10 1211
roL roP
roL roL
roLroL
roP
roP roP
roP
roP
caL caL caLcaL
caR caR caR
caP caP caP caP
Symbolic model checking!
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 388/456
7. Modalities in Action 2. Complexity
Explicit vs. Symbolic Model Checking
m, l nlocal, lCTL P-complete PSPACE-completeLTL PSPACE-complete PSPACE-completeCTL* PSPACE-complete PSPACE-complete
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 389/456
7. Modalities in Action 2. Complexity
Main message:
Complexity is very sensitive to the context!In particular, the way we define the input,and measure its size, is crucial.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 390/456
7. Modalities in Action 2. Complexity
Even if model checking appears very easy, it canbe very hard.
Still, people do automatic model checking!LTL: SPINCTL/ATL: MOCHA, MCMAS, VeriCS
Even if model checking is theoretically hard, itcan be feasible in practice.
demo (MCMAS)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 391/456
7. Modalities in Action 3. References
7.3 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 392/456
7. Modalities in Action 3. References
[Clarke86ctl] E.M. Clarke, E.A. Emerson, and A.P. Sistla.Automatic verification of finite-state concurrent systems usingtemporal logic specifications.ACM Transactions on Programming Languages and Systems,8(2):244–263, 1986.
[GiunchigliaTraverso00] Fausto Giunchiglia and Paolo Traverso.Planning as model checking.In Susanne Biundo and Maria Fox (Eds.) Recent Advances in AIPlanning, 5th European Conference on Planning, ECP’99, Durham,UK, September 8-10, 1999, Proceedings, 1–20, LNCS 1809,Springer 2000.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 393/456
7. Modalities in Action 3. References
[Jamroga/Dix2] Wojciech Jamroga and Jürgen Dix (2007).Model Checking Abilities of Agents: A Closer LookTheory of Computing Systems. To appear.
[Schnoebelen03complexity] Philippe Schnoebelen.The Complexity of Temporal Model Checking.In Advances in Modal Logics, Proceedings of AiML 2002, 2003.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 394/456
8. Where the Frameworks Meet
Chapter 8. Where theFrameworks Meet
Where the Frameworks Meet8.1 Modalities in LP8.2 LP in Modal Structures8.3 There and Back Again8.4 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 395/456
8. Where the Frameworks Meet
This section is more speculative than the others.Starting with Slide 398, we discuss briefly some LPapproaches that are enhanced with suitable modalflavor.From Slide 423 on, we consider a few approaches thatdo contain some LP flavor.Finally, in the last section we try to come up with somecomparison between modal approaches on one handand LP approaches on the other. We formulate twoconjectures about the representation of Kripkemodels as sets of logic programs.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 396/456
8. Where the Frameworks Meet 1. Modalities in LP
8.1 Modalities in LP
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 397/456
8. Where the Frameworks Meet 1. Modalities in LP
Temporal Logic Programming
Temporal formulae are “injected” into logicprogramsMany variants exist
Explicit reasoning about properties thatevolve over timeEnforcing execution flow
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 398/456
8. Where the Frameworks Meet 1. Modalities in LP
Example: a TEMPLOG program that generates thesequence of Fibonacci numbers:
fib(0).©fib(1).
l�©©fib(X) Ð fib(Y), ©fib(Z), X is Y+Z
�.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 399/456
8. Where the Frameworks Meet 1. Modalities in LP
Temporal Programming: METATEM
Instead of propositional models, why not usingfirst-ordermodels?
METATEM is based on a first-order temporallogic based on discrete, linear models with finitepast and infinite future, called FML.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 400/456
8. Where the Frameworks Meet 1. Modalities in LP
Syntax of FML.
The formulae for FML are generated as usual, starting froma set Lp of predicate symbols, a set Lv of variable symbols,a set Lc of constant symbols, the quantifiers @ and D, andthe set Lt of terms (constants and variables). The set Fml isdefined by:If t1, ..., tn are in Lt and p is a predicate symbol of arity n,then ppt1, ..., tnq is in Fml.J (true) and K (false) are in Fml.If A and B are in Fml, then so are A, A^B, AUUUB, ASSSB,and pAq.If A is in Fml and v is in Lv, then Dv.A and @v.A are bothin Fml.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 401/456
8. Where the Frameworks Meet 1. Modalities in LP
Temporal operators:
ϕUUUψ ϕ holds until ψ primitive
ϕSSSψ ϕ since ψ primitive
©©©ϕ ϕ is true in the next state [KUUUϕ]©�©�©�ϕ the current state is not the initial state,
and ϕ was true in the previous state [KSSSϕ]© © © ϕ if the current state is not the initial state,
then ϕ was true in the previous state [ ©�©�©� ϕ]♦♦♦ϕ ϕ will be true in some future state [JUUUϕ]�ϕ ϕ was true in some past state [JSSSϕ]lllϕ ϕ will be true in all future states [ ♦♦♦ ϕ]�ϕ ϕ was true in all past states [ � ϕ]
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 402/456
8. Where the Frameworks Meet 1. Modalities in LP
Semantics of FML.
The models for FML formulae are given bya structure consisting of a sequence ofworlds (also called states), together withan assignment of truth values to atomicsentences within states,a domain D which is assumed to be constantfor every state,and mappings from elements of thelanguage into denotations.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 403/456
8. Where the Frameworks Meet 1. Modalities in LP
Definition 8.1 (FML model)
A FML model is a tupleM � xσ,D,hc,hpy whereσ is the ordered set of states s0,s1,s2, ...,hc is a map from the constants into D, andhp is a map from N�Lp into Dn Ñ { true, false } (thefirst argument of hp is the index i of the state si).
Thus, for a particular state s, and a particular predicate pof arity n, hps, pq gives truth values to atoms constructedfrom n-tuples of elements of D.A variable assignment hv is a mapping from the variablesinto elements of D. Given a variable and the valuationfunction hc, a term assignment τvh is a mapping fromterms into D defined in the usual way.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 404/456
8. Where the Frameworks Meet 1. Modalities in LP
The semantics of FML is given by the |ù relation thatgives the truth value of a formula in a modelM at aparticular moment in time i and with respect to a variableassignment.
xM , i,hvy |ù JxM , i,hvy �|ù KxM , i,hvy |ù ppx1, ...,xnq iff hppi, pqpτvhpx1q, ...,τvhpxnqq � truexM , i,hvy |ù ϕ iff xM , i,hvy �|ù ϕ
xM , i,hvy |ù ϕ_ψ iff xM , i,hvy |ù ϕ or xM , i,hvy |ù ψ
xM , i,hvy |ù ϕ UUUψ iff for some k s.t. i k, xM ,k,hvy |ù ψ
and for all j, if i j k then xM , j,hvy |ù ϕ
xM , i,hvy |ù ϕ SSSψ iff for some k s.t. 0¤ k i, xM ,k,hvy |ù ψ
and for all j, if k j i then xM , j,hvy |ù ϕ
xM , i,hvy |ù @x.ϕ iff for all d PD,xM , i,hvrd{xsy |ù ϕ
xM , i,hvy |ù Dx.ϕ iff there exists d PD s.t. xM , i,hvrd{xsy |ù ϕ
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 405/456
8. Where the Frameworks Meet 1. Modalities in LP
Concurrent METATEM is a programminglanguage for distributed AI based on FML.A system contains a number of concurrently executingagents which are able to communicate throughmessage passing.Each agent executes a specification of its desiredbehavior.Each agent has two main components:an interface which defines how the agent mayinteract with its environment (i.e., other agents);a computational engine, defining how the agentmay act.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 406/456
8. Where the Frameworks Meet 1. Modalities in LP
An agent interface consists of three components:a unique agent identifier which names the agenta set of predicates defining what messages will beaccepted by the agent – they are called environmentpredicates;a set of predicates defining messages that the agentmay send—these are called component predicates.
Besides environment and component predicates, an agenthas a set of internal predicates with no external effect.The computational engine of an object is based on theMETATEM paradigm of executable temporal logics. Theidea behind this approach is to directly execute adeclarative agent specification given as a set of programrules.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 407/456
8. Where the Frameworks Meet 1. Modalities in LP
Program rules are temporal logic formulae ofthe form:
antecedent: pastÑ consequent: future
The intuitive interpretation of such a rule is:
on the basis of the past, do the future
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 408/456
8. Where the Frameworks Meet 1. Modalities in LP
Contract Proposal from [MascardiMS04]
contractProposal
acknowledge
contractProposal
accept
refuse
Buyer Seller
accept
refuse
contractProposal
acknowledge
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 409/456
8. Where the Frameworks Meet 1. Modalities in LP
Seller agent may receive a contractProposalmessagefrom a buyer agent.According to the amount of merchandise required andthe price proposed by the buyer, the seller mayaccept the proposal, refuse it or try to negotiate anew price by sending a contractProposalmessageback to the buyer.The buyer agent can do the same (accept, refuse ornegotiate) when it receives a contractProposalmessage back from the seller.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 410/456
8. Where the Frameworks Meet 1. Modalities in LP
Behaviour of sellerif the received message iscontractProposalpmerchandise,amount, proposed priceq
thenif there is enough merchandise in the warehouseand the price is greater or equal than amax value,the seller accepts by sending an acceptmessage tothe buyer and concurrently ships the requiredmerchandise to the buyer (if no concurrent actionsare available, answering and shipping merchandisewill be executed sequentially);
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 411/456
8. Where the Frameworks Meet 1. Modalities in LP
if there is not enough merchandise in the warehouseor the price is lower or equal than amin value, theseller agent refuses by sending a refusemessage tothe buyer;if there is enough merchandise in the warehouse andthe price is betweenmin andmax, the seller sends acontractProposal to the buyer with a proposed priceevaluated as the mean of the price proposed by thebuyer andmax.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 412/456
8. Where the Frameworks Meet 1. Modalities in LP
The merchandise to be exchanged are oranges,with minimum and maximum price 1 and 2euro respectively. The initial amount of orangesthat the seller possesses is 1000.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 413/456
8. Where the Frameworks Meet 1. Modalities in LP
Concurrent METATEM program for the selleragent
The interface of the seller agent is the followingsellerpcontractProposalqraccept,re f use,contractProposal,ships
meaning that:the seller agent, identified by the seller identifier, isable to recognize a contractProposalmessage with itsarguments, not specified in the interface;the messages that the seller agent is able to broadcastto the environment, including both communicativeacts and actions on the environment, are accept,refuse, contractProposal, ship.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 414/456
8. Where the Frameworks Meet 1. Modalities in LP
The internal knowledge base of the seller agent containsthe following rigid predicates (predicates whose valuenever changes):min-price(orange, 1).max-price(orange, 2).
The internal knowledge base of the seller agent containsthe following flexible predicates (predicates whose valuechanges over time):
storingporange,1000q.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 415/456
8. Where the Frameworks Meet 1. Modalities in LP
The program rules of the seller agent are the followingones (lowercase symbols = constants, uppercase =variables):
@Buyer, Merchandise, Req_Amnt, Price©�©�©�[contractProposalpBuyer,seller,Merchandise,Req_Amnt,Priceq^ storingpMerchandise,Old_Amountq^ Old_Amount ¥ Req_Amnt^ maxpricepMerchandise,Maxq ^ Price¥Max]
ñ [shippBuyer,Merchandise,Req_Amnt,Priceq ^acceptpseller,Buyer,Merchandise,Req_Amnt,Priceq]
If there was a previous state where Buyer sent a contractProposalmessage to seller, and in that previous state all the conditions weremet to accept the proposal, then accept the Buyer’s proposal and shipthe required merchandise.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 416/456
8. Where the Frameworks Meet 1. Modalities in LP
@Buyer,Merchandise,Req_Amnt,Price©�©�©�rcontractProposalpBuyer,seller,Merchandise,Req_Amnt,Priceq^storingpMerchandise,Old_Amountq^min� pricepMerchandise,Minq^Old_Amount Req_Amnt_Price¥Mins ùñ
re f usepseller,Buyer,Merchandise,Req_Amnt,Priceq
If there was a previous state where Buyer sent acontractProposalmessage to seller, and in that previousstate the conditions were not met to accept the Buyer’sproposal, then send a refusemessage to Buyer.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 417/456
8. Where the Frameworks Meet 1. Modalities in LP
@Buyer,Merchandise,Req_Amnt,Price©�©�©�rcontractProposalpBuyer,seller,Merchandise,Req_Amnt,Priceq^storingpMerchandise,Old_Amountq ^ min� pricepMerchandise,Minq^max� pricepMerchandise,Maxq^Old_Amount ¥ Req_Amnt^Price¡Min ^ Price Max^New_Price� pMax�Priceq{2s ùñ
contractProposalpseller,Buyer,Merchandise,Req_Amnt,New_Priceq
If there was a previous state where Buyer sent acontractProposalmessage to seller, and in that previousstate the conditions were met to send a contractProposalback to Buyer, then send a contractProposalmessage toBuyer with a new proposed price.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 418/456
8. Where the Frameworks Meet 1. Modalities in LP
Situation Calculus
Another way of extending logic programswith modal elementsPredicates parameterized with situationssituation � possible worldMoreover, execution of an action transformsthe current situation into a new one ( dynamic logic)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 419/456
8. Where the Frameworks Meet 1. Modalities in LP
Breeze Breeze
Breeze
BreezeBreeze
Stench
Stench
BreezePIT
PIT
PIT
1 2 3 4
1
2
3
4
START
Gold�
Stench
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 420/456
8. Where the Frameworks Meet 1. Modalities in LP
Perceptpra,Breeze,g,u,cs,sq Ñ BreezepsqAtpAgent, l,sq^Breezepsq Ñ Breezypl,sq
Atpp, l,dopForward,sqq Ø location_aheadpp, l,sq^ Wallpl,sq
HoldingpGold,dopGrab,sqq Ø At_Goldpsq_HoldingpGold,sq
Situation calculus can be seen as a translationof dynamic logic to FOL.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 421/456
8. Where the Frameworks Meet 2. LP in Modal Structures
8.2 LP in Modal Structures
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 422/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Shoham suggests the following threecomponents of an Agent OrientedProgramming system:A formal language with clear syntax fordescribing the mental state.A programming language for definingagents.A method of transforming legacy code intoan agent.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 423/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Shoham: an agent has commitments (orobligations). One such commitment can be toperform an action.
No need for action selection. But thelanguage specification must have amechanism for adopting commitments ornot.All rules must be created at compile time:huge amount of possible scenarios.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 424/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Agent Programming: AGENT-0
AGENT-0 programming language is based on aquantified multi-modal logic, with directreference to time. Three modalities: Beliefs,Commitments, Capabilities.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 425/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Atoms: Sentences in a point-based temporalframework:is_ f riendpaaa,bbbq (facts),turnpI, le f tqt (instantaneous actions).
No distinction between actions andfacts.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 426/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Beliefs: BnowIII go_swimmingpIII,CLZqt : I believenow that I am going to swim in CLZ attime t.Bnow
III ontablepblock_bqt .
B3aaaB
4bbb is_ f riendpaaa,bbbq.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 427/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Obligations: (also called commitments) are thebeliefs that one agent will create thetruth of a statement (for anotheragent)OBLt
III,youyouyou go_swimmingpIII,CLZqt�1,
(at time t, I am obligated to you to goswimming in CLZ at time t�1).The argument does not need to bean action: OBLt
pIII,youyouyouq in_lecturepyouyouyouqt�1.
A decision is an obligation tooneself: DECt
aaaϕ :� OBLtpaaa,aaaqϕ.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 428/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Capabilities: An agent is said to be capable of astatement if it has the ability to see thatthat statement hold at the specifiedtime:CANnow
III in_lecturepyouqt
(I am capable of seeing to it that youare in a lecture at time t.)
Note: capabilities may change.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 429/456
8. Where the Frameworks Meet 2. LP in Modal Structures
AGENT-0 Programs
An agent in AGENT-0 consists of (1) a set ofinitial beliefs, (2) a set of capabilities, (3) a set ofinitial commitments, and (4) a set ofcommitment rules of the form
pCOMMITmsgcond mntlcond pagentagentagent, t, actionqq,
“Commit to perform action for agentagentagent at time t (ifmsgcond holds of the new incoming messages, ifmntlcond holds in the mental state, if the agentis currently capable of doing action).”
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 430/456
8. Where the Frameworks Meet 2. LP in Modal Structures
agentagentagent: this is the name of an agent;action: a private or communicative action.
Only primitive actions are allowed!Action “Find the gold and bring ithome” is, most likely, not primitive. Itrequires a plan (a sequence ofprimitive actions).
msgcond: a message condition of the formpSender Type Contentq.
mntlcond: this describes a condition about theown mental state of the agent (i.e., theagent’s beliefs and commitments);
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 431/456
8. Where the Frameworks Meet 2. LP in Modal Structures
Cycle
AGENT-0 follows the following simple controlloop when executing a program:At each time step1 gather incoming messages and update themental state accordingly,
2 execute commitments (using capabilities).
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 432/456
8. Where the Frameworks Meet 2. LP in Modal Structures
More recent agent-oriented programminglanguages follow similar ideas!3APL, 2APL BDI programmingImpactJasonJack......
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 433/456
8. Where the Frameworks Meet 2. LP in Modal Structures
beliefs
commitments
abilities
EXECUTE
updatebeliefs
updatecommitments
initialize messages in
internal actions
messages out
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 434/456
8. Where the Frameworks Meet 2. LP in Modal Structures
What makes an agent do something?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 435/456
8. Where the Frameworks Meet 3. There and Back Again
8.3 There and Back Again
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 436/456
8. Where the Frameworks Meet 3. There and Back Again
From Modal Logic to Logic Programming
In more general terms: agent programming useslogic programs as compact representations ofagents’ motivational attitudes.
Logic program = epistemic state
Update = transition
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 437/456
8. Where the Frameworks Meet 3. There and Back Again
Together with update procedures, logicprograms can be used to representtemporal-epistemic models.
Advantages:Compact representationsCan be compact even when the number ofpossible worlds is huge or infinite
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 438/456
8. Where the Frameworks Meet 3. There and Back Again
Example: Counting Ducks
ducks(1)
q1
q2ducks(2)
ducks(3)
q3
....
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 439/456
8. Where the Frameworks Meet 3. There and Back Again
inpool(tweety).duckscnt(0,[],0,[]).duckscnt(N,Duckslist,NewN,[Duck|Duckslist])Ð
duckscnt(_,_,N,Duckslist), inpool(Duck),notin(Duck,Duckslist), NewN is N+1.
ducks(N)Ð duckscnt(_,_,N,_),N1 is N+1, notduckscnt(_,_,N1,_).
ducks(N)Ð notducks(N).
Additional assumptions:Perception: inpool(_), inpool(_)At most one percept per step!Relevant: ducks(_)
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 440/456
8. Where the Frameworks Meet 3. There and Back Again
ducks(1)
q1
q2ducks(2)
ducks(3)
q3
....
+ standard update procedure
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 441/456
8. Where the Frameworks Meet 3. There and Back Again
ducks(1)
q1
q2ducks(2)
ducks(3)
q3
....
ducks(1)
q1
q2ducks(2)
ducks(3)
q3
....
warm
warm
warm
ducks(1)
q1
q2ducks(2)
ducks(3)
q3
....
warm
warm
warm
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 442/456
8. Where the Frameworks Meet 3. There and Back Again
Representation:
inpool(tweety).duckscnt(0,[],0,[]).duckscnt(N,Duckslist,NewN,[Duck|Duckslist])Ð
duckscnt(_,_,N,Duckslist), inpool(Duck),notin(Duck,Duckslist), NewN is N+1.
ducks(N)Ð duckscnt(_,_,N,_),N1 is N+1, notduckscnt(_,_,N1,_).
ducks(N)Ð notducks(N).
Perception: inpool(_), inpool(_),warm, warm Ð notwarmAt most one percept per stepRelevant: ducks(_), warm
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 443/456
8. Where the Frameworks Meet 3. There and Back Again
Multiple agents multiple programs
Conjecture 8.1
Every finite Kripke model can be represented bya multi-LP system (i.e., a finite collection of logicprograms + update procedure).
What about infinitemodels?
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 444/456
8. Where the Frameworks Meet 3. There and Back Again
From Logic Programming to Modal Logic
The reverse transformation is also meaningful. Alogic programming system can be simulated bya Kripke model.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 445/456
8. Where the Frameworks Meet 3. There and Back Again
Local state = logic program set of answer sets
Possible world/global state =answer sets ASPpP1qY � � �YASPpPkq
Epistemic/Doxastic relations generated by local states
Which one is the actual world? We do not know!Way out: add special world with arbitrary valuation.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 446/456
8. Where the Frameworks Meet 3. There and Back Again
Conjecture 8.2
Every collection of logic programs xP1, . . . ,Pky canbe simulated as a pointed Kripke model xM ,wywith k accessibility relations.
Advantage:We get semantics of epistemic formulaexP1, . . . ,Pky |ù Ki Beliϕ iff xM ,wy |ù Ki BeliϕNote that, for propositional ϕ:xP1, . . . ,Pky |ù Beliϕ iff m |ù ϕ for every answerset m P ASPpPiq
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 447/456
8. Where the Frameworks Meet 3. There and Back Again
Transition = update
But: do the agents really know anything aboutthe future?Suggestion: try the “worlds-within worlds”approach (cf. Rao/Georgeff’s BDI logic)
Exercise
Try to simulate a multi-LP system with aneighborhood model.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 448/456
8. Where the Frameworks Meet 4. References
8.4 References
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 449/456
8. Where the Frameworks Meet 4. References
[BFG89] Barringer, H., M. Fisher, D. Gabbay, G. Gough, and R. Owens(1990).METATEM: A framework for programming in temporal logic.In J. W. de Bakker, W. P. de Roever, and G. Rozenberg (Eds.),Proceedings of the 1989 REX Workshop on Stepwise Refinement ofDistributed Systems: Models, Formalisms, Correctness, pp. 94–129.Springer-Verlag.LNCS 430.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 450/456
8. Where the Frameworks Meet 4. References
[finger-fisher-owens] Finger, M., M. Fisher, and R. Owens (1993).METATEM at work: Modelling reactive systems using executabletemporal logic.In P. Chung, G. L. Lovegrove, and M. Ali (Eds.), Proceedings of the6th International Conference on Industrial and EngineeringApplications of Artificial Intelligence and Expert Systems(IEA/AIE’93), pp. 209–218. Gordon and Breach Publishing.
[fisherNormalForm] Fisher, M. (1992).A normal form for first-order temporal formulae.In D. Kapur (Ed.), Proceedings of the 11th International Conferenceon Automated Deduction (CADE’92), pp. 370–384.Springer-Verlag.LNCS 607.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 451/456
8. Where the Frameworks Meet 4. References
[concMTM13] Fisher, M. (1993).Concurrent METATEM – A language for modeling reactivesystems.In A. Bode, M. Reeve, and G. Wolf (Eds.), Proceedings of the 5thInternational Conference on Parallel Architectures and Language,Europe (PARLE’93), pp. 185–196. Springer-Verlag.LNCS 694.
[concMTM14] Fisher, M. and H. Barringer (1991).Concurrent METATEM processes – A language for distributed AI.In E. Mosekilde (Ed.), Proceedings of the 1991 European SimulationMulticonference. SCS Press.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 452/456
8. Where the Frameworks Meet 4. References
[concMTM16] Fisher, M. and M. Wooldridge (1993).Executable temporal logic for distributed AI.In K. Sycara (Ed.), Proceedings of the 12th International Workshopof Distributed AI (IWDAI’93), pp. 131–142.
[HiDBoHoMe98] Hindriks, K. V., F. S. de Boer, H. Hoek, and J.-J. C.Meyer (1998).Formal semantics of the core of AGENT-0.In ECAI’98 Workshop on Practical Reasoning and Rationality, pp.20–29.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 453/456
8. Where the Frameworks Meet 4. References
[mascardi02] Mascardi, V. (2002).Logic-Based Specification Environments for Multi-Agent Systems.Ph. D. thesis, Computer Science Department of GenovaUniversity, Genova, Italy.DISI-TH-2002-04.
[MascardiMS04] Mascardi, V., M. Martelli, and L. Sterling (2004).Logic-based specification languages for intelligent softwareagents.TPLP 4(4), 429–494.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 454/456
8. Where the Frameworks Meet 4. References
[Parunak-odell] Odell, J., H. V. D. Parunak, and B. Bauer (2000a).Extending UML for agents.In G. Wagner, Y. Lespérance, and E. Yu (Eds.), Proceedings of the2nd Workshop on Agent-Oriented Information Systems (AOIS’00).Held in conjunction with 17th National conference on ArtificialIntelligence (AAAI’00), pp. 3–17.
[aose54] Odell, J., H. V. D. Parunak, and B. Bauer (2000b).Representing agent interaction protocols in UML.In P. Ciancarini and M. Wooldridge (Eds.), Proceedings of the 1stInternational Workshop on Agent-Oriented Software Engineering(AOSE’00), pp. 121–140. Springer-Verlag.LNCS 1957.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 455/456
8. Where the Frameworks Meet 4. References
[Shoham90] Shoham, Y. (1993, March).Agent-oriented programming.Artificial Intelligence 60, 51–92.
[placa] Thomas, S. R. (1995).The PLACA agent programming language.In M. Wooldridge and N. R. Jennings (Eds.), Proceedings of the 1stInternational Workshop on Agent Theories, Architectures, andLanguages (ATAL’94), pp. 355–370. Springer-Verlag.LNCS 890.
Jürgen Dix and Wojtek Jamroga � ESSLLI (Dublin 2007) 456/456