Notes on Chapter 0 of Gries & Schneider
Using Mathematics

Math is used for representing, or modeling, the world, providing a way to represent relationships that is not only concise and precise but also well-suited to manipulations that can reveal insights about the objects being modeled.

Examples:

A mundane example:

Mary had twice as many apples a John. But then she discarded half of hers, while John ate one of his. Afterwards, Mary still had exactly twice as many apples as John. How many applies did Mary and John, respectively, have initially?

Letting m and j represent the number of applies initially held, respectively, by Mary and John, this "word problem" can be modeled using two equations:

m = 2j;   m/2 = 2(j-1)

Any pair (m,j) of natural numbers satisfying both equations could describe the number of apples held by Mary and John. Notice how more succinct is this mathematical model than is the word problem.

Which illustrates one of the Virtues of mathematical models:

A mathematical model may be more understandable, concise, precise, and/or rigorous than an informal natural language description.

To illustrate the benefits of rigor, consider the specification of an algorithm that computes a natural number approximation to a given integer's square root. Let n be the input variable and b the output variable (both of type integer).

A typical way of expressing a specification is via a precondition and postcondition. Here, the likely precondition would be n ≥ 0. But what about the postcondition? To say, informally, that the value of b will be an integer that is "close to" √n is too imprecise. Formalizing the postcondition forces us to think carefully about which approximations to √n would be acceptable.

There are at least three reasonable choices:

  1. b2 ≤ n < (b+1)2  (i.e., b = ⌊√n⌋)
  2. (b-1)2 < n ≤ b2  (i.e., b = ⌈√n⌉)
  3. |b2 − n)| ≤ |(b+1)2 − n)|   ∧   |b2 − n)| ≤ |(b-1)2 − n)|  (i.e., the square of b is at least as close to n as are the squares of (b-1) and (b+1))
    Note that (by number theory) this expression implies (b-1)2 < n < (b+1)2, ensuring that no natural number can be a better approximation to √n than b is (and making it unnecessary to include this expression in the postcondition).

A second important virtue of mathematical models is this:

Answers to questions about objects/phenomena can often be computed directly using a mathematical model describing them.

This virtue is illustrated by how Neptune was discovered in 1846 using models of planetary motion.

A third important virtue of mathematical models:

Math provides methods for reasoning: for manipulating expressions, proving properties from and about these expressions, and obtaining new results from known ones. This reasoning can be carried out without knowing/caring about the meaning of the symbols occurring in the expressions.

As an example, G&S show how to take e = m·c2 and use algebraic manipulations to arrive at (the equivalent, under the assumption c≠0) e/c2 = m

The point made here is that, during the manipulations, there is no need to be concerned with the meanings of the variables e, m, or c. That is, the manipulations are purely syntactic. (Well, almost, as the assumption c≠0 played a role. Is that a matter of syntax? Or of semantics?)

Here could be where a solution to the Mary/John apple word problem is derived!

Most students will be much more familiar with manipulating arithmetic expressions (involving numbers) than with manipulationg logical expressions (involving boolean values). The latter is a useful skill for programmers, and this book/course will emphasize it.

As an example, how would you make sense of this (confusing) statement about the array b[]:

Every value occurring in array segment b[1..n] that does not occur in b[i..j] does occur in b[i..j].

By the end of this course, you should be able to translate this sentence into one that makes more sense.

Beyond syntactic manipulation

The first several chapters of the book emphasize the syntactic manipulation of formulas, but the text as a whole addresses much more. The book mentions some examples...

In science and engineering, mastery of a subject is equivalent to being able to reason about it. The relevant concept here is proof. The text discusses various methods of proof. Formal logic is the basis for these discussions.