src/HOL/Subst/Subst.ML
changeset 972 e61b058d58d2
parent 968 3cdaa8724175
child 1266 3ae9fe3c0f68
equal deleted inserted replaced
971:f4815812665b 972:e61b058d58d2
    17                                  (fn _ => [simp_tac raw_subst_ss 1])
    17                                  (fn _ => [simp_tac raw_subst_ss 1])
    18 in val subst_rews = map mk_thm 
    18 in val subst_rews = map mk_thm 
    19 ["Const(c) <| al = Const(c)",
    19 ["Const(c) <| al = Const(c)",
    20  "Comb t u <| al = Comb (t <| al) (u <| al)",
    20  "Comb t u <| al = Comb (t <| al) (u <| al)",
    21  "[] <> bl = bl",
    21  "[] <> bl = bl",
    22  "(<a,b>#al) <> bl = <a,b <| bl> # (al <> bl)",
    22  "((a,b)#al) <> bl = (a,b <| bl) # (al <> bl)",
    23  "sdom([]) = {}",
    23  "sdom([]) = {}",
    24  "sdom(<a,b>#al) = (if Var(a)=b then (sdom al) Int Compl({a}) \
    24  "sdom((a,b)#al) = (if Var(a)=b then (sdom al) Int Compl({a}) \
    25 \                               else (sdom al) Un {a})"
    25 \                               else (sdom al) Un {a})"
    26 ];
    26 ];
    27    (* This rewrite isn't always desired *)
    27    (* This rewrite isn't always desired *)
    28    val Var_subst = mk_thm "Var(x) <| al = assoc x (Var x) al";
    28    val Var_subst = mk_thm "Var(x) <| al = assoc x (Var x) al";
    29 end;
    29 end;
    40 goal Subst.thy "t <: u --> t <| s <: u <| s";
    40 goal Subst.thy "t <: u --> t <| s <: u <| s";
    41 by (uterm_ind_tac "u" 1);
    41 by (uterm_ind_tac "u" 1);
    42 by (ALLGOALS (asm_simp_tac subst_ss));
    42 by (ALLGOALS (asm_simp_tac subst_ss));
    43 val subst_mono  = store_thm("subst_mono", result() RS mp);
    43 val subst_mono  = store_thm("subst_mono", result() RS mp);
    44 
    44 
    45 goal Subst.thy  "~ (Var(v) <: t) --> t <| <v,t <| s>#s = t <| s";
    45 goal Subst.thy  "~ (Var(v) <: t) --> t <| (v,t <| s)#s = t <| s";
    46 by (imp_excluded_middle_tac "t = Var(v)" 1);
    46 by (imp_excluded_middle_tac "t = Var(v)" 1);
    47 by (res_inst_tac [("P",
    47 by (res_inst_tac [("P",
    48     "%x.~x=Var(v) --> ~(Var(v) <: x) --> x <| <v,t<|s>#s=x<|s")]
    48     "%x.~x=Var(v) --> ~(Var(v) <: x) --> x <| (v,t<|s)#s=x<|s")]
    49     uterm_induct 2);
    49     uterm_induct 2);
    50 by (ALLGOALS (simp_tac (subst_ss addsimps [Var_subst])));
    50 by (ALLGOALS (simp_tac (subst_ss addsimps [Var_subst])));
    51 by (fast_tac HOL_cs 1);
    51 by (fast_tac HOL_cs 1);
    52 val Var_not_occs  = store_thm("Var_not_occs", result() RS mp);
    52 val Var_not_occs  = store_thm("Var_not_occs", result() RS mp);
    53 
    53 
    57 by (REPEAT (etac rev_mp 3));
    57 by (REPEAT (etac rev_mp 3));
    58 by (ALLGOALS (asm_simp_tac subst_ss));
    58 by (ALLGOALS (asm_simp_tac subst_ss));
    59 by (ALLGOALS (fast_tac HOL_cs));
    59 by (ALLGOALS (fast_tac HOL_cs));
    60 qed "agreement";
    60 qed "agreement";
    61 
    61 
    62 goal Subst.thy   "~ v: vars_of(t) --> t <| <v,u>#s = t <| s";
    62 goal Subst.thy   "~ v: vars_of(t) --> t <| (v,u)#s = t <| s";
    63 by(simp_tac(subst_ss addsimps [agreement,Var_subst]
    63 by(simp_tac(subst_ss addsimps [agreement,Var_subst]
    64                      setloop (split_tac [expand_if])) 1);
    64                      setloop (split_tac [expand_if])) 1);
    65 val repl_invariance  = store_thm("repl_invariance", result() RS mp);
    65 val repl_invariance  = store_thm("repl_invariance", result() RS mp);
    66 
    66 
    67 val asms = goal Subst.thy 
    67 val asms = goal Subst.thy 
    68      "v : vars_of(t) --> w : vars_of(t <| <v,Var(w)>#s)";
    68      "v : vars_of(t) --> w : vars_of(t <| (v,Var(w))#s)";
    69 by (uterm_ind_tac "t" 1);
    69 by (uterm_ind_tac "t" 1);
    70 by (ALLGOALS (asm_simp_tac (subst_ss addsimps [Var_subst])));
    70 by (ALLGOALS (asm_simp_tac (subst_ss addsimps [Var_subst])));
    71 val Var_in_subst  = store_thm("Var_in_subst", result() RS mp);
    71 val Var_in_subst  = store_thm("Var_in_subst", result() RS mp);
    72 
    72 
    73 (**** Equality between Substitutions ****)
    73 (**** Equality between Substitutions ****)
   111 
   111 
   112 goal Subst.thy "(q <> r) <> s =s= q <> (r <> s)";
   112 goal Subst.thy "(q <> r) <> s =s= q <> (r <> s)";
   113 by (simp_tac (subst_ss addsimps [subst_eq_iff,subst_comp]) 1);
   113 by (simp_tac (subst_ss addsimps [subst_eq_iff,subst_comp]) 1);
   114 qed "comp_assoc";
   114 qed "comp_assoc";
   115 
   115 
   116 goal Subst.thy "<w,Var(w) <| s>#s =s= s"; 
   116 goal Subst.thy "(w,Var(w) <| s)#s =s= s"; 
   117 by (rtac (allI RS (subst_eq_iff RS iffD2)) 1);
   117 by (rtac (allI RS (subst_eq_iff RS iffD2)) 1);
   118 by (uterm_ind_tac "t" 1);
   118 by (uterm_ind_tac "t" 1);
   119 by (REPEAT (etac rev_mp 3));
   119 by (REPEAT (etac rev_mp 3));
   120 by (ALLGOALS (simp_tac (subst_ss addsimps[Var_subst]
   120 by (ALLGOALS (simp_tac (subst_ss addsimps[Var_subst]
   121                                  setloop (split_tac [expand_if]))));
   121                                  setloop (split_tac [expand_if]))));