doc-src/IsarAdvanced/Codegen/Thy/Codegen.thy
changeset 21223 b3bdc1abc7d3
parent 21222 6dfdb69e83ef
child 21323 74ab7c0980c7
equal deleted inserted replaced
21222:6dfdb69e83ef 21223:b3bdc1abc7d3
   790 *}
   790 *}
   791 
   791 
   792 code_const "Code_Generator.eq \<Colon> int \<Rightarrow> int \<Rightarrow> bool"
   792 code_const "Code_Generator.eq \<Colon> int \<Rightarrow> int \<Rightarrow> bool"
   793   (SML "!(_ : IntInf.int = _)")
   793   (SML "!(_ : IntInf.int = _)")
   794 
   794 
   795 subsubsection {* typedecls interpretated by customary serializations *}
   795 subsubsection {* typedecls interpreted by customary serializations *}
   796 
   796 
   797 text {*
   797 text {*
   798   A common idiom is to use unspecified types for formalizations
   798   A common idiom is to use unspecified types for formalizations
   799   and interpret them for a specific target language:
   799   and interpret them for a specific target language:
   800 *}
   800 *}
   964 
   964 
   965 print_codethms (insert)
   965 print_codethms (insert)
   966 
   966 
   967 text {*
   967 text {*
   968   This reveals the function equation @{thm insert_def}
   968   This reveals the function equation @{thm insert_def}
   969   for @{const insert}, which is operationally meaningsless
   969   for @{const insert}, which is operationally meaningless
   970   but forces an equality constraint on the set members
   970   but forces an equality constraint on the set members
   971   (which is not fullfiable if the set members are functions).
   971   (which is not satisfiable if the set members are functions).
   972   Even when using set of natural numbers (which are an instance
   972   Even when using set of natural numbers (which are an instance
   973   of \emph{eq}), we run into a problem:
   973   of \emph{eq}), we run into a problem:
   974 *}
   974 *}
   975 
   975 
   976 definition
   976 definition
  1154   \begin{description}
  1154   \begin{description}
  1155 
  1155 
  1156   \item @{ML_type CodegenConsts.const} is the identifier type:
  1156   \item @{ML_type CodegenConsts.const} is the identifier type:
  1157      the product of a \emph{string} with a list of \emph{typs}.
  1157      the product of a \emph{string} with a list of \emph{typs}.
  1158      The \emph{string} is the constant name as represented inside Isabelle;
  1158      The \emph{string} is the constant name as represented inside Isabelle;
  1159      the \emph{typs} are a type instantion in the sense of System F,
  1159      the \emph{typs} are a type instantiation in the sense of System F,
  1160      with canonical names for type variables.
  1160      with canonical names for type variables.
  1161 
  1161 
  1162   \item @{ML CodegenConsts.norm_of_typ}~@{text thy}~@{text "(constname, typ)"}
  1162   \item @{ML CodegenConsts.norm_of_typ}~@{text thy}~@{text "(constname, typ)"}
  1163      maps a constant expression @{text "(constname, typ)"} to its canonical identifier.
  1163      maps a constant expression @{text "(constname, typ)"} to its canonical identifier.
  1164 
  1164 
  1228   \item @{ML CodegenData.add_funcl}~@{text "(const, lthms)"}~@{text "thy"} adds
  1228   \item @{ML CodegenData.add_funcl}~@{text "(const, lthms)"}~@{text "thy"} adds
  1229      suspended function equations @{text lthms} for constant
  1229      suspended function equations @{text lthms} for constant
  1230      @{text const} to executable content.
  1230      @{text const} to executable content.
  1231 
  1231 
  1232   \item @{ML CodegenData.add_inline}~@{text "thm"}~@{text "thy"} adds
  1232   \item @{ML CodegenData.add_inline}~@{text "thm"}~@{text "thy"} adds
  1233      inlineing theorem @{text thm} to executable content.
  1233      inlining theorem @{text thm} to executable content.
  1234 
  1234 
  1235   \item @{ML CodegenData.del_inline}~@{text "thm"}~@{text "thy"} remove
  1235   \item @{ML CodegenData.del_inline}~@{text "thm"}~@{text "thy"} remove
  1236      inlining theorem @{text thm} from executable content, if present.
  1236      inlining theorem @{text thm} from executable content, if present.
  1237 
  1237 
  1238   \item @{ML CodegenData.add_inline_proc}~@{text "f"}~@{text "thy"} adds
  1238   \item @{ML CodegenData.add_inline_proc}~@{text "f"}~@{text "thy"} adds
  1250 
  1250 
  1251   \item @{ML CodegenData.add_datatype}~@{text "(name, (spec, cert))"}~@{text "thy"} adds
  1251   \item @{ML CodegenData.add_datatype}~@{text "(name, (spec, cert))"}~@{text "thy"} adds
  1252      a datatype to executable content, with type constructor
  1252      a datatype to executable content, with type constructor
  1253      @{text name} and specification @{text spec}; @{text spec} is
  1253      @{text name} and specification @{text spec}; @{text spec} is
  1254      a pair consisting of a list of type variable with sort
  1254      a pair consisting of a list of type variable with sort
  1255      contraints and a list of constructors with name
  1255      constraints and a list of constructors with name
  1256      and types of arguments.  The addition as datatype
  1256      and types of arguments.  The addition as datatype
  1257      has to be justified giving a certificate of suspended
  1257      has to be justified giving a certificate of suspended
  1258      theorems as wittnesses for injectiveness and distincness.
  1258      theorems as witnesses for injectiveness and distinctness.
  1259 
  1259 
  1260   \item @{ML CodegenData.del_datatype}~@{text "name"}~@{text "thy"}
  1260   \item @{ML CodegenData.del_datatype}~@{text "name"}~@{text "thy"}
  1261      remove a datatype from executable content, if present.
  1261      remove a datatype from executable content, if present.
  1262 
  1262 
  1263   \item @{ML CodegenData.get_datatype_of_constr}~@{text "thy"}~@{text "const"}
  1263   \item @{ML CodegenData.get_datatype_of_constr}~@{text "thy"}~@{text "const"}
  1294     a normalized function equation system.
  1294     a normalized function equation system.
  1295 
  1295 
  1296   \item @{ML CodegenFuncgr.make}~@{text thy}~@{text cs}
  1296   \item @{ML CodegenFuncgr.make}~@{text thy}~@{text cs}
  1297     returns a normalized function equation system,
  1297     returns a normalized function equation system,
  1298     with the assertion that it contains any function
  1298     with the assertion that it contains any function
  1299     definition for constants @{text cs} (if exisiting).
  1299     definition for constants @{text cs} (if existing).
  1300 
  1300 
  1301   \item @{ML CodegenFuncgr.funcs}~@{text funcgr}~@{text c}
  1301   \item @{ML CodegenFuncgr.funcs}~@{text funcgr}~@{text c}
  1302     retrieves function definition for constant @{text c}.
  1302     retrieves function definition for constant @{text c}.
  1303 
  1303 
  1304   \item @{ML CodegenFuncgr.typ}~@{text funcgr}~@{text c}
  1304   \item @{ML CodegenFuncgr.typ}~@{text funcgr}~@{text c}