     @prefix : <http://www.w3.org/2002/05/matrix/vocab#> .
     @prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix rec: <http://www.w3.org/2001/02pd/rec54#>.
@prefix :<detect-missing#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rsb:<rec-shouldbe#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix mat: <http://www.w3.org/2002/05/matrix/vocab#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix time: <http://www.w3.org/2000/10/swap/time#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.

<detect-missing.n3>      dc:title "Rules detecting faulty documents on the Rec Track";
        dc:description """Set of rules detecting Rec track documents which doesn't match expectations as described in rec-shouldbe.n3, and that were published less than 6 months ago
        Run it as cwm detect-missing.n3 --think --purge-rules
""";
         rdfs:seeAlso <rec-shouldbe>.

this log:forAll :DOC, :PROP, :STATUS, :DATE, :REQ, :MISS.

:RequirementProperty is rdf:type of rsb:requires, rsb:suggests.
:misses :matches rsb:requires.
:shouldHave :matches rsb:suggests.

{
 <../../TheMatrix.rdf> log:semantics [
        log:includes { 
                :DOC a mat:Work; a :STATUS ; dc:date :DATE
        }; log:notIncludes {
                :DOC :PROP []
        }; log:notIncludes {
                :DOC a mat:Informative
        }
   ].
  <known-missing.n3> log:semantics [
        log:notIncludes {
                :DOC :shouldHave :PROP.
        }; log:notIncludes {
                :DOC :misses :PROP.
        }
 ].
  <rec-shouldbe.n3> log:semantics [
        log:includes {
                  :STATUS a rec:TRPub; :REQ :PROP
        }
 ].
 :REQ a :RequirementProperty; is :matches of :MISS.
# Was the document published less than 6 months ago?
 #converting iso date in seconds for proper math comparison
 [ is time:inSeconds of  :DATE ]
   math:greaterThan 
 [ is math:difference of ( 
   # current time in seconds
   [ is time:inSeconds of [is time:localTime of "" ] ] 
    # 15552000 is the # of seconds in 6*30 days
    "15552000")
 ].
} log:implies {
  :DOC :MISS :PROP.
}.

