Walk into any preschool and you’ll find toddling superheroes battling imaginary monsters. We take it for granted that young children play and, especially, pretend. Why do they spend so much time in fantasy worlds?

People have suspected that play helps children learn, but until recently there was little research that showed this or explained why it might be true. In my lab at the University of California at Berkeley, we’ve been trying to explain how very young children can learn so much so quickly, and we’ve developed a new scientific approach to children’s learning.

Where does pretending come in? It relates to what philosophers call “counterfactual” thinking, like Einstein wondering what would happen if a train went at the speed of light.

In one study, my student Daphna Buchsbaum introduced 3- and 4-year-olds to a stuffed monkey and a musical toy and told them, “It’s Monkey’s birthday, and this is a birthday machine we can use to sing to Monkey. It plays “Happy Birthday” when you put a zando” (a funny-looking object) “on it like this.” Then she held up a different object and explained that it wasn’t a zando and therefore wouldn’t make the music play. Then she asked some tricky counterfactual questions: “If this zando wasn’t a zando, would the machine play music or not?” What if the non-zando was a zando? About half the 3-year-olds answered correctly.

Then a confederate took away the toys and Daphna said, “We could just pretend that this box is the machine and that this block is a zando and this other one isn’t. Let’s put the blocks on the machine. What will happen next?” About half said the pretend zando made pretend music, while the pretend non-zando did nothing (well, pretend nothing, which is quite a concept even if you’re older than 3).

We found children who were better at pretending could reason better about counterfactuals—they were better at thinking about different possibilities. And thinking about possibilities plays a crucial role in the latest understanding about how children learn. The idea is that children at play are like pint-sized scientists testing theories. They imagine ways the world could work and predict the pattern of data that would follow if their theories were true, and then compare that pattern with the pattern they actually see. Even toddlers turn out to be smarter than we would have thought if we ask them the right questions in the right way.

Play is under pressure right now, as parents and policymakers try to make preschools more like schools. But pretend play is not only important for kids; it’s a crucial part of what makes all humans so smart.