I have created a test map for you, hope it's what you want.
You actually have 2 spells, 1 for the spell itself, and 1 more is just a dummy (used for learning the spell)
When you learn Spell A (Dummy), Spell B (True Spell) will be added/leveled up.
When the spell reaches maximum level, it will disable the spell to be learned ever again for the player, not for that unit.
Basically this method supports up to 12 units, 1 unit per player and it is called as MPI, not MUI.
So you can't have more than 1 unit per player using this method.