annotate_kodkod_constraints(greedy, b(Node,Type,Info), VarsAcc, NewVarsAcc, AnnotatedAst) :-
functor(Node, _, Arity),
Arity == 2,
arg(1, Node, Lhs),
arg(2, Node, Rhs),
\+contains_higher_order_or_int_ast([Lhs]),
\+contains_higher_order_or_int_ast([Rhs]),
!,
annotate_constraint_for_kodkod(b(Node,Type,Info), VarsAcc, NewVarsAcc, AnnotatedAst).
annotate_kodkod_constraints(preferred, b(Node,Type,Info), VarsAcc, NewVarsAcc, AnnotatedAst) :-
functor(Node, Functor, _),
preferred_by_kodkod(Functor),
!,
annotate_constraint_for_kodkod(b(Node,Type,Info), VarsAcc, NewVarsAcc, AnnotatedAst).
annotate_kodkod_constraints(AnnotationType, b(Node,Type,Info), VarsAcc, NewVarsAcc, AnnotatedAst) :-
functor(Node, Functor, Arity),
Arity == 2,
arg(1, Node, Lhs),
arg(2, Node, Rhs),
!,
annotate_kodkod_constraints(AnnotationType, Lhs, VarsAcc, VarsAcc1, ALhs),
annotate_kodkod_constraints(AnnotationType, Rhs, VarsAcc1, NewVarsAcc, ARhs),
NNode =.. [Functor, ALhs, ARhs],
AnnotatedAst = b(NNode,Type,Info).
annotate_kodkod_constraints(greedy, b(forall(Ids, Lhs, Rhs),pred,Info), VarsAcc, NewVarsAcc, AnnotatedAst) :-
\+contains_higher_order_or_int_ast([Ids]),
\+contains_higher_order_or_int_ast([Lhs]),
\+contains_higher_order_or_int_ast([Rhs]),
!,
annotate_kodkod_constraints(greedy, Lhs, VarsAcc, VarsAcc1, ALhs),
annotate_kodkod_constraints(greedy, Rhs, VarsAcc1, NewVarsAcc, ARhs),
AnnotatedAst = b(forall(Ids, ALhs, ARhs),pred,Info).
annotate_kodkod_constraints(greedy, b(exists(Ids, Pred),pred,Info), VarsAcc, NewVarsAcc, AnnotatedAst) :-
\+contains_higher_order_or_int_ast([Ids]),
\+contains_higher_order_or_int_ast([Pred]),
!,
annotate_kodkod_constraints(greedy, Pred, VarsAcc, NewVarsAcc, APred),
AnnotatedAst = b(exists(Ids, APred),pred,Info).
annotate_kodkod_constraints(_, Ast, VarsAcc, VarsAcc, Ast).