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.
berghofe@11522
     1
(*  Title:      Pure/Proof/proof_rewrite_rules.ML
berghofe@11522
     2
    ID:         $Id$
berghofe@11522
     3
    Author:     Stefan Berghofer
berghofe@11522
     4
    Copyright   2000  TU Muenchen
berghofe@11522
     5
berghofe@11522
     6
Simplification function for partial proof terms involving
berghofe@11522
     7
meta level rules.
berghofe@11522
     8
*)
berghofe@11522
     9
berghofe@11522
    10
signature PROOF_REWRITE_RULES =
berghofe@11522
    11
sig
berghofe@11522
    12
  val rprocs : (string * (typ list -> Proofterm.proof -> Proofterm.proof option)) list
berghofe@11522
    13
end;
berghofe@11522
    14
berghofe@11522
    15
structure ProofRewriteRules : PROOF_REWRITE_RULES =
berghofe@11522
    16
struct
berghofe@11522
    17
berghofe@11522
    18
open Proofterm;
berghofe@11522
    19
berghofe@11522
    20
fun rew _ (PThm (("ProtoPure.rev_triv_goal", _), _, _, _) %% _ %
berghofe@11522
    21
      (PThm (("ProtoPure.triv_goal", _), _, _, _) %% _ % prf)) = Some prf
berghofe@11522
    22
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% _ %% _ %
berghofe@11522
    23
      (PAxm ("ProtoPure.equal_intr", _, _) %% _ %% _ % prf % _)) = Some prf
berghofe@11522
    24
  | rew _ (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
berghofe@11522
    25
      (PAxm ("ProtoPure.equal_intr", _, _) %% A %% B % prf1 % prf2)) =
berghofe@11522
    26
          Some (equal_intr_axm %% B %% A % prf2 % prf1)
berghofe@11522
    27
berghofe@11522
    28
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
berghofe@11522
    29
      (PAxm ("ProtoPure.combination", _, _) %% _ %% _ %% _ %% _ %
berghofe@11522
    30
        (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("==>", _)) %% _ %% _ %% _ %
berghofe@11522
    31
           (PAxm ("ProtoPure.reflexive", _, _) %% _) % prf1) % prf2)) =
berghofe@11522
    32
      let
berghofe@11522
    33
        val _ $ A $ C = Envir.beta_norm X;
berghofe@11522
    34
        val _ $ B $ D = Envir.beta_norm Y
berghofe@11522
    35
      in Some (AbsP ("H1", None, AbsP ("H2", None,
berghofe@11522
    36
        equal_elim_axm %%% C %%% D % incr_pboundvars 2 0 prf2 %
berghofe@11522
    37
          (PBound 1 % (equal_elim_axm %%% B %%% A %
berghofe@11522
    38
            (symmetric_axm %% None %% None % incr_pboundvars 2 0 prf1) % PBound 0)))))
berghofe@11522
    39
      end
berghofe@11522
    40
berghofe@11522
    41
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
berghofe@11522
    42
      (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
berghofe@11522
    43
        (PAxm ("ProtoPure.combination", _, _) %% _ %% _ %% _ %% _ %
berghofe@11522
    44
          (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("==>", _)) %% _ %% _ %% _ %
berghofe@11522
    45
             (PAxm ("ProtoPure.reflexive", _, _) %% _) % prf1) % prf2))) =
berghofe@11522
    46
      let
berghofe@11522
    47
        val _ $ A $ C = Envir.beta_norm Y;
berghofe@11522
    48
        val _ $ B $ D = Envir.beta_norm X
berghofe@11522
    49
      in Some (AbsP ("H1", None, AbsP ("H2", None,
berghofe@11522
    50
        equal_elim_axm %%% D %%% C %
berghofe@11522
    51
          (symmetric_axm %% None %% None % incr_pboundvars 2 0 prf2)
berghofe@11522
    52
            % (PBound 1 % (equal_elim_axm %%% A %%% B % incr_pboundvars 2 0 prf1 % PBound 0)))))
berghofe@11522
    53
      end
berghofe@11522
    54
