Tag Archives: logic

On debugging software and Popper’s philosophy of science

Software containing bugs often produces undesirable results. When the a posteriori output from a programme does not meet our a priori expectations, either the programme logic has a flaw or the programme logic is fine, but the programme design was flawed.
When we test a programme, we are effectively collecting empirical data from which we make inductive propositions about the programme. So, if the erroneous output exhibits a certain pattern, we might infer a rule that might be generating this data. This is inductive science; moving from a limited set of observations to a general principle or law. And inductive science is, philosophically speaking,not uncontroversial. Induction is subject to the risk of ‘black swan’ events; no matter how many examples we find in support of a supposition (“All swans are white”), induction alone can never prove the objective truth of “All swans are white”.
However, Popper noted that we can apply deductive reasoning to the results of induction. So when our supposition that “All swans are white” is contradicted by the discovery of a single black swan, we may deduce that “Not all swans are white”. This move has maximal justification.
When we debug code with known errors, a good procedure is to create test conditions that enable us to apply this deductive technique and thus isolate the faulty lines of logic. We induce a hypothesis such as “All inputs {A} when processed by logic {L1,L2..LN} produce output {B}”, when we expected to see output {C}. We induce this from the output we can see in testing; and remember it is just an unproven hypothesis at this point. Now, if we can product output {B*} from the same inputs and logic, we can deduce something far stronger; a concrete proposition that “Not all input {A} when processed by logic {L1,L2..LN} produce output {B}” or its logical counterpart “Inputs {A} when processed…can produce {B} OR {B*}”.
This is a powerful result; moving from supposition to fact, by deduction. And software debugging is particularly well-placed to benefit from its application.

Leave a comment

Filed under Lateral thoughts