SLIDE 1 Completeness and Minimality
Detlef Plump University of York Annegret Habel Universit¨ at Oldenburg
SLIDE 2
Abstract objects and rules
Assumption 1 O and R are sets of objects and rules such that each S ⊆ R induces a binary relation ⇒S on O.
SLIDE 3 Examples: objects and rules
Graph rewriting: Double-pushout approach ([HP 01], previous talk) String rewriting:
- O = Σ∗ for some finite alphabet Σ
- R = {l → r | l, r ∈ Σ∗}
- v ⇒S w if v = xly and w = xry for some (l → r) ∈ S and x, y ∈ Σ∗
Term rewriting:
- O = T(F), set of closed terms over a finite set F of function symbols
- R = {l → r | l, r ∈ T(F, X), l ∈ X, Var(r) ⊆ Var(l)}
- t ⇒S u if u results from t by replacing any subterm σ(l) with σ(r),
where (l → r) ∈ S and σ: T(F, X) → T(F)
SLIDE 4 Abstract programs
Syntax (1) For every finite set S of rules, S and S ↓ are programs. (2) If P and Q are programs, then P; Q is a program. Semantics The semantics of a program P is a binary relation P on O: (1) S = ⇒S for every finite set S of rules (2) S ↓ = {x, y | x ⇒∗
S y and y ∈ Dom(⇒S)}
(3) P; Q = P ◦ Q (relation composition)
SLIDE 5 Example: term rewriting program
Negate = Eval↓; {true → false, false → true} where Eval = ¬(true) → false true ∧ x → x true ∨ x → true ¬(false) → true false ∧ x → false false ∨ x → x Note:
- F = {true, false, ¬, ∧, ∨}
- Negate: T(F) → T(F) satisfies
Negate(t) = true if t ⇒∗
Eval false
false if t ⇒∗
Eval true
SLIDE 6 Representation of objects as strings
Assumption 2 Σ is a finite alphabet and α: Σ∗ → O a surjective partial function. Graph rewriting: α = gra: Σ∗ → AC [HP 01] String rewriting: α: Σ∗ → Σ∗ is the identity function on Σ∗ Term rewriting:
- let Σ ⊇ F and ⌈t⌉ be the result of removing all parentheses and commas in a
term t; then ⌈ ⌉ is an injective function [Cohn 81]
- α: Σ∗ → T(F) is defined by
α(w) = t if there exists t ∈ T(F) with ⌈t⌉ = w, undefined
SLIDE 7
Example: representation of terms
g(f(a), h(b, c)) gfahbc α
SLIDE 8
Abstract computability
Let O1, O2 ⊆ O. A partial function f : O1 → O2 is computable if there is a partial computable string function f ′ : α−1(O1) → α−1(O2) such that for all w ∈ α−1(O1): (1) α(w) ∈ Dom(f) implies f(α(w)) = α(f ′(w)). (2) α(w) ∈ Dom(f) implies w ∈ Dom(f ′). O1 O2 α−1(O1) α−1(O2) f f ′ α α
SLIDE 9
Computational completeness
Completeness Condition There is a total function ( )• : Σ∗ → O such that: C1 (String functions) For every partial computable function f : S1 → S2 with S1, S2 ⊆ Σ∗, there is a program Pf such that for all w ∈ S1 and x ∈ O, w•Pfx if and only if f(w)• = x. C2 (Encoding) There is a program Encode such that for all x, y ∈ O, xEncodey if and only if x = α(w) and y = w• for some w ∈ Σ∗. C3 (Decoding) There is a program Decode such that for all w ∈ Σ∗ and y ∈ O, w•Decodey if and only if y = α(w).
SLIDE 10
Completeness Condition in diagrams
C1: O O S1 S2 Pf f ( )• ( )• Partial computable string functions can be simulated by programs on string-like objects. C2: O O Σ∗ Encode α ( )• All objects are encoded as string-like objects. C3: O O Σ∗ Decode α ( )• Decoding is inverse to encoding.
SLIDE 11
Example: encoding and decoding terms
g(f(a), h(b, c)) g1(f1(a1(h1(b1(c1(✷)))))) gfahbc Encode Decode α ( )•
SLIDE 12
Computational completeness
Theorem (Computational completeness) If the Completeness Condition is satisfied, then for every partial computable function f : O1 → O2 there is a program that computes f. Corollary (Completeness of string, term and graph programs) The languages of string, term and graph rewriting programs are computationally complete.
SLIDE 13
Minimality: graph, string and term programs
Theorem (Graph and string programs) For graph and string rewriting, omitting any of the three programming constructs results in an incomplete language. Theorem (Term programs) For term rewriting, omitting either iteration or sequential composition results in an incomplete language.
SLIDE 14 Future work
- Can single-step application of rules be omitted
– in term programs? – in string and graph programs computing functions not defined on the empty string/graph?
- Alternative way to guarantee completeness: adding contexts prior to
computations – string rewriting: enclose input string in special markers – term rewriting: add special top symbol – graph rewriting: ?
- Applying the framework to other rule-based models of computation
SLIDE 15
Structure of completeness proof
O1 O2 O O α−1(O1) α−1(O2) f Pf ′ f ′ Encode Decode ( )• α ( )• α The program P = Encode; Pf ′; Decode computes f, i.e. P ∩ (O1 × O2) = f.
SLIDE 16 Minimality: cyclic functions
Cyclic functions A partial function f : O → O is cyclic if there are o ∈ O and n ≥ 2 such that f(o) = o and f n(o) = o. Examples: Reversal of graph edges, string reversal and Boolean term negation are cyclic functions. Lemma No cyclic partial function is computable by a program of the form P ↓. Proof: Let f : O → O be cyclic and consider o ∈ O and n ≥ 2 such that f(o) = o and f n(o) = o. Suppose that there is a program P ↓ such that P ↓ = f. Then P ↓(f n−1(o)) = f n(o) = o, hence f n−1(o) ⇒∗
P o and o ∈ Dom(⇒P ). But
P ↓(o) = f(o) and o = f(o) imply o ⇒+
P f(o), a contradiction.
SLIDE 17 Minimality: neutral objects
Neutral objects
- ∈ O is neutral if for every finite set of rules R and every x ∈ O,
- ⇒+
R x implies x ∈ Dom(⇒R).
Examples: The empty graph and the empty string are neutral objects in graph and string rewriting, respectively. Lemma Let f : O1 → O2 be a partial function such that there is a neutral element
- ∈ Dom(f) with f(o) = o. Then for every program P1; . . . ; Pn that computes f,
- ne of the components Pi is a set of rules.