#|
                      A Representation of TIME 


There has been considerable research on "theories of time", and it 
is not our goal here to contribute to that enterprise.  Our goals 
are modest: to draw from past research an ontology for describing 
temporal entities, and to set the stage for encoding, in the future, 
a set of axioms that manipulate statements expressed in that
ontology.

We define a "temporal entity" as an event (such as dining) or a 
situation (such as the 20th Century).  (Please see the "KM Situations 
Manual" for a detailed description of events and situations.)  

Objects, such as people, are not temporal entities.  However, they
have a time-of-existence property which is a temporal entity, in 
particular, a Situation.

We use James Allen's original set of temporal relations (e.g. before,
during, ...) to express the connections between temporal entities.
IKB extends Allen's set in some useful ways, so we might want to 
incorporate some of those relations, too.

This file is in four parts:
  1) specification of temporal entities and temporal relations in KM
  2) two examples of axioms for temporal reasoning, encoded in KM
  3) an example of using the proposed ontology to represent some
     information about Leonardo di Vinci, encoded in KM
  4) some sample queries that KM can answer given this information
|#

;;; =================================================================
;;; Part I: specification of temporal entities and temporal relations 
;;;         in KM
;;; Events and Situations are Temporal-entity's; They are described with
;;; temporal relations, such as before, after, during, and so on.

(Temporal-entity has 
		 (superclasses (Thing))
		 (subclasses (Event Situation)))

(every Object has
       (time-of-existence ((a Situation with 
			      (start ((the created-by of Self)))
			      (end ((the destroyed-by of Self)))))))

(time-of-existence has
		   (instance-of (Slot))
		   (domain (Object))
		   (range (Situation))
		   (cardinality (N-to-1))
		   (fluent-status (*Non-Fluent))
		   (inverse (time-of-existence-of)))

(before has
	(instance-of (Slot))
	(domain (Temporal-entity))
	(range (Temporal-entity))
	(cardinality (N-to-N))
	(fluent-status (*Non-Fluent))
	(inverse (after)))

(after has
       (instance-of (Slot))
       (domain (Temporal-entity))
       (range (Temporal-entity))
       (cardinality (N-to-N))
       (fluent-status (*Non-Fluent))
       (inverse (before)))

(during has
	(instance-of (Slot))
	(domain (Temporal-entity))
	(range (Temporal-entity))
	(cardinality (N-to-N))
	(fluent-status (*Non-Fluent))
	(inverse (during-of)))

(temporally-contains has
		     (instance-of (Slot))
		     (domain (Temporal-entity))
		     (range (Temporal-entity))
		     (cardinality (N-to-N))
		     (fluent-status (*Non-Fluent))
		     (inverse (temporally-contained-by)))

(temporally-overlaps has
		     (instance-of (Slot))
		     (domain (Temporal-entity))
		     (range (Temporal-entity))
		     (cardinality (N-to-N))
		     (fluent-status (*Non-Fluent))
		     (inverse (temporally-overlapped-by)))

(temporally-meets has
		  (instance-of (Slot))
		  (domain (Temporal-entity))
		  (range (Temporal-entity))
		  (cardinality (N-to-N))
		  (fluent-status (*Non-Fluent))
		  (inverse (temporally-met-by)))

(temporally-starts has
		   (instance-of (Slot))
		   (domain (Temporal-entity))
		   (range (Temporal-entity))
		   (cardinality (N-to-N))
		   (fluent-status (*Non-Fluent))
		   (inverse (temporally-started-by)))

(temporally-finishes has
		     (instance-of (Slot))
		     (domain (Temporal-entity))
		     (range (Temporal-entity))
		     (cardinality (N-to-N))
		     (fluent-status (*Non-Fluent))
		     (inverse (temporally-finished-by)))

;;; add definitions for the other temporal relations, too ...

;;; ====================================================================
;;; Part 2: two examples of axioms for temporal reasoning, encoded in KM

;;; 1. the time-of-existence of an Object overlaps the situations during
;;;    which the object plays a role in events.  (The code for this rule
;;;    needs to be generalized to include all the case roles, not just 
;;;    agent-of.)
(every Object has 
       (time-of-existence ((a Situation with 
			      (temporally-overlaps 
			       ((forall (the agent-of of Self) 
					(the situationDuring of It))))))))

;;; 2. if a situation, S, includes an event, E, 
;;;    then the situationDuring of E is a Situation S2 such that
;;;    S is a supersituation of S2.

(every Situation has
       (includes-event ((must-be-a Event with
				   (situationDuring
				    ((must-be-a Situation with
						(supersituations (Self)))))
				   ))))


;;; ===================================================================
;;; Part 3: an example of using the proposed ontology to represent some
;;;         information about Leonardo di Vinci, encoded in KM
;;; This example includes objects (Leonardo), situations
;;; (Life-of-Leonardo), and events (Create-Statue-of-David).

(Person has (superclasses (Object)))

(Leonardo has 
	  (instance-of (Person))
	  (time-of-existence (Life-of-Leonardo))
	  (agent-of (Create-Statue-of-David)))

(Life-of-Leonardo has
		  (instance-of (Situation))
		  (supersituations (Renaissance))
		  (start (Year1452))
		  (includes-event (Create-Statue-of-David))
		  (end (Year1519)))

