Skip to content

Commit

Permalink
Yesterday + Today's
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Jan 23, 2024
1 parent 9beec39 commit e5a5691
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 43 deletions.
Binary file added AlgebraicTopology.pdf
Binary file not shown.
12 changes: 9 additions & 3 deletions CodingAndCryptography/00_modelling_communication.tex
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ \section{Modelling communication}
This coding system detects the common human errors of writing an incorrect digit and transposing two adjacent digits.
Noisy coding is adapted to the channel, which in this case is the human reading the number and typing it into a computer.

\begin{definition}
\begin{definition}[Communication Channel]
A \vocab{communication channel} accepts a string of symbols from a finite alphabet $\mathcal A = \qty{a_1, \dots, a_r}$ and outputs a string of symbols from another finite alphabet $\mathcal B = \qty{b_1, \dots, b_s}$.
It is modelled by the probabilities $\prob{y_1 \dots y_n \text{ received} \mid x_1 \dots x_n \text{ sent}}$.
\end{definition}
\begin{definition}

\begin{definition}[Discrete Memoryless Channel]
A \vocab{discrete memoryless channel} is a channel where $p_{ij} = \prob{b_j \text{ received} \mid a_i \text{ sent}}$ are the same for each channel use, and independent of all past and future uses of the channel.
Its \vocab{channel matrix} is the $r \times s$ stochastic matrix $P = (p_{ij})$.
\end{definition}

