Re: use of constraints

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: use of constraints

Green, Leslie (Les)

Hi all,

I have previously done some work with constraints over OWL knowledge bases, and up until now I have been using A Protégé plugin (The Protégé Axiom Language) to describe the constraints.

I would like to be able to use something a little more RDF-native, and have been exploring the possibility of using n3 to describe the constraints.

However... It seems implication used in n3 and implemented in CWM and Euler is not logical implication, but a production style implication. I was wondering if there is any way to treat implication in n3 as logical implication?

For example, I want to do the following:

# For all :f in the current knowledge base with :foo of :a, there must exist a :t with :bar of the same value :a
# I cannot get this implication to work... Can it be done??
@forAll :f .
@forSome :t, :a .
{:f model:foo :a } => {:t model:bar :a}.

I have been attempting to treat the above n3 as a query, with the command:
java euler.EulerRunner model+datafile.n3 --query thisconstraintfile.n3
 
What I was hoping for was Euler to say that the above implication is proven within the knowledge base defined in "model+datafile.n3", however no matter if I set the data within that file to match (be proven) or not to match, I get the same result:

# Generated with http://eulersharp.sourceforge.net/ version 1.5.88 on 21 Jul 2008 05:42:36 GMT
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.

(<temprules.n3>!log:semantics
 <n3testrules.n3>!log:semantics)!log:conjunction =>
{
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix p0: <http://www.n3testrules.owl#>.
@prefix nsp0: <http://>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix q: <http://www.w3.org/2004/ql#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix r: <http://www.w3.org/2000/10/swap/reason#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fn: <http://www.w3.org/2006/xpath-functions#>.
@prefix time: <http://www.w3.org/2000/10/swap/time#>.
@prefix : <http://www.n3testmodel.owl#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix var: <http://localhost/var#>.
@prefix www: <http://www.n3testdata.owl#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix n3: <http://www.w3.org/2004/06/rei#>.


# No proof found in 1 step (100000 steps/sec) using 1 engine (31 triples)

# Proof found in 2 steps (200000 steps/sec) using 1 engine (31 triples)
}.

Am I crazy?? Can this be done within the n3 logic?

Cheers, Les

-----------------------------------------------------------------
Jos De Roo Said:

assume one calls
  {set-of-triples} => {}.
a constraint.
 
I found constraints quite useful
to write rules to detect inconsistencies
e.g.
  {?Y owl:disjointWith ?Z. ?X a ?Y, ?Z} => {}.

and to use single triple constraints as rule premise
e.g.
  {?X :cp :hipInjury. {?X :fracture :femur} => {}}
   => {?X :contusion :hip}.
so that given
  :Ann :cp :hipInjury.
  {:Ann :fracture :femur} => {}.
one could derive
  :Ann :contusion :hip.
and if it would somehow be the case that
  :Ann :fracture :femur.
then one can clearly detect that inconsistency.



Reply | Threaded
Open this post in threaded view
|

Re: use of constraints

jos.deroo
Hi Leslie,

The P => A in a query is indeed only intended as filter rule
i.e. if you have P then the answer is A.

What you seem to want is a query like

#################### constraintsQ.n3 #######################
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <triples#>.

@forAll :F, :A, :S.

{:F :foo :A.
 <triples.n3> log:semantics :S.
 :S log:notIncludes {_:T :bar :A}}
 =>
 {<triples.n3> :missing {_:X :bar :A}}.
############################################################

and then given

###################### triples.n3 ##########################
@prefix : <triples#>.

:les :foo :cat.
############################################################


the answer with ~/cwm triples.n3 --filter=constraintQ.n3
is

#Processed by Id: cwm.py,v 1.197 2007/12/13 15:38:39 syosi Exp
        #    using base file:///home/jdroo/temp/triples.n3
       
#  Notation3 generation by
#       notation3.py,v 1.200 2007/12/11 21:18:08 syosi Exp

#   Base was: file:///home/jdroo/temp/triples.n3
     @prefix : <triples#> .
   
    <>     :missing {
          [      :bar :cat ].
        } .
   
#ENDS


and with ~/euler --sem --nope --test triples.n3 --query constraintQ.n3
it is

#Processed by $Id: SEMLibrary.java 2244 2008-07-18 23:54:34Z josd $
@keywords is, of, a.