(subsituations has
	       (instance-of (Slot))
	       (domain (Temporal-entity))
	       (range (Temporal-entity))
	       (cardinality (N-to-N))
	       (fluent-status (*Non-Fluent))
	       (inverse (supersituations)))

(includes-event has
		(instance-of (Slot))
		(domain (Situation))
		(range (Event))
		(cardinality (N-to-N))
		(fluent-status (*Non-Fluent))
		(inverse (included-in-situation)))

(Create-Statue-of-David has
			(instance-of (Create))
			(included-in-situation (Life-of-Leonardo))
			(situationDuring (Leonardo-while-creating-David))
			(before-situation ((:args (a Situation) 
						  (a Situation))))
			(agent (Leonardo))
			(object (Statue-of-David)))
 
(Leonardo-while-creating-David has
			       (instance-of (Situation)))

(Renaissance has 
	     (instance-of (Situation))
	     (start ((the end of Dark-Age)))  ; need to relate start and end 
	     (end ((the start of Modern-Age))); to prev-situation and next-sitn
	     (subsituations (Life-of-Leonardo          ; a Situation
			     Create-Calculus           ; an Event
			)))

(Create-Calculus has
		 (instance-of (Create))
		 (object (Calculus))
		 (agent (Newton Leibnitz))            ; is a set of values OK?
		 (start (Year1684)))

(Dark-Age has 
	  (instance-of (Situation)))
(Modern-Age has
	    (instance-of (Situation)))

(in-situation Renaissance 
	      (every Person has
		     (intellect (*high))))

(Create has (superclasses (Event)))
(every Create has
       (agent ((a Person))) 
       (object ((a Object)))
       (situationBefore ((a Situation with
			    (assertions 
			     ('((the agent of Self)
				has 
				(feelings (excited))))))))
       (situationDuring ((a Situation with
			    (assertions 
			     ('((the agent of Self)
				has 
				(feelings (scared))))))))
       (situationAfter ((a Situation with 
			   (assertions
			    ('((the agent of Self) 
			       has
			       (proud-of ((the object of Self)))))))))
       (pcs-list ((:triple (Self object) existence *Hypothetical)))
       (del-list ((:triple (Self object) existence *Hypothetical)))
       (add-list ((:triple (Self object) existence *Physical))))

(feelings has 
	  (instance-of (Slot))
	  (domain (Person))
	  (range (Emotion))
	  (fluent-status (*Fluent))
	  (situation-specific (t))
	  (cardinality (N-to-N)))

;; some low-level access functions...
(situationBefore has 
		 (instance-of (Slot))
		 (domain (Event))
		 (range (Situation))
		 (cardinality (N-to-1))
		 (inverse (situationBefore-of)))
(every Event has
       (situationBefore ((the1 before-situation of Self)))
       (situationAfter ((the2 after-situation of Self))))


(in-situation (the situationBefore of Create-Statue-of-David)
	      (do Create-Statue-of-David))

;;; =====================================================================
;;; Part 4: some sample queries that KM can answer given this information
#|
;; Main event - Create-Statue-of-David
KM> (showme Create-Statue-of-David)
(Create-Statue-of-David has 
  (agent (Leonardo))
  (includes-event-of (Life-of-Leonardo))
  (instance-of (Create))
  (included-in-situation (Life-of-Leonardo))
  (situationDuring (Leonardo-while-creating-David))
  (before-situation ((:args _Situation85 _Situation86)))
  (object (Statue-of-David))
  (after-situation (((:args _Situation86 _Situation85) & (:args _Situation86 _Situation85))))
  (situationBefore (_Situation85))
  (pcs-list ((:triple Statue-of-David existence *Hypothetical)))
  (add-list ((:triple Statue-of-David existence *Physical)))
  (del-list ((:triple Statue-of-David existence *Hypothetical))))

(in-situation _Situation85
  (Create-Statue-of-David has 
    (agent (Leonardo))
    (object (Statue-of-David))))

(Create-Statue-of-David)

;; What was Leonardo feeling before Create-Statue-of-David?
KM> (in-situation (the situationBefore of Create-Statue-of-David)
                  (the feelings of Leonardo))
(excited)

;; What was Leonardo feeling during Create-Statue-of-David?
KM> (in-situation (the situationDuring of Create-Statue-of-David)
                  (the feelings of Leonardo))
(scared)

;; What was Leonardo proud of afterwards?
KM> (in-situation (the situationAfter of Create-Statue-of-David)
                  (the proud-of of Leonardo))
(Statue-of-David)

;; Leonardo's not smart in the *global situation
KM> (the intellect of Leonardo)
NIL

;;but during his life,...
KM> (in-situation Life-of-Leonardo (the intellect of Leonardo))
(*high)

;; the Statue-of-David doesn't exist in the *global situation
KM> (in-situation Life-of-Leonardo (the existence of Statue-of-David))
NIL

;; the Statue-of-David has hypothetical existence before it was created
KM> (in-situation (the situationBefore of Create-Statue-of-David)
                  (the existence of Statue-of-David))
(*Hypothetical)

;; Does there exist a situation when it has physical existence?
KM> (oneof (the instances of Situation)
            where (in-situation It  
                   ((the existence of Statue-of-David) = *Physical)))
(_Situation86)

;; what action (applied to which situation) is responsible for it?
KM> (the prev-situation of _Situation86)
((:args _Situation89 Create-Statue-of-David))

|#