Вы находитесь на странице: 1из 32

.

:
2

051
. .

:
.
. .

2012 .


():
, ,
. :


.
,

( ),

Turbo Pascal.
:
-


:

30
2
1
2


4
.. 5
1. .
6
2.
()
8
3.
()
10
4.
.
12
5.

..
14
6.
.
16
. 17

1. 1 (
)
18
2.
29

..30


.
,
,
, . ,
,

,
, .


:
DE
E C
AD
BC

:
AB

()
(D E ) ( E C ) ( A D ) (B C ) = A B

1.
, .
/ .
/ .
,
, ..
.
, .
, .
, .
..


, :
1)

2)

,

()
.
, ,
( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B
1. D E 2. E C 3. A D 4. C B 5. B C 6. ( D E ) ( E C )
7. ( D E ) ( E C ) ( A D ) 8. ( D E ) ( E C ) ( A D ) ( B C )
9. ( D E ) ( E C ) ( A D ) ( B C ) ( C B )
10. ( D E ) ( E C ) ( A D ) ( B C ) ( C B ) A
11. ( D E ) ( E C ) ( A D ) ( B C ) ( C B ) B

1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5

A B C D E

1 2 3 4 5 6 7 8 9 1
0

1
1

1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
3
1
3
2

1.

()
Q
, :
- Q (, )
,
P1 P2 Pn Q
(.. )
P1, P2, , Pn
Q

:
[( D E ) ( E C ) ( A D ) ( B C )] A B
[( D E ) ( E C ) ( A D ) ( B C ) ( C B )] A B
[( D E ) ( E C ) ( A D ) ( B C ) ( C B )] A B
[( D E ) ( E C ) ( A D ) ( B C ) ( C B )] A B =
= ( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B =
= ( D E ) ( E C ) D ( B C ) C A B =
= ( D E ) ( E C ) D C A B = E E D C A B =


[( D E ) ( E C ) ( A D ) ( B C )] A B


( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B

( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B
( D E ), ( E C ), ( A D ),( B C ), ( C B ) A, B
D , ( E C ), ( A D ),( B C ), ( C B ) A, B
D , E , ( A D ),( B C ), ( C B ) A, B

( E ), ( E C ), ( A D ),( B C ), ( C B ) A, B
E , E , ( A D ),( B C ), ( C B ) A, B

D , C , ( A D ),( B C ), ( C B ) A, B
D , E , A ,( B C ), ( C B ) A, B

E , C , ( A D ),( B C ), ( C B ) A, B

E , ( A D ),( B C ), ( C B ) A, B , E

D , E , D ,( B C ), ( C B ) A, B

E , C , A ,( B C ), ( C B ) A, B

D , C , A ,( B C ), ( C B ) A, B

D , E , ( B C ), ( C B ) A, B , D

E , C , D ,( B C ), ( C B ) A, B

D , C , D ,( B C ), ( C B ) A, B

E , C , D , B , ( C B ) A, B
E , C , D , C , ( C B ) A, B

E , C , D , B , C A, B
D , C , ( B C ), ( C B ) A, B , D

E , C , D , B A, B , C

E , C , D , B , B A, B

E , C , D , C , C A, B

E , C , D , C , C A, B

E , C , D , C , B A, B

10

. , .

2.
()

() , :
Q (, )
,
P1 P2 Pn Q
. , Q ,
Q (.. Q ) , ,
, .
, ,
.

,
.
, ,
(A B) ( A C) (B C)
[(A B) ( A C)] (B C)
.. ().
[( D E ) ( E C ) ( A D ) ( B C )] ( A B ) =
= [( D E ) ( E C ) ( A D ) ( B C ) ( C B )] ( A B ) =
= [( D E ) ( E C ) ( A D ) ( B C ) ( C B )] ( A B ) =
= ( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B =
= ( D E )(E C ) D (B C ) C A B =
= E E D C A B =
, , .

11


:
[( D E ) ( E C ) ( A D ) ( B C )] ( A B )


( D E ) ( E C ) ( A D ) ( B C ) (C B ) A B

, ()
( D E ), ( E C ), ( A D ), ( B C ), ( C B ), A, B

- .

, , .

12

3.
( . 1)
(VH)
(V1) 1.
(Z1) 2. ,
, .3, .4.
(V2) 3. AB ( A B ) ( A B )
(Z2) 4. ,
, .5, .6.
(V3) 5. AB A B
(Z3) 6. ,
, , .7, .8.
(V4) 7. A B A B A B A B ..
(Z4) 8. ,
, .9, .10.
(V5) 9. A A .
(Z5) 10.
, , .11, .12.
(V6) 11. A ( B C ) ( A B ) ( A C ) .
(V7) 12. , .
(V8) 13. .
(Z6) 14.
, ,
, , .15, .16.
(V9) 15. .
(Z7) 16.
, ,
, , .17, .18.
(V10) 17.
.
().
(Z8) 18. , ,
.19, .20.
(Z9) 19. ,
, .20,
.21.
(V11) 20. . .
(V12) 21. i ,
, .14.
(Z10) 22. .
, . 23 . 21.
(V13) 23. . .
13

(V)

Vn

Z
5

V1

Z
1

V6

V2

V7

V8

Z
2

Z
6

V3

V9
Z
3

Z
7

V4

V10
Z
4

Z
8

V5
Z
9

V11

V12
Z
10

V13

Vk.
14

4.

( . 3)
(Vn)
(V1)1.
(Z1) 2. ,

, . 3, . 4.
(V2) 3. : A B = ( A B) ( A B )
(Z2) 4. ,
, . 5, . 6
(V3) 5. :
AB= AB

(Z3) 6. ,
, . 7, . 8
(V4) 7. : ( A B) = A B , ( A B) = A B
(Z4) 8. ,

, . V5, . V6
(V5) 9. :
( A B) C = ( A C ) ( B C ) , ( A B) C = ( A C ) B C )

(V6) 10.
.
(V7) 11. ()
n
(V8)12. ( ) ,
1
n, (s1),
(Z5) 13. (s1),
, , .Vk.
. V9
(V9) 14. (s2),

15

s1, (

s1)
(Z6) 15. (s2)
, V8. . Z7
(Z7) 16.
X ,
X , .V10. .V9.
(V10) 17.
(s3),
, ,
X X . s1
(s3).
(Z8) 18. ,

,
.Vk. . V11
(V11) 19.

.V9.
(V) .
1

Vn

V6

V1

Z
1

V7

V8

V2
Z
5

Z
2

V9

V3

Z
3
Z
V4
V5
4

Z
6

Z
7

16

V10

Z
8

V11
Vk.

1
5.



(
)
IA(k, s) = n*H (k, s)

(1)

H (k, s) = (

k
k
s
s
s
s
log
+ 1 log 1 + 0 + log 0 )
n
n
n
n
n
n

H (k, s) = (

k
k
s
s
log
+ 2 * log )
n
n
n
n

(2)
(3)

( - )
k
s1
s0
s (s = s1 = s0)
(1) IK(k, s) = n (

k
k
log ),
n
n

17

IS(k, s) = n (2 *

s
s
log ),
n
n

.
(1)
, ().

I ( k, s)

= I ( k, s)

(4)
I (k, s) I (k, s).

:
,
I (k, s)
.

18



,
(
)
(
).
() , -,
,
.
, ..
(
). ,
, , ,

.

.

,
.

19

1. (
).
uses crt;
Type mas=array [1..50,1..40] of string[2];
VAR stp:mas;
sx:array[1..40] of byte;
i,j,n:byte;
{**************************************************************}
{ }
Procedure Wwod;
var np,j,i,k,n1,n2:byte;
ss,s1:string; sc:char;
Procedure Obrab(c1,c2:char);
Procedure zamena;
var i:byte;
begin
i:=pos('[',s1);
while i<>0 do
begin
s1[i]:='(';
i:=pos('[',s1);
end;
i:=pos(']',s1);
while i<>0 do
begin
s1[i]:=')';
i:=pos(']',s1);
end;
i:=pos('-',s1);
while i<>0 do
begin
s1[i]:='^';
i:=pos('-',s1);
end;
end;
{**************************************************************}
{ }
Procedure DeMorgan(var s1:string);
var i,j,k:byte;
begin
i:=pos('^',s1); delete(s1,i,2);
k:=pos(')',s1); delete(s1,k,1);
while true do
begin
20

if s1[i]='^' then
begin
delete(s1,i,1);
inc(i);
dec(k)
end
else
begin
insert('-',s1,i);
inc(i,2);
inc(k)
end;
if i=k then break;
if s1[i]='+' then s1[i]:='*'
else s1[i]:='+';
inc(i);
end;
end;
{**************************************************************}
{ }
Procedure Disp;
var i,j,k:byte;
sp:string;
Function dis(s:string):string;
var x,l,i,j,p,n:byte;
s1,s2,sn:string[80];
begin
i:=pos('(',s); j:=pos(')',s); sn:='';
if (s[j+1]=c1)and(j<>length(s)) then
begin
x:=i;
s1:=copy(s,i+1,j-i-1);
l:=length(s); p:=l;
for n:=j+2 to l do
if s[n]=c2 then
begin
l:=n;
break
end;
if l=p then s2:=copy(s,j+1,l-j)
else s2:=copy(s,j+1,l-j-1);
if l=p then delete(s,i,l-i+1)
else delete(s,i,l-i);
repeat
i:=pos(c2,s1);
if i=0 then
begin
i:=length(s1);
insert(copy(s1,1,i)+s2+',',sn,1);
delete(sn,length(sn),1);
insert(sn,s,x);
21

delete(sn,1,80);
break;
end;
insert(copy(s1,1,i-1)+s2+',',sn,1);
delete(s1,1,i)
until false;
end
else
begin
s1:=copy(s,i+1,j-i-1);
l:=1;
for n:=i-2 downto 1 do
if s[n]=c2 then
begin
l:=n;
break
end;
if l=1 then
begin
s2:=copy(s,1,i-l);
x:=1;
end
else
begin
s2:=copy(s,l+1,i-l-1);
x:=l+1;
end;
if l=1 then delete(s,1,j)
else delete(s,l+1,j-l);
repeat
i:=pos(c2,s1);
if i=0 then
begin
i:=length(s1);
insert(s2+copy(s1,1,i)+',',sn,1);
delete(sn,length(sn),1);
insert(sn,s,x);
delete(sn,1,80);
break;
end;
insert(s2+copy(s1,1,i-1)+',',sn,1);
delete(s1,1,i);
until false;
end;
dis:=s;
end;
begin
repeat
i:=pos('(',s1);
j:=pos('^',s1);
k:=pos(')',s1);
22

if i=j+1 then
if ((s1[j-1]=c2)or(s1[j-1]=',')or(j=1))and
((s1[k+1]=c2)or(s1[k+1]=',')or(k=length(s1)))then
begin
DeMorgan(s1);
continue;
end;
if (i<>j+1)and(j<i)and(j<>0) then
begin
s1[j]:='-';
continue;
end;
if (i=j+1) then
begin
sp:=copy(s1,j,k-i+2);
delete(s1,j,1);
delete(s1,i,k-i-1);
DeMorgan(sp);
insert(sp,s1,i);
end;
if i>0 then s1:=dis(s1);
until pos('(',s1)=0;
end;
begin
if pos('(',s1)>0 then Disp;
zamena;
end;
{**************************************************************}
{ () s1}
Procedure inversia;
var i,j,k:byte;
s:string;
Procedure proverka;
var s:^string;
begin
i:=pos('[',s1); j:=pos(']',s1);
while i<>0 do
begin
s^:=copy(s1,i+1,j-1-i);
if (((i=1)or(s1[i-1]='+'))and(s1[i-1]<>'^'))
and((s1[j+1]='+')or(j=length(s1)))
then
begin
delete(s1,i,1);
delete(s1,j-1,1)
end
else
if (pos('+',s^)=0)and((((i=1)or
(s1[i-1]='*'))and(s1[i-1]<>'^'))
23

and((s1[j+1]='*')or(j=length(s1))))then
begin
delete(s1,i,1);
delete(s1,j-1,1)
end
else
begin
s1[j]:=')';
s1[i]:='(';
end;
i:=pos('[',s1); j:=pos(']',s1);
end;
end;
begin
i:=pos('(',s1); j:=0;
while i<>0 do
begin
if (i=1)or(s1[i-1]<>'^') then
begin
insert('^',s1,i);
inc(i)
end
else
begin
delete(s1,i-1,1);
dec(i)
end;
k:=pos(')',s1);
s1[i]:='['; s1[k]:=']';
i:=pos('(',s1);
end;
s:=s1;
repeat
i:=pos('[',s);
if (i=1)or(i=2) then
begin
k:=pos(']',s);
j:=j+k+1;
if j-1<length(s1) then
begin
if s1[j]='*' then s1[j]:='+'
else s1[j]:='*'
end;
delete(s,1,k+1);
end
else
begin
if s[1]='^' then
begin
delete(s1,j+1,1);
24

delete(s,1,3);
inc(j,2);
if j<length(s1) then
begin
if s1[j]='+' then s1[j]:='*'
else s1[j]:='+'
end;
end
else
begin
insert('^',s1,j+1);
inc(j,3);
if j<length(s1) then
begin
if s1[j]='+' then s1[j]:='*'
else s1[j]:='+'
end;
delete(s,1,2);
end
end
until length(s)=0;
proverka;
end;
{**************************************************************}
{ s1}
Procedure implik;
var i,j,k:byte;
begin
while pos('>',s1)<>0 do
begin
i:=pos('>',s1);
if s1[i-1]=')' then
begin
j:=pos(')',s1);
while j<>i-1 do
begin
k:=pos('(',s1);
s1[j]:=']'; s1[k]:='[';
j:=pos(']',s1);
end;
k:=pos('(',s1);
insert('^',s1,k);
s1[i+1]:='+';
end
else
begin
insert('^',s1,i-1);
s1[i+1]:='+';
end;
end;
25

end;
{**************************************************************}
{ s1}
Procedure inverX2;
var i:byte;
begin
while pos('^',s1)<>0 do
begin
i:=pos('^',s1);
if s1[i+1]='^' then delete(s1,i,2)
else s1[i]:='-';
end;
while pos('-',s1)>0 do
begin
i:=pos('-',s1);
s1[i]:='^';
end;
end;
{**************************************************************}
{ s1}
Procedure ekvivalentia;
var i,j,k:byte;
s2,s3:string[2];
ss:string[20];
begin
repeat
i:=pos('<',s1);
if (s1[i-2]='^')and(i-1<>1) then
begin
s2:=copy(s1,i-2,2);
j:=i-2
end
else
begin
s2:=copy(s1,i-1,1);
j:=i-1
end;
if (s1[i+2]='^')and(i+1<>length(s1)) then
begin
s3:=copy(s1,i+2,2);
k:=i+4-j
end
else
begin
k:=i+3-j;
s3:=copy(s1,i+2,1);
end;
delete(s1,j,k);
26

ss:='('+'^'+s2+'+'+s3+')'+'*'+'('+s2+'+'+'^'+s3+')';
insert(ss,s1,j);
until pos('<>',s1)=0;
end;
begin
clrscr;
write(' :');
readln(np);
writeln;
n:=0;
for i:=1 to np do
begin
write('',i,'- :');
readln(s1);
if pos('<>',s1)<>0 then ekvivalentia;
if pos('>',s1)<>0 then implik;
inverX2;
Obrab('+','*');
j:=pos('*',s1);
while j<>0 do
begin
s1[j]:=',';
j:=pos('*',s1);
end;
repeat
n1:=1;
inc(n);
k:=pos(',',s1);
if k=0 then k:=length(s1)+1;
ss:=copy(s1,1,k-1);
delete(s1,1,k);
repeat
n2:=pos('+',ss);
if n2=0 then n2:=length(ss)+1;
stp[n,n1]:=copy(ss,1,n2-1);
delete(ss,1,n2); inc(n1);
until length(ss)=0;
sx[n]:=n1-1;
until length(s1)=0;
end;
write(' :'); readln(s1);
if pos('<>',s1)<>0 then ekvivalentia;
if pos('>',s1)<>0 then implik;
Obrab('+','*');
inverX2;
inversia;
inverX2;
i:=pos('*',s1);
while i<>0 do
begin
s1[i]:=',';
27

i:=pos('*',s1);
end;
repeat
n1:=1;
inc(n);
k:=pos(',',s1);
if k=0 then k:=length(s1)+1;
ss:=copy(s1,1,k-1);
delete(s1,1,k);
repeat
n2:=pos('+',ss);
if n2=0 then n2:=length(ss)+1;
stp[n,n1]:=copy(ss,1,n2-1);
delete(ss,1,n2);
inc(n1);
until length(ss)=0;
sx[n]:=n1-1;
until length(s1)=0;
end;
{**************************************************************}
{
( )}
Procedure MetRezolut(var a:mas);
procedure cop(var sw:string;ss:string);
begin
sw:='';
while length(ss)<>0 do
begin
if ss[1]='^' then
begin
sw:=sw+copy(ss,1,2)+'+';
delete(ss,1,2)
end
else
begin
sw:=sw+copy(ss,1,1)+'+';
delete(ss,1,1)
end;
end;
delete(sw,length(sw),1);
end;
var b:boolean;
q,i,j,j1,h,k:byte;
x:string[2];
s:string;
f:text;
sj1,sj,si:set of byte;
sw1,sw2,sw3:string;
begin
clrscr;
28

assign(f,'rez.txt');
rewrite(f);
writeln(f,' ');
writeln(f,'***********************');
for i:=1 to n do
begin
s:='';
for j:=1 to sx[i] do s:=s+a[i,j]+'+';
delete(s,length(s),1);
writeln(f,s,' <- ',i,'- ');
end;
writeln(f,'***********************');
for q:=1 to n do
begin
s:='';
si:=[];
include(si,q);
for j:=1 to sx[q] do s:=s+a[q,j];
sw1:='';
cop(sw1,s);
writeln(f,sw1,' <- ');
repeat
b:=false;
for i:=1 to n do
begin
if not(i in si) then
begin
sj:=[];
sw1:='';
cop(sw1,s);
for j:=1 to sx[i] do
begin
x:=a[i,j];
h:=length(x);
if h=2 then
begin
delete(x,1,1);
dec(h)
end
else
begin
insert('^',x,1);
inc(h)
end;
k:=pos(x,s);
if (k>0)and(s[k-1]='^')and(a[i,j]=copy(s,k-1,2)) then
begin
k:=0;
sj:=sj+[j];
end
else if k>0 then
begin
29

sj1:=sj1+[j];
delete(s,k,h)
end;
end;
if sj1<>[] then
begin
for j:=1 to sx[i] do
if (not(j in sj1)) and (not(j in sj))
then s:=s+a[i,j];
b:=true;
include(si,i);
sj1:=[];
sw2:='';
for j:=1 to sx[i] do sw2:=sw2+a[i,j];
cop(sw2,sw2);
if length(s)<>0 then cop(sw3,s)
else sw3:='__';
writeln(f,sw3,' :',sw1,' ',sw2);
if length(s)=0 then
begin
writeln(f, , ');
writeln(f,'***********************');
close(f);
exit;
end;
break;
end;
end;
if b then break
end;
if (i=n)and(not(b)) then break;
until false;
writeln(f,'' ');
end;
writeln(f,' , .. ');
writeln(f,'***********************');
close(f);
end;
{**************************************************************}
BEGIN
for i:=1 to 50 do
for j:=1 to 40 do stp[i,j]:='0';
Wwod;
clrscr;
MetRezolut(stp);
writeln(' rez.txt');
END.

30

.
: 4
1- : D E
2- : E C
3- : A D
4- : B C
: A B
<< >>

31


1. .. . 2004 .
2.
..


( 22.01
). , 2003 .

32