# Difference between revisions of "Maude Tools:Order-sorted Term Patterns"

## Introduction

This page introduces the Maude Order-sorted Pattern Solver, a tool that accepts an order-sorted pattern as input and can—in many cases—discover a finite union of terms equivalent to the given pattern, if it exists.

Order-sorted term patterns are a simple notation for describing unions, intersections, and differences of sets of terms generated by an order-sorted signature.

Our tool transforms general patterns into finite unions by interpreting intersection as unification and difference as an application of our order-sorted symbolic difference algorithm.

### Example Patterns

Suppose t1, t2, and t3 are terms in an order-sorted signature. Then:

1. {t1,t2,t3} is the pattern representing the union of instances these terms.
2. {t1} - {t2} is the pattern representing the instances of t1 that are not instances of t2.
3. {t1,t2} & {t3} is the pattern representing the intersection of instances of t1 and t2 with t3.
4. {} is the empty pattern which has no instances.

## Theoretical Details

### Closure Under Boolean Operations

For some order-sorted signatures, term patterns are closed under union, intersection, and difference. Otherwise, we can usually apply a transformation to a signature so that it becomes closed under these operations.

### Special Patterns

Assuming finite signatures, there is a finite pattern which generates every term. There is also a finite pattern generates no terms (e.g. the empty pattern).

### Pattern Equivalence

Two patterns are considered equivalent if they generate the same term set. This condition can be checked by observing if the subtracting each pattern by the other results in the empty pattern.

### Relationship to Propositional Tree Automata

An order-sorted signature can be viewed as a tree automaton that accepts as inputs any term that the signature generates. The generalization of a tree automaton—a propositional tree automaton—can accept not only terms but also unions, intersections, and complements of terms. Our order-sorted term patterns provide a simpler and more intuitive algorithm which accomplishes this same task.

### Order-sorted Symbolic Difference

Our symbolic difference algorithm generalizes previous approaches such as that of Lassez and Marriott, by extending to the case of order-sorted terms.

To use the pattern solver tool, both of the following tarballs will need to be downloaded. Note that currently, the binary is compiled for Linux only. Any modern Linux distribution should be unproblematic.

Once you have downloaded and unpacked both archives, you can run examples. To do so, you need to invoke the Maude rewrite engine (called maude in Maude binary tarball) on the example you wish to run. For example, if I unpacked both archives in my home directory and wanted to run the Pichler example (shown below), I could run:

# ~/maude2.7-bin/maude ~/pat-solve-rel/examples/pichler-ex.maude

## Tool Example Inputs

The following example inputs are all taken from the /examples folder inside the root directory of the pattern solver tool:

These examples are all formatted as equalities between two pattern terms, tested using the method presented above. The terms occurring in a pattern are presented using Maude META-LEVEL syntax, which is documented in the Maude Manual (see section 11.2).

Hopefully, the examples will give a flavor of how the syntax looks when written down and the kinds of queries one might make.