Introduction to Unification Theory Higher-Order Unification Temur - - PowerPoint PPT Presentation

introduction to unification theory
SMART_READER_LITE
LIVE PREVIEW

Introduction to Unification Theory Higher-Order Unification Temur - - PowerPoint PPT Presentation

Introduction to Unification Theory Higher-Order Unification Temur Kutsia RISC, Johannes Kepler University of Linz, Austria kutsia@risc.jku.at Overview Introduction Preliminaries Higher-Order Unification Procedure Outline Introduction


slide-1
SLIDE 1

Introduction to Unification Theory

Higher-Order Unification Temur Kutsia

RISC, Johannes Kepler University of Linz, Austria kutsia@risc.jku.at

slide-2
SLIDE 2

Overview

Introduction Preliminaries Higher-Order Unification Procedure

slide-3
SLIDE 3

Outline

Introduction Preliminaries Higher-Order Unification Procedure

slide-4
SLIDE 4

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

slide-5
SLIDE 5

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

▸ However, it makes sense to ask to find, e.g., a function that

when applied to an object gives again this object: Find an F such that F(a) = a.

slide-6
SLIDE 6

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

▸ However, it makes sense to ask to find, e.g., a function that

when applied to an object gives again this object: Find an F such that F(a) = a.

▸ F: Higher-order variable, appears at functional position.

slide-7
SLIDE 7

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

▸ However, it makes sense to ask to find, e.g., a function that

when applied to an object gives again this object: Find an F such that F(a) = a.

▸ F: Higher-order variable, appears at functional position. ▸ Can be solved, e.g., with the identity function or with the

constant function a.

slide-8
SLIDE 8

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

▸ However, it makes sense to ask to find, e.g., a function that

when applied to an object gives again this object: Find an F such that F(a) = a.

▸ F: Higher-order variable, appears at functional position. ▸ Can be solved, e.g., with the identity function or with the

constant function a.

▸ Higher-order equations.

slide-9
SLIDE 9

Introduction

▸ In first order unification, we were not allowed to replace a

variable with a function.

▸ However, it makes sense to ask to find, e.g., a function that

when applied to an object gives again this object: Find an F such that F(a) = a.

▸ F: Higher-order variable, appears at functional position. ▸ Can be solved, e.g., with the identity function or with the

constant function a.

▸ Higher-order equations. ▸ Solving method: Higher-order unification.

slide-10
SLIDE 10

Introduction

▸ Higher-order unification is fundamental in automating

higher-order reasoning.

▸ Used in logical frameworks, logic programming, program

synthesis, program transformation, type inferencing, computational linguistics, etc.

▸ Much more complicated than first-order unification

(undecidable, of type zero, nonterminating, ...).

▸ In this lecture: Introduction to higher-order unification.

slide-11
SLIDE 11

Outline

Introduction Preliminaries Higher-Order Unification Procedure

slide-12
SLIDE 12

Simply Typed λ-Calculus

▸ Simply type λ-calculus is our term language. ▸ In this section: Definitions and elementary properties.

▸ Types ▸ Terms ▸ Substitutions ▸ Reduction ▸ Unification

slide-13
SLIDE 13

Types

Types

Consider a finite set whose elements are called atomic types (or base types). Then:

▸ Atomic types are types, ▸ If T and U are types than T → U is a type.

The expression T1 → T2 → ⋯ → Tn → U is a notation for the type T1 → (T2 → ⋯ → (Tn → U)...).

slide-14
SLIDE 14

Types

Order of a Type

▸ o(T) = 1 if T is atomic. ▸ o(T → U) = max{1 + o(T),o(U)}.

Example

Let T1,T2,T3 be atomic types, then

▸ o(T1 → T2 → T3) = 2. ▸ o((T1 → T2) → T3) = 3.

slide-15
SLIDE 15

Terms

Assumptions:

▸ Consider finite set of constants. ▸ To each constant a type is assigned. ▸ For each atomic type there is at least one constant. ▸ For each type there is an infinite set of variables. ▸ Two different types have disjoint sets of variables.

λ-Terms

▸ Constants are terms. ▸ Variables are terms. ▸ If t and s are terms then (t s) is a term. ▸ If x is a variable and t is a term then λx.t is a term.

The expression (t s1 ... sn) is a notation for the term (...(t s1) ... sn)

slide-16
SLIDE 16

Terms

▸ λx.t is a function where λx is the λ-abstraction and t is the

  • body. Intuitively, it is a function x ↦ t.

▸ In λx.t, λx is a binder for x in t. Occurrences of x in t are

bound.

▸ (t s) is an application where function t is applied to the

argument s.

slide-17
SLIDE 17

Terms

Type of a Term

A term t is said to have the type T if either

▸ t is a constant of type T, ▸ t is a variable of type T, ▸ t = (r s), r has type U → T and s has type U for some U, ▸ t = λx.s, the variable x has type U, the term s has type V

and T = U → V.

▸ A term t is said to be well-typed if there exists a type T

such that t has type T.

▸ In this case T is unique and it is called the type of t. ▸ We consider only well-typed terms.

slide-18
SLIDE 18

Order

Order of a Symbol, Language

▸ The order of a function symbol or a variable is the order of

its type.

▸ A language of order n is one which allows function symbols

  • f order at most n + 1 and variables of order at most n.

Formalization of the conventions:

▸ First order term denotes an individual. ▸ Second order term denotes a function on individuals. ▸ etc.

slide-19
SLIDE 19

Free Variables

▸ vars(t): The set of variables occurring in the term t. ▸ An occurrence of a variable in a term is free if it is not

bound.

