From: <jm...@us...> - 2010-03-26 17:33:08
|
Revision: 1360 http://eulergui.svn.sourceforge.net/eulergui/?rev=1360&view=rev Author: jmvanel Date: 2010-03-26 17:33:02 +0000 (Fri, 26 Mar 2010) Log Message: ----------- swrl-n3-rules: extract variableSubstitution.n3 from swrl-n3-rules.n3 Modified Paths: -------------- trunk/eulergui/examples/swrl-n3-rules.n3 trunk/eulergui/examples/swrl-n3-rules.n3p Added Paths: ----------- trunk/eulergui/examples/variableSubstitution.n3 Modified: trunk/eulergui/examples/swrl-n3-rules.n3 =================================================================== --- trunk/eulergui/examples/swrl-n3-rules.n3 2010-03-26 16:02:18 UTC (rev 1359) +++ trunk/eulergui/examples/swrl-n3-rules.n3 2010-03-26 17:33:02 UTC (rev 1360) @@ -138,111 +138,3 @@ } => { ?RULE :distinctVariables ?LAD . }. - -######## variable substitution ######### - -#** variable substitution of ?V by ?VT in a triple ?T == {?S ?P ?O} -{ {?V ?P ?O} :substituteVariable (?V ?VT). -} => { # the subject is substituted - ( {?V ?P ?O} (?V ?VT) ) :variableSubstitution {?VT ?P ?O} -}. -{ {?S ?P ?V} :substituteVariable (?V ?VT). -} => { # the object is substituted - ( {?S ?P ?V} (?V ?VT) ) :variableSubstitution {?S ?P ?VT} -}. - -#** substitution of a list of variable substitutions ?L in a statement -# Antecedent: :substituteVariableList -# @subject an RDF statement -# @object list of variable substitutions, e.g. ( (:x ?X)(:y ?Y) ) -#** Consequent: :substituteVariableList - substitution of a list of variable substitutions ?L in a triple -{ - (?STAT ?INVARIANT) :substituteVariableList ?L . - # _:d e:trace ( rdf:first :substituteVariableList ?L ). - ?STAT log:includes {?S ?P ?O} . - # ?L a rdf:List . - ?L rdf:first (?V ?VT) . - # _:d e:trace ( rdf:first :substituteVariableList ?L log:includes {?V ?P ?O} ). -} => { - {?S ?P ?O} :substituteVariable (?V ?VT). -}. - -{ - (?STAT ?INVARIANT) :substituteVariableList ?L . - ?STAT log:includes {?S ?P ?O} . - # ?L a rdf:List . - ?L rdf:rest ?REST . - - # recover result from preceding rule: - ?L rdf:first (?V ?VT) . - ( {?S ?P ?O} (?V ?VT) ) :variableSubstitution {?SS ?P ?OS} . - - # _:d e:trace ( rdf:rest :substituteVariableList ?L - # :variableSubstitution {?SS ?P ?OS} ). -} => { - # ?REST a rdf:List . - ({?SS ?P ?OS} ?INVARIANT) :substituteVariableList ?REST . -}. - -# substitution of triples in a formula ?F - WIP -{ ?F :substituteVariablesInFormula ?L . - # ?F log:includes ?STAT . - ?F log:includes {?S ?P ?O} . - # _:d e:trace ("substituteVariablesInFormula" - # ?F ?STAT # ?L ). -} => { - ( - # ?STAT - {?S ?P ?O} - # ( ?F ?STAT ?L ) # INVARIANT - ( ?F {?S ?P ?O} ?L ) # INVARIANT - ) :substituteVariableList ?L . -}. - -#** recover the fully substituted triple from the initial formula, non substituted triple ?STAT and substitution list ?L -{ - ( ?STAT (?F ?STAT ?L) # INVARIANT - ) :substituteVariableList ?L . - - #_:d e:findall ( ?STAT_ - # {(?STAT_ (?F ?STAT ?L) ) :substituteVariableList ()} ?TSUBST ). - (?TSUBST (?F ?STAT ?L) ) :substituteVariableList (). - - # _:d e:trace ("trace substitutedTriple" - # ?F ?STAT ?L ). - -} => { - (?F ?L) :substitutedTriplesInFormula ?TSUBST. -}. - -{ ?F :substituteVariablesInFormula ?L . - _:d e:findall ( ?TSUBST_ - { (?F ?L) :substitutedTriplesInFormula ?TSUBST_ . } - ?TSUBST ). - ?TSUBST log:conjunction ?FSUBST . -} => { - (?F ?L) :substitutedFormula ?FSUBST. -}. - -# substitution of triples in a pair of formulas (?A ?C) . TODO - - -# test substituteVariableList -# ( {:x :sibling :y} -# ( {:x :sibling :y} ( (:x ?X)(:y ?Y) ) ) -# ) :substituteVariableList -# ( (:x ?X)(:y ?Y) ) . -# ( (:x ?X)(:y ?Y) ) a rdf:List . - - {:x :sibling :y. :x :hates :y.} :substituteVariablesInFormula - ( (:x _:x)(:y _:y ) ) . -# ( (:x _:x)(:y _:y ) ) a rdf:List . # useless with latest Euler - -{ ?LC :substituteVariable ?L . } => { _:dd :print (?LC :substituteVariable ?L) . }. -{ ?LC :variableSubstitution ?L . } => { _:dd :print (?LC :variableSubstitution ?L) . }. -{ ?LC :substituteVariableList ?L . } => { _:dd :print (?LC :substituteVariableList ?L) . }. -{ ?LC :substitutedTriple ?L . } => { _:dd :print (?LC :substitutedTriple ?L) . }. -{ ?LC :substitutedTriplesInFormula ?L . } => { _:dd :print (?LC :substitutedTriplesInFormula ?L) . }. -{ ?LC :substitutedFormula ?L . } => { _:dd :print (?LC :substitutedFormula ?L) . }. -# -{ ?LC :substituteVariablesInFormula ?L . } => { _:dd :print (?LC :substituteVariablesInFormula ?L) . }. Modified: trunk/eulergui/examples/swrl-n3-rules.n3p =================================================================== --- trunk/eulergui/examples/swrl-n3-rules.n3p 2010-03-26 16:02:18 UTC (rev 1359) +++ trunk/eulergui/examples/swrl-n3-rules.n3p 2010-03-26 17:33:02 UTC (rev 1360) @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<java version="1.6.0_18" class="java.beans.XMLDecoder"> +<java version="1.6.0_18-ea" class="java.beans.XMLDecoder"> <object class="eulergui.project.Project"> + <void property="eulerArguments"> + <string></string> + </void> <void property="n3Query"> <object class="eulergui.project.N3Source"> <void property="URI"> @@ -33,6 +36,14 @@ </void> </object> </void> + <void method="put"> + <string>./variableSubstitution.n3</string> + <object class="eulergui.project.N3Source"> + <void property="URI"> + <string>./variableSubstitution.n3</string> + </void> + </object> + </void> </void> </object> </java> Added: trunk/eulergui/examples/variableSubstitution.n3 =================================================================== --- trunk/eulergui/examples/variableSubstitution.n3 (rev 0) +++ trunk/eulergui/examples/variableSubstitution.n3 2010-03-26 17:33:02 UTC (rev 1360) @@ -0,0 +1,88 @@ +@prefix : <http://owldl.com/ontologies/dl-safe.owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. +@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#> . +@prefix log: <http://www.w3.org/2000/10/swap/log#> . + +######## variable substitution ######### + +#** variable substitution of ?V by ?VT in a triple ?T == {?S ?P ?O} +{ {?V ?P ?O} :substituteVariable (?V ?VT). +} => { # the subject is substituted + ( {?V ?P ?O} (?V ?VT) ) :variableSubstitution {?VT ?P ?O} +}. +{ {?S ?P ?V} :substituteVariable (?V ?VT). +} => { # the object is substituted + ( {?S ?P ?V} (?V ?VT) ) :variableSubstitution {?S ?P ?VT} +}. + +#** substitution of a list of variable substitutions ?L in a statement +# Antecedent: :substituteVariableList +# @subject an RDF statement +# @object list of variable substitutions, e.g. ( (:x ?X)(:y ?Y) ) +#** Consequent: :substituteVariableList - substitution of a list of variable substitutions ?L in a triple +{ + (?STAT ?INVARIANT) :substituteVariableList ?L . + # _:d e:trace ( rdf:first :substituteVariableList ?L ). + ?STAT log:includes {?S ?P ?O} . + ?L rdf:first (?V ?VT) . +} => { + {?S ?P ?O} :substituteVariable (?V ?VT). +}. + +{ + (?STAT ?INVARIANT) :substituteVariableList ?L . + ?STAT log:includes {?S ?P ?O} . + ?L rdf:rest ?REST . + + # recover result from preceding rule: + ?L rdf:first (?V ?VT) . + ( {?S ?P ?O} (?V ?VT) ) :variableSubstitution {?SS ?P ?OS} . +} => { + ({?SS ?P ?OS} ?INVARIANT) :substituteVariableList ?REST . +}. + +# substitution of triples in a formula ?F - WIP +{ ?F :substituteVariablesInFormula ?L . + # ?F log:includes ?STAT . + ?F log:includes {?S ?P ?O} . +} => { + ( + {?S ?P ?O} + ( ?F {?S ?P ?O} ?L ) # INVARIANT + ) :substituteVariableList ?L . +}. + +#** recover the fully substituted triple from the initial formula, non substituted triple ?STAT and substitution list ?L +{ + ( ?STAT (?F ?STAT ?L) # INVARIANT + ) :substituteVariableList ?L . + (?TSUBST (?F ?STAT ?L) ) :substituteVariableList (). +} => { + (?F ?L) :substitutedTriplesInFormula ?TSUBST. +}. + +#** recover the fully substituted formula from the initial formula and substitution list ?L +{ ?F :substituteVariablesInFormula ?L . + _:d e:findall ( ?TSUBST_ + { (?F ?L) :substitutedTriplesInFormula ?TSUBST_ . } + ?TSUBST ). + ?TSUBST log:conjunction ?FSUBST . +} => { + (?F ?L) :substitutedFormula ?FSUBST. +}. + +# substitution of triples in a pair of formulas (?A ?C) . TODO + +# test data + {:x :sibling :y. :x :hates :y.} :substituteVariablesInFormula + ( (:x _:x)(:y _:y ) ) . + +# test print +{ ?LC :substituteVariable ?L . } => { _:dd :print (?LC :substituteVariable ?L) . }. +{ ?LC :variableSubstitution ?L . } => { _:dd :print (?LC :variableSubstitution ?L) . }. +{ ?LC :substituteVariableList ?L . } => { _:dd :print (?LC :substituteVariableList ?L) . }. +{ ?LC :substitutedTriple ?L . } => { _:dd :print (?LC :substitutedTriple ?L) . }. +{ ?LC :substitutedTriplesInFormula ?L . } => { _:dd :print (?LC :substitutedTriplesInFormula ?L) . }. +{ ?LC :substitutedFormula ?L . } => { _:dd :print (?LC :substitutedFormula ?L) . }. +# +{ ?LC :substituteVariablesInFormula ?L . } => { _:dd :print (?LC :substituteVariablesInFormula ?L) . }. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |