Propositional Logic Prover II: Truth Table Generator

Learn techniques to build a truth table from a propositional logic formula.

Introduction

Truth tables can be useful in many situations. They can be used to make inferences or validate an argument, to understand logic circuits, to understand complex conditional statements in programming, or even to create automated reasoning systems. Equally important, they help to understand how to evaluate a propositional formula.

You can find the full code in my github repo.

Prerequisites

Here are the concepts you need to know to understand the text in this project:

The tools needed for this project:

  • Python
  • PrettyTable

Check your knowledge

What is a valuation in propositional logic?

A valuation is an assignment (or mapping) of each propositional variable to either the truth value "true" or the truth value "false".

Can you evaluate $((A \land B) \lor C)$ when $A$ is true, $B$ is true, but $C$ is false?

If we evaluate $(A \land B)$ we get the truth value 'true' because a conjunction is 'true' if the two operands are 'true'. Then we evaluate $(\text{true} \lor C)$ to finally get a 'true' value, as at least one operand needs to be 'true' for the disjunction to evaluate to 'true'. Using a truth table will be much more efficient than to explain with words.

Overview

Objectives

The main objectives of this project include:

  1. Understanding what truth tables are and how they are built.
  2. Implementing a truth table generator that expects a wff as input.
  3. Implementing a truth table visualizer to display a table in a suitable format.
This figure illustrates a well-formed formula (wff) mapped to its corresponding truth table. The wff serves as the input to the truth table builder, with the resulting truth table visualized on the right.

Figure 1. Wff to its truth table. This figure illustrates a well-formed formula (wff) mapped to its corresponding truth table. The wff serves as the input to the truth table builder, with the resulting truth table visualized on the right.

By achieving these objectives, we aim to deepen our understanding of compound proposition evaluation, while also developing a versatile tool that can serve multiple purposes.