Common Subexpression Elimination - ProB Documentation

Common Subexpression Elimination

As of version 1.5.1 ProB supports common subexpression elimination (CSE).

To enable it you need to set the advanced preference CSE to true (this can be done using the switch -p CSE TRUE when using the command-line version probcli or using the Advanced Preferences command in ProB Tcl/Tk). With CSE enabled, ProB will translate the predicate

x:dom(f(a)) & r=f(a)(x)

into

(LET @0==(f(a)) IN x ∈ dom(@0) ∧ r = @0(x))

before evaluating it. Similarly, the predicate

x*x+2*x > y*y*y & y*y*y > x*x+2*x

gets translated into

LET @2==(x*x+2*x) IN (LET @4==((y*y)*y) IN @2 > @4 & @4 > @2))

To enable CSE also inside substitutions (aka B statements) you need to set the preference CSE_SUBST to true.