Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the generated PDF a lot prettier
- Loading branch information
Showing
15 changed files
with
353 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
tex_files := Introduction.tex BaseTypes.tex TokenAlgebra.tex Crypto.tex Address.tex Script.tex GovernanceActions.tex PParams.tex Transaction.tex Utxo.tex Utxow.tex Tally.tex Deleg.tex Ledger.tex Ratify.tex Chain.tex Utxo/Properties.tex PDF.tex | ||
|
||
tex_files2 := $(addprefix src/latex/Ledger/, $(tex_files)) | ||
|
||
.PHONY: all clean | ||
all: | ||
agda --only-scope-checking --latex src/Ledger.lagda | ||
cd src/latex && xelatex Ledger.tex | ||
cp src/latex/Ledger.pdf . | ||
src/latex/Ledger/%.tex: src/Ledger/%.lagda | ||
cd src && agda --only-scope-checking --latex ../$< | ||
all: $(tex_files2) | ||
cd src/latex && xelatex Ledger/PDF.tex | ||
cp src/latex/PDF.pdf . | ||
clean: | ||
rm -rf src/latex | ||
rm -rf src/MAlonzo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
\section{Base types} | ||
\begin{code}[hide] | ||
module Ledger.BaseTypes where | ||
|
||
open import Prelude using (ℕ) | ||
\end{code} | ||
|
||
|
||
\begin{code}[hide] | ||
private | ||
\end{code} | ||
\begin{figure*}[h] | ||
\begin{code} | ||
Coin = ℕ | ||
Slot = ℕ | ||
Epoch = ℕ | ||
\end{code} | ||
\caption{Some basic types used in many places in the ledger} | ||
\end{figure*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
\section{Introduction} | ||
\begin{code}[hide] | ||
module Ledger.Introduction where | ||
|
||
open import Prelude | ||
\end{code} | ||
|
||
Repository: https://github.com/input-output-hk/formal-ledger-specifications | ||
|
||
\subsection{Separation of concerns} | ||
|
||
The \emph{Cardano Node} consists of three pieces: | ||
|
||
\begin{itemize} | ||
\item Networking layer, which deals with sending messages accross the internet | ||
\item Consensus layer, which establishes a common order of valid blocks | ||
\item Ledger layer, which decides whether a sequence of blocks is valid | ||
\end{itemize} | ||
|
||
Because of this separation, the ledger gets to be a state machine: | ||
\[ s \xrightarrow[X]{b} s' \] | ||
|
||
More generally, we will consider state machines with an environment: | ||
\[ Γ ⊢ s \xrightarrow[X]{b} s' \] | ||
|
||
These are modeled as 4-ary relations between the environment \(Γ\), an | ||
initial state \(s\), a signal \(b\) and a final state \(s'\). The ledger consists of | ||
25-ish (depending on the version) such relations that depend on each | ||
other, forming a directed graph that is almost a tree. | ||
|
||
\subsection{Computational} | ||
|
||
Since all such state machines need to be evaluated by the node and all | ||
nodes should compute the same states, the relations specified by them | ||
should be computable by functions. This is captured by the following | ||
record, which is parametrized over the step relation. | ||
|
||
\begin{code}[hide] | ||
private variable C S Sig : Set | ||
Γ : C | ||
s s' : S | ||
b : Sig | ||
|
||
postulate ℙ_ : Set → Set | ||
_↛_ : Set → Set → Set | ||
_∈_ : ∀ {A : Set} → A → ℙ A → Set | ||
\end{code} | ||
\begin{figure*}[h] | ||
\begin{code} | ||
record Computational (_⊢_⇀⦇_,X⦈_ : C → S → Sig → S → Set) : Set where | ||
field | ||
compute : C → S → Sig → Maybe S | ||
≡-just⇔STS : compute Γ s b ≡ just s' ⇔ Γ ⊢ s ⇀⦇ b ,X⦈ s' | ||
\end{code} | ||
\end{figure*} | ||
|
||
\subsection{Sets \& maps} | ||
|
||
The ledger heavily uses set theory. For various reasons it was | ||
necessary to implement our own set theory (there'll be a paper on this | ||
some time in the future). Crucially, the set theory is completely | ||
abstract (in a technical sense - Agda has an abstract keyword) meaning | ||
that implementation details of the set theory are | ||
irrelevant. Additionally, all sets in this specification are finite. | ||
|
||
We use this set theory to define maps as seen below, which are used in | ||
many places. We usually think of maps as partial functions | ||
(i.e. functions not defined everywhere), but importantly they are not | ||
Agda functions. | ||
|
||
\begin{figure*}[h] | ||
\begin{code} | ||
_⊆_ : {A : Set} → ℙ A → ℙ A → Set | ||
X ⊆ Y = ∀ {x} → x ∈ X → x ∈ Y | ||
|
||
_≡ᵉ_ : {A : Set} → ℙ A → ℙ A → Set | ||
X ≡ᵉ Y = X ⊆ Y × Y ⊆ X | ||
|
||
Rel : Set → Set → Set | ||
Rel A B = ℙ (A × B) | ||
|
||
left-unique : {A B : Set} → Rel A B → Set | ||
left-unique R = ∀ {a b b'} → (a , b) ∈ R → (a , b') ∈ R → b ≡ b' | ||
|
||
Map : Set → Set → Set | ||
Map A B = Σ (Rel A B) left-unique | ||
\end{code} | ||
\end{figure*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.