<https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/#select-children>
        a       <https://w3id.org/atomgraph/linkeddatahub#Content> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
                <https://w3id.org/atomgraph/linkeddatahub#SelectChildren> .

<https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/>
        a       <https://www.w3.org/ns/ldt/document-hierarchy#Container> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
                <https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/#this> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_999>
                <https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/#select-children> ;
        <http://purl.org/dc/terms/modified>
                "2023-07-10T15:53:49.011Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        <http://purl.org/dc/terms/title>
                "SPARQL Algebra" ;
        <http://rdfs.org/sioc/ns#has_parent>
                <https://kgdev.net/specifications/sparql11-query/sparqlDefinition/> ;
        <http://www.w3.org/ns/prov#wasDerivedFrom>
                <https://www.w3.org/TR/sparql11-query/#sparqlAlgebra> ;
        <http://xmlns.com/foaf/0.1/primaryTopic>
                <https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/#this> .

<https://kgdev.net/specifications/sparql11-query/sparqlDefinition/sparqlAlgebra/#this>
        a                          <https://kgdev.net/ns#Definition> , <https://w3id.org/atomgraph/linkeddatahub#Content> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#value>
                "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h3 id=\"this\">SPARQL Algebra</h3>\n\n<p>For each remaining symbol in a SPARQL abstract query, we define an operator for evaluation. The SPARQL algebra operators of the same name are used to evaluate SPARQL abstract query nodes as described in the section \"<a href=\"../#sparqlAlgebraEval\" shape=\"rect\">Evaluation Semantics</a>\". Evaluation of basic graph patterns and property path patterns has been described above.</p>\n<p><strong>Definition: Filter</strong></p>\n<p>Let Ω be a multiset of solution mappings and expr be an expression. We define:</p>\n<p>Filter(expr, Ω, D(G)) = { μ | μ in Ω and expr(μ) is an expression that has an effective boolean value of true }</p>\n<p>card<a href=\"μ\" shape=\"rect\">Filter(expr, Ω, D(G))</a> = card<a href=\"μ\" shape=\"rect\">Ω</a></p>\n<blockquote>\n<p>Note that evaluating an <code>exists(pattern)</code>\nexpression uses the dataset and active graph, D(G). See the\n<a href=\"../#defn_evalFilter\" shape=\"rect\">evaluation of filter</a>.</p>\n</blockquote>\n<p><strong>Definition: Join</strong></p>\n<p>Let Ω1 and Ω2 be multisets of solution mappings. We define:</p>\n<p>Join(Ω1, Ω2) = { merge(μ1, μ2) | μ1 in Ω1and μ2 in Ω2, and μ1 and μ2 are compatible }</p>\n<p>card<a href=\"μ\" shape=\"rect\">Join(Ω1, Ω2)</a> =<br clear=\"none\"></br>\n     for each merge(μ1, μ2), μ1 in Ω1and μ2 in Ω2 such that μ = merge(μ1, μ2),<br clear=\"none\"></br>\n         sum over (μ1, μ2), card<a href=\"μ1\" shape=\"rect\">Ω1</a>*card<a href=\"μ2\" shape=\"rect\">Ω2</a></p>\n<p>It is possible that a solution mapping μ in a Join can arise in different solution mappings, μ1and μ2 in the multisets being joined. The cardinality of  μ is the sum of the cardinalities from all possibilities.</p>\n<p><strong>Definition: Diff</strong></p>\n<p>Let Ω1 and Ω2 be multisets of solution mappings and expr be an expression. We define:</p>\n<p>Diff(Ω1, Ω2, expr) = { μ | μ in Ω1 such that ∀ μ′ in Ω2, either μ and μ′ are not compatible or μ and μ' are compatible and expr(merge(μ, μ')) has an effective boolean value of false }</p>\n<p>card<a href=\"μ\" shape=\"rect\">Diff(Ω1, Ω2, expr)</a> = card<a href=\"μ\" shape=\"rect\">Ω1</a></p>\n<p>Diff is used internally for the definition of LeftJoin.</p>\n<p><strong>Definition: LeftJoin</strong></p>\n<p>Let Ω1 and Ω2 be multisets of solution mappings and expr be an expression. We define:</p>\n<p>LeftJoin(Ω1, Ω2, expr) = Filter(expr, Join(Ω1, Ω2)) ∪ Diff(Ω1, Ω2, expr)</p>\n<p>card<a href=\"μ\" shape=\"rect\">LeftJoin(Ω1, Ω2, expr)</a> = card<a href=\"μ\" shape=\"rect\">Filter(expr, Join(Ω1, Ω2))</a> + card<a href=\"μ\" shape=\"rect\">Diff(Ω1, Ω2, expr)</a></p>\n<p>Written in full that is:</p>\n<p>LeftJoin(Ω1, Ω2, expr) =<br clear=\"none\"></br>\n     { merge(μ1, μ2) | μ1 in Ω1 and μ2 in Ω2, μ1 and μ2 are compatible and expr(merge(μ1, μ2)) is true }<br clear=\"none\"></br>\n ∪<br clear=\"none\"></br>\n     { μ1 | μ1 in Ω1, ∀ μ2 in Ω2, μ1 and μ2 are not compatible, or Ω2 is empty }<br clear=\"none\"></br>\n ∪<br clear=\"none\"></br>\n     { μ1 | μ1 in Ω1, ∃ μ2 in Ω2, μ1 and μ2 are compatible and expr(merge(μ1, μ2)) is false. }</p>\n<p>As these are distinct, the cardinality of LeftJoin is cardinality of these individual components of the definition.</p>\n<p><strong>Definition: Union</strong></p>\n<p>Let Ω1 and Ω2 be multisets of solution mappings. We define:</p>\n<p>Union(Ω1, Ω2) = { μ | μ in Ω1 or μ in Ω2 }</p>\n<p>card<a href=\"μ\" shape=\"rect\">Union(Ω1, Ω2)</a> = card<a href=\"μ\" shape=\"rect\">Ω1</a> + card<a href=\"μ\" shape=\"rect\">Ω2</a></p>\n<p><strong>Definition: Minus</strong></p>\n<p>Let Ω1 and Ω2 be multisets of solution mappings. We define:</p>\n<p>Minus(Ω1, Ω2) = { μ | μ in Ω1 . ∀ μ' in Ω2, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint }</p>\n<p>card<a href=\"μ\" shape=\"rect\">Minus(Ω1, Ω2)</a> = card<a href=\"μ\" shape=\"rect\">Ω1</a></p>\n<p>The additional restriction on dom(μ) and dom(μ') is added because otherwise if there is a solution mapping in Ω2 that has no variables in common with the solution mappings of Ω1, then Minus(Ω1, Ω2) would be empty, regardless of the rest of Ω2. The empty solution mapping is compatible with every other solution mapping so <code>P MINUS {}</code> would otherwise be empty for any pattern <code>P</code>.</p>\n<p><strong>Definition: Extend</strong>Let μ be a solution mapping, Ω a multiset of solution mappings, <em>var</em> a variable and <em>expr</em> be an <a href=\"../../expressions/#this\" shape=\"rect\">expression</a>, then we define:</p>\n<p>Extend(μ, var, expr) = μ ∪ { (var,value) | var not in dom(μ) and value = expr(μ) }</p>\n<p>Extend(μ, var, expr) = μ if var not in dom(μ) and expr(μ) is an error</p>\n<p>Extend is undefined when var in dom(μ).</p>\n<p>Extend(Ω, var, expr) = { Extend(μ, var, expr) | μ in Ω }</p>\n<p>Write [ x | C ] for a sequence of elements where C is a condition on x.</p>\n<p>Write card<a href=\"x\" shape=\"rect\">L</a> to be the cardinality of x in L.</p>\n<p><strong>Definition: ToList</strong>Let Ω be a multiset of solution mappings. We define:</p>\n<p>ToList(Ω) = a sequence of mappings μ in Ω in any order, with card<a href=\"μ\" shape=\"rect\">Ω</a> occurrences of μ</p>\n<p>card<a href=\"μ\" shape=\"rect\">ToList(Ω)</a> = card<a href=\"μ\" shape=\"rect\">Ω</a></p>\n<p><strong>Definition: OrderBy</strong>Let Ψ be a sequence of solution mappings. We define:</p>\n<p>OrderBy(Ψ, condition) = [ μ | μ in Ψ and the sequence satisfies the ordering condition]</p>\n<p>card<a href=\"μ\" shape=\"rect\">OrderBy(Ψ, condition)</a> = card<a href=\"μ\" shape=\"rect\">Ψ</a></p>\n<p><strong>Definition: Project</strong>Let Ψ be a sequence of solution mappings and PV a set of variables.</p>\n<p>For mapping μ, write Proj(μ, PV) to be the restriction of μ to variables in PV.</p>\n<p>Project(Ψ, PV) = [ Proj(Ψ[μ], PV) | μ in Ψ ]</p>\n<p>card<a href=\"μ\" shape=\"rect\">Project(Ψ, PV)</a> = card<a href=\"μ\" shape=\"rect\">Ψ</a></p>\n<p>The order of Project(Ψ, PV) must preserve any ordering given by OrderBy.</p>\n<p><strong>Definition: Distinct</strong>Let Ψ be a sequence of solution mappings. We define:</p>\n<p>Distinct(Ψ) = [ μ | μ in Ψ ]</p>\n<p>card<a href=\"μ\" shape=\"rect\">Distinct(Ψ)</a> = 1</p>\n<p>The order of Distinct(Ψ) must preserve any ordering given by OrderBy.</p>\n<p><strong>Definition: Reduced</strong>Let Ψ be a sequence of solution mappings. We define:</p>\n<p>Reduced(Ψ) = [ μ | μ in Ψ ]</p>\n<p>card<a href=\"μ\" shape=\"rect\">Reduced(Ψ)</a> is between 1 and card<a href=\"μ\" shape=\"rect\">Ψ</a></p>\n<p>The order of Reduced(Ψ) must preserve any ordering given by OrderBy.</p>\n<p>The Reduced solution sequence modifier does not guarantee a defined cardinality.</p>\n<p><strong>Definition: Slice</strong>Let Ψ be a sequence of solution mappings. We define:</p>\n<p>Slice(Ψ, start, length)[i] = Ψ[start+i] for i = 0 to (length-1)</p>\n<p><strong>Definition: ToMultiSet</strong>Let Ψ be a solution sequence. We define:</p>\n<p>ToMultiSet(Ψ) = { μ | μ in Ψ }</p>\n<p>card<a href=\"μ\" shape=\"rect\">ToMultiSet(Ψ)</a> = card<a href=\"μ\" shape=\"rect\">Ψ</a></p>\n<p>ListEval is a function which is used to evaluate a list of expressions against a solution and return a list of the resulting values.</p>\n<p><strong>Definition: ToMultiset</strong></p>\n<p>ToMultiset turns a sequence into a multiset with the same elements and cardinality as the sequence. The order of the sequence has no effect on the resulting multiset, and duplicates are preserved.</p>\n<p><strong>Definition: Exists</strong></p>\n<p>exists(pattern) is a function that returns true if the pattern <a href=\"../#defn_evalExists\" shape=\"rect\">evaluates</a> to a non-empty solution sequence, given the current solution mapping and active graph at the time of evaluation; otherwise it returns false.</p></div>"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> ;
        <http://www.w3.org/ns/prov#wasDerivedFrom>
                <https://www.w3.org/TR/sparql11-query/#sparqlAlgebra> ;
        <https://schema.org/name>  "SPARQL Algebra" .
