&gt; Practice, experience and good heuristics help, though. And if they don&#x27;t, then you redesign the formal system until they do.<p>I&#x27;m not sure anyone really understands the cognitive processes behind doing math. But maybe?<p>&gt; The desired invariants (see below) and complexity bounds for your code will tell you what data structures might be more convenient than others.<p>I rarely write code where I even need to think about complexity bounds! I&#x27;d be surprised if that was a dominating concern for even a significant fraction of programmers (systems HPC programmers, for sure, but...UI programmers?).<p>&gt; Only if I can&#x27;t see what the invariants are, then I might use some examples to generate plausible candidates, but the job isn&#x27;t done until I have found and confirmed the invariants themselves. In other words, I don&#x27;t conflate “works for these few examples” with “works in general”.<p>We don&#x27;t. But you need to start somewhere. Don&#x27;t underestimate the value of a few good examples in the problem solving process.