Order-Sorted Unification with Regular Expression Sorts (Work in - - PowerPoint PPT Presentation

order sorted unification with regular expression sorts
SMART_READER_LITE
LIVE PREVIEW

Order-Sorted Unification with Regular Expression Sorts (Work in - - PowerPoint PPT Presentation

Order-Sorted Unification with Regular Expression Sorts (Work in Progress) Temur Kutsia 1 Mircea Marin 2 1 RISC, JKU Linz, Austria. 2 University of Tsukuba, Japan Presented by Laura Kov acs Motivation Advantages of using sorts in logic:


slide-1
SLIDE 1

Order-Sorted Unification with Regular Expression Sorts

(Work in Progress) Temur Kutsia1 Mircea Marin2

1RISC, JKU Linz, Austria. 2University of Tsukuba, Japan

Presented by Laura Kov´ acs

slide-2
SLIDE 2

Motivation

Advantages of using sorts in logic:

◮ More adequate coding of mathematical problems in logic. ◮ Simplification of algebraic specifications. ◮ Compact and natural formalizations of AI problems. ◮ Supporting typed computations. ◮ ...

slide-3
SLIDE 3

Motivation

Sorted unification:

◮ Walther in 1988 extended first-order unification to

  • rder-sorted case:

◮ Infinitely many sorts, ordered ◮ No overloading ◮ Problems may have infinitely many unifiers ◮ Complete procedure to enumerate unifiers ◮ Minimal complete set of unifiers might not exist ◮ If the set of sorts is finite, the problems becomes finitary

slide-4
SLIDE 4

Motivation

Sorted unification:

◮ Walther in 1988 extended first-order unification to

  • rder-sorted case:

◮ Infinitely many sorts, ordered ◮ No overloading ◮ Problems may have infinitely many unifiers ◮ Complete procedure to enumerate unifiers ◮ Minimal complete set of unifiers might not exist ◮ If the set of sorts is finite, the problems becomes finitary

◮ Further generalizations: Schmidt-Schauss 1989, Weidenbach

1996:

◮ Sorts as unary predicates ◮ Term declarations allowed ◮ Undecidable

slide-5
SLIDE 5

Motivation

Sorted unification:

◮ Walther in 1988 extended first-order unification to

  • rder-sorted case:

◮ Infinitely many sorts, ordered ◮ No overloading ◮ Problems may have infinitely many unifiers ◮ Complete procedure to enumerate unifiers ◮ Minimal complete set of unifiers might not exist ◮ If the set of sorts is finite, the problems becomes finitary

◮ Further generalizations: Schmidt-Schauss 1989, Weidenbach

1996:

◮ Sorts as unary predicates ◮ Term declarations allowed ◮ Undecidable

◮ Other works: Kirchner 1988, Hendrix, Mesegeur 2008

(equational OSU).

slide-6
SLIDE 6

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

slide-7
SLIDE 7

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

slide-8
SLIDE 8

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

◮ Finite set of basic sorts B and order .

slide-9
SLIDE 9

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

◮ Finite set of basic sorts B and order . ◮ Sorts are regular expressions over B, denoted R. extends to

sorts.

slide-10
SLIDE 10

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

◮ Finite set of basic sorts B and order . ◮ Sorts are regular expressions over B, denoted R. extends to

sorts.

◮ Set of variables VR for each R ∈ R.

slide-11
SLIDE 11

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

◮ Finite set of basic sorts B and order . ◮ Sorts are regular expressions over B, denoted R. extends to

sorts.

◮ Set of variables VR for each R ∈ R. ◮ Set of function symbols FR,s for each R ∈ R, s ∈ B.

slide-12
SLIDE 12

Motivation

Closer look at Walther’s work:

◮ Set of sorts S and order ≤. ◮ Set of variables Vs for each s ∈ S. ◮ Set of function symbols Fw,s for each w ∈ S∗, s ∈ S. ◮ All these sets are pairwise disjoint.

Our contribution:

◮ Finite set of basic sorts B and order . ◮ Sorts are regular expressions over B, denoted R. extends to

sorts.

◮ Set of variables VR for each R ∈ R. ◮ Set of function symbols FR,s for each R ∈ R, s ∈ B. ◮ Sets of function symbols are not required to be disjoint.

slide-13
SLIDE 13

Related Work

WU SYNU WURC SEQU OSU REOSU

◮ SYNU - Syntactic unification (Robinson 1965). ◮ WU - Word unification (Schulz 1990). ◮ OSU - Order-sorted unification (Walther 1988). ◮ SEQU - Sequence unification (Kutsia 2002). ◮ WURC - Word unification with regular constraints (Schulz

1990).

◮ REOSU - Regular expression order-sorted unification.

slide-14
SLIDE 14

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Sort information.

Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q. x, z : s∗ y, u : q a, b : s f : q∗ → r g : q → q, s + r → s

◮ Solution: {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, b)}. ◮ v: fresh variable of sort s + r. ◮ u → v weakens g(u) : q to g(v) : s.

slide-15
SLIDE 15

Sorts

◮ Finite set B of basic sorts, partially ordered with the relation

.

◮ s, r, q denote basic sorts. ◮ Regular expression sorts:

R ::= s | 1 | R1.R2 | R1+R2 | R∗.

◮ Corresponding regular language [

[R] ]: The set of words of base sorts, defined as usual.

slide-16
SLIDE 16

Sorts

Extensions of :

◮ On words of base sorts:

s1 · · · sn r1 · · · rn iff si ri for all 1 ≤ i ≤ n.

slide-17
SLIDE 17

Sorts

Extensions of :

◮ On words of base sorts:

s1 · · · sn r1 · · · rn iff si ri for all 1 ≤ i ≤ n.

◮ On sets of words of base sorts:

S1 S2 iff for each w1 ∈ S1 there is w2 ∈ S2 such that w1 w2.

slide-18
SLIDE 18

Sorts

Extensions of :

◮ On words of base sorts:

s1 · · · sn r1 · · · rn iff si ri for all 1 ≤ i ≤ n.

◮ On sets of words of base sorts:

S1 S2 iff for each w1 ∈ S1 there is w2 ∈ S2 such that w1 w2.

◮ On (regular expression) sorts:

R1 R2 iff [ [R1] ] [ [R2] ].

slide-19
SLIDE 19

Sorts

Extensions of :

◮ On words of base sorts:

s1 · · · sn r1 · · · rn iff si ri for all 1 ≤ i ≤ n.

◮ On sets of words of base sorts:

S1 S2 iff for each w1 ∈ S1 there is w2 ∈ S2 such that w1 w2.

◮ On (regular expression) sorts:

R1 R2 iff [ [R1] ] [ [R2] ].

◮ R1 ≃ R2 means R1 R2 and R2 R1.

slide-20
SLIDE 20

Alphabet

◮ Countable set of variables VR for each sort R, satisfying

conditions:

◮ VR1 = VR2 if R1 ≃ R2. ◮ VR1 ∩ VR2 = ∅ if R1 ≃ R2.

slide-21
SLIDE 21

Alphabet

◮ Countable set of variables VR for each sort R, satisfying

conditions:

◮ VR1 = VR2 if R1 ≃ R2. ◮ VR1 ∩ VR2 = ∅ if R1 ≃ R2.

◮ A family of sets of function symbols {FR.s | R ∈ R, s ∈ B},

satisfying conditions:

◮ FR1.s1 = FR2.s2 iff R1.s1 ≃ R2.s2 ◮ Monotonicity: If f ∈ FR1.s1 ∩ FR2.s2 and R1 R2, then s1 s2. ◮ Preregularity: If f ∈ FR1.s1 and R2 R1, then there is a

  • least element in the set {s | f ∈ FR.s and R2 R}.

◮ Finite overloading: For each f , the set {FR.s | f ∈ FR.s} is

finite.

slide-22
SLIDE 22

Alphabet

◮ Countable set of variables VR for each sort R, satisfying

conditions:

◮ VR1 = VR2 if R1 ≃ R2. ◮ VR1 ∩ VR2 = ∅ if R1 ≃ R2.

◮ A family of sets of function symbols {FR.s | R ∈ R, s ∈ B},

satisfying conditions:

◮ FR1.s1 = FR2.s2 iff R1.s1 ≃ R2.s2 ◮ Monotonicity: If f ∈ FR1.s1 ∩ FR2.s2 and R1 R2, then s1 s2. ◮ Preregularity: If f ∈ FR1.s1 and R2 R1, then there is a

  • least element in the set {s | f ∈ FR.s and R2 R}.

◮ Finite overloading: For each f , the set {FR.s | f ∈ FR.s} is

finite.

◮ Notation. We use

◮ f : R → s for f ∈ FR.s ◮ a : s for a ∈ F1.s ◮ x : R for x ∈ VR

slide-23
SLIDE 23

Terms

The set of terms over V = ∪R∈RVR and F = ∪R∈R,s∈BFR.s: The least set T (F, V) = {TR(F, V) | R ∈ R} such that

◮ VR ⊆ TR(F, V). ◮ TR1(F, V) ⊆ TR2(F, V) if R1 R2. ◮ If f : R → s and 1 R, then f (ǫ) ∈ Ts(F, V). ◮ If f : R → s, ti ∈ TRi(F, V) for 1 ≤ i ≤ n, n ≥ 1, such that

  • R1. · · · .Rn R, then f (t1, . . . , tn) ∈ Ts(F, V).
slide-24
SLIDE 24

Terms

The set of terms over V = ∪R∈RVR and F = ∪R∈R,s∈BFR.s: The least set T (F, V) = {TR(F, V) | R ∈ R} such that

◮ VR ⊆ TR(F, V). ◮ TR1(F, V) ⊆ TR2(F, V) if R1 R2. ◮ If f : R → s and 1 R, then f (ǫ) ∈ Ts(F, V). ◮ If f : R → s, ti ∈ TRi(F, V) for 1 ≤ i ≤ n, n ≥ 1, such that

  • R1. · · · .Rn R, then f (t1, . . . , tn) ∈ Ts(F, V).

Lemma

For each term t there exists a -minimal sort R that is unique modulo ≃ such that t ∈ TR(F, V).

slide-25
SLIDE 25

Semantics of Sorts

◮ sem(s) = Ts(F): Semantics of a basic sort s is the set of

ground terms of sort s.

◮ Semantics of a regular sort is the set of ground term

sequences of the corresponding sort:

◮ sem(1) = {ǫ}. ◮ sem(R1.R2) = {(˜

s1,˜ s2) | ˜ s1 ∈ sem(R1),˜ s2 ∈ sem(R2)}.

◮ sem(R1+R2) = sem(R1) ∪ sem(R2). ◮ sem(R∗) = sem(R)∗.

slide-26
SLIDE 26

Substitutions

◮ Substitution: a well-sorted mapping from variables to

sequences of terms, which is identity almost everywhere.

◮ Well-sortedness (of σ): sort(σ(x)) sort(x) for all x. ◮ Standard notions defined in the usual way. ◮ Subsumption σ ≤X ϑ: σ is more general than ϑ on the set of

variables X

slide-27
SLIDE 27

Algorithms for Sorts

We will need to

◮ Decide . ◮ Compute greatest lower bounds for regular expressions. ◮ Compute weakening substitutions.

N.B. Our basic sorts are ordered.

slide-28
SLIDE 28

Algorithms for Sorts. Deciding

◮ closure R of a sort R:

◮ s =

rs r

◮ 1 = 1 ◮ R1.R2 = R1.R2 ◮ R1+R2 = R1+R2 ◮ R∗ = R

◮ Nice property: S R iff [

[S] ] ⊆ [ [R] ].

◮ Deciding [

[S] ] ⊆ [ [R] ] does not need to take into account

  • rdering on basic sorts.

◮ [

[S] ] ⊆ [ [R] ] can be decided by Antimirov’s algorithm.

◮ The problem is PSPACE-complete.

slide-29
SLIDE 29

Algorithms for Sorts. Compute glb

◮ Without ordering on basic sorts, glb of regular expression sorts

is their intersection.

◮ In our case, we modify Antimirov-Mosses intersection

algorithm:

◮ To intersect two basic sorts, compute maximal elements in the

set of their lower bounds.

◮ The number of such maximal elements is finite. Their sum is

the glb of the given basic sorts.

◮ Requires double-exponential time.

slide-30
SLIDE 30

Algorithms for Sorts. Compute Weakening Substitutions

◮ Weakening substitution for a term sequence ˜

t towards a sort R: A substitution σ such that sort(˜ tσ) R.

◮ What is it good for?

Example

◮ Let x : s, f : R1 → s1, f : R2 → s2, y : R2. ◮ Sort ordering: R1 R2, s1 s s2.

slide-31
SLIDE 31

Algorithms for Sorts. Compute Weakening Substitutions

◮ Weakening substitution for a term sequence ˜

t towards a sort R: A substitution σ such that sort(˜ tσ) R.

◮ What is it good for?

Example

◮ Let x : s, f : R1 → s1, f : R2 → s2, y : R2. ◮ Sort ordering: R1 R2, s1 s s2. ◮ Then x and f (y) do not unify: sort(f (y)) = s2 s = sort(x).

slide-32
SLIDE 32

Algorithms for Sorts. Compute Weakening Substitutions

◮ Weakening substitution for a term sequence ˜

t towards a sort R: A substitution σ such that sort(˜ tσ) R.

◮ What is it good for?

Example

◮ Let x : s, f : R1 → s1, f : R2 → s2, y : R2. ◮ Sort ordering: R1 R2, s1 s s2. ◮ Then x and f (y) do not unify: sort(f (y)) = s2 s = sort(x). ◮ But, if we weaken sort(f (y)) to s1, then unification is possible.

slide-33
SLIDE 33

Algorithms for Sorts. Compute Weakening Substitutions

◮ Weakening substitution for a term sequence ˜

t towards a sort R: A substitution σ such that sort(˜ tσ) R.

◮ What is it good for?

Example

◮ Let x : s, f : R1 → s1, f : R2 → s2, y : R2. ◮ Sort ordering: R1 R2, s1 s s2. ◮ Then x and f (y) do not unify: sort(f (y)) = s2 s = sort(x). ◮ But, if we weaken sort(f (y)) to s1, then unification is possible. ◮ To weaken, we take the instance of f (y) under the

substitution {y → z}, where sort(z) = R1, which gives sort(f (z)) = s1.

slide-34
SLIDE 34

Algorithms for Sorts. Compute Weakening Substitutions

◮ A rule-based algorithm has been developed to compute

weakening substitutions.

◮ The algorithm is sound, complete, and terminating. ◮ The finite overloading property of the alphabet and the finite

factorization property of regular expressions are important for termination.

◮ Each weakening substitution is a variable renaming

substitution.

◮ Details in the paper.

slide-35
SLIDE 35

Unification Type, Decidability, Procedure

◮ Type: Infinitary. ◮ Decidability: Unknown. (Conjectured to be decidable. No

formal proof yet).

◮ Unification procedure: Involves computing weakening

  • substitutions. Sound and complete. Not minimal in general.
slide-36
SLIDE 36

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

slide-37
SLIDE 37

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {f (x, y, z) . = f (f (x), g(u), a, b)}; ε = ⇒decompose

slide-38
SLIDE 38

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {f (x, y, z) . = f (f (x), g(u), a, b)}; ε = ⇒decompose {(x, y, z) . = (f (x), g(u), a, b)}; ε = ⇒project

slide-39
SLIDE 39

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {f (x, y, z) . = f (f (x), g(u), a, b)}; ε = ⇒decompose {(x, y, z) . = (f (x), g(u), a, b)}; ε = ⇒project {(y, z) . = (f (ǫ), g(u), a, b)}; {x → ǫ} = ⇒eliminate

slide-40
SLIDE 40

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {z . = (g(u), a, b)}; {x → ǫ, y → f (ǫ)} = ⇒weaken widen (sort(v) = s + r), (sort(z1) = s∗)

slide-41
SLIDE 41

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {z . = (g(u), a, b)}; {x → ǫ, y → f (ǫ)} = ⇒weaken widen (sort(v) = s + r), (sort(z1) = s∗) {z1 . = (a, b)}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), z1)} = ⇒widen (sort(z2) = s∗)

