Programming Language Theory Concept
Boolean blindness
Journey Statuslearning Tags
-> The boolean discards it; you must later \"remember\" what it meant.
Elaboration
Constructive types preserve the witness; booleans erase it.
When you compute
isZero n, you learn one bit.But you had richer information-the structure of
n.-> The boolean discards it; you must later "remember" what it meant.
-> As Robert Harper puts it: to use a boolean you must know its provenance, but you've blinded yourself by reducing information to a bit.
Example
Boolean approach (blind)
txtf = if isZero n then y else f (pred n)-> Information is collapsed to a bit, branched, then had to recover what you lost -
predmust re-check thatnis non-zero.Constructive approach (witnessing)
txtf = case n of Zero -> y Succ m -> f mThe pattern match is the proof of non-zero-ness. The witness
mis the predecessor-extracted, not recomputed.