rdfjs / types

Authoritative TypeScript typings for all RDFJS specifications
MIT License
17 stars 13 forks source link

Proposal: `Formula` term #37

Open jeswr opened 1 year ago

jeswr commented 1 year ago

I would like to propose the introduction of a new RDF/JS term called a Formula to represent Notation3 Formulas / Graph Terms.

Currently, when Notation3 syntax is parsed, Graph Terms in Notation3 are represented using blank nodes. That is,

:a :b { :c :d :e } . 

will be parsed as the two quads

:a :b _:b0
:c :d :e _:b0

The fact that _:b0 represents a graph term and not a blank node in :a :b _:b0 cannot be deduced from the triple alone. Instead it has to be implicit from the presence of the quad :c :d :e _:b0 in a dataset; where _:b0 is used as a graph term.

Furthermore, empty graphs are legal in N3. That is, the statement :a :b {} . is legal in N3. This gets parsed to the RDF/JS quad :a :b _:b0 which is the same as parsing :a :b [] despite :a :b {} and :a :b [] having an entirely different semantic meaning. This means that without having a notion of Notation3 Formulas / Graph Terms, or at least the empty graph, we are enable to represent all N3 concepts within RDF/JS.

phochste commented 1 year ago

For the empty graph it would be sufficient to parse it as true :a :b {} is isomorphic to :a :b true. See also https://w3c.github.io/N3/spec/semantics.html#ground-graphs .

jeswr commented 1 year ago

or the empty graph it would be sufficient to parse it as true :a :b {} is isomorphic to :a :b true.

I'm not entirely sure on this. Note that a parser should deal only with converting syntax to a set of triples and generally not be aware of any semantics that reasoners apply. So I am not sure if {} should be parsed as true in the same way that ex:me should not be parsed as ex1:me even if ex:me owl:sameAs ex1:me.

If the spec were explicit in saying that {} should be parsed as the literal true then I would be ok with this.

I'd be interested to see what @josd thinks of this.

phochste commented 1 year ago

in the same way that ex:me should not be parsed as ex1:me even if ex:me owl:sameAs ex1:me.

I think this owl:sameAs is on yet another level (already an inference). The true of the empty graph is on model level. But, you are right that this is already interpreting the data in some way. Interestingly, it depends on the implementation.

josd commented 1 year ago

In eye we treat {} as true because the empty conjunction of triples is true.

rubensworks commented 1 year ago

Since N3 is not (on its way to become) a W3C rec yet, I'm not sure if it's the right time to add this to the core datamodel yet of RDF/JS. An alternative would be for the N3 CG to propose an extension of the RDF/JS Term, and standardize it in the context of the N3 CG?

bergos commented 1 year ago

If treating {} as true, as proposed by @josd, is possible without drawbacks, I would support that solution. That would avoid the problems mentioned by @rubensworks.

Btw. These kind of topics should be discussed in the repository of the Data Model specification. If there is more to discuss, please move the discussion there. In case the solution with true works, it would be good to have a summary somewhere. Maybe you can create a new N3 page in the Wiki.

jeswr commented 1 year ago

If treating {} as true, as proposed by @josd, is possible without drawbacks, I would support that solution.

I'm deferring this decision to the N3 group. If we see a syntax test case where the test case is :a :b {} and the expected output is :a :b true then we can close of this issue and I will create a wiki page.

Otherwise I will move the discussion to the Data Model specification repo.