tags:

views:

74

answers:

1

Hello people,

I am trying to create some rules and facts on a certain situation. The situation is such that if a user owes money then he is said to be in debt after 5 days if it is not repaid, if he doesn't then he is a normal person. So far i'm experimenting with something like:

I have two rules:

debtpayment_unfulfilled(X) :- owes_money(W, Amountowed, Amountpaid, Days), Days >= 7,Amountowed > Amountpaid. .
debtpayment_fulfilled(X) :- debt_paid(W,Amountowed,Amountpaid), Amountowed =:= Amountpaid.
owes_money(jim, 500, 200, 8).

But i can't seem to get it to compile, XSB tells me there is an unbound variable expr in clause #1...

any ideas? edit scrap that, I have just got it to compile lol, typo, btw does the ruling look right for what im trying to do? when i try running it, i cant get an answer with the query:

debtpayment_unfulfilled(jim).

edit:

is it possible to do something like this:

debtpayment_unfulfilled(X) :- owes_money(X, Amountowed, Amountpaid, Days), Days >= Days + 7,Amountowed > Amountpaid.

the days + 7 bit or is that not possible?

+1  A: 

Your mistake is that you use different variable names in debtpayment_unfulfilled and owes_money. Try this:

debtpayment_unfulfilled(X) :- owes_money(X, Amountowed, Amountpaid, Days), Days >= 7,Amountowed > Amountpaid.
debtpayment_fulfilled(X) :- debt_paid(X, Amountowed, Amountpaid), Amountowed =:= Amountpaid.
owes_money(jim, 500, 200, 8).
3lectrologos
cheers, i think it did the trick, but i was wondering, instead of having two rules for fulfilled/unfulfilled wouldnt it be better jsut to have say the first one(unfulfilled) as it would tell you if a debt as been paid and also if it has not been paid if it evaluates to false?
KP65
I didn't give much thought to the semantics before. Yes, given that fulfilled/unfulfilled are exact opposites (that can't be seen the way they're formulated now), it would be better to have only one rule.
3lectrologos
please see the edit i have made, maybe you can help?
KP65