Starlight Breaks Magic

by Lets Do This

Rating: everyone
Tags: Twilight Sparkle, My Little Pony: Friendship is Magic, Drama, Starswirl the Bearded, Starlight Glimmer, Sunburst
Length: 16097

Starlight believes she's broken magic itself. Worse, she can prove it. And she's going to need help from her closest friends... because her entire life has been leading up to this moment...

Starlight believes she's broken magic itself. Worse, she can prove it. And she's going to need help from her closest friends... because her entire life has been leading up to this moment...

Set between Seasons 7 and 8. Warning: contains recursion, self-reference, and higher-order spells. Plus flashbacks and didacticism. And Starlight being Starlight, of course...

Published 2020-12-04 21:50:00 UTC
Last updated 2020-12-04 21:50:00 UTC

Starlight Breaks Magic

"I've really done it this time, haven't I?" Starlight Glimmer asked hopelessly. "I've broken magic!"

It was quiet in the library in the Friendship Castle in Ponyville, even quieter than usual. Twilight Sparkle herself said nothing, as she intently read through the slim thesis Starlight had nervously pushed across the table. It contained a concise but thorough summary of Starlight's discovery.

A smile gradually stole onto the lavender alicorn's face. It moved from her snout, up to her eyes, then even to the tips of her ears, which were swept forward alertly. She looked up at Starlight.

"I know you'll have double-checked this."

"Triple-checked," Starlight confirmed. "But I wanted a read-through by a friend, somepony I trust, before showing it to anypony else. Because you've gotta admit, Twilight... this is pretty devastating."

"I wouldn't say that, exactly," Twilight replied. "Though it is ground-breaking to say the least."

"Ground-breaking. Yeah, that's a good way to put it. Considering what I've done to the discipline of magic." Starlight's face thudded onto the table-top. "So," she said in a muffled voice, "what should I do, Twilight?"

"You should talk to somepony who knows a lot about spells, even more than I do. Somepony who can give you a professional read on this. I mean, I'm the Princess of Friendship. And I know a lot about magic. And just reading through this, I can tell it's an important discovery. But... I'm not really the expert you need."

Starlight looked up, wide-eyed. "So... you're saying I should take this to the scholars at the Archives? See what they make of it?" She winced. "You think I have time to make out my will first?"

Twilight smiled understandingly. "Not just yet. I think there's another pony you should show this to. And given you two are friends again, I'm sure he'd be willing to give this a thorough look."

"Sunburst?" Starlight looked surprised. "Well, yeah, that makes sense. But he's all the way up north, in the Crystal Empire."

"Then isn't it great you've got vacation time saved up?"

"Vacation time? Since when?"

"Since five seconds ago." Twilight smiled. "Seriously, Starlight. You've been helping out so capably here, and staying on top of your friendship studies --"

"-- with... the occasional spectacular screw-up," Starlight added.

"That's how we learn," Twilight said. "You deserve a little time for yourself to follow up on this. Plus a road-trip and sight-seeing will do you good. And it's the perfect excuse to drop in on an old friend to catch up, and oh-by-the-way ask if he'll read something and give you his opinion on it. Sounds like a win-win plan to me!"

"Okay, sure. If you can spare me around here, I'll go pack."

"Don't bother. Just grab whatever books and scrolls you think you'll need and go catch the midday train, before you miss it. I'm sure Princess Cadance will be happy to roll out the welcome mat and provide anything you've forgotten. I'll have Spike send a message ahead, just to let her know you're coming."

"Thanks, Twilight."

"Not a problem, my diligent student. Have fun!"

Turning, Starlight raced from the room, already mentally cataloguing the scrolls and journals she'd want to take.

And Twilight watched her go, an amused, wistful look on her face. Then she went to find Spike, to have him send a letter to Cadance.

Followed by one or two others.

There were arrangements to make here...

Honorable wizards, sorcerors, and mages...

When I was invited to give this guest lecture to the Research Division of the Canterlot Archives, on the occasion of the one thousand, one hundredth, and eleventh anniversary of its founding, I was deeply honored. And... let's be honest, more than a little nervous. So I'll try to keep this brief and to the point, and worthy of your valuable time and attention.

Ever since I was a filly, I've been fascinated by magic, and the crafting of spells. By what's possible with just a few tried-and-true spell components, some execution forms, and a bit of horn-power.

And, in making this the focus of my life's work, I have been so fortunate in having the help of some excellent friends and guides along the way...

"This is Sunburst, Pumpkin," said Firelight, as he gently settled his daughter in her seat at the rec-room table. "Now be a good filly, Punkie Wunkin, and the two of you play together, while Daddy and Sunburst's parents are talking. Okay, Sugar Plum?"

"'Kay." As her father left the room, the lavender, pig-tailed filly peered nervously across the table at the smallish, tan-coated colt.

Sunburst stared back at her owlishly, as if uncertain what she was.

"Uh... hi," she tried cautiously. "My name's really Starlight Glimmer. Daddy's nice and all, but he sometimes forgets to actually say it. Wow, your mane is really orangey!"

Sunburst self-consciously put a white-socked forehoof to his neatly combed locks. "It's... called ginger," he said in a voice that sounded perpetually trembly and nervous. "Though I'm not sure why. Ginger root isn't anywhere near this color. Um, sorry. Not really relevant. Er... what do you like to play?"

"Um..." Starlight thought furiously, glancing around. She didn't know many games for more than one pony, except...

Her eyes landed on a large, flat box tucked high on a bookshelf.

"Hey! You have Dragon Pit too?"

His eyes went wide. "You like to play Dragon Pit?"

"Sure! Daddy sometimes plays it with me." Starlight shrugged. "Mostly to humor me. I'm not sure he likes it all that much. But I sure do."

"Same here!" Sunburst's horn flared, and he tugged the box from the shelf and levitated it down onto the table. "Mom will sometimes play it with me as a reward, if I've been very good. But I wish I could play it more often. You wanna be red or blue?"

"Blue," she said. "I usually pick blue, since it matches my magic."

"That's perfect!" Sunburst replied. "I like the red dragon, 'cause it's nearly the same color as my mane."

They quickly settled in, rolling the die and moving the small dragon tokens along paths that wound over the carved slopes of the volcano. As Sunburst set his piece on a square at the end of one of the winding marble trails, the entire board shuddered, in that telltale way.

"Uh oh..." Starlight said warningly. "Somepony's dragon is gonna get trapped!"

"Eeeee!" Sunburst leaned closer, entranced. "I hope it's me! I know it means I have to start over from the beginning. But I just love it when my piece drops through the board. It just disappears -- like it teleported!"

"What I like," Starlight said, "is when the magic kicks in, and the marble pops up out of the volcano. 'Cause then you don't know which way it's gonna roll, whose piece it's gonna hit."

"Right!" Sunburst nodded. "Oh, this is so great! I didn't think there were any kids around here who liked this game as much as I do."

Starlight stared at him. "Why not?"

Sunburst suddenly looked miserable. "Well... other colts laugh and say it's a game for little foals, because it's all dice-rolling. No strategy, you see. But that's what makes it so much fun, because..."

"... you never know what's going to happen!" Starlight chorused with him, pointing a hoof at the tagline printed on the box. They both laughed at that, grinning at each other.

Then they played for a while in happy silence, rolling the die, moving the pieces, and occasionally retrieving a trapped dragon from the bin under the board.

Then Sunburst looked up hesitantly. "Um... do you like studying magic at all? Reading spells, trying them out, stuff like that?"

"Do I!" Starlight replied. Then she looked doubtful. "Well... I like doing magic. I'm not so crazy about magic lessons. They're so boring! Having to memorize all those spells out of dusty old books. And learn how to say them just right. And they take so much time to say. And they're always just baby spells anyway, doing little piffly stuff like levitating a toothpick or something."

"Yeah, I hear you." Sunburst scratched his mane with a hoof. "But... how do you study magic without memorizing spells?"

"Oh! I like making my own spells," Starlight said proudly. "A little bit of this, a little bit of that, and boom, I got a new spell. Sometimes it even works, too. Eeeyeah... more often not. But I keep trying until it does."

"Oh, I get it!" Sunburst nodded. "You mean structured magic."

Starlight stared at him. "What kind of magic?"

"Structured magic. It's when you're constructing spells from scratch by putting together fundamental components in standard forms. Like building a tower out of blocks, or a clock out of gears. You decide what you want the spell to do, then you put together the right pieces in the right patterns in order to do it. It's kinda new, so they don't really teach it much in school."

"Get outta town!" Starlight said, amazed. "There's actually a word for what I do? I thought I was just messin' around!" She looked sad. "At least, that's what everypony always tells me, when they ask what spells I know."

"Well, I think it's cool. There aren't many ponies who can just make spells, instead of learning or discovering them. That's mage-level stuff."

"Really?" Starlight's eyes lit up. "Wow! Thanks, Sunburst!"

He shrugged. "It's the truth. When we finish the game, I've got a book on structured magic we could look through. Maybe we could try working on a spell together? I mean... if you'd like to."

"You kidding me? That sounds great!" She giggled. "You know, you're loads of fun, Sunburst! A lot more fun than I thought you'd be, listening to Daddy talk about you on the way over."

He smiled back. "You too! I mean, when Mom said you were coming over to play this afternoon, I was worried it would be really uncomfortable, know what I mean? But this is great! We have so much in common."

"Hang on a sec," Starlight said suspiciously. "Let's give it a real test..." She eyed him narrowly. "You like apple juice?"

"Absa-pony-lutely," Sunburst confirmed.

Starlight nodded. "Yep, that settles it. We got lots in common. So... you wanna be friends?"

"You mean we're not already?" Sunburst laughed. "It gets better than this?"

