annotate automaton-in-agda/src/utm.agda @ 294:248711134141

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 29 Dec 2021 19:08:28 +0900
parents 3fa72793620b
children cd91a9f313dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module utm where
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import turing
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Product
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Bool
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.List
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Nat
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 data utmStates : Set where
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
10 reads : utmStates
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 read0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 read1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 read2 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 read3 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 read4 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 read5 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 read6 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 loc0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 loc1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 loc2 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 loc3 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 loc4 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 loc5 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 loc6 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 fetch0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 fetch1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 fetch2 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 fetch3 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 fetch4 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 fetch5 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 fetch6 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 fetch7 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 print0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 print1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 print2 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 print3 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 print4 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 print5 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 print6 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 print7 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 mov0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 mov1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 mov2 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 mov3 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 mov4 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 mov5 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 mov6 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 tidy0 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 tidy1 : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 halt : utmStates
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 data utmΣ : Set where
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 0 : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 1 : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 B : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 * : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 $ : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 ^ : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 X : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Y : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 Z : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 @ : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 b : utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 utmδ : utmStates → utmΣ → utmStates × (Write utmΣ) × Move
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
71 utmδ reads x = read0 , wnone , mnone
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 utmδ read0 * = read1 , write * , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 utmδ read0 x = read0 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 utmδ read1 x = read2 , write @ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 utmδ read2 ^ = read3 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 utmδ read2 x = read2 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 utmδ read3 0 = read4 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 utmδ read3 1 = read5 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 utmδ read3 b = read6 , write b , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 utmδ read4 @ = loc0 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 utmδ read4 x = read4 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 utmδ read5 @ = loc0 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 utmδ read5 x = read5 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 utmδ read6 @ = loc0 , write B , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 utmδ read6 x = read6 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 utmδ loc0 0 = loc0 , write X , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 utmδ loc0 1 = loc0 , write Y , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 utmδ loc0 B = loc0 , write Z , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 utmδ loc0 $ = loc1 , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 utmδ loc0 x = loc0 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 utmδ loc1 X = loc2 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 utmδ loc1 Y = loc3 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 utmδ loc1 Z = loc4 , write B , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 utmδ loc1 * = fetch0 , write * , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 utmδ loc1 x = loc1 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 utmδ loc2 0 = loc5 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 utmδ loc2 1 = loc6 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 utmδ loc2 B = loc6 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 utmδ loc2 x = loc2 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 utmδ loc3 1 = loc5 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 utmδ loc3 0 = loc6 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 utmδ loc3 B = loc6 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 utmδ loc3 x = loc3 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 utmδ loc4 B = loc5 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 utmδ loc4 0 = loc6 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 utmδ loc4 1 = loc6 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 utmδ loc4 x = loc4 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 utmδ loc5 $ = loc1 , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 utmδ loc5 x = loc5 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 utmδ loc6 $ = halt , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 utmδ loc6 * = loc0 , write * , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 utmδ loc6 x = loc6 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 utmδ fetch0 0 = fetch1 , write X , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 utmδ fetch0 1 = fetch2 , write Y , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 utmδ fetch0 B = fetch3 , write Z , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 utmδ fetch0 x = fetch0 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 utmδ fetch1 $ = fetch4 , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 utmδ fetch1 x = fetch1 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 utmδ fetch2 $ = fetch5 , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 utmδ fetch2 x = fetch2 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 utmδ fetch3 $ = fetch6 , write $ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 utmδ fetch3 x = fetch3 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 utmδ fetch4 0 = fetch7 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 utmδ fetch4 1 = fetch7 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 utmδ fetch4 B = fetch7 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 utmδ fetch4 * = print0 , write * , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 utmδ fetch4 x = fetch4 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 utmδ fetch5 0 = fetch7 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 utmδ fetch5 1 = fetch7 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 utmδ fetch5 B = fetch7 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 utmδ fetch5 * = print0 , write * , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 utmδ fetch5 x = fetch5 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 utmδ fetch6 0 = fetch7 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 utmδ fetch6 1 = fetch7 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 utmδ fetch6 B = fetch7 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 utmδ fetch6 * = print0 , write * , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 utmδ fetch6 x = fetch6 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 utmδ fetch7 * = fetch0 , write * , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 utmδ fetch7 x = fetch7 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 utmδ print0 X = print1 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 utmδ print0 Y = print2 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 utmδ print0 Z = print3 , write Z , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 utmδ print1 ^ = print4 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 utmδ print1 x = print1 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 utmδ print2 ^ = print5 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 utmδ print2 x = print2 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 utmδ print3 ^ = print6 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 utmδ print3 x = print3 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 utmδ print4 x = print7 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 utmδ print5 x = print7 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 utmδ print6 x = print7 , write B , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 utmδ print7 X = mov0 , write X , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 utmδ print7 Y = mov1 , write Y , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 utmδ print7 x = print7 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 utmδ mov0 ^ = mov2 , write ^ , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 utmδ mov0 x = mov0 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 utmδ mov1 ^ = mov3 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 utmδ mov1 x = mov1 , write x , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 utmδ mov2 0 = mov4 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 utmδ mov2 1 = mov5 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 utmδ mov2 B = mov6 , write ^ , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 utmδ mov3 0 = mov4 , write ^ , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 utmδ mov3 1 = mov5 , write ^ , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 utmδ mov3 B = mov6 , write ^ , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 utmδ mov4 ^ = tidy0 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 utmδ mov5 ^ = tidy0 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 utmδ mov6 ^ = tidy0 , write B , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 utmδ tidy0 $ = tidy1 , write $ , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 utmδ tidy0 x = tidy0 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 utmδ tidy1 X = tidy1 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 utmδ tidy1 Y = tidy1 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 utmδ tidy1 Z = tidy1 , write B , left
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 140
diff changeset
173 utmδ tidy1 $ = reads , write $ , right
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 utmδ tidy1 x = tidy1 , write x , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 utmδ _ x = halt , write x , mnone
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 U-TM : Turing utmStates utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 U-TM = record {
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 tδ = utmδ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 ; tstart = read0
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 ; tend = tend
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 ; tnone = b
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 } where
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 tend : utmStates → Bool
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 tend halt = true
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 tend _ = false
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 -- Copyδ : CopyStates → ℕ → CopyStates × ( Write ℕ ) × Move
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 -- Copyδ s1 0 = H , wnone , mnone
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 -- Copyδ s1 1 = s2 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 -- Copyδ s2 0 = s3 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 -- Copyδ s2 1 = s2 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 -- Copyδ s3 0 = s4 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 -- Copyδ s3 1 = s3 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 -- Copyδ s4 0 = s5 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 -- Copyδ s4 1 = s4 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 -- Copyδ s5 0 = s1 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 -- Copyδ s5 1 = s5 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 -- Copyδ H _ = H , wnone , mnone
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 -- Copyδ _ (suc (suc _)) = H , wnone , mnone
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 Copyδ-encode : List utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 Copyδ-encode =
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ -- s1 0 = H , wnone , mnone
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 * ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ -- s1 1 = s2 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 * ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ -- s2 0 = s3 , write 0 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 * ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ -- s2 1 = s2 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 * ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ -- s3 0 = s4 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 * ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ -- s3 1 = s3 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 * ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ -- s4 0 = s5 , write 0 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 * ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ -- s4 1 = s4 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 * ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ -- s5 0 = s1 , write 1 , right
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 * ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ -- s5 1 = s5 , write 1 , left
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 []
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 input-encode : List utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 input-encode = 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 input+Copyδ : List utmΣ
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 input+Copyδ = ( $ ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ * ∷ [] ) -- start state
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 ++ Copyδ-encode
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 ++ ( $ ∷ ^ ∷ input-encode )
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
225 short-input : List utmΣ
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
226 short-input = $ ∷ 0 ∷ 0 ∷ 0 ∷ * ∷
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
227 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ * ∷
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
228 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ * ∷
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
229 0 ∷ 1 ∷ B ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ * ∷
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
230 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ $ ∷
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
231 ^ ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
233 utm-test1 : List utmΣ → utmStates × ( List utmΣ ) × ( List utmΣ )
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
234 utm-test1 inp = Turing.taccept U-TM inp
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
235
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
236 {-# TERMINATING #-}
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
237 utm-test2 : ℕ → List utmΣ → utmStates × ( List utmΣ ) × ( List utmΣ )
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
238 utm-test2 n inp = loop n (Turing.tstart U-TM) inp []
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 where
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 loop : ℕ → utmStates → ( List utmΣ ) → ( List utmΣ ) → utmStates × ( List utmΣ ) × ( List utmΣ )
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 loop zero q L R = ( q , L , R )
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
242 loop (suc n) q L R with move {utmStates} {utmΣ} {0} {utmδ} q L R | q
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
243 ... | nq , nL , nR | reads = loop n nq nL nR
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
244 ... | nq , nL , nR | _ = loop (suc n) nq nL nR
139
3be1afb87f82 add utm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245
140
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
246 t1 = utm-test2 20 short-input
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
247
4c3fbfde1bc2 utm tester
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 139
diff changeset
248 t : (n : ℕ) → utmStates × ( List utmΣ ) × ( List utmΣ )
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 140
diff changeset
249 -- t n = utm-test2 n input+Copyδ
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 140
diff changeset
250 t n = utm-test2 n short-input