Frontier Software


By Robert Laing

Flow Control

Yet another way to think of logic is as electrical switches, where on is true and off is false. Here conjunction is switches in series, and disjunction is switches in parallel.

p q r s

If any switch in series is not on (such as switch r in the above diagram), it breaks the flow of electric current, meaning a light or whatever the circuit powers would be off. If the switches were in parallel, (which I’ll illustrate in disjunction), any on switch would put the circuit on.

Looking at the above four switches in series — p ∧ q ∧ r ∧ s — does it make any difference what order they are in?

From the perspective of pure maths, that’s a stupid question: p ∧ q is commutative and associative, just like multiplication.

But something Prolog makes explicit by using a comma for both and and to separate sequential statements, in some cases the order does matter.