;;; -*- Mode: LISP; Package: GTRE-EXAMPLE; Syntax: Common-lisp; -*-
;;;
;;; *******************************************************
;;;
;;; PORTABLE AI LAB - EPFL
;;;
;;; *******************************************************
;;;
;;; Filename:   safe-to-stack-ex.cl
;;; Short Desc: Simple example for jtms
;;; Version:    1.0
;;; Status:     experimental
;;; Last Mod:   19.12.91 - Fatma FEKIH-AHMED
;;; Author:     Dean ALLEMANG & 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 ((safe-to-stack (make-instance 'tre-example
		     ;;rules in JTRE syntax
		       :rule-set '((rule ((:in (volume ?p1 ?vol1) :var ?V1)
					  (:in (density ?p1 ?d1) :var ?V2))
					 (rassert! (weight ?p1 (:lisp (* ?vol1 ?d1))) (just ?V1 ?V2)))
				     
				   (rule ((:in (weight ?p1 ?w1) :var ?V3)
					  (:in (weight ?p2 ?w2) :var ?V4 :test (< ?w1 ?w2)))
				    (rassert! (lighter ?p1 ?p2) (just ?V3 ?V4)))
				     
				   (rule ((:in (isa ?p1 table) :var ?V6))
				    (rassert! (weight ?p1 5) (just ?V6)))
				     
				   (rule ((:in (lighter ?p1 ?p2) :var ?V7))
				    (rassert! (safe-to-stack ?p1 ?p2) (just ?V7))))
		     
		     ;; assertions in NMJTRE syntax
		     :assertions '((assert! '(density book 4))
				   (assert! '(volume book 1))
				   (assert! '(isa this-table table)))
		     
		     :contradiction '())))

  (pail-lib::put-pool pail-lib:*pail-pool* safe-to-stack :name "SAFE-TO-STACK"))



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

