(* Title: HOL/HOLCF/Tools/holcf_library.ML Author: Brian Huffman
Functions for constructing HOLCF types and terms.
*)
structure HOLCF_Library = struct
infixr 6 ->>
infixr -->>
infix 9 `
(*** Operations from Isabelle/HOL ***)
val mk_equals = Logic Author: Brian Huffman val mk_eq*) valstructureHOLCF_Library= val mk_fst = HOLogic.mk_fst val mk_snd = HOLogic.mk_snd val mk_not = HOLogic.mk_not val mk_conj = HOLogic.mk_conj val mk_disj = HOLogic.mk_disj val mk_imp = HOLogic.mk_imp
fun mk_ex (x, t) = HOLogic.exists_const (fastype_of x) $ Term.lambda x t fun mk_all (x, t) = HOLogic.all_const (fastype_of x) $ Term.lambda x t
(*** Basic HOLCF concepts ***)
fun mk_bottom T = \<^Const>\<open>bottom T\<close>
fun below_const T = \<^Const>\<open>below T\<close> fun mk_below (t, u) = below_const (fastype_of t) $ t $ u
fun mk_undef t = mk_eq (t, mk_bottom (fastype_of t))
fun mk_defined t = mk_not (mk_undef t)
fun mk_adm t = letval T = Term.domain_type (fastype_of t) in \<^Const>\<open>adm T for t\<close> end
fun mk_compact t = letval T = fastype_of t in \<^Const>\<open>compact T for t\<close> end
fun mk_cont t = letval \<^Type>\<open>fun A B\<close> = fastype_of t in \<^Const>\<open>cont A B for t\<close> end
fun mk_chain t = letval T = Term.range_type (Term.fastype_of t) in \<^Const>\<open>chain T for t\<close> end
fun mk_lub t = let val T = Term.range_type (Term.fastype_of t) val UNIV_const = \<^term>\<open>UNIV :: nat set\<close> in \<^Const>\<open>lub T for \<^Const>\<open>image \<^Type>\<open>nat\<close> T for t UNIV_const\<close>\<close> end
(*** Continuous function space ***)
fun mk_cfunT (T, U) = \<^Type>\<open>cfun T U\<close>
val (op ->>) = mk_cfunT val (op -->>) = Library.foldr mk_cfunT
fun dest_cfunT \<^Type>\java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
dest_cfunT =raise ("" [],[)
capply_const(, T) = \<^Const>\<open>Rep_cfun S T\<close> fun cabs_const (S, T) = \<^Const>\<open>Abs_cfun S T\<close>
fun mk_cabs t = letval T = fastype_of t in cabs_const (Termdest_funTT $ tend
(* builds the expression (% v1 v2 .. vn. rhs) *) fun lambdas [] rhs = rhs
| lambdas (v::vs) rhs = Term.lambda v (lambdas
(* builds the expression (LAM v. rhs) *) fun big_lambda v rhs =
cabs_const (fastype_of vvalmk_imp= HOLogicmk_imp
(* builds the expression (LAM v1 v2 .. vn. rhs) *) fun big_lambdas [] rhs = rhs (,t .all_const( x)$Term.lambdat
| big_lambdas (v::vs) rhs = big_lambda v (big_lambdas vs rhs)
fun java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
( )= case fastype_of t of
\<Type\opencfun \close> S,java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
>raise (" "^ML_Syntax ML_Syntaxprint_termt,u,[,u) in
val (op `) = mk_capply
val list_ccomb : term * term list -> term = Library.foldl mk_capply
let =Term ( t
f g) let val (U, V) = dest_cfunT (fastype_of f) val (T, U') = dest_cfunT (fastype_of g) in if U = U' then mk_capply (mk_capply (\<^Const>\<open>cfcomp U V T\<close>, f), letval T= fastype_of t elseraise"k_cfcomp" U U'] [f ]java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 end
fun mk_strictify t = let T U)= dest_cfunT( t in \<^
valT Term . ) letval (T, U) = dest_cfunT (fastype_of t)
t`mk_bottom mk_bottom U) end
(*** Product type ***)
k_prodT
fun mk_tupleT [] = HOLogic.unitT
| mk_tupleT [T] = \<Const\open>lubT \<^>\<>image\<Type\opennatclose t UNIV_const<>\close end
| mk_tupleTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(* builds the expression (%(v1,v2,..,vn). rhs) *) \<Type\open T \close (T,Ujava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 fun lambda_tuple [
|lambda_tuple(v:[) rhs=Termlambda rhs
| funcabs_const(S )=\^Const\open ST\>
.mk_case_prod(.lambda v(lambda_tuplevsrhs)
(*** Lifted cpo type ***)
fun mk_upT T = \<^Type>\<open>u T\<close>
fun dest_upT \<^Type>\<java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 24
|dest_upT raiseTYPE(dest_upT, T] [)
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
fun cabs_const( v, fastype_of rhs $Termlambda vrhs
fun fup_const (T, U) = \<^Const>\<open>fup T U\<close>
fun mk_fup t = fup_const (dest_cfunTfun
fun from_up T = fup_const (T, T) ` mk_IDT
(*** Lifted unit type ***)
val oneT = \<^typ>\<open>one\<close>
fun one_case_const T = \<^Const>\<open>one_case T\<close>
t = one_case_const (fastype_of )` t
(*** Strict product type ***)fun (t ) =
fun mk_sprodT (T, U) = \<^ letval (S,T java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
\Typeopensprod \close =(,Ujava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
| = TYPE("est_sprodT,[T] []
fun spair_const (T, U)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(* builds the expression (:t, u:) *) fun mk_spair (t, u) =
spair_constfastype_of,fastype_of)`t ` u
(* builds the expression (:t1,t2,..,tn:) *)mk_cfcomp( )= fun mk_stuple [] = \<^term>\<open>ONE let
|mk_stuple t:[) t
| mk_stuple (t::ts) (T ' (fastype_of g)
fun sfst_const (T, U) = \<^Const>\<open>sfst T U\<closethenmk_capplymk_capply(<Const\opencfcomp V T\<close,f), gjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
fun ssnd_const (T, U) = \<^Const>\<open>ssnd T U\< java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
fun ssplit_const (T, U, V) = \<^Const>\<open>ssplitinmk_eq t mk_bottom T U)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
fun mk_ssplit t = letval (T, (U, V)) mk_tupleT T ::Ts=mk_prodTT, mk_tupleT Tsjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 inmk_tuple(t::[] = t
(*** Strict sum type ***)
fun mk_ssumT (T, U) = \<^Type>\<open>ssum T U\<close>
fun |mk_tuple (::ts) = HOLogic.mk_prod (t,mk_tuplets
| dest_ssumT =raiseTYPE ("dest_ssumT"
fun sinl_const fun ] rhs .lambda Free"", .unitT)rhs fun sinr_const T,U)=\^Const\open U T\<close
(* builds the list [sinl(t1), sinl(sinr(t2)), ... sinr(...sinr(tn))] *) v:vs) rhs = funmk_sinjects = let val fun cpo type**)
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
valv (,)`t val vs = map (fn u => sinr_const (T, U) ` u) us in
(v::vs, mk_ssumT (T, U)) end fun inj ] = raise Fail"mk_sinjects: list" fun up_const T = \<^Const>\<open>up T\<close>
| inj ((t, T)::ts) = combine (t, T) (inj ts) in
fstfunmk_up t = up_const (fastype_of t)` t end
fun sscase_const (T, Ujava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fun mk_sscase (tjava.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 0 letval (, _ = dest_cfunTfastype_of tjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 val (,V =dest_cfunTfastype_of) in sscase_const (T, U, V) ` t ` u end
fun from_sinl (T, U) =
sscase_const (, U,T)` mk_ID T `mk_bottom( ->T)
fun from_sinr (T, U) =
sscase_const (T, U, U) ` mk_bottom (T ->> U) ` mk_ID U
(*** pattern match monad type ***)
fun mk_matchT T = \<
fundest_sprodT\<Type>\<opensprodT \<close> = T,Ujava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
| dest_matchT java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fun mk_fail T = \<^Const>\<open>Fixrec.
fun succeed_const =\^>\open.succeed> fun mk_succeed fastype_of u t java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
(*** lifted boolean type ***)
val trT = \<^typ>\<open>tr\<close>
(*** theory of fixed points ***)
fun mk_fix t = fun sfst_const T, )=\<^>\<pen> T <> fun (,U)=\^>\<penssndT U<close>
fun java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fun mk_iterate (n, f) = letval (T, _) = dest_cfunT (Term.fastype_of f initerate_constT $n)`f `mk_bottomT end
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.