set-, . :
T = {x: x this is a rule} = {this, is, a, rule}
, x, . , , .
, . ,
U = {x: x = <y, z>, y this one list,
z AB}
, x :
- x 2-
- x1 this one list
- x1 AB
this one list 3 , AB , U 6 , :
U = {<this, A>, <this, B>, <one, A>, <one, B>, <list, A>, <list, B>}
. , . , U :
U = {<y, z>: y this one list, z AB}
, , , . :
{<x, y>: x , y = x Ñ /}
{<x, x Ñ />: x }
, . S S, power(S).
,
T = {this, is, a, rule}
power(T) = {U: U Í T} = {{}, {this}, {is},, {a, is, rule}, T}
0-, 1-, 2-, 3- 4-, 1+4+6+4+1=16 . , 16 =24 . . , 2x2x2x2=16. S n-, power(S) 2n.
Set- , . ,
{p: p -}
.
.
.
: S È T = {x: x Î S x Î T}
S T = {x: x Î S, x Ï T} []
S Ç T = {x: x Î S, x Î T}
|
|
.
S È T | S T | S Ç T |
, , , , .. S Í U T Í U,
S È T Í U
S T Í U
S Ç T Í U
S, :
S È {} = S È {} = S
S {} = S, {} - S = {}
S Ç {} = {} È S = {}
, ..
S È T = T È S
S Ç T = T È S
, ..
R È (S È T) = (R È T) È S
R Ç (S Ç T) = (R ÇT) È S
, .
.
.
S = {this, is, a, set}
T = {this, is, another, set}
S È T = T È S ={this, is, a, set, another}
S T = {a}
T S = {another}
S Ç T = {this, is, set}
(S T) È (S Ç T) = {this, is, a, set}
(S T) È (S È T) = {}
.
È | S È T = {x: x Î S x Î T} | , | |
Ç | S Ç T = {x: x Î S, x Î T} | , | |
- | S T = {x: x Î S, x Ï T} | , |
.
2- . .
, .. , 2-, , , . , 1- :
C = {<x, Ñx>: x - } = {<a, a>, <b, b>, }
, . , . , . s r ,
s È r, s r, s Ç r
.
, , , . r ,
<x, y> Î r <x, z> Î r, y = z.
. , C 1- .
|
|
. , , , , .
f,g , f Ç g, f g , f È g, . ,
H = {< Θ y, y>: y - } = {<a, a>, <a, aa>, }
C, . , C Í H:
C Ç H = C
,
H - = {< Θ y, y>: y 2 }
, ,
C H = {}
,
C È H = H
.
(domain), (range). , <x, y> Î r, x r, r.
<x, y> Î r y x, value-:
y=r(x)
, y r x , , y r x ( ).
r x, :
- x Ï domain(r), r x
- x Î domain(r), y, z, <x, y> Î r <x, z> Î r. r x
- x Î domain(r), <x, y> Î r. r x y=r(x).
, , .
:
{}, ,
domain({}) = {}, range({}) = {}
(identity function), I ,
x Î domain(r), I(x) = x.
, 1-, .
, . :
r = {<ball, bat>, <ball, game>, <game, ball>}
, - 2-
domain(r) = {ball, game}
range (r) = {ball, game, bat}
, r , ball.
, :
s = {<x, y>: x y
this is a relation that is not a function}
:
s = {<this, is>, <is, a>, <a, relation>, <relation, that>,
<that, is>, <is, not>, <not, a>, <a, function>}
:
f = {<x, y>: y
this is a relation that is also a function}
:
f = {<this, is>, <is, a>, <a, relation>,
<relation, that>, <that, is>, <also, a>}
.
. , . , .
|
|
: box-, .
- . . . -, - . , . - -.
. .
Box-.
- , -. :
P = PROGRAM PrintHello (INPUT, OUTPUT); BEGIN WRITELN(HELLO) END.
, I, .
, ,
P = PROGRAM PrintHello (INPUT, OUTPUT);
BEGIN
WRITELN(HELLO)
END.
P , P. P 2- ( ) , , ,
P = {<L, M>: L, P
M}
Box- , . PrintHello, :
P = {<L, M: L , M 1- <HELLO> } =
{<L, <HELLO>>: L }
box:
P = PROGRAM PrintHello (INPUT, OUTPUT); BEGIN WRITELN(HELLO) END
P - ,
PROGRAM PrintHello (INPUT, OUTPUT); BEGIN WRITELN(HELLO) END (L) = <HELLO>
L.
Box- - . . -. , R
PROGRAM PrintHelloInSteps (INPUT, OUTPUT);
BEGIN
WRITE(HE);
WRITE (L);
WRITELN(LO)
END.
P, R = P.
R CFPascal PrintHelloInSteps. PrintHelloInSteps R, PrintHelloInSteps R box-.