Question about range constraint enforcement

View: New views
2 Messages — Rating Filter:   Alert me  

Question about range constraint enforcement

by srini_ottawa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
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
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Question about range constraint enforcement

by Thomas Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Nov 3, 2008, at 8:10 AM, Srini Ram wrote:

> 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)

You have a problem here, in that "Max_time_slot" is a reference to a  
PowerLoom instance, and not a numeric value.  To use the functional  
value, you would need to write

(defconcept Time_slot (?t number)
     :<=> (AND (>= ?t 1) (=< ?t (numeric-constant Max_time_slot)))
     :closed TRUE)

instead.

I haven't had time to work through the rest of your message yet.




_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum