src/Sequents/LK.thy
author paulson <lp15@cam.ac.uk>
Mon Jun 11 14:34:17 2018 +0100 (14 months ago)
changeset 68424 02e5a44ffe7d
parent 63530 045490f55f69
child 69593 3dda49e08b9d
permissions -rw-r--r--
the last of the infinite product proofs
wenzelm@41959
     1
(*  Title:      Sequents/LK.thy
paulson@2073
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2073
     3
    Copyright   1993  University of Cambridge
paulson@2073
     4
paulson@7094
     5
Axiom to express monotonicity (a variant of the deduction theorem).  Makes the
wenzelm@61386
     6
link between \<turnstile> and \<Longrightarrow>, needed for instance to prove imp_cong.
paulson@2073
     7
paulson@7117
     8
Axiom left_cong allows the simplifier to use left-side formulas.  Ideally it
paulson@7117
     9
should be derived from lower-level axioms.
paulson@7117
    10
paulson@7094
    11
CANNOT be added to LK0.thy because modal logic is built upon it, and
paulson@7094
    12
various modal rules would become inconsistent.
paulson@2073
    13
*)
paulson@2073
    14
wenzelm@17481
    15
theory LK
wenzelm@17481
    16
imports LK0
wenzelm@17481
    17
begin
paulson@2073
    18
wenzelm@27149
    19
axiomatization where
wenzelm@61386
    20
  monotonic:  "($H \<turnstile> P \<Longrightarrow> $H \<turnstile> Q) \<Longrightarrow> $H, P \<turnstile> Q" and
paulson@2073
    21
wenzelm@61386
    22
  left_cong:  "\<lbrakk>P == P';  \<turnstile> P' \<Longrightarrow> ($H \<turnstile> $F) \<equiv> ($H' \<turnstile> $F')\<rbrakk>
