Skip to content

Commit

Permalink
using PREFIX and GRAPH keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Aug 25, 2024
1 parent 08a5c02 commit 1e04823
Show file tree
Hide file tree
Showing 54 changed files with 5,735 additions and 5,734 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.3
1.2.4
38 changes: 19 additions & 19 deletions etc/ackermann.trig
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@
# where A(4,0) has a value of 2 digits, A(4,1) has a value of 5 digits
# and A(4,2) has a value of 19729 digits.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix lingua: <http://www.w3.org/2000/10/swap/lingua#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <#>.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX lingua: <http://www.w3.org/2000/10/swap/lingua#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# assuming lingua explanations
[] lingua:explanation [].

# ackermann(x, y)
_:bng_1 lingua:backward _:bng_2.

_:bng_1 {
GRAPH _:bng_1 {
(var:X var:Y) :ackermann var:A.
}

_:bng_2 {
GRAPH _:bng_2 {
(var:Y 3) math:sum var:B.
(var:X var:B 2) :ackermann var:C.
(var:C 3) math:difference var:A.
Expand All @@ -47,57 +47,57 @@ _:bng_2 {
# succ (x=0)
_:bng_3 lingua:backward _:bng_4.

_:bng_3 {
GRAPH _:bng_3 {
(0 var:Y var:Z) :ackermann var:A.
}

_:bng_4 {
GRAPH _:bng_4 {
[] rdf:value true; log:callWithCut true.
(var:Y 1) math:sum var:A.
}

# sum (x=1)
_:bng_5 lingua:backward _:bng_6.

_:bng_5 {
GRAPH _:bng_5 {
(1 var:Y var:Z) :ackermann var:A.
}

_:bng_6 {
GRAPH _:bng_6 {
[] rdf:value true; log:callWithCut true.
(var:Y var:Z) math:sum var:A.
}

# product (x=2)
_:bng_7 lingua:backward _:bng_8.

_:bng_7 {
GRAPH _:bng_7 {
(2 var:Y var:Z) :ackermann var:A.
}

_:bng_8 {
GRAPH _:bng_8 {
[] rdf:value true; log:callWithCut true.
(var:Y var:Z) math:product var:A.
}

# exponentiation (x=3), tetration (x=4), pentation (x=5), hexation (x=6), etc
_:bng_9 lingua:backward _:bng_10.

_:bng_9 {
GRAPH _:bng_9 {
(var:X 0 var:Z) :ackermann 1.
}

_:bng_10 {
GRAPH _:bng_10 {
[] rdf:value true; log:callWithCut true.
}

_:bng_11 lingua:backward _:bng_12.

_:bng_11 {
GRAPH _:bng_11 {
(var:X var:Y var:Z) :ackermann var:A.
}

_:bng_12 {
GRAPH _:bng_12 {
(var:Y 1) math:difference var:B.
(var:X var:B var:Z) :ackermann var:C.
(var:X 1) math:difference var:D.
Expand All @@ -107,7 +107,7 @@ _:bng_12 {
# query
_:bng_14 lingua:answer _:bng_14.

_:bng_14 {
GRAPH _:bng_14 {
(0 0) :ackermann var:A0.
(0 6) :ackermann var:A1.
(1 2) :ackermann var:A2.
Expand Down
34 changes: 17 additions & 17 deletions etc/acp.trig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Access control policy example
# -----------------------------

@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix lingua: <http://www.w3.org/2000/10/swap/lingua#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <#>.
PREFIX list: <http://www.w3.org/2000/10/swap/list#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX lingua: <http://www.w3.org/2000/10/swap/lingua#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

:test1 :policy :PolicyX;
:has :A, :B, :C.
Expand All @@ -18,73 +18,73 @@

_:bng_1 lingua:backward _:bng_2.

_:bng_1 {
GRAPH _:bng_1 {
var:Pol :pass :allOfTest.
}

_:bng_2 {
GRAPH _:bng_2 {
var:Test :policy var:Pol.
var:Pol a :Policy.
(_:bng_3 _:bng_4) log:forAllIn var:X.
}

_:bng_3 {
GRAPH _:bng_3 {
var:Pol :allOf var:Field.
}

_:bng_4 {
GRAPH _:bng_4 {
var:Test :has var:Field.
}

_:bng_5 lingua:backward _:bng_6.

_:bng_5 {
GRAPH _:bng_5 {
var:Pol :pass :anyOfTest.
}

_:bng_6 {
GRAPH _:bng_6 {
var:Test :policy var:Pol.
var:Pol a :Policy.
(var:Field _:bng_7 var:List) log:collectAllIn var:X.
var:List list:length var:L.
(var:L) log:notEqualTo (0).
}

_:bng_7 {
GRAPH _:bng_7 {
var:Pol :anyOf var:Field.
var:Test :has var:Field.
}

_:bng_8 lingua:backward _:bng_9.

_:bng_8 {
GRAPH _:bng_8 {
var:Pol :pass :noneOfTest.
}

_:bng_9 {
GRAPH _:bng_9 {
var:Test :policy var:Pol.
var:Pol a :Policy.
(var:Field _:bng_10 var:List) log:collectAllIn var:X.
var:List list:length var:L.
(var:L) log:equalTo (0).
}

_:bng_10 {
GRAPH _:bng_10 {
var:Pol :noneOf var:Field.
var:Test :has var:Field.
}

# query
_:bng_11 lingua:answer _:bng_12.

_:bng_11 {
GRAPH _:bng_11 {
var:Pol a :Policy.
var:Pol :pass :allOfTest.
var:Pol :pass :anyOfTest.
var:Pol :pass :noneOfTest.
}

_:bng_12 {
GRAPH _:bng_12 {
:test :for var:Pol.
:test :is true.
}
16 changes: 8 additions & 8 deletions etc/backward.trig
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
#
# See https://www.w3.org/2000/10/swap/doc/tutorial-1.pdf page 17

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix lingua: <http://www.w3.org/2000/10/swap/lingua#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <#>.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX lingua: <http://www.w3.org/2000/10/swap/lingua#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# something is more interesting if it is greater
_:bng_1 lingua:backward _:bng_2.

_:bng_1 {
GRAPH _:bng_1 {
var:X :moreInterestingThan var:Y.
}

_:bng_2 {
GRAPH _:bng_2 {
var:X math:greaterThan var:Y.
}

# query
_:bng_3 lingua:answer _:bng_3.

_:bng_3 {
GRAPH _:bng_3 {
[] rdf:value 5; :moreInterestingThan 3.
}
26 changes: 13 additions & 13 deletions etc/complement.trig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Negation as envisioned by Wouter Termont
# ----------------------------------------

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix lingua: <http://www.w3.org/2000/10/swap/lingua#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <#>.
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX lingua: <http://www.w3.org/2000/10/swap/lingua#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# Each predicate in RDF represents a binary relation, i.e. a set of 2-tuples.
# For each of those relations you can formulate exactly one complementary
Expand All @@ -14,43 +14,43 @@
# between these complements by a predicate, e.g. log:complement, then we
# can express the following in pure RDF
#
# NOT {
# GRAPH # NOT {
# _:s1 :p1 _:o1.
# _:s2 :p2 _:o2.
# _:s3 :p3 _:o3.
# }
_:bng_1 lingua:forward _:bng_2.

_:bng_1 {
GRAPH _:bng_1 {
_:s1 :p1 _:o1.
_:s2 :p2 _:o2.
}

_:bng_2 {
GRAPH _:bng_2 {
:c3 log:complement :p3.
_:s3 :c3 _:o3.
}

_:bng_3 lingua:forward _:bng_4.

_:bng_3 {
GRAPH _:bng_3 {
_:s2 :p2 _:o2.
_:s3 :p3 _:o3.
}

_:bng_4 {
GRAPH _:bng_4 {
:c1 log:complement :p1.
_:s1 :c1 _:o1.
}

_:bng_5 lingua:forward _:bng_6.

_:bng_5 {
GRAPH _:bng_5 {
_:s3 :p3 _:o3.
_:s1 :p1 _:o1.
}

_:bng_6 {
GRAPH _:bng_6 {
:c2 log:complement :p2.
_:s2 :c2 _:o2.
}
Expand All @@ -63,7 +63,7 @@ _:bng_6 {
# fuse
_:bng_7 lingua:forward false.

_:bng_7 {
GRAPH _:bng_7 {
var:P log:complement var:C.
var:S var:P var:O.
var:S var:C var:O.
Expand All @@ -72,6 +72,6 @@ _:bng_7 {
# query
_:bng_8 lingua:answer _:bng_8.

_:bng_8 {
GRAPH _:bng_8 {
_:bng_7 lingua:forward false.
}
Loading

0 comments on commit 1e04823

Please sign in to comment.