• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
          • Std/strings
            • Pretty-printing
              • Pretty-printing-implementation
                • Missing-functionality
                • Printconfig
                • Cons-ppr1
                • Print-escaped-charlist
                • Atom-size
                • Print-escaped-str
                • Obj-size
                • Maybe-merge-flat
                  • Ppr
                  • Printer-instructions
                  • Keyword-param-valuep
                  • Print-flat-objs
                  • Radix-print-int
                  • Print-escaped-atom
                  • Print-atom
                  • Print-escaped-symbol
                  • Radix-print-complex
                  • Basic-print-complex
                  • Radix-print-rat
                  • Spaces1
                  • Basic-print-rat
                  • Basic-print-nat
                  • Basic-print-int
                  • Spaces
                  • My-needs-slashes
                  • Pinstlist->max-width
                  • Nat-size
                  • Special-term-num
                  • Print-column
                  • Print-base-fix
                  • Int-size
                  • Keyword-fix
                  • Print-instruction
                  • Pinst->width
                  • In-home-package-p
                  • Eviscerated->guts
                  • Evisceratedp
                  • Pprdot
                • Eviscerate
                • Pretty
                • Revappend-pretty
                • Pretty-list
              • Printtree
              • Base64
              • Charset-p
              • Strtok!
              • Cases
              • Concatenation
              • Html-encoding
              • Character-kinds
              • Substrings
              • Strtok
              • Equivalences
              • Url-encoding
              • Lines
              • Explode-implode-equalities
              • Ordering
              • Numbers
              • Pad-trim
              • Coercion
              • Std/strings/digit-to-char
              • Substitution
              • Symbols
            • String-listp
            • Stringp
            • Length
            • Search
            • Remove-duplicates
            • Position
            • Coerce
            • Concatenate
            • Reverse
            • String
            • Subseq
            • Substitute
            • String-upcase
            • String-downcase
            • Count
            • Char
            • String<
            • String-equal
            • String-utilities
            • String-append
            • String>=
            • String<=
            • String>
            • Hex-digit-char-theorems
            • String-downcase-gen
            • String-upcase-gen
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Pretty-printing-implementation

    Maybe-merge-flat

    Basic merging of flat singleton objects into rows.

    Signature
    (maybe-merge-flat x rows width config) → new-rows
    Arguments
    x — Instruction for the car of the list.
        Guard (pinst-p x).
    rows — Instructions for the cdr of the list.
        Guard (pinstlist-p rows).
    width — Width we're trying to stay within.
        Guard (natp width).
    config — Guard (printconfig-p config).
    Returns
    new-rows — Type (pinstlist-p new-rows).

    Definitions and Theorems

    Function: maybe-merge-flat

    (defun maybe-merge-flat (x rows width config)
     (declare (xargs :guard (and (pinst-p x)
                                 (pinstlist-p rows)
                                 (natp width)
                                 (printconfig-p config))))
     (declare
       (xargs
            :guard (and (eq (pinst-kind x) :flat)
                        (let ((what (pflat->what (pinst-flat->guts x))))
                          (and (consp what) (not (cdr what))))
                        (consp rows))))
     (let ((acl2::__function__ 'maybe-merge-flat))
       (declare (ignorable acl2::__function__))
       (b*
         ((x (pinst-fix x))
          (rows (pinstlist-fix rows))
          (row1 (car rows))
          ((unless (eq (pinst-kind row1) :flat))
           (cons x rows))
          (x.guts (pinst-flat->guts x))
          (row1.guts (pinst-flat->guts row1))
          ((the unsigned-byte row1.width)
           (pflat->width row1.guts))
          ((the unsigned-byte x.width)
           (pflat->width x.guts))
          ((the unsigned-byte merged-width)
           (+ 1
              (the unsigned-byte (+ x.width row1.width))))
          ((the unsigned-byte flat-right-margin)
           (printconfig->flat-right-margin config))
          ((unless (and (<= merged-width flat-right-margin)
                        (<= merged-width width)))
           (cons x rows))
          (x.what (pflat->what x.guts))
          (row1.what (pflat->what row1.guts))
          (merged-guts (make-pflat :width merged-width
                                   :what (cons (car x.what) row1.what)))
          (merged-inst (make-pinst-flat :guts merged-guts)))
         (cons merged-inst (rest rows)))))

    Theorem: pinstlist-p-of-maybe-merge-flat

    (defthm pinstlist-p-of-maybe-merge-flat
      (b* ((new-rows (maybe-merge-flat x rows width config)))
        (pinstlist-p new-rows))
      :rule-classes :rewrite)