From what I see, the following and-clause :
[(and
[(< ?d ?next)]
[(> ?d ?today)])]
should not be inside square brackets [] . If that’s the case, could also remove and as well, because at the top level it is implied.
Seems like this is an old issue.