Sunday, August 17, 2014

Perl GCD

O Perl, how I love you.  Here is a Perl subroutine that finds the greatest common divisor of two integers:

sub gcd
{
  (my $x, my $y ) =

    map abs, grep { $_ } @_;
  $y ? gcd( $y, $x % $y ) : $x
}


and here is  a Perl subroutine that finds the greatest common divisor of any number of integers (including 0 integers, for which it returns undef):

sub gcd
{
  (my $x, my $y, my @others) =

    map abs, grep { $_ } @_;
  $y ? gcd( $y, $x % $y, @others ) : $x
}


note the difference, and how small it is.

An Argument Against the Possibility of Transworld Identity of Indiscernibles

I'm going to attempt prove that transworld identity of indiscernables is impossible. Maybe this is unnecessary because either it is obvious to anyone who cares or proving it is easy enough that it hardly needs to be done, but I'm going to do it anyway. I would like to establish its truth because of my modal symbolic logic app, somerby.net/mack/logic. Right now, it does not handle transworld identity in a reasonable way. I need to fix this. My plan is to change the algorithm so it operates under the assumption that transworld identity of indiscernables is impossible, which is (in my opinion) the correct behavior.

Let me explain what I mean by "Transworld Identity of Indiscernibles". Transworld identity is when an object is considered to exist in two different possible worlds. Let me explain that I mean by "possible worlds", too. Abraham Lincoln existed in the real world. In the imaginary world of the movie Abraham Lincoln: Vampire Hunter, Abraham Lincoln also existed and, in addition to his duties as president, hunted vampires. These two Abraham Lincolns are supposed to be the same person somehow; if they weren't, then Abraham Lincoln: Vampire Hunter would not have the question "what if Abraham Lincoln had to save his country from vampires" to drive its plot, and it would just be about a bearded man in a stovepipe hat killing vampires. Or maybe it was. I don't know. I haven't seen the movie. So here's a less fantastical example: consider the statement "if I hadn't been caught in traffic, I would have been at the meeting on time". It's an ordinary, plausible thing to say, and it mentions two possible worlds: the real world, where I was late for a meeting, and a hypothetical world where I was not late for that same meeting. The statement implies that I exist in both possible worlds; there's late me, and then there's punctual me, and they are both supposed to be me somehow. That's transworld identity.

Identity of Indiscernibles is a principle that defines one particular kind of identity. This principle is that two things are identical if and only if it is impossible to distinguish them in any way. It is the kind of identity that is represented by the equals sign (=) in math and in symbolic logic. To state the principle in mathematical terms, x = y if and only if there is no statement φ = "... α ..." such that φ is true when x is substituted for α everywhere in φ and φ is false when y is substituted for α everywhere in φ.

So we have this thing called "Transworld Identity" and we have another thing called "Identity of Indiscernibles". What about Transworld Identity of Indiscernibles? Is it ever true that x = y when x and y are in two different worlds? I say "no", and here is my argument:

Suppose object o1 exists in possible world w1 and object o2 exists in possible world w2. Suppose further that w1 and w2 are different. If they are different, then there must be some quality Q which w1 has which w2 does not have; else how are they be different? Supposing all of that, then the statement "o1 exists in a world with quality Q" is true and the statement "o2 exists in a world with quality Q" is false. Therefore, by the definition of "identical" given above, o1 and o2 are not identical. ∎