-1

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?

false
  • 10,264
  • 13
  • 101
  • 209
user3043636
  • 559
  • 6
  • 23

1 Answers1

2

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.

Paulo Moura
  • 18,373
  • 3
  • 23
  • 33