Support the Arctic Sea Ice Forum and Blog

Author Topic: Russian Logic  (Read 8216 times)

Stephen

  • Frazil ice
  • Posts: 150
    • View Profile
  • Liked: 30
  • Likes Given: 0
Russian Logic
« on: April 17, 2014, 06:07:16 AM »
Does !A = !A ?

Let's suppose that A is my dog, Rosie, she's a little Jack Russel terrier
So A = (Jack Russel terrier)
!A = !(Jack Russel terrier)
So !A = (bottle of beer)
and !A = (bicycle)

Does (bottle of beer) = (bicycle) ?
No
So !A <> !A
The ice was here, the ice was there,   
The ice was all around:
It crack'd and growl'd, and roar'd and howl'd,   
Like noises in a swound!
  Rime of the Ancient Mariner by Samuel Taylor Coleridge

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #1 on: April 17, 2014, 09:37:54 AM »
Congratulations, you've just failed at your programming job.

A is a Jack Russel
!A is anything that isn't a Jack Russel
B is Bottle of Beer

I think we all agree that a bottle of beer is something that isn't a Jack Russel.

We can write that as B = !A which is logically the same as B <> A

So now we ask is something that isn't a Jack Russel equivilent of something else that isn't a Jack Russel. At this point you are NOT comparing the thing itself, but just the fact that it ISN'T a Jack Russel.

So honestly !A = !A

If you'd like a bit of Perl code to help prove the point:

#!/usr/bin/perl
use strict;

my $A = "Jack Russel";

if ( !$A eq !$A ){
   print "True\n";
}else{
   print "False\n";
}

Jim Hunt

  • First-year ice
  • Posts: 5198
  • Stay Home, Save Lives
    • View Profile
    • The Arctic sea ice Great White Con
  • Liked: 625
  • Likes Given: 56
Re: Russian Logic
« Reply #2 on: April 17, 2014, 10:04:46 AM »
If you'd like a bit of Perl code to help prove the point:

How would you express that idea in brainfuck, the most famous of all the esoteric programming languages?

http://esolangs.org/wiki/Brainfuck
Reality is merely an illusion, albeit a very persistent one - Albert Einstein

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #3 on: April 17, 2014, 10:18:51 AM »
Jim,

Ah, good old BF. The most reductionist Turing complete language there is. And a classic example of a write once language. If you thought regular expressions looked like line noise, BF looks like someone held down the shift key and just ran along the top of the keyboard until they get bored.

I've got a Perl to BF converter somewhere (come to think of it, I wrote a BF compiler a long time ago too).

As for the logic - it doesn't matter what language it's done in. It will always be the same.

The confusion comes when people try and convert the logic into English. You need to be very careful to retain what is actually being written over what you THINK is being written.

F.Tnioli

  • Grease ice
  • Posts: 772
    • View Profile
  • Liked: 147
  • Likes Given: 38
Re: Russian Logic
« Reply #4 on: April 17, 2014, 10:19:15 AM »
Does !A = !A ?

Let's suppose that A is my dog, Rosie, she's a little Jack Russel terrier
So A = (Jack Russel terrier)
!A = !(Jack Russel terrier)
So !A = (bottle of beer)
and !A = (bicycle)

Does (bottle of beer) = (bicycle) ?
No
So !A <> !A

Geez, guys, we got a topic for this! Wow. ^^

To the matter! :)

!A = !A usually, like i said. It does not require any proof. The only case when !A <> !A - is when we _postulate_ that A <> A. Ok?

However, the proof you give, - is incorrect. I'll put every line of your proof and then i'll show how and why there is an error there.

