Implement `semantic predicate` feature

(cherry picked from commit 1ae8c8f06b52c7bd13e49f52c4bbd3b2e9c217c4)