▸ The set of variables that occur freely in t, denoted fvars(t):

▸ fvars(c) = ∅, where c is a constant. ▸ fvars(x) = {x}. ▸ fvars((sr)) = fvars(s) ∪ fvars(r). ▸ fvars(λx.s) = fvars(s) ∖ {x}.

▸ Closed term: A term without free variables.

slide-20
SLIDE 20

Free Variables

Example

▸ fvars(λx.x) = ∅.

(Closed term)

▸ fvars(λx.y) = {y}. ▸ fvars(((λx.x)x)) = {x}.

(x has a bound occurrence as well)

slide-21
SLIDE 21

Substitution

▸ We reuse the definition of substitution as finite mapping

from the previous lectures, but in addition require that it preserves types.

▸ Hence, if x ↦ t is a binding of a substitution, x and t have

the same type.

▸ The definitions of composition, more general substitution,

  • etc. will also be reused.
slide-22
SLIDE 22

Replacement in a Term

Replacement in a Term

Let σ = {x1 ↦ t1,...,xn ↦ tn} be a substitution and t be a term, then the term t⟨σ⟩ is defined as follows:

▸ c⟨σ⟩ = c. ▸ xi⟨σ⟩ = ti. ▸ x⟨σ⟩ = x, if x ∉ {x1,...,xn}. ▸ (sr)⟨σ⟩ = (s⟨σ⟩r⟨σ⟩). ▸ (λx.s)⟨σ⟩ = (λx.s⟨σ⟩).

Example

▸ (λx.x)⟨{x ↦ y}⟩ = λx.y. ▸ (λy.x)⟨{x ↦ y}⟩ = λy.y (variable capture).

slide-23
SLIDE 23

α-Equivalence

α-Equivalence

▸ c ≡α c. ▸ x ≡α x. ▸ (t s) ≡α (t′ s′) if t ≡α t′ and s ≡α s′. ▸ λx.t ≡α λy.s if t⟨{x ↦ z}⟩ ≡α s⟨{y ↦ z}⟩ for some variable z

different from x and y and occurring neither in t nor in s.

Example

▸ λx.x ≡α λy.y. ▸ α-equivalence is an equivalence relation. ▸ Application and abstraction are compatible with

α-equivalence.

slide-24
SLIDE 24

Substitution in a Term

Substitution in a Term

Let σ = {x1 ↦ t1,...,xn ↦ tn} be a substitution and t be a term, then the term tσ is defined as follows:

▸ cσ = c. ▸ xiσ = ti. ▸ xσ = x, if x ∉ {x1,...,xn}. ▸ (sr)σ = (sσ rσ). ▸ (λx.s)σ = (λy.s{x ↦ y}σ), where y is a fresh variable of the

same type as x. Since the choice of fresh variable is arbitrary, the substitution

  • peration is defined on α-equivalence classes.
slide-25
SLIDE 25

Substitution in a Term

Example

▸ (λx.x){x ↦ y} = λz.z. ▸ (λy.x){x ↦ y} = λz.y (no variable capture). ▸ (x λx.(x y)){x ↦ λz.z} = (λz.z λu.(uy)).

slide-26
SLIDE 26

Reduction

▸ Intuition: Function evaluation. ▸ For instance, evaluating function f ∶ x ↦ x + 1 at 2:

f(2) = 2 + 1.

▸ As λ-terms: ((λx.x + 1) 2) ⊳ x + 1{x ↦ 2} = 2 + 1.

(β-reduction)

slide-27
SLIDE 27

Reduction

Formally:

βη-Reduction

▸ β-reduction: ((λx.s)t) ⊳ s{x ↦ t}. ▸ η-reduction: (λx.(t x)) ⊳ t, if x ∉ fvars(t).

Propagates into contexts:

▸ If s ⊳ s′ then (st) ⊳ (s′ t). ▸ If t ⊳ t′ then (st) ⊳ (st′). ▸ If t ⊳ t′ then λx.t ⊳ λx.t′.

slide-28
SLIDE 28

Reduction

⊳∗ - reflexive-transitive closure of ⊳. Facts:

▸ βη-Reduction preserves types. ▸ If s ⊳∗ t then sσ ⊳∗ tσ. ▸ Each term has a unique βη-normal form modulo

α-equivalence.

slide-29
SLIDE 29

Reduction

Example

λx.(f ((λy.(yx))λz.z)) ⊳β λx.(f ((λz.z)x)) ⊳β λx.(f x) ⊳η f

slide-30
SLIDE 30

Long Normal Form

Long Normal Form

Assume

▸ t = λx1....λxm.(r s1 ... sk) is in the βη-normal form, ▸ T1 → ⋯ → Tn → U is a type of t, ▸ U is atomic and n ≥ m.

Then the long normal form of t is the term t′ = λx1....λxm.λxm+1....λxn.(r s′

1 ...s′ k x′ m+1 ... x′ n)

where

▸ s′ i is the long normal form of si. ▸ x′ i is the long normal form of xi.

slide-31
SLIDE 31

Long Normal Form

Long Normal Form

Assume

▸ t = λx1....λxm.(r s1 ... sk) is in the βη-normal form, ▸ T1 → ⋯ → Tn → U is a type of t, ▸ U is atomic and n ≥ m.

Then the long normal form of t is the term t′ = λx1....λxm.λxm+1....λxn.(r s′

1 ...s′ k x′ m+1 ... x′ n)

where

▸ s′ i is the long normal form of si. ▸ x′ i is the long normal form of xi.

The long normal form of any term is that of its normal form.

slide-32
SLIDE 32

Long Normal Form

Long Normal Form

Assume

