Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prolog Beginner - Is This a Bad Idea?

Tags:

The application I'm working on is a "configurator" of sorts. It's written in C# and I even wrote a rules engine to go with it. The idea is that there are a bunch of propositional logic statements, and the user can make selections. Based on what they've selected, some other items become required or completely unavailable.

The propositional logic statements generally take the following forms:

A => ~X 
ABC => ~(X+Y) 
A+B => Q 
A(~(B+C)) => ~Q A <=> B

The symbols:

=>  -- Implication
<=> -- Material Equivalence
~   -- Not
+   -- Or
Two letters side-by-side -- And

I'm very new to Prolog, but it seems like it might be able to handle all of the "rules processing" for me, allowing me to get out of my current rules engine (it works, but it's not as fast or easy to maintain as I would like).

In addition, all of the available options fall in a hierarchy. For instance:

Outside
   Color
      Red
      Blue
      Green
   Material
      Wood
      Metal

If an item at the second level (feature, such as Color) is implied, then an item at the third level (option, such as Red) must be selected. Similarly if we know that a feature is false, then all of the options under it are also false.

The catch is that every product has it's own set of rules. Is it a reasonable approach to set up a knowledge base containing these operators as predicates, then at runtime start buliding all of the rules for the product?

The way I imagine it might work would be to set up the idea of components, features, and options. Then set up the relationships between then (for instance, if the feature is false, then all of its options are false). At runtime, add the product's specific rules. Then pass all of the user's selections to a function, retrieving as output which items are true and which items are false.

I don't know all the implications of what I'm asking about, as I'm just getting into Prolog, but I'm trying to avoid going down a bad path and wasting lots of time in the process.

Some questions that might help target what I'm trying to find out:

  1. Does this sound do-able?
  2. Am I barking up the wrong tree?
  3. Are there any drawbacks or concerns to trying to create all of these rules at runtime?
  4. Is there a better system for this kind of thing out there that I might be able to squeeze into a C# app (Silverlight, to be exact)?
  5. Are there other competing systems that I should examine?
  6. Do you have any general advice about this sort of thing?

Thanks in advance for your advice!