Skip to main content
Springer Nature - PMC COVID-19 Collection logoLink to Springer Nature - PMC COVID-19 Collection
. 2020 May 25;12142:441–450. doi: 10.1007/978-3-030-50433-5_34

Simulations of Quantum Finite Automata

Gustaw Lippa 8, Krzysztof Makieła 8, Marcin Kuta 8,
Editors: Valeria V Krzhizhanovskaya8, Gábor Závodszky9, Michael H Lees10, Jack J Dongarra11, Peter M A Sloot12, Sérgio Brissos13, João Teixeira14
PMCID: PMC7304700

Abstract

This paper presents a Python library to simulate different kinds of quantum finite automata on a classical computer. The library also provides tools for language generation and visual representation of simulation results. We have conducted experiments to measure the time complexity of the simulation in a function of the automaton size, alphabet size and word length. Examples of library usage are also provided.

Keywords: Quantum finite automata, Acceptance conditions, Cut-point, Automata simulation

Introduction

Finite automata are real models of computers, which have only limited amount of memory. Finite automata are also interesting models themselves, due to their simplicity but at the same time rich structure and interesting properties [7]. Since the introduction of finite automata in 1959 by Rabin and Scott [13], the theme has been quite well recognized and approached from various aspects. Connections with different domains, including algebra and logics, have also been established.

The picture for theory of quantum automata and languages generated by them is less clear, and various important problems remain open [2, 11]. The task of quantum finite automata is to recognise quantum languages. Studying these languages is useful in establishing the computational and expressive power of quantum machines in general. However, such devices are not yet available and simulators have to be used instead. Because of that, we developed a library written in Python, running on a classical computer and providing implementation of several types of quantum finite automata.

This paper presents the library for simulating quantum finite automata. The library can help in exploring hypotheses on unknown relations between classes of quantum finite automata and quantum languages by providing evidence about accepting probabilities of particular words and sets of words. The library could also be useful for teaching students courses on finite automata in a quantum context.

Related Work

Simulation of classical finite automata is a mature area. A comprehensive survey of simulators of classical finite automata is given in [5] and JFLAP emerges as the most mature and popular tool [14].

On the other hand, there have been many libraries focused on bringing quantum computation onto the classical architectures, perhaps the best known being Q#1. The low-level libraries include Quirk2, with graphical interface available through a web browser, or Quantum++3, a high performance library written in C++11. The high-level libraries provide similar functionalities but focus more on code expressiveness. They often enable using real life simulators or quantum computers as their back-ends. Examples of such libraries include ProjectQ4, Qiskit5 and the aforementioned Q#.

However, we have not found a solution focused solely on quantum finite automata. The available pieces of software were either too low-level, focusing on quantum gates and quantum phenomena in micro-scale, or too abstract, providing interfaces for developing quantum algorithms in general, but without tools dedicated specifically for quantum automata.

Quantum Finite Automata

In this work we consider only one-way finite automata, i.e., in each step of a simulation the head reads one symbol from the tape and moves forward. Backward or empty moves of the head are forbidden. The paper defines all automata in a uniform framework, which means that for classical finite automata notation differs slightly from the one adopted widely in literature.

Preliminaries. An input alphabet Inline graphic is a finite set of symbols. The working alphabet Inline graphic equals Inline graphic, where $ denotes a special end-marker symbol outside the input alphabet. Set Q is a finite set of states and Inline graphic is a distinguished state, called the initial state. Each classical state Inline graphic has a quantum counterpart Inline graphic. A pure quantum state Inline graphic of quantum automaton is defined as

graphic file with name M8.gif 1

where Inline graphic and Inline graphic.

Vector Inline graphic denotes column vector consisting of |Q| ones. Matrix Inline graphic denotes square Inline graphic matrix containing ones on a diagonal and zeros elsewhere.

Definition 1

Nondeterministic Finite Automaton (NFA) [13] is a 5-tuple Inline graphic, where Inline graphic is a set of accepting states, and for all Inline graphic transition matrix Inline graphic satisfies Inline graphic. If transition matrices Inline graphic additionally satisfy for all Inline graphic condition

