We finished our modeling of sudoku solutions. Along the way, we introduced some new notation and discussed definition and proof techniques in detail.

Review:

is the set of all pairs (*A*×*B**a*,*b*) with*a*∈*A*and*b*∈*B*.- Set comprehension:
**{**denotes the set of all elements x having the given property. You should read it as "the set of all x such that property holds". For example,*x*∣*p**r**o**p**e**r**t**y*}*N*= {*n*∣*n*is an integer and 1 ≤*n*≤ 9}*A*×*B*= {(*a*,*b*)∣*a*∈*A*and*b*∈*B*}

Implication: A compact way to write "if

*P*is true then*Q*is true" is. This is usually pronounced "*P*⇒*Q**P*implies*Q*", but I prefer "if*P*then*Q*" or "whenever*P*is true,*Q*is true". See sudoku example below for examples.Universal quantification:

**∀**means "for all x, P is true". See sudoku example below for examples.*x*,*P***Not covered in lecture**:**∃**means "there exists some*x*,*P**x*such that*P*is true".Function definition:

means "*f*:*x*↦*e**f*is a function, and the value of*f*(*x*) is*e*". Note the difference between → (which gives the domain and codomain) and ↦ which gives an expression for computing the function.Examples:

*i*:*x*↦*x*+ 1*b*:*x*↦*x*/ 3*f*: (*i*,*j*) ↦*i*+*j*/ 2

When using a variable in a definition, it's important to distinguish between "for all x, P is true" and "there exists an x such that P is true".

When writing a proof,

**write down what you want to prove, and clearly label it. Then, clearly label the beginning of your proof**. Everything you write after "proof" should be something that you've shown to be true. If you don't label it clearly, it will look like what you're claiming is one of the things you know to be true. This can lead to circular logic."if P then Q" is logically equivalent to "if Q is false then P is false". These statements are

**contrapositives**of each other. Rephrasing a statement as its contrapositive can often lead to easier proofs or clearer definitions.Notation should be used when it clarifies, but not excessively. At their heart, proofs are explanations of why something is true. Using too much notation can obscure the explanation and make the proof hard to read.

When in doubt,

**reread your proof**and think about how hard it is to interpret. Find a balance between verbosity and obfuscation.**Don't use an example to prove a "for all" statement**. Examples are helpful to figure out how to prove something, but they are not proofs. Examples are fine to prove that something exists though.Sometimes you can leave things out, if there's nothing else that makes sense. For example, in the sudoku definition below, I should write "for all

*i*in*N*", but it doesn't make sense for*i*to be in any set besides*N*, since I plug it into*f*. But sometimes it's clearer to leave things in: I explicitly wrote*c*∈*C*below because I hadn't used that variable before and I thought it would be clearer.It's useful to make your own definitions (like

*b**o**x*in the sudoku definition)You can write down definitions however you like, as long as they're clear. See the many definitions of

*b**o**x*below.A common proof technique is

**proof by contradiction**. When trying to*prove*a statement*P*, we can instead*assume*that*P*is false, and then arrive at some nonsensical statement (a contradiction). Since we have faith in logic, we must have made a mistake, and that mistake was to assume that*P*was false in the first place. See below for an example.

A sudoku solution *f* is a function *f*: *C* → *N* satisfying the following properties:

- For all
*i*,*j*, and*j*ʹ, if*j*≠*j*ʹ then*f*(*i*,*j*) ≠*f*(*i*,*j*ʹ) - For all
*i*,*i*ʹ, and*j*, if*i*≠*i*ʹ then*f*(*i*,*j*) ≠*f*(*i*ʹ,*j*) - For all
*c*_{1}and*c*_{2}∈*C*, if*c*_{1}≠*c*_{2}and*b**o**x*(*c*_{1}) =*b**o**x*(*c*_{2}), then*f*(*c*_{1}) ≠*f*(*c*_{2}).

It's often easier to work with the contrapositives (this is an equivalent definition):

- For all
*i*,*j*, and*j*ʹ, if*f*(*i*,*j*) =*f*(*i*,*j*ʹ) then*j*=*j*ʹ - For all
*i*,*i*ʹ, and*j*, if*f*(*i*,*j*) =*f*(*i*ʹ,*j*) then*i*=*i*ʹ - For all
*c*_{1}and*c*_{2}∈*C*with*b**o**x*(*c*_{1}) =*b**o**x*(*c*_{2}), if*f*(*c*_{1}) =*f*(*c*_{2}) then*c*_{1}=*c*_{2}.

Here *b**o**x* is a function that gives the number of the large box that contains the cell. Here are three styles of definition of *b**o**x*; decide which one you like best (my favorite is the first):

*b**o**x*(*i*,*j*) is the number of the large box that contains the (*i*,*j*) cell, where we number the large 9x9 grids as follows:

1 | 4 | 7 |

2 | 5 | 8 |

3 | 6 | 9 |

*b**o**x*(*i*,*j*) is the (*i*,*j*)th entry in the following table:

1 | 1 | 1 | 4 | 4 | 4 | 7 | 7 | 7 |

1 | 1 | 1 | 4 | 4 | 4 | 7 | 7 | 7 |

1 | 1 | 1 | 4 | 4 | 4 | 7 | 7 | 7 |

2 | 2 | 2 | 5 | 5 | 5 | 8 | 8 | 8 |

2 | 2 | 2 | 5 | 5 | 5 | 8 | 8 | 8 |

2 | 2 | 2 | 5 | 5 | 5 | 8 | 8 | 8 |

3 | 3 | 3 | 6 | 6 | 6 | 9 | 9 | 9 |

3 | 3 | 3 | 6 | 6 | 6 | 9 | 9 | 9 |

3 | 3 | 3 | 6 | 6 | 6 | 9 | 9 | 9 |

- (using integer division)
*b**o**x*:*C*→*N*given by*b**o**x*: (*i*,*j*) ↦ 1 + ⌊(*i*− 1) / 3⌋ + 3 ⋅ (1 + ⌊(*j*− 1) / 3⌋)

As you play sudoku, you are generating in your head lots of proofs. This is overkill, but let's write down one such proof as an example of proving something from definitions.

Suppose we are working on the following puzzle:

1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | |

It is clear that the 4th entry of the 5th row must be 5. Let's prove it.

**Claim**: if *f* is a sudoku solution and if *f*(5, 1) = 1, and *f*(5, 2) = 2, and *f*(5, 3) = 3, and (note I'm not assuming anything about *f*(5, 4)) *f*(5, 5) = 5, and *f*(5, 6) = 6, and so on,

then *f*(5, 4) = 4.

**Proof**: First, we can summarize the assumptions: for all *k* ≠ 4, *f*(5, *k*) = *k*. Now, we can proceed to prove the claim by contradiction.

Suppose that *f*(5, 4) ≠ 4. Well, we know *f*(5, 4) = *k* for some *k*; and we've assumed that *k* ≠ 4. Therefore we can apply the assumption to conclude that *f*(5, *k*) = *k*. Since *f* is assumed to be a sudoku solution, it must satisfy rule 1, and therefore since *f*(5, 4) = *f*(5, *k*), we conclude that 4 = *k*. But this is nonsense: we've assumed that *k* ≠ 4!

Therefore, our assumption that *f*(5, 4) ≠ 4 must have been incorrect.