▸ t = λx1....λxm.(r s1 ... sk) is in the βη-normal form, ▸ T1 → ⋯ → Tn → U is a type of t, ▸ U is atomic and n ≥ m.

Then the long normal form of t is the term t′ = λx1....λxm.λxm+1....λxn.(r s′

1 ...s′ k x′ m+1 ... x′ n)

where

▸ s′ i is the long normal form of si. ▸ x′ i is the long normal form of xi.

The long normal form of any term is that of its normal form. Since t is in the normal form, r (called the head of t) is either a constant or a variable.

slide-33
SLIDE 33

Long Normal Form

Example

Let the type of f be T1 → T2 → U, with U atomic. Let t be λx.(f ((λy.(yx))λz.z)).

slide-34
SLIDE 34

Long Normal Form

Example

Let the type of f be T1 → T2 → U, with U atomic. Let t be λx.(f ((λy.(yx))λz.z)).

▸ The long normal form of t is λx.λy.(f x y).

slide-35
SLIDE 35

Long Normal Form

Example

Let the type of f be T1 → T2 → U, with U atomic. Let t be λx.(f ((λy.(yx))λz.z)).

▸ The long normal form of t is λx.λy.(f x y). ▸ λx.λy.(f x y) is a long normal form of λx.(f x) as well, which

is a β-normal form of t.

slide-36
SLIDE 36

Long Normal Form

Example

Let the type of f be T1 → T2 → U, with U atomic. Let t be λx.(f ((λy.(yx))λz.z)).

▸ The long normal form of t is λx.λy.(f x y). ▸ λx.λy.(f x y) is a long normal form of λx.(f x) as well, which

is a β-normal form of t.

▸ In general, to compute long normal form, it is not

necessary to perform η-reductions.

slide-37
SLIDE 37

Long Normal Form

▸ In the rest, “normal form” stands for “long normal form”. ▸ Notation: We write

λx1....λxn. r(t1,...,tm) for λx1....λxn. (r t1 ... tm) in normal form. r is either a constant or a variable.

slide-38
SLIDE 38

Outline

Introduction Preliminaries Higher-Order Unification Procedure

slide-39
SLIDE 39

Higher Order Unification

Higher-Order Unification Problem, Unifier

▸ Higher-Order Unification problem: a finite set of equations

P = {s1 ≐? t1,...,sn ≐? tn}, where si,ti are λ-terms.

▸ Unifier of P: a substitution σ such that siσ and tiσ have the

same normal form for each 1 ≤ i ≤ n. We will use capital letters to denote free variables in unification problems.

slide-40
SLIDE 40

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}.

slide-41
SLIDE 41

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Unifier: σ1 = {F ↦ λx.f(x,b)}.

slide-42
SLIDE 42

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Unifier: σ1 = {F ↦ λx.f(x,b)}. ▸ Justification:

F(f(a,b))σ1 = ((λx.f(x,b)) f(a,b)) ⊳β f(f(a,b),b).

slide-43
SLIDE 43

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Unifier: σ1 = {F ↦ λx.f(x,b)}. ▸ Justification:

F(f(a,b))σ1 = ((λx.f(x,b)) f(a,b)) ⊳β f(f(a,b),b). f(F(a),b)σ1 = f(((λx.f(x,b))a),b) ⊳β f(f(a,b),b).

slide-44
SLIDE 44

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}.

slide-45
SLIDE 45

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Another unifier: σ2 = {F ↦ λx.f(f(x,b),b)}.

slide-46
SLIDE 46

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Another unifier: σ2 = {F ↦ λx.f(f(x,b),b)}. ▸ Justification:

F(f(a,b))σ2 = ((λx.f(f(x,b),b))f(a,b)) ⊳β f(f(f(a,b),b),b).

slide-47
SLIDE 47

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Another unifier: σ2 = {F ↦ λx.f(f(x,b),b)}. ▸ Justification:

F(f(a,b))σ2 = ((λx.f(f(x,b),b))f(a,b)) ⊳β f(f(f(a,b),b),b). f(F(a),b)σ2 = f(((λx.f(f(x,b),b))a),b) ⊳β f(f(f(a,b),b),b).

slide-48
SLIDE 48

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}.

slide-49
SLIDE 49

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Infinitely many unifiers, of the shape

{F ↦ λx. f(...f(x,b),...b)}.

slide-50
SLIDE 50

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Infinitely many unifiers, of the shape

{F ↦ λx. f(...f(x,b),...b)}.

▸ Incomparable wrt instantiation quasi-ordering.

slide-51
SLIDE 51

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Infinitely many unifiers, of the shape

{F ↦ λx. f(...f(x,b),...b)}.

▸ Incomparable wrt instantiation quasi-ordering. ▸ Minimal complete set of unifiers.

slide-52
SLIDE 52

Higher Order Unification

Example

▸ P = {F(f(a,b)) ≐? f(F(a),b)}. ▸ Infinitely many unifiers, of the shape

{F ↦ λx. f(...f(x,b),...b)}.

▸ Incomparable wrt instantiation quasi-ordering. ▸ Minimal complete set of unifiers. ▸ There are problems for which this set does not exist!

slide-53
SLIDE 53

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}.

slide-54
SLIDE 54

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

slide-55
SLIDE 55

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

σ = {F ↦ λx.λy. H(x)} H(λx.G(x))

slide-56
SLIDE 56

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

σ = {F ↦ λx.λy. H(x)} H(λx.G(x)) σ0 = {F ↦ λx.λy.x, G ↦ λx.Y} λx.Y

slide-57
SLIDE 57

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

