Skip to content

Commit

Permalink
Rename ∑ᵐᵛ -> ∑ (#304)
Browse files Browse the repository at this point in the history
Addresses one item of #282
  • Loading branch information
williamdemeo authored Nov 15, 2023
1 parent 60f3638 commit f6958f8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/Axiom/Set/Sum.agda
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ module _ ⦃ _ : DecEq A ⦄ ⦃ _ : DecEq B ⦄ where
indexedSumᵐ : (A × B Carrier) FinMap A B Carrier
indexedSumᵐ f (m , _ , h) = indexedSum f (m , h)

indexedSumᵐᵛ : (B Carrier) FinMap A B Carrier
indexedSumᵐᵛ f = indexedSumᵐ (f ∘ proj₂)
indexedSumᵛ : (B Carrier) FinMap A B Carrier
indexedSumᵛ f = indexedSumᵐ (f ∘ proj₂)

indexedSumᵐ-cong : {f : A × B Carrier}
indexedSumᵐ f Preserves (_≡ᵉ_ on proj₁) ⟶ _≈_
Expand Down Expand Up @@ -156,5 +156,5 @@ module _ ⦃ _ : DecEq A ⦄ ⦃ _ : DecEq B ⦄ where
helper : toRel m ≡ᵉ toRel (m₁ ∪ˡᶠ m₂)
helper = ≡ᵉ.trans (proj₁ m≡m₁∪m₂) (≡ᵉ.sym $ disjoint-∪ˡ-∪ disj-dom')

syntax indexedSumᵐ (λ a x) m = ∑ᵐ[ a m ] x
syntax indexedSumᵐᵛ (λ a x) m =ᵐᵛ[ a m ] x
-- syntax indexedSumᵐ (λ a → x) m = ∑ᵐ[ a ← m ] x -- (not used; leave for now?)
syntax indexedSumᵛ (λ a x) m = ∑[ a m ] x
2 changes: 1 addition & 1 deletion src/Ledger/Chain.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ data _⊢_⇀⦇_,NEWEPOCH⦈_ : NewEpochEnv → NewEpochState → Epoch → New
open Acnt acnt

trWithdrawals = esW .EnactState.withdrawals
totWithdrawals = ∑ᵐᵛ[ x ← trWithdrawals ᶠᵐ ] x
totWithdrawals = ∑[ x ← trWithdrawals ᶠᵐ ] x

removedGovActions = flip concatMapˢ removed λ (gaid , gaSt) →
mapˢ (GovActionState.returnAddr gaSt ,_)
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger/GovernanceActions.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ data _⊢_⇀⦇_,ENACT⦈_ : EnactEnv → EnactState → GovAction → EnactSta
record s { pparams = applyUpdate (s .pparams .proj₁) up , gid }

Enact-Wdrl : let newWdrls = s .withdrawals ∪⁺ wdrl in
ᵐᵛ[ x ← newWdrls ᶠᵐ ] x ≤ t
∑[ x ← newWdrls ᶠᵐ ] x ≤ t
───────────────────────────────────────
⟦ gid , t , e ⟧ᵉ ⊢ s ⇀⦇ TreasuryWdrl wdrl ,ENACT⦈
record s { withdrawals = newWdrls }
Expand Down
4 changes: 2 additions & 2 deletions src/Ledger/GovernanceActions/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ instance
(ChangePParams up) just (-, Enact-PParams)
Info just (-, Enact-Info)
(TreasuryWdrl wdrl)
case ¿ ∑ᵐᵛ[ x (s .withdrawals ∪⁺ wdrl) ᶠᵐ ] x ≤ t ¿ of λ where
case ¿ ∑[ x (s .withdrawals ∪⁺ wdrl) ᶠᵐ ] x ≤ t ¿ of λ where
(yes p) just (-, Enact-Wdrl p)
(no _) nothing
Computational-ENACT .completeness ⟦ _ , t , e ⟧ᵉ s action _ p
Expand All @@ -46,5 +46,5 @@ instance
... | .ChangePParams up | Enact-PParams = refl
... | .Info | Enact-Info = refl
... | .TreasuryWdrl wdrl | Enact-Wdrl p
rewrite dec-yes (¿ (∑ᵐᵛ[ x (s .withdrawals ∪⁺ wdrl) ᶠᵐ ] x) ≤ t ¿) p .proj₂
rewrite dec-yes (¿ (∑[ x (s .withdrawals ∪⁺ wdrl) ᶠᵐ ] x) ≤ t ¿) p .proj₂
= refl
18 changes: 9 additions & 9 deletions src/Ledger/Ratify.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,24 @@ mostStakeDRepDist-0 = (proj₂ ∘ Equivalence.from ∈-filter)

-- TODO: maybe this can be proven easier with the maximum?
mostStakeDRepDist-∅ : ∀ {dist} → ∃[ N ] mostStakeDRepDist dist N ˢ ≡ᵉ ∅
mostStakeDRepDist-∅ {dist} = suc (∑ᵐᵛ[ x ← dist ᶠᵐ ] x) , Properties.∅-least
mostStakeDRepDist-∅ {dist} = suc (∑[ x ← dist ᶠᵐ ] x) , Properties.∅-least
(⊥-elim ∘ uncurry helper ∘ Equivalence.from ∈-filter)
where
open ≤-Reasoning

helper : ∀ {k v} → v > ∑ᵐᵛ[ x ← dist ᶠᵐ ] x → (k , v) ∉ dist
helper : ∀ {k v} → v > ∑[ x ← dist ᶠᵐ ] x → (k , v) ∉ dist
helper {k} {v} v>sum kv∈dist = 1+n≰n $ begin-strict
v
≡˘⟨ indexedSum-singleton' $ finiteness ❴ k , v ❵ ⟩
ᵐᵛ[ x ← ❴ k , v ❵ᵐ ᶠᵐ ] x
∑[ x ← ❴ k , v ❵ᵐ ᶠᵐ ] x
≡˘⟨ indexedSumᵐ-cong {x = (dist ∣ ❴ k ❵) ᶠᵐ} {y = ❴ k , v ❵ᵐ ᶠᵐ}
$ res-singleton' {m = dist} kv∈dist ⟩
ᵐᵛ[ x ← (dist ∣ ❴ k ❵) ᶠᵐ ] x
∑[ x ← (dist ∣ ❴ k ❵) ᶠᵐ ] x
≤⟨ m≤m+n _ _ ⟩
ᵐᵛ[ x ← (dist ∣ ❴ k ❵) ᶠᵐ ] x +ℕ ∑ᵐᵛ[ x ← (dist ∣ ❴ k ❵ ᶜ) ᶠᵐ ] x
∑[ x ← (dist ∣ ❴ k ❵) ᶠᵐ ] x +ℕ ∑[ x ← (dist ∣ ❴ k ❵ ᶜ) ᶠᵐ ] x
≡˘⟨ indexedSumᵐ-partition {m = dist ᶠᵐ} {(dist ∣ ❴ k ❵) ᶠᵐ} {(dist ∣ ❴ k ❵ ᶜ) ᶠᵐ}
$ res-ex-disj-∪ Properties.Dec-∈-singleton ⟩
ᵐᵛ[ x ← dist ᶠᵐ ] x
∑[ x ← dist ᶠᵐ ] x
<⟨ v>sum ⟩
v ∎

Expand Down Expand Up @@ -344,7 +344,7 @@ abstract
-- unused, keep until we know for sure that there'll be no minimum AVS
-- activeVotingStake : ℙ VDeleg → StakeDistrs → (VDeleg ⇀ Vote) → Coin
-- activeVotingStake cc dists votes =
-- ∑ᵐᵛ[ x ← getStakeDist DRep cc dists ∣ dom votes ᶜ ᶠᵐ ] x
-- ∑[ x ← getStakeDist DRep cc dists ∣ dom votes ᶜ ᶠᵐ ] x

-- TODO: explain this notation in the prose and it's purpose:
-- if there's no stake, accept only if threshold is zero
Expand All @@ -362,8 +362,8 @@ abstract
acceptedStakeRatio r cc dists votes = acceptedStake /₀ totalStake
where
acceptedStake totalStake : Coin
acceptedStake = ∑ᵐᵛ[ x ← (getStakeDist r cc dists ∣ votedYesHashes votes r) ᶠᵐ ] x
totalStake = ∑ᵐᵛ[ x ← getStakeDist r cc dists ∣ votedAbstainHashes votes r ᶜ ᶠᵐ ] x
acceptedStake = ∑[ x ← (getStakeDist r cc dists ∣ votedYesHashes votes r) ᶠᵐ ] x
totalStake = ∑[ x ← getStakeDist r cc dists ∣ votedAbstainHashes votes r ᶜ ᶠᵐ ] x

acceptedBy : RatifyEnv → EnactState → GovActionState → GovRole → Set
acceptedBy Γ (record { cc = cc , _; pparams = pparams , _ }) gs role =
Expand Down
4 changes: 2 additions & 2 deletions src/Ledger/Utxo.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ instance
_ = ExUnit-CommutativeMonoid

HasCoin-Map : ∀ {A} → ⦃ DecEq A ⦄ → HasCoin (A ⇀ Coin)
HasCoin-Map .getCoin s = indexedSumᵐᵛ ⦃ +-0-commutativeMonoid ⦄ id (s ᶠᵐ)
HasCoin-Map .getCoin s = indexedSumᵛ ⦃ +-0-commutativeMonoid ⦄ id (s ᶠᵐ)

isPhaseTwoScriptAddress : Tx → Addr → Bool
isPhaseTwoScriptAddress tx a
Expand Down Expand Up @@ -79,7 +79,7 @@ module _ (let open Tx; open TxBody) where
outs tx = mapKeys (tx .txid ,_) (tx .txouts)

balance : UTxO → Value
balance utxo = indexedSumᵐᵛ ⦃ Value-CommutativeMonoid ⦄ getValue (utxo ᶠᵐ)
balance utxo = indexedSumᵛ ⦃ Value-CommutativeMonoid ⦄ getValue (utxo ᶠᵐ)

cbalance : UTxO → Coin
cbalance utxo = coin (balance utxo)
Expand Down

0 comments on commit f6958f8

Please sign in to comment.