Day 1: Truth in a model and semantic consequence

Today we see that a sentence is true or false only inside a model, and we define what it means for a sentence to follow from a set of sentences.

Syntax and semantics

Logic is the study of inference in language. If someone says a sentence, they are committed to more than that one sentence: a hearer will infer other sentences that follow from it. For example, from All of my friends can ride a bicycle and Sandy is my friend, the hearer infers Sandy can ride a bicycle. We want a precise, mathematical account of this kind of inference.

The first step is a distinction that runs through the whole course:

Here is a model. Let \(M = \{1,2,3,4,5,6,7,8\}\) and interpret three nouns as subsets of \(M\):

\([\![\mathit{runners}]\!] = \{1,2,3,4,5,6\},\qquad [\![\mathit{skiers}]\!] = \{1,4\},\qquad [\![\mathit{skaters}]\!] = \{2,4\}.\)

Figure 1 shows this model as a picture.

M runners skiers skaters 1 4 2 3 5 6 7 8
Figure 1. The model with \(M = \{1,\dots,8\}\). The black oval is \([\![\mathit{runners}]\!]\), the blue oval is \([\![\mathit{skiers}]\!]\), the red oval is \([\![\mathit{skaters}]\!]\).
Definition: truth of All p are q in a model

Let \(\mathcal M\) be a model that interprets each noun \(p\) as a subset \([\![p]\!]\) of a set \(M\). The sentence All \(p\) are \(q\) is true in \(\mathcal M\), written \(\mathcal M \models \textit{All } p \textit{ are } q\), iff \([\![p]\!] \subseteq [\![q]\!]\), that is, iff every element of \([\![p]\!]\) is also an element of \([\![q]\!]\).

Otherwise the sentence is false in \(\mathcal M\), written \(\mathcal M \not\models \textit{All } p \textit{ are } q\). This happens exactly when some element of \([\![p]\!]\) is not in \([\![q]\!]\).

Example 1

Decide whether each sentence is true or false in the model of Figure 1.

(a) All skaters are runners.

(b) All runners are skiers.

(c) All skaters are skiers.

(d) All runners are runners.

Solution.

(a) True. \([\![\mathit{skaters}]\!] = \{2,4\}\) and both 2 and 4 belong to \([\![\mathit{runners}]\!] = \{1,\dots,6\}\). So \(\{2,4\} \subseteq \{1,\dots,6\}\).

(b) False. The element 3 is in \([\![\mathit{runners}]\!]\) but not in \([\![\mathit{skiers}]\!] = \{1,4\}\). One such element is enough to make the sentence false. (Elements 2, 5, 6 also work.)

(c) False. The element 2 is a skater but not a skier.

(d) True. Every set is a subset of itself, so \([\![\mathit{runners}]\!] \subseteq [\![\mathit{runners}]\!]\). In fact All \(x\) are \(x\) is true in every model, for every noun \(x\), for the same reason.

Important

The sentence All skaters are runners is not true or false on its own. The question "Is it true?" only makes sense after a model is given. Once the model is specified precisely, the truth value can be computed, even mechanically. Sentences are true or false in models.

Inference based on models

Logical reasoning is reasoning that works for all models. It cannot tell you what is true. It can tell you that, if certain assumptions are true, then certain conclusions are also true. Consider:

All sparrows are birds.
All birds are animals.
All sparrows are animals.

This inference does not depend on what sparrows, birds, and animals actually are. Replace the three nouns by any other nouns, or by nouns you have never heard of, and the argument still works: in every model where the two sentences above the line are true, the sentence below the line is also true. We now make this idea precise. First, some notation.

Notation: Greek letters

We use \(\varphi\) (phi), \(\psi\) (psi), \(\chi\) (chi) for sentences, and \(\Gamma\) (gamma), \(\Delta\) (delta) for sets of sentences. The word "sentence" changes meaning from one logical system to another; the definitions below are the same for all of them.

Definition 0.3: semantic consequence

Each logical system has its own definition of when a model \(\mathcal M\) satisfies a sentence \(\varphi\), written \(\mathcal M \models \varphi\). Let \(\Gamma\) be a set of sentences and \(\mathcal M\) a model.

  • \(\mathcal M \models \Gamma\) iff \(\mathcal M \models \varphi\) for every \(\varphi \in \Gamma\).
  • \(\Gamma \models \varphi\) iff for all models \(\mathcal M\): if \(\mathcal M \models \Gamma\), then \(\mathcal M \models \varphi\).

We read \(\Gamma \models \varphi\) as: every model of \(\Gamma\) is a model of \(\varphi\); or \(\Gamma\) logically (semantically) implies \(\varphi\); or \(\varphi\) is a semantic consequence of \(\Gamma\).

We write \(\Gamma \not\models \varphi\) when this fails. In plain terms: there is some model \(\mathcal M\) with \(\mathcal M \models \Gamma\) but \(\mathcal M \not\models \varphi\). Such a model is called a countermodel.

Example 2

Show that \(\{\textit{All } p \textit{ are } q,\ \textit{All } q \textit{ are } r\} \models \textit{All } p \textit{ are } r\).

Solution.

By Definition 0.3 we must consider an arbitrary model \(\mathcal M\) in which both assumptions are true and show that the conclusion is true there too.

Suppose \(\mathcal M \models \textit{All } p \textit{ are } q\) and \(\mathcal M \models \textit{All } q \textit{ are } r\). By the definition of truth, \([\![p]\!] \subseteq [\![q]\!]\) and \([\![q]\!] \subseteq [\![r]\!]\).

