Program Testing and Synthesis by Program Semantics