In a large saucepan, heat the olive oil and in it sauté the onion, celery, and carrots over moderately low heat until soft. Add the cumin and garlic, stir, and sauté 1 minute longer.
Add the lentils, ham hocks, stock or water, and tomatoes and bring to a boil. Lower the heat and simmer, partially covered, until the lentils are tender, about 1 hour.
Remove the ham hocks and shred the meat, removing all fat and gristle. Reserve the meat.
Purée about half the lentils and return to the pan.
Add the ham, the spinach, lemon juice, salt, and pepper to taste and simmer for 15 minutes. Serve in heated bowls.