# Re: semantics of OPTIONAL/LeftJoin

From: Roman Kontchakov <roman@dcs.bbk.ac.uk>
Date: Tue, 16 Jun 2015 16:42:51 +0100
Message-Id: <7A08FF72-0CED-454C-A268-E8351CA7CED7@dcs.bbk.ac.uk>

```Dear Andy

It seems to me that the fix to the "written in full" definition of LeftJoin as described in http://www.w3.org/2013/sparql-errata#sparql11-query does not quite work.

For example, let Ω1 = { (?X -> :a) }, Ω2 = { (?X -> :a,  ?A -> 20), (?X -> :b, ?A -> 30) } and F = ?A = 30.

Using the normative definition, LeftJoin(Ω1,Ω2,F) = Filter(F, Join(Ω1,Ω2)) union Diff(Ω1,Ω2,F), we obtain

- Join(Ω1,Ω2) = { (?X -> :a, ?A -> 20) } and so Filter(F, Join(Ω1,Ω2)) is empty;

- on the other hand, Diff(Ω1,Ω2,F) = { (?X -> :a) } because for the only mapping μ1 in Ω1, the first mapping in Ω2 is compatible with μ1 but the effective boolean value of F is false and the second mapping in Ω2 is not compatible with μ1.

Thus,  LeftJoin(Ω, Ω2, F) = { (?X -> :a) }       (1)

Using the "written in full" definition from the errata,

LeftJoin(Ω1, Ω2, F) =   { merge(μ1, μ2) | μ1 in Ω1 and μ2 in Ω2, μ1 and μ2 are compatible and F(merge(μ1, μ2)) is true }
∪  { μ1 | μ1 in Ω1, ∀ μ2 in Ω2, μ1 and μ2 are not compatible, or Ω2 is empty }
∪  { μ1 | μ1 in Ω1, ∀ μ2 in Ω2, μ1 and μ2 are compatible and F(merge(μ1, μ2)) is false }

we obtain, respectively,

- the empty set (see above),
- the empty set (because Ω2 is not empty and contains a mapping compatible with the only mapping in Ω1),
- the empty set (because the first mapping in Ω2 is compatible with the only mapping in Ω1 but F is false).

The result, therefore, is the empty set, which is not equal to (1).

In fact, I suspect, there is no simple way of translating the two components in the union of the normative definition into some sort of `three-component' union. So, in my view, it is easier to replace the current "written in full" version of LeftJoin with Filter over Join + Diff (or omit it altogether to avoid any confusion).

Best regards
Roman

--
Roman Kontchakov
Birkbeck, University of London
```
Received on Thursday, 18 June 2015 09:46:13 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 18 June 2015 09:46:13 UTC