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 5.1 (Valuation) A function \(\nu : \mathcal{A} \to \mathrm{bool}\) will be called a valuation for atomic formulas.
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) \doteq \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 + b \times b' + b\)
- \(b\ [\Leftrightarrow]\ b' := 1 + b + b'\)
5.1.4 Boolean interpretations
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} \]
Definition 5.2 (Boolean interpretation of well-formed formulas) Let \(\nu : \mathcal{A} \to \text{bool}\) be a valuation for atomic formulas. The function \(\widehat{\nu} : \text{Wff} \to \text{bool}\) defined recursively by
- \(\widehat{\nu}(P_i) = \nu(P_i)\).
- \(\widehat{\nu}(\neg F) = !\widehat{\nu}(F)\).
- \(\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) \doteq \widehat{\nu}(F')\)
is called the interpretation of well-formed formulas associated to the valuation \(\nu\).
5.1.5 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{false} = \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 5.3 (Sematically satisfiable formulas) A well-formed formula \(F\) is called semantically satisfiable, or just 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.
If \(\mathcal{B} := \{ \mathrm{false}, \mathrm{undefined}, \mathrm{true} \}\), we can in principle 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 5.4 (Semantically valid formulas) A well-formed formula \(F\) is called semantically valid, or just valid, if for all valuation \(\nu : \mathcal{A} \to \mathrm{bool}\), one has \(\widehat{\nu}(F) = \mathrm{true}\). A semantically 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} \]
The following result establishes a formal relation between the validity of a well-formed formula \(F\) and the fact that its negation \(\neg F\) is not satisfiable, where by not satisfiable we mean (informally) that there does not exist a valuation \(\nu\) such that \(\widehat{\nu}(\neg F) = \text{true}\), or (more formally) that if such a valuation exists then we reach an absurdity. As a witness for absurdity, we can for instance choose the equality \(\text{false} = \text{true}\) in \(\text{bool}\). We will come back to this in the next lecture.
Theorem 5.1 A well-formed formula \(F\) is valid if and only if \(\neg F\) is not satisfiable.
Proof. Exercise.
5.3 Semantic equivalence
Let us discuss the notion of semantic equivalence of two well-formed formulas in the framework of Boolean semantics.
Definition 5.5 (Semantic equivalence) Let \(F\) and F’$ be well-formed formulas. Then \(F\) and \(F'\) are called semantically equivalent if, for all valuation \(\nu : \mathcal{A} \to \mathrm{bool}\), one has \(\widehat{\nu}(F) = \widehat{\nu}(F')\). We will denote the semantic equivalence relation by \(F \equiv F'\).
Note that \(F \equiv F'\) is not itself a well-formed formula; it is only an expression that indicates that two well-formed formulas are semantically equivalent! Let us give an example of semantically equivalent formulas.
Theorem 5.2 (Syntactic equivalence and double implication are semantically equivalent) For all well-formed formulas \(F\) and \(F'\), the formula \(F \Leftrightarrow F'\) is semantically 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) \doteq \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} \]
Note that whether two formulas are semantically equivalent depends on the choice of semantics. So far, we have been dealing exclusively with 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 \(\doteq\). If we interpret well-formed formula differently (with other truth values or a different interpretation of the connectives), formulas such as \(F \Leftrightarrow F'\) and \((F \Rightarrow F') \wedge (F' \Rightarrow F)\) may or may not remain semantically equivalent.
Definition 5.6 (Semantics of a well-formed formula) 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} \} \]
In particular, the formula \(F\) is satisfiable if and only if \(\mathrm{sem}(F) \not= \emptyset\), and the formulas \(F\) and \(F'\) are equivalent if and only if they have the same semantics: \[ F \equiv F'\ \text{if\ and\ only\ if}\ \mathrm{sem}(F) = \mathrm{sem}(F'). \] As an example, the semantics of the previously seen formula \(F := (P \vee Q) \wedge \neg P\) consist of only one valuation, namely \(\nu_0 := \{ P \mapsto \mathrm{false}; Q \mapsto \mathrm{false} \}\).
To conclude, we give the following characterisation of semantically equivalent formulas: semantic equivalence is “the same as” validity of syntactic equivalence.
Theorem 5.3 (Validity of syntactic equivalence) Let \(F\) and \(F'\) be well-formed formulas. Then \(F \equiv F'\) if and only if the well-formed formula \(F \Leftrightarrow F'\) is valid. In other words, \(F\) and \(F'\) are semantically 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.