Structured magic is the discipline that attempts to represent all magic in terms of fundamental spell components and forms of execution. In a way, it's an offshoot of logic, since a spell in structured magic is essentially an existence proof: a proof that a given effect is achievable, and representable in the form of a valid, strongly-typed, castable spell.

I know many professional mages view structured magic as a kind of tortured tour-de-force, achieving by complex assemblies of trivial operations a semblance of the art inherent in a well-thought out, hoof-crafted spell.

Yet it can be shown that basically any spell can ultimately be represented in terms of such simple operations...

The morning had been hot and fine, so Sunburst and Starlight had toted a small carpet outside and spread it under a shady tree on the hill near Sunburst's home, where there was a cool breeze. Over the past few months they'd often gotten together for study sessions like this, though their respective parents dotingly persisted in calling them "playdates".

Sunburst had brought along a number of books on magic, some he was reading for school, and some he'd picked out at the library because he thought they would be helpful for Starlight. And Starlight had brought along a set of baby blocks she was using to help her learn how to do multi-cast levitation.

Starlight stared fiercely at one of the blocks, her horn singing. She'd already learned the rote way of levitating it. Then she'd managed to restructure the spell tail-recursively, so she didn't have to keep reciting it over and over in her head as she cast. She could just apply minimal sustaining power, and the spell would reinvoke itself, automatically, as often as required.

But now she was trying to refactor the spell further, so it was properly scalable: so she could increase the number of blocks she was holding, or pick up things other than blocks, without having to change anything except the sustaining magic required. What Sunburst had said was a "generic-concurrent" spell, based on a check of one of the books he'd brought.

The block wobbled unsteadily in Starlight's magic for a few moments. And then she felt the spell slip a gear. The cast failed, the block thunked back to the carpet.

Starlight growled in frustration. It had felt so close... why could she not see what was wrong?

While she'd been working at it, Sunburst had been paging through a spellbook hovering in his magic. He swept it over, and showed her a slightly different form of the levitation spell.

And something clicked. Starlight could see the difference between the two spells, like extra corners on each, which got in the way of using either recurrently.

Adjusting the old spell to eliminate those differences, Starlight recast. And this time she picked up the block with ease. It gently spun in the air before her. Excited, she cast the spell over all the blocks. They leapt into the air and spun gently in a circle before her, like a Ferris wheel, neat as you please.

"Wow!" Sunburst stared at the blocks. "Will you show me how you did that, Starlight? It's so cool, how you can take spells I thought were all of a piece, and pick out just what you need from them."

"Sure," she replied. "Though you know, I wouldn't be able to do stuff like this without you helping me. I don't know how to look stuff up properly, so I get frustrated and give up too easy."

"Hey, not a problem," He grinned. "We're a team, right?"

"You bet!"

Starlight described the adjustments she'd made to the levitation spell, and Sunburst gave it a try himself. However, he couldn't manage to hold onto more than two of the blocks simultaneously.

"I... don't think I'm casting it right," he said, squinting as he tried to pick up another block. "I'm used to casting spells as... well, spells, as single units. It's hard getting past that and treating them as collections of components, the way you do."

Starlight shrugged. "That's not you, it's me. I just haven't studied as much as you have. I never learned to see spells any other way. It's why I'm so lousy at my lessons." She grimaced. "My magic tutor hates me. She keeps telling me I'll never get into Celestia's School just fiddling around with magic the way I do."

"Woah... now that would be something, wouldn't it?" Sunburst let the blocks drop back onto the carpet. "To go to Celestia's School, study with the best and brightest ponies in the realm. Maybe even learn from the Princess herself... wow!"

"Yeah, but... that's not happening until we get our cutie-marks, right?" Starlight pointed at her own blank flank.

"That's what Mom says," Sunburst agreed. "She says she's never heard of a pony yet who was admitted to the School and didn't already have their mark."

"Well... then maybe we might get in next year?" Starlight said.

"You never know." Sunburst grinned. "It's still a couple weeks before the Examiner arrives. Maybe if we keep practicing, it'll happen by then."

"Maybe." Starlight smiled in return. "I'm just glad I have a good friend to study this stuff with. I'm not sure what I'd do without that..."

Key to the construction of complex spells are the concepts of naming and calling. Without this, it would be necessary to repeat literally every single component one uses in a spell, every time it is used. And for some of the longer, more intricate spells, this could take weeks, months, even years.

By the naming operation, one can represent spells as parameterized names, which can in turn invoke other spells by parameterized names. Thus, one can speak in one breath, or think in one thought, a spell that invokes many libraries-worth of previously designed, previously tested sub-spells -- even if most of them perform fairly trivial operations.

But that is the point here, really. If you'll pardon the pun, there's no magic involved. Just repetition of triviality, as fast as possible. The goal is to factor out spells to their most concrete, minimal, reusable forms -- into the smallest pieces that do actual work. And create thereby a vast collection of almost trivial spell components, which can nevertheless be put together to add up to any complex effect we wish to create.

And there's a bonus: given the right toolkit of named spells, it is possible to adapt spellcasting to the needs of the moment, deriving new spells on the fly, rather than relying on monolithic spells, which can be more powerful but are also difficult to adapt quickly.

Further it can be shown -- and has been, more than once -- that by this atomizing, constructive process we can represent every single spell that is valid and castable.

Every spell, that is, save one...

"Sunburst! We're leaving in ten minutes!"

"Okay, Mom!" Sunburst called. Then he grinned at Starlight, sitting opposite him at the table in the living room. "Like the two of us haven't been ready to go for at least half an hour!"

Starlight nodded. "Daddy's the same way. It's why I asked if I could wait over at your house. Do we have time for a game before we go?"

"Have to be a quick one," Sunburst said.

"How about Book Stack?"

"Okay."

Working together, the two ponies used their magic to lift books from the nearby bookcase, and stacked them into a tall tower on the table. Sunburst did the last few at the very top, since he had finer control, while Starlight clapped her forehooves excitedly.

Then with her magic, she gently tugged at a book near the bottom of the stack, teasing it loose. She heaved a sigh of relief as it finally came free, the rest of the stack settling down into the open gap. Then she grinned at Sunburst, and moved to lift the book up to the very top of the stack.

Unexpectedly, the entire stack of books suddenly swayed. And then collapsed, falling straight at her.

Starlight flinched, her eyes shut tight...

But nothing happened.

Opening her eyes, she saw Sunburst had somehow managed to grab the entire tower with his magic, and was keeping it from falling on her. But the strain was clearly telling. He was going to run out of power soon, the levitation spell was going to fail, and then...

Sunburst's eyes went wide, and Starlight saw him quickly shift spells, saw him try to use the structured-magic form they'd been practicing, grabbing the books with a scalable spell and thus reducing the power draw...

And this time, it worked. The book stack neatly disassembled into a swirling ring of books surrounding Sunburst. He himself was hovering in midair at the center of the ring, using no more power than he would need to hold himself or any one of the books individually.

All at once, a bright glow surrounded Sunburst. The books flew across the room, slamming back into place on the bookshelves. Sunburst settled to the ground. There was a flash of light on his flank...

And just like that, he had his cutie-mark: a bright orange sun projecting rays of light. Sunburst stared at it, astounded. Then he bounded into the air with a foalish whinny of excitement. Overcome by joy, he brushed right past Starlight and raced out through the open front door, to where his parents were standing outside waiting for Firelight to arrive.

His parents were just as shocked and pleased as Sunburst. Grabbing him up in their magic, they hurried off, excited and proud, to show everypony in town...

... leaving Starlight, sad-eyed and forlorn, at the open front door. She watched them disappear from sight. Then Starlight looked at her own blank flank, her eyes welling up with tears.

When her father finally arrived, asking what all the commotion was about, she told him what happened. And he hugged her consolingly, telling her that these things happened, everything would be fine. All the usual things parents tell their children, thinking they'll help make things better...

But Starlight already knew, deep down, that things weren't going to get better.

Sunburst had gotten his cutie-mark. And on the very day the School's Examiner had come to visit. If that wasn't an auspicious sign, nothing was. He was practically enrolled in Celestia's School already.

And Starlight wasn't.

She'd be left behind, all alone.

In a moment, she'd lost her best friend... her only friend... the only friend she'd ever had, or needed.

Forever.

It wasn't going to be fine.

No. It wasn't.

Not one tiny bit...

Spells are not always perfect.

A spell may fizzle from being said wrong, or from insufficient power. A spell may also have bugs: it may be incorrectly written, or just designed wrong, so it does the wrong thing, or has unintended side-effects. More perniciously, a spell may simply never produce any effect at all, but simply "hang", consuming magic until it's either cancelled or the sustaining source of magic is removed.

To help avoid this, any system of structured magic includes a method for spell derivation, type-checking, and verification, ensuring all spells derived by the system are valid, castable, and correct.

The system is termed "complete" if all valid spells are derivable.

The system is termed "consistent" if all derived spells are properly castable, and no invalid or uncastable spells are derivable.

This would appear to resolve the issue of improperly written spells. And for most simple usages, it does. However, we're interested in a guarantee here: that all proper spells are covered, and all improper spells excluded. And it can be demonstrated that no such system can be both complete and consistent. Because for any such system, there is one valid, castable spell that cannot be derived.

And the worst part? It doesn't matter which system you start with.

They're all broken... in exactly the same way...

"Honey?" Firelight gently tapped on the closet door. "Puddin? Are you okay in there?"

"No!" Starlight yelled. "Just leave me alone, Daddy!"

"Now, I know you're worried, Punkie Wunkin," Firelight said gently. "But this is what you've been waiting for, isn't it? And it's nothing to be worried about, right? There's absolutely nothing wrong with a pony getting their cutie mark. Is there? Huh? Sweetie?"

"This is! It's completely wrong! As wrong as it can be!"

