lib/scripts/convert.pl
changeset 11009 9e0ad9a5f9bb
parent 11001 6754fa0f2af7
child 11013 b2af88422983
equal deleted inserted replaced
11008:f7333f055ef6 11009:9e0ad9a5f9bb
    74   s/hypsubst_tac 1/hypsubst/g;
    74   s/hypsubst_tac 1/hypsubst/g;
    75   s/arith_tac 1/arith/g;
    75   s/arith_tac 1/arith/g;
    76   s/strip_tac 1/intro strip/g;
    76   s/strip_tac 1/intro strip/g;
    77   s/split_all_tac 1/simp (no_asm_simp) only: split_tupled_all/g;
    77   s/split_all_tac 1/simp (no_asm_simp) only: split_tupled_all/g;
    78 
    78 
    79   s/rotate_tac ([~\d]+) 1/rotate_tac $1/g;
    79   s/rotate_tac (\d+) 1/rotate_tac $1/g;
    80   s/rotate_tac ([~\d]+) (\d+)/rotate_tac [$2] $1/g;
    80   s/rotate_tac (\d+) (\d+)/rotate_tac [$2] $1/g;
       
    81   s/rotate_tac (~\d+) 1/rotate_tac -$1/g;
       
    82   s/rotate_tac (~\d+) (\d+)/rotate_tac [$2] -$1/g;
    81   s/rename_tac *(\".*?\") *1/rename_tac $1/g;
    83   s/rename_tac *(\".*?\") *1/rename_tac $1/g;
    82   s/rename_tac *(\".*?\") *(\d+)/rename_tac [$2] $1/g;
    84   s/rename_tac *(\".*?\") *(\d+)/rename_tac [$2] $1/g;
    83   s/case_tac *(\".*?\") *1/case_tac $1/g;
    85   s/case_tac *(\".*?\") *1/case_tac $1/g;
    84   s/case_tac *(\".*?\") *(\d+)/case_tac [$2] $1/g;
    86   s/case_tac *(\".*?\") *(\d+)/case_tac [$2] $1/g;
    85   s/induct_tac *(\".*?\") *1/induct_tac $1/g;
    87   s/induct_tac *(\".*?\") *1/induct_tac $1/g;
    86   s/induct_tac *(\".*?\") *(\d+)/induct_tac [$2] $1/g;
    88   s/induct_tac *(\".*?\") *(\d+)/induct_tac [$2] $1/g;
    87   s/subgoal_tac *(\".*?\") *1/subgoal_tac $1/g;
    89   s/subgoal_tac *(\".*?\") *1/subgoal_tac $1/g;
    88   s/subgoal_tac *(\".*?\") *(\d+)/subgoal_tac [$2] $1/g;
    90   s/subgoal_tac *(\".*?\") *(\d+)/subgoal_tac [$2] $1/g;
    89   s/thin_tac *(\".*?\") *1/erule_tac P = $1 thin_rl/g;
    91   s/thin_tac *(\".*?\") *1/erule_tac V = $1 in thin_rl/g;
    90   s/thin_tac *(\".*?\") *(\d+)/erule_tac [$2] P = $1/g;
    92   s/thin_tac *(\".*?\") *(\d+)/erule_tac [$2] V = $1 in thin_rl/g;
    91 
    93 
    92   s/stac ([\w\.]+) 1/subst $1/g;
    94   s/rewtac ([\w\'\.]+) 1/unfold $1/g;
    93   s/rtac ([\w\.]+) 1/rule $1/g;
    95   s/stac ([\w\'\.]+) 1/subst $1/g;
    94   s/rtac ([\w\.]+) (\d+)/rule_tac [$2] $1/g;
    96   s/rtac ([\w\'\.]+) 1/rule $1/g;
    95   s/res_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\.]+) 1/rule_tac $1 = $2 $3/g;
    97   s/rtac ([\w\'\.]+) (\d+)/rule_tac [$2] $1/g;
    96   s/dtac ([\w\.]+) 1/drule $1/g;
    98   s/res_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\'\.]+) 1/rule_tac $1 = $2 in $3/g;
    97   s/dtac ([\w\.]+) (\d+)/drule_tac [$2] $1/g;
    99   s/dtac ([\w\'\.]+) 1/drule $1/g;
    98   s/dres_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\.]+) 1/drule_tac $1 = $2 $3/g;
   100   s/dtac ([\w\'\.]+) (\d+)/drule_tac [$2] $1/g;
    99   s/datac ([\w\.]+) (\d+) 1/"drule ($2) $1"/g;
   101   s/dres_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\'\.]+) 1/drule_tac $1 = $2 in $3/g;
   100   s/etac ([\w\.]+) 1/erule $1/g;
   102   s/datac ([\w\'\.]+) (\d+) 1/drule ($2) $1/g;
   101   s/etac ([\w\.]+) (\d+)/erule_tac [$2] $1/g;
   103   s/etac ([\w\'\.]+) 1/erule $1/g;
   102   s/eres_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\.]+) 1/erule_tac $1 = $2 $3/g;
   104   s/etac ([\w\'\.]+) (\d+)/erule_tac [$2] $1/g;
   103   s/eatac ([\w\.]+) (\d+) 1/"erule ($2) $1"/g;
   105   s/eres_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\'\.]+) 1/erule_tac $1 = $2 in $3/g;
   104   s/forward_tac \[([\w\.]+)\] 1/frule $1/g;
   106   s/eatac ([\w\'\.]+) (\d+) 1/erule ($2) $1/g;
   105   s/ftac ([\w\.]+) 1/frule $1/g;
   107   s/forward_tac \[([\w\'\.]+)\] 1/frule $1/g;
   106   s/ftac ([\w\.]+) (\d+)/frule_tac [$2] $1/g;
   108   s/ftac ([\w\'\.]+) 1/frule $1/g;
   107   s/forw_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\.]+) 1/frule_tac $1 = $2 $3/g;
   109   s/ftac ([\w\'\.]+) (\d+)/frule_tac [$2] $1/g;
   108   s/fatac ([\w\.]+) (\d+) 1/"frule ($2) $1"/g;
   110   s/forw_inst_tac \[\((\".*?\"),(\".*?\")\)\] ([\w\'\.]+) 1/frule_tac $1 = $2 in $3/g;
       
   111   s/fatac ([\w\'\.]+) (\d+) 1/frule ($2) $1/g;
   109 
   112 
   110 
   113 
   111   s/THEN /, /g;
   114   s/THEN /, /g;
   112   s/ORELSE/|/g;
   115   s/ORELSE/|/g;
   113   s/fold_goals_tac *(\[[\w\. ,]*\]|[\w\.]+)/"fold ".thmlist($1)/eg;
   116   s/fold_goals_tac *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"fold ".thmlist($1)/eg;
   114   s/rewrite_goals_tac *(\[[\w\. ,]*\]|[\w\.]+)/"unfold ".thmlist($1)/eg;
   117   s/rewrite_goals_tac *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"unfold ".thmlist($1)/eg;
   115   s/cut_facts_tac *(\[[\w\. ,]*\]|[\w\.]+) 1/"cut_tac ".thmlist($1)/eg;
   118   s/cut_facts_tac *(\[[\w\'\. ,]*\]|[\w\'\.]+) 1/"cut_tac ".thmlist($1)/eg;
   116   s/resolve_tac *(\[[\w\. ,]*\]|[\w\.]+) 1/"rule ".thmlist($1)/eg;
   119   s/resolve_tac *(\[[\w\'\. ,]*\]|[\w\'\.]+) 1/"rule ".thmlist($1)/eg;
   117   s/EVERY *(\[[\w\. ,]*\]|[\w\.]+)/thmlist($1)/eg;
   120   s/EVERY *(\[[\w\'\. ,]*\]|[\w\'\.]+)/thmlist($1)/eg;
   118 
   121 
   119   s/addIs *(\[[\w\. ,]*\]|[\w\.]+)/"intro: ".thmlist($1)/eg;
   122   s/addIs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"intro: ".thmlist($1)/eg;
   120   s/addSIs *(\[[\w\. ,]*\]|[\w\.]+)/"intro!: ".thmlist($1)/eg;
   123   s/addSIs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"intro!: ".thmlist($1)/eg;
   121   s/addEs *(\[[\w\. ,]*\]|[\w\.]+)/"elim: ".thmlist($1)/eg;
   124   s/addEs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"elim: ".thmlist($1)/eg;
   122   s/addSEs *(\[[\w\. ,]*\]|[\w\.]+)/"elim!: ".thmlist($1)/eg;
   125   s/addSEs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"elim!: ".thmlist($1)/eg;
   123   s/addDs *(\[[\w\. ,]*\]|[\w\.]+)/"dest: ".thmlist($1)/eg;
   126   s/addDs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"dest: ".thmlist($1)/eg;
   124   s/addSDs *(\[[\w\. ,]*\]|[\w\.]+)/"dest!: ".thmlist($1)/eg;
   127   s/addSDs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"dest!: ".thmlist($1)/eg;
   125   s/delrules *(\[[\w\. ,]*\]|[\w\.]+)/"del: ".thmlist($1)/eg;
   128   s/delrules *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"del: ".thmlist($1)/eg;
   126   s/addsimps *(\[[\w\. ,]*\]|[\w\.]+)/"$simpmodmod"."add: ".thmlist($1)/eg;
   129   s/addsimps *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"$simpmodmod"."add: ".thmlist($1)/eg;
   127   s/delsimps *(\[[\w\. ,]*\]|[\w\.]+)/"$simpmodmod"."del: ".thmlist($1)/eg;
   130   s/delsimps *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"$simpmodmod"."del: ".thmlist($1)/eg;
   128   s/addcongs *(\[[\w\. ,]*\]|[\w\.]+)/"cong add: ".thmlist($1)/eg;
   131   s/addcongs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"cong add: ".thmlist($1)/eg;
   129   s/delcongs *(\[[\w\. ,]*\]|[\w\.]+)/"cong del: ".thmlist($1)/eg;
   132   s/delcongs *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"cong del: ".thmlist($1)/eg;
   130   s/addsplits *(\[[\w\. ,]*\]|[\w\.]+)/"split add: ".thmlist($1)/eg;
   133   s/addsplits *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"split add: ".thmlist($1)/eg;
   131   s/delsplits *(\[[\w\. ,]*\]|[\w\.]+)/"split del: ".thmlist($1)/eg;
   134   s/delsplits *(\[[\w\'\. ,]*\]|[\w\'\.]+)/"split del: ".thmlist($1)/eg;
   132 
   135 
   133   s/([\w\.]+) RS ([\w\.]+)/$1 \[THEN $2\]/g;
   136   s/([\w\'\.]+) RS ([\w\'\.]+)/$1 \[THEN $2\]/g;
   134 
   137 
   135   s/ +/ /g;                  # remove multiple whitespace
   138   s/ +/ /g;                  # remove multiple whitespace
   136   s/\( /\(/; s/ \)/\)/g;  # remove leading and trailing space inside parentheses
   139   s/\( /\(/; s/ \)/\)/g;  # remove leading and trailing space inside parentheses
   137   s/^ *(.*?) *$/$1/s;        # remove enclosing whitespace
   140   s/^ *(.*?) *$/$1/s;        # remove enclosing whitespace
   138   s/^\( *([\w\.]+) *\)$/$1/; # remove outermost parentheses if around atoms
   141   s/^\( *([\w\'\.]+) *\)$/$1/; # remove outermost parentheses if around atoms
   139   s/^([a-zA-Z])/ $1/ if (!($lead =~ m/[\s\(]$/)); # add space if required
   142   s/^([a-zA-Z])/ $1/ if (!($lead =~ m/[\s\(]$/)); # add space if required
   140   $_;
   143   $_;
   141 }
   144 }
   142 
   145 
   143 sub thmname { "@@" . ++$thmcount . "@@"; }
   146 sub thmname { "@@" . ++$thmcount . "@@"; }
   195     print substr $_,0,$i+2;
   198     print substr $_,0,$i+2;
   196     $_ = substr $_,$i+2;
   199     $_ = substr $_,$i+2;
   197     goto nlc;
   200     goto nlc;
   198   }
   201   }
   199   $_=$line;
   202   $_=$line;
   200   s/^Goalw *(\[[\w\.\s,]*\]|[\w\.]+) *(.+)/
   203   s/^Goalw *(\[[\w\'\.\s,]*\]|[\w\'\.]+) *(.+)/
   201     "lemma ".thmname().": $2$head"."apply (unfold ".thmlist($1).")"/se;
   204     "lemma ".thmname().": $2$head"."apply (unfold ".thmlist($1).")"/se;
   202   s/^Goal *(.+)/"lemma ".thmname().": $1"/se;
   205   s/^Goal *(.+)/"lemma ".thmname().": $1"/se;
   203   s/ goal/"(*".thmname()."*) goal"/se; # ugly old-style goals
   206   s/ goal/"(*".thmname()."*) goal"/se; # ugly old-style goals
   204   s/^qed_spec_mp *\"(.*?)\"/done($1," [rule_format (no_asm)]")/se;
   207   s/^qed_spec_mp *\"(.*?)\"/done($1," [rule_format (no_asm)]")/se;
   205   s/^qed *\"(.*?)\"/done($1,"")/se;
   208   s/^qed *\"(.*?)\"/done($1,"")/se;
   206   s/^bind_thm *\( *\"(.*?)\" *, *(.*?result *\( *\).*?) *\) *$/done($1,"[?? $2 ??] ")/se;
   209   s/^bind_thm *\( *\"(.*?)\" *, *(.*?result *\( *\).*?) *\) *$/done($1,"[?? $2 ??] ")/se;
   207   s/^by(\s*\(?\s*)(.*?)$/"apply$1".process_tac($1,$2)/se;
   210   s/^by(\s*\(?\s*)(.*?)$/"apply$1".process_tac($1,$2)/se;
       
   211   s/^Addsimps\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [simp]"/seg;
       
   212   s/^Delsimps\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [simp del]"/seg;
       
   213   s/^Addsplits\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [split]"/seg;
       
   214   s/^Delsplits\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [split del]"/seg;
       
   215   s/^AddIs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [intro]"/seg;
       
   216   s/^AddSIs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [intro!]"/seg;
       
   217   s/^AddEs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [elim]"/seg;
       
   218   s/^AddSEs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [elim!]"/seg;
       
   219   s/^AddDs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [dest]"/seg;
       
   220   s/^AddSDs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [dest!]"/seg;
       
   221   s/^AddIffs\s*\[\s*([\w\'\. ,]*)\s*\]/"declare ".thmlist($1)." [iff]"/seg;
   208   print "$_$tail";
   222   print "$_$tail";
   209   if(!$next) { last; } # prevents reading finally from stdin (thru <>)!
   223   if(!$next) { last; } # prevents reading finally from stdin (thru <>)!
   210 }
   224 }
   211 backpatch_thmnames;
   225 backpatch_thmnames;
   212 select(STDOUT);
   226 select(STDOUT);