Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Beyond the two typical programming architectures, procedural and object-oriented, there is a third type typically called rules-oriented. In such a program, the state of the program is represented by a "cloud" of facts. Operations are initized when facts matching certain requirements exist within the "cloud" as defined by rules; these rules, when initiated, can remove the matched facts completely from the complete, or add new facts, in addition to other less mundane tasks. For example, the following 'program' describes how one would prepare a meal and clean up afterwards:
Rule 1 - Clean-Up: Given 1: ( dirty-dishes ) Do Remove fact 1 add fact ( clean-dishes ) Rule 2 - Prepare-Food: Given 1: ( clean-dishes ) 2: ( raw-food ?foodtype ) Do Remove fact 1, fact 2 add fact ( cooked-food ?foodtype ) add fact ( dirty-dishes ) Rule 3 - Serve-Food Given 1: ( clean-dishes ) 2: ( cooked-food ?foodtype ) Do Remove fact 1, fact 2 add fact ( dirty-dishes )
If this code was then executed with the initial facts "( dirty-dishes )" and "( raw-food beef )", the following would happen:
Start                  ( dirty-dishes ) ( raw-food beef )
Clean-Up               ( clean-dishes ) ( raw-food beef )
Prepare-Food           ( dirty-dishes ) ( cooked-food beef )
Clean-Up               ( clean-dishes ) ( cooked-food beef )
Serve-Food             ( dirty-dishes )
Clean-Up               ( clean-dishes )
While a simple example, rules-based programming is very powerful when it comes to AI-like systems, including expert systems and fuzzy logic. For example, I worked out a symbolic differentiation system given any equation (typed out specifically) back when I was in high school using a rules-based system.

Currently the only langauge that I'm aware that does rules-based stuff is CLIPS, which you can get for free; the only caveat is that CLIPS 'functionality' outside of the rules matching is weak beyond simply print and file IO statements. I'm wondering if anyone has seen anything like this for perl yet; a check of CPAN shows nothing, and a google search doesn't turn up concrete answers. Mixing perl into a rules language may make it much more powerful than it seems. For example, having the ability to put any sort of perl code in the "Do" blocks of the prototypes above, or even more powerful, allow regex expersions to help with the fact matching in the "Given" blocks.

Because I don't see anything like this yet, I figure that this would be a good project to attempt after I get done with my current updating project. But as I don't want to reinvent the wheel, I'd figure I'd ask to see if anyone knew of such a beast to start with.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

In reply to Rules-based Perl? by Masem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (11)
    As of 2014-08-01 16:09 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Who would be the most fun to work for?















      Results (28 votes), past polls