From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Tue, 03 May 2005 13:42:01 +0100
Message-ID: <42777199.50007@hp.com>

```

> Continuing where Bijan left off, I have a comment on
> the formal definition of "Optional Matching".
>
> Here's what the specs [1] say:
> "Given graph pattern GP1, and graph pattern GP2,
> Opt(GP1, GP2) is the optional match of GP2 of graph G,
> given GP1.
>
> Let GP = (GP1 union GP2) then S is a solution of
> Opt(GP1, GP2) if"
> [snip]
> -----
> I'm not sure which "union" is meant here? Obviously, I
> assume we don't mean the 'union' keyword used for
> pattern alternatives. In any case, "union" implies
> logical disjunction whereas what we need here is a
> conjunction, i.e.,  we need a group pattern, so we can
> rewrite GP = {GP1, GP2}
> ----
>
> ..continuing with the defn..
>
> "S is a solution for a match of GP on G, or else S is
> a solution for GP1 and S is not a solution for GP.
>
> S in R(Opt(GP1, GP2), G) if:
>    S in R(GP, G)
> or
>   S not in R(GP,G) and S in R(GP1, G)."
> ------
>
> I'm not sure if "S not in R(GP,G)" is required in the
> second disjunct. As I understand Optional Matching, if
> S is a solution to an optional match of GP2 on G given
> GP1, it implies that S must match GP1 first (on G) and
> then optionally match GP2 (on G), right? So in that
> case, the definition should be:
>
> S in R(Opt(GP1, GP2), G) if:
>
>   S in R(GP1, G)
> or
>   S in R(GP, G), where GP = {GP1, GP2}

I think this definition is the same as defining OPT(P) as "P or true".  It has
nicer theoretical properties but gives more solutions and generally the extra

Example:

_:a foaf:mbox <mailto:alice> .
_:a foaf:name "Alice"  .

Pattern

{
?x foaf:name ?mbox
OPTIONAL { ?x foaf:name ?name }
}

gives:

?mbox = <mailto:alice>
?mbox = <mailto:alice>  ?name = "Alice"

which isn't really what the application task is (i.e. extending a solution with
extra information).

It is not a simple matter of noting when an optional caused a binding or a fixed
pattern - as patterns grow, the same solution can come via different routes.

Andy

> ------
>
> Cheers,