# 37181 - Discrete Mathematics


Such a subject is designed to develop a basic understanding of foundational mathematics and the nature of mathematical proofs. Foundational mathematics will essentially be mathematical logic and set theory, which serve as a language for all of mathematics. Using this mathematical framework, we then discuss the basic proof methods used to advance mathematics.

We'll apply these new skills to rigorously approach various branches of "discrete" mathematical structures (structures with finite or countable elements). In all, we discuss the fundamentals of the following fields:

- mathematical logic
- set theory
- combinatorics
- elementary number theory
- graph theory

---


## Mathematical logic

### Propositional logic

proposition
connectives

#### Connectives
connectives form a special algebra over propositions called a **Boolean algebra** 
- Logical conjunction $\land$
- Logical disjunction $\lor$
- Logical negation $\not$
- Material implication $\implies$
- Material equivalence $\iff$

| $p$ |  $q$ | $p \land q$|
| :---: | :---: | :---: |
| $\top$ | $\top$ | $\top$ |
| $\top$ | $\bot$ | $\bot$ |
| $\bot$ | $\top$ | $\bot$ |
| $\bot$ | $\bot$ | $\bot$ |


only when all propositions hold

| $p$ |  $q$ | $p \lor q$|
| :---: | :---: | :---: |
| $\top$ | $\top$ | $\top$ |
| $\top$ | $\bot$ | $\top$ |
| $\bot$ | $\top$ | $\top$ |
| $\bot$ | $\bot$ | $\bot$ |

only when at least one proposition holds

| $p$ | $\not p$|
| :---: | :---: |
| $\top$ | $\bot$ |
| $\bot$ | $\top$ |

the opposite value of the proposition

| $p$ |  $q$ | $p \implies q$|
| :---: | :---: | :---: |
| $\top$ | $\top$ | $\top$ |
| $\top$ | $\bot$ | $\top$ |
| $\bot$ | $\top$ | $\top$ |
| $\bot$ | $\bot$ | $\bot$ |

means that $p$ being true is enough evidence to say that $q$ is true too

| $p$ |  $q$ | $p \iff q$|
| :---: | :---: | :---: |
| $\top$ | $\top$ | $\top$ |
| $\top$ | $\bot$ | $\top$ |
| $\bot$ | $\top$ | $\top$ |
| $\bot$ | $\bot$ | $\bot$ |

 $p$ and $q$ have the same value



##### De Morgan's laws (connectives)