σ = {F ↦ λx.λy. H(x)} H(λx.G(x)) σ0 = {F ↦ λx.λy.x, G ↦ λx.Y} λx.Y σ1 = {F ↦ λx.λy. G1(x,x(H1

1(x,y))), G ↦ λx. Y}

G1(λx.Y, Y)

slide-58
SLIDE 58

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

σ = {F ↦ λx.λy. H(x)} H(λx.G(x)) σ0 = {F ↦ λx.λy.x, G ↦ λx.Y} λx.Y σ1 = {F ↦ λx.λy. G1(x,x(H1

1(x,y))), G ↦ λx. Y}

G1(λx.Y, Y) σ2 = {F ↦ λx.λy.G2(x,x(H2

1(x,y)),x(H2 2(x,y))), G ↦ λx.Y}

G2(λx.Y, Y, Y)

slide-59
SLIDE 59

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions (together with the instance terms):

σ = {F ↦ λx.λy. H(x)} H(λx.G(x)) σ0 = {F ↦ λx.λy.x, G ↦ λx.Y} λx.Y σ1 = {F ↦ λx.λy. G1(x,x(H1

1(x,y))), G ↦ λx. Y}

G1(λx.Y, Y) σ2 = {F ↦ λx.λy.G2(x,x(H2

1(x,y)),x(H2 2(x,y))), G ↦ λx.Y}

G2(λx.Y, Y, Y) ... σn = {F ↦ λx.λy.Gn(x,x(Hn

1(x,y)),...,x(Hn n(x,y))), G ↦ λx.Y}

Gn(λx.Y, Y,...,Y) (There are n Y’s here.)

slide-60
SLIDE 60

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions:

σ = {F ↦ λx.λy.H(x)} σ0 = {F ↦ λx.x, G ↦ λx.Y} σn = {F ↦ λx.λy.Gn(x,x(Hn

1(x,y)),...,x(Hn n(x,y))), G ↦ λx.Y}

slide-61
SLIDE 61

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions:

σ = {F ↦ λx.λy.H(x)} σ0 = {F ↦ λx.x, G ↦ λx.Y} σn = {F ↦ λx.λy.Gn(x,x(Hn

1(x,y)),...,x(Hn n(x,y))), G ↦ λx.Y} ▸ No mcsu. For all i,j > i: σi /

⩿{F,G} σj, σ / ⩿{F,G} σi, σi / ⩿{F,G} σ, and σi ≖{F,G} σi+1ϑi where ϑi = {Gi+1 ↦ λx.λy1....λyi+1.Gi(x,y1,...,yi), Hi+1

1

↦ Hi

1,...,Hi+1 i

↦ Hi

i}

slide-62
SLIDE 62

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ Complete set of solutions:

σ = {F ↦ λx.λy.H(x)} σ0 = {F ↦ λx.x, G ↦ λx.Y} σn = {F ↦ λx.λy.Gn(x,x(Hn

1(x,y)),...,x(Hn n(x,y))), G ↦ λx.Y} ▸ No mcsu. For all i,j > i: σi /

⩿{F,G} σj, σ / ⩿{F,G} σi, σi / ⩿{F,G} σ, and σi ≖{F,G} σi+1ϑi where ϑi = {Gi+1 ↦ λx.λy1....λyi+1.Gi(x,y1,...,yi), Hi+1

1

↦ Hi

1,...,Hi+1 i

↦ Hi

i} ▸ Infinite descending chain: σ1 ⪀{F,G} σ2 ⪀{F,G} ⋯

slide-63
SLIDE 63

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}.

slide-64
SLIDE 64

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ The problem is of third order.

slide-65
SLIDE 65

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ The problem is of third order. ▸ Higher-order unification of the order 3 and above is of type 0.

slide-66
SLIDE 66

Higher Order Unification Is of Type 0

▸ Unification problem: P = {F(λx.G(x),a) ≐? F(λx.G(x),b)}. ▸ The problem is of third order. ▸ Higher-order unification of the order 3 and above is of type 0. ▸ Second order unification is infinitary.

slide-67
SLIDE 67

Higher Order Unification Is Undecidable

▸ Idea: Reduce Hilbert’s 10th problem to a higher-order

unification problem.

▸ Hilbert’s 10th problem is undecidable: There is no

algorithm that takes as input two polynomials P(X1,...,Xn) and Q(X1,...,Xn) with natural coefficients and answers if there exist natural numbers m1,...,mn such that P(m1,...,mn) = Q(m1,...,mn).

▸ Reduction requires to represent

▸ natural numbers, ▸ addition, ▸ multiplication

in terms of higher-order unification.

slide-68
SLIDE 68

Higher Order Unification Is Undecidable

Representation (Goldfarb 1981):

▸ Natural number n represented as a λ-term denoted by n:

λx.g(a,g(a,...g(a,x)...)) with n occurrences of g and a. The type of g is i → i → i and the type of a is i. Such terms are called Goldfarb numbers.

▸ Goldfarb numbers are exactly those that solve the

unification problem {g(a,X(a)) ≐? X(g(a,a))} and have the type i → i.

slide-69
SLIDE 69

Higher Order Unification Is Undecidable

Representation:

▸ Addition is represented by the λ-term add:

λn.λm.λx. n(m(x)).

▸ Multiplication is represented by the higher-order unification

problem

{Y(a,b,g(g(X3(a),X2(b)),a)) ≐? g(g(a,b),Y(X1(a),g(a,b),a)) Y(b,a,g(g(X3(b),X2(a)),a)) ≐? g(g(b,a),Y(X1(b),g(a,a),a))}