Take any \(x \in [\![p]\!]\). Then \(x \in [\![q]\!]\) by the first inclusion, and then \(x \in [\![r]\!]\) by the second. So \([\![p]\!] \subseteq [\![r]\!]\), which means \(\mathcal M \models \textit{All } p \textit{ are } r\).

Since \(\mathcal M\) was arbitrary, the consequence holds in every model. This is the sparrows argument above, with the nouns replaced by letters.

Example 3

Show that \(\textit{All } p \textit{ are } q \not\models \textit{All } q \textit{ are } p\).

Solution.

We need one countermodel: a model where the assumption is true and the conclusion is false.

Let \(M = \{1, 2\}\), \([\![p]\!] = \{1\}\), \([\![q]\!] = \{1, 2\}\).

The assumption holds: \(\{1\} \subseteq \{1,2\}\). The conclusion fails: \(2 \in [\![q]\!]\) but \(2 \notin [\![p]\!]\), so \([\![q]\!] \not\subseteq [\![p]\!]\).

One countermodel is enough, because \(\Gamma \models \varphi\) requires the conclusion to hold in every model of \(\Gamma\). Note that the model of Figure 1 would also work, with \(p = \mathit{skiers}\) and \(q = \mathit{runners}\).

Exercise 1

Self-check only. This exercise is not graded.

Let \(M = \{1,2,3,4,5,6,7\}\) with \([\![\mathit{cats}]\!] = \{1,2,3\}\), \([\![\mathit{pets}]\!] = \{1,2,3,5\}\), \([\![\mathit{dogs}]\!] = \{4,5\}\), \([\![\mathit{animals}]\!] = \{1,2,3,4,5,6\}\). Decide whether each sentence is true or false in this model.

Solution.

(a) True: \(\{1,2,3\} \subseteq \{1,2,3,5\}\). (b) False: 5 is a pet but not a cat. (c) False: 4 is a dog but not a pet. (d) True: \(\{4,5\} \subseteq \{1,\dots,6\}\). (e) True: \(\{1,2,3,5\} \subseteq \{1,\dots,6\}\). (f) False: 6 is an animal but not a pet.

Exercise 2

Self-check only. This exercise is not graded.

Give a countermodel showing that

\(\{\textit{All } p \textit{ are } q,\ \textit{All } r \textit{ are } q\} \not\models \textit{All } p \textit{ are } r.\)

Use \(M = \{1,2,3,4,5,6\}\). Enter each interpretation as a list of numbers separated by commas, for example 1, 3, 4. Leave a field empty for the empty set.

One solution.

\([\![p]\!] = \{1\}\), \([\![q]\!] = \{1,2\}\), \([\![r]\!] = \{2\}\). Both assumptions hold, since \(\{1\} \subseteq \{1,2\}\) and \(\{2\} \subseteq \{1,2\}\). The conclusion fails, since \(1 \in [\![p]\!]\) but \(1 \notin [\![r]\!]\). Many other countermodels work; the checker accepts any of them.

Formal proofs and informal proofs

A proof in mathematics is a piece of reasoning that convinces us that some assumptions imply a conclusion. It is written in a natural language, may use diagrams and citations, and often skips steps. It is informal.

A formal proof is a caricature of an informal proof. Its sentences come from a precise grammar, and its steps are applications of precisely stated rules. Two properties matter:

This looks paradoxical: we study meaning, yet the basic objects are checked without meaning. It is not a mistake. Syntax and formal proofs are mathematical objects that can be built and taken apart mechanically. Their connection to meaning is a separate result, and proving that connection is the main work of this course (you will see the first such result on Day 3).

Definition: a formal language given by an inductive definition

Start with atomic sentences \(p_0, p_1, p_2, \dots\). The set \(\mathsf T\) of terms of boolean algebra is the smallest set such that:

  1. every atomic sentence \(p_i\) is in \(\mathsf T\), and \(\mathrm T\) and \(\mathrm F\) are in \(\mathsf T\);
  2. if \(\varphi \in \mathsf T\), then \((\neg\varphi) \in \mathsf T\);
  3. if \(\varphi, \psi \in \mathsf T\), then \((\varphi \wedge \psi)\), \((\varphi \vee \psi)\), and \((\varphi \leftrightarrow \psi)\) are in \(\mathsf T\).

At this point these expressions do not mean anything. No semantics has been given. \(\mathsf T\) is only a precisely specified collection of strings.

Example 4

(a) Show that \((\neg(p_0 \wedge \mathrm F))\) belongs to \(\mathsf T\).

(b) Explain why the string \(p_0 \wedge\) does not belong to \(\mathsf T\).

Solution.

(a) We build the string using the clauses. \(p_0 \in \mathsf T\) and \(\mathrm F \in \mathsf T\) by clause 1. Then \((p_0 \wedge \mathrm F) \in \mathsf T\) by clause 3. Then \((\neg(p_0 \wedge \mathrm F)) \in \mathsf T\) by clause 2. Each step is a mechanical check of the form of the string; we never asked what \(\wedge\) or \(\neg\) means.

(b) \(\mathsf T\) is the smallest set closed under the three clauses. Every string produced by clause 2 or 3 begins with an opening parenthesis, and the strings from clause 1 are single symbols. The string \(p_0 \wedge\) is neither, so it is not produced by any clause and is not in \(\mathsf T\).

Day 2: Preorders and monotone functions

Today we study preorders, a kind of mathematical structure that will appear throughout the course, and functions between preorders that respect the order.

Preorders

Definition 0.4: preorder

A preorder is a pair \(\mathbb P = (P, \le)\), where \(P\) is a set and \(\le\) is a relation on \(P\) which is both reflexive and transitive.

  • Reflexivity: \(p \le p\) for all \(p \in P\).
  • Transitivity: for all \(p, q, r \in P\), if \(p \le q\) and \(q \le r\), then \(p \le r\).

