• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
      • Std/lists
      • Omaps
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
      • Std/io
      • Std/basic
      • Std/system
        • Fresh-logical-name-with-$s-suffix
        • Irrelevant-formals-info
        • Std/system/function-queries
        • Std/system/term-queries
        • Std/system/term-transformations
          • Make-mv-let-call
          • Mvify
          • Remove-trivial-vars
          • Remove-unused-vars
          • Fsublis-fn-rec
          • Close-lambdas
          • Fsublis-var
          • Remove-mbe-logic/exec
          • Untranslate$
          • Remove-dead-if-branches
          • Remove-progn
          • Make-mv-nth-calls
          • Apply-fn-into-ifs
            • Conjoin-equalities
            • Fapply-unary-to-terms
            • Apply-unary-to-terms
            • Apply-terms-same-args
            • Apply-term
            • Fsublis-fn-lst-simple
            • Fsublis-fn
            • Fapply-terms-same-args
            • Fsublis-fn-simple
            • Fapply-term
            • Remove-mbe-logic
            • Remove-mbe-exec
            • Quote-term
            • Quote-term-list
            • Apply-term*
            • Std/system/fsubcor-var
            • Std/system/conjoin
            • Std/system/flatten-ands-in-lit
            • Fapply-term*
            • Std/system/dumb-negate-lit
          • Std/system/enhanced-utilities
          • Install-not-normalized-event
          • Install-not-normalized-event-lst
          • Std/system/term-function-recognizers
          • Genvar$
          • Std/system/event-name-queries
          • Pseudo-tests-and-call-listp
          • Maybe-pseudo-event-formp
          • Add-suffix-to-fn-or-const
          • Chk-irrelevant-formals-ok
          • Table-alist+
          • Pseudo-tests-and-callp
          • Add-suffix-to-fn-or-const-lst
          • Known-packages+
          • Add-suffix-to-fn-lst
          • Unquote-term
          • Event-landmark-names
          • Add-suffix-lst
          • Std/system/theorem-queries
          • Unquote-term-list
          • Std/system/macro-queries
          • Pseudo-command-landmark-listp
          • Install-not-normalized$
          • Pseudo-event-landmark-listp
          • Known-packages
          • Std/system/partition-rest-and-keyword-args
          • Rune-enabledp
          • Rune-disabledp
          • Included-books
          • Std/system/pseudo-event-formp
          • Std/system/plist-worldp-with-formals
          • Std/system/w
          • Std/system/geprops
          • Std/system/arglistp
          • Std/system/constant-queries
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Std/system/term-transformations

    Apply-fn-into-ifs

    Apply a function symbol or lambda expression to the term, pushing the function into the if branches.

    Signature
    (apply-fn-into-ifs fn term) → new-term
    Arguments
    fn — Guard (pseudo-termfnp fn).
    term — Guard (pseudo-termp term).
    Returns
    new-term — A pseudo-termp.

    If the term is not an if, the function is applied to the term. Otherwise, the function is applied to the `then' and `else' branches, and recursively to their `then' and `else' branches if those are ifs as well. For instance, applying a symbol f to (if a (if b c d) e) results in (if a (if b (f c) (f d)) (f e)).

    Definitions and Theorems

    Function: apply-fn-into-ifs

    (defun apply-fn-into-ifs (fn term)
     (declare (xargs :guard (and (pseudo-termfnp fn)
                                 (pseudo-termp term))))
     (declare (xargs :guard (or (symbolp fn)
                                (= (len (lambda-formals fn)) 1))))
     (let ((__function__ 'apply-fn-into-ifs))
      (declare (ignorable __function__))
      (b*
       (((when (variablep term))
         (apply-term* fn term))
        ((when (fquotep term))
         (apply-term* fn term))
        ((unless (eq (ffn-symb term) 'if))
         (apply-term* fn term))
        ((unless (= (len (fargs term)) 3))
         (raise
          "Internal error: ~
                    the IF term ~x0 does not have 3 arguments."
          term)))
       (cons-term 'if
                  (list (fargn term 1)
                        (apply-fn-into-ifs fn (fargn term 2))
                        (apply-fn-into-ifs fn (fargn term 3)))))))