1. In a computing environment comprising at least one processor and one computer-readable storage media, a method for inferring formula patterns in an arbitrary formula using mixed second-order pattern matching, the method comprising: accessing the arbitrary formula; instantiating each first-order place-holder in the arbitrary formula by one or more sub-formulas or one or more sub-terms; checking that multiple instantiations of each sub-term and each sub-formula coincide when instantiating a same pattern variable; instantiating each second-order place-holder in the arbitrary formula by making a substitution for each function and each relation symbol found in the arbitrary formula; associating each bound identifier with a permutation, the permutation of the bound identifiers being in the scope of strong or weak second-order variables or function symbols; and, instantiating any second-order place-holders in the arbitrary formula by one or more known functions or one or more known terms.