Skip to content

Conversation

@carlostome
Copy link
Collaborator

@carlostome carlostome commented Oct 3, 2025

Description

First step towards addressing #929.

Blocked by input-output-hk/agda-sets#16

There are a couple of postulates at the beginning of the file that should be taken as assumptions of the EpochStructure type (discuss in meeting)

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 force-pushed the bisimulation-expired-dreps branch from 185e3ef to c242176 Compare October 14, 2025 13:05
@carlostome carlostome changed the title WIP: prove that EPOCH not depends on expired dreps Prove that EPOCH not depends on expired dreps Oct 14, 2025
@carlostome carlostome force-pushed the bisimulation-expired-dreps branch 4 times, most recently from 850ff61 to 6c43c81 Compare October 16, 2025 07:49
@carlostome carlostome marked this pull request as ready for review October 16, 2025 07:49
@carlostome carlostome force-pushed the bisimulation-expired-dreps branch 2 times, most recently from 6c43c81 to d590f39 Compare October 17, 2025 12:03
@carlostome carlostome force-pushed the bisimulation-expired-dreps branch from 5b54a15 to 9b55dfe Compare October 20, 2025 15:53
Copy link
Member

@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.

Looks great! Just some (mostly minor) comments you might find helpful.

Comment on lines 26 to 45
filter-⇒ : (P⇒Q : U.Universal (P U.⇒ Q)) filter sp-P (filter sp-Q X) ≡ᵉ filter sp-P X
filter-⇒ P⇒Q = filter-⇒-⊆ , filter-⇒-⊇
where
filter-⇒-⊆ : filter sp-P (filter sp-Q X) ⊆ filter sp-P X
filter-⇒-⊆ p with from ∈-filter p
... | (q , p) with from ∈-filter p
... | (_ , p) = to ∈-filter (q , p)

filter-⇒-⊇ : filter sp-P X ⊆ filter sp-P (filter sp-Q X)
filter-⇒-⊇ p with from ∈-filter p
... | (q , p) = to ∈-filter (q , (to ∈-filter (P⇒Q _ q , p)))

module _ {P : A Type} {sp-P : specProperty P} {Q : B Type} {sp-Q : specProperty Q} where

import Relation.Unary as U

module _ {f : A B} (Qf⇒P : U.Universal ((Q ∘ f) U.⇒ P)) where

filter-map : filter sp-Q (map f X) ≡ᵉ filter sp-Q (map f (filter sp-P X))
filter-map = filter-map-⊆ , filter-map-⊇
Copy link
Member

Choose a reason for hiding this comment

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

I love these theorems and the straight-forward way you prove them---nice work! ...although I'm wondering why the function f and the premise of the filter-map theorem are pulled out as module parameters instead of just making them part of the statement (type signature) of the filter-map theorem.

Comment on lines 4 to 20
open import Data.Bool using (if_then_else_)
open import Data.Nat using (_≤ᵇ_)
open import Data.List using (map)
open import Class.Monad hiding (Monad-TC)
open import Class.MonadTC
hiding (extendContext)
open import Class.MonadError
using (MonadError; MonadError-TC)
open import Class.Show
open import Meta.Prelude
open import Meta.Init public
renaming (TC to TCI)
hiding (Monad-TC; MonadError-TC; toℕ)
hiding (Monad-TC; MonadError-TC)
open import Reflection using (TC; extendContext)

open MonadTC ⦃...⦄
open MonadError ⦃...⦄ using (error; catch)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
open import Data.Nat using (_≤ᵇ_)
open import Data.List using (map)
open import Class.Monad hiding (Monad-TC)
open import Class.MonadTC
hiding (extendContext)
open import Class.MonadError
using (MonadError; MonadError-TC)
open import Class.Show
open import Meta.Prelude
open import Meta.Init public
renaming (TC to TCI)
hiding (Monad-TC; MonadError-TC)
open import Reflection using (TC; extendContext)
open MonadTC ⦃...⦄

