Skip to content

Basic concept

mpoulshock edited this page Mar 30, 2011 · 2 revisions

Classes in the library define legal entities - things like people, property, institutions, and jurisdictions. C# methods are used to express and determine relationships among these entities. For example, the following could be used in a determination of whether a person is liable for a tort:

namespace Hammurabi.US
{
  public class Tort
  {
    public static bool? LiableForTortTo(Person p, Person d)
    {
      return HadDutyTowards(d,p) && 
             BreachedDutyTowards(d,p) && 
             CausedDamageTo(d,p);
    }
  }
}

As the code above suggests, Hammurabi takes something of a functional programming approach. A declarative legal “rule” is modeled as a static method in C#. In general, these functions have no side effects. However, there are some functions (Facts.Input___) that fetch data for the other functions to digest. Where do they fetch the data from? A data structure called the FactBase, which is a list of all facts that have been asserted into memory. (Note: this is the only global data structure.)

How are facts asserted into memory? By using statements like:

Person Joe = new Person(“Joe”);
Person Sally = new Person(“Sally”);
Facts.Assert(Joe, “IsMarriedTo”, Sally, true);

If a fact has not been asserted into memory, it is “unknown” - that is, neither true nor false (the open world assumption). Unknown-ness can propagate through the call stack so that if insufficient facts are asserted for a particular determination, the relevant method will return “unknown.” For instance, using the tort law example above, if no facts were asserted indicating whether or not person d caused any damage to person p, LiableForTortTo() would return null.