So A = (Jack Russel terrier) // this is OK
!A = !(Jack Russel terrier) // this is OK
So !A = (bottle of beer) // this is an error, because !A = !(Jack Russel terrier) (from the previous line). Translating the previous line into normal english, it states: "an entity known as "!A" - is something which is not Jack Russel terrier". What is this "something"? Quite simply, it is EVERYTHING ELSE than Jack Russel terrier. I.e., whole darn universe, everything existing, including this post, including you and me and 7+ billions of people, and all other dog varieties except Jack Russel terrier, too. And yet, with this line, you equate this all - including you and me - to a bottle of beer??? NO WAI!!! :D
and !A = (bicycle) // this is the same error as the previous line. Also, consider this: if we take this and previous line, and put them together, then we will have: !A = (bottle of beer) = (bicycle), from which we can extract this: (bottle of beer) = (bicycle). Which is obviously incorrect. Ergo, the equations which have led to this - are also incorrect. Namely, both this and previous line of your proof - are ones which are incorrect. This is yet one more - second, - method to easily demonstrate your error.
Does (bottle of beer) = (bicycle) ? No // this is OK
So !A <> !A // this is incorrect, since, as i've shown just above, !A > (beer) and !A > (bicycle). Again, the only way to make the statement "!A <> !A:" to be correct - is to postulate: "A <> A". There is NO other way to make it work. :D


Sorry! :D


To everyone: before posting in a melting season topic, please be sure to know contents of this moderator's post: https://forum.arctic-sea-ice.net/index.php/topic,3017.msg261893.html#msg261893 . Thanks!

plg

  • New ice
  • Posts: 76
    • View Profile
  • Liked: 1
  • Likes Given: 0
Re: Russian Logic
« Reply #5 on: April 17, 2014, 11:03:06 AM »
Hm. Do not prove logic propositions by using a programming language with preconceived design decisions.

Anybody working with SQL is probably aware of the interesting rules to match null values:
SELECT count(*) FROM tbl;  -->  100
SELECT count(*) FROM tbl  WHERE arctic = 'cold';  -->  50
SELECT count(*) FROM tbl  WHERE arctic != 'cold';  -->  30  (!)
SELECT count(*) FROM tbl  WHERE arctic IS NULL;  -->  20

Almost all programming languages implement binary logic, null values in C# and Java will mostly give errors.

SQL is one of the few exceptions.

So, whatever proofs are done in a programming language only exposes the design decisions in the language, it does not prove fundamental concepts of logic.

Incidentally BF can be considered simple when comparing to Malbolge, http://en.wikipedia.org/wiki/Malbolge
.

My personal favorite is Whitespace http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29. What can go with only using tabs and spaces, everything else is comments?
If you are not paranoid you just do not have enough information yet.

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #6 on: April 17, 2014, 11:25:08 AM »
plg,

But that's only becuase SQL gives a specific meaning to NULL. That being a lack of any data.

So in that case our   !A = NULL   is effectively written as   !A =    which is indeed an error.

That's also why you can't compare NULL to anything, but must specifically check for there being no data by using the IS NULL function.

Once again - you need to be VERY SPECIFIC about how exactly the logic is being described in English.

Edit....
SELECT count(*) FROM tbl  WHERE arctic IS NULL is really looking for there being no data about the temperature of the arctic.
« Last Edit: April 17, 2014, 11:42:22 AM by DoomInTheUK »

RaenorShine

  • Frazil ice
  • Posts: 244
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #7 on: April 17, 2014, 11:26:54 AM »

So !A = (bottle of beer) // this is an error, because !A = !(Jack Russel terrier) (from the previous line). Translating the previous line into normal english, it states: "an entity known as "!A" - is something which is not Jack Russel terrier". What is this "something"? Quite simply, it is EVERYTHING ELSE than Jack Russel terrier. I.e., whole darn universe, everything existing, including this post, including you and me and 7+ billions of people, and all other dog varieties except Jack Russel terrier, too. And yet, with this line, you equate this all - including you and me - to a bottle of beer??? NO WAI!!! :D
and !A = (bicycle) // this is the same error as the previous line. Also, consider this: if we take this and previous line, and put them together, then we will have: !A = (bottle of beer) = (bicycle), from which we can extract this: (bottle of beer) = (bicycle). Which is obviously incorrect. Ergo, the equations which have led to this - are also incorrect. Namely, both this and previous line of your proof - are ones which are incorrect. This is yet one more - second, - method to easily demonstrate your error.
!A is not an entity its a logical statement, and its value is really a set of values ( albeit if A is boolean a set of 1 value)

