src/HOL/Tools/ATP/res_clasimpset.ML
changeset 16156 2f6fc19aba1e
parent 16061 8a139c1557bf
child 16172 629ba53a072f
     1.1 --- a/src/HOL/Tools/ATP/res_clasimpset.ML	Tue May 31 12:36:01 2005 +0200
     1.2 +++ b/src/HOL/Tools/ATP/res_clasimpset.ML	Tue May 31 12:42:36 2005 +0200
     1.3 @@ -5,7 +5,7 @@
     1.4      Copyright   2004  University of Cambridge
     1.5  *)
     1.6  
     1.7 -signature RES_CLASIMP =
     1.8 +signature RES_CLASIMP = 
     1.9    sig
    1.10       val write_out_clasimp :string -> (ResClause.clause * Thm.thm) Array.array * int
    1.11    end;
    1.12 @@ -50,6 +50,30 @@
    1.13  (*Insert th into the result provided the name is not "".*)
    1.14  fun add_nonempty ((name,th), ths) = if name="" then ths else th::ths;
    1.15  
    1.16 +fun posinlist x [] n = "not in list"
    1.17 +|   posinlist x (y::ys) n = if (x=y) 
    1.18 +			    then
    1.19 + 				string_of_int n
    1.20 +			    else posinlist x (ys) (n+1)
    1.21 +
    1.22 +
    1.23 +fun pairup [] [] = []
    1.24 +|   pairup (x::xs) (y::ys) = (x,y)::(pairup xs ys)
    1.25 +
    1.26 +fun multi x 0 xlist = xlist
    1.27 +   |multi x n xlist = multi x (n -1 ) (x::xlist);
    1.28 +
    1.29 +
    1.30 +fun clause_numbering ((clause, theorem), cls) = let val num_of_cls = length cls
    1.31 +                                              val numbers = 0 upto (num_of_cls -1)
    1.32 +                                              val multi_name = multi (clause, theorem)  num_of_cls []
    1.33 +                                          in 
    1.34 +                                              (multi_name)
    1.35 +                                          end;
    1.36 +
    1.37 +
    1.38 +
    1.39 + 
    1.40  
    1.41  fun write_out_clasimp filename = 
    1.42      let val claset_rules = ResAxioms.claset_rules_of_thy (the_context());
    1.43 @@ -64,22 +88,25 @@
    1.44  
    1.45  	val cls_thms = (claset_cls_thms@simpset_cls_thms);
    1.46  	val cls_thms_list = List.concat cls_thms;
    1.47 -
    1.48 -	(*********************************************************)
    1.49 -	(* create array and put clausename, number pairs into it *)
    1.50 -	(*********************************************************)
    1.51 -	val num_of_clauses =  0;
    1.52 -	val clause_arr = Array.fromList cls_thms_list;
    1.53 -
    1.54 -	val num_of_clauses = List.length cls_thms_list;
    1.55 -
    1.56 +        (* length 1429 *)
    1.57  	(*************************************************)
    1.58  	(* Write out clauses as tptp strings to filename *)
    1.59  	(*************************************************)
    1.60  	val clauses = map #1(cls_thms_list);
    1.61  	val cls_tptp_strs = map ResClause.tptp_clause clauses;
    1.62 +        val alllist = pairup cls_thms_list cls_tptp_strs
    1.63 +        val whole_list = List.concat (map clause_numbering alllist);
    1.64 + 
    1.65 +        (*********************************************************)
    1.66 +	(* create array and put clausename, number pairs into it *)
    1.67 +	(*********************************************************)
    1.68 +	val num_of_clauses =  0;
    1.69 +	val clause_arr = Array.fromList whole_list;
    1.70 +	val num_of_clauses = List.length whole_list;
    1.71 +
    1.72  	(* list of lists of tptp string clauses *)
    1.73  	val stick_clasrls =   List.concat cls_tptp_strs;
    1.74 +        (* length 1581*)
    1.75  	val out = TextIO.openOut filename;
    1.76  	val _=   ResLib.writeln_strs out stick_clasrls;
    1.77  	val _= TextIO.flushOut out;
    1.78 @@ -88,6 +115,7 @@
    1.79  	(clause_arr, num_of_clauses)
    1.80    end;
    1.81  
    1.82 -
    1.83  end;
    1.84  
    1.85 +
    1.86 +