# Business Rules and Logic ~ What Exactly Is a Business Rule?

I recently received a communication from an old friend (I'll call him George), "soliciting opinions" on a matter to do with logic and business rules.  After I'd responded, I realized that the whole exchange could possibly be of interest to a wider audience, and so I worked it up into the present technical note.

First, here's the whole of George's communication (all formatting etc. exactly as in his original):

 I'd like your opinion on a fundamental question about "rule." Example just for illustration ... It must be that:  each customer places some order. Predicate?  Proposition?  Hybrid?  Other? I stick with my opinion so far that the closest thing in formal logic is logical implication, which can be taken to be a predicate. But the quantification does make it interesting.  Just a diversion?  Could you equally say: customer must place order. That sounds more like a predicate, but it may be just semantics (Of course). Any insight would be appreciated.

George also added the handwritten note "Soliciting opinions!" at the bottom of the page.  What follows is an edited version of my response to his solicitation.

Dear George:

Thanks for your communication "soliciting opinions" ...  The following isn't just an opinion, however -- it's meant to be definitive (joke) -- at least as far as it goes.  Hope you find it helpful.

It must be that:  each customer places some order.

You ask whether this rule is, formally, a predicate, a proposition, a hybrid of both, or something else entirely.  (Note: "Formally" here is my addition, but I assume it's what you meant.)  My short answer is:  It's a proposition.  My longer answer follows ...

There are at least two ways to represent the given rule using the notation of formal logic:

 `1.` ```FORALL c ( EXISTS o ( places ( c, o ) ) )``` 2. ```FORALL x ( IF cust ( x )``` ```THEN EXISTS y ( order ( y ) AND``` `places ( x, y ) ) )`

Both of these expressions are indeed propositions, a point I'll come back to later.  I'll refer to them as Proposition 1 and Proposition 2, respectively.  And what we might call the preamble to the original natural-language formulation -- `It must be that `-- simply means the proposition in question (whichever one we choose) is required to evaluate to `TRUE`.

Now let's take a closer look at Proposition 1:

```FORALL c ( EXISTS o ( places ( c, o ) ) )```

Here I'm using what's sometimes called "sorted logic," in which the "logic variables" (`c` and `o` in the example) are considered to be "sorted," or what we in the IT community would more usually call typed.  In other words, we can imagine we've been given definitions of the form (the syntax here is based on QUEL):

```RANGE OF c IS CUSTOMER /* i.e., c is of type CUSTOMER */```

```RANGE OF o IS ORDER /* i.e., o is of type ORDER */```

Proposition 1 thus simply states:

```For all customers c, there exists at least one order o such that c places o.```

The expression ```places(c,o ```) is an invocation of a predicate -- a truth-valued function, if you prefer -- called `places`; it returns TRUE if ```"c places o" ```is true and `FALSE `otherwise.  Note: Proposition 1 is indeed a proposition rather than a more general predicate, even though it includes the expression ```places(c,o) ```as a subexpression; the effect of the quantifiers ```FORALL c ```and `EXISTS o `is to bind the variables `c `and `o`, thereby converting that subexpression (and hence the overall expression as well) into a proposition.  I'll elaborate on this issue of the formal difference between predicates and propositions later.

Now let's turn to Proposition 2:

 ```FORALL x ( IF cust ( x )``` ```THEN EXISTS y ( order ( y ) AND``` `places ( x, y ) ) )`

Here I'm using a more conventional "unsorted" logic (unsorted logic is the kind that logicians more typically assume, but it's slightly more cumbersome for our purposes, as will soon be obvious).  In other words, instead of assuming we have some arbitrary number of distinct "sorts" (equivalently, types or domains), we assume there's just one "sort," called the universe of discourse, that contains everything we might ever be interested in (customers, orders, elephants, bicycles, etc. -- you name it).  So we need to introduce two new predicates -- `cust(x)`, which returns `TRUE `if and only if `x `is a customer, and `order(y)`, which returns `TRUE `if and only if `y `is an order.  Thus, Proposition 2 states:

```For all objects x, if x is a customer, then there exists at least one object y such that y is an order and x places y.```

In your communication, you say:  "I stick with my opinion so far that the closest thing [to a formal expression of your original rule] in formal logic is [a] logical implication, which can be taken to be a predicate."  As you can see, Proposition 2 does include a logical implication (IF ... THEN ...), but it is not a logical implication; the initial quantifier is crucial.  I don't have a problem with your thinking in terms of logical implication, but to think that way does mean you're thinking -- at least partly, albeit implicitly -- in terms of unsorted logic, and I respectfully suggest that sorted logic would be a better basis.

As for logical implication being "taken to be a predicate":  There's some confusion here.  Some implications are propositions; e.g., "IF 5 < 2 THEN Al Gore is the US president."  (By the way, this proposition is true -- not for political reasons, but because 5 < 2 is false.)  Some implications are more general predicates; e.g., "IF ```z ```is a US citizen then ```z ```is allowed to vote in the US."  (Note that we can't assign a truth value to this latter implication without first assigning a value to `z`.)  Thus, you might indeed say, as you more or less did say, that an implication is a predicate, but that statement doesn't mean what I think you think it means.  To get technical on you for a moment:

• All implications are predicates; some implications are propositions.

• All propositions are predicates; some predicates aren't propositions (see below).  To be precise, a predicate is a proposition if and only if it involves no free variable references.

• A variable reference is free if and only if it's not bound (by some quantifier).

Formal explanation of predicates and propositions (assuming "sorted logic"):

