A Problem in Logic (42)

1 Name: #!/usr/bin/anonymous : 2008-05-04 03:29 ID:MuJs/AX1

I need some help with a simple problem involving the basic logical operators: AND, OR, and NOT, along with the relational operator EQUAL TO, and truth values TRUE and FALSE.

Let's assume that we have a function tD() that tests whether 3 integers are all different. So, tD( 1, 2, 2 ) will return FALSE, and tD( 6, 6, 6 ) will return TRUE.

Now, my problem is to define a function the uses the above to determine whether or not 4 integers are equal. Let's call it

bool fE( a, b, c, d )

defined completely in terms of

bool tD( a, b, c) 

and the aforementioned operators.

you can write in any code you prefer.

2 Name: #!/usr/bin/anonymous : 2008-05-04 07:52 ID:G2d+PFYw

please explain tD again.

3 Name: #!/usr/bin/anonymous : 2008-05-04 13:29 ID:Heaven

>>2
tD() returns TRUE if the 3 integers are equal and FALSE if they are unequal.

bool fE(a, b, c, d) =
tD(a, b, c) == tD(a, b, d) == TRUE

4 Name: #!/usr/bin/anonymous : 2008-05-04 13:37 ID:Heaven

>>2
sorry about that, td( 6, 6, 6 ) would return FALSE, not TRUE.
td() tests whether three integers are all different.

td( 1, 2, 1 ) returns FALSE
td( 2, 3, 5 ) returns TRUE

5 Name: #!/usr/bin/anonymous : 2008-05-04 13:41 ID:Heaven

>>3
no, td returns TRUE if 3 integers are all different
and FALSE if any of them are equal.
again, my fault for the confusion.

6 Name: #!/usr/bin/anonymous : 2008-05-04 14:14 ID:Heaven

>>5
Ok then, now it makes more sense

tD(a, b, c) =
!(((a & b & c) | b | c) == a)
fE(a, b, c, d) =
tD(a, b, c) == tD(a, b, c) == TRUE

fE returns FALSE if they are all equal and TRUE if they are unequal.

7 Name: #!/usr/bin/anonymous : 2008-05-04 14:44 ID:Heaven

>>6
no, fE() should return TRUE if they are all equal and FALSE if they are unequal.

fE() and tD() test for opposite things, and on a different number of arguments.

fE() - fourEqual() - are these fourEqual()?
tD() - threeDifferent() - are these threeDifferent()?

The point is that one takes an even number of integers and tests for equality, and the other takes an odd number of integers and tests for distinction.

8 Name: #!/usr/bin/anonymous : 2008-05-04 15:07 ID:Heaven

>>7
Then change the == TRUE to == FALSE you god damn retard.

9 Name: #!/usr/bin/anonymous : 2008-05-04 15:40 ID:MuJs/AX1

>>8
and exactly where does the variable d come into play?

10 Name: #!/usr/bin/anonymous : 2008-05-04 15:53 ID:MuJs/AX1

>>8
also, let me tell you right now that if you're referring to >>6
thinking that the absolute gibberish

tD(a,b,c) == tD(a,b,c) == TRUE 

(which ill assume you meant what was posted in >>3)

tD(a,b,c) == tD(a,b,d) == False //you're correction

is anywhere close to being right
you are the fucking retard my dear friend.

fE(1, 2, 1, 2)
tD( 1, 2, 1) == tD(1, 2, 2) == false
false == false == false
true

not gonna cut it faggot

or the other way

fE(1, 1, 1, 1)
tD(1, 1, 1) == tD(1, 1, 1) == true
false == false == true
false

not gonna cut it nigger

11 Name: #!/usr/bin/anonymous : 2008-05-04 16:19 ID:Heaven

>>1

Do your own homework, dude.

12 Name: #!/usr/bin/anonymous : 2008-05-04 16:45 ID:MuJs/AX1

>>11
this isn't homework. this is a simple problem i made up for this board, that apparently no one here is capable of solving.

13 Name: #!/usr/bin/anonymous : 2008-05-04 17:05 ID:BJTy114F

>>12
Oh hai

thrD(a,b,c) := not(a=b=c)
frE( a, b, c, d ) := not( thrD( a, b, c) or thrD(b,c,d) )

14 Name: #!/usr/bin/anonymous : 2008-05-04 17:56 ID:MuJs/AX1

>>13
well, let's see...

frE( 1, 2, 1, 1 ) =>
not( thrD( 1, 2, 1) or thrD( 2, 1, 1) ) =>
not( FALSE or FALSE ) =>
not( FALSE ) =>
TRUE

close, but no cigar. and this is assuming thrD() actually does what it's suppose to, namely determine if all three arguments are different. your code for thrD() does not do this.

