Situation Calculus Institute for Software Technology 1
Dates Organizational Issues 10.11.2016 8:45-11:00 (HS i12) lecture and first assignment 17.11.2016 8:45-11:00 (HS i12) lecture and programming assignment 23.11.2016 18:00-18:45 (HS i11) practice 30.11.2016 18:00-18:45 (HS i11) practice and solution for first assignment 28.11.2016 12:00 submission first assignment 07.12.2016 23:59 submission programming assignment 2
Organizational Issues Motivation Introduction Agenda Brief Recap of First Order Logic (if needed) Situation Calculus (today) Introduction Formal Definition Usage Programming in Situation Calculus (next week) Programming Language YAGI Domain Modeling 3
Literature Knowledge in Action by Raymond Reiter MIT Press Artificial Intelligence: A Modern Approach by Stuart Russel amd Peter Norvig Prentice Hall 4
Motivation What is Situation Calculus good for? 5
There is nothing permanent except change. Heraclitus of Ephesus, 535 c. 475 BC 6
Perception-Decision-Execution 7
Dealing with Multiple Worlds 8
Belief Management 9
Belief Management 10
Brief Recap First Order Logic 11
The Situation Calculus is a methodology to reason about actions and change it allows deductive reasoning on how to behave what are the consequences proposed by John McCarthy (1963) further developed by Raymond Reiter and others originally used for database transactions (1995) uses second-order logic (Reiter 2001) modeling of dynamic systems (e.g., robots, plants, ) basis for several (action) programming languages (e.g. Golog) 18
Properties of the Situation Calculus Advantages allows for reasoning about actions and change uses the foundations of logic allows for testing and proving of properties is solution to some fundamental problems of AI (e.g. frame problem) Drawbacks based on second-order logic domain modeling is complex and error prune real implementation somehow fuzzy computational expensive (in particular if you do it wrong) 19
Building Blocks Domain Dependent Objects Fluents Situations Actions The green building blocks are different sorts in the second order logic. The blue building block is used to retrieve properties about the world. 20
States Electrical Engineering or Computer Science several applications of states Deterministic Finite Automaton signup protocols parser model checking testing submission pass q 0 q 1 q 2 q 30 A Q,, q,, 0 F no submission not pass 22
Situations inductively defined as term a constant symbol S 0 denotes the initial situation (nothing happened so far) a binary function symbol do:actions sitations situations situations can be interpreted as sequences of actions do(a,s) performs action a in situation s do(a,s) adds action a to sequence represented by s binary predicate symbol :situation situation s s denotes that s is a proper subsequence of s 23
Sates versus Situations situations are different to states they contain a history of what happened so far snapshots of properties of the world are retrieved by fluents, i.e. which predicates hold in a situation two situations are different if their sequence is different the state of fluents may be the same 24
Situation Tree do(a n,s 0 ) a n a 3 a 2 a n a 1 S 0 a 3 a 2 do(a n,do(a 1,S 0 )) a 1 do(a 1,S 0 ) a n a 3 a 2 a 1 25
Example Dress Up 26
Actions actions are the only entities which change something (i.e., situations and truth values of fluents) actions are represented as function symbols actions have a unique name, if the names are different the actions perform different things actions can have parameters of arity n, e.g. moveto(object, room) or sleep() an action a is executed in a situation s by the function s =do(a,s) leading to a new situation s an action has a precondition in which situation an action is possible to be executed 27
Action Precondition Axioms take care if an action a is executable we introduce a binary predicate symbol Poss:action situation is a sentence in the form Poss(A(x 1,,x n ),s) A (x 1,,x n,s) A is a formula with free variables x 1,,x n and s e.g. Poss(enter_room(x),s) door_open(x,s) axioms have to be defined for all actions a A 29
Fluents used to catch the dynamic world fluents are related to states represent relations and functions that change from situation to situation two different fluents relational fluents functional fluents 30
Relational Fluents represents a relation (or properties) of objects in a situation s it is represented by a predicate symbol with arity n+1 in the form F(x 1,,x n,s) F:(objects actions) n situation {T,F} it represents the truth value of a relation or property in a certain situation examples: at(x,y,s) or broken(x,s) 31
Functional Fluents represents a function of objects in a situation s it is represented by a function symbol with arity n+1 in the form f(x 1,,x n,s) it represents the result (object) of a function f:(objects actions) n situation (objects actions) example: position(x,s) 32
Frame Problem another important (fundamental) problem of AI formulated by John McCarhty and Patrick Hayes related to the abstract modeling of dynamic world how to efficiently specify what is changed by an action and what remains the same sloppy: logic has no memory we need frame axioms example: the color of an object does not change if it is lifted, color(x,c,s) color(x,c,do(lift(x),s)) 33
Successor State Axioms (1) are a solution to the Frame Problem naively we have to specify all effect axioms (because of the frame problem) a. φ F+ (x 1,,x n, y 1,,y m, s) F(x 1,,x n,do(a(y 1,,y m ),s)) b. φ F- (x 1,,x n, y 1,,y m, s) F(x 1,,x n,do(a(y 1,,y m ),s)) example: fragile(x,s) broken(x,do(drop(x),s)) use Causal Completeness Assumption a and b specify all casual laws related to A and F 34
Successor State Axioms (2) F(x 1,,x n,s) F(x 1,,x n,do(a(y 1,,y m ),s)) φ F- (x 1,,x n,y 1,,y m,s) F(x 1,,x n,s) φ F- (x 1,,x n,y 1,,y m,s) F(x 1,,x n,do(a(y 1,,y m ),s)) [PFA] F(x 1,,x n,s) F(x 1,,x n,do(a(y 1,,y m ),s)) φ F+ (x 1,,x n,y 1,,y m,s) F(x 1,,x n,s) φ F+ (x 1,,x n,y 1,,y m,s) F(x 1,,x n,do(a(y 1,,y m ),s)) [NFA] lead to 2 x #actions x #fluents frame axioms fragile(x,s) broken(x,do(drop(x),s)) [PEA] broken(x,s) fragile(x,s) broken(x,do(drop(x),s)) [NFA] 35
Successor State Axioms (4) the general solution positive and negative normal form effect axioms + F(t 1,,t n,do(α,s)) ( y 1,,y m )[a=α x=t + ] F(x 1,,x n,do(a,s)) + F(x 1,,x n,do(a,s)) ( +(1) +(k) ) F(x 1,,x n,do(a,s)) + (x 1,,x n,a,s) F(x 1,,x n,do(a,s)) [PNF] - (x 1,,x n,a,s) F(x 1,,x n,do(a,s)) [NNF] unique name axiom for actions A(x) B(y) and A(x 1,,x n )=A(y 1,,y n ) x 1 =y 1 x n =y n if T entails ( x,a,s). + (x,a,s) - (x,a,s) F(x,do(a,s)) + (x,a,s) F(x,s) - (x,a,s) [SSA-RF] 37
Successor State Axioms (5) now we need only #actions + #fluents axioms 38
Summary Successor State Axioms provides a solution to the Frame Problem yields simple compact axioms only for deterministic primitive actions does not solve the qualification and ramification problem length of successor state axioms ~ #actions change a fluent assumption: only a few actions change a fluent 39
Initial Situation S 0 is a special constant of sort situation it represents the initial situation D S0 is the initial database it comprises sentences describing the initial theory of the world, i.e. fluents that hold in S 0 S 0 is the only situation mentioned D S0 must not mention Poss, do or it may comprise non-situation terms examples: location(robot,office1,s 0 ), mountain(mteverest) 42
Foundational Axioms for Situations ensure some properties of situations situations are understood as sequence of actions abbreviation: do(a n,( do(a 1,S 0 )) = do([a 1,a n ],S 0 ) s s denotes that s is a subsequence of s 1. do(a 1,s 1 )=do(a 2,s 2 ) a 1 =a 2 s 1 =s 2 [UNA] 2. P.P(S 0 ) a,s.(p(s) P(do(a,s))) s.p(s) [SCA] 3. (s S 0 ) [nothing happened prior S 0 ] 4. s do(a,s ) s s with s s ~ s s s=s 43
Basic Action Theory (BAT) D D ssa D ap D una D S 0 Σ set of foundational axioms for situations D ssa set of successor state axioms D ap set of action precondition axioms D una set of unique name axioms for actions D set of first order sentences uniform in S S 0 0 44
Putting all Together (An Example) Towers of Hanoi a b c 3 2 1 3 2 1 45
Regression related to the projection problem does a sentence hold for a future situation used for automated reasoning and planning in the SC sketch: prove if sentence W is entailed by BAT W mentions a relational fluent F(x 1,,x n,do(a,σ)) successor state axiom F(x 1,,x n,do(a,s)) F (x 1,,x n,a,s) obtain W by substituting F by F eliminating complex situation do(a, σ) from W W is closer to S 0 than W repeat the substitution until W 0 uniform in S 0 now we can prove W in the initial database (no second order axioms) 46
Regressable Formulas a formula W in the situation calculus is regressable iff 1. situation terms mentioned in W are of the form do([α 1,,α n ],S 0 ) 2. for atoms of form Poss(α,s) mentioned in W α has the form A(t 1,,t n ) and is an action function symbol 3. W does not quantify over situations 4. W does not mention the predicate symbol nor any equality atom σ=σ for situations 47
Examples for Regressable Formulas 1. Poss(walk(A,B)S 0 ) Poss(enter(office(Sue)),do(walk(A,B),S 0 )) Poss(giveCoffee(Sue),do([walk(A,B),enter(Office(Sue))],S 0 ) 2. ( a,a ).ontable(a,do(a,s 0 )) ( x).x A ontable(x,do([a,a ],S 0 )) Regressable? Poss(a,S 0 ) holding(x,do(pickup(a),s)) 48
Regression Operator 1. if W is situation-independent or a relational fluent F(x,S 0 ) [W]=W 2. if W is a regressable Poss(A(t),σ) atom and Poss(A(x),s) A (x,s) [W]= [ A (t,σ)] 3. if W is a relational fluent F(t,do(α,σ)) and F(x,do(a,s)) F (x,a,s) [W]= [ F (t,α,σ)] 4. [ W]= [W] [W 1 W 2 ]= [W 1 ] [W 2 ] [( v)w]=( v) [W] 49
Important Result from Regression if D is a basic action theory and W is a regressable sentence then, D W iff D S 0 D una [W] 50
Situation Calculus Summary allows for reasoning about change and actions a dialect of the second-order logic uses the concept of situations allows for proving properties solves the frame problem Basic Action Theory implements the situation calculus Action Precondition & Successor State Axioms & Unique Name Assumption & Foundation Axioms & Initial Situation Regression and Planning allows for automated reasoning and planning 53
Outlook Programming with SC Situation Calculus is yet only a theoretical construct Golog (algol for Logic) is based on the Situation Calculus it is a program language for dynamic systems cumbersome to use (Prolog-based interpreter ) YAGI (yet another golog interpreter) gives a clear syntax and better usability 54
Questions? 55