• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
        • Transforms
          • Expression-sizing
          • 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
            • Make-implicit-wires
              • Vl-modulelist-make-implicit-wires
              • Vl-make-implicit-wires-aux
              • Shadowcheck
                • Vl-shadowcheck-reference-name
                • Vl-shadowcheck-aux
                • Vl-shadowcheck-reference-names
                • Vl-shadowcheck-declare-names
                • Vl-shadowcheck-declare-name
                • Vl-shadowcheck-fundecl
                • Vl-shadowcheck-declare-typedefs
                • Vl-shadowcheck-blockitemlist
                • Vl-shadowcheck-taskdecl
                • Vl-shadowcheck-portdecllist
                • Vl-shadowcheck-paramdecls
                • Vl-shadowcheck-taskdecls
                • Vl-shadowcheck-paramdecl
                • Vl-shadowcheck-gateinst
                • Vl-shadowcheck-vardecls
                • Vl-shadowcheck-vardecl
                • Vl-shadowcheck-portdecl
                • Vl-shadowcheck-modinst
                • Vl-shadowcheck-imports
                • Vl-shadowcheck-import
                • Vl-shadowcheck-fundecls
                • Vl-shadowcheck-blockitem
                • Vl-shadowcheck-ports
                • Vl-shadowcheck-port
                • Vl-shadowcheck-initial
                • Vl-shadowcheck-assign
                • Vl-shadowcheck-always
                • Vl-shadowcheck-alias
                • Vl-shadowcheck-state
                • Vl-shadowcheck-module
                • Vl-shadowcheck-modules
                • Vl-shadowcheck-push-scope
                • Vl-lexscopes
                  • Vl-lexscopes-fix
                  • Vl-lexscopes-direct-import-name
                    • Vl-lexscopes-wild-import-name
                    • Vl-lexscopes-wild-import-names
                    • Vl-lexscopes-declare-name
                    • Vl-lexscopes-do-import
                    • Vl-lexscopes-find
                    • Vl-lexscopes-equiv
                    • Vl-lexscopes-p
                    • Vl-lexscopes-exit-scope
                    • Vl-lexscopes-enter-new-scope
                  • Vl-shadowcheck-design
                  • Vl-shadowcheck-pop-scope
                  • Vl-lexscope
                • Vl-stmt-check-undeclared
                • Vl-make-implicit-wires-main
                • Vl-fundecl-check-undeclared
                • Vl-warn-about-undeclared-wires
                • Vl-implicitst
                • Vl-blockitem-check-undeclared
                • Vl-taskdecl-check-undeclared
                • Vl-modinst-exprs-for-implicit-wires
                • Vl-blockitemlist-check-undeclared
                • Vl-import-check-undeclared
                • Vl-make-ordinary-implicit-wires
                • Vl-gateinst-exprs-for-implicit-wires
                • Vl-remove-declared-wires
                • Vl-make-port-implicit-wires
                • Vl-module-make-implicit-wires
                • Vl-vardecl-exprs-for-implicit-wires
                • Vl-design-make-implicit-wires
              • Resolve-indexing
              • Origexprs
              • Argresolve
              • Portdecl-sign
              • Designwires
              • Udp-elim
              • Vl-annotate-design
            • 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-lexscopes

    Vl-lexscopes-direct-import-name

    Extend the lexscopes with a direct import of a single name.

    Signature
    (vl-lexscopes-direct-import-name pkgname name scopes ctx warnings) 
      → 
    (mv scopes warnings)
    Arguments
    pkgname — Name of the package being imported from.
        Guard (stringp pkgname).
    name — Name being directly imported from the package.
        Guard (stringp name).
    scopes — Guard (vl-lexscopes-p scopes).
    ctx — Guard (vl-import-p ctx).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    scopes — Type (vl-lexscopes-p scopes).
    warnings — Type (vl-warninglist-p warnings).

    Definitions and Theorems

    Function: vl-lexscopes-direct-import-name

    (defun vl-lexscopes-direct-import-name
           (pkgname name scopes ctx warnings)
     (declare (xargs :guard (and (stringp pkgname)
                                 (stringp name)
                                 (vl-lexscopes-p scopes)
                                 (vl-import-p ctx)
                                 (vl-warninglist-p warnings))))
     (let ((__function__ 'vl-lexscopes-direct-import-name))
      (declare (ignorable __function__))
      (b*
       ((pkgname (string-fix pkgname))
        (name (string-fix name))
        (scopes (vl-lexscopes-fix scopes))
        (ctx (vl-import-fix ctx))
        (warnings (vl-warninglist-fix warnings))
        ((when (atom scopes))
         (raise "Expected at least one scope.")
         (mv scopes warnings))
        (scope1 (car scopes))
        (entry (vl-lexscope-find name scope1))
        ((unless entry)
         (mv
           (cons (hons-acons name
                             (make-vl-lexscope-entry :direct-pkg pkgname
                                                     :decl nil
                                                     :wildpkgs nil)
                             scope1)
                 (cdr scopes))
           warnings))
        ((vl-lexscope-entry entry))
        (warnings
         (if entry.decl
          (fatal
               :type :vl-name-clash
               :msg
               "~a0: can't import ~s1 after locally declaring it (~a2)."
               :args (list ctx name entry.decl))
          warnings))
        (warnings
         (if
          (and entry.direct-pkg
               (not (equal entry.direct-pkg pkgname)))
          (fatal
           :type :vl-name-clash
           :msg
           "~a0: can't import ~s1 from ~s2 after previously importing ~
                             it from ~s3."
           :args (list ctx name pkgname entry.direct-pkg))
          warnings))
        (new-entry (if (or entry.decl entry.direct-pkg)
                       entry
                     (change-vl-lexscope-entry entry
                                               :direct-pkg pkgname)))
        (new-scope1 (hons-acons name new-entry scope1))
        (new-scopes (cons new-scope1 (cdr scopes))))
       (mv new-scopes warnings))))

    Theorem: vl-lexscopes-p-of-vl-lexscopes-direct-import-name.scopes

    (defthm vl-lexscopes-p-of-vl-lexscopes-direct-import-name.scopes
      (b* (((mv ?scopes ?warnings)
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)))
        (vl-lexscopes-p scopes))
      :rule-classes :rewrite)

    Theorem: vl-warninglist-p-of-vl-lexscopes-direct-import-name.warnings

    (defthm vl-warninglist-p-of-vl-lexscopes-direct-import-name.warnings
      (b* (((mv ?scopes ?warnings)
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)))
        (vl-warninglist-p warnings))
      :rule-classes :rewrite)

    Theorem: vl-lexscopes-direct-import-name-of-str-fix-pkgname

    (defthm vl-lexscopes-direct-import-name-of-str-fix-pkgname
      (equal (vl-lexscopes-direct-import-name (str-fix pkgname)
                                              name scopes ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-streqv-congruence-on-pkgname

    (defthm vl-lexscopes-direct-import-name-streqv-congruence-on-pkgname
     (implies
       (streqv pkgname pkgname-equiv)
       (equal
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)
            (vl-lexscopes-direct-import-name pkgname-equiv
                                             name scopes ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-str-fix-name

    (defthm vl-lexscopes-direct-import-name-of-str-fix-name
      (equal (vl-lexscopes-direct-import-name pkgname (str-fix name)
                                              scopes ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-streqv-congruence-on-name

    (defthm vl-lexscopes-direct-import-name-streqv-congruence-on-name
      (implies (streqv name name-equiv)
               (equal (vl-lexscopes-direct-import-name
                           pkgname name scopes ctx warnings)
                      (vl-lexscopes-direct-import-name
                           pkgname
                           name-equiv scopes ctx warnings)))
      :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-lexscopes-fix-scopes

    (defthm vl-lexscopes-direct-import-name-of-vl-lexscopes-fix-scopes
      (equal (vl-lexscopes-direct-import-name
                  pkgname name (vl-lexscopes-fix scopes)
                  ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-lexscopes-equiv-congruence-on-scopes

    (defthm
     vl-lexscopes-direct-import-name-vl-lexscopes-equiv-congruence-on-scopes
     (implies (vl-lexscopes-equiv scopes scopes-equiv)
              (equal (vl-lexscopes-direct-import-name
                          pkgname name scopes ctx warnings)
                     (vl-lexscopes-direct-import-name
                          pkgname
                          name scopes-equiv ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-import-fix-ctx

    (defthm vl-lexscopes-direct-import-name-of-vl-import-fix-ctx
      (equal (vl-lexscopes-direct-import-name
                  pkgname name scopes (vl-import-fix ctx)
                  warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-import-equiv-congruence-on-ctx

    (defthm
      vl-lexscopes-direct-import-name-vl-import-equiv-congruence-on-ctx
      (implies (vl-import-equiv ctx ctx-equiv)
               (equal (vl-lexscopes-direct-import-name
                           pkgname name scopes ctx warnings)
                      (vl-lexscopes-direct-import-name
                           pkgname
                           name scopes ctx-equiv warnings)))
      :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-warninglist-fix-warnings

    (defthm
         vl-lexscopes-direct-import-name-of-vl-warninglist-fix-warnings
      (equal (vl-lexscopes-direct-import-name
                  pkgname name scopes
                  ctx (vl-warninglist-fix warnings))
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-warninglist-equiv-congruence-on-warnings

    (defthm
     vl-lexscopes-direct-import-name-vl-warninglist-equiv-congruence-on-warnings
     (implies (vl-warninglist-equiv warnings warnings-equiv)
              (equal (vl-lexscopes-direct-import-name
                          pkgname name scopes ctx warnings)
                     (vl-lexscopes-direct-import-name
                          pkgname
                          name scopes ctx warnings-equiv)))
     :rule-classes :congruence)