
Matching μ-Logic
Abstract
This paper, authored by Xiaohong Chen and Grigore Rosu and published at LICS 2019 (the 34th Annual ACM/IEEE Symposium on Logic in Computer Science), makes two fundamental contributions to the theory of matching logic. First, it proposes a sound and complete proof system for matching logic in its full generality, resolving a significant open problem since previous completeness results were limited to specific theories providing equality and membership. Second, it introduces matching -logic, an extension of matching logic with a least fixpoint -binder. The -binder allows the definition of recursive patterns, enabling matching -logic to capture as special instances many important logics in mathematics and computer science, including first-order logic with least fixpoints, modal -logic, dynamic logic, various temporal logics (including infinite-trace and finite-trace linear temporal logic, and computation tree logic), and notably reachability logic --- the logic underlying program verification in the K framework. Matching -logic thus serves as a unifying foundation for specifying and reasoning about fixpoints, induction, programming language semantics, and program verification.
Introduction
Matching logic was introduced by Grigore Rosu as a logic for specifying and reasoning about mathematical structures by means of patterns and pattern matching. Unlike classical first-order logic, where formulas evaluate to truth values, matching logic patterns are interpreted as the sets of elements that they match. This set-valued semantics provides a natural framework for expressing both structural properties (like "the term has the form ") and logical properties (like "for all , holds") within a single formalism. Matching logic was originally developed as the logical foundation for the K framework, a rewrite-based framework for defining programming language semantics, but its scope extends far beyond programming languages.
Prior to this paper, the proof theory of matching logic was incomplete in general. Sound and complete deduction had been established only for matching logic theories that include specific axioms defining equality and membership, which restricted the class of models to which the completeness result applied. This limitation was problematic because many important applications of matching logic --- including its use as a foundation for the K framework --- require reasoning in theories that do not necessarily include equality and membership axioms. The first contribution of this paper addresses this gap by proposing the proof system , which is sound and complete for all matching logic theories. The second contribution, the extension to matching -logic, is motivated by the observation that many important logical systems used in program verification and formal methods are based on fixpoints, and that matching logic's pattern-based formalism is naturally suited to incorporate fixpoint reasoning.
Matching Logic: Syntax and Semantics
The syntax of matching logic is parametric in a signature consisting of a set of element variables , a set of set variables , and a set of constant symbols . Patterns are defined by the grammar:
Here, is an element variable (matching a single element), is a set variable (matching a set of elements), is a constant symbol, is application (a crucial construct that generalizes both function application and symbol application), is the empty pattern, is implication, and is existential quantification. The remaining standard connectives are derived: , , , , and .
The semantics of matching logic is given by matching logic models , where is a non-empty carrier set and assigns to each constant symbol a subset . An -valuation maps element variables to elements of and set variables to subsets of . The interpretation of a pattern is defined inductively:
A pattern is valid in a model (written ) if for all valuations , meaning that every element of matches . A pattern is satisfiable if for some model and valuation.
The Proof System H
The proof system is a Hilbert-style deduction system for matching logic consisting of axiom schemas and inference rules. The axioms include the standard propositional tautologies (since matching logic subsumes propositional logic through the pattern algebra), the axioms for the existential quantifier (adapted from first-order logic), and crucially, a set of axioms that govern the interaction between application and the logical connectives. The key axioms specific to matching logic include:
- Propagation of : and
- Propagation of :
- Propagation of : when
- Framing: from , derive for any context
The inference rules include modus ponens (), universal generalization ( when is not free in any hypothesis), and the set variable generalization rule. The soundness of is proved by showing that every axiom is valid in all matching logic models and that the inference rules preserve validity. The completeness is proved by a Henkin-style construction: from a consistent theory and a pattern not derivable from , a model is constructed in which all patterns in are valid but is not. The completeness proof requires careful handling of the set-valued semantics and the interaction between element variables and set variables.
Matching Mu-Logic: Syntax and Semantics
Matching -logic extends matching logic with the least fixpoint operator , where is a set variable and is a pattern in which occurs positively (i.e., under an even number of negations). The positivity requirement ensures the existence of the least fixpoint by the Knaster-Tarski theorem. The syntax of matching -logic extends the matching logic grammar with:
The semantics of the -binder is the standard least fixpoint semantics:
That is, is interpreted as the intersection of all pre-fixpoints of the operator . The greatest fixpoint is defined dually: . The proof system for matching -logic extends with the pre-fixpoint axiom and the Knaster-Tarski (Park) induction rule:
- Pre-fixpoint:
- Knaster-Tarski: from , derive
The pre-fixpoint axiom says that is a pre-fixpoint (unfolding the definition is valid), and the Knaster-Tarski rule says that is the least pre-fixpoint (any other pre-fixpoint contains it). Together, these capture the complete deductive theory of least fixpoints.
Capturing Important Logics
The paper's most striking result is the demonstration that matching -logic captures numerous important logics as special instances. Each logic is obtained by choosing an appropriate matching logic signature and axioms, and then expressing the logic's formulas as matching -logic patterns:
- First-order logic (FOL): Classical FOL is a special case where all patterns are interpreted as either or (i.e., patterns are "predicate-like"). This is achieved by adding a definedness axiom: , which forces every singleton to be "total." Under this axiom, matching logic collapses to FOL, and the -binder gives FOL extended with least fixpoints (LFP).
- Modal -logic: By adding a modal signature with a binary relation symbol (the accessibility relation), the modal operators and can be defined. The -binder then gives the full modal -calculus, which subsumes all standard modal and temporal logics.
- Linear temporal logic (LTL): Both infinite-trace LTL and finite-trace LTL are instances. The temporal operators are defined using fixpoints: ("eventually ") and ("always "), where is the "next" operator.
- Computation Tree Logic (CTL): CTL's branching-time operators, including (there exists a path where eventually ) and (on all paths, always ), are defined as fixpoints over the transition relation.
- Dynamic logic: The modality ("after executing program , holds") is expressible, with iteration (Kleene star) captured via the -binder: .
Reachability Logic as an Instance
Perhaps the most significant application of matching -logic is the capture of reachability logic, the logic that underpins program verification in the K framework. Reachability logic allows the specification and verification of program behavior by expressing reachability claims of the form , meaning "any program configuration matching pattern will eventually reach (in zero or more steps) a configuration matching pattern ." Reachability logic generalizes Hoare logic: the Hoare triple can be expressed as the reachability claim , where the first component is the state predicate and the second is the remaining computation.
In matching -logic, a reachability claim is expressed using the least fixpoint:
This says: starting from any configuration matching , either already holds, or after one step (), the property holds --- and by the least fixpoint, this must eventually terminate with holding. The one-step transition is defined using the language's operational semantics (the K rewrite rules). The paper proves that the proof system of matching -logic, when instantiated with the axioms corresponding to a K language definition, yields exactly the proof rules of reachability logic. This result is foundational for the K framework, because it means that the K verifier's reasoning is grounded in a sound and complete logic, and that all of K's verification capabilities are instances of matching -logic reasoning.
Relationship to the K Framework
Matching -logic serves as the logical foundation of the K framework. In K, a programming language is defined by its syntax, configuration, and rewrite rules. The semantics of a K definition can be formalized as a matching -logic theory, where the rewrite rules become axioms expressing one-step transitions. The K verifier proves reachability claims (program specifications) by constructing matching -logic proofs, using the rewrite rules as axioms and the fixpoint induction rule as the source of loop invariant reasoning.
The paper establishes that this connection is not merely an analogy but a precise mathematical correspondence. Every K rewrite rule (with side conditions) translates to a matching -logic axiom . Every program property proved by the K verifier corresponds to a theorem of matching -logic. This means that every program verification performed in K is, at its core, a matching -logic proof, even though the user interacts with K at a much higher level of abstraction. The result provides a strong foundational justification for the K approach to program verification and opens the door to cross-verification: proofs generated by the K verifier can, in principle, be checked by an independent matching -logic proof checker. This connection between K and matching -logic is central to the Proof of Proof () technology developed by Pi2 Labs, which generates cryptographic proofs from matching logic proof certificates.
Conclusion
The paper makes two contributions of lasting significance to the foundations of formal methods. The sound and complete proof system for matching logic resolves a fundamental question about the proof theory of this logic and provides a solid deductive foundation for all applications of matching logic. The extension to matching -logic, with its ability to capture first-order logic with fixpoints, modal -logic, temporal logics, dynamic logic, and reachability logic, establishes matching -logic as one of the most expressive and unifying logics in the formal methods landscape.
The practical implications of matching -logic are far-reaching. By providing a single logical framework that subsumes the many different logics used in program verification, matching -logic simplifies the foundations of verification tools and enables cross-language and cross-logic reasoning. The connection to the K framework means that language-independent program verification can be grounded in a single, well-understood logic. The paper opens numerous directions for future work, including the development of automated proof tactics for matching -logic, the investigation of decidability fragments, and the application of matching -logic to new domains such as probabilistic programs and quantum computing. Matching -logic represents a significant step toward the vision of a universal logic for programming languages and formal verification.
Stay Informed
Sign up for updates and never miss important announcements.
Join the community
Join our Discord server to get support or connect with the Pi² community.