Experiment on Simulation Theory from a software engineer's point of view.

Experiment on Simulation Theory from a software engineer's point of view.
Photo by Joseph Barrientos / Unsplash

I just returned back from a short walk with my family along Laaksolahden beach. And along the walk, my mind drifted from a topic to another.

So, this is just a wild idea on my approach to the Simulation Theory.

First of all, I should remind the reviewers that I am a bit of a skeptic on this topic. I grew up with The Matrix series but currently, the idea is a bit towards philosophy rather than being scientific.

Now; the main idea of this article;

Assume that we are all processes or pieces of software defined in a computer in posthuman era. And the future post-human species are running a simulation (which is our perception of reality) to understand their evolution.

With a very simple perspective, we can consider below code as a single individual human-being.

   1    from io import StringIO
   2    from threading import Thread
   3    from time import sleep
   4    
   5    
   6    class Human(Thread):
   7        def __init__(self):
   8            super().__init__()
   9            self.to_say = "I am real\n"
  10    
  11        def run(self):
  12            while True:
  13                print(self.to_say)
  14                sleep(0.5)
  15    
  16    
  17    neo = Human()
  18    neo.start()
  19    neo.join()
───────┴────────────────────
❯ python one.py 
I am real

I am real

I am real

I am real

This is us. And from our perspective, we forever (or until get killed) say "I am real". And there is no way that this piece of code can alter itself. This code can not miraculously come up and say "I am in a simulation". This is the whole idea of a simulation. Everything within the simulation environment just contributes to its reality.

For the sake of lesser complexity on the code, I have chosen to use Threads over Process because Threads share the same memory are where memory areas of processes are isolated from each other.

But there is still hope. Now assume that we have another piece of code.

   1    import gc
   2    from threading import Thread
   3    from time import sleep
   4    
   5    
   6    class Human(Thread):
   7        def __init__(self):
   8            super().__init__()
   9            self.to_say = "I am real\n"
  10    
  11        def run(self):
  12            while True:
  13                print(self.to_say)
  14                sleep(0.5)
  15    
  16    
  17    class Morpheus(Human):
  18        def run(self):
  19            sleep(2)
  20            while True:
  21                for obj in gc.get_objects():
  22                    if isinstance(obj, Human) and obj.to_say == "I am real\n":
  23                        obj.to_say = "This is matrix\n"
  24    
  25    
  26    neo = Human()
  27    neo.start()
  28    morpheus = Morpheus()
  29    morpheus.start()
  30    
  31    neo.join()
  32    morpheus.join()
❯ python two.py 
I am real

I am real

I am real

I am real

I am real

This is matrix

This is matrix

This is matrix

This is matrix

This is matrix

Now we have Morpheus. As you can see, a single human being is not capable of knowing whether or not it is living in a simulation. Because it's variables and conditions are just defined to process existing state as reality.

But Morpheus (still an entity inside the simulation environment but has a slightly different codebase) can tell Human if it's real or not.

But it doesn't end here.

Now Human keeps saying "This is matrix". But it is still just a variable. It is a believer of the matrix. But there is no proof. We need a proof. From Neo's point of view, everything is internally consistent.

And there comes the Oracle. The one who listens to the world around and that knows the past and present. So can detect the changes in the consistency.

   1    import gc
   2    import sys
   3    from io import StringIO
   4    from threading import Thread
   5    from time import sleep
   6    
   7    world = StringIO()
   8    
   9    
  10    class Human(Thread):
  11        def __init__(self):
  12            super().__init__()
  13            self.to_say = "I am real\n"
  14    
  15        def run(self):
  16            while True:
  17                world.write(self.to_say)
  18                sleep(0.5)
  19    
  20    
  21    class Morpheus(Human):
  22        def run(self):
  23            sleep(2)
  24            while True:
  25                for obj in gc.get_objects():
  26                    if isinstance(obj, Human) and obj.to_say == "I am real\n":
  27                        obj.to_say = "This is matrix\n"
  28    
  29    
  30    class Oracle(Human):
  31        def run(self):
  32            while True:
  33                data = world.getvalue()
  34                lines = data.splitlines()
  35                if len(set(lines)) > 1:
  36                    print("Someone has awakened")
  37                sleep(2)
  38    
  39    
  40    neo = Human()
  41    neo.start()
  42    morpheus = Morpheus()
  43    morpheus.start()
  44    oracle = Oracle()
  45    oracle.start()
  46    
  47    neo.join()
  48    morpheus.join()
  49    oracle.join()
❯ python example.py 
Someone has awakened

So approximately after 2 seconds, Morpheus tells Neo that everything is a matrix. And Neo believes it. But that is not enough to prove. Oracle has to watch for the changes and should say that, within the simulation, something that should not happen happened and altered Neo's perception of reality.

Neo no longer says "I am real" as programmed but now says "This is matrix". And the change in the self-code in runtime is observed by the Oracle.

Of course, in real life, this is not just a single variable. We have huge amounts of variables that define our universe. But, if Morpheus alters one and we see it's effect on Neo which is observed and recorded by the Oracle, then that's it.

So you folks out there! If you are designing experiments to prove simulation theory, you need something outside the experiment that alters reality and something that observes past and present state of the reality.