A preorder is technically a pair, not a set. Following standard usage, we refer to it by the set when the order is clear.

Example 5 (Examples 0.5 and 0.6)

(a) The natural numbers \(\mathbb N = \{0, 1, 2, \dots\}\) with the usual ordering \(\le\).

(b) For any set \(X\), the set \(\mathcal P(X)\) of all subsets of \(X\), ordered by inclusion: \(A \le B\) iff \(A \subseteq B\).

Why these are preorders.

(a) Reflexive: \(n \le n\) for every natural number. Transitive: if \(n \le m\) and \(m \le k\) then \(n \le k\). The real numbers with the usual ordering form a preorder in the same way.

(b) Reflexive: every element of \(A\) is an element of \(A\), so \(A \subseteq A\). Transitive: if every element of \(A\) is in \(B\), and every element of \(B\) is in \(C\), then every element of \(A\) is in \(C\); so \(A \subseteq C\).

Example 6 (Example 0.7): relations that are not preorders

(a) \(A = \{a,b,c\}\) and \(R = \{(a,b), (b,c)\}\).

(b) \(\mathbb N\) with \(E = \{(n,m) : n - m \le 1\}\).

(c) \(\mathbb N\) with \(R = \{(n,m) : n < m\}\).

Solution.

(a) Not reflexive: \((a,a) \notin R\). Not transitive either: \((a,b) \in R\) and \((b,c) \in R\), but \((a,c) \notin R\). One failure is enough, so \((A,R)\) is not a preorder.

(b) Reflexive: \(n - n = 0 \le 1\). Not transitive: \((2,1) \in E\) since \(2-1 = 1\), and \((1,0) \in E\) since \(1-0=1\), but \((2,0) \notin E\) since \(2 - 0 = 2 > 1\). So \((\mathbb N, E)\) is not a preorder.

(c) Transitive: if \(n < m\) and \(m < k\) then \(n < k\). Not reflexive: \(0 < 0\) is false. So \((\mathbb N, R)\) is not a preorder.

Note the convention: we write \(\le\) only when we are working with a preorder. For an arbitrary relation we use a letter such as \(R\).

Hasse diagrams and equivalence in a preorder

Let \(P = \{a, b, c, d, e, f, g\}\) with the preorder \(\le\) whose full list of pairs is

\(a \le a,\ a \le b,\ a \le c,\ a \le d,\ a \le e,\ a \le f,\ a \le g,\ b \le b,\ b \le c,\ b \le e,\ b \le f,\ b \le g,\ c \le b,\ c \le c,\ c \le e,\ c \le f,\ c \le g,\)
\(d \le d,\ d \le e,\ d \le f,\ d \le g,\ e \le e,\ e \le f,\ e \le g,\ f \le e,\ f \le f,\ f \le g,\ g \le e,\ g \le f,\ g \le g.\)

Figure 2 shows the same preorder as a picture, called its Hasse diagram.

a b, c d e, f, g
Figure 2. Hasse diagram of the preorder on \(\{a,\dots,g\}\). Going up along lines means \(\le\). Elements drawn in one node are equivalent.

How to read the diagram:

Example 7

Using Figure 2, decide: (a) is \(d \le c\)? (b) is \(c \le g\)? (c) is \(g \le e\)? (d) is \(e \le a\)?

Solution.

(a) No. There is no upward path from \(d\) to the node of \(b,c\); the two middle nodes are not connected. In the list of pairs, \(d \le c\) does not appear.

(b) Yes. There is a line from the node \(b,c\) up to the node \(e,f,g\), and \(c\) and \(g\) are in those nodes. In the list, \(c \le g\) appears.

(c) Yes. \(g\) and \(e\) are in the same node, so \(g \le e\) and \(e \le g\); thus \(g \equiv e\).

(d) No. The path from \(a\) to \(e\) goes upward, not downward. \(e \le a\) is not in the list.

Definition 0.8: opposite and flattening

For any preorder \(\mathbb P = (P, \le)\):

  • The opposite preorder \(\mathbb P^{\mathrm{op}}\) has the same set \(P\), with \(p \le q\) in \(\mathbb P^{\mathrm{op}}\) iff \(q \le p\) in \(\mathbb P\).
  • The flattened preorder \(\mathbb P^{\flat}\) has the same set \(P\), with \(p \le q\) in \(\mathbb P^{\flat}\) iff \(p = q\).
Example 8 (Example 0.9): the preorder \(\mathbf 2\)

An important preorder for logic is \(\mathbf 2\), also called Bool. Its set is \(\{\mathrm T, \mathrm F\}\) and its order is \(\mathrm F \le \mathrm T\) (together with \(\mathrm F \le \mathrm F\) and \(\mathrm T \le \mathrm T\)). Figure 3 shows \(\mathbf 2\), its opposite, and its flattening.

Explanation.

In \(\mathbf 2^{\mathrm{op}}\) the order is reversed: \(\mathrm T \le \mathrm F\). So \(\mathrm T\) is now at the bottom.

In \(\mathbf 2^{\flat}\) no element is below another different element. The two nodes stand side by side without a line. Both \(\mathbf 2^{\mathrm{op}}\) and \(\mathbf 2^{\flat}\) are preorders: reversing an order or keeping only the reflexive pairs preserves reflexivity and transitivity.

