I've been reading up again on N3 rules and N3 in general and am struggling to understand what the correct scoping of variables declared with @forSome and @forAll is.

Do the variables defined only have scope in the subsequent formula/Triple or do they have scope for all subsequent triples (and if so where does the scope end - at the next @[email protected])?

The N3 Rules documentation would seem to suggest the latter since it has examples such as:

@forSome :a.
:Joe :home :a.
:a  :phone "555-1212".

So does as I suspect the variables apply to all subsequent triples and how do I decide when it stops applying (if it does at all)?

asked 12 Oct '10, 15:01

Rob%20Vesse's gravatar image

Rob Vesse ♦
accept rate: 29%

From the N3 Rules doc you linked:

The "this" indicates the scope of the variable - it in fact stands for the formula in which it is, in this case the outermost formula of the document. In most cases for simple rules, the variables are quantified in the scope of the document, but when things get nested, it is wise to think about what you mean.

It's not very clearly worded, but I interpret the scoping to be given by { } as per formulae.

So, I'd interpret it as:

@forSome :a.
:Joe :home :a.
:a  :phone "555-1212".

keeps the @forSome scope for :a to the phone triple, but

@forSome :a.
:Joe :home :a.
:a  :phone "555-1212".

wouldn't, though:

@forSome :a.{
:Joe :home :a.
:a  :phone "555-1212".

seemingly would.

If there's no { }, strictly speaking it seems that it should apply to the whole document.

permanent link

answered 12 Oct '10, 15:12

Signified's gravatar image

Signified ♦
accept rate: 37%

edited 12 Oct '10, 16:07


Which part of the N3 specification is clearly worded ;-) Ok, that makes sense, thanks for that

(12 Oct '10, 20:43) Rob Vesse ♦ Rob%20Vesse's gravatar image

The tagline? "An readable language for data on the Web." Oh no, wait. :)

(12 Oct '10, 21:13) Signified ♦ Signified's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Oct '10, 15:01

question was seen: 1,435 times

last updated: 12 Oct '10, 16:07