berghofe@11522
    55
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
berghofe@11522
    56
      (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("all", _)) %% _ %% _ %% _ %
berghofe@11522
    57
        (PAxm ("ProtoPure.reflexive", _, _) %% _) %
berghofe@11522
    58
          (PAxm ("ProtoPure.abstract_rule", _, _) %% _ %% _ % prf))) =
berghofe@11522
    59
      let
berghofe@11522
    60
        val _ $ P = Envir.beta_norm X;
berghofe@11522
    61
        val _ $ Q = Envir.beta_norm Y;
berghofe@11522
    62
      in Some (AbsP ("H", None, Abst ("x", None,
berghofe@11522
    63
          equal_elim_axm %%% incr_boundvars 1 P $ Bound 0 %%% incr_boundvars 1 Q $ Bound 0 %
berghofe@11522
    64
            (incr_pboundvars 1 1 prf %%% Bound 0) % (PBound 0 %%% Bound 0))))
berghofe@11522
    65
      end
berghofe@11522
    66
berghofe@11522
    67
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some X %% Some Y %
berghofe@11522
    68
      (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %        
berghofe@11522
    69
        (PAxm ("ProtoPure.combination", _, _) %% Some (Const ("all", _)) %% _ %% _ %% _ %
berghofe@11522
    70
          (PAxm ("ProtoPure.reflexive", _, _) %% _) %
berghofe@11522
    71
            (PAxm ("ProtoPure.abstract_rule", _, _) %% _ %% _ % prf)))) =
berghofe@11522
    72
      let
berghofe@11522
    73
        val _ $ P = Envir.beta_norm X;
berghofe@11522
    74
        val _ $ Q = Envir.beta_norm Y;
berghofe@11522
    75
      in Some (AbsP ("H", None, Abst ("x", None,
berghofe@11522
    76
        equal_elim_axm %%% incr_boundvars 1 P $ Bound 0 %%% incr_boundvars 1 Q $ Bound 0 %
berghofe@11522
    77
          (symmetric_axm %% None %% None % (incr_pboundvars 1 1 prf %%% Bound 0))
berghofe@11522
    78
            % (PBound 0 %%% Bound 0))))
berghofe@11522
    79
      end
berghofe@11522
    80
berghofe@11522
    81
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some A %% Some C %
berghofe@11522
    82
      (PAxm ("ProtoPure.transitive", _, _) %% _ %% Some B %% _ % prf1 % prf2) % prf3) =
berghofe@11522
    83
         Some (equal_elim_axm %%% B %%% C % prf2 %
berghofe@11522
    84
           (equal_elim_axm %%% A %%% B % prf1 % prf3))
berghofe@11522
    85
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% Some A %% Some C %
berghofe@11522
    86
      (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
berghofe@11522
    87
        (PAxm ("ProtoPure.transitive", _, _) %% _ %% Some B %% _ % prf1 % prf2)) % prf3) =
berghofe@11522
    88
         Some (equal_elim_axm %%% B %%% C % (symmetric_axm %% None %% None % prf1) %
berghofe@11522
    89
           (equal_elim_axm %%% A %%% B % (symmetric_axm %% None %% None % prf2) % prf3))
berghofe@11522
    90
berghofe@11522
    91
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% _ %% _ %
berghofe@11522
    92
      (PAxm ("ProtoPure.reflexive", _, _) %% _) % prf) = Some prf
berghofe@11522
    93
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) %% _ %% _ %
berghofe@11522
    94
      (PAxm ("ProtoPure.symmetric", _, _) %% _ %% _ %
berghofe@11522
    95
        (PAxm ("ProtoPure.reflexive", _, _) %% _)) % prf) = Some prf
berghofe@11522
    96
berghofe@11522
    97
  | rew _ _ = None;
berghofe@11522
    98
berghofe@11522
    99
val rprocs = [("Pure/meta_equality", rew)];
berghofe@11522
   100
berghofe@11522
   101
end;
berghofe@11522
   102
berghofe@11522
   103
Proofterm.add_prf_rprocs ProtoPure.thy ProofRewriteRules.rprocs;