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
93
Quantum Computation
spark6251
0
260
Introduction to use Grunt
spark6251
0
79
Introduction to Regular Expression
spark6251
0
330
Introduction to SCSS+COMPASS
spark6251
0
260
Introduction to Psychology
spark6251
1
250
Introduction to HTML5
spark6251
0
260
Other Decks in Technology
See All in Technology
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
340
OCI技術資料 : ファイル・ストレージ 概要
ocise
3
11k
[JAWS-UG新潟#20] re:Invent2024 -CloudOperationsアップデートについて-
shintaro_fukatsu
0
120
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
2
120
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
290
能動的ドメイン名ライフサイクル管理のすゝめ / Practice on Active Domain Name Lifecycle Management
nttcom
0
250
生成AIのガバナンスの全体像と現実解
fnifni
1
210
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
190
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
140
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
1.5k
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
290
ハイテク休憩
sat
PRO
2
180
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Embracing the Ebb and Flow
colly
84
4.5k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Designing for humans not robots
tammielis
250
25k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Thoughts on Productivity
jonyablonski
68
4.4k
Building Adaptive Systems
keathley
38
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Cult of Friendly URLs
andyhume
78
6.1k
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 • • •
•
• •