"Aw, that just can't be right, Honey Bunch. Now, whatever your mark is, I'm sure it's exactly the right one for you. And Daddy's so proud! Won't you please come out?"

"No! I won't! And that's final! Just... just go away and leave me alone! Leave me to rot in here!"

Firelight winced, unhappy at the evident pain in her voice. "Okay, Punkin... Daddy will leave you be. But you know I'm here for you. Whenever you need somepony to talk to, you just let me know. Okay?"

In response, there was only silence.

Sadly, Firelight forced himself to back off and turn away. He tried not to worry. It's just a phase, he told himself. New-mark jitters. Same thing happened to me. I was worried I was destined to become an arsonist, before I realized I was a natural at kindling students' interest in history. It'll pass...

But in the darkness of the coat closet, Starlight Glimmer huddled deep in the back amongst the long-legged overcoats, terrified out of her mind.

Finally screwing up her nerve, she cast a spotlight spell with her horn, and directed it at her flank.

And there it was, bold as brass: her cutie-mark. A livid brand baked onto her. A purple star-lozenge -- which generally was associated with magic, not too surprising -- and wispy blue swirls rising from it.

It didn't look accusingly sinister. Unless you knew where it came from.

Starlight buried her face in her forehooves, sobbing.

It had all started with the magic demo that morning at school. Which Starlight had flunked miserably. She'd tried, really tried, to memorize by rote the spell for folding a napkin. But without Sunburst's help to keep her focused, it just didn't stick. She kept forgetting parts of the long, sonorous tide of syllables, and never at the same place twice. She'd get halfway through, then abruptly replace some random "æ" with an "ä". And she could feel the entire spell fizzling, the cast failing, as the whole class laughed at her.

The more she tried, the more frustrated she became, and the harder it was not to make mistakes, in a downward spiral.

Eventually she gave up, and begged the teacher to allow her to demonstrate it via structured magic. She could have done it in moments, she was certain: a single telekinesis fold, a few geometric transforms, done. Easy peasy.

That's not how it's done by practiced mages, Miss Glimmer, the teacher had said icily. And assigned her additional followup work before she could retry the demo.

That was bad enough, by itself. But then after class Starlight had yet another falling out with her magic tutor. She knew it cost Daddy serious bits, hiring a private magic tutor for her. And she tried to be patient, studying and completing the extra homework. But when Ms. Horn bluntly accused her of not practicing, of not being serious about her studies... that was the last straw.

Starlight hauled off and gave the yellow-maned spinster a serious piece of her mind. And with tears running down her face, Starlight insisted she had, in fact, been studying...

Just... not the assigned lesson...

Ms. Horn left in a huff, darkly warning Firelight there'd be daylight shining in Tartarus before she set hoof in the house again.

As usual, Daddy hadn't been mad about it. He just joked about how Ms. Horn was always saying gloomy stuff like that, but didn't really mean it. And offered to help Starlight go over her assignments for class.

But Starlight had had enough of lessons, of magic, of all of it, for one day.

Grabbing up her carryall with her magic, she'd charged out of the house, then just kept running in a straight line until she was deep in the woods beyond town.

She came to a clearing she sometimes went to, when she wanted to be by herself. She flung off her carryall and sat down beneath a tree, with dappled sunlight and birdsong all around her.

She scowled. And fumed. And snarled under her breath.

"Why not me?" she suddenly yelled, startling a few birds out of nearby bushes. "Seriously! Why did Sunburst get everything he always wanted, and not me? We were a team! We did everything together!"

Jumping up to her hooves, she stamped the ground, livid and panting.

"Why? Just tell me why! Why did he have to leave?"

She could feel her anger boiling over, running away with her. And for once, she just didn't care. Unrestrained, her magic flung open the pockets of her carryall, yanking out the books inside: her spellbooks from school, the extra volume from her tutoring sessions...

And the volume on structured magic, which Sunburst had left behind. Because he obviously had no use for it any longer.

Starlight suddenly wanted nothing to do with any of them, ever again.

A simple telekinesis spell snapped branches from nearby trees, flung them into a pile. A pyromancy spell sparked the pile alight, into roaring flames. And Starlight flung the books onto the fire, determinedly, unrepentantly.

She kicked the pyro spell up a notch, just to be extra sure.

The old bindings cracked, the parchment-thin pages blackened and twisted. And the magic, the spells recorded within the volumes, was released. It twisted upwards in glowing streamers, turning the rising flames a brilliant coral blue.

Starlight watched it all burn, and smiled. Enough was enough. She didn't need anyone telling her how to do magic. She could manage on her own, thank you very much. She didn't need friends either, because friends went away, just when you thought you could count on them. She was not going to be left behind, abandoned, forgotten any more. She'd make sure of that.

Starlight nodded, determined. She'd make her own path, her own destiny...

... and nopony will stop me.

The books charred, the flames crackled. The spells vanished, going up in smoke.

And then, in the midst of her gloating, Starlight suddenly realized the burning spellbooks weren't the only thing that was glowing. She was too, surrounded by a nimbus of light. It lifted her into the air, even as she struggled against it. A gust of wind swept through the clearing, snuffing out the fire, even though the damage to the spellbooks was already done.

There was a flash, and a blurred moment, in which Starlight had a brief glimpse of a future spreading out ahead of her... like a boundless landscape lit for an instant by a blaze of lightning.

Then she landed back on her hooves again, in an abrupt stillness that made her wonder whether she could even hear any longer. Then she heard birds cheeping, a light breeze rustling leaves in the trees. Everything was astonishingly, numbingly, heart-poundingly normal.

She looked nervously at her flank. And saw her cutie-mark.

A purple lozenge for magic... with blue, flame-like swirls rising from it.

Starlight screamed.

Abandoning her carryall, she raced from the clearing, heading for home at top speed. And crying, in ashamed horror.

What have I done? she thought frantically, as she ran. Ran as hard as she could -- just ran, and ran, and ran, trying to get away from, trying to escape, the accusing mark branded onto her flesh.

Sweet Celestia, what the hay have I done?

Spells are expressed in two distinct ways. First there's the original, written version of the spell, what we call its "unrolled" version. Here its component forms and invocations are laid out and editable. In this form it's just text -- albeit usually text written in enchanted ink on carefully prepared scroll or spellbook paper.

The other expression of the spell is its active or "rolled up" version, where it's converted to an activatable form. This occurs when we speak or think simple spells, but a more complex spell may also be bound to an enchanted object: a staff, ring, or even the spell's original scroll or spellbook. In this form, the spell is ready for use, and merely requires application of magic power to invoke it.

And this is an important distinction: in its unrolled form, a spell is a physical object like any other. Hence, it can be manipulated by spells. We can cast spells that operate on the unrolled text of a spell. This is often used by professional mages for the purposes of spell-checking, textual searches, and the like.

But it is also possible to apply spells to a system such as structured magic, to its components, forms, and derivation rules. And thereby, use magic to derive and validate spells automatically. We can even construct spells that generate and check entire systems of magic, exhaustively and mechanically.

I know this may give some of you pause, may feel like a debasement of the art of magic. But look at it this way: it's a tool, like any other, extending our reach as magic users. And at the same time providing assurance, along the way, that our reach doesn't exceed our grasp.

It merely requires seeing what we do already from a different, augmented perspective, where we no longer need to manage the details ourselves.

Where we can allow the system to manage the details for us, while we get on with more important things...

... the things we'd really rather be doing with our lives...

"I hate school!" Starlight yelled, as she burst in through the back door. She stomped straight through the kitchen, then down the hallway to her room. "And I'm never going back!" she announced, not caring if anypony actually heard. "School sucks!"

Kicking open the door to her room, she stormed in, then bucked the door closed behind her.

Then she stared around... at her masterpiece. Her sanctum and retreat, her Fortress of Darkness.

It was perfect.

The gloomy lighting. The torn curtains. The precisely chosen three tones of dark purple paint on wall, wainscoting, and trim. The acid-band posters on the walls. The long-playing stereo with the huge subwoofer. The leather jacket, the studded anklets. The day-glo crystals. The massive antlered skull on the bed's headboard. The DeathHoof guitar in the corner. Starlight was proud of that one, actually. She didn't even know how to play the dratted thing, it was simply there as an accent.

And, scattered everywhere about the room, the Nightmare ritual implements. Starlight had collected the works: candle, book and bell. The plush demon alicorn sitting on the subwoofer. The star charts on the desk, with the Dark Zodiac limned in ice-blue night-glow magic. The artfully placed copy of the Black Book of Hoofstradamus lying on the floor, open to the page with the Summoning spell. A shopping list of vile ingredients, casually tossed on top of it. By all appearances, Starlight had sold her soul to the Mare of Darkness, and didn't care who knew it.

She was the Bad Filly. And she could do whatever she pleased, because nopony expected any better of her. And that suited Starlight just fine. If Harmony saw fit to brand her with a scarlet cutie-mark for using her magic to destroy a few worthless, useless spellbooks, she might as well act the part, huh?

But she didn't actually like all this stuff. She didn't actually believe in it. To be honest, some of it was pretty hokey. It was a mixed metaphor really, when you stopped to think about it. Sort of a wild casserole of hardrock-punk-goth-emo-whathaveyou. But -- and this was the important thing -- only somepony who knew all those styles would have noticed it.

And it served its purpose. It was window-dressing... necessary window-dressing. It was what Starlight showed the world, so the world would leave her alone, to her plans.

And as soon as she actually figured out what those plans were... well, that would be grand.

Flinging herself face down onto the unmade bed, Starlight prepared to spend the requisite thirty minutes in a practiced show of resentful, intransigent ennui. The Bad Filly, in a Really Bad Mood...

Then she abruptly looked up, at the wall behind the headboard, at the posters slapped up there.

There was one poster she knew she hadn't put up there, over to the left near the window. A familiar stallion face in profile, mane dyed bright green, wearing a studded leather jacket...

