5 Semantics of propositional logic
To give a meaning to well-formed formulas, we will construct a set of truth values \(\mathcal{B}\) and a function \[ \mathrm{eval}: \mathrm{Wff} \to \mathcal{B}. \]
In fact, we will restrict ourselves to the case when \(\mathcal{B} := \mathrm{bool} = \{ \mathrm{false}, \mathrm{true} \}\). These two possible truth values could also be denoted by \(\{0, 1\}\).
5.1 Evaluation of well-formed formulas
Recall that well-formed formulas are defined inductively, with constructors
- \(P : \mathbb{N} \rightarrow \mathrm{Wff}\)
- \(\neg : \mathrm{Wff} \to \mathrm{Wff}\)
- \(\wedge : \mathrm{Wff} \to \mathrm{Wff} \to \mathrm{Wff}\)
- \(\vee : \mathrm{Wff} \to \mathrm{Wff} \to \mathrm{Wff}\)
- \(\Rightarrow : \mathrm{Wff} \to \mathrm{Wff} \to \mathrm{Wff}\)
- \(\Leftrightarrow : \mathrm{Wff} \to \mathrm{Wff} \to \mathrm{Wff}\)
so we can define a function out of \(\mathrm{Wff}\) by pattern matching on the constructors (primitive recursion).
5.1.1 Valuations
The first case is that of so-called atomic formulas, meaning well-formed formulas \(F\) of the form \(F = P_i\) for some natural number \(i : \mathbb{N}\). In practice, what we want here is to define \(\mathrm{eval}(P_i)\) for all \(i\). The constructor’s name \(P\) is not relevant here: what we want is a function \(\nu : \mathbb{N} \to \mathrm{bool}\), with the same domain as \(P\). Then we can use this function to set \(\mathrm{eval}(P_i) := \nu(i)\) for all \(i\).
For convenience, in these notes we will think of the set of atomic formulas as a subset of the set of well-formed formulas \[ \mathcal{A} := \{P_0, P_1, \ \ldots\ \} \subset \mathrm{Wff} \] so we are able to identify \(\nu : \mathbb{N} \to \mathrm{bool}\) and \(\mathrm{eval}|_{\mathcal{A}} : \mathcal{A} \to \mathrm{bool}\).
Definition. A function \(\nu : \mathcal{A} \to \mathrm{bool}\) will be called a valuation for \(\mathcal{A}\).
A valuation assigns a truth value to every atomic formula. In our case, the possible truth values are \(\mathrm{true}\) and \(\mathrm{false}\), but this is arbitrary. In particular, we could have more than two truth values (take for instance \(\mathcal{B} := \{ \mathrm{false}, \mathrm{undefined}, \mathrm{true} \}\)).
Suppose we are given a valuation \(\nu : \mathcal{A} \to \mathrm{bool}\). Then we want to construct an extension \(\widehat{\nu} : \mathrm{Wff} \to \mathrm{bool}\) of \(\nu\), meaning a function \(\widehat{\nu}\) from \(\mathrm{Wff}\) to \(\mathrm{bool}\) such that \(\widehat{\nu}|_{\mathcal{A}} = \nu\). To achieve this, it suffices to carry on with the pattern matching and define:
- Given a well-formed formula \(F\), a boolean \(\widehat{\nu}(\neg F)\), and
- Given well-formed formulas \(F\) and \(F'\), a boolean \(\widehat{\nu}(F \diamond F')\) for every binary constructor \(\diamond \in \{\wedge, \vee, \Rightarrow, \Leftrightarrow\}\).
In this process, we are allowed to consider that \(\widehat{\nu}(F)\) and \(\widehat{\nu}(F')\) are already defined (recursion principle).
5.1.2 Negation
Let \(F\) be a well-formed formula. We want to define \(\widehat{\nu}(\neg F) : \mathrm{bool}\), assuming that \(\widehat{\nu}(F) : \mathrm{bool}\) has already been defined. The natural thing to do is to set
\[\widehat{\nu}(\neg F) := ! \widehat{\nu}(F)\]
where \(! b\) is the negation of the boolean \(b\) (meaning that \(!b = \mathrm{false}\) if \(b = \mathrm{true}\) and \(!b = \mathrm{true}\) if \(b = \mathrm{false}\)). This is precisely the function negb : bool -> bool that we defined in the introduction to pattern matching.
So, to interpret the function\(\neg : \mathrm{Wff} \to \mathrm{Wff}\), we have used a function \(! : \mathrm{bool} \to \mathrm{bool}\), replacing \(\mathrm{Wff}\) by \(\mathrm{bool}\) everywhere it appears in the type signature of \(\neg\) (which here is both domain and codomain). We will proceed similarly for other constructors.
5.1.3 Binary constructors
To define \(\widehat{\nu}(F \diamond F')\) for each binary constructor \(\diamond \in \{ \wedge, \vee, \Rightarrow, \Leftrightarrow \}\), we proceed as follows. As a function, the binary constructors have type signature \[ \diamond : \mathrm{Wff} \to \mathrm{Wff} \to \mathrm{Wff}\ , \] so to interpret them we will use a function \([\diamond] : \mathrm{bool} \to \mathrm{bool} \to \mathrm{bool}\), and set \[ \widehat{\nu}(F \diamond F') := \widehat{\nu}(F)\ [\diamond]\ \widehat{\nu}(F'). \] Since we are proceeding recursively, this is sufficient to compute \(\widehat{\nu}(F \diamond F')\) as soon as \(\widehat{\nu}(F)\) and \(\widehat{\nu}(F')\) are known.
The binary constructors \(\wedge, \vee, \Rightarrow, \Leftrightarrow\) will be interpreted, respectively, by the functions andb, orb, implb and eqb, which we have introduced in the lecture on pattern matching. We will use the following notation for boolean operations.
- \(\widehat{\nu}(F \wedge F') := \widehat{\nu}(F)\ \&\negmedspace\&\ \widehat{\nu}(F')\)
- \(\widehat{\nu}(F \vee F') := \widehat{\nu}(F)\ ||\ \widehat{\nu}(F')\)
- \(\widehat{\nu}(F \Rightarrow F') := \widehat{\nu}(F) \preccurlyeq \widehat{\nu}(F')\)
- \(\widehat{\nu}(F \Leftrightarrow F') := \widehat{\nu}(F) = = \widehat{\nu}(F')\)
Note that if we think of \(\mathrm{bool}\) as \(\{0, 1\}\) (equipped with the usual ordering \(0 \leqslant 1\), an addition law \(+\) such that \(1 + 1 = 0\), and a multiplication law \(\times\)), then we can also use the following notation:
- \([\neg] b := 1 + b\)
- \(b\ [\wedge]\ b' := \min(b, b')\)
- \(b\ [\vee]\ b' := \max(b,b')\)
- \(b\ [\Rightarrow]\ b' := 1 + x \times y + x\)
- \(b\ [\Leftrightarrow]\ b' := b == b'\)
With this we have defined a function \(\widehat{\nu} : \mathrm{Wff} \to \mathrm{bool}\) by primitive recursion. Note that part of it is entirely mechanical: the interpretation \([\diamond]\) of the constructors \(\neg, \wedge, \vee, \Rightarrow\) and \(\Leftrightarrow\) does not depend on the valuation \(\nu : \mathcal{A} \to \mathrm{bool}\). So what we have seen above is a procedure to construct an evaluation/interpretation function \(\widehat{\nu} : \mathrm{Wff} \to \mathrm{bool}\) from a valuation \(\nu : \mathcal{A} \to \mathrm{bool}\). \[ \begin{array}{rcl} (\mathcal{A} \to \mathrm{bool}) & \longrightarrow & (\mathrm{Wff} \to \mathrm{bool}) \\ \nu & \longmapsto & \widehat{\nu} \end{array} \] We will come back to this later when we discuss recursion principles in further generality.
5.1.4 Example
Let \(P\) and \(Q\) be atomic formulas and let \(F := (P \vee Q) \wedge \neg P\). What are the possible truth values for \(F\) (in \(\mathrm{bool}\))? Meaning, what is \(\widehat{\nu}(F)\) as a function of \(\nu\)?
For instance, if \(\nu(P) = \mathrm{false}\) and \(\nu(Q) = \mathrm{true}\), what does \(\widehat{\nu}(F)\) compute to? \[ \begin{array}{rcl} \widehat{\nu}(F) & = & \widehat{\nu}\big( (P \vee Q) \wedge \neg P \big) \\ & = & \widehat{\nu}(P \vee Q)\ \& \negmedspace\&\ \widehat{\nu}(\neg P) \\ & = & \big( \nu(P)\ ||\ \nu(Q) \big) \ \& \negmedspace\&\ !\nu(P) \\ & = & \big( \mathrm{false}\ ||\ \mathrm{true} \big)\ \&\negmedspace\&\ !\mathrm{false}\\ & = & \mathrm{true}\ \&\negmedspace\&\ !\mathrm{true}\\ & = & \mathrm{true} \end{array} \]
We can compute similarly for other values of \(\nu(P)\) and \(\nu(Q)\) and store the result in a truth table for \(F\). \[ \begin{array}{c|c|c|c|c} \nu(P) & \nu(Q) & \widehat{\nu}(P \vee Q) & \widehat{\nu}(\neg P) & \widehat{\nu}\big((P \vee Q) \wedge \neg P\big) \\ \hline \mathrm{false} & \mathrm{false} & \mathrm{false} & \mathrm{true} & \mathrm{false} \\ \mathrm{false} & \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{true} \\ \mathrm{true} & \mathrm{false} & \mathrm{true} & \mathrm{false} & \mathrm{false} \\ \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{false} & \mathrm{false} \end{array} \]
Note that:
- There are as many columns in the truth table of \(F\) as there are subformulas in \(F\).
- If \(F\) has \(n\) atomic subformulas, the truth table of \(F\) has \(2^n\) rows (since each atomic formula can assume two different boolean values).
- We are labelling the columns using \(\nu(P)\), \(\nu(Q)\), \(\widehat{\nu}(P \vee Q)\), … , not just \(P\), \(Q\), \(P \vee Q\), … , to emphasise that the truth table depends on an evaluation procedure of well-formed formulas. Here we have chosen to interpret well-formed formulas as booleans, in a standard way.
Depending on the particular well-formed formula \(F\), we may be able to simplify the computation. For instance, in the example \(F := (P \vee Q) \wedge \neg P\) above, since \(\_\ \&\negmedspace\&\ \mathrm{true} = \mathrm{false}\) regardless of what appears in the placeholder “\(\_\)” , we have \(\widehat{\nu}(F) = \mathrm{false}\) as soon as \(\nu(P)= \mathrm{true}\).
5.2 Satisfiablity and validity
Definition. A well-formed formula \(F\) is called satisfiable if there exists a valuation \(\nu : \mathcal{A} \to \mathrm{bool}\) such that \(\widehat{\nu}(F) = \mathrm{true}\).
For example, the formula \(F := (P \vee Q) \wedge \neg P\) (where \(P\) and \(Q\) are atomic formulas) is satisfiable.
Observation. If \(\mathcal{B} := \{ \mathrm{false}, \mathrm{undefined}, \mathrm{true} \}\), we can decide if the only accepted truth value for satisfiability is \(\mathrm{true}\) or if \(\mathrm{undefined}\) is also acceptable. This will usually depend on the context, in particular the applications we may have in mind.
Definition. A well-formed formula \(F\) is called valid if for all valuation \(\nu : \mathcal{A} \to \mathrm{bool}\), one has \(\widehat{\nu}(F) = \mathrm{true}\). A valid formula is also called a tautology.
So a tautology is a compound formula whose truth value is always equal to \(\mathrm{true}\), regardless of the truth value of its subformulas.
For example, the formula \(F := (P \vee Q) \wedge \neg P\) seen above (where \(P\) and \(Q\) are atomic formulas) is not a tautology. In contrast, the formula \(F \Rightarrow \neg P\) is a tautology, as shown by the following truth table. \[ \begin{array}{c|c|c|c|c|c} \nu(P) & \nu(Q) & \widehat{\nu}(P \vee Q) & \widehat{\nu}(\neg P) & \widehat{\nu}\big((P \vee Q) \wedge \neg P\big) & \widehat{\nu}\big((P \vee Q) \wedge \neg P \Rightarrow \neg P\big) \\ \hline \mathrm{false} & \mathrm{false} & \mathrm{false} & \mathrm{true} & \mathrm{false} & \mathrm{true} \\ \mathrm{false} & \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{true} \\ \mathrm{true} & \mathrm{false} & \mathrm{true} & \mathrm{false} & \mathrm{false} & \mathrm{true} \\ \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{false} & \mathrm{false} & \mathrm{true} \end{array} \]
Theorem. A well-formed formula \(F\) is vlid if and only if \(\neg F\) is not satisfiable.
Proof. Exercise.
5.3 Logical equivalence
Let us discuss the notion of logical equivalence in the framework of Boolean semantics (meaning when a well-formed formula can only take one of two truth values, called \(\mathrm{true}\) and \(\mathrm{false}\), and the logical connectives \(\neg\), \(\wedge\), \(\vee\), \(\Rightarrow\) and \(\Leftrightarrow\) are interpreted via the Boolean operations \(!\), \(\&\negmedspace\&\), \(||\), \(\preccurlyeq\) and \(==\)).
Definition. The well-formed formulas \(F\) and \(F'\) are called logically equivalent if, for all valuation \(\nu : \mathcal{A} \to \mathrm{bool}\), one has \(\widehat{\nu}(F) = \widehat{\nu}(F')\).
Theorem. For all well-formed formulas \(F\) and \(F'\), the formula \(F \Leftrightarrow F'\) is logically equivalent to \((F \Rightarrow F') \wedge (F' \Rightarrow F)\).
Proof. We will compute the truth tables of \(F \Leftrightarrow F'\) and \((F \Rightarrow F') \wedge (F' \Rightarrow F)\) and see that they coincide.
First we compute \(\widehat{\nu}(F \Leftrightarrow F')\) as much as possible: \[ \widehat{\nu}(F \Leftrightarrow F') = \widehat{\nu}(F) == \widehat{\nu}(F') \]
The computation is now stuck: we have to pattern match on \(\widehat{\nu}(F)\) and \(\widehat{\nu}(F')\) to trigger a case analysis.
Next we compute \(\widehat{\nu} \big( (F \Rightarrow F') \wedge (F' \Rightarrow F) \big)\) \[ \begin{array}{rcl} \widehat{\nu} \big( (F \Rightarrow F') \wedge (F' \Rightarrow F) \big) & = & \widehat{\nu} (F \Rightarrow F')\ \&\negmedspace\&\ \widehat{\nu} (F' \Rightarrow F) \\ & = & \big( \widehat{\nu} (F) \preccurlyeq \widehat{\nu}(F') \big)\ \&\negmedspace\&\ \big( \widehat{\nu} (F') \preccurlyeq \widehat{\nu}(F) \big) \end{array} \] The computation is stuck again, we need to distinguish cases according to values of \(\widehat{\nu}(F)\) and \(\widehat{\nu}(F')\).
The truth tables of \(F \Leftrightarrow F'\) and \((F \Rightarrow F') \wedge (F' \Rightarrow F)\) are therefore given as follows, and the last column of the first table is indeed the same as the last column of the second table. \[ \begin{array}{c|c|c} \widehat{\nu}(F) & \widehat{\nu}(F') & \widehat{\nu}(F \Leftrightarrow F') \\ \hline \mathrm{false} & \mathrm{false} & \mathrm{true} \\ \mathrm{false} & \mathrm{true} & \mathrm{false} \\ \mathrm{true} & \mathrm{false} & \mathrm{false} \\ \mathrm{true} & \mathrm{true} & \mathrm{true} \end{array} \] \[ \begin{array}{c|c|c|c|c} \widehat{\nu}(F) & \widehat{\nu}(F') & \widehat{\nu}(F \Rightarrow F') & \widehat{\nu}(F' \Rightarrow F) & \widehat{\nu}\big((F \Rightarrow F') \wedge (F' \Rightarrow F)\big) \\ \hline \mathrm{false} & \mathrm{false} & \mathrm{true} & \mathrm{true} & \mathrm{true} \\ \mathrm{false} & \mathrm{true} & \mathrm{true} & \mathrm{false} & \mathrm{false} \\ \mathrm{true} & \mathrm{false} & \mathrm{false} & \mathrm{true} & \mathrm{false} \\ \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{true} & \mathrm{true} \end{array} \]
The set of valuations \(\nu : \mathcal{A} \to \mathrm{bool}\) that make a formula \(F\) (evaluate to) \(\mathrm{true}\) will be called the semantics of \(F\). \[ \mathrm{sem}(F) := \{ \nu : \mathcal{A} \to \mathrm{bool}\ |\ \widehat{\nu}(F) = \mathrm{true} \} = \{ \nu_0, \nu_1,\ ...\ \} \] In particular, the formula \(F\) is satisfiable if and only if \(\mathrm{sem}(F) \not= \emptyset\), and the formulas \(F\) and \(F'\) are logically equivalent if and only if they have the same semantics: \(\mathrm{sem}(F) = \mathrm{sem}(F')\). As an example, the semantics of the formula the formula \(F := (P \vee Q) \wedge \neg P\) are given by \(\nu_0 := \{ P \mapsto \mathrm{false}; Q \mapsto \mathrm{false} \}\). To conclude, we give the following characterisation of logically equivalent formulas, which can also be taken as a definition.
Theorem. Two well-formed formulas \(F\) and \(F'\) are logically equivalent if and only if \(F \Leftrightarrow F'\) is a tautology.
Proof. Exercise.
We will see in forthcoming lectures that there also exist purely syntactic methods to determine when is a given formula a tautology.