src/HOL/Import/proof_kernel.ML
changeset 30346 90efbb8a8cb2
parent 30190 479806475f3c
child 30447 955190fa639b
equal deleted inserted replaced
30345:76fd85bbf139 30346:90efbb8a8cb2
  1924         val (info,rhs') = disamb_term rhs
  1924         val (info,rhs') = disamb_term rhs
  1925         val ctype = type_of rhs'
  1925         val ctype = type_of rhs'
  1926         val csyn = mk_syn thy constname
  1926         val csyn = mk_syn thy constname
  1927         val thy1 = case HOL4DefThy.get thy of
  1927         val thy1 = case HOL4DefThy.get thy of
  1928                        Replaying _ => thy
  1928                        Replaying _ => thy
  1929                      | _ => (ImportRecorder.add_consts [(constname, ctype, csyn)]; Sign.add_consts_i [(constname,ctype,csyn)] thy)
  1929                      | _ => (ImportRecorder.add_consts [(constname, ctype, csyn)];
       
  1930                               Sign.add_consts_i [(Binding.name constname,ctype,csyn)] thy)
  1930         val eq = mk_defeq constname rhs' thy1
  1931         val eq = mk_defeq constname rhs' thy1
  1931         val (thms, thy2) = PureThy.add_defs false [((Binding.name thmname,eq),[])] thy1
  1932         val (thms, thy2) = PureThy.add_defs false [((Binding.name thmname,eq),[])] thy1
  1932         val _ = ImportRecorder.add_defs thmname eq
  1933         val _ = ImportRecorder.add_defs thmname eq
  1933         val def_thm = hd thms
  1934         val def_thm = hd thms
  1934         val thm' = def_thm RS meta_eq_to_obj_eq_thm
  1935         val thm' = def_thm RS meta_eq_to_obj_eq_thm
  2015                                val str = Library.foldl (fn (acc,(c,T,csyn)) =>
  2016                                val str = Library.foldl (fn (acc,(c,T,csyn)) =>
  2016                                                    acc ^ "\n  " ^ (quotename c) ^ " :: \"" ^ Display.string_of_ctyp (ctyp_of thy T) ^ "\" " ^ (string_of_mixfix csyn)) ("consts",consts)
  2017                                                    acc ^ "\n  " ^ (quotename c) ^ " :: \"" ^ Display.string_of_ctyp (ctyp_of thy T) ^ "\" " ^ (string_of_mixfix csyn)) ("consts",consts)
  2017                                val thy' = add_dump str thy
  2018                                val thy' = add_dump str thy
  2018                                val _ = ImportRecorder.add_consts consts
  2019                                val _ = ImportRecorder.add_consts consts
  2019                            in
  2020                            in
  2020                                Sign.add_consts_i consts thy'
  2021                                Sign.add_consts_i (map (fn (c, T, mx) => (Binding.name c, T, mx)) consts) thy'
  2021                            end
  2022                            end
  2022 
  2023 
  2023             val thy1 = List.foldr (fn(name,thy)=>
  2024             val thy1 = List.foldr (fn(name,thy)=>
  2024                                 snd (get_defname thyname name thy)) thy1 names
  2025                                 snd (get_defname thyname name thy)) thy1 names
  2025             fun new_name name = fst (get_defname thyname name thy1)
  2026             fun new_name name = fst (get_defname thyname name thy1)
  2091                       | _ => raise ERR "new_type_definition" "Bad type definition theorem"
  2092                       | _ => raise ERR "new_type_definition" "Bad type definition theorem"
  2092             val tfrees = OldTerm.term_tfrees c
  2093             val tfrees = OldTerm.term_tfrees c
  2093             val tnames = map fst tfrees
  2094             val tnames = map fst tfrees
  2094             val tsyn = mk_syn thy tycname
  2095             val tsyn = mk_syn thy tycname
  2095             val typ = (tycname,tnames,tsyn)
  2096             val typ = (tycname,tnames,tsyn)
  2096             val ((_, typedef_info), thy') = TypedefPackage.add_typedef false (SOME thmname) typ c NONE (rtac th2 1) thy
  2097             val ((_, typedef_info), thy') =
       
  2098               TypedefPackage.add_typedef false (SOME (Binding.name thmname))
       
  2099                 (Binding.name tycname, tnames, tsyn) c NONE (rtac th2 1) thy
  2097             val _ = ImportRecorder.add_typedef (SOME thmname) typ c NONE th2
  2100             val _ = ImportRecorder.add_typedef (SOME thmname) typ c NONE th2
  2098 
  2101 
  2099             val th3 = (#type_definition typedef_info) RS typedef_hol2hol4
  2102             val th3 = (#type_definition typedef_info) RS typedef_hol2hol4
  2100 
  2103 
  2101             val fulltyname = Sign.intern_type thy' tycname
  2104             val fulltyname = Sign.intern_type thy' tycname
  2177                       | _ => raise ERR "type_introduction" "Bad type definition theorem"
  2180                       | _ => raise ERR "type_introduction" "Bad type definition theorem"
  2178             val tfrees = OldTerm.term_tfrees c
  2181             val tfrees = OldTerm.term_tfrees c
  2179             val tnames = sort string_ord (map fst tfrees)
  2182             val tnames = sort string_ord (map fst tfrees)
  2180             val tsyn = mk_syn thy tycname
  2183             val tsyn = mk_syn thy tycname
  2181             val typ = (tycname,tnames,tsyn)
  2184             val typ = (tycname,tnames,tsyn)
  2182             val ((_, typedef_info), thy') = TypedefPackage.add_typedef false NONE typ c (SOME(rep_name,abs_name)) (rtac th2 1) thy
  2185             val ((_, typedef_info), thy') =
       
  2186               TypedefPackage.add_typedef false NONE (Binding.name tycname,tnames,tsyn) c
       
  2187                 (SOME(Binding.name rep_name,Binding.name abs_name)) (rtac th2 1) thy
  2183             val _ = ImportRecorder.add_typedef NONE typ c (SOME(rep_name,abs_name)) th2
  2188             val _ = ImportRecorder.add_typedef NONE typ c (SOME(rep_name,abs_name)) th2
  2184             val fulltyname = Sign.intern_type thy' tycname
  2189             val fulltyname = Sign.intern_type thy' tycname
  2185             val aty = Type (fulltyname, map mk_vartype tnames)
  2190             val aty = Type (fulltyname, map mk_vartype tnames)
  2186             val abs_ty = tT --> aty
  2191             val abs_ty = tT --> aty
  2187             val rep_ty = aty --> tT
  2192             val rep_ty = aty --> tT