meta-interpreter Prolog, count the number of ground facts

169 Views Asked by At

I have a proof(meta-interpreter) in prolog :

 solvept(true,true):- !.
 solvept((A,B),(ProofA,ProofB)):-
     !, solvept(A,ProofA), solvept(B,ProofB).
 solvept(A,(A:-Proof)):-
     clause(A,B), solvept(B,Proof).

with this KB :

  son(aa,bb).
  son(bb,cc).
  son(rr,tt).

OK, now I want count the number of ground facts. Who can help me?

1

There are 1 best solutions below

0
On

Some hints: the clause/2 standard predicate returns the atom true in its second argument for facts. There's also a ground/1 standard predicate that allows you to test if a term is ground. Finally, you need some extra arguments to actually count the number of ground facts used during a proof. This number is initially zero and it's incremented every time you use a ground fact. Try to use an accumulator to implement the counting. Consider reporting back your implementation attempts.