Unfortunately you may already be past the point where you can easily prove he did not contribute to the project. Even if you can show he did little to no useful work, the fact that you both allowed him to continue to claim the work as partially his own in order to pass a course will make it hard for you to prove that he doesn't have any ownership claim to the IP of the project.
This will come into play if, later, you do find success and he chooses to sue you. There are many high profile examples (facebook, for one) of founders coming back for a share of the company even after they were "let go".
When you let him go, be up front, explain why, and ask him what, if any, claim he feels he has to the project. If necessary go over the code.
If possible, work with a lawyer in the formation of the company and explain the situation.
The best possible case probably won't happen - where he completely signs over any and all claim he had to you without recompense.
However, once you've explained to him how little he's contributed, and received his side of the story and how much he believes he's contributed, you should then give him a share of the company.
If your case that he contributed little is strong, he should be willing to settle for a single digit fraction of the company or less. Tell him you don't want him to provide further work. Document everything he has so far contributed, and as part of the contract that gives him a small share indicate that he accepts he has no further claim or interest in any of the IP, he signs everything away to the company for its exclusive use and ownership. Further, you should consider making sure his share does not provide him any voting or administrative rights.
Having done that, you should have a pretty strong case if he does attack you later. Yes, you lose a very small portion of the company, but it may prevent a much larger share being taken by the courts later if you do succeed. Further, at some point you may be able to make him an offer to buy out his shares soon after formation or initial investment. Having an interest in the company and selling the shares later only solidifies his acceptance of the situation, and will provide adequate proof that he felt he was compensated appropriately for his early efforts.
If you succeed, you will still make significantly more than him, and the small amount you lose should simply be considered part of doing business.
It's probably a small risk, but he'll be much more likely to accept and sign such documents now than after the company is formed, so do this as early as possible. Then buy out his interest as early as possible.
Also, consult with a lawyer and have them write everything up. If your company isn't that far along, then at least write down every contact you have with him regarding the business. You can make and sign informal agreements, but be careful - poorly written agreements may actually show him to be, in the eyes of the legal system, to be a more significant founder than he is.