Relating Nominal and Higher-Order Pattern Unification James Cheney - - PowerPoint PPT Presentation

relating nominal and higher order pattern unification
SMART_READER_LITE
LIVE PREVIEW

Relating Nominal and Higher-Order Pattern Unification James Cheney - - PowerPoint PPT Presentation

Relating Nominal and Higher-Order Pattern Unification James Cheney University of Edinburgh UNIF 2005 April 22, 2005 1 Motivation Higher-order unification : studied since ca. 1970 Undecidable, infinitary, though [Huet 1975]s


slide-1
SLIDE 1

Relating Nominal and Higher-Order Pattern Unification

James Cheney University of Edinburgh UNIF 2005 April 22, 2005

1

slide-2
SLIDE 2

Motivation

  • Higher-order unification: studied since ca. 1970
  • Undecidable, infinitary, though [Huet 1975]’s algorithm often works

well in practice

  • Higher-order pattern unification [Miller 1991]: efficiently (O(n)) decid-

able, unitary special case

  • Claim: HOPU “least extension of FOU with support for name-binding”

2

slide-3
SLIDE 3

Motivation

  • Nominal unification: unifies terms with names and binding axiomatized

using swapping and freshness [Urban, Pitts, and Gabbay 2003]

  • Nice properties: O(n2), unitary
  • [UPG03] observed similarities and possible reduction from NU to HOPU

3

slide-4
SLIDE 4

Our goal

  • Understand exact relationship between two approaches
  • What can one do that the other cannot?
  • Efficient (linear) nominal unification via HOPU?
  • Semantics for higher-order patterns via nominal terms?

4

slide-5
SLIDE 5

Higher-order patterns

  • Higher-order patterns are λ-terms (with “metavariables” F, G) such

that for every subterm of the form F t, we have t a list of distinct bound variables.

  • Yes:

λx, y.F y x λx, y.x (F y x) (λz.G z y)

  • No:

λx, y.F (y x) λx, y, z.F (x y z) (G z y)

5

slide-6
SLIDE 6

Higher-order patterns

  • We will use a refined language and type system for higher-order pat-

terns.

x, y

A

Vars c, d ∈ CnstSym Uninterpreted constant symbols τ ::= δ | τ → τ′ types Σ ::= · | Σ, c : τ signatures Γ ::= · | Γ, X : τ contexts t, u ::= c | xτ | t t′ | λxτ.t λ-terms | X | tˆxτ flexible terms

  • Note that bound variables are tagged with types, whereas metavari-

ables are typed in Γ.

6

slide-7
SLIDE 7

Higher-order patterns

  • Three judgments: normal (↑), rigid atomic (↓), and flexible atomic (⇓)

Γ ⊢ t ↓ δ Γ ⊢ t ↑ δ Γ ⊢ t ⇓ δ Γ ⊢ t ↑ δ Γ ⊢ t ↑ τ′ Γ ⊢ λxτ.t ↑ τ → τ′ Normal c : τ ∈ Σ Γ ⊢ c ↓ τ Γ ⊢ xτ ↓ τ Γ ⊢ t ↓ τ → τ′ Γ ⊢ u ↑ τ Γ ⊢ t u ↓ τ′ Rigid atomic Γ, X : τ ⊢ X ⇓ τ Γ ⊢ t ⇓ τ → τ′ (x ∈ FV (t)) Γ ⊢ tˆxτ ⇓ τ′ Flexible atomic

  • Equational laws:

(λx.t) y ≈β0 t[y/x] t : τ → τ′ ≈η λx.(t x) (x ∈ FV (t))

7

slide-8
SLIDE 8

Higher-order patterns

  • Three judgments: normal (↑), rigid atomic (↓), and flexible atomic (⇓)

Γ ⊢ t ↓ δ Γ ⊢ t ↑ δ Γ ⊢ t ⇓ δ Γ ⊢ t ↑ δ Γ ⊢ t ↑ τ′ Γ ⊢ λxτ.t ↑ τ → τ′ Normal c : τ ∈ Σ Γ ⊢ c ↓ τ Γ ⊢ xτ ↓ τ Γ ⊢ t ↓ τ → τ′ Γ ⊢ u ↑ τ Γ ⊢ t u ↓ τ′ Rigid atomic Γ, X : τ ⊢ X ⇓ τ Γ ⊢ t ⇓ τ → τ′ (x ∈ FV (t)) Γ ⊢ tˆxτ ⇓ τ′ Flexible atomic

  • Note: pattern restriction enforced here

