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
110
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
140
Programmer and English
spark6251
0
110
Let's go to the study session
spark6251
0
95
Quantum Computation
spark6251
0
260
Introduction to use Grunt
spark6251
0
80
Introduction to Regular Expression
spark6251
0
330
Introduction to SCSS+COMPASS
spark6251
0
270
Introduction to Psychology
spark6251
1
250
Introduction to HTML5
spark6251
0
260
Other Decks in Technology
See All in Technology
Pwned Labsのすゝめ
ken5scal
2
500
IAMのマニアックな話2025
nrinetcom
PRO
6
1.3k
IAMポリシーのAllow/Denyについて、改めて理解する
smt7174
2
210
Amazon Q Developerの無料利用枠を使い倒してHello worldを表示させよう!
nrinetcom
PRO
2
120
"TEAM"を導入したら最高のエンジニア"Team"を実現できた / Deploying "TEAM" and Building the Best Engineering "Team"
yuj1osm
1
220
4th place solution Eedi - Mining Misconceptions in Mathematics
rist
0
150
急成長する企業で作った、エンジニアが輝ける制度/ 20250227 Rinto Ikenoue
shift_evolve
0
160
Visualize, Visualize, Visualize and rclone
tomoaki0705
9
83k
生成AI “再”入門 2025年春@WIRED TUESDAY EDITOR'S LOUNGE
kajikent
0
150
開発組織を進化させる!AWSで実践するチームトポロジー
iwamot
2
460
Snowflake ML モデルを dbt データパイプラインに組み込む
estie
0
110
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
540
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
13k
Embracing the Ebb and Flow
colly
84
4.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
Done Done
chrislema
182
16k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
KATA
mclloyd
29
14k
Navigating Team Friction
lara
183
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Making Projects Easy
brettharned
116
6k
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 • • •
•
• •