[mercury-users] Term manipulations in Mercury -- advice requested

Gregory D. Weber gdweber at indiana.edu
Wed Jun 2 09:22:35 AEST 2004


Greetings!  I am interested in using Mercury as the programming language
to develop a first-order rule learning system.  I have done a fair amount
of Scheme and Common Lisp programming and a wee bit of Prolog.

The rule learning program should start with a description of a
classification task, which includes a specification of the predicates
to be used, their names, arity, and argument types, and a collection
of training examples.  To learn a rule, I want to use a general to
specific search in which the program (forming the conditions of a
rule) starts with the most general term for some predicate and
incrementally adds conditions to it.  For example, given the knowledge
that there is a widget predicate with 2 arguments, the first
argument's values may be yellow, red, or black, and the second
argument's values are numbers, the program could begin with the
general term

widget(A, B).

and form specializations such as

widget(yellow, B).

widget(A, B), B > 10, B <= 16.

If I were doing this in Prolog, I would be using functor, arg, and
"=.." ("univ").  I think I see two possible ways to do it in Mercury.

1.  One is to use the facilities of the term and related libraries
(varset__init, varset__new_named_var, term__atom, term__context,
term__variable, term__functor, or parser__read_term_from_string, to
build terms; term__unify and term__substitute, to match terms to
examples).

2.  The other is to use facilities of std_util (functor, construct,
argument, deconstruct; and for matching, unify or just '=').

My impression is that (1) is going to be more complicated,
that it might be more flexible and require less compile-time
information than (2), and that it might be less efficient than (2).

I would be glad if anyone would point out to me the pros and cons of
the two alternative strategies.  What's the rationale for providing
more or less equivalent tools for term manipulation in two distinct
libraries?  Also, is there any other way that I should consider?

-- 
Gregory D. Weber

Associate Professor of Computer Science, Indiana University East
2325 Chester Boulevard, Richmond, Indiana 47374-1289, U.S.A.
Telephone: (765) 973-8420         World-Wide Web http://mypage.iu.edu/~gdweber/

----
ASCII plain text is the document format that maximizes readability and 
minimizes hassle and hazard.  It is the format of the official documents
defining Internet protocols (http://www.rfc-editor.org/).


--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list