7 minutes read

Logic is an area of mathematics concerned with truth and falsity. Suppose that you have two statements: the statement ''if it rains then the grass outside is wet'' and the statement ''it rains''. If you know that both of these statements are true, can you conclude that the statement ''The grass outside is wet'' must also be true? Intuitively we feel that this should be the case even though we have not even defined what being ''true'' should mean. Logic allows us to make this intuition precise. It gives us a framework to ask meaningful questions about the truth of statements and to answer them.

Logic also lies in the foundation of a bigger part of mathematics, it gives mathematicians rules to prove theorems. It is central to computer science where it is used both in hardware and software. For example, the processor in your computer probably contains billions of logic gates each of which performs some simple logic operation. When you, as a programmer, write a complicated if-statement, you are using logical connectives to combine elementary conditions. Logic also finds use in artificial intelligence, for instance, in automatic planning and scheduling, and plays a key role in computational complexity theory.

In this topic, we will start our exploration of logic by delving into the basics of propositional logic.

Truth values and propositions

There are only two possible truth values in classical logic: true and false, which correspond to 1 and 0, respectively. Either something is true or it is false but there is nothing in between.

A proposition is a statement that can be assigned a truth value. For instance, ''7 is a prime number'' and ''2 is greater than 3'' are propositions. The first one is true and the second one is false. That is, the truth value of the first proposition is 1 and the truth value of the second proposition is 0. In the case above, it was easy to assign truth values to the two propositions. In general, we do not require truth values of propositions to be known, we just require that they can be assigned. To give an example of something that is not a proposition, ''Good morning, Mr. Bond'' is not a proposition because we cannot meaningfully assign a truth value to a greeting.

Propositional logic does not ''see'' inside elementary propositions and treats them as atomic. Therefore we usually denote elementary propositions by letters, e.g. PP, QQ, RR, and call them propositional variables. We can, of course, still imagine that these letters represent some statements in natural language, such as ''it rains'', but we can safely abstract from it.

What this also means is that if we get a logic problem stated in English (or any other language), we will first need to do some work ourselves to represent it using propositional variables, and only then will we be able to use tools from propositional logic.

Conjunction

Logical connectives are similar to connectives that you know from English. They are used to connect logical propositions into more complex ones, much like connectives in English are used to connect clauses into more complex sentences. Here we start with the connective called a conjunction.

The conjunction is a logical connective that corresponds to the English ''and''. It is denoted by the symbol \land.

Take two propositional variables, say, PP and QQ. From them, you can construct the proposition PQP \land Q. For instance, if PP corresponds to the English sentence ''it rains'' and QQ corresponds to ''it is sunny'' then the proposition PQP \land Q corresponds to ''it rains and it is sunny''.

The truth value of the conjunction PQP \land Q is determined by the truth values of the propositions PP and QQ. The proposition PQP \land Q is true only when PP and QQ are both true. It is false in all the other cases: when PP is true and QQ is false, when PP is false and QQ is true and when PP and QQ are both false. That is, for instance, the proposition ''it rains and it is sunny'' would only be true if both ''it rains'' and ''it is sunny'' were true.

Intermezzo: Truth tables for logical connectives

When we introduced conjunction, we listed all cases when it is true and when it is false, based on the truth values of the propositions in it. There is a more convenient way to do this using what we call a truth table.

One such truth table for the proposition PQP \land Q is shown below.

PP QQ PQP \land Q
0 0 0
0 1 0
1 0 0
1 1 1

This truth table has three columns. The first two are for the truth values of the propositional variables PP and QQ. The third is for the truth value of the conjunction PQP \land Q.

For instance, the first row in our table is 0, 0, 0'' which means that when PP (the first ''0'') and QQ (the second ''0'') are both false then the proposition PQP \land Q is also false (the third ''0''). The second row is ''0, 1, 0'' which means that when PP is false and QQ is true then PQP \land Q is again false.

As you may probably agree, using truth tables is quite convenient. They are easy to read once you get used to them. Next, we will use truth tables to introduce other logical connectives.

Disjunction

