| author | wenzelm | 
| Sun, 13 Mar 2011 22:55:50 +0100 | |
| changeset 41959 | b460124855b8 | 
| parent 41439 | a31c451183e6 | 
| child 46124 | 3ee75fe01986 | 
| permissions | -rw-r--r-- | 
| 41959 | 1 | (* Title: HOL/Word/Tools/smt_word.ML | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 2 | Author: Sascha Boehme, TU Muenchen | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 3 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 4 | SMT setup for words. | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 5 | *) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 6 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 7 | signature SMT_WORD = | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 8 | sig | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 9 | val setup: theory -> theory | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 10 | end | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 11 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 12 | structure SMT_Word: SMT_WORD = | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 13 | struct | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 14 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 15 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 16 | (* utilities *) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 17 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 18 | fun dest_binT T = | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 19 | (case T of | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 20 |     Type (@{type_name "Numeral_Type.num0"}, _) => 0
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 21 |   | Type (@{type_name "Numeral_Type.num1"}, _) => 1
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 22 |   | Type (@{type_name "Numeral_Type.bit0"}, [T]) => 2 * dest_binT T
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 23 |   | Type (@{type_name "Numeral_Type.bit1"}, [T]) => 1 + 2 * dest_binT T
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 24 |   | _ => raise TYPE ("dest_binT", [T], []))
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 25 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 26 | fun is_wordT (Type (@{type_name word}, _)) = true
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 27 | | is_wordT _ = false | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 28 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 29 | fun dest_wordT (Type (@{type_name word}, [T])) = dest_binT T
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 30 |   | dest_wordT T = raise TYPE ("dest_wordT", [T], [])
 | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 31 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 32 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 33 | (* SMT-LIB logic *) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 34 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 35 | fun smtlib_logic ts = | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 36 | if exists (Term.exists_type (Term.exists_subtype is_wordT)) ts | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 37 | then SOME "QF_AUFBV" | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 38 | else NONE | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 39 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 40 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 41 | (* SMT-LIB builtins *) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 42 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 43 | local | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 44 | val smtlibC = SMTLIB_Interface.smtlibC | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 45 | |
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 46 |   val wordT = @{typ "'a::len word"}
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 47 | |
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 48 | fun index1 n i = n ^ "[" ^ string_of_int i ^ "]" | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 49 | fun index2 n i j = n ^ "[" ^ string_of_int i ^ ":" ^ string_of_int j ^ "]" | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 50 | |
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 51 |   fun word_typ (Type (@{type_name word}, [T])) =
 | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 52 | Option.map (index1 "BitVec") (try dest_binT T) | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 53 | | word_typ _ = NONE | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 54 | |
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 55 |   fun word_num (Type (@{type_name word}, [T])) i =
 | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 56 |         Option.map (index1 ("bv" ^ string_of_int i)) (try dest_binT T)
 | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 57 | | word_num _ _ = NONE | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 58 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 59 | fun if_fixed pred m n T ts = | 
| 41127 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 60 | let val (Us, U) = Term.strip_type T | 
| 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 61 | in | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 62 | if pred (U, Us) then | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 63 | SOME (n, length Us, ts, Term.list_comb o pair (Const (m, T))) | 
| 41127 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 64 | else NONE | 
| 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 65 | end | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 66 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 67 | fun if_fixed_all m = if_fixed (forall (can dest_wordT) o (op ::)) m | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 68 | fun if_fixed_args m = if_fixed (forall (can dest_wordT) o snd) m | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 69 | |
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 70 | fun add_word_fun f (t, n) = | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 71 | let val c as (m, _) = Term.dest_Const t | 
| 41439 
a31c451183e6
avoid ML structure aliases (especially single-letter abbreviations)
 boehmes parents: 
