# $Date: 2009-10-17 23:26:13 -0400 (Sat, 17 Oct 2009) $
# $Revision: 27513 $
# $Author: lkagal $

#  The user may not query specifically for people living in New England.

@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

@prefix math: <http://www.w3.org/2000/10/swap/math#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
@prefix air: <http://dig.csail.mit.edu/TAMI/2007/amord/air#> .
@prefix db: <http://dig.csail.mit.edu/2009/IARPA-PIR/usecase2/db#> .
@prefix s: <http://dig.csail.mit.edu/2009/IARPA-PIR/sparql#> .
@prefix : <http://dig.csail.mit.edu/2009/IARPA-PIR/usecase2/ne-policy#> .

@forAll :QUERY, :PLIST, :WHERE, :VAR, :TRIPLE.
@forAll :X, :LOCATION, :L, :S, :IN.

:NE_Policy a air:Policy;
    air:label "New England policy for IARPA PIR project: The user may not query specifically for people living in New England";
    air:rule :NE_RULE1.

:NE_RULE1 a air:BeliefRule;
       air:label "NE policy rule1";
       air:pattern {
               :QUERY a s:SPARQLQuery;
        	  s:POSList :PLIST;
           	  s:WhereClause :WHERE.
       };
        air:description (:QUERY " is a SPARQL query");
        air:rule :NE_RULE2.
 	#air:assert { :QUERY air:non-compliant-with :NE_Policy }.

:NE_RULE2 a air:BeliefRule;
       air:label "NE policy rule2";
       air:pattern {
             :WHERE s:TriplePattern :TRIPLE.
             :TRIPLE log:includes { :X :L :LOCATION }.
             #:L list:in db:lives-attributes. 
             :L list:in (db:state db:szipcode db:city db:address). 
        };
        air:description (:QUERY " contains lives-in attribute " :L " with value " :LOCATION);
 	#air:assert { :QUERY air:non-compliant-with :NE_Policy }.
	air:rule :NE_RULE3;
	air:alt[
            air:description (:QUERY " does not contain lives-in attribute ");
            air:assert{:QUERY air:compliant-with :NE_Policy }].

:NE_RULE3 a air:BeliefRule;
       air:label "NE policy rule3";
       air:pattern {
              :LOCATION db:in db:NewEngland
        };
        air:description ( "The user is filtering on ":L " with value set to " :LOCATION ", which is in New England ");
        air:rule [ air:pattern {}; 
                   air:description ( "The user may not query specifically for people living in New England" );
                   air:assert { :QUERY air:non-compliant-with :NE_Policy }
        ];
	air:alt[
          air:description ( "The user is not querying specifically for people living in New England" );
          air:assert{:QUERY air:compliant-with :NE_Policy }].


@forAll :LS, :A, :B.
{ <http://dig.csail.mit.edu/2009/IARPA-PIR/usecase2/db.n3> log:semantics :LS.
   :LS log:includes {:A db:in :B}
} => { :A db:in :B }.

@forAll :F, :G, :C.
{ :F db:in :G.
  :G db:in :C
} => { :F db:in :C }.


#ends
