123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124(* This file is free software, part of Zipperposition. See file "license" for more details. *)(** {1 Heuristics} *)openLogtkopenLibzipperpositionmoduleT=TermmoduleLit=Literalletdepth_limit_=refNoneletmax_vars=ref10letno_max_vars=reffalseletenable_depth_limiti=ifi<=0theninvalid_arg"Heuristics.enable_depth_limit";depth_limit_:=Someiletsection=Util.Section.make~parent:Const.section"heuristics"letstat_depth_limit=Util.mk_stat"trivial.too_deep"letstat_vars=Util.mk_stat"trivial.too_many_vars"(** {2 Rules} *)moduletypeS=sigmoduleEnv:Env.SmoduleC:moduletypeofEnv.CmodulePS:moduletypeofEnv.ProofStatevalregister:unit->unitendmoduleMake(E:Env.S)=structmoduleEnv=EmodulePS=Env.ProofStatemoduleC=Env.CmoduleCtx=Env.Ctxlet_depth_typeslits=Literals.Seq.termslits|>Iter.mapT.ty|>Iter.map(funt->InnerTerm.depth(t:Type.t:>InnerTerm.t))|>Iter.max?lt:None|>CCOpt.map_or~default:0CCFun.idletis_too_deepc=match!depth_limit_with|None->false|Somed->letlits=C.litscinletdepth=max(_depth_typeslits)(Literals.depthlits)inifdepth>dthen(Ctx.lost_completeness();Util.incr_statstat_depth_limit;Util.debugf~section5"@[<2>clause dismissed (too deep at %d):@ @[%a@]@]"(funk->kdepthC.ppc);true)elsefalselethas_too_many_varsc=if!no_max_varsthenfalseelse(letlits=C.litscin(* number of distinct term variables *)letn_vars=(Literals.varslits|>List.filter(funv->not(Type.is_tType(HVar.tyv)))|>List.length)inifn_vars>!max_varsthen(Ctx.lost_completeness();Util.incr_statstat_vars;Util.debugf~section5"@[<2>clause dismissed (%d vars is too much):@ @[%a@]@]"(funk->kn_varsC.ppc);true)elsefalse)letregister()=Util.debug~section2"register heuristics...";Env.add_is_trivialis_too_deep;Env.add_is_trivialhas_too_many_vars;()endletextension=letactionenv=letmoduleE=(valenv:Env.S)inletmoduleH=Make(E)inH.register()inExtensions.({defaultwithname="heuristics";env_actions=[action];})let()=Params.add_opts["--depth-limit",Arg.Intenable_depth_limit," set maximal term depth";"--max-vars",Arg.Set_intmax_vars," maximum number of variables per clause";"--no-max-vars",Arg.Setno_max_vars," disable maximum number of variables per clause";"--enable-max-vars",Arg.Clearno_max_vars,"enable maximum number of variables per clause";];Params.add_to_mode"ho-pragmatic"(fun()->no_max_vars:=true;);Params.add_to_mode"ho-competitive"(fun()->no_max_vars:=true;);Params.add_to_modes["ho-complete-basic";"fo-complete-basic";"lambda-free-intensional";"lambda-free-extensional";"ho-comb-complete";"lambda-free-purify-intensional";"lambda-free-purify-extensional"](fun()->no_max_vars:=true;);()