A universal data language: RDF
Semantic web works by:
- Semantics of data represented as graph of typed binary relations
- URIs used to identify terms, including relationship types
... but RDF/XMl syntax is rather verbose for some cases.
A human-readable syntax for RDF: N3
ex:c1 rdf:type ex:Car;
ex:licensedYear 2002, 2003, 2004;
ex:color "green";
ex:users ( ex:Joe ex:Jill).
- Origin: whiteboards and IRC
- Unix-style
- Human Readable and Writable
- Compact
Adding graphs to N3: {}
ex:Joe ex:said { ex:c1 ex:color "charcoal" }.
- RDF Graph was not a RDF literal type
- N3 fixes that
- Express relations between graphs
- Allows reasoning of provenance, trust etc
"Graph" or N3 "Formula"
Adding variables: ?x
- RDF has existentials in a way in blank nodes
- N3 adds universal and existential
- Substitution in graph implies substitution in nested graphs
Making rules: log:implies
{ ?x fam:brother ?y; fam:son ?z }
=> { ?x fam:nephew ?z }.
- Subject is antecedent (body)
- Predicate is log:implies
- Object is consequent (head)
- log:implies shorthand is
=>
In
<http://www.w3.org/2000/10/swap/log#>
namespace
Cwm processing
- Forward-chaining
- Nested graphs on either side
- Rules can generate rules
- N3 completeness: Anything written in N3 can be queried, generated using
N3.
N3 can of course be constrained to prohibit nesting
Built-in Functions and operators: Use RDF Properties
{ ex:d test:point ?x. ?x math:sin ?y }
=> {...}
- Different engines will implement different functions
- Dynamic loading of new functions
- Fuzzy boundary between built-in functions and properties
N-ary functions: Use argument lists
{ ?x a ex:TestData.
( ?x 1 ) math:sum ?y.
( ?y " is one more than " ?x ) string:concatenation ?s
} => { ?s a ex:Result }.
Functions using graphs
- log:semantics
- Retrieve resource and parse to graph
- log:includes
- Is graph G subset of graph F?
@forAll v:DOC, c:G1, v:Order, v:y.
{ <master.rdf> log:semantics v:G1.
v:G1 log:includes { vi:DOC a biz:CustomerOrder }.
v:DOC log:semantics v:ORDER.
v:ORDER log:includes { [] biz:item v:y }.
} => {
v:DOC ex:orderItem v:y
}.
Defaults: Use explicit domain
- Defaults and NAF don't work in open web
- Do work if with respect to given graph
- Reusable rules can't have implicit scope of default
- log:notIncludes is used
{ <thisOrder.rdf> log:semantics ?ORDER.
?ORDER log:includes { ?x biz:item ?y. ?y a ex:Car };
?ORDER log:notIncludes { ?y ex:color [] }
} => {
?y ex:Color "black"
}.
Syntactic sugar?
Implementation features
- Inference engine delegates query to others
- Inference engine treats local SQL database as part of KB
- Automatically look up web documents from URI
Other Implementations and Subsets
- Euler: Backward chainer (Java)
- Pychinko: Rete (Python)
- Turtle: subset which is RDF - widely used
- SPARQL
- NTriples: minimum subset which is RDF - widely used
N3 extensions also been used to represent queries and patches/updates.
Summary of requirents
- Single data model for data from all sources
- Same syntax for data and data part of rules
- RDF properties for functions and operators
- RDF collections (lists) for Nary functions
- Completely declarative for maximum reuse
- Explicit scoping of defaults
- Able to objectively discuss provenance and contents of documents