Nominal Unification and Matching of Higher Order Expressions with Recursive Let
Manfred Schmidt-Schau?, Temur Kutsia, Jordi Levy, Mateu Villaret, Yunus Kutz
aa r X i v : . [ c s . L O ] F e b Fundamenta Informaticae XXI (2001) 1001–1035
DOI 10.3233/FI-2016-0000IOS Press
Nominal Unification and Matching of Higher Order Expressionswith Recursive Let
Manfred Schmidt-Schauß * C
GU Frankfurt, Germany, [email protected]
Temur Kutsia † RISC, JKU Linz, Austria, [email protected]
Jordi Levy ‡ IIIA - CSIC, Spain, [email protected]
Mateu Villaret § IMA, Universitat de Girona, Spain, [email protected]
Yunus Kutz
GU Frankfurt, Germany, [email protected]
Abstract.
A sound and complete algorithm for nominal unification of higher-order expressionswith a recursive let is described, and shown to run in nondeterministic polynomial time. We alsoexplore specializations like nominal letrec-matching for expressions, for DAGs, and for garbage-free expressions and determine their complexity. Finally, we also provide a nominal unificationalgorithm for higher-order expressions with recursive let and atom-variables, where we show thatit also runs in nondeterministic polynomial time.
Keywords:
Nominal unification, lambda calculus, higher-order expressions, recursive let, atomvariables
This paper is an extended version of the conference publication [1]. * Partially supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SCHM 986/11-1 C Corresponding author † Partially supported by the Austrian Science Fund (FWF) project P 28789-N32. ‡ Partially supported by the MINECO/FEDER projects RASO (TIN2015-71799-C2-1-P) and LoCoS (TIN2015-66293-R). § Partially supported by UdG project MPCUdG2016/055.002
M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
1. Introduction
Unification [2] is an operation to make two logical expressions equal by finding substitutions into vari-ables. There are numerous applications in computer science, in particular of (efficient) first-order uni-fication, for example in automated reasoning, type checking and verification. Unification algorithmsare also extended to higher-order calculi with various equivalence relations. If equality includes α -conversion and β -reduction and perhaps also η -conversion of a (typed or untyped) lambda-calculus,then unification procedures are known (see, e.g., [3]), however, the problem is undecidable [4, 5].Our motivation comes from syntactical reasoning on higher-order expressions, with equality be-ing α -equivalence of expressions, and where a unification algorithm is demanded as a basic service.Nominal unification is the extension of first-order unification with abstractions. It unifies expressionsw.r.t. α -equivalence, and employs permutations as a mathematically clean treatment of renamings. Itis known that nominal unification is decidable [6, 7], where the complexity of the decision problem ispolynomial time [8]. It can be seen also from a higher-order perspective [9], as equivalent to Miller’shigher-order pattern unification [10]. There are efficient algorithms [8, 11], formalizations of nom-inal unification [12], formalizations with extensions to commutation properties within expressions[13], and generalizations of nominal unification to narrowing [14]. Equivariant (nominal) unification[15, 16, 17] extends nominal unification by permutation-variables, but it can also be seen as a general-ization of nominal unification by permitting abstract names for variables.We are interested in unification w.r.t. an additional extension with cyclic let. To the best of ourknowledge, there is no nominal unification algorithm for higher-order expressions permitting generalbinding structures like a cyclic let. Higher-order unification could be applied, however, the algorithmsare rather general and thus the obtained complexities of specializations is far too high. Thus wepropose to extend and adapt usual nominal unification [6, 7] to languages with recursive let.The motivation and intended application scenario is as follows: constructing syntactic reasoningalgorithms for showing properties of program transformations on higher-order expressions in call-by-need functional languages (see for example [18, 19]) that have a letrec-construct (also called cyclic let)[20] as in Haskell [21], (see e.g. [22] for a discussion on reasoning with more general name binders,and [23] for a formalization of general binders in Isabelle). Extended nominal matching algorithmsare necessary for applying program transformations that could be represented as rewrite rules. Basicproperties of program transformations like commuting properties of conflicting applications or over-laps can be analyzed in an automated way if there is a nominal unification algorithm of appropriatecomplexity. There may be applications also to coinductive extensions of logic programming [24] andstrict functional languages [25]. Basically, overlaps of expressions have to be computed (a variant ofcritical pairs) and reduction steps (under some strategy) have to be performed. To this end, first anexpressive higher-order language is required to represent the meta-notation of expressions. For exam-ple, the meta-notation (( λx.e ) e ) for a beta-redex is made operational by using unification variables X , X for e , e . The scoping of X and X is different, which can be dealt with by nominal tech-niques. In fact, a more powerful unification algorithm is required for meta-terms employing recursiveletrec-environments.Our main algorithm L ETREC U NIFY is derived from first-order unification and nominal unification:From first-order unification we borrow the decomposition rules, and the sharing method from Martelli- . Schmidt-Schauss et al. / Nominal Unification with Recursive Let
Montanari-style unification algorithms [26]. The adaptations of decomposition for abstractions and theadvantageous use of permutations of atoms is derived from nominal unification algorithms. Decom-posing letrec-expression requires an extension by a permutation of the bindings in the environment,where, however, one has to take care of scoping. Since in contrast to basic nominal unification, thereare nontrivial fixpoints of permutations (see Example 3.2), novel techniques are required and lead toa surprisingly moderate complexity: a fixed-point shifting rule (FPS) and a redundancy removing rule(ElimFP) are required. These rules bound the number of fixpoint equations
X . = π · X (where π is apermutation) using techniques and results from computations in permutation groups. The applicationof these techniques is indispensable (see Example 4.6) for obtaining efficiency.Inspired by the applications in programming languages, we investigate the notion of garbage-free expressions. The restriction to garbage-free expressions permits several optimizations of theunification algorithms. The first is that testing α -equivalence is polynomial. Another advantage is thatdue to the unique correspondence of positions for two α -equal garbage-free expressions, we show thatin this case, fixpoint equations can be replaced by freshness constraints (Corollary 8.3).As a further extension, we study the possibility to formulate input problems using atom variablesas in [27, 28] in order to take advantage of the potential of less nondeterminism. The correspondingalgorithm L ETREC U NIFY
AV requires permutation expressions and generalizes freshness constraintsas further expressibility, and also other techniques such as explicit compression of permutations. Thealgorithm runs in NP time. We added a strategy to really exploit the extended expressivity and theomission of certain nondeterministic choices.
Related Work:
Besides the already mentioned related work, we highlight further work. In nomi-nal commutative unification [29], one can observe that there are nontrivial fixpoints of permutations.This is similar to what we have in nominal unification with recursive let (when garbage-freeness isnot required), which is not surprising, because, essentially, this phenomenon is related to the lackof the ordering: in one case among the arguments of a commutative function symbol, in the othercase among the bindings of recursive let. Consequently, nominal C-unification reduces to fixpointconstraints. Those constraints may have infinitely many incomparable solutions expressed in termsof substitutions and freshness constraints (which is the standard way to represent nominal unifiers).In [30], the authors proposed to use fixpoint constraints as a primitive notion (instead of freshnessconstraints) to axiomatize α -equivalence and, hence, use them in the representation of unifiers, whichhelped to finitely represent solutions of nominal C-unification problems. The technical report [31] con-tains explanations how to obtain a nominal C-unification algorithm from a letrec unification algorithmand transfers the NP-completeness result for letrec unification to nominal commutative unification.The ρ g -calculus [32] integrates term rewriting and lambda calculus, where cyclic, shared termsare permitted. Such term-graphs are represented as recursion constraints, which resemble to recursivelet environments. The evaluation mechanism of the ρ g -calculus is based on matching for such sharedstructures. Matching and recursion equations are incorporated in the object level and rules for theirevaluation are presented.Unification of higher-order expressions with recursive let (but without nominal features) has beenstudied in the context of proving correctness of program transformations in call-by-need λ -calculi [33,34]. Later, in [35], the authors proposed a more elaborated approach to address semantic properties ofprogram calculi, which involves unification of meta-expressions of higher-order lambda calculi with M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let letrec environments. This unification problem extends those from [33, 34]: environments are treated asmultisets, different kinds of variables are considered (for letrec environments, contexts, and bindingchains), more than one environment variable is permitted, and non-linear unification problems areallowed. Equivalence there is syntactic, in contrast to our nominal approach where equality modulo α is considered. Unlike [35], our unification problems do not involve context and chain variables, butwe do have environment variables in matching problems. Moreover, we permit atom variables in anextension of nominal letrec unification.There are investigations into variants of nominal techniques with a modified view of variables andtheir renamings and algorithms for the respective variants of nominal unification [36], however, it isunclear whether this can be extended to letrec. Results : The nominal letrec unification algorithm is complete and runs in nondeterministic poly-nomial time (Theorem 5.2, 5.4). The nominal letrec matching is NP-complete (Theorems 6.3, 5.1), aswell as the nominal letrec unification problem (Theorems 5.4, 5.1). Nominal letrec matching for DAGsis in NP and outputs substitutions only (Theorem 6.5), and a very restricted nominal letrec matchingproblem is already graph-isomorphism hard (Theorem 7.2). Nominal unification for garbage-freeexpressions can be done with simple fixpoint rules (Corollary 8.3). In the extension with atom vari-ables, nominal unification can be done using further useful strategies with less nondeterminism andis NP-complete (Theorem 9.15). We construct an algorithm for nominal matching including letrec-environment variables, which runs in NP time (Theorem 10.4).
Structure of the paper.
It starts with a motivating intuition on nominal unification (Sec. 2). Afterexplaining the ground letrec-language LLR in Sec. 3, the unification algorithm L
ETREC U NIFY forLLR-expression is described in Sec. 4. Sec. 5 contains the arguments for soundness and completenessof L
ETREC U NIFY . Sec. 6 describes an improved algorithm for nominal matching on LLR: L
ETREC -M ATCH . Further sections are on extensions. Sec. 7 shows Graph-Isomorphism-hardness of nominalletrec matching and unification on garbage-free expressions (Theorem 7.2). Sec. 8 shows that fixpoint-equations for garbage-free expressions can be translated into freshness constraints (Cor. 8.3). Sec. 9considers nominal unification in an extension with atom variables, an nominal unification algorithmL
ETREC U NIFY
AV is defined and the differences to L
ETREC U NIFY are highlighted. It is shown thatthere is a simple strategy such that nominal unification runs in NP time (Theorem 9.15). The lastsection (Sec. 10) presents a nominal matching algorithm L
ETREC E NV M ATCH that is derived fromthe corresponding nominal unification algorithm L
ETREC U NIFY
AV. Sec. 11 concludes the paper.
2. Some Intuitions
In first order unification we have a language of applications of function symbols over a (possibleempty) list of arguments ( f e . . . e n ) , where n is the arity of f , and variables X . Solutions of equa-tions between terms are substitutions for variables that make both sides of equations syntacticallyequal. First order unification problems may be solved using the following two problem transformationrules:(Decomposition) Γ ·∪{ ( f e . . . e n ) . = ( f e ′ . . . e ′ n ) } Γ ∪ { e . = e ′ . . . e n . = e ′ n } . Schmidt-Schauss et al. / Nominal Unification with Recursive Let (Instantiation) Γ ·∪{ X . = e } [ X e ]Γ If X does not occur in e .The substitution solving the original set of equation may be easily recovered from the sequence oftransformations. However, the algorithm resulting from these rules is exponential in the worst case.Martelli and Montanari [26] described a set of improved rules that result into an O ( n log n ) timealgorithm where n is the size of the input equations. In a first phase the problem is flattened, result-ing into equations where every term is a variable or of the form ( f X . . . X n ) . The second phase is atransformation using the following rules:(Decomposition) Γ ·∪{ ( f X . . . X n ) . = ( f Y . . . Y n ) } Γ ∪ { X . = Y , . . . , X n . = Y n } (Variable Instantiation) Γ ·∪{ X . = Y } [ X Y ]Γ (Elimination) Γ ·∪{ X . = e } Γ If X neither occurs in e nor in Γ (Merge) Γ ·∪{ X . = ( f X . . . X n ) , X . = ( f Y . . . Y n ) } Γ ∪ { X . = ( f X . . . X n ) , X . = Y , . . . , X n . = Y n } Notice that in these rules the terms involved in the equations are not modified (they are not in-stantiated), except by the replacement of a variable by another in the Variable Instantiation rule. Wecan define a measure on problems as the number of distinct variables, plus the number of equations,plus the sum of the arities of the function symbols occurrences. All rules decrease this measure (forinstance, the merge rule increases the number of equations by n − , but removes a function symboloccurrence of arity n ). Since this measure is linear in the size of the problem, this proves that themaximal number of rule applications is linear. The Merge rule is usually described as Γ ·∪{ X . = e , X . = e } Γ ∪ { X . = e , e . = e } If e and e are not variablesHowever, this rule does not decrease the proposed measure. We can force the algorithm to, ifpossible, immediately apply a decomposition of the equation e . = e . Then, the application of bothrules (resulting into the first proposed Merge rule) do decrease the measure. Nominal unification is an extension of first-order unification where we have lambda-binders. Vari-ables of the target language are called atoms, and the unification-variables are simply called variables.Bound atoms can be renamed. For instance, λa. ( f a ) is equivalent to λb. ( f b ) . We also have permuta-tions of atom names (represented as swappings) applied to expressions of the language. When thesepermutations are applied to a variable, this is called a suspension . The action of a permutation on a The original Martelli and Montanari’s algorithm is a bit different. In fact, they do not flatten equations. However, theessence of the algorithm is basically the same as the one described here. In the flattening process we replace every proper subterm ( fe . . . e n ) by a fresh variable X , and add the equation X . =( fe . . . e n ) . We repeat this operation (at most a linear number of times) until all proper subterms are variable occurrences.006 M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let term is simplified until we get a term where permutations are innermost and only apply to variables.For instance, ( a b ) · λa. ( f X a ( f b c )) , where ( a b ) is a swapping between the atoms a and b , resultsinto λb. ( f ( a b ) · X b ( f a c )) . As we will see below, we also need a predicate to denote that an atom a cannot occur free in a term e , noted a e .We can extend the previous first-order unification algorithm to the nominal language modulo α -equivalence. The decomposition of λ -expressions distinguishes two cases, when the binder name isthe same and when they are distinct and we have to rename one of them:(Decompositionlambda 1) Γ ·∪{ λa.s . = λa.t } Γ ∪ { s . = t } (Decompositionlambda 2) Γ ·∪{ λa.s . = λb.t } Γ ∪ { s . = ( a b ) · t, a t } As we see in the second rule, we introduce a freshness constraint that has to be checked or solved,so we need a set of transformations for this kind of equations. This set of freshness constraints issolved in a second phase of the algorithm.As we have said, permutations applied to variables cannot be longer simplified and result intosuspensions. Therefore, now, we deal with suspensions instead of variables, and we do not make anydistinction between X and Id · X . Variable instantiation distinguishes two cases:(VariableInstantiation) Γ ·∪{ π · X . = π ′ · Y } X = Y [ X ( π − ◦ π ′ ) · Y ]Γ (Fixpoint) Γ ·∪{ π · X . = π ′ · X } Γ ∪ { a X | a ∈ dom ( π − ◦ π ′ ) } Notice that equations between the same variable
X . = X that are trivially solvable in first-order unifi-cation, adopt now the form π · X . = π ′ · X . This kind of equations are called fixpoint equations andimpose a restriction on the possible instantiations of X , when π and π ′ are not the identity. Namely, π · X . = π ′ · X is equivalent to { a X | a ∈ dom ( π − ◦ π ′ ) } , where the domain dom ( π ) is the set ofatoms a such that π ( a ) = a .From this set of rules we can derive an O ( n log n ) algorithm, similar to the algorithms describedin [8, 11]. This algorithm has three phases. First, it flattens all equations. Second, it applies thisset of problem transformation rules. Using the same measure as in the first-order case (consideringlambda abstraction as a unary function symbol and not counting the number of freshness equations),we can prove that the length of problem transformation sequences is always linear. In a third phase, wedeal with freshness equations. Notice that the number of distinct non-simplifiable freshness equations a X is quadratically bounded. Letrec expressions have the form ( letrec a .e ; . . . ; a n .e n in e ) . Variables a i are binders wherethe scope is in all expressions e j and in e . We can rename these binders, obtaining an equivalent ex-pression. For instance, ( letrec a. ( f a ) in ( g a )) ∼ ( letrec b. ( f b ) in ( g b )) . Moreover, we can alsoswap the order of definitions. For instance, ( letrec a.f ; b.g in ( h a b )) ∼ ( letrec b.g ; a.f in ( h a b )) .Schmidt-Schauß et al. [37] prove that equivalence of letrec expressions is graph-isomorphism (GI)complete and Schmidt-Schauß and Sabel [35] prove that unification is NP-complete. The GI-hardnesscan be elegantly proved by encoding any graph, like G = ( V, E ) = ( { v , v , v } , { ( v , v ) , ( v , v ) } ) ,into a letrec expression, like ( letrec v .a ; v .a ; v .a in letrec e . ( c v v ); e . ( c v v ) in a ) . Here, . Schmidt-Schauss et al. / Nominal Unification with Recursive Let v i represent the nodes and ( c v i v j ) the edges of the graph.Unfortunately, there are nontrivial fixpoints of permutations in the letrec-language. For example, ( letrec a .b , a .b , a .a in a ) is a fixpoint of the equation X . = ( b b ) · X , although b and b are not fresh in the expression. Therefore, the fixpoint rule of the nominal algorithm in [6] would notbe complete in our setting: to ensure X . = ( b b ) · X we cannot require b X and b X . See alsoExample 3.2. Hence, fixpoint equations can in general not be replaced by freshness constraints. Forthe general case we need a complex elimination rule, called fixed point shift:(FixPointShift) Γ ·∪{ π · X . = π ′ · X, . . . , π n · X . = π ′ n · X, π · X . = e } Γ ∪ { π π − · e . = π ′ π − · e, . . . , π n π − · e . = π ′ n π − · e } , if X neither occurs in e nor in Γ .The substitution is X → π − · e . This rule can generate an exponential number of equations (seeExample 4.6). In order to avoid this effect, we will use a property on the number of generators ofpermutation groups (see end of Section 3).For the decomposition of letrec expressions we also need to introduce a (don’t know) nondeter-ministic choice. Γ ·∪{ letrec a .s ; . . . ; a n .s n in r . = letrec b .t ; . . . ; b n .t n in r ′ }| ∀ ρ (Γ ∪ { s . = π · t ρ (1) , . . . , s n . = π · t ρ ( n ) , r . = π · r ′ } Where the necessary freshness constraints are { a i letrec b .t ; . . . ; b n .t n in r ′ ) | i = 1 , . . . , n } , ρ is a permutation on { , . . . , n } and π is an (atom-)permutation that extends { b ρ ( i ) a i | i =1 , . . . , n ) } with dom ( π ) ⊆ { a , . . . , a n , b , . . . , b n } .In Section 4, we will describe in full detail all the transformation rules of our algorithm.
3. The Ground Language of Expressions
The very first idea of nominal techniques [6] is to use concrete variable names in lambda-calculi(also in extensions), in order to avoid implicit α -renamings, and instead use operations for explic-itly applying bijective renamings. Suppose s = λ x . x and t = λ y . y are concrete (syntactically dif-ferent) lambda-expressions. The nominal technique provides explicit name-changes using permuta-tions. These permutations are applied irrespective of binders. For example ( x y ) · ( λ x .λ x . a ) resultsin λ y .λ y . a . Syntactic reasoning on higher-order expressions, for example unification of higher-orderexpressions modulo α -equivalence will be emulated by nominal techniques on a language with con-crete names, where the algorithms require certain extra constraints and operations. The gain is that allconditions and substitutions etc. can be computed and thus more reasoning tasks can be automated,whereas the implicit name conditions under non-bijective renamings have a tendency to complicate(unification-) algorithms and to hide the required conditions on equality/disequality/occurrence/non-occurrence of names. We will stick to a notation closer to lambda calculi than most other papers onnominal unification, however, note that in general the differences are only in notation and the con-structs like application and abstraction can easily be translated into something equivalent in the otherlanguage without any loss. M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
We define the language
LRL ( L et R ec L anguage) of (ground-)expressions, which is a lambda calculusextended with a recursive let construct. The notation is consistent with [6]. The (infinite) set of atoms A is a set of (concrete) symbols a, b which we usually denote in a meta-fashion; so we can use symbols a, b also with indices (the variables in lambda-calculus). There is a set F of function symbols witharity ar ( · ) . The syntax of the expressions e of LRL is: e ::= a | λa.e | ( f e . . . e ar ( f ) ) | ( letrec a .e ; . . . ; a n .e n in e ) We will also use tuples, which are written as ( e , . . . , e n ) , and which are treated as functional ex-pressions in the language. We assume that binding atoms a , . . . , a n in a letrec-expression ( letrec a .e ; . . . ; a n .e n in e ) are pairwise distinct. Sequences of bindings a .e ; . . . ; a n .e n are abbreviated as env .The expressions ( letrec a .e ; . . . ; a n .e n in e ) and ( letrec a ρ (1) .e ρ (1) ; . . . ; a ρ ( n ) .e ρ ( n ) in e ) aredefined as equivalent for every permutation ρ of { , . . . , n } .The scope of atom a in λa.e is standard: a has scope e . The letrec -construct has a special scop-ing rule: in ( letrec a .s ; . . . ; a n .s n in r ) , every atom a i that is free in some s j or r is bound bythe environment a .s ; . . . ; a n .s n . This defines in LRL the notion of free atoms FA ( e ) , bound atoms BA ( e ) in expression e , and all atoms AT ( e ) in e . For an environment env = { a .e , . . . , a n .e n } ,we define the set of letrec-atoms as LA ( env ) = { a , . . . , a n } . We say a is fresh for e iff a FA ( e ) (also denoted as a e ). As an example, the expression ( letrec a. cons s b ; b.cons s a in a ) repre-sents an infinite list ( cons s ( cons s ( cons s ( cons s . . . )))) , where s , s are expressions. Thefunctional application operator in functional languages (which is usally implicit) can be encoded bya binary function app , which also allows to deal with partial applications. Our language LRL is afragment of core calculi [18, 19], since for example the case-construct is missing, but this could alsobe represented. For more programming examples the reader may consult the functional programminglanguages literature and web-sites.We will use mappings on atoms from A . A swapping ( a b ) is a bijective function (on LRL -expressions) that maps an atom a to atom b , atom b to a , and is the identity on other atoms. Wewill also use finite permutations π on atoms from A , which could be represented as a compositionof swappings in the algorithms below. Let dom ( π ) = { a ∈ A | π ( a ) = a } . Then every finitepermutation can be represented by a composition of at most ( | dom ( π ) | − swappings. Composition π ◦ π and inverse π − can be immediately computed, where the complexity is polynomial in the sizeof dom ( π ) . Permutations π operate on expressions simply by recursing on the structure. For a letrec-expression this is π · ( letrec a .s ; . . . ; a n .s n in e ) = ( letrec π · a .π · s ; . . . ; π · a n .π · s n in π · e ) .Note that permutations also change names of bound atoms.We will use the following definition (characterization) of α -equivalence: Definition 3.1.
The α -equivalence ∼ on expressions e ∈ LRL is defined as follows:• a ∼ a .• if e i ∼ e ′ i for all i , then ( f e . . . e n ) ∼ ( f e ′ . . . e ′ n ) for an n -ary f ∈ F .• If e ∼ e ′ , then λa.e ∼ λa.e ′ . . Schmidt-Schauss et al. / Nominal Unification with Recursive Let • If a e ′ and e ∼ ( a b ) · e ′ , then λa.e ∼ λb.e ′ .• If there is a permutation π on atoms such that – dom ( π ) ⊆ { a , . . . , a n } ∪ { b , . . . , b n } , where a i = a j and b i = b j for all i = j , – π ( b i ) = a i for all i , – { a , . . . , a n } letrec b .t , . . . , b n .t n in r ′ ) , and – r ∼ π ( r ′ ) and s i ∼ π ( t i ) for i = 1 , . . . , n hold.Then ( letrec a .s , . . . , a n .s n in r ) ∼ ( letrec b .t , . . . , b n .t n in r ′ ) .The last phrase includes that ( letrec a .s , . . . , a n .s n in r ) ∼ ( letrec b ρ (1) .t ρ (1) , . . . , b ρ ( n ) .t ρ ( n ) in r ′ ) .for every permutation ρ on { , . . . , n } , by the definition of syntactic equality.Note that ∼ is identical to α -equivalence, i.e. the relation generated by renamings of bindingconstructs and permutation of bindings in a letrec. We omit a proof, since it detracts the attention fromthe main contents. Such a proof is not hard to construct by using that α -equivalence holds, if and onlyif the graph constructed by replacing bindings by pointing edges, where the outgoing edges from anenvironment are unordered and the one from a function application are ordered.A nice and important property that is often implicitly used is: e ∼ e is equivalent to π · e ∼ π · e for any (atom-)permutation π .In usual nominal unification, the solutions of fixpoint equations X . = π · X , i.e. the sets { e | π · e ∼ e } can be characterized by using finitely many freshness constraints [6]. Clearly, all these sets andalso all finite intersections are nonempty, since at least fresh atoms are elements and since A is infinite.However, in our setting, these sets are nontrivial: Example 3.2.
The α -equivalence ( a b ) · ( letrec c.a ; d.b in True ) ∼ ( letrec c.a ; d.b in True ) holds, which means that there are expressions t in LRL with t ∼ ( a b ) · t and FA ( t ) = { a, b } . This isin contrast to usual nominal unification. Below we will use the results on complexity of operations in finite permutation groups, see [38, 39].We summarize some facts on the so-called symmetric group and its properties. We consider a set { o , . . . , o n } of distinct objects o i (in our case atoms), and the symmetric group Σ( { o , . . . , o n } ) (ofsize n ! ) of permutations of these objects. We will also look at its elements, subsets and subgroups.Subgroups of Σ( { o , . . . , o n } ) can always be represented by a set of generators (represented as per-mutations on { o , . . . , o n } ). If H is a set of elements (or generators), then h H i denotes the generatedsubgroup of Σ( { o , . . . , o n } ) . Some facts are:• A permutation can be represented in space linear in n .• Every subgroup of Σ( { o , . . . , o n } ) can be represented by ≤ n generators.However, elements in a subgroup may not be representable as a product of polynomially many of thesegenerators.The following questions can be answered in polynomial time: M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let { a b } ·∪∇∇ if a = b { a f s . . . s n ) } ·∪∇{ a s , . . . , a s n } ∪ ∇ { a λa.s ) } ·∪∇∇ { a λb.s ) } ·∪∇{ a s } ∪ ∇ if a = b { a letrec a .s ; . . . , a n .s n in r ) } ·∪∇∇ if a ∈ { a , . . . , a n } { a a } ·∪∇⊥{ a letrec a .s ; . . . , a n .s n in r ) } ·∪∇{ a s , . . . a s n , a r } ∪ ∇ if a
6∈ { a , . . . , a n } { a π · X ) } ·∪∇{ π − ( a ) X } ∪ ∇ Figure 1. Simplification of freshness constraints in
LRLX • The element-question: π ∈ G .• The subgroup question: G ⊆ G .However, intersection of groups and set-stabilizer (i.e. { π ∈ G | π ( M ) = M } ) are not known tobe computable in polynomial time, since those problems are as hard as graph-isomorphism (see [38]).
4. A Nominal Letrec Unification Algorithm
As an extension of
LRL , there is a countably infinite set of (unification) variables
Var ranged over by
X, Y where we also use indices. The syntax of the language
LRLX ( L et R ec L anguage e X tended) is e ::= a | X | π · X | λa.e | ( f e . . . e ar ( f ) ) | ( letrec a .e ; . . . ; a n .e n in e ) Var ( e ) is the set of variables X occurring in e .The expression π · e for a non-variable e means an operation, which is performed by shifting π down, using the additional simplification π · ( π · e ) → ( π ◦ π ) · e , where after the shift, π only occursin the subexpressions of the form π · X , which are called suspensions . Usually, we do not distinguish X and Id · X , notationally. A freshness constraint in our unification algorithm is of the form a e ,where e is an LRLX -expression, and an atomic freshness constraint is of the form a X . Lemma 4.1.
The rules in Fig. 1 for simplifying sets of freshness constraints in
LRLX run in poly-nomial time and the result is either ⊥ , i.e. fail, or a set of freshness constraints where all singleconstraints are atomic. This constitutes a polynomial decision algorithm for satisfiability of ∇ : If ⊥ is in the result, then unsatisfiable, otherwise satisfiable.We can assume in the following algorithms that sets of freshness constraint are immediately simplified.In the following we will use Var (Γ , ∇ ) , and Var (Γ , e ) and similar notation for the set of (unification-)variables occurring in the syntactic objects mentioned in the brackets. Definition 4.2. An LRLX -unification problem is a pair (Γ , ∇ ) , where Γ is a set of equations { s . = t , . . . , s n . = t n } , and ∇ is a set of freshness constraints { a X , . . . , a m X m } . A (ground) solution . Schmidt-Schauss et al. / Nominal Unification with Recursive Let of (Γ , ∇ ) is a substitution ρ (mapping variables in Var (Γ , ∇ ) to ground expressions), such that s i ρ ∼ t i ρ , for i = 1 , . . . , n , and a j X j ρ ) , for j = 1 , . . . , m .The decision problem is whether there is a ground solution for a given (Γ , ∇ ) or not. Definition 4.3.
Let (Γ , ∇ ) be an LRLX -unification problem. We consider triples ( σ, ∇ ′ , FIX ) asrepresenting general unifiers, where σ is a substitution (compressed as a DAG (directed acyclic graph))mapping variables to LRLX -expressions, ∇ ′ is a set of freshness constraints, and FIX is a set offixpoint equations of the form π ′ · X . = π · X , where X dom ( σ ) .A triple ( σ, ∇ ′ , FIX ) is a unifier of (Γ , ∇ ) , if(i) there exists a ground substitution ρ that solves ( ∇ ′ σ, FIX ) , i.e., for every a X in ∇ ′ , a Xσρ is valid, and for every fixpoint equation π ′ · X . = π · X ∈ FIX , it holds π ′ · ( Xρ ) ∼ π · ( Xρ ) ; and(ii) for every ground substitution ρ that instantiates all variables in V ar (Γ , ∇ ) and which solves ( ∇ ′ σ, FIX ) , the ground substitution σρ is a solution of (Γ , ∇ ) .A set M of unifiers is complete , if every solution µ is covered by at least one unifier, i.e., there is someunifier ( σ, ∇ ′ , FIX ) in M , and a ground substitution ρ , such that Xµ ∼ Xσρ for all X ∈ Var (Γ , ∇ ) .We will employ nondeterministic rule-based algorithms computing unifiers: There are clearlyindicated disjunctive (don’t know nondeterministic) rules, and all other rules are don’t care nondeter-ministic. This distinction is related to the completeness of the solution algorithms: don’t care meansthat the rule has several possibilities where it is sufficient for completeness to take only one. On theother hand, don’t know means that for achieving completeness, every possibility of the rule has to beexplored. The collecting variant of the algorithm runs and collects all solutions from all alternativesof the disjunctive rule(s). The decision variant guesses and verifies one possibility and tries to detectthe existence of a single unifier.Since we want to avoid the exponential size explosion of the Robinson-style unification, keep-ing the good properties of Martelli Montanari-style algorithms [26], we stick to a set of equations asdata structure. As a preparation for the algorithm, all expressions in equations are exhaustively flat-tened as follows: ( f t . . . t n ) → ( f X . . . X n ) plus the equations X . = t , . . . , X n . = t n . Also λa.s is replaced by λa.X with equation X . = s , and ( letrec a .s ; . . . , a n .s n in r ) is replaced by ( letrec a .X ; . . . , a n .X n in X ) with the additional equations X . = s ; . . . ; X n . = s n ; X . = r . Theintroduced variables X i , X are fresh ones. Thus, all expressions in equations are of depth at most 1,not counting the permutation applications in the suspensions.In the notation of the rules, we use [ e/X ] as substitution that replaces X by e , whereas { X → t } isused for constructing a syntactically represented substitution. In the written rules, we may omit ∇ or θ if they are not changed. We will use a notation “ | ” in the consequence part of a rule, usually with a setof possibilities, to denote disjunctive (i.e. don’t know) nondeterminism. The only nondeterministicrule that requires exploring all alternatives is rule (6). The other rules can be applied in any order,where it is not necessary to explore alternatives. M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let (1) Γ ·∪{ e . = e } , ∇ , θ Γ , ∇ , θ (2) Γ ·∪{ π · X . = π · Y } , ∇ , θ Y = X Γ[ π − π · Y /X ] , ∇ [ π − π · Y /X ] , θ ∪ { X π − π · Y } (3) Γ ·∪{ ( f s . . . s n ) . = ( f s ′ . . . s ′ n ) } , ∇ , θ Γ ∪ { s . = s ′ , . . . , s n . = s ′ n } , ∇ , θ (4) Γ ·∪{ λa.s . = λa.t } , ∇ , θ Γ ∪ { s . = t } , ∇ , θ (5) Γ ·∪{ λa.s . = λb.t } , ∇ , θ a = b Γ ∪ { s . = ( a b ) · t } , ∇ ∪ { a t } , θ (6) Γ ·∪{ letrec a .s ; . . . ; a n .s n in r . = letrec b .t ; . . . ; b n .t n in r ′ } , ∇ , θ (cid:12)(cid:12)(cid:12) ∀ ρ (Γ ∪ { s . = π · t ρ (1) , . . . , s n . = π · t ρ ( n ) , r . = π · r ′ } , ∇ ∪ { a i letrec b .t ; . . . ; b n .t n in r ′ ) | i = 1 , . . . , n } , θ ) where ρ is a permutation on { , . . . , n } and π is an (atom-)permutation that extends { b ρ ( i ) a i | i = 1 , . . . , n ) } with dom ( π ) ⊆ { a , . . . , a n , b , . . . , b n } Figure 2. Standard (1,2) and decomposition rules (3,4,5,6) L ETREC U NIFY
The top symbol of an expression is defined as tops ( f s . . . s n ) = f , tops ( a ) = a , tops ( λa.s ) = λ ,and tops ( letrec env in s ) = ( letrec , n ) , where n is the number of bindings in env . It is undefinedfor variables X . Definition 4.4.
The rule-based algorithm L
ETREC U NIFY is defined in the following. Its rules are inFigs. 2, 3 and 4. L
ETREC U NIFY operates on a tuple (Γ , ∇ , θ ) , where Γ is a set of flattened equations e . = e , and where we assume that . = is symmetric, ∇ contains freshness constraints, and θ representsthe already computed substitution as a list of mappings of the form X e . Initially θ is empty.The final state will be reached, i.e. the output, when Γ only contains fixpoint equations of the form π · X . = π · X that are non-redundant, and the rule (Output) fires. Note that the rule (FPS) representsthe usual solution rule if the premise is only a single equation.The rules (1)–(6), and (ElimFP) have highest priority; then (MMS) and (FPS). The rule (Output)(lowest priority) terminates an execution on Γ by outputting a unifier ( θ, ∇ ′ , FIX ) .We assume that the algorithm L ETREC U NIFY halts if a failure rule (see Fig.4) is applicable.Note that the two rules (MMS) and (FPS), without further precaution, may cause an exponentialblow-up in the number of fixpoint-equations (see Example 4.6). The rule (ElimFP) will bound thenumber of generated fixpoint equations by exploiting knowledge on operations within permutationgroups.Note that the application of every rule can be done in polynomial time. In particular rule (FailFS),since the computation of FA (( X ) θ ) can be done in polynomial time by iterating over the solutioncomponents. . Schmidt-Schauss et al. / Nominal Unification with Recursive Let (MMS) Γ ·∪{ π · X . = e , π · X . = e } , ∇ Γ ∪ { π · X . = e } ∪ Γ ′ , ∇ ∪ ∇ ′ , if e , e are not suspensions, where Γ ′ is theset of equations generated by decomposing π − · e . = π − · e using (3)–(6), and where ∇ ′ is the corresponding resulting set of freshnessconstraints.(FPS) Γ ·∪{ π · X . = π ′ · X, . . . , π n · X . = π ′ n · X, π · X . = e } , θ Γ ∪ { π π − · e . = π ′ π − · e, . . . , π n π − · e . = π ′ n π − · e } , θ ∪ { X π − · e } ,If neither X ∈ Var (Γ , e ) , nor e is a suspension, nor (Cycle) (see Fig.4) is applicable.(ElimFP) Γ ·∪{ π · X . = π ′ · X, . . . , π n · X . = π ′ n · X, π · X . = π ′ · X } , θ Γ ∪ { π · X . = π ′ · X, . . . , π n · X . = π ′ n · X } , θ ,If π − π ′ ∈ h π − π ′ , . . . , π − n π ′ n i . (Output) Γ , ∇ , θ ( θ, ∇ , Γ) if Γ only consists of fixpoint-equations. Figure 3. Main Rules of L
ETREC U NIFY (Clash) Γ ·∪{ s . = t } , ∇ , θ tops ( s ) = tops ( t ) and s and t are not suspensions ⊥ (Cycle) If π · X . = s , . . . , π n · X n . = s n in Γ where s i are not suspensionsand X i +1 occurs in s i for i = 1 , . . . , n − and X occurs in s n . ⊥ (FailF) a a ∈ ∇⊥ (FailFS) a X ∈ ∇ and a occurs free in ( Xθ ) ⊥ Figure 4. Failure Rules of L
ETREC U NIFY
Example 4.5.
We illustrate the letrec-rule by a ground example without flattening. Let the equationbe: ( letrec a. ( a, b ) , b. ( a, b ) in b ) . = ( letrec b. ( b, c ) , c. ( b, c ) in c ) . Select the identity (position-)permutation ρ , which results in: π = { b a ; c b ; a c } , where the third binding a c isirrelevant, but unique in this case.Decomposition of the equations ( a, b ) . = π · ( b, c ) , ( a, b ) . = π · ( b, c ) , b . = π · c } is possible without failand yields only trivial equations.The freshness constraint is { a, b } letrec b. ( b, c ) , c. ( b, c ) in c ) , which holds. Example 4.6.
This example shows that FPS (together with the standard and decomposition rules) maygive rise to an exponential number of equations in the size of the original problem. Let there be vari-ables X i , i = 1 , . . . , n and the equations Γ = { X n . = π · X n , X n . = ( f X n − ρ n · X n − ) , . . . , X . =( f X ρ · X ) } where π, ρ , . . . , ρ n are permutations. We prove that this unification problem may giverise to n − equations, if the redundancy rule (ElimFP) is not there. M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
The first step is by (FPS): ( f X n − ρ n · X n − . = π · ( f X n − ρ n · X n − ) ,X n − . = ( f X n − ρ n − · X n − ) , . . . ) Using decomposition and inversion: X n − . = π · X n − ,X n − . = ρ − n · π · ρ n · X n − ,X n − . = ( f X n − ρ n − · X n − ) , . . . After (FPS): ( f X n − ρ n − · X n − ) . = π · ( f X n − ρ n − · X n − ) , ( f X n − ρ n − · X n − ) . = ρ − n · π · ρ n · ( f X n − ρ n − · X n − ) ,X n − . = ( f X n − ρ n − · X n − ) , . . . Decomposition and inversion: X n − . = π · X n − ,X n − . = ρ − n − · π · ρ n − · X n − ,X n − . = ρ − n · π · ρ n · X n − ,X n − . = ρ − n − · ρ − n · π · ρ n · ρ n − · X n − ,X n − . = ( f X n − ρ n − · X n − ) , . . . Now it is easy to see that all equations X . = π ′ · X are generated, with π ′ ∈ { ρ − πρ where ρ is a com-position of a subsequence of ρ n , ρ n − , . . . , ρ } , which makes n − equations. The permutations arepairwise different using an appropriate choice of ρ i and π . The starting equations can be constructedusing the decomposition rule of abstractions.
5. Soundness, Completeness, and Complexity of L ETREC U NIFY
First we show that a restricted problem class of nominal letrec unification is already NP-hard. If theequations for unification are of the form s . = t , . . . , s n . = t n , and the expressions t i do not containvariables X i , then this is a nominal letrec-matching problem (see also Section 6). Theorem 5.1.
Nominal letrec matching (hence also unification) in
LRL is NP -hard, for two letrecexpressions, where subexpressions are free of letrec. Proof:
We encode the NP -hard problem of finding a Hamiltonian cycle in a 3-regular graph [40, 41], whichare graphs where all nodes have the same degree k = 3 . Let G be a graph, a , . . . , a n be thevertexes of the graph G , and E be the set of edges of G . The first environment part is env = a . ( node a ); . . . ; a n . ( node a n ) , and a second environment part env consists of bindings b. ( f a a ′ ) and b ′ . ( f a ′ a ) for every edge ( a, a ′ ) ∈ E for fresh names b, b ′ . Then let t := ( letrec env ; env in which is intended to represent the graph. Let the second expression encode the question whetherthere is a Hamiltonian cycle in a regular graph as follows: The first part of the environment is env ′ = . Schmidt-Schauss et al. / Nominal Unification with Recursive Let a . ( node X ) , . . . , a n . ( node X n ) . The second part is env ′ consisting of b . ( f X X ); b . ( f X X ); . . . ; b n . ( f X n X ) ,where all b i are different atoms, and the third part env ′ consists of a number of (dummy) entries ofthe form b. ( f Z Z ′ ) , where b is always a fresh atom for every binding, and Z, Z ′ are fresh variablesfor every entry. The number of these dummy entries can be computed as ∗ n − n due to the assump-tion that the degree of G is . Let s := ( letrec env ′ ; env ′ ; env ′ in , representing the questionof the Hamiltonian cycle existence. Then the matching problem s ✂ t is solvable iff the graph has aHamiltonian cycle. The degree is , hence it is not possible that there are shortcuts in the cycle. ⊓⊔ L ETREC U NIFY
We will use size (Γ) for estimating the runtime of L
ETREC U NIFY , which is the sum of the sizes ofthe equated expressions, and where the size of an expression is its size as a term tree, without size ofnames. We do not count the size of permutations.
Theorem 5.2.
The decision variant of the algorithm L
ETREC U NIFY runs in nondeterministic polyno-mial time. Its collecting version returns a complete set of at most exponentially many unifiers, everyone represented in polynomial space. The number of rule applications is O ( S log( S )) where S is thesize of the input. Proof:
Let Γ , ∇ be the input, where Γ is assumed to be flattened, and S all be size (Γ , ∇ ) . We use S = size (Γ ) to argue on the number of steps of L ETREC U NIFY . The execution of a single rule canbe done in polynomial time depending on the size of the intermediate state, thus we have to show thatthe size of the intermediate states remains polynomial and that the number of rule applications is atmost polynomial.The number of fixpoint-equations for every variable X is at most S ∗ log( S ) since the numberof atoms is never increased, and since we assume that (ElimFP) is applied whenever possible. Thesize of the permutation group on the set of all atoms in the input is at most S ! , and so the lengthof proper subset-chains and hence the maximal number of (necessary) generators of a subgroup is atmost log( S !) ≤ S ∗ log( S ) . The redundancy of generators can be tested in polynomial time dependingon the number of atoms. Note also that applicability of (ElimFP) can be tested in polynomial time bychecking the maximal possible subsets.The lexicographically ordered termination measure ( , λ FA , is used:1. is the number of different variables in Γ ,2. λ FA is the number of letrec-, λ , function-symbols and atoms in Γ , but not in permutations,3. is the number of equations in Γ .Since shifting permutations down and simplification of freshness constraints both terminate inpolynomial time, and do not increase the measures, we only compare states which are normal formsfor shifting down permutations and simplifying freshness constraints. The following table shows theeffect of the rules: M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
The entries + m represents an increase of at most m in the relevant measure component. This formof table permits an easy check that the complexity of a single run is polynomial. Note that we omitthe failure rules in th table, since these stop immediately. λ FA < ≤ < (FPS) < +2 S log( S ) < (MMS) = < +2 S (3) , (4) , (5) , (6) = < + S (ElimFP) = = < (1) ≤ ≤ < The table shows that every rule application strictly decreases the lexicographic measure as a com-bination of the three basic measures. The entries can be verified by checking the rules, and using theargument that there are not more than S log( S ) fixpoint equations for a single variable X . We use thetable to argue on the (overall) number of rule applications and hence the complexity: The rules (2) and(FPS) strictly reduce the number of variables in Γ and can be applied at most S times. (FPS) increasesthe second measure at most by ∗ S log( S ) , since the number of symbols may be increased as oftenas there are fixpoint-equations and there are at most S log( S ) . Since no other rule increases the mea-sure, λ FA will never be greater than S log( S ) . The rule (MMS) strictly decreases λ FA .Hence , i.e. the number of equations is bounded by S log( S ) . Thus, the number of rule appli-cations is O ( S log( S )) .The complexity of applications of single rules is polynomial, in particular (FPS), see Section 3.2. Thecomplexity of the constraint simplification (Lemma 4.1) is also polynomial. We also have to argue onthe failure rules. These detect all fail cases, and the size of the state part ∇ remains polynomial. Thechecks within the failure rules can be done in polynomial time in S all , where the argument for polyno-miality of the check in (FailFS) is an algorithm that iteratively applies parts of θ and checks. ⊓⊔ Theorem 5.3.
The algorithm L
ETREC U NIFY is sound and complete.
Proof:
Soundness of the algorithm holds, by easy arguments for every rule, similar as in [6], and since theletrec-rule follows the definition of ∼ in Def. 3.1. A further argument is that the failure rules aresufficient to detect states without solutions.Completeness requires more arguments. The decomposition and standard rules, with the exceptionof rule (6), retain the set of solutions. The same for (MMS), (FPS), and (ElimFP). Note that thenondeterminism in (ElimFP) does not affect completeness. The nondeterministic rule (6) provides allpossibilities for potential ground solutions. Moreover, the failure rules are not applicable to states thatare solvable.A final output of L ETREC U NIFY for a solvable input has at least one ground solution as instance:we can instantiate all variables that remain in Γ out by a fresh atom. Then all fixpoint equations aresatisfied, since the permutations cannot change this atom, and since the (atomic) freshness constraints . Schmidt-Schauss et al. / Nominal Unification with Recursive Let hold. This ground solution can be represented in polynomial space by using θ , plus an instance X a for all remaining variables X and a fresh atom a , and removing all fixpoint equations and freshnessconstraints. ⊓⊔ Theorem 5.4.
The nominal letrec-unification problem is NP -complete. Proof:
This follows from Theorems 5.2 and 5.3, and Theorem 5.1. ⊓⊔
6. Nominal Matching with Letrec: L ETREC M ATCH
Reductions using reductions rules of the form l → r in higher order calculi with letrec, in particularon a meta-notation, require a matching algorithm, matching the rules’ left hand side to an expressionor subexpression that is to be reduced. For the application it is sufficient if the instance of the righthand side rσ is ground and the variable convention holds for rσ . Example 6.1.
Consider the (lbeta)-rule, which is the version of (beta) used in call-by-need calculiwith sharing [42, 18, 19]. Note that only the sharing power of the recursive environment is used here. ( lbeta ) ( λx.e ) e → letrec x.e in e . An (lbeta) step, for example, on ( λx.x ) ( λy.y ) is performed by representing the target in LRL and thebeta-rule in the language LRLX, where e , e are represented as variables X , X , and then matching ( app ( λc.X ) X ) ✂ ( app ( λa.a ) ( λb.b )) , where app is the explicit representation of the binary appli-cation operator. This results in σ := { X c ; X λb.b } , and the reduction result is the σ -instanceof ( letrec c.X in X ) , which is ( letrec c. ( λb.b ) in c ) . Note that this form of reduction sequencespermits α -equivalence as intermediate steps.We derive a nominal letrec matching algorithm as a specialization of L ETREC U NIFY . We usenon symmetric equations written s ✂ t , where s is an LRLX -expression, and t does not containvariables. Note that neither freshness constraints nor suspensions are necessary (and hence no fixpointequations) in the solution. We assume that the input is a set s ✂ t , . . . , s n ✂ t n of match equationsof expressions, where for all i : s i may contain variables, and t i is ground. Definition 6.2.
The rules of the nondeterministic algorithm L
ETREC M ATCH are in Fig. 5.The test e ∼ e may for example be performed as a subroutine call to this (nondeterministic)matching procedure in the collecting version, i.e. the test succeeds if there is a nondeterministicexecution with success as result. Standard arguments show: Theorem 6.3. L ETREC M ATCH is sound and complete for nominal letrec matching. It decides nom-inal letrec matching in nondeterministic polynomial time. Its collecting version returns a finite com-plete set of an at most exponential number of matching substitutions, which are of at most polynomialsize.
M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let Γ ·∪{ e ✂ e } Γ Γ ·∪{ ( f s . . . s n ) ✂ ( f s ′ . . . s ′ n ) } Γ ∪ { s ✂ s ′ , . . . , s n ✂ s ′ n } Γ ·∪{ λa.s ✂ λa.t } Γ ∪ { s ✂ t } Γ ·∪{ λa.s ✂ λb.t a t } Γ ∪ { s ✂ ( a b ) · t } Γ ·∪{ π · X ✂ e } Γ ∪ { X ✂ π − · e } Γ ·∪{ X ✂ e , X ✂ e e ∼ e } Γ ∪ { X ✂ e } Γ ·∪{ letrec a .s ; . . . ; a n .s n in r ✂ letrec b .t ; . . . ; b n .t n in r ′ }| ∀ ρ Γ ∪ { s ✂ π · t ρ (1) , . . . , s n ✂ π · t ρ ( n ) , r ✂ π · r ′ } where ρ is a permutation on { , . . . , n } , and π is an (atom-) permutation that ex-tends { b ρ ( i ) a i | i = 1 , . . . , n ) } with dom ( π ) ⊆ { a , . . . , a n , b , . . . , b n } , and { a i letrec b .t ; . . . ; b n .t n in r ′ ) | i = 1 , . . . n } s ✂ t ∈ Γ , and s is not a suspension, but tops ( s ) = tops ( t ) ⊥ Γ ·∪{ λa.s ✂ λb.t not ( a t ) }⊥ Γ ·∪{ X ✂ e , X ✂ e e e }⊥ Figure 5. Rules of the matching algorithm L
ETREC M ATCH
Theorem 6.4.
Nominal letrec matching is NP-complete.
Proof:
The problem is in NP, which follows from Theorem 6.3. It is also NP-hard, which follows fromTheorem 5.1. ⊓⊔ A slightly more general situation for nominal letrec matching occurs, when the matching equations Γ are compressed using a DAG. We construct a practically more efficient algorithm L ETREC D AG -M ATCH from L
ETREC U NIFY as follows. First we generate Γ from Γ , which only contains flattenedexpressions by encoding the DAG-nodes as variables together with a unification equation. An expres-sion is said Γ -ground, if it does not reference variables from Γ (also via equations). In order to avoidsuspension (i.e. to have nicer results), the decomposition rule for λ -expressions with different bindernames is modified as follows : Γ ·∪ ( λa.s . = λb.t } , ∇ Γ ∪ { s . = ( a b ) · t } , ∇ ∪ { a t } λb.t is Γ -groundThe extra conditions a t and Γ -ground can be tested in polynomial time. The equations Γ areprocessed applying L ETREC U NIFY (with the mentioned modification) with the guidance that the right-hand sides of match-equations are also right-hand sides of equations in the decomposition rules. Theresulting matching substitutions can be interpreted as the instantiations into the variables of Γ . Since Γ is a matching problem, the result will be free of fixpoint equations, and there will be no freshnessconstraints in the solution. Thus we have: . Schmidt-Schauss et al. / Nominal Unification with Recursive Let
Theorem 6.5.
The collecting variant of L
ETREC D AG M ATCH outputs an at most exponential set ofDAG-compressed substitutions that is complete, where every unifier is represented in polynomialspace.
7. Graph-Isomorphism-Hardness of Nominal Letrec Matching and Uni-fication without Garbage
First we clarify the notion of garbage, which is a notion from a programming language point of view.
Definition 7.1.
We say that an expression t contains garbage , iff there is a subexpression ( letrec env in r ) ,and the environment env can be split into two environments env = env ; env , such that env (thegarbage) is not trivial, and the atoms from LA ( env ) occur neither free in env nor in r . Otherwise,the expression is free of garbage (or garbage-free ).Since α -equivalence of LRL -expressions is Graph-Isomorphism-complete [37], but α -equivalenceof garbage-free LRL -expressions is polynomial, it is useful to look for improvements of unificationand matching for garbage-free expressions.As a remark: Graph-Isomorphism is known to have complexity between
PTIME and NP . Thereare arguments that it is weaker than the class of NP-complete problems [43]. There is also a claim thatit is quasi-polynomial [44], which means that it requires less than exponential time.We will show that even very restricted nominal letrec matching problems are Graph-Isomorphismcomplete, which makes it very unlikely that there is a polynomial algorithm. Theorem 7.2.
Nominal letrec matching with one occurrence of a single variable and a garbage-freetarget expression is Graph-Isomorphism-hard.
Proof:
Let G , G be two regular graphs with degree ≥ . Let t be ( letrec env in g b . . . , b m ) theencoding of an arbitrary graph G where env is the encoding as in the proof of Theorem 5.1, nodesare encoded as a . . . a n , and the edge-binders are b i . Then t is free of garbage. Let the environment env be the encoding of G in s = ( letrec env in X ) . Then s matches t iff the graphs G , G areisomorphic. Since the graph-isomorphism problem for regular graphs of degree ≥ is GI-hard [45],we have GI -hardness. If there is an isomorphism of G and G , then it is easy to see that this bijectionleads to an equivalence of the environments, and we can instantiate X with ( g b . . . , b m ) . ⊓⊔
8. On Fixpoints and Garbage
We will show in this section that
LRLX -expressions without garbage only have trivial fixpointing per-mutations. Looking at Example 3.2, the α -equivalence ( a b ) · ( letrec c.a ; d.b in True ) ∼ ( letrec c.a ; d.b in True ) holds, where dom (( a b )) ∩ FA ( letrec c.a ; d.b in True ) = { a, b } 6 = ∅ . However,we see that the complete environment in this example is garbage (Def. 7.1).As a helpful information, we write the α -equivalence-rule for letrec-expressions in the groundlanguage LRL as an extension of the rule for lambda-abstractions.
M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let r ∼ π · r ′ , s i ∼ π · t ρ ( i ) , i = 1 , . . . , n, M letrec b .t ; . . . ; b n .t n in r ′ ) letrec a .s ; . . . ; a n .s n in r ∼ letrec b .t ; . . . ; b n .t n in r ′ where ρ is a permutation on { , . . . , n } , M = { a , . . . , a n } \ { b , . . . , b n } , and π is asmallest atom-permutation-extension of the bijective function { b i a ρ ( i ) , i = 1 , . . . , n } such that dom ( π ) ⊆ ( { b , . . . , b n } ∪ { a , . . . , a n } ) .Note that α -equivalence of s, t means structural equivalence of s, t as trees, and a justificationalways comes with a bijective relation between the positions of s, t where only the names of atoms atnodes may be different.A further example of garbage is ( letrec a. b. in ( f b )) , where a is unused, but b is used in theright hand side. In this case a. is garbage. Another example is e := ( letrec a.d ; b. c.d in ( f b )) ,which is an example with a free atom d , and the garbage consists of two bindings, { a.d ; c.d } . It is α -equivalent to ( letrec a ′ .d ; b. c ′ .d in ( f b )) =: e ′ . Note that in this case, there are two differentpermutations (bijective functions) mapping e ′ to (the α -equivalent) e : { a ′ a ; c ′ c } and { a ′ c ; c ′ a } .The next lemma shows that this situation is only possible if the expressions contain garbage. Lemma 8.1. If s ∼ t , and s is free of garbage, then α -equivalence provides a unique correspondenceof the positions of s and t . Proof:
The proof is by induction on the structure and size of expressions. For the structure, the only nontrivialcase is letrec: Let s = ( letrec a .e , . . . , a n .e n in e ) ∼ ( letrec b .f , . . . , b n .f n in f ) = t . Notethat due to syntactic equality all permutations of the environments are also to be considered. Thenthere is bijective mapping ϕ , with ϕ ( b i ) = a ρ ( i ) , i = 1 , . . . , n , where ρ is a permutation on { , . . . , n } ,and such that e i ∼ ϕ ( f ρ ( i ) ) , i = 1 , . . . , n , e ∼ ϕ ( f ) , and ( { a , . . . , a n } \ { b , . . . , b n } ) t holds. Let ϕ be the atom-permutation that extends ϕ , mapping ( { a , . . . , a n } \ { b , . . . , b n } ) to ( { b , . . . , b n } \{ a , . . . , a n } ) .The induction hypothesis implies a unique position correspondence of e and f , since e ∼ ϕ ( f ) .This implies that the bindings for { a , . . . , a n } ∩ FA ( e ) have a unique correspondence to the bindingsin t . This is continued by exhaustively following free occurrences of atoms a i in the right hand sidesof the top bindings in s . Since there is no garbage in s , all bindings can be reached by this process,hence we have uniqueness of the correspondence of positions. ⊓⊔ Proposition 8.2.
Let e be an expression that does not have garbage, and let π be a permutation. Then π · e ∼ e implies dom ( π ) ∩ FA ( e ) = ∅ . Proof:
The proof is by induction on the size of the expression.• If e is an atom, then this is trivial.• If e = f e . . . .e n , then no e i contains garbage, and π · e i ∼ e i implies dom ( π ) ∩ FA ( e i ) = ∅ ,hence also dom ( π ) ∩ FA ( e ) = ∅ . . Schmidt-Schauss et al. / Nominal Unification with Recursive Let • If e = λa.e ′ , then there are two cases:1. π ( a ) = a . Then π · e ′ ∼ e ′ , and we can apply the induction hypothesis.2. π ( a ) = b = a . Then ( a b ) · π fixes e ′ , and b e ′ . The induction hypothesis implies dom (( a b ) · π ) ∩ FA ( e ′ ) = ∅ . We have dom ( π ) ⊆ dom (( a b ) · π )) ∪ { a, b } , hence dom ( π ) ∩ FA ( λa.e ′ ) = ∅ .• First a simple case with one binding in the environment: t = ( letrec a .e in e ) , π · t ∼ t . If π ( a ) = a , then π · ( e, e ) ∼ ( e, e ) , and the induction hypothesis implies dom ( π ) ∩ FA ( e, e ) = ∅ , which in turn implies dom ( π ) ∩ FA ( t ) = ∅ .If π ( a ) = b = a , then b e, e ) and for π ′ := ( a b ) · π , it holds π ′ · ( e, e ) ∼ ( e, e ) , andso dom (( a b ) · π ) ∩ FA ( e, e ) = ∅ . since dom ( π ) ⊆ dom (( a b ) · π ) ∪ { a , b } , we obtain dom ( π ) ∩ t = ∅ . In the case of one binding, it is irrelevant whether the binding is garbage ornot.• Let t = ( letrec a .e ; . . . ; a n .e n in e ) , and t is a fixpoint of π , i.e. π ( t ) ∼ t . Notethat no part of the environment is garbage. The permutation π can be split into π = π · π ,where dom ( π ) ⊆ FA ( t ) and dom ( π ) ∩ FA ( t ) = ∅ . From t ∼ π · t and Lemma 8.1 weobtain that there is a unique permutation ρ on { , . . . , n } , such that there is an injective map-ping ϕ : π ( a ) a ρ (1) , . . . , π ( a n ) a ρ ( n ) , and e ∼ ϕπ ( e ) , e ρ ( i ) ∼ ϕπ ( e i ) . Then α -equivalence implies that ϕπ can be extended to a atom-permutation ϕπ by mapping theatoms in { a , . . . , a n } \ { π ( a ) , . . . , π ( a n ) } bijectively to { π ( a ) , . . . , π ( a n ) } \ { a , . . . , a n } .By the freshness constraints for α -equivalences of letrec-expressions, ϕπ ( e ) = ϕπ ( e ) and ϕπ ( e i ) = ϕπ ( e i ) which in turn implies that e ∼ ϕπ ( e ) and e i ∼ ϕπ ( i e ) , and we can apply theinduction hypothesis.This shows that FA ( e ) \ { a , . . . , a n } are not moved by ϕπ , and the same for all e i , hence thisalso holds for t . ⊓⊔ Corollary 8.3.
Let e be an expression that does not have garbage, and let π be a permutation. Then π · e ∼ e is equivalent to dom ( π ) ∩ FA ( e ) = ∅ . Proof:
This follows from Proposition 8.2. The other direction is easy. ⊓⊔ The proof also shows a slightly more general statement:
Corollary 8.4.
Let e be an expression such that in all environments with at least two bindings there areno garbage bindings, and let π be a permutation. Then π · e ∼ e is equivalent to dom ( π ) ∩ FA ( e ) = ∅ .In case that the input does not represent garbage-parts, and the semantics is defined such that onlyground garbage free expressions are permitted, the set of rules in the case without atom-variables canbe optimized as follows: (ElimFP) can be omitted and instead of (FPS) there are two rules: M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let (FPS2) Γ ·∪{ X . = π · X } , ∇ Γ , ∇ ∪ { a X | a ∈ dom ( π ) } ,(ElimX) Γ ·∪{ X . = e } , θ Γ , θ ∪ { X e } , if X Var (Γ) , and e is not a suspension of X . Example 8.5.
It cannot be expected that the letrec-decomposition rule (7) can be turned into a deter-ministic rule, and to obtain a unitary nominal unification, under the restriction that input expressionsare garbage-free, and also instantiations are garbage-free. Consider the equation: ( letrec a .e ; a .e in (( a , a ) , X )) . = ( letrec b .f ; b .f in ( X ′ , ( b , b ))) . Then the in-expressions do not enforce a unique correspondence between the bindings of the left andright-hand bindings. An example also follows from the proof of Theorem 7.2, which shows that evennominal matching may have several incomparable solutions for garbage-free expressions.
9. Nominal Unification with Letrec and Atom-Variables
In this section we extend the unification algorithm to the language
LRLXA , which is an extension of
LRLX with atom variables. Atom-variables increase the expressive power of a term language withatoms alone. If in an application example it is known that in a pair ( x , x ) the expressions x , x canonly be atoms, but x = x as well as x = x is possible, then two different unification problems haveto be formulated. If atom variables are possible, then the notation ( A , A ) covers both possibilities.It is known that the nominal unification problem with atom-variables but without letrec is NP-complete [27]. An algorithm and corresponding rules and discussions can be found in [27]. Animplication is NP-hardness of nominal unification with atom variables and letrec. As an extension of
LRLX , we define the language
LRLXA as follows: Let A denote atom variables, V denote atom variables or atoms, W denote suspensions of atoms or atom variables, X denotesexpression variables, π a permutation, and e an expression. The syntax of the language LRLXA is V ::= a | AW ::= π · Vπ ::= ∅ | ( W W ) | π ◦ πe ::= π · X | W | λW.e | ( f e . . . e ar ( f ) ) | ( letrec W .e ; . . . ; W n .e n in e ) Let
Var ( e ) be the set of atom or expression variables occurring in e , and let AtVar ( e ) be the set ofatom variables occurring in e . Similarly for sequences of expressions or permutations.The expression π · e for a non-variable expression e means an operation, which is performed by shifting π down in the expression, using the simplifications π · ( π · X ) → ( π ◦ π ) · X , where only expressions π · X and π · V remain, where the latter are called suspensions and where π · V is abbreviated as W . . Schmidt-Schauss et al. / Nominal Unification with Recursive Let
Remark 9.1. An alert for the reader: In this section the use of atom-variables induces generaliza-tions and changes in the LRLXA -formulation of problems: binders may now be suspensions of atom-variables, and also “nested” permutation representations are permitted, which is due to atom variables,since in general, this permutation representation cannot be simplified.Several simple facts and intuitions that are used for
LRLX no longer hold.A freshness constraint in our unification algorithm is of the form V e where e is an LRLXA -expression. The justification for the slightly more complex form as usual ( a X ) is that atom variablesprevent a simplification to this form. The notation π − is defined as the reversed list of swappings of π . We also view π · V e as identical to the constraint V π − · e .Naively applying ground substitutions sometimes leads to syntactically invalid ground expressions,since instantiation may make binding atoms in letrecs equal, which is illegal. Example 9.2.
The equation ( app ( letrec A.a, B.a in B ) A ) . = ( app ( letrec A.a, B.a in B ) B ) enforces that A, B are instantiated with the same atom, which contradicts the syntactic assumption ondistinct atoms for the binding names in letrec-expressions. However, ( app ( letrec A.a, C.a in C ) A ) . = ( app ( letrec A.a, D.a in D ) B ) is solvable. Assumption 9.3.
We circumvent the problem of illegal ground instances by assuming that for ev-ery letrec-expression in the input of unification and matching algorithms there are sufficiently manyfreshness constraint that prevent these illegal expressions.
Definition 9.4. An LRLXA -unification problem is a pair (Γ , ∇ ) , where Γ is a set of equations s . = t ,and ∇ is a set of freshness constraints V e . In addition (for clarity), for every letrec-subexpression letrec W .e , . . . , W m .e m in e , which occurs in Γ or ∇ , the set ∇ must also contain the freshnessconstraint W i W j for all i, j = 1 , . . . , m with i = j .A (ground) solution of (Γ , ∇ ) is a substitution ρ (mapping variables in Var (Γ , ∇ ) to groundexpressions), such that sρ ∼ tρ for all equations s . = t in Γ , and for all V e ∈ ∇ : V ρ eρ ) holds.The decision problem is whether there is a solution for a given (Γ , ∇ ) . Proposition 9.5.
The
LRLXA -unification problem is in NP, and hence NP-complete.
Proof:
The argument is that every ground instantiation of an atom variable is an atom, which can be guessedand checked in polynomial time: guess the images of atom variables under a ground solution ρ in theset of atoms in the current state, or in an arbitrary set of fresh atom variables of cardinality at mostthe number of different atom variables in the input (i.e. guess the function γ ). Then instantiate theproblem using γ , thereby removing all atom-variables. The resulting problem can be decided (andsolved) by an NP-algorithm as shown in this paper (Theorem 5.2). ⊓⊔ M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let (1) Γ ·∪{ e . = e } Γ (2) Γ ·∪{ π · V . = π · V } , ∇ , θ Γ , ∇ ∪ { V = π − π · V } , θ (3 a ) Γ ·∪{ π · X . = π · Y } , ∇ , θ X = Y Γ[ π − π · Y /X ] , ∇ [ π − π · Y /X ] , θ ∪ { X π − π Y } (3 b ) Γ ·∪{ π · X . = π · V } , ∇ , θ Γ[ π − π · V /X ] , ∇ [ π − π · V /X ] , θ ∪ { X π − π V } (4) Γ ·∪ ( f ( π · X ) . . . ( π n · X n )) . = ( f ( π ′ · X ′ ) . . . ( π ′ n · X ′ n )) } Γ ∪ { π · X . = π ′ · X ′ , . . . , π n · X n . = π ′ n · X ′ n } (5) Γ ·∪ ( λW.π · X . = λW.π · X } Γ ∪ { π · X . = π · X } (6) Γ ·∪ ( λW .π · X . = λW .π · X } , ∇ Γ ∪ { π · X . = ( W W ) · π · X } , ∇ ∪ { W λW .π · X ) } (7) Γ ·∪ ( letrec W .π · X ; . . . ; W n .π n · X n in π · Y . = letrec W ′ .π ′ · X ′ ; . . . ; W ′ n .π ′ n · X ′ n in π ′ · Y ′ ) , ∇ (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ∀ ρ Γ ∪ ( decompose( n +1 , λW . . . λW n . ( π · X , . . . , π n · X n , π · Y ) . = λW ′ ρ (1) . . . . λW ′ ρ ( n ) . ( π ′ ρ (1) · X ′ ρ (1) , . . . , π ′ ρ ( n ) · X ′ ρ ( n ) , π ′ · Y ′ )) ) , ∇ ∪ ( decompfresh( n +1 , λW . . . λW n . ( π · X , . . . , π n · X n , π · Y ) . = λW ′ ρ (1) . . . . λW ′ ρ ( n ) . ( π ′ ρ (1) · X ′ ρ (1) , . . . , π ′ ρ ( n ) · X ′ ρ ( n ) , π ′ · Y ′ )) ) where ρ is a permutation on { , . . . , n } and decompose( n, . ) is the equation part of n -foldapplication of rules (4), (5) or (6) and decomposefresh( n, . ) is the freshness constraintpart of the n -fold application of rules (4), (5) or (6); (in both cases after flattening). Figure 6. Standard and decomposition rules with atom variables of L
ETREC U NIFY
AV.
Remark 9.6.
Note that the equation A = π · B for atom variables A, B can be encoded as the freshnessconstraint A λπ · B.A . In the following we may use equations V = π · V as a more readable versionof V λπ · V .V . L ETREC U NIFY AV Now we describe the nominal unification algorithm L
ETREC U NIFY
AV for
LRLXA . It will extendthe algorithm L
ETREC U NIFY by a treatment of atom variables that extend the expressibility. It hasflexible rules, such that a strategy can be added to control the nondeterminism and such that it isan improvement over a brute-force guessing-algorithm that first guesses all atom instances of atom-variables and then uses Algorithm L
ETREC U NIFY (see Algorithm 9.13 for such an improvement). The . Schmidt-Schauss et al. / Nominal Unification with Recursive Let (MMS), (FPS), (ElimFP) and (Output) are almost the same as the ones in Fig 3.(MMS) Γ ·∪{ π · X . = e , π · X . = e } , ∇ Γ ∪ { π · X . = e } ∪ Γ ′ , ∇ ∪ ∇ ′ , if e , e are not suspensions, where Γ ′ is theset of equations generated by decomposing π − · e . = π − · e using (1)–(7), and where ∇ ′ is the corresponding resulting set of freshnessconstraints.(FPS) Γ ·∪{ π · X . = π ′ · X, . . . , π n · X . = π ′ n · X, π · X . = e } , θ Γ ∪ { π π − · e . = π ′ π − · e, . . . , π n π − · e . = π ′ n π − · e } , θ ∪ { X π − · e } ,If X Var (Γ , e ) , and e is not a suspension, and (Cycle) (see Fig.4) is not applicable.(ElimFP) Γ ·∪{ π · X . = π ′ · X, . . . , π n · X . = π ′ n · X, π · X . = π ′ · X } , θ Γ ∪ { π · X . = π ′ · X, . . . , π n · X . = π ′ n · X } , θ ,If π − π ′ ∈ h π − π , . . . , π − n π n i , and π i , π ′ i , π, π ′ are ground, i.e. do not contain atom variables.(Output) Γ , ∇ , θ ( θ, ∇ , Γ) if Γ only consists of fixpoint-equations.(ElimA) Γ , ∇ , θ Γ[ a/A ] , ∇ [ a/A ] , θ ∪ { A a } , where we guess the following: some atom variable A occurring in Γ , ∇ and an atom a that occurs in Γ , ∇ , θ ,or is a fresh atom. Figure 7. Main rules of L
ETREC U NIFY AV simple idea is to only make these guesses if a certain space-bound of the whole state is exceeded andthen use the guesses and further rules to shrink the size of the problem representation.Note that permutations with atom variables may lead to an exponential blow-up of their size, whichis defeated by a compression mechanism. Note also that equations of the form A . = e , in particular A . = π · A ′ , cannot be solved by substitutions ( A π · A ′ ) for two reasons: (i) the atom variable A mayoccur in the right hand side, and (ii) due to our compression mechanism (see below), the substitutionmay introduce cycles into the compression, which is forbidden.Atoms in the input are permitted. In the rules an extra mention of atoms is only in (2), (3),(ElimFP), (ElimA), (Clashab), (FailF), (FailFS) and in (ElimFP). Definition 9.7.
The algorithm L
ETREC U NIFY
AV operates on a tuple (Γ , ∇ , θ ) , where the rules aredefined in Figs. 6 and 7, and failure rules are in Fig. 8. The following explanations are in order:1. Γ is assumed to be a set of flattened equations e . = e (see the remarks after Definition 4.3).2. We assume that . = is symmetric,3. ∇ contains freshness constraints, like a e , A e , which in certain cases may be written asequations of the form A = π · A ′ (see Remark 9.6, for better readability and simplicity).4. θ represents the already computed substitution as a list of replacements of the form X e . Weassume that the substitution is the iterated replacement. Initially θ is empty. M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let (Clash) Γ ·∪{ s . = t } , ∇ , θ tops ( s ) = tops ( t ) and s and t are not suspensions ⊥ (ClashA) { s . = t } is in Γ , and s is a suspension of an atom or atom variableand tops ( t ) is a function symbol, λ or letrec ⊥ (Clashab) Γ ·∪{ a . = b } , ∇ , θ a = b ⊥ (Cycle) If π · X . = s , . . . , π n · X n . = s n in Γ where s i are not suspensionsand X i +1 occurs in s i for i = 1 , . . . , n − and X occurs in s n . ⊥ (FailF) a a ∈ ∇⊥ (FailFS) a X ∈ ∇ and a occurs free in ( Xθ ) ⊥ Figure 8. Failure Rules of L
ETREC U NIFY AV The final state will be reached, i.e. the output, when Γ only contains fixpoint equations of the form π · X . = π · X , and the rule (Output) fires.In the notation of the rules, we will use [ e/X ] as substitution that replaces X by e . We may omit ∇ or θ in the notation of a rule, if they are not changed. We will also use a notation “ | ” in the consequencepart of one rule, with a set of possibilities, to denote disjunctive (i.e. don’t know) nondeterminism.There are two nondeterministic rules with disjunctive nondeterminism: the letrec-decomposition rule(7) exploring all alternatives of the correspondence between bindings; the other one is (ElimA) thatguesses the instantiation of an atom-variable. In case it is guessed to be different from all currentlyused atoms, we remember this fact (for simplicity) by selecting a fresh atom for instantiation. Theother rules can be applied in any order, where it is not necessary to explore alternatives.We assume that permutations in the algorithm L ETREC U NIFY
AV are compressed using a grammar-mechanism, as a variation of grammar-compression in [46, 47]. However, we do not mention it in therules of the algorithm, but we will use it in the complexity arguments.The use of the iterated decomposition in rule (7) appears clumsy at a first look, however, it is aneasy algorithmic representation of the method to define the permutations (with atom variables) in arecursive fashion, where the introduction of permutation variables is avoided.
Definition 9.8.
The components of a permutation grammar G , used for compression, are:• Nonterminals P i .• For every nonterminal P i there is an associated inverse P j , which can also be written as P i .• Rules of the form P i → w . . . w n , n ≥ where w i is either a nonterminal or a terminal. Atall times P i → w n . . . w holds, i.e., if a nonterminal is added its inverse is added accordingly.Usually, n ≤ , but also another fixed bound for n is possible. . Schmidt-Schauss et al. / Nominal Unification with Recursive Let • Terminal elements are ∅ , ( V V ) .The grammar is deterministic: every nonterminal is on the left-hand side of exactly one rule. It is alsonon-recursive: the terminal index is such that P i can only be in right-hand sides of the nonterminal P j with j < i . The function inv , mapping P i → P i and T → T for terminals T computes theinverse in constant time. This is true by construction, because if P → w . . . w n then inv ( P ) → inv ( w n ) . . . inv ( w ) and inv ( T ) = T for terminals. Every nonterminal P represents a permutation val ( P ) , which is computed from the grammar as follows:1. val ( P ) = val ( w ) . . . val ( w n ) (as a composition of permutations), if P → w . . . w n .2. val ( ∅ ) = Id .3. val (( P · V P · V )) = ( val ( P ) · V val ( P ) · V ) . Lemma 9.9.
For nonterminals P of a permutation grammar G , the permutation val ( inv ( P )) is theinverse of val ( P ) . Let S denote in the following the size of the initial unification problem. Proposition 9.10.
Let G be a permutation grammar, and let P be a nonterminal, such that val ( P ) contains n atoms, and does not contain any atom variables. Then val ( P ) can be transformed into apermutation of length at most n in polynomial time. Proof:
For every P the size of the set At ( P ) has an upper bound S and can be computed in time O ( S · log( S )) For every such atom a ∈ At ( P ) we compute its image P · a and save the result in a mapping fromatoms to atoms. The computation of P · a can be done in O ( S ) , yielding a total of O ( S ) for theconstruction of this map, which has size O ( S ) . At last, the construction of the permutation list can bedone in linear time, i.e. O ( S ) . ⊓⊔ Now we consider the operations to extend the grammar during the unification algorithm.
Proposition 9.11.
Extending n times the grammar G can be performed in polynomial time in n , andthe size of the initial grammar G . Proof:
We check the extension operations:Adding a nonterminal can be done in constant time. Adding an inverse of P is in constant time, sincethe inverses of the sub-permutations are already available. Adding a composition P = P · P and atthe same time the inverse, can be done in constant time. ⊓⊔ M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
As a summary we obtain: Generating the permutation grammar on the fly during the execution of theunification rules can be done in polynomial time, since (as we will show below) the number of ruleexecutions is polynomial in the size of the initial input. Also the operation of applying a compressedground permutation to an atom is polynomial.Note that (MMS) and (FPS), without further precaution, may cause an exponential blow-up in thenumber of fixpoint equations (see Example 4.6). The rule (ElimFP) will limit the number of fixpointequations for atom-only permutations by exploiting knowledge on operations on permutation groups.The rule (ElimA) can be used according to a dynamic strategy (see below): if the space requirementfor the state is too high, then it can be applied until simplification rules make (Γ , ∇ ) smaller.The rule (Output) terminates an execution on Γ by outputting a unifier ( θ, ∇ ′ , X ) , where the solv-ability of ∇ ′ needs to be checked using methods as in the algorithm proposed in [27]. The method is tonondeterministically instantiate atom-variables by atoms, and then checking the freshness constraints,which is in NP (see also Theorem 5.2).We will show that the algorithm runs in polynomial time by applying (ElimA) following a strategydefined below. There are two rules, which can lead to a size increase of the unification problem if weignore the size of the permutations: (MMS) and (FPS):• (MMS) Given the equations X . = e , X . = e , the increase of the size of Γ after the applicationof the rule has an upper bound O ( S ) .• (FPS) Given X . = π · X, . . . , X . = π k · X, X . = e , the size increase has an upper bound O ( S ) .Disregarding the permutations of only atoms, it is not known whether there exists a polynomialupper bound of the number of independent permutations with atom variables - but it seems veryunlikely. Definition 9.12.
Let p ( x ) be some easily computable function R + → R + . The rule ElimAB ( p ) isdefined as follows:ElimAB ( p ) : If there are k > p ( S ) fixpoint equations X . = π · X, . . . , X . = π k · X in Γ for some variable X , then apply (ElimA) for all A ∈ AtVar ( π , . . . , π k ) . Thenimmediately apply (ElimFP) exhaustively. Definition 9.13.
The guided version L
ETREC U NIFY
AVB ( p ) of L ETREC U NIFY
AV is obtained by re-placing (ElimA) with ElimAB ( p ) where p ( x ) is some (easily computable) function R + → R + , suchthat ∀ x ∈ R + : q ( x ) ≥ p ( x ) ≥ x ∗ log( x ) holds for some polynomial q . In addition the priority of therules is as follows, where highest priority comes first: (1), . . . , (6), (ElimFP), (MMS), (Output). ThenElimAB ( p ) , (FPS), and the nondeterministic rule (7) with lowest priority. Lemma 9.14.
Let Γ , ∇ be a solvable input. For every function p ( x ) with ∀ x ∈ R + : p ( x ) ≥ x log( x ) ,the algorithm L ETREC U NIFY
AVB ( p ) does not get stuck, and for every intermediate state of the algo-rithm L ETREC U NIFY
AVB ( p ) it holds that the number of fixpoint equations per expression variable isbounded above by p ( S ) . . Schmidt-Schauss et al. / Nominal Unification with Recursive Let
Proof:
The upper bound of the number of fixpoint equations is proved as follows: Let m be the number ofatoms in the original unification problem. The rule (ElimA) (called by (ElimAB)) introduces at most S − m new atoms, which implies at most S atoms at any time. If L ETREC U NIFY
AVB ( p ) exceedsits upper space bound and applies ElimAB ( p ) on the fixpoint equations X . = π · X, . . . , X . = π k · X ,the number of fixpoint equations of X can be reduced to at most S log( S ) ≤ p ( S ) (see the proof ofTheorem 5.2).Since the input is solvable, the choices can be made accordingly, guided by the solution, and thenit is not possible that there is an occurs-check-fail for the variables. Hence if the upper line of thepreconditions of (FPS) is a part of Γ , there will also be a maximal variable X , such that the condition X Var (Γ , e ) can be satisfied. ⊓⊔ Theorem 9.15.
Let Γ , ∇ be a solvable input. For every function p ( x ) such that there is a polynomial q ( x ) with ∀ x : q ( x ) ≥ p ( x ) ≥ x log( x ) , L ETREC U NIFY
AVB ( p ) does not get stuck and runs inpolynomial space and time. Proof:
The proof is inspired by the proof of Theorem 5.2, and uses Lemma 9.14 that shows that the numberof fixpoint-equations for a single variable is at most p ( S ) .Below we show some estimates on the size and the number of steps. The termination measure ( , λ FA , , , which is ordered lexicographically, is as follows: is the number of different variables in Γ , λ FA is the number of letrec-, λ , function-symbols and atoms in Γ , but not in permutations, is the number of equations in Γ , and is the number of equations where non of the equated expressions is a variable.Since shifting permutations down and simplification of freshness constraints both terminate anddo not increase the measures, we only compare states which are normal forms for shifting downpermutations and simplifying freshness constraints.The following table shows the effect of the rules: Let S be the size of the initial (Γ , ∇ ) where Γ is already flattened. Again, the entries + W represent a size increase of at most W in the relevantmeasure component. λ FA < ≤ = ≤ (FPS) < +2 p ( S ) < +2 p ( S ) (MMS) = < +2 S =(4) , (5) , (6) , (7) = < + S ≤ ElimAB(p) = = < ≤ (1) ≤ ≤ < ≤ (2) = = = < M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let
The table shows that the rule applications strictly decrease the measure. The entries can be verifiedby checking the rules, and using the argument that there are not more than p ( S ) fixpoint equations fora single variable X . We use the table to argue on the number of rule applications and hence thecomplexity: The rules (3) and (FPS) strictly reduce the number of variables in Γ and can be appliedat most S times. The rule (FPS) increases the second measure at most by p ( S ) , since the number ofsymbols may be increased as often as there are fixpoint-equations, and there are at most p ( S ) . Thusthe measure λ FA will never be greater than Sp ( S ) .The rule (MMS) strictly decreases λ FA , hence , i.e. the number of equations, isbounded by S p ( S ) . The same bound holds for . Hence the number of rule applica-tions is O ( S p ( S )) . Of course, there may be a polynomial effort in executing a single rule, and byProposition 9.11 the contribution of the grammar-operations is also only polynomial. Finally, since p ( x ) is polynomially bounded by q ( x ) , the algorithm can be executed in polynomial time. ⊓⊔
10. Nominal Letrec Matching with Environment Variables
We extend the language
LRLXA by variables E that may encode partial letrec-environments for anominal matching algorithm, which leads to a larger coverage of nominal matching problems in rea-soning about the (snall-step operational) semantics of programming languages. Example 10.1.
Consider as an example a rule (llet-e) of the operational seman-tics of a functional core language, which merges letrec -environments (see [19]): ( letrec E in ( letrec E in X )) → ( letrec E ; E in X ) . It can be applied toan expression ( letrec a. b. in ( letrec c. ( a, b, c ) in c )) as follows: The left-hand side ( letrec E in ( letrec E in X )) of the reduction rule matches ( letrec a. b. in ( letrec c. ( a, b, c ) in c )) with the match: { E
7→ { a. b. } ; E
7→ { c. ( a, b, c ) } ; X c } , producingthe next expression as an instance of the right hand side ( letrec E ; E in X ) , which is ( letrec a. b. c. ( a, b, c ) in c ) . Note that for application to extended lambda calculi, more careis needed w.r.t. scoping in order to get valid reduction results in all cases. The restriction that asingle letrec environment binds different variables becomes more important. The reduction (llet-e) iscorrectly applicable, if the target expression satisfies the so-called distinct variable convention, i.e., ifall bound variables are different and if all free variables in the expression are different from all boundvariables.An alternative that is used for a similar unification task in [35] requires the additional constructof non-capture constraints: NCC ( env , env ) , which means that for every valid instantiation ρ , vari-ables occurring free in env ρ are not captured by the top letrec-binders in env ρ . In this paper wefocus on nominal matching for the extension with environment variables, and leave the investigationof reduction rules and sequences for further work. Definition 10.2.
The grammar for the extended language
LRLXAE ( L et R ec L anguage e X tendedwith A tom variables and E nvironment) variables E is: . Schmidt-Schauss et al. / Nominal Unification with Recursive Let (1) Γ ·∪{ e ✂ e } Γ (2) Γ ·∪{ π · A ✂ a } , ∇ , θ Γ[ π − · a/A ] , ∇ [ π − · a/A ] , θ ∪ { A π − · a } (3) Γ ·∪{ π · X ✂ e } , ∇ , θ Γ[ π − · e/X ] , ∇ [ π − · e/X ] , θ ∪ { X π − · e } (4) Γ ·∪{ ( f e . . . e n )) ✂ ( f e ′ . . . e ′ n ) } Γ ∪ { e ✂ e ′ , . . . e n ✂ e ′ n } (5) Γ ·∪{ ( λa.e ✂ λa.e } Γ ∪ { e ✂ e } (6) Γ ·∪{ ( λW.e ✂ λa.e , ∇} Γ ∪ { ( W a ) · e ✂ e , ∇ ∪ { a λW.e } (7) Γ ·∪ ( letrec W .e ; . . . ; W n .e n in e ✂ letrec a .e ′ ; . . . ; a n .e ′ n in e ′ ) , ∇ If the left hand side environmentdoes not contain environment variables. (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ∀ ρ Γ ∪ ( decompose( n +1 , λW . . . λW n . ( e , . . . , e n , e )) ✂ λa ρ (1) . . . . λa ρ ( n ) . ( e ′ ρ (1) , . . . , e ′ ρ ( n ) , e ′ )) ) , ∇ ∪ ( decompfresh( n +1 , λW . . . λW n . ( e , . . . , e n , e )) . = λa ρ (1) . . . . λa ρ ( n ) .e ′ ρ (1) , . . . , e ′ ρ ( n ) , e ′ )) ) where ρ is a permutation on { , . . . , n } and decompose( n, . ) is the equation part of n -foldapplication of rules (4), (5) or (6) and decomposefresh( n, . ) is the freshness constraintpart of the n -fold application of rules (4), (5) or (6). (8) Γ ·∪{ ( letrec W .e ; . . . ; E ; . . . ; W n .e n in e ) ✂ letrec a .e ′ ; . . . ; a n .e ′ m in e ′ } , ∇ , θ (cid:12)(cid:12)(cid:12) ∀ σ ((Γ ∪ { ( letrec W .e ; . . . ; E ; . . . ; W n .e n in e ) ✂ letrec a .e ′ ; . . . ; a n .e ′ m in e ′ } ) σ, ∇ σ, θ ∪ σ where σ = { E A .X , . . . A k .X k } where A i , X i are fresh variables and k ≤ m − n . Figure 9. Standard and decomposition matching rules with environment variables of L
ETREC E NV M ATCH . V ::= a | AW ::= π · Vπ ::= ∅ | ( W W ) | π ◦ πe ::= π · X | W | λW.e | ( f e . . . e ar ( f ) ) | ( letrec env in e ) env ::= E | W.e | env ; env | ∅ We define a nominal matching algorithm, where environment variables may occur (unrestricted)in left hand sides, but not in the right hand sides.The matching algorithm with environment variables is described below. It can be obtained fromthe algorithm L
ETREC U NIFY
AV by adding a rule that (nondeterministically) instantiates environmentvariables by environments of the form W .X ; . . . ; W k .X k . This can eliminate all environment vari-ables. After this operation of eliminating all environment variables, it is possible to use simplified M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let and optimized rules of L
ETREC U NIFY
AV. Since the optimizations are not completely obvious, andrequire also slight modifications of the rules, we make them explicit.
Definition 10.3.
The matching algorithm L
ETREC E NV M ATCH is described in Fig. 9. Permittedinputs are matching equations between expressions where environment variables E may only occurin the left hand sides of matching equations. The don’t know-nondeterminism is indicated in therespective rules.The result is a substitution and a freshness constraint including atom-constraints and a substitution.We omit failure rules, since these obviously follow from the nominal matching algorithm. Guess-ing the number of instances into environment variables may lead to clashes due to a wrong number ofbindings in environments. An implementation can be more clever by checking the possible number ofbindings before guessing. The constraints can be solved in NP-time by guessing and instantiating theinstances of atom-variables.The rules terminate in polynomial time, since the right hand sides are made smaller, and completenessholds, since all cases are covered. Hence: Theorem 10.4.
The nominal matching algorithm L
ETREC E NV M ATCH is sound and complete andruns in NP time.
11. Conclusion and Future Research
We construct nominal unification algorithms for expressions with letrec, for the case where only atomsare permitted, and also for the case where in addition atom variables are permitted. We also describeseveral nominal letrec matching algorithms for variants, in particular also for expressions with envi-ronment variables. All algorithms run in (nondeterministic) polynomial time. Future research is toinvestigate extensions of nominal unification with environment variables E , perhaps as an extensionof the matching algorithm.Future work is also an investigation into the connection with equivariant nominal unification[15, 16, 17], and to investigate nominal matching together with equational theories. Also applica-tions of nominal techniques to reduction steps in operational semantics of calculi with letrec andtransformations should be more deeply investigated. References [1] Schmidt-Schauß M, Kutsia T, Levy J, Villaret M. Nominal Unification of Higher Order Expressions withRecursive Let. In: Hermenegildo MV, L´opez-Garc´ıa P (eds.), Logic-Based Program Synthesis and Trans-formation - 26th International Symposium, LOPSTR 2016, Edinburgh, UK, September 6-8, 2016, RevisedSelected Papers, volume 10184 of
Lecture Notes in Computer Science . Springer, 2016 pp. 328–344. doi:10.1007/978-3-319-63139-4 19. URL https://doi.org/10.1007/978-3-319-63139-4_19 .[2] Baader F, Snyder W. Unification Theory. In: Robinson JA, Voronkov A (eds.), Handbook of AutomatedReasoning, pp. 445–532. Elsevier and MIT Press, 2001. . Schmidt-Schauss et al. / Nominal Unification with Recursive Let [3] Huet GP. A Unification Algorithm for Typed lambda-Calculus.
Theor. Comput. Sci. , 1975. (1):27–57.doi:10.1016/0304-3975(75)90011-0.[4] Goldfarb WD. The Undecidability of the Second-Order Unification Problem. Theor. Comput. Sci. , 1981. :225–230. doi:10.1016/0304-3975(81)90040-2.[5] Levy J, Veanes M. On the Undecidability of Second-Order Unification. Inf. Comput. , 2000. (1-2):125–150. doi:10.1006/inco.2000.2877.[6] Urban C, Pitts AM, Gabbay M. Nominal Unification. In: 17th CSL, 12th EACSL, and 8th KGC, volume2803 of
LNCS . Springer, 2003 pp. 513–527. doi:10.1007/978-3-540-45220-1 41.[7] Urban C, Pitts AM, Gabbay MJ. Nominal unification.
Theor. Comput. Sci. , 2004. (1–3):473–497.doi:10.1016/j.tcs.2004.06.016.[8] Calv`es C, Fern´andez M. A polynomial nominal unification algorithm.
Theor. Comput. Sci. , 2008. (2-3):285–306. doi:10.1016/j.tcs.2008.05.012.[9] Levy J, Villaret M. Nominal Unification from a Higher-Order Perspective.
ACM Trans. Comput. Log. ,2012. (2):10. doi:10.1145/2159531.2159532.[10] Miller D. A Logic Programming Language with Lambda-Abstraction, Function Variables, and SimpleUnification. J. Log. Comput. , 1991. (4):497–536. doi:10.1093/logcom/1.4.497.[11] Levy J, Villaret M. An Efficient Nominal Unification Algorithm. In: Lynch C (ed.), Proc. 21st RTA,volume 6 of LIPIcs . Schloss Dagstuhl, 2010 pp. 209–226. doi:10.4230/LIPIcs.RTA.2010.209.[12] Ayala-Rinc´on M, Fern´andez M, Rocha-Oliveira AC. Completeness in PVS of a Nominal UnificationAlgorithm.
ENTCS , 2016. (3):57–74. doi:10.1016/j.entcs.2016.06.005.[13] Ayala-Rinc´on M, de Carvalho Segundo W, Fern´andez M, Nantes-Sobrinho D. A Formalisation of Nominal α -equivalence with A and AC Function Symbols. Electr. Notes Theor. Comput. Sci. , 2017. :21–38.doi:10.1016/j.entcs.2017.04.003.[14] Ayala-Rinc´on M, Fern´andez M, Nantes-Sobrinho D. Nominal Narrowing. In: Pientka B, Kesner D (eds.),Proc. first FSCD, LIPIcs. 2016 pp. 11:1–11:17. doi:10.4230/LIPIcs.FSCD.2016.11.[15] Cheney J. Equivariant Unification.
J. Autom. Reasoning , 2010. (3):267–300. doi:10.1007/s10817-009-9164-3.[16] Cheney J. Nominal Logic Programming. Ph.D. thesis, Cornell University, Ithaca, New York, U.S.A.,2004.[17] Aoto T, Kikuchi K. A Rule-Based Procedure for Equivariant Nominal Unification. In: Informal proceed-ings HOR. 2016 p. 5.[18] Moran AKD, Sands D, Carlsson M. Erratic Fudgets: A semantic theory for an embedded coordinationlanguage. In: Coordination ’99, volume 1594 of LNCS . Springer-Verlag, 1999 pp. 85–102. doi:10.1007/3-540-48919-3 8.[19] Schmidt-Schauß M, Sch¨utz M, Sabel D. Safety of N¨ocker’s Strictness Analysis.
J. Funct. Programming ,2008. (04):503–551. doi:10.1017/S0956796807006624.[20] Ariola ZM, Klop JW. Cyclic Lambda Graph Rewriting. In: Proc. IEEE LICS. IEEE Press, 1994 pp.416–425. doi:10.1109/LICS.1994.316066.[21] Marlow S (ed.). Haskell 2010 – Language Report. 2010. URL . M. Schmidt-Schauss et al. / Nominal Unification with Recursive Let [22] Cheney J. Toward a General Theory of Names: Binding and Scope. In: MERLIN 2005. ACM, 2005 pp.33–40. doi:10.1145/1088454.1088459.[23] Urban C, Kaliszyk C. General Bindings and Alpha-Equivalence in Nominal Isabelle.
Log. MethodsComput. Sci. , 2012. (2). doi:10.2168/LMCS-8(2:14)2012.[24] Simon L, Mallya A, Bansal A, Gupta G. Coinductive Logic Programming. In: Etalle S, Truszczynski M(eds.), 22nd ICLP, LNCS. 2006 pp. 330–345. doi:10.1007/11799573 25.[25] Jeannin J, Kozen D, Silva A. CoCaml: Functional Programming with Regular Coinductive Types. Fundam.Inform. , 2017. (3-4):347–377. doi:10.3233/FI-2017-1473.[26] Martelli A, Montanari U. An efficient unification algorithm.
ACM Trans. Program. Lang. Syst. , 1982. (2):258–282. doi:10.1145/357162.357169.[27] Schmidt-Schauß M, Sabel D, Kutz YDK. Nominal unification with atom-variables. J. Symb. Comput. ,2019. :42–64. doi:10.1016/j.jsc.2018.04.003.[28] Schmidt-Schauß M, Sabel D. Nominal Unification with Atom and Context Variables. In: Kirchner [48],2018 pp. 28:1–28:20. doi:10.4230/LIPIcs.FSCD.2018.28.[29] Ayala-Rinc´on M, de Carvalho Segundo W, Fern´andez M, Nantes-Sobrinho D. Nominal C-Unification.In: Fioravanti F, Gallagher JP (eds.), 27th LOPSTR, Revised Selected Papers, volume 10855 of LNCS .Springer, 2017 pp. 235–251. doi:10.1007/978-3-319-94460-9 14.[30] Ayala-Rinc´on M, Fern´andez M, Nantes-Sobrinho D. Fixed-Point Constraints for Nominal EquationalUnification. In: Kirchner [48], 2018 pp. 7:1–7:16. doi:10.4230/LIPIcs.FSCD.2018.7.[31] Schmidt-Schauss M, Kutsia T, Levy J, Villaret M. Nominal Unification of Higher Order Expressions withRecursive Let. RISC Report Series 16-03, RISC, Johannes Kepler University Linz, Austria, 2016.[32] Baldan P, Bertolissi C, Cirstea H, Kirchner C. A rewriting calculus for cyclic higher-order term graphs.
Mathematical Structures in Computer Science , 2007. (3):363–406. doi:10.1017/S0960129507006093.[33] Rau C, Schmidt-Schauß M. A Unification Algorithm to Compute Overlaps in a Call-by-Need Lambda-Calculus with Variable-Binding Chains. In: Proc. 25th UNIF. 2011 pp. 35–41.[34] Rau C, Schmidt-Schauß M. Towards Correctness of Program Transformations Through Unification andCritical Pair Computation. In: Proc. 24th UNIF, volume 42 of EPTCS . 2010 pp. 39–54. doi:10.4204/EPTCS.42.4.[35] Schmidt-Schauß M, Sabel D. Unification of program expressions with recursive bindings. In: Cheney J,Vidal G (eds.), 18th PPDP. ACM, 2016 pp. 160–173. doi:10.1145/2967973.2968603.[36] Dowek G, Gabbay MJ, Mulligan DP. Permissive nominal terms and their unification: an infinite, co-infinite approach to nominal techniques.
Log. J. IGPL , 2010. (6):769–822. doi:10.1093/jigpal/jzq006.URL https://doi.org/10.1093/jigpal/jzq006 .[37] Schmidt-Schauß M, Rau C, Sabel D. Algorithms for Extended Alpha-Equivalence and Complexity. In:van Raamsdonk F (ed.), 24th RTA 2013, volume 21 of LIPIcs . Schloss Dagstuhl, 2013 pp. 255–270. doi:http://dx.doi.org/10.4230/LIPIcs.RTA.2013255.[38] Luks EM. Permutation Groups and Polynomial-Time Computation. In: Finkelstein L, Kantor WM (eds.),Groups And Computation, volume 11 of
DIMACS . DIMACS/AMS, 1991 pp. 139–176.[39] Furst ML, Hopcroft JE, Luks EM. Polynomial-Time Algorithms for Permutation Groups. In: 21st FoCS.IEEE Computer Society, 1980 pp. 36–41. doi:10.1109/SFCS.1980.34. . Schmidt-Schauss et al. / Nominal Unification with Recursive Let [40] Picouleau C. Complexity of the Hamiltonian Cycle in Regular Graph Problem.
Theor. Comput. Sci. , 1994. (2):463–473. doi:10.1016/0304-3975(94)90185-6.[41] Garey MR, Johnson DS, Tarjan RE. The Planar Hamiltonian Circuit Problem is NP-Complete.