8

slide-9
SLIDE 9

Nominal patterns

  • We consider nominal terms of the following restricted form:

a, b

A

Names c, d ∈ CnstSym Uninterpreted constant symbols τ ::= δ | σ → τ first-order types σ ::= δ | ν | νσ base types Σ ::= · | Σ, c : τ signatures Γ ::= · | Γ, X : σ contexts t ::= c | t t′ | X first-order terms |

aν | aνt | t @ aν

nominal patterns

  • Note that names are tagged with name-types ν, whereas metavari-

ables are assigned σ-types in Γ.

9

slide-10
SLIDE 10

Nominal patterns

  • Two judgments: normal (↑), atomic (↓)

Γ ⊢ t ↓ ǫ (ǫ = δ, ν) Γ ⊢ t ↑ ǫ Γ ⊢ t ↑ σ Γ ⊢ aνt ↑ νσ Normal c : τ ∈ Σ Γ ⊢ c ↓ τ Γ ⊢ aν ↓ ν Γ ⊢ t ↓ τ → τ′ Γ ⊢ u ↑ τ Γ ⊢ t u ↓ τ′ Atomic Γ, X : σ ⊢ X ↓ σ Γ ⊢ t ↓ νσ (a ∈ FN(t)) Γ ⊢ t @ aν ↓ σ Atomic

  • Equational laws (where (a b) · t = t[a/b, b/a]:

(at) @ b ≈β (a b) · t t : ντ ≈η a(t @ a)

10

slide-11
SLIDE 11

Metavariables

  • In HOPU, metavariables can only be replaced with closed terms (no

free variables).

  • We adopt this convention for nominal pattern unification also (no free

names).

  • This is not the case in ordinary NU: metavariables can be replaced

with terms mentioning “free names”.

  • We will return to this at the end.

11

slide-12
SLIDE 12

Key result

  • Nominal pattern unification translates to a special case of HOPU.

c∗ = c (t u)∗ = t∗ u∗ X∗ = X

a∗

ν

= aν (aνt)∗ = λaν.t∗ (t @ aν)∗ = (t∗)ˆaν Lemma 1. If Γ ⊢ t : τ is a nominal pattern and b ∈ FN(t), then ((a b) · t)∗ = (t[a/b, b/a])∗ = (t[b/a])∗ = t∗[b/a]

  • The translation preserves types and β and η laws and is one-to-one.

So, unification can be decided by translation.

12

slide-13
SLIDE 13

Next step

  • (−)∗ injective & total but not surjective
  • Example:

λx, y.x y ≈ λx, y.F x y since x used as a function.

  • Nevertheless, it can be translated to the equivalent problem

xyapp(var(x), y) ≈ xyF @ x @ y

13

slide-14
SLIDE 14

Idea

  • Idea: Let the base types be Vτ of “variable names of type τ”, Eδ of

“expressions of type δ”

  • Define Eτ→τ′ = VτEτ′
  • Use explicit function symbols var : Vτ → Eτ and app : Eτ→τ′ →

Eτ → Eτ′.

  • Translate as follows:

c∗∗ = c

xτ∗∗

= var(xντ) (λx.t)∗∗ = xt∗∗ (t u)∗∗ = app(t∗∗, u∗∗) X∗∗ = X (tˆx)∗∗ = t∗∗ @ x

14

slide-15
SLIDE 15

Main result

  • This translation is injective and preserves types, β, and η. So any

HOPU problem can be solved by translation. Theorem 2. A higher-order pattern unification problem t ≈? u in ηlβn- normal form has a solution if and only if its translation t∗∗ ≈? u∗∗ has a nominal pattern unifier.

15

slide-16
SLIDE 16

Not done yet

  • Nominal patterns were invented for the purpose of relating HOPU to

NU.

  • Still need to relate nominal patterns with “full” nominal unification.
  • In particular, can NPU problems actually be translated to NU prob-

lems?

  • Two problems: NU lacks concretion, and NU unifiers can substitute
  • pen terms for metavariables

16

slide-17
SLIDE 17

Nominal terms

a, b

A

Names c, d ∈ CnstSym Uninterpreted constant symbols Σ ::= · | Σ, c : τ signatures Γ ::= · | Γ, X : σ contexts t, u ::= X | c | t u First-order terms (applicative style) | at | (a b) · t | a Nominal terms C ::= t ≈ u | a # t Equality, freshness constraints Note: metavariables can mention free names!

17

slide-18
SLIDE 18

Ground swapping

The result of applying a swapping permutation to a ground term is: (a b) · c =

    

b

(a = c)

a

(b = c)

c

(a = c = b) (a b) · c = c (a b) · (t u) = ((a b) · t) ((a b) · u) (a b) · ct = (a b) · c(a b) · t For nominal terms, permutations applied to metavariables are “suspended” (since metavariables can mention names).

18

slide-19
SLIDE 19

Ground freshness theory

(a = b)

a # b

Different names fresh

a # c

Anything fresh for constant

a # t a # u a # t u

Freshness ignores function application

a # at

Fresh if bound (a = b)

a # t a # bt

Fresh if fresh for body

19

slide-20
SLIDE 20

Ground equational theory

a ≈ a

c ≈ c t1 ≈ u1 t2 ≈ u2 t1 t2 ≈ u1 u2 t ≈ u at ≈ au

                  

Standard equational rules (a = b)

a # u

t ≈ (a b) · u at ≈ bu α-equivalence for abstractions

20

slide-21
SLIDE 21

Solving the first problem

  • We can translate out concretion using the following property:

at ≈ u ⇐ ⇒ t ≈ u @ a

  • This works only if a # u, that is, u @ a is well-formed.
  • Thus, we can remove concretion by translating:

P[t @ a] ⇐ ⇒ ∃X.P[X] ∧ aX ≈ t

  • Note that X may mention a.

21

slide-22
SLIDE 22

Solving the second problem

  • We need to translate nominal unifiers ∇, θ (θ open) to nominal pat-

tern unifiers θ′ (closed)

  • This is tricky; I’ll show an example and gloss over details.
  • Also need to be careful about empty types, but this is a standard prob-

lem.

22

slide-23
SLIDE 23

An example

  • Given

abX @ b @ a ≈ abY @ a

  • we assume a, b # X, Y and substitute

X = baX′, Y = aY ′

  • This gives us a NU problem

{a, b} # {baX′, aY ′}, abX′ ≈ abY ′

  • with solution {b # Y ′}, [X′ = Y ′]

23

slide-24
SLIDE 24

An example

  • We have:

X = baY ′, Y = aY ′, b # Y ′

  • Now we want to solve for X, Y in terms of closed metavariables.
  • Since b # Y ′, substitute Y ′ = Z @ a to obtain

X = baZ @ a, Y = aZ @ a

  • which is the most general solution:

ab(baZ @ a) @ b @ a ≈ abZ @ a ≈ ab(aZ @ a) @ a

24

slide-25
SLIDE 25

Big picture

NPU HOPU HOU O(n) O(n ) 2 Undecidable NP-complete NU EVU lots of intermediate cases...

25

slide-26
SLIDE 26

Related work

  • [Miller 91] showed that full HOU could be translated to Lλ programs
  • [Hamana 2001,2002] studied unification/LP for binding algebra terms,

similar but slightly less restricted than patterns. Apparently NP, exact complexity unknown

  • [Urban et al 2004] discuss reducing NU to HOPU; seems much harder

to translate answers back

26

slide-27
SLIDE 27

Future work

  • Translating Lλ to αProlog, FOλ∇ to NL?
  • Exact complexity bounds for reductions, nominal unification? (better

than O(n2)?)

  • HOU, β0 unification, π-calculus structural congruence unification as

nominal equational unification?

27

slide-28
SLIDE 28

Conclusion

  • Showed that HOPU can be simulated by NU via a straightforward

translation.

  • Reverse direction (HOPU to NU), exact complexity of NU still unclear.
  • Intermediate NPU case seems interesting in its own right
  • and provides an independent explanation for the pattern restriction.

28