graphic file with name M21.gif 2

then an automaton is Deterministic Finite Automaton (DFA). Classes of NFAs and DFAs are equivalent as they recognize the same class of languages, i.e., class of regular languages.

Definition 2

Probabilistic Finite Automaton (PFA) [12] is a 5-tuple Inline graphic, where vector I is a stochastic column vector describing initial distribution of states, i.e., Inline graphic and Inline graphic. Vector F is a column vector of size |Q| with i-th entry equal 1 if Inline graphic is a accepting state and 0 otherwise. For all Inline graphic transition matrix Inline graphic is Markovian, i.e., its rows define probability distribution. Thus, for all Inline graphic we have Inline graphic and Inline graphic satisfies (2).

Definition 3

Measure-Once Quantum Finite Automaton (MO-QFA) [9] is a 5-tuple Inline graphic, where Inline graphic is a set of accepting states. Transition matrices Inline graphic satisfy Inline graphic for all Inline graphic and are unitary, i.e., for all Inline graphic we have

graphic file with name M37.gif 3

The set of accepting states corresponds to a projective operator:

graphic file with name M38.gif 4

Definition 4

Measure-Many Quantum Finite Automaton (MM-QFA) [8] is a 6-tuple Inline graphic, where Inline graphic is a set of rejecting states, and Inline graphic are transition matrices satisfying (3).

The automaton partitions set Q into Inline graphic, where Inline graphic is a set of nonhalting (neutral) states. Sets Inline graphic and Inline graphic should be pairwise disjoint.

In a manner analogous to (4), projective operators Inline graphic and Inline graphic are defined as follows:

graphic file with name M48.gif 5
graphic file with name M49.gif 6

Definition 5

General Quantum Finite Automaton (GQFA) [10] is a 6-tuple Inline graphic. The model is similar to MM-QFA, but the transition matrices Inline graphic are more general – they are a composition of a finite sequence of applications of unitary transformations followed by orthogonal measurements. Note, that there is a more general definition of GQFA, provided by Hirvensalo [6], but it is not considered in our work.

For a broader description of these and other types of quantum automata we refer a reader to [3, 7, 11].

Language Acceptance Modes

Let Inline graphic denote probability of accepting word Inline graphic by automaton Inline graphic and let Inline graphic be a real number such that Inline graphic. Given Inline graphic, probability Inline graphic is computed as Inline graphic for MO-QFA, but for MM-QFA is more complicated.

There exist several modes of language acceptance:

  • with a cut-point Inline graphic, if for all Inline graphic, we have Inline graphic and for all Inline graphic, we have Inline graphic. This mode of acceptance is also called with an unbounded error.

  • with an isolated cut-point Inline graphic, if there exists Inline graphic, such, that for all Inline graphic, we have Inline graphic and for all Inline graphic, we have Inline graphic.

  • with a bounded error Inline graphic, if for all Inline graphic, we have Inline graphic and for all Inline graphic, we have Inline graphic. This mode of acceptance is equivalent to acceptance with an isolated cut-point, where cut-point Inline graphic is isolated with value Inline graphic.

  • with a positive one-sided unbounded error if for all Inline graphic, we have Inline graphic.

  • with a negative one-sided unbounded error if for all Inline graphic, we have Inline graphic.

  • Monte Carlo acceptance [4], if there exists Inline graphic such, that for all Inline graphic, we have Inline graphic and for all Inline graphic, we have Inline graphic. Such Inline graphic is called Monte Carlo QFA for L.

Acceptance with a cut-point and acceptance with an isolated cut-point are the most import modes of language acceptance, and are implemented in our library.

Library

The simulation library6 provides its interface through a number of classes, each representing one of the automata models. It also uses modules LanguageGenera-tor, LanguageChecker and Plotter. Figure 1 presents main components of the simulation library, which offers the following functionality.

Fig. 1.

Fig. 1.

Model of the quantum finite automata library

Automaton Definition. A new automaton is constructed with an object belonging to a class representing implemented automaton (one of PFA, MO_1QFA, MM_1QFA, GQFA) and data defining chosen automaton, such as the alphabet, transition matrices and matrices of projective measurements are passed. A user has to assure unitarity of transition matrices.

