|
Announce ERES (Re: prolog like operation in erlang ?): msg#00373lang.erlang.general
Dear all, the question of HP lead me to announce (before time!) ERES, which is an Erlang library to realize rule-processing engines as in Prolog. You may find it at: http://www.diit.unict.it/users/csanto/eres.html Please note that it is an "alpha" version since I still have to implement some optimization and fixes. Also the documentation needs to be improved :)) Anyway, I would appreciate any feedback from those of you which will try ERES. ERES is based on the concept of "knowledge base" which can store a set of "facts". For example, the problem of HP can be solved as: eres:new (mykb). eres:assert_list (mykb, [{x1,m1,m2}, {x2,m1,m2}, {x3,m3,m6}]). Then, using "eres:querykb (mykb, {nil, m1,m2])" will return: [{x1,m1,m2}, {x2,m1,m2}] You can also use lambda expressions in querykb (see the web page). But the main use of ERES is rule processing. You can implement rules such as: pre-condition --> action as function clauses, where the pre-condition refers to checking the presence of a certain fact in the knowledge base. For example, if you want to express that "each father is also a male", you can write: myrule (E, {father, X}) -> eres:assert (E, {male, X}), true. Asserting a fact like {father, corrado} will result in the automatical creation of the fact {male, corrado} (see the documentation for more detail). Regards, -Corrado Quoting HP Wei <hp@xxxxxxxxxx>: > Another newbie type question: > > Suppose I define a relation through the following function: > > rel(x1, m1, m2) -> true; > rel(x2, m1, m2) -> true; > rel(x3, m3, m6) -> true; > .... > > In prolog, if I am not mistaken, > something like rel(X, m1, m2) can give me X = [x1, x2]. > > In erlang, how do I in general get the corresponding X ?? > Or should I encode the relation in a structure in this case ? > > HP > > -- ====================================================== Eng. Corrado Santoro, Ph.D. Unversity of Catania - Engineering Faculty Department of Computer Science and Telecommunications Engineering Viale A. Doria, 6 - 95125 CATANIA (ITALY) Tel: +39 095 7382364 Fax: +39 095 338280 EMail: csanto@xxxxxxxxxxxxx Personal Home Page: http://www.diit.unict.it/users/csanto NUXI Home Page: http://nuxi.iit.unict.it ====================================================== ------------------------------------------------- This mail sent through IMP: http://www.cdc.unict.it/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | ETS keys: how complex in usual cases?: 00373, Dan Gudmundsson |
|---|---|
| Next by Date: | Re: mnesia:match_object() on an ordered_set: 00373, Ulf Wiger |
| Previous by Thread: | Re: prolog like operation in erlang ?i: 00373, Kent Boortz |
| Next by Thread: | ETS keys: how complex in usual cases?: 00373, Scott Lystig Fritchie |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |