Framework for Synthesis by Unfolding of Declarative Programs