src/HOL/hologic.ML
changeset 23247 b99dce43d252
parent 22994 02440636214f
child 23269 851b8ea067ac
equal deleted inserted replaced
23246:309a57cae012 23247:b99dce43d252
    69   val zero: term
    69   val zero: term
    70   val is_zero: term -> bool
    70   val is_zero: term -> bool
    71   val mk_Suc: term -> term
    71   val mk_Suc: term -> term
    72   val dest_Suc: term -> term
    72   val dest_Suc: term -> term
    73   val Suc_zero: term
    73   val Suc_zero: term
    74   val mk_nat: IntInf.int -> term
    74   val mk_nat: integer -> term
    75   val dest_nat: term -> IntInf.int
    75   val dest_nat: term -> integer
    76   val class_size: string
    76   val class_size: string
    77   val size_const: typ -> term
    77   val size_const: typ -> term
    78   val bitT: typ
    78   val bitT: typ
    79   val B0_const: term
    79   val B0_const: term
    80   val B1_const: term
    80   val B1_const: term
    82   val dest_bit: term -> int
    82   val dest_bit: term -> int
    83   val intT: typ
    83   val intT: typ
    84   val pls_const: term
    84   val pls_const: term
    85   val min_const: term
    85   val min_const: term
    86   val bit_const: term
    86   val bit_const: term
    87   val mk_numeral: IntInf.int -> term
    87   val mk_numeral: integer -> term
    88   val dest_numeral: term -> IntInf.int
    88   val dest_numeral: term -> integer
    89   val number_of_const: typ -> term
    89   val number_of_const: typ -> term
    90   val add_numerals_of: term -> (term * typ) list -> (term * typ) list
    90   val add_numerals_of: term -> (term * typ) list -> (term * typ) list
    91   val mk_number: typ -> IntInf.int -> term
    91   val mk_number: typ -> integer -> term
    92   val dest_number: term -> typ * IntInf.int
    92   val dest_number: term -> typ * integer
    93   val realT: typ
    93   val realT: typ
    94   val nibbleT: typ
    94   val nibbleT: typ
    95   val mk_nibble: int -> term
    95   val mk_nibble: int -> term
    96   val dest_nibble: term -> int
    96   val dest_nibble: term -> int
    97   val charT: typ
    97   val charT: typ
   184 fun choice_const T = Const("Hilbert_Choice.Eps", (T --> boolT) --> T);
   184 fun choice_const T = Const("Hilbert_Choice.Eps", (T --> boolT) --> T);
   185 
   185 
   186 fun Collect_const T = Const ("Collect", [T --> boolT] ---> mk_setT T);
   186 fun Collect_const T = Const ("Collect", [T --> boolT] ---> mk_setT T);
   187 fun mk_Collect (a, T, t) = Collect_const T $ absfree (a, T, t);
   187 fun mk_Collect (a, T, t) = Collect_const T $ absfree (a, T, t);
   188 
   188 
   189 val class_eq = "Code_Generator.eq";
   189 val class_eq = "HOL.eq";
   190 
   190 
   191 fun mk_mem (x, A) =
   191 fun mk_mem (x, A) =
   192   let val setT = fastype_of A in
   192   let val setT = fastype_of A in
   193     Const ("op :", [dest_setT setT, setT] ---> boolT) $ x $ A
   193     Const ("op :", [dest_setT setT, setT] ---> boolT) $ x $ A
   194   end;
   194   end;
   296 val Suc_zero = mk_Suc zero;
   296 val Suc_zero = mk_Suc zero;
   297 
   297 
   298 fun mk_nat n =
   298 fun mk_nat n =
   299   let
   299   let
   300     fun mk 0 = zero
   300     fun mk 0 = zero
   301       | mk n = mk_Suc (mk (IntInf.- (n, 1)));
   301       | mk n = mk_Suc (mk (n -% 1));
   302   in if IntInf.< (n, 0)
   302   in if n < 0
   303     then error "mk_nat: negative numeral"
   303     then error "mk_nat: negative numeral"
   304     else mk n
   304     else mk n
   305   end;
   305   end;
   306 
   306 
   307 fun dest_nat (Const ("HOL.zero_class.zero", _)) = 0
   307 fun dest_nat (Const ("HOL.zero_class.zero", _)) = Integer.zero
   308   | dest_nat (Const ("Suc", _) $ t) = IntInf.+ (dest_nat t, 1)
   308   | dest_nat (Const ("Suc", _) $ t) = Integer.inc (dest_nat t)
   309   | dest_nat t = raise TERM ("dest_nat", [t]);
   309   | dest_nat t = raise TERM ("dest_nat", [t]);
   310 
   310 
   311 val class_size = "Nat.size";
   311 val class_size = "Nat.size";
   312 
   312 
   313 fun size_const T = Const ("Nat.size_class.size", T --> natT);
   313 fun size_const T = Const ("Nat.size_class.size", T --> natT);
   333 
   333 
   334 val intT = Type ("IntDef.int", []);
   334 val intT = Type ("IntDef.int", []);
   335 
   335 
   336 val pls_const = Const ("Numeral.Pls", intT)
   336 val pls_const = Const ("Numeral.Pls", intT)
   337 and min_const = Const ("Numeral.Min", intT)
   337 and min_const = Const ("Numeral.Min", intT)
   338 and bit_const = Const ("Numeral.Bit", [intT, bitT] ---> intT);
   338 and bit_const = Const ("Numeral.Bit", intT --> bitT --> intT);
   339 
   339 
   340 fun mk_numeral 0 = pls_const
   340 fun mk_numeral 0 = pls_const
   341   | mk_numeral ~1 = min_const
   341   | mk_numeral ~1 = min_const
   342   | mk_numeral i =
   342   | mk_numeral i =
   343       let val (q, r) = IntInf.divMod (i, 2)
   343       let val (q, r) = Integer.divmod i 2
   344       in bit_const $ mk_numeral q $ mk_bit (IntInf.toInt r) end;
   344       in bit_const $ mk_numeral q $ mk_bit (Integer.machine_int r) end;
   345 
   345 
   346 fun dest_numeral (Const ("Numeral.Pls", _)) = 0
   346 fun dest_numeral (Const ("Numeral.Pls", _)) = 0
   347   | dest_numeral (Const ("Numeral.Min", _)) = ~1
   347   | dest_numeral (Const ("Numeral.Min", _)) = ~1
   348   | dest_numeral (Const ("Numeral.Bit", _) $ bs $ b) =
   348   | dest_numeral (Const ("Numeral.Bit", _) $ bs $ b) =
   349       2 * dest_numeral bs + IntInf.fromInt (dest_bit b)
   349       2 *% dest_numeral bs +% Integer.int (dest_bit b)
   350   | dest_numeral t = raise TERM ("dest_numeral", [t]);
   350   | dest_numeral t = raise TERM ("dest_numeral", [t]);
   351 
   351 
   352 fun number_of_const T = Const ("Numeral.number_class.number_of", intT --> T);
   352 fun number_of_const T = Const ("Numeral.number_class.number_of", intT --> T);
   353 
   353 
   354 fun add_numerals_of (Const _) =
   354 fun add_numerals_of (Const _) =