Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other PDF cleanup items: Fig 5 (Token algebras) #298

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/Ledger/Address.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ Addr = BaseAddr ⊎ BootstrapAddr
VKeyAddr = VKeyBaseAddr ⊎ VKeyBootstrapAddr
ScriptAddr = ScriptBaseAddr ⊎ ScriptBootstrapAddr
\end{code}
\end{AgdaSuppressSpace}
\end{AgdaAlign}
\caption{Definitions used in Addresses}
\label{fig:defs:addresses}
\end{figure*}
\begin{figure*}[h!]
\begin{AgdaAlign}
\end{AgdaSuppressSpace} \\
\emph{Helper functions}
\AgdaTarget{payCred, isVKeyAddr}
\begin{code}
Expand All @@ -88,8 +82,8 @@ isScriptAddr = isScript ∘ payCred
isScriptRwdAddr = isScript ∘ RwdAddr.stake
\end{code}
\end{AgdaAlign}
\caption{Definitions used in Addresses, continued}
\label{fig:defs:addresses-cont}
\caption{Definitions used in Addresses}
\label{fig:defs:addresses}
\end{figure*}
\begin{code}[hide]
payCred (inj₁ record {pay = pay}) = pay
Expand Down
23 changes: 18 additions & 5 deletions src/Ledger/TokenAlgebra.lagda
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
\section{Token algebras}
\label{sec:token-algebra}

\begin{figure*}[h]
\begin{AgdaAlign}
\begin{code}[hide]
{-# OPTIONS --safe #-}

module Ledger.TokenAlgebra (PolicyId : Set) where

module Ledger.TokenAlgebra (
\end{code}
\emph{Abstract types}
\begin{code}
PolicyId
\end{code}
\begin{code}[hide]
: Set) where
open import Ledger.Prelude

open import Algebra using (CommutativeMonoid ; Monoid)
Expand All @@ -14,14 +21,16 @@ open import Data.Nat.Properties using (+-0-monoid)
open import Relation.Binary using (Rel)
open import Relation.Unary using (Pred)
\end{code}

\begin{figure*}
\emph{Derived types}
\AgdaTarget{TokenAlgebra}
\begin{AgdaSuppressSpace}
\begin{code}
record TokenAlgebra : Set₁ where
field Value-CommutativeMonoid : CommutativeMonoid 0ℓ 0ℓ

MemoryEstimate : Set
MemoryEstimate = ℕ

\end{code}
\begin{code}[hide]
open CommutativeMonoid Value-CommutativeMonoid public
Expand All @@ -41,6 +50,7 @@ record TokenAlgebra : Set₁ where
property : coin ∘ inject ≗ id
coinIsMonoidHomomorphism : IsMonoidHomomorphism coin
\end{code}
\end{AgdaSuppressSpace}
\begin{code}[hide]
⦃ DecEq-Value ⦄ : DecEq Value
⦃ Dec-≤ᵗ ⦄ : ∀ {v v′} → Dec (v ≤ᵗ v′)
Expand All @@ -49,9 +59,12 @@ record TokenAlgebra : Set₁ where
addValue : HasAdd Value
addValue = record { _+_ = _+ᵛ_ }
\end{code}
\emph{Helper functions}
\AgdaTarget{sumᵛ}
\begin{code}
sumᵛ : List Value → Value
sumᵛ = foldr _+ᵛ_ (inject 0)
\end{code}
\end{AgdaAlign}
\caption{Token algebras, used for multi-assets}
\end{figure*}