src/Pure/Proof/proof_rewrite_rules.ML
author berghofe
Fri Aug 31 16:17:05 2001 +0200 (2001-08-31 ago)
changeset 11522 42fbb6abed5a
child 11539 0f17da240450
permissions -rw-r--r--
Initial revision of tools for proof terms.
     1 (*  Title:      Pure/Proof/proof_rewrite_rules.ML
     2     ID:         $Id$
     3     Author:     Stefan Berghofer
     4     Copyright   2000  TU Muenchen
     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 X %% Some Y %
    29       (PAxm ("ProtoPure.combination", _, _) %% _ %% _ %% _ %% _ %
    30         (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("==>", _)) %% _ %% _ %% _ %
    31            (PAxm ("ProtoPure.reflexive", _, _) %% _) % prf1) % prf2)) =
    32       let
    33         val _ $ A $ C = Envir.beta_norm X;
    34         val _ $ B $ D = Envir.beta_norm Y
    35       in Some (AbsP ("H1", None, AbsP ("H2", None,
    36         equal_elim_axm %%% C %%% D % incr_pboundvars 2 0 prf2 %
    37           (PBound 1 % (equal_elim_axm %%% B %%% A %
    38             (symmetric_axm %% None %% None % incr_pboundvars 2 0 prf1) % PBound 0)))))
    39       end
    40 
    41   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
    42       (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
    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 Y;
    48         val _ $ B $ D = Envir.beta_norm X
    49       in Some (AbsP ("H1", None, AbsP ("H2", None,
    50         equal_elim_axm %%% D %%% C %
    51           (symmetric_axm %% None %% None % incr_pboundvars 2 0 prf2)
    52             % (PBound 1 % (equal_elim_axm %%% A %%% B % incr_pboundvars 2 0 prf1 % PBound 0)))))
    53       end
    54 
    55   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
    56       (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("all", _)) %% _ %% _ %% _ %
    57         (PAxm ("ProtoPure.reflexive", _, _) %% _) %
    58           (PAxm ("ProtoPure.abstract_rule", _, _) %% _ %% _ % prf))) =
    59       let
    60         val _ $ P = Envir.beta_norm X;
    61         val _ $ Q = Envir.beta_norm Y;
    62       in Some (AbsP ("H", None, Abst ("x", None,
    63           equal_elim_axm %%% incr_boundvars 1 P $ Bound 0 %%% incr_boundvars 1 Q $ Bound 0 %
    64             (incr_pboundvars 1 1 prf %%% Bound 0) % (PBound 0 %%% Bound 0))))
    65       end
    66 
    67   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
    68       (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %        
    69         (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("all", _)) %% _ %% _ %% _ %
    70           (PAxm ("ProtoPure.reflexive", _, _) %% _) %
    71             (PAxm ("ProtoPure.abstract_rule", _, _) %% _ %% _ % prf)))) =
    72       let
    73         val _ $ P = Envir.beta_norm X;
    74         val _ $ Q = Envir.beta_norm Y;
    75       in Some (AbsP ("H", None, Abst ("x", None,
    76         equal_elim_axm %%% incr_boundvars 1 P $ Bound 0 %%% incr_boundvars 1 Q $ Bound 0 %
    77           (symmetric_axm %% None %% None % (incr_pboundvars 1 1 prf %%% Bound 0))
    78             % (PBound 0 %%% Bound 0))))
    79       end
    80 
    81   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some A %% Some C %
    82       (PAxm ("ProtoPure.transitive", _, _) %% _ %% Some B %% _ % prf1 % prf2) % prf3) =
    83          Some (equal_elim_axm %%% B %%% C % prf2 %
    84            (equal_elim_axm %%% A %%% B % prf1 % prf3))
    85   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some A %% Some C %
    86       (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
    87         (PAxm ("ProtoPure.transitive", _, _) %% _ %% Some B %% _ % prf1 % prf2)) % prf3) =
    88          Some (equal_elim_axm %%% B %%% C % (symmetric_axm %% None %% None % prf1) %
    89            (equal_elim_axm %%% A %%% B % (symmetric_axm %% None %% None % prf2) % prf3))
    90 
    91   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% _ %% _ %
    92       (PAxm ("ProtoPure.reflexive", _, _) %% _) % prf) = Some prf
    93   | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% _ %% _ %
    94       (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
    95         (PAxm ("ProtoPure.reflexive", _, _) %% _)) % prf) = Some prf
    96 
    97   | rew _ _ = None;
    98 
    99 val rprocs = [("Pure/meta_equality", rew)];
   100 
   101 end;
   102 
   103 Proofterm.add_prf_rprocs ProtoPure.thy ProofRewriteRules.rprocs;