Defining Declarative Logic Using Decision Tables - Gnorion/BizVR GitHub Wiki

Defining Declarative Logic Using Decision Tables

Declarative rules define the logic necessary to solve a problem without needing to specify the order of execution of those rules. This means the rule author only needs to focus on defining the problem in terms of rules. They can then use an inference engine to determine an execution sequence that will produce the output.

see also Defining Functions as Decision Tables where the order of execution is specified by means of functions

Suppose you have these rules that you use to decide whether to go somewhere on vacation:

Location
if location = Seattle then its wet is yes
if location = Dallas and its summer = yes then its hot is yes
if location = Dallas and its winter = yes then its cold is yes
Weather
if its hot = yes and its wet = yes then its humid is yes
if its wet = yes and its cold = yes then its snowing is yes
Temperature
if temperature <= 40 then its cold is yes
if temperature >= 80 then its hot is yes
Seasons
if month = June or  = July or  = August then its summer is yes
if month = November or  = December or  = January then its winter is yes
Should I go
if its hot = yes then should I go is no
if its wet = yes then should I go is no
if its cold = yes then should I go is no
if its humid = yes then should I go is no
if its snowing = yes then should I go is no
if its hot = no and its wet = no and its cold = no and its humid = no and its snowing = no then should I go is yes

At the highest level the decision might look like this (DRD) where we identify the inputs and outputs and factors that affect the decision:

image

Which in BizVR would look like this (BizVR shows a bit more detail for each table than the DMN DRD:

image

The order of execution is not predetermined in this (declarative) model. Compare this with the functional model

How the rules are processed

  • The execution engine will start with the output that is required (should I go) and then look for any rules that set this as an action.
  • In order to test the conditions specified in those rules the engine may have to look for other rules that set the values of those conditions.
  • This process repeats until the engine is able to determine the result.
  • Once a result is determined, no further rules are executed.
  • If it runs out of rules to try before it can find the output value then it stops and the value is left as unknown.

The decision tables themselves might look something like this:

image

image

image

image

image