I am getting back to the declarative process work I began a couple of years ago. Peter Marks and Ben Moseley's session at SPA2006 got me started again.
I now have a partial implementation of a DVD rental application written in a declarative process style using eXist and XQuery. The essence of the design is to retain all events and compute the current state by the evaluation of predicates over the event trace. The rules are hard-coded in eXist functions in this demo. Rules are mostly XPath expressions. For example
- To find the current address for a person $p given SetAddress events
- events($p)[SetAddress][last()]//address
- To find the address at $date
- events($p)[SetAddress][@date
- To check if a member is suspended given Suspend and Reinstate events
- exists( events($p)[Suspend or Reinstate][last()][Suspend])
Some of the advantages of this approach are clear:
- the state of the system can be evaluated at any time in the past by filtering the event stream for events before the specified date
- if the rules are held as data, the state can be computed synoptically (i.e. according to rules applicable at the time) - but how should they be encoded - as executable XQuery expressions?
- changes in rules are supported, allowing re-interpretation of the past
- subjective rules are supported although only within the event language created
- 'what-if' analysis is supported, allowing questions to be asked about the impact of changes in the rules
- rules are robust to insertion of other events
- the event history is often required to understand what has happened and why so there is no addition storage requirement
Some disadvantages are also clear:
- The computational cost is higher than simply fetching a simple value
- Writing declarative rules is not easy and will need a higher level language
- The approach requires a global model of the system, so its applicable to systems but not to distributed systems
- It's not yet clear what range of behaviour is expressable
Much more work is needed to see how well this model will fit with other processes. Some applications include:
- lightweight processes - e.g. academic processes such as setting and marking coursework
- descriptive models of real processes and their subsequent analysis for process improvement
Prior work
The Alloy language (Daniel Jackson, MIT)
Peter Marks and Ben Moseley - Functional Relational Programming, SPA 2007, FRP site
Work on rule-based language has had a rough ride - several projects in this area (e.g. BRML) are defunct. Some activity in R2ML and RuleML.