Distributed system theory literature often argues for correctness using an informal, Hoare-like style of reasoning. While these arguments are intuitive, they have not all been foolproof, and whether they directly correspond to formal proofs is in question. We formally ground this kind of reasoning and connect it to standard formal approaches through language design and meta-analysis, which leads to a functional style of compositional formal reasoning for a class of distributed systems, including cases involving Byzantine faults. The core of our approach is twin languages: Sync and Async, which formalize the insight from distributed system theory that an asynchronous system can be reduced to a synchronous system for more straightforward reasoning under certain conditions. Sync describes a distributed system as a single, synchronous, data-parallel program. It restricts programs syntactically and has a functional denotational semantics suitable for Hoare-style formal reasoning. Async models a distributed system as a collection of interacting monadic programs, one for each non-faulty node in the system. It has a standard trace-based operational semantics, modeling asynchrony with interleaving. Sync compiles to Async and can then be extracted to yield executable code. We prove that any safety property proven for a Sync program in its denotational semantics is preserved in the operational semantics of its compiled Async programs. We implement the twin languages in Rocq and verify the safety properties of two fault-tolerant consensus protocols: BOSCO and SeqPaxos.
翻译:分布式系统理论文献常采用一种非形式化的类Hoare推理风格来论证正确性。尽管这类论证具有直观性,但它们并非绝对可靠,且其与形式化证明的直接对应关系存疑。我们通过语言设计与元分析,为此类推理建立形式化基础,并将其与标准形式化方法相关联,从而为包含拜占庭故障在内的某类分布式系统建立了一种函数式组合形式推理范式。我们方法的核心是一对孪生语言:Sync与Async,它们形式化了分布式系统理论中的核心洞见——在特定条件下,异步系统可归约为同步系统以进行更直接的推理。Sync将分布式系统描述为单一、同步、数据并行的程序,通过语法限制程序结构,并采用适用于Hoare式形式化推理的函数式指称语义。Async将分布式系统建模为交互式单子程序的集合,每个非故障节点对应一个程序,采用基于轨迹的标准操作语义,通过交错执行模拟异步行为。Sync可编译为Async,进而可提取为可执行代码。我们证明:在Sync程序的指称语义中验证的任何安全性性质,在其编译生成的Async程序的操作语义中均得以保持。我们在Rocq中实现了这对孪生语言,并验证了两个容错共识协议(BOSCO与SeqPaxos)的安全性性质。