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
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 Motivation
Sorted unification:
◮ Walther in 1988 extended first-order unification to
◮ 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 Motivation
Sorted unification:
◮ Walther in 1988 extended first-order unification to
◮ 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 Motivation
Sorted unification:
◮ Walther in 1988 extended first-order unification to
◮ 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
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
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
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
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
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
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
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
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
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
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
Sorts
Extensions of :
◮ On words of base sorts:
s1 · · · sn r1 · · · rn iff si ri for all 1 ≤ i ≤ n.
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
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
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 Alphabet
◮ Countable set of variables VR for each sort R, satisfying
conditions:
◮ VR1 = VR2 if R1 ≃ R2. ◮ VR1 ∩ VR2 = ∅ if R1 ≃ R2.
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 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 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 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 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
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
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 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
◮ [
[S] ] ⊆ [ [R] ] can be decided by Antimirov’s algorithm.
◮ The problem is PSPACE-complete.
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
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
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
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.