• No results found

Playing with patterns, searching for strings

N/A
N/A
Protected

Academic year: 2021

Share "Playing with patterns, searching for strings"

Copied!
21
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Playing with patterns, searching for strings

Citation for published version (APA):

Woude, van der, J. C. S. P. (1987). Playing with patterns, searching for strings. (Computing science notes; Vol. 8713). Technische Universiteit Eindhoven.

Document status and date: Published: 01/01/1987

Document Version:

Publisher’s PDF, also known as Version of Record (includes final page, issue and volume numbers)

Please check the document version of this publication:

• A submitted manuscript is the version of the article upon submission and before peer-review. There can be important differences between the submitted version and the official published version of record. People interested in the research are advised to contact the author for the final version of the publication, or visit the DOI to the publisher's website.

• The final author version and the galley proof are versions of the publication after peer review.

• The final published version features the final layout of the paper including the volume, issue and page numbers.

Link to publication

General rights

Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain

• You may freely distribute the URL identifying the publication in the public portal.

If the publication is distributed under the terms of Article 25fa of the Dutch Copyright Act, indicated by the “Taverne” license above, please follow below link for the End User Agreement:

www.tue.nl/taverne

Take down policy

If you believe that this document breaches copyright please contact us at: openaccess@tue.nl

providing details and we will investigate your claim.

(2)

Playing with patterns, searching for strings

J aap van der Woudc

87/13

(3)

COMPUTING SCIENCE NOTES

This is a series of notes of the Computing Science Section of the Department of Mathematics and Computing Science of Eindhoven University of Technol-ogy.

Since many of these notes are preliminary versions or may be publiShed else-where, they have a limited distribution only and are not for review.

Copies of these notes are available from the author or the editor.

Eindhoven University of Technology

Department of Mathematics and Computing Science P.O. Box 513

5600 MB Eindhoven The Netherlands All rights reserved

(4)

Playing with patterns, searching for strings

Jaap van der Woude

june 87

§o

Pattern identification is a source of several iostructive programming exercises. We shall present one such exercise that is especially interesting for problems dealing with periodicity. In particu-lar it enables US to treat preprocessing and search in the Knuth-Morris-Pratt pattern search algorithm as a unity.

Some remarks on names and notations:

Let L be a fixed alphabet. A word over L, i.e. an element of the free monoid (L* , A) generated by L, will be called a string. lC" \ (A) will be denoted by L'", the nonempty strings. (In the sequel, capitals refer to strings, lowercase letters to naturals (including 0) or functions, unless stated otherwise.)

Let X be a string. In order to facilitate references to the length IX I of X and symbols occuring in X, we shall write X (i : 0,,;, i <N) . Then IX I = N and X (i) is the i + 1'· symbol of X.

If n ,,;, N we shall write X J, n for X (i : 0,,;, i < n), the prefix of X withe length n.

A string X is called periodic if X

=

pm for some PEL'" and m ;:, 2, where pm is the concate-nation of m copies of P. In that case, P as well as I P I is called a period of X. The period of X is the smallest period (if any).

For strings X and Y

X ,,;, Y denotes "X is a prefix of Y"

X<Ymeans X";'Y",X",y

So much for general remarks on names and notations.

First we shall state the basic problem (MPP) in its "historical" context, subsequently we shall give two applications

Pattern-search (e.g. Knuth-Morris-Pratt) Periodicity-search (for all prefixes)

(5)

1

L The MPP problem

The problem we would like to consider evolved from the exercise below. We shall give some heuristics for this program evolution.

Exercise ("carn:check")

A string X is a

carre

if X = p2 for some string P E l7 . Derive a program to find every prefix

of X that is a carre. The formal specification:

where (0)

I [N : int ; (N ~ 1)

]1

X (i :OS:i <N): string;

