doc-src/ZF/ZF_examples.thy
author paulson
Tue, 19 Aug 2003 13:53:58 +0200
changeset 14152 12f6f18e7afc
child 14159 e2eba24c8a2a
permissions -rw-r--r--
For the Isar version of the ZF logics manual
paulson@14152
     1
header{*Examples of Reasoning in ZF Set Theory*}
paulson@14152
     2
paulson@14152
     3
theory ZF_examples = Main_ZFC:
paulson@14152
     4
paulson@14152
     5
subsection {* Binary Trees *}
paulson@14152
     6
paulson@14152
     7
consts
paulson@14152
     8
  bt :: "i => i"
paulson@14152
     9
paulson@14152
    10
datatype "bt(A)" =
paulson@14152
    11
  Lf | Br ("a \<in> A", "t1 \<in> bt(A)", "t2 \<in> bt(A)")
paulson@14152
    12
paulson@14152
    13
declare bt.intros [simp]
paulson@14152
    14
paulson@14152
    15
text{*Induction via tactic emulation*}
paulson@14152
    16
lemma Br_neq_left [rule_format]: "l \<in> bt(A) ==> \<forall>x r. Br(x, l, r) \<noteq> l"
paulson@14152
    17
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    18
  apply (induct_tac l)
paulson@14152
    19
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    20
  apply auto
paulson@14152
    21
  done
paulson@14152
    22
paulson@14152
    23
(*
paulson@14152
    24
  apply (Inductive.case_tac l)
paulson@14152
    25
  apply (tactic {*exhaust_tac "l" 1*})
paulson@14152
    26
*)
paulson@14152
    27
paulson@14152
    28
text{*The new induction method, which I don't understand*}
paulson@14152
    29
lemma Br_neq_left': "l \<in> bt(A) ==> (!!x r. Br(x, l, r) \<noteq> l)"
paulson@14152
    30
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    31
  apply (induct set: bt)
paulson@14152
    32
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    33
  apply auto
paulson@14152
    34
  done
paulson@14152
    35
paulson@14152
    36
lemma Br_iff: "Br(a, l, r) = Br(a', l', r') <-> a = a' & l = l' & r = r'"
paulson@14152
    37
  -- "Proving a freeness theorem."
paulson@14152
    38
  by (blast elim!: bt.free_elims)
paulson@14152
    39
paulson@14152
    40
inductive_cases BrE: "Br(a, l, r) \<in> bt(A)"
paulson@14152
    41
  -- "An elimination rule, for type-checking."
paulson@14152
    42
paulson@14152
    43
text {*
paulson@14152
    44
@{thm[display] BrE[no_vars]}
paulson@14152
    45
\rulename{BrE}
paulson@14152
    46
*};
paulson@14152
    47
paulson@14152
    48
subsection{*Powerset example*}
paulson@14152
    49
paulson@14152
    50
lemma Pow_mono: "A<=B  ==>  Pow(A) <= Pow(B)"
paulson@14152
    51
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    52
apply (rule subsetI)
paulson@14152
    53
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    54
apply (rule PowI)
paulson@14152
    55
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    56
apply (drule PowD)
paulson@14152
    57
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    58
apply (erule subset_trans, assumption)
paulson@14152
    59
done
paulson@14152
    60
paulson@14152
    61
lemma "Pow(A Int B) = Pow(A) Int Pow(B)"
paulson@14152
    62
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    63
apply (rule equalityI)
paulson@14152
    64
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    65
apply (rule Int_greatest)
paulson@14152
    66
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    67
apply (rule Int_lower1 [THEN Pow_mono])
paulson@14152
    68
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    69
apply (rule Int_lower2 [THEN Pow_mono])
paulson@14152
    70
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    71
apply (rule subsetI)
paulson@14152
    72
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    73
apply (erule IntE)
paulson@14152
    74
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    75
apply (rule PowI)
paulson@14152
    76
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    77
apply (drule PowD)+
paulson@14152
    78
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    79
apply (rule Int_greatest, assumption+)
paulson@14152
    80
done
paulson@14152
    81
paulson@14152
    82
text{*Trying again from the beginning in order to use @{text blast}*}
paulson@14152
    83
lemma "Pow(A Int B) = Pow(A) Int Pow(B)"
paulson@14152
    84
by blast
paulson@14152
    85
paulson@14152
    86
paulson@14152
    87
lemma "C<=D ==> Union(C) <= Union(D)"
paulson@14152
    88
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    89
apply (rule subsetI)
paulson@14152
    90
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    91
apply (erule UnionE)
paulson@14152
    92
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    93
apply (rule UnionI)
paulson@14152
    94
apply (erule subsetD, assumption, assumption)
paulson@14152
    95
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
    96
done
paulson@14152
    97
paulson@14152
    98
text{*Trying again from the beginning in order to prove from the definitions*}
paulson@14152
    99
paulson@14152
   100
lemma "C<=D ==> Union(C) <= Union(D)"
paulson@14152
   101
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   102
apply (rule Union_least)
paulson@14152
   103
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   104
apply (rule Union_upper)
paulson@14152
   105
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   106
apply (erule subsetD, assumption)
paulson@14152
   107
done
paulson@14152
   108
paulson@14152
   109
paulson@14152
   110
lemma "[| a:A;  f: A->B;  g: C->D;  A Int C = 0 |] ==> (f Un g)`a = f`a"
paulson@14152
   111
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   112
apply (rule apply_equality)
paulson@14152
   113
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   114
apply (rule UnI1)
paulson@14152
   115
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   116
apply (rule apply_Pair, assumption+)
paulson@14152
   117
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14152
   118
apply (rule fun_disjoint_Un, assumption+)
paulson@14152
   119
done
paulson@14152
   120
paulson@14152
   121
end