Question about range constraint enforcement

Srini Ram <[email protected]> Mon, 3 Nov 2008 08:10:46 -0800 (PST)
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
Here is an excerpt of some code I have

(deffunction numeric-constant (?name (?n number)) :closed TRUE)
(assert (numeric-constant Max_time_slot 96))

;; Time slot is any number between 1 and 96, inclusive
(defconcept Time_slot (?t number)
    :<=> (AND (>= ?t 1) (=< ?t Max_time_slot))
    :closed TRUE)

  (deffunction some-function ( (?p PERSON) (?t TIME_SLOT) )
    :-> (?v INTEGER) )

* (retrieve  (and (= ?ts 7) (some-function joe ?ts ?v)))

There is 1 solution so far:
  #1: ?TS=7, ?V=3                               ;; ok, ?ts has been coerced to type TIME_SLOT


;; Try a value for timeslot that is out of bounds 
* (retrieve  (and (= ?ts 104) ( some-function joe ?ts ?v))
No solutions.                   --> Did not get a  warning for violation of the range of TIME_SLOT
                                     --> Should not be possible to coerce ?ts to TIME_SLOT therefore.
                                     --> Should get error similar to error below

;; Try direct value that is out-of-range
* (retrieve  (some-function joe 104 ?v)))   
WARNING: Type check violation on argument `104' in proposition
   (= (SOME-FUNCTION joe 104 104) ?v).
   Argument must have type `TIME_SLOT'.                   ;; This is a type error, not a range error
   Warning occurred while parsing the proposition:
   (KAPPA (?V) (SOME-FUNCTION joe 104  ?V))

No solutions.


Please let me know what I am missing in the definition of TIME_SLOT to make sure its range is respected.
I hope I dont have to do the following :-)
(assert (Time_slot 0))
(assert (Time_slot 1))
....
(assert (Time_slot 96))

I think this will be a common use similar to typedefs in other languages...

Thanks
Srini

_______________________________________________
powerloom-forum mailing list
[email protected]
http://mailman.isi.edu/mailman/listinfo/powerloom-forum