Aa is 50*100,write(aa),nl,aa is 50*15,write(aa),nl. in prolog
Answers
Answered by
10
I can in a predicate write that code to a file and then consult it, and query a . .... listing(a), listing(b). main:-retractall(a(X)),assert(a(1):- write('aa')), retractall(b(X)),assert ...
Answered by
15
Let's get started with a quick knowledge base. This KB comes directly from page 42 of "Thinking as Computation" by Hector Levesque. There's nothing special here. It's just a basic KB that we can start with.
% This is the Prolog version of the family example
child(john,sue). child(john,sam).
child(jane,sue). child(jane,sam).
child(sue,george). child(sue,gina).
male(john). male(sam). male(george).
female(sue). female(jane). female(june).
parent(Y,X) :- child(X,Y).
father(Y,X) :- child(X,Y), male(Y).
opp_sex(X,Y) :- male(X), female(Y).
opp_sex(Y,X) :- male(X), female(Y).
grand_father(X,Z) :- father(X,Y), parent(Y,Z).
Similar questions