You can create facts a prolog file and load them using
consult function.
For example,
animals.pl
bigger(elephant, tiger). bigger(tiger, rabbit). bigger(rabbit, sparrow). bigger(sparrow, ant).
1 ?- consult(animals). true. 2 ?- bigger(tiger, rabbit). true. 3 ?- bigger(dragon, bluewhale). false.
You can also use assert function to define facts in
prolog terminal.
1 ?- assert(bigger(elephant, rabbit)). true. 2 ?- assert(bigger(rabbit, ant)). true. 3 ?- bigger(elephant, rabbit). true.
assert(bigger(elephant,
rabbit)).
assert(bigger(rabbit,
ant)).
Above two statements define the facts.
bigger(elephant,
rabbit).
Above statement asks prolog, is elephant bigger than
rabbit?
No comments:
Post a Comment