FT TF TF 2 2 op 2 flat
Figure 3. Left: \(\mathbf 2\) with \(\mathrm F \le \mathrm T\). Middle: \(\mathbf 2^{\mathrm{op}}\). Right: \(\mathbf 2^{\flat}\), where the only order relations are \(\mathrm T \le \mathrm T\) and \(\mathrm F \le \mathrm F\).
Definition 0.10: product of two preorders

For preorders \(\mathbb P\) and \(\mathbb Q\), the product \(\mathbb P \times \mathbb Q\) has as its set the cartesian product \(P \times Q\), ordered by

\((p, q) \le (p', q')\) in \(\mathbb P \times \mathbb Q\) iff \(p \le p'\) in \(\mathbb P\) and \(q \le q'\) in \(\mathbb Q\).

Exercise 3

Self-check only. This exercise is not graded.

Enter a relation \(R\) on \(\{a, b, c\}\) that is reflexive but not transitive. Write the pairs separated by commas, for example (a,a), (a,b), (b,c).

One solution.

\(R = \{(a,a), (b,b), (c,c), (a,b), (b,c)\}\). Reflexive: all three pairs \((x,x)\) are present. Not transitive: \((a,b)\) and \((b,c)\) are in \(R\), but \((a,c)\) is not. Any relation with all three reflexive pairs and one missing "shortcut" works.

Exercise 4

Self-check only. This exercise is not graded.

Enter a preorder \(\le\) on \(\{a, b, c\}\) in which \(a \equiv b\) (that is, \(a \le b\) and \(b \le a\)) but \(a \le c\) is false. Same input format as Exercise 3.

One solution.

\(\{(a,a), (b,b), (c,c), (a,b), (b,a)\}\). It is reflexive and transitive (the only chains are \(a \le b \le a\) and \(b \le a \le b\), and \(a \le a\), \(b \le b\) are present). Here \(a \equiv b\) and \(c\) is not comparable to them. Adding \((c,a)\) and \((c,b)\) gives another correct answer: then \(c\) sits below the node \(a, b\).

Monotone and antitone functions

Definition 0.11: monotone and antitone functions

Let \(\mathbb P\) and \(\mathbb Q\) be preorders. A function \(f : P \to Q\) is

  • monotone if for all \(p, q \in P\): if \(p \le q\) in \(\mathbb P\), then \(f(p) \le f(q)\) in \(\mathbb Q\);
  • antitone if for all \(p, q \in P\): if \(p \le q\) in \(\mathbb P\), then \(f(q) \le f(p)\) in \(\mathbb Q\).
Important

To show that a function is not monotone, one pair \(p \le q\) with \(f(p) \le f(q)\) false is enough. To show that it is monotone, you must argue for all pairs. The same holds for antitone.

Example 9 (Example 0.12): functions from \(\mathbb N\) to \(\mathbb N\)

For each function, decide whether it is monotone, antitone, both, or neither.

(a) \(f(x) = x + 1\)

(b) \(g(x) = x^2 - 3x + 2\)

(c) \(h(x) = 577\)

(d) \(i(x) = x\)

(e) \(j(0) = 1\) and \(j(x) = 0\) for \(x > 0\)

Solution.

(a) Monotone: if \(n \le m\) then \(n + 1 \le m + 1\). Not antitone: \(0 \le 1\) but \(f(1) = 2 \le 1 = f(0)\) is false.

(b) Compute \(g(0) = 2\), \(g(1) = 0\), \(g(2) = 0\), \(g(3) = 2\). Not monotone: \(0 \le 1\) but \(g(0) = 2 \le 0 = g(1)\) is false. Not antitone: \(1 \le 3\) but \(g(3) = 2 \le 0 = g(1)\) is false. So \(g\) is neither.

(c) A constant function is both monotone and antitone: for any \(n \le m\), \(h(n) = 577 \le 577 = h(m)\) and also \(h(m) \le h(n)\). Every constant function has this property.

(d) The identity is monotone: \(n \le m\) gives \(i(n) = n \le m = i(m)\). It is not antitone: \(0 \le 1\) but \(1 \le 0\) fails.

(e) Antitone: take \(n \le m\). If \(n = 0\), then \(j(m) \le 1 = j(0)\) holds because \(j(m)\) is 0 or 1. If \(n > 0\), then \(m > 0\) too, and \(j(m) = 0 \le 0 = j(n)\). Not monotone: \(0 \le 1\) but \(j(0) = 1 \le 0 = j(1)\) fails.

Example 10 (Example 0.13): the four functions from \(\mathbf 2\) to \(\mathbf 2\)
\(f(\mathrm T)\)\(f(\mathrm F)\)
\(f_1\)TT
\(f_2\)TF
\(f_3\)FT
\(f_4\)FF

Which of these are monotone, and which are antitone?

Solution.

In \(\mathbf 2\) the only pair \(p \le q\) with \(p \ne q\) is \(\mathrm F \le \mathrm T\). Monotone means \(f(\mathrm F) \le f(\mathrm T)\); antitone means \(f(\mathrm T) \le f(\mathrm F)\). The reflexive pairs never cause a problem.

\(f_1\) (constant T) and \(f_4\) (constant F): both conditions hold, so both monotone and antitone.

\(f_2\) is the identity: \(f_2(\mathrm F) = \mathrm F \le \mathrm T = f_2(\mathrm T)\), so monotone. Antitone would need \(\mathrm T \le \mathrm F\), which is false.

\(f_3\) is negation, it flips the truth values: \(f_3(\mathrm T) = \mathrm F \le \mathrm T = f_3(\mathrm F)\), so antitone; not monotone.

Summary: \(f_1, f_2, f_4\) are monotone; \(f_1, f_3, f_4\) are antitone.

Example 11 (Example 0.14): the material conditional

