1. A method for synthesizing a computer program by a hardware processor and a program synthesizer, the method comprising: representing program components and registers by position set variables and constraints on the position set variables using Monadic Second-Order Logic; determining potential combinations of the program components by solving the constraints; and forming the computer program from at least one of the potential combinations.