Animal Cognition confirms that dogs are more likely to steal food in the dark, even after they were told not to, when they know there's a better chance that humans can't see what they've done, than when it's light in the room.
That proves that dogs have what is known as a theory of mind. In other words, they understand that humans, or any other animals for that matter, have different feelings, thoughts, or perspectives than they do, and it's up to them to try to figure out what those perspectives are. In the case of food stealing, they know, since they were already told, that they're not supposed to take the food. But since it's dark in the room, and they think that no one can see them taking it, they know there's a good chance they won't get caught. All of that thinking, planning, anticipating, and basing their behavior on what the other person is thinking and seeing and what the other person may or may not do shows the remarkable intelligence--and sneakiness--of the dog.