src/Pure/Proof/proof_rewrite_rules.ML
author berghofe
Wed Oct 31 20:00:35 2001 +0100 (2001-10-31 ago)
changeset 12002 bc9b5bad0e7b
parent 11612 ae8450657bf0
child 12237 39aeccee9e1c
permissions -rw-r--r--
Additional rules for simplifying inside "Goal"
     1 (*  Title:      Pure/Proof/proof_rewrite_rules.ML
     2     ID:         $Id$
     3     Author:     Stefan Berghofer, TU Muenchen
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     5 
     6 Simplification function for partial proof terms involving
     7 meta level rules.
     8 *)
     9 
    10 signature PROOF_REWRITE_RULES =
    11 sig
    12   val rprocs : (string * (typ list -> Proofterm.proof -> Proofterm.proof option)) list
    13 end;
    14 
    15 structure ProofRewriteRules : PROOF_REWRITE_RULES =
    16 struct
    17 
    18 open Proofterm;
    19 
    20 fun rew _ (PThm (("ProtoPure.rev_triv_goal", _), _, _, _) % _ %%
    21       (PThm (("ProtoPure.triv_goal", _), _, _, _) % _ %% prf)) = Some prf
    22   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
    23       (PAxm ("ProtoPure.equal_intr", _, _) % _ % _ %% prf %% _)) = Some prf
    24   | rew _ (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
    25       (PAxm ("ProtoPure.equal_intr", _, _) % A % B %% prf1 %% prf2)) =
    26           Some (equal_intr_axm % B % A %% prf2 %% prf1)
    27 
    28   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some (_ $ A) % Some (_ $ B) %%
    29       (PAxm ("ProtoPure.combination", _, _) % Some (Const ("Goal", _)) %
    30         _ % _ % _ %% (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %%
    31       ((tg as PThm (("ProtoPure.triv_goal", _), _, _, _)) % _ %% prf2)) =
    32       Some (tg %> B %% (equal_elim_axm %> A %> B %% prf1 %% prf2))
    33 
    34   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some (_ $ A) % Some (_ $ B) %%
    35       (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
    36         (PAxm ("ProtoPure.combination", _, _) % Some (Const ("Goal", _)) %
    37            _ % _ % _ %% (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1)) %%
    38       ((tg as PThm (("ProtoPure.triv_goal", _), _, _, _)) % _ %% prf2)) =
    39       Some (tg %> B %% (equal_elim_axm %> A %> B %%
    40         (symmetric_axm % None % None %% prf1) %% prf2))
    41 
    42   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
    43       (PAxm ("ProtoPure.combination", _, _) % _ % _ % _ % _ %%
    44         (PAxm ("ProtoPure.combination", _, _) % Some (Const ("==>", _)) % _ % _ % _ %%
    45            (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %% prf2)) =
    46       let
    47         val _ $ A $ C = Envir.beta_norm X;
    48         val _ $ B $ D = Envir.beta_norm Y
    49       in Some (AbsP ("H1", None, AbsP ("H2", None,
    50         equal_elim_axm %> C %> D %% incr_pboundvars 2 0 prf2 %%
    51           (PBound 1 %% (equal_elim_axm %> B %> A %%
    52             (symmetric_axm % None % None %% incr_pboundvars 2 0 prf1) %% PBound 0)))))
    53       end
    54 
    55   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
    56       (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
    57         (PAxm ("ProtoPure.combination", _, _) % _ % _ % _ % _ %%
    58           (PAxm ("ProtoPure.combination", _, _) % Some (Const ("==>", _)) % _ % _ % _ %%
    59              (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %% prf2))) =
    60       let
    61         val _ $ A $ C = Envir.beta_norm Y;
    62         val _ $ B $ D = Envir.beta_norm X
    63       in Some (AbsP ("H1", None, AbsP ("H2", None,
    64         equal_elim_axm %> D %> C %%
    65           (symmetric_axm % None % None %% incr_pboundvars 2 0 prf2)
    66             %% (PBound 1 %% (equal_elim_axm %> A %> B %% incr_pboundvars 2 0 prf1 %% PBound 0)))))
    67       end
    68 
    69   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
    70       (PAxm ("ProtoPure.combination", _, _) % Some (Const ("all", _)) % _ % _ % _ %%
    71         (PAxm ("ProtoPure.reflexive", _, _) % _) %%
    72           (PAxm ("ProtoPure.abstract_rule", _, _) % _ % _ %% prf))) =
    73       let
    74         val _ $ P = Envir.beta_norm X;
    75         val _ $ Q = Envir.beta_norm Y;
    76       in Some (AbsP ("H", None, Abst ("x", None,
    77           equal_elim_axm %> incr_boundvars 1 P $ Bound 0 %> incr_boundvars 1 Q $ Bound 0 %%
    78             (incr_pboundvars 1 1 prf %> Bound 0) %% (PBound 0 %> Bound 0))))
    79       end
    80 
    81   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
    82       (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%        
    83         (PAxm ("ProtoPure.combination", _, _) % Some (Const ("all", _)) % _ % _ % _ %%
    84           (PAxm ("ProtoPure.reflexive", _, _) % _) %%
    85             (PAxm ("ProtoPure.abstract_rule", _, _) % _ % _ %% prf)))) =
    86       let
    87         val _ $ P = Envir.beta_norm X;
    88         val _ $ Q = Envir.beta_norm Y;
    89       in Some (AbsP ("H", None, Abst ("x", None,
    90         equal_elim_axm %> incr_boundvars 1 P $ Bound 0 %> incr_boundvars 1 Q $ Bound 0 %%
    91           (symmetric_axm % None % None %% (incr_pboundvars 1 1 prf %> Bound 0))
    92             %% (PBound 0 %> Bound 0))))
    93       end
    94 
    95   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some A % Some C %%
    96       (PAxm ("ProtoPure.transitive", _, _) % _ % Some B % _ %% prf1 %% prf2) %% prf3) =
    97          Some (equal_elim_axm %> B %> C %% prf2 %%
    98            (equal_elim_axm %> A %> B %% prf1 %% prf3))
    99   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some A % Some C %%
   100       (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
   101         (PAxm ("ProtoPure.transitive", _, _) % _ % Some B % _ %% prf1 %% prf2)) %% prf3) =
   102          Some (equal_elim_axm %> B %> C %% (symmetric_axm % None % None %% prf1) %%
   103            (equal_elim_axm %> A %> B %% (symmetric_axm % None % None %% prf2) %% prf3))
   104 
   105   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
   106       (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf) = Some prf
   107   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
   108       (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
   109         (PAxm ("ProtoPure.reflexive", _, _) % _)) %% prf) = Some prf
   110 
   111   | rew _ _ = None;
   112 
   113 val rprocs = [("Pure/meta_equality", rew)];
   114 
   115 end;
   116 
   117 Proofterm.add_prf_rprocs ProtoPure.thy ProofRewriteRules.rprocs;