• A predicate, `P `say, is a truth-valued read-only operator (also known as a truth-valued read-only function).

• By definition, predicate `P `is formulated in terms of some specified set of parametersNote:  As indicated earlier, parameters are usually called variables in logic.  However, I'm concerned here (as logicians typically aren't) with the computing context specifically, and I want to avoid confusion with variables as understood in that context.

• All parameters are typed.  When ```P ```is invoked (or instantiated), arguments are substituted for the parameters; if parameter `p `is declared to be of type `T`, then, in every instantiation of `P`, the argument substituted for `p `must also be of type `T`.

• Substituting arguments for the parameters effectively converts the predicate into a proposition.  We say the arguments satisfy the predicate if and only if that proposition is true.

• A proposition can be regarded as a degenerate predicate (it's a predicate for which the corresponding set of parameters is empty).

To say it again, therefore, all propositions are predicates (though most predicates aren't propositions).  So the answer to your original question is:  The rule is a proposition, and therefore it's a predicate too.  Note too, incidentally, that the concept of a "hybrid" proposition/predicate makes no sense.

You say:  "The quantification does make it interesting," and ask whether it's "just a diversion."  I hope it's obvious from all of the foregoing that it's not just a diversion!  The point is, formal logic forces us to make the quantifiers explicit, even when they're merely implicit in the natural-language formulation.  There are many, many ways of stating the original rule in natural language.  Typically, some -- probably most -- of those ways will be ambiguous (in this connection, see the appendix to this response!).  Your approach to addressing the problem of ambiguity is, I believe, to insist that certain words (e.g., shall, must) always be used in certain limited ways and always have certain fixed, prescribed semantics.  It seems to me, however, that such an approach will always be liable to error; you simply can't just edict that such commonly used words have such prescribed meanings and hope that the universe of pertinent people will never use them in any other way.  I might point to the case of "table" in the relational world; I do believe SQL is the mess it is, in part (but only in part!), because we refused in the early days to face up to a slightly unpalatable fact:  the fact, that is, that it would have been much better to use the precise but unfamiliar term relation instead of the fuzzy term table.  As it was, we made the wrong decision ... and the rest, as they say, is history.

Here's how logic helps.  Your rule designer might say, for example, "A customer must place an order" -- thinking, perfectly reasonably, that this assertion defines a customer (in order to be a customer in the first place, you must place an order).  The assertion sounds precise!  But the person trained in logic says "Aha! -- there are several different logical expressions that could correspond to this assertion" (equivalently, "There are several different interpretations of this assertion, all of them prima facie valid, and I have no idea which one is intended").  For example:

 ``` FORALL c EXISTS o ( places ( c,o ) )``` ``` /* Proposition 1: presumably what was intended */``` ``` EXISTS c EXISTS o ( places ( c,o ) )``` ``` /* there must be at least one customer who places an order */``` ``` EXISTS o FORALL c ( places ( c,o ) )``` ``` /* there's at least one order that every customer places */``` ``` FORALL c UNIQUE o ( places ( c,o ) )``` ` /* each customer places exactly one order */` ``` UNIQUE o FORALL c ( places ( c,o ) )``` ``` /* there's exactly one order that every customer places */```

Note my use of the quantifier `UNIQUE `to mean "there exists exactly one," incidentally.  I've also dropped unnecessary parentheses here and there.

The logician, then, has to ask the rule designer which of the foregoing interpretations -- if any (the list isn't exhaustive) -- is the one intended.  And the rule designer then has to come up with a better formulation (in whatever language is being used, be it natural language or some other vehicle).  And then we iterate, and iterate, and iterate ... until eventually we reach a formulation that states precisely what's intended, nor more and no less.  How much better it would be for the rule designer to be trained in logic and to express the rule in logic in the first place!

Yes, I know the counterarguments, but I don't agree with them.

/* Signed */ Chris Date

### Appendix:

*/ ?>

To bolster my claim that natural-language formulations of business rules are often ambiguous, I quote here a piece by Robert Graves and Alan Hodge.  The piece is included and analyzed in detail in an article by Ernest Nagel entitled "Symbolic Notation, Haddocks' Eyes, and the Dog-Walking Ordinance," in James Newman (ed.), The World of Mathematics, Vol. 3, Simon and Schuster, 1956 (republished by Dover Publications Inc., 2000).  Thanks to Lauri Pietarinen of AtBusiness Communications Oy, Helsinki, Finland, for drawing this splendid example to my attention.

#### References

  Actually I prefer the term parameters, for reasons I'll explain later. Of course, there's no suggestion that "the system understands" that predicate; it's just something we introduce, a kind of deus ex machina if you like, that we define, by fiat, to have the indicated meaning.  Though -- at the risk of confusing you -- if there's a relation in the database corresponding to that predicate, and if the tuple ```<c,o> ```appears in that relation, the system does at least know that `places(c,o) `is `TRUE`, even though it doesn't know what the predicate `places `"means." For the record, the logical implication `IF p THEN q `is defined to be equivalent to `(NOT p) OR q`.  It thus evaluates to `FALSE `if and only if `p `is true and `q `is false. Yes, you could "equally say" (as you suggest) `customer must place order`.  Though I don't know why you think this formulation "sounds more like a predicate."  Nor do I know what you mean by "it may just be semantics."  What may be just semantics? # # # C.J. Date , "Business Rules and Logic ~ What Exactly Is a Business Rule?" Business Rules Journal Vol. 4, No. 12, (Dec. 2003)
URL: http://www.brcommunity.com/a2003/b170.html 