"Oh, no..." she muttered. "Don't tell me..."

Behind her, the door to her room creaked open. "Hey, Punky-Wunkin!"

Her father leaned into the room, in what he probably thought was a cool manner. He was done up exactly like the poster: green mane, studded jacket, the works.

"How'd you know your 'ol Daddy was a shock-rocker back in the day, huh? Howzabout a huggy-wuggy for your raddo-daddo, hey?"

Starlight stared at him, horrified. Then she buried her face in the pillow, and groaned.

Then, jumping up from the bed, she pointed a hoof. "Out! Out, out, out! Get out!" Running across to the door, she pushed him through it, then slammed it behind him. And this time, locked it firmly.

"For Nightmare's sake!" she shouted, leaning against it. "Why can't I have a normal dad, who hates what I like the way he's supposed to?"

Getting a grip on herself, Starlight crossed over to the desk. Obviously, the whole ultra-goth-rebellion thing wasn't gonna work out. Time for plan B.

But she didn't have a Plan B.

Not yet, anyways.

She was going to have to come up with one, figure out what she really wanted to do. After all, if she was going to change the world, show everyone cutie-marks were bad news, she needed to get cracking here.

First, she decided, she'd need some kind of manifesto, something she could use to persuade and gather followers.

Yes, an N-point program, for...

... for what, exactly?

Then she remembered, the idea that came to her on the train-ride home, after seeing Sunburst off at Celestia's School. Creating a perfect society, where ponies were all truly equal. Where differences, talents, special gifts, all that uniqueness, didn't get in the way, or give anypony an unfair edge.

Yes. That was plan B.

Starlight hauled a blank journal out of the desk drawer, together with a stack of quills. She sat for a moment, thinking about it.

And then started writing.

It's all about cutie-marks, she began. Who has them, and who doesn't. Who gets what they want in life, and who loses out. It's not fair. We shouldn't be bound by a mark on our flanks -- a seal of approval from Harmony or whatever, that we're properly placed in life. There has to be a different way, a better way...

She smiled, feeling the solid, reassuring truth of it.

And there is, she wrote. A world without cutie-marks. Where everypony is equal. No winners, no losers. Nopony left behind...

Starlight nodded, getting into it. It was just like when she constructed spells. Each piece in its place, all working together seamlessly, orchestrated by the standard spell-forms: linear flow, conditional, iteration, sub-spell, tail-recursion, continuation, combinators... Every part in its place, doing exactly what was required of it.

But this time, she was doing it with ideas. With the needs all ponies had: the need for something better, something greater. The need for a way out of whatever mess of a life they found themselves living.

Yes. It was just like spell-crafting... but with live ponies.

Starlight grinned.

It was going to be so perfect...

This capacity, the capacity to operate on spell systems via magic, is dependent on the ability to treat spells both as actions, and as data, interchangeably. Actions and data are treated equally. Neither is more essential or higher-ranking than the other. This is exactly what structured magic gives us. The spells are both the actions and the data, simultaneously. The two are one and the same.

Given this equivalence, we can even apply a spell to its own text... we can allow it to operate on itself, in an automated fashion...

... and this is where things start to go awry.

Just to give you a hint here, a bit of a preview: have you heard the one about the mane-stylist, who trims everypony's mane, except for those who trim themselves?

Does the stylist trim her own mane?

Moons later, Starlight stood on the hard-packed dirt street, in the middle of a barren desert, looking with pride at the two rows of skeletal houses under construction.

It was going so wonderfully. The ponies she'd encouraged to come here -- willingly, of course -- were happily settling into their lives. They were following the guidelines in her manifesto -- voluntarily, of course -- and not flaunting their talents in any way.

They were happy. Or at least, appeared to be.

They trusted Starlight enough to maintain the big, happy smiles she'd advised them to wear at all times. It was, she explained, a kind of sympathetic magic for the soul. If you held the smile long enough, some of it was bound to sink in sooner or later, lifting your spirits, right? It only made sense.

But Starlight knew she was behind schedule here. She'd figured she'd have time to crack the problem of extracting and storing cutie-mark magic on the way here. But one thing had led to another. There'd been supply issues, a few arguments to deal with -- friendly debates really, not disagreements, because there were no disagreements here. And there was the village layout to plan: what the standard house-style should be, who lived where. Plus providing supplies for her followers, way out here in the desert.

And on, and on...

Starlight sighed. Well, I'm a little behind, that's all.

What she needed was a shortcut, a way to buy back time in which she could get the cutie-mark spell ready. She needed a convenient place to store the extracted cutie-mark magic, keep it locked away. Then she could focus her effort on the cutie-mark extraction spell itself.

Some kind of stone, she decided. With appropriate resonance properties, so it can sustain a cellular storage grid.

Starlight was proud of having figured out that much of it at least, even with all the distractions.

Trouble was, she didn't know the first thing about rocks. Magic, yes. Rocks... eh, not so much.

Trotting around at the edge of town, trying to clear her thoughts, Starlight suddenly happened across an unfamiliar earth-pony mare. Slate-gray in color, wearing a steel blue frock and a hard-hat, the pony had an oddly placid, unruffled expression on her face. Solemn, but not sad, just... unexcitable. She seemed perfectly content with exactly who she was, and exactly where she was.

Maybe I should ask her to join us? Starlight thought. She's a natural!

The strange mare was expertly tapping at a boulder with a hammer in her teeth, apparently trying to collect a sample. Never look a gift hog in the teeth, Starlight thought, trotting over to her.

"Psst!" she whispered. "Do you know a lot about... rocks?"

The mare didn't even look up. "Yes."

"Have you ever come across some kind of super-powerful stone that could store the cutie-mark magic of... oh, I don't know... an entire village?"

"Yep." The mare pointed a hoof. "In the big cave."

Then she went right back to tapping away at the boulder, utterly focused and completely disinterested.

Starlight blinked, astonished.

Maybe I shouldn't ask her to join us... she's a little too good at this...

Without another word, she turned and hurried away, up the path the pony had pointed to. And quickly found the cave. And when she walked in, and saw the tall, flat-faced sheer wall of crystal at the back, everything fell into place.

It was perfect. She'd enchant the crystal with the storage grid spell, then find some stick or other in the desert, and claim it was an artifact to remove cutie marks.

And then she'd use the spell, her spell -- her magic -- to make them all truly equal.

Well, apart from herself, obviously. Somepony would need to be able to cast the spell. Especially if there were any new arrivals. But she'd figure out a way around that.

The point was, Starlight finally felt it was all coming together. It was like when she did the first roll-up on a new spell, converting it into its active form. That strong, reassuring sense that the thing she'd created was finally working, that all that remained were minor tweaks and adjustments.

And she'd thrown everything she knew into this one: Recursion, continuations, monads... all but one thing, the most complex spell-form of all, the spell that created recursive spells without using names...

The recursive combinator.

Because how could you eliminate a cutie mark, if you still had to call it something?

Starlight nodded. This spell was going to need that. To remove a pony's talents, you had to have a spell that could still work when the names went away. A spell that would hold back the connection the pony had with her own cutie-mark, that would use the pony's own magic to keep the two separated, denying the connection existed without ever actually naming it...

Because what was not named could never be spoken of.

It was going to be a challenge, Starlight knew. It would take a lot of drafts and debugging. But Starlight liked a challenge. It was what made the whole thing worthwhile.

It was what made magic fun...

On her way out of the cave, Starlight stumbled across a long piece of driftwood. She lifted it in her magic, turned it about. It was like a two-pronged pitchfork -- a huge, arcane-looking Y of dessicated flame-tree wood.

The recursive combinator, Starlight thought calmly, with absolute certainty. Plus my magic... and this stick.

No doubt about it. I can make this work.

Starlight nodded. It was all coming together.

I am the Bad Filly, she thought. And from here on out, nopony can stand in my way...

There's more than one way for a spell to refer to itself.

Among the twelve basic forms for spell construction, one of the most important is recursion. This is where a spell, as part of its operations, invokes itself. Now this might sound like a quick recipe for producing the kind of "hanging" error I mentioned earlier. If a spell invokes itself, doesn't it simply go on doing so forever, or until the magic runs out?

Not if you structure it properly.

A properly recursive spell does one of two things: either it determines there's nothing more to do and stops, or it performs one part of whatever its effect is, then invokes itself to do the rest. It's kind of like the children's song, Ninety-Nine Buckets of Oats: each time around, you remove one bucket, and then start the entire song over again with one fewer buckets, until they're all gone and you can stop.

The trick is, obviously, knowing when to stop. Sometimes it's easy to tell.

Sometimes, it's a lot harder...

... and you need a little help from a good friend.

Ahem, excuse me. Just a passing thought. Where was I?

Invocation of a spell is normally done via naming and calling. One spell invokes another by its name. In the case of recursion, the spell invokes its own name.

However, there are exceptional cases where one needs to perform recursion without defining names. This is where the recursive combinator is employed. You define a "step" spell that has a single parameter: an active spell to invoke. This "step" spell performs one "step" of a recursive operation. It takes down one bucket, so to speak. And then it invokes its parameter spell to do the rest.

The recursive combinator takes just such a "step" spell, and passes it an active reference to itself, thus producing a fully-recursive spell without the use of names. This is trickier than it sounds, actually, which is why it took so long for this spell to be derived. And as mentioned, the cases where it's needed are few. Yet they're important enough to make this a significant member of the twelve basic spell forms.

But there is yet another way for a spell to refer to itself. As I mentioned previously, a spell can refer to its own unrolled text, treated purely as data.

And this is where the entire game changes...

Late in the evening, Starlight shut the door of the small garret bedroom in Princess Twilight's Friendship Castle.

