wiki:Ologicd

DISCLAIMER : This page is work in progress! Comments are welcomed...

Introducing ologicd

ologicd is a logic deamon. It is meant to run  software agents. Those agents may interact with external software through DBus.

ologicd is built upon Flora2. Flora is a Frame Logic inference engine itself built upon XSB, a Prolog inference engine.

About the architecture

Interaction with ologicd are made through DBus in the following ways :

  • External software can directly query ologicd's agents,
  • ologicd can listen for signals from external software,
  • ologicd can act on external software by calling methods or emiting signals.

[Add a graphical view of those relationships]

About Flora2 and Frame Logic

Simply put, Frame Logic is object orientation and logic. You can think of it as logic predicates defined as object methods. Or, the other way round, object methods implemented using logic.

There are many implementations of Frame Logic around (each with subtle syntax differences). We chose Flora for two main reasons :

  • we consider its syntax more matured, and
  • it is based on XSB, and thus uses its tabled logic feature, which gives the best performance.

[Add a simple example of the Flora syntax]

Use cases for ologicd

Here are some use cases for ologicd. Obviously, those could be implemented in a non-logic language. However logic programming makes them simpler to implement and maintain.

Customization based on rules

Phone ringing :

  • Launch different phone rings for particular persons, groups, ... in particular situations.
  • Route calls to answering machine for particular persons, groups, ... in particular situations.

Contact classification by collecting/correlating data :

  • Frequency of calls and messages, ...
  • Location when sending/receving calls and messages, ...
  • Time and agenda's planned activity when sending/receving calls and messages, ...

For instance, say I receive calls from contact X everytime when I'm at work or during work hours. This contact is automatically (or semi-automatically at user's choice) added to the Business contact group. Say I previously defined a special ringing for this contact group and, thus, contact X inherits this phone ring.

Call Patern Recognition

Recognizable call patterns :

  • Bip calls : A friend bips me (just one or two ringings) so that I call him back.

SMS Content Recognition

Recognizable SMS content :

  • Adresses : Those can be checked automatically with help of web directories and displayed on maps, ...
  • Mails
  • Numbers
  • Names : Correlated with adresses, mails, numbers, this can help to semi-automatically enhance contacts data.

Full SMS recognition :

  • SMS from answering machine : Recognized call captured by answering machine could be added to the missed calls view.

Activity/Context? Recognition

[Stuff like "Launched GPS app and curently moving => do not dim screen"]

Display customization and filtering :

  • Completion choices that would better fit the current context to appear at top.

For instance, when at work, the Contacts view would show Business contacts as first choices for completion.

Detailed architecture

Core components

XSB

XSB consists of two parts :

  • the compiler that transforms Prolog code into bytecode, and
  • the inference engine that interprets prolog bytecode

We, thus, need two bb recipes for XSB : one for the build host and one for the target.

Flora

Flora also consists of two parts :

  • the compiler that transforms F-Logic into Prolog code, and
  • the runtime Prolog and Flora code

Here again we need two bb recipes for Flora : one for the build host and one for the target.

Agent-support components

Those are F-Logic (and/or Prolog) modules for Flora that are needed to program cool agents :

  • Scheduler
  • Proof builder
  • ...

Glue components

libxsb-frontend

libxsb-frontend is a tiny lib that implements a C and Vala wrapper around the XSB C api.

ologicd query engine

ologicd query engine is a simple DBus server that queries the Flora engine. Queries are expressed as Flora goal, so this does just forward queries to Flora.

ologicd agent manager

ologicd agent manager is a simple DBus server that enables/disables individual agents. This is only special queries from the point of view of Flora.

ologicd#dbus

ologicd#dbus is a Flora binding for DBus. This is meant for agents to open their own DBus connections and register their own objects.

Status

Agent-support components

Scheduler 0% ?
Proof builder 0% ?

Glue components

libxsb-frontend 100% Done - Working ptitjes
ologicd query engine 100% Done - Working ptitjes
ologicd agent manager 10% API tinkering ptitjes
ologicd#dbus 0% ptitjes

Packaging

XSB native recipe 10% Patching started based on ebuild ptitjes
XSB target recipe 10% Patching started based on ebuild ptitjes
Flora native recipe 10% Patching started based on ebuild ptitjes
Flora target recipe 10% Patching started based on ebuild ptitjes
libxsb-frontend recipe 0% Easy to do because base on autotools ?
ologicd recipe 0% Easy to do because base on autotools ?

Building ologicd

First, you'll need a working multi-threaded  XSB 3.1 and  Flora 0.95. Unfortunately, there is no package available for Debian, RedHat? or whatever... There is a XSB 3.1 ebuild for Gentoo, but it does not build with the multi-threaded engine enabled. I have working patches and a working ebuild for those interested in the meantime. Anyway, the best way for non-gentooers is to build it by hand.

Then get and build  libxsb-frontend. This is a shared lib and it wraps the xsb.o compiled from XSB.

Finaly get and build  ologidc.

Enjoy!