PROGRAMA SMODELS





Integrantes


Alejandra Cisneros Rojas

Ofelia Quintero Cerón

CORRIDAS

CODIGO Y PANTALLA DE YALE 1:


fluent(loaded).
fluent(alive).
action(load).
action(shoot).
time(0..1).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(alive,0).
occurs(shoot,0).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(F, T+1) :- fluent(F),
time(T),
action(A),
holds(F,T),
occurs(A,T),
not ab(F, A, T).
not_holds(F, T+1) :- fluent(F),
time(T),
action(A),
not_holds(F,T),
occurs(A,T),
not ab(F, A, T).
% holds(loaded, T+1) :- time(T),
% occurs(load, T).
% ab(loaded, load, T) :- time(T).
not_holds(alive, T+1) :- time(T),
occurs(shoot, T),
holds(loaded, T).
ab(alive, shoot, T) :- time(T),
not not_holds(loaded, T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hide fluent(F).
hide action(A).
hide time(T).
%hide ab(F,A,T).
%hide occurs(A,T).

CODIGO Y PANTALLA DE YALE 2:


fluent(loaded). fluent(alive).
action(load).
action(shoot).
time(0..1).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(alive,0).
occurs(shoot,0).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(F, T+1) :- fluent(F),
time(T),
action(A),
holds(F,T),
occurs(A,T),
not ab(F, A, T).
not_holds(F, T+1) :- fluent(F),
time(T),
action(A),
not_holds(F,T),
occurs(A,T),
not ab(F, A, T).

% holds(loaded, T+1) :- time(T), % occurs(load, T).

% ab(loaded, load, T) :- time(T).
not_holds(alive, T+1) :- time(T),
occurs(shoot, T),
holds(loaded, T).

ab(alive, shoot, T) :- time(T),
not not_holds(loaded, T).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(loaded, T) :- time(T),
occurs(shoot,T),
holds(alive,T),
not_holds(alive, T+1).

not_holds(loaded, T) :- time(T),
occurs(shoot,T),
holds(alive, T+1).

not_holds(F,T) :- time(T),
fluent(F),
action(A),
occurs(A,T),
not_holds(F, T+1),
not ab(F, A, T).

holds(F,T) :- time(T),
fluent(F),
action(A),
occurs(A,T),
holds(F, T+1),
not ab(F, A, T).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hide fluent(F).
hide action(A).
hide time(T).
%hide ab(F,A,T).
%hide occurs(A,T).

CODIGO Y PANTALLA DE BLOCK



const length=7.
time(1..length).
block(a).
block(b).
block(c).
block(d).
block(e).
initially(handempty).
initially(clear(a)).
initially(clear(c)).
initially(ontable(c)).
initially(ontable(b)).
initially(on(a,b)).
initially(on(c,d)).

finally(on(a,c)).
finally(on(c,b)).

not_goal(T):- time(T),
literal(X),
finally(X),
not holds(X,T).

goal(T) :- time(T),
not not_goal(T).

exists_plan :- goal(length).

:- not exists_plan.

%Defining what are fluents and
%what are actions.

fluent(on(X,Y)) :-
block(X),
block(Y).

fluent(ontable(X)) :-
block(X).

fluent(clear(X)) :-
block(X).

fluent(holding(X)) :-
block(X).

fluent(handempty).

fluent(soltado(X)):-
block(X).

action(pick_up(X)) :-
block(X).

action(put_down(X)) :-
block(X).
action(stack(X,Y)) :-
block(X),
block(Y).

action(unstack(X,Y)) :-
block(X),
block(Y).

action(soltar(X)):-
block(X).

%Effects of actions and executability conditions.

executable(pick_up(X), T) :-
block(X),
time(T),
T < length,
holds(clear(X), T),
holds(ontable(X), T),
holds(handempty, T).

executable(put_down(X), T) :-
block(X),
time(T),
T < length,
holds(holding(X),T)
.
executable(stack(X,Y),T) :-
block(Y),
block(X),
time(T),
T < length,
holds(holding(X),T),
holds(clear(Y), T).

executable(unstack(X,Y),T) :-
block(Y),
block(X),
time(T),
T < length,
holds(clear(X), T),
holds(on(X,Y), T),
holds(handempty, T).

executable(soltar(X),T):-
block(X),
time(T),
T holds(holding(X),T).

causes(pick_up(X), neg(ontable(X))) :-
block(X).

causes(pick_up(X), neg(clear(X))) :-
block(X).

causes(pick_up(X), holding(X)) :-
block(X).

causes(pick_up(X), neg(handempty)) :-
block(X).

causes(put_down(X), ontable(X)) :-
block(X).

causes(put_down(X), clear(X)) :-
block(X).
causes(put_down(X), neg(holding(X))) :-
block(X).
causes(put_down(X), handempty) :-
block(X).
causes(stack(X,Y), neg(holding(X))) :-
block(X),
block(Y).
causes(stack(X,Y), neg(clear(Y))) :-
block(X),
block(Y).

causes(stack(X,Y), clear(X)) :-
block(X),
block(Y).
causes(stack(X,Y), handempty) :-
block(X),
block(Y).
causes(stack(X,Y), on(X,Y)) :-
block(X),
block(Y).

causes(unstack(X,Y), holding(X)) :-
block(X),
block(Y).
causes(unstack(X,Y), clear(Y)) :-
block(X),
block(Y).
causes(unstack(X,Y), neg(clear(X))) :-
block(X),
block(Y).

causes(stac(X,Y), neg(handempty)) :-
block(X),
block(Y).
causes(soltar(X,Y), neg(handempty)) :-
block(X),
block(Y).
causes(unstack(X,Y), neg(on(X,Y))) :-
block(X),
block(Y).

causes(soltar(X),clear(X)):- block(X).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
literal(G) :-
fluent(G).
literal(neg(G)) :-
fluent(G).
contrary(F, neg(F)) :-
fluent(F).
contrary(neg(F), F) :-
fluent(F).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(F, 1) :-
literal(F),
initially(F).

holds(F, T+1) :-
literal(F),
time(T),
T < length,
action(A),
executable(A,T),
occurs(A,T),
causes(A,F).
holds(F, T+1) :-
literal(F),
literal(G),
contrary(F,G),
time(T),
T < length,
holds(F,T),
not holds(G, T+1).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
possible(A,T) :-
action(A),
time(T),
executable(A,T),
not goal(T).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
occurs(A,T) :-
action(A),
time(T),
possible(A,T),
not not_occurs(A,T).
not_occurs(A,T) :-
action(A),
action(AA),
time(T),
occurs(AA,T),
neq(A,AA).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hide time(T).
hide action(A).
hide causes(A,F).
hide initially(F).
hide contrary(F,G).
hide fluent(F).
hide literal(L).
hide executable(A,T).
hide holds(F,T).
hide not_occurs(A,T).
hide possible(A,T).
%hide possible1(A,T).
%hide possible2(A,T).
hide block(X).
hide exists_plan.
hide finally(X).
hide goal(T).
hide not_goal(T).

PANTALLA DE BLOCK 2:

PANTALLA DE BLOCK 3:

PANTALLA DE BLOCK 4:

PANTALLA DE BLOCK 5:

CODIGO Y PANTALLA DE PLANNING:


const length=9.
const no_pts=8.
time(1..length).
location(1..no_pts).
vehicle(v).
initially(edge(1,2)).
initially(edge(2,3)).
initially(edge(3,4)).
initially(edge(4,8)).
initially(edge(8,7)).
initially(edge(7,6)).
initially(edge(6,5)).
initially(edge(5,1)).
initially(edge(2,6)).
initially(edge(7,3)).

initially(at(v,3)).
finally(at(v,2)).
not_goal(T):- time(T),
literal(X),
finally(X),
not holds(X,T).

goal(T) :- time(T),
not not_goal(T).
exists_plan :-
goal(length).
:- not exists_plan.

%Defining what are fluents and %what are actions.
fluent(at(V,X)) :-
vehicle(V),
location(X).

fluent(edge(X,Y)) :-
location(X),
location(Y).
action(move(V,X,Y)) :-
vehicle(V),
location(X),
location(Y).

%Effects of actions and executability conditions.
impossible_if(move(V,L,LL), neg(at(V,L))) :- vehicle(V),
location(L),
location(LL).

impossible_if(move(V,L1,L2), neg(edge(L1,L2))) :-
vehicle(V),
location(L1),
location(L2).

%executable(move(V,L,LL), T) :-
% vehicle(V),
% location(L),
% location(LL),
% time(T),
% T < length,
% holds(at(V,L),T),
% holds(edge(L,LL), T),
% neq(L,LL).

causes(move(V,L,LL), at(V, LL)) :-
vehicle(V),
location(L),
location(LL).

causes(move(V,L,LL), neg(at(V,L))) :-
vehicle(V),
location(L),
location(LL).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
literal(G) :-
fluent(G).
literal(neg(G)) :-
fluent(G).
contrary(F, neg(F)) :-
fluent(F).
contrary(neg(F), F) :-
fluent(F).

%Defining Execeutability
not_executable(A,T) :-
action(A),
time(T),
impossible_if(A,B),
holds(B,T).

executable(A,T) :-
action(A),
time(T),
not not_executable(A,T).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
holds(F, 1) :-
literal(F),
initially(F).

holds(neg(F), 1) :-
fluent(F),
not holds(F,1).
holds(F, T+1) :-
literal(F),
time(T),
T < length,
action(A),
executable(A,T),
occurs(A,T),
causes(A,F).

holds(F, T+1) :-
literal(F),
literal(G),
contrary(F,G),
time(T),
T < length,
holds(F,T),
not holds(G, T+1).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
possible(A,T) :-
action(A),
executable(A,T),
time(T),
not goal(T).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
occurs(A,T) :-
action(A),
time(T),
possible(A,T),
not not_occurs(A,T).

not_occurs(A,T) :-
action(A),
action(AA),
time(T),
occurs(AA,T),
neq(A,AA).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hide time(T).
hide action(A).
hide causes(A,F).
hide initially(F).
hide contrary(F,G).
hide fluent(F).
hide literal(L).
hide executable(A,T).
hide holds(F,T).
hide not_occurs(A,T).
hide possible(A,T).
hide at(X,Y).
hide exists_plan.
hide finally(X).
hide goal(T).
hide not_goal(T).
hide impossible_if(X,Y).
hide location(L).
hide not_executable(A,T).
hide vehicle(V).

PANTALLA DE PLANNING 2:

1