1. Propositional Logic Examples

Must Sing Rule

See the L4 code for this ‘Must Sing’ example

This example gives an overview of how to write a simple rule in L4 using the simple rule: “Every person who walks and eats or drinks must sing”.

We thank Matthew Waddington for originally authoring the case from which this example is drawn.

This chapter begins with a very simple rule, which is the input and is the contract we want to formalise:

“Every person who walks and eats or drinks must sing”.

Notice that there is ambiguity in thie sentence. We could mean:

  1. Every person who walks and (eats or drinks) must sing.

  2. Every person who (walks and eats) or drinks must sing.

The brackets disambiguate the sentence.

In interpretation 1, people who walk and people who eat or drink must sing. This is the interpretation shown in the google spreadsheet example.

We write interpretation 1 in L4 like this:

Must Sing Rule interpretation 1 in L4

EVERY

Person

WHO

walks

AND

eats

OR

drinks

MUST

sing

In interpretation 2, people who walk and eat or people who drink must sing.

We write interpretation 2 in L4 like this:

Must Sing Rule interpretation 2 in L4

EVERY

Person

WHO

walks

AND

eats

OR

drinks

MUST

sing

We transformed the rule into L4 with the following method:

  1. Break the rule up into subclauses separated by keywords like EVERY, WHO, and AND.

  2. Write down the nouns (“Person”) and verbs (“walks”, “eats”, “drinks”) in the cell to the right of the keywords.

We use indentation to disambiguate the sentence. An indentation is when the cells next to and below a keyword are blank.

Home Insurance Clause

See the L4 code for this ‘Home Insurance’ example, labelled as ‘Rodents and Vermin’

This example focus on a single decision rule drawn from a home insurance policy and its transformations to more easily understood forms.

“We do not cover any loss or damage caused by rodents, insects, vermin or birds. However, this exclusion does not apply to:

  1. loss or damage to your contents caused by birds; or

  2. ensuing covered loss unless any other exclusion applies or where an animal causes water to escape from a household appliance, swimming pool or plumbing, heating or air conditioning system.”

Following the method we learned in the “Must Sing” example, we need to:

  1. Break the rule up into subclauses separated by keywords like EVERY, WHO, and AND.

  2. Write down the nouns and verbs in the cell to the right of the keywords.

Remembering that we use indentation to disambiguate the sentence. An indentation is when the cells next to and below a keyword are blank.

Breaking the home insurance rule into subclauses

"We do not cover any loss or damage caused by rodents, insects, vermin or birds. However, this exclusion does not apply to:

loss or damage caused by birds; or

ensuing covered loss

unless any other exclusion applies

or where an animal causes water to escape from a household appliance, swimming pool or plumbing, heating or air conditioning system."

The two ways to encode the home insurance rule

We can write this rule in two ways, a ‘positive’ way and a ‘negative’ way.

The positive way is where we formalise the rule in a way that tells you that you are covered if the subclauses apply. Another way of saying this is “the damage is covered if…”

The negative way is where we formalise the rule in a way that tells you that you are not covered if the subclauses apply. Another way of saying this is “the damage is not covered if…”

Below is the table for the positive case, “the damage is covered if…” The rows and columns are numbered for convenience and reference.

Encoding of the positive version of the home insurance rule

The damage is covered if…

1

2

3

4

5

6

7

8

9

1

DECIDE

Loss or Damage 1

IS

Covered

2

IF

NOT

Loss or Damage

caused by

rodents

3

OR

insects

4

OR

vermin

5

OR

birds

6

UNLESS

Loss or Damage

IS

ensuing covered loss

7

OR

Loss or Damage

IS

to Contents

8

AND

Loss or Damage

IS

caused by birds

9

UNLESS

any other exclusion applies

10

OR

any animal caused water to escape from

a household appliance

11

OR

a swimming pool

12

OR

a plumbing, heating, or air conditioning system

Understanding the L4 encoding

This table looks very daunting, but we can split it into a few major subsections.

Step 1: Declare what version of the rule you’re encoding

The first step is to decide what version of the contract you’re encoding with the DECIDE keyword. In this case, we decided that we are encoding the positive vesion of the contract, “the damge is covered if…”

We see this decision in the first row, where we see “DECIDE Loss or damage 1 IS Covered”.

Step 1

1

DECIDE

Loss or Damage 1

IS

Covered

Step 2: Create the encoding one subclause at a time

First subclause

The original home insurance rule states that the rule is an exclusion that does not apply in certain cases, like damage caused by rodents, insects, vermin, or birds.

Since we’re encoding a positive version of this rule, we say “The damage is covered IF the damage is NOT caused by rodents, insects, vermin, or birds.”

We see this encoding from rows 2 to 5 of the encoding.

First subclause

2

IF

NOT

Loss or Damage

caused by

rodents

3

OR

insects

4

OR

vermin

5

OR

birds

Second subclause

The second subclause can be split into two subsubclauses.

Second subclause, subsubclause 1

6

UNLESS

Loss or Damage

IS

ensuing covered loss

7

OR

Loss or Damage

IS

to Contents

8

AND

Loss or Damage

IS

caused by birds

Second subclause, subsubclause 2

9

UNLESS

any other exclusion applies

10

OR

any animal caused water to escape from

a household appliance

11

OR

a swimming pool

12

OR

a plumbing, heating, or air conditioning system