Maximally Parallel Contextual String Rewriting a 1 Traian Florin S , - - PowerPoint PPT Presentation

maximally parallel contextual string rewriting
SMART_READER_LITE
LIVE PREVIEW

Maximally Parallel Contextual String Rewriting a 1 Traian Florin S , - - PowerPoint PPT Presentation

Maximally Parallel Contextual String Rewriting a 1 Traian Florin S , erb anut , University of Bucharest Diaspora s , tiint , ific a 2016 1 joint work with Liviu P . Dinu Traian Florin S , erb anut , a (UNIBUC) Maximally


slide-1
SLIDE 1

Maximally Parallel Contextual String Rewriting

Traian Florin S

, erb˘

anut

, ˘

a1

University of Bucharest

Diaspora s

, tiint ,ific˘

a 2016

1joint work with Liviu P

. Dinu

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 1 / 26

slide-2
SLIDE 2

Motivation

Contents

1

Motivation

2

Technical background

3

Contextual String Rewriting Defining maximal parallelism Computing maximal parallel instances

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 2 / 26

slide-3
SLIDE 3

Motivation

Hyphenation rules!

(for Romanian)

Hyphenation for Romanian seems simple

8 insertion rules for regular words [Dinu, 2003] Regular: no consecutive vowels (to exclude diphthongs, triphthongs).

In the rules below vs stand for vowels, cs for consonants

1

(v1, -, cv2)

2

(v1, -, c1c2v2) if c1c2 ∈ {ch, gh} or (c1, c2) ∈ {b, c, d, f, g, h, p, t} × {l, r}

3

(v1c1, -, c2v2) if c1c2 {ch, gh} and (c1, c2) {b, c, d, f, g, h, p, t} × {l, r}

4

