PREFIX dpv: <https://w3id.org/dpv#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX pol: <http://example.org/ns/pol/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX odrl: <http://www.w3.org/ns/odrl/2/>
PREFIX sign: <https://example.org/signature#>
PREFIX ca: <https://w3id.org/context-associations#>
PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX list: <http://www.w3.org/2000/10/swap/list#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>

CONSTRUCT {
    ?person rdf:type foaf:Person.
    ?person foaf:age ?age.
} WHERE {
    ?dataCollection rdf:type ca:Collection;
        ca:contains
            <<?person rdf:type foaf:Person>>,
            <<?person foaf:age ?age>>.

    ?age math:notLessThan 18.

    ?policyCollection rdf:type ca:Collection;
        ca:contains
            <<?permission odrl:assigner ?person>>,
            <<?permission odrl:target ?dataCollection>>,
            <<?agreement rdf:type odrl:Agreement>>,
            <<?agreement odrl:permission ?permission>>,
            <<?permission odrl:action odrl:use>>,
            <<?permission odrl:constraint ?constraint>>,
            <<?constraint odrl:leftOperand <https://w3id.org/oac#Purpose>>>,
            <<?constraint odrl:operator odrl:eq >>,
            <<?constraint odrl:rightOperand ?purpose>>.

    ?purpose list:in (dpv:Personalisation dpv:ServiceProvision).

    ?dataSignatureCollection rdf:type ca:Collection;
        ca:contains
            <<?dataSignature sign:target ?dataCollection>>,
            <<?dataSignature rdf:type sign:DataIntegrityProof>>,
            <<?dataSignature sign:issuer ?dataSignatureIssuer>>.

    ?dataSignatureIssuer log:equalTo <https://overheid.be/ca>.

    ?policySignatureCollection rdf:type ca:Collection;
        ca:contains
            <<?policySignature sign:issuer ?person>>,
            <<?policySignature sign:target ?policyCollection>>,
            <<?policySignature rdf:type sign:DataIntegrityProof>>.
}
