Skip to main content
QUICK REVIEW

[Paper Review] A Verified Algorithm for Deciding Pattern Completeness

Cynthia Kop, Yamada, Akihisa|arXiv (Cornell University)|Feb 8, 2017
Semantic Web and OntologiesComputer Science2 references2 citations
TL;DR

This paper presents a sound and efficient algorithm to verify quasi-reductivity in Logically Constrained Term Rewriting Systems (LCTRSs), ensuring that evaluation never gets stuck due to missing pattern matches. The method checks for completeness of rules by testing whether all possible constructor patterns are covered, under the assumptions of left-linearity, constructor-soundness, and left-value-freeness, with the key result being a decision procedure that confirms quasi-reductivity via a syntactic check on rule patterns.

ABSTRACT

Pattern completeness is the property that the left-hand sides of a functional program cover all cases w.r.t. pattern matching. In the context of term rewriting a related notion is quasi-reducibility, a prerequisite if one wants to perform ground confluence proofs by rewriting induction. In order to certify such confluence proofs, we develop a novel algorithm that decides pattern completeness and that can be used to ensure quasi-reducibility. One of the advantages of the proposed algorithm is its simple structure: it is similar to that of a regular matching algorithm and, unlike an existing decision procedure for quasi-reducibility, it avoids enumerating all terms up to a given depth. Despite the simple structure, proving the correctness of the algorithm is not immediate. Therefore we formalize the algorithm and verify its correctness using the proof assistant Isabelle/HOL. To this end, we not only verify some auxiliary algorithms, but also design an Isabelle library on sorted term rewriting. Moreover, we export the verified code in Haskell and experimentally evaluate its performance. We observe that our algorithm significantly outperforms existing algorithms, even including the pattern completeness check of the GHC Haskell compiler.

Motivation & Objective

  • To address the problem of evaluation getting stuck in LCTRSs due to incomplete pattern matching.
  • To formalize and verify a decision procedure for quasi-reductivity in LCTRSs.
  • To provide a practical, implementable method that ensures all constructor patterns are covered by rules.
  • To establish conditions—left-linearity, constructor-soundness, and left-value-freeness—under which the algorithm is sound and effective.

Proposed method

  • The algorithm checks for pattern completeness by analyzing the set of all left-hand sides of rules and their associated constraints.
  • It defines a predicate OK(−→x, A, b) that determines whether a given set of patterns and constraints can cover all possible constructor term inputs.
  • The method uses structural induction on the number of arguments and sorts, distinguishing cases based on whether the current argument is a value, a term, or a choice between both.
  • It relies on the assumption of left-linearity to safely substitute variables and avoid variable capture during pattern matching.
  • The algorithm checks whether, for every defined or calculation symbol f, the set Af of patterns for f satisfies OK((), Af, either), which ensures all constructor inputs are covered.
  • The core of the method is a recursive coverage check that propagates constraints and verifies that all possible constructor term inputs can be matched by some rule.

Experimental results

Research questions

  • RQ1Can we automatically verify that no ground irreducible term exists other than constructor terms in LCTRSs?
  • RQ2Under what conditions can we decide quasi-reductivity via syntactic pattern coverage?
  • RQ3Is there a sound and efficient algorithm to detect missing cases in rule patterns of LCTRSs?
  • RQ4Can the algorithm be made complete for the class of left-linear, left-value-free, and constructor-sound LCTRSs?

Key findings

  • The algorithm is sound: if OK((), Af, either) holds for all symbols f, then the LCTRS is quasi-reductive.
  • The method is fully implemented in the Ctrl tool, demonstrating practical applicability.
  • The algorithm relies on three structural restrictions—left-linearity, constructor-soundness, and left-value-freeness—to ensure correctness.
  • The paper conjectures that the method is also complete for the class of left-linear, left-value-free, and constructor-sound LCTRSs, though completeness is not proven here.
  • The algorithm effectively detects missing pattern cases by analyzing the structure of rule left-hand sides and their constraints.
  • The verification of pattern completeness is reduced to a syntactic check on rule patterns, avoiding expensive model checking or proof search.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.