src/Pure/Proof/proof_rewrite_rules.ML
changeset 80295 8a9588ffc133
parent 79411 700d4f16b5f2
child 80590 505f97165f52
equal deleted inserted replaced
80294:eec06d39e5fa 80295:8a9588ffc133
    37       else NONE;
    37       else NONE;
    38     val equal_intr_axm = ax Proofterm.equal_intr_axm [];
    38     val equal_intr_axm = ax Proofterm.equal_intr_axm [];
    39     val equal_elim_axm = ax Proofterm.equal_elim_axm [];
    39     val equal_elim_axm = ax Proofterm.equal_elim_axm [];
    40     val symmetric_axm = ax Proofterm.symmetric_axm [propT];
    40     val symmetric_axm = ax Proofterm.symmetric_axm [propT];
    41 
    41 
    42     fun rew' (PThm ({name = "Pure.protectD", ...}, _) % _ %%
    42     fun rew' (PThm ({thm_name = ("Pure.protectD", 0), ...}, _) % _ %%
    43         (PThm ({name = "Pure.protectI", ...}, _) % _ %% prf)) = SOME prf
    43         (PThm ({thm_name = ("Pure.protectI", 0), ...}, _) % _ %% prf)) = SOME prf
    44       | rew' (PThm ({name = "Pure.conjunctionD1", ...}, _) % _ % _ %%
    44       | rew' (PThm ({thm_name = ("Pure.conjunctionD1", 0), ...}, _) % _ % _ %%
    45         (PThm ({name = "Pure.conjunctionI", ...}, _) % _ % _ %% prf %% _)) = SOME prf
    45         (PThm ({thm_name = ("Pure.conjunctionI", 0), ...}, _) % _ % _ %% prf %% _)) = SOME prf
    46       | rew' (PThm ({name = "Pure.conjunctionD2", ...}, _) % _ % _ %%
    46       | rew' (PThm ({thm_name = ("Pure.conjunctionD2", 0), ...}, _) % _ % _ %%
    47         (PThm ({name = "Pure.conjunctionI", ...}, _) % _ % _ %% _ %% prf)) = SOME prf
    47         (PThm ({thm_name = ("Pure.conjunctionI", 0), ...}, _) % _ % _ %% _ %% prf)) = SOME prf
    48       | rew' (PAxm ("Pure.equal_elim", _, _) % _ % _ %%
    48       | rew' (PAxm ("Pure.equal_elim", _, _) % _ % _ %%
    49         (PAxm ("Pure.equal_intr", _, _) % _ % _ %% prf %% _)) = SOME prf
    49         (PAxm ("Pure.equal_intr", _, _) % _ % _ %% prf %% _)) = SOME prf
    50       | rew' (PAxm ("Pure.symmetric", _, _) % _ % _ %%
    50       | rew' (PAxm ("Pure.symmetric", _, _) % _ % _ %%
    51         (PAxm ("Pure.equal_intr", _, _) % A % B %% prf1 %% prf2)) =
    51         (PAxm ("Pure.equal_intr", _, _) % A % B %% prf1 %% prf2)) =
    52             SOME (equal_intr_axm % B % A %% prf2 %% prf1)
    52             SOME (equal_intr_axm % B % A %% prf2 %% prf1)
    53 
    53 
    54       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME (_ $ A) % SOME (_ $ B) %%
    54       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME (_ $ A) % SOME (_ $ B) %%
    55         (PAxm ("Pure.combination", _, _) % SOME (Const ("Pure.prop", _)) %
    55         (PAxm ("Pure.combination", _, _) % SOME (Const ("Pure.prop", _)) %
    56           _ % _ % _ %% (PAxm ("Pure.reflexive", _, _) % _) %% prf1) %%
    56           _ % _ % _ %% (PAxm ("Pure.reflexive", _, _) % _) %% prf1) %%
    57         ((tg as PThm ({name = "Pure.protectI", ...}, _)) % _ %% prf2)) =
    57         ((tg as PThm ({thm_name = ("Pure.protectI", 0), ...}, _)) % _ %% prf2)) =
    58         SOME (tg %> B %% (equal_elim_axm %> A %> B %% prf1 %% prf2))
    58         SOME (tg %> B %% (equal_elim_axm %> A %> B %% prf1 %% prf2))
    59 
    59 
    60       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME (_ $ A) % SOME (_ $ B) %%
    60       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME (_ $ A) % SOME (_ $ B) %%
    61         (PAxm ("Pure.symmetric", _, _) % _ % _ %%
    61         (PAxm ("Pure.symmetric", _, _) % _ % _ %%
    62           (PAxm ("Pure.combination", _, _) % SOME (Const ("Pure.prop", _)) %
    62           (PAxm ("Pure.combination", _, _) % SOME (Const ("Pure.prop", _)) %
    63              _ % _ % _ %% (PAxm ("Pure.reflexive", _, _) % _) %% prf1)) %%
    63              _ % _ % _ %% (PAxm ("Pure.reflexive", _, _) % _) %% prf1)) %%
    64         ((tg as PThm ({name = "Pure.protectI", ...}, _)) % _ %% prf2)) =
    64         ((tg as PThm ({thm_name = ("Pure.protectI", 0), ...}, _)) % _ %% prf2)) =
    65         SOME (tg %> B %% (equal_elim_axm %> A %> B %%
    65         SOME (tg %> B %% (equal_elim_axm %> A %> B %%
    66           (symmetric_axm % ?? B % ?? A %% prf1) %% prf2))
    66           (symmetric_axm % ?? B % ?? A %% prf1) %% prf2))
    67 
    67 
    68       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME X % SOME Y %%
    68       | rew' (PAxm ("Pure.equal_elim", _, _) % SOME X % SOME Y %%
    69         (PAxm ("Pure.combination", _, _) % _ % _ % _ % _ %%
    69         (PAxm ("Pure.combination", _, _) % _ % _ % _ % _ %%
   243       (Abst (s, SOME T, fst (insert_refl defs (T :: Ts) prf)), false)
   243       (Abst (s, SOME T, fst (insert_refl defs (T :: Ts) prf)), false)
   244   | insert_refl defs Ts (AbsP (s, t, prf)) =
   244   | insert_refl defs Ts (AbsP (s, t, prf)) =
   245       (AbsP (s, t, fst (insert_refl defs Ts prf)), false)
   245       (AbsP (s, t, fst (insert_refl defs Ts prf)), false)
   246   | insert_refl defs Ts prf =
   246   | insert_refl defs Ts prf =
   247       (case Proofterm.strip_combt prf of
   247       (case Proofterm.strip_combt prf of
   248         (PThm ({name = s, prop, types = SOME Ts, ...}, _), ts) =>
   248         (PThm ({thm_name, prop, types = SOME Ts, ...}, _), ts) =>
   249           if member (op =) defs s then
   249           if member (op =) defs thm_name then
   250             let
   250             let
   251               val vs = vars_of prop;
   251               val vs = vars_of prop;
   252               val tvars = build_rev (Term.add_tvars prop);
   252               val tvars = build_rev (Term.add_tvars prop);
   253               val (_, rhs) = Logic.dest_equals (Logic.strip_imp_concl prop);
   253               val (_, rhs) = Logic.dest_equals (Logic.strip_imp_concl prop);
   254               val rhs' = Term.betapplys (subst_TVars (map fst tvars ~~ Ts)
   254               val rhs' = Term.betapplys (subst_TVars (map fst tvars ~~ Ts)
   269     val prf' =
   269     val prf' =
   270       if r then
   270       if r then
   271         let
   271         let
   272           val cnames = map (fst o dest_Const o fst) defs';
   272           val cnames = map (fst o dest_Const o fst) defs';
   273           val expand = Proofterm.fold_proof_atoms true
   273           val expand = Proofterm.fold_proof_atoms true
   274             (fn PThm ({serial, name, prop, ...}, _) =>
   274             (fn PThm ({serial, thm_name, prop, ...}, _) =>
   275                 if member (op =) defnames name orelse
   275                 if member (op =) defnames thm_name orelse
   276                   not (exists_Const (member (op =) cnames o #1) prop)
   276                   not (exists_Const (member (op =) cnames o #1) prop)
   277                 then I
   277                 then I
   278                 else Inttab.update (serial, "")
   278                 else Inttab.update (serial, Thm_Name.empty)
   279               | _ => I) [prf] Inttab.empty;
   279               | _ => I) [prf] Inttab.empty;
   280         in Proofterm.expand_proof thy (Inttab.lookup expand o #serial) prf end
   280         in Proofterm.expand_proof thy (Inttab.lookup expand o #serial) prf end
   281       else prf;
   281       else prf;
   282   in
   282   in
   283     rewrite_terms (Pattern.rewrite_term thy defs' [])
   283     rewrite_terms (Pattern.rewrite_term thy defs' [])