Even in the Equine class horse is at the bottom of the list, ponies, mules and donkeys are all much smarter. Smartest one I ever ran across was a pony/donkey cross. Sturdy and smart with a gate like a jackhammer. As a pack animal though she would walk any other animal into the ground and then dance pass their prone bodies saying "Nah, Nah, Nah you sissies!"
Now goat is ahead of cow though. Little trouble makers.
So pig, goat, cow, horse, duck, chicken, sheep. Just my opinion, your millage may vary.
`
As farmers, we always did the gate test to determine farm animal intelligence.The heifers and cows, et alii, would be in the pasture with a loop-lock gate, just a rope on a nob. Lift the rope and you are out, The cows failed miserably, not a one. The pig could open and reloop it/ The horse, an Arabian, always lifted the loop with his mouth. Ditto for the goat. The chicken was too small but there is a video on utube showing a chicken opening a door. There is also a video on same showing 3 women who failed the swing-do-not lift gate test.
Thus the gate ranking is:
1. pig
2. Horse
3. goat
4. chicken
5. cow
6. woman
7. goose