-
Notifications
You must be signed in to change notification settings - Fork 0
/
eqb.p
218 lines (207 loc) · 5.28 KB
/
eqb.p
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
program g (input,output);
var i,j,k,n : integer;
fout : boolean;
s : string;
f : array[1..3,0..9,1..25] of byte;
len : array[1..3,0..9] of integer;
tau : array[1..2,0..9] of byte;
ff : array[1..3,1..1000] of byte;
hib : array[1..3] of integer;
p : array[0..9] of integer;
dim : array[1..2] of integer;
rate : array[1..2] of real;
a : array[1..2,0..9,0..9] of integer;
procedure pp(m,ss,tt : integer);
var i,j : integer;
begin
hib[tt] := 0;
for i := 1 to hib[ss] do
for j := 1 to len[m,ff[ss,i]] do
if hib[tt] < 1000 then
begin
if m = 2 then
if ff[ss,i] > 0 then
if p[ff[ss,i]] = 0 then p[ff[ss,i]] := hib[tt];
hib[tt] := hib[tt]+1;
ff[tt,hib[tt]] := f[m,ff[ss,i],j];
end;
end;
function comprate(i:integer):real;
var j,k,m : integer;
t : real;
b : array[0..9,0..9] of real;
r : array[8..9] of real;
begin
b[0,0] := 1;
for j := 1 to dim[i]-1 do b[0,j] := 0;
for m := 1 to 9 do
for j := 0 to dim[i]-1 do
begin
b[m,j] := 0;
for k := 0 to dim[i]-1 do b[m,j] := b[m,j]+b[m-1,k]*a[i,k,j];
end;
for j := 8 to 9 do
begin
t := 0;
for k := 0 to dim[i]-1 do t := t+b[j,k];
r[j] := t;
end;
comprate := r[9]/r[8];
end;
procedure build(i:integer);
begin
hib[i] := 1;
ff[i,1] := 0;
pp(i,i,3);
pp(i,3,i);
pp(i,i,3);
pp(i,3,i);
pp(i,i,3);
pp(i,3,i);
pp(i,i,3);pp(i,3,i);
end;
procedure expand(i,q:integer);
var c : char;
j,k,m,mm : integer;
hib : array[0..9] of integer;
t : array[0..9,1..25] of byte;
begin
if i=1 then c := 'f' else c := 'g';
writeln('Replace ',c,' by ',c,'^',q,':');
for j := 0 to dim[i]-1 do
begin
write(c,'(',j,') = ');
hib[j] := 0;
for k := 1 to len[i,j] do
for m := 1 to len[i,f[i,j,k]] do
if q = 2 then
begin hib[j] := hib[j]+1; t[j,hib[j]] := f[i,f[i,j,k],m]; write(t[j,hib[j]]); end
else
for mm := 1 to len[i,f[i,f[i,j,k],m]] do
begin hib[j] := hib[j]+1; t[j,hib[j]] := f[i,f[i,f[i,j,k],m],mm]; write(t[j,hib[j]]); end;
writeln;
end;
for j := 0 to dim[i]-1 do
begin
len[i,j] := hib[j];
for k := 1 to len[i,j] do f[i,j,k] := t[j,k];
end;
if i = 2 then
begin
for j := 0 to 9 do p[j] := 0;
build(i);
end;
end;
procedure adjustrates;
var r: real;
begin
r := ln(rate[1])/ln(rate[2]);
if r > 0.49 then
if r < 0.51 then expand(1,2);
if r > 0.32 then
if r < 0.35 then expand(1,3);
if r > 1.98 then
if r < 2.02 then expand(2,2);
if r > 2.97 then
if r < 3.03 then expand(2,3);
if r > 1.48 then
if r < 1.52 then begin expand(2,3); expand(1,2); end;
if r > 0.66 then
if r < 0.68 then begin expand(2,2); expand(1,3); end;
end;
begin {start program}
for j := 0 to 9 do p[j] := 0;
for i := 1 to 2 do
begin
readln(n); {size signature Fi}
dim[i] := n;
for j := 0 to dim[i] do
for k := 0 to dim[i] do a[i,j,k] := 0;
for j := 0 to n-1 do
begin
if i= 1 then write('f(',j,') = ') else write ('g(',j,') = ');
readln(s);
len[i,j] := length(s);
for k := 1 to len[i,j] do
begin f[i,j,k] := ord(s[k]) - ord('0'); write(f[i,j,k]); a[i,j,f[i,j,k]] := a[i,j,f[i,j,k]]+1; end;
writeln;
end;
readln(s);
for j := 1 to n do
begin
tau[i,j-1] := ord(s[j]) - ord('0');
if i=1 then write('tau') else write('rho');
writeln('(',j-1,') = ',tau[i,j-1]);
end;
rate[i] := comprate(i);
build(i);
end;
adjustrates;
writeln('Claim to be proved: tau(f^infty(0)) = rho(g^infty(0)).');
{writeln(hib[1]);
writeln(hib[2]);}
fout := false;
for i := 1 to 1000 do
if i <= hib[1] then
if i <= hib[2] then
if tau[1,ff[1,i]] <> tau[2,ff[2,i]] then
if not fout then
begin
writeln('****** error on position ',i);
fout := true;
end;
{if not fout then writeln('First part checked to be equal');}
writeln('We will prove the following properties simultaneously by induction on n.');
for i := 0 to 9 do
if (i=0) or (p[i] > 0) then
begin
write('(',i,') tau(f^{n-1}(');
for j := 1 to len[2,i] do f[3,i,j] := ff[1,p[i]+j];
for j := 1 to len[2,i] do write(f[3,i,j]);
writeln(')) = rho(g^n(',i,'))');
len[3,i] := len[2,i];
end;
writeln('Then our claim follows from (0).');
{check basis:}
writeln('Basis n=1 of induction:');
for i := 0 to 9 do
if (i=0) or (p[i] > 0) then
begin
for j := 1 to len[2,i] do
if tau[1,f[3,i,j]] <> tau[2,f[2,i,j]] then begin fout := true; writeln('****** error in tau'); end;
write('tau(f^0(');
for j := 1 to len[2,i] do write(f[3,i,j]);
write(')) = ');
for j := 1 to len[2,i] do write(tau[1,f[3,i,j]]);
writeln(' = rho(g(',i,'))');
end;
if not fout then writeln('basis of induction proved');
{check induction step:}
for i := 0 to 9 do
if (i=0) or (p[i] > 0) then
begin
writeln('Induction step part (',i,'):');
write('tau(f^n(');
for j := 1 to len[2,i] do write(f[3,i,j]);
writeln(')) = ');
write('tau(f^{n-1}(');
for j := 1 to len[2,i] do
for k := 1 to len[1,f[3,i,j]] do write(f[1,f[3,i,j],k]);
writeln(')) = ');
write('rho(g^n(');
for j := 1 to len[2,i] do write(f[2,i,j]);
writeln(')) = rho(g^{n+1}(',i,'))');
hib[1] := 1;
ff[1,1] := i;
pp(3,1,2);
pp(1,2,3); {F(u_i) stored in 3}
hib[1] := 1;
ff[1,1] := i;
pp(2,1,2);
pp(3,2,1); {u(G(i)) stored in 1}
if hib[1] <> hib[3] then begin fout := true; writeln('****** error: wrong length in induction step at ',i); end;
if not fout then
for j := 1 to hib[1] do if ff[1,j] <> ff[3,j] then begin fout := true; writeln('****** error in induction step at ',i); end;
end;
if not fout then writeln('Induction step proved, hence claim proved');
end.