🤖 AI Summary
This study addresses the extensive redundancy in syntax, semantics, and metatheory development across modal logic formalizations. To mitigate this, it proposes CSLib, a general-purpose modal logic library built upon the Lean theorem prover. Uniquely treating reuse and integration as first-class design concerns, CSLib introduces a polyadic language framework that supports both vertical and horizontal reuse, alongside an automated proof infrastructure. The authors demonstrate its efficacy by successfully deriving multiple modal logics and applying them to domains in mathematics and programming languages. Notably, the proposed approach reduces code volume for specific logics by 67%, significantly enhancing the efficiency of formal verification efforts.
📝 Abstract
Modal logic comprises a broad family of logics to reason about relational structures. The literature presents many such logics, displaying diverse operators, semantics, and applications. This plurality is reflected in a zoo of mechanised modal logics, which often duplicate syntax, semantics, metatheory, and reasoning infrastructure. We present a library-grade formalisation of modal logic in Lean, developed as part of CSLib (the Lean Computer Science Library) and designed around two complementary forms of reuse: vertical reuse, whereby specialised logics inherit from common abstractions, and horizontal reuse, whereby modal logic becomes a reasoning tool for independently formalised domains. Our development provides a generic framework for polyadic modal languages, reusable metatheory and proof automation, and derived interfaces for specialised modal logics. We exemplify our infrastructure by deriving basic modal logic, basic temporal logic, and Hennessy-Milner Logic; the latter subsumes and extends CSLib's previous implementation while reducing its logic-specific code by 67%. We further apply the same modal infrastructure to reasoning about mathematics (radicals of ideals), theory of programming languages (the type safety strategy for the simply typed $\lambda$-calculus), and concurrency theory (reasoning about processes in the Calculus of Communicating Systems). Our experience suggests that reuse, automation, and integration with the strong Lean ecosystem should be treated as first-class design concerns when formalising theories for shared libraries.