Short answer: Deterministic clauses and probabilistic clauses have different semantics. Long answer in part 2.
Part 1: What your program means
substance(Y). % means everything is a substance.
property(1, use, Y). % means: 1 uses everything (whatever 1 is)
As indicated in Paulo's answer to your previous question, the scope of the variable is limited to the clause. The Y in these facts are not the same variable. From a logic perspective, you have 2 separate clauses:
(forall Y: substance(Y))
(forall Z: person(1, use, Z))
His suggestion will work and means person 1 uses all substances.
substance(methadone).
substance(heroin).
substance(methadone).
substance(heroin).
0.8::property(X,use,nicotine) :- %gives NonGroundProbabilisticClause error
property(X,use,Z),
substance(Z).
% person(1).
% property(1, use, Y):- substance(Y). % person1 uses all substances
query(property(1,use, nicotine)).
% property(1,use,nicotine): 0.96
EDIT after seeing what you meant
Since you want it to be 0.8 whether uses 1 or many substances, you can just do this:
argument-in-prolog-using-a-series-of-facts
substance(methadone).
substance(heroin).
0.8::property(X,use,nicotine) :-
uses_atleast_one_substance(X).
uses_atleast_one_substance(X):-
property(X,use,Z),
substance(Z).
person(1).
property(1, use, Y):- substance(Y).
query(property(1,use, nicotine)).
Part 2: What's happening
I have to make a guess here: The non-probabilistic clause may work because it's non-probabilistic and hence not an annotated-disjunction. It may have prolog-like semantics.
Probabilistic clauses follow the semantics of annotated disjunctions. Every probabilistic clause is implicitly an annotated disjunction -
p::head:- body.
is p::head ; (1-p)not_head:- body.
Here's a paper with the semantics of "Logic Programs with Annotated Disjunctions".
It says every grounding of the body independently causes the head to be true with the specified probability.
With that in mind, The reason you're getting the error is because there is indeed a non-ground BODY in the proof.
P::property(X,use,nicotine) :- %gives NonGroundProbabilisticClause error
property(X,use,W), % This can unify with person(1,use,Z), leaving Z free
substance(Z), % This can unify with substance(Y), leaving Z free
P is 0.8.
You can't have variables in the body because you don't know how many causes there are. It breaks the semantics and problog detects it and throws an error. That's what's happening.