Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Finite Automaton equivalents to Regular Expression
Search
N@N
December 13, 2015
Technology
0
98
Finite Automaton equivalents to Regular Expression
数物セミナー冬の大談話会2015 in 岡山での発表資料
N@N
December 13, 2015
Tweet
Share
More Decks by N@N
See All by N@N
introduction to modern numerical analysis
spark6251
0
120
Programmer and English
spark6251
0
100
Let's go to the study session
spark6251
0
83
Quantum Computation
spark6251
0
250
Introduction to use Grunt
spark6251
0
76
Introduction to Regular Expression
spark6251
0
310
Introduction to SCSS+COMPASS
spark6251
0
250
Introduction to Psychology
spark6251
1
230
Introduction to HTML5
spark6251
0
230
Other Decks in Technology
See All in Technology
なんで私に登壇依頼が?! ~頼られるエンジニアになるためには~ /
mixi_engineers
PRO
2
200
Vos logs méritent mieux que la config par défaut
lyrixx
2
250
プッシュ型子育てサービスを、先行プロジェクト実施自治体において開始します
govtechtokyo
0
240
マイクロサービス環境におけるDB戦略 in DMMプラットフォーム
pospome
11
3k
GitHub最新情報キャッチアップ 2024年3月
dzeyelid
16
3.2k
長文から長文を生成するLLMツールをオープンソースで作ってみた。
tomohisa
2
140
Cloud Friendly(?) Jenkins. How we failed to make Jenkins cloud native and what we learned?
onenashev
PRO
0
110
ビジネスロジックを「型」で表現するOOPのための関数型DDD / Functional And Type-Safe DDD for OOP
yuitosato
29
11k
やっていきテスト
k6s4i53rx
0
160
オブジェクトのおしゃべり大失敗 メッセージングアンチパターン集 / messaging anti-pattern collection
ytake
0
330
XRミーティング 2024-03-20
1ftseabass
PRO
0
100
統計的学習理論読み Chapter 2
kmatsui
1
190
Featured
See All Featured
The Invisible Side of Design
smashingmag
293
49k
Designing the Hi-DPI Web
ddemaree
275
33k
Ruby is Unlike a Banana
tanoku
95
10k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
A Philosophy of Restraint
colly
195
15k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
Why You Should Never Use an ORM
jnunemaker
PRO
50
8.6k
Teambox: Starting and Learning
jrom
126
8.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
How to train your dragon (web standard)
notwaldorf
71
5.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
15
6.3k
Raft: Consensus for Rubyists
vanstee
130
6.2k
Transcript
None
• • •
• • • • • • •
• : → • ∈ , ⊂ , ∀ ,
∃ •
• •
• • •
• • • •
None
•
$ perl -i -pe 's/foo/bar/g' input foo oaaahhhhhhhh! -> bar
oaaahhhhhhhh! $ perl -i'*.bak' -pe 's/foo/bar/g' input
• HT 0x09 ¥t LF 0x0a ¥n CR 0x0d ¥r
LF ¥n CR ¥r CR+LF ¥r¥n
$ perl -i -pe 's/^¥t*//g' input
<A>B</C> -> B $ perl -i -pe 's/<(.*)>(.*)</(.*)>/$2/g' input <saflijlsa>BBBBBBBIAA</fjsaljfoa>
-> BBBBBBBIAA ¥1
• http://www.rexv.org/ • https://jex.im/regulex/
• • https://speakerdeck.com/spark6251/
• • • •
• 0 ∈ ℕ
None
•
None
None
1 1 2
• 1 1 1 1 1 2 2 2 1
2
• ≠ Σ • • Σ • • • Σ
Σ5 ∋ = = 5 • = 0 • Σ = , , , , , , , , ⋯
def = , Σ, , 0 , Σ : ×
Σ → 0 ∈ ⊂
1 = {1 , 2 } Σ = 0,1 :
× Σ → 1 ∈ 2 ⊂ 0 1 1 2 1 2 2 2 1 2
def =
1 = 0 1 (.*)0(.*) 1 2
1 2 1 2 2
Σ = < RESET >, 0,1, ⋯ , • •
< RESET >
• = , Σ, , 0 , • Σ ∋
= 1 2 ⋯ ∀ ∈ Σ def ∃ ∈ s. t. 0 = 0 , +1 = +1 ∈
def ∃: NFA s. t. recognize
• , • ∪ ≔ ∈ or ∈ • ∘
≔ ∈ and ∈ • ∗ ≔ 1 2 ⋯ ∈ ℕ, ∈ •
• Σ ≔ , , ⋯ , • ≔ good,
bad • ≔ start, end • ∪ = good, bad, start, end • ∘ = goodstart, goodend, badstart, badend • ∗ = , good, bad, goodgood, goodbad, badbad, ⋯
1 , 2 : Reg. Lang. ⇒ 1 ∪ 2
: Reg. Lang. 1 , 2 : Reg. Lang. ⇒ 1 ∘ 2 : Reg. Lang. : Reg. Lang. ⇒ ∗: Reg. Lang.
• 1 , 2 1 , 2 • 1 ∪
2 • 1 , 2 • 1 or 2 • • 1 2 •
• 1 = 1 , Σ, 1 , 1 ,
1 1 • 2 = 2 , Σ, 2 , 2 , 2 2 1. ≔ 1 , 2 1 ∈ 1 and 2 ∈ 2 2. ∀ 1 , 2 ∈ : ∀ ∈ Σ: 1 , 2 , = 1 1 , , 2 2 , 3. 0 ≔ 1 , 2 4. ≔ 1 , 2 1 ∈ 1 or 2 ∈ 2 = 1 × 2 ∪ 2 × 1 = , Σ, , 0 ,
1 1 2 1 2 1 2
• = , Σ, , 0 , = 1 ,
2 , 1 , 1 , 1 , 2 , 1 , 2 , 1 , 1 , 1 , 2 : 1 × 2 × Σ → 1 × 2 0 = 1 , 2 = 1 , 2 , 1 , 1 , 1 , 2 , 1 , 1 1 1 2 1 2 1 2
• • •
• • • • •
• 2 1 3 4
2 1 1 1 2 1 3 3 3 4
2 1 3 4
def = , Σ, , 0 , Σ : ×
Σ → Σ ≔ Σ ∪ 0 ∈ ⊂
= {1 , 2 , 3 , 4 } Σ
= 0,1 : × Σ → 1 ∈ 2 ⊂ 0 1 ε 1 1 1 , 2 ∅ 2 3 ∅ 3 3 4 ∅ ∅ 4 ∅ ∅ ∅ 2 1 3 4
• = , Σ, , 0 , • Σ ∋
= 1 2 ⋯ ∀ ∈ Σ def ∃ ∈ s. t. 0 = 0 ∀ ∈ ℕ, ≤ − 1: +1 ∈ , +1 ∈
iff ∀1 : NFA: ∃2 : DFA s. t. 1
≡ 2 ∀1 , 2 : FA 1 ≡ 2 def 1 2
• = , Σ, , 0 , • ′ =
′, Σ, ′, 0 ′ , ′ • ′ • • • • card = ⇒ card = 2
• = , Σ, , 0 , • ′ =
′, Σ, ′, 0 ′ , ′ 1. ′ ≔ 2. ∀ ∈ ′: ∀ ∈ Σ: ′ , = ∈ ∈ , , ∈ = , ∈ 3. 0 ′ ≔ 0 4. ′ ≔ ∈ ′ ⊂
• ⊂ ′ ∈ ′ ∗ → • ⊂ ≔
∗ → ′ , = , = ∈ ∈ , , ∈ 0 ′ = 0 ///
∃: DFA s. t. recognize
• • • ′ = ′ ′ 2 1 3
• = , Σ, , 0 , • ′ =
′, Σ, ′, 0 ′ , ′ • 0 ′ = 0 = 1 , 2 • ′ = 3 , 1 , 3 , 2 , 3 , 1 , 2 , 3 2 1 3
0 1 ε 1 1 1 , 2 ∅ 2
3 ∅ 3 3 ∅ ∅ ∅ ′ 0 1 1 1 , 2 , 3 1 , 2 2 3 ∅ 3 ∅ ∅ 2 1 3
′ 0 1 1 1 , 2 , 3 1
, 2 2 3 ∅ 3 ∅ ∅ ′ 0 1 1 1 , 2 , 3 1 , 2 2 3 ∅ 3 ∅ ∅ 1 , 2 1 , 2 , 3 1 , 2 1 , 2 , 3 1 , 2 , 3 1 , 2 2 1 3
1 , 2 , 3 1 , 2 3 2
1
1 , 2 , 3 1 , 2
′ = 1 , 2 , 1 , 2 ,
3 0 ′ = 1 , 2 ′ = 1 , 2 , 3 1 , 2 , 3 1 , 2 ′ 0 1 1 , 2 1 , 2 , 3 1 , 2 1 , 2 , 3 1 , 2 , 3 1 , 2
1 , 2 : Reg. Lang. ⇒ 1 ∪ 2
: Reg. Lang. 1 , 2 : Reg. Lang. ⇒ 1 ∘ 2 : Reg. Lang. : Reg. Lang. ⇒ ∗: Reg. Lang.
1. ≔ 0 ∪ 1 ∪ 2 2. ∀ ∈
: ∀ ∈ Σ : , = 1 , ∈ 1 2 , ∈ 2 1 , 2 = 0 and = ∅ = 0 and ≠ 3. ≔ 1 ∪ 2 • = 0 and = • 1 ∘ 2 , ∗
• • •
• Σ = 0,1 • 0 ∪ 1 ∗ •
0 ∪ 1 ∗0 0 ∪ 1 ∗ ∘ 0 • 0Σ∗ ∪ 1Σ∗ ΣΣ∗
• ∗, 1 ∘ 2 , 1 ∪ 2 •
1 ∗ ∪ 2 ∘ 3 ∪ 4 ∗ 1 ∗ ∪ 2 ∘ 3 ∪ 4 ∗
def 1. ∈ Σ 2. 3. ∅ 4. 1 ∪
2 5. 1 ∘ 2 6. 1 ∗ 1 , 2
• + ≔ ∗ • + = ∪ • ≔
⋯ ∈ ℕ • 1∗∅ ≔ ∅ • ∅∗ ≔ • ∗
+∪−∪ + ∪ +. ∗ ∪ ∗. + +72, −5.2,
2. , −.6
•
• NFA DFA def ∃: NFA s. t. recognize
⇐ ⇒ ⇒
⇐ 1. ∈ Σ = = = 1 , 2
, Σ, , 1 , 2 2. = = = 1 , Σ, , 1 , 1 a 1 2 1
⇐ 3. = ∅ = ∅ = 1 , Σ,
, 1 , ∅ 4. = 1 ∪ 2 5. = 1 ∘ 2 6. = 1 ∗ 1
⇒
• • • • •
• = , Σ, , 0 , • ′ =
′, Σ, ′, , • → ′ 1. 0 → 2. ∈ : → ∅
+ 2 + 1 2
1 2 2 3 3 1 1 3 1 2
∗3
def = , Σ, , , Σ : − ×
− → ℛ ℛ ∈ ∈ 1 , 2 = 1 2
• = , Σ, , , • Σ ∋ =
1 2 ⋯ ∀ ∈ Σ∗ def ∃ ∈ s. t. 0 = = ∀ ∈ ℕ: = −1 , ⇒ ∈
⇒ • CONVERT
⇒ CONVERT 5. 6. = 2 →
⇒ CONVERT 7. > 2 , ≠ rip ∈ ′
= ′, Σ, ′, , ′ = − rip ∀ ∈ ′ − , ∀ ∈ ′ − : ′ , = 1 2 ∗ 3 ∪ 4 1 = , rip , 2 = rip , rip , 3 = rip , , 4 = , 8. CONVERT ′ = 2
⇒ CONVERT CONVERT CONVERT CONVERT G′ CONVERT ′ CONVERT ′′
CONVERT −2
⇒ ∀: GNFA: CONVERT ≡ ′ = CONVERT ∀1 ,
2 : FA 1 ≡ 2 def 1 2
⇒ ⇒ = 2 • •
⇒ ⇒ − 1 ′ , 1 , 2 ,
⋯ , ≠ rip ∀ ′
⇒ ⇒ rip → rip → ′
⇒ ⇐ ′ rip ′
⇒ ′ − 1 ′ ≡ ≡
2 1 3
1 ∪ 0 ∪ 1 2 1 3 0
1 ∪ 0 ∪ 1 2 1 0
1 ∪ 0 0 ∪ 1 1
0 ∪ 1 ∗ 1 ∪ 0 [01]*1?0
• 0∗1∗ • 01 • • •
•
• •