- Relations
- relations on multiple sets
- relations on two different sets
- relations generalize functions
*x**R**y*notation- key terms: equivalence relation, equivalence class, quotient of a set, closure

- Finite automata
- motivation
- example
- definitions: Σ
^{ * }, DFA

(review) a

**binary relation***R*on a set*S*is a set of pairs of elements of*S*. In other words,*R*⊆*S*×*S*. In other words,*R*is a set of edges in a directed graph with vertices*S*.Relations can relate more than two sets. In general, a

**relation**on*S*,*T*,*U*, … is a subset of*S*×*T*×*U*× ⋯.Example: a database table can be thought of as a set of rows; each row can be thought of as a tuple. Thus the table is a relation on

*S*,*T*,*U*, … where*S*is the set of possible values for the first column,*T*is the set of possible values for the second column, and so on.notation: if

*R*is a binary relation and (*x*,*y*) ∈*R*we write*x**R**y*. this generalizes relations like " = " and "≤".relations generalize functions. You can think of a function

*F*as a relation:*y**F**x*if*y*=*F*(*x*). Relation composition (as defined last lecture) is then the same as function composition.

(review) if *R* is a relation on a set *S* then

*R*is**reflexive**if for all*x*∈*S*,*x**R**x*.*R*is**symmetric**if for all*x*and*y*∈*S*, if*x**R**y*then*y**R**x**R*is**transitive**if for all*x*,*y*, and*z*∈*S*, if*x**R**y*and*y**R**z*then*x**R**z*.

A relation satisfying all three properties is called an **equivalence relation**. Equivalence relations "act like" the = relation.

If you ever write a function as part of a program and call it something like "equals" or "equiv", you should check that it actually defines an equivalence relation!

Recall when discussing number theory, we defined the equivalence class of *x* (written [*x*]_{m}) as $\{Y \in \N | x \equiv y (mod~m)\}$.

This construction generalizes to any equivalence relation. If *R* is an equivalence relation on *S*, and if *x* ∈ *S*, then we can define the **equivalence class of x** ([

The set of all equivalence classes of *S* (using the relation *R*) is called the **quotient** of *S* by *R*, or simply ** S / R** (read "

If you think of *R* as a graph, it must consist of a collection of a collection of subgraphs, each of which is completely connected; these subgraphs are the equivalence classes of *S* / *R*.

For the last portion of the lecture we started discussing finite automata. Finite automata are a very simple way to model certain computations that take strings as input and output yes or no.

Key definitions:

- An
**alphabet**(usually denoted Σ ) is a finite set. The elements of the alphabet are called**characters**.- common alphabets include {0, 1}, {
*a*,*b*, …,*z*}, the set of all ASCII characters, the set of all Unicode characters, the set of all hexadecimal digits, etc.

- common alphabets include {0, 1}, {
- If Σ is an alphabet, then
**Σ**is the set of strings of characters from Σ .^{ * }- example: 0010110 ∈ {0, 1}
^{ * }

- example: 0010110 ∈ {0, 1}
- A
**language**(also called a**problem**or a**specification**) is a subset of Σ^{ * }.- example: the set of even length strings

- A
**deterministic finite automaton**(plural automata) (abbreviated**DFA**) is a 5-tuple (*Q*, Σ ,*δ*,*q*_{0},*F*) where*Q*is a finite set. Elements of*Q*are called**states**- Σ is an alphabet
*δ*:*Q*× Σ →*Q*is called the**transition function***q*_{0}∈*Q*is called the**initial state***F*⊆*Q*is called the**set of accepting (or final) states**

- Example: the image on the right (click image for LaTeX source) depicts
*M*= (*Q*,*Σ*,*δ*,*q*_{0},*F*) where:*Q*= {*q*_{1},*q*_{2}}, Σ = {0, 1},*q*_{0}=*q*_{1}, and*F*= {*q*_{1}}*δ*is given by*δ*: (*q*_{1}, 1)↦*q*_{1};*δ*: (*q*_{1}, 0)↦*q*_{2}*δ*: (*q*_{2}, 1)↦*q*_{2};*δ*: (*q*_{2}, 0)↦*q*_{1}

Note: because

*δ*is a function, there**must**be a transition from every state on every character.A machine processes a string one character at a time, starting in the start state and following a transition for each character until it consumes the whole string. After it processes the string, it

**accepts**if it ends in a final state, and it**rejects**otherwise.Convince yourself that the above machine accepts all (and only) the strings in the language

*L*= {*x*∣*x*has an even number of 0's}.