• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
          • Bip32
          • Bech32
          • Bip39
            • *bip39-english-words*
            • Bip39-mnemonic-to-seed
            • Bip39-entropy-to-word-indexes
            • Bip39-entropy
            • Bip39-word-indexes-to-words
              • Bip39-words-to-mnemonic
              • Bip39-entropy-to-seed
              • Bip39-entropy-to-mnemonic
              • Bip39-english-words-bound-p
              • Bip39-entropy-size-p
            • Bip44
            • Base58
            • Bip43
            • Bytes
            • Base58check
            • Cryptography
            • Bip-350
            • Bip-173
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Bip39

    Bip39-word-indexes-to-words

    Map each 11-bit index to a word from the predefined wordlist, which consists of 2,048 words.

    Signature
    (bip39-word-indexes-to-words indexes) → words
    Arguments
    indexes — Guard (ubyte11-listp indexes).
    Returns
    words — Type (string-listp words).

    The resulting words have always a length bounded by the maximum length of the English words, namely 8. This is because the words are taken from the English worlist. This theorem is proved from the fact that nth applied to *bip39-english-words* always yields a value whose length is less than or equal to 8. This fact should be provable directly by forcing the expansion of nth, but it seem to take a long time, presumably due to the length of the wordlist. So instead we prove it via a few local lemmas that use a locally defined function.

    Definitions and Theorems

    Function: bip39-word-indexes-to-words

    (defun bip39-word-indexes-to-words (indexes)
      (declare (xargs :guard (ubyte11-listp indexes)))
      (cond ((endp indexes) nil)
            (t (cons (nth (ubyte11-fix (car indexes))
                          *bip39-english-words*)
                     (bip39-word-indexes-to-words (cdr indexes))))))

    Theorem: string-listp-of-bip39-word-indexes-to-words

    (defthm string-listp-of-bip39-word-indexes-to-words
      (b* ((words (bip39-word-indexes-to-words indexes)))
        (string-listp words))
      :rule-classes :rewrite)

    Theorem: len-of-bip39-word-indexes-to-words

    (defthm len-of-bip39-word-indexes-to-words
      (equal (len (bip39-word-indexes-to-words indexes))
             (len indexes)))

    Theorem: bip39-words-bounded-p-of-bip39-word-indexes-to-words

    (defthm bip39-words-bounded-p-of-bip39-word-indexes-to-words
      (bip39-english-words-bound-p
           (bip39-word-indexes-to-words indexes)))

    Theorem: bip39-word-indexes-to-words-of-ubyte11-list-fix-indexes

    (defthm bip39-word-indexes-to-words-of-ubyte11-list-fix-indexes
     (equal
          (bip39-word-indexes-to-words (acl2::ubyte11-list-fix indexes))
          (bip39-word-indexes-to-words indexes)))

    Theorem: bip39-word-indexes-to-words-ubyte11-list-equiv-congruence-on-indexes

    (defthm
     bip39-word-indexes-to-words-ubyte11-list-equiv-congruence-on-indexes
     (implies (acl2::ubyte11-list-equiv indexes indexes-equiv)
              (equal (bip39-word-indexes-to-words indexes)
                     (bip39-word-indexes-to-words indexes-equiv)))
     :rule-classes :congruence)