ArticleslgStudy

science

Tagged Deterministic Finite Automaton

Tagged Deterministic Finite Automaton is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Tagged Deterministic Finite Automaton rather than just read about it. In short: In the automata theory, a tagged deterministic finite automaton (TDFA) is an extension of deterministic finite automaton (DFA). In addition to solving the recognition problem for regular languages, TDFA is also capable of submatch extraction and parsing.

Tagged Deterministic Finite Automaton — main illustration
Tagged Deterministic Finite Automaton — illustration

Key takeaways

  • Tagged Deterministic Finite Automaton belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Tagged Deterministic Finite Automaton to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Tagged Deterministic Finite Automaton from memory before moving on to harder problems.

Reference excerpt

In the automata theory, a tagged deterministic finite automaton (TDFA) is an extension of deterministic finite automaton (DFA). In addition to solving the recognition problem for regular languages, TDFA is also capable of submatch extraction and parsing. While canonical DFA can find out if a string belongs to the language defined by a regular expression, TDFA can also extract substrings that match specific subexpressions. More generally, TDFA can identify positions in the input string that match tagged positions in a regular expression (tags are meta-symbols similar to capturing parentheses, but without the pairing requirement).

History TDFA were first described by Ville Laurikari in 2000.

Prior to that it was unknown whether it is possible to perform submatch extraction in one pass on a deterministic finite-state automaton, so this paper was an important advancement. Laurikari described TDFA construction and gave a proof that the determinization process terminates, however the algorithm did not handle disambiguation correctly. In 2007 Chris Kuklewicz implemented TDFA in a Haskell library Regex-TDFA with POSIX longest-match semantics.

Kuklewicz gave an informal description of the algorithm

and answered the principal question whether TDFA are capable of POSIX longest-match disambiguation, which was doubted by other researchers.

In 2017 Ulya Trafimovich described TDFA with one-symbol lookahead.

The use of a lookahead symbol reduces the number of registers and register operations in a TDFA, which makes it faster and often smaller than Laurikari TDFA. Trafimovich called TDFA variants with and without lookahead TDFA(1) and TDFA(0) by analogy with LR parsers LR(1) and LR(0). The algorithm was implemented in the open-source lexer generator RE2C.

Trafimovich formalized Kuklewicz disambiguation algorithm. In 2018 Angelo Borsotti worked on an experimental Java implementation of TDFA; it was published later in 2021.

In 2019 Borsotti and Trafimovich adapted POSIX disambiguation algorithm by Okui and Suzuki to TDFA. They gave a formal proof of correctness of the new algorithm and showed that it is faster than Kuklewicz algorithm in practice.

In 2020 Trafimovich published an article about TDFA implementation in RE2C.

In 2022 Borsotti and Trafimovich published a paper with a detailed description of TDFA construction.

The paper incorporated their past research and presented multi-pass TDFA that are better suited to just-in-time determinization. They also compared TDFA against other algorithms and provided benchmarks.

Formal definition TDFA have the same basic structure as ordinary DFA: a finite set of states linked by transitions. In addition to that, TDFA have a fixed set of registers that hold tag values, and register operations on transitions that set or copy register values. The values may be scalar offsets, or offset lists for tags that match repeatedly (the latter can be represented efficiently using a trie structure). There is no one-to-one mapping between tags in a regular expression and registers in a TDFA: a single tag may need many registers, and the same register may hold values of different tags.

The following definition is according to Trafimovich and Borsotti. The original definition by Laurikari is slightly different. A tagged deterministic finite automaton F {\displaystyle F} is a tuple

( Σ , T , S , S f , s 0 , R , R f , δ , φ ) {\displaystyle (\Sigma ,T,S,S_{f},s_{0},R,R_{f},\delta ,\varphi )} , where:

Σ {\displaystyle \Sigma } is a finite set of symbols (alphabet)

T {\displaystyle T} is a finite set of tags

S {\displaystyle S} is a finite set of states with initial state s 0 {\displaystyle s_{0}} and a subset of final states S f ⊆ S {\displaystyle S_{f}\subseteq S}

R {\displaystyle R} is a finite set of registers with a subset of final registers R f {\displaystyle R_{f}} (one per tag)

δ : S × Σ → S × O ∗ {\displaystyle \delta :S\times \Sigma \rightarrow S\times O^{*}} is a transition function

