1

Assume that I have the following statements:

A p B, A p C, B p C  ( p is a symmetric property, i.e.  B p A, C p A and C p B)
A v 2, B v 1, C v 1,

I want to use a rule to do something like:

?a p all(?b)
if ?b v 1
than ?a q 'Yes'

that means that you can infer (A q 'Yes'), but B can't since B p A and A v 2(although B p C and C v 1).

[rule: (?a eg:p ?b), (?b eg:v 1) -> (?a eg:q 'Yes')]

I've used the above rule in Jena, but I got A,B,C eg:q 'Yes', which is wrong. Any help will be greatly appreciated.

Update (originally posted as an answer)

the meaning of (?a p all(?b)) is that I like to get a set which all ?mem in this set fulfill the (?a p ?mem). And all member must fulfill (?mem v 1) to infer (?a q 'Yes').

For example,

A p B and A p C,so I get a set which contains (B, C).since B and C v 1,so A q 'Yes.

B p A and B p C,so I get a set(A, C),but A v 2,so can't infer that B q 'Yes'.

Problem Solved

Thanks to Joshua Taylor.

Firstly, these two rules can't use at the same time.The rule2 should be used after rule1.

And, the rule2 should be [rule2: (?s ?p ?o) noValue(?s, connectedToNonOne) -> (?s q 'Yes')].

  • It's not clear what your rule is supposed to mean. What is `?a p all(?b)` supposed to mean? The `if ?b v 1 then ?a q 'Yes'` is understandable. – Joshua Taylor May 03 '15 at 13:01

1 Answers1

1

but I got A,B,C eg:q 'Yes', which is wrong.

The rule you have actually written in Jena says

        For any two individuals X and Y, if (X p Y) and (Y v 1) then (X q 'Yes').

From the rule you've written, this is correct, by:

        (A p C), (C v 1) → (A q 'Yes')
        (B p C), (C v 1) → (B q 'Yes')
        (C p B), (B v 1) → (C q 'Yes')

What you're actually trying to say is:

        For any individual X, if for every individual Y, (X p Y) implies (Y v 1), then (X q 'Yes').

In first order logic, your original rule could be written as:

        ∀ x,y ([p(x,y) ∧ v(y,1)] → q(x,'yes')

What you're actually trying to capture would be:

        ∀x[(∀y[p(x,y) → v(y,1)]) → q(x,'yes')]

That's harder to capture in Jena rules, because to check whether (∀y[p(x,y) → v(y,1)]) holds or not, all Jena can do is check whether there are currently any counterexamples. If one were added later, you might have incorrect inferences.

Using the builtins available in the rule reasoner, you could do something with noValue and notEqual along the lines of:

#-- If an individual is disqualified by being
#-- connected to a something that is connected
#-- to something that is not equal to 1, then 
#-- add a connectedToNonOne triple.
[rule1: 
  (?x p ?y), (?y v ?z), notEqual(?z,1)
  ->
  (?x connectedToNonOne true)]

#-- Mark everything that is *not* disqualified
#-- with `q 'Yes'`.
[rule2:
  noValue(?x, connectedToNonOne)
  ->
  (?x q 'Yes')
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Yes, I understand the meaning of your rules.The rule1 works perfectly,but the rule2 doesn't work.It returns an (anonymous node, q, 'Yes')statement. – Jiaming Lin May 04 '15 at 03:19
  • Thank you so much.Problem solved.Firstly, these two rules can't use at the same time.The rule2 should be used after rule1. And, the rule2 should be [rule2: (?s ?p ?o) noValue(?s, connectedToNonOne) -> (?s q 'Yes')]. – Jiaming Lin May 04 '15 at 06:59