Answer-Set Programming is here:
http://pcgbook.com/wp-content/uploads/chapter08.pdf
Thanks for link anyway. Yeah, it's a subset of my approach but a good one for clear intro to subject. As they were describing it, my mind drifted back to attempts at automated programming. I've seen recent work under banner program synthesis. In any case, I was thinking how they specified facts & constraints to force generation of results could be applied to software-rewriting. You start with unsafe code expressed with certain meaning/semantics, extract those as abstract rules, and then use them + safety heuristics to synthesize equivalent program that's safe.