Please move this work to VM directly and do at least the following changes:
remove a global state. Currently if during execution of the same program in two different circuits the same variable will be boolean then it would mix them
do not implement equality and such things for Boolean. Use wrapper type for it. And we already have such equality in VM
do not use String for operation type. Use enum instead
add function for long-ors and long-ands, when there are chains like a | b | c | d, and we have a | b already memoized
The structure of the BooleanWrapper is created. Added storage. The tests are correct. Optimization is successful.