that has a solution {X1 ↦ m1,X2 ↦ m2,X3 ↦ m3,Y ↦ t} for some t iff m1 × m2 = m3.

slide-70
SLIDE 70

Higher Order Unification Is Undecidable

Reduction from Hilbert’s 10th problem:

▸ Every equation P(X1,...,Xn) = Q(X1,...,Xn) can be

decomposed into a system of equations of the form: Xi + Xj = Xk, Xi × Xj = Xk, Xi = m.

▸ With each such system associate a unification problem

containing

▸ for each Xi an equation g(a,Xi(a)) ≐? Xi(g(a,a)), ▸ for each Xi + Xj = Xk the equation add(Xi,Xj) ≐? Xk, ▸ for each Xi × Xj = Xk the two equations used to define

multiplication,

▸ for each Xi = m the equation Xi ≐? m.

slide-71
SLIDE 71

Second Order Unification Is Undecidable

▸ The reduction implies undecidability of higher-order

unification.

▸ Since the reduction is actually to second-order unification,

the result is sharper:

Theorem

Second-order unification is undecidable. For the details of undecidability of second-order unification, see

  • W. D. Goldfarb

The undecidability of the second-order unification problem. Theoretical Computer Science 13, 225–230.

slide-72
SLIDE 72

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

slide-73
SLIDE 73

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

slide-74
SLIDE 74

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

  • 2. For a given unification problem, take the first untried

substitution and check whether it is a solution.

slide-75
SLIDE 75

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

  • 2. For a given unification problem, take the first untried

substitution and check whether it is a solution.

  • 3. If yes, stop with success. If not, mark the substitution as

tried and iterate.

slide-76
SLIDE 76

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

  • 2. For a given unification problem, take the first untried

substitution and check whether it is a solution.

  • 3. If yes, stop with success. If not, mark the substitution as

tried and iterate.

▸ Checking is not hard: Apply the substitution to both sides of

each equation, normalize, and compare the normal forms.

slide-77
SLIDE 77

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

  • 2. For a given unification problem, take the first untried

substitution and check whether it is a solution.

  • 3. If yes, stop with success. If not, mark the substitution as

tried and iterate.

▸ Checking is not hard: Apply the substitution to both sides of

each equation, normalize, and compare the normal forms.

▸ If the problem is solvable, the procedure will detect it after

finite steps.

slide-78
SLIDE 78

Higher-Order Unification Procedure

▸ Higher-order semi-decision procedure is easy to design:

  • 1. Enumerate all substitutions (in fact, it is enough to

enumerate all closed substitutions).

  • 2. For a given unification problem, take the first untried

substitution and check whether it is a solution.

  • 3. If yes, stop with success. If not, mark the substitution as

tried and iterate.

▸ Checking is not hard: Apply the substitution to both sides of

each equation, normalize, and compare the normal forms.

▸ If the problem is solvable, the procedure will detect it after

finite steps.

▸ Then... why to bother with looking for another unification

procedure?

slide-79
SLIDE 79

Higher-Order Unification Procedure

Why to look for a “better” procedure?

slide-80
SLIDE 80

Higher-Order Unification Procedure

Why to look for a “better” procedure?

▸ To find solutions faster.

slide-81
SLIDE 81

Higher-Order Unification Procedure

Why to look for a “better” procedure?

▸ To find solutions faster. ▸ To report failure for many unsolvable cases.

slide-82
SLIDE 82

Higher-Order Unification Procedure

Why to look for a “better” procedure?

▸ To find solutions faster. ▸ To report failure for many unsolvable cases. ▸ To reduce redundancy. ▸ etc.

slide-83
SLIDE 83

Higher-Order Unification Procedure

▸ System: a pair P;σ, where P is a higher-order unification

problem and σ is a substitution.

▸ Procedure is given by transformation rules on systems. ▸ The description essentially follows the paper

  • W. Snyder and J. Gallier.

Higher-Order Unification Revisited: Complete Sets of Transformations.

  • J. Symbolic Computation, 8(1–2), 101–140, 1989.
slide-84
SLIDE 84

Important Observation

▸ Flex-flex equation has a form

λx1....λxk. F(s1,...,sn) ≐? λx1....λxk. G(t1,...,tm). The head of both sides are free variables.

slide-85
SLIDE 85

Important Observation

▸ Flex-flex equation has a form

λx1....λxk. F(s1,...,sn) ≐? λx1....λxk. G(t1,...,tm). The head of both sides are free variables.

▸ Any flex-flex equation is solvable. Just take

{F ↦ λy1....λyn. c, G ↦ λy1....λym. c}.

slide-86
SLIDE 86

Important Observation

▸ Flex-flex equation has a form

λx1....λxk. F(s1,...,sn) ≐? λx1....λxk. G(t1,...,tm). The head of both sides are free variables.

▸ Any flex-flex equation is solvable. Just take

{F ↦ λy1....λyn. c, G ↦ λy1....λym. c}.

▸ The appropriate c always exists because for each type we

have at least one constant of that type.

slide-87
SLIDE 87

Important Observation

▸ Flex-flex equation has a form

λx1....λxk. F(s1,...,sn) ≐? λx1....λxk. G(t1,...,tm). The head of both sides are free variables.

▸ Any flex-flex equation is solvable. Just take

{F ↦ λy1....λyn. c, G ↦ λy1....λym. c}.

▸ The appropriate c always exists because for each type we

have at least one constant of that type.

▸ Flex-flex equations may introduce infinite branching in the

search tree (very undesirable property).

slide-88
SLIDE 88

Important Observation

▸ Flex-flex equation has a form

λx1....λxk. F(s1,...,sn) ≐? λx1....λxk. G(t1,...,tm). The head of both sides are free variables.

