src/HOL/Tools/rewrite_hol_proof.ML
author berghofe
Wed, 13 Nov 2002 15:28:41 +0100
changeset 13708 a3a410782c95
parent 13602 4cecd1e0f4a9
child 13916 f078a758e5d8
permissions -rw-r--r--
prove_goal' -> Goal.simple_prove_goal_cterm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Tools/rewrite_hol_proof.ML
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     2
    ID:         $Id$
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     3
    Author:     Stefan Berghofer, TU Muenchen
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     5
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     6
Rewrite rules for HOL proofs
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     7
*)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     8
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
     9
signature REWRITE_HOL_PROOF =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    10
sig
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    11
  val rews: (Proofterm.proof * Proofterm.proof) list
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    12
  val elim_cong: typ list -> Proofterm.proof -> Proofterm.proof option
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    13
end;
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    14
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    15
structure RewriteHOLProof : REWRITE_HOL_PROOF =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    16
struct
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    17
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    18
open Proofterm;
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    19
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    20
val rews = map (pairself (ProofSyntax.proof_of_term (the_context ()) Symtab.empty true) o
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    21
    Logic.dest_equals o Logic.varify o ProofSyntax.read_term (the_context ()) propT)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    22
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    23
  (** eliminate meta-equality rules **)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    24
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    25
  ["(equal_elim % x1 % x2 %% \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    26
 \    (combination % TYPE('T1) % TYPE('T2) % Trueprop % x3 % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    27
 \      (axm.reflexive % TYPE('T3) % x4) %% prf1) %% prf2) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    28
 \  (iffD1 % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    29
 \    (meta_eq_to_obj_eq % TYPE(bool) % A % B %% prf1) %% prf2)",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    30
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    31
   "(equal_elim % x1 % x2 %% (axm.symmetric % TYPE('T1) % x3 % x4 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    32
 \    (combination % TYPE('T2) % TYPE('T3) % Trueprop % x5 % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    33
 \      (axm.reflexive % TYPE('T4) % x6) %% prf1)) %% prf2) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    34
 \  (iffD2 % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    35
 \    (meta_eq_to_obj_eq % TYPE(bool) % A % B %% prf1) %% prf2)",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    36
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    37
   "(meta_eq_to_obj_eq % TYPE('U) % x1 % x2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    38
 \    (combination % TYPE('U) % TYPE('T) % f % g % x % y %% prf1 %% prf2)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    39
 \  (cong % TYPE('U) % TYPE('T) % f % g % x % y %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    40
 \    (meta_eq_to_obj_eq % TYPE('T => 'U) % f % g %% prf1) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    41
 \    (meta_eq_to_obj_eq % TYPE('T) % x % y %% prf2))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    42
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    43
   "(meta_eq_to_obj_eq % TYPE('T) % x1 % x2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    44
 \    (axm.transitive % TYPE('T) % x % y % z %% prf1 %% prf2)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    45
 \  (trans % TYPE('T) % x % y % z %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    46
 \    (meta_eq_to_obj_eq % TYPE('T) % x % y %% prf1) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    47
 \    (meta_eq_to_obj_eq % TYPE('T) % y % z %% prf2))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    48
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    49
   "(meta_eq_to_obj_eq % TYPE('T) % x % x %% (axm.reflexive % TYPE('T) % x)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    50
 \  (refl % TYPE('T) % x)",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    51
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    52
   "(meta_eq_to_obj_eq % TYPE('T) % x % y %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    53
 \    (axm.symmetric % TYPE('T) % x % y %% prf)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    54
 \  (sym % TYPE('T) % x % y %% (meta_eq_to_obj_eq % TYPE('T) % x % y %% prf))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    55
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    56
   "(meta_eq_to_obj_eq % TYPE('T => 'U) % x1 % x2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    57
 \    (abstract_rule % TYPE('U) % TYPE('T) % f % g %% prf)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    58
 \  (ext % TYPE('U) % TYPE('T) % f % g %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    59
 \    (Lam (x::'T). meta_eq_to_obj_eq % TYPE('U) % f x % g x %% (prf % x)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    60
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    61
   "(meta_eq_to_obj_eq % TYPE('T) % x % y %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    62
 \    (eq_reflection % TYPE('T) % x % y %% prf)) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    63
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    64
   "(meta_eq_to_obj_eq % TYPE('T1) % x1 % x2 %% (equal_elim % x3 % x4 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    65
 \    (combination % TYPE(prop) % TYPE('T) % x7 % x8 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    66
 \      (combination % TYPE('T3) % TYPE('T) % op == % op == % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    67
 \        (axm.reflexive % TYPE('T4) % op ==) %% prf1) %% prf2) %% prf3)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    68
 \  (iffD1 % A = C % B = D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    69
 \    (cong % TYPE(bool) % TYPE('T::type) % op = A % op = B % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    70
 \      (cong % TYPE('T=>bool) % TYPE('T) %  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    71
 \        (op = :: 'T=>'T=>bool) % (op = :: 'T=>'T=>bool) % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    72
 \        (refl % TYPE('T=>'T=>bool) % (op = :: 'T=>'T=>bool)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    73
 \        (meta_eq_to_obj_eq % TYPE('T) % A % B %% prf1)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    74
 \      (meta_eq_to_obj_eq % TYPE('T) % C % D %% prf2)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    75
 \    (meta_eq_to_obj_eq % TYPE('T) % C % D %% prf3))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    76
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    77
   "(meta_eq_to_obj_eq % TYPE('T1) % x1 % x2 %% (equal_elim % x3 % x4 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    78
 \    (axm.symmetric % TYPE('T2) % x5 % x6 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    79
 \      (combination % TYPE(prop) % TYPE('T) % x7 % x8 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    80
 \        (combination % TYPE('T3) % TYPE('T) % op == % op == % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    81
 \          (axm.reflexive % TYPE('T4) % op ==) %% prf1) %% prf2)) %% prf3)) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    82
 \  (iffD2 % A = C % B = D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    83
 \    (cong % TYPE(bool) % TYPE('T::type) % op = A % op = B % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    84
 \      (cong % TYPE('T=>bool) % TYPE('T) %  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    85
 \        (op = :: 'T=>'T=>bool) % (op = :: 'T=>'T=>bool) % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    86
 \        (refl % TYPE('T=>'T=>bool) % (op = :: 'T=>'T=>bool)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    87
 \        (meta_eq_to_obj_eq % TYPE('T) % A % B %% prf1)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    88
 \      (meta_eq_to_obj_eq % TYPE('T) % C % D %% prf2)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    89
 \    (meta_eq_to_obj_eq % TYPE('T) % C % D %% prf3))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    90
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    91
   (** rewriting on bool: insert proper congruence rules for logical connectives **)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    92
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    93
   (* All *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    94
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    95
   "(iffD1 % All P % All Q %% (cong % TYPE('T1) % TYPE('T2) % All % All % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    96
 \    (refl % TYPE('T3) % x1) %% (ext % TYPE(bool) % TYPE('a) % x2 % x3 %% prf)) %% prf') ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    97
 \  (allI % TYPE('a) % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    98
 \    (Lam x.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
    99
 \        iffD1 % P x % Q x %% (prf % x) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   100
 \         (spec % TYPE('a) % P % x %% prf')))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   101
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   102
   "(iffD2 % All P % All Q %% (cong % TYPE('T1) % TYPE('T2) % All % All % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   103
 \    (refl % TYPE('T3) % x1) %% (ext % TYPE(bool) % TYPE('a) % x2 % x3 %% prf)) %% prf') ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   104
 \  (allI % TYPE('a) % P %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   105
 \    (Lam x.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   106
 \        iffD2 % P x % Q x %% (prf % x) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   107
 \         (spec % TYPE('a) % ?Q % x %% prf')))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   108
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   109
   (* Ex *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   110
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   111
   "(iffD1 % Ex P % Ex Q %% (cong % TYPE('T1) % TYPE('T2) % Ex % Ex % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   112
 \    (refl % TYPE('T3) % x1) %% (ext % TYPE(bool) % TYPE('a) % x2 % x3 %% prf)) %% prf') ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   113
 \  (exE % TYPE('a) % P % EX x. Q x %% prf' %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   114
 \    (Lam x H : P x.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   115
 \        exI % TYPE('a) % Q % x %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   116
 \         (iffD1 % P x % Q x %% (prf % x) %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   117
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   118
   "(iffD2 % Ex P % Ex Q %% (cong % TYPE('T1) % TYPE('T2) % Ex % Ex % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   119
 \    (refl % TYPE('T3) % x1) %% (ext % TYPE(bool) % TYPE('a) % x2 % x3 %% prf)) %% prf') ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   120
 \  (exE % TYPE('a) % Q % EX x. P x %% prf' %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   121
 \    (Lam x H : Q x.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   122
 \        exI % TYPE('a) % P % x %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   123
 \         (iffD2 % P x % Q x %% (prf % x) %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   124
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   125
   (* & *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   126
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   127
   "(iffD1 % A & C % B & D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   128
 \    (cong % TYPE('T3) % TYPE('T4) % op & % op & % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   129
 \      (refl % TYPE('T5) % op &) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   130
 \  (conjI % B % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   131
 \    (iffD1 % A % B %% prf1 %% (conjunct1 % A % C %% prf3)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   132
 \    (iffD1 % C % D %% prf2 %% (conjunct2 % A % C %% prf3)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   133
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   134
   "(iffD2 % A & C % B & D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   135
 \    (cong % TYPE('T3) % TYPE('T4) % op & % op & % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   136
 \      (refl % TYPE('T5) % op &) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   137
 \  (conjI % A % C %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   138
 \    (iffD2 % A % B %% prf1 %% (conjunct1 % B % D %% prf3)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   139
 \    (iffD2 % C % D %% prf2 %% (conjunct2 % B % D %% prf3)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   140
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   141
   "(cong % TYPE(bool) % TYPE(bool) % op & A % op & A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   142
 \    (refl % TYPE(bool=>bool) % op & A)) ==  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   143
 \  (cong % TYPE(bool) % TYPE(bool) % op & A % op & A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   144
 \    (cong % TYPE(bool=>bool) % TYPE(bool) %  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   145
 \      (op & :: bool=>bool=>bool) % (op & :: bool=>bool=>bool) % A % A %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   146
 \        (refl % TYPE(bool=>bool=>bool) % (op & :: bool=>bool=>bool)) %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   147
 \        (refl % TYPE(bool) % A)))",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   148
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   149
   (* | *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   150
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   151
   "(iffD1 % A | C % B | D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   152
 \    (cong % TYPE('T3) % TYPE('T4) % op | % op | % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   153
 \      (refl % TYPE('T5) % op | ) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   154
 \  (disjE % A % C % B | D %% prf3 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   155
 \    (Lam H : A. disjI1 % B % D %% (iffD1 % A % B %% prf1 %% H)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   156
 \    (Lam H : C. disjI2 % D % B %% (iffD1 % C % D %% prf2 %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   157
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   158
   "(iffD2 % A | C % B | D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   159
 \    (cong % TYPE('T3) % TYPE('T4) % op | % op | % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   160
 \      (refl % TYPE('T5) % op | ) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   161
 \  (disjE % B % D % A | C %% prf3 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   162
 \    (Lam H : B. disjI1 % A % C %% (iffD2 % A % B %% prf1 %% H)) %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   163
 \    (Lam H : D. disjI2 % C % A %% (iffD2 % C % D %% prf2 %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   164
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   165
   "(cong % TYPE(bool) % TYPE(bool) % op | A % op | A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   166
 \    (refl % TYPE(bool=>bool) % op | A)) ==  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   167
 \  (cong % TYPE(bool) % TYPE(bool) % op | A % op | A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   168
 \    (cong % TYPE(bool=>bool) % TYPE(bool) %  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   169
 \      (op | :: bool=>bool=>bool) % (op | :: bool=>bool=>bool) % A % A %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   170
 \        (refl % TYPE(bool=>bool=>bool) % (op | :: bool=>bool=>bool)) %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   171
 \        (refl % TYPE(bool) % A)))",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   172
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   173
   (* --> *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   174
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   175
   "(iffD1 % A --> C % B --> D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   176
 \    (cong % TYPE('T3) % TYPE('T4) % op --> % op --> % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   177
 \      (refl % TYPE('T5) % op --> ) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   178
 \  (impI % B % D %% (Lam H: B. iffD1 % C % D %% prf2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   179
 \    (mp % A % C %% prf3 %% (iffD2 % A % B %% prf1 %% H))))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   180
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   181
   "(iffD2 % A --> C % B --> D %% (cong % TYPE('T1) % TYPE('T2) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   182
 \    (cong % TYPE('T3) % TYPE('T4) % op --> % op --> % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   183
 \      (refl % TYPE('T5) % op --> ) %% prf1) %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   184
 \  (impI % A % C %% (Lam H: A. iffD2 % C % D %% prf2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   185
 \    (mp % B % D %% prf3 %% (iffD1 % A % B %% prf1 %% H))))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   186
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   187
   "(cong % TYPE(bool) % TYPE(bool) % op --> A % op --> A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   188
 \    (refl % TYPE(bool=>bool) % op --> A)) ==  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   189
 \  (cong % TYPE(bool) % TYPE(bool) % op --> A % op --> A % B % C %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   190
 \    (cong % TYPE(bool=>bool) % TYPE(bool) %  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   191
 \      (op --> :: bool=>bool=>bool) % (op --> :: bool=>bool=>bool) % A % A %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   192
 \        (refl % TYPE(bool=>bool=>bool) % (op --> :: bool=>bool=>bool)) %%  \
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   193
 \        (refl % TYPE(bool) % A)))",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   194
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   195
   (* ~ *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   196
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   197
   "(iffD1 % ~ P % ~ Q %% (cong % TYPE('T1) % TYPE('T2) % Not % Not % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   198
 \    (refl % TYPE('T3) % Not) %% prf1) %% prf2) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   199
 \  (notI % Q %% (Lam H: Q.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   200
 \    notE % P % False %% prf2 %% (iffD2 % P % Q %% prf1 %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   201
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   202
   "(iffD2 % ~ P % ~ Q %% (cong % TYPE('T1) % TYPE('T2) % Not % Not % P % Q %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   203
 \    (refl % TYPE('T3) % Not) %% prf1) %% prf2) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   204
 \  (notI % P %% (Lam H: P.  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   205
 \    notE % Q % False %% prf2 %% (iffD1 % P % Q %% prf1 %% H)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   206
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   207
   (* = *)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   208
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   209
   "(iffD1 % B % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   210
 \    (iffD1 % A = C % B = D %% (cong % TYPE('T1) % TYPE(bool) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   211
 \      (cong % TYPE('T2) % TYPE(bool) % op = % op = % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   212
 \        (refl % TYPE('T3) % op =) %% prf1) %% prf2) %% prf3) %% prf4) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   213
 \  (iffD1 % C % D %% prf2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   214
 \    (iffD1 % A % C %% prf3 %% (iffD2 % A % B %% prf1 %% prf4)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   215
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   216
   "(iffD2 % B % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   217
 \    (iffD1 % A = C % B = D %% (cong % TYPE('T1) % TYPE(bool) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   218
 \      (cong % TYPE('T2) % TYPE(bool) % op = % op = % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   219
 \        (refl % TYPE('T3) % op =) %% prf1) %% prf2) %% prf3) %% prf4) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   220
 \  (iffD1 % A % B %% prf1 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   221
 \    (iffD2 % A % C %% prf3 %% (iffD2 % C % D %% prf2 %% prf4)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   222
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   223
   "(iffD1 % A % C %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   224
 \    (iffD2 % A = C % B = D %% (cong % TYPE('T1) % TYPE(bool) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   225
 \      (cong % TYPE('T2) % TYPE(bool) % op = % op = % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   226
 \        (refl % TYPE('T3) % op =) %% prf1) %% prf2) %% prf3) %% prf4)==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   227
 \  (iffD2 % C % D %% prf2 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   228
 \    (iffD1 % B % D %% prf3 %% (iffD1 % A % B %% prf1 %% prf4)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   229
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   230
   "(iffD2 % A % C %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   231
 \    (iffD2 % A = C % B = D %% (cong % TYPE('T1) % TYPE(bool) % x1 % x2 % C % D %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   232
 \      (cong % TYPE('T2) % TYPE(bool) % op = % op = % A % B %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   233
 \        (refl % TYPE('T3) % op =) %% prf1) %% prf2) %% prf3) %% prf4) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   234
 \  (iffD2 % A % B %% prf1 %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   235
 \    (iffD2 % B % D %% prf3 %% (iffD1 % C % D %% prf2 %% prf4)))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   236
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   237
   "(cong % TYPE(bool) % TYPE(bool) % op = A % op = A % B % C %%  \
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   238
 \    (refl % TYPE(bool=>bool) % op = A)) ==  \
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   239
 \  (cong % TYPE(bool) % TYPE(bool) % op = A % op = A % B % C %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   240
 \    (cong % TYPE(bool=>bool) % TYPE(bool) %  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   241
 \      (op = :: bool=>bool=>bool) % (op = :: bool=>bool=>bool) % A % A %%  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   242
 \        (refl % TYPE(bool=>bool=>bool) % (op = :: bool=>bool=>bool)) %%  \
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   243
 \        (refl % TYPE(bool) % A)))",
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   244
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   245
   "(iffD1 % A % C %% (trans % TYPE(bool) % A % B % C %% prf1 %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   246
 \  (iffD1 % B % C %% prf2 %% (iffD1 % A % B %% prf1 %% prf3))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   247
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   248
   "(iffD2 % A % C %% (trans % TYPE(bool) % A % B % C %% prf1 %% prf2) %% prf3) ==  \
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   249
 \  (iffD2 % A % B %% prf1 %% (iffD2 % B % C %% prf2 %% prf3))",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   250
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   251
   "(iffD1 % A % A %% (refl % TYPE(bool) % A) %% prf) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   252
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   253
   "(iffD2 % A % A %% (refl % TYPE(bool) % A) %% prf) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   254
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   255
   "(iffD1 % A % B %% (sym % TYPE(bool) % B % A %% prf)) == (iffD2 % B % A %% prf)",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   256
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   257
   "(iffD2 % A % B %% (sym % TYPE(bool) % B % A %% prf)) == (iffD1 % B % A %% prf)",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   258
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   259
   (** normalization of HOL proofs **)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   260
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   261
   "(mp % A % B %% (impI % A % B %% prf)) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   262
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   263
   "(impI % A % B %% (mp % A % B %% prf)) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   264
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   265
   "(spec % TYPE('a) % P % x %% (allI % TYPE('a) % P %% prf)) == prf % x",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   266
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   267
   "(allI % TYPE('a) % P %% (Lam x::'a. spec % TYPE('a) % P % x %% prf)) == prf",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   268
13602
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   269
   "(exE % TYPE('a) % P % Q %% (exI % TYPE('a) % P % x %% prf1) %% prf2) == (prf2 % x %% prf1)",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   270
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   271
   "(exE % TYPE('a) % P % Q %% prf %% (exI % TYPE('a) % P)) == prf",
4cecd1e0f4a9 - additional congruence rules for boolean operators
berghofe
parents: 13404
diff changeset
   272
13404
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   273
   "(disjE % P % Q % R %% (disjI1 % P % Q %% prf1) %% prf2 %% prf3) == (prf2 %% prf1)",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   274
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   275
   "(disjE % P % Q % R %% (disjI2 % Q % P %% prf1) %% prf2 %% prf3) == (prf3 %% prf1)",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   276
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   277
   "(conjunct1 % P % Q %% (conjI % P % Q %% prf1 %% prf2)) == prf1",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   278
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   279
   "(conjunct2 % P % Q %% (conjI % P % Q %% prf1 %% prf2)) == prf2",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   280
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   281
   "(iffD1 % A % B %% (iffI % A % B %% prf1 %% prf2)) == prf1",
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   282
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   283
   "(iffD2 % A % B %% (iffI % A % B %% prf1 %% prf2)) == prf2"];
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   284
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   285
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   286
(** Replace congruence rules by substitution rules **)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   287
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   288
fun strip_cong ps (PThm (("HOL.cong", _), _, _, _) % _ % _ % Some x % Some y %%
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   289
      prf1 %% prf2) = strip_cong (((x, y), prf2) :: ps) prf1
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   290
  | strip_cong ps (PThm (("HOL.refl", _), _, _, _) % Some f) = Some (f, ps)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   291
  | strip_cong _ _ = None;
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   292
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   293
val subst_prf = fst (strip_combt (#2 (#der (rep_thm subst))));
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   294
val sym_prf = fst (strip_combt (#2 (#der (rep_thm sym))));
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   295
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   296
fun make_subst Ts prf xs (_, []) = prf
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   297
  | make_subst Ts prf xs (f, ((x, y), prf') :: ps) =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   298
      let val T = fastype_of1 (Ts, x)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   299
      in if x aconv y then make_subst Ts prf (xs @ [x]) (f, ps)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   300
        else change_type (Some [T]) subst_prf %> x %> y %>
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   301
          Abs ("z", T, list_comb (incr_boundvars 1 f,
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   302
            map (incr_boundvars 1) xs @ Bound 0 ::
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   303
            map (incr_boundvars 1 o snd o fst) ps)) %% prf' %%
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   304
          make_subst Ts prf (xs @ [x]) (f, ps)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   305
      end;
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   306
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   307
fun make_sym Ts ((x, y), prf) =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   308
  ((y, x), change_type (Some [fastype_of1 (Ts, x)]) sym_prf %> x %> y %% prf);
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   309
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   310
fun elim_cong Ts (PThm (("HOL.iffD1", _), _, _, _) % _ % _ %% prf1 %% prf2) =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   311
      apsome (make_subst Ts prf2 []) (strip_cong [] prf1)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   312
  | elim_cong Ts (PThm (("HOL.iffD2", _), _, _, _) % _ % _ %% prf1 %% prf2) =
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   313
      apsome (make_subst Ts prf2 [] o
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   314
        apsnd (map (make_sym Ts))) (strip_cong [] prf1)
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   315
  | elim_cong _ _ = None;
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   316
eeac2bbfe958 Rules for rewriting HOL proofs.
berghofe
parents:
diff changeset
   317
end;