If we generate a not-join clause that lists three variables to join, e.g. (not-join [?e1 ?e2 ?e3] ...), and only two of these variables are referenced in the body of the not-join clause, we'll get the following error when we execute the query:
"Join variable not declared inside clauses"
This seems to happen even if all the joined variables are bound outside the not-join clause. Therefore, when we generate a not-join clause, we should omit lvars not used in the clause's body from the list of lvars to join.