HCLS/ACPPTaskForce/TutorialUseRule/N3
Appearance
	
	
Example 1.1: RDF triples in N3
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
:A a rdfs:Class.
:B a rdfs:Class.
:C a rdfs:Class.
:a  a :A;
    :hasProperty1 20.
:b  a :B;
    :hasProperty2  20.
:c a :C.
    
:hasProperty3 a rdf:Property; 
              rdfs:domain :C. 
Example 1.2: Rules in N3
Rule: If A's property :hasProperty1 has a value greater than 10, and B's property :hasProperty2 has a value greater than 12, then C's property :hasProperty3 should has the value of 15.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
{?A :hasProperty1 ?V1. 
         ?B :hasProperty2 ?V2.
         ?V1 math:greaterThan 10.
         ?V2 math:greaterThan 12.}
=>
{?C :hasProperty3 15}
Example 1.3: Query in N3
SPARQL query can also be writen in N3
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix q: <http://www.w3.org/2004/ql#>.
[]
q:select {?C :hasProperty3 ?V};
q:where {?C :hasProperty3 ?V}.
More Examples
A good example of N3 rules is the owl-rules.n3. This file contains rules of (most) OWL semantics.
You can find more N3 examples at Euler Proof Mechanism