- Logistics: no technology in classroom policy.
- Starting definitions (with Sudoku example)
- key terms: set, cartesian product, function, domain, codomain

- image of the board

- mostly see the syllabus
- first homework and reading for next week released Friday sometime after class
- please no laptops or other devices in lecture
- please be silent in lecture
- quizzes, i>clickers, and tablet lectures are new, please feel free to approach us with suggestions for improvements.

Definition: a **set** is an unordered collection of **elements**. Two sets are considered the same if they contain the same elements; the order and duplication of elements is ignored. We write *e* ∈ *S* to indicate that *e* is an element of the set *S* (similarly *e* ∉ *S* indicates that *e* is *not* an element of *S*).

(Note: ∈ ("is an element of", `\in`

in LaTeX) is different from *e* or *E* (the letter e) and *ϵ* (the greek letter epsilon, LaTeX `\epsilon`

).)

There are many ways to write down sets.

- You can enumerate the elements: {1, 2, 3, 4, 5}
- You can use ellipses if it's clear: {1, 2, ..., 5}
- You can give a (clear!) english description: "the set of all even natural numbers"
- We'll discuss set comprehension notation next time.

You have written down a set if the reader can unambiguously determine whether a given element is or is not in the set.

Examples:

- {1, 2}={2, 1}={1, 2, 2, 1, 2}≠{1, 2, 3}
- {1, 2}≠{3, 4}
- We let
*N*= {1, 2, ...9} for the sudoku example - We defined
*C*as the set of all pairs of numbers from*N*:*C*= {(1, 1),(1, 2),…,(1, 9),(2, 1),(2, 2),…,(2, 9),…,(9, 1),…,(9, 9)}

This set is called the**cartesian product**of*N*with itself, and is written*N*×*N*.

A **function** *f* from a set *A* to a set *B* is an *unambiguous* rule, which gives an element of *B* for *each* element of *A*. *A* is called the **domain** of *f*, while *B* is called the **codomain** of *f*. We often write *f* : *A* → *B* to represent the statement "*f* is a function from *A* to *B*".

As with sets, there are many ways to write down functions. The key rule is that everyone agrees (unambiguously!) what the output is for a given input (the input is the element of the domain, the output is the element of the codomain).

The domain and codomain are different: every element of the domain must have a corresponding element of the codomain, but an element of the codomain may have any number (including 0) of elements of the domain that map to it.

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*}

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

We started modeling sudoku solutions. Here's where we are so far:

Let the *set of numbers* *N* = {1, 2, …, 9}. Let the set of *cells* *C* = *N* × *N*.

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*s**q**u**a**r**e*(*c*_{1})=*s**q**u**a**r**e*(*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*s**q**u**a**r**e*(*c*_{1})=*s**q**u**a**r**e*(*c*_{2}), if*f*(*c*_{1})=*f*(*c*_{2}) then*c*_{1}=*c*_{2}.

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

*s**q**u**a**r**e*(*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 |

*s**q**u**a**r**e*(*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)
*s**q**u**a**r**e*:*C*→*N*given by $square : (i,j) \mapsto 1 + \left\lfloor(i - 1)/3\right\rfloor + 3 \cdot \left(1 + \lfloor(j-1)/3\right\rfloor\right)$

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

Suppose we are working on the following puzzle:

8 | ||||||||

1 | 5 | 7 | ||||||

3 | 7 | 1 | 2 | 6 | 8 | |||

1 | 6 | 5 | 3 | |||||

5 | 9 | |||||||

2 | 1 | |||||||

5 | 3 | 7 | 1 | 4 | ||||

8 | 7 | |||||||

4 | _ | 9 |

It is clear that the last entry of the third column (cell (9,3)) must be 1. Let's prove it.

**Claim**: if *f* is a sudoku solution compatible with the above board (that is, if *f*(2, 2)=1, *f*(1, 5)=8, *f*(2, 5)=5 and so on), then *f*(9, 3)=1.

**Proof**: There must be a 1 somewhere in box 3 (in other words, there exists some (*i*, *j*) such that *s**q**u**a**r**e*(*i*, *j*)=3 and *f*(*i*, *j*)=1). By rule 2, *j* cannot be 1, because *f*(4, 1)=1. Similarly, since *f*(2, 2)=1, *j* cannot be 2. Thus *j* must be 3; and *f*(7, 3)≠1, and *f*(8, 3)≠1. The only cell left is (9, 3), so *f*(9, 3) must be 1.

**Question**: is this proof good? (Hint)