• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
      • Gl
      • Witness-cp
      • Ccg
      • Install-not-normalized
      • Rewrite$
      • Removable-runes
      • Efficiency
      • Rewrite-bounds
      • Bash
      • Def-dag-measure
      • Fgl
        • Fgl-rewrite-rules
          • Fgl-syntactic-checker-binders
          • Binder
          • Fancy-ev
            • Def-fgl-program
            • Bind-var
            • Add-fgl-brewrites
            • Def-fgl-rewrite
            • Narrow-equiv
            • Def-fgl-branch-merge
            • Add-fgl-rewrites
            • Fgl-interp-obj
            • Fgl-prog2
            • Collect-cmr-rewrites-for-formula-name
            • Syntax-bind
            • Fgl-time
            • Assume
            • Add-fgl-binder-meta
            • Add-fgl-primitive
            • Add-fgl-meta
            • Add-fgl-branch-merges
            • Cmr::rewritelist->lhses
            • Remove-fgl-brewrites
            • Remove-fgl-branch-merges
            • Lhses->branch-function-syms
            • Enable-execution
            • Abort-rewrite
            • Syntax-interp
            • Remove-fgl-rewrites
            • Lhses->leading-function-syms
            • Remove-fgl-primitive
            • Remove-fgl-binder-meta
            • If!
            • Disable-execution
            • Remove-fgl-meta
            • Fgl-time-fn
            • Disable-definition
            • Def-fgl-brewrite
          • Fgl-function-mode
          • Fgl-object
          • Fgl-solving
          • Fgl-handling-if-then-elses
          • Fgl-getting-bits-from-objects
          • Fgl-primitive-and-meta-rules
          • Fgl-interpreter-overview
          • Fgl-counterexamples
          • Fgl-correctness-of-binding-free-variables
          • Fgl-debugging
          • Fgl-testbenches
          • Def-fgl-boolean-constraint
          • Fgl-stack
          • Fgl-rewrite-tracing
          • Def-fgl-param-thm
          • Def-fgl-thm
          • Fgl-fast-alist-support
          • Advanced-equivalence-checking-with-fgl
          • Fgl-array-support
          • Fgl-internals
        • 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
    • Fgl-rewrite-rules

    Fancy-ev

    Term evaluator used by FGL for syntaxp, bind-free, and syntax-bind interpretation.

    Signature
    (fancy-ev x alist reclimit interp-st state hard-errp aokp) 
      → 
    (mv errmsg val new-interp-st new-state)
    Arguments
    x — Guard (pseudo-termp x).
    alist — Guard (symbol-alistp alist).
    reclimit — Guard (natp reclimit).
    interp-st — Guard (interp-st-bfrs-ok interp-st).

    Fancy-ev is a term evaluator capable of running terms that include functions that access the FGL interpreter state and the ACL2 state, and even may modify the FGL interpreter state in limited ways. It is used for evaluating syntaxp, bind-free, and syntax-bind forms in the FGL rewriter.

    Fancy-ev uses magic-ev-fncall to allow it to run most functions that do not access stobjs. When magic-ev-fncall fails, it can also expand function definitions and interpret their bodies. But additionally, it calls an attachable function fancy-ev-primitive to allow it to directly execute functions that access and/or modify the ACL2 state and FGL interp-st.

    To allow a function my-fn that accesses/updates interp-st or state to be executable by fancy-ev, there are two steps:

    • (fancy-ev-add-primitive my-fn guard-form) checks that the function is valid as a fancy-ev primitive and that guard-form suffices to check that the function's guard is satisfied when provided an interp-st satisfying interp-st-bfrs-ok. If so, the function/guard pair is recorded in the table fancy-ev-primitives for later use by def-fancy-ev-primitives.
    • (def-fancy-ev-primitives my-fancy-ev-primitives-impl) defines a function named my-fancy-ev-primitives-impl and attaches it to fancy-ev-primitive. The function is defined as a case statement on the input function symbol where for each function/guard pair in the fancy-ev-primitives table, if the input function symbol matches that function, it checks the given guard form and then executes the function on the input arguments, returning its return value list and modified interp-st (if any). This allows all functions that were added using fancy-ev-add-primitive to be executed by fancy-ev.