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