Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file arrays.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136moduleId=Dolmen.Std.Id(* Ae arrays *)(* ************************************************************************ *)moduleAe=structmoduleTff(Type:Tff_intf.S)(Ty:Dolmen.Intf.Ty.Ae_Arraywithtypet:=Type.Ty.t)(T:Dolmen.Intf.Term.Ae_Arraywithtypet:=Type.T.t)=structtype_Type.err+=|Bad_farray_arity:Dolmen.Std.Term.tType.errletparseenvs=matchswith|Type.Id{name=Simple"farray";ns=Sort}->Type.builtin_ty(funastargs->matchargswith|[ty]->Ty.arrayTy.int(Type.parse_tyenvty)|[ity;vty]->Ty.array(Type.parse_tyenvity)(Type.parse_tyenvvty)|_->Type._errorenv(Astast)Bad_farray_arity)|Type.BuiltinArray_get->Type.builtin_term(Base.term_app2(moduleType)envsT.select)|Type.BuiltinArray_set->Type.builtin_term(Base.term_app3(moduleType)envsT.store)|_->`Not_foundendend(* Smtlib arrays *)(* ************************************************************************ *)moduleSmtlib2=struct(* Restrictions imposed by some theories on the kinds of arrays that
are allowed to occur. This tecnically brings some cross-theory
dependency, but since the restrictions are simple enough, we can
get by with simple syntactic checks on the sort declarations.
The restrictions are as follows:
- AUFLIA, QF_AUFLIA : int -> int
- AUFLIRA : int -> real & int -> (int -> real)
- QF_ABV, QF_AUFBV : bitvec _ -> bitvec _
*)typeconfig=|All|Only_int_int|Only_ints_real|Only_bitvecletprint_configfmt=function|All->Format.fprintffmt"all"|Only_int_int->Format.fprintffmt"only_int_int"|Only_ints_real->Format.fprintffmt"only_ints_real"|Only_bitvec->Format.fprintffmt"only_bitvec"moduleTff(Type:Tff_intf.S)(Ty:Dolmen.Intf.Ty.Smtlib_Arraywithtypet:=Type.Ty.t)(T:Dolmen.Intf.Term.Smtlib_Arraywithtypet:=Type.T.tandtypety:=Type.Ty.t)=structtype_Type.err+=|Forbidden:string->Dolmen.Std.Term.tType.errtype_Type.warn+=|Extension:Id.t->Dolmen.Std.Term.tType.warnletmsg=function|All->assertfalse|Only_int_int->"Only array types of the form (Array Int Int) are allowed by the logic"|Only_ints_real->"Only array types of the form (Array Int Int) or (Array Int (Array (Int Real))) \
are allowed by the logic"|Only_bitvec->"Only array types of the form (Array (_ BitVec i) (_ BitVec j)) for some i, j \
are allowed by the logic"letmk_array_tyenvconfigastsrcdst=leterror()=Type._errorenv(Astast)(Forbidden(msgconfig))inbeginmatchconfig,Ty.viewsrc,Ty.viewdstwith|All,_,_->()(* AUFLIA, QF_AUFLIA restrictions *)|Only_int_int,`Int,`Int->()|Only_int_int,_,_->error()(* AUFLIRA restriction *)|Only_ints_real,`Int,`Real->()|Only_ints_real,`Int,`Array(src',dst')->beginmatchTy.viewsrc',Ty.viewdst'with|`Int,`Real->()|_,_->error()end|Only_ints_real,_,_->error()(* QF_ABV, QF_AUFBV restrictions *)|Only_bitvec,`Bitv_,`Bitv_->()|Only_bitvec,_,_->error()end;Ty.arraysrcdstletparse~configversionenvs=matchswith(* Array theory according to the spec *)|Type.Id{name=Simple"Array";ns=Sort}->Type.builtin_ty(Base.ty_app2_ast(moduleType)envs(mk_array_tyenvconfig))|Type.Id{name=Simple"select";ns=Term}->Type.builtin_term(Base.term_app2(moduleType)envsT.select)|Type.Id{name=Simple"store";ns=Term}->Type.builtin_term(Base.term_app3(moduleType)envsT.store)(* Extension, particularly needed for models *)|Type.Id({name=Simple"const";ns=Term;}asc)->beginmatchversionwith|`Script_->`Not_found|`Response_->Type.builtin_term(funastargs->Type._warnenv(Astast)(Extensionc);letindex_ty=Type.wildcardenv(Added_type_argumentast)Any_in_scopeinBase.term_app1(moduleType)envs(T.constindex_ty)astargs)end|_->`Not_foundendend