Propositional logic and truth table (CSCI 2824 Spring 2015)

In this lecture, we will cover the following concepts:

  1. Propositional Logic, Connectives and Truth Tables.

  2. The truth table to analyze situations.

  3. Equivalence of Formulae, Tautologies and Fallacies.

This lecture corresponds to section 1.3 in Ensley and Crawley's book.

Logic

In a very crude sense, logic is the assembly language of mathematics (or philosophy). Logic can be defined as the study of reasoning itself or the study of techniques for drawing valid conclusions from premises. Understanding Logic is very important to computing at many levels. For instance, propositional Logic and propositional connectives such as AND, OR and NOT form the basic building block of digital circuits from which we build modern computers. Logic is also key to areas of CS such as automata theory, programming language semantics and artificial intelligence.

Propositional Logic

What are propositions? Propositions are simply declarative statements that are either true or false, but not both.

Examples of propositions:

  • “Socrates is mortal”.

  • “Jenny went to lunch with Craig”.

  • “1+1=2”.

  • “I am telling the truth”.

  • “The quick brown fox jumped over the lazy brown dog”.

  • “If 2+2=5, then I am the richest man on earth”.

While studying propositional logic, we do not really care about what the proposition itself “means” just that it is either true or it is false.

Therefore, we simply use propositional variables (also called Boolean variables) to represent propositions. Why this? Just makes it nice and algebra like. Proposition variables can take on boolean values, i.e., T (true) or F (false).

We use letters like p,q,r and so on to represent proposition variables.

Propositional Logic Formulae

Formulae in propositional logic are defined as follows:

  • Any propositional variable is a formula.

  • Conjunction: If f_1 and f_2 are formulas, then f_1 land f_2 (read as f_1 AND f_2) is a formula.

  • Disjunction: If f_1 and f_2 are formulas, then f_1 lor f_2 (read as f_1 OR f_2) is a formula.

  • Negation: If f is a formula then neg f (read as NOT f) is a formula.

Caution on “OR” operator

When we say ‘‘Either p OR q is true’’, we mean that at least one of the two propositions p, q is true. It could be that both of p and q are true. (See the definition in the textbook.)

This is different from the exclusive OR (written as XOR or oplus). For any propositions p and q, poplus q means “either p or q, but not both”.

Let us try some examples. Read the following propositional formulae aloud:

  • p

  • p land q

  • p lor r

  • p lor (q land neg r)

  • neg( r lor (p lor q lor neg r) ) .

Example

Consider the following two propositions:

  • p: It is rainy today.

  • q: It is sunny today.

Then:

p land q It is rainy and sunny today.
p lor q It is rainy or sunny today.
p land (lnot q) It is rainy and not sunny today.

Truth table

We evaluate propositional formulae using truth tables. For any given proposition formula depending on several propositional variables, we can draw a truth table considering all possible combinations of boolean values that the variables can take, and in the table we evaluate the resulting boolean value of the proposition formula for each combination of boolean values.

Truth Table for AND

p q  p land q
T T T
T F F
F T F
F F F

Each row represents some kind of a situation. For example, the top most row represents the situation when propositions p and q are both ’'true’’. Then we conclude that the formula p land q in this situation is also ’'true’’.

Logicians call these situations models. In this case, a Logician would say that the truth assignment {p rightarrow true, q rightarrow true } is a model of the formula (p land q). In other words, if you imagine a situation wherein the proposition p is true and the proposition q is true then in that situation formula p land q is true.

To avoid confusion let us use the term “situations” and “models”. We will formalize models later for first-order (predicate) logic.

Truth Table for OR

p q  p lor q
T T T
T F T
F T T
F F F

Can you write down all the models of p lor q (read p OR q)?

Does this correspond to your conception of lor (the logical connective OR)?

Truth Table for NOT

p neg p
T F
F T

Truth Table for Compound Formulae

XOR is an important derived connective that is defined in terms of land, lor, neg. It has the interpretation of “either-or”: i.e, either p or q, but not both.

p XOR q is the formula  (p land neg q) lor (neg p land q).

Its truth table can be written as below:

p q p land neg q neg p land q p XOR q
T F T F T
T T F F F
F T F T T
F F F F F

We will go through few more examples of truth tables in the book.

Other examples of derived connectives are:

  • Implication p Rightarrow q is defined as  neg p lor q (we will study this in detail next week).

  • Equivalence  p Leftrightarrow q is defined as  ( p land q) lor (neg p land neg q).

  • Nand (a.k.a not of and) p mbox{NAND} q is defined as neg (p land q).

  • NOR (a.k.a not of or) p mbox{NOR}  q is defined as neg (p lor q)

  • XOR (exclusive or) p mbox{XOR} q is defined as (plor q) land (neg(pland q)).

Let us write the truth table for the Leftrightarrow connective (equivalence connective):

p q p land q neg p land neg q p Leftrightarrow q
T F F F F
T T T F T
F T F F F
F F F T T

Tautology, Fallacies and Equivalence

Tautology

A formula is a tautology if and only if it is true no matter what value one gives to the propositions involved in the formula.

Example is p lor neg p.

p neg p p lor neg p
T F T
F T T

No matter what you value one gives p, the formula p lor neg p is always true.

Other examples of tautology are

  •  (neg (p land q)) Leftrightarrow  (neg p lor neg q) (De Morgan's Law).

  •  (p land neg q) lor p (also written as (p Rightarrow q) Rightarrow p).

  •  ((p Rightarrow q) Rightarrow r) Rightarrow ((p Rightarrow r) Rightarrow (q Rightarrow r)) (do not even try expanding this :-)

Fallacies

Fallacies are the opposite of tautologies. These are formulae that are false no matter what the truth values of the propositions in them.

Example: p land neg p.

p neg p p land neg p
T F F
F T F

If we take a tautology and negate it then it becomes a fallacy.

Therefore neg (p lor neg p) is a fallacy.

Logical Equivalence

Two formulae are logically equivalent if and only if they have the same truth value in each row of the (joint) truth table. When two propositional formulae p and q are logically equivalent, we use the notation piff q or p equiv q.

Example:

The formulae F_1: neg(p land q) and F_2: neg p lor neg q are logically equivalent. To see why let us write their truth tables (we tack them together for convenience).

p q F_1: neg(p land q) F_2: neg p lor neg q
T T F F
F T T T
T F T T
F F T T

Notice that for all the truth table rows, F_1,F_2 coincide.

Examples of equivalent formulae include

  • p and neg neg p.

  • neg p and neg neg neg neg neg p.

  • neg (p lor q) and neg p land neg q (De-Morgan's law).

Technically, you need not assume that the formulae have the same set of propositions. For example, p land q and neg p are not logically equivalent. However, p land (q lor neg p) and p are logically equivalent.

Similarly, q land neg q and r land neg r are logically equivalent since they are both fallacies.

Example: De Morgan's laws

The De Morgan's laws are good examples of logically equivalent formulae: for any two proposition formulae p and q,

 begin{array}{rl}    lnot (p land q) & iff (lnot p) lor (lnot q),     lnot (p lor q) & iff (lnot p) land (lnot q). end{array}

Again, the equivalence can be provde using truth tables.

Theorem:

Statement of Theorem: Whenever two formulae F_1 and F_2 are equivalent then F_1 Leftrightarrow F_2 is a tautology.

Proof: Consider the truth table for the formula F_1 Leftrightarrow F_2 generated from a truth table that has a column for F_1 and a column for F_2 (as shown below).

p_1 p_2 cdots p_n F_1 F_2  F_1 Leftrightarrow F_2
T T cdots F F F T
vdots  vdots ddots vdots vdots vdots vdots
F F cdots T T T T

Note that for F_1 Leftrightarrow F_2 column to have a false entry at some row, F_1 and F_2 must have different values at that row. But since F_1 is logically equivalent to F_2, they always have the same value at each row.

As a result, the F_1 Leftrightarrow F_2 column must be all true, for all the rows in the truth table. Therefore it is a tautology.