Bug in setof? -- findall works but setof doesn't find dynamic predicate

There’s some discussion about the “exists” notation and other nuances of findall/setof (and other aggregators) here:

As a general rule, there shouldn’t be any “unused” variables in a predicate to findall/3, bagof/3, setof/3 – use an auxiliary predicate if necessary. And be especially careful of “_” in the predicate to findall/3 et al – in that context, it almost never does what you think it does. :wink:

2 Likes