• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
      • Gl
        • Term-level-reasoning
        • Glmc
        • Other-resources
        • Optimization
          • Term-level-reasoning
          • Def-gl-param-thm
          • Case-splitting
          • Modes
          • Memory-management
          • Preferred-definitions
            • Custom-symbolic-counterparts
            • Redundant-recursion
            • Alternate-definitions
            • Gl-param-thm
          • Reference
          • Debugging
          • Basic-tutorial
        • Witness-cp
        • Ccg
        • Install-not-normalized
        • Rewrite$
        • Removable-runes
        • Efficiency
        • Rewrite-bounds
        • Bash
        • Def-dag-measure
        • Fgl
        • Bdd
        • Remove-hyps
        • Contextual-rewriting
        • Simp
        • Rewrite$-hyps
        • Bash-term-to-dnf
        • Use-trivial-ancestors-check
        • Minimal-runes
        • Clause-processor-tools
        • Fn-is-body
        • Without-subsumption
        • Rewrite-equiv-hint
        • Def-bounds
        • Rewrite$-context
        • Try-gl-concls
        • Hint-utils
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Optimization

    Preferred-definitions

    To instruct GL to symbolically execute filter2 in place of filter1, we can do the following:

    (defthm filter1-for-gl
      (equal (filter1 x) (filter2 x))
      :rule-classes nil)
    
    (gl::set-preferred-def filter1 filter1-for-gl)

    The set-preferred-def form extends a table that GL consults when expanding a function's definition. Each entry in the table pairs a function name with the name of a theorem. The theorem must state that a call of the function is unconditionally equal to some other term.

    When GL encounters a call of a function in this table, it replaces the call with the right-hand side of the theorem, which is justified by the theorem. So after the above event, GL will replace calls of filter1 with filter2.

    As another example of a preferred definition, GL automatically optimizes the definition of evenp, which ACL2 defines as follows:

    (evenp x) = (integerp (* x (/ 2)))

    This definition is basically unworkable since GL provides little support for rational numbers. However, GL has an efficient, built-in implementation of logbitp. So to permit the efficient execution of evenp, GL proves the following identity and uses it as evenp's preferred definition.

    (defthm evenp-is-logbitp
      (equal (evenp x)
             (or (not (acl2-numberp x))
                 (and (integerp x)
                      (equal (logbitp 0 x) nil)))))