She gazed around at the room, still a little overawed. Twilight had offered her complete freedom of choice: any room in the Castle she wanted to call her own. And this one had seemed just right. It had an efficient little desk, a window, a comfortable bed, a bookshelf...

And no memories. It didn't remind her of any other place she'd been in her entire life. She could start anew here, clean slate. Start making some new memories.

She needed that.

Sitting at the desk, she stared up through the window at the night sky, at the friendly twinkling of the stars overhead.

It was still astonishing to her, how quickly things had changed. Only just that morning, she'd been utterly determined to destroy Princess Twilight, plus her special cutie-mark connection with her friends, as payback for their sabotage of her village, her plan for a perfect pony society...

Which... was totally the right thing for them to do, Starlight acknowledged. I was really over the edge, there.

By midafternoon, she'd come within a razor's edge of unraveling the entire timeline of Equestria itself, plunging it into a bleak, lifeless dust-bowl future. All in the name of vengeance, of retribution. She'd been convinced it was the only possible way to deal with the loss of control over her village, the loss of control over her destiny...

... the utter, miserable certainty that she was completely beyond redemption.

Twilight had stopped Starlight dead in her tracks, persuaded her to yield willingly, to give up her anger and distrust. And she'd done it not by force but by offering something Starlight had been certain she could no longer expect nor deserve from anypony:

Friendship.

Real, unconditional, non-judgemental friendship.

Twilight had listened to Starlight, understood the pain driving her. And, in spite of everything Starlight had done, Twilight had offered to be the friend Starlight needed, to help her find her way back.

She'd brought Starlight back with her to Ponyville, and spoken up for her to her own friends. And for the rest of the afternoon, Twilight and her friends had welcomed Starlight to Ponyville. They'd treated her like a family member, come home at last from a long voyage in a dark and distant land. They'd shown her the sights, been there for her every moment. They'd shown her kindness she knew she didn't deserve, and could never possibly repay.

And now here she was, Twilight's guest and her personal student. Here to learn about Friendship, as well as help out around the Castle wherever she could. Twilight hadn't placed any conditions or requirements on that. Anything Starlight felt like doing would be a help, she'd said.

It had all changed so suddenly, Starlight felt like a completely different pony. Mainly because Twilight and her friends treated her like one. Like somepony completely other than the horrible monster she'd turned herself into.

Starlight turned her head to look at her cutie-mark, the purple lozenge with its blue swirls.

And no longer understood it.

She hadn't mentioned to Twilight her fears about her cutie-mark... because she suddenly wasn't even sure of them herself. If I'm not the Bad Filly, she thought. If I'm not somehow being punished for the destruction of those spellbooks, my rebellion against Harmony, or whatever... if I'm not condemned to the kind of hopeless, twisted life I was sinking into, which up until yesterday I was certain was my only option... then who exactly am I now? What the hay does my cutie-mark actually mean?

What am I really meant to do with my life?

She had no idea any more.

What she did know was, she intended to make the most of this chance. She was going to study, learn about friendship, try her hardest to be that different, better kind of pony her new friends saw in her.

And maybe... just maybe... she'd figure it all out.

Starlight idly pulled open the desk drawer to have a look inside it. She found a blank journal, plus some fresh quills. And she smiled at that. It would be totally like Twilight to have snuck these in here, while Starlight was out today, on the chance she might want to use them.

But then again, maybe it was exactly what she needed.

With a strong sense of deja vu, Starlight pulled out the journal and quills, set them on the desk before her.

I'm going to do this right, she thought. I'll be organized from now on. Be methodical, take notes, learn from my mistakes. I am going to figure this out...

Flipping open the journal, she picked up a quill in her magic.

And settled in to write...

Okay, now this is the tricky bit. So with your kind indulgence, I'll take you through it step by step...

Day 1:
Became Twilight's student today. I have so much to learn, and the best examples to learn from. And I'm determined to make this work, to pay her back for her kindness in offering to be my friend.

The first thing I need to do, tomorrow, is figure out how to get around in Twilight's castle. This place is a lot bigger than it looks from the outside...

To begin with, any spell may be referred to by its unrolled text, or by a reference to its active form.

Similarly, the derivation of a spell can be referred to by the sequence of base components and forms, derivation rules, and intermediate steps required to construct it. By its existence in the system, this derivation proves the spell is valid and castable.

And remember too, spells are first-class objects in structured magic. A spell can take other spells as parameters, in either unrolled or active form. It can invoke the active form of spells to use their effects. And it can operate on the unrolled text of a spell, to check it.

Actions and data... one and the same.

So we can represent a derivation itself as a spell in the system, which derives its target spell. And given both spells and their derivations as spells, we can go on to automatically derive and check other spells.

Spells are like that.

They're like friends in a way. You can't have just one. Sooner or later, you end up having a whole lot more...

Day 20:
I still can't believe it. I just sent Sunburst a letter. Something I never thought I'd be doing, ever again.

Twilight's first friendship lesson actually worked. Sunburst and I are friends again! And we both got what we always wanted. He's a big important wizard in the Crystal Empire now, as Royal Crystaller for Princess Flurry Heart. And I have my oldest friend back, just as if we'd never been apart.

I'm really gonna have to buy Spike a gem sundae or something. That little guy is such a good friend. He never gave up on me. Without his stubborn, determined, annoying, exasperating persistence, this would not have worked.

I can see now why Twilight considers him her right-hoof dragon...

Day 50:
So, I made a new friend today. And yeah, Trixie is a little self-absorbed, I guess. But honestly, I think we have a real connection. We get each other.

Either that, or she's using me as some kind of pawn in a really long game, planning to get back at Princess Twilight. Biding her time then striking, when Twilight least expects it...

But what kind of pony would think like that, huh?

Muahahahaha...

Maybe that's why Trixie and I get along so well. We're both a little devious at heart...

Given that spells can operate on other spells, we can construct a spell,

Proof(S,x,y)

which given any spell system S, the unrolled form of a spell x, and a proposed spell derivation y, mechanically checks y for validity as a proof of x.

In plain language, it asks: is y a proper sequence of spells and derivations in S that ends in x?

This is straightforward to check, so I've left the text of this spell as an appendix to my thesis. But notice that this is our first example of a spell that operates on an entire system of spells, S, as a unit.

Also, I'd like to note in passing my indebtedness to Clover the Clever, for her Countably Concurrent Conjuration. It allows such exhaustive check spells to execute in something far quicker and more practical than geologic time...

Day 68:
Okay... as teachers go, Twilight is about as subtle as a half-brick through a window. That whole Hearth's Warming "story" about a twisted sorceress, who tries to use magic to destroy Heath's Warming, and is only talked out of it by three "spirits" who sound an awful lot like some of Twilight's closest friends?

Yeah. Uh huh. Riiiight...

But the Hearth's Warming Eve party itself was really nice, especially considering it was my first in like, ever.

Afterwards, I hunted around in the library for the book Twilight was reading from. And I can't find it. I'm tempted to ask Spike tomorrow where it is, just so I can see the smug look on his face and know I'm right. I'm pretty sure Twilight made the whole thing up on the spot, Pinkie-Pie voice and all.

And I'm really glad she did.

I hadn't realized how much I sometimes need a kick in the rump like that, to remind me to join in.

Plus, I had a really great time.

Maybe I'm finally getting the hang of this whole friendship thing...

Day 188:
Ugh, I thought I knew what I was doing here. But I don't. Spike was right. I totally missed the point.

I was afraid of failing at my friendship lessons, so I used magic to compel my friends to do exactly what I told them to, so I could get all five of my friendship assignments done at the same time...

And... wound up with a Friendship castle encrusted with cake batter and spiders.

I can only hope they'll all forgive me when I apologize tomorrow.

I really messed this up.

I keep falling back on magic to control ponies, when what I need to be doing is learning how to be a good friend. I don't know when to say when, and that keeps getting me in over my head. I should just stop using magic altogether -- entirely, cold turkey.

And I should never, ever be in charge of anypony ever again. I am not a good leader. I just don't know how to handle power.

And I don't want anypony to pay the price for it, ever again.

Day 210:
I said I should never be in charge of anypony. So what happens? Obviously, I end up leading a last-ditch effort to save Equestria from the Queen of the Changelings, Chrysalis herself.

Seriously? I didn't think anypony could even get that spiteful. Queen Chrysalis makes me look like Ms. Congeniality, even on my worst days.

Maybe I'm not the Most Evil Pony in the Land after all. Who knew?

Anyways, so now I'm a bit of a hero of Equestria, which isn't too shabby. And I helped turn most of the Changeling population into allies of Equestria, which isn't bad either. Plus, I feel I've finally, really made up with the ponies from my little village/cult. Which was kind of the best possible ending to a very stressful day.

Sigh.

Why is it I can't just make a pledge and stick to it? Why does Harmony or whatever keep kicking me off the wagon, forcing me to deal with my issues? I wish I knew.

But if I can handle being in charge, even if it's only a few of my closest friends... then maybe I can handle magic again, without it getting away from me.

I'll go grab one of Clover the Clever's old spell-catalogues from the library. Maybe write a spell or two.

But... little spells. Firefly spells.

Baby steps, Starlight...

Now, given we have a spell that checks proofs, it's not much of a stretch to construct another spell,

Derivable(S,x)

which uses it to determine whether a proof exists in S for a spell x, by exhaustive invocation of Proof(S, x, y).

Again, this is straightforward, so I've left the text of this spell as an appendix to the thesis.

Did I mention Clover the Clever was a really smart pony?

Anyways, moving right along...

Day 390:
Yeesh. Why don't I ever learn? I'm desperate to avoid losing Trixie as my best friend, so what do I do? I immediately turn to magic, use a spell to bottle up my anger so I won't flip out at her in a boiling mad rage. And end up with the magic running wild, nearly hurting some innocent bystanders, including Granny Smith. And I still ended up flipping out at Trixie. Because the only way to reclaim that loose anger was to channel it, let it out, as I should have done in the first place.

