# Auto-generated AIR exclusion policy.

@prefix air: <http://dig.csail.mit.edu/TAMI/2007/amord/air#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix s: <http://dig.csail.mit.edu/2009/IARPA-PIR/sparql#>.
@prefix : <>.

# User-defined namespaces:
@prefix example: <http://www.example.com/#> .

@forAll :P, :Q, :T, :U, :V, :W.
@forAll :T0, :U0, :V0. # Variables for example:name
@forAll :T1, :U1, :V1. # Variables for example:age
@forAll :T2, :U2, :V2. # Variables for example:dob
@forAll :T3, :U3, :V3. # Variables for example:ssn

:sample-exclusion a air:Policy;
    air:label "A sample auto-generated exclusion policy.";
    air:rule :sample-exclusion-check.
        
:sample-exclusion-check a air:BeliefRule;
    air:label "sample-exclusion query check";
    air:pattern {
        :Q a s:SPARQLQuery;
           s:retrieve :P;
           s:clause :W.
    };
    air:description ("Make sure this is a query.");
    # Goes to the first rule. If there are no attributes,
    # simply go to the default rule.
    air:rule :sample-exclusion-noncompliance-rule.

:sample-exclusion-noncompliance-rule a air:BeliefRule;
    air:label "sample-exclusion, a default deny policy.";
    air:pattern {
        # Catch RETRIEVE
        :P s:var :V0.
        :W s:triplePattern :T0.
        :T0 log:includes { [] example:name :V0 } .
        # Catch USE
        :W s:triplePattern :T1.
        :T1 log:includes { [] example:age :V1 }.
        :W s:triplePattern :U1.
        :U1 log:includes { :V1 [] [] } .
        # Catch RETRIEVE
        :P s:var :V2.
        :W s:triplePattern :T2.
        :T2 log:includes { [] example:dob :V2 } .
        # Catch USE
        :W s:triplePattern :T3.
        :T3 log:includes { [] example:ssn :V3 }.
        :W s:triplePattern :U3.
        :U3 log:includes { :V3 [] [] } .
        };
    air:description ("You may see up to 3 of 4 of these attributes: example:name example:age example:dob example:ssn . This query is incompliant: " :Q ) ;
    air:assert{ :Q air:non-compliant-with :sample-exclusion } ;
    # No more policies, go to the base case.
    air:alt [ air:rule :sample-exclusion-default ] .


:sample-exclusion-default a air:BeliefRule;
    air:label "sample-exclusion default rule";
    air:pattern { # Empty search.
        };
    air:description ("No regulated attributes found. Asserting compliance.");
    air:assert{ :Q air:compliant-with :sample-exclusion } .
        
#ends
