2:-op(300, fy, ?). 3
4lower_case_list(A,B) :-
5 findall(Y,(member(X,A),lower_case(X,Y)),B).
6
7capitalize(WordLC, WordUC) :-
8 atom_chars(WordLC, [FirstChLow|LWordLC]),
9 atom_chars(FirstLow, [FirstChLow]),
10 upcase_atom(FirstLow, FirstUpp),
11 atom_chars(FirstUpp, [FirstChUpp]),
12 atom_chars(WordUC, [FirstChUpp|LWordLC]),!.
13
14require_def(R) --> ['(',':','requirements'], oneOrMore(require_key, R), [')'].
15require_key(strips) --> [':strips'].
16require_key(typing) --> [':typing'].
17require_key('negative-preconditions') --> [':negative-preconditions'].
18require_key('disjunctive-preconditions') --> [':disjunctive-preconditions'].
19require_key(equality) --> [':equality'].
20require_key('existential-preconditions') --> [':existential-preconditions'].
21require_key('universal-preconditions') --> [':universal-preconditions'].
22require_key('quantified-preconditions') --> [':quantified-preconditions'].
23require_key('conditional-effects') --> [':conditional-effects'].
24require_key(fluents) --> [':fluents'].
25require_key(adl) --> [':adl'].
26require_key('durative-actions') --> [':durative-actions'].
27require_key('derived-predicates') --> [':derived-predicates'].
28require_key('timed-initial-literals') --> [':timed-initial-literals'].
29require_key(preferences) --> [':preferences'].
32require_key(R) --> [':', R].
33
34types_def(L) --> ['(',':',types], subsumptionList(L), [')'].
35constants_def(L) --> ['(',':',constants], typed_list(name, L), [')'].
36predicates_def(P) --> ['(',':',predicates], oneOrMore(atomic_formula_skeleton, P), [')'].
37
38atomic_formula_skeleton(F)
39 --> ['('], predicate(P), typed_list(variable, L), [')'], {F =.. [P|L]}.
42atomic_function_skeleton(f(S, L))
43 --> ['('], function_symbol(S), typed_list(variable, L), [')'].
44
45functions_def(F) --> ['(',':',functions], zeroOrMore(function_def,F), [')']. 46
47function_def(F) --> ['('],name(N),zeroOrMore(typed_arguments,A),[')'],{F = f(N,A)}.
48typed_arguments(A) --> oneOrMore(variable,Variables),['-'],name(T),{A = are(Variables,T)}.
52structure_def(A) --> action_def(A).
53structure_def(D) --> durative_action_def(D). 54structure_def(D) --> derived_def(D). 55
56function_typed_list(W, [F|Ls]) --> oneOrMore(W, L), ['-'], !, function_type(T), function_typed_list(W, Ls), {F =.. [are,L,T]}. 57function_typed_list(W, L) --> zeroOrMore(W, L).
58
59function_type(number) --> [number].
60emptyOr(_) --> ['(',')'].
61emptyOr(W) --> W.
62
64action_def(action(S, L, Precon, Pos, Neg, Assign))
65 --> ['(',':',action], action_symbol(S),
66 [':',parameters,'('], typed_list(variable, L), [')'],
67 action_def_body(Precon, Pos, Neg, Assign),
68 [')'].
69
70durative_action_def(durativeAction(S, L, V, P1, P2))
71 --> ['(',':','durative-action'], action_symbol(S),
72 [':',parameters,'('], typed_list(variable, L), [')'],
73 [':',duration,'('], ['='], variable(_), value(V), [')'],
74 durative_action_def_body(P1, P2), [')'].
75
76value(V) --> atomic_function(_,V).
77value(V) --> f_exp(V).
78
79action_symbol(N) --> name(N).
80action_def_body(P, Pos, Neg, Assign)
81 --> (([':',precondition], emptyOr(pre_GD(P))) ; []),
82 (([':',effect], emptyOr(effect(Pos, Neg, Assign))) ; []).
83
84durative_action_def_body(P1, P2)
85 --> (([':',condition], temp_GD(P1)) ; []),
86 (([':',effect], temp_GD(P2)) ; []).
87
88temp_GD(P) --> ['(',and], oneOrMore(temp_GD,P), [')'].
89temp_GD('at start'(P)) --> ['('],[at,start],pre_GD(P),[')'].
90temp_GD('at end'(P)) --> ['('],[at,end],pre_GD(P),[')'].
91temp_GD('over all'(P)) --> ['('],[over,all],pre_GD(P),[')'].
92temp_GD(P) --> pre_GD(P).
93
94pref_name(N) --> name(N).
95
96atomic_function(_, F) --> ['('], function_symbol(S), zeroOrMore(term, T), [')'], {F =.. [S|T]}.
97
98f_exp(N) --> number(N).
99f_exp(op(O, E1, E2)) --> ['('], binary_op(O), f_exp(E1), f_exp(E2), [')'].
100f_exp('-'(E)) --> ['(','-'], f_exp(E), [')'].
101f_exp(H) --> f_head(H).
102
103binary_op(O) --> multi_op(O).
104binary_op('-') --> ['−'].
105binary_op('/') --> ['/'].
106multi_op('*') --> ['*'].
107multi_op('+') --> ['+'].
108multi_op('-') --> ['-'].
109
110cond_effect(E) --> ['(',and], zeroOrMore(p_effect, E), [')']. 111cond_effect(E) --> p_effect(E).
120effect(P, N, A) --> ['(',and], c_effect(P, N, A), [')'].
121effect(P, N, A) --> c_effect(P, N, A).
123c_effect(when(P, E)) --> ['(',when], gd(P), cond_effect(E), [')']. 124c_effect(P, N, A) --> p_effect(P, N, A).
125p_effect([], [], []) --> [].
126p_effect(Ps, Ns, [F|As]) --> ['('], assign_op(O), [')'], p_effect(Ps, Ns, As), {F =.. [O]}.
128p_effect(Ps, [F|Ns], As) --> ['(',not], atomic_formula(term,F), [')'], p_effect(Ps, Ns, As).
129p_effect([F|Ps], Ns, As) --> atomic_formula(term, F), p_effect(Ps, Ns, As).
130p_effect(op(O, H, E)) --> ['('], assign_op(O), f_head(H), f_exp(E), [')']. 131
132derived_def(derived(S,G)) --> ['(', ':', 'derived'], atomic_formula_skeleton(S), gd(G), [')'].
133
134:- ensure_loaded('sharedPDDL2.2').