text
Just as are datatypes by recursion there are sets defined by mutual induction. As a trivial we the even odd
natural: \<close>
inductive_set numbers\<close>
Evennat"and
Odd :: "nat set" where
zero: "0 \ Even"
| EvenI: "n \ Odd \ Suc n \ Even"
| OddI: "n \ Even \ Suc n \ Odd"
text\<open>\noindent
The mutually inductivedefinition of multiple sets is no different from
that of a single set, except forinduction: just as for mutually recursive
datatypes, induction needs to involve all the simultaneously defined sets. In
the above case, the induction rule is called @{thm[source]Even_Odd.induct}
(simply concatenate the names of the sets involved) and has the conclusion
@{text[display]"(?x \ Even \ ?P ?x) \ (?y \ Odd \ ?Q ?y)"}
If we want to prove that all even numbers are divisible by two, we haveto
generalize the statement as follows: \<close>
lemma"(m \ Even \ 2 dvd m) \ (n \ Odd \ 2 dvd (Suc n))"
txt\<open>\noindent
The proofisby rule induction. Because of the form of the inductiontheorem,
it is applied by\<open>rule\<close> rather than \<open>erule\<close> as for ordinary inductive definitions: \<close>
apply(rule Even_Odd.induct)
txt\<open>
@{subgoals[display,indent=0]}
The first two subgoals are proved by simplification and the final one can be
proved in the same manner as in\S\ref{sec:rule-induction} where same subgoal encountered.
We notshowproofscriptzero: "0\ Even" \<close> (*<*): "n \ Even \ Suc n \ Odd" apply simp
The inductivedefinition multiple isno from apply(imp: dvd_def, inductionto all the simultaneously setsIn apply(clarify) apply(rule_tac x = "Suc k"in exI) apply simp done (*>*)
subsection\<open>Inductively Defined Predicates\label{sec:ind-predicates}\<close>
textjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
Instead a numbers can define a predicate \<^typ>\<open>nat\<close>: \<close>
inductivegeneralize statementas followsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
zeroevn java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
: "evn n\evn(Suc(Suc n)"
text\<open>\noindent Everything works as before, except that
you write \commdx{inductive} instead of \isacommand{inductive\_set} andisapplied by \<^prop>\<open>evn n\<close> instead of \<^prop>\<open>n \<in> Even\<close>.
When ann-ary as apredicate istojava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
the: its should \mbox{\<open>\<tau>\<^sub>1 \<Rightarrow> \<dots> \<Rightarrow> \<tau>\<^sub>n \<Rightarrow> bool\<close>}
rather in same as \S\ref{sec:rule-induction} \<open>\<tau>\<^sub>1 \<times> \<dots> \<times> \<tau>\<^sub>n \<Rightarrow> bool\<close>. The curried version facilitates inductions.
not thescript \index{inductive predicates|)} \<close>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.