• 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

    Cons-ppr1

    Signature
    (cons-ppr1 x rows width pair-keywords-p config eviscp) 
      → 
    new-rows
    Arguments
    x — A single printer instruction, representing either a DOT or a single object. Intuitively this is the instruction for the car of the list we're trying to print.
        Guard (pinst-p x).
    rows — A list of printer instructions that will be printed as a column. Intuitively these are the instructions for the cdr of the list we're trying to print.
        Guard (pinstlist-p rows).
    width — Guard (posp width).
    config — Guard (printconfig-p config).
    eviscp — Guard (booleanp eviscp).
    Returns
    new-rows — Type (pinstlist-p new-rows).

    The goal here is to add x to rows by either merging it with the first row or—if that won't work because it's too wide—by putting it into a new row. For instance, x might be (FLAT 3 ABC) and rows could be ((FLAT 7 DEF GHI) ...). In this case we need to decide to either:

    add a new row                   merge with the first row
    ABC                    -or-     ABC DEF GHI
    DEF GHI                         ...
    ...

    The default behavior is always to add a new row, i.e., to just cons x onto rows. But if the first row is flat, and we can fit x onto it without using up too many characters, then we should extend the first row.

    It is also here that we deal specially with keywords. If x is (FLAT 3 :ABC) and column is ((...) (...)) then we have the choice:

    add a new row                   merge with the first row
    :ABC                   -or-     :ABC (...)
    (...)                           (...)
    (...)

    Definitions and Theorems

    Function: cons-ppr1

    (defun cons-ppr1 (x rows
                        width pair-keywords-p config eviscp)
     (declare (xargs :guard (and (pinst-p x)
                                 (pinstlist-p rows)
                                 (posp width)
                                 (printconfig-p config)
                                 (booleanp eviscp))))
     (declare
        (xargs :guard
               (case (pinst-kind x)
                 (:flat (let ((what (pflat->what (pinst-flat->guts x))))
                          (and (consp what) (not (cdr what)))))
                 (otherwise t))))
     (let ((acl2::__function__ 'cons-ppr1))
      (declare (ignorable acl2::__function__))
      (b*
       ((x (pinst-fix x))
        (rows (pinstlist-fix rows))
        ((when (atom rows)) (cons x rows))
        (xkind (pinst-kind x))
        ((when (eq xkind :flat))
         (b* ((x.guts (pinst-flat->guts x))
              (x.what (pflat->what x.guts))
              (x.obj (first x.what))
              ((unless (or (atom x.obj)
                           (and eviscp (evisceratedp x.obj))))
               (cons x rows))
              (row1 (first rows))
              ((unless (and (keywordp x.obj)
                            (keyword-param-valuep row1 eviscp)))
               (maybe-merge-flat x rows width config))
              ((unless (or pair-keywords-p (atom (rest rows))
                           (eq (pinst-kind (second rows)) :keypair)
                           (eq (pinst-kind (second rows))
                               :keyline)))
               (maybe-merge-flat x rows width config))
              ((the unsigned-byte x.width)
               (pflat->width x.guts))
              ((the unsigned-byte row1.width)
               (pinst->width row1))
              (keypair-width (+ 1 x.width row1.width))
              ((when (<= keypair-width width))
               (cons (make-pinst-keypair :width keypair-width
                                         :kwd x.guts
                                         :value row1)
                     (cdr rows))))
           (cons (make-pinst-keyline :guts x.guts)
                 rows)))
        ((when (eq xkind :dot))
         (b*
          ((row1 (first rows))
           ((unless (eq (pinst-kind row1) :flat))
            (cons x rows))
           (row1.guts (pinst-flat->guts row1))
           (row1.width (pflat->width row1.guts))
           (merged-width (+ 2 row1.width))
           (flat-right-margin (printconfig->flat-right-margin config))
           ((unless (and (<= merged-width flat-right-margin)
                         (<= merged-width width)))
            (cons x rows))
           (new-guts
            (make-pflat :width merged-width
                        :what (ec-call (car (pflat->what row1.guts))))))
          (cons (make-pinst-flat :guts new-guts)
                (cdr rows)))))
       (cons x rows))))

    Theorem: pinstlist-p-of-cons-ppr1

    (defthm pinstlist-p-of-cons-ppr1
      (b* ((new-rows (cons-ppr1 x rows
                                width pair-keywords-p config eviscp)))
        (pinstlist-p new-rows))
      :rule-classes :rewrite)