File tree Expand file tree Collapse file tree
Cslib/Computability/Machines/MultiTapeTuring Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ Authors: Christian Reitwiessner
66
77module
88
9- import Cslib.Foundations.Data.BiTape
10- import Cslib.Foundations.Data.RelatesInSteps
11-
129public import Cslib.Computability.Machines.MultiTapeTuring.Basic
1310public import Cslib.Computability.Machines.MultiTapeTuring.ListEncoding
1411public import Cslib.Computability.Machines.MultiTapeTuring.HeadStats
@@ -41,31 +38,56 @@ uses "goto", and every variable is a stack:
4138def reachable(a, b, t, r):
4239 terminate = 0
4340 result = 0
44- section = [ 0 ]
41+ initial_t = t
42+ section = [:terminate, :fun_start]
4543 while !terminate:
4644 match section.pop()
47- | 0 =>
45+ | :fun_start =>
4846 if t = 0:
4947 result = r(a, b)
50- terminate = 1
51- section.push(7)
48+ section.push(:fun_return)
5249 else:
53- section.push(1)
54- | 1 =>
55- c.push(0)
56- section.push(2)
57- | 2 =>
50+ c.push(0)
51+ section.push(:loop_start)
52+ | :loop_start =>
5853 if c.top() = num_vertices:
59- section.push(6)
54+ c.pop()
55+ result = 0
56+ section.push(:fun_return)
6057 else:
6158 a.push(a.top())
6259 b.push(c.top())
63- section.push(0)
6460 t.push(t.top() - 1)
65- section.push(3)
66- | 3 =>
67- section.push(4)
68-
61+ section.push(:after_first_rec)
62+ section.push(:fun_start)
63+ | :after_first_rec =>
64+ if result == 1:
65+ a.push(c.top())
66+ b.push(b.top())
67+ t.push(t.top() - 1)
68+ section.push(:after_second_rec)
69+ section.push(0)
70+ else:
71+ result = 0
72+ section.push(:loop_continue)
73+ | :after_second_rec =>
74+ if result == 1:
75+ c.pop()
76+ section.push(:fun_return)
77+ else:
78+ section.push(:loop_continue)
79+ | :loop_continue =>
80+ c.push(c.top() + 1)
81+ section.push(:loop_start)
82+ | :fun_return =>
83+ a.pop()
84+ b.pop()
85+ t.pop()
86+ | :terminate =>
87+ terminate = 1
88+ -- cleanup
89+ terminate.pop()
90+ initial_t.pop()
6991
7092
7193-/
You can’t perform that action at this time.
0 commit comments