export_helper.ml revision 617719566ec7a718fc4f601c02ca91f21ca6deb6
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maedersignature ExportHelper =
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder type named_term = (string * term)
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder (* general helper functions *)
2eeec5240b424984e3ee26296da1eeab6c6d739eChristian Maeder val unlines : string list -> string
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val unqualify : string -> string
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (* isabelle specific functions *)
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val theory_of_string : string -> theory list -> theory
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski val theory_by_name : string -> theory
49588f3d624e56594d888bc622bc90618ae3c2c5Till Mossakowski val name_of_theory : theory -> string
57d320fc4d0fe1a1c08cfe6cd9ebec09b86c2cbfTill Mossakowski val axioms_of : theory -> named_term list
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val non_image_theories : theory -> theory list
49588f3d624e56594d888bc622bc90618ae3c2c5Till Mossakowski val thms_of : theory -> named_term list
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val consts_of : theory -> (string * typ) list
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val datatypes_of : theory -> ((string * typ list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (string * typ list) list) list) list
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (* mutually_rec_types@(name * type_params *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder constructors@(constructor_name * type_args))) *)
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val functions_of : theory -> (string * typ *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (term list * term) list) list
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (* name * type *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder def_eqs@(pats * defterm) *)
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val classes_of : theory -> (class * string list *
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich (string * term) list *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder (string * typ) list) list
1842453990fed8a1bd7a5ac792d7982c1d2bfcd5Christian Maeder (* name * parents * assumes * fixes *)
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder val locales_of : theory -> (string *
2272b992302eb61b2a039033cb8cdaf7809fe682Christian Maeder ((string * typ) * mixfix) list *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder named_term list * named_term list *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder string list) list
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder (* name * fixes * in-locale axioms *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder ex-locale axioms * parents *)
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder val pretty_as_str : Pretty.T -> string
2272b992302eb61b2a039033cb8cdaf7809fe682Christian Maeder val repr_term : theory -> term -> Pretty.T
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich val repr_typ : theory -> typ -> Pretty.T
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder val repr_name : string -> Pretty.T
f9e0b18852b238ddb649d341194e05d7200d1bbeChristian Maeder val repr_function : theory -> (string * typ *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder (term list * term) list) -> Pretty.T
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder val repr_class : theory -> (class * string list *
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder (string * term) list *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder (string * typ) list) -> Pretty.T
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder val repr_locale : theory -> (string *
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder ((string * typ) * mixfix) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder named_term list * named_term list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder string list) -> Pretty.T
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val repr_datatype : theory -> (string * typ list * (string *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder typ list) list) list -> Pretty.T
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder val theory_of_exportable_data : theory -> theory
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder val get_basic_theory_data : theory -> (named_term list *
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich named_term list *
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (string * typ) list)
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (* axioms * theorems * consts *)
e5b79e9fe9606fd386dc840ea9f1514e7b9b32b9Christian Maeder type theory_data = (string * named_term list * named_term list *
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (string * typ) list * ((string * typ list *
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (string * typ list) list) list) list *
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe (string * typ * (term list * term) list) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (class * string list * (string * term) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (string * typ) list) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (string * ((string * typ) * mixfix) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder named_term list * named_term list *
ef7d1a1d5454458d46b9acefeda94b12bdc695b2Christian Maeder string list) list)
2de8dfc30c926ee27254bfa32230a01435530efeKlaus Luettich (* name * axioms * theorems * consts * datatypes *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder functions * classes * locales *)
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder val get_theories : theory -> theory_data list
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maeder val xml_of_theories : theory_data list -> XML.tree
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder exception ExportError of string
4e2331b387b90a234dc36b12c778914d3e202718Christian Maederstructure ExportHelper : ExportHelper =
54a0a1e10bd93721cf52dbd9b816c8f108997ec0Christian Maederexception ExportError of string
4e2331b387b90a234dc36b12c778914d3e202718Christian Maedertype named_term = string * term
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maedertype theory_data = (string * named_term list * named_term list *
cd6e5706893519bfcf24539afa252fcbed5097ddKlaus Luettich (string * typ) list * ((string * typ list *
9603ad7198b72e812688ad7970e4eac4b553837aKlaus Luettich (string * typ list) list) list) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (string * typ * (term list * term) list) list *
da955132262baab309a50fdffe228c9efe68251dCui Jian (class * string list * (string * term) list *
f64f3dc78de82101483fe97bf109a42ca4d59d77Klaus Luettich (string * typ) list) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder (string * ((string * typ) * mixfix) list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder named_term list * named_term list *
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder string list) list)
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maeder (* name * axioms * theorems * consts * datatypes *
cd6e5706893519bfcf24539afa252fcbed5097ddKlaus Luettich functions * classes * locales *)
9603ad7198b72e812688ad7970e4eac4b553837aKlaus Luettich(* ------------------------------ General helper functions *)
f64f3dc78de82101483fe97bf109a42ca4d59d77Klaus Luettichval unlines = String.concatWith (String.str (Char.chr 10))
4e2331b387b90a234dc36b12c778914d3e202718Christian Maederfun lift f sel = fn (t1,t2) => f (sel t1,sel t2)
da955132262baab309a50fdffe228c9efe68251dCui Jianfun unqualify n = if Long_Name.is_qualified n
99634745e86bb1c79da4e2b376e580f65ee67082Klaus Luettich then (Long_Name.implode (List.tl (Long_Name.explode n)))
0ee3933098d65199ae39ea41cfc62634226dad15Klaus Luettich(* ------------------------------ Isabelle specific functions *)
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder(* Keep track of the number of theories created from a string *)
63324a97283728a30932828a612c7b0b0f687624Christian Maeder(* create a theory from a string of its body *)
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maederfun theory_of_string body parents =
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder let val name = "TempTheory"^Int.toString (Unsynchronized.inc thmNum)
9603ad7198b72e812688ad7970e4eac4b553837aKlaus Luettich val header = Thy_Header.make ("TempTheory",Position.none) [] [] []
edd35c6c970fa1707dc6ad7a3ba26119e0046223Cui Jian val text = unlines ["theory "^name,"begin",body,"end"]
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maeder in #1 (Thy_Load.load_thy 0 (Thy_Load.get_master_path ()) header
ef7d1a1d5454458d46b9acefeda94b12bdc695b2Christian Maeder Position.start text parents) end
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettichfun remove_hol_true_prop t = case t of
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder op$ (Const ("HOL.Trueprop",_), tm) => tm
f2c050360525df494e6115073b0edc4c443a847cMihai Codescu | (t $ u) => (remove_hol_true_prop t) $ (remove_hol_true_prop u)
f2c050360525df494e6115073b0edc4c443a847cMihai Codescu | Abs (s,T,t) => Abs (s,T,remove_hol_true_prop t)
7bf4436b6f9987b070033a323757b206c898c1beChristian Maederval prettify_term = Logic.strip_imp_concl o remove_hol_true_prop
63324a97283728a30932828a612c7b0b0f687624Christian Maeder(* remove data that is already present in a parent theory *)
63324a97283728a30932828a612c7b0b0f687624Christian Maederfun remove_parent_data df cmp T =
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder let val d = df T
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder val pd = (List.foldl op@ [] (List.map df (Context.parents_of T)))
33c33fde308de14d34177617a28524312f5f0ad8Christian Maeder in Ord_List.subtract cmp (Ord_List.make cmp pd) (Ord_List.make cmp d) end
04d04d19fdd5320953c78ad5b6d2d11f85bc4bcfChristian Maeder(* a couple of aliases *)
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maederval theory_by_name = Thy_Info.get_theory
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maederval name_of_theory = Context.theory_name
63324a97283728a30932828a612c7b0b0f687624Christian Maeder(* check if the theory is not part of the logic image *)
63324a97283728a30932828a612c7b0b0f687624Christian Maederfun is_non_image_theory T = length (Thy_Info.loaded_files (name_of_theory T)) > 0
209f37a7f7b3c61e5dc1a90bd83b65a24c8be3faChristian Maederfun non_image_theories T = List.concat (List.map
209f37a7f7b3c61e5dc1a90bd83b65a24c8be3faChristian Maeder (fn T' => if is_non_image_theory T'
209f37a7f7b3c61e5dc1a90bd83b65a24c8be3faChristian Maeder then T'::(non_image_theories T') else [])
63324a97283728a30932828a612c7b0b0f687624Christian Maederfun hol_forall_elim tm =
63324a97283728a30932828a612c7b0b0f687624Christian Maeder let val qnt = #1 (Term.dest_Const (HOLogic.all_const HOLogic.boolT))
209f37a7f7b3c61e5dc1a90bd83b65a24c8be3faChristian Maeder val body = Term.strip_qnt_body qnt tm
63324a97283728a30932828a612c7b0b0f687624Christian Maeder val vars = List.map (fn (s,tp) => Var ((s,0),tp))
4e2331b387b90a234dc36b12c778914d3e202718Christian Maeder in Term.subst_bounds (List.rev vars, body) end
04d04d19fdd5320953c78ad5b6d2d11f85bc4bcfChristian Maederfun hol_conjunctions tm = case HOLogic.dest_conj tm of
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder | tms => List.concat (List.map hol_conjunctions tms)
f64f3dc78de82101483fe97bf109a42ca4d59d77Klaus Luettichfun thms_of T = List.map (fn (s,d) => (s,prop_of d))
64325303fc09fc4d88ced49be11ff2d29966422aCui Jian (remove_parent_data Global_Theory.all_thms_of
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich (lift fast_string_ord #1) T)
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe(* currently there seems to be no way (anymore) to
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe attach any terms to a const directly. Thus the discarded
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe part is (hopefully) always NONE
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich todo: maybe throw an exception if this is not the case? *)
64325303fc09fc4d88ced49be11ff2d29966422aCui Jianfun consts_of T =
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich let val get_consts = fn T => List.map (fn (n,(t,_)) => (n,t))
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe (((Name_Space.dest_table (Syntax.init_pretty_global T)) o
fdf94376fa12e6f685f87741be2f3d02e03c429eChristian Maeder #constants o Consts.dest o Sign.consts_of) T)
0ee3933098d65199ae39ea41cfc62634226dad15Klaus Luettich in remove_parent_data get_consts (lift fast_string_ord #1) T end
709653bffee501341e2fdc55b9223e4921047c65Till Mossakowskifun datatypes_of T =
709653bffee501341e2fdc55b9223e4921047c65Till Mossakowski let val get_datatypes = (#log_types o Type.rep_tsig o Sign.tsig_of)
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich val ts = remove_parent_data get_datatypes fast_string_ord T
5efed683fd173e9d53bd5f1929ba5b0c8a228710Christian Maeder val is_mutually_rec_type = fn (_,i) => length (#descr i) >1
17d4f8c5576d93f36cafe68161cdb960ec49ce7cChristian Maeder val check_rec = fn (n,v) => if is_mutually_rec_type (n,v)
64325303fc09fc4d88ced49be11ff2d29966422aCui Jian then (#index v) < 1 else true
57d320fc4d0fe1a1c08cfe6cd9ebec09b86c2cbfTill Mossakowski val rec dtyp2typ = fn (descs,t) => case t of
64325303fc09fc4d88ced49be11ff2d29966422aCui Jian Datatype.DtTFree (s,srt) => TFree (s,srt)
afe76697dd6888856a066934a1112a38809b27faChristian Maeder Type (s,List.map (curry dtyp2typ descs) ts)
57d320fc4d0fe1a1c08cfe6cd9ebec09b86c2cbfTill Mossakowski case List.find (curry op= i o #1) descs of
d19b839f3726cc508e3c52a7af227167a9e38f45Klaus Luettich SOME (_,(s,ts,_)) => Type (s, List.map
da955132262baab309a50fdffe228c9efe68251dCui Jian (curry dtyp2typ descs) ts)
63324a97283728a30932828a612c7b0b0f687624Christian Maeder | NONE => raise ExportError("Internal Error!")
63324a97283728a30932828a612c7b0b0f687624Christian Maeder val dt_desc = fn info => List.map (fn (i,(s,vs,eqs)) =>
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich let val vs' = List.map (curry dtyp2typ info) vs
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich val eqs' = List.map (fn (s,ts) =>
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (s,List.map (curry dtyp2typ info) ts)) eqs
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich in (s,vs',eqs') end) info
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich in List.foldl (fn (n,l) => case Datatype.get_info T n of
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich SOME(v) => if check_rec (n,v)
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich then (dt_desc (#descr v))::l
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich | NONE => l) [] ts end
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich dest_Const is in Pure/term.ML
da955132262baab309a50fdffe228c9efe68251dCui Jianval functions_of =
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich let val get_funs = fn T =>
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich let val d = Item_Net.content (Function_Common.get_function
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich val fun_def = (fn (pats,def) => (#2 (strip_comb pats),def))
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich o HOLogic.dest_eq o HOLogic.dest_Trueprop o #2
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich in List.map (fn (c,i) => case dest_Const c of
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (n,t) => (n,t,List.map fun_def (#psimps i))) d end
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich in remove_parent_data get_funs (lift fast_string_ord #1) end
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maederfun classes_of T =
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich let val cls_suffix = "_class_def"
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich val thms = thms_of T
da955132262baab309a50fdffe228c9efe68251dCui Jian val cls_names = List.map (fn n => String.substring (n,0,String.size n-
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich String.size cls_suffix)) (List.filter (String.isSuffix cls_suffix)
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich in List.map (fn name =>
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder let val i = AxClass.get_info T name
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich o Logic.dest_equals o Thm.prop_of o #def) i))
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich val parents = List.map (fn n => String.substring
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (List.filter (fn n => (String.isSuffix "_class" n) andalso
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (not (String.isPrefix "HOL" n))) parents')
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich val axioms' = List.map (fn (n,t) => (n,(HOLogic.dest_Trueprop o #2
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (List.filter ((String.isPrefix (name^".")) o #1) thms)
5fcb1cb8c190e9bfb8d5c06c2e7d7a4b65f361acKlaus Luettich (* note: instead of cls_names we should only use
eac3174ea16c143bfaeb3f2e2103a11a2f162c6cChristian Maeder ancestors of the class *)
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe val all_params = List.map (fn (s,t) => (Long_Name.base_name s,t))
7c8051ef91610c696bc9fa2e61ad1b153fbe7ce0Klaus Luettich (List.concat (List.map (#params o AxClass.get_info T) cls_names))
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe val sub_vars = List.map (fn (s,t) => ((s,0),Free (s,t))) all_params
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder val axioms = List.map (fn (s,t) => (s,Term.subst_Vars sub_vars t))
fdf94376fa12e6f685f87741be2f3d02e03c429eChristian Maeder in (name,parents,axioms,#params i) end) cls_names end
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbefun locales_of T =
fdf94376fa12e6f685f87741be2f3d02e03c429eChristian Maeder let val all_locales = fn T => List.map (fn l => (#name l, #parents l))
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe (fn (c,l) => fast_string_ord (#1 c,#1 l))
d4cb5f03c55f0aeff72f06dac61e1af24479ddd9Rainer Grabbe (Ord_List.make (lift fast_string_ord #1)
33fc94b09b906329ca7505caa1ddcddf67e3f8daTill Mossakowski (classes_of T))
0206ab93ef846e4e0885996d052b9b73b9dc66b0Christian Maeder (Ord_List.make (lift fast_string_ord #1)
in List.map (fn (name,ps) =>
val params = Ord_List.subtract (fn (s,((s1,_),_)) =>
(Ord_List.make fast_string_ord parent_params)
(Ord_List.make (lift fast_string_ord (#1 o #1))
(Locale.params_of T name))
val filter = ["_axioms.intro","_axioms_def","_def",".intro",".axioms_"]
val axioms' = List.filter
(fn t => (not (List.exists
(fn s => String.isPrefix (name ^ s) (#1 t))
o Thm.prop_of) t)) axioms'
(List.map (fn ((s,tp),_) =>
val parse_axioms = fn v => List.map hol_forall_elim
case List.find ((curry op= (name^"_axioms_def")) o #1) axs of
case List.find ((curry op= (name^"_def")) o #1) axs of
val in_loc = List.filter (fn (_,t) =>
List.exists (fn t' => t = t') in_locale_axioms) axioms
val ex_loc = List.filter (fn (_,t) =>
not (List.exists (fn t' => t = t') in_locale_axioms)) axioms
fun pretty_as_str p = Pretty.str_of p
in Syntax.pretty_term ctxt end
let val n = Long_Name.base_name n'
else Pretty.str n end
((Pretty.breaks ([repr_name s]
[Pretty.str " = ",repr_term T tm]))) def_eqs
in Pretty.block (head@Pretty.separate " | " body) end
let val head = [Pretty.str "class", repr_name s]
then [Pretty.str "="] else [])
val parents = List.map repr_name ps
[repr_name s,Pretty.str "::",
Pretty.quote (repr_typ T tp)])) fixes
[repr_name s, Pretty.str ":",
Pretty.quote (repr_term T tm)])) assumes
then [Pretty.str "+"] else [])@
let val head = [Pretty.str "locale", repr_name s]
then [Pretty.str "="] else [])
val parents = List.map repr_name ps
Pretty.quote (repr_typ T tp)])) fixes
[repr_name s, Pretty.str ":",
Pretty.quote (repr_term T tm)])) in_loc
then [Pretty.str "+"] else [])@
let val dts = List.map (fn (s,vs,eqs) =>
let val vs' = Pretty.enclose "(" ")"
([vs']@[repr_name s,Pretty.str "="]@eqs')) end) d
Pretty.separate "and" dts) end
val classes_Graph = String_Graph.make
(List.map (fn l => ((#1 l,l),#2 l)) (classes_of T))
val classes = List.map
(#1 o #2 o (String_Graph.get_entry classes_Graph))
val locales_Graph = String_Graph.make
(List.map (fn l => ((#1 l,l),#5 l)) (locales_of T))
val locales = List.map
(#1 o #2 o (String_Graph.get_entry locales_Graph))
in theory_of_string (unlines (List.map pretty_as_str
((List.map (repr_datatype T) datatypes)
@(List.map (repr_function T) functions)
@(List.map (repr_class T) classes)
val axs = Ord_List.subtract cmp
(Ord_List.make (lift fast_string_ord #1) (axioms_of T))
val thms = Ord_List.subtract cmp
(Ord_List.make (lift fast_string_ord #1) (thms_of T))
val consts = Ord_List.subtract cmp
(Ord_List.make (lift fast_string_ord #1) (consts_of T))
in List.map (fn T =>
List.map (fn (n,s) =>
if n = "name" andalso String.isPrefix (moduleName^".") s
List.map (fixTypeNames moduleName) c)
| XML.Elem (d,c) =>
SOME(Mixfix.Infixl (s,j)) => [("infixl",s), ("mixfix_i",string_of_int j)]
| SOME(Mixfix.Infixr (s,j)) => [("infixr",s), ("mixfix_i",string_of_int j)]
| SOME(Mixfix.Infix (s,j)) => [("infix",s), ("mixifix_i",string_of_int j)]
XML.Elem (("Const",a),t) =>
in XML.Elem (("Const",a@b),map (xml_of_term' T tbl) t) end
fun xml_of_term T t = xml_of_term' T Symtab.empty
(("Constructor",[("name",Long_Name.base_name s)]),
::(List.map(fn (pats,tm) =>
(List.map (fn p =>
@(List.map (fn (s,t) =>
@(List.map (fn (s,t) =>
[XML_Syntax.xml_of_type t])) fixes))
(List.map (fn ((s,t),m) =>
[XML_Syntax.xml_of_type t])) fixes)
@(List.map (fn (s,t) =>
@(List.map (fn (s,t) =>
@(List.map (fn p =>
val imports = List.map
(fn T => XML.Elem (("Import",[("name",name_of_theory T)]),[]))
(("Axiom",[("name",Long_Name.base_name n)]),
(("Theorem",[("name",Long_Name.base_name n)]),
(("Const",[("name",Long_Name.base_name n)]),
[XML_Syntax.xml_of_type tp])) cs
val datatypes = List.map (xml_of_datatype T) dts
val functions = List.map (xml_of_function T) fns
val classes = List.map (xml_of_class T) cls
val locales' = List.map (xml_of_locale T) locales
in fixTypeNames name (XML.Elem (("IsaTheory",[("name",name)]),