<> a <http://www.w3.org/2000/10/swap/log#N3Document> .

@prefix dc: <http://purl.org/dc/elements/1.1/>.
<> dc:description """travel request
for WebOnt ftf in Stanford CA""";
  dc:relation <http://www.w3.org/2001/08swws67/>.

@prefix k: <http://opencyc.sourceforge.net/daml/cyc.daml#> .

@prefix r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.

@prefix : <req#>.
@prefix mt: <mit-travel@@#>.
@prefix p: <http://www.w3.org/2000/10/swap/pim/usps#>.
@prefix con: <http://www.w3.org/2000/10/swap/pim/contact#>.
@prefix apt: <http://www.megginson.com/exp/ns/airports#>. #@@hmm...
@prefix dt: <http://www.w3.org/2001/XMLSchema#>.
@prefix w3c: <http://www.w3.org/2001/02pd/rec54#>. #@@update


# excerpt of the calendar...
:SunJun30 a k:Date; dt:date "2002-06-30"; a k:Sunday;
  is k:contiguousAfter of :MonJul1.
:MonJul1 a k:Date; dt:date "2002-07-01"; a k:Monday;
  is k:contiguousAfter of :TueJul2.
:TueJul2 a k:Date; dt:date "2002-07-02"; a k:Tuesday;
  is k:contiguousAfter of :WedJul3.
:WedJul3 a k:Date; dt:date "2002-07-03"; a k:Wednesday.

# from the meeting page
# @@put on w3c calendar of events page
# @@check consistency with WG home page?
_:webontftf3 a w3c:RemoteMeeting;
  k:socialParticipants [ con:mailbox <mailto:www-webont-wg@w3.org>;
	con:homePage <http://www.w3.org/2001/sw/WebOnt/> ];
  is k:containsInformationAbout of <http://www.w3.org/2001/sw/WebOnt/ftf3.html>;
  k:startingDate :MonJul1;
  k:endingDate :TueJul2;
  k:eventOccursAt [ p:cityName "Stanford";
               k:inRegion [ p:stateAbbr "CA" ]].

<> a mt:TravelRequest;
   # :for relates a request to a trip.
   # @@was: to a formula describing
   # a situation where the request is satisfied.
   mt:for
     [ mt:forMeeting _:webontftf3;
     k:passengers _:DanC; # perhaps we could leave this implicit, or get it elsewhere?
     k:origin__RoundTrip :airportMCI; # I'll get myself to the airport
     ];
   mt:preferredAirline :AA.

_:DanC con:fullName "Dan Connolly";
  con:mailbox <mailto:connolly@w3.org>.

@prefix log: <http://www.w3.org/2000/10/swap/log#> .
this log:forAll :TRIP, :MEETING, :OUT, :IN, :START, :END, :WHERE.

# a (normal) trip for a meeting at some place is a round trip to that place.
{ :TRIP mt:forMeeting [ k:eventOccursAt :WHERE ] }
  log:implies {
   :TRIP k:destination__RoundTrip :WHERE }.

# You have to get there before the meeting and leave after.
{ :TRIP mt:forMeeting :MEETING;
     k:outboundLegOfRoundTrip :OUT;
     k:inboundLegOfRoundTrip :IN;
}
 log:implies {
   :MEETING  k:startsAfterEndingOf :OUT.
   :IN k:startsAfterEndingOf :MEETING
 }.


# (normal) meeting trips start the day before the meeting
# and end the day after.
{ :TRIP mt:forMeeting :MEETING.
  :MEETING
    k:startingDate [ k:contiguousAfter :START ];
    k:endingDate [ is k:contiguousAfter of :END ];
}
 log:implies {
  :TRIP k:startingDate :START;
    k:endingDate :END.
 }.




#hmm...
{ :WHO :nearestAirport :WHERE.
  :TRIP a k:Translation__RoundTrip;
    k:passengers :WHO }
  log:implies { :TRIP k:origin__RoundTrip :WHERE }.



:airportMCI a k:Airport__Physical; # Airport__Organization?
 con:homePage <http://www.kcairports.com/kci/default.htm>;
 k:inRegion
 [ p:cityName "Kansas City";
   k:inRegion [ p:stateAbbr "MO" ] ];
 # from http://www.megginson.com/samples/rdf/airports.rdf
 apt:icao "KMCI";
 apt:name "Kansas City, Kansas City International Airport, MO, United States";
 apt:iata "MCI";
 apt:latitude "39-17-50N";
 apt:longitude "094-43-50W";
 apt:elevation "320M".


:DanC con:mailbox <mailto:connolly@w3.org>;
      con:homePage <http://www.w3.org/People/Connolly/>.

:AA a k:AirlineCompany.

@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .

k:Sunday s:label "Sunday".
k:Monday s:label "Monday".
k:Tuesday s:label "Tuesday".
k:Wednesday s:label "Wednesday".


mt:forMeeting s:label "for meeting";
 s:comment """a normal trip for a meeting;
   leaves from nearest airport, gets there
   before the meeting starts, leaves after meeting ends.""";
 s:domain [ s:subClassOf k:Translation__RoundTrip ].


mt:TravelRequest a s:Class;
  s:subClassOf k:Request;
  s:isDefinedBy <http://www.w3.org/Team/Admin/Travelpolicy.html>.


<http://www.w3.org/Team/Admin/Travelpolicy.html>
dc:description """
    *  Destination
    * Dates of Travel
    * Preferred times
    * Preferred airline (not guaranteed)

2. Requests should also include**

    * Hotel (link or email associated with meeting/conference)
    * Conference registration details (conference link)
    * Rental car needs
""".


########


@prefix str: <http://www.w3.org/2000/10/swap/string#> .
this log:forAll :N1, :N2, :N, :WHEN.

{ :WHERE p:cityName :N1;
    k:inRegion [ p:stateAbbr :N2 ].
  (:N1 ", " :N2 ", U.S.A.") str:concatenation :N.
}
 log:implies {
  :WHERE r:value :N
}.

{ :WHEN a [ s:label :N1 ]; dt:date :N2.
  (:N1 ", " :N2) str:concatenation :N.
} log:implies { :WHEN r:value :N }.
