-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html~
879 lines (779 loc) · 26.3 KB
/
index.html~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
<!DOCTYPE html>
<html>
<head>
<title>Solutions for Computation</title>
<!-- 2016-12-13 周二 23:18 -->
<meta charset="utf-8">
<meta name="generator" content="Org-mode">
<meta name="author" content="sylsaint">
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center; }
.todo { font-family: monospace; color: red; }
.done { color: green; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.right { text-align: center; }
th.left { text-align: center; }
th.center { text-align: center; }
td.right { text-align: right; }
td.left { text-align: left; }
td.center { text-align: center; }
dt { font-weight: bold; }
.footpara:nth-child(2) { display: inline; }
.footpara { display: block; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="styles/readtheorg/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="styles/readtheorg/css/readtheorg.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="styles/lib/js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="styles/readtheorg/js/readtheorg.js"></script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">Solutions for Computation</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1. chapter 1</a>
<ul>
<li><a href="#sec-1-1">1.1. M<sub>1</sub> and M<sub>2</sub></a></li>
<li><a href="#sec-1-2">1.2. formal description</a></li>
<li><a href="#sec-1-3">1.3. diagram of DFA</a></li>
<li><a href="#sec-1-4">1.4. intersection of two languages</a></li>
<li><a href="#sec-1-5">1.5. complement of language</a></li>
<li><a href="#sec-1-6">1.6. diagram of DFAs</a></li>
<li><a href="#sec-1-7">1.7. diagram of NFAs with specified states</a></li>
<li><a href="#sec-1-8">1.8. recognize union of languages</a></li>
<li><a href="#sec-1-9">1.9. recognize concatenation of languages</a></li>
<li><a href="#sec-1-10">1.10. recognize start of languages</a></li>
<li><a href="#sec-1-11">1.11. NFA convertion</a></li>
<li><a href="#sec-1-12">1.12. DFA with five states</a></li>
<li><a href="#sec-1-13">1.13. 1s separated by odd symbols</a></li>
<li><a href="#sec-1-14">1.14. judgement about closure of language under complement</a></li>
<li><a href="#sec-1-15">1.15. closure of RL under the star operation</a></li>
<li><a href="#sec-1-16">1.16. convert NFA to DFA</a>
<ul>
<li><a href="#sec-1-16-1">1.16.1. <span class="done DONE">DONE</span> write a program to convert NFA to DFA</a></li>
</ul>
</li>
<li><a href="#sec-1-17">1.17. NFA recognizing (01 U 001 U 010)<sup>*</sup></a></li>
<li><a href="#sec-1-18">1.18. Regular expression generating the languages</a></li>
<li><a href="#sec-1-19">1.19. conver regular expression to NFA</a></li>
<li><a href="#sec-1-20">1.20. give examples of regular expressions</a></li>
<li><a href="#sec-1-21">1.21. automata to regular expressions</a></li>
<li><a href="#sec-1-22">1.22. comment recognizer</a></li>
<li><a href="#sec-1-23">1.23. Prove that B = B+ iff BB belongs to B</a></li>
<li><a href="#sec-1-24">1.24. Finite State Transducer(FST)</a></li>
<li><a href="#sec-1-25">1.25. FST formal definition</a></li>
<li><a href="#sec-1-26">1.26. using FST to give definition</a></li>
<li><a href="#sec-1-27">1.27. using FST to make diagram of specific FST</a></li>
<li><a href="#sec-1-28">1.28. convert regular expression to NFA</a></li>
<li><a href="#sec-1-29">1.29. pumping lemma</a></li>
<li><a href="#sec-1-30">1.30. Finding error in proving</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> chapter 1</h2>
<div class="outline-text-2" id="text-1">
</div><div id="outline-container-sec-1-1" class="outline-3">
<h3 id="sec-1-1"><span class="section-number-3">1.1</span> M<sub>1</sub> and M<sub>2</sub></h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>q<sub>1</sub>
</li>
<li>M<sub>1</sub>: {q<sub>2</sub>}, M<sub>2</sub>: {q<sub>4</sub>}
</li>
<li>M<sub>1</sub>: q<sub>1</sub> -> q<sub>2</sub> -> q<sub>3</sub> -> q<sub>1</sub> -> q<sub>1</sub>, M<sub>2</sub>: q<sub>1</sub> -> q<sub>1</sub> -> q<sub>1</sub> -> q<sub>2</sub> -> q<sub>4</sub>
</li>
<li>M<sub>1</sub>: yes, M<sub>2</sub>: no
</li>
<li>M<sub>1</sub>: no, M<sub>2</sub>: yes
</li>
</ul>
</div>
</div>
<div id="outline-container-sec-1-2" class="outline-3">
<h3 id="sec-1-2"><span class="section-number-3">1.2</span> formal description</h3>
<div class="outline-text-3" id="text-1-2">
<ol class="org-ol">
<li>{Q={q<sub>1</sub>, q<sub>2</sub>, q<sub>3</sub>}, E={a, b}, q<sub>1</sub>, {q<sub>2</sub>}, transition}
<table>
<colgroup>
<col class="left">
<col class="left">
<col class="left">
</colgroup>
<tbody>
<tr>
<td class="left">state</td>
<td class="left">a</td>
<td class="left">b</td>
</tr>
<tr>
<td class="left">q<sub>1</sub></td>
<td class="left">q<sub>2</sub></td>
<td class="left">q<sub>1</sub></td>
</tr>
<tr>
<td class="left">q<sub>2</sub></td>
<td class="left">q<sub>3</sub></td>
<td class="left">q<sub>3</sub></td>
</tr>
<tr>
<td class="left">q<sub>3</sub></td>
<td class="left">q<sub>2</sub></td>
<td class="left">q<sub>1</sub></td>
</tr>
</tbody>
</table>
</li>
<li>{Q={q<sub>1</sub>, q<sub>2</sub>, q<sub>3</sub>, q<sub>4</sub>}, E={a, b}, q<sub>1</sub>, {q<sub>1</sub>, q<sub>4</sub>}, transition}
<table>
<colgroup>
<col class="left">
<col class="left">
<col class="left">
</colgroup>
<tbody>
<tr>
<td class="left">state</td>
<td class="left">a</td>
<td class="left">b</td>
</tr>
<tr>
<td class="left">q<sub>1</sub></td>
<td class="left">q<sub>1</sub></td>
<td class="left">q<sub>2</sub></td>
</tr>
<tr>
<td class="left">q<sub>2</sub></td>
<td class="left">q<sub>3</sub></td>
<td class="left">q<sub>4</sub></td>
</tr>
<tr>
<td class="left">q<sub>3</sub></td>
<td class="left">q<sub>2</sub></td>
<td class="left">q<sub>1</sub></td>
</tr>
<tr>
<td class="left">q<sub>4</sub></td>
<td class="left">q<sub>3</sub></td>
<td class="left">q<sub>4</sub></td>
</tr>
</tbody>
</table>
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-3" class="outline-3">
<h3 id="sec-1-3"><span class="section-number-3">1.3</span> diagram of DFA</h3>
<div class="outline-text-3" id="text-1-3">
<div class="figure">
<p><img src="chapter1/1.3.png" alt="1.3.png">
</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-4" class="outline-3">
<h3 id="sec-1-4"><span class="section-number-3">1.4</span> intersection of two languages</h3>
<div class="outline-text-3" id="text-1-4">
<ol class="org-ol">
<li></li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-5" class="outline-3">
<h3 id="sec-1-5"><span class="section-number-3">1.5</span> complement of language</h3>
<div class="outline-text-3" id="text-1-5">
<ol class="org-ol">
<li><img src="chapter1/1.5.1.png" alt="1.5.1.png">
</li>
<li><img src="chapter1/1.5.2.png" alt="1.5.2.png">
</li>
<li><img src="chapter1/1.5.3.png" alt="1.5.3.png">
</li>
<li><img src="chapter1/1.5.4.png" alt="1.5.4.png">
</li>
<li><img src="chapter1/1.5.5.png" alt="1.5.5.png">
</li>
<li><img src="chapter1/1.5.6.png" alt="1.5.6.png">
</li>
<li><img src="chapter1/1.5.7.png" alt="1.5.7.png">
</li>
<li><img src="chapter1/1.5.8.png" alt="1.5.8.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-6" class="outline-3">
<h3 id="sec-1-6"><span class="section-number-3">1.6</span> diagram of DFAs</h3>
<div class="outline-text-3" id="text-1-6">
<ol class="org-ol">
<li><img src="chapter1/1.6.1.png" alt="1.6.1.png">
</li>
<li><img src="chapter1/1.6.2.png" alt="1.6.2.png">
</li>
<li><img src="chapter1/1.6.3.png" alt="1.6.3.png">
</li>
<li><img src="chapter1/1.6.4.png" alt="1.6.4.png">
</li>
<li><img src="chapter1/1.6.5.png" alt="1.6.5.png">
</li>
<li><img src="chapter1/1.6.6.png" alt="1.6.6.png">
</li>
<li><img src="chapter1/1.6.7.png" alt="1.6.7.png">
</li>
<li><img src="chapter1/1.6.8.png" alt="1.6.8.png">
</li>
<li><img src="chapter1/1.6.9.png" alt="1.6.9.png">
</li>
<li><img src="chapter1/1.6.10.png" alt="1.6.10.png">
</li>
<li><img src="chapter1/1.6.11.png" alt="1.6.11.png">
</li>
<li><img src="chapter1/1.6.12.png" alt="1.6.12.png">
</li>
<li><img src="chapter1/1.6.13.png" alt="1.6.13.png">
</li>
<li><img src="chapter1/1.6.14.png" alt="1.6.14.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-7" class="outline-3">
<h3 id="sec-1-7"><span class="section-number-3">1.7</span> diagram of NFAs with specified states</h3>
<div class="outline-text-3" id="text-1-7">
<ol class="org-ol">
<li><img src="chapter1/1.7.1.png" alt="1.7.1.png">
</li>
<li><img src="chapter1/1.7.2.png" alt="1.7.2.png">
</li>
<li><img src="chapter1/1.7.3.png" alt="1.7.3.png">
</li>
<li><img src="chapter1/1.7.4.png" alt="1.7.4.png">
</li>
<li><img src="chapter1/1.7.5.png" alt="1.7.5.png">
</li>
<li><img src="chapter1/1.7.6.png" alt="1.7.6.png">
</li>
<li><img src="chapter1/1.7.7.png" alt="1.7.7.png">
</li>
<li><img src="chapter1/1.7.8.png" alt="1.7.8.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-8" class="outline-3">
<h3 id="sec-1-8"><span class="section-number-3">1.8</span> recognize union of languages</h3>
<div class="outline-text-3" id="text-1-8">
<ol class="org-ol">
<li><img src="chapter1/1.8.1.png" alt="1.8.1.png">
</li>
<li><img src="chapter1/1.8.2.png" alt="1.8.2.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-9" class="outline-3">
<h3 id="sec-1-9"><span class="section-number-3">1.9</span> recognize concatenation of languages</h3>
<div class="outline-text-3" id="text-1-9">
<ol class="org-ol">
<li><img src="chapter1/1.9.1.png" alt="1.9.1.png">
</li>
<li><img src="chapter1/1.9.2.png" alt="1.9.2.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-10" class="outline-3">
<h3 id="sec-1-10"><span class="section-number-3">1.10</span> recognize start of languages</h3>
<div class="outline-text-3" id="text-1-10">
<ol class="org-ol">
<li><img src="chapter1/1.10.1.png" alt="1.10.1.png">
</li>
<li><img src="chapter1/1.10.2.png" alt="1.10.2.png">
</li>
<li><img src="chapter1/1.10.3.png" alt="1.10.3.png">
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-11" class="outline-3">
<h3 id="sec-1-11"><span class="section-number-3">1.11</span> NFA convertion</h3>
<div class="outline-text-3" id="text-1-11">
<p>
Question: Prove that every NFA can be converted to an equivalent one
that has a single accept state
</p>
<p>
Answer: Asume the NFA is N = {Q, Σ, δ, q<sub>0</sub>, F}, F is the set of final states.
Thus, we can construct a new NFA N<sup>1</sup> = {Q, Σ, δ<sup>1</sup>, q<sub>0</sub>, F<sup>1</sup>}, the represent
is as follows:
</p>
<ol class="org-ol">
<li>F<sup>1</sup> = {q<sub>f</sub>}
</li>
<li>δ<sup>1</sup>(q, a) = δ(q, a), q belongs to Q and q not belong to F
</li>
<li>δ<sup>1</sup>(q, ε) = δ(q, ε) U {q<sub>f</sub>}, q belongs to F, q<sub>f</sub> belongs to F<sup>1</sup>
</li>
</ol>
<p>
Now, we can prove it in bidirection:
</p>
<p>
==> w is any string accepted by NFA N, so we can conclude that δ(w, a) belongs to
F. according the transition function above, w is accepted by NFA N<sup>1</sup>.
</p>
<p>
<== w is any string accepted by NFA N<sup>1</sup>, and w = wε,
according to formula δ<sup>1</sup>(q, ε) = q<sub>f</sub>, q = δ<sup>1</sup>(q<sub>0</sub>, w) = δ(q<sub>0</sub>, w)
belongs to F, so w is also accepted by NFA N.
</p>
</div>
</div>
<div id="outline-container-sec-1-12" class="outline-3">
<h3 id="sec-1-12"><span class="section-number-3">1.12</span> DFA with five states</h3>
<div class="outline-text-3" id="text-1-12">
<p>
It can be descripted by the following:
D = {odd b's followed by even a's}, now the answer is not correct, ignore it!
</p>
<p>
Answer has been fixed, now it's right.
</p>
<div class="figure">
<p><img src="chapter1/1.12.png" alt="1.12.png">
</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-13" class="outline-3">
<h3 id="sec-1-13"><span class="section-number-3">1.13</span> 1s separated by odd symbols</h3>
<div class="outline-text-3" id="text-1-13">
<p>
First, we should construct a NFA, then convert it to a DFA. this DFA has 7 states, besides, the last three final
states with all other states pointing at them and no one point out, so we can combine them into one final state.
</p>
<div class="figure">
<p><img src="chapter1/1.13.png" alt="1.13.png">
</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-14" class="outline-3">
<h3 id="sec-1-14"><span class="section-number-3">1.14</span> judgement about closure of language under complement</h3>
<div class="outline-text-3" id="text-1-14">
<ol class="org-ol">
<li>Show that if M is a DFA that recognizes language B, swapping the accept
and nonaccept states in M yields a new DFA recognizing the complement of
B. Conclude that the class of regular languages is closed under complemen
<p>
Answer: Assume any DFA M = {Q, Σ, δ, q<sub>0</sub>, F}, after swapping states, we get M<sub>c</sub> = {Q, Σ, δ, q<sub>0</sub>, F<sub>c</sub>},
F<sub>c</sub> = {q | q ∈ Q - F}. for any w ∈ Σ<sup>*</sup> and w ∉ F, it will falls in the states of Q - F = F<sub>c</sub>, thus,
we can conclude that M<sub>c</sub> accepts the complement of language LM.
</p>
<p>
According the conclusion above, any DFA and it's complement are DFAs, all the languages accepted by DFAs are regular
languages, so regular languages are closed under complement.
</p>
</li>
<li>Show by giving an example that if M is an NFA that recognizes language
C, swapping the accept and nonaccept states in M doesn鈥檛 necessarily yield
a new NFA that recognizes the complement of C. Is the class of languages
recognized by NFAs closed under complement? Explain your answer.
<div class="figure">
<p><img src="chapter1/1.14.png" alt="1.14.png">
</p>
</div>
<p>
Origin NFA: accepting language containing at least one 0;
</p>
<p>
NFA after swapping: accepting language containing (0+1)<sup>*</sup>
</p>
<p>
Is the class of languages recognized by NFAs closed under complement? Answer: Yes, any NFA is also a NFA after swapping states,
because every NFA has an equivalent DFA, so they are all regular languages, thus, languages are closed under complement.
</p>
</li>
</ol>
</div>
</div>
<div id="outline-container-sec-1-15" class="outline-3">
<h3 id="sec-1-15"><span class="section-number-3">1.15</span> closure of RL under the star operation</h3>
<div class="outline-text-3" id="text-1-15">
<div class="figure">
<p><img src="chapter1/1.15.png" alt="1.15.png">
</p>
</div>
<p>
The origin accepts the language L = {w | w has (2+3n) 0's and n ∈ N}. using the construction method proposed by 1.15, it will
accepts w = 000 ∉ L. So, it fails to prove the Theorem 1.49.
</p>
</div>
</div>
<div id="outline-container-sec-1-16" class="outline-3">
<h3 id="sec-1-16"><span class="section-number-3">1.16</span> convert NFA to DFA</h3>
<div class="outline-text-3" id="text-1-16">
<p>
a. <img src="chapter1/1.16.a.png" alt="1.16.a.png">
</p>
<p>
b. <img src="chapter1/1.16.b.png" alt="1.16.b.png">
</p>
</div>
<div id="outline-container-sec-1-16-1" class="outline-4">
<h4 id="sec-1-16-1"><span class="section-number-4">1.16.1</span> <span class="done DONE">DONE</span> write a program to convert NFA to DFA</h4>
<div class="outline-text-4" id="text-1-16-1">
</div>
</div>
</div>
<div id="outline-container-sec-1-17" class="outline-3">
<h3 id="sec-1-17"><span class="section-number-3">1.17</span> NFA recognizing (01 U 001 U 010)<sup>*</sup></h3>
<div class="outline-text-3" id="text-1-17">
<p>
a. <img src="chapter1/1.17.a.png" alt="1.17.a.png">
</p>
<p>
b. <img src="chapter1/1.17.b.png" alt="1.17.b.png">
</p>
</div>
</div>
<div id="outline-container-sec-1-18" class="outline-3">
<h3 id="sec-1-18"><span class="section-number-3">1.18</span> Regular expression generating the languages</h3>
<div class="outline-text-3" id="text-1-18">
<div class="org-src-container">
<pre class="src src-shell">1. ^1(0|1)*0$
2. 0*10*10*1[01]*
3. [01]*0101[01]*
4. [01]{2}1[01]*
5. 0([01]{2})*|1([01]{2})*[01]
6.
7. [01]{0, 5}
8.
9. (1[01])+
10. 000*|1000*|0100*|000*10*
11. 0?
12. (00)* | 0*10*10*
13. (?!.*)
14. [01]+
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-19" class="outline-3">
<h3 id="sec-1-19"><span class="section-number-3">1.19</span> conver regular expression to NFA</h3>
<div class="outline-text-3" id="text-1-19">
<p>
a. <img src="chapter1/1.19.a.png" alt="1.19.a.png">
</p>
<p>
b. <img src="chapter1/1.19.b.png" alt="1.19.b.png">
</p>
<p>
c. <img src="chapter1/1.19.c.png" alt="1.19.c.png">
</p>
</div>
</div>
<div id="outline-container-sec-1-20" class="outline-3">
<h3 id="sec-1-20"><span class="section-number-3">1.20</span> give examples of regular expressions</h3>
<div class="outline-text-3" id="text-1-20">
<div class="org-src-container">
<pre class="src src-python">a. a*b* | ab / aab | ba / bba
b. a(ab)*b | ab / aabb | a / b
c. a* U b* | a / b | ab / ba
d. (aaa)* | aaa / aaaaaa | b / ba
e. (a+b)*a(a+b)*b(a+b)*a(a+b)* | aba / abab | ab / ba
f. aba U bab | aba / bab | aab / b
g. (\epsilon U a )b | b / ab | aa / bb
h. (a U ab U bb)(a+b)* | a / ab | ba / bab
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-21" class="outline-3">
<h3 id="sec-1-21"><span class="section-number-3">1.21</span> automata to regular expressions</h3>
</div>
<div id="outline-container-sec-1-22" class="outline-3">
<h3 id="sec-1-22"><span class="section-number-3">1.22</span> comment recognizer</h3>
<div class="outline-text-3" id="text-1-22">
<p>
a. <img src="chapter1/1.22.png" alt="1.22.png">
</p>
<p>
b. regular expression:
</p>
<div class="org-src-container">
<pre class="src src-shell">/#(a+b+/+#(a+b))*#/
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-23" class="outline-3">
<h3 id="sec-1-23"><span class="section-number-3">1.23</span> Prove that B = B+ iff BB belongs to B</h3>
<div class="outline-text-3" id="text-1-23">
<p>
=> if B = B+, then language constructed by this grammar is L(B) = L(B + BB + BBB + …) = L(B) + L(BB) + …,
then BB belongs to B;
</p>
<p>
<= if BB belongs to B, then BBB belongs to BB, so BBB belongs to B. Thus by induction, (B)<sub>n</sub> belongs to B(n>=1).
so B = B+.
</p>
</div>
</div>
<div id="outline-container-sec-1-24" class="outline-3">
<h3 id="sec-1-24"><span class="section-number-3">1.24</span> Finite State Transducer(FST)</h3>
<div class="outline-text-3" id="text-1-24">
<div class="org-src-container">
<pre class="src src-shell">a. T1: 011 -> 000
b. T1: 211 -> 111
c. T1: 121 -> 011
d. T1: 0202 -> 0101
e. T2: b -> 1
f. T2: bbab -> 1111
g. T2: bbbbbb -> 110110
h. T2: e -> e
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-25" class="outline-3">
<h3 id="sec-1-25"><span class="section-number-3">1.25</span> FST formal definition</h3>
<div class="outline-text-3" id="text-1-25">
<p>
FST is a 5-tuple whitch is composed of {Q, Σ, δ, q<sub>0</sub>, Γ}
</p>
<div class="org-src-container">
<pre class="src src-shell">Q: the states set of FST
\Sigma: the inputs set of FST
\delta : Q X \Sigma -> Q X \Gamma
q_0: the start state of FST
\Gamma: the outputs set of FST
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-26" class="outline-3">
<h3 id="sec-1-26"><span class="section-number-3">1.26</span> using FST to give definition</h3>
<div class="outline-text-3" id="text-1-26">
<ol class="org-ol">
<li>T1 = {Q, Σ, δ, q<sub>0</sub>, Γ}
</li>
</ol>
<div class="org-src-container">
<pre class="src src-shell">Q: {q1, q2}
\Sigma: {0, 1, 2}
\Gamma: {0, 1}
\delta: Q X \Sigma -> Q X \Gamma
q0: q1
</pre>
</div>
<ol class="org-ol">
<li>T2 = {Q, Σ, δ, q<sub>0</sub>, Γ}
</li>
</ol>
<div class="org-src-container">
<pre class="src src-shell">Q: {q1, q2, q3}
\Sigma: {a, b}
\Gamma: {0, 1}
\delta: Q X \Sigma -> Q X \Gamma
q0: q1
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-27" class="outline-3">
<h3 id="sec-1-27"><span class="section-number-3">1.27</span> using FST to make diagram of specific FST</h3>
<div class="outline-text-3" id="text-1-27">
<div class="figure">
<p><img src="chapter1/1.27.png" alt="1.27.png">
</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-28" class="outline-3">
<h3 id="sec-1-28"><span class="section-number-3">1.28</span> convert regular expression to NFA</h3>
<div class="outline-text-3" id="text-1-28">
<p>
a. a(abb)<sup>*</sup>∪ b
</p>
<div class="figure">
<p><img src="chapter1/1.28.a.png" alt="1.28.a.png">
</p>
</div>
<p>
b. a<sup>+</sup> ∪ (ab)<sup>+</sup>
</p>
<div class="figure">
<p><img src="chapter1/1.28.b.png" alt="1.28.b.png">
</p>
</div>
<p>
c. (a∪ b<sup>+</sup>)a<sup>+</sup>b<sup>+</sup>
</p>
<div class="figure">
<p><img src="chapter1/1.28.c.png" alt="1.28.c.png">
</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-29" class="outline-3">
<h3 id="sec-1-29"><span class="section-number-3">1.29</span> pumping lemma</h3>
<div class="outline-text-3" id="text-1-29">
<p>
a. A<sub>1</sub> = {0<sup>n</sup>1<sup>n</sup>2<sup>n</sup> | n >= 0}
</p>
<p>
Assume w ∈ A<sub>1</sub> and A<sub>1</sub> is regular. Thus, w = xyz, |x| < n, |xy| <= n.
Now, according pumping lemma, xy<sup>k</sup>z ∈ A<sub>1</sub>(k >= 0). if we let k = 0,
then w = xz = 0<sup>m</sup>1<sup>n</sup>2<sup>n</sup> ∉ A<sub>1</sub>, so we can conclude that A<sub>1</sub>
is not regular.
</p>
<p>
b. A<sub>2</sub> = {www | w ∈ {a,b}<sup>*</sup>}
</p>
<p>
Assume w is a<sup>n</sup>, we can get that w<sup>'</sup> = a<sup>n</sup>a<sup>n</sup>a<sup>n</sup>. Now, w<sup>'</sup> is the same
as A<sub>1</sub> above, so, by contradiction, A<sub>2</sub> is not regular.
</p>
<p>
c. A<sub>3</sub> = {a<sup>2<sup>n</sup></sup> | n >= 0}
</p>
<p>
Assume n = 2m, w = a<sup>2<sup>2m</sup></sup> ∈ A<sub>3</sub>, now let n = m, then w = a<sup>2<sup>2n</sup></sup>.
According to pumping lemma, w = xyz, |x| < 2<sup>n</sup>, |xy| <= 2<sup>n</sup> and w = xy<sup>k</sup>z(k>=0) ∈ A<sub>3</sub>.
so let k = 0, w = xz = a<sup>2<sup>m</sup></sup>a<sup>2<sup>n</sup></sup> = a<sup>2<sup>m+n</sup></sup>(m<n) ∉ A<sub>3</sub>. Thus,
A<sub>3</sub> is not regular.
</p>
</div>
</div>
<div id="outline-container-sec-1-30" class="outline-3">
<h3 id="sec-1-30"><span class="section-number-3">1.30</span> Finding error in proving</h3>
<div class="outline-text-3" id="text-1-30">
<p>
Assume s = 0<sup>p</sup>1<sup>p</sup>, w = xy<sup>k</sup>z(y>=0) ∈ s, if y ≠ 1
</p>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: sylsaint</p>
<p class="date">Created: 2016-12-13 周二 23:18</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.1.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>