Just... not all at once.

At least nopony got hurt. And Trixie and I are still friends, and have a better understanding of each other. So, that's good. Plus, we got Twilight's map table back where it belonged in time. I don't think Twilight's found out about that. If she has, she hasn't said anything.

Even so, maybe it's just not safe for me to have anything to do with magic any more. I always end up overdoing it. Always end up having to clean up a big mess afterwards.

Day 420:
Well, I did it again. Without even thinking about it, I went with my gut and tried using magic to resolve the Royal Sisters' little... disagreement. By switching their cutie-marks so they each could see how the other half lives.

And nearly turned both of them into raging, power-mad versions of themselves. And nearly wound up a dream-world basket case myself.

That's it. I'm done with using magic for anything serious.

I just can't stop going overboard. I just can't handle it properly. It's not worth the risk.

Which really hurts. Because I'm so good at it. But that's the thing: I'm so good I don't know when enough is enough. I can't count on myself to stop when I should.

I'm never going with my gut again. Think first, then act. That's what I need to do.

One more screwup like this, and I could be in real trouble...

Day 510:
Urgh... I can't even win for trying. And I tried this time. I really tried.

Trixie and I go to the Changeling Hive, to visit Thorax, and try to help him with the issues he's having with his brother. So... thinking about it this time, I figured that we'd just talk to Pharynx, only talk with him, and try to convince him to change his mind.

And when that idea bombs, what do I do? Right away, I think of using my magic to switch around the trails of leaves the Hive had set out to lead the maulwurf away from them. So that instead, the maulwurf attacks the Hive, Thorax and Pharynx work together to save the day, and re-bond as brothers again. Hurrah, hurrah, happy ending all round.

Except... it all backfired, and nearly turned the Hive against both of them. I was just lucky Pharynx loved both his brother and the Hive enough to still want to defend them. And that the rest of the Hive showed up when they did.

Hmm... I did give the Changelings a rousing speech which in the end convinced them to gang together, to help out Thorax and Pharynx. And Trixie was right, it was kind of epic. I do know how to talk to ponies, convince them to do what they need to do...

Okay, from now on, I'm going to think first, talk to ponies second. And just not use magic at all. No more magic, Starlight. Talking, communication, understanding. That's what I really need to focus on here.

So... why doesn't it feel like the right answer?

And what would the right answer even look like?

Okay, now here's the kicker.

Given the Derivable() spell, we can construct a simple check spell, G(S, x), which merely negates it and hence tests whether a spell x is not derivable in system S:

G(S,x) = ~ Derivable(S,x)

This spell is valid by itself, since it's merely performing a test on a potential spell, returning logical true or false based on whether the spell is derivable or not.

But if we apply the spell G to its own spell text:

G(S,g)

Then we're in hot water, because we've created a check spell that amounts to the statement:

G is not derivable in system S.

If this spell was derivable by S, it would mean S is inconsistent, since the spell G produces an incorrect result.

Hence, G must not be derivable by S. But this means S is incomplete, because G is castable, and now produces a correct result.

So in one simple stroke, we've shown that the system S cannot be both complete and consistent.

At this point you're thinking, this has got to be just an exception, right? Just a weird corner case. Maybe it depends on a weakness in the system S of magic that we're using to represent and derive spells.

But the pattern I've just described, for deriving the spell G, can be applied to any system S of structured magic. As a result, no system of structured magic can be both complete and consistent, since it's always possible to construct a spell that is both evidently valid and castable, yet underivable in the system.

Ever have one of those days?

When a very simple idea just blows up in your face?

Day 540:
Would somepony please tell me why the universe seems determined to keep me off balance? Ensure that any strategy I settle on is immediately thwarted? Why can I never just make a plan and stick to it? I wish I knew.

But... I'm getting ahead of myself, here.

Today was... pretty amazing. I helped Twilight and Sunburst rescue the Pillars of Harmony -- including Star Swirl the Bearded himself, the most famous of all pony wizards -- from eternal imprisonment in Limbo. And I did it by nothing more than reading some illegible handwriting in one of Star Swirl's old journals, and applying a little of my magic when asked.

Then we had to fight off the Pony of Shadows, who'd also come back from Limbo along with the Pillars. That was... a little heart-stopping, to say the least. But it came out all right.

And in the process, I wound up schooling not only Princess Twilight herself, but also Star Swirl the Bearded... on friendship. By insisting we should talk to Stygian, help him choose to come back from the brink. By helping Star Swirl and the others understand that they wound up imprisoning both themselves and a good friend in Limbo for over a thousand years, all because they didn't talk to him, didn't reach out. They didn't stop to find out what drove him away from them...

... to seek answers all on his own.

I know what that feels like. Oh, don't I ever.

So, okay, maybe I do know how to keep a handle on things: by talking, and listening. Knowing when I'm going too far, before I get there. And using my magic to help out, where and when it's needed, and only as much as needed.

Maybe I can handle magic again.

Yeah, I know I keep saying that, and it keeps coming back to bite me.

But I can't just leave it be. My skill with magic... it's a part of who I am. Even when it gets me in trouble.

Whenever I try to deny that... it hurts.

But from now on, I'll only use magic for study -- only for research. I'm going down to Twilight's library tomorrow, get out some of my old textbooks on structured magic, and work on some theory.

Just theory, no practice. Pick a topic, write a thesis or two, just to keep my busy little pony mind occupied.

I mean it's not like I could get in trouble just studying magic, right?

Maybe, you're thinking, structured magic is the problem, and some other, more elegant method of deriving and checking spells wouldn't have the same flaw?

Nope. The same procedure can, with trivial modifications, be applied to any sufficiently expressive system of magic.

Any of them. No exceptions.

No system of magic can ever be guaranteed to be perfectly complete and consistent.

This is, I think you'll agree, a somewhat startling and disturbing result. I know it scared the crap out of me, when I first realized it.

Thankfully, as I mentioned at the start, I had some really good friends and guides to talk to about all this...

There was a gentle, polite rapping at the door.

Followed -- after a brief pause to remember whose door it was -- by a louder, insistent pounding of a hoof. Which finally got through to the ginger-maned, star-cloaked pony seated at the reading lectern.

Blinking in surprise, Sunburst turned and started to run towards the door. And caught a corner of his cloak with a misplaced back hoof, and went tumbling into a stack of books. Which collided with the overstocked case behind them, causing several more tomes to slide out and land on him as he groggily picked himself up.

Shaking his head, he moved to the door and pulled it open. And immediately broke into a smile.

"Uh... Starlight! What a surprise!"

"Hey, Sunburst." Starlight shrugged her carryall to a more comfortable position on her back, and nervously rubbed her shoulder with a hoof.

"Well, what brings you to the Crystal Empire? I haven't heard from you in weeks!"

"I know. And I'm sorry about that. I've been really focused on... well, my studies. So I haven't had time to write."

"Oh, that's okay. I figured it meant you were busy on something. Is it another project for Princess Twilight?"

"Not... exactly." Starlight grinned weakly. "This one's kinda my own fault. And I've been working so hard on it, Twilight recommended I take a little time off, get away from the books for a while. And so... I came up here. And since I was in the neighborhood I figured I'd... well, drop by to visit."

"Great!"

"If you're not busy?"

"No, not at all!"

"I'm not a bother?"

"Hardly! It's wonderful to have you!"

"Oh. Thanks." Starlight raised an eyebrow. "You gonna invite me in? Or are we gonna keep having this conversation on the front stoop?"

"What? Oh, sorry! Come in." Resettling his spectacles, Sunburst stepped aside so she could enter.

Starlight gazed around at his small house. At the utterly disheveled mess filling it: the scattered books, the used dishes and glasses sitting on table, desk, and lectern. The scroll paper scattered all over the floor, covered with half-crossed-out notes...

She sighed happily. "This reminds me of home, Sunburst. Seriously! You should see my room at Twilight's Castle after I've pulled a few all-nighters."

"Huh? Oh, right. Sorry about the mess. Uh, would you like something? Some tea, maybe?"

Starlight ended up making the tea herself for safety's sake, after giving the teapot and cups a thorough inspection and a pass with a cleaning spell. Soon the two of them were seated comfortably at the table, looking across it at each other. Sunburst was smiling, in that wonderful, slightly dotty way of his. A smile that said he very much wanted to be a good friend, and hadn't a ghost of a chance of figuring out how. Not by himself, anyway.

"So..." Starlight said. "What have you been working on lately?"

"You mean, like Royal Crystaller duties?" Sunburst beamed proudly. "I've been planning out a schedule of lessons for Flurry Heart, once she's old enough to really focus on more than the basics. And I'm also thinking ahead, coming up with an overall plan for her studies. It's exciting, actually. I mean, an alicorn has so much power to work with, and access to such a huge range of magic types: unicorn and pegasus and earth-pony magic. Figuring out Flurry's lessons is like, well, writing a symphony for a full orchestra. Having all the instruments available. Nothing held back! No limitations! Ahem." He blushed a bit. "Sorry. It's just such an honor. I really throw myself into the work, and I talk everypony's ear off who'll listen to me."

"I can imagine," Starlight said, and looked for a quick way to head him off. "But... apart from work. What else have you been up to. Like, for fun?"

"Oh, right! Well, I do have this pet project I've been working on as a sideline for a while now." He grinned sheepishly. "Actually, I've been kind of stuck on it lately. So it's great you came by. Maybe I could ask you to give me an opinion? See if you see something I don't?"

"Well... sure." Starlight nodded in surprise. "What is it?"

Sunburst eagerly levitated over a number of scrolls, as well as a large, heavy spell-tome. "You remember how as foals, we used to write spells together, using structured magic?"

