\documentclass[11pt]{article}
\usepackage{euler}
\usepackage{xltxtra}
\usepackage{amsmath}
%\usepackage{amssymb}
\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage{listings}
%\setmainfont[Mapping=tex-text]{Ubuntu}
%{FreeSerif}
%{DejaVu Serif}

\date{26th of June 2012}
\author{Lukas Prokop}
\title{Software paradigms exam 27.6.2011}

% Definitions by Daniel Gruß
% https://github.com/lava2/swp/blob/master/commands.tex
% various operators
\DeclareMathOperator {\id}{id}
\DeclareMathOperator*{\ggt}{ggT}
\DeclareMathOperator*{\kgv}{kgV}
\DeclareMathOperator {\ord}{ord}
\DeclareMathOperator {\fmod}{mod}
\DeclareMathOperator*{\trace}{tr}
\DeclareMathOperator {\nil}{nil}
\DeclareMathOperator*{\supp}{Supp}
\DeclareMathOperator {\lm}{lm}
\DeclareMathOperator {\lt}{lt}
\DeclareMathOperator {\lc}{lc}
\DeclareMathOperator*{\rest}{rest}
\DeclareMathOperator*{\tmult}{\:{mult}\:}
\DeclareMathOperator*{\tplus}{\:{plus}\:}
\DeclareMathOperator*{\tminus}{\:{minus}\:}
\DeclareMathOperator*{\tnull}{\:{null}\:}
\DeclareMathOperator*{\teins}{\:{eins}\:}
\DeclareMathOperator*{\tif}{\:{if}\:}
\DeclareMathOperator*{\telse}{\:{else}\:}
\DeclareMathOperator*{\tthen}{\:{then}\:}
\DeclareMathOperator*{\tlt}{\:{lt?}\:}
\DeclareMathOperator*{\teq}{\:{eq?}\:}
\DeclareMathOperator*{\tumult}{\:\u{mult}\:}
\DeclareMathOperator*{\tuplus}{\:\u{plus}\:}
\DeclareMathOperator*{\tuminus}{\:\u{minus}\:}
\DeclareMathOperator*{\tunull}{\:\u{null}\:}
\DeclareMathOperator*{\tueins}{\:\u{eins}\:}
\DeclareMathOperator*{\tuif}{\:\u{if}\:}
\DeclareMathOperator*{\tuelse}{\:\u{else}\:}
\DeclareMathOperator*{\tuthen}{\:\u{then}\:}
\DeclareMathOperator*{\tult}{\:\u{lt?}\:}
\DeclareMathOperator*{\tueq}{\:\u{eq?}\:}
\DeclareMathOperator {\End}{end}
\DeclareMathOperator*{\rang}{rang}
\DeclareMathOperator*{\dist}{d}
\DeclareMathOperator*{\real}{Re}
\DeclareMathOperator*{\imag}{Im}
\DeclareMathOperator*{\sign}{sign}
\DeclareMathOperator*{\weight}{weight}

