src/Pure/Proof/proof_rewrite_rules.ML
author wenzelm
Wed, 14 Nov 2001 23:14:59 +0100
changeset 12184 f4aaa2647fd2
parent 12002 bc9b5bad0e7b
child 12237 39aeccee9e1c
permissions -rw-r--r--
updated;
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
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    13
end;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    14
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    15
structure ProofRewriteRules : PROOF_REWRITE_RULES =
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    16
struct
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    17
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    18
open Proofterm;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    19
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    20
fun rew _ (PThm (("ProtoPure.rev_triv_goal", _), _, _, _) % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    21
      (PThm (("ProtoPure.triv_goal", _), _, _, _) % _ %% prf)) = Some prf
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    22
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    23
      (PAxm ("ProtoPure.equal_intr", _, _) % _ % _ %% prf %% _)) = Some prf
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    24
  | rew _ (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    25
      (PAxm ("ProtoPure.equal_intr", _, _) % A % B %% prf1 %% prf2)) =
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    26
          Some (equal_intr_axm % B % A %% prf2 %% prf1)
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    27
12002
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    28
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some (_ $ A) % Some (_ $ B) %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    29
      (PAxm ("ProtoPure.combination", _, _) % Some (Const ("Goal", _)) %
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    30
        _ % _ % _ %% (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    31
      ((tg as PThm (("ProtoPure.triv_goal", _), _, _, _)) % _ %% prf2)) =
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    32
      Some (tg %> B %% (equal_elim_axm %> A %> B %% prf1 %% prf2))
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    33
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    34
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some (_ $ A) % Some (_ $ B) %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    35
      (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    36
        (PAxm ("ProtoPure.combination", _, _) % Some (Const ("Goal", _)) %
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    37
           _ % _ % _ %% (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1)) %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    38
      ((tg as PThm (("ProtoPure.triv_goal", _), _, _, _)) % _ %% prf2)) =
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    39
      Some (tg %> B %% (equal_elim_axm %> A %> B %%
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    40
        (symmetric_axm % None % None %% prf1) %% prf2))
bc9b5bad0e7b Additional rules for simplifying inside "Goal"
berghofe
parents: 11612
diff changeset
    41
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    42
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    43
      (PAxm ("ProtoPure.combination", _, _) % _ % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    44
        (PAxm ("ProtoPure.combination", _, _) % Some (Const ("==>", _)) % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    45
           (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %% prf2)) =
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    46
      let
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    47
        val _ $ A $ C = Envir.beta_norm X;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    48
        val _ $ B $ D = Envir.beta_norm Y
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    49
      in Some (AbsP ("H1", None, AbsP ("H2", None,
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    50
        equal_elim_axm %> C %> D %% incr_pboundvars 2 0 prf2 %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    51
          (PBound 1 %% (equal_elim_axm %> B %> A %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    52
            (symmetric_axm % None % None %% incr_pboundvars 2 0 prf1) %% PBound 0)))))
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    53
      end
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    54
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    55
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    56
      (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    57
        (PAxm ("ProtoPure.combination", _, _) % _ % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    58
          (PAxm ("ProtoPure.combination", _, _) % Some (Const ("==>", _)) % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    59
             (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf1) %% prf2))) =
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    60
      let
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    61
        val _ $ A $ C = Envir.beta_norm Y;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    62
        val _ $ B $ D = Envir.beta_norm X
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    63
      in Some (AbsP ("H1", None, AbsP ("H2", None,
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    64
        equal_elim_axm %> D %> C %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    65
          (symmetric_axm % None % None %% incr_pboundvars 2 0 prf2)
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    66
            %% (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
    67
      end
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    68
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    69
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    70
      (PAxm ("ProtoPure.combination", _, _) % Some (Const ("all", _)) % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    71
        (PAxm ("ProtoPure.reflexive", _, _) % _) %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    72
          (PAxm ("ProtoPure.abstract_rule", _, _) % _ % _ %% prf))) =
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    73
      let
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    74
        val _ $ P = Envir.beta_norm X;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    75
        val _ $ Q = Envir.beta_norm Y;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    76
      in Some (AbsP ("H", None, Abst ("x", None,
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    77
          equal_elim_axm %> incr_boundvars 1 P $ Bound 0 %> incr_boundvars 1 Q $ Bound 0 %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    78
            (incr_pboundvars 1 1 prf %> Bound 0) %% (PBound 0 %> Bound 0))))
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    79
      end
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    80
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    81
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some X % Some Y %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    82
      (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%        
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    83
        (PAxm ("ProtoPure.combination", _, _) % Some (Const ("all", _)) % _ % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    84
          (PAxm ("ProtoPure.reflexive", _, _) % _) %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    85
            (PAxm ("ProtoPure.abstract_rule", _, _) % _ % _ %% prf)))) =
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    86
      let
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    87
        val _ $ P = Envir.beta_norm X;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    88
        val _ $ Q = Envir.beta_norm Y;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    89
      in Some (AbsP ("H", None, Abst ("x", None,
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    90
        equal_elim_axm %> incr_boundvars 1 P $ Bound 0 %> incr_boundvars 1 Q $ Bound 0 %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    91
          (symmetric_axm % None % None %% (incr_pboundvars 1 1 prf %> Bound 0))
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    92
            %% (PBound 0 %> Bound 0))))
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    93
      end
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
    94
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    95
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some A % Some C %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    96
      (PAxm ("ProtoPure.transitive", _, _) % _ % Some B % _ %% prf1 %% prf2) %% prf3) =
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    97
         Some (equal_elim_axm %> B %> C %% prf2 %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    98
           (equal_elim_axm %> A %> B %% prf1 %% prf3))
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
    99
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % Some A % Some C %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   100
      (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   101
        (PAxm ("ProtoPure.transitive", _, _) % _ % Some B % _ %% prf1 %% prf2)) %% prf3) =
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   102
         Some (equal_elim_axm %> B %> C %% (symmetric_axm % None % None %% prf1) %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   103
           (equal_elim_axm %> A %> B %% (symmetric_axm % None % None %% prf2) %% prf3))
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   104
11612
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   105
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   106
      (PAxm ("ProtoPure.reflexive", _, _) % _) %% prf) = Some prf
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   107
  | rew _ (PAxm ("ProtoPure.equal_elim", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   108
      (PAxm ("ProtoPure.symmetric", _, _) % _ % _ %%
ae8450657bf0 Exchanged % and %%.
berghofe
parents: 11539
diff changeset
   109
        (PAxm ("ProtoPure.reflexive", _, _) % _)) %% prf) = Some prf
11522
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   110
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   111
  | rew _ _ = None;
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   112
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   113
val rprocs = [("Pure/meta_equality", rew)];
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   114
42fbb6abed5a Initial revision of tools for proof terms.
berghofe
parents:
diff changeset
   115
end;
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
Proofterm.add_prf_rprocs ProtoPure.thy ProofRewriteRules.rprocs;