Generation of Language Samples. The LanguageGenerator module is responsible for this functionality. For finite languages, a user can provide a list of words which entirely define the language. To account for the infinite regular languages, a language can be defined with a regular expression. Generation of samples of stochastic languages is not implemented in the current version of the library.

Automaton Simulation. The LanguageChecker module of the library enables simulation of an automaton run on a single word or on a random or user-defined sample of defined language. A simulation is determined by a transition matrix and one simulation of the automaton on a given word is sufficient to obtain all information about word acceptance or rejection. Thus, there is no need to repeat a simulation since transition matrices are stationary. Simulation results are returned with respect to two modes of language acceptance: with a cut-point and with an isolated cut-point.

Results Visualisation. The library has a dedicated Plotter module to plot histograms of counts of words accepted and words rejected with a given probability. A cut-point and an isolation interval can also be shown.

Simulations and Results

There exist two ways of simulating systems of a probabilistic nature. One way is the strong simulation, which requires calculating the exact probability of an outcome. The other way is the weak simulation, which is based on a sampling from the output distribution in order to approximate the probability. The latter is the only tractable way of simulating quantum computers because of the complexity of the task. However, our library performs a strong simulation, which is adequate because of the simpler nature of quantum automata.

Experiments

We have performed a handful of experiments to determine the time complexity of the simulations depending on various parameters.

Automaton size. During our research we concluded that the most important factor in the time complexity of a simulation is the number of automaton states. In a true QFA, the relation between the number of states and computation time would be linear. In our simulator the time complexity is polynomial which agrees with the result proven in [3]. Figure 2 shows simulation time of GQFA with the growing number of its states. The results are quite close to the values predicted theoretically. Simulation time is reported as the arithmetic mean from 5 simulations for each automaton size.

Fig. 2.

Fig. 2.

Simulation time of GQFA in a function of the number of states

Alphabet Size. Figure 3 presents simulation time of GQFA as a function of the size of alphabet, over which automaton is defined. For each alphabet size, simulation time was measured as the arithmetic mean over 500 random words. It should be noted that the scale in ordinate axis (y-axis) does not start from 0. Figure 3 shows that there is no dependence between the size of the alphabet and the time of simulation. This is because the change of the alphabet size influences only the amount of input data (transition matrices and projective measurement matrices) required to define an automaton but does not impact computation time at all.

Fig. 3.

Fig. 3.

Simulation time of GQFA in a function of the alphabet size

Word Length. The relation between the time of computation and the length of an input word is linear. This is not surprising, because with each letter of the input word, an automaton performs a fixed number of matrix multiplications. The size of these matrices is determined by the number of states of automaton. For each letter a transition function must be applied and a measurement may be performed, depending on the type of an automaton. Figure 4 shows simulation time of GQFA as a function of the length of simulated words. For each word length, 100 random words were simulated and simulation time was taken as the arithmetic mean over these 100 words.

Fig. 4.

Fig. 4.

Simulation time of GQFA in a function of the length of simulated words

Usage Example

Listing 1.1 presents exemplary code for defining a MM-QFA automaton. This automaton is well-known in literature and was proposed by Ambainis and Freivalds [1] as a part of the proof that there exists a one-way QFA, which recognizes language Inline graphic with probability Inline graphic, where p is the real root of the equation Inline graphic. Figure 5 visualizes obtained acceptance probabilities and their corresponding word counts.graphic file with name 500809_1_En_34_Figa_HTML.jpg

Fig. 5.

Fig. 5.

Visualization of acceptance probabilities and acceptance modes for MM-QFA

Conclusions

The library provides a simple API for functionality required to simulate quantum finite automata. We hope the library will encourage research at the intersection of quantum computations and theory of formal languages and automata. We have experimentally shown that the time complexity of simulating a quantum finite automaton is polynomial in relation to the size of the automaton. Nevertheless, we believe that the library may be useful for researchers, lecturers and students as a tool to prove or disprove certain properties of quantum automata and languages in a reasonable time. We have successfully used our library and thus shown that it returns expected results for examples taken from literature.

