FML Expression Simplifier

The writing of FML expressions can in some cases reach a high level of complexity, where redundant or unnecessary parts can easily be overlooked. To help you optimize your expressions, the PetroVR FML Editor has a built-in simplifier which can identify and replace segments that are redundant or can be expressed in a simpler manner. The simplifier reduces the expression as much as possible without changing its output, and so makes it easier to read and understand.

The simplifier can operate in two modes: (a) automatic, where the expression is simplified every time it is entered/modified and validated; or (b) manually, by clicking the Simplify button which is enabled when PetroVR detects that it is possible to simplify the expression. You can switch between these modes with the Simplify FML expressions option in the Options (Tools menu).

What the Simplifier does

  • This is a list of the operations performed by the FML Expression Simplifier:
  • Removes repeated arguments from and() and or() functions.
  • Removes the if() function when the receiver is already a Boolean.
  • Replaces the use of 1 or 0 with true or false in Boolean expressions.
  • Applies the absorption law to and() and or() functions.
  • Removes spurious comparisons of Boolean variables with true and false.
  • Replaces column numbers with columns names (more expressive and relocatable).
  • Removes constant Boolean arguments from and() and or() functions.
  • Removes superfluous conditional branches from if() functions.
  • Detects contradictions in add() arguments and replaces the function call with false.
  • Applies De Morgan laws whenever appropriate.
  • Removes double negations in calls to not().
  • Removes redundant calls to idempotent functions such as lowercase(), uppercase(), capitalize(), abs(), round(), ceiling(), floor().
  • Removes repeated arguments from and() and or() functions.
  • Rewrites calls to if(not()) as calls to if().
  • Replaces if()-based calculations of max() with calls to max().
  • Replaces if()-based calculations of min() with calls to min().
  • Removes comparisons with false.
  • Removes comparisons with true.
  • Removes superfluous comparisons.
  • Removes uses of not equal true and not equal false.
  • Replaces not(true) as false and not(false) as true.
  • Removes tautologies.
  • Takes out common factors, e.g. a * b + c + d * a + 1 is reduced to a * (b + d) + c + 1.