Certain program analyses can be encoded as Chain programs (corresponding to context-free languages), which belong to a restricted form of Datalog programs. Each rule in a chain program has the following format:
p(X,Y) :- q0(X,Z1), q1(Z1,Z2), q2(Z2,Z3)…, qn(Zn,Y)
My question is whether Z3 can take advantage of the structure of the chain programs and be more efficient in evaluating chain programs in comparison to evaluating arbitrary datalog programs.
Z3’s finite state datalog engine uses bottom-up evaluation.
It includes an option to perform magic set transformations that can be enabled.
This transformation does wonders in some cases involving chain programs.
You can enable the option by setting “:magic-sets-for-queries” to “true”.
Hope this helps