123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159(* This file is free software, part of Logtk. See file "license" for more details. *)(** {1 Unique Identifiers} *)typet={id:int;name:string;mutablepayload:exnlist;(** Use [exn] as an open type for user-defined payload *)}typet_=tletmake=letn=ref0infunname->letid=!ninincrn;{id;name;payload=[];}letmakeffmt=CCFormat.ksprintf~f:makefmtletcopyt=maket.nameletidt=t.idletnamet=t.nameletpayloadt=t.payload(* for temporary purposes *)letdummy_of_intid=letname="DUMMY_"^(CCInt.to_stringid)in{id;name;payload=[]}letset_payload?(can_erase=fun_->false)te=letrecaux=function|[]->[e]|e'::tailwhencan_erasee'->e::tail|e'::tail->e'::auxtailint.payload<-auxt.payloadletpayload_find~f:pt=beginmatcht.payloadwith|[]->None|e1::tail->matchpe1,tailwith|Some_asres,_->res|None,[]->None|None,e2::tail2->matchpe2,tail2with|Some_asres,_->res|None,[]->None|None,e3::tail3->matchpe3with|Some_asres->res|None->CCList.find_mapptail3endletpayload_pred~f:pt=beginmatcht.payloadwith|[]->false|e::_whenpe->true|_::e::_whenpe->true|_::_::e::_whenpe->true|l->List.existsplendlethasht=t.idletequali1i2=i1.id=i2.idletcomparei1i2=Pervasives.comparei1.idi2.idletppoutid=CCFormat.stringoutid.nameletto_string=CCFormat.to_stringppletpp_fulloutid=Format.fprintfout"%s/%d"id.nameid.idletpp_fullc=pp_fullletpp_tstpoutid=ifUtil.tstp_needs_escapingid.namethenCCFormat.fprintfout"'%s'"id.nameelseCCFormat.stringoutid.nameletpp_zf=pp_tstpletgensym=letr=ref0inletnames="abcdefghijklmopq"infun()->leti=!r/String.lengthnamesinletj=!rmodString.lengthnamesinletname=ifi=0thenPrintf.sprintf"%c"names.[j]elsePrintf.sprintf"%c%d"names.[j]iinincrr;makenamemoduleO_=structtypet=t_letequal=equalletcompare=comparelethash=hashendmoduleMap=CCMap.Make(O_)moduleSet=CCSet.Make(O_)moduleTbl=CCHashtbl.Make(O_)exceptionAttr_infixofstringexceptionAttr_prefixofstringexceptionAttr_parameterofinttypeskolem_kind=K_normal|K_after_cnf|K_ind(* inductive *)exceptionAttr_skolemofskolem_kindexceptionAttr_distinctexceptionAttr_commexceptionAttr_assocletas_infix=payload_find~f:(functionAttr_infixs->Somes|_->None)letis_infixid=as_infixid|>CCOpt.is_someletas_prefix=payload_find~f:(functionAttr_prefixs->Somes|_->None)letis_prefixid=as_prefixid|>CCOpt.is_someletas_parameterid=payload_findid~f:(functionAttr_parameteri->Somei|_->None)letis_parameterid=as_parameterid|>CCOpt.is_someletis_commid=CCOpt.is_some@@payload_find~f:(functionAttr_comm->Some1|_->None)idletis_associd=CCOpt.is_some@@payload_find~f:(functionAttr_assoc->Some1|_->None)idletis_acid=is_commid&&is_associdletis_skolemid=payload_predid~f:(function|Attr_skolem_->true|_->false)letis_postcnf_skolemid=payload_predid~f:(function|Attr_skolemK_after_cnf->true|_->false)letas_skolemid=payload_findid~f:(function|Attr_skolema->Somea|_->None)(* Note: If you want to reinsert mandatory arguments: They were here. (let num_mandatory_args _ =) *)letis_distinct_objectid=payload_predid~f:(function|Attr_distinct->true|_->false)