The Computer Science behind Disney's Frozen
If you understand these songs, you understand ideas from computer science
Sometimes you don’t have to be taught a difficult field like computer science or artificial intelligence. Instead, you just have to learn in what ways you already know what it is teaching. You already know a lot about it, you just didn’t know you knew all along.
It turns out that if you intuitively grasped the songs “Into the Unknown” and “The Next Right Thing” from Frozen 2, you also understand two fundamental problems artificial intelligence and computer science are struggling with. In them, the protagonists have to confront the same algorithmic trade-offs as reinforcement learning agents, optimization algorithms, and, well, every human being.
1. Into the Unknown: Explore-Exploit Tradeoff
Elsa is in a beautiful castle with her loved ones. A voice calls her to adventure. She could potentially find something even better, but this could mean losing what she has! She sings: “Everyone I’ve ever loved is here within these walls […] I’m afraid of what I’m risking if I follow you, Into the unknown”
The song “Into the Unknown” shows the internal struggle of optimizing the exploration-exploitation trade-off. Elsa is in a position where “exploitation” is a robust choice, namely taking the decision that given the current information is best. She could have a wonderful life continuing living in the castle with the people she loves. Exploitation protects both from the losses of bad decisions but also doesn’t allow one to discover even better options.
Elsa can’t stop hearing the voice that calls her to adventure. She wonders whether she should choose “exploration”. Instead of doing what currently seems best, more information could identify an even better option. Exploration is risky, as one can lose the good one already has. Elsa explicitly wonders about what she could lose, but can’t shake the feeling that there is something bigger waiting for her: “Are you here to distract me
So I make a big mistake? Or are you someone out there Who’s a little bit like me?
Who knows deep down I’m not where I’m meant to be? […] Don’t you know there’s part of me That longs to go Into the unknown!”
As you intuitively understood this when listening to the song, you intuitively understand what this algorithmic trade-off is about. Humans are faced with the same problem in all areas of life, from choosing a place to live to finding and selecting a partner.
2. The Next Right Thing: Greedy Algorithm
The Frozen 2 song “The Next Right Thing” shows the problem of computational complexity and solves it with a greedy algorithm. Anna sings: “I won’t look too far ahead It’s too much for me to take”
She can’t figure out what the best thing to do is. Thinking through all options and their implications is too much, especially because she is grieving and in emotional pain. Similarly, the cost of calculating through a whole problem space to find the best solution is very costly for an algorithm. This is the problem of “computational complexity”. Instead of brute-forcing an optimal solution, simpler heuristics are used. They are less costly and still find relatively good solutions. So does Anna as she focuses on taking one good step at a time: “break it down to this next breath, this next step This next choice is one that I can make So I’ll walk through this night Stumbling blindly toward the light And do the next right thing”
Greedy algorithms are myopic algorithms, intentionally short-sighted, to reduce computational complexity. It is another idea you can intuitively grasp from Frozen 2 but also from your daily life. Even just planning ahead all the meals you will eat in your life and how to prepare them is unsolvable. Preparing and eating one at a time is tractable.
3. You Already Understand Computer Science
Did you understand the two songs from Frozen 2 intuitively? Then you already understand parts of computer science. Q.E.D.
Should you want to learn more about algorithms and how they relate to fundamental problems of the human condition, I recommend the book “Algorithms To Live By” by Brian Christian and Tom Griffiths. You can, for example, find the exploration-exploitation trade-off (Into the Unknown) in Chapter 2!
This is a gem. Bookmarked to refer back to when I need a Disney idiom for AI's paradoxes