src/HOL/Nominal/nominal_permeq.ML
changeset 26338 f8ed02f22433
parent 25997 0c0f5d990d7d
child 26343 0dd2eab7b296
equal deleted inserted replaced
26337:44473c957672 26338:f8ed02f22433
    69 val cp1_aux             = @{thm "cp1_aux"};
    69 val cp1_aux             = @{thm "cp1_aux"};
    70 val perm_aux_fold       = @{thm "perm_aux_fold"}; 
    70 val perm_aux_fold       = @{thm "perm_aux_fold"}; 
    71 val supports_fresh_rule = @{thm "supports_fresh"};
    71 val supports_fresh_rule = @{thm "supports_fresh"};
    72 
    72 
    73 (* pulls out dynamically a thm via the proof state *)
    73 (* pulls out dynamically a thm via the proof state *)
    74 fun dynamic_thms st name = PureThy.get_thms (theory_of_thm st) (Name name);
    74 fun global_thms st name = PureThy.get_thms (theory_of_thm st) (Facts.Named (name, NONE));
    75 fun dynamic_thm  st name = PureThy.get_thm  (theory_of_thm st) (Name name);
    75 fun global_thm  st name = PureThy.get_thm  (theory_of_thm st) (Facts.Named (name, NONE));
    76 
    76 
    77 
    77 
    78 (* needed in the process of fully simplifying permutations *)
    78 (* needed in the process of fully simplifying permutations *)
    79 val strong_congs = [@{thm "if_cong"}]
    79 val strong_congs = [@{thm "if_cong"}]
    80 (* needed to avoid warnings about overwritten congs *)
    80 (* needed to avoid warnings about overwritten congs *)
   109         (Const("Nominal.perm",
   109         (Const("Nominal.perm",
   110           Type("fun",[Type("List.list",[Type("*",[Type(n,_),_])]),_])) $ pi $ (f $ x)) => 
   110           Type("fun",[Type("List.list",[Type("*",[Type(n,_),_])]),_])) $ pi $ (f $ x)) => 
   111             (if (applicable_app f) then
   111             (if (applicable_app f) then
   112               let
   112               let
   113                 val name = Sign.base_name n
   113                 val name = Sign.base_name n
   114                 val at_inst = PureThy.get_thm sg (Name ("at_" ^ name ^ "_inst"))
   114                 val at_inst = dynamic_thm sg ("at_" ^ name ^ "_inst")
   115                 val pt_inst = PureThy.get_thm sg (Name ("pt_" ^ name ^ "_inst"))
   115                 val pt_inst = dynamic_thm sg ("pt_" ^ name ^ "_inst")
   116               in SOME ((at_inst RS (pt_inst RS perm_eq_app)) RS eq_reflection) end
   116               in SOME ((at_inst RS (pt_inst RS perm_eq_app)) RS eq_reflection) end
   117             else NONE)
   117             else NONE)
   118       | _ => NONE
   118       | _ => NONE
   119   end
   119   end
   120 
   120 
   144 (* function for simplyfying permutations *)
   144 (* function for simplyfying permutations *)
   145 fun perm_simp_gen dyn_thms eqvt_thms ss i = 
   145 fun perm_simp_gen dyn_thms eqvt_thms ss i = 
   146     ("general simplification of permutations", fn st =>
   146     ("general simplification of permutations", fn st =>
   147     let
   147     let
   148        val ss' = Simplifier.theory_context (theory_of_thm st) ss
   148        val ss' = Simplifier.theory_context (theory_of_thm st) ss
   149          addsimps ((List.concat (map (dynamic_thms st) dyn_thms))@eqvt_thms)
   149          addsimps ((List.concat (map (global_thms st) dyn_thms))@eqvt_thms)
   150          delcongs weak_congs
   150          delcongs weak_congs
   151          addcongs strong_congs
   151          addcongs strong_congs
   152          addsimprocs [perm_simproc_fun, perm_simproc_app]
   152          addsimprocs [perm_simproc_fun, perm_simproc_app]
   153     in
   153     in
   154       asm_full_simp_tac ss' i st
   154       asm_full_simp_tac ss' i st
   196       if pi1 <> pi2 then  (* only apply the composition rule in this case *)
   196       if pi1 <> pi2 then  (* only apply the composition rule in this case *)
   197         if T = U then    
   197         if T = U then    
   198           SOME (Drule.instantiate'
   198           SOME (Drule.instantiate'
   199             [SOME (ctyp_of sg (fastype_of t))]
   199             [SOME (ctyp_of sg (fastype_of t))]
   200             [SOME (cterm_of sg pi1), SOME (cterm_of sg pi2), SOME (cterm_of sg t)]
   200             [SOME (cterm_of sg pi1), SOME (cterm_of sg pi2), SOME (cterm_of sg t)]
   201             (mk_meta_eq ([PureThy.get_thm sg (Name ("pt_"^tname'^"_inst")),
   201             (mk_meta_eq ([dynamic_thm sg ("pt_"^tname'^"_inst"),
   202              PureThy.get_thm sg (Name ("at_"^tname'^"_inst"))] MRS pt_perm_compose_aux)))
   202              dynamic_thm sg ("at_"^tname'^"_inst")] MRS pt_perm_compose_aux)))
   203         else
   203         else
   204           SOME (Drule.instantiate'
   204           SOME (Drule.instantiate'
   205             [SOME (ctyp_of sg (fastype_of t))]
   205             [SOME (ctyp_of sg (fastype_of t))]
   206             [SOME (cterm_of sg pi1), SOME (cterm_of sg pi2), SOME (cterm_of sg t)]
   206             [SOME (cterm_of sg pi1), SOME (cterm_of sg pi2), SOME (cterm_of sg t)]
   207             (mk_meta_eq (PureThy.get_thm sg (Name ("cp_"^tname'^"_"^uname'^"_inst")) RS 
   207             (mk_meta_eq (dynamic_thm sg ("cp_"^tname'^"_"^uname'^"_inst") RS 
   208              cp1_aux)))
   208              cp1_aux)))
   209       else NONE
   209       else NONE
   210     end
   210     end
   211   | _ => NONE);
   211   | _ => NONE);
   212 
   212 
   305             val supports_rule' = Thm.lift_rule goal supports_rule;
   305             val supports_rule' = Thm.lift_rule goal supports_rule;
   306             val _ $ (_ $ S $ _) =
   306             val _ $ (_ $ S $ _) =
   307               Logic.strip_assums_concl (hd (prems_of supports_rule'));
   307               Logic.strip_assums_concl (hd (prems_of supports_rule'));
   308             val supports_rule'' = Drule.cterm_instantiate
   308             val supports_rule'' = Drule.cterm_instantiate
   309               [(cert (head_of S), cert s')] supports_rule'
   309               [(cert (head_of S), cert s')] supports_rule'
   310             val fin_supp = dynamic_thms st ("fin_supp")
   310             val fin_supp = global_thms st ("fin_supp")
   311             val ss' = ss addsimps [supp_prod,supp_unit,finite_Un,finite_emptyI,conj_absorb]@fin_supp
   311             val ss' = ss addsimps [supp_prod,supp_unit,finite_Un,finite_emptyI,conj_absorb]@fin_supp
   312           in
   312           in
   313             (tactical ("guessing of the right supports-set",
   313             (tactical ("guessing of the right supports-set",
   314                       EVERY [compose_tac (false, supports_rule'', 2) i,
   314                       EVERY [compose_tac (false, supports_rule'', 2) i,
   315                              asm_full_simp_tac ss' (i+1),
   315                              asm_full_simp_tac ss' (i+1),
   324 (* it first collects all free variables and tries to show that the *) 
   324 (* it first collects all free variables and tries to show that the *) 
   325 (* support of these free variables (op supports) the goal          *)
   325 (* support of these free variables (op supports) the goal          *)
   326 fun fresh_guess_tac tactical ss i st =
   326 fun fresh_guess_tac tactical ss i st =
   327     let 
   327     let 
   328 	val goal = List.nth(cprems_of st, i-1)
   328 	val goal = List.nth(cprems_of st, i-1)
   329         val fin_supp = dynamic_thms st ("fin_supp")
   329         val fin_supp = global_thms st ("fin_supp")
   330         val fresh_atm = dynamic_thms st ("fresh_atm")
   330         val fresh_atm = global_thms st ("fresh_atm")
   331 	val ss1 = ss addsimps [symmetric fresh_def,fresh_prod,fresh_unit,conj_absorb,not_false]@fresh_atm
   331 	val ss1 = ss addsimps [symmetric fresh_def,fresh_prod,fresh_unit,conj_absorb,not_false]@fresh_atm
   332         val ss2 = ss addsimps [supp_prod,supp_unit,finite_Un,finite_emptyI,conj_absorb]@fin_supp
   332         val ss2 = ss addsimps [supp_prod,supp_unit,finite_Un,finite_emptyI,conj_absorb]@fin_supp
   333     in
   333     in
   334       case Logic.strip_assums_concl (term_of goal) of
   334       case Logic.strip_assums_concl (term_of goal) of
   335           _ $ (Const ("Nominal.fresh", Type ("fun", [T, _])) $ _ $ t) => 
   335           _ $ (Const ("Nominal.fresh", Type ("fun", [T, _])) $ _ $ t) =>