ex/PropLog.ML
author clasohm
Wed, 02 Nov 1994 11:50:09 +0100
changeset 156 fd1be45b64bf
parent 130 e7dcf3c07865
child 171 16c4ea954511
permissions -rw-r--r--
added IOA to isabelle/HOL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
130
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     1
(*  Title: 	HOL/ex/pl.ML
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     3
    Author: 	Tobias Nipkow & Lawrence C Paulson
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     4
    Copyright   1994  TU Muenchen & University of Cambridge
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     5
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     6
Soundness and completeness of propositional logic w.r.t. truth-tables.
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     7
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     8
Prove: If H|=p then G|=p where G:Fin(H)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
     9
*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    10
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    11
open PropLog;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    12
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    13
(** Monotonicity **)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    14
goalw PropLog.thy thms.defs "!!G H. G<=H ==> thms(G) <= thms(H)";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    15
by (rtac lfp_mono 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    16
by (REPEAT (ares_tac basic_monos 1));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    17
val thms_mono = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    18
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    19
(*Rule is called I for Identity Combinator, not for Introduction*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    20
goal PropLog.thy "H |- p->p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    21
by(best_tac (HOL_cs addIs [thms.K,thms.S,thms.MP]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    22
val thms_I = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    23
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    24
(** Weakening, left and right **)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    25
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    26
(* "[| G<=H;  G |- p |] ==> H |- p"
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    27
   This order of premises is convenient with RS
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    28
*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    29
val weaken_left = standard (thms_mono RS subsetD);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    30
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    31
(* H |- p ==> insert(a,H) |- p *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    32
val weaken_left_insert = subset_insertI RS weaken_left;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    33
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    34
val weaken_left_Un1  =    Un_upper1 RS weaken_left;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    35
val weaken_left_Un2  =    Un_upper2 RS weaken_left;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    36
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    37
goal PropLog.thy "!!H. H |- q ==> H |- p->q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    38
by(fast_tac (HOL_cs addIs [thms.K,thms.MP]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    39
val weaken_right = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    40
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    41
(*The deduction theorem*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    42
goal PropLog.thy "!!H. insert(p,H) |- q  ==>  H |- p->q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    43
by (etac thms.induct 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    44
by (fast_tac (set_cs addIs [thms_I, thms.H RS weaken_right]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    45
by (fast_tac (set_cs addIs [thms.K RS weaken_right]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    46
by (fast_tac (set_cs addIs [thms.S RS weaken_right]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    47
by (fast_tac (set_cs addIs [thms.DN RS weaken_right]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    48
by (fast_tac (set_cs addIs [thms.S RS thms.MP RS thms.MP]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    49
val deduction = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    50
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    51
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    52
(* "[| insert(p,H) |- q; H |- p |] ==> H |- q"
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    53
    The cut rule - not used
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    54
*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    55
val cut = deduction RS thms.MP;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    56
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    57
(* H |- false ==> H |- p *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    58
val thms_falseE = weaken_right RS (thms.DN RS thms.MP);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    59
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    60
(* [| H |- p->false;  H |- p;  q: pl |] ==> H |- q *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    61
val thms_notE = standard (thms.MP RS thms_falseE);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    62
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    63
(** The function eval **)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    64
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    65
val pl_ss = set_ss addsimps
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    66
  (PropLog.pl.simps @ [eval2_false, eval2_var, eval2_imp]
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    67
               @ [hyps_false, hyps_var, hyps_imp]);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    68
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    69
goalw PropLog.thy [eval_def] "tt[false] = False";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    70
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    71
val eval_false = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    72
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    73
goalw PropLog.thy [eval_def] "tt[#v] = (v:tt)";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    74
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    75
val eval_var = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    76
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    77
goalw PropLog.thy [eval_def] "tt[p->q] = (tt[p]-->tt[q])";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    78
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    79
val eval_imp = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    80
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    81
val pl_ss = pl_ss addsimps [eval_false, eval_var, eval_imp];
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    82
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    83
(*Soundness of the rules wrt truth-table semantics*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    84
goalw PropLog.thy [sat_def] "!!H. H |- p ==> H |= p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    85
by (etac thms.induct 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    86
by (fast_tac (set_cs addSDs [eval_imp RS iffD1 RS mp]) 5);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    87
by (ALLGOALS (asm_simp_tac pl_ss));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    88
val soundness = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    89
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    90
(*** Towards the completeness proof ***)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    91
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    92
goal PropLog.thy "!!H. H |- p->false ==> H |- p->q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    93
by (rtac deduction 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    94
by (etac (weaken_left_insert RS thms_notE) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    95
by (rtac thms.H 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    96
by (rtac insertI1 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    97
val false_imp = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    98
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
    99
val [premp,premq] = goal PropLog.thy
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   100
    "[| H |- p;  H |- q->false |] ==> H |- (p->q)->false";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   101
by (rtac deduction 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   102
by (rtac (premq RS weaken_left_insert RS thms.MP) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   103
by (rtac (thms.H RS thms.MP) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   104
by (rtac insertI1 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   105
by (rtac (premp RS weaken_left_insert) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   106
val imp_false = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   107
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   108
(*This formulation is required for strong induction hypotheses*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   109
goal PropLog.thy "hyps(p,tt) |- if(tt[p], p, p->false)";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   110
by (rtac (expand_if RS iffD2) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   111
by(PropLog.pl.induct_tac "p" 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   112
by (ALLGOALS (simp_tac (pl_ss addsimps [thms_I, thms.H])));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   113
by (fast_tac (set_cs addIs [weaken_left_Un1, weaken_left_Un2, 
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   114
			   weaken_right, imp_false]
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   115
                    addSEs [false_imp]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   116
val hyps_thms_if = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   117
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   118
(*Key lemma for completeness; yields a set of assumptions satisfying p*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   119
val [sat] = goalw PropLog.thy [sat_def] "{} |= p ==> hyps(p,tt) |- p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   120
by (rtac (sat RS spec RS mp RS if_P RS subst) 1 THEN
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   121
    rtac hyps_thms_if 2);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   122
by (fast_tac set_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   123
val sat_thms_p = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   124
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   125
(*For proving certain theorems in our new propositional logic*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   126
val thms_cs = 
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   127
    set_cs addSIs [deduction] addIs [thms.H, thms.H RS thms.MP];
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   128
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   129
(*The excluded middle in the form of an elimination rule*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   130
goal PropLog.thy "H |- (p->q) -> ((p->false)->q) -> q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   131
by (rtac (deduction RS deduction) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   132
by (rtac (thms.DN RS thms.MP) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   133
by (ALLGOALS (best_tac (thms_cs addSIs prems)));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   134
val thms_excluded_middle = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   135
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   136
(*Hard to prove directly because it requires cuts*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   137
val prems = goal PropLog.thy
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   138
    "[| insert(p,H) |- q;  insert(p->false,H) |- q |] ==> H |- q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   139
by (rtac (thms_excluded_middle RS thms.MP RS thms.MP) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   140
by (REPEAT (resolve_tac (prems@[deduction]) 1));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   141
val thms_excluded_middle_rule = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   142
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   143
(*** Completeness -- lemmas for reducing the set of assumptions ***)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   144
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   145
(*For the case hyps(p,t)-insert(#v,Y) |- p;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   146
  we also have hyps(p,t)-{#v} <= hyps(p, t-{v}) *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   147
goal PropLog.thy "hyps(p, t-{v}) <= insert(#v->false, hyps(p,t)-{#v})";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   148
by (PropLog.pl.induct_tac "p" 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   149
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   150
by (simp_tac (pl_ss setloop (split_tac [expand_if])) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   151
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   152
by (fast_tac set_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   153
val hyps_Diff = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   154
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   155
(*For the case hyps(p,t)-insert(#v -> false,Y) |- p;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   156
  we also have hyps(p,t)-{#v->false} <= hyps(p, insert(v,t)) *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   157
goal PropLog.thy "hyps(p, insert(v,t)) <= insert(#v, hyps(p,t)-{#v->false})";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   158
by (PropLog.pl.induct_tac "p" 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   159
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   160
by (simp_tac (pl_ss setloop (split_tac [expand_if])) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   161
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   162
by (fast_tac set_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   163
val hyps_insert = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   164
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   165
(** Two lemmas for use with weaken_left **)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   166
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   167
goal Set.thy "B-C <= insert(a, B-insert(a,C))";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   168
by (fast_tac set_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   169
val insert_Diff_same = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   170
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   171
goal Set.thy "insert(a, B-{c}) - D <= insert(a, B-insert(c,D))";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   172
by (fast_tac set_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   173
val insert_Diff_subset2 = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   174
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   175
(*The set hyps(p,t) is finite, and elements have the form #v or #v->false;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   176
 could probably prove the stronger hyps(p,t) : Fin(hyps(p,{}) Un hyps(p,nat))*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   177
goal PropLog.thy "hyps(p,t) : Fin(UN v:{x.True}. {#v, #v->false})";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   178
by (PropLog.pl.induct_tac "p" 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   179
by (ALLGOALS (simp_tac (pl_ss setloop (split_tac [expand_if])) THEN'
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   180
              fast_tac (set_cs addSIs Fin.intrs@[Fin_UnI])));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   181
val hyps_finite = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   182
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   183
val Diff_weaken_left = subset_refl RSN (2, Diff_mono) RS weaken_left;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   184
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   185
(*Induction on the finite set of assumptions hyps(p,t0).
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   186
  We may repeatedly subtract assumptions until none are left!*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   187
val [sat] = goal PropLog.thy
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   188
    "{} |= p ==> !t. hyps(p,t) - hyps(p,t0) |- p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   189
by (rtac (hyps_finite RS Fin_induct) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   190
by (simp_tac (pl_ss addsimps [sat RS sat_thms_p]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   191
by (safe_tac set_cs);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   192
(*Case hyps(p,t)-insert(#v,Y) |- p *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   193
by (rtac thms_excluded_middle_rule 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   194
by (rtac (insert_Diff_same RS weaken_left) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   195
by (etac spec 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   196
by (rtac (insert_Diff_subset2 RS weaken_left) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   197
by (rtac (hyps_Diff RS Diff_weaken_left) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   198
by (etac spec 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   199
(*Case hyps(p,t)-insert(#v -> false,Y) |- p *)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   200
by (rtac thms_excluded_middle_rule 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   201
by (rtac (insert_Diff_same RS weaken_left) 2);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   202
by (etac spec 2);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   203
by (rtac (insert_Diff_subset2 RS weaken_left) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   204
by (rtac (hyps_insert RS Diff_weaken_left) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   205
by (etac spec 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   206
val completeness_0_lemma = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   207
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   208
(*The base case for completeness*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   209
val [sat] = goal PropLog.thy "{} |= p ==> {} |- p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   210
by (rtac (Diff_cancel RS subst) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   211
by (rtac (sat RS (completeness_0_lemma RS spec)) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   212
val completeness_0 = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   213
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   214
(*A semantic analogue of the Deduction Theorem*)
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   215
val [sat] = goalw PropLog.thy [sat_def] "insert(p,H) |= q ==> H |= p->q";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   216
by (simp_tac pl_ss 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   217
by (cfast_tac [sat] 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   218
val sat_imp = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   219
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   220
val [finite] = goal PropLog.thy "H: Fin({p.True}) ==> !p. H |= p --> H |- p";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   221
by (rtac (finite RS Fin_induct) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   222
by (safe_tac (set_cs addSIs [completeness_0]));
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   223
by (rtac (weaken_left_insert RS thms.MP) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   224
by (fast_tac (set_cs addSIs [sat_imp]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   225
by (fast_tac thms_cs 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   226
val completeness_lemma = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   227
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   228
val completeness = completeness_lemma RS spec RS mp;
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   229
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   230
val [finite] = goal PropLog.thy "H: Fin({p.True}) ==> (H |- p) = (H |= p)";
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   231
by (fast_tac (set_cs addSEs [soundness, finite RS completeness]) 1);
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   232
val thms_iff = result();
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   233
e7dcf3c07865 Updated PL to PropLog using Larrys ind. defs.
nipkow
parents:
diff changeset
   234
writeln"Reached end of file.";