Skip to content
Alpha: see what works today →
Menu

Derivation

same-pairs

Two records named together by a counting Same judgment are currently the same, unless they are also currently different: a Different judgment wins. A Same none of whose members are currently different joins each member with its least, in code point order of the IRI, both ways: a star, 2(n - 1) pairs for n members, which makes the entries every pair would. A Same two of whose members are currently different joins every other pair of its members, so a Different pair is still joined through a third member.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX prov: <http://www.w3.org/ns/prov#>

CONSTRUCT { ?a cascade:currentlySame ?b }
WHERE {
  { { SELECT ?j (IRI(MIN(STR(?m))) AS ?least)
      WHERE { ?j cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?m }
      GROUP BY ?j }
    MINUS { ?x cascade:currentlyDifferent ?y . ?j prov:hadMember ?x , ?y }
    ?j prov:hadMember ?member .
    FILTER (?member != ?least)
    VALUES ?toLeast { true false }
    BIND (IF(?toLeast, ?member, ?least) AS ?a)
    BIND (IF(?toLeast, ?least, ?member) AS ?b) }
  UNION
  { { SELECT DISTINCT ?j
      WHERE {
        ?x cascade:currentlyDifferent ?y .
        ?j cascade:countsUnderLens true ; cascade:verdict cascade:Same ; prov:hadMember ?x , ?y } }
    ?j prov:hadMember ?a , ?b .
    FILTER (?a != ?b)
    FILTER NOT EXISTS { ?a cascade:currentlyDifferent ?b } }
}

Terms it reads

cascade:Same · cascade:countsUnderLens · cascade:currentlyDifferent · cascade:currentlySame · cascade:verdict · prov:hadMember

Rules and decision notes that name it

No rule or decision note writes its path.

queries/derivations/same-pairs.rq on GitHub ↗