| 
8745
 | 
     1  | 
(*<*)
  | 
| 
58860
 | 
     2  | 
theory prime_def imports Main begin
  | 
| 
11457
 | 
     3  | 
consts prime :: "nat \<Rightarrow> bool"
  | 
| 
8745
 | 
     4  | 
(*>*)
  | 
| 
67406
 | 
     5  | 
text\<open>
  | 
| 
9844
 | 
     6  | 
\begin{warn}
 | 
| 
 | 
     7  | 
A common mistake when writing definitions is to introduce extra free
  | 
| 
11456
 | 
     8  | 
variables on the right-hand side.  Consider the following, flawed definition
  | 
| 
69505
 | 
     9  | 
(where \<open>dvd\<close> means ``divides''):
  | 
| 
67613
 | 
    10  | 
@{term[display,quotes]"prime(p) \<equiv> 1 < p \<and> (m dvd p \<longrightarrow> (m=1 \<or> m=p))"}
 | 
| 
11457
 | 
    11  | 
\par\noindent\hangindent=0pt
  | 
| 
69597
 | 
    12  | 
Isabelle rejects this ``definition'' because of the extra \<^term>\<open>m\<close> on the
  | 
| 
11456
 | 
    13  | 
right-hand side, which would introduce an inconsistency (why?). 
  | 
| 
 | 
    14  | 
The correct version is
  | 
| 
67613
 | 
    15  | 
@{term[display,quotes]"prime(p) \<equiv> 1 < p \<and> (\<forall>m. m dvd p \<longrightarrow> (m=1 \<or> m=p))"}
 | 
| 
9844
 | 
    16  | 
\end{warn}
 | 
| 
67406
 | 
    17  | 
\<close>
  | 
| 
8745
 | 
    18  | 
(*<*)
  | 
| 
 | 
    19  | 
end
  | 
| 
 | 
    20  | 
(*>*)
  |