Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance word automation procedures WORD_ARITH and BITBLAST_RULE #110

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

jargh
Copy link
Contributor

@jargh jargh commented Sep 19, 2024

This makes the word decision procedures WORD_ARITH/WORD_ARITH_TAC and BITBLAST_RULE more capable in several ways:

  • Both BITBLAST_RULE and WORD_ARITH make more systematic reduction of word ground expressions internally.

  • BITBLAST_RULE now transforms "val(x) MOD n" and "val(x) DIV n" where n is (or can be transformed into) a power of 2, into bitwise equivalents so that the core procedure can handle it.

  • WORD_ARITH also expands "val(word n)" into "n MOD ...." after all the casewise "linear" expansions have been tried, giving it some capacity to handle multiplication by constants.

  • The underlying integer arithmetic procedure INT_ARITH has been enhanced so that it is never worse to use it than the natural number version, because it will infer nonnegativity of quotients introduced by div/rem elimination where possible.

Here are some word examples that work now but didn't before:

WORD_ARITH
!m n. m < 4096 /\ n <= 511 ==> word_ule (word_add (word_mul (word n) (word 0x00001000)) (word m)) (word 0x0000000001FFFFFF:int64);;

BITBLAST_RULE
word_and x (word 256):int64 = word 0 <=> val x MOD 512 < 256;;

This makes the word decision procedures WORD_ARITH/WORD_ARITH_TAC
and BITBLAST_RULE more capable in several ways:

 * Both BITBLAST_RULE and WORD_ARITH make more systematic reduction
   of word ground expressions internally.

 * BITBLAST_RULE now transforms "val(x) MOD n" and "val(x) DIV n"
   where n is (or can be transformed into) a power of 2, into
   bitwise equivalents so that the core procedure can handle it.

 * WORD_ARITH also expands "val(word n)" into "n MOD ...." after
   all the casewise "linear" expansions have been tried, giving
   it some capacity to handle multiplication by constants.

 * The underlying integer arithmetic procedure INT_ARITH has been
   enhanced so that it is never worse to use it than the natural
   number version, because it will infer nonnegativity of quotients
   introduced by div/rem elimination where possible.

Here are some word examples that work now but didn't before:

 WORD_ARITH
   `!m n. m < 4096 /\ n <= 511
        ==> word_ule (word_add (word_mul (word n) (word 0x00001000)) (word m))
                     (word 0x0000000001FFFFFF:int64)`;;

  BITBLAST_RULE
    `word_and x (word 256):int64 = word 0 <=> val x MOD 512 < 256`;;
@jrh13 jrh13 merged commit 5af59fc into jrh13:master Sep 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants