서픽스 오토마톤

Suffix automaton
서픽스 오토마톤
Suffix automaton bold.svg
유형서브스트링 인덱스
발명된1983
발명자앤셀름 블러머, 재닛 블러머, 안제이 에렌퓨흐트, 데이비드 하우슬러, 로스 매코넬
O 표기의 시간 복잡도
알고리즘. 평균 최악의 경우
공간

컴퓨터 과학에서 서픽스 오토마톤은 주어진 문자열의 서브스트링 인덱스를 나타내는 효율적인 데이터 구조이며, 모든 서브스트링에 대한 압축 정보의 저장, 처리 및 검색을 가능하게 한다.S의 접미사 오토마톤({S})은 초기 정점에서 최종 정점까지의 경로가 문자열의 접미사를 나타내도록 전용 초기 정점과 "최종" 정점 세트를 가진 최소 방향 비순환 그래프입니다.

오토마타 이론에서 접미사 오토마톤은 주어진 S 2 \ S1} 접미사 집합을 인식하는 최소 부분 결정론적 유한 오토마톤이다.접미사 자동화의 상태 그래프는 DAWG(Directed acyclic word graph)라고 불리며, 결정론적 비순환적 유한 상태 자동화에 사용되기도 한다.

서픽스 오토마타는 1983년 덴버 대학콜로라도 볼더 대학의 과학자 그룹에 의해 도입되었다.이들은 선형 시간 온라인 알고리즘을 제안했으며 길이가 최소 2자 이상인 SS})의 서픽스 오토마톤은 2개의({ 2 상태와 3개의({}) 전환이 있음을 보여주었다.추가 연구는 접미사 오토마타와 접미사 트리의 밀접한 관련성을 보여주었으며, 단일 발신 호를 가진 노드를 압축하여 얻은 압축 접미사 오토마톤과 같은 접미사 오토마타의 몇 가지 일반화를 개략적으로 설명했다.

서픽스 오토마타는 서브스트링 검색 및 2개 이상의 문자열로 이루어진 가장 큰 공통 서브스트링 계산과 같은 문제에 대한 효율적인 해결책을 제공합니다.

역사

스트링 abcabcab의 일반 CDAWG 도면을 사용한 Anselm Blumer

비록 비슷한 개념 초 접미사 나무들과 함께 피터 Weiner,[2]의 작품에서 연구되어 졌다 접미사 automaton의 개념 1983[1]의 과학자들의 덴버 대학교와 콜로라도 대학교 볼더의 집단에서 안젤름 블루머, 자넷 블루머, 안제이 Ehrenfeucht, 데이비드 Haussler과 로스 매코널로 구성된 도입되었는데, Vaughan[3] 프랫과 아나톨 슬리센코.[4]Blumer 등은 초기 작업에서 길이가1({1)보다 S 대해 작성된 접미사 오토마톤을 보여주었고 자동화에 알고리즘을 제안했다.온스트럭처링[5]

1983년 Mu-Tian Chen과 Joel Seiferas는 독자적으로 Weiner의 1973년 서픽스 트리 구축[2] 알고리즘에 문자열서픽스 오토마톤(*S 보조 [6]구조로 구축한다는 것을 보여주었다.1987년, Blumer 등은 접미사 트리에 사용되는 압축 기술을 접미사 오토마톤에 적용하고 압축된 접미사 오토마톤을 발명했다. 이것은 또한 CDAWG([7]compacted directed acyclic word graph)라고도 불린다.1997년 Maxime Crochemore와 Renaud Vérin은 직접 CDAWG [1]구축을 위한 선형 알고리즘을 개발했습니다.2001년, 이네나가 슌스케 은 트라이에 [8]의해 주어진 단어 세트에 대한 CDAWG 구축 알고리즘을 개발했다.

정의들

보통 접미사 오토마타와 관련 개념에 대해 말할 때, 특히 [9]다음과 같은 형식 언어 이론과 오토마타 이론의 몇 가지 개념이 사용됩니다.

  • 알파벳은 단어 구성에 사용되는 유한 집합δ(\입니다.그 요소를 '문자'라고 한다.
  • "Word"는 문자 1 2 ... n { \ _ 1} \_ {2} \ \ n} { \ "Length"는 { \=}로 됩니다.
  • '포멀 랭귀지'는 주어진 알파벳 위에 있는 단어 집합이다.
  • "모든 단어의 언어"는 여기서 "*" 문자는 Kleene 별을 나타냄), "빈 단어"(길이가 0인 단어)는 {\(\로 표시됩니다.
  • " 연결" n α _ { { {} 1 2 … m _ {1alpha _ { α \ style \ {된다.ndsα의 β {\ 표기하여 얻은 단어, 즉 β m 1}\\alpha _{{{\ } \alpha } _ \lang} \alpha} \lang}{\langu}_{ \lang}_{{\
  • "언어 연결" AB(\ B A A B 또는 AB 표시되며 쌍으로 연결된 { : α Adisplay B(\ AB)에 해당합니다
  • 단어 \ \ in \ Sigma { * } 、 、 \ \ sigma \ alpha \ , 、 , , \ style \ \ sigma 、 \ sigmaα α α α α α α α α α α α α α α α α α α α α α 、 \ sigma 。\displaystyle \mega \ \ "subword", "subword"(부호)로 불린다.
  • \ \ } + ... \ \ T_} = 서 l{ l {r은 T {T에서 S {displaystyle S 및 오른쪽 발생 위치라고 한다.

오토마톤 구조

공식적으로는 결정론적 유한 오토마톤은 5 A ( , F (\A}}=(\ Q,\delta에 의해 결정된다.[10]

  • \Sigma }는 단어 구성에 사용되는 알파벳입니다.
  • Q 일련의 자동 "상태"입니다.
  • 00}\ Q 자동화의 "초기" 상태입니다.
  • Q ( \ F \ Q )는 자동화의 "최종" 상태의 집합입니다.
  • Q는 자동의 부분적인 "" 함수입니다.이 경우, Qσ q q display display {\ σ display display display display display q q q qq q q {\ {\ {\ {\ {\ q q {\ {\ {\ {\ {\ {\ q {\ q q {\ {\ {\ {\ {\ q q q q q q q q q q q q q q q q q q \

일반적으로 결정론적 유한 오토마톤은 다음과 같이 [10]유도 그래프("그림")로 표현된다.

  • 그래프 꼭지점 세트는 Q(\ Q에 대응합니다.
  • 그래프에는 초기 0에 대응하는 특정 마킹된 정점이 있습니다.
  • 그래프에는 최종 F F에 대응하는 여러 개의 표시된 정점이 있습니다.
  • 그래프 호 세트는 트랜지션 \에 대응합니다.
  • 구체적으로는1 , ) 2 \ ( ( ( q , \ display {2 1} )에서 로 호가 표시됩니다.이 천이는 될 수도 있습니다 2(\

다이어그램 측면에서, 오토마톤은 단어 1 2 … m{ \ opha _ {1}\_ { _ (를) 인식한다 이는 F의 초기 {\}}에서 최종 {\{0까지의 경로가 있는 에만 해당된다.path \ \ 자동으로 인식되는 단어 세트는 자동이 인식하도록 설정된 언어를 형성합니다.이 용어에서S(\ S의 접미사 오토마톤에 의해 인식되는 언어는 접미사 [9]언어(공백일 수 있음)입니다.

자동 상태

에 대한 { \ \ obega}의 "오른쪽 컨텍스트"는 집합 [] α : } { \ [ \ ] { R } = \ { \ { \ { \ \ 이며 이러한 이다.는 L{\ L에서 단어를 형성합니다. 오른쪽 문맥은 모든 단어 집합에서 자연스러운 동등성관계를 합니다 [ ] R [β ] { { \ ]} = [ \ ]R}L(\ L 어떤 결정론적 유한 오토마톤에 의해 인식되는 경우, 동일한 언어를 인식하고 가능한 최소 수의 상태를 갖는 동형 자동자까지 고유한 것이 존재합니다.이러한 자동화를 주어진 L L에 대한 최소 자동화라고 합니다. Myhill-Nerode 정리를 통해 올바른 컨텍스트의 [11][12]관점에서 명시적으로 정의할 수 있습니다.

정리 - 알파벳(\ 대한 L(\ L 인식하는 최소 자동화는 다음과 같이 명시적으로 정의할 수 있습니다.

  • 그대로입니다.
  • Q(\ Q 모든 단어 대응합니다
  • 초기 0빈 단어[ {\R의 오른쪽 컨텍스트에 대응합니다.
  • Final F { FLl l from from from R의 오른쪽 컨텍스트에 대응합니다.
  • ( \ \ [ [ ] ]] { \ [ \} { \ {} { \ } \ \ \ \ \ [ } \ long } \ } \ {{ [ \ } { \ } { \ } { } {} { } { } { } { } { } { } { }

이러한 용어로, "자동화"는 S s { =}\n의 접미어 언어를 인식하는 최소 결정론적 유한 자동화이다.이 언어의 오른쪽 {\\가 S {\ S 접미사인α {\\alpha 구성되어 있으며, 오른쪽 컨텍스트와 오른쪽 컨텍스트 사이의 분사를 정의하는 다음과 같은 lema를 공식화할 수 있습니다.S S[13][14]에서 발생한 올바른 위치 집합:

정리 : d s ( ) { : l { ( \ ) = \ { : \ =_ { } \ s { \} be berences of of ofof of of of theorem of of of of of of of of of of of of ofof of of of of of of of of of of of of of of of of of of of of of of of of of of of of of of

d s (" ( \ [ { [ obega ] 에는 다음 분사가 있습니다.

  • x e s (\ x \ ( \ ) 의 경우 + + ...s n ] [ style s + 1) s 2 \ { } \ [ \]{ } ;
  • R {\alpha [ \R - p () \ - \\ in ( \obega )} 。

예를 들어, S {\ S 그 서브워드 {\, s { 2,6} {(ab) =2, 및 b} { } r, }, a = a 、 비공식적으로 {는) 의 끝부분까지 b(\ab 단어로 되며, d s는 이러한 발생의 올바른 위치에 의해 형성됩니다이 예에서 x (){ x =2 \ endpos ) a[ [ ]R { { s _ { 4 }{ n ( ) s } s = { } with withrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsrespondsresponds with in in in in in in in in(는) 단어 a [ b ] a \ ab ]{(는) 요소 - a d p s ( { endpos에 대응합니다

이는 접미사 자동 상태의 몇 가지 구조 속성을 의미합니다.α(\\alpha 라고 .[14]

  • [ {\[\R [ R {[\R}}이 적어도1개의 공통 x {\ 가지고 경우 공통 요소입니다. α \alphaβ \ 이므로 (\)\(\alpha) R [] R [ displaystyle [ \ ]]의 서픽스입니다 b{ab}는 c {cab}의 서픽스이므로[ { , } [b { [ cab n s ( ) { } {, 6} n s ( )\ ( ) = \ { 6 \ } \ \ {, 6 \ } ) ;
  • [β] {\ ]_{R} = [\R}인 () = ( (\ \에만 표시된다 β { \ } { , a { ] e s ( )= s ( {, 6 { endpos (b)= \ { 2 ;
  • [ [ ]} [\ 및 β 인 경우 {\ \ \leq [ R의 [ ]이다.]_{ _{R}. 에서는[] [ a ] { a b a { ]{ [ { a { [ 접미사" \ 해당합니다

접미사 오토마톤의 모든 q [] {\ qR}}은 이 [14]상태에서 인식되는 가장 긴 단어의 중첩된 접미사를 연속적으로 인식한다.

"왼쪽 확장" displaystyle} (는) {\displaystyle(와) 오른쪽 컨텍스트가 같은 가장 긴 displaystyle {style\}}}{\display [ {\q= R} 로 인식되는 가장 긴 문자열의 {\ len 로 표시됩니다.다음과 [15]같이 표시됩니다.

{}의 왼쪽 는 β β { \ \ = \ \ {\ {\ theorem theorem theorem theorem theorem theorem theorem theorem ← theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem theorem

q [α ] {\ q = [\ "Suffix link" (q {}는q {에서 인식되지 않는 α의 접미사를 포함하는 p { 대한 포인터입니다.

q [α ] { q [ \ ] { { { } { \ 、 l k 또,[15] 다음과 같은 것이 있습니다.

정리 - 접미사 링크는 T 를 형성합니다.{ \{T) 。이러한 링크는 다음과 같이 명시적으로 정의할 수 있습니다.

  1. 트리의 V(\ V 모든 S 서브스트링의 왼쪽 {\
  2. 트리의 E α display display over display display display display display display display display display display display display display display display display overdisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplayoverdisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplayoverdisplaydisplaydisplaydisplaydisplayoverdisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplayoverdisplaydisplayoverdisplaydisplaydisplaydisplaydisplaydisplayoveroverdisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplayover 입니다

접미사 트리를 사용한 연결

접미사 트리, 접미사 트리, DAWG 및 CDAWG의 관계

"프리픽스 트리"(또는 "트리")는 동일한 문자로 표시된 두 개의 나가는 호를 가진 vv}가 없는 방식으로 호가 문자로 표시된 루트 방향 트리입니다.trie의 일부 정점은 최종으로 표시됩니다.Trie는 어근에서 최종 꼭지점까지의 경로에 의해 정의된 단어 집합을 인식한다고 한다.이와 같이 프리픽스 트리는 루트를 초기 [16]정점으로 인식할 경우 특별한 종류의 결정론적 유한 오토마타입니다.displaystyle S)라는 단어의 "suffix trie"는 일련의 접미사를 인식하는 접두사 트리입니다."접미사 트리"는 압축절차를 통해 접미사 트리로부터 얻은 트리이며, 그 사이에 정점의 정도가 [15]2일 경우 후속 에지가 병합된다.

그 정의에 따르면 서픽스 트리e를 최소화함으로써 서픽스 오토마톤을 얻을 수 있다.접미사 트리의 최소화와(접미사 [17]트리의 가장자리에 있는 각 문자열이 알파벳의 솔리드 문자라고 가정할 경우) 접미사 오토마톤의 콤팩트화를 통해 압축된 접미사 오토마톤을 얻을 수 있음을 알 수 있다.접미사 트리와 같은 문자열의 접미사 오토마톤 간에는 이러한 연결 이외에도 S 2 … n \ S 접미사 오토마톤과 반전 S -1 S^ 1 의 연결도 있습니다.[18]

오른쪽 컨텍스트와 마찬가지로 "왼쪽 "[ ] L { L \ [ \L } \ { \ \ in \ Sigma ^ { *} : \ \ L\ sigma \ set style 、 (\ ) {\ {\ {\styleensions {\ {\ {\ {\ωωω\ {\ωstylestylestylestyle → { \ } 및등가관계 [] [β ] { 문자열의 "" L L 관련하여 올바른 확장자를 고려하는 경우 다음을 얻을 [15]수 있습니다.

정리 - S S 접미사 트리는 다음과 같이 명시적으로 정의할 수 있습니다.

  • 트리의 V(\ V S S 서브스트링의 확장 해당합니다.
  • E(\ x 、 x → display display display display display display display displaydisplay → display display display displaydisplay display display display display display display display display display display display display display display displaydisplaydisplay displaydisplay display display display display display display display display display display display display display display display display display display display를 클릭합니다.

여기서 triplet( 1, , )e { \ ( _ { , \ , v {} \ E}는 "{\ 표시된 1 ~2 { {}의 엣지가 있음을 의미합니다.

즉, 링크트리와 S 서픽스 [18]동형입니다.

단어 "abbcbc" 및 "cbcbba"의 접미사 구조

왼쪽 확장의 경우와 마찬가지로 오른쪽 [15]확장의 경우 다음 보조항목이 유지됩니다.

정리 - 오른쪽 α displaystyle α displaystyle { } \ \ alpha 있습니다.S{ \ 모든 발생이 성공할 수 있는 가장 긴 단어입니다.

크기

n S(\S 서픽스 오토마톤에는 상태 전환이 있습니다.이러한 경계는 b n- bb b … - { bc ab^{c}에 [13]대응하여 도달합니다.이것은 Q + - 2( \ \ \+ )로 보다 엄밀하게 공식화할 수 있습니다.서 {\{ \}와 ( \ Q)는 대응하는 [14]자동화의 트랜지션 및 상태 수입니다.

최대 접미사 오토마타

건설

처음에 자동화는 빈 단어에 대응하는 단일 상태로만 구성되며, 그 후 문자열의 문자가 하나씩 추가되고 각 단계에서 자동화가 단계적으로 [19]재구축된다.

상태 갱신

문자열에 새 문자가 추가된 후 일부 동등성 클래스가 변경됩니다.[ { style [ \ { _ { \ }} { style \서픽스의 언어에 관한 컨텍스트라고 합니다 다음 x{\ x [ {에서 { x로의 천이를[14]로 정의합니다.

: ,( \ style \ alpha , \ \\ Sigma { * } some over over over over over over over over over over over over over displaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplaydisplay \ \ Sigma \ sigma 다음으로 [ { \ [ \ { R _ { \ obega}}과[ x { \ [\ { R { \ x 에 다음과 같은 대응이 있습니다.

  • x [] R x[ { } { \ cup \ { \ α가 x { 접미사인
  • [ x [] x [ \ \ _ \ x }=[ \ { \ obega 이외의 경우

현재 에 x 한 후α \ 컨텍스트는(\ x x의 접미사인 에만 크게 변경됩니다.즉, 등가관계 R x {\displaystyle \_ x R { \ _ omega개량한 것입니다.즉 [] R [ ] R [] R \ [ \ ] X ] { \ } { \ } { \ } { } { } { } { } { } { } { } { } { } {{ [ \ ] { R _ { \ obega } = [ \ { R { \ obega}}. r 2개의 동등 클래스(\ \ { _ { \ obe } })가 추가되면 각각 최대 2개의 새로운 클래스로 분할됩니다.첫째, 빈 오른쪽 콘텍스트에 대응하는 동등성 클래스는 항상 2개의 동등성 클래스로 분할됩니다.그 중 하나는 x ( \ \x )자체에 대응하고 { ( \ \ { \ \ \ } )를 오른쪽 콘텍스트로합니다.이 새로운 등가 클래스에는 정확하게 x에서 발생하지 않은 모든 서픽스가 포함됩니다.이러한 단어의 오른쪽 컨텍스트는 이전에는 비어 있었고 현재는 [14]빈 단어만 포함되어 있기 때문입니다.

서픽스 오토마톤 상태와 서픽스 트리의 정점과의 대응관계를 고려할 때, 새로운 문자가 부가된 후에 분할될 가능성이 있는 제2의 상태를 찾아낼 수 있다.에서x)」로의 이행은, 역스트링의 「})」에서 「로의 이행에 대응합니다.서픽스 트리에 관해서는 최장 R ( \ x \ { R )를R ( \ \ ^ { } )의 서픽스트리에 삽입하는 것에 대응합니다.이 삽입 후 최대 2개의 새로운 정점이 형성될 수 있습니다.x R ( x R \ x \ ^ ^ 합니다.나뭇가지가 있었다면 직계 조상에 해당하죠서픽스 오토마타로 돌아가면 첫 번째 새로운 상태가θ 하고 두 번째 상태(두 번째 새로운 상태가 있는 경우가 서픽스 링크임을 의미합니다.이는 다음과 같은 조건이라고 할 수 있다.[14]

정리 - display display display \ \ Sigma { *} , x \ x\ \ Sigma, \ \ sigma x 중 가장 긴 입니다. α {\ \ {\}}{\alpha그 후 모든 v 다음과 같이 됩니다.

  • ] R [ ] { ]_인 경우 [ [] { ]_[\ [ x [ ] x{ \ ] x x
  • ] R [] { ]_인 경우}}{}} u {\ {\ 、 [] R x [ x \ [ \ x x
  • ] R [] { ]_인 경우}}{R_ u> u>\ \ 다음으로 [ x [ R \ ] x x

, β { \ \display}(예를 들어 { x {=\ =\ 에서 전혀 발생하지 않은 )[14]는 빈 오른쪽 컨텍스트에 하는 분할된다는 것을 의미합니다

서픽스 링크 외에 오토마톤의 최종 상태를 정의하기 위해서도 필요합니다.구조 속성에서 {\q =]R}에 인식되는 {\displaystyle }의 모든 접미사가 접미사 경로 정점에 의해 인식됩니다.즉, 길이가 n ( k (){ ( (q )}{ q}}{ displaystyle ( ( )}}}{ displaystyle ( q ) stylink ( ( }}}}}보다 큰 접미사가 .) {link)} 등입니다. 인식하는 상태가 l {last로 표시되는 모든 최종 상태 \의 서픽스를 인식하는 상태)가 시퀀스 k ( t), 2 ( link합니다.[19]

전환 및 접미사 링크 업데이트

x(\ x 추가된 후 서픽스 자동화의 새로운 상태는 [ ] x {\x] 됩니다. x및 [ x {\[\ x [ x ] R x {\ x}로부터의 서픽스 링크{ x [ x{\ x 하며 [] R x {\alpha x에서 n] 로 이동한다{ x(는) 접미사로만 {\x에만 발생하므로 [ ] R {\[\_부터의 이행은 일절 없습니다{ x(는) 길이가α {\ 접미사에서 시작하여 문자 {\x로 표시해야 합니다 [ R xdis {\ ] x 서브셋으로 됩니다.{R_ [ R x {\ x에서[ R{\ style이행하는 것은 ] [\ ]에서와 같아야 . { \alpha} less n ( k ([ ] ) } ( link ( [ \ _ { \ obega}} ){ len ( ( [ \ alpha ]_ }) _ { \ } } } ) ωω ω ω ω ω ω ω ω ω ω ω [ {\ [이 상태의 것.이러한 서픽스에 대응하는 상태는 [ \ [ \ ] _ { \ omega[19]의 서픽스 링크 패스의 트래버설로 판별할 수 있습니다.

단어 abbcbc에 대한 접미사 자동 생성
∅ → a
Single letter SA.svg Single letter SA.svg
첫 번째 문자가 추가된 후에는 접미사 자동화로 하나의 상태만 생성됩니다. 마찬가지로 접미사 트리에 리프 하나만 추가됩니다.
a → 복부
Ab SA.svg Ba ST.svg
이전에 b가 나타나지 않았기 때문에 이전의 모든 최종 상태에서 새로운 전환이 도출됩니다. 같은 이유로 접미사 트리의 루트에 다른 리프가 추가됩니다.
ab → abb
Abb SA.svg Bba ST.svg
상태 2는 단어 ab와 b를 인식하지만 b만이 새로운 접미사이므로 이 단어는 상태 4로 구분됩니다. 접미사 트리에서 이는 정점 2로 이어지는 가장자리의 분할에 해당합니다.
abb → abbc
Abbc SA.svg Cbba ST.svg
문자 c는 처음 발생하므로 이전의 모든 최종 상태에서 전이가 도출됩니다. 역문자열의 접미사 트리에 루트에 다른 리프가 추가되었습니다.
abbc → abbcb
Abbcb SA.svg Bcbba ST.svg
상태 4는 유일한 단어 b(서픽스)로 구성되어 있기 때문에 상태는 분할되지 않습니다. 이에 대응하여 접미사목의 정점 4에 새로운 잎이 매달린다.
abbcb → abbcbc
Suffix Automaton extension.svg Suffix Tree extension.svg
상태 5는 단어 abbc, bbc, bc c를 인식하지만 마지막 두 개만 새로운 단어의 접미사이므로 새 상태 8로 구분됩니다. 이에 대응하여 정점 5로 이어지는 엣지를 분할하고 엣지 중간에 정점 8을 둔다.

건설 알고리즘

상기의 이론적인 결과에 따라 x(\x)를 사용하여 자동화를 문자 x[19] 서픽스 자동화로 재구축하는 알고리즘이 알고리즘은 다음과 같습니다.

  1. 대응하는 상태는 l \last로 됩니다.
  2. x x 추가된 이전 t{p가 변수p last}에 되고 l t { last x {\ x에 대응하는 새로운 상태로 재할당됩니다.
  3. 에 대응하는 상태는 \last로 하여 갱신됩니다이를 수행하려면 xx로 이미 이행한 상태가 될 때까지p , k () , 2 () , { p , ) , link ^ { ( ) , \ 해야 합니다.
  4. 상기의 루프가 종료하면, 다음의 3개의 케이스가 있습니다.
    1. 서픽스 경로 상에 x x로 이행한 상태가 없는 이전에 \ \omega에서 발생한 적이 없으며 에서(\ last 서픽스 링크는로 이어집니다.
    2. xx 이행이 발견되어 l (p) + n () ( \ len ( ) + 1 ( ) 에서(\q로 이어지는 경우 q {}는 분할할 필요가 없습니다
    3. ( )> (p )+ \ (q )p+ 1 \len + \ len ( p ) from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from from l l l l l from from from
  5. If the previous step was concluded with the creation of , transitions from it and its suffix link should copy those of , at the same time is assigned to be common suffix link of both and ;
  6. Transitions that have led to before but corresponded to words of the length at most are redirected to . To do this, one continues going through the suffix path of until the state is found such that transition by from it doesn't lead to .

The whole procedure is described by the following pseudo-code:[19]

function add_letter(x):     define p = last     assign last = new_state()     assign len(last) = len(p) + 1     while δ(p, x) is undefined:         assign δ(p, x) = last, p = link(p)     define q = δ(p, x)     if q = last:         assign link(last) = q0     else if len(q) = len(p) + 1:         assign link(last) = q     else:         define cl = new_state()         assign len(cl) = len(p) + 1         assign δ(cl) = δ(q), link(cl) = link(q)         assign link(last) = link(q) = cl         while δ(p, x) = q:             assign δ(p, x) = cl, p = link(p) 

Here is the initial state of the automaton and is a function creating new state for it. It is assumed , , and are stored as global variables.[19]

Complexity

Complexity of the algorithm may vary depending on the underlying structure used to store transitions of the automaton. It may be implemented in with memory overhead or in with memory overhead if one assumes that memory allocation is done in . To obtain such complexity, one has to use the methods of amortized analysis. The value of strictly reduces with each iteration of the cycle while it may only increase by as much as one after the first iteration of the cycle on the next add_letter call. Overall value of never exceeds and it is only increased by one between iterations of appending new letters that suggest total complexity is at most linear as well. The linearity of the second cycle is shown in a similar way.[19]

Generalizations

The suffix automaton is closely related to other suffix structures and substring indices. Given a suffix automaton of a specific string one may construct its suffix tree via compacting and recursive traversal in linear time.[20] Similar transforms are possible in both directions to switch between the suffix automaton of and the suffix tree of reversed string .[18] Other than this several generalizations were developed to construct an automaton for the set of strings given by trie,[8] compacted suffix automation (CDAWG),[7] to maintain the structure of the automaton on the sliding window,[21] and to construct it in a bidirectional way, supporting the insertion of a characters to both the beginning and the end of the string.[22]

Compacted suffix automaton

As was already mentioned above, a compacted suffix automaton is obtained via both compaction of a regular suffix automaton (by removing states which are non-final and have exactly one out-going arc) and the minimization of a suffix tree. Similarly to the regular suffix automaton, states of compacted suffix automaton may be defined in explicit manner. A two-way extension of a word is the longest word , such that every occurrence of in is preceded by and succeeded by . In terms of left and right extensions it means that two-way extension is the left extension of the right extension or, which is equivalent, the right extension of the left extension, that is . In terms of two-way extensions compacted automaton is defined as follows:[15]

TheoremCompacted suffix automaton of the word is defined by a pair , where:

  • is a set of automaton states;
  • is a set of automaton transitions.

Two-way extensions induce an equivalence relation which defines the set of words recognized by the same state of compacted automaton. This equivalence relation is a transitive closure of the relation defined by , which highlights the fact that a compacted automaton may be obtained by both gluing suffix tree vertices equivalent via relation (minimization of the suffix tree) and gluing suffix automaton states equivalent via relation (compaction of suffix automaton).[23] If words and have same right extensions, and words and have same left extensions, then cumulatively all strings , and have same two-way extensions. At the same time it may happen that neither left nor right extensions of and coincide. As an example one may take , and , for which left and right extensions are as follows: , but and . That being said, while equivalence relations of one-way extensions were formed by some continuous chain of nested prefixes or suffixes, bidirectional extensions equivalence relations are more complex and the only thing one may conclude for sure is that strings with the same two-way extension are substrings of the longest string having the same two-way extension, but it may even happen that they don't have any non-empty substring in common. The total number of equivalence classes for this relation does not exceed which implies that compacted suffix automaton of the string having length has at most states. The amount of transitions in such automaton is at most .[15]

Suffix automaton of several strings

Consider a set of words . It is possible to construct a generalization of suffix automaton that would recognize the language formed up by suffixes of all words from the set. Constraints for the number of states and transitions in such automaton would stay the same as for a single-word automaton if you put .[23] The algorithm is similar to the construction of single-word automaton except instead of state, function add_letter would work with the state corresponding to the word assuming the transition from the set of words to the set .[24][25]

This idea is further generalized to the case when is not given explicitly but instead is given by a prefix tree with vertices. Mohri et al. showed such an automaton would have at most and may be constructed in linear time from its size. At the same time, the number of transitions in such automaton may reach , for example for the set of words over the alphabet the total length of words is equal to , the number of vertices in corresponding suffix trie is equal to and corresponding suffix automaton is formed of states and transitions. Algorithm suggested by Mohri mainly repeats the generic algorithm for building automaton of several strings but instead of growing words one by one, it traverses the trie in a breadth-first search order and append new characters as it meet them in the traversal, which guarantees amortized linear complexity.[26]

Sliding window

Some compression algorithms, such as LZ77 and RLE may benefit from storing suffix automaton or similar structure not for the whole string but for only last its characters while the string is updated. This is because compressing data is usually expressively large and using memory is undesirable. In 1985, Janet Blumer developed an algorithm to maintain a suffix automaton on a sliding window of size in worst-case and on average, assuming characters are distributed independently and uniformly. She also showed complexity cannot be improved: if one considers words construed as a concatenation of several words, where , then the number of states for the window of size would frequently change with jumps of order , which renders even theoretical improvement of for regular suffix automata impossible.[27]

The same should be true for the suffix tree because its vertices correspond to states of the suffix automaton of the reversed string but this problem may be resolved by not explicitly storing every vertex corresponding to the suffix of the whole string, thus only storing vertices with at least two out-going edges. A variation of McCreight's suffix tree construction algorithm for this task was suggested in 1989 by Edward Fiala and Daniel Greene;[28] several years later a similar result was obtained with the variation of Ukkonen's algorithm by Jesper Larsson.[29][30] The existence of such an algorithm, for compacted suffix automaton that absorbs some properties of both suffix trees and suffix automata, was an open question for a long time until it was discovered by Martin Senft and Tomasz Dvorak in 2008, that it is impossible if the alphabet's size is at least two.[31]

One way to overcome this obstacle is to allow window width to vary a bit while staying . It may be achieved by an approximate algorithm suggested by Inenaga et al. in 2004. The window for which suffix automaton is built in this algorithm is not guaranteed to be of length but it is guaranteed to be at least and at most while providing linear overall complexity of the algorithm.[32]

Applications

Suffix automaton of the string may be used to solve such problems as:[33][34]

  • Counting the number of distinct substrings of in on-line,
  • Finding the longest substring of occurring at least twice in ,
  • Finding the longest common substring of and in ,
  • Counting the number of occurrences of in in ,
  • Finding all occurrences of in in , where is the number of occurrences.

It is assumed here that is given on the input after suffix automaton of is constructed.[33]

Suffix automata are also used in data compression,[35] music retrieval[36][37] and matching on genome sequences.[38]

References

Bibliography

External links