The Shortest Way to Draw a Connected Picture

  • Published on
    22-Sep-2016

  • View
    212

  • Download
    0

Embed Size (px)

Transcript

  • 319

    The Shortest Way to Draw a Connected Picture

    Patrice Seebold* and Karine Slowinski

    Abstract With any word over the alphabet we asso- ciate a connected picture in the following manner: the read- ing of each letter of this word induces a unit line: respectively) stands for a right (left, up, down respectively) move. We present a rewriting system which can yield, from any word over all the words describing the same picture. Particularly, we give an algorithm to find a minimal word describing a given picture: this word represents the shortest way to draw this picture without pen-up .

    1. Introduction

    result which can be helpful to improve the use of plotters, for example pen plotters, can be also useful in such domains as graph theory or pattern recognition. Moreover, it can be easily generalized to the case of any even number of moves (for example 8 or 16 as in some sophisticated plotters). This method can also be compared with the encoding established by Freeman1 to facilitate the process- ing of geometric configurations by means of a digital com- puter.

    This approach (the description of pictures by words), which uses results and techniques from formal language theory (see Harrison2, or Salomaa3 ), was initiated by

    All random plotters accept the general commands lower pen, raise pen, move one unit left (right) and move one unit up (down). If we restrict ourselves to the case of pictures drawn without raising the pen, it is possible to represent any sequence of commands move one unit left, right, up or down as a word over a four letter alphabet, each letter cod- ing for a unit move. We call such words picture words.

    The aim of this paper is to study the set of all the pic- ture words describing a given picture (drawn without pen- up). However, these words are in general redundant since some segments are drawn several times: for example, the sequence move one unit left, move one unit right, move one unit left corresponds to three drawings of the same segment; it can be replaced by the single command move one unit left which has the same effect: the segment is drawn and the pen stays in the same position at the end of the drawing, Thus, it is possible to improve the represen- tation of the sequence of moves associated with the draw- ing of a given picture and we present an algorithm to con- struct, from any picture word describing a given picture, a word of minimal length describing the same picture. This

    *C.N.R.S. - U.A. 369, L.I.F.L. Universit de Lille 1 59655 Villeneuve dAscq Cedex, France Present address: C.N.R.S. - LA 248, L.I.T.P. Universit de Paris 7 2 Place Jussieu, 75251 Pans Cedex 05, France C.N.R.S. - U.A. 369, L.I.F.L. Universit de Lille 1 Cite scientifique, Bt M3 59655 Villeneuve dAscq Cedex, France This work was partially supported by the Programme de Re- cherche Coordonne Mathematiques et Informatique of the Ministere de la Recherche et de la Technologie.

    Maurer, Rozenberg and Welz14. They established many results about different classes of picture languages and they in particular introduced the concept of retreat which was studied by Hinz5 and is the starting point of our work. More precisely, we construct a rewriting system which can obtain, from a given word describing a picture, all the words describing the same picture and can find algorithm- icly a minimal word. Moreover, our results complete recent works. Gutbrod6, in particular, supplied a similar system which obtains all the words describing a same picture. However, his system has not the notion of a simple word and thus, does not realize an algorithm to find a minimal word. As for Brandenburg and Dassow7, they introduced a rewriting system able to reduce words but not to minimize them. Note that Brandenburg8 showed, using graph theory, that it is possible to compute a minimal word for a given picture in polynomial time (but he did not give any algo- rithm to achieve this).

    Our results also remain true (and the same system can be used) if we increase the number of elementary moves in the plane and it seems they could stay available if we con- sider spaces with more than two dimensions.

    This paper is organized as follows: after preliminaries and basic notions for the construction of picture languages, the first part is dedicated to the introduction of the rewriting system and the proof of the main results, the second part dealing with the notion of basic pictures. We conclude with some interesting open questions.

    2. Preliminaries We assume the reader to be familiar with basic formal language theory (see Harrison2 or Salomaa3), and we just recall several notations.

    Let A be a finite set called an alphabet. The elements of A are letters and finite strings over A are words. A* is

    North-Holland Computer Graphics Forum 10 (1991) 319-327

  • 320 P. Seebold et al. / The Shortest Way to Draw a Connected Picture

    the semi-group generated by A with the operation of concatenation (the neutral element is the empty word E). For a word w over A denotes its length, i.e. the number of letters of this word (in particular, and, for any is the number of occurrences of the letter x within w. A word is a factor (left fac- tor respectively) of the word w E A* if there exists

    respectively) and such that Before giving formally the basic notions and

    definitions, we start with an informal description of the representation of pictures by words.

    A picture word is a word over the alphabet (i.e. an element of The letter r stands for move

    one unit right and u stands for move one unit u p . For convenience, we denote by the opposite of r (move one unit left) and by U the opposite of u (move one unit down).

    Different words can describe the same picture: for instance and describe the same picture, and also if the starting and ending points are not important.

    3. Basic Notions Let be the Cartesian plane and a four letter alphabet. With each letter from we associate a unit move in as follows: respectively) induces a unit move to the right (left, up, down respectively). Thus, we define a morphism e (non injective) which associates with any word over an integer pair representing the associated move in

    A segment is the portion of straight line between the points (i,j) and An oriented segment

    is the oriented trace of the move between the points (i,j) and Remark: To any segment correspond two oriented seg- ments and with x = t and

    Drawing Convention In any representation of a picture associated with a word, we will use the following conventions:

    full point overlapping lines (i.e. different drawings of the same segment) are represented by closely drawn parallel lines.

    For example, the word will be represented by word by (see also examples above).

    and the

    However, this is just a representation given to show

    and the drawing: the real picture corresponding to is |to is

    4. Part 1 - Drawn Pictures We associate with any word over a unique picture as follows:

    the word is read, letter by letter, from left to right; the starting point is the point (0, 0); for each letter, we draw the associated oriented seg- ment whose ending point is the starting point of the next segment.

    Remark: The ending point of the picture is the point with coordinates Such a picture is drawn without pen-up. For any word respectively) denotes the set of (oriented respectively) seg- ments of the picture associated with w. Example: With one associates the following picture: ( o denotes the starting point and the ending point)

    the starting point of the drawing is represented by an empty point othe ending point of the drawing is represented by a

  • P. Seebold et al. / The Shortest Way to Draw a Connected Picture 321

    Example:

    is not. Conversely, any picture can be considered as a set of seg- ments S. If this picture is connected and if we choose in it astarting point St and an ending point E, a word describing this picture will be just an element of with the follow- ing properties: if a picture associated with this word is drawn from the point St, each segment of S is drawn at least once (and as many times as is necessary), no other segment is drawn and the drawing stops on the point E.

    is minimal,

    Remark: In general, there are several minimal words which describe a given picture.

    The aim of this paper is to describe an algorithm such that one can obtain, from any word a minimal word w such that This algorithm is based on the use of a rewritingsystem.

    For example, the two words and describe the same picture: 5. The Rewriting System R

    We introduce in this section a rewriting system R which can obtain from any word w over all the words of describing the same picture (in particular, all the minimal words). Definitions: Let A be an alphabet. A rewriting system R over A is a subset of Each element is called a rule and is denoted by One step derivation

    but the word does not describe the same picture as relation is defined by: and (because of the starting and ending points):

    denotes the transitive and reflexive closure of

    If we say that w is an ancestor of v (by R) v i s a descendant of w (by R). or

    Two facts here are important: For further details about rewriting systems, see Jantzen9. Let inv(w) denotes the inverse of w defined even if a given segment is drawn several times, it

    appears only once in the picture. Thus, a given picture is associated with an infinite number of words over For example, for any the picture associ- ated with the word is the same as that associated with the words describing a given picture will be the same whatever is the starting point of this picture (what is

    by:

    Convention: In what follows, we write instead of

    A loop is a word 1 over such that e(1) = (0, 0) (i.e. important is the position of the ending point to that of the starting point). the starting and ending points of the picture associated with 1 are the same). L is the set of all the loops Over part 1, the starting point will always be (0, 0).

    So, the picture associated with ally word is com- pletely defined by the pair (S(w), e(w)). In what follows, we will denote this picture by pict(w). With the above

    Remark: The loops are the words from in which occur as many r as and as many u as

    example, one has and for any

    Since the number of words describing a given picture is infinite, there exist such words shorter than the others. The shortest are called minimal. Formally, a word i s minimal if

    We define the rewriting system R over as

    with

    in of

  • 322 P. Seebold et al. / The Shortest Way to Draw a Connected Picture

    Property: R preserves pictures (i.e. for any word v descen- dant of w, one has and Two facts here are very important:

    each rule of these sets of rules is context-free. This means that it can be used freely in any context without any effect on the other parts of the words (even if the fact that it is applied or not depends on a particular context). although a rule as seems to be natural, it cannot be used here: indeed a fundamental property needed for our rewriting system (to be able to obtain all of the words describing a given picture) is that any application of any of its rules preserves pictures; it is clear that a rule as does not have this pro- perty.

    Remark: Gutbrod6 introduced a similar system working on words. We can easily show that every transformation of his system can be simulated by a combination of rules from R. Moreover, Gutbrod does not give an algorithm to obtain a minimal word.

    The next sets of rules can be simulated by rules from R:

    Convention: In what follows, we use the term r u l e instead of set of rules. So, we write the rule R1 instead of o n e rule from the set of rules R1.

    6. Results and Proofs In this section, we use the system R to show that for any word there exists a minimal word m that derives from w (theorem 1). The proof is constructive and needs only a finite number of derivations: thus it provides an algorithm (corollary 1) (this result is not evident since the system R is not noetherien: because of the rule R 2 , there exist infinite derivations). Another important result is that, using the system R, one can obtain from any word all the words such that pict(w) = pict(w) (propo- sition 2). In the second part, we will show that these results remain true even if we consider pictures just as sets of seg- ments (i.e. the starting and ending points are not taken into account).

    For any word (the multiplicity of the segment s relative to the word w) is the number of times the segment s is drawn during the construction of pict(w) (of course, if and only if

    A word is simple if for any is 1 or 2 (each segment of pict(w) i s drawn at most twice). As for the minimal words, there are in general several sim- ple words which describe a given picture. Example: The words and describe the same picture.

    not simple simple not minimal not minimal

    simple

    minimal simple minimal

    Lemma 1: Let For any segment such that there exists derived from w such that:

    for any

    Observe that

    Proof Let and be a segment such that (i.e. the segment s is drawn at least three times

    during the construction of pict(w)). Assume that w = with and

    where a, a and a represent in this order the three first pas- sages on s. Four cases are possible, depending on the values of a and a. These four cases are similar, so we establish the result only for one of them.

    For instance, suppose a = a and a = a: w = with (we also have

    and w is derived as follows:

    Theorem 1: For any word there exists a minimal word m that derives from w. The proof is in two major steps (corollary 1.2 and 3.3) and involves an intermediate normal form for pictures which we call simple.

    (the notation in this derivation step).

    indicates that only the rule Ri is involved

  • P. Seebold et al. / The Shortest Way to Draw a Connected Picture 323

    R4 is simulated only by R1 which does not change the multiplicity of segments. As R2 is just used once, only the multiplicity of s decreases by 2. Consequently,

    The two following corollaries are direct consequences of lemma 1.

    Corollary 1.1: A minimal word is simple Proof Suppose w is minimal and not simple. There exists a segment s from S(w) such that Applying lemma 1, we get a word strictly shorter than w and describ- ing the same picture. Contradiction.

    Corollary 1.2: For any word there exists a simple word p that derives from w. Proof Let as long as there exists a segment with multiplicity superior or equal to 3, we apply lemma 1. We get a word p describing the same picture as w, but all seg- ments in S(p) have a multiplicity inferior or equal to 2: p is simple. Remark: Brandenburg and Dassow7 got a similar result using a rewriting system. However, their system which can be simulated by R1 and R2, does not allow obtaining all the simple words and in particular, the minimal words.

    The next result is not used to prove theorem 1, but it is interesting because it indicates that every picture can be drawn with ut most one passage in each direction on each segme...

Recommended

View more >