@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix nsp0: <file:/home/jdroo/temp/triples.n3#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix q: <http://www.w3.org/2004/ql#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix nsp1: <file:/home/jdroo/temp/constraintQ.n3#>.
@prefix r: <http://www.w3.org/2000/10/swap/reason#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fn: <http://www.w3.org/2006/xpath-functions#>.
@prefix time: <http://www.w3.org/2000/10/swap/time#>.
@prefix nsp2: <file:/home/jdroo/temp/>.
@prefix : <file:/home/jdroo/temp/triples#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix var: <http://localhost/var#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix n3: <http://www.w3.org/2004/06/rei#>.

nsp2:triples.n3 :missing {_:sk0 :bar :cat}.

#ENDS 47 msec.


This is scoped negation as failure and log:notIncludes is not
about finding wether the object formula is included in the
deductive closure of the subject formula.

Kind Regards,

Jos De Roo | Agfa HealthCare
Senior Researcher | HE/Advanced Clinical Applications Research
T  +32 3444 6256

Quadrat NV, Kortrijksesteenweg 157, 9830 Sint-Martens-Latem, Belgium
http://www.agfa.com/healthcare/
R.O.: Septestraat 27, B-2640 Mortsel, Belgium | RLE Antwerp | VAT BE 0403.003.524 | IBAN BE03570124715584 | Citibank International PLC, B-1050 Brussels
Click on link to read important disclaimer: http://www.agfa.com/healthcare/maildisclaimer

-----[hidden email] wrote: -----

To: <[hidden email]>
From: "Green, Leslie (Les)" <[hidden email]>
Sent by: [hidden email]
Date: 07/21/2008 07:51AM
Subject: Re: use of constraints


Hi all,

I have previously done some work with constraints over OWL knowledge bases, and up until now I have been using A Protégé plugin (The Protégé Axiom Language) to describe the constraints.

I would like to be able to use something a little more RDF-native, and have been exploring the possibility of using n3 to describe the constraints.

However... It seems implication used in n3 and implemented in CWM and Euler is not logical implication, but a production style implication. I was wondering if there is any way to treat implication in n3 as logical implication?

For example, I want to do the following:

# For all :f in the current knowledge base with :foo of :a, there must exist a :t with :bar of the same value :a
# I cannot get this implication to work... Can it be done??
@forAll :f .
@forSome :t, :a .
{:f model:foo :a } => {:t model:bar :a}.

I have been attempting to treat the above n3 as a query, with the command:
java euler.EulerRunner model+datafile.n3 --query thisconstraintfile.n3

What I was hoping for was Euler to say that the above implication is proven within the knowledge base defined in "model+datafile.n3", however no matter if I set the data within that file to match (be proven) or not to match, I get the same result:

# Generated with http://eulersharp.sourceforge.net/ version 1.5.88 on 21 Jul 2008 05:42:36 GMT
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.

(<temprules.n3>!log:semantics
<n3testrules.n3>!log:semantics)!log:conjunction =>
{
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix p0: <http://www.n3testrules.owl#>.
@prefix nsp0: <http://>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix q: <http://www.w3.org/2004/ql#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix r: <http://www.w3.org/2000/10/swap/reason#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fn: <http://www.w3.org/2006/xpath-functions#>.
@prefix time: <http://www.w3.org/2000/10/swap/time#>.
@prefix : <http://www.n3testmodel.owl#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix var: <http://localhost/var#>.
@prefix www: <http://www.n3testdata.owl#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix n3: <http://www.w3.org/2004/06/rei#>.


# No proof found in 1 step (100000 steps/sec) using 1 engine (31 triples)

# Proof found in 2 steps (200000 steps/sec) using 1 engine (31 triples)
}.

Am I crazy?? Can this be done within the n3 logic?

Cheers, Les

-----------------------------------------------------------------
Jos De Roo Said:

assume one calls
 {set-of-triples} => {}.
a constraint.

I found constraints quite useful
to write rules to detect inconsistencies
e.g.
 {?Y owl:disjointWith ?Z. ?X a ?Y, ?Z} => {}.

and to use single triple constraints as rule premise
e.g.
 {?X :cp :hipInjury. {?X :fracture :femur} => {}}
  => {?X :contusion :hip}.
so that given
 :Ann :cp :hipInjury.
 {:Ann :fracture :femur} => {}.
one could derive
 :Ann :contusion :hip.
and if it would somehow be the case that
 :Ann :fracture :femur.
then one can clearly detect that inconsistency.