|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Powerloom beginner questions...It seems that there are three ways of writing
functions: 1. Powerloom deffunction 2. Stella function 3. Lisp function I understand that stella code can call lisp via verbatim, but: a. how does powerloom function call a stella function. b. When do I write a PL (def)function as opposed to a Stella (or LISP) function (defun). c. Can PL facts/queries/rules only see PL functions? This does not work for example: ;; I guess I am calling STELLA defun and not CL::defun ;; below. If I wanted to define a LISP function, would ;; I just say (verbatim (:common-lisp (CL:defun... ? (defun sl-age-fn ((age INTEGER)) (return (* 2 age)) ) ;; all persons are aged 20 (defrule age-rule (=> (Person ?x ) (age ?x (sl-age-fn 10)))) ..This gives unknown sl-age-fn when evaluated. Thanks Srini ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs _______________________________________________ powerloom-forum mailing list powerloom-forum@... http://mailman.isi.edu/mailman/listinfo/powerloom-forum |
|
|
Re: Powerloom beginner questions...On Jan 28, 2008, at 9:45 AM, Srini Ram wrote: > It seems that there are three ways of writing > functions: > 1. Powerloom deffunction > 2. Stella function > 3. Lisp function OK. Let's start with a general overview of those options here, before getting into detailed answers to the questions below. 1. PowerLoom functions. These are logical functions and follow the general rules of logical functions. They can be thought of as special, single-valued relations. The major difference between a PowerLoom function and an ordinary PowerLoom relation is that functions can use "functional syntax", since they are single-valued. Functional syntax is simply a form that omits the last argument to the function. That allows them to be used inside the logical forms (such as queries and assertions) where a value would otherwise be used. Functions also introduce the notion of skolem individuals -- special anonymous individuals that represent the possibly unknown value of a function. That is what allows one to write something like: (assert (> (age Bob) 20)) for the function "age". 2. Stella functions. These are programming language functions written in the Stella language. They get translated into a native function or method in the underlying programming language that you are using. 3. Lisp function. A function written in the Lisp programming language. This can only be used with the Lisp version of PowerLoom. There are similar analogs for C++ and Java. > > > I understand that stella code can call lisp via > verbatim, but: > a. how does powerloom function call a stella > function. Normally it doesn't. There is a provision called specialists which allow the execution of Stella code. We don't have any specific documentation for the interface to the reasoning engine, other than what you would find in the Stella code for the specialists. It is a bit arcane, since it has to properly interface with the control mechanism for the inference engine in PowerLoom. There is also a simpler interface for defining constraint functions, which we use for doing, in particular, arithmetic. There are examples, particularly in the specialists.ste and arithmetic.ste files. The basic interface is conceptually fairly simple, but there are a lot of details that need to be taken care of. It involves accessing control frames and setting values and return values properly. Rather than get into that in detail here, I suggest that if you want to do this, we take the detailed discussion off the main forum mailing list. > > b. When do I write a PL (def)function as opposed to a > Stella (or LISP) function (defun). You write a PL function when you want to have a logical function. That is a function that exists in the logic and can be used as part of PowerLoom assertions and queries. You would write a programming language (Stella, Lisp, Java, etc.) function if you want to have something programmatic happen. There is a method for linking the functions, as noted above. > c. Can PL facts/queries/rules only see PL functions? Yes. > > > This does not work for example: > > ;; I guess I am calling STELLA defun and not CL::defun > ;; below. If I wanted to define a LISP function, would > ;; I just say (verbatim (:common-lisp (CL:defun... ? > (defun sl-age-fn ((age INTEGER)) > (return (* 2 age)) > ) > > ;; all persons are aged 20 > (defrule age-rule > (=> (Person ?x ) > (age ?x (sl-age-fn 10)))) > > ..This gives unknown sl-age-fn when evaluated. That would be expected behavior. The Stella or Lisp function is not visible to the reasoner. Note that because of the fairly big support for arithmetic, you can, in fact, write functions like the one above just using PowerLoom. But I suspect this was just a simple test example, and what you really need to do is more complicated. We should discuss that off-list. _______________________________________________ powerloom-forum mailing list powerloom-forum@... http://mailman.isi.edu/mailman/listinfo/powerloom-forum |
| Free Forum Powered by Nabble | Forum Help |