class: center, middle # CS-3110: Formal Languages and Automata ## Math Review ### Chapter 1 + 2 --- class: center, middle # Sets, Functions, Relations --- # Sets A set is a collection of: * unique, * unordered * elements Likewise, a collection of unique, unordered elements **defines** a set (two sets with the same elements are really the same set). When we write sets, we put the elements in braces: `\( \{a,b,c\}\)` --- # Set Properties Uniqueness: * Each element is only present once Unorderedness: * While we have to choose some order when we write sets, this order does not matter. `\( \{a,b,c\} \)` is the same set as `\(\{c, b, a\}\)` Elements: * Can be anything, including other sets * There is no limit, we may have **infinitely many** elements in our set (e.g. the set of all integers) --- # Set Operations What can we do with a set? -- Really just one thing: * Check if an element is in the set or not: `\(x \in Y\)` * Everything else is just built on top of this operation --- # Set Notation Often we want to define sets "concisely". For example, we do not want to (and can't) write out **all** legal email addresses. Notation, for some given set Y and a predicate P: $$ Q = \\{ x | P(x) \\} $$ Read this is: "Q is the set of all x for which P(x) holds". We could then use: $$ \text{emails} = \\{x | x\:\text{is a valid email address}\\} $$ --- class: medium # Aside: Predicates What is a predicate? - A predicate is an incomplete proposition - That is, it is a statement **about something** - "The rose is red" is a statement about "the rose", "is red" is a predicate - "2 divides 8" (or `\(2 | 8\)`) is a statement about "2" and "8", "divides" is a predicate - `\(x \in Y\)` is a statement about x and Y, `\(\in\)` is a predicate --- # Propositional statements We can also construct more complex statements with the logical operators `\(\wedge, \vee, \rightarrow, \neg\)` * `\(2 | 8 \wedge 2 | 4\)` means "2 divides 8 and 2 divides 4" * `\(2 | 8 \vee 2 | 5\)` means "2 divides 8 or 2 divides 5" * `\(2 | 5 \rightarrow 2 | 3\)` means "if 2 divides 5 then 2 divides 3" * `\(\neg 2 | 5\)` means "2 does not divide 5" --- class: medium # Quantifiers Talking about how 2 divides 8 or other number is only marginally interesting. Instead, we would like to talk about more general cases, like "if any number divides another number". For this we use the quantifiers "for all" `\(\forall\)` and "exists" `\(\exists\)` * `\(\forall a,b: (a | b \wedge b | a) \rightarrow (a = b)\)`: For every combination of a and b, if a divides b **and** b divides a then a and be are equal * `\(\exists a, b: a | b \wedge \neg b | a\)`: There are two numbers a and b, such that a divides b and b does not divide a (for example: a = 2, b = 8, or a = 3 and b = 9, or ...) --- # Set Operations With this knowledge, we can now define set operations: Union: $$ Y \cup Z = \\{x | x \in Y \vee x \in Z\\} $$ Intersection: $$ Y \cap Z = \\{x | x \in Y \wedge x \in Z\\} $$ Difference: $$ Y - Z = Y \setminus Z = \\{x | x \in Y \wedge \neg x \in Z\\} $$ --- class: medium # Set Complement One operation that is often useful is the complement of a set, i.e. all elements that are not in a set: $$ \\overline{Y} = \\{x | \neg x \in Y\\\} $$ But this begs the question: **Which** elements? If I have "the complement of the set of all email addresses", does this contain, the number 5, L.A., the realm of Asgard, etc.? -- This would probably not be very useful, so we usually have some "domain" of discourse, aka the **universal set** of all things we are currently looking at, and the complement is taken **with respect to this set**. For a domain "D": $$ \\overline{Y} = \\{x | x \in D \wedge \neg x \in Y\\\} $$ --- # One final shortcut * When using the set builder notation, it is very common to have an `\(x\in Y\)` term in the predicate * It is very common to use this shorthand notation, which is also often clearer: $$ \\overline{Y} = \\{x \in D | \neg x \in Y\\\} $$ This notation emphasizes/clarifies that the predicate is a **restriction** placed on the element in D. --- class: medium # Subsets and supersets * Given two sets A and B * If all elements in A are also in B (but B may or may not have additional elements), we call A a **subset** of B, and B a **superset** of A $$ A \subseteq B \equiv \forall x: x \in A \rightarrow x \in B $$ A subset/superset is called **proper** if A and B are not equal (i.e. there is at least on element in B that is not in A) $$ A \subset B \equiv \forall x: x \in A \rightarrow x \in B \wedge \neg A = B $$ --- class: medium # The powerset * Given a set A * We call the powerset of A `\(\mathcal{P}(A)\)` or `\(2^A\)` the **set of all subsets** of A: $$ \mathcal{P}(A) = 2^A = \\{x | x \subseteq A\\} $$ For example: $$ \mathcal{P}(\\{1,2\\}) = \\{\\{\\}, \\{1\\}, \\{2\\}, \\{1,2\\}\\} $$ For a set with n elements the powerset will have `\(2^n\)` elements. --- class: center, middle # Relations and Functions --- class: medium # Tuples * Before we talk about relations, we need another data type: tuples * A tuple is a **finite, ordered** enumeration of elements * We write tuples in parenthesis: `\((a,b)\)` and `\((b,a)\)` are **different** tuples, if a and b are different * One use of tuples is to combine elements from multiple sets (or the same set multiple times) * For example: 2D or 3D coordinates are tuples of numbers --- # The Cartesian Product Given two sets X and Y, we define the Cartesian Product of these two sets: $$ X \times Y = \\{(a,b) | a \in X \wedge b \in Y\\} $$ This will produce every combination of elements of X and Y as one element in the product (set). --- # Relations * Remember when we talked about predicates? * Relations are an alternative view of the same idea * A Relation is a set of tuples of elements that are in some relation with one another * For example: our "divides" predicate is a relation between natural numbers --- # The divides relation A relation is a set: $$ | = \\{(a,b) \in \mathbb{N}\times \mathbb{N} | a\:\text{divides}\: b \\} $$ What can we do with sets? Check if something is an element or not: $$ (2,8) \in |\\\\ \neg (2,5) \in |\\\\ \forall a,b: (a,b) \in | \wedge (b,a) \in | \rightarrow a = b $$ --- # Notation This looks weird: $$ (2,8) \in | $$ So we usually write it as: $$ 2 | 8 $$ Generally, if we have a relation R, we define $$ aRb \equiv (a,b) \in R $$ --- # Properties of Relations A relation may (or may not) be: Reflexive: $$ \forall a: aRa $$ Transitive: $$ \forall a,b,c: (aRb \wedge bRc) \rightarrow aRc $$ Symmetric: $$ \forall a,b: aRb \rightarrow bRa $$ --- # Equivalence Relations An equivalence relation is a relation which is reflexive, transitive **and** symmetric. These are relations that put elements in "equivalence" with one another (hence the name), which means all elements that are in relation are "the same" according to some criterium. We call elements that are "the same" in this sense as being part of one **equivalence class**. For example: Numbers modulo 5 using the equivalence relation `\(aRb \leftrightarrow a \equiv b \mod 5\)`. 1, 6, 11, 16, ... are all "equivalent" modulo 5, they are in one equivalence class (often written as [1]). In fact, we only have five equivalence classes: [0], [1], [2], [3], [4], and we can use them to do math: [1] + [3] = [4] --- class: medium # Equivalence Relations: Why do we care? * Say we have a set Y and an equivalence relation R on that set * We can then "divide" Y into parts, where each "part" is one equivalence class * Each element of Y will be in one of these parts, i.e. we have **partitioned** Y this way * We can often use this partition for proofs: - Show that something interesting holds between equivalent elements - Show that something interesting holds between different equivalence classes --- # Functions A function f is a mapping from a set A to a set B: $$ f: A \mapsto B $$ Alternative view: A function f is a subset of `\(A\times B\)` with the property that there is exactly one pair `\((a,b)\)` **for each** `\(a\in A\)` in f. The `\(b\)` for each of these pairs may be different or the same. We usually write $$ f(a) = b $$ instead of $$ (a,b) \in f $$ --- class: medium # An example Let $$ A = \\{1,2\\}\\\\ B = \\{a,b,c\\} $$ and $$ f = \\{(1,a), (2,b)\\}\\\\ g = \\{(1,a), (2,a)\\}\\\\ r = \\{(a,1), (b,2)\\}\\\\ s = \\{(1,a)\\}\\\\ t = \\{(a,1), (a,2), (b,1), (b,3)\\} $$ f and g are functions, but r, s, and t are **not**. --- class: medium # Note * We started with sets * Then we talked about relations, which are also just sets * Then we talked about functions, which are also just sets * The **only** operation on sets we "need" is `\(\in\)`, everything else is just shorthand notation * Elements of sets can be other sets, so we can have, for example, a set of functions, or a function that maps relations to elements, or a relation between functions, etc. --- class: center, middle # Proofs --- # Mathematical Truths A common mathematical "joke": There are only two kinds of mathematical truths: - Unproven ones - Trivial ones (The joke being that once there is a proof for something it becomes trivial) --- # Proofs * A proof is a logical (irrefutable) argument * We start with some premises * Then we apply logical operations/rules * Until we arrive at a conclusion --- class: medium # Proof types * Direct Proof: Apply logical rules until you reach the desired conclusion * Proof by Mathematical Induction: Show that a base case holds, and that, given an arbitrary case, one can construct a successor (example next time) * Proof by Contradiction: Assume that what you want to proof is false, and show that that would lead to a contradiction * Proof by Contrapositive: To show that "p implies q", you can show the equivalent "not q implies not p" instead --- class: medium # Pigeonhole Principle * We have n pigeon-holes * There are n+1 pigeons in them * We conclude: There is at least one pigeon-hole that has at least two pigeons in it * We can use this to prove all kinds of things, like: There are two people in L.A. that have the same number of hairs on their head --- # Pigeonhole Principle
Author:
en:User:BenFrantzDale
; this image by
en:User:McKay
--- class: medium # Proof types not allowed in CS3110 * Proof by example: "It works for n=2" * Proof by forward citation: "As can be seen in (Chomsky, 2025)" * Proof by mathematical intuition: "It's obvious" * Proof by cumbersome notation: "Given `\(\overline{\gimel} = \frac{\mathsf{\Xi}}{\overline{\mathsf{\Xi}}} \times 😺\)` ..." * Proof by exhaustion: "As can be seen in chapter 7 on page 86 of my submission of homework 2, ..." (Adapted from [Top 10 Proof Techniques NOT Allowed in 6.042](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/video-lectures/lecture-3-strong-induction/MIT6_042JF10_proof.pdf))