% graphics and sectioning
\newcommand{\skizze}[1]{$ $ \begin{center}\includegraphics[scale = 0.33]{images/#1.png}\end{center}}
\newcommand{\mychapter}[1]{\chapter{#1}}
\newcommand{\mysection}[1]{\section{#1}}
\newcommand{\mysubsection}[1]{\subsection{#1}}
\newcommand{\separate}{\begin{center}*\:*\:*\end{center}}

% definition and proof tools
\newcommand{\proofdone}{\hfill \ensuremath{\Box}}
\newcommand{\mathdone}{\tag*{\ensuremath{\Box}}}

\newcommand{\defas}{\mathrel{\mathop:}=}
\newcommand{\asdef}{=\mathrel{\mathop:}}

\newcommand{\there}{``$\Rightarrow$'' \;}
\newcommand{\back}{``$\Leftarrow$'' \;}

\newcommand{\then}{\: \Rightarrow \:}
\newcommand{\ifonlyif}{\: \Leftrightarrow \:}
\renewcommand{\u}[1]{\underline{#1}}
\newcommand{\tu}[1]{\text{\underline{#1}}}

\newcommand{\tobe}{\overset{!}{=}}
\newcommand{\isit}{\overset{?}{=}}

% referencing
\newcommand{\tagstar}{\tag*{$\star$}}
\newcommand{\refstar}{\ensuremath{(\star)}}
\newcommand{\alrefstar}{\tag*{(\star)}}
\newcommand{\tagstarn}[1]{\tag*{$\star_{#1}$}}
\newcommand{\refstarn}[1]{\ensuremath{(\star_{#1})}}
\newcommand{\alrefstarn}[1]{\tag*{(\star_{#1})}}

% mathtext
\newcommand{\sonst}{\text{sonst}}
\newcommand{\const}{\mathrm{const}}

% braces
\newcommand{\abs}[1]{\left\lvert{#1}\right\rvert}
\newcommand{\norm}[1]{\left\lVert{#1}\right\rVert}
\newcommand{\angled}[1]{\left\langle{#1}\right\rangle}
\newcommand{\tangled}[1]{\langle{#1}\rangle}
\newcommand{\braced}[1]{\left( {#1} \right)}
\newcommand{\sbraced}[1]{\left\{#1\right\}}
\newcommand{\bbraced}[1]{\left[#1\right]}

\newcommand{\bbinom}[2]{\genfrac[]{0pt}{0}{#1}{#2}}
\newcommand{\cbinom}[2]{\genfrac{\{}{\}}{0pt}{0}{#1}{#2}}
\newcommand{\ebinom}[2]{\genfrac{}{}{0pt}{0}{#1}{#2}}

\newcommand{\gausslo}[1]{\left\lfloor {#1} \right\rfloor}
\newcommand{\gausshi}[1]{\left\lceil {#1} \right\rceil}
\newcommand{\gaussround}[1]{\left\lfloor {#1} \right\rceil}

% under/overlining
\newcommand{\ov}[1]{\overline{#1}}
\newcommand{\un}[1]{\underline{#1}}
\newcommand{\vek}[1]{\vec{#1}}

% relations
\newcommand{\sm}{\setminus}
\newcommand{\se}{\subseteq}
\newcommand{\nse}{\nsubseteq}
\newcommand{\sne}{\nsubseteq}
\newcommand{\ise}{\supseteq}
\newcommand{\nise}{\nsupseteq}
\newcommand{\sneq}{\subsetneqq}
\newcommand{\isneq}{\supsetneqq}

\newcommand{\subideal}{\trianglelefteq}
\newcommand{\isubideal}{\trianglerighteq}

\newcommand{\divs}{\mathrel\vert}
\newcommand{\ndivs}{\nmid}
\newcommand{\iso}{\simeq}

\newcommand{\nequiv}{\not\equiv}

% sets
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\F}{\mathbb{F}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\primes}{\mathbb{P}}
\newcommand{\potenz}{\mathcal{P}}

\newcommand{\dotcup}{\ensuremath{\mathaccent\cdot\cup}}

\newcommand{\prob}{\mathbb{P}}
\newcommand{\erw}{\mathbb{E}}
\newcommand{\variance}{\mathbb{V}}

% greek symbols
\newcommand{\fee}{\varphi}
\newcommand{\eps}{\varepsilon}

% various tools
\newcommand{\where}{\mathrel\big\vert}
\newcommand{\limited}{\big\vert}

% complexity theory
\newcommand{\ordn}{\mathcal{O}}
\newcommand{\oh}{\mathcal{O}}

% analysis
\newcommand{\de}{\, \dd}
\newcommand{\dd}{\mathrm{d}}

\renewcommand{\thesubsection}{\arabic{subsection}}
\newcommand{\rbr}[1]{\left(#1\right)}
\newcommand{\ebr}[1]{\left[#1\right]}
\newcommand{\sbr}[1]{\left<#1\right>}
\newcommand{\gbr}[1]{\left\{#1\right\}}
\renewcommand{\det}[1]{\text{det}\left(#1\right)}
\renewcommand{\u}[1]{\underline{#1}}
\renewcommand{\o}[1]{\overline{#1}}
\renewcommand{\b}[1]{\textbf{#1}}

\newcommand{\E}{\mathbb{E}}
\renewcommand{\P}{\mathbb{P}}
%\newcommand{\I}{\mathbb{I}}
\newcommand{\V}{\mathbb{V}}
\newcommand{\dx}{\text{d}x}
\newcommand{\D}{\mathbb{D}}
\newcommand{\kA}{\mathcal{A}}
\newcommand{\kC}{\mathcal{C}}
\newcommand{\kP}{\mathcal{P}}

\newcommand{\Lra}{\:\Leftrightarrow\:}
\newcommand{\lra}{\:\leftrightarrow\:}
\newcommand{\Ra}{\:\Rightarrow\:}
\newcommand{\ra}{\:\rightarrow\:}
\newcommand{\La}{\:\Leftarrow\:}
\newcommand{\la}{\:\leftarrow\:}

\newcommand{\limi}[1]{\lim_{#1 \rightarrow \infty}}
\newcommand{\mceil}[1]{\left\lceil #1 \right\rceil}
\newcommand{\mfloor}[1]{\left\lfloor #1 \right\rfloor}

\DeclareMathOperator{\ggT}{ggT}
\DeclareMathOperator{\kgV}{kgV}

\DeclareMathOperator{\RR}{R}
\DeclareMathOperator{\notdivides}{\nmid}

\newcommand{\lng}[1]{\mathcal{#1}}
\newcommand{\kwu}[1]{\text{\:\u{#1}\:}}
\newcommand{\kw}[1]{\text{\:{#1}\:}}
\newcommand{\I}[3]{I_{\lng{#1}}\left(#2,\tu{#3}\right)}
\newcommand{\Iu}[3]{I_{\lng{#1}}\left(#2,#3\right)}

\newcommand{\twedge}{\text{$\wedge$}}
\newcommand{\tforall}{\text{$\forall$}}
\newcommand{\texists}{\text{$\exists$}}
\newcommand{\tvee}{\text{$\vee$}}
\newcommand{\tto}{\text{$\to$}}
\newcommand{\tneg}{\text{$\neg$}}
% End Definitions

\DeclareMathOperator*{\s}{s}
\DeclareMathOperator*{\binStack}{binStack}
\DeclareMathOperator*{\add}{add}
\DeclareMathOperator*{\len}{len}
\newcommand{\Null}{\text{null}}
\newcommand{\set}[1]{\left\{#1\right\}}

\lstdefinelanguage{EXP}%
  {keywords={if,then,else},%
%   emph={plus,minus,mult,add0,add1,sub,build,rest,first,second,reverse,depth,max,nth,lt?,eq?,is0?,is1?,isEmpty?,atom?},
   moreemph={null,eins,0,1,[]},% epsilon is missing
   emphstyle=\emph,
   mathescape={true}%
  }%
\newcommand{\NE}{\text{NE:}\hspace{5pt}}
\newcommand{\NR}{\text{NR:}\hspace{5pt}}

\begin{document}
\maketitle
\tableofcontents
\newpage
%
\section{Exercise 1}
%
%\begin{table}
  \begin{tabular}{lcccc}
           &    S     &    A    &   B   &   C \\ \hline
    \textsc{FIRST}  & $\set{\u{a}}$ & $\set{\u{a}}$ & $\set{\u{b}, \u{c}, \u{a}}$ & $\set{\u{c}, \varepsilon}$ \\
    \textsc{FOLLOW} & $\set{\$}$ & $\set{\$, \u{b}, \u{c}, \u{a}}$ & $\set{\$, \u{b}, \u{c}, \u{a}}$ & $\set{\u{a}}$ \\
  \end{tabular}
%\end{table}
%
\section{Exercise 2a}
%
%\begin{table}
  \begin{tabular}{lcccc}
      &    $\u{a}$     &    $\u{b}$    &   $\u{c}$   &   \$ \\
  \hline
    S & $S \to A$      & $S \to A$     & $S \to A$   & \\
    A & $A \to AB, A \to \u{a}$ &      &             & \\
    B & $B \to CA$     & $B \to \u{b}$ & $B \to CA$  & \\
    C & $C \to \varepsilon$ &          & $C \to \u{c}D, C \to \u{c}$ & \\
    D &                & $D \to \u{b}$ & $D \to \u{c}$ & \\
  \end{tabular}
%\end{table}

$(A, \u{a})$ contains a left recursion.
$(C, \u{c})$ contains an ambiguity.
%
\section{Exercise 2b}
%
\begin{align*}
  S &\to IR \\
  R &\to CIR \\
  R &\to \varepsilon \\[7pt]
  I &\to \u{a}J \\
  J &\to \u{b}J \\
  J &\to \varepsilon \\[7pt]
  C &\to \u{c}D \\
  C &\to \varepsilon \\
  D &\to \u{c} \\
  D &\to \u{b} \\
  D &\to \varepsilon
\end{align*}
%
%\begin{table}
 \begin{center}
  \begin{tabular}{lcccc}
      & $\u{a}$ & $\u{b}$ & $\u{c}$ & \$ \\
  \hline
    S & $S \to IR$ &      &         &  \\
    R & $R \to CIR$ &     & $R \to CIR$ & $R \to \epsilon$ \\
    I & $I \to \u{a}J$ &  &         &  \\
    J & $J \to \varepsilon$ & $J \to \u{b}J$ & $J \to \varepsilon$ & $J \to \varepsilon$ \\
    C & $C \to \varepsilon$ & & $C \to \u{c}D$ & \\
    D & $D \to \varepsilon$ & $D \to \u{b}$ & $D \to \u{c}$ & \\
  \end{tabular}
 \end{center}
%\end{table}
%
\section{Exercise 2c}
%
\begin{center}
 \begin{tabular}{lll}
  \textsc{Input}           & \textsc{Stack}        & \textsc{Comment} \\
  $\u{\$abcbba}$           & $S$                   & $S \to IR$ \\
  $\u{\$abcbba}$           & $RI$                  & $I \to \u{a}J$ \\
  $\u{\$abcbba}$           & $RJ\u{a}$             & $J \to \u{b}J$ \\
  $\u{\$abcbb}$            & $RJ\u{b}$             & $J \to \u{b}J$ \\
  $\u{\$abcb}$             & $RJ\u{b}$             & $J \to \varepsilon$ \\
  $\u{\$abc}$              & $R$                   & $R \to CIR$ \\
  $\u{\$abc}$              & $RIC$                 & $C \to \u{c}D$ \\
  $\u{\$abc}$              & $RID\u{c}$            & $D \to \u{b}$ \\
  $\u{\$ab}$               & $RI\u{b}$             & $I \to \u{a}J$ \\
  $\u{\$a}$                & $RJ\u{a}$             & $J \to \varepsilon$ \\
  $\u{\$}$                 & $R$                   & $R \to \varepsilon$ \\
  $\u{\$}$                 &                       & accepted \\
 \end{tabular}
\end{center}
%
\section{Exercise 3}
%
\lstset{language=EXP}
\begin{lstlisting}
factorial(x) =
  if eq?(x, 0) then eins
  else if eq?(x, eins) then eins
  else mult(factorial(minus(x, eins)), x)
\end{lstlisting}

Proof by complete induction.

\subsection{Induction hypothesis}
\[
  \forall \omega, \omega(\u{x}) \leq n, \omega(\u{x}) \in ℕ:
    I(\delta, \omega, \u{factorial(x)}) = \omega(\u{x})!
\]

\subsection{Induction base 0}
\[
  \omega(\u{x}) = 0
\] \[
  I(\delta, \omega, \u{\text{if eq?(x, 0) then eins else if eq?}}\ldots)
\] \[
  \NR I(\delta, \omega, \u{\text{eq?(x, 0)}})
    = \operatorname{eq?}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{0}))
    = \operatorname{eq?}(\omega(\u{x}), 0)
    = T
\] \[
  I(\delta, \omega, \u{\text{eins}}) = 1 = 0!
\]

\subsection{Induction base 1}
%
\[
  \omega(\u{x}) = 1
\] \[
  I(\delta, \omega, \u{\text{if eq?(x, 0) then eins else if eq?}}\ldots)
\] \[
  \NR I(\delta, \omega, \u{\text{eq?(x, 0)}})
    = \operatorname{eq?}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{0}))
    = \operatorname{eq?}(\omega(\u{x}), 0)
    = F
\] \[
  I(\delta, \omega, \u{\text{if eq?(x, 1) then eins else mult}}\ldots)
\] \[
  \NR I(\delta, \omega, \u{\text{eq?(x, eins)}})
    = \operatorname{eq?}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{\text{eins}}))
    = \operatorname{eq?}(\omega(\u{x}), 1)
    = T
\] \[
  I(\delta, \omega, \u{\text{eins}}\ldots) = 1 = 1!
\]

\subsection{Induction step}
%
\[
  \omega(\u{x}) = n + 1 \qquad n \geq 2
\] \[
  I(\delta, \omega, \u{\text{if eq?(x, 0) then eins else if eq?}}\ldots)
\] \[
  \NR I(\delta, \omega, \u{\text{eq?(x, 0)}})
    = \operatorname{eq?}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{0}))
    = \operatorname{eq?}(\omega(\u{x}), 0)
    = F
\] \[
  I(\delta, \omega, \u{\text{if eq?(x, 1) then eins else mult}}\ldots)
\] \[
  \NR I(\delta, \omega, \u{\text{eq?(x, eins)}})
    = \operatorname{eq?}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{\text{eins}}))
    = \operatorname{eq?}(\omega(\u{x}), 1)
    = F
\] \[
  I(\delta, \omega, \u{\text{mult(factorial(minus(x, eins)), x)}})
    = \operatorname{mult}(I(\delta, \omega, \u{\text{factorial(minus(x, eins))}}), I(\delta, \omega, \u{x}))
\] \[
  \NE \omega'(\u{x})
    = I(\delta, \omega, \u{\text{minus(x, eins)}})
    = \operatorname{minus}(I(\delta, \omega, \u{x}), I(\delta, \omega, \u{\text{eins}}))
\] \[
    = \operatorname{minus}(\omega(\u{x}), 1)
    = \operatorname{minus}(n + 1, 1) = n
\] \[
  \operatorname{mult}(n!, n+1) = (n+1)! \qquad \text{ corresponds to hypothesis}
\]

%
\section{Exercise 4a}
%
\lstset{language=prolog}
\begin{lstlisting}
odd(binStack(V, R)) :- odd(R).
odd(binStack(s(0), null)).
\end{lstlisting}
%
\section{Exercise 4b}
%
Tables~\ref{tab:4b-def} and~\ref{tab:4b-deriv}.
\begin{table}[h]
  \begin{tabular}{cl}
    Q   & $\neg \len(\binStack(0, \binStack(0, \binStack(0, \Null))), \s(\s(\s(0))))$ \\
    C1  & $\add(X, 0, X)$ \\
    C2  & $\add(X, \s(Y), \s(Z)) \lor \neg \add(X, Y, Z)$ \\
    C3  & $\len(\Null, 0)$ \\
    C4  & $\len(\binStack(V, R), E) \lor \neg \len(R, S) \lor \neg \add(\s(0), S, E)$
  \end{tabular}
  \caption{Rules of exercise 4b in logical notation}
  \label{tab:4b-def}
\end{table}
%
\begin{table}[h]
  \begin{tabular}{cl}
    Q   & $\neg \len(\binStack(0, \binStack(0, \binStack(0, \Null))), \s(\s(\s(0))))$ \\
    C4  & $\len(\binStack(V, R), E) \lor \neg \len(R, S) \lor \neg \add(\s(0), S, E)$ \\
    $\Theta$ & $\{ V = 0, R = \binStack(0, \binStack(0, null)), E = \s(\s(\s(0))) \}$ \\
    R   & $\neg \len(\binStack(0, \binStack(0, \Null)), S_1) \lor \neg \add(\s(0), S_1, \s(\s(\s(0))))$ \\[10pt]%

    C4  & $\len(\binStack(V, R), E) \lor \neg \len(R, S) \lor \neg \add(\s(0), S, E)$ \\
    $\Theta$ & $\{ V_2 = 0, R_2 = \binStack(0, \Null), E_2 = S_1 \}$ \\
    R   & $\neg \len(\binStack(0, \Null), S_2) \lor \neg \add(\s(0), S_2, S_1)
           \lor \neg \add(\s(0), S_1, \s(\s(\s(0))))$ \\[10pt]%

    C3  & $\len(\Null, 0)$ \\
    $\Theta$ & $\{ S_3 = 0 \}$ \\
    R   & $\neg \add(\s(0), 0, S_2) \lor \neg \add(\s(0), S_2, S_1) \lor \neg \add(\s(0), S_1, \s(\s(\s(0))))$ \\[10pt]%

    C1  & $\add(X, 0, X)$ \\
    $\Theta$ & $\{ S_2 = \s(0), X = S_2 \}$ \\
    R   & $\neg \add(\s(0), \s(0), S_1) \lor \neg \add(\s(0), S_1, \s(\s(\s(0))))$ \\[10pt]%

    C2  & $\add(X, \s(Y), \s(Z)) \lor \neg \add(X, Y, Z)$ \\
    $\Theta$ & $\{ X_2 = \s(0), Y_2 = 0, Z_2 = A, S_1 = \s(A) \}$ \\
    R   & $\neg \add(\s(0), 0, A) \lor \neg \add(\s(0), \s(A), \s(\s(\s(0))))$ \\[10pt]%

    C1  & $\add(X, 0, X)$ \\
    $\Theta$ & $\{ X_3 = \s(0), A = X_3 \}$ \\
    R   & $\neg \add(\s(0), \s(\s(0)), \s(\s(\s(0)))$ \\[10pt]%

    C2  & $\add(X, \s(Y), \s(Z)) \lor \neg \add(X, Y, Z)$ \\
    $\Theta$ & $\{ X_4 = \s(0), Y_3 = \s(0), Z_3 = \s(\s(0)) \}$ \\
    R   & $\neg \add(\s(0), \s(0), \s(\s(0)))$ \\[10pt]%

    C2  & $\add(X, \s(Y), \s(Z)) \lor \neg \add(X, Y, Z)$ \\
    $\Theta$ & $\{ X_5 = \s(0), Y_4 = 0, Z_4 = \s(0) \}$ \\
    R   & $\neg \add(\s(0), 0, \s(0))$ \\[10pt]%

    C1  & $\add(X, 0, X)$ \\
    $\Theta$ & $\{ X_6 = \s(0) \}$ \\
    R   & empty, query got successfully derivated. \\
  \end{tabular}
  \caption{Derivation of the query in exercise 4b}
  \label{tab:4b-deriv}
\end{table}
%
\section{Exercise 5}
%
\[
  \pi[\text{add}](\pi(a), \pi(b)) = \operatorname{add}(a, b)
\]
%
\lstset{language=EXP}
\begin{lstlisting}
add(a, b) =
  if eq?(mod(a, 2), 1) then
    if eq?(mod(b, 2), 1) then
      sub(add(a, b), 1)
    else
      if gt?(a, b) then
        sub(a, b)
      else
        add(sub(b, a), 1)
  else
    if eq?(mod(b, 2), 1) then
      if gt?(a, b) then
        add(sub(a, b), 1)
      else
        sub(b, a)
    else
      add(a, b)
\end{lstlisting}

\begin{enumerate}
  \item Sign of first parameter is positive, second parameter the same
  \item Sign of first parameter is positive, second parameter is negative
  \item Sign of first parameter is negative, second parameter is positive
  \item Sign of first parameter is negative, second parameter the same
\end{enumerate}

\textbf{Case both parameters are positive:} \\
If both parameters are positive, the modulo value of both values by 2 is 1.
Therefore the very last line of the function is evaluated. For decoded
values the result is $a+b$, which equals to $\pi(a) + \pi(b)$ for encoded
values as far as the sum of two even numbers is even (which represents
a positive number).

\end{document}


% from latexml
\documentclass{article}
\usepackage{xcolor}
\usepackage{cancel}
\usepackage{siunitx}
\usepackage{float}
\usepackage{multirow}
\usepackage{booktabs}

\DeclareSIQualifier\polymer{pol}
\DeclareSIQualifier\catalyst{cat}
\DeclareSIQualifier\isotropic{i} %?

\DeclareSIUnit\abbra{ a }
\DeclareSIUnit\abbrb{ \abbra }  % abbreviation
\DeclareSIUnit\abbrc{ \abbrb }  % abbreviation twice
\DeclareSIUnit\abbrd{ \abbre }  % before defined
\DeclareSIUnit\abbre{ e }

\def\mabbra{a}
\DeclareSIUnit\mabbrb{\mabbra}

\DeclareSIPrefix\killer{\kilo}{3}

\usepackage{amsmath}
\begin{document}
{
\color{red}
Some text \\
\SI{4}{\metre\per\sievert} \\
More text \\
\SI[color = blue]{4}{\metre\per\sievert} \\
Still red here!
\numlist[color = blue]{1;2;3;4}\\
Still red here!\\
}

\si{m^2.s}\\
\si{\mu m^2}\\

\SI{0.094}{\pi . \milli\meter . \milli\radian}\\

\SI{0.094}{\frac{1}{3} . \milli\meter . \milli\radian}\\

\SI{0.094}{\pi \per \milli\meter . \milli\radian\tothe{3}}\\
\section{Numbers}
\subsection{General}
%\num{\sqrt{2}}\\
%\num{{a word}}\\
\num{12345,67890}\\
\num{1+-2i}\\
\num{.3e45}\\
\num{1.654 x 2.34 x 3.430}\\
\num{\pi}\\
\num{2\pi}\\
\num{\pi/3}\\

\num{123}\\
\num{1234}\\
\num{12345}\\
\num{0.123}\\
\num{0,1234}\\
\num{.12345}\\
\num{3.45d-4}\\
\num{-e10}\\

\num{123e4}\\
%\num{123e4(3)}\\
\num{123(3)e4}\\

\num{123\pm2}\\
\num{123\pm2i}\\
\num{123+234i}\\
%\num{123+234}\\
%\num{123e2+234e3i}\\
\num{123+234ie3}\\
\num{123(1)+234(1)ie3}\\
%\num{123e2(1)+234e3i(1)}\\
%\num{+234(1)ie3}\\              %comes out weird?
\num{+3i}\\
\num{+3ie4}\\

Pretty nonsensical stuff?
\num{1.\pi e+3}\\
\def\dig{1234}\\
\num{\dig.\dig}\\
\def\odd{\xi}\\
\def\odder{\odd}\\
\num[input-symbols=\xi]{3\xi}\\
\num[input-symbols=\xi]{3\odd}\\
%\num[input-symbols=\odd]{3\odd}\\
\num[input-symbols=\odd, input-protect-tokens=\odd]{3\odd}\\
\num[input-symbols=\odd, input-protect-tokens=\odd]{3\odder}\\
\num[input-symbols=\odder, input-protect-tokens=\odder]{3\odder}\\
%\num[input-symbols=\odder, input-protect-tokens=\odd]{3\odder}\\
%\num[input-symbols=\odd, input-protect-tokens=\odder]{3\odder}\\

\num{1.23(1)}\\
%\num{1.23(0.01)}
\num{1.23\pm0.01}\\
%\num{1.23(1.0)}\\
%\num{1.23(\pm1)}\\
\num{1.23(\pi)}\\

\subsection{Parsing numbers}

\subsubsection{input-digits, input-decimal-markers, input-signs, input-exponent-markers}

\subsubsection{input-symbols, input-ignore}
\subsubsection{input-comparators}

\num{< 10} \\
%\SI{>> 5}{\metre} \\
\num{\le 0.12}\\

\subsubsection{input-open-uncertainty, input-close-uncertainty, input-uncertainty-signs}
\num{9.99(9)}\\
\num{9.99 +- 0.09}\\
\num{9.99 \pm 0.09}\\
\num{123 +- 4.5}\\
\num{12.3 +- 6}\\

\subsubsection{input-complex-roots}
\num{9.99 + 88.8i} \\
\num{9.99 + i88.8}\\

\subsubsection{input-protect-tokens}

\subsubsection{parse-numbers}
\num[parse-numbers = false]{\sqrt{2}}\\

\subsection{Post-processing numbers}
\subsubsection{round-mode, round-precision}
{
\num{1.23456} \\
\num{14.23} \\
\num{0.12345(9)} \\
\sisetup{
  round-mode = places,
  round-precision = 3
}%
\num{1.23456} \\
\num{14.23} \\
\num{0.12345(9)} \\
\sisetup{
  round-mode = figures,
  round-precision = 3
}%
\num{1.23456} \\
\num{14.23} \\
\num{0.12345(9)}\\
}
\subsubsection{round-integer-to-decimal}
{
\num[round-mode = figures]{1} \\
\num[round-mode = places]{1} \\
\sisetup{round-integer-to-decimal}
\num[round-mode = figures]{1} \\
\num[round-mode = places]{1}\\
}

\subsubsection{round-minimum}
{
\sisetup{round-mode = places}%
\num{0.0055} \\
\num{0.0045} \\
\sisetup{round-minimum = 0.01}%
\num{0.0055} \\
\num{0.0045}\\
}

\subsubsection{round-half}
{
\sisetup{round-mode = places, round-half = up}%
\num{0.055} \\
\num{0.045} \\
\sisetup{round-half = even}%
\num{0.055} \\
\num{0.045}
}

\subsubsection{add-decimal-zero, add-integer-zero}
{
\num{123.} \\
\num{456} \\
\num{.789} \\
\sisetup{
  add-decimal-zero = false,
  add-integer-zero = false,
}%
\num{123.} \\
\num{456} \\
\num{.789}\\
}

\subsubsection{minimum-integer-digits}
\num{123} \\
\num[minimum-integer-digits = 1]{123} \\
\num[minimum-integer-digits = 2]{123} \\
\num[minimum-integer-digits = 3]{123} \\
\num[minimum-integer-digits = 4]{123}\\

\subsubsection{explicit-sign, retain-explicit-sign}
\num{+345} \\
\num[retain-explicit-plus]{+345} \\
\num[explicit-sign = -]{345}\\
\num[explicit-sign = -]{+345}\\

\subsubsection{retain-unity-mantissa, retain-zero-exponent}
\num{1e4} \\
\num[retain-unity-mantissa = false]{1e4} \\
\num{444e0} \\
\num[retain-zero-exponent = true]{444e0}\\

\subsubsection{scientific-notation, fixed-exponent}
{
\num{0.001}\\
\num{0.0100} \\
\num{1200}\\
\sisetup{scientific-notation = true}%
\num{0.001}\\
\num{0.0100} \\
\num{1200}\\
\sisetup{scientific-notation = engineering}%
\num{0.001}\\
\num{0.0100} \\
\num{1200}\\
\sisetup{
fixed-exponent = 2,
scientific-notation = fixed,
}%
\num{0.001}\\
\num{0.0100} \\
\num{1200}\\
}

\subsubsection{omit-uncertainty}
\num{0.01(2)} \\
\num[omit-uncertainty]{0.01(2)}\\

\subsection{Printing numbers}
\subsubsection{group-digits, group-four-digits,group-seperator}
\num{12345.67890}\\
\num[group-digits= false]{12345.67890}\\
\num[group-digits= decimal]{12345.67890} \\
\num[group-digits= integer]{12345.67890}\\

\num[group-digits= false]{12345.67890}\\
\num[group-digits= decimal]{12345.67890} \\
\num[group-digits= integer]{12345.67890}\\

\num{1234567890.1234567890}\\
\num[group-four-digits]{1234567890.1234567890}\\

\num{12345} \\
\num[group-separator = {,}]{12345} \\
\num[group-separator = \text{~}]{12345}\\

\subsubsection{group-minimum-digits}
\num{1234} \\
\num[group-minimum-digits = 4]{1234} \\
\num{1234.5678} \\
\num[group-minimum-digits = 4]{1234.5678}\\

\subsubsection{output-complex-root,output-decimal-marker,copy-complex-root,copy-decimal-marker}
\num{1.23} \\
\num[output-decimal-marker = {,}]{1.23} \\
\num{1+2i} \\
\num[output-complex-root = \text{\ensuremath{i}}]{1+2i} \\
\num[output-complex-root = j]{1+2i} \\
\num[copy-complex-root]{1+2j} \\
\num[copy-decimal-marker]{555,555}\\

\subsubsection{complex-root-position}
\num{67-0.9i} \\
\num[complex-root-position = before-number]{67-0.9i} \\
\num[complex-root-position = after-number]{67-0.9i}\\

\subsubsection{exponent-base, exponent-product}
\num[exponent-product = \times]{1e2} \\
\num[exponent-product = \cdot]{1e2} \\
\num[exponent-base = 2]{1e2}\\

\subsubsection{output-exponent-marker}
\num[output-exponent-marker = \text{e}]{1e2} \\
\num[output-exponent-marker = \ensuremath{\mathrm{E}}]{1e2}\\

\subsubsection{separate-uncertainty,uncertainty-separator,output-open-uncertainty,output-close-uncertain
ty}
{
\num{1.234(5)} \\
\num{1.234\pm 0.005} \\
\num[separate-uncertainty = true]{1.234(5)} \\
\num[separate-uncertainty = true]{1.234\pm 0.005} \\
\sisetup{
  output-open-uncertainty = [,
  output-close-uncertainty = ],
  uncertainty-separator= {\,}
}
\num{1.234(5)}\\
}
\num{8.2(13)} \\
\num{8.2\pm1.3} \\
\num[separate-uncertainty]{8.2(13)}\\
\num[separate-uncertainty]{8.2\pm1.3} \\

\num{1.234(5) x \pi} \\
\num[separate-uncertainty = true]{1.234(5) x \pi} \\

\num{1.2 +- 0.001}\\
\num[separate-uncertainty]{1.2 +- 0.001}\\

\subsubsection{bracket-numbers, open-bracket, close-bracket}
{
\num{1 e10} \\
\num{2i e10} \\
\num{1+2i e10} \\
\num[bracket-numbers = false]{1+2i e10} \\
\sisetup{
  open-bracket = \{,
  close-bracket = \},
}
\num{1+2i e10}\\
}

\subsubsection{negative-color}
\num{-15673} \\
\num[negative-color = red]{-15673}

\subsubsection{bracket-negative-numbers}
\num{-15673} \\
\num[bracket-negative-numbers]{-15673} \\
%\SI{-10}{\metre} \\
%\SI[bracket-negative-numbers]{-10}{\metre}

\subsection{Multi-part Numbers}

\subsubsection{input-product,input-quotient}
\num{1 x 2 x 3} \\
\num{1e4 x 2(3) x 3/4} \\
\num[input-product=*]{4 * 5 * 6} \\
\num{ 1 / 2e4 } \\
\num{ 1e2 / 3e4 }\\

\subsubsection{output-product, output-quotient}
\num[output-product = \cdot]{4.87 x 5.321 x 6.90545} \\
\num[output-quotient = \text{ div }]{1 / 2}\\

\subsubsection{quotient-mode}
\num{1 / 2e4} \\
\num[quotient-mode = fraction]{1 / 2e4}\\

\subsubsection{fraction-function}
{
\sisetup{quotient-mode= fraction}
\num{1 / 1}\\
\num[fraction-function= \dfrac]{1 / 2}\\
%\num[fraction-function= \sfrac]{1 / 3}\\
\num[fraction-function= \tfrac]{1 / 4}\\
}

\subsection{Lists and ranges of numbers}
\subsubsection{list-final-separator,list-pair-separator,list-separator}
\numlist{0.1;0.2;0.3}\\
\numlist[list-separator = {; }]{0.1;0.2;0.3}\\
\numlist[list-final-separator = {, }]{0.1;0.2;0.3} \\
\numlist[
list-separator
= { and },
list-final-separator = { and finally }
]{0.1;0.2;0.3} \\
\numlist{0.1;0.2} \\
\numlist[list-pair-separator = {, and }]{0.1;0.2}\\

\subsection{range-phrase}

\numrange{5}{100} \\
\numrange[range-phrase = --]{5}{100}\\

\subsection{Angles}
\subsubsection{number-angle-product}
\ang{2.67} \\
\ang[number-angle-product = \,]{2.67}
\subsubsection{arc-separator}
\ang{6;7;6.5} \\
\ang[arc-separator = \,]{6;7;6.5}
\subsubsection{add-arc-degree-zero,add-arc-minute-zero,add-arc-second-zero}
\ang{-1;;} \\
\ang{;-2;} \\
\ang{;;-3} \\
{
\sisetup{add-arc-degree-zero}
\ang{-1;;} \\
\ang{;-2;} \\
\ang{;;-3} \\
}
{
\sisetup{add-arc-minute-zero}
\ang{-1;;} \\
\ang{;-2;} \\
\ang{;;-3} \\
}
{
\sisetup{add-arc-second-zero}
\ang{-1;;} \\
\ang{;-2;} \\
\ang{;;-3}\\
}
\ang[add-arc-minute-zero,add-arc-second-zero]{45.697}\\

\subsubsection{angle-symbol-over-decimal}
\ang{45.697} \\
\ang{6;7;6.5} \\
\ang[angle-symbol-over-decimal]{45.697} \\
\ang[angle-symbol-over-decimal]{6;7;6.5}

% \ang{10}\\
% \ang{12.3}\\
% \ang{4,5}\\
% \ang{1;2;3}\\
% \ang{;;1}\\
% \ang{+10;;}\\
% \ang{-0;1;}\\

\section{Units}
\def\showunit#1{#1 & \texttt{$\backslash$#1} & \si{\csname#1\endcsname}}
\begin{table}
\caption{SI base units}
\centering
\begin{tabular}{lll}\hline\hline
Unit & Macro & Symbol \\\hline
\showunit{ampere}\\
\showunit{candela}\\
\showunit{kelvin}\\
\showunit{kilogram}\\
\showunit{metre}\\
\showunit{mole}\\
\showunit{second}\\
\end{tabular}
\end{table}

\begin{table}
\caption{Coherent derived units}
\centering
\begin{tabular}{llllll}\hline\hline
Unit & Macro & Symbol &
Unit & Macro & Symbol \\\hline
\showunit{becquerel}     & \showunit{newton} \\
\showunit{degreeCelsius} & \showunit{ohm} \\
\showunit{coulomb}       & \showunit{pascal} \\
\showunit{farad}         & \showunit{radian} \\
\showunit{gray}          & \showunit{siemens} \\
\showunit{hertz}         & \showunit{sievert} \\
\showunit{henry}         & \showunit{steradian} \\
\showunit{joule}         & \showunit{tesla} \\
\showunit{katal}         & \showunit{volt} \\
\showunit{lumen}         & \showunit{watt} \\
\showunit{lux}           & \showunit{weber} \\
\end{tabular}
\end{table}

\begin{table}
\caption{Non-SI units}
\centering
\begin{tabular}{lll}\hline\hline
Unit & Macro & Symbol \\\hline
\showunit{day}\\
\showunit{degree}\\
\showunit{hectare}\\
\showunit{hour} \\
\showunit{litre}\\
\showunit{liter}\\
\showunit{arcminute}\\
\showunit{minute}\\
\showunit{arcsecond}\\
\showunit{tonne}\\
\end{tabular}
\end{table}

\begin{table}
\caption{Expermental Non-SI units}
\centering
\begin{tabular}{lll}\hline\hline
Unit & Macro & Symbol \\\hline
\showunit{astronomicalunit}\\
\showunit{atomicmassunit}\\
\showunit{bohr}\\
\showunit{clight}\\
\showunit{dalton}\\
\showunit{electronmass}\\
\showunit{electronvolt}\\
\showunit{elementarycharge}\\
\showunit{hartree}\\
\showunit{planckbar}\\
\end{tabular}
\end{table}

\begin{table}
\caption{Other non-SI units}
\centering
\begin{tabular}{lll}\hline\hline
Unit & Macro & Symbol \\\hline
\showunit{angstrom}\\
\showunit{bar}\\
\showunit{barn}\\
\showunit{bel}\\
\showunit{decibel}\\
\showunit{knot}\\
\showunit{mmHg}\\
\showunit{nauticalmile}\\
\showunit{neper}\\
\end{tabular}
\end{table}

\def\showprefix#1{#1 & \texttt{$\backslash$#1} & \si{\csname#1\endcsname} & \si[prefixes-as-symbols=false]{\csname#1\endcsname}}
\begin{table}
\caption{Other non-SI units}
\centering
\begin{tabular}{llllllll}\hline\hline
Unit & Macro & Symbol & Power
Unit & Macro & Symbol & Power \\\hline
\showprefix{yocto} & \showprefix{deca}\\
\showprefix{zepto} & \showprefix{hecto}\\
\showprefix{atto}  & \showprefix{kilo}\\
\showprefix{femto} & \showprefix{mega}\\
\showprefix{pico}  & \showprefix{giga}\\
\showprefix{nano}  & \showprefix{tera}\\
\showprefix{micro} & \showprefix{peta}\\
\showprefix{milli} & \showprefix{exa}\\
\showprefix{centi} & \showprefix{zetta}\\
\showprefix{deci}  & \showprefix{yotta}\\
\end{tabular}
\end{table}

\begin{table}
\caption{Abbreviated units}
\centering
\begin{tabular}{lll}\hline\hline
Unit & Macro & Symbol \\\hline
\showunit{fg}\\
\showunit{pg}\\
\showunit{ng}\\
\showunit{ug}\\
\showunit{mg}\\
\showunit{g}\\
\showunit{kg}\\
\showunit{amu}\\\hline
\showunit{pm}\\
\showunit{nm}\\
\showunit{um}\\
\showunit{mm}\\
\showunit{cm}\\
\showunit{dm}\\
\showunit{m}\\
\showunit{km}\\\hline
\showunit{as}\\
\showunit{fs}\\
\showunit{ps}\\
\showunit{ns}\\
\showunit{us}\\
\showunit{ms}\\
\showunit{s}\\\hline
\showunit{fmol}\\
\showunit{pmol}\\
\showunit{nmol}\\
\showunit{umol}\\
\showunit{mmol}\\
\showunit{mol}\\
\showunit{kmol}\\\hline
\showunit{pA}\\
\showunit{nA}\\
\showunit{uA}\\
\showunit{mA}\\
\showunit{A}\\
\showunit{kA}\\\hline
\showunit{ul}\\
\showunit{ml}\\
\showunit{l}\\
\showunit{hl}\\
\showunit{uL}\\
\showunit{mL}\\
\showunit{L}\\
\showunit{hL}\\\hline
\showunit{mHz}\\
\showunit{Hz}\\
\showunit{kHz}\\
\showunit{MHz}\\
\showunit{GHz}\\
\showunit{THz}\\\hline
\showunit{mN}\\
\showunit{N}\\
\showunit{kN}\\
\showunit{MN}\\\hline
\showunit{Pa}\\
\showunit{kPa}\\
\showunit{MPa}\\
\showunit{GPa}\\\hline
\showunit{mohm}\\
\showunit{kohm}\\
\showunit{Mohm}\\\hline
\showunit{pV}\\
\showunit{nV}\\
\showunit{uV}\\
\showunit{mV}\\
\showunit{V}\\
\showunit{kV}\\\hline
\showunit{W}\\
\showunit{uW}\\
\showunit{mW}\\
\showunit{kW}\\
\showunit{MW}\\
\showunit{GW}\\\hline
\showunit{J}\\
\showunit{kJ}\\\hline
\showunit{eV}\\
\showunit{meV}\\
\showunit{keV}\\
\showunit{MeV}\\
\showunit{GeV}\\
\showunit{TeV}\\\hline
\showunit{kWh}\\\hline
\showunit{F}\\
\showunit{fF}\\
\showunit{pF}\\\hline
\showunit{K}\\\hline
\showunit{dB}\\\hline
\end{tabular}
\end{table}

\begin{table}
\caption{Binary prefixes}
\centering
\begin{tabular}{llllllll}\hline\hline
Unit & Macro & Symbol & Power \\\hline
\showprefix{kibi} \\
\showprefix{mebi} \\
\showprefix{gibi} \\
\showprefix{tebi} \\
\showprefix{pebi} \\
\showprefix{exbi} \\
\showprefix{zebi} \\
\showprefix{yobi} \\
\end{tabular}
\end{table}

%\subsection{Creating Units}
%\subsection{Loading additional units}

\subsection{Using units}
% Note that \kilogram is defined as \kilo\gram, and acts sorta like a macro
\si{\kilogram}
\si{\kilo\gram}
% Not allowed.
%\si{\kilo\kilogram}
%\si{\kilo\kilo\gram}
{
% and note that regular macros ARE expanded!
\def\killermeater{\kilo\meter}
\si{\killermeater}
}
{
% BUT, it prefers its OWN definitions!
\def\gram{Grr}
\si{\kilo\gram}
}

% However, it's happy with various indirect definitions.
% Ie. units, prefixes (at least) act like regular macros within \si.
\si{\abbra}\\
\si{\abbrb}\\
\si{\abbrc}\\
\si{\abbrd}\\
\si{\abbre}\\

\si{\mabbra}\\
\si{\mabbrb}\\

\si{\killer\meter}\\

% Where can highlight go?
\si{\highlight{red}\kilo\gram\metre\per\second} \\
\si{\kilo\highlight{red}\gram\metre\per\second} \\
\si{\kilo\gram\highlight{red}\metre\per\second} \\
\si{\kilo\gram\metre\highlight{red}\per\second} \\
\si{\kilo\gram\metre\per\highlight{red}\second} \\

\si{\cancel\kilo\gram\metre\per\second} \\
\si{\kilo\cancel\gram\metre\per\second} \\
\si{\kilo\gram\cancel\metre\per\second} \\
\si{\kilo\gram\metre\cancel\per\second} \\
\si{\kilo\gram\metre\per\cancel\second} \\

\subsubsection{forbid-literal-units, inter-unit-product}
\si{\farad\squared\lumen\candela} \\
\si[inter-unit-product = \ensuremath{{}\cdot{}}]
{\farad\squared\lumen\candela}\\

\subsubsection{per-mode, per-symbol, bracket-unit-denominator}
\si{\joule\per\mole\per\kelvin} \\
\si{\metre\per\second\squared} \\
\si[per-mode=fraction]{\joule\per\mole\per\kelvin} \\
\si[per-mode=fraction]{\joule\raiseto{-1}\mole\per\kelvin} \\
\si[per-mode=fraction]{\metre\per\second\squared}\\
\si{\ampere\per\mole\second} \\
\si[per-mode = reciprocal-positive-first]{\ampere\per\mole\second}

{
\sisetup{per-mode = symbol}%
\si{\joule\per\mole\per\kelvin} \\
\si{\metre\per\second\squared} \\
\si[per-symbol = \text{~div~}]{\joule\per\mole\per\kelvin} \\
\si[bracket-unit-denominator = false]{\joule\per\mole\per\kelvin}\\
}
\si[per-mode=repeated-symbol]{\joule\per\mole\per\kelvin}\\
{
\sisetup{per-mode = symbol-or-fraction}%
\( \si{\joule\per\mole\per\kelvin} \)
\[ \si{\joule\per\mole\per\kelvin} \]
\si{\joule\per\mole\per\kelvin} \\
\(
\displaystyle
\si{\joule\per\mole\per\kelvin}
\)
\[
\textstyle
\si{\joule\per\mole\per\kelvin}
\]
}

\subsubsection{sticky-per}
\si{\pascal\per\gray\henry} \\
\si[sticky-per]{\pascal\per\gray\henry}\\

\subsubsection{power-font}
\si{\metre\per\second\squared} \\
\si[power-font = unit]{\metre\per\second\squared}\\

\subsubsection{literal-superscript-as-power}
\si{m.s^{2}} \\
\si[literal-superscript-as-power = false]{m.s^{2}}\\

\subsubsection{qualifier-mode, qualifier-phrase}
\si{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
\si[qualifier-mode = brackets]
{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
\si[qualifier-mode = subscript]
{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
\si[qualifier-mode = space]
{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
\si[qualifier-mode = text]
{\deci\bel\isotropic}\\

\si[qualifier-mode = phrase]
{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
\si[qualifier-mode = phrase, qualifier-phrase = { by }]
{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\

\subsubsection{prefixes-as-symbols}
\si{\milli\litre\per\mole\deci\ampere} \\
%%\SI{10}{\kilo\gram\squared\deci\second} \\
\si[prefixes-as-symbols=false]{\milli\litre\per\mole\deci\ampere}\\
\si[prefixes-as-symbols=false]{\kilo\gram\squared\deci\second}\\
\si{\mega\gram\squared\deci\second}\\
\si[prefixes-as-symbols=false]{\mega\gram\squared\deci\second}\\
\si{\micro\gram\squared\deci\second}\\
\si[prefixes-as-symbols=false]{\micro\gram\squared\deci\second}\\
\si{\per\mega\gram\squared\deci\second}\\
\si[prefixes-as-symbols=false]{\per\mega\gram\squared\deci\second}\\
\si{\per\micro\gram\squared\deci\second}\\
\si[prefixes-as-symbols=false]{\per\micro\gram\squared\deci\second}\\
%%\SI[prefixes-as-symbols=false]{10}{\kilo\gram\squared\deci\second}\\

\subsubsection{parse-units}
%%\SI{300}{\MHz} \\
%%\SI[parse-units = false]{300}{\MHz}\\

\subsection{Numbers with units}
\subsubsection{allow-number-unit-breaks}
\subsubsection{number-unit-product}
\SI{2.67}{\farad} \\
\SI[number-unit-product = \ ]{2.67}{\farad} \\
\SI[number-unit-product = ]{2.67}{\farad}\\

\subsubsection{multi-part-units}
{
\sisetup{separate-uncertainty}%
\SI{12.3(4)}{\kilo\gram} \\
\SI[multi-part-units = brackets]{12.3(4)}{\kilo\gram} \\
\SI[multi-part-units = repeat]{12.3(4)}{\kilo\gram}\\
\SI[multi-part-units = single]{12.3(4)}{\kilo\gram}\\
}

{
\sisetup{separate-uncertainty,bracket-numbers = false}%
\num{1.234(5)e-4} \\
\SI{1.234(5)e-4}{\metre}\\
}
\subsubsection{product-units}
\SI{2 x 3 x 4}{\metre} \\
\SI[product-units = brackets]{2 x 3 x 4}{\metre}\\
\SI[product-units = brackets-power]{2 x 3 x 4}{\metre}\\
\SI[product-units = power]{2 x 3 x 4}{\metre}\\
\SI[product-units = repeat]{2 x 3 x 4}{\metre}\\
\SI[product-units = single]{2 x 3 x 4}{\metre}\\

\subsubsection{list-units,range-units}
\SIlist{2;4;6;8}{\tesla} \\
\SIlist[list-units = brackets]{2;4;6;8}{\tesla} \\
\SIlist[list-units = repeat]{2;4;6;8}{\tesla} \\
\SIlist[list-units = single]{2;4;6;8}{\tesla} \\
\SIrange{2}{4}{\degreeCelsius} \\
\SIrange[range-units = brackets]{2}{4}{\degreeCelsius} \\
\SIrange[range-units = repeat]{2}{4}{\degreeCelsius} \\
\SIrange[range-units = single]{2}{4}{\degreeCelsius}\\

\subsubsection{exponent-to-prefix}
\SI{1700}{\g} \\
\SI{1.7e3}{\g} \\
{
\sisetup{exponent-to-prefix}%
\SI{1700}{\g} \\
\SI{1.7e3}{\g} \\
}
{
\sisetup{fixed-exponent = 3, scientific-notation = fixed}%
\SI{1700}{\g} \\
\SI{1.7e3}{\g}\\
}

\subsubsection{just degree}

\si{\degree}

\section{Tabular material}
% \begin{tabular}{S}
% 2.3456 \\
% \end{tabular}
% \end{document}

\begin{table}[H]
\caption{Standard behaviour of the \texttt{S} column type.}
\label{tab:S:standard}
\centering
\begin{tabular}{S}
\toprule
{Some Values} \\
\midrule
2.3456 \\
34.2345 \\
-6.7835 \\
90.473 \\
5642.5 \\
1.2e3 \\
e4 \\
\bottomrule
\end{tabular}
\end{table}

%\end{document}

\begin{table}[H]
\caption{Detection of surrounding material in an \texttt{S} column.}
\label{tab:S:extras}
\centering
\begin{tabular}{S[color=orange]}
\toprule
{Some Values} \\
\midrule
12.34 \\
\color{purple} 975,31 \\
44.268 \textsuperscript{\emph{a}} \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[H]
\caption{Controlling complex alignment with the tablenum macro.}
\label{tab:tablenum}
\centering
\begin{tabular}{lr}
\toprule
Heading & Heading \\
\midrule
Info & More info \\
Info & More info \\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{12,34}} \\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{333.5567}} \\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{4563.21}} \\
\bottomrule
\end{tabular}
\hfil
\begin{tabular}{lr}
\toprule
Heading & Heading \\
\midrule
\multirow{2}*{\tablenum{88,999}} & aaa \\
& bbb \\
\multirow{2}*{\tablenum{33,435}} & ccc \\
& ddd \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[H]
\centering
\caption{Units in tables.}
\label{tab:s:demo}
\begin{tabular}{s}
\toprule
\multicolumn{1}{c}{Unit} \\
\midrule
\metre\squared\per\second \\
\pascal \\
m.s^{-1} \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[H]
\centering
\caption{The \texttt{s} column processes everything.}
\label{tab:s:processing}
\sisetup{color = orange}
\begin{tabular}{ss}
\toprule
{Unit}
& \multicolumn{1}{c}{Unit}\\
\midrule
{\si{m^3}} & \multicolumn{1}{c}{\si{m^3}} \\
\kilogram
& \kilogram \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-parse-only}
\begin{table}[H]
\centering
\caption{Parsing without aligning in an \texttt{S} column.}
\label{tab:S:parse}
\begin{tabular}{SS[table-parse-only]}
\toprule
{Decimal-centred} &
{Simple centring} \\
\midrule
12.345 & 12.345 \\
6,78   & 6,78   \\
-88.8(9) & -88.8(9) \\
4.5e3    & 4.5e3 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-number-alignment}
\begin{table}[H]
\caption{Aligning the \texttt{S} column.}
\label{tab:S:align}
\centering
\sisetup{
table-figures-integer = 2,
table-figures-decimal = 4
}
\begin{tabular}{
S
S[table-number-alignment = center]
S[table-number-alignment = left]
S[table-number-alignment = right]
}
\toprule
{Some Values} & {Some Values} & {Some Values} & {Some Values} \\
\midrule
2.3456 & 2.3456 & 2.3456 & 2.3456\\
34.2345 & 34.2345 & 34.2345 & 34.2345\\
56.7835 & 56.7835& 56.7835 & 56.7835\\
90.473 & 90.473 & 90.473 & 90.473\\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-figures-decimal, table-figures-exponent,table-figures-integer,table-figures-
uncertainty}

\begin{table}[H]
\caption{Reserving space in \texttt{S} columns.}
\label{tab:S:space}
\sisetup{
table-number-alignment = center,
table-figures-integer = 2
}
\centering
\begin{tabular}{
S
S[table-number-alignment = right]
S[table-figures-uncertainty = 1]
S[separate-uncertainty, table-figures-uncertainty = 1]
S[table-sign-mantissa]
S[table-figures-exponent = 1]
}
\toprule
{Values}
& {Values}
& {Values}
& {Values}
& {Values}
& {Values} \\
\midrule
2.3 & 2.3 & 2.3(5) & 2.3(5) & 2.3 & 2.3e8\\
34.23 & 34.23 & 34.23(4) & 34.23(4) & 34.23 & 34.23\\
56.78 & 56.78 & 56.78(3) & 56.78(3) & -56.78 & 56.78e3\\
3,76 & 3,76 & 3,76(2) & 3.76(2) & +-3.76 & e6\\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-comparator}
\begin{table}[H]
\caption{Reserving space for comparators in \texttt{S} columns.}
\label{tab:S:comparators}
\sisetup{
table-number-alignment = center,
table-figures-integer = 2,
table-figures-decimal = 2,
table-figures-exponent = 2,
}
\centering
\begin{tabular}{
S
S[table-comparator = true]}
\toprule
{Values}
& {Values} \\
\midrule
2 .3  & < 2.3e8\\
34.23 & = 34.23 \\
56.78 & >= 56.78e3\\
3,76  & \gg e6 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-format}
\begin{table}[H]
\caption{Using the \texttt{table-format} option.}
\label{tab:S:format}
\centering
\begin{tabular}{
S
S[table-format = 2.2]
S[table-format = 2.2(1)]
S[table-format = +2.2]
S[table-format = 2.2e1]
}
\toprule
{Values}
& {Values}
& {Values}
& {Values}
& {Values} \\
\midrule
2.3 & 2.3 & 2.3(5) & 2.3 & 2.3e8 \\
34.23 & 34.23 & 34.23(4) & 34.23 & 34.23 \\
56.78 & 56.78 & 56.78(3) & -56.78 & 56.78e3 \\
3,76 & 3,76 & 3.76(2) & +-3.76 & e6 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-space-text-pre, table-space-text-post}
\begin{table}[H]
\caption{Text before and after numbers.}
\label{tab:S:ends}
\centering
\sisetup{
table-number-alignment = center,
table-figures-integer = 2,
table-figures-decimal = 4,
table-space-text-pre
= now~,
table-space-text-post =
\textsuperscript{\emph{a}}
}
\begin{tabular}{S}
\toprule
{Values} \\
\midrule
2.3456 \\
34.2345 \textsuperscript{\emph{a}}\\
56.7835 \\
now~ 90.473 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-align-comparator, table-align-exponent, table-align-uncertainty}
\begin{table}[H]
\centering
\caption{The \texttt{table-align-exponent} option}
\label{tab:align:exp}
\sisetup{table-format = 1.3e2, table-number-alignment = center}
\begin{tabular}{SS[table-align-exponent = false]}
\toprule
{Header} & {Header} \\
\midrule
1.2e3 & 1.2e3 \\
1.234e56 & 1.234e56 \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[H]
\centering
\caption{The \texttt{table-align-uncertainty} option}
\label{tab:align:uncert}
\sisetup{
separate-uncertainty,
table-format = 1.3(1),
}
\begin{tabular}{SS[table-align-uncertainty = false]}
\toprule
{Header} & {Header} \\
\midrule
1.2(1) & 1.2(3) \\
1.234(5) & 1.234(5) \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[H]
\centering
\caption{The \texttt{table-align-comparator} option}
\label{tab:align:comp}
\sisetup{table-format = >2.2}
\begin{tabular}{SS[table-align-comparator = false]}
\toprule
{Header} & {Header} \\
\midrule
> 1.2 & > 1.2 \\
< 12.34 & < 12.34 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-omit-exponent}
\begin{table}[H]
\centering
\caption{The \texttt{table-omit-exponent} option}
\label{tab:exp:omit}
\begin{tabular}{
S[table-format = 1.1e1]
S[fixed-exponent = 3, table-format = 2.1, table-omit-exponent]
}
\toprule
{Header} & {Header / \num{e3}} \\
\midrule
1.2e3 & 1.2e3 \\
3e2 & 3e2 \\
1.0e4 & 1.0e4 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-align-text-pre,table-align-text-post}
% \begin{table}[H]
% \caption{Closing notes up to text.}
% \label{tab:S:notes}
% \newrobustcmd\NoteMark[1]{%
% \textsuperscript{\emph{#1}}%
% }
% \centering
% \sisetup{
% table-number-alignment = center,
% table-figures-integer = 2,
% table-figures-decimal = 4,
% table-space-text-pre
% = \NoteMark{a}
% }
% \begin{tabular}{
% S
% S[table-align-text-pre = false]
% }
% \toprule
% {Values}
% & {Values} \\
% \midrule
% 2.3456 &
% 2.3456 \\
% \NoteMark{a} 4.234 & \NoteMark{a} 4.234 \\
% \NoteMark{b}
% .78
% & \NoteMark{b}
% .78 \\
% \NoteMark{d} 88
% & \NoteMark{d} 88
% \\
% \bottomrule
% \end{tabular}
% \hfil
% \sisetup{table-space-text-post = \NoteMark{a}}
% \begin{tabular}{
% S
% S[table-align-text-post = false]
% }
% \toprule
% {Values}
% & {Values} \\
% \midrule
% 2.3456
% & 2.3456 \\
% 34.234 \NoteMark{a} & 34.234 \NoteMark{a} \\
% 56.78
% \NoteMark{b} & 56.78 \NoteMark{b} \\
% 90.4
% \NoteMark{c} & 90.4
% \NoteMark{c} \\
% 88
% \NoteMark{d} & 88
% \NoteMark{d} \\
% \bottomrule
% \end{tabular}
% \end{table}

\subsubsection{table-auto-round}
\begin{table}[H]
\centering
\caption{The \texttt{table-auto-round} option.}
\label{tab:S:auto}
\sisetup{
table-number-alignment = center,
table-figures-integer = 1,
table-figures-decimal = 3
}
% Notice the overfull hbox which results with
% the first column
\begin{tabular}{
S
S[table-auto-round]
}
\toprule
{Header} & {Header} \\
\midrule
1.2 & 1.2 \\
1.2345 & 1.2345 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{parse-numbers}
\begin{table}[H]
\caption{Aligning without parsing.}
\label{tab:S:nonparsed}
\sisetup{
parse-numbers = false,
table-figures-integer = 2,
table-figures-decimal = 3
}
\centering
\begin{tabular}{
S
S[table-number-alignment = center]
S[table-number-alignment = right]
S[table-number-alignment = left]
}
\toprule
{Some values}
& {Some values}
& {Some values}
& {Some values} \\
\midrule
2.35 &
2.35 &
2.35 &
2.35 \\
34.234 &
34.234 &
34.234 & 34.234 \\
56.783 &
56.783 &
56.783 & 56.783 \\
3,762 &
3,762 &
3,762 &
3.762 \\
\sqrt{2} & \sqrt{2} & \sqrt{2} & \sqrt{2} \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-text-alignment}
\begin{table}[H]
\caption{Aligning text in \texttt{S} columns.}
\label{tab:S:text}
\sisetup{
table-number-alignment = center,
table-figures-integer = 4,
table-figures-decimal = 4
}
\centering
\begin{tabular}{
S
S[table-text-alignment = left]
S[table-text-alignment = right]
}
\toprule
{Values}
& {Values}
& {Values} \\
\midrule
992.435 & 992.435 & 992.435 \\
7734.2344 & 7734.2344 & 7734.2344 \\
56.7834 &
56.7834 &
56.7834 \\
3,7462 &
3,7462 &
3,7462 \\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-unit-alignment}
\begin{table}[H]
\centering
\caption{Alignment options in \texttt{s} columns.}
\label{tab:s:align}
\begin{tabular}
{
s[table-unit-alignment = right]
s
s[table-unit-alignment = left]
}
\toprule
{Right-aligned} &
{Centred text} &
{Left-aligned} \\
\midrule
\metre\per\second & \metre\per\second & \metre\per\second \\
\kilogram
& \kilogram
& \kilogram
\\
\bottomrule
\end{tabular}
\end{table}

\subsubsection{table-alignment}

\subsubsection{table-column-width}
\begin{table}[H]
\centering
\caption{Fixed-width columns.}
\label{tab:width:fixed}
\begin{tabular}
{
s
s[table-column-width = 2 cm]
S
S[table-column-width = 2 cm]
}
\toprule
{Flexible} &
{Fixed}
&
{Flexible} &
{Fixed}
\\
\midrule
\metre\per\second & \metre\per\second & 1.23 & 1.23 \\
\kilogram\candela & \kilogram\candela & 45.6 & 45.6 \\
\bottomrule
\end{tabular}
\end{table}

% \begin{table}[H]
% \centering
% \caption{Right-aligning under a heading.}
% \label{tab:width:special}
% \settowidth\mylength{Long header}
% \sisetup{
% table-format
% = 4
% ,
% table-number-alignment = center
% ,
% table-column-width
% = \mylength ,
% input-decimal-markers =
% ,
% input-symbols
% = .
% ,
% }
% \begin{tabular}{S}
% \toprule
% {Long header} \\
% \midrule
% 12.33 \\
% 2
% \\
% 1234
% \\
% \bottomrule
% \end{tabular}
% \end{table}

\end{document}

\si{kg.m.s^{-1}}\\
\si{\kilogram\metre\per\second} \\
\si[per-mode=symbol]{\kilogram\metre\per\second} \\
\si[per-mode=symbol]{\kilogram\metre\per\ampere\per\second}

\numlist{10;20;30}\\
\SIlist{0.13;0.67;0.80}{\milli\metre} \\
\numrange{10}{20}\\
\SIrange{0.13}{0.67}{\milli\metre}\\

\numlist{10;30;50;70}

\numrange{10}{30}

\si{kg.m/s^2} \\
\si{g_{polymer}~mol_{cat}.s^{-1}}

\si{\kilo\gram\metre\per\square\second}
\si{\gram\per\cubic\centi\metre}
\si{\square\volt\cubic\lumen\per\farad}
\si{\metre\squared\per\gray\cubic\lux}
\si{\henry\second}

\SI[mode=text]{1.23}{J.mol^{-1}.K^{-1}}\\
\SI{.23e7}{\candela}\\
\SI[per-mode=symbol]{1.99}[\$]{\per\kilogram}\\
\SI[per-mode=fraction]{1,345}{\coulomb\per\mole}\\

\SIlist{10;30;45}{\metre}

\si{\square\becquerel} \\
\si{\joule\squared\per\lumen} \\
\si{\cubic\lux\volt\tesla\cubed}

\si{\henry\tothe{5}} \\
\si{\raiseto{4.5}\radian}

\si{\joule\per\mole\per\kelvin} \\
\si{\joule\per\mole\kelvin} \\
\si{\per\henry\tothe{5}} \\
\si{\per\square\becquerel}

\si{\kilogram\of{metal}} \\
\SI[qualifier-mode = brackets]
{0.1}{\milli\mole\of{cat}\per\kilogram\of{prod}}

\si[per-mode = fraction]
{\cancel\kilogram\metre\per\cancel\kilogram\per\second} \\
\si{\highlight{red}\kilogram\metre\per\second} \\
\si[unit-color = purple]
{\highlight{red}\kilogram\metre\per\second}

\si{\kilo} \\
\si{\micro} \\
\si[prefixes-as-symbols = false]{\kilo}

\si{\kilo\gram\micro} \\
\SI{10}{\micro}

\begin{table}
\caption{Standard behaviour of the \texttt{S} column type.}
\label{tab:S:standard}
\centering
\begin{tabular}{S}
\toprule
{Some Values} \\
\midrule
2.3456 \\
34.2345 \\
-6.7835 \\
90.473 \\
5642.5
\\
1.2e3 \\
e4 \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}
\caption{Detection of surrounding material in an \texttt{S}
column.}
\label{tab:S:extras}
\centering
\begin{tabular}{S[color=orange]}
\toprule
{Some Values} \\
\midrule
12.34 \\
\color{purple} 975,31 \\
44.268 \textsuperscript{\emph{a}} \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}
\caption{Controlling complex alignment with the tablenum macro.}
\label{tab:tablenum}
\centering
\begin{tabular}{lr}
\toprule
Heading & Heading \\
\midrule
Info & More info \\
Info & More info \\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{12,34}}
\\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{333.5567}} \\
\multicolumn{2}{c}{\tablenum[table-format = 4.4]{4563.21}}
\bottomrule
\end{tabular}
\hfil
\begin{tabular}{lr}
\toprule
Heading & Heading \\
\midrule
\multirow{2}*{\tablenum{88,999}} & aaa \\
& bbb \\
\multirow{2}*{\tablenum{33,435}} & ccc \\
& ddd \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}
\centering
\caption{Units in tables.}
\label{tab:s:demo}
\begin{tabular}{s}
\toprule
\multicolumn{1}{c}{Unit} \\
\midrule
\metre\squared\per\second \\
\pascal \\
m.s^{-1} \\
\bottomrule
\end{tabular}
\end{table}

\end{document}


\section{Modules}

\begin{itemize}

	\item Modules provide a way to store data structures and procedures

	\item Example:\\
	\gcl{0}{\Module ~ UniqueNumberAllocator}
	\gcl{1}{\Export ~ Acquire, Reset}
	\gcl{1}{\Import ~ Choose}
	\gcl{1}{}
	\gcl{1}{\Var ~ u : \textbf{set} \left[0, N\right)}
	\gcl{1}{}
	\gcl{1}{\Procedure ~ Acquire(\Result ~ t) \defeq}
	\gcl{2}{Choose(\left[0, N\right) - $ u $, t); u := u \cup \left\lbrace t \right\rbrace]}
	\gcl{1}{}
	\gcl{1}{\Procedure ~ Reset() \defeq u := \left\lbrace \right\rbrace}
	\gcl{1}{}
	\gcl{1}{\Procedure ~ Choose(\Value ~ s; \Result ~ e) \defeq e : [s \ne \left\lbrace \right\rbrace, e \in s]}
	\gcl{1}{}
	\gcl{1}{\Initially ~ u = \left\lbrace \right\rbrace}
	$ \End $
	\item Syntax

	\begin{itemize}

		\item Modules are declared with $ \Module $ and have a unique name

		\item Module-level variables are declared in the $ \Var $ clause and given a type

		\item The initial condition of module variables is given the predicate in the $ \Initially $ clause

		\item Modules may define procedures which make use of its variables

		\item Modules list which procedures are exported publicly with an $ \Export $ clause (if there is no $ \Export $ clause, all procedures are exported)

		\item The variables and procedures of another module may be used if they are included in the $ \Import $ clause

		\begin{itemize}

			\item Imported variables must be redeclared exactly as in their source module

			\item Imported procedures must be redeclared: the original declaration must refine the redeclaration

			\item Imported procedures cannot refer to the local variables of the module they are imported into

			\item Circular import/export is not well defined

		\end{itemize}

	\end{itemize}

\end{itemize}

\subsection{Module Refinement}

\begin{itemize}

	\item A module $ M' $ refines some module $ M $ with exported procedures $ E $, imported procedures $ I $ and initialisation condition $ init $ when

	\begin{itemize}

		\item $ M' $ has the same local and imported variables as $ M $

		\item The exported procedures $ E' $ refine those in $ E $ (there may be more procedures in $ E' $, but not fewer)

		\item The imported procedures $ I' $ refine those in $ I $ (there may be fewer procedures in $ I' $ but not more)

		\item The initialisation $ init' $ is stronger than $ init $ -- i.e. $ init' \entails init $

	\end{itemize}

	\item To refine modules with different variables, data refinement is required

\end{itemize}

\newpage

\subsection{Data Refinement}

\begin{itemize}

	\item The local state of a module cannot be accessed from the outside, so it may be changed provided the difference cannot be detected by use of the exported procedures

	\item Rule 1: \textbf{Introducing new variables}

	\begin{itemize}

		\item Relationships between new and existing variables are maintained via a \textbf{coupling invariant} $ CI $

		\begin{itemize}

			\item E.g. $ CI \defeq p = q + r $

		\end{itemize}

		\item The initialisation $ init $ becomes $ init \land CI $

		\begin{itemize}

			\item E.g. if initialisation was $ p = 1 $, it would become $ p = 1 \land p = q + r $

		\end{itemize}

		\item Any specification $ w : [P, Q] $ becomes $ w, c : [P \land CI, Q \land CI] $ where $ c $ is the list of new variables

		\begin{itemize}

			\item E.g. $ p : [p > 0, p < p_0]  $ becomes $ p, q, r : [p > 0 \land p = q + r, p < p_0 \land p = q + r] $

		\end{itemize}

		\item Every assignment in the module $ w := E $ becomes $ w, c := E, F $ provided that $ CI \entails CI[w, c \backslash E, F] $

		\begin{itemize}

			\item E.g. $ p := p + 1 $ becomes $ p, q := p + 1, q + 1 $, or alternately $ p, r := p + 1, r + 1 $

		\end{itemize}

		\item Every guard in the module $ G $ becomes $ G' $ provided that $ CI \entails (G \iff G') $

		\begin{itemize}

			\item $ G' \defeq CI \land G $ is always suitable

			\item E.g. the guard $ p > 0 $ could become $ p > 0 \land p = q + r $, or alternately $ p = q +r \implies p > 0 $

		\end{itemize}

	\end{itemize}

	\item Rule 2: \textbf{Removing an existing variable}

	\begin{itemize}

		\item Only \textbf{auxiliary variables} may be removed, i.e. they must only appear in:

		\begin{itemize}

			\item Assignments

			\item Specifications which modify only auxiliary variables

		\end{itemize}

		\item The initialisation $ init $ becomes $ \exists a \cdot init $ where $ a $ is the auxiliary variable

		\begin{itemize}

			\item The `one-point rule' may be used to remove the existential quantifier: $ \exists x \cdot P \land x = n \equiv P[x \backslash n] $

			\item E.g. given initialisation $ p = 1 \land p = q + r $, it would become $ \exists p \cdot p = 1 \land p = q + r \equiv q + r = 1 $

		\end{itemize}

		\item All specifications $ w, a : [P, Q] $ become $ w : [\exists a \cdot P, \forall a_0 \cdot P[w, a \backslash w_0, a_0] \implies (\exists a \cdot Q)] $

		\begin{itemize}

			\item A similar one-point rule may be used to remove the universal quantifier:\\
			$~~~~ \forall x \cdot P \land x = n \implies Q \equiv P[x \backslash n] \implies Q[x \backslash n] $

			\item E.g. $ p, q, r : [p > 0 \land p = q + r, p < p_0 \land p = q + r] $ can be refined to:\\
			\form{q, r : [\exists p \cdot p > 0 \land p = q + r, \forall p_0 \cdot p_0 > 0 \land p_0 = q_0 + r_0 \implies (\exists p \cdot p < p_0 \land p = q + r)]}
			\hint{\refsto}{Apply $ \exists $ one-point rule to pre and postconditions}
			\form{q, r : [q + r > 0, \forall p_0 \cdot p_0 > 0 \land p_0 = q_0 + r_0 \implies q + r < p_0]}
			\hint{\refsto}{Apply $ \forall $ one-point rule to postcondition}
			\form{q, r : [q + r > 0, q_0 + r_0 > 0 \implies q + r < q_0 + r_0]}

		\end{itemize}

		\item Any assignment $ w, a := E, F $ where $ E $ contains no variables from $ a $ can be replaced by $ w := E $

		\begin{itemize}

			\item E.g. $ p, q := p + 1, q + 1 $ can be replaced by $ q := q + 1 $

		\end{itemize}

		\item Normally the coupling invariant $ CI $ relates each concrete state to a unique abstract state (e.g. $ p = q + r $), in which case the following rule applies:

		\begin{itemize}

			\item Given abstract variables $ a $ and concrete variables $ c $, if $ CI \defeq a = f(c) \land P(c) $ then a guard $ G $ may be replaced by $ G[a \backslash f(c)] \land P(c)$, or simply by $ G[a \backslash f(c)] $

			\item E.g. $ p > 0 \land p = q + r $ can be replaced by $ q + r > 0 \land q + r = q + r \equiv q + r > 0 $

		\end{itemize}

	\end{itemize}

\end{itemize}


%auto-ignore
\providecommand{\MainFolder}{..}
\documentclass[\MainFolder/Text.tex]{subfiles}
\begin{document}

\section{Homological perturbation lemma}

\begin{Remark}[Origin of $\BV$-formalism in physics]
in $\BRST$ we have clasical fields $x$ and ghosts $c$ (and Lagrange multiplier $\lambda$ and $\bar{c}$ for gauge fixing)
in $\BV$-formalism add anti-fields and anti-ghosts
$$ \int_{V_0} \Vol(G) \int_{V_0/G} f(v) e^{S_{\BRST}}$$
Having $S$, they use the
resolution of the integration
$$(V_{\BV}\coloneqq T^*[-1]V_{\BRST},) \rightarrow (V_{\BRST},\int,Q,\Action_{\BRST} =)\rightarrow (V_0,\int,\Action_0)$$
-and $\Action_0$ gets written as $\Action_{\BRST} = \Action_0 +  Q(\Psi)$, where $\Psi$ is a $Q$-exact term depending on $\lambda$, $\bar{c}$ and $c$ (and Faddeev Poppov determinant and gauge fixing) called the gauge fixing fermion. Now, eventhough $\int_{V_0} e^{\Action_0}$ does not exist, $\int_V e^{\Action_{\BRST}}$ exists and does not depend $\Psi$. To remove the choice completely, one considers the $\BV$-formalism on odd cotangent bundle $V_{\BV} = T^*[1] V_{0}$ with the canonical odd symplectic form, where there is a well-defined notion of integration over a Lagrangian subspace $L \subset V_{\BV}$ which does not depend on $L$ if  the integrand is $\BV$-closed. The choice of $\Psi$ then corresponds to the choice of $L$. Having $V_0 = \Harm \oplus C$ of ``harmonic'' and the rest and. This amounts
$$ Z:  $$
$\BRST$ extends the space of fields
$$ $$
$$ \int_V f(v) e^{\Action(v)} $$
\end{Remark}

In \cite{Doubek2018}, they consider multilinear operations $l_{kg}: V^{\otimes k} \rightarrow \R$ for $k\ge 1$, $g\ge 0$ on an odd symplectic vector space~$V$ and write down an action $\Action\in \Fun(V)$ similar to \eqref{Eq:MyAction} with~$\MC_{kg}$ replaced with~$l_{kg}^+$. Notice that whereas they have $l^+_{kg}(v,\dotsc,v)$ for a ``field'' $v\in V$, we have $\MC_{kg}(v_1,\dotsc,v_k)$ for a ``string of fields'' $v_1\dotsb v_k\in \CycB(V)$. They consider the Schwarz's canonical $\BV$-operator on $\Fun(V)$ and show that $\Action$ satisfies the quantum master equation if and only if $(l_{kg})$ satisfy the relation of a quantum $\LInfty$-algebra. This is equivalent to the notion of a loop homotopy algebra from \cite{Markl1997} and to string brackets in closed string field theory from \cite{Zwiebach1992}.

In order to transform \eqref{Eq:QME} and \eqref{Eq:Twist} to the convention of \cite{Doubek2018}, we make the substitutions $\BVOp \mapsto \BVOp$ and $S \mapsto S = \hbar S$.

A deformation retract \eqref{Eq:DefRetr} induces a deformation retract
\begin{equation*}
\begin{tikzcd}
\bigl(\CycC(V),\OPQ_{110}\bigr) \arrow[loop left]{l}{K_\CycC}\arrow[shift left]{r}{P_\CycC} & \arrow[shift left]{l}{I_\CycC} \bigl(\CycC(V'),\OPQ_{110}'\bigr),
\end{tikzcd}
\end{equation*}
which further induces a deformation retract
\begin{equation*}
\begin{tikzcd}
\bigl(\Fun(B(V)),\hat{\OPQ}_{110}\bigr) \arrow[loop left]{l}{K}\arrow[shift left]{r}{P} & \arrow[shift left]{l}{I} \bigl(\Fun(B(V')),\hat{\OPQ}_{110}'\bigr).
\end{tikzcd}
\end{equation*}
We can take $P$ and $P$, resp.~$I$ and $I$ to be the natural extensions of $\iota^*$, resp.~$\pi^*$. In~\cite{Doubek2018}, they write down formulas for $K_F$ given $K$ using a tensor trick due to Eilenberg Mac-Lane (the same method may apply to get $K$ from $\Htp$ too). Note that any surjective quasi-isomorphism over $\R$ is a deformation retract.\ToDo[caption={injectiv qi},noline]{Are injective quasi-isomorphisms sections of deformatino retractions?} They idea of \cite{Doubek2018} would be to view $\BVOp$ and $\BVOp^\MC$ as perturbations of $\{\FreeAction,\cdot\} = \hat{\OPQ}_{110}$ and apply the Homological Perturbation Lemma from \cite{Crainic2004} to obtain deformation retracts
\begin{equation*}\begin{tikzcd}[execute at end picture={
\draw[->,dashed] (3.5,1.5) to[out=0,in=90] node[midway,right,xshift=.5cm]{$\delta^{(1)} = \BVOp_0$} (5,.75) to[out=-90,in=0] (3.5,0);
\draw[->,dashed] (3.5,1.5) to[out=0,in=0] node[pos=0.8,right,xshift=.3cm]{$\delta^{(2)} = \BVOp_0 + \{\IntAction,\cdot\}$} (3.5,-1.5);
}]
\bigl(\Fun(B(V)),\hat{\OPQ}_{110}\bigr) \arrow[loop left]{l}{K}\arrow[shift left]{r}{P} & \arrow[shift left]{l}{I} \bigl(\Fun(B(V')),\hat{\OPQ}_{110}'\bigr) \\
\bigl(\Fun(B(V)),\BVOp \bigr) \arrow[loop left]{l}{K^{(1)}}\arrow[shift left]{r}{P^{(1)}} & \arrow[shift left]{l}{I^{(1)}} \bigl(\Fun(B(V')),\BVOp^{(1)}\bigr)\\
\bigl(\Fun(B(V)),\BVOp^\MC \bigr) \arrow[loop left]{l}{K^{(2)}}\arrow[shift left]{r}{P^{(2)}} & \arrow[shift left]{l}{I^{(2)}} \bigl(\Fun(B(V')),\BVOp^{(2)}\bigr)
\end{tikzcd}\end{equation*}
where
\begin{align*}
 \BVOp^{(i)} &= \hat{\OPQ}_{110}' + P(\Id - \delta^{(i)}K)^{-1}\delta^{(i)} I = \hat{\OPQ}_{110}' + P \delta^{(i)} I + P \delta^{(i)} K \delta^{(i)} I + \dotsb  \\
 I^{(i)} &= I + K(\Id - \delta^{(i)}K)^{-1}\delta^{(i)} I = I + K \delta^{(i)} I + K \delta^{(i)} K \delta^{(i)} I + \dotsb \\
 P^{(i)} &= P + P(\Id-\delta^{(i)}K)^{-1}\delta^{(i)} K = P + P \delta^{(i)} K + P \delta^{(i)} K \delta^{(i)} K + \dotsb\\
 K^{(i)} &= K + K(\Id-\delta^{(i)}K)^{-1}\delta^{(i)}K = K + K\delta^{(i)} K + K \delta^{(i)} K \delta^{(i)} K + \dotsb
\end{align*}
The prerequisite for this is ``smallness'' of $\delta^{(i)}$, i.e., that $(\Id - \delta^{(i)} K)$ is invertible, plus another condition which guarantees $P(A K^2 A + A K + K A)I = 0$ where $A= (\Id - \delta K)\delta$. In the case of a special deformation retract, it holds automatically.

In the special case of being the deformation retract onto the Hodge decomposition

$$ \BVOp^{(1)} = P\BVOp_0 I,\quad \BVOp^{(2)}=\BVOp^{(1)} + \{W,\cdot\}^{(1)}\quad\text{and}\quad P^{(2)}_{\Fun} = Z $$

and define the \emph{effective action}
$$W \coloneqq \log\bigl(P'(e^{\IntAction})\bigr) \in \Fun(\CycB(V'))$$
and the \emph{path integral}
$$P^{(2)}_{\Fun} \coloneqq L_{\bigl(P'(e^{\IntAction})\bigr)^{-1}} \circ P'_{\Fun} \circ L_{P'(e^{\IntAction})}: \Fun(\CycB(V)) \rightarrow \Fun(\CycB(V')).$$

\begin{Question}
Can one choose the data and apply the Lemma to get
$$ \BVOp^{(1)} = \BVOp_0', \quad W = \Action_{\HTP_* \MC},\quad P^{(1)} = e^\HTP,\quad P^{(2)}= e^{\HTP^\MC} $$
\end{Question}

The article of \cite{Doubek2018} contains references of other authors on how to get the path integral.

The Chern-Simons is
\end{document}


\subsection{Symmetric}

We have a document we want to be able to transfer on an insecure medium.

We use a key to encrypt the file, and a key to decrypt the file.

With symmetric encryption these are the same key.


\chapter{Physical Background }
\label{chapter:Introduction}
\textit{In this chapter raise and explains the basis of  fundamental physics in semiconductor and quantum structures, implemented  to understand the results in this work.}
\vfill
\minitoc
\newpage

\lettrine[lines=3, lraise=.1, nindent=0mm, slope=0mm]{\textbf{Q}}{uantum mechanics}  is basically electron behavior that exhibits many phenomena non explained by classical regime. Quantum structures (QS) are artificially systems conformed by semiconductors where electrons exhibit their quantum nature, this is a great platform to study and create quantum devices. Nowadays, the progress in creation of QS consist in precisely deposition of thin films, in which electrons show fundamentally new electrical and optical properties\cite{sundram1991structures}. Most of these properties consist in quantum behavior  as the energy confinement, which is the principal interest to study the electron and their consequent interactions which generates analogous  hydrogen atom in semiconductors. Therefore, the interest to studying QS was increasing for many years ago and nowadays, those continue considering an excellent research area.

In this chapter, it presents the fundamental concepts to describe the physical  phenomena resultant in this work, without intention to replicate concepts and models already explained in publications with major impact. Therefore, the purpose is to present an own interpretation to highlight the great obtained results.

\section{Semiconductor Bandstructure}
\label{sec:chapter-1-semiconductor}
\vspace{-10mm}
To starting with physical background to understand the QS, it has to start with understand the  band structure of semiconductors. The band structure describes the electron behavior in a solid, therefore, we will need to invoke the \sch equation to describe it behavior. But, due inside a solid around $10^{23}$ valence electrons contribute to the bonding in each cubic centimeter, this results in a many-body complex problem\cite{piprek2017handbook}, then the general hamiltonian for a solid has the form\cite{alloul2010introduction,cardona2005fundamentals}:

\begin{equation}
\begin{split}
	H  =  &\dfrac{1}{2M}\sum\limits_{i=1}^{N_{n}} \bff{P}_{j}^{2} + \dfrac{1}{2m_{0}} \sum\limits_{j=1}^{N_{e}} \bff{p}_{j}^{2} + \dfrac{Z^{2}}{2} \sum\limits_{i,j=1,i\neq j}^{N_{n}} V_{c}\left(\bff{R}_{i}-\bff{R}_{j}\right)-Z\sum\limits_{i=1}^{N_{n}}\sum\limits_{j=1}^{N_{e}}V_{c}\left(\bff{r}_{j}-\bff{R}_{i}\right) \\
	   & + \dfrac{1}{2} \sum\limits_{i,j=1,i\neq j}^{N_{e}} V_{c} \left(\bff{r}_{i}-\bff{r}_{j}\right).
\end{split}
\label{eq:chapter-1-solid-hamiltonian}
\end{equation}

Where  $N_{n}$ is the number of atomic nuclei, $N_{e}$ is the number of electrons with mass $m_{0}$, asumming that the nuclei are the same mass it's consider  $M$ and charge $Z_{e}$. As is obviously, this Hamiltonian is so complicated, the sum of five terms which consists in : kinetic enrgies to electrons and nuclei, the nucleus-nucleus, nucleus-electron and electron-electron Coulomb interactions, also $\bff{R}_{i}$ are the positions of the nuclei and $\bff{r}_{j}$ are the position of the electrons, the operators $\bff{P}$ and $\bff{p}$ are momentum operators to nuclei and electrons respectively.  Finally, the consider of  Coulomb potential $V_{c}$\cite{alloul2010introduction}.

Fortunately, the QS are formed by crystalline materials, the Bloch theorem provide the most important tool to develop required equations. The Bloch theorem establish a periodic potential $U(\rv)$ for electrons, this due the material is periodic (definition of crystal structure) and the \sch equation it can describe in terms of single electron  as:

\begin{equation}
	\left[-\dfrac{\hbar^2}{2m_{0}}\nabla^2 + U(\rv)\right]\psi (r)=\senergy\psi(\rv)
	\label{eq:chapter-1-first-sch}
\end{equation}

The principal reason that the periodic potential in a crystal structure is highly important is their translational invariance concept and the consequent symmetry operations that are possible in a crystalline solid. The symmetry concept, as a  tool to understand solids, is discussed with major detail in the next chapter. In according to Bloch's theorem we can associate a wave vector $\boldsymbol{k}$ with each energy state, $E_{n}(\boldsymbol{k})$. Thus, it is useful to display the energies $E_{n}(\bf{k})$ as a function of the wave vector $\boldsymbol{k}$. This result also knowing as dispersion relation, but in general terms is the electron band structure of the given solid\cite{piprek2017handbook}.

Even if, the calculation of electron band structure in solids are very complex by the distance between atoms that composes it's, and the Bloch's theorem provide the most important tool to reduce the problem to crystalline structures, exists several methods to  calculate the realistic bandstructure for semiconductors that are categorized in two groups: Atomistic methods\footnote{In this category can include the ab initio methods, these are the most complex methods due to propose  solutions of the many-body problem} (Tight-binding, orthogonalized plane wave methods) and Perturbative methods ($\boldsymbol{k}\bigcdot \boldsymbol{p}$)\footnote{In fact, both TB and $\boldsymbol{k}\bigcdot \boldsymbol{p}$ also consider in same kind, because both are \emph{semi-empirical} methods due to they consider experimental parameters.}.
These two main categories with theirs respective methods have special characteristics which becomes in the reasons to choose them. The reasons have to do with to the described bandstructure, this mean, in case of Atomistic methods the entire bands  (valence and conduction) can describe, but in case of perturbative methods are reserve to near bandedge bandstructures. So, each of these methods can be chosen and enhanced as the system to study requires.
We won't enter  in discussion about of which of these methods are the best, the reasons are simple, each method is powerful, and we must be remembered that the complexity of solutions requires that these are solved by numerical techniques therefore this convert it to good approximations.
Then, basically the electron behavior inside a semiconductor consist in solutions of the appropriate Schrödinger equation\cite{boer2018semiconductor}.
\subsection{Valence and Conduction Bands}
\label{subsec:chapter-1-valence-and-conduction-bands}
\vspace{-10mm}
The most important characteristic of semiconductors even we can call as the fingerprint of these, is their bands structure, this characteristic sort out the solids as insulators, metals, and semiconductors.
These are the reason of many mechanisms and phenomena by which study this structures. In general,  the bands of semiconductors composed by valence and conduction bands separated by a  region known as bandgap.
The bandgap, which is proportional to separation energy of valence and conduction bands also is called as forbidden region, this is because doesn't exist electron states, therefore this gap energy determine the electron conduction in a semiconductor and the difference they have with the insulators and metals as shows \Cref{fig:subsubsection-1.1.1-solid-types}.

\begin{figure}[h!]
	\centering
	\includegraphics[width=\linewidth]{../figures/chapter-1/solid-sort/build/solid-sort}
	\caption{Band energy diagram for insulators (left), semiconductors(center) and metals (right). The principal difference is the gap energy, for insulators this is longer than semiconductors, although in semiconductors gap energy depends on materials, finally in metals doesn't exist gap energy instead exist an overlap bands characterize these. Dashed line determine Fermi's level.  }
	\label{fig:subsubsection-1.1.1-solid-types}
\end{figure}

So, the bandgap determines many characterizes and functionalities in semiconductors. The bandgap energy classifies semiconductors in direct and indirect semiconductors, but doesn't only depend on this energy, in reality the band structure is the liable for this. As before mentioned, it is so difficult to describe electrons behaviors over the solids due to the many body interactions that exists in its, and therefore the Scr\"odinger equation that's describe electrons behaviors is complicatedly to solve.  Fortunately, the semiconductor structures have a one of the most important characterize  and his has to do with their atomic structure,  that's periodically arrangement of atoms.
This periodicity is the key to propose solutions and describe the semiconductor band structure.
Starting with describe bulk semiconductors, for example GaAs which consists in with the family III-V cube semiconductor so that their lattice structure consist in a two sublattices correspond to each atom which it conform as shows in \Cref{fig:subsubsection-1.1.1-bulk-1}. For this case, when the atoms in two sublattice are diferent, the crystal structure is then called \emph{zinc-blende}\cite{vurgaftman2020bands}.

To calculate bandstructures of bulk semiconductors it's important to define specific symmetry direction, this mean that it's not possible to plot dispersion relation. For each three-dimensional wave vector $\boldsymbol{k}$, then the plot energy as a function of $\boldsymbol{k}$ is along of different high-symmetry directions\cite{piprek2017handbook}.
In this work the structures to study are composed of semiconductors III-V, being GaAs the bulk in each structure.  GaAs is a direct semiconductor so that the $\left[001\right]$ direction is the high-symetry direction then is denoted by $\Gamma$ point (at $\boldsymbol{k}=0$)
\begin{figure}[h!]
	\centering
	\includegraphics[width=\linewidth]{../figures/chapter-1/bulk-1/build/bulk-1}
	\caption{
		 GaAs crystal lattice, where the each sublattice correspond of each atom species Ga and As. }
	\label{fig:subsubsection-1.1.1-bulk-1}
\end{figure}

As before mentioned several times, it's very complex to compute the Schrödinger equation in the solids. The most ``exact'' compute is employed by DFT theory,  these calculations commonly are called atomistic even some  semiempirical models can consider as atomistic, but the semiemprical models are good approximations in comparison with the DFT theory. So, which is the reason to call ``exact'' solutions to the DFT results? The answer leads us to great discussion and  it's not intended to get into controversy,  but in general the DFT calculations have the capacity to calculate in terms of electrons interaction and the empirical methods are based in potential choice.\\

We will, don't into details about band calculations theories and models, but we will make a general reference to the importance in this work. The models more performed in semiconductor heterostructures as GaAs/AlGaAs are semiempirical, this is because DFT theory and their derived models are very limited to carried out in large structures, their electron interaction nature need high computational perform. So that in comparison with empirical models where the main role is the potential of semiconductor structures, this reduces computational reduce. So, the most models used in semiconductor band calculations are empirical models, these models are distinguished by low computational requires for this reason are considered like approximations. The importance to discuss these concepts will take relevance when we discuss the physics model proposed in this work.

\begin{figure}[h!]\label{fig:subsubsection-1.1.1-GaAsbands-1}
	\centering
	\begin{subfigure}{\textwidth}
	\includegraphics[width=\linewidth]{../figures/chapter-1/bands/build/bands01}
	\phantomsubcaption\label{subfig:subsubsection-1.1.1-GaAsbands-1-a)}
	\phantomsubcaption\label{subfig:subsubsection-1.1.1-GaAsbands-1-b)}
\end{subfigure}
	\caption{Band structure of GaAs, \subref{subfig:subsubsection-1.1.1-GaAsbands-1-a)} hows the zoom around of $\Gamma$  to denote the direct band gap and the electrons energy  needed to jump from valence to conduction band. \subref{subfig:subsubsection-1.1.1-GaAsbands-1-b)} denotes the two directions to dispersion of the bands corresponds to Brillouin zone: $\Gamma\to\mathrm{X}$ and  $\Gamma\to\mathrm{L}$.\cite{fox2002optical}}
\end{figure}

The \Cref{fig:subsubsection-1.1.1-GaAsbands-1} shows the results of calculations of TB model as discus it in \cite{vogl1983asemiempirical} and the code was impmemented by R. Muller \cite{rpmuller2017}. The model purposes by Vogl et al.  take into account small number of localized pseudo-orbitals and based the empirical parameters to substituted on TB Hamiltonian.
The importance to get bandstructure it's based  importance to study optical properties of solid structures, if it doesn't exist  band electrons it's like look a place without map, so, the band structure  far from being  a complex tool it's the key to get the information to investigate the optical properties.

As shown in \Cref{subfig:subsubsection-1.1.1-GaAsbands-1-a)} the GaAs bandstructure shows that it's a direct semiconductor as a previously mentioned, this gives way to get electron transitions from VB to CB and the energy to success this it. In \Cref{subfig:subsubsection-1.1.1-GaAsbands-1-b)} it's plotted, the band dispertion around $\Gamma$ point, it's the most symmetry point.  It is well-known that the band dispersion increasing $\boldsymbol{k}$ along two different directions of the Brillouin zone, from $\boldsymbol{k}=(0,0,0)$ to X point $\boldsymbol{k}=(2\pi a_{L})(1,0,0)$ and L point $\boldsymbol{k}=(2\pi a_{L})(1,1,1)$.  So, these figures, are the typical representation of direct gap to III-V semiconductors around of  $\boldsymbol{k}=0$, then, is obviously that the shape of dispersion is parabolic. For the GaAs bandstructure calculations shown in \Cref{fig:subsubsection-1.1.1-GaAsbands-1} doesn't take into account the contribution of spin\footnote{This spin contribution as called as split-off (so) hole band.}, therefore it's focus on three bands dispersion correspond to a single $s$-like conduction band and two $p$-like valence bands.  Is important to say that the characteristic curvature $E\!\!-\!\!\boldsymbol{k}$ of dispersion bands corresponds to an electron ($e$) in case of positive curvature while the negative curvature correspond to holes states; heavy ($hh$) and light hole ($lh$) bands, so, this denotes that the transitions, are of dipole nature\cite{fox2002optical,cardona2005fundamentals}.
\begin{figure}[h!]
	\centering
		\includegraphics[width=0.5\linewidth]{../figures/chapter-1/bands/build/bands02}
	\caption{Two typical transitions for GaAs near $\boldsymbol{k}=0$. The first one correspond to the heavy-hole and second one to the light-hole. }
	\label{fig:subsubsection-1.1.1-GaAsbands-2}
\end{figure}
All the above disputed is significant to refers of one of the most indispensable quantum mechanisms in solids, this is absorption. The electron absorption, specifically interband absorption, give way to a fundamental physical process that involves the principle of many basic studies of semiconductors, applications, and the importance to understand the electron behavior in a semiconductor structures disputed in this work. Then the \Cref{fig:subsubsection-1.1.1-GaAsbands-2} schematizes the two typical transitions in GaAs bulk, this transitions are near to k=0, so that is called interband absorption. Is important to remark that the interband transitions are observed in all solids, but the mechanisms are different dependently of their bandstructure, for what,  being repetitive when mentioning that the bandstructure is the key to study solids.

In case of GaAs the interband tranisitions are called as direct transitions, this is because their bandstructure proofs GaAs is a direct Gap semiconductor.  This process is determined by quantum mechanical rate $W_{i\to f}$ for exciting and electron in a initial quantum state $\psi_{i}$ to final state $\psi_{f}$ by absorption of a photon of angular frequency $\omega$\cite{fox2002optical}. As is very know, this is given by Fermi's golden rule. Later this is disputed according to highlight the model and results obtained. It has been mentioned that the direct transitions are of dipole nature, as before mentioned the CB is type $s$-like while the VB is $p$-like, then it've electric-dipole allowed transitions $p\to s$. The excitation of electron in CB carries to leave an initial state unoccupied, this is called as a hole creation, then the electron in the final state and the hole is considered as \textbf{electron-hole pair}. The next part subject this theme with major focus.

\subsection{Excitons}
\label{subsec:chapter-1-excitons}
\vspace{-10mm}
The importance to study bandstrcuture of semiconductors is very clear so far, so that could be said that absorption process is the source of optical properties of solids. It's due to this that the importance to study of semiconductors in the optoelectronics applications. But, this process give rise to formation of one of the most important excitations in the crystal structures. The photon absorption process carries to an electron is excited from CB to VB, this  generates an empty location in VB which has positive charge. This positive empty location called as hole, therefore the electron and hole have opposite charge then it's  to be expected that they are attracted, so, this creates a bound state called an exciton\cite{leonard2017exciton}.

From \Cref{fig:subsubsection-1.1.1-GaAsbands-2} and \Cref{fig:subsubsection-1.1.1-x-1}  is clearly that excitons are commonly presented in direct band gap semiconductors as GaAs, this was denoted by absorption experiments,  after mentioned in \Cref{subsec:chapter-3-pl} this is the cause in photoluminiscence mechanism.

\begin{figure}[b]
	\centering
	\includegraphics[width=0.5\linewidth]{../figures/chapter-1/exciton-1/build/x-1}
	\caption{Qualitative scheme of exciton creation in GaAs as direct gap.}
	\label{fig:subsubsection-1.1.1-x-1}
\end{figure}

\section{Semiconductor Low-Dimensional Structures}
\label{sec:chapter-1-low-dimensional-structures}
\vspace{-10mm}
The previous section engaged to explain the principles of semiconductors, this is the bandstructure, the importance of these is practically the fingerprint of all semiconductor, without bandstructure  the understanding of these would be improbable. The first approximations were based in  GaAs bulk, their cubic symmetry practically defines their nature and consequently the physical effects as excitons existence.  But, what happens  if joined several semiconductors with same symmetry and structural parameters? The bulk properties and physical properties are the same?.
The answers they are well-known, when two materials with relatively same structural parameters, as lattice constant can create a heterojunction, the union of several heterojunction make up a heterostructure.\footnote{The samples studied in this work are heterostructures, for this reason, and by nomenclature it's we refer to that way.}\\*
\begin{figure}[h]
	\centering
	\includegraphics[width=0.65\textwidth]{../figures/chapter-1/heterostructures/out/hs-01}
	\caption{General scheme of GaAs/\algaas heterostructure, at top show the scheme of atomic arranged of this heterjunction, the dashed lines are the matched between two dissimilar materials. In bottom shows the band-edge profile.}
	\label{fig:subsection-1.2-heterostructure}
\end{figure}
The \Cref{fig:subsection-1.2-heterostructure} is a general scheme of a heterostructure, in this case is presents three species of atoms Al, As, Ga. These atoms can   locate in columns III-V of the periodic table, hence its name of III-V semiconductors. The principal characteristic of these atoms is that it can create matched structures as GaAs, AlAs and ternary alloys as \algaas with specific Al concentration. The matched semiconductors produce a material with new properties based principally in the difference of bandgap which involves the alloys. \\*
As can see in \Cref{fig:subsection-1.2-heterostructure} it's consisting a GaAs/\algaas heterostructure, these interface is well-matched due to the lattice parameters is relatively equals, therefore and thanks to powerful growth technics as MBE it's possible to get high-quality quantum structures.

Also, the heterostructure composed by two semiconductors with different band gaps generate a discontinuity in either the conduction or the valence band can be represented by a constant potential term\cite{harrison2016quantum}.  The theory to treatment the electron behavior in these structures, is relatively simple if we consider the above.
Although, in this chapter doesn't have intention to explore the theory of electron behavior in that, worth noting that  it get one-dimensional potential $V(z)$ to both bands, so the Schr\"odinger equation can solve simple.

\subsection{Quantum wells}
\label{subsection:chapter-1-quantum-wells}
\vspace{-10mm}
Doubtless the creation or growth of heterostructures increased the interest in the study of quantum structures, the interactions, and physical behavior of light-matter they would not have been possible without these.  The major relevance is due the quantum confinement, the junction of semiconductors results in an interest quantum structures with specific dimensions. From 3D bulk the dimensions reduce to 2D,1D and 0D dimensional structures. Therefore each of that has interest properties and their correspond applications. The \Cref{fig:subsection-1.2-heterostructures} schematics the low dimensional heterostructures from 3D bulk, the first low dimensional from 3D to 2D  is the Quantum Wells, then from 2D to 1D it have the Quantum Wires finally with 0D have the Quantum Dots.
\begin{figure}
	\centering
	\includegraphics[width=0.6\textwidth]{../figures/chapter-1/heterostructures/out/lds-00}
	\caption{Heterostructures from bulk (3D), to Quantum Wells (2D), Quantum Wires (1D) and Quantum Dots (0D).  }
	\label{fig:subsection-1.2-heterostructures}
\end{figure}
The quantum confinement so is the principal reason to study that structures, the electron behavior which exhibits in it  should  can to help  understand  a great variety of quantum mechanical phenomena as electron interaction on a crystal.
Suppose a heterostructure composed with a two semiconductor alloys as sandwich, this 2D quantum structure is called a Single Quantum Well (SQW). \\*
This dissimilar semiconductors in terms of their potential energy ($V(z)$) can be schematized as \Cref{fig:subsection-1.2-single-quantum-well-scheme}. The Gap difference of \algaas and GaAs is due to $x$ Al concentration in \algaas therefore it obtains a one dimensional potential profile, with that can confinement electrons in a 2D plane along $z$ direction.
All of these carries to quantum mechanics formalism, the electron behavior should be obeyed these rules. If we have an electron closed in two potential barriers  an $L$ distance, the wave which describe it will be spatially confined.
So if we confined many electrons in these potential,  we have two important physical aspects: the first one is knowing as Pauli's exclusion principle, which as of its Fermion nature prevents carriers with the same spin occupying the same region in of space\cite{harrison2016quantum,pauli1925zusammenhang}, the second one and one of the most relevant in the birth of the quantum mechanics; the Heisenberg's uncertainty principle.
That last, it can say  that is the consequence of quantum confinement due to the space reduction of the electrons is expected that momentum increases by an amount of the order $\hbar/L$. Therefore, the energy of that confined particles increases, and it's referred to as confinement energy\cite{cardona2005fundamentals}. \\*
\begin{figure}
	\centering
	\includegraphics[width=0.65\textwidth]{../figures/chapter-1/heterostructures/out/qw1}
	\caption{GaAs/\algaas Single Quantum Well }
	\label{fig:subsection-1.2-single-quantum-well-scheme}
\end{figure}
Then the quantum confinement is our started point to understand the optical properties in QWs. As is referred in the figure, the uni-dimensional potential profile can well describe by top conduction- and bottom valence-bands, the band offset in these two of correspond gap energy between that, while Al concentration increases their bandgap and the band offset ($\mathrm{Q_{c}}$ to CB and $\mathrm{Q_{v}}$ to VB) also to.

It's so clearly  that the QWs have the potential to presents amazing quantum properties, even if all of these are very important we focus on the optical properties, basically our interest is the light-matter interaction through its result mechanisms.

\subsection{Preliminary approach of Quantum Confinement effect in QWs}
\label{subsection:chapter-1-preliminary-approach-of-quantum-confinment-effect-in-qws}
\vspace{-10mm}
As the title describes, here it will try to explain as the first  approach the quantum confinement effect in QWs. If  it starts with the  scoop, which it can be reduced the electrons space, then this mean that in reciprocal space it has two components $k_{x}$ and $k_{y}$. Then say in crystal symmetry properties to the case of GaAs/\algaas QWs it's $\Gamma$ the central point, as long as $x < 0.4$\footnote{It will be explained in the next section, although it's due to the Gap go from direct to indirect, shortly the symmetry $\Gamma\to X$.} the bandstructure depends on confinement energ, so say which the bandstructure depends on confinement energy.
In this case, the electronic properties in comparison with a bulk semiconductor properties can solve trough particle-in-a-box as textbook problem as first approach. Nevertheless, even if usually can solver without much mathematical formalism is very essential that it dedicates a chapter with their solution, this is because will employ a physical formalism exclusively to QWs structures. In general way, as it before mentioned the Schrödinger equation solution is the fundamental pillar to understand, where it's taken into account which  in a crystal the periodic potential is the key. Here are important remarks before to continue, when it has a heterostructure starting with the bulk model it's clearly that the system doesn't same, the Quantum Mechanics which is behind take into account the symmetry properties, then it can be developed a Hamiltonian  to understand that system.  In the next chapter will be explained details and the formalism both physical and mathematical to solve and discus it's. The model which give the tools to get the solutions is called as Effective Mass Approximation, thus their correspond Schrödinger equation is\cite{harrison2016quantum,chuang1995physics,singh2003electronic,bastard1990wave,fox2002optical,davies1998physics}:
\begin{equation}\label{eq:chapter-1-ema-schroedinger}
	-\dfrac{\hbar^{2}}{2m^{*}}\dfrac{\partial^{2}}{\partial {z}^{2}}\psi(z)+V(z)\psi(z)=E\psi(z),
\end{equation}

where the $m^{*}$ is the effective mass in each material, and $V(z)$ is the potential profile got by heterostructure materials properties. Therefore, that differential equation can solve as in textbooks explained\cite{de2014introduccion,griffiths2018introduction,sakurai1995modern,cohen2019quantum,chuang1995physics,harrison2016quantum,fox2002optical,bastard1990wave}. The idea is thinking as a one particle in a finite potential well, where is well important established the boundary conditions and solve the Schrödinger equation in each part of single QW, this means that need to create a potential function. Then it's can obtain the Eigenfunctions and their correspond Eigenenergies.

\begin{figure}
	\begin{subfigure}{\textwidth}
		\centering
		\includegraphics[width=0.65\textwidth]{../figures/chapter-1/heterostructures/out/qw2}
		\phantomsubcaption\label{subfig:subsection-1.2-single-quantum-well-scheme2-a)}
		\phantomsubcaption\label{subfig:subsection-1.2-single-quantum-well-scheme2-b)}
	\end{subfigure}
	\caption{General scheme of typical Schrödinger's equation solutions to one-dimensional potential as \subref{subfig:subsection-1.2-single-quantum-well-scheme2-a)} where the Eigenenergies of both electron and holes are denoted with same color depending on  $n$ value.\subref{subfig:subsection-1.2-single-quantum-well-scheme2-b)} It's plot, of the subbands in  the same case of  \subref{subfig:subsection-1.2-single-quantum-well-scheme2-a)} to both particles.  }
	\label{fig:subsection-1.2-single-quantum-well-scheme2}
\end{figure}

The principal idea doesn't is reproducing something which is very well known, the objective of this part is established the scoop of the next chapter. Therefore,  before to continue, we will finish with to explain the dispersion in-plane of single QW. As in the QW the one-dimensional potential set up the 1D confinement, is important doesn't confuse which the QW is a 2D structure, but their confinement is along of $z$ direction  this mean 1D. Then, the particle can motion in the $x-y$ plane. By this reason, even if consider 3D Schrödinger equation and  the above is considered it obtain \Cref{eq:chapter-1-ema-schroedinger}
therefore, the solutions in the one-dimensional potential produce discrete states of energy $E_{z}=E_{n}$\cite{harrison2016quantum}, where $n$ is the energy level it which produce  subbands as shows in \Cref{fig:subsection-1.2-single-quantum-well-scheme2}. In contrast, before it called as ``energy bands'' in the bulk case, now due to the quantum confinement gets subbands to both conduction- and valence bands.

These subbands are the result of the sum of $E_{z}$ and $E_{x,y}$, which are the 1D confinement energy and the in-plane momentum $k_{x,y}$ then\cite{harrison2016quantum}:
\begin{equation}\label{eqn:chapter-1-total-enery-ema-aprox}
	E = E_{n} + \dfrac{\hbar^{2}|\boldsymbol{k}_{x,y}|^{2}}{2m^{*}}.
\end{equation}
From equation the effective mass  $m^*$ depends on particle, i.e the effective mass to electrons in CB and the holes in VB. So, the most relevant in the solutions is the energy $E_{n}$ (\Cref{subfig:subsection-1.2-single-quantum-well-scheme2-a)})  is discrete, this is the quantum confinement in the low-dimensional heterostructures.

\section{Summary}
\vspace{-10mm}
In this chapter, was exposed the generalities of semiconductor band structure and low-dimensional heterostructures, highlighting or taking in major GaAs/\algaas that's the semiconductors of major importance in this work.
The band structure interpretation  usually be so hard, and their calculations even more, but the impact and relevance in optical properties of semiconductors starts from that interpretation, from here arises the mathematical arsenal to right physical interpretation. Another significant concept which was treatment as first approach is the effective mass concept, even if, when solved, the bulk Hamiltonian it considers the mass as constant parameter or depending on semiconductor material, contrary  in low-dimensional structures have an important role.  \\*

In generally, the band structure of semiconductors is the key to understand quantum properties of solids, in this work the  relevant is the light-matter. Remember that light-mater interaction in solids can be studied by process resulting in it, as absorption, reflection, transmission, diffraction, scattering, and others\cite{rivera2020light}.  Although, the light-matter interactions are fundamentally  quantum electrodynamical, also, can be studied in quantum way through before mentioned process. Firstly, is the photon absorption process can help to understand or calculate the fundamental parameter in semiconductors as is bandgap energy.
This parameter is the started point in the study of semiconductors, this is the start point in the map called bandstructure, if it ignores the gap value in the semiconductor to study it couldn't possibly get the principal optical properties of that. \\*
Then, the bandstructure of semiconductors is the map to understand them, without these routes or fundamental parameters couldn't have quantum devices.