• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
          • Vl-lint
            • Vl-lintconfig-p
            • Condcheck
            • Lint-warning-suppression
            • Lucid
            • Lvaluecheck
            • Vl-interfacelist-alwaysstyle
            • Truncation-warnings
            • Vl-modulelist-alwaysstyle
            • Skip-detection
            • Vl-lint-report
            • Vl-lintresult
            • Vl::vl-design-sv-use-set
            • Oddexpr-check
            • Leftright-check
              • Vl-packagelist-leftright-check
              • Vl-modulelist-leftright-check
              • Vl-interfacelist-leftright-check
              • Vl-collect-ac-args
              • Vl-leftright-exprlist-duplicates
                • Vl-interface-leftright-check
                • Vl-package-leftright-check
                • Vl-module-leftright-check
                • Vl-expr-leftright-check1
                • Vl-expr-leftright-check
                • Vl-expr-indexy-via-ctx
                • Vl-ctxexprlist-leftright-check
                • Vl-design-leftright-check
                • Vl-ctxexprlist-leftright-check-nrev
                • Vl-op-ac-p
              • Duplicate-detect
              • Selfassigns
              • *vl-lint-help*
              • Arith-compare-check
              • Dupeinst-check
              • Qmarksize-check
              • Lint-whole-file-suppression
              • Run-vl-lint-main
              • Logicassign
              • Run-vl-lint
              • Vl-print-certain-warnings
              • Duperhs-check
              • Vl-lint-top
              • Sd-filter-problems
              • Vl-modulelist-add-svbad-warnings
              • Vl-module-add-svbad-warnings
              • Check-case
              • Vl-lint-extra-actions
              • Drop-lint-stubs
              • Vl-lint-print-warnings
              • Drop-user-submodules
              • Check-namespace
              • Vl-lintconfig-loadconfig
              • Vl-lint-design->svex-modalist-wrapper
              • Vl-delete-sd-problems-for-modnames-aux
              • Vl-collect-new-names-from-orignames
              • Vl-lint-print-all-warnings
              • Vl-design-remove-unnecessary-modules
              • Vl-delete-sd-problems-for-modnames
              • Vl-always-check-style
              • Vl-vardecllist-svbad-warnings
              • Vl-vardecl-svbad-warnings
              • Vl-reportcard-remove-suppressed
              • Vl-reportcard-keep-suppressed
              • Vl-alwayslist-check-style
              • Vl-remove-nameless-descriptions
              • Vl-lint-apply-quiet
              • Vl-warninglist-remove-suppressed
              • Vl-warninglist-keep-suppressed
              • Vl-print-eliminated-descs
              • Vl-module-alwaysstyle
              • Vl-jp-reportcard-aux
              • Vl-interface-alwaysstyle
              • Vl-design-alwaysstyle
              • Vl-jp-description-locations
              • Vl-jp-reportcard
              • Vl-pp-stringlist-lines
              • Vl-jp-design-locations
              • Vl-datatype-svbad-p
              • Unpacked-range-check
              • Sd-problem-major-p
              • Vl-alwaysstyle
            • Vl-server
            • Vl-gather
            • Vl-zip
            • Vl-main
            • Split-plusargs
            • Vl-shell
            • Vl-json
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Leftright-check

    Vl-leftright-exprlist-duplicates

    Optimized duplicate expression gatherer for leftright checking.

    Signature
    (vl-leftright-exprlist-duplicates x) → *
    Arguments
    x — Guard (vl-exprlist-p x).

    Originally I just used duplicated-members to check for duplicates. Profiling revealed that this was expensive. To speed it up, I made a benchmark out of some real calls of duplicated-members for leftright checking. Out of 396,966 calls, 396,945 of them (99.99+%) had no duplicated members. Furthermore, short lists are extremely common:

    • 150,302 of them have only 2 elements (37%)
    • 45,301 of them have only 3 elements (11%)
    • 31,930 of them have only 4 elements (8%)
    • 25,516 of them have only 5 elements (6%)

    However, there are occasionally very long lists with over 600+ members. This function is just an optimized alternative to duplicated-members that seems to perform well on this kind of data set. We gain significant performance out of this function by memoizing vl-expr-strip.

    Definitions and Theorems

    Function: vl-leftright-exprlist-duplicates

    (defun vl-leftright-exprlist-duplicates (x)
      (declare (xargs :guard (vl-exprlist-p x)))
      (declare (xargs :guard (true-listp x)))
      (let ((__function__ 'vl-leftright-exprlist-duplicates))
        (declare (ignorable __function__))
        (mbe :logic
             (hons-duplicated-members (vl-exprlist-fix x))
             :exec
             (b* (((when (longer-than-p 25 x))
                   (hons-duplicated-members x))
                  ((when (no-duplicatesp-equal x)) nil))
               (hons-duplicated-members x)))))

    Theorem: vl-leftright-exprlist-duplicates-of-vl-exprlist-fix-x

    (defthm vl-leftright-exprlist-duplicates-of-vl-exprlist-fix-x
      (equal (vl-leftright-exprlist-duplicates (vl-exprlist-fix x))
             (vl-leftright-exprlist-duplicates x)))

    Theorem: vl-leftright-exprlist-duplicates-vl-exprlist-equiv-congruence-on-x

    (defthm
     vl-leftright-exprlist-duplicates-vl-exprlist-equiv-congruence-on-x
     (implies (vl-exprlist-equiv x x-equiv)
              (equal (vl-leftright-exprlist-duplicates x)
                     (vl-leftright-exprlist-duplicates x-equiv)))
     :rule-classes :congruence)