#   Issue tracking - Change of state
#
# Finite state automaton ontology
#

@keywords a, is, of.

@prefix :	<http://www.w3.org/2005/01/wf/flow#>.

@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix doc: <http://www.w3.org/2000/10/swap/pim/doc#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix os: <http://www.w3.org/2000/10/swap/os#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix time: <http://www.w3.org/2000/10/swap/time#> .
@prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#> .
@prefix delta: <http://www.w3.org/2004/delta#> .

@prefix this: <#>.


@forAll  b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z.

# Rules for change

# Context:    1!os:argv^log:uri   is the record to date
#	      2!os:argv^log:uri   is the new information


{ 1!os:argv!os:baseAbsolute is log:uri of  ?x} => { ?x  a this:History }. 
{ 2!os:argv!os:baseAbsolute is log:uri of ?x} => { ?x  a this:News }. 

########## Creation of a new issue:

{  d a this:News.
   d!log:semantics log:includes { d date e}.
} => { d date e }.  # Believe documents about their own dates


# Believe anything about transitions originating in the document

{  d a this:News.
   d!log:semantics log:includes {  x origin d; p v}.
} => { 
	x p v.	
}.


# Generate a URI for the creation event for any new task defined in the file
#
#{  d a this:News.
#   x origin d.
#   d!log:semantics log:includes {  x p v}.
#   (x!log:uri "_creation") string:concatenation y!log:uri. # hack
#} => { 
#	x lastAction y.
#	y a Creation; source d; date e; task x.
#}.


# Transitions inherit final state from class
{ x origin d.  x a [ final s] } => { x final s }.

########## New information about an existing issue:

#  If a newer transaction is received, then it becomes the latest:

{   h a this:History.
    h!log:semantics log:includes {x lastAction y. y  date  d}.
    n a this:News; date e.
  #  t a Transition.
     n!log:semantics log:includes {z task x}.
#	z final t.
#   	e time:greaterThan d.
} => {
	@forAll INIT.
	(h n x d e y z) a RESULT.
	{x state INIT} delta:deletion {
			x lastAction y; state INIT};
		    delta:insertion {
			x lastAction z; state t.
			z previousAction y}.
}.



#ends
