Edd Mann Developer

Understanding De Morgan's Laws to simplify propositions

Yesterday I watched a conference talk about Formal Logic and De Morgan’s laws were discussed. Wikipedia does a very good job of explaining the laws in-depth, but essentially they are transformation rules that allow you to simplify certain propositions. Whilst programming, predicate logic of this form appears very frequently, and it is very useful to know how you can rewrite a predicate to better describe its intent.

// Negation of conjunction
(!a && !b) == !(a || b)

// Negation of disjunction
(!a || !b) == !(a && b)