## Conditional Logic applied to Requirement Statements

### Antecedents and Consequents

An example of a Requirement Statement, particularly a functional requirement statement, may be:

*When the Engine_Temperature is greater than 100 degrees Celsius [212 degress Fahrenheit], then the Driver_Display shall indicate High_Engine_Temperature_Alarm.*

Borrowing terms from Logic the portion *“When the Engine_Temperature is greater than 100 degrees Celsius [212 degress Fahrenheit]”* is the **Antecedent** of the statement and *“the Driver_Display shall indicate High_Engine_Temperature_Alarm”* is the **Consequent**. The Antecedent portion must be true in order for the Consequent to be true. Therefore the general form of a (functional) requirement statement is

[Antecedent], then [Consequent].

Antecedents are synonymous to the Pre-Condition, Trigger or Guard of the requirement statement whilst Consequent is synonymous to the Effect, Qualifying or Post-Condition of the requirement statement.

### Boolean Operators commonly used in Requirements

Boolean Operators are common functions that take one or multiple Boolean Operands to produce an output.

- AND (also represented as ∩, ˄, ∙). If X and Y are logical operands then this function is used as “X AND Y”.
- OR (also represented as U, ˅, +). Used as “X OR Y”.
- NOT (also represented as ¬, or a line over the operand). Used as “NOT X”
- THEN (also represented as →). Used as “X THEN Y”

Not strictly an Operator but parentheses are used to nest Boolean Operators.

There are of course other Boolean Operators derived from those above, such as NAND, NOR, XOR, XNOR, etc. but these operators, used in a textual requirements, often cause more confusion than intended.

Take the below requirement as an example:

*When [Device_A is Activated] NAND [Device_B is Activated], then Device C is Activated.*

You probably read that and process it as follows:

*When [Device_A is De-Activated] OR [Device_B is De-Activated], then Device C is Activated.*

So instead of using derived Boolean Operators it is recommend to stick to the basics and avoid additional cognitive effort to understand textual requirements.

### Boolean Operator AND

Boolean Operators are common functions that take one or multiple Boolean Operands to produce an output.

Useful for drawing a logical graph the following symbol is used to represent the Boolean Operator AND.

Using a truth table the following table shows the output of the Boolean Operator AND.

X | Y | X AND Y |

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

### Boolean Operator OR

Boolean Operator OR performs a **disjunction** of antecedent operands. This is represented in a Venn diagram as follows:

Useful for drawing a logical graph the following symbol is used to represent the Boolean Operator OR.

Using a truth table the following table shows the output of the Boolean Operator OR.

X | Y | X OR Y |

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

### Boolean Operator NOT

Boolean Operator NOT performs a **negation** of antecedent operands. This is represented in a Venn diagram as follows:

Useful for drawing a logical graph the following symbol is used to represent the Boolean Operator NOT.

Using a truth table the following table shows the output of the Boolean Operator NOT.

X | NOT X |

0 | 1 |

1 | 0 |

### Boolean Algebra Identities

Applying the Boolean Operator OR to operands is performing Boolean addition to the Operand values. Boolean addition is similar to arithmetic addition except that the sum doesn’t go past the value of 1.

E.g. if X is TRUE (1), Y is FALSE (0) and Z is TRUE (1) then X OR Y OR Z has value TRUE (1) as (1 + 0 + 1 = 1).

Applying the Boolean Operator AND operands is performing Boolean multiplication to the Operand values. Boolean multiplication is the same as arithmetic multiplication.

E.g. if X is TRUE (1), Y is FALSE (0) and Z is TRUE (1) then X AND Y AND Z has value FALSE (0) as (1 x 0 x 1 = 0).

Below is a table of important Boolean Identities.

Additative | Multiplicative |

X ˅ 1 = 1 | X ˄ 1 = X |

X ˅ 0 = X | X ˄ 0 = 0 |

X ˅ X = X | X ˄ X = X |

X ˅ ¬X = 1 | X ˄ ¬X = 0 |

### Boolean Algebra Laws

#### Commutative Law

Boolean Algebra is commutative which means

- X ˄ Y = Y ˄ X
- X ˅ Y = Y ˅ X

#### Associative Law

Boolean Algebra is associative which means

- X ˄ (Y ˄ Z) = (X ˄ Y) ˄ Z
- X ˅ (Y ˅ Z) = (X ˅ Y) ˅ Z

#### Distributive Law

Boolean Algebra is distributive which means

- X ˄ (Y ˅ Z) = (X ˄ Y) ˅ (X ˄ Z)
- X ˅ (Y ˄ Z) = (X ˅ Y) ˄ (X ˅ Z)

The last one isn’t intuitive at first so needs some explanation:

- X ˅ (Y ˄ Z)
- let (X ˄ 1) ˅ (Y ˄ Z)
- let 1 = 1 ˅ Y therefore X ˄ (1 ˅ Y) ˅ (Y ˄ Z)
- use distributive law to multiple out therefore (X ˄ 1) ˅ (X ˄ Y) ˅ (Y ˄ Z)
- let 1 = 1 ˅ Z therefore X ˄ (1 ˅ Z) ˅ (X ˄ Y) ˅ (Y ˄ Z)
- (X ˄ X) ˅ (X ˄ Z) ˅ (X ˄ Y) ˅ (Y ˄ Z)
- (X ˅ Y) ˄ (X ˅ Z)

#### De Morgan’s Law

De Morgan’s Law has two parts.

- ¬(X ˄ Y) = ¬X ˅ ¬Y or negation of multiplication of operands is equivalent to sum of negated operands.
- ¬(X ˅ Y) = (¬X) ˄ (¬Y) or negation of sum of operands is equivalent to multiplication of negated operands