I[e (i :lS:iS:N): lI!ll!Yofboo1; CARRECHECK

{(A i : l<:;iS:N : e(i) '" car (X .l.i»}

]1

car(X) " (EP :PEl7:X=PP).

A standard feature in programming methodology is: weaken in the postcondition by replace-ment of a constant by a variable.

If we consider the term in definition (0) : X = PP we might think of P as being a constant. Symmetry tells us to replace P by a variable twice. So X = PP might be "generalized" to X

=

PE 1\ X

=

FP for variables E and F.

I.e. P is a pre- and postfix of X . So for strings P and X we define

(1) P lll1X " (EE.F :E.FEl7:X=PE I\x=FP)

and note that P lll1 X 1\ IX I = 2

*

IP I "" car(X) .

The lack of reflexivity of lll1. created by the domain in (1). seems unnatural. but it results from the definition of periodicity. i.e. the domain in definition (0).

Moreover. incorporating reflexivity of lll1 leads to additional non-triviality analysis (in !!!IlIl below for example).

First we give a few properties of lll1. the simple proofs are omitted. Let H • P and X be strings and h • x E L. then

(2) (3)

(6)

2

-Property 4 will be used for prefixes of a fixed string X:

(4') X-I-k+!ooX-I-n+! "X-I-k ooX-I-n I\X(k)~X(n)

(4") -'X h+! 00 X -I-n+! " -'X J.k 00 X -I-n Y X(k);<X(n)

By 2, the transitivily of 00, we feel invited to consider maximal pre- and postfixes. So define:

(5) P!!!Ill!X " P 00 X 1\ (AH: HooX: H~P Y HOOP) Note that the following are equivalent

!l. P !!!Ill! X

fl. P 00 X 1\ (A H : H ooX : IH I~ IP I)

£ PooXI\(AH:HooX:H~P)

In section 6 we show that, given P !!!Ill! X, we have car(X) " IX I mod(2*(IX I-IP I»~O

So indeed the generalization (weakening of carre) is fruitful. The carrecheck problem has evolved to the MPP problem:

Derive a program that calculates for every prefix of a given string its maximal pre- and postfix. The formal specification

I [N : int ; (N ;;, I) X (i : O~ i<N) : §l!:ing ;

I[f (i :l$i~N): arrayQf[O .. N);

MPP

]1 ]1 .

(7)

§ 2. Solution to the MPP problem Forced by the postcondition of MPP :

Ro (A i : l';;i,;;N : X .1j(i)!llIll!X .1 i),

we choose the following invariants :

Po (A i : I';;i';;n : X .1j(i)!llIll!x.1i) P, I,;; n';; N. Awroximation 0 (for MPP) n := 1 ; j : (I) = 0 (Po A P,) ; do n *-N ... So (x.1k !lli11!x.1n +I) ·3 . ;j :(n+I)=k {(PoAP,):+l) ; n : = n + I (Po A P, ) od {Po A P, A n = N , hence Re}

On cosmetical grounds, with 4' in mind, we consider a slightly different postcondition for So : R, X.1k + I !llIll! X.1n + I

By definition of!lllll! (version 5b.) and by 4' ,R, equivales

x.1k I!I2X.1n A X(k)=X(n) A (Aj :X.1jI!l2X.1n+1 :j';;k+l)

This leads us to a repetition for So with guard X (k) *-X (n) and invariants :

Qo (Aj :x.1jI!l2X.1n+1 :j';;k+l) Q, X.1k I!I2x.1n A k?: 0

Approximation I (for Sol

k :=f(n) (QoA Ql. see the note below)

; do X (k) *-X (n) A k *-0

... decrease k under invariance of Q (and P)"

od {QoA Q, A (X(k)=X(n)Y k =0) }

The second conjunct in the guard is forced upon us by the wish to decrease k, leaving k ?: 0 invariant. note Po ~ {instantiation at n ,def. mpp (5 b.)} X .1f(n) 1!12 x.1n A (A j : x.1j 1!12

x.1n :

j';;f(n» ~ {by 4' : X .1 j + I 1!12 X .1 n + I ;a. X .1 j 1!12 X .1 n} X .1f(n)I!I2X.1n A (Aj :X .1j+ll!l2X J.n+1 :j';;f(n»

*

(dummy change) X J. f (n) 1!12 X .1 n A (A j : X J. j I!I2X .1 n +1 : j';; f (n)+ I) = (def. Qo, Qd (Q, A Qo)

j

(n)

(8)

4

-Under assumption of Qo 1\ Q, 1\ Po 1\ P, and the guard, we study reduction of k. First with respect to Qo : Let j > 0 then X J,j PllX J,n +1 "> [Qo;by4" ,X(k);OX(n) ~~XJ,k+lPllXJ,n+l} X J,j PllX J,n+l I\jS k+l " j ;Ok+l "> [j ~ O,4'} XJ,j-1PllXJ,n I\j-l<k "> (Q,,3) X J,j -1 PllX J,k

"> [Po, O;Ok < n , def. !!lllI! 5l!} j-ISf(k)

For j = 0, certainly we have j S

f

(k) + 1. Hence Qo} (1) holds.

With respect to Q, : Po I\Q, "> [k;O 0 : Po instantiated at k} X J,f(k) PllX J,k 1\ X J,k PllX J,n "> [2} X J,f(k) PllX J,n = (def. Q,.J(k)~ O} Q,

j

(k)

This shows that "decrease k under invariance ... is established by k :=

f

(k). (Certainly Po" P, is not affected.)

Because of the conjunct k ;0 0 in the guard, neither R, not the original postcondition of So are

met, but a mixture is :

and Qo 1\ Q," X(k) ;OX(n) 1\ k = 0 "> (4")

Qo 1\ Q, 1\ ~ X J.k + 1 Pll X J.n +1 1\ k = 0

"> (X J. 0 Pll X J. n + 1 , def. !!lllI!J

(9)

This proves the following solution for MPP : n:= 1 ;

f

:(1)

=

0 (Po /\ Pd ; don;tN ~I[k:int; k :=f(n) (Qo /\ Qd ; do X(k) ;tX(n) /\ k ;t 0 ~ k :=f(k) 5 -od (Qo /\ Q,/\ (X(k)=X(n)V k =0») ; if X (k) = X (n)~ (X -I-k + 1 !!!Ill! X

.J.

n + I) k := k + 1 11 X (k) ;t X (n)~ (X

.J.k

+ 1 !!!Ill! X .J.n + I) skip fi (X

.J.

k !!!Ill! X -I-n + I)

; f :

(n + I) = k (Po /\ P,)':'+d JI n:=n+1 od (Po /\ P, /\ n = N • hence R.,)

For the complexity of the algorithm. consider k to exist outside the innerblock (P2: k =

f

(n» . A variant function that shows linearity is 2N - 2n + k .

(10)

6

-§ 3. Pattern search

Let P E Ie be fixed. the pattern. Suppose we are interested in (all) occurrences of P in a string

Z.

Put Y = PZ. then we are searching for numbers n. such that

In this setting the pattern might be represented by its length only. Let X be a string. p

a

number 1 ~ p < I X I .

As X J, p is a postfix of X J, n iff p = n Y X J, p l1I! X J, n • we define (the occurrence of the pattern as postfix of X J, n):

(6)

Let j be

as

in the MPP problem. It seems reasonable to hope for suitable O-information in the !!!llI!-knowledge recorded in j. Indeed. for strings H • P and X we have

(7)

Property 7. which is closely linked to 3. follows easily from 5g, • 2 . It relates O(n) to j (n) as follows :

O(n) =

(6)

p =n Y XJ,p l1I!XJ,n = (X J, j (n) !!!llI! X J, n • 7 with H • P , X := X J, P ,X J, j (n), X J, n) p =n Y X J,p =X J,j(n)Y X J,p l1I!X J,j(n) = (X J,p =X J,j(n) '" p =j(n); 6) p =n Y

o

(J(n»

As j (n) < n (nonrefiexivity of

1llV,

O(n) depends only on j (n) and O(i: 1~ i <n). This senies pattern search as a simple extension of the MPP problem, by adding invariant

P3 (A i : 1~ i ~ n : 0 (n) '" O(n»

and initialization 0 : (1) = (p = 1) (P3 )

extra statement; 0 : (n + 1) = (p =n + 1) Y o(J(n + 1» (P3

:+tl

(11)

7

-§ 4. Knuth - Morris - Pratt

The pattern search presented in the previous section has a serious drawback : storage linear in the length of the given string (concatenated with the pattern). Indeed, the algorithm needs

f (i : I~ g n) to calculate f (n + I) and O{i: I~i ~ n) and fen + I) to calculate O{n+ I).

As, for fixed p, we

are

interested in n such that X ! p 1111 X ! n (instead of !!!ill! !) the infonna-tion recorded in

f

exceeds our needs : we might do with pre- and postfixes with lengths at most p. So we define : (P and p

are

not related ! )

(8)

(9)

PxxX ",PI1I1X"IPI<p

P IJ..1m '" P 1U]; X" (A H : H xxX: H;P

v

H xxP)

The reader is urged to convince himself of the truth of the 1m-versions of 2, 3 , 5"' b • C (i.e.

only (m)11I1 replaced by (Ut) 1U!<). Property 4, however, has a slightly different xx-version. We shall only provide the 1U];-version of 4' :

(lO') X!k 1U]; X!n "X{k); X{n)

'" (X !k +11U]; X !n + I" k <p -I) V (X

!k

+ 11111 X !n + 1 " k;p -I) The Jl1t1t problem is given by the postcondition

Po

(Ai: l~i~N : X !${i)wmX!i)

For the solution of the Jl1t1t problem we define invariants, (the obvious adaptations of the invariants for MPP)

1to (Ai:l~i~n:X!${i)wmX!i)

'1'0

(A j : X

!

j lillX

!

n + 1 : j ~ k + I)

'1'1

X! k 1m X ! n " k ~ 0

Except from the obvious adaptations, Jl1t1t differs from MPP only in the case analysis in the innerblock : the drawback of 10' :

Certainly,

'1'0" '1'1"

X{k); X{n)" k < p-I => 110', def. u xx) X !k+1 J,lII1iX !n+1 but

'1'0" '1'1"

X{k) ;X{n)" k ; p-I => 1100,k+l;p} X!p 1111 X !n +1 =>

Ilto,

instantation at p ; 2) X!$(p)l!JmX!n+1

(12)

8

-This shows that the alternative statement following the inner repetition should be changed (for the ~1t1t problem) to

('1'01\

'1'1

1\ (X(k)=X(n)v k =o)}

; ifX(k)=X(n)1\ k <p-I ~ (X J.k+1 UltltX J.n+l) k :=k+1

o

X(k) = X(n) 1\ k = P -I ~ (X J.<p<p) U1t1t X J.n + I} k := </l(P)

o

X(k)" X(n) ~ (k = 01\ X J.k U1t1t X J.n + I) skip fi

(X J. k U It It X J. n +l)

This and the change from

f

to </l make the solution of MPP to a solution of ~1t. The code will reappear in the Knuth-Monis-Pratt pattern search algorithm. so we shall leave it with this. Note that for calculation of </l(n + I) only </l(n) and </l (i : 15 i 5 p) are needed : </l{n) for initializ-ing k. </l (i : 15 i 5 p) in the inner repetition. I.e. ~1t1t needs storage proportional to the "pattern length".

Similar to § 3. we now transform ~1t1t to a pattern search algorithm: Knuth-Monis-Pratt. With respect to occurrence of X J.p as postfix of X J. n + I. note that

0(0+ I)

= (6)

p =n+lvXJ.p Ill!XJ.n+1

(4'; def. Itlt)

P =n+IV (XJ.p-IzmXJ.n 1\ X(P-I)=X(n»

= (def. of It It :

'1'';-1 "

true; def.

'I')

p

=

n + I V <'1'01\ '1'11\ X(k)

=

X(n»:_l

So calculation of 0(0 + I) depends only on the postcondition of the inner repetition and occurrence is to be signalled in the second alternative (the occurrence at n + 1 = p is not relevant of course).

We are now ready for the Knuth-Monis-Pratt algorithm.

As only </l(i : 15 i 5p) and </l(n) are needed to calculate </l(n + I) • we have to distinguish between preprocessing

search

- "filling ~"

- IIsignalling occurrences'!.

This seperation of the two parts is inevitable. but an earlier separation is unnecessary.

1

unelegant and confusing. In order to account for the reduced domain of </l we modify 1to to 1to•

to "buffer" </l{n) we add

1tz

1

1to (Ai: 15i5pminn :XJ.</l(i)UltltXJ.i)

1tz X J.k UItIt X J.n

(13)

9

-The Knuth-Moms-Pratt pattern search algorithm we derived : I[k:int;

CP(i: l:5i:5p): array llf [O .. p-l);

,

n , k := 1 , 0 ; <I> :(1) = 0 {1to " 1t, " 11:,} ; don "N

,

~ {1to " 1t, " 1to " n "N , so

'1'0"

'I',} do X (k) "X (n) " k ,,0 ~k:=<I>(k) ad {'I'o"

'1',,,

(X(k)=X(n)v k =O)} ; if X(k) =X(n)" k <p -l~ k :=k+l

[) X(k) =X(n)" k =p -I~ k:= <I>(p); "MATCH' [) X(k)" X(n)~ skip

6 {X

ik

I!..lU!; X

in

+ I, SO 1t,.+,} ; if n < p~ <1>: (n + 1) = k [) n <: p~

,

skip 6 { (1to "1t,,, 1to>,:' +,) ; n:== n

,

+1 ad {1to " 1t, " 11:, " n

=

N , so Po} ]1

(14)

-

10-§ S. Further remarks on pattern search

The second alternative statement in the algorithm above, distinguishing preprocessing and search, may also lead to a code with two (sequential) repetitions, one for each alternative. We chose for the form above to stress the uniformity: the difference between the parts is solely based upon coding, the genesis doesn't differentiate!

Several people noticed the strong resemblance of those parts, but in the literature we searched in vain for a presentation or derivation (at all) of the algorithm that did justice to that resem-blance. ([C 85] and [W 86] deserve some Credit).

[Note that even in 1983 the preprocessing was said to be "complicated and difficult to under-stand" ([S 83] p. 242). As the two parts are almost identical such a statement is puzzling. Has it anything to do with the widespread chaotic algorithm presentation? (e.g. [KMP 77], [BM 77])].

In our opinion, exploitation of pre- and postfixes simplified the "derivation" of the algorithm such that it becomes within reach of every freshmen course.

We conclude the discussion of pattern search with a remark on the Boyer-Moore fast pattern search ([BM 77]). As this algorithm is slightly beyond the scope of this paper, we shall only hint at its relation with the MPP problem.

Consider X E t* and pattern X J.p. In the Knuth-Morris-Pratt pattern search we decided to build up pre- and postfixes bit by bit, but we could have been greedier:

To that end consider the (linear-search-like) invariant PBM (Ai :XJ.pI1llXJ.i :i>n)

As X J.p I1ll X J.n + 1 ,.. (4'J X(p -1); X(n) we first check X(n) as a candidate for the end of a pattern occurrence.

Let s ; (MAXj : O<:;j<:;p "X(n);XU): j)!!!M-1

Then PBM.:'+p.s holds.

In other words : the first candidate m to satisfy X

J.

p I1ll X

J.

m is m ; n + p - s. If s < p - 1 we can "leap further", if s ; p - 1 we check X(n -1) ,etcetera

This requires knowledge of the occurrences of values and periodicities in the pattern.

The reader is challenged to give a "derivation" of the Boyer-Moore fast pattern search based on this early deviation of the MPP problem.

(15)

11

-§ 6. Periodicity search

In section 1 we "generalized" the carrecheck exercise to the MPP problem, and we promised to show that a solution for carrecheck is found as soon as MPP is solved.

We shall keep our promise in the following way : we give a variant of carrecheck

we proclaim an enrichment of MPP that solves the (variant) exercise

we perform some string-mathematics to prove that the exercise is solved by that enrich-mentofMPP.

For fixed m '" 2 consider the following postcondition

R (Ai:lSiSN:c(i)=(EP:PeL'":X,J.i=pm)

" (A i : IS i S N : per (i) = i min (MIN p : p period of X ,J. i :

In case m = 2, the first conjunct of R is just the postcondition of carrecheck. The second conjuct of R means :

per (i) is the period of X ,J. i if X ,J. i is periodic, otherwise per (i) = i.

Obviously we should extent iovariant P for the MPP problem with a conjunct p. to get an invariant for the new problem.

Initialization of p. : ; c : (1) = false; per: (I) = 1.

The outer repetition should contain an establishment of p.:+! .

So, followiog "/: (n +1) = k (Po:+d" and before "n: = n +1", we proclaim the statement list:

; c : (n + 1) = (n + 1) mod (m

*

(n + 1-/ (n + 1») = 0

; if (n + \) mod (n + 1- / (n + 1» = 0 ... per: (n + 1) = n + 1 - / (n + 1)

o

(n + 1) mod (n + \- / (n + 1» " 0 ... per: (n + 1) = n + 1

Ii

(p.:

+! , see corollary 5 to follow ) . Indeed a mioor adaptation, but it takes a proof!

The string-mathematics to follow is quite elementary, and has nothing to do with programmiog and - methodology. So we adopt a more conventional mathematical style, but (for the conveni-ence of non-mathematicians) we still take small steps in the proofs.

The basic idea is to squeeze periodicity information out of 1!12 or ll!I!I2 knowledge. Let D , Y E I;+ with D 1!12 Y. Then there are E ,F e L'" such that Y

=

DE " Y

=

FD .

Lemmata 1 and 2 tell us about (almost) periodicity of Y. (they are well-known, e.g. see (L 79) Ch. 11.5). Much more can be said if D !!!1!12 Y, some of which is done io 3,4,5.

(16)

12

-Lemma 1 Let D E 1:* and E ,F E 17 such that DE ~ FD .

Then there are L E 1:*, K E 17 and n '" 0 with

Q D ~F"L andL <F (hence DE ~FD ~Fn+lL)

1

E ~KL andF ~LK .

Proof Certainly, there are L E 1:* and n '" 0 such that D ~ F" L and I L I < I Fl. ThenF"LE ~DE ~FD ~F"+IL ,soLE ~FL.

As I L I < I F I ~ I E I , there are K , Kl E 17 with LK ~ F and E ~ Kl L .

Hence, L(KI L) ~ LE ~ FL ~ (LK)L and it follows that Kl ~ K .

o

Lemma 2 Let D, F E 1:* with DF ~ FD. Then there is a P E 1:* such that D ,F E (P'" 1m'"

OJ.

If D ,F E 17 it follows that DF is periodic with period at most gcd ( I D I , I F I ) .

Proof By induction to the length of DF. If D ~ A or F ~ A the existence of P is obvious.

Let D ,F E 17 . By 1, there are K , L , n such that D ~ F" L ,F ~ KL and F ~ LK . Hence KL ~ LK .

As D ~ A, I KL I ~ I F I < I DF I , so by induction there is aPE 1:* (as K E 17 even PEl:'" ) such that K ,L E (P'" 1m",

OJ .

Consequently, D ,F E (P'" 1m",

OJ

which proves the first part. If D ,F E 17 then DF E (p",+2 1m",

OJ

while PEl:'" .

Note that I P I divides I D I and I Fl.

Lemma 3 Let Y ~ FD and D !llI!Il Y. Then F is not periodic.

Proof By definition of (m)1lIl, F ~ A . So, by 1, there are L , n with D ~ F" L and L < F . Suppose F is periodic, say F ~ Q'" for some Q E 17, m '" 2 .

o

Then QF ~ FQ , hence QL < QF ~ FQ . As also L < F < FQ , it follows that FQ has both L and QL as prefix. Since I L I < I QL I we have L < QL and, equivalently, Q'" Q","-l L < Qm Q"'" L .

As Y ~ FD ~ Q'" Q"'" L , it follows that Q'" Q","-l L IlIl Y. However, since m '" 2, I D I ~ I Q"'" L I < I Q'" Q","-l L I which contradicts D !llI!Il Y . This falsifies

periodi-city of F.

0

(17)

13

-Lemma 4 Let Y ~ PD ,D !!!lm Y . Let P I!I! Y and I PI;;' I PI, then there is a k ;;, 0 such that D ~ p' P . (I.e. all pre-postfixes of Y With lenght;;, I P I are known).

Proof As D !!!lm Y, P c# A, so there are n ;;, 0 and L < P with D ~ pn L .

Because I L I < I P I $ I P I and P is a postfix of D ,L is a postfix of P. Hence there are a

k: 0 $ k S n and H < P with D ~ pl HP . Let HG ~ P then P ~ Gp·-k-I L .

As I H I + I G I ~ I PiS I P I ~ I G I + I pn-k-I L I , I H I $ I p ft - k- I L I .

Since H < p.-k and p.-'-I L < p.-l it follows that H $ pft-.-I L , so GH S Gpft-l-I L ~ P .

On the other hand HG ~ P $ P ,so GH ~ HG .

As H < P ,and, by :i, p is not periodic it follows from 2< that H ~ A , which shows D ~ pl P .

o

Corollary 5 Let D !!!lm Y , say Y ~ PD . Let m ;;, 2 , then (EC ::y~cm) iff IY I mod(m* IPI)~O.

In particular, Y is a carre iff I Y I !illl!!. 2 I P I ~ 0 , and Y is periodic iff D c#Aand IY I !illl!!.IP I ~O.

Proof By I, Y ~ pn+1 L and L < P , so the if-part is obvious.

Let Y ~cm; note that since m;;' 2, Cm-Il!l! Y. As ID I;;' I Cm-Il , IP I $ I C 1$ ICm-II,

soby~, D ~plcm-I.

Hence pl+1 Cm- I ~ Y ~ CCm- 1 and C ~ pHI, so Y ~ pm

*

(k+l) . The remaIic on Y being a carre is an instantation for m ~ 2 .

Finally,asYc#p,IYlmodIPI~O" (Em:m;;'2:IYlmod(m*IPI)~O).

0

(18)

14

-Acknowledgements

The carre problem and related other problems were "en vogue" in the enviromnent of the Eindhoven University of Technology. So, inevitably, I was contaminated too.

I would like to thank all colleagues that contributed to the genesis of this paper by comments and interest.

References

[BM 77]

[C 85]

Boyer, R.S. and Moore J.S., A fast string searching algorithm, CACM 20 , 762 - 772 (1977). Chengdian, C.,

A derivation of the Knuth-Morris-Pratt pat-tern matching program,

EUT-report 85-Wsk-02,

Eindhoven University of Technology (1985). [KMP 77] Knuth, D.E., Morris, J.B. and Pratt, V.R.,

[L 79]

[S 83]

[W 86]

Fast pattern matching in strings, SIAM J. Comput. !i , 323 - 350 (1977). Lallement, G.,

Semigroups and combinatorial applications, Wiley-interscience, (1979).

Sedge wick, R., Algorithms,

Addison - Wesley, (1983). Wiltink, G.,

Knuth-Morris-Pratt, private communication, (1986).

(19)

In this series appeared : No. 85/01 85/02 85/03 85/04 86/01 86/02 86/03 86/04 86/05 86/06 86/iJJ Authorls\ R.H. Mak. W.M.C.J. van Overveld W.J.M. Lemmens T. Verhoeff H.M.J.L. Schols R. Koymans G.A. Bussing K.M. van Hee M. Voorhoeve Rob Hoogerwoord G.J. Houben J. Paredaens K.M. van Hee Jan L.G. Dietz Kees M. van Hee

Tom Verhoeff

R. Gerth L. Shira

15

-Title

The formal specification and derivation of CMOS-circuits

On arithmetic operations with M-out-of-N-codes

Use of a computer for evaluation of flow films

Delay insensitive directed trace structures satisfy the foam rubber wrapper postulate

Specifying message passing and real-time systems

ELISA, A language for formal specifications of information systems

Some rellections on the implementation of trace structures

The partition of an information system in several parallel systems

A framework for the conceptual modeling of discrete dynamic systems

Nondeterminism and divergence created by concealment in CSP

On proving communication closedness of distributed layers

(20)

16

-86/08 R. Koymans Compositional semantics for real-time R.K. Shyamasundar distributed computing (Inf. & Control 1987) w.P. de Roever

R. Gertb

S. Arum Kumar

86/09 C. Huizing Full abstraction of a real-time denotational

R. Gertb semantics for an OCCAM-like language W.P. de Roever

86/10 J. Hooman A compositional proof theory for real-time distributed message passing

86/11 W.P. de Roever Questions to Robin Milner - A responders commentary (IFIP86)

86/12 A. Boucher A timed failures model for extended R. Gertb communicating processes

86/13 R. Gertb Proving monitors revisited: a first step towards W.P. de Roever verifying object oriented systems

(Fund. Informatica IX-4)

86/14 R. Koymans Specifying passing systems requires extending temporal logic

87/01 R. Gertb On the existence of a sound and complete axiomatizations of the mortitor concept

87/02 Simon J. Klaver Fcderatieve Databases Chris F.M. Verbeme

87/03 G.J. Houben A formal approach to distributed J. Paredaens information systems

87/04 T. Verhoeff Delayinsensitive codes -An overview

87/05 R. Kuiper Enforcing non-determinism via linear time temporal logic specification

(21)

87/06 87/07 87/08 87/09 87/10 87/11 87/12 87/13 R. Koymans R. Koymans H.M.J.L. Schols J. Kalisvaart L.R.A. Kessener W.J.M. Lemmens M.L.P van Lierop FJ. Peters H.M.M. van de Wetering T. Verhoeff P. Lemmens K.M. van Hee A. Lapinski

J. van der Woude

17

-Temporelc logica specificatie van message passing en real-time systemen (in Dutch)

Specifying message passing and real-time systems with real-time temporal logic

The maximum number of states after projection

Language extensions to study structures for raster graphics

Three families of maximally nondeterministic automata

Eldorado ins and outs.

Specifications of a data base management toolkit according to the functional model

OR and AI approaches to decision support systems

Referenties

GERELATEERDE DOCUMENTEN

In de Nota Ruimte is door het rijk niet langer de gehele provincie als Nationaal Landschap voorgesteld maar zijn er drie gebieden overgebleven.. De status van Nationaal

Motivatie en handvaten voor het op kosteneffectieve wijze vermin- deren van de milieubelasting door een aantal belangrijke herbiciden in maïs en daardoor mogelijk behoud van

Dit laatste geval doet zich slechts voor als men de toelaatbare verzameling van oppervlakten heeft uitgebreid met die, waarvan de oppervlakte wordt uitgedrukt door een

A In dit artikel gaat het over 'handwerk' bij het leren en het beoefenen van wis- kunde. De laatste jaren is van vele kanten gewezen op de grote aandacht voor het intellectueel

Hans Steur heeft zich als doel gesteld aan leraren materiaal te verschaffen om hun wiskundelessen met praktische toepassingen te kunnen verrjken. Hij is daarin voortreffelijk

Het systeem moet niet allen veilig zijn voor diegenen die zich erin bevinden, maar ook voor diegenen die aarzelen ervan gebruik te maken omdat het onveilig

Bodems van kommen, schalen en potten (Fig. Bodemscherf van pot of schaal met vlakke bodem. Kern : grijs, klei vermengd met stukjes kiezel ; goed gebakken. Binnenwand :

Bij Tabel 4.2. moet bovendien worden opgemerkt dat het niet mogelijk is om de verschillende vervoerswijzen met elkaar te vergelijken, aangezien het om aandelen gaat, en niet