src/Doc/Tutorial/Misc/prime_def.thy
author wenzelm
Tue, 31 Mar 2020 14:09:36 +0200
changeset 71637 45c2b8cf1b26
parent 69597 ff784d5a5bfb
permissions -rw-r--r--
more robust message_context and shutdown, e.g. after errors in protocol loop (see also 3f02bc5a5a03);

(*<*)
theory prime_def imports Main begin
consts prime :: "nat \<Rightarrow> bool"
(*>*)
text\<open>
\begin{warn}
A common mistake when writing definitions is to introduce extra free
variables on the right-hand side.  Consider the following, flawed definition
(where \<open>dvd\<close> means ``divides''):
@{term[display,quotes]"prime(p) \<equiv> 1 < p \<and> (m dvd p \<longrightarrow> (m=1 \<or> m=p))"}
\par\noindent\hangindent=0pt
Isabelle rejects this ``definition'' because of the extra \<^term>\<open>m\<close> on the
right-hand side, which would introduce an inconsistency (why?). 
The correct version is
@{term[display,quotes]"prime(p) \<equiv> 1 < p \<and> (\<forall>m. m dvd p \<longrightarrow> (m=1 \<or> m=p))"}
\end{warn}
\<close>
(*<*)
end
(*>*)