next up previous
Next: Logical Operators Up: prolog Previous: Compound Query

Interactive Definitions

To enter facts and/or rules directly, type:

  | ?- consult(user).
  |

You get a new prompt as above (|). At this point you would enter your facts and rules. For example,

  | man(socrates).
  | mortal(X) :- man(X).
  | end_of_file.
  | ?-

When done entering facts and rules, just type 'end_of_file.', and you will return to the original prompt.

Now we can ask queries of our facts and rules. For example,

  | ?- man(socrates).

  yes
  | ?- mortal(X).

  X = socrates        <press return at this point>

  | ?- man(plato).

  no
  | ?-