Skip to content
Alpha: see what works today →
Menu

Lens

everyday

The lens decides which judgments count, and is the one step of the build that can be swapped. This one counts a person's judgment not retracted, nor replaced by a judgment not itself retracted. A matcher judgment counts on the same terms when the Cascade matcher made it, every reference version it used is current or has a current version whose rows join its members as its rule reads them (M7), and the current version of a rule list has a row for its rule with the query hash of that rule's row in a version it is asserted under by an assertion no retraction invalidates: its rule runs now the query it was asserted with, and no release declared that assertion wrong. A retracted judgment replaces nothing.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>

CONSTRUCT { ?j cascade:countsUnderLens true }
WHERE {
  { ?j a cascade:Judgment ; prov:wasAttributedTo/a prov:Person .
    FILTER NOT EXISTS {
      ?replacing dct:replaces ?j
      OPTIONAL { ?undoing prov:invalidated ?replacing }
      FILTER (!BOUND(?undoing))
    }
    FILTER NOT EXISTS { ?retraction prov:invalidated ?j } }
  UNION
  { { SELECT DISTINCT ?j
          WHERE {
            { SELECT DISTINCT ?rule ?hash
              WHERE { ?ruleList pav:hasCurrentVersion ?current .
                      ?currentRow cascade:rowOfRuleListVersion ?current ; cascade:matcherRule ?rule ; cascade:queryHash ?hash } }
            ?assertedRow cascade:matcherRule ?rule ; cascade:queryHash ?hash ; cascade:rowOfRuleListVersion ?asserted .
            ?assertion cascade:assertedUnderRuleListVersion ?asserted ; cascade:assertedJudgment ?j .
            FILTER NOT EXISTS { ?assertionRetraction prov:invalidated ?assertion }
            ?j cascade:matcherRule ?rule .
          } }
    ?j a cascade:Judgment ; prov:wasAttributedTo cascade:CascadeMatcher .
    FILTER NOT EXISTS {
      ?replacing dct:replaces ?j
      OPTIONAL { ?undoing prov:invalidated ?replacing }
      FILTER (!BOUND(?undoing))
    }
    FILTER NOT EXISTS { ?retraction prov:invalidated ?j }
    MINUS {
      ?j prov:wasDerivedFrom ?input .
      ?input prov:specializationOf ?series .
      ?series a cascade:ReferenceSeries ; pav:hasCurrentVersion ?now .
      FILTER (?now != ?input)
      FILTER NOT EXISTS { ?j cascade:membersJoinedByCurrentTableVersion ?now }
    } }
}

Terms it reads

cascade:CascadeMatcher · cascade:Judgment · cascade:ReferenceSeries · cascade:assertedJudgment · cascade:assertedUnderRuleListVersion · cascade:countsUnderLens · cascade:matcherRule · cascade:membersJoinedByCurrentTableVersion · cascade:queryHash · cascade:rowOfRuleListVersion · dct:replaces · pav:hasCurrentVersion · prov:Person · prov:invalidated · prov:specializationOf · prov:wasAttributedTo · prov:wasDerivedFrom

Rules and decision notes that name it

queries/lenses/everyday.rq on GitHub ↗