I'm exploring program synthesis systems such as Rosette, where you describe a function through constraints or a formal specification and the system generates an implementation. For a simple example like squaring an integer, the specification might be written as ∀x∈Z, f(x)=x². That seems just as difficult as writing the function directly, so I'm trying to understand where the practical advantage appears. Is synthesis mainly useful for complicated conditional logic, many edge cases, or situations where the desired behavior can be described more easily than the implementation?
4 Answers
It’s best understood as a higher-level, declarative way to express a program. In ordinary code, you describe both the result and the procedure used to obtain it. With synthesis, you can focus on requirements such as valid outputs, invariants, and relationships between inputs and outputs, while the system handles the lower-level construction. That is not especially helpful for a one-line function, but it can be valuable when the implementation is tedious and the requirements are easier to state than the algorithm.
A specification is also independent of the target programming language. You describe the intended behavior once, and the synthesizer can search for an implementation in whichever language or representation is appropriate. That separation can make the same requirements reusable across different environments.
Synthesis encourages you to define behavior before getting lost in implementation details. Instead of deciding every operation and control-flow step yourself, you state the requirements and let the tool find an implementation that satisfies them. Of course, the specification still has to be precise, and the search may be expensive.
The benefit usually isn’t visible in tiny examples like squaring a number. It becomes more useful when the behavior involves lots of conditions and edge cases. A compact specification can describe what must be true, while manually writing and debugging all the implementation paths can become much more complicated.

So the key difference is that the specification can remain small even when the implementation needed to satisfy it is large or language-specific.