• 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
          • Preprocessor
          • Vl-loadconfig
          • Lexer
          • Vl-loadstate
          • Parser
          • Vl-load-merge-descriptions
          • Scope-of-defines
          • Vl-load-file
          • Vl-flush-out-descriptions
          • Vl-description
          • Vl-loadresult
          • Vl-read-file
          • Vl-find-basename/extension
          • Vl-find-file
          • Vl-read-files
          • Extended-characters
            • Vl-echar-p
            • Vl-location
              • Vl-location-p
              • Vl-location-fix
              • Vl-string-between-locs
              • Vl-location-between-p
              • Vl-string-findloc
                • Vl-string-findloc-aux
                • Vl-location-equiv
                • Make-vl-location
                • Vl-location-string
                • Vl-location->filename
                • Vl-location->line
                • Change-vl-location
                • Vl-location->col
                • *vl-fakeloc*
              • Vl-echarlist->chars
              • Vl-echarlist-from-chars
              • Vl-echarlist-from-str
              • Vl-echarlist-unsigned-value
              • Vl-change-echarlist-locations
              • Vl-echar-digit-value
              • Vl-echarlist->string
            • Vl-load
            • Vl-load-main
            • Vl-load-description
            • Vl-descriptions-left-to-load
            • Inject-warnings
            • Vl-load-descriptions
            • Vl-load-files
            • Vl-load-summary
            • Vl-collect-modules-from-descriptions
            • Vl-descriptionlist
          • Transforms
          • Lint
          • Mlib
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Vl-string-findloc

    Vl-string-findloc-aux

    Signature
    (vl-string-findloc-aux x n xl cline ccol tline tcol) → offset
    Arguments
    x — The string to search.
        Guard (stringp x).
    n — Our current position in x.
        Guard (natp n).
    xl — Precomputed length of x.
        Guard (eql xl (length x)).
    cline — Current line number, corresponding to n.
        Guard (posp cline).
    ccol — Current column number, corresponding to n, except: we don't bother to track this until we reach the desired line.
        Guard (natp ccol).
    tline — Target line number we're looking for.
        Guard (posp tline).
    tcol — Target column number we're looking for.
        Guard (natp tcol).
    Returns
    offset — nil indicates a failure to find the desired location; otherwise the position of the target line/column number.
        Type (maybe-natp offset).

    Definitions and Theorems

    Function: vl-string-findloc-aux

    (defun vl-string-findloc-aux (x n xl cline ccol tline tcol)
     (declare (xargs :guard (and (stringp x)
                                 (natp n)
                                 (posp cline)
                                 (natp ccol)
                                 (posp tline)
                                 (natp tcol)
                                 (eql xl (length x)))))
     (declare (xargs :guard (<= n xl)))
     (let ((__function__ 'vl-string-findloc-aux))
      (declare (ignorable __function__))
      (b* (((when (and (eql cline tline) (eql ccol tcol)))
            (lnfix n))
           ((when (mbe :logic (zp (- (nfix xl) (nfix n)))
                       :exec (eql n xl)))
            nil)
           (curr (char x n)))
       (cond
          ((< cline tline)
           (let ((new-n (+ 1 (lnfix n)))
                 (new-cline (if (eql curr #\Newline)
                                (+ 1 cline)
                              cline)))
             (vl-string-findloc-aux x new-n xl new-cline 0 tline tcol)))
          ((> cline tline) nil)
          ((< ccol tcol)
           (let ((new-n (+ 1 (lnfix n)))
                 (new-cline (if (eql curr #\Newline)
                                (+ 1 cline)
                              cline))
                 (new-ccol (if (eql curr #\Newline) 0 (+ 1 ccol))))
             (vl-string-findloc-aux x new-n
                                    xl new-cline new-ccol tline tcol)))
          (t nil)))))

    Theorem: maybe-natp-of-vl-string-findloc-aux

    (defthm maybe-natp-of-vl-string-findloc-aux
     (b* ((offset (vl-string-findloc-aux x n xl cline ccol tline tcol)))
       (maybe-natp offset))
     :rule-classes :type-prescription)

    Theorem: type-of-vl-string-findloc-aux

    (defthm type-of-vl-string-findloc-aux
      (or (natp (vl-string-findloc-aux x n xl cline ccol tline tcol))
          (not (vl-string-findloc-aux x n xl cline ccol tline tcol)))
      :rule-classes :type-prescription)

    Theorem: bounds-of-vl-string-findloc-aux-1

    (defthm bounds-of-vl-string-findloc-aux-1
     (implies
          (and (natp n) (natp xl) (<= n xl))
          (and (<= 0
                   (vl-string-findloc-aux x n xl cline ccol tline tcol))
               (<= (vl-string-findloc-aux x n xl cline ccol tline tcol)
                   xl)))
     :rule-classes :linear)

    Theorem: bounds-of-vl-string-findloc-aux-2

    (defthm bounds-of-vl-string-findloc-aux-2
     (implies (and (vl-string-findloc-aux x n xl cline ccol tline tcol)
                   (natp n)
                   (natp xl)
                   (<= n xl))
              (<= n
                  (vl-string-findloc-aux x n xl cline ccol tline tcol)))
     :rule-classes :linear)