Starlight nodded. "The one time in my life," she said, half to herself, "when I felt completely happy..."

"Right!" Sunburst said, not really paying attention. "And you kept trying to teach me how to approach magic the same way that you do, by viewing it purely as building-blocks, so the creation of a spell is in a way a purely mechanical process, freed from the imperative of a specific end goal."

Starlight stared at him.

"Is that what I was doing? Uh, never mind. I'll take your word for it."

"Well, after we met up again," Sunburst went on, "I got to thinking about that. And while working on Flurry's lesson plan, I found myself wondering whether one could do the same thing for magic itself. Just sketch out an entire, all-encompassing plan for structured magic. By which I mean, every possible spell would be constructed and demonstrated, completely by rote. Only spells that are valid and castable would be constructable in the system. And so, by simply turning the crank so to speak, working step-by-step, one could mechanically discover every possible workable spell!"

"Uh..."

"And I've made a lot of progress!" He shoved across one of the scrolls, pointing a hoof at a complex diagram. "See? I started with a tree of the various spell families: Light, shadow, dark, chaos. And now Twilight's friendship magic, too. And then I listed the various subtypes: luminance, levitation, healing, and so on. Then I analyzed the most basic spells of each subtype, the way that you used to do, organizing them by base components. I looked for patterns, found ways to rearrange them into a common representation. And then..." He waggled his eyebrows. "Then I really got to work!"

"Sunburst..."

"Here, take a look!" Dragging over the spell-tome with his magic, Sunburst eagerly flipped it open and paged through it. Hundreds of pages fluttered past before Starlight's gaze, each packed with dense formulae in a complex symbology. Which, nevertheless, had a certain overall pattern to it. Starlight could tell, even just at a glance. It was a careful process from simple to complex, defining terms using other terms, building up a sequence, a flow of reason, of castable spells.

It was beautiful.

It was magic itself...

Sunburst stopped at a particular page, pointed with a hoof. "See? I'm really proud of this one. Page 780: I'm able to show that the luminance spell, one of the most basic of light magic spells, isn't merely a spell that unicorns can do. It's pretty much implied by the whole structure of magic. If you can do magic, you can light up a room, Q.E.D.!"

"But... isn't that kind of obvious?"

"Sure! But this proves it, you see? It shows it's not just happenstance, not just luck or wishful thinking. It's guaranteed! It's real. It arises from nothing, yet it's as solid as this table-top." He rapped the table with a hoof. "I mean... wow! When I got to that point, I felt like it was all coming together. Like I could really do this!" Shutting the book, Sunburst grabbed it up in his magic and hugged it with his forehooves.

Starlight stared at him, uneasily. "But... you said you were stuck somewhere?"

Coming down from wizardly rapture, Sunburst put the book on the table, resettling his spectacles. "Well, yeah. You see how many pages it took to show a simple spell like luminance is constructable. Even with the notational hacks I've come up with, moving on to more complex spells is gonna be a lot of work. I worry that the system I've come up with isn't powerful enough, that I'll have to eventually redo it from scratch to make it better. So, maybe..." He looked wistful. "Maybe you might read through it? See if you can suggest something? Some way I can make the notation fully extensible so I can capture every spell, no matter how complex?"

Starlight winced.

"You can't, Sunburst."

"What?" Sunburst blinked. "Oh, I know it'll take a lot of work. And time. I might not be able to see it through personally. I might have to create a plan, find some students to carry it on after me, like a cathedral, a multi-generational project. But that's just organization, and I can easily handle --"

"I mean," Starlight interrupted, hating herself as she said it, "you can't get there, Sunburst. You simply can't! You can't capture every castable spell in a system like this."

"Huh?"

Starlight sighed. "Look, let me be honest with you. I didn't just show up on your doorstep for a friendly chat. I actually wanted to ask you to read something I came up with, give me your professional opinion. I was gonna just leave it with you, let you read it when you had the time, but..." She gritted her teeth. "Maybe you should read it now. Like, right now!"

"Well... sure!"

Starlight dug into the carryall sitting beside her on the floor, and brought out a copy of the thesis she'd shown to Twilight. The booklet was comically slim compared to the hulking mass of Sunburst's spell-tome.

Sunburst resettled his spectacles, opened the thin volume before him on the table, and read. And read. And kept reading, turning page after page with an intense, focused stare.

While Starlight kept her forehooves pressed firmly to the floor, to stop herself from biting them.

As he read, Sunburst's eyes went wide. His mouth dropped open. He read faster, turning pages at increasing speed. His eyes darted over the pages, over the careful, neat symbology that Starlight had come up with to demonstrate her work with precision and clarity... and in the process fling a very carefully and precisely constructed spanner into the immense, complex machinery that Sunburst had so painstakingly worked out.

Sunburst came to the end of it. It hadn't taken long at all. He looked up, grinning dazedly.

"Sunburst?" Starlight asked, nervously. "Are you okay?"

"What? Oh, sure!"

"Then I didn't screw up somewhere? I checked it over myself. Even had Twilight give it a look."

"Oh no, not at all! It's iron-clad, Starlight, from what I can see. And you're absolutely right. It isn't possible. For any mechanically-derived system of magic, you can always come up with an evidently castable spell that the system itself can't derive. You can always turn the system back on itself, using its very certitude to derive a fundamental contradiction."

He stared at the heavy volume on the table, amazed. "So all this, this pile of magical doodlings... it really is just a pipe dream," he whispered. "An El Dorado... just like in the Daring Do stories..."

Starlight grimaced. She wanted to cry. "I'm so sorry, Sunburst..."

He stared at her, amazed. "For what?" He broke into a huge smile. "Starlight, this is great!"

"It is?"

"Yeah! This is exactly why I was feeling stuck! I kind of knew in my heart of hearts that there was a fundamental flaw here. But I didn't know where to begin to look for it. And every time I sat down and managed to work out yet another page of this thing --" he thumped the volume with a hoof. "I felt I could get there, with only a little more effort. I felt false hope."

He pointed at Starlight's thesis.

"But this, this is the proof I was looking for. This tells me I can give it up, stop beating my head against the wall, and move on to something more productive."His smile turned damp-eyed with gratitude."Thank you, Starlight!"

"What?" Starlight shook her head. "I undermine structured magic itself... drive a stake through the heart of your personal pet project, your pride and joy... and you're thanking me?"

Sunburst laughed, and shook his head. "It was only a project, Starlight. Just a notion I was working out. Though, granted, perhaps in more detail than average."

"Really?"

"Sure!" Sunburst shrugged. "I mean, yeah, it hurts a little learning it's not possible. But that's okay! I don't define myself by projects like this, Starlight, by what I try to accomplish. I define myself by what I can actually do, by the things I know and learn. And you haven't hurt me, if that's what you're worried about. Far from it! I've learned something, something I never would have seen on my own. And I'm grateful for that. Really grateful. Plus, I'm grateful for something else, too..."

He removed his spectacles, polished them with a corner of his robe, and then put them back again.

"I'm really grateful that it was you who showed this to me, Starlight. My best friend, and a pony I consider a true colleague in magic. Not some random, self-important mage. A friend, who can let me down hard, but also cares enough about me to tell me personally, and worry about how it'll affect me. Thank you, Starlight."

Starlight stared at him, her mouth open. "Uhhh... you're welcome? Glad I could help? Wow." She shook her head. "I guess I was afraid that I'd done something horrible again. That I'd blown a hole in magic itself, brought the whole thing down in a shambles. That anyone with an ounce of experience in magic was going to hate me for discovering this, for raining on their parade. But if you don't feel like that...?"

He shook his head confidently. "Not a bit!"

"Then... maybe it's okay I figured this out..."

"More than okay," Sunburst nodded. "This is, like, the discovery of the decade! Maybe even the century! This is mage-level stuff, Starlight!"

"Yeah, well..." Starlight blushed. "I do seem to have a knack for that sort of thing, messing around with magic the way I do..."

"Absolutely! And if you want, I'll give it a more thorough re-read, give you editorial notes. I can also help with getting it written up for publishing, putting together a formal presentation."

"A presentation?"

"Definitely! Because when the mages read this, they're gonna want to hear about it straight from the pony's mouth -- from the author herself!"

"Woah." Starlight looked worried. "I'm gonna have to think about that. Maybe ask Twilight if I can borrow her slide projector." She shook her head. "But that's tomorrow's worry, not today's." She grinned. "Thanks, Sunburst. I think Twilight really had the right idea, suggesting I talk to you..."

Starlight's eyes went wide, and she clapped a hoof to her mouth. "Not... that it wouldn't have been my first thought," she added quickly. "If it hadn't been such a long train-ride to get here, and I hadn't been so wrapped up in my usual panicking over nothing and... well, you get the idea..."

Sunburst just smiled understandingly. Then he thumped the table with a hoof. "Well!" he said. "Now we've gotten all that sorted out, got both of our respective puckwudgies off our backs, what do you say we take a break, do something fun for a change? Spend some time together, like we used to. After all, you did say Twilight gave you some time off. Er, how long do you have?"

"She didn't say, exactly," Starlight replied. "But you know Twilight. As long as the work gets done, whenever is soon enough."

"Great! So... what would you like to do?"

Starlight bit her lip. "You... wouldn't happen to have that copy of Dragon Pit I sent you for Hearth's Warming?"

Sunburst reached under the table and pulled it out. "It's a little dusty," he explained, "only because I can't talk anyone else here into playing it. And Flurry, she's still too young." He grinned. "You want to be red or blue?"

"Oh, you know me..." Starlight said, grinning. "I'll take red, like always."

"Huh?" Sunburst stared. "But... I thought you always played blue! I..."

Starlight smirked.

"Gotcha! You never know what's gonna happen, right?"

Sunburst stared at her, gobsmacked.

