%% bc.lp -- Chapter 8, Section 8.5.1 %% Last Modified: 2/3/14 %% Models a domain description of a briefcase with two clasps. %% Action toggle(C) causes a particular clasp to be toggled. %% If both clasps are up, the briefcase is open. %% Domain Signature clasp(1). clasp(2). %% Fluents: fluent(inertial, up(C)) :- clasp(C). fluent(defined, open). %% Action: action(toggle(C)) :- clasp(C). #const n = 1. step(0..n). %% toggle(C) causes up(C) if -up(C) holds(up(C), I+1) :- occurs(toggle(C),I), -holds(up(C), I), I < n. %% toggle(C) causes -up(C) if up(C) -holds(up(C), I+1) :- occurs(toggle(C),I), holds(up(C), I), I < n. %% open if up(1), up(2). holds(open, I) :- holds(up(1),I), holds(up(2),I). %% CWA for Defined Fluents -holds(F,I) :- fluent(defined,F), step(I), not holds(F,I). %% General Inertia Axiom holds(F,I+1) :- fluent(inertial,F), holds(F,I), not -holds(F,I+1), I < n. -holds(F,I+1) :- fluent(inertial,F), -holds(F,I), not holds(F,I+1), I < n. %% CWA for actions -occurs(A,I) :- action(A), step(I), not occurs(A,I). %% Particular initial situation %% Change at will: -holds(up(1),0). holds(up(2),0). -holds(open,0). %% Particular occurence of action toggle at step 0 %% Change at will: occurs(toggle(1),0). %% Display for clingo %#show holds/2. %#show -holds/2.