doc-src/Codegen/Thy/Program.thy
changeset 30227 853abb4853cc
parent 30226 2f4684e2ea95
child 30938 c6c9359e474c
equal deleted inserted replaced
30226:2f4684e2ea95 30227:853abb4853cc
   285 text {*
   285 text {*
   286   \noindent For completeness, we provide a substitute for the
   286   \noindent For completeness, we provide a substitute for the
   287   @{text case} combinator on queues:
   287   @{text case} combinator on queues:
   288 *}
   288 *}
   289 
   289 
   290 definition %quote
   290 lemma %quote queue_case_AQueue [code]:
   291   aqueue_case_def: "aqueue_case = queue_case"
   291   "queue_case f (AQueue xs ys) = f (ys @ rev xs)"
   292 
   292   unfolding AQueue_def by simp
   293 lemma %quote aqueue_case [code, code inline]:
       
   294   "queue_case = aqueue_case"
       
   295   unfolding aqueue_case_def ..
       
   296 
       
   297 lemma %quote case_AQueue [code]:
       
   298   "aqueue_case f (AQueue xs ys) = f (ys @ rev xs)"
       
   299   unfolding aqueue_case_def AQueue_def by simp
       
   300 
   293 
   301 text {*
   294 text {*
   302   \noindent The resulting code looks as expected:
   295   \noindent The resulting code looks as expected:
   303 *}
   296 *}
   304 
   297 
   311   detail, here some practical hints:
   304   detail, here some practical hints:
   312 
   305 
   313   \begin{itemize}
   306   \begin{itemize}
   314 
   307 
   315     \item When changing the constructor set for datatypes, take care
   308     \item When changing the constructor set for datatypes, take care
   316       to provide an alternative for the @{text case} combinator
   309       to provide alternative equations for the @{text case} combinator.
   317       (e.g.~by replacing it using the preprocessor).
       
   318 
   310 
   319     \item Values in the target language need not to be normalised --
   311     \item Values in the target language need not to be normalised --
   320       different values in the target language may represent the same
   312       different values in the target language may represent the same
   321       value in the logic.
   313       value in the logic.
   322 
   314