Manuscript Offprint
arXiv:2610.31266Notation3: Graph Terms for RDF
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Notation3 Logic was introduced as an extension of RDF allowing the user to express rules on top of triples and to make statements about graphs. The original proposal of the logic only came with an informal specification of its semantics which has been refined later on. While this refinement clarified the meaning of rules and implicitly quantified variables, it left the meaning of graphs used as terms – so-called graph terms – open. In this paper we aim to close this gap. We discuss in detail, how graph terms are used in Notation3, which formal requirements they need to meet, and provide examples to illustrate the difficulties when defining their semantics. We then introduce an abstract syntax for the logic and define its semantics in two steps: similarly to RDF's simple interpretations, we define interpretations and basic entailment for Notation3 which covers plain RDF triples but also triples containing graph terms. N3-entailment is then an extension of basic entailment which assigns meaning to the different special predicates of the logic like for example the implication symbol. N3-entailment is defined in a way that it can be extended whenever a new predicate is added to the logic. As Notation3 Logic is currently under development, we expect many predicates to be added. Our research provides and important step towards the full standardisation of the logic.
2012 ACM Subject Classification Information systems → Resource Description Framework (RDF); Theory of computation → Logic and verification; Theory of computation → Semantics and reasoning
Keywords and phrases Notation3 Logic, Graph terms, Semantics, Rules, RDF
Digital Object Identifier 10.4230/TGDK.1.1.42
Supplementary Material The authors declare that this article involves no relevant supplementary resources.
Acknowledgements The authors would like to thank all the participants of the W3C Notation 3 Community Group for fruitful discussions and their feedback on early stages of this work.
Received Date of submission Accepted Date of acceptance Published Date of publishing
Editor TGDK section area editor
https://www.w3.org/community/n3-dev/
1 Introduction
Ever since the invention of the Semantic Web, the community saw the need to allow users to make statements about statements. Different approaches like singleton properties [31], the inclusion of named graphs to RDF [30, Section 4], or the integration of RDF-star (formally RDF*) [21, 22] into the upcoming RDF 1.2, are only some indicators for it. And while these proposals and standards to some extend address the problem, they all have some draw-backs: singleton properties and RDF-star only support statements about triples but not about RDF graphs and for named graphs, there is so far no agreement about their semantics [39].
In this paper we focus on another framework which supports statements about statements: Notation3 Logic (N3) [13]. N3 was proposed by Tim Berners-Lee and others to provide a simple syntax for RDF – this resulted in RDF-Turtle [32] – but also as a logical extension for RDF. N3
© Jane Open Access and Joan R. Public;
licensed under Creative Commons License CC-BY 4.0
Transactions on Graph Data and Knowledge, Vol. 1, Issue 1, Article No. 42, pp. 42:1–42:29
Transactions on Graph Data and Knowledge
Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany

