My little Havanese is very quick to study his environment, and draw conclusions.
I live in a senior residence, with a door controlled by a ring to my cell phone, which requires me to push 9 to release the lock.
Smart little guy figured out that when my cell rings, and I do not talk on it, but push the 9 - someone is coming to visit, which means the possibility of treats. He gets very excited, and runs to the door to wait. My talking on the phone disappoints him, as it isn’t paired with a visitor (treats).
Also, when I was potty training him - (a treat for doing a “good job”), he decided that the triumphant hind leg scratch-dance just might be related to the appearance of treats.
Now, when he really wants a treat, guess what he does? A wonderful hind leg scratch-dance, with a happy expectant look on his little face!
I love dogs - particularly those who try to understand our behaviors.