src/Tools/eqsubst.ML
changeset 52246 54c0d4128b30
parent 52242 2d634bfa1bbf
child 52732 b4da1f2ec73f
equal deleted inserted replaced
52245:f76fb8858e0b 52246:54c0d4128b30
    53 struct
    53 struct
    54 
    54 
    55 (* changes object "=" to meta "==" which prepares a given rewrite rule *)
    55 (* changes object "=" to meta "==" which prepares a given rewrite rule *)
    56 fun prep_meta_eq ctxt =
    56 fun prep_meta_eq ctxt =
    57   Simplifier.mksimps ctxt #> map Drule.zero_var_indexes;
    57   Simplifier.mksimps ctxt #> map Drule.zero_var_indexes;
       
    58 
       
    59 (* make free vars into schematic vars with index zero *)
       
    60 fun unfix_frees frees =
       
    61    fold (K (Thm.forall_elim_var 0)) frees o Drule.forall_intr_list frees;
    58 
    62 
    59 
    63 
    60 type match =
    64 type match =
    61   ((indexname * (sort * typ)) list (* type instantiations *)
    65   ((indexname * (sort * typ)) list (* type instantiations *)
    62    * (indexname * (typ * term)) list) (* term instantiations *)
    66    * (indexname * (typ * term)) list) (* term instantiations *)
   244 (* conclthm is a theorem of for just the conclusion *)
   248 (* conclthm is a theorem of for just the conclusion *)
   245 (* m is instantiation/match information *)
   249 (* m is instantiation/match information *)
   246 (* rule is the equation for substitution *)
   250 (* rule is the equation for substitution *)
   247 fun apply_subst_in_concl ctxt i st (cfvs, conclthm) rule m =
   251 fun apply_subst_in_concl ctxt i st (cfvs, conclthm) rule m =
   248   RW_Inst.rw ctxt m rule conclthm
   252   RW_Inst.rw ctxt m rule conclthm
   249   |> IsaND.unfix_frees cfvs
   253   |> unfix_frees cfvs
   250   |> Conv.fconv_rule Drule.beta_eta_conversion
   254   |> Conv.fconv_rule Drule.beta_eta_conversion
   251   |> (fn r => Tactic.rtac r i st);
   255   |> (fn r => Tactic.rtac r i st);
   252 
   256 
   253 (* substitute within the conclusion of goal i of gth, using a meta
   257 (* substitute within the conclusion of goal i of gth, using a meta
   254 equation rule. Note that we assume rule has var indicies zero'd *)
   258 equation rule. Note that we assume rule has var indicies zero'd *)
   324     val st2 = Thm.rotate_rule (j - 1) i st; (* put premice first *)
   328     val st2 = Thm.rotate_rule (j - 1) i st; (* put premice first *)
   325     val preelimrule =
   329     val preelimrule =
   326       RW_Inst.rw ctxt m rule pth
   330       RW_Inst.rw ctxt m rule pth
   327       |> (Seq.hd o prune_params_tac)
   331       |> (Seq.hd o prune_params_tac)
   328       |> Thm.permute_prems 0 ~1 (* put old asm first *)
   332       |> Thm.permute_prems 0 ~1 (* put old asm first *)
   329       |> IsaND.unfix_frees cfvs (* unfix any global params *)
   333       |> unfix_frees cfvs (* unfix any global params *)
   330       |> Conv.fconv_rule Drule.beta_eta_conversion; (* normal form *)
   334       |> Conv.fconv_rule Drule.beta_eta_conversion; (* normal form *)
   331   in
   335   in
   332     (* ~j because new asm starts at back, thus we subtract 1 *)
   336     (* ~j because new asm starts at back, thus we subtract 1 *)
   333     Seq.map (Thm.rotate_rule (~ j) (Thm.nprems_of rule + i))
   337     Seq.map (Thm.rotate_rule (~ j) (Thm.nprems_of rule + i))
   334       (Tactic.dtac preelimrule i st2)
   338       (Tactic.dtac preelimrule i st2)