Hello,...

im going over over course that was tought by Dr. David Tankus : "Logic and formal Language".

one of the things that distinct this lecturar (i don't know how to call him in the right form) is that any mathimatical question should be solved by c programming (wonder why ... ).

any why

one of the ways to check relations is using a binary matrix (the value can be 0 or 1).

The matrix is created when the lines are the domain and coulmuns are the range.

for example the relation :

A = {1,2,3,4}

B = {1,2,4,6}

R = A toward B

R = {(1,1) , (2,2),(3,4),(4,6)}

then the domain is : (1,2,3,4)

and range is (1,2,4,6).

so lets go to the issues :

Relation is Reflexive if aRa (each pair is in relation with it self) by defention it means that any object (i don't how to call this in english).

so all diagnel in the matrix should be ones

so:

i = lines.

J = coulmuns.

Code:

#define true 1
#define false 0
int check_for_reflexive(int **matrix)
{
for (i =0 ; i < lines;i++)
{
if (matrix[i][i] == 0)
{
return false;
}
}
return true;
}

Ireflexive:

a not R a: (object not in relation with it self)

the diagnnel should be all 0.

Code:

[CODE]
int check_for_Ireflexive(int **matrix)
{
for (i =0 ; i < lines;i++)
{
if (matrix[i][i] == 1) //see the deference ?
{
return false;
}
}
return true;
}
[/CODE]

Semtric:

aRb and bRa dlarrow semtric:

(1,2) in R and (2,1) in R

so:

Code:

[CODE]
int check_for_semtric(int **matrix)
{
for (i =0 ; i < lines;i++)
{
for (j =0;j <colmuns;j++)
{
if (matrix[i][j] == 1))
if (matirx[j][i] == 0)
return false;
}
}
return true;
}
[/CODE]

antisemtric:

aRb and bRa dlrarrow a = b.

so ...

Code:

int check_for_antisemtric(int **matrix)
{
for (i =0 ; i < lines;i++)
for (j =0;j <colmuns;j++)
{
if ((matrix[i][j] == 1)) && (matrix[j][i] ==1))
{
if (i != j)
return false;
}
}
return true;
}

Asemtirc:

if aRb then b not R a

Code:

int check_for_antisemtric(int **matrix)
{
for (i =0 ; i < lines;i++)
for (j =0;j <colmuns;j++)
{
if ((matrix[i][j] == 1)) && (matrix[j][i] ==1))
{
return false;
}
}
return true;
}

Transtive:

if aRb and bRc then aRc example : 1 <3<4 -> 1<4

Code:

int check_for_trastive(int **matrix)
{
for (i =0 ; i < lines;i++)
for (j =0;j <colmuns;j++)
for(k = 0;k < colmuns;k++)
{
if ((matrix[i][k] == 1)) && (matrix[k][j] ==1)) ** (matrix[i][j] == 0)
{
return false;
}
}
return true;
}