Algebraic Tools for Binary Relations in Coq

The aim of this project is to provide algebraic tools for reasoning about binary relations in Coq:

Deciding Kleene Algebras

Binary relations form a Kleene Algebra, by considering set-theoretic union, relational composition, and relexive transitive closure. The main tactic we provide in this library allows one to decide (in)equalities in Kleene algebras; using the initiality theorem proved independently by Kozen and Krob in the early 90's. We rely on Kozen's proof: we implement finite automata algorithms (construction, removing of epsilon-transitions, determinisation, minimisation), and the proof goes by replaying these algorithms in an algebraic way, using matrices.

For example, this tactic automatically solves goals of the form a#*(b+a#*(1+c))# = (a+b+c)# or a*b*c*a*b*c*a# <= a#*(b*c+a)#, where a, b, and c are elements of an arbitrary Kleene algebra (binary relations, regular languages, min-max expressions...), # is the (postfix) star operation, * is the infix product or concatenation operation, + is the sum or union operation, and 1 is the neutral element.

Changes in the second release

  1. We switched to positive binary numbers, which required the introduction of a new infrastructure.
  2. The construction algorithm is no longer Thompson's one; it is no longer implemented using a matricial representation.
  3. The epsilon removal step is no longer computed algebraically: we prove that our construction returns acyclic epsilon-transitions, so that we can use a linear transitive closure algorithm.
  4. The determinisation algorithm remained the same, but was reimplemented in a more natural way, thanks to a partial fixpoint operator. (In particular, we no longer need the CoLoR library: termination of the determinisation step no longer requires multiset well-founded orderings.)
  5. We no longer use minimisation to tests DFAs fo equivalence; instead, we implemented Hopcroft and Karp's algorithm, using an efficient disjoint-sets data-structure.
  6. In case of failure, the tactic now provides a counter-example to the user; the decision procedure was moreover proved complete.

Performances

We performed intensive tests on randomly generated regular expressions. On typical use cases, the tactic runs instantaneously. It runs in less than one second for expressions with 150 internal nodes and 20 variables, and less than one minute for even larger expressions (1000 internal nodes, 40 variables), that are very unlikely to appear in ``human-written'' proofs. (These timings were obtained by testing each regular expression with itself: this is approximately a worst case, since we implemented an early failure optimisation in the equivalence check.)

We also compared our approach with the works of Struth, Hoefner, and Dang, who work with automatic theorem provers (ATP). Timings can be found here, the whole benchmark is there.

Matrices

Kozen's initiality proof goes by encoding automata at the algebraic level, using matrices. Therefore, the ATBR library contains a set of definitions and tools about matrices (over semirings or Kleene algebras). In particular, it contains "ring"-like tactics for matrices whose dimensions are not necessarily uniform.

Rewriting closed equations modulo A / AC

In the structures we consider, having to handle associativity and commutativity explicitly can be tedious. This library contains ad-hoc tactics allowing to rewrite a closed equation in the current goal, modulo A or AC. We plan to implement systematic tactics for solving automatically the general case of universally quantified equations.

Downloads

Authors

Thomas Braibant and Damien Pous

Documentation

The code is not fully documented, yet. Here we describe the the overall structure, with pointers to the coqdoc generated documentation. Here is the README file from the archive.


Last modified: Tue Jan 26 16:20:23 CET 2010