;;; -*- Mode: LISP; Package: GTRE-EXAMPLE; Syntax: Common-lisp; -*-
;;;
;;; *******************************************************
;;;
;;; PORTABLE AI LAB - EPFL
;;;
;;; *******************************************************
;;;
;;; Filename:   right-trains-ex.cl
;;; Short Desc: Simple example to show that temporal features 
;;;             are not straightforward using TMS.
;;;             (Please refer to right-trains-ex.cl)
;;; Version:    1.0
;;; Status:     experimental
;;; Last Mod:   10.02.91 - Fatma FEKIH-AHMED
;;; Author:     Fatma FEKIH-AHMED
;;;
;;; Copyright (c) 1992 Istituto Dalle Molle (IDSIA), University of
;;; Zurich, Swiss Federal Institute of Technology Lausanne.
;;;
;;; Permission is granted to any individual or institution to use, copy,
;;; modify, and distribute this software, provided that this complete
;;; copyright and permission notice is maintained, intact, in all
;;; copies and supporting documentation.
;;;
;;; IDSIA provides this software "as is" without express or implied
;;; warranty.  
;;;
;;; =======================================================================
;;; PACKAGE DECLARATIONS
;;; =======================================================================
(in-package :gtre-example)

(import '(pail-lib::tre-example
	  gtre::rule
	  gtre::assert!
	  gtre::rassert!
	  gtre::retract!
	  gtre::rretract!
	  gtre::contradiction
	  gtre::GOD
	  gtre::USER
	  ))

;;; =======================================================================
;;; TMS Example
;;; =======================================================================

(let ((trains (make-instance 'tre-example
		     ;;rules in NMJTRE syntax		    
		     :rule-set '((rule ((:in (possible-arrival ?train ?hour) :var ?J1)
					(:in (free-track ?track ?hour) :var ?J2))
				       (rassert! (effective-arrival ?train ?track ?hour) 
						 (justif (:in ?J1) (:in ?J2))))
				 
				 (rule ((:in (effective-arrival ?train1 ?track ?hour) :var ?J1)
					      (:in (effective-arrival ?train2 ?track ?hour) :var ?J2 
					       :test (neq ?train1 ?train2)))
				  (rassert! contradiction-found (justif (:in ?J1) (:in ?J2)))))
		     
		     ;; assertions in NMJTRE syntax		    
		     :assertions '((assert! '(possible-arrival 1 12))
				   (assert! '(possible-arrival 1 14))
				   
				   (assert! '(possible-arrival 2 12))
				   (assert! '(possible-arrival 2 13))

				   (assert! '(possible-arrival 3 12))
				   
				   (assert! '(free-track 1 12))
				   (assert! '(free-track 1 13))
				   (assert! '(free-track 1 14))
				   
				   (assert! '(free-track 2 12))
				   (assert! '(free-track 2 13))
				   (assert! '(free-track 2 14))
				   )
		     
		     :contradiction '((contradiction 'contradiction-found))

		     :lisp-code '((defun neq (x1 x2)
				    (not (eq x1 x2)))))))
  
  (pail-lib::put-pool pail-lib:*pail-pool* trains :name "RIGHT-TRAINS"))



;;; =======================================================================
;;; END OF FILE
;;; ======================================================================= 
