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

agda2vec introduces extra empty lines #666

Merged
merged 11 commits into from
Feb 18, 2025

Conversation

williamdemeo
Copy link
Collaborator

@williamdemeo williamdemeo commented Jan 31, 2025

Description

This closes issue #653.

(It may be as simple as removing the extra new line character + \n from the file.write line in the write_file function.)

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

This closes issue #653.

(It may be as simple as removing the extra new line character `+ \n` from the `file.write` line in the `write_file` function.)
@williamdemeo williamdemeo linked an issue Jan 31, 2025 that may be closed by this pull request
@williamdemeo williamdemeo force-pushed the 653-agda2vec-introduces-extra-empty-lines branch from 04e613c to ff11336 Compare January 31, 2025 15:29
@williamdemeo williamdemeo self-assigned this Feb 3, 2025
@@ -113,7 +113,7 @@ rec {
version = "0.1";
src = "${formalLedger}";
meta = { };
buildInputs = [ agdaWithDeps latex python3 ];
buildInputs = [ agdaWithDeps latex python310 ];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So we can use the List type annotation and type aliases in agda2vec.py:

from typing import List, TypeAlias
StrVec: TypeAlias = List[str]

Comment on lines +552 to +562
data _⊢_⇀⦇_,RATIFY'⦈_ :
RatifyEnv → RatifyState → GovActionID × GovActionState → RatifyState → Type where

RATIFY-Accept : {Γ : RatifyEnv}
{es es' : EnactState}
{removed : ℙ (GovActionID × GovActionState)}
{d : Bool}
{a : GovActionID × GovActionState}

→ let open RatifyEnv Γ; st = a .proj₂; open GovActionState st in

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes the code more transparent and much easier to understand, imo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that making the bindings' type explicit makes it easier to understand the rule.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment on lines 566 to 567
Γ ⊢ ⟦ es , removed , d ⟧ʳ ⇀⦇ a ,RATIFY'⦈
⟦ es' , ❴ a ❵ ∪ removed , delayingAction action ⟧ʳ
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No need for the extra indentation/whitespace since we're not relying on agda to handle alignment here.

@williamdemeo williamdemeo force-pushed the 653-agda2vec-introduces-extra-empty-lines branch from 280be9e to d50868a Compare February 14, 2025 14:44
plus changes `Ratify.lagda`: experiments to improve layout of Fig 54 of cardano-ledger.pdf
@williamdemeo williamdemeo force-pushed the 653-agda2vec-introduces-extra-empty-lines branch from d50868a to 9533584 Compare February 14, 2025 14:48
@williamdemeo williamdemeo marked this pull request as ready for review February 14, 2025 14:48
Copy link
Contributor

@carlostome carlostome left a comment

Choose a reason for hiding this comment

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

LGTM.

There seems to be a small aligning glitch, which was already present before, in that sometimes lines containing vertical vectors aren't aligned with their surroundings. For example, see Ratify-Continue and Ratify-Reject in Figure 44.

Comment on lines +552 to +562
data _⊢_⇀⦇_,RATIFY'⦈_ :
RatifyEnv → RatifyState → GovActionID × GovActionState → RatifyState → Type where

RATIFY-Accept : {Γ : RatifyEnv}
{es es' : EnactState}
{removed : ℙ (GovActionID × GovActionState)}
{d : Bool}
{a : GovActionID × GovActionState}

→ let open RatifyEnv Γ; st = a .proj₂; open GovActionState st in

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that making the bindings' type explicit makes it easier to understand the rule.

Comment on lines +552 to +562
data _⊢_⇀⦇_,RATIFY'⦈_ :
RatifyEnv → RatifyState → GovActionID × GovActionState → RatifyState → Type where

RATIFY-Accept : {Γ : RatifyEnv}
{es es' : EnactState}
{removed : ℙ (GovActionID × GovActionState)}
{d : Bool}
{a : GovActionID × GovActionState}

→ let open RatifyEnv Γ; st = a .proj₂; open GovActionState st in

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@williamdemeo
Copy link
Collaborator Author

LGTM.

There seems to be a small aligning glitch, which was already present before, in that sometimes lines containing vertical vectors aren't aligned with their surroundings. For example, see Ratify-Continue and Ratify-Reject in Figure 44.

You're absolutely right. I'm not sure how hard this would be to fix, but it would surely involve making the script more sophisticated (or, rather, less dumb). Right now agda2vec throws away some alignment information (in the form of the Agda generated escape sequences, like \>[981I][@{}l@{\AgdaIndent{0}}]). Perhaps the next improvement to the script should be to actually try to make use of these alignment macros.

@williamdemeo williamdemeo merged commit fd4d0b9 into master Feb 18, 2025
8 checks passed
@williamdemeo williamdemeo deleted the 653-agda2vec-introduces-extra-empty-lines branch February 18, 2025 14:01
github-actions bot added a commit that referenced this pull request Feb 18, 2025
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.

agda2vec introduces extra empty lines
2 participants