Copy link
Member

Choose a reason for hiding this comment

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

Apparently, the following lines can be omitted:

open import Data.Bool using (if_then_else_)

and

open MonadError ⦃...⦄ using (error; catch)

Comment on lines +51 to +52
import Relation.Unary as U
P⇒Q : U.Universal ((λ ((_ , e') : Credential × Epoch) → sucᵉ e ≤ sucᵉ e') U.⇒ (λ (_ , e') → e ≤ e'))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import Relation.Unary as U
P⇒Q : U.Universal ((λ ((_ , e') : Credential × Epoch) → sucᵉ e ≤ sucᵉ e') U.⇒ (λ (_ , e') → e ≤ e'))
P⇒Q : Π[ (λ ((_ , e') : Credential × Epoch) → sucᵉ e ≤ sucᵉ e') ⇒ (λ (_ , e') → e ≤ e') ]

Comment on lines 76 to 78
import Relation.Unary as U
module esp = HasPreorder (EpochStructure.preoEpoch epochStructure)
P⇒Q : U.Universal ((λ ((_ , e') : Credential × Epoch) → sucᵉ e ≤ e') U.⇒ (λ (_ , e') → e ≤ e'))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import Relation.Unary as U
module esp = HasPreorder (EpochStructure.preoEpoch epochStructure)
P⇒Q : U.Universal ((λ ((_ , e') : Credential × Epoch) sucᵉ e ≤ e') U.⇒ (λ (_ , e') e ≤ e'))
module esp = HasPreorder (EpochStructure.preoEpoch epochStructure)
P⇒Q : Π[ (λ ((_ , e') : Credential × Epoch) sucᵉ e ≤ e') ⇒ (λ (_ , e') e ≤ e') ]

Comment on lines +270 to +278
cong
: ∀ {rSt rSt' : RatifyState} (rSt≡rSt' : rSt ≡ rSt') {govSt govSt' : GovState} (govSt≡govSt' : govSt ≡ govSt') {rSt'' rSt''' : RatifyState}
→ Γ ⊢ rSt ⇀⦇ govSt ,RATIFIES⦈ rSt''
→ Γ' ⊢ rSt' ⇀⦇ govSt' ,RATIFIES⦈ rSt'''
→ rSt'' ≡ rSt'''
cong refl refl (BS-base Id-nop) (BS-base Id-nop) = refl
cong refl refl (BS-ind {sig = a} p ps) (BS-ind {sig = a'} q qs)
with RATIFY.cong Γ≈Γ' {a = a} {a' = a'} refl p q
... | refl = cong refl refl ps qs
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit surprised RATIFIES-deterministic isn't used here... I suppose because the gammas are not identical. 🤔

Also, I wonder if some of the cong lemmas should be factored out into their respective Properties modules; e.g., the congs for RATIFY and RATIFIES could go somewhere under Ratify/Properties/.

@@ -0,0 +1,569 @@
{-# OPTIONS --safe #-}
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to make this new file an .lagda.md file?

@carlostome
Copy link
Collaborator Author

Blocked by #964

Copy link
Member

@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.

Awesome. Nice work!! ...before you merge, would you mind converting your new ExpiredDReps.agda file to .lagda.md? Also, while it's fresh in your mind, please add some documentation that states the purpose of the module and explains the property you're proving. 🙏🏼

@carlostome carlostome merged commit e8eac02 into master Oct 29, 2025
12 of 14 checks passed
@carlostome carlostome deleted the bisimulation-expired-dreps branch October 29, 2025 14:10
carlostome added a commit that referenced this pull request Oct 30, 2025
* Update ExpiredDReps.lagda.md
module _ {Γ : EnactEnv} {eSt : EnactState} {ga : GovAction} where
-- TODO: Make this follow from computationalness or viceversa
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just happened to see this PR, we actually have a lemma for this already: computational⇒rightUnique in Interface.ComputationalRelation.

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.

4 participants