• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
        • Symbolic-test-vectors
        • Esim-primitives
        • E-conversion
        • Esim-steps
        • Patterns
          • Pat->al
          • Pat-flatten1
          • Member-of-pat-flatten
          • Similar-patternsp
          • Pat-flatten
            • Al->pat
            • Assoc-pat->al
            • Subsetp-of-pat-flatten
            • Pat->fal
            • Data-for-patternp
          • Mod-internal-paths
          • Defmodules
          • Esim-simplify-update-fns
          • Esim-tutorial
          • Esim-vl
        • Vl2014
        • Sv
        • Vwsim
        • Fgl
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Testing-utilities
      • Math
    • Patterns

    Pat-flatten

    Flatten a pattern into a list of atoms (with an accumulator).

    (pat-flatten pat acc) flattens pat, appending its atoms onto acc, in order. For instance,

    (pat-flatten '((a) (b c)) '(x y z))
    -->
    (a b c x y z)

    The accumulator argument is occasionally useful. But for reasoning, we rewrite pat-flatten into pat-flatten1 with the following theorem:

    Theorem: pat-flatten-is-pat-flatten1

    (defthm pat-flatten-is-pat-flatten1
            (equal (pat-flatten pat acc)
                   (append (pat-flatten1 pat) acc)))

    Definitions and Theorems

    Function: pat-flatten

    (defun pat-flatten (pat acc)
           (declare (xargs :guard t))
           (if pat
               (if (atom pat)
                   (cons pat acc)
                   (pat-flatten (car pat)
                                (pat-flatten (cdr pat) acc)))
               acc))