src/FOL/simpdata.ML
changeset 4652 d24cca140eeb
parent 4649 89ad3eb863a1
child 4669 06f3c56dcba8
equal deleted inserted replaced
4651:70dd492a1698 4652:d24cca140eeb
   307 
   307 
   308 simpset_ref() := FOL_ss;
   308 simpset_ref() := FOL_ss;
   309 
   309 
   310 
   310 
   311 
   311 
       
   312 
       
   313 
       
   314 
       
   315 
   312 (*** Integration of simplifier with classical reasoner ***)
   316 (*** Integration of simplifier with classical reasoner ***)
   313 
   317 
   314 (* rot_eq_tac rotates the first equality premise of subgoal i to the front,
   318 (* rot_eq_tac rotates the first equality premise of subgoal i to the front,
   315    fails if there is no equaliy or if an equality is already at the front *)
   319    fails if there is no equaliy or if an equality is already at the front *)
   316 local
   320 local
   322 val rot_eq_tac = 
   326 val rot_eq_tac = 
   323      SUBGOAL (fn (Bi,i) => let val n = find_eq (Logic.strip_assums_hyp Bi) in
   327      SUBGOAL (fn (Bi,i) => let val n = find_eq (Logic.strip_assums_hyp Bi) in
   324 		if n>0 then rotate_tac n i else no_tac end)
   328 		if n>0 then rotate_tac n i else no_tac end)
   325 end;
   329 end;
   326 
   330 
   327 
   331 use "$ISABELLE_HOME/src/Provers/clasimp.ML";
   328 fun safe_asm_more_full_simp_tac ss = TRY o rot_eq_tac THEN' 
   332 open Clasimp;
   329 				     safe_asm_full_simp_tac ss;
       
   330 (*an unsatisfactory fix for the incomplete asm_full_simp_tac!
       
   331   better: asm_really_full_simp_tac, a yet to be implemented version of
       
   332 			asm_full_simp_tac that applies all equalities in the
       
   333 			premises to all the premises *)
       
   334 
       
   335 (*Add a simpset to a classical set!*)
       
   336 infix 4 addSss addss;
       
   337 fun cs addSss ss = cs addSaltern ("safe_asm_more_full_simp_tac",
       
   338 				  CHANGED o (safe_asm_more_full_simp_tac ss));
       
   339 fun cs addss  ss = cs addbefore  ("asm_full_simp_tac", asm_full_simp_tac ss);
       
   340 
       
   341 fun Addss ss = (claset_ref() := claset() addss ss);
       
   342 
       
   343 (*Designed to be idempotent, except if best_tac instantiates variables
       
   344   in some of the subgoals*)
       
   345 
       
   346 type clasimpset = (claset * simpset);
       
   347 
   333 
   348 val FOL_css = (FOL_cs, FOL_ss);
   334 val FOL_css = (FOL_cs, FOL_ss);
   349 
   335 
   350 fun pair_upd1 f ((a,b),x) = (f(a,x), b);
       
   351 fun pair_upd2 f ((a,b),x) = (a, f(b,x));
       
   352 
       
   353 infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2
       
   354 	addsimps2 delsimps2 addcongs2 delcongs2;
       
   355 fun op addSIs2   arg = pair_upd1 (op addSIs) arg;
       
   356 fun op addSEs2   arg = pair_upd1 (op addSEs) arg;
       
   357 fun op addSDs2   arg = pair_upd1 (op addSDs) arg;
       
   358 fun op addIs2    arg = pair_upd1 (op addIs ) arg;
       
   359 fun op addEs2    arg = pair_upd1 (op addEs ) arg;
       
   360 fun op addDs2    arg = pair_upd1 (op addDs ) arg;
       
   361 fun op addsimps2 arg = pair_upd2 (op addsimps) arg;
       
   362 fun op delsimps2 arg = pair_upd2 (op delsimps) arg;
       
   363 fun op addcongs2 arg = pair_upd2 (op addcongs) arg;
       
   364 fun op delcongs2 arg = pair_upd2 (op delcongs) arg;
       
   365 
       
   366 
       
   367 fun mk_auto_tac (cs, ss) m n =
       
   368     let val cs' = cs addss ss 
       
   369 	val bdt = Blast.depth_tac cs m;
       
   370 	fun blast_depth_tac i thm = bdt i thm handle Blast.TRANS s => 
       
   371 		(warning ("Blast_tac: " ^ s); Seq.empty);
       
   372         val maintac = 
       
   373           blast_depth_tac	   (*fast but can't use addss*)
       
   374           ORELSE'
       
   375           depth_tac cs' n;         (*slower but general*)
       
   376     in  EVERY [ALLGOALS (asm_full_simp_tac ss),
       
   377 	       TRY (safe_tac cs'),
       
   378 	       REPEAT (FIRSTGOAL maintac),
       
   379                TRY (safe_tac (cs addSss ss)),
       
   380 	       prune_params_tac] 
       
   381     end;
       
   382 
       
   383 fun auto_tac (cs,ss) = mk_auto_tac (cs,ss) 4 2;
       
   384 
       
   385 fun Auto_tac st = auto_tac (claset(), simpset()) st;
       
   386 
       
   387 fun auto () = by Auto_tac;