▸ Any flex-flex equation is solvable. Just take

{F ↦ λy1....λyn. c, G ↦ λy1....λym. c}.

▸ The appropriate c always exists because for each type we

have at least one constant of that type.

▸ Flex-flex equations may introduce infinite branching in the

search tree (very undesirable property).

▸ Idea: Do not try to solve flex-flex equations. Assume them

  • solved. Preunification.
slide-89
SLIDE 89

Preunification

Preunifier

▸ Let ≅ be the least congruence relation on the set of

λ-terms that contains the set of flex-flex pairs.

▸ A substitution σ is a preunifier for a unification problem

{s1 ≐? t1,...,sn ≐? tn} iff normal-form(siσ) ≅ normal-form(tiσ) for each 1 ≤ i ≤ n.

Convention

▸ xn abbreviates x1,...,xn. ▸ λxn abbreviates λx1.....λxn.

slide-90
SLIDE 90

One Technical Notion

Partial Binding

A partial binding of type T1 → ⋯ → Tn → U (U atomic) is a term

  • f the form

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk))

where l is a constant or a variable, and

slide-91
SLIDE 91

One Technical Notion

Partial Binding

A partial binding of type T1 → ⋯ → Tn → U (U atomic) is a term

  • f the form

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk))

where l is a constant or a variable, and

▸ the type of xi is Ti for 1 ≤ i ≤ n,

slide-92
SLIDE 92

One Technical Notion

Partial Binding

A partial binding of type T1 → ⋯ → Tn → U (U atomic) is a term

  • f the form

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk))

where l is a constant or a variable, and

▸ the type of xi is Ti for 1 ≤ i ≤ n, ▸ the type of l is S1 → ⋯ → Sk → U, where Si is

Ri

1 → ⋯ → Ri mi → S′ i (S′ i atomic) for 1 ≤ i ≤ k,

slide-93
SLIDE 93

One Technical Notion

Partial Binding

A partial binding of type T1 → ⋯ → Tn → U (U atomic) is a term

  • f the form

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk))

where l is a constant or a variable, and

▸ the type of xi is Ti for 1 ≤ i ≤ n, ▸ the type of l is S1 → ⋯ → Sk → U, where Si is

Ri

1 → ⋯ → Ri mi → S′ i (S′ i atomic) for 1 ≤ i ≤ k, ▸ the type of yi j is Ri j for 1 ≤ i ≤ k and 1 ≤ j ≤ mi.

slide-94
SLIDE 94

One Technical Notion

Partial Binding

A partial binding of type T1 → ⋯ → Tn → U (U atomic) is a term

  • f the form

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk))

where l is a constant or a variable, and

▸ the type of xi is Ti for 1 ≤ i ≤ n, ▸ the type of l is S1 → ⋯ → Sk → U, where Si is

Ri

1 → ⋯ → Ri mi → S′ i (S′ i atomic) for 1 ≤ i ≤ k, ▸ the type of yi j is Ri j for 1 ≤ i ≤ k and 1 ≤ j ≤ mi. ▸ the type of Hi is T1 → ⋯ → Tn → Ri 1 → ⋯ → Ri mi → S′ i for

1 ≤ i ≤ k.

slide-95
SLIDE 95

Partial Binding

λxn. l(λy1

m1.H1(xn,y1 m1),...,λyk mk.Hk(xn,yk mk)) ▸ Imitation binding: l is a constant or a free variable. ▸ (ith) Projection binding: l is xi. ▸ A partial binding t is appropriate to F if t and F have the

same types.

▸ F ↦ t: Appropriate partial (imitation, projection) binding if t

is partial (imitation, projection) binding appropriate to F.

slide-96
SLIDE 96

Higher-Order Preunification Procedure

▸ The inference system UHOP consists of the rules:

▸ Trivial ▸ Decomposition ▸ Variable Elimination ▸ Orient ▸ Imitation ▸ Projection

▸ The rules transform systems: pairs P;σ, where P is a

higher-order unification problem and σ is a substitution.

▸ A system P;σ is in presolved form if P is either empty or

consists of flex-flex equations only.

slide-97
SLIDE 97

Higher-Order Preunification Procedure. Rules

Trivial: {t ≐? t} ∪ P′;ϑ ⇒ P′;ϑ

slide-98
SLIDE 98

Higher-Order Preunification Procedure. Rules

Trivial: {t ≐? t} ∪ P′;ϑ ⇒ P′;ϑ Decomposition: {λxk. l(s1,...,sn) ≐? λxk. l(t1,...,tn)} ∪ P′;ϑ ⇒ {λxk. s1 ≐? λxk. t1,...,λxk. sn ≐? λxk. tn,} ∪ P′;ϑ. where l is either a constant or one of the bound variables x1,...,xk.

slide-99
SLIDE 99

Higher-Order Preunification Procedure. Rules

Trivial: {t ≐? t} ∪ P′;ϑ ⇒ P′;ϑ Decomposition: {λxk. l(s1,...,sn) ≐? λxk. l(t1,...,tn)} ∪ P′;ϑ ⇒ {λxk. s1 ≐? λxk. t1,...,λxk. sn ≐? λxk. tn,} ∪ P′;ϑ. where l is either a constant or one of the bound variables x1,...,xk. Variable Elimination: {λx1....λxk. F(x1,...,xk) ≐? t} ∪ P′;ϑ ⇒ P′{F ↦ t};ϑ{F ↦ t}. If F ∉ fvars(t)

slide-100
SLIDE 100

Higher-Order Preunification Procedure. Rules

