Do mares and their foals recognize each other after spending a few years apart?

Example: If a 6-months-old foal is sent to another farm to be raised and trained, and returns to his mother’s farm when he is 3 or 4 years old, will they recognize each other?

In your example, perhaps the mare would not – but for the same reason you might not recognize your own child if she was taken from you at 2, and – ten years later – showed up at your door selling Girl Scout cookies as a 12 year old.
Relatively speaking, this is approximately the scenario you have outlined from the horse’s perspective (sans the Girl Scout cookies).
As a teenager, I raised and trained a horse I would later have to part with during college.? It broke my heart at the time, as these things do.
Over ten years later, I happened to have the opportunity to see him again – the first time in all those years.? An Arabian, he had become snow white – and only for this reason did he recognize me a second or two before I recognized him.
Horses are often informally compared to three year old humans in terms of intelligence, but this is a bit misleading.? Not being humans, it is difficult to compare.
But in terms of retaining lessons they have learned, I would argue horses are the more capable (at least compared to my three year olds, who, of course, were above average).? Horses are very social, sensate animals – they have a real need for relationships, and wither without them.
Combined, these qualities explain their uncanny capacity for remembering close friends and associates – whether herd-mates, off-spring, or people who have been close to them.