src/ZF/ex/PropLog.ML
author wenzelm
Tue, 20 Oct 1998 16:26:20 +0200
changeset 5686 1f053d05f571
parent 5618 721671c68324
child 6046 2c8a8be36c94
permissions -rw-r--r--
Symtab.foldl;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     1
(*  Title:      ZF/ex/prop-log.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     3
    Author:     Tobias Nipkow & Lawrence C Paulson
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
     6
Inductive definition of propositional logic.
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
Soundness and completeness w.r.t. truth-tables.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
Prove: If H|=p then G|=p where G:Fin(H)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
open PropLog;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
(*** prop_rec -- by Vset recursion ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
(** conversion rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    18
Goal "prop_rec(Fls,b,c,d) = b";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
by (rtac (prop_rec_def RS def_Vrec RS trans) 1);
5618
paulson
parents: 5325
diff changeset
    20
by (simp_tac (simpset() addsimps prop.con_defs) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    21
qed "prop_rec_Fls";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    23
Goal "prop_rec(#v,b,c,d) = c(v)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
by (rtac (prop_rec_def RS def_Vrec RS trans) 1);
5618
paulson
parents: 5325
diff changeset
    25
by (simp_tac (simpset() addsimps prop.con_defs) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    26
qed "prop_rec_Var";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    28
Goal "prop_rec(p=>q,b,c,d) = \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
\      d(p, q, prop_rec(p,b,c,d), prop_rec(q,b,c,d))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
by (rtac (prop_rec_def RS def_Vrec RS trans) 1);
5618
paulson
parents: 5325
diff changeset
    31
by (simp_tac (rank_ss addsimps prop.con_defs) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    32
qed "prop_rec_Imp";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    34
Addsimps [prop_rec_Fls, prop_rec_Var, prop_rec_Imp];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
(*** Semantics of propositional logic ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
(** The function is_true **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    40
Goalw [is_true_def] "is_true(Fls,t) <-> False";
5618
paulson
parents: 5325
diff changeset
    41
by (Simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    42
qed "is_true_Fls";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    44
Goalw [is_true_def] "is_true(#v,t) <-> v:t";
5618
paulson
parents: 5325
diff changeset
    45
by (Simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    46
qed "is_true_Var";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
5618
paulson
parents: 5325
diff changeset
    48
Goalw [is_true_def] "is_true(p=>q,t) <-> (is_true(p,t)-->is_true(q,t))";
paulson
parents: 5325
diff changeset
    49
by (Simp_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    50
qed "is_true_Imp";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
(** The function hyps **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    54
Goalw [hyps_def] "hyps(Fls,t) = 0";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    55
by (Simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    56
qed "hyps_Fls";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    58
Goalw [hyps_def] "hyps(#v,t) = {if(v:t, #v, #v=>Fls)}";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    59
by (Simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    60
qed "hyps_Var";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
    62
Goalw [hyps_def] "hyps(p=>q,t) = hyps(p,t) Un hyps(q,t)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    63
by (Simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    64
qed "hyps_Imp";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    66
Addsimps prop.intrs;
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    67
Addsimps [is_true_Fls, is_true_Var, is_true_Imp,
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    68
	  hyps_Fls, hyps_Var, hyps_Imp];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*** Proof theory of propositional logic ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
    72
Goalw thms.defs "G<=H ==> thms(G) <= thms(H)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
by (rtac lfp_mono 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    74
by (REPEAT (rtac thms.bnd_mono 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
by (REPEAT (ares_tac (univ_mono::basic_monos) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    76
qed "thms_mono";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    78
val thms_in_pl = thms.dom_subset RS subsetD;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    80
val ImpE = prop.mk_cases prop.con_defs "p=>q : prop";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    82
(*Stronger Modus Ponens rule: no typechecking!*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
    83
Goal "[| H |- p=>q;  H |- p |] ==> H |- q";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    84
by (rtac thms.MP 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
by (REPEAT (eresolve_tac [asm_rl, thms_in_pl, thms_in_pl RS ImpE] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    86
qed "thms_MP";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
(*Rule is called I for Identity Combinator, not for Introduction*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
    89
Goal "p:prop ==> H |- p=>p";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    90
by (rtac (thms.S RS thms_MP RS thms_MP) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    91
by (rtac thms.K 5);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    92
by (rtac thms.K 4);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
    93
by (REPEAT (ares_tac prop.intrs 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    94
qed "thms_I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
(** Weakening, left and right **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
(* [| G<=H;  G|-p |] ==> H|-p   Order of premises is convenient with RS*)
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    99
bind_thm ("weaken_left", (thms_mono RS subsetD));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
(* H |- p ==> cons(a,H) |- p *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
val weaken_left_cons = subset_consI RS weaken_left;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
val weaken_left_Un1  = Un_upper1 RS weaken_left;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
val weaken_left_Un2  = Un_upper2 RS weaken_left;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   107
Goal "[| H |- q;  p:prop |] ==> H |- p=>q";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   108
by (rtac (thms.K RS thms_MP) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
by (REPEAT (ares_tac [thms_in_pl] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   110
qed "weaken_right";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
(*The deduction theorem*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   113
Goal "[| cons(p,H) |- q;  p:prop |] ==>  H |- p=>q";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   114
by (etac thms.induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   115
by (fast_tac (claset() addIs [thms_I, thms.H RS weaken_right]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   116
by (fast_tac (claset() addIs [thms.K RS weaken_right]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   117
by (fast_tac (claset() addIs [thms.S RS weaken_right]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   118
by (fast_tac (claset() addIs [thms.DN RS weaken_right]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   119
by (fast_tac (claset() addIs [thms.S RS thms_MP RS thms_MP]) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   120
qed "deduction";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
(*The cut rule*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   124
Goal "[| H|-p;  cons(p,H) |- q |] ==>  H |- q";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
by (rtac (deduction RS thms_MP) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
by (REPEAT (ares_tac [thms_in_pl] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   127
qed "cut";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   129
Goal "[| H |- Fls; p:prop |] ==> H |- p";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   130
by (rtac (thms.DN RS thms_MP) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
by (rtac weaken_right 2);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   132
by (REPEAT (ares_tac (prop.intrs@[consI1]) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   133
qed "thms_FlsE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
(* [| H |- p=>Fls;  H |- p;  q: prop |] ==> H |- q *)
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   136
bind_thm ("thms_notE", (thms_MP RS thms_FlsE));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
(*Soundness of the rules wrt truth-table semantics*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   139
Goalw [logcon_def] "H |- p ==> H |= p";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   140
by (etac thms.induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   141
by (fast_tac (claset() addSDs [is_true_Imp RS iffD1 RS mp]) 5);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   142
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   143
qed "soundness";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
(*** Towards the completeness proof ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   147
val [premf,premq] = goal PropLog.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
    "[| H |- p=>Fls; q: prop |] ==> H |- p=>q";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
by (rtac (premf RS thms_in_pl RS ImpE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
by (rtac deduction 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
by (rtac (premf RS weaken_left_cons RS thms_notE) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   152
by (REPEAT (ares_tac [premq, consI1, thms.H] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   153
qed "Fls_Imp";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   155
val [premp,premq] = goal PropLog.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
    "[| H |- p;  H |- q=>Fls |] ==> H |- (p=>q)=>Fls";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
by (cut_facts_tac ([premp,premq] RL [thms_in_pl]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
by (etac ImpE 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
by (rtac deduction 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
by (rtac (premq RS weaken_left_cons RS thms_MP) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   161
by (rtac (consI1 RS thms.H RS thms_MP) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
by (rtac (premp RS weaken_left_cons) 2);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   163
by (REPEAT (ares_tac prop.intrs 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   164
qed "Imp_Fls";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
(*Typical example of strengthening the induction formula*)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   167
Goal "p: prop ==> hyps(p,t) |- if(is_true(p,t), p, p=>Fls)";
5116
8eb343ab5748 Renamed expand_if to split_if and setloop split_tac to addsplits,
paulson
parents: 5068
diff changeset
   168
by (rtac (split_if RS iffD2) 1);
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   169
by (etac prop.induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   170
by (ALLGOALS (asm_simp_tac (simpset() addsimps [thms_I, thms.H])));
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   171
by (safe_tac (claset() addSEs [Fls_Imp RS weaken_left_Un1, 
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   172
			       Fls_Imp RS weaken_left_Un2]));
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   173
by (ALLGOALS (fast_tac (claset() addIs [weaken_left_Un1, weaken_left_Un2, 
5618
paulson
parents: 5325
diff changeset
   174
					weaken_right, Imp_Fls])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   175
qed "hyps_thms_if";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
(*Key lemma for completeness; yields a set of assumptions satisfying p*)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   178
Goalw [logcon_def] "[| p: prop;  0 |= p |] ==> hyps(p,t) |- p";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   179
by (dtac hyps_thms_if 1);
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   180
by (Asm_full_simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   181
qed "logcon_thms_p";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
(*For proving certain theorems in our new propositional logic*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
val thms_cs = 
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   185
    ZF_cs addSIs (prop.intrs @ [deduction])
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   186
          addIs [thms_in_pl, thms.H, thms.H RS thms_MP];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
(*The excluded middle in the form of an elimination rule*)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   189
Goal "[| p: prop;  q: prop |] ==> H |- (p=>q) => ((p=>Fls)=>q) => q";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
by (rtac (deduction RS deduction) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   191
by (rtac (thms.DN RS thms_MP) 1);
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   192
by (ALLGOALS (blast_tac thms_cs));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   193
qed "thms_excluded_middle";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
(*Hard to prove directly because it requires cuts*)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   196
Goal "[| cons(p,H) |- q;  cons(p=>Fls,H) |- q;  p: prop |] ==> H |- q";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
by (rtac (thms_excluded_middle RS thms_MP RS thms_MP) 1);
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   198
by (REPEAT (ares_tac (prop.intrs@[deduction,thms_in_pl]) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   199
qed "thms_excluded_middle_rule";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
(*** Completeness -- lemmas for reducing the set of assumptions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
(*For the case hyps(p,t)-cons(#v,Y) |- p;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
  we also have hyps(p,t)-{#v} <= hyps(p, t-{v}) *)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   205
Goal "p: prop ==> hyps(p, t-{v}) <= cons(#v=>Fls, hyps(p,t)-{#v})";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   206
by (etac prop.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   207
by (Simp_tac 1);
5618
paulson
parents: 5325
diff changeset
   208
by (Asm_simp_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   209
by (fast_tac (claset() addSEs prop.free_SEs) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   210
by (Asm_simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   211
by (Fast_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   212
qed "hyps_Diff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
(*For the case hyps(p,t)-cons(#v => Fls,Y) |- p;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
  we also have hyps(p,t)-{#v=>Fls} <= hyps(p, cons(v,t)) *)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   216
Goal "p: prop ==> hyps(p, cons(v,t)) <= cons(#v, hyps(p,t)-{#v=>Fls})";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   217
by (etac prop.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   218
by (Simp_tac 1);
5618
paulson
parents: 5325
diff changeset
   219
by (Asm_simp_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   220
by (fast_tac (claset() addSEs prop.free_SEs) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   221
by (Asm_simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   222
by (Fast_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   223
qed "hyps_cons";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
(** Two lemmas for use with weaken_left **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   227
Goal "B-C <= cons(a, B-cons(a,C))";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   228
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   229
qed "cons_Diff_same";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   231
Goal "cons(a, B-{c}) - D <= cons(a, B-cons(c,D))";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   232
by (Fast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   233
qed "cons_Diff_subset2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
(*The set hyps(p,t) is finite, and elements have the form #v or #v=>Fls;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
 could probably prove the stronger hyps(p,t) : Fin(hyps(p,0) Un hyps(p,nat))*)
5325
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   237
Goal "p: prop ==> hyps(p,t) : Fin(UN v:nat. {#v, #v=>Fls})";
f7a5e06adea1 Yet more removal of "goal" commands, especially "goal ZF.thy", so ZF.thy
paulson
parents: 5137
diff changeset
   238
by (etac prop.induct 1);
5618
paulson
parents: 5325
diff changeset
   239
by (asm_simp_tac (simpset() addsimps [UN_I]) 2);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   240
by (ALLGOALS Asm_simp_tac);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   241
by (fast_tac (claset() addIs Fin.intrs) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   242
qed "hyps_finite";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
val Diff_weaken_left = subset_refl RSN (2, Diff_mono) RS weaken_left;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
(*Induction on the finite set of assumptions hyps(p,t0).
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
  We may repeatedly subtract assumptions until none are left!*)
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   248
val [premp,sat] = goal PropLog.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
    "[| p: prop;  0 |= p |] ==> ALL t. hyps(p,t) - hyps(p,t0) |- p";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
by (rtac (premp RS hyps_finite RS Fin_induct) 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   251
by (simp_tac (simpset() addsimps [premp, sat, logcon_thms_p, Diff_0]) 1);
4152
451104c223e2 Ran expandshort, especially to introduce Safe_tac
paulson
parents: 4091
diff changeset
   252
by Safe_tac;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
(*Case hyps(p,t)-cons(#v,Y) |- p *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
by (rtac thms_excluded_middle_rule 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   255
by (etac prop.Var_I 3);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
by (rtac (cons_Diff_same RS weaken_left) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
by (etac spec 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
by (rtac (cons_Diff_subset2 RS weaken_left) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
by (rtac (premp RS hyps_Diff RS Diff_weaken_left) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
by (etac spec 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
(*Case hyps(p,t)-cons(#v => Fls,Y) |- p *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
by (rtac thms_excluded_middle_rule 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   263
by (etac prop.Var_I 3);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
by (rtac (cons_Diff_same RS weaken_left) 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
by (etac spec 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
by (rtac (cons_Diff_subset2 RS weaken_left) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
by (rtac (premp RS hyps_cons RS Diff_weaken_left) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
by (etac spec 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   269
qed "completeness_0_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
(*The base case for completeness*)
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   272
val [premp,sat] = goal PropLog.thy "[| p: prop;  0 |= p |] ==> 0 |- p";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
by (rtac (Diff_cancel RS subst) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
by (rtac (sat RS (premp RS completeness_0_lemma RS spec)) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   275
qed "completeness_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
(*A semantic analogue of the Deduction Theorem*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   278
Goalw [logcon_def] "[| cons(p,H) |= q |] ==> H |= p=>q";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   279
by (Simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   280
by (Fast_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   281
qed "logcon_Imp";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   283
Goal "H: Fin(prop) ==> ALL p:prop. H |= p --> H |- p";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
by (etac Fin_induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   285
by (safe_tac (claset() addSIs [completeness_0]));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
by (rtac (weaken_left_cons RS thms_MP) 1);
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   287
by (blast_tac (claset() addSIs (logcon_Imp::prop.intrs)) 1);
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5116
diff changeset
   288
by (blast_tac thms_cs 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   289
qed "completeness_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
val completeness = completeness_lemma RS bspec RS mp;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 501
diff changeset
   293
val [finite] = goal PropLog.thy "H: Fin(prop) ==> H |- p <-> H |= p & p:prop";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2873
diff changeset
   294
by (fast_tac (claset() addSEs [soundness, finite RS completeness, 
5618
paulson
parents: 5325
diff changeset
   295
			       thms_in_pl]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   296
qed "thms_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
writeln"Reached end of file.";