42:2 Notation3: Graph Terms for RDF
supports so-called graph terms which are conceptually very similar to RDF-star's triple terms with the only difference that N3 does not only allow triples as terms but entire graphs. Of course, this comes with challenges: graph terms could stand for themselves or for bigger graphs, scoping of blank nodes is far from trivial, and graph terms are used to express logical constructs. When originally proposed, the semantics of N3 has only been defined informally and different implementations like Cwm [10], EYE [37] or Data-Fu [27] were developed to reason on it. The theoretical works which followed later on to define a model theoretic semantics for N3 did focus on rules [3, 4] and on implicit quantification [5], but did not fully cover the semantics of graph terms as it was originally intended.
In this paper we aim to fill this gap: We analyse the requirements a graph term semantics has to comply with according to the informal specifications and the existing implementations. We then propose an abstract syntax for N3 and define its semantics in two steps: we first specify a base semantics which covers the meaning of graph terms but does not assign any meaning to the built-in predicates of the logic. In that sense our base semantics is very similar to RDF's simple entailment. In a second step we define N3-semantics which covers the logical predicates in N3's log-namespace . Here we mainly focus on logical implication (log:implies) and on graph inclusion (log:includes). Especially the former is crucial for N3 as this predicate enables rule-based reasoning. We furthermore show that our definitions are in-line with the requirements.
The remainder of this paper is structured as follows: In Section 2 we analyse how graph terms are used in N3, and we derive the requirements for their semantics in Section 3. In Section 4 we define an abstract syntax for N3 and explain how it maps to the concrete serialization syntax. In Section 5 we then provide a formal semantics for the abstract syntax, and we show in Section 6 that the semantics of graph terms meets our requirements. In Section 7 we discuss the related work and explain how our formalisation relates to other approaches to enable statements about statements in RDF. With Section 8 we conclude our paper.
:alice :likes :pasta.
(1)
This triple informally means that “Alice likes pasta.” Just as in RDF, we have literals and IRIs which refer to resources, and blank nodes which are used as existentially quantified variables. N3 furthermore supports graph terms. We can, for example, state that
:bob :says {:alice :likes :pizza, :pasta}.
(2)
Which informally means that “Bob says that Alice likes pizza and pasta.” Note that, while RDF-star only allows a single triple to be used as a term, here the object is a set of triples which we interpret as a conjunction. This makes it possible to have co-referring blank nodes in graph terms. We could modify the previous statement and get:
:bob :says {_:x :likes :pizza. _:x :likes :pasta}.
(3)
http://www.w3.org/2000/10/swap/log
We omit the prefix definitions where not relevant to keep the paper short.
42:3
Despite being a little bit vague, we could give an informal interpretation before. In this case it is more complex because there is implicit existential quantification involved. In our proposal, the above means “Bob says that there exists someone who likes pizza and pasta”. The blank node is existentially quantified within the graph term and not outside of it . It has to be said, that this interpretation is still subject to discussion, which is why a semantics of N3 needs to be flexible to be able to adjust possible future changes in the scoping of implicit quantification.
Graph terms are not only used to make statements about statements but also to express logical operations. A rule can be written as follows:
In this rule, the ?x stands for a (implicitly) universally quantified variable and the sign => is syntactic sugar for the N3 predicate log:implies. The above rule informally means that “If someone likes pasta, then they also like spaghetti.”. We see that the rule above is simply a triple with graph terms as subject and object and a special predicate log:implies. This is a design choice of N3: All data and axioms in N3 are expressed through triples, and all semantic decisions (e.g., scoping of variables) we take for graph terms in statements like Formula 2 also apply to the graph terms occurring in rules like Formula 4 above.
We illustrate this by providing the following example:
This can be freely interpreted as “Everything Bob says is true.” In order to use this formula, apply it to Formula 2 and derive the triples
we need to consider the dual nature of Formula 5. Understanding the IRI log:implies as a predicate, we have an atomic formula (in first-order-like syntax it would be ) and we can unify the universal variable ?x with the graph term {:alice :likes :pasta, :pizza.}. As a consequence, we get the formula
\begin{aligned}\{:b o b:s a y s\{:a l i c e:l i k e s:p a s t a,:p i z z a.}\}&\}\\ =&\{:a l i c e:l i k e s:p a s t a,:p i z z a.}\}.\end{aligned} \tag{7}This, in turn, can now be seen as an implication and applied on Formula 2 it yields Formula 6.
3 Requirements on a formal semantics
The examples in the previous section reveal that there are several difficulties and uncertainties when dealing with graph terms in N3. Some requirements on N3's semantics only become clear after further analysing the logic. Below, we list and explain the main requirements to be taken into account when defining the semantics of N3, with a special focus on graph terms.
Semantic compatibility with RDF N3 syntactically extends RDF Turtle and each RDF Turtle triple is also an N3 triple. N3 semantics should thus be compatible with RDF semantics. As N3 does not assign special semantics to the different predicates of the RDF and RDFS namespace (e.g., rdf:type, rdfs:domain), we limit this requirement to compatibility with the RDF
In the latter case, Formula 3 would instead mean “There exists someone of whom Bob says they like pizza and pasta”.
42:4 Notation3: Graph Terms for RDF
simple entailment. N3 should additionally support D-Entailment, but we leave that detail out of the considerations of this paper as our main focus is on graph terms.
Referential Opacity One detail which often leads to discussion when a logic supports statements about statements is the question whether or not a constant occurring in a formula term (as a generalised graph term) refers to the same resource as it does in a stated formula (e.g. [22, Section 6.4.4]). This is often illustrated by the superman example which in N3 syntax would be:
:superman owl:sameAs :clarkKent.
(8)
:loisLane :knows {:superman :can :fly}.
(9)
Above, we borrowed the predicate owl:sameAs from OWL [38] to express equality. The above means in a free translation: “Superman is the same as Clark Kent and Lois Lane knows that Superman can fly.” Under the assumption that we support equality, we ask the question whether we can derive that
:loisLane :knows {:clarkKent :can :fly}
(10)
or in words “Lois Lane knows that Clark Kent can fly.” In case of a positive answer, we say that graph terms are transparent, otherwise they are opaque.
Opaque graph terms are considered a better design choice for N3. Firstly, as the Superman example above demonstrates, there are use-cases where the derivations entailed by transparency are not desirable. Secondly, if such derivations are desired, it is still possible to enable them by adding a rule of the form:
{?x owl:sameAs ?y. ?s ?p {?x ?q ?r} =>{?s ?p {?y ?q ?r}}}.
(11)
or a variant thereof. Referential opacity is a weaker, less constraining, option than transparency.
Closedness of graph terms Another detail to be discussed in the context of graph terms is whether we consider them closed or open. By this we mean whether the term {:clarkKent :can :fly} from Formula 10 refers to a graph (a set of triples) containing exactly one triple (closed), namely :clarkKent :can :fly. or to a potentially bigger graph containing at least that triple – but may contain others (open). Both options have been considered as proposed semantics for datasets in RDF [39]. Consider the rule expressed in Formula 7. If the graph term on the left-hand side could denote a graph containing arbitrary extra triples, there would be no way to prove it to be satisfied by the currently known triples, and therefore no way to derive the consequence of that (or any) rule. Therefore, we consider graph terms to be closed in our semantics.
Clarity and flexibility of quantification scopes N3 has two kinds of variables: existentially quantified (or blank nodes, inherited from RDF) and universally quantified (in order to express rules, as illustrated earlier). When combined with graph terms, this immediately raises the question of the scope of these quantifications. Historically, blank nodes (such as _:y) have been scoped to the innermost graph containing them (“locally scoped”), while universal variables (such as ?x) have been scoped to the top-level graph (“globally scoped”). While this fits most use-cases, those scoping rules have always been a topic of discussions and a point of divergence among different implementations of N3 [5]. For example, they do not tell us precisely how to interpret the following simple graph:
?x :loves _:y.
(12)
We know that both variables are scoped to the same (top-level) graph, but it is not clear how they interact. Without additional information, the reader could either interpret the above as (a) "Everybody loves somebody" or (b) "There is someone who is loved by everyone".
42:5
Even if we specify the scoping rule to disambiguate the example above (and we will, making (a) the correct interpretation), we also need a way to explicitly express the quantification scope of a given variable when the implicit scoping rule are not adequate. Besides the example of interpretation (b) above, consider the example below where we want to describe, in an N3 graph, the content of another N3 document:
<example.n3> log:semantics { @forall :x. :x :loves _:y }
(13)
Here, we could not have used the implicitly quantified universal ?x, because its scope would have been the whole graph, while what we want to convey is that it is scoped to the graph term representing the content of example.n3. Explicit quantification was also introduced early in N3 (with the keywords @forall and @forSome), but like the implicit scoping rules, their interpretations and implementations have varied largely.
4 Syntax
Before defining the semantics of N3, we introduce its syntax. The concrete syntax of N3, which is used to illustrate examples throughout this paper, is described in the draft report of the W3C Notation 3 Community Group. Space limitations prevent from presenting it in details, but the examples provided in Section 2 present its main features, such as graph terms (Formula 2) and rules (Formula 4).
To address the last requirement from above, the flexibility to express different quantification scopes, but also to have a way to easily deal with quantification, we define an abstract syntax. Below, we introduce this abstract syntax, explain its relation to concrete syntax and provide the syntactic definitions needed to define the semantics.
4.1 Abstract Syntax
We first define atomic triples, the building blocks of our abstract syntax.
▶ Definition 1 (Atomic Term). The set of atomic terms consists of
the set C of IRIs,
the set L of Literals,
the set V of Variables.
As we can see, the abstract syntax has only one kind of variable. It does not distinguish between existential (blank nodes) and universal variables, because contrarily to the concrete syntax, all variables in the abstract syntax will be explicitly quantified.
▶ Definition 2 (Term). A term can be
an atomic term,
a graph term where G is a finite graph (see below).
Note that we make a clear difference between a graph and a graph term. This difference will become important in Section 5.
▶ Definition 3 (Triple). A triple is a 3-tuple of terms, respectively called the subject, predicate and object of the triple.
https://w3c.github.io/N3/spec/
42:6 Notation3: Graph Terms for RDF
Note that, in contrast to RDF, N3 allows for any kind of term in all positions of a triple.
While in RDF a graph is simply defined as a set of triples, N3 needs a way to specify which variables are universally or existentially quantified, and in which scope.
▶ Definition 4 (Graph). An N3 graph (or simply graph) is a tuple where
is a (possibly empty) set of universally quantified variables,
is a (possibly empty) set of existentially quantified variables,
U and E are disjoint,
F is a (possibly empty) set of triples.
A graph is finite if the sets , and are finite.
Note that this model is a strict superset of RDF: any RDF graph can be seen as an N3 graph, where F is the set of triples constituting the graph, , and E is the set of all blank nodes used in F. Of course, an RDF graph will use no graph term in F.
▶ Remark (Notation). Consider a graph . To improve readability, in our examples, we will use the quantifier to mark the set of universally quantified variables and the quantifier to mark the set of existentially quantified variables, and omit those sets when they are empty. For example, will be noted will be noted , and will be noted .
4.2 From concrete to abstract syntax
From a syntactic point of view, N3 can be seen as a superset of Turtle [32], with which we assume the reader to be familiar. The main N3-specific features of the concrete syntax were introduced in Sections 2. N3 supports implicitly scoped universal variables, starting with a question mark (e.g. ?x); graph terms, enclosed in curly brackets ({}); and the symbol => which is an alias for the predicate log:implies. IRIs in the concrete syntax translate to IRIs (C) in the abstract syntax (except when quantified with the keywords @forall and @forSome, see below). Literals in the concrete syntax translate to literals (L) in the abstract syntax. Blank nodes and ?-prefixed universals translate to variables (V). Different concrete symbols are translated to distinct variables in the abstract syntax. In particular ?x and _:x are not the same and if we modify Formula 12 as follows
?x :loves _:x.
(12')
it corresponds to the abstract N3 graph
For the translation of implicit quantification, we adhere to the following schema: the variable corresponding to any ?-prefixed universals is automatically added to the U set of the outermost graph. The variable corresponding to a blank node is automatically added to the E set of the innermost graph. For example, in the RDF triple
_ : x : likes : pasta.
(15)
we have only one level, and the blank node is quantified there, we get
42:7
while in Formula 3 from above, the blank nodes occurring in the graph term are quantified there, and we get
In the following example:
variable ?x is universally quantified on the outermost graph, the blank node _:y is local to the consequent of the rule. We get
which is an existential rule [4].
Explicit quantification in the concrete syntax is expressed with the @forall or @forSome keyword, followed by an IRI and by a period (.). Such quantified IRIs will then translate to variables (V) in the abstract syntax rather than IRIs (C). Formula 12 from above could also be written as
(12")
The formula again corresponds to the abstract formula 14. The quantifier keywords can be used in the top-level graph or in any graph term, but must always occur before the first triple of the graph to which they belong, and all @foralls must be placed before any @forSome of the same graph . Any further use of the quantified IRI in the same graph, or nested graph terms, will be represented in the abstract syntax by the corresponding variable. For example, the formula
is represented as
4.3 Variables
For the definitions which follow later in this document, we need to make some statements about the variables occurring in N3 graphs. Here we distinguish between variables occurring directly in a graph an those which are nested. To be able to differentiate them, we introduce the following concept of constituents.
▶ Definition 5 (Direct Constituent). A term is a direct constituent of a graph if it is the subject, predicate or object of a triple . We denote the set of direct constituents of a graph as .
We now define the more general notion of constituents, which are informally speaking all terms occurring in a graph.
▶ Definition 6 (Constituent). A term is a constituent of a graph if it is either
■ a direct constituent of , or
These constraints were not part of the original N3 syntax, but we add them to improve readability and avoid corner cases.
42:8 Notation3: Graph Terms for RDF
■ a constituent of graph , where the graph term is a direct constituent of . We denote the set of constituents of a graph G as .
In other words: direct constituents are all terms which directly form the graph's triples. Constituents also include all terms found in nested graph terms independently of the depth of the nesting.
We illustrate these definitions on an earlier example: Formula 3, whose abstract syntax is given in Formula 17. We encounter three direct constituents: :bob, :says, ; and seven constituents: all the above plus x, :likes, :pizza, :pasta.
With that definition, we now introduce the notion of free variable.
▶ Definition 7 (Free Variable). The set of free variables in a term, triple, set of triples or graph x is noted and defined as follows:
For a graph and a variable : We say that is free in iff . Otherwise, is said to be scoped in .
Examples:
■ In (Formula 12) all variables are scoped.
■ In the variable is free while is scoped.
■ In , the variable is scoped while the variable is free.
With this definition, we now introduce ground graphs:
▶ Definition 8 (Ground term, triple and graph).
■ A term is ground if it is either
an IRI,
a Literal,
a graph term with .
We denote the set of ground terms as .
■ A triple is ground if and are ground.
■ A graph is ground if and all triples in F are ground.
Note that this definition treats graphs and graph terms differently: a graph term may be ground while the corresponding graph is not. More precisely: a graph term is ground if all its variable constituents are scoped, while to be ground, a graph must additionally have no variable in its direct constituents. A ground graph may still contain variables, as long as these are scoped within a graph term. This is because these variables are not accessible by outside quantification. If we modify Formula 17 from above by adding quantification we get
As the variable in this graph only occurs, scoped, in the graph term , it can not be "reached" by the universal quantifier we just added, and therefore Formulae 17 and 22 will be interpreted equally.
42:9
The example illustrates that a graph can contain quantified variables which do not occur freely in any triple of and thus do not contribute to the interpretation of the graph. In order to simplify our considerations for the following sections, we introduce the notion of normalised graphs which exclude such quantification.
▶ Definition 9 (Normalisation). For each graph , we call the normalisation of .
The normalisation of Formula 22 is Formula 17. We provide more examples below:
4.4 Isomorphisms
Having the syntactic definition in place, we can now take a closer look at the relation between two graphs. Just like in RDF, we can define isomorphisms between N3 graphs and between graph terms. The latter will become particularly important in Section 5 where we define the semantics. When interpreting graph terms, the naming of a variable should not matter. Just as the Formulae 12, 12' and 12'' had the same meaning and could be translated to the abstract formula 14, the latter formula should have the meaning as
(14′)
where we only changed the variable names. And that behavior should also hold for graph terms: we would like our semantics to assign the same meaning to the abstract graph term
from Formula 17 as for
(23′)
where we only replaced the variable x by y.
In order to be able to define isomorphisms between graph terms, we first introduce mechanisms to combine mappings. Here and later in this paper, we write to denote the domain X of a mapping .
▶ Definition 10 (Mapping Combination). Let M and N be two mappings from terms to terms, we define their combination, noted as follows:
Informally speaking, this definition means that the second mapping “overrides” the first one whenever a term is in both of their domains. This is very similar to the behavior of quantifiers in first-order logic where the scope of a quantifier is always the set of quantified variables occurring freely in the quantified formula. This similarity is no coincidence. In our semantics, combinations will be mainly used to handle nested variable scopes.
For a mapping , we denote by the restriction of to the set .
We can now define what it means for N3 graphs to be isomorphic to each other.
42:10 Notation3: Graph Terms for RDF
▶ Definition 11 (Isomorphic under M). Let M be a bijection between sets of variables in V:
■ a graph is isomorphic to under iff, and and
■ and
■ is isomorphic to under
■ a set of triples is isomorphic to a set of triples under M iff
■ M is a bijection from to ,
there is a bijection from the triples in to those in such that, for each triple and for the image it holds that and are isomorphic under to and , respectively
■ a variable v is isomorphic under M to ,
■ an IRI or Literal is isomorphic under M to itself,
■ a graph term is isomorphic under to if for and there is a bijection between and such that is a bijection and is isomorphic to under .
As we will further discuss below (Lemma 13), if a graph is isomorphic to a graph under , then is isomorphic to under . This close connection motivates us to omit mentioning the mapping when talking about isomorphisms. We get the following more general definition:
▶ Definition 12 (Isomorphic). A graph is said to be isomorphic to a graph , written as , if there exists some such that is isomorphic to under .
We note that, for the subset of N3 graphs that are also RDF graphs, our notion of isomorphism is equivalent to that defined in the RDF specification [30]. We also note the following lemma.
▶ Lemma 13 (Equivalence property of Isomorphisms). The isomorphic relation from above is reflexive, symmetric, and transitive.
To prove this lemma, we first remark that, given a graph such that , it holds that per Definitions 7 and 9. For convenience, we denote this set by .
Given two mappings and with disjoint domains, we remark that (treating mappings as set of pairs). If additionally , and are bijections, this implies that .
Isomorphism of N3 graphs ( ) is reflexive. This is trivially true by choosing the identity for the bijections M, T and P.
Isomorphism of N3 graphs ( ) is symmetric. Let us first prove by induction that if is isomorphic to under a bijection , then is isomorphic to under . Let and . There must be a bijection mapping triples from to triples from that satisfies the definition of isomorphism under .
If we assume that neither nor contain graph terms, then trivially is isomorphic to under by choosing to map from triples from to .
If contains graph terms, then must map every graph term occurring in to a graph term occurring in , and for each such pair there must exist a bijection such that is isomorphic to under .
Per our induction hypothesis, is also isomorphic to under . We remark that the domains of and are disjoint, so . We can then conclude that the graph term is isomorphic to under , choosing , and therefore that is isomorphic to under
42:11
From the above, it follows that if , then .
Isomorphism of N3 graphs ( ) is transitive. Let us first prove by induction that if is isomorphic to under , and is isomorphic to under , then is isomorphic to under . Let for . There must be a bijection from to and a bijection from to that satisfy the definition of isomorphism under and respectively.
If we assume that neither , nor contain graph terms, then trivially is isomorphic to under by choosing to map from to .
If contains graph terms, then must map every graph term occurring in to a graph term occurring in , and for each such pair there must exist a bijection such that is isomorphic to under . Similarly must map every graph term occurring in to a graph term occurring in , and for each such pair there must exist a bijection such that is isomorphic to under . Per our induction hypothesis, is isomorphic to under . Since the domain of and are disjoint for all , this is equal to . Since the image of is , and the image of is the domain of , this is equal to and therefore each graph term is isomorphic to under , choosing . Hence, is isomorphic to under .
From the above, it follows that if and , then .
We give an example to further illustrate the definition. Consider the following graphs in concrete syntax
written in abstract syntax these are
Then is isomorphic to but not to .
4.5 Syntactic relations between graphs
Beyond isomorphism, N3 graphs can have other useful relationships with each other. In this section we define the notion of subgraph, instance/generalisation, and merge.
▶ Definition 14 (Subgraph). A graph is a subgraph of a graph , written as , if , , , and .
Note that this definition is slightly more complicated than the subgraph relation in RDF which is basically the same as a subset [24], since in N3, we need to also take variable bindings into account. Given the graphs
42:12 Notation3: Graph Terms for RDF
and
is a subgraph of , but neither are (quantifiers differ) nor (y is free in ).
Note that for the definition of subgraphs, concrete variable names matter. The graph
is not a subgraph of G, it is, however, isomorphic to one of its subgraphs, namely .
In order to define the notions of instance and generalisation, we first need to define a way to properly substitute variables in an N3 graph.
▶ Definition 15 (Total application). Let M be a mapping from a set of variable into a set S. A total application of M on graphs and terms is defined as follows:
if x is a variable
if , x otherwise
if x is an IRI or a Literal
if is a graph term
if
,
if is a set of triples
if is a graph
The total application of M replaces all free variables occurring directly or nested in a graph with their image through M. As an example we consider a modification of the rule in Formula 18, where the universal ?x is replaced with a free variable:
(24)
Let be a mapping such that and , then we get:
In this example, we replace x with its value because it occurs freely in the graph while y does not get replaced since it is quantified in the nested graph.
▶ Definition 16 (Instance and generalisation of a graph). Let be a graph.
We call a graph an E-instance of if there exists a mapping such that is the normalisation of . Conversely, we call an E-generalisation of .
We call a graph a U-instance of if there exists a mapping such that is the normalisation of . Conversely, we call a U-generalization of .
For example:
■ {(:alice, :likes, :pizza)} is an E-instance of ∃{x} {(x, :likes, :pizza)}, with M = {x ↔ :alice}
■ is an E-instance of , with
■ {(:alice, :likes, :pizza)} is a U-instance of , with
■ is a U-instance of with .
42:13
is an E-generalization of , which is itself a U-instance of ,
We will see below (Section 5.3) that these definitions allow us to formulate a counterpart to RDF's interpolation lemma [24, Section 5.2]. In particular, note that our notion of E-instance extends the notion of instance of an RDF graph. In contrast to RDF, N3 also covers universal quantification, hence the need to differentiate two kinds of instances/generalisations.
▶ Definition 17 (Merge of graphs). Let and be two graphs such that . By we denote the disjoint union of and .
Let be a set of graphs. We call a graph a merge of if, for all there exist a graph isomorphic to , such that .
This definition extends that of the merge of RDF graphs as defined in Section 4.1 of RDF Semantics [24].
▶ Definition 18 (Closure of a graph). A graph G is said to be closed if it does not contain any free variable, i.e. . Given a graph , the closed graph is called the closure of G.
As we will see in the following section, any graph is semantically equivalent to its closure.
5 Semantics
Having introduced N3's abstract syntax in the previous section, we now define N3's semantics. We do that in two steps: we first define N3's base semantics which only covers the meaning of terms and variables but does not take any special predicates into account. After that, we discuss N3 semantics which assigns meaning to N3's built-in predicates (Section 5.4). Here, we limit our considerations to the most important predicates (including log:implies). We plan to extend the definitions in future work.
5.1 Base Semantics
To define N3's base semantics, we start with an interpretation function:
▶ Definition 19 (Interpretation). An interpretation I is defined by:
■ a set (domain) whose elements are referred to as resources,
■ a mapping (denotation) from to , such that its restriction to is a total mapping,
■ a mapping from ground graph terms to ground graph terms, such that
■ for any graph term :
■ for two graph terms and :
■ a subset (extension) of .
This definition is generally “compatible” with RDF simple interpretations, with the following superficial changes:
■ IR becomes ,
IP is assumed, without loss of generality, to be a subset of ,
■ IS and IL have been merged in ,
■ IEXT can be derived from ; formally: ; conversely: .
42:14 Notation3: Graph Terms for RDF
The interpretation maps each ground graph term to an isomorphic copy of itself. In that sense, ground graph terms are similar to literals in RDF (they have a “fixed” denotation). As a consequence, two non-isomorphic graphs cannot have the same meaning.
However, N3-entailment(see Section 5.4) provides mechanisms to “unquote” graphs and to compare them based on the meaning of the formula they quote.
We now inductively define how to interpret ground graphs with an interpretation I:
▶ Definition 20 (Application of an interpretation). For ground terms, triples, and graphs, we define the application of an interpretation I as follows:
if x is an IRI or a Literal
if x is a ground graph term
if is a ground triple
false otherwise
if is a set of ground triples
true otherwise
if is a ground graph
The definition implies that the empty graph is true under any interpretation I.
In order to extend the definition towards non-ground graphs, we rely on a few additional definitions. To better understand the need for these, consider the following example:
?x :says {?x :is :wise}.
(26)
which freely translates to “everyone says about themselves that they are wise”. In abstract syntax, the formula would be expressed as:
This formula is interesting because the universally quantified variable appears once as a direct constituent in the triple and once nested. The semantics for ground graphs maps direct constituents to (not further specified) domain elements, while ground nested graphs are mapped to an isomorphic version of themselves.
If we replace the variable x with, for example, :bob, we get
With an interpretation I:
if (interpretation of the triple), which holds
if
Note that the mapping maps the URI :bob directly to a resource of , while operates on the graph term which contains the URI :bob. If we go back to Formula 27 where we have a variable instead of :bob, the first occurrence of should stand for a resource, while the second occurrence (in the graph term) depends on the syntactical representation of that resource. Note that this diverges from how RDF deals with variables, i.e. blank nodes [24, Section 5.1].
While RDF semantics maps blank nodes to resources, our semantics for N3 maps variables to ground terms, which are then, depending on the context, mapped to resource via an interpretation I, or kept as is. While this shift is not neutral (the domain may contain unnamed elements, which are therefore unreachable by quantified variables), we will prove later that it has no significant impact on basic entailment: N3 basic entailment on RDF graphs is equivalent to RDF simple
42:15
entailment, despite this different treatment of existentials (Lemma 26 below). The difference is likely to matter, however, with more complex inference regimes introducing negation [20].
▶ Definition 21 (Interpretation with assignment). Let be an interpretation and a mapping (assignment) from to . We define the application on terms, triples, and graphs as follows:
if x is a variable
if x is an IRI or a Literal
if x is a graph term
if
false otherwise
if is a set of triples
true otherwise
if is a graph
there exists a mapping
such that
false otherwise
When is a graph, will only affect the free variables in (quantified variables will be handled by and ). Then if is a closed graph (i.e. without free variables), is not influenced by . In such cases, we can omit the assignment and simply write .
▶ Definition 22 (Basic models). Let be an interpretation and a graph. We call a basic model of , noted , if for all mappings .
The above definition handles all variables occurring freely in a graph as universally quantified. Note that the interpretation of a variable depends on its position in a graph. In the expression , the first is interpreted as (an element of the domain) while the second is interpreted as (a ground term).
▶ Definition 23 (Basic entailment). Let and be graphs. We say that b-entails , written as iff for each basic model of , i.e. such that , it holds that .
We give some examples for b-enatilemnt. Formula 27 from above b-entails Formula 28 and
but not
Formula 30 b-entails Formulae 28 and 29, and Formula 28 b-entails Formula 29. Note that basic entailment does not support rules. Rule 19 from above
b-entails
but even in combination with
42:16 Notation3: Graph Terms for RDF
we cannot b-entail that
This kind of entailment is only supported by N3-entailment which will be discussed below in Section 5.4.
As basic entailment on its own does not support concepts like rules or negation, it can not be used to construct contradictions and all N3 graphs have a basic model.
▶ Lemma 24 (Basic satisfiability). For each N3 graph there exists a basic model.
Proof. Consider the interpretation with , the identity mapping, and mapping all ground graph terms to one of their isomorphic representations (such as required in Definition 19). This interpretation is a model for all graphs.
For the closure of a graph we furthermore observe the following:
▶ Lemma 25 (Closure). Each N3 graph has the same models as its closure.
Proof. Let be an N3 graph and its closure. Let . We show that for all there exists such that . As , we know that for and , there exists . If we chose and such that , we set , then we have and therefore .
Conversely, let . We show that for all and there exists such that . As , we know that for , there exists . We set , then we have and therefore .
From the lemma above, we conclude that we can, without loss of generality, focus on closed graphs for the rest of the proofs. Any subsequent result is straightforwardly extensible to non-closed graph by first taking their closure.
For pure RDF graphs (i.e. graphs without graph terms and universal quantification) b-entailment coincides with RDF simple entailment [24, Section 5.2]. For an RDF graph G let E be the set of blank nodes occurring in it. We denote its N3 representation with explicit quantifiers as detailed in Section 4.2 as .
▶ Lemma 26 (Simple Entailment). For two RDF graphs and with blank nodes and , respectively, the following holds:
Proof. In the following, we note RDF simple entailment as , to clearly differentiate it from Notation3 basic entailment, still noted . We also use RDF simple interpretations and Notation3 interpretations interchangeably, since we showed after Definition 19 that they can easily be transformed into each other.
Assume . Let , i.e. there exists such that . We build a new model such that , and is the restriction of to this new domain. Clearly , so . We also have , choosing . Per our assumption, : there exists such that . By construction, all elements of are named, so there exists a function such that . So we can build defined by ,
42:17
and therefore . It follows, by construction of , that , and therefore .
Assume . Let , i.e. there exists such that . Without loss of generality, we assume that does not contain any graph term. We set (the set of existentials that maps to a named individual), and . We can define an injection which assigns to every resource in a graph term of the form with . We define the interpretation as follows:
where
In other words, is obtained by replacing in all resources by . Clearly, , so . We also have by choosing
Per our assumption, : there exists such that . We can build as follows:
5.2 Semantic relations between graphs
Having introduced basic models, we now discuss the semantic implications of the syntactic relations between graphs we introduced in Sections 4.4 and 4.5. We start with isomorphic graphs and show:
▶ Lemma 27 (Isomorphic graphs). If two closed graphs are isomorphic to each other, they share the same models.
Proof. Given two closed graphs and where is isomorphic to under . Let .
If and are ground , we simply need to show that . This holds because is isomorphic to under , and maps any two isomorphic ground graph terms to the same image.
If and are not ground, we show that for each mapping there exists a mapping such that . As , we know that for there exists a mapping such that . We set , then and therefore .
We can furthermore show, that N3 graphs b-entail their subgraphs.
For such an injection to exists, we must assume that is not greater than . This is obviously true for finite graphs or countably infinite graphs, as contains an countably infinite amount of IRIs. We note that nothing in the definition of RDF constrains the set of blank nodes to be countable, so a graph using an uncountable amount of blank nodes is theoretically possible and would break this assumption. We consider, however, that this corner case has no practical relevance.
42:18 Notation3: Graph Terms for RDF
▶ Lemma 28 (Subgraphs). A closed N3 graph b-entails any of its subgraphs.
Proof. Let be a closed N3 graph, and a subgraph of . We notice that is necessarily closed (as ) and therefore . We also notice that, if and , . Let be an interpretation such that . We show that for all , there exists such that . As , we know that for such that , there exists such that . It also holds that , as , and so . We set , then and therefore .
Similarly to RDF simple entailment, we see that E-instances entail their generalisations.
▶ Lemma 29 (E-Instances). A closed N3 graph is b-entailed by any of its E-instances.
Proof. Let be a closed N3 graph, and an E-instance of with the instantiation mapping . Let . We show that for all , there exists such that . As , we know that there exists such that . We set
We have
For U-instances, the opposite is true: U-generalisations entail their instances.
▶ Lemma 30 (U-Instances). A closed N3 graph entails any of its U-instances.
Proof. Let be a closed N3 graph, and a U-instance of with the instantiation mapping . Let . We show that for all , there exists such that . As , we know that for all there exists such that . We chose such that
We have
The merge of two logical consequences is furthermore a logical consequence.
▶ Lemma 31 (Merge). Let be closed graphs, let be a merge of and , and let and then .
Proof. Let be as stated above, and let . Then and . As is a merge of and , there exist graphs and such that (Definition 17). By Lemma 27 it holds that and and as , this implies that and thus .
42:19
5.3 Interpolation Lemma
In the previous section we showed how several syntactic relations between graphs ensure entailment but we did not yet characterise the other direction: the syntactical relation between graphs which entail each other. The goal of this section is to find an N3 counterpart for RDF's interpolation lemma.
To do so, we first remind that, according to Lemma 26 that for pure RDF graphs b-entailment coincides with RDF simple entailment. In N3, we furthermore need to take universal quantification into account. The graph
b-entails
We replaced the universal variable x by the ground term :s and retrieved a U-instance (Lemma 30). This form of syntactical derivation gets more complicated if there are existentially quantified variables depending on the universals like for example in the following case:
Here, we state that everyone (and everything) has a mother. We can safely b-entail that
but the entailment
is incorrect and a correct version of this kind of entailment would be
to make sure that :bob and :liz possibly have different mothers. As we quantify over all ground terms and thus over an infinite set – even if the set of constants is limited, we can construct infinitely many graph terms – we cannot easily identify a finite graph from which all possible consequences can be derived, as it is the case for simple entailment in RDF where we have RDF's interpolation lemma. Instead, we construct the universal extension of a graph which might be infinite. The idea is motivated by the concept of universal models for existential rules [19].
▶ Definition 32 (Universal Extension). Let be a finite and normalised closed N3 graph, . Let be a set of variables such that . We enumerate the variables in and define for each combination of ground terms two mappings and , such that:
(i) for all ,
(ii) if or
If is minimal in the sense that for each there exists a value and a value such that , we call the graph with a universal extension of via . In cases where the exact choice of is not important, we omit and call a universal extension of .
Note that, modulo an appropriate mapping , the universal extension contains all triples which must be true in any model of . This is captured by the following lemma:
42:20 Notation3: Graph Terms for RDF
▶ Lemma 33 (Universal Extension equivalence). Let be a finite normalized closed graph, and a universal extension of . Let be an interpretation, then the following holds:
Proof. Let be a model of . We know that for all mappings , there exists a mapping such that is true. We also know (from Definition 32) that there exists a mapping such that . We also know that, for every , there exists and such that . We set . It follows that is true, thus .
Let be a model of . We know that there exists such that is true. We also know (from Definition 32) that for all mapping there exists a mapping such that . We set . Then is true, thus .
With universal extensions, we can provide the N3 version of the interpolation lemma for basic entailment:
▶ Lemma 34 (Generalised interpolation lemma). Given two finite normalised closed graphs and and universal extensions of and of then the following holds:
\quad iff \quad there exists a mapping such that, for every triple of an E-instance of there is some triple of such that , , and , are isomorphic under to , , and respectively.
Before proving the lemma, we demonstrate how it relates to the RDF interpolation lemma for simple entailment [24, Section 5.3] with the following corollary:
▶ Corollary 35 (RDF interpolation lemma). Given two finite normalised closed graphs and which do not contain graph terms. b-entails a graph if and only if a subgraph of is an E-instance of .
To see how the corollary is a special case of the lemma we first we take a closer look at the right hand side of the lemma. Note that universal extensions and are variants of and in which only the variables in and are renamed. As we exclude graph terms as components, the isomorphism between the elements , , and , , is only an isomorphism in the RDF sense.
We come back to Lemma 34 and provide its proof:
Proof. Let . We construct a model for . We set , where stands for the identity function. We choose a representation of the isomorphic graph terms and let map graph terms to their isomorphic image. For each we choose a unique IRI . We set . We clearly see that . By Lemma 33, it follows that , which by our assumption means that and thus, again by Lemma 33, . That is, there is a mapping such that or written differently for each triple . We can therefore always find a triple such that . We apply the mapping
42:21
to create an E-instance of . The claim follows for the mapping
where is an arbitrary value.
Let be a mapping such that, for every triple of an E-instance of there exists some triple of such that , and are isomorphic under to , and , respectively. Let . As is an E-instance of , there exists a mapping such that . We thus have that is isomorphic to a subgraph of . It follows by Lemma 28 and Lemma 27, that , that is, there exists a mapping , such that . We extend and to total mappings and on which behave like the identity function in cases where , respectively are not defined. Then holds and thus . The claim follows by Lemma 33.
Note that Corollary 35 differs from RDF's interpolation lemma as stated in the specification in one detail: RDF allows the graphs to be infinite while we only talk about finite graphs. The reason is that is that our proof relies on finding "fresh" ground terms the existential variables can map to (variables need to correspond to ground terms). This is not possible for a graph G using all possible ground terms, i.e. . For such a graph these terms always carry additional meaning. We aim to address this issue in future work.
5.4 N3-entailment
In the previous sections we introduced and discussed N3's basic-entailment which – as we explained – is very similar to RDF's simple entailment. On top of this, we define N3-entailment which covers the N3-predicates collected under the log-namespace . We introduce the predicates log:implies and log:includes.
▶ Definition 36 (N3 models and entailment). Let I be an interpretation and G and H be graphs. We call I an N3 model of G, noted , iff and I satisfies the following conditions:
■ I satisfies the conditions for log:implies (see Definition 37)
■ I satisfies the conditions for log:includes (see Definition 40)
We say that G N3-entails H, written as iff for each interpretation I it holds that if then .
Note, that the log-namespace covers a wider range of predicates supporting, for example operations on literals (log:dtlit, log:langlit) or types of terms (log:rawType). We omit those here as the primary focus of this paper are graph terms. To take into account the missing cases, the above definition can be extended.
Below, we provide the definitions for the two predicates. We start with the predicate log:implies, which is used for implications.
▶ Definition 37 (Semantic conditions for log:implies). The semantic conditions on an interpretation I for log:implies are:
■ for all , holds only if either
http://www.w3.org/2000/10/swap/log#
42:22 Notation3: Graph Terms for RDF
and are both graph terms and holds if
s or g is not a graph term
To illustrate how this definition makes it possible to apply rules on data, we come back to our example from the previous section:
{(:tom, rdf:type, :Human)}
(32)
(31)
Any model I of these two triples must satisfy:
By the semantic condition on log:implies (first bullet), and the fact that I is a model for the graph on the left hand side (“tom type human”), we derive that I is also a model for the graph on the right-hand side. The graph above thus N3-entails
If we were to replace :tom in the second line with a universally quantified variable x (as in Formula 19), the implication still holds. First, consider the implication as a “regular” assertion containing a universal. This assertion must hold for every possible value of ?x, including :tom, so the second bullet above would still hold in every basic model of the graph. This would in turn lead to the N3-entailment that , as above.
The example also shows that N3-entailment supports a form of existential rules. Thus, in general, it is not decidable whether one graph is N3-entailed by another [9]. Other rule frameworks for RDF either exclude blank nodes on rule heads (e.g. SWRL [25]) or limit how often such rules can be applied (e.g. SPARQL RL [18]). As blank nodes are widely used and important in different contexts, N3 allows them in rule heads. Some reasoners like for example EYE [37] provide mechanisms to tame such rules by different mechanisms.
The above mechanism even allows us to cover the "unquoting" example from Section 2 which had a variable as rule head:
:bob :says {:alice :likes :pizza, :pasta}.
(2)
{ :bob :says ?x } => ?x.
(5)
Represented in abstract syntax, these formulae can be written as:
(40)
(41)
By simple entailment, we obtain Formula 7 which we represent in abstract semantics as:
(42)
With the condition for log:implies, we derive from Formulae 40 and 41:
(43)
which is the abstract representation of Formula 6.
42:23
Note that the semantic condition above is a one-way implication (“only if”). This means that given two graphs G and H such that , it does not necessarily hold that log:implies . Note also that the semantic condition allows for log:implies to hold between a non-graph term and any other term (last sub-bullet in Definition 37), in which case, it does not have any special meaning.
Similarly to the conditions shown above, we define the semantics for the predicate log:includes. The predicate was initially introduced to mimic basic entailment (more precisely its predecessor N3 derivation [13, Section 5.7]). It has two ground graph terms as arguments and is true if the second graph is b-entailed by the first one. A simple example of such a true triple (in N3 syntax) is:
{:s :p :o. :a :b :c} log:includes {:a :b :c}
(44)
As the second argument of the predicate is a subgraph of the first we clearly see it is b-entailed by it (see Lemma 28). This example is easy to implement and supported by most reasoners we are aware of. However, b-entailment including universal quantification is rather complex as we illustrated earlier on Formulae 36-39. To the best of our knowledge, there is furthermore no reasoner supporting it and most practical use cases only require a simpler form of entailment which does not go beyond the expressivity of RDF's interpolation lemma (Corollary 35) . We therefore exclude universal quantification here and define:
▶ Definition 38 (Existential consequence). If a subgraph of a finite closed N3 graph is isomorphic to an E-instance of an N3 graph , we call a existential consequence of .
From our considerations in Section 5.2, we immediately see:
▶ Corollary 39 (Existential Consequence). An N3 graph b-entails any of its existential consequences.
Proof. This follows directly from Lemmas 27, 28 and 29.
Note that even graphs with universally quantified variables can have existential consequences. The concept only limits the kind of derivation steps taken into account and explicitly excludes consequences produced by instantiating universals. The graph
is an existential consequence of graph in Formula 34.
We use the existential consequence to define the semantics of the predicate log:includes.
▶ Definition 40 (Semantic conditions for log:includes). The semantic conditions on an interpretation I for log:includes are:
if and only if and are both graph terms and is an existential consequence of .
Note that the semantic condition above is a two-way implication (“if and only if”). In other words, the extension of log:includes contains exactly all the pairs of graph terms present in such that the second one is an existential consequence of the first one.
Example uses can be found on the N3 test suite https://codeberg.org/phochste/notation3tests.
42:24 Notation3: Graph Terms for RDF
6 Discussion of the requirements
Having defined the concept of basic semantics and N3 semantics, we now come back to the requirements identified in Section 3 discussing them one by one.
Semantic compatibility with RDF We defined basic entailment (Definition 23) and characterised it through a generalised interpolation lemma (Lemma 34). We furthermore showed that for RDF graphs b-entailment and simple entailment coincide (Lemma 26) and that the N3 interpolation lemma for b-entailment (Lemma 34) is an extension of the RDF interpolation lemma for simple entailment on finite graphs (Corollary 35). The main difference between the two is that the RDF interpolation lemma also holds for infinite graphs while the N3 interpolation lemma is limited to finite graphs. As entailment between infinite RDF graphs is rarely needed in practice, we consider the difference between both forms of entailment minimal . The semantics we defined is otherwise in line with RDF-entailment and the requirement is met.
Referential Opacity The second requirement we identified was referential opacity. We meet this requirement by semantically representing graph terms as syntactic objects in base semantics which can then be further refined in N3 semantics – or possible other extensions – like we exemplified on implications and inclusion. We come back to our superman example (Formulae 8 and 9), which we represent in abstract syntax
Even with an interpretation where , we have:
With Rule 11 which we write in abstract syntax as
This rule b-entails
and with N3-entailment we get
Our semantics supports referential opacity, while allowing to locally enable the derivations that would follow from referential transparency, as illustrated above.
Closedness of graph terms Another requirement we identified was that graph terms in N3 need to be closed as they are used to represent premises and conclusions of rules. We again meet this criterion by interpreting graph terms by an isomorphic syntactical representation. In the case of implications, we further interpret the graph terms as graphs which in case they are true in a
Furthermore, as explained in Section 8, we conjecture that Lemma 34 can be generalized to a broader class of graphs, not necessarily finite.
42:25
model can be used to derive new facts. If needed, IRIs could be used to represent open graphs. We could for example state
\{(:loisLanesKnowledge,:contains,\{\(:superman,:can,:fly)\})\}and provide semantics for the predicate :contains which ensure that the subject of the predicate represents a graph consisting of at least the triples occurring in its object graphs. This idea has been discussed in previous work to represent RDF datasets using N3 [7].
Clarity and flexibility of quantification scopes We introduced explicit quantification to avoid possible ambiguities arising from implicit scoping. For each graph we declare the set of universally and existentially quantified variables. This makes our semantics independent of the concrete syntax whose scoping of implicit quantification is still subject to discussion. Our semantics with explicit scoping makes it possible to better understand the impact of future scoping decisions and possible restrictions to the language. In our approach, we chose to follow N3's original specification in which the scope of universal specification is always outside the scope of existential quantification when these are declared on the same graph [13, p.20]. At least if we employ N3 entailment and not just basic entailment, this design decision does not restrict the expressivity of our logic. For example, if we want to modify our initial example on quantification ("Everybody loves somebody", Formula 12) to express that there exists someone who is loved by everyone, we can state
According to our semantics, the empty graph is always true and in an N3 model the formula has thus the intended meaning.
7 Related work
The work presented in this paper has been influenced by several other publications.
First, it relies on the original contributions introducing Notation3 Logic: W3C team submission [12], a web page by Tim Berners-Lee explaining design issues of the framework [11], and a research paper detailing the logic [13]. All N3 features discussed in this paper were informally introduced in these early specifications of the logic; however, none of them had formal semantics. This explicitly includes graph terms and implicit quantification of two different types. N3 also offers the means to state explicit quantification (see also Formulae 12" and 20). In the past, this feature often lead to problems because N3 treats the quantifiers themselves as parts of the graphs and thus as elements of sets. This makes it difficult to determine the proper scope of a quantifier and their orders. The specification allows us to write Formula 12" from above as
(12")
without changing its meaning ("everybody loves somebody"). As we consider this detail confusing, we impose a fixed order for the two kinds of quantifiers. Not only explicit quantification but also its implicit counterparts has lead to contradicting interpretations. In previous work, we investigated the extent and impact of these disagreements and proposed a mapping to a logic with explicit quantification [5, 6]. This mapping could cope with formulae which are similar to First Order Logic like, for example, the implication detailed in Formula 4. But it did not cover cases like the unquoting exemplified in Formula 5 or the built-in log:includes. The development of N3 was continued by a W3C community group which provided specifications for the syntax of the language [35], its semantics [8], and its built-in functions [36]. The semantics developed
42:26 Notation3: Graph Terms for RDF
in this context forms the base of the work we present in this paper. In addition to refining the definitions of that specification, we furthermore investigate N3's formal relationship to RDF simple entailment and add a semantic definition for the predicate log:includes. In earlier work this predicate relies on a simplified form of entailment called n3-derivation [13, p.13]. Even though n3-derivation was not fully detailed when introduced, we see a strong similarity to basic entailment as it was introduced in this paper.
The idea of referencing to graphs, formulae, or statements has not only been discussed in the context of N3 but can also be found in different frameworks for the web and beyond. We first discuss web formalisms to then broaden our discussion towards logic in general. In the moment of writing, the W3C RDF & SPARQL working group is developing RDF 1.2 [28] and SPARQL 1.2 [23] which add triple terms to RDF and SPARQL. Conceptually, these are very similar to graph terms with the main difference that users can not use whole graphs as terms of triples but only single triples. RDF 1.2 originates from RDF-star (also RDF*) [22] which was originally proposed by Hartig [21]. In RDF 1.2 the use of triple terms is restricted and they are only allowed in the object position of a triple. Blank nodes in triple terms are globally quantified and triple terms are referentially transparent. In both of these aspects, triple terms differ from N3 graph terms. A singleton N3 graph term is not the same as a triple term in RDF 1.2. RDF does furthermore not support rules and it does not support any mechanism to unquote triple terms as illustrated for N3 with Example 5.
Before the rise and standardisation of triple terms, RDF reification [24, Appendix D1] was used to make statements about triples. There was no special syntactic construct to refer to triples but these were described in RDF's triple syntax. A reified triple was represented by an IRI or blank node in combination with predicates making connections to the different components of a triple (rdf:subject, rdf:predicate, rdf:object). There was no semantics for RDF reification and no guarantees or checks that a reified triple was well-formed (we could for example have two subject declarations for the same term). However, by the way RDF reification is done, we can assume that it is referentially transparent and that all existential quantification is global.
As an alternative to RDF reification, Nguyen et al. proposed singleton properties [31]. The idea behind this concept is to use, in each triple to be reified, a fresh predicate that is related to the original property. That predicate can then be used to refer to the single triple where it is used. This approach to refer to triples does not only differ syntactically from the former two, it also differs in another sense: while triple terms and also reification, just like N3 graph terms, can be used without stating the triple, this is not possible with singleton properties. We can, for example, not express Formula 8 without asserting that :superman :can :fly.
To refer to graphs RDF 1.1 furthermore introduced the concept of RDF datasets [30, Section 4]. Here, a combination of a graph name and a graph can be stated in an RDF document and the name can then further be used to refer to that construct. Although RDF datasets are part of the RDF 1.1 recommendation, their semantics has not been fixed and there exist different proposals [39] addressing the different aspects identified in Section 3 in various ways most of which can be represented by N3 [7]. The semantics introduced by Carroll et al. [16] is the closest to the graph term semantics introduced in this paper. A named graph in this semantics is a pair composed of a name and a graph, and that name can be used in triples and always refers to the pair itself. As N3 graph terms do not have names, we observe a difference here. The graph is closed, blank nodes are local, and the graph itself is interpreted as a syntactical object thereby supporting referential opacity.
Outside of the web context, Common Logic [26] defines constructs similar to RDF datasets and their semantics according to Carroll et al. Here, we can again combine formulae with names to then use these names in other formulae. In contrast to RDF datasets, Common Logic supports
42:27
universal quantification but it does not support to quantify into a formula. The expression
is supported by our semantics of N3 but cannot be expressed in Common Logic. The difficulty here is that the quantified variable x occurs inside and outside of the graph term. We solve that by first grounding the variable, then further interpret it according to the position where it is used (once as a direct term, once as part of the graph term). Common Logic does furthermore not support unquoting. In contrast to that, Qiana, a framework developed by Coumes et al. [17], supports both quantifying into a formula/graph term and unquoting. The mechanism to do so differs from our approach, as its formalisation treats quoted formulae as logical functions which directly take terms of the domain of discourse as arguments. This can be used to resolve quantification over variables used simultaneously inside and outside a quoted formula – we use grounding instead. Qiana furthermore diverges from N3 in that its main focus is to display formulae together with some context under which they may or may not be true. In that regard, it is close to the different variants of modal logic [14]. We adopt Qiana's notation of underlining formulae/graph terms to indicate their mention rather than use.
The concept of universal extension of N3 graphs (Definition 32) and the related theory have been influenced by the work around existential rules [9] (also called tuple-generating dependencies [1] or [15]). Here, the chase procedure can be used to construct universal models [19]: existential rules are applied repeatedly to a growing set of facts, where each rule application adds new facts unless its head already maps homomorphically into the existing ones. In the case of basic entailment, we do not have rules but -formulae which could be seen as existential rules with empty bodies. To mimic RDF's interpolation lemma, we therefore have to apply them on all terms producing infinite models. Existential rules are furthermore closely related to N3 rules employing the built-in predicate log:implies [4, 3] and query answering for N3 entailment faces the same problems as for existential rules and is in general undecidable.
8 Conclusion and future work
We have proposed an abstract syntax and a formal semantics for N3. Compared to previous efforts in that direction, our proposal aims to cover the different ways in which graph terms have been used historically in N3: statements about statements, and rules. This formal semantics is defined in two levels: basic semantics (comparable to RDF's simple entailment), and N3 semantics, which includes N3's special predicates, notably the rule-defining predicate log:implies. We have shown that this formal semantics satisfies the requirement we identified as meeting those different use-cases, and that RDF's interpolation lemma for simple entailment can be extended to N3's basic semantics (on finite graphs).
While we proved our generalized interpolation lemma for finite graphs only, we conjecture that a proof may exist for infinite graphs as well. As a matter of fact, our proof does not prevent the graphs to have an infinite number of triples; it only requires them to not use all the variables (so that we can build a universal extension) nor all the ground terms (so that we can build a mapping ). But we believe that even those constrains could be lifted, and plan to address them in future work.
We also acknowledge that our generalized interpolation lemma is far less practical than its counterpart in RDF: it relies in the universal extension of N3 graphs, which are infinite as soon as the graph contains a universal variable (unlike universal models [19], the concept of which universal extensions are inspired). In the future, we wish to provide an entailment procedure which only takes the terms occurring in the two involved graphs into account similar to the RDFS entailment rules provided in the RDF specification [34, 24].
42:28 Notation3: Graph Terms for RDF
Finally, while we formally define in N3-entailment the semantics of the special predicates log:implies and log:includes, the original N3 specification (and its implementations) provide much more special predicates. We plan to include them, following the example of the two we described in this paper. Note that some of these additional properties will include new challenges, such as negation (e.g. log:notIncludes ) and aggregation (e.g. log:forAllIn ). As N3 allows variables to occur in the predicate position of triples, these concepts cannot rely on classical stratification [2]. We plan to base our definitions on chain stratification [29], a concept recently proposed to overcome that problem.
References
1 Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison-Wesley, 1995. URL: http://webdam.inria.fr/Alice/.
2 Krzysztof R. Apt, Howard A. Blair, and Adrian Walker. Towards a theory of declarative knowledge. In Jack Minker, editor, Foundations of Deductive Databases and Logic Programming, pages 89–148. Morgan Kaufmann, 1988. doi:10.1016/B978-0-934613-40-8.50006-3.
3 Dörthe Arndt and Stephan Mennicke. Notation3 as an existential rule language. In International Joint Conference on Rules and Reasoning, pages 70–85. Springer, 2023. doi:10.1007/978-3-031-45072-3_5.
4 Dörthe Arndt and Stephan Mennicke. Existential Notation3 logic. Theory and Practice of Logic Programming, pages 1–36, June 2025. doi:10.1017/S1471068425000055.
5 Dörthe Arndt, Tom Schrijvers, Jos De Roo, and Ruben Verborgh. Implicit quantification made explicit: How to interpret blank nodes and universal variables in Notation3 logic. Journal of Web Semantics, 58:100501, 2019. doi:10.1016/j.websem.2019.04.001.
6 Dörthe Arndt, Ruben Verborgh, Jos De Roo, Hong Sun, Erik Mannens, and Rik Van de Walle. Semantics of Notation3 logic: A solution for implicit quantification. In Rule Technologies: Foundations, Tools, and Applications: 9th International Symposium, RuleML 2015, Berlin, Germany, August 2-5, 2015, Proceedings 9, pages 127–143. Springer, 2015. doi:10.1007/978-3-319-21542-6_9.
7 Dörthe Arndt and William Van Woensel. Towards supporting multiple semantics of named graphs using N3 rules. In Ahmet Soylu, Sotiris Moschoyiannis, Guido Governatori, Mantas Simkus, Petros S. Stefaneas, Alexander Steen, and Adrian Giurca, editors, Proceedings of the 13th RuleML+RR 2019 Doctoral Consortium and Rule Challenge, September 16-19, 2019 - Bolzano, Italy, volume 2438 of CEUR Workshop Proceedings. CEUR-WS.org, 2019. URL: https://ceur-ws.org/Vol-2438/paper6.pdf.
8 Dörthe Arndt and Pierre-Antoine Champin. Notation3 semantics. W3C community group report, W3C, October 2025. https://w3c.github.io/N3/reports/20230703/semantics.html.
9 Jean-François Baget, Michel Leclère, Marie-Laure Mugnier, and Eric Salvat. On rules with existential variables: Walking the decidability line. Artif. Intell., 175(9-10):1620–1654, 2011. doi:10.1016/J.ARTINT.2011.03.002.
10 Tim Berners-Lee. Cwm, 2000–2009. http://www.w3.org/2000/10/swap/doc/cwm.html.
11 Tim Berners-Lee. Notation 3 Logic. Technical report, W3C, 2005. URL: https://www.w3.org/DesignIssues/Notation3.
12 Tim Berners-Lee and Dan Connolly. Notation3 (N3): A readable RDF syntax. Technical report, W3C, 2011. URL: https://www.w3.org/TeamSubmission/n3/.
13 Tim Berners-Lee, Dan Connolly, Lalana Kagal, Yosi Scharf, and Jim Hendler. N3Logic: A logical framework for the World Wide Web. Theory and Practice of Logic Programming, 8(3):249–269, 2008. URL: http://arxiv.org/abs/0711.1533, doi:10.1017/S1471068407003213.
14 Patrick Blackburn, Maarten de Rijke, and Yde Venema. Modal Logic, volume 53 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2001. doi:10.1017/CB09781107050884.
15 Andrea Cali, Georg Gottlob, and Thomas Lukasiewicz. Datalog : a unified approach to ontologies and integrity constraints. In Ronald Fagin, editor, Database Theory - ICDT 2009, 12th International Conference, St. Petersburg, Russia, March 23-25, 2009, Proceedings, volume 361 of ACM International Conference Proceeding Series, pages 14–30. ACM, 2009. doi:10.1145/1514894.1514897.
16 Jeremy J. Carroll, Christian Bizer, Patrick J. Hayes, and Patrick Stickler. Named graphs, provenance and trust. In Allan Ellis and Tatsuya Hagino, editors, Proceedings of the 14th international conference on World Wide Web, WWW 2005, Chiba, Japan, May 10-14, 2005, pages 613–622. ACM, 2005. doi:10.1145/1060745.1060835.
17 Simon Coumes, Pierre-Henri Paris, François Schwarzentruber, and Fabian M. Suchanek. Qiana: A first-order formalism to quantify over contexts and formulas with temporality. J. Artif. Intell. Res., 85, 2026. doi:10.1613/JAIR.1.18402.
https://w3c-cg.github.io/N3/spec/builtins.html#log:notIncludes
https://w3c-cg.github.io/N3/spec/builtins.html#log:forAllIn
42:29
18 Robert David, David Habgood, Andy Seaborne, and Simon Steyskal. SPARQL 1.2 RL. W3C working draft, W3C, September 2026. https://www.w3.org/TR/sparql12-r1/.
19 Alin Deutsch, Alan Nash, and Jeffrey B. Remmel. The chase revisited. In Maurizio Lenzerini and Domenico Lembo, editors, Proceedings of the Twenty-Seventh ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS 2008, June 9-11, 2008, Vancouver, BC, Canada, pages 149–158. ACM, 2008. doi:10.1145/1376916.1376938.
20 Michael Genesereth and Eric Kao. The Herbrand manifesto. In Nick Bassiliades, Georg Gottlob, Fariba Sadri, Adrian Paschke, and Dumitru Roman, editors, Rule Technologies: Foundations, Tools, and Applications, pages 3–12, Cham, 2015. Springer International Publishing. doi:10.1007/978-3-319-21542-6_1.
21 Olaf Hartig. Foundations of RDF* and SPARQL*: (an alternative approach to statement-level metadata in RDF). In AMW 2017 11th Alberto Mendelzon International Workshop on Foundations of Data Management and the Web, Montevideo, Uruguay, June 7-9, 2017., volume 1912. Juan Reutter, Divesh Srivastava, 2017. URL: https://ceur-ws.org/Vol-1912/paper12.pdf.
22 Olaf Hartig, Pierre-Antoine Champin, Gregg Kellogg, and Andy Seaborne. RDF-star and SPARQL-star. W3C community group report, W3C, December 2021. https://www.w3.org/2021/12/rdf-star.html.
23 Olaf Hartig, Andy Seaborne, Ruben Taelman, Gregory Williams, and Thomas Pellissier Tanon. SPARQL 1.2 query language. W3C working draft, W3C, September 2026. https://www.w3.org/TR/sparql12-query/.
24 Pat Hayes and Peter F. Patel-Schneider. RDF 1.1 Semantics. W3C recommendation, W3C, February 2014. URL: https://www.w3.org/TR/rdf11-semantics/.
25 Ian Horrocks, Peter F Patel-Schneider, Harold Boley, Said Tabet, Benjamin Grosof, and Mike Dean. SWRL: A semantic web rule language combining OWL and RuleML. W3C member submission, W3C, May 2004. https://www.w3.org/Submission/2004/SUBM-SWRL-20040521/.
26 ISO/IEC. Information technology — Common Logic (CL): A framework for a family of logic-based languages. Standard ISO/IEC 24707:2018, International Organization for Standardization, Geneva, Switzerland, 2018.
27 Tobias Käfer and Andreas Harth. Rule-based programming of user agents for linked data. LDOW@WWW, 2073, 2018. URL: https://ceur-ws.org/Vol-2073/article-05.pdf.
28 Gregg Kellogg, Olaf Hartig, Pierre-Antoine Champin, and Andy Seaborne. RDF 1.2 concepts and abstract syntax. W3C candidate re-
commendation snapshot, W3C, April 2026. URL: https://www.w3.org/TR/rdf12-concepts/.
29 Nils Küchenmeister, Alex Ivliev, Dörthe Arndt, and Markus Krötzsch. Stratified negation in RDF rules: A correct approach. In Manolis Koubarakis, Maria-Esther Vidal, Axel Polleres, Marieke van Erp, Ernesto Jimenez Ruiz, Oshani Seneviratne, Lora Aroyo, Gianluca Demartini, Reham Alharbi, Roberto Barile, Claudia d'Amato, and Valentina Tamma, editors, Proceedings of the 25th International Semantic Web Conference (ISWC 2026). Springer, 2026.
30 Markus Lanthaler, David Wood, and Richard Cyganiak. RDF 1.1 concepts and abstract syntax. W3C recommendation, W3C, February 2014. URL: https://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/.
31 Vinh Nguyen, Olivier Bodenreider, and Amit Sheth. Don't like RDF reification? Making statements about statements using singleton property. In Proceedings of the 23rd international conference on World Wide Web, pages 759–770, 2014. doi:10.1145/2566486.2567973.
32 Eric Prud'hommeaux and Gavin Carothers. RDF 1.1 turtle. W3C recommendation, W3C, February 2014. URL: https://www.w3.org/TR/2014/REC-turtle-20140225/.
33 Eric Prud'hommeaux and Gavin Carothers. RDF 1.1 turtle. W3C recommendation, W3C, February 2014. https://www.w3.org/TR/2014/REC-turtle-20140225/.
34 Herman J. ter Horst. Completeness, decidability and complexity of entailment for RDF schema and a semantic extension involving the OWL vocabulary. J. Web Semant., 3(2-3):79–115, 2005. doi:10.1016/J.WEBSEM.2005.06.001.
35 William Van Woensel, Dörthe Arndt, Pierre-Antoine Champin, Dominik Tomaszuk, and Gregg Kellogg. Notation3 language. W3C community group report, W3C, October 2025. https://w3c.github.io/N3/reports/20230703/.
36 William Van Woensel and Patrick Hochstenbach. Notation3 builtin functions. W3C community group report, W3C, July 2023. https://w3c.github.io/N3/reports/20230703/builtins.html.
37 Ruben Verborgh and Jos De Roo. Drawing conclusions from linked data on the web: The EYE reasoner. IEEE Software, 32(5):23–27, May 2015. doi:10.1109/MS.2015.63.
38 W3C OWL Working Group. OWL 2 web ontology language document overview (second edition). W3C recommendation, W3C, December 2012. https://www.w3.org/TR/owl2-overview/.
39 Antoine Zimmermann. RDF 1.1: On semantics of RDF datasets. W3C working group note, W3C, February 2014. URL: https://www.w3.org/TR/rdf11-datasets/.