On rewrite programs: semantics and relationship with Prolog