src/HOL/Import/shuffler.ML
changeset 37778 87b5dfe00387
parent 37146 f652333bbf8e
child 38549 d0385f2764d8
equal deleted inserted replaced
37777:22107b894e5a 37778:87b5dfe00387
   217         val lhs = list_all ([xv,yv],t)
   217         val lhs = list_all ([xv,yv],t)
   218         val rhs = list_all ([yv,xv],swap_bound 0 t)
   218         val rhs = list_all ([yv,xv],swap_bound 0 t)
   219         val rew = Logic.mk_equals (lhs,rhs)
   219         val rew = Logic.mk_equals (lhs,rhs)
   220         val init = Thm.trivial (cterm_of thy rew)
   220         val init = Thm.trivial (cterm_of thy rew)
   221     in
   221     in
   222         (all_comm RS init handle e => (message "rew_th"; OldGoals.print_exn e))
   222         all_comm RS init
   223     end
   223     end
   224 
   224 
   225 fun quant_rewrite thy assumes (t as Const("all",T1) $ (Abs(x,xT,Const("all",T2) $ Abs(y,yT,body)))) =
   225 fun quant_rewrite thy assumes (t as Const("all",T1) $ (Abs(x,xT,Const("all",T2) $ Abs(y,yT,body)))) =
   226     let
   226     let
   227         val res = (find_bound 0 body;2) handle RESULT i => i
   227         val res = (find_bound 0 body;2) handle RESULT i => i
   313                 else ()
   313                 else ()
   314             end
   314             end
   315     in
   315     in
   316         case t of
   316         case t of
   317             Const("all",_) $ (Abs(x,xT,Const("==",eqT) $ P $ Q)) =>
   317             Const("all",_) $ (Abs(x,xT,Const("==",eqT) $ P $ Q)) =>
   318             ((if eta_redex P andalso eta_redex Q
   318             (if eta_redex P andalso eta_redex Q
   319               then
   319               then
   320                   let
   320                   let
   321                       val cert = cterm_of thy
   321                       val cert = cterm_of thy
   322                       val v = Free (Name.variant (Term.add_free_names t []) "v", xT)
   322                       val v = Free (Name.variant (Term.add_free_names t []) "v", xT)
   323                       val cv = cert v
   323                       val cv = cert v
   338                       val lhs = (#1 (Logic.dest_equals (prop_of res)))
   338                       val lhs = (#1 (Logic.dest_equals (prop_of res)))
   339                   in
   339                   in
   340                        SOME res
   340                        SOME res
   341                   end
   341                   end
   342               else NONE)
   342               else NONE)
   343              handle e => OldGoals.print_exn e)
       
   344           | _ => NONE
   343           | _ => NONE
   345        end
   344        end
   346 
   345 
   347 fun beta_fun thy assume t =
   346 fun beta_fun thy assume t =
   348     SOME (Thm.beta_conversion true (cterm_of thy t))
   347     SOME (Thm.beta_conversion true (cterm_of thy t))
   519         val c = prop_of th
   518         val c = prop_of th
   520         val vars = OldTerm.add_term_frees (c, OldTerm.add_term_vars(c,[]))
   519         val vars = OldTerm.add_term_frees (c, OldTerm.add_term_vars(c,[]))
   521     in
   520     in
   522         Drule.forall_intr_list (map (cterm_of thy) vars) th
   521         Drule.forall_intr_list (map (cterm_of thy) vars) th
   523     end
   522     end
   524     handle e => (writeln "close_thm internal error"; OldGoals.print_exn e)
   523 
   525 
   524 
   526 (* Normalizes a theorem's conclusion using norm_term. *)
   525 (* Normalizes a theorem's conclusion using norm_term. *)
   527 
   526 
   528 fun norm_thm thy th =
   527 fun norm_thm thy th =
   529     let
   528     let
   616                res as SOME (name,th) => if (prop_of th) aconv t
   615                res as SOME (name,th) => if (prop_of th) aconv t
   617                                         then res
   616                                         then res
   618                                         else error "Internal error in set_prop"
   617                                         else error "Internal error in set_prop"
   619              | NONE => NONE
   618              | NONE => NONE
   620     end
   619     end
   621     handle e => (writeln "set_prop internal error"; OldGoals.print_exn e)
       
   622 
   620 
   623 fun find_potential thy t =
   621 fun find_potential thy t =
   624     let
   622     let
   625         val shuffles = ShuffleData.get thy
   623         val shuffles = ShuffleData.get thy
   626         val ignored = collect_ignored shuffles []
   624         val ignored = collect_ignored shuffles []