To make the sauce, heat the butter in a pan, then gently fry the onions, carrots, celery and garlic for 15 mins until soft and golden.
Turn up the heat, add the mushrooms and the tomato purée, then cook for 4 mins more.
Stir in the herbs, then add the lentils.
Pour the wine and stock into the pan - it's important that you do not season with salt at this stage.
Simmer for 40-50 mins until the lentils are very soft.
Now season to taste and take off heat.
While the lentils are cooking, tip the potatoes into a pan of water, then boil for about 15 mins until tender. Drain well, mash with the butter and milk, then season with salt and pepper.
To assemble the pies, divide the lentil mixture between all the dishes that you are using, then top with mash.
Scatter the cheese over.
Heat oven to 190C/fan 170C/gas 5, then bake for 30 mins until the topping is golden.