• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
        • Transforms
          • Expression-sizing
            • Expression-sizing-minutia
            • Expression-sizing-intro
            • Vl-keyvalue-pattern-collect-array-replacements
            • Vl-assignpattern-positional-replacement
            • Vl-plainarg-exprsize
            • Vl-assignpattern-keyvalue-replacement
            • Vl-keyvalue-pattern-collect-struct-replacements
            • Vl-modulelist-exprsize
            • Vl-expr-assignpattern-extend/truncate
            • Vl-structmemberlist->types
            • Vl-expr-size
              • Vl-expr-selfsize
              • Vl-expr-typedecide
              • Vl-expr-expandsizes
                • Vl-weirdint-atom-expandsizes
                • Vl-constint-atom-expandsizes
                • Vl-hidexpr-expandsizes
                • Vl-expandsizes-zeroextend
                • Vl-atom-expandsizes
                • Vl-string-atom-expandsizes
                  • Vl-sign-extend-constint
                • Vl-exprlist-expandsizes
                • Vl-exprlist-size
              • Vl-expr-selfdetermine-type
              • Vl-assignpattern-multi-replacement
              • Vl-parse-keyval-pattern-struct
              • Vl-plainarglist-exprsize
              • Vl-parse-keyval-pattern-array
              • Vl-warn-about-implicit-extension
              • Vl-assigncontext-size
              • Vl-arguments-exprsize
              • Vl-assignpattern-replacement
              • Vl-packeddimensionlist-exprsize
              • Vl-namedparamvaluelist-exprsize
              • Vl-maybe-delayoreventcontrol-exprsize
              • Vl-repeateventcontrol-exprsize
              • Vl-paramvaluelist-exprsize
              • Vl-maybe-packeddimension-exprsize
              • Vl-delayoreventcontrol-exprsize
              • Vl-namedparamvalue-exprsize
              • Vl-namedarglist-exprsize
              • Vl-enumitemlist-exprsize
              • Vl-packeddimension-exprsize
              • Vl-maybe-paramvalue-exprsize
              • Vl-evatomlist-exprsize
              • Vl-atom-selfdetermine-type
              • Vl-rangelist-exprsize
              • Vl-maybe-gatedelay-exprsize
              • Vl-maybe-datatype-exprsize
              • Vl-gatedelay-exprsize
              • Vl-paramargs-exprsize
              • Vl-namedarg-exprsize
              • Vl-eventcontrol-exprsize
              • Vl-enumbasetype-exprsize
              • Vl-delaycontrol-exprsize
              • Vl-paramvalue-exprsize
              • Vl-maybe-range-exprsize
              • Vl-enumitem-exprsize
              • Vl-range-exprsize
              • Vl-paramdecl-exprsize
              • Vl-paramdecllist-exprsize
              • Vl-maybe-expr-size
              • Vl-evatom-exprsize
              • Vl-vardecllist-exprsize
              • Vl-portdecllist-exprsize
              • Vl-modinstlist-exprsize
              • Vl-initiallist-exprsize
              • Vl-gateinstlist-exprsize
              • Vl-fundecllist-exprsize
              • Vl-assign-exprsize
              • Vl-interfaceport-exprsize
              • Vl-assignlist-exprsize
              • Vl-alwayslist-exprsize
              • Vl-portlist-exprsize
              • Vl-modinst-exprsize
              • Vl-gateinst-exprsize
              • Vl-fundecl-exprsize
              • Vl-vardecl-exprsize
              • Vl-regularport-exprsize
              • Vl-portdecl-exprsize
              • Vl-initial-exprsize
              • Vl-always-exprsize
              • Vl-port-exprsize
              • Vl-lvalue-type
              • Vl-classify-extension-warning-hook
              • Welltyped
              • Vl-castexpr->datatype
              • Vl-expr-size-assigncontext
              • Vl-type-expr-pairs-sum-datatype-sizes
              • Vl-basictype->datatype
              • Vl-expr-replace-assignpatterns
              • Vl-design-exprsize
              • Vl-op-simple-vector-p
              • Vl-expr-val-alist-max-count
              • Vl-expr-has-patterns
              • Vl-exprlist-max-count
              • Vl-unsigned-when-size-zero-lst
              • Vl-type-expr-pairs
              • Append-n
              • Vl-expr-val-alist
              • Vl-datatypelist
            • Occform
            • Oprewrite
            • Expand-functions
            • Delayredux
            • Unparameterization
            • Caseelim
            • Split
            • Selresolve
            • Weirdint-elim
            • Vl-delta
            • Replicate-insts
            • Rangeresolve
            • Propagate
            • Clean-selects
            • Clean-params
            • Blankargs
            • Inline-mods
            • Expr-simp
            • Trunc
            • Always-top
            • Gatesplit
            • Gate-elim
            • Expression-optimization
            • Elim-supplies
            • Wildelim
            • Drop-blankports
            • Clean-warnings
            • Addinstnames
            • Custom-transform-hooks
            • Annotate
            • Latchcode
            • Elim-unused-vars
            • Problem-modules
          • Lint
          • Mlib
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Vl-expr-expandsizes

    Vl-string-atom-expandsizes

    Propagate the final width and type of an expression into a weird integer atom.

    Signature
    (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings) 
      → 
    (mv successp warnings new-x)
    Arguments
    x — Guard (vl-expr-p x).
    finalwidth — Guard (natp finalwidth).
    finaltype — Guard (vl-exprtype-p finaltype).
    ctx — Guard (vl-context-p ctx).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    successp — Type (booleanp successp).
    warnings — Type (vl-warninglist-p warnings).
    new-x — Type (vl-expr-p new-x).

    Definitions and Theorems

    Function: vl-string-atom-expandsizes

    (defun vl-string-atom-expandsizes
           (x finalwidth finaltype ctx warnings)
     (declare (xargs :guard (and (vl-expr-p x)
                                 (natp finalwidth)
                                 (vl-exprtype-p finaltype)
                                 (vl-context-p ctx)
                                 (vl-warninglist-p warnings))))
     (declare (xargs :guard (and (vl-atom-p x)
                                 (vl-fast-string-p (vl-atom->guts x)))))
     (let ((__function__ 'vl-string-atom-expandsizes))
      (declare (ignorable __function__))
      (b*
       ((x (vl-expr-fix x))
        (finalwidth (lnfix finalwidth))
        (finaltype (vl-exprtype-fix finaltype))
        (ctx (vl-context-fix ctx))
        (guts (vl-atom->guts x))
        ((vl-string guts) guts)
        (origwidth (* 8 (length guts.value)))
        ((when (> origwidth finalwidth))
         (mv
          nil
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: origwidth > finalwidth when expanding ~a1. This ~
                             indicates a serious bug in our sizing code."
           :args (list ctx x))
          x))
        ((unless (eq finaltype :vl-unsigned))
         (mv
          nil
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: finaltype is ~s1 when expanding ~a2.  This ~
                             indicates a serious bug in our sizing/typing code."
           :args (list ctx finaltype x))
          x))
        (inner (change-vl-atom x
                               :finalwidth origwidth
                               :finaltype :vl-unsigned))
        ((mv successp warnings new-x)
         (vl-expandsizes-zeroextend inner finalwidth ctx warnings))
        ((unless successp) (mv nil warnings x)))
       (mv t warnings new-x))))

    Theorem: booleanp-of-vl-string-atom-expandsizes.successp

    (defthm booleanp-of-vl-string-atom-expandsizes.successp
      (b* (((mv ?successp ?warnings ?new-x)
            (vl-string-atom-expandsizes
                 x finalwidth finaltype ctx warnings)))
        (booleanp successp))
      :rule-classes :type-prescription)

    Theorem: vl-warninglist-p-of-vl-string-atom-expandsizes.warnings

    (defthm vl-warninglist-p-of-vl-string-atom-expandsizes.warnings
      (b* (((mv ?successp ?warnings ?new-x)
            (vl-string-atom-expandsizes
                 x finalwidth finaltype ctx warnings)))
        (vl-warninglist-p warnings))
      :rule-classes :rewrite)

    Theorem: vl-expr-p-of-vl-string-atom-expandsizes.new-x

    (defthm vl-expr-p-of-vl-string-atom-expandsizes.new-x
      (b* (((mv ?successp ?warnings ?new-x)
            (vl-string-atom-expandsizes
                 x finalwidth finaltype ctx warnings)))
        (vl-expr-p new-x))
      :rule-classes :rewrite)

    Theorem: warning-irrelevance-of-vl-string-atom-expandsizes

    (defthm warning-irrelevance-of-vl-string-atom-expandsizes
     (let
      ((ret1 (vl-string-atom-expandsizes
                  x finalwidth finaltype ctx warnings))
       (ret2
           (vl-string-atom-expandsizes x finalwidth finaltype nil nil)))
      (implies (syntaxp (not (and (equal ctx ''nil)
                                  (equal warnings ''nil))))
               (and (equal (mv-nth 0 ret1) (mv-nth 0 ret2))
                    (equal (mv-nth 2 ret1)
                           (mv-nth 2 ret2))))))

    Theorem: no-change-loserp-of-vl-string-atom-expandsizes

    (defthm no-change-loserp-of-vl-string-atom-expandsizes
      (let ((ret (vl-string-atom-expandsizes
                      x finalwidth finaltype ctx warnings)))
        (implies (not (mv-nth 0 ret))
                 (equal (mv-nth 2 ret)
                        (vl-expr-fix x)))))

    Theorem: vl-expr-welltyped-p-of-vl-string-atom-expandsizes

    (defthm vl-expr-welltyped-p-of-vl-string-atom-expandsizes
      (let ((ret (vl-string-atom-expandsizes
                      x finalwidth finaltype ctx warnings)))
        (implies (and (mv-nth 0 ret)
                      (force (vl-atom-p x))
                      (force (vl-string-p (vl-atom->guts x))))
                 (vl-expr-welltyped-p (mv-nth 2 ret)))))

    Theorem: vl-expr->finalwidth-of-vl-string-atom-expandsizes

    (defthm vl-expr->finalwidth-of-vl-string-atom-expandsizes
      (let ((ret (vl-string-atom-expandsizes
                      x finalwidth finaltype ctx warnings)))
        (implies (and (mv-nth 0 ret)
                      (force (vl-atom-p x))
                      (force (vl-string-p (vl-atom->guts x))))
                 (equal (vl-expr->finalwidth (mv-nth 2 ret))
                        (nfix finalwidth)))))

    Theorem: vl-expr->finaltype-of-vl-string-atom-expandsizes

    (defthm vl-expr->finaltype-of-vl-string-atom-expandsizes
      (let ((ret (vl-string-atom-expandsizes
                      x finalwidth finaltype ctx warnings)))
        (implies (and (mv-nth 0 ret)
                      (force (vl-atom-p x))
                      (force (vl-string-p (vl-atom->guts x))))
                 (equal (vl-expr->finaltype (mv-nth 2 ret))
                        (vl-exprtype-fix finaltype)))))

    Theorem: vl-string-atom-expandsizes-of-vl-expr-fix-x

    (defthm vl-string-atom-expandsizes-of-vl-expr-fix-x
     (equal
      (vl-string-atom-expandsizes (vl-expr-fix x)
                                  finalwidth finaltype ctx warnings)
      (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)))

    Theorem: vl-string-atom-expandsizes-vl-expr-equiv-congruence-on-x

    (defthm vl-string-atom-expandsizes-vl-expr-equiv-congruence-on-x
     (implies
      (vl-expr-equiv x x-equiv)
      (equal
        (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)
        (vl-string-atom-expandsizes x-equiv
                                    finalwidth finaltype ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-string-atom-expandsizes-of-nfix-finalwidth

    (defthm vl-string-atom-expandsizes-of-nfix-finalwidth
     (equal
      (vl-string-atom-expandsizes x (nfix finalwidth)
                                  finaltype ctx warnings)
      (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)))

    Theorem: vl-string-atom-expandsizes-nat-equiv-congruence-on-finalwidth

    (defthm
          vl-string-atom-expandsizes-nat-equiv-congruence-on-finalwidth
     (implies
      (acl2::nat-equiv finalwidth finalwidth-equiv)
      (equal
        (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)
        (vl-string-atom-expandsizes x finalwidth-equiv
                                    finaltype ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-string-atom-expandsizes-of-vl-exprtype-fix-finaltype

    (defthm vl-string-atom-expandsizes-of-vl-exprtype-fix-finaltype
     (equal
      (vl-string-atom-expandsizes
           x finalwidth (vl-exprtype-fix finaltype)
           ctx warnings)
      (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)))

    Theorem: vl-string-atom-expandsizes-vl-exprtype-equiv-congruence-on-finaltype

    (defthm
     vl-string-atom-expandsizes-vl-exprtype-equiv-congruence-on-finaltype
     (implies
      (vl-exprtype-equiv finaltype finaltype-equiv)
      (equal
        (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)
        (vl-string-atom-expandsizes x finalwidth
                                    finaltype-equiv ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-string-atom-expandsizes-of-vl-context-fix-ctx

    (defthm vl-string-atom-expandsizes-of-vl-context-fix-ctx
     (equal
      (vl-string-atom-expandsizes x finalwidth
                                  finaltype (vl-context-fix ctx)
                                  warnings)
      (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)))

    Theorem: vl-string-atom-expandsizes-vl-context-equiv-congruence-on-ctx

    (defthm
          vl-string-atom-expandsizes-vl-context-equiv-congruence-on-ctx
     (implies
      (vl-context-equiv ctx ctx-equiv)
      (equal
        (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)
        (vl-string-atom-expandsizes x finalwidth
                                    finaltype ctx-equiv warnings)))
     :rule-classes :congruence)

    Theorem: vl-string-atom-expandsizes-of-vl-warninglist-fix-warnings

    (defthm vl-string-atom-expandsizes-of-vl-warninglist-fix-warnings
     (equal
      (vl-string-atom-expandsizes x finalwidth finaltype
                                  ctx (vl-warninglist-fix warnings))
      (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)))

    Theorem: vl-string-atom-expandsizes-vl-warninglist-equiv-congruence-on-warnings

    (defthm
     vl-string-atom-expandsizes-vl-warninglist-equiv-congruence-on-warnings
     (implies
      (vl-warninglist-equiv warnings warnings-equiv)
      (equal
        (vl-string-atom-expandsizes x finalwidth finaltype ctx warnings)
        (vl-string-atom-expandsizes x finalwidth
                                    finaltype ctx warnings-equiv)))
     :rule-classes :congruence)