✖

Propositional logic examples

In this article we look at a few formulae and their possible assignments using the truth table method.

First example

Let’s find out when this formula is true: ϕ = (p ∧ q) ∨ ¬q. We write the propositional variables p and q in a table:

pq11100100

Next we add the first part of the formula to the table: (p ∧ q), then the negation ¬q, and then the whole formula:

pqp∧q¬qϕ11100100

Now we work out the values for the third column, which is a simple conjunction, and also for the negation – there we just put the opposite of the values in the second column:

pqp∧q¬qϕ1110100101000001

Finally we work out the values in the last column. This is the whole formula. In terms of our table, we are calculating the disjunction “between the third and fourth columns”. The result:

pqp∧q¬qϕ11101100110100000011

Second example

Same task, different formula: ϕ = (p ∧ ¬q) ⇔ (¬p ⇒ q). We can see that the formula contains the propositional variables p and q and their negations. So first we create a table with the two variables and their negations:

pq¬p¬q1100100101100011

Next we add the formulae p ∧ ¬q and ¬p ⇒ q, which we can now evaluate easily, because the table contains both the assignments of the individual statements and of their negations. The table looks like this:

pq¬p¬q(p∧¬q)(¬p⇒q)110001100111011001001100

Last, we need to evaluate the whole formula, which is the biconditional between the last two columns:

pq¬p¬q(p∧¬q)(¬p⇒q)ϕ1100010100111101100100011001

Third example

The third example is a little harder: we will try three propositional variables, which makes the table more complicated to fill in. The formula is: ϕ = (¬(p ⇒ q)) ∧ (r ⇔ (¬p ∨ q)).

Because there are three propositional variables, the total number of possible assignments is eight:

pqr111110101100011010001000

From here on we proceed as in the previous case and fill in each column in all eight rows. The whole table looks like this:

pqr¬p(p⇒q)(¬p∨q)¬(p⇒q)(r⇔(¬p∨q))ϕ111011010110011000101000100100000111011111010010111000001111010000111000

Fourth example

This time we won’t give an ordinary formula but a word problem. Three friends who want to go to a wild party, where topless models will be handing out refreshments, don’t quite like each other and set conditions under which they will go to the party. Their names are Max, Jack and Paul. The rules are as follows:

  1. If Max goes, then Jack will go too.
  2. Paul will come to the party or, if Max comes, Jack won’t come.
  3. Paul will come if and only if Max doesn’t come or Jack doesn’t come.

The question is: can all of them come to the party? If not, who can go to the party without breaking any of the rules?

First we need to rewrite the statements above using propositional variables and formulae. Let’s denote the propositional variables M, J and P (Max, Jack, Paul); each always stands for a statement such as “Max will go to the party”. We could rewrite the first rule like this: M ⇒ J – “if M, then J”, or “if Max goes to the party, then Jack will go to the party”.

We would rewrite the second rule like this. The rule begins with the sentence “Paul will come to the party or…”, so we clearly need a disjunction. For now we write: P ∨ … The next part of the sentence says: “if Max comes, Jack won’t come”. That is an implication, and on the right-hand side we also need a negation: “Jack won’t come” = ¬J. The whole implication would look like this: M ⇒ ¬J. We attach it to the earlier disjunction: P ∨ (M ⇒ ¬J).

We rewrite the third rule like this: we start with “Paul will come if and only if”. That means a biconditional: P ⇔ … Next we have “Max doesn’t come or Jack doesn’t come”, which we rewrite as ¬M ∨ ¬J. Putting it together: (P ⇔ (¬M ∨ ¬J)).

Now we put all the formulae into a table and work out the values:

MJP(M⇒J)(P∨(M⇒¬J))(P⇔(¬M∨¬J))111110110101101011100010011111010110001111000110

The question was whether all three boys can go to the wild party. We find the answer in the first row. It covers the case where all the boys go – this is shown by the three ones in the first three columns. Are all the conditions met? The first is met (fourth column), so is the second (fifth column), but the last is not (last column), where there is a zero. This means that if all three go, the third condition will not be met.

So we look for the rows in which the positions representing the conditions (that is, the last three columns) are all ones. A one means that the condition is met. We can see that this happens in two cases: when Jack and Paul go but Max doesn’t, and when only Paul goes.

You can also work it out by adding to the table a formula ϕ, which will be the conjunction of all three conditions. It looks like this: ϕ = ((M ⇒ J) ∧ (P ∨ (M ⇒ ¬J)) ∧ (P ⇔ (¬M ∨ ¬J))). This represents what we want – for all the formulae (all the conditions) to be satisfied. The table would then look like this:

MJP(M⇒J)(P∨(M⇒¬J))(P⇔(¬M∨¬J))ϕ11111001101010101011010001000111111010110000111110001100

A few more examples of the truth table method

Because I wrote a program that can automatically build the whole table from a given formula, I have to make good use of it, so here are a few more solved formulae:

Formula: ((a ∧ ¬b) ∨ (b ∧ (b ⇒ a))). Table:

ab(a∧¬b)(b∧(b⇒a))((a∧¬b)∨(b∧(b⇒a)))11011101010100000000

Formula: (a ∨ ¬a) ⇔ (b ∧ ¬b). Table:

ab(a∨¬a)(b∧¬b)((a∨¬a)⇔(b∧¬b))11100101000110000100

Formula: ¬(a ∨ b) ⇔ (¬b ∧ ¬a). Table:

ab¬(a∨b)(¬b∧¬a)(¬(a∨b)⇔(¬b∧¬a))11001100010100100111

Formula: ϕ = (¬p ⇔ (q ∧ r)) ⇒ (p ∨ ¬(p ∧ q)). Table:

pqr(q∧r)¬(p∧q)(¬p⇔(q∧r))(p∨¬(p∧q))ϕ1111001111000111101011111000111101111111010010110010101100001011

Formula: ϕ = ¬(p ⇔ ¬q) ∧ (r ⇒ ¬p) ∧ (p ∨ r). Table:

pqr¬(p⇔¬q)(r⇒¬p)(p∨r)ϕ11110101101111101001010001100110110010010000111110001100

Chapters: Propositional logic, Truth values of formulae, Propositional logic examples