src/HOL/Main.thy
changeset 13367 ad307f0d80db
parent 13093 ab0335307905
child 13403 bc2b32ee62fd
     1.1 --- a/src/HOL/Main.thy	Tue Jul 16 18:26:36 2002 +0200
     1.2 +++ b/src/HOL/Main.thy	Tue Jul 16 18:26:52 2002 +0200
     1.3 @@ -13,85 +13,6 @@
     1.4    PreList} already includes most HOL theories.
     1.5  *}
     1.6  
     1.7 -text {* Belongs to theory List. *}
     1.8 -declare lists_mono [mono]
     1.9 -declare map_cong [recdef_cong]
    1.10 -lemmas rev_induct [case_names Nil snoc] = rev_induct
    1.11 -  and rev_cases [case_names Nil snoc] = rev_exhaust
    1.12 -
    1.13 -
    1.14 -subsection {* Characters and strings *}
    1.15 -
    1.16 -datatype nibble =
    1.17 -    Nibble0 | Nibble1 | Nibble2 | Nibble3 | Nibble4 | Nibble5 | Nibble6 | Nibble7
    1.18 -  | Nibble8 | Nibble9 | NibbleA | NibbleB | NibbleC | NibbleD | NibbleE | NibbleF
    1.19 -
    1.20 -datatype char = Char nibble nibble
    1.21 -  -- "Note: canonical order of character encoding coincides with standard term ordering"
    1.22 -
    1.23 -types string = "char list"
    1.24 -
    1.25 -syntax
    1.26 -  "_Char" :: "xstr => char"    ("CHR _")
    1.27 -  "_String" :: "xstr => string"    ("_")
    1.28 -
    1.29 -parse_ast_translation {*
    1.30 -  let
    1.31 -    val constants = Syntax.Appl o map Syntax.Constant;
    1.32 -
    1.33 -    fun mk_nib n = "Nibble" ^ chr (n + (if n <= 9 then ord "0" else ord "A" - 10));
    1.34 -    fun mk_char c =
    1.35 -      if Symbol.is_ascii c andalso Symbol.is_printable c then
    1.36 -        constants ["Char", mk_nib (ord c div 16), mk_nib (ord c mod 16)]
    1.37 -      else error ("Printable ASCII character expected: " ^ quote c);
    1.38 -
    1.39 -    fun mk_string [] = Syntax.Constant "Nil"
    1.40 -      | mk_string (c :: cs) = Syntax.Appl [Syntax.Constant "Cons", mk_char c, mk_string cs];
    1.41 -
    1.42 -    fun char_ast_tr [Syntax.Variable xstr] =
    1.43 -        (case Syntax.explode_xstr xstr of
    1.44 -          [c] => mk_char c
    1.45 -        | _ => error ("Single character expected: " ^ xstr))
    1.46 -      | char_ast_tr asts = raise AST ("char_ast_tr", asts);
    1.47 -
    1.48 -    fun string_ast_tr [Syntax.Variable xstr] =
    1.49 -        (case Syntax.explode_xstr xstr of
    1.50 -          [] => constants [Syntax.constrainC, "Nil", "string"]
    1.51 -        | cs => mk_string cs)
    1.52 -      | string_ast_tr asts = raise AST ("string_tr", asts);
    1.53 -  in [("_Char", char_ast_tr), ("_String", string_ast_tr)] end;
    1.54 -*}
    1.55 -
    1.56 -print_ast_translation {*
    1.57 -  let
    1.58 -    fun dest_nib (Syntax.Constant c) =
    1.59 -        (case explode c of
    1.60 -          ["N", "i", "b", "b", "l", "e", h] =>
    1.61 -            if "0" <= h andalso h <= "9" then ord h - ord "0"
    1.62 -            else if "A" <= h andalso h <= "F" then ord h - ord "A" + 10
    1.63 -            else raise Match
    1.64 -        | _ => raise Match)
    1.65 -      | dest_nib _ = raise Match;
    1.66 -
    1.67 -    fun dest_chr c1 c2 =
    1.68 -      let val c = chr (dest_nib c1 * 16 + dest_nib c2)
    1.69 -      in if Symbol.is_printable c then c else raise Match end;
    1.70 -
    1.71 -    fun dest_char (Syntax.Appl [Syntax.Constant "Char", c1, c2]) = dest_chr c1 c2
    1.72 -      | dest_char _ = raise Match;
    1.73 -
    1.74 -    fun xstr cs = Syntax.Appl [Syntax.Constant "_xstr", Syntax.Variable (Syntax.implode_xstr cs)];
    1.75 -
    1.76 -    fun char_ast_tr' [c1, c2] = Syntax.Appl [Syntax.Constant "_Char", xstr [dest_chr c1 c2]]
    1.77 -      | char_ast_tr' _ = raise Match;
    1.78 -
    1.79 -    fun list_ast_tr' [args] = Syntax.Appl [Syntax.Constant "_String",
    1.80 -            xstr (map dest_char (Syntax.unfold_ast "_args" args))]
    1.81 -      | list_ast_tr' ts = raise Match;
    1.82 -  in [("Char", char_ast_tr'), ("@list", list_ast_tr')] end;
    1.83 -*}
    1.84 -
    1.85 -
    1.86  subsection {* Configuration of the code generator *}
    1.87  
    1.88  types_code