src/ZF/Induct/PropLog.thy
author paulson
Thu, 20 Dec 2001 15:17:48 +0100
changeset 12560 5820841f21fd
parent 12088 6f463d16cbd0
child 12610 8b9845807f77
permissions -rw-r--r--
converted some ZF/Induct examples to Isar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
     1
(*  Title:      ZF/Induct/PropLog.thy
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     2
    ID:         $Id$
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     3
    Author:     Tobias Nipkow & Lawrence C Paulson
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     5
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     6
Datatype definition of propositional logic formulae and inductive definition
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     7
of the propositional tautologies.
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
     8
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
     9
Inductive definition of propositional logic.
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    10
Soundness and completeness w.r.t. truth-tables.
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    11
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    12
Prove: If H|=p then G|=p where G \<in> Fin(H)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    13
*)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    14
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    15
theory PropLog = Main:
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    16
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    17
(** The datatype of propositions; note mixfix syntax **)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    18
consts
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    19
  propn     :: "i"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    20
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    21
datatype
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    22
  "propn" = Fls
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    23
         | Var ("n \<in> nat")                       ("#_" [100] 100)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    24
         | "=>" ("p \<in> propn", "q \<in> propn")          (infixr 90)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    25
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    26
(** The proof system **)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    27
consts
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    28
  thms     :: "i => i"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    29
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    30
syntax
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    31
  "|-"     :: "[i,i] => o"                        (infixl 50)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    32
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    33
translations
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    34
  "H |- p" == "p \<in> thms(H)"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    35
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    36
inductive
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    37
  domains "thms(H)" <= "propn"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    38
  intros
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    39
    H:  "[| p \<in> H;  p \<in> propn |] ==> H |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    40
    K:  "[| p \<in> propn;  q \<in> propn |] ==> H |- p=>q=>p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    41
    S:  "[| p \<in> propn;  q \<in> propn;  r \<in> propn |] 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    42
         ==> H |- (p=>q=>r) => (p=>q) => p=>r"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    43
    DN: "p \<in> propn ==> H |- ((p=>Fls) => Fls) => p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    44
    MP: "[| H |- p=>q;  H |- p;  p \<in> propn;  q \<in> propn |] ==> H |- q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    45
  type_intros "propn.intros"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    46
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    47
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    48
(** The semantics **)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    49
consts
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    50
  "|="        :: "[i,i] => o"                        (infixl 50)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    51
  hyps        :: "[i,i] => i"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    52
  is_true_fun :: "[i,i] => i"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    53
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    54
constdefs (*this definitionis necessary since predicates can't be recursive*)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    55
  is_true     :: "[i,i] => o"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    56
    "is_true(p,t) == is_true_fun(p,t)=1"
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    57
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    58
defs
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    59
  (*Logical consequence: for every valuation, if all elements of H are true
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    60
     then so is p*)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    61
  logcon_def:  "H |= p == \<forall>t. (\<forall>q \<in> H. is_true(q,t)) --> is_true(p,t)"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    62
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    63
primrec (** A finite set of hypotheses from t and the Vars in p **)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    64
  "hyps(Fls, t)    = 0"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    65
  "hyps(Var(v), t) = (if v \<in> t then {#v} else {#v=>Fls})"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    66
  "hyps(p=>q, t)   = hyps(p,t) Un hyps(q,t)"
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    67
 
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    68
primrec (** Semantics of propositional logic **)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    69
  "is_true_fun(Fls, t)    = 0"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    70
  "is_true_fun(Var(v), t) = (if v \<in> t then 1 else 0)"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    71
  "is_true_fun(p=>q, t)   = (if is_true_fun(p,t)=1 then is_true_fun(q,t)
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    72
			     else 1)"
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    73
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    74
declare propn.intros [simp]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    75
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    76
(*** Semantics of propositional logic ***)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    77
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    78
(** The function is_true **)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    79
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    80
lemma is_true_Fls [simp]: "is_true(Fls,t) <-> False"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    81
by (simp add: is_true_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    82
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    83
lemma is_true_Var [simp]: "is_true(#v,t) <-> v \<in> t"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    84
by (simp add: is_true_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    85
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    86
lemma is_true_Imp [simp]: "is_true(p=>q,t) <-> (is_true(p,t)-->is_true(q,t))"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    87
by (simp add: is_true_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    88
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    89
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    90
(*** Proof theory of propositional logic ***)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    91
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    92
lemma thms_mono: "G \<subseteq> H ==> thms(G) \<subseteq> thms(H)"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    93
apply (unfold thms.defs )
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    94
apply (rule lfp_mono)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    95
apply (rule thms.bnd_mono)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    96
apply (assumption | rule univ_mono basic_monos)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    97
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    98
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    99
lemmas thms_in_pl = thms.dom_subset [THEN subsetD]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   100
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   101
inductive_cases ImpE: "p=>q \<in> propn"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   102
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   103
(*Stronger Modus Ponens rule: no typechecking!*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   104
lemma thms_MP: "[| H |- p=>q;  H |- p |] ==> H |- q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   105
apply (rule thms.MP)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   106
apply (erule asm_rl thms_in_pl thms_in_pl [THEN ImpE])+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   107
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   108
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   109
(*Rule is called I for Identity Combinator, not for Introduction*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   110
lemma thms_I: "p \<in> propn ==> H |- p=>p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   111
apply (rule thms.S [THEN thms_MP, THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   112
apply (rule_tac [5] thms.K)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   113
apply (rule_tac [4] thms.K)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   114
apply (simp_all add: propn.intros ) 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   115
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   116
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   117
(** Weakening, left and right **)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   118
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   119
(* [| G \<subseteq> H;  G|-p |] ==> H|-p   Order of premises is convenient with RS*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   120
lemmas weaken_left = thms_mono [THEN subsetD, standard]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   121
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   122
(* H |- p ==> cons(a,H) |- p *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   123
lemmas weaken_left_cons = subset_consI [THEN weaken_left]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   124
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   125
lemmas weaken_left_Un1  = Un_upper1 [THEN weaken_left]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   126
lemmas weaken_left_Un2  = Un_upper2 [THEN weaken_left]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   127
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   128
lemma weaken_right: "[| H |- q;  p \<in> propn |] ==> H |- p=>q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   129
by (simp_all add:  thms.K [THEN thms_MP] thms_in_pl) 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   130
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   131
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   132
(*The deduction theorem*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   133
lemma deduction: "[| cons(p,H) |- q;  p \<in> propn |] ==>  H |- p=>q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   134
apply (erule thms.induct)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   135
    apply (blast intro: thms_I thms.H [THEN weaken_right])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   136
   apply (blast intro: thms.K [THEN weaken_right])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   137
  apply (blast intro: thms.S [THEN weaken_right])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   138
 apply (blast intro: thms.DN [THEN weaken_right])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   139
apply (blast intro: thms.S [THEN thms_MP [THEN thms_MP]])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   140
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   141
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   142
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   143
(*The cut rule*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   144
lemma cut: "[| H|-p;  cons(p,H) |- q |] ==>  H |- q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   145
apply (rule deduction [THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   146
apply (simp_all add: thms_in_pl)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   147
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   148
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   149
lemma thms_FlsE: "[| H |- Fls; p \<in> propn |] ==> H |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   150
apply (rule thms.DN [THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   151
apply (rule_tac [2] weaken_right)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   152
apply (simp_all add: propn.intros)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   153
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   154
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   155
(* [| H |- p=>Fls;  H |- p;  q \<in> propn |] ==> H |- q *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   156
lemmas thms_notE = thms_MP [THEN thms_FlsE, standard]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   157
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   158
(*Soundness of the rules wrt truth-table semantics*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   159
lemma soundness: "H |- p ==> H |= p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   160
apply (unfold logcon_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   161
apply (erule thms.induct)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   162
apply auto
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   163
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   164
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   165
(*** Towards the completeness proof ***)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   166
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   167
lemma Fls_Imp: "[| H |- p=>Fls; q \<in> propn |] ==> H |- p=>q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   168
apply (frule thms_in_pl)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   169
apply (rule deduction)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   170
apply (rule weaken_left_cons [THEN thms_notE]) 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   171
apply (blast intro: thms.H elim: ImpE)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   172
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   173
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   174
lemma Imp_Fls: "[| H |- p;  H |- q=>Fls |] ==> H |- (p=>q)=>Fls"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   175
apply (frule thms_in_pl)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   176
apply (frule thms_in_pl [of concl: "q=>Fls"])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   177
apply (rule deduction)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   178
apply (erule weaken_left_cons [THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   179
apply (rule consI1 [THEN thms.H, THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   180
apply (blast intro: weaken_left_cons elim: ImpE)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   181
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   182
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   183
(*Typical example of strengthening the induction formula*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   184
lemma hyps_thms_if:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   185
     "p \<in> propn ==> hyps(p,t) |- (if is_true(p,t) then p else p=>Fls)"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   186
apply (simp (no_asm))
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   187
apply (induct_tac "p")
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   188
apply (simp_all (no_asm_simp) add: thms_I thms.H)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   189
apply (safe elim!: Fls_Imp [THEN weaken_left_Un1] 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   190
                   Fls_Imp [THEN weaken_left_Un2])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   191
apply (blast intro: weaken_left_Un1 weaken_left_Un2 weaken_right Imp_Fls)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   192
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   193
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   194
(*Key lemma for completeness; yields a set of assumptions satisfying p*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   195
lemma logcon_thms_p: "[| p \<in> propn;  0 |= p |] ==> hyps(p,t) |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   196
apply (unfold logcon_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   197
apply (drule hyps_thms_if)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   198
apply simp
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   199
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   200
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   201
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   202
(*For proving certain theorems in our new propositional logic*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   203
lemmas propn_SIs = propn.intros deduction
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   204
lemmas propn_Is = thms_in_pl thms.H thms.H [THEN thms_MP]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   205
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   206
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   207
(*The excluded middle in the form of an elimination rule*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   208
lemma thms_excluded_middle:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   209
     "[| p \<in> propn;  q \<in> propn |] ==> H |- (p=>q) => ((p=>Fls)=>q) => q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   210
apply (rule deduction [THEN deduction])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   211
apply (rule thms.DN [THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   212
apply (best intro!: propn_SIs intro: propn_Is)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   213
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   214
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   215
(*Hard to prove directly because it requires cuts*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   216
lemma thms_excluded_middle_rule:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   217
     "[| cons(p,H) |- q;  cons(p=>Fls,H) |- q;  p \<in> propn |] ==> H |- q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   218
apply (rule thms_excluded_middle [THEN thms_MP, THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   219
apply (blast intro!: propn_SIs intro: propn_Is)+
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   220
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   221
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   222
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   223
(*** Completeness -- lemmas for reducing the set of assumptions ***)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   224
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   225
(*For the case hyps(p,t)-cons(#v,Y) |- p
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   226
  we also have hyps(p,t)-{#v} \<subseteq> hyps(p, t-{v}) *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   227
lemma hyps_Diff:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   228
     "p \<in> propn ==> hyps(p, t-{v}) \<subseteq> cons(#v=>Fls, hyps(p,t)-{#v})"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   229
by (induct_tac "p", auto)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   230
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   231
(*For the case hyps(p,t)-cons(#v => Fls,Y) |- p
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   232
  we also have hyps(p,t)-{#v=>Fls} \<subseteq> hyps(p, cons(v,t)) *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   233
lemma hyps_cons:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   234
     "p \<in> propn ==> hyps(p, cons(v,t)) \<subseteq> cons(#v, hyps(p,t)-{#v=>Fls})"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   235
by (induct_tac "p", auto)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   236
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   237
(** Two lemmas for use with weaken_left **)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   238
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   239
lemma cons_Diff_same: "B-C \<subseteq> cons(a, B-cons(a,C))"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   240
by blast
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   241
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   242
lemma cons_Diff_subset2: "cons(a, B-{c}) - D \<subseteq> cons(a, B-cons(c,D))"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   243
by blast
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   244
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   245
(*The set hyps(p,t) is finite, and elements have the form #v or #v=>Fls
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   246
 could probably prove the stronger hyps(p,t) \<in> Fin(hyps(p,0) Un hyps(p,nat))*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   247
lemma hyps_finite: "p \<in> propn ==> hyps(p,t) \<in> Fin(\<Union>v \<in> nat. {#v, #v=>Fls})"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   248
by (induct_tac "p", auto)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   249
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   250
lemmas Diff_weaken_left = Diff_mono [OF _ subset_refl, THEN weaken_left]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   251
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   252
(*Induction on the finite set of assumptions hyps(p,t0).
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   253
  We may repeatedly subtract assumptions until none are left!*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   254
lemma completeness_0_lemma [rule_format]:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   255
    "[| p \<in> propn;  0 |= p |] ==> \<forall>t. hyps(p,t) - hyps(p,t0) |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   256
apply (frule hyps_finite)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   257
apply (erule Fin_induct)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   258
apply (simp add: logcon_thms_p Diff_0)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   259
(*inductive step*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   260
apply safe
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   261
(*Case hyps(p,t)-cons(#v,Y) |- p *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   262
 apply (rule thms_excluded_middle_rule)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   263
   apply (erule_tac [3] propn.intros)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   264
  apply (blast intro: cons_Diff_same [THEN weaken_left])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   265
 apply (blast intro: cons_Diff_subset2 [THEN weaken_left] 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   266
		     hyps_Diff [THEN Diff_weaken_left])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   267
(*Case hyps(p,t)-cons(#v => Fls,Y) |- p *)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   268
apply (rule thms_excluded_middle_rule)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   269
  apply (erule_tac [3] propn.intros)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   270
 apply (blast intro: cons_Diff_subset2 [THEN weaken_left] 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   271
		     hyps_cons [THEN Diff_weaken_left])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   272
apply (blast intro: cons_Diff_same [THEN weaken_left])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   273
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   274
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   275
(*The base case for completeness*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   276
lemma completeness_0: "[| p \<in> propn;  0 |= p |] ==> 0 |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   277
apply (rule Diff_cancel [THEN subst])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   278
apply (blast intro: completeness_0_lemma) 
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   279
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   280
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   281
(*A semantic analogue of the Deduction Theorem*)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   282
lemma logcon_Imp: "[| cons(p,H) |= q |] ==> H |= p=>q"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   283
by (simp add: logcon_def)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   284
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   285
lemma completeness [rule_format]:
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   286
     "H \<in> Fin(propn) ==> \<forall>p \<in> propn. H |= p --> H |- p"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   287
apply (erule Fin_induct)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   288
apply (safe intro!: completeness_0)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   289
apply (rule weaken_left_cons [THEN thms_MP])
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   290
 apply (blast intro!: logcon_Imp propn.intros)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   291
apply (blast intro: propn_Is)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   292
done
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   293
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   294
lemma thms_iff: "H \<in> Fin(propn) ==> H |- p <-> H |= p & p \<in> propn"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   295
by (blast intro: soundness completeness thms_in_pl)
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   296
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
   297
end