While I'm not ready to indoctrinate my four-year-old into the monkhood of true geekery while he's getting in his prime running around time, I was curious to see how logically he could think. My layman's knowledge was that children began properly interpreting and creating rules around the age of six, while four was still wild imagination territory.
For my experiment, I created an extremely minimal programming game, like a very stripped-down version of RoboRally: https://dl.dropboxusercontent.com/u/5458223/robot_factory.jp...
The image depicted is doctored. We had already completed four playthroughs the night before with a similar setup, however. He was able to figure out how to program the robot to collect all of its pieces (three Duplo blocks comprised the robot; successful completion of the robot wins the game). I demonstrated the rules once, and then let him try to play by himself with minimal guidance. One interesting strategy he discovered was placing the "instructions" (the cards with arrows) on the game board in order to create a path. https://dl.dropboxusercontent.com/u/5458223/robot_factory_re...
A few weeks later, we played it again, and I taught him how to make new "instruction cards". We're not yet at the place where we've done anything with variables and abstraction. Apparently he liked the game well enough, because he independently recreated it at school: