Skip to content

feat(FLP): distributed algorithms for solving the consensus problem#556

Open
ctchou wants to merge 1 commit into
leanprover:mainfrom
ctchou:flp-algorithm
Open

feat(FLP): distributed algorithms for solving the consensus problem#556
ctchou wants to merge 1 commit into
leanprover:mainfrom
ctchou:flp-algorithm

Conversation

@ctchou
Copy link
Copy Markdown
Collaborator

@ctchou ctchou commented May 10, 2026

This is the first PR of the formalization of Völzer's proof of the famous result in distributed computing, first proved by Fischer, Lynch and Paterson, that distributed consensus is impossible in the presence of even a single crash fault.

  • Algorithm.lean defines the "syntax" of a distributed algorithm for solving the consensus problem and proves some basic properties.
  • README.md is for the overall project and mentions Lean files which will be PR-ed later.
  • references.bib is updated to add the papers by FLP and Völzer.

Zulip discussion:
#CSLib > Impossibility of distributed consensus

@ctchou
Copy link
Copy Markdown
Collaborator Author

ctchou commented May 11, 2026

Rebased on the current main.

the reception of message `m` and `none` denotes a stuttering step. -/
abbrev Action (P M : Type*) := Option (Message P M)

/-- `Dest ps x` means that if `x ≠ none`, then `x = some m` with `m.dest ∈ ps`. -/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you meant to write DestIn.


/-- Given `inp : P → Bool`, the initial state of the algorithm `a` contains a single message
carrying the boolean value `inp p` to each process `p`, where the initial internal state is
`a.init p` and no decision has been made. The assumption `[Fintyep P]` is made because
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fintyep -> Fintype.

its `out` field, it is not allowed to "change its mind" later. -/
def Algorithm.recvMsg (a : Algorithm P M S) (m : Message P M) (s : State P M S) : State P M S :=
let p := m.dest
{ msgs := s.msgs.erase m + a.send m (s.proc p)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if m wasn't contained in s.msgs to begin with? I see that is handled by Algorithm.LTS correctly, but a comment explaining this would be useful for future readers.

/-- The global state of the distributed algorithm. -/
structure State (P M S : Type*) where
/-- A multiset containing all messages that are in-flight (namely, they have been sent but
not yet received. Note that being a multiset implies that the messages are not ordered. -/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

close parens here?


/-- The stuttering step does not change the global state. -/
theorem tr_none {s s' : State P M S} (h : a.LTS.Tr s none s') : s = s' := by
grind [Algorithm.LTS]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the iff here might be nicer?


namespace Cslib.FLP

open Function Set Sum Multiset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Function is unused here.

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.

3 participants