What should really be written is

 A = (Jack Russel terrier)

!A ⊇ (bottle of beer) (not A contains bottle of beer)
!A ⊇ (bicycle) (not A contains bicycle)

This does not prove that
(bottle of beer) = (bicycle)

plg

  • New ice
  • Posts: 76
    • View Profile
  • Liked: 1
  • Likes Given: 0
Re: Russian Logic
« Reply #8 on: April 17, 2014, 11:59:44 AM »
plg,

But that's only becuase SQL gives a specific meaning to NULL. That being a lack of any data.

So in that case our   !A = NULL   is effectively written as   !A =    which is indeed an error.

That's also why you can't compare NULL to anything, but must specifically check for there being no data by using the IS NULL function.

Once again - you need to be VERY SPECIFIC about how exactly the logic is being described in English.

Edit....
SELECT count(*) FROM tbl  WHERE arctic IS NULL is really looking for there being no data about the temperature of the arctic.

Yes, I am aware of the meaning of NULL in SQL (although it does trip up a lot of people that are new to SQL).

My point was not really about SQL per se, but the fact that sample code in any programming language does not constitute proof one way ore the other when it comes symbolic/mathematical/propositional/<insert favorite> logic. It only shows the design decisions and compromises by the language designer.
If you are not paranoid you just do not have enough information yet.

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #9 on: April 17, 2014, 12:33:50 PM »
I agree that a language example is not 'ideal', but surely the implementation of negation and comparison should be a fundamental given. If it wasn't then you couldn't have a Turing complete language and therefore the whole edifice would collapse.

For any example, the devil is always in the details and semantics can trip you up in any language. A computer language will generally have fewer gotchas than a natural language due to their own internal constraints. They just tend to be a bit 'odd' if you're not used to them.

This whole issue boils down to comparison and negation. I'm struggling to think of a valid frame of reference in which !A <> !A is valid.

Well it's more fun than doing real work anyway.  ;D

SATire

  • Grease ice
  • Posts: 514
    • View Profile
  • Liked: 34
  • Likes Given: 8
Re: Russian Logic
« Reply #10 on: April 17, 2014, 03:19:49 PM »
hey guys - please calm down and try first to agree what is the topic.

If it is logic - F.Tnioli got it (nearly ;-) ).
If it is programming language - maybe you need your own thread to agree what is the specific programming language to discuss about? Logic is much more than programming a simple electric system...
If it is set theory (mathematics) - maybe you need another thread for that.

Now I want to give also my view: Stephen would be totally wrong, if this about logic (because I translate "Russian logic" to "niggling logic" - trying to be more precise than usually necessary ;-)

The problem with asuming the possibility of A<>A or !A<>!A in logic, where A is a statement, is that this statement which is in contradiction to itself - tough stuff.

Maybe I would like to suggest to change the title to Greek logic - in ancient times they had a lot of fun discussing statements like "I know that I do not know anything" or things like "you can not walk two times into the same river" with the later extension to "you can not even walk one time into the same river" (because it becomes a changed river while stepping in). For statements like that A<>A may hold. Normaly you exclude such things explicitely from modern logic - at least if I remember right my university curse in formal logic some decades ago...

F.Tnioli

  • Grease ice
  • Posts: 772
    • View Profile
  • Liked: 147
  • Likes Given: 38
Re: Russian Logic
« Reply #11 on: April 17, 2014, 03:52:58 PM »
I bet you do, sir.

To remind, the whole gig started when someone said: "precise is an imprecise term". I merely developed this phraze to illustrate that IF and WHEN precise is NOT precise, - then term "imprecise" itself loses its usual meaning as well.

Also, IRT RaenorShine: oh, here we go, the KEY doubt. I knew it'd get to it. See, some people think that "not A" - is "anything" except "A"; others (incluing quite many scientists, especially mathematicians, engineers and programmers) - think that "not A" - is "everything" except "A". I am one of the latter bunch.

