@prefix dc: <http://purl.org/dc/elements/1.1/>.

<> dc:description """working toward a test query: when can EricM and DanC
get together for a game of pool?""".

@prefix ical: <http://ilrt.org/discovery/2001/06/schemas/ical-full/hybrid.rdf#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix u: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix pa: <http://www.w3.org/2000/08/palm56/addr#> .

@prefix foaf: <http://xmlns.com/foaf/0.1/> .

@prefix nav: <http://www.w3.org/2001/07dc-bos/grokNavItin#> .
@prefix t: <http://www.w3.org/2001/08swws67/travel#>.

@prefix log:  <http://www.w3.org/2000/10/swap/log#> .
@prefix v: <?>.

this log:forAll v:doc, v:who, v:grp, v:where, v:where2,
	v:e, v:e2, v:text, v:name, v:dt, v:whoWhere, v:day.


@prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#> .
@prefix ont:  <http://www.daml.org/2001/03/daml+oil#> .
foaf:mbox  u:subPropertyOf contact:mailbox.
contact:mailbox a ont:UnambiguousProperty.

######
# Borrow from cyc...
@prefix cg: <http://www.cyc.com/cyc-2-1/vocab/group-vocab.html#>.
@prefix ct: <http://www.cyc.com/cyc-2-1/vocab/time-vocab.html#>.
@prefix cs: <http://www.cyc.com/cyc-2-1/vocab/spatial-vocab.html#>.
@prefix cact: <http://www.cyc.com/cyc-2-1/vocab/actor-vocab-complete.html#>.
@prefix ctrans: <http://www.cyc.com/cyc-2-1/vocab/transportation-vocab.html#>.

cact:eventOccursAt u:subPropertyOf ct:temporallyIntersects, cact:actors, cs:inRegion .
cg:groupMembers u:domain cg:Group; cg:range ct:TemporalThing. 


<#EricDanBayArea> cg:groupMembers	[ =<#em>; foaf:name "Eric Miller";
					foaf:mbox <mailto:em@w3.org> ];
	cg:groupMembers		[ =<#DanC>; foaf:name "Dan Connolly";
					foaf:mbox <mailto:connolly@w3.org> ];

	#and no others...
              cg:groupCardinality [ is cg:seriesLength of (<#x> <#y>)];
	#hmmm... haven't said EricM and DanC are distinct.

   cact:eventOccursAt [ t:stateAbbr "CA" ];
   a t:TemporallyContinuous.


# Of course there are many ERIC MILLERs in the world,
# but as of this excercise, only one who uses
# the navigant itinerary stuff.
# Hmm... perhaps I could add a command-line option
# to grokNavItin.pl to ground the user
# in URI space (email address, homepage, ...)
{ v:doc nav:for v:who.
  v:who pa:name "MILLER"; pa:firstName "ERIC" }
  log:implies { v:who = <#em> }.

{ v:doc nav:for v:who.
  v:who pa:name "CONNOLLY"; pa:firstName "DANIEL" }
  log:implies { v:who = <#DanC> }.


## kludge to convert between yyyy-mm-dd and yyyymmdd
<#jul30> a ct:CalendarDay;
  t:yyyymmdd "20010730";
  t:yyyy_mm_dd "2001-07-30".
<#jul31> a ct:CalendarDay;
  t:yyyymmdd "20010731";
  t:yyyy_mm_dd "2001-07-31".
<#aug1> a ct:CalendarDay;
  t:yyyymmdd "20010801";
  t:yyyy_mm_dd "2001-08-01".
<#aug2> a ct:CalendarDay;
  t:yyyymmdd "20010802";
  t:yyyy_mm_dd "2001-08-02".



ical:ATTENDEE u:subPropertyOf cact:actors.

# associate events with calendar days.
# @@ignore timezones
{
  v:e ical:DTSTART [ rdf:value v:d1 ].
  v:day t:yyyymmdd v:d2.
  v:d1 log:startsWith v:d2.
}
  log:implies { v:day ct:temporallySubsumes v:e }.


# grp is continuous...
this log:forAll v:d1, v:d2, v:d3.
{
  ct:CalendarDay is rdf:type of v:d1, v:d2, v:d3.

  v:grp a t:TemporallyContinuous; ct:temporallyIntersects v:d1, v:d2.
  v:d3 t:yyyy_mm_dd [ log:greaterThan [ is t:yyyy_mm_dd of v:d1 ];
		      log:lessThan    [ is t:yyyy_mm_dd of v:d2 ]; ].
}
  log:implies { v:grp ct:temporallyIntersects v:d3 }.


## an event involving ?who located ?where
# includes the whole day when ?who arrives ?where....
# Hmm... this assumes the event is temporally subsumed by the itinerary?
{ v:e cg:groupMembers v:who; cs:inRegion v:where.
  v:itin nav:for v:who; nav:air v:e2.
  v:e2 ctrans:toLocation v:where2.
  v:where2 cs:inRegion v:where.
  v:e2 ct:endingDate v:day.
 }
log:implies
 { v:e ct:temporallySubsumes v:day }.

{ v:e cg:groupMembers v:who; cs:inRegion v:where.
  v:itin nav:for v:who; nav:air v:e2.
  v:e2 ctrans:fromLocation v:where2.
  v:where2 cs:inRegion v:where.
  v:e2 ct:startingDate v:day.
 }
log:implies
 { v:e ct:temporallySubsumes v:day. }.


{ v:grp cg:groupMembers v:who;
    ct:temporallyIntersects [ = v:e; cact:actors v:who ].
}
  log:implies
{
  v:grp <#__hasPlans> v:e.
}.


