next up previous
Next: Command predicates Up: plp A compiler for Previous: Examples


Dynamic Preferences with Variables

With variables, we can now express conditional, context-sensitive preferences:

bird(tweety).
penguin(tweety).
water_shy(tweety).

bird(opus).
emu(opus).

bird(scully).
toy(scully).

    flies(X) :- name(r1(X)), not neg flies(X), bird(X).
neg flies(X) :- name(r2(X)), not     flies(X), penguin(X).
neg flies(X) :- name(r3(X)), not     flies(X), emu(X).
neg flies(X) :- name(r4(X)), not     flies(X), toy(X).

(r1(X) < r2(X)) :- not water_shy(X).
(r1(X) < r3(X)).
For treating such programs, they are preprocessed in two steps:
  1. rules with variables are replaced by their ground instances;
  2. names with a complex term structure are turned into constants (eg. name(r(f(c))) is turned into name(r_f_c)).
These steps are included in the procedure vlp2pl/2 and accordingly in vlp2dlv/2 and vlp2sm/2. It is important to note that files containing logic programs with variables are supposed to have the extension .vlp !



Subsections

Torsten Schaub 2000-12-05