• 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
        • Lint
        • Mlib
          • Scopestack
          • Filtering-by-name
          • Vl-namefactory
          • Substitution
          • Allexprs
          • Hid-tools
            • Following-hids
              • Vl-follow-hidexpr
              • Vl-partselect-type-top-dimension-replacement
              • Vl-hidindex-datatype-resolve-dims
              • Vl-follow-hidexpr-error
              • Vl-follow-hidexpr-dimscheck
              • Vl-index-find-type
                • Vl-follow-hidexpr-dimcheck
                • Vl-partselect-expr-type
                • Vl-ss-find-hidexpr-range!!
                • Vl-hidstep
                • Vl-ss-find-hidexpr-range
                • Vl-genarrayblocklist-find-block
                • Vl-flatten-hidindex
                • Vl-hidexpr-resolved-p
                • Vl-flatten-hidexpr
                • Vl-hidindex-resolved-p
                • Vl-hidtrace
              • Vl-hidexpr-traverse-datatype
              • Abstract-hids
              • Vl-hidexpr-find-type
            • Vl-consteval
            • Range-tools
            • Lvalexprs
            • Hierarchy
            • Finding-by-name
            • Expr-tools
            • Expr-slicing
            • Stripping-functions
            • Stmt-tools
            • Modnamespace
            • Vl-parse-expr-from-str
            • Welltyped
            • Reordering-by-name
            • Flat-warnings
            • Genblob
            • Expr-building
            • Datatype-tools
            • Syscalls
            • Relocate
            • Expr-cleaning
            • Namemangle
            • Caremask
            • Port-tools
            • Lvalues
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Following-hids

    Vl-index-find-type

    Signature
    (vl-index-find-type x ss ctx) → (mv warning type)
    Arguments
    x — Should be a hid (perhaps just an ID), perhaps with some indexing operators applied to it, i.e., bitselect or index operators but not part-select operators. So for instance: foo, foo.bar, foo.bar[3], foo.bar[3][4][5].
        Guard (vl-expr-p x).
    ss — Scopestack where x occurs.
        Guard (vl-scopestack-p ss).
    ctx — Guard (acl2::any-p ctx).
    Returns
    warning — Success indicator, we fail if we can't follow the HID or this isn't an appropriate expression.
        Type (iff (vl-warning-p warning) warning).
    type — The type of the resulting expression after all indexing is done.
        Type (implies (not warning) (vl-datatype-p type)).

    Definitions and Theorems

    Function: vl-index-find-type

    (defun vl-index-find-type (x ss ctx)
     (declare (xargs :guard (and (vl-expr-p x)
                                 (vl-scopestack-p ss)
                                 (acl2::any-p ctx))))
     (let ((__function__ 'vl-index-find-type))
      (declare (ignorable __function__))
      (b*
       ((x (vl-expr-fix x))
        ((when (or (vl-atom-p x)
                   (not (member (vl-nonatom->op x)
                                '(:vl-index :vl-bitselect)))))
         (b*
          (((unless (vl-hidexpr-p x))
            (mv
             (make-vl-warning
              :type :vl-bad-index-expr
              :msg
              "~a0: An index operator was applied to a bad subexpression, ~a1."
              :args (list ctx x)
              :fn __function__)
             nil))
           ((mv warning type)
            (vl-hidexpr-find-type x ss ctx))
           ((when warning) (mv warning nil)))
          (mv nil type)))
        ((vl-nonatom x))
        ((mv warning sub-type)
         (vl-index-find-type (first x.args)
                             ss ctx))
        ((when warning) (mv warning nil))
        (udims (vl-datatype->udims sub-type))
        ((when (consp udims))
         (mv nil
             (vl-datatype-update-udims (cdr udims)
                                       sub-type)))
        (pdims (vl-datatype->pdims sub-type))
        ((when (consp pdims))
         (mv nil
             (vl-datatype-update-pdims
                  (cdr pdims)
                  (vl-datatype-set-unsigned sub-type))))
        ((when (vl-datatype-bitselect-ok sub-type))
         (mv nil
             (make-vl-coretype :name :vl-logic))))
       (mv
        (make-vl-warning
         :type :vl-bad-indexing-operator
         :msg
         "~a0: Can't apply an index operator to ~a1 because ~
                                   it has no dimensions; its type is ~a2."
         :args (list ctx (first x.args) sub-type)
         :fn __function__)
        nil))))

    Theorem: return-type-of-vl-index-find-type.warning

    (defthm return-type-of-vl-index-find-type.warning
      (b* (((mv common-lisp::?warning
                common-lisp::?type)
            (vl-index-find-type x ss ctx)))
        (iff (vl-warning-p warning) warning))
      :rule-classes :rewrite)

    Theorem: return-type-of-vl-index-find-type.type

    (defthm return-type-of-vl-index-find-type.type
      (b* (((mv common-lisp::?warning
                common-lisp::?type)
            (vl-index-find-type x ss ctx)))
        (implies (not warning)
                 (vl-datatype-p type)))
      :rule-classes :rewrite)

    Theorem: context-irrelevance-of-vl-index-find-type

    (defthm context-irrelevance-of-vl-index-find-type
      (implies (syntaxp (not (equal ctx ''nil)))
               (b* (((mv err1 type1)
                     (vl-index-find-type x ss ctx))
                    ((mv err2 type2)
                     (vl-index-find-type x ss nil)))
                 (and (iff err1 err2)
                      (equal type1 type2)))))

    Theorem: vl-index-find-type-of-vl-expr-fix-x

    (defthm vl-index-find-type-of-vl-expr-fix-x
      (equal (vl-index-find-type (vl-expr-fix x)
                                 ss ctx)
             (vl-index-find-type x ss ctx)))

    Theorem: vl-index-find-type-vl-expr-equiv-congruence-on-x

    (defthm vl-index-find-type-vl-expr-equiv-congruence-on-x
      (implies (vl-expr-equiv x x-equiv)
               (equal (vl-index-find-type x ss ctx)
                      (vl-index-find-type x-equiv ss ctx)))
      :rule-classes :congruence)

    Theorem: vl-index-find-type-of-vl-scopestack-fix-ss

    (defthm vl-index-find-type-of-vl-scopestack-fix-ss
      (equal (vl-index-find-type x (vl-scopestack-fix ss)
                                 ctx)
             (vl-index-find-type x ss ctx)))

    Theorem: vl-index-find-type-vl-scopestack-equiv-congruence-on-ss

    (defthm vl-index-find-type-vl-scopestack-equiv-congruence-on-ss
      (implies (vl-scopestack-equiv ss ss-equiv)
               (equal (vl-index-find-type x ss ctx)
                      (vl-index-find-type x ss-equiv ctx)))
      :rule-classes :congruence)

    Theorem: vl-index-find-type-of-identity-ctx

    (defthm vl-index-find-type-of-identity-ctx
      (equal (vl-index-find-type x ss (identity ctx))
             (vl-index-find-type x ss ctx)))

    Theorem: vl-index-find-type-equal-congruence-on-ctx

    (defthm vl-index-find-type-equal-congruence-on-ctx
      (implies (equal ctx ctx-equiv)
               (equal (vl-index-find-type x ss ctx)
                      (vl-index-find-type x ss ctx-equiv)))
      :rule-classes :congruence)