wenzelm@61386
    23
               \<Longrightarrow> (P, $H \<turnstile> $F) \<equiv> (P', $H' \<turnstile> $F')"
paulson@2073
    24
wenzelm@27149
    25
wenzelm@60770
    26
subsection \<open>Rewrite rules\<close>
wenzelm@27149
    27
wenzelm@27149
    28
lemma conj_simps:
wenzelm@61386
    29
  "\<turnstile> P \<and> True \<longleftrightarrow> P"
wenzelm@61386
    30
  "\<turnstile> True \<and> P \<longleftrightarrow> P"
wenzelm@61386
    31
  "\<turnstile> P \<and> False \<longleftrightarrow> False"
wenzelm@61386
    32
  "\<turnstile> False \<and> P \<longleftrightarrow> False"
wenzelm@61386
    33
  "\<turnstile> P \<and> P \<longleftrightarrow> P"
wenzelm@61386
    34
  "\<turnstile> P \<and> P \<and> Q \<longleftrightarrow> P \<and> Q"
wenzelm@61386
    35
  "\<turnstile> P \<and> \<not> P \<longleftrightarrow> False"
wenzelm@61386
    36
  "\<turnstile> \<not> P \<and> P \<longleftrightarrow> False"
wenzelm@61386
    37
  "\<turnstile> (P \<and> Q) \<and> R \<longleftrightarrow> P \<and> (Q \<and> R)"
wenzelm@55228
    38
  by (fast add!: subst)+
wenzelm@27149
    39
wenzelm@27149
    40
lemma disj_simps:
wenzelm@61386
    41
  "\<turnstile> P \<or> True \<longleftrightarrow> True"
wenzelm@61386
    42
  "\<turnstile> True \<or> P \<longleftrightarrow> True"
wenzelm@61386
    43
  "\<turnstile> P \<or> False \<longleftrightarrow> P"
wenzelm@61386
    44
  "\<turnstile> False \<or> P \<longleftrightarrow> P"
wenzelm@61386
    45
  "\<turnstile> P \<or> P \<longleftrightarrow> P"
wenzelm@61386
    46
  "\<turnstile> P \<or> P \<or> Q \<longleftrightarrow> P \<or> Q"
wenzelm@61386
    47
  "\<turnstile> (P \<or> Q) \<or> R \<longleftrightarrow> P \<or> (Q \<or> R)"
wenzelm@55228
    48
  by (fast add!: subst)+
wenzelm@27149
    49
wenzelm@27149
    50
lemma not_simps:
wenzelm@61386
    51
  "\<turnstile> \<not> False \<longleftrightarrow> True"
wenzelm@61386
    52
  "\<turnstile> \<not> True \<longleftrightarrow> False"
wenzelm@55228
    53
  by (fast add!: subst)+
wenzelm@27149
    54
wenzelm@27149
    55
lemma imp_simps:
wenzelm@61386
    56
  "\<turnstile> (P \<longrightarrow> False) \<longleftrightarrow> \<not> P"
wenzelm@61386
    57
  "\<turnstile> (P \<longrightarrow> True) \<longleftrightarrow> True"
wenzelm@61386
    58
  "\<turnstile> (False \<longrightarrow> P) \<longleftrightarrow> True"
wenzelm@61386
    59
  "\<turnstile> (True \<longrightarrow> P) \<longleftrightarrow> P"
wenzelm@61386
    60
  "\<turnstile> (P \<longrightarrow> P) \<longleftrightarrow> True"
wenzelm@61386
    61
  "\<turnstile> (P \<longrightarrow> \<not> P) \<longleftrightarrow> \<not> P"
wenzelm@55228
    62
  by (fast add!: subst)+
wenzelm@27149
    63
wenzelm@27149
    64
lemma iff_simps:
wenzelm@61386
    65
  "\<turnstile> (True \<longleftrightarrow> P) \<longleftrightarrow> P"
wenzelm@61386
    66
  "\<turnstile> (P \<longleftrightarrow> True) \<longleftrightarrow> P"
wenzelm@61386
    67
  "\<turnstile> (P \<longleftrightarrow> P) \<longleftrightarrow> True"
wenzelm@61386
    68
  "\<turnstile> (False \<longleftrightarrow> P) \<longleftrightarrow> \<not> P"
wenzelm@61386
    69
  "\<turnstile> (P \<longleftrightarrow> False) \<longleftrightarrow> \<not> P"
wenzelm@55228
    70
  by (fast add!: subst)+
wenzelm@27149
    71
wenzelm@27149
    72
lemma quant_simps:
wenzelm@61386
    73
  "\<And>P. \<turnstile> (\<forall>x. P) \<longleftrightarrow> P"
wenzelm@61386
    74
  "\<And>P. \<turnstile> (\<forall>x. x = t \<longrightarrow> P(x)) \<longleftrightarrow> P(t)"
wenzelm@61386
    75
  "\<And>P. \<turnstile> (\<forall>x. t = x \<longrightarrow> P(x)) \<longleftrightarrow> P(t)"
wenzelm@61386
    76
  "\<And>P. \<turnstile> (\<exists>x. P) \<longleftrightarrow> P"
wenzelm@61386
    77
  "\<And>P. \<turnstile> (\<exists>x. x = t \<and> P(x)) \<longleftrightarrow> P(t)"
wenzelm@61386
    78
  "\<And>P. \<turnstile> (\<exists>x. t = x \<and> P(x)) \<longleftrightarrow> P(t)"
wenzelm@55228
    79
  by (fast add!: subst)+
wenzelm@27149
    80
wenzelm@27149
    81
wenzelm@60770
    82
subsection \<open>Miniscoping: pushing quantifiers in\<close>
wenzelm@27149
    83
wenzelm@60770
    84
text \<open>
wenzelm@61385
    85
  We do NOT distribute of \<forall> over \<and>, or dually that of \<exists> over \<or>
wenzelm@27149
    86
  Baaz and Leitsch, On Skolemization and Proof Complexity (1994)
wenzelm@27149
    87
  show that this step can increase proof length!
wenzelm@60770
    88
\<close>
wenzelm@27149
    89
wenzelm@60770
    90
text \<open>existential miniscoping\<close>
wenzelm@27149
    91
lemma ex_simps:
wenzelm@61386
    92
  "\<And>P Q. \<turnstile> (\<exists>x. P(x) \<and> Q) \<longleftrightarrow> (\<exists>x. P(x)) \<and> Q"
wenzelm@61386
    93
  "\<And>P Q. \<turnstile> (\<exists>x. P \<and> Q(x)) \<longleftrightarrow> P \<and> (\<exists>x. Q(x))"
wenzelm@61386
    94
  "\<And>P Q. \<turnstile> (\<exists>x. P(x) \<or> Q) \<longleftrightarrow> (\<exists>x. P(x)) \<or> Q"
wenzelm@61386
    95
  "\<And>P Q. \<turnstile> (\<exists>x. P \<or> Q(x)) \<longleftrightarrow> P \<or> (\<exists>x. Q(x))"
wenzelm@61386
    96
  "\<And>P Q. \<turnstile> (\<exists>x. P(x) \<longrightarrow> Q) \<longleftrightarrow> (\<forall>x. P(x)) \<longrightarrow> Q"
wenzelm@61386
    97
  "\<And>P Q. \<turnstile> (\<exists>x. P \<longrightarrow> Q(x)) \<longleftrightarrow> P \<longrightarrow> (\<exists>x. Q(x))"
wenzelm@55228
    98
  by (fast add!: subst)+
wenzelm@27149
    99
wenzelm@60770
   100
text \<open>universal miniscoping\<close>
wenzelm@27149
   101
lemma all_simps:
wenzelm@61386
   102
  "\<And>P Q. \<turnstile> (\<forall>x. P(x) \<and> Q) \<longleftrightarrow> (\<forall>x. P(x)) \<and> Q"
wenzelm@61386
   103
  "\<And>P Q. \<turnstile> (\<forall>x. P \<and> Q(x)) \<longleftrightarrow> P \<and> (\<forall>x. Q(x))"
wenzelm@61386
   104
  "\<And>P Q. \<turnstile> (\<forall>x. P(x) \<longrightarrow> Q) \<longleftrightarrow> (\<exists>x. P(x)) \<longrightarrow> Q"
wenzelm@61386
   105
  "\<And>P Q. \<turnstile> (\<forall>x. P \<longrightarrow> Q(x)) \<longleftrightarrow> P \<longrightarrow> (\<forall>x. Q(x))"
wenzelm@61386
   106
  "\<And>P Q. \<turnstile> (\<forall>x. P(x) \<or> Q) \<longleftrightarrow> (\<forall>x. P(x)) \<or> Q"
wenzelm@61386
   107
  "\<And>P Q. \<turnstile> (\<forall>x. P \<or> Q(x)) \<longleftrightarrow> P \<or> (\<forall>x. Q(x))"
wenzelm@55228
   108
  by (fast add!: subst)+
wenzelm@27149
   109
wenzelm@60770
   110
text \<open>These are NOT supplied by default!\<close>
wenzelm@27149
   111
lemma distrib_simps:
wenzelm@61386
   112
  "\<turnstile> P \<and> (Q \<or> R) \<longleftrightarrow> P \<and> Q \<or> P \<and> R"
wenzelm@61386
   113
  "\<turnstile> (Q \<or> R) \<and> P \<longleftrightarrow> Q \<and> P \<or> R \<and> P"
wenzelm@61386
   114
  "\<turnstile> (P \<or> Q \<longrightarrow> R) \<longleftrightarrow> (P \<longrightarrow> R) \<and> (Q \<longrightarrow> R)"
wenzelm@55228
   115
  by (fast add!: subst)+
wenzelm@27149
   116
wenzelm@61386
   117
lemma P_iff_F: "\<turnstile> \<not> P \<Longrightarrow> \<turnstile> (P \<longleftrightarrow> False)"
wenzelm@27149
   118
  apply (erule thinR [THEN cut])
wenzelm@55228
   119
  apply fast
wenzelm@27149
   120
  done
wenzelm@27149
   121
wenzelm@45602
   122
lemmas iff_reflection_F = P_iff_F [THEN iff_reflection]
wenzelm@27149
   123
wenzelm@61386
   124
lemma P_iff_T: "\<turnstile> P \<Longrightarrow> \<turnstile> (P \<longleftrightarrow> True)"
wenzelm@27149
   125
  apply (erule thinR [THEN cut])
wenzelm@55228
   126
  apply fast
wenzelm@27149
   127
  done
wenzelm@27149
   128
wenzelm@45602
   129
lemmas iff_reflection_T = P_iff_T [THEN iff_reflection]
wenzelm@27149
   130
wenzelm@27149
   131
wenzelm@27149
   132
lemma LK_extra_simps:
wenzelm@61386
   133
  "\<turnstile> P \<or> \<not> P"
wenzelm@61386
   134
  "\<turnstile> \<not> P \<or> P"
wenzelm@61386
   135
  "\<turnstile> \<not> \<not> P \<longleftrightarrow> P"
wenzelm@61386
   136
  "\<turnstile> (\<not> P \<longrightarrow> P) \<longleftrightarrow> P"
wenzelm@61386
   137
  "\<turnstile> (\<not> P \<longleftrightarrow> \<not> Q) \<longleftrightarrow> (P \<longleftrightarrow> Q)"
wenzelm@55228
   138
  by (fast add!: subst)+
wenzelm@27149
   139
wenzelm@27149
   140
wenzelm@60770
   141
subsection \<open>Named rewrite rules\<close>
wenzelm@27149
   142
wenzelm@61386
   143
lemma conj_commute: "\<turnstile> P \<and> Q \<longleftrightarrow> Q \<and> P"
wenzelm@61386
   144
  and conj_left_commute: "\<turnstile> P \<and> (Q \<and> R) \<longleftrightarrow> Q \<and> (P \<and> R)"
wenzelm@55228
   145
  by (fast add!: subst)+
wenzelm@27149
   146
wenzelm@27149
   147
lemmas conj_comms = conj_commute conj_left_commute
wenzelm@27149
   148
wenzelm@61386
   149
lemma disj_commute: "\<turnstile> P \<or> Q \<longleftrightarrow> Q \<or> P"
wenzelm@61386
   150
  and disj_left_commute: "\<turnstile> P \<or> (Q \<or> R) \<longleftrightarrow> Q \<or> (P \<or> R)"
wenzelm@55228
   151
  by (fast add!: subst)+
wenzelm@27149
   152
wenzelm@27149
   153
lemmas disj_comms = disj_commute disj_left_commute
wenzelm@27149
   154
wenzelm@61386
   155
lemma conj_disj_distribL: "\<turnstile> P \<and> (Q \<or> R) \<longleftrightarrow> (P \<and> Q \<or> P \<and> R)"
wenzelm@61386
   156
  and conj_disj_distribR: "\<turnstile> (P \<or> Q) \<and> R \<longleftrightarrow> (P \<and> R \<or> Q \<and> R)"
wenzelm@27149
   157
wenzelm@61386
   158
  and disj_conj_distribL: "\<turnstile> P \<or> (Q \<and> R) \<longleftrightarrow> (P \<or> Q) \<and> (P \<or> R)"
wenzelm@61386
   159
  and disj_conj_distribR: "\<turnstile> (P \<and> Q) \<or> R \<longleftrightarrow> (P \<or> R) \<and> (Q \<or> R)"
wenzelm@27149
   160
wenzelm@61386
   161
  and imp_conj_distrib: "\<turnstile> (P \<longrightarrow> (Q \<and> R)) \<longleftrightarrow> (P \<longrightarrow> Q) \<and> (P \<longrightarrow> R)"
wenzelm@61386
   162
  and imp_conj: "\<turnstile> ((P \<and> Q) \<longrightarrow> R)  \<longleftrightarrow> (P \<longrightarrow> (Q \<longrightarrow> R))"
wenzelm@61386
   163
  and imp_disj: "\<turnstile> (P \<or> Q \<longrightarrow> R)  \<longleftrightarrow> (P \<longrightarrow> R) \<and> (Q \<longrightarrow> R)"
wenzelm@27149
   164
wenzelm@61386
   165
  and imp_disj1: "\<turnstile> (P \<longrightarrow> Q) \<or> R \<longleftrightarrow> (P \<longrightarrow> Q \<or> R)"
wenzelm@61386
   166
  and imp_disj2: "\<turnstile> Q \<or> (P \<longrightarrow> R) \<longleftrightarrow> (P \<longrightarrow> Q \<or> R)"
wenzelm@27149
   167
wenzelm@61386
   168
  and de_Morgan_disj: "\<turnstile> (\<not> (P \<or> Q)) \<longleftrightarrow> (\<not> P \<and> \<not> Q)"
wenzelm@61386
   169
  and de_Morgan_conj: "\<turnstile> (\<not> (P \<and> Q)) \<longleftrightarrow> (\<not> P \<or> \<not> Q)"
wenzelm@27149
   170
wenzelm@61386
   171
  and not_iff: "\<turnstile> \<not> (P \<longleftrightarrow> Q) \<longleftrightarrow> (P \<longleftrightarrow> \<not> Q)"
wenzelm@55228
   172
  by (fast add!: subst)+
wenzelm@27149
   173
wenzelm@27149
   174
lemma imp_cong:
wenzelm@61386
   175
  assumes p1: "\<turnstile> P \<longleftrightarrow> P'"
wenzelm@61386
   176
    and p2: "\<turnstile> P' \<Longrightarrow> \<turnstile> Q \<longleftrightarrow> Q'"
wenzelm@61386
   177
  shows "\<turnstile> (P \<longrightarrow> Q) \<longleftrightarrow> (P' \<longrightarrow> Q')"
wenzelm@55233
   178
  apply (lem p1)
wenzelm@55228
   179
  apply safe
wenzelm@60770
   180
   apply (tactic \<open>
wenzelm@60754
   181
     REPEAT (resolve_tac @{context} @{thms cut} 1 THEN
wenzelm@27149
   182
       DEPTH_SOLVE_1
wenzelm@59498
   183
         (resolve_tac @{context} [@{thm thinL}, @{thm thinR}, @{thm p2} COMP @{thm monotonic}] 1) THEN
wenzelm@60770
   184
           Cla.safe_tac @{context} 1)\<close>)
wenzelm@27149
   185
  done
wenzelm@27149
   186
wenzelm@27149
   187
lemma conj_cong:
wenzelm@61386
   188
  assumes p1: "\<turnstile> P \<longleftrightarrow> P'"
wenzelm@61386
   189
    and p2: "\<turnstile> P' \<Longrightarrow> \<turnstile> Q \<longleftrightarrow> Q'"
wenzelm@61386
   190
  shows "\<turnstile> (P \<and> Q) \<longleftrightarrow> (P' \<and> Q')"
wenzelm@55233
   191
  apply (lem p1)
wenzelm@55228
   192
  apply safe
wenzelm@60770
   193
   apply (tactic \<open>
wenzelm@60754
   194
     REPEAT (resolve_tac @{context} @{thms cut} 1 THEN
wenzelm@27149
   195
       DEPTH_SOLVE_1
wenzelm@59498
   196
         (resolve_tac @{context} [@{thm thinL}, @{thm thinR}, @{thm p2} COMP @{thm monotonic}] 1) THEN
wenzelm@60770
   197
           Cla.safe_tac @{context} 1)\<close>)
wenzelm@27149
   198
  done
wenzelm@27149
   199
wenzelm@61386
   200
lemma eq_sym_conv: "\<turnstile> x = y \<longleftrightarrow> y = x"
wenzelm@55228
   201
  by (fast add!: subst)
wenzelm@27149
   202
wenzelm@48891
   203
ML_file "simpdata.ML"
wenzelm@60770
   204
setup \<open>map_theory_simpset (put_simpset LK_ss)\<close>
wenzelm@60770
   205
setup \<open>Simplifier.method_setup []\<close>
wenzelm@17481
   206
wenzelm@27149
   207
wenzelm@63530
   208
text \<open>To create substitution rules\<close>
wenzelm@27149
   209
wenzelm@61386
   210
lemma eq_imp_subst: "\<turnstile> a = b \<Longrightarrow> $H, A(a), $G \<turnstile> $E, A(b), $F"
wenzelm@55230
   211
  by simp
wenzelm@27149
   212
wenzelm@61386
   213
lemma split_if: "\<turnstile> P(if Q then x else y) \<longleftrightarrow> ((Q \<longrightarrow> P(x)) \<and> (\<not> Q \<longrightarrow> P(y)))"
wenzelm@27149
   214
  apply (rule_tac P = Q in cut)
wenzelm@55230
   215
   prefer 2
wenzelm@55230
   216
   apply (simp add: if_P)
wenzelm@61385
   217
  apply (rule_tac P = "\<not> Q" in cut)
wenzelm@55230
   218
   prefer 2
wenzelm@55230
   219
   apply (simp add: if_not_P)
wenzelm@55228
   220
  apply fast
wenzelm@27149
   221
  done
wenzelm@27149
   222
wenzelm@61386
   223
lemma if_cancel: "\<turnstile> (if P then x else x) = x"
wenzelm@55233
   224
  apply (lem split_if)
wenzelm@55228
   225
  apply fast
wenzelm@27149
   226
  done
wenzelm@27149
   227
wenzelm@61386
   228
lemma if_eq_cancel: "\<turnstile> (if x = y then y else x) = x"
wenzelm@55233
   229
  apply (lem split_if)
wenzelm@55228
   230
  apply safe
wenzelm@27149
   231
  apply (rule symL)
wenzelm@27149
   232
  apply (rule basic)
wenzelm@27149
   233
  done
wenzelm@27149
   234
paulson@2073
   235
end