41281diff
changeset | 72 | in SMT_Builtin.add_builtin_fun smtlibC (Term.dest_Const t, K (f m n)) end | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 73 | |
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 74 | fun hd2 xs = hd (tl xs) | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 75 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 76 |   fun mk_nat i = @{const nat} $ HOLogic.mk_number @{typ nat} i
 | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 77 | |
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 78 |   fun dest_nat (@{const nat} $ n) = snd (HOLogic.dest_number n)
 | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 79 |     | dest_nat t = raise TERM ("not a natural number", [t])
 | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 80 | |
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 81 | fun mk_shift c [t, u] = Const c $ t $ mk_nat (snd (HOLogic.dest_number u)) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 82 |     | mk_shift c ts = raise TERM ("bad arguments", Const c :: ts)
 | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 83 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 84 | fun shift m n T ts = | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 85 | let val U = Term.domain_type T | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 86 | in | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 87 | (case (can dest_wordT U, try (dest_nat o hd2) ts) of | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 88 | (true, SOME i) => | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 89 | SOME (n, 2, [hd ts, HOLogic.mk_number U i], mk_shift (m, T)) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 90 | | _ => NONE) (* FIXME: also support non-numerical shifts *) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 91 | end | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 92 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 93 | fun mk_extract c i ts = Term.list_comb (Const c, mk_nat i :: ts) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 94 | |
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 95 | fun extract m n T ts = | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 96 | let val U = Term.range_type (Term.range_type T) | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 97 | in | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 98 | (case (try (dest_nat o hd) ts, try dest_wordT U) of | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 99 | (SOME lb, SOME i) => | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 100 | SOME (index2 n (i + lb - 1) lb, 1, tl ts, mk_extract (m, T) lb) | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 101 | | _ => NONE) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 102 | end | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 103 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 104 | fun mk_extend c ts = Term.list_comb (Const c, ts) | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 105 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 106 | fun extend m n T ts = | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 107 | let val (U1, U2) = Term.dest_funT T | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 108 | in | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 109 | (case (try dest_wordT U1, try dest_wordT U2) of | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 110 | (SOME i, SOME j) => | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 111 | if j-i >= 0 then SOME (index1 n (j-i), 1, ts, mk_extend (m, T)) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 112 | else NONE | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 113 | | _ => NONE) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 114 | end | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 115 | |
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 116 | fun mk_rotate c i ts = Term.list_comb (Const c, mk_nat i :: ts) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 117 | |
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 118 | fun rotate m n T ts = | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 119 | let val U = Term.domain_type (Term.range_type T) | 
| 41127 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 120 | in | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 121 | (case (can dest_wordT U, try (dest_nat o hd) ts) of | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 122 | (true, SOME i) => SOME (index1 n i, 1, tl ts, mk_rotate (m, T) i) | 
| 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 123 | | _ => NONE) | 
| 41127 
2ea84c8535c6
re-implemented eta-expansion, lambda-lifting, and explicit application on terms (exploiting the control over the term structure);
 boehmes parents: 
41072diff
changeset | 124 | end | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 125 | in | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 126 | |
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 127 | val setup_builtins = | 
| 41439 
a31c451183e6
avoid ML structure aliases (especially single-letter abbreviations)
 boehmes parents: 
41281diff
changeset | 128 | SMT_Builtin.add_builtin_typ smtlibC (wordT, word_typ, word_num) #> | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 129 | fold (add_word_fun if_fixed_all) [ | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 130 |     (@{term "uminus :: 'a::len word => _"}, "bvneg"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 131 |     (@{term "plus :: 'a::len word => _"}, "bvadd"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 132 |     (@{term "minus :: 'a::len word => _"}, "bvsub"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 133 |     (@{term "times :: 'a::len word => _"}, "bvmul"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 134 |     (@{term "bitNOT :: 'a::len word => _"}, "bvnot"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 135 |     (@{term "bitAND :: 'a::len word => _"}, "bvand"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 136 |     (@{term "bitOR :: 'a::len word => _"}, "bvor"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 137 |     (@{term "bitXOR :: 'a::len word => _"}, "bvxor"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 138 |     (@{term "word_cat :: 'a::len word => _"}, "concat") ] #>
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 139 | fold (add_word_fun shift) [ | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 140 |     (@{term "shiftl :: 'a::len word => _ "}, "bvshl"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 141 |     (@{term "shiftr :: 'a::len word => _"}, "bvlshr"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 142 |     (@{term "sshiftr :: 'a::len word => _"}, "bvashr") ] #>
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 143 | add_word_fun extract | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 144 |     (@{term "slice :: _ => 'a::len word => _"}, "extract") #>
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 145 | fold (add_word_fun extend) [ | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 146 |     (@{term "ucast :: 'a::len word => _"}, "zero_extend"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 147 |     (@{term "scast :: 'a::len word => _"}, "sign_extend") ] #>
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 148 | fold (add_word_fun rotate) [ | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 149 |     (@{term word_rotl}, "rotate_left"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 150 |     (@{term word_rotr}, "rotate_right") ] #>
 | 
| 41281 
679118e35378
removed odd decoration of built-in symbols as Vars (instead provide built-in desctructor functions along with their inverse functions);
 boehmes parents: 
41127diff
changeset | 151 | fold (add_word_fun if_fixed_args) [ | 
| 41061 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 152 |     (@{term "less :: 'a::len word => _"}, "bvult"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 153 |     (@{term "less_eq :: 'a::len word => _"}, "bvule"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 154 |     (@{term word_sless}, "bvslt"),
 | 
| 
492f8fd35fc0
centralized handling of built-in types and constants for bitvectors
 boehmes parents: 
41060diff
changeset | 155 |     (@{term word_sle}, "bvsle") ]
 | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 156 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 157 | end | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 158 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 159 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 160 | (* setup *) | 
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 161 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 162 | val setup = | 
| 41072 
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
 boehmes parents: 
41061diff
changeset | 163 | Context.theory_map ( | 
| 
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
 boehmes parents: 
41061diff
changeset | 164 | SMTLIB_Interface.add_logic (20, smtlib_logic) #> | 
| 
9f9bc1bdacef
be more flexible: store SMT built-in symbols in generic contexts (not in theory contexts)
 boehmes parents: 
41061diff
changeset | 165 | setup_builtins) | 
| 41060 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 166 | |
| 
4199fdcfa3c0
moved smt_word.ML into the directory of the Word library
 boehmes parents: diff
changeset | 167 | end |