conv-theory-files.pl
author lcp
Thu, 12 Jan 1995 03:00:38 +0100
changeset 849 013a16d3addb
parent 436 0cdc840297bb
permissions -rwxr-xr-x
Proved equivalence of Ord and Ord_alt. Proved ordertype_eq_imp_ord_iso, le_well_ord_Memrel, le_ordertype_Memrel, lt_oadd1, oadd_le_self, bij_0_sum, oadd_0, oadd_assoc, id_ord_iso_Memrel, ordertype_0. Now well_ord_Memrel follows from le_well_ord_Memrel and ordertype_Memrel follows from le_ordertype_Memrel. Proved simpler versions of Krzysztof's theorems Ord_oadd, ordertype_pred_subset, ordertype_pred_lt, ordertype_pred_unfold, bij_sum_0, bij_sum_succ, ordertype_sum_Memrel, lt_oadd_disj, oadd_inject. Deleted ordertype_subset: subsumed by ordertype_pred_unfold. Proved ordinal multiplication theorems Ord_omult, lt_omult, omult_oadd_lt, omult_unfold, omult_0, omult_0_left, omult_1, omult_1_left, oadd_omult_distrib, omult_succ, omult_assoc, omult_UN, omult_Limit, lt_omult1, omult_le_self, omult_le_mono1, omult_lt_mono2, omult_le_mono2, omult_le_mono, omult_lt_mono, omult_le_self2, omult_inject.

#!/usr/bin/perl -s-	 # -*-Perl-*-

#---------------------------------------------------------------------
#The following script file is useful to convert old theory files into a
#style consistent with new naming conventions. Now, the names of the
#files must be the same as the names of the theories they define (with
#a ".thy" suffix) and corresponding ML files must also be renamed.
#
#To make this renaming easier, the following perl script can be used.
#It traverses the given directory recursively.  For each file of the
#form abc.thy, this script does the following steps:
#
#1. Reads the file and grabs the first identifier, say Abc (skipping comments
#   (*...*) and white space).
#2. Outputs the commands needed to rename the file abc.thy to Abc.thy,
#   including the appropriate CVS commands.
#3. If abc.ML also exists, it outputs appropriate commands to rename it
#   to Abc.ML.
#
#These commands can be put into a file, which can then be executed.
#If you are not using cvs, use "grep" to extract just the "mv" commands.
#
#						- Sara Kalvala
#						  (sk@cl.cam.ac.uk)
#---------------------------------------------------------------------

open(MATCH_FILES, "find . -name \"*thy\" -print |");

foreach $each_match (<MATCH_FILES>) {
 chop($each_match);
 if($each_match =~ /(.*\/)(\w*)\.thy/) {$dirpart = $1;}
 else {print "something wrong with finding path!\n";
       $dirpart = "";}
 open (CONTENTS, $each_match);
 @readit = <CONTENTS>;
 chop(@readit); $oneline = join(" ",@readit);
 $oneline =~ s/\(\*([^\*]|(\*[^\)]))*\*\)//g ;
# comments: have to remove strings of anything but stars or stars
# followed by anything but right parenthesis 
 if($oneline =~ /\s*([^ ]*)\s*=.*/)
 {$th_name = $1;
  $new_name = $dirpart . $th_name . ".thy";
  print "mv -i $each_match $new_name \n";
  print "cvs rm $each_match ; cvs add $new_name \n";
# for ML files
  $each_ML = $each_match;
  $each_ML =~ s/.thy/.ML/;
  if (-e $each_ML) { $new_ML = $dirpart . $th_name . ".ML";
		     print "mv -i $each_ML $new_ML \n";
		     print "cvs rm $each_ML ; cvs add $new_ML \n";}}
 else {print "something wrong with format of theory file!\n";}
}