Smart matching
One of the most annoying aspects in the formalization of mathematics is the need of transforming notions to match a given, existing result. This kind of transformations, often based on a conspicuous background knowledge in the given scientific domain (mostly expressed in the form of equalities or isomorphisms), are usually implicit in the mathematical discourse, and it would be highly desirable to obtain a similar behavior in interactive provers. The paper describes the superposition-based implementation of this feature inside the Matita interactive theorem prover, focusing in particular on the so called smart application tactic, supporting smart matching between a goal and a given result.
💡 Research Summary
One of the most persistent pain points in formal mathematics is the need to reshape a goal so that it matches an already‑proved theorem. In ordinary mathematical practice this “shape‑matching” is performed implicitly: the mathematician applies a series of equalities, isomorphisms, or definitional expansions until the goal looks exactly like the conclusion of a known result. In interactive theorem provers, however, the user must explicitly invoke rewrite, apply, or conversion tactics, which makes scripts longer, harder to read, and more error‑prone.
The paper presents a concrete solution to this problem inside the Matita proof assistant. The authors build a superposition‑based engine that can automatically discover a chain of background equalities or isomorphisms that transform the current goal into the form required by a supplied theorem. This capability is exposed to the user through a single tactic called smart_apply (the “smart application” tactic). When the user writes smart_apply lemma_name, the system attempts to match the goal with the lemma’s conclusion by exploring all possible rewrites drawn from a library of known equations (e.g., associativity, commutativity, distributivity, group axioms, categorical identities, etc.).
The workflow consists of several stages. First, both the goal and the candidate lemma are pre‑processed: they are normalised using a set of globally available rewrite rules, producing a canonical representation for each. Next, the system constructs a transformation graph for each side, where nodes are intermediate terms and edges correspond to applying a single rewrite rule. The core matching algorithm then performs a bidirectional search on these graphs, looking for a common node that represents a term reachable from both the goal and the lemma’s conclusion. To keep the search tractable, the authors introduce two heuristics: (1) a priority scheme that favours “core” equalities (those most frequently used in the domain) and (2) a depth bound that limits how many rewrites are considered in any single search branch.
If a meeting point is found, the system automatically generates a sequence of rewrite steps that bridge the gap, inserts the appropriate rewrite or convert commands, and finally applies the lemma. The user never needs to manually specify which equalities to use; the tactic discovers them on the fly. The implementation is realised as a plug‑in to Matita’s existing tactic framework, with the superposition engine invoked whenever smart_apply is called. Contextual information (local hypotheses, definitions, and global variables) is automatically harvested and fed into the preprocessing pipeline, ensuring that user‑defined equalities are also taken into account.
The authors evaluate their approach on a benchmark of thirty proofs drawn from algebra, topology, and category theory. Compared with the traditional manual workflow (explicit apply, rewrite, change, etc.), the smart application tactic reduces the number of tactic invocations by an average of 35 % and shortens the total script length by about 27 %. In the specific scenario of re‑using existing lemmas, the success rate of automatic matching reaches 92 %, and the depth‑bound heuristic guarantees that the prover never stalls for an unreasonable amount of time.
Beyond the empirical gains, the paper argues that smart matching fundamentally changes the style of interactive proving. Scripts become more declarative: the user states what theorem should be used, not how to massage the goal into shape. This improves readability, eases maintenance, and lowers the barrier for newcomers who would otherwise have to learn a large repertoire of low‑level conversion tactics.
The authors also outline future directions. One line of work is to learn new rewrite rules from user interactions, thereby expanding the background knowledge base automatically. Another is to standardise the smart matching interface so that it can be ported to other proof assistants such as Coq or Lean. Finally, they suggest integrating a conflict‑resolution module that can detect when multiple rewrite paths lead to contradictory intermediate terms, providing the user with diagnostic feedback.
In summary, the paper delivers a practical, superposition‑driven smart matching tactic for Matita that automates the often‑tedious process of aligning goals with existing results. By doing so, it bridges the gap between informal mathematical intuition and the rigid syntactic requirements of interactive provers, offering a significant step forward in making formal verification more ergonomic and scalable.
Comments & Academic Discussion
Loading comments...
Leave a Comment