The material conditional is the function \(\to : \{\mathrm T,\mathrm F\} \times \{\mathrm T,\mathrm F\} \to \{\mathrm T,\mathrm F\}\) defined by

\(\mathrm T \to \mathrm T = \mathrm T,\quad \mathrm T \to \mathrm F = \mathrm F,\quad \mathrm F \to \mathrm T = \mathrm T,\quad \mathrm F \to \mathrm F = \mathrm T.\)

Show that \(\to\) is monotone when taken as a function from \(\mathbf 2^{\mathrm{op}} \times \mathbf 2\) to \(\mathbf 2\).

Solution.

First we work out the order on \(\mathbf 2^{\mathrm{op}} \times \mathbf 2\). By Definition 0.10, \((p,q) \le (p',q')\) iff \(p \le p'\) in \(\mathbf 2^{\mathrm{op}}\) (that is, \(p' \le p\) in \(\mathbf 2\)) and \(q \le q'\) in \(\mathbf 2\). The first coordinate may go from T to F, and the second from F to T.

So \((\mathrm T,\mathrm F)\) is the bottom element, \((\mathrm F, \mathrm T)\) is the top, and \((\mathrm F,\mathrm F)\), \((\mathrm T,\mathrm T)\) are in the middle and not comparable with each other. This is the diamond in Figure 4.

Now apply \(\to\): the bottom \((\mathrm T,\mathrm F)\) goes to F, and the other three pairs go to T. Going up in the diamond, the value never goes from T down to F. Concretely, take any \(x \le y\) in the product. If \(x = (\mathrm T,\mathrm F)\), the value at \(x\) is F, and F is below every element of \(\mathbf 2\). Otherwise the value at \(x\) is T; then \(y \ne (\mathrm T, \mathrm F)\) because \((\mathrm T,\mathrm F)\) is the bottom, so the value at \(y\) is also T. In both cases the value at \(x\) is \(\le\) the value at \(y\). So \(\to\) is monotone.

Note that \(\to\) is not monotone from \(\mathbf 2 \times \mathbf 2\) to \(\mathbf 2\): there \((\mathrm F,\mathrm F) \le (\mathrm T, \mathrm F)\), but \(\mathrm T \le \mathrm F\) fails. Taking the opposite order in the first coordinate is exactly what makes the function monotone. This is the reason for the "op".

(T, F) (F, F) (T, T) (F, T) F T value F value T value T value T 2 2 op × 2
Figure 4. Left: the product \(\mathbf 2^{\mathrm{op}} \times \mathbf 2\), with the value of the material conditional written in green under each node. Right: the target preorder \(\mathbf 2\). Moving up on the left never moves down on the right.
Exercise 5

Self-check only. This exercise is not graded.

Let \(\mathbb C\) be the three-element chain \(\{0, 1, 2\}\) with \(0 \le 1 \le 2\) (usual order). Give a function \(f : \mathbb C \to \mathbb C\) that is monotone, not antitone, and not the identity.

One solution.

\(f(0) = 0\), \(f(1) = 0\), \(f(2) = 1\). Monotone: \(0 \le 0 \le 1\). Not antitone: \(1 \le 2\) but \(f(2) = 1 \le 0 = f(1)\) fails. Not the identity since \(f(1) \ne 1\). Any non-decreasing, non-constant function other than the identity is accepted; a constant function is rejected because constants are also antitone.

Composition

Let \(g : P \to Q\) and \(f : Q \to R\) be functions on preorders. The composition \(f \circ g : P \to R\) is defined by \((f \circ g)(p) = f(g(p))\): first apply \(g\), then apply \(f\) to the result.

Proposition 0.15

If \(f\) and \(g\) are both monotone, then so is \(f \circ g\).

Proof. Suppose \(p_1 \le p_2\) in \(P\). Since \(g\) is monotone, \(g(p_1) \le g(p_2)\) in \(Q\). Since \(f\) is monotone, \(f(g(p_1)) \le f(g(p_2))\) in \(R\). (This is the important step: monotonicity of \(f\) is applied to the pair \(g(p_1) \le g(p_2)\).) But \((f \circ g)(p_1) = f(g(p_1))\) and \((f \circ g)(p_2) = f(g(p_2))\), so \((f \circ g)(p_1) \le (f \circ g)(p_2)\). As \(p_1, p_2\) were arbitrary, \(f \circ g\) is monotone.

Example 12

Let \(g : \mathbb N \to \mathbb N\), \(g(x) = x + 1\), and \(f : \mathbb N \to \mathcal P(\mathbb N)\), \(f(n) = \{0, 1, \dots, n\}\), where \(\mathcal P(\mathbb N)\) is ordered by inclusion. Is \(f \circ g\) monotone?

Solution.

\(g\) is monotone (Example 9(a)). \(f\) is monotone: if \(n \le m\) then \(\{0,\dots,n\} \subseteq \{0,\dots,m\}\), because every number up to \(n\) is also a number up to \(m\).

By Proposition 0.15, \(f \circ g\) is monotone. Directly: \((f \circ g)(x) = \{0, 1, \dots, x+1\}\), and if \(x \le y\) then \(\{0,\dots,x+1\} \subseteq \{0,\dots,y+1\}\).

Day 3: The logic of identity, soundness and completeness

Today we go through a complete small logical system from start to finish: syntax, semantics, a proof system, and the two theorems that connect them.

Reminder

For any logical system: \(\mathcal M \models \Gamma\) means every sentence in \(\Gamma\) is true in \(\mathcal M\); \(\Gamma \models \varphi\) means every model of \(\Gamma\) is a model of \(\varphi\). A relation on a set is reflexive if every element is related to itself, and transitive if \(x\,R\,y\) and \(y\,R\,z\) imply \(x\,R\,z\).

Syntax and semantics

Syntax. We start with a collection of names, \(\mathrm{Names} = \{\mathit{Amina}, \mathit{Bao}, \mathit{Clarisse}, \mathit{Damir}, \dots\}\). We use letters \(a, b, c, \dots\) as variables over names. The sentences are the expressions \(a = b\), read "\(a\) is \(b\)", where \(a\) and \(b\) are names. There are no other sentences.

Semantics of the identity language

A model \(\mathcal M\) is a set \(M\) together with an interpretation function \([\![\ ]\!] : \mathrm{Names} \to M\). We define

\(\mathcal M \models a = b\) iff \([\![a]\!] = [\![b]\!]\).

The notions \(\mathcal M \models \Gamma\) and \(\Gamma \models a = b\) are then given by Definition 0.3.

Example 13 (Example 0.16)

Let \(M = \{1,2,3,4\}\), with \([\![a]\!] = 1\), \([\![b]\!] = 1\), \([\![c]\!] = 2\). Which of \(a = b\), \(a = c\), \(c = c\) are true in \(\mathcal M\)?

Solution.

\(\mathcal M \models a = b\), because \([\![a]\!] = 1 = [\![b]\!]\).

\(\mathcal M \not\models a = c\), because \([\![a]\!] = 1 \ne 2 = [\![c]\!]\).

\(\mathcal M \models c = c\), because \([\![c]\!] = [\![c]\!]\). This holds for every name in every model.

Two observations from Figure 5: two different names can refer to the same element, as in real life (\([\![\mathit{Superman}]\!] = [\![\mathit{Clark\ Kent}]\!]\)), and an element of the model need not have any name (here 3 and 4).

Names M abc 1234
Figure 5. The model of Example 13. The interpretation function sends \(a\) and \(b\) to 1, and \(c\) to 2. Elements 3 and 4 have no name.

Some semantic facts that follow directly from properties of equality between elements of a set:

  1. \(\models a = a\) (true in every model; here \(\Gamma\) is empty).
  2. \(a = b \models b = a\).
  3. \(a = b,\ b = c \models a = c\).
  4. \(b = c,\ d = a,\ a = c \models d = b\).

The goal is to characterize, for every set \(\Gamma\) of equations, exactly which single equations are semantic consequences of \(\Gamma\). We do this with a proof system.

The proof system \(\mathsf E\)

Definition 0.17: rules of the proof system \(\mathsf E\)
 
r
\(a = a\)
\(a = b\)
s
\(b = a\)
\(a = b\)
\(b = c\)
t
\(a = c\)

The rules are named for reflexivity (r), symmetry (s), and transitivity (t). Rule r has no premises: \(a = a\) may be written at any time.

A formal proof from \(\Gamma\) is a tree built with these rules, whose leaves are either sentences from \(\Gamma\) or instances of rule r. We write \(\Gamma \vdash a = b\) if there is such a tree with conclusion \(a = b\).

Example 14 (Example 0.18)

Show that \(b = c,\ d = a,\ a = c \vdash d = b\).

Solution.
\(d = a\)
\(a = c\)
t
\(d = c\)
\(b = c\)
s
\(c = b\)
t
\(d = b\)

Reading from the top: the leaves \(d = a\), \(a = c\), \(b = c\) are all in \(\Gamma\). Rule t combines \(d = a\) and \(a = c\) into \(d = c\). Rule s turns \(b = c\) into \(c = b\). Rule t combines \(d = c\) and \(c = b\) into \(d = b\).

Checking this proof requires no knowledge of what the names refer to. Each step only matches the shape of a rule.

Example 15

Show that \(a = c,\ b = c \vdash a = b\), and show that \(\vdash b = b\) (with no assumptions).

Solution.
\(a = c\)
\(b = c\)
s
\(c = b\)
t
\(a = b\)

Rule t needs the middle name to match: \(a = c\) and \(c = b\). The assumption is \(b = c\), so we first apply rule s to it. Then t gives \(a = b\).

For \(\vdash b = b\), the proof is a single application of rule r, with no premises. Its tree has only the conclusion \(b = b\).

Exercise 6

Self-check only. This exercise is not graded.

Build a formal proof tree showing \(b = a,\ b = c \vdash a = c\). The conclusion is fixed at the bottom. For each sentence choose how it is obtained (assumption from \(\Gamma\), rule r, s, or t); choosing s or t opens boxes for the premises above. Write sentences in the form a = b.

Solution.
\(b = a\)
s
\(a = b\)
\(b = c\)
t
\(a = c\)

Rule t needs premises of the shape \(a = x\) and \(x = c\) with the same middle name. The assumption \(b = a\) has the names in the wrong order, so rule s is applied to it first. Then \(a = b\) and \(b = c\) give \(a = c\) by rule t. Both leaves are assumptions from \(\Gamma\).

Equivalence relations

To prove completeness we need a general notion from mathematics.

Definition 0.19: equivalence relation

A relation \(E\) on a set \(X\) is an equivalence relation if:

  1. for all \(x \in X\), \(x\,E\,x\) (reflexive);
  2. for all \(x, y \in X\), if \(x\,E\,y\) then \(y\,E\,x\) (symmetric);
  3. for all \(x, y, z \in X\), if \(x\,E\,y\) and \(y\,E\,z\) then \(x\,E\,z\) (transitive).

For \(x \in X\), the equivalence class of \(x\) is \([x] = \{y \in X : x\,E\,y\}\). The quotient set \(X/E\) is the set of all equivalence classes.

Every equivalence relation is a preorder (it is reflexive and transitive). A preorder in which \(p \le q\) always implies \(q \le p\) is an equivalence relation.

Example 16 (Example 0.20)

Let \(X = \{1,2,3,4\}\) and

\(R_1 = \{(1,1),(1,2),(1,3),(2,1),(3,3),(3,4)\}\)
\(R_2 = \{(1,1),(2,2),(1,2),(2,1),(3,3),(4,4)\}\)
\(R_3 = \{(1,1),(2,2),(3,3),(1,2),(2,1),(1,3),(3,1),(2,3),(3,2),(4,4)\}\)

Which are equivalence relations? For those that are, find the equivalence classes and the quotient set.

Solution.

\(R_1\) is not reflexive: \((2,2) \notin R_1\). So it is not an equivalence relation. (It is not symmetric either: \((3,4) \in R_1\) but \((4,3) \notin R_1\).)

\(R_2\) is reflexive (all four pairs \((x,x)\) are present), symmetric (the only non-reflexive pairs are \((1,2)\) and \((2,1)\), each other's reverse), and transitive (the only chains are like \(1\,R_2\,2\), \(2\,R_2\,1\), giving \(1\,R_2\,1\), which is present). So \(R_2\) is an equivalence relation. Classes: \([1] = \{1,2\} = [2]\), \([3] = \{3\}\), \([4] = \{4\}\). Quotient: \(X/R_2 = \{\{1,2\}, \{3\}, \{4\}\}\), often written \(\{[1],[3],[4]\}\).

\(R_3\) relates every pair among \(1,2,3\) in both directions, and \(4\) only to itself. Reflexivity, symmetry, and transitivity all hold. Classes: \([1] = [2] = [3] = \{1,2,3\}\) and \([4] = \{4\}\). Quotient: \(X/R_3 = \{\{1,2,3\}, \{4\}\}\).

Example 17 (Remark 0.21): definitions on quotient sets must be independent of representatives

Let \(X = \{0, 1, \dots, 23\}\) (the hours of a day) and let \(x\,R\,y\) iff \(x \bmod 12 = y \bmod 12\). Define \([x] + [y] = [\,(x + y) \bmod 12\,]\). Is this a proper definition?

Solution.

\(R\) is an equivalence relation: it compares the values \(x \bmod 12\), and equality of values is reflexive, symmetric, and transitive. The classes are \([0] = \{0, 12\}\), \([1] = \{1, 13\}\), and so on; the quotient is \(\{[0], [1], \dots, [11]\}\), the 12-hour clock.

The concern: \([3] + [11]\) is defined through the numbers 3 and 11, but \([3] = [15]\) and \([11] = [23]\). If we had chosen 15 and 23 as representatives, we would compute \(15 + 23 = 38\).

Check: \(3 + 11 = 14\) and \(14 \bmod 12 = 2\); \(38 \bmod 12 = 2\). Both choices give \([2]\). In general, if \(x \bmod 12 = x' \bmod 12\) and \(y \bmod 12 = y' \bmod 12\), then \((x+y) \bmod 12 = (x'+y') \bmod 12\). So the result does not depend on which representatives we pick, and the definition is proper.

Whenever a function or relation is defined on a quotient set through representatives, this independence check must be done.

Exercise 7

Self-check only. This exercise is not graded.

Let \(\mathrm{Names} = \{a, b, c, d, e, f\}\) and \(\Gamma = \{a = b,\ b = c,\ d = e\}\). Define \(x \equiv_\Gamma y\) iff \(\Gamma \vdash x = y\). List the equivalence classes of \(\equiv_\Gamma\). Write the names of each class separated by spaces, and separate classes with |, for example a d | b | c e f.

Solution.

The classes are \(\{a,b,c\}\), \(\{d,e\}\), \(\{f\}\). From \(a = b\) and \(b = c\), rule t gives \(a = c\); rule s gives the reverse directions; rule r gives \(x = x\) for every name. Nothing in \(\Gamma\) connects \(f\) to another name, and nothing connects the group \(a,b,c\) to the group \(d,e\), so no proof tree can produce such an equation (this is what soundness guarantees; see below).

Soundness and completeness

Definition 0.22

Let \(\Gamma\) be a set of sentences. Define a relation \(\equiv_\Gamma\) on \(\mathrm{Names}\) by: \(x \equiv_\Gamma y\) iff \(\Gamma \vdash x = y\).

Proposition 0.23

For every set \(\Gamma\), the relation \(\equiv_\Gamma\) is an equivalence relation.

Proof. Reflexive: \(\Gamma \vdash x = x\) by rule r. Symmetric: if there is a proof of \(x = y\) from \(\Gamma\), apply rule s at the bottom to get a proof of \(y = x\). Transitive: if there are proofs of \(x = y\) and \(y = z\) from \(\Gamma\), put them side by side and apply rule t to get a proof of \(x = z\).

Lemma 0.24: soundness

If \(\Gamma \vdash x = y\), then \(\Gamma \models x = y\). In other words: if \(\Gamma \vdash x = y\) and a model \(\mathcal M\) satisfies all sentences in \(\Gamma\), then \(\mathcal M \models x = y\).

Proof. Fix a model \(\mathcal M\) with \(\mathcal M \models \Gamma\). We show by induction on proof trees that the conclusion of every proof from \(\Gamma\) is true in \(\mathcal M\).

  • A leaf is either a sentence of \(\Gamma\), true in \(\mathcal M\) by assumption, or an instance \(a = a\) of rule r, true because \([\![a]\!] = [\![a]\!]\).
  • Rule s: if \([\![a]\!] = [\![b]\!]\), then \([\![b]\!] = [\![a]\!]\).
  • Rule t: if \([\![a]\!] = [\![b]\!]\) and \([\![b]\!] = [\![c]\!]\), then \([\![a]\!] = [\![c]\!]\).

So each rule takes true premises to a true conclusion, and the conclusion of the whole tree is true in \(\mathcal M\).

Theorem 0.25: completeness

If \(\Gamma \models x = y\), then \(\Gamma \vdash x = y\).

Proof. Suppose \(\Gamma \models x = y\). Consider the equivalence relation \(\equiv_\Gamma\) on \(\mathrm{Names}\). Define a model \(\mathcal M\) by taking \(M = \mathrm{Names}/{\equiv_\Gamma}\), the quotient set, and \([\![v]\!] = [v]\) for each name \(v\). Each name is sent to its own equivalence class.

Claim: \(\mathcal M \models \Gamma\). Take an equation \(v = w\) in \(\Gamma\). Then \(\Gamma \vdash v = w\) (a one-leaf proof), so \(v \equiv_\Gamma w\), so \([v] = [w]\), so \([\![v]\!] = [\![w]\!]\). The equation is satisfied.

Since \(\Gamma \models x = y\) and \(\mathcal M \models \Gamma\), we get \(\mathcal M \models x = y\). That is, \([x] = [\![x]\!] = [\![y]\!] = [y]\). Two equivalence classes are equal only if their elements are related, so \(x \equiv_\Gamma y\). By Definition 0.22, \(\Gamma \vdash x = y\).

Together, soundness and completeness say that for this system the two notions of consequence agree: \(\Gamma \vdash x = y\) if and only if \(\Gamma \models x = y\). The proof-theoretic side is mechanical and checkable; the semantic side talks about all models. The theorems guarantee that they pick out exactly the same equations. This is the pattern we will repeat for every logical system in the course.

Example 18: using soundness to show that something is not provable

Let \(\Gamma = \{a = b,\ c = d\}\). Show that \(\Gamma \nvdash a = c\).

Solution.

By soundness, if \(\Gamma \vdash a = c\) then every model of \(\Gamma\) satisfies \(a = c\). So it is enough to find one model of \(\Gamma\) where \(a = c\) is false.

Take \(M = \{1, 2\}\), \([\![a]\!] = [\![b]\!] = 1\), \([\![c]\!] = [\![d]\!] = 2\). Then \(\mathcal M \models a = b\) and \(\mathcal M \models c = d\), so \(\mathcal M \models \Gamma\). But \([\![a]\!] = 1 \ne 2 = [\![c]\!]\), so \(\mathcal M \not\models a = c\).

Hence \(\Gamma \not\models a = c\), and by soundness \(\Gamma \nvdash a = c\). Trying to search through all possible proof trees is not needed.

Exercise 8

Self-check only. This exercise is not graded.

Let \(\Gamma = \{a = b,\ b = d,\ c = e\}\). Give a model with \(M = \{1, 2, 3\}\) showing that \(\Gamma \not\models d = e\). Choose the value of each name.

One solution.

\([\![a]\!] = [\![b]\!] = [\![d]\!] = 1\) and \([\![c]\!] = [\![e]\!] = 2\). All three equations in \(\Gamma\) hold, and \([\![d]\!] = 1 \ne 2 = [\![e]\!]\). By soundness this also shows \(\Gamma \nvdash d = e\). Any assignment with \(a, b, d\) equal, \(c, e\) equal, and the two groups different is accepted.

Homework, Week 2

Instructions
  • Fill in your name in the field below before you start.
  • Show your work. A bare answer without reasoning receives no credit. Write full sentences where a proof or an explanation is asked.
  • When you are done, click "Save homework as PDF" and upload the PDF to Canvas.
  • Your answers are saved automatically in this browser. If you open this file on a different computer or in a different browser, they will not be there.
  • Total: 100 points. Questions 2 and 3 are taken from Section 0.5 of the textbook; the others are based on the material of Days 1 and 3.

Question 1: semantic consequence20 points

The sentences in this question are of the form All \(p\) are \(q\), with the semantics of Day 1.

Question 2 (Exercise 0.6)20 points

Let \(\mathbb P\) be the preorder with three points \(P = \{x, y, z\}\) and order

\(x \le x,\quad y \le y,\quad z \le z,\quad x \le y,\quad x \le z,\)

and no other relations. So \(x\) is below both \(y\) and \(z\), and \(y\), \(z\) are not comparable. Let \(\mathbb Q = \mathbb P^{\mathrm{op}}\), which has the same set and the reversed order. The Hasse diagrams of both are shown below.

xyz xyz P Q = P op

In each part, give the count and explain how you found it (for example, by listing the functions, or by an argument that covers all cases).

Question 3 (Exercise 0.9)20 points

This question builds on Proposition 0.15. Let \(g : P \to Q\) and \(f : Q \to R\) be functions between preorders, and let \(f \circ g : P \to R\) be their composition, \((f \circ g)(p) = f(g(p))\). Prove each statement in full, following the style of the proof of Proposition 0.15.

Question 4: formal proofs in \(\mathsf E\)15 points

Build a formal proof tree for each statement, using only the rules r, s, t of Definition 0.17. The conclusion is given at the bottom of each tree. For every sentence in the tree, choose how it is obtained: as an assumption from \(\Gamma\), by rule r (no premises), by rule s (one premise), or by rule t (two premises). When you choose s or t, empty boxes for the premises appear above; type the premise sentences into them, then continue upward until every leaf is an assumption from \(\Gamma\) or an instance of rule r. Write sentences in the form a = b.

Question 5: equivalence relations, soundness, completeness25 points