And i have this to say to the former bunch: the term "contains" has its own, well known, mathematical equivalent (operand), and it's not "!" (i.e., it's other than negation operation). The symbol is: ∋ (or ∈, depends on which side of the equation which thing is). Funny thing, http://en.wikipedia.org/wiki/List_of_mathematical_symbols does mention set theory in the details about this symbol.

It's probably the same symbol you've used in your post, RaenorShine. If so, then i completely agree with your post, and am (and, was - above!) just saying the same thing. :)

So, whenever you use word "contains", you gotta use this symbol, indeed - because it's different. Of course, there is a relation between "!" and "∋" - namely, the former is just one of (potentially infinite) possible sets expressed purely with the help of the latter. But still, to me, those are two mighty different logics, and i guess, the main reason i deny the use of "!" in the "anything except" sense (and advocate the "everything except" sense) - is because "anything except" one lacks definity. It's a loose thing. Allows for (potentially infinite) number of solutions, and potentially infinite amount of anything, - is not a thing human mind can easily operate with. I prefer single solutions, and precise logics.

Only then precise is precise, and not imprecise. :D :D
« Last Edit: April 17, 2014, 04:04:19 PM by F.Tnioli »
To everyone: before posting in a melting season topic, please be sure to know contents of this moderator's post: https://forum.arctic-sea-ice.net/index.php/topic,3017.msg261893.html#msg261893 . Thanks!

ccgwebmaster

  • Nilas ice
  • Posts: 1085
  • Civilisation collapse - what are you doing?
    • View Profile
    • CCG Website
  • Liked: 2
  • Likes Given: 0
Re: Russian Logic
« Reply #12 on: April 17, 2014, 04:31:55 PM »
Almost all programming languages implement binary logic, null values in C# and Java will mostly give errors.

C# supports nullable types, as well as being able to set object references to null.

int? a = null;

