I want to restrict the query property(X, use, Y)
to values of Y
in the list [a,b,c]
.
c/1
is true for only those values of Y
.
I thought the following would work, but it doesn't.
c(a).
c(b).
c(c).
property(X, use, Y).
c(Y).
The following statements yield only false
.
person(1).
property(1, use, _).
I'm using Problog, but I'm not using any Problog functions here, so I think I am misunderstanding something about unification.
I thought c(Y)
would generate the list and Y
would be unified across the facts.
Update
This does seem to be an Problog-specific issue as the following illustrates.
substance(methadone).
substance(heroin).
P::property(X,use,nicotine) :- %doesn't work
property(X,use,Z),
substance(Z),
P is 0.8.
property(X,use,nicotine) :- %works
property(X,use,Z),
substance(Z).
person(1).
substance(Y).
property(1, use, Y).
question from:
https://stackoverflow.com/questions/65862141/how-to-restrict-values-of-an-argument-in-prolog-using-a-series-of-facts 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…