CookBook/Package/Ind_Examples.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 13 Feb 2009 14:15:28 +0000
changeset 115 039845fc96bd
parent 114 13fd0a83d3c3
child 116 c9ff326e3ce5
permissions -rw-r--r--
some update of the package introduction
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
     1
theory Ind_Examples
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
     2
imports Main LaTeXsugar
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
     3
begin
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
     4
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
     5
section{* Examples of Inductive Definitions \label{sec:ind-examples} *}
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
     6
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
     7
text {*
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
     8
  Let us first give three examples showing how to define inductive predicates
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
     9
  by hand and then how to prove characteristic properties about them, such as 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    10
  introduction rules and an induction principle. From these examples, we will 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    11
  figure out a 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    12
  general method for defining inductive predicates.  The aim in this section is 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    13
  not to write proofs that are as beautiful as possible, but as close as 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    14
  possible to the ML-code producing the proofs that we will develop later.
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    15
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    16
  As a first example, let us consider the transitive closure of a relation @{text
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    17
  R}. It is an inductive predicate characterized by the two introduction rules
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    18
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    19
  \begin{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    20
  @{term[mode=Axiom] "trcl R x x"} \hspace{5mm}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    21
  @{term[mode=Rule] "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    22
  \end{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    23
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    24
  (FIXME first rule should be an ``axiom'')
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    25
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    26
  Note that the @{text trcl} predicate has two different kinds of parameters: the
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    27
  first parameter @{text R} stays \emph{fixed} throughout the definition, whereas
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    28
  the second and third parameter changes in the ``recursive call''.
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    29
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    30
  Since an inductively defined predicate is the least predicate closed under
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    31
  a collection of introduction rules, we define the predicate @{text "trcl R x y"} in
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    32
  such a way that it holds if and only if @{text "P x y"} holds for every predicate
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    33
  @{text P} closed under the rules above. This gives rise to the definition 
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    34
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    35
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    36
definition "trcl R x y \<equiv> 
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    37
      \<forall>P. (\<forall>x. P x x) \<longrightarrow> (\<forall>x y z. R x y \<longrightarrow> P y z \<longrightarrow> P x z) \<longrightarrow> P x y"
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    38
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    39
text {*
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    40
  where we quantify over the predicate @{text P}. Note that we have to use the
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    41
  object implication @{text "\<longrightarrow>"} and object quantification @{text "\<forall>"} for stating
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    42
  this definition. The introduction rules and induction principles derived later
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    43
  should use the corresponding meta-connectives since they simplify the reasoning for
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    44
  the user.
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    45
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    46
  With this definition, the proof of the induction theorem for the transitive
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    47
  closure is almost immediate. It suffices to convert all the meta-level
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    48
  connectives in the induction rule to object-level connectives using the
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    49
  @{text atomize} proof method (Line 4), expand the definition of @{text trcl}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    50
  (Line 5 and 6), eliminate the universal quantifier contained in it (Line 7),
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    51
  and then solve the goal by assumption (Line 8).
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    52
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    53
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    54
114
13fd0a83d3c3 properly handled linenumbers in ML-text and Isar-proofs
Christian Urban <urbanc@in.tum.de>
parents: 113
diff changeset
    55
lemma %linenos trcl_induct:
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    56
  assumes asm: "trcl R x y"
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    57
  shows "(\<And>x. P x x) \<Longrightarrow> (\<And>x y z. R x y \<Longrightarrow> P y z \<Longrightarrow> P x z) \<Longrightarrow> P x y"
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    58
apply(atomize (full))
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    59
apply(cut_tac asm)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    60
apply(unfold trcl_def)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    61
apply(drule spec[where x=P])
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    62
apply(assumption)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    63
done
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    64
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    65
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    66
  The proofs for the introduction are slightly more complicated. We need to prove
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    67
  the goals @{prop "trcl R x x"} and @{prop "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"}.
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    68
  In order to prove the first goal, we again unfold the definition and
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    69
  then apply the introdution rules for @{text "\<forall>"} and @{text "\<longrightarrow>"} as often as possible.
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    70
  We then end up in the goal state
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    71
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    72
*}
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    73
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    74
(*<*)lemma "trcl R x x"
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    75
apply (unfold trcl_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    76
apply (rule allI impI)+(*>*)
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    77
txt {* @{subgoals [display]} *}
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    78
(*<*)oops(*>*)
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    79
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    80
text {*
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    81
  The two assumptions correspond to the introduction rules, where @{text "trcl
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    82
  R"} has been replaced by P. Thus, all we have to do is to eliminate the
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    83
  universal quantifier in front of the first assumption, and then solve the
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    84
  goal by assumption. Thus the proof is:
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    85
*}
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    86
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
    87
lemma trcl_base: "trcl R x x"
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    88
apply(unfold trcl_def)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    89
apply(rule allI impI)+
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    90
apply(drule spec)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    91
apply(assumption)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    92
done
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    93
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    94
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    95
  Since the second introduction rule has premises, its proof is not as easy. After unfolding 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    96
  the definitions and applying the introduction rules for @{text "\<forall>"} and @{text "\<longrightarrow>"}, we 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
    97
  get the goal state
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    98
*}
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
    99
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   100
(*<*)lemma "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   101
apply (unfold trcl_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   102
apply (rule allI impI)+(*>*)
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   103
txt {*@{subgoals [display]} *}
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   104
(*<*)oops(*>*)
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   105
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   106
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   107
  The third and fourth assumption corresponds to the first and second
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   108
  introduction rule, respectively, whereas the first and second assumption
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   109
  corresponds to the pre\-mises of the introduction rule. Since we want to prove
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   110
  the second introduction rule, we apply the fourth assumption to the goal
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   111
  @{term "P x z"}. In order for the assumption to be applicable as a rule, we have to
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   112
  eliminate the universal quantifier and turn the object-level implications
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   113
  into meta-level ones. This can be accomplished using the @{text rule_format}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   114
  attribute. Applying the assumption produces the two new subgoals
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   115
*}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   116
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   117
(*<*)lemma "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   118
apply (unfold trcl_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   119
apply (rule allI impI)+
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   120
proof -
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   121
  case (goal1 P)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   122
  have a4: "\<forall>x y z. R x y \<longrightarrow> P y z \<longrightarrow> P x z" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   123
  show ?case
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   124
    apply (rule a4[rule_format])(*>*)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   125
txt {*@{subgoals [display]} *}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   126
(*<*)oops(*>*)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   127
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   128
text {* 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   129
  which can be
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   130
  solved using the first and second assumption. The second assumption again
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   131
  involves a quantifier and an implications that have to be eliminated before it
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   132
  can be applied. To avoid potential problems with higher-order unification, 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   133
  we should explcitly instantiate the universally quantified
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   134
  predicate variable to @{text "P"} and also match explicitly the implications
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   135
  with the the third and fourth assumption. This gives the proof:
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   136
*}
113
9b6c9d172378 slightly updated
Christian Urban <urbanc@in.tum.de>
parents: 102
diff changeset
   137
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   138
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   139
lemma trcl_step: "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   140
apply(unfold trcl_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   141
apply(rule allI impI)+
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   142
proof -
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   143
  case (goal1 P)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   144
  have a1: "R x y" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   145
  have a2: "\<forall>P. (\<forall>x. P x x) 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   146
                  \<longrightarrow> (\<forall>x y z. R x y \<longrightarrow> P y z \<longrightarrow> P x z) \<longrightarrow> P y z" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   147
  have a3: "\<forall>x. P x x" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   148
  have a4: "\<forall>x y z. R x y \<longrightarrow> P y z \<longrightarrow> P x z" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   149
  show "P x z"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   150
    apply(rule a4[rule_format])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   151
    apply(rule a1)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   152
    apply(rule a2 [THEN spec[where x=P], THEN mp, THEN mp, OF a3, OF a4])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   153
    done
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   154
qed
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   155
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   156
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   157
  It might be surprising that we are not using the automatic tactics in
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   158
  Isabelle in order to prove the lemmas we are after. After all @{text "blast"}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   159
  would easily dispense of the lemmas.
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   160
*}
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   161
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   162
lemma trcl_step_blast: "R x y \<Longrightarrow> trcl R y z \<Longrightarrow> trcl R x z"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   163
apply(unfold trcl_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   164
apply(blast)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   165
done
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   166
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   167
text {*
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   168
  Experience has shown that it is generally a bad idea to rely heavily on @{term blast}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   169
  and the like in automated proofs. The reason is that you do not have precise control 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   170
  over them (the user can, for example, declare new intro- or simplification rules that 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   171
  can throw automatic tactics off course) and also it is very hard to debug
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   172
  proofs involving automatic tactics. Therefore whenever possible, automatic tactics
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   173
  should be avoided or constrained. 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   174
  
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   175
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   176
  This method of defining inductive predicates generalises also to mutually inductive
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   177
  predicates. The next example defines the predicates @{text even} and @{text odd} 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   178
  characterised by the following rules:
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   179
 
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   180
  \begin{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   181
  @{term[mode=Axiom] "even (0::nat)"} \hspace{5mm}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   182
  @{term[mode=Rule] "odd m \<Longrightarrow> even (Suc m)"} \hspace{5mm}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   183
  @{term[mode=Rule] "even m \<Longrightarrow> odd (Suc m)"}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   184
  \end{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   185
  
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   186
  Since the predicates are mutually inductive, each definition 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   187
  quantifies over both predicates, below named @{text P} and @{text Q}.
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   188
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   189
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   190
definition "even n \<equiv> 
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   191
  \<forall>P Q. P 0 \<longrightarrow> (\<forall>m. Q m \<longrightarrow> P (Suc m)) 
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   192
             \<longrightarrow> (\<forall>m. P m \<longrightarrow> Q (Suc m)) \<longrightarrow> P n"
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   193
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   194
definition "odd n \<equiv>
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   195
  \<forall>P Q. P 0 \<longrightarrow> (\<forall>m. Q m \<longrightarrow> P (Suc m)) 
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   196
             \<longrightarrow> (\<forall>m. P m \<longrightarrow> Q (Suc m)) \<longrightarrow> Q n"
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   197
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   198
text {*
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   199
  For proving the induction rule, we use exactly the same technique as in the transitive
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   200
  closure example:
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   201
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   202
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   203
lemma even_induct:
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   204
  assumes asm: "even n"
38
e21b2f888fa2 added a preliminary section about parsing
Christian Urban <urbanc@in.tum.de>
parents: 32
diff changeset
   205
  shows "P 0 \<Longrightarrow> 
e21b2f888fa2 added a preliminary section about parsing
Christian Urban <urbanc@in.tum.de>
parents: 32
diff changeset
   206
             (\<And>m. Q m \<Longrightarrow> P (Suc m)) \<Longrightarrow> (\<And>m. P m \<Longrightarrow> Q (Suc m)) \<Longrightarrow> P n"
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   207
apply(atomize (full))
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   208
apply(cut_tac asm)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   209
apply(unfold even_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   210
apply(drule spec[where x=P])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   211
apply(drule spec[where x=Q])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   212
apply(assumption)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   213
done
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   214
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   215
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   216
  We omit the other induction rule having @{term "Q n"} as conclusion.
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   217
  The proofs of the introduction rules are also very similar to the ones in the
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   218
  @{text "trcl"}-example. We only show the proof of the second introduction rule:
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   219
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   220
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   221
lemma evenS: "odd m \<Longrightarrow> even (Suc m)"
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   222
apply (unfold odd_def even_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   223
apply (rule allI impI)+
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   224
proof -
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   225
  case (goal1 P)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   226
  have a1: "\<forall>P Q. P 0 \<longrightarrow> (\<forall>m. Q m \<longrightarrow> P (Suc m)) 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   227
                             \<longrightarrow> (\<forall>m. P m \<longrightarrow> Q (Suc m)) \<longrightarrow> Q m" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   228
  have a2: "P 0" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   229
  have a3: "\<forall>m. Q m \<longrightarrow> P (Suc m)" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   230
  have a4: "\<forall>m. P m \<longrightarrow> Q (Suc m)" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   231
  show "P (Suc m)"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   232
    apply(rule a3[rule_format])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   233
    apply(rule a1[THEN spec[where x=P], THEN spec[where x=Q],
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   234
	THEN mp, THEN mp, THEN mp, OF a2, OF a3, OF a4])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   235
    done
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   236
qed
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   237
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   238
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   239
  As a final example, we definethe accessible part of a relation @{text R} characterised 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   240
  by the introduction rule
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   241
  
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   242
  \begin{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   243
  @{term[mode=Rule] "(\<forall>y. R y x \<longrightarrow> accpart R y) \<Longrightarrow> accpart R x"}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   244
  \end{center}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   245
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   246
  whose premise involves a universal quantifier and an implication. The
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   247
  definition of @{text accpart} is as follows:
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   248
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   249
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   250
definition "accpart R x \<equiv> \<forall>P. (\<forall>x. (\<forall>y. R y x \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> P x"
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   251
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   252
text {*
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   253
  The proof of the induction theorem is again straightforward.
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   254
*}
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   255
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   256
lemma accpart_induct:
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   257
  assumes asm: "accpart R x"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   258
  shows "(\<And>x. (\<forall>y. R y x \<longrightarrow> P y) \<Longrightarrow> P x) \<Longrightarrow> P x"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   259
apply(atomize (full))
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   260
apply(cut_tac asm)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   261
apply(unfold accpart_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   262
apply(drule spec[where x=P])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   263
apply(assumption)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   264
done
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   265
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   266
text {*
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   267
  Proving the introduction rule is a little more complicated, because the quantifier
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   268
  and the implication in the premise. We first convert the meta-level universal quantifier
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   269
  and implication to their object-level counterparts. Unfolding the definition of
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   270
  @{text accpart} and applying the introduction rules for @{text "\<forall>"} and @{text "\<longrightarrow>"}
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   271
  yields the following proof state:
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   272
*}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   273
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   274
(*<*)lemma accpartI: "(\<forall>y. R y x \<longrightarrow> accpart R y) \<Longrightarrow> accpart R x"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   275
apply (unfold accpart_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   276
apply (rule allI impI)+(*>*)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   277
txt {* @{subgoals [display]} *}
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   278
(*<*)oops(*>*)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   279
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   280
text {*
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   281
  Applying the second assumption produces a proof state with the new local assumption
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   282
  @{term "R y x"}, which will then be used to solve the goal @{term "P y"} using the
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   283
  first assumption.
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   284
*}
88
ebbd0dd008c8 adaptation of the package chapter to fit the rest
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   285
115
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   286
lemma %small accpartI: "(\<forall>y. R y x \<longrightarrow> accpart R y) \<Longrightarrow> accpart R x"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   287
apply (unfold accpart_def)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   288
apply (rule allI impI)+
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   289
proof -
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   290
  case (goal1 P)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   291
  have a1: "\<forall>y. R y x \<longrightarrow> 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   292
                   (\<forall>P. (\<forall>x. (\<forall>y. R y x \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> P y)" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   293
  have a2: "\<forall>x. (\<forall>y. R y x \<longrightarrow> P y) \<longrightarrow> P x" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   294
  show "P x"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   295
    apply(rule a2[rule_format])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   296
    proof -
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   297
      case (goal1 y)
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   298
      have a3: "R y x" by fact
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   299
      show "P y"
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   300
      apply(rule a1[THEN spec[where x=y], THEN mp, OF a3, 
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   301
            THEN spec[where x=P], THEN mp, OF a2])
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   302
      done
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   303
  qed
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   304
qed
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   305
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   306
text {*
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   307
  Now the point is to figure out what the automatic proofs should do. For
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   308
  this it might be instructive to look at the general construction principle
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   309
  of inductive definitions, which we shall do next.
039845fc96bd some update of the package introduction
Christian Urban <urbanc@in.tum.de>
parents: 114
diff changeset
   310
*}
32
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   311
5bb2d29553c2 Added new chapter about writing packages.
berghofe
parents:
diff changeset
   312
end