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