thrD( 1, 2, 1 ) =>
not( 1 == 2 == 1 )
not( FALSE )
TRUE

15 Name: #!/usr/bin/anonymous : 2008-05-04 18:46 ID:Heaven

>>10,14
HOLY SHIT You're a fucking retard.
I used only the binary operators AND, OR and the equality operator.

(((a & b & c) | b | c) == a) tests whether b and c equal a.
Let's call that expression A.
!A means they are unequal

tD(a, b, c) <- !A(a, b, c)
So far, good.

!A(a, b, c) == !A(a, b, d) means all four not the same number if true, else the same number.

tD(a, b, c) == tD(a, b, d) means the same

fE(a, b, c, d) <- !(tD(a, b, c) == tD(a, b, d))

There. I did it assuming it's possible to use only once the equal operator in every definition, and that you meant binary operators AND, OR.

Now, to your actual retarded problem

tD(a, b, c) <- !(a == b == c)
fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, d)

OK? Got it? Now, that's all based to your first post, because of your mistake.

On to your second post:

tD(a, b, c) <- !(a == b || a == c || b == c)
fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, c)

I love your attitude, you make mistakes, then you blame us for them, then you call us uncapable of solving such "problem".
Fuck.

16 Name: #!/usr/bin/anonymous : 2008-05-04 19:19 ID:MuJs/AX1

>>15
First of all, I acknowledged my mistake as well as the confusion it would bring, early on.
Second, my attitude was only brought about because you called me "fucking retarded".
Third, your answer is still wrong.

I suppose I failed miserably to explain this problem, but I'm going to try once more.

We are given a function called threeDifferent(). It does not need to be defined, it is given to us. What this function does is take three integer arguments and determine whether or not they are all different. If they are all different it returns true. If any of them are the same, it returns false. Here are some examples:

threeDifferent( 1, 2, 3 ) *returns* TRUE
threeDifferent( 1, 2, 1 ) *returns* FALSE

In the first case, all three integers are different. In the next case, the first and the last are the same, so no.

Now what I want is a function called fourEqual() defined using threeDifferent(). What fourEqual() does is determine if four integers are all equal. Here are some examples:

fourEqual( 1, 1, 1, 1) *returns* TRUE
fourEqual( 1, 2, 1, 1) *returns* FALSE

In the first case, each argument is 1, so they are in fact all equal. In the second case, 2 is different, so they are not equal.

Now, lets look at your code:

fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, d)

In particular, the case of (1, 2, 1, 1)

fE(1, 2, 1, 1) <- !tD(1, 2, 1) && !tD(1, 2, 1)

Obviously (1, 2, 1, 1) are not all equal, so fE(1, 2, 1, 1) should return FALSE.
And (1, 2, 1) are not all different, so tD(1, 2, 1) should return FALSE. Why? Because they are not all different.
So, the result of evaluating !tD(1, 2, 1) is TRUE.
So, the expression

!tD(1, 2, 1) && !td(1, 2, 1) 

becomes

!(FALSE) && !(FALSE)
TRUE && TRUE
TRUE

Therefore, your function fE(1, 2, 1, 1) will return TRUE. But is it true that they are all equal? NO.

17 Name: #!/usr/bin/anonymous : 2008-05-04 23:59 ID:Heaven

>>16

> Therefore, your function fE(1, 2, 1, 1) will return TRUE. But is it true that they are all equal? NO.

It would not, with my definition (or at least what I understood from your definition).
But fine, with your definition of tD(), yes, it wouldn't be correct.

I have another question, do you consider TRUE and FALSE as integers? (1 and 0). It would make things easier in solving this

18 Name: #!/usr/bin/anonymous : 2008-05-05 00:10 ID:Heaven

>>17
Your definition doesn't really make sense to me:

(((a & b & c) | b | c) == a)

Since a, b, and c are integers, and | is a logical operator,

(((a & b & c) | b | c) 

will always evaluate to TRUE unless a, b, and c are all 0.

here is what tD() would look like in C:

bool tD( int a, int b, int c )
{
return !( (a == b) || (b == c) || (a == c) )
}

19 Name: #!/usr/bin/anonymous : 2008-05-05 00:21 ID:BJTy114F

>>14
Oh, I though tD returned true when all three are not the same. After reading >>16, I don't think there is an actual solution to this unless you know beforehand that a,b,c,d are all not a specific value. If you know that, then you can do

frE(a,b,c,d) = not( thrD(a,b,k) or thrD(a,c,k) or ...[rest of the pairs])

Otherwise, I don't see any solution.

20 Name: #!/usr/bin/anonymous : 2008-05-05 00:24 ID:Heaven

>>18
My definition used the binary operators | and & and not the logical && and ||. (my mistake)
Also, my definition of tD() checks if just two are unequal.

>>19
I see a solution, if true and false are numbers 1 and 0.

21 Name: #!/usr/bin/anonymous : 2008-05-05 00:30 ID:BJTy114F

>>20
Care to show it then?

22 Name: #!/usr/bin/anonymous : 2008-05-05 00:40 ID:Heaven

>>12

So why are you making up utterly pointless homework problems? Just get a job in academia already if that's what you want to do.

Also, your problem is unsolvable as stated.

tD(a,a,a)==tD(a,a,b)==tD(a,b,a)==tD(b,a,a)==FALSE

However, fE(a,a,a,a) != fE(a,a,a,b), but as fE can only be defined in terms of the above expressions, which all have the same value, fE(a,a,a,a) will be equal to fE(a,a,a,b) no matter how it is defined.

23 Name: #!/usr/bin/anonymous : 2008-05-06 04:39 ID:Heaven

>>1

bool fE(a, b, c, d){
return tD(0, 1, 2) && a == b && b == c && c == d;
}

24 Name: #!/usr/bin/anonymous : 2008-05-06 05:14 ID:Heaven

>>23
YOU JUST WON THE GAME!

25 Name: #!/usr/bin/anonymous : 2008-05-06 22:59 ID:Heaven

>>22
take a chill pill dude.
GREAT GOING KID!

26 Name: #!/usr/bin/anonymous : 2009-06-15 16:00 ID:1O5xs7G4

lol the hilarious memories

27 Name: #!/usr/bin/anonymous : 2009-07-09 10:44 ID:U6iGdPRO

(NOT dif(a,a,b) )AND (NOT dif(b,b,c)) AND (NOT dif( c,c,d))
Am I doing it wrong?

28 Name: #!/usr/bin/anonymous : 2009-07-09 10:47 ID:U6iGdPRO

Ye you are.

29 Name: #!/usr/bin/anonymous : 2009-07-10 13:26 ID:8E70gVsm

>>27
Already been proven to not have a solution. What more can you want to see that, yes, you are doing it wrong.

30 Name: #!/usr/bin/anonymous : 2009-10-28 14:46 ID:uhec6hUr

I think I learned about this in my english class

Man is mortal, Socrates is man, theirfore Socrates is mortal.

I'm not a real programer but I think this makes some sence

31 Name: #!/usr/bin/anonymous : 2009-10-28 15:41 ID:Heaven

>>30 wants us to post a joke about his english typos, that's why he mentioned he goes to an english class. just silly.

32 Name: simpleton : 2009-10-28 17:24 ID:uhec6hUr

But does it make sense?

If you want to know if all are true you just need to compare one value against every other.

The other ways just tell you how true the statement is which isn't necessary in this case.

P.S. Only a troll would point out something as stupid as spelling typos.

33 Name: #!/usr/bin/anonymous : 2009-10-28 18:03 ID:Heaven

>>32

> P.S. Only a troll would point out something as stupid as spelling typos.

By the same logic, only a troll would revive an old (and dead, since the original question has been answered and there haven't been spawned any new discussions) thread with a post like >>30.

34 Name: simpleton : 2009-10-29 14:58 ID:uhec6hUr

Acknowledged.

I sincerely apologize for my inappropriate conduct and hope you can forgive me.

I'm a bit new at this.

35 Name: #!/usr/bin/anonymous : 2009-10-29 19:26 ID:Heaven

I can't forgive you but you won't be punished this time.

36 Name: #!/usr/bin/anonymous : 2009-11-30 22:31 ID:6QLkxa0c

tD( a, b, c) AND tD( b, c, d)

37 Name: #!/usr/bin/anonymous : 2009-12-02 03:17 ID:Heaven

This tread needs to die.

38 Name: #!/usr/bin/anonymous : 2009-12-21 16:09 ID:Heaven

indeed

39 Name: #!/usr/bin/anonymous : 2010-01-08 02:39 ID:++N2AMPW

do we have TeX on this board?

40 Name: #!/usr/bin/anonymous : 2010-01-22 20:42 ID:Heaven

int td (int a, int b, int c)
{

if (a == b && a == c)
return 1;
else
return 0;

}

What exactly was the problem here?

41 Name: #!/usr/bin/anonymous : 2010-01-23 12:00 ID:epdqu1GD

haha.
Thats what I would have done. if A = B = C then

42 Name: #!/usr/bin/anonymous : 2010-11-16 03:48 ID:/c0w81Dm

oh hai, this thread @___@ ~___~ ^__^

This thread has been closed. You cannot post in this thread any longer.