(v1c1c2, -, c3v2) if c1c2c3 ∈ {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

5

(v1c1, -, c2c3v2) if c1c2c3 {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

6

(v1c1c2, -, c3c4v2) if c2c3c4 ∈ {gst, nbl}

7

(v1c1, -, c2c3c4v2) if c2c3c4 {gst, nbl}

8

(v1c1c2, -, c3c4c5v2) if c1c2c3c4c5 ∈ {ptspr, stscr}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 3 / 26

slide-4
SLIDE 4

Motivation

Hyphenation example

lingvistic˘ a

1

(v1, -, cv2)

2

(v1, -, c1c2v2) if c1c2 ∈ {ch, gh} or (c1, c2) ∈ {b, c, d, f, g, h, p, t} × {l, r}

3

(v1c1, -, c2v2) if c1c2 {ch, gh} and (c1, c2) {b, c, d, f, g, h, p, t} × {l, r}

4

(v1c1c2, -, c3v2) if c1c2c3 ∈ {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

5

(v1c1, -, c2c3v2) if c1c2c3 {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

6

(v1c1c2, -, c3c4v2) if c2c3c4 ∈ {gst, nbl}

7

(v1c1, -, c2c3c4v2) if c2c3c4 {gst, nbl}

8

(v1c1c2, -, c3c4c5v2) if c1c2c3c4c5 ∈ {ptspr, stscr}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 4 / 26

slide-5
SLIDE 5

Motivation

Hyphenation example

lingvistic˘ a lin-gvistic˘ a by rule (5)

1

(v1, -, cv2)

2

(v1, -, c1c2v2) if c1c2 ∈ {ch, gh} or (c1, c2) ∈ {b, c, d, f, g, h, p, t} × {l, r}

3

(v1c1, -, c2v2) if c1c2 {ch, gh} and (c1, c2) {b, c, d, f, g, h, p, t} × {l, r}

4

(v1c1c2, -, c3v2) if c1c2c3 ∈ {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

5

(v1c1, -, c2c3v2) if c1c2c3 {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

6

(v1c1c2, -, c3c4v2) if c2c3c4 ∈ {gst, nbl}

7

(v1c1, -, c2c3c4v2) if c2c3c4 {gst, nbl}

8

(v1c1c2, -, c3c4c5v2) if c1c2c3c4c5 ∈ {ptspr, stscr}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 4 / 26

slide-6
SLIDE 6

Motivation

Hyphenation example

lingvistic˘ a lin-gvistic˘ a by rule (5) lin-gvis-tic˘ a by rule (3) lin-gvis-ti-c˘ a by rule (1)

1

(v1, -, cv2)

2

(v1, -, c1c2v2) if c1c2 ∈ {ch, gh} or (c1, c2) ∈ {b, c, d, f, g, h, p, t} × {l, r}

3

(v1c1, -, c2v2) if c1c2 {ch, gh} and (c1, c2) {b, c, d, f, g, h, p, t} × {l, r}

4

(v1c1c2, -, c3v2) if c1c2c3 ∈ {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

5

(v1c1, -, c2c3v2) if c1c2c3 {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm}

6

(v1c1c2, -, c3c4v2) if c2c3c4 ∈ {gst, nbl}

7

(v1c1, -, c2c3c4v2) if c2c3c4 {gst, nbl}

8

(v1c1c2, -, c3c4c5v2) if c1c2c3c4c5 ∈ {ptspr, stscr}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 4 / 26

slide-7
SLIDE 7

Motivation

Parallel hyphenation

Approach [Dinu, 2009] Insertion systems can model syllabification Insertion can be done in parallel by sharing the context Maximally parallel application of rules yields one-step hyphenation Why? Suggested as possible at cognitive level by some linguists lingvistic˘ a =⇒ lingvistic˘ a =⇒ lin-gvis-ti-c˘ a

(v1, -, cv2) (v1c1, -, c2v2) if c1c2 {ch, gh} and (c1, c2) {b, c, d, f, g, h, p, t} × {l, r} (v1c1, -, c2c3v2) if c1c2c3 {lpt, mpt, mpt

,, ncs , , nct, nct ,, ndv, rct, rtf, stm} Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 5 / 26

slide-8
SLIDE 8

Motivation

Connections with other formalisms

Contextual description of rules Insertion/Deletion Systems [Kari, 1991]

String Rewriting + Insertion Rules + Deletion Rules + Parallel application

K concurrent rewriting [Ros

, u, S , erb˘

anut

, ˘

a, 2010]

Term rewriting + contextual K rules + Parallel application

Maximally parallel application of rules L-Systems [Lindenmayer, 1968]

Context free grammars with maximally parallel derivation Context Sensitive L-Systems have some notion of sharing However, the context is usually altered during the rewrite

P Systems [P˘ aun, 1998]

Multiset rewriting with local rules Contextual sharing in the promoter/inhibitor variant

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 6 / 26

slide-9
SLIDE 9

Motivation

Contributions

Contextual string rewriting rules

as a (slight) variation of rules from Insertion/Deletion Systems as a specialization of K rules to string rewriting

Formal definition for (maximal) parallel matching and derivation Transformations to TRSs

for simulating one-step maximal parallel derivation

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 7 / 26

slide-10
SLIDE 10

Technical background

Contents

1

Motivation

2

Technical background

3

Contextual String Rewriting Defining maximal parallelism Computing maximal parallel instances

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 8 / 26

slide-11
SLIDE 11

Technical background

Formal languages

Alphabets: Σ, . . .

are sets of letters: a, b, c, . . .

Words: u, v, w, x, y,. . .

are (finite) sequences of letters

The set of all words over alphabet Σ is denoted Σ∗ The empty word is denoted by λ Concatenation of two words is obtained by juxtaposition _ _ and is associative, with unit λ

(Σ∗, _ _, λ) is the free monoid generated by Σ

A formal language over Σ is a subset of Σ∗.

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 9 / 26

slide-12
SLIDE 12

Technical background

Insertion/Deletion Systems

[Kari, 1991] Syntax An insertion-deletion system is a tuple Γ = (Σ, T, A, I, D), where

Σ is an alphabet

T ⊆ Σ is the terminal alphabet A ⊆ Σ∗ is the set of axioms (starting symbols) I (the insertion rules) and D (the deletion rules) are

finite sets of triples of the form (u, x, v), where u, x, v ∈ Σ∗ with x λ

(Sequential) Semantics Insertion rule (u, x, v) specifies insertion of x in context (u, v) u v

= > u x v

Deletion rule (u, x, v) specifies deletion of x in context (u, v) u x v

= > u v

The language generated by Γ is L(Γ) = {w ∈ T∗ | ∃u ∈ A.u ⇒∗ w}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 10 / 26

slide-13
SLIDE 13

Technical background

Insertion grammars with (maximum) parallel derivation

[Dinu, 2009] Syntax An insertion grammar Γ = (Σ, A, I) is a special case of insertion/deletion systems, where There are no non-terminals ( T = Σ ) There are no deletion rules ( D = ∅ ) Parallel Semantics w ⇛Γ z iff w = w0 w0w1 w1 . . . wr−1 wr−1wr wr, where r ≥ 1 (r maximal for maximum derivation) for all 1 ≤ i ≤ r, there exist (ui, xi, vi) ∈ I such that

wi−1 wi−1 ends with ui wi wi starts with vi

z = w0 w0x1w1 w1x2 . . . wr−1 wr−1xrwr wr

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 11 / 26

slide-14
SLIDE 14

Technical background

Insertion grammars derivation examples

Example Let Σ = {a, b, c, d}, A = {abcd}, and I = {(a, a, b), (b, b, c), (c, cd, d)} Language for non-maximally parallel derivation: a+b+cndn Language for maximum parallel derivation: anbncndn Example Let Σ = {a, b}, A = {a, b}, and I = {(a, b, λ), (λ, ba, b)}. Language for non-maximally parallel derivation:

{a} ∪ {(ab+)+} ∪ {b(ab+)∗}

Language for maximum parallel derivation: “Fibonacci words”:

{a, b, ab, bab, abbab, bababbab, abbabbababbab, . . .}

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 12 / 26

slide-15
SLIDE 15

Technical background

K rewriting

[Ros

, u, S , erb˘

anut

, ˘

a, 2010]

Contextual rules for concurrent term rewriting with sharing

Syntax A K rule is of the form k[l1 → r1, . . . , ln → rn] where k is an n-ary context (shared by concurrent rule applications) l1, . . . , ln are the parts to be rewritten r1, . . . , rn are their corresponding replacements 2D notation: k[ l1 r1

, . . . ,

ln rn

]

Semantics Non-Concurrent through flattening to term rewrite rules k[l_1, ... ,l_n]

= > k[r_1, ... ,r_n]

Concurrent through graph rewriting [S

, erb˘

anut

, ˘

a, Ros

, u, 2011] Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 13 / 26

slide-16
SLIDE 16

Technical background

Insertion/Deletion rules as K rules

Insertion rule (u,x,v): u

  • x

v Deletion rule (u,x,v): u x

  • v
  • is the generic unit of K for the given (associative) operation

It will be instantiated by λ in this particular case. Natural Question Why not having general rules of the form u x y v ?

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 14 / 26

slide-17
SLIDE 17

Contextual String Rewriting

Contents

1

Motivation

2

Technical background

3

Contextual String Rewriting Defining maximal parallelism Computing maximal parallel instances

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 15 / 26

slide-18
SLIDE 18

Contextual String Rewriting

Contextual String Rewriting

Definition A Contextual string rewrite rule is of the form u x → y v, where u, x, y, v are words over Σ uxv, xy ∈ Σ+ Reading: x rewrites to y in the context (u, v) A Contextual SRS is a set R of contextual string rewrite rules. Non concurrent semantics Through rewrite rules: u x v => u y v

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 16 / 26

slide-19
SLIDE 19

Contextual String Rewriting Defining maximal parallelism

Formalizing a parallel matching instance

Definition

π : w0

w0y1ρ1w1 w1y2ρ2w2 w2 . . . wr−1 wr−1yrρrwr wr is a parallel instance of R on w if for all 1 ≤ i ≤ r,

ρi is the rule ui xi → yi vi ∈ R, and

wi−1 wi−1 ends with ui wi wi starts with vi

The parallel rewriting step induced by π is w0 w0x1w1 w1x2w2 w2 . . . xrwr wr ⇛R,π w0 w0y1w1 w1y2w2 w2 . . . yrwr wr

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 17 / 26

slide-20
SLIDE 20

Contextual String Rewriting Defining maximal parallelism

Parallel matching instance

Example

Given the rules:

ρ1 : licen c → s e

and

ρ2 : ( → λ

a parallel instance for mylicence(driving) could be

π : mylicen s ρ1 e( λ ρ2 driving)

and we have that mylicence(driving) ⇛R,π mylicense(driving)

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 18 / 26

slide-21
SLIDE 21

Contextual String Rewriting Defining maximal parallelism

Parallel instance refinement

Let π : w0 w0y1ρ1w1 w1y2ρ2w2 w2 . . . wr−1 wr−1yrρrwr wr be an instance on a word w and let ρi be ui xi → yi vi for each 1 ≤ i ≤ r. Then: Each wi wi starts with vi and ends with ui+1 Definition (π ≻ π′)

π is refinable if any wi, 0 ≤ i ≤ r, admits some parallel instance πi : wi,0

wi,0yi,1ρi,1 wi,1 wi,1 such that by replacing wi by πi in π we still get a parallel instance of w. i.e., wi,0 wi,0 still starts with vi and wi,1 wi,1 still ends with ui+1 iff the “split” of wi wi was not inside either vi or ui+1

π is maximal if cannot be refined anymore.

Note: To refine π, vi and ui+1 must not overlap on wi for some 0 ≤ i ≤ r

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 19 / 26

slide-22
SLIDE 22

Contextual String Rewriting Defining maximal parallelism

Parallel instance refinement

Example

Given the rules:

ρ1 : licen c → s e ρ2 : ( → λ ρ3 : λ → (

Then, the previous parallel instance of mylicence(driving):

π : mylicen s ρ1 e( λ ρ2 driving)

can be further refined using ρ3 to

π′ : mylicen s ρ1 e ρ3 (

( λ ρ2 driving) which is maximal w.r.t the rules above, and we have that mylicence(driving) ⇛R,π′ mylicense (driving)

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 20 / 26

slide-23
SLIDE 23

Contextual String Rewriting Defining maximal parallelism

Results Summary

Rewriting using parallel instances has the following properties: Is sound and complete for regular string rewriting The refinement relation terminates

Each refinement matches or consumes at least one letter (uxv λ) Each letter can be matched by at most two rules Therefore, the length of any refinement chain for |w| is at most 2|w|

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 21 / 26

slide-24
SLIDE 24

Contextual String Rewriting Computing maximal parallel instances

Contents

1

Motivation

2

Technical background

3

Contextual String Rewriting Defining maximal parallelism Computing maximal parallel instances

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 22 / 26

slide-25
SLIDE 25

Contextual String Rewriting Computing maximal parallel instances

Rasing the flag

To each letter a in a matching instance we can associate two flags to track when it is matched by rules A ✛ flag raised to the left when a was matched by some u A ✛ flag to the right when a was matched by some v The y parts of an instance are marked in red (and treated as a single letter) Example Given ρ1 : licen c → s e and ρ2 : ( → λ , the flag encoding of mylicen s ρ1 e( λ ρ2 driving) would be m y ✛ l ✛ i ✛ c ✛ e ✛ n s e

✛ ✛

( λ d r i v i n g )

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 23 / 26

slide-26
SLIDE 26

Contextual String Rewriting Computing maximal parallel instances

Encoding rules

Idea: make sure the split of a wi does not occur inside the vi✛

  • r ✛

ui+1 part u x → y v and x λ or uv λ u

x ✛ v → ✛ u

y ✛ v✛

λ → y v

Z ✛ v → Z y ✛ v✛ , and

? ✛ ✛

v → ?

y ✛ v✛

,

u λ → y u

Z → ✛ u

y Z, and u

✛ ✛ ? → ✛

u

y ✛

?,2

Example We can use the encoding ?

✛ ✛

( → ?

✛ (

  • f rule λ → ( to refine

m y ✛ l ✛ i ✛ c ✛ e ✛ n s e

✛ ✛

( λ d r i v i n g ) to m y ✛ l ✛ i ✛ c ✛ e ✛ n s e

✛ (

✛ λ d r i v i n g )

2✛

indicates the flags are not modified by the rule (i.e., stands for flag variables); ? is a variable of sort letter; Z is a variable of sort word

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 24 / 26

slide-27
SLIDE 27

Contextual String Rewriting Computing maximal parallel instances

Results Summary

The proposed transformations have the following properties: Properly encoding the refinement of parallel instances Erasing the extra flags and marks one obtains the rewritten word (through the current instance) Solve the problem of computing a maximal instance

Every normal form of the transformed systems encodes a maximal parallel instance The transformed systems terminate for any input Any maximal parallel instance of w is computed in at most 2|w| steps

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 25 / 26

slide-28
SLIDE 28

Contextual String Rewriting Computing maximal parallel instances

Bibliography

Dinu, 2003 An approach to syllables via some extensions of Marcus contextual grammars LP Dinu - Grammars Dinu, 2009 On Insertion Grammars with Maximum Parallel Derivation - Fundamenta Informaticae 93 (4), 357-369 Kari, 1991 On Insertion and Deletion in Formal Languages. Ph.D. Thesis, University of Turku, 1991 Lindenmayer, 1968 Mathematical models for cellular interaction in

  • development. J. Theoret. Biology, 18:280—315

P˘ aun, 1998 Computing with Membranes. TUCS Report 208. Turku Centre for Computer Science Ros

, u, S , erb˘

anut

, ˘

a, 2010 An overview of the K semantic framework. Journal

  • f Logic and Algebraic Programming

S

, erb˘

anut

, ˘

a, Ros

, u, 2011 A Truly Concurrent Semantics for the K Framework

Based on Graph Transformations. ICGT’11

Traian Florin S

, erb˘

anut

a (UNIBUC) Maximally Parallel Contextual String Rewriting Diaspora s

,tiint ,ific˘

a 2016 26 / 26