slide-42
SLIDE 42

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {z2 . = b}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, z2), z1 → (a, z2)} = ⇒eliminate

slide-43
SLIDE 43

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {z2 . = b}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, z2), z1 → (a, z2)} = ⇒eliminate {ǫ . = ǫ}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, b), z1 → (a, b), z2 → b} = ⇒trivial

slide-44
SLIDE 44

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: {z2 . = b}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, z2), z1 → (a, z2)} = ⇒eliminate {ǫ . = ǫ}; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, b), z1 → (a, b), z2 → b} = ⇒trivial ∅; {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, b), z1 → (a, b), z2 → b}

slide-45
SLIDE 45

Unification Procedure.

Example

◮ Solve f (x, y, z) .

= f (f (x), g(u), a, b)

◮ Basic sorts: s, r, q. Ordering: s ≺ q, r ≺ q.

x, z : s∗ f : q∗ → r y, u : q g : q → q, s + r → s a, b : s

Unification: (Restricting the solution to the original problem variables) {x → ǫ, y → f (ǫ), u → v, z → (g(v), a, b)} sort(v) = s + r

slide-46
SLIDE 46

Summary

◮ Order-sorted unification extended to regular expression sorts. ◮ The obtained problem generalizes some known unification

problems.

◮ Sort weakening algorithm constructed. Its soundness,

completeness, and termination are proved.

◮ An algorithm for computing greatest lower bound of a set of

sorts is sketched.

◮ Unification type is infinitary: proved. ◮ Procedure for enumerating a (minimal) complete set of

unifiers constructed. Its soundness and completeness proved.

◮ Decidability to be proved.