\begin{theorem}[De Morgan's laws]
$$\not(p \land q) \iff \not p \lor \not q$$
$$\not(p \lor q) \iff \not p \land \not q$$
\end{theorem}

### First order logic
#### Quantifiers
- Universal quantifier $\forall$
- Existential quantifier $\exists$
##### De Morgan's laws (quantifiers)
$$\nexists x [\varphi(x)] \iff  \forall x [\not \varphi(x)]$$
$$\not \forall x [\varphi(x)] \iff  \exists x [\not \varphi(x)]$$

### Statements in mathematics

statement (formula)
tautology
contradiction

#### Jargon for mathematical statements
proposition
: mathematical statement


##### Proven propositions
lemma
: proven proposition used as a result in proving a theorem or a family of proposition

theorem
: proven proposition of significant importance

corollary
: proven proposition that follows naturally from a theorem


##### unproven propositions
conjecture
: unproven proposition that is considered likely to be true

hypothesis
: conjecture used as a sufficient condition for man


### 3-SAT problem
satisfiable formula
satisfying assignment

#### Stating the 3-SAT problem and algorithmic solution

#### P versus NP problem



### Proof techniques
various proof techniques rooted in how the statement is interpreted logically

- direct proof ($p \implies q$)
- proof by contraposition ($\not q \implies \not p$)
- proof by contradiction ($ \not[p \implies q] \implies \bot$)



---


## Set theory

### Sets and set notation
set
subset
element
empty set


#### Set builder notation

$$\{ x \in X : P(x) \}$$

### Set operations

- union
- intersection
- set difference

#### De morgan's laws (set theory)

### Relations
#### Equivalence relations
equivalence relation
partition
equivalence class
### Functions
function
injective function
surjective function
bijective function
### Principle of mathematical induction

---


## Combinatorics
### Counting techniques
### Permutations
### Combinations
### Catalan numbers

### Proof techniques
- pidgeon hole principle
- combinatorial proof


---



## Elementary number theory
### Well-ordering principle
Logically equivalent to induction
### Primality
### GCD and LCM
### Modular arithmetic
### Euler's theorem


---


## Graph theory

\begin{theorem}[Euler's formula]
Let $G$ be a connected planar graph, then the following holds
$$|V|-|E|+|F|=2$$
\end{theorem}


<h3 class=blue>Logical conjunction</h3>
<p>Logical operator \(\land\) (pronounced <b>AND</b>) that returns true iff all parameters are true</p>
<table>
  <tr>
    <td>\(p\)</td>
    <td>\(q\)</td>
    <td>\(p \land q\)</td>
  </tr>
  <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>1</td>
    <td>0</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>0</td>
  </tr>
</table>

<h3 class=blue>Logical disjunction</h3>
<p>Logical operator \(\lor\) (pronounced <b>OR</b>) that returns true iff at least one parameter is true</p>
<table>
  <tr>
    <td>\(p\)</td>
    <td>\(q\)</td>
    <td>\(p \lor q\)</td>
  </tr>
  <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>1</td>
    <td>0</td>
    <td>1</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>0</td>
  </tr>
</table>

<h3 class=blue>Logical negation</h3>
<p>Unary logical operator \(\neg\) (pronounced <b>NOT</b>) that returns true iff the parameter is false</p>
<table>
  <tr>
    <td>\(p\)</td>
    <td>\(\neg p\)</td>
  </tr>
  <tr>
    <td>1</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
  </tr>
</table>

<h3 class=blue>Material implication</h3>
<p>Binary logical operator \(\implies\) (pronounced <b>implies</b>) that returns true iff parameter 1  being true guarantees the truth of parameter 2</p>
<table>
  <tr>
    <td>\(p\)</td>
    <td>\(q\)</td>
    <td>\(p \implies q\)</td>
  </tr>
  <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>1</td>
    <td>0</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>1</td>
  </tr>
</table>

<h3 class=blue>Material equivalence</h3>
<p>Binary logical operator \(\implies\) (pronounced <b>if and only if</b>, often abbreviated to iff) that returns true iff parameter 1 being true guarantees the truth of parameter 2 and parameter 1 being false guarantees that parameter 2 is also false</p>
<table>
  <tr>
    <td>\(p\)</td>
    <td>\(q\)</td>
    <td>\(p \iff q\)</td>
  </tr>
  <tr>
    <td>1</td>
    <td>1</td>
    <td>1</td>
  </tr>
  <tr>
    <td>1</td>
    <td>0</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>1</td>
  </tr>
</table>


<h3 class=blue>De Morgan's Laws</h3>
<p>Laws that determine relational properties of boolean algebra</p>
<ul>
	<li>\( \neg \bigvee_{i=1} p_i \iff  \bigwedge_{i=1} \neg p_i \)</li>
	<li>\( \neg \bigwedge_{i=1} p_i \iff  \bigvee_{i=1} \neg p_i \)</li>
</ul>

<h3 class=blue>Statement Affermazione 宣告</h3>
<p>Mathematical declaration that is either true for false
</p>

<h3 class=blue>Logical connective Conettivo logicale 論理的接続詞</h3>
<p>Linking several statements with logical symbols
</p>

<h3 class=blue>Tautology Tautologia 恒真式</h3>
<p>Formation of logical connectives so that result is always positive
</p>

<h3 class=blue>Universe of discourse Universo del discorso 談話の宇宙</h3>
<p>Set \(U\) representing the domain of variables that a statement considers</p>

<h3 class=blue>Universal quantifier ( \(\forall\) )</h3>
<p>Predicate logical operator (pronounced <b>for all</b>) denoting the universe of discourse for some statement to hold. </p>
<p>\(\forall s \in S [P(s)]\)</p>
<p>For instance \(\forall x \in \mathbb{N} ( 5x \in \mathbb{N}) \) restricts the universe of discourse to the natural numbers, however swapping for \( \forall x \in \mathbb{R}\) would falsify this claim.</p>



<h3 class=blue>Existential quantifier ( \(\exists\) ) </h3>
<p>Predicate logical operator (pronounced <b>there exists</b>) denoting the existence of an element in the universe that satisfies the statement.</p>
<p>\(\exists s \in S [P(s)]\)</p>
<p>For instance \( \exists \varphi \in \mathbb{R} [ \varphi^2 - \varphi -1 =0]\) claims the existence of some element satisfying this polynomial in the set of real numbers, however swapping for \( \exists \varphi \in \mathbb{N}\) would falsify this claim.</p>


<h3><a class=blue>Negation Negazione 否定</a></h3>
<p>To negate some statement involving quantifiers, one can deduce that if a statement claims to not hold for all (\(\forall\)) elements, then equivalently one can say that there exists (\(\exists\)) some counterexample, so:</p>
<p>\( \neg(\forall x[ P(x)]) \iff \exists x ( \neg[P(x)]) \)</p>
<p>For statements disclaiming there exists some element that satisfies it, one can equivalently say that it is unsatisfiable for all elements, therefore:</p>
<p>\( \neg(\exists x [ P(x) ] ) \iff \forall x ( \neg[ P(x) ] ) \)</p>


<h3><a class=blue>Satisfiability Soddisfacibilit&agrave; 充足可能性</a></h3>
<p>A boolean formula is satisfiable if there are some settings for its variables that can output a \(1\) (or 'true').</p>

<h3 class=blue>3-SAT</h3>
<p>a common Satisfiability test where each x, y, and r value can either have a
  &not;, or not have a &not; (hah) like (x&#8321;&or;y&#8321;&or;r&#8321;)&and;
  (x&#8322;&or;y&#8322;&or;r&#8322;)&and;(x&#8323;&or;y&#8323;&or;r&#8323;)
</p>

<h3 class=blue>P</h3>
<p>\(P\) is a set that containing all 'languages' for which there exists a polynomial time Turing machine that can recognise it. For more detail, refer to <a href=http://zaco.au/daigaku/2023_spr/tcs.php>Theory of Computer Science</a>.</p>

<h3 class=blue>NP</h3>
<p>\(NP\) is a set that containing all 'languages' for which there exists a nondeterministic polynomial time Turing machine that can recognise it. Equivalently, it can be a set containing all 'languages' for which there exists a polynomial time Turing machine that can verify its configuration. For more detail, refer to <a href=http://zaco.au/daigaku/2023_spr/tcs.php>Theory of Computer Science</a>.</p>




<h2 class=red>Proof Prova 証明</h2>



<h3 class=red>Direct proof Prova diretta 直接証明</h3>
<p>Proving a statement directly</p>
<p>\( p \implies q \)</p>

<h3 class=red>Contrapositive proof Prova contrapositiva 対偶論法</h3>
<p>Proving a statement by demonstrating how the absense of an equivalence implies the condition not being met</p>
<p>\( \neg q \implies \neg p \)</p>

<h3 class=red>Proof by contradiction Prova per contraddizione 背理論法</h3>
<p>Proving a statement by assuming the inverse of the statement to demonstrate inconsistencies with previously affirmed statements and axioms</p>
<p>\( \neg q \implies 0 \)</p>

<h3 class=red>Proof by infinite descent</h3>
<p>Proof by contradiction by demonstrating that if some statement were true, it would have to be true for some smaller number.</p>



<h3 class=red>Diagonalization argument</h3>
<p>Proof by demonstrating the ability to construct some counterexample or contradictory element. For instance, Cantor proved th </p>


<h3 class=red>Without loss of generality</h3>
<p>WLOG, assumption that can be safely made in a proof since even if the assumption was incorrect, a construction could be made to logically extend the general case to the assumption </p>
<p>For instance when talking about convergent sequences \( \lim_{n \to \infty} A_n = 0\), one can assume WLOG that the sequence converges to 0  \( \lim_{n \to \infty} A_n = 0\), since even if it didn't one could just consider the construction \(\lim_{n \to\ \infty} A_n - L = 0\) instead</p>


<h3 class=red>Real algebraic inequalities</h3>
<p>\(a,b \in \mathbb{R} \implies\)</p>
<ul>
	<li>\(a &gt; b \implies a-b &gt; 0\)</li>
	<li>\( a^2 \geq 0\)</li>
	<li>\(ab \geq 0 \iff (a+b)^2 \geq a^2 + b^2\)</li>
	<li>\(|a+b| \geq |a| + |b|\)</li>
</ul>


<h3 class=red>Integral bounds</h3>
<p><a href=/daigaku/2023_spr/ra.php>Real Analysis</a> can employ concepts such as boundedness, compactness and the definition of a Riemann integral to prove bounds on certain integrals, this subject does not delve into this topic (it is not discrete), however it's pretty neat</p>
<p>\(f \text{ is monotone decreasing} \implies  (a-b)f(b) \lt \int_{a}^{b} f(x)dx \lt (a-b)f(a) \)</p>


<h3 class=red>Arithmetic Geometric mean inequality</h3>
<p>\( S \subseteq \mathbb{R}, A_{S} \geq G_{S} \)</p>
<p>Or in more detail...</p>
<p>\(S \subseteq \mathbb{R}, s \in S, N=|S|,\frac{ \sum_{n=1} s_{n} }{N} \geq \sqrt[N]{ \prod_{n=1} s_{n} } \)</p>
<p>As an extension, both means are equal when all elements are the same number</p>
<p>\(\forall k \in S, k \in \mathbb{R} , A_{S} = G_{S} \iff (\exists r \in \mathbb{R} | \forall k \in S, k \in \mathbb{R}, k=r)\)</p>



<h3 class=red>Conjecture Congettazione 推測</h3>
<p>Unproven statement with unknown truth</p>
<h3 class=red>Axiom Assioma 公理</h3>
<p>Unproven Statement that is taken to be a logically irreducible truth</p>
<h3 class=red>Lemma</h3>
<p>Proven statement used to provide sufficient basis for a theorem</p>
<h3 class=red>Proposition</h3>
<p>Proven statement that is an independent result</p>
<h3 class=red>Theorem</h3>
<p>Proven statement with significance</p>
<h3 class=red>Corrolary</h3>
<p>Proven statement that is a direct result of a theorem</p>

<h3 class=red>First element Primo elemento 最初要素</h3>
<p>\( S \subseteq \mathbb{N} \: \forall s \leq x \)
</p>


<h3 class=red>Existence</h3>
<p>\(\forall y ( \exists  x [ P(x,y)])  \)</p>
<h3 class=red>Uniqueness</h3>
<p>\(\exists ! x [ P(x)] \iff [ P(x) \land P(y) \iff x=y]\)</p>







<h2 class=yellow>Set theory</h2>



<h3><a class=yellow>Set Insieme 集合</a></h3>
<p>Well defined collection of elements characterized by some axiomatic set theory (commonly ZFC)</p>


<h3 class=yellow>Zermelo-Fraenkel set theory (ZF set theory)</h3>
<p>Collection of axioms which define the properties of sets along with the controversial axiom of choice</p>
<p>\(\varphi\) is a predicate</p>
<h4 class=yellow>Axiom of extensionality</h4>
<p>Statement that sets with the same elements are equal</p>
<p>\( \forall x\forall y [ \forall z (z \in x \iff z \in y) \implies x=y ] \)</p>
<h4 class=yellow>Axiom of regularity</h4>
<p>Statement that nonempty sets with the same elements are equal</p>
<p>\( \forall x\forall y [ \forall z (z \in x \iff z \in y) \implies x=y ] \)</p>
<p>\( \forall x [ \exists a (a \in x) \implies \exists y ( y \in x \land \nexists z (z \in y \land z \in x) ] \)</p>
<p>\( \forall x [ x \neq \emptyset \implies \exists y \in x ( y \cap x = \emptyset) ] \)</p>


<ul>
	<li>\( \forall x\forall y [ \forall z (z \in x \iff z \in y) \implies x=y ] \) (Axiom of extensionality)</li>
	<li>\( \forall x [ \exists a (a \in x) \implies \exists y ( y \in x \land \nexists z (z \in y \land z \in x) ] \) (Axiom of regularity)</li>
	<li>\( \forall x [ x \neq \emptyset \implies \exists y \in x ( y \cap x = \emptyset) ] \) (Axiom of regularity)</li>
	<li>\( \forall A, \exists B, \forall x, (x \in B \iff x \in S \land \varphi(x)) \) (Axiom of separation)</li>
	<li>\( \forall x \forall y \exists z ( x \in z \land y \in z) \) (Axiom of pairing)</li>
	<li>\( \forall A, \exists C, \forall x, (x \in C \iff \exists B, (x \in B \land)) \) (Axiom of union)</li>
	<li> (Axiom of powersets)</li>
	<li> (Axiom of infinity)</li>
	<li> (Axiom of regularity)</li>
	<li> (Axiom of replacement)</li>
	<li> (Axiom of choice)</li>
</ul>


<h3 class=yellow>Set notation</h3>
<p>A set's symbol is often a capitalized letter, and its representation is a set of braces around the set elements, which are separated by commas.</p>
<ul>
	<li>Collection of elements in braces</li>
	<li>Collection of elements in braces with trailing dots</li>
	<li>Symbol (often capitalized)</li>
	<li>Set builder notation in braces</li>
	<li>Set builder notation with universe of discourse in braces</li>
</ul>
<p>\(S = \{6,2,0,4,9\}\)</p>
<p>\(M = \{\text{Mario}, \text{Luigi}, \text{Peach}\}\)</p>
<p>\(\mathbb{N} = \{ 0,1,2,3, \cdots \}\)</p>
<h4 class=yellow>Set builder notation</h4>
<p>\( \{ x : P(x)  \}\)</p>
<p>\( \{ x \in U : P(x)  \}\)</p>
<ul>
	<li>\(:\) is the 'such that' symbol</li>
	<li>\(x\) is a bound variable representing members of the set</li>
	<li>\(P\) is a predicate</li>
	<li>\(U\) is the universe of discourse (may be omitted when obvious)</li>
</ul>
<p>\(3\mathbb{Z} = \{ n \in \mathbb{Z} : 3|n  \}\)</p>

<h3><a class=yellow>Element Elemento 要素</a></h3>
<p>Object in a set, can be variables and conditions</p>

<h3 class=yellow>Union Unione 和集合</h3>
<p>Set operation forming the set of elements containd within the scope of 'A' or 'B'</p>
<p>\( A \cup B = \{x : x \in A \lor x \in B \}\)</p>

<h3 class=yellow>Intersection Intersezione 積集合</h3>
<p>Set operation forming the set of elements contained in both 'A' and 'B'</p>
<p>\( A \cap B = \{x : x \in A \land x \in B \}\)</p>

<h3 class=yellow>Set difference</h3>
<p>Binary set operator of removing all items of set 'B' from set 'A'</p>
<p>\( A \setminus B = \{x \in A : x \notin B \}\)</p>
<p>\( A \setminus B = A \cap \overline{B}\)</p>

<h3 class=yellow>Complement set</h3>
<p>Unary set operator</p>
<p>A complement set of a subset includes all the elements in the superset and not in the subset; the other part of the set. For the following, let \(X\) be the set space:</p>
<p>\( A^{c},\bar{A} = X \setminus A \)</p>
<p>\( A \cup A^{c} = X\)</p>
<p>\( A \cap A^{c} = \emptyset \)</p>
<p>\( A\setminus B = A \cap B^{c}\)</p>

<h3 class=yellow>Subset</h3>
<p>Set such that all its elements are also contained in another set (called a <b>superset</b>). The notation \(A \subset B\) is used to </p>
<p>\( A \subseteq B \iff A \cap \bar{B} = \emptyset\)</p>
<h4 class=yellow>Strict subset</h4>
<p>Subset that is not equal to its superset</p>
<p>\( A \subset B \iff (A \subseteq B \land A \neq B)\)</p>



<h3 class=yellow>Empty set Insieme vuoto 空集合</h3>
<p>Set with no elements (hence a cardinality of 0)</p>
<p>\( \emptyset \)</p>
<p>\( |\emptyset| = 0 \)</p>

<h3 class=yellow>Disjoint sets</h3>
<p>Two sets are disjoint is they have a null set as their intersection, no element is in both setsAlso called <b>Mutual exclusivity</b></p>
<p>\(A,B \text{ are pairwise disjoint } \iff A \cap B = \emptyset \)</p>

<h3 class=yellow>Partition</h3>
<p>Given some set \(S\) a partition is a family of mutually exclusive sets that form \(S\) under union</p>
<p>\(P \text{ is a partition on }S \iff \)</p>
<ul>
	<li>\(\bigcup_{P_n \in P} P_n = S\)</li>
	<li>\(\forall n,k( n\neq k \implies P_n \cap P_k = \emptyset )\)</li>
	<li>\(\emptyset \notin P \)</li>
</ul>



<h3 class=yellow>Closure</h3>
<p>\( A \text{ is closed under } \cdot \iff \forall a_1 , a_2 \in A , a_1 \cdot a_2 \in A \)</p>

<h3 class=yellow>Set relation laws</h3>
<p>intersections and unions are commutative (like addition and multiplication, order doesn't matter)</p>
<ul>
	<li>\( (A \cup B) \cap C = (A \cap C) \cup (B \cap C) \)</li>
	<li>\( (A \cap B) \cup C = (A \cup C) \cap (B \cup C) \)</li>
	<li>\( (A \cup B) \setminus C = (A \setminus C) \cup (B \setminus C) \)</li>
	<li>\( (A \cap B) \setminus C = (A \setminus C) \cap (B \setminus C) \)</li>
</ul>



<h3 class=yellow>De Morgan's sets laws</h3>
<p>Laws that determine relational properties of sets</p>
<ul>
	<li>\( (\bigcup_{i=1}^{\infty} A_{i})^{c} = \bigcap_{i=1}^{\infty} A_{i}^{c}\)</li>
	<li>\( (\bigcap_{i=1}^{\infty} A_{i})^{c} = \bigcup_{i=1}^{\infty} A_{i}^{c}\)</li>
</ul>

<h3 class=yellow>Countability Numerabilità 可算性</h3>
<p>\(S \text{ is countable } \iff \exists f : S \to \mathbb{N} ( f \text{ is bijective})\)</p>

<h3 class=yellow>Cardinal number</h3>
<p>Number representing quantity of elements in a set</p>
<h3 class=yellow>Ordinal number</h3>
<p>Number representing the order of an element</p>


<h3 class=yellow>Set inclusion</h3>
<p>Logical symbol \(\in\) denoting the inclusion of some element in some set</p>
<p>For instance \(42 \in \mathbb{N}\) is true and \(\pi \in \mathbb{Q}\) is not.</p>
<h4 class=yellow>Set exclusion</h4>
<h3><a class=yellow>\( \notin \)</a></h3>
<p>Logical symbol \(\notin\) denoting the exclusion of some element in some set</p>

<h3 class=yellow>Universal set</h3>
<p>A theoretical set \(\xi\) that contains all possible sets including itself. Its existence is impossible in ZFC as it fails Russel's paradox (see <a href=http://zaco.au/daigaku/2023_spr/tcs.php>Theory of Computer Science</a> for more detail).</p>

<h3 class=yellow>Venn diagram Diagramma di Venn ベン図</h3>
<p>Visual representation of set, not valid as proof</p>




<h3 class=blue>Set theoretic numbers</h3>
<ul>
	<li>Cardinal; quantities used to describe size of set</li>
	<li>Ordinal; quantities used to describe order</li>
</ul>


<h3 class=yellow>Aleph-Nought \(\aleph_{0}\)</h3>
<p>Cardinal number representing countable infinity</p>
<ul>
	<li>\( |\mathbb{N}| = \aleph_{0}\)</li>
	<li>\( |\mathbb{Z}| = \aleph_{0}\)</li>
	<li>\( |\mathbb{Q}| = \aleph_{0}\)</li>
</ul>


<h3 class=yellow>Omega \(\omega\)</h3>
<p>Denoted as \(\omega \), is an ordinal number used to represent the order of the number after all finite numbers (which if you count from a finite ordinal number, is unreachable). \(\omega \), \(\omega +1\), \(2\omega\), \(\omega^2\), \(\omega^\omega\), \(\varepsilon _{0}\) (which is a notation for \(\omega^{\omega^{\omega}}\))</p>
<p>\(\omega : \forall n \in \mathbb{N} \omega \gt n\)</p>


<h3 class=yellow>Aleph-One \(\aleph_{1}\)</h3>
<p>Cardinal number representing the smallest uncountable infinity</p>
<ul>
	<li>\( |\mathbb{R}| = \aleph_{1}\)</li>
</ul>

<h3 class=yellow>Cantor's theorem</h3>
<p>\(\mathcal{P}(\mathbb{N}) \text{ is uncountable}\)</p>
<h4 class=yellow>Proof</h4>
<p>Cantor's diagonalization argument.</p>



<h3 class=yellow>Cantor set</h3>
<p>Consider a sequence of sets \(\mathcal{C}_{n}\). Set \(\mathcal{C}_{0} = [0,1]\), removing the 'middle third' of the set to form \(\mathcal{C}_{1} = [0,\frac{1}{3}] \cup [\frac{2}{3},1]\), then removing the middle thirds for the remaining two thirds to form \(\mathcal{C}_{2} = [0,\frac{1}{9}] \cup [\frac{2}{9},\frac{1}{3}] \cup [\frac{2}{3},\frac{7}{9}] \cup [\frac{8}{9},1]\), and this process is conducted ad infinitum. Then:</p>
<p>\(\mathcal{C} = \bigcap^{\infty}_{n=1} \mathcal{C}_{n} =  \lim_{n \to \infty}\mathcal{C}_{n}\)</p>
<p>It represents numbers representable by \( \sum^{\infty} \sum_{k=1} \frac{a_k}{3^k} : a_{k} = \begin{cases} 0 \\ 2 \end{cases}\), hence by Cantor's diagonal argument this set is uncountable</p>





<h2 class=green>Induction</h2>



<h3 class=green>Well-ordering Principle</h3>
<p>All subsets of \( \mathbb{N} \) that aren't empty have a first element. Induction hinges off this fact to prove for some first element and then prove this form holds for all elements in this subset.</p>
<p>\( \forall S : S \subseteq \mathbb{N} \land S \neq \emptyset, \exists s \in S : s \text{ is the first element}\)</p>

<h3 class=green>Principle of mathematical induction</h3>
<ol>
	<li>Prove statement for a non-variable constant such as 1, 4, 6, etc. (that we will denote with constant \(c\))</li>
	<li>Assume statement is true for variable \(k\)</li>
	<li>Prove statement for \(k+1\) to prove \(\forall n \geq c\)</li>
</ol>
<p>\( \forall n \in \mathbb{N} \geq c, P(n)  \iff  ( P(c) \land ( P(k) \implies P(k+1)) )\)</p>

<h3 class=green>Strong induction</h3>
<p>A variant of induction that sets up a larger range of statements to draw from in proving some argument.</p>
<p>\( \forall n \in \mathbb{N} \geq c, P(n)  \iff  ( P(c) \land ( \bigwedge_{i=1}^{k-c} P(c + i) \implies P(k+1)) )\)</p>


<h3 class=green>Algorithm correctness</h3>
<p>An algorithm is correct iff it:</p>
<ul>
	<li>Terminates after a finite number of steps</li>
	<li>Returns the correct value</li>
</ul>

<h3 class=green>Loop invariant</h3>
<p>Mathematical statement involving variables that holds after every iteration of a loop</p>
<h3 class=green>Termination Terminazione 終止</h3>
<p>Mathematical statement that when satisfied after an iteration of a loop, ends said loop</p>

<h3 class=green>Big-\(O\) Grande-\(O\) 大-\(O\)</h3>
<p>\( \exists k,M\in \mathbb{R} : \forall n \geq k,|f(n)| \leq Mg(n) \iff f \in O(g)\)</p>
<p>Big-O is a way of categorising functions by which functions eventually 'dominate' them, for instance, \(x^2 \in O(e^x)\) since there comes a point in the function where \(e^x\) will always be larger than \(x^2\)</p>




<h2 class=indigo>Relations & functions</h2>



<h3><a class=indigo>Ordered pair Coppia ordinata 順序対</a></h3>
<p>Two coupled numbers from two sets that are bound by a relation. The order of this pair is crucial as the ordered pairs are formed as such</p>
<p>\( (a,b) : a \in A, b \in B \)</p>
<p>The following example creates a basic set of ordered pairs based on the cartesian product of two sets A and B</p>
<p>\( A \times B = \{(a,b) : a \in A , b \in B\} \)</p>

<h3 class=indigo>Relation</h3>
<p>Set of ordered pairs \(R\)</p>
<p>\( xRy \iff (x,y) \in R\)</p>
<p>Note that \(R\) acts as both a set and a characteristic function in this definition</p>
<p>The symbol \(\sim\) is used for equivalence relations (defined below)</p>

<h3 class=indigo>Relation properties</h3>
<h4 class=indigo>Reflexive Riflessivo 反射的</h4>
<p>\(R \text{ is reflexive } \iff \forall x \in X, xRx\)</p>
<h4 class=indigo>Symmetric Simmetrico 対称的</h4>
<p>\(R \text{ is symmetric } \iff (\forall x,y \in X, xRy \implies yRx)\)</p>
<h4 class=indigo>Antisymmetric Antisimmetrico 反対称的</h4>
<p>\(R \text{ is antisymmetric } \iff (\forall x,y \in X, xRy \land xRy \implies x=y)\)</p>
<h4 class=indigo>Transitive Transitivo 推移的</h4>
<p>\(R \text{ is transitive } \iff (\forall x,y,z \in X, xRy \land yRz \implies xRz)\)</p>

<h3 class=indigo>Equivalence relation Relazione d'equivalenza</h3>
<p>Relation \(\sim\) with the properties generally associated with equality of mathematical objects</p>
<p>\(\sim \text{ is an equivalence relation } \iff \sim \text{ is reflexive, symmetric, and transitive}\)</p>
<h4 class=indigo>Equivalence class</h4>
<p>Subset of \(X\) with all the elements \(x\) that satisfy \(a \sim x\)</p>
<p>\( [a] = \{ x \in X : a \sim x \}\)</p>

<h3 class=indigo>Partial order Ordine parziale</h3>
<p>Relation that is reflexive, antisymmetric and transitive</p>
<p>\(R \text{ is a partial order } \iff R \text{ is reflexive, antisymmetric, and transitive}\)</p>

<h3 class=indigo>Powerset Gruppo di potenza 冪集合</h3>
<p>Set containing all possible subsets of some set (this includes the null set)</p>
<p>\( \mathcal{P}(S) = \{ s : s \subseteq S \}\)</p>
<p>\( |\mathcal{P}(S)| = 2^{|S|} = \sum^{|S|}_{n=0} \binom{|S|}{n} \)</p>


<h3 class=indigo>Hassee diagram</h3>
<p>Diagram of power sets, the first branch for |A|-1 (where A is the set, so
  |A|-1 is the size of A minus one)
</p>

<h3 class=indigo>Function Funzione 機能</h3>
<p>Relationship \(f : X \to Y\) where each domain elements \(X\) has a single mapping</p>
<p>\(f \text{ is a function } \iff ( \forall x,y,z \in X, xfy \implies \nexists z \in \mathbb{R} \setminus y : xfz)\)</p>
<p>\(f(x)=y \iff xfy\)</p>

<h3 class=indigo>Function properties</h3>
<h4 class=indigo>Injection Iniezone 単射</h4>
<p>Property such that there are no mappings of different domain and same range. This is also known as a <b>one to one relationship</b></p>
<p>\( f \text{ is injective } \iff (\forall x,y \in X, f(x)=f(y) \implies x=y )\)</p>
<h4 class=indigo>Surjection Suriezione 全射</h4>
<p>Property such that every range element has a mapping. This is also known as a <b>onto relationship</b></p>
<p>\( f \text{ is surjective } \iff (\forall y \in Y,\exists x \in X : f(x)=y)\)</p>
<h4 class=indigo>Bijection Biiezione 全単射</h4>
<p>Property such that injection and surjection holds.</p>
<p>\( f \text{ is bijective } \iff f \text{ is surjective and injective}\)</p>


<h3 class=indigo>Ackermann's Function Funzione di Ackermann アッカーマンの関数</h3>
<p>A 20th century algorithm that serves as an example of recursion</p>
<p>\( A(m,n) = \begin{cases} n+1 & m = 0 \\ A(m-1,1) & n=0,m \gt 0 \\ A(m-1,A(m,n-1)) & m,n \gt 0 \end{cases}\)</p>






<h2 class=cyan>Combinatorics</h2>



<p>'The key to combinatorics is the counting principles with bijections.'</p>

<h3 class=cyan>Multiplication Principle Principio di moltiplicazione 乗法原理</h3>
<p>Principle that multiplication enumerates events occuring in succession (all events occur in conjunction)</p>
<p>\(\prod^{n}_{k=1} |C_k|\)</p>
<ul><li>\(C_{k}\) represents the enumeration in case \(k\), given that the previous \(k-1\) cases have occured</li></ul>

<h3 class=cyan>Addition Principle Principio d'adizione 加法原理</h3>
<p>Principle that addition enumerates events occuring distinctly (if one event occurs, the other events do not)</p>
<p>\(\sum^{n}_{k=1} |C_k|\)</p>
<ul><li>\(C_{k}\) represents the enumeration in case \(k\), given that only one case occurs</li></ul>
<h3 class=cyan>Division principle Principio di divizione 除法原理</h3>
<p>Principle that division by \(d\) de-enumerates unimportant events if each desired event has \(d-1\) unimportant events</p>


<h3 class=cyan>Pidgeon hole principle Principio dei cassetti 引出しの論理</h3>
<p>Principle that when assigning one of \(n\) 'states' (or mappings) to an object in some set \(S\), if \(|S| \gt n\) then at least two objects must share the same 'state'. For instance, in a room of \(8=7+1\) people, there must be at least two people that were born on the same day of the week.</p>
<p>\( f: A \to B \text{ is surjective } \land |A| \gt |B| \implies \exists a_1,a_2 \in A [ f(a_1)=f(a_2) ] \)</p>

<h3 class=cyan>Factorial properties</h3>
<ul>
	<li>\( n! = (n-1)!n \)</li>
	<li>\( n! = \prod_{k=1}^{n} k \)</li>
	<li>\( \frac{n!}{(a-1)!} = \prod_{k=a}^{n} k \)</li>
</ul>

<h3 class=cyan>Inclusion-Exclusion Principle</h3>
<p>When counting the cardinality of union sets, the idea is to add the sizes of the set together and then minus the amount of elements that were 'double-counted'</p>
<p> \( | \bigcup_{k=1}^{n} S_k| = \sum_{\emptyset \neq J \subseteq \{1,...,n\} } (-1)^{|J|+1} | \bigcap_{j \in J} S_j| \)</p>
<h3 class=cyan>2 sets</h3>
<p>For two sets, \(|A| + |B|\) will count the elements of \(A \cap B\) twice, therefore</p>
<p> \( | A \cup B| = |A| + |B| - |A \cap B| \)</p>
<h3 class=cyan>3 sets</h3>
<p>For three sets, the intersects of any two set will be counted twice, and the intersection of all three sets will be counted thrice, but in deleting all doubly counted elements, we will accidentally delete the elements of \(A \cap B \cap C\) from the count, so we add it back</p>
<p> \( | A \cup B \cup C| = |A| + |B| + |C| - |A \cap B|  - |A \cap C| - |B \cap C| + |A \cap B \cap C|\)</p>

  
<h3 class=cyan>Permutation Permutazione 置換</h3>
<p>Enumeration of ordered \(k\)-tuples that can be formed by selecting elements from a set \(S\) of \(n\) elements.</p>
<!--<p>Counting the ordered arrangements of a set with size \(k\) that is formed from a selection of \(n\) distinct elements. For instance, I have to make a \(3\)-tuple and I have \(10\) elements at my disposal. With mutltiplication principle (since each choice ), we see I can order the set in \(10 \times 9 \times 8= \frac{10!}{7!} \) ways</p>-->
<h4 class=cyan>Without repetition (\(k\)-permutations of \(n\))</h4>
<p>Disallowing multiple selections of the same element \(s \in S\) produces the following formula</p>
<p>\( P(n,k)=\frac{n!}{(n-k)!} \)</p>
<ul>
	<li>\(n\) is the amount of possible elements to employ</li>
	<li>\(k\) is the amount of elements that are employed</li>
</ul>
<h4 class=cyan>With repetition</h4>
<p>Allowing unlimited selections of the same element \(s \in S\) produces the following formula</p>
<p>\( n^k \)</p>

<!--<p>In the case of permutations with repetition of a certain element, we only care about unique sets, so if you think about it recursively, we want to get the permutation of the entire set, then divide it by the permutation of the repeated elements \(k!\), so if we want to find the ways we could uniquely order the word \(\text{HELLO}\) in 5 symbols, we have the permutation of all letters \(5!\) divided by the permutation of the 'L's \(2!\). If there are several groups of repetition, like for a 7 symbol word with the letters \(\text{BABOOON}\) (extra O intentional), it's the permutation of all letters \(7!\) divided by the permutation of the 'B's \(2!\) then divided by the permutation of the 'O's \(3!\).</p>-->

<h3 class=cyan>Combination Combinazione 組合せ</h3>
<p>Enumeration of unordered sets of size \(k\) that can be formed by selecting elements from a set of \(n\) elements without repetition.</p>
<!--<p>Counting the unordered arrangements of a set with size \(k\) that is formed from a selection of \(n\) distinct elements.</p>
<p>The number of subsets of size \(k\) that can be created where sets have no order</p>-->
<h4 class=cyan>Without repetition (\(k\)-combinations of \(n\))</h4>
<p>\( C(n,k)=\frac{P(n,k)}{P(k,k)}=\frac{n!}{k!(n-k)!}=\binom{n}{k} \)</p>
<ul>
	<li>\(n\) is the possible mount of elements to employed</li>
	<li>\(k\) is the amount of elements that are employed</li>
</ul>
<p>This is bijective to the enumeration of arrangements of an ordered \(n\)-tuple, of which elements are partitioned into a class of \(k\) and \(n-k\) elements and permutations of elements of the same class are not counted.</p>
<h4 class=cyan>With repetition</h4>
<p>\( C(n+k-1,k)=\binom{n+k-1}{k} \)</p>


<h3 class=cyan>Binomial Coefficient</h3>
<p>Notation for the \(k\)th coefficients of a binomial of degree \(n\)</p>
<p>\( \binom{n}{k} = \frac{n!}{k!(n-k)!}\)</p>
<h4 class=cyan>Propositions</h4>
<p>\( \binom{n}{0} = \binom{n}{n} = 1 \)</p>
<p>\( \binom{n}{k} = \binom{n}{n-k} \)</p>
<p>\( \binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k} \)</p>
<p>\( \binom{2n}{n} = \sum^{n}_{k=0} \binom{n}{k}^{2} \)</p>
<p>\( \sum^{n}_{k=0} \binom{n}{k} = 2^{n}\)</p>
<h4 class=cyan>Vandermonde's convolution</h4>
<p>\( \binom{r+s}{n} = \sum^{n}_{k=0} \binom{r}{k} \binom{s}{n-k} \)</p>

<h3><a class=cyan>Binary string</a></h3>
<p>Sequence of 0s and 1s</p>
<p>\( ( c_k )^{n}_{k=0} : \forall k (c_{i} \in \{0,1\})\)</p>
<h4 class=cyan>Empty string</h4>
<p>Binary string of length 0, denoted as \(\lambda\) in mathematics and as \(\varepsilon\) in computer science</p>
<h4 class=cyan>Square</h4>
<p>Binary string that either is or contains another binary string that fits form XX (so 1010 is 10*10, which are two identical binary strings next to eachother)
</p>


<h3 class=cyan>Pascal's triangle</h3>
<p>Triangle formed by the binomial coefficients \( \binom{n}{k}\) where \(n \geq 0\) is the row and \(0 \leq k \leq n\) is the column.</p>

<h3 class=cyan>Binomial theorem Teorema binomiale 二項定理</h3>
<p>General form of the expansion of a binomial</p>
<p>\( (x+y)^{n} = \sum^{n}_{i=0} \binom{n}{i} x^{i}y^{n-i} \)</p>
<ul>
	<li>\( \binom{n}{k} = \frac{P(n,n)}{P(n-k,n-k)P(k,k)} = C(n,k) = \frac{n!}{k! (n-k)!} \) is the binomial coefficient, enumerating permutations of \(x\)s and \(y\)s, ignoring permutations of the \(x\)s and themselves and the \(y\)s and themselves
		<ul>
			<li>\(P(n,n)\) represents all \(n\)-tuples with \(n-k\) \(x\)s and \(k\) \(y\)s</li>
			<li>\(P(n-k,n-k)\) represents all orderings of the \(n-k\) \(x\)s in the \(n\)-tuple</li>
			<li>\(P(k,k)\) represents all orderings of the \(k\) \(y\)s in the \(n\)-tuple</li>
		</ul>
	</li>
</ul>

<h3><a class=cyan>Counting paths</a></h3>
<p>The formula; "think recursively". For instance, think of yourself at a crossroads with two initial paths. The amount of total paths until you've reached some end is \(P(p_0)=2+P(p_1)+ P(p_2)\)</p>


<h3 class=cyan>Catalan numbers</h3>
<p>Catalan numbers count the amount of objects that fufil "ordered-parity balancing" such as Dyck words, balanced bracket expressions with length \(2n\). One may see the relevance of Catalan numbers with issues relating to the stack.</p>
<p>\( C_n = \frac{1}{n+1} \binom{2n}{n}\)</p>
<p>\( C_{n+1} = \sum_{k=0}^{n} C_k C_{n-k}\)</p>
<h4 class=cyan>Closed-form proof</h4>
<p>The permutations of \(n\) ( symbols and \(n\) ) symbols is represented by \( \binom{2n}{n}\). Now one must remove all invalid permutations that do not have "ordered-parity balancing" (So rejecting strings like '())(()' and accepting strings like '()(())'). One may think of it as a string of brackets where each '(' adds one to some value and each ')' minuses one to that value, with the value starting at 0, so for instance \( (())() \implies 1+1-1-1+1-1=0\). The string is invalid if the value doesn't equal 0 (this is already handled in \( \binom{2n}{n}\)) or if at any term the expression ever goes below zero (which we must now find a way to count and eliminate from \( \binom{2n}{n}\)).</p>
<p> For all strings invalid by the latter condition, we notice that when reading the string from left to right there is some specific interval at the string \(k\) where the value goes sub-zero and therefore invalid (hence the symbol at \(k\) must also be a ')'), and within these first \(k\) terms one can find \(\frac{k-1}{2}\) '(' symbols and \(\frac{k-1}{2} +1 = \frac{k+1}{2}\) ')' symbols (because there is an extra ')' that ruins the parity in these first \(k\) symbols; notice how both of them added is \(k\) as it should be). Now, if one swaps the parity of the first \(k\) symbols, the entire string should add up to 2, and is in bijection with strings invalid by the second condition. In this converted string, one has \((\frac{k+1}{2}) + (n- \frac{k-1}{2}) = n+1\) '(' symbols and hence \(n-1\) ')' symbols, and since these strings are in bijection with the second-condition invalid strings we can count the second-condition invalid strings with \( \binom{2n}{n+1}\). Therefore \(C_n = \binom{2n}{n} - \binom{2n}{n+1} = \frac{1}{n+1} \binom{2n}{n}\) </p>

<h4 class=cyan>Recursive-form proof</h4>



<h2 class=red>Number theory</h2>




<h3 class=red>\(\mathbb{N}\)</a></h3>
<p>Countable set of natural numbers, the simplest set on which addition is defined completely</p>
<p>\( \mathbb{N} = \{0,1,2,3,4,5,...\} \)</p>
<p>\( \mathbb{N} = \{0 \}  \cup \{ a : a-1 \in \mathbb{N} \} \)</p>
<p>\( |\mathbb{N}| = \aleph_{0}\)</p>

<h3 class=red>\(\mathbb{Z}\)</a></h3>
<p>Countable set of integers, superset of \(\mathbb{N}\) on which subtraction is defined completely</p>
<p>\( \mathbb{Z} = \{b-a : a,b \in \mathbb{N} \} \)</p>
<p>\( |\mathbb{Z}| = \aleph_{0}\)</p>

<h3 class=red>\(\mathbb{Q}\)</a></h3>
<p>Countable set of rational numbers, superset of \(\mathbb{Z}\) on which division is defined completely except for division by zero</p>
<p>\( \mathbb{Q} = \{\frac{b}{a} : a,b \in \mathbb{Z} \land a \neq 0\} \)</p>
<p>\( |\mathbb{Q}| = \aleph_{0}\)</p>


<h3 class=red>\(\mathbb{R}\)</a></h3>
<p>Uncountable set of real numbers, superset of \(\mathbb{Q}\) representing all numbers that some rational sequence can approach</p>
<p>\( \mathbb{R} = \{ a : ( \exists a_n : \mathbb{N} \to \mathbb{Q} )( \lim_{n \to \infty} a_n = a)\}\)</p>
<p>\( |\mathbb{R}| = \aleph_{1}\)</p>

<h3 class=red>\(\mathbb{C}\)</a></h3>
<p>Uncountable set of complex numbers, superset of \(\mathbb{R}\) extending the reals to the complex field by defining all operations with respect to the imaginary unit</p>
<p>\( \mathbb{C} = \{ a+bi : a,b \in \mathbb{R} \} \)</p>


<h3 class=red>\(\mathbb{A}\)</h3>
<p>Set of algebraic numbers</p>
<p>\( a \in \mathbb{A} \iff (\exists P(x) \text{ with rational coefficients } : P(a)=0 ) \)</p>


<h3 class=red>Divisibility</h3>
<p>Relationship between integers such that \(b\) is some multiple of \(a\).</p>
<p>\( a|b \iff \exists k \in \mathbb{Z}: b=ka  \)</p>
<ul>
	<li>\(b\) is the <b>dividend</b></li>
	<li>\(a\) is the <b>divisor</b> and when the statement holds, is a <b>factor</b> of \(b\)</li>
	<li>\(k\) is the <b>quotient</b></li>
</ul>

<h3 class=red>Primality</h3>
<p>Property of an integer such that it has no divisor other than itself and 1</p>
<p>\( p \text{ is prime } \iff \nexists q \in \mathbb{N} \setminus 1 :  q|p \)</p>
<h4 class=red>Coprimality</h4>
<p>Relationship between integers such that they share no common factors other than 1. In this situation, the two integers are said to be <b>relatively prime</b> or <b>coprime</b></p>
<p>\( p,q \text{ are coprime } \iff \gcd (p,q)=1\)</p>

<h3 class=red>Lowest Common Multiple (LCM)</h3>
<p>The lowest common multiple of some set \(S\) is the smallest possible number such that all \(s\in S\) divide this number </p>
<p>\(\text{lcm} (S) = \min \{k : \forall s \in S, s|k \} \)</p>

<h3 class=red>Greatest Common Divisor (GCD)</h3>
<p>The greatest common denominatorof some set \(S\) is the smallest possible number such that all \(s\in S\) divide this number </p>
<p>\(\gcd (S) = \max \{k : \forall s \in S, k|s \} \)</p>
<p>\(\gcd (a,b) \cdot \text{lcm} (a,b) = a \cdot b \)</p>


<h3 class=red>Euclid's division lemma</h3>
<p>Lemma that asserts the uniqueness and relationship of the quotient and remainder of two numbers.</p>
<p>\(\forall a,b \in \mathbb{Z} b\neq 0, \exists! q,r \in \mathbb{Z} : a =bq +r : 0 \leq r \lt |b|\)</p>

<h3 class=red>Euclidean algorithm</h3>
<p>Algorithm used to find \(\gcd (q,d) \) in running time \(O(\log(\min (q,d)))\). </p>
<p> It works by recursively finding a number that is divisible by both the divisor \(d\) and the remainder, since if the number goes into the divisor and the remainder, it also goes into the quotient</p>
<p>\(q,r \in \mathbb{N},0 \leq r \leq d, q=kd+r\)</p>
<p>\(\gcd (q,d) = \gcd (d,r)\)</p>




<h3 class=red>Modular reduction</h3>
<p>The concept of finding the remainder of the division of two integers, say \(x,n\), or in other words, how numerically far \(x\) is from being a multiple of \(n\)</p>
<p>\(x \equiv y \mod n \iff \exists k \in \mathbb{Z} ( x=kn+y ) \)</p>
<p>This means that \(n|x-y\) and we can say that \(x\) is congruent to \(y\) for modulo \(n\)</p>
<p>An alternative shortened notation for modular arithmetic is \(x \equiv y \mod n \iff [x]_n=y\)</p>


<h3 class=red>Modular arithmetic</h3>
<p>Arithmetic with modular reduction is symmetric, symmetric, and transitive, as well as fufilling the following:</p>
<ul>
	<li>\(x \equiv y \mod n \implies x+k \equiv y+k \mod n\)</li>
	<li>\(x \equiv y \mod n \implies k\in \mathbb{Z}, kx \equiv ky \mod n\)</li>
	<li>\(x,y \in \mathbb{Z}, x \equiv y \mod n \implies k\in \mathbb{N}, x^{k} \equiv y^{k} \mod n\)</li>
</ul>


<h3 class=red>Modular multiplicative inverse</h3>
<p>\( \gcd (a,n)=1 \implies \exists a^{-1} : a^{-1}a \equiv 1 \mod n \)</p>
<p>Integer such that when multiplied with another number \(a\) with modulo of some number \(n\), returns 1. It can be determined through reverse euclidean algorithm</p>

<h3 class=red>Affine cipher</h3>
<p>\(f(x) = (ax+b) \mod 26\)</p>
<p>Linear cipher function that employs modular arithmetic to map each of the 26 letters with another letter. The function is best when a and b are chosen to make a bijective set for values of x from 1 to 26 (this is done by choosing \(a\) coprime to 26 and choosing ).</p>





<h4 class=red>Final digit</h4>
<p>The rightmost digit of a number \(n\) can be though of as \( n \mod 10\) in the decimal system. This sheds light to a few tricks that can be used to enumerate the final digit of \(n\), for instance:</p>
<ul>
	<li>\(123 \cdot 321\) can be reduced to \(3 \cdot 1=3\) (modular arithmetic laws)</li>
	<li>For \(2^{13}\), since we know that powers of 2 reduced mod 10 follow the cycle \(2_1,4_2,8_3,6_0\) and since \(13 \mod 4 = 1\), therefore the final digit is \(2\)</li>
	<li>\(7!\) expanded is \(1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 \cdot 6 \cdot 7\) and so has the factor \(5 \cdot 2 10\) and therefore has a final digit \(0\) since the number is a multiple of 10</li>
</ul>


<h3 class=red>Digital root</h3>
<p> Denoted as \( \text{dr}(n) \), all digits added together until a single digit number reached, \(365 \to 3+6+5=14 \to 1+4=5\). Note that adding some digit 9 does not change the digital root since digital roots can be thought of as putting the number \(\mod 9\) since \(\forall k \in \mathbb{N}, 10^k \mod 9 = 1\) and when paired with BRT, proves digital roots show whether a number can be divided by 9</p>
<h4 class=red>Theorems</h4>
<p>\(3|n \iff 3|\text{dr}(n)\)</p>
<p>\(9|n \iff 9|\text{dr}(n)\)</p>



<h3 class=red>Repeated squaring</h3>
<p>Method of representing an exponentiated number into products such that the powers are powers of two. This allows for each product term to be recursively resolved.</p>
<p>\([m^e]_n\)</p>
<h4 class=red>Method</h4>
<ol>
	<li>Find binary power expansion \(m^e = m^{2^{\lfloor \log_{2}(e) \rfloor}k_{ \lfloor \log_{2}(e) \rfloor + 1}}... m^{4 k_3} m^{2 k_2} m^{k_1} : k_i \in \{0,1\} \)</li>
	<li>Recursively resolve each term using the rule \( [ m^{2^{i+1}} ]_n =  [ [ m^{2^{i}} ]_{n}^{2} ]_{n} \)</li>
</ol>



<h3 class=red>Square number</h3>
<p>Number with the property that its square root is an integer</p>
<p>\(k^2 = \sum_{n=1}^{k} 2n-1\)</p>





<h3 class=red>Additive group of integers modulo \(n\)</h3>
<p>Set of all integers from 0 to n-1; these elements are closed under \(\mod n\) addition</p>
<p>\(\mathbb{Z} \setminus n \mathbb{Z} = \mathbb{Z} \cap [0,n-1]\)</p>

<h3 class=red>Multiplicative group of integers modulo \(n\)</h3>
<p>Set of all integers from 1 to n-1 that are coprime to n; these elements are closed under \(\mod n\) multiplication</p>
<p>\( (\mathbb{Z} \setminus n \mathbb{Z})^{\times}  = \{ k  \in \mathbb{Z}\cap [1,n]  :  \gcd (n,k)=1 \} \)</p>


<h3 class=red>Euler's totient function オイラーのトーシェント関数</h3>
<p>Function \(\varphi : \mathbb{Z} \to \mathbb{Z}\) that returns the cardinality of \( (\mathbb{Z} \setminus n \mathbb{Z})^{\times} \)</p>
<p>\( \varphi (n) = |(\mathbb{Z} \setminus n \mathbb{Z})^{\times}| \)</p>
<p>\( \varphi (n) = n\prod_{p|n} (1- \frac{1}{p}) \)</p>
<h4 class=red>Properties</h4>
<ul>
	<li>\( \varphi(p)=p-1  \)</li>
	<li>\( \varphi(p^n)=p^n-p^{n-1}  \)</li>
	<li>\( \gcd (n,m) = 1 \implies \varphi(nm) = \varphi (n) \varphi (m) \)</li>
	<li>\( \sum_{d | n} \varphi(d) = n \)</li>
</ul>
<h4 class=red>Proofs</h4>
<p>For the third lemma, this is proved by establishing a bijection between \( \mathbb{Z}_{nk}^{*}\) and \(  \mathbb{Z}_{n}^{*} \times \mathbb{Z}_{k}^{*} \). This can be done by showing surjection and injection by the function \(f(X)=(X \mod n , X \mod k) \). To do this, modular arithmetic can be used to show surjection and Chinese remainder theorem to show injection.</p>
<p>The fourth lemma is a result of partitioning the set \(S = \{1,2,3,...,n\}\) into an array of sets that have some common divisor, so \(S_{d_i} = \{ s \in S : \gcd (s,n)= d_{i}\}\). Note that the sum of the cardinalities of these sets equals \(n\) since a number cannot have two GCDs with \(n\); the GCD partitions \(S\) into disjoint sets without repetition. The sets \(S_{d_i}\) can each have all elements divided by \(d_i\) since all elements are divisible by \(d_i\), now doing this turns each \(S_{d_i} \to \mathbb{Z}^{*}_{d_i}\), meaning that the cardinalities of each of these sets is represented as \( \varphi (d_i)\). Recall that these sets are just partitions of the original set containing all numbers up to \(n\), so we have proved this fourth lemma.</p>
<p>Showing that \(f : \mathbb{Z}_{nm}^{*} \to \mathbb{Z}_{m}^{*} \times \mathbb{Z}_{n}^{*}  \) is bijective when \(\gcd (m,n) = 1 \) proves this statement, since bijectivity implies equal cardinalities. \( \gcd(x,nm) =1 \iff \gcd(x,m) =1 \land \gcd(x,n)=1 \iff \gcd([x]_m,m) =1 \land \gcd([x]_n,n)=1\) by Euclid's corrolary and Euclidean algorithm, so both the domain and codomain have the same cardinalitiy</p>


<h3 class=red>Euler's theorem Teoria di Euler オイラー定理</h3>
<p>\( \gcd (a,n)=1 \implies a^{\varphi (n)} \equiv 1 \mod n \)</p>
<h4 class=red>Direct proof</h4>
<p>Since \(\gcd (a,n) = 1\), it is true that \(\mathbb{Z}_{n}^{*} = a\mathbb{Z}_{n}^{*}\) (since multiplying each element by a coprime number and taking modulo n simply permutes the set). Remember that \( \phi (n) = |\mathbb{Z}_{n}^{*}|\) so therefore \( \prod^{\varphi (n)}_{i=1} x_i \equiv \prod^{\varphi (n)}_{i=1} ax_i \equiv a^{\varphi (n)}\prod^{\varphi (n)}_{i=1} x_i \mod n\). Multiplying both sides by \((\prod^{\varphi (n)}_{i=1} x_i)^{-1}\) leaves us with Euler's theorem.</p>
<h4 class=red>Lagrangian proof</h4>
<p>Since \(\gcd (a,n) = 1\), let \(G = \mathbb{Z}_{n}^{*}\), and let \(H\) be a subgroup of \(G\). Any \(a \in G\) can be utilized to form \(H\) and since \( \varphi (n) = |G| \) and \( \exists k \in \mathbb{Z} : k = \frac{|G|}{|H|}\), then \(k|H| = \varphi (n) \). Now, \(a^{\varphi (n)} \equiv a^{k |H|} \equiv a^{|H|} \equiv 1 \mod n\).</p>


<h3 class=red>Fermat's little theorem</h3>
<p>Weaker variant and corrolary of Euler's theorem</p>
<p>\(p \text{ is prime } \implies a^{p-1} \equiv 1  \mod p\)</p>
<h4 class=red>Combinatorial proof</h4>
<p>Consider all the possible strings with length \(p\) and combination with a set of \(a\) symbols (there are \(a^p\) of these)</p>
<p>Now consider all the unique \(a\)-ary necklaces of length \(p\), each necklace can be rotated \(p\) times to obtain unique strings with the exception of necklaces with one symbol (\(a\) of such necklaces exist).</p>
<p>\(a\) of these strings have one single orientation, therefore there are \(a^p-a\) combinations belonging to a necklace with \(p\) orientations. If there were \(k\) such necklaces and \(p\) orientations for each, then \(a^p -a = kp \implies a^p -a | p \implies a^{p-1} \equiv 1 \mod p\)</p>
<h4 class=red>Euler's theorem corrolary proof</h4>
<p>\(a^{\varphi(p)} \equiv 1 \mod p \implies a^{p-1} \equiv 1  \mod p\)</p>
<h4 class=red>Inductive proof</h4>
<p>Note the follwing lemma:</p>
<ul><li>\((x+y)^{p} \equiv x^p + y^p \mod p\)</li></ul>
<p>\(1^p \equiv 1 \mod p\) (Base case, trivial)</p>
<p>\(k^p \equiv k \mod p\) (General assumption)</p>
<p>\((k+1)^p \equiv k^p + 1 \equiv k+1 \mod p\) (inductive proof, application of freshman's dream)</p>
<h4 class=red>Lagrange's theorem proof</h4>
<p>Consider the group \( ( \mathbb{Z}\setminus p \mathbb{Z} )^{\times} \) which has order \(p-1\).</p>
<p>Now consider its cyclic subgroup \( H \cong \mathbb{Z} \setminus k \mathbb{Z}\) generated by \( a \), hence\(a^k \equiv 1 \mod n\)</p>
<p>By Lagrange's theorem, \( k|p-1 \) Hence \( a^{p-1} \equiv a^{km} \equiv (a^{k})^{m} =1^{m} \equiv 1 \mod p\)</p>

<h3 class=red>Multiplicative order</h3>
<p>The smallest \( x : a^x \equiv 1 \mod n\)  is called the order of a mod n, or \( \text{ord}_n (a) \)</p>


<h3 class=red>Symmetric encryption</h3>
<p>Encryption scheme using a single key to handleencryption and decryption</p>

<h3 class=red>Asymmetric encryption</h3>
<p>Encryption scheme using separate keys for handling encryption (public key) and decryption (private key)</p>

<h3 class=red>Rivest-Shamir-Adleman (RSA)</h3>
<p>Asymmetric encryption scheme based on Euler's theorem to exploit the high time complexity of prime factorization.</p>
<p>\( m^{ed} \equiv m \mod n \) where:</p>
<ul>
	<li>\(e\) is the public key</li>
	<li>\(n\) is the public modulus</li>
	<li>\(d\) is the private key</li>
</ul>
<h4 class=red>Key generation</h4>
<ol>
	<li>Choose two sufficiently large primes \(p\) and \(q\), and let \(n=pq\)</li>
	<li>Calculate \(\varphi(n)\)</li>
	<li>Choose \(e : \gcd (e,\lambda(n))=1, 2  &lt; e &lt; \varphi(n)\) (note that \(e\) can't be 2 in practice since \( p,q \neq 2 \implies \varphi(n) \equiv 0 \mod 2 \))</li>
	<li>Calculate \(d : ed \equiv 1 \mod \varphi(n)\), since \(\gcd (a,n)=1 \implies \forall k \in \mathbb{Z}, a^{k\varphi(n)+1} \equiv a \mod n\) and we want to make \(ed = k \varphi (n) + 1\) </li>
</ol>


<h3 class=red>Chinese Remainder Theorem (CRT)</h3>
<p>Theorem that any system of modular equations with coprime moduli has a unique answer modulo \(N\) (the theorem doesn't include how to calculate this answer)</p>
<p>\( \exists! x \in \mathbb{Z}_N :  \begin{cases} x \equiv a_1 \mod n_1 \\ x \equiv a_2 \mod n_2 \\ \vdots \\ x \equiv a_k \mod n_k \end{cases}   \)</p>
<ul>
	<li>\( N = \prod^{k}_{i=1} n_i\)</li>
	<li>\( i \neq j \iff \gcd (n_i , n_j) = 1\)</li>
</ul>

<h4 class=red>Proof</h4>
<p>Assume distinct \(x,y\) satisfy the modular system, then \(n_i | x-y\). Since each modulo is coprime to one another, \(N | x-y\). This implies \(x-y \equiv 0 \mod N \implies x \equiv y \mod N\), so \(y\) is merely a translation by \(N\) of the unique answer \(y\). Therefore the answer is unique (injective) modulo \(N\)</p>
<p>Since the amount of combinations of different sets of \(\{a_1,a_2,...,a_k\}\) is \(N\) (the same as the possible values of \(x\)), the injectivity implies bijectivity (\(N\) possible values of \(x\), which are unique for any \(N\) choice of \(\{a_1,a_2,...,a_k\}\))</p>

<h4 class=red>Calculation</h4>
<p>\(x = \sum^{k}_{i=1} a_i A_i\)</p>
<ul>
	<li>\(A_i = \mu_{i} \frac{N}{n_i} \)</li>
	<li>\( \mu_{i} =(\frac{N}{n_i})^{-1} \mod n_i\)</li>
</ul>









<h2 class=orange>Graph theory</h2>




<h3 class=orange>Vertex Vertice 頂点</h3>
<p>Element that may have relations to other vertexes through <b>edges</b></p>
<p> Visually, vertexes are represented as dots</p>
<p>\(v\)</p>
<ul>
	<li>\(v\) is a vertex</li>
</ul>

<h3 class=orange>Edge Arco 辺</h3>
<p>Subset of 2 vertexes denoting a symmetric relation between two vertexes</p>
<p>Visually, edges are represented as lines between the vertexes</p>
<p>\(e=\{ v_i, v_j \}\)</p>
<ul>
	<li>\(e\) is an edge</li>
	<li>\(v_i,v_j\) are vertexes</li>
</ul>
<h4 class=orange>Directed edge Arco direttato</h4>
<p>Ordered pair \(e= ( v_i, v_j ) \) of 2 vertexes denoting an ordered relation between \(v_i\) (<b>source</b>) to \(v_j\) (<b>terminal</b>) </p>
<p> Visually, edges are represented as arrows pointing from the source to terminal</p>
<p>\(e= ( v_i, v_j ) \)</p>
<ul>
	<li>\(e\) is an edge</li>
	<li>\(v_i\) is the <b>source vertex</b></li>
	<li>\(v_j\) is the <b>terminal vertex</b></li>
</ul>
<h4 class=orange>Loop Cappio 循環</h4>
<p>Edge \(\{v_i, v_i\}\) such that the source vertex is also the terminal</p>

<h3 class=orange>Graph Grafo グラフ</h3>
<p>A graph \(G\) is an ordered pair \( (V,E) \) where:</p>
<ul>
	<li>\(V\) is the set of vertexes</li>
	<li>\(E\) is the set of edges on \(V\)</li>
</ul>
<p>Graphs are formally defined through set theory, but can be visualised with circles for vertexes and lines connecting vertexes as edges. A matrix can also represent a graph and its edges.</p>

<h4 class=orange>Directed graph</h4>
<p>Graph that employs directed edges</p>
<h4 class=orange>Multigraph Multigrafo 多重グラフ</h4>
<p>Graph that may contain the same edge multiple times </p>
<h4 class=orange>Simple graph Graffico semplice 単純グラフ</h4>
<p>Graph  that is not a multigraph and has no loops</p>




<h3 class=orange>Walk Passeggiata 歩道</h3>
<p>Sequence of edges such that the terminal of the current edge is the source of the subsequent edge</p>
<h4 class=orange>Trail Sentiero 小道</h4>
<p>Walk such that no edge is repeated</p>
<h4 class=orange>Path Sentiero chiuso 道</h4>
<p>Trail such that no vertex is repeated</p>
<h4 class=orange>Length of path Lunghezza della via 道の長さ</h4>
<p>Amount of edges in path</p>

<h3 class=orange>Circuit Circuito 回路</h3>
<p>Graph where e is associared as {x,v<sub>1</sub>} then {v<sub>1</sub>,v<sub>2</sub>} until {v<sub>n</sub>,x} </p>
<h3 class=orange>Connected Connesso 接続</h3>
<p>\(G \text{ is connected } \iff \)</p>

<h3 class=orange>Simple path</h3>
<p>Path where v<sub>n</sub> is never connected back to again once connected to</p>

<h3 class=orange>Endpoint</h3>
<p>Vertex of an edge</p>

<h3 class=orange>Incident</h3>
<p>\( e \text{ is incident to } v \iff \exists v \in e\)</p>

<h3 class=orange>Adjacency</h3>
<p>In a directed graph, \(v_1\) and \(v_2\) are adjacent iff there exists some edge relating them, so </p>
<p>\( v_1 \text{ and } v_2 \text{ are adjacent} \iff \exists e \in E : e = \{v_1 ,  v_2\} \)</p>

<h3 class=orange>In-adjacency</h3>
<p>\( v_1 \text{ is in-adjacent to } v_2 \iff \exists e \in E : e = (v_1 ,  v_2) \)</p>


<h3 class=orange>In-adjacency</h3>
<p>\( v_1 \text{ is out-adjacent to } v_2 \iff \exists e \in E : e = (v_2 ,  v_1) \)</p>

<h3 class=orange>Degree of a vertex</h3>
<p>A degree of a vertex is the amount of edges that it interacts with (an edge usually adds 1 for the edges exit, but on a loop it adds 2, since you cound for the exit and entry)</p>
<p>\( \deg (v) = \sum_{e\in E} p(e) \)</p>
<p>\(v \neq u,w\)</p>
<p>\(p(e_{vv}) = 2\)</p>
<p>\(p(e_{vw}) = 1\)</p>
<p>\(p(e_{uw}) = 0\)</p>


<h3 class=orange>Adjacency matrix Matrice delle adiacenze 隣接行列</h3>
<p>A matrix \(A\) with dimensions \(|V| \times |V|\) such that:</p>
<p>\( A_{ij} = \begin{cases} 0 & \{i,j\} \notin E \\ 1 & \{i,j\} \in E \end{cases}\)</p>
<p>Undirected graphs have symmetric matrixes</p>
<h4 class=orange>Directed</h4>
<p>\( A_{ij} = \begin{cases} 0 & (i,j) \notin E \\ 1 & (i,j) \in E \end{cases}\)</p>

<h3 class=orange>Complete Completato 完了</h3>
<p>Simple graphs where every node is connected to every other node</p>

<h3 class=orange>Bipartite</h3>
<p>Graph with \(m+n\) vertexes where no m vertex connects to another m vertex and no n vertex connects to another n vertex</p>

<h3 class=orange>Subpath</h3>
<p>A path within a path (can be an empty path)</p>

- Euler path (each edge traversed exactly once)
- Hamiltonian path (each vertex reached exactly once)


<h3 class=orange>Tree Albero 木</h3>
<p>Connected graph with no circuits, such as binary tree structures</p>
<p>\(G \text{ is a tree } \iff |E|=|V|-1 \land G \text{ is connected}\)</p>

<h3 class=orange>Leaf Foglia 葉</h3>
<p>Node of degree 1 on a tree</p>


<h3 class=orange>Forest Selva 森林</h3>
<p>Collection of trees</p>


\begin{lemma}[Kőnig's lemma]
Let $G$ be a connected locally finite infinite graph, then $G$ contains an infinite simple path (ray)
\end{lemma}


- Euler circuit (each edge traversed exactly once)
- Hamiltonian circuit (each vertex except for first vertex reached exactly once)
<h3 class=orange>Spanning Tree Albero ricoprente 全域木</h3>
<p>Tree over another graph that connects to all vertexes using the pre-existing edges</p>


<h3 class=orange>Rooted tree</h3>
<p>Tree with a special node called a root</p>

<h3 class=orange>Root Radice 根底</h3>
<p>If two vertexes \(v,u\) share an edge, and a path from v to r (r for root) passes u, then r is a root. v is then called a parent and u a child </p>

<h3 class=orange>Depth Profondità 深遠</h3>
<p>Distance of some vertex \(v\) from the root node</p>

<h3 class=orange>Bracket free expressions</h3>
<p>Mathematical expressions can be written without brackets by being represented in a rooted tree, where nodes are operators and numbers. Then it can be rewritten as an expression in various methods...</p>

<h3 class=orange>Preorder</h3>
<p>Parent, left, right</p>

<h3 class=orange>Postorder</h3>
<p>Left, right, parent</p>

<h3 class=orange>Inorder</h3>
<p>Left, parent, right</p>

<h3 class=orange>Planar Planare 平面</h3>
<p>Graph that has no edge cross another edge</p>

<h3 class=orange>Face Faccia 面</h3>
<p>Region bound by edges</p>


<!--<h3 class=orange>Propositions</h3>
<p>\(G \text{ is a connected graph with no edge intersections}\)</p>
<p>\( |E|=1 \implies |V| \leq 2\) If we have one egde, we have either one or two vertexes (1 in the case of a loop. 2 in the case of no loop)</p>
<p>\( e \to e+1 \land  v \to v \iff f \to f+1 \) When we add an edge and the amount of vertexes isn;t changed, we've added a face.</p>
<p>\( e \to e+1 \land  f \to f \iff v \to v+1 \) When we add an edge and the amount of faces isn't changed, we've added a vertex.</p>
<p>\( f=x \implies e=v-2+x \) If we have \(x\) faces, we have \(v-2+x\) edges. Why? Let's start with the minumum faces; 1. This means we have a tree, and due to our 3rd conjecture, every edge we're adding that doesn't make a face adds a vertex, and if we use this in conjunction with the first conjecture (the no loop version, since trees can't have loops), we deduce there are \(v-1=v-2+1\). Now let's say we make a new face, due to that 2nd conjecture we are adding an edge but no vertex, so that means for each face we gain, we're just adding an edge (induction for more formal proof?), so we can generalise it as \( e=v-1+(f-1) \to e=v-2+f \). Wait, I just rediscovered Euler's formula (for connected graphs case)? Hell yeah!</p>-->



