• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • 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-dead-if-branches-lst
          • 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
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Std/system/term-transformations

Remove-dead-if-branches

Remove all the dead if bramches in a term.

Signature
(remove-dead-if-branches term) → new-term
Arguments
term — Guard (pseudo-termp term).
Returns
new-term — Type (pseudo-termp new-term), given the guard.

Each (if t a b) or (if (not nil) a b) is turned into a, and each (if nil a b) or (if (not t) a b) is turned into b. This is done to a and b, recursively.

Function: remove-dead-if-branches

(defun remove-dead-if-branches (term)
 (declare (xargs :guard (pseudo-termp term)))
 (let ((__function__ 'remove-dead-if-branches))
  (declare (ignorable __function__))
  (b*
   (((when (variablep term)) term)
    ((when (fquotep term)) term)
    (fn (ffn-symb term))
    ((when (and (eq fn 'if)
                (= (len (fargs term)) 3)))
     (cond
      ((member-equal (fargn term 1)
                     (list *t* (fcons-term 'not (list *nil*))))
       (remove-dead-if-branches (fargn term 2)))
      ((member-equal (fargn term 1)
                     (list *nil* (fcons-term 'not (list *t*))))
       (remove-dead-if-branches (fargn term 3)))
      (t
       (cons
          'if
          (cons (remove-dead-if-branches (fargn term 1))
                (cons (remove-dead-if-branches (fargn term 2))
                      (cons (remove-dead-if-branches (fargn term 3))
                            'nil)))))))
    (new-args (remove-dead-if-branches-lst (fargs term)))
    ((when (symbolp fn))
     (fcons-term fn new-args)))
   (fcons-term
        (make-lambda (lambda-formals fn)
                     (remove-dead-if-branches (lambda-body fn)))
        new-args))))

Function: remove-dead-if-branches-lst

(defun remove-dead-if-branches-lst (terms)
  (declare (xargs :guard (pseudo-term-listp terms)))
  (let ((__function__ 'remove-dead-if-branches-lst))
    (declare (ignorable __function__))
    (b* (((when (endp terms)) nil)
         (new-term (remove-dead-if-branches (car terms)))
         (new-terms (remove-dead-if-branches-lst (cdr terms))))
      (cons new-term new-terms))))

Theorem: return-type-of-remove-dead-if-branches.new-term

(defthm return-type-of-remove-dead-if-branches.new-term
  (implies (and (pseudo-termp term))
           (b* ((?new-term (remove-dead-if-branches term)))
             (pseudo-termp new-term)))
  :rule-classes :rewrite)

Theorem: return-type-of-remove-dead-if-branches-lst.new-terms

(defthm return-type-of-remove-dead-if-branches-lst.new-terms
  (implies (and (pseudo-term-listp terms))
           (b* ((?new-terms (remove-dead-if-branches-lst terms)))
             (and (pseudo-term-listp new-terms)
                  (equal (len new-terms) (len terms)))))
  :rule-classes :rewrite)

Subtopics

Remove-dead-if-branches-lst