Skip to content

Comments

Add work-in-progress Lean formalization#165

Open
daira wants to merge 7 commits intodaira:mainfrom
zodl-inc:lean
Open

Add work-in-progress Lean formalization#165
daira wants to merge 7 commits intodaira:mainfrom
zodl-inc:lean

Conversation

@daira
Copy link
Owner

@daira daira commented Jul 14, 2025

No description provided.

@daira daira added the Crosslink An issue related to the Crosslink construction label Jul 14, 2025
@daira daira force-pushed the lean branch 3 times, most recently from 531bec1 to cb41963 Compare July 14, 2025 02:29
@shielded-nate
Copy link

I hereby volunteer to be a reviewer for this PR with the two big caveats:

  1. My availability is quite uncertain, perhaps no cycles until early 2026.
  2. I don't have Lean experience (some haskell-perspective on dependent types, a smidgen of reading Coq examples like 10 years ago), so my review will likely be full of many basic questions, which might be good for security proofs!

If that schedule doesn't work for this PR, then I'd like to capture my review notes elsewhere in this repo (after this PR and subsequent changes are merged).

daira added 4 commits August 16, 2025 18:15
Signed-off-by: Daira-Emma Hopwood <[email protected]>
Signed-off-by: Daira-Emma Hopwood <[email protected]>
Copy link

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

Great start, thanks for pushing this forward. I’ve left a few optional suggestions and questions inline.
I’d love to contribute more to this Lean formalization, including taking a pass at some of the current sorrys, and to help across the repo more broadly. I’m not sure what the most convenient way to coordinate is (issues, pr's, a short sync, or something else) so I’m happy to follow your lead, @daira, if you think that would add value.

/--
An execution of Π_bc has Agreement on the view `V : Node → Time → BcChain` iff
for all times `t`, `u` and all Π-nodes `i`, `j` (potentially the same) such that
`i` is honest at time `t` and `j` is honest at time `u`, we have `V i t ≤≥ V j u`.

Choose a reason for hiding this comment

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

Suggested change
`i` is honest at time `t` and `j` is honest at time `u`, we have `V i t ≤≥ V j u`.
`i` is honest at time `t` and `j` is honest at time `u`, we have `V i t ≼≽ V j u`.


Since chains are represented tip-first, this is implemented by dropping the first
`k` elements.
-/

Choose a reason for hiding this comment

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

Suggested change
-/
TODO: this definition works for any chain type; generalize it.
-/

There are several definitions that can be generalized (bft_prefix, bc_tip, etc). Do we want to have a Definitions.lean in the future for some of those?

local infix:50 "≼/≽" => bc_conflicts

/-- If a ≼ c ∧ b ≼ c then a ≼≽ b. -/
public lemma linear_prefix (a b c : BcChain) (hac : a ≼ c) (hbc : b ≼ c) : a ≼≽ b := by

Choose a reason for hiding this comment

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

This is true for any chain type. Will be good to add it to the Bftchain file too, as we have no lemmas there atm.


TODO: this definition works for any chain type; generalize it.
-/
public def ComposedBftAgreement {U : Type} (V : Node → Time → U) (f : U → BftChain) :=

Choose a reason for hiding this comment

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

I think this definition is not in the book. Should we add it there?

Choose a reason for hiding this comment

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

Will be good to auto generate docs from the lean code and publish somewhere.


import Mathlib.Tactic

import TFL.LCA

Choose a reason for hiding this comment

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

Suggested change
import TFL.LCA
import TFL.BcChain

No need to import LCA here but just BcChain will do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Crosslink An issue related to the Crosslink construction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants