Skip to content

Commit

Permalink
Rename ∅ᵐ → ∅ (#305)
Browse files Browse the repository at this point in the history
* Rename  ∅ᵐ → ∅

Addresses one item of #282

* rename empty set using typeclasses

---------

Co-authored-by: Andre Knispel <andre.knispel@gmx.de>
  • Loading branch information
williamdemeo and WhatisRT authored Nov 17, 2023
1 parent cf73110 commit eafd83a
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 19 deletions.
21 changes: 21 additions & 0 deletions src/Interface/HasEmptySet.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# OPTIONS --safe #-}

open import Axiom.Set using (Theory)

module Interface.HasEmptySet (th : Theory) where

open Theory th renaming (Set to ℙ_; ∅ to ∅ˢ)
open import Axiom.Set.Map th

record HasEmptySet (A : Set) : Set where
field
: A

instance
HasEmptySet-Set : {A : Set} HasEmptySet (ℙ A)
HasEmptySet-Set = record { ∅ = ∅ˢ }

HasEmptySet-Map : {A B : Set} HasEmptySet (Map A B)
HasEmptySet-Map = record { ∅ = ∅ᵐ }

open HasEmptySet ⦃...⦄ public
8 changes: 4 additions & 4 deletions src/Ledger/Chain.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ data _⊢_⇀⦇_,NEWEPOCH⦈_ : NewEpochEnv → NewEpochState → Epoch → New
((deposits ∣ ❴ GovActionDeposit gaid ❵) ˢ)
govActionReturns = aggregate₊ $ mapˢ (λ (a , _ , d) → a , d) removedGovActions ᶠˢ

es = record esW { withdrawals = ∅ }
es = record esW { withdrawals = ∅ }
retired = retiring ⁻¹ e
refunds = govActionReturns ∪⁺ trWithdrawals ∣ dom rewards
unclaimed = govActionReturns ∪⁺ trWithdrawals ∣ dom rewards ᶜ
Expand Down Expand Up @@ -150,7 +150,7 @@ govActionDeposits : LState → VDeleg ⇀ Coin
govActionDeposits ls =
let open LState ls; open CertState certState; open PState pState
open UTxOState utxoSt; open DState dState
in foldl _∪⁺_ ∅ $ setToList $
in foldl _∪⁺_ ∅ $ setToList $
mapPartial
(λ where (gaid , record { returnAddr = record {stake = c} }) → do
vd ← lookupᵐ? voteDelegs c ⦃ _ ∈? _ ⦄
Expand All @@ -162,8 +162,8 @@ calculateStakeDistrs : LState → StakeDistrs
calculateStakeDistrs ls =
let open LState ls; open CertState certState; open PState pState
open UTxOState utxoSt; open DState dState
spoDelegs = ∅ -- TODO
drepDelegs = ∅ -- TODO
spoDelegs = ∅ -- TODO
drepDelegs = ∅ -- TODO
in
record
{ stakeDistr = govActionDeposits ls
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/Chain/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module _ {Γ : NewEpochEnv} {nes : NewEpochState} {e : Epoch} where
open NewEpochState nes hiding (es)
open RatifyState fut using (removed) renaming (es to esW)
open LState ls; open CertState certState; open Acnt acnt
es = record esW { withdrawals = }
es = record esW { withdrawals = ∅ }
govSt' = filter (λ x ¿ ¬ proj₁ x ∈ mapˢ proj₁ removed ¿) govSt

NEWEPOCH-total : ∃[ nes' ] Γ ⊢ nes ⇀⦇ e ,NEWEPOCH⦈ nes'
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/Deleg.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Ledger.Deleg (gs : _) (open GovStructure gs) where

open import Ledger.GovernanceActions gs
\end{code}
\begin{figure*}[h]
\begin{figure*}[h!]
\begin{code}
record PoolParams : Set where
field rewardAddr : Credential
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/Foreign/HSLedger.agda
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ instance
; mint = ε -- tokenAlgebra only contains ada atm, so mint is surely empty
; txfee = txfee
; txvldt = from txvldt
; txwdrls =
; txwdrls =
; txup = nothing
; txADhash = nothing
; netwrk = nothing
Expand Down
3 changes: 1 addition & 2 deletions src/Ledger/Gov.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ addAction : GovState
→ Epoch → GovActionID → RwdAddr → (a : GovAction) → NeedsHash a
→ GovState
addAction s e aid addr a prev = s ∷ʳ (aid , record
{ votes = ∅ᵐ ; returnAddr = addr ; expiresIn = e ; action = a ; prevAction = prev })

{ votes = ∅ ; returnAddr = addr ; expiresIn = e ; action = a ; prevAction = prev })
\end{code}
\caption{Types and functions used in the GOV transition system\protect\footnotemark}
\label{defs:gov-defs}
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/GovernanceActions.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ data _⊢_⇀⦇_,ENACT⦈_ : EnactEnv → EnactState → GovAction → EnactSta
⟦ gid , t , e ⟧ᵉ ⊢ s ⇀⦇ NoConfidence ,ENACT⦈
record s { cc = nothing , gid }

Enact-NewComm : let old = maybe proj₁ ∅ (s .EnactState.cc .proj₁)
Enact-NewComm : let old = maybe proj₁ ∅ (s .EnactState.cc .proj₁)
maxTerm = s .pparams .proj₁ .PParams.ccMaxTermLength +ᵉ e
in
∀[ term ∈ range new ] term ≤ maxTerm
Expand Down
4 changes: 2 additions & 2 deletions src/Ledger/NewPP.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ record NewPParamState : Set where
updatePPUp : PParams → PPUpdateState → PPUpdateState
updatePPUp pparams record { fpup = fpup }
with allᵇ (isViableUpdate? pparams) (range fpup)
... | false = record { pup = ∅ ; fpup = ∅ }
... | true = record { pup = fpup ; fpup = ∅ }
... | false = record { pup = ∅ ; fpup = ∅ }
... | true = record { pup = fpup ; fpup = ∅ }

votedValue : ProposedPPUpdates → PParams → ℕ → Maybe PParamsUpdate
votedValue pup pparams quorum =
Expand Down
3 changes: 2 additions & 1 deletion src/Ledger/Prelude.agda
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ open import Tactic.DeriveComp public
open import Tactic.Premises public

open import Ledger.Interface.HasCoin public
open import Ledger.Set public
open import Ledger.Set renaming (∅ to ∅ˢ) public
open import Interface.HasEmptySet th public
2 changes: 1 addition & 1 deletion src/Ledger/Ratify.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ actualVotes Γ pparams cc ga votes = mapKeys (credVoter CC) (actualCCVotes cc
_ → Vote.abstain -- expired, no hot key or resigned

actualCCVotes : CCData → Credential ⇀ Vote
actualCCVotes nothing = ∅
actualCCVotes nothing = ∅
actualCCVotes (just (cc , q)) = ifᵈ (ccMinSize ≤ lengthˢ (activeCC $ just (cc , q)))
then mapWithKey actualCCVote cc
else constMap (dom cc) Vote.no
Expand Down
7 changes: 3 additions & 4 deletions src/Ledger/Transaction.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,14 @@ the transaction body are:
wits : TxWitnesses
-- isValid : Bool
txAD : Maybe AuxiliaryData

\end{code}
\emph{Abstract functions}
\begin{code}
\end{code}
\end{AgdaSuppressSpace}
\caption{Definitions used in the UTxO transition system}
\label{fig:defs:utxo-shelley}
\end{figure*}

\begin{figure*}[h]
\emph{Abstract functions}
\begin{code}
getValue : TxOut → Value
getValue (_ , v , _) = v
Expand All @@ -187,6 +184,8 @@ the transaction body are:
isP2Script : Script → Bool
isP2Script = is-just ∘ isInj₂
\end{code}
\caption{Definitions used in the UTxO transition system, continued}
\label{fig:defs:utxo-shelley-cont}
\end{figure*}
\begin{code}[hide]
instance
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/Utxo.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module _ (let open Tx; open TxBody) where
certDepositᵐ : PParams → DCert → DepositPurpose ⇀ Coin
certDepositᵐ pp cert = case certDeposit pp cert of λ where
(just (p , v)) → ❴ p , v ❵ᵐ
nothing → ∅
nothing → ∅

propDepositᵐ : PParams → GovActionID → GovProposal → DepositPurpose ⇀ Coin
propDepositᵐ pp gaid record { returnAddr = record { stake = c } }
Expand Down

0 comments on commit eafd83a

Please sign in to comment.