If you're using dried lentils, cook them in plenty of water until just soft, drain them, and save the cooking liquid. If you're using tinned lentils, drain them and save the liquid.
While the lentils are cooking, sauté the onion, garlic, basil and cayenne pepper in oil until soft, but not brown.
Add the carrot, pepper and mushrooms. Cover and cook over a low heat for 10 minutes or until the carrot has softened. Add the cooked lentils, tomato puree and seasoning. If the mixture is very thick, add a little of the reserved liquid from the lentils.
Cook the mixture for a further 5 minutes and then transfer it to an oven-proof dish. Cover it with mashed potato and sprinkle with grated cheese. Bake it for 30 minutes in a moderate oven, until the top is golden-brown.