φ : S f → O ∗ {\displaystyle \varphi :S_{f}\rightarrow O^{*}} is a final function, where O {\displaystyle O} is a set of register operations of the following types: set register i {\displaystyle i} to nil or to the current position: i ← v {\displaystyle i\leftarrow v} , where v ∈ { n , p } {\displaystyle v\in \{\mathbf {n} ,\mathbf {p} \}}

copy register j {\displaystyle j} to register i {\displaystyle i} : i ← j {\displaystyle i\leftarrow j}

… excerpt ends here. Continue reading the full article.

Illustrations

Tagged Deterministic Finite Automaton: Figure 1: TNFA for regular expression 
  
    
      
        
          a
          
            ∗
          
        
        t
        
          b
          
            ∗
          
        
        
          |
        
        a
        b
      
    
    {\displaystyle a^{*}tb^{*}|ab}
  
.
Figure 1: TNFA for regular expression a ∗ t b ∗ | a b {\displaystyle a^{*}tb^{*}|ab} .
Tagged Deterministic Finite Automaton: Figure 2: TNFA for regular expression 
  
    
      
        
          a
          
            ∗
          
        
        t
        
          b
          
            ∗
          
        
        
          |
        
        a
        b
      
    
    {\displaystyle a^{*}tb^{*}|ab}
  
 simulated on a string 
  
    
      
        a
        b
      
    
    {\displaystyle ab}
  
.
Figure 2: TNFA for regular expression a ∗ t b ∗ | a b {\displaystyle a^{*}tb^{*}|ab} simulated on a string a b {\displaystyle ab} .
Tagged Deterministic Finite Automaton: Figure 3: Determinization of TNFA for regular expression 
  
    
      
        
          a
          
            ∗
          
        
        t
        
          b
          
            ∗
          
        
        
          |
        
        a
        b
      
    
    {\displaystyle a^{*}tb^{*}|ab}
  
.
Figure 3: Determinization of TNFA for regular expression a ∗ t b ∗ | a b {\displaystyle a^{*}tb^{*}|ab} .
Tagged Deterministic Finite Automaton: Figure 4: TDFA for regular expression 
  
    
      
        
          a
          
            ∗
          
        
        t
        
          b
          
            ∗
          
        
        
          |
        
        a
        b
      
    
    {\displaystyle a^{*}tb^{*}|ab}
  
 without optimizations.
Figure 4: TDFA for regular expression a ∗ t b ∗ | a b {\displaystyle a^{*}tb^{*}|ab} without optimizations.
Tagged Deterministic Finite Automaton: Figure 5: Optimized TDFA for regular expression 
  
    
      
        
          a
          
            ∗
          
        
        t
        
          b
          
            ∗
          
        
        
          |
        
        a
        b
      
    
    {\displaystyle a^{*}tb^{*}|ab}
  
.
Figure 5: Optimized TDFA for regular expression a ∗ t b ∗ | a b {\displaystyle a^{*}tb^{*}|ab} .

Worked examples

Example 1 — a first encounter with Tagged Deterministic Finite Automaton

Start with the simplest possible case. Write down what Tagged Deterministic Finite Automaton claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Tagged Deterministic Finite Automaton before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Tagged Deterministic Finite Automaton ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Tagged Deterministic Finite Automaton

In research
Tagged Deterministic Finite Automaton appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Tagged Deterministic Finite Automaton in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Tagged Deterministic Finite Automaton is common in secondary-school and first-year university syllabi. It links to neighbouring topics Finite-state machines, so understanding it makes those chapters shorter.
In everyday life
Look for Tagged Deterministic Finite Automaton outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Tagged Deterministic Finite Automaton” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Tagged Deterministic Finite Automaton in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Tagged Deterministic Finite Automaton means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Tagged Deterministic Finite Automaton out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Tagged Deterministic Finite Automaton in simple terms?

In the automata theory, a tagged deterministic finite automaton (TDFA) is an extension of deterministic finite automaton (DFA). In addition to solving the recognition problem for regular languages, TDFA is also capable of submatch extraction and parsing.

Why does Tagged Deterministic Finite Automaton matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Tagged Deterministic Finite Automaton?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Tagged Deterministic Finite Automaton.

Tags

  • Finite-state machines

Keep exploring