Added builtin safety and reordering to policy engine

Previously, policy writers needed to ensure that left-to-right evaluation
of the rule body guaranteed that all the inputs for a builtin were bound
before that builtin was evaluated.  Similarly for negation.

This change automates the reordering process, but does so in a way
that leaves the rule unchanged if it is properly ordered.  This ensures
that people can hand-tweak the ordering if they want, but they do
not need to.  It constitutes a first step toward query optimization.

Change-Id: Ia8e522dcec655df6c49a71f748f6280b9df64eeb
Merge "Added builtin safety and reordering to policy engine"