Unfortunately Microsoft failed to integrate nullable types with their table adapter implementation, leaving you in some cases using ugly functions to check for null (but I digress... that's just a pet peeve of mine).

Usually define the value of A and it (with a few ugly exceptions - http://www.hotscripts.com/forums/c-c/57931-c-tip-what-difference-between-postfix-prefix-operators.html) remains the same throughout an instruction (when it doesn't the code will at least say it doesn't - so not sure that can really give a case where !A != !A, as it would be !A != !--A (I'm assuming prefix decrement takes precedence over the negation operator, if I'm wrong, add your own brackets)).

As has been pointed out, if you're comparing facts - the original statement cannot really hold up, !A = !A, end of story. The bicycle = beer because both of them do not equal a dog (or you can take the set view from RaenorShine).

But how about we take ! to mean bitwise negation (usually uses operator ~)? Then we get to say not only that "bicycle <> beer" but also that "!bicycle <>  !beer"?  ::)

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #13 on: April 17, 2014, 05:19:46 PM »
I'll hold my hand up and hang my head in shame for this straying so far off topic we might end up back where we started from the other direction.

As for bitwise logic - that can really confuse the unwary, or even the wary if you're not ready for it.
Just like this lovely piece of code that was found to be flying around in a Tornado aircraft:

A = A xor B;
B = A xor B;
A = A xor B;

I leave it to the reader to work out what that does (and NO it wouldn't matter what language it was written in - just as long as you can do an XOR operation).

Now I'm fairly sure that if we bitwise negate a bicycle then it would be unrideable and heaven forbid that we produce an undrinkable beer the same way.

So that brings us back to the original point of "is precise an imprecise term". Personally I don't have enough rules about each term to strictly define it either way, and I'm not even sure that I care. The only objection that I had was with the extrapolation to the logical fallacy of !A <> !A.

- or should that be !A != !A.  ;)


F.Tnioli

  • Grease ice
  • Posts: 772
    • View Profile
  • Liked: 147
  • Likes Given: 38
Re: Russian Logic
« Reply #14 on: April 18, 2014, 10:32:38 AM »
A = A xor B;
B = A xor B;
A = A xor B;

What a nice piece.

I assume A and B are both boolean. Then, it seems to me this code changes both A and B to opposite values if A != B initially, and does not produce any lasting change if A = B initially.

However, there is one little fine detail. In case A = B = false initially, this code does not change anything at all, HOWEVER, if A = B = true initially, then this code changes A to false in its 1st line, and then changes it bck to true in its 3rd line. End result is the same, yes, BUT, if any other process or subsystem monitors A, especially if A has a timestamp for "last changed" for it, - then cases "A=B=false" and "A=B=true" - will lead to different outcomes (somewhere outside of this particular block of code, of course). Thus, this code may still have a sense, i guess.

Those folks in aviation industries get all sorts of weird stuff workin'. Hehe. :D
To everyone: before posting in a melting season topic, please be sure to know contents of this moderator's post: https://forum.arctic-sea-ice.net/index.php/topic,3017.msg261893.html#msg261893 . Thanks!

SATire

  • Grease ice
  • Posts: 514
    • View Profile
  • Liked: 34
  • Likes Given: 8
Re: Russian Logic
« Reply #15 on: April 18, 2014, 01:31:39 PM »
just to remind you: If this is about logic, than things like A, !A, B, ... are "statements". And the "values" such statements may have are "true" or "false" and not an animal or such things like a set - that would be set theory, which is part of mathematics. And A or B are not variables like they are used in enginnering like programming languages.

So - if statement A ist true, then statement !A is false. If true is equal to false then you end up with such ancient Greek things...

Jim Hunt

  • First-year ice
  • Posts: 5198
  • Stay Home, Save Lives
    • View Profile
    • The Arctic sea ice Great White Con
  • Liked: 625
  • Likes Given: 56
Re: Russian Logic
« Reply #16 on: April 18, 2014, 04:22:29 PM »
Just in case anyone fancies putting the vast programming expertise on display here to good use, don't forget that we have The Developer's Corner!
Reality is merely an illusion, albeit a very persistent one - Albert Einstein

F.Tnioli

  • Grease ice
  • Posts: 772
    • View Profile
  • Liked: 147
  • Likes Given: 38
Re: Russian Logic
« Reply #17 on: April 21, 2014, 10:42:24 AM »
just to remind you: If this is about logic, than things like A, !A, B, ... are "statements". And the "values" such statements may have are "true" or "false" and not an animal or such things like a set - that would be set theory, which is part of mathematics. And A or B are not variables like they are used in enginnering like programming languages.

So - if statement A ist true, then statement !A is false. If true is equal to false then you end up with such ancient Greek things...
Oh, i got bad news for you, SATire.

1st, this is about logic, but things like A, !A, B, ... - may be anything. Not just statements. It depends on context. If we'd _logically_ discuss semantics or something like that - then A, !A, B, ... could possibly be symbols, and not statements, for example.

2nd, logic doesn't have to be boolean - it may be, or it may not be, depends on what kind of logic is used by people who discuss the subject. For example, if we'd have mr. Sherlock Holmes here, for some strange reason being interested and posting about our subject, - i bet he'd use his deductive methods left and right; those methods incude operations with values other than "true" and "false", so it ain't boolean thing - and yet, it's logic alright.

3rd, logic itself - tadaaa! - is an ancient Greek thing. No, seriously - check it out, - it surely is: http://en.wikipedia.org/wiki/Logic . So you see, if ancient greeks are folks who have made the whole thing (logic itself), - then who are we to argue if ancient greeks also say that true is equal to false? :D :D

Just jokin'. ^^
« Last Edit: April 21, 2014, 10:50:12 AM by F.Tnioli »
To everyone: before posting in a melting season topic, please be sure to know contents of this moderator's post: https://forum.arctic-sea-ice.net/index.php/topic,3017.msg261893.html#msg261893 . Thanks!

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #18 on: April 22, 2014, 03:58:23 PM »
FT,

The xor trick works any any variable types. Strings are fun to explain!

And yep, the effect is to swap the contents of the two variables without using an intermediate variable. I'm still not sure whether to give a badge for cleverness, or a slap on the back of the head for unmaintainable code.

I bet the ancient Greeks would have loved modern IT.

F.Tnioli

  • Grease ice
  • Posts: 772
    • View Profile
  • Liked: 147
  • Likes Given: 38
Re: Russian Logic
« Reply #19 on: April 22, 2014, 04:15:19 PM »
Jokes aside, ancient greeks were, as far as i can tell, much like any other people in history: lots of not-so-bright folks (vast majority), and very few brilliant thinkers. Two things influence modern public-opinion about ancient greeks: 1st, the huge gain in human knowledge their culture produced, and 2nd - huge amount of time between us and them. The former is why we still give a nod to great many things of ancient-greek designs; the latter is why we don't have a clue about huge number of nonsense and crap ancient greeks produced: with time, only most correct and most important things remained in the memory of subsequent human cultures, since all the crap does not interest people (except very few historians, if any at all).

I imagine, should some ancient greeks be put among us today, - we'd find nearly all of them NOT loving modern IT. Very few of them - 1 in 1000 may be? - would love modern IT, but this could hardly qualify for "ancient greeks loving IT", you know. Much like any nations today have their own geeks and bigheads, you know.

But i get what you talk about. Those few ancient greeks whos names some few of us still know today, - would love the thing. Sure, many of them would, yes. Because, above all, it allows to test whether any statement is correct or not, - unless one takes a bug to be a feature, of course, but then, proper debugging is one more awesome thing to get busy with. They'd love both. :D :D

P.S. Ah, so that xor code originally operates non-boolean values and it is assumed that initial values of A and B are NOT the exactly same, eh? Yep, then it's completely different story. Probably it is some code which is being executed in a separate device - perhaps a missile warheads? - which ahs very, very limited RAM, and thus, every real-type or even every integer-type variable - is very valuable. Makes sense. I'd do a badge, not a slap, but then, i'm just an amateur in terms of coding. Or rather, _was_ one, even. %)
To everyone: before posting in a melting season topic, please be sure to know contents of this moderator's post: https://forum.arctic-sea-ice.net/index.php/topic,3017.msg261893.html#msg261893 . Thanks!

ccgwebmaster

  • Nilas ice
  • Posts: 1085
  • Civilisation collapse - what are you doing?
    • View Profile
    • CCG Website
  • Liked: 2
  • Likes Given: 0
Re: Russian Logic
« Reply #20 on: April 22, 2014, 04:56:13 PM »
And yep, the effect is to swap the contents of the two variables without using an intermediate variable. I'm still not sure whether to give a badge for cleverness, or a slap on the back of the head for unmaintainable code.

The developers might be able to make a case for it on optimisation grounds if they were operating in a limited enough environment or absolutely had to get maximum speed? Similar to using bit shifting to multiply/divide by powers of two? Sometimes at the low level there's a much faster way to do the same thing if your case is specific enough. If it meant you could work only in CPU registers you wouldn't even need to touch RAM...

[EDIT] Assuming the platform had the same sort of setup as the x86 architecture register wise.

DoomInTheUK

  • Frazil ice
  • Posts: 221
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: Russian Logic
« Reply #21 on: April 22, 2014, 05:02:11 PM »
FT,

Point taken about the Greeks - I agree that those actively involved in discussions about logic would love IT, the rest wouldn't get it at all. Much like today really.


The xor in this case is a bitwise operation, not a comparison.

A truth table helps picture what's going on:

A = 101 (decimal 5)
B = 110 (decimal 6)

After step 1, A is 011 ( the result of 101 xor'd with 110 - decimal 3)
After step 2, B is 101 ( the result of 110 xor'd with now 011 )
After Step 3, A is 110 ( the result of 011 xor'd with now 101 )

ccg,

True, it's highly effecient, but when written in a high level language like ADA it loses some of it's flair. I still favour giving a slap. It's just not the right time and place for that sort of code.
Yep, I think a slap is more in keeping.
« Last Edit: April 22, 2014, 06:17:58 PM by DoomInTheUK »