Orient: {λxk. l(t1,...,tm) ≐? λxk. F(s1,...,sn)} ∪ P′;ϑ ⇒ {λxk. F(s1,...,sn) ≐? λxk. l(t1,...,tm)} ∪ P′;ϑ where l is not a free variable.

slide-101
SLIDE 101

Higher-Order Preunification Procedure. Rules

Orient: {λxk. l(t1,...,tm) ≐? λxk. F(s1,...,sn)} ∪ P′;ϑ ⇒ {λxk. F(s1,...,sn) ≐? λxk. l(t1,...,tm)} ∪ P′;ϑ where l is not a free variable. Imitation: {λxk. F(s1,...,sn) ≐? λxk. f(t1,...,tm)} ∪ P′;ϑ ⇒ {λxk. f(λz1

  • r1. H1(s1,...,sn,z1

r1),...,λzm

  • rm. Hm(s1,...,sn,zm

rm))σ

≐? λxk. f(t1,...,tm)σ} ∪ P′σ;ϑσ where

▸ σ = {F ↦ λyn. f(λz1

  • r1. H1(yn,z1

r1),...,λzm

  • rm. Hm(yn,zm

rm))},

appropriate imitation binding.

▸ H1,...,Hm are fresh variables.

slide-102
SLIDE 102

Higher-Order Preunification Procedure. Rules

Projection: {λxk. F(s1,...,sn) ≐? λxk. l(t1,...,tm)} ∪ P′;ϑ ⇒ {λxk. si(λz1

  • r1. H1(s1,...,sn,z1

r1),...,λzm

  • rm. Hm(s1,...,sn,zm

rm))σ

≐? λxk. l(t1,...,tm)σ} ∪ P′σ;ϑσ where

▸ l is either a constant or one of the bound variables x1,...,xk, ▸ σ = {F ↦ λyn. yi(λz1

  • r1. H1(yn,z1

r1),...,λzm

  • rm. Hm(yn,zm

rm))},

appropriate projection binding.

▸ H1,...,Hm are fresh variables.

slide-103
SLIDE 103

Higher-Order Preunification Procedure. Control

In order to solve a higher-order unification problem P:

▸ Create an initial system P;ε.

slide-104
SLIDE 104

Higher-Order Preunification Procedure. Control

In order to solve a higher-order unification problem P:

▸ Create an initial system P;ε. ▸ Apply successively rules from UHOP, building a complete

(finitely branching, but potentially infinite) tree of derivations.

slide-105
SLIDE 105

Higher-Order Preunification Procedure. Control

In order to solve a higher-order unification problem P:

▸ Create an initial system P;ε. ▸ Apply successively rules from UHOP, building a complete

(finitely branching, but potentially infinite) tree of derivations.

▸ If no rule can be applied to a node, and it contains at least

  • ne equation that is not flex-flex, then extend the branch

with , indicating failure.

slide-106
SLIDE 106

Higher-Order Preunification Procedure. Control

In order to solve a higher-order unification problem P:

▸ Create an initial system P;ε. ▸ Apply successively rules from UHOP, building a complete

(finitely branching, but potentially infinite) tree of derivations.

▸ If no rule can be applied to a node, and it contains at least

  • ne equation that is not flex-flex, then extend the branch

with , indicating failure.

▸ Successful leaves contain presolved systems.

slide-107
SLIDE 107

Higher-Order Preunification Procedure. Control

In order to solve a higher-order unification problem P:

▸ Create an initial system P;ε. ▸ Apply successively rules from UHOP, building a complete

(finitely branching, but potentially infinite) tree of derivations.

▸ If no rule can be applied to a node, and it contains at least

  • ne equation that is not flex-flex, then extend the branch

with , indicating failure.

▸ Successful leaves contain presolved systems. ▸ If ∆;σ is a successful leaf, σ is a solution of P computed by

the higher-order preunification procedure.

slide-108
SLIDE 108

Higher-Order Preunification. Major Results

Theorem (Soundness)

If P;ε ⇒∗ ∆;σ and ∆ is in presolved form, then σ∣fvars(P) is a preunifier of P.

Theorem (Completeness)

If ϑ is a preunifier of P, then there exists a sequence of transformations P;ε ⇒∗ ∆;σ such that ∆ is in presolved form, and σ ⩿fvars(P)

β

ϑ.

slide-109
SLIDE 109

Higher-Order Preunification. Optimization

▸ The procedure can be optimized by stripping off the binder

λx when x does not occur in the body.

▸ For instance, Elimination rule does not apply to

λx.λy. P(x) ≐? λx.λy. f(a)

▸ After removing λy from both sides, Elimination can be

applied directly.

slide-110
SLIDE 110

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

slide-111
SLIDE 111

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

slide-112
SLIDE 112

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
slide-113
SLIDE 113

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}
slide-114
SLIDE 114

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}

{F(f(a)) ≐? f(F(a))};ε

slide-115
SLIDE 115

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Imit {f(G(f(a))) ≐? f(f(G(a)))};{F ↦ λx. f(G(x))}
slide-116
SLIDE 116

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Imit {f(G(f(a))) ≐? f(f(G(a)))};{F ↦ λx. f(G(x))}
  • ⇒Dec {G(f(a)) ≐? f(G(a))};{F ↦ λx. f(G(x))}
slide-117
SLIDE 117

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Imit {f(G(f(a))) ≐? f(f(G(a)))};{F ↦ λx. f(G(x))}
  • ⇒Dec {G(f(a)) ≐? f(G(a))};{F ↦ λx. f(G(x))}
  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. f(x),G ↦ λx. x}
slide-118
SLIDE 118