\begin{example}
The \vocab{binary symmetric channel} with error probability $p \in [0,1]$ is a discrete memoryless channel with input and output alphabets $\qty{0, 1}$, where the channel matrix is
\[ \begin{pmatrix}
Expand All @@ -38,6 +40,7 @@ \section{Modelling communication}
Here, a symbol is transmitted correctly with probability $1 - p$.
Usually, we assume $p < \frac{1}{2}$.
\end{example}

\begin{example}
The \vocab{binary erasure channel} has $\mathcal A = \qty{0, 1}$ and $\mathcal B = \qty{0, 1, \star}$.
The channel matrix is
Expand All @@ -48,6 +51,7 @@ \section{Modelling communication}
$p$ can be interpreted as the probability that the symbol received is unreadable.
If $\star$ is received, we say that we have received a \vocab{splurge error}.
\end{example}

\begin{definition}
We model $n$ uses of a channel by the \vocab{$n$th extension}, with input alphabet $\mathcal A^n$ and output alphabet $\mathcal B^n$.
A \vocab{code} $C$ of length $n$ is a function $\mathcal M \to \mathcal A^n$, where $\mathcal M$ is a set of messages.
Expand All @@ -58,9 +62,11 @@ \section{Modelling communication}
\item The \vocab{error rate} of the code is $\hat e(C) = \max_{x \in \mathcal M} \prob{\text{error} \mid x \text{ sent}}$.
\end{itemize}
\end{definition}
\begin{definition}

\begin{definition}[Capacity]
A channel can \vocab{transmit reliably at rate $R$} if there is a sequence of codes $(C_n)_{n=1}^\infty$ with each $C_n$ a code of length $n$ such that $\lim_{n \to \infty} \rho(C_n) = R$ and $\lim_{n \to \infty} \hat e(C_n) = 0$.
The \vocab{capacity} of a channel is the supremum of all reliable transmission rates.
\end{definition}

It is a nontrivial fact that the capacity of the binary symmetric channel with $p < \frac{1}{2}$ is nonzero.
This is one of Shannon's theorems, proven later.
39 changes: 30 additions & 9 deletions CodingAndCryptography/01_noiseless_coding.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@ \subsection{Prefix-free codes}
Let $\mathcal A$ be a finite alphabet.
We write $\mathcal A^\star$ for the set of strings of elements of $\mathcal A$, defined by $\mathcal A^\star = \bigcup_{n \geq 0} A^n$.
The \vocab{concatenation} of two strings $x = x_1 \dots x_r$ and $y = y_1 \dots y_s$ is the string $xy = x_1 \dots x_r y_1 \dots y_s$.
\begin{definition}

\begin{definition}[Code]
Let $\mathcal A, \mathcal B$ be alphabets.
A \vocab{code} is a function $c \colon \mathcal A \to \mathcal B^\star$.
The \vocab{codewords} of $c$ are the elements of $\Im c$.
\end{definition}

\begin{example}[Greek fire code]
Let $\mathcal A = \qty{\alpha, \beta, \dots, \omega}$, and $B = \qty{1, 2, 3, 4, 5}$.
We map $c(\alpha) = 11, c(\beta) = 12, \dots, c(\psi) = 53, c(\omega) = 54$.
$xy$ means to hold up $x$ torches and another $y$ torches nearby.
This code was described by the historian Polybius.
\end{example}

\begin{example}
Let $\mathcal A$ be a set of words in some dictionary.
Let $\mathcal B$ be the letters of English $\qty{A, \dots, Z, \text{\textvisiblespace}}$
The code is to spell the word and follow with a space.
\end{example}

The general idea is to send a message $x_1, \dots, x_n \in \mathcal A^\star$ as $c(x_1) \dots c(x_n) \in \mathcal B^\star$.
So $c$ extends to a function $c^\star \colon \mathcal A^\star \to \mathcal B^\star$.
\begin{definition}

\begin{definition}[Decipherable]
A code $c$ is \vocab{decipherable} (or \vocab{uniquely decodable}) if $c^\star$ is injective.
\end{definition}

If $c$ is decipherable, each string in $\mathcal B^\star$ corresponds to at most one message.
It does not suffice to require that $c$ be injective.
Consider $\mathcal A = \qty{1, 2, 3, 4}, \mathcal B = \qty{0,1}$, and let $c(1) = 0, c(2) = 1, c(3) = 00, c(4) = 01$.
Expand All @@ -44,40 +50,48 @@ \subsection{Prefix-free codes}
One can easily find decipherable codes that are not prefix-free.

\subsection{Kraft's inequality}
\begin{definition}

\begin{definition}[Kraft's Inequality]
Let $\mathcal A$ be an alphabet of size $m$, and $\mathcal B$ be an alphabet of size $a$.
Let $c \colon \mathcal A \to \mathcal B^\star$ be a code with codewords are of length $\ell_1, \dots, \ell_m$.
Then, \vocab{Kraft's inequality} is
\[ \sum_{i=1}^m a^{-\ell_i} \leq 1 \]
\end{definition}

\begin{theorem}
A prefix-free code (with given codeword lengths) exists if and only if Kraft's inequality holds.
A prefix-free code (with given codeword lengths) exists iff Kraft's inequality holds.
\end{theorem}

\begin{proof}
Let us rewrite Kraft's inequality as $\sum_{\ell=1}^s n_\ell a^{-\ell} \leq 1$, where $n_\ell$ is the number of codewords of length $\ell$, and $s$ is the length of the longest codeword.
Suppose $c \colon \mathcal A \to \mathcal B^\star$ is prefix-free.

$(\implies)$: Suppose $c \colon \mathcal A \to \mathcal B^\star$ is prefix-free.
Then,
\[ n_1 a^{s-1} + n_2 a^{s-2} + \dots + n_{s-1} a + n_s \leq a^s \]
since the left hand side counts the number of strings of length $s$ in $\mathcal B$ with some codeword of $c$ as a prefix, and the right hand side counts the total number of strings of length $s$.
Dividing by $a^s$ gives the desired result.

Now, suppose that $\sum_{\ell=1}^s n_\ell a^{-\ell} \leq 1$.
$(\Longleftarrow)$: Now, suppose that $\sum_{\ell=1}^s n_\ell a^{-\ell} \leq 1$.
We aim to construct a prefix-free code $c$ with $n_\ell$ codewords of length $\ell$ for all $\ell \leq s$.
Proceed by induction on $s$.

The case $s = 1$ is clear; in this case, the inequality gives $n_1 \leq a$.

By the inductive hypothesis, we have constructed a prefix-free code $\hat c$ with $n_\ell$ codewords of length $\ell$ for all $\ell < s$.
The inequality gives $n_1 a^{s-1} + \dots + n_{s-1} a + n_s \leq a^s$.
The first $s - 1$ terms on the left hand side gives the number of strings of length $s$ with some codeword of $\hat c$ as a prefix.
So we are free to add $n_s$ additional codewords of length $s$ to $\hat c$ to form $c$ without exhausting our supply of $a^s$ total strings of length $s$.
\end{proof}

\begin{remark}
The proof of existence of such a code is constructive; one can choose codewords in order of increasing length, ensuring that we do not introduce prefixes at each stage.
\end{remark}

\subsection{McMillan's inequality}
\begin{theorem}
\begin{theorem}[McMillan's inequality]
Any decipherable code satisfies Kraft's inequality.
\end{theorem}

\begin{proof}
Let $c \colon \mathcal A \to \mathcal B^\star$ be decipherable with word lengths $\ell_1, \dots, \ell_m$.
Let $s = \max_{i \leq m} \ell_i$.
Expand All @@ -90,32 +104,39 @@ \subsection{McMillan's inequality}
\[ \qty(\sum_{i=1}^m a^{-\ell_i})^R \leq Rs \implies \sum_{i=1}^m a^{-\ell_i} \leq \qty(Rs)^{\frac{1}{R}} \]
As $R \to \infty$, the right hand side converges to 1, giving Kraft's inequality as required.
\end{proof}

\begin{corollary}
A decipherable code with prescribed word lengths exists if and only if a prefix-free code with the same word lengths exists.
A decipherable code with prescribed word lengths exists iff a prefix-free code with the same word lengths exists.
\end{corollary}
We can therefore restrict our attention to prefix-free codes.

\subsection{Entropy}
\vocab{Entropy} is a measure of `randomness' or `uncertainty' in an input message.
Suppose that we have a random variable $X$ taking a finite number of values $x_1, \dots, x_n$ with probability $p_1, \dots, p_n$.
Then, the entropy of this random variable is the expected number of fair coin tosses required to determine $X$.

\begin{example}
Suppose $p_1 = p_2 = p_3 = p_4 = \frac{1}{4}$.
Identifying $\qty{x_1, x_2, x_3, x_4} = \qty{00, 01, 10, 11}$, we would expect $H(X) = 2$.
\end{example}

\begin{example}
Suppose $p_1 = \frac{1}{2}$, $p_2 = \frac{1}{4}$, and $p_3 = p_4 = \frac{1}{8}$.
Identifying $\qty{x_1, x_2, x_3, x_4} = \qty{0, 10, 110, 111}$, we obtain $H(X) = \frac{1}{2} \cdot 1 + \frac{1}{4} \cdot 2 + \frac{1}{8} \cdot 3 + \frac{1}{8} \cdot 3 = \frac{7}{4}$.
\end{example}

In a sense, the first example is `more random' than the second, as its entropy is higher.
\begin{definition}

\begin{definition}[Entropy]
The \vocab{entropy} of a random variable $X$ taking a finite number of values $x_1, \dots, x_n$ with probabilities $p_1, \dots, p_n$ is defined to be
\[ H(X) = H(p_1, \dots, p_n) = -\sum_{i=1}^n p_i \log p_i = -\expect{\log p_i} \]
where the logarithm is taken with base 2.
\end{definition}

Note that $H(X) \geq 0$, and equality holds exactly when $X$ is constant with probability 1.
It is measured in \vocab{bits}, binary digits.
By convention, we write $0 \log 0 = 0$ (note that $x \log x \to 0$ as $x \to 0$).

\begin{example}
For a biased coin with probability $p$ of a head, we write $H(p,1-p) = H(p)$.
We find
Expand Down
Binary file modified CodingAndCryptography/cc.pdf
Binary file not shown.
80 changes: 51 additions & 29 deletions LogicAndSetTheory/01_propositional_logic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ \subsection{Semantic implication}
\end{example}

\begin{definition}[Tautology]
A \vocab{tautology} is $t \in L$ s.t. $v(t) = 1 \forall$ valuations $v$.
A \vocab{tautology} is $t \in L$ s.t. $v(t) = 1 \; \forall$ valuations $v$.
We write $\models t$.
\end{definition}

Expand Down Expand Up @@ -283,16 +283,17 @@ \subsection{Soundness}
\begin{proof}
We have a proof $t_1, \dots, t_n$ of $t$ from $S$.
We aim to show that any model of $S$ is also a model of $t$, so if $v$ is a valuation that maps every element of $S$ to 1, then $v(t) = 1$.

We show this by induction on the length of the proof.
$v(p) = 1$ for each axiom $p$ and for each $p \in S$.
$v(p) = 1$ for each axiom $p$ (as axioms are tautologies) and for each $p \in S$.
Further, $v(t_i) = 1, v(t_i \implies t_j) = 1$, then $v(t_j) = 1$.
Therefore, $v(t_i) = 1$ for all $i$.
\end{proof}

\subsection{Adequacy}
Consider the case of adequacy where $t = \bot$.
If our axioms are adequate, $S \models \bot$ implies $S \vdash \bot$, so $S \not\vdash \bot$.
We say $S$ is \vocab{consistent} if $S \not\vdash \bot$.
If our axioms are adequate, $S \models \bot$ implies $S \vdash \bot$.
We say $S$ is \vocab{consistent} if $S \not\vdash \bot$ and \vocab{inconsistent} if $S \vdash \bot$.
Therefore, in an adequate system, if $S$ has no models then $S$ is inconsistent; equivalently, if $S$ is consistent then it has a model.

In fact, the statement that consistent axiom sets have a model implies adequacy in general.
Expand All @@ -314,9 +315,17 @@ \subsection{Adequacy}
If $S$ is consistent, then the deductive closure is also consistent.
Computing the deductive closure before the valuation solves the problem for $S = \qty{p_1, p_1 \implies p_2}$.
However, if a primitive proposition $p$ is not in $S$, but $\neg p$ is also not in $S$, this technique still does not work, as it would assign false to both $p$ and $\neg p$.
\begin{theorem}[model existence lemma]

\begin{theorem}[Model Existence Lemma] \label{thm:mod}
Every consistent set $S \subseteq L$ has a model.
\end{theorem}

\begin{remark}
We use the fact that $P$ is a countable set in order to show that $L$ is countable.
The result does in fact hold if $P$ is uncountable, but requires Zorn's Lemma and will be proved in Chapter 3.
Some sources call this theorem the `completeness theorem'.
\end{remark}

\begin{proof}
First, we claim that for any consistent $S \subseteq L$ and proposition $p \in L$, either $S \cup \qty{p}$ is consistent or $S \cup \qty{\neg p}$ is consistent.
If this were not the case, then $S \cup \qty{p} \vdash \bot$, and also $S \cup \qty{\neg p} \vdash \bot$.
Expand All @@ -325,17 +334,18 @@ \subsection{Adequacy}

Now, $L$ is a countable set as each $L_n$ is countable, so we can enumerate $L$ as $t_1, t_2, \dots$.
Let $S_0 = S$, and define $S_1 = S_0 \cup \qty{t_1}$ or $S_1 = S_0 \cup \qty{\neg t_1}$, chosen s.t. $S_1$ is consistent.
Continuing inductively, define $\overline S = \bigcup_{i \in \mathbb N} S_i$.
Then, for all $t \in L$, either $t \in \overline S$ or $\neg t \in \overline S$.
Note that $\overline S$ is consistent; indeed, if $\overline S \vdash \bot$, then this proof uses hypotheses only in $S_n$ for some $n$, but then $S_n \vdash \bot$ contradicting consistency of $S_n$.
Note also that $\overline S$ is deductively closed, so if $\overline S \vdash p$, we must have $p \in \overline S$; otherwise, $\neg p \in \overline S$ so $\overline S \vdash \neg p$, giving $\overline S \vdash \bot$, contradicting consistency of $\overline S$.
Continuing inductively, define $\overline S = \bigcup_{i} S_i$. \\
Then, $\forall \; t \in L$, either $t \in \overline S$ or $\neg t \in \overline S$. \\
Note that $\overline S$ is consistent since proofs are finite; indeed, if $\overline S \vdash \bot$, then this proof uses hypotheses only in $S_n$ for some $n$, but then $S_n \vdash \bot$ contradicting consistency of $S_n$. \\
Note also that $\overline S$ is deductively closed, so if $\overline S \vdash p$, we must have $p \in \overline S$; otherwise, $\neg p \in \overline S$ so $\overline S \vdash \neg p$, giving $\overline S \vdash \bot$ by MP, contradicting consistency of $\overline S$.

Now, define the function
\begin{align*}
v(t) = \begin{cases}
1 & t \in \overline S \\
0 & t \not\in \overline S
\end{cases}
\end{align*}
v(t) = \begin{cases}
1 & t \in \overline S \\
0 & t \not\in \overline S
\end{cases}
\end{align*}
We show that $v$ is a valuation, then the proof is complete as $v(s) = 1$ for all $s \in S$.
Since $\overline S$ is consistent, $\bot \not\in \overline S$, so $v(\bot) = 0$.

Expand All @@ -348,54 +358,66 @@ \subsection{Adequacy}
Therefore, as $\overline S$ is deductively closed, $(p \implies q) \in \overline S$.

Finally, suppose $v(p) = 0$, so $p \not\in \overline S$, and we want to show $(p \implies q) \in \overline S$.
We know that $\neg p \in \overline S$, so it suffices to show that $p \implies \bot \vdash p \implies q$.
We know that $\neg p \in \overline S$, so it suffices to show that $(p \implies \bot) \vdash (p \implies q)$.
By the deduction theorem, this is equivalent to proving $\qty{p, p \implies \bot} \vdash q$, or equivalently, $\bot \vdash q$.
But by axiom 1, $\bot \implies (\neg q \implies \bot)$ where $(\neg q \implies \bot) = \neg\neg q$, so the proof is complete by axiom 3.
\end{proof}
\begin{remark}
We used the fact that $P$ was a countable set in order to show that $L$ was countable.
The result does in fact hold if $P$ is uncountable, but requires more tools to prove.
Some sources call this theorem the `completeness theorem'.
\end{remark}
\begin{corollary}[adequacy]

\begin{corollary}[Adequacy]
Let $S \subseteq L$ and let $t \in L$, s.t. $S \models t$.
Then $S \vdash t$.
\end{corollary}

\begin{proof}
Follows from the remarks before the model existence lemma.
$S \cup \qty{\neg t} \models \bot$, so \nameref{thm:mod}, $S \cup \qty{\neg t} \vdash \bot$.
Then by \nameref{thm:ded} $S \vdash \neg \neg t$.
$\neg \neg t \implies t$ by Axiom 3 and so by MP $S \vdash t$.
\end{proof}

\subsection{Completeness}
\begin{theorem}[completeness theorem for propositional logic]
\begin{theorem}[Completeness Theorem for Propositional Logic]
Let $S \subseteq L$ and $t \in L$.
Then $S \models t$ if and only if $S \vdash t$.
Then $S \models t$ iff $S \vdash t$.
\end{theorem}

\begin{proof}
Follows from soundness and adequacy.
\end{proof}
\begin{theorem}[compactness theorem]

\begin{theorem}[Compactness Theorem]
Let $S \subseteq L$ and $t \in L$ with $S \models t$.
Then there exists a finite subset $S' \subseteq S$ s.t. $S' \models t$.
\end{theorem}

\begin{proof}
Trivial after applying the completeness theorem, since proofs depend on only finitely many hypotheses in $S$.
\end{proof}
\begin{corollary}[compactness theorem, equivalent form]

\begin{corollary}[Compactness Theorem, Equivalent Form]
Let $S \subseteq L$.
Then if every finite subset $S' \subseteq S$ has a model, then $S$ has a model.
\end{corollary}

\begin{proof}
Let $t = \bot$ in the compactness theorem.
Then, if $S \models \bot$, some finite $S' \subseteq S$ has $S' \models \bot$.
But this is not true by assumption, so there is a model for $S$.
\end{proof}

\begin{remark}
This corollary is equivalent to the more general compactness theorem, since the assertion that $S \models t$ is equivalent to the statement that $S \cup \qty{\neg t}$ has no model, and $S' \models t$ is equivalent to the statement that $S' \cup \qty{\neg t}$ has no model.
\end{remark}
\begin{theorem}[decidability theorem]
Let $S \subseteq L$ and $t \in L$.

\begin{note}
The use of the word compactness is more than a fanciful analogy.
See Sheet 1.
\end{note}

\begin{theorem}[Decidability Theorem]
Let $S \subseteq L$, $S$ finite and $t \in L$.
Then, there is an algorithm to decide (in finite time) if $S \vdash t$.
\end{theorem}

\begin{proof}
Trivial after replacing $\vdash$ with $\models$, by drawing the relevant truth tables.
Trivial after replacing $\vdash$ with $\models$, and checking all valuations by drawing the relevant truth tables.
\end{proof}
Binary file modified LogicAndSetTheory/logicandsettheory.pdf
Binary file not shown.
Binary file modified ProbAndMeasure/probmeasure.pdf
Binary file not shown.
Binary file modified QuantumInfoAndComputing/qic.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions QuantumInfoAndComputing/qic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

\input{../preamble-dynamic.tex}
\usepackage{qcircuit}
\RequirePackage{unicode-math}
% \RequirePackage{unicode-math}

\author{Based on lectures by \nlecturer \ and notes by thirdsgames.co.uk}

Expand All @@ -19,5 +19,5 @@
\input{01_mathematical_background.tex}
\input{02_quantum_states_as_information_carriers.tex}
\input{03_quantum_cryptography.tex}
\input{04_quantum_computation.tex}
% \input{04_quantum_computation.tex}
\end{document}

0 comments on commit e5a5691

Please sign in to comment.