The scope of the project can be broadened in several directions, e.g. by adding new types of automata.

Acknowledgments. The research presented in this paper was supported by the funds assigned to AGH University of Science and Technology by the Polish Ministry of Science and Higher Education.

Footnotes

Contributor Information

Valeria V. Krzhizhanovskaya, Email: V.Krzhizhanovskaya@uva.nl

Gábor Závodszky, Email: G.Zavodszky@uva.nl.

Michael H. Lees, Email: m.h.lees@uva.nl

Jack J. Dongarra, Email: dongarra@icl.utk.edu

Peter M. A. Sloot, Email: p.m.a.sloot@uva.nl

Sérgio Brissos, Email: sergio.brissos@intellegibilis.com.

João Teixeira, Email: joao.teixeira@intellegibilis.com.

Marcin Kuta, Email: mkuta@agh.edu.pl.

References

  • 1.Ambainis, A., Freivalds, R.: 1-way quantum finite automata: strengths, weaknesses and generalizations. In: 39th Annual Symposium on Foundations of Computer Science, FOCS 1998, pp. 332–341 (1998). 10.1109/SFCS.1998.743469
  • 2.Ambainis, A., Kikusts, A., Valdats, M.: On the class of languages recognizableby 1-way quantum finite automata. In: Ferreira, A., Reichel, H. (eds.) 18th Annual Symposium on Theoretical Aspects of Computer Science, STACS 2001, pp. 75–86 (2001)
  • 3.Ambainis, A., Yakaryılmaz, A.: Automata and quantum computing (2015). CoRR abs/1507.01988
  • 4.Bianchi MP, Mereghetti C, Palano B. Quantum finite automata: advances on bertoni’s ideas. Theor. Comput. Sci. 2017;664:39–53. doi: 10.1016/j.tcs.2016.01.045. [DOI] [Google Scholar]
  • 5.Chakraborty P, Saxena PC, Katti CP. Fifty years of automata simulation: a review. ACM Inroads. 2011;2(4):59–70. doi: 10.1145/2038876.2038893. [DOI] [Google Scholar]
  • 6.Hirvensalo M. Quantum automata with open time evolution. IJNCR. 2010;1(1):70–85. doi: 10.4018/jncr.2010010104. [DOI] [Google Scholar]
  • 7.Hirvensalo M. Quantum automata theory – a review. In: Kuich W, Rahonis G, editors. Algebraic Foundations in Computer Science; Heidelberg: Springer; 2011. pp. 146–167. [Google Scholar]
  • 8.Kondacs, A., Watrous, J.: On the power of quantum finite state automata. In: 38th Annual Symposium on Foundations of Computer Science, FOCS 1997, Miami Beach, Florida, USA, 19–22 October 1997, pp. 66–75. IEEE Computer Society (1997)
  • 9.Moore C, Crutchfield JP. Quantum automata and quantum grammars. Theor. Comput. Sci. 2000;237(1–2):275–306. doi: 10.1016/S0304-3975(98)00191-1. [DOI] [Google Scholar]
  • 10.Nayak, A.: Optimal lower bounds for quantum automata and random access codes. In: 40th Annual Symposium on Foundations of Computer Science, FOCS 1999, pp. 369–377 (1999)
  • 11.Qiu, D., Li, L., Mateus, P., Gruska, J.: Quantum finite automata. In: Wang, J. (ed.) Handbook of Finite State Based Models and Applications, pp. 113–144 (2012)
  • 12.Rabin MO. Probabilistic automata. Inf. Control. 1963;6(3):230–245. doi: 10.1016/S0019-9958(63)90290-0. [DOI] [Google Scholar]
  • 13.Rabin MO, Scott DS. Finite automata and their decision problems. IBM J. Res. Dev. 1959;3(2):114–125. doi: 10.1147/rd.32.0114. [DOI] [Google Scholar]
  • 14.Rodger SH, Finley TW. JFLAP: An Interactive Formal Languages and Automata Package. Sudbury: Jones and Bartlett Publishers; 2006. [Google Scholar]

Articles from Computational Science – ICCS 2020 are provided here courtesy of Nature Publishing Group

RESOURCES