A model for a Lindenmayer reconstruction algorithm
11 A model for a Lindenmayer reconstruction algorithm Diego Gabriel Krivochen & Beth Phillips Abstract: Given an input string s and a specific Lindenmayer system (the so-called Fibonacci grammar ), we define an automaton which is capable of (i) determining whether s belongs to the set of strings that the Fibonacci grammar can generate (in other words, if s corresponds to a generation of the grammar) and, if so, (ii) reconstructing the previous generation. We assume a two-tape one-way finite automaton (2FA): Definition 1: a two-tape one-way deterministic FA (2FA) is a tuple 〈 Σ, Q, δ, q , F 〉 , where: Σ is the input alphabet. Σ = {0, 1} Q is the set of states q ∈ Q is the initial state δ is a transition function F ⊆ Q is the set of accepting states ⊳ , ⊲ ∉ Σ are left- and right-end markers, respectively Each tape has an independent head. At each point, a set of rules determines the action and movement of the heads depending on what is written on the input tape (Tape 1) and determines what is to be written in the output tape (Tape 2), which is initially empty (which we will indicate with the symbol ε ). Definition 2: given a 2FA G , the configuration of G is a tuple 〈 x , x , q n , i , i 〉 ∈ ( ⊳ Σ* ⊲ ) × Q × ℕ , where q n ∈ Q is the current state, x and x are the contents of tapes 1 and 2 respectively and i and i are the positions of the 1 st and 2 nd heads . We can simplify this by assuming that x n = i n : because the only symbol that each head is ‘aware’ of is the currently scanned one, specifying the content of the tape implies that the head is at that position. Because our 2FA is one way , the heads can do two things as far as movement is concerned: R: move one slot to the right S: stay in place There is no leftward movement. The transition function for our 2FA is a rule of the form δ( q n , x , x ) = ( q m , y , y , M , M ) Note that the rule specifies the input state, the contents of T1 and T2, and the machine’s movements (denoted by ‘M’) in each tape; as we said above, there is no need to specify the position of the head separately. Specifically, the transition function in generalized form can be read as ‘in state q n , with x in T1 and x in T2, proceed to state q m by changing x to y and x to y , then move or stay in place on T1 and move or stay in place on T2’. For example, δ( q , 0 , ε ) = ( q , ,
0, R, S) Furia (2012) offers a generalized definition which, for our present purposes, seems to be an overkill. means ‘in state q , with 0 on T1 and ε on T2, proceed to state q ; leave 0 on T1 (or, equivalently, replace 0 by 0 on T1) and move right, and replace ε by 0 in T2 and stay in place’. Tape 1 contains a string of 1s and 0s, Tape 2 is initially empty. The head in T1 is read-only (or, equivalently, it rewrites every symbol as itself), the head in T2 is read-write. It is crucial to note that the content of Tape 2 at i n will depend on the content of T1 at i n as per the corresponding rule. Definition 3: a multitape automaton with n- tapes A is k -synchronized if for n heads h , …, h n , these heads are never farther than k apart (Ibarra & Tran, 2012). The heads in our 2FA are . This limit is given by the size of the minimal grammatical constituents in the strings evaluated by the automaton: the minimal constituent size we will consider is 1 and the maximal constituent size is 2, as defined by the rules of the grammar which generate the input string. The very specific constraints set on our 2FA derive from the specificity of what we want it to do. The 2FA we construct here does two things: It serves as a test for Fibonacci-membership applied to the output of a generative Lindenmayer system with alphabet Σ = {0, 1} and rules 0 → 1; 1 → 0 1 (cf. Prusinkiewicz & Lindenmayer, 2010) –
Fib grammar henceforth- (operations over Tape 1) A derivation for the Fib grammar is illustrated as follows: Fibonacci sequence = {0, 1, 1, 2, 3, 5, 8, 13, 21…} 0
13 symbols 101011010110110101101
21 symbols … The choice of this particular Lindenmayer system to generate the Fibonacci sequence finds justification in how low-level local transition facts map to higher-level constituent structure: the fact that a [0] is always followed by a [1] allows us to ‘group’ [01] units when reading an output string from the Fib grammar from left-to-right and map them to their previous generation, which as per the rules of the grammar is [1]. Relevantly, this reconstruction property does not extend to the other irreducible Fibonacci Lindenmayer grammar (which we refer to as bif ), 0 → 1; 1 → 1 0: since [1] in a generation g n can be mapped to a [0] in g n-1 by itself, a point of ambiguity is created at every [1] in the string; furthermore local bi-grams [01] do not longer correspond to a constituent. Low-level and high-level properties of the grammar (or representational and derivational properties) do not map to each other in the same way for the Fib and bif grammars. Applied only once to a string s , the 2FA proposed here assess only the ‘Fibonacci-grammaticality’ of s . By ‘Fibonacci-grammaticality’ we mean ‘compliance with the following local n -gram constraints’: *111 *00 It must be noted that a string may be Fibonacci-grammatical without it being an actual Fibonacci string (i.e., an output of the Fib grammar). The 2FA does this by having the transitions corresponding to these n -grams undefined, with which the procedure terminates immediately. Theorem: a string s corresponds to a generation of the Fibonacci grammar if and only if after a finite number of recursive applications of the transition functions 1-3 specified below, the algorithm stops when there is only a 0 (the axiom of the Fibonacci grammar) on the output tape. This means that 2FA can in fact determine the Fibonacci membership of a string as long as the length of that string (notated | s |) is a Fibonacci number. Given any generation g n of the Fib grammar , 2FA can construct g n-1 on Tape 2 Instructions: δ( q , 0 , ε ) = ( q , ,
0, R, S) In state q , with 0 on T1 and ε on T2, proceed to state q ; leave 0 in T1 (or, equivalently, replace 0 by 0 on T1) and move right, and replace ε by 0 in T2 and stay in place. 2. δ( q , 1 ,
0) = ( q , ,
1, R, R) In state q , with 1 on T1 and 0 on T2, proceed to state q ; leave 1 on T1 (or, equivalently, replace 1 by 1 on T1) and move right, and replace 0 by 1 on T2 and move right. 3. δ( q , 1 , ε ) = ( q , ,
0, R, R) In state q , with 1 on T1 and ε on T2, proceed to state q ; leave 1 on T1 (or, equivalently, replace 1 by 1 on T1) and move right, and replace ε by 0 on T2 and move right. Recall that T1 is (presumably) a Fib string; T2 is initially ⊳ ε ε ε … ⊲ . The algorithm operates until h in T1 reaches ⊲ in an accepting state. When this happens, h in T2 moves right until reaching ⊲ . Because 2FA is , if h reaches ⊲ in n steps, h will reach ⊲ in at most n+2 steps. An input string s is accepted if both heads end up on ⊲ after a finite number of steps. Example:
We will mark in bold the symbols in T1 that have already been read at each point. In this example, T1 contains generation 4 of the
Fib-grammar . 1) T1 ⊳ ⊲ T2 ⊳ ε ε ε ⊲ (by 1) 2) T1 ⊳ ⊲ T2 ⊳ ε ε ε ⊲ (by 2) 3) T1 ⊳ ⊲ T2 ⊳
10 ε ε ε ⊲ (by 3) 4) T1 ⊳ ⊲ T2 ⊳
100 ε ε ⊲ (by 1) 5) T1 ⊳ ⊲ T2 ⊳
101 ε ⊲ (by 2) References:
Furia, Carlo (2012) A survey of multi-tape automata. arXiv:1205.0178v2 Ibarra, Oscar & Nicholas Tran (2012) How to Synchronize the Heads of a Multitape Automaton.
International Journal of Foundations of Computer Science