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

652 remove superscripts from rec constr #655

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

carlostome
Copy link
Contributor

@carlostome carlostome commented Jan 29, 2025

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Any semantic changes to the specifications are documented in CHANGELOG.md
  • Code is formatted according to CONTRIBUTING.md
  • Self-reviewed the diff

@carlostome carlostome linked an issue Jan 29, 2025 that may be closed by this pull request
@carlostome carlostome force-pushed the 652-remove-superscripts-from-rec-constr branch from c56a925 to b08b87f Compare January 29, 2025 10:49
@carlostome
Copy link
Contributor Author

This is currently blocked by #653

@carlostome carlostome force-pushed the 652-remove-superscripts-from-rec-constr branch from 675be19 to ef77a0e Compare January 31, 2025 09:54
@carlostome carlostome self-assigned this Feb 3, 2025
@carlostome carlostome force-pushed the 652-remove-superscripts-from-rec-constr branch from 8c1cc29 to f5a6fb8 Compare February 3, 2025 16:46
@carlostome carlostome force-pushed the 652-remove-superscripts-from-rec-constr branch from e9c13f9 to 8b8148e Compare February 5, 2025 12:26
@carlostome

This comment was marked as outdated.

@carlostome
Copy link
Contributor Author

carlostome commented Feb 5, 2025

We need to decide what the name for To (previously ToRecord) should be and where to put the definition.

Copy link
Collaborator

@williamdemeo williamdemeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few observations/questions/suggestions, mainly about whether we should also remove superscripts on constructors in conformance modules.

field
Δt Δr Δf : ℤ
rs : Credential ⇀ Coin
\end{code}
\begin{code}[hide]
-- more convient here than doing checks
{zeroSum} : Δt + Δr + Δf + ℤ.+ ∑[ x ← rs ] x ≡ ℤ.0ℤ
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this {zeroSum} line was included in the first place, so I'm not sure why it can be removed. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure either why the field is there. Nothing seems to break if I simply remove it.

@WhatisRT, do you know the purpose of this field?

Copy link
Collaborator

@WhatisRT WhatisRT Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's going to be relevant for the preservation of ada proof. RewardUpdate is constructed at some point during the epoch and then applied (see applyRUpd) at the epoch boundary (this is something we could potentially change in the future, because IIRC this is purely done for performance reasons, but that's another topic). When we apply the RewardUpdate the amount of ada in the system changes by this sum, which is why we need it to be zero. So I think there are only two options to deal with this:

  • weaken the statement to something like 'ada is preserved if the RewardUpdate was correctly constructed', or
  • just do it correct-by-construction as is done here.

We usually don't do correct-by-construction in our data for various reasons (e.g. it makes translation for conformance tests more difficult), but here it seemed like a good choice because it disturbs very little and we actually get a stronger property in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest for now removing this (having a hidden field complicates things in using the uniform constructor approach), and when (and if) needed it we put it back.

b c : Bool

instance
unquoteDecl To-R'' = derive-To ⦃ defaultTCOptions ⦄ ((quote R'' , To-R'') ∷ [])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still trying to understand how the metaprogramming logic works, so I won't comment on this part of the PR.

src/Ledger/Certs.lagda Show resolved Hide resolved
src/Ledger/Certs/Properties.agda Show resolved Hide resolved
@@ -148,7 +149,7 @@ instance
ledger' : Γ C.⊢ (getCertDeps* cdeposits ⊢conv s) ⇀⦇ tx ,LEDGER⦈ C.⟦ utxoStC' , govSt' , certStateC' ⟧ˡ
ledger' = C.LEDGER-V⋯ refl utxow' certs' gov'
utxoEq : utxoStC' ≡ utxoSt'
utxoEq = cong (λ • → L.⟦ _ , _ , • , _ ⟧)
utxoEq = cong (λ • → ⟦ _ , _ , • , _ ⟧)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised you can remove both the superscript and the L. here. 🤔 I suppose I should try to understand the metaprogramming you did to see why this works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about an instance of To for RewardsUpdate being in scope.

src/Ledger/Conway/Conformance/Certs.agda Outdated Show resolved Hide resolved
src/Ledger/Conway/Conformance/Certs.agda Outdated Show resolved Hide resolved
src/Ledger/Conway/Conformance/Certs.agda Outdated Show resolved Hide resolved
src/Ledger/Conway/Conformance/Certs.agda Outdated Show resolved Hide resolved
src/Ledger/Conway/Conformance/Epoch.agda Outdated Show resolved Hide resolved
@carlostome carlostome marked this pull request as ready for review February 6, 2025 12:32
src/Class/To.agda Outdated Show resolved Hide resolved
src/Class/To.agda Outdated Show resolved Hide resolved
Copy link
Collaborator

@WhatisRT WhatisRT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this, but it's a shame that we're losing some of the patterns here. I think some of them should be resurrected. Here's the most obvious place where things got worse. Before:
Screenshot 2025-02-06 at 14 40 52

After:
Screenshot 2025-02-06 at 14 40 24

Obviously this has other issues as well, but in the before it's really easy to see what changed and maybe more crucially what didn't change (and that e.g. the reserves and treasury didn't get swapped), and in the after this is completely gone (and just adding the vertical vectors back in isn't going to fix it). There are a few other places such as UTXOW.

It's a shame that it's not quite as powerful as Lean's ⟨ ⟩ which also functions as a pattern on the LHS, but there probably isn't much we can do about that. I think in the above cases, it would be good to keep the patterns around just to render those more nicely.

Maybe it could be a future AIM project to get such record patterns that can be used for matching as well?

src/Class/To.agda Outdated Show resolved Hide resolved
@carlostome
Copy link
Contributor Author

The before/after differences are due to a bug in the agda2vec.py script (see #666) not of this PR really

@WhatisRT
Copy link
Collaborator

WhatisRT commented Feb 6, 2025

If #666 is fixed then it still doesn't resolve the problem. In the before picture, the LHS provides quite a lot of information visually, just by being able to line up matching entries on the RHS. This gets lost completely if the LHS is just applyRUpd ru epochState.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove superscripts from ⟦_,...,_⟧ (probably via a typeclass)
3 participants