And then burst into laughter. So did Starlight.

It was so good, being with an old friend again...

If I might speculate just for a moment, this discovery has serious implications, both in the discipline of magic, and in the broader realms of philosophy:

On the one hoof, it seems to indicate that pony magic is not formally representable in a complete, consistent, automatable fashion. Our ability to construct and cast spells will outstrip any mechanical attempt to represent and verify them. But this means, as a result, that there are inherent limits to our ability to reason about, and to validate, our own magic.

On the other hoof, pony magic might actually be formally representable. But then this implies there may exist spells that are not constructable and castable by any pony. That there are practical limitations on who we are, as magic users.

Neither of these is a particularly palatable outcome. But this does not, I would hasten to add, suggest abandoning the effort of systematizing magic as we are trying to do. Rather, it may mean having to take a more nuanced approach to determining what, in fact, we are able to say with precision about magic... as well as about our own capabilities.

This, I would imagine, will provide fertile ground for future research efforts...

All was hushed, in the Canterlot Archives' main lecture hall, as Starlight concluded her presentation.

Starlight paused to take a breath and a sip of water, while looking out at the audience gathered in the hall: mages, wizards, sorcerors, hailing from all corners of Equestria, and even beyond. Pretty much anyone who was anyone in magic, seated in the shadowy ranks before her.

Including Star Swirl the Bearded himself, front row center. The most famed wizard of all time was looking on with that austere, slightly unearthly calm with which he viewed everything passing beneath his lofty, bewhiskered gaze.

"So, that's the theory," Starlight went on. "And now it's time for the practical. In this, I'm indebted to my friend and associate, Sunburst, who has graciously consented to allow me to use the text of his own formulation of structured magic as a concrete example."

She smiled at Sunburst, seated beside Princess Twilight in the front row. Then, with her magic, Starlight lifted the heavy volume from the lectern before her, and held it in midair for all to see.

"We have System S," she motioned with Sunburst's text. "And we have spell G, instantiated based on system S, and applied to its own spell text." She lifted a small spell-scroll, held it aloft as well. "For demonstrative purposes I've taken the liberty of adding a small wrapper spell, which if G returns true, will invoke an indicator spell, in this case simple luminance."

She gestured to the presentation screen, on which the wrapper spell was displayed:

G'(S) = if G(S) then Luminance

"We invoke spell G..." she said, charging her horn and launching a beam of magic at the scroll. This in turn directed its own rainbow cascade of magic at the spell-text.

There was a brief pause, in which nopony spoke, nopony breathed.

And then the spell scroll slowly, gently -- but definitively -- glowed.

Starlight exhaled in relief. She'd done it before, she knew that it should work. But you never know... demo or die, as they say.

"As you can see, the spell is valid and castable. And it invokes the luminance spell. Hence G is not derivable in System S, so system S is incomplete. And, since the same procedure may be applied for any such system, any system of magic derivation is necessarily, provably incomplete.

"This concludes my practical demonstration. Thank you all, for your time and attention."

Silence held for a few moments.

And then there was thunderous applause, a deafening hammering of hooves, throughout the vast hall.

Except for Star Swirl. Who rose, eyeing the audience. And then slowly, austerely mounted the stage, and turned to face Starlight. The room swiftly fell silent again. All eyes were on him.

"Miss Glimmer," he said calmly, magisterially. "Not too long ago, you taught me a valuable lesson. About listening, about understanding, about hearing what one has ignored, seeing what one has missed. And now you have come to all of us with an observation about magic that, somehow, none of us have thus far seen..."

Starlight's heart stopped. He's seen something, she thought, some mistake, some loophole. And he's going to take me to pieces, one careful, irrefutable stroke at at time...

But Star Swirl's eyes were twinkling.

He nodded. "I find it most agreeable, Miss Glimmer, given your... shall we say... difficult journey coming to this conclusion, that it should be a pony such as yourself who makes this discovery. Not some closeted academic, but a pony of the world. Who has dealt with issues few of us have had to face, and come through them, I might add, with flying colors."

He glanced at the audience -- slowly, steadily, as if daring anyone to speak.

"If there are no objections," he went on, "I would suggest this discovery merits proper accreditation. And a fitting place amongst the ranks of professional mages..."

He looked back at Starlight, and held out a hoof.

"Congratulations... Magisteria Glimmer."

Eyes wide, mouth gaping, Starlight weakly shook his hoof, as applause rose and filled the hall again.

Then Star Swirl leaned closer, a smile quirking his beard. "And now, Mage Glimmer," he whispered, "what do you plan to work on for an encore?"

"I'm so happy for you, Starlight!" Twilight said, grinning ear to ear. "Even I don't rate the title of Mage. I only finished one of Star Swirl's spells. And then I became an alicorn Princess, which kind of limits one's academic career, as you might imagine."

The two of them were seated in Twilight's library, and Spike had just served them mugs of warm, soothing cocoa. Starlight nodded. "Thanks, Twilight. But I gotta ask... just how much of that did you plan?"

Twilight shook her head. "Very little, actually. I didn't actually know Sunburst was working on a system of structured magic. I only knew he was really good at spells and would be a good sounding board for you. And the title?" She shrugged. "I might have mentioned to the right ponies that my personal student had completed work on her thesis and had an important result to share with the Research Group. But having you give the guest lecture at the All Ones Anniversary forum was entirely their idea. Though I'll bet Star Swirl had something to do with it. And I certainly never suggested they treat it as your thesis defense... but I'm not about to object either, not at all. You're an excellent student, Starlight, and a great friend. I think your work and your accomplishments speak for themselves."

"Thanks again," Starlight said bashfully. And then looked mildly nervous. "This... doesn't mean I'm going to suddenly sprout wings and turn into a Princess, does it?"

"Not likely." Twilight giggled. "Though if you save Equestria a couple more times, then you might have to worry."

Starlight nodded, and sipped her cocoa for a bit.

"Twilight," she said at last, "I owe you... all of you, so much. If there's anything I can do to pay you back, even in some small way..."

"Well..." Twilight said, glancing about conspiratorially, "there is something you might do. Though you need to promise to keep it hush-hush for now. I did have this idea in mind for a School that would teach the principles of Friendship to anyone who wants to learn. And I could use some help organizing the rules and curricula. And who better to do that than my very first customer: my own personal student?"

"Wow," Starlight nodded. "Okay, sure! Mum's the word, and count me in!"

"And," Twilight went on, "I could really use a pony who listens, who understands, who can help others, for the position of School Guidance Counselor. And given how far you've come, I can't think of a better pony for the job."

She held out a hoof. "Does that suit you... Mage Glimmer?"

Starlight thought about it, and then shook hooves with her. "I think it suits me to a T... Princess Twilight!"

"Don't you mean a G, Miss Glimmer?"

They laughed, and went on drinking their cocoa.

And Starlight glanced at her cutie-mark. The diamond for magic, and the blue swirls... Perhaps showing her reaching out beyond magic? Reaching out, listening, helping others? Being more than just a spell-caster, being a true friend...

A school counselor, maybe? Is that what it means?

She mentally shrugged.

Eh. It'll do for today. I can come up a better explanation tomorrow...

The End

My Little Pony: Friendship is Magic, its characters and indicia are the property of Hasbro.
No infringement is intended. This story is a work of fan fiction, written by fans for fans of the series.

Author's Note

For the curious, here's a number of links/books on the real-world topics that Starlight's structured magic "thesis" is based upon.

Gödel's Theorem:

Starlight's thesis is primarily based on Godel's Incompleteness Theorems, which state that no sufficiently powerful system for representing and proving mathematical theorems can be complete and consistent. Here's some good references on Godel's theorems and related topics. (Gödel, Escher, Bach in particular is a fun read -- don't let the length scare you, it's nicely parcelled into readable chapters and entertaining dialogues.)

Quanta Magazine: "How Gödel's Proof Works"

Gödel's Proof, by Nagel and Newman

Gödel, Escher, Bach: An Eternal Golden Braid, by Douglas Hofstadter

Turing, Turing Machines, and The "Halting Problem"

Since structured magic is somewhere between (and has features of both) logical proofs and software development, Starlight's result is also connected to computability theory, and the "halting problem": the question of whether it's possible to write a program that determines, simply by looking at a program's text, whether the program will or will not "halt" -- that is, always complete and produce a result.

Alan Turing demonstrated that it is not possible, that is there are programs where it's not possible to determine whether they halt.

Turing used a fictional computing device (the "Turing Machine") to demonstrate his result. Alonzo Church used a mathematical formalism called the "Lambda Calculus", which has similarities to a programming language. These two formalisms, together with Gödel's concept of a "general recursive" function, are essentially equivalent (this has become known as the "Church-Turing Thesis").

Some references on these topics are:

The Halting Problem

Turing Machines

Lambda Calculus:
An Introduction to Functional Programming Through Lambda Calculus, by Greg Michaelson

The Church-Turing Thesis

Programming Languages: (Functional and/or Strongly-Typed)

I envision structured magic having a lot in common with functional and/or strongly-typed computer languages. A couple prototypical examples of such languages (there are others, of course) are Lisp/Scheme, and the strongly-typed language Haskell.

Lisp/Scheme in particular is a great example of a programming language in which the programs and the data are essentially the same. The syntax is based on Church's Lambda Calculus, though as a programming language it's much more practical and fun to use.

Haskell is a strongly-typed functional language, which means it will refuse even to compile (aka "roll-up") a program if it's not properly written (specifically, if arguments to functions are not of the proper types). It takes work to learn, but that's because it really stretches your concepts of what a programming language is, so it's well worth learning if you're into programming languages.

The Scheme Programming Language, by R. Kent Dybvig

Scheme Programming Language

Learn You a Haskell for Great Good! (Haskell programming language tutorial)