Higher-Order Preunification. Examples

Example

▸ Unification problem {F(f(a)) ≐? f(F(a))}. ▸ The preunification procedure enumerates the complete set

  • f (pre)unifiers that is infinite.

▸ Here we show only two derivations.

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. x}

{F(f(a)) ≐? f(F(a))};ε

  • ⇒Imit {f(G(f(a))) ≐? f(f(G(a)))};{F ↦ λx. f(G(x))}
  • ⇒Dec {G(f(a)) ≐? f(G(a))};{F ↦ λx. f(G(x))}
  • ⇒Proj {f(a) ≐? f(a)};{F ↦ λx. f(x),G ↦ λx. x}
  • ⇒Tr ∅;{F ↦ λx. f(x),G ↦ λx. x}
slide-119
SLIDE 119

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

re-solved form reached.

slide-120
SLIDE 120

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

{λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))};ε

re-solved form reached.

slide-121
SLIDE 121

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

{λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))};ε

  • ⇒Imit {λx. g(H1(f(x,G)),H2(f(x,G))) ≐? λx. g(f(x,G1),f(x,G2))};

{F ↦ λy. g(H1(y),H2(y))}

re-solved form reached.

slide-122
SLIDE 122

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

{λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))};ε

  • ⇒Imit {λx. g(H1(f(x,G)),H2(f(x,G))) ≐? λx. g(f(x,G1),f(x,G2))};

{F ↦ λy. g(H1(y),H2(y))}

  • ⇒Dec,Proj,Proj {λx. f(x,G) ≐? λx. f(x,G1),λx. f(x,G) ≐? λx. f(x,G2)};

{F ↦ λy. g(y,y),H1 ↦ λy. y,H2 ↦ λy. y}

re-solved form reached.

slide-123
SLIDE 123

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

{λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))};ε

  • ⇒Imit {λx. g(H1(f(x,G)),H2(f(x,G))) ≐? λx. g(f(x,G1),f(x,G2))};

{F ↦ λy. g(H1(y),H2(y))}

  • ⇒Dec,Proj,Proj {λx. f(x,G) ≐? λx. f(x,G1),λx. f(x,G) ≐? λx. f(x,G2)};

{F ↦ λy. g(y,y),H1 ↦ λy. y,H2 ↦ λy. y}

  • ⇒Dec,Tr,Dec,Tr {λx. G ≐? λx. G1,λx. G ≐? λx. G2};

{F ↦ λy. g(y,y),H1 ↦ λy. y,H2 ↦ λy. y}

re-solved form reached.

slide-124
SLIDE 124

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))}. ▸ Here we show only the successful derivation.

{λx. F(f(x,G)) ≐? λx. g(f(x,G1),f(x,G2))};ε

  • ⇒Imit {λx. g(H1(f(x,G)),H2(f(x,G))) ≐? λx. g(f(x,G1),f(x,G2))};

{F ↦ λy. g(H1(y),H2(y))}

  • ⇒Dec,Proj,Proj {λx. f(x,G) ≐? λx. f(x,G1),λx. f(x,G) ≐? λx. f(x,G2)};

{F ↦ λy. g(y,y),H1 ↦ λy. y,H2 ↦ λy. y}

  • ⇒Dec,Tr,Dec,Tr {λx. G ≐? λx. G1,λx. G ≐? λx. G2};

{F ↦ λy. g(y,y),H1 ↦ λy. y,H2 ↦ λy. y}

Pre-solved form reached.

slide-125
SLIDE 125

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(x,a) ≐? λx. f(G(a,x))}. ▸ One of the successful derivations.

slide-126
SLIDE 126

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(x,a) ≐? λx. f(G(a,x))}. ▸ One of the successful derivations.

{{λx. F(x,a) ≐? λx. f(G(a,x))};ε

slide-127
SLIDE 127

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(x,a) ≐? λx. f(G(a,x))}. ▸ One of the successful derivations.

{{λx. F(x,a) ≐? λx. f(G(a,x))};ε

  • ⇒Imit {λx. f(H(x,a)) ≐? λx. f(G(a,x))};{F ↦ λy1.λy2. f(H(y1,y2))}
slide-128
SLIDE 128

Higher-Order Preunification. Examples

Example

▸ Problem {λx. F(x,a) ≐? λx. f(G(a,x))}. ▸ One of the successful derivations.

{{λx. F(x,a) ≐? λx. f(G(a,x))};ε

  • ⇒Imit {λx. f(H(x,a)) ≐? λx. f(G(a,x))};{F ↦ λy1.λy2. f(H(y1,y2))}
  • ⇒Dec {λx. H(x,a) ≐? λx. G(a,x)};{F ↦ λy1.λy2. f(H(y1,y2))}

Flex-flex.

slide-129
SLIDE 129

Decidable Subcases

Some decidable subcases of higher-order unification:

▸ Monadic second-order unification. Terms do not contain

constants of arity greater than 1. Example: {λx.f(F(x)) ≐? λx.F(f(x))}.

▸ Second-order unification with linear occurrences of

second-order variables.

▸ Context unification. ▸ Linear second-order unification. ▸ Bounded second-order unification.

slide-130
SLIDE 130

Decidable Subcases

Some decidable subcases of higher-order unification:

▸ Unification with higher-order patterns. Pattern is a term t

such that for every subterm of the form F(s1,...,sn), the s’s are distinct variables bound in t. Example: {λx.λy. F(x) ≐? λx.λy. c(G(y,x))}.

▸ Higher-order matching. One side in the equations is a

closed term.

  • Example. {λx. F(x,λy. y) ≐? λx.f(x,a)}.