Disjunction is the logical connective that corresponds to the English ''or''. It is denoted by the symbol \lor.

Below is the truth table for disjunction.

PP QQ PQP \lor Q
0 0 0
0 1 1
1 0 1
1 1 1

Consider the following English sentence: ''I will eat a cake or I will eat an ice cream.'' We can denote ''I will eat a cake'' by PP and ''I will eat an ice cream'' by QQ. We can now take a look at the proposition PQP \lor Q and some concrete cases from the truth table for this proposition.

First, we will look at the case when PP is false and QQ is false. Then PQP \lor Q is also false according to the truth table for disjunction. That can be interpreted in our example as: if I do not eat a cake and if I do not eat ice cream then the statement ''I will eat a cake or I will eat an ice cream'' is not true. Intuitively, this also corresponds to the meaning of ''or'' from everyday English. When we normally use ''or'', we mean that at least one of the statements should hold.

Second, we will consider the case from the last row of the truth table. Here, both PP and QQ are true. The disjunction PQP \lor Q is again true. In our example with cake and ice cream, this corresponds to the situation when I will eat both a cake and an ice cream. In everyday language, in situations like this we might oftentimes mean by ''or'' something closer to ''either… or...'' but in propositional logic, this is not the case. Disjunction PQP \lor Q is true when either one of PP and QQ is true or if both PP and QQ are true. So maybe if you happen to host a party for logicians in your future life, if they say that they want ice cream or a cake, you can give them both.

Negation

Negation is another logical connective. It is denoted by ¬\lnot. Unlike the two other connectives, conjunction and disjunction, negation does not connect two propositions, it applies to only one, e.g. we can have ¬P\lnot P. As its name suggests, negation ''flips the truth value of the proposition it is applied to. When PP is true, ¬P\lnot P is false and when PP is false then ¬P\lnot P is true.

The truth table of negation is rather simple and is shown below.

PP ¬P\lnot P
0 1
1 0

For instance, when PP corresponds to the English statement ''the grass is green'', its negation ¬P\lnot P corresponds to the statement ''the grass is not green''.

Building more complex propositions

Now that we have learned about conjunction, disjunction, and negation, we can use them to construct more complex propositions. For that, we can also use brackets and the constants 1 and 0.

The following are examples of propositions: PP, PQP \lor Q, (PQ)R(P \lor Q) \land R, ¬(RS)\lnot (R \land S).

We can also construct truth tables for the more complex propositions. The truth value of a proposition is determined by the truth tables of the connectives involved and the truth values of the propositional variables. For instance, to compute the truth value of the proposition (PQ)R(P \lor Q) \land R when PP is true, QQ is false and RR is false, we first determine the truth value of the proposition PQP \lor Q, which is 1. Now what is left is to evaluate the expression 1R1 \land R, which is what we got after we replaced PQP \lor Q in (PQ)R(P \lor Q) \land R by 1. Since the truth value of RR is 0, the conjunction 1R1 \land R evaluates to 0.

Now we know how to compute truth values of more complex propositions. That means that we can also construct truth tables for them!

Here is an example. Consider again the proposition (PQ)R(P \lor Q) \land R. Here is its truth table.

PP QQ RR (PQ)R(P \lor Q) \land R
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1

Conclusion

In this topic, we got acquainted with the basics of propositional logic. The main take-away points from this topic are:

  • A proposition is a statement which can be assigned a truth value 0 (false) or 1 (true).
  • Propositional variables, e.g. PP, QQ, represent atomic propositions.
  • Conjunction, denoted \land, is the logical connective that corresponds to the English ''and''. The proposition PQP \land Q is true when both PP and QQ are true and false otherwise.
  • Disjunction, denoted \lor, is the logical connective that corresponds to the English ''or''. The proposition PQP\lor Q is true when at least one of PP and QQ is true and it is false when both of them are false.
  • Negation, denoted ¬\lnot, is the logical connective that corresponds to the English ''not''. The proposition ¬P\lnot P is true when PP is false and false when PP is true.
  • Propositions can be combined using logical connectives into more complex propositions.
21 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo