Quantum Finite Automata and Their Simulations Gustaw Lippa - - PowerPoint PPT Presentation

quantum finite automata and their simulations
SMART_READER_LITE
LIVE PREVIEW

Quantum Finite Automata and Their Simulations Gustaw Lippa - - PowerPoint PPT Presentation

Quantum Finite Automata and Their Simulations Gustaw Lippa Krzysztof Makie la Marcin Kuta mkuta@agh.edu.pl Department of Computer Science, AGH University of Science and Technology, Krak ow, Poland Krak ow Quantum Informatics Seminar


slide-1
SLIDE 1

Quantum Finite Automata and Their Simulations

Gustaw Lippa Krzysztof Makie la Marcin Kuta

mkuta@agh.edu.pl

Department of Computer Science, AGH University of Science and Technology, Krak´

  • w, Poland

Krak´

  • w Quantum Informatics Seminar (KQIS)

13 October 2020

slide-2
SLIDE 2

Outline

Motivation Quantum finite automata Library for simulating quantum finite automata

slide-3
SLIDE 3

Existing libraries

Java Formal Languages and Automata Package (JFLAP) Quirk Quantum++ Q# Qiskit ProjectQ

slide-4
SLIDE 4

Types of Finite Automata

Classical automata

Deterministic Finite Automaton (DFA) Nondeterministic Finite Automaton (NFA) Alternating Finite Automaton (AFA)

slide-5
SLIDE 5

Types of Finite Automata

Classical automata

Deterministic Finite Automaton (DFA) Nondeterministic Finite Automaton (NFA) Alternating Finite Automaton (AFA)

Probabilistic automata

Probabilistic Finite Automaton (PFA)

slide-6
SLIDE 6

Types of Finite Automata

Classical automata

Deterministic Finite Automaton (DFA) Nondeterministic Finite Automaton (NFA) Alternating Finite Automaton (AFA)

Probabilistic automata

Probabilistic Finite Automaton (PFA)

Quantum automata

Measure-Once Quantum Finite Automaton (MO-QFA) Measure-Many Quantum Finite Automaton (MM-QFA) General Quantum Finite Automaton (GQFA)

slide-7
SLIDE 7

Deterministic Finite Automaton

