Support for querying rules that have a heads/bodies with a certain form.