doc-src/IsarRef/Thy/HOL_Specific.thy
changeset 31912 f5bd306f5e9d
parent 31254 03a35fbc9dc6
child 31998 2c7a24f74db9
equal deleted inserted replaced
31845:cc7ddda02436 31912:f5bd306f5e9d
    79   \begin{matharray}{rcl}
    79   \begin{matharray}{rcl}
    80     @{attribute (HOL) split_format}@{text "\<^sup>*"} & : & @{text attribute} \\
    80     @{attribute (HOL) split_format}@{text "\<^sup>*"} & : & @{text attribute} \\
    81   \end{matharray}
    81   \end{matharray}
    82 
    82 
    83   \begin{rail}
    83   \begin{rail}
    84     'split\_format' (((name *) + 'and') | ('(' 'complete' ')'))
    84     'split\_format' ((( name * ) + 'and') | ('(' 'complete' ')'))
    85     ;
    85     ;
    86   \end{rail}
    86   \end{rail}
    87 
    87 
    88   \begin{description}
    88   \begin{description}
    89   
    89   
   367     'rep\_datatype' ('(' (name +) ')')? (term +)
   367     'rep\_datatype' ('(' (name +) ')')? (term +)
   368     ;
   368     ;
   369 
   369 
   370     dtspec: parname? typespec infix? '=' (cons + '|')
   370     dtspec: parname? typespec infix? '=' (cons + '|')
   371     ;
   371     ;
   372     cons: name (type *) mixfix?
   372     cons: name ( type * ) mixfix?
   373   \end{rail}
   373   \end{rail}
   374 
   374 
   375   \begin{description}
   375   \begin{description}
   376 
   376 
   377   \item @{command (HOL) "datatype"} defines inductive datatypes in
   377   \item @{command (HOL) "datatype"} defines inductive datatypes in
   513   \end{matharray}
   513   \end{matharray}
   514 
   514 
   515   \begin{rail}
   515   \begin{rail}
   516     'relation' term
   516     'relation' term
   517     ;
   517     ;
   518     'lexicographic\_order' (clasimpmod *)
   518     'lexicographic\_order' ( clasimpmod * )
   519     ;
   519     ;
   520   \end{rail}
   520   \end{rail}
   521 
   521 
   522   \begin{description}
   522   \begin{description}
   523 
   523 
   563   \begin{rail}
   563   \begin{rail}
   564     'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints?
   564     'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints?
   565     ;
   565     ;
   566     recdeftc thmdecl? tc
   566     recdeftc thmdecl? tc
   567     ;
   567     ;
   568     hints: '(' 'hints' (recdefmod *) ')'
   568     hints: '(' 'hints' ( recdefmod * ) ')'
   569     ;
   569     ;
   570     recdefmod: (('recdef\_simp' | 'recdef\_cong' | 'recdef\_wf') (() | 'add' | 'del') ':' thmrefs) | clasimpmod
   570     recdefmod: (('recdef\_simp' | 'recdef\_cong' | 'recdef\_wf') (() | 'add' | 'del') ':' thmrefs) | clasimpmod
   571     ;
   571     ;
   572     tc: nameref ('(' nat ')')?
   572     tc: nameref ('(' nat ')')?
   573     ;
   573     ;
   781   \begin{matharray}{rcl}
   781   \begin{matharray}{rcl}
   782     @{method_def (HOL) iprover} & : & @{text method} \\
   782     @{method_def (HOL) iprover} & : & @{text method} \\
   783   \end{matharray}
   783   \end{matharray}
   784 
   784 
   785   \begin{rail}
   785   \begin{rail}
   786     'iprover' ('!' ?) (rulemod *)
   786     'iprover' ('!' ?) ( rulemod * )
   787     ;
   787     ;
   788   \end{rail}
   788   \end{rail}
   789 
   789 
   790   The @{method (HOL) iprover} method performs intuitionistic proof
   790   The @{method (HOL) iprover} method performs intuitionistic proof
   791   search, depending on specifically declared rules from the context,
   791   search, depending on specifically declared rules from the context,
   822   geometry.  See @{"file" "~~/src/HOL/ex/Coherent.thy"} for some
   822   geometry.  See @{"file" "~~/src/HOL/ex/Coherent.thy"} for some
   823   examples.
   823   examples.
   824 *}
   824 *}
   825 
   825 
   826 
   826 
       
   827 section {* Checking and refuting propositions *}
       
   828 
       
   829 text {*
       
   830   Identifying incorrect propositions usually involves evaluation of
       
   831   particular assignments and systematic counter example search.  This
       
   832   is supported by the following commands.
       
   833 
       
   834   \begin{matharray}{rcl}
       
   835     @{command_def (HOL) "value"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
       
   836     @{command_def (HOL) "quickcheck"}@{text "\<^sup>*"} & : & @{text "proof \<rightarrow>"} \\
       
   837     @{command_def (HOL) "quickcheck_params"} & : & @{text "theory \<rightarrow> theory"}
       
   838   \end{matharray}
       
   839 
       
   840   \begin{rail}
       
   841     'value' ( ( '[' name ']' ) ? ) modes? term
       
   842     ;
       
   843 
       
   844     'quickcheck' ( ( '[' args ']' ) ? ) nat?
       
   845     ;
       
   846 
       
   847     'quickcheck_params' ( ( '[' args ']' ) ? )
       
   848     ;
       
   849 
       
   850     modes: '(' (name + ) ')'
       
   851     ;
       
   852 
       
   853     args: ( name '=' value + ',' )
       
   854     ;
       
   855   \end{rail}
       
   856 
       
   857   \begin{description}
       
   858 
       
   859   \item @{command (HOL) "value"}~@{text t} evaluates and prints a
       
   860     term; optionally @{text modes} can be specified, which are
       
   861     appended to the current print mode (see also \cite{isabelle-ref}).
       
   862     Internally, the evaluation is performed by registered evaluators,
       
   863     which are invoked sequentially until a result is returned.
       
   864     Alternatively a specific evaluator can be selected using square
       
   865     brackets; available evaluators include @{text nbe} for
       
   866     \emph{normalization by evaluation} and \emph{code} for code
       
   867     generation in SML.
       
   868 
       
   869   \item @{command (HOL) "quickcheck"} tests the current goal for
       
   870     counter examples using a series of arbitrary assignments for its
       
   871     free variables; by default the first subgoal is tested, an other
       
   872     can be selected explicitly using an optional goal index.
       
   873     A number of configuration options are supported for
       
   874     @{command (HOL) "quickcheck"}, notably:
       
   875 
       
   876     \begin{description}
       
   877 
       
   878       \item[size] specifies the maximum size of the search space for
       
   879         assignment values.
       
   880 
       
   881       \item[iterations] sets how many sets of assignments are
       
   882         generated for each particular size.
       
   883 
       
   884     \end{description}
       
   885 
       
   886     These option can be given within square brackets.
       
   887 
       
   888   \item @{command (HOL) "quickcheck_params"} changes quickcheck
       
   889     configuration options persitently.
       
   890 
       
   891   \end{description}
       
   892 *}
       
   893 
       
   894 
   827 section {* Invoking automated reasoning tools -- The Sledgehammer *}
   895 section {* Invoking automated reasoning tools -- The Sledgehammer *}
   828 
   896 
   829 text {*
   897 text {*
   830   Isabelle/HOL includes a generic \emph{ATP manager} that allows
   898   Isabelle/HOL includes a generic \emph{ATP manager} that allows
   831   external automated reasoning tools to crunch a pending goal.
   899   external automated reasoning tools to crunch a pending goal.
   858     @{command_def (HOL) "atp_messages"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   926     @{command_def (HOL) "atp_messages"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   859     @{method_def (HOL) metis} & : & @{text method} \\
   927     @{method_def (HOL) metis} & : & @{text method} \\
   860   \end{matharray}
   928   \end{matharray}
   861 
   929 
   862   \begin{rail}
   930   \begin{rail}
   863   'sledgehammer' (nameref *)
   931   'sledgehammer' ( nameref * )
   864   ;
   932   ;
   865   'atp\_messages' ('(' nat ')')?
   933   'atp\_messages' ('(' nat ')')?
   866   ;
   934   ;
   867 
   935 
   868   'metis' thmrefs
   936   'metis' thmrefs
   987   One framework generates code from both functional and relational
  1055   One framework generates code from both functional and relational
   988   programs to SML.  See \cite{isabelle-HOL} for further information
  1056   programs to SML.  See \cite{isabelle-HOL} for further information
   989   (this actually covers the new-style theory format as well).
  1057   (this actually covers the new-style theory format as well).
   990 
  1058 
   991   \begin{matharray}{rcl}
  1059   \begin{matharray}{rcl}
   992     @{command_def (HOL) "value"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
       
   993     @{command_def (HOL) "code_module"} & : & @{text "theory \<rightarrow> theory"} \\
  1060     @{command_def (HOL) "code_module"} & : & @{text "theory \<rightarrow> theory"} \\
   994     @{command_def (HOL) "code_library"} & : & @{text "theory \<rightarrow> theory"} \\
  1061     @{command_def (HOL) "code_library"} & : & @{text "theory \<rightarrow> theory"} \\
   995     @{command_def (HOL) "consts_code"} & : & @{text "theory \<rightarrow> theory"} \\
  1062     @{command_def (HOL) "consts_code"} & : & @{text "theory \<rightarrow> theory"} \\
   996     @{command_def (HOL) "types_code"} & : & @{text "theory \<rightarrow> theory"} \\  
  1063     @{command_def (HOL) "types_code"} & : & @{text "theory \<rightarrow> theory"} \\  
   997     @{attribute_def (HOL) code} & : & @{text attribute} \\
  1064     @{attribute_def (HOL) code} & : & @{text attribute} \\
   998   \end{matharray}
  1065   \end{matharray}
   999 
  1066 
  1000   \begin{rail}
  1067   \begin{rail}
  1001   'value' term
       
  1002   ;
       
  1003 
       
  1004   ( 'code\_module' | 'code\_library' ) modespec ? name ? \\
  1068   ( 'code\_module' | 'code\_library' ) modespec ? name ? \\
  1005     ( 'file' name ) ? ( 'imports' ( name + ) ) ? \\
  1069     ( 'file' name ) ? ( 'imports' ( name + ) ) ? \\
  1006     'contains' ( ( name '=' term ) + | term + )
  1070     'contains' ( ( name '=' term ) + | term + )
  1007   ;
  1071   ;
  1008 
  1072 
  1031   ;
  1095   ;
  1032 
  1096 
  1033   'code' (name)?
  1097   'code' (name)?
  1034   ;
  1098   ;
  1035   \end{rail}
  1099   \end{rail}
  1036 
       
  1037   \begin{description}
       
  1038 
       
  1039   \item @{command (HOL) "value"}~@{text t} evaluates and prints a term
       
  1040   using the code generator.
       
  1041 
       
  1042   \end{description}
       
  1043 
  1100 
  1044   \medskip The other framework generates code from functional programs
  1101   \medskip The other framework generates code from functional programs
  1045   (including overloading using type classes) to SML \cite{SML}, OCaml
  1102   (including overloading using type classes) to SML \cite{SML}, OCaml
  1046   \cite{OCaml} and Haskell \cite{haskell-revised-report}.
  1103   \cite{OCaml} and Haskell \cite{haskell-revised-report}.
  1047   Conceptually, code generation is split up in three steps:
  1104   Conceptually, code generation is split up in three steps: