Conjunction and Disjunction

We have already seen negation in propositional logic (¬). Negation flips a truth value from true to false, or from false to true. In this section we will look at two more logical operators: conjunction () and disjunction ()

Six-minute video

You can also view this video on YouTube

You can find the slides here and also as .odp.


Key Points

  • A truth table is a way of writing out all the possible values for a logical expression.
  • In a truth table, you write every combination of values for the atomic propositions in an expression, then work out from these the values for the expression as a whole - or, if the expression is complicated, each step in working it out.
  • Conjunction is the logical version of “and”. A conjunction p∧q is true if and only if both p and q are true, otherwise it is false.
  • Disjunction is the logical version of “or”. A disjunction p∧q is false if and only if both p and q are false, otherwise it is true.

Truth table for conjunction

p q p∧q
T T T
T F F
F T F
F F F

Truth table for disjunction

p q p∨q
T T T
T F T
F T T
F F F

Logical operators in Python

In Python many statements resolve to either True or False. For example a == 0 is such a statement. We might use them in an if statement, such as:

if (a == 0)
    print ("A is zero")

We can combine such statements using logical operators. In Python we use and for the logical operator (conjunction). For example (a == 0) and (b < 7). This is only true if both a == 0 and b < 7 are true.

For disjunction (v) we use or, such as in: (a == 0) or (b < 7). This is true if either a == 0 or b < 7 are true (or both).

For negation (¬) we use not, such as not (a == 0)

In other languages these are commonly represented by the symbols &&, || and ! respectively, such as in Java.


Questions

1. Check your understanding

Work out the truth value for the following conjunctions:

1. Conjunction

Calculate the truth values for the following logical propositions:

  Expression True False  
1.
2.
3.
4.
5.

Check Answers

2. Disjunction

Work out the truth value for the following disjunctions:

  Expression True False  
1.
2.
3.
4.
5.
6.

Check Answers

3. Truth tables

Create truth tables below, using the following example as a guide

Truth table for ¬(p∧q):
p q p∧q ¬(p∧q)
T T T F
T F F T
F T F T
F F F T
Truth table for ¬(p∨q):
p q p∨q ¬(p∨q)
T T
T F
F T
F F

Check Answers

Truth table for (¬p) ∨ (¬q):
p q ¬p ¬q (¬p) ∨ (¬q)
T T
T F
F T
F F

Check Answers

4. Exclusive Or

The Exclusive or operator has the following truth table:

p q p⊕q
T T F
T F T
F T T
F F F

Calculate the truth values for the following logical propositions:

  Expression True False  
1.
2.
3.
4.
5.

Check Answers


Summary

In this section we have learned four more logical operators: conjunction (), disjunction ().

  • You should be able to construct truth tables for logical statements from the truth values of their component propositions.
  • You should be able to use conjunction, disjunction, and negation, and recognise their symbols.
  • You should be able to write out the truth tables for conjunction, disjunction, and negation.

In the next section we will find out about two more logical operators implication, and equivalence.