doc-src/Nitpick/nitpick.tex
changeset 38173 de6ef87e65b3
parent 38172 62d4bdc3f7cc
child 38175 ef644a533265
equal deleted inserted replaced
38172:62d4bdc3f7cc 38173:de6ef87e65b3
  2600 \flushitem{\textit{nitpick\_choice\_spec}}
  2600 \flushitem{\textit{nitpick\_choice\_spec}}
  2601 
  2601 
  2602 \nopagebreak
  2602 \nopagebreak
  2603 This attribute specifies the (free-form) specification of a constant defined
  2603 This attribute specifies the (free-form) specification of a constant defined
  2604 using the \hbox{(\textbf{ax\_})}\allowbreak\textbf{specification} command.
  2604 using the \hbox{(\textbf{ax\_})}\allowbreak\textbf{specification} command.
  2605 
       
  2606 \end{enum}
  2605 \end{enum}
  2607 
  2606 
  2608 When faced with a constant, Nitpick proceeds as follows:
  2607 When faced with a constant, Nitpick proceeds as follows:
  2609 
  2608 
  2610 \begin{enum}
  2609 \begin{enum}
  2656 Nitpick then expands all occurrences of $\mathit{odd}~n$ to $n~\textrm{mod}~2
  2655 Nitpick then expands all occurrences of $\mathit{odd}~n$ to $n~\textrm{mod}~2
  2657 = 1$. Alternatively, we can specify an equational specification of the constant:
  2656 = 1$. Alternatively, we can specify an equational specification of the constant:
  2658 
  2657 
  2659 \prew
  2658 \prew
  2660 \textbf{lemma} $\mathit{odd\_simp}'$ [\textit{nitpick\_simp}]:\kern.4em ``$\textit{odd}~n = (n~\textrm{mod}~2 = 1)$''
  2659 \textbf{lemma} $\mathit{odd\_simp}'$ [\textit{nitpick\_simp}]:\kern.4em ``$\textit{odd}~n = (n~\textrm{mod}~2 = 1)$''
       
  2660 \postw
       
  2661 
       
  2662 Moreover, because of its internal three-valued logic, Nitpick tends to lose a
       
  2663 lot of precision in the presence of partially specified constants. For example,
       
  2664 
       
  2665 \prew
       
  2666 \textbf{lemma} $\mathit{list\_of\_LCons}$ [\textit{nitpick\_simp}]: \\
       
  2667 ``$\textit{list\_of}~(\textit{LCons~x~xs}) = {}$ \\
       
  2668 \phantom{``}$(\textrm{if}~\textit{lfinite~xs}~\textrm{then}~x \mathbin{\#} \textit{list\_of~xs}~\textrm{else}~\textit{undefined})$''
       
  2669 \postw
       
  2670 
       
  2671 is superior to
       
  2672 
       
  2673 \prew
       
  2674 \textbf{lemma} $\mathit{list\_of\_LCons}$ [\textit{nitpick\_psimp}]: \\
       
  2675 ``$\textit{lfinite~xs} \,\Longrightarrow\, \textit{list\_of}~(\textit{LCons~x~xs}) = x \mathbin{\#} \textit{list\_of~xs\/}$''
  2661 \postw
  2676 \postw
  2662 
  2677 
  2663 Such tweaks should be done with great care, because Nitpick will assume that the
  2678 Such tweaks should be done with great care, because Nitpick will assume that the
  2664 constant is completely defined by its equational specification. For example, if
  2679 constant is completely defined by its equational specification. For example, if
  2665 you make ``$\textit{odd}~(2 * k + 1)$'' a \textit{nitpick\_simp} rule and neglect to provide rules to handle the $2 * k$ case, Nitpick will define
  2680 you make ``$\textit{odd}~(2 * k + 1)$'' a \textit{nitpick\_simp} rule and neglect to provide rules to handle the $2 * k$ case, Nitpick will define