Deterministic Finite Automaton (DFA) A = (Σ, Q, q0, Qacc, δ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q F - set of accepting states, F ⊆ Q δ: Q × Σ → Q - transition function Determinism condition For all q ∈ Q we have

p∈Q δ(q, σ, p) = 1

slide-8
SLIDE 8

Deterministic Finite Automaton

Figure: Internals of Finite Automaton [3]

slide-9
SLIDE 9

Deterministic Finite Automaton

Figure: Configuration of Finite Automaton [2]

slide-10
SLIDE 10

Deterministic Finite Automaton

Example

1 1 1 1 1 1 1

Figure: Deterministic finite automaton [2]

slide-11
SLIDE 11

Nondeterministic Finite Automaton

Nondeterministic Finite Automaton (NFA) A = (Σ, Q, q0, Qacc, δ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q F - set of accepting states, F ⊆ Q δ: Q × Σ → 2Q - transition function

slide-12
SLIDE 12

Nondeterministic Finite Automaton

Example

b a a a b 1 2 3 4 5 6 7 8 ǫ ǫ ǫ a a b b b a b

Figure: Nondeterministic finite automaton [2]

slide-13
SLIDE 13

Probabilistic Finite Automaton

Probabilistic Finite Automaton (PFA) A = (Σ, Q, π, η, {Mσ}σ∈Σ) Σ - alphabet, finite set of symbols π - vector denoting initial distribution of states, π ∈ [0, 1]1×N η - vector encoding accepting states, η ∈ {0, 1}N×1 {Mσ}σ∈Σ - set of transition matrices Acceptance probability w = σ1 . . . σn PA(w) = πM(σ1) . . . M(σn)η

slide-14
SLIDE 14

Measure-Once Quantum Finite Automaton

Measure-Once Quantum Finite Automaton (MO-QFA) A = (Q, Σ, q0, F, {Uσ}σ∈Σ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q F - set of accepting states, F ⊆ Q {Uσ}σ∈Σ - set of transition matrices Acceptance probability w = σ1 . . . σn PA(w) = PaccU(σn) . . . U(σ1)|q02

(Moore, C., Crutchfield, J.P.: Quantum automata and quantum grammars. Theoretical Computer Science 237(1-2), 275–306 (2000) )

slide-15
SLIDE 15

Measure-Once Quantum Finite Automaton

Dual formulation of automaton Classical Matrix Initial state q0 |q0 = (1, 0, . . . , 0)T Transitions δ: Q × Σ × Q → C {Uσ}σ∈Σ δ(qi, σ, qj) Uσ(j, i) Accepting states F Pacc =

q∈F |qq|

Unitarity condition Transition function δ:

  • p∈Q δ(q1, σ, p)δ(q2, σ, p) =
  • 1

q1 = q2 q1 = q2 Transition matrix U: U†

σUσ = UσU† σ = I|Q|

slide-16
SLIDE 16

Pumping lemma

Theorem (Pumping lemma for regular languages) Let language L be a regular language. Then there exists constant K such that for all w ∈ L, |w| ≥ K there exist x, y, z such that (1) w = xyz (2) |xy| ≤ K (3) |y| ≥ 1 (4) for all i ≥ 0 it holds wi = xyiz ∈ L

slide-17
SLIDE 17

Pumping lemma

Theorem (Pumping lemma for quantum regular languages) Let language L be recognized by MO − QFA. Then there exists constant K such that for any w and any ε > 0 for any u, v it holds |PA(xyKz) − PA(xyz)| < ε. Additionally, if automaton A is n-dimensional there exists constant c such that K < (cε)−n

slide-18
SLIDE 18

Measure-Once Quantum Finite Automaton

Example A = (Q, Σ, q0, F, {Uσ}σ∈Σ) Σ = {a} Q = {q0, q1} F = {q1} δ: δ(q0, a, q0) =

1 √ 2

δ(q0, a, q1) =

1 √ 2

δ(q1, a, q0) =

1 √ 2

δ(q1, a, q1) = − 1

√ 2

Matrix formulation |q0 = 1

  • |q1 =

1

  • U(a) =

1

√ 2 1 √ 2 1 √ 2

− 1

√ 2

  • Pacc = |q1q1| =

1

slide-19
SLIDE 19

Measure-Many Quantum Finite Automaton

Measure-Many Quantum Finite Automaton (MM-QFA) A = (Q, Σ, q0, Qacc, Qrej, {Uσ}σ∈Γ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q Qacc - set of accepting states, Qacc ⊆ Q Qrej - set of rejecting states, Qrej ⊆ Q {Uσ}σ∈Σ - set of transition matrices Evolution |Ψ → Pnon|U|Ψ pacc → pacc + Pacc|U|Ψ2 prej → prejpacc + Prej|U|Ψ2

(Kondacs, A., Watrous, J.: On the power of quantum finite state automata. 38th Annual Symposium on Foundations of Computer Science, FOCS’97)

slide-20
SLIDE 20

Measure-Many Quantum Finite Automaton

Acceptance probability w = σ1 . . . σn PA(w) =

n+1

  • k=1

PaccU(σk)

k−1

  • i=1

(PnonU(σi))2

slide-21
SLIDE 21

Example

Example A = (Q, Σ, q0, Qacc, Qrej, {Uσ}σ∈Σ) Σ = {a} Q = {q0, q1, qacc, qrej} Qacc = {qacc} Qrej = {qrej} δ: δ(q0, a, q0) = 1

2

δ(q0, a, q1) =

1 √ 2

δ(q0, a, qacc) = 1

2

δ(q0, a, qrej) = 0 . . . Evolution U(a)|q0 = 1

2|q0 + 1 √ 2|q1 + 1 2|qacc

U(a)|q1 = 1

2|q0 − 1 √ 2|q1 + 1 2|qacc

U($)|q0 = |qacc U($)|q1 = |qrej

slide-22
SLIDE 22

Comparison of MO-QFA and MM-QFA

MO-QFA MM-QFA One measurement Many measurements after reading the last symbol after reading each symbol acceptance or rejection acceptance, rejection or continuation Advantages and disadvantages of QFA QFA can be exponetially more space efficent than DFA or PFA Sometimes it is impossible to simulate DFA by QFA (due to limited memory) QFA cannot recognize all regular languages (due to reversibility)

slide-23
SLIDE 23

General Quantum Finite Automaton

General Quantum Finite Automaton (GQFA) A = (Q, Σ, q0, Qacc, Qrej, {Uσ}σ∈Γ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q Qacc - set of accepting states, Qacc ⊆ Q Qrej - set of rejecting states, Qrej ⊆ Q {Uσ}σ∈Σ - set of transition matrices

slide-24
SLIDE 24

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

slide-25
SLIDE 25

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

NFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

slide-26
SLIDE 26

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

NFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

DFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

slide-27
SLIDE 27

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

NFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

DFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

PFA

δ: Q × Σ × Q → [0, 1] Mσ ∈ [0, 1]|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

slide-28
SLIDE 28

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

NFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

DFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

PFA

δ: Q × Σ × Q → [0, 1] Mσ ∈ [0, 1]|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

MO-QFA

δ: Q × Σ × Q → C Mσ ∈ C|Q|×|Q|

  • p∈Q δ(q1, σ, p)δ(q2, σ, p) = δq1=q2

U†

σUσ = UσU† σ = I|Q|

slide-29
SLIDE 29

Two Formulations of Finite Automata

Automaton Transition function Transition matrix

NFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

DFA

δ: Q × Σ × Q → {0, 1} Mσ ∈ {0, 1}|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

PFA

δ: Q × Σ × Q → [0, 1] Mσ ∈ [0, 1]|Q|×|Q|

  • p∈Q δ(q, σ, p) = 1

Mσ1 = 1

MO-QFA

δ: Q × Σ × Q → C Mσ ∈ C|Q|×|Q|

  • p∈Q δ(q1, σ, p)δ(q2, σ, p) = δq1=q2

U†

σUσ = UσU† σ = I|Q| MM-QFA

δ: Q × Σ × Q → C Mσ ∈ C|Q|×|Q|

  • p∈Q δ(q1, σ, p)δ(q2, σ, p) = δq1=q2

U†

σUσ = UσU† σ = I|Q|

slide-30
SLIDE 30

Language Acceptance Modes 1/2

with a cut-point λ ∈ [0, 1), if for all x ∈ L, we have PA(x) > λ and for all x / ∈ L, we have PA(x) ≤ λ. This mode

  • f acceptance is also called with an unbounded error.

with an isolated cut-point λ ∈ [0, 1), if there exists ε ≥ 0, such, that for all x ∈ L, we have PA(x) ≥ λ + ε and for all x / ∈ L, we have PA(x) ≤ λ − ε. with a bounded error ε ∈ [0, 1

2), if for all x ∈ L, we have

PA(x) ≥ 1 − ε and for all x / ∈ L, we have PA(x) ≤ ε. This mode of acceptance is equivalent to acceptance with an isolated cut-point, where cut-point λ = 1

2 is isolated with

value 1

2 − ε.

slide-31
SLIDE 31

Language Acceptance Modes 2/2

with a positive one-sided unbounded error if for all x ∈ L, we have PA(x) > 0. with a negative one-sided unbounded error if for all x ∈ L, we have PA(x) = 1. Monte Carlo acceptance, if there exists ε ∈ (0, 1

2] such, that

for all x ∈ L, we have PA(x) = 1 and for all x / ∈ L, we have PA(x) ≤ ε. Such A is called Monte Carlo QFA for L.

slide-32
SLIDE 32

Hierarchy of quantum languages

Hierarchy of quantum languages Automaton Class of languages DFA Regular NFA Regular Acceptance Bounded Unbounded PFA Regular Stochastic MO-QFA ⊂ Regular ⊂ Stochastic MM-QFA ⊂ Regular Stochastic GQFA ⊂ Regular QFAC Regular CL-QFA Regular

slide-33
SLIDE 33

Hierarchy of quantum automata

Hierarchy of quantum automata Once Many U(σ) MO-QFA MM-QFA U(σ)+Projective Measurement LQFA GQFA

slide-34
SLIDE 34

Hierarchy of quantum languages

Figure: Hierarchy of classes of quantum languages recognized with bounded error [7]

slide-35
SLIDE 35

Functionality of the library

Definitions of automata: PFA, MO-QFA, MM-QFA, GQFA Simulations of automaton for a given word Sample generation from a language defined by regular expressions Examination of different acceptance modes for a given language Results visualisation

slide-36
SLIDE 36

Problems

Implementation problems Rounding errors Stability Samples generation Computational complexity

slide-37
SLIDE 37

Possible solutions

Rounding errors

More precise representation of complex numbers Estimating generated error based on performed computation A custom solution developed using domain knowledge

Stability

Results verification

Samples generation

Using an existing library Generating random samples

Computational complexity

Changing the simulation type from strong to weak Optimising computation Using existing optimised solutions

slide-38
SLIDE 38

Solutions taken in the library

Rounding errors - errors are estimated although not as precisely as it is probably possible. Future solution may check known constraints (like unitary state matrices) at every step and fix errors during the simulation Stability - there is a check at the end of the simulation whether the result is sensible Samples generation - samples are generated randomly, skewed towards shorter words. The parameters are configurable Computational complexity - the library uses NumPy, which is

  • ptimised enough for matrix multiplication, as it’s basis
slide-39
SLIDE 39

Simulations

Computational complexity Automaton size Alphabet size Word length

slide-40
SLIDE 40

Computational complexity

slide-41
SLIDE 41

Alphbet size

20 states 30 states

slide-42
SLIDE 42

Word length

5-letter alphabet 20 states of automaton

slide-43
SLIDE 43

Results visualisation

slide-44
SLIDE 44

Usage example 1/4

import numpy as np from math import sqrt from QFA.MM_1QFA import MM_1QFA from QFA. LanguageGenerator import LanguageGenerator from QFA. LanguageChecker import LanguageChecker from QFA.Plotter import Plotter

slide-45
SLIDE 45

Usage example 2/4

alphabet = ’ ab ’ p = 0.682327803828019 # A u x i l l a r y v a r i a b l e # I n i t i a l s t a t e

  • f

automaton i n i t i a l s t a t e = np . a r r a y ( [ [ s q r t (1−p ) ] , [ s q r t ( p ) ] , [ 0 ] , [ 0 ] ] ) # T r a n s i t i o n m a t r i c e s U a = np . a r r a y ([[1 −p , s q r t ( p∗(1−p ) ) , 0 , −s q r t ( p ) ] , [ s q r t ( p∗(1−p ) ) , p , 0 , s q r t (1−p ) ] , [ 0 , 0 , 1 , ] , [ s q r t ( p ) , −s q r t (1−p ) , 0 , ] ] ) U b = np . a r r a y ( [ [ 0 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 0 ] , [ 0 , 0 , 1 , 0 ] , [ 1 , 0 , 0 , 0 ] ] ) U end = np . a r r a y ( [ [ 0 , 0 , 0 , 1 ] , [ 0 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 0 ] , [ 1 , 0 , 0 , 0 ] ] )

slide-46
SLIDE 46

Usage example 3/4

# Accepting and r e j e c t i n g s t a t e s are d e f i n e d with m a t r i c e s # r e p r e s e n t i n g p r o j e c t i v e measurements P acc = np . a r r a y ( [ [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 1 , 0 ] , [ 0 , 0 , 0 , 0 ] ] ) P r e j = np . a r r a y ( [ [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 1 ] ] ) qfa = MM 1QFA( alphabet , i n i t i a l s t a t e , [ U a , U b , U end ] , P acc , P r e j )

slide-47
SLIDE 47

Usage example 4/4

language_generator = LanguageGenerator (’a*b*’, alphabet) language , not_in_language = language_generator . get_language_sample () language_checker = LanguageChecker (qfa , language , not_in_language ) plotter = Plotter( language_checker ) plotter.plot ()

slide-48
SLIDE 48

Two-way Quantum Finite Automaton

Two-way Quantum Finite Automaton (2QFA) A = (Q, Σ, q0, Qacc, Qrej, δ) Σ - alphabet, finite set of symbols Q - finite set of states q0 - initial state, q0 ∈ Q Qacc - set of accepting states, Qacc ⊆ Q Qrej - set of rejecting states, Qrej ⊆ Q δ - transition function

slide-49
SLIDE 49

Two-way Quantum Finite Automaton

Conditions on δ Local probability and orthogonality condition:

  • p∈Q,d

δ(q1, σ, p, d)δ(q2, σ, p, d) =

  • 1

q1 = q2 q1 = q2 Separability condition I:

  • p∈Q
  • δ(q1, σ, p, →)δ(q2, σ, p, ↓)+

+ δ(q1, σ, p, ↓)δ(q2, σ, p, ←)

  • = 0

Separability condition II:

  • p∈Q

δ(q1, σ, p, →)δ(q2, σ, p, ←) = 0

slide-50
SLIDE 50

Applications of 2QFA

L = { x ∈ {A, C, G, U}∗ | x = xR } L = { AnG mUnC n | n, m ≥ 0 } (a) hairpin loop (b) pseudoknot L = { AnUnG mC m | n, m ≥ 0 } (c) dumbbell

Figure: RNA structures recognised by 2QFA [3]

slide-51
SLIDE 51

Bibliography I

[1] Quantum finite automata library. https://github.com/gustawlippa/QFA. [2] Theory of finite automata and formal languages (in polish). https://www.kompilatory.agh.edu.pl. [3] Amandeep Singh Bhatia and Shenggen Zheng. RNA-2QCFA: evolving two-way quantum finite automata with classical states for RNA secondary structures. CoRR, abs/2007.06273, 2020. [4] Attila Kondacs and John Watrous. On the power of quantum finite state automata. In 38th Annual Symposium on Foundations of Computer Science, FOCS’97, pages 66–75, 1997.

slide-52
SLIDE 52

Bibliography II

[5] Gustaw Lippa, Krzysztof Makie la, and Marcin Kuta. Simulations of quantum finite automata. In Proceedings of 20th International Conference on Computational Science, ICCS 2020, volume 12142 of LNCS, pages 441–450, 2020. [6] Cristopher Moore and James P. Crutchfield. Quantum automata and quantum grammars. Theoretical Computer Science, 237(1-2):275–306, 2000. [7] Daowen Qiu, Lvzhou Li, Paulo Mateus, and Jozef Gruska. Quantum finite automata. In Handbook of Finite State Based Models and Applications, pages 113–144. 2012.