# Re: DRAFT: List of Built-ins

From: Benjamin Grosof (bgrosof@MIT.EDU)
Date: 05/28/03

• Next message: Wagner, G.R.: "RE: DRAFT: List of Built-ins"

```Hi Said, Sandro, and all:
I agree with most of Sandro's comments -- right on.

I strongly suggest we sharply distinguish
(1) purely informational sensing built-ins
versus
(2) other kinds of procedural attachments that we might consider invoking
as "built-ins".

In particular, assignment, I/O writing, and the control/debugging
operations do not belong in (1).
Moreover, assignment and the control/debugging operations should not be
treated as procedural attachments to be
invoked from within the rule language (at least not in any initial version
of our semantic web rules language / RuleML).
I/O writing is OK as an effecting built-in.

I suggest more built-ins be added for mathematical operations.  In
particular, logarithm (probably in different flavors for log base 2, log
base e, and log base 10) and exponential (again, with flavors for different
bases) and the usual trigonometric functions (sine, cosine, tangent, etc.)
are pretty crucial.

Benjamin

At 11:44 AM 5/28/2003 -0400, Sandro Hawke wrote:

> > As promised, please find, attached, the list of built-ins. This is a
> > draft, a new version will be available next week with much more details.
>
>Understood; feel free to answer my questions in that new version
>instead of e-mail, if that works better.
>
>General question: how do you propose to organize built-ins in terms of
>input vs. output vs. bi-directional parameters?  EG addition and
>subtraction can be the same predicate:
>     sum(3,4,7)   true if 3+4=7
>     sum(3,4,?x)  binds ?x to 7 if unbound
>     sum(3,?y,7)  binds ?y to 4 if unbound
>This is a little odd for addition, but I guess it's common in Prolog
>for list-append.
>
> > 3. More Built-ins:
> > ----------------
> >       3.1     Assign                  =
>
>What does this mean in a KR language, where it doesn't make sense to
>talk about changing the value of something?
>
> >       3.2     Increment               ++
> >       3.3     Decrement               --
>
>Ditto, unless you just mean +1 and -1.
>
> >       3.4     Power                   **
> >       3.5     Abs (absolute value)
> >       3.6     Min
> >       3.7     Max
> >
> > 4. Data Types
> > --------------
> >       Our approach is to integrate XML Part 2, Data Types:
> >       http://www.w3.org/TR/xmlschema-2/
>
>What kind of built-ins does that give you?  For example, the datatype
>"duration" [1] represents a length of time via a 6-tuple of <year,
>month, day, hour, minute, second>.   It has an ordering, and the
>following "constraining facets":
>     * pattern
>     * enumeration
>     * whiteSpace
>     * maxInclusive
>     * maxExclusive
>     * minInclusive
>     * minExclusive
>
>So what built-ins does that suggest we should have associated with the
>xsd:duration type?
>
> > 5. String built-ins:
> > -----------------
> >       5.1     str-length      returns the length of a given string in
> charact
> > ers
> >       5.2     str-cat         string concatenation
> >       5.3     str-compare     compares 2 strings
> >       5.4     str-index               returns the position of the first
> argum
> > ent within the =
> > second argument
> >       5.5     is-String               returns TRUE if the argument is a
> strin
> > g, FALSE =
> > otherwise
> >       5.6     sub-string      returns a substring from a string
> argument give
> > n two =
> > 1-based indices
> >       5.7     str-upcase      returns the given string argument in
> Uppercase
> >       5.8     str-lowcase     retrns the given string argument in lowercase
>
>Do you really want hyphens in names?  stringLength is probably more in
>keeping with current naming wisdom.    Is isString different from
>checking to see if it's in the String class?
>
>What are strings, btw?  Are they XSD strings, RDF plain literals (are
>those xsd strings?), or something else.
>
> > 6. I/O Streams built-ins:
> > -----------------------
> >       6.1     open            Open a file or a stream
> >       6.3     write           Write to a stream or file
> >       6.4     close           close file or stream
>
>I'd suggest that file handling and URI handling be unified.  Opening
>and reading a file is pretty much the same as GET of an HTTP URI.   If
>the default basename is file: with the current directory, the
>difference is only noticable on filenames starting with something that
>looks like a URI scheme name.
>
>"write" is of course not a side-effect-free (sensing) operation.
>
> >       6.5     printout                sends unformatted output to a
> given str
> > eam/router
>
>... this is an enormous can of worms....   What kind of formatting are
>you suggesting "write" has?
>
> > 7. Control and debugging built-ins:
> > ---------------------------------
> >       7.1     run             invoke an inference cycle
> >       7.2     query           run a query
> >       7.3     halt            halts an inference/query cycle
> >       7.4     reset           reset the fact base
> >       7.5     show-facts      returns the list of asserted facts
> >       7.5     show-rules      returns the list of rules
> >       7.8     debug           runs in a debug mode: traces all rule firings
> >       7.9     assert          assert new facts
> >       7.10    retract         retract facts
> >       7.13    evaluate                evaluates a string input as
> command lin
> > e input and =
> > returns the result
> >       7.14    clear           clear engine from all its contents:
> rules, fact
> > s, etc.
>
>Most of these are not sensing operations either.  I don't know how you
>expect to fit them into a KR language.  Any ideas?
>
>      -- sandro

________________________________________________________________________________________________
Prof. Benjamin Grosof
Web Technologies for E-Commerce, Business Policies, E-Contracting, Rules,
XML, Agents, Semantic Web Services
MIT Sloan School of Management, Information Technology group