<<VilCretas`

RelacionComposicion[R1_,R2_]:=Module[{Composicion={},i,j},For[i=1,i<=Length[R2],For[j=1,j<=Length[R1],If[R2[[i,2]]==R1[[j,1]],Composicion=Append[Composicion,{R2[[i,1]],R1[[j,2]]}]];j++];
i++];DeleteDuplicates[Composicion]]

Ejercicio 1

A={14,18,35,41,47};
R1={{14,18},{14,41},{18,18},{35,14},{35,18},{35,35},{41,35},{47,14}};
R2={{14,18},{14,41},{14,47},{18,18},{18,35},{18,47},{41,18},{47,35}};
MR1 = MatrizRelBin[R1,A,A][[1]];
MR2 = MatrizRelBin[R2,A,A][[1]];
R = InterseccionBooleana[UnionBooleana[Transpose[MR1],MR2,lista->True], ComplementoBooleano[InterseccionBooleana[MR1,MR2,lista->True],lista->True],lista->True]//MatrixForm
R = R[[1]];
RelBinMatriz[R,A,A]

RA = Intersection[Union[Reverse/@R1,R2],Complement[PC[A,A],Intersection[R1,R2]]]

MatrizRelBin[RA,A,A]

(({{0, 0, 1, 0, 1}, {1, 0, 1, 0, 1}, {0, 0, 1, 1, 0}, {1, 1, 0, 0, 0}, {0, 0, 1, 0, 0}})) ==(({{0, 0, 1, 0, 1}, {1, 0, 1, 0, 1}, {0, 0, 1, 1, 0}, {1, 1, 0, 0, 0}, {0, 0, 1, 0, 0}}))

Ejercicio 2

Clear[A]
Clear[R1,R2,MR1,MR2,R,RA]

A = {100,8,55,34,81,1,39,87,53,16};
B= {13,62,21,66,44,88,93,95,80,16};
H = {22,64,5,18,95,72,52,44,98,10};
R1 = {{8,88},{100,80},{53,80},{100,44},{87,93},{53,16},{8,93},{87,13},{1,62},{100,93}};
R2 = {{16,22},{95,98},{88,10},{66,5},{80,72},{21,22},{88,44},{62,72},{80,22},{66,72}};
RelacionComposicion[R2,R1]
MR1 =MatrizRelBin[R1,A,B][[1]];
MR2 =MatrizRelBin[R2,B,H][[1]];
MR = RelBinMatriz[ProductoBooleano[MR1,MR2,lista->True],A,H]

L = {{1,72},{8,10},{8,44},{53,22},{53,72},{100,22},{100,72}};
S = {{8,10},{8,44},{100,72},{100,22},{53,72},{53,22},{1,72}};
V = {{100,22},{87,95},{1,72},{39,64},{53,22},{34,10}};

Table[i->ElementRelBinQ[L,i],{i, V}]
Table[i->ElementRelBinQ[S,i],{i,V}]

Ejercicio 3

A={56,5,52,35,72,21,36};
MR = (({{1, 0, 0, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0}}))
R = RelBinMatriz[MR,A,A]
ClasificacionRelBin[R,A]

Ejercicio 4

A ={2,7,9,10,11,12,14,17,18,20,23,25,26,27,29,36,39,41,43,48};
B ={3,4,6,7,11,16,20,23,25,26,27,29,31,36,40,41,47,48,49,50};
R = RelBin["Mod[a+b,2]!=0",A,B]
j = RelBin["OddQ[a+b]==True",A,B]
ElementRelBinQ[j,{23,36}]
Length[j]
ElementRelBinQ[R,{23,36}]
Length[R]

Ejercicio 5

R = {{25,44},{25,64},{25,95},{44,64},{95,64}}
Grafo[R,dirigido->True]

L = {{{25,44},{25,64},{25,95},{44,64},{95,64}},{{25,44},{25,64},{25,25},{44,64},{95,64}},{{44,25},{25,64},{25,95},{44,64},{95,64}},{{25,44},{25,64},{25,95},{44,64},{64,95}},{{25,44},{25,64},{95,25},{44,64},{95,64}}}

Table[R == i,{i,L}]

R == L[[1]]
R == {{25,44},{25,64},{25,95},{44,64},{95,64}}

Ejercicio 6

A = Range[-5,1000,5];
B = Range[5,1000,5];
Length[PC[A,B]]

Ejercicio 7

A = Range[1,100,3];
R = RelBin["a>b&&Mod[a-b,20]==0",A,A]
Dom = DominioRelBin[R]
Length[Dom]