Skip to content
myAudience.
← Explore the library

Boolean policy, selection and exhaustive evidence

By UK A Level Computer Science · independent study · myAudience

A and C enter an AND gate; S enters through NOT. The complete eight-row table highlights only A=1, C=1, S=0, Permit=1.

Original textbook concept plate generated with OpenAI imagegen; labels and states checked against the lesson model. · Generated original teaching artwork; pending operator rights/provenance review before publication.

Boolean policy, selection and exhaustive evidence

A Boolean has two truth values. A predicate maps inputs to a Boolean result; relational operators such as ≥ turn numerical comparisons into predicates. Selection chooses a branch according to such a result. In a fictional club model, access requires an age of at least sixteen, consent and no suspension. This is an original programming policy, not a statement about law or the myAudience product. Normative policy decides which conditions should matter; a program can implement that decision accurately without proving that the decision is fair or desirable.

Let A mean age≥16, C mean consent and S mean suspended. The formula is A∧C∧¬S. AND requires both operands true; OR requires at least one; NOT reverses a truth value; XOR requires different truth values for two Boolean operands. Parentheses make intended grouping explicit. For Boolean values, C XOR S is not a replacement for C AND NOT S: when C is false and S true, XOR would be true. This counterexample is more persuasive than saying that the expressions “look different”.

A truth table for A,C,S has 2³=8 rows. Exactly one row permits access: A=true, C=true, S=false. Enumerating all rows proves equivalence between formulas in this finite abstract domain. Boundary tests on numerical age remain necessary because A is derived from an integer. Ages fifteen and sixteen distinguish ≥ from >; age seventeen does not. The predicate's contract assumes age is an integer and the other values are actual Booleans. Python's and/or operators can return an operand rather than a Boolean, so accepting arbitrary strings or containers changes the meaning of the function.

Short-circuit evaluation stops AND at the first false operand and OR at the first true operand. That can protect a later operation such as i<len(a) and a[i]>0. Reversing the order may index outside the list before the bounds check runs. This is an operational consequence, separate from the truth-table equivalence of total Boolean predicates. If an operand raises an exception or has a side effect, algebraic rearrangement may preserve logical truth while changing program behaviour. Keep policy predicates pure where possible so their reasoning is dependable.

De Morgan's law gives the denial condition ¬(A∧C∧¬S)=¬A∨¬C∨S. This expression supports explanations, but multiple denial reasons can coexist. A single if/elif chain reports only its first matching branch; independent checks can collect every reason. Choosing an explanation format is a user-interface decision. The numerical comparison, Boolean policy, branching control and explanation should be distinguished during debugging: an incorrect birthday calculation can produce an incorrect result even if the Boolean formula is flawless.

Reading the diagram: Read A, C and S as Boolean inputs, not voltage measurements. The NOT gate turns S into ¬S before the three-input AND. The eight truth-table rows exhaust the abstract Boolean domain; only A=1,C=1,S=0 produces Permit=1 and is highlighted. The ages still need their own numerical boundary tests because A represents the separate comparison age≥16. This fictional policy is an exercise, not a legal access rule.

Runnable original Python 3, independently executed on Python the related topic. Read the stated input contract before running. These examples use fictional data and are teaching models, not production services.

```python
def permitted(age, consent, suspended):
"""Original fictional access policy, not a legal or product age policy."""
return age >= 16 and consent and not suspended
```

Worked example: Trace permitted(16, True, False), then compare the intended formula with A and (C or not S).

At age 16, A is true. C is true and not S is true, so the conjunction is true.

For A=true,C=false,S=false, the intended formula is false because consent is absent.

The alternative evaluates false or true inside its parentheses, giving true. It therefore admits a forbidden row.

Answer: The first call returns True. The proposed alternative is inequivalent and permits access without consent.

Check your understanding: 1. State the denial formula. 2. How many of the eight truth-table rows permit access? 3. A bounds check is written a[i]>0 and i<len(a). Explain a failing input and rewrite it; include negative indices in your assumptions.

Answer: 1. not A or not C or S. 2. Exactly one. 3. With a=[] and i=0, indexing raises IndexError before the size comparison. Use 0<=i<len(a) and a[i]>0. The added lower bound matters because Python negative indices can access existing elements, while this algorithm intends an ordinary nonnegative position.

Why: OR is inclusive unless specified otherwise. De Morgan changes each connective and negates each operand. Exhaustive Boolean rows do not test numerical parsing or indexing effects. A bounds condition must be evaluated first and must describe the intended index domain.

Author source references