diff --git a/.gitignore b/.gitignore index 981adcb3e8..b64884308c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ cmake-build # vim swap files **/.*.swp +**/.*.swo diff --git a/CASC/PortfolioMode.cpp b/CASC/PortfolioMode.cpp index 9a1a9d7a7c..dac69d79a7 100644 --- a/CASC/PortfolioMode.cpp +++ b/CASC/PortfolioMode.cpp @@ -200,12 +200,15 @@ bool PortfolioMode::prepareScheduleAndPerform(const Shell::Property& prop) addScheduleExtra(sOrig,sWithExtras,"avsq=on:plsq=on"); // split queues addScheduleExtra(sOrig,sWithExtras,"av=on:atotf=0.5"); // turn AVATAR off +#if VHOL if(!prop.higherOrder()){ +#endif //these options are not currently HOL compatible addScheduleExtra(sOrig,sWithExtras,"bsd=on:fsd=on"); // subsumption demodulation addScheduleExtra(sOrig,sWithExtras,"to=lpo"); // lpo +#if VHOL } - +#endif // If contains integers, rationals and reals if(prop.props() & (Property::PR_HAS_INTEGERS | Property::PR_HAS_RATS | Property::PR_HAS_REALS)){ addScheduleExtra(sOrig,sWithExtras,"hsm=on"); // Sets a sensible set of Joe's arithmetic rules (TACAS-21) @@ -267,12 +270,11 @@ bool PortfolioMode::prepareScheduleAndPerform(const Shell::Property& prop) schedule.loadFromIterator(main.iterFifo()); addScheduleExtra(main,schedule,"rp=on:de=on"); // random polarities, demodulation encompassment - } else if (env.options->schedule() == Options::Schedule::SNAKE_TPTP_SAT) { ASS(fallback.isEmpty()); schedule.loadFromIterator(main.iterFifo()); - addScheduleExtra(main,schedule,"rp=on:fmbksg=on:de=on"); // random polarities, demodulation encompassment for saturation, fmbksg for the fmb's + addScheduleExtra(main,schedule,"rp=on:fmbksg=on:de=on"); // random polarities, demodulation encompassment for saturation, fmbksg for the fmb's } else { // all other schedules just get loaded plain @@ -369,6 +371,15 @@ void PortfolioMode::getSchedules(const Property& prop, Schedule& quick, Schedule Schedules::getSnakeTptpSatSchedule(prop,quick); break; +#if VHOL + case Options::Schedule::SNAKE_TPTP_HOL: + Schedules::getSnakeTptpHolSchedule(prop,quick); + break; + case Options::Schedule::SNAKE_SLH: + Schedules::getSnakeSlhSchedule(prop,quick); + break; +#endif + case Options::Schedule::CASC_2019: case Options::Schedule::CASC: Schedules::getCasc2019Schedule(prop,quick,fallback); @@ -379,9 +390,6 @@ void PortfolioMode::getSchedules(const Property& prop, Schedule& quick, Schedule Schedules::getCascSat2019Schedule(prop,quick,fallback); break; - case Options::Schedule::CASC_HOL_2020: - Schedules::getHigherOrderSchedule2020(quick,fallback); - break; case Options::Schedule::SMTCOMP: case Options::Schedule::SMTCOMP_2018: diff --git a/CASC/Schedules.cpp b/CASC/Schedules.cpp index 5adddaabb6..858d929d80 100644 --- a/CASC/Schedules.cpp +++ b/CASC/Schedules.cpp @@ -2871,149 +2871,6 @@ void Schedules::getLtb2017DefaultSchedule(const Property& property, Schedule& sc sched.push("lrs+1003_4_bsr=unit_only:cond=fast:fsr=off:gsp=on:gs=on:gsaa=from_current:nm=0:nwc=1:stl=300:sos=on:sac=on:add=large:afp=10000:afq=1.1:anc=none:urr=ec_only:uhcvi=on_60"); // HLL 50 (1) } -void Schedules::getHigherOrderSchedule2020(Schedule& quick, Schedule& fallback) -{ - //no fallback at present - quick.push("ott+1002_2_av=off:bd=preordered:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lma=on:nm=64:nwc=10:sp=reverse_arity:updr=off_2"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_2"); - quick.push("lrs+1011_8_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_3"); - quick.push("dis+10_128_acc=on:add=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=4000:afq=1.4:amm=off:bd=preordered:cond=on:fsr=off:fde=unused:gs=on:gsem=on:irw=on:lma=on:nm=64:nwc=1.2:nicw=on:sos=on:sp=occurrence:updr=off:uhcvi=on_2"); - quick.push("lrs+1010_8_add=off:afp=100000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:amm=off:anc=none:irw=on:nm=16:newcnf=on:nwc=1.1:nicw=on:stl=30:sp=reverse_arity:urr=on_13"); - quick.push("ott+1002_8:1_add=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afr=on:afp=100000:afq=1.1:amm=off:anc=none:bd=off:bs=unit_only:fsr=off:gs=on:gsem=off:nm=32:nwc=10:sp=occurrence:urr=on:updr=off_14"); - quick.push("lrs+1011_5:1_acc=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:amm=off:anc=all_dependent:bd=off:ccuc=small_ones:fde=unused:gs=on:gsaa=full_model:gsem=off:lcm=predicate:lwlo=on:nm=6:newcnf=on:nwc=2.5:stl=30:sp=occurrence:updr=off_3"); - quick.push("lrs+4_3_av=off:br=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:nm=0:newcnf=on:nwc=1:stl=30:sp=occurrence:urr=on_32"); - quick.push("dis+1010_3:2_av=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:gsp=on:nm=2:nwc=1:sp=reverse_arity:urr=ec_only_29"); - quick.push("dis+1_2:3_acc=on:add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=40000:afq=2.0:amm=sco:anc=none:er=filter:fsr=off:gsp=on:gs=on:gsem=off:nm=64:newcnf=on:nwc=1_3"); - quick.push("dis+10_128_acc=on:add=off:add=off:afp=4000:afq=1.4:amm=off:bd=preordered:cond=on:fsr=off:fde=unused:gs=on:gsem=on:irw=on:lma=on:nm=64:nwc=1.2:nicw=on:sos=on:sp=occurrence:updr=off:uhcvi=on_40"); - quick.push("dis-11_3_add=off:afp=40000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_2"); - quick.push("dis+1002_6_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=40000:afq=2.0:bsr=on:cond=on:irw=on:lma=on:nm=2:nwc=2.5:nicw=on:sp=reverse_arity:updr=off_2"); - quick.push("lrs+1010_3_av=off:fsr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:gs=on:gsem=off:nm=2:newcnf=on:nwc=2:stl=30:sp=reverse_arity:urr=on:updr=off_9"); - quick.push("lrs+1002_1_av=off:er=filter:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:fsr=off:gs=on:gsem=off:irw=on:lma=on:nm=4:nwc=1:stl=30:sd=3:ss=axioms:st=1.5:sos=on_1"); - quick.push("ott+2_2_afp=10000:afq=1.4:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:amm=off:anc=none:gsp=on:gs=on:gsem=off:irw=on:lcm=predicate:nm=32:nwc=1.5:sos=on:sp=reverse_arity_7"); - quick.push("lrs+1010_3:2_afr=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:anc=none:gsp=on:irw=on:lwlo=on:nm=2:newcnf=on:nwc=1.7:sac=on:sp=occurrence_300"); - quick.push("lrs+1011_5:1_acc=on:csup=on:inj=on:e2e=on:prag=on:cases=on:cnfonf=eager:amm=off:anc=all_dependent:bd=off:ccuc=small_ones:fde=unused:gs=on:gsaa=full_model:gsem=off:lcm=predicate:lwlo=on:nm=6:newcnf=on:nwc=2.5:stl=30:sp=occurrence:updr=off_30"); - quick.push("ott+11_20_afr=on:afp=100000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:amm=sco:anc=all:bsr=on:irw=on:lma=on:nm=4:nwc=1.2:sac=on:sp=occurrence_6"); - quick.push("dis+1002_3:1_acc=model:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afr=on:afp=40000:afq=1.1:anc=none:ccuc=first:fsr=off:gsp=on:irw=on:nm=16:nwc=1:sos=all_8"); - quick.push("lrs+10_12_add=off:afp=100000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.4:amm=sco:anc=none:cond=on:lma=on:nm=64:nwc=1.3:stl=30:sac=on:urr=on_41"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:chr=on:cases=on:cnfonf=lazy_gen:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_30"); - quick.push("dis+10_4_av=off:bsr=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:cond=fast:er=filter:fde=none:gsp=on:lcm=reverse:lma=on:nwc=4:sp=occurrence:urr=on_8"); - quick.push("lrs+1002_1_add=large:csup=on:inj=on:fe=off:chr=on:cases=on:cnfonf=eager:afr=on:afp=1000:afq=1.1:amm=sco:anc=none:er=known:fsr=off:gs=on:gsem=off:lma=on:nm=2:newcnf=on:nwc=2:stl=30:sd=1:ss=axioms:st=5.0:sp=reverse_arity:updr=off_50"); - quick.push("lrs+1011_5_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=1000:afq=1.2:anc=none:fsr=off:irw=on:lma=on:nm=64:newcnf=on:nwc=1:stl=30:sd=3:ss=axioms:st=2.0:sos=on:sac=on:sp=reverse_arity:urr=on:updr=off_130"); - quick.push("lrs+1010_8_add=off:afp=100000:csup=on:inj=off:cases=on:chr=off:e2e=on:cnfonf=eager:afq=1.0:amm=off:anc=none:irw=on:nm=16:newcnf=on:nwc=1.1:nicw=on:stl=30:sp=reverse_arity:urr=on_13"); - quick.push("lrs+1_4_afp=100000:afq=1.2:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:anc=none:bd=off:cond=on:gs=on:gsem=off:nm=64:nwc=1:sd=2:ss=axioms:st=2.0:sos=all:updr=off_300"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:mXXn=1:cases=on:e2e=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_186"); - quick.push("dis+1002_4_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=40000:afq=1.0:anc=none:cond=fast:fde=none:gs=on:gsaa=full_model:lma=on:lwlo=on:nm=0:nwc=1.5:sp=reverse_arity:tha=off_300"); - quick.push("dis-11_3_add=off:afp=40000:csup=on:inj=on:chr=on:e2e=on:prag=on:cases=on:cnfonf=eager:afq=1.0:fde=all:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_50"); - quick.push("dis+1011_10_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afr=on:afp=4000:afq=1.0:amm=off:anc=none:lma=on:nm=64:nwc=4:sac=on:sp=occurrence_75"); - quick.push("dis+1010_3:2_av=off:csup=on:prag=on:chr=on:cases=on:bet=on:cnfonf=lazy_not_be_gen:gsp=on:nm=2:nwc=1:sp=reverse_arity:urr=ec_only_29"); - quick.push("lrs+1011_8_add=large:csup=on:inj=on:prag=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_26"); - quick.push("lrs+1011_8_add=large:csup=on:fe=off:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_30"); - quick.push("dis+1002_4_add=large:csup=on:narr=off:inj=on:prag=on:cbe=off:cases=on:cnfonf=eager:afp=40000:afq=1.0:anc=none:cond=fast:fde=none:gs=on:gsaa=full_model:lma=on:lwlo=on:nm=0:nwc=1.5:sp=reverse_arity_27"); - quick.push("dis+1_3_add=large:afp=4000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:anc=none:gs=on:gsem=off:inw=on:lcm=reverse:lwlo=on:nm=64:nwc=1:sos=all:sac=on:updr=off:uhcvi=on_125"); - quick.push("dis+1010_3:1_av=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:nm=32:nwc=1:sos=all:urr=ec_only:updr=off_77"); - quick.push("lrs+1011_5:4_acc=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:add=large:afr=on:afp=10000:afq=2.0:amm=sco:anc=none:bsr=on:ccuc=first:cond=on:fde=unused:gs=on:gsaa=from_current:gsem=off:irw=on:nm=2:newcnf=on:nwc=1.2:stl=30:sos=on:sac=on:sp=reverse_arity:updr=off_126"); - quick.push("lrs+1002_1_add=large:csup=on:narr=off:inj=on:fe=off:chr=on:cases=on:cnfonf=eager:afr=on:afp=1000:afq=1.1:amm=sco:anc=none:er=known:fsr=off:gs=on:gsem=off:lma=on:nm=2:newcnf=on:nwc=2:stl=30:sd=1:ss=axioms:st=5.0:sp=reverse_arity:updr=off_50"); - quick.push("lrs-3_4:1_afp=1000:afq=1.4:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:amm=sco:fde=none:gs=on:lcm=reverse:lma=on:nwc=1.5:stl=30:sd=1:ss=axioms:sp=reverse_arity:urr=on:updr=off:uhcvi=on_11"); - quick.push("ott+11_2:1_add=large:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=40000:afq=2.0:amm=sco:anc=none:br=off:cond=on:irw=on:nwc=1:sd=2:ss=axioms:st=2.0:sos=all:urr=on:updr=off_9"); - quick.push("lrs+1011_8_add=large:csup=off:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_13"); - quick.push("lrs+1011_2:1_av=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_300"); - quick.push("dis+1011_4_av=off:cond=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lma=on:nm=2:nwc=1:sos=all:sp=occurrence_5"); - quick.push("lrs+10_3:1_av=off:bsr=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:cond=on:er=known:gs=on:lcm=reverse:nm=32:nwc=4:stl=30:sp=occurrence:urr=on:updr=off_73"); - quick.push("dis+10_1_add=off:afp=4000:csup=on:inj=on:chr=on:e2e=on:cases=on:cnfonf=eager:afq=1.2:anc=none:br=off:cond=on:gs=on:irw=on:lcm=reverse:nwc=10:sd=10:ss=axioms:sos=theory:sac=on:sp=occurrence:urr=on_12"); - quick.push("lrs+4_3_av=off:bd=preordered:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:bs=unit_only:cond=fast:fde=unused:gsp=on:gs=on:gsem=on:lma=on:lwlo=on:nm=6:nwc=1:stl=60:sp=occurrence:uhcvi=on_481"); - quick.push("lrs+1002_1_av=off:fde=unused:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:lwlo=on:nm=16:nwc=4:sp=occurrence_300"); - quick.push("ott+1002_2_av=off:bd=preordered:csup=on:inj=on:chr=on:cases=on:cnfonf=lazy_not_gen_be_off:bet=on:sup=off:irw=on:lma=on:nm=64:nwc=10:sp=reverse_arity:updr=off_70"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:bet=on:cases=on:cnfonf=lazy_not_gen_be_off:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_45"); - quick.push("lrs+1011_8_add=large:csup=on:e2e=on:prag=on:mXXn=1:cnfonf=lazy_simp:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_19"); - quick.push("dis+1011_4_av=off:cond=on:piset=false_true_not:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lma=on:nm=2:nwc=1:sos=all:sp=occurrence_5"); - quick.push("dis+1002_7_acc=on:afp=4000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=2.0:amm=sco:anc=none:cond=fast:fsr=off:gsp=on:gs=on:gsem=on:lma=on:nm=6:newcnf=on:nwc=1.1:nicw=on:sos=on:sac=on:sp=reverse_arity:urr=ec_only:updr=off_73"); - quick.push("dis+11_24_afp=40000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.1:amm=sco:anc=none:bs=on:gs=on:gsem=off:lcm=predicate:lma=on:nm=2:nwc=1:sos=on:sac=on:updr=off_91"); - quick.push("lrs+1010_8_add=off:afp=100000:afq=1.0:amm=off:anc=none:csup=on:cases=on:ptlr=on:irw=on:nm=16:newcnf=on:nwc=1.1:nicw=on:stl=30:sp=reverse_arity:urr=on_13"); - quick.push("lrs+1011_5_afr=on:afp=100000:narr=ski:prag=on:mXXn=3:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:amm=off:anc=none:cond=on:lma=on:nm=6:nwc=1:stl=30:sac=on:urr=on_15"); - quick.push("lrs+1011_5:4_acc=on:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:add=large:afr=on:afp=0:afq=2.0:amm=sco:anc=none:bsr=on:ccuc=first:cond=on:fde=unused:gs=on:gsaa=from_current:gsem=off:irw=on:nm=2:newcnf=on:nwc=1.2:stl=30:sos=on:sac=on:sp=reverse_arity:updr=off_12"); - quick.push("lrs+1011_8_add=large:csup=on:narr=off:fe=off:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_10"); - quick.push("lrs+11_3:2_add=large:afp=1000:afq=1.1:amm=sco:anc=none:csup=on:cases=on:ptlr=on:bd=off:er=filter:irw=on:lcm=predicate:lma=on:nm=6:nwc=1:stl=30:sp=occurrence:urr=on:updr=off_10"); - quick.push("lrs+1011_8_add=large:csup=on:piset=all:inj=on:chr=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_31"); - quick.push("lrs+1_8:1_av=off:cond=fast:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:fde=unused:lcm=predicate:nm=16:nwc=10:sp=occurrence:urr=ec_only_600"); - quick.push("dis+1011_5_add=off:afr=on:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=10000:afq=1.1:amm=off:anc=none:cond=on:fsr=off:nm=32:nwc=1:sd=3:ss=axioms:st=2.0:sp=occurrence:updr=off_2"); - quick.push("lrs-11_4:1_afp=0:narr=sk:prag=on:csup=on:inj=on:mXXn=1:cases=on:e2e=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_186"); - quick.push("dis+1002_6_add=large:csup=on:narr=sk:prag=on:mXXn=4:inj=on:chr=on:cases=on:cnfonf=eager:afp=0:afq=2.0:bsr=on:cond=on:irw=on:lma=on:nm=2:nwc=2.5:nicw=on:sp=reverse_arity:updr=off_22"); - quick.push("lrs-11_4:1_afp=0:fe=axiom:narr=sk:prag=on:csup=on:inj=on:mXXn=1:cases=on:e2e=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_186"); - quick.push("dis+1_3_add=large:afp=4000:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afq=1.0:anc=none:gs=on:gsem=off:inw=on:lcm=reverse:lwlo=on:nm=64:nwc=1:sos=all:sac=on:updr=off:uhcvi=on_300"); - quick.push("lrs+1011_10_aac=none:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:acc=model:add=large:afp=40000:afq=2.0:anc=none:bd=off:bsr=on:fsr=off:gs=on:gsem=off:irw=on:lcm=reverse:lwlo=on:nm=64:nwc=3:nicw=on:stl=30_38"); - quick.push("lrs+10_1:1_av=off:bsr=on:csup=on:fe=axiom:cases=on:cnfonf=eager:cond=on:er=known:gs=on:lcm=reverse:nm=32:nwc=4:stl=30:sp=occurrence:urr=on:updr=off_67"); - quick.push("ott+11_2:1_add=large:narr=ski:prag=on:mXXn=4:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=0:afq=2.0:amm=sco:anc=none:br=off:cond=on:irw=on:nwc=1:sd=2:ss=axioms:st=2.0:sos=all:urr=on:updr=off_9"); - quick.push("ott+1002_8:1_add=off:csup=on:fe=axiom:chr=on:cases=on:cnfonf=eager:afr=on:afp=100000:afq=1.1:amm=off:anc=none:bd=off:bs=unit_only:fsr=off:gs=on:gsem=off:nm=32:nwc=10:sp=occurrence:urr=on:updr=off_15"); - quick.push("dis+1011_10_add=large:csup=on:narr=off:inj=on:chr=on:cases=on:cnfonf=eager:afr=on:afp=4000:afq=1.0:amm=off:anc=none:lma=on:nm=64:nwc=4:sac=on:sp=occurrence_20"); - quick.push("lrs-11_4:1_afp=0:fe=axiom:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=lazy_gen:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_30"); - quick.push("lrs+1011_5_add=large:csup=on:fe=axiom:ntd=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=0:afq=1.2:anc=none:fsr=off:irw=on:lma=on:nm=64:newcnf=on:nwc=1:stl=30:sd=3:ss=axioms:st=2.0:sos=on:sac=on:sp=reverse_arity:urr=on:updr=off_40"); - quick.push("lrs+1002_1_av=off:csup=on:e2e=on:cs=on:fde=unused:lwlo=on:nm=16:nwc=4:sp=occurrence_150"); - quick.push("ott+2_1:1_csup=on:afp=0:fe=axiom:narr=off:prag=on:cs=on_50"); - quick.push("lrs+1011_2:1_av=off:fe=axiom:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_100"); - quick.push("lrs+1011_2:1_av=off:piset=small_set:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_200"); - quick.push("lrs+1011_2:1_av=off:irw=off:csup=on:e2e=on:cs=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_30"); - quick.push("dis+1011_10_add=large:csup=on:fe=axiom:narr=off:inj=on:chr=on:cases=on:cnfonf=eager:afr=on:afp=4000:afq=1.0:amm=off:anc=none:afp=0:lma=on:nm=64:nwc=4:sac=on:sp=occurrence_20"); - quick.push("dis+1002_4_add=large:afp=40000:afq=1.5:csup=on:e2e=on:cs=on:anc=none:cond=fast:fde=none:gs=on:gsaa=full_model:lma=on:lwlo=on:nm=0:nwc=1.5:sp=reverse_arity:tha=off_44"); - quick.push("lrs+11_3:2_add=large:afp=1000:afq=1.1:amm=sco:csup=on:e2e=on:cs=on:anc=none:bd=off:er=filter:irw=on:lcm=predicate:lma=on:nm=6:nwc=1:stl=30:sp=occurrence:urr=on:updr=off_43"); - quick.push("lrs+4_3_av=off:bd=preordered:bs=unit_only:cond=fast:csup=on:e2e=on:cs=on:fde=unused:gsp=on:gs=on:gsem=on:lma=on:lwlo=on:nm=6:nwc=1:stl=60:sp=occurrence:uhcvi=on_100"); - quick.push("lrs-3_4:1_afp=1000:afq=1.4:csup=on:e2e=on:cs=on:amm=sco:fde=none:gs=on:lcm=reverse:lma=on:nwc=1.5:stl=30:sd=1:ss=axioms:sp=reverse_arity:urr=on:updr=off:uhcvi=on_11"); - quick.push("ott+2_1:1_csup=on:prag=on:cs=on:inj=on:mXXn=1_170"); - quick.push("dis-11_3_add=off:afp=0:fe=axiom:csup=on:inj=on:chr=on:e2e=on:prag=on:cases=on:cnfonf=eager:afq=1.0:fde=all:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_50"); - quick.push("lrs+1011_5:1_acc=on:fe=axiom:csup=on:inj=on:e2e=on:prag=on:cases=on:cnfonf=eager:amm=off:anc=all_dependent:bd=off:ccuc=small_ones:afp=0:fde=unused:gs=on:gsaa=full_model:gsem=off:lcm=predicate:lwlo=on:nm=6:newcnf=on:nwc=2.5:stl=30:sp=occurrence:updr=off_30"); - quick.push("ott+1002_2_av=off:bd=preordered:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lma=on:nm=64:nwc=10:sp=reverse_arity:updr=off_20"); - quick.push("lrs-11_4:1_afp=4000:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=lazy_gen:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_30"); - quick.push("lrs+1011_2:1_av=off:irw=off:ntd=on:csup=on:e2e=on:cs=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_30"); - quick.push("lrs+1010_3:2_afr=on:csup=on:ntd=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:anc=none:gsp=on:irw=on:lwlo=on:nm=2:newcnf=on:nwc=1.7:sac=on:sp=occurrence_300"); - quick.push("lrs+1_8:1_av=off:fe=axiom:cond=fast:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:fde=unused:lcm=predicate:nm=16:nwc=10:sp=occurrence:urr=ec_only_300"); - quick.push("ott+2_1:1_csup=on:narr=off:prag=on:cs=on_110"); - quick.push("lrs+1011_2:1_av=off:narr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:irw=on:lwlo=on:nm=16:newcnf=on:nwc=2:sd=4:ss=axioms:st=3.0:sp=occurrence_200"); - quick.push("lrs+1011_5_add=large:csup=on:ntd=on:inj=on:chr=on:cases=on:cnfonf=eager:afp=1000:afq=1.2:anc=none:fsr=off:irw=on:lma=on:nm=64:newcnf=on:nwc=1:stl=30:sd=3:ss=axioms:st=2.0:sos=on:sac=on:sp=reverse_arity:urr=on:updr=off_130"); - quick.push("lrs+1011_5_add=large:csup=on:fe=axiom:inj=on:chr=on:cases=on:cnfonf=eager:afp=1000:afq=1.2:anc=none:fsr=off:irw=on:lma=on:nm=64:newcnf=on:nwc=1:stl=30:sd=3:ss=axioms:st=2.0:sos=on:sac=on:sp=reverse_arity:urr=on:updr=off_130"); - quick.push("lrs+1011_8_add=large:csup=on:fe=axiom:e2e=on:prag=on:mXXn=1:cnfonf=lazy_simp:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_19"); - quick.push("lrs+1011_8_add=large:csup=on:fe=axiom:piset=all:inj=on:chr=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_31"); - quick.push("ott+1002_2_av=off:bd=preordered:csup=on:inj=on:cvc=on:chr=on:cases=on:cnfonf=eager:irw=on:lma=on:nm=64:nwc=10:sp=reverse_arity:updr=off_2"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_2"); - quick.push("lrs+1011_8_add=large:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_3"); - quick.push("dis+10_128_acc=on:add=off:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afp=4000:afq=1.4:amm=off:bd=preordered:cond=on:fsr=off:fde=unused:gs=on:gsem=on:irw=on:lma=on:nm=64:nwc=1.2:nicw=on:sos=on:sp=occurrence:updr=off:uhcvi=on_2"); - quick.push("lrs+1010_8_add=off:afp=100000:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afq=1.0:amm=off:anc=none:irw=on:nm=16:newcnf=on:nwc=1.1:nicw=on:stl=30:sp=reverse_arity:urr=on_13"); - quick.push("ott+1002_8:1_add=off:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afr=on:afp=100000:afq=1.1:amm=off:anc=none:bd=off:bs=unit_only:fsr=off:gs=on:gsem=off:nm=32:nwc=10:sp=occurrence:urr=on:updr=off_14"); - quick.push("lrs+1011_5:1_acc=on:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:amm=off:anc=all_dependent:bd=off:ccuc=small_ones:fde=unused:gs=on:gsaa=full_model:gsem=off:lcm=predicate:lwlo=on:nm=6:newcnf=on:nwc=2.5:stl=30:sp=occurrence:updr=off_3"); - quick.push("lrs+4_3_av=off:br=off:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:nm=0:newcnf=on:nwc=1:stl=30:sp=occurrence:urr=on_32"); - quick.push("dis+1010_3:2_av=off:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:gsp=on:nm=2:nwc=1:sp=reverse_arity:urr=ec_only_29"); - quick.push("dis+1_2:3_acc=on:add=large:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afp=40000:afq=2.0:amm=sco:anc=none:er=filter:fsr=off:gsp=on:gs=on:gsem=off:nm=64:newcnf=on:nwc=1_3"); - quick.push("dis+10_128_acc=on:add=off:add=off:afp=4000:afq=1.4:amm=off:cvc=on:bd=preordered:cond=on:fsr=off:fde=unused:gs=on:gsem=on:irw=on:lma=on:nm=64:nwc=1.2:nicw=on:sos=on:sp=occurrence:updr=off:uhcvi=on_40"); - quick.push("dis-11_3_add=off:afp=40000:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afq=1.0:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_2"); - quick.push("dis+1002_6_add=large:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afp=40000:afq=2.0:bsr=on:cond=on:irw=on:lma=on:nm=2:nwc=2.5:nicw=on:sp=reverse_arity:updr=off_2"); - quick.push("lrs+1010_3_av=off:fsr=off:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:gs=on:gsem=off:nm=2:newcnf=on:nwc=2:stl=30:sp=reverse_arity:urr=on:updr=off_9"); - quick.push("lrs+1002_1_av=off:er=filter:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:fsr=off:gs=on:gsem=off:irw=on:lma=on:nm=4:nwc=1:stl=30:sd=3:ss=axioms:st=1.5:sos=on_1"); - quick.push("ott+2_2_afp=10000:afq=1.4:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:amm=off:anc=none:gsp=on:gs=on:gsem=off:irw=on:lcm=predicate:nm=32:nwc=1.5:sos=on:sp=reverse_arity_7"); - quick.push("lrs+1010_3:2_afr=on:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afp=100000:afq=1.1:anc=none:gsp=on:irw=on:lwlo=on:nm=2:newcnf=on:nwc=1.7:sac=on:sp=occurrence_300"); - quick.push("lrs+1011_5:1_acc=on:csup=on:inj=on:e2e=on:prag=on:cvc=on:cases=on:cnfonf=eager:amm=off:anc=all_dependent:bd=off:ccuc=small_ones:fde=unused:gs=on:gsaa=full_model:gsem=off:lcm=predicate:lwlo=on:nm=6:newcnf=on:nwc=2.5:stl=30:sp=occurrence:updr=off_30"); - quick.push("ott+11_20_afr=on:afp=100000:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afq=1.0:amm=sco:anc=all:bsr=on:irw=on:lma=on:nm=4:nwc=1.2:sac=on:sp=occurrence_6"); - quick.push("dis+1002_3:1_acc=model:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afr=on:afp=40000:afq=1.1:anc=none:ccuc=first:fsr=off:gsp=on:irw=on:nm=16:nwc=1:sos=all_8"); - quick.push("lrs+10_12_add=off:afp=100000:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=eager:afq=1.4:amm=sco:anc=none:cond=on:lma=on:nm=64:nwc=1.3:stl=30:sac=on:urr=on_41"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:chr=on:cases=on:cvc=on:cnfonf=lazy_gen:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_30"); - quick.push("dis+10_4_av=off:bsr=on:csup=on:cvc=on:inj=on:chr=on:cases=on:cnfonf=eager:cond=fast:er=filter:fde=none:gsp=on:lcm=reverse:lma=on:nwc=4:sp=occurrence:urr=on_8"); - quick.push("lrs+1002_1_add=large:csup=on:inj=on:cvc=on:fe=off:chr=on:cases=on:cnfonf=eager:afr=on:afp=1000:afq=1.1:amm=sco:anc=none:er=known:fsr=off:gs=on:gsem=off:lma=on:nm=2:newcnf=on:nwc=2:stl=30:sd=1:ss=axioms:st=5.0:sp=reverse_arity:updr=off_50"); - quick.push("lrs+1011_5_add=large:csup=on:inj=on:cvc=on:chr=on:cases=on:cnfonf=eager:afp=1000:afq=1.2:anc=none:fsr=off:irw=on:lma=on:nm=64:newcnf=on:nwc=1:stl=30:sd=3:ss=axioms:st=2.0:sos=on:sac=on:sp=reverse_arity:urr=on:updr=off_130"); - quick.push("lrs+1010_8_add=off:afp=100000:csup=on:cvc=on:inj=off:cases=on:chr=off:e2e=on:cnfonf=eager:afq=1.0:amm=off:anc=none:irw=on:nm=16:newcnf=on:nwc=1.1:nicw=on:stl=30:sp=reverse_arity:urr=on_13"); - quick.push("lrs+1_4_afp=100000:afq=1.2:csup=on:inj=on:cvc=on:chr=on:cases=on:cnfonf=eager:anc=none:bd=off:cond=on:gs=on:gsem=off:nm=64:nwc=1:sd=2:ss=axioms:st=2.0:sos=all:updr=off_300"); - quick.push("lrs-11_4:1_afp=4000:csup=on:inj=on:mXXn=1:cvc=on:cases=on:e2e=on:cnfonf=eager:afq=2.0:anc=none:br=off:gs=on:lwlo=on:nm=64:nwc=3:stl=30:urr=on_186"); - quick.push("dis+1002_4_add=large:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afp=40000:afq=1.0:anc=none:cond=fast:fde=none:gs=on:gsaa=full_model:lma=on:lwlo=on:nm=0:nwc=1.5:sp=reverse_arity:tha=off_300"); - quick.push("dis-11_3_add=off:afp=40000:csup=on:inj=on:cvc=on:chr=on:e2e=on:prag=on:cases=on:cnfonf=eager:afq=1.0:fde=all:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_50"); - quick.push("dis+1011_10_add=large:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:afr=on:afp=4000:afq=1.0:amm=off:anc=none:lma=on:nm=64:nwc=4:sac=on:sp=occurrence_75"); - quick.push("dis+1010_3:2_av=off:csup=on:prag=on:chr=on:cvc=on:cases=on:bet=on:cnfonf=lazy_not_be_gen:gsp=on:nm=2:nwc=1:sp=reverse_arity:urr=ec_only_29"); - quick.push("lrs+1011_8_add=large:csup=on:inj=on:prag=on:cvc=on:cases=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_26"); - quick.push("lrs+1011_8_add=large:csup=on:fe=off:cases=on:cvc=on:cnfonf=eager:afp=100000:afq=1.1:er=filter:gsp=on:gs=on:gsem=on:lma=on:nm=6:nwc=1:stl=30:sd=2:ss=axioms:st=1.5:sos=on_30"); - quick.push("dis+1002_4_add=large:csup=on:narr=off:inj=on:cvc=on:prag=on:cbe=off:cases=on:cnfonf=eager:afp=40000:afq=1.0:anc=none:cond=fast:fde=none:gs=on:gsaa=full_model:lma=on:lwlo=on:nm=0:nwc=1.5:sp=reverse_arity_27"); - quick.push("dis+1_3_add=large:afp=4000:csup=on:inj=on:cvc=on:chr=on:cases=on:cnfonf=eager:afq=1.0:anc=none:gs=on:gsem=off:inw=on:lcm=reverse:lwlo=on:nm=64:nwc=1:sos=all:sac=on:updr=off:uhcvi=on_125"); - quick.push("dis+1010_3:1_av=off:csup=on:inj=on:chr=on:cvc=on:cases=on:cnfonf=eager:irw=on:nm=32:nwc=1:sos=all:urr=ec_only:updr=off_77"); - quick.push("lrs+1010_3_av=off:fsr=off:csup=on:inj=on:chr=on:cases=on:cnfonf=eager:gs=on:gsem=off:nm=2:newcnf=on:nwc=2:stl=30:sp=reverse_arity:urr=on:updr=off_650"); - quick.push("dis-11_3_add=off:afp=0:fe=axiom:mXXn=2:csup=on:inj=on:chr=on:e2e=on:prag=on:cases=on:cnfonf=eager:afq=1.0:fde=all:amm=sco:anc=none:gs=on:irw=on:lcm=reverse:nm=6:nwc=1:sd=4:ss=axioms:st=3.0:sos=on:sac=on_600"); - quick.push("lrs+4_3_av=off:bd=preordered:fe=axiom:narr=off:csup=on:ntd=on:inj=on:chr=on:cases=on:cnfonf=lazy_simp:bs=unit_only:cond=fast:fde=unused:gsp=on:gs=on:gsem=on:lma=on:lwlo=on:nm=6:nwc=1:stl=60:sp=occurrence:uhcvi=on_600"); - quick.push("ott+2_1:1_csup=on:fe=axiom:ntd=on:narr=off:prag=on:cs=on_600"); -} - // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- @@ -5129,3 +4986,1995 @@ void Schedules::getSnakeTptpSatSchedule(const Shell::Property& property, Schedul // Improves by expected 0.4363593202030057 probs costing 1274359 Mi // Overall score 2081.1804482430707 probs on average / budget 9091993 Mi } + +#if VHOL + +void Schedules::getSnakeTptpHolSchedule(const Shell::Property& property, Schedule& quick) { + // Sub-schedule for 1200Mi strat cap / 9600Mi overall limit + quick.push("lrs+1002_1:8_bd=off:fd=off:hud=10:tnu=1:i=183:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=conj_eager:fd=off:fe=off:kws=frequency:spb=intro:i=4:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cbe=off:chr=on:fsr=off:hfsq=on:nm=64:sos=theory:sp=weighted_frequency:i=27:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:inj=on:i=2:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_aac=none:au=on:cnfonf=lazy_not_gen_be_off:sos=all:i=2:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=2:sos=on:ss=axioms:i=275:si=on:rtra=on_0"); + quick.push("lrs+1004_1:128_cond=on:e2e=on:sp=weighted_frequency:i=18:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bet=on:cnfonf=off:fd=off:hud=5:inj=on:i=3:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_cnfonf=lazy_not_be_gen:hud=14:prag=on:sp=weighted_frequency:tnu=1:i=37:si=on:rtra=on_0"); + quick.push("lrs+2_16:1_acc=model:au=on:bd=off:c=on:e2e=on:nm=2:sos=all:i=15:si=on:rtra=on_0"); + quick.push("dis+21_1:1_cbe=off:cnfonf=off:fs=off:fsr=off:hud=1:inj=on:i=3:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=4203469,65536:i=1041:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:chr=on:plsq=on:slsq=on:i=7:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:amm=sco:cs=on:tgt=full:i=16:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:cnfonf=off:fd=preordered:fe=off:fsr=off:hud=11:inj=on:kws=precedence:s2pl=no:sp=weighted_frequency:tgt=full:i=3:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_apa=on:au=on:bd=preordered:cnfonf=off:cs=on:ixr=off:sos=on:i=3:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=off:cs=on:hud=3:prag=on:sup=off:i=7:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_add=large:cnfonf=lazy_pi_sigma_gen:fe=off:prag=on:i=3:si=on:rtra=on_0"); + quick.push("dis+1004_1:1_cha=on:cs=on:fe=off:hud=1:i=4:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_anc=all_dependent:au=on:cbe=off:fde=unused:ntd=on:i=18:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_e2e=on:sd=1:sgt=8:ss=axioms:i=710:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_chr=on:prag=on:i=6:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_au=on:bd=off:e2e=on:fde=none:fs=off:fsr=off:sos=on:i=902:si=on:rtra=on_0"); + quick.push("dis+21_1:8_apa=on:cnfonf=off:fd=off:fsr=off:hud=0:ins=1:kws=inv_frequency:nwc=10.0:ss=axioms:st=5.0:i=21:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_gen:fe=off:i=5:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_cnfonf=lazy_not_gen_be_off:cs=on:fe=off:hud=10:inj=on:ins=3:plsq=on:plsqc=1:sd=10:ss=axioms:tnu=1:i=6:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_au=on:c=on:fsr=off:piset=equals:i=377:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_atotf=0.2:c=on:cbe=off:cnfonf=lazy_simp:fe=off:ins=2:ntd=on:s2a=on:s2at=5.0:sgt=5:ss=axioms:st=1.5:i=779:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_not_be_gen:ntd=on:sp=const_min:ss=axioms:sup=off:i=19:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:s2a=on:sd=1:sgt=50:ss=axioms:i=879:si=on:rtra=on_0"); + quick.push("dis+1002_1:128_acc=on:er=filter:i=17:si=on:rtra=on_0"); + quick.push("ott+21_1:1_apa=on:au=on:cnfonf=off:sos=on:i=3:si=on:rtra=on_0"); + quick.push("lrs+1010_1:8_cnfonf=off:hud=1:inj=on:tnu=5:i=30:si=on:rtra=on_0"); + quick.push("dis+10_1:1_ixr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:i=127:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cbe=off:cnfonf=conj_eager:cond=on:hi=on:i=100:si=on:rtra=on_0"); + quick.push("dis+10_1:1_anc=none:cnfonf=lazy_gen:fd=preordered:fe=off:hud=10:ins=3:ixr=off:nwc=5.0:plsq=on:plsqc=1:plsqr=32,1:sp=const_frequency:uhcvi=on:i=3:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:avsq=on:e2e=on:ins=3:s2a=on:s2at=3.0:ss=axioms:i=20:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cbe=off:hud=5:nm=4:plsq=on:plsqr=7,1:prag=on:sp=const_max:tnu=1:i=86:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:nm=2:ntd=on:sd=2:ss=axioms:st=5.0:i=107:si=on:rtra=on_0"); + quick.push("lrs+2_1:1024_cnfonf=lazy_gen:fe=off:hud=15:plsq=on:plsqc=1:plsqr=32,1:i=39:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_not_gen:fsr=off:kws=precedence:nwc=5.0:s2a=on:ss=axioms:st=1.5:i=448:si=on:rtra=on_0"); + quick.push("lrs+10_1:512_au=on:fde=unused:lma=on:nm=32:plsq=on:plsqc=1:plsqr=16121663,131072:sfv=off:sp=const_max:ss=axioms:st=3.0:tgt=full:i=46:si=on:rtra=on_0"); + quick.push("lrs+10_1:10_au=on:av=off:cbe=off:cnfonf=lazy_pi_sigma_gen:ntd=on:plsq=on:plsqc=1:plsqr=32,1:i=98:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_apa=on:au=on:bd=off:cnfonf=off:fd=off:sos=on:sp=weighted_frequency:i=507:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_amm=off:fd=preordered:ixr=off:nm=0:pe=on:piset=equals:prag=on:sac=on:tgt=ground:i=149:si=on:rtra=on_0"); + quick.push("lrs+21_1:16_au=on:bd=off:piset=and:i=39:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:gs=on:hud=10:prag=on:tnu=1:i=6:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_aac=none:au=on:e2e=on:nm=2:nwc=10.0:sd=1:ss=axioms:st=3.0:i=1087:si=on:rtra=on_0"); + quick.push("dis+10_1:1_aac=none:cs=on:i=47:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_av=off:cbe=off:cnfonf=lazy_simp:fsr=off:ntd=on:ss=axioms:st=1.5:i=44:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:bd=off:cnfonf=lazy_gen:fe=off:hud=10:plsq=on:plsqc=1:plsqr=32,1:prag=on:tnu=1:i=432:si=on:rtra=on_0"); + quick.push("lrs+10_7:1_cnfonf=lazy_gen:fe=off:nwc=5.0:plsq=on:i=62:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_add=large:amm=off:anc=all_dependent:chr=on:fd=off:ins=2:sp=const_max:tnu=5:uhcvi=on:i=31:si=on:rtra=on_0"); + quick.push("dis+10_1:128_hud=1:i=96:si=on:rtra=on_0"); + quick.push("lrs+1002_1:4_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:hud=15:inj=on:nwc=4.0:s2a=on:sac=on:sp=reverse_arity:i=453:si=on:rtra=on_0"); + quick.push("lrs-1004_1:1_au=on:bsd=on:cbe=off:cnfonf=off:fe=axiom:fsd=on:i=71:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_bd=off:fsr=off:ntd=on:s2a=on:ss=axioms:i=83:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_cnfonf=lazy_not_gen_be_off:hud=1:ins=1:i=11:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_gen_be_off:fsr=off:spb=non_intro:i=41:si=on:rtra=on_0"); + // Improves by expected 2321.3567788514306 probs costing 9599 Mi + // Sub-schedule for 1200Mi strat cap / 9600Mi overall limit + quick.push("lrs+1004_1:1_chr=on:prag=on:i=6:si=on:rtra=on_0"); + quick.push("dis+10_1:1_avsq=on:cnfonf=off:e2e=on:nm=32:i=150:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:s2a=on:sd=7:ss=axioms:st=1.5:i=343:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_cbe=off:chr=on:hfsq=on:hfsqr=1,16:hud=3:sac=on:sp=unary_frequency:ss=axioms:st=5.0:tnu=2:i=109:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:c=on:e2e=on:fsr=off:sos=all:sp=const_frequency:ss=axioms:i=253:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:sd=1:sgt=16:ss=axioms:i=140:si=on:rtra=on_0"); + quick.push("dis+1010_16:1_acc=model:au=on:avsq=on:cond=fast:plsq=on:plsqc=2:plsqr=9267,262144:i=614:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_e2e=on:fde=unused:fe=axiom:prag=on:sd=1:sos=on:ss=axioms:st=2.0:i=202:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cs=on:ins=3:kws=inv_frequency:nwc=10.0:ss=axioms:st=3.0:i=339:si=on:rtra=on_0"); + quick.push("dis+10_1:1_anc=none:cnfonf=lazy_gen:fd=preordered:fe=off:hud=10:ins=3:ixr=off:nwc=5.0:plsq=on:plsqc=1:plsqr=32,1:sp=const_frequency:uhcvi=on:i=283:si=on:rtra=on_0"); + quick.push("dis+2_1:1_cha=on:hud=7:nwc=3.0:prag=on:tnu=2:i=134:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_cnfonf=lazy_simp:fd=off:i=298:si=on:rtra=on_0"); + quick.push("lrs+2_1:8_erd=off:plsq=on:plsqr=32,1:sos=on:i=192:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:hud=1:nm=0:prag=on:sd=2:sgt=32:sos=all:ss=axioms:i=258:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_au=on:cond=fast:ntd=on:piset=and:plsq=on:plsqc=1:plsqr=183491,1048576:sac=on:tgt=ground:i=90:si=on:rtra=on_0"); + quick.push("dis+1004_16:1_avsq=on:avsqr=1,16:cnfonf=lazy_gen:cs=on:fe=off:tgt=ground:tnu=1:i=231:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:s2a=on:sgt=32:slsq=on:slsqc=1:slsql=off:ss=axioms:i=458:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_add=large:amm=off:anc=all_dependent:chr=on:fd=off:ins=2:sp=const_max:tnu=5:uhcvi=on:i=31:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_gen:kws=inv_precedence:nwc=10.0:s2a=on:sp=weighted_frequency:ss=axioms:i=297:si=on:rtra=on_0"); + quick.push("dis+2_1:4_amm=off:au=on:cbe=off:cnfonf=lazy_gen:hfaw=0:hfsq=on:hfsql=off:plsq=on:plsqc=1:plsqr=35,4:sac=on:i=987:si=on:rtra=on_0"); + quick.push("lrs+10_1:1024_avsq=on:avsqc=4:avsqr=584411,1048576:bd=off:bet=on:br=off:chr=on:fsd=on:fsdmm=1:hud=10:nm=0:ntd=on:nwc=9.0:piset=or:plsq=on:plsqc=2:plsql=on:plsqr=852219,1048576:rawr=on:sp=const_frequency:spb=units:i=182:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=none:nwc=10.0:s2a=on:s2at=2.0:i=182:si=on:rtra=on_0"); + quick.push("dis+10_1:8_cha=on:cnfonf=lazy_pi_sigma_gen:fe=axiom:hud=5:plsq=on:plsqr=32,1:prag=on:sos=all:i=154:si=on:rtra=on_0"); + quick.push("dis+1003_1:64_atotf=0.4:au=on:fsr=off:hflw=5:hfsq=on:hfsqc=20:hfsql=off:plsq=on:plsqc=1:plsqr=32,1:i=79:si=on:rtra=on_0"); + quick.push("dis+1010_5:2_anc=all_dependent:awrs=converge:bd=off:bet=on:c=on:cha=on:cnfonf=lazy_not_gen_be_off:fe=axiom:hud=5:kws=precedence:piset=and:prag=on:s2a=on:sac=on:slsq=on:slsqc=1:sp=reverse_arity:ss=axioms:st=1.5:i=216:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_fe=off:hud=10:ins=2:sac=on:sp=const_frequency:i=114:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=on:au=on:bd=off:e2e=on:sgt=8:ss=axioms:i=922:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_au=on:bd=off:cnfonf=lazy_not_gen_be_off:nwc=10.0:piset=and:i=182:si=on:rtra=on_0"); + quick.push("ott+1010_1:1024_au=on:av=off:c=on:cnfonf=conj_eager:piset=equals:s2a=on:sp=occurrence:spb=units:ss=axioms:i=164:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:gs=on:hud=10:prag=on:tnu=1:i=50:si=on:rtra=on_0"); + quick.push("dis-30_1:1_acc=on:bd=off:fsr=off:plsq=on:plsqr=32,1:i=368:si=on:rtra=on_0"); + quick.push("dis+2_1:1_bd=off:e2e=on:hud=1:nm=3:piset=or:prag=on:s2a=on:sp=const_max:i=1021:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_gen:fe=off:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=267:si=on:rtra=on_0"); + quick.push("dis+21_1:5_au=on:ntd=on:nwc=5.0:s2a=on:ss=axioms:st=5.0:i=204:si=on:rtra=on_0"); + quick.push("dis+2_1:1024_atotf=0.0802881:au=on:bs=unit_only:cnfonf=lazy_not_gen_be_off:fde=none:nwc=10.0:prag=on:i=26:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_bd=preordered:c=on:cbe=off:cnfonf=lazy_not_gen_be_off:hud=10:ixr=off:prag=on:i=53:si=on:rtra=on_0"); + // Improves by expected 72.38832436063082 probs costing 9563 Mi + // Sub-schedule for 12000Mi strat cap / 96000Mi overall limit + quick.push("dis+1002_1:1_aac=none:au=on:e2e=on:nm=2:nwc=10.0:sd=1:ss=axioms:st=3.0:i=4436:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_acc=model:avsq=on:ixr=off:prag=on:s2a=on:sac=on:i=1539:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:e2e=on:fde=none:kws=inv_precedence:plsq=on:plsqr=32,1:sos=on:i=408:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=4203469,65536:i=5205:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_au=on:av=off:cbe=off:nwc=10.0:s2a=on:s2at=3.0:sd=2:ss=axioms:st=5.0:i=1913:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:cbe=off:piset=equals:sd=1:sgt=20:sos=all:ss=axioms:i=4350:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_cbe=off:chr=on:hfsq=on:hfsqr=1,16:hud=3:sac=on:sp=unary_frequency:ss=axioms:st=5.0:tnu=2:i=68:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:nwc=5.0:s2a=on:s2at=2.0:sac=on:sd=7:ss=axioms:st=2.0:i=358:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_add=large:amm=off:anc=all_dependent:chr=on:fd=off:ins=2:sp=const_max:tnu=5:uhcvi=on:i=31:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_simp:sgt=5:sos=on:ss=axioms:i=279:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:fde=none:slsq=on:i=258:si=on:rtra=on_0"); + quick.push("dis+2_1:1024_atotf=0.0802881:au=on:bs=unit_only:cnfonf=lazy_not_gen_be_off:fde=none:nwc=10.0:prag=on:i=26:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=995:si=on:rtra=on_0"); + quick.push("dis+10_1:8_amm=sco:cbe=off:hflw=5:hfsq=on:hfsqc=14:hfsql=off:hfsqr=4,1:hud=5:ile=on:lma=on:nm=2:ntd=on:prag=on:sac=on:sp=frequency:i=373:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:cnfonf=lazy_pi_sigma_gen:hflw=4:hfsq=on:hfsqc=20:hfsql=off:i=253:si=on:rtra=on_0"); + quick.push("lrs+1002_1:14_au=on:bd=off:e2e=on:fde=unused:sac=on:sos=on:i=832:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_chr=on:cnfonf=lazy_not_be_gen:gs=on:hud=5:plsq=on:plsqc=1:plsqr=5,1:prag=on:rawr=on:i=668:si=on:rtra=on_0"); + quick.push("dis+10_1:1_anc=none:cnfonf=lazy_gen:fd=preordered:fe=off:hud=10:ins=3:ixr=off:nwc=5.0:plsq=on:plsqc=1:plsqr=32,1:sp=const_frequency:uhcvi=on:i=40:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_cnfonf=lazy_pi_sigma_gen:fd=off:ntd=on:sd=1:sgt=32:sos=on:ss=axioms:i=294:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_avsq=on:fe=off:fsr=off:hud=10:plsq=on:plsqr=32,1:prag=on:i=187:si=on:rtra=on_0"); + quick.push("lrs+1010_2:3_au=on:fsr=off:sd=4:ss=axioms:st=1.5:i=371:si=on:rtra=on_0"); + quick.push("dis+1003_1:1_au=on:bd=preordered:fde=none:ixr=off:nwc=10.0:i=1827:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:cnfonf=lazy_gen:fe=off:hud=10:plsq=on:plsqc=1:plsqr=32,1:tnu=1:i=70:si=on:rtra=on_0"); + quick.push("lrs+10_1:20_bd=off:cnfonf=lazy_not_be_gen:fe=axiom:hud=10:ins=1:nm=20:prag=on:sos=on:i=316:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=lazy_gen:fe=off:plsq=on:plsqc=1:plsqr=3548551,65536:s2a=on:i=932:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:bd=preordered:cnfonf=lazy_pi_sigma_gen:plsq=on:plsqc=1:plsqr=32,1:sos=all:sp=occurrence:i=4714:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=none:nwc=10.0:s2a=on:s2at=2.0:i=8250:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:cnfonf=off:fd=off:flr=on:hud=1:lcm=reverse:prag=on:sd=1:sos=on:ss=axioms:i=770:si=on:rtra=on_0"); + quick.push("ott+1010_5:1_av=off:fe=off:ins=1:kws=precedence:sp=reverse_arity:i=794:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:avsq=on:avsqr=1,16:cond=on:sp=frequency:i=464:si=on:rtra=on_0"); + quick.push("ott+21_1:3_avsq=on:bd=off:cnfonf=lazy_gen:fe=off:hud=10:ixr=off:plsq=on:plsqc=1:plsqr=32,1:prag=on:tnu=1:i=1376:si=on:rtra=on_0"); + quick.push("dis+10_1:1_etr=on:plsq=on:plsqc=1:plsqr=32,1:i=906:si=on:rtra=on_0"); + quick.push("lrs+1002_1:16_bd=off:e2e=on:fde=unused:kws=precedence:sac=on:sos=on:ss=axioms:i=434:si=on:rtra=on_0"); + quick.push("lrs+10_5:4_cnfonf=conj_eager:fe=axiom:hflw=5:hfsq=on:hfsqc=10:hfsql=off:hud=10:plsq=on:sgt=5:spb=goal_then_units:ss=axioms:i=865:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cnfonf=lazy_simp:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=593:si=on:rtra=on_0"); + quick.push("dis+10_1:1_sd=2:sgt=20:slsq=on:ss=axioms:st=6.0:i=443:si=on:rtra=on_0"); + quick.push("dis+10_1:1_atotf=0.1:cbe=off:sd=3:ss=axioms:st=2.0:i=594:si=on:rtra=on_0"); + quick.push("ott+10_1:1024_anc=none:bd=off:e2e=on:fde=none:fsr=off:hud=10:ixr=off:nm=4:nwc=5.0:spb=goal:i=327:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=2:sos=on:ss=axioms:i=5411:si=on:rtra=on_0"); + quick.push("lrs+10_1:20_au=on:c=on:cbe=off:cnfonf=lazy_gen:ins=1:plsq=on:plsqc=1:plsqr=46,31:sac=on:i=1762:si=on:rtra=on_0"); + quick.push("dis+1003_1:64_cha=on:cnfonf=lazy_gen:hud=9:nwc=8.0:prag=on:i=96:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_hud=5:kws=inv_frequency:nm=16:nwc=2.0:prag=on:sos=on:ss=axioms:i=503:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_au=on:cond=fast:ntd=on:piset=and:plsq=on:plsqc=1:plsqr=183491,1048576:sac=on:tgt=ground:i=90:si=on:rtra=on_0"); + quick.push("lrs+10_1:64_hud=5:plsq=on:plsqr=2011171,524288:i=593:si=on:rtra=on_0"); + quick.push("dis-1002_1:1_alpa=false:apa=on:au=on:bd=off:cnfonf=off:e2e=on:er=filter:fde=unused:plsq=on:plsqr=9699663,1048576:s2a=on:sos=on:sp=unary_first:i=1512:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_cbe=off:cnfonf=lazy_not_gen_be_off:ins=1:i=569:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_bd=off:cnfonf=off:e2e=on:fd=off:fe=axiom:hud=5:prag=on:sos=on:i=501:si=on:rtra=on_0"); + quick.push("lrs+1010_1:3_cnfonf=conj_eager:fsr=off:prag=on:sd=4:sgt=10:ss=axioms:i=562:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:fde=unused:kws=precedence:tgt=full:i=406:si=on:rtra=on_0"); + quick.push("dis+1004_1:128_au=on:cbe=off:e2e=on:sac=on:i=582:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:bd=off:bsr=unit_only:sd=2:sgt=32:sos=all:ss=axioms:i=456:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=conj_eager:tgt=ground:i=393:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_au=on:cnfonf=conj_eager:nwc=10.0:pe=on:prag=on:s2a=on:ss=axioms:st=1.5:i=1335:si=on:rtra=on_0"); + quick.push("dis+1010_16:1_acc=model:au=on:avsq=on:cond=fast:plsq=on:plsqc=2:plsqr=9267,262144:i=3373:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=32,1:spb=goal_then_units:i=474:si=on:rtra=on_0"); + quick.push("lrs+1002_1:16_amm=sco:cnfonf=lazy_pi_sigma_gen:fe=off:nm=60:piset=all_but_not_eq:plsq=on:plsqc=1:plsqr=2,1:rawr=on:sp=occurrence:ss=included:st=-1.0:i=157:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_amm=off:cs=on:kws=precedence:nwc=10.0:piset=all:s2a=on:sac=on:sp=unary_frequency:spb=goal:ss=axioms:st=3.0:i=590:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_kws=precedence:prag=on:rawr=on:sos=all:sp=unary_first:i=104:si=on:rtra=on_0"); + quick.push("lrs+1010_1:10_au=on:bd=off:cnfonf=lazy_pi_sigma_gen:sp=occurrence:i=414:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:bsd=on:bsr=unit_only:fd=off:hud=8:nm=16:prag=on:i=715:si=on:rtra=on_0"); + quick.push("dis+21_1:5_au=on:ntd=on:nwc=5.0:s2a=on:ss=axioms:st=5.0:i=961:si=on:rtra=on_0"); + quick.push("lrs-1002_1:128_abs=on:bd=preordered:cbe=off:e2e=on:fde=unused:fe=off:tgt=full:i=1213:si=on:rtra=on_0"); + quick.push("lrs+1002_1:12_bd=off:hud=1:ntd=on:piset=equals:prag=on:i=1979:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_amm=off:au=on:bsd=on:cbe=off:cnfonf=lazy_gen:sp=unary_frequency:i=481:si=on:rtra=on_0"); + quick.push("dis+10_8:1_apa=on:cnfonf=off:e2e=on:plsq=on:plsqc=1:plsqr=32,1:ss=axioms:i=783:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_avsq=on:avsqr=1,16:kws=inv_arity:nwc=5.0:sd=1:ss=axioms:i=432:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_atotf=0.5:au=on:cbe=off:cnfonf=lazy_not_be_gen:fe=off:nwc=5.0:spb=units:i=1670:si=on:rtra=on_0"); + quick.push("dis+2_1:1_au=on:hfaw=0:hfsq=on:sp=weighted_frequency:i=90:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:cnfonf=lazy_gen:ixr=off:plsq=on:plsqc=1:plsqr=32,1:i=346:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cnfonf=lazy_not_gen:hud=10:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=401:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:s2a=on:sd=1:sgt=50:ss=axioms:i=6454:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_avsq=on:fe=off:fsr=off:hud=10:kws=arity:prag=on:i=283:si=on:rtra=on_0"); + quick.push("ott+10_1:1_aac=none:apa=on:au=on:cnfonf=off:ntd=on:nwc=12.0:sos=on:i=865:si=on:rtra=on_0"); + quick.push("lrs+1002_3:4_au=on:av=off:cnfonf=off:fd=off:fsr=off:ins=2:sd=1:sos=on:ss=axioms:i=4528:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cbe=off:hud=5:nm=4:plsq=on:plsqr=7,1:prag=on:sp=const_max:tnu=1:i=1001:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cbe=off:cnfonf=conj_eager:cond=on:hi=on:i=102:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_nm=20:s2a=on:s2at=3.0:sp=const_frequency:i=952:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1024_add=large:c=on:cbe=off:cnfonf=lazy_gen:fde=none:nm=30:piset=and:sac=on:uhcvi=on:i=578:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_avsq=on:avsqr=16,1:bet=on:cbe=off:cnfonf=lazy_not_be_gen:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=643:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_cnfonf=off:ntd=on:nwc=3.0:s2a=on:sp=const_frequency:i=865:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:erd=off:s2a=on:s2at=3.0:sos=all:i=1174:si=on:rtra=on_0"); + quick.push("ott+1010_1:32_apa=on:atotf=0.3:au=on:c=on:cnfonf=off:fe=off:fsr=off:nm=6:piset=or:sac=on:sos=on:i=644:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_alpa=true:au=on:cs=on:tgt=ground:i=1201:si=on:rtra=on_0"); + quick.push("lrs+1666_1:64_cnfonf=lazy_simp:hud=5:plsq=on:plsql=on:plsqr=152565,524288:tnu=2:i=1046:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_c=on:cnfonf=lazy_simp:fsr=off:hud=5:kws=arity:nm=32:plsq=on:plsqc=1:plsqr=642,29:prag=on:i=222:si=on:rtra=on_0"); + // Improves by expected 228.8984796945416 probs costing 95986 Mi + // Sub-schedule for 12000Mi strat cap / 96000Mi overall limit + quick.push("ott+1010_1:4_cbe=off:chr=on:hfsq=on:hfsqr=1,16:hud=3:sac=on:sp=unary_frequency:ss=axioms:st=5.0:tnu=2:i=68:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_chr=on:cnfonf=lazy_not_be_gen:gs=on:hud=5:plsq=on:plsqc=1:plsqr=5,1:prag=on:rawr=on:i=454:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cnfonf=lazy_simp:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=360:si=on:rtra=on_0"); + quick.push("lrs+1002_1:16_amm=sco:cnfonf=lazy_pi_sigma_gen:fe=off:nm=60:piset=all_but_not_eq:plsq=on:plsqc=1:plsqr=2,1:rawr=on:sp=occurrence:ss=included:st=-1.0:i=157:si=on:rtra=on_0"); + quick.push("ott+1004_1:24_anc=none:cbe=off:cnfonf=lazy_not_gen:fe=off:piset=not:prag=on:rp=on:i=5061:si=on:rtra=on_0"); + quick.push("lrs+1002_1:8_av=off:fd=off:hud=5:tnu=1:i=2401:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:e2e=on:nm=4:s2a=on:i=5798:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:cnfonf=lazy_gen:ixr=off:plsq=on:plsqc=1:plsqr=32,1:i=346:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_av=off:bd=off:bet=on:e2e=on:fde=unused:fe=off:plsq=on:prag=on:sos=on:i=1321:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_gen:kws=inv_precedence:nwc=10.0:i=1312:si=on:rtra=on_0"); + quick.push("ott+2_8:1_add=large:c=on:cnfonf=off:e2e=on:er=filter:hud=5:plsq=on:plsqr=1,1:ss=axioms:i=672:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:c=on:e2e=on:fsr=off:sos=all:sp=const_frequency:ss=axioms:i=1897:si=on:rtra=on_0"); + quick.push("lrs+10_1:40_av=off:fde=unused:ntd=on:plsq=on:plsqc=2:plsqr=411915,1048576:sp=unary_frequency:tgt=full:i=1202:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:cnfonf=lazy_pi_sigma_gen:hfsq=on:hfsqc=40:hfsqr=8,1:ntd=on:sos=on:sp=occurrence:ss=axioms:i=1493:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_av=off:fde=unused:hud=10:nwc=10.0:s2a=on:ss=axioms:i=7679:si=on:rtra=on_0"); + quick.push("lrs+2_1:1024_anc=all:cnfonf=off:cs=on:e2e=on:nm=20:s2at=1.5:slsq=on:slsqr=1,2:spb=goal:i=340:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=model:au=on:nwc=5.0:sd=5:ss=axioms:st=2.5:i=3672:si=on:rtra=on_0"); + quick.push("dis-1002_3:1_acc=model:bd=off:bsd=on:bsdmm=1:cnfonf=lazy_not_be_gen:fd=off:fe=off:ntd=on:nwc=10.0:piset=equals:plsq=on:plsqc=1:plsqr=32,1:sp=const_max:uhcvi=on:i=1535:si=on:rtra=on_0"); + quick.push("dis+10_16:1_hud=1:plsq=on:plsqc=1:plsqr=32,1:prag=on:sd=1:sgt=64:ss=axioms:i=4637:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_fde=unused:prag=on:sd=2:sgt=32:ss=axioms:i=3174:si=on:rtra=on_0"); + quick.push("lrs+1010_1:10_au=on:bd=off:cnfonf=lazy_pi_sigma_gen:sp=occurrence:i=307:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_au=on:bd=off:e2e=on:fde=none:fs=off:fsr=off:sos=on:i=3619:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cbe=off:fde=none:ins=1:sp=const_max:i=2325:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:sac=on:sd=5:slsq=on:slsqr=1,4:ss=axioms:st=2.0:i=2341:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_apa=on:bsd=on:cnfonf=off:hud=10:sac=on:sos=on:ss=axioms:i=7257:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=lazy_gen:fe=off:plsq=on:plsqc=1:plsqr=3548551,65536:s2a=on:i=3710:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_avsq=on:avsqr=1,16:kws=inv_arity:nwc=5.0:sd=1:ss=axioms:i=326:si=on:rtra=on_0"); + quick.push("lrs+1010_1:64_au=on:c=on:e2e=on:flr=on:hfsq=on:hfsql=off:hfsqr=4,1:ins=1:ntd=on:sp=occurrence:i=1100:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:fde=unused:kws=precedence:tgt=full:i=406:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_aac=none:bd=preordered:e2e=on:fde=none:fe=axiom:nm=16:nwc=10.0:prag=on:i=1871:si=on:rtra=on_0"); + quick.push("dis+2_1:1_bd=off:e2e=on:hud=1:nm=3:piset=or:prag=on:s2a=on:sp=const_max:i=1194:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=32,1:spb=goal_then_units:i=474:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=lazy_gen:ins=3:plsq=on:plsqc=1:plsqr=15142123,262144:sp=reverse_arity:i=3115:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_kws=precedence:prag=on:rawr=on:sos=all:sp=unary_first:i=831:si=on:rtra=on_0"); + quick.push("dis+1666_14:1_cnfonf=lazy_gen:fe=off:hud=10:piset=all_but_not_eq:prag=on:sp=const_max:i=1188:si=on:rtra=on_0"); + quick.push("ott+1010_1:20_cnfonf=lazy_pi_sigma_gen:fe=axiom:plsq=on:plsqc=2:plsqr=32,1:sac=on:sos=all:i=2868:si=on:rtra=on_0"); + quick.push("dis+10_1:4_atotf=0.1:avsq=on:bsr=unit_only:e2e=on:sd=1:sp=const_max:ss=axioms:i=1516:si=on:rtra=on_0"); + quick.push("lrs+1002_1:20_afp=1000:au=on:bsd=on:cnfonf=lazy_not_gen_be_off:sos=all:sp=const_max:i=2321:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:bd=off:bsd=on:ixr=off:sp=const_max:i=2812:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_bd=off:sd=1:sgt=16:ss=axioms:i=4604:si=on:rtra=on_0"); + quick.push("ott+1002_1:4_c=on:chr=on:cnfonf=lazy_not_be_gen:hud=10:nm=10:piset=all_but_not_eq:rp=on:spb=goal:uhcvi=on:i=2678:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_avsq=on:avsqr=16,1:bet=on:cbe=off:cnfonf=lazy_not_be_gen:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=643:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=458:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_anc=all_dependent:apa=on:au=on:bd=off:c=on:cnfonf=off:ntd=on:i=2546:si=on:rtra=on_0"); + quick.push("dis+21_1:1_acc=model:au=on:cnfonf=lazy_gen:ins=2:plsq=on:plsqc=1:plsqr=32,1:i=1432:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cnfonf=lazy_not_gen:hud=10:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=386:si=on:rtra=on_0"); + // Improves by expected 56.1663357045758 probs costing 95861 Mi + // Sub-schedule for 120000Mi strat cap / 960000Mi overall limit + quick.push("dis+1002_1:1_cnfonf=lazy_simp:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=360:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cbe=off:chr=on:fsr=off:hfsq=on:nm=64:sos=theory:sp=weighted_frequency:i=5446:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_gen:fe=off:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=2573:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:cnfonf=lazy_gen:fe=off:hud=10:plsq=on:plsqc=1:plsqr=32,1:tnu=1:i=2655:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_apa=on:au=on:av=off:cnfonf=off:e2e=on:nm=0:nwc=10.0:i=2781:si=on:rtra=on_0"); + quick.push("lrs+1010_1:10_au=on:bd=off:cnfonf=lazy_pi_sigma_gen:sp=occurrence:i=307:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_avsq=on:avsqr=1,16:kws=inv_arity:nwc=5.0:sd=1:ss=axioms:i=1548:si=on:rtra=on_0"); + quick.push("lrs+10_1:3_alpa=true:hud=3:ins=1:ntd=on:plsq=on:plsqc=1:plsqr=32,1:prag=on:s2a=on:s2agt=10:i=5214:si=on:rtra=on_0"); + quick.push("dis+21_1:1_aac=none:bsr=on:nwc=3.0:s2a=on:i=3201:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_chr=on:cnfonf=lazy_not_be_gen:gs=on:hud=5:plsq=on:plsqc=1:plsqr=5,1:prag=on:rawr=on:i=454:si=on:rtra=on_0"); + quick.push("lrs+1002_1:32_au=on:ins=2:nm=16:ntd=on:piset=all_but_not_eq:sp=occurrence:i=3049:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=preordered:cnfonf=off:e2e=on:kws=inv_precedence:lwlo=on:sd=2:ss=axioms:i=7311:si=on:rtra=on_0"); + quick.push("lrs+1002_1:14_au=on:bd=off:e2e=on:fde=unused:sac=on:sos=on:i=6804:si=on:rtra=on_0"); + quick.push("dis+1003_1:1_au=on:bd=preordered:fde=none:ixr=off:nwc=10.0:i=1683:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:av=off:bd=off:cs=on:e2e=on:hfsq=on:hfsqc=50:hfsql=off:nm=0:i=4688:si=on:rtra=on_0"); + quick.push("dis-1_1:1_amm=off:au=on:cbe=off:spb=intro:i=2207:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_atotf=0.2:c=on:cbe=off:cnfonf=lazy_simp:fe=off:ins=2:ntd=on:s2a=on:s2at=5.0:sgt=5:ss=axioms:st=1.5:i=8216:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_atotf=0.5:au=on:cbe=off:cnfonf=lazy_not_be_gen:fe=off:nwc=5.0:spb=units:i=430:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:gs=on:hud=10:prag=on:tnu=1:i=2012:si=on:rtra=on_0"); + quick.push("ott+1010_1:32_apa=on:atotf=0.3:au=on:c=on:cnfonf=off:fe=off:fsr=off:nm=6:piset=or:sac=on:sos=on:i=631:si=on:rtra=on_0"); + quick.push("dis+2_1:1_bd=off:e2e=on:hud=1:nm=3:piset=or:prag=on:s2a=on:sp=const_max:i=8785:si=on:rtra=on_0"); + quick.push("lrs-1002_1:128_abs=on:bd=preordered:cbe=off:e2e=on:fde=unused:fe=off:tgt=full:i=739:si=on:rtra=on_0"); + quick.push("dis+1002_1:1024_fe=off:hud=5:prag=on:i=5473:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=2:sos=on:ss=axioms:i=43570:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_amm=off:fd=preordered:ixr=off:nm=0:pe=on:piset=equals:prag=on:sac=on:tgt=ground:i=8382:si=on:rtra=on_0"); + quick.push("dis-30_1:1_acc=on:bd=off:fsr=off:plsq=on:plsqr=32,1:i=407:si=on:rtra=on_0"); + quick.push("lrs+10_1:50_cbe=off:cnfonf=lazy_pi_sigma_gen:fe=off:hud=5:plsq=on:plsqr=1,32:sos=all:i=2971:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:bd=off:e2e=on:fde=none:fe=off:piset=or:prag=on:rawr=on:sos=on:updr=off:i=9822:si=on:rtra=on_0"); + quick.push("dis+10_5:1_av=off:ntd=on:s2a=on:s2at=3.0:sgt=16:sp=unary_frequency:ss=axioms:i=8425:si=on:rtra=on_0"); + quick.push("lrs+30_1:1_aac=none:au=on:cbe=off:cs=on:nm=2:rawr=on:sos=on:i=3107:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_aac=none:au=on:cnfonf=lazy_not_gen_be_off:sos=all:i=7967:si=on:rtra=on_0"); + quick.push("lrs+1010_10:959_abs=on:acc=on:bd=off:ccuc=small_ones:cha=on:cnfonf=lazy_simp:fd=preordered:fe=off:hud=3:ile=on:kws=inv_frequency:nm=2:piset=and:sd=5:sp=frequency:spb=goal_then_units:ss=axioms:st=4.5:i=3629:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1024_au=on:fe=axiom:lwlo=on:nm=0:ntd=on:nwc=10.0:spb=non_intro:uhcvi=on:i=939:si=on:rtra=on_0"); + quick.push("dis+1666_14:1_cnfonf=lazy_gen:fe=off:hud=10:piset=all_but_not_eq:prag=on:sp=const_max:i=1188:si=on:rtra=on_0"); + quick.push("dis+21_3:2_avsq=on:cbe=off:e2e=on:flr=on:ile=on:nwc=5.0:piset=or:rawr=on:sp=occurrence:i=3205:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_cnfonf=off:ntd=on:nwc=3.0:s2a=on:sp=const_frequency:i=865:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:bd=off:cbe=off:cha=on:cnfonf=lazy_pi_sigma_gen:fd=off:fe=off:ntd=on:sp=const_frequency:i=7469:si=on:rtra=on_0"); + quick.push("dis+10_1:10_bd=preordered:e2e=on:fde=none:fe=axiom:hud=3:kws=precedence:nwc=3.0:prag=on:sp=const_max:tgt=full:i=4165:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:avsq=on:cnfonf=lazy_simp:fsr=off:ntd=on:nwc=10.0:sp=reverse_frequency:ss=axioms:st=1.5:i=13468:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:bsr=unit_only:cbe=off:fe=off:fsr=off:nm=10:nwc=6.0:plsq=on:plsqc=1:plsqr=32,1:sos=all:i=2635:si=on:rtra=on_0"); + quick.push("dis+1010_1:4_avsq=on:avsqr=16,1:bet=on:cbe=off:cnfonf=lazy_not_be_gen:hud=5:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=631:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=4203469,65536:i=15557:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:sac=on:sd=5:slsq=on:slsqr=1,4:ss=axioms:st=2.0:i=2142:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_aac=none:au=on:bd=off:cnfonf=conj_eager:nwc=5.0:sgt=5:sp=reverse_arity:ss=axioms:i=5624:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=1665:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_av=off:prag=on:sd=1:sos=on:sp=occurrence:ss=axioms:i=64912:si=on:rtra=on_0"); + quick.push("lrs+10_1:32_atotf=0.1:avsq=on:bsr=on:cnfonf=lazy_gen:fde=unused:i=7801:si=on:rtra=on_0"); + quick.push("ott+2_1:1_au=on:hfsq=on:hfsqc=5:hfsql=off:nwc=5.0:sd=3:ss=axioms:st=5.0:i=15194:si=on:rtra=on_0"); + quick.push("dis-1002_1:1_alpa=false:apa=on:au=on:bd=off:cnfonf=off:e2e=on:er=filter:fde=unused:plsq=on:plsqr=9699663,1048576:s2a=on:sos=on:sp=unary_first:i=6753:si=on:rtra=on_0"); + quick.push("lrs+1002_1:28_bd=off:cnfonf=lazy_simp:plsq=on:plsqr=1,1:prag=on:i=1003:si=on:rtra=on_0"); + quick.push("ott-21_5:4_atotf=0.3:e2e=on:hud=15:ins=1:plsq=on:plsqc=1:plsqr=32,1:sp=unary_frequency:tnu=2:i=13018:si=on:rtra=on_0"); + quick.push("dis+10_1:4_atotf=0.1:avsq=on:bsr=unit_only:e2e=on:sd=1:sp=const_max:ss=axioms:i=1267:si=on:rtra=on_0"); + quick.push("lrs+10_1:20_au=on:c=on:cbe=off:cnfonf=lazy_gen:ins=1:plsq=on:plsqc=1:plsqr=46,31:sac=on:i=2570:si=on:rtra=on_0"); + quick.push("lrs+1004_1:128_cond=on:e2e=on:sp=weighted_frequency:i=13163:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_au=on:s2a=on:sd=2:ss=axioms:st=5.0:i=5087:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:bd=off:cnfonf=lazy_pi_sigma_gen:s2a=on:sac=on:sd=1:sgt=20:ss=axioms:i=10380:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:cbe=off:piset=equals:sd=1:sgt=20:sos=all:ss=axioms:i=4218:si=on:rtra=on_0"); + quick.push("ott+1666_1:1_hfaw=0:hfsq=on:hfsql=off:hfsqr=1,16:hud=15:slsq=on:slsqr=1,2:tnu=2:i=3971:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:bs=on:sd=5:sp=occurrence:ss=axioms:st=2.0:i=14014:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_ins=1:sgt=8:ss=axioms:i=8517:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:e2e=on:nm=4:s2a=on:i=10148:si=on:rtra=on_0"); + quick.push("lrs+10_1:2_ntd=on:nwc=10.0:plsq=on:plsqc=1:plsqr=2,1:ss=axioms:i=9078:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bet=on:bsr=on:cnfonf=lazy_pi_sigma_gen:er=filter:kws=inv_frequency:ntd=on:sd=3:ss=axioms:i=16164:si=on:rtra=on_0"); + quick.push("lrs+32_1:1_au=on:bet=on:cbe=off:cs=on:ins=3:i=6102:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:e2e=on:fde=unused:nm=4:s2a=on:sos=all:sp=const_frequency:i=10308:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:avsq=on:bd=off:cbe=off:cnfonf=off:cs=on:hud=5:nm=0:plsq=on:plsqc=1:plsqr=7,1:ss=axioms:tgt=full:i=4041:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=model:au=on:nwc=5.0:sd=5:ss=axioms:st=2.5:i=6901:si=on:rtra=on_0"); + quick.push("lrs-1_1:1_au=on:cbe=off:ntd=on:i=5576:si=on:rtra=on_0"); + quick.push("lrs+1002_1:8_bd=off:fd=off:hud=10:tnu=1:i=2014:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=lazy_gen:fe=off:plsq=on:plsqc=1:plsqr=3548551,65536:s2a=on:i=5115:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:cnfonf=lazy_pi_sigma_gen:sos=on:ss=axioms:i=13001:si=on:rtra=on_0"); + quick.push("dis+10_1:2_aac=none:acc=on:atotf=0.1:au=on:fde=none:ins=1:ixr=off:nwc=5.0:i=11105:si=on:rtra=on_0"); + quick.push("dis+10_1:1_anc=none:cnfonf=lazy_gen:fd=preordered:fe=off:hud=10:ins=3:ixr=off:nwc=5.0:plsq=on:plsqc=1:plsqr=32,1:sp=const_frequency:uhcvi=on:i=13832:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:s2a=on:sd=1:sgt=50:ss=axioms:i=32887:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_avsq=on:fde=unused:prag=on:i=3362:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=lazy_simp:nwc=5.0:sgt=5:ss=axioms:st=1.5:i=24965:si=on:rtra=on_0"); + quick.push("lrs+1010_2:1_amm=off:avsq=on:c=on:cbe=off:e2e=on:fsr=off:ins=3:s2a=on:s2at=-1.0:i=15705:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_au=on:cnfonf=conj_eager:nwc=10.0:pe=on:prag=on:s2a=on:ss=axioms:st=1.5:i=1536:si=on:rtra=on_0"); + quick.push("dis+10_1:1_fde=none:kws=precedence:piset=not:prag=on:slsq=on:slsqc=1:sp=unary_frequency:i=23684:si=on:rtra=on_0"); + quick.push("ott+1004_1:24_anc=none:cbe=off:cnfonf=lazy_not_gen:fe=off:piset=not:prag=on:rp=on:i=4925:si=on:rtra=on_0"); + quick.push("lrs-1010_1:50_au=on:awrs=converge:awrsf=430:bet=on:cbe=off:cha=on:nm=20:sac=on:i=14666:si=on:rtra=on_0"); + quick.push("lrs+1002_1:4_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:hud=15:inj=on:nwc=4.0:s2a=on:sac=on:sp=reverse_arity:i=3322:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_gen:kws=inv_precedence:nwc=10.0:i=1810:si=on:rtra=on_0"); + quick.push("dis+1666_1:1_anc=none:bs=on:cbe=off:cha=on:cnfonf=lazy_gen:fe=off:fsr=off:hud=5:kws=precedence:piset=pi_sigma:prag=on:sos=on:sp=frequency:i=2465:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cbe=off:cnfonf=lazy_pi_sigma_gen:fsr=off:ins=1:kws=inv_precedence:nwc=10.0:ss=axioms:st=2.0:i=41234:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:nm=0:i=14027:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=conj_eager:nwc=10.0:sac=on:i=27021:si=on:rtra=on_0"); + quick.push("dis-1666_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:i=5643:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_apa=on:au=on:cnfonf=off:e2e=on:flr=on:nm=4:s2a=on:i=8612:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=none:nwc=10.0:s2a=on:s2at=2.0:i=3743:si=on:rtra=on_0"); + quick.push("dis+10_1:2_amm=off:bd=preordered:cnfonf=off:e2e=on:fe=off:fsr=off:hud=5:nm=3:s2a=on:sos=on:i=2571:si=on:rtra=on_0"); + quick.push("dis+1010_1:16_cbe=off:cnfonf=conj_eager:fe=off:hud=15:nwc=3.0:piset=pi_sigma:prag=on:sd=5:sp=weighted_frequency:ss=axioms:st=2.0:i=35728:si=on:rtra=on_0"); + quick.push("lrs+1004_1:24_i=5433:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_anc=all_dependent:au=on:avsq=on:cnfonf=lazy_pi_sigma_gen:piset=not:i=27944:si=on:rtra=on_0"); + quick.push("ott+10_1:10_cnfonf=lazy_gen:fde=none:sp=const_frequency:i=15814:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_atotf=0.1:au=on:cbe=off:ntd=on:sp=const_frequency:i=9867:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=32,1:spb=goal_then_units:i=5419:si=on:rtra=on_0"); + quick.push("dis+1010_1:28_au=on:cnfonf=off:e2e=on:fde=none:nicw=on:s2a=on:s2at=5.0:tgt=full:i=15386:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:bd=preordered:cnfonf=lazy_pi_sigma_gen:plsq=on:plsqc=1:plsqr=32,1:sos=all:sp=occurrence:i=4714:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:c=on:fsr=off:ntd=on:prag=on:sd=1:sos=all:ss=axioms:st=5.0:i=42749:si=on:rtra=on_0"); + quick.push("lrs+10_1:156_afp=4000:avsq=on:avsqr=4,1:fe=axiom:ss=axioms:tgt=ground:i=19001:si=on:rtra=on_0"); + quick.push("lrs+1_1:1_au=on:cbe=off:cs=on:nm=4:i=14341:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=off:sd=1:ss=axioms:st=3.0:i=13159:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_e2e=on:fde=unused:fe=axiom:prag=on:sd=1:sos=on:ss=axioms:st=2.0:i=6604:si=on:rtra=on_0"); + // Improves by expected 96.50411951866694 probs costing 957886 Mi + // Sub-schedule for 120000Mi strat cap / 960000Mi overall limit + quick.push("dis+1002_1:1_au=on:bsr=unit_only:cbe=off:fe=off:fsr=off:nm=10:nwc=6.0:plsq=on:plsqc=1:plsqr=32,1:sos=all:i=2635:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_au=on:s2a=on:sd=2:ss=axioms:st=5.0:i=41131:si=on:rtra=on_0"); + quick.push("ott+1666_1:1_hfaw=0:hfsq=on:hfsql=off:hfsqr=1,16:hud=15:slsq=on:slsqr=1,2:tnu=2:i=3971:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:sac=on:sd=5:slsq=on:slsqr=1,4:ss=axioms:st=2.0:i=2142:si=on:rtra=on_0"); + quick.push("dis-1_1:1_amm=off:au=on:cbe=off:spb=intro:i=1314:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_avsq=on:fde=unused:prag=on:i=3362:si=on:rtra=on_0"); + quick.push("lrs+1002_1:14_au=on:bd=off:e2e=on:fde=unused:sac=on:sos=on:i=5756:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=lazy_gen:plsq=on:plsqc=1:plsqr=4203469,65536:i=2607:si=on:rtra=on_0"); + quick.push("ott+2_1:1_au=on:hfsq=on:hfsqc=5:hfsql=off:nwc=5.0:sd=3:ss=axioms:st=5.0:i=15187:si=on:rtra=on_0"); + quick.push("dis-1666_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:i=21027:si=on:rtra=on_0"); + quick.push("lrs+1004_1:128_cond=on:e2e=on:sp=weighted_frequency:i=35698:si=on:rtra=on_0"); + quick.push("lrs-1010_1:50_au=on:awrs=converge:awrsf=430:bet=on:cbe=off:cha=on:nm=20:sac=on:i=14573:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:bs=on:sd=5:sp=occurrence:ss=axioms:st=2.0:i=14014:si=on:rtra=on_0"); + quick.push("dis+10_1:10_bd=preordered:e2e=on:fde=none:fe=axiom:hud=3:kws=precedence:nwc=3.0:prag=on:sp=const_max:tgt=full:i=4165:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_apa=on:au=on:cnfonf=off:e2e=on:flr=on:nm=4:s2a=on:i=8612:si=on:rtra=on_0"); + quick.push("lrs-1_1:1_au=on:cbe=off:ntd=on:i=5576:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=none:nwc=10.0:s2a=on:s2at=2.0:i=4408:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_av=off:prag=on:sd=1:sos=on:sp=occurrence:ss=axioms:i=13925:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:e2e=on:fde=unused:nm=4:s2a=on:sos=all:sp=const_frequency:i=117046:si=on:rtra=on_0"); + quick.push("lrs+1004_1:24_i=5433:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:nm=0:i=8192:si=on:rtra=on_0"); + quick.push("lrs+32_1:1_au=on:bet=on:cbe=off:cs=on:ins=3:i=6102:si=on:rtra=on_0"); + quick.push("lrs+1002_8:1_au=on:cs=on:e2e=on:nm=10:s2a=on:i=35602:si=on:rtra=on_0"); + quick.push("ott+1004_1:24_anc=none:cbe=off:cnfonf=lazy_not_gen:fe=off:piset=not:prag=on:rp=on:i=6101:si=on:rtra=on_0"); + quick.push("dis+1010_3039923:1048576_bsr=unit_only:cbe=off:cha=on:cnfonf=off:e2e=on:fsr=off:hud=1:ixr=off:kws=precedence:lma=on:nm=4:piset=or:s2a=on:sp=frequency:spb=goal_then_units:i=28153:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=off:sd=1:ss=axioms:st=3.0:i=13159:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bet=on:bsr=on:cnfonf=lazy_pi_sigma_gen:er=filter:kws=inv_frequency:ntd=on:sd=3:ss=axioms:i=12389:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:nwc=5.0:i=37202:si=on:rtra=on_0"); + quick.push("ott+10_1:10_cnfonf=lazy_gen:fde=none:sp=const_frequency:i=15814:si=on:rtra=on_0"); + quick.push("dis+1010_1:28_add=off:cnfonf=lazy_not_gen:kws=frequency:piset=all:i=8801:si=on:rtra=on_0"); + quick.push("ott-21_5:4_atotf=0.3:e2e=on:hud=15:ins=1:plsq=on:plsqc=1:plsqr=32,1:sp=unary_frequency:tnu=2:i=12360:si=on:rtra=on_0"); + quick.push("lrs+10_1:156_afp=4000:avsq=on:avsqr=4,1:fe=axiom:ss=axioms:tgt=ground:i=19001:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:cnfonf=off:fd=off:flr=on:hud=1:lcm=reverse:prag=on:sd=1:sos=on:ss=axioms:i=28134:si=on:rtra=on_0"); + quick.push("dis+10_1:1_fde=none:kws=precedence:piset=not:prag=on:slsq=on:slsqc=1:sp=unary_frequency:i=23684:si=on:rtra=on_0"); + quick.push("ott+10_1:10_avsq=on:bd=off:cnfonf=lazy_gen:sd=2:sgt=16:sos=on:ss=axioms:i=56001:si=on:rtra=on_0"); + quick.push("dis+2_1:1_cbe=off:fe=off:i=13068:si=on:rtra=on_0"); + quick.push("dis+10_3:1_anc=all:avsq=on:c=on:cnfonf=off:e2e=on:fd=off:fde=none:ins=3:nwc=5.0:plsq=on:plsqc=1:plsqr=4964065,131072:prag=on:s2a=on:s2agt=64:i=8801:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_bet=on:cond=fast:e2e=on:fe=off:hud=5:nm=0:ntd=on:nwc=7.0:piset=and:prag=on:rawr=on:sgt=40:ss=included:uhcvi=on:i=42318:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:avsq=on:bd=off:cbe=off:cnfonf=off:cs=on:hud=5:nm=0:plsq=on:plsqc=1:plsqr=7,1:ss=axioms:tgt=full:i=10924:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_anc=all_dependent:cnfonf=conj_eager:cond=fast:fe=axiom:nm=16:s2a=on:s2at=4.0:sd=2:ss=axioms:st=3.0:i=96745:si=on:rtra=on_0"); + quick.push("lrs-1010_8:1_au=on:c=on:ins=1:i=70437:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:bd=off:e2e=on:fde=none:fe=off:piset=or:prag=on:rawr=on:sos=on:updr=off:i=11540:si=on:rtra=on_0"); + quick.push("lrs+1002_1:4_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:hud=15:inj=on:nwc=4.0:s2a=on:sac=on:sp=reverse_arity:i=32059:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_atotf=0.1:au=on:cbe=off:ntd=on:sp=const_frequency:i=14041:si=on:rtra=on_0"); + quick.push("dis+10_1:1_fe=axiom:fsr=off:hud=5:nwc=6.0:plsq=on:plsqc=2:plsqr=32,1:s2a=on:s2agt=40:sp=weighted_frequency:i=15424:si=on:rtra=on_0"); + // Improves by expected 15.178891728241835 probs costing 948589 Mi + // Sub-schedule for 500000Mi strat cap / 4000000Mi overall limit + quick.push("ott+1666_1:1_hfaw=0:hfsq=on:hfsql=off:hfsqr=1,16:hud=15:slsq=on:slsqr=1,2:tnu=2:i=3971:si=on:rtra=on_0"); + quick.push("dis-1_1:1_amm=off:au=on:cbe=off:spb=intro:i=2207:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:bsr=unit_only:cbe=off:fe=off:fsr=off:nm=10:nwc=6.0:plsq=on:plsqc=1:plsqr=32,1:sos=all:i=2635:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_avsq=on:fde=unused:prag=on:i=3362:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_apa=on:au=on:cnfonf=off:e2e=on:flr=on:nm=4:s2a=on:i=8612:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_av=off:fde=unused:hud=10:nwc=10.0:s2a=on:ss=axioms:i=129283:si=on:rtra=on_0"); + quick.push("ott+2_1:1_au=on:hfsq=on:hfsqc=5:hfsql=off:nwc=5.0:sd=3:ss=axioms:st=5.0:i=15187:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=off:sd=1:ss=axioms:st=3.0:i=13159:si=on:rtra=on_0"); + quick.push("lrs-1010_1:50_au=on:awrs=converge:awrsf=430:bet=on:cbe=off:cha=on:nm=20:sac=on:i=14573:si=on:rtra=on_0"); + quick.push("dis+1010_1:28_add=off:cnfonf=lazy_not_gen:kws=frequency:piset=all:i=8801:si=on:rtra=on_0"); + quick.push("dis-1666_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:i=50861:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_au=on:s2a=on:sd=2:ss=axioms:st=5.0:i=120493:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:bs=on:sd=5:sp=occurrence:ss=axioms:st=2.0:i=77525:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:cnfonf=off:fd=off:flr=on:hud=1:lcm=reverse:prag=on:sd=1:sos=on:ss=axioms:i=13432:si=on:rtra=on_0"); + quick.push("lrs+10_1:156_afp=4000:avsq=on:avsqr=4,1:fe=axiom:ss=axioms:tgt=ground:i=19001:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=lazy_simp:nwc=5.0:sgt=5:ss=axioms:st=1.5:i=17538:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1024_au=on:hud=10:ntd=on:ss=included:i=168763:si=on:rtra=on_0"); + quick.push("lrs+2_16:1_acc=model:au=on:bd=off:c=on:e2e=on:nm=2:sos=all:i=84973:si=on:rtra=on_0"); + quick.push("ott+10_1:10_cnfonf=lazy_gen:fde=none:sp=const_frequency:i=15814:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_ins=2:sd=1:ss=axioms:st=3.0:i=173649:si=on:rtra=on_0"); + quick.push("lrs+1002_8:1_au=on:cs=on:e2e=on:nm=10:s2a=on:i=35602:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:nwc=5.0:i=37202:si=on:rtra=on_0"); + quick.push("lrs+1002_1:14_au=on:bd=off:e2e=on:fde=unused:sac=on:sos=on:i=16361:si=on:rtra=on_0"); + quick.push("lrs+1010_1:3_au=on:bd=off:c=on:cbe=off:fsr=off:ins=1:ss=axioms:st=1.5:i=15670:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_bd=off:ntd=on:plsq=on:plsqc=1:plsqr=32,1:i=137969:si=on:rtra=on_0"); + quick.push("lrs+1004_1:24_i=198698:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_bet=on:cond=fast:e2e=on:fe=off:hud=5:nm=0:ntd=on:nwc=7.0:piset=and:prag=on:rawr=on:sgt=40:ss=included:uhcvi=on:i=42318:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_av=off:prag=on:sd=1:sos=on:sp=occurrence:ss=axioms:i=33524:si=on:rtra=on_0"); + quick.push("dis+10_3366879:524288_awrs=decay:bd=preordered:cbe=off:e2e=on:kws=arity_squared:nwc=3.0:piset=pi_sigma:sac=on:sd=1:sgt=64:sp=const_max:ss=axioms:tgt=full:i=29485:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:nm=0:i=20308:si=on:rtra=on_0"); + quick.push("lrs-1_1:1_au=on:cbe=off:ntd=on:i=22706:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:fde=none:ins=2:nwc=10.0:piset=or:i=99377:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_cnfonf=lazy_simp:fe=off:hud=5:piset=or:prag=on:i=112304:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_chr=on:ntd=on:i=32514:si=on:rtra=on_0"); + quick.push("lrs+10_1:5_av=off:awrs=converge:awrsf=200:kws=precedence:i=31508:si=on:rtra=on_0"); + quick.push("ott+10_1:1_au=on:av=off:sd=1:ss=axioms:st=2.0:i=29617:si=on:rtra=on_0"); + quick.push("lrs-1010_8:1_au=on:c=on:ins=1:i=70437:si=on:rtra=on_0"); + quick.push("dis+1010_4:1_atotf=0.3:erd=off:sd=2:sgt=8:ss=axioms:i=33157:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_av=off:bd=off:cnfonf=lazy_gen:fe=axiom:hud=10:prag=on:ss=axioms:i=37349:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:s2a=on:s2agt=32:sgt=8:ss=axioms:i=98380:si=on:rtra=on_0"); + quick.push("ott+10_1:10_avsq=on:bd=off:cnfonf=lazy_gen:sd=2:sgt=16:sos=on:ss=axioms:i=56001:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:e2e=on:fde=unused:nm=4:s2a=on:sos=all:sp=const_frequency:i=141566:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:plsq=on:i=63430:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_av=off:fe=off:sd=2:slsq=on:slsqr=1,16:ss=axioms:st=5.0:i=82580:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=220001:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_cnfonf=off:e2e=on:nm=4:ntd=on:s2a=on:i=97391:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_fe=axiom:nwc=5.0:prag=on:sos=on:ss=axioms:i=73072:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_anc=all_dependent:cnfonf=conj_eager:cond=fast:fe=axiom:nm=16:s2a=on:s2at=4.0:sd=2:ss=axioms:st=3.0:i=96745:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:e2e=on:nm=10:sos=all:sp=reverse_arity:i=88102:si=on:rtra=on_0"); + quick.push("lrs+1010_1:4_cnfonf=lazy_not_be_gen:fe=off:hud=10:i=171919:si=on:rtra=on_0"); + // Improves by expected 14.563032764332931 probs costing 3169082 Mi + // Sub-schedule for 500000Mi strat cap / 4000000Mi overall limit + quick.push("ott+1666_1:1_hfaw=0:hfsq=on:hfsql=off:hfsqr=1,16:hud=15:slsq=on:slsqr=1,2:tnu=2:i=3602:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=off:sd=1:ss=axioms:st=3.0:i=13159:si=on:rtra=on_0"); + quick.push("ott+2_1:1_au=on:hfsq=on:hfsqc=5:hfsql=off:nwc=5.0:sd=3:ss=axioms:st=5.0:i=15187:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:cnfonf=off:fd=off:flr=on:hud=1:lcm=reverse:prag=on:sd=1:sos=on:ss=axioms:i=28134:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_bet=on:cond=fast:e2e=on:fe=off:hud=5:nm=0:ntd=on:nwc=7.0:piset=and:prag=on:rawr=on:sgt=40:ss=included:uhcvi=on:i=42318:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:nwc=5.0:i=37202:si=on:rtra=on_0"); + quick.push("ott+10_1:1_au=on:av=off:sd=1:ss=axioms:st=2.0:i=36665:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:fde=none:ins=2:nwc=10.0:piset=or:i=99377:si=on:rtra=on_0"); + quick.push("dis-1666_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:i=50861:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_cnfonf=lazy_simp:fe=off:hud=5:piset=or:prag=on:i=112304:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_fe=axiom:nwc=5.0:prag=on:sos=on:ss=axioms:i=73072:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:plsq=on:i=90575:si=on:rtra=on_0"); + quick.push("lrs+1002_1:14_au=on:bd=off:e2e=on:fde=unused:sac=on:sos=on:i=77965:si=on:rtra=on_0"); + quick.push("lrs-1_1:1_au=on:cbe=off:ntd=on:i=99319:si=on:rtra=on_0"); + quick.push("lrs-1010_8:1_au=on:c=on:ins=1:i=97110:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=183300:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_au=on:s2a=on:sd=2:ss=axioms:st=5.0:i=161771:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:e2e=on:fde=unused:nm=4:s2a=on:sos=all:sp=const_frequency:i=171310:si=on:rtra=on_0"); + // Improves by expected 2.3738304642733343 probs costing 1393213 Mi + // Sub-schedule for 500000Mi strat cap / 4000000Mi overall limit + quick.push("lrs+10_1:1_cnfonf=off:sd=1:ss=axioms:st=3.0:i=13159:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:cnfonf=off:fd=off:flr=on:hud=1:lcm=reverse:prag=on:sd=1:sos=on:ss=axioms:i=28134:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_fe=axiom:nwc=5.0:prag=on:sos=on:ss=axioms:i=73072:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_anc=all_dependent:au=on:cbe=off:cnfonf=lazy_pi_sigma_gen:fde=none:ins=2:nwc=10.0:piset=or:i=99377:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_cnfonf=lazy_simp:fe=off:hud=5:piset=or:prag=on:i=112304:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=lazy_not_be_gen:ntd=on:pe=on:i=220001:si=on:rtra=on_0"); + // Improves by expected 0.7448542041792773 probs costing 546041 Mi + // Sun16Jul HOL3: Overall score 2808.1746472908735 probs on average / budget 7225820 Mi + + // Tue: HOL3 2 Overall score 2800.260571768602 probs on average / budget 7372043 Mi + // Tue: HOL3 Overall score 2798.5308839897193 probs on average / budget 7843409 Mi + // Sun: HOL3 Overall score 2791.350517910691 probs on average / budget 8511622 Mi + // Fri: Overall score 2775.567019728554 probs on average / budget 8273879 Mi + // Tue: Overall score 2758.4199055140407 probs on average / budget 8640381 Mi +} + +void Schedules::getSnakeSlhSchedule(const Shell::Property& property, Schedule& quick) { + if (property.higherOrder()) { + if (property.hasPolymorphicSym()) { + // th1_sledgehammering/TH1.txt - but done in a weighted way (problems already covered by the other subscheds weigh less) + // Sub-schedule for 10000Mi strat cap / 10000Mi overall limit + quick.push("lrs+10_1:128_au=on:bd=off:cnfonf=off:plsq=on:plsqr=32,1:sac=on:sos=all:i=1086:si=on:rtra=on_0"); + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=817:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:e2e=on:er=filter:hud=10:kws=precedence:sos=on:sp=weighted_frequency:ss=axioms:st=3.0:uhcvi=on:i=795:si=on:rtra=on_0"); + quick.push("lrs+21_1:128_av=off:e2e=on:hud=1:prag=on:sd=2:sgt=10:sos=all:ss=axioms:i=494:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=1:sos=on:sp=frequency:ss=axioms:i=851:si=on:rtra=on_0"); + quick.push("lrs+1002_3:2_au=on:bsr=unit_only:hud=10:ntd=on:piset=all_but_not_eq:s2a=on:s2at=7.0:sd=2:sos=all:ss=axioms:i=970:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=off:cnfonf=lazy_not_gen_be_off:ntd=on:prag=on:s2a=on:s2agt=32:s2at=5.0:sp=unary_frequency:tnu=5:i=11:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_av=off:prag=on:sd=1:sos=on:sp=const_frequency:ss=axioms:i=240:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=off:fde=none:fe=off:kws=precedence:prag=on:sos=on:sp=frequency:i=646:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:fd=off:sd=1:sgt=16:sos=all:ss=axioms:i=583:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cnfonf=off:e2e=on:s2a=on:s2agt=16:slsq=on:i=1662:si=on:rtra=on_0"); + quick.push("lrs+1002_1:7_au=on:cnfonf=off:fe=axiom:ins=2:lecc=0.5:nm=32:sd=1:sgt=64:ss=axioms:i=208:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:apa=on:au=on:avsq=on:avsqr=561497,524288:cnfonf=off:e2e=on:s2a=on:s2agt=64:s2at=2.0:ss=axioms:i=1077:si=on:rtra=on_0"); + quick.push("dis+3_10:23_bd=off:fde=none:fe=off:nwc=5.0:sac=on:sfv=off:sp=occurrence:i=2:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=model:avsq=on:fe=axiom:fsr=off:nm=16:piset=pi_sigma:prag=on:sd=2:sgt=16:sp=weighted_frequency:ss=axioms:i=570:si=on:rtra=on_0"); + // Improves by expected 539.2390664018176 probs costing 9997 Mi + // Sub-schedule for 20000Mi strat cap / 20000Mi overall limit + quick.push("lrs+2_3:1_bd=off:fd=off:fde=none:fe=off:prag=on:sos=on:i=567:si=on:rtra=on_0"); + quick.push("dis+1002_1:32_au=on:av=off:cnfonf=off:fsr=off:sd=2:sgt=4:sos=on:ss=axioms:i=315:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_au=on:cnfonf=off:fde=unused:fe=axiom:prag=on:slsq=on:slsqc=2:sos=on:i=959:si=on:rtra=on_0"); + quick.push("lrs+1002_3:1_au=on:e2e=on:fd=off:fe=axiom:sos=on:i=2294:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:av=off:e2e=on:kws=inv_precedence:nwc=10.0:sos=on:i=1240:si=on:rtra=on_0"); + quick.push("ott+1010_3:2_acc=on:au=on:cnfonf=off:fsr=off:ins=3:nm=40:ntd=on:s2a=on:s2agt=60:slsq=on:i=2032:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_au=on:av=off:cnfonf=off:fe=off:s2a=on:sos=on:i=1247:si=on:rtra=on_0"); + quick.push("dis+10_1:1_nwc=3.0:sd=2:ss=axioms:i=175:si=on:rtra=on_0"); + quick.push("lrs+10_1:8_au=on:cnfonf=lazy_pi_sigma_gen:sd=2:sos=all:ss=axioms:st=1.5:i=281:si=on:rtra=on_0"); + quick.push("dis+10_1:8_fsr=off:hud=5:nm=16:prag=on:sd=1:sos=on:sp=frequency:ss=axioms:i=754:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:erd=off:fd=off:fde=none:sos=all:ss=axioms:i=549:si=on:rtra=on_0"); + quick.push("ott+10_1:1_kws=arity:prag=on:sd=1:sos=all:ss=axioms:st=3.0:i=469:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:cnfonf=off:prag=on:sd=2:sos=all:ss=axioms:i=793:si=on:rtra=on_0"); + quick.push("lrs+1002_1:32_au=on:avsq=on:sd=1:sgt=16:sos=on:ss=axioms:st=2.0:i=405:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:ntd=on:s2a=on:sfv=off:ss=axioms:i=971:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_erd=off:fe=off:ins=3:plsq=on:sos=on:i=398:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cnfonf=conj_eager:fe=axiom:sd=1:ss=axioms:i=1807:si=on:rtra=on_0"); + quick.push("lrs+1002_1:5_acc=on:avsq=on:avsqr=1,16:fe=axiom:prag=on:sd=1:ss=axioms:st=4.0:i=293:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:cnfonf=off:fd=off:fe=axiom:sd=2:sgt=8:sp=reverse_frequency:ss=axioms:i=505:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:fe=off:nwc=10.0:sd=1:sos=on:ss=axioms:st=1.5:i=567:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_c=on:sac=on:sos=on:ss=axioms:i=672:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=on:au=on:avsq=on:bd=off:cnfonf=off:fe=off:sd=2:ss=axioms:st=2.0:i=1062:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:cs=on:fde=unused:ntd=on:nwc=10.0:sac=on:sd=1:sgt=10:sos=on:ss=axioms:i=891:si=on:rtra=on_0"); + quick.push("lrs+31_1:1024_apa=on:au=on:cnfonf=off:e2e=on:fsr=off:sd=2:sgt=4:sos=on:ss=axioms:i=628:si=on:rtra=on_0"); + // Improves by expected 83.38577641685194 probs costing 19850 Mi + // Sub-schedule for 30000Mi strat cap / 30000Mi overall limit + quick.push("lrs+10_1:1_au=on:fe=axiom:plsq=on:plsqr=32,1:sos=all:ss=axioms:i=1826:si=on:rtra=on_0"); + quick.push("dis+1002_1:8_av=off:fd=off:fsr=off:prag=on:sos=on:ss=axioms:i=423:si=on:rtra=on_0"); + quick.push("dis+10_3:1_au=on:e2e=on:fsr=off:sd=1:sgt=16:ss=axioms:i=799:si=on:rtra=on_0"); + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=2432:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:fe=off:kws=precedence:sos=on:sp=frequency:i=2599:si=on:rtra=on_0"); + quick.push("dis+1002_1:3_au=on:fsr=off:sd=1:sgt=16:sos=on:ss=axioms:i=649:si=on:rtra=on_0"); + quick.push("dis+10_1:16_bd=preordered:cnfonf=lazy_pi_sigma_gen:sos=on:ss=axioms:st=1.2:i=495:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_au=on:av=off:bd=off:cond=fast:nm=2:s2a=on:s2agt=40:sos=all:spb=non_intro:i=834:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_au=on:fde=none:s2a=on:slsq=on:i=3477:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:cnfonf=off:fs=off:fsr=off:ins=3:kws=precedence:sd=2:sp=reverse_arity:ss=axioms:sup=off:i=408:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_acc=on:au=on:avsq=on:avsqr=1,2:bd=off:bs=unit_only:fe=axiom:sp=const_max:i=2235:si=on:rtra=on_0"); + quick.push("lrs-1002_1:64_bd=off:fde=none:fe=off:hud=10:sos=on:i=586:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:fe=off:kws=precedence:sos=on:sp=const_max:ss=axioms:i=547:si=on:rtra=on_0"); + quick.push("dis+1002_2:3_amm=off:au=on:fsr=off:nwc=7.0:s2a=on:s2agt=16:ss=axioms:st=3.0:i=611:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_au=on:av=off:bd=off:plsq=on:plsqc=1:plsqr=32,1:sos=on:ss=axioms:st=2.0:i=399:si=on:rtra=on_0"); + quick.push("lrs-1002_8:1_av=off:bd=off:bs=unit_only:e2e=on:fe=axiom:prag=on:sos=on:ss=axioms:st=3.0:i=1521:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_au=on:bd=off:e2e=on:fsr=off:nwc=10.0:sac=on:sos=all:ss=axioms:st=3.0:i=678:si=on:rtra=on_0"); + quick.push("ott+10_1:1_nwc=2.0:sd=1:sgt=64:sos=all:ss=axioms:i=695:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:av=off:e2e=on:sd=1:sos=all:sp=const_frequency:ss=axioms:i=589:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:sd=2:sgt=64:sos=all:ss=axioms:i=4566:si=on:rtra=on_0"); + quick.push("lrs+1002_1:4_au=on:av=off:bd=off:e2e=on:fd=off:fsr=off:s2a=on:sos=on:i=800:si=on:rtra=on_0"); + quick.push("dis-1002_1:1_au=on:cnfonf=off:e2e=on:nm=16:plsq=on:plsqr=1,2:sac=on:sos=on:sp=reverse_frequency:ss=axioms:i=2241:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:avsq=on:bd=off:fd=off:fe=axiom:fsr=off:sac=on:sos=on:i=528:si=on:rtra=on_0"); + // Improves by expected 50.792548623271934 probs costing 29915 Mi + // Sub-schedule for 60000Mi strat cap / 60000Mi overall limit + quick.push("lrs+1002_1:1_piset=or:prag=on:s2a=on:sos=on:ss=axioms:i=1425:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_au=on:e2e=on:fe=off:sos=on:ss=axioms:i=494:si=on:rtra=on_0"); + quick.push("dis+2_1:1_au=on:av=off:bd=off:fd=off:sos=on:sp=const_frequency:i=1750:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:fde=none:kws=frequency:plsq=on:plsqc=1:plsqr=32,1:sac=on:sos=on:i=434:si=on:rtra=on_0"); + quick.push("ott+21_1:1_bd=preordered:fd=off:fe=off:fs=off:fsr=off:sos=on:i=377:si=on:rtra=on_0"); + quick.push("dis+21_1:1_av=off:cnfonf=off:prag=on:s2a=on:sos=on:i=484:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:e2e=on:er=filter:hud=10:kws=precedence:sos=on:sp=weighted_frequency:ss=axioms:st=3.0:uhcvi=on:i=3504:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqc=1:bd=off:c=on:sac=on:sd=1:sos=all:ss=axioms:st=2.0:i=3204:si=on:rtra=on_0"); + quick.push("dis+2_1:32_au=on:kws=precedence:sp=weighted_frequency:ss=axioms:tgt=ground:i=446:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_erd=off:fe=axiom:hud=10:lma=on:sfv=off:slsq=on:sos=all:i=397:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_anc=all:au=on:bd=off:cnfonf=off:fd=off:fs=off:fsr=off:nwc=5.0:sac=on:sos=on:ss=axioms:i=2030:si=on:rtra=on_0"); + quick.push("dis+32_2:1_au=on:av=off:cnfonf=lazy_pi_sigma_gen:ntd=on:s2a=on:slsq=on:i=1282:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:cnfonf=lazy_not_be_gen:fde=unused:piset=not:sd=1:slsq=on:ss=axioms:st=3.0:i=1778:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:cnfonf=lazy_not_be_gen:s2a=on:slsq=on:i=1059:si=on:rtra=on_0"); + quick.push("lrs+1002_3:2_au=on:bsr=unit_only:hud=10:ntd=on:piset=all_but_not_eq:s2a=on:s2at=7.0:sd=2:sos=all:ss=axioms:i=2194:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cnfonf=lazy_simp:fe=axiom:hfsq=on:ntd=on:sd=1:sgt=32:ss=axioms:i=456:si=on:rtra=on_0"); + quick.push("ott+10_1:2_ins=4:lcm=predicate:nm=6:s2a=on:s2at=-1.0:sac=on:sd=1:sgt=64:sp=weighted_frequency:ss=axioms:st=1.2:i=1498:si=on:rtra=on_0"); + quick.push("ott+10_16:1_br=off:bsr=unit_only:fe=axiom:flr=on:nm=64:sos=on:sp=occurrence:i=1383:si=on:rtra=on_0"); + quick.push("dis+10_5:1_au=on:nwc=10.0:sac=on:sd=1:sos=on:ss=axioms:i=1027:si=on:rtra=on_0"); + quick.push("dis+10_1:50_av=off:cnfonf=off:prag=on:sd=2:sos=on:ss=axioms:st=1.5:i=926:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_pi_sigma_gen:fe=axiom:s2a=on:s2agt=8:sd=2:sgt=4:ss=axioms:i=355:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_bsr=unit_only:cnfonf=conj_eager:nwc=3.0:sd=1:ss=axioms:i=663:si=on:rtra=on_0"); + quick.push("dis+1002_1:8_avsq=on:avsqr=1,16:e2e=on:s2a=on:ss=axioms:st=3.0:i=358:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:c=on:cnfonf=off:e2e=on:nm=32:nwc=10.0:sgt=8:ss=axioms:i=493:si=on:rtra=on_0"); + quick.push("lrs+10_1:8_au=on:cnfonf=lazy_pi_sigma_gen:sd=2:sos=all:ss=axioms:st=1.5:i=418:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_atotf=0.2:au=on:bsr=unit_only:cha=on:e2e=on:fsr=off:sd=1:sp=unary_first:ss=axioms:st=4.0:i=836:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_fe=off:prag=on:sd=1:sos=all:ss=axioms:st=2.5:i=308:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:fd=off:sd=1:sgt=16:sos=all:ss=axioms:i=3033:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=conj_eager:sd=1:sgt=100:ss=axioms:i=1662:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:sgt=4:sos=on:ss=axioms:i=407:si=on:rtra=on_0"); + quick.push("lrs+1010_5:1_au=on:cbe=off:s2a=on:s2agt=32:sac=on:i=3644:si=on:rtra=on_0"); + quick.push("dis+10_1:2_cnfonf=off:fsr=off:sp=unary_first:ss=axioms:st=1.5:i=663:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_e2e=on:fde=none:nwc=10.0:sd=1:sgt=16:sos=all:ss=axioms:i=251:si=on:rtra=on_0"); + quick.push("ott+10_1:1_fsr=off:hfaw=0:hfsq=on:hfsql=off:hfsqr=4,1:ins=3:kws=precedence:ntd=on:sp=frequency:i=813:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:bd=off:bs=unit_only:cnfonf=off:fd=off:fsr=off:hud=3:ins=3:prag=on:sd=2:sgt=8:sos=on:ss=axioms:i=1144:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_av=off:bsr=unit_only:e2e=on:fd=preordered:prag=on:sos=all:sp=const_frequency:i=3763:si=on:rtra=on_0"); + quick.push("dis+10_1:1_hud=10:prag=on:s2a=on:s2at=1.2:sac=on:sos=all:i=1345:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:apa=on:au=on:avsq=on:avsqr=561497,524288:cnfonf=off:e2e=on:s2a=on:s2agt=64:s2at=2.0:ss=axioms:i=1956:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:erd=off:sos=on:i=354:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:fde=none:sd=2:sos=all:ss=axioms:i=347:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_aac=none:e2e=on:fsr=off:nm=4:prag=on:sac=on:sd=1:sos=on:ss=axioms:st=4.0:i=730:si=on:rtra=on_0"); + quick.push("lrs+1002_1:8_au=on:ins=2:sd=1:sos=on:ss=axioms:i=435:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cnfonf=off:s2a=on:s2agt=32:sd=1:ss=axioms:st=6.0:i=401:si=on:rtra=on_0"); + quick.push("lrs+10_3:1_au=on:e2e=on:ins=3:sd=1:sos=all:ss=axioms:i=378:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:avsq=on:avsqr=1,6:bsr=unit_only:nm=2:nwc=2.0:sac=on:sos=all:ss=axioms:i=756:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_bd=off:fe=axiom:hud=19:sac=on:sos=on:tnu=1:i=722:si=on:rtra=on_0"); + quick.push("dis+21_1:4_au=on:ntd=on:s2a=on:s2agt=32:s2at=1.2:slsq=on:slsqc=1:i=776:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=off:fs=off:fsr=off:sd=10:sos=on:ss=axioms:st=5.0:i=1711:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_fde=none:sd=1:sos=on:ss=axioms:st=2.0:i=406:si=on:rtra=on_0"); + quick.push("lrs+4_1:10_awrs=converge:awrsf=500:bd=off:kws=inv_frequency:sd=1:ss=axioms:st=3.0:tgt=ground:i=1137:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=model:avsq=on:fe=axiom:fsr=off:nm=16:piset=pi_sigma:prag=on:sd=2:sgt=16:sp=weighted_frequency:ss=axioms:i=3579:si=on:rtra=on_0"); + // Improves by expected 51.41792201759229 probs costing 59941 Mi + // Sub-schedule for 120000Mi strat cap / 120000Mi overall limit + quick.push("lrs+1010_16:1_acc=on:au=on:e2e=on:nm=32:sac=on:sd=1:sos=on:ss=axioms:st=5.0:i=4879:si=on:rtra=on_0"); + quick.push("lrs+21_1:64_au=on:cnfonf=lazy_pi_sigma_gen:fsr=off:kws=frequency:s2at=5.0:slsq=on:slsqc=1:i=1100:si=on:rtra=on_0"); + quick.push("dis+1002_1:8_av=off:fd=off:fsr=off:prag=on:sos=on:ss=axioms:i=773:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:bet=on:c=on:cnfonf=off:lcm=reverse:piset=small_set:sd=1:sp=reverse_frequency:ss=axioms:i=364:si=on:rtra=on_0"); + quick.push("dis+1002_1:1024_av=off:e2e=on:fe=axiom:sos=on:sp=unary_first:i=2641:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_au=on:bd=off:cnfonf=off:plsq=on:plsqr=32,1:sac=on:sos=all:i=2281:si=on:rtra=on_0"); + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=2421:si=on:rtra=on_0"); + quick.push("dis+1004_1:4_fde=none:sd=1:sgt=32:ss=axioms:tgt=ground:i=569:si=on:rtra=on_0"); + quick.push("lrs+10_2:3_au=on:cnfonf=lazy_pi_sigma_gen:fe=off:kws=inv_arity:sd=2:sp=reverse_arity:ss=axioms:st=3.0:tgt=full:i=947:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:bd=off:fd=off:fde=none:sos=all:i=1670:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:av=off:cnfonf=lazy_pi_sigma_gen:fsr=off:nwc=6.0:s2a=on:s2agt=16:i=4110:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_ins=2:nm=4:prag=on:sac=on:sd=1:sos=on:spb=goal_then_units:ss=axioms:i=986:si=on:rtra=on_0"); + quick.push("lrs+10_1:5_cnfonf=off:e2e=on:er=known:hud=15:inj=on:sd=1:sgt=40:ss=axioms:tnu=9:i=2044:si=on:rtra=on_0"); + quick.push("lrs+21_1:1024_au=on:nwc=10.0:piset=small_set:sac=on:sfv=off:sos=on:sp=unary_frequency:i=1868:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=1:sos=on:sp=frequency:ss=axioms:i=1081:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:avsq=on:e2e=on:sos=on:i=2248:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:er=filter:fe=off:flr=on:hud=10:ntd=on:nwc=10.0:i=1795:si=on:rtra=on_0"); + quick.push("dis+21_1:8_bd=off:cbe=off:fe=off:kws=inv_arity_squared:plsq=on:plsqc=1:plsqr=375431,1048576:sd=1:ss=axioms:st=3.0:tgt=full:tnu=2:i=592:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:e2e=on:fd=off:fe=off:sos=on:i=2401:si=on:rtra=on_0"); + quick.push("ott+10_5:4_amm=off:apa=on:bd=off:bsr=unit_only:cnfonf=off:cond=fast:fe=off:fsr=off:nm=7:plsq=on:prag=on:sac=on:sfv=off:sos=all:sp=const_frequency:tnu=8:i=1206:si=on:rtra=on_0"); + quick.push("ott+10_1:1_apa=on:bsr=unit_only:cnfonf=off:fe=off:fsr=off:hud=8:ntd=on:prag=on:sos=all:ss=axioms:i=781:si=on:rtra=on_0"); + quick.push("dis+21_1:1_av=off:fe=off:hud=1:kws=inv_precedence:sos=on:i=1125:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:cnfonf=off:fe=axiom:hud=5:sac=on:sd=1:sos=on:ss=axioms:st=2.0:i=416:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:bd=off:cnfonf=off:fd=off:ntd=on:piset=all_but_not_eq:sos=all:i=587:si=on:rtra=on_0"); + quick.push("lrs-1004_16:1_ins=1:plsq=on:plsqc=1:plsqr=32,1:prag=on:sac=on:sd=1:sos=on:spb=goal_then_units:ss=axioms:st=4.0:i=2524:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_au=on:av=off:e2e=on:fe=off:kws=inv_arity:sos=on:sp=unary_frequency:i=679:si=on:rtra=on_0"); + quick.push("dis+1002_1:28_aac=none:plsq=on:plsqc=2:plsqr=8,1:sd=2:sp=frequency:ss=axioms:tgt=ground:i=2092:si=on:rtra=on_0"); + quick.push("dis+21_3:1_au=on:c=on:nwc=3.0:s2a=on:s2agt=64:sd=1:sp=reverse_arity:ss=axioms:st=5.0:i=3412:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:e2e=on:er=known:sos=all:sp=const_max:ss=axioms:i=640:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_acc=model:au=on:awrs=converge:awrsf=200:nwc=10.0:s2a=on:s2at=1.2:slsq=on:i=2074:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:avsq=on:hfsq=on:hfsqr=5,33:kws=arity_squared:piset=equals:plsq=on:plsql=on:plsqr=1,32:sd=1:sos=all:ss=axioms:st=5.0:i=832:si=on:rtra=on_0"); + quick.push("dis+10_6:1_fs=off:fsr=off:hfsq=on:kws=frequency:ntd=on:prag=on:sd=2:ss=axioms:i=862:si=on:rtra=on_0"); + quick.push("lrs+1002_1:32_avsq=on:fd=off:sos=on:i=1662:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_prag=on:sd=1:sos=on:ss=axioms:st=2.0:i=718:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_anc=all:au=on:fe=off:plsq=on:plsqr=32,1:sac=on:sos=all:ss=axioms:i=1004:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_bd=off:fd=off:hud=10:ntd=on:sgt=16:sos=on:ss=axioms:i=644:si=on:rtra=on_0"); + quick.push("dis+10_1:8_fsr=off:hud=5:nm=16:prag=on:sd=1:sos=on:sp=frequency:ss=axioms:i=812:si=on:rtra=on_0"); + quick.push("lrs+10_3:1_au=on:bd=off:sd=1:sos=on:ss=axioms:st=5.0:i=968:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:fe=off:kws=precedence:sos=on:sp=const_max:ss=axioms:i=547:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:cnfonf=off:prag=on:sd=2:sos=all:ss=axioms:i=3486:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=off:inj=on:kws=precedence:ntd=on:sos=on:sp=reverse_arity:i=3320:si=on:rtra=on_0"); + quick.push("dis+10_1:14_au=on:fe=axiom:lma=on:nm=2:nwc=5.0:sac=on:sos=all:ss=axioms:i=1526:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_au=on:cbe=off:plsq=on:plsqc=1:plsqr=6694409,65536:i=7208:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cnfonf=conj_eager:fe=axiom:sd=1:ss=axioms:i=4007:si=on:rtra=on_0"); + quick.push("ott+21_163:29_au=on:fde=unused:lcm=predicate:sos=on:sp=const_frequency:i=1097:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:cnfonf=lazy_not_gen:fd=off:sos=on:i=495:si=on:rtra=on_0"); + quick.push("ott+10_1:1_au=on:cnfonf=lazy_gen:hflw=2:hfsq=on:hfsqc=2:hfsqr=4,1:kws=precedence:s2a=on:s2at=1.5:sp=unary_first:i=2708:si=on:rtra=on_0"); + quick.push("dis+10_1:16_acc=model:avsq=on:avsqr=1,16:cnfonf=lazy_not_be_gen:plsq=on:plsqc=1:plsqr=32,1:ss=axioms:i=853:si=on:rtra=on_0"); + quick.push("dis+10_1:10_acc=model:e2e=on:fe=off:s2a=on:s2at=3.0:tgt=full:i=699:si=on:rtra=on_0"); + quick.push("dis+10_16:1_acc=on:au=on:fd=off:fsr=off:hflw=0:hfsq=on:kws=precedence:sd=1:ss=axioms:st=1.5:i=3212:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_hud=1:inj=on:prag=on:s2a=on:sos=all:i=1517:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:nm=2:plsq=on:plsqr=32,1:sos=all:i=4382:si=on:rtra=on_0"); + quick.push("lrs+1002_1:5_acc=on:avsq=on:avsqr=1,16:fe=axiom:prag=on:sd=1:ss=axioms:st=4.0:i=663:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_au=on:c=on:cnfonf=off:e2e=on:fe=off:fsr=off:nwc=5.0:s2a=on:s2agt=100:ss=axioms:i=4502:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:fsr=off:sac=on:sd=1:sgt=32:sos=all:ss=axioms:i=1380:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bsr=unit_only:e2e=on:sos=on:ss=axioms:st=2.0:i=1514:si=on:rtra=on_0"); + quick.push("lrs+1010_1:8_afp=30:au=on:bd=off:c=on:cbe=off:cnfonf=off:hud=15:nm=30:piset=equals:sd=1:sos=on:ss=axioms:i=481:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_fsr=off:ntd=on:nwc=5.0:prag=on:sos=on:sp=unary_first:i=858:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_au=on:bd=off:cnfonf=lazy_simp:fd=off:fsr=off:sd=3:sgt=20:sp=unary_frequency:ss=axioms:i=861:si=on:rtra=on_0"); + quick.push("dis-1002_1:16_av=off:fe=off:hud=19:nwc=12.0:sos=on:ss=axioms:st=2.0:i=1025:si=on:rtra=on_0"); + quick.push("dis+10_16:1_acc=on:avsq=on:fe=axiom:fsr=off:s2a=on:s2agt=16:s2at=3.0:i=3806:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:hfsq=on:ins=2:s2a=on:s2at=1.5:sd=1:ss=axioms:st=3.0:i=617:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_hud=24:plsq=on:sd=1:sos=all:ss=axioms:tnu=1:i=581:si=on:rtra=on_0"); + quick.push("lrs+1002_3:1_au=on:cnfonf=off:fe=off:lcm=reverse:sd=1:sos=on:sp=const_frequency:ss=axioms:i=1125:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=lazy_pi_sigma_gen:ntd=on:nwc=10.0:slsq=on:slsqc=1:sp=unary_frequency:uhcvi=on:i=4051:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:fd=off:nm=20:nwc=10.0:plsq=on:s2a=on:s2agt=64:ss=axioms:st=5.0:i=702:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_au=on:cnfonf=lazy_pi_sigma_gen:ins=1:tgt=ground:i=644:si=on:rtra=on_0"); + quick.push("dis-1002_1:1_av=off:bs=unit_only:fe=axiom:hud=10:prag=on:sos=on:sp=const_frequency:ss=axioms:tnu=2:i=974:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_aac=none:bd=off:e2e=on:kws=inv_frequency:sos=all:ss=axioms:i=1008:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:avsq=on:bd=off:cnfonf=lazy_pi_sigma_gen:fd=off:sos=on:i=876:si=on:rtra=on_0"); + quick.push("dis+1002_1:4_aac=none:bd=off:e2e=on:fe=off:fsr=off:prag=on:sos=on:i=767:si=on:rtra=on_0"); + quick.push("dis+10_1:16_awrs=converge:e2e=on:fe=off:nwc=10.0:s2a=on:s2at=4.0:sd=2:ss=axioms:st=2.0:i=672:si=on:rtra=on_0"); + // Improves by expected 44.20607043074075 probs costing 119900 Mi + // Sub-schedule for 240000Mi strat cap / 240000Mi overall limit + quick.push("lrs+10_1:1_au=on:fe=axiom:plsq=on:plsqr=32,1:sos=all:ss=axioms:i=4406:si=on:rtra=on_0"); + quick.push("ott+2_8:1_au=on:awrs=converge:e2e=on:fsr=off:hud=10:ins=3:ntd=on:s2at=2.5:slsq=on:slsqc=1:i=4617:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_piset=or:prag=on:s2a=on:sos=on:ss=axioms:i=3296:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_aac=none:cbe=off:fsr=off:kws=inv_frequency:nwc=4.0:tnu=1:i=2128:si=on:rtra=on_0"); + quick.push("lrs+1010_4:1_amm=sco:ins=3:ss=axioms:st=1.5:i=3408:si=on:rtra=on_0"); + quick.push("dis+10_1:8_au=on:bd=off:cnfonf=off:e2e=on:fde=none:lma=on:sgt=5:sos=all:ss=axioms:i=3184:si=on:rtra=on_0"); + quick.push("dis+21_1:1_av=off:cnfonf=off:prag=on:s2a=on:sos=on:i=1304:si=on:rtra=on_0"); + quick.push("lrs+21_1:128_av=off:e2e=on:hud=1:prag=on:sd=2:sgt=10:sos=all:ss=axioms:i=3585:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_not_be_gen:fe=axiom:fs=off:fsr=off:plsq=on:s2a=on:s2at=2.0:sos=all:i=3340:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_anc=all:au=on:bd=off:cnfonf=off:fd=off:fs=off:fsr=off:nwc=5.0:sac=on:sos=on:ss=axioms:i=5830:si=on:rtra=on_0"); + quick.push("dis+10_1:16_au=on:cnfonf=off:fe=off:plsq=on:plsqc=1:plsqr=32,1:rawr=on:tgt=ground:i=1020:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:ins=2:ixr=off:nm=2:nwc=3.0:sac=on:sos=on:i=1087:si=on:rtra=on_0"); + quick.push("dis+1002_1:3_atotf=0.2:bd=off:cnfonf=conj_eager:fd=off:fe=off:ins=1:nwc=2.0:plsq=on:plsqc=2:plsqr=32,1:s2a=on:s2agt=4:sos=all:i=1525:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:av=off:e2e=on:kws=inv_precedence:nwc=10.0:sos=on:i=7200:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:sd=1:sos=on:sp=frequency:ss=axioms:i=4551:si=on:rtra=on_0"); + quick.push("ott+1010_3:2_acc=on:au=on:cnfonf=off:fsr=off:ins=3:nm=40:ntd=on:s2a=on:s2agt=60:slsq=on:i=14357:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_acc=on:au=on:bd=off:fde=none:hud=15:sgt=4:sp=const_max:ss=axioms:uhcvi=on:i=1095:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:cnfonf=lazy_gen:nwc=10.0:s2a=on:sp=unary_first:i=9755:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_au=on:awrs=decay:bsr=on:e2e=on:fe=off:nm=40:nwc=10.0:piset=all:sos=all:i=2288:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=lazy_not_gen:nwc=5.0:sos=all:i=1973:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:ins=3:nm=4:sgt=20:sos=all:ss=axioms:i=11085:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:er=filter:fd=off:fs=off:fsr=off:hud=20:kws=arity:nm=40:nwc=6.0:sd=7:sos=on:ss=axioms:i=491:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:er=known:fe=off:s2a=on:sac=on:sos=on:i=4606:si=on:rtra=on_0"); + quick.push("ott+30_1:1_cnfonf=off:fd=off:nm=4:ntd=on:plsq=on:plsqr=32,1:sac=on:i=2533:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_avsq=on:bsr=unit_only:cnfonf=off:kws=frequency:nm=32:sos=on:sp=const_frequency:i=3838:si=on:rtra=on_0"); + quick.push("lrs+2_1:3_apa=on:au=on:avsq=on:cnfonf=off:fde=unused:fs=off:fsr=off:rawr=on:sos=all:i=901:si=on:rtra=on_0"); + quick.push("dis+10_1:50_av=off:cnfonf=off:prag=on:sd=2:sos=on:ss=axioms:st=1.5:i=828:si=on:rtra=on_0"); + quick.push("lrs+1002_1:16_au=on:av=off:c=on:cbe=off:fe=off:plsq=on:plsqr=263619,8192:sos=on:ss=axioms:i=1835:si=on:rtra=on_0"); + quick.push("ott+1010_2:3_aac=none:afr=on:cnfonf=lazy_gen:fe=axiom:hud=1:nwc=10.0:piset=all_but_not_eq:prag=on:s2a=on:s2at=3.0:i=1901:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_acc=model:au=on:awrs=converge:awrsf=200:nwc=10.0:s2a=on:s2at=1.2:slsq=on:i=2007:si=on:rtra=on_0"); + quick.push("ott+1002_5:1_cond=fast:e2e=on:fe=off:hud=15:piset=all_but_not_eq:s2a=on:s2agt=100:s2at=5.0:sac=on:sos=on:i=802:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:bd=off:cnfonf=off:fsr=off:sd=1:sgt=32:ss=axioms:i=1817:si=on:rtra=on_0"); + quick.push("ott+1010_452:41_au=on:fsr=off:hfaw=0:hfsq=on:hfsqc=10:ins=3:kws=inv_frequency:nm=2:rawr=on:s2a=on:s2at=5.0:s2pl=on:sac=on:uhcvi=on:i=2186:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_apa=on:av=off:cnfonf=off:piset=pi_sigma:prag=on:slsq=on:slsqr=2,1:ss=axioms:i=5341:si=on:rtra=on_0"); + quick.push("dis+21_8:1_acc=model:au=on:avsq=on:avsqr=1,8:bsr=on:e2e=on:fd=off:fe=off:ixr=off:ntd=on:nwc=5.0:plsq=on:plsqc=1:plsqr=4056251,32768:s2a=on:i=1946:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_atotf=0.2:au=on:bsr=unit_only:cha=on:e2e=on:fsr=off:sd=1:sp=unary_first:ss=axioms:st=4.0:i=14118:si=on:rtra=on_0"); + quick.push("lrs+21_1:1024_au=on:chr=on:erd=off:fe=axiom:sos=all:ss=axioms:i=1892:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_bd=off:cbe=off:fe=axiom:flr=on:prag=on:sd=2:ss=axioms:st=1.5:i=1162:si=on:rtra=on_0"); + quick.push("lrs+10_1:2_e2e=on:sd=1:ss=axioms:st=3.0:i=1016:si=on:rtra=on_0"); + quick.push("lrs+1004_1:1_au=on:av=off:bd=off:plsq=on:plsqc=1:plsqr=32,1:sos=on:ss=axioms:st=2.0:i=1141:si=on:rtra=on_0"); + quick.push("dis+10_16:1_hud=1:lma=on:ntd=on:prag=on:sos=all:sp=occurrence:ss=axioms:i=1830:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_acc=on:bd=off:cnfonf=off:fe=axiom:kws=inv_arity_squared:piset=equals:prag=on:sd=1:sp=reverse_arity:ss=axioms:tgt=ground:i=1674:si=on:rtra=on_0"); + quick.push("ott+4_1:1_cbe=off:cnfonf=lazy_not_be_gen:hud=20:irw=on:nwc=5.0:piset=all:plsq=on:plsqr=32,1:prag=on:sos=all:sp=occurrence:i=2039:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bsr=unit_only:s2a=on:sos=all:ss=axioms:i=802:si=on:rtra=on_0"); + quick.push("dis+10_1:16_acc=model:avsq=on:avsqr=1,16:cnfonf=lazy_not_be_gen:plsq=on:plsqc=1:plsqr=32,1:ss=axioms:i=2250:si=on:rtra=on_0"); + quick.push("lrs+20_1:4_au=on:bd=off:e2e=on:slsq=on:slsqr=1,8:sos=on:i=4703:si=on:rtra=on_0"); + quick.push("dis+10_1:64_au=on:cnfonf=off:fde=none:ins=2:nm=6:sos=on:i=1929:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_apa=on:atotf=0.3:au=on:cnfonf=off:s2a=on:s2agt=16:sgt=8:sos=on:sp=frequency:ss=axioms:i=4669:si=on:rtra=on_0"); + quick.push("dis+1010_1:3_bd=preordered:cnfonf=lazy_simp:nwc=5.0:s2a=on:s2at=3.0:sp=unary_first:i=3446:si=on:rtra=on_0"); + quick.push("dis+1010_3:2_e2e=on:rawr=on:sac=on:sd=1:sos=all:ss=axioms:st=3.0:i=1969:si=on:rtra=on_0"); + quick.push("lrs-1002_8:1_av=off:bd=off:bs=unit_only:e2e=on:fe=axiom:prag=on:sos=on:ss=axioms:st=3.0:i=4393:si=on:rtra=on_0"); + quick.push("lrs+1002_1:7_au=on:cnfonf=off:fe=axiom:ins=2:lecc=0.5:nm=32:sd=1:sgt=64:ss=axioms:i=2917:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_kws=arity:nwc=10.0:prag=on:sd=1:sgt=16:ss=axioms:i=723:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_av=off:bd=off:sd=2:sos=on:ss=axioms:st=3.0:i=1277:si=on:rtra=on_0"); + quick.push("ott+10_4:1_cnfonf=lazy_gen:fe=axiom:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:ss=axioms:i=1469:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_av=off:bd=off:cnfonf=off:fe=axiom:hud=5:nwc=10.0:sd=1:sos=on:ss=axioms:st=2.0:i=1156:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:bd=off:cbe=off:cnfonf=lazy_pi_sigma_gen:fe=off:s2a=on:s2agt=32:i=4604:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:fe=off:nwc=10.0:sd=1:sos=on:ss=axioms:st=1.5:i=3044:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_au=on:avsq=on:bsr=on:cnfonf=off:e2e=on:nm=2:sac=on:sos=all:i=13916:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:avsq=on:avsqr=1,6:bsr=unit_only:nm=2:nwc=2.0:sac=on:sos=all:ss=axioms:i=3820:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:bd=off:fd=off:sos=all:ss=axioms:i=2903:si=on:rtra=on_0"); + quick.push("dis-33_1:62_fsr=off:hfsq=on:s2a=on:sac=on:slsq=on:slsqc=1:slsqr=2735097,1048576:i=1308:si=on:rtra=on_0"); + quick.push("dis+10_1:1_alpa=true:atotf=0.4:avsq=on:avsqr=1,16:cnfonf=lazy_pi_sigma_gen:fd=off:fde=unused:fe=axiom:ins=1:s2a=on:s2at=1.5:i=3339:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:cs=on:fde=unused:ntd=on:nwc=10.0:sac=on:sd=1:sgt=10:sos=on:ss=axioms:i=891:si=on:rtra=on_0"); + quick.push("dis+1004_5:1_au=on:fe=off:plsq=on:plsqc=1:plsqr=32,1:sos=on:sp=const_frequency:spb=goal:i=1058:si=on:rtra=on_0"); + quick.push("dis+2_1:1_au=on:cnfonf=off:e2e=on:fe=off:nwc=3.0:s2a=on:s2at=7.0:sp=weighted_frequency:i=2138:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:sd=2:sgt=64:sos=all:ss=axioms:i=6939:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=model:avsq=on:fe=axiom:fsr=off:nm=16:piset=pi_sigma:prag=on:sd=2:sgt=16:sp=weighted_frequency:ss=axioms:i=14103:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:nwc=10.0:s2agt=32:s2at=7.0:s2pl=on:sp=frequency:ss=axioms:uhcvi=on:i=3332:si=on:rtra=on_0"); + // Improves by expected 38.33506744983474 probs costing 239967 Mi + // Sub-schedule for 480000Mi strat cap / 480000Mi overall limit + quick.push("lrs+10_1:1_au=on:fe=axiom:plsq=on:plsqr=32,1:sos=all:ss=axioms:i=4201:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:av=off:cnfonf=conj_eager:fe=off:nwc=5.0:sp=unary_first:ss=axioms:st=3.0:i=20925:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cnfonf=lazy_not_be_gen:piset=all_but_not_eq:plsq=on:plsqc=1:plsqr=19,2:sac=on:slsq=on:i=6917:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_avsq=on:cbe=off:prag=on:s2a=on:sac=on:i=3537:si=on:rtra=on_0"); + quick.push("lrs+1004_2:3_au=on:c=on:cnfonf=off:ins=2:kws=precedence:ntd=on:sp=reverse_frequency:spb=goal:i=3785:si=on:rtra=on_0"); + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=20258:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqc=1:bd=off:c=on:sac=on:sd=1:sos=all:ss=axioms:st=2.0:i=7608:si=on:rtra=on_0"); + quick.push("dis+10_1:8_cnfonf=lazy_not_gen:plsq=on:plsqc=1:plsqr=19,2:s2pl=on:sd=1:sp=unary_frequency:ss=axioms:st=4.0:i=6035:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_not_be_gen:fe=axiom:fs=off:fsr=off:plsq=on:s2a=on:s2at=2.0:sos=all:i=3340:si=on:rtra=on_0"); + quick.push("lrs+1002_3:1_au=on:e2e=on:fd=off:fe=axiom:sos=on:i=4637:si=on:rtra=on_0"); + quick.push("dis+10_1:3_aac=none:bd=off:cnfonf=lazy_not_gen:fe=axiom:kws=inv_frequency:nwc=3.0:prag=on:s2a=on:s2at=7.0:i=2787:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:ins=2:ixr=off:nm=2:nwc=3.0:sac=on:sos=on:i=7814:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_bet=on:erd=off:fe=off:hud=10:prag=on:sac=on:sos=all:sp=const_max:i=3587:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:avsq=on:e2e=on:sos=on:i=4358:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:cs=on:fd=off:fde=unused:nm=4:ntd=on:prag=on:sos=all:sp=unary_first:i=4381:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=lazy_pi_sigma_gen:ins=1:ntd=on:plsq=on:sp=const_min:i=3405:si=on:rtra=on_0"); + quick.push("ott-1002_8:1_au=on:bd=off:bsr=unit_only:ntd=on:sac=on:sos=on:sp=reverse_arity:i=5401:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:er=filter:fd=off:fs=off:fsr=off:hud=20:kws=arity:nm=40:nwc=6.0:sd=7:sos=on:ss=axioms:i=5708:si=on:rtra=on_0"); + quick.push("ott+10_1:4_amm=sco:au=on:nwc=5.0:s2a=on:s2at=3.0:sp=const_max:i=5864:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:er=known:fe=off:s2a=on:sac=on:sos=on:i=4606:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_abs=on:amm=off:atotf=0.4:au=on:avsq=on:fe=axiom:hfsq=on:hfsqc=1:kws=frequency:ntd=on:nwc=3.0:prag=on:s2a=on:i=6978:si=on:rtra=on_0"); + quick.push("lrs+1004_5:1_apa=on:avsq=on:cnfonf=off:e2e=on:fe=axiom:fsr=off:ntd=on:plsq=on:plsqc=1:plsqr=32,1:sp=const_max:i=1958:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_avsq=on:bsr=unit_only:cnfonf=off:kws=frequency:nm=32:sos=on:sp=const_frequency:i=3838:si=on:rtra=on_0"); + quick.push("lrs+10_1:16_atotf=0.3:bsr=on:nm=10:sd=1:sgt=16:slsq=on:slsqc=4:slsqr=1,3:sp=frequency:ss=axioms:tgt=full:i=4750:si=on:rtra=on_0"); + quick.push("ott+1002_1:64_atotf=0.2:au=on:hflw=2:hfsq=on:hfsql=off:hfsqr=1,2:kws=inv_frequency:sos=on:sp=occurrence:i=2036:si=on:rtra=on_0"); + quick.push("lrs+10_16:1_aac=none:au=on:cnfonf=lazy_pi_sigma_gen:s2a=on:slsq=on:slsqr=1,4:i=10956:si=on:rtra=on_0"); + quick.push("dis+2_1:1_av=off:fe=off:prag=on:s2a=on:sos=on:i=3686:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:e2e=on:s2a=on:s2agt=64:sac=on:sos=on:i=10086:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_acc=model:au=on:awrs=converge:awrsf=200:nwc=10.0:s2a=on:s2at=1.2:slsq=on:i=11839:si=on:rtra=on_0"); + quick.push("lrs+21_5:4_apa=on:c=on:cnfonf=off:er=known:fe=axiom:fs=off:fsr=off:prag=on:sos=on:i=1063:si=on:rtra=on_0"); + quick.push("dis+1010_1:8_au=on:ins=1:sd=1:sos=on:sp=unary_first:ss=axioms:i=3992:si=on:rtra=on_0"); + quick.push("ott+1010_2:1_bs=unit_only:bsr=unit_only:cnfonf=lazy_not_gen:etr=on:fe=off:piset=pi_sigma:plsq=on:plsqc=1:plsqr=32,1:sos=all:i=12001:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=off:nm=32:ntd=on:nwc=10.0:i=3901:si=on:rtra=on_0"); + quick.push("ott+1010_2:1_e2e=on:fsr=off:hud=1:ins=3:sd=1:ss=axioms:st=3.0:i=2736:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_apa=on:bd=off:cnfonf=off:e2e=on:prag=on:sd=1:sos=on:ss=axioms:st=2.0:i=6312:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_apa=on:av=off:cnfonf=off:piset=pi_sigma:prag=on:slsq=on:slsqr=2,1:ss=axioms:i=17621:si=on:rtra=on_0"); + quick.push("lrs+21_4:1_au=on:fe=axiom:ins=3:ntd=on:nwc=10.0:i=11226:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_cnfonf=off:erd=off:hud=21:ins=2:plsq=on:plsqr=32,1:sac=on:sos=on:i=7700:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_av=off:fsr=off:plsq=on:plsqr=32,1:sd=1:sos=on:ss=axioms:i=4520:si=on:rtra=on_0"); + quick.push("lrs+21_1:1024_au=on:chr=on:erd=off:fe=axiom:sos=all:ss=axioms:i=1892:si=on:rtra=on_0"); + quick.push("lrs+1004_2:3_au=on:c=on:cnfonf=off:fe=off:ins=1:sd=1:sgt=16:ss=axioms:i=6080:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=off:inj=on:kws=precedence:ntd=on:sos=on:sp=reverse_arity:i=3320:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_au=on:cbe=off:plsq=on:plsqc=1:plsqr=6694409,65536:i=29072:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:avsq=on:avsqr=1,16:c=on:cnfonf=off:fe=axiom:i=2145:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_e2e=on:fde=none:nwc=10.0:sd=1:sgt=16:sos=all:ss=axioms:i=2290:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_au=on:bd=off:cnfonf=lazy_pi_sigma_gen:ss=axioms:i=6538:si=on:rtra=on_0"); + quick.push("dis+2_12:1_afp=100000:afq=1.0:apa=on:au=on:c=on:cnfonf=off:fe=off:ins=2:nm=32:sos=all:sp=occurrence:i=1742:si=on:rtra=on_0"); + quick.push("dis-1004_16:1_awrs=converge:cnfonf=conj_eager:fe=off:fsr=off:nwc=5.0:plsq=on:plsqc=1:plsqr=4709875,524288:sp=const_frequency:i=9984:si=on:rtra=on_0"); + quick.push("lrs+10_1:1024_aac=none:anc=all:au=on:bd=off:fd=off:fe=off:kws=precedence:piset=pi_sigma:plsq=on:plsqr=4689123,65536:sos=all:sp=unary_frequency:i=7093:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_fe=axiom:prag=on:sos=all:sp=reverse_arity:ss=axioms:i=4712:si=on:rtra=on_0"); + quick.push("lrs+1002_1:64_au=on:e2e=on:fe=off:kws=precedence:ntd=on:sac=on:sp=reverse_arity:tgt=ground:i=1968:si=on:rtra=on_0"); + quick.push("dis+21_1:1_fe=axiom:sd=1:sos=on:ss=axioms:i=1812:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cnfonf=off:e2e=on:s2a=on:s2agt=16:slsq=on:i=6205:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_aac=none:cnfonf=lazy_not_be_gen:sos=all:i=5492:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:bd=off:cnfonf=off:fd=off:fe=axiom:sd=2:sgt=8:sp=reverse_frequency:ss=axioms:i=20720:si=on:rtra=on_0"); + quick.push("dis+1002_1:128_acc=on:amm=off:au=on:cha=on:cnfonf=lazy_pi_sigma_gen:fe=off:hflw=2:hfsq=on:hud=10:ntd=on:piset=or:i=1689:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_au=on:kws=inv_frequency:lma=on:sos=all:sp=const_frequency:i=5065:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_au=on:c=on:cnfonf=off:e2e=on:fe=off:fsr=off:nwc=5.0:s2a=on:s2agt=100:ss=axioms:i=7852:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:bsr=unit_only:cbe=off:fd=off:fsr=off:sos=on:ss=axioms:i=2910:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:fsr=off:sac=on:sd=1:sgt=32:sos=all:ss=axioms:i=2138:si=on:rtra=on_0"); + quick.push("dis+21_8:1_avsq=on:avsqr=1,16:cnfonf=off:fd=off:prag=on:s2a=on:slsq=on:slsqc=2:slsqr=2,31:sos=all:i=7099:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:fe=off:nwc=10.0:sd=1:sos=on:ss=axioms:st=1.5:i=8702:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_av=off:bd=off:ntd=on:prag=on:sos=all:sp=occurrence:i=5212:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=on:au=on:avsq=on:bd=off:cnfonf=off:fe=off:sd=2:ss=axioms:st=2.0:i=6777:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_au=on:bd=off:cnfonf=lazy_simp:fd=off:fsr=off:sd=3:sgt=20:sp=unary_frequency:ss=axioms:i=8801:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_av=off:ins=3:sos=all:ss=axioms:i=10813:si=on:rtra=on_0"); + quick.push("ott+10_16:1_amm=off:au=on:avsq=on:cnfonf=lazy_not_gen_be_off:piset=equals:s2a=on:s2at=3.0:i=8464:si=on:rtra=on_0"); + quick.push("dis+3_10:23_bd=off:fde=none:fe=off:nwc=5.0:sac=on:sfv=off:sp=occurrence:i=14070:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:cnfonf=off:piset=equals:sd=1:sos=all:ss=axioms:i=11466:si=on:rtra=on_0"); + quick.push("dis+2_1:40_au=on:av=off:fd=off:hfsq=on:hfsqr=1,32:nm=2:sos=on:sp=const_min:i=11391:si=on:rtra=on_0"); + // Improves by expected 33.334496597666266 probs costing 479797 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("lrs+10_1:1_au=on:fe=axiom:plsq=on:plsqr=32,1:sos=all:ss=axioms:i=4201:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_av=off:fd=off:fsr=off:hud=1:plsq=on:plsqr=32,1:prag=on:sd=2:sos=all:ss=axioms:st=2.0:i=13662:si=on:rtra=on_0"); + quick.push("dis+10_1:1_nwc=10.0:prag=on:s2a=on:s2agt=64:sp=unary_first:uhcvi=on:i=12648:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:cnfonf=off:fd=off:fe=off:ntd=on:prag=on:sos=all:i=9759:si=on:rtra=on_0"); + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=16940:si=on:rtra=on_0"); + quick.push("ott+10_8:1_apa=on:au=on:av=off:cnfonf=off:nwc=10.0:sp=reverse_arity:ss=axioms:i=50131:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=lazy_not_be_gen:fe=axiom:fs=off:fsr=off:plsq=on:s2a=on:s2at=2.0:sos=all:i=3340:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:av=off:cnfonf=lazy_pi_sigma_gen:fsr=off:nwc=6.0:s2a=on:s2agt=16:i=24878:si=on:rtra=on_0"); + quick.push("ott+2_1:1_anc=all_dependent:cnfonf=lazy_pi_sigma_gen:fe=off:nwc=10.0:s2a=on:s2agt=100:i=39415:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1024_au=on:av=off:ntd=on:sos=on:sp=frequency:ss=axioms:st=5.0:i=3525:si=on:rtra=on_0"); + quick.push("dis+21_1:16_avsq=on:avsqr=3,1:bd=preordered:cha=on:cnfonf=off:e2e=on:fsr=off:sos=on:sp=weighted_frequency:tnu=2:i=3358:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_au=on:awrs=decay:bsr=on:e2e=on:fe=off:nm=40:nwc=10.0:piset=all:sos=all:i=9251:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:cs=on:fd=off:fde=unused:nm=4:ntd=on:prag=on:sos=all:sp=unary_first:i=9543:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:av=off:bd=preordered:bsr=on:c=on:nwc=10.0:s2a=on:ss=axioms:i=20296:si=on:rtra=on_0"); + quick.push("lrs+1002_3:2_au=on:bsr=unit_only:hud=10:ntd=on:piset=all_but_not_eq:s2a=on:s2at=7.0:sd=2:sos=all:ss=axioms:i=16038:si=on:rtra=on_0"); + quick.push("lrs-1004_1:1_c=on:cnfonf=off:nm=2:plsq=on:plsqc=1:plsqr=14,1:sp=const_frequency:ss=axioms:i=9327:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:er=filter:fd=off:fs=off:fsr=off:hud=20:kws=arity:nm=40:nwc=6.0:sd=7:sos=on:ss=axioms:i=5708:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:nm=0:sos=all:sp=const_frequency:i=7666:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:er=known:fe=off:s2a=on:sac=on:sos=on:i=4146:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_abs=on:amm=off:atotf=0.4:au=on:avsq=on:fe=axiom:hfsq=on:hfsqc=1:kws=frequency:ntd=on:nwc=3.0:prag=on:s2a=on:i=6978:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=conj_eager:ins=3:nwc=4.0:plsq=on:plsqc=1:plsqr=15179,262144:sac=on:sd=1:ss=axioms:i=9037:si=on:rtra=on_0"); + quick.push("lrs+1004_5:1_apa=on:avsq=on:cnfonf=off:e2e=on:fe=axiom:fsr=off:ntd=on:plsq=on:plsqc=1:plsqr=32,1:sp=const_max:i=4559:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_avsq=on:bsr=unit_only:cnfonf=off:kws=frequency:nm=32:sos=on:sp=const_frequency:i=4544:si=on:rtra=on_0"); + quick.push("ott+10_1:1_au=on:avsq=on:avsqr=1,16:c=on:cnfonf=off:sd=1:sos=all:ss=axioms:st=5.0:i=2889:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_bs=unit_only:cnfonf=lazy_not_gen_be_off:fe=off:fsr=off:hfsq=on:lecc=1.5:nwc=7.0:piset=equals:s2a=on:s2agt=10:sac=on:i=8945:si=on:rtra=on_0"); + quick.push("dis+1010_2:1_acc=on:au=on:avsq=on:avsqr=1,2:bd=off:bs=unit_only:fe=axiom:sp=const_max:i=107085:si=on:rtra=on_0"); + quick.push("ott+1010_2:3_aac=none:afr=on:cnfonf=lazy_gen:fe=axiom:hud=1:nwc=10.0:piset=all_but_not_eq:prag=on:s2a=on:s2at=3.0:i=38728:si=on:rtra=on_0"); + quick.push("ott+10_3:1_c=on:cnfonf=lazy_not_be_gen:fsr=off:ntd=on:sd=10:sos=all:ss=axioms:st=2.0:i=8601:si=on:rtra=on_0"); + quick.push("dis+1010_1:64_acc=model:au=on:awrs=converge:awrsf=200:nwc=10.0:s2a=on:s2at=1.2:slsq=on:i=16649:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cnfonf=off:e2e=on:hud=10:ins=2:plsq=on:plsqc=1:plsqr=32,1:s2a=on:sac=on:sos=on:i=26547:si=on:rtra=on_0"); + quick.push("lrs+1002_1:32_avsq=on:fd=off:sos=on:i=15956:si=on:rtra=on_0"); + quick.push("dis+1010_4:1_au=on:cnfonf=lazy_pi_sigma_gen:sac=on:sgt=8:ss=axioms:i=6334:si=on:rtra=on_0"); + quick.push("dis+10_1:3_au=on:cnfonf=lazy_pi_sigma_gen:fe=axiom:nwc=5.0:s2a=on:s2at=3.0:sac=on:sp=const_max:i=3701:si=on:rtra=on_0"); + quick.push("lrs+1010_5:1_apa=on:au=on:av=off:cnfonf=off:fe=axiom:sos=on:i=7349:si=on:rtra=on_0"); + quick.push("lrs+1010_2:1_au=on:av=off:e2e=on:fe=off:kws=inv_frequency:sos=on:i=8672:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:cnfonf=off:prag=on:sd=2:sos=all:ss=axioms:i=22332:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=off:inj=on:kws=precedence:ntd=on:sos=on:sp=reverse_arity:i=3320:si=on:rtra=on_0"); + quick.push("ott+1004_4:1_av=off:cbe=off:fsr=off:ins=3:kws=inv_frequency:nm=20:prag=on:i=38170:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:e2e=on:sos=all:i=9092:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_acc=on:bd=off:cnfonf=off:fe=axiom:kws=inv_arity_squared:piset=equals:prag=on:sd=1:sp=reverse_arity:ss=axioms:tgt=ground:i=4302:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_atotf=0.4:au=on:bsr=unit_only:cbe=off:e2e=on:fe=axiom:sos=on:sp=reverse_arity:i=8305:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bsr=unit_only:s2a=on:sos=all:ss=axioms:i=10056:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:fe=off:sos=on:sp=unary_first:i=6400:si=on:rtra=on_0"); + quick.push("lrs+20_1:4_au=on:bd=off:e2e=on:slsq=on:slsqr=1,8:sos=on:i=5185:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_hud=1:inj=on:prag=on:s2a=on:sos=all:i=16774:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:nm=2:plsq=on:plsqr=32,1:sos=all:i=20437:si=on:rtra=on_0"); + quick.push("dis+21_1:1_c=on:e2e=on:fe=axiom:sd=2:sp=frequency:ss=axioms:i=31036:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cnfonf=conj_eager:fe=off:fsr=off:piset=and:prag=on:s2a=on:s2agt=40:sp=const_min:spb=non_intro:i=19675:si=on:rtra=on_0"); + quick.push("dis+2_1:3_au=on:bs=on:bsr=unit_only:e2e=on:hud=5:nwc=10.0:sgt=10:sos=on:sp=frequency:ss=axioms:i=22664:si=on:rtra=on_0"); + quick.push("lrs+10_1:1024_aac=none:anc=all:au=on:bd=off:fd=off:fe=off:kws=precedence:piset=pi_sigma:plsq=on:plsqr=4689123,65536:sos=all:sp=unary_frequency:i=7093:si=on:rtra=on_0"); + quick.push("ott+21_4:1_e2e=on:flr=on:nwc=10.0:s2a=on:s2at=3.0:i=32613:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_fe=axiom:prag=on:sos=all:sp=reverse_arity:ss=axioms:i=4712:si=on:rtra=on_0"); + quick.push("dis+21_1:1_fe=axiom:sd=1:sos=on:ss=axioms:i=6777:si=on:rtra=on_0"); + quick.push("dis+21_8:1_avsq=on:avsqr=1,16:cnfonf=off:fd=off:prag=on:s2a=on:slsq=on:slsqc=2:slsqr=2,31:sos=all:i=7099:si=on:rtra=on_0"); + quick.push("lrs+1002_4:1_afr=on:au=on:ins=2:kws=precedence:sos=on:sp=weighted_frequency:i=12621:si=on:rtra=on_0"); + quick.push("lrs+1010_4:1_avsq=on:sac=on:sp=const_max:ss=axioms:i=8888:si=on:rtra=on_0"); + quick.push("dis+10_5:4_acc=on:amm=off:cnfonf=off:ins=3:ixr=off:nwc=3.0:ss=axioms:st=2.0:i=8889:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:cnfonf=lazy_not_gen_be_off:nm=16:ntd=on:nwc=5.0:s2a=on:s2at=4.5:i=8124:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_acc=on:au=on:avsq=on:bd=off:cnfonf=off:fe=off:sd=2:ss=axioms:st=2.0:i=8034:si=on:rtra=on_0"); + quick.push("lrs+21_3:1_au=on:avsq=on:avsqr=1,2:fsr=off:hfsq=on:nm=0:ntd=on:sd=1:ss=axioms:i=12690:si=on:rtra=on_0"); + quick.push("dis+2_1:40_au=on:av=off:fd=off:hfsq=on:hfsqr=1,32:nm=2:sos=on:sp=const_min:i=11391:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=off:fs=off:fsr=off:sd=10:sos=on:ss=axioms:st=5.0:i=8726:si=on:rtra=on_0"); + quick.push("ott+1010_2:1_abs=on:au=on:e2e=on:fde=unused:piset=equals:s2a=on:s2at=5.0:i=41200:si=on:rtra=on_0"); + quick.push("dis+21_1:1_avsq=on:avsqr=1,16:bd=off:hud=1:ins=1:prag=on:sos=on:ss=included:i=9461:si=on:rtra=on_0"); + quick.push("ott+10_16:1_bsd=on:c=on:nm=32:s2a=on:sac=on:sos=all:i=13341:si=on:rtra=on_0"); + // Improves by expected 21.49337275538251 probs costing 959748 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("ott-32_8:1_ntd=on:nwc=10.0:prag=on:sos=on:uhcvi=on:i=18524:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_au=on:bet=on:c=on:cnfonf=off:lcm=reverse:piset=small_set:sd=1:sp=reverse_frequency:ss=axioms:i=90001:si=on:rtra=on_0"); + quick.push("lrs+1666_4:1_au=on:i=60219:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_anc=all:au=on:bd=off:cnfonf=off:fd=off:fs=off:fsr=off:nwc=5.0:sac=on:sos=on:ss=axioms:i=42160:si=on:rtra=on_0"); + quick.push("ott+1010_3:2_acc=on:au=on:cnfonf=off:fsr=off:ins=3:nm=40:ntd=on:s2a=on:s2agt=60:slsq=on:i=14357:si=on:rtra=on_0"); + quick.push("lrs+1002_1:3_apa=on:atotf=0.1:au=on:bd=off:cnfonf=off:plsq=on:plsqr=178679,1048576:sos=on:i=10665:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_au=on:awrs=decay:bsr=on:e2e=on:fe=off:nm=40:nwc=10.0:piset=all:sos=all:i=9251:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:cs=on:fd=off:fde=unused:nm=4:ntd=on:prag=on:sos=all:sp=unary_first:i=9543:si=on:rtra=on_0"); + quick.push("lrs+1002_3:2_au=on:bsr=unit_only:hud=10:ntd=on:piset=all_but_not_eq:s2a=on:s2at=7.0:sd=2:sos=all:ss=axioms:i=16038:si=on:rtra=on_0"); + quick.push("lrs+10_8:3_bd=off:e2e=on:inj=on:s2agt=16:slsq=on:slsqc=1:ss=axioms:i=16221:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:fd=off:ntd=on:sos=on:i=111403:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_abs=on:amm=off:atotf=0.4:au=on:avsq=on:fe=axiom:hfsq=on:hfsqc=1:kws=frequency:ntd=on:nwc=3.0:prag=on:s2a=on:i=6978:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=conj_eager:ins=3:nwc=4.0:plsq=on:plsqc=1:plsqr=15179,262144:sac=on:sd=1:ss=axioms:i=9037:si=on:rtra=on_0"); + quick.push("ott+10_3:1_c=on:cnfonf=lazy_not_be_gen:fsr=off:ntd=on:sd=10:sos=all:ss=axioms:st=2.0:i=9176:si=on:rtra=on_0"); + quick.push("lrs+1010_7:1_cnfonf=off:e2e=on:fe=off:hfaw=0:hflw=3:hfsq=on:hfsqc=3:ins=2:piset=or:spb=non_intro:i=25452:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:cnfonf=lazy_not_gen:fe=axiom:fsr=off:ins=3:nwc=10.0:s2a=on:i=35527:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cnfonf=off:e2e=on:hud=10:ins=2:plsq=on:plsqc=1:plsqr=32,1:s2a=on:sac=on:sos=on:i=26547:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_atotf=0.2:au=on:bsr=unit_only:cha=on:e2e=on:fsr=off:sd=1:sp=unary_first:ss=axioms:st=4.0:i=14118:si=on:rtra=on_0"); + quick.push("ott+10_1:1_kws=arity:prag=on:sd=1:sos=all:ss=axioms:st=3.0:i=20084:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:cnfonf=lazy_gen:fsr=off:ntd=on:sp=const_min:tgt=full:i=29543:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_aac=none:au=on:cnfonf=off:inj=on:kws=precedence:ntd=on:sos=on:sp=reverse_arity:i=5501:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:e2e=on:sos=all:i=28740:si=on:rtra=on_0"); + quick.push("ott+4_1:1_cbe=off:cnfonf=lazy_not_be_gen:hud=20:irw=on:nwc=5.0:piset=all:plsq=on:plsqr=32,1:prag=on:sos=all:sp=occurrence:i=9860:si=on:rtra=on_0"); + quick.push("ott+10_1:8_fe=off:hfaw=5:hfsq=on:hfsqc=1:hfsqr=5,1:hud=15:nwc=15.0:prag=on:s2a=on:s2agt=16:ss=axioms:st=2.0:i=24782:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:e2e=on:nwc=13.0:s2a=on:ss=axioms:i=16679:si=on:rtra=on_0"); + quick.push("dis+10_16:1_acc=on:au=on:fd=off:fsr=off:hflw=0:hfsq=on:kws=precedence:sd=1:ss=axioms:st=1.5:i=15687:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_hud=1:inj=on:prag=on:s2a=on:sos=all:i=16774:si=on:rtra=on_0"); + quick.push("ott+21_4:1_e2e=on:flr=on:nwc=10.0:s2a=on:s2at=3.0:i=32613:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_au=on:cnfonf=lazy_pi_sigma_gen:fe=off:s2a=on:s2at=1.5:i=27060:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bsr=unit_only:e2e=on:sos=on:ss=axioms:st=2.0:i=12207:si=on:rtra=on_0"); + quick.push("lrs+2_3:1_cnfonf=conj_eager:fe=axiom:ntd=on:sd=1:sgt=100:sp=occurrence:ss=axioms:i=13946:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:cbe=off:fe=off:nwc=10.0:sd=1:sos=on:ss=axioms:st=1.5:i=11320:si=on:rtra=on_0"); + quick.push("lrs+21_3:1_au=on:avsq=on:avsqr=1,2:fsr=off:hfsq=on:nm=0:ntd=on:sd=1:ss=axioms:i=12690:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=lazy_pi_sigma_gen:ntd=on:nwc=10.0:slsq=on:slsqc=1:sp=unary_frequency:uhcvi=on:i=32057:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:sd=2:sgt=64:sos=all:ss=axioms:i=115768:si=on:rtra=on_0"); + // Improves by expected 7.948723589584731 probs costing 950493 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("ott+1002_1:8_au=on:bd=off:cbe=off:e2e=on:fd=off:inj=on:nicw=on:sd=2:sos=on:sp=reverse_arity:ss=axioms:st=2.0:i=20258:si=on:rtra=on_0"); + quick.push("ott+10_8:1_apa=on:au=on:av=off:cnfonf=off:nwc=10.0:sp=reverse_arity:ss=axioms:i=50131:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:e2e=on:er=filter:hud=10:kws=precedence:sos=on:sp=weighted_frequency:ss=axioms:st=3.0:uhcvi=on:i=89296:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:bd=off:cnfonf=lazy_not_gen_be_off:kws=inv_frequency:ntd=on:nwc=15.0:plsq=on:plsqc=1:plsqr=6736429,1048576:i=25655:si=on:rtra=on_0"); + quick.push("lrs+1666_4:1_au=on:i=69997:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:cnfonf=lazy_gen:nwc=10.0:s2a=on:sp=unary_first:i=39214:si=on:rtra=on_0"); + quick.push("dis+10_8:1_au=on:avsq=on:avsqr=1,16:fe=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:rawr=on:i=68450:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:cs=on:fd=off:fde=unused:nm=4:ntd=on:prag=on:sos=all:sp=unary_first:i=11818:si=on:rtra=on_0"); + quick.push("dis+1010_2:3_abs=on:amm=off:atotf=0.4:au=on:avsq=on:fe=axiom:hfsq=on:hfsqc=1:kws=frequency:ntd=on:nwc=3.0:prag=on:s2a=on:i=26731:si=on:rtra=on_0"); + quick.push("ott+10_1:1_au=on:avsq=on:avsqr=1,16:c=on:cnfonf=off:sd=1:sos=all:ss=axioms:st=5.0:i=41921:si=on:rtra=on_0"); + quick.push("ott+1010_2:3_aac=none:afr=on:cnfonf=lazy_gen:fe=axiom:hud=1:nwc=10.0:piset=all_but_not_eq:prag=on:s2a=on:s2at=3.0:i=38728:si=on:rtra=on_0"); + quick.push("lrs+1010_5:1_au=on:cbe=off:s2a=on:s2agt=32:sac=on:i=153471:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:e2e=on:sos=all:i=28740:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_hud=1:inj=on:prag=on:s2a=on:sos=all:i=16774:si=on:rtra=on_0"); + quick.push("ott+21_4:1_e2e=on:flr=on:nwc=10.0:s2a=on:s2at=3.0:i=32613:si=on:rtra=on_0"); + quick.push("lrs+10_1:16_hud=10:inj=on:nm=10:ntd=on:nwc=10.0:plsq=on:plsqr=1,32:s2a=on:s2at=3.0:sp=const_frequency:i=40581:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=lazy_gen:kws=inv_frequency:plsq=on:plsqc=1:plsqr=20,1:i=54328:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_au=on:cnfonf=off:fs=off:fsr=off:sd=10:sos=on:ss=axioms:st=5.0:i=114378:si=on:rtra=on_0"); + // Improves by expected 4.215704352839791 probs costing 923066 Mi + // Overall score 874.3687486355826 probs on average / budget 3792674 Mi + } else { + // Sub-schedule for 10000Mi strat cap / 10000Mi overall limit + quick.push("lrs+1002_1:1_au=on:av=off:fd=off:fde=unused:ntd=on:sos=on:sp=frequency:ss=axioms:i=782:si=on:rtra=on_0"); + quick.push("lrs+1002_2:3_avsq=on:fde=none:nwc=3.0:prag=on:sac=on:sd=2:sgt=32:sos=on:sp=unary_frequency:ss=axioms:i=754:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:cnfonf=off:e2e=on:piset=small_set:sac=on:sd=1:sos=all:ss=axioms:st=5.0:i=810:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:sd=1:sos=all:ss=axioms:st=1.5:i=617:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:ntd=on:nwc=5.0:sac=on:sd=1:sgt=16:spb=units:ss=axioms:i=660:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:ins=3:sos=on:ss=axioms:i=707:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_e2e=on:fd=off:fe=off:prag=on:sos=on:i=826:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:fd=off:sos=on:sp=unary_frequency:ss=axioms:i=835:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_acc=on:au=on:chr=on:cnfonf=off:fd=preordered:nwc=10.0:s2a=on:i=705:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:e2e=on:ixr=off:s2a=on:sd=2:sp=occurrence:ss=axioms:i=608:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=unused:nwc=5.0:sac=on:sos=all:sp=const_frequency:i=876:si=on:rtra=on_0"); + quick.push("lrs+1010_1:5_cnfonf=lazy_pi_sigma_gen:kws=precedence:nm=32:nwc=10.0:sp=const_frequency:i=15:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_acc=model:au=on:avsq=on:fd=off:hfsq=on:s2a=on:s2agt=16:sgt=10:sp=unary_frequency:ss=axioms:i=1727:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:sd=1:ss=axioms:i=2:si=on:rtra=on_0"); + // Improves by expected 2258.269138383958 probs costing 9910 Mi + // Sub-schedule for 20000Mi strat cap / 20000Mi overall limit + quick.push("dis+1002_1:1_au=on:kws=inv_precedence:nwc=5.0:sd=1:sgt=32:ss=axioms:i=947:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:bd=off:cnfonf=off:fd=off:sos=all:i=2392:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=2494:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=1258:si=on:rtra=on_0"); + quick.push("ott+2_1:128_bd=off:ins=3:kws=precedence:sd=1:sos=on:sp=frequency:ss=axioms:st=5.0:i=297:si=on:rtra=on_0"); + quick.push("lrs+0_1:1_fe=off:prag=on:sos=all:ss=axioms:i=988:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:cbe=off:nm=10:sd=1:sos=all:ss=axioms:st=3.0:i=423:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:kws=precedence:sos=on:sp=reverse_arity:ss=axioms:i=742:si=on:rtra=on_0"); + quick.push("lrs+1010_1:4_au=on:avsq=on:sd=2:sgt=8:ss=axioms:i=313:si=on:rtra=on_0"); + quick.push("lrs+1010_4:1_amm=off:awrs=decay:bsr=on:cbe=off:e2e=on:fde=none:fe=axiom:nwc=5.0:prag=on:sac=on:sd=1:spb=goal_then_units:ss=axioms:i=3335:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_hud=10:ins=2:sos=all:ss=axioms:tnu=1:i=229:si=on:rtra=on_0"); + quick.push("dis+10_8:1_au=on:e2e=on:sgt=8:ss=axioms:i=328:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_bd=off:cbe=off:hud=1:prag=on:sos=on:sp=const_min:ss=axioms:i=649:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:fde=none:plsq=on:plsqc=1:plsqr=32,1:sos=on:sp=const_frequency:ss=axioms:st=3.0:i=1048:si=on:rtra=on_0"); + quick.push("ott+1002_17:12_au=on:ins=3:sac=on:sd=3:sos=on:sp=occurrence:ss=axioms:i=1918:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=942:si=on:rtra=on_0"); + quick.push("dis+1002_1:32_au=on:c=on:fd=off:nm=2:sd=1:sos=on:sp=frequency:ss=axioms:st=3.0:i=1354:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2a=on:s2agt=8:sd=2:sgt=8:ss=axioms:i=355:si=on:rtra=on_0"); + // Improves by expected 212.0573861120701 probs costing 19994 Mi + // Sub-schedule for 30000Mi strat cap / 30000Mi overall limit + quick.push("dis+10_4:1_avsq=on:e2e=on:fde=none:s2a=on:s2at=3.0:slsq=on:slsqc=1:i=1101:si=on:rtra=on_0"); + quick.push("dis+10_1:1_avsq=on:cs=on:e2e=on:i=290:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_bd=preordered:cbe=off:e2e=on:fe=axiom:hud=5:s2a=on:s2agt=60:slsq=on:ss=axioms:tnu=1:i=2233:si=on:rtra=on_0"); + quick.push("dis+10_1:1_avsq=on:cnfonf=lazy_pi_sigma_gen:sd=1:ss=axioms:i=265:si=on:rtra=on_0"); + quick.push("lrs+2_1:64_bd=off:nwc=5.0:sd=2:ss=axioms:i=290:si=on:rtra=on_0"); + quick.push("lrs+1002_2:3_avsq=on:fde=none:nwc=3.0:prag=on:sac=on:sd=2:sgt=32:sos=on:sp=unary_frequency:ss=axioms:i=3711:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_bd=off:e2e=on:ins=1:sac=on:sd=1:sos=on:ss=axioms:st=2.0:i=585:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:au=on:cnfonf=off:e2e=on:hud=15:sos=on:i=1337:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:sd=1:sos=all:ss=axioms:st=1.5:i=1186:si=on:rtra=on_0"); + quick.push("lrs+4_1:1_fd=off:fs=off:fsr=off:sac=on:sos=on:ss=axioms:i=413:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_e2e=on:nwc=5.0:sd=1:sgt=30:ss=axioms:i=980:si=on:rtra=on_0"); + quick.push("dis+10_3:1_avsq=on:sd=1:ss=axioms:st=2.0:tgt=ground:i=278:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_kws=precedence:sos=on:sp=frequency:ss=axioms:i=252:si=on:rtra=on_0"); + quick.push("lrs+31_1:1_au=on:cnfonf=off:ins=3:plsq=on:sd=1:sgt=32:sos=on:ss=axioms:i=494:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_fd=off:hud=20:sos=on:ss=axioms:tnu=2:i=289:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bsd=on:fsd=on:nwc=10.0:sd=1:ss=axioms:i=401:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_sd=1:sgt=30:sp=reverse_arity:ss=axioms:tgt=full:i=633:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:avsqr=1,16:kws=arity_squared:nm=20:sd=1:sp=const_frequency:ss=axioms:i=134:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_er=filter:fd=off:flr=on:nwc=10.0:ss=axioms:st=3.0:i=365:si=on:rtra=on_0"); + quick.push("lrs+20_1:1_au=on:bd=off:erd=off:fde=none:sos=on:i=493:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=off:fde=unused:fe=off:fs=off:fsr=off:hud=10:sos=on:i=719:si=on:rtra=on_0"); + quick.push("dis+10_1:1_hud=5:nm=16:prag=on:sac=on:sos=on:ss=axioms:tnu=2:i=1029:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:c=on:cnfonf=off:e2e=on:ins=1:kws=precedence:ntd=on:sd=2:sos=on:ss=axioms:st=2.0:i=640:si=on:rtra=on_0"); + quick.push("dis+10_1:32_fd=off:kws=precedence:sd=2:sos=on:ss=axioms:i=237:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_sd=2:slsq=on:slsqc=1:ss=axioms:i=751:si=on:rtra=on_0"); + quick.push("ott+10_1:1_atotf=0.1:au=on:cnfonf=off:e2e=on:fsr=off:ins=4:kws=precedence:s2a=on:i=2166:si=on:rtra=on_0"); + quick.push("lrs+1002_1:2_e2e=on:sd=2:sgt=16:ss=axioms:i=502:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_acc=model:au=on:avsq=on:fd=off:hfsq=on:s2a=on:s2agt=16:sgt=10:sp=unary_frequency:ss=axioms:i=4453:si=on:rtra=on_0"); + quick.push("dis+10_4:1_apa=on:au=on:cnfonf=off:fde=none:sd=2:ss=axioms:st=3.0:i=691:si=on:rtra=on_0"); + quick.push("lrs+10_1:4_au=on:av=off:bd=off:e2e=on:sos=all:i=1786:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_e2e=on:hud=10:sd=1:ss=axioms:st=3.0:tgt=ground:i=621:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:fd=preordered:sos=on:ss=axioms:st=1.5:i=621:si=on:rtra=on_0"); + // Improves by expected 134.93277978747452 probs costing 29914 Mi + // Sub-schedule for 60000Mi strat cap / 60000Mi overall limit + quick.push("lrs+10_1:1_au=on:cnfonf=off:sd=1:sos=all:ss=axioms:st=3.0:i=541:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:av=off:fd=off:fde=unused:ntd=on:sos=on:sp=frequency:ss=axioms:i=2132:si=on:rtra=on_0"); + quick.push("dis+2_16:1_e2e=on:gs=on:s2a=on:s2agt=32:sgt=32:ss=axioms:i=1182:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:c=on:ins=3:plsq=on:plsqc=5:sd=1:sos=on:ss=axioms:i=567:si=on:rtra=on_0"); + quick.push("ott+10_5:4_au=on:avsq=on:bs=unit_only:bsr=unit_only:fsr=off:ins=3:kws=arity:sd=1:sos=all:ss=axioms:i=1467:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqr=16,1:fd=off:nm=2:sos=all:i=890:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:fde=unused:nm=2:sac=on:sos=all:i=5985:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_apa=on:bsr=on:cnfonf=off:hud=10:ins=2:kws=inv_frequency:sd=2:slsq=on:slsqc=5:sos=on:ss=axioms:i=240:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_bd=off:fd=off:kws=inv_precedence:sos=on:ss=axioms:i=375:si=on:rtra=on_0"); + quick.push("ott+10_1:1_acc=model:avsq=on:c=on:cnfonf=off:fd=off:nm=0:sp=reverse_arity:ss=axioms:i=551:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_afp=1010:fde=unused:fe=off:hud=10:kws=arity_squared:prag=on:sos=on:sp=reverse_arity:i=1031:si=on:rtra=on_0"); + quick.push("dis+1002_2:3_aac=none:au=on:avsq=on:cbe=off:fde=none:lcm=predicate:nm=32:prag=on:sos=on:sp=unary_first:ss=axioms:st=2.0:i=1600:si=on:rtra=on_0"); + quick.push("dis+10_5:1_au=on:avsq=on:ss=axioms:i=516:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:ntd=on:nwc=5.0:sac=on:sd=1:sgt=16:spb=units:ss=axioms:i=3945:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:cnfonf=conj_eager:ins=1:sac=on:sp=const_max:ss=axioms:st=3.0:tgt=ground:i=267:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:hud=10:sd=4:sos=on:ss=axioms:st=2.0:i=828:si=on:rtra=on_0"); + quick.push("ott+1010_1:4_au=on:avsq=on:avsqc=1:cnfonf=off:e2e=on:fsr=off:ins=1:nwc=10.0:s2a=on:s2at=2.5:sac=on:sp=const_min:i=693:si=on:rtra=on_0"); + quick.push("lrs+1010_1:4_au=on:e2e=on:hud=10:nm=32:plsq=on:plsqc=1:plsqr=32,1:sac=on:sos=on:i=1381:si=on:rtra=on_0"); + quick.push("dis+10_1:64_cnfonf=lazy_not_be_gen:cond=fast:fsr=off:hud=5:ntd=on:nwc=10.0:sac=on:sd=1:sos=on:sp=const_max:ss=axioms:i=798:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:fd=off:sos=on:sp=unary_frequency:ss=axioms:i=3962:si=on:rtra=on_0"); + quick.push("lrs+2_1:3_au=on:bd=off:e2e=on:sos=on:ss=axioms:i=577:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_au=on:avsq=on:cbe=off:plsq=on:plsqc=1:plsqr=32,1:rawr=on:rp=on:sd=2:ss=axioms:st=3.0:i=5743:si=on:rtra=on_0"); + quick.push("dis+10_5:1_cnfonf=off:slsq=on:sp=const_max:i=571:si=on:rtra=on_0"); + quick.push("dis+10_1:1_e2e=on:hflw=5:hfsq=on:hfsqc=8:hfsql=off:i=273:si=on:rtra=on_0"); + quick.push("lrs+0_1:1_au=on:ins=3:kws=precedence:ntd=on:sos=on:sp=const_max:ss=axioms:i=476:si=on:rtra=on_0"); + quick.push("dis+2_1:1_cnfonf=off:e2e=on:kws=inv_frequency:nm=0:nwc=5.0:s2a=on:s2agt=32:ss=axioms:i=487:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_e2e=on:plsq=on:plsqr=32,1:sgt=8:ss=axioms:i=1796:si=on:rtra=on_0"); + quick.push("dis+22_1:1_au=on:fe=axiom:ntd=on:nwc=10.0:s2a=on:i=559:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:avsqr=1,16:kws=arity_squared:nm=20:sd=1:sp=const_frequency:ss=axioms:i=638:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_acc=on:anc=all_dependent:avsq=on:fde=unused:hud=1:ins=2:piset=all_but_not_eq:prag=on:sac=on:i=6474:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_cnfonf=lazy_not_gen_be_off:hud=5:sd=1:ss=axioms:i=597:si=on:rtra=on_0"); + quick.push("ott+2_1:128_bd=off:ins=3:kws=precedence:sd=1:sos=on:sp=frequency:ss=axioms:st=5.0:i=290:si=on:rtra=on_0"); + quick.push("dis+2_1:1_au=on:avsq=on:nm=0:sd=1:ss=axioms:i=708:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_avsq=on:fsr=off:nm=2:prag=on:sos=on:i=748:si=on:rtra=on_0"); + quick.push("dis+1010_1:16_amm=sco:cnfonf=off:sd=1:ss=axioms:st=2.0:tgt=full:tnu=5:i=1806:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=preordered:hud=15:kws=precedence:nm=16:sd=3:sgt=16:sos=on:sp=frequency:ss=axioms:i=483:si=on:rtra=on_0"); + quick.push("ott+10_16:1_aac=none:au=on:cnfonf=off:nm=20:s2a=on:ss=axioms:i=5155:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_au=on:cnfonf=lazy_pi_sigma_gen:fd=off:fsr=off:s2a=on:s2agt=10:i=1398:si=on:rtra=on_0"); + quick.push("dis+32_1:2_au=on:cnfonf=lazy_pi_sigma_gen:kws=inv_precedence:nwc=10.0:s2a=on:s2agt=30:i=1441:si=on:rtra=on_0"); + quick.push("dis+10_1:8_ins=1:nm=6:s2a=on:sd=3:ss=axioms:i=451:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:ins=2:sos=on:ss=axioms:st=1.5:i=350:si=on:rtra=on_0"); + // Improves by expected 120.32336523397528 probs costing 59931 Mi + // Sub-schedule for 120000Mi strat cap / 120000Mi overall limit + quick.push("lrs+10_1:1_au=on:av=off:cnfonf=off:fde=none:fsr=off:sos=on:sp=const_frequency:i=854:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:fde=none:kws=inv_precedence:nwc=5.0:plsq=on:plsqc=1:plsqr=6,1:prag=on:s2a=on:i=1328:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cs=on:prag=on:sos=on:i=1475:si=on:rtra=on_0"); + quick.push("ott+10_1:1_hud=15:ins=1:sd=1:sgt=32:sos=all:ss=axioms:st=2.0:i=1132:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:av=off:cnfonf=lazy_not_gen_be_off:fe=axiom:kws=arity:nwc=5.0:ss=axioms:i=4969:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_cbe=off:e2e=on:hud=10:sd=1:ss=axioms:st=3.0:tgt=ground:i=1144:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_au=on:avsq=on:e2e=on:fde=unused:nm=6:nwc=10.0:sac=on:i=4810:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_atotf=0.1:au=on:cnfonf=off:inj=on:piset=and:s2a=on:sos=on:i=944:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_au=on:avsq=on:e2e=on:nm=0:s2a=on:s2at=1.5:i=2837:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_apa=on:bsr=on:cnfonf=off:hud=10:ins=2:kws=inv_frequency:sd=2:slsq=on:slsqc=5:sos=on:ss=axioms:i=240:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:cnfonf=off:hud=10:nm=32:sac=on:sd=1:sims=off:sos=all:ss=axioms:st=2.0:i=1511:si=on:rtra=on_0"); + quick.push("dis-1004_8:1_av=off:bd=off:fd=off:fe=off:hud=22:sos=on:tnu=2:i=883:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:av=off:fde=unused:hfsq=on:hfsqr=16,1:hud=10:lma=on:nm=3:piset=and:sos=all:sp=const_frequency:i=408:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_cnfonf=lazy_pi_sigma_gen:ins=1:nm=32:ntd=on:nwc=10.0:prag=on:s2at=3.0:slsq=on:slsqr=1,16:i=1080:si=on:rtra=on_0"); + quick.push("dis+1010_4:1_amm=off:bs=on:c=on:cbe=off:nm=64:nwc=6.0:s2a=on:s2at=5.0:sac=on:slsq=on:slsqr=1,8:i=1108:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_ins=3:prag=on:sos=on:sp=const_min:i=907:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:cnfonf=off:e2e=on:piset=small_set:sac=on:sd=1:sos=all:ss=axioms:st=5.0:i=1025:si=on:rtra=on_0"); + quick.push("ott+1010_1:128_afp=1010:afq=2.19963:avsq=on:avsqr=1,8:er=known:sd=1:ss=axioms:i=1045:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:cnfonf=conj_eager:ins=1:sac=on:sp=const_max:ss=axioms:st=3.0:tgt=ground:i=241:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_au=on:av=off:cnfonf=off:cond=fast:nm=6:sos=all:i=2216:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:bd=off:fd=off:kws=inv_frequency:sos=on:i=766:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:kws=inv_precedence:nwc=5.0:sd=1:sgt=32:ss=axioms:i=3722:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_apa=on:au=on:bsr=on:cnfonf=off:fe=off:nm=32:prag=on:sac=on:sos=on:sp=unary_first:ss=axioms:i=1895:si=on:rtra=on_0"); + quick.push("dis+10_1:1_atotf=0.5:fe=axiom:fsr=off:sd=1:sgt=16:sos=all:ss=axioms:i=1467:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:fd=off:sos=on:sp=unary_frequency:ss=axioms:i=464:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:e2e=on:fe=off:prag=on:sos=all:sp=const_frequency:ss=axioms:i=4945:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:e2e=on:ins=2:sd=1:sos=all:ss=axioms:st=3.0:i=326:si=on:rtra=on_0"); + quick.push("ott+10_4:1_e2e=on:fde=unused:nm=40:nwc=10.0:s2a=on:s2at=2.0:sp=unary_frequency:ss=axioms:i=1443:si=on:rtra=on_0"); + quick.push("lrs+2_1:6_au=on:cnfonf=off:ss=axioms:st=1.5:i=1438:si=on:rtra=on_0"); + quick.push("dis+21_8:1_au=on:cbe=off:cnfonf=off:hud=15:nwc=5.0:piset=not:sos=all:sp=unary_frequency:ss=axioms:i=3365:si=on:rtra=on_0"); + quick.push("dis+10_1:128_av=off:fde=unused:hud=1:prag=on:sos=all:ss=axioms:i=3425:si=on:rtra=on_0"); + quick.push("dis+3_7:4_bsr=on:c=on:erd=off:fde=none:hud=10:lma=on:nwc=5.0:sac=on:sos=on:sp=frequency:i=2203:si=on:rtra=on_0"); + quick.push("lrs+31_1:1_au=on:cnfonf=off:ins=3:plsq=on:sd=1:sgt=32:sos=on:ss=axioms:i=289:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_aac=none:cbe=off:cnfonf=lazy_pi_sigma_gen:sos=all:sp=const_max:uhcvi=on:i=753:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_avsq=on:bsd=on:cnfonf=off:nm=10:piset=all_but_not_eq:s2a=on:s2at=6.0:sp=const_min:i=2214:si=on:rtra=on_0"); + quick.push("ott+2_1:1024_apa=on:atotf=0.2:bd=off:cnfonf=off:erd=off:fd=off:nm=0:sos=all:i=1527:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_bd=off:chr=on:erd=off:fd=off:fe=axiom:hud=10:sac=on:sos=on:i=538:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_c=on:fsr=off:hud=0:kws=inv_arity:ntd=on:sos=on:sp=occurrence:i=1098:si=on:rtra=on_0"); + quick.push("dis+22_1:1_au=on:fe=axiom:ntd=on:nwc=10.0:s2a=on:i=1348:si=on:rtra=on_0"); + quick.push("ott+10_1:1_s2a=on:s2at=2.0:sd=2:ss=axioms:i=7135:si=on:rtra=on_0"); + quick.push("dis+21_1:4_avsq=on:avsqr=924271,1048576:c=on:e2e=on:fs=off:fsr=off:piset=and:plsq=on:plsqr=32,1:sd=10:sos=on:sp=unary_first:ss=axioms:st=1.5:tnu=2:i=791:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_e2e=on:sd=1:ss=axioms:st=3.0:i=6037:si=on:rtra=on_0"); + quick.push("dis+1010_3:1_acc=on:au=on:chr=on:cnfonf=off:fd=preordered:nwc=10.0:s2a=on:i=938:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:e2e=on:ixr=off:s2a=on:sd=2:sp=occurrence:ss=axioms:i=4357:si=on:rtra=on_0"); + quick.push("dis+10_1:2_au=on:cnfonf=lazy_pi_sigma_gen:ss=axioms:st=1.2:tgt=ground:i=938:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_bs=on:e2e=on:prag=on:sos=on:ss=axioms:i=2052:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:kws=precedence:sos=on:sp=frequency:ss=axioms:st=3.0:i=728:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=lazy_pi_sigma_gen:sd=1:slsq=on:ss=axioms:i=753:si=on:rtra=on_0"); + quick.push("lrs+1002_4:1_au=on:cnfonf=off:er=filter:fde=none:ntd=on:nwc=10.0:i=1213:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:c=on:cnfonf=off:e2e=on:ins=1:kws=precedence:ntd=on:sd=2:sos=on:ss=axioms:st=2.0:i=1417:si=on:rtra=on_0"); + quick.push("ott+2_4:1_au=on:cnfonf=lazy_pi_sigma_gen:hud=16:ins=3:nm=20:plsq=on:plsqc=1:plsqr=13,2:rawr=on:sp=reverse_arity:ss=axioms:st=3.0:i=2643:si=on:rtra=on_0"); + quick.push("lrs+21_1:128_acc=model:au=on:cbe=off:e2e=on:pe=on:piset=small_set:sos=on:sp=occurrence:ss=axioms:i=1179:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_e2e=on:prag=on:rawr=on:sos=on:sp=weighted_frequency:i=991:si=on:rtra=on_0"); + quick.push("dis+21_1:1_bd=off:e2e=on:s2a=on:s2agt=32:sfv=off:ss=axioms:st=2.0:i=1247:si=on:rtra=on_0"); + quick.push("ott+10_4:1_au=on:cnfonf=lazy_gen:fde=unused:kws=precedence:s2a=on:s2at=2.0:sd=1:ss=axioms:st=5.0:i=2161:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:fde=none:sos=all:i=1840:si=on:rtra=on_0"); + quick.push("dis+1010_1:20_au=on:av=off:cbe=off:fe=off:nm=2:sos=on:sp=weighted_frequency:uhcvi=on:i=1141:si=on:rtra=on_0"); + quick.push("dis+10_1:8_au=on:c=on:sos=all:ss=axioms:i=1777:si=on:rtra=on_0"); + quick.push("dis+10_1:5_cnfonf=off:e2e=on:fsr=off:prag=on:s2a=on:i=647:si=on:rtra=on_0"); + quick.push("dis+10_1:128_atotf=0.1:fd=off:fsr=off:hflw=5:hfsq=on:hfsqc=5:hfsql=off:hfsqr=1,16:plsq=on:plsqr=9,8:tnu=1:i=1197:si=on:rtra=on_0"); + quick.push("ott+1666_4:1_au=on:bd=off:erd=off:ntd=on:sos=all:i=1038:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:e2e=on:hfsq=on:hfsql=off:lcm=reverse:nm=32:nwc=10.0:s2a=on:s2at=3.0:sd=1:ss=axioms:st=6.0:i=1290:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_acc=on:au=on:bd=off:sgt=16:ss=axioms:tgt=full:i=6550:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:cnfonf=off:sos=on:ss=axioms:i=4664:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_afr=on:cs=on:e2e=on:hfsq=on:hfsqc=20:ntd=on:nwc=10.0:s2a=on:i=1215:si=on:rtra=on_0"); + quick.push("dis+10_1:1024_bd=preordered:fde=unused:prag=on:sos=on:i=743:si=on:rtra=on_0"); + // Improves by expected 102.61049630834741 probs costing 119999 Mi + // Sub-schedule for 240000Mi strat cap / 240000Mi overall limit + quick.push("dis+10_4:1_avsq=on:e2e=on:fde=none:s2a=on:s2at=3.0:slsq=on:slsqc=1:i=1101:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=off:sd=1:sos=all:ss=axioms:st=3.0:i=972:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:fde=none:kws=inv_precedence:nwc=5.0:plsq=on:plsqc=1:plsqr=6,1:prag=on:s2a=on:i=4577:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:bsd=on:ins=3:plsq=on:plsqc=1:plsqr=1,1:s2a=on:s2at=3.0:sd=10:sp=weighted_frequency:ss=axioms:i=1655:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:av=off:fd=off:fde=unused:ntd=on:sos=on:sp=frequency:ss=axioms:i=2115:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_bd=preordered:cbe=off:e2e=on:fe=axiom:hud=5:s2a=on:s2agt=60:slsq=on:ss=axioms:tnu=1:i=7155:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_cnfonf=lazy_gen:fe=off:fsr=off:hud=15:nwc=10.0:s2a=on:i=4273:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_fe=off:hud=10:sos=on:ss=axioms:i=1016:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:e2e=on:fde=none:ins=3:kws=precedence:s2a=on:s2at=5.0:sp=frequency:i=2335:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:av=off:bsd=on:cnfonf=off:kws=arity_squared:sp=const_min:ss=axioms:i=3375:si=on:rtra=on_0"); + quick.push("ott+10_5:4_au=on:avsq=on:bs=unit_only:bsr=unit_only:fsr=off:ins=3:kws=arity:sd=1:sos=all:ss=axioms:i=5339:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqr=16,1:fd=off:nm=2:sos=all:i=5800:si=on:rtra=on_0"); + quick.push("dis+21_2:3_cnfonf=conj_eager:fsr=off:sd=1:slsq=on:ss=axioms:st=4.0:i=1845:si=on:rtra=on_0"); + quick.push("lrs+1002_2:3_avsq=on:fde=none:nwc=3.0:prag=on:sac=on:sd=2:sgt=32:sos=on:sp=unary_frequency:ss=axioms:i=6172:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:av=off:fde=unused:hfsq=on:hfsqr=16,1:hud=10:lma=on:nm=3:piset=and:sos=all:sp=const_frequency:i=9434:si=on:rtra=on_0"); + quick.push("ott+1010_16:1_av=off:fe=off:hud=10:ins=5:nwc=3.0:prag=on:rawr=on:i=4927:si=on:rtra=on_0"); + quick.push("dis+2_1:1_hflw=5:hfsq=on:hfsqc=8:hfsql=off:hfsqr=1,2:piset=pi_sigma:spb=goal:i=1805:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:bd=off:e2e=on:fde=none:ins=1:prag=on:sos=on:i=6247:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:avsq=on:hud=22:ins=3:ntd=on:nwc=3.0:s2a=on:sp=weighted_frequency:i=2589:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:cnfonf=conj_eager:ins=1:sac=on:sp=const_max:ss=axioms:st=3.0:tgt=ground:i=241:si=on:rtra=on_0"); + quick.push("lrs+1010_3:1_au=on:bd=off:fde=none:lecc=1.5:nwc=10.0:i=9473:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_e2e=on:fd=off:fe=off:prag=on:sos=on:i=4492:si=on:rtra=on_0"); + quick.push("dis+10_1:64_cnfonf=lazy_not_be_gen:cond=fast:fsr=off:hud=5:ntd=on:nwc=10.0:sac=on:sd=1:sos=on:sp=const_max:ss=axioms:i=798:si=on:rtra=on_0"); + quick.push("dis+10_16:1_au=on:avsq=on:cnfonf=conj_eager:piset=equals:s2a=on:sp=occurrence:ss=axioms:i=3218:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:fd=off:sos=on:sp=unary_frequency:ss=axioms:i=464:si=on:rtra=on_0"); + quick.push("lrs+2_1:3_au=on:bd=off:e2e=on:sos=on:ss=axioms:i=2601:si=on:rtra=on_0"); + quick.push("ott+10_4:1_e2e=on:fde=unused:nm=40:nwc=10.0:s2a=on:s2at=2.0:sp=unary_frequency:ss=axioms:i=11317:si=on:rtra=on_0"); + quick.push("dis+10_16:1_au=on:avsq=on:c=on:chr=on:nm=2:sac=on:sp=unary_first:ss=axioms:i=2545:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_fde=none:prag=on:sd=2:sgt=8:ss=axioms:tgt=ground:i=11785:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=4513:si=on:rtra=on_0"); + quick.push("lrs+1010_4:1_acc=on:au=on:bd=off:sfv=off:ss=axioms:i=10881:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_avsq=on:avsqr=16,1:cnfonf=conj_eager:nwc=10.0:plsq=on:plsqc=1:plsqr=32,1:sd=2:spb=intro:ss=axioms:i=1928:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_fd=off:hud=20:sos=on:ss=axioms:tnu=2:i=1063:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:avsq=on:fsr=off:ins=3:kws=frequency:sos=all:i=1479:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_bd=off:chr=on:erd=off:fd=off:fe=axiom:hud=10:sac=on:sos=on:i=538:si=on:rtra=on_0"); + quick.push("lrs+21_8:1_cnfonf=lazy_not_gen:nm=2:nwc=10.0:plsq=on:plsqc=2:plsqr=6,1:prag=on:sgt=8:sp=unary_frequency:ss=axioms:i=10373:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=off:fd=off:rp=on:sac=on:sos=on:i=1264:si=on:rtra=on_0"); + quick.push("dis+10_16:1_au=on:avsq=on:bet=on:cbe=off:cnfonf=off:ins=3:ntd=on:plsq=on:plsqc=1:plsqr=32,1:i=3847:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_au=on:bs=on:bsr=unit_only:c=on:fsr=off:hud=10:kws=inv_precedence:nm=6:ntd=on:nwc=10.0:sac=on:sos=on:i=1617:si=on:rtra=on_0"); + quick.push("dis+10_1:12_cnfonf=conj_eager:ss=axioms:st=3.0:tgt=full:i=620:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_bd=off:bet=on:bsd=on:bsr=unit_only:fde=none:nwc=10.0:sp=occurrence:i=2482:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_atotf=0.2:au=on:bd=off:cnfonf=off:e2e=on:sos=all:i=3365:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=off:fde=none:ss=axioms:i=1579:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:e2e=on:ixr=off:s2a=on:sd=2:sp=occurrence:ss=axioms:i=490:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=7308:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_er=filter:fd=off:flr=on:nwc=10.0:ss=axioms:st=3.0:i=365:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:cnfonf=off:sd=1:sgt=16:sp=occurrence:ss=axioms:i=1367:si=on:rtra=on_0"); + quick.push("lrs+20_1:1_au=on:bd=off:erd=off:fde=none:sos=on:i=3577:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_aac=none:c=on:cnfonf=lazy_not_gen:sos=on:i=3633:si=on:rtra=on_0"); + quick.push("dis+1004_1:5_avsq=on:cs=on:e2e=on:ins=2:sos=all:i=1188:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=off:fe=off:nwc=10.0:s2a=on:s2agt=8:sd=1:ss=axioms:st=5.0:i=357:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:kws=precedence:sos=on:sp=frequency:ss=axioms:st=3.0:i=728:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:cnfonf=lazy_pi_sigma_gen:sd=1:slsq=on:ss=axioms:i=568:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:c=on:cnfonf=off:e2e=on:ins=1:kws=precedence:ntd=on:sd=2:sos=on:ss=axioms:st=2.0:i=5301:si=on:rtra=on_0"); + quick.push("dis+1010_73:128_bd=preordered:fsr=off:nwc=3.0:s2a=on:s2at=2.0:i=909:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_av=off:cnfonf=lazy_pi_sigma_gen:nwc=5.0:prag=on:s2a=on:s2agt=16:i=3801:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=preordered:hud=15:kws=precedence:nm=16:sd=3:sgt=16:sos=on:sp=frequency:ss=axioms:i=668:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_aac=none:bd=off:ins=2:sos=on:sp=reverse_frequency:ss=axioms:i=559:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:c=on:cnfonf=off:kws=inv_precedence:piset=and:sd=1:ss=axioms:tgt=ground:tnu=2:i=9010:si=on:rtra=on_0"); + quick.push("lrs+10_97:429_c=on:cnfonf=lazy_gen:fe=axiom:ntd=on:s2a=on:sp=const_frequency:tgt=ground:i=1342:si=on:rtra=on_0"); + quick.push("lrs+21_1:128_acc=model:au=on:cbe=off:e2e=on:pe=on:piset=small_set:sos=on:sp=occurrence:ss=axioms:i=494:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:bs=unit_only:bsd=on:cnfonf=off:fde=unused:fsr=off:hud=5:kws=inv_arity_squared:sp=const_min:i=2235:si=on:rtra=on_0"); + quick.push("dis+10_8:1_au=on:nwc=10.0:sos=all:i=3282:si=on:rtra=on_0"); + quick.push("lrs-4_1:1_sd=1:sgt=8:sos=all:ss=axioms:i=882:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_acc=model:au=on:avsq=on:fd=off:hfsq=on:s2a=on:s2agt=16:sgt=10:sp=unary_frequency:ss=axioms:i=5939:si=on:rtra=on_0"); + quick.push("ott+10_1:64_aac=none:acc=on:au=on:avsq=on:avsqr=2,15:cnfonf=lazy_not_gen_be_off:ins=1:tgt=full:i=3310:si=on:rtra=on_0"); + quick.push("ott+10_2:1_au=on:cnfonf=off:ins=1:plsq=on:plsqc=1:plsqr=10813507,131072:i=6244:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:sos=all:ss=axioms:i=1198:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_afr=on:cs=on:e2e=on:hfsq=on:hfsqc=20:ntd=on:nwc=10.0:s2a=on:i=4753:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=4954:si=on:rtra=on_0"); + // Improves by expected 83.63371839116107 probs costing 239607 Mi + // Sub-schedule for 480000Mi strat cap / 480000Mi overall limit + quick.push("dis+10_4:1_avsq=on:e2e=on:fde=none:s2a=on:s2at=3.0:slsq=on:slsqc=1:i=19923:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:fde=none:kws=inv_precedence:nwc=5.0:plsq=on:plsqc=1:plsqr=6,1:prag=on:s2a=on:i=13542:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:bsd=on:ins=3:plsq=on:plsqc=1:plsqr=1,1:s2a=on:s2at=3.0:sd=10:sp=weighted_frequency:ss=axioms:i=1655:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:av=off:fd=off:fde=unused:ntd=on:sos=on:sp=frequency:ss=axioms:i=2115:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_cnfonf=off:e2e=on:fde=unused:hud=10:nm=16:pe=on:s2a=on:s2at=2.0:tgt=ground:i=2601:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_fe=off:hud=10:sos=on:ss=axioms:i=1016:si=on:rtra=on_0"); + quick.push("dis+10_1:3_au=on:cnfonf=lazy_pi_sigma_gen:i=1623:si=on:rtra=on_0"); + quick.push("ott+10_1:1_atotf=0.1:bd=off:cnfonf=off:cs=on:ins=2:nwc=3.0:sd=10:ss=axioms:i=3771:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:av=off:bsd=on:cnfonf=off:kws=arity_squared:sp=const_min:ss=axioms:i=925:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_c=on:cnfonf=lazy_gen:fe=off:ins=2:nwc=5.0:s2a=on:sp=occurrence:i=3973:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:fde=unused:nm=2:sac=on:sos=all:i=14632:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cnfonf=lazy_pi_sigma_gen:plsq=on:sos=on:i=9176:si=on:rtra=on_0"); + quick.push("ott+1010_16:1_au=on:cnfonf=off:e2e=on:i=12374:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_atotf=0.1:au=on:cnfonf=off:inj=on:piset=and:s2a=on:sos=on:i=1557:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_au=on:avsq=on:e2e=on:nm=0:s2a=on:s2at=1.5:i=15824:si=on:rtra=on_0"); + quick.push("dis+1004_1:4_av=off:e2e=on:hud=3:prag=on:sos=on:ss=axioms:i=953:si=on:rtra=on_0"); + quick.push("lrs+1002_4:1_au=on:cnfonf=off:ins=1:nm=2:ntd=on:slsq=on:slsqc=4:sos=on:i=5996:si=on:rtra=on_0"); + quick.push("lrs+1002_2:3_avsq=on:fde=none:nwc=3.0:prag=on:sac=on:sd=2:sgt=32:sos=on:sp=unary_frequency:ss=axioms:i=14840:si=on:rtra=on_0"); + quick.push("ott+1010_1:64_au=on:cbe=off:cnfonf=off:nwc=10.0:s2a=on:ss=axioms:i=5101:si=on:rtra=on_0"); + quick.push("lrs+2_1:6_apa=on:cnfonf=off:e2e=on:fe=off:fsr=off:hud=1:prag=on:sos=on:sp=unary_frequency:i=9099:si=on:rtra=on_0"); + quick.push("dis+2_1:1_hflw=5:hfsq=on:hfsqc=8:hfsql=off:hfsqr=1,2:piset=pi_sigma:spb=goal:i=1042:si=on:rtra=on_0"); + quick.push("dis+1010_13:15_au=on:bd=off:bet=on:cnfonf=off:fe=axiom:hud=10:nm=0:ntd=on:nwc=5.0:sp=const_max:updr=off:i=1615:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:bd=off:e2e=on:fde=none:ins=1:prag=on:sos=on:i=6247:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_alpa=true:anc=none:atotf=0.1:au=on:cnfonf=off:ins=3:nm=64:sd=1:sp=occurrence:ss=axioms:st=5.0:i=6117:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:ntd=on:nwc=5.0:sac=on:sd=1:sgt=16:spb=units:ss=axioms:i=7827:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:hud=10:sd=4:sos=on:ss=axioms:st=2.0:i=3081:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_au=on:av=off:bs=unit_only:bsr=unit_only:e2e=on:er=filter:fde=unused:lecc=1.3:nm=4:sp=frequency:i=11051:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:e2e=on:ins=3:sos=on:ss=axioms:i=1761:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_au=on:av=off:cnfonf=off:cond=fast:nm=6:sos=all:i=4759:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:kws=inv_precedence:nwc=5.0:sd=1:sgt=32:ss=axioms:i=1340:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_apa=on:au=on:bsr=on:cnfonf=off:fe=off:nm=32:prag=on:sac=on:sos=on:sp=unary_first:ss=axioms:i=1895:si=on:rtra=on_0"); + quick.push("lrs+21_16:1_au=on:bd=preordered:fde=none:ins=2:nwc=10.0:ss=axioms:st=2.0:i=12174:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_acc=on:au=on:bd=off:bsr=unit_only:cnfonf=off:fsr=off:nm=2:sos=all:i=4581:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_atotf=0.2:au=on:bd=off:cnfonf=off:plsq=on:plsqc=1:plsqr=1,2:prag=on:sd=1:ss=axioms:st=3.0:tgt=full:i=4854:si=on:rtra=on_0"); + quick.push("lrs+10_3:1_au=on:fsr=off:sd=1:sgt=100:ss=axioms:i=11200:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_e2e=on:nwc=5.0:sd=1:sgt=30:ss=axioms:i=870:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=off:sd=2:sos=on:ss=axioms:i=1561:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_avsq=on:bd=off:cnfonf=off:ins=2:kws=precedence:ntd=on:sp=const_frequency:spb=units:tgt=full:i=4317:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_au=on:e2e=on:fd=off:sos=on:sp=unary_frequency:ss=axioms:i=4597:si=on:rtra=on_0"); + quick.push("dis+10_16:1_au=on:avsq=on:c=on:chr=on:nm=2:sac=on:sp=unary_first:ss=axioms:i=1781:si=on:rtra=on_0"); + quick.push("ott+1002_2:1_au=on:cnfonf=lazy_gen:fde=none:nm=32:s2a=on:sp=const_min:i=6520:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=1303:si=on:rtra=on_0"); + quick.push("dis+3_7:4_bsr=on:c=on:erd=off:fde=none:hud=10:lma=on:nwc=5.0:sac=on:sos=on:sp=frequency:i=8152:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_av=off:prag=on:sos=all:sp=frequency:i=7003:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:avsq=on:fsr=off:ins=3:kws=frequency:sos=all:i=1479:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_avsq=on:bsd=on:cnfonf=off:nm=10:piset=all_but_not_eq:s2a=on:s2at=6.0:sp=const_min:i=1368:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=off:fd=off:rp=on:sac=on:sos=on:i=1264:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:avsqr=1,16:kws=arity_squared:nm=20:sd=1:sp=const_frequency:ss=axioms:i=964:si=on:rtra=on_0"); + quick.push("dis+21_1:4_avsq=on:avsqr=924271,1048576:c=on:e2e=on:fs=off:fsr=off:piset=and:plsq=on:plsqr=32,1:sd=10:sos=on:sp=unary_first:ss=axioms:st=1.5:tnu=2:i=791:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_au=on:bs=on:bsr=unit_only:c=on:fsr=off:hud=10:kws=inv_precedence:nm=6:ntd=on:nwc=10.0:sac=on:sos=on:i=1617:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bs=on:cnfonf=lazy_not_be_gen:kws=inv_frequency:nwc=10.0:rawr=on:slsq=on:sp=weighted_frequency:uhcvi=on:i=2146:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:ntd=on:sos=on:sp=frequency:uhcvi=on:i=8947:si=on:rtra=on_0"); + quick.push("lrs+21_7:1_bd=preordered:c=on:cnfonf=lazy_gen:fde=unused:fe=axiom:hud=10:piset=not:s2at=3.0:slsq=on:slsqr=9,7:ss=axioms:i=2167:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_bd=off:bet=on:bsd=on:bsr=unit_only:fde=none:nwc=10.0:sp=occurrence:i=2482:si=on:rtra=on_0"); + quick.push("lrs+1002_1:3_au=on:bs=unit_only:c=on:cnfonf=off:fde=none:kws=inv_arity_squared:nm=32:nwc=5.0:sos=on:i=12312:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:e2e=on:ixr=off:s2a=on:sd=2:sp=occurrence:ss=axioms:i=724:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:piset=pi_sigma:plsq=on:plsqr=9,2:prag=on:sd=1:sgt=32:sp=occurrence:ss=axioms:uhcvi=on:i=3366:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=1384:si=on:rtra=on_0"); + quick.push("ott+2_1:1_amm=off:atotf=0.4:cnfonf=off:fde=none:lma=on:nm=2:prag=on:sos=all:sp=const_max:tgt=ground:tnu=9:i=1540:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_acc=on:anc=all_dependent:avsq=on:fde=unused:hud=1:ins=2:piset=all_but_not_eq:prag=on:sac=on:i=61085:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_cnfonf=lazy_not_gen_be_off:hud=5:sd=1:ss=axioms:i=1486:si=on:rtra=on_0"); + quick.push("dis+1004_1:5_avsq=on:cs=on:e2e=on:ins=2:sos=all:i=1188:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:kws=precedence:sos=on:sp=frequency:ss=axioms:st=3.0:i=728:si=on:rtra=on_0"); + quick.push("dis+10_1:1_hud=5:nm=16:prag=on:sac=on:sos=on:ss=axioms:tnu=2:i=1141:si=on:rtra=on_0"); + quick.push("lrs+1002_4:1_au=on:cnfonf=off:er=filter:fde=none:ntd=on:nwc=10.0:i=20139:si=on:rtra=on_0"); + quick.push("dis+1010_73:128_bd=preordered:fsr=off:nwc=3.0:s2a=on:s2at=2.0:i=909:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=unused:nwc=5.0:sac=on:sos=all:sp=const_frequency:i=30846:si=on:rtra=on_0"); + quick.push("lrs+1010_4:1_amm=off:awrs=decay:bsr=on:cbe=off:e2e=on:fde=none:fe=axiom:nwc=5.0:prag=on:sac=on:sd=1:spb=goal_then_units:ss=axioms:i=9747:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_sd=2:slsq=on:slsqc=1:ss=axioms:i=751:si=on:rtra=on_0"); + quick.push("lrs+10_97:429_c=on:cnfonf=lazy_gen:fe=axiom:ntd=on:s2a=on:sp=const_frequency:tgt=ground:i=1342:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_cbe=off:cnfonf=lazy_not_gen:nwc=13.0:prag=on:s2a=on:sp=weighted_frequency:i=1957:si=on:rtra=on_0"); + quick.push("lrs+21_1:128_acc=model:au=on:cbe=off:e2e=on:pe=on:piset=small_set:sos=on:sp=occurrence:ss=axioms:i=1179:si=on:rtra=on_0"); + quick.push("lrs+1002_1:16_abs=on:acc=model:au=on:bsr=unit_only:e2e=on:fde=none:sos=on:sp=const_frequency:i=5109:si=on:rtra=on_0"); + quick.push("ott+10_4:1_au=on:cnfonf=lazy_gen:fde=unused:kws=precedence:s2a=on:s2at=2.0:sd=1:ss=axioms:st=5.0:i=1125:si=on:rtra=on_0"); + quick.push("dis+10_1:128_atotf=0.1:fd=off:fsr=off:hflw=5:hfsq=on:hfsqc=5:hfsql=off:hfsqr=1,16:plsq=on:plsqr=9,8:tnu=1:i=1197:si=on:rtra=on_0"); + quick.push("ott+1666_4:1_au=on:bd=off:erd=off:ntd=on:sos=all:i=1038:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:e2e=on:hfsq=on:hfsql=off:lcm=reverse:nm=32:nwc=10.0:s2a=on:s2at=3.0:sd=1:ss=axioms:st=6.0:i=3014:si=on:rtra=on_0"); + quick.push("dis+1004_1:1_cnfonf=lazy_gen:fe=off:sd=1:sgt=30:slsq=on:ss=axioms:i=9638:si=on:rtra=on_0"); + quick.push("lrs+1010_3:1_bet=on:cnfonf=lazy_not_gen:fde=unused:nwc=10.0:sd=1:sp=unary_first:ss=axioms:i=6897:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:sos=all:ss=axioms:i=7846:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=12360:si=on:rtra=on_0"); + // Improves by expected 68.48008648144638 probs costing 479536 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("lrs+21_1:1_au=on:bsd=on:ins=3:plsq=on:plsqc=1:plsqr=1,1:s2a=on:s2at=3.0:sd=10:sp=weighted_frequency:ss=axioms:i=1655:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:av=off:fd=off:fde=unused:ntd=on:sos=on:sp=frequency:ss=axioms:i=1997:si=on:rtra=on_0"); + quick.push("ott+1010_3:1_bd=preordered:cbe=off:e2e=on:fe=axiom:hud=5:s2a=on:s2agt=60:slsq=on:ss=axioms:tnu=1:i=4783:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_cnfonf=off:e2e=on:fde=unused:hud=10:nm=16:pe=on:s2a=on:s2at=2.0:tgt=ground:i=2601:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_fe=off:hud=10:sos=on:ss=axioms:i=1016:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:av=off:cnfonf=lazy_not_gen_be_off:fe=axiom:kws=arity:nwc=5.0:ss=axioms:i=5570:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:av=off:bsd=on:cnfonf=off:kws=arity_squared:sp=const_min:ss=axioms:i=925:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_c=on:cnfonf=lazy_gen:fe=off:ins=2:nwc=5.0:s2a=on:sp=occurrence:i=3973:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqr=16,1:fd=off:nm=2:sos=all:i=5800:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:fde=unused:nm=2:sac=on:sos=all:i=68605:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_atotf=0.1:au=on:cnfonf=off:inj=on:piset=and:s2a=on:sos=on:i=1526:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_fsd=on:hud=10:ntd=on:sp=reverse_arity:ss=axioms:i=13001:si=on:rtra=on_0"); + quick.push("lrs+1002_4:1_au=on:cnfonf=off:ins=1:nm=2:ntd=on:slsq=on:slsqc=4:sos=on:i=13141:si=on:rtra=on_0"); + quick.push("lrs+1010_1:64_acc=model:anc=all:bd=off:bsd=on:bsr=on:ins=3:ntd=on:prag=on:sos=all:i=40579:si=on:rtra=on_0"); + quick.push("lrs+1002_2:3_avsq=on:fde=none:nwc=3.0:prag=on:sac=on:sd=2:sgt=32:sos=on:sp=unary_frequency:ss=axioms:i=37097:si=on:rtra=on_0"); + quick.push("ott+1010_1:64_au=on:cbe=off:cnfonf=off:nwc=10.0:s2a=on:ss=axioms:i=5101:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_apa=on:au=on:cnfonf=off:e2e=on:hud=15:sos=on:i=1967:si=on:rtra=on_0"); + quick.push("ott+10_1:1_cbe=off:cnfonf=lazy_gen:ins=3:nwc=10.0:s2a=on:i=10040:si=on:rtra=on_0"); + quick.push("dis+2_1:1_hflw=5:hfsq=on:hfsqc=8:hfsql=off:hfsqr=1,2:piset=pi_sigma:spb=goal:i=1042:si=on:rtra=on_0"); + quick.push("dis+1002_2:3_aac=none:au=on:avsq=on:cbe=off:fde=none:lcm=predicate:nm=32:prag=on:sos=on:sp=unary_first:ss=axioms:st=2.0:i=22803:si=on:rtra=on_0"); + quick.push("dis+1010_13:15_au=on:bd=off:bet=on:cnfonf=off:fe=axiom:hud=10:nm=0:ntd=on:nwc=5.0:sp=const_max:updr=off:i=1615:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:bd=off:e2e=on:fde=none:ins=1:prag=on:sos=on:i=4783:si=on:rtra=on_0"); + quick.push("ott+10_1:1_bd=preordered:bsr=on:cnfonf=lazy_gen:ntd=on:nwc=10.0:sims=off:sp=const_frequency:i=3527:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_au=on:avsq=on:hud=22:ins=3:ntd=on:nwc=3.0:s2a=on:sp=weighted_frequency:i=2579:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_e2e=on:ntd=on:nwc=5.0:sac=on:sd=1:sgt=16:spb=units:ss=axioms:i=65701:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_av=off:awrs=converge:cnfonf=off:nwc=4.0:plsq=on:plsqc=1:plsql=on:plsqr=3090729,1048576:ss=axioms:tgt=ground:i=69646:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:bd=off:cnfonf=off:fd=off:sos=all:i=9162:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_acc=on:au=on:bd=off:bsr=unit_only:cnfonf=off:fsr=off:nm=2:sos=all:i=40221:si=on:rtra=on_0"); + quick.push("lrs+1002_1:128_atotf=0.2:au=on:bd=off:cnfonf=off:plsq=on:plsqc=1:plsqr=1,2:prag=on:sd=1:ss=axioms:st=3.0:tgt=full:i=4186:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_e2e=on:fd=off:fe=off:prag=on:sos=on:i=3319:si=on:rtra=on_0"); + quick.push("dis+10_16:1_au=on:avsq=on:cnfonf=conj_eager:piset=equals:s2a=on:sp=occurrence:ss=axioms:i=3218:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_avsq=on:bd=off:cnfonf=off:ins=2:kws=precedence:ntd=on:sp=const_frequency:spb=units:tgt=full:i=4317:si=on:rtra=on_0"); + quick.push("ott+2_1:1_au=on:cnfonf=off:sos=all:ss=axioms:st=3.0:i=18139:si=on:rtra=on_0"); + quick.push("dis+10_3:2_cnfonf=lazy_pi_sigma_gen:fe=off:nwc=5.0:prag=on:s2a=on:s2at=3.0:sp=frequency:i=9898:si=on:rtra=on_0"); + quick.push("dis+21_8:1_au=on:cbe=off:cnfonf=off:hud=15:nwc=5.0:piset=not:sos=all:sp=unary_frequency:ss=axioms:i=6753:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_abs=on:au=on:cnfonf=off:fde=unused:inj=on:sos=on:i=3344:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_au=on:bd=preordered:e2e=on:ins=3:kws=inv_frequency:nwc=10.0:sp=const_min:i=7911:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=4081:si=on:rtra=on_0"); + quick.push("dis+3_7:4_bsr=on:c=on:erd=off:fde=none:hud=10:lma=on:nwc=5.0:sac=on:sos=on:sp=frequency:i=1325:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_avsq=on:avsqr=16,1:cnfonf=conj_eager:nwc=10.0:plsq=on:plsqc=1:plsqr=32,1:sd=2:spb=intro:ss=axioms:i=10373:si=on:rtra=on_0"); + quick.push("dis+10_4:1_atotf=0.3:bs=on:cnfonf=lazy_simp:fe=axiom:gs=on:nm=0:nwc=10.0:sp=const_frequency:i=23452:si=on:rtra=on_0"); + quick.push("lrs+32_1:2_au=on:cbe=off:lecc=0.75:s2a=on:s2at=6.0:tgt=ground:i=14769:si=on:rtra=on_0"); + quick.push("lrs+1010_1:128_au=on:avsq=on:fsr=off:ins=3:kws=frequency:sos=all:i=1479:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=lazy_not_gen:fe=off:hud=15:ins=2:nm=16:prag=on:uhcvi=on:i=17013:si=on:rtra=on_0"); + quick.push("lrs+21_8:1_cnfonf=lazy_not_gen:nm=2:nwc=10.0:plsq=on:plsqc=2:plsqr=6,1:prag=on:sgt=8:sp=unary_frequency:ss=axioms:i=9328:si=on:rtra=on_0"); + quick.push("ott+1002_14:1_c=on:cnfonf=lazy_gen:er=tagged:fe=axiom:s2a=on:ss=included:i=18879:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_cnfonf=off:fd=off:rp=on:sac=on:sos=on:i=1264:si=on:rtra=on_0"); + quick.push("lrs+10_2:3_amm=off:au=on:bd=off:fde=unused:fe=off:fsr=off:nm=16:ntd=on:s2a=on:s2at=2.0:ss=axioms:st=3.0:i=9251:si=on:rtra=on_0"); + quick.push("ott+1002_2:1_au=on:ins=1:nm=2:sac=on:sos=all:i=2811:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bs=on:cnfonf=lazy_not_be_gen:kws=inv_frequency:nwc=10.0:rawr=on:slsq=on:sp=weighted_frequency:uhcvi=on:i=2146:si=on:rtra=on_0"); + quick.push("ott+1002_23:4_fsd=on:ins=3:nwc=10.0:prag=on:i=1671:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:ntd=on:sos=on:sp=frequency:uhcvi=on:i=2778:si=on:rtra=on_0"); + quick.push("lrs+21_7:1_bd=preordered:c=on:cnfonf=lazy_gen:fde=unused:fe=axiom:hud=10:piset=not:s2at=3.0:slsq=on:slsqr=9,7:ss=axioms:i=33343:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_bd=off:bet=on:bsd=on:bsr=unit_only:fde=none:nwc=10.0:sp=occurrence:i=2695:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:avsq=on:e2e=on:ixr=off:s2a=on:sd=2:sp=occurrence:ss=axioms:i=13229:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:piset=pi_sigma:plsq=on:plsqr=9,2:prag=on:sd=1:sgt=32:sp=occurrence:ss=axioms:uhcvi=on:i=3366:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=20702:si=on:rtra=on_0"); + quick.push("ott+2_1:1_amm=off:atotf=0.4:cnfonf=off:fde=none:lma=on:nm=2:prag=on:sos=all:sp=const_max:tgt=ground:tnu=9:i=1540:si=on:rtra=on_0"); + quick.push("dis+1004_1:5_avsq=on:cs=on:e2e=on:ins=2:sos=all:i=1188:si=on:rtra=on_0"); + quick.push("dis+1002_1:4_cnfonf=off:e2e=on:fde=unused:fsr=off:sac=on:sfv=off:tgt=full:i=15049:si=on:rtra=on_0"); + quick.push("ott+1010_44:25_afr=on:avsq=on:c=on:cnfonf=off:e2e=on:fd=preordered:hud=5:rawr=on:sp=frequency:spb=non_intro:tgt=full:tnu=1:i=7623:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=off:fe=off:nwc=10.0:s2a=on:s2agt=8:sd=1:ss=axioms:st=5.0:i=8973:si=on:rtra=on_0"); + quick.push("dis+1010_1:2_avsq=on:cnfonf=lazy_pi_sigma_gen:fe=axiom:hud=10:sd=2:ss=axioms:i=3633:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_au=on:cnfonf=lazy_gen:fsr=off:hfsq=on:hfsqr=1,32:sgt=16:ss=axioms:i=23300:si=on:rtra=on_0"); + quick.push("dis+1010_1:16_amm=sco:cnfonf=off:sd=1:ss=axioms:st=2.0:tgt=full:tnu=5:i=34824:si=on:rtra=on_0"); + quick.push("dis+2_1:1_bd=off:prag=on:sos=all:sp=frequency:ss=axioms:uhcvi=on:i=8613:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:bet=on:fde=none:nm=20:sos=on:i=14011:si=on:rtra=on_0"); + quick.push("ott+2_4:1_au=on:cnfonf=lazy_pi_sigma_gen:hud=16:ins=3:nm=20:plsq=on:plsqc=1:plsqr=13,2:rawr=on:sp=reverse_arity:ss=axioms:st=3.0:i=24800:si=on:rtra=on_0"); + quick.push("lrs+10_16:1_au=on:bd=off:sac=on:sos=all:i=13248:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:c=on:cnfonf=off:kws=inv_precedence:piset=and:sd=1:ss=axioms:tgt=ground:tnu=2:i=20260:si=on:rtra=on_0"); + quick.push("dis+10_2:3_avsq=on:fd=off:fde=none:lcm=reverse:prag=on:sac=on:sos=on:i=4887:si=on:rtra=on_0"); + quick.push("ott+10_16:1_aac=none:au=on:cnfonf=off:nm=20:s2a=on:ss=axioms:i=24752:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:bs=unit_only:bsd=on:cnfonf=off:fde=unused:fsr=off:hud=5:kws=inv_arity_squared:sp=const_min:i=2235:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_acc=model:au=on:avsq=on:fd=off:hfsq=on:s2a=on:s2agt=16:sgt=10:sp=unary_frequency:ss=axioms:i=2286:si=on:rtra=on_0"); + quick.push("ott+10_4:1_au=on:cnfonf=lazy_gen:fde=unused:kws=precedence:s2a=on:s2at=2.0:sd=1:ss=axioms:st=5.0:i=1125:si=on:rtra=on_0"); + quick.push("lrs+1_1:1_acc=on:au=on:ccuc=first:erd=off:fde=none:fsr=off:nm=10:ntd=on:s2a=on:s2at=5.0:i=17270:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:sd=1:ss=axioms:i=2489:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:fde=none:plsq=on:plsqc=1:plsqr=32,1:sos=on:sp=const_frequency:ss=axioms:st=3.0:i=9026:si=on:rtra=on_0"); + quick.push("ott+1002_17:12_au=on:ins=3:sac=on:sd=3:sos=on:sp=occurrence:ss=axioms:i=2265:si=on:rtra=on_0"); + quick.push("dis+10_1:128_atotf=0.1:fd=off:fsr=off:hflw=5:hfsq=on:hfsqc=5:hfsql=off:hfsqr=1,16:plsq=on:plsqr=9,8:tnu=1:i=1197:si=on:rtra=on_0"); + quick.push("dis+10_1:3_au=on:av=off:cha=on:cnfonf=conj_eager:etr=on:fde=none:nwc=3.0:sp=weighted_frequency:i=12872:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=4954:si=on:rtra=on_0"); + // Improves by expected 49.127566684028515 probs costing 957834 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("dis+10_4:1_avsq=on:e2e=on:fde=none:s2a=on:s2at=3.0:slsq=on:slsqc=1:i=18622:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_fe=off:hud=10:sos=on:ss=axioms:i=4533:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_au=on:av=off:cnfonf=lazy_not_gen_be_off:fe=axiom:kws=arity:nwc=5.0:ss=axioms:i=5570:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_au=on:av=off:bsd=on:cnfonf=off:kws=arity_squared:sp=const_min:ss=axioms:i=44027:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:avsq=on:avsqr=16,1:fd=off:nm=2:sos=all:i=4753:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:fde=unused:nm=2:sac=on:sos=all:i=6251:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_au=on:avsq=on:e2e=on:nm=0:s2a=on:s2at=1.5:i=11778:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_fsd=on:hud=10:ntd=on:sp=reverse_arity:ss=axioms:i=13001:si=on:rtra=on_0"); + quick.push("ott+10_15:2_au=on:avsq=on:cnfonf=lazy_pi_sigma_gen:cs=on:fde=none:ins=2:sp=unary_first:i=22053:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:cnfonf=off:e2e=on:piset=small_set:sac=on:sd=1:sos=all:ss=axioms:st=5.0:i=46089:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_bd=off:e2e=on:hud=15:s2a=on:sos=on:ss=axioms:tnu=1:i=5292:si=on:rtra=on_0"); + quick.push("dis+2_1:1_hflw=5:hfsq=on:hfsqc=8:hfsql=off:hfsqr=1,2:piset=pi_sigma:spb=goal:i=1805:si=on:rtra=on_0"); + quick.push("lrs+21_16:1_au=on:bd=preordered:fde=none:ins=2:nwc=10.0:ss=axioms:st=2.0:i=12174:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_acc=model:avsq=on:ccuc=small_ones:cnfonf=lazy_simp:nm=16:nwc=10.0:s2a=on:sac=on:sp=const_frequency:i=22253:si=on:rtra=on_0"); + quick.push("ott+10_1:1_afp=2000:avsq=on:bsr=unit_only:chr=on:ntd=on:piset=and:sos=on:sp=weighted_frequency:i=5377:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_atotf=0.0319537:au=on:sos=on:sp=unary_frequency:i=6236:si=on:rtra=on_0"); + quick.push("dis+10_3:2_cnfonf=lazy_pi_sigma_gen:fe=off:nwc=5.0:prag=on:s2a=on:s2at=3.0:sp=frequency:i=9898:si=on:rtra=on_0"); + quick.push("ott+10_4:1_e2e=on:fde=unused:nm=40:nwc=10.0:s2a=on:s2at=2.0:sp=unary_frequency:ss=axioms:i=28120:si=on:rtra=on_0"); + quick.push("lrs+10_2:1_fde=none:prag=on:sd=2:sgt=8:ss=axioms:tgt=ground:i=14683:si=on:rtra=on_0"); + quick.push("ott+1002_2:1_au=on:cnfonf=lazy_gen:fde=none:nm=32:s2a=on:sp=const_min:i=5696:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=85280:si=on:rtra=on_0"); + quick.push("dis+3_7:4_bsr=on:c=on:erd=off:fde=none:hud=10:lma=on:nwc=5.0:sac=on:sos=on:sp=frequency:i=5088:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_avsq=on:avsqr=16,1:cnfonf=conj_eager:nwc=10.0:plsq=on:plsqc=1:plsqr=32,1:sd=2:spb=intro:ss=axioms:i=10373:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=lazy_not_gen:fe=off:hud=15:ins=2:nm=16:prag=on:uhcvi=on:i=17013:si=on:rtra=on_0"); + quick.push("ott+1002_14:1_c=on:cnfonf=lazy_gen:er=tagged:fe=axiom:s2a=on:ss=included:i=14123:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bs=on:cnfonf=lazy_not_be_gen:kws=inv_frequency:nwc=10.0:rawr=on:slsq=on:sp=weighted_frequency:uhcvi=on:i=2146:si=on:rtra=on_0"); + quick.push("dis+1002_16:1_au=on:ntd=on:sos=on:sp=frequency:uhcvi=on:i=2778:si=on:rtra=on_0"); + quick.push("lrs+0_1:1_hfsq=on:hud=10:ins=2:prag=on:sac=on:sp=const_frequency:i=48810:si=on:rtra=on_0"); + quick.push("lrs+1666_1:1_bd=off:bet=on:bsd=on:bsr=unit_only:fde=none:nwc=10.0:sp=occurrence:i=2482:si=on:rtra=on_0"); + quick.push("lrs+1002_1:3_au=on:bs=unit_only:c=on:cnfonf=off:fde=none:kws=inv_arity_squared:nm=32:nwc=5.0:sos=on:i=12312:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cnfonf=lazy_pi_sigma_gen:fe=off:piset=pi_sigma:plsq=on:plsqr=9,2:prag=on:sd=1:sgt=32:sp=occurrence:ss=axioms:uhcvi=on:i=3366:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=2946:si=on:rtra=on_0"); + quick.push("lrs+1010_16:1_acc=on:anc=all_dependent:avsq=on:fde=unused:hud=1:ins=2:piset=all_but_not_eq:prag=on:sac=on:i=90050:si=on:rtra=on_0"); + quick.push("ott+1010_44:25_afr=on:avsq=on:c=on:cnfonf=off:e2e=on:fd=preordered:hud=5:rawr=on:sp=frequency:spb=non_intro:tgt=full:tnu=1:i=7601:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=off:fe=off:nwc=10.0:s2a=on:s2agt=8:sd=1:ss=axioms:st=5.0:i=8973:si=on:rtra=on_0"); + quick.push("dis+1010_1:2_avsq=on:cnfonf=lazy_pi_sigma_gen:fe=axiom:hud=10:sd=2:ss=axioms:i=3633:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:c=on:cnfonf=off:e2e=on:ins=1:kws=precedence:ntd=on:sd=2:sos=on:ss=axioms:st=2.0:i=25272:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:bd=off:bet=on:fde=none:nm=20:sos=on:i=95997:si=on:rtra=on_0"); + quick.push("ott+2_1:1_abs=on:e2e=on:fsd=on:fsr=off:kws=inv_precedence:piset=not:prag=on:s2a=on:s2pl=no:sos=on:i=4759:si=on:rtra=on_0"); + quick.push("dis+10_1:1_au=on:e2e=on:fde=unused:nwc=5.0:sac=on:sos=all:sp=const_frequency:i=80153:si=on:rtra=on_0"); + quick.push("dis+10_2:3_avsq=on:fd=off:fde=none:lcm=reverse:prag=on:sac=on:sos=on:i=4887:si=on:rtra=on_0"); + quick.push("ott+10_16:1_aac=none:au=on:cnfonf=off:nm=20:s2a=on:ss=axioms:i=85427:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_e2e=on:prag=on:rawr=on:sos=on:sp=weighted_frequency:i=15115:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:fde=none:sos=all:i=11130:si=on:rtra=on_0"); + quick.push("ott+1002_17:12_au=on:ins=3:sac=on:sd=3:sos=on:sp=occurrence:ss=axioms:i=2265:si=on:rtra=on_0"); + quick.push("lrs+1010_3:1_bet=on:cnfonf=lazy_not_gen:fde=unused:nwc=10.0:sd=1:sp=unary_first:ss=axioms:i=6897:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_au=on:e2e=on:sos=all:ss=axioms:i=4492:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=11980:si=on:rtra=on_0"); + // Improves by expected 20.832310444427776 probs costing 953511 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("dis+1002_1:1_fe=off:hud=10:sos=on:ss=axioms:i=6230:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_au=on:bsd=on:c=on:fde=none:piset=equals:sac=on:sp=const_min:i=71177:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_c=on:cnfonf=lazy_gen:fe=off:ins=2:nwc=5.0:s2a=on:sp=occurrence:i=15983:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:au=on:fde=unused:nm=2:sac=on:sos=all:i=26900:si=on:rtra=on_0"); + quick.push("lrs+1010_1:64_acc=model:anc=all:bd=off:bsd=on:bsr=on:ins=3:ntd=on:prag=on:sos=all:i=40579:si=on:rtra=on_0"); + quick.push("ott+10_15:2_au=on:avsq=on:cnfonf=lazy_pi_sigma_gen:cs=on:fde=none:ins=2:sp=unary_first:i=18776:si=on:rtra=on_0"); + quick.push("lrs+2_1:6_apa=on:cnfonf=off:e2e=on:fe=off:fsr=off:hud=1:prag=on:sos=on:sp=unary_frequency:i=9099:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_bd=off:e2e=on:hud=15:s2a=on:sos=on:ss=axioms:tnu=1:i=5292:si=on:rtra=on_0"); + quick.push("dis+1002_2:3_aac=none:au=on:avsq=on:cbe=off:fde=none:lcm=predicate:nm=32:prag=on:sos=on:sp=unary_first:ss=axioms:st=2.0:i=22803:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_c=on:cnfonf=off:hud=15:rawr=on:sd=1:sos=all:ss=axioms:i=73159:si=on:rtra=on_0"); + quick.push("dis+1010_1:5_au=on:avsq=on:ins=3:nm=0:nwc=10.0:prag=on:sos=all:sp=const_frequency:i=11506:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_au=on:av=off:bs=unit_only:bsr=unit_only:e2e=on:er=filter:fde=unused:lecc=1.3:nm=4:sp=frequency:i=18598:si=on:rtra=on_0"); + quick.push("lrs+21_16:1_au=on:bd=preordered:fde=none:ins=2:nwc=10.0:ss=axioms:st=2.0:i=12174:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_atotf=0.0319537:au=on:sos=on:sp=unary_frequency:i=6236:si=on:rtra=on_0"); + quick.push("ott+10_4:1_e2e=on:fde=unused:nm=40:nwc=10.0:s2a=on:s2at=2.0:sp=unary_frequency:ss=axioms:i=15576:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_c=on:cnfonf=off:hud=10:nm=10:ntd=on:s2a=on:sac=on:sgt=30:ss=included:i=41932:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:cnfonf=lazy_simp:fde=none:sp=occurrence:i=11232:si=on:rtra=on_0"); + quick.push("lrs+1010_8:1_au=on:cnfonf=lazy_pi_sigma_gen:fde=none:nwc=10.0:s2a=on:sac=on:i=188785:si=on:rtra=on_0"); + quick.push("dis+3_7:4_bsr=on:c=on:erd=off:fde=none:hud=10:lma=on:nwc=5.0:sac=on:sos=on:sp=frequency:i=9862:si=on:rtra=on_0"); + quick.push("lrs+21_8:1_cnfonf=lazy_not_gen:nm=2:nwc=10.0:plsq=on:plsqc=2:plsqr=6,1:prag=on:sgt=8:sp=unary_frequency:ss=axioms:i=9102:si=on:rtra=on_0"); + quick.push("ott+1002_14:1_c=on:cnfonf=lazy_gen:er=tagged:fe=axiom:s2a=on:ss=included:i=13047:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_aac=none:au=on:bd=off:cnfonf=off:nm=0:s2at=3.0:s2pl=on:sac=on:sos=on:i=74823:si=on:rtra=on_0"); + quick.push("dis+10_3:1_acc=on:avsq=on:bs=unit_only:cnfonf=off:fe=axiom:ins=3:plsq=on:plsqc=1:plsqr=32,1:prag=on:i=20702:si=on:rtra=on_0"); + quick.push("lrs+20_1:1_au=on:bd=off:erd=off:fde=none:sos=on:i=111726:si=on:rtra=on_0"); + quick.push("dis+2_5:1_au=on:e2e=on:fsr=off:sos=on:sp=unary_first:ss=axioms:i=9441:si=on:rtra=on_0"); + quick.push("dis+10_1:1_cnfonf=off:fe=off:nwc=10.0:s2a=on:s2agt=8:sd=1:ss=axioms:st=5.0:i=8973:si=on:rtra=on_0"); + quick.push("dis+1010_1:2_avsq=on:cnfonf=lazy_pi_sigma_gen:fe=axiom:hud=10:sd=2:ss=axioms:i=3633:si=on:rtra=on_0"); + quick.push("dis+21_1:1_au=on:c=on:cnfonf=off:e2e=on:ins=1:kws=precedence:ntd=on:sd=2:sos=on:ss=axioms:st=2.0:i=25272:si=on:rtra=on_0"); + quick.push("dis+2_1:1_bd=off:prag=on:sos=all:sp=frequency:ss=axioms:uhcvi=on:i=8613:si=on:rtra=on_0"); + quick.push("lrs+10_16:1_au=on:bd=off:sac=on:sos=all:i=44526:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_e2e=on:prag=on:rawr=on:sos=on:sp=weighted_frequency:i=15115:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_au=on:fde=none:kws=inv_frequency:ntd=on:sos=on:i=4811:si=on:rtra=on_0"); + // Improves by expected 11.519827354524478 probs costing 955651 Mi + + // Fri14 Overall score 3061.786675181413 probs on average / budget 3825887 Mi + // Wed12 Overall score 3048.3069003468577 probs on average / budget 3833691 Mi + // Tue11 Overall score 3039.0840598543527 probs on average / budget 3828761 Mi + // Mon10b Overall score 3037.186917544398 probs on average / budget 3813568 Mi + // Mon10a Overall score 3000.409829293265 probs on average / budget 3825232 Mi + // Sun09 Overall score 2938.863699793977 probs on average / budget 1918256 Mi + } + } else { // if (property.higherOrder()) + // Sub-schedule for 10000Mi strat cap / 10000Mi overall limit + quick.push("dis+1002_1:1_bd=off:fd=off:sos=on:i=601:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=894:si=on:rtra=on_0"); + quick.push("dis+1011_4:1_av=off:nwc=10.0:sd=1:sgt=16:ss=axioms:i=563:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_br=off:s2a=on:s2at=5.0:sd=2:ss=axioms:st=2.0:urr=on:i=596:si=on:rtra=on_0"); + quick.push("dis+21_2:3_drc=off:kws=precedence:s2a=on:s2agt=100:sgt=10:sp=unary_first:ss=axioms:i=628:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_fd=preordered:lecc=0.5:sos=on:sp=unary_frequency:to=lpo:urr=on:i=834:si=on:rtra=on_0"); + quick.push("dis-10_1:1_atotf=0.2:bd=off:drc=off:fd=preordered:fsr=off:nwc=3.0:sd=1:sp=const_frequency:spb=goal:ss=axioms:st=1.5:to=lpo:i=236:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_bd=off:drc=off:ins=3:nwc=10.0:s2a=on:ss=axioms:i=497:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=preordered:fd=preordered:fsd=on:newcnf=on:plsq=on:plsql=on:slsq=on:sos=on:sp=weighted_frequency:spb=goal:to=lpo:i=362:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_av=off:sd=2:sos=on:ss=axioms:urr=on:i=511:si=on:rtra=on_0"); + quick.push("dis+10_1:1_br=off:newcnf=on:nwc=10.0:s2a=on:ss=axioms:urr=on:i=246:si=on:rtra=on_0"); + quick.push("ott-2_2:3_av=off:drc=off:lcm=reverse:newcnf=on:nm=2:nwc=10.0:s2a=on:s2agt=10:to=lpo:urr=on:i=787:si=on:rtra=on_0"); + quick.push("lrs+1011_4:1_nwc=5.0:s2a=on:sp=const_min:ss=axioms:urr=on:i=647:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_ep=RS:fde=unused:slsq=on:slsqr=1,2:sp=occurrence:spb=goal:i=555:si=on:rtra=on_0"); + quick.push("dis-1011_1:3_fd=preordered:sd=1:sgt=100:ss=axioms:tgt=full:urr=ec_only:i=534:si=on:rtra=on_0"); + quick.push("ott+1011_8:1_br=off:drc=off:kws=precedence:nm=2:s2a=on:s2agt=16:sp=frequency:urr=on:i=1522:si=on:rtra=on_0"); + quick.push("dis+2_3:1_awrs=converge:awrsf=200:s2a=on:s2at=4.0:uhcvi=on:urr=on:i=2:si=on:rtra=on_0"); + // Improves by expected 5474.0882895272125 probs costing 9998 Mi + // Sub-schedule for 20000Mi strat cap / 20000Mi overall limit + quick.push("dis+2_1:1_nwc=10.0:sd=1:sgt=100:sp=frequency:ss=axioms:to=lpo:urr=on:i=731:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_ep=RS:erd=off:newcnf=on:sos=on:sp=weighted_frequency:i=301:si=on:rtra=on_0"); + quick.push("lrs+1011_8:1_cond=fast:drc=off:nwc=3.0:rawr=on:s2a=on:sac=on:slsq=on:slsqr=40,243:sp=const_frequency:to=lpo:uhcvi=on:i=1612:si=on:rtra=on_0"); + quick.push("dis+1011_1:2_anc=none:fd=preordered:kws=inv_arity_squared:nm=20:s2a=on:s2agt=100:s2pl=on:sd=2:slsq=on:slsqr=7,8:spb=intro:ss=axioms:st=5.0:i=2224:si=on:rtra=on_0"); + quick.push("ott+1010_1:1_amm=sco:ep=RST:sos=on:sp=reverse_arity:ss=axioms:st=1.5:urr=on:i=509:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_av=off:bsd=on:kws=inv_arity_squared:plsq=on:plsqr=1,8:ss=axioms:tgt=full:i=2036:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:bd=off:sd=1:sos=all:ss=axioms:st=2.0:i=164:si=on:rtra=on_0"); + quick.push("lrs-1010_1:1_bd=off:sos=on:sp=weighted_frequency:to=lpo:i=373:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_avsq=on:bce=on:fde=unused:ins=2:kws=inv_frequency:sos=on:sp=reverse_arity:urr=on:i=232:si=on:rtra=on_0"); + quick.push("dis+10_1:2_newcnf=on:nm=2:sd=1:ss=axioms:i=162:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_nm=16:nwc=5.0:s2a=on:s2at=2.0:urr=on:i=780:si=on:rtra=on_0"); + quick.push("ott+10_1:1_av=off:erd=off:sos=on:ss=axioms:st=1.5:urr=on:i=197:si=on:rtra=on_0"); + quick.push("dis+1011_7:3_aac=none:bsr=unit_only:er=filter:kws=precedence:lma=on:nm=0:sd=2:sgt=16:sp=unary_first:ss=axioms:tgt=ground:i=425:si=on:rtra=on_0"); + quick.push("ott+1002_2:1_bd=off:kws=precedence:newcnf=on:rp=on:sos=on:sp=unary_first:ss=axioms:st=1.5:i=709:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=inv_precedence:plsq=on:rawr=on:rp=on:slsq=on:sp=unary_first:i=46:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=2:s2a=on:s2at=1.5:ss=axioms:tgt=ground:i=291:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:kws=precedence:lcm=predicate:sos=on:sp=const_frequency:spb=goal:i=356:si=on:rtra=on_0"); + quick.push("ott+10_1:1_drc=off:s2a=on:sd=1:sp=weighted_frequency:ss=axioms:st=5.0:to=lpo:i=249:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_amm=off:sgt=8:sos=all:sp=unary_first:ss=axioms:to=lpo:i=234:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_nm=2:s2a=on:s2agt=100:sd=4:sgt=8:sos=all:ss=axioms:i=446:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_drc=off:nwc=10.0:s2a=on:s2at=3.0:sp=frequency:spb=non_intro:ss=axioms:to=lpo:i=244:si=on:rtra=on_0"); + quick.push("dis+10_1:1_avsq=on:s2a=on:s2agt=32:sac=on:i=428:si=on:rtra=on_0"); + quick.push("dis+10_3:1_av=off:nwc=5.0:s2a=on:s2agt=16:s2at=1.5:sd=1:sp=reverse_frequency:spb=goal:ss=axioms:st=5.0:i=368:si=on:rtra=on_0"); + quick.push("lrs-1010_1:1_ep=RSTC:sos=on:urr=ec_only:i=305:si=on:rtra=on_0"); + quick.push("lrs-32_1:1_fde=unused:kws=arity_squared:newcnf=on:nicw=on:nwc=5.0:rnwc=on:s2a=on:s2at=-1.0:urr=on:i=79:si=on:rtra=on_0"); + quick.push("lrs-1010_2:1_drc=off:kws=precedence:nwc=10.0:s2a=on:s2at=2.5:ss=axioms:st=3.0:i=452:si=on:rtra=on_0"); + quick.push("dis-1011_1:8_drc=off:fsr=off:lsd=10:nm=0:s2a=on:s2agt=16:sgt=10:spb=goal_then_units:ss=axioms:tgt=full:to=lpo:i=1411:si=on:rtra=on_0"); + quick.push("lrs-1002_1:1_bd=off:erd=off:sos=on:sp=unary_first:to=lpo:i=159:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_bd=off:flr=on:nm=2:s2a=on:sd=2:ss=axioms:i=344:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_avsq=on:drc=off:nwc=10.0:sp=frequency:to=lpo:i=332:si=on:rtra=on_0"); + quick.push("dis+21_1:1_ins=3:newcnf=on:sos=on:sp=weighted_frequency:to=lpo:i=250:si=on:rtra=on_0"); + quick.push("dis+10_1:4_av=off:fde=none:sos=on:sp=frequency:to=lpo:i=418:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:bd=preordered:kws=precedence:nwc=10.0:sgt=16:sp=const_frequency:spb=goal_then_units:ss=axioms:i=728:si=on:rtra=on_0"); + quick.push("lrs-2_2:3_av=off:fsd=on:ins=1:lcm=predicate:nwc=8.0:s2a=on:s2at=5.0:slsq=on:slsqc=2:slsqr=2,1:sp=const_frequency:uhcvi=on:i=88:si=on:rtra=on_0"); + quick.push("ott+10_1:1_s2a=on:s2agt=16:sgt=10:slsq=on:slsqc=1:sp=const_min:spb=goal_then_units:ss=axioms:to=lpo:i=474:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:avsq=on:avsqc=1:fsr=off:tgt=ground:i=204:si=on:rtra=on_0"); + quick.push("lrs-1011_1:20_sd=2:sgt=30:sp=frequency:spb=goal_then_units:ss=axioms:tgt=full:i=259:si=on:rtra=on_0"); + quick.push("ott+1666_5:1_aac=none:bs=unit_only:kws=inv_frequency:nwc=5.0:rawr=on:s2a=on:s2agt=64:sac=on:sp=occurrence:spb=goal:urr=on:i=1418:si=on:rtra=on_0"); + // Improves by expected 283.9457762984722 probs costing 20000 Mi + // Sub-schedule for 30000Mi strat cap / 30000Mi overall limit + quick.push("dis+1010_1:7_bd=off:kws=arity_squared:s2a=on:sp=const_frequency:tgt=ground:i=788:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_plsq=on:plsqr=32,1:rawr=on:sac=on:sos=all:sp=unary_frequency:to=lpo:i=201:si=on:rtra=on_0"); + quick.push("ott+1_8:1_add=large:nm=64:s2a=on:s2agt=5:s2at=3.0:tgt=full:uhcvi=on:urr=on:i=1258:si=on:rtra=on_0"); + quick.push("dis+10_3:1_drc=off:nwc=10.0:s2a=on:s2at=2.0:urr=on:i=2604:si=on:rtra=on_0"); + quick.push("ott+1002_5:1_drc=off:nwc=10.0:sp=const_min:spb=goal_then_units:to=lpo:urr=on:i=253:si=on:rtra=on_0"); + quick.push("dis+1011_4:1_anc=none:bd=off:fsr=off:lsd=10:s2at=4.0:sd=2:slsq=on:slsqc=1:sp=weighted_frequency:ss=axioms:st=5.0:i=302:si=on:rtra=on_0"); + quick.push("dis-1010_8:1_av=off:cond=fast:flr=on:kws=inv_frequency:nm=0:nwc=10.0:i=777:si=on:rtra=on_0"); + quick.push("lrs+10_3:1_bd=off:ins=3:nwc=3.0:sd=2:sgt=30:sp=frequency:ss=axioms:to=lpo:urr=on:i=1497:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_ep=RS:ss=axioms:i=822:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_alpa=false:bd=preordered:fde=none:newcnf=on:nm=64:s2at=5.0:slsq=on:slsqr=4,1:sos=on:sp=frequency:to=lpo:i=203:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:drc=off:sos=on:urr=on:i=532:si=on:rtra=on_0"); + quick.push("lrs+2_3:1_bsr=unit_only:nwc=10.0:sos=all:sp=unary_frequency:ss=axioms:to=lpo:i=275:si=on:rtra=on_0"); + quick.push("dis+2_1:64_bd=off:fd=off:s2a=on:sac=on:sos=on:sp=const_frequency:i=208:si=on:rtra=on_0"); + quick.push("ott+2_4:1_br=off:bsd=on:drc=off:nm=2:sp=unary_first:urr=on:i=3039:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_fd=off:nm=2:sos=on:to=lpo:urr=on:i=416:si=on:rtra=on_0"); + quick.push("ott+10_1:128_s2a=on:sp=reverse_arity:spb=goal_then_units:to=lpo:i=65:si=on:rtra=on_0"); + quick.push("dis+1010_1:1024_bd=off:drc=off:newcnf=on:rawr=on:s2pl=on:sd=2:sgt=20:sp=const_frequency:spb=goal_then_units:ss=axioms:tgt=full:i=278:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_add=large:amm=sco:gs=on:newcnf=on:s2a=on:s2agt=30:s2at=1.2:s2pl=no:slsq=on:slsqr=1,8:sp=reverse_arity:spb=intro:i=447:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=inv_precedence:plsq=on:rawr=on:rp=on:slsq=on:sp=unary_first:i=59:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_ep=R:newcnf=on:sd=1:sos=on:ss=axioms:st=4.0:i=168:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:fd=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2at=5.0:s2pl=no:sd=1:sos=on:ss=axioms:i=222:si=on:rtra=on_0"); + quick.push("ott+10_1:1_drc=off:fd=preordered:s2a=on:s2at=2.0:sp=weighted_frequency:spb=goal:tgt=full:to=lpo:urr=on:i=471:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=off:fsr=off:plsq=on:plsqr=32,1:sd=1:sos=on:ss=axioms:i=316:si=on:rtra=on_0"); + quick.push("dis+10_1:1_erd=off:sos=all:ss=axioms:i=247:si=on:rtra=on_0"); + quick.push("dis+1010_7:15_abs=on:anc=all:nm=0:sos=on:sp=weighted_frequency:ss=axioms:i=190:si=on:rtra=on_0"); + quick.push("lrs+2_1:3_atotf=0.1:bd=off:fd=off:sos=on:i=228:si=on:rtra=on_0"); + quick.push("lrs+1011_29:64_av=off:bs=unit_only:drc=off:kws=inv_frequency:lcm=reverse:sp=reverse_arity:tgt=full:i=780:si=on:rtra=on_0"); + quick.push("dis+2_1:7_av=off:fd=preordered:newcnf=on:nm=10:rp=on:sgt=16:sos=all:ss=axioms:i=612:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_av=off:bd=off:fsr=off:sos=on:ss=axioms:urr=on:i=1000:si=on:rtra=on_0"); + quick.push("dis-1011_1:1_av=off:fd=preordered:fsr=off:lcm=reverse:nm=2:nwc=10.0:s2a=on:s2agt=16:spb=goal:to=lpo:i=1217:si=on:rtra=on_0"); + quick.push("dis+11_1:1_atotf=0.1:nm=32:plsq=on:plsqc=1:plsql=on:plsqr=1,1:s2agt=64:slsq=on:slsqc=1:slsqr=2,1:sp=reverse_arity:spb=non_intro:ss=axioms:i=547:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_add=large:avsq=on:avsqr=21,4:bsr=unit_only:nm=16:nwc=6.0:plsq=on:plsqr=7452629,65536:rawr=on:s2a=on:slsq=on:slsqc=1:slsqr=1,4:sp=const_frequency:uhcvi=on:i=211:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:drc=off:fd=preordered:s2a=on:sp=unary_first:to=lpo:i=333:si=on:rtra=on_0"); + quick.push("dis+1011_8:1_avsq=on:ep=RS:fsr=off:plsq=on:plsqr=32,1:ss=axioms:st=1.5:i=549:si=on:rtra=on_0"); + quick.push("dis+10_1:1_sd=1:sos=on:ss=axioms:st=2.0:i=218:si=on:rtra=on_0"); + quick.push("dis-1011_1:128_atotf=0.1:bd=off:fsr=off:s2a=on:slsq=on:slsqc=1:slsqr=1,2:sp=const_min:ss=axioms:st=5.0:tgt=full:to=lpo:i=314:si=on:rtra=on_0"); + quick.push("ott+1011_1:1_bd=off:flr=on:sos=on:i=317:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_ep=RS:fde=unused:slsq=on:slsqr=1,2:sp=occurrence:spb=goal:i=930:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_av=off:nwc=5.0:sd=1:sgt=8:ss=axioms:i=251:si=on:rtra=on_0"); + quick.push("dis+10_1:1_av=off:kws=precedence:lcm=reverse:sd=2:sgt=10:sp=const_max:ss=axioms:st=2.0:i=378:si=on:rtra=on_0"); + quick.push("dis+10_8:1_kws=precedence:newcnf=on:s2a=on:s2at=5.0:sd=2:slsq=on:slsqc=1:sp=unary_frequency:ss=axioms:st=3.0:urr=on:i=343:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_cond=fast:drc=off:erd=off:s2a=on:sac=on:slsq=on:slsql=off:ss=axioms:i=668:si=on:rtra=on_0"); + quick.push("dis-1011_1:3_fd=preordered:sd=1:sgt=100:ss=axioms:tgt=full:urr=ec_only:i=3535:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:avsq=on:avsqc=5:avsqr=3,1:sd=1:sgt=10:spb=goal_then_units:ss=axioms:st=3.0:tgt=full:i=547:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:bd=off:lwlo=on:plsq=on:sos=all:sp=const_min:ss=axioms:st=5.0:to=lpo:i=179:si=on:rtra=on_0"); + quick.push("ott+2_1:64_aac=none:acc=model:awrs=decay:awrsf=5:br=off:rawr=on:sos=all:sp=weighted_frequency:tgt=ground:to=lpo:urr=ec_only:i=563:si=on:rtra=on_0"); + quick.push("dis+10_16:1_avsq=on:avsqr=1,16:fd=preordered:sgt=8:sos=all:ss=axioms:to=lpo:i=425:si=on:rtra=on_0"); + quick.push("lrs-10_1:1_av=off:bd=off:kws=precedence:sos=on:sp=unary_first:spb=goal:i=243:si=on:rtra=on_0"); + // Improves by expected 151.7500472259248 probs costing 29978 Mi + // Sub-schedule for 60000Mi strat cap / 60000Mi overall limit + quick.push("ott+1002_1:1_ep=RS:erd=off:newcnf=on:sos=on:sp=weighted_frequency:i=247:si=on:rtra=on_0"); + quick.push("dis+21_16:1_ep=RST:nm=3:slsq=on:ss=axioms:st=2.0:urr=on:i=704:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=1694:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_av=off:rawr=on:s2a=on:slsq=on:slsqr=1,4:sp=unary_first:tgt=ground:i=1535:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_av=off:nm=32:plsq=on:sp=const_frequency:spb=goal:urr=on:i=497:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:br=off:kws=arity_squared:newcnf=on:nm=40:nwc=10.0:sd=1:sp=unary_first:spb=goal_then_units:ss=axioms:urr=on:i=762:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:sos=on:sp=frequency:to=lpo:urr=on:i=423:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_flr=on:fsd=on:sd=2:ss=axioms:i=1254:si=on:rtra=on_0"); + quick.push("dis-11_1:1_avsq=on:avsqr=1,16:ep=R:gs=on:nm=32:plsq=on:plsqc=1:plsqr=19,1:sos=on:i=362:si=on:rtra=on_0"); + quick.push("dis+10_5:4_anc=none:bd=off:drc=off:fsr=off:ins=2:newcnf=on:sd=1:sgt=8:sp=unary_first:ss=axioms:tgt=full:i=1105:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:bd=off:bsr=unit_only:kws=frequency:lcm=reverse:nm=16:s2a=on:s2agt=8:sd=1:ss=axioms:st=3.0:urr=on:i=766:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_bd=off:kws=inv_frequency:lcm=reverse:nwc=10.0:plsq=on:plsql=on:plsqr=1,32:rawr=on:s2agt=16:s2at=3.0:sd=2:slsq=on:slsqc=2:sp=frequency:ss=axioms:st=5.0:i=312:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_bd=off:fd=off:nm=4:nwc=10.0:sd=1:ss=axioms:urr=on:i=355:si=on:rtra=on_0"); + quick.push("ott+1011_1:1_bd=off:drc=off:flr=on:kws=precedence:s2a=on:s2agt=32:sp=frequency:urr=on:i=608:si=on:rtra=on_0"); + quick.push("ott+10_1:1_av=off:erd=off:sos=on:ss=axioms:st=1.5:urr=on:i=197:si=on:rtra=on_0"); + quick.push("dis+2_4:1_acc=on:avsq=on:avsqc=1:avsqr=43,6:drc=off:fsr=off:kws=precedence:lcm=reverse:lma=on:newcnf=on:rawr=on:sac=on:sos=on:sp=weighted_frequency:i=865:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_nwc=10.0:sgt=8:ss=axioms:urr=on:i=819:si=on:rtra=on_0"); + quick.push("ott+10_1:128_s2a=on:sp=reverse_arity:spb=goal_then_units:to=lpo:i=159:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_anc=none:flr=on:kws=inv_arity:nm=0:nwc=5.0:sd=1:sgt=60:spb=units:ss=axioms:uhcvi=on:i=854:si=on:rtra=on_0"); + quick.push("ott+10_4:1_br=off:nwc=10.0:s2a=on:s2at=5.0:spb=goal:ss=axioms:st=2.0:tgt=full:to=lpo:urr=on:i=417:si=on:rtra=on_0"); + quick.push("ott+21_11537325:1048576_awrs=decay:awrsf=30:bd=off:nm=20:nwc=10.0:sd=10:sp=weighted_frequency:ss=axioms:st=2.0:urr=on:i=2221:si=on:rtra=on_0"); + quick.push("dis+21_1:1_anc=all:er=tagged:fsr=off:nm=16:s2agt=16:s2pl=on:sac=on:sos=on:sp=const_min:spb=goal_then_units:to=lpo:i=445:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=inv_precedence:plsq=on:rawr=on:rp=on:slsq=on:sp=unary_first:i=59:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_flr=on:plsq=on:s2a=on:s2agt=16:to=lpo:i=410:si=on:rtra=on_0"); + quick.push("dis+11_1:1_fsr=off:plsq=on:plsqr=3,1:s2a=on:s2agt=4:sac=on:sgt=8:ss=axioms:urr=on:i=1476:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_avsq=on:avsqc=1:avsqr=1,16:lcm=reverse:s2a=on:s2agt=16:sp=frequency:urr=on:i=575:si=on:rtra=on_0"); + quick.push("dis+10_1:1_acc=on:br=off:s2a=on:s2agt=16:urr=on:i=1564:si=on:rtra=on_0"); + quick.push("lrs-1011_2:1_er=filter:flr=on:nwc=5.0:sac=on:sp=reverse_arity:to=lpo:i=482:si=on:rtra=on_0"); + quick.push("lrs+1002_1:2_ep=R:fsr=off:lwlo=on:s2a=on:sos=on:i=902:si=on:rtra=on_0"); + quick.push("ott+10_1:32_drc=off:kws=precedence:sd=1:spb=goal_then_units:ss=axioms:st=2.0:i=412:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_avsq=on:drc=off:ins=1:rawr=on:spb=non_intro:ss=axioms:st=2.0:tgt=ground:urr=on:i=563:si=on:rtra=on_0"); + quick.push("dis-1011_1:10_acc=on:drc=off:nm=2:s2a=on:s2at=3.0:sac=on:sd=2:sgt=10:ss=axioms:tgt=ground:i=2602:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:kws=precedence:sd=1:slsq=on:sp=const_frequency:spb=intro:ss=axioms:tgt=full:i=462:si=on:rtra=on_0"); + quick.push("lrs+1010_1:3_newcnf=on:sp=unary_first:ss=axioms:st=3.0:urr=on:i=899:si=on:rtra=on_0"); + quick.push("lrs+10_1:40_av=off:bs=unit_only:rp=on:sd=1:ss=axioms:st=5.0:tgt=full:i=1668:si=on:rtra=on_0"); + quick.push("ott+10_8:1_acc=on:awrs=decay:awrsf=200:ccuc=first:drc=off:fde=none:newcnf=on:nm=10:nwc=6.0:sp=reverse_frequency:uhcvi=on:urr=on:i=788:si=on:rtra=on_0"); + quick.push("lrs+1002_1:2_av=off:sd=1:sos=all:ss=axioms:st=3.0:urr=ec_only:i=221:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_add=large:avsq=on:avsqr=21,4:bsr=unit_only:nm=16:nwc=6.0:plsq=on:plsqr=7452629,65536:rawr=on:s2a=on:slsq=on:slsqc=1:slsqr=1,4:sp=const_frequency:uhcvi=on:i=836:si=on:rtra=on_0"); + quick.push("ott+2_1:1_plsq=on:plsqr=32,1:rawr=on:sos=all:sp=weighted_frequency:spb=units:ss=axioms:to=lpo:i=616:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_av=off:ins=1:kws=inv_frequency:s2a=on:s2agt=8:sd=2:slsq=on:slsqc=1:slsqr=1,4:ss=axioms:st=5.0:tgt=ground:i=361:si=on:rtra=on_0"); + quick.push("lrs+2_1:67_av=off:fde=unused:kws=precedence:lcm=reverse:sos=on:i=208:si=on:rtra=on_0"); + quick.push("ott-2_2:3_av=off:drc=off:lcm=reverse:newcnf=on:nm=2:nwc=10.0:s2a=on:s2agt=10:to=lpo:urr=on:i=1514:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_flr=on:kws=precedence:s2at=5.0:slsq=on:slsqc=1:sp=const_min:ss=axioms:st=2.0:tgt=ground:i=3668:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_drc=off:kws=precedence:s2a=on:urr=on:i=435:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_av=off:bd=off:erd=off:fsr=off:gs=on:sos=on:urr=on:i=625:si=on:rtra=on_0"); + quick.push("ott+21_35:3_drc=off:s2at=5.0:sac=on:slsq=on:slsqr=1,8:sp=reverse_frequency:ss=axioms:urr=on:i=7156:si=on:rtra=on_0"); + quick.push("dis+10_1:6_awrs=converge:drc=off:nm=4:s2a=on:sp=const_frequency:to=lpo:urr=on:i=459:si=on:rtra=on_0"); + quick.push("lrs+21_1:6_av=off:drc=off:fd=preordered:kws=frequency:nwc=5.0:sd=1:sgt=30:ss=axioms:st=3.0:tgt=ground:i=941:si=on:rtra=on_0"); + quick.push("lrs+2_1:4_er=filter:plsq=on:plsqc=1:plsqr=32,1:sp=frequency:spb=goal:ss=axioms:st=2.0:tgt=ground:urr=on:i=1189:si=on:rtra=on_0"); + quick.push("lrs+21_16:1_bd=off:cond=fast:kws=precedence:nm=2:s2a=on:sos=on:sp=unary_first:urr=ec_only:i=661:si=on:rtra=on_0"); + quick.push("dis+10_1:14_aac=none:fd=preordered:fsr=off:s2a=on:sac=on:sd=2:sgt=8:sp=weighted_frequency:ss=axioms:tgt=full:i=1613:si=on:rtra=on_0"); + quick.push("ott+10_1:1_s2a=on:s2agt=16:sgt=10:slsq=on:slsqc=1:sp=const_min:spb=goal_then_units:ss=axioms:to=lpo:i=1350:si=on:rtra=on_0"); + quick.push("lrs+3_1:6_anc=all:avsq=on:drc=off:nm=0:nwc=5.0:s2a=on:s2agt=8:spb=goal_then_units:to=lpo:urr=on:i=1116:si=on:rtra=on_0"); + quick.push("ott+1004_1:12_atotf=0.2:ins=1:sd=1:sgt=32:sp=frequency:ss=axioms:st=3.0:tgt=full:i=588:si=on:rtra=on_0"); + quick.push("ott+21_1:1_drc=off:s2a=on:s2agt=15:sp=reverse_arity:to=lpo:urr=on:i=671:si=on:rtra=on_0"); + quick.push("lrs+10_1:16_nwc=10.0:s2a=on:ss=axioms:st=2.0:urr=on:i=499:si=on:rtra=on_0"); + quick.push("lrs-1011_1:20_sd=2:sgt=30:sp=frequency:spb=goal_then_units:ss=axioms:tgt=full:i=1353:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_aac=none:fsr=off:sos=all:sp=const_frequency:ss=axioms:st=3.0:urr=on:i=1220:si=on:rtra=on_0"); + quick.push("dis+10_16:1_avsq=on:avsqr=1,16:fd=preordered:sgt=8:sos=all:ss=axioms:to=lpo:i=1207:si=on:rtra=on_0"); + quick.push("lrs+1002_3:1_plsq=on:plsqr=1,2:s2a=on:s2agt=8:sac=on:sgt=4:ss=axioms:i=683:si=on:rtra=on_0"); + quick.push("dis+1010_5568647:1048576_awrs=decay:awrsf=200:ins=3:kws=inv_arity:nwc=5.0:ss=axioms:i=450:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_av=off:ep=RSTC:erd=off:kws=arity_squared:nwc=5.0:s2a=on:i=389:si=on:rtra=on_0"); + quick.push("lrs+1011_2:1_bd=off:br=off:s2a=on:s2agt=8:s2at=1.2:slsq=on:slsqc=1:slsqr=2,1:i=566:si=on:rtra=on_0"); + // Improves by expected 129.57230129213247 probs costing 59995 Mi + // Sub-schedule for 120000Mi strat cap / 120000Mi overall limit + quick.push("ott+11_1:1_av=off:bsr=unit_only:sos=all:i=2836:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_av=off:fd=off:nwc=5.0:sd=2:ss=axioms:st=3.0:to=lpo:i=2899:si=on:rtra=on_0"); + quick.push("dis+1002_2:1_anc=all_dependent:drc=off:newcnf=on:nm=32:s2a=on:s2agt=20:s2at=1.5:sp=reverse_arity:i=2258:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=6540:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_fd=off:nwc=5.0:sos=on:spb=goal_then_units:to=lpo:i=343:si=on:rtra=on_0"); + quick.push("ott+1002_5:1_drc=off:nwc=10.0:sp=const_min:spb=goal_then_units:to=lpo:urr=on:i=2333:si=on:rtra=on_0"); + quick.push("ott+21_1:1_av=off:nwc=5.0:s2a=on:spb=intro:to=lpo:i=1038:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_fd=preordered:fde=unused:nm=10:s2at=5.0:slsq=on:slsqc=1:slsqr=4,1:spb=goal:ss=axioms:st=2.0:tgt=ground:to=lpo:i=433:si=on:rtra=on_0"); + quick.push("lrs+1011_3:2_lsd=30:nm=30:s2a=on:s2agt=15:slsq=on:spb=goal:to=lpo:i=1401:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_av=off:cond=fast:drc=off:kws=precedence:s2a=on:s2at=3.0:i=842:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_aac=none:avsq=on:avsqc=2:nm=40:sac=on:sos=all:urr=on:i=2039:si=on:rtra=on_0"); + quick.push("dis+10_1:8_av=off:fsd=on:fsr=off:s2a=on:sos=all:i=2503:si=on:rtra=on_0"); + quick.push("lrs+11_4:1_br=off:bs=on:drc=off:sp=const_frequency:spb=goal_then_units:ss=axioms:to=lpo:i=840:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_kws=arity_squared:nm=32:nwc=2.0:sac=on:i=687:si=on:rtra=on_0"); + quick.push("dis-11_1:1_avsq=on:avsqr=1,16:ep=R:gs=on:nm=32:plsq=on:plsqc=1:plsqr=19,1:sos=on:i=411:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_bd=off:kws=inv_frequency:lcm=reverse:nwc=10.0:plsq=on:plsql=on:plsqr=1,32:rawr=on:s2agt=16:s2at=3.0:sd=2:slsq=on:slsqc=2:sp=frequency:ss=axioms:st=5.0:i=312:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_ep=RS:ss=axioms:i=1165:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=precedence:newcnf=on:nm=4:sos=on:sp=const_max:i=813:si=on:rtra=on_0"); + quick.push("lrs-1002_1:1_br=off:s2a=on:sp=unary_frequency:to=lpo:urr=on:i=1313:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_alpa=false:bd=preordered:fde=none:newcnf=on:nm=64:s2at=5.0:slsq=on:slsqr=4,1:sos=on:sp=frequency:to=lpo:i=203:si=on:rtra=on_0"); + quick.push("dis+1011_2:1_afr=on:fde=none:s2a=on:s2agt=20:i=2973:si=on:rtra=on_0"); + quick.push("ott+1011_1:1_bd=off:drc=off:flr=on:kws=precedence:s2a=on:s2agt=32:sp=frequency:urr=on:i=608:si=on:rtra=on_0"); + quick.push("lrs+10_16:1_abs=on:drc=off:nm=6:sac=on:sos=on:i=1041:si=on:rtra=on_0"); + quick.push("ott+10_1:1_av=off:erd=off:sos=on:ss=axioms:st=1.5:urr=on:i=1054:si=on:rtra=on_0"); + quick.push("dis+1011_5:1_gsp=on:ins=2:kws=inv_precedence:newcnf=on:sos=all:sp=const_max:spb=goal_then_units:i=697:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_fd=off:nm=2:sos=on:to=lpo:urr=on:i=1715:si=on:rtra=on_0"); + quick.push("dis+1010_5:1_av=off:kws=precedence:nm=64:plsq=on:s2a=on:s2at=2.0:sp=unary_frequency:ss=axioms:i=1866:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_erd=off:ins=1:kws=frequency:nm=40:sd=1:ss=axioms:st=5.0:tgt=ground:uhcvi=on:i=2009:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_anc=none:flr=on:kws=inv_arity:nm=0:nwc=5.0:sd=1:sgt=60:spb=units:ss=axioms:uhcvi=on:i=1951:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_acc=on:anc=none:bd=off:drc=off:erd=off:nwc=10.0:rnwc=on:s2a=on:s2at=2.0:urr=ec_only:i=691:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_nm=2:s2a=on:s2agt=16:sp=const_max:ss=axioms:st=2.0:urr=on:i=1009:si=on:rtra=on_0"); + quick.push("ott+2_8:1_abs=on:br=off:kws=frequency:nm=30:s2a=on:s2at=1.2:sp=frequency:tgt=full:urr=on:i=1046:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:ss=axioms:st=3.0:urr=on:i=1855:si=on:rtra=on_0"); + quick.push("lrs+1011_1:2_av=off:fsr=off:ins=1:lsd=10:nm=16:nwc=10.0:s2a=on:s2at=3.0:sp=unary_first:urr=on:i=519:si=on:rtra=on_0"); + quick.push("dis+1_1:1_atotf=0.18:fd=off:flr=on:newcnf=on:sos=on:i=355:si=on:rtra=on_0"); + quick.push("dis+1011_1:2_av=off:drc=off:flr=on:kws=precedence:sgt=8:ss=axioms:i=555:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=inv_precedence:plsq=on:rawr=on:rp=on:slsq=on:sp=unary_first:i=932:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cond=on:fd=preordered:flr=on:sos=on:sp=reverse_frequency:ss=axioms:i=338:si=on:rtra=on_0"); + quick.push("dis-1011_1:2_av=off:fde=unused:nwc=3.0:s2a=on:s2agt=100:tgt=full:i=1487:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_fd=preordered:lecc=0.5:sos=on:sp=unary_frequency:to=lpo:urr=on:i=1078:si=on:rtra=on_0"); + quick.push("dis+10_1:64_acc=on:bce=on:fde=none:nm=30:sd=3:sos=on:sp=frequency:ss=axioms:st=7.0:tgt=ground:to=lpo:i=905:si=on:rtra=on_0"); + quick.push("lrs-1011_1:32_av=off:bsd=on:drc=off:nm=10:sd=2:sgt=20:ss=axioms:st=1.5:tgt=ground:i=8118:si=on:rtra=on_0"); + quick.push("dis+10_4:1_cond=fast:fde=none:s2a=on:s2agt=32:s2at=1.2:i=1338:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=preordered:fd=preordered:fsd=on:newcnf=on:plsq=on:plsql=on:slsq=on:sos=on:sp=weighted_frequency:spb=goal:to=lpo:i=695:si=on:rtra=on_0"); + quick.push("ott+21_1:1_drc=off:fde=unused:s2a=on:s2at=5.0:sp=const_min:urr=ec_only:i=664:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_afr=on:kws=precedence:nm=16:sp=weighted_frequency:spb=goal_then_units:ss=axioms:tgt=ground:i=3722:si=on:rtra=on_0"); + quick.push("dis+1011_1:5_av=off:bsr=unit_only:drc=off:sp=reverse_arity:tgt=full:i=4913:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:nm=2:plsq=on:plsqc=2:sos=all:sp=const_frequency:i=397:si=on:rtra=on_0"); + quick.push("dis+21_5:1_drc=off:s2a=on:s2agt=16:s2at=5.0:tgt=full:uhcvi=on:urr=on:i=1397:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=5:drc=off:fde=none:kws=precedence:s2a=on:s2at=6.0:sp=frequency:spb=goal:tgt=ground:i=1081:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2agt=16:slsq=on:slsqc=1:sp=weighted_frequency:to=lpo:i=842:si=on:rtra=on_0"); + quick.push("lrs-1010_1:1_ep=RSTC:sos=on:urr=ec_only:i=849:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:kws=precedence:sd=1:slsq=on:sp=const_frequency:spb=intro:ss=axioms:tgt=full:i=348:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_anc=none:ep=RS:nm=2:sd=10:sgt=10:sp=const_max:ss=axioms:i=1105:si=on:rtra=on_0"); + quick.push("lrs+1010_5:1_fde=unused:ins=3:newcnf=on:nwc=6.0:s2a=on:s2at=3.0:spb=intro:i=2557:si=on:rtra=on_0"); + quick.push("dis+11_1:3_avsq=on:avsql=on:bd=off:drc=off:fd=preordered:kws=inv_frequency:lma=on:newcnf=on:sp=reverse_frequency:tgt=ground:uhcvi=on:i=4384:si=on:rtra=on_0"); + quick.push("dis+1011_1:4_avsq=on:bd=off:kws=inv_frequency:nwc=5.0:s2a=on:sac=on:sp=const_frequency:i=1788:si=on:rtra=on_0"); + quick.push("ott+2_2:1_br=off:drc=off:ins=3:newcnf=on:nm=0:sp=const_frequency:ss=axioms:st=3.0:tgt=full:urr=on:i=5487:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_cond=fast:nm=10:sd=2:spb=intro:ss=axioms:i=1162:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_bd=preordered:nwc=5.0:sd=1:ss=axioms:urr=on:i=2880:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_acc=on:avsq=on:avsqc=1:fsr=off:tgt=ground:i=182:si=on:rtra=on_0"); + quick.push("dis-1_1:1_abs=on:bd=off:sos=on:sp=frequency:to=lpo:i=481:si=on:rtra=on_0"); + quick.push("dis+1011_3:1_av=off:fsr=off:nwc=10.0:sgt=16:sp=unary_first:ss=axioms:st=2.0:i=1980:si=on:rtra=on_0"); + quick.push("ott+21_1:1_drc=off:s2a=on:s2agt=15:sp=reverse_arity:to=lpo:urr=on:i=1077:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_bd=off:nm=16:s2a=on:s2agt=16:sp=frequency:to=lpo:i=732:si=on:rtra=on_0"); + quick.push("lrs-1011_1:20_sd=2:sgt=30:sp=frequency:spb=goal_then_units:ss=axioms:tgt=full:i=237:si=on:rtra=on_0"); + quick.push("ott+1011_8:1_br=off:drc=off:kws=precedence:nm=2:s2a=on:s2agt=16:sp=frequency:urr=on:i=7121:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_av=off:cond=fast:gs=on:ins=3:sos=all:sp=frequency:to=lpo:i=1438:si=on:rtra=on_0"); + quick.push("lrs+1011_2:13_av=off:awrs=decay:awrsf=300:bd=off:fd=off:fsr=off:kws=inv_precedence:s2a=on:s2at=1.5:slsq=on:spb=goal:i=1103:si=on:rtra=on_0"); + quick.push("ott+21_29:3_erd=off:s2a=on:s2at=1.5:sac=on:sd=1:ss=axioms:st=6.0:to=lpo:urr=on:i=770:si=on:rtra=on_0"); + quick.push("lrs-11_1:1_br=off:drc=off:kws=precedence:lsd=50:slsq=on:slsql=off:slsqr=1,2:spb=intro:ss=axioms:i=492:si=on:rtra=on_0"); + quick.push("dis-1010_1:6_fde=unused:ins=2:rawr=on:slsq=on:slsqc=1:slsqr=11,4:sp=reverse_arity:spb=non_intro:tgt=ground:i=760:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2a=on:sp=occurrence:to=lpo:i=293:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_anc=all:awrs=decay:bs=on:erd=off:ins=1:sd=1:sgt=16:sos=all:spb=goal:ss=axioms:st=1.5:to=lpo:i=1323:si=on:rtra=on_0"); + quick.push("dis+21_1:8_bs=unit_only:fsr=off:kws=inv_arity_squared:sos=on:sp=unary_frequency:i=1386:si=on:rtra=on_0"); + quick.push("dis+2_8:1_aac=none:abs=on:bd=off:er=tagged:fde=none:fs=off:fsr=off:sfv=off:sos=all:to=lpo:i=566:si=on:rtra=on_0"); + quick.push("dis+1002_1:2_av=off:ep=RSTC:erd=off:kws=arity_squared:nwc=5.0:s2a=on:i=389:si=on:rtra=on_0"); + // Improves by expected 107.39643521475446 probs costing 119873 Mi + // Sub-schedule for 240000Mi strat cap / 240000Mi overall limit + quick.push("dis+1010_1:7_bd=off:kws=arity_squared:s2a=on:sp=const_frequency:tgt=ground:i=537:si=on:rtra=on_0"); + quick.push("dis+10_1:1_fd=off:ins=2:lma=on:sos=all:spb=goal_then_units:i=369:si=on:rtra=on_0"); + quick.push("ott+1_8:1_add=large:nm=64:s2a=on:s2agt=5:s2at=3.0:tgt=full:uhcvi=on:urr=on:i=1447:si=on:rtra=on_0"); + quick.push("dis-10_1:3_acc=model:awrs=decay:br=off:bsd=on:fd=preordered:nm=2:s2a=on:s2at=3.0:tgt=full:to=lpo:i=3738:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_av=off:bsd=on:kws=inv_arity_squared:plsq=on:plsqr=1,8:ss=axioms:tgt=full:i=10094:si=on:rtra=on_0"); + quick.push("dis+11_1:7_sac=on:sd=2:ss=axioms:st=4.0:i=1715:si=on:rtra=on_0"); + quick.push("ott+4_1:1024_bd=off:plsq=on:plsqc=1:plsqr=7,1:sd=2:ss=axioms:i=383:si=on:rtra=on_0"); + quick.push("lrs+1011_1:24_atotf=0.2:bd=off:s2a=on:s2agt=60:sgt=20:ss=axioms:tgt=ground:i=8128:si=on:rtra=on_0"); + quick.push("lrs+10_7:4_acc=on:drc=off:kws=inv_frequency:nm=16:sp=weighted_frequency:spb=intro:ss=axioms:tgt=full:i=476:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=893:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_fd=off:nwc=5.0:sos=on:spb=goal_then_units:to=lpo:i=343:si=on:rtra=on_0"); + quick.push("ott+1002_5:1_drc=off:nwc=10.0:sp=const_min:spb=goal_then_units:to=lpo:urr=on:i=1356:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_ep=RS:sos=on:ss=axioms:st=1.5:urr=on:i=3901:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:br=off:kws=arity_squared:newcnf=on:nm=40:nwc=10.0:sd=1:sp=unary_first:spb=goal_then_units:ss=axioms:urr=on:i=1084:si=on:rtra=on_0"); + quick.push("lrs+11_2:1_av=off:drc=off:lsd=50:nm=2:nwc=5.0:s2a=on:s2agt=20:i=4880:si=on:rtra=on_0"); + quick.push("lrs+1011_5:1_av=off:lwlo=on:nwc=3.0:tgt=ground:i=10632:si=on:rtra=on_0"); + quick.push("lrs+11_4:1_br=off:bs=on:drc=off:sp=const_frequency:spb=goal_then_units:ss=axioms:to=lpo:i=840:si=on:rtra=on_0"); + quick.push("dis+1004_1:1_av=off:drc=off:fd=preordered:flr=on:s2a=on:s2agt=16:sp=const_frequency:urr=ec_only:i=2191:si=on:rtra=on_0"); + quick.push("dis-1010_8:1_av=off:cond=fast:flr=on:kws=inv_frequency:nm=0:nwc=10.0:i=546:si=on:rtra=on_0"); + quick.push("ott+2_1:1_lcm=predicate:s2a=on:s2agt=4:s2at=2.0:urr=on:i=6322:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bs=on:fde=unused:flr=on:s2a=on:s2at=2.0:i=1860:si=on:rtra=on_0"); + quick.push("dis+10_5:4_anc=none:bd=off:drc=off:fsr=off:ins=2:newcnf=on:sd=1:sgt=8:sp=unary_first:ss=axioms:tgt=full:i=1834:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_av=off:bd=off:bsr=unit_only:kws=frequency:lcm=reverse:nm=16:s2a=on:s2agt=8:sd=1:ss=axioms:st=3.0:urr=on:i=713:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_bd=off:kws=inv_frequency:lcm=reverse:nwc=10.0:plsq=on:plsql=on:plsqr=1,32:rawr=on:s2agt=16:s2at=3.0:sd=2:slsq=on:slsqc=2:sp=frequency:ss=axioms:st=5.0:i=312:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_ep=RS:ss=axioms:i=1165:si=on:rtra=on_0"); + quick.push("dis+1010_1:24_kws=arity_squared:sac=on:sgt=20:sp=unary_frequency:ss=axioms:tgt=full:i=11705:si=on:rtra=on_0"); + quick.push("lrs+10_8:1_drc=off:ins=1:plsq=on:plsqc=1:plsqr=32,1:urr=on:i=3162:si=on:rtra=on_0"); + quick.push("ott+1011_1:1_bd=off:drc=off:flr=on:kws=precedence:s2a=on:s2agt=32:sp=frequency:urr=on:i=2837:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_amm=off:bs=unit_only:fd=preordered:kws=inv_frequency:lcm=predicate:newcnf=on:spb=goal:tgt=ground:i=10191:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_av=off:ins=1:newcnf=on:nwc=10.0:s2a=on:s2at=2.0:ss=axioms:i=4466:si=on:rtra=on_0"); + quick.push("lrs-3_3:1_slsq=on:sp=frequency:to=lpo:urr=on:i=1192:si=on:rtra=on_0"); + quick.push("ott+1011_5:1_atotf=0.2:nm=0:sgt=10:ss=axioms:tgt=ground:i=2284:si=on:rtra=on_0"); + quick.push("dis-1011_1:1_av=off:fd=off:nm=2:slsq=on:slsql=off:spb=goal_then_units:ss=axioms:st=5.0:uhcvi=on:i=5106:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_fde=unused:flr=on:gsp=on:lwlo=on:nwc=10.0:sd=2:spb=units:ss=axioms:st=2.0:urr=on:i=2348:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_anc=none:flr=on:kws=inv_arity:nm=0:nwc=5.0:sd=1:sgt=60:spb=units:ss=axioms:uhcvi=on:i=1715:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_acc=on:anc=none:bd=off:drc=off:erd=off:nwc=10.0:rnwc=on:s2a=on:s2at=2.0:urr=ec_only:i=691:si=on:rtra=on_0"); + quick.push("dis+1011_1:14_ep=R:fsr=off:kws=inv_arity:lsd=50:nwc=5.0:s2a=on:s2agt=60:sp=weighted_frequency:i=1769:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_ep=R:nm=0:slsq=on:slsqr=1,16:i=8263:si=on:rtra=on_0"); + quick.push("dis+10_16:1_drc=off:sd=2:sos=on:sp=const_min:ss=axioms:to=lpo:i=2535:si=on:rtra=on_0"); + quick.push("dis+1010_16:1_sos=on:sp=const_frequency:to=lpo:i=6745:si=on:rtra=on_0"); + quick.push("dis+1010_1:24_amm=sco:nm=0:s2a=on:s2at=2.0:sp=unary_first:tgt=ground:i=2461:si=on:rtra=on_0"); + quick.push("ott+2_8:1_abs=on:br=off:kws=frequency:nm=30:s2a=on:s2at=1.2:sp=frequency:tgt=full:urr=on:i=1046:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_br=off:plsq=on:plsqr=4779363,1048576:sd=2:sos=all:ss=axioms:urr=on:i=3830:si=on:rtra=on_0"); + quick.push("dis+1002_5:1_add=large:amm=sco:gs=on:newcnf=on:s2a=on:s2agt=30:s2at=1.2:s2pl=no:slsq=on:slsqr=1,8:sp=reverse_arity:spb=intro:i=375:si=on:rtra=on_0"); + quick.push("lrs+1011_1:2_av=off:fsr=off:ins=1:lsd=10:nm=16:nwc=10.0:s2a=on:s2at=3.0:sp=unary_first:urr=on:i=2292:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_br=off:s2a=on:s2at=5.0:sd=2:ss=axioms:st=2.0:urr=on:i=2461:si=on:rtra=on_0"); + quick.push("dis+1011_1:2_av=off:drc=off:flr=on:kws=precedence:sgt=8:ss=axioms:i=555:si=on:rtra=on_0"); + quick.push("dis+10_1:1_kws=inv_precedence:plsq=on:rawr=on:rp=on:slsq=on:sp=unary_first:i=932:si=on:rtra=on_0"); + quick.push("dis+21_141:35_awrs=decay:awrsf=110:kws=precedence:lcm=reverse:lma=on:nwc=10.0:s2a=on:s2at=3.0:sp=reverse_arity:i=2411:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_av=off:bd=off:br=off:cond=fast:nwc=3.0:s2a=on:s2at=3.0:i=3870:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_atotf=0.00189482:drc=off:fsr=off:s2a=on:sd=1:ss=axioms:st=2.0:i=2594:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=preordered:fd=preordered:fsd=on:newcnf=on:plsq=on:plsql=on:slsq=on:sos=on:sp=weighted_frequency:spb=goal:to=lpo:i=4502:si=on:rtra=on_0"); + quick.push("ott+21_1:1_drc=off:fde=unused:s2a=on:s2at=5.0:sp=const_min:urr=ec_only:i=664:si=on:rtra=on_0"); + quick.push("ott+10_1:1_bd=off:nm=30:slsq=on:slsqr=1,2:sp=unary_first:ss=axioms:st=2.0:uhcvi=on:urr=on:i=5300:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_amm=off:sgt=8:sos=all:sp=unary_first:ss=axioms:to=lpo:i=1515:si=on:rtra=on_0"); + quick.push("lrs-1011_8:1_amm=off:avsq=on:avsqr=1,16:bd=off:sos=on:sp=const_frequency:spb=non_intro:to=lpo:uhcvi=on:i=551:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_nm=2:s2a=on:s2agt=100:sd=4:sgt=8:sos=all:ss=axioms:i=481:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_anc=none:ep=RS:kws=frequency:lcm=reverse:rp=on:s2a=on:sos=on:sp=occurrence:spb=goal:tgt=ground:updr=off:i=481:si=on:rtra=on_0"); + quick.push("dis+21_5:1_acc=on:br=off:lcm=predicate:newcnf=on:nicw=on:nm=2:sp=unary_first:ss=axioms:st=1.5:urr=on:i=3391:si=on:rtra=on_0"); + quick.push("dis-1011_1:28_av=off:drc=off:fde=unused:s2a=on:tgt=full:i=3375:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_avsq=on:drc=off:ins=1:rawr=on:spb=non_intro:ss=axioms:st=2.0:tgt=ground:urr=on:i=1807:si=on:rtra=on_0"); + quick.push("dis+1002_8:1_s2a=on:s2agt=10:i=1986:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=5:drc=off:fde=none:kws=precedence:s2a=on:s2at=6.0:sp=frequency:spb=goal:tgt=ground:i=4248:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2agt=16:slsq=on:slsqc=1:sp=weighted_frequency:to=lpo:i=410:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:kws=precedence:sd=1:slsq=on:sp=const_frequency:spb=intro:ss=axioms:tgt=full:i=1780:si=on:rtra=on_0"); + quick.push("dis-1011_1:1_av=off:fd=preordered:fsr=off:lcm=reverse:nm=2:nwc=10.0:s2a=on:s2agt=16:spb=goal:to=lpo:i=1903:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_anc=none:ep=RS:nm=2:sd=10:sgt=10:sp=const_max:ss=axioms:i=971:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_add=large:avsq=on:avsqr=21,4:bsr=unit_only:nm=16:nwc=6.0:plsq=on:plsqr=7452629,65536:rawr=on:s2a=on:slsq=on:slsqc=1:slsqr=1,4:sp=const_frequency:uhcvi=on:i=836:si=on:rtra=on_0"); + quick.push("lrs+1011_4:1_nwc=5.0:s2a=on:sp=const_min:ss=axioms:urr=on:i=1660:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_acc=model:anc=all:bd=off:flr=on:kws=inv_frequency:nm=16:sac=on:sos=all:i=3697:si=on:rtra=on_0"); + quick.push("lrs+1010_1:3_newcnf=on:spb=non_intro:ss=axioms:st=2.0:urr=on:i=1140:si=on:rtra=on_0"); + quick.push("ott+21_1:1_bsr=unit_only:fsr=off:kws=inv_arity:nwc=10.0:rawr=on:sos=all:sp=frequency:i=1566:si=on:rtra=on_0"); + quick.push("lrs+21_1:7_drc=off:gsp=on:sd=1:sgt=64:ss=axioms:urr=on:i=4815:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_atotf=0.4:fde=unused:nm=2:sos=all:to=lpo:uhcvi=on:i=4977:si=on:rtra=on_0"); + quick.push("lrs+21_1:6_av=off:drc=off:fd=preordered:kws=frequency:nwc=5.0:sd=1:sgt=30:ss=axioms:st=3.0:tgt=ground:i=941:si=on:rtra=on_0"); + quick.push("ott+1004_8:1_fd=preordered:sac=on:ss=axioms:st=3.0:to=lpo:i=3117:si=on:rtra=on_0"); + quick.push("lrs+3_1:6_anc=all:avsq=on:drc=off:nm=0:nwc=5.0:s2a=on:s2agt=8:spb=goal_then_units:to=lpo:urr=on:i=2430:si=on:rtra=on_0"); + quick.push("lrs+10_1:8_drc=off:slsq=on:slsqc=1:sp=const_min:ss=axioms:to=lpo:i=493:si=on:rtra=on_0"); + quick.push("lrs+2_1:1_bd=off:fd=off:sfv=off:sos=all:to=lpo:i=3997:si=on:rtra=on_0"); + quick.push("dis+1011_3:1_av=off:fsr=off:nwc=10.0:sgt=16:sp=unary_first:ss=axioms:st=2.0:i=1197:si=on:rtra=on_0"); + quick.push("lrs+1002_16:1_flr=on:nwc=3.0:s2a=on:s2agt=16:sp=const_min:spb=goal:to=lpo:urr=on:i=1399:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_aac=none:fsr=off:sos=all:sp=const_frequency:ss=axioms:st=3.0:urr=on:i=1072:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:ins=1:lwlo=on:nwc=10.0:sp=weighted_frequency:urr=on:i=3443:si=on:rtra=on_0"); + quick.push("dis+10_16:1_avsq=on:avsqr=1,16:fd=preordered:sgt=8:sos=all:ss=axioms:to=lpo:i=1288:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2a=on:sp=occurrence:to=lpo:i=293:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_anc=all:awrs=decay:bs=on:erd=off:ins=1:sd=1:sgt=16:sos=all:spb=goal:ss=axioms:st=1.5:to=lpo:i=1221:si=on:rtra=on_0"); + quick.push("ott+1666_5:1_aac=none:bs=unit_only:kws=inv_frequency:nwc=5.0:rawr=on:s2a=on:s2agt=64:sac=on:sp=occurrence:spb=goal:urr=on:i=13536:si=on:rtra=on_0"); + // Improves by expected 77.33427083754582 probs costing 239991 Mi + // Sub-schedule for 480000Mi strat cap / 480000Mi overall limit + quick.push("lrs+1011_8:1_cond=fast:drc=off:nwc=3.0:rawr=on:s2a=on:sac=on:slsq=on:slsqr=40,243:sp=const_frequency:to=lpo:uhcvi=on:i=8121:si=on:rtra=on_0"); + quick.push("dis+1011_2:1_acc=on:br=off:drc=off:kws=precedence:newcnf=on:sp=reverse_arity:tgt=ground:uhcvi=on:i=13525:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bd=off:sos=all:ss=axioms:i=3630:si=on:rtra=on_0"); + quick.push("dis+21_1:4_bs=unit_only:bsd=on:ile=on:sp=const_min:tgt=full:to=lpo:uhcvi=on:i=2762:si=on:rtra=on_0"); + quick.push("lrs+10_7:4_acc=on:drc=off:kws=inv_frequency:nm=16:sp=weighted_frequency:spb=intro:ss=axioms:tgt=full:i=3049:si=on:rtra=on_0"); + quick.push("ott+21_1:1_av=off:nwc=5.0:s2a=on:spb=intro:to=lpo:i=1038:si=on:rtra=on_0"); + quick.push("lrs+1011_3:2_lsd=30:nm=30:s2a=on:s2agt=15:slsq=on:spb=goal:to=lpo:i=1401:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:fsr=off:lecc=0.5:lsd=50:nm=2:s2a=on:s2at=3.0:sp=frequency:tgt=ground:i=3853:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_avsq=on:bce=on:fde=unused:ins=2:kws=inv_frequency:sos=on:sp=reverse_arity:urr=on:i=3073:si=on:rtra=on_0"); + quick.push("ott+2_1:1_lcm=predicate:s2a=on:s2agt=4:s2at=2.0:urr=on:i=6097:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_bs=on:fde=unused:flr=on:s2a=on:s2at=2.0:i=1860:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_ep=RS:ss=axioms:i=1165:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_fde=unused:uhcvi=on:i=16232:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:fde=none:newcnf=on:nwc=5.0:i=4876:si=on:rtra=on_0"); + quick.push("lrs+1011_3:1_nm=2:s2a=on:s2at=3.0:sp=const_min:ss=axioms:st=5.0:tgt=full:i=1673:si=on:rtra=on_0"); + quick.push("ott+10_1:1_av=off:erd=off:sos=on:ss=axioms:st=1.5:urr=on:i=10207:si=on:rtra=on_0"); + quick.push("ott+21_314:127_av=off:bd=preordered:drc=off:fde=none:gsp=on:nm=6:s2a=on:s2agt=30:sp=const_min:spb=goal:urr=ec_only:i=1565:si=on:rtra=on_0"); + quick.push("dis+1011_7:3_aac=none:bsr=unit_only:er=filter:kws=precedence:lma=on:nm=0:sd=2:sgt=16:sp=unary_first:ss=axioms:tgt=ground:i=920:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_ins=2:kws=precedence:nwc=5.0:sac=on:urr=ec_only:i=2425:si=on:rtra=on_0"); + quick.push("ott+21_11537325:1048576_awrs=decay:awrsf=30:bd=off:nm=20:nwc=10.0:sd=10:sp=weighted_frequency:ss=axioms:st=2.0:urr=on:i=3718:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_ins=2:nm=2:sp=frequency:tgt=ground:to=lpo:i=5996:si=on:rtra=on_0"); + quick.push("ott+21_1:1_kws=precedence:nm=4:sos=on:sp=frequency:uhcvi=on:updr=off:urr=on:i=5264:si=on:rtra=on_0"); + quick.push("dis+1010_1:1024_bd=off:drc=off:newcnf=on:rawr=on:s2pl=on:sd=2:sgt=20:sp=const_frequency:spb=goal_then_units:ss=axioms:tgt=full:i=3581:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_drc=off:newcnf=on:nm=2:sd=1:sp=occurrence:ss=axioms:st=3.0:i=4038:si=on:rtra=on_0"); + quick.push("dis+21_2:3_cond=on:fde=none:lcm=reverse:nm=0:plsq=on:plsqc=1:plsqr=32,1:sac=on:spb=goal_then_units:tgt=full:i=14261:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_avsq=on:avsqr=1,2:bd=off:kws=inv_frequency:nm=6:sos=all:spb=intro:i=7339:si=on:rtra=on_0"); + quick.push("dis+1011_1:7_av=off:bsd=on:drc=off:fd=preordered:ins=3:lsd=60:nm=2:nwc=10.0:sp=const_min:ss=axioms:st=3.0:i=5995:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2a=on:s2agt=16:i=1362:si=on:rtra=on_0"); + quick.push("lrs+10_1:128_acc=on:awrs=decay:awrsf=30:fd=preordered:fde=none:ins=3:kws=arity_squared:newcnf=on:nwc=5.0:rnwc=on:s2a=on:sp=unary_frequency:ss=axioms:i=1394:si=on:rtra=on_0"); + quick.push("dis-1011_1:128_bd=off:drc=off:fsd=on:sp=const_frequency:ss=axioms:tgt=ground:i=4809:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_cond=on:nwc=10.0:ss=axioms:st=2.0:urr=on:i=3544:si=on:rtra=on_0"); + quick.push("dis+10_8:1_av=off:ep=R:plsq=on:plsqr=204383,524288:sos=all:i=9186:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_avsq=on:avsqc=3:avsqr=1,16:flr=on:nwc=10.0:s2a=on:s2agt=32:sp=frequency:spb=goal_then_units:tgt=ground:i=8899:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_amm=off:sgt=8:sos=all:sp=unary_first:ss=axioms:to=lpo:i=1339:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_afr=on:kws=precedence:nm=16:sp=weighted_frequency:spb=goal_then_units:ss=axioms:tgt=ground:i=3722:si=on:rtra=on_0"); + quick.push("dis+0_16:1_br=off:kws=inv_frequency:s2a=on:s2at=5.0:urr=on:i=2417:si=on:rtra=on_0"); + quick.push("dis-1011_1:28_av=off:drc=off:fde=unused:s2a=on:tgt=full:i=3375:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_avsq=on:drc=off:ins=1:rawr=on:spb=non_intro:ss=axioms:st=2.0:tgt=ground:urr=on:i=1807:si=on:rtra=on_0"); + quick.push("ott+2_1:1_bsr=unit_only:flr=on:sac=on:sos=all:i=3511:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2agt=16:slsq=on:slsqc=1:sp=weighted_frequency:to=lpo:i=410:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_av=off:sd=2:sos=on:ss=axioms:urr=on:i=14864:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_anc=none:ep=RS:nm=2:sd=10:sgt=10:sp=const_max:ss=axioms:i=971:si=on:rtra=on_0"); + quick.push("dis+11_1:3_avsq=on:avsql=on:bd=off:drc=off:fd=preordered:kws=inv_frequency:lma=on:newcnf=on:sp=reverse_frequency:tgt=ground:uhcvi=on:i=10010:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_gsp=on:kws=arity:plsq=on:plsqr=1,1:s2a=on:s2at=2.0:sp=unary_frequency:spb=goal_then_units:i=9429:si=on:rtra=on_0"); + quick.push("dis+1011_1:4_avsq=on:bd=off:kws=inv_frequency:nwc=5.0:s2a=on:sac=on:sp=const_frequency:i=1629:si=on:rtra=on_0"); + quick.push("ott+1002_16:1_add=off:anc=all_dependent:nm=64:sac=on:slsq=on:slsqr=1,16:urr=on:i=6961:si=on:rtra=on_0"); + quick.push("lrs+1010_1:3_av=off:drc=off:foolp=on:kws=arity_squared:nm=20:nwc=10.0:plsq=on:plsqc=1:plsqr=32,1:sp=unary_frequency:tgt=full:i=7727:si=on:rtra=on_0"); + quick.push("dis+1011_8:1_avsq=on:ep=RS:fsr=off:plsq=on:plsqr=32,1:ss=axioms:st=1.5:i=720:si=on:rtra=on_0"); + quick.push("ott+21_1:1_bsr=unit_only:fsr=off:kws=inv_arity:nwc=10.0:rawr=on:sos=all:sp=frequency:i=1566:si=on:rtra=on_0"); + quick.push("lrs+21_1:7_drc=off:gsp=on:sd=1:sgt=64:ss=axioms:urr=on:i=3830:si=on:rtra=on_0"); + quick.push("lrs+10_1:5_av=off:drc=off:gsp=on:kws=precedence:s2a=on:s2at=-1.0:sos=on:spb=goal_then_units:i=5072:si=on:rtra=on_0"); + quick.push("dis-1011_1:4_av=off:drc=off:fde=unused:kws=inv_frequency:nm=32:nwc=2.0:tgt=full:i=31202:si=on:rtra=on_0"); + quick.push("lrs+1011_1:12_amm=off:br=off:ins=1:s2a=on:s2at=5.0:sims=off:urr=on:i=15694:si=on:rtra=on_0"); + quick.push("ott+21_35:3_drc=off:s2at=5.0:sac=on:slsq=on:slsqr=1,8:sp=reverse_frequency:ss=axioms:urr=on:i=26662:si=on:rtra=on_0"); + quick.push("lrs+2_1:4_er=filter:plsq=on:plsqc=1:plsqr=32,1:sp=frequency:spb=goal:ss=axioms:st=2.0:tgt=ground:urr=on:i=1189:si=on:rtra=on_0"); + quick.push("ott-10_8:1_flr=on:rawr=on:s2a=on:s2at=5.0:sac=on:slsq=on:i=9607:si=on:rtra=on_0"); + quick.push("lrs+10_4:1_bd=preordered:nwc=5.0:sd=1:ss=axioms:urr=on:i=2880:si=on:rtra=on_0"); + quick.push("lrs+1011_1:14_av=off:drc=off:kws=frequency:lecc=1.5:lwlo=on:s2a=on:s2at=5.0:slsq=on:slsql=off:slsqr=3,4:spb=goal:tgt=full:i=16083:si=on:rtra=on_0"); + quick.push("ott+10_1:1_s2a=on:s2agt=16:sgt=10:slsq=on:slsqc=1:sp=const_min:spb=goal_then_units:ss=axioms:to=lpo:i=2785:si=on:rtra=on_0"); + quick.push("ott+10_1:1_flr=on:fsr=off:nwc=10.0:s2a=on:sac=on:spb=goal:urr=on:i=3506:si=on:rtra=on_0"); + quick.push("dis+1011_1:16_drc=off:sac=on:spb=goal_then_units:ss=axioms:st=5.0:i=10538:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_fde=none:kws=frequency:newcnf=on:s2a=on:s2agt=64:sac=on:slsq=on:slsqr=1,2:i=6707:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_aac=none:ep=RST:s2a=on:sos=all:sp=occurrence:spb=goal_then_units:i=17627:si=on:rtra=on_0"); + quick.push("lrs+1011_1:2_ins=1:newcnf=on:spb=goal:ss=axioms:tgt=full:i=22096:si=on:rtra=on_0"); + quick.push("dis+1011_3:1_av=off:fsr=off:nwc=10.0:sgt=16:sp=unary_first:ss=axioms:st=2.0:i=1406:si=on:rtra=on_0"); + quick.push("ott+1004_1:12_atotf=0.2:ins=1:sd=1:sgt=32:sp=frequency:ss=axioms:st=3.0:tgt=full:i=11080:si=on:rtra=on_0"); + quick.push("lrs+1002_16:1_flr=on:nwc=3.0:s2a=on:s2agt=16:sp=const_min:spb=goal:to=lpo:urr=on:i=1399:si=on:rtra=on_0"); + quick.push("lrs-1011_1:20_sd=2:sgt=30:sp=frequency:spb=goal_then_units:ss=axioms:tgt=full:i=1428:si=on:rtra=on_0"); + quick.push("dis+1002_1:1_av=off:cond=fast:gs=on:ins=3:sos=all:sp=frequency:to=lpo:i=1092:si=on:rtra=on_0"); + quick.push("dis-1011_1:1_atotf=0.1:drc=off:kws=inv_precedence:s2a=on:s2agt=20:sac=on:spb=non_intro:tgt=ground:i=11373:si=on:rtra=on_0"); + quick.push("dis-1011_1:14_av=off:awrs=decay:awrsf=200:ins=1:nwc=10.0:sos=on:sp=unary_first:i=4014:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_bd=off:ins=1:lwlo=on:nwc=10.0:sp=weighted_frequency:urr=on:i=3443:si=on:rtra=on_0"); + quick.push("dis+10_16:1_avsq=on:avsqr=1,16:fd=preordered:sgt=8:sos=all:ss=axioms:to=lpo:i=1776:si=on:rtra=on_0"); + quick.push("lrs+1002_3:1_plsq=on:plsqr=1,2:s2a=on:s2agt=8:sac=on:sgt=4:ss=axioms:i=882:si=on:rtra=on_0"); + quick.push("lrs+1010_1:6_anc=all:awrs=decay:bs=on:erd=off:ins=1:sd=1:sgt=16:sos=all:spb=goal:ss=axioms:st=1.5:to=lpo:i=1221:si=on:rtra=on_0"); + quick.push("dis+10_4:1_bd=off:drc=off:kws=precedence:nm=2:rawr=on:s2a=on:slsq=on:slsqc=3:slsql=off:slsqr=1,8:sp=const_frequency:urr=ec_only:i=8538:si=on:rtra=on_0"); + quick.push("dis+2_875:524288_av=off:erd=off:kws=inv_arity_squared:rawr=on:sos=all:spb=goal_then_units:ss=axioms:st=3.0:i=2088:si=on:rtra=on_0"); + quick.push("dis+2_3:1_awrs=converge:awrsf=200:s2a=on:s2at=4.0:uhcvi=on:urr=on:i=16763:si=on:rtra=on_0"); + // Improves by expected 41.86702006570085 probs costing 479219 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("lrs+1011_8:1_cond=fast:drc=off:nwc=3.0:rawr=on:s2a=on:sac=on:slsq=on:slsqr=40,243:sp=const_frequency:to=lpo:uhcvi=on:i=8121:si=on:rtra=on_0"); + quick.push("dis+1011_2:1_acc=on:br=off:drc=off:kws=precedence:newcnf=on:sp=reverse_arity:tgt=ground:uhcvi=on:i=13525:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_av=off:bsd=on:kws=inv_arity_squared:plsq=on:plsqr=1,8:ss=axioms:tgt=full:i=58470:si=on:rtra=on_0"); + quick.push("lrs+1011_1:24_atotf=0.2:bd=off:s2a=on:s2agt=60:sgt=20:ss=axioms:tgt=ground:i=8120:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=6913:si=on:rtra=on_0"); + quick.push("ott+1002_1:1_avsq=on:bce=on:fde=unused:ins=2:kws=inv_frequency:sos=on:sp=reverse_arity:urr=on:i=3073:si=on:rtra=on_0"); + quick.push("lrs+10_1:20_av=off:nm=2:sp=const_frequency:tgt=ground:i=30341:si=on:rtra=on_0"); + quick.push("ott+2_1:1_lcm=predicate:s2a=on:s2agt=4:s2at=2.0:urr=on:i=6322:si=on:rtra=on_0"); + quick.push("lrs+1011_16:1_awrs=converge:lwlo=on:nwc=3.0:s2a=on:s2agt=32:sd=1:sp=const_frequency:ss=axioms:st=3.0:i=7195:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:fde=none:newcnf=on:nwc=5.0:i=4876:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_amm=off:bs=unit_only:fd=preordered:kws=inv_frequency:lcm=predicate:newcnf=on:spb=goal:tgt=ground:i=11656:si=on:rtra=on_0"); + quick.push("ott+10_1:1_av=off:erd=off:sos=on:ss=axioms:st=1.5:urr=on:i=10207:si=on:rtra=on_0"); + quick.push("ott+2_4:1_br=off:bsd=on:drc=off:nm=2:sp=unary_first:urr=on:i=16933:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_anc=none:flr=on:kws=inv_arity:nm=0:nwc=5.0:sd=1:sgt=60:spb=units:ss=axioms:uhcvi=on:i=3056:si=on:rtra=on_0"); + quick.push("dis+1010_1:1_ins=2:nm=2:sp=frequency:tgt=ground:to=lpo:i=5996:si=on:rtra=on_0"); + quick.push("lrs+10_5:1_br=off:s2a=on:s2at=5.0:sd=2:ss=axioms:st=2.0:urr=on:i=3173:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_drc=off:newcnf=on:nm=2:sd=1:sp=occurrence:ss=axioms:st=3.0:i=4038:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_avsq=on:avsqr=1,2:bd=off:kws=inv_frequency:nm=6:sos=all:spb=intro:i=8587:si=on:rtra=on_0"); + quick.push("dis+1011_1:7_av=off:bsd=on:drc=off:fd=preordered:ins=3:lsd=60:nm=2:nwc=10.0:sp=const_min:ss=axioms:st=3.0:i=5995:si=on:rtra=on_0"); + quick.push("lrs-1011_1:32_av=off:bsd=on:drc=off:nm=10:sd=2:sgt=20:ss=axioms:st=1.5:tgt=ground:i=11353:si=on:rtra=on_0"); + quick.push("lrs+10_1:1_drc=off:erd=off:flr=on:sp=frequency:ss=axioms:to=lpo:i=3413:si=on:rtra=on_0"); + quick.push("dis-1011_1:128_bd=off:drc=off:fsd=on:sp=const_frequency:ss=axioms:tgt=ground:i=4809:si=on:rtra=on_0"); + quick.push("lrs+1002_1:1_bd=preordered:fd=preordered:fsd=on:newcnf=on:plsq=on:plsql=on:slsq=on:sos=on:sp=weighted_frequency:spb=goal:to=lpo:i=4793:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_atotf=0.1:flr=on:kws=precedence:sp=const_min:i=35258:si=on:rtra=on_0"); + quick.push("dis-1010_1:1_avsq=on:avsqc=3:avsqr=1,16:flr=on:nwc=10.0:s2a=on:s2agt=32:sp=frequency:spb=goal_then_units:tgt=ground:i=8899:si=on:rtra=on_0"); + quick.push("lrs-10_1:4_acc=model:nm=0:s2a=on:sac=on:sp=reverse_arity:ss=axioms:i=6565:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_lsd=10:sp=const_frequency:ss=axioms:st=2.0:tgt=full:uhcvi=on:i=5521:si=on:rtra=on_0"); + quick.push("dis+21_5:1_acc=on:br=off:lcm=predicate:newcnf=on:nicw=on:nm=2:sp=unary_first:ss=axioms:st=1.5:urr=on:i=5474:si=on:rtra=on_0"); + quick.push("ott+2_1:1_bsr=unit_only:flr=on:sac=on:sos=all:i=5123:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=5:drc=off:fde=none:kws=precedence:s2a=on:s2at=6.0:sp=frequency:spb=goal:tgt=ground:i=22924:si=on:rtra=on_0"); + quick.push("dis+10_1:1_s2agt=16:slsq=on:slsqc=1:sp=weighted_frequency:to=lpo:i=767:si=on:rtra=on_0"); + quick.push("lrs+10_2:3_av=off:bd=off:br=off:bs=unit_only:drc=off:nwc=5.0:sp=const_min:ss=axioms:tgt=ground:i=40987:si=on:rtra=on_0"); + quick.push("ott+10_8:1_acc=on:fsr=off:kws=frequency:nm=40:nwc=10.0:s2a=on:s2at=1.5:sac=on:tgt=full:urr=on:i=2607:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_gsp=on:kws=arity:plsq=on:plsqr=1,1:s2a=on:s2at=2.0:sp=unary_frequency:spb=goal_then_units:i=9429:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_av=off:drc=off:fde=unused:kws=inv_precedence:s2a=on:s2at=5.0:sp=reverse_arity:spb=goal_then_units:tgt=ground:i=16263:si=on:rtra=on_0"); + quick.push("ott+1002_16:1_add=off:anc=all_dependent:nm=64:sac=on:slsq=on:slsqr=1,16:urr=on:i=3798:si=on:rtra=on_0"); + quick.push("ott+21_1:1_bsr=unit_only:fsr=off:kws=inv_arity:nwc=10.0:rawr=on:sos=all:sp=frequency:i=1566:si=on:rtra=on_0"); + quick.push("lrs+21_1:7_drc=off:gsp=on:sd=1:sgt=64:ss=axioms:urr=on:i=3830:si=on:rtra=on_0"); + quick.push("dis-1011_1:4_av=off:drc=off:fde=unused:kws=inv_frequency:nm=32:nwc=2.0:tgt=full:i=172628:si=on:rtra=on_0"); + quick.push("ott+21_35:3_drc=off:s2at=5.0:sac=on:slsq=on:slsqr=1,8:sp=reverse_frequency:ss=axioms:urr=on:i=23269:si=on:rtra=on_0"); + quick.push("ott-10_8:1_flr=on:rawr=on:s2a=on:s2at=5.0:sac=on:slsq=on:i=9607:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_ep=RS:fde=unused:slsq=on:slsqr=1,2:sp=occurrence:spb=goal:i=5156:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_bd=off:drc=off:kws=inv_frequency:s2a=on:slsq=on:slsqr=1,16:sp=reverse_frequency:i=15582:si=on:rtra=on_0"); + quick.push("ott+10_1:1_flr=on:fsr=off:nwc=10.0:s2a=on:sac=on:spb=goal:urr=on:i=1480:si=on:rtra=on_0"); + quick.push("dis+1011_1:16_drc=off:sac=on:spb=goal_then_units:ss=axioms:st=5.0:i=30462:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_fde=none:kws=frequency:newcnf=on:s2a=on:s2agt=64:sac=on:slsq=on:slsqr=1,2:i=58288:si=on:rtra=on_0"); + quick.push("ott+10_5:1_newcnf=on:nm=16:sp=frequency:spb=goal:tgt=full:urr=on:i=23110:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_aac=none:ep=RST:s2a=on:sos=all:sp=occurrence:spb=goal_then_units:i=66939:si=on:rtra=on_0"); + quick.push("lrs+1011_1:2_ins=1:newcnf=on:spb=goal:ss=axioms:tgt=full:i=22096:si=on:rtra=on_0"); + quick.push("ott+1004_1:12_atotf=0.2:ins=1:sd=1:sgt=32:sp=frequency:ss=axioms:st=3.0:tgt=full:i=11080:si=on:rtra=on_0"); + quick.push("dis+10_1:1_drc=off:nm=2:nwc=3.0:sp=const_frequency:spb=non_intro:urr=on:i=12548:si=on:rtra=on_0"); + quick.push("dis-1011_1:1_atotf=0.1:drc=off:kws=inv_precedence:s2a=on:s2agt=20:sac=on:spb=non_intro:tgt=ground:i=56532:si=on:rtra=on_0"); + quick.push("dis-1011_1:14_av=off:awrs=decay:awrsf=200:ins=1:nwc=10.0:sos=on:sp=unary_first:i=3771:si=on:rtra=on_0"); + quick.push("lrs+1011_4:1_afr=on:rawr=on:slsq=on:slsqr=1,2:sp=const_max:spb=intro:uhcvi=on:urr=ec_only:i=27814:si=on:rtra=on_0"); + quick.push("dis+2_875:524288_av=off:erd=off:kws=inv_arity_squared:rawr=on:sos=all:spb=goal_then_units:ss=axioms:st=3.0:i=2088:si=on:rtra=on_0"); + // Improves by expected 18.1183416852127 probs costing 952371 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("lrs+1011_1:8_av=off:sd=1:spb=goal_then_units:ss=axioms:st=5.0:uhcvi=on:i=80949:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_av=off:bsd=on:kws=inv_arity_squared:plsq=on:plsqr=1,8:ss=axioms:tgt=full:i=47349:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=6913:si=on:rtra=on_0"); + quick.push("ott+2_1:1_lcm=predicate:s2a=on:s2agt=4:s2at=2.0:urr=on:i=3807:si=on:rtra=on_0"); + quick.push("lrs+1011_16:1_awrs=converge:lwlo=on:nwc=3.0:s2a=on:s2agt=32:sd=1:sp=const_frequency:ss=axioms:st=3.0:i=25600:si=on:rtra=on_0"); + quick.push("dis+1010_1:24_kws=arity_squared:sac=on:sgt=20:sp=unary_frequency:ss=axioms:tgt=full:i=52880:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:fde=none:newcnf=on:nwc=5.0:i=4876:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_amm=off:bs=unit_only:fd=preordered:kws=inv_frequency:lcm=predicate:newcnf=on:spb=goal:tgt=ground:i=83426:si=on:rtra=on_0"); + quick.push("lrs+1010_1:16_av=off:s2a=on:sp=const_frequency:tgt=full:i=26935:si=on:rtra=on_0"); + quick.push("dis-1011_1:128_bd=off:drc=off:fsd=on:sp=const_frequency:ss=axioms:tgt=ground:i=4809:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_atotf=0.1:flr=on:kws=precedence:sp=const_min:i=35258:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=5:drc=off:fde=none:kws=precedence:s2a=on:s2at=6.0:sp=frequency:spb=goal:tgt=ground:i=22924:si=on:rtra=on_0"); + quick.push("lrs+10_2:3_av=off:bd=off:br=off:bs=unit_only:drc=off:nwc=5.0:sp=const_min:ss=axioms:tgt=ground:i=27187:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_av=off:drc=off:fde=unused:kws=inv_precedence:s2a=on:s2at=5.0:sp=reverse_arity:spb=goal_then_units:tgt=ground:i=16263:si=on:rtra=on_0"); + quick.push("lrs+1011_1:12_amm=off:br=off:ins=1:s2a=on:s2at=5.0:sims=off:urr=on:i=25881:si=on:rtra=on_0"); + quick.push("ott+21_35:3_drc=off:s2at=5.0:sac=on:slsq=on:slsqr=1,8:sp=reverse_frequency:ss=axioms:urr=on:i=26662:si=on:rtra=on_0"); + quick.push("ott-10_8:1_flr=on:rawr=on:s2a=on:s2at=5.0:sac=on:slsq=on:i=9607:si=on:rtra=on_0"); + quick.push("lrs+10_1:2_av=off:br=off:drc=off:lecc=1.6:sp=weighted_frequency:tgt=full:i=179211:si=on:rtra=on_0"); + quick.push("lrs+1011_1:14_av=off:drc=off:kws=frequency:lecc=1.5:lwlo=on:s2a=on:s2at=5.0:slsq=on:slsql=off:slsqr=3,4:spb=goal:tgt=full:i=22579:si=on:rtra=on_0"); + quick.push("ott+10_1:1_flr=on:fsr=off:nwc=10.0:s2a=on:sac=on:spb=goal:urr=on:i=3506:si=on:rtra=on_0"); + quick.push("dis+1011_1:16_drc=off:sac=on:spb=goal_then_units:ss=axioms:st=5.0:i=30462:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_fde=none:kws=frequency:newcnf=on:s2a=on:s2agt=64:sac=on:slsq=on:slsqr=1,2:i=54338:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_aac=none:ep=RST:s2a=on:sos=all:sp=occurrence:spb=goal_then_units:i=66939:si=on:rtra=on_0"); + quick.push("dis+2_875:524288_av=off:erd=off:kws=inv_arity_squared:rawr=on:sos=all:spb=goal_then_units:ss=axioms:st=3.0:i=2088:si=on:rtra=on_0"); + quick.push("ott+1011_1:10_nwc=10.0:ss=axioms:tgt=full:i=36675:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_av=off:bd=off:lwlo=on:nwc=10.0:sp=unary_first:to=lpo:i=60909:si=on:rtra=on_0"); + // Improves by expected 5.968501703193174 probs costing 958007 Mi + // Sub-schedule for 960000Mi strat cap / 960000Mi overall limit + quick.push("dis+1011_1:3_av=off:bsd=on:kws=inv_arity_squared:plsq=on:plsqr=1,8:ss=axioms:tgt=full:i=47349:si=on:rtra=on_0"); + quick.push("ott+1010_8:1_bsr=unit_only:drc=off:fsr=off:plsq=on:plsqc=1:plsqr=32,1:s2a=on:s2agt=32:urr=on:i=6913:si=on:rtra=on_0"); + quick.push("ott+2_1:1_lcm=predicate:s2a=on:s2agt=4:s2at=2.0:urr=on:i=6097:si=on:rtra=on_0"); + quick.push("lrs+1010_1:1_bd=off:fde=none:newcnf=on:nwc=5.0:i=4876:si=on:rtra=on_0"); + quick.push("ott+10_1:1_bd=off:nm=30:slsq=on:slsqr=1,2:sp=unary_first:ss=axioms:st=2.0:uhcvi=on:urr=on:i=52916:si=on:rtra=on_0"); + quick.push("dis+1011_1:3_atotf=0.1:flr=on:kws=precedence:sp=const_min:i=25809:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_acc=on:avsq=on:avsqc=5:drc=off:fde=none:kws=precedence:s2a=on:s2at=6.0:sp=frequency:spb=goal:tgt=ground:i=22924:si=on:rtra=on_0"); + quick.push("dis+10_1:14_acc=on:drc=off:fd=preordered:fde=unused:plsq=on:plsqr=1,32:sac=on:sp=occurrence:tgt=full:i=196386:si=on:rtra=on_0"); + quick.push("lrs+1011_1:1_av=off:drc=off:fde=unused:kws=inv_precedence:s2a=on:s2at=5.0:sp=reverse_arity:spb=goal_then_units:tgt=ground:i=16263:si=on:rtra=on_0"); + quick.push("dis+1011_1:1_ep=RS:fde=unused:slsq=on:slsqr=1,2:sp=occurrence:spb=goal:i=122892:si=on:rtra=on_0"); + quick.push("lrs+10_1:2_av=off:br=off:drc=off:lecc=1.6:sp=weighted_frequency:tgt=full:i=193646:si=on:rtra=on_0"); + quick.push("ott+10_1:1_flr=on:fsr=off:nwc=10.0:s2a=on:sac=on:spb=goal:urr=on:i=3506:si=on:rtra=on_0"); + quick.push("dis+1011_1:16_drc=off:sac=on:spb=goal_then_units:ss=axioms:st=5.0:i=30462:si=on:rtra=on_0"); + quick.push("dis+1010_8:1_fde=none:kws=frequency:newcnf=on:s2a=on:s2agt=64:sac=on:slsq=on:slsqr=1,2:i=54338:si=on:rtra=on_0"); + quick.push("lrs+21_1:1_acc=on:atotf=0.1:drc=off:gs=on:lwlo=on:sac=on:sp=const_frequency:ss=axioms:tgt=full:i=77167:si=on:rtra=on_0"); + quick.push("dis+2_875:524288_av=off:erd=off:kws=inv_arity_squared:rawr=on:sos=all:spb=goal_then_units:ss=axioms:st=3.0:i=2088:si=on:rtra=on_0"); + quick.push("ott+1011_1:10_nwc=10.0:ss=axioms:tgt=full:i=79160:si=on:rtra=on_0"); + // Improves by expected 2.9329672676943623 probs costing 942775 Mi + // Overall score 6292.973951117842 probs on average / budget 3812207 Mi + } +} + +#endif diff --git a/CASC/Schedules.hpp b/CASC/Schedules.hpp index 3daacb7a57..6853a143ef 100644 --- a/CASC/Schedules.hpp +++ b/CASC/Schedules.hpp @@ -26,8 +26,6 @@ class Schedules { public: static void getScheduleFromFile(const vstring& filename, Schedule& quick); - - static void getHigherOrderSchedule2020(Schedule& quick, Schedule& fallback); static void getCasc2019Schedule(const Shell::Property& property, Schedule& quick, Schedule& fallback); static void getCascSat2019Schedule(const Shell::Property& property, Schedule& quick, Schedule& fallback); @@ -46,6 +44,12 @@ class Schedules static void getSnakeTptpUnsSchedule(const Shell::Property& property, Schedule& quick); static void getSnakeTptpSatSchedule(const Shell::Property& property, Schedule& quick); + +#if VHOL + static void getSnakeTptpHolSchedule(const Shell::Property& property, Schedule& quick); + static void getSnakeSlhSchedule(const Shell::Property& property, Schedule& quick); +#endif + }; } diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ee4b1c80..5639d5cff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,6 +233,8 @@ set(VAMPIRE_KERNEL_SOURCES Kernel/Problem.cpp Kernel/Renaming.cpp Kernel/RobSubstitution.cpp + Kernel/HOLUnification.cpp + Kernel/HOLMatching.cpp Kernel/MismatchHandler.cpp Kernel/Signature.cpp Kernel/SortHelper.cpp @@ -283,6 +285,8 @@ set(VAMPIRE_KERNEL_SOURCES Kernel/RCClauseStack.hpp Kernel/Renaming.hpp Kernel/RobSubstitution.hpp + Kernel/HOLUnification.hpp + Kernel/HOLMatching.hpp Kernel/MismatchHandler.hpp Kernel/Signature.hpp Kernel/SortHelper.hpp @@ -306,22 +310,20 @@ set(VAMPIRE_KERNEL_SOURCES Kernel/PolynomialNormalizer.cpp Kernel/ApplicativeHelper.hpp Kernel/ApplicativeHelper.cpp - Kernel/SKIKBO.hpp - Kernel/SKIKBO.cpp Inferences/CNFOnTheFly.cpp Inferences/CNFOnTheFly.hpp - Inferences/CombinatorDemodISE.cpp - Inferences/CombinatorDemodISE.hpp - Inferences/CombinatorNormalisationISE.hpp - Inferences/CombinatorNormalisationISE.cpp + Inferences/BetaEtaISE.cpp + Inferences/BetaEtaISE.hpp + Inferences/FlexFlexSimplify.cpp + Inferences/FlexFlexSimplify.hpp + Inferences/ImitateProject.hpp + Inferences/ImitateProject.cpp Inferences/ArgCong.hpp Inferences/ArgCong.cpp Inferences/NegativeExt.cpp Inferences/NegativeExt.hpp - Inferences/Narrow.hpp - Inferences/Narrow.cpp - Inferences/SubVarSup.hpp - Inferences/SubVarSup.cpp + Inferences/PositiveExt.cpp + Inferences/PositiveExt.hpp Inferences/BoolEqToDiseq.hpp Inferences/BoolEqToDiseq.cpp Inferences/PrimitiveInstantiation.cpp @@ -338,8 +340,8 @@ set(VAMPIRE_KERNEL_SOURCES Inferences/CasesSimp.hpp Inferences/Cases.cpp Inferences/Cases.hpp - Shell/LambdaElimination.cpp - Shell/LambdaElimination.hpp + Shell/LambdaConversion.cpp + Shell/LambdaConversion.hpp ) source_group(kernel_source_files FILES ${VAMPIRE_KERNEL_SOURCES}) @@ -358,6 +360,7 @@ set(VAMPIRE_INDEXING_SOURCES Indexing/LiteralSubstitutionTree.cpp Indexing/ResultSubstitution.cpp Indexing/SubstitutionTree.cpp + Indexing/HOLSubstitutionTree.cpp Indexing/SubstitutionTree_FastGen.cpp Indexing/SubstitutionTree_FastInst.cpp Indexing/SubstitutionTree_Nodes.cpp @@ -365,8 +368,8 @@ set(VAMPIRE_INDEXING_SOURCES Indexing/TermIndex.cpp Indexing/TermSharing.cpp Indexing/TermSubstitutionTree.cpp - Indexing/AcyclicityIndex.hpp - Indexing/ClauseCodeTree.hpp +# Indexing/AcyclicityIndex.hpp + Indexing/ClauseCodeTree.hpp Indexing/ClauseVariantIndex.hpp Indexing/CodeTree.hpp Indexing/CodeTreeInterfaces.hpp @@ -380,6 +383,7 @@ set(VAMPIRE_INDEXING_SOURCES Indexing/LiteralSubstitutionTree.hpp Indexing/ResultSubstitution.hpp Indexing/SubstitutionTree.hpp + Indexing/HOLSubstitutionTree.hpp Indexing/TermCodeTree.hpp Indexing/TermIndex.hpp Indexing/TermIndexingStructure.hpp @@ -643,8 +647,6 @@ set(VAMPIRE_SHELL_SOURCES Shell/Token.hpp Shell/TPTPPrinter.hpp Shell/TweeGoalTransformation.hpp - Shell/UnificationWithAbstractionConfig.hpp - Shell/UnificationWithAbstractionConfig.cpp Shell/UIHelper.hpp Shell/VarManager.hpp Shell/Lexer.hpp @@ -715,6 +717,7 @@ set(UNIT_TESTS UnitTests/tDHMap.cpp UnitTests/tQuotientE.cpp UnitTests/tUnificationWithAbstraction.cpp + UnitTests/tHOLMatching.cpp UnitTests/tGaussianElimination.cpp UnitTests/tPushUnaryMinus.cpp UnitTests/tArithmeticSubtermGeneralization.cpp @@ -731,7 +734,7 @@ set(UNIT_TESTS UnitTests/tBinaryHeap.cpp UnitTests/tSafeRecursion.cpp UnitTests/tKBO.cpp - UnitTests/tSKIKBO.cpp +# UnitTests/tSKIKBO.cpp UnitTests/tLPO.cpp UnitTests/tRatioKeeper.cpp UnitTests/tTwoVampires.cpp @@ -741,9 +744,12 @@ set(UNIT_TESTS UnitTests/tBottomUpEvaluation.cpp UnitTests/tCoproduct.cpp UnitTests/tEqualityResolution.cpp + UnitTests/tEqualityFactoring.cpp + UnitTests/tImitateProject.cpp UnitTests/tIterator.cpp UnitTests/tOption.cpp UnitTests/tStack.cpp + UnitTests/tBetaReduction.cpp ) source_group(unit_tests FILES ${UNIT_TESTS}) @@ -802,6 +808,13 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Release) add_compile_definitions(VDEBUG=0) endif() +if(CMAKE_BUILD_HOL STREQUAL On) + message(STATUS "Building with HOL support") + add_compile_definitions(VHOL=1) +else() + message(STATUS "Building without HOL support") + add_compile_definitions(VHOL=0) +endif() add_compile_definitions(VTIME_PROFILING=1) if (CYGWIN) @@ -917,7 +930,7 @@ endif() # COMPILE_TESTS ################################################################# # automated generation of Vampire revision information from git # ################################################################# -set(VAMPIRE_VERSION_NUMBER 4.7) +set(VAMPIRE_VERSION_NUMBER 4.8) execute_process( COMMAND git rev-parse --is-inside-work-tree diff --git a/Debug/Output.hpp b/Debug/Output.hpp index 6c70e0dbf2..79aa38957b 100644 --- a/Debug/Output.hpp +++ b/Debug/Output.hpp @@ -11,17 +11,15 @@ * @file Forwards.hpp * Forward declarations of some classes */ -#ifndef __Debug_Output__ -#define __Debug_Output__ +#ifndef __Debug_Output_HPP__ +#define __Debug_Output_HPP__ #include #include +#include -namespace Kernel { -template -std::ostream& operator<<(std::ostream& out, std::pair const& self) -{ return out << "(" << self.first << ", " << self.second << ")"; } +namespace Kernel { /** Newtype in order to nicely output a pointer. * Usage: `out << outputPtr(ptr) << std::endl;` @@ -36,6 +34,11 @@ struct OutputPtr { template OutputPtr outputPtr(T* self) { return { .self = self, }; } +template +void repeat(std::ostream& out, T const& c, int times) +{ for (int i = 0; i < times; i++) out << c; }; + + /** Newtype for outputting a datatype that implements it in multiline format. * Usage: `out << multiline(substitutioTree) << std::endl;` * @@ -43,18 +46,77 @@ OutputPtr outputPtr(T* self) { return { .self = self, }; } * std::ostream& operator<<(std::ostream&, OutputMultiline) */ template -struct OutputMultiline { T const& self; }; +struct OutputMultiline { + T const& self; + unsigned indent; -template -OutputMultiline multiline(T const& self) -{ return { self }; } + static void outputIndent(std::ostream& out, unsigned indent) + { repeat(out, " ", indent); }; +}; template -void repeat(std::ostream& out, T const& c, int times) -{ for (int i = 0; i < times; i++) out << c; }; +OutputMultiline multiline(T const& self, unsigned indent = 0) +{ return { self, indent, }; } + +template +struct OutputInterleaved { + Sep const& sep; + Iter iter; +}; + +template +struct OutputInterleaved outputInterleaved(Sep const& s, Iter i) +{ return OutputInterleaved{s, std::move(i)}; } + + +template +auto commaSep(Iter i) { return outputInterleaved(", ", std::move(i)); } + +template +struct __OutputTuple +{ + static void apply(std::ostream& out, Tup const& self) + { + out << std::get(self) << ", "; + __OutputTuple::apply(out, self); + } +}; + +template +struct __OutputTuple { + static void apply(std::ostream& out, Tup const& self) + { + out << std::get(self); + } +}; -static constexpr char const* INDENT = " "; +template +std::ostream& operator<<(std::ostream& out, std::tuple const& self) +{ + out << "("; + Kernel::__OutputTuple<0, std::tuple_size>::value - 1, std::tuple>::apply(out, self); + out << ")"; + return out; +} + + +template +std::ostream& operator<<(std::ostream& out, std::pair const& self) +{ return out << "(" << self.first << ", " << self.second << ")"; } + +template +std::ostream& operator<<(std::ostream& out, Kernel::OutputInterleaved self) +{ + if (self.iter.hasNext()) { + out << self.iter.next(); + while (self.iter.hasNext()) { + out << self.sep << self.iter.next(); + } + } + return out; +} } // namespace Kernel -#endif // __Debug_Output__ + +#endif // __Debug_Output_HPP__ diff --git a/Debug/Tracer.hpp b/Debug/Tracer.hpp index 2383ddbf32..7efd9bb687 100644 --- a/Debug/Tracer.hpp +++ b/Debug/Tracer.hpp @@ -24,6 +24,7 @@ #include #include +#include "Debug/Output.hpp" using namespace std; diff --git a/Forwards.hpp b/Forwards.hpp index 3e3a246b7a..3e9e517cdd 100644 --- a/Forwards.hpp +++ b/Forwards.hpp @@ -59,8 +59,6 @@ using namespace Lib; class Signature; class Term; -typedef BiMap FuncSubtermMap; - class TermList; typedef VirtualIterator TermIterator; typedef Stack TermStack; @@ -69,10 +67,6 @@ typedef List VList; // a list of variables (which are unsigned) typedef List SList; // a list of sorts (which are now, with polymorphism, TermLists) typedef const SharedSet VarSet; -typedef std::pair,std::pair> UnificationConstraint; -typedef Stack UnificationConstraintStack; -typedef Lib::SmartPtr UnificationConstraintStackSP; - class Literal; typedef List LiteralList; typedef Stack LiteralStack; @@ -102,9 +96,13 @@ class Problem; class Renaming; class Substitution; -class RobSubstitution; -typedef VirtualIterator SubstIterator; -typedef Lib::SmartPtr RobSubstitutionSP; +class RobSubstitutionTL; +typedef VirtualIterator SubstIterator; +typedef Lib::SmartPtr RobSubstitutionSP; + +class RobSubstitutionTS; +typedef VirtualIterator SubstIteratorTS; +typedef Lib::SmartPtr RobSubstitutionTSSP; class Matcher; typedef VirtualIterator MatchIterator; @@ -135,10 +133,14 @@ enum Color { COLOR_INVALID = 3u }; +enum class SymbolType{FUNC, PRED, TYPE_CON}; + }; namespace Indexing { + + class Index; class IndexManager; class LiteralIndex; @@ -150,9 +152,15 @@ class TermSharing; class ResultSubstitution; typedef Lib::SmartPtr ResultSubstitutionSP; +//typedef Lib::VirtualIterator SubstSPIterator; + +enum class SplittingAlgo { NONE +#if VHOL + , HOL_MATCH + , HOL_UNIF +#endif + }; -struct SLQueryResult; -struct TermQueryResult; }; namespace Saturation diff --git a/Indexing/AcyclicityIndex.cpp b/Indexing/AcyclicityIndex.cpp index 7e1281ffee..4aa508af53 100644 --- a/Indexing/AcyclicityIndex.cpp +++ b/Indexing/AcyclicityIndex.cpp @@ -204,7 +204,7 @@ namespace Indexing _tis(nullptr), _nextResult(nullptr), _stack(0), - _subst(new RobSubstitution()), + _subst(new RobSubstitutionTS()), _substChanges(0), _nextAvailableIndex(0), _currentDepth(0) @@ -393,7 +393,7 @@ namespace Indexing TermIndexingStructure *_tis; CycleQueryResult *_nextResult; Stack _stack; - RobSubstitution *_subst; + RobSubstitutionTS *_subst; Stack _substChanges; int _nextAvailableIndex; unsigned _currentDepth; diff --git a/Indexing/ClauseCodeTree.hpp b/Indexing/ClauseCodeTree.hpp index 5faf86c63a..db0975297e 100644 --- a/Indexing/ClauseCodeTree.hpp +++ b/Indexing/ClauseCodeTree.hpp @@ -99,6 +99,7 @@ class ClauseCodeTree : public CodeTree { void init(ClauseCodeTree* tree_, Clause* query_, bool sres_); void reset(); + bool keepRecycled() const { return lInfos.keepRecycled(); } Clause* next(int& resolvedQueryLit); diff --git a/Indexing/ClauseVariantIndex.cpp b/Indexing/ClauseVariantIndex.cpp index 7cbbba9511..9825c6f4b2 100644 --- a/Indexing/ClauseVariantIndex.cpp +++ b/Indexing/ClauseVariantIndex.cpp @@ -26,6 +26,7 @@ #include "LiteralSubstitutionTree.hpp" #include "ClauseVariantIndex.hpp" +#include "Indexing/IndexManager.hpp" namespace Indexing { @@ -187,7 +188,7 @@ void SubstitutionTreeClauseVariantIndex::insert(Clause* cl) } if(!_strees[clen]) { - _strees[clen]=new LiteralSubstitutionTree(); + _strees[clen] = new LiteralSubstitutionTree(); } Literal* mainLit=getMainLiteral(cl->literals(), clen); _strees[clen]->insert(mainLit, cl); diff --git a/Indexing/CodeTree.hpp b/Indexing/CodeTree.hpp index 44b88e8327..b3f2e90aff 100644 --- a/Indexing/CodeTree.hpp +++ b/Indexing/CodeTree.hpp @@ -395,6 +395,11 @@ class CodeTree public: bool next(); + bool keepRecycled() const + { return bindings.keepRecycled() + || btStack.keepRecycled() + || (firstsInBlocks && firstsInBlocks->keepRecycled()); } + protected: void init(CodeOp* entry_, LitInfo* linfos_, size_t linfoCnt_, CodeTree* tree_, Stack* firstsInBlocks_); @@ -491,6 +496,7 @@ class CodeTree public: /** Variable bindings */ BindingArray bindings; + bool keepRecycled() const { return bindings.keepRecycled(); } protected: /** the matcher object is initialized but no execution of code was done yet */ diff --git a/Indexing/CodeTreeInterfaces.cpp b/Indexing/CodeTreeInterfaces.cpp index 52affd68ec..d2f594b9f1 100644 --- a/Indexing/CodeTreeInterfaces.cpp +++ b/Indexing/CodeTreeInterfaces.cpp @@ -13,6 +13,7 @@ * */ +#include "Indexing/ResultSubstitution.hpp" #include "Lib/Allocator.hpp" #include "Lib/Recycled.hpp" #include "Debug/TimeProfiling.hpp" @@ -155,18 +156,15 @@ class CodeTreeTIS::ResultIterator CALL("CodeTreeTIS::ResultIterator::next"); ASS(_found); - TermQueryResult res; - if(_retrieveSubstitutions) { + ResultSubstitutionSP subs; + if (_retrieveSubstitutions) { _resultNormalizer->reset(); _resultNormalizer->normalizeVariables(_found->t); - res=TermQueryResult(_found->t, _found->lit, _found->cls, - ResultSubstitutionSP(_subst,true)); - } - else { - res=TermQueryResult(_found->t, _found->lit, _found->cls); + subs = ResultSubstitutionSP(_subst, /* nondisposable */ true); } + auto out = TermQueryResult(_found->t, _found->lit, _found->cls, subs); _found=0; - return res; + return out; } private: diff --git a/Indexing/CodeTreeInterfaces.hpp b/Indexing/CodeTreeInterfaces.hpp index 8b62d0b8f9..624f196eb4 100644 --- a/Indexing/CodeTreeInterfaces.hpp +++ b/Indexing/CodeTreeInterfaces.hpp @@ -48,11 +48,15 @@ class CodeTreeTIS : public TermIndexingStructure TermQueryResultIterator getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true); bool generalizationExists(TermList t); + // TODO: get rid of NOT_IMPLEMENTED + TermQueryResultIterator getUwa(TypedTermList t) { NOT_IMPLEMENTED; } #if VDEBUG virtual void markTagged(){ NOT_IMPLEMENTED; } #endif + virtual void output(std::ostream& out) const { out << "CodeTree"; } + private: class ResultIterator; diff --git a/Indexing/HOLSubstitutionTree.cpp b/Indexing/HOLSubstitutionTree.cpp new file mode 100644 index 0000000000..38e81cac61 --- /dev/null +++ b/Indexing/HOLSubstitutionTree.cpp @@ -0,0 +1,416 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file TermSubstitutionTree.cpp + * Implements class TermSubstitutionTree. + */ + +#if VHOL + +#include "Lib/Environment.hpp" +#include "Lib/Metaiterators.hpp" +#include "Kernel/Term.hpp" +#include "Indexing/HOLSubstitutionTree.hpp" + +namespace Indexing +{ + +using namespace Lib; +using namespace Kernel; + + +using Subterm = HOLSubstitutionTree::Subterm; + +std::ostream& operator<< (ostream& out, const Subterm& t ) +{ + return out<shared(); + bool r2HasSpecVars=r2.original.isTerm() && !r2.original.term()->shared(); + if( r1HasSpecVars && !r2HasSpecVars ) { + return GREATER; + } + if( r2HasSpecVars && !r1HasSpecVars ) { + return LESS; + } + return Int::compare(r2.var,r1.var); + } + static Comparison compare(const HOLBinding& b1, const HOLBinding& b2) + { +#if REORDERING + return Int::compare(b2.var,b1.var); +#else + return Int::compare(b1.var,b2.var); +#endif + } +}; + + +void HOLSubstitutionTree::higherOrderInsert(HOLBindingMap& svBindings,LeafData ld) +{ +#define DEBUG_INSERT(...) //DBG(__VA_ARGS__) + CALL("SubstitutionTree::splittableInsert"); + ASS_EQ(_iterCnt,0); + + auto pnode = &_root; + DEBUG_INSERT("insert: ", svBindings, " into ", *this) + + if(*pnode == 0) { + if (svBindings.isEmpty()) { + auto leaf = createLeaf(); + leaf->insert(std::move(ld)); + *pnode = leaf; + DEBUG_INSERT(0, "out: ", *this); + return; + } else { + // create root + *pnode=createIntermediateNode(svBindings.getOneKey()); + } + } + if(svBindings.isEmpty()) { + ASS((*pnode)->isLeaf()); + ensureLeafEfficiency(reinterpret_cast(pnode)); + static_cast(*pnode)->insert(ld); + DEBUG_INSERT("out: ", *this); + return; + } + + typedef BinaryHeap SplitRecordHeap; + static SplitRecordHeap unresolvedSplits; + unresolvedSplits.reset(); + + ASS((*pnode)); + ASS(!(*pnode)->isLeaf()); + +start: + +#if REORDERING + ASS(!(*pnode)->isLeaf() || !unresolvedSplits.isEmpty()); + bool canPostponeSplits=false; + if((*pnode)->isLeaf() || (*pnode)->algorithm()!=UNSORTED_LIST) { + canPostponeSplits=false; + } else { + UArrIntermediateNode* inode = static_cast(*pnode); + canPostponeSplits = inode->size()==1; + if(canPostponeSplits) { + unsigned boundVar=inode->childVar; + Node* child=inode->_nodes[0]; + bool removeProblematicNode=false; + if(svBindings.find(boundVar)) { + Subterm term=svBindings.get(boundVar); + + bool wouldDescendIntoChild = inode->childByTop(term.top(),false)!=0; + ASS_EQ(wouldDescendIntoChild, term.top() == child->top()); + if(!wouldDescendIntoChild) { + //if we'd have to perform all postponed splitting due to + //node with a single child, we rather remove that node + //from the tree and deal with the binding, it represented, + //later. + removeProblematicNode=true; + } + } else if(!child->term.isTerm() || child->term.term()->shared()) { + //We can remove nodes binding to special variables undefined in our branch + //of the tree, as long as we're sure, that during split resolving we put these + //binding nodes below nodes that define spec. variables they bind. + removeProblematicNode=true; + } else { + canPostponeSplits = false; + } + if(removeProblematicNode) { + unresolvedSplits.insert(HOLUnresolvedSplitRecord(inode->childVar, child->term, child->splittable())); + child->term=inode->term; + child->setSplittable(inode->splittable()); //TODO is this correct??? + *pnode=child; + inode->makeEmpty(); + delete inode; + goto start; + } + } + } + canPostponeSplits|=unresolvedSplits.isEmpty(); + if(!canPostponeSplits) { + + while(!unresolvedSplits.isEmpty()) { + HOLUnresolvedSplitRecord urr=unresolvedSplits.pop(); + + Node* node=*pnode; + IntermediateNode* newNode = createIntermediateNode(node->term, urr.var, node->splittable()); + + node->term=urr.original; + node->setSplittable(urr.splittable); + + *pnode=newNode; + + Node** nodePosition=newNode->childByTop(node->top(), true); + ASS(!*nodePosition); + *nodePosition=node; + } + } +#endif + ASS(!(*pnode)->isLeaf()); + + IntermediateNode* inode = static_cast(*pnode); + ASS(inode); + + unsigned boundVar=inode->childVar; + Subterm term=svBindings.get(boundVar); + svBindings.remove(boundVar); + + //Into pparent we store the node, we might be inserting into. + //So in the case we do insert, we might check whether this node + //needs expansion. + Node** pparent=pnode; + pnode=inode->childByTop(term.top(),true); + + if (*pnode == 0) { + HOLBindingMap::Iterator svit(svBindings); + BinaryHeap remainingBindings; + while (svit.hasNext()) { + unsigned var; + Subterm term; + svit.next(var, term); + remainingBindings.insert(HOLBinding(var, term)); + } + while (!remainingBindings.isEmpty()) { + HOLBinding b=remainingBindings.pop(); + IntermediateNode* inode = createIntermediateNode(term.term(), b.var, term.splittable()); + term=b.term; + + *pnode = inode; + pnode = inode->childByTop(term.top(),true); + } + Leaf* lnode=createLeaf(term.term(), term.splittable()); + *pnode=lnode; + lnode->insert(ld); + + ensureIntermediateNodeEfficiency(reinterpret_cast(pparent)); + DEBUG_INSERT("out: ", *this); + return; + } + + ASS(term.top() == (*pnode)->top()); + + TermList* tt = term.termPtr(); + TermList* ss = &(*pnode)->term; + + // ss is the term in node, tt is the term to be inserted + // ss and tt have the same top symbols but are not equal + // create the common subterm of ss,tt and an alternative node + Stack toProcess(64); + toProcess.push(SubtermPair(ss, (*pnode)->splittable(), tt, term.splittable())); + + while(!toProcess.isEmpty()) { + auto pair = toProcess.pop(); + + TermList* lhs = pair.lhs(); + TermList* rhs = pair.rhs(); + + // I am a bit concerned about doing + // an == check on possibly non-shared terms, + // but that is what existing code does + if(*lhs == *rhs){ + } else if(!lhs->isVar() && !rhs->isVar() && pair.lhsTop() == pair.rhsTop()){ + // we can have two vars which are not == but have the same top + // since the top() function does take into accoutn whether one variable is + // special. Might be worth changing this TODO + + // same top different content + ASS(!lhs->isVar() && !rhs->isVar()); + ASS(!lhs->isLambdaTerm() && !rhs->isLambdaTerm()); + ASS_EQ(lhs->term()->functor(), rhs->term()->functor()); + + if (lhs->isTerm() && lhs->term()->shared()) { + Term* s = lhs->term(); + // create a shallow copy of s + s = Term::cloneNonShared(s); + lhs->setTerm(s); + } + + Term* l = lhs->term(); + Term* r = rhs->term(); + + if(rhs->isApplication()){ + ASS(lhs->isApplication()); + toProcess.push(SubtermPair(l->nthArgument(0), true, r->nthArgument(0), true)); + toProcess.push(SubtermPair(l->nthArgument(1), true, r->nthArgument(1), true)); + toProcess.push(SubtermPair(l->nthArgument(2), true, r->nthArgument(2), true)); + toProcess.push(SubtermPair(l->nthArgument(3), _splittable(lhs->nthArg(3)), + r->nthArgument(3), _splittable(rhs->nthArg(3)))); + } else { + for (unsigned i = 0; i < l->arity(); i++) { + toProcess.push(SubtermPair(l->nthArgument(i), true, r->nthArgument(i), true)); + } + } + } else { + // different top + unsigned x; + if(!lhs->isSpecialVar()) { + x = _nextVar++; + #if REORDERING + unresolvedSplits.insert(HOLUnresolvedSplitRecord(x,*lhs, pair.lhsSplittable())); + lhs->makeSpecialVar(x); + #else + // TODO, this doesn't work with splitting currently + Node::split(pnode,lhs,x); + #endif + } else { + x=lhs->var(); + } + svBindings.set(x, Subterm(*rhs, pair.rhsSplittable())); + } + } + + if (svBindings.isEmpty()) { + ASS((*pnode)->isLeaf()); + ensureLeafEfficiency(reinterpret_cast(pnode)); + Leaf* leaf = static_cast(*pnode); + leaf->insert(ld); + DEBUG_INSERT("out: ", *this); + return; + } + + goto start; +} + +/* + * Remove an entry from the substitution tree. + * + * @b pnode is pointer to root of tree corresponding to + * top symbol of the term/literal being removed, and + * @b bh contains its arguments. + * + * If the removal results in a chain of nodes containing + * no terms/literals, all those nodes are removed as well. + */ +void HOLSubstitutionTree::higherOrderRemove(HOLBindingMap& svBindings, LeafData ld) +{ + CALL("SubstitutionTree::remove"); +#define DEBUG_REMOVE(...) //DBG(__VA_ARGS__) + ASS_EQ(_iterCnt,0); + auto pnode = &_root; + + ASS(*pnode); + + DEBUG_REMOVE("remove: ", svBindings, " from ", *this) + + static Stack history(1000); + history.reset(); + + while (! (*pnode)->isLeaf()) { + history.push(pnode); + + IntermediateNode* inode=static_cast(*pnode); + + unsigned boundVar=inode->childVar; + Subterm t = svBindings.get(boundVar); + + pnode=inode->childByTop(t.top(),false); + ASS(pnode); + + + TermList s = (*pnode)->term; + ASS((*pnode)->top() == t.top()); + + if(s==t.term()) { + continue; + } + + // computing the disagreement set of the two terms + Stack> subterms(120); + + subterms.push(std::make_pair(s, t)); + while (! subterms.isEmpty()) { + auto pair = subterms.pop(); + + auto treeTerm = pair.first; + auto remvTerm = pair.second; + + if (treeTerm==remvTerm.term()) { + continue; + } + if (treeTerm.isVar()) { + ASS(treeTerm.isSpecialVar()); + svBindings.set(treeTerm.var(),remvTerm); + continue; + } + ASS(!treeTerm.isVar()); + + Term* l = treeTerm.term(); + Term* r = remvTerm.term().term(); + + if(l->isApplication()){ + ASS(r->isApplication()); + subterms.push(std::make_pair((*l)[0], Subterm((*r)[0], true))); + subterms.push(std::make_pair((*l)[1], Subterm((*r)[1], true))); + subterms.push(std::make_pair((*l)[2], Subterm((*r)[2], true))); + subterms.push(std::make_pair((*l)[3], Subterm((*r)[3], _splittable((*r)[3])))); + } else { + ASS(l->arity() == r->arity()); + for (unsigned i = 0; i < l->arity(); i++) { + subterms.push(std::make_pair((*l)[i], Subterm((*r)[i], true))); + } + } + } + } + + ASS ((*pnode)->isLeaf()); + + + Leaf* lnode = static_cast(*pnode); + lnode->remove(ld); + ensureLeafEfficiency(reinterpret_cast(pnode)); + + while( (*pnode)->isEmpty() ) { + if(history.isEmpty()) { + delete *pnode; + *pnode=0; + DEBUG_REMOVE("out: ", *this); + return; + } else { + Node* node=*pnode; + IntermediateNode* parent=static_cast(*history.top()); + parent->remove((*pnode)->top()); + delete node; + pnode=history.pop(); + ensureIntermediateNodeEfficiency(reinterpret_cast(pnode)); + } + } + DEBUG_REMOVE("out: ", *this); +} // SubstitutionTree::remove + +} // namespace Indexing + +#endif diff --git a/Indexing/HOLSubstitutionTree.hpp b/Indexing/HOLSubstitutionTree.hpp new file mode 100644 index 0000000000..eecff526b4 --- /dev/null +++ b/Indexing/HOLSubstitutionTree.hpp @@ -0,0 +1,153 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file TermSubstitutionTree.hpp + * Defines class TermSubstitutionTree. + */ + + +#ifndef __HOLSubstitutionTree__ +#define __HOLSubstitutionTree__ + +#if VHOL + + +#include "Forwards.hpp" +#include "SubstitutionTree.hpp" + +#include "Kernel/Renaming.hpp" +#include "Kernel/ApplicativeHelper.hpp" + +namespace Indexing { + +/** A variant of substitution tree that supports non-splitting nodes */ +class HOLSubstitutionTree +: public SubstitutionTree +{ + using SplittableType = std::function; + +public: + CLASS_NAME(HOLSubstitutionTree); + USE_ALLOCATOR(HOLSubstitutionTree); + + HOLSubstitutionTree(SplittableType f) : SubstitutionTree(), _splittable(f) {} + + class Subterm { + TermList _subterm; + bool _splittable; + public: + Subterm(TermList t, bool splittable) + : _subterm(t), _splittable(splittable) {} + + // dummy constructor needed for use in DHMap + Subterm(){} + + bool splittable() const { return _splittable; } + + TermList::Top top(){ + return _subterm.top(_splittable); + } + + TermList term() const { return _subterm; } + TermList* termPtr() { return &_subterm; } + + friend std::ostream& operator<<(std::ostream& out, Subterm const& self); + }; + + +private: + class SubtermPair + { + TermList* _t1; + TermList* _t2; + bool _t1Splittable; + bool _t2Splittable; + public: + SubtermPair(TermList* t1, bool t1s, TermList* t2, bool t2s) + : _t1(t1), _t2(t2), _t1Splittable(t1s), _t2Splittable(t2s) {} + + TermList* lhs() { return _t1; } + TermList* rhs() { return _t2; } + + bool lhsSplittable() { return _t1Splittable; } + bool rhsSplittable() { return _t2Splittable; } + + TermList::Top lhsTop() { return _t1->top(_t1Splittable); } + TermList::Top rhsTop() { return _t2->top(_t2Splittable); } + }; + + typedef DHMap HOLBindingMap; + typedef ApplicativeHelper AH; + + SplittableType _splittable; + +public: + + + void handle(TypedTermList const& key, LeafData ld, bool doInsert) override + { handleImplHol(key, ld, doInsert); } + + void handle(Literal* const& key, LeafData ld, bool doInsert) override + { handleImplHol(key, ld, doInsert); } + + template + void handleImplHol (Key const& key, LeafData ld, bool doInsert) + { + auto norm = Renaming::normalize(key,VarBank::NORM_RESULT_BANK); + Recycled bindings; + setSort(key, ld); + createHOLBindings(norm, /* reversed */ false, + [&](auto var, auto term) { + bindings->insert(var, term); + _nextVar = max(_nextVar, (int)var + 1); + }); + if (doInsert) higherOrderInsert(*bindings, ld); + else higherOrderRemove(*bindings, ld); + } + + void higherOrderInsert(HOLBindingMap& binding,LeafData ld); + void higherOrderRemove(HOLBindingMap& binding,LeafData ld); + + // TODO document + template + void createHOLBindings(TypedTermList term, bool reversed, BindingFunction bindSpecialVar) + { + bindSpecialVar(0, Subterm(term, _splittable(term))); + bindSpecialVar(1, Subterm(term.sort(),true)); + } + + template + void createHOLBindings(Literal* lit, bool reversed, BindingFunction bindSpecialVar) + { + // equality is the only predicate + ASS(lit->isEquality()); + + TermList l0 = *lit->nthArgument(0); + TermList l1 = *lit->nthArgument(1); + + if (reversed) { + bindSpecialVar(1,Subterm(l0, _splittable(l0)) ); + bindSpecialVar(0,Subterm(l1, _splittable(l1)) ); + } else { + bindSpecialVar(0,Subterm(l0, _splittable(l0)) ); + bindSpecialVar(1,Subterm(l1, _splittable(l1)) ); + } + + auto sort = SortHelper::getEqualityArgumentSort(lit); + bindSpecialVar(2, Subterm(sort, true)); + } + +}; + +}; + +#endif + +#endif /* __TermSubstitutionTree__ */ diff --git a/Indexing/Index.hpp b/Indexing/Index.hpp index d991dbabec..4a38695f90 100644 --- a/Indexing/Index.hpp +++ b/Indexing/Index.hpp @@ -23,12 +23,12 @@ #include "Lib/VirtualIterator.hpp" #include "Saturation/ClauseContainer.hpp" #include "ResultSubstitution.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Lib/Allocator.hpp" namespace Indexing { - using namespace Kernel; using namespace Lib; using namespace Saturation; @@ -37,66 +37,61 @@ using namespace Saturation; /** * Class of objects which contain results of single literal queries. */ -struct SLQueryResult +template +struct LQueryRes { - SLQueryResult() {} - SLQueryResult(Literal* l, Clause* c, ResultSubstitutionSP s) - : literal(l), clause(c), substitution(s) {} - SLQueryResult(Literal* l, Clause* c) - : literal(l), clause(c) {} - SLQueryResult(Literal* l, Clause* c, ResultSubstitutionSP s,UnificationConstraintStackSP con) - : literal(l), clause(c), substitution(s), constraints(con) {} + LQueryRes() {} + LQueryRes(Literal* l, Clause* c, Unifier unifier) + : literal(l), clause(c), unifier(std::move(unifier)) {} Literal* literal; Clause* clause; - ResultSubstitutionSP substitution; - UnificationConstraintStackSP constraints; + Unifier unifier; struct ClauseExtractFn { - Clause* operator()(const SLQueryResult& res) + Clause* operator()(const LQueryRes& res) { return res.clause; } }; }; +template +LQueryRes lQueryRes(Literal* l, Clause* c, Unifier unifier) +{ return LQueryRes(l,c,std::move(unifier)); } /** * Class of objects which contain results of term queries. */ -struct TermQueryResult +template +struct TQueryRes { - TermQueryResult() : literal(nullptr), clause(nullptr) {} - TermQueryResult(TermList t, Literal* l, Clause* c, ResultSubstitutionSP s) - : term(t), literal(l), clause(c), substitution(s) {} - TermQueryResult(TermList t, Literal* l, Clause* c, ResultSubstitutionSP s, bool b) - : term(t), literal(l), clause(c), substitution(s) {} - TermQueryResult(TermList t, Literal* l, Clause* c) - : term(t), literal(l), clause(c) {} - TermQueryResult(TermList t, Literal* l, Clause* c, ResultSubstitutionSP s,UnificationConstraintStackSP con) - : term(t), literal(l), clause(c), substitution(s), constraints(con) {} - TermQueryResult(TermList t, Literal* l, Clause* c, ResultSubstitutionSP s,UnificationConstraintStackSP con, bool b) - : term(t), literal(l), clause(c), substitution(s), constraints(con) {} + TQueryRes() {} + TQueryRes(TermList t, Literal* l, Clause* c, Unifier unifier) + : term(t), literal(l), clause(c), unifier(std::move(unifier)) {} TermList term; Literal* literal; Clause* clause; - ResultSubstitutionSP substitution; - UnificationConstraintStackSP constraints; - friend std::ostream& operator<<(std::ostream& out, TermQueryResult const& self) + + Unifier unifier; + + friend std::ostream& operator<<(std::ostream& out, TQueryRes const& self) { return out << "{ term: " << self.term << ", literal: " << outputPtr(self.literal) << ", clause: " << outputPtr(self.literal) - << ", substitution: " << self.substitution - << ", constraints: " << self.constraints + << ", unifier: " << self.unifier << "}"; } - }; +template +TQueryRes tQueryRes(TermList t, Literal* l, Clause* c, Unifier unifier) +{ return TQueryRes(t,l,c,std::move(unifier)); } + struct ClauseSResQueryResult { ClauseSResQueryResult() {} @@ -121,8 +116,11 @@ struct FormulaQueryResult ResultSubstitutionSP substitution; }; -typedef VirtualIterator SLQueryResultIterator; -typedef VirtualIterator TermQueryResultIterator; +using TermQueryResult = TQueryRes; +using SLQueryResult = LQueryRes; + +using TermQueryResultIterator = VirtualIterator; +using SLQueryResultIterator = VirtualIterator; typedef VirtualIterator ClauseSResResultIterator; typedef VirtualIterator FormulaQueryResultIterator; diff --git a/Indexing/IndexManager.cpp b/Indexing/IndexManager.cpp index e2f5a416e4..de4a04b438 100644 --- a/Indexing/IndexManager.cpp +++ b/Indexing/IndexManager.cpp @@ -26,6 +26,8 @@ #include "TermIndex.hpp" #include "TermSubstitutionTree.hpp" +#include "Kernel/TermIterators.hpp" + #include "Shell/Statistics.hpp" #include "IndexManager.hpp" @@ -33,6 +35,13 @@ using namespace Lib; using namespace Indexing; + +IndexManager::IndexManager(SaturationAlgorithm* alg) + : _alg(alg) + , _uwa(MismatchHandler::create()) + , _uwaFixedPointIteration(env.options->unificationWithAbstractionFixedPointIteration()) +{ } + Index* IndexManager::request(IndexType t) { CALL("IndexManager::request"); @@ -101,135 +110,148 @@ Index* IndexManager::create(IndexType t) CALL("IndexManager::create"); Index* res; - LiteralIndexingStructure* is; - TermIndexingStructure* tis; bool isGenerating; - static bool const useConstraints = env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF; - static bool const extByAbs = (env.options->functionExtensionality() == Options::FunctionExtensionality::ABSTRACTION) && - env.property->higherOrder(); - + switch(t) { case BINARY_RESOLUTION_SUBST_TREE: - is=new LiteralSubstitutionTree(useConstraints); - res=new BinaryResolutionIndex(is); + res = new BinaryResolutionIndex(new LiteralSubstitutionTree()); isGenerating = true; break; - case BACKWARD_SUBSUMPTION_SUBST_TREE: - is=new LiteralSubstitutionTree(); - res=new BackwardSubsumptionIndex(is); + case BACKWARD_SUBSUMPTION_SUBST_TREE: { + auto lst = +#if VHOL + env.property->higherOrder() ? + new LiteralSubstitutionTree(SplittingAlgo::HOL_MATCH) : +#endif + new LiteralSubstitutionTree(); + res = new BackwardSubsumptionIndex(lst); isGenerating = false; break; - case FW_SUBSUMPTION_UNIT_CLAUSE_SUBST_TREE: - is=new LiteralSubstitutionTree(); - res=new UnitClauseLiteralIndex(is); + } + case FW_SUBSUMPTION_UNIT_CLAUSE_SUBST_TREE: { + auto lst = +#if VHOL + env.property->higherOrder() ? + new LiteralSubstitutionTree(SplittingAlgo::HOL_MATCH) : +#endif + new LiteralSubstitutionTree(); + res = new UnitClauseLiteralIndex(lst); isGenerating = false; break; + } case URR_UNIT_CLAUSE_SUBST_TREE: - is=new LiteralSubstitutionTree(); - res=new UnitClauseLiteralIndex(is); + res = new UnitClauseLiteralIndex(new LiteralSubstitutionTree()); isGenerating = true; break; case URR_NON_UNIT_CLAUSE_SUBST_TREE: - is=new LiteralSubstitutionTree(); - res=new NonUnitClauseLiteralIndex(is); + res =new NonUnitClauseLiteralIndex(new LiteralSubstitutionTree()); isGenerating = true; break; - case SUPERPOSITION_SUBTERM_SUBST_TREE: - tis=new TermSubstitutionTree(useConstraints, extByAbs); - res=new SuperpositionSubtermIndex(tis, _alg->getOrdering()); - isGenerating = true; - break; - case SUPERPOSITION_LHS_SUBST_TREE: - res=new SuperpositionLHSIndex(new TermSubstitutionTree(useConstraints, extByAbs), _alg->getOrdering(), _alg->getOptions()); + case SUPERPOSITION_SUBTERM_SUBST_TREE:{ + auto tst = +#if VHOL + env.property->higherOrder() ? + new TermSubstitutionTree(SplittingAlgo::HOL_UNIF) : +#endif + new TermSubstitutionTree(); + res = new SuperpositionSubtermIndex(tst, _alg->getOrdering()); isGenerating = true; break; - - case SUB_VAR_SUP_SUBTERM_SUBST_TREE: - //using a substitution tree to store variable. - //TODO update - tis=new TermSubstitutionTree(); - res=new SubVarSupSubtermIndex(tis, _alg->getOrdering()); - isGenerating = true; - break; - case SUB_VAR_SUP_LHS_SUBST_TREE: - tis=new TermSubstitutionTree(); - res=new SubVarSupLHSIndex(tis, _alg->getOrdering(), _alg->getOptions()); + } + case SUPERPOSITION_LHS_SUBST_TREE: { + auto tst = +#if VHOL + env.property->higherOrder() ? + new TermSubstitutionTree(SplittingAlgo::HOL_UNIF) : +#endif + new TermSubstitutionTree(); + res = new SuperpositionLHSIndex(tst, _alg->getOrdering(), _alg->getOptions()); isGenerating = true; break; - - case SKOLEMISING_FORMULA_INDEX: - tis=new TermSubstitutionTree(false, false, true); - res=new SkolemisingFormulaIndex(tis); + } +#if VHOL + case SKOLEMISING_FORMULA_INDEX: { + auto tis = new TermSubstitutionTree(SplittingAlgo::HOL_MATCH); + tis->useExtra(); + res = new SkolemisingFormulaIndex(tis); isGenerating = false; break; + } +#endif - /*case RENAMING_FORMULA_INDEX: - tis=new TermSubstitutionTree(false, false, true); - res=new RenamingFormulaIndex(tis); - attachPassive = true; - break;*/ - - case NARROWING_INDEX: - tis=new TermSubstitutionTree(); - res=new NarrowingIndex(tis); - isGenerating = true; - break; - - case PRIMITIVE_INSTANTIATION_INDEX: - tis=new TermSubstitutionTree(); - res=new PrimitiveInstantiationIndex(tis); + case ACYCLICITY_INDEX: + res = new AcyclicityIndex(new TermSubstitutionTree()); isGenerating = true; - break; - case ACYCLICITY_INDEX: - tis = new TermSubstitutionTree(); - res = new AcyclicityIndex(tis); - isGenerating = true; - break; - - case DEMODULATION_SUBTERM_SUBST_TREE: - tis=new TermSubstitutionTree(); - if (env.options->combinatorySup()) { - res=new DemodulationSubtermIndexImpl(tis); + break; + + case DEMODULATION_SUBTERM_SUBST_TREE: { + auto tis= +#if VHOL + env.property->higherOrder() ? + new TermSubstitutionTree(SplittingAlgo::HOL_MATCH) : +#endif + new TermSubstitutionTree(); +#if VHOL + if (env.property->higherOrder()) { + res=new DemodulationSubtermIndex(tis); } else { - res=new DemodulationSubtermIndexImpl(tis); +#endif + res=new DemodulationSubtermIndex(tis); +#if VHOL } +#endif isGenerating = false; break; + } + case DEMODULATION_LHS_CODE_TREE: - tis=new CodeTreeTIS(); - res=new DemodulationLHSIndex(tis, _alg->getOrdering(), _alg->getOptions()); + res = new DemodulationLHSIndex(new CodeTreeTIS(), _alg->getOrdering(), _alg->getOptions()); isGenerating = false; break; case DEMODULATION_LHS_SUBST_TREE: - tis=new TermSubstitutionTree(); - res=new DemodulationLHSIndex(tis, _alg->getOrdering(), _alg->getOptions()); - isGenerating = false; - break; - - case FW_SUBSUMPTION_CODE_TREE: - res=new CodeTreeSubsumptionIndex(); + res = +#if VHOL + env.property->higherOrder() ? + new DemodulationLHSIndex(new TermSubstitutionTree(SplittingAlgo::HOL_MATCH), _alg->getOrdering(), _alg->getOptions()) : +#endif + new DemodulationLHSIndex(new TermSubstitutionTree(), _alg->getOrdering(), _alg->getOptions()); isGenerating = false; break; - case FW_SUBSUMPTION_SUBST_TREE: - is=new LiteralSubstitutionTree(); -// is=new CodeTreeLIS(); - res=new FwSubsSimplifyingLiteralIndex(is); + case FW_SUBSUMPTION_SUBST_TREE: { + auto lst = +#if VHOL + env.property->higherOrder() ? + new LiteralSubstitutionTree(SplittingAlgo::HOL_MATCH) : +#endif + new LiteralSubstitutionTree(); + res = new FwSubsSimplifyingLiteralIndex(lst); isGenerating = false; break; + } - case FSD_SUBST_TREE: - is = new LiteralSubstitutionTree(); - res = new FSDLiteralIndex(is); + case FSD_SUBST_TREE: { + auto lst = +#if VHOL + env.property->higherOrder() ? + new LiteralSubstitutionTree(SplittingAlgo::HOL_MATCH) : +#endif + new LiteralSubstitutionTree(); + res = new FSDLiteralIndex(lst); isGenerating = false; break; + } case REWRITE_RULE_SUBST_TREE: - is=new LiteralSubstitutionTree(); - res=new RewriteRuleIndex(is, _alg->getOrdering()); + res = +#if VHOL + env.property->higherOrder() ? + new RewriteRuleIndex(new LiteralSubstitutionTree(SplittingAlgo::HOL_MATCH), _alg->getOrdering()) : +#endif + new RewriteRuleIndex(new LiteralSubstitutionTree(), _alg->getOrdering()); isGenerating = false; break; @@ -239,20 +261,17 @@ Index* IndexManager::create(IndexType t) break; case UNIT_INT_COMPARISON_INDEX: - is = new LiteralSubstitutionTree(); - res = new UnitIntegerComparisonLiteralIndex(is); + res = new UnitIntegerComparisonLiteralIndex(new LiteralSubstitutionTree()); isGenerating = true; break; case INDUCTION_TERM_INDEX: - tis = new TermSubstitutionTree(); - res = new InductionTermIndex(tis); + res = new InductionTermIndex(new TermSubstitutionTree()); isGenerating = true; break; case STRUCT_INDUCTION_TERM_INDEX: - tis = new TermSubstitutionTree(); - res = new StructInductionTermIndex(tis); + res = new StructInductionTermIndex(new TermSubstitutionTree()); isGenerating = true; break; diff --git a/Indexing/IndexManager.hpp b/Indexing/IndexManager.hpp index b79063b314..1ef9202910 100644 --- a/Indexing/IndexManager.hpp +++ b/Indexing/IndexManager.hpp @@ -19,8 +19,10 @@ #include "Forwards.hpp" #include "Lib/DHMap.hpp" #include "Index.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Lib/Allocator.hpp" +#include "Kernel/MismatchHandler.hpp" namespace Indexing @@ -39,14 +41,11 @@ enum IndexType { SUPERPOSITION_SUBTERM_SUBST_TREE, SUPERPOSITION_LHS_SUBST_TREE, - SUB_VAR_SUP_SUBTERM_SUBST_TREE, - SUB_VAR_SUP_LHS_SUBST_TREE, DEMODULATION_SUBTERM_SUBST_TREE, DEMODULATION_LHS_CODE_TREE, DEMODULATION_LHS_SUBST_TREE, - FW_SUBSUMPTION_CODE_TREE, FW_SUBSUMPTION_SUBST_TREE, BW_SUBSUMPTION_SUBST_TREE, @@ -57,10 +56,10 @@ enum IndexType { GLOBAL_SUBSUMPTION_INDEX, ACYCLICITY_INDEX, - NARROWING_INDEX, - PRIMITIVE_INSTANTIATION_INDEX, + +#if VHOL SKOLEMISING_FORMULA_INDEX, - RENAMING_FORMULA_INDEX, +#endif UNIT_INT_COMPARISON_INDEX, INDUCTION_TERM_INDEX, @@ -74,7 +73,8 @@ class IndexManager USE_ALLOCATOR(IndexManager); /** alg can be zero, then it must be set by setSaturationAlgorithm */ - explicit IndexManager(SaturationAlgorithm* alg) : _alg(alg) {} + explicit IndexManager(SaturationAlgorithm* alg); + void setSaturationAlgorithm(SaturationAlgorithm* alg) { CALL("IndexManager::setSaturationAlgorithm"); @@ -98,6 +98,8 @@ class IndexManager DHMap _store; Index* create(IndexType t); + Shell::Options::UnificationWithAbstraction _uwa; + bool _uwaFixedPointIteration; }; }; diff --git a/Indexing/LiteralIndex.cpp b/Indexing/LiteralIndex.cpp index 264841e98d..6059f8168f 100644 --- a/Indexing/LiteralIndex.cpp +++ b/Indexing/LiteralIndex.cpp @@ -25,6 +25,7 @@ #include "LiteralSubstitutionTree.hpp" #include "LiteralIndex.hpp" +#include "IndexManager.hpp" namespace Indexing { @@ -41,18 +42,6 @@ SLQueryResultIterator LiteralIndex::getAll() return _is->getAll(); } -SLQueryResultIterator LiteralIndex::getUnifications(Literal* lit, - bool complementary, bool retrieveSubstitutions) -{ - return _is->getUnifications(lit, complementary, retrieveSubstitutions); -} - -SLQueryResultIterator LiteralIndex::getUnificationsWithConstraints(Literal* lit, - bool complementary, bool retrieveSubstitutions) -{ - return _is->getUnificationsWithConstraints(lit, complementary, retrieveSubstitutions); -} - SLQueryResultIterator LiteralIndex::getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) { @@ -189,7 +178,7 @@ void NonUnitClauseLiteralIndex::handleClause(Clause* c, bool adding) RewriteRuleIndex::RewriteRuleIndex(LiteralIndexingStructure* is, Ordering& ordering) : LiteralIndex(is), _ordering(ordering) { - _partialIndex=new LiteralSubstitutionTree(); + _partialIndex = new LiteralSubstitutionTree(); } RewriteRuleIndex::~RewriteRuleIndex() diff --git a/Indexing/LiteralIndex.hpp b/Indexing/LiteralIndex.hpp index cd5750a0f3..96ab090436 100644 --- a/Indexing/LiteralIndex.hpp +++ b/Indexing/LiteralIndex.hpp @@ -19,6 +19,7 @@ #include "Lib/DHMap.hpp" #include "Index.hpp" +#include "LiteralIndexingStructure.hpp" namespace Indexing { @@ -34,11 +35,11 @@ class LiteralIndex SLQueryResultIterator getAll(); - SLQueryResultIterator getUnifications(Literal* lit, - bool complementary, bool retrieveSubstitutions = true); + SLQueryResultIterator getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions = true) + { return _is->getUnifications(lit, complementary, retrieveSubstitutions); } - SLQueryResultIterator getUnificationsWithConstraints(Literal* lit, - bool complementary, bool retrieveSubstitutions = true); + SLQueryResultIterator getUwa(Literal* lit, bool complementary) + { return _is->getUwa(lit, complementary); } SLQueryResultIterator getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions = true); @@ -46,6 +47,18 @@ class LiteralIndex SLQueryResultIterator getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions = true); +#if VHOL + + SLQueryResultIterator getHOLInstances(Literal* lit, + bool complementary, bool retrieveSubstitutions = true) + { return _is->getHOLInstances(lit, complementary, retrieveSubstitutions); } + + SLQueryResultIterator getHOLGeneralizations(Literal* lit, + bool complementary, bool retrieveSubstitutions = true) + { return _is->getHOLGeneralizations(lit, complementary, retrieveSubstitutions); } + +#endif + size_t getUnificationCount(Literal* lit, bool complementary); diff --git a/Indexing/LiteralIndexingStructure.hpp b/Indexing/LiteralIndexingStructure.hpp index 7124a6a9ca..183add9374 100644 --- a/Indexing/LiteralIndexingStructure.hpp +++ b/Indexing/LiteralIndexingStructure.hpp @@ -18,6 +18,9 @@ #include "Forwards.hpp" #include "Index.hpp" +#include "Kernel/MismatchHandler.hpp" +#include "Lib/VirtualIterator.hpp" +#include "Shell/Options.hpp" namespace Indexing { @@ -29,16 +32,26 @@ class LiteralIndexingStructure { virtual void remove(Literal* lit, Clause* cls) = 0; virtual SLQueryResultIterator getAll() { NOT_IMPLEMENTED; } - virtual SLQueryResultIterator getUnifications(Literal* lit, - bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual SLQueryResultIterator getUnificationsWithConstraints(Literal* lit, - bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual SLQueryResultIterator getGeneralizations(Literal* lit, - bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual SLQueryResultIterator getInstances(Literal* lit, - bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual SLQueryResultIterator getVariants(Literal* lit, - bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + + virtual SLQueryResultIterator getUnifications(Literal* lit, + bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual SLQueryResultIterator getUwa(Literal* lit, + bool complementary) = 0; + virtual SLQueryResultIterator getGeneralizations(Literal* lit, bool complementary, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual SLQueryResultIterator getInstances(Literal* lit, bool complementary, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual SLQueryResultIterator getVariants(Literal* lit, bool complementary, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + +#if VHOL + virtual SLQueryResultIterator getHOLGeneralizations(Literal* lit, + bool complementary, bool retrieveSubstitutions = true) + { NOT_IMPLEMENTED; } + virtual SLQueryResultIterator getHOLInstances(Literal* lit, + bool complementary, bool retrieveSubstitutions = true) + { NOT_IMPLEMENTED; } +#endif virtual size_t getUnificationCount(Literal* lit, bool complementary) { diff --git a/Indexing/LiteralSubstitutionTree.cpp b/Indexing/LiteralSubstitutionTree.cpp index c7081641f4..f21ff41089 100644 --- a/Indexing/LiteralSubstitutionTree.cpp +++ b/Indexing/LiteralSubstitutionTree.cpp @@ -12,6 +12,10 @@ * Implements class LiteralSubstitutionTree. */ +#include "Forwards.hpp" +#include "Indexing/SubstitutionTree.hpp" +#include "Indexing/HOLSubstitutionTree.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Lib/Environment.hpp" #include "Lib/Metaiterators.hpp" @@ -20,6 +24,7 @@ #include "Kernel/SortHelper.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" +#include "Kernel/ApplicativeHelper.hpp" #include "Shell/Statistics.hpp" @@ -28,71 +33,73 @@ namespace Indexing { -LiteralSubstitutionTree::LiteralSubstitutionTree(bool useC) -: _trees(env.signature->predicates() * 2) -, _useC(useC) +LiteralSubstitutionTree::LiteralSubstitutionTree(SplittingAlgo algo) +: _algo(algo), _trees(env.signature->predicates() * 2) { } SLQueryResultIterator LiteralSubstitutionTree::getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions) -{ return getResultIterator(lit, complementary, retrieveSubstitutions, /* constraints */ false); } - -SLQueryResultIterator LiteralSubstitutionTree::getUnificationsWithConstraints(Literal* lit, bool complementary, bool retrieveSubstitutions) -{ return getResultIterator(lit, complementary, retrieveSubstitutions, /* constraints */ true); } +{ return getResultIterator>(lit, complementary, retrieveSubstitutions); } SLQueryResultIterator LiteralSubstitutionTree::getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) -{ return getResultIterator(lit, complementary, retrieveSubstitutions, /* constraints */ false); } +{ return getResultIterator(lit, complementary, retrieveSubstitutions); } SLQueryResultIterator LiteralSubstitutionTree::getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) -{ return getResultIterator(lit, complementary, retrieveSubstitutions, /* constraints */ false); } +{ return getResultIterator(lit, complementary, retrieveSubstitutions); } + +#if VHOL + SLQueryResultIterator LiteralSubstitutionTree::getHOLInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) + { return getResultIterator>(lit, complementary, retrieveSubstitutions); } + SLQueryResultIterator LiteralSubstitutionTree::getHOLGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) + { return getResultIterator>(lit, complementary, retrieveSubstitutions); } +#endif SLQueryResultIterator LiteralSubstitutionTree::getVariants(Literal* query, bool complementary, bool retrieveSubstitutions) { - return pvi(iterTraits(getTree(query, complementary).getVariants(query, retrieveSubstitutions)) - .map([](QueryResult qr) { return SLQueryResult(qr.data->literal, qr.data->clause, qr.subst, qr.constr); })); + CALL("LiteralSubstitutionTree::getVariants"); + + return pvi(iterTraits(getTree(query, complementary)->getVariants(query, retrieveSubstitutions)) + .map([](auto qr) { return SLQueryResult(qr.data->literal, qr.data->clause, qr.unif); })); } +// TODO no substitution in this resultIterator SLQueryResultIterator LiteralSubstitutionTree::getAll() { CALL("LiteralSubstitutionTree::getAll"); return pvi( iterTraits(getRangeIterator((unsigned long)0, _trees.size())) - .flatMap([this](auto i) { return LeafIterator(&_trees[i]); }) + .flatMap([this](auto i) { return LeafIterator(_trees[i]); }) .flatMap([](Leaf* l) { return l->allChildren(); }) - .map([](const LeafData& ld) { return SLQueryResult(ld.literal, ld.clause); }) + .map([](auto ld) { return SLQueryResult(ld->literal, ld->clause, ResultSubstitutionSP()); }) ); } -SubstitutionTree& LiteralSubstitutionTree::getTree(Literal* lit, bool complementary) +SubstitutionTree* LiteralSubstitutionTree::getTree(Literal* lit, bool complementary) { auto idx = complementary ? lit->header() : lit->complementaryHeader(); while (idx >= _trees.size()) { - _trees.push(SubstitutionTree(_useC, /* rfSubs */ false)); + switch(_algo){ + case SplittingAlgo::NONE: + _trees.push(new SubstitutionTree()); + break; + #if VHOL + case SplittingAlgo::HOL_UNIF: + ASSERTION_VIOLATION; // currently we don't expect any literal index to use higher-order unif + break; + case SplittingAlgo::HOL_MATCH: + _trees.push(new HOLSubstitutionTree([](TermList t){ + return !t.isLambdaTerm(); + } )); + break; + #endif + } } return _trees[idx]; } -template -SLQueryResultIterator LiteralSubstitutionTree::getResultIterator(Literal* lit, bool complementary, bool retrieveSubstitutions, bool useConstraints) -{ - CALL("LiteralSubstitutionTree::getResultIterator"); - - auto iter = [&](bool reversed) - { return iterTraits(getTree(lit, complementary).iterator(lit, retrieveSubstitutions, useConstraints, reversed)) ; }; - - auto filterResults = [=](auto it) { - return pvi( - std::move(it) - .map([](QueryResult qr) { return SLQueryResult(qr.data->literal, qr.data->clause, qr.subst, qr.constr); }) - ); - }; - return !lit->commutative() - ? filterResults(iter( /* reversed */ false)) - : filterResults(concatIters( - iter( /* reversed */ false), - iter( /* reversed */ true) - )); -} +// template +// SLQueryResultIterator LiteralSubstitutionTree::getResultIterator(Literal* lit, bool complementary, bool retrieveSubstitutions, Args... args) + } // namespace Indexing diff --git a/Indexing/LiteralSubstitutionTree.hpp b/Indexing/LiteralSubstitutionTree.hpp index 2c8382b4bb..31966379fd 100644 --- a/Indexing/LiteralSubstitutionTree.hpp +++ b/Indexing/LiteralSubstitutionTree.hpp @@ -16,8 +16,12 @@ #ifndef __LiteralSubstitutionTree__ #define __LiteralSubstitutionTree__ +#include "Indexing/Index.hpp" +#include "Kernel/MismatchHandler.hpp" +#include "Lib/VirtualIterator.hpp" #include "LiteralIndexingStructure.hpp" #include "SubstitutionTree.hpp" +#include "Kernel/HOLUnification.hpp" namespace Indexing { @@ -25,53 +29,129 @@ namespace Indexing { class LiteralSubstitutionTree : public LiteralIndexingStructure { - using UnificationsIterator = SubstitutionTree::UnificationsIterator; using FastInstancesIterator = SubstitutionTree::FastInstancesIterator; using BindingMap = SubstitutionTree::BindingMap; using LDIterator = SubstitutionTree::LDIterator; using FastGeneralizationsIterator = SubstitutionTree::FastGeneralizationsIterator; - using QueryResult = SubstitutionTree::QueryResult; using LeafData = SubstitutionTree::LeafData; using LeafIterator = SubstitutionTree::LeafIterator; using Leaf = SubstitutionTree::Leaf; + using AbstractingAlgo = UnificationAlgorithms::AbstractingUnification; + using RobAlgo = UnificationAlgorithms::RobUnification; +#if VHOL + using HOLInstAlgo = UnificationAlgorithms::HOLInstantiation; + using HOLGenAlgo = UnificationAlgorithms::HOLGeneralisation; +#endif public: CLASS_NAME(LiteralSubstitutionTree); USE_ALLOCATOR(LiteralSubstitutionTree); - LiteralSubstitutionTree(bool useC=false); + LiteralSubstitutionTree(SplittingAlgo algo = SplittingAlgo::NONE); void insert(Literal* lit, Clause* cls) override { handleLiteral(lit, cls, /* insert */ true); } void remove(Literal* lit, Clause* cls) override { handleLiteral(lit, cls, /* insert */ false); } + SLQueryResultIterator getAll() final override; void handleLiteral(Literal* lit, Clause* cls, bool insert) - { getTree(lit, /* complementary */ false).handle(lit, SubstitutionTree::LeafData(cls, lit), insert); } + { getTree(lit, /* complementary */ false)->handle(lit, SubstitutionTree::LeafData(cls, lit), insert); } - SLQueryResultIterator getAll() override; + SLQueryResultIterator getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; + //TODO add getHOL required for subsumption - SLQueryResultIterator getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions) override; +#if VHOL + SLQueryResultIterator getHOLInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; + SLQueryResultIterator getHOLGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; +#endif - SLQueryResultIterator getUnificationsWithConstraints(Literal* lit, bool complementary, bool retrieveSubstitutions) override; + SLQueryResultIterator getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; + SLQueryResultIterator getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; + SLQueryResultIterator getVariants(Literal* lit, bool complementary, bool retrieveSubstitutions) final override; - SLQueryResultIterator getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) override; +#if VDEBUG + virtual void markTagged() final override { } +#endif - SLQueryResultIterator getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) override; +private: + static unsigned idxToFunctor(unsigned idx) { return idx / 2; } + static bool idxIsNegative(unsigned idx) { return idx % 2; } + static unsigned toIdx(unsigned f, bool isNegative) { return f * 2 + isNegative; } + + template + auto getResultIterator(Literal* lit, bool complementary, bool retrieveSubstitutions, Args... args) + { + CALL("LiteralSubstitutionTree::getResultIterator"); + + auto iter = [=](bool reversed) + { return iterTraits(getTree(lit, complementary)->template iterator(lit, retrieveSubstitutions, reversed, args...)) ; }; + + auto filterResults = [=](auto it) { + return pvi( + std::move(it) + .map([](auto r) { return lQueryRes(r.data->literal, r.data->clause, std::move(r.unif)); }) + ); + }; + return !lit->commutative() + ? filterResults(iter( /* reversed */ false)) + : filterResults(concatIters( + iter( /* reversed */ false), + iter( /* reversed */ true) + )); + } - SLQueryResultIterator getVariants(Literal* lit, bool complementary, bool retrieveSubstitutions) override; +public: -#if VDEBUG - virtual void markTagged() override { } -#endif + SLQueryResultIterator getUwa(Literal* lit, bool complementary) final override + { + static auto uwa = env.options->unificationWithAbstraction(); + static bool fixedPointIteration = env.options->unificationWithAbstractionFixedPointIteration(); + + return getResultIterator>(lit, complementary, /* retrieveSubstitutions */ true, MismatchHandler(uwa), fixedPointIteration); + } + + friend std::ostream& operator<<(std::ostream& out, LiteralSubstitutionTree const& self) + { + int i = 0; + out << "{ "; + for (auto& t : self._trees) { + if (!t->isEmpty()) { + auto f = env.signature->getPredicate(idxToFunctor(i)); + if (idxIsNegative(i)) out << "~"; + out << *f << "(" << t << "), "; + } + i++; + } + return out << "} "; + } + friend std::ostream& operator<<(std::ostream& out, OutputMultiline const& self) + { + int i = 0; + out << "{ " << endl; + for (auto& t : self.self._trees) { + if (!t->isEmpty()) { + auto f = env.signature->getPredicate(idxToFunctor(i)); + OutputMultiline::outputIndent(out, self.indent); + out << (idxIsNegative(i) ? "~" : " ") << *f << "(" << multiline(*t, self.indent + 1) << ")" << endl; + } + i++; + } + return out << "} "; + } + private: - SubstitutionTree& getTree(Literal* lit, bool complementary); + SubstitutionTree* getTree(Literal* lit, bool complementary); - template - SLQueryResultIterator getResultIterator(Literal* lit, bool complementary, bool retrieveSubstitutions, bool useConstraints); + // static auto createSLQueryResult(SubstitutionTree::QueryResult> r) + // { return lQueryRes(r.data->literal, r.data->clause, *r.unif); } + // + // static auto createSLQueryResult(SubstitutionTree::QueryResult> r) + // { return SLQueryResult(r.data->literal, r.data->clause, ResultSubstitutionSP((ResultSubstitution*)&*r.unif.unwrapOrElse([](){return RobSubstitutionSP();}))); } - Stack _trees; - bool _useC; + SplittingAlgo _algo; + // stack destructor will destroy trees + Stack _trees; }; }; diff --git a/Indexing/ResultSubstitution.cpp b/Indexing/ResultSubstitution.cpp index a7c1fe7d40..923d0a1887 100644 --- a/Indexing/ResultSubstitution.cpp +++ b/Indexing/ResultSubstitution.cpp @@ -29,7 +29,7 @@ class RSProxy CLASS_NAME(RSProxy); USE_ALLOCATOR(RSProxy); - RSProxy(RobSubstitution* subst, int queryBank, int resultBank) + RSProxy(RobSubstitutionTL* subst, VarBank queryBank, VarBank resultBank) : _subst(subst), _queryBank(queryBank), _resultBank(resultBank) {} TermList applyToQuery(TermList t) override @@ -42,10 +42,10 @@ class RSProxy Literal* applyToResult(Literal* l) override { return _subst->apply(l,_resultBank); } - TermList applyTo(TermList t,unsigned index) override - { return _subst->apply(t,index); } - Literal* applyTo(Literal* l,unsigned index) override - { return _subst->apply(l,index); } + TermList applyTo(TermList t,VarBank bank) override + { return _subst->apply(t,bank); } + Literal* applyTo(Literal* l,VarBank bank) override + { return _subst->apply(l,bank); } virtual size_t getQueryApplicationWeight(TermList t) override { return _subst->getApplicationResultWeight(t, _queryBank); } virtual size_t getQueryApplicationWeight(Literal* l) override { return _subst->getApplicationResultWeight(l, _queryBank); } @@ -54,16 +54,19 @@ class RSProxy virtual void output(std::ostream& out) const final override { out << *_subst; } + /** return iterator over constraints */ + virtual Recycled getConstraints() override { return _subst->constraints(); } + virtual bool isIdentityOnQueryWhenResultBound() override { return _subst->outputBank() == _queryBank;} + virtual bool isIdentityOnResultWhenQueryBound() override { return _subst->outputBank() == _resultBank;} + private: - RobSubstitution* _subst; - int _queryBank; - int _resultBank; + RobSubstitutionTL* _subst; + VarBank _queryBank; + VarBank _resultBank; }; -ResultSubstitutionSP ResultSubstitution::fromSubstitution(RobSubstitution* s, int queryBank, int resultBank) -{ - return ResultSubstitutionSP(new RSProxy(s, queryBank, resultBank)); -} +ResultSubstitutionSP ResultSubstitution::fromSubstitution(RobSubstitutionTL* s, VarBank queryBank, VarBank resultBank) +{ return ResultSubstitutionSP(new RSProxy(s, queryBank, resultBank)); } /** * Test whether this substitution object is a renaming on the variables of @param t diff --git a/Indexing/ResultSubstitution.hpp b/Indexing/ResultSubstitution.hpp index aaccb60678..aa425e3886 100644 --- a/Indexing/ResultSubstitution.hpp +++ b/Indexing/ResultSubstitution.hpp @@ -46,8 +46,8 @@ class ResultSubstitution virtual TermList applyToResult(TermList t) { NOT_IMPLEMENTED; } virtual Literal* applyToResult(Literal* l) { NOT_IMPLEMENTED; } - virtual TermList applyTo(TermList t, unsigned index) { ASSERTION_VIOLATION; } - virtual Literal* applyTo(Literal* l, unsigned index) { NOT_IMPLEMENTED; } + virtual TermList applyTo(TermList t, VarBank bank) { ASSERTION_VIOLATION; } + virtual Literal* applyTo(Literal* l, VarBank bank) { NOT_IMPLEMENTED; } /** if implementation cannot easily give result for this, zero is returned */ virtual size_t getQueryApplicationWeight(TermList t) { return 0; } @@ -57,6 +57,8 @@ class ResultSubstitution virtual size_t getResultApplicationWeight(TermList t) { return 0; } /** if implementation cannot easily give result for this, zero is returned */ virtual size_t getResultApplicationWeight(Literal* l) { return 0; } + /** return stack of constraints */ + virtual Recycled getConstraints() { NOT_IMPLEMENTED; } template T apply(T t, bool result) @@ -133,7 +135,7 @@ class ResultSubstitution */ virtual bool isIdentityOnResultWhenQueryBound() {return false;} - static ResultSubstitutionSP fromSubstitution(RobSubstitution* s, int queryBank, int resultBank); + static ResultSubstitutionSP fromSubstitution(RobSubstitutionTL* s, VarBank queryBank, VarBank resultBank); virtual void output(std::ostream& ) const = 0; friend std::ostream& operator<<(std::ostream& out, ResultSubstitution const& self) { self.output(out); return out; } diff --git a/Indexing/SubstitutionTree.cpp b/Indexing/SubstitutionTree.cpp index 42c4f248e0..b2bb70cb7a 100644 --- a/Indexing/SubstitutionTree.cpp +++ b/Indexing/SubstitutionTree.cpp @@ -45,15 +45,12 @@ using namespace std; using namespace Indexing; - /** * Initialise the substitution tree. * @since 16/08/2008 flight Sydney-San Francisco */ -SubstitutionTree::SubstitutionTree(bool useC, bool rfSubs) +SubstitutionTree::SubstitutionTree() : _nextVar(0) - , _useC(useC) - , _functionalSubtermMap(someIf(rfSubs, [](){ return FuncSubtermMap(); })) , _root(nullptr) #if VDEBUG , _tag(false) @@ -72,7 +69,6 @@ SubstitutionTree::~SubstitutionTree() { CALL("SubstitutionTree::~SubstitutionTree"); ASS_EQ(_iterCnt,0); - delete _root; } // SubstitutionTree::~SubstitutionTree @@ -130,7 +126,6 @@ struct BindingComparator } }; - /** * Insert an entry to the substitution tree. * @@ -140,15 +135,22 @@ struct BindingComparator */ void SubstitutionTree::insert(BindingMap& svBindings, LeafData ld) { -#define DEBUG_INSERT(...) // DBG(__VA_ARGS__) +#define DEBUG_INSERT(...) // DBG(__VA_ARGS__) CALL("SubstitutionTree::insert"); ASS_EQ(_iterCnt,0); auto pnode = &_root; DEBUG_INSERT("insert: ", svBindings, " into ", *this) if(*pnode == 0) { - ASS(!svBindings.isEmpty()) - *pnode=createIntermediateNode(svBindings.getOneKey(),_useC); + if (svBindings.isEmpty()) { + auto leaf = createLeaf(); + leaf->insert(std::move(ld)); + *pnode = leaf; + DEBUG_INSERT(0, "out: ", *this); + return; + } else { + *pnode=createIntermediateNode(svBindings.getOneKey()); + } } if(svBindings.isEmpty()) { ASS((*pnode)->isLeaf()); @@ -180,31 +182,31 @@ void SubstitutionTree::insert(BindingMap& svBindings, LeafData ld) Node* child=inode->_nodes[0]; bool removeProblematicNode=false; if(svBindings.find(boundVar)) { - TermList term=svBindings.get(boundVar); - bool wouldDescendIntoChild = inode->childByTop(term,false)!=0; - ASS_EQ(wouldDescendIntoChild, TermList::sameTop(term, child->term)); - if(!wouldDescendIntoChild) { - //if we'd have to perform all postponed splitting due to - //node with a single child, we rather remove that node - //from the tree and deal with the binding, it represented, - //later. - removeProblematicNode=true; - } + TermList term=svBindings.get(boundVar); + bool wouldDescendIntoChild = inode->childByTop(term.top(),false)!=0; + ASS_EQ(wouldDescendIntoChild, TermList::sameTop(term, child->term)); + if(!wouldDescendIntoChild) { + //if we'd have to perform all postponed splitting due to + //node with a single child, we rather remove that node + //from the tree and deal with the binding, it represented, + //later. + removeProblematicNode=true; + } } else if(!child->term.isTerm() || child->term.term()->shared()) { - //We can remove nodes binding to special variables undefined in our branch - //of the tree, as long as we're sure, that during split resolving we put these - //binding nodes below nodes that define spec. variables they bind. - removeProblematicNode=true; + //We can remove nodes binding to special variables undefined in our branch + //of the tree, as long as we're sure, that during split resolving we put these + //binding nodes below nodes that define spec. variables they bind. + removeProblematicNode=true; } else { - canPostponeSplits = false; + canPostponeSplits = false; } if(removeProblematicNode) { - unresolvedSplits.insert(UnresolvedSplitRecord(inode->childVar, child->term)); - child->term=inode->term; - *pnode=child; - inode->makeEmpty(); - delete inode; - goto start; + unresolvedSplits.insert(UnresolvedSplitRecord(inode->childVar, child->term)); + child->term=inode->term; + *pnode=child; + inode->makeEmpty(); + delete inode; + goto start; } } } @@ -215,12 +217,12 @@ void SubstitutionTree::insert(BindingMap& svBindings, LeafData ld) UnresolvedSplitRecord urr=unresolvedSplits.pop(); Node* node=*pnode; - IntermediateNode* newNode = createIntermediateNode(node->term, urr.var,_useC); + IntermediateNode* newNode = createIntermediateNode(node->term, urr.var); node->term=urr.original; *pnode=newNode; - Node** nodePosition=newNode->childByTop(node->term, true); + Node** nodePosition=newNode->childByTop(node->top(), true); ASS(!*nodePosition); *nodePosition=node; } @@ -239,7 +241,7 @@ void SubstitutionTree::insert(BindingMap& svBindings, LeafData ld) //So in the case we do insert, we might check whether this node //needs expansion. Node** pparent=pnode; - pnode=inode->childByTop(term,true); + pnode=inode->childByTop(term.top(),true); if (*pnode == 0) { BindingMap::Iterator svit(svBindings); @@ -252,11 +254,11 @@ void SubstitutionTree::insert(BindingMap& svBindings, LeafData ld) } while (!remainingBindings.isEmpty()) { Binding b=remainingBindings.pop(); - IntermediateNode* inode = createIntermediateNode(term, b.var,_useC); + IntermediateNode* inode = createIntermediateNode(term, b.var); term=b.term; *pnode = inode; - pnode = inode->childByTop(term,true); + pnode = inode->childByTop(term.top(),true); } Leaf* lnode=createLeaf(term); *pnode=lnode; @@ -373,7 +375,7 @@ void SubstitutionTree::remove(BindingMap& svBindings, LeafData ld) unsigned boundVar=inode->childVar; TermList t = svBindings.get(boundVar); - pnode=inode->childByTop(t,false); + pnode=inode->childByTop(t.top(),false); ASS(pnode); @@ -438,7 +440,7 @@ void SubstitutionTree::remove(BindingMap& svBindings, LeafData ld) } else { Node* node=*pnode; IntermediateNode* parent=static_cast(*history.top()); - parent->remove(term); + parent->remove(term.top()); delete node; pnode=history.pop(); ensureIntermediateNodeEfficiency(reinterpret_cast(pnode)); @@ -463,15 +465,14 @@ SubstitutionTree::Leaf* SubstitutionTree::findLeaf(Node* root, BindingMap& svBin unsigned boundVar=inode->childVar; TermList t = svBindings.get(boundVar); - Node** child=inode->childByTop(t,false); + Node** child=inode->childByTop(t.top(),false); if(!child) { return 0; } node=*child; - TermList s = node->term; - ASS(TermList::sameTop(s,t)); + ASS_REP2(TermList::sameTop(s,t), s, t); if(s==t) { continue; @@ -490,27 +491,27 @@ SubstitutionTree::Leaf* SubstitutionTree::findLeaf(Node* root, BindingMap& svBin TermList* tt = subterms.pop(); ss = subterms.pop(); if (tt->next()->isEmpty()) { - ASS(ss->next()->isEmpty()); + ASS(ss->next()->isEmpty()); } else { - subterms.push(ss->next()); - subterms.push(tt->next()); + subterms.push(ss->next()); + subterms.push(tt->next()); } if (*ss==*tt) { - continue; + continue; } if (ss->isSpecialVar()) { - svBindings.set(ss->var(),*tt); - continue; + svBindings.set(ss->var(),*tt); + continue; } if(ss->isVar() || tt->isVar() || ss->term()->functor()!=tt->term()->functor()) { - return 0; + return 0; } ss = ss->term()->args(); if (! ss->isEmpty()) { - ASS(! tt->term()->args()->isEmpty()); - subterms.push(ss); - subterms.push(tt->term()->args()); + ASS(! tt->term()->args()->isEmpty()); + subterms.push(ss); + subterms.push(tt->term()->args()); } } } @@ -548,13 +549,13 @@ void SubstitutionTree::Node::split(Node** pnode, TermList* where, int var) Node* node=*pnode; - IntermediateNode* newNode = createIntermediateNode(node->term, var,node->withSorts()); + IntermediateNode* newNode = createIntermediateNode(node->term, var); node->term=*where; *pnode=newNode; where->makeSpecialVar(var); - Node** nodePosition=newNode->childByTop(node->term, true); + Node** nodePosition=newNode->childByTop(node->term.top(), true); ASS(!*nodePosition); *nodePosition=node; } @@ -565,7 +566,7 @@ void SubstitutionTree::IntermediateNode::loadChildren(NodeIterator children) while(children.hasNext()) { Node* ext=*children.next(); - Node** own=childByTop(ext->term, true); + Node** own=childByTop(ext->top(), true); ASS(! *own); *own=ext; } @@ -576,8 +577,7 @@ void SubstitutionTree::Leaf::loadChildren(LDIterator children) CALL("SubstitutionTree::Leaf::loadClauses"); while(children.hasNext()) { - LeafData ld=children.next(); - insert(ld); + insert(*children.next()); } } @@ -601,7 +601,6 @@ SubstitutionTree::Leaf* SubstitutionTree::LeafIterator::next() return static_cast(out); } - void SubstitutionTree::LeafIterator::skipToNextLeaf() { for (;;) { @@ -630,243 +629,18 @@ bool SubstitutionTree::LeafIterator::hasNext() return _curr != nullptr; } -SubstitutionTree::UnificationsIterator::~UnificationsIterator() -{ - if(_clientBDRecording) { - _subst->bdDone(); - _clientBDRecording=false; - _clientBacktrackData.backtrack(); - } - if (_bdStack) - while(_bdStack->isNonEmpty()) { - _bdStack->pop().backtrack(); - } -} - -bool SubstitutionTree::UnificationsIterator::hasNext() -{ - CALL("SubstitutionTree::UnificationsIterator::hasNext"); - - if(_clientBDRecording) { - _subst->bdDone(); - _clientBDRecording=false; - _clientBacktrackData.backtrack(); - } - - while(!_ldIterator.hasNext() && findNextLeaf()) {} - return _ldIterator.hasNext(); -} - -SubstitutionTree::QueryResult SubstitutionTree::UnificationsIterator::next() -{ - CALL("SubstitutionTree::UnificationsIterator::next"); - - while(!_ldIterator.hasNext() && findNextLeaf()) {} - ASS(_ldIterator.hasNext()); - - ASS(!_clientBDRecording); - - LeafData& ld=_ldIterator.next(); - - if(_retrieveSubstitution) { - Renaming normalizer; - if(_literalRetrieval) { - normalizer.normalizeVariables(ld.literal); - } else { - normalizer.normalizeVariables(ld.term); - if (ld.sort.isNonEmpty()) { - normalizer.normalizeVariables(ld.sort); - } - } - - ASS(_clientBacktrackData.isEmpty()); - _subst->bdRecord(_clientBacktrackData); - _clientBDRecording=true; - - _subst->denormalize(normalizer,NORM_RESULT_BANK,RESULT_BANK); - - return QueryResult(ld, ResultSubstitution::fromSubstitution( &*_subst, QUERY_BANK, RESULT_BANK), - // TODO do we really wanna copy the whole constraints stack here? - UnificationConstraintStackSP(new UnificationConstraintStack(*_constraints))); - } else { - return QueryResult(ld); - } -} - - -bool SubstitutionTree::UnificationsIterator::findNextLeaf() -{ - CALL("SubstitutionTree::UnificationsIterator::findNextLeaf"); - - if(_nodeIterators->isEmpty()) { - //There are no node iterators in the stack, so there's nowhere - //to look for the next leaf. - //This shouldn't hapen during the regular retrieval process, but it - //can happen when there are no literals inserted for a predicate, - //or when predicates with zero arity are encountered. - ASS(_bdStack->isEmpty()); - return false; - } - - if(_inLeaf) { - ASS(!_clientBDRecording); - //Leave the current leaf - _bdStack->pop().backtrack(); - _inLeaf=false; - } - - ASS(!_clientBDRecording); - ASS(_bdStack->length()+1==_nodeIterators->length()); - - do { - while(!_nodeIterators->top().hasNext() && !_bdStack->isEmpty()) { - //backtrack undos everything that enter(...) method has done, - //so it also pops one item out of the nodeIterators stack - _bdStack->pop().backtrack(); - _svStack->pop(); - } - if(!_nodeIterators->top().hasNext()) { - return false; - } - Node* n=*_nodeIterators->top().next(); - - BacktrackData bd; - bool success=enter(n,bd); - if(!success) { - bd.backtrack(); - continue; - } else { - _bdStack->push(bd); - } - } while(!_inLeaf); - return true; -} - -bool SubstitutionTree::UnificationsIterator::enter(Node* n, BacktrackData& bd) -{ - CALL("SubstitutionTree::UnificationsIterator::enter"); - -#if VDEBUG - if(_tag){ - cout << "=========================================" << endl; - cout << "entering..." << *n << endl; - cout << "subst is " << _subst << endl; - cout << "svstack is " << _svStack << endl; - cout << "=========================================" << endl; - } -#endif - - bool success=true; - bool recording=false; - if(!n->term.isEmpty()) { - //n is proper node, not a root - - TermList qt(_svStack->top(), true); - - recording=true; - _subst->bdRecord(bd); - success=associate(qt,n->term,bd); - } - if(success) { - if(n->isLeaf()) { - _ldIterator=static_cast(n)->allChildren(); - _inLeaf=true; - } else { - IntermediateNode* inode=static_cast(n); - _svStack->push(inode->childVar); - NodeIterator nit=getNodeIterator(inode); - if(_useUWAConstraints){ - TermList qt = _subst->getSpecialVarTop(inode->childVar); - NodeIterator enit = pvi(getConcatenatedIterator(inode->childBySort(qt),nit)); - _nodeIterators->backtrackablePush(enit,bd); - } - else{ - _nodeIterators->backtrackablePush(nit, bd); - } - } - } - if(recording) { - _subst->bdDone(); - } - return success; -} - -bool SubstitutionTree::SubstitutionTreeMismatchHandler::introduceConstraint(TermList query,unsigned index1, TermList node,unsigned index2) -{ - CALL("SubstitutionTree::MismatchHandler::introduceConstraint"); - - auto constraint = make_pair(make_pair(query,index1),make_pair(node,index2)); - _constraints.backtrackablePush(constraint,_bd); - return true; -} - -bool SubstitutionTree::STHOMismatchHandler::handle - (RobSubstitution* subst,TermList query,unsigned index1, TermList node,unsigned index2) -{ - CALL("SubstitutionTree::STHOMismatchHandler::handle"); - - auto constraint = make_pair(make_pair(query,index1),make_pair(node,index2)); - _constraints.backtrackablePush(constraint,_bd); - return true; -} - -/** - * TODO: explain properly what associate does - * called from enter(...) - */ -bool SubstitutionTree::UnificationsIterator::associate(TermList query, TermList node, BacktrackData& bd) -{ - CALL("SubstitutionTree::UnificationsIterator::associate"); - - //The ordering of the if statements is important here. Higher-order problems - //should never require theory resoning (at the moment, theories cannot be parsed in HOL) - //However, a user can still set UWA option on. We don't wan't that to result in - //the wrong handler being used. - if(_useHOConstraints){ - STHOMismatchHandler hndlr(*_constraints,bd); - return _subst->unify(query,QUERY_BANK,node,NORM_RESULT_BANK,&hndlr); - } - if(_useUWAConstraints){ - SubstitutionTreeMismatchHandler hndlr(*_constraints,bd); - return _subst->unify(query,QUERY_BANK,node,NORM_RESULT_BANK,&hndlr); - } - return _subst->unify(query,QUERY_BANK,node,NORM_RESULT_BANK); -} - -//TODO I think this works for VSpcialVars as well. Since .isVar() will return true -//for them -SubstitutionTree::NodeIterator SubstitutionTree::UnificationsIterator::getNodeIterator(IntermediateNode* n) -{ - CALL("SubstitutionTree::UnificationsIterator::getNodeIterator"); - - unsigned specVar=n->childVar; - TermList qt=_subst->getSpecialVarTop(specVar); - if(qt.isVar()) { - return n->allChildren(); - } else { - Node** match=n->childByTop(qt, false); - if(match) { - return pvi( - getConcatenatedIterator( - getSingletonIterator(match), - n->variableChildren() - )); - } else { - return n->variableChildren(); - } - } -} - void SubstitutionTree::Leaf::output(std::ostream& out, bool multiline, int indent) const -{ out << this->term; } +{ + out << this->term << " Leaf " << + (this->splittable() ? "" : " {NS}"); } void SubstitutionTree::IntermediateNode::output(std::ostream& out, bool multiline, int indent) const { // TODO const version of allChildren auto childIter = iterTraits(((IntermediateNode*)this)->allChildren()); if (!this->term.isEmpty()) { - out << this->term - << " ; "; + out << this->term << + (this->splittable() ? "" : " {NS}") << " ; "; } out << "S" << this->childVar << " -> "; @@ -878,7 +652,7 @@ void SubstitutionTree::IntermediateNode::output(std::ostream& out, bool multilin if (multiline) { auto outp = [&](Node** x) { out << endl; - repeat(out, INDENT, indent + 1); + OutputMultiline::outputIndent(out, indent + 1); out << "| "; (*x)->output(out, multiline, indent + 1); }; @@ -888,7 +662,7 @@ void SubstitutionTree::IntermediateNode::output(std::ostream& out, bool multilin outp(childIter.next()); } out << endl; - repeat(out, INDENT, indent); + OutputMultiline::outputIndent(out, indent + 1); out << "]"; } else { @@ -900,7 +674,6 @@ void SubstitutionTree::IntermediateNode::output(std::ostream& out, bool multilin out << " ]"; } - } else { (*first)->output(out, multiline, indent); } @@ -931,11 +704,9 @@ std::ostream& Indexing::operator<<(std::ostream& out, SubstitutionTree const& se std::ostream& Indexing::operator<<(std::ostream& out, OutputMultiline const& self) { if (self.self._root) { - self.self._root->output(out, true, /* indent */ 0); + self.self._root->output(out, /* multiline */ true, /* indent */ 0); } else { out << ""; } return out; } - - diff --git a/Indexing/SubstitutionTree.hpp b/Indexing/SubstitutionTree.hpp index de858faf34..0cc1f8b1ab 100644 --- a/Indexing/SubstitutionTree.hpp +++ b/Indexing/SubstitutionTree.hpp @@ -21,6 +21,8 @@ #include "Forwards.hpp" +#include "Kernel/MismatchHandler.hpp" +#include "Lib/Exception.hpp" #include "Lib/VirtualIterator.hpp" #include "Lib/Metaiterators.hpp" #include "Lib/Comparison.hpp" @@ -36,6 +38,11 @@ #include "Lib/Recycled.hpp" #include "Kernel/BottomUpEvaluation/TypedTermList.hpp" +#if VHOL + #include "Kernel/HOLUnification.hpp" + #include "Kernel/HOLMatching.hpp" +#endif + #include "Kernel/RobSubstitution.hpp" #include "Kernel/Renaming.hpp" #include "Kernel/Clause.hpp" @@ -43,7 +50,9 @@ #include "Kernel/OperatorType.hpp" #include "Lib/Option.hpp" #include "Kernel/Signature.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/ApplicativeHelper.hpp" +#include "Indexing/ResultSubstitution.hpp" #include "Lib/Allocator.hpp" @@ -119,27 +128,22 @@ class SubstitutionTree { public: - static constexpr int QRS_QUERY_BANK = 0; - static constexpr int QRS_RESULT_BANK = 1; CLASS_NAME(SubstitutionTree); USE_ALLOCATOR(SubstitutionTree); - SubstitutionTree(bool useC, bool rfSubs); - + SubstitutionTree(); + SubstitutionTree(SubstitutionTree const&) = delete; SubstitutionTree& operator=(SubstitutionTree const& other) = delete; SubstitutionTree(SubstitutionTree&& other) - : SubstitutionTree(other._useC, /* rfSubst */ false) + : SubstitutionTree() { std::swap(_nextVar, other._nextVar); - std::swap(_useC, other._useC); - std::swap(_functionalSubtermMap, other._functionalSubtermMap); std::swap(_root, other._root); #if VDEBUG std::swap(_tag, other._tag); #endif } - virtual ~SubstitutionTree(); friend std::ostream& operator<<(std::ostream& out, SubstitutionTree const& self); @@ -154,9 +158,9 @@ class SubstitutionTree : clause(cls), literal(literal), term(term), sort(term.sort()) { extraTerm.makeEmpty();} LeafData(Clause* cls, Literal* literal, TermList term, TermList extraTerm) - : clause(cls), literal(literal), term(term), extraTerm(extraTerm) { sort.makeEmpty(); } + : clause(cls), literal(literal), term(term), extraTerm(extraTerm) { sort.makeEmpty();} LeafData(Clause* cls, Literal* literal, TermList term) - : clause(cls), literal(literal), term(term) { sort.makeEmpty(); extraTerm.makeEmpty();} + : clause(cls), literal(literal), term(term) { extraTerm.makeEmpty(); sort.makeEmpty(); } LeafData(Clause* cls, Literal* literal) : clause(cls), literal(literal) { term.makeEmpty(); sort.makeEmpty(), extraTerm.makeEmpty(); } @@ -164,6 +168,13 @@ class SubstitutionTree bool operator==(const LeafData& o) { return clause==o.clause && literal==o.literal && term==o.term; } + friend std::ostream& operator<<(std::ostream& out, LeafData const& self) + { out << "term " << self.term << " : " << self.sort << "\n" << + "literal " << self.literal->toString() << "\n" << + "clause " << self.clause->toString(); + return out; + } + Clause* clause; Literal* literal; TermList term; @@ -174,26 +185,32 @@ class SubstitutionTree TermList extraTerm; }; - typedef VirtualIterator LDIterator; + typedef VirtualIterator LDIterator; struct QueryResult { LeafData const* data; - ResultSubstitutionSP subst; - UnificationConstraintStackSP constr; + ResultSubstitutionSP unif; - QueryResult(LeafData const& ld) : data(&ld), subst(), constr() {}; - QueryResult(LeafData const& ld, ResultSubstitutionSP subst, UnificationConstraintStackSP constr) : data(&ld), subst(subst), constr(constr) {} + QueryResult(LeafData const* ld, ResultSubstitutionSP unifier) : data(ld), unif(unifier) {} }; - using QueryResultIterator = VirtualIterator; + using QueryResultIter = VirtualIterator; + // TODO make const function - template - QueryResultIterator iterator(TermOrLit query, bool retrieveSubstitutions, bool withConstraints, bool reversed = false) + template + auto iterator(TermOrLit query, bool retrieveSubstitutions, bool reversed, Args... args) { - CALL("TermSubstitutionTree::iterator"); - return _root == nullptr - ? QueryResultIterator::getEmpty() - : pvi(iterTraits(Iterator(this, _root, query, retrieveSubstitutions, reversed, withConstraints, _functionalSubtermMap.asPtr() ))); + CALL("SubstitutionTree::iterator"); + if(_root == nullptr) + return QueryResultIter::getEmpty(); + + return pvi(getFlattenedIterator(vi(new I(this, _root, query, retrieveSubstitutions, reversed, std::move(args)...)))); + + /*return iterTraits( + someIf(_root != nullptr, + [&]() { return I(this, _root, query, retrieveSubstitutions, reversed, std::move(args)...) ; }) + .intoIter()) + .flatten().flatten();*/ } class LDComparator @@ -202,7 +219,7 @@ class SubstitutionTree inline static Comparison compare(const LeafData& ld1, const LeafData& ld2) { - CALL("SubstitutionTree::LDComparator::compare"); + CALL("SubstitutionTree::Comparator::compare"); if(ld1.clause && ld2.clause && ld1.clause!=ld2.clause) { ASS_NEQ(ld1.clause->number(), ld2.clause->number()); @@ -251,20 +268,24 @@ class SubstitutionTree }; class Node { + protected: + bool canSplit; + public: friend std::ostream& operator<<(ostream& out, OutputMultiline const& self) - { self.self.output(out, /* multiline = */ true, /* indent */ 0); return out; } + { self.self.output(out, /* multiline = */ true, self.indent); return out; } friend std::ostream& operator<<(ostream& out, Node const& self) { self.output(out, /* multiline = */ false, /* indent */ 0); return out; } inline Node() { term.makeEmpty(); } inline - Node(TermList ts) : term(ts) { } + Node(TermList ts, bool splittable = true) : canSplit(splittable), term(ts) { } virtual ~Node(); /** True if a leaf node */ virtual bool isLeaf() const = 0; virtual bool isEmpty() const = 0; - virtual bool withSorts(){ return false; } + + TermList::Top top() const { return term.top(canSplit); } /** * Return number of elements held in the node. * @@ -273,6 +294,10 @@ class SubstitutionTree virtual int size() const { NOT_IMPLEMENTED; } virtual NodeAlgorithm algorithm() const = 0; + + bool splittable() const { return canSplit; } + void setSplittable(bool b) { canSplit = b; } + /** * Remove all referenced structures without destroying them. * @@ -295,100 +320,6 @@ class SubstitutionTree typedef VirtualIterator NodeIterator; - class IntermediateNode; - - //We can remove this class once we deal with UWA uniformly for - //for theories and HOL AYB - class ChildBySortHelper - { - public: - - CLASS_NAME(SubstitutionTree::ChildBySortHelper); - USE_ALLOCATOR(ChildBySortHelper); - - ChildBySortHelper(IntermediateNode* p): _parent(p) - { - bySort.ensure(Signature::FIRST_USER_CON); - bySortTerms.ensure(Signature::FIRST_USER_CON); - } - - void loadFrom(ChildBySortHelper* other){ - ASS(other->bySort.size() == other->bySortTerms.size()); - for(unsigned i=0;ibySort.size();i++){ - DHSet::Iterator it1(other->bySort[i]); - bySort[i].loadFromIterator(it1); - Stack::Iterator it2(other->bySortTerms[i]); - bySortTerms[i].loadFromIterator(it2); - } - } - - /** - * Return an iterator of child nodes whose top term has the same sort - * as Termlist t. Only consider interpreted sorts. - * - */ - NodeIterator childBySort(TermList t) - { - CALL("SubstitutionTree::ChildBySortHelper::childBySort"); - TermList srt; - // only consider interpreted sorts - if(SortHelper::tryGetResultSort(t,srt) && !srt.isVar()){ - ASS(srt.isTerm()); - unsigned con = srt.term()->functor(); - if(!srt.term()->isSuper() && env.signature->isInterpretedNonDefault(con)){ - unsigned top = t.term()->functor(); - TermStack::Iterator fit(bySortTerms[con]); - auto withoutThisTop = getFilteredIterator(fit,NotTop(top)); - auto nodes = getMappingIterator(withoutThisTop,ByTopFn(this)); - return pvi(getFilteredIterator(nodes,NonzeroFn())); - } - } - return NodeIterator::getEmpty(); - } - - DArray> bySort; - DArray> bySortTerms; - - IntermediateNode* _parent; - /* - * This is used for recording terms that might - */ - void mightExistAsTop(TermList t) - { - CALL("SubstitutionTree::ChildBySortHelper::mightExistAsTop"); - if(!t.isTerm()){ return; } - TermList srt; - if(SortHelper::tryGetResultSort(t,srt) && !srt.isVar() && - !srt.term()->isSuper()){ - unsigned con = srt.term()->functor(); - if(env.signature->isInterpretedNonDefault(con)){ - unsigned f = t.term()->functor(); - if(bySort[con].insert(f)){ - bySortTerms[con].push(t); - } - } - } - } - void remove(TermList t) - { - CALL("SubstitutionTree::ChildBySortHelper::remove"); - if(!t.isTerm()){ return;} - TermList srt; - if(SortHelper::tryGetResultSort(t,srt) && !srt.isVar() && - !srt.term()->isSuper()){ - unsigned con = srt.term()->functor(); - if(env.signature->isInterpretedNonDefault(con)){ - unsigned f = t.term()->functor(); - if(bySort[con].remove(f)){ - bySortTerms[con].remove(t); - } - } - } - } - - };// class SubstitutionTree::ChildBySortHelper - - class IntermediateNode : public Node @@ -396,11 +327,12 @@ class SubstitutionTree public: /** Build a new intermediate node which will serve as the root*/ inline - IntermediateNode(unsigned childVar) : childVar(childVar),_childBySortHelper(0) {} + IntermediateNode(unsigned childVar) : childVar(childVar) {} /** Build a new intermediate node */ inline - IntermediateNode(TermList ts, unsigned childVar) : Node(ts), childVar(childVar),_childBySortHelper(0) {} + IntermediateNode(TermList ts, unsigned childVar, bool splittable) : + Node(ts, splittable), childVar(childVar) {} inline bool isLeaf() const final override { return false; }; @@ -419,20 +351,19 @@ class SubstitutionTree * If canCreate is false, null pointer is returned in case * suitable child does not exist. */ - virtual Node** childByTop(TermList t, bool canCreate) = 0; + virtual Node** childByTop(TermList::Top t, bool canCreate) = 0; /** * Remove child which points to node with top symbol of @b t. * This node has to still exist in time of the call to remove method. */ - virtual void remove(TermList t) = 0; - + virtual void remove(TermList::Top t) = 0; /** * Remove all children of the node without destroying them. */ virtual void removeAllChildren() = 0; - + void destroyChildren(); void makeEmpty() final override @@ -441,46 +372,13 @@ class SubstitutionTree removeAllChildren(); } - - virtual NodeIterator childBySort(TermList t) - { - if(!_childBySortHelper) return NodeIterator::getEmpty(); - return _childBySortHelper->childBySort(t); - } - virtual void mightExistAsTop(TermList t) { - if(_childBySortHelper){ - _childBySortHelper->mightExistAsTop(t); - } - } - void loadChildren(NodeIterator children); const unsigned childVar; - ChildBySortHelper* _childBySortHelper; virtual void output(std::ostream& out, bool multiline, int indent) const override; }; // class SubstitutionTree::IntermediateNode - struct ByTopFn - { - ByTopFn(ChildBySortHelper* n) : node(n) {}; - Node** operator()(TermList t){ - return node->_parent->childByTop(t,false); - } - private: - ChildBySortHelper* node; - }; - struct NotTop - { - NotTop(unsigned t) : top(t) {}; - bool operator()(TermList t){ - return t.term()->functor()!=top; - } - private: - unsigned top; - }; - - class Leaf : public Node { @@ -491,7 +389,7 @@ class SubstitutionTree {} /** Build a new leaf */ inline - Leaf(TermList ts) : Node(ts) {} + Leaf(TermList ts, bool splittable) : Node(ts, splittable) {} inline bool isLeaf() const final override { return true; }; @@ -499,7 +397,6 @@ class SubstitutionTree virtual void insert(LeafData ld) = 0; virtual void remove(LeafData ld) = 0; void loadChildren(LDIterator children); - virtual void output(std::ostream& out, bool multiline, int indent) const override; }; @@ -509,17 +406,22 @@ class SubstitutionTree class SListLeaf; class SetLeaf; static Leaf* createLeaf(); - static Leaf* createLeaf(TermList ts); + static Leaf* createLeaf(TermList ts, bool splittable = true); static void ensureLeafEfficiency(Leaf** l); - static IntermediateNode* createIntermediateNode(unsigned childVar,bool constraints); - static IntermediateNode* createIntermediateNode(TermList ts, unsigned childVar,bool constraints); + static IntermediateNode* createIntermediateNode(unsigned childVar); + static IntermediateNode* createIntermediateNode(TermList ts, unsigned childVar, bool splittable = true); static void ensureIntermediateNodeEfficiency(IntermediateNode** inode); struct IsPtrToVarNodeFn { bool operator()(Node** n) - { - return (*n)->term.isVar(); + { + // treat non-splittable nodes like variable nodes + return (*n)->term.isVar() || !(*n)->splittable() +#if VHOL + || (*n)->term.isPlaceholder() // treat placeholders exactly like variables +#endif + ; } }; @@ -533,7 +435,8 @@ class SubstitutionTree _nodes[0]=0; } inline - UArrIntermediateNode(TermList ts, unsigned childVar) : IntermediateNode(ts, childVar), _size(0) + UArrIntermediateNode(TermList ts, unsigned childVar, bool splittable = true) + : IntermediateNode(ts, childVar, splittable), _size(0) { _nodes[0]=0; } @@ -562,8 +465,8 @@ class SubstitutionTree return pvi( getFilteredIterator(PointerPtrIterator(&_nodes[0],&_nodes[_size]), IsPtrToVarNodeFn()) ); } - virtual Node** childByTop(TermList t, bool canCreate); - void remove(TermList t); + virtual Node** childByTop(TermList::Top t, bool canCreate); + void remove(TermList::Top t); #if VDEBUG virtual void assertValid() const @@ -579,24 +482,13 @@ class SubstitutionTree Node* _nodes[UARR_INTERMEDIATE_NODE_MAX_SIZE+1]; }; - class UArrIntermediateNodeWithSorts - : public UArrIntermediateNode - { - public: - UArrIntermediateNodeWithSorts(unsigned childVar) : UArrIntermediateNode(childVar) { - _childBySortHelper = new ChildBySortHelper(this); - } - UArrIntermediateNodeWithSorts(TermList ts, unsigned childVar) : UArrIntermediateNode(ts, childVar) { - _childBySortHelper = new ChildBySortHelper(this); - } - }; - class SListIntermediateNode : public IntermediateNode { public: SListIntermediateNode(unsigned childVar) : IntermediateNode(childVar) {} - SListIntermediateNode(TermList ts, unsigned childVar) : IntermediateNode(ts, childVar) {} + SListIntermediateNode(TermList ts, unsigned childVar, bool splittable = true) : + IntermediateNode(ts, childVar, splittable) {} ~SListIntermediateNode() { @@ -637,7 +529,7 @@ class SubstitutionTree NodeSkipList::PtrIterator(_nodes), IsPtrToVarNodeFn()) ); } - virtual Node** childByTop(TermList t, bool canCreate) + virtual Node** childByTop(TermList::Top t, bool canCreate) { CALL("SubstitutionTree::SListIntermediateNode::childByTop"); @@ -645,7 +537,6 @@ class SubstitutionTree bool found=_nodes.getPosition(t,res,canCreate); if(!found) { if(canCreate) { - mightExistAsTop(t); *res=0; } else { res=0; @@ -653,14 +544,9 @@ class SubstitutionTree } return res; } - inline - void remove(TermList t) - { - _nodes.remove(t); - if(_childBySortHelper){ - _childBySortHelper->remove(t); - } - } + + inline void remove(TermList::Top t) + { _nodes.remove(t); } CLASS_NAME(SubstitutionTree::SListIntermediateNode); USE_ALLOCATOR(SListIntermediateNode); @@ -668,45 +554,53 @@ class SubstitutionTree class NodePtrComparator { public: - static Comparison compare(TermList t1,TermList t2) + static Comparison compare(TermList::Top t1, TermList::Top t2) { - CALL("SubstitutionTree::SListIntermediateNode::NodePtrComparator::compare"); - - if(t1.isVar()) { - if(t2.isVar()) { - return Int::compare(t1.var(), t2.var()); - } - return LESS; - } - if(t2.isVar()) { - return GREATER; - } - return Int::compare(t1.term()->functor(), t2.term()->functor()); + CALL("SubstitutionTree::SListIntermediateNode::NodePtrComparator::compare"); + + if(t1.var()) { + if(t2.var()) { + return Int::compare(*t1.var(), *t2.var()); + } + return LESS; + } + if(t2.var()) { + return GREATER; + } +#if VHOL + if(env.property->higherOrder() && t1.functor() && t2.functor()){ + // always put placeholder directly after variables in SkipList + // so that IsPtrToVarNodeFn return true for placehodlers as well + bool t1IsPlaceholder = env.signature->isPlaceholder(*t1.functor()); + bool t2IsPlaceholder = env.signature->isPlaceholder(*t2.functor()); + if(t1IsPlaceholder && !t2IsPlaceholder) return LESS; + if(t2IsPlaceholder && !t1IsPlaceholder) return GREATER; + } +#endif + if(t1.id()) { + if(t2.id()) { + return Int::compare(*t1.id(), *t2.id()); + } + return LESS; + } + if(t2.id()) { + return GREATER; + } + + return Int::compare(*t1.functor(), *t2.functor()); } static Comparison compare(Node* n1, Node* n2) - { return compare(n1->term, n2->term); } - static Comparison compare(TermList t1, Node* n2) - { return compare(t1, n2->term); } + { return compare(n1->top(), n2->top()); + + } + static Comparison compare(TermList::Top t1, Node* n2) + { return compare(t1, n2->top()); } }; typedef SkipList NodeSkipList; NodeSkipList _nodes; }; - - - class SListIntermediateNodeWithSorts - : public SListIntermediateNode - { - public: - SListIntermediateNodeWithSorts(unsigned childVar) : SListIntermediateNode(childVar) { - _childBySortHelper = new ChildBySortHelper(this); - } - SListIntermediateNodeWithSorts(TermList ts, unsigned childVar) : SListIntermediateNode(ts, childVar) { - _childBySortHelper = new ChildBySortHelper(this); - } - }; - class Binding { public: /** Number of the variable at this node */ @@ -753,18 +647,9 @@ class SubstitutionTree void setSort(TypedTermList const& term, LeafData& ld) { - ASS_EQ(ld.term, term) ld.sort = term.sort(); } - void setSort(TermList const& term, LeafData& ld) - { - ASS_EQ(ld.term, term) - if (term.isTerm()) { - ld.sort = SortHelper::getResultSort(term.term()); - } - } - void setSort(Literal* literal, LeafData &ld) { @@ -775,14 +660,17 @@ class SubstitutionTree } + virtual void handle(TypedTermList const& key, LeafData ld, bool doInsert) + { handleImpl(key, ld, doInsert); } + + virtual void handle(Literal* const& key, LeafData ld, bool doInsert) + { handleImpl(key, ld, doInsert); } + template - void handle(Key const& key, LeafData ld, bool doInsert) + void handleImpl(Key const& key, LeafData ld, bool doInsert) { - auto norm = Renaming::normalize(key); - if (_functionalSubtermMap.isSome()) { - norm = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(norm, &_functionalSubtermMap.unwrap()); - } - + CALL("SubstitutionTree::handleImpl"); + auto norm = Renaming::normalize(key, NORM_RESULT_BANK); Recycled bindings; setSort(key, ld); createBindings(norm, /* reversed */ false, @@ -794,18 +682,14 @@ class SubstitutionTree else remove(*bindings, ld); } -private: +protected: void insert(BindingMap& binding,LeafData ld); void remove(BindingMap& binding,LeafData ld); /** Number of the next variable */ int _nextVar; - /** Array of nodes */ - /** enable searching with constraints for this tree */ - bool _useC; - /** functional subterms of a term are replaced by extra sepcial - variables before being inserted into the tree */ - Option _functionalSubtermMap; + Cntr _iterCnt; + Node* _root; #if VDEBUG bool _tag; @@ -829,8 +713,8 @@ class SubstitutionTree virtual TermList applyToResult(TermList t) final override { return _result->apply(t); } virtual Literal* applyToResult(Literal* l) final override { return _result->apply(l); } - virtual TermList applyTo(TermList t, unsigned index) final override { ASSERTION_VIOLATION; } - virtual Literal* applyTo(Literal* l, unsigned index) final override { NOT_IMPLEMENTED; } + virtual TermList applyTo(TermList t, VarBank bank) final override { ASSERTION_VIOLATION; } + virtual Literal* applyTo(Literal* l, VarBank bank) final override { NOT_IMPLEMENTED; } virtual size_t getQueryApplicationWeight(TermList t) final override { return t.weight(); } virtual size_t getQueryApplicationWeight(Literal* l) final override { return l->weight(); } @@ -846,24 +730,33 @@ class SubstitutionTree { return _root == nullptr ? false - : FastGeneralizationsIterator(this, _root, query, /* retrieveSubstitutions */ false, /* reversed */ false, /* useC */ false).hasNext(); + : FastGeneralizationsIterator(this, _root, query, /* retrieveSubstitutions */ false, /* reversed */ false).hasNext(); } template - QueryResultIterator getVariants(Query query, bool retrieveSubstitutions) + QueryResultIter getVariants(Query query, bool retrieveSubstitutions) { CALL("LiteralSubstitutionTree::getVariants"); - RenamingSubstitution* renaming = retrieveSubstitutions ? new RenamingSubstitution() : nullptr; - ResultSubstitutionSP resultSubst = retrieveSubstitutions ? ResultSubstitutionSP(renaming) : ResultSubstitutionSP(); + auto renaming = retrieveSubstitutions ? make_unique() : std::unique_ptr(nullptr); + ResultSubstitutionSP resultSubst = retrieveSubstitutions ? ResultSubstitutionSP(&*renaming) : ResultSubstitutionSP(); Query normQuery; if (retrieveSubstitutions) { + ASS(false); + // TODO this is not safe at the moment + // the use of embedded banks is causing issues here. + // Luckily, we only call this from one place currently ClauseVariantIndex + // which doesn't need to retrive the substittuio renaming->_query->normalizeVariables(query); normQuery = renaming->_query->apply(query); } else { - normQuery = Renaming::normalize(query); + // put onto norm result bank, so that terms + // f (x0 / 0) and f (x0 / 3) don't fail an == check for + // syntactic equality + // Long term need to bring back the TermSpec based + normQuery = Renaming::normalize(query, NORM_RESULT_BANK); } Recycled svBindings; @@ -874,18 +767,18 @@ class SubstitutionTree } }); Leaf* leaf = findLeaf(*svBindings); if(leaf==0) { - return QueryResultIterator::getEmpty(); + return QueryResultIter::getEmpty(); } else { return pvi(iterTraits(leaf->allChildren()) - .map([retrieveSubstitutions, renaming, resultSubst](LeafData& ld) + .map([retrieveSubstitutions, renaming = std::move(renaming), resultSubst](LeafData* ld) { ResultSubstitutionSP subs; if (retrieveSubstitutions) { renaming->_result->reset(); - renaming->_result->normalizeVariables(SubtitutionTreeConfig::getKey(ld)); + renaming->_result->normalizeVariables(SubtitutionTreeConfig::getKey(*ld)); subs = resultSubst; } - return QueryResult(ld, subs, UnificationConstraintStackSP()); + return QueryResult(ld, subs); })); } } @@ -905,8 +798,6 @@ class SubstitutionTree Stack _nodeIterators; }; - - /** * Class that supports matching operations required by * retrieval of generalizations in substitution trees. @@ -1029,10 +920,6 @@ class SubstitutionTree bindSpecialVar(1,*lit->nthArgument(0)); bindSpecialVar(0,*lit->nthArgument(1)); - } else if (lit->arity() == 0) { - // insert a dummy term - bindSpecialVar(0, TermList::var(0)); - } else { TermList* args=lit->args(); @@ -1049,22 +936,24 @@ class SubstitutionTree * Iterator, that yields generalizations of given term/literal. */ class FastGeneralizationsIterator + : public IteratorCore { public: - FastGeneralizationsIterator(FastGeneralizationsIterator&&) = default; - FastGeneralizationsIterator& operator=(FastGeneralizationsIterator&&) = default; - DECL_ELEMENT_TYPE(QueryResult); +// FastGeneralizationsIterator(FastGeneralizationsIterator&&) = default; +// FastGeneralizationsIterator& operator=(FastGeneralizationsIterator&&) = default; + DECL_ELEMENT_TYPE(QueryResultIter); + using Unifier = ResultSubstitutionSP; /** * If @b reversed If true, parameters of supplied binary literal are * reversed. (useful for retrieval commutative terms) */ template - FastGeneralizationsIterator(SubstitutionTree* parent, Node* root, TermOrLit query, bool retrieveSubstitution, bool reversed, bool useC, FuncSubtermMap* fstm = nullptr) + FastGeneralizationsIterator(SubstitutionTree* parent, Node* root, TermOrLit query, bool retrieveSubstitution, bool reversed) : _literalRetrieval(std::is_same::value) , _retrieveSubstitution(retrieveSubstitution) - , _inLeaf(false) + , _inLeaf(root->isLeaf()) , _subst(query,parent->_nextVar) - , _ldIterator(LDIterator::getEmpty()) + , _ldIterator(_inLeaf ? static_cast(root)->allChildren() : LDIterator::getEmpty()) , _resultNormalizer() , _root(root) , _alternatives() @@ -1074,15 +963,12 @@ class SubstitutionTree { CALL("SubstitutionTree::FastGeneralizationsIterator::FastGeneralizationsIterator"); ASS(root); - ASS(!root->isLeaf()); - - ASS_REP(!useC, "instantion with abstraction is not a thing (yet (?))") parent->createBindings(query, reversed, [&](unsigned var, TermList t) { _subst.bindSpecialVar(var, t); }); } - QueryResult next(); + QueryResultIter next(); bool hasNext(); protected: @@ -1120,12 +1006,6 @@ class SubstitutionTree class InstMatcher { public: - void reset() - { - _boundVars.reset(); - _bindings.reset(); - _derefBindings.reset(); - } CLASS_NAME(SubstitutionTree::InstMatcher); USE_ALLOCATOR(InstMatcher); @@ -1180,25 +1060,25 @@ class SubstitutionTree CALL("SubstitutionTree::InstMatcher::bindSpecialVar"); ASS_EQ(getBSCnt(), 0); - ALWAYS(_bindings.insert(TermList(var,true),TermSpec(true,term))); + ALWAYS(_bindings->insert(TermList(var,true),TermSpec(true,term))); } bool isSpecVarBound(unsigned specVar) { - return _bindings.find(TermList(specVar,true)); + return _bindings->find(TermList(specVar,true)); } /** Return term bound to special variable @b specVar */ TermSpec getSpecVarBinding(unsigned specVar) { - TermSpec res=_bindings.get(TermList(specVar,true)); + TermSpec res=_bindings->get(TermList(specVar,true)); return res; } bool findSpecVarBinding(unsigned specVar, TermSpec& res) { - return _bindings.find(TermList(specVar,true), res); + return _bindings->find(TermList(specVar,true), res); } bool matchNext(unsigned specVar, TermList nodeTerm, bool separate=true); @@ -1211,7 +1091,7 @@ class SubstitutionTree int getBSCnt() { int res=0; - TermStack::Iterator vsit(_boundVars); + TermStack::Iterator vsit(*_boundVars); while(vsit.hasNext()) { if(vsit.next().isEmpty()) { res++; @@ -1222,7 +1102,7 @@ class SubstitutionTree void onLeafEntered() { - _derefBindings.reset(); + _derefBindings->reset(); } private: @@ -1236,15 +1116,15 @@ class SubstitutionTree CALL("SubstitutionTree::InstMatcher::isBound"); ASS(var.isVar()); - return _bindings.find(var); + return _bindings->find(var); } void bind(TermList var, TermSpec trm) { CALL("SubstitutionTree::InstMatcher::bind"); ASS(!var.isOrdinaryVar() || !trm.q); //we do not bind ordinary vars to query terms - ALWAYS(_bindings.insert(var, trm)); - _boundVars.push(var); + ALWAYS(_bindings->insert(var, trm)); + _boundVars->push(var); } TermSpec deref(TermList var); @@ -1254,16 +1134,16 @@ class SubstitutionTree /** Stacks of bindings made on each backtrack level. Backtrack * levels are separated by empty terms. */ - TermStack _boundVars; + Recycled _boundVars; - BindingMap _bindings; + Recycled _bindings; /** * A cache for bindings of variables to result terms * * The map is reset whenever we enter a new leaf */ - DHMap _derefBindings; + Recycled> _derefBindings; struct DerefTask { @@ -1281,7 +1161,7 @@ class SubstitutionTree { CALL("SubstitutionTree::InstMatcher::DerefApplicator::apply"); if(query) { - return im->_derefBindings.get(TermList(var, false)); + return im->_derefBindings->get(TermList(var, false)); } else { return TermList(var, false); @@ -1292,7 +1172,7 @@ class SubstitutionTree CALL("SubstitutionTree::InstMatcher::DerefApplicator::applyToSpecVar"); ASS(!query); - return im->_derefBindings.get(TermList(specVar, true)); + return im->_derefBindings->get(TermList(specVar, true)); } private: bool query; @@ -1304,24 +1184,24 @@ class SubstitutionTree * Iterator, that yields generalizations of given term/literal. */ class FastInstancesIterator + : public IteratorCore { public: - FastInstancesIterator(FastInstancesIterator&&) = default; - FastInstancesIterator& operator=(FastInstancesIterator&&) = default; - DECL_ELEMENT_TYPE(QueryResult); +// FastInstancesIterator(FastInstancesIterator&&) = default; +// FastInstancesIterator& operator=(FastInstancesIterator&&) = default; + DECL_ELEMENT_TYPE(QueryResultIter); + using Unifier = ResultSubstitutionSP; /** * If @b reversed If true, parameters of supplied binary literal are * reversed. (useful for retrieval commutative terms) */ template - FastInstancesIterator(SubstitutionTree* parent, Node* root, - TermOrLit query, bool retrieveSubstitution, bool reversed, bool useC, - FuncSubtermMap* fstm) //final two for compatibility purposes + FastInstancesIterator(SubstitutionTree* parent, Node* root, TermOrLit query, bool retrieveSubstitution, bool reversed) : _literalRetrieval(std::is_same::value) , _retrieveSubstitution(retrieveSubstitution) - , _inLeaf(false) - , _ldIterator(LDIterator::getEmpty()) + , _inLeaf(root->isLeaf()) + , _ldIterator(_inLeaf ? static_cast(root)->allChildren() : LDIterator::getEmpty()) , _root(root) , _alternatives() , _specVarNumbers() @@ -1330,14 +1210,17 @@ class SubstitutionTree { CALL("SubstitutionTree::FastInstancesIterator::FastInstancesIterator"); ASS(root); - ASS(!root->isLeaf()); parent->createBindings(query, reversed, - [&](unsigned var, TermList t) { _subst->bindSpecialVar(var, t); }); + [&](unsigned var, TermList t) { _subst.bindSpecialVar(var, t); }); + + if (_inLeaf) { + _subst.onLeafEntered(); //we reset the bindings cache + } } bool hasNext(); - QueryResult next(); + QueryResultIter next(); protected: bool findNextLeaf(); @@ -1350,7 +1233,7 @@ class SubstitutionTree bool _inLeaf; LDIterator _ldIterator; - Recycled _subst; + InstMatcher _subst; Renaming _resultDenormalizer; Node* _root; @@ -1361,39 +1244,24 @@ class SubstitutionTree InstanceCntr _iterCntr; }; - class SubstitutionTreeMismatchHandler : public UWAMismatchHandler + // currently, the iterator makes use of RobSubstitutionTL + // so tree unification cannot involve termspecs, only TermLists + // This has a minor performance drawback, so what should be done + // is to template this Iterator with a substitution to allow it to be + // use with either RobSubstitutionTL or RobSubstitutionTS (or any other substitution) + template + class TreeIterator final + : public IteratorCore { public: - SubstitutionTreeMismatchHandler(Stack& c, BacktrackData& bd) : - UWAMismatchHandler(c), _constraints(c), _bd(bd) {} - //virtual bool handle(RobSubstitution* subst, TermList query, unsigned index1, TermList node, unsigned index2); - private: - virtual bool introduceConstraint(TermList t1,unsigned index1, TermList t2,unsigned index2); - Stack& _constraints; - BacktrackData& _bd; - }; +// UnificationsIterator(UnificationsIterator&&) = default; +// UnificationsIterator& operator=(UnificationsIterator&&) = default; + DECL_ELEMENT_TYPE(QueryResultIter); - class STHOMismatchHandler : public HOMismatchHandler - { - public: - STHOMismatchHandler(Stack& c, BacktrackData& bd) : - HOMismatchHandler(c), _constraints(c), _bd(bd) {} - virtual bool handle(RobSubstitution* subst, TermList query, unsigned index1, TermList node, unsigned index2); - private: - Stack& _constraints; - BacktrackData& _bd; - }; - - class UnificationsIterator - { - public: - UnificationsIterator(UnificationsIterator&&) = default; - UnificationsIterator& operator=(UnificationsIterator&&) = default; - DECL_ELEMENT_TYPE(QueryResult); - - template - UnificationsIterator(SubstitutionTree* parent, Node* root, TermOrLit query, bool retrieveSubstitution, bool reversed, bool useC, FuncSubtermMap* funcSubtermMap) + template + TreeIterator(SubstitutionTree* parent, Node* root, TermOrLit query, bool retrieveSubstitution, bool reversed, AlgoArgs... args) : _subst() + , _algo(std::move(args)...) , _svStack() , _literalRetrieval(std::is_same::value) , _retrieveSubstitution(retrieveSubstitution) @@ -1402,33 +1270,25 @@ class SubstitutionTree , _nodeIterators() , _bdStack() , _clientBDRecording(false) - , _useUWAConstraints(useC) - , _useHOConstraints(funcSubtermMap) - , _constraints() , _iterCntr(parent->_iterCnt) #if VDEBUG , _tag(parent->_tag) #endif { -#define DEBUG_QUERY(...) // DBG(__VA_ARGS__) - CALL("SubstitutionTree::UnificationsIterator::UnificationsIterator"); - - ASS(!_useUWAConstraints || retrieveSubstitution); - ASS(!_useUWAConstraints || parent->_useC); +#define DEBUG_QUERY(...) //DBG(__VA_ARGS__) + CALL("SubstitutionTree::UnificationsIterator::TreeIterator"); if(!root) { return; } - if(funcSubtermMap){ - _subst->setMap(funcSubtermMap); - query = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(query, funcSubtermMap); - } + _algo.initSub(&*_subst); - parent->createBindings(query, reversed, - [&](unsigned var, TermList t) { _subst->bindSpecialVar(var, t, QUERY_BANK); }); - DEBUG_QUERY("query: ", subst) + query = ToBank(QUERY_BANK).toBank(query); + parent->createBindings(query, reversed, + [&](unsigned var, TermList t) { _subst->bindSpecialVar(var, t); }); + DEBUG_QUERY("query: ", *_subst); BacktrackData bd; enter(root, bd); @@ -1436,26 +1296,191 @@ class SubstitutionTree } - ~UnificationsIterator(); + ~TreeIterator() + { + CALL("SubstitutionTree::UnificationsIterator::~TreeIterator"); - bool hasNext(); - QueryResult next(); - protected: - virtual bool associate(TermList query, TermList node, BacktrackData& bd); - virtual NodeIterator getNodeIterator(IntermediateNode* n); + if(_clientBDRecording) { + _subst->bdDone(); + _clientBDRecording=false; + _clientBacktrackData.backtrack(); + } + // if (_bdStack) + while(_bdStack->isNonEmpty()) { + _bdStack->pop().backtrack(); + } + } - bool findNextLeaf(); - bool enter(Node* n, BacktrackData& bd); + bool hasNext() + { + CALL("SubstitutionTree::TreeIterator::hasNext"); + if(_clientBDRecording) { + _subst->bdDone(); + _clientBDRecording=false; + _clientBacktrackData.backtrack(); + } - static const int QUERY_BANK=0; - static const int RESULT_BANK=1; - static const int NORM_RESULT_BANK=3; + while(!_ldIterator.hasNext() && findNextLeaf()) {} + return _ldIterator.hasNext(); + } - Recycled _subst; - Recycled _svStack; + QueryResultIter next() + { + CALL("SubstitutionTree::TreeIterator::next"); + + while(!_ldIterator.hasNext() && findNextLeaf()) {} + ASS(_ldIterator.hasNext()); + + ASS(!_clientBDRecording); + + auto ld = _ldIterator.next(); + // TODO resolve this kinda messy bit + if (_retrieveSubstitution) { + Renaming normalizer; + if(_literalRetrieval) { + normalizer.normalizeVariables(ld->literal); + } else { + normalizer.normalizeVariables(ld->term); + ASS (ld->sort.isNonEmpty()); + normalizer.normalizeVariables(ld->sort); + } + + ASS(_clientBacktrackData.isEmpty()); + _subst->bdRecord(_clientBacktrackData); + _clientBDRecording=true; + + _subst->denormalize(normalizer,NORM_RESULT_BANK,RESULT_BANK); + } + + // postprocess in the leaf + // For syntactic first-order unification postprocessing just wraps + // the single unifier into an iterator + // For UWA, if fixed point iteration has been chosen, this is carried out + // For HOL, a set of HOL unifiers are returned + SubstIterator substs = _algo.postprocess(&*_subst, ld->term, ld->sort); + return pvi(iterTraits(substs).map([ld](RobSubstitutionTL* subst){ + return QueryResult(ld, + ResultSubstitution::fromSubstitution(subst,QUERY_BANK,RESULT_BANK)); + })); + } private: + + NodeIterator getNodeIterator(IntermediateNode* n) + { + CALL("SubstitutionTree::TreeIterator::getNodeIterator"); + + // TODO rename usesUwa to something more self explanatory + if (_algo.usesUwa()) { + return n->allChildren(); + } + + unsigned specVar=n->childVar; + // TermList qt = _abstractingUnifier.subs().getSpecialVarTop(specVar); + // TODO should this function really be part of algo? + auto top = _subst->getSpecialVarTop(specVar); + if(top.var() || top.id() +#if VHOL + || env.signature->isPlaceholder(*top.functor()) +#endif + ) { + return n->allChildren(); + } else { + Node** match=n->childByTop(top, false); + if(match) { + return pvi( + getConcatenatedIterator( + getSingletonIterator(match), + n->variableChildren() + )); + } else { + return n->variableChildren(); + } + } + } + + bool findNextLeaf() + { + CALL("SubstitutionTree::TreeIterator::findNextLeaf"); + + if(_nodeIterators->isEmpty()) { + //There are no node iterators in the stack, so there's nowhere + //to look for the next leaf. + //This shouldn't hapen during the regular retrieval process, but it + //can happen when there are no literals inserted for a predicate, + //or when predicates with zero arity are encountered. + ASS(_bdStack->isEmpty()); + return false; + } + + if(_inLeaf) { + ASS(!_clientBDRecording); + //Leave the current leaf + _bdStack->pop().backtrack(); + _inLeaf=false; + } + + ASS(!_clientBDRecording); + ASS(_bdStack->length()+1==_nodeIterators->length()); + + do { + while(!_nodeIterators->top().hasNext() && !_bdStack->isEmpty()) { + //backtrack undos everything that enter(...) method has done, + //so it also pops one item out of the nodeIterators stack + _bdStack->pop().backtrack(); + _svStack->pop(); + } + if(!_nodeIterators->top().hasNext()) { + return false; + } + Node* n=*_nodeIterators->top().next(); + + BacktrackData bd; + bool success=enter(n,bd); + if(!success) { + bd.backtrack(); + continue; + } else { + _bdStack->push(bd); + } + } while(!_inLeaf); + return true; + } + + bool enter(Node* n, BacktrackData& bd) + { + CALL("SubstitutionTree::TreeIterator::enter"); + + bool success=true; + bool recording=false; + if(!n->term.isEmpty()) { + //n is proper node, not a root + recording=true; + _subst->bdRecord(bd); + success = _algo.associate(_svStack->top(),n->term,&*_subst); + } + if(success) { + if(n->isLeaf()) { + _ldIterator=static_cast(n)->allChildren(); + _inLeaf=true; + } else { + IntermediateNode* inode=static_cast(n); + _svStack->push(inode->childVar); + backtrackablePush(*_nodeIterators, getNodeIterator(inode), bd); + } + } + if(recording) { + _subst->bdDone(); + } + + return success; + } + + Recycled _subst; + + UnificationAlgorithm _algo; + Recycled _svStack; bool _literalRetrieval; bool _retrieveSubstitution; bool _inLeaf; @@ -1464,21 +1489,17 @@ class SubstitutionTree Recycled> _bdStack; bool _clientBDRecording; BacktrackData _clientBacktrackData; - bool _useUWAConstraints; - bool _useHOConstraints; - Recycled _constraints; InstanceCntr _iterCntr; #if VDEBUG bool _tag; #endif }; -#if VDEBUG + public: - bool isEmpty() const; -#endif + bool isEmpty() const { return _root == nullptr || _root->isEmpty(); } + friend std::ostream& operator<<(std::ostream& out, SubstitutionTree const& self); - Cntr _iterCnt; }; // class SubstiutionTree template<> @@ -1498,6 +1519,7 @@ struct SubtitutionTreeConfig +using RobUnificationsIterator = SubstitutionTree::TreeIterator; } // namespace Indexing diff --git a/Indexing/SubstitutionTree_FastGen.cpp b/Indexing/SubstitutionTree_FastGen.cpp index dee8a5ff2a..62534898b9 100644 --- a/Indexing/SubstitutionTree_FastGen.cpp +++ b/Indexing/SubstitutionTree_FastGen.cpp @@ -173,6 +173,7 @@ bool SubstitutionTree::GenMatcher::matchNextAux(TermList queryTerm, TermList nod CALL("SubstitutionTree::GenMatcher::matchNextAux"); bool success; + if(nodeTerm.isTerm()) { Term* nt=nodeTerm.term(); if(nt->shared() && nt->ground()) { @@ -183,7 +184,7 @@ bool SubstitutionTree::GenMatcher::matchNextAux(TermList queryTerm, TermList nod ASS(nt->arity()>0); success = queryTerm.isTerm() && queryTerm.term()->functor()==nt->functor() && - MatchingUtils::matchArgs(nt, queryTerm.term(), binder); + MatchingUtils::matchArgs(nt, queryTerm.term(), binder); } } else { ASS_METHOD(nodeTerm,isOrdinaryVar()); @@ -199,11 +200,11 @@ bool SubstitutionTree::GenMatcher::matchNextAux(TermList queryTerm, TermList nod if(separate) { //we have to unbind ordinary variables, that were bound. for(;;) { - unsigned boundVar = _boundVars->pop(); - if(boundVar==BACKTRACK_SEPARATOR) { - break; - } - _bindings->remove(boundVar); + unsigned boundVar = _boundVars->pop(); + if(boundVar==BACKTRACK_SEPARATOR) { + break; + } + _bindings->remove(boundVar); } } } @@ -258,7 +259,6 @@ ResultSubstitutionSP SubstitutionTree::GenMatcher::getSubstitution( } - bool SubstitutionTree::FastGeneralizationsIterator::hasNext() { CALL("SubstitutionTree::FastGeneralizationsIterator::hasNext"); @@ -267,25 +267,27 @@ bool SubstitutionTree::FastGeneralizationsIterator::hasNext() return _ldIterator.hasNext(); } -SubstitutionTree::QueryResult SubstitutionTree::FastGeneralizationsIterator::next() +SubstitutionTree::QueryResultIter SubstitutionTree::FastGeneralizationsIterator::next() { CALL("SubstitutionTree::FastGeneralizationsIterator::next"); while(!_ldIterator.hasNext() && findNextLeaf()) {} ASS(_ldIterator.hasNext()); - LeafData& ld=_ldIterator.next(); + auto ld = _ldIterator.next(); if(_retrieveSubstitution) { _resultNormalizer->reset(); if(_literalRetrieval) { - _resultNormalizer->normalizeVariables(ld.literal); + _resultNormalizer->normalizeVariables(ld->literal); } else { - _resultNormalizer->normalizeVariables(ld.term); + _resultNormalizer->normalizeVariables(ld->term); } - return QueryResult(ld,_subst.getSubstitution(&*_resultNormalizer),UnificationConstraintStackSP()); + // TODO update this once we make matching iterators templated on matching algorithm + // or remove altogether if we go with Joe's refactor + return pvi(getSingletonIterator(QueryResult(ld,_subst.getSubstitution(&*_resultNormalizer)))); } else { - return QueryResult(ld); + return pvi(getSingletonIterator(QueryResult(ld, ResultSubstitutionSP()))); } } @@ -322,23 +324,23 @@ bool SubstitutionTree::FastGeneralizationsIterator::findNextLeaf() if(curr) { if(sibilingsRemain) { - ASS(_nodeTypes->top()!=UNSORTED_LIST || *static_cast(_alternatives->top())); - currSpecVar=_specVarNumbers->top(); + ASS(_nodeTypes->top()!=UNSORTED_LIST || *static_cast(_alternatives->top())); + currSpecVar=_specVarNumbers->top(); } else { - currSpecVar=_specVarNumbers->pop(); + currSpecVar=_specVarNumbers->pop(); } } //let's find a node we haven't been to... while(curr==0 && _alternatives->isNonEmpty()) { void* currAlt=_alternatives->pop(); if(!currAlt) { - //there's no alternative at this level, we have to backtrack - _nodeTypes->pop(); - _specVarNumbers->pop(); - if(_alternatives->isNonEmpty()) { - _subst.backtrack(); - } - continue; + //there's no alternative at this level, we have to backtrack + _nodeTypes->pop(); + _specVarNumbers->pop(); + if(_alternatives->isNonEmpty()) { + _subst.backtrack(); + } + continue; } NodeAlgorithm parentType=_nodeTypes->top(); @@ -346,42 +348,42 @@ bool SubstitutionTree::FastGeneralizationsIterator::findNextLeaf() //proper term nodes that we want to enter don't appear //on _alternatives stack (as we always enter them first) if(parentType==UNSORTED_LIST) { - Node** alts=static_cast(currAlt); - while(*alts && !(*alts)->term.isVar()) { - alts++; - } - curr=*(alts++); - while(*alts && !(*alts)->term.isVar()) { - alts++; - } - if(*alts) { - _alternatives->push(alts); - sibilingsRemain=true; - } else { - sibilingsRemain=false; - } + Node** alts=static_cast(currAlt); + while(*alts && !(*alts)->term.isVar()) { + alts++; + } + curr=*(alts++); + while(*alts && !(*alts)->term.isVar()) { + alts++; + } + if(*alts) { + _alternatives->push(alts); + sibilingsRemain=true; + } else { + sibilingsRemain=false; + } } else { - ASS_EQ(parentType,SKIP_LIST) - auto alts = static_cast(currAlt); - if(alts->head()->term.isVar()) { - curr=alts->head(); - if(alts->tail() && alts->tail()->head()->term.isVar()) { - _alternatives->push(alts->tail()); - sibilingsRemain=true; - } else { - sibilingsRemain=false; - } - } + ASS_EQ(parentType,SKIP_LIST) + auto alts = static_cast(currAlt); + if(alts->head()->term.isVar()) { + curr=alts->head(); + if(alts->tail() && alts->tail()->head()->term.isVar()) { + _alternatives->push(alts->tail()); + sibilingsRemain=true; + } else { + sibilingsRemain=false; + } + } } if(sibilingsRemain) { - currSpecVar=_specVarNumbers->top(); + currSpecVar=_specVarNumbers->top(); } else { - _nodeTypes->pop(); - currSpecVar=_specVarNumbers->pop(); + _nodeTypes->pop(); + currSpecVar=_specVarNumbers->pop(); } if(curr) { - break; + break; } } if(!curr) { @@ -403,14 +405,14 @@ bool SubstitutionTree::FastGeneralizationsIterator::findNextLeaf() ASS(curr); ASSERT_VALID(*curr); if(!_subst.matchNext(specVar, curr->term, false)) { - //matching failed, let's go back to the node, that had multiple children - //_subst->backtrack(); - if(sibilingsRemain || _alternatives->isNonEmpty()) { - //this backtrack can happen for two different reasons and have two different meanings: - //either matching at [1] was separated from the previous one and we're backtracking it, - //or it was not, which means it had no sibilings and we're backtracking from its parent. - _subst.backtrack(); - } + //matching failed, let's go back to the node, that had multiple children + //_subst->backtrack(); + if(sibilingsRemain || _alternatives->isNonEmpty()) { + //this backtrack can happen for two different reasons and have two different meanings: + //either matching at [1] was separated from the previous one and we're backtracking it, + //or it was not, which means it had no sibilings and we're backtracking from its parent. + _subst.backtrack(); + } curr=0; goto main_loop_start; } @@ -499,7 +501,7 @@ bool SubstitutionTree::FastGeneralizationsIterator::enterNode(Node*& curr) ASS_EQ(currType, SKIP_LIST); auto nl=static_cast(inode)->_nodes.listLike(); if(binding.isTerm()) { - Node** byTop=inode->childByTop(binding, false); + Node** byTop=inode->childByTop(binding.top(), false); if(byTop) { curr=*byTop; } diff --git a/Indexing/SubstitutionTree_FastInst.cpp b/Indexing/SubstitutionTree_FastInst.cpp index cdac2b9bbb..475069e606 100644 --- a/Indexing/SubstitutionTree_FastInst.cpp +++ b/Indexing/SubstitutionTree_FastInst.cpp @@ -95,14 +95,14 @@ TermList SubstitutionTree::InstMatcher::derefQueryBinding(unsigned var) TermSpec varBinding; { TermList val; - if(_derefBindings.find(tvar, val)) { + if(_derefBindings->find(tvar, val)) { return val; } //only bound values can be passed to this function - ALWAYS(_bindings.find(tvar, varBinding)); + ALWAYS(_bindings->find(tvar, varBinding)); if(varBinding.isFinal()) { - ALWAYS(_derefBindings.insert(tvar, varBinding.t)); + ALWAYS(_derefBindings->insert(tvar, varBinding.t)); return varBinding.t; } } @@ -118,14 +118,14 @@ TermList SubstitutionTree::InstMatcher::derefQueryBinding(unsigned var) TermList bvar=varBinding.t; TermList derefBoundTerm; - if(_derefBindings.find(bvar, derefBoundTerm)) { - ALWAYS(_derefBindings.insert(tvar, derefBoundTerm)); + if(_derefBindings->find(bvar, derefBoundTerm)) { + ALWAYS(_derefBindings->insert(tvar, derefBoundTerm)); } - ALWAYS(_bindings.find(bvar,varBinding)); + ALWAYS(_bindings->find(bvar,varBinding)); } if(varBinding.isFinal()) { - ALWAYS(_derefBindings.insert(tvar, varBinding.t)); + ALWAYS(_derefBindings->insert(tvar, varBinding.t)); goto next_loop; } { @@ -133,13 +133,13 @@ TermList SubstitutionTree::InstMatcher::derefQueryBinding(unsigned var) toDo.push(DerefTask(tvar, varBinding)); VariableIterator vit(varBinding.t); while(vit.hasNext()) { - TermList btv=vit.next(); //bound term variable - if(varBinding.q || btv.isSpecialVar()) { - ASS(_bindings.find(btv)); - if(!_derefBindings.find(btv)) { - toDo.push(DerefTask(btv)); - } - } + TermList btv=vit.next(); //bound term variable + if(varBinding.q || btv.isSpecialVar()) { + ASS(_bindings->find(btv)); + if(!_derefBindings->find(btv)) { + toDo.push(DerefTask(btv)); + } + } } } next_loop: @@ -149,15 +149,15 @@ TermList SubstitutionTree::InstMatcher::derefQueryBinding(unsigned var) DerefApplicator applicator(this, tspec.q); TermList derefTerm=SubstHelper::applySV(tspec.t, applicator); ASS_REP(!derefTerm.isTerm() || derefTerm.term()->shared(), derefTerm); - ALWAYS(_derefBindings.insert(tvar, derefTerm)); + ALWAYS(_derefBindings->insert(tvar, derefTerm)); } if(toDo.isEmpty()) { break; } tvar=toDo.pop().var; - ALWAYS(_bindings.find(tvar, varBinding)); + ALWAYS(_bindings->find(tvar, varBinding)); }; - return _derefBindings.get(tvar0); + return _derefBindings->get(tvar0); } SubstitutionTree::InstMatcher::TermSpec SubstitutionTree::InstMatcher::deref(TermList var) @@ -170,7 +170,7 @@ SubstitutionTree::InstMatcher::TermSpec SubstitutionTree::InstMatcher::deref(Ter #endif for(;;) { TermSpec res; - if(!_bindings.find(var, res)) { + if(!_bindings->find(var, res)) { return TermSpec(var.isOrdinaryVar() ? true : false, var); } if( res.t.isTerm() || (!res.q && res.t.isOrdinaryVar()) ) { @@ -194,11 +194,11 @@ void SubstitutionTree::InstMatcher::backtrack() CALL("SubstitutionTree::InstMatcher::backtrack"); for(;;) { - TermList boundVar=_boundVars.pop(); + TermList boundVar=_boundVars->pop(); if(boundVar.isEmpty()) { break; } - _bindings.remove(boundVar); + _bindings->remove(boundVar); } } @@ -213,12 +213,12 @@ bool SubstitutionTree::InstMatcher::tryBacktrack() { CALL("SubstitutionTree::InstMatcher::tryBacktrack"); - while(_boundVars.isNonEmpty()) { - TermList boundVar=_boundVars.pop(); + while(_boundVars->isNonEmpty()) { + TermList boundVar=_boundVars->pop(); if(boundVar.isEmpty()) { return true; } - _bindings.remove(boundVar); + _bindings->remove(boundVar); } return false; } @@ -231,7 +231,7 @@ bool SubstitutionTree::InstMatcher::matchNext(unsigned specVar, TermList nodeTer if(separate) { TermList sep; sep.makeEmpty(); - _boundVars.push(sep); + _boundVars->push(sep); } #if VDEBUG @@ -308,8 +308,8 @@ bool SubstitutionTree::InstMatcher::matchNextAux(TermList queryTerm, TermList no bool dt2Bindable= !dt2.isTerm() && (ts2.q || !dt2.isOrdinaryVar()); if(!dt1Bindable && !dt2Bindable) { - success=false; - goto finish; + success=false; + goto finish; } //we try to bind ordinary variables first, as binding a special @@ -318,34 +318,34 @@ bool SubstitutionTree::InstMatcher::matchNextAux(TermList queryTerm, TermList no //may come later, so we want to keep it unbound) if(ts1.q && dt1.isOrdinaryVar() && !isBound(dt1)) { - bind(dt1, TermSpec(ts2.q,dt2)); - continue; + bind(dt1, TermSpec(ts2.q,dt2)); + continue; } if(ts2.q && dt2.isOrdinaryVar() && !isBound(dt2)) { - bind(dt2, TermSpec(ts1.q,dt1)); - continue; + bind(dt2, TermSpec(ts1.q,dt1)); + continue; } if(dt2.isSpecialVar() && !isBound(dt2)) { - ASS(!ts2.q); - bind(dt2, TermSpec(ts1.q,dt1)); - continue; + ASS(!ts2.q); + bind(dt2, TermSpec(ts1.q,dt1)); + continue; } if(dt1.isSpecialVar() && !isBound(dt1)) { - ASS(!ts1.q); - bind(dt1, TermSpec(ts2.q,dt2)); - continue; + ASS(!ts1.q); + bind(dt1, TermSpec(ts2.q,dt2)); + continue; } TermSpec deref1=TermSpec(ts1.q, dt1); TermSpec deref2=TermSpec(ts2.q, dt2); if(dt1Bindable) { - ASS(isBound(dt1)); //if unbound, we would have assigned it earlier - deref1=deref(dt1); + ASS(isBound(dt1)); //if unbound, we would have assigned it earlier + deref1=deref(dt1); } if(dt2Bindable) { - ASS(isBound(dt2)); - deref2=deref(dt2); + ASS(isBound(dt2)); + deref2=deref(dt2); } toDo.push(make_pair(deref1, deref2)); @@ -377,32 +377,33 @@ bool SubstitutionTree::FastInstancesIterator::hasNext() #undef LOGGING #define LOGGING 0 -SubstitutionTree::QueryResult SubstitutionTree::FastInstancesIterator::next() +SubstitutionTree::QueryResultIter SubstitutionTree::FastInstancesIterator::next() { CALL("SubstitutionTree::FastInstancesIterator::next"); while(!_ldIterator.hasNext() && findNextLeaf()) {} ASS(_ldIterator.hasNext()); - LeafData& ld=_ldIterator.next(); + auto ld = _ldIterator.next(); if(_retrieveSubstitution) { _resultDenormalizer.reset(); bool ground=_literalRetrieval - ? ld.literal->ground() - : (ld.term.isTerm() && ld.term.term()->ground()); + ? ld->literal->ground() + : (ld->term.isTerm() && ld->term.term()->ground()); if(!ground) { - Renaming normalizer; + Renaming normalizer(0, NORM_RESULT_BANK); if(_literalRetrieval) { - normalizer.normalizeVariables(ld.literal); + normalizer.normalizeVariables(ld->literal); } else { - normalizer.normalizeVariables(ld.term); + normalizer.normalizeVariables(ld->term); } _resultDenormalizer.makeInverse(normalizer); } - - return QueryResult(ld, _subst->getSubstitution(&_resultDenormalizer),UnificationConstraintStackSP()); + // TODO update this once we make matching iterators templated on matching algorithm + // or remove altogether if we go with Joe's refactor + return pvi(getSingletonIterator(QueryResult(ld, _subst.getSubstitution(&_resultDenormalizer)))); } else { - return QueryResult(ld, ResultSubstitutionSP(),UnificationConstraintStackSP()); + return pvi(getSingletonIterator(QueryResult(ld, ResultSubstitutionSP()))); } } #undef LOGGING @@ -422,7 +423,7 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() if(_alternatives->isEmpty()) { return false; } - _subst->backtrack(); + _subst.backtrack(); _inLeaf=false; curr=0; } else { @@ -455,9 +456,9 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() _nodeTypes->pop(); _specVarNumbers->pop(); if(_alternatives->isNonEmpty()) { - _subst->backtrack(); - } - continue; + _subst.backtrack(); + } + continue; } NodeAlgorithm parentType = _nodeTypes->top(); @@ -466,26 +467,26 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() //matching by a variable (as there is always at most one child //for matching by term) if(parentType==UNSORTED_LIST) { - Node** alts=static_cast(currAlt); - curr=*(alts++); - if(*alts) { - _alternatives->push(alts); - sibilingsRemain=true; - } else { - sibilingsRemain=false; - } + Node** alts=static_cast(currAlt); + curr=*(alts++); + if(*alts) { + _alternatives->push(alts); + sibilingsRemain=true; + } else { + sibilingsRemain=false; + } } else { - ASS_EQ(parentType,SKIP_LIST) - auto alts = static_cast(currAlt); - ASS(alts); - - curr=alts->head(); - if(alts->tail()) { - _alternatives->push(alts->tail()); - sibilingsRemain=true; - } else { - sibilingsRemain=false; - } + ASS_EQ(parentType,SKIP_LIST) + auto alts = static_cast(currAlt); + ASS(alts); + + curr=alts->head(); + if(alts->tail()) { + _alternatives->push(alts->tail()); + sibilingsRemain=true; + } else { + sibilingsRemain=false; + } } if(sibilingsRemain) { @@ -501,11 +502,11 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() //there are no other alternatives return false; } - if(!_subst->matchNext(currSpecVar, curr->term, sibilingsRemain)) { //[1] + if(!_subst.matchNext(currSpecVar, curr->term, sibilingsRemain)) { //[1] //match unsuccessful, try next alternative curr=0; if(!sibilingsRemain && _alternatives->isNonEmpty()) { - _subst->backtrack(); + _subst.backtrack(); } continue; } @@ -515,15 +516,15 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() curr=static_cast(curr)->_nodes[0]; ASS(curr); ASSERT_VALID(*curr); - if(!_subst->matchNext(specVar, curr->term, false)) { - //matching failed, let's go back to the node, that had multiple children - //_subst->backtrack(); - if(sibilingsRemain || _alternatives->isNonEmpty()) { - //this backtrack can happen for two different reasons and have two different meanings: - //either matching at [1] was separated from the previous one and we're backtracking it, - //or it was not, which means it had no sibilings and we're backtracking from its parent. - _subst->backtrack(); - } + if(!_subst.matchNext(specVar, curr->term, false)) { + //matching failed, let's go back to the node, that had multiple children + //_subst.backtrack(); + if(sibilingsRemain || _alternatives->isNonEmpty()) { + //this backtrack can happen for two different reasons and have two different meanings: + //either matching at [1] was separated from the previous one and we're backtracking it, + //or it was not, which means it had no sibilings and we're backtracking from its parent. + _subst.backtrack(); + } curr=0; goto main_loop_start; } @@ -532,14 +533,14 @@ bool SubstitutionTree::FastInstancesIterator::findNextLeaf() //we've found a leaf _ldIterator=static_cast(curr)->allChildren(); _inLeaf=true; - _subst->onLeafEntered(); //we reset the bindings cache + _subst.onLeafEntered(); //we reset the bindings cache return true; } //let's go to the first child sibilingsRemain=enterNode(curr); if(curr==0 && _alternatives->isNonEmpty()) { - _subst->backtrack(); + _subst.backtrack(); } } } @@ -570,7 +571,7 @@ bool SubstitutionTree::FastInstancesIterator::enterNode(Node*& curr) InstMatcher::TermSpec querySpec; //here we are interested only in the top functor or the fact that the query is a variable //so we can discard the information about term origin - if(_subst->findSpecVarBinding(inode->childVar, querySpec)) { + if(_subst.findSpecVarBinding(inode->childVar, querySpec)) { query=querySpec.t; } else { @@ -591,8 +592,8 @@ bool SubstitutionTree::FastInstancesIterator::enterNode(Node*& curr) } if(*nl) { - //we've found the term with the same top functor - ASS_EQ((*nl)->term.term()->functor(),bindingFunctor); + //we've found the term with the same top functor + ASS_EQ((*nl)->term.term()->functor(),bindingFunctor); curr=*nl; noAlternatives=true; //there is at most one term with each top functor } @@ -617,9 +618,9 @@ bool SubstitutionTree::FastInstancesIterator::enterNode(Node*& curr) ASS(nl); //inode is not empty if(query.isTerm()) { //only term with the same top functor will be matched by a term - Node** byTop=inode->childByTop(query, false); + Node** byTop=inode->childByTop(query.top(), false); if(byTop) { - curr=*byTop; + curr=*byTop; } nl=0; } diff --git a/Indexing/SubstitutionTree_Nodes.cpp b/Indexing/SubstitutionTree_Nodes.cpp index 1826b802ea..5412c71f44 100644 --- a/Indexing/SubstitutionTree_Nodes.cpp +++ b/Indexing/SubstitutionTree_Nodes.cpp @@ -36,7 +36,7 @@ class SubstitutionTree::UListLeaf inline UListLeaf() : _children(0), _size(0) {} inline - UListLeaf(TermList ts) : Leaf(ts), _children(0), _size(0) {} + UListLeaf(TermList ts, bool splittable = true) : Leaf(ts, splittable), _children(0), _size(0) {} ~UListLeaf() { LDList::destroy(_children); @@ -51,7 +51,7 @@ class SubstitutionTree::UListLeaf inline LDIterator allChildren() { - return pvi( LDList::RefIterator(_children) ); + return pvi( iterTraits(LDList::RefIterator(_children)).map([](auto& x) { return &x; }) ); } inline void insert(LeafData ld) @@ -82,7 +82,7 @@ class SubstitutionTree::SListLeaf { public: SListLeaf() {} - SListLeaf(TermList ts) : Leaf(ts) {} + SListLeaf(TermList ts, bool splittable = true) : Leaf(ts, splittable) {} static SListLeaf* assimilate(Leaf* orig); @@ -97,7 +97,7 @@ class SubstitutionTree::SListLeaf inline LDIterator allChildren() { - return pvi( LDSkipList::RefIterator(_children) ); + return pvi( iterTraits(LDSkipList::RefIterator(_children)).map([](auto& x) { return &x; }) ); } void insert(LeafData ld) { CALL("SubstitutionTree::SListLeaf::insert"); @@ -123,23 +123,21 @@ SubstitutionTree::Leaf* SubstitutionTree::createLeaf() return new UListLeaf(); } -SubstitutionTree::Leaf* SubstitutionTree::createLeaf(TermList ts) +SubstitutionTree::Leaf* SubstitutionTree::createLeaf(TermList ts, bool splittable) { - return new UListLeaf(ts); + return new UListLeaf(ts, splittable); } -SubstitutionTree::IntermediateNode* SubstitutionTree::createIntermediateNode(unsigned childVar,bool useC) +SubstitutionTree::IntermediateNode* SubstitutionTree::createIntermediateNode(unsigned childVar) { CALL("SubstitutionTree::createIntermediateNode/2"); - if(useC){ return new UArrIntermediateNodeWithSorts(childVar); } return new UArrIntermediateNode(childVar); } -SubstitutionTree::IntermediateNode* SubstitutionTree::createIntermediateNode(TermList ts, unsigned childVar,bool useC) +SubstitutionTree::IntermediateNode* SubstitutionTree::createIntermediateNode(TermList ts, unsigned childVar, bool splittable) { CALL("SubstitutionTree::createIntermediateNode/3"); - if(useC){ return new UArrIntermediateNodeWithSorts(ts, childVar); } - return new UArrIntermediateNode(ts, childVar); + return new UArrIntermediateNode(ts, childVar, splittable); } void SubstitutionTree::IntermediateNode::destroyChildren() @@ -163,17 +161,16 @@ void SubstitutionTree::IntermediateNode::destroyChildren() } } -SubstitutionTree::Node** SubstitutionTree::UArrIntermediateNode::childByTop(TermList t, bool canCreate) +SubstitutionTree::Node** SubstitutionTree::UArrIntermediateNode::childByTop(TermList::Top t, bool canCreate) { CALL("SubstitutionTree::UArrIntermediateNode::childByTop"); - + for(int i=0;i<_size;i++) { - if(TermList::sameTop(t, _nodes[i]->term)) { + if(t == _nodes[i]->top()) { return &_nodes[i]; } } if(canCreate) { - mightExistAsTop(t); ASS_L(_size,UARR_INTERMEDIATE_NODE_MAX_SIZE); ASS_EQ(_nodes[_size],0); _nodes[++_size]=0; @@ -182,12 +179,12 @@ SubstitutionTree::Node** SubstitutionTree::UArrIntermediateNode::childByTop(Term return 0; } -void SubstitutionTree::UArrIntermediateNode::remove(TermList t) +void SubstitutionTree::UArrIntermediateNode::remove(TermList::Top t) { CALL("SubstitutionTree::UArrIntermediateNode::remove"); for(int i=0;i<_size;i++) { - if(TermList::sameTop(t, _nodes[i]->term)) { + if(t == _nodes[i]->top()) { _size--; _nodes[i]=_nodes[_size]; _nodes[_size]=0; @@ -206,13 +203,7 @@ SubstitutionTree::IntermediateNode* SubstitutionTree::SListIntermediateNode { CALL("SubstitutionTree::SListIntermediateNode::assimilate"); - IntermediateNode* res= 0; - if(orig->withSorts()){ - res = new SListIntermediateNodeWithSorts(orig->term, orig->childVar); - res->_childBySortHelper->loadFrom(orig->_childBySortHelper); - }else{ - res = new SListIntermediateNode(orig->term, orig->childVar); - } + IntermediateNode* res = new SListIntermediateNode(orig->term, orig->childVar, orig->splittable()); res->loadChildren(orig->allChildren()); orig->makeEmpty(); delete orig; @@ -227,7 +218,7 @@ SubstitutionTree::SListLeaf* SubstitutionTree::SListLeaf::assimilate(Leaf* orig) { CALL("SubstitutionTree::SListLeaf::assimilate"); - SListLeaf* res=new SListLeaf(orig->term); + SListLeaf* res=new SListLeaf(orig->term, orig->splittable()); res->loadChildren(orig->allChildren()); orig->makeEmpty(); delete orig; diff --git a/Indexing/TermIndex.cpp b/Indexing/TermIndex.cpp index 7f336e758f..b5e303c62d 100644 --- a/Indexing/TermIndex.cpp +++ b/Indexing/TermIndex.cpp @@ -26,7 +26,6 @@ #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" -#include "Shell/LambdaElimination.hpp" #include "Indexing/TermSubstitutionTree.hpp" #include "TermIndex.hpp" @@ -37,20 +36,6 @@ using namespace Lib; using namespace Kernel; using namespace Inferences; -TermIndex::~TermIndex() -{ - delete _is; -} - -TermQueryResultIterator TermIndex::getUnifications(TypedTermList t, bool retrieveSubstitutions, bool withConstraints) -{ return _is->getUnifications(t, retrieveSubstitutions, withConstraints); } - -TermQueryResultIterator TermIndex::getGeneralizations(TypedTermList t, bool retrieveSubstitutions) -{ return _is->getGeneralizations(t, retrieveSubstitutions); } - -TermQueryResultIterator TermIndex::getInstances(TypedTermList t, bool retrieveSubstitutions) -{ return _is->getInstances(t, retrieveSubstitutions); } - void SuperpositionSubtermIndex::handleClause(Clause* c, bool adding) { CALL("SuperpositionSubtermIndex::handleClause"); @@ -60,14 +45,22 @@ void SuperpositionSubtermIndex::handleClause(Clause* c, bool adding) unsigned selCnt=c->numSelected(); for (unsigned i=0; icombinatorySup() ? EqHelper::getFoSubtermIterator(lit,_ord) - : EqHelper::getSubtermIterator(lit,_ord); + VirtualIterator rsti; +#if VHOL + if(!env.property->higherOrder()){ +#endif + rsti = EqHelper::getSubtermIterator(lit,_ord); +#if VHOL + } else { + rsti = EqHelper::getFoSubtermIterator(lit,_ord); + } +#endif + while (rsti.hasNext()) { auto tt = TypedTermList(rsti.next()); - ((TermSubstitutionTree*)_is)->handle(tt, lit, c, adding); + ((TermSubstitutionTree*)&*_is)->handle(tt, lit, c, adding); } } - // DBGE(multiline(*((TermSubstitutionTree*)_is))) } void SuperpositionLHSIndex::handleClause(Clause* c, bool adding) @@ -86,8 +79,8 @@ void SuperpositionLHSIndex::handleClause(Clause* c, bool adding) } } -template -void DemodulationSubtermIndexImpl::handleClause(Clause* c, bool adding) +template +void DemodulationSubtermIndex::handleClause(Clause* c, bool adding) { CALL("DemodulationSubtermIndex::handleClause"); @@ -103,9 +96,7 @@ void DemodulationSubtermIndexImpl::handleClause(Clause* c // the removes could be called on different literals than the inserts! inserted.reset(); Literal* lit=(*c)[i]; - typename std::conditional::type it(lit); + SubtermIterator it(lit); while (it.hasNext()) { Term* t= it.next(); if (!inserted.insert(t)) {//TODO existing error? Terms are inserted once per a literal @@ -125,10 +116,10 @@ void DemodulationSubtermIndexImpl::handleClause(Clause* c } } -// This is necessary for templates defined in cpp files. -// We are happy to do it for DemodulationSubtermIndexImpl, since it (at the moment) has only two specializations: -template class DemodulationSubtermIndexImpl; -template class DemodulationSubtermIndexImpl; +#if VHOL +template class DemodulationSubtermIndex; +#endif +template class DemodulationSubtermIndex; void DemodulationLHSIndex::handleClause(Clause* c, bool adding) { @@ -227,197 +218,7 @@ void StructInductionTermIndex::handleClause(Clause* c, bool adding) // Indices for higher-order inferences from here on// ///////////////////////////////////////////////////// -void SubVarSupSubtermIndex::handleClause(Clause* c, bool adding) -{ - CALL("SubVarSupSubtermIndex::handleClause"); - - - DHSet unstableVars; - c->collectUnstableVars(unstableVars); - - unsigned selCnt=c->numSelected(); - for (unsigned i=0; iinsert(TypedTermList(var,sort), lit, c); - } else { - _is->remove(TypedTermList(var,sort), lit, c); - } - } - } -} - -void SubVarSupLHSIndex::handleClause(Clause* c, bool adding) -{ - CALL("SubVarSupLHSIndex::handleClause"); - - unsigned selCnt=c->numSelected(); - for (unsigned i=0; iinsert(TypedTermList(lhs,sort), lit, c); - } - else { - _is->remove(TypedTermList(lhs,sort), lit, c); - } - } - } -} -void PrimitiveInstantiationIndex::populateIndex() -{ - CALL("PrimitiveInstantiationIndex::populateIndex"); - - typedef ApplicativeHelper AH; - - static Options::PISet set = env.options->piSet(); - - auto srtOf = [] (TermList t) { - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); - }; - - static TermList boolS = AtomicSort::boolSort(); - - TermList s1 = TermList(0, false); - TermList x = TermList(1, false); - TermList y = TermList(2, false); - TermList s1_bool = AtomicSort::arrowSort(s1, boolS); - TermList args1[] = {s1, boolS, boolS}; - TermList args2[] = {s1, s1_bool, s1_bool}; - - unsigned k_comb = env.signature->getCombinator(Signature::K_COMB); - unsigned b_comb = env.signature->getCombinator(Signature::B_COMB); - unsigned v_and = env.signature->getBinaryProxy("vAND"); - unsigned v_or = env.signature->getBinaryProxy("vOR"); - unsigned v_imp = env.signature->getBinaryProxy("vIMP"); - unsigned v_not = env.signature->getNotProxy(); - unsigned v_equals = env.signature->getEqualityProxy(); - - TermList kcomb = TermList(Term::create2(k_comb, AtomicSort::boolSort(), s1)); - TermList bcomb1 = TermList(Term::create(b_comb, 3, args1)); - TermList bcomb2 = TermList(Term::create(b_comb, 3, args2)); - TermList vand = TermList(Term::createConstant(v_and)); - TermList vor = TermList(Term::createConstant(v_or)); - TermList vimp = TermList(Term::createConstant(v_imp)); - TermList vnot = TermList(Term::createConstant(v_not)); - TermList vequals = TermList(Term::create1(v_equals, s1)); - - TermList kTerm1 = AH::createAppTerm3(srtOf(kcomb), kcomb, TermList(Term::foolFalse()), x); - TermList kTerm2 = AH::createAppTerm3(srtOf(kcomb), kcomb, TermList(Term::foolTrue()), x); - TermList andTerm = AH::createAppTerm3(srtOf(vand), vand, x, y); - TermList orTerm = AH::createAppTerm3(srtOf(vor), vor, x, y); - TermList impTerm = AH::createAppTerm3(srtOf(vimp), vimp, x, y); - TermList notTerm = AH::createAppTerm(srtOf(vnot), vnot, x); - TermList equalsTerm = AH::createAppTerm3(srtOf(vequals), vequals, x, y); - TermList trm = AH::createAppTerm(srtOf(bcomb1), bcomb1, vnot); - TermList notEqualsTerm = AH::createAppTerm3(srtOf(bcomb2), bcomb2, trm, vequals); - notEqualsTerm = AH::createAppTerm3(srtOf(notEqualsTerm), notEqualsTerm, x, y); - - if(set == Options::PISet::ALL){ - _is->insert(TypedTermList(kTerm1.term()), 0, 0); - _is->insert(TypedTermList(kTerm2.term()), 0, 0); - _is->insert(TypedTermList(andTerm.term()), 0, 0); - _is->insert(TypedTermList(orTerm.term()), 0, 0); - _is->insert(TypedTermList(impTerm.term()), 0, 0); - _is->insert(TypedTermList(notTerm.term()), 0, 0); - _is->insert(TypedTermList(equalsTerm.term()), 0, 0); - _is->insert(TypedTermList(notEqualsTerm.term()), 0, 0); - } else if (set == Options::PISet::ALL_EXCEPT_NOT_EQ){ - _is->insert(TypedTermList(kTerm1.term()), 0, 0); - _is->insert(TypedTermList(kTerm2.term()), 0, 0); - _is->insert(TypedTermList(andTerm.term()), 0, 0); - _is->insert(TypedTermList(orTerm.term()), 0, 0); - _is->insert(TypedTermList(impTerm.term()), 0, 0); - _is->insert(TypedTermList(notTerm.term()), 0, 0); - _is->insert(TypedTermList(equalsTerm.term()), 0, 0); - } else if (set == Options::PISet::FALSE_TRUE_NOT){ - _is->insert(TypedTermList(kTerm1.term()), 0, 0); - _is->insert(TypedTermList(kTerm2.term()), 0, 0); - _is->insert(TypedTermList(notTerm.term()), 0, 0); - } else if (set == Options::PISet::FALSE_TRUE_NOT_EQ_NOT_EQ){ - _is->insert(TypedTermList(kTerm1.term()), 0, 0); - _is->insert(TypedTermList(kTerm2.term()), 0, 0); - _is->insert(TypedTermList(notTerm.term()), 0, 0); - _is->insert(TypedTermList(equalsTerm.term()), 0, 0); - _is->insert(TypedTermList(notEqualsTerm.term()), 0, 0); - } -} - -void NarrowingIndex::populateIndex() -{ - CALL("NarrowingIndex::populateIndex"); - - typedef ApplicativeHelper AH; - - static Options::Narrow set = env.options->narrow(); - - auto srtOf = [] (TermList t) { - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); - }; - - TermList s1 = TermList(0, false); - TermList s2 = TermList(1, false); - TermList s3 = TermList(2, false); - TermList x = TermList(3, false); - TermList y = TermList(4, false); - TermList z = TermList(5, false); - TermList args[] = {s1, s2, s3}; - - unsigned s_comb = env.signature->getCombinator(Signature::S_COMB); - TermList constant = TermList(Term::create(s_comb, 3, args)); - TermList lhsS = AH::createAppTerm(srtOf(constant), constant, x, y, z); - TermList rhsS = AH::createAppTerm3(AtomicSort::arrowSort(s1, s2, s3), x, z, AH::createAppTerm(AtomicSort::arrowSort(s1, s2), y, z)); - Literal* sLit = Literal::createEquality(true, lhsS, rhsS, s3); - - unsigned c_comb = env.signature->getCombinator(Signature::C_COMB); - constant = TermList(Term::create(c_comb, 3, args)); TermList lhsC = AH::createAppTerm(srtOf(constant), constant, x, y, z); - TermList rhsC = AH::createAppTerm3(AtomicSort::arrowSort(s1, s2, s3), x, z, y); - Literal* cLit = Literal::createEquality(true, lhsC, rhsC, s3); - - unsigned b_comb = env.signature->getCombinator(Signature::B_COMB); - constant = TermList(Term::create(b_comb, 3, args)); - TermList lhsB = AH::createAppTerm(srtOf(constant), constant, x, y, z); - TermList rhsB = AH::createAppTerm(AtomicSort::arrowSort(s2, s3), x, AH::createAppTerm(AtomicSort::arrowSort(s1, s2), y, z)); - Literal* bLit = Literal::createEquality(true, lhsB, rhsB, s3); - - unsigned k_comb = env.signature->getCombinator(Signature::K_COMB); - constant = TermList(Term::create2(k_comb, s1, s2)); - TermList lhsK = AH::createAppTerm3(srtOf(constant), constant, x, y); - Literal* kLit = Literal::createEquality(true, lhsK, x, s1); - - unsigned i_comb = env.signature->getCombinator(Signature::I_COMB); - constant = TermList(Term::create1(i_comb, s1)); - TermList lhsI = AH::createAppTerm(srtOf(constant), constant, x); - Literal* iLit = Literal::createEquality(true, lhsI, x, s1); - - if(set == Options::Narrow::ALL){ - _is->insert(TypedTermList(lhsS.term()), sLit, 0); - _is->insert(TypedTermList(lhsC.term()), cLit, 0); - _is->insert(TypedTermList(lhsB.term()), bLit, 0); - _is->insert(TypedTermList(lhsK.term()), kLit, 0); - _is->insert(TypedTermList(lhsI.term()), iLit, 0); - } else if (set == Options::Narrow::SKI) { - _is->insert(TypedTermList(lhsS.term()), sLit, 0); - _is->insert(TypedTermList(lhsK.term()), kLit, 0); - _is->insert(TypedTermList(lhsI.term()), iLit, 0); - } else if (set == Options::Narrow::SK){ - _is->insert(TypedTermList(lhsS.term()), sLit, 0); - _is->insert(TypedTermList(lhsK.term()), kLit, 0); - } -} +#if VHOL void SkolemisingFormulaIndex::insertFormula(TermList formula, TermList skolem) { @@ -425,112 +226,6 @@ void SkolemisingFormulaIndex::insertFormula(TermList formula, TermList skolem) _is->insert(TypedTermList(formula.term()), skolem); } -/*void HeuristicInstantiationIndex::insertInstantiation(TermList sort, TermList instantiation) -{ - CALL("HeuristicInstantiationIndex::insertInstantiation"); - _is->insert(sort, instantiation); -} - -void HeuristicInstantiationIndex::handleClause(Clause* c, bool adding) -{ - CALL("HeuristicInstantiationIndex::handleClause"); - - typedef ApplicativeHelper AH; - - TermList freshVar(c->maxVar() + 1, false); - VList* boundVar = new VList(freshVar.var()); - - for (unsigned i=0; ilength(); i++) { - Literal* lit=(*c)[i]; - TermList leftHead, rightHead, lhSort, rhSort; - static TermStack leftArgs; - static TermStack rightArgs; - AH::getHeadSortAndArgs(*lit->nthArgument(0), leftHead, lhSort, leftArgs); - AH::getHeadSortAndArgs(*lit->nthArgument(1), rightHead, rhSort, rightArgs); - if(leftHead.isTerm() && AH::getComb(leftHead) == Signature::NOT_COMB && - AH::getProxy(leftHead) == Signature::NOT_PROXY && - leftHead == rightHead && - leftArgs.size() == rightArgs.size() && - leftArgs.size()) - { - TermList sort, boundVarSort, combTerm; - for(i = 0; i < leftArgs.size(); i++){ - boundVarSort = AH::getNthArg(lhSort, leftArgs.size() - i); - SList* boundVarSortList = new SList(boundVarSort); - - Literal* newLit = EqHelper::replace(lit, leftArgs[i], freshVar); - newLit->setPolarity(!newLit->polarity()); - Term* eqForm = Term::createFormula(new Kernel::AtomicFormula(newLit)); - Term* lambdaTerm = Term::createLambda(TermList(eqForm), boundVar, boundVarSortList, AtomicSort::boolSort()); - combTerm = LambdaElimination().elimLambda(lambdaTerm); - if(!_insertedInstantiations.contains(combTerm)){ - cout << "lhs is " + lit->nthArgument(0)->toString() << endl; - cout << "arg " + leftArgs[i].toString() << endl; - cout << "inserting " + lambdaTerm->toString() << endl; - cout << "inserting " + combTerm.toString() << endl; - _insertedInstantiations.insert(combTerm); - insertInstantiation(lambdaTerm->getSpecialData()->getSort(), combTerm); - } - //may be harmful performance wise, but otherwise these - //leak - //eqForm->destroy(); - //lambdaTerm->destroy(); - - newLit = EqHelper::replace(lit, rightArgs[i], freshVar); - newLit->setPolarity(!newLit->polarity()); - eqForm = Term::createFormula(new Kernel::AtomicFormula(newLit)); - lambdaTerm = Term::createLambda(TermList(eqForm), boundVar, boundVarSortList, AtomicSort::boolSort()); - combTerm = LambdaElimination().elimLambda(lambdaTerm); - if(!_insertedInstantiations.contains(combTerm)){ - cout << "rhs is " + lit->nthArgument(1)->toString() << endl; - cout << "arg " + rightArgs[i].toString() << endl; - cout << "inserting " + lambdaTerm->toString() << endl; - cout << "inserting " + combTerm.toString() << endl; - _insertedInstantiations.insert(combTerm); - insertInstantiation(lambdaTerm->getSpecialData()->getSort(), combTerm); - } - - //eqForm->destroy(); - //lambdaTerm->destroy(); - - SList::destroy(boundVarSortList); - } - } - } - - VList::destroy(boundVar); -} - -void RenamingFormulaIndex::insertFormula(TermList formula, TermList name, - Literal* lit, Clause* cls) -{ - CALL("RenamingFormulaIndex::insertFormula"); - _is->insert(formula, name, lit, cls); -} - -void RenamingFormulaIndex::handleClause(Clause* c, bool adding) -{ - CALL("RenamingFormulaIndex::handleClause"); - - typedef ApplicativeHelper AH; - - for (unsigned i=0; ilength(); i++) { - Literal* lit=(*c)[i]; - NonVariableNonTypeIterator it(lit); - while (it.hasNext()) { - TermList trm = TermList(it.next()); - Term* t = trm.term(); - if(SortHelper::getResultSort(t) == AtomicSort::boolSort() && - AH::getProxy(AH::getHead(t)) != Signature::NOT_PROXY){ - if(adding){ - env.signature->incrementFormulaCount(t); - } else { - env.signature->decrementFormulaCount(t); - } - } - } - } -}*/ - +#endif } // namespace Indexing diff --git a/Indexing/TermIndex.hpp b/Indexing/TermIndex.hpp index ab478a8f74..a355699489 100644 --- a/Indexing/TermIndex.hpp +++ b/Indexing/TermIndex.hpp @@ -31,16 +31,35 @@ class TermIndex CLASS_NAME(TermIndex); USE_ALLOCATOR(TermIndex); - virtual ~TermIndex(); + TermQueryResultIterator getUnifications(TypedTermList t, bool retrieveSubstitutions = true) + { return _is->getUnifications(t, retrieveSubstitutions); } - TermQueryResultIterator getUnifications(TypedTermList t, bool retrieveSubstitutions = true, bool withConstraints = false); - TermQueryResultIterator getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true); - TermQueryResultIterator getInstances(TypedTermList t, bool retrieveSubstitutions = true); + TermQueryResultIterator getUwa(TypedTermList t) + { return _is->getUwa(t); } + TermQueryResultIterator getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) + { return _is->getGeneralizations(t, retrieveSubstitutions); } + + TermQueryResultIterator getInstances(TypedTermList t, bool retrieveSubstitutions = true) + { return _is->getInstances(t, retrieveSubstitutions); } + +#if VHOL + TermQueryResultIterator getHOLUnifiers(TypedTermList t) + { return _is->getHOLUnifiers(t); } + + TermQueryResultIterator getHOLInstances(TypedTermList t) + { return _is->getHOLInstances(t); } + + TermQueryResultIterator getHOLGeneralizations(TypedTermList t) + { return _is->getHOLGeneralizations(t); } +#endif + + friend std::ostream& operator<<(std::ostream& out, TermIndex const& self) + { return out << *self._is; } protected: TermIndex(TermIndexingStructure* is) : _is(is) {} - TermIndexingStructure* _is; + unique_ptr _is; }; class SuperpositionSubtermIndex @@ -78,28 +97,16 @@ class SuperpositionLHSIndex /** * Term index for backward demodulation */ +template class DemodulationSubtermIndex : public TermIndex { public: - // people seemed to like the class, although it add's no interface on top of TermIndex + CLASS_NAME(DemodulationSubtermIndex); + USE_ALLOCATOR(DemodulationSubtermIndex); + DemodulationSubtermIndex(TermIndexingStructure* is) : TermIndex(is) {}; -protected: - // it's the implementation of this below in DemodulationSubtermIndexImpl, which makes this work - void handleClause(Clause* c, bool adding) = 0; -}; - -template -class DemodulationSubtermIndexImpl -: public DemodulationSubtermIndex -{ -public: - CLASS_NAME(DemodulationSubtermIndexImpl); - USE_ALLOCATOR(DemodulationSubtermIndexImpl); - - DemodulationSubtermIndexImpl(TermIndexingStructure* is) - : DemodulationSubtermIndex(is) {}; protected: void handleClause(Clause* c, bool adding); }; @@ -161,70 +168,7 @@ class StructInductionTermIndex // Indices for higher-order inferences from here on// ///////////////////////////////////////////////////// -class PrimitiveInstantiationIndex -: public TermIndex -{ -public: - CLASS_NAME(PrimitiveInstantiationIndex); - USE_ALLOCATOR(PrimitiveInstantiationIndex); - - PrimitiveInstantiationIndex(TermIndexingStructure* is) : TermIndex(is) - { - populateIndex(); - } -protected: - void populateIndex(); -}; - -class SubVarSupSubtermIndex -: public TermIndex -{ -public: - CLASS_NAME(SubVarSupSubtermIndex); - USE_ALLOCATOR(SubVarSupSubtermIndex); - - SubVarSupSubtermIndex(TermIndexingStructure* is, Ordering& ord) - : TermIndex(is), _ord(ord) {}; -protected: - void handleClause(Clause* c, bool adding); -private: - Ordering& _ord; -}; - -class SubVarSupLHSIndex -: public TermIndex -{ -public: - CLASS_NAME(SubVarSupLHSIndex); - USE_ALLOCATOR(SubVarSupLHSIndex); - - SubVarSupLHSIndex(TermIndexingStructure* is, Ordering& ord, const Options& opt) - : TermIndex(is), _ord(ord) {}; -protected: - void handleClause(Clause* c, bool adding); -private: - Ordering& _ord; -}; - -/** - * Index used for narrowing with combinator axioms - */ -class NarrowingIndex -: public TermIndex -{ -public: - CLASS_NAME(NarrowingIndex); - USE_ALLOCATOR(NarrowingIndex); - - NarrowingIndex(TermIndexingStructure* is) : TermIndex(is) - { - populateIndex(); - } -protected: - void populateIndex(); -}; - - +#if VHOL class SkolemisingFormulaIndex : public TermIndex { @@ -237,6 +181,8 @@ class SkolemisingFormulaIndex void insertFormula(TermList formula, TermList skolem); }; +#endif + /*class HeuristicInstantiationIndex : public TermIndex { @@ -251,20 +197,6 @@ class SkolemisingFormulaIndex void handleClause(Clause* c, bool adding); private: Set _insertedInstantiations; -}; - -class RenamingFormulaIndex -: public TermIndex -{ -public: - CLASS_NAME(RenamingFormulaIndex); - USE_ALLOCATOR(RenamingFormulaIndex); - - RenamingFormulaIndex(TermIndexingStructure* is) : TermIndex(is) - {} - void insertFormula(TermList formula, TermList name, Literal* lit, Clause* cls); -protected: - void handleClause(Clause* c, bool adding); };*/ }; diff --git a/Indexing/TermIndexingStructure.hpp b/Indexing/TermIndexingStructure.hpp index b0131d47a6..999d244603 100644 --- a/Indexing/TermIndexingStructure.hpp +++ b/Indexing/TermIndexingStructure.hpp @@ -17,7 +17,8 @@ #define __TermIndexingStructure__ #include "Index.hpp" -#include "Kernel/BottomUpEvaluation/TypedTermList.hpp" +#include "Kernel/TypedTermList.hpp" +#include "Kernel/HOLUnification.hpp" namespace Indexing { @@ -29,19 +30,38 @@ class TermIndexingStructure { virtual void remove(TypedTermList t, Literal* lit, Clause* cls) = 0; virtual void insert(TypedTermList t, TermList trm){ NOT_IMPLEMENTED; } virtual void insert(TypedTermList t, TermList trm, Literal* lit, Clause* cls){ NOT_IMPLEMENTED; } + virtual void remove(TypedTermList t, TermList trm, Literal* lit, Clause* cls){ NOT_IMPLEMENTED; } - virtual TermQueryResultIterator getUnifications(TypedTermList t, bool retrieveSubstitutions = true, bool withConstraints = false) { NOT_IMPLEMENTED; } - virtual TermQueryResultIterator getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual TermQueryResultIterator getInstances(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual TermQueryResultIterator getUnifications(TypedTermList t, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual TermQueryResultIterator getUwa(TypedTermList t) = 0; + virtual TermQueryResultIterator getGeneralizations(TypedTermList t, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual TermQueryResultIterator getInstances(TypedTermList t, + bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + +#if VHOL + virtual TermQueryResultIterator getHOLUnifiers(TypedTermList t) + { NOT_IMPLEMENTED; } + virtual TermQueryResultIterator getHOLInstances(TypedTermList t) + { NOT_IMPLEMENTED; } + virtual TermQueryResultIterator getHOLGeneralizations(TypedTermList t) + { NOT_IMPLEMENTED; } +#endif + virtual bool generalizationExists(TermList t) { NOT_IMPLEMENTED; } #if VDEBUG virtual void markTagged() = 0; #endif + virtual void output(std::ostream& output) const = 0; + friend std::ostream& operator<<(std::ostream& out, TermIndexingStructure const& self) + { self.output(out); return out; } }; + }; #endif /* __TermIndexingStructure__ */ diff --git a/Indexing/TermSharing.cpp b/Indexing/TermSharing.cpp index efbec517e3..022b635af2 100644 --- a/Indexing/TermSharing.cpp +++ b/Indexing/TermSharing.cpp @@ -32,8 +32,6 @@ using namespace Kernel; using namespace Indexing; -typedef ApplicativeHelper AH; - /** * Initialise the term sharing structure. * @since 29/12/2007 Manchester @@ -81,8 +79,11 @@ void TermSharing::setPoly() { CALL("TermSharing::setPoly()"); - //combinatory superposiiton can introduce polymorphism into a monomorphic problem - _poly = env.property->higherOrder() || env.property->hasPolymorphicSym() || + _poly = +#if VHOL + env.property->higherOrder() || +#endif + env.property->hasPolymorphicSym() || (env.options->equalityProxy() != Options::EqualityProxy::OFF && !env.options->useMonoEqualityProxy()); } @@ -107,68 +108,36 @@ Term* TermSharing::insert(Term* t) TermList* ts1 = t->args(); TermList* ts2 = ts1->next(); if (argNormGt(*ts1, *ts2)) { - swap(ts1->_content, ts2->_content); + t->argSwap(); } } +#if VHOL + +#endif + _termInsertions++; Term* s = _terms.insert(t); if (s == t) { unsigned weight = 1; unsigned vars = 0; - bool hasInterpretedConstants=t->arity()==0 && - env.signature->getFunction(t->functor())->interpreted(); - bool hasTermVar = false; + bool hasSortVar = false; + bool hasInterpretedConstants=t->arity()==0 && + env.signature->getFunction(t->functor())->interpreted(); +#if VHOL + bool hasDBIndex = t->deBruijnIndex().isSome(); + bool hasRedex = t->isRedex(); + bool hasLambda = t->isLambdaTerm(); +#endif Color color = COLOR_TRANSPARENT; - - if(env.options->combinatorySup()){ - int maxRedLength = -1; - TermList head; - TermStack args; - AH::getHeadAndArgs(t, head, args); - if(!AH::isComb(head) || AH::isUnderApplied(head, args.size())){ - maxRedLength = sumRedLengths(args); - } else { - switch(AH::getComb(head)){ - case Signature::B_COMB: - if(!AH::isComb(AH::getHead(args[args.size()-1])) && - !AH::isComb(AH::getHead(args[args.size()-2]))){ - maxRedLength = sumRedLengths(args); - maxRedLength = maxRedLength == -1 ? -1 : maxRedLength + 1; - } - break; - case Signature::S_COMB: - if(!AH::isComb(AH::getHead(args[args.size()-1])) && - !AH::isComb(AH::getHead(args[args.size()-2]))){ - maxRedLength = sumRedLengths(args); - maxRedLength = maxRedLength == -1 ? -1 : maxRedLength + 1; - if(maxRedLength != -1 && args[args.size() - 3].isTerm()){ - maxRedLength += args[args.size() - 3].term()->maxRedLength(); - } - } - break; - case Signature::C_COMB: - case Signature::I_COMB: - case Signature::K_COMB: - if(!AH::isComb(AH::getHead(args[args.size()-1]))){ - maxRedLength = sumRedLengths(args); - maxRedLength = maxRedLength == -1 ? -1 : maxRedLength + 1; - } - break; - default: - ASSERTION_VIOLATION; - } - } - t->setMaxRedLen(maxRedLength); - } unsigned typeArity = t->numTypeArguments(); for (unsigned i = 0; i < t->arity(); i++) { TermList* tt = t->nthArgument(i); if (tt->isVar()) { ASS(tt->isOrdinaryVar()); - if(i >= typeArity){ - hasTermVar = true; + if(i < typeArity){ + hasSortVar = true; } vars++; weight += 1; @@ -181,35 +150,44 @@ Term* TermSharing::insert(Term* t) vars += r->numVarOccs(); weight += r->weight(); - hasTermVar |= r->hasTermVar(); + hasSortVar |= r->hasSortVar(); +#if VHOL + hasDBIndex = hasDBIndex ? true : r->hasDBIndex(); + hasRedex = hasRedex ? true : r->hasRedex(); + hasLambda = hasLambda ? true : r->hasLambda(); +#endif + hasInterpretedConstants = hasInterpretedConstants ? true : r->hasInterpretedConstants(); if (env.colorUsed) { color = static_cast(color | r->color()); } - if(!hasInterpretedConstants && r->hasInterpretedConstants()) { - hasInterpretedConstants=true; - } } } t->markShared(); t->setId(_totalTerms); t->setNumVarOccs(vars); t->setWeight(weight); - t->setHasTermVar(hasTermVar); + t->setHasSortVar(hasSortVar); + if (env.colorUsed) { Color fcolor = env.signature->getFunction(t->functor())->color(); color = static_cast(color | fcolor); t->setColor(color); } - + +#if VHOL + t->setHasRedex(hasRedex); + t->setHasDBIndex(hasDBIndex); + t->setHasLambda(hasLambda); +#endif t->setInterpretedConstantsPresence(hasInterpretedConstants); _totalTerms++; //poly function works for mono as well, but is slow //it is fine to use for debug ASS_REP(_wellSortednessCheckingDisabled || SortHelper::areImmediateSortsValidPoly(t), t->toString()); - if (!_poly && !SortHelper::areImmediateSortsValidMono(t) && !_wellSortednessCheckingDisabled){ + if (!_wellSortednessCheckingDisabled && !_poly && !SortHelper::areImmediateSortsValidMono(t)){ USER_ERROR("Immediate (shared) subterms of term/literal "+t->toString()+" have different types/not well-typed!"); - } else if (_poly && !SortHelper::areImmediateSortsValidPoly(t) && !_wellSortednessCheckingDisabled){ + } else if (!_wellSortednessCheckingDisabled && _poly && !SortHelper::areImmediateSortsValidPoly(t)){ USER_ERROR("Immediate (shared) subterms of term/literal "+t->toString()+" have different types/not well-typed!"); } } @@ -236,10 +214,12 @@ AtomicSort* TermSharing::insert(AtomicSort* sort) } unsigned weight = 1; unsigned vars = 0; + bool hasSortVar = false; for (TermList* tt = sort->args(); ! tt->isEmpty(); tt = tt->next()) { if (tt->isVar()) { ASS(tt->isOrdinaryVar()); + hasSortVar = true; vars++; weight += 1; } @@ -251,12 +231,14 @@ AtomicSort* TermSharing::insert(AtomicSort* sort) vars += r->numVarOccs(); weight += r->weight(); + hasSortVar |= r->hasSortVar(); } } sort->markShared(); sort->setId(_totalSorts); sort->setNumVarOccs(vars); sort->setWeight(weight); + sort->setHasSortVar(hasSortVar); _totalSorts++; @@ -297,7 +279,7 @@ Literal* TermSharing::insert(Literal* t) TermList* ts1 = t->args(); TermList* ts2 = ts1->next(); if (argNormGt(*ts1, *ts2)) { - swap(ts1->_content, ts2->_content); + t->argSwap(); } } @@ -378,7 +360,7 @@ Literal* TermSharing::insertVariableEquality(Literal* t, TermList sort) TermList* ts1 = t->args(); TermList* ts2 = ts1->next(); if (argNormGt(*ts1, *ts2)) { - swap(ts1->_content, ts2->_content); + t->argSwap(); } //we need these values set during insertion into the sharing set @@ -524,7 +506,7 @@ bool TermSharing::equals(const Term* s,const Term* t) const TermList* ss = s->args(); const TermList* tt = t->args(); while (! ss->isEmpty()) { - if (ss->_content != tt->_content) { + if (*ss != *tt) { return false; } ss = ss->next(); diff --git a/Indexing/TermSubstitutionTree.cpp b/Indexing/TermSubstitutionTree.cpp index f83f465808..f79a25e0cc 100644 --- a/Indexing/TermSubstitutionTree.cpp +++ b/Indexing/TermSubstitutionTree.cpp @@ -15,17 +15,41 @@ #include "Lib/Environment.hpp" #include "Lib/Metaiterators.hpp" #include "Kernel/Term.hpp" +#include "Kernel/ApplicativeHelper.hpp" #include "TermSubstitutionTree.hpp" +#if VHOL +#include "Indexing/HOLSubstitutionTree.hpp" +#endif + namespace Indexing { using namespace Lib; using namespace Kernel; -TermSubstitutionTree::TermSubstitutionTree(bool useC, bool rfSubs, bool extra) -: SubstitutionTree(useC, rfSubs) -, _extra(extra) -{ } + +TermSubstitutionTree::TermSubstitutionTree(SplittingAlgo algo) +#if VHOL + : _extra(false), _algo(algo) +#endif +{ + switch(algo){ + case SplittingAlgo::NONE: + _tree.reset(new SubstitutionTree()); + break; +#if VHOL + case SplittingAlgo::HOL_UNIF: + _tree.reset(new SubstitutionTree()); + break; + case SplittingAlgo::HOL_MATCH: + _tree.reset(new HOLSubstitutionTree([](TermList t){ + return !t.isLambdaTerm(); + } )); + break; +#endif + } + +} } // namespace Indexing diff --git a/Indexing/TermSubstitutionTree.hpp b/Indexing/TermSubstitutionTree.hpp index c578b07da3..7b3974b4a6 100644 --- a/Indexing/TermSubstitutionTree.hpp +++ b/Indexing/TermSubstitutionTree.hpp @@ -17,7 +17,10 @@ #define __TermSubstitutionTree__ +#include "Forwards.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Kernel/Renaming.hpp" +#include "Kernel/TypedTermList.hpp" #include "Lib/SkipList.hpp" #include "Lib/BiMap.hpp" @@ -25,6 +28,10 @@ #include "TermIndexingStructure.hpp" #include "SubstitutionTree.hpp" +#if VHOL +#include "Kernel/HOLUnification.hpp" +#endif + namespace Indexing { /* @@ -36,23 +43,24 @@ namespace Indexing { /** A wrapper class around SubstitutionTree that makes it usable as a TermIndexingStructure */ class TermSubstitutionTree -: public TermIndexingStructure, SubstitutionTree +: public TermIndexingStructure { + using AbstractingAlgo = UnificationAlgorithms::AbstractingUnification; + using RobAlgo = UnificationAlgorithms::RobUnification; + using LeafData = SubstitutionTree::LeafData; + using FastInstancesIterator = SubstitutionTree::FastInstancesIterator; + using FastGeneralizationsIterator = SubstitutionTree::FastGeneralizationsIterator; +#if VHOL + using HOLAlgo = UnificationAlgorithms::HOLUnification; + using HOLInstAlgo = UnificationAlgorithms::HOLInstantiation; + using HOLGenAlgo = UnificationAlgorithms::HOLGeneralisation; +#endif + public: CLASS_NAME(TermSubstitutionTree); USE_ALLOCATOR(TermSubstitutionTree); - - /* - * The extra flag is a higher-order concern. it is set to true when - * we require the term query result to include two terms, the result term - * and another. - * - * The main use case is to store a different term in the leaf to the one indexed - * in the tree. This is used for example in Skolemisation on the fly where we - * store Terms of type $o (formulas) in the tree, but in the leaf we store - * the skolem terms used to witness them (to facilitate the reuse of Skolems) - */ - TermSubstitutionTree(bool useC=false, bool replaceFunctionalSubterms = false, bool extra = false); + + explicit TermSubstitutionTree(SplittingAlgo algo = SplittingAlgo::NONE); void handle(TypedTermList t, Literal* lit, Clause* cls, bool adding) { handleTerm(t, LeafData(cls, lit, t), adding); } @@ -69,47 +77,102 @@ class TermSubstitutionTree void insert(TypedTermList t, TermList trm, Literal* lit, Clause* cls) override { handleTerm(t, LeafData(cls, lit, t, trm), /* insert */ true); } - bool generalizationExists(TermList t) override - { return t.isVar() ? false : SubstitutionTree::generalizationExists(TypedTermList(t.term())); } + void remove(TypedTermList t, TermList trm, Literal* lit, Clause* cls) override + { handleTerm(t, LeafData(cls, lit, t, trm), /* insert */ false); } + bool generalizationExists(TermList t) override + { return t.isVar() ? false : _tree->generalizationExists(TypedTermList(t.term())); } #if VDEBUG - virtual void markTagged() override { SubstitutionTree::markTagged();} + virtual void markTagged() override { _tree->markTagged();} #endif -private: - + virtual void output(std::ostream& out) const final override { out << *this; } - void handleTerm(TypedTermList tt, LeafData ld, bool insert) - { SubstitutionTree::handle(tt, ld, insert); } +#if VHOL + void useExtra(){ _extra = true; } +#endif - template - auto getResultIterator(TypedTermList query, bool retrieveSubstitutions, bool withConstraints) - { - return iterTraits(SubstitutionTree::iterator(query, retrieveSubstitutions, withConstraints)) - .map([this](QueryResult qr) - { return TermQueryResult( - _extra ? qr.data->extraTerm : qr.data->term, - qr.data->literal, qr.data->clause, qr.subst, qr.constr); }) ; +private: + + void handleTerm(TypedTermList tt, LeafData ld, bool insert){ +#if VHOL + if(env.property->higherOrder() && _algo == SplittingAlgo::HOL_UNIF){ + // replace higher-order terms with placeholder constants + tt = TypedTermList(ToPlaceholders().replace(tt), tt.sort()); + } +#endif + _tree->handle(tt, ld, insert); } + + template + auto getResultIterator(TypedTermList query, bool retrieveSubstitutions, Args... args) + { + return iterTraits(_tree->iterator(query, retrieveSubstitutions, /* reversed */ false, std::move(args)...)) + .map([ +#if VHOL + this +#endif + ](auto qr) + { return tQueryRes( +#if VHOL + _extra ? qr.data->extraTerm : +#endif + qr.data->term, + qr.data->literal, qr.data->clause, std::move(qr.unif)); }) ; } - //higher-order concerns +#if VHOL + /* + * The extra flag is a higher-order concern. it is set to true when + * we require the term query result to include two terms, the result term + * and another. + * + * The main use case is to store a different term in the leaf to the one indexed + * in the tree. This is used for example in Skolemisation on the fly where we + * store Terms of type $o (formulas) in the tree, but in the leaf we store + * the skolem terms used to witness them (to facilitate the reuse of Skolems) + */ bool _extra; +#endif + SplittingAlgo _algo; + unique_ptr _tree; friend std::ostream& operator<<(std::ostream& out, TermSubstitutionTree const& self) - { return out << (SubstitutionTree const&) self; } + { return out << *self._tree; } friend std::ostream& operator<<(std::ostream& out, OutputMultiline const& self) - { return out << multiline((SubstitutionTree const&) self.self); } + { return out << multiline(*self.self._tree, self.indent); } + public: TermQueryResultIterator getInstances(TypedTermList t, bool retrieveSubstitutions) override - { return pvi(getResultIterator(t, retrieveSubstitutions, /* constraints */ false)); } + { return pvi(getResultIterator(t, retrieveSubstitutions)); } TermQueryResultIterator getGeneralizations(TypedTermList t, bool retrieveSubstitutions) override - { return pvi(getResultIterator(t, retrieveSubstitutions, /* constraints */ false)); } + { return pvi(getResultIterator(t, retrieveSubstitutions)); } + + TermQueryResultIterator getUwa(TypedTermList t) final override + { + static auto uwa = env.options->unificationWithAbstraction(); + static bool fixedPointIteration = env.options->unificationWithAbstractionFixedPointIteration(); + + return pvi(getResultIterator>(t, true, MismatchHandler(uwa), fixedPointIteration)); + } + + TermQueryResultIterator getUnifications(TypedTermList t, bool retrieveSubstitutions) override + { return pvi(getResultIterator>(t, retrieveSubstitutions)); } + +#if VHOL + TermQueryResultIterator getHOLUnifiers(TypedTermList t) final override + { + TypedTermList tp = TypedTermList(ToPlaceholders().replace(t), t.sort()); + return pvi(getResultIterator>(tp, true, t)); + } - TermQueryResultIterator getUnifications(TypedTermList t, bool retrieveSubstitutions, bool withConstraints) override - { return pvi(getResultIterator(t, retrieveSubstitutions, withConstraints)); } + TermQueryResultIterator getHOLInstances(TypedTermList t) final override + { return pvi(getResultIterator>(t, true)); } + TermQueryResultIterator getHOLGeneralizations(TypedTermList t) final override + { return pvi(getResultIterator>(t, true)); } +#endif }; }; diff --git a/Inferences/ArgCong.cpp b/Inferences/ArgCong.cpp index 7fa5cf5ec8..818f66bdb6 100644 --- a/Inferences/ArgCong.cpp +++ b/Inferences/ArgCong.cpp @@ -12,6 +12,8 @@ * Implements class ArgCong. */ +#if VHOL + #include #include "Lib/VirtualIterator.hpp" @@ -56,10 +58,8 @@ struct ArgCong::IsPositiveEqualityFn struct ArgCong::ResultFn { - ResultFn(Clause* cl, bool afterCheck = false, Ordering* ord = nullptr) - : /*_afterCheck(afterCheck), _ord(ord),*/ _cl(cl), _cLen(cl->length()) { - _freshVar = cl->maxVar() + 1; - } + ResultFn(Clause* cl) + : _cl(cl), _cLen(cl->length()), _freshVar(cl->maxVar() + 1) {} Clause* operator() (Literal* lit) { CALL("ArgCong::ResultFn::operator()"); @@ -76,14 +76,14 @@ struct ArgCong::ResultFn } TermList alpha1, alpha2; - if(eqSort.isVar()){ + if(sortIsVar){ subst.reset(); alpha1 = TermList(_freshVar+1, false); alpha2 = TermList(_freshVar+2, false); subst.bind(eqSort.var(), AtomicSort::arrowSort(alpha1, alpha2)); } else { - alpha1 = *eqSort.term()->nthArgument(0); - alpha2 = *eqSort.term()->nthArgument(1); + alpha1 = eqSort.domain(); + alpha2 = eqSort.result(); } TermList freshVar = TermList(_freshVar, false); @@ -93,8 +93,8 @@ struct ArgCong::ResultFn lhs = SubstHelper::apply(lhs, subst); rhs = SubstHelper::apply(rhs, subst); } - TermList newLhs = ApplicativeHelper::createAppTerm(alpha1, alpha2, lhs, freshVar); - TermList newRhs = ApplicativeHelper::createAppTerm(alpha1, alpha2, rhs, freshVar); + TermList newLhs = ApplicativeHelper::app(alpha1, alpha2, lhs, freshVar); + TermList newRhs = ApplicativeHelper::app(alpha1, alpha2, rhs, freshVar); Literal* newLit = Literal::createEquality(true, newLhs, newRhs, alpha2); @@ -105,15 +105,8 @@ struct ArgCong::ResultFn if(curr!=lit) { Literal* currAfter; - if (sortIsVar /*&& _afterCheck && _cl->numSelected() > 1*/) { + if (sortIsVar) { currAfter = SubstHelper::apply(curr, subst); - /* - - if (i < _cl->numSelected() && _ord->compare(currAfter,newLit) == Ordering::GREATER) { - env.statistics->inferencesBlockedForOrderingAftercheck++; - res->destroy(); - return 0; - }*/ //TODO reintroduce check } else { currAfter = curr; } @@ -129,9 +122,6 @@ struct ArgCong::ResultFn return res; } private: - // currently unused - // bool _afterCheck; - // Ordering* _ord; Clause* _cl; unsigned _cLen; unsigned _freshVar; @@ -151,9 +141,7 @@ ClauseIterator ArgCong::generateClauses(Clause* premise) auto it2 = getFilteredIterator(it1,IsPositiveEqualityFn()); - auto it3 = getMappingIterator(it2,ResultFn(premise, - getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(), - &_salg->getOrdering())); + auto it3 = getMappingIterator(it2,ResultFn(premise)); auto it4 = getFilteredIterator(it3,NonzeroFn()); @@ -162,3 +150,5 @@ ClauseIterator ArgCong::generateClauses(Clause* premise) } } + +#endif \ No newline at end of file diff --git a/Inferences/ArgCong.hpp b/Inferences/ArgCong.hpp index 089072636f..9a6007ffb4 100644 --- a/Inferences/ArgCong.hpp +++ b/Inferences/ArgCong.hpp @@ -16,6 +16,8 @@ #ifndef __ArgCong__ #define __ArgCong__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -44,4 +46,6 @@ class ArgCong }; +#endif + #endif /* __ArgCong__ */ diff --git a/Inferences/BackwardDemodulation.cpp b/Inferences/BackwardDemodulation.cpp index d575452b1c..9d2e14c6bf 100644 --- a/Inferences/BackwardDemodulation.cpp +++ b/Inferences/BackwardDemodulation.cpp @@ -24,12 +24,14 @@ #include "Kernel/Clause.hpp" #include "Kernel/ColorHelper.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Ordering.hpp" #include "Kernel/Renaming.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/Term.hpp" #include "Kernel/RobSubstitution.hpp" +#include "Kernel/TermIterators.hpp" #include "Indexing/Index.hpp" #include "Indexing/TermIndex.hpp" @@ -50,15 +52,17 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; -void BackwardDemodulation::attach(SaturationAlgorithm* salg) +template +void BackwardDemodulation::attach(SaturationAlgorithm* salg) { CALL("BackwardDemodulation::attach"); BackwardSimplificationEngine::attach(salg); - _index=static_cast( + _index=static_cast*>( _salg->getIndexManager()->request(DEMODULATION_SUBTERM_SUBST_TREE) ); } -void BackwardDemodulation::detach() +template +void BackwardDemodulation::detach() { CALL("BackwardDemodulation::detach"); _index=0; @@ -66,7 +70,8 @@ void BackwardDemodulation::detach() BackwardSimplificationEngine::detach(); } -struct BackwardDemodulation::RemovedIsNonzeroFn +template +struct BackwardDemodulation::RemovedIsNonzeroFn { bool operator() (BwSimplificationRecord arg) { @@ -74,21 +79,27 @@ struct BackwardDemodulation::RemovedIsNonzeroFn } }; -struct BackwardDemodulation::RewritableClausesFn +template +struct BackwardDemodulation::RewritableClausesFn { - RewritableClausesFn(DemodulationSubtermIndex* index, Literal* lit) : _index(index), _lit(lit) {} + RewritableClausesFn(DemodulationSubtermIndex* index, Literal* lit) : _index(index), _lit(lit) {} VirtualIterator > operator() (TermList lhs) { TermList sort = SortHelper::getTermSort(lhs, _lit); - return pvi( pushPairIntoRightIterator(lhs, _index->getInstances(TypedTermList(lhs,sort), true)) ); + return pvi( pushPairIntoRightIterator(lhs, +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances(TypedTermList(lhs,sort)) : +#endif + _index->getInstances(TypedTermList(lhs,sort), true)) ); } private: - DemodulationSubtermIndex* _index; + DemodulationSubtermIndex* _index; Literal* _lit; }; - -struct BackwardDemodulation::ResultFn +template +struct BackwardDemodulation::ResultFn { typedef DHMultiset ClauseSet; @@ -133,14 +144,14 @@ struct BackwardDemodulation::ResultFn TermList lhsS=qr.term; TermList rhsS; - if(!qr.substitution->isIdentityOnResultWhenQueryBound()) { + if(!qr.unifier->isIdentityOnResultWhenQueryBound()) { //When we apply substitution to the rhs, we get a term, that is //a variant of the term we'd like to get, as new variables are //produced in the substitution application. //We'd rather rename variables in the rhs, than in the whole clause //that we're simplifying. - TermList lhsSBadVars=qr.substitution->applyToQuery(lhs); - TermList rhsSBadVars=qr.substitution->applyToQuery(rhs); + TermList lhsSBadVars=qr.unifier->applyToQuery(lhs); + TermList rhsSBadVars=qr.unifier->applyToQuery(rhs); Renaming rNorm, qNorm, qDenorm; rNorm.normalizeVariables(lhsSBadVars); qNorm.normalizeVariables(lhsS); @@ -148,7 +159,7 @@ struct BackwardDemodulation::ResultFn ASS_EQ(lhsS,qDenorm.apply(rNorm.apply(lhsSBadVars))); rhsS=qDenorm.apply(rNorm.apply(rhsSBadVars)); } else { - rhsS=qr.substitution->applyToBoundQuery(rhs); + rhsS=qr.unifier->applyToBoundQuery(rhs); } if(_ordering.compare(lhsS,rhsS)!=Ordering::GREATER) { @@ -163,7 +174,7 @@ struct BackwardDemodulation::ResultFn Ordering::Result tord=_ordering.compare(rhsS, other); if(tord!=Ordering::LESS && tord!=Ordering::LESS_EQ) { if (_encompassing) { - if (qr.substitution->isRenamingOn(lhs,false /* we talk of a non-result, i.e., a query term */)) { + if (qr.unifier->isRenamingOn(lhs,false /* we talk of a non-result, i.e., a query term */)) { // under _encompassing, we know there are no other literals in qr.clause return BwSimplificationRecord(0); } @@ -195,7 +206,7 @@ struct BackwardDemodulation::ResultFn } } - Literal* resLit=EqHelper::replace(qr.literal,lhsS,rhsS); + Literal* resLit=SubtermReplacer(lhsS,rhsS).transform(qr.literal); if(EqHelper::isEqTautology(resLit)) { env.statistics->backwardDemodulationsToEqTaut++; _removed->insert(qr.clause); @@ -232,8 +243,8 @@ struct BackwardDemodulation::ResultFn Ordering& _ordering; }; - -void BackwardDemodulation::perform(Clause* cl, +template +void BackwardDemodulation::perform(Clause* cl, BwSimplificationRecordIterator& simplifications) { CALL("BackwardDemodulation::perform"); @@ -261,4 +272,9 @@ void BackwardDemodulation::perform(Clause* cl, simplifications=getPersistentIterator(replacementIterator); } +#if VHOL +template class BackwardDemodulation; +#endif +template class BackwardDemodulation; + } diff --git a/Inferences/BackwardDemodulation.hpp b/Inferences/BackwardDemodulation.hpp index b83350dab6..7e471dae19 100644 --- a/Inferences/BackwardDemodulation.hpp +++ b/Inferences/BackwardDemodulation.hpp @@ -26,6 +26,7 @@ namespace Inferences { using namespace Indexing; using namespace Kernel; +template class BackwardDemodulation : public BackwardSimplificationEngine { @@ -42,7 +43,7 @@ class BackwardDemodulation struct RewritableClausesFn; struct ResultFn; - DemodulationSubtermIndex* _index; + DemodulationSubtermIndex* _index; }; }; diff --git a/Inferences/BackwardSubsumptionDemodulation.cpp b/Inferences/BackwardSubsumptionDemodulation.cpp index 7ec8c9c408..6a0bf76ab5 100644 --- a/Inferences/BackwardSubsumptionDemodulation.cpp +++ b/Inferences/BackwardSubsumptionDemodulation.cpp @@ -22,6 +22,7 @@ #include "Kernel/Clause.hpp" #include "Kernel/ColorHelper.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/LiteralByMatchability.hpp" #include "Kernel/MLMatcherSD.hpp" @@ -55,13 +56,14 @@ using namespace Indexing; using namespace Saturation; -BackwardSubsumptionDemodulation::BackwardSubsumptionDemodulation() +template +BackwardSubsumptionDemodulation::BackwardSubsumptionDemodulation() : _preorderedOnly{false} , _allowIncompleteness{false} { } - -void BackwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) +template +void BackwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) { CALL("BackwardSubsumptionDemodulation::attach"); BackwardSimplificationEngine::attach(salg); @@ -69,8 +71,8 @@ void BackwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) _index.request(salg->getIndexManager(), BACKWARD_SUBSUMPTION_SUBST_TREE); } - -void BackwardSubsumptionDemodulation::detach() +template +void BackwardSubsumptionDemodulation::detach() { CALL("BackwardSubsumptionDemodulation::detach"); _index.release(); @@ -110,8 +112,8 @@ STLIterator getSTLIterator(Iterator begin, Iterator end) return STLIterator(begin, end); } - -void BackwardSubsumptionDemodulation::perform(Clause* sideCl, BwSimplificationRecordIterator& simplifications) +template +void BackwardSubsumptionDemodulation::perform(Clause* sideCl, BwSimplificationRecordIterator& simplifications) { CALL("BackwardSubsumptionDemodulation::perform"); ASSERT_VALID(*sideCl); @@ -170,7 +172,8 @@ void BackwardSubsumptionDemodulation::perform(Clause* sideCl, BwSimplificationRe } // perform -void BackwardSubsumptionDemodulation::performWithQueryLit(Clause* sideCl, Literal* candidateQueryLit, vvector& simplifications) +template +void BackwardSubsumptionDemodulation::performWithQueryLit(Clause* sideCl, Literal* candidateQueryLit, vvector& simplifications) { // sideCl // vvvvvvvvvv @@ -191,7 +194,12 @@ void BackwardSubsumptionDemodulation::performWithQueryLit(Clause* sideCl, Litera bool mustPredActive = false; unsigned mustPred; - SLQueryResultIterator rit = _index->getInstances(candidateQueryLit, false, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances(candidateQueryLit, false, false) : +#endif + _index->getInstances(candidateQueryLit, false, false); while (rit.hasNext()) { SLQueryResult qr = rit.next(); Clause* candidate = qr.clause; @@ -294,7 +302,8 @@ void BackwardSubsumptionDemodulation::performWithQueryLit(Clause* sideCl, Litera /// Handles the matching part. /// Returns true iff the main premise has been simplified. -bool BackwardSubsumptionDemodulation::simplifyCandidate(Clause* sideCl, Clause* mainCl, vvector& simplifications) +template +bool BackwardSubsumptionDemodulation::simplifyCandidate(Clause* sideCl, Clause* mainCl, vvector& simplifications) { static vvector alts; @@ -388,7 +397,8 @@ bool BackwardSubsumptionDemodulation::simplifyCandidate(Clause* sideCl, Clause* /// Handles the rewriting part. /// Returns true iff the main premise has been simplified. -bool BackwardSubsumptionDemodulation::rewriteCandidate(Clause* sideCl, Clause* mainCl, MLMatcherSD const& matcher, Clause*& replacement) +template +bool BackwardSubsumptionDemodulation::rewriteCandidate(Clause* sideCl, Clause* mainCl, MLMatcherSD const& matcher, Clause*& replacement) { Ordering const& ordering = _salg->getOrdering(); @@ -487,10 +497,7 @@ bool BackwardSubsumptionDemodulation::rewriteCandidate(Clause* sideCl, Clause* m continue; } - // TODO higher-order support not yet implemented; see forward demodulation - // (maybe it's enough to just use the different iterator) - ASS(!env.options->combinatorySup()); - NonVariableNonTypeIterator nvi(dlit); + SubtermIterator nvi(dlit); while (nvi.hasNext()) { TermList lhsS = TermList(nvi.next()); // named 'lhsS' because it will be matched against 'lhs' @@ -646,7 +653,7 @@ bool BackwardSubsumptionDemodulation::rewriteCandidate(Clause* sideCl, Clause* m /** * Step 4: found application of SD; now create the conclusion */ - Literal* newLit = EqHelper::replace(dlit, lhsS, rhsS); + Literal* newLit = SubtermReplacer(lhsS,rhsS).transform(dlit); ASS_EQ(ordering.compare(lhsS, rhsS), Ordering::GREATER); #if VDEBUG if (getOptions().literalComparisonMode() != Options::LiteralComparisonMode::REVERSE) { @@ -713,5 +720,11 @@ bool BackwardSubsumptionDemodulation::rewriteCandidate(Clause* sideCl, Clause* m return false; } // rewriteCandidate +#if VHOL +template class BackwardSubsumptionDemodulation; +#endif +template class BackwardSubsumptionDemodulation; } + + diff --git a/Inferences/BackwardSubsumptionDemodulation.hpp b/Inferences/BackwardSubsumptionDemodulation.hpp index 0d79e359a2..a742798754 100644 --- a/Inferences/BackwardSubsumptionDemodulation.hpp +++ b/Inferences/BackwardSubsumptionDemodulation.hpp @@ -45,6 +45,7 @@ using namespace Kernel; * * This class implements the backward direction. */ +template class BackwardSubsumptionDemodulation : public BackwardSimplificationEngine { diff --git a/Inferences/BackwardSubsumptionResolution.cpp b/Inferences/BackwardSubsumptionResolution.cpp index 50c9732bee..caf12f9fff 100644 --- a/Inferences/BackwardSubsumptionResolution.cpp +++ b/Inferences/BackwardSubsumptionResolution.cpp @@ -110,12 +110,17 @@ void BackwardSubsumptionResolution::perform(Clause* cl, if(clen==1) { List* simplRes=0; - SLQueryResultIterator rit=_index->getInstances( (*cl)[0], true, false); + SLQueryResultIterator rit= +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances( (*cl)[0], true, false) : +#endif + _index->getInstances( (*cl)[0], true, false); while(rit.hasNext()) { SLQueryResult qr=rit.next(); if(!checkedClauses.insert(qr.clause)) { - continue; + continue; } Clause* resCl=ForwardSubsumptionAndResolution::generateSubsumptionResolutionClause(qr.clause, qr.literal, cl); @@ -157,7 +162,12 @@ void BackwardSubsumptionResolution::perform(Clause* cl, List* simplRes=0; - SLQueryResultIterator rit=_index->getInstances( lmLit, true, false); + SLQueryResultIterator rit= +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances( lmLit, true, false) : +#endif + _index->getInstances( lmLit, true, false); while(rit.hasNext()) { SLQueryResult qr=rit.next(); Clause* icl=qr.clause; @@ -178,9 +188,9 @@ void BackwardSubsumptionResolution::perform(Clause* cl, if(!mustPredInit) { mustPred=lmHeader; for(unsigned bi=0;biheader(); if(pred!=lmHeader && (mustPred==lmHeader || pred>mustPred)) { mustPred=pred; @@ -191,11 +201,11 @@ void BackwardSubsumptionResolution::perform(Clause* cl, for(unsigned ii=0;iiheader(); if(pred==mustPred) { - haveMustPred=true; + haveMustPred=true; } } if(!haveMustPred) { @@ -209,9 +219,9 @@ void BackwardSubsumptionResolution::perform(Clause* cl, basePredsInit=true; basePreds.reset(); for(unsigned bi=0;biheader(); basePreds.insert(pred); } @@ -221,17 +231,17 @@ void BackwardSubsumptionResolution::perform(Clause* cl, for(unsigned ii=0;iiheader(); if(!basePreds.find(pred)) { - if(allowedMisses==0) { - fail=true; - break; - } - else { - allowedMisses--; - } + if(allowedMisses==0) { + fail=true; + break; + } + else { + allowedMisses--; + } } } if(fail) { @@ -245,15 +255,15 @@ void BackwardSubsumptionResolution::perform(Clause* cl, LiteralList::push(qr.literal, matchedLits[lmIndex]); for(unsigned bi=0;bigetInstances( lmLit, false, false); + rit= +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances( lmLit, false, false) : +#endif + _index->getInstances( lmLit, false, false); while(rit.hasNext()) { SLQueryResult qr=rit.next(); Clause* icl=qr.clause; @@ -302,9 +317,9 @@ void BackwardSubsumptionResolution::perform(Clause* cl, if(!mustPredInit) { mustPred=lmPred; for(unsigned bi=0;bifunctor(); if(pred!=lmPred && (mustPred==lmPred || pred>mustPred)) { mustPred=pred; @@ -315,11 +330,11 @@ void BackwardSubsumptionResolution::perform(Clause* cl, for(unsigned ii=0;iifunctor(); if(pred==mustPred) { - haveMustPred=true; + haveMustPred=true; } } if(!haveMustPred) { @@ -333,9 +348,9 @@ void BackwardSubsumptionResolution::perform(Clause* cl, basePredsInit=true; basePreds.reset(); for(unsigned bi=0;biheader(); basePreds.insert(pred); } @@ -346,20 +361,20 @@ void BackwardSubsumptionResolution::perform(Clause* cl, for(unsigned ii=0;iiheader(); if(!haveNeg && basePreds.find(pred^1)) { - haveNeg=true; + haveNeg=true; } if(!basePreds.find(pred)) { - if(allowedMisses==0) { - fail=true; - break; - } - else { - allowedMisses--; - } + if(allowedMisses==0) { + fail=true; + break; + } + else { + allowedMisses--; + } } } if(fail || !haveNeg) { @@ -372,13 +387,13 @@ void BackwardSubsumptionResolution::perform(Clause* cl, Literal* resolvedLit=0; for(unsigned bi=0;bilength(); i++){ + Literal* lit = (*c)[i]; + ASS(lit->isEquality()); + TermList t0 = *lit->nthArgument(0); + TermList t1 = *lit->nthArgument(1); + + TermList t0r = t0.betaEtaNF(); + TermList t1r = t1.betaEtaNF(); + + + if((t0r != t0) || (t1r != t1)){ + modified = true; + newLit = Literal::createEquality(lit->polarity(), t0r, t1r, SortHelper::getResultSort(t0.term())); + litStack.push(newLit); + continue; + } + litStack.push(lit); + } + + if(!modified){ + return c; + } + + Inference inf = SimplifyingInference1(InferenceRule::BETA_ETA_NORMALISE, c); + Clause* newC = Clause::fromStack(litStack, inf); + + return newC; +} + +#endif + diff --git a/Inferences/CombinatorDemodISE.hpp b/Inferences/BetaEtaISE.hpp similarity index 62% rename from Inferences/CombinatorDemodISE.hpp rename to Inferences/BetaEtaISE.hpp index a238394287..8a13ac5709 100644 --- a/Inferences/CombinatorDemodISE.hpp +++ b/Inferences/BetaEtaISE.hpp @@ -13,28 +13,30 @@ */ -#ifndef __CombinatorDemodISE__ -#define __CombinatorDemodISE__ +#ifndef __BetaEtaSimplify__ +#define __BetaEtaSimplify__ + +#if VHOL #include "Forwards.hpp" #include "InferenceEngine.hpp" +#include "Kernel/TermTransformer.hpp" namespace Inferences { -class CombinatorDemodISE + +class BetaEtaSimplify : public ImmediateSimplificationEngine { public: - CLASS_NAME(CombinatorDemodISE); - USE_ALLOCATOR(CombinatorDemodISE); + CLASS_NAME(BetaEtaSimplify); + USE_ALLOCATOR(BetaEtaSimplify); - CombinatorDemodISE(){} Clause* simplify(Clause* cl); -private: - TermList reduce(TermList t, unsigned& length); - bool headNormalForm(TermList& t); }; }; -#endif /* __CombinatorDemodISE__ */ +#endif + +#endif /* __BetaEtaSimplify__ */ diff --git a/Inferences/BinaryResolution.cpp b/Inferences/BinaryResolution.cpp index 4c31403b5e..a7ed8505ab 100644 --- a/Inferences/BinaryResolution.cpp +++ b/Inferences/BinaryResolution.cpp @@ -14,6 +14,8 @@ #include "Debug/RuntimeStatistics.hpp" +#include "Indexing/ResultSubstitution.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Lib/Environment.hpp" #include "Lib/Int.hpp" #include "Lib/Metaiterators.hpp" @@ -31,6 +33,7 @@ #include "Indexing/Index.hpp" #include "Indexing/LiteralIndex.hpp" #include "Indexing/IndexManager.hpp" +#include "Indexing/SubstitutionTree.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -38,7 +41,6 @@ #include "Shell/Statistics.hpp" #include "BinaryResolution.hpp" -#include "Shell/UnificationWithAbstractionConfig.hpp" namespace Inferences { @@ -56,8 +58,6 @@ void BinaryResolution::attach(SaturationAlgorithm* salg) GeneratingInferenceEngine::attach(salg); _index=static_cast ( _salg->getIndexManager()->request(BINARY_RESOLUTION_SUBST_TREE) ); - - _unificationWithAbstraction = env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF; } void BinaryResolution::detach() @@ -73,22 +73,22 @@ void BinaryResolution::detach() struct BinaryResolution::UnificationsFn { - UnificationsFn(BinaryResolutionIndex* index,bool cU) - : _index(index),_unificationWithAbstraction(cU) {} + + UnificationsFn(BinaryResolutionIndex* index) + : _index(index) {} VirtualIterator > operator()(Literal* lit) { + static bool usingUwa = env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF; + if(lit->isEquality()) { //Binary resolution is not performed with equality literals return VirtualIterator >::getEmpty(); } - if(_unificationWithAbstraction){ - return pvi( pushPairIntoRightIterator(lit, _index->getUnificationsWithConstraints(lit, true)) ); - } - return pvi( pushPairIntoRightIterator(lit, _index->getUnifications(lit, true)) ); + return pvi( pushPairIntoRightIterator(lit, usingUwa ? _index->getUwa(lit, /* complementary */ true) : + _index->getUnifications(lit, true, true))); } private: BinaryResolutionIndex* _index; - bool _unificationWithAbstraction; }; struct BinaryResolution::ResultFn @@ -102,7 +102,8 @@ struct BinaryResolution::ResultFn SLQueryResult& qr = arg.second; Literal* resLit = arg.first; - return BinaryResolution::generateClause(_cl, resLit, qr, _parent.getOptions(), _passiveClauseContainer, _afterCheck ? _ord : 0, &_selector); + auto subs = qr.unifier; + return BinaryResolution::generateClause(_cl, resLit, qr.clause, qr.literal, subs, _parent.getOptions(), _passiveClauseContainer, _afterCheck ? _ord : 0, &_selector); } private: Clause* _cl; @@ -117,32 +118,33 @@ struct BinaryResolution::ResultFn * Ordering aftercheck is performed iff ord is not 0, * in which case also ls is assumed to be not 0. */ -Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQueryResult qr, const Options& opts, PassiveClauseContainer* passiveClauseContainer, Ordering* ord, LiteralSelector* ls) +Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, Clause* resultCl, Literal* resultLit, + ResultSubstitutionSP subs, const Options& opts, PassiveClauseContainer* passiveClauseContainer, Ordering* ord, LiteralSelector* ls) { CALL("BinaryResolution::generateClause"); - ASS(qr.clause->store()==Clause::ACTIVE);//Added to check that generation only uses active clauses + ASS(resultCl->store()==Clause::ACTIVE);//Added to check that generation only uses active clauses - if(!ColorHelper::compatible(queryCl->color(),qr.clause->color()) ) { + auto constraints = subs->getConstraints(); + + if(!ColorHelper::compatible(queryCl->color(),resultCl->color()) ) { env.statistics->inferencesSkippedDueToColors++; if(opts.showBlocked()) { env.beginOutput(); - env.out()<<"Blocked resolution of "<toString()<<" and "<toString()<isEmpty(); unsigned clength = queryCl->length(); - unsigned dlength = qr.clause->length(); + unsigned dlength = resultCl->length(); // LRS-specific optimization: // check whether we can conclude that the resulting clause will be discarded by LRS since it does not fulfil the age/weight limits (in which case we can discard the clause) @@ -150,11 +152,11 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ // since we have not built the clause yet we compute lower bounds on the weight of the clause after each step and recheck whether the weight-limit can still be fulfilled. unsigned wlb=0;//weight lower bound unsigned numPositiveLiteralsLowerBound = // lower bound on number of positive literals, don't know at this point whether duplicate positive literals will occur - Int::max(queryLit->isPositive() ? queryCl->numPositiveLiterals()-1 : queryCl->numPositiveLiterals(), - qr.literal->isPositive() ? qr.clause->numPositiveLiterals()-1 : qr.clause->numPositiveLiterals()); + Int::max(queryLit->isPositive() ? queryCl->numPositiveLiterals()-1 : queryCl->numPositiveLiterals(), + resultLit->isPositive() ? resultCl->numPositiveLiterals()-1 : resultCl->numPositiveLiterals()); - Inference inf(GeneratingInference2(withConstraints? - InferenceRule::CONSTRAINED_RESOLUTION:InferenceRule::RESOLUTION,queryCl, qr.clause)); + Inference inf(GeneratingInference2(constraints->isNonEmpty() ? + InferenceRule::CONSTRAINED_RESOLUTION:InferenceRule::RESOLUTION,queryCl, resultCl)); Inference::Destroyer inf_destroyer(inf); // will call destroy on inf when coming out of scope unless disabled bool needsToFulfilWeightLimit = passiveClauseContainer && !passiveClauseContainer->fulfilsAgeLimit(wlb, numPositiveLiteralsLowerBound, inf) && passiveClauseContainer->weightLimited(); @@ -167,8 +169,8 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ } } for(unsigned i=0;iweight(); } } @@ -179,8 +181,7 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ } } - unsigned conlength = withConstraints ? constraints->size() : 0; - unsigned newLength = clength+dlength-2+conlength; + unsigned newLength = clength+dlength-2+constraints->size(); inf_destroyer.disable(); // ownership passed to the the clause below Clause* res = new(newLength) Clause(newLength, inf); // the inference object owned by res from now on @@ -188,57 +189,18 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ Literal* queryLitAfter = 0; if (ord && queryCl->numSelected() > 1) { TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - queryLitAfter = qr.substitution->applyToQuery(queryLit); + queryLitAfter = subs->applyToQuery(queryLit); } -#if VDEBUG -/* - if(withConstraints && constraints->size() > 0){ - cout << "Other: " << qr.clause->toString() << endl; - cout << "queryLit: " << queryLit->toString() << endl; - cout << "resLit: " << qr.literal->toString() << endl; - cout << "SUB:" << endl << qr.substitution->toString() << endl; -*/ -/* - cout << "SUB(deref):" << endl << qr.substitution->toString(true) << endl; -*/ - //} -#endif unsigned next = 0; - if(withConstraints){ - for(unsigned i=0;isize();i++){ - pair,pair> con = (*constraints)[i]; - -#if VDEBUG - //cout << "con pair " << con.first.toString() << " , " << con.second.toString() << endl; -#endif - - TermList qT = qr.substitution->applyTo(con.first.first,con.first.second); - TermList rT = qr.substitution->applyTo(con.second.first,con.second.second); - - TermList sort = SortHelper::getResultSort(rT.term()); - - Literal* constraint = Literal::createEquality(false,qT,rT,sort); - - static Options::UnificationWithAbstraction uwa = opts.unificationWithAbstraction(); - if(uwa==Options::UnificationWithAbstraction::GROUND && - !constraint->ground() && - (!UnificationWithAbstractionConfig::isInterpreted(qT) && - !UnificationWithAbstractionConfig::isInterpreted(rT))) { - - // the unification was between two uninterpreted things that were not ground - res->destroy(); - return 0; - } - - (*res)[next] = constraint; - next++; - } + for(Literal* c : *constraints){ + (*res)[next++] = c; } + for(unsigned i=0;iapplyToQuery(curr); + Literal* newLit = subs->applyToQuery(curr); if(needsToFulfilWeightLimit) { wlb+=newLit->weight() - curr->weight(); if(!passiveClauseContainer->fulfilsWeightLimit(wlb, numPositiveLiteralsLowerBound, res->inference())) { @@ -268,15 +230,15 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ } Literal* qrLitAfter = 0; - if (ord && qr.clause->numSelected() > 1) { + if (ord && resultCl->numSelected() > 1) { TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - qrLitAfter = qr.substitution->applyToResult(qr.literal); + qrLitAfter = subs->applyToResult(resultLit); } for(unsigned i=0;iapplyToResult(curr); + Literal* curr=(*resultCl)[i]; + if(curr!=resultLit) { + Literal* newLit = subs->applyToResult(curr); if(needsToFulfilWeightLimit) { wlb+=newLit->weight() - curr->weight(); if(!passiveClauseContainer->fulfilsWeightLimit(wlb, numPositiveLiteralsLowerBound, res->inference())) { @@ -286,7 +248,7 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ return 0; } } - if (qrLitAfter && i < qr.clause->numSelected()) { + if (qrLitAfter && i < resultCl->numSelected()) { TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); Ordering::Result o = ord->compare(newLit,qrLitAfter); @@ -299,21 +261,19 @@ Clause* BinaryResolution::generateClause(Clause* queryCl, Literal* queryLit, SLQ return 0; } } - + ASS_L(next, newLength) (*res)[next] = newLit; next++; } } - if(withConstraints){ + if(constraints->isNonEmpty()){ env.statistics->cResolution++; } else{ env.statistics->resolution++; } - //cout << "RESULT " << res->toString() << endl; - return res; } @@ -326,7 +286,7 @@ ClauseIterator BinaryResolution::generateClauses(Clause* premise) PassiveClauseContainer* passiveClauseContainer = _salg->getPassiveClauseContainer(); // generate pairs of the form (literal selected in premise, unifying object in index) - auto it1 = getMappingIterator(premise->getSelectedLiteralIterator(),UnificationsFn(_index,_unificationWithAbstraction)); + auto it1 = getMappingIterator(premise->getSelectedLiteralIterator(),UnificationsFn(_index)); // actually, we got one iterator per selected literal; we flatten the obtained iterator of iterators: auto it2 = getFlattenedIterator(it1); // perform binary resolution on these pairs diff --git a/Inferences/BinaryResolution.hpp b/Inferences/BinaryResolution.hpp index af6c9583fb..10c04379ce 100644 --- a/Inferences/BinaryResolution.hpp +++ b/Inferences/BinaryResolution.hpp @@ -20,7 +20,7 @@ #include "InferenceEngine.hpp" #include "Kernel/Ordering.hpp" -#include "Shell/UnificationWithAbstractionConfig.hpp" +#include "Kernel/RobSubstitution.hpp" namespace Inferences { @@ -37,14 +37,15 @@ class BinaryResolution USE_ALLOCATOR(BinaryResolution); BinaryResolution() - : _index(0), - _unificationWithAbstraction(false) + : _index(0) { } void attach(SaturationAlgorithm* salg); void detach(); - static Clause* generateClause(Clause* queryCl, Literal* queryLit, SLQueryResult res, const Options& opts, PassiveClauseContainer* passive=0, Ordering* ord=0, LiteralSelector* ls = 0); + static Clause* generateClause(Clause* queryCl, Literal* queryLit, + Clause* resultCl, Literal* resultLit, + ResultSubstitutionSP subs, const Options& opts, PassiveClauseContainer* passive=0, Ordering* ord=0, LiteralSelector* ls = 0); ClauseIterator generateClauses(Clause* premise); private: @@ -52,7 +53,6 @@ class BinaryResolution struct ResultFn; BinaryResolutionIndex* _index; - bool _unificationWithAbstraction; }; }; diff --git a/Inferences/BoolEqToDiseq.cpp b/Inferences/BoolEqToDiseq.cpp index 4cbd3f42f2..715683a1ef 100644 --- a/Inferences/BoolEqToDiseq.cpp +++ b/Inferences/BoolEqToDiseq.cpp @@ -12,6 +12,8 @@ * Implements class PrimitiveInstantiation. */ +#if VHOL + #include "Debug/RuntimeStatistics.hpp" #include "Kernel/OperatorType.hpp" @@ -56,34 +58,22 @@ ClauseIterator BoolEqToDiseq::generateClauses(Clause* cl) continue; } TermList eqSort = SortHelper::getEqualityArgumentSort(lit); - if(eqSort == AtomicSort::boolSort()){ + if(eqSort.isBoolSort()){ TermList lhs = *lit->nthArgument(0); TermList rhs = *lit->nthArgument(1); if(AH::isBool(lhs) || AH::isBool(rhs)){ pos++; continue; } - TermList head = AH::getHead(lhs); - if(!head.isVar()){ - Signature::Symbol* sym = env.signature->getFunction(head.term()->functor()); - if(sym->proxy() != Signature::NOT){ - TermList vNot = TermList(Term::createConstant(env.signature->getNotProxy())); - TermList vNotSort = SortHelper::getResultSort(vNot.term()); - TermList newLhs = AH::createAppTerm(vNotSort, vNot, lhs); - newLit = Literal::createEquality(false, newLhs, rhs, AtomicSort::boolSort()); - goto afterLoop; - } + TermList head = lhs.head(); + if(!head.isVar() && !head.isNot()){ + newLit = Literal::createEquality(false, AH::app(AH::neg(), lhs), rhs, AtomicSort::boolSort()); + goto afterLoop; } - head = AH::getHead(rhs); - if(!head.isVar()){ - Signature::Symbol* sym = env.signature->getFunction(head.term()->functor()); - if(sym->proxy() != Signature::NOT){ - TermList vNot = TermList(Term::createConstant(env.signature->getNotProxy())); - TermList vNotSort = SortHelper::getResultSort(vNot.term()); - TermList newRhs = AH::createAppTerm(vNotSort, vNot, rhs); - newLit = Literal::createEquality(false, lhs, newRhs, AtomicSort::boolSort()); - goto afterLoop; - } + head = rhs.head(); + if(!head.isVar() && !head.isNot()){ + newLit = Literal::createEquality(false, lhs, AH::app(AH::neg(), rhs), AtomicSort::boolSort()); + goto afterLoop; } } pos++; @@ -104,3 +94,5 @@ ClauseIterator BoolEqToDiseq::generateClauses(Clause* cl) } } + +#endif diff --git a/Inferences/BoolEqToDiseq.hpp b/Inferences/BoolEqToDiseq.hpp index 36cd9a685a..e0b8cea0e0 100644 --- a/Inferences/BoolEqToDiseq.hpp +++ b/Inferences/BoolEqToDiseq.hpp @@ -15,6 +15,8 @@ #ifndef __BoolEqToDiseq__ #define __BoolEqToDiseq__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -34,3 +36,5 @@ class BoolEqToDiseq : public GeneratingInferenceEngine } #endif + +#endif diff --git a/Inferences/BoolSimp.cpp b/Inferences/BoolSimp.cpp index eabbba5904..4f8638927c 100644 --- a/Inferences/BoolSimp.cpp +++ b/Inferences/BoolSimp.cpp @@ -8,11 +8,12 @@ * and in the source directory */ +#if VHOL #include "Lib/Environment.hpp" #include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" @@ -37,11 +38,12 @@ Clause* BoolSimp::simplify(Clause* premise) { while (literalPosition < cLen) { Literal *literal = (*premise)[literalPosition]; + // Below should be safe. We can bool simplify a term that contains free indices NonVariableNonTypeIterator nvi(literal); while (nvi.hasNext()) { subTerm = TermList(nvi.next()); - if(SortHelper::getResultSort(subTerm.term()) == AtomicSort::boolSort()){ + if(SortHelper::getResultSort(subTerm.term()).isBoolSort()){ simpedSubTerm = boolSimplify(subTerm); if(simpedSubTerm != subTerm){ goto substitution; @@ -59,7 +61,9 @@ Clause* BoolSimp::simplify(Clause* premise) { Clause* conclusion = new(conclusionLength) Clause(conclusionLength, SimplifyingInference1(InferenceRule::BOOL_SIMP, premise)); for (unsigned i = 0; i < conclusion->length(); i++) { - (*conclusion)[i] = i == literalPosition ? EqHelper::replace((*premise)[i], subTerm, simpedSubTerm) : (*premise)[i]; + (*conclusion)[i] = i == literalPosition ? + SubtermReplacer(subTerm, simpedSubTerm).transform((*premise)[i]) : + (*premise)[i]; } env.statistics->booleanSimps++; @@ -69,56 +73,33 @@ Clause* BoolSimp::simplify(Clause* premise) { bool BoolSimp::areComplements(TermList t1, TermList t2){ CALL("BoolSimp::areComplements"); - Signature::Symbol* sym; static TermStack args; TermList head; ApplicativeHelper::getHeadAndArgs(t1, head, args); - if(!head.isVar()){ - sym = env.signature->getFunction(head.term()->functor()); - if(sym->proxy() == Signature::NOT){ - ASS(args.size() == 1); - if(args[0] == t2){ return true;} - } - } + if(head.isNot() && args[0] == t2) return true; ApplicativeHelper::getHeadAndArgs(t2, head, args); - if(!head.isVar()){ - sym = env.signature->getFunction(head.term()->functor()); - if(sym->proxy() == Signature::NOT){ - ASS(args.size() == 1); - if(args[0] == t1){ return true;} - } - } + if(head.isNot() && args[0] == t1) return true; return false; } - -TermList BoolSimp::negate(TermList term){ - CALL("BoolSimp::negate"); - - TermList constant, constSort; - - constant = TermList(Term::createConstant(env.signature->getNotProxy())); - constSort = SortHelper::getResultSort(constant.term()); - return ApplicativeHelper::createAppTerm(constSort, constant, term); -} - TermList BoolSimp::boolSimplify(TermList term){ CALL("BoolSimp::boolSimplify"); + typedef ApplicativeHelper AH; + static TermList troo(Term::foolTrue()); static TermList fols(Term::foolFalse()); static TermStack args; TermList head; - ApplicativeHelper::getHeadAndArgs(term, head, args); + AH::getHeadAndArgs(term, head, args); if(head.isVar()){ return term; } - Signature::Symbol* sym = env.signature->getFunction(head.term()->functor()); - switch(sym->proxy()){ + switch(AH::getProxy(head)){ case Signature::AND:{ ASS(args.size() == 2); if(args[1] == fols || args[0] == fols){ return fols; } @@ -144,15 +125,15 @@ TermList BoolSimp::boolSimplify(TermList term){ if(areComplements(args[0], args[1])){ return args[0]; } if(args[0] == args[1]){ return troo; } if(args[0] == troo){ return troo; } - if(args[0] == fols){ return negate(args[1]); } + if(args[0] == fols){ return AH::app(AH::neg(), args[1]); } break; } case Signature::IFF:{ ASS(args.size() == 2); if(args[0] == troo){ return args[1]; } else if(args[1] == troo){ return args[0]; } - if(args[0] == fols){ return negate(args[1]); } else - if(args[1] == fols){ return negate(args[0]); } + if(args[0] == fols){ return AH::app(AH::neg(), args[1]); } else + if(args[1] == fols){ return AH::app(AH::neg(), args[0]); } if(args[0] == args[1]){ return troo; } if(areComplements(args[0], args[1])){ return fols; } break; @@ -161,24 +142,16 @@ TermList BoolSimp::boolSimplify(TermList term){ ASS(args.size() == 1); if(args[0] == troo){ return fols; } if(args[0] == fols){ return troo; } - ApplicativeHelper::getHeadAndArgs(args[0], head, args); - if(!head.isVar()){ - sym = env.signature->getFunction(head.term()->functor()); - if(sym->proxy() == Signature::NOT){ - ASS(args.size() == 1); - return args[0]; - } + AH::getHeadAndArgs(args[0], head, args); + if(head.isNot()){ + ASS(args.size() == 1); + return args[0]; } break; } case Signature::EQUALS:{ ASS(args.size() == 2); if(args[0] == args[1]){ return troo; } - /*if(args[0].isTerm() && args[0].term()->ground() && - args[1].isTerm() && args[1].term()->ground() && - args[0] != args[1]){ - return fols; - }*/ } default: return term; @@ -189,3 +162,5 @@ TermList BoolSimp::boolSimplify(TermList term){ } + +#endif \ No newline at end of file diff --git a/Inferences/BoolSimp.hpp b/Inferences/BoolSimp.hpp index 367bd07b3f..5b5bde8180 100644 --- a/Inferences/BoolSimp.hpp +++ b/Inferences/BoolSimp.hpp @@ -15,6 +15,8 @@ #ifndef __BOOL_SIMP__ #define __BOOL_SIMP__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -30,10 +32,11 @@ class BoolSimp : public ImmediateSimplificationEngine private: TermList boolSimplify(TermList term); - TermList negate(TermList term); bool areComplements(TermList t1, TermList t2); }; } #endif + +#endif diff --git a/Inferences/CNFOnTheFly.cpp b/Inferences/CNFOnTheFly.cpp index e493d2e818..2daa20c2c7 100644 --- a/Inferences/CNFOnTheFly.cpp +++ b/Inferences/CNFOnTheFly.cpp @@ -12,6 +12,8 @@ * */ +#if VHOL + #include "Lib/Environment.hpp" #include "Kernel/Clause.hpp" @@ -39,387 +41,34 @@ static Clause* replaceLits(Clause *c, Literal *a, Literal *b, InferenceRule r, b static TermList sigmaRemoval(TermList sigmaTerm, TermList expsrt); static TermList piRemoval(TermList piTerm, Clause* clause, TermList expsrt); static InferenceRule convert(Signature::Proxy cnst); -static ClauseIterator produceClauses(Clause* c, bool generating, SkolemisingFormulaIndex* index = 0); +static ClauseIterator produceClauses(Clause* c, bool generating, + SkolemisingFormulaIndex* index = 0); typedef ApplicativeHelper AH; -/*Clause* NotProxyISE::simplify(Clause* c){ - CALL("NotProxyISE::simplify"); - - TermList boolSort = AtomicSort::boolSort(); - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); - - static TermStack args; - TermList head; - - for(int i = c->length()-1; i>=0; i--){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList term; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - term = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - term = lhs; - } else { - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - AH::getHeadAndArgs(term, head, args); - Signature::Proxy prox = AH::getProxy(head); - - if((prox == Signature::NOT) && (args.size())){ - TermList rhs = positive ? fols : troo; - Literal* l1 = Literal::createEquality(true, args[0], rhs, boolSort); - Inference *inf = new Inference1(convert(prox), c); - Clause* res = replaceLits(c, lit, l1, inf); - res->setAge(c->age()); - return res; - } - } - - return c; -} - -Clause* EqualsProxyISE::simplify(Clause* c){ - CALL("EqualsProxyISE::simplify"); - - TermList boolSort = AtomicSort::boolSort(); - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); - - static TermStack args; - TermList head; - - for(int i = c->length()-1; i >=0; i--){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList term; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - term = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - term = lhs; - } else { - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - AH::getHeadAndArgs(term, head, args); - Signature::Proxy prox = AH::getProxy(head); - - if((prox == Signature::EQUALS) && (args.size() == 2)){ - TermList srt = *SortHelper::getResultSort(head.term()).term()->nthArgument(0); - Literal* l1 = Literal::createEquality(positive, args[0], args[1], srt); - Inference *inf = new Inference1(convert(prox), c); - Clause* res = replaceLits(c, lit, l1, inf); - res->setAge(c->age()); - return res; - } - } - - return c; -} - -Clause* PiSigmaProxyISE::simplify(Clause* c){ - CALL("PiSigmaProxyISE::simplify"); - - TermList boolSort = AtomicSort::boolSort(); - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); - - static TermStack args; - TermList head; - - for(int i = c->length() - 1 ; i >= 0; i--){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList term; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - term = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - term = lhs; - } else { - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - AH::getHeadAndArgs(term, head, args); - Signature::Proxy prox = AH::getProxy(head); - - if((prox == Signature::PI || prox == Signature::SIGMA ) && (args.size())){ - TermList rhs = positive ? troo : fols; - TermList srt = *SortHelper::getResultSort(head.term()).term()->nthArgument(0); - TermList newTerm; - Inference *inf; - if((prox == Signature::PI && positive) || - (prox == Signature::SIGMA && !positive)){ - inf = new Inference1(convert(Signature::PI), c); - newTerm = piRemoval(args[0], c, srt); - } else { - TermList skolemTerm = sigmaRemoval(args[0], srt); - newTerm = AH::createAppTerm(srt, args[0], skolemTerm); - inf = new Inference1(convert(Signature::SIGMA), c); - } - Literal* l1 = Literal::createEquality(true, newTerm, rhs, boolSort); - Clause* res = replaceLits(c, lit, l1, inf); - res->setAge(c->age()); - return res; - } - } - - return c; -} - -Clause* OrImpAndProxyISE::simplify(Clause* c){ - CALL("rImpAndProxyISE::simplify"); - - TermList boolSort = AtomicSort::boolSort(); - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); - - static TermStack args; - TermList head; - - for(int i = c->length() -1; i >=0; i--){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList term; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - term = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - term = lhs; - } else { - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - AH::getHeadAndArgs(term, head, args); - Signature::Proxy prox = AH::getProxy(head); - - if((prox == Signature::OR) && (args.size() == 2)){ - if(positive){ - Literal* l1 = Literal::createEquality(true, args[1], troo, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], troo, boolSort); - Inference *inf = new Inference1(convert(prox), c); - Clause* res = replaceLits(c, lit, l1, inf, l2); - res->setAge(c->age()); - return res; - } - } - - if((prox == Signature::AND) && (args.size() == 2)){ - if(!positive){ - Literal* l1 = Literal::createEquality(true, args[1], fols, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], fols, boolSort); - Inference *inf = new Inference1(convert(prox), c); - Clause* res = replaceLits(c, lit, l1, inf, l2); - res->setAge(c->age()); - return res; - } - } - - if((prox == Signature::IMP) && (args.size() == 2)){ - if(positive){ - Literal* l1 = Literal::createEquality(true, args[1], fols, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], troo, boolSort); - Inference *inf = new Inference1(convert(prox), c); - Clause* res = replaceLits(c, lit, l1, inf, l2); - res->setAge(c->age()); - return res; - } - } - } - - return c; -} - -ClauseIterator ProxyISE::simplifyMany(Clause* c){ - CALL("ProxyISE::simplifyMany"); - - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); - TermList boolSort = AtomicSort::boolSort(); - - static TermStack args; - TermList head; - - ClauseStack resultStack; - unsigned clength = c->length(); - - for(unsigned i = 0; i < clength; i++){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList term; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - term = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - term = lhs; - } else if(SortHelper::getEqualityArgumentSort(lit) == boolSort) { - //equality or diseqality between boolean terms - Literal* lhsTroo = Literal::createEquality(true, lhs, troo, boolSort); - Literal* lhsFols = Literal::createEquality(true, lhs, fols, boolSort); - Literal* rhsTroo = Literal::createEquality(true, rhs, troo, boolSort); - Literal* rhsFols = Literal::createEquality(true, rhs, fols, boolSort); - if(lit->polarity()){ - Inference* inf1 = new Inference1(convert(Signature::IFF), c); - Inference* inf2 = new Inference1(convert(Signature::IFF), c); - Clause* res1 = replaceLits(c, lit, lhsTroo, inf1, rhsFols); - Clause* res2 = replaceLits(c, lit, lhsFols, inf2, rhsTroo); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - } else { - Inference* inf1 = new Inference1(convert(Signature::XOR), c); - Inference* inf2 = new Inference1(convert(Signature::XOR), c); - Clause* res1 = replaceLits(c, lit, lhsTroo, inf1, rhsTroo); - Clause* res2 = replaceLits(c, lit, lhsFols, inf2, rhsFols); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - } - goto afterLoop; - } else { - continue; - } - - AH::getHeadAndArgs(term, head, args); - Signature::Proxy prox = AH::getProxy(head); - if(prox == Signature::NOT_PROXY){ - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - if((prox == Signature::OR) && (args.size() == 2)){ - if(!positive){ - Literal* l1 = Literal::createEquality(true, args[1], fols, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], fols, boolSort); - Inference* inf1 = new Inference1(convert(prox), c); - Inference* inf2 = new Inference1(convert(prox), c); - Clause* res1 = replaceLits(c, lit, l1, inf1); - Clause* res2 = replaceLits(c, lit, l2, inf2); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - goto afterLoop; - } - } - - if((prox == Signature::AND) && (args.size() == 2)){ - if(positive){ - Literal* l1 = Literal::createEquality(true, args[1], troo, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], troo, boolSort); - Inference* inf1 = new Inference1(convert(prox), c); - Inference* inf2 = new Inference1(convert(prox), c); - Clause* res1 = replaceLits(c, lit, l1, inf1); - Clause* res2 = replaceLits(c, lit, l2, inf2); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - goto afterLoop; - } - } - - if((prox == Signature::IMP) && (args.size() == 2)){ - if(!positive){ - Literal* l1 = Literal::createEquality(true, args[1], troo, boolSort); - Literal* l2 = Literal::createEquality(true, args[0], fols, boolSort); - Inference* inf1 = new Inference1(convert(prox), c); - Inference* inf2 = new Inference1(convert(prox), c); - Clause* res1 = replaceLits(c, lit, l1, inf1); - Clause* res2 = replaceLits(c, lit, l2, inf2); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - goto afterLoop; - } - } - - if((prox == Signature::IFF || prox == Signature::XOR) && (args.size() == 2)){ - bool polarity = (prox == Signature::IFF) == positive; - //equality or diseqality between boolean terms - Literal* lhsTroo = Literal::createEquality(true, args[1], troo, boolSort); - Literal* lhsFols = Literal::createEquality(true, args[1], fols, boolSort); - Literal* rhsTroo = Literal::createEquality(true, args[0], troo, boolSort); - Literal* rhsFols = Literal::createEquality(true, args[0], fols, boolSort); - if(polarity){ - Inference* inf1 = new Inference1(convert(Signature::IFF), c); - Inference* inf2 = new Inference1(convert(Signature::IFF), c); - Clause* res1 = replaceLits(c, lit, lhsTroo, inf1, rhsFols); - Clause* res2 = replaceLits(c, lit, lhsFols, inf2, rhsTroo); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - } else { - Inference* inf1 = new Inference1(convert(Signature::XOR), c); - Inference* inf2 = new Inference1(convert(Signature::XOR), c); - Clause* res1 = replaceLits(c, lit, lhsTroo, inf1, rhsTroo); - Clause* res2 = replaceLits(c, lit, lhsFols, inf2, rhsFols); - res1->setAge(c->age()+1); - res2->setAge(c->age()+1); - resultStack.push(res1); - resultStack.push(res2); - } - goto afterLoop; - } - } - - return ClauseIterator::getEmpty(); - -afterLoop: - - return pvi(getUniquePersistentIterator(ClauseStack::Iterator(resultStack))); - -}*/ - -ClauseIterator produceClauses(Clause* c, bool generating, SkolemisingFormulaIndex* index) +ClauseIterator produceClauses(Clause* c, bool generating, + SkolemisingFormulaIndex* index) { CALL("CNFOnTheFly::produceClauses"); static bool eager = env.options->cnfOnTheFly() == Options::CNFOnTheFly::EAGER; - static bool simp = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_SIMP; + static bool instantiations = env.options->cnfOnTheFly() == Options::CNFOnTheFly::CONJ_EAGER; + static bool simp = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_SIMP || instantiations; static bool gen = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_GEN; + static bool simp_except_pi_sigma_gen = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_SIMP_PI_SIGMA_GEN; static bool simp_except_not_be_off = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_SIMP_NOT_GEN_BOOL_EQ_OFF; static bool simp_except_not_and_be = env.options->cnfOnTheFly() == Options::CNFOnTheFly::LAZY_SIMP_NOT_GEN_BOOL_EQ_GEN; - bool not_be = simp_except_not_be_off || (!generating && simp_except_not_and_be); + // if we don't want to simplify <=>, or we want to simplify it as a generating inference, but we have reached here + // from a simplification inference, or the opposite + bool not_be = simp_except_not_be_off || (!generating && simp_except_not_and_be) || + ( generating && simp_except_pi_sigma_gen); if(generating && (eager || simp)){ return ClauseIterator::getEmpty(); } if(!generating && gen){ return ClauseIterator::getEmpty(); } - TermList troo = TermList(Term::foolTrue()); - TermList fols = TermList(Term::foolFalse()); + TermList troo = AH::top(); + TermList fols = AH::bottom(); TermList boolSort = AtomicSort::boolSort(); static TermStack args; @@ -464,13 +113,29 @@ ClauseIterator produceClauses(Clause* c, bool generating, SkolemisingFormulaInde AH::getHeadAndArgs(term, head, args); Signature::Proxy prox = AH::getProxy(head); - if(prox == Signature::NOT_PROXY || prox == Signature::IFF || - prox == Signature::XOR){ + if(prox == Signature::NOT_PROXY || prox == Signature::IFF || prox == Signature::XOR){ + // iff and xor are dealt with by IFFXORRewriter continue; } - if(generating && !gen && prox != Signature::NOT){ - continue; + // need to decide whether to continue at this point or not + + if(simp_except_pi_sigma_gen){ + if(generating && prox != Signature::PI && prox != Signature::SIGMA){ + continue; + } + if(!generating && (prox == Signature::PI || prox == Signature::SIGMA)){ + continue; + } + } + + if(simp_except_not_be_off || simp_except_not_and_be){ + if(generating && prox != Signature::NOT){ + continue; + } + if(!generating && prox == Signature::NOT){ + continue; + } } bool positive = AH::isTrue(boolVal) == lit->polarity(); @@ -547,23 +212,59 @@ ClauseIterator produceClauses(Clause* c, bool generating, SkolemisingFormulaInde if((prox == Signature::PI || prox == Signature::SIGMA ) && (args.size())){ TermList rhs = positive ? troo : fols; - TermList srt = *SortHelper::getResultSort(head.term()).term()->nthArgument(0); + TermList srt = SortHelper::getResultSort(head.term()).domain(); + ASS(srt.isArrowSort()); TermList newTerm; InferenceRule rule; - if((prox == Signature::PI && positive) || - (prox == Signature::SIGMA && !positive)){ + if((prox == Signature::PI && positive) || (prox == Signature::SIGMA && !positive)){ rule = convert(Signature::PI); newTerm = piRemoval(args[0], c, srt); + if(instantiations && !args[0].isVar()){ + DHSet* insts = env.signature->getInstantiations(); + DHSet::Iterator it(*insts); + while(it.hasNext()){ + TermList t = it.next(); + ASS(t.isTerm()); + static RobSubstitutionTS subst; + subst.reset(); + + TermList tSort = SortHelper::getResultSort(t.term()); + TermList aSort = srt.domain(); + + if(subst.unify(tSort,0,aSort,1)){ + TermList tS = subst.apply(t, 0); + TermList argS = subst.apply(args[0],1); + + TermList app = AH::app(argS, tS); + Literal* l1 = Literal::createEquality(true, app, rhs, boolSort); + + unsigned clen = c->length(); + + // cant use replaceLits, as we need to apply the type unifier + Clause* res = new(clen) Clause(clen, GeneratingInference1(InferenceRule::BOOL_INSTANTIATION, c)); + (*res)[0] = l1; + unsigned next = 1; + for(unsigned i=0;igetGeneralizations(TypedTermList(term.term()), true); + auto results = index->getHOLGeneralizations(TypedTermList(term.term())); if(results.hasNext()){ TermQueryResult tqr = results.next(); TermList skolemTerm = tqr.term; - skolemTerm=tqr.substitution->applyToBoundResult(skolemTerm); - newTerm = AH::createAppTerm(srt, args[0], skolemTerm); + skolemTerm=tqr.unifier->applyToBoundResult(skolemTerm); + newTerm = AH::app(srt, args[0], skolemTerm); newTermCreated = true; } } @@ -572,7 +273,7 @@ ClauseIterator produceClauses(Clause* c, bool generating, SkolemisingFormulaInde if(index){ index->insertFormula(TypedTermList(term.term()), skolemTerm); } - newTerm = AH::createAppTerm(srt, args[0], skolemTerm); + newTerm = AH::app(srt, args[0], skolemTerm); } rule = convert(Signature::SIGMA); } @@ -606,6 +307,8 @@ Clause* replaceLits(Clause *c, Literal *a, Literal *b, InferenceRule r, bool inc Clause* res = new(length) Clause(length, NonspecificInference1(r, c)); res->setAge(incAge? c->age() + 1 : c->age()); + env.statistics->proxyEliminations++; + unsigned i = 0; while ((*c)[i] != a) { i++; } std::memcpy(res->literals(), c->literals(), length * sizeof(Literal*)); @@ -678,7 +381,7 @@ TermList sigmaRemoval(TermList sigmaTerm, TermList expsrt){ } } - TermList resultSort = *expsrt.term()->nthArgument(0); + TermList resultSort = expsrt.domain(); SortHelper::normaliseArgSorts(typeVars, termVarSorts); SortHelper::normaliseSort(typeVars, resultSort); @@ -686,9 +389,9 @@ TermList sigmaRemoval(TermList sigmaTerm, TermList expsrt){ TermList skSymSort = AtomicSort::arrowSort(termVarSorts, resultSort); unsigned fun = Skolem::addSkolemFunction(typeVars.size(), typeVars.size(), 0, skSymSort); TermList head = TermList(Term::create(fun, typeVars.size(), typeVars.begin())); - TermList skolemTerm = ApplicativeHelper::createAppTerm(SortHelper::getResultSort(head.term()), head, termVars); + TermList skolemTerm = AH::app(head, termVars); - ASS(*expsrt.term()->nthArgument(1) == AtomicSort::boolSort()); + ASS(expsrt.result().isBoolSort()); //cout << "OUT OF sigmaRemoval " + sigmaTerm.toString() << endl; return skolemTerm; @@ -700,11 +403,10 @@ TermList piRemoval(TermList piTerm, Clause* clause, TermList expsrt){ unsigned maxVar = clause->maxVar(); do{ - maxVar++; - TermList newVar = TermList(maxVar, false); - piTerm = ApplicativeHelper::createAppTerm(expsrt, piTerm, newVar); - expsrt = *expsrt.term()->nthArgument(1); - }while(expsrt != AtomicSort::boolSort()); + TermList newVar(++maxVar, false); + piTerm = AH::app(expsrt, piTerm, newVar); + expsrt = expsrt.result(); + }while(!expsrt.isBoolSort()); return piTerm; } @@ -764,7 +466,8 @@ void LazyClausificationGIE::detach() CALL("LazyClausificationGIE::detach"); _formulaIndex=0; - _salg->getIndexManager()->release(SKOLEMISING_FORMULA_INDEX); + + _salg->getIndexManager()->release(SKOLEMISING_FORMULA_INDEX); GeneratingInferenceEngine::detach(); } @@ -782,6 +485,7 @@ void LazyClausification::detach() CALL("LazyClausification::detach"); _formulaIndex=0; + _salg->getIndexManager()->release(SKOLEMISING_FORMULA_INDEX); SimplificationEngine::detach(); } @@ -809,3 +513,5 @@ ClauseIterator LazyClausification::perform(Clause* c) } + +#endif \ No newline at end of file diff --git a/Inferences/CNFOnTheFly.hpp b/Inferences/CNFOnTheFly.hpp index c6ef4ffa4a..c708b7774a 100644 --- a/Inferences/CNFOnTheFly.hpp +++ b/Inferences/CNFOnTheFly.hpp @@ -15,6 +15,8 @@ #ifndef __CNFOnTheFly__ #define __CNFOnTheFly__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" #include "Kernel/Term.hpp" @@ -95,63 +97,9 @@ class LazyClausificationGIE SkolemisingFormulaIndex* _formulaIndex; }; -/*class NotProxyISE - : public ImmediateSimplificationEngine -{ -public: - CLASS_NAME(NotProxyISE); - USE_ALLOCATOR(NotProxyISE); - - Kernel::Clause* simplify(Kernel::Clause* c); -}; - - -class EqualsProxyISE - : public ImmediateSimplificationEngine -{ - -public: - CLASS_NAME(EqualsProxyISE); - USE_ALLOCATOR(EqualsProxyISE); - - Kernel::Clause* simplify(Kernel::Clause* c); -}; - - -class OrImpAndProxyISE - : public ImmediateSimplificationEngine -{ - -public: - CLASS_NAME(OrImpAndProxyISE); - USE_ALLOCATOR(OrImpAndProxyISE); - - Kernel::Clause* simplify(Kernel::Clause* c); -}; - - -class PiSigmaProxyISE - : public ImmediateSimplificationEngine -{ - -public: - CLASS_NAME(PiSigmaProxyISE); - USE_ALLOCATOR(PiSigmaProxyISE); - - Kernel::Clause* simplify(Kernel::Clause* c); -}; - - -class ProxyISE - : public ImmediateSimplificationEngine { - public: - CLASS_NAME(ProxyISE); - USE_ALLOCATOR(ProxyISE); - ClauseIterator simplifyMany(Clause* c); - Clause* simplify(Clause* c){ NOT_IMPLEMENTED; } -};*/ - } #endif + +#endif diff --git a/Inferences/Cases.cpp b/Inferences/Cases.cpp index 9e60675f6e..ce694e2cb7 100644 --- a/Inferences/Cases.cpp +++ b/Inferences/Cases.cpp @@ -17,16 +17,18 @@ * [1] http://arxiv.org/abs/1505.01682 */ +#if VHOL + #include "Lib/Environment.hpp" #include "Kernel/Clause.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" #include "Kernel/Signature.hpp" #include "Kernel/OperatorType.hpp" -#include "Kernel/SortHelper.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -36,21 +38,13 @@ namespace Inferences { Clause* Cases::performParamodulation(Clause* premise, Literal* lit, TermList t) { CALL("Cases::performParamodulation"); - + ASS(t.isTerm()); - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - - if((t == lhs) || (t == rhs)){ - return 0; - } - static TermList troo(Term::foolTrue()); static TermList fols(Term::foolFalse()); - - // Found a boolean term! Create the C[true] \/ s = false clause + // Create the C[true] \/ s = false clause unsigned conclusionLength = premise->length() + 1; Clause* conclusion = new(conclusionLength) Clause(conclusionLength, @@ -63,7 +57,7 @@ Clause* Cases::performParamodulation(Clause* premise, Literal* lit, TermList t) if(curr != lit){ (*conclusion)[i] = (*premise)[i]; } else { - (*conclusion)[i] = EqHelper::replace((*premise)[i], t, troo); + (*conclusion)[i] = SubtermReplacer(t,troo).transform((*premise)[i]); } } @@ -120,3 +114,5 @@ ClauseIterator Cases::generateClauses(Clause* premise) } } + +#endif diff --git a/Inferences/Cases.hpp b/Inferences/Cases.hpp index d7f4eef6bd..b025ba4945 100644 --- a/Inferences/Cases.hpp +++ b/Inferences/Cases.hpp @@ -15,6 +15,8 @@ #ifndef __Cases__ #define __Cases__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -35,3 +37,5 @@ class Cases : public GeneratingInferenceEngine { } #endif + +#endif diff --git a/Inferences/CasesSimp.cpp b/Inferences/CasesSimp.cpp index 587b3221f7..86b7eb4a24 100644 --- a/Inferences/CasesSimp.cpp +++ b/Inferences/CasesSimp.cpp @@ -17,10 +17,13 @@ * [1] http://arxiv.org/abs/1505.01682 */ +#if VHOL + #include "Lib/Environment.hpp" +#include "Lib/PairUtils.hpp" #include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" @@ -70,8 +73,8 @@ ClauseIterator CasesSimp::performSimplification(Clause* premise, Literal* lit, T (*conclusion1)[i] = (*premise)[i]; (*conclusion2)[i] = (*premise)[i]; } else { - (*conclusion1)[i] = EqHelper::replace((*premise)[i], t, troo); - (*conclusion2)[i] = EqHelper::replace((*premise)[i], t, fols); + (*conclusion1)[i] = SubtermReplacer(t,troo).transform((*premise)[i]); + (*conclusion2)[i] = SubtermReplacer(t,fols).transform((*premise)[i]); } } @@ -124,10 +127,12 @@ ClauseIterator CasesSimp::simplifyMany(Clause* premise) auto it3 = getMapAndFlattenIterator(it2,RewriteableSubtermsFn()); - //Perform Narrow auto it4 = getMapAndFlattenIterator(it3,ResultFn(premise, *this)); return pvi( it4 ); } } + +#endif + diff --git a/Inferences/CasesSimp.hpp b/Inferences/CasesSimp.hpp index c5fbbb4902..a766294def 100644 --- a/Inferences/CasesSimp.hpp +++ b/Inferences/CasesSimp.hpp @@ -15,6 +15,8 @@ #ifndef __CASES_SIMP__ #define __CASES_SIMP__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -45,3 +47,5 @@ class CasesSimp : public ImmediateSimplificationEngine { } #endif + +#endif diff --git a/Inferences/Choice.cpp b/Inferences/Choice.cpp index b9c045ee76..4f8b12b9ee 100644 --- a/Inferences/Choice.cpp +++ b/Inferences/Choice.cpp @@ -12,6 +12,8 @@ * Implements class PrimitiveInstantiation. */ +#if VHOL + #include "Debug/RuntimeStatistics.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -44,12 +46,13 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; +typedef ApplicativeHelper AH; + Clause* Choice::createChoiceAxiom(TermList op, TermList set) { CALL("Choice::createChoiceAxiom"); - TermList opType = SortHelper::getResultSort(op.term()); - TermList setType = ApplicativeHelper::getNthArg(opType, 1); + TermList setSort = SortHelper::getResultSort(op.term()).domain(); unsigned max = 0; FormulaVarIterator fvi(&set); @@ -61,29 +64,29 @@ Clause* Choice::createChoiceAxiom(TermList op, TermList set) } TermList freshVar = TermList(max+1, false); - TermList t1 = ApplicativeHelper::createAppTerm(setType, set, freshVar); - TermList t2 = ApplicativeHelper::createAppTerm(opType, op, set); - t2 = ApplicativeHelper::createAppTerm(setType, set, t2); + TermList t1 = AH::app(setSort, set, freshVar); + TermList t2 = AH::app(op, set); + t2 = AH::app(setSort, set, t2); Clause* axiom = new(2) Clause(2, NonspecificInference0(UnitInputType::AXIOM, InferenceRule::CHOICE_AXIOM)); - (*axiom)[0] = Literal::createEquality(true, t1, TermList(Term::foolFalse()), AtomicSort::boolSort());; - (*axiom)[1] = Literal::createEquality(true, t2, TermList(Term::foolTrue()), AtomicSort::boolSort());; + (*axiom)[0] = Literal::createEquality(true, t1, AH::bottom(), AtomicSort::boolSort()); + (*axiom)[1] = Literal::createEquality(true, t2, AH::top(), AtomicSort::boolSort()); return axiom; } struct Choice::AxiomsIterator { - AxiomsIterator(Term* term) + AxiomsIterator(TermList term) { CALL("Choice::AxiomsIterator"); + ASS(term.isApplication()); + + _set = term.rhs(); - _set = *term->nthArgument(3); - _headSort = AtomicSort::arrowSort(*term->nthArgument(0),*term->nthArgument(1)); - _resultSort = ApplicativeHelper::getResultApplieadToNArgs(_headSort, 1); - - //cout << "the result sort is " + _resultSort.toString() << endl; + _headSort = AH::lhsSort(term); + _resultSort = SortHelper::getResultSort(term.term()); DHSet* ops = env.signature->getChoiceOperators(); DHSet::Iterator opsIt(*ops); @@ -103,21 +106,21 @@ struct Choice::AxiomsIterator _choiceOps.remove(op); OperatorType* type = env.signature->getFunction(op)->fnType(); - static RobSubstitution subst; + static RobSubstitutionTL subst; static TermStack typeArgs; typeArgs.reset(); subst.reset(); for(int i = type->numTypeArguments() -1; i >= 0; i--){ - TermList typeArg = TermList((unsigned)i, false); + TermList typeArg = TermList((unsigned)i, VarBank::QUERY_BANK); typeArgs.push(typeArg); } Term* choiceOp = Term::create(op, typeArgs.size(), typeArgs.begin()); TermList choiceOpSort = SortHelper::getResultSort(choiceOp); - if(subst.unify(choiceOpSort, 0, _headSort, 1)){ + if(subst.unify(choiceOpSort, _headSort)){ _nextChoiceOperator = TermList(choiceOp); - _opApplied = subst.apply(_nextChoiceOperator, 0); - _setApplied = subst.apply(_set, 1); + _opApplied = subst.apply(_nextChoiceOperator, VarBank::QUERY_BANK); + _setApplied = subst.apply(_set, DEFAULT_BANK); _inBetweenNextandHasNext = true; return true; } @@ -150,12 +153,13 @@ struct Choice::ResultFn { ResultFn(){} - VirtualIterator operator() (Term* term){ - TermList op = *term->nthArgument(2); + VirtualIterator operator() (Term* t){ + TermList term(t); + TermList op = term.lhs(); if(op.isVar()){ return pvi(AxiomsIterator(term)); } else { - Clause* axiom = createChoiceAxiom(op, *term->nthArgument(3)); + Clause* axiom = createChoiceAxiom(op, term.rhs()); env.statistics->choiceInstances++; return pvi(getSingletonIterator(axiom)); } @@ -166,24 +170,23 @@ struct Choice::IsChoiceTerm { bool operator()(Term* t) { + if(t->isLambdaTerm()) return false; TermStack args; TermList head; ApplicativeHelper::getHeadAndArgs(t, head, args); - if(args.size() != 1){ return false; } - - TermList headSort = AtomicSort::arrowSort(*t->nthArgument(0), *t->nthArgument(1)); - - TermList tv = TermList(0, false); - TermList o = AtomicSort::boolSort(); - TermList sort = AtomicSort::arrowSort(AtomicSort::arrowSort(tv, o), tv); - - static RobSubstitution subst; - subst.reset(); - - subst.reset(); - return ((head.isVar() || env.signature->isChoiceOperator(head.term()->functor())) && - subst.match(sort,0,headSort,1)); - + if(args.size() == 1 && !args[0].isVar() && !args[0].containsLooseIndex()){ + TermList headSort = AH::lhsSort(TermList(t)); + + TermList tv = TermList(0, VarBank::QUERY_BANK); // put on QUERY_BANK to separate in from variables in headSort + TermList o = AtomicSort::boolSort(); + TermList sort = AtomicSort::arrowSort(AtomicSort::arrowSort(tv, o), tv); + + static RobSubstitutionTL subst; + subst.reset(); + return ((head.isVar() || env.signature->isChoiceOperator(head.term()->functor())) && + subst.match(sort,headSort,VarBank::QUERY_BANK)); + } + return false; } }; @@ -203,24 +206,21 @@ struct Choice::SubtermsFn ClauseIterator Choice::generateClauses(Clause* premise) { - CALL("PrimitiveInstantiation::generateClauses"); - - //cout << "Choice with " << premise->toString() << endl; + CALL("Choice::generateClauses"); //is this correct? auto it1 = premise->getSelectedLiteralIterator(); - //filter out literals that are not suitable for narrowing + auto it2 = getMapAndFlattenIterator(it1, SubtermsFn()); - //pair of literals and possible rewrites that can be applied to literals auto it3 = getFilteredIterator(it2, IsChoiceTerm()); - //apply rewrite rules to literals auto it4 = getMapAndFlattenIterator(it3, ResultFn()); - return pvi( it4 ); } } + +#endif diff --git a/Inferences/Choice.hpp b/Inferences/Choice.hpp index 70bbfb32e7..8b93170583 100644 --- a/Inferences/Choice.hpp +++ b/Inferences/Choice.hpp @@ -15,6 +15,8 @@ #ifndef __CHOICE__ #define __CHOICE__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -40,3 +42,5 @@ class Choice : public GeneratingInferenceEngine } #endif + +#endif diff --git a/Inferences/CombinatorDemodISE.cpp b/Inferences/CombinatorDemodISE.cpp deleted file mode 100644 index 358de9c4c0..0000000000 --- a/Inferences/CombinatorDemodISE.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file CombinatorDemodISE.cpp - * Implements class CombinatorDemodISE. - */ - -#include "Lib/Random.hpp" -#include "Lib/Environment.hpp" -#include "Lib/DArray.hpp" -#include "Lib/SmartPtr.hpp" - -#include "Kernel/Term.hpp" -#include "Kernel/Clause.hpp" -#include "Kernel/ApplicativeHelper.hpp" -#include "Kernel/TermIterators.hpp" -#include "Kernel/Inference.hpp" -#include "Kernel/SKIKBO.hpp" -#include "Kernel/SortHelper.hpp" -#include "Shell/Statistics.hpp" -#include "CombinatorDemodISE.hpp" - -using namespace Lib; -using namespace Kernel; -using namespace Inferences; - -typedef ApplicativeHelper AH; - -Clause* CombinatorDemodISE::simplify(Clause* c) -{ - CALL("CombinatorDemodISE::simplify"); - - Literal* newLit; - LiteralStack litStack; - bool modified = false; - - // cout << "into CombinatorDemodISE " + c->toString() << endl; - - unsigned length = 0; - unsigned length0; - unsigned length1; - - for(unsigned i = 0; i < c->length(); i++){ - Literal* lit = (*c)[i]; - ASS(lit->isEquality()); - TermList t0 = *lit->nthArgument(0); - TermList t1 = *lit->nthArgument(1); - - length0 = 0; - length1 = 0; - - TermList t0r = t0.isVar() ? t0 : reduce(t0, length0); - TermList t1r = t1.isVar() ? t1 : reduce(t1, length1); - - length = length + length0 + length1; - - if((t0r != t0) || (t1r != t1)){ - modified = true; - newLit = Literal::createEquality(lit->polarity(), TermList(t0r), TermList(t1r), SortHelper::getResultSort(t0.term())); - litStack.push(newLit); - } else { - litStack.push(lit); - } - } - - if(!modified){ - return c; - } - - Inference inf = SimplifyingInference1(InferenceRule::COMBINATOR_DEMOD, c); - inf.increaseReductions(length); - Clause* newC = Clause::fromStack(litStack, inf); - /*if(c->number() == 1620){ - cout << "out of CombinatorDemodISE " + newC->toString() << endl; - }*/ - //if(!newC){ cout << "RETURNING NULL CLAUSE" << endl; } - return newC; -} - -TermList CombinatorDemodISE::reduce(TermList t, unsigned& length) -{ - CALL("CombinatorDemodISE::reduce"); - - typedef SmartPtr ArgsIt_ptr; - - ASS(!t.isVar()); - - static Stack terms(8); - static Stack infos(8); - static Stack modified(8); - static Stack argIts(8); - static TermStack args; - - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS(infos.isEmpty()); - modified.reset(); - args.reset(); - - headNormalForm(t); - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(t, false))); - ArgsIt_ptr argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - - for (;;) { - if (!argIts.top()->hasNext()) { - argIts.pop(); - if (terms.isEmpty()) { - //we're done, args stack contains modified arguments - //of the literal. - ASS(argIts.isEmpty()); - break; - } - Term* orig = terms.pop(); - AH::HigherOrderTermInfo hoti=infos.pop(); - if (!modified.pop()) { - args.truncate(args.length() - hoti.argNum); - args.push(TermList(orig)); - continue; - } - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - TermList* argLst=&args.top() - (hoti.argNum - 1); - args.truncate(args.length() - hoti.argNum); - - TermList trm = AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum); - args.push(trm); - modified.setTop(true); - continue; - } - - TermList tl= argIts.top()->next(); - bool reduced = headNormalForm(tl); - if(reduced){ - length++; - modified.setTop(true); - } - if (tl.isVar()) { - args.push(tl); - continue; - } - ASS(tl.isTerm()); - Term* t=tl.term(); - terms.push(t); - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(tl, false))); - argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - } - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS_EQ(modified.length(),1); - ASS_EQ(infos.length(),1); - AH::HigherOrderTermInfo hoti=infos.pop(); - ASS_EQ(args.length(),hoti.argNum); - - if (!modified.pop()) { - return t; - } - - TermList* argLst=&args.top() - (hoti.argNum-1); - ASS(!t.term()->isLiteral()); - return AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum);; -} - -bool CombinatorDemodISE::headNormalForm(TermList& t) -{ - CALL("CombinatorDemodISE::headNormalForm"); - - static TermStack args; - TermList head; - - bool modified = false; - - for(;;){ - AH::getHeadAndArgs(t, head, args); - if(AH::isComb(head) && !AH::isUnderApplied(head, args.size())){ - modified = true; - t = SKIKBO::reduce(args, head); - } else { - break; - } - } - return modified; -} - - - diff --git a/Inferences/CombinatorNormalisationISE.cpp b/Inferences/CombinatorNormalisationISE.cpp deleted file mode 100644 index 8c2dcb8383..0000000000 --- a/Inferences/CombinatorNormalisationISE.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file CombinatorNormalisationISE.cpp - * Implements class CombinatorNormalisationISE. - */ - -#include "Lib/Random.hpp" -#include "Lib/Environment.hpp" -#include "Lib/DArray.hpp" -#include "Lib/SmartPtr.hpp" - -#include "Kernel/Term.hpp" -#include "Kernel/Clause.hpp" -#include "Kernel/ApplicativeHelper.hpp" -#include "Kernel/TermIterators.hpp" -#include "Kernel/Inference.hpp" -#include "Kernel/SKIKBO.hpp" -#include "Kernel/SortHelper.hpp" -#include "Kernel/Signature.hpp" -#include "Shell/Statistics.hpp" -#include "CombinatorNormalisationISE.hpp" - -using namespace Lib; -using namespace Kernel; -using namespace Inferences; - -typedef ApplicativeHelper AH; - -Clause* CombinatorNormalisationISE::simplify(Clause* c) -{ - CALL("CombinatorNormalisationISE::simplify"); - - Literal* newLit; - LiteralStack litStack; - bool modified = false; - - // cout << "into CombinatorNormalisationISE " + c->toString() << endl; - - for(unsigned i = 0; i < c->length(); i++){ - Literal* lit = (*c)[i]; - ASS(lit->isEquality()); - TermList t0 = *lit->nthArgument(0); - TermList t1 = *lit->nthArgument(1); - - TermList t0r = t0.isVar() ? t0 : normalise(t0); - TermList t1r = t1.isVar() ? t1 : normalise(t1); - - if((t0r != t0) || (t1r != t1)){ - modified = true; - newLit = Literal::createEquality(lit->polarity(), TermList(t0r), TermList(t1r), SortHelper::getResultSort(t0.term())); - litStack.push(newLit); - } else { - litStack.push(lit); - } - } - - if(!modified){ - return c; - } - - Clause* newC = Clause::fromStack(litStack, SimplifyingInference1(InferenceRule::COMBINATOR_NORMALISE, c)); - - return newC; -} - -TermList CombinatorNormalisationISE::normalise(TermList t) -{ - CALL("CombinatorNormalisationISE::normalise"); - - typedef SmartPtr ArgsIt_ptr; - - ASS(!t.isVar()); - - static Stack terms(8); - static Stack infos(8); - static Stack modified(8); - static Stack argIts(8); - static TermStack args; - - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS(infos.isEmpty()); - modified.reset(); - args.reset(); - - replaceWithSmallerCombinator(t); - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(t, false))); - ArgsIt_ptr argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - - for (;;) { - if (!argIts.top()->hasNext()) { - argIts.pop(); - if (terms.isEmpty()) { - //we're done, args stack contains modified arguments - //of the literal. - ASS(argIts.isEmpty()); - break; - } - Term* orig = terms.pop(); - AH::HigherOrderTermInfo hoti=infos.pop(); - if (!modified.pop()) { - args.truncate(args.length() - hoti.argNum); - args.push(TermList(orig)); - continue; - } - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - TermList* argLst=&args.top() - (hoti.argNum - 1); - args.truncate(args.length() - hoti.argNum); - - TermList trm = AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum); - args.push(trm); - modified.setTop(true); - continue; - } - - TermList tl= argIts.top()->next(); - //cout << "tl is " + tl.toString() << endl; - bool reduced = replaceWithSmallerCombinator(tl); - if(reduced){ - //cout << "after mod " + tl.toString() << endl; - modified.setTop(true); - } - if (tl.isVar()) { - args.push(tl); - continue; - } - ASS(tl.isTerm()); - Term* t=tl.term(); - terms.push(t); - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(tl, false))); - argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - } - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS_EQ(modified.length(),1); - ASS_EQ(infos.length(),1); - AH::HigherOrderTermInfo hoti=infos.pop(); - ASS_EQ(args.length(),hoti.argNum); - - if (!modified.pop()) { - return t; - } - - TermList* argLst=&args.top() - (hoti.argNum-1); - ASS(!t.term()->isLiteral()); - return AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum);; -} - -bool CombinatorNormalisationISE::replaceWithSmallerCombinator(TermList& t) -{ - CALL("CombinatorNormalisationISE::replaceWithSmallerCombinator"); - - static TermStack args; - static TermStack args1; - static TermStack args2; - TermList head; - TermList head1; - TermList head2; - - TermList sort; - if(t.isTerm()){ - sort = SortHelper::getResultSort(t.term()); - } - - //cout << "The original term is " + t.toString() << endl; - - AH::getHeadAndArgs(t, head, args); - if(AH::isComb(head) && (args.size() == 1 || args.size() == 2)){ - Signature::Combinator comb = AH::getComb(head); - switch(comb){ - case Signature::S_COMB: { - if(args.size() == 1){ - TermList arg1 = args[0]; - AH::getHeadAndArgs(arg1, head1, args1); - if(args1.size() == 1 && - AH::isComb(head1) && (AH::getComb(head1) == Signature::C_COMB || - AH::getComb(head1) == Signature::S_COMB) && - AH::isComb(args1[0]) && AH::getComb(args1[0]) == Signature::K_COMB){ - //S (C K) = I /\ S (S K) = I - t = TermList(Term::create1(env.signature->getCombinator(Signature::I_COMB), AH::getNthArg(sort,1))); - return true; - } - if(args1.size() == 2 && - AH::isComb(head1) && AH::getComb(head1) == Signature::B_COMB && - AH::isComb(args1[1]) && AH::getComb(args1[1]) == Signature::K_COMB){ - TermList s1 = AH::getNthArg(SortHelper::getResultSort(head1.term()), 2); - TermList s2 = AH::getNthArg(sort, 1); - t = createKTerm(s1, s2, args1[0]); - return true; - } - } - if(args.size() == 2){ - TermList arg1 = args[1]; - TermList arg2 = args[0]; - if(AH::isComb(arg1) && AH::getComb(arg1) == Signature::K_COMB){ - t = TermList(Term::create1(env.signature->getCombinator(Signature::I_COMB), AH::getNthArg(sort,1))); - return true; - } - AH::getHeadAndArgs(arg1, head1, args1); - if(args1.size() == 2 && - AH::isComb(head1) && AH::getComb(head1) == Signature::B_COMB && - AH::isComb(args1[1]) && AH::getComb(args1[1]) == Signature::K_COMB){ - t = args1[0]; - return true; - } - AH::getHeadAndArgs(arg2, head2, args2); - bool arg2isKY = args2.size() == 1 && AH::isComb(head2) && AH::getComb(head2) == Signature::K_COMB; - bool arg1isKX = args1.size() == 1 && AH::isComb(head1) && AH::getComb(head1) == Signature::K_COMB; - if(arg1isKX){ - if(arg2isKY){ - TermList xSort = AH::getNthArg(SortHelper::getResultSort(head1.term()), 1); - TermList xy = AH::createAppTerm(xSort, args1[0], args2[0]); - TermList s1 = SortHelper::getResultSort(xy.term()); - TermList s2 = AH::getNthArg(sort, 1); - t = createKTerm(s1, s2, xy); - return true; - } - if(!args2.size() && AH::isComb(head2) && AH::getComb(head2) == Signature::I_COMB){ - t = args1[0]; - return true; - } - TermList arg1sort = AH::getNthArg(SortHelper::getResultSort(head1.term()),1); - TermList arg2sort = AH::getNthArg(SortHelper::getResultSort(head.term()),2); - t = createSCorBTerm(args1[0], arg1sort, args[0], arg2sort, Signature::B_COMB); - return true; - } - if(arg2isKY){ - TermList arg1sort = AH::getNthArg(SortHelper::getResultSort(head.term()),1); - TermList arg2sort = AH::getNthArg(SortHelper::getResultSort(head2.term()),1); - t = createSCorBTerm(args[1], arg1sort, args2[0], arg2sort, Signature::C_COMB); - return true; - } - } - } - break; - case Signature::B_COMB : { - if(args.size() == 1){ - if(AH::isComb(args[0]) && AH::getComb(args[0]) == Signature::I_COMB){ - t = TermList(Term::create1(env.signature->getCombinator(Signature::I_COMB), AH::getNthArg(sort,1))); - return true; - } - } - if(args.size() == 2){ - if(AH::isComb(args[0]) && AH::getComb(args[0]) == Signature::I_COMB){ - t = args[1]; - return true; - } - AH::getHeadAndArgs(args[0], head2, args2); - bool arg2isKY = args2.size() == 1 && AH::isComb(head2) && AH::getComb(head2) == Signature::K_COMB; - if(arg2isKY){ - TermList xSort = AH::getNthArg(SortHelper::getResultSort(head.term()), 1); - TermList xy = AH::createAppTerm(xSort, args[1], args2[0]); - TermList s1 = SortHelper::getResultSort(xy.term()); - TermList s2 = AH::getNthArg(sort, 1); - t = createKTerm(s1, s2, xy); - return true; - } - } - } - break; - case Signature::C_COMB : { - if(args.size() == 1){ - TermList arg1 = args[0]; - AH::getHeadAndArgs(arg1, head1, args1); - if(args1.size() == 1 && - AH::isComb(head1) && AH::getComb(head1) == Signature::C_COMB){ - t = args1[0]; //C (C t) = t - return true; - } - } - if(args.size() == 2){ - AH::getHeadAndArgs(args[1], head1, args1); - bool arg1isKX = args1.size() == 1 && AH::isComb(head1) && AH::getComb(head1) == Signature::K_COMB; - if(arg1isKX){ - TermList xSort = AH::getNthArg(SortHelper::getResultSort(head1.term()), 1); - TermList xy = AH::createAppTerm(xSort, args1[0], args[0]); - TermList s1 = SortHelper::getResultSort(xy.term()); - TermList s2 = AH::getNthArg(sort, 1); - t = createKTerm(s1, s2, xy); - return true; - } - } - } - break; - default: {} - - } - } - - return false; -} - -TermList CombinatorNormalisationISE::createKTerm(TermList s1, TermList s2, TermList arg1) -{ - CALL("CombinatorNormalisationISE::createKTerm"); - - unsigned kcomb = env.signature->getCombinator(Signature::K_COMB); - TermList res = TermList(Term::create2(kcomb, s1, s2)); - res = AH::createAppTerm(SortHelper::getResultSort(res.term()), res, arg1); - return res; -} - -TermList CombinatorNormalisationISE::createSCorBTerm(TermList arg1, TermList arg1sort, - TermList arg2, TermList arg2sort, Signature::Combinator comb) -{ - CALL("CombinatorNormalisationISE::createSCorBTerm"); - - TermList s1, s2, s3; - unsigned cb = env.signature->getCombinator(comb); - - if(comb == Signature::S_COMB || comb == Signature::C_COMB){ - //cout << "CCOMB arg1 " + arg1.toString() + " of sort " + arg1sort.toString() << endl; - s1 = AH::getNthArg(arg1sort, 1); - s2 = AH::getNthArg(arg1sort, 2); - s3 = AH::getResultApplieadToNArgs(arg1sort, 2); - } else { - //cout << "BCOMB arg1 " + arg1.toString() + " of sort " + arg1sort.toString() << endl; - s1 = AH::getNthArg(arg2sort, 1); - s2 = AH::getNthArg(arg1sort, 1); - s3 = AH::getResultApplieadToNArgs(arg1sort, 1); - } - - TermList args[] = {s1, s2, s3}; - TermList c = TermList(Term::create(cb, 3, args)); - return AH::createAppTerm3(SortHelper::getResultSort(c.term()), c, arg1, arg2); -} - - - diff --git a/Inferences/CombinatorNormalisationISE.hpp b/Inferences/CombinatorNormalisationISE.hpp deleted file mode 100644 index c10b4b998e..0000000000 --- a/Inferences/CombinatorNormalisationISE.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file CombinatorNormalisationISE.hpp - * Defines class CombinatorNormalisationISE. - */ - - -#ifndef __CombinatorNormalisationISE__ -#define __CombinatorNormalisationISE__ - -#include "Kernel/Signature.hpp" -#include "Forwards.hpp" -#include "InferenceEngine.hpp" - -//simplification engine for normalising combinators. -//uses the following equations: - -// S(KX)(KY) -> K(XY) -// S(KX)I -> X -// S(KX)Y -> BXY -// SKX -> I -// S(BKX) -> KX -// S(BKX)Y -> X -// BX(KY) -> KXY -// BXI -> X -// BI -> I -// C(KX)Y -> K(XY) - -namespace Inferences { - -class CombinatorNormalisationISE -: public ImmediateSimplificationEngine -{ -public: - CLASS_NAME(CombinatorNormalisationISE); - USE_ALLOCATOR(CombinatorNormalisationISE); - - CombinatorNormalisationISE(){} - Clause* simplify(Clause* cl); -private: - TermList normalise(TermList t); - bool replaceWithSmallerCombinator(TermList& t); - TermList createKTerm(TermList s1, TermList s2, TermList arg1); - TermList createSCorBTerm(TermList arg1, TermList arg1sort, TermList arg2, TermList arg2sort, Signature::Combinator comb); -}; - -}; - -#endif /* __CombinatorNormalisationISE__ */ diff --git a/Inferences/Condensation.cpp b/Inferences/Condensation.cpp index 0bdc78b500..9cdf989d00 100644 --- a/Inferences/Condensation.cpp +++ b/Inferences/Condensation.cpp @@ -74,19 +74,19 @@ Clause* Condensation::simplify(Clause* cl) newLits.ensure(newLen); - RobSubstitution subst0; + RobSubstitutionTL subst0; // For each unifying subst of l1 and l2 // apply the subst to l1 and search for instances of this in the clause // (note that this is symmetric to applying subst to l2) - SubstIterator sit=subst0.unifiers(l1,0,l2,0,false); + SubstIterator sit=subst0.unifiers(l1,l2,false); while(sit.hasNext()) { - RobSubstitution* subst=sit.next(); + RobSubstitutionTL* subst=sit.next(); alts.init(newLen,0); bool success=false; unsigned next=0; { - Literal* lit=subst->apply(l1,0); + Literal* lit=subst->apply(l1, DEFAULT_BANK); newLits[next] = lit; // Use lit as a query to find instances of it in cmi (i.e. the clause) LiteralMiniIndex::InstanceIterator iit(cmi, lit, false); @@ -105,7 +105,7 @@ Clause* Condensation::simplify(Clause* cl) // apply the subst and search for instances of the result as before for(unsigned i=0;iapply((*cl)[i],0); + Literal* lit=subst->apply((*cl)[i],DEFAULT_BANK); newLits[next] = lit; LiteralMiniIndex::InstanceIterator iit(cmi, lit, false); if(!iit.hasNext()) { diff --git a/Inferences/ElimLeibniz.cpp b/Inferences/ElimLeibniz.cpp index d4b4254c50..5fd03dcc3a 100644 --- a/Inferences/ElimLeibniz.cpp +++ b/Inferences/ElimLeibniz.cpp @@ -12,6 +12,8 @@ * Implements class PrimitiveInstantiation. */ +#if VHOL + #include "Debug/RuntimeStatistics.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -84,18 +86,18 @@ ElimLeibniz::LeibEqRec ElimLeibniz::getLiteralInfo(Literal* lit){ } Clause* ElimLeibniz::createConclusion(Clause* premise, Literal* newLit, - Literal* posLit, Literal* negLit, RobSubstitution& subst){ + Literal* posLit, Literal* negLit, RobSubstitutionTL& subst){ CALL("ElimLeibniz::createConclusion"); unsigned newLen=premise->length() - 1; Clause* res = new(newLen) Clause(newLen, GeneratingInference1(InferenceRule::LEIBNIZ_ELIMINATION, premise)); - Literal* newLitAfter = subst.apply(newLit, 0); + Literal* newLitAfter = subst.apply(newLit, DEFAULT_BANK); unsigned next = 0; for(unsigned i=0;ilength();i++) { Literal* curr=(*premise)[i]; if(curr!=posLit && curr!=negLit){ - Literal* currAfter = subst.apply(curr, 0); + Literal* currAfter = subst.apply(curr, DEFAULT_BANK); (*res)[next++] = currAfter; } } @@ -108,13 +110,11 @@ ClauseIterator ElimLeibniz::generateClauses(Clause* premise) { CALL("ElimLeibniz::generateClauses"); - typedef SortHelper SH; - static TermStack args; TermList head; - Stack positiveLits; - Stack negativeLits; + LiteralStack positiveLits; + LiteralStack negativeLits; Literal* posLit; Literal* negLit; @@ -140,8 +140,8 @@ ClauseIterator ElimLeibniz::generateClauses(Clause* premise) goto afterLoop; } } - if(pol){ positiveLits.push(lit); } else - { negativeLits.push(lit); } + if(pol){ positiveLits.push(lit); } + else { negativeLits.push(lit); } } return ClauseIterator::getEmpty(); @@ -149,7 +149,7 @@ ClauseIterator ElimLeibniz::generateClauses(Clause* premise) afterLoop: ClauseStack clauses; - static RobSubstitution subst; + static RobSubstitutionTL subst; subst.reset(); LeibEqRec lerPosLit = getLiteralInfo(posLit); @@ -160,24 +160,20 @@ ClauseIterator ElimLeibniz::generateClauses(Clause* premise) TermList var = TermList(lerPosLit.var, false); - TermList vEquals = TermList(Term::create1(env.signature->getEqualityProxy(), argS)); - TermList t1 = AH::createAppTerm(SH::getResultSort(vEquals.term()), vEquals, lerNegLit.arg); - if(subst.unify(var, 0, t1, 0)){ + TermList vEquals = AH::equality(argS); + // creating the term = arg (which is eta-equivalent to ^x. arg = x) + TermList t1 = AH::app(vEquals, lerNegLit.arg); + if(subst.unify(var, t1)){ Clause* c = createConclusion(premise, newLit, posLit, negLit, subst); clauses.push(c); subst.reset(); } - TermList t2 = AH::createAppTerm(SH::getResultSort(vEquals.term()), vEquals, lerPosLit.arg); - - TermList typeArgs[] = {argS, AtomicSort::boolSort(), AtomicSort::boolSort()}; - unsigned b_comb = env.signature->getCombinator(Signature::B_COMB); - - TermList bComb = TermList(Term::create(b_comb, 3, typeArgs)); - TermList vNot = TermList(Term::createConstant(env.signature->getNotProxy())); - t2 = AH::createAppTerm3(SH::getResultSort(bComb.term()), bComb,vNot,t2); + TermList db = AH::getDeBruijnIndex(0, argS); + // creating the term ^x. arg != x + TermList t2 = AH::lambda(argS, AH::app(AH::neg(), AH::app(AH::app(vEquals, lerPosLit.arg),db))); - if(subst.unify(var, 0, t2, 0)){ + if(subst.unify(var, t2)){ Clause* c = createConclusion(premise, newLit, posLit, negLit, subst); clauses.push(c); } @@ -188,3 +184,5 @@ ClauseIterator ElimLeibniz::generateClauses(Clause* premise) } } + +#endif diff --git a/Inferences/ElimLeibniz.hpp b/Inferences/ElimLeibniz.hpp index e5cbb59ba1..cbe7057cc8 100644 --- a/Inferences/ElimLeibniz.hpp +++ b/Inferences/ElimLeibniz.hpp @@ -15,6 +15,8 @@ #ifndef __ElimLeibniz__ #define __ElimLeibniz__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -43,7 +45,7 @@ class ElimLeibniz : public GeneratingInferenceEngine bool isPair(Literal* l1, Literal* l2); - Clause* createConclusion(Clause* premise, Literal* newLit, Literal* posLit, Literal* negLit, RobSubstitution& subst); + Clause* createConclusion(Clause* premise, Literal* newLit, Literal* posLit, Literal* negLit, RobSubstitutionTL& subst); LeibEqRec getLiteralInfo(Literal* lit); @@ -52,3 +54,5 @@ class ElimLeibniz : public GeneratingInferenceEngine } #endif + +#endif diff --git a/Inferences/EqualityFactoring.cpp b/Inferences/EqualityFactoring.cpp index 3991499f04..fd0e001568 100644 --- a/Inferences/EqualityFactoring.cpp +++ b/Inferences/EqualityFactoring.cpp @@ -35,6 +35,8 @@ #include "EqualityFactoring.hpp" +#include "Indexing/SubstitutionTree.hpp" + #if VDEBUG #include using namespace std; @@ -81,11 +83,22 @@ struct EqualityFactoring::FactorablePairsFn Clause* _cl; }; +void EqualityFactoring::attach(SaturationAlgorithm* salg) +{ + CALL("EqualityFactoring::attach"); + + GeneratingInferenceEngine::attach(salg); +} + +template struct EqualityFactoring::ResultFn { + ResultFn(Clause* cl, bool afterCheck, Ordering& ordering) - : _cl(cl), _cLen(cl->length()), _afterCheck(afterCheck), _ordering(ordering) {} - Clause* operator() (pair,pair > arg) + : _cl(cl), _cLen(cl->length()), _afterCheck(afterCheck), _ordering(ordering), + _algo() {} + + ClauseIterator operator() (pair,pair > arg) { CALL("EqualityFactoring::ResultFn::operator()"); @@ -94,109 +107,95 @@ struct EqualityFactoring::ResultFn ASS(sLit->isEquality()); ASS(fLit->isEquality()); - FuncSubtermMap funcSubtermMap; TermList srt = SortHelper::getEqualityArgumentSort(sLit); - static RobSubstitution subst; - static UnificationConstraintStack constraints; - subst.reset(); - constraints.reset(); + Recycled subst; + subst->reset(); - if (!subst.unify(srt, 0, SortHelper::getEqualityArgumentSort(fLit), 0)) { - return 0; + if (!subst->unify(srt, SortHelper::getEqualityArgumentSort(fLit))) { + return ClauseIterator::getEmpty(); } - TermList srtS=subst.apply(srt,0); + Recycled results; + + TermList srtS = subst->apply(srt,DEFAULT_BANK); TermList sLHS=arg.first.second; TermList sRHS=EqHelper::getOtherEqualitySide(sLit, sLHS); TermList fLHS=arg.second.second; TermList fRHS=EqHelper::getOtherEqualitySide(fLit, fLHS); ASS_NEQ(sLit, fLit); + + auto unifiers = _algo.unifiers(sLHS,fLHS, &*subst); - static Options::FunctionExtensionality ext = env.options->functionExtensionality(); - bool use_ho_handler = (ext == Options::FunctionExtensionality::ABSTRACTION) && env.property->higherOrder(); + while(unifiers.hasNext()){ + RobSubstitutionTL* subst = unifiers.next(); - if(use_ho_handler){ - TermList sLHSreplaced = sLHS; - TermList fLHSreplaced = fLHS; - if(!sLHS.isVar() && !fLHS.isVar() && - !srtS.isVar() && !srtS.isArrowSort()){ - sLHSreplaced = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(sLHS.term(), &funcSubtermMap); - fLHSreplaced = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(fLHS.term(), &funcSubtermMap); - } - subst.setMap(&funcSubtermMap); - HOMismatchHandler hndlr(constraints); - if(!subst.unify(sLHSreplaced,0,fLHSreplaced,0, &hndlr)) { - return 0; + TermList sLHSS = subst->apply(sLHS,DEFAULT_BANK); + TermList sRHSS = subst->apply(sRHS,DEFAULT_BANK); + + if(Ordering::isGorGEorE(_ordering.compare(sRHSS,sLHSS))) { + // try next unifier (of course there isn't one in the syntactic first-order case) + continue; } - } else { - if(!subst.unify(sLHS,0,fLHS,0)) { - return 0; + TermList fRHSS = subst->apply(fRHS,DEFAULT_BANK); + if(Ordering::isGorGEorE(_ordering.compare(fRHSS,sLHSS))) { + continue; } - } + auto constraints = subst->constraints(); + unsigned newLen=_cLen + constraints->length(); - TermList sLHSS=subst.apply(sLHS,0); - TermList sRHSS=subst.apply(sRHS,0); - if(Ordering::isGorGEorE(_ordering.compare(sRHSS,sLHSS))) { - return 0; - } - TermList fRHSS=subst.apply(fRHS,0); - if(Ordering::isGorGEorE(_ordering.compare(fRHSS,sLHSS))) { - return 0; - } + Clause* res = new(newLen) Clause(newLen, GeneratingInference1(InferenceRule::EQUALITY_FACTORING, _cl)); - unsigned newLen=_cLen+constraints.length(); - Clause* res = new(newLen) Clause(newLen, GeneratingInference1(InferenceRule::EQUALITY_FACTORING, _cl)); + (*res)[0]=Literal::createEquality(false, sRHSS, fRHSS, srtS); - (*res)[0]=Literal::createEquality(false, sRHSS, fRHSS, srtS); - - Literal* sLitAfter = 0; - if (_afterCheck && _cl->numSelected() > 1) { - TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - sLitAfter = subst.apply(sLit, 0); - } + Literal* sLitAfter = 0; + if (_afterCheck && _cl->numSelected() > 1) { + TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); + sLitAfter = subst->apply(sLit, DEFAULT_BANK); + } - unsigned next = 1; - for(unsigned i=0;i<_cLen;i++) { - Literal* curr=(*_cl)[i]; - if(curr!=sLit) { - Literal* currAfter = subst.apply(curr, 0); - - if (sLitAfter) { - TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - if (i < _cl->numSelected() && _ordering.compare(currAfter,sLitAfter) == Ordering::GREATER) { - env.statistics->inferencesBlockedForOrderingAftercheck++; - res->destroy(); - return 0; + unsigned next = 1; + bool afterCheckFailed = false; + for(unsigned i=0;i<_cLen;i++) { + Literal* curr=(*_cl)[i]; + if(curr!=sLit) { + Literal* currAfter = subst->apply(curr, DEFAULT_BANK); + + if (sLitAfter) { + TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); + if (i < _cl->numSelected() && _ordering.compare(currAfter,sLitAfter) == Ordering::GREATER) { + env.statistics->inferencesBlockedForOrderingAftercheck++; + res->destroy(); + afterCheckFailed = true; + break; + } } - } - (*res)[next++] = currAfter; + (*res)[next++] = currAfter; + } } - } - for(unsigned i=0;iequalityFactoring++; + for(Literal* c : *constraints){ + (*res)[next++] = c; + } + ASS_EQ(next,newLen); - return res; + env.statistics->equalityFactoring++; + results->push(res); + } + return pvi(getUniquePersistentIterator(ClauseStack::Iterator(*results))); } private: Clause* _cl; unsigned _cLen; bool _afterCheck; Ordering& _ordering; + UnifAlgo _algo; }; ClauseIterator EqualityFactoring::generateClauses(Clause* premise) @@ -216,12 +215,16 @@ ClauseIterator EqualityFactoring::generateClauses(Clause* premise) auto it4 = getMapAndFlattenIterator(it3,FactorablePairsFn(premise)); - auto it5 = getMappingIterator(it4,ResultFn(premise, - getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(), _salg->getOrdering())); + bool afterCheck = getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(); + Ordering& ord = _salg->getOrdering(); - auto it6 = getFilteredIterator(it5,NonzeroFn()); +#if VHOL + if(env.property->higherOrder()){ + return pvi(getMapAndFlattenIterator(it4, ResultFn(premise, afterCheck, ord))); + } +#endif - return pvi( it6 ); + return pvi(getMapAndFlattenIterator(it4, ResultFn(premise, afterCheck, ord))); } } diff --git a/Inferences/EqualityFactoring.hpp b/Inferences/EqualityFactoring.hpp index 24f49d48a1..cc8ea9a1df 100644 --- a/Inferences/EqualityFactoring.hpp +++ b/Inferences/EqualityFactoring.hpp @@ -30,17 +30,24 @@ using namespace Saturation; class EqualityFactoring : public GeneratingInferenceEngine { + using RobAlgo = UnificationAlgorithms::RobUnification; + using HOLAlgo = UnificationAlgorithms::HOLUnification; + public: CLASS_NAME(EqualityFactoring); USE_ALLOCATOR(EqualityFactoring); + EqualityFactoring(){} + + void attach(SaturationAlgorithm* salg); ClauseIterator generateClauses(Clause* premise); private: struct IsPositiveEqualityFn; struct IsDifferentPositiveEqualityFn; struct FactorablePairsFn; - struct ResultFn; + template + struct ResultFn; }; diff --git a/Inferences/EqualityResolution.cpp b/Inferences/EqualityResolution.cpp index e0123fae7c..bfafb5991e 100644 --- a/Inferences/EqualityResolution.cpp +++ b/Inferences/EqualityResolution.cpp @@ -32,12 +32,13 @@ #include "Kernel/LiteralSelector.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/ApplicativeHelper.hpp" +#include "Kernel/MismatchHandler.hpp" +#include "Kernel/HOLUnification.hpp" #include "Saturation/SaturationAlgorithm.hpp" #include "EqualityResolution.hpp" -#include "Shell/UnificationWithAbstractionConfig.hpp" #if VDEBUG #include @@ -55,145 +56,136 @@ using namespace Saturation; struct EqualityResolution::IsNegativeEqualityFn { bool operator()(Literal* l) - { return l->isEquality() && l->isNegative(); } + { + return l->isEquality() && l->isNegative() +#if VHOL + // no point trying to resolve two terms of functional sort + // instead, let negExt grow both sides and then resolve... + // for first part of condition see comments in NegExt and ImitateProject + && (l->isFlexRigid() || !SortHelper::getEqualityArgumentSort(l).isArrowSort()) +#endif + ; + } }; +void EqualityResolution::attach(SaturationAlgorithm* salg) +{ + CALL("EqualityResolution::attach"); + + GeneratingInferenceEngine::attach(salg); +} + +template struct EqualityResolution::ResultFn { - ResultFn(Clause* cl, bool afterCheck = false, Ordering* ord = nullptr) - : _afterCheck(afterCheck), _ord(ord), _cl(cl), _cLen(cl->length()) {} - Clause* operator() (Literal* lit) + + template + ResultFn(Clause* cl, bool afterCheck, Ordering* ord, AlgoArgs... args) + : _afterCheck(afterCheck), _ord(ord), _cl(cl), _cLen(cl->length()), + _algo(std::move(args)...) {} + + ClauseIterator operator() (Literal* lit) { CALL("EqualityResolution::ResultFn::operator()"); ASS(lit->isEquality()); ASS(lit->isNegative()); - FuncSubtermMap funcSubtermMap; + Recycled sub; + sub->reset(); + Recycled results; TermList arg0 = *lit->nthArgument(0); TermList arg1 = *lit->nthArgument(1); - static Options::UnificationWithAbstraction uwa = env.options->unificationWithAbstraction(); - static Options::FunctionExtensionality ext = env.options->functionExtensionality(); - bool use_uwa_handler = uwa != Options::UnificationWithAbstraction::OFF; - bool use_ho_handler = (ext == Options::FunctionExtensionality::ABSTRACTION) && - env.property->higherOrder(); - - if(use_ho_handler){ - TermList sort = SortHelper::getEqualityArgumentSort(lit); - if(!arg0.isVar() && !arg1.isVar() && - !sort.isVar() && !sort.isArrowSort()){ - arg0 = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(arg0.term(), &funcSubtermMap); - arg1 = ApplicativeHelper::replaceFunctionalAndBooleanSubterms(arg1.term(), &funcSubtermMap); - } - } - - //cout << "arg0 " + arg0.toString() << endl; - //cout << "arg1 " + arg1.toString() << endl; - - // We only care about non-trivial constraints where the top-sybmol of the two literals are the same - // and therefore a constraint can be created between arguments - if(use_uwa_handler && arg0.isTerm() && arg1.isTerm() && - arg0.term()->functor() == arg1.term()->functor()){ - use_uwa_handler = false; - } - - static RobSubstitution subst; - static UnificationConstraintStack constraints; - subst.reset(); - constraints.reset(); - subst.setMap(&funcSubtermMap); - - if(use_uwa_handler){ - UWAMismatchHandler hndlr(constraints); - if(!subst.unify(arg0,0,arg1,0,&hndlr)){ - return 0; - } - } - - if(use_ho_handler){ - HOMismatchHandler hndlr(constraints); - if(!subst.unify(arg0,0,arg1,0,&hndlr)){ - return 0; - } - } - - if(!use_uwa_handler && !use_ho_handler && !subst.unify(arg0,0,arg1,0)){ - return 0; + bool check = true; +#if VHOL + if(env.property->higherOrder()){ + ASS(!lit->isFlexFlex()); // should never select flex flex literals + unsigned depth = env.options->higherOrderUnifDepth(); + check = check && (depth == 0 || !lit->isFlexRigid()); } +#endif - //cout << "equalityResolution with " + _cl->toString() << endl; - //cout << "The literal is " + lit->toString() << endl; - //cout << "cLength " << cLength << endl; - - unsigned newLen=_cLen-1+ constraints.length(); + auto substs = _algo.unifiers(arg0, arg1, &*sub, /* no top level constraints */ check); - Clause* res = new(newLen) Clause(newLen, GeneratingInference1(InferenceRule::EQUALITY_RESOLUTION, _cl)); + while(substs.hasNext()){ + RobSubstitutionTL* sub = substs.next(); - Literal* litAfter = 0; + auto constraints = sub->constraints(); + unsigned newLen=_cLen - 1 + constraints->length(); - if (_afterCheck && _cl->numSelected() > 1) { - TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - litAfter = subst.apply(lit, 0); - } + Clause* res = new(newLen) Clause(newLen, GeneratingInference1(InferenceRule::EQUALITY_RESOLUTION, _cl)); - unsigned next = 0; - for(unsigned i=0;i<_cLen;i++) { - Literal* curr=(*_cl)[i]; - if(curr!=lit) { - Literal* currAfter = subst.apply(curr, 0); + Literal* litAfter = 0; - if (litAfter) { - TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); + if (_afterCheck && _cl->numSelected() > 1) { + TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); + litAfter = sub->apply(lit, DEFAULT_BANK); + } - if (i < _cl->numSelected() && _ord->compare(currAfter,litAfter) == Ordering::GREATER) { - env.statistics->inferencesBlockedForOrderingAftercheck++; - res->destroy(); - return 0; + unsigned next = 0; + bool afterCheckFailed = false; + for(unsigned i=0;i<_cLen;i++) { + Literal* curr=(*_cl)[i]; + if(curr!=lit) { + Literal* currAfter = sub->apply(curr, DEFAULT_BANK); + + if (litAfter) { + TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); + + if (i < _cl->numSelected() && _ord->compare(currAfter,litAfter) == Ordering::GREATER) { + env.statistics->inferencesBlockedForOrderingAftercheck++; + res->destroy(); + afterCheckFailed = true; + break; + } } - } - (*res)[next++] = currAfter; - } - } - for(unsigned i=0;iground() && - !UnificationWithAbstractionConfig::isInterpreted(qT) && - !UnificationWithAbstractionConfig::isInterpreted(rT) ) { - - // the unification was between two uninterpreted things that were not ground - res->destroy(); - return 0; + (*res)[next++] = currAfter; + } } - (*res)[next++] = constraint; - } - ASS_EQ(next,newLen); - - env.statistics->equalityResolution++; + // try next unifier (of course there isn't one in the syntactic first-order case) + if(afterCheckFailed) continue; - return res; + for (auto l : *constraints) { + (*res)[next++] = l; + } + ASS_EQ(next,newLen); + + env.statistics->equalityResolution++; + results->push(res); + // would like to do the below, but exiting higher-order iterator early causes + // some issue wrelating to celeting the underlying Substitution whilst it is still + // recording. TODO fix this and add code back in + //if(res->isEmpty()){ + // derived the empty clause, no need to continue with loop + //break; + //} + } + return pvi(getUniquePersistentIterator(ClauseStack::Iterator(*results))); } private: bool _afterCheck; Ordering* _ord; Clause* _cl; unsigned _cLen; + UnifAlgo _algo; }; ClauseIterator EqualityResolution::generateClauses(Clause* premise) { CALL("EqualityResolution::generateClauses"); + static auto uwa = env.options->unificationWithAbstraction(); + static bool fixedPointIteration = env.options->unificationWithAbstractionFixedPointIteration(); + static bool usingUwa = uwa !=Options::UnificationWithAbstraction::OFF; + +#if VHOL + static bool usingHOL = env.property->higherOrder(); +#endif + if(premise->isEmpty()) { return ClauseIterator::getEmpty(); } @@ -203,13 +195,23 @@ ClauseIterator EqualityResolution::generateClauses(Clause* premise) auto it2 = getFilteredIterator(it1,IsNegativeEqualityFn()); - auto it3 = getMappingIterator(it2,ResultFn(premise, - getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(), - &_salg->getOrdering())); + bool afterCheck = getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(); + Ordering* ord = &_salg->getOrdering(); - auto it4 = getFilteredIterator(it3,NonzeroFn()); + if(usingUwa){ + return pvi(getMapAndFlattenIterator(it2, + ResultFn(premise, afterCheck, ord, MismatchHandler(uwa), fixedPointIteration))); + } + +#if VHOL + if(usingHOL){ + return pvi(getMapAndFlattenIterator(it2, + ResultFn (premise, afterCheck, ord))); + } +#endif - return pvi( it4 ); + return pvi(getMapAndFlattenIterator(it2, + ResultFn (premise, afterCheck, ord))); } /** @@ -220,8 +222,12 @@ ClauseIterator EqualityResolution::generateClauses(Clause* premise) Clause* EqualityResolution::tryResolveEquality(Clause* cl, Literal* toResolve) { CALL("EqualityResolution::tryResolveEquality"); + + // AYB should template tryResolveEquality function really... + auto it = ResultFn(cl, /* no aftercheck */ false, /* no ordering */ nullptr)(toResolve); - return ResultFn(cl)(toResolve); + if(it.hasNext()) return it.next(); + else return 0; } } diff --git a/Inferences/EqualityResolution.hpp b/Inferences/EqualityResolution.hpp index 4a1a91bc64..0d11774e76 100644 --- a/Inferences/EqualityResolution.hpp +++ b/Inferences/EqualityResolution.hpp @@ -30,16 +30,23 @@ using namespace Saturation; class EqualityResolution : public GeneratingInferenceEngine { + using AbstractingAlgo = UnificationAlgorithms::AbstractingUnification; + using RobAlgo = UnificationAlgorithms::RobUnification; + using HOLAlgo = UnificationAlgorithms::HOLUnification; + public: CLASS_NAME(EqualityResolution); USE_ALLOCATOR(EqualityResolution); + void attach(SaturationAlgorithm* salg); + ClauseIterator generateClauses(Clause* premise); static Clause* tryResolveEquality(Clause* cl, Literal* toResolve); private: + + template struct ResultFn; struct IsNegativeEqualityFn; - }; diff --git a/Inferences/ExtensionalityResolution.cpp b/Inferences/ExtensionalityResolution.cpp index 7b29e607aa..7fc005de57 100644 --- a/Inferences/ExtensionalityResolution.cpp +++ b/Inferences/ExtensionalityResolution.cpp @@ -76,22 +76,22 @@ struct ExtensionalityResolution::ForwardPairingFn */ struct ExtensionalityResolution::ForwardUnificationsFn { - ForwardUnificationsFn() { _subst = RobSubstitutionSP(new RobSubstitution()); } - VirtualIterator, RobSubstitution*> > operator()(pair arg) + ForwardUnificationsFn() { _subst = RobSubstitutionTSSP(new RobSubstitutionTS()); } + VirtualIterator, RobSubstitutionTS*> > operator()(pair arg) { CALL("ExtensionalityResolution::ForwardUnificationsFn::operator()"); Literal* trmEq = arg.first; Literal* varEq = arg.second.literal; - SubstIterator unifs = _subst->unifiers(varEq,0,trmEq,1,true); + SubstIteratorTS unifs = _subst->unifiers(varEq,0,trmEq,1,true); if (!unifs.hasNext()) { - return VirtualIterator, RobSubstitution*> >::getEmpty(); + return VirtualIterator, RobSubstitutionTS*> >::getEmpty(); } return pvi(pushPairIntoRightIterator(arg, unifs)); } private: - RobSubstitutionSP _subst; + RobSubstitutionTSSP _subst; }; /** @@ -100,11 +100,11 @@ struct ExtensionalityResolution::ForwardUnificationsFn struct ExtensionalityResolution::ForwardResultFn { ForwardResultFn(Clause* otherCl, ExtensionalityResolution& parent) : _otherCl(otherCl), _parent(parent) {} - Clause* operator()(pair, RobSubstitution*> arg) + Clause* operator()(pair, RobSubstitutionTS*> arg) { CALL("ExtensionalityResolution::ForwardResultFn::operator()"); - RobSubstitution* subst = arg.second; + RobSubstitutionTS* subst = arg.second; Literal* otherLit = arg.first.first; Clause* extCl = arg.first.second.clause; Literal* extLit = arg.first.second.literal; @@ -166,22 +166,22 @@ struct ExtensionalityResolution::BackwardPairingFn struct ExtensionalityResolution::BackwardUnificationsFn { BackwardUnificationsFn(Literal* extLit) - : _extLit (extLit) { _subst = RobSubstitutionSP(new RobSubstitution()); } - VirtualIterator, RobSubstitution*> > operator()(pair arg) + : _extLit (extLit) { _subst = RobSubstitutionTSSP(new RobSubstitutionTS()); } + VirtualIterator, RobSubstitutionTS*> > operator()(pair arg) { CALL("ExtensionalityResolution::BackwardUnificationsFn::operator()"); Literal* otherLit = arg.second; - SubstIterator unifs = _subst->unifiers(_extLit,0,otherLit,1,true); + SubstIteratorTS unifs = _subst->unifiers(_extLit,0,otherLit,1,true); if (!unifs.hasNext()) { - return VirtualIterator, RobSubstitution*> >::getEmpty(); + return VirtualIterator, RobSubstitutionTS*> >::getEmpty(); } return pvi(pushPairIntoRightIterator(arg, unifs)); } private: Literal* _extLit; - RobSubstitutionSP _subst; + RobSubstitutionTSSP _subst; }; /** @@ -190,11 +190,11 @@ struct ExtensionalityResolution::BackwardUnificationsFn struct ExtensionalityResolution::BackwardResultFn { BackwardResultFn(Clause* extCl, Literal* extLit, ExtensionalityResolution& parent) : _extCl(extCl), _extLit(extLit), _parent(parent) {} - Clause* operator()(pair, RobSubstitution*> arg) + Clause* operator()(pair, RobSubstitutionTS*> arg) { CALL("ExtensionalityResolution::BackwardResultFn::operator()"); - RobSubstitution* subst = arg.second; + RobSubstitutionTS* subst = arg.second; Clause* otherCl = arg.first.first; Literal* otherLit = arg.first.second; @@ -217,7 +217,7 @@ struct ExtensionalityResolution::BackwardResultFn Clause* ExtensionalityResolution::performExtensionalityResolution( Clause* extCl, Literal* extLit, Clause* otherCl, Literal* otherLit, - RobSubstitution* subst, + RobSubstitutionTS* subst, unsigned& counter, const Options& opts) { diff --git a/Inferences/ExtensionalityResolution.hpp b/Inferences/ExtensionalityResolution.hpp index 8daad523e3..b6e103d18b 100644 --- a/Inferences/ExtensionalityResolution.hpp +++ b/Inferences/ExtensionalityResolution.hpp @@ -50,7 +50,7 @@ class ExtensionalityResolution static Clause* performExtensionalityResolution( Clause* extCl, Literal* extLit, Clause* otherCl, Literal* otherLit, - RobSubstitution* subst, + RobSubstitutionTS* subst, unsigned& counter, const Options& opts); private: diff --git a/Inferences/FOOLParamodulation.cpp b/Inferences/FOOLParamodulation.cpp index 1e899ca48c..6c3fa9b7ca 100644 --- a/Inferences/FOOLParamodulation.cpp +++ b/Inferences/FOOLParamodulation.cpp @@ -20,7 +20,7 @@ #include "Lib/Environment.hpp" #include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" @@ -85,10 +85,11 @@ ClauseIterator FOOLParamodulation::generateClauses(Clause* premise) { } // we shouldn't replace variables, hence NonVariableIterator - NonVariableIterator nvi(literal); + NonVariableNonTypeIterator nvi(literal); while (nvi.hasNext()) { - TermList subterm = nvi.next(); - unsigned functor = subterm.term()->functor(); + Term* st = nvi.next(); + unsigned functor = st->functor(); + TermList subterm(st); // we shouldn't replace boolean constants if (env.signature->isFoolConstantSymbol(false,functor) || env.signature->isFoolConstantSymbol(true,functor)) { @@ -118,7 +119,7 @@ ClauseIterator FOOLParamodulation::generateClauses(Clause* premise) { // Copy the literals from the premise except for the one at `literalPosition`, // that has the occurrence of `booleanTerm` replaced with false for (unsigned i = 0; i < conclusion->length() - 1; i++) { - (*conclusion)[i] = i == literalPosition ? EqHelper::replace((*premise)[i], booleanTerm, troo) : (*premise)[i]; + (*conclusion)[i] = i == literalPosition ? SubtermReplacer(booleanTerm,troo).transform((*premise)[i]) : (*premise)[i]; } // Add s = false to the clause diff --git a/Inferences/Factoring.cpp b/Inferences/Factoring.cpp index 8b2b1bab40..dfb1017915 100644 --- a/Inferences/Factoring.cpp +++ b/Inferences/Factoring.cpp @@ -55,9 +55,9 @@ class Factoring::UnificationsOnPositiveFn UnificationsOnPositiveFn(Clause* cl, LiteralSelector& sel) : _cl(cl), _sel(sel) { - _subst=RobSubstitutionSP(new RobSubstitution()); + _subst=RobSubstitutionSP(new RobSubstitutionTL()); } - VirtualIterator > operator() (pair nums) + VirtualIterator > operator() (pair nums) { CALL("Factoring::UnificationsFn::operator()"); @@ -70,19 +70,19 @@ class Factoring::UnificationsOnPositiveFn if(l1->isEquality()) { //We don't perform factoring with equalities - return VirtualIterator >::getEmpty(); + return VirtualIterator >::getEmpty(); } if(_sel.isNegativeForSelection(l1)) { //We don't perform factoring on negative literals // (this check only becomes relevant, when there is more than one literal selected // and yet the selected ones are not all positive -- see the check in generateClauses) - return VirtualIterator >::getEmpty(); + return VirtualIterator >::getEmpty(); } - SubstIterator unifs=_subst->unifiers(l1,0,l2,0, false); + SubstIterator unifs=_subst->unifiers(l1,l2, false); if(!unifs.hasNext()) { - return VirtualIterator >::getEmpty(); + return VirtualIterator >::getEmpty(); } return pvi( pushPairIntoRightIterator(l2, unifs) ); @@ -104,7 +104,7 @@ class Factoring::ResultsFn public: ResultsFn(Clause* cl, bool afterCheck, Ordering& ord) : _cl(cl), _cLen(cl->length()), _afterCheck(afterCheck), _ord(ord) {} - Clause* operator() (pair arg) + Clause* operator() (pair arg) { CALL("Factoring::ResultsFn::operator()"); @@ -119,13 +119,13 @@ class Factoring::ResultsFn if (_afterCheck && _cl->numSelected() > 1) { TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - skippedAfter = arg.second->apply(skipped, 0); + skippedAfter = arg.second->apply(skipped, DEFAULT_BANK); } for(unsigned i=0;i<_cLen;i++) { Literal* curr=(*_cl)[i]; if(curr!=skipped) { - Literal* currAfter = arg.second->apply(curr, 0); + Literal* currAfter = arg.second->apply(curr, DEFAULT_BANK); if (skippedAfter) { TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); diff --git a/Inferences/FastCondensation.cpp b/Inferences/FastCondensation.cpp index a7029a76c6..bc57d98701 100644 --- a/Inferences/FastCondensation.cpp +++ b/Inferences/FastCondensation.cpp @@ -54,6 +54,12 @@ struct FastCondensation::CondensationBinder return term.isVar() && var==term.var(); } +#if VHOL + if(env.property->higherOrder() && term.containsLooseIndex()){ + return false; + } +#endif + TermList* binding; if(bindings.getValuePtr(var,binding,term)) { return true; diff --git a/Inferences/FlexFlexSimplify.cpp b/Inferences/FlexFlexSimplify.cpp new file mode 100644 index 0000000000..65eb207623 --- /dev/null +++ b/Inferences/FlexFlexSimplify.cpp @@ -0,0 +1,45 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file CombinatorDemodISE.cpp + * Implements class CombinatorDemodISE. + */ + +#if VHOL + +#include "Kernel/Term.hpp" +#include "Kernel/Clause.hpp" +#include "Kernel/Inference.hpp" +#include "Kernel/SortHelper.hpp" +#include "FlexFlexSimplify.hpp" + +using namespace Lib; +using namespace Kernel; +using namespace Inferences; + + +Clause* FlexFlexSimplify::simplify(Clause* c) +{ + CALL("FlexFlexSimplify::simplify"); + + if(c->isEmpty()) return c; + + for(unsigned i = 0; i < c->length(); i++){ + Literal* lit = (*c)[i]; + if(!lit->isFlexFlex()){ + return c; + } + } + // all flex flex, return the empty clause + return new(0) Clause(0, SimplifyingInference1(InferenceRule::FLEX_FLEX_SIMPLIFY, c)); +} + +#endif + diff --git a/Inferences/FlexFlexSimplify.hpp b/Inferences/FlexFlexSimplify.hpp new file mode 100644 index 0000000000..66031c0129 --- /dev/null +++ b/Inferences/FlexFlexSimplify.hpp @@ -0,0 +1,42 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file CombinatorDemodISE.hpp + * Defines class CombinatorDemodISE. + */ + + +#ifndef __FlexFlexSimplify__ +#define __FlexFlexSimplify__ + +#if VHOL + +#include "Forwards.hpp" +#include "InferenceEngine.hpp" +#include "Kernel/TermTransformer.hpp" + +namespace Inferences { + + +class FlexFlexSimplify +: public ImmediateSimplificationEngine +{ +public: + CLASS_NAME(FlexFlexSimplify); + USE_ALLOCATOR(FlexFlexSimplify); + + Clause* simplify(Clause* cl); +}; + +}; + +#endif + +#endif /* __BetaEtaSimplify__ */ diff --git a/Inferences/ForwardDemodulation.cpp b/Inferences/ForwardDemodulation.cpp index 29cb717d3a..4bd4eed979 100644 --- a/Inferences/ForwardDemodulation.cpp +++ b/Inferences/ForwardDemodulation.cpp @@ -30,6 +30,7 @@ #include "Kernel/SortHelper.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/ColorHelper.hpp" #include "Kernel/RobSubstitution.hpp" @@ -51,27 +52,37 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; -void ForwardDemodulation::attach(SaturationAlgorithm* salg) +template +void ForwardDemodulation::attach(SaturationAlgorithm* salg) { CALL("ForwardDemodulation::attach"); ForwardSimplificationEngine::attach(salg); _index=static_cast( - _salg->getIndexManager()->request(DEMODULATION_LHS_CODE_TREE) ); +#if VHOL + env.property->higherOrder() ? + _salg->getIndexManager()->request(DEMODULATION_LHS_SUBST_TREE) : +#endif + _salg->getIndexManager()->request(DEMODULATION_LHS_CODE_TREE) ); _preorderedOnly=getOptions().forwardDemodulation()==Options::Demodulation::PREORDERED; _encompassing = getOptions().demodulationEncompassment(); } -void ForwardDemodulation::detach() +template +void ForwardDemodulation::detach() { CALL("ForwardDemodulation::detach"); _index=0; - _salg->getIndexManager()->release(DEMODULATION_LHS_CODE_TREE); +#if VHOL + env.property->higherOrder() ? + _salg->getIndexManager()->release(DEMODULATION_LHS_SUBST_TREE) : +#endif + _salg->getIndexManager()->release(DEMODULATION_LHS_CODE_TREE); ForwardSimplificationEngine::detach(); } -template -bool ForwardDemodulationImpl::perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) +template +bool ForwardDemodulation::perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) { CALL("ForwardDemodulation::perform"); TIME_TRACE("forward demodulation"); @@ -88,9 +99,7 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* unsigned cLen=cl->length(); for(unsigned li=0;li::type it(lit); + SubtermIterator it(lit); while(it.hasNext()) { TermList trm = TermList(it.next()); if(!attempted.insert(trm)) { @@ -110,7 +119,13 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* toplevelCheck &= lit->isPositive() && (cLen == 1); } - TermQueryResultIterator git=_index->getGeneralizations(TypedTermList(trm.term()), true); + TermQueryResultIterator git= +#if VHOL + env.property->higherOrder() ? + _index->getHOLGeneralizations(TypedTermList(trm.term())) : +#endif + _index->getGeneralizations(TypedTermList(trm.term()), true); + while(git.hasNext()) { TermQueryResult qr=git.next(); ASS_EQ(qr.clause->length(),1); @@ -119,31 +134,42 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* continue; } - // to deal with polymorphic matching - // Ideally, we would like to extend the substitution - // returned by the index to carry out the sort match. - // However, ForwardDemodulation uses a CodeTree as its - // indexing mechanism, and it is not clear how to extend - // the substitution returned by a code tree. - static RobSubstitution subst; + static RobSubstitutionTS subst; bool resultTermIsVar = qr.term.isVar(); - if(resultTermIsVar){ - TermList querySort = SortHelper::getTermSort(trm, lit); - TermList eqSort = SortHelper::getEqualityArgumentSort(qr.literal); - subst.reset(); - if(!subst.match(eqSort, 0, querySort, 1)){ - continue; +#if VHOL + // in higher-order case, we use a substitution tree for + // index which does sort checking internally + if(!env.property->higherOrder()){ +#endif + // to deal with polymorphic matching + // Ideally, we would like to extend the substitution + // returned by the index to carry out the sort match. + // However, ForwardDemodulation uses a CodeTree as its + // indexing mechanism, and it is not clear how to extend + // the substitution returned by a code tree. + + if(resultTermIsVar){ + TermList querySort = SortHelper::getTermSort(trm, lit); + TermList eqSort = SortHelper::getEqualityArgumentSort(qr.literal); + subst.reset(); + if(!subst.match(eqSort, 0, querySort, 1)){ + continue; + } } +#if VHOL } +#endif TermList rhs=EqHelper::getOtherEqualitySide(qr.literal,qr.term); TermList rhsS; - if(!qr.substitution->isIdentityOnQueryWhenResultBound()) { + auto subs = qr.unifier; + if(!subs->isIdentityOnQueryWhenResultBound()) { //When we apply substitution to the rhs, we get a term, that is //a variant of the term we'd like to get, as new variables are //produced in the substitution application. - TermList lhsSBadVars=qr.substitution->applyToResult(qr.term); - TermList rhsSBadVars=qr.substitution->applyToResult(rhs); + ASS(false); // we don't expect to reach here + TermList lhsSBadVars = subs->applyToResult(qr.term); + TermList rhsSBadVars = subs->applyToResult(rhs); Renaming rNorm, qNorm, qDenorm; rNorm.normalizeVariables(lhsSBadVars); qNorm.normalizeVariables(trm); @@ -151,12 +177,18 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* ASS_EQ(trm,qDenorm.apply(rNorm.apply(lhsSBadVars))); rhsS=qDenorm.apply(rNorm.apply(rhsSBadVars)); } else { - rhsS=qr.substitution->applyToBoundResult(rhs); + rhsS = subs->applyToBoundResult(rhs); } - if(resultTermIsVar){ - rhsS = subst.apply(rhsS, 0); +#if VHOL + if(!env.property->higherOrder()){ +#endif + if(resultTermIsVar){ + rhsS = subst.apply(rhsS, 0); + } +#if VHOL } - +#endif + Ordering::Result argOrder = ordering.getEqualityArgumentOrder(qr.literal); bool preordered = argOrder==Ordering::LESS || argOrder==Ordering::GREATER; #if VDEBUG @@ -191,11 +223,11 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* if(tord!=Ordering::LESS && tord!=Ordering::LESS_EQ) { if (_encompassing) { // last chance, if the matcher is not a renaming - if (qr.substitution->isRenamingOn(qr.term,true /* we talk of result term */)) { + if (subs->isRenamingOn(qr.term,true /* we talk of result term */)) { continue; // under _encompassing, we know there are no other literals in cl } } else { - Literal* eqLitS=qr.substitution->applyToBoundResult(qr.literal); + Literal* eqLitS = subs->applyToBoundResult(qr.literal); bool isMax=true; for(unsigned li2=0;li2::perform(Clause* cl, Clause* } } - Literal* resLit = EqHelper::replace(lit,trm,rhsS); + Literal* resLit = SubtermReplacer(trm, rhsS).transform(lit); if(EqHelper::isEqTautology(resLit)) { env.statistics->forwardDemodulationsToEqTaut++; premises = pvi( getSingletonIterator(qr.clause)); @@ -251,9 +283,9 @@ bool ForwardDemodulationImpl::perform(Clause* cl, Clause* return false; } -// This is necessary for templates defined in cpp files. -// We are happy to do it for ForwardDemodulationImpl, since it (at the moment) has only two specializations: -template class ForwardDemodulationImpl; -template class ForwardDemodulationImpl; +#if VHOL +template class ForwardDemodulation; +#endif +template class ForwardDemodulation; } diff --git a/Inferences/ForwardDemodulation.hpp b/Inferences/ForwardDemodulation.hpp index c6f3834bce..e3e6ba7eb0 100644 --- a/Inferences/ForwardDemodulation.hpp +++ b/Inferences/ForwardDemodulation.hpp @@ -28,6 +28,7 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; +template class ForwardDemodulation : public ForwardSimplificationEngine { @@ -37,25 +38,13 @@ class ForwardDemodulation void attach(SaturationAlgorithm* salg) override; void detach() override; - bool perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) override = 0; + bool perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) override; protected: bool _preorderedOnly; bool _encompassing; DemodulationLHSIndex* _index; }; -template -class ForwardDemodulationImpl -: public ForwardDemodulation -{ -public: - CLASS_NAME(ForwardDemodulationImpl); - USE_ALLOCATOR(ForwardDemodulationImpl); - - bool perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) override; -private: -}; - }; diff --git a/Inferences/ForwardLiteralRewriting.cpp b/Inferences/ForwardLiteralRewriting.cpp index 5222775a10..311b9f46ce 100644 --- a/Inferences/ForwardLiteralRewriting.cpp +++ b/Inferences/ForwardLiteralRewriting.cpp @@ -56,7 +56,12 @@ bool ForwardLiteralRewriting::perform(Clause* cl, Clause*& replacement, ClauseIt for(unsigned i=0;igetGeneralizations(lit, lit->isNegative(), true); + SLQueryResultIterator git= +#if VHOL + env.property->higherOrder() ? + _index->getHOLGeneralizations(lit, lit->isNegative(), true) : +#endif + _index->getGeneralizations(lit, lit->isNegative(), true); while(git.hasNext()) { SLQueryResult qr=git.next(); Clause* counterpart=_index->getCounterpart(qr.clause); @@ -67,21 +72,22 @@ bool ForwardLiteralRewriting::perform(Clause* cl, Clause*& replacement, ClauseIt } if(cl==qr.clause || cl==counterpart) { - continue; + continue; } Literal* rhs0 = (qr.literal==(*qr.clause)[0]) ? (*qr.clause)[1] : (*qr.clause)[0]; Literal* rhs = lit->isNegative() ? rhs0 : Literal::complementaryLiteral(rhs0); + auto subs = qr.unifier; - ASS(qr.substitution->isIdentityOnQueryWhenResultBound()); + ASS(subs->isIdentityOnQueryWhenResultBound()); //Due to the way we build the _index, we know that rhs contains only //variables present in qr.literal ASS(qr.literal->containsAllVariablesOf(rhs)); - Literal* rhsS=qr.substitution->applyToBoundResult(rhs); + Literal* rhsS = subs->applyToBoundResult(rhs); if(ordering.compare(lit, rhsS)!=Ordering::GREATER) { - continue; + continue; } Clause* premise=lit->isNegative() ? qr.clause : counterpart; @@ -104,10 +110,10 @@ bool ForwardLiteralRewriting::perform(Clause* cl, Clause*& replacement, ClauseIt unsigned next=1; for(unsigned i=0;igetGeneralizations((*cl)[li], false, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _unitIndex->getHOLGeneralizations((*cl)[li], false, false) : +#endif + _unitIndex->getGeneralizations((*cl)[li], false, false); while (rit.hasNext()) { Clause *premise = rit.next().clause; if (ColorHelper::compatible(cl->color(), premise->color())) { @@ -250,7 +255,12 @@ bool ForwardSubsumptionAndResolution::perform(Clause *cl, Clause *&replacement, LiteralMiniIndex miniIndex(cl); for (unsigned li = 0; li < clen; li++) { - SLQueryResultIterator rit = _fwIndex->getGeneralizations((*cl)[li], false, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _fwIndex->getHOLGeneralizations((*cl)[li], false, false) : +#endif + _fwIndex->getGeneralizations((*cl)[li], false, false); while (rit.hasNext()) { SLQueryResult res = rit.next(); Clause *mcl = res.clause; @@ -287,7 +297,12 @@ bool ForwardSubsumptionAndResolution::perform(Clause *cl, Clause *&replacement, for (unsigned li = 0; li < clen; li++) { Literal *resLit = (*cl)[li]; - SLQueryResultIterator rit = _unitIndex->getGeneralizations(resLit, true, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _unitIndex->getHOLGeneralizations(resLit, true, false) : +#endif + _unitIndex->getGeneralizations(resLit, true, false); while (rit.hasNext()) { Clause *mcl = rit.next().clause; if (ColorHelper::compatible(cl->color(), mcl->color())) { @@ -323,7 +338,12 @@ bool ForwardSubsumptionAndResolution::perform(Clause *cl, Clause *&replacement, for (unsigned li = 0; li < clen; li++) { Literal *resLit = (*cl)[li]; //resolved literal - SLQueryResultIterator rit = _fwIndex->getGeneralizations(resLit, true, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _fwIndex->getHOLGeneralizations(resLit, true, false) : +#endif + _fwIndex->getGeneralizations(resLit, true, false); while (rit.hasNext()) { SLQueryResult res = rit.next(); Clause *mcl = res.clause; diff --git a/Inferences/ForwardSubsumptionDemodulation.cpp b/Inferences/ForwardSubsumptionDemodulation.cpp index 014f3a7624..ba142ed883 100644 --- a/Inferences/ForwardSubsumptionDemodulation.cpp +++ b/Inferences/ForwardSubsumptionDemodulation.cpp @@ -18,6 +18,7 @@ #include "Indexing/LiteralMiniIndex.hpp" #include "Kernel/ColorHelper.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/MLMatcherSD.hpp" #include "Kernel/Matcher.hpp" @@ -42,7 +43,8 @@ using namespace Inferences; using namespace Saturation; -void ForwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) +template +void ForwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) { CALL("ForwardSubsumptionDemodulation::attach"); ForwardSimplificationEngine::attach(salg); @@ -57,16 +59,16 @@ void ForwardSubsumptionDemodulation::attach(SaturationAlgorithm* salg) } } - -void ForwardSubsumptionDemodulation::detach() +template +void ForwardSubsumptionDemodulation::detach() { CALL("ForwardSubsumptionDemodulation::detach"); _index.release(); ForwardSimplificationEngine::detach(); } - -bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) +template +bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) { CALL("ForwardSubsumptionDemodulation::perform"); @@ -98,7 +100,12 @@ bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, C // Subsumption by unit clauses if (_doSubsumption) { for (unsigned sqli = 0; sqli < cl->length(); ++sqli) { - SLQueryResultIterator rit = _unitIndex->getGeneralizations((*cl)[sqli], false, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _unitIndex->getHOLGeneralizations((*cl)[sqli], false, false) : +#endif + _unitIndex->getGeneralizations((*cl)[sqli], false, false); while (rit.hasNext()) { Clause* premise = rit.next().clause; @@ -128,7 +135,12 @@ bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, C /** * Step 1: find candidate clauses for subsumption */ - SLQueryResultIterator rit = _index->getGeneralizations(subsQueryLit, false, false); + SLQueryResultIterator rit = +#if VHOL + env.property->higherOrder() ? + _index->getHOLGeneralizations(subsQueryLit, false, false) : +#endif + _index->getGeneralizations(subsQueryLit, false, false); while (rit.hasNext()) { SLQueryResult res = rit.next(); Clause* mcl = res.clause; // left premise of FSD @@ -404,10 +416,7 @@ bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, C continue; } - // TODO higher-order support not yet implemented; see forward demodulation - // (maybe it's enough to just use the different iterator) - ASS(!env.options->combinatorySup()); - NonVariableNonTypeIterator nvi(dlit); + SubtermIterator nvi(dlit); while (nvi.hasNext()) { TermList lhsS = TermList(nvi.next()); // named 'lhsS' because it will be matched against 'lhs' @@ -597,7 +606,7 @@ bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, C /** * Step 4: found application of FSD; now create the conclusion */ - Literal* newLit = EqHelper::replace(dlit, lhsS, rhsS); + Literal* newLit = SubtermReplacer(lhsS,rhsS).transform(dlit); ASS_EQ(ordering.compare(lhsS, rhsS), Ordering::GREATER); #if VDEBUG if (getOptions().literalComparisonMode() != Options::LiteralComparisonMode::REVERSE) { @@ -676,3 +685,11 @@ bool ForwardSubsumptionDemodulation::perform(Clause* cl, Clause*& replacement, C return false; } + +namespace Inferences +{ +#if VHOL + template class ForwardSubsumptionDemodulation; +#endif + template class ForwardSubsumptionDemodulation; +} \ No newline at end of file diff --git a/Inferences/ForwardSubsumptionDemodulation.hpp b/Inferences/ForwardSubsumptionDemodulation.hpp index 7ef26eaaf6..39f53f8c1a 100644 --- a/Inferences/ForwardSubsumptionDemodulation.hpp +++ b/Inferences/ForwardSubsumptionDemodulation.hpp @@ -44,6 +44,7 @@ using namespace Saturation; * * This class implements the forward direction. */ +template class ForwardSubsumptionDemodulation : public ForwardSimplificationEngine { diff --git a/Inferences/GaussianVariableElimination.cpp b/Inferences/GaussianVariableElimination.cpp index e752338357..d5d0ad6116 100644 --- a/Inferences/GaussianVariableElimination.cpp +++ b/Inferences/GaussianVariableElimination.cpp @@ -11,7 +11,7 @@ #include "Kernel/Rebalancing.hpp" #include "Kernel/Rebalancing/Inverters.hpp" #include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/InterpretedLiteralEvaluator.hpp" #include "Inferences/InterpretedEvaluation.hpp" #include "Kernel/PolynomialNormalizer.hpp" @@ -78,11 +78,11 @@ SimplifyingGeneratingInference1::Result GaussianVariableElimination::rewrite(Cla auto sz = cl.size() - 1; Clause& out = *new(sz) Clause(sz, inf); for (unsigned i = 0; i < skipLiteral; i++) { - out[i] = checkLeq(cl[i], EqHelper::replace(cl[i], find, replace)); + out[i] = checkLeq(cl[i], SubtermReplacer(find,replace).transform(cl[i])); } for (unsigned i = skipLiteral; i < sz; i++) { - out[i] = checkLeq(cl[i+1], EqHelper::replace(cl[i+1], find, replace)); + out[i] = checkLeq(cl[i+1], SubtermReplacer(find,replace).transform(cl[i+1])); } if(!premiseRedundant) { diff --git a/Inferences/HyperSuperposition.cpp b/Inferences/HyperSuperposition.cpp index 2953b8c3dc..d60d7f2743 100644 --- a/Inferences/HyperSuperposition.cpp +++ b/Inferences/HyperSuperposition.cpp @@ -24,7 +24,7 @@ #include "Kernel/Clause.hpp" #include "Kernel/ColorHelper.hpp" -#include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/RobSubstitution.hpp" #include "Kernel/SortHelper.hpp" @@ -90,7 +90,7 @@ bool HyperSuperposition::rewriterEntryComparator(RewriterEntry p1, RewriterEntry return w1isLiteral(),t2->isLiteral()); @@ -226,7 +226,7 @@ void HyperSuperposition::tryUnifyingSuperpositioins(Clause* cl, unsigned literal Color clauseClr = cl->color(); - static RobSubstitution subst; + static RobSubstitutionTS subst; subst.reset(); int bank2 = disjointVariables ? 1 : 0; @@ -271,12 +271,12 @@ void HyperSuperposition::tryUnifyingSuperpositioins(Clause* cl, unsigned literal TermList tgtBase = rwr.first.second; TermList src = subst.apply(srcBase, rwrBank); TermList tgt = subst.apply(tgtBase, rwrBank); - t1Rwr = EqHelper::replace(t1Rwr, src, tgt); + t1Rwr = SubtermReplacer(src,tgt).transform(t1Rwr); } - static RobSubstitution checkerSubst; + static RobSubstitutionTS checkerSubst; checkerSubst.reset(); - if(!checkerSubst.unifyArgs(t1Rwr, 0, t2, bank2)) { + if(!checkerSubst.unify(TermList(t1Rwr), 0, TermList(t2), bank2)) { return; } @@ -293,7 +293,7 @@ void HyperSuperposition::tryUnifyingSuperpositioins(Clause* cl, unsigned literal } else { Literal* lSubst = subst.apply(lit0, 0); - Literal* lRwr = EqHelper::replace(lSubst, TermList(t1Subst), TermList(t1Rwr)); + Literal* lRwr = SubtermReplacer(TermList(t1Subst),TermList(t1Rwr)).transform(lSubst); resLits.push(lRwr); } } @@ -361,10 +361,10 @@ void HyperSuperposition::resolveFixedLiteral(Clause* cl, unsigned litIndex, Clau CALL("HyperSuperposition::resolveFixedLiteral"); Literal* lit = (*cl)[litIndex]; - SLQueryResultIterator unifs = _index->getUnifications(lit, true, true); + SLQueryResultIterator unifs = _index->getUnifications(lit, /* complementary = */ true, /* retrieveSubstitutions */ true); while(unifs.hasNext()) { SLQueryResult qr = unifs.next(); - Clause* genCl = BinaryResolution::generateClause(cl, lit, qr, getOptions()); + Clause* genCl = BinaryResolution::generateClause(cl, lit, qr.clause, qr.literal, qr.unifier, getOptions()); acc.push(ClausePair(cl, genCl)); } } @@ -430,7 +430,7 @@ bool HyperSuperposition::tryGetUnifyingPremises(Term* t1, Term* t2, Color clr, b Color clauseClr = clr; - static RobSubstitution subst; + static RobSubstitutionTS subst; subst.reset(); int bank2 = disjointVariables ? 1 : 0; diff --git a/Inferences/HyperSuperposition.hpp b/Inferences/HyperSuperposition.hpp index 6e866d7a4b..01428ea4d4 100644 --- a/Inferences/HyperSuperposition.hpp +++ b/Inferences/HyperSuperposition.hpp @@ -55,14 +55,14 @@ class HyperSuperposition typedef pair ClausePair; typedef Stack ClausePairStack; - bool tryToUnifyTwoTermPairs(RobSubstitution& subst, TermList tp1t1, int bank11, + bool tryToUnifyTwoTermPairs(RobSubstitutionTS& subst, TermList tp1t1, int bank11, TermList tp1t2, int bank12, TermList tp2t1, int bank21, TermList tp2t2, int bank22); bool tryMakeTopUnifiableByRewriter(TermList t1, TermList t2, int t2Bank, int& nextAvailableBank, ClauseStack& premises, - RewriterStack& rewriters, RobSubstitution& subst, Color& infClr); + RewriterStack& rewriters, RobSubstitutionTS& subst, Color& infClr); bool tryGetRewriters(Term* t1, Term* t2, int t2Bank, int& nextAvailableBank, ClauseStack& premises, - RewriterStack& rewriters, RobSubstitution& subst, Color& infClr); + RewriterStack& rewriters, RobSubstitutionTS& subst, Color& infClr); void tryUnifyingSuperpositioins(Clause* cl, unsigned literalIndex, Term* t1, Term* t2, bool disjointVariables, ClauseStack& acc); diff --git a/Inferences/ImitateProject.cpp b/Inferences/ImitateProject.cpp new file mode 100644 index 0000000000..319217c20f --- /dev/null +++ b/Inferences/ImitateProject.cpp @@ -0,0 +1,199 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file EqualityResolution.cpp + * Implements class EqualityResolution. + */ + +#if VHOL + +#include + +#include "Lib/VirtualIterator.hpp" +#include "Lib/Metaiterators.hpp" +#include "Lib/PairUtils.hpp" +#include "Lib/Stack.hpp" + +#include "Lib/Environment.hpp" +#include "Shell/Statistics.hpp" +#include "Shell/Options.hpp" +#include "Indexing/SubstitutionTree.hpp" + +#include "Kernel/Clause.hpp" +#include "Kernel/Unit.hpp" +#include "Kernel/Inference.hpp" +#include "Kernel/RobSubstitution.hpp" +#include "Kernel/EqHelper.hpp" +#include "Kernel/Ordering.hpp" +#include "Kernel/SubstHelper.hpp" +#include "Kernel/SortHelper.hpp" +#include "Kernel/ApplicativeHelper.hpp" + +#include "Saturation/SaturationAlgorithm.hpp" + + +#include "ImitateProject.hpp" + +namespace Inferences +{ + +using namespace Lib; +using namespace Kernel; +using namespace Indexing; +using namespace Saturation; + +struct ImitateProject::CanImitateAndProject +{ + bool operator()(Literal* l) + { + ASS(l->isEquality()); + return l->isFlexRigid() && !l->polarity(); + // TODO decide whether to keep check below (see NegExt) + /*&& !SortHelper::getEqualityArgumentSort(l).isArrowSort()*/; + } +}; + + +struct ImitateProject::ResultFn +{ + Clause* createRes(InferenceRule rule) + { + CALL("ImitateProject::ResultFn::createRes"); + + Clause* res = new(_cLen) Clause(_cLen, GeneratingInference1(rule, _cl)); + + for(unsigned i=0;i<_cLen;i++) { + Literal* curr=(*_cl)[i]; + Literal* currAfter = SubstHelper::apply(curr, _subst); + (*res)[i] = currAfter; + } + return res; + } + + void addProofExtraString(Clause* c, Literal* lit, TermList headFlex, TermList pb, int pos = -1) + { + CALL("ImitateProject::ResultFn::addProofExtraString"); + + bool projecting = pos > -1; + + vstring litPosition = Lib::Int::toString(_cl->getLiteralPosition(lit)); + + vstring suffix = pos == 1 ? "st" : (pos == 2 ? "nd" : (pos == 3 ? "nd" : "th")); + vstring projArgString = projecting ? ", projecting the " + Int::toString(pos) + suffix + " argument" : ""; + + vstring extra = "at literal " + litPosition + projArgString + ", binding: [" + + headFlex.toString() + " -> " + pb.toString() + "]"; + + if (!env.proofExtra) { + env.proofExtra = new DHMap(); + } + env.proofExtra->insert(c,extra); + + } + + + ResultFn(Clause* cl) + : _cl(cl), _cLen(cl->length()), _maxVar(TermList(cl->maxVar(), false)) {} + ClauseIterator operator() (Literal* lit) + { + CALL("ImitateProject::ResultFn::operator()"); + + typedef ApplicativeHelper AH; + + ASS(lit->isEquality()); + ASS(lit->isFlexRigid()); + + static ClauseStack results; + results.reset(); + _subst.reset(); + + TermList arg0 = *lit->nthArgument(0); + TermList arg1 = *lit->nthArgument(1); + + TermList flexTerm, rigidTerm; + + if(arg0.head().isVar()){ + flexTerm = arg0; + rigidTerm = arg1; + } else { + flexTerm = arg1; + rigidTerm = arg0; + } + + TermStack bindings; + bool imitFound = AH::getProjAndImitBindings(flexTerm,rigidTerm,bindings,_maxVar); + + // some inefficiency below as we iterate the term twice. Once in + // getProjAndImitBindings and again in the head() call below. + // However, it keeps the code cleaner, and I doubt that the penalty is high + TermList headFlex = flexTerm.head(); + if(imitFound){ + TermList imitpb = bindings[0]; + + _subst.bind(headFlex.var(), imitpb); + Clause* res = createRes(InferenceRule::IMITATE); + + if(env.options->proofExtra()==Options::ProofExtra::FULL){ + addProofExtraString(res, lit, headFlex, imitpb); + } + + results.push(res); + } + + // projections + for(unsigned i = 1; i < bindings.size(); i++){ + // try and project each of the arguments of the flex head in turn + _subst.reset(); + TermList projpb = bindings[i]; + + _subst.bind(headFlex.var(), projpb); + Clause* res = createRes(InferenceRule::PROJECT); + + if(env.options->proofExtra()==Options::ProofExtra::FULL){ + addProofExtraString(res, lit, headFlex, projpb, (int)(bindings.size() - i)); + } + + results.push(res); + } + + + return pvi(getUniquePersistentIterator(ClauseStack::Iterator(results)));; + } +private: + Substitution _subst; + Clause* _cl; + unsigned _cLen; + TermList _maxVar; +}; + +ClauseIterator ImitateProject::generateClauses(Clause* premise) +{ + CALL("ImitateProject::generateClauses"); + + if(premise->isEmpty()) { + return ClauseIterator::getEmpty(); + } + ASS(premise->numSelected()>0); + + // selected literals + auto it1 = premise->getSelectedLiteralIterator(); + + // only selected literals which are flex rigid + auto it2 = getFilteredIterator(it1,CanImitateAndProject()); + + // carry out imitations and projections + auto it3 = getMapAndFlattenIterator(it2,ResultFn(premise)); + + return pvi( it3 ); +} + +} + +#endif diff --git a/Inferences/Narrow.hpp b/Inferences/ImitateProject.hpp similarity index 52% rename from Inferences/Narrow.hpp rename to Inferences/ImitateProject.hpp index ec0500ae6f..cc5e880dee 100644 --- a/Inferences/Narrow.hpp +++ b/Inferences/ImitateProject.hpp @@ -8,18 +8,20 @@ * and in the source directory */ /** - * @file Superposition.hpp - * Defines class Superposition. + * @file EqualityResolution.hpp + * Defines class EqualityResolution. */ -#ifndef __Narrow__ -#define __Narrow__ +#ifndef __ImitateProject__ +#define __ImitateProject__ + +#if VHOL #include "Forwards.hpp" -#include "Indexing/TermIndex.hpp" #include "InferenceEngine.hpp" +#include "Shell/Options.hpp" namespace Inferences { @@ -27,32 +29,23 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; -class Narrow +class ImitateProject : public GeneratingInferenceEngine { public: - CLASS_NAME(Narrow); - USE_ALLOCATOR(Narrow); + CLASS_NAME(ImitateProject); + USE_ALLOCATOR(ImitateProject); ClauseIterator generateClauses(Clause* premise); - - void attach(SaturationAlgorithm* salg); - void detach(); - private: - NarrowingIndex* _index; - - Clause* performNarrow( - Clause* nClause, Literal* nLiteral, TermList nTerm, - TermList combAxLhs, Literal* combAx, ResultSubstitutionSP subst); - - struct ApplicableNarrowsFn; - struct RewriteableSubtermsFn; struct ResultFn; + struct CanImitateAndProject; }; }; -#endif /* __Narrow__ */ +#endif + +#endif /* __ImitateProject__ */ diff --git a/Inferences/Induction.cpp b/Inferences/Induction.cpp index 732a89b6a1..296bdf3711 100644 --- a/Inferences/Induction.cpp +++ b/Inferences/Induction.cpp @@ -14,8 +14,10 @@ #include +#include "Forwards.hpp" #include "Indexing/IndexManager.hpp" +#include "Indexing/ResultSubstitution.hpp" #include "Lib/BitUtils.hpp" #include "Lib/DHMap.hpp" #include "Lib/IntUnionFind.hpp" @@ -463,7 +465,7 @@ void InductionClauseIterator::processLiteral(Clause* premise, Literal* lit) // add formula with default bound if (_opt.integerInductionDefaultBound()) { InductionFormulaIndex::Entry* e = nullptr; - static TermQueryResult defaultBound(TermList(theory->representConstant(IntegerConstantType(0))), nullptr, nullptr); + static TermQueryResult defaultBound(TermList(theory->representConstant(IntegerConstantType(0))), nullptr, nullptr, ResultSubstitutionSP()); // for now, represent default bounds with no bound in the index, this is unique // since the placeholder is still int if (notDoneInt(ctx, nullptr, nullptr, e)) { @@ -573,13 +575,13 @@ void InductionClauseIterator::processIntegerComparison(Clause* premise, Literal* .filter([&premise](const TermQueryResult& tqr) { return tqr.clause != premise; }) - .map([&indt](const TermQueryResult& tqr) { + .map([&indt](const auto& tqr) { return InductionContext(indt, tqr.literal, tqr.clause); }) .flatMap([this](const InductionContext& arg) { return vi(ContextSubsetReplacement::instance(arg, _opt)); }); - TermQueryResult b(bound, lit, premise); + TermQueryResult b(bound, lit, premise, ResultSubstitutionSP()); // loop over literals containing the current induction term while (it.hasNext()) { auto ctx = it.next(); diff --git a/Inferences/InductionHelper.cpp b/Inferences/InductionHelper.cpp index 08c86e5fd9..78b41e973c 100644 --- a/Inferences/InductionHelper.cpp +++ b/Inferences/InductionHelper.cpp @@ -37,7 +37,7 @@ struct SLQueryResultToTermQueryResultFn { SLQueryResultToTermQueryResultFn(TermList v) : variable(v) {} TermQueryResult operator() (const SLQueryResult slqr) { - return TermQueryResult(slqr.substitution->applyToQuery(variable), slqr.literal, slqr.clause); + return TermQueryResult(slqr.unifier->applyToQuery(variable), slqr.literal, slqr.clause, ResultSubstitutionSP()); } TermList variable; diff --git a/Inferences/InferenceEngine.cpp b/Inferences/InferenceEngine.cpp index 73fd408f13..953b1a46f4 100644 --- a/Inferences/InferenceEngine.cpp +++ b/Inferences/InferenceEngine.cpp @@ -41,7 +41,9 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; +#if VHOL typedef ApplicativeHelper AH; +#endif /** * Return options that control the inference engine. @@ -265,11 +267,13 @@ CompositeSGI::~CompositeSGI() { } } +#if VHOL + Clause* ChoiceDefinitionISE::simplify(Clause* c) { CALL("ChoiceDefinitionISE::simplify"); - if (c->length() != 2) { + if (c->length() != 2 || !c->noSplits()) { return c; } @@ -278,14 +282,16 @@ Clause* ChoiceDefinitionISE::simplify(Clause* c) TermList x, f; - if(!isPositive(lit1) && is_of_form_xy(lit1, x) && - isPositive(lit2) && is_of_form_xfx(lit2, x, f)){ + if( isNegative(lit1) && isOfFormXY(lit1, x) && + isPositive(lit2) && isOfFormXfX(lit2, x, f)){ unsigned fun = f.term()->functor(); env.signature->addChoiceOperator(fun); return 0; - } else if(!isPositive(lit2) && is_of_form_xy(lit2, x) && - isPositive(lit1) && is_of_form_xfx(lit1, x, f)) { + } else + if( isNegative(lit2) && isOfFormXY(lit2, x) && + isPositive(lit1) && isOfFormXfX(lit1, x, f)) { unsigned fun = f.term()->functor(); + env.signature->addChoiceOperator(fun); return 0; } @@ -299,6 +305,7 @@ bool ChoiceDefinitionISE::isPositive(Literal* lit) { TermList rhs = *lit->nthArgument(1); if(!AH::isBool(lhs) && !AH::isBool(rhs)){ return false; } if(AH::isBool(lhs) && AH::isBool(rhs)){ return false; } + if(AH::isBool(lhs)){ return lit->polarity() == AH::isTrue(lhs); } @@ -308,21 +315,42 @@ bool ChoiceDefinitionISE::isPositive(Literal* lit) { return false; }; -bool ChoiceDefinitionISE::is_of_form_xy(Literal* lit, TermList& x){ - CALL("ChoiceDefinitionISE::is_of_form_xy"); +bool ChoiceDefinitionISE::isNegative(Literal* lit) { + CALL("ChoiceDefinitionISE::isPositive"); + + TermList lhs = *lit->nthArgument(0); + TermList rhs = *lit->nthArgument(1); + if(!AH::isBool(lhs) && !AH::isBool(rhs)){ return false; } + if(AH::isBool(lhs) && AH::isBool(rhs)){ return false; } + + if(AH::isBool(lhs)){ + return lit->polarity() != AH::isTrue(lhs); + } + if(AH::isBool(rhs)){ + return lit->polarity() != AH::isTrue(rhs); + } + return false; +}; + +bool ChoiceDefinitionISE::isOfFormXY(Literal* lit, TermList& x){ + CALL("ChoiceDefinitionISE::isOfFormXY"); TermList term = AH::isBool(*lit->nthArgument(0)) ? *lit->nthArgument(1) : *lit->nthArgument(0); + if(term.isLambdaTerm()){ return false; } + TermStack args; ApplicativeHelper::getHeadAndArgs(term, x, args); return (x.isVar() && args.size() == 1 && args[0].isVar()); } -bool ChoiceDefinitionISE::is_of_form_xfx(Literal* lit, TermList x, TermList& f){ - CALL("ChoiceDefinitionISE::is_of_form_xfx"); +bool ChoiceDefinitionISE::isOfFormXfX(Literal* lit, TermList x, TermList& f){ + CALL("ChoiceDefinitionISE::isOfFormXfX"); TermList term = AH::isBool(*lit->nthArgument(0)) ? *lit->nthArgument(1) : *lit->nthArgument(0); + if(term.isLambdaTerm()){ return false; } + TermStack args; TermList head; ApplicativeHelper::getHeadAndArgs(term, head, args); @@ -334,6 +362,64 @@ bool ChoiceDefinitionISE::is_of_form_xfx(Literal* lit, TermList x, TermList& f){ return false; } +Clause* TautologyDeletionISE2::simplify(Clause* c) +{ + CALL("TautologyDeletionISE2::simplify"); + + typedef ApplicativeHelper AH; + + static LiteralStack negLits; + static LiteralStack posLits; + + negLits.reset(); + posLits.reset(); + + for(unsigned i = 0; i < c->length(); i++){ + Literal* lit = (*c)[i]; + TermList lhs = *lit->nthArgument(0); + TermList rhs = *lit->nthArgument(1); + if(!lit->polarity() && AH::isBool(lhs) && AH::isBool(rhs) && + (AH::isTrue(lhs) != AH::isTrue(rhs))){ + //false != true + return 0; + } else if(AH::isBool(lhs) && AH::isBool(rhs)){ + continue; + } + + if(AH::isBool(lhs)){ + AH::isTrue(lhs) == lit->polarity() ? posLits.push(lit) : negLits.push(lit); + } else if (AH::isBool(rhs)){ + AH::isTrue(rhs) == lit->polarity() ? posLits.push(lit) : negLits.push(lit); + } + } + + for(unsigned i =0; i < posLits.size(); i++){ + Literal* posLit = posLits[i]; + TermList posNonBooleanSide = *posLit->nthArgument(0); + if(AH::isBool(posNonBooleanSide)){ + posNonBooleanSide = *posLit->nthArgument(1); + } + ASS(!AH::isBool(posNonBooleanSide)); + for(unsigned j = 0; j < negLits.size(); j++){ + Literal* negLit = negLits[j]; + TermList negNonBooleanSide = *negLit->nthArgument(0); + if(AH::isBool(negNonBooleanSide)){ + negNonBooleanSide = *negLit->nthArgument(1); + } + ASS_REP(!AH::isBool(negNonBooleanSide), negLit->toString()); + if(posNonBooleanSide == negNonBooleanSide){ + //t = true \/ t = false + //t = true \/ t != true + return 0; + } + } + } + + return c; +} + +#endif //VHOL + Clause* DuplicateLiteralRemovalISE::simplify(Clause* c) { CALL("DuplicateLiteralRemovalISE::simplify"); @@ -428,70 +514,12 @@ Clause* DuplicateLiteralRemovalISE::simplify(Clause* c) return d; } -Clause* TautologyDeletionISE2::simplify(Clause* c) -{ - CALL("TautologyDeletionISE2::simplify"); - - typedef ApplicativeHelper AH; - - static LiteralStack negLits; - static LiteralStack posLits; - - negLits.reset(); - posLits.reset(); - - for(unsigned i = 0; i < c->length(); i++){ - Literal* lit = (*c)[i]; - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - if(!lit->polarity() && AH::isBool(lhs) && AH::isBool(rhs) && - (AH::isTrue(lhs) != AH::isTrue(rhs))){ - //false != true - return 0; - } else if(AH::isBool(lhs) && AH::isBool(rhs)){ - continue; - } - - if(AH::isBool(lhs)){ - AH::isTrue(lhs) == lit->polarity() ? posLits.push(lit) : negLits.push(lit); - } else if (AH::isBool(rhs)){ - AH::isTrue(rhs) == lit->polarity() ? posLits.push(lit) : negLits.push(lit); - } - } - - for(unsigned i =0; i < posLits.size(); i++){ - Literal* posLit = posLits[i]; - TermList posNonBooleanSide = *posLit->nthArgument(0); - if(AH::isBool(posNonBooleanSide)){ - posNonBooleanSide = *posLit->nthArgument(1); - } - ASS(!AH::isBool(posNonBooleanSide)); - for(unsigned j = 0; j < negLits.size(); j++){ - Literal* negLit = negLits[j]; - TermList negNonBooleanSide = *negLit->nthArgument(0); - if(AH::isBool(negNonBooleanSide)){ - negNonBooleanSide = *negLit->nthArgument(1); - } - ASS_REP(!AH::isBool(negNonBooleanSide), negLit->toString()); - if(posNonBooleanSide == negNonBooleanSide){ - //t = true \/ t = false - //t = true \/ t != true - return 0; - } - } - } - - return c; -} - Clause* TrivialInequalitiesRemovalISE::simplify(Clause* c) { CALL("TrivialInequalitiesRemovalISE::simplify"); static DArray lits(32); - typedef ApplicativeHelper AH; - int length = c->length(); int j = 0; lits.ensure(length); @@ -504,11 +532,13 @@ Clause* TrivialInequalitiesRemovalISE::simplify(Clause* c) } TermList* t1 = l->args(); TermList* t2 = t1->next(); +#if VHOL if((AH::isTrue(*t1) && AH::isFalse(*t2) && l->polarity()) || (AH::isTrue(*t2) && AH::isFalse(*t1) && l->polarity())){ found++; continue; } +#endif if(l->isPositive()){ lits[j++] = l; continue; diff --git a/Inferences/InferenceEngine.hpp b/Inferences/InferenceEngine.hpp index 216f6c2524..825f490d29 100644 --- a/Inferences/InferenceEngine.hpp +++ b/Inferences/InferenceEngine.hpp @@ -426,6 +426,7 @@ class CompositeSGI Stack _generators; }; +#if VHOL //removes clauses which define choice operators class ChoiceDefinitionISE : public ImmediateSimplificationEngine @@ -437,27 +438,30 @@ class ChoiceDefinitionISE Clause* simplify(Clause* cl); bool isPositive(Literal* lit); + bool isNegative(Literal* lit); - bool is_of_form_xy(Literal* lit, TermList& x); - bool is_of_form_xfx(Literal* lit, TermList x, TermList& f); + bool isOfFormXY(Literal* lit, TermList& x); + bool isOfFormXfX(Literal* lit, TermList x, TermList& f); }; -class DuplicateLiteralRemovalISE +class TautologyDeletionISE2 : public ImmediateSimplificationEngine { public: - CLASS_NAME(DuplicateLiteralRemovalISE); - USE_ALLOCATOR(DuplicateLiteralRemovalISE); + CLASS_NAME(TautologyDeletionISE2); + USE_ALLOCATOR(TautologyDeletionISE2); Clause* simplify(Clause* cl); }; -class TautologyDeletionISE2 +#endif + +class DuplicateLiteralRemovalISE : public ImmediateSimplificationEngine { public: - CLASS_NAME(TautologyDeletionISE2); - USE_ALLOCATOR(TautologyDeletionISE2); + CLASS_NAME(DuplicateLiteralRemovalISE); + USE_ALLOCATOR(DuplicateLiteralRemovalISE); Clause* simplify(Clause* cl); }; diff --git a/Inferences/Injectivity.cpp b/Inferences/Injectivity.cpp index 4906a9e052..0516e54475 100644 --- a/Inferences/Injectivity.cpp +++ b/Inferences/Injectivity.cpp @@ -13,18 +13,20 @@ * creates a Skolem to act as left-inverse funcion */ +#if VHOL + #include "Lib/Environment.hpp" #include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Term.hpp" -#include "Kernel/TermIterators.hpp" #include "Kernel/Signature.hpp" #include "Kernel/OperatorType.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/ApplicativeHelper.hpp" +#include "Shell/Statistics.hpp" + #include "Injectivity.hpp" namespace Inferences { @@ -54,28 +56,46 @@ ClauseIterator Injectivity::generateClauses(Clause* premise) { TermList lhsM = *(mainLit->nthArgument(0)); TermList rhsM = *(mainLit->nthArgument(1)); + if(lhsM.isLambdaTerm() || rhsM.isLambdaTerm()) + { return ClauseIterator::getEmpty(); } + TermList lhsS = *(sideLit->nthArgument(0)); TermList rhsS = *(sideLit->nthArgument(1)); static TermStack argsLhs;//No need to reset because getHeadAndArgs resets - static TermStack argsRhs; + static TermStack argsRhs; TermStack termArgs; - TermList argLhs, argRhs, headLhs, headRhs, differingArg; + + TermStack argSorts; // sorts of argsLhs and argsRhs (not instantiated!) + TermStack termArgSorts; + TermList headLhs, headRhs, differingArg, differingArgSort; ApplicativeHelper::getHeadAndArgs(lhsM, headLhs, argsLhs); ApplicativeHelper::getHeadAndArgs(rhsM, headRhs, argsRhs); - if(headLhs != headRhs || headLhs.isVar() || - ApplicativeHelper::isComb(headLhs)){ - return ClauseIterator::getEmpty(); - } + + if(headLhs != headRhs || headLhs.isVar()) + { return ClauseIterator::getEmpty(); } + // assertion below holds, since lhsM and rhsM have same types and neither is a lambda term ASS(argsLhs.size() == argsRhs.size()); + + // TODO inelegant stuff here + // THe reason we get the sorts from the type instead of using getHeadArgsAndSorts + // is become we want the original non-instantiated sorts... + TermList headLhsSort = env.signature->getFunction(headLhs.term()->functor())->fnType()->result(); + for(unsigned i = 0; i < argsLhs.size(); i++){ + argSorts.push(headLhsSort.domain()); + headLhsSort = headLhsSort.result(); + } + bool differingArgFound = false; - unsigned index = 0; termArgs.push(lhsM); + termArgSorts.push(headLhsSort); + int idx = argSorts.size() - 1; while(!argsLhs.isEmpty()){ - argLhs = argsLhs.pop(); - argRhs = argsRhs.pop(); + TermList argLhs = argsLhs.pop(); + TermList argRhs = argsRhs.pop(); + TermList sort = argSorts[idx]; if(!argLhs.isVar() || !argRhs.isVar()){ return ClauseIterator::getEmpty(); } @@ -85,22 +105,24 @@ ClauseIterator Injectivity::generateClauses(Clause* premise) { } if((argLhs == lhsS && argRhs == rhsS) || (argLhs == rhsS && argRhs == lhsS)){ - differingArg = argLhs; + differingArg = argLhs; + differingArgSort = sort; differingArgFound = true; } else { return ClauseIterator::getEmpty(); } } else { termArgs.push(argLhs); + termArgSorts.push(sort); } - if(!differingArgFound){ index++; } + idx--; } - //at this point, we know the clause is of the form f x1 y x2... = f x1 z x2 ... \/ x != y - //index holds the index of the different argument - TermList newLhs = createNewLhs(headLhs, termArgs, index); - TermList sort = SortHelper::getResultSort(newLhs.term()); - Literal* lit = Literal::createEquality(true, newLhs, differingArg, sort); + env.statistics->injectiveFunInverses++; + + //at this point, we know the clause is of the form f x1 y x2... != f x1 z x2 ... \/ x = y + TermList newLhs = createNewLhs(headLhs, termArgs, AtomicSort::arrowSort(termArgSorts, differingArgSort)); + Literal* lit = Literal::createEquality(true, newLhs, differingArg, differingArgSort); Clause* conclusion = new(1) Clause(1, GeneratingInference1(InferenceRule::INJECTIVITY, premise)); @@ -109,7 +131,7 @@ ClauseIterator Injectivity::generateClauses(Clause* premise) { return pvi(getSingletonIterator(conclusion)); } -TermList Injectivity::createNewLhs(TermList oldhead, TermStack& termArgs, unsigned index){ +TermList Injectivity::createNewLhs(TermList oldhead, TermStack& termArgs, TermList invFunSort){ CALL("Injectivity::createNewLhs"); TermList* typeArg = oldhead.term()->args(); @@ -121,34 +143,18 @@ TermList Injectivity::createNewLhs(TermList oldhead, TermStack& termArgs, unsign Signature::Symbol* func = env.signature->getFunction(oldhead.term()->functor()); vstring pref = "inv_" + func->name() + "_"; - unsigned iFunc = env.signature->addFreshFunction(func->arity(), pref.c_str() ); - - OperatorType* funcType = func->fnType(); - TermList type = funcType->result(); - - TermList oldResult = ApplicativeHelper::getResultApplieadToNArgs(type, termArgs.size()); - TermStack sorts; - TermList newResult; - - sorts.push(oldResult); - for(unsigned i = 1; i <= termArgs.size(); i++){ - if(i - 1 != index){ - sorts.push(ApplicativeHelper::getNthArg(type,i)); - } else { - newResult = ApplicativeHelper::getNthArg(type,i); - } - } - - TermList inverseType = AtomicSort::arrowSort(sorts, newResult); + unsigned iFunc = env.signature->addFreshFunction(oldhead.term()->arity(), pref.c_str() ); - OperatorType* invFuncType = OperatorType::getConstantsType(inverseType, funcType->numTypeArguments()); + OperatorType* invFuncType = OperatorType::getConstantsType(invFunSort, oldhead.term()->arity()); Signature::Symbol* invFunc = env.signature->getFunction(iFunc); + invFunc->setType(invFuncType); TermList invFuncHead = TermList(Term::create(iFunc, func->arity(), typeArgs.begin())); - TermList invFuncHeadType = SortHelper::getResultSort(invFuncHead.term()); - return ApplicativeHelper::createAppTerm(invFuncHeadType, invFuncHead, termArgs); + return ApplicativeHelper::app(invFuncHead, termArgs); } } + +#endif \ No newline at end of file diff --git a/Inferences/Injectivity.hpp b/Inferences/Injectivity.hpp index 03abcf2813..6ecabed92c 100644 --- a/Inferences/Injectivity.hpp +++ b/Inferences/Injectivity.hpp @@ -15,6 +15,8 @@ #ifndef __Injectivity__ #define __Injectivity__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -28,9 +30,11 @@ class Injectivity : public GeneratingInferenceEngine { ClauseIterator generateClauses(Clause* premise); private: - TermList createNewLhs(TermList oldhead, TermStack& termArgs, unsigned index); + TermList createNewLhs(TermList oldhead, TermStack& termArgs, TermList sort); }; } #endif + +#endif diff --git a/Inferences/InnerRewriting.cpp b/Inferences/InnerRewriting.cpp index 4a2817ae95..e37d4ae74b 100644 --- a/Inferences/InnerRewriting.cpp +++ b/Inferences/InnerRewriting.cpp @@ -15,6 +15,7 @@ #include "InnerRewriting.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -39,7 +40,7 @@ bool InnerRewriting::perform(Clause* cl, Clause*& replacement, ClauseIterator& p for (unsigned j = 0; j < len; j++) { if (i != j) { Literal* lit = (*cl)[j]; - Literal* nLit = EqHelper::replace(lit,lhs,rhs); + Literal* nLit = SubtermReplacer(lhs,rhs).transform(lit); if (nLit != lit) { if(EqHelper::isEqTautology(nLit)) { env.statistics->innerRewritesToEqTaut++; @@ -57,7 +58,7 @@ bool InnerRewriting::perform(Clause* cl, Clause*& replacement, ClauseIterator& p (*res)[k] = nLit; } else { Literal* oLit = (*cl)[k]; - Literal* rLit = EqHelper::replace(oLit,lhs,rhs); + Literal* rLit = SubtermReplacer(lhs,rhs).transform(oLit); if(EqHelper::isEqTautology(rLit)) { env.statistics->innerRewritesToEqTaut++; res->destroy(); diff --git a/Inferences/Instantiation.cpp b/Inferences/Instantiation.cpp index 501baa2d21..b77585d6ef 100644 --- a/Inferences/Instantiation.cpp +++ b/Inferences/Instantiation.cpp @@ -235,10 +235,10 @@ class Instantiation::AllSubstitutionsIterator{ CALL("Instantiation::AllSubstitutionsIterator"); DHMap sortedVars; SortHelper::collectVariableSorts(cl,sortedVars); - VirtualIterator> it = sortedVars.items(); + auto it = sortedVars.items(); while(it.hasNext()){ - std::pair item = it.next(); + auto item = it.next(); DArray* array = new DArray(); array->initFromIterator(ins->getCandidateTerms(cl,item.first,item.second)); candidates.insert(item.first,array); diff --git a/Inferences/Narrow.cpp b/Inferences/Narrow.cpp deleted file mode 100644 index 6d8e492944..0000000000 --- a/Inferences/Narrow.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file Narrow.cpp - * Implements class Narrow. - */ - -#include "Debug/RuntimeStatistics.hpp" - -#include "Lib/Environment.hpp" -#include "Lib/Int.hpp" -#include "Lib/Metaiterators.hpp" -#include "Lib/PairUtils.hpp" -#include "Lib/VirtualIterator.hpp" - -#include "Kernel/Clause.hpp" -#include "Kernel/ColorHelper.hpp" -#include "Kernel/EqHelper.hpp" -#include "Kernel/Inference.hpp" -#include "Kernel/Ordering.hpp" -#include "Kernel/SortHelper.hpp" -#include "Kernel/Term.hpp" -#include "Kernel/TermIterators.hpp" -#include "Kernel/Unit.hpp" -#include "Kernel/LiteralSelector.hpp" -#include "Kernel/RobSubstitution.hpp" -#include "Kernel/ApplicativeHelper.hpp" -#include "Kernel/Signature.hpp" - -#include "Indexing/Index.hpp" -#include "Indexing/IndexManager.hpp" -#include "Indexing/TermSharing.hpp" - -#include "Saturation/SaturationAlgorithm.hpp" - -#include "Shell/Options.hpp" -#include "Shell/Statistics.hpp" - -#include "Narrow.hpp" - -#if VDEBUG -#include -using namespace std; -#endif - -using namespace Inferences; -using namespace Lib; -using namespace Kernel; -using namespace Indexing; -using namespace Saturation; - -void Narrow::attach(SaturationAlgorithm* salg) -{ - CALL("Narrow::attach"); - - GeneratingInferenceEngine::attach(salg); - _index=static_cast ( - _salg->getIndexManager()->request(NARROWING_INDEX) ); -} - -void Narrow::detach() -{ - CALL("Narrow::detach"); - - _index=0; - _salg->getIndexManager()->release(NARROWING_INDEX); - GeneratingInferenceEngine::detach(); -} - -struct Narrow::ApplicableNarrowsFn -{ - ApplicableNarrowsFn(NarrowingIndex* index) : _index(index) {} - VirtualIterator, TermQueryResult> > operator()(pair arg) - { - CALL("Narrow::ApplicableRewritesFn()"); - ASS(arg.second.isTerm()); - - TypedTermList tt(arg.second.term()); - return pvi( pushPairIntoRightIterator(arg, _index->getUnifications(tt, true)) ); - } -private: - NarrowingIndex* _index; -}; - -struct Narrow::RewriteableSubtermsFn -{ - RewriteableSubtermsFn(Ordering& ord) : _ord(ord) {} - - VirtualIterator > operator()(Literal* lit) - { - CALL("Narrow::RewriteableSubtermsFn()"); - - return pvi( pushPairIntoRightIterator(lit, - EqHelper::getNarrowableSubtermIterator(lit, _ord)) ); - } - -private: - Ordering& _ord; -}; - - -struct Narrow::ResultFn -{ - ResultFn(Clause* cl, Narrow& parent) : _cl(cl), _parent(parent) {} - Clause* operator()(pair, TermQueryResult> arg) - { - CALL("Narrow::ResultFn::operator()"); - - TermQueryResult& qr = arg.second; - return _parent.performNarrow(_cl, arg.first.first, arg.first.second, qr.term, - qr.literal, qr.substitution); - } -private: - Clause* _cl; - Narrow& _parent; -}; - -ClauseIterator Narrow::generateClauses(Clause* premise) -{ - CALL("Narrow::generateClauses"); - - //cout << "Narrow with " << premise->toString() << endl; - - auto it1 = premise->getSelectedLiteralIterator(); - - auto it2 = getMapAndFlattenIterator(it1,RewriteableSubtermsFn(_salg->getOrdering())); - auto it3 = getMapAndFlattenIterator(it2,ApplicableNarrowsFn(_index)); - - //Perform Narrow - auto it4 = getMappingIterator(it3,ResultFn(premise, *this)); - - auto it5 = getFilteredIterator(it4,NonzeroFn()); - - return pvi( it5 ); -} - - - -/** - * If Narrow should be performed, return result of the Narrow, - * otherwise return 0. - */ -Clause* Narrow::performNarrow( - Clause* nClause, Literal* nLiteral, TermList nTerm, - TermList combAxLhs, Literal* combAx, ResultSubstitutionSP subst) -{ - CALL("Narrow::performNarrow"); - // we want the rwClause and eqClause to be active - ASS(nClause->store()==Clause::ACTIVE); - ASS(nTerm.isTerm()); - //if(nClause->number() == 276){ - //cout << "performNarrow with " << nClause->toString() /*<< "\n and " << nLiteral->toString() << "\n and " << nTerm.toString()*/ << endl; - //cout << "the term being narrowed " << nTerm.toString() << endl; - //cout << "combAxLhs " << combAxLhs.toString() << endl; - //} - - static TermStack args; - TermList head; - ApplicativeHelper::getHeadAndArgs(nTerm, head, args); - ASS(head.isVar()); - - TermList headLHS = ApplicativeHelper::getHead(combAxLhs); - ASS(ApplicativeHelper::isComb(headLHS)); - Signature::Combinator comb = ApplicativeHelper::getComb(headLHS); - unsigned argNum = args.size(); - - //0 means unlimited - bool incr = false; - unsigned lim = env.options->maxXXNarrows(); - if(lim != 0){ - if(comb < Signature::I_COMB && argNum == 1){ - if(nClause->inference().xxNarrows() == lim){ - env.statistics->discardedNonRedundantClauses++; - return 0; - } else { - incr = true; - } - } - } - - unsigned cLen = nClause->length(); - TermList combAxRhs = EqHelper::getOtherEqualitySide(combAx, combAxLhs); - - Ordering& ordering = _salg->getOrdering(); - - TermList combAxRhsS = subst->apply(combAxRhs, 1); - Literal* nLiteralS = subst->apply(nLiteral, 0); //0 is query bank - TermList nTermS = subst->apply(nTerm, 0); - - //cout << "Check ordering on " << tgtTermS.toString() << " and " << rwTermS.toString() << endl; - - TermList arg0=*nLiteralS->nthArgument(0); - TermList arg1=*nLiteralS->nthArgument(1); - - if(!arg0.containsSubterm(nTermS)) { - if(Ordering::isGorGEorE(ordering.getEqualityArgumentOrder(nLiteralS))) { - return 0; - } - } else if(!arg1.containsSubterm(nTermS)) { - if(Ordering::isGorGEorE(Ordering::reverse(ordering.getEqualityArgumentOrder(nLiteralS)))) { - return 0; - } - } - - Literal* tgtLitS = EqHelper::replace(nLiteralS,nTermS,combAxRhsS); - - //TODO required? - if(EqHelper::isEqTautology(tgtLitS)) { - return 0; - } - - InferenceRule rule; - if(comb == Signature::S_COMB && argNum == 1){ - rule = InferenceRule::SXX_NARROW; - } else if(comb == Signature::S_COMB && argNum == 2){ - rule = InferenceRule::SX_NARROW; - } else if(comb == Signature::S_COMB && argNum == 3){ - rule = InferenceRule::S_NARROW; - } else if(comb == Signature::C_COMB && argNum == 1){ - rule = InferenceRule::CXX_NARROW; - } else if(comb == Signature::C_COMB && argNum == 2){ - rule = InferenceRule::CX_NARROW; - } else if(comb == Signature::C_COMB && argNum == 3){ - rule = InferenceRule::C_NARROW; - } else if(comb == Signature::B_COMB && argNum == 1){ - rule = InferenceRule::BXX_NARROW; - } else if(comb == Signature::B_COMB && argNum == 2){ - rule = InferenceRule::BX_NARROW; - } else if(comb == Signature::B_COMB && argNum == 3){ - rule = InferenceRule::B_NARROW; - } else if(comb == Signature::K_COMB && argNum == 1){ - rule = InferenceRule::KX_NARROW; - } else if(comb == Signature::K_COMB && argNum == 2){ - rule = InferenceRule::K_NARROW; - } else { - rule = InferenceRule::I_NARROW; - } - - Inference inf(GeneratingInference1(rule, nClause)); - if(incr){ inf.incXXNarrows(); } - - // If proof extra is on let's compute the positions we have performed - // Narrow on - /*if(env.options->proofExtra()==Options::ProofExtra::FULL){ - - inf->setExtra(extra); - }*/ //TODO update proof extra - - bool afterCheck = getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(); - - Clause* res = new(cLen) Clause(cLen, inf); - - (*res)[0] = tgtLitS; - int next = 1; - for(unsigned i=0;iapply(curr, 0); - - if(EqHelper::isEqTautology(currAfter)) { - goto construction_fail; - } - - if (afterCheck) { - TIME_TRACE(TimeTrace::LITERAL_ORDER_AFTERCHECK); - if (i < nClause->numSelected() && ordering.compare(currAfter,nLiteralS) == Ordering::GREATER) { - env.statistics->inferencesBlockedForOrderingAftercheck++; - goto construction_fail; - } - } - (*res)[next++] = currAfter; - } - } - - env.statistics->narrow++; - return res; - -construction_fail: - //cout << "failed" << endl; - res->destroy(); - return 0; -} diff --git a/Inferences/NegativeExt.cpp b/Inferences/NegativeExt.cpp index 9049b870ac..6fa724686f 100644 --- a/Inferences/NegativeExt.cpp +++ b/Inferences/NegativeExt.cpp @@ -12,6 +12,8 @@ * Implements class NegativeExt. */ +#if VHOL + #include #include "Lib/VirtualIterator.hpp" @@ -51,8 +53,8 @@ using namespace Saturation; struct NegativeExt::IsNegativeEqualityFn { - bool operator()(Literal* l) - { return l->isEquality() && !l->isPositive(); } + bool operator()(Literal* l) // TODO decide whether to keep final check (see ImitateProject) + { return l->isEquality() && !l->isPositive() && l->isRigidRigid(); } }; struct NegativeExt::ResultFn @@ -70,6 +72,7 @@ struct NegativeExt::ResultFn varSorts.reset(); TermList eqSort = SortHelper::getEqualityArgumentSort(lit); + // TODO why do we not perform negative extensionality when eqSort is a variable? if(eqSort.isVar() || !eqSort.isArrowSort()){ return 0; } @@ -125,8 +128,8 @@ struct NegativeExt::ResultFn } } - TermList alpha1 = *eqSort.term()->nthArgument(0); - TermList alpha2 = *eqSort.term()->nthArgument(1); + TermList alpha1 = eqSort.domain(); + TermList alpha2 = eqSort.result(); TermList resultSort = alpha1; SortHelper::normaliseArgSorts(typeVars, termVarSorts); @@ -137,10 +140,10 @@ struct NegativeExt::ResultFn TermList head = TermList(Term::create(fun, typeVars.size(), typeVars.begin())); //cout << "the head is " + head.toString() << endl; //cout << "It has sort " + skSymSort.toString() << endl; - TermList skolemTerm = ApplicativeHelper::createAppTerm(SortHelper::getResultSort(head.term()), head, termVars); + TermList skolemTerm = ApplicativeHelper::app(head, termVars); - TermList newLhs = ApplicativeHelper::createAppTerm(alpha1, alpha2, lhs, skolemTerm); - TermList newRhs = ApplicativeHelper::createAppTerm(alpha1, alpha2, rhs, skolemTerm); + TermList newLhs = ApplicativeHelper::app(alpha1, alpha2, lhs, skolemTerm); + TermList newRhs = ApplicativeHelper::app(alpha1, alpha2, rhs, skolemTerm); Literal* newLit = Literal::createEquality(false, newLhs, newRhs, alpha2); @@ -187,3 +190,5 @@ ClauseIterator NegativeExt::generateClauses(Clause* premise) } } + +#endif diff --git a/Inferences/NegativeExt.hpp b/Inferences/NegativeExt.hpp index 58b1f87666..1a357953dc 100644 --- a/Inferences/NegativeExt.hpp +++ b/Inferences/NegativeExt.hpp @@ -16,6 +16,8 @@ #ifndef __NegativeExt__ #define __NegativeExt__ +#if VHOL + #include "Forwards.hpp" #include "InferenceEngine.hpp" @@ -43,4 +45,6 @@ class NegativeExt }; +#endif + #endif /* __NegativeExt__ */ diff --git a/Inferences/PositiveExt.cpp b/Inferences/PositiveExt.cpp new file mode 100644 index 0000000000..0a527192ec --- /dev/null +++ b/Inferences/PositiveExt.cpp @@ -0,0 +1,141 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file NegativeExt.cpp + * Implements class NegativeExt. + */ + +#if VHOL + +#include + +#include "Lib/VirtualIterator.hpp" +#include "Lib/Metaiterators.hpp" +#include "Lib/PairUtils.hpp" + +#include "Lib/Environment.hpp" +#include "Shell/Statistics.hpp" + +#include "Kernel/Clause.hpp" +#include "Kernel/Unit.hpp" +#include "Kernel/Inference.hpp" +#include "Kernel/ApplicativeHelper.hpp" +#include "Kernel/TermIterators.hpp" +#include "Kernel/LiteralSelector.hpp" +#include "Saturation/SaturationAlgorithm.hpp" + +#include "PositiveExt.hpp" + +#if VDEBUG +#include +using namespace std; +#endif + +namespace Inferences +{ + +using namespace Lib; +using namespace Kernel; +using namespace Indexing; +using namespace Saturation; + +struct PositiveExt::IsPositiveEqualityFn +{ + bool operator()(Literal* l) + { return l->isEquality() && l->isPositive(); } +}; + +struct PositiveExt::ResultFn +{ + ResultFn(Clause* cl) : _cl(cl), _cLen(cl->length()) {} + + Clause* operator() (Literal* lit) // f X = g X + { + CALL("PositiveExt::ResultFn::operator()"); + + ASS(lit->isEquality()); + ASS(lit->isPositive()); + + TermList lhs = *lit->nthArgument(0); //f X + TermList rhs = *lit->nthArgument(1); //g X + + if(lhs.isApplication() && rhs.isApplication()){ + TermList left1 = lhs.lhs(); // f + TermList right1 = lhs.rhs(); // X + + TermList left2 = rhs.lhs(); // g + TermList right2 = rhs.rhs(); // X + + if(right1.isVar() && right2.isVar() && right1 == right2){ + unsigned var = right1.var(); // X + // X doesn't occur in f and g + if(!left1.isFreeVariable(var) && !left2.isFreeVariable(var)){ + bool occursInC = false; + for(unsigned i=0;i<_cLen;i++) { + Literal* curr=(*_cl)[i]; + if(curr!=lit && curr->isFreeVariable(var)) { + occursInC = true; + } + } + + if(!occursInC){ + TermList sort = ApplicativeHelper::lhsSort(lhs); + // f = g + Literal* newLit = Literal::createEquality(true, left1, left2, sort); + + Clause* res = new(_cLen) Clause(_cLen, GeneratingInference1(InferenceRule::POSITIVE_EXT, _cl)); + + for(unsigned i=0;i<_cLen;i++) { + Literal* curr=(*_cl)[i]; + if(curr!=lit) { + (*res)[i] = curr; + } else { + (*res)[i] = newLit; + } + } + + env.statistics->positiveExtensionality++; + + return res; // f = x \/ C' + } + } + } + } + + return 0; + } +private: + Clause* _cl; // f X = g X \/ C' + unsigned _cLen; +}; + +ClauseIterator PositiveExt::generateClauses(Clause* premise) +{ + CALL("PositiveExt::generateClauses"); + + if(premise->isEmpty()) { + return ClauseIterator::getEmpty(); + } + ASS(premise->numSelected()>0); + + auto it1 = premise->getSelectedLiteralIterator(); + + auto it2 = getFilteredIterator(it1,IsPositiveEqualityFn()); + + auto it3 = getMappingIterator(it2,ResultFn(premise)); + + auto it4 = getFilteredIterator(it3,NonzeroFn()); + + return pvi( it4 ); +} + +} + +#endif diff --git a/Inferences/PositiveExt.hpp b/Inferences/PositiveExt.hpp new file mode 100644 index 0000000000..73030e2473 --- /dev/null +++ b/Inferences/PositiveExt.hpp @@ -0,0 +1,50 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file EqualityResolution.hpp + * Defines class EqualityResolution. + */ + + +#ifndef __PositiveExt__ +#define __PositiveExt__ + +#if VHOL + +#include "Forwards.hpp" + +#include "InferenceEngine.hpp" +#include "Shell/Options.hpp" + +namespace Inferences { + +using namespace Kernel; +using namespace Indexing; +using namespace Saturation; + +class PositiveExt +: public GeneratingInferenceEngine +{ +public: + CLASS_NAME(PositiveExt); + USE_ALLOCATOR(PositiveExt); + + ClauseIterator generateClauses(Clause* premise); +private: + struct ResultFn; + struct IsPositiveEqualityFn; +}; + + +}; + +#endif + +#endif /* __NegativeExt__ */ diff --git a/Inferences/PrimitiveInstantiation.cpp b/Inferences/PrimitiveInstantiation.cpp index 685dad041b..62c11c9950 100644 --- a/Inferences/PrimitiveInstantiation.cpp +++ b/Inferences/PrimitiveInstantiation.cpp @@ -12,6 +12,8 @@ * Implements class PrimitiveInstantiation. */ +#if VHOL + #include "Debug/RuntimeStatistics.hpp" #include "Saturation/SaturationAlgorithm.hpp" @@ -21,6 +23,7 @@ #include "Kernel/Inference.hpp" #include "Kernel/Substitution.hpp" #include "Kernel/ApplicativeHelper.hpp" +#include "Kernel/SubstHelper.hpp" #include "Lib/Environment.hpp" #include "Lib/Metaiterators.hpp" @@ -42,96 +45,206 @@ using namespace Kernel; using namespace Indexing; using namespace Saturation; -void PrimitiveInstantiation::attach(SaturationAlgorithm* salg) -{ - CALL("PrimitiveInstantiation::attach"); - - GeneratingInferenceEngine::attach(salg); - _index=static_cast ( - _salg->getIndexManager()->request(PRIMITIVE_INSTANTIATION_INDEX) ); -} - -void PrimitiveInstantiation::detach() -{ - CALL("PrimitiveInstantiation::detach"); - - _index=0; - _salg->getIndexManager()->release(PRIMITIVE_INSTANTIATION_INDEX); - GeneratingInferenceEngine::detach(); -} - struct PrimitiveInstantiation::IsInstantiable { bool operator()(Literal* l) { - if(SortHelper::getEqualityArgumentSort(l) != AtomicSort::boolSort()){ - return false; - } - - TermList lhs = *(l->nthArgument(0)); - TermList rhs = *(l->nthArgument(1)); - - TermList head; - TermStack args; - ApplicativeHelper::getHeadAndArgs(lhs, head, args); - if(head.isVar()){ return true; } - ApplicativeHelper::getHeadAndArgs(rhs, head, args); - if(head.isVar()){ return true; } - - return false; + return l->isFlexRigid() && SortHelper::getEqualityArgumentSort(l).isBoolSort(); } }; struct PrimitiveInstantiation::ResultFn { - ResultFn(Clause* cl): _cl(cl){} - - Clause* operator() (TermQueryResult tqr){ - const int QUERY = 0; + typedef ApplicativeHelper AH; + typedef pair IndexPair; + typedef Stack IndexPairStack; - ResultSubstitutionSP subst = tqr.substitution; + ResultFn(Clause* cl): _cl(cl), _freshVar(cl->maxVar() + 1){ + TermList sortVar(_freshVar++, false); + // rather than constantly recreating this stack + // and pushing on the terms every time we run a prim inst inference + // another option is to use RobSubstitution and allow it to + // rename terms apart. That way, we don't need to worry about freshness + // of variables. The potential downside is that the whole RobSubstitution + // mechanism is complicated and may add its own overhead. Worth investigating + // though + _heads.push(AH::top()); + _heads.push(AH::bottom()); + auto piSet = env.options->piSet(); + switch(piSet){ + case Options::PISet::ALL_EXCEPT_NOT_EQ: + case Options::PISet::ALL: + _heads.push(AH::conj()); + _heads.push(AH::disj()); + _heads.push(AH::neg()); + _heads.push(AH::equality(sortVar)); + _heads.push(AH::pi(sortVar)); + _heads.push(AH::sigma(sortVar)); + break; + case Options::PISet::PRAGMATIC: + case Options::PISet::NOT: + _heads.push(AH::neg()); + break; + // Equality and Pi and Sigma introduce polymorphism + // into monomorphic problem... + case Options::PISet::NOT_EQ_NOT_EQ: + _heads.push(AH::neg()); + _heads.push(AH::equality(sortVar)); + break; + case Options::PISet::AND: + _heads.push(AH::conj()); + break; + case Options::PISet::OR: + _heads.push(AH::disj()); + break; + case Options::PISet::EQUALS: + _heads.push(AH::equality(sortVar)); + break; + case Options::PISet::PI_SIGMA: + _heads.push(AH::pi(sortVar)); + _heads.push(AH::sigma(sortVar)); + break; + } + } + + Clause* createRes() + { + CALL("PrimitiveInstantiation::ResultFn::createRes"); + unsigned cLen = _cl->length(); - Clause* res = new(cLen) Clause(cLen, GeneratingInference1(InferenceRule::PRIMITIVE_INSTANTIATION, _cl)); for(unsigned i=0;iapply(curr, QUERY); + Literal* currAfter = SubstHelper::apply(curr, _subst); (*res)[i] = currAfter; } + return res; + } - env.statistics->primitiveInstantiations++; - return res; + void getSameSortIndices(TermStack& sorts, IndexPairStack& indices){ + CALL("PrimitiveInstantiation::ResultFn::getSameSortIndices"); + + for(unsigned i = 0; i < sorts.size(); i++){ + for(unsigned j = i + 1; j < sorts.size(); j++){ + if(sorts[i] == sorts[j]){ + indices.push(make_pair(i, j)); + } + } + } } - -private: - Clause* _cl; -}; -struct PrimitiveInstantiation::ApplicableRewritesFn -{ + ClauseIterator operator() (Literal* lit){ + CALL("PrimitiveInstantiation::ResultFn::operator()"); + + auto set = env.options->piSet(); + static bool pragmatic = set == Options::PISet::PRAGMATIC; + static bool include_not_eq = set == Options::PISet::ALL || + set == Options::PISet::NOT_EQ_NOT_EQ; + + static ClauseStack results; + results.reset(); + + TermList arg0 = *lit->nthArgument(0); + TermList arg1 = *lit->nthArgument(1); + + // Flex term is of form X a1 ... an + TermList flexTerm = arg0.head().isVar() ? arg0 : arg1; + + // since term is rigid, cannot be a variable + TermList headFlex; + TermStack argsFlex; + TermStack sortsFlex; //sorts of arguments of flex head + + AH::getHeadArgsAndArgSorts(flexTerm, headFlex, argsFlex, sortsFlex); + ASS(argsFlex.size() == sortsFlex.size()); + + if(!argsFlex.size()){ + // TODO do we really want to do this? + return ClauseIterator::getEmpty(); + } + + // if any amongst a1 ... an is of sort $o, project that + // argument to the top + for(unsigned i =0; i < sortsFlex.size() && pragmatic; i++){ + if(sortsFlex[i].isBoolSort()){ + _subst.reset(); + TermList gb = AH::surroundWithLambdas(AH::getDeBruijnIndex(i, sortsFlex[i]), sortsFlex); + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + } + } + + if(pragmatic){ + IndexPairStack sameSortArgs; + getSameSortIndices(sortsFlex, sameSortArgs); + for(unsigned i = 0; i < sameSortArgs.size(); i++){ + _subst.reset(); + IndexPair p = sameSortArgs[i]; - ApplicableRewritesFn(PrimitiveInstantiationIndex* index) : _index(index){} - VirtualIterator operator()(Literal* l) - { - CALL("PrimitiveInstantiation::ApplicableRewritesFn()"); - - TermList lhs = *l->nthArgument(0); - TermList rhs = *l->nthArgument(1); - - TypedTermList lhst(lhs, SortHelper::getTermSort(lhs, l)); - TypedTermList rhst(rhs, SortHelper::getTermSort(rhs, l)); - - TermStack args; - TermList head; - - ApplicativeHelper::getHeadAndArgs(lhs, head, args); - - return pvi(_index->getUnifications((head.isVar() ? lhst : rhst))); + TermList dbi = AH::getDeBruijnIndex(p.first, sortsFlex[p.first]); + TermList dbj = AH::getDeBruijnIndex(p.second, sortsFlex[p.second]); + + // creating term dbi = dbj + TermList tm = AH::app2(AH::equality(sortsFlex[p.first]), dbi, dbj); + TermList gb = AH::surroundWithLambdas(tm, sortsFlex); + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + + //creating dbi != dbj + _subst.reset(); + gb = AH::surroundWithLambdas(AH::app(AH::neg(), tm), sortsFlex); + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + + if(sortsFlex[p.first].isBoolSort()){ + //creating dbi \/ dbj + _subst.reset(); + gb = AH::surroundWithLambdas(AH::app2(AH::disj(), dbi, dbj), sortsFlex); + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + + //creating dbi /\ dbj + _subst.reset(); + gb = AH::surroundWithLambdas(AH::app2(AH::conj(), dbi, dbj), sortsFlex); + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + } + } + } + + // bind head variable to all general bindings produced using heads in _heads + for(unsigned i =0; i < _heads.size(); i++){ + _subst.reset(); + TermList fVar(_freshVar,false); + + bool surround = (!_heads[i].isEquals() || !include_not_eq); + TermList gb = AH::createGeneralBinding(fVar,_heads[i],sortsFlex,surround); + TermList gb2 = surround ? gb : AH::surroundWithLambdas(gb, sortsFlex); + + _subst.bind(headFlex.var(), gb2); + results.push(createRes()); + + if(!surround){ + // add not equals + _subst.reset(); + gb = AH::surroundWithLambdas(AH::app(AH::neg(), gb), sortsFlex); + + _subst.bind(headFlex.var(), gb); + results.push(createRes()); + } + } + + env.statistics->primitiveInstantiations++; + return pvi(getUniquePersistentIterator(ClauseStack::Iterator(results))); } + private: - PrimitiveInstantiationIndex* _index; + TermStack _heads; + Clause* _cl; + unsigned _freshVar; + Substitution _subst; }; ClauseIterator PrimitiveInstantiation::generateClauses(Clause* premise) @@ -140,18 +253,14 @@ ClauseIterator PrimitiveInstantiation::generateClauses(Clause* premise) //is this correct? auto it1 = premise->getSelectedLiteralIterator(); - //filter out literals that are not suitable for narrowing + //filter out literals that are not suitable for PI auto it2 = getFilteredIterator(it1, IsInstantiable()); - - //pair of literals and possible rewrites that can be applied to literals - auto it3 = getMapAndFlattenIterator(it2, ApplicableRewritesFn(_index)); - - //apply rewrite rules to literals - auto it4 = getMappingIterator(it3, ResultFn(premise)); + //perform instantiations + auto it3 = getMapAndFlattenIterator(it2, ResultFn(premise)); - - return pvi( it4 ); - + return pvi( it3 ); } } + +#endif \ No newline at end of file diff --git a/Inferences/PrimitiveInstantiation.hpp b/Inferences/PrimitiveInstantiation.hpp index aec25d1cbd..888c8eb6e3 100644 --- a/Inferences/PrimitiveInstantiation.hpp +++ b/Inferences/PrimitiveInstantiation.hpp @@ -16,6 +16,8 @@ #ifndef __PrimitiveInstantiation__ #define __PrimitiveInstantiation__ +#if VHOL + #include "Forwards.hpp" #include "Indexing/TermIndex.hpp" @@ -34,21 +36,17 @@ class PrimitiveInstantiation CLASS_NAME(PrimitiveInstantiation); USE_ALLOCATOR(PrimitiveInstantiation); - void attach(SaturationAlgorithm* salg); - void detach(); - ClauseIterator generateClauses(Clause* premise); private: - PrimitiveInstantiationIndex* _index; - struct ApplicableRewritesFn; struct ResultFn; - struct IsInstantiable; - + struct IsInstantiable; }; }; +#endif + #endif /* __PrimitiveInstantiation__ */ diff --git a/Inferences/RenamingOnTheFly.cpp b/Inferences/RenamingOnTheFly.cpp deleted file mode 100644 index edca725d26..0000000000 --- a/Inferences/RenamingOnTheFly.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file ProxyElimination.cpp - * - */ - -#include "Lib/Environment.hpp" - -#include "Kernel/Clause.hpp" -#include "Kernel/EqHelper.hpp" -#include "Kernel/Inference.hpp" -#include "Kernel/Signature.hpp" -#include "Kernel/Term.hpp" -#include "Kernel/TermIterators.hpp" -#include "Kernel/Signature.hpp" -#include "Kernel/OperatorType.hpp" -#include "Kernel/SortHelper.hpp" -#include "Kernel/ApplicativeHelper.hpp" - -#include "Shell/Statistics.hpp" -#include "Shell/Skolem.hpp" - -#include "Saturation/SaturationAlgorithm.hpp" - -#include "RenamingOnTheFly.hpp" - -namespace Inferences { -using namespace Indexing; - -typedef ApplicativeHelper AH; - -void RenamingOnTheFly::attach(SaturationAlgorithm* salg) -{ - CALL("RenamingOnTheFly::attach"); - - SimplificationEngine::attach(salg); - _formulaIndex=static_cast ( - _salg->getIndexManager()->request(RENAMING_FORMULA_INDEX) ); -} - -void RenamingOnTheFly::detach() -{ - CALL("RenamingOnTheFly::detach"); - - _formulaIndex=0; - _salg->getIndexManager()->release(RENAMING_FORMULA_INDEX); - SimplificationEngine::detach(); -} - -ClauseIterator RenamingOnTheFly::produceClauses(Clause* c) -{ - CALL("RenamingOnTheFly::produceClauses"); - - //0 means dont rename - static int namingBound = env.options->naming(); - - TermList troo = TermList(Term::foolTrue()); - TermList boolSort = AtomicSort::boolSort(); - - unsigned clen = c->length(); - UnitList* defs = 0; - ClauseStack newClauses; - LiteralStack lits; - static TermStack args; - TermList head; - bool modified = false; - - for(unsigned i = 0; inthArgument(0); - TermList rhs = *lit->nthArgument(1); - TermList formula; - TermList boolVal; - if(AH::isBool(lhs)){ - boolVal = lhs; - formula = rhs; - } else if(AH::isBool(rhs)){ - boolVal = rhs; - formula = lhs; - } else { - lits.push(lit); - continue; - } - - bool positive = AH::isTrue(boolVal) == lit->polarity(); - - AH::getHeadAndArgs(formula, head, args); - Signature::Proxy prox = AH::getProxy(head); - - if(prox != Signature::NOT_PROXY){ - auto results = _formulaIndex->getGeneralizations(formula, true); - - bool nameExists = false; - bool needToAddDefClause = true; - TermQueryResult tqr; - TermList nameS; - TermList name; - while(results.hasNext()){ - nameExists = true; - tqr = results.next(); - - name = tqr.term; - nameS = tqr.substitution->applyToBoundResult(name); - - Literal* defLit = tqr.literal; - if(positive == defLit->polarity()){ - needToAddDefClause = false; - break; - } - } - - if(nameExists){ - //cout << "the clause is " + c->toString() << endl; - //cout << "the formula is " + formula.toString() << endl; - //cout << "the name is " + name.toString() << endl; - //cout << "the lit is " + tqr.literal->toString() << endl; - //cout << "other clause is " + tqr.clause->toString() << endl; - //cout << "the sub is " + tqr.substitution->toString() << endl; - Literal* newLit = Literal::createEquality(positive, nameS, troo, boolSort); - if(needToAddDefClause){ - Clause* defClause = tqr.clause; - ASS(defClause->size() == 2); - Literal* l1 = (*defClause)[0]; - Literal* l2 = (*defClause)[1]; - Literal* l1RevPol = Literal::complementaryLiteral(l1); - Literal* l2RevPol = Literal::complementaryLiteral(l2); - Inference* inf = new Inference(Inference::PREDICATE_DEFINITION); - Clause* defClauseRevPol = new(2) Clause(2, Unit::AXIOM, inf); - (*defClauseRevPol)[0] = l1RevPol; - (*defClauseRevPol)[1] = l2RevPol; - UnitList::push(defClauseRevPol, defs); - newClauses.push(defClauseRevPol); - if(isNamingLit(l1)){ - addToQueue(getFormula(l2), name, l1RevPol, defClauseRevPol); - } else { - addToQueue(getFormula(l1), name, l2RevPol, defClauseRevPol); - } - } - lits.push(newLit); - modified = true; - continue; - } - - if(namingBound > 0 && - env.signature->formulaCount(formula.term()) >= namingBound) { - env.signature->formulaNamed(formula.term()); - - //create name - static DHMap varSorts; - varSorts.reset(); - - VariableIterator2 vit(formula.term()); - while(vit.hasNext()){ - pair varTypePair = vit.next(); - if(!varSorts.find(varTypePair.first.var())){ - varSorts.insert(varTypePair.first.var(), varTypePair.second); - } - } - - static Stack argSorts; - static Stack termArgs; - static Stack args; - argSorts.reset(); - termArgs.reset(); - args.reset(); - - unsigned var; - TermList varSort; - DHMap::Iterator mapIt(varSorts); - while(mapIt.hasNext()) { - mapIt.next(var, varSort); - if(varSort == AtomicSort::superSort()){ - args.push(TermList(var, false)); - } else { - argSorts.push(varSort); - termArgs.push(TermList(var, false)); - } - } - ASS(termArgs.size() == argSorts.size()); - - VList* vl = VList::empty(); - for(int i = args.size() -1; i >= 0 ; i--){ - VList::push(args[i].var(), vl); - } - - unsigned fun = env.signature->addNameFunction(args.size()); - TermList sort = AtomicSort::arrowSort(argSorts, AtomicSort::boolSort()); - Signature::Symbol* sym = env.signature->getFunction(fun); - sym->setType(OperatorType::getConstantsType(sort, vl)); - TermList funApplied = TermList(Term::create(fun, args.size(), args.begin())); - TermList name = AH::createAppTerm(sort, funApplied, termArgs); - - - //create definition clause - Inference* inf = new Inference(Inference::PREDICATE_DEFINITION); - Clause* defClause = new(2) Clause(2, Unit::AXIOM, inf); - Literal* l1 = Literal::createEquality(!positive, name, troo, boolSort); - Literal* l2 = Literal::createEquality(positive, formula, troo, boolSort); - (*defClause)[0] = l1; - (*defClause)[1] = l2; - UnitList::push(defClause, defs); - newClauses.push(defClause); - addToQueue(formula, name, l1, defClause); - - Literal* newLit = Literal::createEquality(positive, name, troo, boolSort); - lits.push(newLit); - modified = true; - continue; - } - - lits.push(lit); - continue; - } - lits.push(lit); - - } - - if(!modified){ - ASS(newClauses.isEmpty()); - return ClauseIterator::getEmpty(); - } - - UnitList::push(c, defs); - Inference* inf = new InferenceMany(Inference::DEFINITION_FOLDING, defs); - Clause* res = Clause::fromStack(lits, c->inputType(), inf); - newClauses.push(res); - return pvi(getUniquePersistentIterator(ClauseStack::Iterator(newClauses))); -} - -ClauseIterator RenamingOnTheFly::perform(Clause* c) -{ - CALL("RenamingOnTheFly::perform"); - - if(c->inference()->rule() == Inference::PREDICATE_DEFINITION){ - //dont want to name definitions - return ClauseIterator::getEmpty(); - } - - ClauseIterator cit = produceClauses(c); - processQueue(); - return cit; -} - -void RenamingOnTheFly::addToQueue(TermList formula, TermList name, Literal* lit, Clause* c) -{ - CALL("RenamingOnTheFly::addToQueue"); - - _formulas.push(formula); - _names.push(name); - _lits.push(lit); - _clauses.push(c); -} - -void RenamingOnTheFly::processQueue() -{ - CALL("RenamingOnTheFly::processQueue"); - - while(!_formulas.isEmpty()){ - _formulaIndex->insertFormula(_formulas.pop(), _names.pop(), _lits.pop(), _clauses.pop()); - } - -} - - -bool RenamingOnTheFly::isNamingLit(Literal* lit) -{ - CALL("RenamingOnTheFly::isNamingLit"); - - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - bool lhsIsAtom = AH::getProxy(AH::getHead(lhs)) == Signature::NOT_PROXY; - bool rhsIsAtom = AH::getProxy(AH::getHead(rhs)) == Signature::NOT_PROXY; - return lhsIsAtom && rhsIsAtom; -} - -TermList RenamingOnTheFly::getFormula(Literal* lit) -{ - CALL("RenamingOnTheFly::getFormula"); - - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - return AH::isBool(lhs) ? rhs : lhs; -} - - -} diff --git a/Inferences/RenamingOnTheFly.hpp b/Inferences/RenamingOnTheFly.hpp deleted file mode 100644 index b4001af13a..0000000000 --- a/Inferences/RenamingOnTheFly.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file ProxyElimination.hpp - * Defines class ProxyElimination. - */ - -#ifndef __RenamingOnTheFly__ -#define __RenamingOnTheFly__ - -#include "Forwards.hpp" -#include "InferenceEngine.hpp" -#include "Kernel/Inference.hpp" - -#include "Indexing/TermIndex.hpp" - -#include "InferenceEngine.hpp" - -namespace Inferences { -using namespace Indexing; - - -class RenamingOnTheFly - : public SimplificationEngine -{ -public: - CLASS_NAME(RenamingOnTheFly); - USE_ALLOCATOR(RenamingOnTheFly); - - ClauseIterator perform(Clause* c); - - void attach(SaturationAlgorithm* salg) override; - void detach() override; - - //todo make an option -private: - ClauseIterator produceClauses(Clause* c); - void addToQueue(TermList formula, TermList name, Literal* lit, Clause* c); - void processQueue(); - bool isNamingLit(Literal* lit); - TermList getFormula(Literal* lit); - - TermStack _formulas; - TermStack _names; - LiteralStack _lits; - ClauseStack _clauses; - RenamingFormulaIndex* _formulaIndex; -}; - - - - -} - -#endif diff --git a/Inferences/SLQueryBackwardSubsumption.cpp b/Inferences/SLQueryBackwardSubsumption.cpp index 6218fd117b..9db2a71d42 100644 --- a/Inferences/SLQueryBackwardSubsumption.cpp +++ b/Inferences/SLQueryBackwardSubsumption.cpp @@ -115,7 +115,12 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, } if(clen==1) { - SLQueryResultIterator rit=_index->getInstances( (*cl)[0], false, false); + SLQueryResultIterator rit= +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances( (*cl)[0], false, false) : +#endif + _index->getInstances( (*cl)[0], false, false); ClauseIterator subsumedClauses=getUniquePersistentIterator( getFilteredIterator( getMappingIterator(rit,ClauseExtractorFn()), @@ -157,7 +162,12 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, static DHSet checkedClauses; checkedClauses.reset(); - SLQueryResultIterator rit=_index->getInstances( (*cl)[lmIndex], false, false); + SLQueryResultIterator rit= +#if VHOL + env.property->higherOrder() ? + _index->getHOLInstances( (*cl)[lmIndex], false, false) : +#endif + _index->getInstances( (*cl)[lmIndex], false, false); while(rit.hasNext()) { SLQueryResult qr=rit.next(); Clause* icl=qr.clause; @@ -180,9 +190,9 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, //contain an existing literal header after the loop mustPred=0; for(unsigned bi=0;biheader(); if(pred>mustPred) { mustPred=pred; @@ -193,11 +203,11 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, for(unsigned ii=0;iiheader(); if(pred==mustPred) { - haveMustPred=true; + haveMustPred=true; } } if(!haveMustPred) { @@ -211,9 +221,9 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, basePredsInit=true; basePreds.reset(); for(unsigned bi=0;biheader(); basePreds.insert(pred); } @@ -223,17 +233,17 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, for(unsigned ii=0;iiheader(); if(!basePreds.find(pred)) { - if(allowedMisses==0) { - fail=true; - break; - } - else { - allowedMisses--; - } + if(allowedMisses==0) { + fail=true; + break; + } + else { + allowedMisses--; + } } } if(fail) { @@ -247,15 +257,15 @@ void SLQueryBackwardSubsumption::perform(Clause* cl, LiteralList::push(qr.literal, matchedLits[lmIndex]); for(unsigned bi=0;bi -using namespace std; -#endif - -using namespace Inferences; -using namespace Lib; -using namespace Kernel; -using namespace Indexing; -using namespace Saturation; - -void SubVarSup::attach(SaturationAlgorithm* salg) -{ - CALL("SubVarSup::attach"); - - GeneratingInferenceEngine::attach(salg); - _subtermIndex=static_cast ( - _salg->getIndexManager()->request(SUB_VAR_SUP_SUBTERM_SUBST_TREE) ); - _lhsIndex=static_cast ( - _salg->getIndexManager()->request(SUB_VAR_SUP_LHS_SUBST_TREE) ); -} - -void SubVarSup::detach() -{ - CALL("SubVarSup::detach"); - - _subtermIndex=0; - _lhsIndex=0; - _salg->getIndexManager()->release(SUB_VAR_SUP_SUBTERM_SUBST_TREE); - _salg->getIndexManager()->release(SUB_VAR_SUP_LHS_SUBST_TREE); - GeneratingInferenceEngine::detach(); -} - - - -struct SubVarSup::RewritableResultsFn -{ - RewritableResultsFn(SubVarSupSubtermIndex* index) : _index(index) {} - VirtualIterator, TermQueryResult> > operator()(pair arg) - { - CALL("SubVarSup::RewritableResultsFn()"); - - TypedTermList tt(arg.second, SortHelper::getTermSort(arg.second, arg.first)); - - return pvi( pushPairIntoRightIterator(arg, _index->getUnifications(tt, true)) ); - } -private: - SubVarSupSubtermIndex* _index; -}; - -struct SubVarSup::RewriteableSubtermsFn -{ - RewriteableSubtermsFn(Ordering& ord, Clause* prem) : _ord(ord) { - prem->collectUnstableVars(_unstableVars); - } - - VirtualIterator > operator()(Literal* lit) - { - CALL("SubVarSup::RewriteableSubtermsFn()"); - TermIterator it = EqHelper::getRewritableVarsIterator(&_unstableVars, lit, _ord); - return pvi( pushPairIntoRightIterator(lit, it) ); - } - -private: - DHSet _unstableVars; - Ordering& _ord; -}; - -struct SubVarSup::ApplicableRewritesFn -{ - ApplicableRewritesFn(SubVarSupLHSIndex* index) : _index(index) {} - VirtualIterator, TermQueryResult> > operator()(pair arg) - { - CALL("SubVarSup::ApplicableRewritesFn()"); - - TypedTermList tt(arg.second, SortHelper::getTermSort(arg.second, arg.first)); - - //get everything in the tree - //false means dont use substitution - return pvi( pushPairIntoRightIterator(arg, _index->getUnifications(tt, false)) ); - } -private: - SubVarSupLHSIndex* _index; -}; - - -struct SubVarSup::ForwardResultFn -{ - ForwardResultFn(Clause* cl, SubVarSup& parent) : _cl(cl), _parent(parent) {} - Clause* operator()(pair, TermQueryResult> arg) - { - CALL("SubVarSup::ForwardResultFn::operator()"); - - TermQueryResult& qr = arg.second; - return _parent.performSubVarSup(_cl, arg.first.first, arg.first.second, - qr.clause, qr.literal, qr.term, true); - } -private: - Clause* _cl; - SubVarSup& _parent; -}; - - -struct SubVarSup::BackwardResultFn -{ - BackwardResultFn(Clause* cl, SubVarSup& parent) : _cl(cl), _parent(parent) {} - Clause* operator()(pair, TermQueryResult> arg) - { - CALL("SubVarSup::BackwardResultFn::operator()"); - - if(_cl==arg.second.clause) { - return 0; - } - - TermQueryResult& qr = arg.second; - return _parent.performSubVarSup(qr.clause, qr.literal, qr.term, - _cl, arg.first.first, arg.first.second, false); - } -private: - Clause* _cl; - SubVarSup& _parent; -}; - - -ClauseIterator SubVarSup::generateClauses(Clause* premise) -{ - CALL("SubVarSup::generateClauses"); - - //cout << "SubVarSup with " << premise->toString() << endl; - - auto itf1 = premise->getSelectedLiteralIterator(); - - // Get an iterator of pairs of selected literals and rewritable subterms of those literals - // A subterm is rewritable (see EqHelper) if - // a) The literal is a positive equality t1=t2 and the subterm is max(t1,t2) wrt ordering - // b) The subterm is not a variable - auto itf2 = getMapAndFlattenIterator(itf1,RewriteableSubtermsFn(_salg->getOrdering(), premise)); - - // Get clauses with a literal whose complement unifies with the rewritable subterm, - // returns a pair with the original pair and the unification result (includes substitution) - auto itf3 = getMapAndFlattenIterator(itf2,ApplicableRewritesFn(_lhsIndex)); - - //Perform forward SubVarSup - auto itf4 = getMappingIterator(itf3,ForwardResultFn(premise, *this)); - - auto itb1 = premise->getSelectedLiteralIterator(); - auto itb2 = getMapAndFlattenIterator(itb1,EqHelper::SubVarSupLHSIteratorFn(_salg->getOrdering())); - auto itb3 = getMapAndFlattenIterator(itb2,RewritableResultsFn(_subtermIndex)); - - //Perform backward SubVarSup - auto itb4 = getMappingIterator(itb3,BackwardResultFn(premise, *this)); - - // Add the results of forward and backward together - auto it5 = getConcatenatedIterator(itf4,itb4); - - // Remove null elements - these can come from performSubVarSup - auto it6 = getFilteredIterator(it5,NonzeroFn()); - - //cout << "out" << endl; - - return pvi( it6 ); -} - - -/** - * If SubVarSup should be performed, return result of the SubVarSup, - * otherwise return 0. - */ -Clause* SubVarSup::performSubVarSup( - Clause* rwClause, Literal* rwLit, TermList rwTerm, - Clause* eqClause, Literal* eqLit, TermList eqLHS, bool eqIsResult) -{ - CALL("SubVarSup::performSubVarSup"); - // we want the rwClause and eqClause to be active - ASS(rwClause->store()==Clause::ACTIVE); - ASS(eqClause->store()==Clause::ACTIVE); - ASS(rwTerm.isVar()); - - //cout << "performSubVarSup with " << rwClause->toString() << " and " << eqClause->toString() << endl; - //cout << "rwTerm " << rwTerm.toString() << " eqLHSS " << eqLHS.toString() << endl; - - static RobSubstitution subst; - subst.reset(); - - TermList freshVar = TermList(Int::max(rwClause->maxVar(), eqClause->maxVar()) + 1, false); - - unsigned rwLength = rwClause->length(); - unsigned eqLength = eqClause->length(); - - int newAge=Int::max(rwClause->age(),eqClause->age())+1; - - Literal* rwLitS = subst.apply(rwLit, 0); - TermList rwTermS = subst.apply(rwTerm, 0); - Literal* eqLitS = subst.apply(eqLit, 1); - TermList eqLHSS = subst.apply(eqLHS, 1); - TermList freshVarS = subst.apply(freshVar, 0); - - TermList tgtTerm = EqHelper::getOtherEqualitySide(eqLitS, eqLHSS); - - TermList varSort = SortHelper::getTermSort(rwTermS, rwLitS); - TermList eqSort = SortHelper::getEqualityArgumentSort(eqLitS); - - TermList newEqLHS = ApplicativeHelper::createAppTerm(eqSort, varSort, freshVarS, eqLHSS); - TermList newTgtTm = ApplicativeHelper::createAppTerm(eqSort, varSort, freshVarS, tgtTerm); - - //ALWAYS(subst.unify(varSort, 0, varSort, 1)); - //ALWAYS(subst.unify(rwTerm, 0, newEqLHS, 1)); - - Ordering& ordering = _salg->getOrdering(); - - //Literal* rwLitS = subst.apply(rwLit, 0); - //TermList rwTermS = subst.apply(rwTerm, 0); - //newEqLHS = subst.apply(newEqLHS, 1); - ///newTgtTm = subst.apply(newTgtTm, 1); - -#if VDEBUG - //ASS_EQ(rwTermS,newEqLHS); -#endif - - //cout << "Check ordering on " << tgtTermS.toString() << " and " << rwTermS.toString() << endl; - - /*if(rwLitS->isEquality()) { - //check that we're not rewriting only the smaller side of an equality - TermList arg0=*rwLitS->nthArgument(0); - TermList arg1=*rwLitS->nthArgument(1); - - if(!arg0.containsSubterm(rwTermS)) { - if(Ordering::isGorGEorE(ordering.getEqualityArgumentOrder(rwLitS))) { - return 0; - } - } else if(!arg1.containsSubterm(rwTermS)) { - if(Ordering::isGorGEorE(Ordering::reverse(ordering.getEqualityArgumentOrder(rwLitS)))) { - return 0; - } - } - }*/ - - Literal* tgtLitS = EqHelper::replace(rwLitS,rwTermS,newTgtTm); - - //check we don't create an equational tautology (this happens during self-SubVarSup) - if(EqHelper::isEqTautology(tgtLitS)) { - return 0; - } - - // If proof extra is on let's compute the positions we have performed - // SubVarSup on - if(env.options->proofExtra()==Options::ProofExtra::FULL){ - //TODO update for proof extra - } - - bool afterCheck = getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(); - - unsigned newLength = rwLength+eqLength-1; - Inference inf(GeneratingInference2(InferenceRule::SUB_VAR_SUP, rwClause, eqClause)); - Clause* res = new(newLength) Clause(newLength, inf); - - (*res)[0] = tgtLitS; - int next = 1; - for(unsigned i=0;inumSelected() && ordering.compare(currAfter,rwLitS) == Ordering::GREATER) { - env.statistics->inferencesBlockedForOrderingAftercheck++; - goto construction_fail; - } - } - - (*res)[next++] = currAfter; - } - } - - - for(unsigned i=0;isetAge(newAge); - - if(rwClause==eqClause) { - env.statistics->selfSubVarSup++; - } else if(eqIsResult) { - env.statistics->forwardSubVarSup++; - } else { - env.statistics->backwardSubVarSup++; - } - - //cout << "SUBVARSUP " + res->toString() << endl; - return res; - -construction_fail: - res->destroy(); - return 0; -} diff --git a/Inferences/SubVarSup.hpp b/Inferences/SubVarSup.hpp deleted file mode 100644 index e9f251633a..0000000000 --- a/Inferences/SubVarSup.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file SubVarSup.hpp - * Defines class SubVarSup. - */ - - -#ifndef __SubVarSup__ -#define __SubVarSup__ - -#include "Forwards.hpp" -#include "Indexing/TermIndex.hpp" - -#include "InferenceEngine.hpp" - -namespace Inferences { - -using namespace Kernel; -using namespace Indexing; -using namespace Saturation; - -class SubVarSup -: public GeneratingInferenceEngine -{ -public: - CLASS_NAME(SubVarSup); - USE_ALLOCATOR(SubVarSup); - - void attach(SaturationAlgorithm* salg); - void detach(); - - ClauseIterator generateClauses(Clause* premise); - - -private: - Clause* performSubVarSup( - Clause* rwClause, Literal* rwLiteral, TermList rwTerm, - Clause* eqClause, Literal* eqLiteral, TermList eqLHS, bool eqIsResult); - - struct ForwardResultFn; - struct RewriteableSubtermsFn; - struct ApplicableRewritesFn; - - struct LHSsFn; - struct RewritableResultsFn; - struct BackwardResultFn; - - SubVarSupSubtermIndex* _subtermIndex; - SubVarSupLHSIndex* _lhsIndex; -}; - - -}; - -#endif /* __SubVarSup__ */ diff --git a/Inferences/SubsumptionDemodulationHelper.hpp b/Inferences/SubsumptionDemodulationHelper.hpp index efb30f0056..67c3b33570 100644 --- a/Inferences/SubsumptionDemodulationHelper.hpp +++ b/Inferences/SubsumptionDemodulationHelper.hpp @@ -85,6 +85,13 @@ class OverlayBinder return base_it->second == term; } else { +#if VHOL + if(env.property->higherOrder()){ + if(term.containsLooseIndex()){ + return false; + } + } +#endif auto res = m_overlay.insert({var, term}); auto it = res.first; bool inserted = res.second; diff --git a/Inferences/Superposition.cpp b/Inferences/Superposition.cpp index 809137b14c..ed7575459f 100644 --- a/Inferences/Superposition.cpp +++ b/Inferences/Superposition.cpp @@ -14,6 +14,7 @@ #include "Debug/RuntimeStatistics.hpp" +#include "Forwards.hpp" #include "Lib/Environment.hpp" #include "Lib/Int.hpp" #include "Lib/Metaiterators.hpp" @@ -24,6 +25,7 @@ #include "Kernel/Clause.hpp" #include "Kernel/ColorHelper.hpp" #include "Kernel/EqHelper.hpp" +#include "Kernel/TermTransformer.hpp" #include "Kernel/Inference.hpp" #include "Kernel/Ordering.hpp" #include "Kernel/SortHelper.hpp" @@ -43,7 +45,6 @@ #include "Shell/Statistics.hpp" #include "Superposition.hpp" -#include "Shell/UnificationWithAbstractionConfig.hpp" #if VDEBUG #include @@ -85,9 +86,9 @@ struct Superposition::ForwardResultFn { CALL("Superposition::ForwardResultFn::operator()"); - TermQueryResult& qr = arg.second; + auto& qr = arg.second; return _parent.performSuperposition(_cl, arg.first.first, arg.first.second, - qr.clause, qr.literal, qr.term, qr.substitution, true, _passiveClauseContainer, qr.constraints); + qr.clause, qr.literal, qr.term, qr.unifier, true, _passiveClauseContainer); } private: Clause* _cl; @@ -107,9 +108,9 @@ struct Superposition::BackwardResultFn return 0; } - TermQueryResult& qr = arg.second; + auto& qr = arg.second; return _parent.performSuperposition(qr.clause, qr.literal, qr.term, - _cl, arg.first.first, arg.first.second, qr.substitution, false, _passiveClauseContainer, qr.constraints); + _cl, arg.first.first, arg.first.second, qr.unifier, false, _passiveClauseContainer); } private: Clause* _cl; @@ -123,10 +124,10 @@ ClauseIterator Superposition::generateClauses(Clause* premise) CALL("Superposition::generateClauses"); PassiveClauseContainer* passiveClauseContainer = _salg->getPassiveClauseContainer(); - //cout << "SUPERPOSITION with " << premise->toString() << endl; - - //TODO probably shouldn't go here! - static bool withConstraints = env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF; + static bool usingUwa = env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF; +#if VHOL + static bool usingHOL = env.property->higherOrder(); +#endif auto itf1 = premise->getSelectedLiteralIterator(); @@ -136,26 +137,46 @@ ClauseIterator Superposition::generateClauses(Clause* premise) auto itf2 = getMapAndFlattenIterator(itf1, [this](Literal* lit) // returns an iterator over the rewritable subterms - { return pushPairIntoRightIterator(lit, env.options->combinatorySup() ? EqHelper::getFoSubtermIterator(lit, _salg->getOrdering()) - : EqHelper::getSubtermIterator(lit, _salg->getOrdering())); }); + { return pushPairIntoRightIterator(lit, +#if VHOL + env.property->higherOrder() ? EqHelper::getFoSubtermIterator(lit, _salg->getOrdering()) : +#endif + EqHelper::getSubtermIterator(lit, _salg->getOrdering())); }); // Get clauses with a literal whose complement unifies with the rewritable subterm, // returns a pair with the original pair and the unification result (includes substitution) auto itf3 = getMapAndFlattenIterator(itf2, [this](pair arg) - { return pushPairIntoRightIterator(arg, _lhsIndex->getUnifications(arg.second, /*retrieveSubstitutions*/ true, withConstraints)); }); + { auto unifs = usingUwa ? _lhsIndex->getUwa(arg.second) : +#if VHOL + (usingHOL ? _lhsIndex->getHOLUnifiers(arg.second) : +#endif + _lhsIndex->getUnifications(arg.second) +#if VHOL + ) +#endif + ; + return pushPairIntoRightIterator(arg, unifs ); }); //Perform forward superposition auto itf4 = getMappingIterator(itf3,ForwardResultFn(premise, passiveClauseContainer, *this)); auto itb1 = premise->getSelectedLiteralIterator(); auto itb2 = getMapAndFlattenIterator(itb1,EqHelper::SuperpositionLHSIteratorFn(_salg->getOrdering(), _salg->getOptions())); + auto itb3 = getMapAndFlattenIterator(itb2, [this] (pair arg) - { return pushPairIntoRightIterator( - arg, - _subtermIndex->getUnifications(TypedTermList(arg.second, SortHelper::getEqualityArgumentSort(arg.first)), - /* retrieveSubstitutions */ true, withConstraints)); }); + { TypedTermList tt(arg.second, SortHelper::getEqualityArgumentSort(arg.first)); + auto unifs = usingUwa ? _subtermIndex->getUwa(tt) : +#if VHOL + (usingHOL ? _subtermIndex->getHOLUnifiers(tt) : +#endif + _subtermIndex->getUnifications(tt) +#if VHOL + ) +#endif + ; + return pushPairIntoRightIterator(arg, unifs); }); //Perform backward superposition auto itb4 = getMappingIterator(itb3,BackwardResultFn(premise, passiveClauseContainer, *this)); @@ -324,8 +345,7 @@ bool Superposition::earlyWeightLimitCheck(Clause* eqClause, Literal* eqLit, Clause* Superposition::performSuperposition( Clause* rwClause, Literal* rwLit, TermList rwTerm, Clause* eqClause, Literal* eqLit, TermList eqLHS, - ResultSubstitutionSP subst, bool eqIsResult, PassiveClauseContainer* passiveClauseContainer, - UnificationConstraintStackSP constraints) + ResultSubstitutionSP subst, bool eqIsResult, PassiveClauseContainer* passiveClauseContainer) { CALL("Superposition::performSuperposition"); TIME_TRACE("perform superposition"); @@ -333,10 +353,10 @@ Clause* Superposition::performSuperposition( ASS(rwClause->store()==Clause::ACTIVE); ASS(eqClause->store()==Clause::ACTIVE); - // the first checks the reference and the second checks the stack - bool hasConstraints = !constraints.isEmpty() && !constraints->isEmpty(); - TermList eqLHSsort = SortHelper::getEqualityArgumentSort(eqLit); + auto constraints = subst->getConstraints(); + bool hasConstraints = constraints->size() > 0; + TermList eqLHSsort = SortHelper::getEqualityArgumentSort(eqLit); if(eqLHS.isVar()) { if(!checkSuperpositionFromVariable(eqClause, eqLit, eqLHS)) { @@ -350,7 +370,6 @@ Clause* Superposition::performSuperposition( unsigned rwLength = rwClause->length(); unsigned eqLength = eqClause->length(); - unsigned conLength = hasConstraints ? constraints->size() : 0; TermList tgtTerm = EqHelper::getOtherEqualitySide(eqLit, eqLHS); @@ -381,7 +400,11 @@ Clause* Superposition::performSuperposition( #if VDEBUG if(!hasConstraints){ +#if VHOL + ASS_EQ(rwTermS.betaEtaNF(),eqLHSS.betaEtaNF()); +#else ASS_EQ(rwTermS,eqLHSS); +#endif } #endif @@ -408,7 +431,7 @@ Clause* Superposition::performSuperposition( } } - Literal* tgtLitS = EqHelper::replace(rwLitS,rwTermS,tgtTermS); + Literal* tgtLitS = SubtermReplacer(rwTermS,tgtTermS).transform(rwLitS); static bool doSimS = getOptions().simulatenousSuperposition(); @@ -417,7 +440,7 @@ Clause* Superposition::performSuperposition( return 0; } - unsigned newLength = rwLength+eqLength-1+conLength; + unsigned newLength = rwLength+eqLength-1+constraints->size(); static bool afterCheck = getOptions().literalMaximalityAftercheck() && _salg->getLiteralSelector().isBGComplete(); @@ -463,6 +486,20 @@ Clause* Superposition::performSuperposition( env.proofExtra->insert(res,extra); } + // Commenting this out to avoid disturbing Snake schedule just before + // CASC 2023. After competition can uncomment below in order to be able + // to collect unifier information + /*if(env.options->proofExtra() == Options::ProofExtra::UNIFIER){ + vstringstream ss; + ss << *subst; + vstring unifStr = ss.str(); + unifStr = " unifier: \n" + unifStr; + if (!env.proofExtra) { + env.proofExtra = new DHMap(); + } + env.proofExtra->insert(res,unifStr); + }*/ + (*res)[0] = tgtLitS; int next = 1; unsigned weight=tgtLitS->weight(); @@ -472,7 +509,7 @@ Clause* Superposition::performSuperposition( Literal* currAfter = subst->apply(curr, !eqIsResult); if (doSimS) { - currAfter = EqHelper::replace(currAfter,rwTermS,tgtTermS); + currAfter = SubtermReplacer(rwTermS,tgtTermS).transform(currAfter); } if(EqHelper::isEqTautology(currAfter)) { @@ -539,30 +576,9 @@ Clause* Superposition::performSuperposition( } } } - if(hasConstraints){ - for(unsigned i=0;isize();i++){ - UnificationConstraint con = (*constraints)[i]; - - TermList qT = subst->applyTo(con.first.first,con.first.second); - TermList rT = subst->applyTo(con.second.first,con.second.second); - - TermList sort = SortHelper::getResultSort(rT.term()); - Literal* constraint = Literal::createEquality(false,qT,rT,sort); - static Options::UnificationWithAbstraction uwa = env.options->unificationWithAbstraction(); - if(uwa==Options::UnificationWithAbstraction::GROUND && - !constraint->ground() && - (!UnificationWithAbstractionConfig::isInterpreted(qT) - && !UnificationWithAbstractionConfig::isInterpreted(rT) )) { - - // the unification was between two uninterpreted things that were not ground - res->destroy(); - return 0; - } - - (*res)[next] = constraint; - next++; - } + for(auto c : *constraints){ + (*res)[next++] = c; } if(needsToFulfilWeightLimit && !passiveClauseContainer->fulfilsWeightLimit(weight, numPositiveLiteralsLowerBound, res->inference())) { @@ -592,12 +608,5 @@ Clause* Superposition::performSuperposition( } } -/* - if(hasConstraints){ - cout << "RETURNING " << res->toString() << endl; - //NOT_IMPLEMENTED; - } -*/ -// cout << "result " + res->toString() << endl; return res; } diff --git a/Inferences/Superposition.hpp b/Inferences/Superposition.hpp index 79a61ff44a..65ccf960f2 100644 --- a/Inferences/Superposition.hpp +++ b/Inferences/Superposition.hpp @@ -20,6 +20,7 @@ #include "Indexing/TermIndex.hpp" #include "InferenceEngine.hpp" +#include "Kernel/RobSubstitution.hpp" namespace Inferences { @@ -44,8 +45,7 @@ class Superposition Clause* performSuperposition( Clause* rwClause, Literal* rwLiteral, TermList rwTerm, Clause* eqClause, Literal* eqLiteral, TermList eqLHS, - ResultSubstitutionSP subst, bool eqIsResult, PassiveClauseContainer* passiveClauseContainer, - UnificationConstraintStackSP constraints); + ResultSubstitutionSP subst, bool eqIsResult, PassiveClauseContainer* passiveClauseContainer); bool checkClauseColorCompatibility(Clause* eqClause, Clause* rwClause); static bool earlyWeightLimitCheck(Clause* eqClause, Literal* eqLit, diff --git a/Inferences/URResolution.cpp b/Inferences/URResolution.cpp index df685e612a..184fbaca3e 100644 --- a/Inferences/URResolution.cpp +++ b/Inferences/URResolution.cpp @@ -144,7 +144,7 @@ struct URResolution::Item if(!lit) { continue; } - lit = unif.substitution->apply(lit, !useQuerySubstitution); + lit = unif.unifier->apply(lit, !useQuerySubstitution); if(!lit->ground()) { nonGroundCnt++; } @@ -353,7 +353,7 @@ void URResolution::doBackwardInferences(Clause* cl, ClauseList*& acc) unsigned pos = ucl->getLiteralPosition(unif.literal); ASS(!_selectedOnly || posnumSelected()); swap(itm->_lits[0], itm->_lits[pos]); - itm->resolveLiteral(0, unif, cl, false); + itm->resolveLiteral(0, unif, cl, /* useQuerySubstitution */ false); processAndGetClauses(itm, 1, acc); } diff --git a/InstGen/IGAlgorithm.cpp b/InstGen/IGAlgorithm.cpp index 0ef6110517..dee841b601 100644 --- a/InstGen/IGAlgorithm.cpp +++ b/InstGen/IGAlgorithm.cpp @@ -454,9 +454,10 @@ void IGAlgorithm::tryGeneratingInstances(Clause* cl, unsigned litIdx) static LiteralStack genLits2; bool properInstance1; bool properInstance2; + auto subs = unif.unifier; - if (startGeneratingClause(cl, *unif.substitution, true, unif.clause,lit,genLits1,properInstance1) && - startGeneratingClause(unif.clause, *unif.substitution, false, cl,unif.literal,genLits2,properInstance2)) { + if (startGeneratingClause(cl, *subs, true, unif.clause,lit,genLits1,properInstance1) && + startGeneratingClause(unif.clause, *subs, false, cl,unif.literal,genLits2,properInstance2)) { // dismatching test passed for both @@ -464,17 +465,17 @@ void IGAlgorithm::tryGeneratingInstances(Clause* cl, unsigned litIdx) //we make sure the unit is added first, so that it can be used to shorten the //second clause by global subsumption if (properInstance2) { - finishGeneratingClause(unif.clause, *unif.substitution, false, cl,unif.literal,genLits2); + finishGeneratingClause(unif.clause, *subs, false, cl,unif.literal,genLits2); } if (properInstance1) { - finishGeneratingClause(cl, *unif.substitution, true, unif.clause,lit,genLits1); + finishGeneratingClause(cl, *subs, true, unif.clause,lit,genLits1); } } else { if (properInstance1) { - finishGeneratingClause(cl, *unif.substitution, true, unif.clause,lit,genLits1); + finishGeneratingClause(cl, *subs, true, unif.clause,lit,genLits1); } if (properInstance2) { - finishGeneratingClause(unif.clause, *unif.substitution, false, cl,unif.literal,genLits2); + finishGeneratingClause(unif.clause, *subs, false, cl,unif.literal,genLits2); } } } diff --git a/Kernel/ApplicativeHelper.cpp b/Kernel/ApplicativeHelper.cpp index 065d5e0487..e3fad8215a 100644 --- a/Kernel/ApplicativeHelper.cpp +++ b/Kernel/ApplicativeHelper.cpp @@ -1,3 +1,4 @@ + /* * This file is part of the source code of the software program * Vampire. It is protected by applicable @@ -11,8 +12,7 @@ #include "Kernel/Signature.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/TermIterators.hpp" - -#include "Lib/SmartPtr.hpp" +#include "Kernel/EqHelper.hpp" #include "ApplicativeHelper.hpp" @@ -20,38 +20,447 @@ using namespace Lib; using namespace Kernel; using namespace Shell; -TermList ApplicativeHelper::createAppTerm(TermList sort, TermList arg1, TermList arg2, TermList arg3, TermList arg4) +#if VHOL + +TermList BetaNormaliser::normalise(TermList t) { - CALL("ApplicativeHelper::createAppTerm/3"); + CALL("BetaNormaliser::normalise"); - TermList t1 = createAppTerm3(sort, arg1, arg2, arg3); - return createAppTerm(SortHelper::getResultSort(t1.term()), t1, arg4); + // term transformer does not work at the top level... + t = transformSubterm(t); + return transform(t); } -TermList ApplicativeHelper::createAppTerm3(TermList sort, TermList arg1, TermList arg2, TermList arg3) +TermList BetaNormaliser::transformSubterm(TermList t) { - CALL("ApplicativeHelper::createAppTerm3"); + CALL("BetaNormaliser::transformSubterm"); + + if(t.isLambdaTerm()) return t; + + TermList head; + TermStack args; + ApplicativeHelper::getHeadAndArgs(t, head, args); + + while(ApplicativeHelper::canHeadReduce(head, args)){ + t = RedexReducer().reduce(head, args); + if(t.isLambdaTerm()) break; + ApplicativeHelper::getHeadAndArgs(t, head, args); + } - TermList s1 = getNthArg(sort, 1); - TermList s2 = getResultApplieadToNArgs(sort, 1); - TermList s3 = getNthArg(s2, 1); - TermList s4 = getResultApplieadToNArgs(s2, 1); - return createAppTerm(s3, s4, createAppTerm(s1, s2, arg1, arg2), arg3); + return t; +} + +bool BetaNormaliser::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("BetaNormaliser::exploreSubterms"); + + if(newTerm.term()->hasRedex()) return true; + return false; +} + +TermList WHNFDeref::normalise(TermList t) +{ + CALL("WHNFDeref::normalise"); + + // term transformer does not work at the top level... + t = transformSubterm(t); + return t.isLambdaTerm() ? transform(t) : t; +} + +TermList WHNFDeref::transformSubterm(TermList t) +{ + CALL("WHNFDeref::transformSubterm"); + + if(t.isLambdaTerm()) return t; + + TermList head; + TermList sort; + TermStack args; + ApplicativeHelper::getHeadSortAndArgs(t, head, sort, args); + TermList newHead = _sub->derefBound(head); + newHead = SortDeref(_sub).deref(newHead); + + // if the head is a bound variable, then + // either it is bound to a lambda term creating a redex on dereferencing, + // or it is not. In the case, it isn't we need to track + // that the head has changed + bool headDereffed = newHead != head; + + while(ApplicativeHelper::canHeadReduce(newHead, args)){ + headDereffed = false; + t = RedexReducer().reduce(newHead, args); + if(t.isLambdaTerm()) break; + ApplicativeHelper::getHeadSortAndArgs(t, head, sort, args); + newHead = _sub->derefBound(head); + newHead = SortDeref(_sub).deref(newHead); + headDereffed = newHead != head; + } + + if(!headDereffed){ + return t; + } else if(!args.size()){ + return newHead; + } else { + return ApplicativeHelper::app(sort, newHead, args); + } + +} + +bool WHNFDeref::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("WHNFDeref::exploreSubterms"); + + return newTerm.isLambdaTerm(); +} + +TermList EtaNormaliser::normalise(TermList t) +{ + CALL("EtaNormaliser::normalise"); + + using AH = ApplicativeHelper; + + if(t.isVar() || !t.term()->hasLambda()){ + return t; + } + + if(t.isLambdaTerm()){ + TermStack lambdaSorts; + TermList matrix; + AH::getMatrixAndPrefSorts(t, matrix, lambdaSorts); + + if(matrix.isVar()) return t; // ^^^^^^X can't eta reduce this + + TermList matrixSort = SortHelper::getResultSort(matrix.term()); + TermList reduced = normalise(matrix); + if(reduced != matrix){ + t = AH::surroundWithLambdas(reduced, lambdaSorts, matrixSort, true); + } + + return transformSubterm(t); + } + + // t is not a lambda term + + TermList head; + TermList headSort; + TermStack args; + TermStack argsModified; + AH::getHeadSortAndArgs(t, head, headSort, args); + + bool changed = false; + for(unsigned j = 0; j < args.size(); j++){ + argsModified.push(normalise(args[j])); + changed = changed || (argsModified[j] != args[j]); + } + + if(!changed) return t; + TermList res = AH::app(headSort,head,argsModified); + + + return res; +} + +// uses algorithm for eta-reduction that can be found here: +// https://matryoshka-project.github.io/pubs/lambdae.pdf + +TermList EtaNormaliser::transformSubterm(TermList t) +{ + CALL("EtaNormaliser::transformSubterm"); + + TermList body = t; + unsigned l = 0; // number of lambda binders + while(body.isLambdaTerm()){ + l++; + body = body.lambdaBody(); + } + if(!l) return t; //not a lambda term, cannot eta reduce + + unsigned n = 0; // number of De bruijn indices at end of term + TermList newBody = body; + while(body.isApplication()){ + auto dbIndex = body.rhs().deBruijnIndex(); + if(!dbIndex.isSome() || dbIndex.unwrap() != n){ + break; + } + body = body.lhs(); + n++; + } + + TermShifter ts; + ts.shift(body, 0); + auto mfi = ts.minFreeIndex(); + unsigned j = mfi.isSome() ? mfi.unwrap() : UINT_MAX; // j is minimum free index + unsigned k = std::min(l, std::min(n, j)); + + if(!k){ + return t; + } + + for(unsigned i = 0; i < k; i++){ + newBody = newBody.lhs(); + } + newBody = TermShifter().shift(newBody, 0 - k); + + body = t; + for(unsigned i = 0; i < l - k; i++){ + body = body.lambdaBody(); + } + + // TermTransform doesn't work at top level... + if(body == t){ + return newBody; + } + + TermList res = SubtermReplacer(body, newBody).transform(t); + return res; +} + +TermList RedexReducer::reduce(TermList head, TermStack& args) +{ + CALL("RedexReducer::reduce"); + ASS(AH::canHeadReduce(head, args)); + + _replace = 0; + TermList t1 = head.lambdaBody(); + TermList t1Sort = *head.term()->nthArgument(1); + _t2 = args.pop(); + + TermList transformed = transformSubterm(t1); + + if(transformed != t1) return AH::app(t1Sort, transformed, args); + return AH::app(t1Sort, transform(t1), args); +} + +TermList RedexReducer::transformSubterm(TermList t) +{ + CALL("RedexReducer::transformSubterm"); + + if(t.deBruijnIndex().isSome()){ + unsigned index = t.deBruijnIndex().unwrap(); + if(index == _replace){ + // any free indices in _t2 need to be lifted by the number of extra lambdas + // that now surround them + return TermShifter().shift(_t2, _replace); + } + if(index > _replace){ + // free index. replace by index 1 less as now surrounded by one fewer lambdas + TermList sort = SortHelper::getResultSort(t.term()); + return ApplicativeHelper::getDeBruijnIndex(index - 1, sort); + } + } + return t; +} + +void RedexReducer::onTermEntry(Term* t) +{ + CALL("RedexReducer::onTermEntry"); + + if(t->isLambdaTerm()) _replace++; +} + +void RedexReducer::onTermExit(Term* t) +{ + CALL("RedexReducer::onTermExit"); + + if(t->isLambdaTerm()) _replace--; +} + +bool RedexReducer::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("RedexReducer::exploreSubterms"); + + if(orig != newTerm) return false; + if(newTerm.term()->hasDBIndex()) return true; + return false; +} + +TermList TermShifter::shift(TermList term, int shiftBy) +{ + CALL("TermShifter::shift"); + + _cutOff = 0; + _shiftBy = shiftBy; + + TermList transformed = transformSubterm(term); + if(transformed != term) return transformed; + return transform(term); +} + +TermList TermShifter::transformSubterm(TermList t) +{ + CALL("TermShifter::transformSubterm"); + + if(t.deBruijnIndex().isSome()){ + unsigned index = t.deBruijnIndex().unwrap(); + if(index >= _cutOff){ + // free index. lift + if(_shiftBy != 0){ + TermList sort = SortHelper::getResultSort(t.term()); + ASS(_shiftBy >= 0 || index >= std::abs(_shiftBy)); + return ApplicativeHelper::getDeBruijnIndex(index + _shiftBy, sort); + } else { + int j = (int)(index - _cutOff); + if(j < _minFreeIndex || _minFreeIndex == -1){ + _minFreeIndex = j; + } + } + } + } + return t; +} + +void TermShifter::onTermEntry(Term* t) +{ + CALL("TermShifter::onTermEntry"); + + if(t->isLambdaTerm()) _cutOff++; +} + +void TermShifter::onTermExit(Term* t) +{ + CALL("TermShifter::onTermExit"); + + if(t->isLambdaTerm()) _cutOff--; +} + +bool TermShifter::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("TermShifter::exploreSubterms"); + + // already shifted, so must be DB index and won't have subterms anyway + if(orig != newTerm) return false; + if(newTerm.term()->hasDBIndex()) return true; + return false; +} + +TermList SortDeref::deref(TermList term) +{ + CALL("SortDeref::deref"); + + // assume term var here + if(term.isVar() || !term.term()->hasSortVar()) return term; + return transform(term); +} + +TermList SortDeref::transformSubterm(TermList t) +{ + CALL("ortDeref::transformSubterm"); + + if(t.isVar() && _positions.top() < _typeArities.top()){ + t = _sub->derefBound(t); + } + unsigned pos = _positions.pop(); + _positions.push(pos + 1); + return t; +} + +void SortDeref::onTermEntry(Term* t){ + CALL("SortDeref::onTermEntry"); + + _typeArities.push(t->isSort() ? t->arity() : t->numTypeArguments()); + _positions.push(0); +} + +void SortDeref::onTermExit(Term* t){ + CALL("ortDeref::onTermExit"); + + _typeArities.pop(); + _positions.pop(); +} + +bool SortDeref::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("SortDeref::exploreSubterms"); + + ASS(newTerm.isTerm()); + + return newTerm.term()->hasSortVar(); } -TermList ApplicativeHelper::createAppTerm(TermList sort, TermList arg1, TermList arg2) +TermList ToPlaceholders::replace(TermList term) { - CALL("ApplicativeHelper::createAppTerm/2"); + CALL("ToPlaceholders::replace"); + + TermList transformed = transformSubterm(term); + if(transformed != term) return transformed; + _topLevel = false; + return transform(term); +} + +TermList ToPlaceholders::transformSubterm(TermList t) +{ + CALL("ToPlaceholders::transformSubterm"); + + typedef ApplicativeHelper AH; + + if(_nextIsPrefix) return t; + if(t.isVar()) return t; + + // Not expecting any unreduced redexes here + ASS(!t.head().isLambdaTerm()); + + auto sort = SortHelper::getResultSort(t.term()); + if(t.isLambdaTerm() || t.head().isVar()) return AH::placeholder(sort); + + if(_mode == Options::FunctionExtensionality::ABSTRACTION){ + if(sort.isArrowSort() || sort.isVar() || (sort.isBoolSort() && !_topLevel)){ + return AH::placeholder(sort); + } + } + return t; +} + +void ToPlaceholders::onTermEntry(Term* t) +{ + CALL("ToPlaceholders::onTermEntry"); + + if(t->isApplication()) _nextIsPrefix = true; +} + +void ToPlaceholders::onTermExit(Term* t) +{ + CALL("ToPlaceholders::onTermExit"); + + _nextIsPrefix = false; +} + +TermList ApplicativeHelper::app2(TermList sort, TermList head, TermList arg1, TermList arg2) +{ + CALL("ApplicativeHelper::app2"); + + return app(app(sort, head, arg1), arg2); +} + +TermList ApplicativeHelper::app2(TermList head, TermList arg1, TermList arg2) +{ + CALL("ApplicativeHelper::app2"); + ASS(head.isTerm()); + + TermList headSort = SortHelper::getResultSort(head.term()); + return app2(headSort, head, arg1, arg2); +} + +TermList ApplicativeHelper::app(TermList sort, TermList head, TermList arg) +{ + CALL("ApplicativeHelper::app"); TermList s1 = getNthArg(sort, 1); TermList s2 = getResultApplieadToNArgs(sort, 1); - return createAppTerm(s1, s2, arg1, arg2); + return app(s1, s2, head, arg); } -TermList ApplicativeHelper::createAppTerm(TermList s1, TermList s2, TermList arg1, TermList arg2, bool shared) +TermList ApplicativeHelper::app(TermList head, TermList arg) { - CALL("ApplicativeHelper::createAppTerm/1"); - + CALL("ApplicativeHelper::app/2"); + ASS(head.isTerm()); + + return app(SortHelper::getResultSort(head.term()), head, arg); +} + +TermList ApplicativeHelper::app(TermList s1, TermList s2, TermList arg1, TermList arg2, bool shared) +{ + CALL("ApplicativeHelper::app/3"); + static TermStack args; args.reset(); args.push(s1); @@ -65,41 +474,84 @@ TermList ApplicativeHelper::createAppTerm(TermList s1, TermList s2, TermList arg return TermList(Term::createNonShared(app, 4, args.begin())); } -TermList ApplicativeHelper::createAppTerm(TermList sort, TermList head, TermStack& terms) +TermList ApplicativeHelper::app(TermList sort, TermList head, TermStack& terms) { - CALL("ApplicativeHelper::createAppTerm/4"); + CALL("ApplicativeHelper::app/4"); ASS(head.isVar() || SortHelper::getResultSort(head.term()) == sort); TermList res = head; TermList s1, s2; - + for(int i = terms.size() - 1; i >= 0; i--){ s1 = getNthArg(sort, 1); s2 = getResultApplieadToNArgs(sort, 1); - res = createAppTerm(s1, s2, res, terms[i]); + res = app(s1, s2, res, terms[i]); sort = s2; } return res; } -TermList ApplicativeHelper::createAppTerm(TermList sort, TermList head, TermList* args, unsigned arity, bool shared) +TermList ApplicativeHelper::app(TermList head, TermStack& terms) { - CALL("ApplicativeHelper::createAppTerm/5"); - ASS_REP(head.isVar() || SortHelper::getResultSort(head.term()) == sort, sort.toString() ); + CALL("ApplicativeHelper::app/5"); + ASS(head.isTerm()); - TermList res = head; - TermList s1, s2; + TermList sort = SortHelper::getResultSort(head.term()); + return app(sort, head, terms); +} - for(unsigned i = 0; i < arity; i++){ - s1 = getNthArg(sort, 1); - s2 = getResultApplieadToNArgs(sort, 1); - res = createAppTerm(s1, s2, res, args[i], shared); - sort = s2; +TermList ApplicativeHelper::lambda(TermList varSort, TermList termSort, TermList term) +{ + CALL("ApplicativeHelper::lambda"); + + ASS(varSort.isVar() || varSort.term()->isSort()); + ASS(termSort.isVar() || termSort.term()->isSort()); + + static TermStack args; + args.reset(); + args.push(varSort); + args.push(termSort); + args.push(term); + unsigned lam = env.signature->getLam(); + return TermList(Term::create(lam, 3, args.begin())); +} + +TermList ApplicativeHelper::lambda(TermList varSort, TermList term) +{ + CALL("ApplicativeHelper::lambda/2"); + ASS(term.isTerm()); + + TermList termSort = SortHelper::getResultSort(term.term()); + return lambda(varSort, termSort, term); +} + +TermList ApplicativeHelper::matrix(TermList t) +{ + CALL("ApplicativeHelper::matrix"); + + while(t.isLambdaTerm()){ + t = t.lambdaBody(); } - return res; -} + return t; +} + + +TermList ApplicativeHelper::getDeBruijnIndex(int index, TermList sort) +{ + CALL("ApplicativeHelper::createDBIndex"); + + unsigned fun = env.signature->getDeBruijnIndex(index); + return TermList(Term::create1(fun, sort)); +} + +TermList ApplicativeHelper::placeholder(TermList sort) +{ + CALL("ApplicativeHelper::placeholder"); + unsigned fun = env.signature->getPlaceholder(); + return TermList(Term::create1(fun, sort)); +} /** indexed from 1 */ TermList ApplicativeHelper::getResultApplieadToNArgs(TermList arrowSort, unsigned argNum) @@ -108,13 +560,12 @@ TermList ApplicativeHelper::getResultApplieadToNArgs(TermList arrowSort, unsigne while(argNum > 0){ ASS(arrowSort.isArrowSort()); - arrowSort = *arrowSort.term()->nthArgument(1); + arrowSort = arrowSort.result(); argNum--; } return arrowSort; } - /** indexed from 1 */ TermList ApplicativeHelper::getNthArg(TermList arrowSort, unsigned argNum) { @@ -124,36 +575,26 @@ TermList ApplicativeHelper::getNthArg(TermList arrowSort, unsigned argNum) TermList res; while(argNum >=1){ ASS(arrowSort.isArrowSort()); - res = *arrowSort.term()->nthArgument(0); - arrowSort = *arrowSort.term()->nthArgument(1); + res = arrowSort.domain(); + arrowSort = arrowSort.result(); argNum--; } return res; } -TermList ApplicativeHelper::getResultSort(TermList sort) -{ - CALL("ApplicativeHelper::getResultSort"); - - while(sort.isArrowSort()){ - sort = *sort.term()->nthArgument(1); - } - return sort; -} - unsigned ApplicativeHelper::getArity(TermList sort) { CALL("ApplicativeHelper::getArity"); unsigned arity = 0; while(sort.isArrowSort()){ - sort = *sort.term()->nthArgument(1); + sort = sort.result(); arity++; } return arity; } -void ApplicativeHelper::getHeadAndAllArgs(TermList term, TermList& head, TermStack& args) +/*void ApplicativeHelper::getHeadAndAllArgs(TermList term, TermList& head, TermStack& args) { CALL("ApplicativeHelper::getHeadAndAllArgs"); @@ -168,7 +609,7 @@ void ApplicativeHelper::getHeadAndAllArgs(TermList term, TermList& head, TermSta args.push(*term.term()->nthArgument(i)); } } -} +} */ void ApplicativeHelper::getHeadSortAndArgs(TermList term, TermList& head, TermList& headSort, TermStack& args) @@ -177,119 +618,113 @@ void ApplicativeHelper::getHeadSortAndArgs(TermList term, TermList& head, if(!args.isEmpty()){ args.reset(); } - if(!term.isTerm()){ - head = term; - return; - } + term = matrix(term); while(term.isApplication()){ - Term* t = term.term(); - args.push(*t->nthArgument(3)); - term = *t->nthArgument(2); - if(!term.isApplication()){ - headSort = AtomicSort::arrowSort(*t->nthArgument(0), *t->nthArgument(1)); - break; + args.push(term.rhs()); + TermList t = term.lhs(); + if(!t.isApplication()){ + headSort = AtomicSort::arrowSort(term.nthArg(0), term.nthArg(1)); } + term = t; } head = term; - } - -void ApplicativeHelper::getHeadAndArgs(TermList term, TermList& head, TermStack& args) +void ApplicativeHelper::getHeadArgsAndArgSorts(TermList t, TermList& head, TermStack& args, TermStack& argSorts) { - CALL("ApplicativeHelper::getHeadAndArgs"); + CALL("ApplicativeHelper::getHeadArgsAndArgSorts"); if(!args.isEmpty()){ args.reset(); } + if(!argSorts.isEmpty()){ argSorts.reset(); } - while(term.isApplication()){ - args.push(*term.term()->nthArgument(3)); - term = *term.term()->nthArgument(2); - } - head = term; + t = matrix(t); + while(t.isApplication()){ + args.push(t.rhs()); + argSorts.push(rhsSort(t)); + t = t.lhs(); + } + head = t; } +void ApplicativeHelper::getMatrixAndPrefSorts(TermList t, TermList& matrix, TermStack& sorts) +{ + CALL("ApplicativeHelper::getLambdaPrefSorts"); + + while(t.isLambdaTerm()){ + sorts.push(*t.term()->nthArgument(0)); + t = t.lambdaBody(); + } + matrix = t; +} -void ApplicativeHelper::getHeadAndArgs(Term* term, TermList& head, TermStack& args) +void ApplicativeHelper::getArgSorts(TermList t, TermStack& sorts) { - CALL("ApplicativeHelper::getHeadAndArgs/2"); + CALL("ApplicativeHelper::getArgSorts"); - if(!args.isEmpty()){ args.reset(); } + while(t.isArrowSort()){ + sorts.push(t.domain()); + t = t.result(); + } - head = TermList(term); + t = matrix(t); - while(term->isApplication()){ - args.push(*term->nthArgument(3)); - head = *term->nthArgument(2); - if(head.isTerm()){ - term = head.term(); - } else { break; } + while(t.isApplication()){ + sorts.push(*t.term()->nthArgument(0)); + t = t.lhs(); } - } -void ApplicativeHelper::getHeadAndArgs(const Term* term, TermList& head, Deque& args) -{ - CALL("ApplicativeHelper::getHeadAndArgs/3"); - ASS(term->isApplication()); +void ApplicativeHelper::getHeadAndArgs(TermList term, TermList& head, TermStack& args) +{ + CALL("ApplicativeHelper::getHeadAndArgs"); if(!args.isEmpty()){ args.reset(); } - while(term->isApplication()){ - args.push_front(*term->nthArgument(3)); - head = *term->nthArgument(2); - if(head.isTerm()){ - term = head.term(); - } else { break; } - } -} - + term = matrix(term); + while(term.isApplication()){ + args.push(term.rhs()); + term = term.lhs(); + } + head = term; +} -TermList ApplicativeHelper::getHead(TermList t) +void ApplicativeHelper::getHeadAndArgs(Term* term, TermList& head, TermStack& args) { - CALL("ApplicativeHelper::getHead(TermList)"); - - if(!t.isTerm()){ - return t; - } + CALL("ApplicativeHelper::getHeadAndArgs/2"); - while(t.isApplication()){ - t = *t.term()->nthArgument(2); - if(!t.isTerm() || t.term()->isSpecial()){ break; } - } - return t; + getHeadAndArgs(TermList(term), head, args); } -TermList ApplicativeHelper::getHead(Term* t) +void ApplicativeHelper::getHeadAndArgs(const Term* term, TermList& head, TermStack& args) { - CALL("ApplicativeHelper::getHead(Term*)"); - - TermList trm = TermList(t); - while(t->isApplication()){ - trm = *t->nthArgument(2); - if(!trm.isTerm() || trm.term()->isSpecial()){ break; } - t = trm.term(); - } - return trm; + CALL("ApplicativeHelper::getHeadAndArgs/5"); + + getHeadAndArgs(const_cast(term),head,args); } -bool ApplicativeHelper::isComb(const TermList head) +TermList ApplicativeHelper::lhsSort(TermList t) { - CALL("ApplicativeHelper::isComb"); - if(head.isVar()){ return false; } - return env.signature->getFunction(head.term()->functor())->combinator() != Signature::NOT_COMB; -} + CALL("ApplicativeHelper::lhsSort"); + ASS(t.isApplication()); + + TermList s1 = *t.term()->nthArgument(0); + TermList s2 = *t.term()->nthArgument(1); + return AtomicSort::arrowSort(s1,s2); +} -Signature::Combinator ApplicativeHelper::getComb (const TermList head) +TermList ApplicativeHelper::rhsSort(TermList t) { - CALL("ApplicativeHelper::getComb"); - return env.signature->getFunction(head.term()->functor())->combinator(); -} + CALL("ApplicativeHelper::rhsSort") + ASS(t.isApplication()); -Signature::Proxy ApplicativeHelper::getProxy(const TermList t) + return *t.term()->nthArgument(0); +} + +Signature::Proxy ApplicativeHelper::getProxy(const TermList& t) { CALL("ApplicativeHelper::getProxy"); if(t.isVar()){ @@ -298,43 +733,49 @@ Signature::Proxy ApplicativeHelper::getProxy(const TermList t) return env.signature->getFunction(t.term()->functor())->proxy(); } -bool ApplicativeHelper::isUnderApplied(TermList head, unsigned argNum){ - CALL("ApplicativeHelper::isPartiallyAppliedComb"); - - ASS(isComb(head)); - Signature::Combinator c = getComb(head); - return ((c == Signature::I_COMB && argNum < 1) || - (c == Signature::K_COMB && argNum < 2) || - (c == Signature::B_COMB && argNum < 3) || - (c == Signature::C_COMB && argNum < 3) || - (c == Signature::S_COMB && argNum < 3)); -} - -bool ApplicativeHelper::isExactApplied(TermList head, unsigned argNum){ - CALL("ApplicativeHelper::isExactApplied"); +void ApplicativeHelper::getAbstractionTerms(Literal* lit, TermStack& terms) +{ + CALL("ApplicativeHelper::getAbstractionTerms"); - ASS(isComb(head)); - Signature::Combinator c = getComb(head); - return ((c == Signature::I_COMB && argNum == 1) || - (c == Signature::K_COMB && argNum == 2) || - (c == Signature::B_COMB && argNum == 3) || - (c == Signature::C_COMB && argNum == 3) || - (c == Signature::S_COMB && argNum == 3)); + ASS(lit->isEquality()); -} + TermList lhs = *lit->nthArgument(0); + TermList rhs = *lit->nthArgument(1); + TermList eqSort = SortHelper::getEqualityArgumentSort(lit); -bool ApplicativeHelper::isOverApplied(TermList head, unsigned argNum){ - CALL("ApplicativeHelper::isOverApplied"); - - ASS(isComb(head)); - Signature::Combinator c = getComb(head); - return ((c == Signature::I_COMB && argNum > 1) || - (c == Signature::K_COMB && argNum > 2) || - (c == Signature::B_COMB && argNum > 3) || - (c == Signature::C_COMB && argNum > 3) || - (c == Signature::S_COMB && argNum > 3)); + auto dealWithArg = [&](TermList arg, TermList argSort, TermStack& terms){ + if(!arg.containsLooseIndex()){ + TermList db = getDeBruijnIndex(0,argSort); + SubtermReplacer st(arg,db,true); + TermList lhsReplaced = st.transform(lhs); + TermList rhsReplaced = st.transform(rhs); + TermList eq = app2(equality(eqSort), lhsReplaced, rhsReplaced); + eq = lit->polarity() ? app(neg(),eq) : eq; // reverse the polarity of the literal + terms.push(lambda(argSort,eq)); + } + }; + + TermList lhsHead, rhsHead; + TermList lhsMatrix, rhsMatrix; + static TermStack lhsArgs; + static TermStack lhsArgSorts; + static TermStack rhsArgs; + static TermStack rhsArgSorts; + + + getHeadArgsAndArgSorts(lhs, lhsHead, lhsArgs, lhsArgSorts); + getHeadArgsAndArgSorts(rhs, rhsHead, rhsArgs, rhsArgSorts); + if(lhsHead.isTerm() && lhsHead.deBruijnIndex().isNone() && lhsHead == rhsHead) + { + for(unsigned i = 0; i < lhsArgs.size(); i++){ + dealWithArg(lhsArgs[i], lhsArgSorts[i], terms); + } + for(unsigned i = 0; i < rhsArgs.size(); i++){ + dealWithArg(rhsArgs[i], rhsArgSorts[i], terms); + } + } } bool ApplicativeHelper::isBool(TermList t){ @@ -342,122 +783,315 @@ bool ApplicativeHelper::isBool(TermList t){ return isTrue(t) || isFalse(t); } +bool ApplicativeHelper::splittable(TermList t, bool topLevel){ + CALL("ApplicativeHelper::splittable1"); + + if(t.isVar()) return true; + + ASS(!t.head().isLambdaTerm()); // assume t is in head normal form + if(t.isLambdaTerm() || t.head().isVar()) return false; + + if(env.options->functionExtensionality() == Options::FunctionExtensionality::ABSTRACTION){ + auto sort = SortHelper::getResultSort(t.term()); + if(sort.isArrowSort() || sort.isVar() || (sort.isBoolSort() && !topLevel)){ + return false; + } + } + return true; +} + bool ApplicativeHelper::isTrue(TermList term){ CALL("ApplicativeHelper::isTrue"); - return term.isTerm() && env.signature->isFoolConstantSymbol(true, term.term()->functor()); + return term.isTerm() && !term.term()->isSort() && env.signature->isFoolConstantSymbol(true, term.term()->functor()); } bool ApplicativeHelper::isFalse(TermList term){ CALL("ApplicativeHelper::isFalse"); - return term.isTerm() && env.signature->isFoolConstantSymbol(false, term.term()->functor()); + return term.isTerm() && !term.term()->isSort() && env.signature->isFoolConstantSymbol(false, term.term()->functor()); } -bool ApplicativeHelper::isSafe(TermStack& args) -{ - CALL("ApplicativeHelper::isSafe"); +bool ApplicativeHelper::canHeadReduce(TermList const& head, TermStack const& args){ + CALL("ApplicativeHelper::canHeadReduce"); + + return head.isLambdaTerm() && args.size(); +} - for(unsigned i = 0; i < args.size(); i++){ - TermList ithArg = args[i]; - /*if(ithArg.isVar() || !ithArg.term()->ground()){ - return false; - }*/ - TermList head = getHead(ithArg); - if(isComb(head) || head.isVar()){ - return false; - } +bool ApplicativeHelper::isEtaExpandedVar(TermList t, TermList& var){ + CALL("ApplicativeHelper::isEtaExpandedVar"); + + // TODO code sharing with Eta reducer above + TermList body = t; + unsigned l = 0; // number of lambda binders + while(body.isLambdaTerm()){ + l++; + body = body.lambdaBody(); } - return true; + + unsigned n = 0; // number of De bruijn indices at end of term + while(body.isApplication()){ + auto dbIndex = body.rhs().deBruijnIndex(); + if(!dbIndex.isSome() || dbIndex.unwrap() != n) + { break; } + body = body.lhs(); + n++; + } + + var = body; + return n == l && var.isVar(); } -TermList ApplicativeHelper::replaceFunctionalAndBooleanSubterms(Term* term, FuncSubtermMap* fsm) + +void ApplicativeHelper::normaliseLambdaPrefixes(TermList& t1, TermList& t2) { - CALL("TermSubstitutionTree::replaceFunctionalAndBooleanSubterms"); + CALL("ApplicativeHelper::normaliseLambdaPrefixes"); + + if(t1.isVar() && t2.isVar()) return; + TermList nonVar = t1.isVar() ? t2 : t1; + TermList sort = SortHelper::getResultSort(nonVar.term()); + + auto etaExpand = [](TermList t, TermList sort, TermStack& sorts, unsigned n){ + TermStack sorts1; // sorts of new prefix + + t = TermShifter().shift(t,n); // lift loose indices by n + + for(int i = n - 1; i >= 0; i--){ // append De Bruijn indices + ASS(sort.isArrowSort()); + auto s = sort.domain(); + auto dbIndex = getDeBruijnIndex((unsigned)i,s); + t = app(sort, t, dbIndex); + sort = sort.result(); + sorts1.push(s); + } + + while(!sorts1.isEmpty()){ // wrap in new lambdas + t = lambda(sorts1.pop(), t); + } + + while(!sorts.isEmpty()){ // wrap in original lambdas + t = lambda(sorts.pop(), t); + } + + return t; + }; + + unsigned m = 0; + unsigned n = 0; + TermList t1c = t1; + TermList t2c = t2; + TermList t1s = sort; + TermList t2s = sort; + TermStack prefSorts1; + TermStack prefSorts2; - typedef SmartPtr ArgsIt_ptr; - typedef ApplicativeHelper AH; - - static Stack terms(8); - static Stack infos(8); - static Stack modified(8); - static Stack argIts(8); - static TermStack args; + while(t1c.isLambdaTerm()){ + t1c = t1c.lambdaBody(); + prefSorts1.push(t1s.domain()); + t1s = t1s.result(); + m++; + } - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS(infos.isEmpty()); - modified.reset(); - args.reset(); + while(t2c.isLambdaTerm()){ + t2c = t2c.lambdaBody(); + prefSorts2.push(t2s.domain()); + t2s = t2s.result(); + n++; + } - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(TermList(term), false))); - ArgsIt_ptr argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - - for (;;) { - if (!argIts.top()->hasNext()) { - argIts.pop(); - if (terms.isEmpty()) { - //we're done, args stack contains modified arguments - //of the literal. - ASS(argIts.isEmpty()); - break; - } - Term* orig = terms.pop(); - AH::HigherOrderTermInfo hoti=infos.pop(); - if (!modified.pop()) { - args.truncate(args.length() - hoti.argNum); - args.push(TermList(orig)); - continue; + if(m > n) + t2 = etaExpand(t2c, t2s, prefSorts2, m - n); + + if(n > m) + t1 = etaExpand(t1c, t1s, prefSorts1, n - m); +} + + +bool ApplicativeHelper::getProjAndImitBindings(TermList flexTerm, TermList rigidTerm, TermStack& bindings, + TermList& fVar) +{ + CALL("ApplicativeHelper::getProjAndImitBindings"); + + ASS(bindings.isEmpty()); + + // if flexTerm is of form X t1 t2 : i > i and t1 : int and t2 : tau + // this function will fill stack with [i, tau, int] + // Very inelegant at the moment, need to rewrite TODO + auto getFlexHeadSorts = [](TermList flexTerm, TermStack& sorts, TermList rigidTermSort){ + TermList matrixSort; + if(flexTerm.isVar()){ + matrixSort = rigidTermSort; + } else { + matrixSort = SortHelper::getResultSort(flexTerm.term()); + while(flexTerm.isLambdaTerm()){ + matrixSort = *flexTerm.term()->nthArgument(1); + flexTerm = flexTerm.lambdaBody(); } - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - TermList* argLst=&args.top() - (hoti.argNum - 1); - args.truncate(args.length() - hoti.argNum); - - TermList trm = AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum, false); - args.push(trm); - modified.setTop(true); - continue; } - TermList tl= argIts.top()->next(); - if(tl.isTerm()){ - TermList sort = SortHelper::getResultSort(tl.term()); - if(sort.isVar() || sort.isArrowSort() || - sort == AtomicSort::boolSort()){ - tl = getVSpecVar(tl.term(), fsm); - modified.setTop(true); - } - } + TermStack temp; + getArgSorts(matrixSort,temp); + while(!temp.isEmpty()){ + sorts.push(temp.pop()); + } + getArgSorts(flexTerm,sorts); + }; + + // since term is rigid, cannot be a variable + TermList sort = SortHelper::getResultSort(matrix(rigidTerm).term()).finalResult(); + TermList headRigid = rigidTerm.head(); + TermList headFlex; + TermStack argsFlex; + TermStack sortsFlex; //sorts of arguments of flex head + + getHeadAndArgs(flexTerm, headFlex, argsFlex); + getFlexHeadSorts(flexTerm, sortsFlex, SortHelper::getResultSort(rigidTerm.term())); + + TermList pb; + TermList var = fVar; + bool imit = false; + // imitation + if(headRigid.deBruijnIndex().isNone()){ // cannot imitate a bound variable + imit = true; + pb = createGeneralBinding(var, headRigid, sortsFlex); + fVar = var.var() > fVar.var() ? var : fVar; + bindings.push(pb); + } + + ASS(sortsFlex.size() >= argsFlex.size()); + unsigned diff = sortsFlex.size() - argsFlex.size(); + + // projections + for(unsigned i = 0; i < argsFlex.size(); i++){ + // try and project each of the arguments of the flex head in turn + TermList arg = argsFlex[i]; + TermList argSort = sortsFlex[i + diff]; + // sort wrong, cannot project this arg + if(argSort.finalResult() != sort) continue; + TermList head = arg.head(); + // argument has a rigid head different to that of rhs. no point projecting + if(head.isTerm() && head.deBruijnIndex().isNone() && head != headRigid) continue; + + TermList dbi = getDeBruijnIndex(i + diff, sortsFlex[i + diff]); + + TermList pb = createGeneralBinding(fVar,dbi,sortsFlex); + fVar = var.var() > fVar.var() ? var : fVar; + bindings.push(pb); + } + + return imit; +} + +TermList ApplicativeHelper::createGeneralBinding(TermList& freshVar, TermList head, + TermStack& sorts, bool surround){ + CALL("ApplicativeHelper::createGeneralBinding/3"); + ASS(head.isTerm()); // in the future may wish to reconsider this assertion - if (tl.isVar()) { - args.push(tl); - continue; + TermStack args; + TermStack argSorts; + TermStack indices; + + auto getNextFreshVar = [&](){ + freshVar = TermList(freshVar.var() + 1, freshVar.bank()); + return freshVar; + }; + + TermList headSort = SortHelper::getResultSort(head.term()); + getArgSorts(headSort, argSorts); + + for(unsigned i = 0; i < sorts.size(); i++){ + indices.push(getDeBruijnIndex(i, sorts[i])); + } + + while(!argSorts.isEmpty()){ + TermList varSort = AtomicSort::arrowSort(sorts, argSorts.pop()); + args.push(app(varSort, getNextFreshVar(), indices)); + } + + TermList pb = app(head, args); + return surround ? surroundWithLambdas(pb, sorts) : pb; +} + +TermList ApplicativeHelper::surroundWithLambdas(TermList t, TermStack& sorts, bool fromTop) +{ + CALL("ApplicativeHelper::surroundWithLambdas/1"); + + ASS(t.isTerm()); + TermList sort = SortHelper::getResultSort(t.term()); + return surroundWithLambdas(t, sorts, sort, fromTop); +} + + +TermList ApplicativeHelper::surroundWithLambdas(TermList t, TermStack& sorts, TermList sort, bool fromTop) +{ + CALL("ApplicativeHelper::surroundWithLambdas/2"); + + if(!fromTop){ // TODO fromTop is very hacky. See if can merge these two into one loop + for(unsigned i = 0; i < sorts.size(); i++) + { + t = lambda(sorts[i], sort, t); + sort = AtomicSort::arrowSort(sorts[i], sort); } - ASS(tl.isTerm()); - Term* t=tl.term(); - terms.push(t); - modified.push(false); - argIts.push(ArgsIt_ptr(new ApplicativeArgsIt(tl, false))); - argsIt = argIts.top(); - infos.push(AH::HigherOrderTermInfo(argsIt->head(), argsIt->headSort(), argsIt->argNum())); - } - ASS(argIts.isEmpty()); - ASS(terms.isEmpty()); - ASS_EQ(modified.length(),1); - ASS_EQ(infos.length(),1); - AH::HigherOrderTermInfo hoti=infos.pop(); - ASS_EQ(args.length(),hoti.argNum); - - if (!modified.pop()) { - return TermList(term); - } - - TermList* argLst=&args.top() - (hoti.argNum-1); - ASS(!term->isLiteral()); - //cout << "original " + term->toString() << endl; - TermList replaced = AH::createAppTerm(hoti.headSort, hoti.head, argLst, hoti.argNum, false); - //cout << "new " + replaced.toString() << endl; - return replaced; -} \ No newline at end of file + } else { + for(int i = sorts.size() - 1; i >= 0; i--) + { + t = lambda(sorts[i], sort, t); + sort = AtomicSort::arrowSort(sorts[i], sort); + } + } + return t; +} + +TermList ApplicativeHelper::top(){ + CALL("ApplicativeHelper::top"); + + return TermList(Term::foolTrue()); +} + +TermList ApplicativeHelper::bottom(){ + CALL("ApplicativeHelper::bottom"); + + return TermList(Term::foolFalse()); +} + +TermList ApplicativeHelper::conj(){ + CALL("ApplicativeHelper::conj"); + + return TermList(Term::createConstant(env.signature->getBinaryProxy("vAND"))); +} + +TermList ApplicativeHelper::disj(){ + CALL("ApplicativeHelper::disj"); + + return TermList(Term::createConstant(env.signature->getBinaryProxy("vOR"))); +} + +TermList ApplicativeHelper::imp(){ + CALL("ApplicativeHelper::imp"); + + return TermList(Term::createConstant(env.signature->getBinaryProxy("vIMP"))); +} + +TermList ApplicativeHelper::neg(){ + CALL("ApplicativeHelper::neg"); + + return TermList(Term::createConstant(env.signature->getNotProxy())); +} + +TermList ApplicativeHelper::equality(TermList sort){ + CALL("ApplicativeHelper::equality"); + + return TermList(Term::create1(env.signature->getEqualityProxy(), sort)); +} + +TermList ApplicativeHelper::pi(TermList sort){ + CALL("ApplicativeHelper::pi"); + + return TermList(Term::create1(env.signature->getPiSigmaProxy("vPI"), sort)); +} + +TermList ApplicativeHelper::sigma(TermList sort){ + CALL("ApplicativeHelper::sigma"); + + return TermList(Term::create1(env.signature->getPiSigmaProxy("vSIGMA"), sort)); +} + +#endif \ No newline at end of file diff --git a/Kernel/ApplicativeHelper.hpp b/Kernel/ApplicativeHelper.hpp index e201ba9e83..bfdda6ede8 100644 --- a/Kernel/ApplicativeHelper.hpp +++ b/Kernel/ApplicativeHelper.hpp @@ -19,93 +19,226 @@ #include "Signature.hpp" #include "Lib/Deque.hpp" #include "Lib/BiMap.hpp" -#include "Kernel/BottomUpEvaluation/TypedTermList.hpp" +#include "Kernel/TermTransformer.hpp" +#include "Kernel/RobSubstitution.hpp" using namespace Kernel; using namespace Shell; -/** - * A class with function @b elimLambda() that eliminates a lambda expressions - * It does this by applying the well known rewrite rules for SKIBC combinators. - * - * These can be found: - * https://en.wikipedia.org/wiki/Combinatory_logic - */ +#if VHOL + class ApplicativeHelper { public: - struct HigherOrderTermInfo - { - public: - HigherOrderTermInfo(TermList h, TermList hs, unsigned an){ - head = h; - headSort = hs; - argNum = an; - } - - TermList head; - TermList headSort; - unsigned argNum; - }; - - ApplicativeHelper() {}; - - static TermList createAppTerm(TermList sort, TermList arg1, TermList arg2); - static TermList createAppTerm(TermList s1, TermList s2, TermList arg1, TermList arg2, bool shared = true); - static TermList createAppTerm3(TermList sort, TermList arg1, TermList arg2, TermList arg3); - static TermList createAppTerm(TermList sort, TermList arg1, TermList arg2, TermList arg3, TermList arg4); - static TermList createAppTerm(TermList sort, TermList head, TermStack& terms); - static TermList createAppTerm(TermList sort, TermList head, TermList* args, unsigned arity, bool shared = true); + static TermList app(TermList sort, TermList head, TermList arg); + static TermList app(TermList head, TermList arg); + static TermList app(TermList s1, TermList s2, TermList arg1, TermList arg2, bool shared = true); + static TermList app2(TermList sort, TermList head, TermList arg1, TermList arg2); + static TermList app2(TermList head, TermList arg1, TermList arg2); + static TermList app(TermList sort, TermList head, TermStack& terms); + static TermList app(TermList head, TermStack& terms); + + static TermList lambda(TermList varSort, TermList termSort, TermList term); + static TermList lambda(TermList varSort, TermList term); + + static TermList matrix(TermList t); + + static TermList getDeBruijnIndex(int index, TermList sort); + + static TermList placeholder(TermList sort); + static TermList getNthArg(TermList arrowSort, unsigned argNum); static TermList getResultApplieadToNArgs(TermList arrowSort, unsigned argNum); - static TermList getResultSort(TermList sort); static unsigned getArity(TermList sort); - static void getHeadAndAllArgs(TermList term, TermList& head, TermStack& args); + static void getHeadAndArgs(TermList term, TermList& head, TermStack& args); - static void getHeadAndArgs(Term* term, TermList& head, TermStack& args); - static void getHeadAndArgs(const Term* term, TermList& head, Deque& args); - static void getHeadSortAndArgs(TermList term, TermList& head, TermList& headSort, TermStack& args); - static bool isComb(const TermList t); - static Signature::Combinator getComb(const TermList t); - static Signature::Proxy getProxy(const TermList t); - static TermList getHead(TermList t); - static TermList getHead(Term* t); - static bool isUnderApplied(TermList head, unsigned argNum); - static bool isExactApplied(TermList head, unsigned argNum); - static bool isOverApplied(TermList head, unsigned argNum); - static bool isSafe(TermStack& args); - // TODO is this right? - static TermList replaceFunctionalAndBooleanSubterms(TermList t, FuncSubtermMap* fsm) - { return t.isVar() ? t : replaceFunctionalAndBooleanSubterms(t.term(), fsm); } - static Literal* replaceFunctionalAndBooleanSubterms(Literal* l, FuncSubtermMap* fsm) - { - auto res = replaceFunctionalAndBooleanSubterms((Term*)l, fsm); - ASS(res.isTerm()) - ASS(res.term()->isLiteral()) - return (Literal*) res.term(); - } - static TypedTermList replaceFunctionalAndBooleanSubterms(TypedTermList t, FuncSubtermMap* fsm) - { return TypedTermList(replaceFunctionalAndBooleanSubterms((TermList&)t, fsm), t.sort()); } - static TermList replaceFunctionalAndBooleanSubterms(Term* term, FuncSubtermMap* fsm); + static void getHeadAndArgs(Term* term, TermList& head, TermStack& args); + static void getHeadAndArgs(const Term* term, TermList& head, TermStack& args); + + + static void getHeadSortAndArgs(TermList term, TermList& head, TermList& headSort, TermStack& args); + static void getHeadArgsAndArgSorts(TermList t, TermList& head, TermStack& args, TermStack& argSorts); +// function below ONLY used in AppliArgsIT which is used in SKIKBO. Leaving for now in case need to +// revive +// static void getHeadAndAllArgs(TermList term, TermList& head, TermStack& args); + + static TermList lhsSort(TermList t); + static TermList rhsSort(TermList t); + + static void getMatrixAndPrefSorts(TermList t, TermList& matrix, TermStack& sorts); + static void getArgSorts(TermList t, TermStack& sorts); + static Signature::Proxy getProxy(const TermList& t); + + static void getAbstractionTerms(Literal* lit, TermStack& terms); + + // returns true if we can split (decompose) term + // during first-order unification without losing HOL + // unifiers. Return false otherwise + // Assumes that t is in head normal form + static bool splittable(TermList t, bool topLevel = false); static bool isBool(TermList t); static bool isTrue(TermList term); static bool isFalse(TermList term); + static bool canHeadReduce(const TermList& head, const TermStack& args); + static bool isEtaExpandedVar(TermList t, TermList& var); + + static void normaliseLambdaPrefixes(TermList& t1, TermList& t2); + + static bool getProjAndImitBindings(TermList flexTerm, TermList rigidTerm, TermStack& bindings, TermList& freshVar); + // creates a general binding of the form head (FV1 db1 ... dbn) (FV2 db1 ... dbn) ... + // if surround is set to true, the general binding is surround by n lambdas + static TermList createGeneralBinding(TermList& freshVar, TermList head, TermStack& sorts, bool surround = true); + + static TermList surroundWithLambdas(TermList t, TermStack& sorts, bool fromTop = false); + static TermList surroundWithLambdas(TermList t, TermStack& sorts, TermList sort, bool fromTop = false); + static TermList top(); + static TermList bottom(); + static TermList conj(); + static TermList disj(); + static TermList imp(); + static TermList neg(); + static TermList equality(TermList sort); + static TermList pi(TermList sort); + static TermList sigma(TermList sort); +}; + +// reduce a term to normal form +// uses a applicative order reduction strategy +// Currently use a leftmost outermost stratgey +// An innermost strategy is theoretically more efficient +// but is difficult to write iteratively TODO +class BetaNormaliser : public TermTransformer +{ +public: + + BetaNormaliser() { + dontTransformSorts(); + } + TermList normalise(TermList t); + // puts term into weak head normal form + TermList transformSubterm(TermList t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; +}; + +// reduce to eta short form +// normalises top down carrying out parallel eta reductions +// for terms such as ^^^.f 2 1 0 +// WARNING Recursing lurks here (even during proof search!) +// This is BAD! However, an (efficient) iterative implementation is tricky, so +// I am leaving for now. +class EtaNormaliser +{ +public: + + TermList normalise(TermList t); + TermList transformSubterm(TermList t); +}; + +// similar to BetaNormaliser, but places a term in WHNF instead +// of into full normal form +class WHNFDeref : public TermTransformer +{ +public: + + WHNFDeref( RobSubstitutionTL* sub) : _sub(sub) { + dontTransformSorts(); + } + TermList normalise(TermList t); + // puts term into weak head normal form + TermList transformSubterm(TermList t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; private: + RobSubstitutionTL* _sub; +}; + - static TermList getVSpecVar(Term* funcTerm, FuncSubtermMap* fsm) - { - unsigned vNum; - if(fsm->find(funcTerm, vNum)){ - ASS(vNum > TermList::SPEC_UPPER_BOUND); - return TermList(vNum, true); - } else { - unsigned vNum = TermList::SPEC_UPPER_BOUND + fsm->size() + 1; - fsm->insert(vNum, funcTerm); - return TermList(vNum, true); - } +class RedexReducer : public TermTransformer +{ +public: + typedef ApplicativeHelper AH; + RedexReducer() { + dontTransformSorts(); + } + TermList reduce(TermList head, TermStack& args); + TermList transformSubterm(TermList t) override; + void onTermEntry(Term* t) override; + void onTermExit(Term* t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; + +private: + TermList _t2; // term to replace index with (^x.t1) t2 + unsigned _replace; // index to replace +}; + +class TermShifter : public TermTransformer +{ +public: + TermShifter() : _minFreeIndex(-1) { + dontTransformSorts(); + } + // positive value -> shift up + // negative -> shift down + // 0 record minimum free index + TermList shift(TermList term, int shiftBy); + TermList transformSubterm(TermList t) override; + void onTermEntry(Term* t) override; + void onTermExit(Term* t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; + + Option minFreeIndex(){ + return _minFreeIndex > -1 ? Option((unsigned)_minFreeIndex) : Option(); } - + +private: + unsigned _cutOff; // any index higher than _cutOff is a free index + int _shiftBy; // the amount to shift a free index by + int _minFreeIndex; +}; + +class SortDeref : public TermTransformer +{ +public: + SortDeref(RobSubstitutionTL* sub) : _sub(sub) {} + + TermList deref(TermList term); + TermList transformSubterm(TermList t) override; + void onTermEntry(Term* t) override; + void onTermExit(Term* t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; + +private: + RobSubstitutionTL* _sub; + Stack _typeArities; + Stack _positions; }; + +// replaces higher-order subterms (subterms with variable heads e.g., X a b & +// lambda terms) with a special polymorphic constant we call a "placeholder". +// Depending on the mode functional and Boolean subterms may also be replaced +class ToPlaceholders : public TermTransformer +{ +public: + ToPlaceholders() : + _nextIsPrefix(false), + _topLevel(true), + _mode(env.options->functionExtensionality()) { + dontTransformSorts(); + } + + TermList replace(TermList term); + TermList transformSubterm(TermList t) override; + void onTermEntry(Term* t) override; + void onTermExit(Term* t) override; + +private: + bool _nextIsPrefix; + bool _topLevel; + Shell::Options::FunctionExtensionality _mode; +}; + + +#endif + #endif // __ApplicativeHelper__ diff --git a/Kernel/BestLiteralSelector.hpp b/Kernel/BestLiteralSelector.hpp index 92dbcdfe74..b4d981b6ba 100644 --- a/Kernel/BestLiteralSelector.hpp +++ b/Kernel/BestLiteralSelector.hpp @@ -137,38 +137,39 @@ class CompleteBestLiteralSelector CALL("CompleteBestLiteralSelector::doSelection"); ASS_G(eligible, 1); //trivial cases should be taken care of by the base LiteralSelector - static bool combSup = env.options->combinatorySup(); +// static bool combSup = env.options->combinatorySup(); static DArray litArr(64); - static Set maxTermHeads; - maxTermHeads.reset(); +// TODO AYB decide what to do with selection +// static Set maxTermHeads; +// maxTermHeads.reset(); litArr.initFromArray(eligible,*c); litArr.sortInversed(_comp); LiteralList* maximals=0; Literal* singleSelected=0; //If equals to 0 in the end, all maximal - if(combSup){ +/* if(combSup){ fillMaximals(maximals, litArr); LiteralList::Iterator maxIt(maximals); while(maxIt.hasNext()){ Literal* lit = maxIt.next(); - TermList t0 = *lit->nthArgument(0); - TermList t1 = *lit->nthArgument(1); - TermList h0 = ApplicativeHelper::getHead(t0); - TermList h1 = ApplicativeHelper::getHead(t1); - if(h0.isVar()){ maxTermHeads.insert(h0.var()); } - if(h1.isVar()){ maxTermHeads.insert(h1.var()); } + for(unsigned i = 0; i < lit->arity(); i ++){ + TermList t = *lit->nthArgument(i); + TermList h = ApplicativeHelper::getHead(t); + if(h.isVar()){ maxTermHeads.insert(h.var()); } + } } - } + } */ //literals will be selected. bool allSelected=false; - if(isNegativeForSelection(litArr[0]) && - (!combSup || canBeSelected(litArr[0], &maxTermHeads))) { + if(isNegativeForSelection(litArr[0]) /*&& + (!combSup || canBeSelected(litArr[0], &maxTermHeads))*/) { singleSelected=litArr[0]; } else { - if(!combSup){ fillMaximals(maximals, litArr); } + //if(!combSup){ fillMaximals(maximals, litArr); } + fillMaximals(maximals, litArr); unsigned besti=0; LiteralList* nextMax=maximals; while(true) { @@ -180,8 +181,8 @@ class CompleteBestLiteralSelector } besti++; ASS_L(besti,eligible); - if(isNegativeForSelection(litArr[besti]) && - (!combSup || canBeSelected(litArr[besti], &maxTermHeads))){ + if(isNegativeForSelection(litArr[besti]) /*&& + (!combSup || canBeSelected(litArr[besti], &maxTermHeads))*/){ singleSelected=litArr[besti]; break; } @@ -257,7 +258,7 @@ class CompleteBestLiteralSelector _ord.removeNonMaximal(maximals); } - bool canBeSelected(Literal* lit, Set* maxTermHeads) + /*bool canBeSelected(Literal* lit, Set* maxTermHeads) { CALL("CompleteBestLiteralSelector::canBeSelected"); @@ -275,7 +276,7 @@ class CompleteBestLiteralSelector // } // } return true; - } + }*/ private: QComparator _comp; diff --git a/Kernel/BottomUpEvaluation.hpp b/Kernel/BottomUpEvaluation.hpp index 7ea9e06bab..1f1c2deced 100644 --- a/Kernel/BottomUpEvaluation.hpp +++ b/Kernel/BottomUpEvaluation.hpp @@ -37,7 +37,7 @@ namespace Memo { template struct None { - Option get(Arg) + Option get(Arg const&) { return Option(); } template Result getOrInit(Arg const& orig, Init init) @@ -133,7 +133,6 @@ typename EvalFn::Result evaluateBottomUp(typename EvalFn::Arg const& term, EvalF recState->push(BottomUpChildIter(term)); while (!recState->isEmpty()) { - if (recState->top().hasNext()) { Arg t = recState->top().next(); @@ -158,7 +157,6 @@ typename EvalFn::Result evaluateBottomUp(typename EvalFn::Arg const& term, EvalF }); DEBUG("evaluated: ", orig.self(), " -> ", eval); - recResults->pop(orig.nChildren()); recResults->push(std::move(eval)); } @@ -182,6 +180,19 @@ typename EvalFn::Result evaluateBottomUp(typename EvalFn::Arg const& term, EvalF } +template +R evalBottomUp(A const& term, F fun) +{ + struct Eval { + using Result = R; + using Arg = A; + F& fun; + Result operator()(Arg const& a, Result* rs) + { return fun(a,rs); } + }; + return evaluateBottomUp(term, Eval{fun}); +} + } // namespace Lib diff --git a/Kernel/Clause.cpp b/Kernel/Clause.cpp index d520fce594..423b286bc3 100644 --- a/Kernel/Clause.cpp +++ b/Kernel/Clause.cpp @@ -189,6 +189,11 @@ void Clause::destroyIfUnnecessary() } } +bool Clause::isEmpty() const +{ + return _length == 0; +} + /** * Destroy the clause by deleting the clause itself and all of its * literals. @@ -334,6 +339,11 @@ vstring Clause::literalsOnlyToString() const CALL("Clause::literalsOnlyToString"); if (_length == 0) { +#if VHOL + if(env.options->holPrinting() == Options::HPrinting::PRETTY){ + return "⊥"; + } +#endif return "$false"; } else { vstring result; @@ -640,13 +650,6 @@ unsigned Clause::computeWeightForClauseSelection(unsigned w, unsigned splitWeigh return w * ( !derivedFromGoal ? nongoalWeightCoeffNum : nongoalWeightCoefDenom); } - -void Clause::collectUnstableVars(DHSet& acc) -{ - CALL("Clause::collectUnstableVars"); - collectVars2(acc); -} - void Clause::collectVars(DHSet& acc) { CALL("Clause::collectVars"); diff --git a/Kernel/Clause.hpp b/Kernel/Clause.hpp index 77eeeb1e55..4dd07d650a 100644 --- a/Kernel/Clause.hpp +++ b/Kernel/Clause.hpp @@ -122,7 +122,7 @@ class Clause Literal** literals() { return _literals; } /** True if the clause is empty */ - bool isEmpty() const { return _length == 0; } + bool isEmpty() const; void destroy(); void destroyExceptInferenceObject(); @@ -349,8 +349,6 @@ class Clause unsigned getNumeralWeight() const; void collectVars(DHSet& acc); - void collectUnstableVars(DHSet& acc); - unsigned varCnt(); unsigned maxVar(); // useful to create fresh variables w.r.t. the clause diff --git a/Kernel/ColorHelper.cpp b/Kernel/ColorHelper.cpp index fc5b5bc31c..9c025abcbe 100644 --- a/Kernel/ColorHelper.cpp +++ b/Kernel/ColorHelper.cpp @@ -20,7 +20,7 @@ #include "Shell/Options.hpp" #include "Clause.hpp" -#include "EqHelper.hpp" +#include "TermTransformer.hpp" #include "Inference.hpp" #include "Renaming.hpp" #include "Signature.hpp" @@ -117,7 +117,7 @@ Clause* ColorHelper::skolemizeColoredConstants(Clause* c) TermList newTrm = TermList(Term::create(newFn, 0, 0)); for (unsigned i=0; ifunctor())) { //here we each time remove at least one colored symbol Term* newTrm = applyReplacement(t,replMap); - lit = EqHelper::replace(lit,TermList(t),TermList(newTrm)); + lit = SubtermReplacer(TermList(t),TermList(newTrm)).transform(lit); goto start_replacing; } } diff --git a/Kernel/EqHelper.cpp b/Kernel/EqHelper.cpp index 0889997a4e..aa90037f73 100644 --- a/Kernel/EqHelper.cpp +++ b/Kernel/EqHelper.cpp @@ -67,114 +67,14 @@ bool EqHelper::hasGreaterEqualitySide(Literal* eq, const Ordering& ord, TermList ASSERTION_VIOLATION; } -Literal* EqHelper::replace(Literal* lit, TermList what, TermList by) -{ - CALL("EqHelper::replace(Literal*,...)"); - - return static_cast(replace(static_cast(lit), what, by)); -} - -/** - * Replace all occurences of the subterm @b tSrc by @b tDest in the term/literal - * @b lit, and return the result - * - * Cannot be used to replace a sort - */ -Term* EqHelper::replace(Term* trm0, TermList tSrc, TermList tDest) -{ - CALL("EqHelper::replace(Term*,...)"); - ASS(trm0->shared()); - ASS(!trm0->isSort()); - ASS(tSrc.isVar() || !tSrc.term()->isSort()); - ASS(tDest.isVar() || !tDest.term()->isSort()); - - - static Stack toDo(8); - static Stack terms(8); - static Stack modified(8); - static Stack args(8); - ASS(toDo.isEmpty()); - ASS(terms.isEmpty()); - modified.reset(); - args.reset(); - - modified.push(false); - toDo.push(trm0->args()); - - for (;;) { - TermList* tt=toDo.pop(); - if (tt->isEmpty()) { - if (terms.isEmpty()) { - //we're done, args stack contains modified arguments - //of the literal. - ASS(toDo.isEmpty()); - break; - } - Term* orig=terms.pop(); - if (!modified.pop()) { - args.truncate(args.length() - orig->arity()); - args.push(TermList(orig)); - continue; - } - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - TermList* argLst=&args.top() - (orig->arity()-1); - args.truncate(args.length() - orig->arity()); - - args.push(TermList(Term::create(orig,argLst))); - modified.setTop(true); - continue; - } - toDo.push(tt->next()); - - TermList tl=*tt; - if (tl == tSrc) { - args.push(tDest); - modified.setTop(true); - continue; - } - if (tl.isVar() || tl.term()->isSort()) { - args.push(tl); - continue; - } - ASS(tl.isTerm()); - Term* t=tl.term(); - terms.push(t); - modified.push(false); - toDo.push(t->args()); - } - ASS(toDo.isEmpty()); - ASS(terms.isEmpty()); - ASS_EQ(modified.length(),1); - ASS_EQ(args.length(),trm0->arity()); - - if (!modified.pop()) { - // we call replace in superposition only if we already know, - // there is something to be replaced. - // ASSERTION_VIOLATION; // MS: but there is now a new use in InnerRewriting which does not like this extra check - return trm0; - } - - // here we assume, that stack is an array with - // second topmost element as &top()-1, third at - // &top()-2, etc... - TermList* argLst=&args.top() - (trm0->arity()-1); - if (trm0->isLiteral()) { - Literal* lit = static_cast(trm0); - ASS_EQ(args.size(), lit->arity()); - return Literal::create(lit,argLst); - } - return Term::create(trm0,argLst); -} - - VirtualIterator EqHelper::getSubtermIterator(Literal* lit, const Ordering& ord) { CALL("EqHelper::getSubtermIterator"); return getRewritableSubtermIterator(lit, ord); } +#if VHOL + TermIterator EqHelper::getBooleanSubtermIterator(Literal* lit, const Ordering& ord) { CALL("EqHelper::getSubtermIterator"); @@ -187,47 +87,7 @@ VirtualIterator EqHelper::getFoSubtermIterator(Literal* lit, const Orderi return getRewritableSubtermIterator(lit, ord); } -TermIterator EqHelper::getNarrowableSubtermIterator(Literal* lit, const Ordering& ord) -{ - CALL("EqHelper::getNarrowableSubtermIterator"); - return getRewritableSubtermIterator(lit, ord); -} - -/* - * Function is used in the higher-order inference SubVarSup - */ -TermIterator EqHelper::getRewritableVarsIterator(DHSet* unstableVars, Literal* lit, const Ordering& ord) -{ - CALL("EqHelper::getNarrowableSubtermIterator"); - - ASS(lit->isEquality()); - - TermList sel; - switch(ord.getEqualityArgumentOrder(lit)) { - case Ordering::INCOMPARABLE: { - RewritableVarsIt si(unstableVars, lit); - return getUniquePersistentIteratorFromPtr(&si); - } - case Ordering::EQUAL: - case Ordering::GREATER: - case Ordering::GREATER_EQ: - sel=*lit->nthArgument(0); - break; - case Ordering::LESS: - case Ordering::LESS_EQ: - sel=*lit->nthArgument(1); - break; -#if VDEBUG - default: - ASSERTION_VIOLATION; #endif - } - if (!sel.isTerm()) { - return TermIterator::getEmpty(); - } - return getUniquePersistentIterator(vi(new RewritableVarsIt(unstableVars, sel.term(), true))); -} - /** * Return iterator on subterms of a literal, that can be rewritten by @@ -335,62 +195,6 @@ TermIterator EqHelper::getSuperpositionLHSIterator(Literal* lit, const Ordering& } } - -TermIterator EqHelper::getSubVarSupLHSIterator(Literal* lit, const Ordering& ord) -{ - CALL("EqHelper::getSubVarSupLHSIterator"); - - ASS(lit->isEquality()); - - TermList eqSort = SortHelper::getEqualityArgumentSort(lit); - - if (eqSort.isVar() || eqSort.isArrowSort()) { - if (lit->isNegative()) { - return TermIterator::getEmpty(); - } - - TermList t0=*lit->nthArgument(0); - TermList t1=*lit->nthArgument(1); - TermList t0Head = ApplicativeHelper::getHead(t0); - TermList t1Head = ApplicativeHelper::getHead(t1); - bool t0hisVarOrComb = ApplicativeHelper::isComb(t0Head) || t0Head.isVar(); - bool t1hisVarOrComb = ApplicativeHelper::isComb(t1Head) || t1Head.isVar(); - - switch(ord.getEqualityArgumentOrder(lit)) - { - case Ordering::INCOMPARABLE: - if(t0hisVarOrComb && t1hisVarOrComb){ - return pvi( getConcatenatedIterator(getSingletonIterator(t0), - getSingletonIterator(t1)) ); - } else if( t0hisVarOrComb ){ - return pvi( getSingletonIterator(t1) ); - } else if( t1hisVarOrComb ) { - return pvi( getSingletonIterator(t0) ); - } - break; - case Ordering::GREATER: - case Ordering::GREATER_EQ: - if(t1hisVarOrComb){ - return pvi( getSingletonIterator(t0) ); - } - break; - case Ordering::LESS: - case Ordering::LESS_EQ: - if(t0hisVarOrComb){ - return pvi( getSingletonIterator(t1) ); - } - break; - case Ordering::EQUAL: - //there should be no equality literals of equal terms - default: - ASSERTION_VIOLATION; - } - return TermIterator::getEmpty(); - } else { - return TermIterator::getEmpty(); - } -} - /** * Return iterator on sides of the equality @b lit that can be used as an LHS * for demodulation diff --git a/Kernel/EqHelper.hpp b/Kernel/EqHelper.hpp index a8136bae34..cf56df0112 100644 --- a/Kernel/EqHelper.hpp +++ b/Kernel/EqHelper.hpp @@ -36,20 +36,15 @@ class EqHelper static TermList getOtherEqualitySide(Literal* eq, TermList lhs); static bool hasGreaterEqualitySide(Literal* eq, const Ordering& ord, TermList& lhs, TermList& rhs); static VirtualIterator getSubtermIterator(Literal* lit, const Ordering& ord); +#if VHOL static VirtualIterator getFoSubtermIterator(Literal* lit, const Ordering& ord); static TermIterator getBooleanSubtermIterator(Literal* lit, const Ordering& ord); - static TermIterator getNarrowableSubtermIterator(Literal* lit, const Ordering& ord); - static TermIterator getRewritableVarsIterator(DHSet* unstableVars, Literal* lit, const Ordering& ord); +#endif static TermIterator getLHSIterator(Literal* lit, const Ordering& ord); static TermIterator getSuperpositionLHSIterator(Literal* lit, const Ordering& ord, const Options& opt); - static TermIterator getSubVarSupLHSIterator(Literal* lit, const Ordering& ord); static TermIterator getDemodulationLHSIterator(Literal* lit, bool forward, const Ordering& ord, const Options& opt); static TermIterator getEqualityArgumentIterator(Literal* lit); - //WARNING, this function cannot be used when @param t is a sort. - static Term* replace(Term* t, TermList what, TermList by); - static Literal* replace(Literal* lit, TermList what, TermList by); - struct LHSIteratorFn { LHSIteratorFn(const Ordering& ord) : _ord(ord) {} @@ -75,19 +70,6 @@ class EqHelper const Options& _opt; }; - struct SubVarSupLHSIteratorFn - { - SubVarSupLHSIteratorFn(const Ordering& ord) : _ord(ord) {} - - VirtualIterator > operator()(Literal* lit) - { - return pvi( pushPairIntoRightIterator(lit, getSubVarSupLHSIterator(lit, _ord)) ); - } - private: - const Ordering& _ord; - }; - - struct EqualityArgumentIteratorFn { VirtualIterator > operator()(Literal* lit) diff --git a/Kernel/Formula.cpp b/Kernel/Formula.cpp index 4a8e7382ad..d15db7646d 100644 --- a/Kernel/Formula.cpp +++ b/Kernel/Formula.cpp @@ -81,11 +81,7 @@ void Formula::destroy () */ vstring Formula::toString (Connective c) { - static vstring names [] = - { "", "&", "|", "=>", "<=>", "<~>", "~", "!", "?", "$var", "$false", "$true","",""}; - ASS_EQ(sizeof(names)/sizeof(vstring), NOCONN+1); - - return names[(int)c]; + return names()[(int)c]; } // Formula::toString (Connective c) /** @@ -189,6 +185,7 @@ vstring Formula::toString () const SList::Iterator ss(f->sorts()); bool hasSorts = f->sorts(); bool first=true; + bool printDefs = env.options->printDefaultSorts(); while (vs.hasNext()) { int var = vs.next(); if (!first) { @@ -199,10 +196,10 @@ vstring Formula::toString () const if (hasSorts) { ASS(ss.hasNext()); t = ss.next(); - if (t != AtomicSort::defaultSort()) { + if (t != AtomicSort::defaultSort() || printDefs) { res += " : " + t.toString(); } - } else if (SortHelper::tryGetVariableSort(var, const_cast(f),t) && t != AtomicSort::defaultSort()) { + } else if (SortHelper::tryGetVariableSort(var, const_cast(f),t) && (t != AtomicSort::defaultSort() || printDefs)) { res += " : " + t.toString(); } first = false; @@ -217,6 +214,11 @@ vstring Formula::toString () const case BOOL_TERM: { vstring term = f->getBooleanTerm().toString(); +#if VHOL + if(env.property->higherOrder() && f->getBooleanTerm().isApplication()){ + term = "(" + term + ")"; + } +#endif res += env.options->showFOOL() ? "$formula{" + term + "}" : term; continue; diff --git a/Kernel/Formula.hpp b/Kernel/Formula.hpp index 690b3ac995..04568cce03 100644 --- a/Kernel/Formula.hpp +++ b/Kernel/Formula.hpp @@ -36,6 +36,21 @@ using namespace Lib; class Formula { +private: + + static vstring* names(){ + CALL("Formula::names"); +#if VHOL + if(env.options->holPrinting() == Shell::Options::HPrinting::PRETTY){ + static vstring names [] = { "", "∧", "∨", "⇒", "⇔", "⊕", "¬", "∀", "∃", "$var", "⊥", "⊤","",""}; + return names; + } +#endif + + static vstring names [] = { "", "&", "|", "=>", "<=>", "<~>", "~", "!", "?", "$var", "$false", "$true","",""}; + return names; + } + public: /** * Constructor of constant formulas (true/false) diff --git a/Kernel/FormulaTransformer.cpp b/Kernel/FormulaTransformer.cpp index a94e3e42e6..4503796fa3 100644 --- a/Kernel/FormulaTransformer.cpp +++ b/Kernel/FormulaTransformer.cpp @@ -21,6 +21,7 @@ #include "Problem.hpp" #include "SortHelper.hpp" #include "TermTransformer.hpp" +#include "Lib/DHMap.hpp" #include "FormulaTransformer.hpp" diff --git a/Kernel/FormulaTransformer.hpp b/Kernel/FormulaTransformer.hpp index b1516917ac..de64c4b561 100644 --- a/Kernel/FormulaTransformer.hpp +++ b/Kernel/FormulaTransformer.hpp @@ -20,6 +20,7 @@ #include "Inference.hpp" #include "TermTransformer.hpp" #include "Lib/Recycled.hpp" +#include "Lib/DHMap.hpp" namespace Kernel { diff --git a/Kernel/FormulaVarIterator.cpp b/Kernel/FormulaVarIterator.cpp index 1d518d250d..ed46d1fda8 100644 --- a/Kernel/FormulaVarIterator.cpp +++ b/Kernel/FormulaVarIterator.cpp @@ -199,7 +199,7 @@ bool FormulaVarIterator::hasNext() } break; } - +#if VHOL case Term::SF_LAMBDA:{ _instructions.push(FVI_UNBIND); SList* sorts = sd->getLambdaVarSorts(); @@ -216,7 +216,7 @@ bool FormulaVarIterator::hasNext() _vars.push(sd->getLambdaVars()); break; } - +#endif case Term::SF_MATCH: { for (unsigned int i = 0; i < t->arity(); i++) { _instructions.push(FVI_TERM_LIST); diff --git a/Kernel/HOLMatching.cpp b/Kernel/HOLMatching.cpp new file mode 100644 index 0000000000..bb7261ea01 --- /dev/null +++ b/Kernel/HOLMatching.cpp @@ -0,0 +1,46 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file RobSubstitution.hpp + * Defines class RobSubstitution. + * + */ + +#if VHOL + +#include "Kernel/HOLMatching.hpp" +#include "Kernel/ApplicativeHelper.hpp" + +namespace Kernel +{ + +namespace UnificationAlgorithms { + +bool HOLInstantiation::associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub) +{ + CALL("HOLInstantiation::associate"); + + TermList query(specialVar, /* special */ true); + return match(query, node, sub, VarBank::QUERY_BANK); +} + +bool HOLGeneralisation::associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub) +{ + CALL("HOLGeneralisation::associate"); + + TermList query(specialVar, /* special */ true); + return HOLInstantiation::match(node, query, sub, VarBank::NORM_RESULT_BANK); +} + +} + +} + +#endif \ No newline at end of file diff --git a/Kernel/HOLMatching.hpp b/Kernel/HOLMatching.hpp new file mode 100644 index 0000000000..dee3b40128 --- /dev/null +++ b/Kernel/HOLMatching.hpp @@ -0,0 +1,78 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file RobSubstitution.hpp + * Defines class RobSubstitution. + * + */ + +#ifndef __HOLMatching__ +#define __HOLMatching__ + +#if VHOL + +#include "Forwards.hpp" + +#include "Term.hpp" + +#include "Kernel/RobSubstitution.hpp" + + +namespace Kernel +{ + +using namespace Indexing; + +namespace UnificationAlgorithms { + + +/** At the moment, the classes below don't contain much + * logic and could easily be moved in HOLUnification. + * However, I am keeping them as separate classes in case + * I ever add pattern matching in the future which will probably require + * big changes */ +class HOLInstantiation { +public: + + using Constraint = UnificationConstraint; + + static bool match(TermList base, TermList instance, RobSubstitutionTL* sub, VarBank baseBank) + { return sub->match(base, instance, baseBank); } + + void initSub(RobSubstitutionTL* sub) const { sub->setOutputIndex(VarBank::RESULT_BANK); } + + bool associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub); + + SubstIterator postprocess(RobSubstitutionTL* sub, TermList t, TermList sort) + { return pvi(getSingletonIterator(sub)); } + + bool usesUwa() const { return false; } +}; + +class HOLGeneralisation { +public: + + void initSub(RobSubstitutionTL* sub) const { sub->setOutputIndex(VarBank::QUERY_BANK); } + + bool associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub); + + SubstIterator postprocess(RobSubstitutionTL* sub, TermList t, TermList sort) + { return pvi(getSingletonIterator(sub)); } + + bool usesUwa() const { return false; } +}; + +} + +} + +#endif + +#endif diff --git a/Kernel/HOLUnification.cpp b/Kernel/HOLUnification.cpp new file mode 100644 index 0000000000..206748fe17 --- /dev/null +++ b/Kernel/HOLUnification.cpp @@ -0,0 +1,663 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file RobSubstitution.hpp + * Defines class RobSubstitution. + * + */ + +#if VHOL + +#include "Kernel/HOLUnification.hpp" +#include "Kernel/ApplicativeHelper.hpp" + +#include "Indexing/TermSharing.hpp" + +#include "Lib/SkipList.hpp" + +namespace Kernel +{ + +namespace UnificationAlgorithms { + +#define DEBUG_ITERATOR(LVL, ...) if (LVL <= 0) DBG(__VA_ARGS__) +class HOLUnification::HigherOrderUnifiersIt: public IteratorCore { +public: + + using AH = ApplicativeHelper; + + TermList applyTypeSub(TermList t){ + CALL("HOLUnification::HigherOrderUnifiersIt::applyTypeSub"); + + // in the monomorphic case, should be cheap + return SortDeref(_subst).deref(t); + } + + HigherOrderUnifiersIt(TermList t1, TermList t2, RobSubstitutionTL* subst, bool funcExt) : + _used(false), _solved(false), _topLevel(true), _funcExt(funcExt), _depth(0), + _unifiersReturned(0), _freshVar(0, VarBank::FRESH_BANK), _subst(subst){ + CALL("HOLUnification::HigherOrderUnifiersIt::HigherOrderUnifiersIt"); + + BacktrackData bd; + _bdStack->push(bd); + _bindings->push(TermStack()); + + if(!trySolveTrivialPair(t1,t2)){ + _unifPairs.insert(HOLConstraint(applyTypeSub(t1),applyTypeSub(t2))); + } + + DEBUG_ITERATOR(1, "starting iterator with\n ", *this) + } + + ~HigherOrderUnifiersIt() { + CALL("HOLUnification::HigherOrderUnifiersIt::~HigherOrderUnifiersIt"); + + } + + friend std::ostream& operator<<(std::ostream& out, HigherOrderUnifiersIt const& self) + { return out << "Backtrack depth " << self._bdStack->size() << "\nBindings " << + *self._bindings << "\nCurr subst " << *self._subst << "\nUnif pairs " << self._unifPairs; } + + bool solved() { + CALL("HOLUnification::HigherOrderUnifiersIt::solved"); + + SkipList::RefIterator it(_unifPairs); + return !it.hasNext() || it.next().flexFlex(); + } + + bool trySolveTrivialPair(TermList t1, TermList t2){ + CALL("HOLUnification::HigherOrderUnifiersIt::trySolveTrivialPair"); + + if(t1.isVar() && t2.isVar()){ + if(t1 == t2) return true; + _subst->bdRecord(_bdStack->top()); + _subst->bind(t1, t2); + _subst->bdDone(); + applyBindingToPairs(); + return true; + } + return false; + } + + bool backtrack() { + CALL("HOLUnification::HigherOrderUnifiersIt::backtrack"); + + bool success = false; + while(!_bdStack->isEmpty() && !success){ + _depth--; + _bdStack->pop().backtrack(); + // if there are alterntative bindings available stop bracktracking + success = !_bindings->top().isEmpty(); + } + return success; + } + + void applyBindingToPairs(bool sort = false){ + CALL("HOLUnification::HigherOrderUnifiersIt::applyBindingToPairs"); + + Stack temp; + while(!_unifPairs.isEmpty()){ + HOLConstraint pair = popFromUnifPairs(_bdStack->top()); + TermList lhs = pair.lhs(); + TermList rhs = pair.rhs(); + if(sort){ + temp.push(HOLConstraint(SortDeref(_subst).deref(lhs), SortDeref(_subst).deref(rhs))); + } else { + temp.push(HOLConstraint(lhs.whnfDeref(_subst), rhs.whnfDeref(_subst))); + } + } + + while(!temp.isEmpty()){ + addToUnifPairs(temp.pop(), _bdStack->top()); + } + } + + bool hasNext() { + CALL("HOLUnification::HigherOrderUnifiersIt::hasNext"); + + static unsigned maxUnifiers = env.options->takeNUnifiersOnly(); + static unsigned depth = env.options->higherOrderUnifDepth(); + + if(_subst->bdIsRecording()) + _subst->bdDone(); + + if(maxUnifiers && _unifiersReturned == maxUnifiers){ + return false; + } + + if((_solved || solved()) && !_used) // the solved() check ensures that when we start with a flex-flex we return true straight away + { return true; } + + _used = false; + + DEBUG_ITERATOR(1, "has next called with\n ", *this) + + // the logic here is really convoluted and should be cleaned up + // the main complexity is due to the depth limit + // Once the limit is reached, we continue popping constraints until + // we reach a flexRigid pair and then stop and return + // The next time we call hasNext, the system will be in a solved state + // if next() has been called in between, since next clears all unif + // pairs. Hence a backtrack will take place + + bool forward = !solved() || backtrack(); + while(forward && !solved()){ + if(_unifPairs.top().flexRigid() && _depth == depth) + { + // if we are in pragmatic mode, when we hit the depth we backtrack + // In standard mode we return a unifier with constraints + if(env.options->pragmatic() && depth){ + forward = backtrack(); + continue; + } else { + break; + } + } + + auto con = popFromUnifPairs(_bdStack->top()); + + DEBUG_ITERATOR(2, "Next pair\n ", con) + + TermList lhs = con.lhs(); + TermList rhs = con.rhs(); + TermList lhsHead = con.lhsHead(); + TermList rhsHead = con.rhsHead(); + + ASS(!lhsHead.isVar() || !rhsHead.isVar()); // otherwise we would be solved + ASS(lhs.isVar() || rhs.isVar() || SortHelper::getResultSort(lhs.term()) == SortHelper::getResultSort(rhs.term())); + + AH::normaliseLambdaPrefixes(lhs,rhs); + + // normalising can change the head of a term if it is a De Bruijn index + // TODO only recompute head if it has changed above... + lhsHead = lhs.head(); + rhsHead = rhs.head(); + + if(lhs == rhs){ continue; } + + if(con.rigidRigid()){ + TermList s = con.sort(); + if(_funcExt && _depth == 0 && (s.isArrowSort() || s.isVar() || (s.isBoolSort() && !_topLevel))){ + addToUnifPairs(con, _bdStack->top()); + break; + } + } + + if(con.rigidRigid() && lhsHead.term()->functor() == rhsHead.term()->functor()){ + // unify type + bool success = true; + bool workDone = false; + for(unsigned j = 0; j < lhsHead.term()->arity(); j++){ + if(lhsHead.nthArg(j) != rhsHead.nthArg(j)){ + workDone = true; + BacktrackData tempBD; + _subst->bdRecord(tempBD); + success = _subst->unify(lhsHead.nthArg(j), rhsHead.nthArg(j)); + _subst->bdDone(); + if(!success){ + tempBD.backtrack(); + forward = backtrack(); + break; + } else { + tempBD.commitTo(_bdStack->top()); + tempBD.drop(); + } + } + } + + if(!success){ + continue; + } + + if(workDone){ + // we never reach here in the monomorphic case as workDone should always be false + applyBindingToPairs(true); + } + + lhs = applyTypeSub(lhs); + rhs = applyTypeSub(rhs); + + TermStack lhsArgs; + TermStack argSorts; + TermStack rhsArgs; + TermStack sorts; + TermList matrix; + AH::getMatrixAndPrefSorts(lhs, matrix, sorts); + AH::getHeadArgsAndArgSorts(matrix, lhsHead, lhsArgs, argSorts); + AH::getHeadAndArgs(rhs, rhsHead, rhsArgs); + ASS(lhsArgs.size() == rhsArgs.size()); // size must be same due to normalisation of prefixes above + + for(unsigned i = 0; i < lhsArgs.size(); i++){ + auto t1 = lhsArgs[i].whnfDeref(_subst); + t1 = AH::surroundWithLambdas(t1, sorts, argSorts[i], /* traverse stack from top */ true); + auto t2 = rhsArgs[i].whnfDeref(_subst); + t2 = AH::surroundWithLambdas(t2, sorts, argSorts[i], true); + + if(!trySolveTrivialPair(t1,t2)){ + addToUnifPairs(HOLConstraint(t1,t2), _bdStack->top()); + } + } + + } else if(con.flexRigid()){ + TermList flexTerm = lhsHead.isVar() ? lhs : rhs; + TermList rigidTerm = lhsHead.isVar() ? rhs : lhs; + TermList flexHead = lhsHead.isVar() ? lhsHead : rhsHead; + + if(_bdStack->size() == _bindings->size()){ + // reached here not via a backtrack. Need to add new bindings to bindings + + // oracle calls. no point calling oracles if we reach here via a backtrack + // they must have already failed + BacktrackData tempBD; + _subst->bdRecord(tempBD); + auto res = HOLUnification::fixpointUnify(flexTerm, rigidTerm, _subst); + _subst->bdDone(); + + if(res == OracleResult::OUT_OF_FRAGMENT){ + tempBD.backtrack(); // don't think we need this, as we won't have bound anyhting... + // TODO pattern oracle + // TODO solid oracle? + } else if (res == OracleResult::SUCCESS){ + tempBD.commitTo(_bdStack->top()); + tempBD.drop(); + applyBindingToPairs(); + continue; // TODO apply new binding to pairs...??? + } else { + forward = backtrack(); + continue; + } + + TermStack projAndImitBindings; + BacktrackData& bd = _bdStack->top(); + bd.addClosure([this, fv = _freshVar](){ _freshVar = fv; }); + + AH::getProjAndImitBindings(flexTerm, rigidTerm, projAndImitBindings, _freshVar); + + if(projAndImitBindings.isEmpty()){ + // no bindings for this pair of terms + forward = backtrack(); + continue; + } + + backtrackablePush(*_bindings,projAndImitBindings,bd); + } + + _depth++; + addToUnifPairs(con, _bdStack->top()); // add back to pairs with old data + BacktrackData bd; + _bdStack->push(bd); // reached a branch point + + ASS(_bindings->top().size()); + TermList binding = _bindings->top().pop(); + + _subst->bdRecord(_bdStack->top()); + _subst->bind(flexHead, binding); + _subst->bdDone(); + + applyBindingToPairs(); + + } else { + // clash + forward = backtrack(); + } + + _topLevel = false; + } + + if(forward) _solved = true; + + return forward; + } + + RobSubstitutionTL* next() { + CALL("HOLUnification::HigherOrderUnifiersIt::next"); + + // turn remaining unification pairs into standard constraints + // these can either be the flex-flex pairs, or if depth limit reached + // these can include other pairs as well + BacktrackData& bd = _bdStack->top(); + if(!_subst->bdIsRecording()){ + _subst->bdRecord(bd); + } + while(!_unifPairs.isEmpty()){ + ASS(_subst->bdIsRecording()); + HOLConstraint con = popFromUnifPairs(bd); + if(!trySolveTrivialPair(con.lhs(), con.rhs())){ // through head reduction a pair can become trivial + _subst->pushConstraint(con.constraint()); + } + } + + // don't stop recording here + // instead, let RObSubstitution do its free variable renaming + // on top member of BdStack, so that it is undone by a call to bactrack() + _unifiersReturned++; + _used = true; + _solved = false; + return _subst; + } + + HOLConstraint popFromUnifPairs(BacktrackData& bd){ + CALL("HigherOrderUnifiersIt::popFromUnifPairs"); + + auto con = _unifPairs.pop(); + bd.addClosure([this, c = con](){ _unifPairs.insert(c); }); + return con; + } + + void addToUnifPairs(HOLConstraint con, BacktrackData& bd){ + CALL("HigherOrderUnifiersIt::addToUnifPairs"); + + _unifPairs.insert(con); + bd.addClosure([this, c = con ](){ _unifPairs.remove(c); }); + } + +private: + + class HOLCnstComp + { + public: + inline + static Comparison compare(const HOLConstraint& hc1, const HOLConstraint& hc2) + { + CALL("HOLUnification::HOLCnstComp::compare"); + + auto compareTerms = [](TermList t1, TermList t2){ + if(t1.isVar()){ + if(t2.isVar()){ + return (t1.var() < t2.var()) ? LESS : (t1.var() > t2.var())? GREATER : EQUAL; + } + return LESS; + } else if(t2.isVar()){ + return GREATER; + } + + unsigned id1 = t1.term()->getId(); + unsigned id2 = t2.term()->getId(); + + return (id1id2)? GREATER : EQUAL; + }; + + if(hc1.rigidRigid() && !hc2.rigidRigid()){ + return LESS; + } else if (hc2.rigidRigid() && !hc1.rigidRigid()){ + return GREATER; + } else if (hc1.flexRigid() && hc2.flexFlex()){ + return LESS; + } else if (hc2.flexRigid() && hc1.flexFlex()){ + return GREATER; + } + + auto res = compareTerms(hc1.lhs(), hc2.lhs()); + if(res == EQUAL){ + res = compareTerms(hc1.rhs(), hc2.rhs()); + } + return res; + } + }; + + bool _used; + bool _solved; + bool _topLevel; + bool _funcExt; + unsigned _depth; + unsigned _unifiersReturned; + SkipList _unifPairs; + Recycled> _bdStack; + Recycled> _bindings; + TermList _freshVar; + RobSubstitutionTL* _subst; +}; + +class HOLUnification::HigherOrderUnifiersItWrapper: public IteratorCore { +public: + HigherOrderUnifiersItWrapper(TermList t1, TermList s1, TermList t2, TermList s2, bool funcExt) : + _appUnif(env.options->applicativeUnify()), _subst() + { + // this unification must pass, otherwise we wouldn't have reached a leaf + // however, we are forced to recompute it here with the new substitution (not ideal) + ALWAYS(_subst->unify(s1,s2)); + if(_appUnif){ + _success = _subst->unify(t1, t2, true); + } else { + _inner = vi(new HigherOrderUnifiersIt(t1, t2, &*_subst, funcExt)); + } + } + + bool hasNext() { + if(_appUnif){ return _success; } + return _inner.hasNext(); + } + RobSubstitutionTL* next() { + if(_appUnif){ + _success = false; + return &*_subst; + } + return _inner.next(); + } + +private: + bool _appUnif; + bool _success; + SubstIterator _inner; + Recycled _subst; +}; + +SubstIterator HOLUnification::unifiers(TermList t1, TermList t2, RobSubstitutionTL* sub, bool topLevelCheck) +{ + CALL("HOLUnification::unifiers"); + + if(env.options->applicativeUnify()){ + if(sub->unify(t1,t2,true)) + { return pvi(getSingletonIterator(sub)); } + return SubstIterator::getEmpty(); + } + + if(sub->sameTermContent(t1,t2)) return pvi(getSingletonIterator(sub)); + + if(topLevelCheck){ + // if topLevelCheck is set, we want to check that we + // don't return a constraint of the form t1 != t2 + if(t1.isVar() || t2.isVar()){ + auto var = t1.isVar() ? t1 : t2; + auto otherTerm = var == t1 ? t2 : t1; + auto res = fixpointUnify(var,otherTerm,sub); + if(res == OracleResult::SUCCESS) return pvi(getSingletonIterator(sub)); + if(res == OracleResult::FAILURE) return SubstIterator::getEmpty(); + if(res == OracleResult::OUT_OF_FRAGMENT) return SubstIterator::getEmpty(); + } else { + if(!ApplicativeHelper::splittable(t1, true) || !ApplicativeHelper::splittable(t2, true)){ + return SubstIterator::getEmpty(); + } + } + } + + return vi(new HigherOrderUnifiersIt(t1, t2, sub, _funcExt)); +} + +SubstIterator HOLUnification::postprocess(RobSubstitutionTL* sub, TermList t, TermList sort) +{ + CALL("HOLUnification::postprocess"); + + // ignore the sub that has been passed in, since + // that contains substitutions formed during tree traversal which + // are not helpful here (but cannot be erased either!) + TypedTermList res = ToBank(RESULT_BANK).toBank(TypedTermList(t,sort)); + + return vi(new HigherOrderUnifiersItWrapper(_origQuery, _origQuerySort, res, res.sort(), _funcExt)); +} + +bool HOLUnification::associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub) +{ + CALL("HOLUnification::associate"); + + TermList query(specialVar, /* special */ true); + return unifyWithPlaceholders(query, node, sub); +} + +// see E prover code by Petar /TERMS/cte_fixpoint_unif.c +#define DEBUG_FP_UNIFY(LVL, ...) if (LVL <= 0) DBG(__VA_ARGS__) +HOLUnification::OracleResult HOLUnification::fixpointUnify(TermList var, TermList t, RobSubstitutionTL* sub) +{ + CALL("HOLUnification::fixpointUnify"); + + TermList v; + // var can be an eta expanded var due to the normalisation of lambda prefixes + // that takes place in iterator above + if(!var.isEtaExpandedVar(v)) return OracleResult::OUT_OF_FRAGMENT; + var = v; // set var to its eta-reduced variant + + struct TermListFP { + TermList t; + bool underFlex; + unsigned depth; + }; + + bool tIsLambda = t.whnfDeref(sub).isLambdaTerm(); + TermList toFind = sub->root(var); + TermList ts = sub->derefBound(t); // TODO do we even need this derefBound? Shouldn't t already be dereferenced??? + if(ts.isVar()) { + DEBUG_FP_UNIFY(1, ".fp binding(", toFind, " -> ", ts, ")") + sub->bind(toFind, ts); + return OracleResult::SUCCESS; + } + + + Recycled> todo; + todo->push(TermListFP { .t = t, .underFlex = false, .depth = 0, }); + + while (todo->isNonEmpty()){ + auto ts = todo->pop(); + auto term = ts.t.whnfDeref(sub); + unsigned d = ts.depth; + + // TODO consider adding an encountered store similar to first-order occurs check... + + TermList head; + TermStack args; + + while(term.isLambdaTerm()){ + term = term.lambdaBody(); + d++; + } + + ApplicativeHelper::getHeadAndArgs(term, head, args); + + ASS(!head.isLambdaTerm()); + if (head.isVar()) { + if(head == toFind) { + if(ts.underFlex || (tIsLambda && args.size())){ + return OracleResult::OUT_OF_FRAGMENT; + } else { + return OracleResult::FAILURE; + } + } + } + + if(head.deBruijnIndex().isSome()){ + unsigned index = head.deBruijnIndex().unwrap(); + if(index >= d){ + // contains a free index, cannot bind + if(ts.underFlex){ + return OracleResult::OUT_OF_FRAGMENT; + } else { + return OracleResult::FAILURE; + } + } + } + + bool argsUnderFlex = head.isVar() ? true : ts.underFlex; + + for(unsigned i = 0; i < args.size(); i++){ + todo->push(TermListFP { args[i], .underFlex = argsUnderFlex, .depth = d, } ); + } + } + + DEBUG_FP_UNIFY(1, ".fp binding(", toFind, " -> ", ts, ")") + sub->bind(toFind, ts); + return OracleResult::SUCCESS; +} + + +#define DEBUG_UNIFY(LVL, ...) if (LVL <= 0) DBG(__VA_ARGS__) +bool HOLUnification::unifyWithPlaceholders(TermList t1, TermList t2, RobSubstitutionTL* sub) +{ + CALL("HOLUnification::unifyWithPlaceholders"); + + // TODO deal with the case where both terms are fully first-order... + + DEBUG_UNIFY(1, ".unify(", t1, ",", t2, ")") + if(t1 == t2) { + return true; + } + + auto impl = [&]() -> bool { + + Recycled> toDo; + toDo->push(UnifConstraint(t1, t2)); + + // Save encountered unification pairs to avoid + // recomputing their unification + Recycled> encountered; + + auto pushTodo = [&](auto pair) { + if (!encountered->find(pair)) { + encountered->insert(pair.clone()); + toDo->push(std::move(pair)); + } + }; + + while (toDo->isNonEmpty()) { + auto x = toDo->pop(); + auto dt1 = sub->derefBound(x.lhs()); + auto dt2 = sub->derefBound(x.rhs()); + DEBUG_UNIFY(2, ".unify(", dt1, ",", dt2, ")") + + if (dt1 == dt2 || dt1.isPlaceholder() || dt2.isPlaceholder()) { + // do nothing + // we want unification to pass in these cases + } else if(dt1.isVar() && !sub->occurs(dt1, dt2)) { + sub->bind(dt1, dt2); + } else if(dt2.isVar() && !sub->occurs(dt2, dt1)) { + sub->bind(dt2, dt1); + } else if(dt1.isTerm() && dt2.isTerm() && dt1.term()->functor() == dt2.term()->functor()) { + + for (unsigned i = 0; i < dt1.term()->arity(); i++) { + pushTodo(UnifConstraint(dt1.nthArg(i), dt2.nthArg(i))); + } + + } else { + return false; + } + } + return true; + }; + + BacktrackData localBD; + sub->bdRecord(localBD); + bool success = impl(); + sub->bdDone(); + + if(!success) { + localBD.backtrack(); + } else { + if(sub->bdIsRecording()) { + sub->bdCommit(localBD); + } + localBD.drop(); + } + + return success; +} + +} + +} + +#endif \ No newline at end of file diff --git a/Kernel/HOLUnification.hpp b/Kernel/HOLUnification.hpp new file mode 100644 index 0000000000..53727198f5 --- /dev/null +++ b/Kernel/HOLUnification.hpp @@ -0,0 +1,137 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file HOLUnification.hpp + * Defines class HOLUnification. + * + */ + +#ifndef __HOLUnification__ +#define __HOLUnification__ + +#if VHOL + +#include "Forwards.hpp" + +#include "Term.hpp" +#include "Lib/Hash.hpp" +#include "Lib/DHMap.hpp" +#include "Lib/Metaiterators.hpp" +#include "Lib/Environment.hpp" +#include "Lib/Backtrackable.hpp" +#include "Lib/Recycled.hpp" + +#include "Kernel/ApplicativeHelper.hpp" +#include "Kernel/SortHelper.hpp" +#include "Kernel/Signature.hpp" + +namespace Kernel +{ + +using namespace Indexing; + +namespace UnificationAlgorithms { + + +class HOLUnification { + // when this class is used for tree unification the field + // below holds the original query before higher-order subterms have + // been replaced by placeholders + TermList _origQuery; + TermList _origQuerySort; + bool _funcExt; + + bool unifyWithPlaceholders(TermList t1, TermList t2, RobSubstitutionTL* sub); + + // TODO if we implement solid fragment, this will not work... + enum OracleResult + { + SUCCESS=1, + FAILURE=2, + OUT_OF_FRAGMENT=3 + }; + + static OracleResult fixpointUnify(TermList var, TermList t, RobSubstitutionTL* sub); + + using UnifConstraint = UnificationConstraint; + + class HOLConstraint : public UnifConstraint + { + private: + TermList _t1head; + TermList _t2head; + public: + + HOLConstraint(){} // dummy constructor required for use in SkipList + HOLConstraint(TermList t1, TermList t2) : UnifConstraint(t1,t2), + _t1head(t1.head()), _t2head(t2.head()) { + ASS(!_t1head.isLambdaTerm() && !_t2head.isLambdaTerm()); // terms must be in whnf + } + CLASS_NAME(HOLConstraint) + USE_ALLOCATOR(HOLConstraint) + + bool flexFlex() const { return _t1head.isVar() && _t2head.isVar(); } + bool rigidRigid() const { return _t1head.isTerm() && _t2head.isTerm(); } + bool flexRigid() const { return (_t1head.isVar() && !_t2head.isVar()) || (_t2head.isVar() && !_t1head.isVar()); } + + TermList lhsHead() const { return _t1head; } + TermList rhsHead() const { return _t2head; } + + TermList sort() const { + CALL("HOLConstraint::sort()"); + ASS(lhs().isTerm() || rhs().isTerm()); + if(lhs().isTerm()) + { return SortHelper::getResultSort(lhs().term()); } + return SortHelper::getResultSort(rhs().term()); + } + + UnifConstraint constraint() { return UnifConstraint(lhs(),rhs()); } + }; + + inline bool sortCheck(TermList sort, bool topLevel = false){ + CALL("HOLUnification::sortCheck"); + return + _funcExt && + (sort.isOrdinaryVar() || sort.isArrowSort() || (sort.isBoolSort() && !topLevel)); + } + + class HigherOrderUnifiersIt; + class HigherOrderUnifiersItWrapper; + +public: + + HOLUnification() : _funcExt( env.options->functionExtensionality() == Options::FunctionExtensionality::ABSTRACTION) + {} + + HOLUnification(TypedTermList query) : + _funcExt( env.options->functionExtensionality() == Options::FunctionExtensionality::ABSTRACTION) { + TypedTermList t = ToBank(QUERY_BANK).toBank(query); + _origQuery = t; + _origQuerySort = t.sort(); + } + + bool associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub); + SubstIterator unifiers(TermList t1, TermList t2, RobSubstitutionTL* sub, bool topLevelCheck = false); + SubstIterator postprocess(RobSubstitutionTL*, TermList t, TermList sort); + + void initSub(RobSubstitutionTL* sub) const { } + + // method used to decide whether to return all children of a node during tree + // traversal or only the children with same top + bool usesUwa() const { return false; } +}; + +} + +} + +#endif + +#endif diff --git a/Kernel/Inference.cpp b/Kernel/Inference.cpp index ffe6eab421..d51d31940a 100644 --- a/Kernel/Inference.cpp +++ b/Kernel/Inference.cpp @@ -230,13 +230,10 @@ void Inference::updateStatistics() */ } else if (_ptr2 == nullptr) { _inductionDepth = static_cast(_ptr1)->inference().inductionDepth(); - _XXNarrows = static_cast(_ptr1)->inference().xxNarrows(); _reductions = static_cast(_ptr1)->inference().reductions(); } else { _inductionDepth = max(static_cast(_ptr1)->inference().inductionDepth(), static_cast(_ptr2)->inference().inductionDepth()); - _XXNarrows = max(static_cast(_ptr1)->inference().xxNarrows(), - static_cast(_ptr2)->inference().xxNarrows()); _reductions = max(static_cast(_ptr1)->inference().reductions(), static_cast(_ptr2)->inference().reductions()); } @@ -245,12 +242,10 @@ void Inference::updateStatistics() case Kind::INFERENCE_MANY: case Kind::INFERENCE_FROM_SAT_REFUTATION: _inductionDepth = 0; - _XXNarrows = 0; _reductions = 0; UnitList* it= static_cast(_ptr1); while(it) { _inductionDepth = max(_inductionDepth,it->head()->inference().inductionDepth()); - _XXNarrows = max(_XXNarrows,it->head()->inference().xxNarrows()); _reductions = max(_reductions,it->head()->inference().reductions()); it=it->tail(); } @@ -280,22 +275,17 @@ vstring Inference::toString() const result += ", incl: " + Int::toString(_included); result += ", ptd: " + Int::toString(_isPureTheoryDescendant); - if(env.options->addCombAxioms()){ - result += ", cad: " + Int::toString(_combAxiomsDescendant); - } + + result += ", id: " + Int::toString(_inductionDepth); + // AYB TODO +#if VHOL if(env.options->addProxyAxioms()){ result += ", pad: " + Int::toString(_proxyAxiomsDescendant); - } - if(env.options->addCombAxioms() && env.options->addProxyAxioms()){ - result += ", had: " + Int::toString(_holAxiomsDescendant); - } - result += ", id: " + Int::toString(_inductionDepth); - if(env.options->maxXXNarrows() > 0){ - result += ", xxNarrs " + Int::toString(_XXNarrows); - } - if(env.options->prioritiseClausesProducedByLongReduction()){ + } + /*if(env.options->prioritiseClausesProducedByLongReduction()){ result += ", redLen " + Int::toString(_reductions); - } + }*/ +#endif result += ", sl: " + Int::toString(_sineLevel); result += ", age: " + Int::toString(_age); result += ", thAx:" + Int::toString((int)(th_ancestors)); @@ -317,10 +307,9 @@ void Inference::init0(UnitInputType inputType, InferenceRule r) computeTheoryRunningSums(); _isPureTheoryDescendant = isTheoryAxiom(); - _combAxiomsDescendant = isCombinatorAxiom(); +#if VHOL _proxyAxiomsDescendant = isProxyAxiom(); - _holAxiomsDescendant = _combAxiomsDescendant || _proxyAxiomsDescendant; - +#endif //_inductionDepth = 0 from initDefault (or set externally) //_sineLevel = MAX from initDefault (or set externally) } @@ -339,9 +328,9 @@ void Inference::init1(InferenceRule r, Unit* premise) computeTheoryRunningSums(); _isPureTheoryDescendant = premise->isPureTheoryDescendant(); - _combAxiomsDescendant = premise->isCombAxiomsDescendant(); +#if VHOL _proxyAxiomsDescendant = premise->isProxyAxiomsDescendant(); - _holAxiomsDescendant = premise->isHolAxiomsDescendant(); +#endif _sineLevel = premise->getSineLevel(); updateStatistics(); @@ -362,9 +351,9 @@ void Inference::init2(InferenceRule r, Unit* premise1, Unit* premise2) computeTheoryRunningSums(); _isPureTheoryDescendant = premise1->isPureTheoryDescendant() && premise2->isPureTheoryDescendant(); - _combAxiomsDescendant = premise1->isCombAxiomsDescendant() && premise2->isCombAxiomsDescendant() ; - _proxyAxiomsDescendant = premise1->isProxyAxiomsDescendant() && premise2->isProxyAxiomsDescendant(); - _holAxiomsDescendant = premise1->isHolAxiomsDescendant() && premise2->isHolAxiomsDescendant(); +#if VHOL + _proxyAxiomsDescendant = premise1->isProxyAxiomsDescendant() && premise2->isProxyAxiomsDescendant(); +#endif _sineLevel = min(premise1->getSineLevel(),premise2->getSineLevel()); updateStatistics(); @@ -390,25 +379,23 @@ void Inference::initMany(InferenceRule r, UnitList* premises) if (premises) { _isPureTheoryDescendant = true; - _combAxiomsDescendant = true; _proxyAxiomsDescendant = true; - _holAxiomsDescendant = true; it=premises; while(it) { const Inference& inf = it->head()->inference(); _inputType = getInputType(_inputType,inf.inputType()); _isPureTheoryDescendant &= inf.isPureTheoryDescendant(); - _combAxiomsDescendant &= inf.isCombAxiomsDescendant(); +#if VHOL _proxyAxiomsDescendant &= inf.isProxyAxiomsDescendant(); - _holAxiomsDescendant &= inf.isHolAxiomsDescendant(); +#endif _sineLevel = min(_sineLevel,inf.getSineLevel()); it=it->tail(); } } else { _isPureTheoryDescendant = isTheoryAxiom(); - _combAxiomsDescendant = isCombinatorAxiom(); +#if VHOL _proxyAxiomsDescendant = isProxyAxiom(); - _holAxiomsDescendant = _combAxiomsDescendant || _proxyAxiomsDescendant; +#endif } updateStatistics(); @@ -930,8 +917,7 @@ vstring Kernel::ruleName(InferenceRule rule) return "generalized induction hyperresolution"; case InferenceRule::GAUSSIAN_VARIABLE_ELIMINIATION: return "gaussian variable elimination"; - case InferenceRule::COMBINATOR_AXIOM: - return "combinator axiom"; +#if VHOL case InferenceRule::FUNC_EXT_AXIOM: return "functional extensionality axiom"; case InferenceRule::EQUALITY_PROXY_AXIOM: @@ -950,38 +936,10 @@ vstring Kernel::ruleName(InferenceRule rule) return "sigma proxy axiom"; case InferenceRule::ARG_CONG: return "argument congruence"; - case InferenceRule::SXX_NARROW: - return "sxx_narrow"; - case InferenceRule::SX_NARROW: - return "sx_narrow"; - case InferenceRule::S_NARROW: - return "s_narrow"; - case InferenceRule::CXX_NARROW: - return "cxx_narrow"; - case InferenceRule::CX_NARROW: - return "cx_narrow"; - case InferenceRule::C_NARROW: - return "c_narrow"; - case InferenceRule::BXX_NARROW: - return "bxx_narrow"; - case InferenceRule::BX_NARROW: - return "bx_narrow"; - case InferenceRule::B_NARROW: - return "b_narrow"; - case InferenceRule::KX_NARROW: - return "kx_narrow"; - case InferenceRule::K_NARROW: - return "k_narrow"; - case InferenceRule::I_NARROW: - return "i_narrow"; - case InferenceRule::SUB_VAR_SUP: - return "sub-var superposition"; - case InferenceRule::COMBINATOR_DEMOD: - return "combinator demodulation"; - case InferenceRule::COMBINATOR_NORMALISE: - return "combinator normalisation"; case InferenceRule::NEGATIVE_EXT: return "negative extensionality"; + case InferenceRule::POSITIVE_EXT: + return "negative extensionality"; case InferenceRule::INJECTIVITY: return "injectivity"; case InferenceRule::HOL_NOT_ELIMINATION: @@ -1004,8 +962,19 @@ vstring Kernel::ruleName(InferenceRule rule) return "leibniz equality elimination"; case InferenceRule::CASES_SIMP: return "cases simplifying"; - /* this cases are no actual inference rules but only markeres to separatea groups of rules */ + case InferenceRule::BETA_ETA_NORMALISE: + return "beta eta normalization"; + case InferenceRule::FLEX_FLEX_SIMPLIFY: + return "flex-flex simplify"; + case InferenceRule::IMITATE: + return "imitate"; + case InferenceRule::PROJECT: + return "project"; + case InferenceRule::BOOL_INSTANTIATION: + return "heuristic instantiation"; + /* these cases are no actual inference rules but only markeres to separatea groups of rules */ case InferenceRule::PROXY_AXIOM: +#endif case InferenceRule::GENERIC_FORMULA_TRANSFORMATION: case InferenceRule::INTERNAL_FORMULA_TRANSFORMATION_LAST: case InferenceRule::GENERIC_SIMPLIFYING_INFERNCE: diff --git a/Kernel/Inference.hpp b/Kernel/Inference.hpp index 437f0de4cd..80ba101b67 100644 --- a/Kernel/Inference.hpp +++ b/Kernel/Inference.hpp @@ -92,12 +92,6 @@ UnitInputType getInputType(UnitInputType t1, UnitInputType t2); * of the form f(type_args, term_args). In most cases, inferences should NOT * be working on type arguments. Please view TermIterators.hpp for a list of * iterators available. - * - TermSubstitutionTrees, do NOT carry out any type checking. Thus, in the case - * where either the search or query term is a variable, a type check needs to - * be carried out by the inference code. This check may be a unification check or - * a matching check depending on whether the inference is using unification or - * matching. Please view Superposition.cpp for an example of a unification check - * and ForwardDemodulation for an example of a matching check. */ /** @@ -253,15 +247,16 @@ enum class InferenceRule : unsigned char { /** the last simplifying inference marker -- inferences between GENERIC_SIMPLIFYING_INFERNCE and INTERNAL_SIMPLIFYING_INFERNCE_LAST will be automatically understood simplifying (see also isSimplifyingInferenceRule) */ - /* eager demodulation with combinator axioms */ - COMBINATOR_DEMOD, - /* normalising combinators */ - COMBINATOR_NORMALISE, - /* negative extnsionality */ + /* FOOL paramodulation-like simplifying rule */ +#if VHOL CASES_SIMP, BOOL_SIMP, + BETA_ETA_NORMALISE, + + FLEX_FLEX_SIMPLIFY, +#endif INTERNAL_SIMPLIFYING_INFERNCE_LAST, @@ -304,37 +299,10 @@ enum class InferenceRule : unsigned char { INSTANCE_GENERATION, // used by InstGen. Fun fact: the inference has one parent (logically) but the age is set from two parents (and +1)! /* Instantiation */ INSTANTIATION, // used for theory reasoning - /** the last generating inference marker -- - inferences between GENERIC_GENERATING_INFERNCE and INTERNAL_GENERATING_INFERNCE_LAST will be automatically understood generating - (see also isGeneratingInferenceRule) */ + +#if VHOL /* argument congruence: t = t' => tx = t'x*/ ARG_CONG, - /* narrow with combinator axiom */ - SXX_NARROW, - - SX_NARROW, - - S_NARROW, - - CXX_NARROW, - - CX_NARROW, - - C_NARROW, - - BXX_NARROW, - - BX_NARROW, - - B_NARROW, - - KX_NARROW, - - K_NARROW, - - I_NARROW, - /* superposition beneath variable */ - SUB_VAR_SUP, INJECTIVITY, @@ -344,6 +312,12 @@ enum class InferenceRule : unsigned char { NEGATIVE_EXT, + POSITIVE_EXT, + + IMITATE, + + PROJECT, + EQ_TO_DISEQ, /** The next five rules can be either simplifying or generating */ HOL_NOT_ELIMINATION, @@ -356,6 +330,13 @@ enum class InferenceRule : unsigned char { HOL_EQUALITY_ELIMINATION, + // TODO change to HEURISTIC_... + BOOL_INSTANTIATION, +#endif + /** the last generating inference marker -- + inferences between GENERIC_GENERATING_INFERNCE and INTERNAL_GENERATING_INFERNCE_LAST will be automatically understood generating + (see also isGeneratingInferenceRule) */ + INTERNAL_GENERATING_INFERNCE_LAST, /** equality proxy replacement */ @@ -526,9 +507,8 @@ enum class InferenceRule : unsigned char { /** one of two axioms of FOOL (distinct constants or finite domain) */ FOOL_AXIOM_TRUE_NEQ_FALSE, FOOL_AXIOM_ALL_IS_TRUE_OR_FALSE, - - COMBINATOR_AXIOM, - + +#if VHOL FUNC_EXT_AXIOM, /** beginning of proxy funxtion axioms marker --*/ @@ -547,7 +527,8 @@ enum class InferenceRule : unsigned char { PI_PROXY_AXIOM, /* Exists proxy axiom */ SIGMA_PROXY_AXIOM, - +#endif + /** the last internal theory axiom marker -- axioms between THEORY_AXIOM and INTERNAL_THEORY_AXIOM_LAST will be automatically making their respective clauses isTheoryAxiom() true */ INTERNAL_THEORY_AXIOM_LAST, @@ -590,14 +571,12 @@ inline bool isInternalTheoryAxiomRule(InferenceRule r) { toNumber(r) < toNumber(InferenceRule::INTERNAL_THEORY_AXIOM_LAST)); } -inline bool isCombinatorAxiomRule(InferenceRule r) { - return r == InferenceRule::COMBINATOR_AXIOM; -} - +#if VHOL inline bool isProxyAxiomRule(InferenceRule r) { return (toNumber(r) >= toNumber(InferenceRule::PROXY_AXIOM) && toNumber(r) < toNumber(InferenceRule::INTERNAL_THEORY_AXIOM_LAST)); } +#endif inline bool isExternalTheoryAxiomRule(InferenceRule r) { return r == InferenceRule::EXTERNAL_THEORY_AXIOM; @@ -728,7 +707,6 @@ class Inference _rule = r; _included = false; _inductionDepth = 0; - _XXNarrows = 0; _reductions = 0; _sineLevel = std::numeric_limits::max(); _splits = nullptr; @@ -895,13 +873,13 @@ class Inference return isInternalTheoryAxiomRule(_rule) || isExternalTheoryAxiomRule(_rule); } - bool isCombinatorAxiom() const { - return isCombinatorAxiomRule(_rule); - } - +#if VHOL + // Proxy axioms performed really badly, so perhaps just get + // rid of this stuff? bool isProxyAxiom() const { return isProxyAxiomRule(_rule); } +#endif /* * returns true if clause is an external theory axiom @@ -941,23 +919,12 @@ class Inference /** This is how AVATAR sets it... */ void setPureTheoryDescendant(bool val) { _isPureTheoryDescendant = val; } - bool isCombAxiomsDescendant() const { return _combAxiomsDescendant; } - void setCombAxiomsDescendant(bool val) { _combAxiomsDescendant=val; } - bool isProxyAxiomsDescendant() const { return _proxyAxiomsDescendant; } - void setProxyAxiomsDescendant(bool val) { _proxyAxiomsDescendant=val; } - - bool isHolAxiomsDescendant() const { return _holAxiomsDescendant; } - void setHolAxiomsDescendant(bool val) { _holAxiomsDescendant=val; } + void setProxyAxiomsDescendant(bool val) { _proxyAxiomsDescendant=val; } unsigned inductionDepth() const { return _inductionDepth; } void setInductionDepth(unsigned d) { _inductionDepth = d; } - unsigned xxNarrows() const { return _XXNarrows; } - /** used to propagate in AVATAR **/ - void setXXNarrows(unsigned n) { _XXNarrows = n; } - void incXXNarrows(){ if(_XXNarrows < 8){ _XXNarrows++; } } - unsigned reductions() const { return _reductions; } void setReductions(unsigned r) { _reductions = r; } void increaseReductions(unsigned n){ _reductions += n; } @@ -989,12 +956,8 @@ class Inference /** track whether all leafs were theory axioms only */ bool _isPureTheoryDescendant : 1; - /** Clause is a combinator axiom descendant */ - unsigned _combAxiomsDescendant : 1; /** */ unsigned _proxyAxiomsDescendant : 1; - /** clause is descended only from proxy or combinator axioms */ - unsigned _holAxiomsDescendant : 1; /** Induction depth **/ unsigned _inductionDepth : 5; @@ -1003,9 +966,8 @@ class Inference **/ unsigned char _sineLevel : 8; // updated as the minimum from parents to children - /** number of XX' narrows carried out on clause */ - unsigned _XXNarrows : 3; - /** number of weak reductions in the history of this clause */ + // AYB TODO currently unused + /** number of beta reductions in the history of this clause */ unsigned _reductions : 30; // aligned to 64 bits diff --git a/Kernel/InferenceStore.cpp b/Kernel/InferenceStore.cpp index e748232155..794b660276 100644 --- a/Kernel/InferenceStore.cpp +++ b/Kernel/InferenceStore.cpp @@ -95,13 +95,13 @@ void InferenceStore::recordSplittingNameLiteral(Unit* us, Literal* lit) /** * Record the introduction of a new symbol */ -void InferenceStore::recordIntroducedSymbol(Unit* u, bool func, unsigned number) +void InferenceStore::recordIntroducedSymbol(Unit* u, SymbolType st, unsigned number) { CALL("InferenceStore::recordIntroducedSymbol"); SymbolStack* pStack; _introducedSymbols.getValuePtr(u->number(),pStack); - pStack->push(SymbolId(func,number)); + pStack->push(SymbolId(st,number)); } /** @@ -641,8 +641,9 @@ struct InferenceStore::TPTPProofPrinter vstring kind = "fof"; if(env.property->hasNonDefaultSorts()){ kind="tff"; } +#if VHOL if(env.property->higherOrder()){ kind="thf"; } - +#endif return kind+"("+id+","+getRole(rule,origin)+",("+"\n" +" "+formula+"),\n" +" "+inference+")."; @@ -688,14 +689,15 @@ struct InferenceStore::TPTPProofPrinter vostringstream symsStr; while(symIt.hasNext()) { SymbolId sym = symIt.next(); - if (sym.first) { - symsStr << env.signature->functionName(sym.second); - } - else { - symsStr << env.signature->predicateName(sym.second); + if (sym.first == SymbolType::FUNC) { + symsStr << env.signature->functionName(sym.second); + } else if (sym.first == SymbolType::PRED) { + symsStr << env.signature->predicateName(sym.second); + } else { + symsStr << env.signature->typeConName(sym.second); } if (symIt.hasNext()) { - symsStr << ','; + symsStr << ','; } } return getNewSymbols(origin, symsStr.str()); @@ -848,14 +850,14 @@ struct InferenceStore::TPTPProofPrinter while(lits.hasNext()) { Literal* lit=lits.next(); if (lit==nameLit) { - continue; + continue; } if (first) { - first=false; + first=false; } else { - multiple=true; - compStr+=" | "; + multiple=true; + compStr+=" | "; } compStr+=lit->toString(); @@ -876,7 +878,7 @@ struct InferenceStore::TPTPProofPrinter defStr=getQuantifiedStr(nameVars, defStr); List::destroy(nameVars); - SymbolId nameSymbol = SymbolId(false,nameLit->functor()); + SymbolId nameSymbol = SymbolId(SymbolType::PRED,nameLit->functor()); vostringstream originStm; originStm << "introduced(" << tptpRuleName(rule) << ",[" << getNewSymbols("naming",getSingletonIterator(nameSymbol)) @@ -935,8 +937,9 @@ struct InferenceStore::ProofCheckPrinter vstring kind = "fof"; if(env.property->hasNonDefaultSorts()){ kind="tff"; } +#if VHOL if(env.property->higherOrder()){ kind="thf"; } - +#endif out << kind << "(r"<<_is->getUnitIdStr(cs) << ",conjecture, " diff --git a/Kernel/InferenceStore.hpp b/Kernel/InferenceStore.hpp index 43d11b925f..bd287aab86 100644 --- a/Kernel/InferenceStore.hpp +++ b/Kernel/InferenceStore.hpp @@ -73,7 +73,7 @@ class InferenceStore }; void recordSplittingNameLiteral(Unit* us, Literal* lit); - void recordIntroducedSymbol(Unit* u, bool func, unsigned number); + void recordIntroducedSymbol(Unit* u, SymbolType st, unsigned number); void recordIntroducedSplitName(Unit* u, vstring name); void outputUnsatCore(ostream& out, Unit* refutation); @@ -101,7 +101,7 @@ class InferenceStore /** first is true for function symbols, second is symbol number */ - typedef pair SymbolId; + typedef pair SymbolId; typedef Stack SymbolStack; DHMap _introducedSymbols; DHMap _introducedSplitNames; diff --git a/Kernel/KBO.cpp b/Kernel/KBO.cpp index 5c5a2d1129..5bf5b12b3c 100644 --- a/Kernel/KBO.cpp +++ b/Kernel/KBO.cpp @@ -99,7 +99,7 @@ class KBO::State Ordering::Result KBO::State::result(Term* t1, Term* t2) { CALL("KBO::State::result") - Result res; + Result res; if(_weightDiff) { res=_weightDiff>0 ? GREATER : LESS; } else if(t1->functor()!=t2->functor()) { @@ -113,7 +113,7 @@ Ordering::Result KBO::State::result(Term* t1, Term* t2) ASS(t2->isSort()); //should only compare sorts with sorts res=_kbo.compareTypeConPrecedences(t1->functor(), t2->functor()); ASS_REP(res==GREATER || res==LESS, res);//precedence ordering must be total - } else { + } else { res=_kbo.compareFunctionPrecedences(t1->functor(), t2->functor()); ASS_REP(res==GREATER || res==LESS, res); //precedence ordering must be total } @@ -956,6 +956,12 @@ bool KboSpecialWeights::tryGetWeight(unsigned functor, unsigned& bool KboSpecialWeights::tryGetWeight(unsigned functor, unsigned& weight) const { auto sym = env.signature->getFunction(functor); + if (env.signature->isFoolConstantSymbol(true, functor) || + env.signature->isFoolConstantSymbol(false, functor)){ + // Bool symbols must have minimum weight to esnure that they are smaller than other + // terms + weight = _variableWeight; return true; + } if (sym->integerConstant()) { weight = _numInt; return true; } if (sym->rationalConstant()) { weight = _numRat; return true; } if (sym->realConstant()) { weight = _numReal; return true; } diff --git a/Kernel/LiteralSelector.cpp b/Kernel/LiteralSelector.cpp index a288d53607..08d6c3bec9 100644 --- a/Kernel/LiteralSelector.cpp +++ b/Kernel/LiteralSelector.cpp @@ -64,7 +64,11 @@ int LiteralSelector::getSelectionPriority(Literal* l) const CALL("LiteralSelector::getSelectionPriority"); Signature::Symbol* psym=env.signature->getPredicate(l->functor()); - if(psym->label() || psym->answerPredicate()) { + if(psym->label() || psym->answerPredicate() +#if VHOL + || (env.property->higherOrder() && l->isFlexFlex()) // don't select flex-flex literals +#endif + ) { return -2; } return 0; @@ -107,6 +111,13 @@ LiteralSelector* LiteralSelector::getSelector(const Ordering& ordering, const Op int absNum = abs(selectorNumber); +#if VHOL + if(env.property->higherOrder() && (absNum == 11 || absNum == 1011)){ + cout << "WARNING: Look ahead literal selection is not currently compatible with higher-order. Ignoring request to use" << endl; + absNum = 10; // set to some arbitrary hopefully good value + } +#endif + LiteralSelector* res; switch(absNum) { case 0: res = new TotalLiteralSelector(ordering, options); break; diff --git a/Kernel/LookaheadLiteralSelector.cpp b/Kernel/LookaheadLiteralSelector.cpp index d8d607149c..aca24b946e 100644 --- a/Kernel/LookaheadLiteralSelector.cpp +++ b/Kernel/LookaheadLiteralSelector.cpp @@ -14,6 +14,7 @@ #include "Lib/DArray.hpp" #include "Lib/Exception.hpp" +#include "Lib/Metaiterators.hpp" #include "Lib/Stack.hpp" #include "Indexing/IndexManager.hpp" @@ -45,7 +46,7 @@ using namespace Saturation; */ struct LookaheadLiteralSelector::GenIteratorIterator { - DECL_ELEMENT_TYPE(VirtualIterator); + DECL_ELEMENT_TYPE(VirtualIterator>); GenIteratorIterator(Literal* lit, LookaheadLiteralSelector& parent) : stage(0), lit(lit), prepared(false), _parent(parent) {} @@ -81,7 +82,7 @@ struct LookaheadLiteralSelector::GenIteratorIterator BinaryResolutionIndex* gli=static_cast(imgr->get(BINARY_RESOLUTION_SUBST_TREE)); ASS(gli); - nextIt=pvi( getStaticCastIterator(gli->getUnifications(lit,true,false)) ); + nextIt=pvi( dropElementType(gli->getUnifications(lit,true,false)) ); break; } case 1: //backward superposition @@ -102,7 +103,7 @@ struct LookaheadLiteralSelector::GenIteratorIterator ASS(fsi); nextIt=pvi( getMapAndFlattenIterator( - getMappingIterator(EqHelper::getSubtermIterator(lit, _parent._ord), //TODO update for combinatory sup + getMappingIterator(EqHelper::getSubtermIterator(lit, _parent._ord), [](Term* t) { return TermList(t); }), TermUnificationRetriever(fsi, lit)) ); break; @@ -111,10 +112,10 @@ struct LookaheadLiteralSelector::GenIteratorIterator { bool haveEqRes=false; if(lit->isNegative() && lit->isEquality()) { - RobSubstitution rs; - if(rs.unify(*lit->nthArgument(0), 0, *lit->nthArgument(1), 0)) { + RobSubstitutionTL rs; + if(rs.unify(*lit->nthArgument(0), *lit->nthArgument(1))) { haveEqRes=true; - nextIt=pvi( getStaticCastIterator(getSingletonIterator(0)) ); + nextIt=pvi( dropElementType(getSingletonIterator(0)) ); } } if(!haveEqRes) { @@ -135,7 +136,7 @@ struct LookaheadLiteralSelector::GenIteratorIterator return true; } - VirtualIterator next() + VirtualIterator> next() { CALL("LookaheadLiteralSelector::GenIteratorIterator::next"); if(!prepared) { @@ -151,10 +152,10 @@ struct LookaheadLiteralSelector::GenIteratorIterator struct TermUnificationRetriever { TermUnificationRetriever(TermIndex* index, Literal* lit) : _index(index), _lit(lit) {} - VirtualIterator operator()(TermList trm) + VirtualIterator> operator()(TermList trm) { TypedTermList tt(trm, SortHelper::getTermSort(trm, _lit)); - return pvi( getStaticCastIterator(_index->getUnifications(tt,false)) ); + return pvi( dropElementType(_index->getUnifications(tt,false)) ); } private: TermIndex* _index; @@ -164,7 +165,7 @@ struct LookaheadLiteralSelector::GenIteratorIterator int stage; Literal* lit; bool prepared; - VirtualIterator nextIt; + VirtualIterator> nextIt; LookaheadLiteralSelector& _parent; }; @@ -173,7 +174,7 @@ struct LookaheadLiteralSelector::GenIteratorIterator * Return iterator with the same number of elements as there are inferences * that can be performed with @b lit literal selected */ -VirtualIterator LookaheadLiteralSelector::getGeneraingInferenceIterator(Literal* lit) +VirtualIterator> LookaheadLiteralSelector::getGeneraingInferenceIterator(Literal* lit) { CALL("LookaheadLiteralSelector::getGeneraingInferenceIterator"); @@ -190,7 +191,7 @@ Literal* LookaheadLiteralSelector::pickTheBest(Literal** lits, unsigned cnt) CALL("LookaheadLiteralSelector::pickTheBest"); ASS_G(cnt,1); //special cases are handled elsewhere - static DArray > runifs; //resolution unification iterators + static DArray> > runifs; //resolution unification iterators runifs.ensure(cnt); for(unsigned i=0;i getGeneraingInferenceIterator(Literal* lit); + VirtualIterator> getGeneraingInferenceIterator(Literal* lit); struct GenIteratorIterator; diff --git a/Kernel/MainLoop.cpp b/Kernel/MainLoop.cpp index 270af658e2..a6ac47ed4b 100644 --- a/Kernel/MainLoop.cpp +++ b/Kernel/MainLoop.cpp @@ -114,13 +114,21 @@ MainLoop* MainLoop::createFromOptions(Problem& prb, const Options& opt) switch (opt.saturationAlgorithm()) { case Options::SaturationAlgorithm::INST_GEN: - if(env.property->hasPolymorphicSym() || env.property->higherOrder()){ + if(env.property->hasPolymorphicSym() +#if VHOL + || env.property->higherOrder() +#endif + ){ USER_ERROR("The inst gen calculus is currently not compatible with polymorphism or higher-order constructs"); } res = new IGAlgorithm(prb, opt); break; case Options::SaturationAlgorithm::FINITE_MODEL_BUILDING: - if(env.property->hasPolymorphicSym() || env.property->higherOrder()){ + if(env.property->hasPolymorphicSym() +#if VHOL + || env.property->higherOrder() +#endif + ){ USER_ERROR("Finite model buillding is currently not compatible with polymorphism or higher-order constructs"); } if(env.options->outputMode() == Shell::Options::Output::UCORE){ diff --git a/Kernel/Matcher.cpp b/Kernel/Matcher.cpp index dccf5bf97b..3bf1557226 100644 --- a/Kernel/Matcher.cpp +++ b/Kernel/Matcher.cpp @@ -261,182 +261,6 @@ bool MatchingUtils::matchTerms(TermList base, TermList instance) } -//////////////// FastMatchIterator //////////////////// - -void OCMatchIterator::init(Literal* base, Literal* inst, bool complementary) -{ - CALL("FastMatchIterator::init"); - - //TODO we don't seem to use this iterator anywhere, so - //have not updated to polymorphism - if(!Literal::headersMatch(base, inst, complementary)) { - _finished=true; - return; - } - _finished=false; - _firstMatchDone=false; - _base=base; - _inst=inst; -} - -bool OCMatchIterator::tryNextMatch() -{ - CALL("FastMatchIterator::tryNextMatch"); - - if(_finished) { - return false; - } - bool success=false; - if(!_firstMatchDone) { - _firstMatchDone=true; - if(!_base->commutative()) { - _finished=true; - } - reset(); - success=tryDirectMatch(); - } - - if(!success && !_finished) { - ASS(_base->commutative()); - _finished=true; - - reset(); - success=tryReversedMatch(); - } - return success; -} - -void OCMatchIterator::reset() -{ - CALL("FastMatchIterator::reset"); - - _bindings.reset(); - _bound.reset(); -} - -bool OCMatchIterator::tryDirectMatch() -{ - CALL("FastMatchIterator::tryDirectMatch"); - - bool res=MatchingUtils::matchArgs(_base, _inst, *this); - res&=occursCheck(); - return res; -} - -bool OCMatchIterator::tryReversedMatch() -{ - CALL("FastMatchIterator::tryReversedMatch"); - ASS(_base->commutative()); - ASS(_inst->commutative()); - - bool res=MatchingUtils::matchTerms(*_base->nthArgument(0), *_inst->nthArgument(1), *this); - if(res) { - res=MatchingUtils::matchTerms(*_base->nthArgument(1), *_inst->nthArgument(0), *this); - } - res&=occursCheck(); - return res; -} - -bool OCMatchIterator::occursCheck() -{ - CALL("OCMatchIterator::occursCheck"); - - static DHMap statuses; - static Stack toDo; - statuses.reset(); - toDo.reset(); - BoundStack::Iterator bit(_bound); - while(bit.hasNext()) { - unsigned var0=bit.next(); - OCStatus* pst0; - if(!statuses.getValuePtr(var0, pst0)) { - ASS_EQ(*pst0, CHECKED); - continue; - } - - *pst0=ENQUEUED; - toDo.push(var0); - - while(toDo.isNonEmpty()) { - int task=toDo.pop(); - if(task==-1) { - unsigned var=toDo.pop(); - ASS_EQ(statuses.get(var), TRAVERSING); - statuses.set(var, CHECKED); - continue; - } - - unsigned var=task; - - ASS_EQ(statuses.get(var), ENQUEUED); - statuses.set(var, TRAVERSING); - - //this schedules the update of the state to CHECKED - toDo.push(var); - toDo.push(-1); - - TermList tgt; - if(!_bindings.find(var, tgt)) { - continue; - } -// if(tgt.isVar()) { -// int tvar=tgt.var(); -// if(varhigherOrder()){ + if(term.containsLooseIndex()){ + return false; + } + } +#endif return _map.getValuePtr(var,aux,term) || *aux==term; } void specVar(unsigned var, TermList term) @@ -167,62 +175,6 @@ class MatchingUtils }; -/** - * Class of objects that iterate over matches between two literals that - * may share variables (therefore it has to perform occurs check). - */ -class OCMatchIterator -{ -public: - void init(Literal* base, Literal* inst, bool complementary); - - bool tryNextMatch(); - - TermList apply(unsigned var); - TermList apply(TermList t); - Literal* apply(Literal* lit); - -private: - - void reset(); - - bool tryDirectMatch(); - bool tryReversedMatch(); - - enum OCStatus { - ENQUEUED, - TRAVERSING, - CHECKED - }; - bool occursCheck(); - - - bool bind(unsigned var, TermList term) - { - TermList* binding; - - if(_bindings.getValuePtr(var,binding,term)) { - _bound.push(var); - return true; - } - return *binding==term; - } - void specVar(unsigned var, TermList term) - { ASSERTION_VIOLATION; } - - - typedef DHMap BindingMap; - typedef Stack BoundStack; - - BindingMap _bindings; - BoundStack _bound; - bool _finished; - bool _firstMatchDone; - Literal* _base; - Literal* _inst; - - friend class MatchingUtils; -}; class Matcher : public Backtrackable @@ -242,19 +194,20 @@ class Matcher bool matchReversedArgs(Literal* base, Literal* instance); typedef DHMap BindingMap; + /** MapBinder is currently the only higher-order safe binder */ struct MapBinder { MapBinder(Matcher& parent) : _parent(parent) {} bool bind(unsigned var, TermList term) - { + { TermList* aux; if(_map.getValuePtr(var,aux,term)) { - if(_parent.bdIsRecording()) { - _parent.bdAdd(new BindingBacktrackObject(this,var)); - } - return true; + if(_parent.bdIsRecording()) { + _parent.bdAdd(new BindingBacktrackObject(this,var)); + } + return true; } else { - return *aux==term; + return *aux==term; } } void specVar(unsigned var, TermList term) @@ -308,6 +261,10 @@ bool MatchingUtils::matchReversedArgs(Literal* base, Literal* instance, Binder& * Matches two terms, using @b binder to store and check bindings * of base variables. * + * Function is safe for higher-order use if binder is higher-order safe. + * That is, binder never binds a variable to a term containing loose + * (unbound) indices. + * * See MatchingUtils::match for a description of @b binder. */ template @@ -348,30 +305,30 @@ bool MatchingUtils::matchArgs(Term* base, Term* instance, Binder& binder) binder.specVar(it->var(), *bt); } else if(bt->isTerm()) { if(!it->isTerm()) { - return false; + return false; } Term* s = bt->term(); Term* t = it->term(); if(s->functor()!=t->functor()) { - return false; + return false; } if(bt->term()->shared() && it->term()->shared()) { - if(bt->term()->ground() && *bt!=*it) { - return false; - } - if(s->weight() > t->weight()) { - return false; - } + if(bt->term()->ground() && *bt!=*it) { + return false; + } + if(s->weight() > t->weight()) { + return false; + } } if(s->arity() > 0) { - bt = s->args(); - it = t->args(); - continue; + bt = s->args(); + it = t->args(); + continue; } } else { ASS(bt->isOrdinaryVar()); if(!binder.bind(bt->var(), *it)) { - return false; + return false; } } if(subterms.isEmpty()) { diff --git a/Kernel/MismatchHandler.cpp b/Kernel/MismatchHandler.cpp index e7da817af3..bf5cc6daa1 100644 --- a/Kernel/MismatchHandler.cpp +++ b/Kernel/MismatchHandler.cpp @@ -13,84 +13,405 @@ * */ +#include "Lib/Backtrackable.hpp" +#include "Lib/Coproduct.hpp" #include "Shell/Options.hpp" #include "Lib/Environment.hpp" - +#include "Lib/BiMap.hpp" #include "Forwards.hpp" #include "Signature.hpp" #include "Term.hpp" #include "RobSubstitution.hpp" +#include "SortHelper.hpp" #include "MismatchHandler.hpp" -#include "Shell/UnificationWithAbstractionConfig.hpp" +#include "Kernel/SortHelper.hpp" +#include "Kernel/TermIterators.hpp" +#include "NumTraits.hpp" +#include "Kernel/TermIterators.hpp" +#include "Debug/Output.hpp" +#define DEBUG(...) // DBG(__VA_ARGS__) +#define DEBUG_FINALIZE(LVL, ...) if (LVL <= 0) DBG(__VA_ARGS__) namespace Kernel { + +// pair& TermSpec::deref() +// { return _deref.unwrapOrInit([&]() { +// auto t = _subs->derefBound(RobSubstitution::TermSpec(_term, _index)); +// return make_pair(t.term, t.index); +// }); } + +// TermSpec TermSpec::termArg(unsigned i) +// { return TermSpec(*_subs, term()->termArg(i), index(i + nTypeArgs())); } + +// TermSpec::TermSpec(RobSubstitution& subs, TermList term, int index) +// : _subs(&subs) +// , _self(make_pair(term, index)) +// { +// } -bool UWAMismatchHandler::handle(RobSubstitution* sub, TermList t1, unsigned index1, TermList t2, unsigned index2) + +// TermSpec TermSpec::typeArg(unsigned i) +// { return TermSpec(*_subs, term()->typeArg(i), index(i)); } + +Shell::Options::UnificationWithAbstraction MismatchHandler::create() { - CALL("UWAMismatchHandler::handle"); + return env.options->unificationWithAbstraction(); +} + +bool MismatchHandler::isInterpreted(unsigned functor) const +{ + auto f = env.signature->getFunction(functor); + return f->interpreted() || f->termAlgebraCons(); +} + +class AcIter { + unsigned _function; + Recycled _todo; + RobSubstitutionTL const* _subs; +public: + AcIter(unsigned function, TermList t, RobSubstitutionTL const* subs) : _function(function), _todo(), _subs(subs) + { _todo->push(t); } + + DECL_ELEMENT_TYPE(TermList); - TermList tt1 = sub->apply(t1,index1); - TermList tt2 = sub->apply(t2,index2); + bool hasNext() const { return !_todo->isEmpty(); } - if(checkUWA(tt1,tt2)){ - return introduceConstraint(t1,index1,t2,index2); + TermList next() { + ASS(!_todo->isEmpty()); + auto t = _todo->pop(); + auto dt = _subs->derefBound(t); + while (dt.isTerm() && dt.term()->functor() == _function) { + ASS_EQ(dt.term()->arity(), 2); + _todo->push(dt.term()->termArg(1)); + t = dt.term()->termArg(0); + dt = _subs->derefBound(t); + } + return dt; } - return false; +}; + +// auto acIter(unsigned f, TermSpec t) +// { return iterTraits(AcIter(f, t)); } + +bool MismatchHandler::canAbstract(TermList const& t1, TermList const& t2) const +{ + + auto isNumeral = [](TermList t){ + ASS(t.isTerm()); + return env.signature->getFunction(t.term()->functor())->interpretedNumber(); + }; + + if(!(t1.isTerm() && t2.isTerm())) return false; + if(t1.term()->isSort() || t2.term()->isSort()) return false; + + bool t1Interp = isInterpreted(t1.term()->functor()); + bool t2Interp = isInterpreted(t2.term()->functor()); + bool bothNumbers = isNumeral(t1) && isNumeral(t2); + + switch(_mode) { + case Shell::Options::UnificationWithAbstraction::INTERP_ONLY: + return (t1Interp && t2Interp && !bothNumbers); + case Shell::Options::UnificationWithAbstraction::ONE_INTERP: + return !bothNumbers && (t1Interp || t2Interp); + break; + case Shell::Options::UnificationWithAbstraction::CONSTANT: + return !bothNumbers && (t2Interp || t2Interp) + && (t1Interp || t1.term()->numTermArguments()) + && (t2Interp || t2.term()->numTermArguments()); + case Shell::Options::UnificationWithAbstraction::ALL: + case Shell::Options::UnificationWithAbstraction::GROUND: + return true; + case Shell::Options::UnificationWithAbstraction::OFF: + return false; + case Shell::Options::UnificationWithAbstraction::AC1: + case Shell::Options::UnificationWithAbstraction::AC2: + ASSERTION_VIOLATION + } + ASSERTION_VIOLATION; } -bool UWAMismatchHandler::checkUWA(TermList t1, TermList t2) +Option MismatchHandler::tryAbstract(RobSubstitutionTL* sub, TermList const& t1, TermList const& t2) const { - CALL("UWAMismatchHandler::checkUWA"); - - if(!(t1.isTerm() && t2.isTerm())) return false; - - bool t1Interp = Shell::UnificationWithAbstractionConfig::isInterpreted(t1.term()); - bool t2Interp = Shell::UnificationWithAbstractionConfig::isInterpreted(t2.term()); - bool bothNumbers = (theory->isInterpretedConstant(t1) && theory->isInterpretedConstant(t2)); - - bool okay = true; - - static Shell::Options::UnificationWithAbstraction opt = env.options->unificationWithAbstraction(); - if(opt == Shell::Options::UnificationWithAbstraction::OFF){ return false; } - - switch(opt){ - case Shell::Options::UnificationWithAbstraction::INTERP_ONLY: - okay &= (t1Interp && t2Interp && !bothNumbers); - break; - case Shell::Options::UnificationWithAbstraction::ONE_INTERP: - okay &= !bothNumbers && (t1Interp || t2Interp); - break; - case Shell::Options::UnificationWithAbstraction::CONSTANT: - okay &= !bothNumbers && (t1Interp || t2Interp); - okay &= (t1Interp || env.signature->functionArity(t1.term()->functor())); - okay &= (t2Interp || env.signature->functionArity(t2.term()->functor())); - break; - case Shell::Options::UnificationWithAbstraction::ALL: - case Shell::Options::UnificationWithAbstraction::GROUND: - break; - default: - ASSERTION_VIOLATION; - } - return okay; + CALL("MismatchHandler::checkUWA"); + using Uwa = Shell::Options::UnificationWithAbstraction; + ASS(_mode != Uwa::OFF) + + + // TODO add parameter instead of reading from options + if (_mode == Uwa::AC1 || _mode == Uwa::AC2) { + if (!(t1.isTerm() && theory->isInterpretedFunction(t1.term()->functor(), IntTraits::addI)) + || !(t2.isTerm() && theory->isInterpretedFunction(t2.term()->functor(), IntTraits::addI))) { + return Option(); + } + auto a1 = iterTraits(AcIter(IntTraits::addF(), t1, sub)).template collect(); + auto a2 = iterTraits(AcIter(IntTraits::addF(), t2, sub)).template collect(); + // TODO not sure that the below works as desired AYB + auto less = [&](TermList const& lhs, TermList const& rhs) { return lhs < rhs; }; + a1.sort(less); + a2.sort(less); + + Recycled diff1_; + Recycled diff2_; + auto& diff1 = *diff1_; + auto& diff2 = *diff2_; + diff1.moveFromIterator(iterSortedDiff(arrayIter(a1), arrayIter(a2)).map([](auto& x) -> TermList { return x; })); + diff2.moveFromIterator(iterSortedDiff(arrayIter(a2), arrayIter(a1)).map([](auto& x) -> TermList { return x; })); + auto sum = [](auto& diff) { + return arrayIter(diff) + .map([](auto& x) { return x; }) + .fold([](auto l, auto r) + { + TermList args[] = {l, r}; + return TermList(Term::createNonShared(IntTraits::addF(), 2, args)); + }) //create non-shared? + .unwrap(); }; + auto diffConstr = [&]() + { return UnifConstraint(sum(diff1), sum(diff2)); }; + + auto functors = [](auto& diff) + { return arrayIter(diff).map([](auto& f) { return f.term()->functor(); }); }; + + if (diff1.size() == 0 && diff2.size() == 0) { + return some(AbstractionResult(EqualIf())); + + } else if (( diff1.size() == 0 && diff2.size() != 0 ) + || ( diff2.size() == 0 && diff1.size() != 0 ) ) { + return some(AbstractionResult(NeverEqual{})); + + } else if (_mode == Uwa::AC2 && diff1.size() == 1 && diff1[0].isVar()) { + return some(AbstractionResult(EqualIf().unify(UnifConstraint(diff1[0], sum(diff2))))); + + } else if (_mode == Uwa::AC2 && diff2.size() == 1 && diff2[0].isVar()) { + return some(AbstractionResult(EqualIf().unify(UnifConstraint(diff2[0], sum(diff1))))); + + } else if (concatIters(arrayIter(diff1), arrayIter(diff2)).any([](auto& x) { return x.isVar(); })) { + return some(AbstractionResult(EqualIf().constr(diffConstr()))); + + } else if (iterSortedDiff(functors(diff1), functors(diff2)).hasNext() + || iterSortedDiff(functors(diff2), functors(diff1)).hasNext()) { + return some(AbstractionResult(NeverEqual{})); + + } else { + return some(AbstractionResult(EqualIf().constr(diffConstr()))); + } + } else { + auto abs = canAbstract(t1, t2); + DEBUG("canAbstract(", t1, ",", t2, ") = ", abs); + return someIf(abs, [&](){ + return AbstractionResult(EqualIf().constr(UnifConstraint(t1, t2))); + }); + } } -bool UWAMismatchHandler::introduceConstraint(TermList t1,unsigned index1, TermList t2,unsigned index2) +namespace UnificationAlgorithms { + + +bool AbstractingUnification::fixedPointIteration(RobSubstitutionTL* sub) { - auto constraint = make_pair(make_pair(t1,index1),make_pair(t2,index2)); - constraints.push(constraint); + CALL("AbstractingUnification::fixedPointIteration"); + Recycled>> todo; + while (!sub->emptyConstraints()) { + todo->push(sub->popConstraint()); + } + + DEBUG_FINALIZE(1, "finalizing: ", todo) + while (!todo->isEmpty()) { + auto c = todo->pop(); + DEBUG_FINALIZE(2, "popped: ", c); + bool progress; + auto res = unify(c.lhs(), c.rhs(), progress, sub); + if (!res) { + DEBUG_FINALIZE(1, "finalizing failed"); + return false; + } else if (progress) { + while (!sub->emptyConstraints()) { + todo->push(sub->popConstraint()); + } + } else { + // no progress. we keep the constraints + } + } + DEBUG_FINALIZE(1, "finalizing successful: ", *sub); return true; } -bool HOMismatchHandler::handle(RobSubstitution* sub, TermList t1, unsigned index1, TermList t2, unsigned index2) +bool AbstractingUnification::unify(TermList term1, TermList term2, RobSubstitutionTL* sub) +{ + ASS(_uwa._mode != Shell::Options::UnificationWithAbstraction::OFF); + + bool progress; + return unify(term1, term2, progress, sub); +} + +SubstIterator AbstractingUnification::unifiers(TermList t1, TermList t2, RobSubstitutionTL* sub, bool topLevelCheck) +{ + CALL("AbstractingUnification::unifiers"); + + // We only care about non-trivial constraints where the top-sybmol of the two literals are the same + // and therefore a constraint can be created between arguments + if(topLevelCheck && t1.isTerm() && t2.isTerm() && + t1.term()->functor() != t2.term()->functor()){ + return SubstIterator::getEmpty(); + } + + bool unifies = unify(t1, t2, sub); + + if(!unifies){ + return SubstIterator::getEmpty(); + } + + if(!_fpi){ + return pvi(getSingletonIterator(sub)); + } + + bool success = fixedPointIteration(sub); + return success ? pvi(getSingletonIterator(sub)) : SubstIterator::getEmpty(); +} + +SubstIterator AbstractingUnification::postprocess(RobSubstitutionTL* sub, TermList t, TermList sort) { - CALL("HOMismatchHandler::handle"); + CALL("AbstractingUnification::postprocess"); + + if(!_fpi){ + return pvi(getSingletonIterator(sub)); + } + + bool success = fixedPointIteration(sub); + return success ? pvi(getSingletonIterator(sub)) : SubstIterator::getEmpty(); +} + + +#define DEBUG_UNIFY(LVL, ...) if (LVL <= 0) DBG(__VA_ARGS__) +bool AbstractingUnification::unify(TermList t1, TermList t2, bool& progress, RobSubstitutionTL* sub) +{ + CALL("AbstractingUnification::unify"); + ASS_NEQ(_uwa._mode, Shell::Options::UnificationWithAbstraction::OFF) + DEBUG_UNIFY(1, ".unify(", t1, ",", t2, ")") + progress = false; + + if(sub->sameTermContent(t1,t2)) { + progress = true; + return true; + } + + auto impl = [&]() -> bool { + + Recycled>> toDo; + toDo->push(UnificationConstraint(t1, t2)); + + // Save encountered unification pairs to avoid + // recomputing their unification + Recycled>> encountered; + + Option absRes; + auto doAbstract = [&](auto& l, auto& r) -> bool + { + absRes = _uwa.tryAbstract(sub, l, r); + if (absRes) { + DEBUG_UNIFY(2, "abstraction result: ", absRes) + } + return absRes.isSome(); + }; + + auto pushTodo = [&](auto pair) { + // we unify each subterm pair at most once, to avoid worst-case exponential runtimes + // in order to safe memory we do ot do this for variables. + // (Note by joe: didn't make this decision, but just keeping the implemenntation + // working as before. i.e. as described in the paper "Comparing Unification + // Algorithms in First-Order Theorem Proving", by Krystof and Andrei) + // TODO restore this branch? + // if (pair.first.isVar() && isUnbound(pair.first.varSpec()) && + // pair.second.isVar() && isUnbound(pair.second.varSpec())) { + // toDo.push(pair); + // } else + if (!encountered->find(pair)) { + encountered->insert(pair); + toDo->push(pair); + } + }; + + + while (toDo->isNonEmpty()) { + auto x = toDo->pop(); + TermList dt1 = sub->derefBound(x.lhs()); + TermList dt2 = sub->derefBound(x.rhs()); + + DEBUG_UNIFY(2, "popped: ", dt1, " = ", dt2) + if (sub->sameTermContent(dt1, dt2)) { + progress = true; + + } else if(dt1.isVar() && !sub->occurs(dt1, dt2)) { + progress = true; + sub->bind(dt1, dt2); + + } else if(dt2.isVar() && !sub->occurs(dt2, dt1)) { + progress = true; + sub->bind(dt2, dt1); + + } else if(doAbstract(dt1, dt2)) { + + ASS(absRes); + if (absRes->is()) { + return false; + + } else { + ASS(absRes->is()) + auto& conditions = absRes->unwrap(); + auto eq = [](UnificationConstraint& c, TermList const& lhs, TermList const& rhs) + { + // equals instead of == because some of the terms could be non-shared + return (TermList::equals(c.lhs(),lhs) && TermList::equals(c.rhs(),rhs)) + || (TermList::equals(c.lhs(),rhs) && TermList::equals(c.rhs(),lhs)); }; + if (progress + || conditions.constr().size() != 1 + || conditions.unify().size() != 0 + || !eq(conditions.constr()[0], t1, t2) + ) { + progress = true; + } + for (auto& x : conditions.unify()) { + pushTodo(std::move(x)); + } + for (auto& x: conditions.constr()) { + sub->pushConstraint(std::move(x)); + } + } + + } else if(dt1.isTerm() && dt2.isTerm() && dt1.term()->functor() == dt2.term()->functor()) { + + for (unsigned i = 0; i < dt1.term()->arity(); i++) { + pushTodo(UnificationConstraint(dt1.nthArg(i), dt2.nthArg(i))); + } + + } else { + return false; + } + + } + return true; + }; + + BacktrackData localBD; + sub->bdRecord(localBD); + bool success = impl(); + sub->bdDone(); + + if(!success) { + localBD.backtrack(); + } else { + if(sub->bdIsRecording()) { + sub->bdCommit(localBD); + } + localBD.drop(); + } + + DEBUG_UNIFY(1, *sub) + return success; +} - auto constraint = make_pair(make_pair(t1,index1),make_pair(t2,index2)); - constraints.push(constraint); - return true; } } diff --git a/Kernel/MismatchHandler.hpp b/Kernel/MismatchHandler.hpp index 3690738417..8b339f271a 100644 --- a/Kernel/MismatchHandler.hpp +++ b/Kernel/MismatchHandler.hpp @@ -17,51 +17,172 @@ #define __MismatchHandler__ #include "Forwards.hpp" +#include "Shell/Options.hpp" #include "Term.hpp" +#include "Lib/Metaiterators.hpp" +#include "Lib/Option.hpp" +#include "RobSubstitution.hpp" +#include "Indexing/ResultSubstitution.hpp" +#include "Kernel/Signature.hpp" +#include "Lib/Reflection.hpp" +#include "Shell/Options.hpp" namespace Kernel { -class MismatchHandler +class MismatchHandler final { + Shell::Options::UnificationWithAbstraction _mode; + friend class UnificationAlgorithms::AbstractingUnification; + + using AbstractingAlgo = UnificationAlgorithms::AbstractingUnification; public: - // returns true if the mismatch was handled. - virtual bool handle(RobSubstitution* sub, TermList t1, unsigned index1, TermList t2, unsigned index2) = 0; + + MismatchHandler(Shell::Options::UnificationWithAbstraction mode) : _mode(mode) {} + + using UnifConstraint = UnificationConstraint; + + struct EqualIf { + Recycled> _unify; + Recycled> _constr; + + EqualIf() : _unify(), _constr() {} + + auto unify() -> decltype(auto) { return *_unify; } + auto constr() -> decltype(auto) { return *_constr; } + + EqualIf constr(decltype(_constr) constr) && + { _constr = std::move(constr); return std::move(*this); } + + EqualIf unify(decltype(_unify) unify) && + { _unify = std::move(unify); return std::move(*this); } + + + template + EqualIf constr(UnifConstraint constr, As... constrs) && + { + unsigned constexpr len = TypeList::Size>::val; + _constr->reserve(len); + __push(*_constr, std::move(constr), std::move(constrs)...); + return std::move(*this); + } + + + template + EqualIf unify(UnifConstraint unify, As... unifys) && + { + unsigned constexpr len = TypeList::Size>::val; + _unify->reserve(len); + __push(*_unify, std::move(unify), std::move(unifys)...); + return std::move(*this); + } + + friend std::ostream& operator<<(std::ostream& out, EqualIf const& self) + { return out << "EqualIf(unify: " << self._unify << ", constr: " << self._constr << ")"; } + private: + void __push(Stack& s) + { } + template + void __push(Stack& s, UnifConstraint c, As... as) + { s.push(std::move(c)); __push(s, std::move(as)...); } + }; + + struct NeverEqual { + friend std::ostream& operator<<(std::ostream& out, NeverEqual const&) + { return out << "NeverEqual"; } + }; + + using AbstractionResult = Coproduct; + + /** TODO document */ + Option tryAbstract( + RobSubstitutionTL* rob, + TermList const& t1, + TermList const& t2) const; + + auto mode() const { return _mode; } + + // /** TODO document */ + // virtual bool recheck(TermSpec l, TermSpec r) const = 0; + + static Shell::Options::UnificationWithAbstraction create(); + +private: + // for old non-alasca uwa modes + bool isInterpreted(unsigned f) const; + bool canAbstract( + TermList const& t1, + TermList const& t2) const; }; -class UWAMismatchHandler : public MismatchHandler -{ +namespace UnificationAlgorithms { + +// TODO moce somewhere more suitable +class RobUnification { public: - UWAMismatchHandler(Stack& c) : constraints(c) /*, specialVar(0)*/ {} - virtual bool handle(RobSubstitution* sub, TermList t1, unsigned index1, TermList t2, unsigned index2); - CLASS_NAME(UWAMismatchHandler); - USE_ALLOCATOR(UWAMismatchHandler); + // to be used for tree calls + bool associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub) + { + CALL("RobUnification::associate"); + TermList query(specialVar, /* special */ true); + return sub->unify(query, node); + } -private: - bool checkUWA(TermList t1, TermList t2); - virtual bool introduceConstraint(TermList t1,unsigned index1, TermList t2, unsigned index2); + // To be used for non-tree calls. Return an iterator instead of bool + // to fit HOL interface + SubstIterator unifiers(TermList t1, TermList t2, RobSubstitutionTL* sub, bool topLevelCheck = false){ + CALL("RobUnification::unifiers"); + + if(sub->unify(t1, t2)){ + return pvi(getSingletonIterator(sub)); + } + return SubstIterator::getEmpty(); + } - Stack& constraints; - // unsigned specialVar; + // function is called when in the leaf of a substitution tree + // during unification. t is the term stored in the leaf, sort is its sort + SubstIterator postprocess(RobSubstitutionTL* sub, TermList t, TermList sort){ + CALL("RobUnification::postprocess"); + + // sub is a unifier of query and leaf term t, return it + return pvi(getSingletonIterator(sub)); + } + + void initSub(RobSubstitutionTL* sub) const { } + + bool usesUwa() const { return false; } }; -class HOMismatchHandler : public MismatchHandler -{ +class AbstractingUnification { + MismatchHandler _uwa; + bool _fpi; + public: - HOMismatchHandler(UnificationConstraintStack& c) : constraints(c) {} - - virtual bool handle(RobSubstitution* sub, TermList t1, unsigned index1, TermList t2, unsigned index2); + // DEFAULT_CONSTRUCTORS(AbstractingUnifier) + AbstractingUnification(MismatchHandler uwa, bool fixedPointIter) : + _uwa(uwa), _fpi(fixedPointIter) { } - CLASS_NAME(HOMismatchHandler); - USE_ALLOCATOR(HOMismatchHandler); + bool unify(TermList t1, TermList t2, RobSubstitutionTL* sub); + bool unify(TermList l, TermList r, bool& progress, RobSubstitutionTL* sub); + bool fixedPointIteration(RobSubstitutionTL* sub); + SubstIterator unifiers(TermList t1, TermList t2, RobSubstitutionTL* sub, bool topLevelCheck = false); + SubstIterator postprocess(RobSubstitutionTL* sub, TermList t, TermList sort); -private: + bool associate(unsigned specialVar, TermList node, RobSubstitutionTL* sub) + { + CALL("AbstractingUnification::associate"); + + TermList query(specialVar, /* special */ true); + return unify(query, node, sub); + } - Stack& constraints; - // unsigned specialVar; -}; + void initSub(RobSubstitutionTL* sub) const { } + bool usesUwa() const { return _uwa.mode() != Options::UnificationWithAbstraction::OFF; } +}; } + +} // namespace Kernel #endif /*__MismatchHandler__*/ diff --git a/Kernel/Ordering.cpp b/Kernel/Ordering.cpp index 17c6eda353..6d38fd1249 100644 --- a/Kernel/Ordering.cpp +++ b/Kernel/Ordering.cpp @@ -32,7 +32,7 @@ #include "LPO.hpp" #include "KBO.hpp" -#include "SKIKBO.hpp" +//#include "SKIKBO.hpp" #include "KBOForEPR.hpp" #include "Problem.hpp" #include "Signature.hpp" @@ -119,9 +119,9 @@ Ordering* Ordering::create(Problem& prb, const Options& opt) { CALL("Ordering::create"); - if(env.options->combinatorySup() || env.options->lambdaFreeHol()){ + /*if(env.options->combinatorySup() || env.options->lambdaFreeHol()){ return new SKIKBO(prb, opt, env.options->lambdaFreeHol()); - } + }*/ Ordering* out; switch (env.options->termOrdering()) { @@ -138,6 +138,9 @@ Ordering* Ordering::create(Problem& prb, const Options& opt) && env.options->kboWeightGenerationScheme() == Options::KboWeightGenerationScheme::CONST && !env.options->kboMaxZero() && !prb.hasInterpretedOperations() +#if VHOL + && !env.property->higherOrder() +#endif ) { out = new KBOForEPR(prb, opt); } else { @@ -145,7 +148,12 @@ Ordering* Ordering::create(Problem& prb, const Options& opt) } break; case Options::TermOrdering::LPO: - out = new LPO(prb, opt); + if(prb.hasPolymorphicSym()){ + cout << "WARNING: LPO is currently not compatible with polymorphic problems. Ignoring request to use LPO." << endl; + out = new KBO(prb, opt); + } else { + out = new LPO(prb, opt); + } break; default: ASSERTION_VIOLATION; @@ -479,20 +487,15 @@ Ordering::Result PrecedenceOrdering::compareTypeConPrecedences(unsigned tyc1, un tyc2 >= size ? (int)(reverse ? -tyc2 : tyc2) : _typeConPrecedences[tyc2] )); } -enum SymbolType { - FUNCTION, - PREDICATE, - TYPE_CON -}; struct SymbolComparator { SymbolType _symType; SymbolComparator(SymbolType symType) : _symType(symType) {} Signature::Symbol* getSymbol(unsigned s) { - if(_symType == SymbolType::FUNCTION){ + if(_symType == SymbolType::FUNC){ return env.signature->getFunction(s); - } else if (_symType == SymbolType::PREDICATE){ + } else if (_symType == SymbolType::PRED){ return env.signature->getPredicate(s); } else { return env.signature->getTypeCon(s); @@ -817,7 +820,7 @@ DArray PrecedenceOrdering::funcPrecFromOpts(Problem& prb, const Options& op precedence_file.close(); } } else { - sortAuxBySymbolPrecedence(aux,opt,SymbolType::FUNCTION); + sortAuxBySymbolPrecedence(aux,opt,SymbolType::FUNC); } } @@ -845,7 +848,7 @@ DArray PrecedenceOrdering::predPrecFromOpts(Problem& prb, const Options& op precedence_file.close(); } } else { - sortAuxBySymbolPrecedence(aux,opt,SymbolType::PREDICATE); + sortAuxBySymbolPrecedence(aux,opt,SymbolType::PRED); } DArray predicatePrecedences(nPredicates); diff --git a/Kernel/Problem.cpp b/Kernel/Problem.cpp index 97087b6f5c..7ed407cd71 100644 --- a/Kernel/Problem.cpp +++ b/Kernel/Problem.cpp @@ -272,11 +272,12 @@ void Problem::refreshProperty() const TIME_TRACE(TimeTrace::PROPERTY_EVALUATION); ScopedLet phaseLet(env.statistics->phase, Statistics::PROPERTY_SCANNING); - if(_property) { - delete _property; - } + auto oldProp = _property; _propertyValid = true; _property = Property::scan(_units); + if(oldProp) { + delete oldProp; + } env.property = _property; ASS(_property); _property->setSMTLIBLogic(getSMTLIBLogic()); @@ -295,14 +296,14 @@ void Problem::readDetailsFromProperty() const _hasInterpretedOperations = _property->hasInterpretedOperations(); _hasNumerals = _property->hasNumerals(); _hasFOOL = _property->hasFOOL(); - _hasCombs = _property->hasCombs(); - _hasApp = _property->hasApp(); - _hasAppliedVar = _property->hasAppliedVar(); - _hasLogicalProxy = _property->hasLogicalProxy(); _hasPolymorphicSym = _property->hasPolymorphicSym(); _quantifiesOverPolymorphicVar = _property->quantifiesOverPolymorphicVar(); _hasBoolVar = _property->hasBoolVar(); +#if VHOL _higherOrder = _property->higherOrder(); + _hasLogicalProxy = _property->hasLogicalProxy(); + _hasApp = _property->hasApp(); +#endif _mayHaveFormulas = _hasFormulas.value(); _mayHaveEquality = _hasEquality.value(); @@ -324,10 +325,9 @@ void Problem::invalidateEverything() _hasInterpretedOperations = MaybeBool::UNKNOWN; _hasNumerals = MaybeBool::UNKNOWN; _hasFOOL = MaybeBool::UNKNOWN; - _hasCombs = MaybeBool::UNKNOWN; +#if VHOL _hasApp = MaybeBool::UNKNOWN; - _hasAppliedVar = MaybeBool::UNKNOWN; - +#endif _mayHaveFormulas = true; _mayHaveEquality = true; _mayHaveFunctionDefinitions = true; @@ -349,9 +349,9 @@ void Problem::invalidateByRemoval() _hasInterpretedOperations.mightBecameFalse(); _hasNumerals.mightBecameFalse(); _hasFOOL.mightBecameFalse(); - _hasCombs.mightBecameFalse(); - _hasAppliedVar.mightBecameFalse(); +#if VHOL _hasLogicalProxy.mightBecameFalse(); +#endif _hasPolymorphicSym.mightBecameFalse(); _quantifiesOverPolymorphicVar.mightBecameFalse(); _hasBoolVar.mightBecameFalse(); @@ -416,15 +416,7 @@ bool Problem::hasFOOL() const return _hasFOOL.value(); } -bool Problem::hasCombs() const -{ - CALL("Problem::hasCombs"); - - if(!_hasCombs.known()) { refreshProperty(); } - return _hasCombs.value(); -} - - +#if VHOL bool Problem::hasApp() const { CALL("Problem::hasApp"); @@ -433,29 +425,29 @@ bool Problem::hasApp() const return _hasApp.value(); } -bool Problem::hasAppliedVar() const +bool Problem::hasLogicalProxy() const { - CALL("Problem::hasAppliedVar"); + CALL("Problem::hasLogicalProxy"); - if(!_hasAppliedVar.known()) { refreshProperty(); } - return _hasAppliedVar.value(); + if(!_hasLogicalProxy.known()) { refreshProperty(); } + return _hasLogicalProxy.value(); } -bool Problem::hasBoolVar() const +bool Problem::higherOrder() const { - CALL("Problem::hasBoolVar"); + CALL("Problem::hasPolymorphicSym"); - if(!_hasBoolVar.known()) { refreshProperty(); } - return _hasBoolVar.value(); + if(!_higherOrder.known()) { refreshProperty(); } + return _higherOrder.value(); } +#endif - -bool Problem::hasLogicalProxy() const +bool Problem::hasBoolVar() const { - CALL("Problem::hasLogicalProxy"); + CALL("Problem::hasBoolVar"); - if(!_hasLogicalProxy.known()) { refreshProperty(); } - return _hasLogicalProxy.value(); + if(!_hasBoolVar.known()) { refreshProperty(); } + return _hasBoolVar.value(); } bool Problem::hasPolymorphicSym() const @@ -474,13 +466,6 @@ bool Problem::quantifiesOverPolymorphicVar() const return _quantifiesOverPolymorphicVar.value(); } -bool Problem::higherOrder() const -{ - CALL("Problem::hasPolymorphicSym"); - - if(!_higherOrder.known()) { refreshProperty(); } - return _higherOrder.value(); -} #if VDEBUG /////////////////////// diff --git a/Kernel/Problem.hpp b/Kernel/Problem.hpp index 0b4a3c1915..faadfa3ea4 100644 --- a/Kernel/Problem.hpp +++ b/Kernel/Problem.hpp @@ -103,14 +103,15 @@ class Problem { bool hasNumerals() const; // meaning the interpreted constants of arithmetic theories, e.g. 1,2, 3.1415,... /** Problem contains let terms or formulas, or term if-then-else */ bool hasFOOL() const; - bool hasCombs() const; - bool hasLogicalProxy() const; bool hasBoolVar() const; - bool hasApp() const; - bool hasAppliedVar() const; bool hasPolymorphicSym() const; bool quantifiesOverPolymorphicVar() const; + +#if VHOL + bool hasApp() const; bool higherOrder() const; + bool hasLogicalProxy() const; +#endif bool mayHaveEquality() const { return _mayHaveEquality; } bool mayHaveFormulas() const { return _mayHaveFormulas; } @@ -210,14 +211,14 @@ class Problem { mutable MaybeBool _hasInterpretedOperations; mutable MaybeBool _hasNumerals; mutable MaybeBool _hasFOOL; - mutable MaybeBool _hasCombs; - mutable MaybeBool _hasApp; - mutable MaybeBool _hasAppliedVar; - mutable MaybeBool _hasLogicalProxy; mutable MaybeBool _hasPolymorphicSym; mutable MaybeBool _quantifiesOverPolymorphicVar; - mutable MaybeBool _hasBoolVar; + mutable MaybeBool _hasBoolVar; +#if VHOL + mutable MaybeBool _hasApp; + mutable MaybeBool _hasLogicalProxy; mutable MaybeBool _higherOrder; +#endif SMTLIBLogic _smtlibLogic; diff --git a/Kernel/Renaming.cpp b/Kernel/Renaming.cpp index 05de944b1a..7439343319 100644 --- a/Kernel/Renaming.cpp +++ b/Kernel/Renaming.cpp @@ -36,7 +36,8 @@ Literal* Renaming::apply(Literal* lit) { CALL("Renaming::apply(Literal*...)"); - if(identity()) { + if((identity() && _bank == DEFAULT_BANK) || + (lit->shared() && lit->ground())) { return lit; } Applicator a(this); @@ -47,7 +48,8 @@ Term* Renaming::apply(Term* trm) { CALL("Renaming::apply(Term*...)"); - if(identity()) { + if((identity() && _bank == DEFAULT_BANK) || + (trm->shared() && trm->ground())) { return trm; } Applicator a(this); @@ -58,7 +60,8 @@ TermList Renaming::apply(TermList trm) { CALL("Renaming::apply(TermList...)"); - if(identity()) { + if((identity() && _bank == DEFAULT_BANK) || + (trm.isTerm() && trm.term()->shared() && trm.term()->ground())) { return trm; } Applicator a(this); @@ -77,7 +80,7 @@ bool Renaming::identity() const shouldBeIdentity = false; } } - ASS_EQ(_identity, shouldBeIdentity); +// ASS_EQ(_identity, shouldBeIdentity); #endif return _identity; } @@ -92,7 +95,7 @@ void Renaming::normalizeVariables(const Term* t) while(vit.hasNext()) { TermList var=vit.next(); if(var.isOrdinaryVar()) { - getOrBind(var.var()); + getOrBind(var.var(), var.bank()); } } } @@ -100,7 +103,7 @@ void Renaming::normalizeVariables(const Term* t) void Renaming::normalizeVariables(TermList t) { if(t.isOrdinaryVar()) { - getOrBind(t.var()); + getOrBind(t.var(), t.bank()); } else if(t.isTerm()) { normalizeVariables(t.term()); } @@ -121,13 +124,13 @@ void Renaming::makeInverse(const Renaming& orig) _identity = orig.identity(); } -TypedTermList Renaming::normalize(TypedTermList l) +TypedTermList Renaming::normalize(TypedTermList l, VarBank bank) { CALL("Renaming::normalize(Literal*)"); if (l.isTerm()) { - return TypedTermList(normalize(l.term())); + return TypedTermList(normalize(l.term(), bank)); } else { - Recycled n; + Recycled n(0, bank); n->normalizeVariables(TermList(l)); n->normalizeVariables(l.sort()); return TypedTermList(n->apply(TermList(l)), n->apply(l.sort())); @@ -135,29 +138,29 @@ TypedTermList Renaming::normalize(TypedTermList l) } -Literal* Renaming::normalize(Literal* l) +Literal* Renaming::normalize(Literal* l, VarBank bank) { CALL("Renaming::normalize(Literal*)"); - Recycled n; + Recycled n(0, bank); n->normalizeVariables(l); return n->apply(l); } -Term* Renaming::normalize(Term* trm) +Term* Renaming::normalize(Term* trm, VarBank bank) { CALL("Renaming::normalize(Term*)"); - Recycled n; + Recycled n(0, bank); n->normalizeVariables(trm); return n->apply(trm); } -TermList Renaming::normalize(TermList trm) +TermList Renaming::normalize(TermList trm, VarBank bank) { CALL("Renaming::normalize(TermList)"); - Recycled n; + Recycled n(0, bank); n->normalizeVariables(trm); return n->apply(trm); } diff --git a/Kernel/Renaming.hpp b/Kernel/Renaming.hpp index 36b2285d52..389cbff13f 100644 --- a/Kernel/Renaming.hpp +++ b/Kernel/Renaming.hpp @@ -37,14 +37,18 @@ class Renaming { USE_ALLOCATOR(Renaming); Renaming() : - _nextVar(0), _identity(true) { + _nextVar(0), _identity(true), _bank(DEFAULT_BANK) { } /* * Construct a renaming with names starting at firstVar */ Renaming(unsigned firstVar) : - _nextVar(firstVar), _identity(true) { + _nextVar(firstVar), _identity(true), _bank(DEFAULT_BANK) { + } + + Renaming(unsigned firstVar, VarBank bank) : + _nextVar(firstVar), _identity(true), _bank(bank) { } void reset() @@ -52,15 +56,24 @@ class Renaming { _data.reset(); _nextVar = 0; _identity = true; + _bank = DEFAULT_BANK; } + bool keepRecycled() const { return _data.keepRecycled() > 0; } - unsigned getOrBind(unsigned v) + void init(unsigned firstVar, VarBank bank){ + _data.reset(); + _nextVar = firstVar; + _identity = true; + _bank = bank; + } + + unsigned getOrBind(unsigned v, VarBank b) { unsigned res; if (_data.findOrInsert(v, res, _nextVar)) { _nextVar++; - if(v!=res) { - _identity = false; + if(v!=res || b != _bank) { + _identity = false; } } return res; @@ -70,6 +83,8 @@ class Renaming { bool contains(unsigned v) { return _data.find(v); } + VarBank bank() { return _bank; } + Literal* apply(Literal* l); Term* apply(Term* l); TermList apply(TermList l); @@ -79,10 +94,10 @@ class Renaming { void normalizeVariables(TermList t); void makeInverse(const Renaming& orig); - static Literal* normalize(Literal* l); - static TypedTermList normalize(TypedTermList l); - static Term* normalize(Term* t); - static TermList normalize(TermList t); + static Literal* normalize(Literal* l, VarBank bank = DEFAULT_BANK); + static TypedTermList normalize(TypedTermList l, VarBank bank = DEFAULT_BANK); + static Term* normalize(Term* t, VarBank bank = DEFAULT_BANK); + static TermList normalize(TermList t, VarBank bank = DEFAULT_BANK); friend std::ostream& operator<<(std::ostream& out, Renaming const& self) { return out << self._data; } @@ -96,7 +111,7 @@ class Renaming { public: Applicator(Renaming* parent) : _parent(parent) {} TermList apply(unsigned var) - { return TermList(_parent->getOrBind(var), false); } + { return TermList(_parent->getOrBind(var, /* dummy */ DEFAULT_BANK), _parent->bank()); } private: Renaming* _parent; }; @@ -105,6 +120,8 @@ class Renaming { VariableMap _data; unsigned _nextVar; bool _identity; + // we may wish to rename and place on bank simultaneously + VarBank _bank; public: typedef VariableMap::Item Item; VirtualIterator items() const { return _data.items(); } diff --git a/Kernel/RobSubstitution.cpp b/Kernel/RobSubstitution.cpp index 20f8c21c74..e35f83e69c 100644 --- a/Kernel/RobSubstitution.cpp +++ b/Kernel/RobSubstitution.cpp @@ -15,10 +15,15 @@ #include "RobSubstitution.hpp" +#include "Debug/Assertion.hpp" +#include "Debug/Output.hpp" +#include "Debug/Tracer.hpp" +#include "Kernel/BottomUpEvaluation.hpp" #include "Lib/DArray.hpp" #include "Lib/DHSet.hpp" #include "Lib/DHMap.hpp" #include "Lib/Int.hpp" +#include "Lib/Metaiterators.hpp" #include "Renaming.hpp" #include "SortHelper.hpp" @@ -29,55 +34,57 @@ namespace Kernel using namespace Lib; -const int RobSubstitution::SPECIAL_INDEX=-2; -const int RobSubstitution::UNBOUND_INDEX=-1; -/** - * Unify @b t1 and @b t2, and return true iff it was successful. - */ -bool RobSubstitution::unify(TermList t1,int index1, TermList t2, int index2, MismatchHandler* hndlr) -{ - CALL("RobSubstitution::unify/4"); +const int TermSpec::SPECIAL_INDEX=-2; +const int TermSpec::UNBOUND_INDEX=-1; - return unify(TermSpec(t1,index1), TermSpec(t2,index2),hndlr); -} +template +void UnificationConstraintStack::add(Constraint c, Option bd) +{ + CALL("UnificationConstraintStack::add"); -/** - * Unify arguments of @b t1 and @b t2, and return true iff it was successful. - * - * @b t1 and @b t2 can be either terms or literals. - */ -bool RobSubstitution::unifyArgs(Term* t1,int index1, Term* t2, int index2, MismatchHandler* hndlr) -{ - CALL("RobSubstitution::unifyArgs"); - ASS_EQ(t1->functor(),t2->functor()); + if (bd) { + backtrackablePush(_cont, std::move(c), *bd); + } else { + _cont.push(std::move(c)); + } +} - TermList t1TL(t1); - TermList t2TL(t2); +template +UnificationConstraint +UnificationConstraintStack::pop(Option bd) +{ + CALL("UnificationConstraintStack::pop"); - return unify(TermSpec(t1TL,index1), TermSpec(t2TL,index2),hndlr); + auto old = _cont.pop(); + if (bd) { + bd->addClosure([this, old = old.clone()]() mutable { _cont.push(std::move(old)); }); + } + return old; } -bool RobSubstitution::match(TermList base,int baseIndex, - TermList instance, int instanceIndex) -{ - CALL("RobSubstitution::match(TermList...)"); - return match(TermSpec(base,baseIndex), TermSpec(instance,instanceIndex)); +template +Recycled> UnificationConstraintStack::literals(RobSubst& s) +{ + CALL("UnificationConstraintStack::literals"); + + Recycled> out; + out->reserve(_cont.size()); + out->loadFromIterator(literalIter(s)); + return out; } -/** - * Match arguments of @b t1 and @b t2, and return true iff it was successful. - * - * @b t1 and @b t2 can be either terms or literals. - */ -bool RobSubstitution::matchArgs(Term* base,int baseIndex, - Term* instance, int instanceIndex) -{ - CALL("RobSubstitution::match(Literal*...)"); - ASS_EQ(base->functor(),instance->functor()); - TermList baseTL(base); - TermList instanceTL(instance); - return match(TermSpec(baseTL,baseIndex), TermSpec(instanceTL,instanceIndex)); +template +Option UnificationConstraint::toLiteral(RobSubst& s) +{ + CALL("UnificationConstraint::toLiteral"); + + auto t1 = s.apply(_t1); + auto t2 = s.apply(_t2); + + return t1 == t2 + ? Option() + : Option(Literal::createEquality(false, t1, t2, t1.isTerm() ? SortHelper::getResultSort(t1.term()) : SortHelper::getResultSort(t2.term()))); } /** @@ -89,32 +96,41 @@ bool RobSubstitution::matchArgs(Term* base,int baseIndex, * @warning All variables, that occured in some term that was matched or unified * in @b normalIndex, must be also present in the @b normalizer. */ -void RobSubstitution::denormalize(const Renaming& normalizer, int normalIndex, int denormalizedIndex) +template +void RobSubstitution::denormalize(const Renaming& normalizer, VarBankOrInt normBank, VarBankOrInt denormBank) { CALL("RobSubstitution::denormalize"); VirtualIterator nit=normalizer.items(); while(nit.hasNext()) { Renaming::Item itm=nit.next(); - VarSpec normal(itm.second, normalIndex); - VarSpec denormalized(itm.first, denormalizedIndex); - ASS(!_bank.find(denormalized)); - bindVar(denormalized,normal); + TermSpecOrList normal(itm.second, normBank); + TermSpecOrList denormalized(itm.first, denormBank); + + if (denormBank == _outputIndex) { + ASS(!_bank.find(normal)); + bind(normal, denormalized); + } else { + ASS(!_bank.find(denormalized)); + bind(denormalized,normal); + } } } -bool RobSubstitution::isUnbound(VarSpec v) const +template +bool RobSubstitution::isUnbound(TermSpecOrList v) const { CALL("RobSubstitution::isUnbound"); + ASS(v.isVar()); + for(;;) { - TermSpec binding; - bool found=_bank.find(v,binding); - if(!found || binding.index==UNBOUND_INDEX) { + auto binding = _bank.find(v); + if(binding.isNone() || binding->isOutputVar()) { return true; - } else if(binding.term.isTerm()) { + } else if(binding->isTerm()) { return false; } - v=getVarSpec(binding); + v = binding.unwrap(); } } @@ -123,19 +139,20 @@ bool RobSubstitution::isUnbound(VarSpec v) const * return a term, that has the same top functor. Otherwise * return an arbitrary variable. */ -TermList RobSubstitution::getSpecialVarTop(unsigned specialVar) const +template +TermList::Top +RobSubstitution::getSpecialVarTop(unsigned specialVar) const { - VarSpec v(specialVar, SPECIAL_INDEX); + TermSpecOrList v(specialVar, true); for(;;) { - TermSpec binding; - bool found=_bank.find(v,binding); - if(!found || binding.index==UNBOUND_INDEX) { + auto binding = _bank.find(v); + if(binding.isNone() || binding->isOutputVar()) { static TermList auxVarTerm(1,false); - return auxVarTerm; - } else if(binding.term.isTerm()) { - return binding.term; + return auxVarTerm.top(); + } else if(binding->isTerm()) { + return binding->top(); } - v=getVarSpec(binding); + v = binding.unwrap(); } } @@ -144,58 +161,68 @@ TermList RobSubstitution::getSpecialVarTop(unsigned specialVar) const * a non-variable term, return the term. Otherwise, return the root variable * to which @b t belongs. */ -RobSubstitution::TermSpec RobSubstitution::derefBound(TermSpec t) const +template +TermSpecOrList RobSubstitution::derefBound(TermSpecOrList const& t_) const { CALL("RobSubstitution::derefBound"); - if(t.term.isTerm() || t.term.isVSpecialVar()) { - return t; - } - VarSpec v=getVarSpec(t); + + TermSpecOrList const* t = &t_; for(;;) { - TermSpec binding; - bool found=_bank.find(v,binding); - if(!found || binding.index==UNBOUND_INDEX) { - return TermSpec(v); - } else if(binding.term.isTerm() || binding.term.isVSpecialVar()) { - return binding; + if (t->isTerm() || t->isOutputVar()) { + return *t; + } else { + ASS(t->isVar()); + auto binding = _bank.find(*t); + if (!binding || binding->isOutputVar()) { + return *t; + } else { + t = &binding.unwrap(); + } } - v=getVarSpec(binding); } } /** - * If @b v is a bound variable then return the term or root variable - * it is bound to. Otherwise, return the next unbound variable in the - * UNBOUND_INDEX. This effectively names unbound variables apart from - * any variables in the range of bound variables. + * If @b is bound return the root variable / term it is bound to. + * If _outputIndex == UNBOUND_INDEX (default behaviour), return the next + * unbound variable in the UNBOUND_INDEX. This effectively names unbound + * variables apart from any variables in the range of bound variables. + * If _outputIndex != UNBOUND_INDEX, (i.e. it has been set to something + * else using setOutputIndex), the root variable must be of the + * _outputIndex and is returned as is, otherwise we fail on an exception. */ -RobSubstitution::TermSpec RobSubstitution::deref(VarSpec v) const +template +TermSpecOrList RobSubstitution::deref(TermSpecOrList v) const { CALL("RobSubstitution::deref"); + ASS(v.isVar()); + for(;;) { - TermSpec binding; - bool found=_bank.find(v,binding); - if(!found) { - binding.index=UNBOUND_INDEX; - binding.term.makeVar(_nextUnboundAvailable++); - const_cast(*this).bind(v,binding); - return binding; - } else if(binding.index==UNBOUND_INDEX || binding.term.isTerm() - || binding.term.isVSpecialVar()) { - return binding; + auto binding = _bank.find(v); + if(binding.isNone()) { + if(isDefault(_outputIndex)){ + const_cast(*this).bind(v, getUnboundVar()); + return _bank.get(v); + } else { + ASS_REP(v.bank() == _outputIndex, "variable bound index different from _outputIndex. This probably means you either called the wrong operations (e.g. unify) after using setOutputIndex, or you are trying to apply the substitution to a variable that was not bound by this substitution (e.g. by calling RobSubstitution::match or so)") + return v; + } + } else if(binding->isTerm() || binding->bank() == _outputIndex) { + return binding.unwrap(); } - v=getVarSpec(binding); + v = binding.unwrap(); } } -void RobSubstitution::bind(const VarSpec& v, const TermSpec& b) +template +void RobSubstitution::bind(const TermSpecOrList& v, TermSpecOrList b) { CALL("RobSubstitution::bind"); - ASSERT_VALID(b.term); + ASS(v.isVar()); + //Aux terms don't contain special variables, ergo //should be shared. //ASS(!b.term.isTerm() || b.index!=AUX_INDEX || b.term.term()->shared()); - ASS_NEQ(v.index, UNBOUND_INDEX); if(bdIsRecording()) { bdAdd(new BindingBacktrackObject(this, v)); @@ -203,244 +230,194 @@ void RobSubstitution::bind(const VarSpec& v, const TermSpec& b) _bank.set(v,b); } -void RobSubstitution::addToConstraints(const VarSpec& v1, const VarSpec& v2, MismatchHandler* hndlr) -{ - CALL("RobSubstitution::addToConstraints"); - - Term* t1 = _funcSubtermMap->get(v1.var); - Term* t2 = _funcSubtermMap->get(v2.var); - - if(t1 == t2 && t1->shared() && t1->ground()){ return; } - - TermList tt1 = TermList(t1); - TermList tt2 = TermList(t2); - - TermSpec t1spec = TermSpec(tt1, v1.index); - TermSpec t2spec = TermSpec(tt2, v2.index); - - if(t1spec.sameTermContent(t2spec)){ return; } - - //cout << "adding to constraints <" + tt1.toString() + ", " + tt2.toString() + ">" << endl; - - hndlr->handle(this, tt1, v1.index, tt2, v2.index); -} - - -void RobSubstitution::bindVar(const VarSpec& var, const VarSpec& to) -{ - CALL("RobSubstitution::bindVar"); - ASS_NEQ(var,to); - - bind(var,TermSpec(to)); -} - -RobSubstitution::VarSpec RobSubstitution::root(VarSpec v) const +template +TermSpecOrList RobSubstitution::root(TermSpecOrList v) const { CALL("RobSubstitution::root"); + ASS(v.isVar()); + for(;;) { - TermSpec binding; - bool found=_bank.find(v,binding); - if(!found || binding.index==UNBOUND_INDEX || binding.isVSpecialVar() || - binding.term.isTerm()) { + auto binding = _bank.find(v); + if(binding.isNone() || binding->isTerm() || binding->bank() == _outputIndex) { return v; } - v=getVarSpec(binding); + v = binding.unwrap(); } } -bool RobSubstitution::occurs(VarSpec vs, TermSpec ts) +template +bool RobSubstitution::occurs(TermSpecOrList const& toFind_, TermSpecOrList const& ts_) { - vs=root(vs); - Stack toDo(8); - if(ts.isVSpecialVar()){ - Term* t = _funcSubtermMap->get(ts.term.var()); - ts = TermSpec(TermList(t), ts.index); - }else if(ts.isVar()) { - ts=derefBound(ts); - if(ts.isVar()) { - return false; - } - } - typedef DHSet EncounterStore; - static EncounterStore encountered; - encountered.reset(); - - for(;;){ - ASS(ts.term.isTerm()); - VariableIterator vit(ts.term.term()); - while(vit.hasNext()) { - bool isVSpecialVar = false; - TermList var = vit.next(); - if(var.isVSpecialVar()){ isVSpecialVar = true; } - VarSpec tvar=root(getVarSpec(var, ts.index)); - if(tvar==vs) { + ASS(toFind_.isVar()); + + TermSpecOrList toFind = root(toFind_); + TermSpecOrList ts = derefBound(ts_); + if(ts.isVar()) { + return false; + } + typedef DHSet EncounterStore; + Recycled encountered; + Recycled> todo; + todo->push(ts); + + while (todo->isNonEmpty()){ + auto ts = todo->pop(); + if (ts.isVar()) { + TermSpecOrList tvar = root(ts); + if(tvar == toFind) { return true; - } - if(!encountered.find(tvar)) { - TermSpec dtvar; - if(!isVSpecialVar){ - dtvar=derefBound(TermSpec(tvar)); - } else { - Term* t = _funcSubtermMap->get(var.var()); - dtvar = TermSpec(TermList(t), ts.index); - } - if(!dtvar.isVar() || dtvar.isVSpecialVar()) { - if(dtvar.isVSpecialVar()){ - Term* t = _funcSubtermMap->get(dtvar.term.var()); - dtvar = TermSpec(TermList(t), dtvar.index); - } - encountered.insert(tvar); - toDo.push(dtvar); + } else if(!encountered->find(tvar)) { + TermSpecOrList dtvar = derefBound(tvar); + if(!dtvar.isVar()) { + encountered->insert(tvar); + todo->push(dtvar); } } + + } else { + for(unsigned i = 0; i < ts.term()->arity(); i++){ + todo->push(ts.nthArg(i)); + } } + } - if(toDo.isEmpty()) { - return false; + return false; +} + +template +bool RobSubstitution::sameTermContent(TermSpecOrList t1, TermSpecOrList t2) +{ + CALL("RobSubstitution::sameTermContent"); + + bool termSameContent = t1.sameContent(t2); + if(!termSameContent && t1.isTerm() && t1.term()->isLiteral() && + t2.isTerm() && t2.term()->isLiteral()) { + const Literal* l1=static_cast(t1.term()); + const Literal* l2=static_cast(t2.term()); + if(l1->functor()==l2->functor() && l1->arity()==0) { + return true; } - ts=toDo.pop(); } + return termSameContent; +} + +bool RobSubstitutionTS::unify(TermList t1, int idx1, TermList t2, int idx2) +{ + CALL("RobSubstitution::unify/1"); + + return RobSubstitution::unify(TermSpec(t1,idx1), TermSpec(t2,idx2)); +} + +bool RobSubstitutionTS::match(TermList t1, int idx1, TermList t2, int idx2) +{ + CALL("RobSubstitution::match/1"); + + return RobSubstitution::match(TermSpec(t1,idx1), TermSpec(t2,idx2), idx1); } -bool RobSubstitution::unify(TermSpec t1, TermSpec t2,MismatchHandler* hndlr) +template +bool RobSubstitution::unify(TermSpecOrList t1, TermSpecOrList t2 +#if VHOL + , bool applicativeUnify +#endif + ) { CALL("RobSubstitution::unify/2"); +#define DEBUG_UNIFY(lvl, ...) if (lvl < 0) DBG("unify: ", __VA_ARGS__) + DEBUG_UNIFY(0, *this, ".unify(", t1, ",", t2, ")") - if(t1.sameTermContent(t2)) { + + if(sameTermContent(t1,t2)) { return true; } - bool mismatch=false; BacktrackData localBD; bdRecord(localBD); - static Stack toDo(64); - static Stack subterms(64); - ASS(toDo.isEmpty() && subterms.isEmpty()); + static Stack toDo(64); + ASS(toDo.isEmpty()); + toDo.push(Constraint(t1, t2)); // Save encountered unification pairs to avoid // recomputing their unification - typedef DHSet EncStore; - - EncStore encountered; - encountered.reset(); + Recycled> encountered; + +#if VHOL + auto containsLooseIndex = [](TermList t){ + if(env.property->higherOrder()){ + // should never reach here from a tree + // currently we only reach this point by a call to unifiers + // from condensation + ASS(t.isVar() || t.term()->shared()) + // we don't need to dereference any bound variables + // since we should never be binding a variable to a term that contains a loose index + return t.containsLooseIndex(); + } + return false; + }; +#endif + + auto pushTodo = [&](auto pair) { + // we unify each subterm pair at most once, to avoid worst-case exponential runtimes + // in order to safe memory we do ot do this for variables. + // (Note by joe: didn't make this decision, but just keeping the implemenntation + // working as before. i.e. as described in the paper "Comparing Unification + // Algorithms in First-Order Theorem Proving", by Krystof and Andrei) + if (pair.lhs().isVar() && isUnbound(pair.lhs()) && + pair.rhs().isVar() && isUnbound(pair.rhs())) { + toDo.push(std::move(pair)); + } else if (!encountered->find(pair)) { + encountered->insert(pair); + toDo.push(pair); + } + }; + bool mismatch=false; // Iteratively resolve unification pairs in toDo // the current pair is always in t1 and t2 with their dereferenced // version in dt1 and dt2 - for(;;) { - TermSpec dt1=derefBound(t1); - TermSpec dt2=derefBound(t2); + while (toDo.isNonEmpty()) { + auto x = toDo.pop(); + TermSpecOrList const& dt1 = derefBound(x.lhs()); + TermSpecOrList const& dt2 = derefBound(x.rhs()); + DEBUG_UNIFY(1, "next pair: ", tie(dt1, dt2)) // If they have the same content then skip // (note that sameTermContent is best-effort) - if(dt1.sameTermContent(dt2)) { - } else if(dt1.isVSpecialVar() && dt2.isVSpecialVar()){ - ASS(hndlr); - addToConstraints(getVarSpec(dt1), getVarSpec(dt2), hndlr); - } + + if (sameTermContent(dt1,dt2)) { // Deal with the case where eithe rare variables // Do an occurs-check and note that the variable // cannot be currently bound as we already dereferenced - else if(dt1.isVar() && !dt1.isVSpecialVar()) { - VarSpec v1=getVarSpec(dt1); - if(occurs(v1, dt2)) { - mismatch=true; - break; + } else if(dt1.isVar() && !occurs(dt1, dt2) +#if VHOL + && (!applicativeUnify || !containsLooseIndex(dt2)) +#endif + ) { + bind(dt1, dt2); + + } else if(dt2.isVar() && !occurs(dt2, dt1) +#if VHOL + && (!applicativeUnify || !containsLooseIndex(dt1)) +#endif + ) { + bind(dt2, dt1); + + } else if(dt1.isTerm() && dt2.isTerm() + && dt1.term()->functor() == dt2.term()->functor()) { + + for (unsigned i = 0; i < dt1.term()->arity(); i++) { + pushTodo(Constraint(dt1.nthArg(i), dt2.nthArg(i))); } - bind(v1,dt2); - } else if(dt2.isVar() && !dt2.isVSpecialVar()) { - VarSpec v2=getVarSpec(dt2); - if(occurs(v2, dt1)) { - mismatch=true; - break; - } - bind(v2,dt1); - } else if(dt1.isVSpecialVar()){ - Term* t = _funcSubtermMap->get(dt1.term.var()); - t1 = TermSpec(TermList(t), dt1.index); - toDo.push(TTPair(t1, dt2)); - } else if(dt2.isVSpecialVar()){ - Term* t = _funcSubtermMap->get(dt2.term.var()); - t2 = TermSpec(TermList(t), dt2.index); - toDo.push(TTPair(dt1, t2)); - } else { - // Case where both are terms - TermList* ss=&dt1.term; - TermList* tt=&dt2.term; - - ASS(subterms.isEmpty()); - - // Generate todo unification pairs by traversing subterms - // until those subterms either definitely don't unify (report mismatch) - // or until we need to unify them to check - for (;;) { - TermSpec tsss(*ss,dt1.index); - TermSpec tstt(*tt,dt2.index); - - // If they don't have the same content but have the same top functor - // then we need to get their subterm arguments and check those - if (!tsss.sameTermContent(tstt) && TermList::sameTopFunctor(*ss,*tt)) { - ASS(ss->isTerm() && tt->isTerm()); - - Term* s = ss->term(); - Term* t = tt->term(); - ASS(s->arity() > 0); - ASS(s->functor() == t->functor()); - - ss = s->args(); - tt = t->args(); - if (! ss->next()->isEmpty()) { - subterms.push(ss->next()); - subterms.push(tt->next()); - } - } else { - // If they do have the same top functor then their content is the same and - // we can ignore. Otherwise, if one is a variable we create a unification - // pair and if neither are variables we consult the mismatch handler - if (! TermList::sameTopFunctor(*ss,*tt)) { - if(ss->isVar()||tt->isVar()) { - TTPair itm(tsss,tstt); - if((itm.first.isVar() && isUnbound(getVarSpec(itm.first))) || - (itm.second.isVar() && isUnbound(getVarSpec(itm.second))) ) { - toDo.push(itm); - } else if(!encountered.find(itm)) { - toDo.push(itm); - encountered.insert(itm); - } - } else { - // Eventually, we want to make theories using the hashing/very special variable - // mechanism used by higher-order logic to pruduce constraints. - // until then the first condition ensures that the handler is never called - // incorrectly. HOL also uses a handler, but it shouldn't be called here. - if(env.property->higherOrder() || !hndlr || !hndlr->handle(this,tsss.term,tsss.index,tstt.term,tstt.index)){ - mismatch=true; - break; - } - } - } - - if (subterms.isEmpty()) { - break; - } - tt = subterms.pop(); - ss = subterms.pop(); - if (! ss->next()->isEmpty()) { - subterms.push(ss->next()); - subterms.push(tt->next()); - } - } - } - } - if(toDo.isEmpty() || mismatch) { + } else { + mismatch = true; break; } - t1=toDo.top().first; - t2=toDo.pop().second; + + ASS(!mismatch) } if(mismatch) { - subterms.reset(); toDo.reset(); } @@ -455,6 +432,7 @@ bool RobSubstitution::unify(TermSpec t1, TermSpec t2,MismatchHandler* hndlr) localBD.drop(); } + DEBUG_UNIFY(0, *this) return !mismatch; } @@ -467,92 +445,110 @@ bool RobSubstitution::unify(TermSpec t1, TermSpec t2,MismatchHandler* hndlr) * only in internal terms of substitution trees and * this behavior allows easy instance retrieval.) */ -bool RobSubstitution::match(TermSpec base, TermSpec instance) +template +bool RobSubstitution::match(TermSpecOrList base, TermSpecOrList instance, VarBankOrInt baseBank) { CALL("RobSubstitution::match(TermSpec...)"); - if(base.sameTermContent(instance)) { - return true; - } +#define DEBUG_MATCH(lvl, ...) if (lvl < 0) DBG("match: ", __VA_ARGS__) + + if(sameTermContent(base,instance)) { return true; } bool mismatch=false; BacktrackData localBD; bdRecord(localBD); - static Stack subterms(64); - ASS(subterms.isEmpty()); + static Stack toDo(64); + ASS(toDo.isEmpty()); + toDo.push(Constraint(base, instance)); - TermList* bt=&base.term; - TermList* it=&instance.term; + auto quickTests = [](TermList bt, TermList it){ + if(bt.isTerm() && bt.term()->shared() && it.isTerm() && it.term()->shared()){ + if(bt.term()->ground()){ return bt == it; } + return bt.term()->weight() <= it.term()->weight(); + } + return true; + }; - TermSpec binding1; - TermSpec binding2; + auto canBind = [&](TermSpecOrList t) + { return t.isVar() && t.bank() == baseBank; }; - for (;;) { - TermSpec bts(*bt,base.index); - TermSpec its(*it,instance.index); + auto dealWithSpec = [&](TermSpecOrList spec, TermSpecOrList term, bool instance){ + auto binding = _bank.find(spec); + if(binding) { + TermSpecOrList t = binding.unwrap(); + toDo.push(instance ? Constraint(term,t) : Constraint(t,term)); + } else { + bind(spec, term); + } + }; - if (!bts.sameTermContent(its) && TermList::sameTopFunctor(bts.term,its.term)) { - Term* s = bts.term.term(); - Term* t = its.term.term(); - ASS(s->arity() > 0); + auto canCompare = [](TermSpecOrList t) + { return !t.isSpecialVar() && (t.isVar() || t.term()->shared()); }; - bt = s->args(); - it = t->args(); - } else { - if (! TermList::sameTopFunctor(bts.term,its.term)) { - if(bts.term.isSpecialVar()) { - VarSpec bvs(bts.term.var(), SPECIAL_INDEX); - if(_bank.find(bvs, binding1)) { - ASS_EQ(binding1.index, base.index); - bt=&binding1.term; - continue; - } else { - bind(bvs,its); - } - } else if(its.term.isSpecialVar()) { - VarSpec ivs(its.term.var(), SPECIAL_INDEX); - if(_bank.find(ivs, binding2)) { - ASS_EQ(binding2.index, instance.index); - it=&binding2.term; - continue; - } else { - bind(ivs,bts); - } - } else if(bts.term.isOrdinaryVar()) { - VarSpec bvs(bts.term.var(), bts.index); - if(_bank.find(bvs, binding1)) { - ASS_EQ(binding1.index, instance.index); - if(!TermList::equals(binding1.term, its.term)) - { - mismatch=true; - break; - } - } else { - bind(bvs,its); - } - } else { - mismatch=true; - break; - } - } + // Iteratively resolve matching pairs in toDo + while (toDo.isNonEmpty()) { + auto x = toDo.pop(); + TermSpecOrList bt = x.lhs(); + TermSpecOrList it = x.rhs(); + DEBUG_MATCH(1, "next pair: ", tie(bt, it)) - if (subterms.isEmpty()) { - break; - } - bt = subterms.pop(); - it = subterms.pop(); + if(!quickTests(bt,it)){ + DEBUG_MATCH(1, "Rejected by quick tests") + mismatch = true; + break; } - if (!bt->next()->isEmpty()) { - subterms.push(it->next()); - subterms.push(bt->next()); + + if(bt.isSpecialVar()) { + dealWithSpec(bt, it, false); + } else if(it.isSpecialVar()) { + dealWithSpec(it, bt, true); + } else if(canBind(bt)) { + auto binding = _bank.find(bt); + + if(binding) { + auto b = binding.unwrap(); + if(canCompare(b) && canCompare(it)) + { + if(!TermSpecOrList::equals(b, it)){ + mismatch=true; + break; + } + } else { + toDo.push(Constraint(b,it)); + } + } else { +#if VHOL + if(env.property->higherOrder()){ + if(it.containsLooseIndex()){ + mismatch=true; + break; + } + } +#endif + bind(bt, it); + } + } else if (it.isVar() || bt.isVar()) { + ASS(!canBind(it) && !canBind(bt)); + mismatch=true; + break; + } else if (bt.term()->functor() == it.term()->functor()) { + for (unsigned i = 0; i < bt.term()->arity(); i++) { + toDo.push(Constraint(bt.nthArg(i), it.nthArg(i))); + } + } else { + mismatch = true; + break; } - } - bdDone(); + ASS(!mismatch) + } - subterms.reset(); + if(mismatch) { + toDo.reset(); + } + bdDone(); if(mismatch) { localBD.backtrack(); @@ -566,8 +562,20 @@ bool RobSubstitution::match(TermSpec base, TermSpec instance) return !mismatch; } +// AYB do we use this? Not very efficient that we are passing a stack around +// by value +template +Stack RobSubstitution::apply(Stack cl, VarBankOrInt bank) const +{ + CALL("RobSubstitution::apply(Clause*...)"); + for (unsigned i = 0; i < cl.size(); i++) { + cl[i] = apply(cl[i], bank); + } + return cl; +} -Literal* RobSubstitution::apply(Literal* lit, int index) const +template +Literal* RobSubstitution::apply(Literal* lit, VarBankOrInt bank) const { CALL("RobSubstitution::apply(Literal*...)"); static DArray ts(32); @@ -576,207 +584,60 @@ Literal* RobSubstitution::apply(Literal* lit, int index) const return lit; } - int arity = lit->arity(); + unsigned arity = lit->arity(); ts.ensure(arity); - int i = 0; - for (TermList* args = lit->args(); ! args->isEmpty(); args = args->next()) { - ts[i++]=apply(*args,index); + for (unsigned i = 0; i < arity; i++) { + ts[i]=apply(getLitArg(lit,i,bank),bank); } if(lit->isTwoVarEquality()){ - TermList sort = apply(lit->twoVarEqSort(),index); + TermList sort = apply(getLitSort(lit,bank),bank); return Literal::createEquality(lit->polarity(), ts[0], ts[1], sort); } return Literal::create(lit,ts.array()); } -TermList RobSubstitution::apply(TermList trm, int index) const +template +TermList RobSubstitution::apply(TermSpecOrList trm, VarBankOrInt bank) const { CALL("RobSubstitution::apply(TermList...)"); - static Stack toDo(8); - static Stack toDoIndex(8); - static Stack terms(8); - static Stack termRefVars(8); - static Stack args(8); - static DHMap known; - - //is inserted into termRefVars, if respective - //term in terms isn't referenced by any variable - const VarSpec nilVS(-1,0); - - toDo.push(&trm); - toDoIndex.push(index); - - while(!toDo.isEmpty()) { - TermList* tt=toDo.pop(); - index=toDoIndex.pop(); - if(tt->isEmpty()) { - Term* orig=terms.pop(); - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - TermList* argLst=&args.top() - (orig->arity()-1); - args.truncate(args.length() - orig->arity()); - TermList constructed; - if(orig->isSort()){ - constructed.setTerm(AtomicSort::create(static_cast(orig),argLst)); - } else { - constructed.setTerm(Term::create(orig,argLst)); - } - args.push(constructed); - - VarSpec ref=termRefVars.pop(); - if(ref!=nilVS) { - ALWAYS(known.insert(ref,constructed)); - } - continue; - } else { - //if tt==&trm, we're dealing with the top - //term, for which the next() is undefined - if(tt!=&trm) { - toDo.push(tt->next()); - toDoIndex.push(index); - } - } - - TermSpec ts(*tt,index); - - VarSpec vs; - if(ts.term.isVar() && !ts.term.isVSpecialVar()) { - vs=root(getVarSpec(ts) ); - - TermList found; - if(known.find(vs, found)) { - args.push(found); - continue; - } - - ts=deref(vs); - if(ts.term.isVar() && !ts.term.isVSpecialVar()) { - ASS(ts.index==UNBOUND_INDEX); - args.push(ts.term); - continue; - } - } else { - vs=nilVS; - } - Term* t; - if(ts.term.isVSpecialVar()){ - t = _funcSubtermMap->get(ts.term.var()); - } else { - t = ts.term.term(); - } - if(t->shared() && t->ground()) { - args.push(TermList(t)); - continue; - } - terms.push(t); - termRefVars.push(vs); - - toDo.push(t->args()); - toDoIndex.push(ts.index); - } - ASS(toDo.isEmpty() && toDoIndex.isEmpty() && terms.isEmpty() && args.length()==1); - known.reset(); - - - return args.pop(); + //DBG(*this, ".apply(", trm, " " , bank , ")") + + auto out = evalBottomUp(AutoDerefTerm(trm, this, bank), + [&](auto& orig, TermList* args) -> TermList { + //cout << "orig " << orig << endl; + TermList tout; + if (orig.term.isVar()) { + ASS(!orig.term.isOutputVar()) + auto var = deref(orig.term); + ASS(var.isVar() && var.bank() == _outputIndex); + tout = TermList(var.var(), DEFAULT_BANK); + } else { + const Term* origT = orig.term.term(); + tout = TermList(origT->isSort() ? AtomicSort::create(origT->functor(), origT->arity(), args) + : Term::create (origT->functor(), origT->arity(), args)); + } + return tout; + }); + return out; } -size_t RobSubstitution::getApplicationResultWeight(TermList trm, int index) const +template +size_t RobSubstitution::getApplicationResultWeight(TermSpecOrList trm, VarBankOrInt bank) const { CALL("RobSubstitution::getApplicationResultWeight"); - static Stack toDo(8); - static Stack toDoIndex(8); - static Stack terms(8); - static Stack termRefVars(8); - static Stack argSizes(8); - - static DHMap known; - known.reset(); - - //is inserted into termRefVars, if respective - //term in terms isn't referenced by any variable - const VarSpec nilVS(-1,0); - - toDo.push(&trm); - toDoIndex.push(index); - - while(!toDo.isEmpty()) { - TermList* tt=toDo.pop(); - index=toDoIndex.pop(); - if(tt->isEmpty()) { - Term* orig=terms.pop(); - unsigned arity = orig->arity(); - //here we assume, that stack is an array with - //second topmost element as &top()-1, third at - //&top()-2, etc... - size_t* szArr=&argSizes.top() - (orig->arity()-1); - size_t sz = 1; //1 for the function symbol - for(unsigned i=0; inext()); - toDoIndex.push(index); - } - } - - TermSpec ts(*tt,index); - - VarSpec vs; - if(ts.term.isVar() && !ts.term.isVSpecialVar()) { - vs=root(getVarSpec(ts)); - - size_t found; - if(known.find(vs, found)) { - argSizes.push(found); - continue; - } - - ts=deref(vs); - if(ts.term.isVar() && !ts.term.isVSpecialVar()) { - ASS(ts.index==UNBOUND_INDEX); - argSizes.push(1); - continue; - } - } else { - vs=nilVS; - } - Term* t; - if(ts.term.isVSpecialVar()){ - t = _funcSubtermMap->get(ts.term.var()); - }else{ - t=ts.term.term(); - } - if(t->shared() && t->ground()) { - argSizes.push(t->weight()); - continue; - } - terms.push(t); - termRefVars.push(vs); - - toDo.push(t->args()); - toDoIndex.push(ts.index); - } - ASS(toDo.isEmpty() && toDoIndex.isEmpty() && terms.isEmpty() && argSizes.length()==1); - return argSizes.pop(); + return evalBottomUp(AutoDerefTerm(trm, this, bank), + [](auto& orig, size_t* sizes) + { return orig.term.isVar() ? 1 + : (1 + range(0, orig.term.term()->arity()) + .map([&](auto i) { return sizes[i]; }) + .sum()); }); } -size_t RobSubstitution::getApplicationResultWeight(Literal* lit, int index) const +template +size_t RobSubstitution::getApplicationResultWeight(Literal* lit, VarBankOrInt bank) const { CALL("RobSubstitution::getApplicationResultWeight"); static DArray ts(32); @@ -786,26 +647,25 @@ size_t RobSubstitution::getApplicationResultWeight(Literal* lit, int index) cons } size_t res = 1; //the predicate symbol weight - for (TermList* args = lit->args(); ! args->isEmpty(); args = args->next()) { - size_t argWeight = getApplicationResultWeight(*args,index); + for (unsigned i = 0; i < lit->arity(); i++) { + size_t argWeight = getApplicationResultWeight(getLitArg(lit,i,bank),bank); res += argWeight; } return res; } -/** - * Return iterator on matching substitutions of @b l1 and @b l2. - * - * For guides on use of the iterator, see the documentation of - * RobSubstitution::AssocIterator. - */ -SubstIterator RobSubstitution::matches(Literal* base, int baseIndex, - Literal* instance, int instanceIndex, bool complementary) +struct RobSubstitutionTL::ToRobTermList { - return getAssocIterator(this, base, baseIndex, - instance, instanceIndex, complementary); -} + RobSubstitutionTL* operator()(RobSubstitution* r) + { return static_cast(r); } +}; + +struct RobSubstitutionTS::ToRobTermSpec +{ + RobSubstitutionTS* operator()(RobSubstitution* r) + { return static_cast(r); } +}; /** * Return iterator on unifying substitutions of @b l1 and @b l2. @@ -813,57 +673,73 @@ SubstIterator RobSubstitution::matches(Literal* base, int baseIndex, * For guides on use of the iterator, see the documentation of * RobSubstitution::AssocIterator. */ -SubstIterator RobSubstitution::unifiers(Literal* l1, int l1Index, - Literal* l2, int l2Index, bool complementary) +SubstIterator RobSubstitutionTL::unifiers(Literal* l1, Literal* l2, bool complementary) { - return getAssocIterator(this, l1, l1Index, - l2, l2Index, complementary); + + if( !Literal::headersMatch(l1,l2,complementary) ) { + return SubstIterator::getEmpty(); + } + + TermList s1 = l1->isEquality() ? SortHelper::getEqualityArgumentSort(l1) : TermList(0,false); + TermList s2 = l2->isEquality() ? SortHelper::getEqualityArgumentSort(l2) : TermList(0,false); + + TermList t1 = TermList(l1); + TermList t2 = TermList(l2); + + auto it = RobSubstitution::getAssocIterator(this, t1,s1,t2,s2, complementary); + + return pvi(getMappingIterator(it, ToRobTermList())); } -template -SubstIterator RobSubstitution::getAssocIterator(RobSubstitution* subst, - Literal* l1, int l1Index, Literal* l2, int l2Index, bool complementary) +SubstIteratorTS RobSubstitutionTS::unifiers(Literal* l1, int idx1, Literal* l2, int idx2, bool complementary) { - CALL("RobSubstitution::getAssocIterator"); - if( !Literal::headersMatch(l1,l2,complementary) ) { - return SubstIterator::getEmpty(); + return SubstIteratorTS::getEmpty(); } - if( !l1->commutative() ) { - return pvi( getContextualIterator(getSingletonIterator(subst), - AssocContext(l1, l1Index, l2, l2Index)) ); - } else { - return vi( - new AssocIterator(subst, l1, l1Index, l2, l2Index)); - } + TermSpec s1(l1->isEquality() ? SortHelper::getEqualityArgumentSort(l1) : TermList(0,false), idx1); + TermSpec s2(l2->isEquality() ? SortHelper::getEqualityArgumentSort(l2) : TermList(0,false), idx2); + + TermSpec t1(TermList(l1), idx1); + TermSpec t2(TermList(l2), idx2); + + auto it = RobSubstitution::getAssocIterator(this, t1, s1, t2, s2, complementary); + + return pvi(getMappingIterator(it, ToRobTermSpec())); } -template -struct RobSubstitution::AssocContext +template class UnificationConstraint; +template class UnificationConstraint; + +template class UnificationConstraintStack; +template class UnificationConstraintStack; + +template class RobSubstitution; +template class RobSubstitution; + +template +struct RobSubstitution::AssocContext { - AssocContext(Literal* l1, int l1Index, Literal* l2, int l2Index) - : _l1(l1), _l1i(l1Index), _l2(l2), _l2i(l2Index) { ASS(!l1->isEquality()); ASS(!l2->isEquality()); } // only used for non-commutative, i.e. also non-equality, literals - bool enter(RobSubstitution* subst) + AssocContext(TermSpecOrList l1, TermSpecOrList l2) + : _l1(l1), _l2(l2) { } // only used for non-commutative, i.e. also non-equality, literals + bool enter(RobSubst* subst) { subst->bdRecord(_bdata); - bool res=Fn::associate(subst, _l1, _l1i, _l2, _l2i); + bool res=subst->unify(_l1, _l2); if(!res) { subst->bdDone(); ASS(_bdata.isEmpty()); } return res; } - void leave(RobSubstitution* subst) + void leave(RobSubst* subst) { subst->bdDone(); _bdata.backtrack(); } private: - Literal* _l1; - int _l1i; - Literal* _l2; - int _l2i; + TermSpecOrList _l1; + TermSpecOrList _l2; BacktrackData _bdata; }; @@ -899,16 +775,19 @@ struct RobSubstitution::AssocContext * * [1] associate means either match or unify */ -template -class RobSubstitution::AssocIterator: public IteratorCore { +template +class RobSubstitution::AssocIterator: public IteratorCore { public: - AssocIterator(RobSubstitution* subst, Literal* l1, int l1Index, Literal* l2, - int l2Index) : - _subst(subst), _l1(l1), _l1i(l1Index), _l2(l2), _l2i(l2Index), + AssocIterator(RobSubst* subst, + TermSpecOrList l1, + TermSpecOrList s1, + TermSpecOrList l2, + TermSpecOrList s2) : + _subst(subst), _l1(l1), _s1(s1), _l2(l2), _s2(s2), _isEq(static_cast(l1.term())->isEquality()), _state(FIRST), _used(true) { - ASS_EQ(_l1->functor(), _l2->functor()); - ASS(_l1->commutative()); - ASS_EQ(_l1->arity(), 2); + ASS_EQ(_l1.term()->functor(), _l2.term()->functor()); + ASS(_l1.term()->commutative()); + ASS_EQ(_l1.term()->arity(), 2); } ~AssocIterator() { CALL("RobSubstitution::AssocIterator::~AssocIterator"); @@ -932,9 +811,9 @@ class RobSubstitution::AssocIterator: public IteratorCore { if (_state != FIRST) { backtrack(_bdataMain); - } else { + } else if (_isEq) { _subst->bdRecord(_bdataEqAssoc); - if (!Fn::associateEqualitySorts(_subst, _l1, _l1i, _l2, _l2i)) { + if (!_subst->unify(_s1, _s2)) { backtrack(_bdataEqAssoc); // this might not be necessary _state = FINISHED; return false; @@ -945,18 +824,30 @@ class RobSubstitution::AssocIterator: public IteratorCore { switch (_state) { case NEXT_STRAIGHT: - if (Fn::associate(_subst, _l1, _l1i, _l2, _l2i)) { + if (_subst->unify(_l1, _l2 +#if VHOL + , true // check for loose indices when binding +#endif + )) { _state = NEXT_REVERSED; break; } //no break here intentionally case NEXT_REVERSED: { - TermList t11 = *_l1->nthArgument(0); - TermList t12 = *_l1->nthArgument(1); - TermList t21 = *_l2->nthArgument(0); - TermList t22 = *_l2->nthArgument(1); - if (Fn::associate(_subst, t11, _l1i, t22, _l2i)) { - if (Fn::associate(_subst, t12, _l1i, t21, _l2i)) { + TermSpecOrList t11 = _l1.nthArg(0); + TermSpecOrList t12 = _l1.nthArg(1); + TermSpecOrList t21 = _l2.nthArg(0); + TermSpecOrList t22 = _l2.nthArg(1); + if (_subst->unify(t11, t22 +#if VHOL + , true +#endif + )) { + if (_subst->unify(t12, t21 +#if VHOL + , true +#endif + )) { _state = NEXT_CLEANUP; break; } @@ -979,7 +870,7 @@ class RobSubstitution::AssocIterator: public IteratorCore { return _state != FINISHED; } - RobSubstitution* next() { + RobSubst* next() { _used = true; return _subst; } @@ -1000,11 +891,12 @@ class RobSubstitution::AssocIterator: public IteratorCore { FINISHED = 3 }; - RobSubstitution* _subst; - Literal* _l1; - int _l1i; - Literal* _l2; - int _l2i; + RobSubst* _subst; + TermSpecOrList _l1; + TermSpecOrList _s1; + TermSpecOrList _l2; + TermSpecOrList _s2; + bool _isEq; BacktrackData _bdataMain; BacktrackData _bdataEqAssoc; @@ -1017,48 +909,21 @@ class RobSubstitution::AssocIterator: public IteratorCore { bool _used; }; -struct RobSubstitution::MatchingFn { - static bool associateEqualitySorts(RobSubstitution* subst, Literal* l1, int l1Index, - Literal* l2, int l2Index) { - /* Only in the case l1 is of the form X = Y ad l2 is of the form - t1 = t2 can the literals be matched without their sorts being matched */ - if(l1->isTwoVarEquality()){ - ASS(l2->isEquality()); - TermList sb = SortHelper::getEqualityArgumentSort(l1); - TermList si = SortHelper::getEqualityArgumentSort(l2); - return subst->match(sb, l1Index, si, l2Index); - } - return true; - } - static bool associate(RobSubstitution* subst, Literal* l1, int l1Index, - Literal* l2, int l2Index) - { return subst->matchArgs(l1,l1Index,l2,l2Index); } - - static bool associate(RobSubstitution* subst, TermList t1, int t1Index, - TermList t2, int t2Index) - { return subst->match(t1,t1Index,t2,t2Index); } -}; - -struct RobSubstitution::UnificationFn { +template +VirtualIterator*> +RobSubstitution::getAssocIterator(RobSubst* subst, + TermSpecOrList l1, TermSpecOrList s1, TermSpecOrList l2, TermSpecOrList s2, bool complementary) +{ + CALL("RobSubstitution::getAssocIterator"); - static bool associateEqualitySorts(RobSubstitution* subst, Literal* l1, int l1Index, - Literal* l2, int l2Index) { - if(l1->isEquality()) { - ASS(l2->isEquality()); - TermList s1 = SortHelper::getEqualityArgumentSort(l1); - TermList s2 = SortHelper::getEqualityArgumentSort(l2); - return subst->unify(s1, l1Index, s2, l2Index); - } - return true; + if( !l1.term()->commutative() ) { + return pvi( getContextualIterator(getSingletonIterator(subst), + AssocContext(l1, l2)) ); + } else { + return vi( + new AssocIterator(subst, l1, s1, l2, s2)); } +} - static bool associate(RobSubstitution* subst, Literal* l1, int l1Index, - Literal* l2, int l2Index) - { return subst->unifyArgs(l1,l1Index,l2,l2Index); } - - static bool associate(RobSubstitution* subst, TermList t1, int t1Index, - TermList t2, int t2Index) - { return subst->unify(t1,t1Index,t2,t2Index); } -}; -} +} // namespace Kernel diff --git a/Kernel/RobSubstitution.hpp b/Kernel/RobSubstitution.hpp index cbf8215c3d..d963c90a8a 100644 --- a/Kernel/RobSubstitution.hpp +++ b/Kernel/RobSubstitution.hpp @@ -18,10 +18,14 @@ #include "Forwards.hpp" #include "Lib/Backtrackable.hpp" +#include "Lib/Recycled.hpp" #include "Term.hpp" -#include "MismatchHandler.hpp" #include "Lib/Hash.hpp" #include "Lib/DHMap.hpp" +#include "Lib/Metaiterators.hpp" +#include "Kernel/BottomUpEvaluation.hpp" +#include "Lib/Environment.hpp" +#include "Kernel/Signature.hpp" #if VDEBUG #include @@ -31,60 +35,239 @@ namespace Kernel { +template +class RobSubstitution; + +struct TermSpec { // for backwards compatibility + static const int UNBOUND_INDEX; + static const int SPECIAL_INDEX; + + TermSpec() {} + TermSpec(TermList t, int i) : trm(t), index(i) {} + TermSpec(unsigned v, int i) : index(i) { + if(i == SPECIAL_INDEX){ + trm = TermList(v, true); // special variable + } else { + trm = TermList(v, false); // standard variable + } + } + + auto asTuple() const -> decltype(auto) { return std::tie(trm, index); } + IMPL_COMPARISONS_FROM_TUPLE(TermSpec) + IMPL_HASH_FROM_TUPLE(TermSpec) + + bool sameContent(const TermSpec& ts) + { + bool termSameContent=trm.sameContent(&ts.trm); + return termSameContent && (index==ts.index || trm.isSpecialVar() || + (trm.isTerm() && ( + (trm.term()->shared() && trm.term()->ground()) || + trm.term()->arity()==0 ))); + } + + static bool equals(TermSpec t1, TermSpec t2){ + return t1.index == t2.index && TermList::equals(t1.trm, t2.trm); + } + + TermList trm; + int index; + + int bank() const { return index; } + bool isVar() const { return trm.isVar(); } + bool isSpecialVar() const { return trm.isSpecialVar(); } + bool isOrdinaryVar() const { return trm.isOrdinaryVar(); } + bool isTerm() const { return trm.isTerm(); } + bool isOutputVar() const { return isVar() && index == UNBOUND_INDEX; } +#if VHOL + bool containsLooseIndex() const { return trm.containsLooseIndex(); } +#endif + bool onBank() const { return true; } // always on a bank + unsigned var() const { ASS(trm.isVar()); return trm.var(); } + const Term* term() const { ASS(isTerm()); return trm.term(); } + TermList::Top top() const { return trm.top(); } + + TermSpec nthArg(unsigned i ) const { + ASS(isTerm()); + return TermSpec(trm.nthArg(i), index); + } + + /** WARNING implicit conversion */ + operator TermList() const {return trm;} + + friend std::ostream& operator<<(std::ostream& out, TermSpec const& self) + { return out << self.trm << "/" << self.index;; } + + TermSpec clone() const { return *this; } +}; + +template +class UnificationConstraint +{ +protected: + TermSpecOrList _t1; + TermSpecOrList _t2; + + using Constraint = UnificationConstraint; + using RobSubst = RobSubstitution; +public: + // TODO get rid of default constr + UnificationConstraint() {} + CLASS_NAME(UnificationConstraint) + USE_ALLOCATOR(UnificationConstraint) + + auto asTuple() const -> decltype(auto) { return std::tie(_t1, _t2); } + IMPL_COMPARISONS_FROM_TUPLE(UnificationConstraint); + IMPL_HASH_FROM_TUPLE(UnificationConstraint); + + Constraint clone() const { return Constraint(lhs(), rhs()); } + + UnificationConstraint(TermSpecOrList t1, TermSpecOrList t2) + : _t1(t1), _t2(t2) + {} + + Option toLiteral(RobSubst& s); + + TermSpecOrList const& lhs() const { return _t1; } + TermSpecOrList const& rhs() const { return _t2; } + + friend std::ostream& operator<<(std::ostream& out, Constraint const& self) + { return out << self._t1 << " != " << self._t2; } + +}; + +template +class UnificationConstraintStack +{ + using Constraint = UnificationConstraint; + using RobSubst = RobSubstitution; + + Stack _cont; +public: + CLASS_NAME(UnificationConstraintStack) + USE_ALLOCATOR(UnificationConstraintStack) + UnificationConstraintStack() : _cont() {} + UnificationConstraintStack(UnificationConstraintStack&&) = default; + UnificationConstraintStack& operator=(UnificationConstraintStack&&) = default; + + auto iter() const + { return iterTraits(_cont.iter()); } + + // only require these functions for termlists ... + Recycled> literals(RobSubst& s); + + auto literalIter(RobSubst& s) + { return iterTraits(_cont.iter()) + .filterMap([&](auto& c) { return c.toLiteral(s); }); } + + friend std::ostream& operator<<(std::ostream& out, UnificationConstraintStack const& self) + { return out << self._cont; } + + void reset() { _cont.reset(); } + bool keepRecycled() const { return _cont.keepRecycled() > 0; } + + bool isEmpty() const + { return _cont.isEmpty(); } + + void add(Constraint c, Option bd); + Constraint pop(Option bd); +}; + using namespace Lib; +namespace UnificationAlgorithms { + class AbstractingUnification; + class HOLUnification; + class HOLInstantiation; + class HOLGeneralisation; + class RobUnification; +} + +template class RobSubstitution :public Backtrackable { + friend class UnificationAlgorithms::AbstractingUnification; + friend class UnificationAlgorithms::HOLUnification; + friend class UnificationAlgorithms::HOLInstantiation; + friend class UnificationAlgorithms::HOLGeneralisation; + friend class UnificationConstraint; + + using Constraint = UnificationConstraint; + using ConstraintStack = UnificationConstraintStack; + using RobSubst = RobSubstitution; + public: CLASS_NAME(RobSubstitution); USE_ALLOCATOR(RobSubstitution); - RobSubstitution() : _funcSubtermMap(nullptr), _nextUnboundAvailable(0) {} - - SubstIterator matches(Literal* base, int baseIndex, - Literal* instance, int instanceIndex, bool complementary); - SubstIterator unifiers(Literal* l1, int l1Index, Literal* l2, int l2Index, bool complementary); - - bool unify(TermList t1,int index1, TermList t2, int index2, MismatchHandler* hndlr=0); - bool match(TermList base,int baseIndex, TermList instance, int instanceIndex); + RobSubstitution() : _nextUnboundAvailable(0) {} + virtual ~RobSubstitution() = default; + + /* When a `RobSubstitution` is applied to a Term by default the variables in the resulting + * Term will be in a new variable index, that starts mapping the first occurring + * variable in the output to X0, the second one to X1, .... + * In some cases this behaviour should be changed. For example if we a variables sigma such that + * `(s)sigma = t` using `RobSubstitution::match` we want that the variables are not assigned to a new + * index but to the same one as `t`. Therefore this function lets you set the output index of the + * substitution. + * + * Be aware that this is not possible when: + * - applying the substitution to variables that are not in the output index, that were not bound in the + * substitution (i.e. part of generalization operations, etc.) + * - computing unifications + */ + void setOutputIndex(VarBankOrInt idx) { _outputIndex = idx; } - bool unifyArgs(Term* t1,int index1, Term* t2, int index2, MismatchHandler* hndlr=0); - bool matchArgs(Term* base,int baseIndex, Term* instance, int instanceIndex); + // TODO, in the future create a separate function for applicative FOL unification. Will be cleaner + /* + * In the higher-order case, in some instances we want to carry out first-order applicative unification + * This the same as first-order unification, but we need an added check to ensure that we never bind a variable + * to a term that contains a loose index. To use this form of unification, the flag applicativeUnify is added. + */ + bool unify(TermSpecOrList t1, TermSpecOrList t2 +#if VHOL + , bool applicativeUnify = false +#endif + ); + bool match(TermSpecOrList base, TermSpecOrList instance, VarBankOrInt baseBank); - void denormalize(const Renaming& normalizer, int normalIndex, int denormalizedIndex); - bool isUnbound(unsigned var, int index) const + void denormalize(const Renaming& normalizer, VarBankOrInt normBank, VarBankOrInt denormBank); + bool isUnbound(unsigned var, VarBankOrInt bank) const { - return isUnbound(VarSpec(var,index)); + return isUnbound(TermSpecOrList(var, bank)); } void reset() { - _funcSubtermMap = 0; _bank.reset(); + _constr->reset(); _nextUnboundAvailable=0; + resetOutputIndex(); } + + Recycled constraints(){ return _constr->literals(*this); } + + bool keepRecycled() const { return _bank.keepRecycled(); } - void setMap(FuncSubtermMap* fmap){ - _funcSubtermMap = fmap; - } - /** - * Bind special variable to a specified term - * - * Calls to this method must happen before calls to any - * other methods. Also no special variables can occur in - * binding term, as no occur-check is performed. - */ - void bindSpecialVar(unsigned var, TermList t, int index) - { - VarSpec vs(var, SPECIAL_INDEX); - ASS(!_bank.find(vs)); - bind(vs, TermSpec(t,index)); - } - TermList getSpecialVarTop(unsigned specialVar) const; - TermList apply(TermList t, int index) const; - Literal* apply(Literal* lit, int index) const; - size_t getApplicationResultWeight(TermList t, int index) const; - size_t getApplicationResultWeight(Literal* lit, int index) const; + + TermList::Top getSpecialVarTop(unsigned specialVar) const; + Literal* apply(Literal* lit, VarBankOrInt bank) const; + Stack apply(Stack cl, VarBankOrInt bank) const; + size_t getApplicationResultWeight(Literal* lit, VarBankOrInt bank) const; + size_t getApplicationResultWeight(TermSpecOrList t, VarBankOrInt bank) const; + TermList apply(TermSpecOrList t, VarBankOrInt bank) const; + + virtual TermList apply(TermSpecOrList t) const = 0; + virtual TermSpecOrList getUnboundVar() const = 0; + virtual TermSpecOrList getLitArg(Literal* lit, unsigned idx, VarBankOrInt bank) const = 0; + virtual TermSpecOrList getLitSort(Literal* lit, VarBankOrInt bank) const = 0; + virtual bool isDefault(VarBankOrInt bank) const = 0; + virtual void resetOutputIndex() = 0; + + // functions are needed by so many other classes that it is + // easier to just make them public rather than adding other + // classes as friends + TermSpecOrList deref(TermSpecOrList v) const; + TermSpecOrList derefBound(TermSpecOrList const& v) const; #if VDEBUG /** @@ -94,189 +277,77 @@ class RobSubstitution * - Without backtracking, this number doesn't decrease. */ size_t size() const {return _bank.size(); } -#endif - - /** Specifies instance of a variable (i.e. (variable, variable bank) pair) */ - struct VarSpec - { - /** Create a new VarSpec struct */ - VarSpec() {} - /** Create a new VarSpec struct */ - VarSpec(unsigned var, int index) : var(var), index(index) {} - - bool operator==(const VarSpec& o) const - { return var==o.var && index==o.index; } - bool operator!=(const VarSpec& o) const - { return !(*this==o); } - - friend std::ostream& operator<<(std::ostream& out, VarSpec const& self); - - /** number of variable */ - unsigned var; - /** index of variable bank */ - int index; - - /** struct containing first hash function for DHMap object storing variable banks */ - struct Hash1 - { - static unsigned hash(VarSpec& o) { - return HashUtils::combine(o.var, o.index); - } - }; - /** struct containing second hash function for DHMap object storing variable banks */ - struct Hash2 - { - static unsigned hash(VarSpec& o) { - return HashUtils::combine(o.index, o.var); - } - }; - }; - /** Specifies an instance of a term (i.e. (term, variable bank) pair */ - struct TermSpec - { - /** Create a new TermSpec struct */ - TermSpec() : index(0) {} - /** Create a new TermSpec struct */ - TermSpec(TermList term, int index) : term(term), index(index) {} - /** Create a new TermSpec struct from a VarSpec*/ - explicit TermSpec(const VarSpec& vs) : index(vs.index) - { - if(index==SPECIAL_INDEX) { - term.makeSpecialVar(vs.var); - } else { - term.makeVar(vs.var); - } - } - /** - * If it's sure, that @b ts has the same content as this TermSpec, - * return true. If they don't (or it cannot be easily checked), return - * false. Only term content is taken into account, i.e. when two - * literals are pointer do by ts.term, their polarity is ignored. - */ - bool sameTermContent(const TermSpec& ts) - { - bool termSameContent=term.sameContent(&ts.term); - if(!termSameContent && term.isTerm() && term.term()->isLiteral() && - ts.term.isTerm() && ts.term.term()->isLiteral()) { - const Literal* l1=static_cast(term.term()); - const Literal* l2=static_cast(ts.term.term()); - if(l1->functor()==l2->functor() && l1->arity()==0) { - return true; - } - } - if(!termSameContent) { - return false; - } - return index==ts.index || term.isSpecialVar() || - (term.isTerm() && ( - (term.term()->shared() && term.term()->ground()) || - term.term()->arity()==0 )); - } - bool isVSpecialVar() - { - return term.isVSpecialVar(); - } +#endif + RobSubstitution(RobSubstitution&& obj) = default; + RobSubstitution& operator=(RobSubstitution&& obj) = default; - bool isVar() - { - return term.isVar(); - } - bool operator==(const TermSpec& o) const - { return term==o.term && index==o.index; } + VarBankOrInt outputBank() const { return _outputIndex; } - /** term reference */ - TermList term; - /** index of term to which it is bound */ - int index; - }; - typedef pair TTPair; - - /** struct containing first hash function of TTPair objects*/ - struct TTPairHash - { - static unsigned hash(TTPair& o) - { - return IdentityHash::hash(o.first.term.content())^o.first.index ^ - ((IdentityHash::hash(o.second.term.content())^o.second.index)<<1); - } - }; +protected: + typedef DHMap BankType; + mutable unsigned _nextUnboundAvailable; + BankType _bank; + Recycled _constr; + bool sameTermContent(TermSpecOrList t1, TermSpecOrList t2); + void bind(const TermSpecOrList& v, TermSpecOrList b); - friend std::ostream& operator<<(std::ostream& out, TermSpec const& self) - { return out << self.term << "/" << self.index; } + VarBankOrInt _outputIndex; - friend std::ostream& operator<<(std::ostream& out, VarSpec const& self) - { - if(self.index == SPECIAL_INDEX) { - return out << "S" << self.var; - } else { - return out << "X" << self.var << "/" << self.index; - } - } + VirtualIterator getAssocIterator(RobSubst* subst, + TermSpecOrList l1, TermSpecOrList s1, TermSpecOrList l2, TermSpecOrList s2, bool complementary); + struct AssocContext; + class AssocIterator; - RobSubstitution(RobSubstitution&& obj) = default; - RobSubstitution& operator=(RobSubstitution&& obj) = default; private: RobSubstitution(const RobSubstitution& obj) = delete; RobSubstitution& operator=(const RobSubstitution& obj) = delete; + bool isUnbound(TermSpecOrList v) const; - static const int SPECIAL_INDEX; - static const int UNBOUND_INDEX; - - bool isUnbound(VarSpec v) const; - TermSpec deref(VarSpec v) const; - TermSpec derefBound(TermSpec v) const; - - void addToConstraints(const VarSpec& v1, const VarSpec& v2,MismatchHandler* hndlr); - void bind(const VarSpec& v, const TermSpec& b); - void bindVar(const VarSpec& var, const VarSpec& to); - VarSpec root(VarSpec v) const; - bool match(TermSpec base, TermSpec instance); - bool unify(TermSpec t1, TermSpec t2,MismatchHandler* hndlr); - bool occurs(VarSpec vs, TermSpec ts); - - inline - VarSpec getVarSpec(TermSpec ts) const - { - return getVarSpec(ts.term, ts.index); + void pushConstraint(Constraint c){ + _constr->add(std::move(c), bd()); } - - VarSpec getVarSpec(TermList tl, int index) const - { - CALL("RobSubstitution::getVarSpec"); - ASS(tl.isVar()); - index = tl.isSpecialVar() ? SPECIAL_INDEX : index; - return VarSpec(tl.var(), index); + Constraint popConstraint(){ + return _constr->pop(bd()); + } + bool emptyConstraints(){ + return _constr->isEmpty(); } - typedef DHMap BankType; + TermSpecOrList root(TermSpecOrList v) const; + bool occurs(TermSpecOrList const& vs, TermSpecOrList const& ts); - FuncSubtermMap* _funcSubtermMap; - BankType _bank; - mutable unsigned _nextUnboundAvailable; + Option bd(){ + if(bdIsRecording()){ + return Option(bdGet()); + } else { + return Option(); + } + } - friend std::ostream& operator<<(std::ostream& out, RobSubstitution const& self) - { return out << self._bank; } + friend std::ostream& operator<<(std::ostream& out, RobSubst const& self) + { return out << "bindings: " << self._bank << "\n" << "constraints: " << self._constr; } class BindingBacktrackObject : public BacktrackObject { public: - BindingBacktrackObject(RobSubstitution* subst, VarSpec v) + BindingBacktrackObject(RobSubst* subst, TermSpecOrList v) :_subst(subst), _var(v) { - if(! _subst->_bank.find(_var,_term)) { - _term.term.makeEmpty(); + Option t = _subst->_bank.find(_var); + if(t) { + _term = some(*t); } } void backtrack() { - if(_term.term.isEmpty()) { - _subst->_bank.remove(_var); + if(_term.isNone()) { + _subst->_bank.remove(_var); } else { - _subst->_bank.set(_var,_term); + _subst->_bank.set(_var,std::move(*_term)); } } friend std::ostream& operator<<(std::ostream& out, BindingBacktrackObject const& self) @@ -284,25 +355,193 @@ class RobSubstitution CLASS_NAME(RobSubstitution::BindingBacktrackObject); USE_ALLOCATOR(BindingBacktrackObject); private: - RobSubstitution* _subst; - VarSpec _var; - TermSpec _term; + RobSubst* _subst; + TermSpecOrList _var; + Option _term; }; +}; - template - SubstIterator getAssocIterator(RobSubstitution* subst, - Literal* l1, int l1Index, Literal* l2, int l2Index, bool complementary); +class RobSubstitutionTL : public RobSubstitution +{ + friend class UnificationConstraint; - template - struct AssocContext; - template - class AssocIterator; +public: + + RobSubstitutionTL() { + _outputIndex = VarBank::OUTPUT_BANK; + } + + SubstIterator unifiers(Literal* l1, Literal* l2, bool complementary); - struct MatchingFn; - struct UnificationFn; + Literal* apply(Literal* lit, VarBank bank) const + { return RobSubstitution::apply(lit, bank); } + TermList apply(TermList t, VarBank bank) const + { return RobSubstitution::apply(t, bank); } + + /** + * Bind special variable to a specified term + * + * Calls to this method must happen before calls to any + * other methods. Also no special variables can occur in + * binding term, as no occur-check is performed. + */ + void bindSpecialVar(unsigned var, TermList t) + { + TermList vs(var, true); + + ASS(!_bank.find(vs)); + bind(vs, t); + } + +private: + /** This method should only be used when all variables of + * t are on a bank different to DEFAULT_BANK */ + virtual TermList apply(TermList t) const override + { return RobSubstitution::apply(t, DEFAULT_BANK); } + + virtual TermList getUnboundVar() const override + { return TermList(_nextUnboundAvailable++, VarBank::OUTPUT_BANK); } + + virtual TermList getLitArg(Literal* lit, unsigned idx, VarBank b) const override + { return *lit->nthArgument(idx); } + + virtual TermList getLitSort(Literal* lit, VarBank bank) const override + { ASS(lit->isTwoVarEquality()); return lit->twoVarEqSort(); } + + virtual bool isDefault(VarBank bank) const override + { return bank == VarBank::OUTPUT_BANK; } + + virtual void resetOutputIndex() override + { _outputIndex = VarBank::OUTPUT_BANK; } + + struct ToRobTermList; }; +// for backwards compatibility purposes +class RobSubstitutionTS : public RobSubstitution +{ + friend class UnificationConstraint; + +public: + + RobSubstitutionTS() { + _outputIndex = TermSpec::UNBOUND_INDEX; + } + + bool unify(TermList t1, int idx1, TermList t2, int idx2); + bool match(TermList t1, int idx1, TermList t2, int idx2); + + SubstIteratorTS unifiers(Literal* l1, int l1idx, Literal* l2, int l2idx, bool complementary); + + Literal* apply(Literal* lit, int index) const + { return RobSubstitution::apply(lit, index); } + + TermList apply(TermList t, int index) const + { return RobSubstitution::apply(TermSpec(t,index), index); } + +private: + + virtual TermList apply(TermSpec t) const override + { return RobSubstitution::apply(t, t.index); } + + virtual TermSpec getUnboundVar() const override + { return TermSpec(_nextUnboundAvailable++, TermSpec::UNBOUND_INDEX); } + + virtual TermSpec getLitArg(Literal* lit, unsigned idx, int b) const override + { return TermSpec(*lit->nthArgument(idx),b); } + + virtual TermSpec getLitSort(Literal* lit, int b) const override + { ASS(lit->isTwoVarEquality()); return TermSpec(lit->twoVarEqSort(),b); } + + virtual bool isDefault(int bank) const override + { return bank == TermSpec::UNBOUND_INDEX; } + + virtual void resetOutputIndex() override + { _outputIndex = TermSpec::UNBOUND_INDEX; } + + struct ToRobTermSpec; +}; + +using namespace Lib; + +template +struct AutoDerefTerm +{ + using RobSubst = RobSubstitution; + + TermSpecOrList term; + RobSubst const* subs; + VarBankOrInt bank; + + AutoDerefTerm(TermSpecOrList const& t, RobSubst const* s, VarBankOrInt b) + : subs(s) + , bank(b) { + CALL("AutoDerefTerm::AutoDerefTerm"); + + term = t.isOrdinaryVar() && !t.onBank() ? + s->derefBound(TermSpecOrList(t.var(), b)) : + s->derefBound(t); + } + + AutoDerefTerm clone() const { return { term, subs, bank }; } + explicit AutoDerefTerm(AutoDerefTerm const& other) : term(other.term), subs(other.subs), bank(other.bank) {} + AutoDerefTerm(AutoDerefTerm && other) = default; + friend std::ostream& operator<<(std::ostream& out, AutoDerefTerm const& self) + { return out << self.term << "@" << *self.subs; } + }; +}; + +namespace Lib { + + template<> + // struct BottomUpChildIter> + struct BottomUpChildIter> + { + using Item = Kernel::AutoDerefTerm; + Item _self; + unsigned _arg; + + BottomUpChildIter(Item const& self) : _self(Item(self)), _arg(0) {} + + Item self() { return _self.clone(); } + + Item next() + { return Item(_self.term.nthArg(_arg++), _self.subs, _self.bank); } + + bool hasNext() + { return _self.term.isTerm() && _arg < _self.term.term()->arity(); } + + unsigned nChildren() + { return _self.term.isVar() ? 0 : _self.term.term()->arity(); } + }; + + // TODO get rid of code duplication ... + template<> + struct BottomUpChildIter> + { + using Item = Kernel::AutoDerefTerm; + Item _self; + unsigned _arg; + + BottomUpChildIter(Item const& self) : _self(Item(self)), _arg(0) {} + + Item self() { return _self.clone(); } + + Item next() + { return Item(_self.term.nthArg(_arg++), _self.subs, _self.bank); } + + bool hasNext() + { return _self.term.isTerm() && _arg < _self.term.term()->arity(); } + + unsigned nChildren() + { return _self.term.isVar() ? 0 : _self.term.term()->arity(); } + }; + + + +} // namespace Lib + #endif /*__RobSubstitution__*/ diff --git a/Kernel/Signature.cpp b/Kernel/Signature.cpp index a860005b62..7349635296 100644 --- a/Kernel/Signature.cpp +++ b/Kernel/Signature.cpp @@ -60,7 +60,7 @@ Signature::Symbol::Symbol(const vstring& nm, unsigned arity, bool interpreted, b _skolem(0), _tuple(0), _prox(NOT_PROXY), - _comb(NOT_COMB) + _dbIndex(-1) { CALL("Signature::Symbol::Symbol"); ASS(!stringConstant || arity==0); @@ -248,8 +248,13 @@ Signature::Signature (): _rationals(0), _reals(0), _arrayCon(UINT_MAX), +#if VHOL _arrowCon(UINT_MAX), _appFun(UINT_MAX), + _lamFun(UINT_MAX), + _choiceFun(UINT_MAX), + _placeholderFun(UINT_MAX), +#endif _termAlgebras() { CALL("Signature::Signature"); @@ -722,7 +727,7 @@ unsigned Signature::addStringConstant(const vstring& name) return result; } // addStringConstant - +#if VHOL unsigned Signature::getApp() { CALL("Signature::getApp"); @@ -741,6 +746,24 @@ unsigned Signature::getApp() return app; } +unsigned Signature::getLam() +{ + CALL("Signature::getLam"); + + bool added = false; + unsigned lam = addFunction("vLAM", 3, added); + if(added){ + _lamFun = lam; + TermList tv1 = TermList(0, false); + TermList tv2 = TermList(1, false); + TermList arrowType = AtomicSort::arrowSort(tv1, tv2); + OperatorType* ot = OperatorType::getFunctionType({tv2}, arrowType, 2); + Symbol* sym = getFunction(lam); + sym->setType(ot); + } + return lam; +} + unsigned Signature::getDiff(){ CALL("Signature::getDiff"); @@ -764,6 +787,7 @@ unsigned Signature::getChoice(){ bool added = false; unsigned choice = addFunction("vEPSILON",1, added); if(added){ + _choiceFun = choice; TermList alpha = TermList(0, false); TermList bs = AtomicSort::boolSort(); TermList alphaBs = AtomicSort::arrowSort(alpha, bs); @@ -774,48 +798,38 @@ unsigned Signature::getChoice(){ return choice; } -void Signature::incrementFormulaCount(Term* t){ - CALL("Signature::incrementFormulaCount"); - ASS(SortHelper::getResultSort(t) == AtomicSort::boolSort()); - - if(_formulaCounts.find(t)){ - int count = _formulaCounts.get(t); - if(count != -1){ - _formulaCounts.set(t, count + 1); - } - } else { - _formulaCounts.set(t, 1); +unsigned Signature::getDeBruijnIndex(int index) +{ + CALL("Signature::addDeBruijnIndex"); + + bool added = false; + unsigned fun = addFunction("db" + Int::toString(index), 1, added); + if(added){ + TermList alpha = TermList(0, false); + Symbol * sym = getFunction(fun); + sym->setType(OperatorType::getConstantsType(alpha, 1)); + sym->setDBIndex(index); } + return fun; } -void Signature::decrementFormulaCount(Term* t){ - CALL("Signature::incrementFormulaCount"); - ASS(SortHelper::getResultSort(t) == AtomicSort::boolSort()); +unsigned Signature::getPlaceholder() +{ + CALL("Signature::getPlaceholder"); - ASS(_formulaCounts.find(t)) - int count = _formulaCounts.get(t); - if(count != -1){ - _formulaCounts.set(t, count - 1); + if(_placeholderFun != UINT_MAX){ + return _placeholderFun; } -} - -void Signature::formulaNamed(Term* t){ - CALL("Signature::formulaNamed"); - ASS(SortHelper::getResultSort(t) == AtomicSort::boolSort()); - ASS(_formulaCounts.find(t)); - _formulaCounts.set(t, -1); -} - -unsigned Signature::formulaCount(Term* t){ - CALL("Signature::formulaCount"); - - if(_formulaCounts.find(t)){ - return _formulaCounts.get(t); - } - return 0; + unsigned fun = addFreshFunction(1,"ph"); + _placeholderFun = fun; + TermList alpha = TermList(0, false); + Symbol * sym = getFunction(fun); + sym->setType(OperatorType::getConstantsType(alpha, 1)); + return fun; } +#endif /** * If a type constructor with this name and arity exists, return its number. @@ -901,7 +915,9 @@ unsigned Signature::addNameFunction(unsigned arity) { CALL("Signature::addNameFunction"); return addFreshFunction(arity,"sP"); -} // addNamePredicate +} // addNameFunction + + /** * Add fresh function of a given arity and with a given prefix. If suffix is non-zero, * the function name will be prefixI, where I is an integer, otherwise it will be diff --git a/Kernel/Signature.hpp b/Kernel/Signature.hpp index 05c12117f8..dfab065992 100644 --- a/Kernel/Signature.hpp +++ b/Kernel/Signature.hpp @@ -67,17 +67,6 @@ class Signature /** this is not a sort, it is just used to denote the first index of a user-define sort */ static const unsigned FIRST_USER_CON=5; - //Order is important - //Narrow.cpp relies on it - enum Combinator { - S_COMB, - B_COMB, - C_COMB, - I_COMB, - K_COMB, - NOT_COMB - }; - enum Proxy { AND, OR, @@ -157,7 +146,7 @@ class Signature /** proxy type */ Proxy _prox; /** combinator type */ - Combinator _comb; + int _dbIndex; public: /** standard constructor */ @@ -263,9 +252,13 @@ class Signature inline void setProxy(Proxy prox){ _prox = prox; } inline Proxy proxy(){ return _prox; } - - inline void setComb(Combinator comb){ _comb = comb; } - inline Combinator combinator(){ return _comb; } + +#if VHOL + inline void setDBIndex(int index){ _dbIndex = index; } + inline Option dbIndex(){ + return _dbIndex > -1 ? Option((unsigned)_dbIndex) : Option(); + } +#endif inline void markInductionSkolem(){ _inductionSkolem=1; _skolem=1;} inline bool inductionSkolem(){ return _inductionSkolem;} @@ -441,9 +434,15 @@ class Signature unsigned addNamePredicate(unsigned arity); unsigned addNameFunction(unsigned arity); void addEquality(); + +#if VHOL unsigned getApp(); + unsigned getLam(); unsigned getDiff(); unsigned getChoice(); + unsigned getDeBruijnIndex(int index); + unsigned getPlaceholder(); +#endif // Interpreted symbol declarations unsigned addIntegerConstant(const vstring& number,bool defaultSort); @@ -539,10 +538,15 @@ class Signature return _predNames.find(symbolKey,tmp); } +#if VHOL void addChoiceOperator(unsigned fun){ _choiceSymbols.insert(fun); } + void addInstantiation(TermList inst){ + _instantiations.insert(inst); + } + bool isChoiceOperator(unsigned fun){ return _choiceSymbols.contains(fun); } @@ -551,6 +555,11 @@ class Signature return &_choiceSymbols; } + DHSet* getInstantiations(){ + return &_instantiations; + } +#endif + /** return the number of functions */ unsigned functions() const { return _funs.length(); } /** return the number of predicates */ @@ -613,6 +622,18 @@ class Signature return con == BOOL_SRT_CON; } + bool isIntegerCon(unsigned con) const{ + return con == INTEGER_SRT_CON; + } + + bool isRealCon(unsigned con) const{ + return con == REAL_SRT_CON; + } + + bool isRationalCon(unsigned con) const{ + return con == RATIONAL_SRT_CON; + } + bool isTupleCon(unsigned con) { return getTypeCon(con)->tupleSort(); } @@ -623,6 +644,7 @@ class Signature return (con == _arrayCon && _arrayCon != UINT_MAX); } +#if VHOL bool isArrowCon(unsigned con) const{ return (con == _arrowCon && _arrowCon != UINT_MAX); } @@ -631,6 +653,19 @@ class Signature return (fun == _appFun && _appFun != UINT_MAX); } + bool isLamFun(unsigned fun) const{ + return (fun == _lamFun && _lamFun != UINT_MAX); + } + + bool isChoiceFun(unsigned fun) const{ + return (fun == _choiceFun && _choiceFun != UINT_MAX); + } + + bool isPlaceholder(unsigned fun) const{ + return (fun == _placeholderFun && _placeholderFun != UINT_MAX); + } +#endif + bool tryGetFunctionNumber(const vstring& name, unsigned arity, unsigned& out) const; bool tryGetPredicateNumber(const vstring& name, unsigned arity, unsigned& out) const; unsigned getFunctionNumber(const vstring& name, unsigned arity) const; @@ -724,6 +759,7 @@ class Signature return ratSort; } +#if VHOL unsigned getArrowConstructor(){ bool added = false; unsigned arrow = addTypeCon("sTfun",2, added); @@ -735,6 +771,7 @@ class Signature } return arrow; } +#endif unsigned getArrayConstructor(){ bool added = false; @@ -760,6 +797,7 @@ class Signature return tuple; } +#if VHOL unsigned getEqualityProxy(){ bool added = false; unsigned eqProxy = addFunction("vEQ",1, added); @@ -823,72 +861,7 @@ class Signature } return proxy; } //TODO merge with above? - - //TODO make all these names protected - - unsigned getCombinator(Combinator c){ - bool added = false; - unsigned comb; - - auto convert = [] (Combinator cb) { - switch(cb){ - case S_COMB: - return "sCOMB"; - case C_COMB: - return "cCOMB"; - case B_COMB: - return "bCOMB"; - case K_COMB: - return "kCOMB"; - default: - return "iCOMB"; - } - }; - - vstring name = convert(c); - if(c == S_COMB || c == B_COMB || c == C_COMB){ - comb = addFunction(name,3, added); - } else if ( c == K_COMB) { - comb = addFunction(name,2, added); - } else { - comb = addFunction(name,1, added); - } - - if(added){ - unsigned typeArgsArity = 3; - TermList x0 = TermList(0, false); - TermList x1 = TermList(1, false); - TermList x2 = TermList(2, false); - TermList t0 = AtomicSort::arrowSort(x1, x2); - TermList t1 = AtomicSort::arrowSort(x0, t0); - TermList t2 = AtomicSort::arrowSort(x0, x1); - TermList t3 = AtomicSort::arrowSort(x0, x2); - TermList sort; - if(c == S_COMB){ - sort = AtomicSort::arrowSort(t1, t2, t3); - }else if(c == C_COMB){ - sort = AtomicSort::arrowSort(t1, x1, t3); - }else if(c == B_COMB){ - sort = AtomicSort::arrowSort(t0, t2, t3); - }else if(c == K_COMB){ - typeArgsArity = 2; - sort = AtomicSort::arrowSort(x0, x1 , x0); - }else if(c == I_COMB){ - typeArgsArity = 1; - sort = AtomicSort::arrowSort(x0, x0); - } - - Symbol* sym = getFunction(comb); - sym->setType(OperatorType::getConstantsType(sort, typeArgsArity)); - sym->setComb(c); - } - return comb; - } - - void incrementFormulaCount(Term* t); - void decrementFormulaCount(Term* t); - void formulaNamed(Term* t); - unsigned formulaCount(Term* t); +#endif bool isTermAlgebraSort(TermList sort) { return _termAlgebras.find(sort); } @@ -906,7 +879,6 @@ class Signature private: Stack _dividesNvalues; - DHMap _formulaCounts; bool _foolConstantsDefined; unsigned _foolTrue; @@ -921,7 +893,11 @@ class Signature /** Stack of type constructor symbols */ Stack _typeCons; +#if VHOL + // TODO these two don't belong in the signature DHSet _choiceSymbols; + DHSet _instantiations; +#endif /** * Map from vstring "name_arity" to their numbers * @@ -971,8 +947,13 @@ class Signature unsigned _reals; unsigned _arrayCon; +#if VHOL unsigned _arrowCon; unsigned _appFun; + unsigned _lamFun; + unsigned _choiceFun; + unsigned _placeholderFun; +#endif /** * Map from sorts to the associated term algebra, if applicable for the sort diff --git a/Kernel/SortHelper.cpp b/Kernel/SortHelper.cpp index b2360e5d57..abb9d4b2bf 100644 --- a/Kernel/SortHelper.cpp +++ b/Kernel/SortHelper.cpp @@ -55,7 +55,7 @@ OperatorType* SortHelper::getType(Term* t) * * @author Ahmed Bhayat */ -void SortHelper::getTypeSub(const Term* t, Substitution& subst) +bool SortHelper::getTypeSub(const Term* t, Substitution& subst) { CALL("SortHelper::getTypeSub(Term*)"); @@ -64,13 +64,21 @@ void SortHelper::getTypeSub(const Term* t, Substitution& subst) unsigned typeArgsArity = ot->numTypeArguments(); //cout << "typeArgsArity " << typeArgsArity << endl; + bool resultShared = true; typeArg = const_cast(t->args()); for(unsigned i = 0; i < typeArgsArity; i++){ TermList var = ot->quantifiedVar(i); ASS_REP(var.isVar(), t->toString()); + // when working with substitution trees we sometimes need to find the sort + // of terms within the tree. These terms can contain special variables + // and may therefore not be shared. + if(typeArg->isSpecialVar() || (typeArg->isTerm() && !typeArg->term()->shared())){ + resultShared = false; + } subst.bind(var.var(), *typeArg); typeArg = typeArg->next(); } + return resultShared; } // getTypeSub /** @@ -88,16 +96,21 @@ TermList SortHelper::getResultSort(const Term* t) ASS(!t->isSpecial()); ASS(!t->isLiteral()); + //cout << "TERM " << t->toString() << endl; + if(t->isSort()){ return TermList(AtomicSort::superSort()); } Substitution subst; - getTypeSub(t, subst); + bool shared = getTypeSub(t, subst); + + //cout << "SHARED " << shared << endl; + Signature::Symbol* sym = env.signature->getFunction(t->functor()); TermList result = sym->fnType()->result(); ASS(!subst.isEmpty() || (result.isTerm() && (result.term()->isSuper() || result.term()->ground()))); - return SubstHelper::apply(result, subst); + return SubstHelper::apply(result, subst, !shared); } TermList SortHelper::getResultSortMono(const Term* t) @@ -173,10 +186,12 @@ bool SortHelper::getResultSortOrMasterVariable(const Term* t, TermList& resultSo case Term::SF_FORMULA: resultSort = AtomicSort::boolSort(); return true; +#if VHOL case Term::SF_LAMBDA: { resultSort = t->getSpecialData()->getSort(); return true; } +#endif case Term::SF_TUPLE: { resultSort = getResultSort(t->getSpecialData()->getTupleTerm()); return true; @@ -227,8 +242,8 @@ TermList SortHelper::getArgSort(Term* t, unsigned argIndex) return AtomicSort::superSort(); } - getTypeSub(t, subst); - return SubstHelper::apply(ot->arg(argIndex), subst); + bool shared = getTypeSub(t, subst); + return SubstHelper::apply(ot->arg(argIndex), subst, !shared); } // getArgSort /* returns the sort of the nth term argument */ @@ -307,14 +322,21 @@ bool SortHelper::tryGetVariableSort(unsigned var, Formula* f, TermList& res) // first handle the special equality case if(lit->isEquality()){ - TermList* left = lit->nthArgument(0); - TermList* right = lit->nthArgument(1); - if((left->isVar() && left->var()==var) || - (right->isVar() && right->var()==var)){ - - res = getEqualityArgumentSort(lit); - return true; - } + TermList* left = lit->nthArgument(0); + TermList* right = lit->nthArgument(1); + if((left->isVar() && left->var()==var) || + (right->isVar() && right->var()==var)){ + + res = getEqualityArgumentSort(lit); + return true; + } + if(lit->isTwoVarEquality()){ + TermList sort = lit->twoVarEqSort(); + if(sort.containsSubterm(varTerm)){ + res = AtomicSort::superSort(); + return true; + } + } } if(tryGetVariableSort(varTerm, lit, res)){ return true; @@ -483,6 +505,7 @@ void SortHelper::collectVariableSortsIter(CollectTask task, DHMapgetFormula(); todo.push(newTask); } break; +#if VHOL case Term::SF_LAMBDA: { CollectTask newTask; newTask.fncTag = COLLECT_TERMLIST; @@ -490,7 +513,7 @@ void SortHelper::collectVariableSortsIter(CollectTask task, DHMapgetLambdaExp(); todo.push(newTask); } break; - +#endif case Term::SF_TUPLE: { CollectTask newTask; newTask.fncTag = COLLECT_TERM; @@ -833,6 +856,7 @@ bool SortHelper::tryGetVariableSort(TermList var, Term* t0, TermList& result) return true; } } +#if VHOL if (t->isLambda()) { TermList sort = t->getSpecialData()->getLambdaExpSort(); TermList lambdaTerm = t->getSpecialData()->getLambdaExp(); @@ -849,6 +873,7 @@ bool SortHelper::tryGetVariableSort(TermList var, Term* t0, TermList& result) } continue; } +#endif if (t->isMatch()) { for (unsigned int i = 0; i < t->arity(); i++) { auto arg = t->nthArgument(i); @@ -916,6 +941,16 @@ bool SortHelper::areImmediateSortsValidPoly(Term* t) TermList argSort = getResultSort(ta); TermList instantiatedTypeSort = SubstHelper::apply(type->arg(i), subst); if (instantiatedTypeSort != argSort) { + +#if VDEBUG + cout << "the term is " + t->toString() << endl; + cout << "the type of function " + env.signature->getFunction(t->functor())->name() + " is: " + type->toString() << endl; + //cout << "function name : "+ env.signature->getFunction(t->functor())->name() << endl; + //cout << "function name 2 :" + t->functionName() << endl; + cout << "error with expected " << instantiatedTypeSort.toString() << " and actual " << argSort.toString() << " when functor is " << t->functor() << " and arg is " << arg << endl; + ASSERTION_VIOLATION; +#endif + return false; } } diff --git a/Kernel/SortHelper.hpp b/Kernel/SortHelper.hpp index ece2350118..c116bcb63e 100644 --- a/Kernel/SortHelper.hpp +++ b/Kernel/SortHelper.hpp @@ -85,7 +85,7 @@ class SortHelper { static OperatorType* getType(Term* t); - static void getTypeSub(const Term* t, Substitution& subst); + static bool getTypeSub(const Term* t, Substitution& subst); static bool areSortsValid(Clause* cl); static bool areSortsValid(Term* t); diff --git a/Kernel/SubformulaIterator.cpp b/Kernel/SubformulaIterator.cpp index 2e4fb0803c..dbf9097b35 100644 --- a/Kernel/SubformulaIterator.cpp +++ b/Kernel/SubformulaIterator.cpp @@ -198,6 +198,7 @@ bool SubformulaIterator::hasNext () _reserve = rest; return true; } +#if VHOL case Term::SF_LAMBDA: { delete _reserve; TermList lambdaExp = term->getSpecialData()->getLambdaExp(); @@ -209,6 +210,7 @@ bool SubformulaIterator::hasNext () } break; } +#endif case Term::SF_TUPLE: { delete _reserve; Term* tupleTerm = term->getSpecialData()->getTupleTerm(); diff --git a/Kernel/SubstHelper.hpp b/Kernel/SubstHelper.hpp index 6360ba6e98..615e6d2f14 100644 --- a/Kernel/SubstHelper.hpp +++ b/Kernel/SubstHelper.hpp @@ -196,8 +196,8 @@ class SubstHelper for(unsigned i=0;ishared())) { - return false; + if(trm.isSpecialVar()||(trm.isTerm()&&!trm.term()->shared())) { + return false; } } return true; @@ -392,7 +392,7 @@ Term* SubstHelper::applyImpl(Term* trm, Applicator& applicator, bool noSharing) } continue; } - ASS(tl.isVSpecialVar() || tl.isTerm()); + ASS(tl.isTerm()); if(tl.isVar() || (tl.term()->shared() && tl.term()->ground())) { args->push(tl); continue; @@ -427,14 +427,16 @@ Term* SubstHelper::applyImpl(Term* trm, Applicator& applicator, bool noSharing) Literal* lit = static_cast(trm); result=Literal::create(lit,argLst); } else if(trm->isSort()){ - ASS(!noSharing); - result=AtomicSort::create(static_cast(trm),argLst); + if(!noSharing){ + result=AtomicSort::create(static_cast(trm),argLst); + } else { + result=AtomicSort::createNonShared(static_cast(trm),argLst); + } } else { bool shouldShare=!noSharing && canBeShared(argLst, trm->arity()); if(shouldShare) { result=Term::create(trm,argLst); } else { - //At the memoent all sorts should be shared. result=Term::createNonShared(trm,argLst); } } diff --git a/Kernel/Term.cpp b/Kernel/Term.cpp index b7dd9b9a1c..e87b2f3fd2 100644 --- a/Kernel/Term.cpp +++ b/Kernel/Term.cpp @@ -20,6 +20,10 @@ #include "SubstHelper.hpp" #include "TermIterators.hpp" #include "RobSubstitution.hpp" +#include "TermTransformer.hpp" +#if VHOL +#include "ApplicativeHelper.hpp" +#endif #include "Lib/Metaiterators.hpp" #include "Term.hpp" @@ -31,7 +35,9 @@ using namespace Kernel; const unsigned Term::SF_ITE; const unsigned Term::SF_LET; const unsigned Term::SF_FORMULA; +#if VHOL const unsigned Term::SF_LAMBDA; +#endif const unsigned Term::SPECIAL_FUNCTOR_LOWER_BOUND; void Term::setId(unsigned id) @@ -69,7 +75,7 @@ void Term::destroy () { CALL("Term::destroy"); ASS(CHECK_LEAKS || ! shared()); - + size_t sz = sizeof(Term)+_arity*sizeof(TermList)+getPreDataSize(); void* mem = this; mem = reinterpret_cast(reinterpret_cast(mem)-getPreDataSize()); @@ -83,7 +89,10 @@ void Term::destroyNonShared() { CALL("Term::destroyNonShared"); - if (shared()) { + // TODO currently we insert superSort into + // substitution trees in a few specialised places + // Omce we get rid of this can remove the isSuper check + if (shared() || isSuper()) { return; } TermList selfRef; @@ -110,6 +119,9 @@ void Term::destroyNonShared() } } +bool TermList::ground() const +{ return isTerm() && term()->ground(); } + /** * Return true if the term does not contain any unshared proper term. * @@ -174,7 +186,7 @@ bool TermList::isFreeVariable(unsigned var) const bool TermList::sameTop(TermList ss,TermList tt) { if (ss.isVar()) { - return ss==tt; + return ss == tt; } if (tt.isVar()) { return false; @@ -188,6 +200,8 @@ bool TermList::sameTop(TermList ss,TermList tt) */ bool TermList::sameTopFunctor(TermList ss, TermList tt) { + CALL("TermList::sameTopFunctor"); + if (!ss.isTerm() || !tt.isTerm()) { return false; } @@ -200,6 +214,8 @@ bool TermList::sameTopFunctor(TermList ss, TermList tt) */ bool TermList::equals(TermList t1, TermList t2) { + CALL("TermList::equals"); + static Stack stack(8); ASS(stack.isEmpty()); @@ -216,7 +232,7 @@ bool TermList::equals(TermList t1, TermList t2) stack.push(s->args()); stack.push(t->args()); } - else if (ss->content()!=tt->content()) { + else if (*ss != *tt) { stack.reset(); return false; } @@ -234,11 +250,28 @@ bool TermList::equals(TermList t1, TermList t2) return true; } +TermList::Top TermList::top(bool splittable) const +{ + CALL("TermList::top"); + + if(!splittable){ + ASS(isTerm()); + ASS(term()->shared()); // TODO is this valid??? + + return TermList::Top::nonsplittable(term()->getId()); + } + + return isTerm() ? TermList::Top::functor(term()->functor()) + : TermList::Top::var(var()); +} + /** * Return true if all proper terms in the @ args list are shared */ bool TermList::allShared(TermList* args) { + CALL("TermList::allShared"); + while (args->isNonEmpty()) { if (args->isTerm() && !args->term()->shared()) { return false; @@ -253,6 +286,7 @@ unsigned TermList::weight() const return isVar() ? 1 : term()->weight(); } +#if VHOL bool TermList::isArrowSort() { CALL("TermList::isArrowSort"); @@ -260,6 +294,14 @@ bool TermList::isArrowSort() static_cast(term())->isArrowSort(); } +bool Term::isArrowSort() const +{ + CALL("Term::isArrowSort"); + return isSort() && env.signature->isArrowCon(_functor); +} + +#endif + bool TermList::isBoolSort() { CALL("TermList::isBoolSort"); @@ -281,11 +323,100 @@ bool TermList::isTupleSort() static_cast(term())->isTupleSort(); } +bool TermList::isIntSort(){ + CALL("TermList::isIntSort"); + return !isVar() && term()->isSort() && + static_cast(term())->isIntSort(); +} + +bool TermList::isRatSort(){ + CALL("TermList::isRatSort"); + return !isVar() && term()->isSort() && + static_cast(term())->isRatSort(); +} + +bool TermList::isRealSort(){ + CALL("TermList::isRealSort"); + return !isVar() && term()->isSort() && + static_cast(term())->isRealSort(); +} + +#if VHOL + +TermList AtomicSort::domain(){ + CALL("AtomicSort::domain"); + ASS(isArrowSort()); + + return *nthArgument(0); +} + +TermList TermList::domain(){ + CALL("TermList::domain"); + ASS(isArrowSort()); + + return *term()->nthArgument(0); +} + +TermList TermList::result(){ + CALL("TermList::result"); + ASS(isArrowSort()); + + return *term()->nthArgument(1); +} + +TermList TermList::finalResult(){ + CALL("TermList::finalResult"); + + return isVar() || !isArrowSort() ? *this : static_cast(term())->finalResult(); +} + +TermList TermList::whnfDeref(RobSubstitutionTL* sub){ + CALL("TermList::whnfDeref"); + + return WHNFDeref(sub).normalise(*this); +} + +TermList TermList::betaNF(){ + CALL("TermList::betaNF"); + + return BetaNormaliser().normalise(*this); +} + +TermList TermList::etaNF(){ + CALL("TermList::etaNF"); + + return EtaNormaliser().normalise(*this); +} + +TermList TermList::betaEtaNF(){ + CALL("TermList::betaEtaNF"); + + return this->betaNF().etaNF(); +} + +TermList AtomicSort::result(){ + CALL("AtomicSort::result"); + ASS(isArrowSort()); + + return *nthArgument(1); +} + +TermList AtomicSort::finalResult(){ + CALL("AtomicSort::finalResult"); + + TermList trm(this); + while(trm.isArrowSort()){ + trm = trm.result(); + } + return trm; +} + bool AtomicSort::isArrowSort() const { CALL("AtomicSort::isArrowSort"); return env.signature->isArrowCon(_functor); } +#endif bool AtomicSort::isBoolSort() const { CALL("AtomicSort::isBoolSort"); @@ -305,8 +436,28 @@ bool AtomicSort::isTupleSort() const { return env.signature->isTupleCon(_functor); } +bool AtomicSort::isIntSort() const { + CALL("AtomicSort::isIntSort"); + + return env.signature->isIntegerCon(_functor); +} + +bool AtomicSort::isRatSort() const { + CALL("AtomicSort::isRatSort"); + + return env.signature->isRationalCon(_functor); +} + +bool AtomicSort::isRealSort() const { + CALL("AtomicSort::isRealSort"); + + return env.signature->isRealCon(_functor); +} + +#if VHOL + bool TermList::isApplication() const { - CALL("Term::isApplication"); + CALL("TermList::isApplication"); return !isVar() && term()->isApplication(); } @@ -314,9 +465,300 @@ bool TermList::isApplication() const { bool Term::isApplication() const { CALL("Term::isApplication"); - return !isSort() && !isLiteral() && env.signature->isAppFun(_functor); + return !isSort() && !isLiteral() && !isSpecial() && env.signature->isAppFun(_functor); +} + +TermList TermList::lhs() const { + CALL("TermList::lhs"); + ASS(isApplication()); + return *term()->nthArgument(2); +} + +TermList TermList::rhs() const { + CALL("TermList::rhs"); + ASS(isApplication()); + return *term()->nthArgument(3); +} + +TermList TermList::lambdaBody() const { + CALL("TermList::lambdaBody"); + ASS(isLambdaTerm()); + return *term()->nthArgument(2); +} + +TermList TermList::head() { + CALL("TermList::head"); + if(!isApplication() && !isLambdaTerm()){ + return *this; + } + return term()->head(); +} + +TermList Term::head() { + CALL("Term::head"); + + TermList trm = TermList(this); + while(trm.isLambdaTerm()){ + trm = trm.lambdaBody(); + } + while(trm.isApplication()){ + trm = trm.lhs(); + } + return trm; +} + +bool TermList::isLambdaTerm() const { + CALL("TermList::isLambdaTerm"); + + return !isVar() && term()->isLambdaTerm(); +} + +bool Term::isLambdaTerm() const { + CALL("Term::isLambdaTerm"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->isLamFun(_functor); +} + +bool TermList::isEtaExpandedVar(TermList& var) const { + CALL("TermList::isEtaExpandedVar"); + + return ApplicativeHelper::isEtaExpandedVar(*this, var); +} + +bool TermList::isRedex() { + CALL("TermList::isRedex"); + + return isApplication() && lhs().isLambdaTerm(); +} + +bool Term::isRedex() { + CALL("Term::isRedex"); + + return TermList(this).isRedex(); +} + +bool TermList::isNot() const { + CALL("TermList::isNot"); + + return !isVar() && term()->isNot(); +} + +bool Term::isNot() const { + CALL("Term::isNot"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::NOT; +} + +bool TermList::isSigma() const { + CALL("TermList::isSigma"); + + return !isVar() && term()->isSigma(); +} + +bool Term::isSigma() const { + CALL("Term::isSigma"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::SIGMA; +} + +bool TermList::isPi() const { + CALL("TermList::isPi"); + + return !isVar() && term()->isPi(); +} + +bool Term::isPi() const { + CALL("Term::isPi"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::PI; +} + +bool TermList::isIff() const { + CALL("TermList::isIff"); + + return !isVar() && term()->isIff(); +} + +bool Term::isIff() const { + CALL("Term::isIff"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::IFF; +} + +bool TermList::isAnd() const { + CALL("TermList::isAnd"); + + return !isVar() && term()->isAnd(); +} + +bool Term::isAnd() const { + CALL("Term::isAnd"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::AND; +} + +bool TermList::isOr() const { + CALL("TermList::isOr"); + + return !isVar() && term()->isOr(); +} + +bool Term::isOr() const { + CALL("Term::isOr"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::OR; +} + +bool TermList::isXOr() const { + CALL("TermList::isXOr"); + + return !isVar() && term()->isXOr(); +} + +bool Term::isXOr() const { + CALL("Term::isXOr"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::XOR; +} + +bool TermList::isImp() const { + CALL("TermList::isImp"); + + return !isVar() && term()->isImp(); +} + +bool Term::isImp() const { + CALL("Term::isImp"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::IMP; +} + +bool TermList::isEquals() const { + CALL("TermList::isEquals"); + + return !isVar() && term()->isEquals(); +} + +bool Term::isEquals() const { + CALL("Term::isEquals"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->getFunction(_functor)->proxy() == Signature::EQUALS; +} + +bool TermList::isPlaceholder() const { + CALL("TermList::isPlaceholder"); + + return !isVar() && term()->isPlaceholder(); +} + +bool Term::isPlaceholder() const { + CALL("Term::isPlaceholder"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->isPlaceholder(_functor); +} + +bool TermList::isChoice() const { + CALL("TermList::isChoice"); + + return !isVar() && term()->isChoice(); +} + +bool Term::isChoice() const { + CALL("Term::isChoice"); + + return !isSort() && !isLiteral() && !isSpecial() && env.signature->isChoiceFun(_functor); +} + +bool TermList::containsLooseIndex() const { + CALL("TermList::containsLooseIndex()"); + + struct TermListWD { + TermList t; + unsigned depth; + }; + + auto needToCheck = [](TermList t){ + if(t.isVar() || (t.term()->shared() && !t.term()->hasDBIndex())) return false; + return true; + }; + + Stack toDo; + toDo.push( TermListWD { .t = *this, .depth = 0, }); + + while(!toDo.isEmpty()){ + auto item = toDo.pop(); + + if(!needToCheck(item.t)){ + continue; + } + + unsigned dep = item.depth; + if(item.t.deBruijnIndex().isSome()){ + unsigned idx = item.t.deBruijnIndex().unwrap(); + if(idx >= dep) + { return true; } + } + if(item.t.isLambdaTerm()){ + toDo.push(TermListWD { .t = item.t.lambdaBody(), .depth = dep + 1, } ); + } + if(item.t.isApplication()){ + toDo.push(TermListWD { .t = item.t.lhs(), .depth = dep, } ); + toDo.push(TermListWD { .t = item.t.rhs(), .depth = dep, } ); + } + } + return false; +} + +unsigned TermList::numOfAppVarsAndLambdas() const { + CALL("TermList::numOfAppVarsAndLambdas"); + + if (isVar()) { + return 0; + } + const Term* t = term(); + + static DHMap cache; + + unsigned* cached; + if (!cache.getValuePtr(t,cached)) { + return *cached; + } + + // it's OK that the entry in cache has already been created, will only possibly ask for proper subterms + + unsigned res = 0; + + if (isLambdaTerm()) { + res = env.options->hoFeaturesLambdaWeight() + lambdaBody().numOfAppVarsAndLambdas(); + } else if (isApplication()) { + TermList head; + TermStack args; + ApplicativeHelper::getHeadAndArgs(t, head, args); + ASS(!head.isLambdaTerm()); // should be beta-reduced + if(head.isVar()) { + res += env.options->hoFeaturesAppVarWeight(); + } + while(!args.isEmpty()){ + res += args.pop().numOfAppVarsAndLambdas(); + } + } + + *cached = res; + return res; +} + +Option TermList::deBruijnIndex() const { + CALL("TermList::deBruijnIndex"); + return isVar() ? Option() : term()->deBruijnIndex(); +} + +Option Term::deBruijnIndex() const { + CALL("Term::deBruijnIndex"); + return isSort() || isLiteral() || isSpecial() ? Option() : env.signature->getFunction(_functor)->dbIndex(); } +#endif + unsigned Term::numTypeArguments() const { CALL("Term::numTypeArguments"); ASS(!isSort()); @@ -328,7 +770,7 @@ unsigned Term::numTypeArguments() const { : env.signature->getFunction(_functor)->numTypeArguments(); } -TermList* Term::termArgs() +const TermList* Term::termArgs() const { CALL("Term::termArgs"); ASS(!isSort()); @@ -350,6 +792,35 @@ unsigned Term::numTermArguments() const return _arity - numTypeArguments(); } +TermList TermList::toBank(VarBank b) +{ + CALL("TermList::toBank"); + + if(isVar()) + return TermList(_var.var, b); + + return TermList(term()->toBank(b)); +} + +TermList TermList::nthArg(unsigned i) const { + ASS(isTerm()); + return *term()->nthArgument(i); +} + +Term* Term::toBank(VarBank b) +{ + CALL("Term::toBank"); + + return ToBank(b).toBank(this); +} + +Literal* Literal::toBank(VarBank b) +{ + CALL("Literal::toBank"); + + return ToBank(b).toBank(this); +} + bool TermList::containsSubterm(TermList trm) { CALL("Term::containsSubterm"); @@ -506,8 +977,14 @@ vstring Term::variableToString(TermList var) CALL("Term::variableToString"); ASS(var.isVar()); + bool outputBanks = false; +#if VDEBUG + outputBanks = env.options->printVarBanks(); +#endif + if (var.isOrdinaryVar()) { - return (vstring)"X" + Int::toString(var.var()); + return (vstring)"X" + Int::toString(var.var()) + (outputBanks ? + " / " + Int::toString((int)var.bank()) : ""); } else { return (vstring)"S" + Int::toString(var.var()); @@ -585,7 +1062,7 @@ vstring Term::headToString() const vstring symbolsList = ""; vstring typesList = ""; for (unsigned i = 0; i < VList::length(symbols); i++) { - Signature::Symbol* symbol = (fnType->arg(i) == AtomicSort::boolSort()) + Signature::Symbol* symbol = (fnType->arg(i).isBoolSort()) ? env.signature->getPredicate(VList::nth(symbols, i)) : env.signature->getFunction(VList::nth(symbols, i)); symbolsList += symbol->name(); @@ -598,27 +1075,11 @@ vstring Term::headToString() const return "$let([" + typesList + "], [" + symbolsList + "] := " + binding.toString() + ", "; } - case Term:: SF_LAMBDA: { - VList* vars = sd->getLambdaVars(); - SList* sorts = sd->getLambdaVarSorts(); - TermList lambdaExp = sd->getLambdaExp(); - - vstring varList = "["; - - VList::Iterator vs(vars); - SList::Iterator ss(sorts); - TermList sort; - bool first = true; - while(vs.hasNext()) { - if (!first){ - varList += ", "; - }else{ first = false; } - varList += Term::variableToString(vs.next()) + " : "; - varList += ss.next().toString(); - } - varList += "]"; - return "(^" + varList + " : (" + lambdaExp.toString() + "))"; - } +#if VHOL + case Term::SF_LAMBDA: + // we can get here if holPrinting set to RAW + return lambdaToString(sd); +#endif case Term::SF_MATCH: { // we simply let the arguments be written out return "$match("; @@ -631,8 +1092,6 @@ vstring Term::headToString() const if (!isSort() && Theory::tuples()->findProjection(functor(), isLiteral(), proj)) { return "$proj(" + Int::toString(proj) + ", "; } - bool print = (isLiteral() || isSort() || - (env.signature->getFunction(_functor)->combinator() == Signature::NOT_COMB)) && arity(); vstring name = ""; if(isLiteral()) { name = static_cast(this)->predicateName(); @@ -641,7 +1100,7 @@ vstring Term::headToString() const } else { name = functionName(); } - return name + (print ? "(" : ""); + return name + (arity() ? "(" : ""); } } @@ -682,11 +1141,6 @@ vstring TermList::asArgsToString() const continue; } const Term* t = ts->term(); - - if(!(t->isSort() && static_cast(const_cast(t))->isArrowSort())){ - res += t->toString(); - continue; - } res += t->headToString(); @@ -702,7 +1156,7 @@ vstring TermList::asArgsToString() const * Write as a vstring the head of the term list. * @since 27/02/2008 Manchester */ -vstring TermList::toString(bool topLevel) const +vstring TermList::toString() const { CALL("TermList::toString"); @@ -712,7 +1166,19 @@ vstring TermList::toString(bool topLevel) const if (isVar()) { return Term::variableToString(*this); } - return term()->toString(topLevel); + +#if VHOL + if(env.property->higherOrder() && env.options->holPrinting() == Options::HPrinting::PRETTY){ + if(ApplicativeHelper::isTrue(*this)){ + return "⊤"; + } + if(ApplicativeHelper::isFalse(*this)){ + return "⊥"; + } + } +#endif + + return term()->toString(); } // TermList::toString @@ -720,39 +1186,215 @@ vstring TermList::toString(bool topLevel) const * Return the result of conversion of a term into a vstring. * @since 16/05/2007 Manchester */ -vstring Term::toString(bool topLevel) const +vstring Term::toString() const { CALL("Term::toString"); - bool printArgs = true; - if(isSuper()){ return "$tType"; } - if(!isSpecial() && !isLiteral()){ - if(isSort() && static_cast(const_cast(this))->isArrowSort()){ - ASS(arity() == 2); - vstring res; - TermList arg1 = *(nthArgument(0)); - TermList arg2 = *(nthArgument(1)); - res += topLevel ? "" : "("; - res += arg1.toString(false) + " > " + arg2.toString(); - res += topLevel ? "" : ")"; - return res; - } - - printArgs = isSort() || env.signature->getFunction(_functor)->combinator() == Signature::NOT_COMB; +#if VHOL + if(env.property->higherOrder() && env.options->holPrinting() != Options::HPrinting::RAW){ + IndexVarStack st; + return toString(true, st); } +#endif vstring s = headToString(); - if (_arity && printArgs) { + if (_arity) { s += args()->asArgsToString(); // will also print the ')' } return s; } // Term::toString +#if VHOL + +vstring Term::lambdaToString(const SpecialTermData* sd, bool pretty) const +{ + CALL("Term::lambdaToString"); + + VList* vars = sd->getLambdaVars(); + SList* sorts = sd->getLambdaVarSorts(); + TermList lambdaExp = sd->getLambdaExp(); + + vstring varList = pretty ? "" : "["; + + VList::Iterator vs(vars); + SList::Iterator ss(sorts); + TermList sort; + bool first = true; + while(vs.hasNext()) { + varList += first ? "" : ", "; + first = false; + varList += Term::variableToString(vs.next()) + " : "; + varList += ss.next().toString(); + } + varList += pretty ? "" : "]"; + vstring lambda = pretty ? "λ" : "^"; + return "(" + lambda + varList + " : (" + lambdaExp.toString() + "))"; +} + +vstring Term::toString(bool topLevel, IndexVarStack& st) const +{ + CALL("Term::toString(bool, ...)"); + + auto termToStr = [](TermList t, bool top, IndexVarStack& st){ + if (t.isVar()) { + return Term::variableToString(t); + } + return t.term()->toString(top, st); + }; + + auto incrementAll = [](IndexVarStack& st){ + for(unsigned i=0; i < st.size(); i++){ + st[i] = make_pair(++st[i].first, st[i].second); + } + }; + + auto findVar = [](int index, IndexVarStack& st, unsigned& var){ + for(unsigned i=0; i < st.size(); i++){ + if(st[i].first == index){ + var = st[i].second; + return true; + } + } + return false; + }; + + ASS(!isLiteral()); + + auto printSetting = env.options->holPrinting(); + bool pretty = printSetting == Options::HPrinting::PRETTY; + bool db = printSetting == Options::HPrinting::DB_INDICES; + + vstring res; + if(isSpecial()){ + const Term::SpecialTermData* sd = getSpecialData(); + switch(functor()) { + case Term::SF_FORMULA: + return sd->getFormula()->toString(); + case Term:: SF_LAMBDA: + return lambdaToString(sd, pretty); + default: + // currently HOL doesn't support any other specials + ASSERTION_VIOLATION; + } + } + if(isArrowSort()){ + ASS(arity() == 2); + TermList arg1 = *(nthArgument(0)); + TermList arg2 = *(nthArgument(1)); + vstring arrow = pretty ? " → " : " > "; + res += topLevel ? "" : "("; + res += termToStr(arg1,false,st) + arrow + termToStr(arg2,true,st); + res += topLevel ? "" : ")"; + return res; + } + if(isSort()){ + auto sort = static_cast(this); + if(sort->isBoolSort() && pretty) return "ο"; + if(sort->functor() == Signature::DEFAULT_SORT_CON && pretty) return "ι"; + // any non-arrow sort + res = sort->typeConName(); + if(pretty && arity()) res += "⟨"; + for(unsigned i = 0; i < arity(); i++){ + res += pretty && i != 0 ? ", " : ""; + res += !pretty ? " @ " : ""; + res += termToStr(*nthArgument(i),pretty,st); + } + if(pretty && arity()) res += "⟩"; + return res; + } + if(isLambdaTerm()){ + unsigned v = st.size() ? st.top().second + 1 : 0; + vstring bvar = (pretty ? "y" : "Y") + Int::toString(v); + bvar = pretty ? + bvar + " : " + termToStr(*nthArgument(0),true,st) : + "[" + bvar + " : " + termToStr(*nthArgument(0),true,st) + "]"; + bvar = db ? "" : bvar; + + IndexVarStack newSt(st); + incrementAll(newSt); + newSt.push(make_pair(0, v)); + + vstring sep = pretty || db ? ". " : ": "; + vstring lambda = pretty ? "λ" : "^"; + vstring lbrac = pretty ? "" : "("; + vstring rbrac = pretty ? "" : ")"; + + res = "(" + lambda + bvar + sep + lbrac + termToStr(*nthArgument(2),!pretty,newSt) + rbrac + ")"; + return res; + } + if(deBruijnIndex().isSome() && !db){ + unsigned var; + if(findVar(deBruijnIndex().unwrap(), st, var)){ + return (pretty ? "y" : "Y") + Int::toString(var); + } else { + // loose bound index + return "db" + Int::toString(deBruijnIndex().unwrap()); + } + } + + TermList head; + TermStack args; + ApplicativeHelper::getHeadAndArgs(this, head, args); + bool hasArgs = args.size(); + + vstring headStr; + if(head.isVar() || (head.deBruijnIndex().isSome() && !db) || head.isLambdaTerm() || head.term()->isSpecial()){ + headStr = termToStr(head,false,st); + } + else if(head.isNot()){ headStr = pretty ? "¬" : "~"; } + else if(head.isSigma()){ headStr = pretty ? "Σ" : "??"; } + else if(head.isPi()){ headStr = pretty ? "Π" : "!!"; } + else if(head.isAnd()){ headStr = pretty ? "∧" : "&"; } + else if(head.isOr()){ headStr = pretty ? "∨" : "|"; } + else if(head.isXOr()){ headStr = pretty ? "⊕" : "<~>"; } + else if(head.isImp()){ headStr = pretty ? "⇒" : "=>"; } + else if(head.isChoice()){ headStr = pretty ? "ε" : "@@+"; } + else if(head.isIff() || head.isEquals()){ headStr = pretty ? "≈" : "="; } // @=??? + else if(ApplicativeHelper::isTrue(head)){ headStr = pretty ? "⊤" : "$true"; } + else if(ApplicativeHelper::isFalse(head)){ headStr = pretty ? "⊥" : "$false"; } + else { + headStr = head.term()->functionName(); + if(head.deBruijnIndex().isSome()){ + headStr = headStr + "_" + Int::toString(head.deBruijnIndex().unwrap()); + } + } + + if(head.isTerm() && !head.isEquals() && head.deBruijnIndex().isNone() && + !head.isLambdaTerm() && head.term()->arity()){ + Term* t = head.term(); + if(pretty) headStr += "⟨"; + for(unsigned i = 0; i < t->arity(); i++){ + headStr += pretty && i != 0 ? ", " : ""; + headStr += !pretty ? " @ " : ""; + headStr += termToStr(*t->nthArgument(i),pretty,st); + } + if(pretty) headStr += "⟩"; + } + + res += (!topLevel && hasArgs) ? "(" : ""; + + if((head.isAnd() || head.isOr() || head.isIff() || head.isEquals() || head.isImp() || head.isXOr()) && + args.size() == 2){ + res += termToStr(args[1],false,st) + " " + headStr + " " + termToStr(args[0],false,st); + } else { + vstring app = pretty || head.isNot() ? " " : " @ "; + res += headStr; + while(!args.isEmpty()){ + res += app + termToStr(args.pop(),false,st); + } + } + res += (!topLevel && hasArgs) ? ")" : ""; + return res; +} + +#endif + + /** * Return the result of conversion of a literal into a vstring. * @since 16/05/2007 Manchester @@ -764,27 +1406,50 @@ vstring Literal::toString() const if (isEquality()) { const TermList* lhs = args(); vstring s = lhs->toString(); - if (isPositive()) { - s += " = "; + +#if VHOL + if(env.property->higherOrder() && env.options->holPrinting() != Options::HPrinting::RAW && + lhs->isApplication()){ + s = "(" + s + ")"; } - else { - s += " != "; +#endif + + vstring eqSym = isPositive() ? " = " : " != "; +#if VHOL + if(env.options->holPrinting() == Options::HPrinting::PRETTY){ + eqSym = isPositive() ? " ≈ " : " ≉ "; } +#endif + s += eqSym; - vstring res = s + lhs->next()->toString(); - if (env.property->higherOrder() || - (SortHelper::getEqualityArgumentSort(this) == AtomicSort::boolSort())){ + vstring rhs = lhs->next()->toString(); + +#if VHOL + if(env.property->higherOrder() && env.options->holPrinting() != Options::HPrinting::RAW && + lhs->next()->isApplication()){ + rhs = "(" + rhs + ")"; + } +#endif + + vstring res = s + rhs; + if ( +#if VHOL + env.property->higherOrder() || +#endif + (SortHelper::getEqualityArgumentSort(this).isBoolSort())){ res = "("+res+")"; } - /*if(isTwoVarEquality()){ - res += "___ sort: " + twoVarEqSort().toString(); - }*/ return res; } Stack stack(64); vstring s = polarity() ? "" : "~"; +#if VHOL + if(env.options->holPrinting() == Options::HPrinting::PRETTY){ + s = polarity() ? "" : "¬"; + } +#endif unsigned proj; if (Theory::tuples()->findProjection(functor(), true, proj)) { return s + "$proj(" + Int::toString(proj) + ", " + args()->asArgsToString(); @@ -976,8 +1641,6 @@ Term* Term::createNonShared(Term* t,TermList* args) return s; } // Term::createNonShared(const Term* t,Term* args) - - /** Create a new complex term, and do not insert it into the sharing * structure. */ @@ -1072,7 +1735,7 @@ Term* Term::createTupleLet(unsigned tupleFunctor, VList* symbols, TermList bindi unsigned arg = 0; while (sit.hasNext()) { unsigned symbol = sit.next(); - bool isPredicate = tupleSymbol->fnType()->arg(arg) == AtomicSort::boolSort(); + bool isPredicate = tupleSymbol->fnType()->arg(arg).isBoolSort(); if (!distinctSymbols.contains(make_pair(symbol, isPredicate))) { distinctSymbols.insert(make_pair(symbol, isPredicate)); } else { @@ -1109,6 +1772,7 @@ Term* Term::createFormula(Formula* formula) } +#if VHOL /** * Create a lambda term from a list of lambda vars and an * expression and returns the resulting term @@ -1136,6 +1800,7 @@ Term* Term::createLambda(TermList lambdaExp, VList* vars, SList* sorts, TermList s->getSpecialData()->_lambdaData.sort = lambdaTmSort; return s; } +#endif Term* Term::createTuple(unsigned arity, TermList* sorts, TermList* elements) { CALL("Term::createTuple"); @@ -1279,6 +1944,7 @@ TermList AtomicSort::rationalSort(){ return TermList(_rat); } +#if VHOL TermList AtomicSort::arrowSort(TermList s1, TermList s2){ CALL("AtomicSort::arrowSort/1"); unsigned arrow = env.signature->getArrowConstructor(); @@ -1301,6 +1967,7 @@ TermList AtomicSort::arrowSort(TermStack& domSorts, TermList range) } return res; } +#endif AtomicSort* AtomicSort::createConstant(const vstring& name) { @@ -1399,9 +2066,9 @@ bool Term::skip() const return false; } } - NonVariableIterator nvi(const_cast(this)); + NonVariableNonTypeIterator nvi(const_cast(this)); while (nvi.hasNext()) { - unsigned func=nvi.next().term()->functor(); + unsigned func=nvi.next()->functor(); if (!env.signature->getFunction(func)->skip()) { return false; } @@ -1423,8 +2090,10 @@ bool Term::isBoolean() const { case SF_FORMULA: return true; case SF_TUPLE: +#if VHOL case SF_LAMBDA: return false; +#endif case SF_ITE: case SF_LET: case SF_LET_TUPLE: { @@ -1492,7 +2161,7 @@ AtomicSort* AtomicSort::create(unsigned typeCon, unsigned arity, const TermList* * structure if all arguments are shared. * @since 07/01/2008 Torrevieja */ -AtomicSort* AtomicSort::create(AtomicSort* sort,TermList* args) +AtomicSort* AtomicSort::create(AtomicSort const* sort,TermList* args) { CALL("AtomicSort::create/2"); @@ -1513,6 +2182,21 @@ AtomicSort* AtomicSort::create(AtomicSort* sort,TermList* args) return s; } +AtomicSort* AtomicSort::createNonShared(AtomicSort const* sort,TermList* args) +{ + CALL("AtomicSort::createNonShared"); + + int arity = sort->arity(); + AtomicSort* s = new(arity) AtomicSort(*sort); + + TermList* ss = s->args(); + for (int i = 0;i < arity;i++) { + ASS(!args[i].isEmpty()); + *ss-- = args[i]; + } + return s; +} + AtomicSort* AtomicSort::create2(unsigned tc, TermList arg1, TermList arg2) { @@ -1649,6 +2333,22 @@ Literal* Literal::create(Literal* l,TermList* args) return m; } // Literal::create +Literal* Literal::createNonShared(Literal* l, TermList* args) +{ + CALL("Literal::createNonShared"); + // no need to create non-shared equalities currently + ASS(!l->isEquality()); + + int arity = l->arity(); + Literal* m = new(arity) Literal(*l); + + TermList* ts = m->args(); + for (int i = 0;i < arity;i++) { + ASS(!args[i].isEmpty()); + *ts-- = args[i]; + } + return m; +} /** * Return a new equality literal, with polarity @b polarity and @@ -1665,7 +2365,7 @@ Literal* Literal::createEquality (bool polarity, TermList arg1, TermList arg2, T TermList srt1, srt2; #if VDEBUG - static RobSubstitution checkSortSubst; + static RobSubstitutionTL checkSortSubst; checkSortSubst.reset(); #endif @@ -1675,14 +2375,14 @@ Literal* Literal::createEquality (bool polarity, TermList arg1, TermList arg2, T ASS_REP(arg2.isVar(), arg2.toString()); return createVariableEquality(polarity, arg1, arg2, sort); } - ASS(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, 0, srt2, 1)); + ASS(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, srt2, VarBank::DEFAULT_BANK)); } else { - ASS_REP2(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, 0, srt1, 1), sort.toString(), srt1.toString()); + ASS_REP2(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, srt1, VarBank::DEFAULT_BANK), sort.toString(), srt1.toString()); #if VDEBUG if (SortHelper::tryGetResultSort(arg2, srt2)) { checkSortSubst.reset(); - ASS_REP2(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, 0, srt2, 1), sort.toString(), arg2.toString() + " : " + srt2.toString()); + ASS_REP2(env.sharing->isWellSortednessCheckingDisabled() || checkSortSubst.match(sort, srt2, VarBank::DEFAULT_BANK), sort.toString(), arg2.toString() + " : " + srt2.toString()); } #endif } @@ -1734,7 +2434,53 @@ Literal* Literal::create(unsigned pred, bool polarity, std::initializer_list(_info.tag); } /** the term list is empty */ @@ -134,10 +163,9 @@ class TermList { /** the term contains a special variable as its head */ inline bool isSpecialVar() const { return tag() == SPEC_VAR && var() < SPEC_UPPER_BOUND; } - inline bool isVSpecialVar() const { return tag() == SPEC_VAR && var() > SPEC_UPPER_BOUND; } /** return the variable number */ inline unsigned var() const - { ASS(isVar()); return _content / 4; } + { ASS(isVar()); return _var.var; } /** the term contains reference to Term class */ inline bool isTerm() const { return tag() == REF; } @@ -148,28 +176,59 @@ class TermList { /** True of the terms have the same content. Useful for comparing * arguments of shared terms. */ inline bool sameContent(const TermList* t) const - { return _content == t->_content ; } + { return *this == *t ; } inline bool sameContent(const TermList& t) const { return sameContent(&t); } - /** return the content, useful for e.g., term argument comparison */ + /** return the content, useful for e.g., term argument comparison + * AYB depracated */ inline size_t content() const { return _content; } + /** default hash is to hash the content */ unsigned defaultHash() const { return DefaultHash::hash(content()); } unsigned defaultHash2() const { return content(); } - vstring toString(bool topLevel = true) const; + vstring toString() const; + + inline VarBank bank() const + { return static_cast(_var.bank); } + + inline bool isOutputVar() const + { return isVar() && bank() == OUTPUT_BANK; } + + inline bool onBank() const + { return isVar() && bank() != DEFAULT_BANK; } + /** make the term into an ordinary variable with a given number */ - inline void makeVar(unsigned vnumber) - { _content = vnumber * 4 + ORD_VAR; } + inline void makeVar(unsigned vnumber, VarBank bank = DEFAULT_BANK) + { + _var.var = vnumber; + _var.tag = ORD_VAR; + _var.bank = bank; + } /** make the term into a special variable with a given number */ inline void makeSpecialVar(unsigned vnumber) - { _content = vnumber * 4 + SPEC_VAR; } + { + _var.var = vnumber; + _var.tag = SPEC_VAR; + _var.bank = DEFAULT_BANK; + } /** make the term empty (so that isEmpty() returns true) */ inline void makeEmpty() { _content = FUN; } /** make the term into a reference */ inline void setTerm(Term* t) { _term = t; ASS_EQ(tag(), REF); } + class Top : public Coproduct { + Top(Coproduct self) : Coproduct(self) {} + public: + static Top functor(unsigned f) { return Top(Coproduct::variant<0>(f)); } + static Top var (unsigned v) { return Top(Coproduct::variant<1>(v)); } + static Top nonsplittable (unsigned id) { return Top(Coproduct::variant<2>(id)); } + Option functor() const { return as<0>().toOwned(); } + Option var() const { return as<1>().toOwned(); } + Option id() const { return as<2>().toOwned(); } + }; + Top top(bool splittable = true) const; static bool sameTop(TermList ss, TermList tt); static bool sameTopFunctor(TermList ss, TermList tt); static bool equals(TermList t1, TermList t2); @@ -178,14 +237,60 @@ class TermList { /** if not var, the inner term must be shared */ unsigned weight() const; /** returns true if this termList is wrapping a higher-order "arrow" sort */ +#if VHOL bool isArrowSort(); +#endif bool isBoolSort(); bool isArraySort(); bool isTupleSort(); + bool isIntSort(); + bool isRatSort(); + bool isRealSort(); + +#if VHOL bool isApplication() const; + bool isLambdaTerm() const; + bool isEtaExpandedVar(TermList& var) const; + bool isRedex(); + bool isNot() const; + bool isSigma() const; + bool isPi() const; + bool isIff() const; + bool isAnd() const; + bool isOr() const; + bool isXOr() const; + bool isImp() const; + bool isEquals() const; + bool isPlaceholder() const; + bool isChoice() const; + bool containsLooseIndex() const; + // used in clause selection + // nuber of applued variables and lambdas in the term + unsigned numOfAppVarsAndLambdas() const; + Option deBruijnIndex() const; + TermList lhs() const; + TermList rhs() const; + TermList lambdaBody() const; + TermList head(); + TermList domain(); + TermList result(); + TermList finalResult(); + // return the weak head normal form of the term + TermList whnfDeref(RobSubstitutionTL* sub); + TermList betaNF(); + TermList etaNF(); + TermList betaEtaNF(); +#endif + + TermList toBank(VarBank bank); + // Use with care! Make sure that it is a term before calling + // mainly here for compatibility with TermSpec in RobSubstitution + TermList nthArg(unsigned i) const; + bool containsSubterm(TermList v); bool containsAllVariablesOf(TermList t); + bool ground() const; bool isSafe() const; VList* freeVariables() const; @@ -196,9 +301,12 @@ class TermList { #endif inline bool operator==(const TermList& t) const - { return _content==t._content; } + { + // bit comparison + return _content == t._content; + } inline bool operator!=(const TermList& t) const - { return _content!=t._content; } + { return !(*this == t); } friend bool operator<(const TermList& lhs, const TermList& rhs); @@ -206,10 +314,19 @@ class TermList { vstring asArgsToString() const; union { + /** raw content to make it easy to carry out bit comparisons. DON'T USE */ + size_t _content; /** reference to another term */ Term* _term; - /** raw content, can be anything */ - size_t _content; + /** variable */ + struct { + /** a TermTag indicating what is stored here */ + unsigned tag : 2; + /** bank the variable is currently on */ + unsigned bank : 30; + /** variable number */ + unsigned var : 32; + } _var; /** Used by Term, storing some information about the term using bits */ /* * A note from 2022: the following bitfield is somewhat non-portable. @@ -235,7 +352,16 @@ class TermList { /** true if atomic sort */ unsigned sort : 1; /** true if term contains at least one term var */ - unsigned hasTermVar : 1; + unsigned hasSortVar : 1; + #if VHOL + /** true if the term contains a De Bruijn index */ + unsigned hasDBIndex : 1; + /** true if the term contains a redex */ + unsigned hasRedex : 1; + /** true if a term contains a lambda */ + unsigned hasLambda : 1; + #endif + /** Ordering comparison result for commutative term arguments, one of * 0 (unknown) 1 (less), 2 (equal), 3 (greater), 4 (incomparable) * @see Term::ArgumentOrder */ @@ -249,9 +375,10 @@ class TermList { /** term id hiding in this _info */ // this should not be removed without care, // otherwise the bitfield layout might shift, resulting in broken pointer tagging - unsigned id : 32; + unsigned id : 32; } _info; }; + friend class Indexing::TermSharing; friend class Term; friend class Literal; @@ -259,7 +386,7 @@ class TermList { }; // class TermList static_assert( - sizeof(TermList) == sizeof(size_t), + sizeof(TermList) == 8, "size of TermList must be the same size as that of size_t" ); @@ -276,7 +403,9 @@ class Term static const unsigned SF_FORMULA = 0xFFFFFFFD; static const unsigned SF_TUPLE = 0xFFFFFFFC; static const unsigned SF_LET_TUPLE = 0xFFFFFFFB; +#if VHOL static const unsigned SF_LAMBDA = 0xFFFFFFFA; +#endif static const unsigned SF_MATCH = 0xFFFFFFF9; static const unsigned SPECIAL_FUNCTOR_LOWER_BOUND = 0xFFFFFFF9; @@ -307,6 +436,7 @@ class Term TermList binding; TermList sort; } _letTupleData; +#if VHOL struct { TermList lambdaExp; VList* _vars; @@ -314,6 +444,7 @@ class Term TermList sort; TermList expSort;//TODO is this needed? } _lambdaData; +#endif struct { TermList sort; TermList matchedSort; @@ -332,16 +463,20 @@ class Term ASS_REP(getType() == SF_LET || getType() == SF_LET_TUPLE, getType()); return getType() == SF_LET ? _letData.functor : _letTupleData.functor; } +#if VHOL VList* getLambdaVars() const { ASS_EQ(getType(), SF_LAMBDA); return _lambdaData._vars; } SList* getLambdaVarSorts() const { ASS_EQ(getType(), SF_LAMBDA); return _lambdaData._sorts; } TermList getLambdaExp() const { ASS_EQ(getType(), SF_LAMBDA); return _lambdaData.lambdaExp; } +#endif VList* getVariables() const { ASS_EQ(getType(), SF_LET); return _letData.variables; } VList* getTupleSymbols() const { return _letTupleData.symbols; } TermList getBinding() const { ASS_REP(getType() == SF_LET || getType() == SF_LET_TUPLE, getType()); return TermList(getType() == SF_LET ? _letData.binding : _letTupleData.binding); } +#if VHOL TermList getLambdaExpSort() const { ASS_EQ(getType(), SF_LAMBDA); return _lambdaData.expSort; } +#endif TermList getSort() const { switch (getType()) { case SF_ITE: @@ -350,8 +485,10 @@ class Term return _letData.sort; case SF_LET_TUPLE: return _letTupleData.sort; +#if VHOL case SF_LAMBDA: return _lambdaData.sort; +#endif case SF_MATCH: return _matchData.sort; default: @@ -368,6 +505,14 @@ class Term explicit Term(const Term& t) throw(); static Term* create(unsigned function, unsigned arity, const TermList* args); static Term* create(unsigned fn, std::initializer_list args); + static Term* create(unsigned fn, Stack const& args) { return Term::create(fn, args.length(), args.begin()); } + template + static Term* createFromIter(unsigned fn, Iter args) + { + Recycled> stack; + stack->loadFromIterator(args); + return Term::create(fn, *stack); + } static Term* create(Term* t,TermList* args); static Term* createNonShared(unsigned function, unsigned arity, TermList* arg); static Term* createNonShared(Term* t,TermList* args); @@ -379,7 +524,9 @@ class Term static Term* createConstant(unsigned symbolNumber) { return create(symbolNumber,0,0); } static Term* createITE(Formula * condition, TermList thenBranch, TermList elseBranch, TermList branchSort); static Term* createLet(unsigned functor, VList* variables, TermList binding, TermList body, TermList bodySort); +#if VHOL static Term* createLambda(TermList lambdaExp, VList* vars, SList* sorts, TermList expSort); +#endif static Term* createTupleLet(unsigned functor, VList* symbols, TermList binding, TermList body, TermList bodySort); static Term* createFormula(Formula* formula); static Term* createTuple(unsigned arity, TermList* sorts, TermList* elements); @@ -401,7 +548,11 @@ class Term /** Function or predicate symbol of a term */ const unsigned functor() const { return _functor; } - vstring toString(bool topLevel = true) const; + vstring toString() const; +#if VHOL + // auxiliary function to print lambda specials + vstring lambdaToString(const SpecialTermData* sd, bool pretty = false) const; +#endif static vstring variableToString(unsigned var); static vstring variableToString(TermList var); @@ -461,7 +612,9 @@ class Term * non-emptiness * In the monomorphic case, the same as args() */ - TermList* termArgs(); + const TermList* termArgs() const; + + TermList* termArgs(){ return _args + (_arity - numTypeArguments()); } /** Return the 1st type argument for a polymorphic term. * returns a nullpointer if the term not polymorphic @@ -526,10 +679,10 @@ class Term /** True if the term contains a term variable (type variables don't count) * Only applicable to shared terms */ - bool hasTermVar() const + bool hasSortVar() const { ASS(_args[0]._info.shared); - return _args[0]._info.hasTermVar; + return _args[0]._info.hasSortVar; } // ground /** True if the term is shared */ @@ -553,7 +706,7 @@ class Term TermList* ts1 = args(); TermList* ts2 = ts1->next(); - swap(ts1->_content, ts2->_content); + swap(ts1->_var, ts2->_var); } /** Return the weight. Applicable only to shared terms */ @@ -609,11 +762,11 @@ class Term _vars = v; } // setVars - void setHasTermVar(bool b) + void setHasSortVar(bool b) { CALL("setHasTermVar"); - ASS(shared() && !isSort()); - _args[0]._info.hasTermVar = b; + ASS(shared()); + _args[0]._info.hasSortVar = b; } /** Return the number of variable _occurrences_ */ @@ -645,8 +798,77 @@ class Term bool isLiteral() const { return _args[0]._info.literal; } /** True if the term is, in fact, a sort */ bool isSort() const { return _args[0]._info.sort; } + +#if VHOL + + typedef Stack> IndexVarStack; + + vstring toString(bool topLevel, IndexVarStack& map) const; /** true if the term is an application */ bool isApplication() const; + /** true if the term is a lambda term */ + bool isLambdaTerm() const; + /** true if the term is a redex */ + bool isRedex(); + /** true if the term is a negation of a Boolean term*/ + bool isNot() const; + + bool isSigma() const; + bool isPi() const; + bool isIff() const; + bool isAnd() const; + bool isOr() const; + bool isXOr() const; + bool isImp() const; + bool isEquals() const; + bool isPlaceholder() const; + bool isChoice() const; + /** true if term is a sort which is a arrow sort */ + bool isArrowSort() const; + + void setHasRedex(bool b) + { + CALL("setHasRedex"); + ASS(shared() && !isSort()); + _args[0]._info.hasRedex = b; + } + /** true if term contains redex */ + bool hasRedex() const + { + ASS(_args[0]._info.shared); + return _args[0]._info.hasRedex; + } + /** returns the head of an applicative term */ + TermList head(); + /** returns empty option if not a De Bruijn index and index otherwise */ + Option deBruijnIndex() const; + + void setHasDBIndex(bool b) + { + CALL("setHasDBIndex"); + ASS(shared() && !isSort()); + _args[0]._info.hasDBIndex = b; + } + /** returns true if term contains De Bruijn index */ + bool hasDBIndex() const + { + ASS(_args[0]._info.shared); + return _args[0]._info.hasDBIndex; + } + + void setHasLambda(bool b) + { + CALL("setHasLambda"); + ASS(shared() && !isSort()); + _args[0]._info.hasLambda = b; + } + /** true if term contains redex */ + bool hasLambda() const + { + ASS(_args[0]._info.shared); + return _args[0]._info.hasLambda; + } +#endif /** Return an index of the argument to which @b arg points */ unsigned getArgumentIndex(TermList* arg) @@ -696,6 +918,8 @@ class Term bool containsAllVariablesOf(Term* t); size_t countSubtermOccurrences(TermList subterm); + Term* toBank(VarBank bank); + /** Return true if term has no non-constant functions as subterms */ bool isShallow() const; @@ -722,7 +946,9 @@ class Term bool isTupleLet() const { return functor() == SF_LET_TUPLE; } bool isTuple() const { return functor() == SF_TUPLE; } bool isFormula() const { return functor() == SF_FORMULA; } +#if VHOL bool isLambda() const { return functor() == SF_LAMBDA; } +#endif bool isMatch() const { return functor() == SF_MATCH; } bool isBoolean() const; bool isSuper() const; @@ -849,24 +1075,43 @@ class AtomicSort static AtomicSort* create(unsigned typeCon, unsigned arity, const TermList* args); static AtomicSort* create2(unsigned tc, TermList arg1, TermList arg2); - static AtomicSort* create(AtomicSort* t,TermList* args); + static AtomicSort* create(AtomicSort const* a,TermList* args); + static AtomicSort* createNonShared(AtomicSort const* a,TermList* args); static AtomicSort* createConstant(unsigned typeCon) { return create(typeCon,0,0); } static AtomicSort* createConstant(const vstring& name); +#if VHOL /** True if the sort is a higher-order arrow sort */ bool isArrowSort() const; +#endif /** True if the sort $o */ bool isBoolSort() const; /** true if sort is the sort of an array */ bool isArraySort() const; /** true if sort is the sort of an tuple */ bool isTupleSort() const; + /** True if the sort $int */ + bool isIntSort() const; + /** True if rational sort */ + bool isRatSort() const; + /** True if real sort */ + bool isRealSort() const; const vstring& typeConName() const; +#if VHOL + + /** domain of an arrow sort */ + TermList domain(); + /** result sort of an arrow sort */ + TermList result(); + /** */ + TermList finalResult(); + static TermList arrowSort(TermStack& domSorts, TermList range); static TermList arrowSort(TermList s1, TermList s2); static TermList arrowSort(TermList s1, TermList s2, TermList s3); +#endif static TermList arraySort(TermList indexSort, TermList innerSort); static TermList tupleSort(unsigned arity, TermList* sorts); static TermList defaultSort(); @@ -877,7 +1122,6 @@ class AtomicSort static TermList rationalSort(); private: - static AtomicSort* createNonShared(unsigned typeCon, unsigned arity, TermList* arg); static AtomicSort* createNonSharedConstant(unsigned typeCon) { return createNonShared(typeCon,0,0); } }; @@ -932,6 +1176,7 @@ class Literal bool commutative, const TermList* args); static Literal* create(Literal* l,bool polarity); static Literal* create(Literal* l,TermList* args); + static Literal* createNonShared(Literal* l,TermList* args); static Literal* createEquality(bool polarity, TermList arg1, TermList arg2, TermList sort); static Literal* create1(unsigned predicate, bool polarity, TermList arg); static Literal* create2(unsigned predicate, bool polarity, TermList arg1, TermList arg2); @@ -965,6 +1210,13 @@ class Literal return l->isPositive() ? l : complementaryLiteral(l); } +#if VHOL + bool isFlexFlex() const; + bool isFlexRigid() const; + bool isRigidRigid() const; + unsigned numOfAppVarsAndLambdas() const; +#endif + /** true if positive */ bool isPositive() const { @@ -983,6 +1235,8 @@ class Literal return _args[0]._info.polarity; } // polarity + Literal* toBank(VarBank b); + /** * Mark this object as an equality between two variables. */ @@ -1048,4 +1302,10 @@ std::ostream& operator<< (ostream& out, const Literal& tl ); }; +template<> +struct std::hash { + size_t operator()(Kernel::TermList const& t) const + { return t.defaultHash(); } +}; + #endif diff --git a/Kernel/TermIterators.cpp b/Kernel/TermIterators.cpp index 41c8810022..906b6871c2 100644 --- a/Kernel/TermIterators.cpp +++ b/Kernel/TermIterators.cpp @@ -24,8 +24,6 @@ namespace Kernel { -typedef ApplicativeHelper AH; - /** * True if there exists next variable */ @@ -155,7 +153,7 @@ void SubtermIterator::right() /// /// ////////////////////////////////////////////////////////////////////////// -bool TopLevelVarLikeTermIterator::hasNext() +/*bool TopLevelVarLikeTermIterator::hasNext() { CALL("TopLevelVarLikeTermIterator::hasNext"); @@ -241,7 +239,11 @@ bool TopLevelVarIterator::hasNext() } return false; -} +}*/ + +#if VHOL + +typedef ApplicativeHelper AH; Term* FirstOrderSubtermIt::next() { @@ -252,12 +254,22 @@ Term* FirstOrderSubtermIt::next() TermList head; args.reset(); Term* t = _stack.pop(); - AH::getHeadAndArgs(t, head, args); - if(!AH::isComb(head) || AH::isUnderApplied(head, args.size())){ - for(unsigned i = 0; i < args.size(); i++){ - if(!args[i].isVar()){ - _added++; - _stack.push(args[i].term()); + if(!t->isLambdaTerm() || _goInsideLambdas){ + AH::getHeadAndArgs(t, head, args); + if(!head.isLambdaTerm()){ + for(unsigned i = 0; i < args.size(); i++){ + // TODO logic below is wrong + // (not as complete as possible, but not unsound) + // A term that contains loose indices may still + // have subterms that don't have loose indices + // Moreover, we do not explore the body of a lambda currently + if(!args[i].isVar() && !args[i].containsLooseIndex()){ + // demodulating a term that contains a loose index + // is sound, but it may not maintain completeness + // depending on the ordering + _added++; + _stack.push(args[i].term()); + } } } } @@ -274,40 +286,6 @@ void FirstOrderSubtermIt::right() } } // FirstOrderSubtermIt::right - -bool NarrowableSubtermIt::hasNext() -{ - CALL("NarrowableSubtermIt::hasNext"); - - if(!_used){ return true; } - - static TermStack args; - TermList head; - while(!_stack.isEmpty()){ - Term* t = _stack.pop(); - AH::getHeadAndArgs(t, head, args); - if((AH::isComb(head) && AH::isExactApplied(head, args.size())) || - (head.isVar() && args.size() <= 3)){ - _next = TermList(t); - _used = false; - } - if(t->isApplication() && (!AH::isComb(head) || _used)){ - TermList* trm = t->nthArgument(2); - if(trm->isApplication()){ - _stack.push(trm->term()); - } - if(!AH::isComb(head) || AH::isUnderApplied(head, args.size())){ - trm = t->nthArgument(3); - if(trm->isApplication()){ - _stack.push(trm->term()); - } - } - } - if(!_used){ return true; } - } - return false; -} - bool BooleanSubtermIt::hasNext() { CALL("BooleanSubtermIt::hasNext"); @@ -318,8 +296,14 @@ bool BooleanSubtermIt::hasNext() TermList head; while(!_stack.isEmpty()){ Term* t = _stack.pop(); + if(t->isLambdaTerm()) { + // Beware of the loose indices! + // We could strengthen the iterator by returning subterms + // underneath lambdas that don't contain loose indices + continue; + } AH::getHeadAndArgs(t, head, args); - if(SortHelper::getResultSort(t) == AtomicSort::boolSort() && !AH::isBool(head)){ + if(SortHelper::getResultSort(t).isBoolSort() && !AH::isBool(head)){ _next = TermList(t); _used = false; } @@ -334,65 +318,7 @@ bool BooleanSubtermIt::hasNext() return false; } -bool RewritableVarsIt::hasNext() -{ - CALL("RewritableVarsIt::hasNext"); - - if(!_next.isEmpty()){ return true; } - - static TermStack args; - TermList head; - TermList headSort; - while(!_stack.isEmpty()){ - TermList t = _stack.pop(); - TermList s = _sorts.pop(); - AH::getHeadSortAndArgs(t, head, headSort, args); - if(head.isVar() && args.size() <= 1 && _unstableVars->find(head.var()) - && (s.isVar() || s.isArrowSort())){ - _next = head; - } - if(!AH::isComb(head) || AH::isUnderApplied(head, args.size())){ - unsigned count = 1; - while(!args.isEmpty()){ - _sorts.push(AH::getNthArg(headSort, count++)); - _stack.push(args.pop()); - } - } - if(!_next.isEmpty()){ return true; } - } - return false; -} - -//TODO relook at stability and instability -bool UnstableVarIt::hasNext() -{ - CALL("UnstableVarIt::hasNext"); - - if(!_next.isEmpty()){ return true; } - - static TermStack args; - TermList head; - while(!_stack.isEmpty()){ - ASS(_stack.size() == _stable.size()); - TermList t = _stack.pop(); - bool stable = _stable.pop(); - AH::getHeadAndArgs(t, head, args); - if(head.isVar()){ - if(!stable || args.size()){ - _next = head; - } - } - bool argsStable = !head.isVar() && (!AH::isComb(head) || - (AH::isUnderApplied(head, args.size()) && stable)); - for(unsigned i = 0; i < args.size(); i++){ - _stack.push(args[i]); - _stable.push(argsStable); - } - if(!_next.isEmpty()){ return true; } - } - return false; - -} +#endif ////////////////////////////////////////////////////////////////////////// /// /// @@ -623,7 +549,7 @@ TermFunIterator::TermFunIterator (const Term* t) _hasNext = true; _next = t->functor(); - _stack.push(t->args()); + _stack.push(t->termArgs()); } // TermFunIterator::TermFunIterator @@ -651,7 +577,7 @@ bool TermFunIterator::hasNext () _hasNext = true; const Term* t = ts->term(); _next = t->functor(); - _stack.push(t->args()); + _stack.push(t->termArgs()); return true; } return false; diff --git a/Kernel/TermIterators.hpp b/Kernel/TermIterators.hpp index 2530bdfa93..06d98cf6af 100644 --- a/Kernel/TermIterators.hpp +++ b/Kernel/TermIterators.hpp @@ -246,7 +246,7 @@ class SubtermIterator * that can be called at any time to return the head * of @b applicative term */ -class ApplicativeArgsIt +/*class ApplicativeArgsIt : public IteratorCore { public: @@ -263,8 +263,8 @@ class ApplicativeArgsIt bool hasNext(){ return !_stack.isEmpty(); } - /** Return next arg of _head - * @warning hasNext() must have been called before */ + // Return next arg of _head + // @warning hasNext() must have been called before TermList next() { ASS(!_stack.isEmpty()); @@ -351,98 +351,24 @@ class TopLevelVarIterator private: TermStack _stack; TermList _next; -}; - - -class RewritableVarsIt - : public IteratorCore -{ -public: //includeSelf for compatibility - RewritableVarsIt(DHSet* unstableVars, Term* t, bool includeSelf = false) : _stack(8) - { - CALL("RewritableVarsIt"); - - _unstableVars = unstableVars; - _next.makeEmpty(); - if(t->isLiteral()){ - TermList t0 = *t->nthArgument(0); - TermList t1 = *t->nthArgument(1); - if(!t0.isVar()){ - _stack.push(t0); - _sorts.push(SortHelper::getResultSort(t0.term())); - } - if(!t1.isVar()){ - _stack.push(t1); - _sorts.push(SortHelper::getResultSort(t1.term())); - } - return; - } - _stack.push(TermList(t)); - _sorts.push(SortHelper::getResultSort(t)); - } - - bool hasNext(); - TermList next(){ - ASS(!_next.isEmpty()); - ASS(_next.isVar()); - TermList res = _next; - _next.makeEmpty(); - return res; - } -private: - TermList _next; - Stack _stack; - Stack _sorts; - DHSet* _unstableVars; -}; - -class UnstableVarIt - : public IteratorCore -{ -public: - UnstableVarIt(Term* t) : _stable(8), _stack(8) - { - CALL("UnstableVarIt"); - _next.makeEmpty(); - if(t->isLiteral()){ - _stack.push(*t->nthArgument(0)); - _stack.push(*t->nthArgument(1)); - _stable.push(true); - _stable.push(true); - return; - } - _stable.push(true); - _stack.push(TermList(t)); - } - - bool hasNext(); - TermList next() - { - ASS(!_next.isEmpty()); - TermList res = _next; - _next.makeEmpty(); - return res; - } +};*/ -private: - TermList _next; - Stack _stable; - Stack _stack; -}; +#if VHOL class FirstOrderSubtermIt : public IteratorCore { public: - FirstOrderSubtermIt(Term* term, bool includeSelf=false) - : _stack(8), _added(0) + FirstOrderSubtermIt(Term* term, bool includeSelf=false, bool goInsideLambdas=false) + : _stack(8), _added(0), _goInsideLambdas(goInsideLambdas) { CALL("FirstOrderSubtermIt::FirstOrderSubtermIt"); + if(term->isLiteral()){ - TermList t0 = *term->nthArgument(0); - TermList t1 = *term->nthArgument(1); - if(!t0.isVar()){ _stack.push(t0.term()); } - if(!t1.isVar()){ _stack.push(t1.term()); } + for(unsigned i = 0; i < term->arity(); i++){ + TermList t = *term->nthArgument(i); + if(!t.isVar()){ _stack.push(t.term()); } + } return; } _stack.push(term); @@ -458,39 +384,14 @@ class FirstOrderSubtermIt private: Stack _stack; int _added; + bool _goInsideLambdas; }; - -class NarrowableSubtermIt -: public IteratorCore +class DemodulationSubtermIt +: public FirstOrderSubtermIt { public: - NarrowableSubtermIt(Term* term, bool includeSelf=false) - : _used(true), _stack(8) - { - CALL("NarrowableSubtermIt::NarrowableSubtermIt"); - if(term->isLiteral()){ - TermList t0 = *term->nthArgument(0); - TermList t1 = *term->nthArgument(1); - if(!t0.isVar()){ _stack.push(t0.term()); } - if(!t1.isVar()){ _stack.push(t1.term()); } - return; - } - _stack.push(term); - //TODO - } - - bool hasNext(); - TermList next(){ - ASS(!_used); - _used = true; - return _next; - } - -private: - bool _used; - TermList _next; - Stack _stack; + DemodulationSubtermIt(Term* t) : FirstOrderSubtermIt(t, false, true) {} }; /* @@ -505,10 +406,10 @@ class BooleanSubtermIt { CALL("BooleanSubtermIt::BooleanSubtermIt"); if(term->isLiteral()){ - TermList t0 = *term->nthArgument(0); - TermList t1 = *term->nthArgument(1); - if(!t0.isVar()){ _stack.push(t0.term()); } - if(!t1.isVar()){ _stack.push(t1.term()); } + for(unsigned i = 0; i < term->arity(); i++){ + TermList t = *term->nthArgument(i); + if(!t.isVar()){ _stack.push(t.term()); } + } return; } _stack.push(term); @@ -527,6 +428,8 @@ class BooleanSubtermIt Stack _stack; }; +#endif + ////////////////////////////////////////////////////////////////////////// /// /// /// END OF HIGHER-ORDER ITERATORS /// @@ -871,6 +774,8 @@ static const auto anyArgIter = [](Term* term) { return *term->nthArgument(i); }); }; +IterTraits> acIter(TermList t, unsigned f); + } #endif // __TermIterators__ diff --git a/Kernel/TermTransformer.cpp b/Kernel/TermTransformer.cpp index 13c09acf99..fe35fbecf0 100644 --- a/Kernel/TermTransformer.cpp +++ b/Kernel/TermTransformer.cpp @@ -14,6 +14,7 @@ #include "SortHelper.hpp" #include "Term.hpp" +#include "ApplicativeHelper.hpp" #include "TermTransformer.hpp" #include "FormulaTransformer.hpp" @@ -29,6 +30,8 @@ Term* TermTransformer::transform(Term* term) { CALL("TermTransformer::transform(Term* term)"); + onTermEntry(term); + if (term->isSpecial()) { return transformSpecial(term); } @@ -56,6 +59,9 @@ Term* TermTransformer::transform(Term* term) break; } Term* orig = terms.pop(); + + onTermExit(orig); + ASS(!orig->isSpecial()); if (!modified.pop()) { args.truncate(args.length() - orig->arity()); @@ -68,15 +74,9 @@ Term* TermTransformer::transform(Term* term) //&top()-2, etc... TermList *argLst = &args.top() - (orig->arity() - 1); args.truncate(args.length() - orig->arity()); // potentially evil. Calls destructors on the truncated objects, which we are happily reading just below - Term* newTrm; - if(orig->isSort()){ - //For most applications we probably dont want to transform sorts. - //However, we don't enforce that here, inheriting classes can decide - //for themselves - newTrm=AtomicSort::create(static_cast(orig), argLst); - } else { - newTrm=Term::create(orig,argLst); - } + Term* newTrm = orig->isSort() ? + create (orig, argLst, _sharedResult) : + create (orig, argLst, _sharedResult) ; args.push(TermList(newTrm)); modified.setTop(true); continue; @@ -85,6 +85,14 @@ Term* TermTransformer::transform(Term* term) } TermList tl = *tt; + + // We still transform sort and term variables ... + // It is difficult to avoid this though + if(tl.isTerm() && tl.term()->isSort() && _dontTransformSorts){ + args.push(tl); + continue; + } + if (tl.isTerm() && tl.term()->isSpecial()) { Term* td = transformSpecial(tl.term()); if (td != tl.term()) { @@ -96,17 +104,18 @@ Term* TermTransformer::transform(Term* term) TermList dest = transformSubterm(tl); if (tl != dest) { - args.push(dest); modified.setTop(true); - continue; } - if (tl.isVar()) { - args.push(tl); + if (dest.isVar() || !exploreSubterms(tl, dest)) { + args.push(dest); continue; } - ASS(tl.isTerm()); - Term* t = tl.term(); + ASS(dest.isTerm()); + Term* t = dest.term(); + + onTermEntry(t); + ASS(!t->isSpecial()); terms.push(t); modified.push(false); @@ -127,11 +136,27 @@ Term* TermTransformer::transform(Term* term) //&top()-2, etc... TermList* argLst = &args.top() - (term->arity() - 1); - if (term->isLiteral()) { - return Literal::create(static_cast(term), argLst); - } else { - return Term::create(term, argLst); + if(term->isLiteral()){ + Literal* lit = static_cast(term); + if(lit->isEquality() && argLst[0].isVar() && argLst[1].isVar() && !_dontTransformSorts){ + return Literal::createEquality(lit->polarity(), argLst[0], argLst[1], + transform(SortHelper::getEqualityArgumentSort(lit))); + } + return create (term, argLst, _sharedResult); + } else if (term->isSort()){ + return create(term, argLst, _sharedResult); } + return create(term, argLst, _sharedResult); +} + +// default implementation, can override if required +bool TermTransformer::exploreSubterms(TermList orig, TermList newTerm) +{ + CALL("TermTransformer::exploreSubterms"); + ASS(newTerm.isTerm()) + + if(orig != newTerm) return false; + return true; } Literal* TermTransformer::transform(Literal* lit) @@ -239,6 +264,66 @@ TermList TermTransformer::transform(TermList ts) return ts; } } +} + +TermList SubtermReplacer::transformSubterm(TermList t) +{ + CALL("SubtermReplacer::transformSubterm"); + + if(t == _what){ +#if VHOL + if(_liftFreeIndices) + { return TermShifter().shift(_by, _shiftBy); } +#endif + return _by; + } + return t; +} + +#if VHOL + +void SubtermReplacer::onTermEntry(Term* t) +{ + CALL("SubtermReplacer::onTermEntry"); + + if(t->isLambdaTerm()) _shiftBy++; +} + +void SubtermReplacer::onTermExit(Term* t) +{ + CALL("SubtermReplacer::onTermExit"); + + if(t->isLambdaTerm()) _shiftBy--; +} + +#endif + +TypedTermList ToBank::toBank(TypedTermList term){ + CALL("ToBank::toBank"); + + TermList sort = term.sort(); + + if(term.isTerm()){ + return TypedTermList(transform(term).term()); + } else { + return TypedTermList(transformSubterm(term), + sort.isVar() ? transformSubterm(sort) : transform(sort)); + } +} + +TermList ToBank::transformSubterm(TermList t) { + CALL("ToBank::transformSubterm"); + + if(t.isVar() && t.bank() != _bank){ + return TermList(t.var(), _bank); + } + return t; +} + +bool ToBank::exploreSubterms(TermList orig, TermList newTerm) { + CALL("ToBank::exploreSubterms"); + + return !(newTerm.isTerm() && newTerm.term()->shared() && newTerm.term()->ground()); } Formula* TermTransformer::transform(Formula* f) @@ -324,7 +409,12 @@ Term* BottomUpTermTransformer::transform(Term* term) //here we assume, that stack is an array with //second topmost element as &top()-1, third at //&top()-2, etc... - TermList* argLst=&args.top() - (term->arity() - 1); +#if VDEBUG + // don't touch args.top() in DEBUG mode if there are actually no arguments (empty stacks don't like it) + TermList* argLst= args.size() ? &args.top() - (term->arity() - 1) : nullptr; +#else // in release, it's fine too, because Literal::create won't touch the pointer in the zero arity case + TermList* argLst= &args.top() - (term->arity() - 1); +#endif if (term->isLiteral()) { return Literal::create(static_cast(term), argLst); } else { diff --git a/Kernel/TermTransformer.hpp b/Kernel/TermTransformer.hpp index 9289e9a051..e6e1a5239a 100644 --- a/Kernel/TermTransformer.hpp +++ b/Kernel/TermTransformer.hpp @@ -16,7 +16,8 @@ #define __TermTransformer__ #include "Forwards.hpp" - +#include "Term.hpp" +#include "TypedTermList.hpp" namespace Kernel { @@ -34,20 +35,94 @@ namespace Kernel { * This class can be used to transform sort arguments as well by suitably * implementing the transform(TermList) function * - * TermTransformer goes top down but does no recurse into the replaced term + * TermTransformer goes top down */ class TermTransformer { public: + TermTransformer() : + _sharedResult(true), + _dontTransformSorts(false) {} + + void createNonShared(){ _sharedResult = false; } + void dontTransformSorts(){ _dontTransformSorts = true; } + virtual ~TermTransformer() {} Term* transform(Term* term); Literal* transform(Literal* lit); + TermList transform(TermList ts); + protected: virtual TermList transformSubterm(TermList trm) = 0; + // Deliberately empty bodies. + // By default we do nothing on entry and exit + virtual void onTermEntry(Term*){} + virtual void onTermExit(Term*){} + // default implementation explores all subterms when + // a term has not been transformed (orig == new) + // and none otherwise + virtual bool exploreSubterms(TermList orig, TermList newTerm); Term* transformSpecial(Term* specialTerm); - TermList transform(TermList ts); + virtual Formula* transform(Formula* f); + bool _sharedResult; + bool _dontTransformSorts; + +private: + template + Term* create(Term* t, TermList* argLst, bool shared) + { return shared ? T::create(static_cast(t), argLst) : T::createNonShared(static_cast(t), argLst); } +}; + +class SubtermReplacer : public TermTransformer { +public: + SubtermReplacer(TermList what, TermList by +#if VHOL + , bool liftFree = false +#endif + ) : + _what(what) + , _by(by) +#if VHOL + , _liftFreeIndices(liftFree) + , _shiftBy(0) +#endif + { + ASS(what.isVar() || by.isVar() || SortHelper::getResultSort(what.term()) == SortHelper::getResultSort(by.term())); + dontTransformSorts(); + } + + TermList transformSubterm(TermList t) override; + +#if VHOL + void onTermEntry(Term* t) override; + void onTermExit(Term* t) override; +#endif + +private: + TermList _what; + TermList _by; +#if VHOL + bool _liftFreeIndices; // true if need to lift free indices in _what + int _shiftBy; // the amount to shift a free index by +#endif +}; + +class ToBank : public TermTransformer +{ +public: + ToBank(VarBank bank) : _bank(bank) {} + + Term* toBank(Term* t){ return transform(t); } + Literal* toBank(Literal* l){ return transform(l); } + TypedTermList toBank(TypedTermList term); + + TermList transformSubterm(TermList t) override; + bool exploreSubterms(TermList orig, TermList newTerm) override; +private: + VarBank _bank; }; + /** * Has similar philosophy to TermTransformer, but: * goes bottom up and so subterms of currently considered terms @@ -71,7 +146,6 @@ class BottomUpTermTransformer { Formula* transform(Formula* f); }; - } #endif // __TermTransformer__ diff --git a/Kernel/TypedTermList.hpp b/Kernel/TypedTermList.hpp index ad9af1b3fa..df9ee5f2fb 100644 --- a/Kernel/TypedTermList.hpp +++ b/Kernel/TypedTermList.hpp @@ -22,7 +22,13 @@ class TypedTermList : public TermList public: CLASS_NAME(TypedTermList) - TypedTermList(TermList t, SortId sort) : TermList(t), _sort(sort) { ASS_NEQ(sort, AtomicSort::superSort()) } + TypedTermList(TermList t, SortId sort) : TermList(t), _sort(sort) + { + // TODO we have some use cases where we want to enter a sort + // with sort SuperSort(). See BoolInstantiation + // ASS_NEQ(sort, AtomicSort::superSort()); + ASS(!sort.isEmpty()) + } TypedTermList(Term* t) : TypedTermList(TermList(t), SortHelper::getResultSort(t)) {} SortId sort() const { return _sort; } diff --git a/Kernel/Unit.hpp b/Kernel/Unit.hpp index 62fad37ff0..68d348cc35 100644 --- a/Kernel/Unit.hpp +++ b/Kernel/Unit.hpp @@ -76,12 +76,10 @@ class Unit bool derivedFromGoal() const { return _inference.derivedFromGoal(); } /** see isPureTheoryDescendant in Inference.cpp */ bool isPureTheoryDescendant() const { return _inference.isPureTheoryDescendant(); } - /** see isCombAxiomsDescendant in Inference.cpp */ - bool isCombAxiomsDescendant() const { return _inference.isCombAxiomsDescendant(); } +#if VHOL /** see isProxyAxiomsDescendant in Inference.cpp */ bool isProxyAxiomsDescendant() const { return _inference.isProxyAxiomsDescendant(); } - /** see isHolAxiomsDescendant in Inference.cpp */ - bool isHolAxiomsDescendant() const { return _inference.isHolAxiomsDescendant(); } +#endif /** see isTheoryAxiom in Inference.cpp */ bool isTheoryAxiom() const { return _inference.isTheoryAxiom(); } diff --git a/Lib/ArrayMap.hpp b/Lib/ArrayMap.hpp index 7413471a3f..a1bc08d123 100644 --- a/Lib/ArrayMap.hpp +++ b/Lib/ArrayMap.hpp @@ -79,6 +79,7 @@ class ArrayMap _timestamp=1; } } + using DArray::keepRecycled; /** * Ensure that keys less than @b size can be stored in the map diff --git a/Lib/Backtrackable.hpp b/Lib/Backtrackable.hpp index 01b749c800..4532cc90c7 100644 --- a/Lib/Backtrackable.hpp +++ b/Lib/Backtrackable.hpp @@ -18,6 +18,7 @@ #include "List.hpp" #include "Int.hpp" #include "VString.hpp" +#include "Lib/Stack.hpp" namespace Lib { @@ -49,6 +50,8 @@ class BacktrackObject #if VDEBUG virtual vstring toString() const { return "(backtrack object)"; } #endif + template + static BacktrackObject* fromClosure(F f); private: /** * Pointer to the @b BacktrackObject that is previous (i.e. next older) in the @@ -57,8 +60,27 @@ class BacktrackObject BacktrackObject* _next; friend class BacktrackData; + template friend class BacktrackClosure; }; +template +class BacktrackClosure : public BacktrackObject +{ + F _fun; +public: + CLASS_NAME(BacktrackClosure); + USE_ALLOCATOR(BacktrackClosure); + BacktrackClosure(BacktrackClosure&&) = default; + BacktrackClosure& operator=(BacktrackClosure&&) = default; + + BacktrackClosure(F fun) : _fun(std::move(fun)) {} + void backtrack() { _fun(); } +}; + +template +BacktrackObject* BacktrackObject::fromClosure(F f) { return new BacktrackClosure(std::move(f)); } + + /** * Class of objects used to store the change history of * @b Backtrackable objects @@ -130,6 +152,10 @@ class BacktrackData _boList=bo; } + template + void addClosure(F function) + { addBacktrackObject(BacktrackObject::fromClosure(std::move(function))); } + /** * Move all BacktrackObjects from @b this to @b bd. After the * operation, @b this is empty. @@ -220,6 +246,7 @@ class BacktrackData }; }; + /** * A parent class for objects that allow for being restored * to their previous state @@ -259,7 +286,7 @@ class Backtrackable * Ensures that calls to @b bdRecord / @b bdDoNotRecord and * @b bdDone were properly paired. */ - ~Backtrackable() { ASS_EQ(_bdStack,0); } + ~Backtrackable() { ASS_EQ(_bdStack.size(),0); } #endif /** * Start recording object changes into the @b bd object @@ -267,9 +294,7 @@ class Backtrackable * The recording is stopped by a call to the @b bdDone function. */ void bdRecord(BacktrackData& bd) - { - _bdStack=new List(&bd, _bdStack); - } + { _bdStack.push(&bd); } /** * Start ignoring object changes instead of possibly recording them @@ -278,9 +303,7 @@ class Backtrackable * The ignoring is stopped by a call to the @b bdDone function. */ void bdDoNotRecord() - { - _bdStack=new List(0, _bdStack); - } + { _bdStack.push(nullptr); } /** * Finish a request on recording or ignoring object changes and get @@ -289,9 +312,7 @@ class Backtrackable * @see Backtrackable */ void bdDone() - { - List::pop(_bdStack); - } + { _bdStack.pop(); } /** * Move all change records from @b bd to the BacktrackData object associated @@ -317,14 +338,14 @@ class Backtrackable /** * Initialize a Backtrackable object */ - Backtrackable() : _bdStack(0) {} + Backtrackable() : _bdStack() {} /** * Return true iff we are currently recording object changes */ bool bdIsRecording() { - return _bdStack && _bdStack->head(); + return !_bdStack.isEmpty() && _bdStack.top() != nullptr; } /** @@ -351,7 +372,7 @@ class Backtrackable CALL("Backtrackable::bdGet"); ASS(bdIsRecording()); - return *_bdStack->head(); + return *_bdStack.top(); } private: /** @@ -361,9 +382,16 @@ class Backtrackable * A list link that contains 0 at the place of the @b BacktrackData * pointer corresponds to a @b bdDoNotRecord call. */ - List* _bdStack; + Stack _bdStack; }; +template +void backtrackablePush(Stack& s, C v, BacktrackData& bd) +{ + s.push(std::move(v)); + bd.addClosure([&](){ s.pop(); }); +} + }; #endif // __Backtrackable__ diff --git a/Lib/Coproduct.hpp b/Lib/Coproduct.hpp index f05427909c..3190e9d8eb 100644 --- a/Lib/Coproduct.hpp +++ b/Lib/Coproduct.hpp @@ -410,7 +410,7 @@ class Coproduct */ \ template \ inline Option REF> as() REF \ - { return is() ? unwrap() : Option REF>(); } \ + { return is() ? Option REF>(unwrap()) : Option REF>(); } \ FOR_REF_QUALIFIER(REF_POLYMORPIHIC) #undef REF_POLYMORPIHIC @@ -451,6 +451,13 @@ class Coproduct friend bool operator>=(Coproduct const& lhs, Coproduct const& rhs) { return lhs > rhs || lhs == rhs; } + unsigned defaultHash() const + { return Lib::HashUtils::combine( std::hash{}(_tag), apply([](auto const& x){ return x.defaultHash(); })); } + + unsigned defaultHash2() const + { return Lib::HashUtils::combine( std::hash{}(_tag), apply([](auto const& x){ return x.defaultHash2(); })); } + + Coproduct clone() const { return apply([](auto& x){ return Coproduct(x.clone()); }); } }; // class Coproduct diff --git a/Lib/DArray.hpp b/Lib/DArray.hpp index c19d46c7c1..99d20e6269 100644 --- a/Lib/DArray.hpp +++ b/Lib/DArray.hpp @@ -83,6 +83,17 @@ class DArray } } + void swap(DArray& other) { + std::swap(other._size, _size); + std::swap(other._capacity, _capacity); + std::swap(other._array, _array); + } + + bool keepRecycled() const { return _capacity > 0; } + + DArray(DArray&& other) : DArray() { swap(other); } + DArray& operator=(DArray&& other) { swap(other); return *this; } + /** Delete array */ inline ~DArray() @@ -179,6 +190,7 @@ class DArray return false; } // ensure + /** * Set array's size to @b s and that its capacity is at least @b s. * If the capacity is smaller, the array will expand, and all old diff --git a/Lib/DHMap.hpp b/Lib/DHMap.hpp index 36edf96ddf..955f808b3c 100644 --- a/Lib/DHMap.hpp +++ b/Lib/DHMap.hpp @@ -70,12 +70,10 @@ class DHMap : _timestamp(1), _size(0), _deleted(0), _capacityIndex(0), _capacity(0), _nextExpansionOccupancy(0), _entries(0), _afterLast(0) { - typename DHMap::Iterator iit(obj); + typename DHMap::IteratorBase iit(obj); while(iit.hasNext()) { - Key k; - Val v; - iit.next(k, v); - ALWAYS(insert(k,v)); + auto e = iit.next(); + ALWAYS(insert(e->_key,e->_val)); } } @@ -129,6 +127,21 @@ class DHMap } } + bool keepRecycled() const { return _capacity > 0; } + + Option find(Key const& k) const + { + auto e = findEntry(k); + return someIf(e != nullptr, [&]() -> Val const& { return e->_val; }); + } + + + Option find(Key const& k) + { + auto e = findEntry(k); + return someIf(e != nullptr, [&]() -> Val & { return e->_val; }); + } + /** * Find value by the @b key. The result is true if a pair * with this key is in the map. If such a pair is found, @@ -136,7 +149,7 @@ class DHMap * value of @b val remains unchanged. */ inline - bool find(Key key, Val& val) const + bool find(Key const& key, Val& val) const { CALL("DHMap::find/2"); const Entry* e=findEntry(key); @@ -162,15 +175,15 @@ class DHMap return &e->_val; } - /** - * Return true iff a pair with @b key as a key is in the map. - */ - inline - bool find(Key key) const - { - CALL("DHMap::find/1"); - return findEntry(key); - } + // /** + // * Return true iff a pair with @b key as a key is in the map. + // */ + // inline + // bool find(Key key) const + // { + // CALL("DHMap::find/1"); + // return findEntry(key); + // } /** * Return value associated with given key. A pair with @@ -236,10 +249,14 @@ class DHMap } } - /** same as @b insert but using move semantics instead of copying */ - bool emplace(Key key, Val&& val) + /** + * If there is no value stored under @b key in the map, + * insert pair (key,value) and return true. Otherwise, + * return false. + */ + bool insert(Key key, Val val) { - CALL("DHMap::emplace"); + CALL("DHMap::insert"); ensureExpanded(); Entry* e=findEntryToInsert(key); bool exists = e->_info.timestamp==_timestamp && !e->_info.deleted; @@ -253,25 +270,14 @@ class DHMap _deleted--; } e->_info.deleted=0; - e->_key=key; - e->_val=std::move(val); + e->_key = std::move(key); + e->_val = std::move(val); _size++; } return !exists; } - /** - * If there is no value stored under @b key in the map, - * insert pair (key,value) and return true. Otherwise, - * return false. - * This function copies copies @b val. - */ - bool insert(Key key, const Val& val) - { - CALL("DHMap::insert"); - return emplace(key, Val(val)); - } /** * If there is no value stored under @b key in the map, @@ -396,11 +402,11 @@ class DHMap * previously stored under @b key. Otherwise, * return false. */ - bool set(Key key, const Val& val) + bool set(Key key, Val val) { CALL("DHMap::set"); ensureExpanded(); - Entry* e=findEntryToInsert(key); + Entry* e = findEntryToInsert(std::move(key)); bool exists = e->_info.timestamp==_timestamp && !e->_info.deleted; if(!exists) { if(e->_info.timestamp!=_timestamp) { @@ -415,7 +421,7 @@ class DHMap e->_key=key; _size++; } - e->_val=val; + e->_val = std::move(val); return !exists; } @@ -446,7 +452,7 @@ class DHMap * If there is a value stored under the @b key, remove * it and return true. Otherwise, return false. */ - bool remove(Key key) + bool remove(Key const& key) { CALL("DHMap::remove"); Entry* e=findEntry(key); @@ -563,7 +569,7 @@ class DHMap while(ep!=oldAfterLast) { ASS(ep); if(ep->_info.timestamp==oldTimestamp && !ep->_info.deleted) { - insert(ep->_key, ep->_val); + insert(std::move(ep->_key), std::move(ep->_val)); } (ep++)->~Entry(); } @@ -574,17 +580,18 @@ class DHMap } } + /** Return pointer to an Entry object which contains specified key, * or 0, if there is no such */ inline - Entry* findEntry(Key key) + Entry* findEntry(Key const& key) { return const_cast(static_cast(this)->findEntry(key)); } /** Return pointer to an Entry object which contains specified key, * or 0, if there is no such */ - const Entry* findEntry(Key key) const + const Entry* findEntry(Key const& key) const { CALL("DHMap::findEntry"); if (_capacity == 0) return nullptr; @@ -627,7 +634,7 @@ class DHMap /** Return pointer to an Entry object which contains, or could contain * specified key */ - Entry* findEntryToInsert(Key key) + Entry* findEntryToInsert(Key const& key) { CALL("DHMap::findEntryToInsert"); ensureExpanded(); @@ -763,7 +770,7 @@ class DHMap return VirtualIterator(new RangeIteratorCore(*this)); } - typedef std::pair Item; + typedef std::pair Item; private: class ItemIteratorCore diff --git a/Lib/DHSet.hpp b/Lib/DHSet.hpp index c2a094722e..96e2a50b64 100644 --- a/Lib/DHSet.hpp +++ b/Lib/DHSet.hpp @@ -49,11 +49,17 @@ class DHSet _map.reset(); } + DHSet() : _map() {} + DHSet(DHSet&&) = default; + DHSet& operator=(DHSet&&) = default; + + bool keepRecycled() const { return _map.keepRecycled(); } + /** * Return true iff @b val is in the set. */ inline - bool find(Val val) const + bool find(Val const& val) const { CALL("DHSet::find"); @@ -66,7 +72,7 @@ class DHSet * (synomym for the @b find function) */ inline - bool contains(Val val) const + bool contains(Val const& val) const { CALL("DHSet::contains"); @@ -81,7 +87,7 @@ class DHSet { CALL("DHSet::insert"); - return _map.insert(val, EmptyStruct()); + return _map.insert(std::move(val), EmptyStruct()); } @@ -89,7 +95,7 @@ class DHSet * If there is a value stored under the @b key, remove * it and return true. Otherwise, return false. */ - bool remove(Val val) + bool remove(Val const& val) { CALL("DHSet::remove"); diff --git a/Lib/Hash.hpp b/Lib/Hash.hpp index 6d8c72063d..dd07d06ee3 100644 --- a/Lib/Hash.hpp +++ b/Lib/Hash.hpp @@ -22,6 +22,7 @@ #include "Forwards.hpp" #include "VString.hpp" #include "Kernel/Unit.hpp" +#include "Lib/Option.hpp" // the 32-bit FNV prime static const unsigned FNV32_PRIME = 16777619; @@ -93,9 +94,8 @@ struct StackHash { // TODO equals()? template static unsigned hash(const Stack& s, unsigned hash = FNV32_OFFSET_BASIS) { - typename Stack::ConstIterator it(s); - while(it.hasNext()) { - hash = HashUtils::combine(hash, ElementHash::hash(it.next())); + for (auto& x : s) { + hash = HashUtils::combine(hash, ElementHash::hash(x)); } return hash; } @@ -115,6 +115,27 @@ struct VectorHash { } }; +template +struct TupleHash { + + template + static inline typename std::enable_if::type + tuple_hash_impl(const std::tuple &t) { return 0; } + + template + static inline typename std::enable_if::type + tuple_hash_impl(const std::tuple &t) + { return Lib::HashUtils::combine(tuple_hash_impl(t), InnerHash::hash(std::get(t))); } + + + template + static unsigned hash(tuple const& s) { + //C++17: repace with std::apply: + // return std::apply(s, [](auto... args) { return HashUtils::combine(hash(args)...); }); + return tuple_hash_impl<0>(s); + } +}; + /** * The default hash function (FNV-1a), overloaded for various types * Caveat: this implements the 32-bit variant of FNV-1a @@ -200,6 +221,7 @@ class DefaultHash ); } + /** * FNV-1a with initial value @b hash. * @since 31/03/2006 @@ -229,6 +251,17 @@ class DefaultHash } return hash; } + + + + template + static unsigned hash(tuple const& s) + { return TupleHash::hash(s); } + + template + static unsigned hash(Lib::Option const& o) + { return o.isSome() ? o->defaultHash() + : Lib::DefaultHash::hash(typeid(T).hash_code()); } }; // a default secondary hash for doubly-hashed containers @@ -297,6 +330,14 @@ class DefaultHash2 { DefaultHash2::hash(pp.second) ); } + template + static unsigned hash(tuple const& s) + { return TupleHash::hash(s); } + + template + static unsigned hash(Lib::Option const& o) + { return o.isSome() ? o->defaultHash2() + : Lib::DefaultHash2::hash(typeid(T).hash_code()); } }; } // namespace Lib @@ -309,6 +350,12 @@ template struct hash> { return Lib::StackHash::hash(s); } }; -} + +template struct hash> +{ + size_t operator()(tuple const& s) const + { return Lib::DefaultHash::hash(s); } +}; +} // std #endif diff --git a/Lib/Map.hpp b/Lib/Map.hpp index 51a0088ca1..c416ce452c 100644 --- a/Lib/Map.hpp +++ b/Lib/Map.hpp @@ -208,7 +208,7 @@ class Map */ Option tryGet(Key const& key) const { - CALL("Map::find/2"); + CALL("Map::tryGet"); using Opt = Option; auto code = hashCode(key); diff --git a/Lib/MaybeBool.hpp b/Lib/MaybeBool.hpp index ae571e5c42..ceaedf78e0 100644 --- a/Lib/MaybeBool.hpp +++ b/Lib/MaybeBool.hpp @@ -37,6 +37,7 @@ class MaybeBool MaybeBool(Value val) : _value(val) {} bool known() const { return _value!=UNKNOWN; } + bool maybe() const { return _value==UNKNOWN; } bool isTrue() const { return _value==TRUE; } bool isFalse() const { return _value==FALSE; } diff --git a/Lib/Metaiterators.hpp b/Lib/Metaiterators.hpp index 8c3f21a479..14659a5796 100644 --- a/Lib/Metaiterators.hpp +++ b/Lib/Metaiterators.hpp @@ -22,12 +22,13 @@ #include "Forwards.hpp" #include "Lib/Recycled.hpp" +#include "Lib/Reflection.hpp" #include "List.hpp" #include "DHSet.hpp" -#include "Recycled.hpp" #include "VirtualIterator.hpp" #include "Debug/TimeProfiling.hpp" #include "Lib/Option.hpp" +#include "Lib/Coproduct.hpp" namespace Lib { @@ -61,6 +62,7 @@ class InfiniteArrayIterator { public: DECL_ELEMENT_TYPE(El); + DEFAULT_CONSTRUCTORS(InfiniteArrayIterator) InfiniteArrayIterator(const El* ptr) : _nextPtr(ptr) {} inline bool hasNext() { return true; } inline OWN_ELEMENT_TYPE next() { return *(_nextPtr++); } @@ -103,12 +105,15 @@ class ArrayishObjectIterator public: using Cont = ArrayishContentType; DECL_ELEMENT_TYPE(ref_t); + DEFAULT_CONSTRUCTORS(ArrayishObjectIterator) ArrayishObjectIterator(Cont arr) : _arr(arr), _index(0), _size(_arr.size()) {} ArrayishObjectIterator(Cont arr, size_t size) : _arr(arr), _index(0), _size(size) {} inline bool hasNext() { return _index<_size; } - inline ELEMENT_TYPE(ArrayishObjectIterator) next() { ASS(_index<_size); return _arr[_index++]; } + inline OWN_ELEMENT_TYPE next() + { ASS(_index<_size); + return move_if_value(_arr[_index++]); } inline bool knowsSize() { return true;} inline bool size() { return _size;} private: @@ -142,6 +147,7 @@ class OwnedArrayishIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Arr)); + DEFAULT_CONSTRUCTORS(OwnedArrayishIterator) OwnedArrayishIterator(Arr&& arr) : _arr(std::move(arr)), _index(0), _size(_arr.size()) {} OwnedArrayishIterator(Arr&& arr, size_t size) : _arr(std::move(arr)), @@ -175,6 +181,7 @@ class InputIterator { public: DECL_ELEMENT_TYPE(T); + DEFAULT_CONSTRUCTORS(InputIterator) InputIterator(istream& inp, size_t cnt) : _inp(inp), _remaining(cnt) {} bool hasNext() const { return _remaining>0; } @@ -205,6 +212,7 @@ class PointerIterator { public: DECL_ELEMENT_TYPE(T); + DEFAULT_CONSTRUCTORS(PointerIterator) inline PointerIterator(const T* first, const T* afterLast) : _curr(first), _afterLast(afterLast) {} inline bool hasNext() { ASS(_curr<=_afterLast); return _curr!=_afterLast; } @@ -227,6 +235,7 @@ class PointerPtrIterator { public: DECL_ELEMENT_TYPE(T*); + DEFAULT_CONSTRUCTORS(PointerPtrIterator) inline PointerPtrIterator(T* first, T* afterLast) : _curr(first), _afterLast(afterLast) {} inline bool hasNext() { ASS(_curr<=_afterLast); return _curr!=_afterLast; } @@ -236,6 +245,23 @@ class PointerPtrIterator T* _afterLast; }; +template +class ConstPointerPtrIterator +{ +public: + DECL_ELEMENT_TYPE(const T*); + DEFAULT_CONSTRUCTORS(ConstPointerPtrIterator) + inline ConstPointerPtrIterator(T const* first, T const* afterLast) : + _curr(first), _afterLast(afterLast) {} + inline bool hasNext() { ASS(_curr<=_afterLast); return _curr!=_afterLast; } + inline const T* next() { ASS(hasNext()); return _curr++; } +private: + const T *_curr; + const T *_afterLast; +}; + + + /** * Iterator returning a single element @@ -247,6 +273,7 @@ class SingletonIterator { public: DECL_ELEMENT_TYPE(T); + DEFAULT_CONSTRUCTORS(SingletonIterator) explicit SingletonIterator(T el) : _finished(false), _el(el) {} inline bool hasNext() { return !_finished; }; inline T next() { ASS(!_finished); _finished=true; return _el; }; @@ -303,7 +330,8 @@ class StaticCastIterator { public: DECL_ELEMENT_TYPE(To); - explicit StaticCastIterator(Inner inn) :_inn(inn) {} + DEFAULT_CONSTRUCTORS(StaticCastIterator) + explicit StaticCastIterator(Inner inn) :_inn(std::move(inn)) {} inline bool hasNext() { return _inn.hasNext(); }; inline To next() { return static_cast(_inn.next()); }; private: @@ -403,6 +431,7 @@ class FilteredIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Inner)); + DEFAULT_CONSTRUCTORS(FilteredIterator) FilteredIterator(Inner inn, Functor func) : _func(std::move(func)), _inn(std::move(inn)), _next() {} @@ -414,23 +443,25 @@ class FilteredIterator return true; } while(_inn.hasNext()) { - auto next = _inn.next(); + OWN_ELEMENT_TYPE next = move_if_value(_inn.next()); if(_func(next)) { - _next = Option(std::move(next)); - return true; + _next = Option(move_if_value(next)); + return true; } } return false; - }; + } + OWN_ELEMENT_TYPE next() { CALL("FilteredIterator::next") ALWAYS(hasNext()); ASS(_next.isSome()); - auto out = std::move(_next).unwrap(); + OWN_ELEMENT_TYPE out = move_if_value(_next.unwrap()); _next = Option(); return out; - }; + } + private: Functor _func; @@ -438,6 +469,112 @@ class FilteredIterator Option _next; }; +template +class TakeWhileIter +{ +public: + DECL_ELEMENT_TYPE(ELEMENT_TYPE(Iter)); + DEFAULT_CONSTRUCTORS(TakeWhileIter) + + TakeWhileIter(Iter iter, Pred pred) + : _pred(std::move(pred)), _iter(std::move(iter)), _next(), _break(false) {} + + bool hasNext() + { + if (_break) return false; + if(_next.isSome()) return true; + + while(_iter.hasNext()) { + OWN_ELEMENT_TYPE next = move_if_value(_iter.next()); + if(_pred(next)) { + _next = Option(move_if_value(next)); + return true; + } else { + _break = true; + return false; + } + } + return false; + } + + OWN_ELEMENT_TYPE next() + { + ASS(!_break) + ALWAYS(hasNext()); + ASS(_next.isSome()); + OWN_ELEMENT_TYPE out = move_if_value(_next.unwrap()); + _next = Option(); + return out; + } + +private: + + Pred _pred; + Iter _iter; + Option _next; + bool _break; +}; + +template +class SortedIterDiff { +public: + DECL_ELEMENT_TYPE(ELEMENT_TYPE(I1)); + DEFAULT_CONSTRUCTORS(SortedIterDiff) + + SortedIterDiff(I1 i1, I2 i2, Cmp cmp) + : _i1(std::move(i1)) + , _i2(std::move(i2)) + , _curr1() + , _curr2(someIf(_i2.hasNext(), [&]() -> OWN_ELEMENT_TYPE { return move_if_value(_i2.next()); })) + , _cmp(std::move(cmp)) + {} + + void moveToNext() + { +# if VDEBUG + Option old1; +# endif + while (_curr1.isNone() && _i1.hasNext()) { + _curr1 = Option(move_if_value(_i1.next())); + ASS_REP(!_curr1.isSome() || !old1.isSome() || _cmp(*old1, *_curr1) <= 0, "iterator I1 must be sorted"); + while (_curr2.isSome() && _cmp(*_curr2, *_curr1) < 0) { +# if VDEBUG + Option old2 = _curr2.take(); +# endif + _curr2 = someIf(_i2.hasNext(), [&]() -> OWN_ELEMENT_TYPE + { return move_if_value(_i2.next()); }); + ASS_REP(!_curr2.isSome() || !old2.isSome() || _cmp(*old2, *_curr2) <= 0, "iterator I2 must be sorted"); + } + if (( _curr1.isSome() && _curr2.isSome() && _cmp(*_curr1, *_curr2) == 0 ) + || (_curr1.isNone() && _curr2.isNone())) { +# if VDEBUG + old1 = _curr1.take(); +# endif + _curr1 = Option(); + _curr2 = someIf(_i2.hasNext(), [&]() -> OWN_ELEMENT_TYPE + { return move_if_value(_i2.next()); }); + } + } + } + + bool hasNext() + { + moveToNext(); + return _curr1.isSome(); + } + + OWN_ELEMENT_TYPE next() + { + moveToNext(); + return move_if_value(_curr1.take().unwrap()); + } +private: + I1 _i1; + I2 _i2; + Option _curr1; + Option _curr2; + Cmp _cmp; +}; /** * Iterator that maps the contents of another iterator by a function. Whenever the function retuns a non-empty Option @@ -448,6 +585,7 @@ class FilterMapIter { public: DECL_ELEMENT_TYPE(typename std::result_of::type::Content); + DEFAULT_CONSTRUCTORS(FilterMapIter) FilterMapIter(Inner inn, Functor func) : _func(std::move(func)), _inn(std::move(inn)), _next() {} @@ -459,7 +597,7 @@ class FilterMapIter return true; } while(_inn.hasNext()) { - _next = _func(_inn.next()); + _next = _func(move_if_value(_inn.next())); if(_next.isSome()) { return true; } @@ -472,7 +610,7 @@ class FilterMapIter CALL("FilterMapIter::next") ALWAYS(hasNext()); ASS(_next.isSome()); - auto out = std::move(_next).unwrap(); + OWN_ELEMENT_TYPE out = move_if_value(_next.unwrap()); _next = Option(); return out; }; @@ -488,9 +626,10 @@ class FilteredDelIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Inner)); + DEFAULT_CONSTRUCTORS(FilteredDelIterator) FilteredDelIterator(Inner inn, Functor func) - : _func(std::move(func)), _inn(std::move(inn)), _nextStored(false) {} + : _func(func), _inn(inn), _nextStored(false) {} bool hasNext() { if(_nextStored) { @@ -532,12 +671,16 @@ class FilteredDelIterator template inline FilteredIterator getFilteredIterator(Inner inn, Functor func) -{ return FilteredIterator(std::move(inn), std::move(func)); } +{ + return FilteredIterator(std::move(inn), std::move(func)); +} template inline FilteredDelIterator getFilteredDelIterator(Inner inn, Functor func) -{ return FilteredDelIterator(std::move(inn), std::move(func)); } +{ + return FilteredDelIterator(inn, func); +} /** @@ -550,8 +693,9 @@ class WhileLimitedIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Inner)); + DEFAULT_CONSTRUCTORS(WhileLimitedIterator) WhileLimitedIterator(Inner inn, Functor func) - : _func(func), _inn(inn), _nextStored(false) {} + : _func(std::move(func)), _inn(std::move(inn)), _nextStored(false) {} bool hasNext() { if(!_nextStored) { @@ -605,6 +749,7 @@ class CatIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(It1)); + DEFAULT_CONSTRUCTORS(CatIterator) CatIterator(It1 it1, It2 it2) :_first(true), _it1(std::move(it1)), _it2(std::move(it2)) {} @@ -663,9 +808,12 @@ class CatIterator template inline CatIterator getConcatenatedIterator(It1 it1, It2 it2) -{ - return CatIterator(std::move(it1), std::move(it2)); -} +{ return CatIterator(std::move(it1), std::move(it2)); } + +template +inline +auto getConcatenatedIterator(I1 i1, I2 i2, I3 i3, Is... is) +{ return getConcatenatedIterator(getConcatenatedIterator(std::move(i1), std::move(i2)), std::move(i3), std::move(is)...); } @@ -681,10 +829,11 @@ class MappingIterator { public: DECL_ELEMENT_TYPE(ResultType); + DEFAULT_CONSTRUCTORS(MappingIterator) explicit MappingIterator(Inner inner, Functor func) : _func(std::move(func)), _inner(std::move(inner)) {} inline bool hasNext() { CALL("MappingIterator::hasNext"); return _inner.hasNext(); }; - inline ResultType next() { return _func(_inner.next()); }; + inline ResultType next() { return _func(move_if_value(_inner.next())); }; /** * Return true the size of the iterator can be obtained @@ -750,8 +899,10 @@ class MappingIterator * @see MappingIterator */ template -MappingIterator> getMappingIterator(Inner it, Functor f) -{ return MappingIterator>(std::move(it), std::move(f)); } +MappingIterator> getMappingIterator(Inner it, Functor f) +{ + return MappingIterator>(std::move(it), std::move(f)); +} // /** // * Return iterator that returns elements of @b it transformed by @@ -788,6 +939,7 @@ class ConstructingIterator { public: DECL_ELEMENT_TYPE(Constructor*); + DEFAULT_CONSTRUCTORS(ConstructingIterator) explicit ConstructingIterator(Inner inner) : _inner(inner) {} inline bool hasNext() { return _inner.hasNext(); }; @@ -826,12 +978,13 @@ class FlatteningIterator public: using Inner = ELEMENT_TYPE(Master); DECL_ELEMENT_TYPE(ELEMENT_TYPE(Inner)); + DEFAULT_CONSTRUCTORS(FlatteningIterator) explicit FlatteningIterator(Master master) : _master(std::move(master)) - , _current(std::move(_master.hasNext() - ? Option(std::move(_master.next())) - : Option())) + , _current(_master.hasNext() + ? Option(move_if_value(_master.next())) + : Option()) { } bool hasNext() @@ -841,9 +994,9 @@ class FlatteningIterator if (_current.unwrap().hasNext()) { return true; } else { - _current = std::move(_master.hasNext() - ? Option(std::move(_master.next())) - : Option()); + _current = _master.hasNext() + ? Option(move_if_value(_master.next())) + : Option(); } } return false; @@ -855,7 +1008,7 @@ class FlatteningIterator CALL("FlatteningIterator::next"); ASS(_current.isSome()); ASS(_current.unwrap().hasNext()); - return _current.unwrap().next(); + return move_if_value(_current.unwrap().next()); } private: Master _master; @@ -1016,6 +1169,7 @@ class UniquePersistentIterator sizeRef++; } } + return res; } @@ -1043,6 +1197,7 @@ VirtualIterator getUniquePersistentIterator(Inner it) return vi( new UniquePersistentIterator(it) ); } + /** * Return iterator that stores values of the iterator pointed to by @b it * in its constructor, and then yields them in a deterministic order, @@ -1074,8 +1229,6 @@ void makeUnique(Container& cont) VirtualIterator uniqueIt = pvi( getUniquePersistentIterator(ITERATOR_TYPE(Container)(cont)) ); - cont.reset(); - cont.loadFromIterator(uniqueIt); } /** @@ -1105,6 +1258,7 @@ class RangeIterator { public: DECL_ELEMENT_TYPE(T); + DEFAULT_CONSTRUCTORS(RangeIterator) inline RangeIterator(T from, T to) : _next(from), _from(from), _to(to) {} @@ -1135,6 +1289,7 @@ class CombinationIterator { public: DECL_ELEMENT_TYPE(pair); + DEFAULT_CONSTRUCTORS(CombinationIterator) CombinationIterator(T from, T to) : _first(from), _second(from), _afterLast(to) { @@ -1190,6 +1345,7 @@ class Combination2Iterator { public: DECL_ELEMENT_TYPE(pair); + DEFAULT_CONSTRUCTORS(Combination2Iterator) Combination2Iterator(T from, T to1, T to2) : _first(from), _second(from), _afterLast1(to1), _afterLast2(to2) { @@ -1264,9 +1420,10 @@ class ContextualIterator { public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Inner)); + DEFAULT_CONSTRUCTORS(ContextualIterator) ContextualIterator(Inner iit, Ctx context) - : _inContext(false), _used(true), _context(context), _iit(iit) {} + : _inContext(false), _used(true), _context(std::move(context)), _iit(std::move(iit)) {} ~ContextualIterator() { @@ -1282,8 +1439,8 @@ class ContextualIterator if(!_iit.hasNext()) { return false; } - _current=_iit.next(); - } while (!_context.enter(_current)); + _current = Option(_iit.next()); + } while (!_context.enter(_current.unwrap())); _inContext=true; _used=false; @@ -1294,13 +1451,13 @@ class ContextualIterator { ASS(!_used); _used=true; - return _current; + return move_if_value(_current.unwrap()); } private: void assureContextLeft() { if(_inContext) { - _context.leave(_current); + _context.leave(_current.unwrap()); _inContext=false; } } @@ -1309,7 +1466,7 @@ class ContextualIterator bool _used; Ctx _context; Inner _iit; - ELEMENT_TYPE(Inner) _current; + Option _current; }; template @@ -1630,12 +1787,70 @@ struct GetSecondOfPair { } }; + +template +class CoproductIter +{ + Coproduct _inner; +public: + DECL_ELEMENT_TYPE(ELEMENT_TYPE(TypeList::Get<0, TypeList::List>)); + DEFAULT_CONSTRUCTORS(CoproductIter) + + CoproductIter(Coproduct i) : _inner(Coproduct(std::move(i))) {} + + bool hasNext() const + { Coproduct& inner = _inner; + return inner.apply([](auto& x) { return x.hasNext();}); } + + bool hasNext() + { Coproduct& inner = _inner; + return inner.apply([](auto& x) { return x.hasNext();}); } + + OWN_ELEMENT_TYPE next() + { return _inner.apply([](auto&& x) { return x.next();}); } + + bool knowsSize() const + { return _inner.apply([](auto& x) { return x.knowsSize();}); } + + size_t size() const + { return _inner.apply([](auto& x) { return x.size();}); } +}; + +template +auto coproductIter(Coproduct is) +{ return iterTraits(CoproductIter(std::move(is))); } + + +template +static auto _ifElseIter(bool cond, IfIter ifIter, ElseIter elseIter) +{ return iterTraits( + cond ? coproductIter(Coproduct, ResultOf>(ifIter())) + : coproductIter(Coproduct, ResultOf>(elseIter()))); } + +template +static auto ifElseIter(ElseIter elseIter) +{ return elseIter(); } + +template +static auto ifElseIter(bool cond, IfIter ifIter, ElseIters... elseIters) +{ return _ifElseIter(cond, std::move(ifIter), [&]() { return ifElseIter(std::move(elseIters)...); }); } + + +template +static auto concatIters(I1 i1) +{ return iterTraits(std::move(i1)); } + +template +static auto concatIters(I1 i1, I2 i2, Is... is) +{ return iterTraits(getConcatenatedIterator(std::move(i1), concatIters(std::move(i2), std::move(is)...))); } + template class IterTraits { Iter _iter; public: DECL_ELEMENT_TYPE(ELEMENT_TYPE(Iter)); + DEFAULT_CONSTRUCTORS(IterTraits) using Elem = ELEMENT_TYPE(Iter); explicit IterTraits(Iter iter) : _iter(std::move(iter)) {} @@ -1643,7 +1858,7 @@ class IterTraits Elem next() { CALL("IterTraits::next") - return _iter.next(); + return move_if_value(_iter.next()); } bool hasNext() @@ -1654,39 +1869,38 @@ class IterTraits Option tryNext() { - return _iter.hasNext() - ? Option(_iter.next()) - : Option(); + if (_iter.hasNext()) { + return Option(move_if_value(_iter.next())); + } else { + return Option(); + } } - - template - bool any(P f) + template + void forEach(F f) { - CALL("IterTraits::any") + CALL("IterTraits::forEach") while (hasNext()) { - if (f(next())) return true; + f(next()); } - return false; } template - bool all(P f) + bool any(P p) { - CALL("IterTraits::all") - while (hasNext()) { - if (!f(next())) return false; - } - return true; + CALL("IterTraits::any") + return find(p).isSome(); } - template - void forEach(F f) + + template + bool all(P p) { - CALL("IterTraits::forEach") - while (hasNext()) { - f(next()); - } + CALL("IterTraits::all") + while (hasNext()) + if (!p(next())) + return false; + return true; } template @@ -1725,6 +1939,10 @@ class IterTraits IterTraits> map(F f) { return iterTraits(getMappingIterator(std::move(_iter), std::move(f))); } + template + auto inspect(F f) + { return map([f = std::move(f)](auto x) { f(x); return x; }); } + template IterTraits> filter(F f) { return iterTraits(getFilteredIterator(std::move(_iter), std::move(f))); } @@ -1737,6 +1955,12 @@ class IterTraits IterTraits> flatMap(F f) { return iterTraits(getFlattenedIterator(getMappingIterator(std::move(_iter), std::move(f)))); } + auto flatten() + { return iterTraits(getFlattenedIterator(std::move(_iter))); } + + template + auto takeWhile(Pred p) + { return iterTraits(TakeWhileIter(std::move(_iter), std::move(p))); } /** * returns the first minimal element wrt the function `less` @@ -1761,6 +1985,15 @@ class IterTraits } } + unsigned count() + { + unsigned i = 0; + while (hasNext()) { + i++; + next(); + } + return i; + } Option min() { return minBy(std::less{}); } @@ -1773,24 +2006,30 @@ class IterTraits { return maxBy(std::less{}); } auto timeTraced(const char* name) - { return iterTraits(timeTracedIter(name, std::move(_iter))); } + { return iterTraits(timeTraceIter(name, std::move(_iter))); } - template - auto fold(Init init, F fun) + template + auto fold(Result init, F f) -> Result { - Init res = std::move(init); + CALL("IterTraits::fold") + Result accum = std::move(init); while (hasNext()) { - res = fun(std::move(res), next()); + accum = f(std::move(accum), next()); } - return res; + return accum; } template - auto fold(F fun) - { return fold(next(), std::move(fun)); } + auto fold(F fun) -> Option + { return someIf(hasNext(), [&]() { return fold(next(), std::move(fun)); }); } + + template + auto zip(OtherIter other) + { return map([other = std::move(other)](Elem x) mutable { return make_pair(std::move(x), other.next()); }); } + auto sum() - { return fold(0, [](auto l, Elem&& r) { return l + r; }); } + { return fold([](Elem l, Elem r) { return l + r; }) || []() { return Elem(0); }; } template Container collect() @@ -1799,13 +2038,15 @@ class IterTraits return Container::fromIterator(*this); } - template class Container> Container collect() { CALL("IterTraits::collect/2") - return Container::fromIterator(*this); + return Container::fromIterator(std::move(*this)); } + + IterTraits clone() + { return *this; } /** This class is to be used in the context of a for (auto x : ...) loop only. */ class StlIter @@ -1814,14 +2055,14 @@ class IterTraits Option _cur; public: - StlIter(IterTraits& iter) : _iter(Option(iter)), _cur(std::move(iter.tryNext())) {} + StlIter(IterTraits& iter) : _iter(Option(iter)), _cur(iter.tryNext()) {} StlIter() : _iter(), _cur() {} void operator++() { _cur = _iter.unwrap().tryNext(); } Elem operator*() - { return _cur.unwrap(); } + { return move_if_value(_cur.unwrap()); } friend bool operator!=(StlIter const& lhs, StlIter const& rhs) { return !(lhs == rhs); } @@ -1845,17 +2086,49 @@ template IterTraits iterTraits(Iter i) { return IterTraits(std::move(i)); } -template -static auto concatIters(I1 i1) -{ return iterTraits(std::move(i1)); } +static const auto range = [](auto from, auto to) + { return iterTraits(getRangeIterator(from, to)); }; -template -static auto concatIters(I1 i1, I2 i2, Is... is) -{ return iterTraits(getConcatenatedIterator(std::move(i1), concatIters(std::move(i2), std::move(is)...))); } +template +auto iterSortedDiff(I1 i1, I2 i2, Cmp cmp) +{ return iterTraits(SortedIterDiff(std::move(i1), std::move(i2), std::move(cmp))); } +template +auto iterSortedDiff(I1 i1, I2 i2) +{ return iterSortedDiff(std::move(i1), std::move(i2), [&](auto& l, auto& r) { return l == r ? 0 : l < r ? -1 : 1; }); } ///@} +template +auto dropElementType(Iterator iter) +{ return iterTraits(std::move(iter)).map([](auto _) { return make_tuple(); }); } + +template +auto arrayIter(Array const& x) +{ return iterTraits(getArrayishObjectIterator(x)); } + +template +auto arrayIter(Array & x) +{ return iterTraits(getArrayishObjectIterator(x)); } + +template +auto arrayIter(Array && x) +{ return iterTraits(ownedArrayishIterator(std::move(x))); } + +// template +// class IterAsData { +// CreateIter _iter; +// public: +// friend bool operator<(IterAsData const&l, IterAsData const&r) +// { +// auto i1 = iterTraits(l._iter()); +// auto i2 = iterTraits(l._iter()); +// while (i1.hasNext() && i2.hasNext>()) +// } +// }; +// +// template +// auto iterAsData(Iter iter) { return IterAsData(std::move(iter)); } } #endif /* __Metaiterators__ */ diff --git a/Lib/Option.hpp b/Lib/Option.hpp index b07f4d2d56..c33f79b655 100644 --- a/Lib/Option.hpp +++ b/Lib/Option.hpp @@ -7,6 +7,7 @@ * https://vprover.github.io/license.html * and in the source directory */ + /** * This file mainly defined the class Option, which can be thought of as a NULLable pointer, that is * stack-allocated, with RAII semantics. @@ -20,12 +21,50 @@ #include "Debug/Assertion.hpp" #include "Debug/Tracer.hpp" #include +#include "Lib/Reflection.hpp" namespace Lib { - -#define FOR_REF_QUALIFIER(macro) \ +template< + class T, + typename std::enable_if::value, bool>::type = true + > +T move_if_value(std::remove_reference_t && t) +{ return t; } + + +template< + class T, + typename std::enable_if::value, bool>::type = true + > +T move_if_value(std::remove_reference_t& t) +{ return t; } + + +template< + class T, + typename std::enable_if< !std::is_reference::value , bool>::type = true + > +T move_if_value(T& t) +{ return std::move(t); } + +template< + class T, + typename std::enable_if< !std::is_reference::value , bool>::type = true + > +T move_if_value(T const& t) +{ return std::move(t); } + + +template< + class T, + typename std::enable_if< !std::is_reference::value , bool>::type = true + > +T move_if_value(T && t) +{ return std::move(t); } + +#define FOR_REF_QUALIFIER(macro) \ macro(const &, ) macro(&, ) macro(&&, std::move) template @@ -39,22 +78,22 @@ struct MaybeUninit { MaybeUninit() : _elem() {} ~MaybeUninit() {} // This macro will b expanded for (REF,MV) in { (`&&`, `std::move`), (`&`, ``), (`const &`, ``) } -#define for_ref_qualifier(REF, MV) \ - operator T REF() REF \ - { return MV(_elem.init); } \ - \ - void init(T REF content) \ - { ::new(&_elem.init)T(MV(content)); } \ - \ - MaybeUninit& operator=(T REF content) \ - { \ - _elem.init = MV(content); \ - return *this; \ - } \ - - FOR_REF_QUALIFIER(for_ref_qualifier) - -#undef for_ref_qualifier +#define methods(REF, MV) \ + operator T REF() REF \ + { return MV(_elem.init); } \ + \ + void init(T REF content) \ + { ::new(&_elem)T(MV(content)); } \ + \ + MaybeUninit& operator=(T REF content) \ + { \ + _elem.init = MV(content); \ + return *this; \ + } \ + + FOR_REF_QUALIFIER(methods) + +#undef methods }; template @@ -74,60 +113,65 @@ class OptionBase unwrap().~A(); } } - explicit OptionBase(A content) - : _isSome(true) - , _elem() + +#define methods(REF, MV) \ + explicit OptionBase(A REF content) \ + : _isSome(true) \ + , _elem() \ + { \ + CALL("Option(A " #REF ")") \ + _elem.init(move_if_value(content)); \ + } \ + \ + A REF unwrap() REF \ + { \ + ASS(_isSome); \ + return MV(_elem); \ + } \ + \ + OptionBase(OptionBase REF a) : _isSome(a._isSome) \ + { \ + CALL("OptionBase(OptionBase " #REF ")"); \ + if (isSome()) { \ + _elem.init(MV(a).unwrap()); \ + } \ + } \ + + FOR_REF_QUALIFIER(methods) + +#undef methods + + OptionBase& operator=(OptionBase&& other) { - CALL("Option(A)") - _elem.init(std::move(content)); + CALL("OptionBase& operator=(OptionBase&&)"); + if (_isSome) { + unwrap().~A(); + } + if (other._isSome) { + _elem.init(move_if_value(other.unwrap())); + } + _isSome = other._isSome; + return *this; } - -// This macro will b expanded for (REF,MV) in { (`&&`, `std::move`), (`&`, ``), (`const &`, ``) } -#define for_ref_qualifier(REF, MV) \ - \ - A REF unwrap() REF \ - { \ - ASS(_isSome); \ - return MV(_elem); \ - } \ - \ - OptionBase(OptionBase REF a) : _isSome(a._isSome) \ - { \ - CALL("OptionBase(OptionBase " #REF ")"); \ - if (isSome()) { \ - _elem.init(MV(a).unwrap()); \ - } \ - } \ - \ - OptionBase& operator=(OptionBase REF other) \ - { \ - CALL("OptionBase& operator=(OptionBase "#REF")"); \ - \ - if (_isSome) { \ - if (other._isSome) { \ - unwrap() = MV(other).unwrap(); \ - } else { \ - unwrap().~A(); \ - } \ - } else { \ - ASS(isNone()) \ - if (other._isSome){ \ - _elem.init(MV(other).unwrap()); \ - } else { \ - /* nothing to do */ \ - } \ - } \ - _isSome = other._isSome; \ - return *this; \ - } \ - - FOR_REF_QUALIFIER(for_ref_qualifier) - -#undef for_ref_qualifier + + OptionBase& operator=(OptionBase const& other) + { + CALL("OptionBase& operator=(OptionBase const&)"); + if (_isSome) { + unwrap().~A(); + } + if (other._isSome) { + _elem.init(other.unwrap()); + } + _isSome = other._isSome; + return *this; + } + bool isSome() const { return _isSome; } bool isNone() const { return !isSome(); } + static OptionBase fromPtr(A* ptr) { return ptr == nullptr ? OptionBase() : OptionBase(*ptr); } @@ -149,6 +193,7 @@ class OptionBase template class OptionBaseRef { + A* _elem; public: @@ -174,7 +219,8 @@ class OptionBaseRef { return ptr == nullptr ? OptionBaseRef() : *ptr; } friend bool operator==(OptionBaseRef const& lhs, OptionBaseRef const& rhs) - { return *lhs._elem == *rhs._elem; } + { return (lhs._elem == nullptr && rhs._elem == nullptr) + || (lhs._elem != nullptr && rhs._elem != nullptr && *lhs._elem == *rhs._elem); } }; @@ -183,7 +229,7 @@ class OptionBase : public OptionBaseRef { public: OptionBase() : OptionBaseRef() {} - explicit OptionBase(A const& item) : OptionBaseRef(&item) {} + OptionBase(A const& item) : OptionBaseRef(&item) {} OptionBase(OptionBase const& b) : OptionBaseRef(b) {} }; @@ -192,7 +238,17 @@ class OptionBase : public OptionBaseRef { public: OptionBase() : OptionBaseRef() {} - explicit OptionBase(A& item) : OptionBaseRef(&item) {} + OptionBase(A& item) : OptionBaseRef(&item) {} + OptionBase(OptionBase const& b) : OptionBaseRef(b) {} +}; + + +template +class OptionBase : public OptionBaseRef +{ +public: + OptionBase() : OptionBaseRef() {} + OptionBase(A&& item) : OptionBaseRef(&item) {} OptionBase(OptionBase const& b) : OptionBaseRef(b) {} }; @@ -244,6 +300,7 @@ class Option : OptionBase { std::remove_reference_t * asPtr() { return isSome() ? &unwrap() : nullptr; } std::remove_reference_t const* asPtr() const { return isSome() ? &unwrap() : nullptr; } + /** * returns the value held by this option if there is one, or calls the given function f without arguments, * initializes the closuer with the returned value, and returns a reference to the value afterwards. @@ -256,93 +313,203 @@ class Option : OptionBase { return this->unwrap(); } -// This macro will b expanded for (REF,MV) in { (`&&`, `std::move`), (`&`, ``), (`const &`, ``) } -#define for_ref_qualifier(REF, MOVE) \ - \ - /** \ - * applies the given function to the value of this option and returns an option of the return type. \ - * if the Option was None an empty option of the function's return type is returned. \ - */ \ - template \ - Option::type> map(Clsr clsr) REF { \ - using OptOut = Option::type>; \ - return this->isSome() ? OptOut(clsr(MOVE(this->unwrap()))) \ - : OptOut(); \ - } \ - \ - /** \ - * if the Option holds a value the first function is applied to the value. \ - * if the Option is none the second function is called without arguments and the result is returned. \ - * \pre both CaseSome and CaseNone must have the same return type \ - */ \ - template \ - typename std::result_of::type match(CaseSome present, CaseNone none) REF { \ - if (this->isSome()) { \ - return present(MOVE((*this)).unwrap()); \ - } else { \ - return none(); \ - } \ - } \ - \ - /** \ +#define ref_polymorphic(REF, MOVE) \ + \ + /** \ + * applies the given function to the value of this option and returns an option of the return type. \ + * if the Option was None an empty option of the function's return type is returned. \ + */ \ + template \ + Option::type> map(Clsr clsr) REF { \ + using OptOut = Option::type>; \ + return this->isSome() ? OptOut(clsr(MOVE(unwrap()))) \ + : OptOut(); \ + } \ + \ + /** \ + * if the Option holds a value the first function is applied to the value. \ + * if the Option is none the second function is called without arguments and the result is returned.\ + * \pre both CaseSome and CaseNone must have the same return type \ + */ \ + template \ + typename std::result_of::type match(CaseSome present, CaseNone none) REF { \ + if (this->isSome()) { \ + return present(MOVE((*this)).unwrap()); \ + } else { \ + return none(); \ + } \ + } \ + \ + /** \ + * returns the value held by this option if there is one, or returns the value alt otherwise \ + */ \ + A REF unwrapOr(A REF alt) REF { \ + if (this->isSome()) { \ + return MOVE(*this).unwrap(); \ + } else { \ + return MOVE(alt); \ + } \ + } \ + \ + /** \ * returns the value held by this option if there is one, or calls the given function f without arguments \ - * and returns the value otherwise. \ - */ \ - template \ - A unwrapOrElse(Clsr f) REF { \ - if (this->isSome()) { \ - return MOVE(*this).unwrap(); \ - } else { \ - return f(); \ - } \ - } \ - \ - /** \ - * applies a function to the value of this closure if ther is one. the function is expected to return \ - * another option. the resulting Option> will then be flattened to an Option. \ - * \ - * This function is the same as flatMap/andThen/(>>=) in other programming languages with monads. \ - */ \ - template \ - typename std::result_of::type andThen(Clsr clsr) REF { \ - using OptOut = typename std::result_of::type; \ - return this->isSome() ? clsr(MOVE(*this).unwrap()) \ - : OptOut(); \ - } \ - \ - /** \ + * and returns the value otherwise. \ + */ \ + template \ + A unwrapOrElse(Clsr f) REF { \ + if (this->isSome()) { \ + return MOVE(*this).unwrap(); \ + } else { \ + return f(); \ + } \ + } \ + \ + /** \ + * Returns this, if this is Some, or uses the closure to create an alternative option if this is None. \ + */ \ + template::type \ + , Option \ + >::value \ + , bool \ + >::type = true \ + > \ + auto orElse(Clsr clsr) REF -> Option \ + { return this->isSome() ? MOVE(*this) : clsr(); } \ + \ + /** Returns the value of this, if this is Some, or uses the closure to create a value othewise. */\ + template::type \ + , A \ + >::value \ + , bool \ + >::type = true \ + > \ + auto orElse(Clsr clsr) REF -> A \ + { return this->isSome() ? MOVE(*this).unwrap() : clsr(); } \ + \ + /** \ + * applies a function to the value of this closure if ther is one. the function is expected to return\ + * another option. the resulting Option> will then be flattened to an Option.\ + * \ + * This function is the same as flatMap/andThen/(>>=) in other programming languages with monads.\ + */ \ + template \ + typename std::result_of::type andThen(Clsr clsr) REF { \ + using OptOut = typename std::result_of::type; \ + return this->isSome() ? clsr(MOVE(*this).unwrap()) \ + : OptOut(); \ + } \ + \ + template auto flatMap(Clsr clsr) REF { return andThen(clsr); } \ + \ + template \ + Option filter(Pred p) REF { \ + return isSome() && p(unwrap()) \ + ? MOVE(*this) \ + : Option(); \ + } \ + \ + /** \ * turns an Option, Option, or Option into an Option by calling the appropriate move \ - * or copy constructor. \ - */ \ - Option::type>::type> toOwned() REF \ - { \ - using Out = typename std::remove_const::type>::type; \ - return map([](A REF elem) -> Out { return Out(MOVE(elem)); }); \ - } \ + * or copy constructor. \ + */ \ + Option::type>::type> toOwned() REF \ + { \ + using Out = typename std::remove_const::type>::type; \ + return map([](A REF elem) -> Out { return Out(MOVE(elem)); }); \ + } \ + + FOR_REF_QUALIFIER(ref_polymorphic) + +#undef ref_polymorphic - FOR_REF_QUALIFIER(for_ref_qualifier) + Option take() + { + auto out = std::move(*this); + *this = Option(); + return out; + } -#undef for_ref_qualifier + class OptionIter { + Option _self; + OptionIter(Option self) : _self(std::move(self)) {} + public: + friend class Option; + DECL_ELEMENT_TYPE(A); + bool hasNext() const { return _self.isSome(); } + bool hasNext() { return _self.isSome(); } + A next() { return _self.take().unwrap(); } + }; + + Option asRef() const { return someIf(isSome(), [&]() -> decltype(auto) { return unwrap(); }); } + Option asRef() { return someIf(isSome(), [&]() -> decltype(auto) { return unwrap(); }); } + + OptionIter intoIter() && + { return OptionIter(std::move(*this)); } + + auto iter() const& { return asRef().intoIter(); } + auto iter() & { return asRef().intoIter(); } friend std::ostream& operator<<(std::ostream& out, Option const& self) { return self.isSome() ? out << self.unwrap() : out << "None"; } + + + + friend bool operator<(Option const& lhs, Option const& rhs) + { + if (lhs.isSome() < rhs.isSome()) { + return true; + } else if (lhs.isSome() > rhs.isSome()) { + return false; + } else if (lhs.isNone()) { + ASS(rhs.isNone()) + return false; + } else { + ASS(rhs.isSome()) + ASS(lhs.isSome()) + return lhs.unwrap() < rhs.unwrap(); + } + } }; + template auto someIf(bool condition, F create) -> Option { return condition ? Option(create()) : Option(); } -template Option some(T const& t) { return Option( t ); } -template Option some(T & t) { return Option( t ); } +template Option some(T const& t) { return Option(t); } +template Option some(T & t) { return Option(t); } template Option some(T && t) { return Option(std::move(t)); } -template Option none() { return Option(); } + +template Option none() { return Option(); } + +template Option optionalFromPtr(T* t) { return Option::fromPtr(t); } +template Option optionFromPtr(T* t) { return Option::fromPtr(t); } + +template +T operator||(Option t, T c) +{ return std::move(t).unwrapOr(std::move(c)); } + +template +auto operator||(Option t, Clsr f) -> decltype(f()) +{ return std::move(t).orElse(f); } + +template +Option operator||(Option t, Option c) +{ return std::move(t).orElse([&](){ return std::move(c); }); } + + +template +Option operator&&(Option t, Clsr c) +{ return std::move(t).andThen(c); } template -Option optionFromPtr(T* t) -{ return Option::fromPtr(t); } +Option operator&&(Option t, Option c) +{ return std::move(t).andThen([&](){ return std::move(c); }); } -} +} // namespace Lib #endif // __OPTIONAL_H__ diff --git a/Lib/Recycled.hpp b/Lib/Recycled.hpp index 9b8d6338b1..1170d61e7f 100644 --- a/Lib/Recycled.hpp +++ b/Lib/Recycled.hpp @@ -18,63 +18,111 @@ #include "Stack.hpp" #include "DArray.hpp" +#include +#include "Lib/Reflection.hpp" +#include "Lib/Hash.hpp" namespace Lib { -struct DefaultReset +struct DefaultReset { template void operator()(T& t) { t.reset(); } }; -struct NoReset +struct DefaultKeepRecycled +{ template bool operator()(T const& t) { return t.keepRecycled(); } }; + +struct NoReset { template void operator()(T& t) { } }; +template +struct MaybeAlive +{ + T _self; + bool* _alive; + MaybeAlive(T self, bool* alive) + : _self(std::move(self)), _alive(alive) + { *_alive = true; } + ~MaybeAlive() { *_alive = false; } + + + T const& operator* () const { return _self; } + T const* operator->() const { return &_self; } + T& operator* () { return _self; } + T* operator->() { return &_self; } +}; /** A smart that lets you keep memory allocated, and reuse it. * Constructs an object of type T on the heap. When the Recycled is destroyed, - * the object is not returned, but the object is reset using Reset::operator(), + * the object is not returned, but the object is reset using Reset::operator(), * and returned to a pool of pre-allocated objects. When the next Recycled is * constructed an object from the pool is returned instead of allocating heap memory. */ -template +template class Recycled { - unique_ptr _ptr; + T _ptr; Reset _reset; + Keep _keep; - static Stack>& mem() { - static Stack> mem; - return mem; + static bool alive; + static Stack& mem() { + static MaybeAlive> mem(Stack(), &alive); + return *mem; } -public: + Recycled(Recycled const&) = delete; +public: Recycled() - : _ptr(mem().isNonEmpty() ? mem().pop() : make_unique()) + : _ptr(mem().isNonEmpty() ? mem().pop() : T()) , _reset() + , _keep() { } - Recycled(Recycled&& other) = default; - Recycled& operator=(Recycled&& other) = default; + template + Recycled clone(Clone cloneFn) const + { + Recycled c; + T const& from = **this; + T& to = *c; + cloneFn(to, from); + return c; + } - operator bool() const - { return bool(_ptr); } + auto asTuple() const -> decltype(auto) { return std::tie(_ptr); } + IMPL_COMPARISONS_FROM_TUPLE(Recycled); + IMPL_HASH_FROM_TUPLE(Recycled); + + template + Recycled(A a, As... as) + : _ptr(mem().isNonEmpty() ? mem().pop() : T()) + , _reset() + { + _ptr.init(a, as...); + } + + Recycled(Recycled&& other) = default; + Recycled& operator=(Recycled&& other) = default; ~Recycled() - { - if (_ptr) { - _reset(*_ptr); + { + if (_keep(_ptr) && alive) { + _reset(_ptr); mem().push(std::move(_ptr)); } } - T const& operator* () const { ASS(*this); return *_ptr; } - T const* operator->() const { ASS(*this); return &*_ptr; } - T& operator* () { ASS(*this); return *_ptr; } - T* operator->() { ASS(*this); return &*_ptr; } + T const& operator* () const { return _ptr; } + T const* operator->() const { return &_ptr; } + T& operator* () { return _ptr; } + T* operator->() { return &_ptr; } friend std::ostream& operator<<(std::ostream& out, Recycled const& self) - { return self._ptr ? out << *self._ptr : out << "Recycled(nullptr)"; } + { return out << self._ptr; } }; +template +bool Recycled::alive = true; + }; #endif /*__Recycled__*/ diff --git a/Lib/Reflection.hpp b/Lib/Reflection.hpp index 2b6f7a21da..72b8980221 100644 --- a/Lib/Reflection.hpp +++ b/Lib/Reflection.hpp @@ -24,6 +24,31 @@ ///@{ +#define DEFAULT_CONSTRUCTORS(Class) \ + Class(Class const&) = default; \ + Class(Class &&) = default; \ + Class& operator=(Class const&) = default; \ + Class& operator=(Class &&) = default; \ + +#define IMPL_COMPARISONS_FROM_TUPLE(Class) \ + friend bool operator==(Class const& l, Class const& r) \ + { return l.asTuple() == r.asTuple(); } \ + \ + friend bool operator<(Class const& l, Class const& r) \ + { return l.asTuple() < r.asTuple(); } \ + \ + IMPL_COMPARISONS_FROM_LESS_AND_EQUALS(Class) \ + +#define IMPL_COMPARISONS_FROM_LESS_AND_EQUALS(Class) \ + friend bool operator> (Class const& l, Class const& r) { return r < l; } \ + friend bool operator<=(Class const& l, Class const& r) { return l == r || l < r; } \ + friend bool operator>=(Class const& l, Class const& r) { return l == r || l > r; } \ + friend bool operator!=(Class const& l, Class const& r) { return !(l == r); } \ + +#define IMPL_HASH_FROM_TUPLE(Class) \ + unsigned defaultHash() const { return DefaultHash::hash(asTuple()); } \ + unsigned defaultHash2() const { return DefaultHash2::hash(asTuple()); } \ + //The obvious way to define this macro would be //#define DECL_ELEMENT_TYPE(T) typedef T _ElementType //but the preprocessor understands for example @@ -49,16 +74,17 @@ #define DECL_ELEMENT_TYPE(...) typedef __VA_ARGS__ _ElementType /** - * Type of elements in the iterator/collection @b Cl + * Type of elements in the iterator/collection @b __VA_ARGS__ + * This functions is variadic as the argument might be generic, hence contain commas * - * The class @b Cl must have its element type declared by the + * The class @b __VA_ARGS__ must have its element type declared by the * @b DECL_ELEMENT_TYPE macro in order for this macro to be applicable * (Except for cases that are handled by a partial specialization * of the @b Lib::ElementTypeInfo template class.) * * @see DECL_ELEMENT_TYPE, Lib::ElementTypeInfo */ -#define ELEMENT_TYPE(Cl) typename Lib::ElementTypeInfo::Type +#define ELEMENT_TYPE(...) typename Lib::ElementTypeInfo<__VA_ARGS__>::Type /** * Type of elements of the current class @@ -205,6 +231,6 @@ struct IteratorTypeInfo }; -///@}Á +///@}� #endif /* __Reflection__ */ diff --git a/Lib/Stack.hpp b/Lib/Stack.hpp index a7d0ede514..780851afb1 100644 --- a/Lib/Stack.hpp +++ b/Lib/Stack.hpp @@ -18,6 +18,7 @@ #define __Stack__ #include +#include #include "Forwards.hpp" @@ -25,7 +26,8 @@ #include "Debug/Tracer.hpp" #include "Allocator.hpp" -#include "Backtrackable.hpp" +#include "Lib/Reflection.hpp" +// #include "Backtrackable.hpp" namespace std { @@ -35,6 +37,9 @@ void swap(Lib::Stack& s1, Lib::Stack& s2); namespace Lib { +// template +// struct Relocator >; + /** * Class of flexible-size generic stacks. * @since 11/03/2006 Bellevue @@ -58,6 +63,7 @@ class Stack CLASS_NAME(Stack); USE_ALLOCATOR(Stack); + /** * Create a stack having initialCapacity. */ @@ -72,7 +78,7 @@ class Stack _stack = static_cast(mem); } else { - _stack = 0; + _stack = nullptr; } _cursor = _stack; _end = _stack+_capacity; @@ -104,6 +110,8 @@ class Stack } } + bool keepRecycled() const { return _capacity > 0; } + Stack(const Stack& s) : _capacity(s._capacity) @@ -133,6 +141,45 @@ class Stack std::swap(*this,s); } +/** + * @brief Splits this stack into two parts. The first part will contain the first @param sizeOfFirst elements + * and the second part will contain the rest. This function does not involve any memory copying, hence it's + * constant time. + * + * @pre this->size() >= sizeOfFirst + * @post this stack will be empty + * + * @param sizeOfFirst the size of the first of the two parts to be returned + * @return std::pair a pair of stacks, which contain the same elements as this stack + * contained before the call of this function. + */ + std::pair split(unsigned sizeOfFirst) + { + ASS(sizeOfFirst <= this->size()) + Stack lhs; + Stack rhs; + + if (sizeOfFirst == this->size()) { + lhs = std::move(*this); + } else if (sizeOfFirst == 0) { + rhs = std::move(*this); + } else { + lhs._stack = _stack; + lhs._end = lhs._cursor = lhs._stack + sizeOfFirst; + lhs._capacity = sizeOfFirst; + + rhs._stack = _stack + sizeOfFirst; + rhs._end = _end; + rhs._cursor = _cursor; + rhs._capacity = _capacity - sizeOfFirst; + + _stack = _cursor = _end = nullptr; + _capacity = 0; + } + + return make_pair(std::move(lhs), std::move(rhs)); + } + /** De-allocate the stack * @since 13/01/2008 Manchester */ @@ -210,7 +257,7 @@ class Stack static Stack fromIterator(It it) { CALL("Stack::fromIterator"); Stack out; - out.loadFromIterator(it); + out.moveFromIterator(std::move(it)); return out; } /* a first-in-first-out iterator */ @@ -243,6 +290,33 @@ class Stack return _stack[n]; } + friend int cmp(const Stack& l, const Stack& r) + { + CALL("Stack::operator<"); + + int sdiff = int(l.size()) - int(r.size()); + if(sdiff) return sdiff; + + auto i1 = arrayIter(l); + auto i2 = arrayIter(r); + while (i1.hasNext()) { + auto& e1 = i1.next(); + auto& e2 = i2.next(); + if (e1 != e2) { + if (e1 < e2) return -1; + if (e1 > e2) return 1; + } + } + ASS(!i2.hasNext()) + return 0; + } + + friend bool operator< (const Stack& l, const Stack& r) { return cmp(l,r) < 0; } + friend bool operator<=(const Stack& l, const Stack& r) { return cmp(l,r) <= 0; } + friend bool operator> (const Stack& l, const Stack& r) { return cmp(l,r) > 0; } + friend bool operator>=(const Stack& l, const Stack& r) { return cmp(l,r) >= 0; } + + bool operator==(const Stack& o) const { CALL("Stack::operator=="); @@ -327,24 +401,7 @@ class Stack * @since 11/03/2006 Bellevue */ inline - void push(const C& elem) - { - CALL("Stack::push"); - - if (_cursor == _end) { - expand(); - } - ASS(_cursor < _end); - ::new(_cursor) C(elem); - _cursor++; - } // Stack::push() - - /** - * Push new element on the stack (move semantics version). - * @since 11/08/2020 - */ - inline - void push(C&& elem) + void push(C elem) { CALL("Stack::push"); @@ -375,6 +432,37 @@ class Stack } // Stack::pop() + /** removes consecutive duplicates. instead of the operator== the given predicate is used */ + template> + void dedup(Equal eq = std::equal_to{}) + { + auto& self = *this; + if (self.size() == 0) return; + unsigned offs = 0; + for (unsigned i = 1; i < self.size(); i++) { + if (eq(self[offs], self[i])) { + /* skip */ + } else { + self[offs++ + 1] = std::move(self[i]); + } + } + self.pop(self.size() - (offs + 1)); + } + + /** like Stack::dedup but moves the content out of `this` and returns the resulting Stack instead of changing the contents of this */ + template> + Stack deduped(Equal eq = std::equal_to{}) + { dedup(); return std::move(*this); } + + template> + void sort(Less less = std::less{}) + { std::sort(begin(), end(), less); } + + /** like Stack::sort but moves the content out of `this` and returns the resulting Stack instead of changing the contents of this */ + template> + Stack sorted(Equal eq = std::equal_to{}) + { sort(); return std::move(*this); } + inline void pop(unsigned cnt) { @@ -399,6 +487,19 @@ class Stack return false; } + /** + * removes the element at the given index, replacing it by the last element in the stack and shrinking the stack. + * constant time operation. + * returns the removed element. + */ + C swapRemove(unsigned idx) + { + ASS(idx < size()) + ASS(size() > 0) + std::swap((*this)[idx], (*this)[size() - 1]); + return pop(); + } + /** * Return the element past the end of the stack, can be used together * with begin() for iterating over the elements of the stack. @@ -427,6 +528,24 @@ class Stack _cursor = _stack; } + void init(std::initializer_list elems) + { + reserve(elems.size()); + for (auto& x : elems) { + push(std::move(x)); + } + } + + void pushMany() {} + + template + void pushMany(C item, As... rest) + { + push(std::move(item)); + pushMany(std::move(rest)...); + } + + /** Sets the length of the stack to @b len * @since 27/12/2007 Manchester */ inline @@ -463,21 +582,6 @@ class Stack return false; } -#if VDEBUG - vstring toString() - { - vstring ret = "["; - Iterator it(const_cast(*this)); - while(it.hasNext()){ - C el = it.next(); - ret += Int::toString(static_cast(el)); - if(it.hasNext()){ ret +=",";} - } - return ret+"]"; - } - -#endif - friend class RefIterator; /** Iterator iterates over the elements of a stack and can @@ -615,6 +719,9 @@ class Stack C next() { return ConstRefIterator::next(); } }; + ConstIterator iterCloned() const& + { return ConstIterator(*this); } + RefIterator iter() & { return RefIterator(*this); } @@ -819,25 +926,10 @@ class Stack _capacity = newCapacity; } // Stack::expand - class PushBacktrackObject: public BacktrackObject - { - Stack* st; - public: - CLASS_NAME(Stack::PushBacktrackObject); - USE_ALLOCATOR(Stack::PushBacktrackObject); - - PushBacktrackObject(Stack* st) : st(st) {} - void backtrack() { st->pop(); } - }; public: - void backtrackablePush(C v, BacktrackData& bd) - { - push(v); - bd.addBacktrackObject(new PushBacktrackObject(this)); - } - friend ostream& operator<<(ostream& out, const Stack& s) { + friend std::ostream& operator<<(std::ostream& out, const Stack& s) { out << "["; auto iter = s.begin(); if(iter != s.end()) { @@ -862,6 +954,17 @@ class Stack }; +// template +// struct Relocator > +// { +// static void relocate(Stack* oldStack, void* newAddr) +// { +// ::new(newAddr) Stack(std::move(*oldStack)); +// oldStack->~Stack(); +// } +// }; + + } // namespace Lib namespace std diff --git a/Lib/StringUtils.cpp b/Lib/StringUtils.cpp index 2254f631c3..79155a517a 100644 --- a/Lib/StringUtils.cpp +++ b/Lib/StringUtils.cpp @@ -152,6 +152,18 @@ void StringUtils::splitStr(const char* str, char delimiter, Stack& stri strings.push(currPart.begin()); } +void StringUtils::dropEmpty(Stack& strings) +{ + CALL("StringUtils::dropEmpty"); + unsigned i = 0; + for (unsigned j = 0; j < strings.size(); j++) { + if (strings[j].size() > 0) { + strings[i++] = strings[j]; + } + } + strings.truncate(i); +} + bool StringUtils::readEquality(const char* str, char eqChar, vstring& lhs, vstring& rhs) { CALL("StringUtils::readEquality"); diff --git a/Lib/StringUtils.hpp b/Lib/StringUtils.hpp index f82751d266..5149c98fee 100644 --- a/Lib/StringUtils.hpp +++ b/Lib/StringUtils.hpp @@ -33,6 +33,7 @@ class StringUtils { static bool isPositiveDecimal(vstring str); static void splitStr(const char* str, char delimiter, Stack& strings); + static void dropEmpty(Stack& strings); static bool readEquality(const char* str, char eqChar, vstring& lhs, vstring& rhs); static bool readEqualities(const char* str, char delimiter, char eqChar, DHMap& pairs); template diff --git a/Makefile b/Makefile index 8d709dad41..6046719082 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,9 @@ # CHECK_LEAKS - test for memory leaks (debugging mode only) # VZ3 - compile with Z3 -DBG_FLAGS = -g -DVTIME_PROFILING=1 -DVDEBUG=1 -DCHECK_LEAKS=0 # debugging for spider +DBG_FLAGS = -g -DVTIME_PROFILING=1 -DVDEBUG=1 -DCHECK_LEAKS=0 -DVHOL=1 # debugging for spider # DELETEMEin2017: the bug with gcc-6.2 and problems in ClauseQueue could be also fixed by adding -fno-tree-ch -REL_FLAGS = -O6 -DVTIME_PROFILING=1 -DVDEBUG=0 # no debugging +REL_FLAGS = -O6 -DVTIME_PROFILING=1 -DVDEBUG=0 -DVHOL=1 # no debugging GCOV_FLAGS = -O0 --coverage #-pedantic MINISAT_DBG_FLAGS = -D DEBUG @@ -193,11 +193,12 @@ VK_OBJ= Kernel/Clause.o\ Kernel/Inference.o\ Kernel/InferenceStore.o\ Kernel/KBO.o\ - Kernel/SKIKBO.o\ Kernel/KBOForEPR.o\ Kernel/LiteralSelector.o\ Kernel/LookaheadLiteralSelector.o\ Kernel/LPO.o\ + Kernel/HOLUnification.o\ + Kernel/HOLMatching.o\ Kernel/MainLoop.o\ Kernel/Matcher.o\ Kernel/MaximalLiteralSelector.o\ @@ -246,6 +247,7 @@ VI_OBJ = Indexing/AcyclicityIndex.o\ Indexing/LiteralSubstitutionTree.o\ Indexing/ResultSubstitution.o\ Indexing/SubstitutionTree.o\ + Indexing/HOLSubstitutionTree.o\ Indexing/SubstitutionTree_FastGen.o\ Indexing/SubstitutionTree_FastInst.o\ Indexing/SubstitutionTree_Nodes.o\ @@ -268,15 +270,11 @@ VINF_OBJ=Inferences/BackwardDemodulation.o\ Inferences/ExtensionalityResolution.o\ Inferences/ArgCong.o\ Inferences/NegativeExt.o\ - Inferences/Narrow.o\ - Inferences/SubVarSup.o\ Inferences/Factoring.o\ Inferences/FastCondensation.o\ Inferences/FOOLParamodulation.o\ Inferences/Injectivity.o\ Inferences/ForwardDemodulation.o\ - Inferences/CombinatorDemodISE.o\ - Inferences/CombinatorNormalisationISE.o\ Inferences/ForwardLiteralRewriting.o\ Inferences/ForwardSubsumptionAndResolution.o\ Inferences/SubsumptionDemodulationHelper.o\ @@ -297,6 +295,10 @@ VINF_OBJ=Inferences/BackwardDemodulation.o\ Inferences/TautologyDeletionISE.o\ Inferences/TermAlgebraReasoning.o\ Inferences/Induction.o\ + Inferences/FlexFlexSimplify.o\ + Inferences/PositiveExt.o\ + Inferences/ImitateProject.o\ + Inferences/BetaEtaISE.o\ Inferences/InductionHelper.o\ Inferences/URResolution.o\ Inferences/CNFOnTheFly.o\ @@ -355,10 +357,10 @@ VS_OBJ = Shell/AnswerExtractor.o\ Shell/InterpolantMinimizer.o\ Shell/Interpolants.o\ Shell/InterpretedNormalizer.o\ - Shell/LambdaElimination.o\ Shell/LaTeX.o\ Shell/LispLexer.o\ Shell/LispParser.o\ + Shell/LambdaConversion.o\ Shell/Naming.o\ Shell/NNF.o\ Shell/Normalisation.o\ @@ -390,7 +392,6 @@ VS_OBJ = Shell/AnswerExtractor.o\ Shell/VarManager.o\ Shell/Lexer.o\ Shell/Preprocess.o\ - Shell/UnificationWithAbstractionConfig.o\ version.o PARSE_OBJ = Parse/SMTLIB2.o\ @@ -451,7 +452,6 @@ LIB_DEP = Indexing/TermSharing.o\ Shell/Options.o\ Shell/Property.o\ Shell/Statistics.o\ - Shell/UnificationWithAbstractionConfig.o\ version.o # ClausifierDependencyFix.o\ version.o\ @@ -474,7 +474,6 @@ OTHER_CL_DEP = Indexing/LiteralSubstitutionTree.o\ Kernel/InferenceStore.o\ Kernel/Matcher.o\ Kernel/KBO.o\ - Kernel/SKIKBO.o\ Kernel/KBOForEPR.o\ Kernel/Ordering.o\ Kernel/Ordering_Equality.o\ @@ -507,7 +506,7 @@ all: #default make disabled ################################################################ # automated generation of Vampire revision information -VERSION_NUMBER = 4.7 +VERSION_NUMBER = 4.8 # We extract the revision number from svn every time the svn meta-data are modified # (that's why there is the dependency on .svn/entries) diff --git a/Parse/TPTP.cpp b/Parse/TPTP.cpp index 238a763acd..92fab67d2a 100644 --- a/Parse/TPTP.cpp +++ b/Parse/TPTP.cpp @@ -50,17 +50,19 @@ using namespace Parse; DHMap TPTP::_axiomNames; -//Numbers chosen to avoid clashing with connectives. -//Unlikely to ever have 100 connectives, so this should be ok. -const int TPTP::HOL_CONSTANTS_LOWER_BOUND = 99u; -/** operator lambda */ -const int TPTP::LAMBDA = 100u; -/** application of any number of terms */ -const int TPTP::APP = 101u; -/** Pi function for universal quantification */ -const int TPTP::PI = 102u; -/** Sigma function for existential quantification */ -const int TPTP::SIGMA = 103u; +#if VHOL + //Numbers chosen to avoid clashing with connectives. + //Unlikely to ever have 100 connectives, so this should be ok. + const int TPTP::HOL_CONSTANTS_LOWER_BOUND = 99u; + /** operator lambda */ + const int TPTP::LAMBDA = 100u; + /** application of any number of terms */ + const int TPTP::APP = 101u; + /** Pi function for universal quantification */ + const int TPTP::PI = 102u; + /** Sigma function for existential quantification */ + const int TPTP::SIGMA = 103u; +#endif /** * Create a parser, parse the input and return the parsed list of units. @@ -88,7 +90,9 @@ TPTP::TPTP(istream& in) _allowedNames(0), _in(&in), _includeDirectory(""), +#if VHOL _isThf(false), +#endif _containsPolymorphism(false), _currentColor(COLOR_TRANSPARENT), _lastPushed(TM), @@ -137,7 +141,14 @@ void TPTP::parse() fof(true); break; case THF: +#if VHOL _isThf = true; + if(env.options->unificationWithAbstraction() != Options::UnificationWithAbstraction::OFF){ + USER_ERROR("Higher-order and unification with abstraction are currently not compatible"); + } +#else + PARSE_ERROR("To parse higher-order problems please build Vampire with higher-order support", _gpos); +#endif case TFF: _isFof = false; tff(); @@ -191,6 +202,7 @@ void TPTP::parse() case END_FORMULA: endFormula(); break; +#if VHOL case END_APP: endApp(); break; @@ -203,6 +215,7 @@ void TPTP::parse() case HOL_TERM: holTerm(); break; +#endif case FORMULA_INSIDE_TERM: formulaInsideTerm(); break; @@ -1419,6 +1432,7 @@ void TPTP::tff() } vstring nm = name(); consumeToken(T_COLON); +#if VHOL if(_isThf){ tok = getTok(0); if (tok.tag == T_TTYPE) { @@ -1447,6 +1461,7 @@ void TPTP::tff() return; } } +#endif // the matching number of rpars will be read _ints.push(lpars); // remember type name @@ -1519,6 +1534,8 @@ unsigned TPTP::getConstructorArity() * @author Ahmed Bhayat */ +#if VHOL + void TPTP::holFormula() { CALL("TPTP::holFunction"); @@ -1700,7 +1717,9 @@ void TPTP::holTerm() _lastPushed = TM; } - + +#endif + vstring TPTP::convert(Tag t) { CALL("TPTP::convert(Tag t)"); @@ -1736,6 +1755,8 @@ vstring TPTP::convert(Tag t) * @author Ahmed Bhayat */ +#if VHOL + void TPTP::endHolFormula() { CALL("TPTP::endHolFormula"); @@ -1799,6 +1820,7 @@ void TPTP::endHolFormula() _states.push(UNBIND_VARIABLES); return; } + case LITERAL: default: throw ::Exception((vstring)"tell me how to handle connective " + Int::toString(con)); @@ -1946,7 +1968,6 @@ switch (tag) { _states.push(HOL_FORMULA); } - /** * Process the end of an @ term * @since 05/11/2017 Manchester @@ -1975,6 +1996,7 @@ void TPTP::endApp() _termLists.push(TermList(Term::create(app, 4, args.begin()))); _lastPushed = TM; } +#endif /** * Process the end of the $ite expression @@ -2206,6 +2228,7 @@ void TPTP::formula() { CALL("TPTP::formula"); +#if VHOL if(_isThf){ _connectives.push(-2); //special connective for HOL funcs _connectives.push(-1); @@ -2213,10 +2236,13 @@ void TPTP::formula() _states.push(END_HOL_FORMULA); _states.push(HOL_FORMULA); }else{ +#endif _connectives.push(-1); _states.push(END_FORMULA); _states.push(SIMPLE_FORMULA); +#if VHOL } +#endif } // formula /** @@ -2863,7 +2889,11 @@ void TPTP::varList() PARSE_ERROR("two declarations of variable sort",tok); } resetToks(); - bindVariable(var,(_isThf ? readArrowSort() : readSort())); + bindVariable(var,( +#if VHOL + _isThf ? readArrowSort() : +#endif + readSort())); sortDeclared = true; goto afterVar; @@ -3120,9 +3150,11 @@ void TPTP::endEquality() _insideEqualityArgument--; - if((_isThf) && (_lastPushed == FORM)){ +#if VHOL + if(_isThf && (_lastPushed == FORM)){ endFormulaInsideTerm(); } +#endif TermList rhs = _termLists.pop(); TermList lhs = _termLists.pop(); @@ -3260,7 +3292,7 @@ Formula* TPTP::createPredicateApplication(vstring name, unsigned arity) "is not $ttype as mandated by TF1"); } } else { - static RobSubstitution subst; + static RobSubstitutionTS subst; subst.reset(); if(!subst.match(sort, 0, tsSort, 1)) { USER_ERROR("Failed to create predicate application for " + name + " of type " + type->toString() + "\n" + @@ -3314,7 +3346,7 @@ TermList TPTP::createFunctionApplication(vstring name, unsigned arity) "is not $tType as mandated by TF1"); } } else { - static RobSubstitution subst; + static RobSubstitutionTS subst; subst.reset(); if(!subst.match(sort, 0, ssSort, 1)){ USER_ERROR("Failed to create function application for " + name + " of type " + type->toString() + "\n" + @@ -3834,7 +3866,11 @@ void TPTP::endTff() vstring name = _strings.pop(); unsigned arity = ot->arity(); - bool isPredicate = ot->isPredicateType() && !_isThf; + bool isPredicate = ot->isPredicateType(); +#if VHOL + isPredicate = isPredicate && !_isThf; +#endif + bool isTypeCon = !isPredicate && (ot->result() == AtomicSort::superSort()); bool added; @@ -3878,11 +3914,13 @@ void TPTP::endTff() else { symbol->setType(ot); //TODO check whether the below is actually required or not. +#if VHOL if(_isThf){ if(!_typeArities.insert(name, ot->numTypeArguments())){ USER_ERROR("Symbol " + name + " used with different type arities"); } } +#endif } //cout << "added: " + symbol->name() + " of type " + ot->toString() + " and functor " << fun << endl; } @@ -3961,7 +3999,11 @@ OperatorType* TPTP::constructOperatorType(Type* t, VList* vars) SortHelper::normaliseSort(vars, resultSort); } - if (isPredicate && !_isThf) { //in THF, we treat predicates and boolean terms the same + if (isPredicate +#if VHOL + && !_isThf +#endif + ) { //in THF, we treat predicates and boolean terms the same return OperatorType::getPredicateType(arity, argumentSorts.begin(), VList::length(vars)); } else { return OperatorType::getFunctionType(arity, argumentSorts.begin(), resultSort, VList::length(vars)); @@ -4244,10 +4286,12 @@ void TPTP::simpleType() return; } +#if VHOL if(_isThf){ _types.push(new AtomicType(readArrowSort())); return; } +#endif if (tok.tag == T_LPAR) { resetToks(); @@ -4265,6 +4309,8 @@ void TPTP::simpleType() * @since 10/11/2017 Leicester * @author Ahmed Bhayat */ + +#if VHOL TermList TPTP::readArrowSort() { @@ -4341,6 +4387,8 @@ void TPTP::readTypeArgs(unsigned arity) } } +#endif + /** * Read a sort and return its number. If a sort is not built-in, then raise an * exception if it has been declared and newSortExpected, or it has not been @@ -4358,10 +4406,12 @@ TermList TPTP::readSort() { unsigned arity = 0; vstring fname = tok.content; +#if VHOL if(_isThf){ arity = _typeConstructorArities.find(fname) ? _typeConstructorArities.get(fname) : 0; readTypeArgs(arity); } else { +#endif int c = getChar(0); //Polymorphic sorts of are of the form //type_con(sort_1, ..., sort_n) @@ -4386,7 +4436,9 @@ TermList TPTP::readSort() } } } +#if VHOL } +#endif return createTypeConApplication(fname, arity); } case T_VAR: @@ -4462,7 +4514,9 @@ TermList TPTP::readSort() */ bool TPTP::higherPrecedence(int c1,int c2) { +#if VHOL if (c1 == APP) return true; +#endif if (c1 == c2) return false; if (c1 == -1) return false; if (c2 == IFF) return true; @@ -4680,9 +4734,11 @@ unsigned TPTP::addFunction(vstring name,int arity,bool& added,TermList& arg) Theory::RAT_TO_REAL, Theory::REAL_TO_REAL); } +#if VHOL if (name == "vPI" || name == "vSIGMA"){ return env.signature->getPiSigmaProxy(name); } +#endif if (arity > 0) { return env.signature->addFunction(name,arity,added); } @@ -4971,12 +5027,14 @@ unsigned TPTP::addUninterpretedConstant(const vstring& name, Set& overf } //TODO make sure Vampire internal names are unique to Vampire //and cannot occur in the input AYB +#if VHOL if(name == "vAND" || name == "vOR" || name == "vIMP" || name == "vIFF" || name == "vXOR"){ return env.signature->getBinaryProxy(name); } else if (name == "vNOT"){ return env.signature->getNotProxy(); } +#endif return env.signature->addFunction(name,0,added); } // TPTP::addUninterpretedConstant @@ -5213,6 +5271,7 @@ const char* TPTP::toString(State s) return "TYPE"; case END_TFF: return "END_TFF"; +#if VHOL case END_APP: return "END_APP"; case HOL_FORMULA: @@ -5221,6 +5280,7 @@ const char* TPTP::toString(State s) return "END_HOL_FORMULA"; case HOL_TERM: return "HOL_TERM"; +#endif case END_TYPE: return "END_TYPE"; case SIMPLE_TYPE: diff --git a/Parse/TPTP.hpp b/Parse/TPTP.hpp index f3da7895ae..dd11767e08 100644 --- a/Parse/TPTP.hpp +++ b/Parse/TPTP.hpp @@ -221,6 +221,7 @@ class TPTP INCLUDE, /** after the equality */ END_EQ, +#if VHOL /** Read a HOL formula */ HOL_FORMULA, /** build a HOL formula from a connective and one or more formulas */ @@ -229,6 +230,7 @@ class TPTP HOL_TERM, /** create an application term after reading an app */ END_APP, +#endif /** tff declaration */ TFF, /** THF declaration */ @@ -588,7 +590,9 @@ class TPTP * between fof() and tff() in treating numeric constants */ bool _isFof; /** */ +#if VHOL bool _isThf; +#endif /** */ bool _containsPolymorphism; /** various strings saved during parsing */ @@ -809,6 +813,7 @@ class TPTP //these functions were all written in early 2017 (start of PhD) and are consequently //pretty nasty and don't follow the philosophy of the parser. However, they should //not impact standard parsing functions in any way. +#if VHOL void endApp(); void holFormula(); void endHolFormula(); @@ -816,6 +821,7 @@ class TPTP void foldl(TermStack*); TermList readArrowSort(); void readTypeArgs(unsigned arity); +#endif //End of higher-order specific functions void bindVariable(unsigned var,TermList sort); diff --git a/SAT/Z3Interfacing.cpp b/SAT/Z3Interfacing.cpp index 24577ec2d8..f8de64738e 100644 --- a/SAT/Z3Interfacing.cpp +++ b/SAT/Z3Interfacing.cpp @@ -863,8 +863,7 @@ struct ToZ3Expr } } else { symb = env.signature->getFunction(trm->functor()); - OperatorType* ftype = symb->fnType(); - range_sort = ftype->result(); + range_sort = SortHelper::getResultSort(trm); if (env.signature->isTermAlgebraSort(range_sort) && !self._createdTermAlgebras.contains(range_sort) ) { self.createTermAlgebra(*env.signature->getTermAlgebraOfSort(range_sort)); } @@ -910,7 +909,7 @@ struct ToZ3Expr } // If not value then create constant symbol - return self.getConst(symb, self.getz3sort(range_sort)); + return self.getConst(symb, self.getz3sort(range_sort), range_sort); } ASS(trm->numTermArguments()>0); @@ -1069,6 +1068,7 @@ struct ToZ3Expr // uninterpretd function auto f = self.z3Function(Z3Interfacing::FuncOrPredId(trm)); + return f(f.arity(), args); } }; @@ -1096,7 +1096,7 @@ z3::func_decl Z3Interfacing::z3Function(FuncOrPredId functor) SortHelper::getTypeSub(functor.forSorts, typeSubst); namebuf += '$'; for(unsigned i = 0; i < functor.forSorts->numTypeArguments(); i++) - namebuf += functor.forSorts->termArg(i).toString(); + namebuf += functor.forSorts->typeArg(i).toString(); } z3::sort_vector domain_sorts = z3::sort_vector(self._context); @@ -1221,11 +1221,11 @@ z3::expr Z3Interfacing::getNamingConstantFor(TermList toName, z3::sort sort) }); } -z3::expr Z3Interfacing::getConst(Signature::Symbol* symb, z3::sort sort) +z3::expr Z3Interfacing::getConst(Signature::Symbol* symb, z3::sort sort, TermList vsrt) { - return _constantNames.getOrInit(symb, [&]() { + vstring name("c" + symb->name() + (symb->arity() ? ("$" + vsrt.toString()) : "")); + return _constantNames.getOrInit(name, [&]() { // careful: keep native constants' names distinct from the above ones (hence the "c"-prefix below) - vstring name("c" + symb->name()); outputln("(declare-fun ", name, " () ", sort, ")"); return _context.constant(name.c_str(), sort); }); diff --git a/SAT/Z3Interfacing.hpp b/SAT/Z3Interfacing.hpp index b3fe267c06..a2f10f1560 100644 --- a/SAT/Z3Interfacing.hpp +++ b/SAT/Z3Interfacing.hpp @@ -254,13 +254,13 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver Option _out; Map _varNames; Map _termIndexedConstants; - Map _constantNames; + Map _constantNames; bool isNamedExpr(unsigned var) const; z3::expr getNameExpr(unsigned var); z3::expr getNamingConstantFor(TermList name, z3::sort sort); - z3::expr getConst(Signature::Symbol* symb, z3::sort srt); + z3::expr getConst(Signature::Symbol* symb, z3::sort srt, TermList vsrt); void __output(std::ostream& out ) { } template void __output(std::ostream& out, A a, As... as) { out << a; __output(out, as...); } diff --git a/Saturation/AWPassiveClauseContainer.cpp b/Saturation/AWPassiveClauseContainer.cpp index 66c011f8c4..5829e18d1b 100644 --- a/Saturation/AWPassiveClauseContainer.cpp +++ b/Saturation/AWPassiveClauseContainer.cpp @@ -114,7 +114,9 @@ bool WeightQueue::lessThan(Clause* c1,Clause* c2) { CALL("WeightQueue::lessThan"); - if(env.options->prioritiseClausesProducedByLongReduction()){ +#if VHOL + // TODO revivie this heuristic ... + /*if(env.options->prioritiseClausesProducedByLongReduction()){ if(c1->inference().reductions() < c2->inference().reductions()){ return false; } @@ -122,7 +124,8 @@ bool WeightQueue::lessThan(Clause* c1,Clause* c2) if(c2->inference().reductions() < c1->inference().reductions()){ return true; } - } + }*/ +#endif Comparison weightCmp=AWPassiveClauseContainer::compareWeight(c1, c2, _opt); if (weightCmp!=EQUAL) { diff --git a/Saturation/ManCSPassiveClauseContainer.cpp b/Saturation/ManCSPassiveClauseContainer.cpp index bc57ea9e4e..786aa54951 100644 --- a/Saturation/ManCSPassiveClauseContainer.cpp +++ b/Saturation/ManCSPassiveClauseContainer.cpp @@ -41,6 +41,7 @@ class VectorIteratorWrapper : public IteratorCore void ManCSPassiveClauseContainer::add(Clause* cl) { + BYPASSING_ALLOCATOR; CALL("ManCSPassiveClauseContainer::add"); clauses.push_back(cl); addedEvent.fire(cl); diff --git a/Saturation/PredicateSplitPassiveClauseContainer.cpp b/Saturation/PredicateSplitPassiveClauseContainer.cpp index f3de768c16..9d483aec1a 100644 --- a/Saturation/PredicateSplitPassiveClauseContainer.cpp +++ b/Saturation/PredicateSplitPassiveClauseContainer.cpp @@ -506,6 +506,33 @@ float TheoryMultiSplitPassiveClauseContainer::evaluateFeatureEstimate(unsigned, return inf.th_ancestors * expectedRatioDenominator - inf.all_ancestors; } +#if VHOL + +HoFeaturesMultiSplitPassiveClauseContainer::HoFeaturesMultiSplitPassiveClauseContainer(bool isOutermost, const Shell::Options &opt, Lib::vstring name, Lib::vvector> queues) : +PredicateSplitPassiveClauseContainer(isOutermost, opt, name, std::move(queues), opt.hoFeaturesSplitQueueCutoffs(), opt.hoFeaturesSplitQueueRatios(), opt.hoFeaturesSplitQueueLayeredArrangement()) {} + +float HoFeaturesMultiSplitPassiveClauseContainer::evaluateFeature(Clause* cl) const +{ + CALL("HoFeaturesMultiSplitPassiveClauseContainer::evaluateFeature"); + + //calculate the number of huigher-order features (applied variable and lambdas) in the clause; + unsigned res = 0; + for(unsigned i = 0; i < cl->size(); i++){ + res = res + (*cl)[i]->numOfAppVarsAndLambdas(); + } + return res; +} + +float HoFeaturesMultiSplitPassiveClauseContainer::evaluateFeatureEstimate(unsigned, const Inference& inf) const +{ + CALL("HoFeaturesMultiSplitPassiveClauseContainer::evaluateFeatureEstimate"); + + // from the information provided we cannot estimate the feature sadly... + return 0; +} + +#endif + AvatarMultiSplitPassiveClauseContainer::AvatarMultiSplitPassiveClauseContainer(bool isOutermost, const Shell::Options &opt, Lib::vstring name, Lib::vvector> queues) : PredicateSplitPassiveClauseContainer(isOutermost, opt, name, std::move(queues), opt.avatarSplitQueueCutoffs(), opt.avatarSplitQueueRatios(), opt.avatarSplitQueueLayeredArrangement()) {} diff --git a/Saturation/PredicateSplitPassiveClauseContainer.hpp b/Saturation/PredicateSplitPassiveClauseContainer.hpp index 794fc00c53..a983739e09 100644 --- a/Saturation/PredicateSplitPassiveClauseContainer.hpp +++ b/Saturation/PredicateSplitPassiveClauseContainer.hpp @@ -100,6 +100,18 @@ class TheoryMultiSplitPassiveClauseContainer : public PredicateSplitPassiveClaus float evaluateFeatureEstimate(unsigned numPositiveLiterals, const Inference& inf) const override; }; +#if VHOL +class HoFeaturesMultiSplitPassiveClauseContainer : public PredicateSplitPassiveClauseContainer +{ +public: + HoFeaturesMultiSplitPassiveClauseContainer(bool isOutermost, const Shell::Options &opt, Lib::vstring name, Lib::vvector> queues); + +private: + float evaluateFeature(Clause* cl) const override; + float evaluateFeatureEstimate(unsigned numPositiveLiterals, const Inference& inf) const override; +}; +#endif + class AvatarMultiSplitPassiveClauseContainer : public PredicateSplitPassiveClauseContainer { public: diff --git a/Saturation/ProvingHelper.cpp b/Saturation/ProvingHelper.cpp index 9392af232e..f4e51c6a29 100644 --- a/Saturation/ProvingHelper.cpp +++ b/Saturation/ProvingHelper.cpp @@ -140,7 +140,7 @@ void ProvingHelper::runVampire(Problem& prb, const Options& opt) //this point is reached both by the vampire mode (single strategy) and the portfolio mode (strategy schedule) when inside a strategy /* Set random seed one more time, this time in the title of "seed for proof search". - * This should help improve reproducibility when using vampire mode + "--decode" to reply a behavior of a strat from a schedule + * This should help improve reproducibility when using vampire mode + "--decode" to replay a behavior of a strat from a schedule */ Lib::Random::setSeed(opt.randomSeed()); diff --git a/Saturation/SaturationAlgorithm.cpp b/Saturation/SaturationAlgorithm.cpp index dae29878bb..73ffc444c9 100644 --- a/Saturation/SaturationAlgorithm.cpp +++ b/Saturation/SaturationAlgorithm.cpp @@ -56,10 +56,8 @@ #include "Inferences/BinaryResolution.hpp" #include "Inferences/EqualityFactoring.hpp" #include "Inferences/EqualityResolution.hpp" -#include "Inferences/BoolEqToDiseq.hpp" #include "Inferences/ExtensionalityResolution.hpp" #include "Inferences/FOOLParamodulation.hpp" -#include "Inferences/Injectivity.hpp" #include "Inferences/Factoring.hpp" #include "Inferences/ForwardDemodulation.hpp" #include "Inferences/ForwardLiteralRewriting.hpp" @@ -71,26 +69,33 @@ #include "Inferences/TermAlgebraReasoning.hpp" #include "Inferences/SLQueryBackwardSubsumption.hpp" #include "Inferences/Superposition.hpp" + +#if VHOL #include "Inferences/ArgCong.hpp" #include "Inferences/NegativeExt.hpp" -#include "Inferences/Narrow.hpp" #include "Inferences/PrimitiveInstantiation.hpp" #include "Inferences/Choice.hpp" #include "Inferences/ElimLeibniz.hpp" -#include "Inferences/SubVarSup.hpp" #include "Inferences/CNFOnTheFly.hpp" //#include "Inferences/RenamingOnTheFly.hpp" +#include "Inferences/BoolSimp.hpp" +#include "Inferences/CasesSimp.hpp" +#include "Inferences/Cases.hpp" +#include "Inferences/ImitateProject.hpp" +#include "Inferences/BoolEqToDiseq.hpp" +#include "Inferences/Injectivity.hpp" +#include "Inferences/BetaEtaISE.hpp" +#include "Inferences/FlexFlexSimplify.hpp" +#include "Inferences/PositiveExt.hpp" +#endif + #include "Inferences/URResolution.hpp" #include "Inferences/Instantiation.hpp" #include "Inferences/TheoryInstAndSimp.hpp" #include "Inferences/Induction.hpp" #include "Inferences/ArithmeticSubtermGeneralization.hpp" #include "Inferences/TautologyDeletionISE.hpp" -#include "Inferences/CombinatorDemodISE.hpp" -#include "Inferences/CombinatorNormalisationISE.hpp" -#include "Inferences/BoolSimp.hpp" -#include "Inferences/CasesSimp.hpp" -#include "Inferences/Cases.hpp" + #include "Saturation/ExtensionalityClauseContainer.hpp" @@ -134,8 +139,20 @@ std::unique_ptr makeLevel0(bool isOutermost, const Optio return std::make_unique(isOutermost, opt, name + "AWQ"); } -std::unique_ptr makeLevel1(bool isOutermost, const Options& opt, vstring name) +std::unique_ptr makeLevel1(bool isOutermost, bool forHO, const Options& opt, vstring name) { + #if VHOL + if(opt.hoFeaturesSplitQueues() && forHO){ + Lib::vvector> queues; + auto cutoffs = opt.hoFeaturesSplitQueueCutoffs(); + for (unsigned i = 0; i < cutoffs.size(); i++) + { + auto queueName = name + "HoFSQ" + Int::toString(cutoffs[i]) + ":"; + queues.push_back(makeLevel0(false, opt, queueName)); + } + return std::make_unique(isOutermost, opt, name + "HoFSQ", std::move(queues)); + } + #else if (opt.useTheorySplitQueues()) { Lib::vvector> queues; @@ -147,13 +164,14 @@ std::unique_ptr makeLevel1(bool isOutermost, const Optio } return std::make_unique(isOutermost, opt, name + "ThSQ", std::move(queues)); } + #endif else { return makeLevel0(isOutermost, opt, name); } } -std::unique_ptr makeLevel2(bool isOutermost, const Options& opt, vstring name) +std::unique_ptr makeLevel2(bool isOutermost, bool forHO, const Options& opt, vstring name) { if (opt.useAvatarSplitQueues()) { @@ -162,17 +180,17 @@ std::unique_ptr makeLevel2(bool isOutermost, const Optio for (unsigned i = 0; i < cutoffs.size(); i++) { auto queueName = name + "AvSQ" + Int::toString(cutoffs[i]) + ":"; - queues.push_back(makeLevel1(false, opt, queueName)); + queues.push_back(makeLevel1(false, forHO, opt, queueName)); } return std::make_unique(isOutermost, opt, name + "AvSQ", std::move(queues)); } else { - return makeLevel1(isOutermost, opt, name); + return makeLevel1(isOutermost, forHO, opt, name); } } -std::unique_ptr makeLevel3(bool isOutermost, const Options& opt, vstring name) +std::unique_ptr makeLevel3(bool isOutermost, bool forHO, const Options& opt, vstring name) { if (opt.useSineLevelSplitQueues()) { @@ -181,17 +199,17 @@ std::unique_ptr makeLevel3(bool isOutermost, const Optio for (unsigned i = 0; i < cutoffs.size(); i++) { auto queueName = name + "SLSQ" + Int::toString(cutoffs[i]) + ":"; - queues.push_back(makeLevel2(false, opt, queueName)); + queues.push_back(makeLevel2(false, forHO, opt, queueName)); } return std::make_unique(isOutermost, opt, name + "SLSQ", std::move(queues)); } else { - return makeLevel2(isOutermost, opt, name); + return makeLevel2(isOutermost, forHO, opt, name); } } -std::unique_ptr makeLevel4(bool isOutermost, const Options& opt, vstring name) +std::unique_ptr makeLevel4(bool isOutermost, bool forHO, const Options& opt, vstring name) { if (opt.usePositiveLiteralSplitQueues()) { @@ -200,13 +218,13 @@ std::unique_ptr makeLevel4(bool isOutermost, const Optio for (unsigned i = 0; i < cutoffs.size(); i++) { auto queueName = name + "PLSQ" + Int::toString(cutoffs[i]) + ":"; - queues.push_back(makeLevel3(false, opt, queueName)); + queues.push_back(makeLevel3(false, forHO, opt, queueName)); } return std::make_unique(isOutermost, opt, name + "PLSQ", std::move(queues)); } else { - return makeLevel3(isOutermost, opt, name); + return makeLevel3(isOutermost, forHO, opt, name); } } @@ -247,7 +265,12 @@ SaturationAlgorithm::SaturationAlgorithm(Problem& prb, const Options& opt) } else { - _passive = makeLevel4(true, opt, ""); +#if VHOL + bool higher_order = prb.higherOrder(); +#else + bool higher_order = false; +#endif + _passive = makeLevel4(true, higher_order, opt, ""); } _active = new ActiveClauseContainer(opt); @@ -1558,71 +1581,106 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const gie->addFront(res->_instantiation); } - if (prb.hasEquality()) { + if (prb.hasEquality() || opt.FOOLParamodulation() +#if VHOL // cases and foolParamodulation can introduce equality into a problem which has none + || opt.cases() +#endif + ) { gie->addFront(new EqualityFactoring()); gie->addFront(new EqualityResolution()); +#if VHOL if(env.options->superposition()){ +#endif gie->addFront(new Superposition()); +#if VHOL } +#endif } else if(opt.unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF){ gie->addFront(new EqualityResolution()); } - if(opt.combinatorySup()){ +#if VHOL + if(prb.higherOrder()){ gie->addFront(new ArgCong()); gie->addFront(new NegativeExt());//TODO add option - if(opt.narrow() != Options::Narrow::OFF){ - gie->addFront(new Narrow()); + if(!env.options->higherOrderUnifDepth() && !env.options->applicativeUnify()){ + // only add when we are not carrying out higher-order unification + gie->addFront(new ImitateProject()); + } + if(env.options->positiveExtensionality()){ + gie->addFront(new PositiveExt()); } - if(!opt.pragmatic()){ - gie->addFront(new SubVarSup()); + if(prb.hasFOOL() && env.options->booleanEqTrick()){ + gie->addFront(new BoolEqToDiseq()); + } + if(env.options->choiceReasoning()){ + gie->addFront(new Choice()); } } - if(prb.hasFOOL() && - prb.higherOrder() && env.options->booleanEqTrick()){ - // gie->addFront(new ProxyElimination::NOTRemovalGIE()); - gie->addFront(new BoolEqToDiseq()); - } - - if(opt.complexBooleanReasoning() && prb.hasBoolVar() && - prb.higherOrder() && !opt.lambdaFreeHol()){ + if(opt.complexBooleanReasoning() && prb.hasBoolVar() && prb.higherOrder()){ gie->addFront(new PrimitiveInstantiation()); //TODO only add in some cases gie->addFront(new ElimLeibniz()); } - if(env.options->choiceReasoning()){ - gie->addFront(new Choice()); + if (opt.cases() && prb.hasFOOL()) { + gie->addFront(new Cases()); } + if((prb.hasLogicalProxy() || prb.hasBoolVar() || prb.hasFOOL()) && + prb.higherOrder() && !prb.quantifiesOverPolymorphicVar()){ // TODO why the last condition???? + if(env.options->cnfOnTheFly() != Options::CNFOnTheFly::EAGER && + env.options->cnfOnTheFly() != Options::CNFOnTheFly::OFF){ + gie->addFront(new LazyClausificationGIE()); + } + } + + if (prb.higherOrder() && opt.injectivityReasoning()) { + gie->addFront(new Injectivity()); + } +#endif + gie->addFront(new Factoring()); if (opt.binaryResolution()) { gie->addFront(new BinaryResolution()); } if (opt.unitResultingResolution() != Options::URResolution::OFF) { - gie->addFront(new URResolution()); +#if VHOL + if(env.property->higherOrder()){ + // TODO Should we be outputing an error or just dying? + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: unit resulting resolution is not compatible with higher-order. Ignoring request." << endl; + env.endOutput(); + } + } else { +#endif + gie->addFront(new URResolution()); +#if VHOL + } +#endif } if (opt.extensionalityResolution() != Options::ExtensionalityResolution::OFF) { gie->addFront(new ExtensionalityResolution()); } if (opt.FOOLParamodulation()) { - gie->addFront(new FOOLParamodulation()); - } - if (opt.cases() && prb.hasFOOL() && !opt.casesSimp()) { - gie->addFront(new Cases()); - } - - if((prb.hasLogicalProxy() || prb.hasBoolVar() || prb.hasFOOL()) && - prb.higherOrder() && !prb.quantifiesOverPolymorphicVar()){ - if(env.options->cnfOnTheFly() != Options::CNFOnTheFly::EAGER && - env.options->cnfOnTheFly() != Options::CNFOnTheFly::OFF){ - gie->addFront(new LazyClausificationGIE()); +#if VHOL + if(env.property->higherOrder()){ + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: FOOL paramodulation is not compatible with higher-order. Try using Cases or CasesSimp instead. Ignoring request." << endl; + env.endOutput(); + } + } else { +#endif + gie->addFront(new FOOLParamodulation()); +#if VHOL } +#endif } - if (opt.injectivityReasoning()) { - gie->addFront(new Injectivity()); - } if(prb.hasEquality() && env.signature->hasTermAlgebras()) { if (opt.termAlgebraCyclicityCheck() == Options::TACyclicityCheck::RULE) { gie->addFront(new AcyclicityGIE()); @@ -1670,21 +1728,37 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const //create simplification engine +#if VHOL if((prb.hasLogicalProxy() || prb.hasBoolVar() || prb.hasFOOL()) && prb.higherOrder() && !prb.quantifiesOverPolymorphicVar()){ if(env.options->cnfOnTheFly() != Options::CNFOnTheFly::EAGER && env.options->cnfOnTheFly() != Options::CNFOnTheFly::OFF){ res->addSimplifierToFront(new LazyClausification()); } - //res->addSimplifierToFront(new RenamingOnTheFly()); } +#endif // create forward simplification engine if (prb.hasEquality() && opt.innerRewriting()) { res->addForwardSimplifierToFront(new InnerRewriting()); } if (opt.hyperSuperposition()) { - res->addForwardSimplifierToFront(new HyperSuperposition()); +#if VHOL + if(env.property->higherOrder()){ + // TODO how to output error properly? + // Should we be outputing an error or just dying? + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: hyper superposition is not compatible with higher-order. Ignoring request" << endl; + env.endOutput(); + } + } else { +#endif + res->addForwardSimplifierToFront(new HyperSuperposition()); +#if VHOL + } +#endif } if (opt.globalSubsumption()) { res->addForwardSimplifierToFront(new GlobalSubsumption(opt)); @@ -1697,18 +1771,30 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const // fsd should be performed after forward subsumption, // because every successful forward subsumption will lead to a (useless) match in fsd. if (opt.forwardSubsumptionDemodulation()) { - res->addForwardSimplifierToFront(new ForwardSubsumptionDemodulation(false)); +#if VHOL + if(prb.higherOrder()){ + res->addForwardSimplifierToFront(new ForwardSubsumptionDemodulation(false)); + } else { +#endif + res->addForwardSimplifierToFront(new ForwardSubsumptionDemodulation(false)); +#if VHOL + } +#endif } } if (prb.hasEquality()) { switch(opt.forwardDemodulation()) { case Options::Demodulation::ALL: case Options::Demodulation::PREORDERED: - if(opt.combinatorySup()){ - res->addForwardSimplifierToFront(new ForwardDemodulationImpl()); +#if VHOL + if(prb.higherOrder()){ + res->addForwardSimplifierToFront(new ForwardDemodulation()); } else { - res->addForwardSimplifierToFront(new ForwardDemodulationImpl()); +#endif + res->addForwardSimplifierToFront(new ForwardDemodulation()); +#if VHOL } +#endif break; case Options::Demodulation::OFF: break; @@ -1719,14 +1805,9 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const } } if (opt.forwardSubsumption()) { - if (opt.forwardSubsumptionResolution()) { - //res->addForwardSimplifierToFront(new CTFwSubsAndRes(true)); - res->addForwardSimplifierToFront(new ForwardSubsumptionAndResolution(true)); - } - else { - //res->addForwardSimplifierToFront(new CTFwSubsAndRes(false)); - res->addForwardSimplifierToFront(new ForwardSubsumptionAndResolution(false)); - } + //res->addForwardSimplifierToFront(new CTFwSubsAndRes(true)); + bool withResolution = opt.forwardSubsumptionResolution(); + res->addForwardSimplifierToFront(new ForwardSubsumptionAndResolution(withResolution)); } else if (opt.forwardSubsumptionResolution()) { USER_ERROR("Forward subsumption resolution requires forward subsumption to be enabled."); @@ -1737,7 +1818,15 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const switch(opt.backwardDemodulation()) { case Options::Demodulation::ALL: case Options::Demodulation::PREORDERED: - res->addBackwardSimplifierToFront(new BackwardDemodulation()); +#if VHOL + if(prb.higherOrder()){ + res->addBackwardSimplifierToFront(new BackwardDemodulation()); + } else { +#endif + res->addBackwardSimplifierToFront(new BackwardDemodulation()); +#if VHOL + } +#endif break; case Options::Demodulation::OFF: break; @@ -1748,7 +1837,15 @@ SaturationAlgorithm* SaturationAlgorithm::createFromOptions(Problem& prb, const } } if (prb.hasEquality() && opt.backwardSubsumptionDemodulation()) { - res->addBackwardSimplifierToFront(new BackwardSubsumptionDemodulation()); +#if VHOL + if(prb.higherOrder()){ + res->addBackwardSimplifierToFront(new BackwardSubsumptionDemodulation()); + } else { +#endif + res->addBackwardSimplifierToFront(new BackwardSubsumptionDemodulation()); +#if VHOL + } +#endif } if (opt.backwardSubsumption() != Options::Subsumption::OFF) { bool byUnitsOnly=opt.backwardSubsumption()==Options::Subsumption::UNIT_ONLY; @@ -1796,25 +1893,18 @@ ImmediateSimplificationEngine* SaturationAlgorithm::createISE(Problem& prb, cons break; } - if(env.options->combinatorySup()){ - res->addFront(new CombinatorDemodISE()); - res->addFront(new CombinatorNormalisationISE()); - } - - if(env.options->choiceReasoning()){ +#if VHOL + if(prb.higherOrder() && env.options->choiceReasoning()){ res->addFront(new ChoiceDefinitionISE()); } if((prb.hasLogicalProxy() || prb.hasBoolVar() || prb.hasFOOL()) && prb.higherOrder() && !env.options->addProxyAxioms()){ + if(env.options->cnfOnTheFly() == Options::CNFOnTheFly::EAGER){ - /*res->addFrontMany(new ProxyISE()); - res->addFront(new OrImpAndProxyISE()); - res->addFront(new NotProxyISE()); - res->addFront(new EqualsProxyISE()); - res->addFront(new PiSigmaProxyISE());*/ res->addFrontMany(new EagerClausificationISE()); - } else { + } + if(env.options->iffXorRewriter()){ res->addFront(new IFFXORRewriterISE()); } res->addFront(new BoolSimp()); @@ -1824,6 +1914,16 @@ ImmediateSimplificationEngine* SaturationAlgorithm::createISE(Problem& prb, cons res->addFrontMany(new CasesSimp()); } + if(prb.higherOrder() && env.options->newTautologyDel()){ + res->addFront(new TautologyDeletionISE2()); + } + + if(prb.higherOrder()){ + res->addFront(new BetaEtaSimplify()); + res->addFront(new FlexFlexSimplify()); + } +#endif + // Only add if there are distinct groups if(prb.hasEquality() && env.signature->hasDistinctGroups()) { res->addFront(new DistinctEqualitySimplifier()); @@ -1870,9 +1970,6 @@ ImmediateSimplificationEngine* SaturationAlgorithm::createISE(Problem& prb, cons res->addFront(new TrivialInequalitiesRemovalISE()); } res->addFront(new TautologyDeletionISE()); - if(env.options->newTautologyDel()){ - res->addFront(new TautologyDeletionISE2()); - } res->addFront(new DuplicateLiteralRemovalISE()); return res; diff --git a/Saturation/Splitter.cpp b/Saturation/Splitter.cpp index ffc7c8870a..eea2223551 100644 --- a/Saturation/Splitter.cpp +++ b/Saturation/Splitter.cpp @@ -49,6 +49,8 @@ #include "SaturationAlgorithm.hpp" +#include "Shell/UIHelper.hpp" + namespace Saturation { @@ -74,13 +76,27 @@ void SplittingBranchSelector::init() #if VZ3 case Options::SatSolver::Z3: { BYPASSING_ALLOCATOR - _solverIsSMT = true; - _solver = new Z3Interfacing(_parent.getOptions(),_parent.satNaming(), /* unsat core */ false, _parent.getOptions().exportAvatarProblem()); - if(_parent.getOptions().satFallbackForSMT()){ - // TODO make fallback minimizing? - SATSolver* fallback = new MinisatInterfacing(_parent.getOptions(),true); - _solver = new FallbackSolverWrapper(_solver.release(),fallback); - } + #if VHOL + if(env.property->higherOrder()){ + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: Z3 as SAT solver not compatible with higher-order. Using Minisat instead" << endl; + env.endOutput(); + } + _solver = new MinisatInterfacing(_parent.getOptions(),true); + } else { + #endif + _solverIsSMT = true; + _solver = new Z3Interfacing(_parent.getOptions(),_parent.satNaming(), /* unsat core */ false, _parent.getOptions().exportAvatarProblem()); + if(_parent.getOptions().satFallbackForSMT()){ + // TODO make fallback minimizing? + SATSolver* fallback = new MinisatInterfacing(_parent.getOptions(),true); + _solver = new FallbackSolverWrapper(_solver.release(),fallback); + } + #if VHOL + } + #endif } break; #endif @@ -1507,8 +1523,8 @@ void Splitter::onClauseReduction(Clause* cl, ClauseIterator premises, Clause* re } } SplitSet* diff=unionAll->subtract(cl->splits()); - - ASS(allSplitLevelsActive(diff)); + + ASS_REP(allSplitLevelsActive(diff), cl->toString()); if(diff->isEmpty()) { // unconditionally reduced @@ -1596,7 +1612,7 @@ void Splitter::onNewClause(Clause* cl) cl->updateColor(color); } - ASS(allSplitLevelsActive(cl->splits())); + ASS_REP(allSplitLevelsActive(cl->splits()), cl->toString() ); } /** diff --git a/Shell/AnswerExtractor.cpp b/Shell/AnswerExtractor.cpp index a268c2c24c..158c80f500 100644 --- a/Shell/AnswerExtractor.cpp +++ b/Shell/AnswerExtractor.cpp @@ -120,7 +120,7 @@ void AnswerExtractor::getNeededUnits(Clause* refutation, ClauseStack& premiseCla class ConjunctionGoalAnswerExractor::SubstBuilder { public: - SubstBuilder(LiteralStack& goalLits, LiteralIndexingStructure& lemmas, RobSubstitution& subst) + SubstBuilder(LiteralStack& goalLits, LiteralIndexingStructure& lemmas, RobSubstitutionTS& subst) : _goalLits(goalLits), _lemmas(lemmas), _subst(subst), _goalCnt(goalLits.size()), _btData(_goalCnt), _unifIts(_goalCnt), _triedEqUnif(_goalCnt) {} @@ -186,7 +186,7 @@ class ConjunctionGoalAnswerExractor::SubstBuilder while(_unifIts[_depth].hasNext()) { SLQueryResult qres = _unifIts[_depth].next(); ASS_EQ(goalLit->header(), qres.literal->header()); - if(_subst.unifyArgs(goalLit, 0, qres.literal, 1)) { + if(_subst.unify(TermList(goalLit), 0, TermList(qres.literal), 1)) { return true; } } @@ -202,7 +202,7 @@ class ConjunctionGoalAnswerExractor::SubstBuilder private: LiteralStack& _goalLits; LiteralIndexingStructure& _lemmas; - RobSubstitution& _subst; + RobSubstitutionTS& _subst; unsigned _goalCnt; DArray _btData; diff --git a/Shell/BlockedClauseElimination.cpp b/Shell/BlockedClauseElimination.cpp index 23059d5c52..885fe87c8f 100644 --- a/Shell/BlockedClauseElimination.cpp +++ b/Shell/BlockedClauseElimination.cpp @@ -503,9 +503,9 @@ bool BlockedClauseElimination::resolvesToTautologyUn(Clause* cl, Literal* lit, C // cout << "lit: " << lit->toString() << endl; // cout << "plit: " << plit->toString() << endl; - static RobSubstitution subst_main; + static RobSubstitutionTS subst_main; subst_main.reset(); - if(!subst_main.unifyArgs(lit,0,plit,1)) { + if(!subst_main.unify(TermList(lit),0,TermList(plit),1)) { return true; // since they don't resolve } @@ -538,7 +538,7 @@ bool BlockedClauseElimination::resolvesToTautologyUn(Clause* cl, Literal* lit, C static DHSet pcl_lits; pcl_lits.reset(); - static RobSubstitution subst_aux; + static RobSubstitutionTS subst_aux; subst_aux.reset(); for (unsigned i = 0; i < pcl->length(); i++) { @@ -554,7 +554,7 @@ bool BlockedClauseElimination::resolvesToTautologyUn(Clause* cl, Literal* lit, C // cout << "insert2(scurlit): " << scurlit->toString() << endl; if (curlit != plit && cl_lits.find(opscurlit)) { - if (opslit->functor() != scurlit->functor() || !subst_aux.unifyArgs(opslit,0,scurlit,0)) { // opslit is the same thing as plit(subst_main) + if (opslit->functor() != scurlit->functor() || !subst_aux.unify(TermList(opslit),0,TermList(scurlit),0)) { // opslit is the same thing as plit(subst_main) return true; } else { subst_aux.reset(); diff --git a/Shell/BlockedClauseElimination.hpp b/Shell/BlockedClauseElimination.hpp index bcd39fe536..5586d642f4 100644 --- a/Shell/BlockedClauseElimination.hpp +++ b/Shell/BlockedClauseElimination.hpp @@ -23,6 +23,7 @@ #include "Lib/Environment.hpp" #include "Lib/Comparison.hpp" #include "Lib/Stack.hpp" +#include "Lib/Int.hpp" namespace Shell { diff --git a/Shell/EqualityProxy.cpp b/Shell/EqualityProxy.cpp index 950744ecb4..5f76530484 100644 --- a/Shell/EqualityProxy.cpp +++ b/Shell/EqualityProxy.cpp @@ -338,7 +338,7 @@ unsigned EqualityProxy::getProxyPredicate() _defUnit = new FormulaUnit(quantDefForm,NonspecificInference0(UnitInputType::AXIOM,InferenceRule::EQUALITY_PROXY_AXIOM1)); - InferenceStore::instance()->recordIntroducedSymbol(_defUnit, false, newPred); + InferenceStore::instance()->recordIntroducedSymbol(_defUnit, SymbolType::PRED, newPred); _proxyPredicate = newPred; _addedPred = true; return newPred; diff --git a/Shell/EqualityProxyMono.cpp b/Shell/EqualityProxyMono.cpp index 042ae8088b..9a066686a1 100644 --- a/Shell/EqualityProxyMono.cpp +++ b/Shell/EqualityProxyMono.cpp @@ -369,7 +369,7 @@ unsigned EqualityProxyMono::getProxyPredicate(TermList sort) FormulaUnit* defUnit = new FormulaUnit(quantDefForm,NonspecificInference0(UnitInputType::AXIOM,InferenceRule::EQUALITY_PROXY_AXIOM1)); s_proxyPremises.insert(sort, defUnit); - InferenceStore::instance()->recordIntroducedSymbol(defUnit, false, newPred); + InferenceStore::instance()->recordIntroducedSymbol(defUnit, SymbolType::PRED, newPred); return newPred; } diff --git a/Shell/FOOLElimination.cpp b/Shell/FOOLElimination.cpp index 048c25e778..35904721f7 100644 --- a/Shell/FOOLElimination.cpp +++ b/Shell/FOOLElimination.cpp @@ -31,7 +31,9 @@ #include "Shell/Options.hpp" #include "Shell/SymbolOccurrenceReplacement.hpp" -#include "Shell/LambdaElimination.hpp" +#if VHOL +#include "Shell/LambdaConversion.hpp" +#endif #include "Shell/Statistics.hpp" #include "Rectify.hpp" @@ -48,11 +50,33 @@ const char* FOOLElimination::LET_PREFIX = "lG"; const char* FOOLElimination::BOOL_PREFIX = "bG"; const char* FOOLElimination::MATCH_PREFIX = "mG"; -FOOLElimination::FOOLElimination() : _defs(0), _higherOrder(0), _polymorphic(0) {} +FOOLElimination::FOOLElimination() : _defs(0), +#if VHOL + _higherOrder(0), +#endif + _polymorphic(0) {} bool FOOLElimination::needsElimination(FormulaUnit* unit) { CALL("FOOLElimination::needsElimination"); +#if VHOL + if(env.property->higherOrder()) + { + switch(env.options->cnfOnTheFly()){ + case Options::CNFOnTheFly::EAGER: + break; + case Options::CNFOnTheFly::CONJ_EAGER: + if(unit->inputType() != UnitInputType::NEGATED_CONJECTURE && + unit->inputType() != UnitInputType::CONJECTURE){ + return true; + } + break; + default: + return true; + } + } +#endif + /** * Be careful with the difference between FOOLElimination::needsElimination * and Property::_hasFOOL! @@ -98,7 +122,9 @@ bool FOOLElimination::needsElimination(FormulaUnit* unit) { void FOOLElimination::apply(Problem& prb) { CALL("FOOLElimination::apply(Problem*)"); +#if VHOL _higherOrder = prb.hasApp(); +#endif _polymorphic = prb.hasPolymorphicSym(); apply(prb.units()); prb.reportFOOLEliminated(); @@ -151,7 +177,27 @@ FormulaUnit* FOOLElimination::apply(FormulaUnit* unit) { SortHelper::collectVariableSorts(formula, _varSorts); - Formula* processedFormula = process(formula); +#if VHOL + bool isConjecture = + unit->inputType() == UnitInputType::NEGATED_CONJECTURE || + unit->inputType() == UnitInputType::CONJECTURE; + + // The old implementation (combinator implementation) had a check !_polymorhpic + // I've removed it here, but if we start seeing issues on polymorphic problems, that + // is one place to check immediately + bool proxify = env.property->higherOrder() && + env.options->cnfOnTheFly() != Options::CNFOnTheFly::EAGER && + env.options->cnfOnTheFly() != Options::CNFOnTheFly::OFF && + (env.options->cnfOnTheFly() != Options::CNFOnTheFly::CONJ_EAGER || !isConjecture); +#endif + + Formula* processedFormula = +#if VHOL + proxify ? + convertToProxified(formula) : +#endif + process(formula); + if (formula == processedFormula) { return rectifiedUnit; } @@ -174,21 +220,39 @@ FormulaUnit* FOOLElimination::apply(FormulaUnit* unit) { return processedUnit; } -Formula* FOOLElimination::process(Formula* formula) { - CALL("FOOLElimination::process(Formula*)"); +#if VHOL +Formula* FOOLElimination::convertToProxified(Formula* formula) +{ + CALL("FOOLElimination::convertToProxified"); + + LambdaConversion lc; + + Formula* processedFormula; + if(formula->connective() == LITERAL){ + // don't proxify the equality itself, as this blocks definition rewriting + // which really harms performance + Literal* literal = formula->literal(); + TermList lhs = *literal->nthArgument(0); + TermList rhs = *literal->nthArgument(1); + lhs = lc.convertLambda(lhs); + rhs = lc.convertLambda(rhs); + literal = Literal::createEquality(literal->polarity(), lhs, rhs, SortHelper::getEqualityArgumentSort(literal)); + processedFormula = new AtomicFormula(literal); + } else { + TermList proxifiedFormula = lc.convertLambda(formula); + processedFormula = toEquality(proxifiedFormula); + } - if(env.options->cnfOnTheFly() != Options::CNFOnTheFly::EAGER && - !_polymorphic){ - LambdaElimination le = LambdaElimination(); - TermList proxifiedFormula = le.elimLambda(formula); - Formula* processedFormula = toEquality(proxifiedFormula); + if (env.options->showPreprocessing()) { + reportProcessed(formula->toString(), processedFormula->toString()); + } - if (env.options->showPreprocessing()) { - reportProcessed(formula->toString(), processedFormula->toString()); - } + return processedFormula; +} +#endif - return processedFormula; - } +Formula* FOOLElimination::process(Formula* formula) { + CALL("FOOLElimination::process(Formula*)"); switch (formula->connective()) { case LITERAL: { @@ -212,8 +276,11 @@ Formula* FOOLElimination::process(Formula* formula) { * between FOOL boolean terms. */ - if (literal->isEquality() && - (!env.property->higherOrder() || env.options->equalityToEquivalence())) { + if (literal->isEquality() +#if VHOL + && (!env.property->higherOrder() || env.options->equalityToEquivalence()) +#endif + ) { ASS_EQ(literal->arity(), 2); TermList lhs = *literal->nthArgument(0); TermList rhs = *literal->nthArgument(1); @@ -738,7 +805,9 @@ void FOOLElimination::process(Term* term, Context context, TermList& termResult, * where true is FOOL constant * 3) Replace the term with g(Y1, ..., Ym, X1, ..., Xn) */ +#if VHOL if(!_higherOrder){ +#endif Formula *formula = process(sd->getFormula()); collectSorts(freeVars, typeVars, termVars, allVars, termVarSorts); @@ -761,19 +830,21 @@ void FOOLElimination::process(Term* term, Context context, TermList& termResult, NonspecificInference1(InferenceRule::FOOL_ELIMINATION, _unit))); termResult = freshSymbolApplication; - } else { - LambdaElimination le = LambdaElimination(); - termResult = le.elimLambda(sd->getFormula()); +#if VHOL + } + else { + termResult = LambdaConversion().convertLambda(sd->getFormula()); } +#endif break; } +#if VHOL case Term::SF_LAMBDA: { - // Lambda terms are translated to FOL using SKIBC combinators which are extensively described in - // the literature. - LambdaElimination le = LambdaElimination(); - termResult = le.elimLambda(term); + // Lambda terms using named representation are converted to nameless De Bruijn representation + termResult = LambdaConversion().convertLambda(term); break; } +#endif case Term::SF_MATCH: { /** diff --git a/Shell/FOOLElimination.hpp b/Shell/FOOLElimination.hpp index 6117de5b72..c131149476 100644 --- a/Shell/FOOLElimination.hpp +++ b/Shell/FOOLElimination.hpp @@ -37,7 +37,9 @@ class FOOLElimination { /** Check if the unit contains expressions that are not syntactically first-order */ static bool needsElimination(FormulaUnit* unit); - + // Converts a boolean term t to a formula 't = true' + static Formula* toEquality(TermList booleanTerm); + private: FormulaUnit* apply(FormulaUnit* fu); @@ -46,7 +48,9 @@ class FOOLElimination { /** A list of definitions, produced during preprocessing */ UnitList* _defs; +#if VHOL bool _higherOrder; +#endif bool _polymorphic; /** Add a new definitions to _defs */ @@ -58,7 +62,10 @@ class FOOLElimination { /** Process a given part of the unit */ FormulaList* process(FormulaList* fs); Formula* process(Formula* f); - +#if VHOL + Formula* convertToProxified(Formula* f); +#endif + // A context in one of two possible values, so we model it with bool constants typedef bool Context; static const Context TERM_CONTEXT = true; @@ -88,9 +95,6 @@ class FOOLElimination { // context of the current formula void collectSorts(VList* vars, TermStack& typeVars, TermStack& termVars, TermStack& allVars, TermStack& termVarSorts); - // Converts a boolean term t to a formula 't = true' - static Formula* toEquality(TermList booleanTerm); - // Introduces a fresh predicate or function (depending on the context) symbol // with given arguments and result sort static unsigned introduceFreshSymbol(Context context, const char* prefix, diff --git a/Shell/Flattening.cpp b/Shell/Flattening.cpp index c745047a7d..a080ade800 100644 --- a/Shell/Flattening.cpp +++ b/Shell/Flattening.cpp @@ -104,8 +104,11 @@ Formula* Flattening::innerFlatten (Formula* f) { Literal* lit = f->literal(); - if (env.options->newCNF() && !env.property->higherOrder() && - !env.property->hasPolymorphicSym()) { + if (env.options->newCNF() +#if VHOL + && !env.property->higherOrder() +#endif + && !env.property->hasPolymorphicSym()) { // Convert equality between boolean FOOL terms to equivalence if (lit->isEquality()) { TermList lhs = *lit->nthArgument(0); diff --git a/Shell/FunctionDefinition.cpp b/Shell/FunctionDefinition.cpp index f87fb6ec2e..b929fad96d 100644 --- a/Shell/FunctionDefinition.cpp +++ b/Shell/FunctionDefinition.cpp @@ -31,6 +31,7 @@ #include "Kernel/SubstHelper.hpp" #include "Kernel/Term.hpp" #include "Kernel/TermIterators.hpp" +#include "Kernel/ApplicativeHelper.hpp" #include "Shell/Options.hpp" @@ -186,6 +187,9 @@ bool FunctionDefinition::removeUnusedDefinitions(UnitList*& units, Problem* prb) } } for(unsigned i=0;ifunctor(); @@ -376,7 +380,11 @@ bool FunctionDefinition::removeAllDefinitions(UnitList*& units) while(unfoldIterator.hasNext()) { Clause* cl=static_cast(unfoldIterator.next()); ASS(cl->isClause()); +#if VHOL + // AYB TODO not sure what is the point of the below + // proxy axioms are probably going to be removed anyway if(cl->isProxyAxiomsDescendant()){ continue; } +#endif Clause* newCl=applyDefinitions(cl); if(cl!=newCl) { // cout<<"D- "<<(*cl)<arity()) { - if(env.signature->isFoolConstantSymbol(true , f) || - env.signature->isFoolConstantSymbol(false, f)){ +#if VHOL + if(ApplicativeHelper::isBool(TermList(lhs))){ return 0; } +#endif //Higher-order often contains definitions of the form //f = ^x^y... - if (rhs->arity() && !env.property->higherOrder()) { // c = f(...) + if (rhs->arity() +#if VHOL + && !env.property->higherOrder() +#endif + ) { // c = f(...) return 0; } if (rhs->functor() == f) { return 0; } +#if VHOL if(!env.property->higherOrder()){ +#endif return new Def(lhs,rhs,true,true); +#if VHOL } +#endif } int vars = 0; // counter of variables occurring in the lhs diff --git a/Shell/InequalitySplitting.cpp b/Shell/InequalitySplitting.cpp index c687744f8d..3027ef6f84 100644 --- a/Shell/InequalitySplitting.cpp +++ b/Shell/InequalitySplitting.cpp @@ -43,7 +43,10 @@ using namespace Kernel; InequalitySplitting::InequalitySplitting(const Options& opt) -: _splittingTreshold(opt.inequalitySplitting()), _appify(false) +: _splittingTreshold(opt.inequalitySplitting()) +#if VHOL + , _appify(false) +#endif { ASS_G(_splittingTreshold,0); } @@ -52,7 +55,9 @@ void InequalitySplitting::perform(Problem& prb) { CALL("InequalitySplitting::perform"); - _appify = prb.hasApp(); +#if VHOL + _appify = prb.higherOrder(); +#endif if(perform(prb.units())) { prb.invalidateByRemoval(); } @@ -161,22 +166,29 @@ Literal* InequalitySplitting::splitLiteral(Literal* lit, UnitInputType inpType, unsigned fun; OperatorType* type; +#if VHOL if(!_appify){ +#endif fun=env.signature->addNamePredicate(vars.size() + 1); type = OperatorType::getPredicateType({srt}, vars.size()); +#if VHOL } else { srt = AtomicSort::arrowSort(srt, AtomicSort::boolSort()); fun=env.signature->addNameFunction(vars.size()); type = OperatorType::getConstantsType(srt, vars.size()); } - +#endif Signature::Symbol* sym; +#if VHOL if(_appify){ sym = env.signature->getFunction(fun); } else { - sym = env.signature->getPredicate(fun); +#endif + sym = env.signature->getPredicate(fun); +#if VHOL } +#endif sym->setType(type); TermList s; @@ -202,7 +214,15 @@ Literal* InequalitySplitting::splitLiteral(Literal* lit, UnitInputType inpType, (*defCl)[0]=makeNameLiteral(fun, t, false, vars); _predDefs.push(defCl); - InferenceStore::instance()->recordIntroducedSymbol(defCl,false,fun); +#if VHOL + if(_appify){ + InferenceStore::instance()->recordIntroducedSymbol(defCl,SymbolType::FUNC,fun); + } else { +#endif + InferenceStore::instance()->recordIntroducedSymbol(defCl,SymbolType::PRED,fun); +#if VHOL + } +#endif premise=defCl; @@ -229,16 +249,19 @@ Literal* InequalitySplitting::makeNameLiteral(unsigned predNum, TermList arg, bo { CALL("InequalitySplitting::makeNameLiteral"); +#if VHOL if(!_appify){ +#endif vars.push(arg); return Literal::create(predNum, vars.size(), polarity, false, vars.begin()); +#if VHOL } else { - TermList boolT = polarity ? TermList(Term::foolTrue()) : TermList(Term::foolFalse()); + TermList boolT = polarity ? ApplicativeHelper::top() : ApplicativeHelper::bottom(); TermList head = TermList(Term::create(predNum, vars.size(), vars.begin())); - TermList headS = SortHelper::getResultSort(head.term()); - TermList t = ApplicativeHelper::createAppTerm(headS, head, arg); + TermList t = ApplicativeHelper::app(head, arg); return Literal::createEquality(true, t, boolT, AtomicSort::boolSort()); } +#endif } diff --git a/Shell/InequalitySplitting.hpp b/Shell/InequalitySplitting.hpp index 58c53743f3..605b7c8f30 100644 --- a/Shell/InequalitySplitting.hpp +++ b/Shell/InequalitySplitting.hpp @@ -46,7 +46,9 @@ class InequalitySplitting Stack _predDefs; unsigned _splittingTreshold; +#if VHOL bool _appify; // do it the higher-order way +#endif }; }; diff --git a/Shell/LambdaConversion.cpp b/Shell/LambdaConversion.cpp new file mode 100644 index 0000000000..6c30592511 --- /dev/null +++ b/Shell/LambdaConversion.cpp @@ -0,0 +1,482 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file LambdaElimination.cpp + * converts a term from namaed lambda representation to + * a nameless one + */ + + +#if VHOL + +#include "Indexing/TermSharing.hpp" + +#include "Lib/Environment.hpp" +#include "Lib/Deque.hpp" +#include "Lib/Sort.hpp" + +#include "Kernel/Clause.hpp" +#include "Kernel/FormulaUnit.hpp" +#include "Kernel/Inference.hpp" +#include "Kernel/Problem.hpp" +#include "Kernel/Formula.hpp" +#include "Kernel/Signature.hpp" +#include "Kernel/SortHelper.hpp" +#include "Kernel/ApplicativeHelper.hpp" +#include "Kernel/TermIterators.hpp" + +#include "Skolem.hpp" +#include "Options.hpp" + +#include "LambdaConversion.hpp" + +using namespace Lib; +using namespace Kernel; +using namespace Shell; + +typedef ApplicativeHelper AH; + +TermList LambdaConversion::convertLambda(Formula* formula) +{ + CALL("LambdaConversion::convertLambda(Formula*)"); + + // remove top level universal type quantifiers. + if(formula->connective() == FORALL){ + VList* vars = formula->vars(); + SList* sorts = formula->sorts(); + Formula* f = formula->qarg(); + TermList s; + + bool typeVarFound; + while(vars){ + SortHelper::tryGetVariableSort(vars->head(), f, s); + if(s == AtomicSort::superSort()){ + typeVarFound = true; + vars = vars->tail(); + if(sorts) + sorts = sorts->tail(); + } else { + break; + } + } + + if(typeVarFound){ + if(vars) { + formula = new QuantifiedFormula(FORALL,vars,sorts,f); + } else { + formula = f; + } + } + } + + VarToIndexMap map; + return convertLambda(formula, map); +} + +TermList LambdaConversion::convertLambda(Formula* formula, VarToIndexMap& map) +{ + CALL("LambdaConversion::convertLambda(Formula*)/2"); + + TermList appTerm; //The resulting term + + Connective conn = formula->connective(); + + switch(conn){ + case LITERAL: { + Literal* lit = formula->literal(); + ASS(lit->isEquality()); //Is this a valid assumption? + + TermList lhs = convertLambda(*lit->nthArgument(0), map); + TermList rhs = convertLambda(*lit->nthArgument(1), map); + + TermList equalsSort = SortHelper::getEqualityArgumentSort(lit); + + appTerm = AH::app2(AH::equality(equalsSort), lhs, rhs); + + return lit->polarity() ? appTerm : AH::app(AH::neg(), appTerm); + } + case IFF: + case IMP: + case XOR:{ + Formula* lhs = formula->left(); + Formula* rhs = formula->right(); + + vstring name = (conn == IFF ? "vIFF" : (conn == IMP ? "vIMP" : "vXOR")); + TermList constant = TermList(Term::createConstant(env.signature->getBinaryProxy(name))); + + TermList form1 = convertLambda(lhs, map); + TermList form2 = convertLambda(rhs, map); + + return AH::app2(constant, form1, form2);; + } + case AND: + case OR:{ + FormulaList::Iterator argsIt(formula->args()); + + vstring name = (conn == AND ? "vAND" : "vOR"); + TermList constant = TermList(Term::createConstant(env.signature->getBinaryProxy(name))); + + TermList form; + unsigned count = 1; + while(argsIt.hasNext()){ + Formula* arg = argsIt.next(); + form = convertLambda(arg, map); + if(count == 1){ + appTerm = AH::app(constant, form); + }else if(count == 2){ + appTerm = AH::app(appTerm, form); + }else{ + appTerm = AH::app2(constant, appTerm, form); + } + count++; + } + return appTerm; + } + case NOT: { + TermList form = convertLambda(formula->uarg(), map); + return AH::app(AH::neg(), form); + } + case FORALL: + case EXISTS: { + VList* vars = formula->vars(); + VList::Iterator vit(vars); + + TermList form = TermList(Term::createFormula(formula->qarg())); + bool pi = conn == FORALL; + + TermList s; + while(vit.hasNext()){ + int v = vit.next(); + ALWAYS(SortHelper::tryGetVariableSort(v, formula->qarg(), s)); + if(s == AtomicSort::superSort()){ + USER_ERROR("Vampire does not support full TH1. This benchmark is either outside of the TH1 fragment, or outside of the fragment supported by Vampire"); + } + VList* var = VList::singleton(v); + SList* sort = SList::singleton(s); + auto t = TermList(Term::createLambda(form, var, sort, AtomicSort::boolSort())); + form = AH::app((pi ? AH::pi(s) : AH::sigma(s)), t); + } + return convertLambda(form, map); + } + case BOOL_TERM: + return convertLambda(formula->getBooleanTerm(), map); + case TRUE: + return TermList(Term::foolTrue()); + case FALSE: + return TermList(Term::foolFalse()); + default: + ASSERTION_VIOLATION; + + }//switch conn +} + +TermList LambdaConversion::convertLambda(TermList term) +{ + CALL("LambdaConversion::convertLambda(TermList)"); + + VarToIndexMap map; + return convertLambda(term, map); +} + +TermList LambdaConversion::convertLambda(TermList term, VarToIndexMap& map) +{ + CALL("LambdaConversion::convertLambda(TermList)/2"); + + if(term.isVar()){ + IndexSortPair p; + if(map.find(term.var(), p)){ + return AH::getDeBruijnIndex(p.first,p.second); + } + return term; + } + + Term* t = term.term(); + if(t->isSpecial()){ + switch(t->functor()){ + case Term::SF_FORMULA: + return convertLambda(t->getSpecialData()->getFormula(), map); + + case Term::SF_LAMBDA:{ + Term::SpecialTermData* sd = t->getSpecialData(); + SList* sorts = sd->getLambdaVarSorts(); + VList* vars = sd->getLambdaVars(); + + TermList eliminated = convertLambda(vars, sorts, sd->getLambdaExp(), sd->getLambdaExpSort(), map); + ASS_REP2(eliminated.isVar() || sortOf(eliminated) == sd->getSort(), t->toString(), eliminated.toString()) + return eliminated; + } + + default: + ASSERTION_VIOLATION; + } + } + + if(!t->isApplication()){ + return term; + } + + //must be of the form app(s1, s2, arg1, arg2) + TermList s1 = *t->nthArgument(0); + TermList s2 = *t->nthArgument(1); + TermList arg1 = *t->nthArgument(2); + TermList arg2 = *t->nthArgument(3); + + return AH::app(s1, s2, convertLambda(arg1, map), convertLambda(arg2, map)); +} + + +TermList LambdaConversion::convertLambda(VList* vars, SList* sorts, + TermList body, TermList bodySort, VarToIndexMap& map) +{ + CALL("LambdaConversion::LambdaConversion(VList* vars...)"); + + TermList converted; + + unsigned v = (unsigned)vars->head(); + TermList s = sorts->head(); + vars = vars->tail(); + sorts = sorts->tail(); + + VarToIndexMap newMap(map); + newMap.mapValues([](IndexSortPair p){ return make_pair(p.first + 1, p.second); }); + newMap.insert(v, make_pair(0, s)); + + if(vars){ + converted = convertLambda(vars, sorts, body, bodySort, newMap); + } else { + converted = convertLambda(body, newMap); + } + + bodySort = converted.isVar() ? bodySort : sortOf(converted); + return AH::lambda(s, bodySort, converted); +} + +TermList LambdaConversion::convertLambda(Term* lambdaTerm) +{ + CALL("LambdaConversion::convertLambda"); + + return convertLambda(TermList(lambdaTerm)); +} + + +TermList LambdaConversion::sortOf(TermList t) +{ + CALL("LambdaConversion::sortOf"); + + ASS(t.isTerm()); + return SortHelper::getResultSort(t.term()); +} + +void LambdaConversion::addFunctionExtensionalityAxiom(Problem& prb) +{ + CALL("LambdaConversion::addFunctionExtensionalityAxiom"); + + TermList alpha = TermList(0, false); + TermList beta = TermList(1, false); + TermList x = TermList(2, false); + TermList y = TermList(3, false); + unsigned diff = env.signature->getDiff(); + + TermList diffT = TermList(Term::create2(diff, alpha, beta)); + TermList diffTApplied = AH::app2(diffT, x, y); + TermList lhs = AH::app(alpha, beta, x, diffTApplied); + TermList rhs = AH::app(alpha, beta, y, diffTApplied); + + Clause* funcExtAx = new(2) Clause(2, NonspecificInference0(UnitInputType::AXIOM,InferenceRule::FUNC_EXT_AXIOM)); + (*funcExtAx)[0] = Literal::createEquality(false, lhs, rhs, beta); + (*funcExtAx)[1] = Literal::createEquality(true, x, y, AtomicSort::arrowSort(alpha, beta)); + UnitList::push(funcExtAx, prb.units()); + + + if (env.options->showPreprocessing()) { + env.out() << "Added functional extensionality axiom: " << std::endl; + env.out() << funcExtAx->toString() << std::endl; + } +} + +void LambdaConversion::addChoiceAxiom(Problem& prb) +{ + CALL("LambdaConversion::addChoiceAxiom"); + + TermList alpha = TermList(0, false); + TermList boolS = AtomicSort::boolSort(); + TermList alphaBool = AtomicSort::arrowSort(alpha, AtomicSort::boolSort()); + TermList p = TermList(1, false); + TermList x = TermList(2, false); + unsigned choice = env.signature->getChoice(); + + TermList choiceT = TermList(Term::create1(choice, alpha)); + TermList choiceTApplied = AH::app(alphaBool, alpha, choiceT, p); + TermList px = AH::app(alpha, boolS, p, x); + TermList pchoiceT = AH::app(alpha, boolS, p, choiceTApplied); + + Clause* choiceAx = new(2) Clause(2, NonspecificInference0(UnitInputType::AXIOM,InferenceRule::CHOICE_AXIOM)); + (*choiceAx)[0] = Literal::createEquality(true, px, AH::bottom(), boolS); + (*choiceAx)[1] = Literal::createEquality(true, pchoiceT, AH::top(), boolS); + UnitList::push(choiceAx, prb.units()); + + + if (env.options->showPreprocessing()) { + env.out() << "Added Hilbert choice axiom: " << std::endl; + env.out() << choiceAx->toString() << std::endl; + } +} + +void LambdaConversion::addProxyAxioms(Problem& prb) +{ + CALL("LambdaConversion::addProxyAxioms"); + + TermList s1 = TermList(0, false); + TermList x = TermList(1, false); + TermList y = TermList(2, false); + + TermList choiceSort = AtomicSort::arrowSort(AtomicSort::arrowSort(s1, AtomicSort::boolSort()), s1); + unsigned skolem1 = Skolem::addSkolemFunction(1,1,0, choiceSort); + unsigned skolem2 = Skolem::addSkolemFunction(1,1,0, choiceSort); + TermList sk1 = TermList(Term::create1(skolem1, s1)); + TermList sk2 = TermList(Term::create1(skolem2, s1)); + + Clause* eqAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::EQUALITY_PROXY_AXIOM)); + (*eqAxiom1)[0] = toEquality(AH::app2(AH::equality(s1), x, y), true); + (*eqAxiom1)[1] = Literal::createEquality(false,x,y,s1); + eqAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(eqAxiom1, prb.units()); + + Clause* eqAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::EQUALITY_PROXY_AXIOM)); + (*eqAxiom2)[0] = toEquality(AH::app2(AH::equality(s1), x, y), false); + (*eqAxiom2)[1] = Literal::createEquality(true,x,y,s1); + eqAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(eqAxiom2, prb.units()); + + Clause* notAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::NOT_PROXY_AXIOM)); + (*notAxiom1)[0] = toEquality(AH::app(AH::neg(), x), true); + (*notAxiom1)[1] = toEquality(x, true); + notAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(notAxiom1, prb.units()); + + Clause* notAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::NOT_PROXY_AXIOM)); + (*notAxiom2)[0] = toEquality(AH::app(AH::neg(), x), false); + (*notAxiom2)[1] = toEquality(x, false); + notAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(notAxiom2, prb.units()); + + Clause* piAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::PI_PROXY_AXIOM)); + (*piAxiom1)[0] = toEquality(AH::app(AH::pi(s1), x), true); + (*piAxiom1)[1] = toEquality(AH::app(s1, AtomicSort::boolSort(), x, AH::app(sk1, x)), false); + piAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(piAxiom1, prb.units()); + + Clause* piAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::PI_PROXY_AXIOM)); + (*piAxiom2)[0] = toEquality(AH::app(AH::pi(s1), x), false); + (*piAxiom2)[1] = toEquality(AH::app(s1, AtomicSort::boolSort(), x, y), true); + piAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(piAxiom2, prb.units()); + + Clause* sigmaAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::SIGMA_PROXY_AXIOM)); + (*sigmaAxiom1)[0] = toEquality(AH::app(AH::sigma(s1), x), true); + (*sigmaAxiom1)[1] = toEquality(AH::app(s1, AtomicSort::boolSort(), x, y), false); + sigmaAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(sigmaAxiom1, prb.units()); + + Clause* sigmaAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::SIGMA_PROXY_AXIOM)); + (*sigmaAxiom2)[0] = toEquality(AH::app(AH::sigma(s1), x), false); + (*sigmaAxiom2)[1] = toEquality(AH::app(s1, AtomicSort::boolSort(), x, AH::app(sk2, x)), true); + sigmaAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(sigmaAxiom2, prb.units()); + + Clause* impAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); + (*impAxiom1)[0] = toEquality(AH::app2(AH::imp(), x, y), true); + (*impAxiom1)[1] = toEquality(x, true); + impAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(impAxiom1, prb.units()); + + Clause* impAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); + (*impAxiom2)[0] = toEquality(AH::app2(AH::imp(), x, y), true); + (*impAxiom2)[1] = toEquality(y, false); + impAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(impAxiom2, prb.units()); + + Clause* impAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); + (*impAxiom3)[0] = toEquality(AH::app2(AH::imp(), x, y), false); + (*impAxiom3)[1] = toEquality(x, false); + (*impAxiom3)[2] = toEquality(y, true); + impAxiom3->inference().setProxyAxiomsDescendant(true); + UnitList::push(impAxiom3, prb.units()); + + Clause* andAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); + (*andAxiom1)[0] = toEquality(AH::app2(AH::conj(), x, y), false); + (*andAxiom1)[1] = toEquality(x, true); + andAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(andAxiom1, prb.units()); + + Clause* andAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); + (*andAxiom2)[0] = toEquality(AH::app2(AH::conj(), x, y), false); + (*andAxiom2)[1] = toEquality(y, true); + andAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(andAxiom2, prb.units()); + + Clause* andAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); + (*andAxiom3)[0] = toEquality(AH::app2(AH::conj(), x, y), true); + (*andAxiom3)[1] = toEquality(x, false); + (*andAxiom3)[2] = toEquality(y, false); + andAxiom3->inference().setProxyAxiomsDescendant(true); + UnitList::push(andAxiom3, prb.units()); + + Clause* orAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); + (*orAxiom1)[0] = toEquality(AH::app2(AH::disj(), x, y), true); + (*orAxiom1)[1] = toEquality(x, false); + orAxiom1->inference().setProxyAxiomsDescendant(true); + UnitList::push(orAxiom1, prb.units()); + + Clause* orAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); + (*orAxiom2)[0] = toEquality(AH::app2(AH::disj(), x, y), true); + (*orAxiom2)[1] = toEquality(y, false); + orAxiom2->inference().setProxyAxiomsDescendant(true); + UnitList::push(orAxiom2, prb.units()); + + Clause* orAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); + (*orAxiom3)[0] = toEquality(AH::app2(AH::disj(), x, y), false); + (*orAxiom3)[1] = toEquality(x, true); + (*orAxiom3)[2] = toEquality(y, true); + orAxiom3->inference().setProxyAxiomsDescendant(true); + UnitList::push(orAxiom3, prb.units()); + + + //TODO iff and xor + + if (env.options->showPreprocessing()) { + env.out() << "Added proxy axioms: " << std::endl; + env.out() << eqAxiom1->toString() << std::endl; + env.out() << eqAxiom2->toString() << std::endl; + env.out() << notAxiom1->toString() << std::endl; + env.out() << notAxiom2->toString() << std::endl; + env.out() << piAxiom1->toString() << std::endl; + env.out() << piAxiom2->toString() << std::endl; + env.out() << sigmaAxiom1->toString() << std::endl; + env.out() << sigmaAxiom2->toString() << std::endl; + env.out() << impAxiom1->toString() << std::endl; + env.out() << impAxiom2->toString() << std::endl; + env.out() << impAxiom3->toString() << std::endl; + env.out() << andAxiom1->toString() << std::endl; + env.out() << andAxiom2->toString() << std::endl; + env.out() << andAxiom3->toString() << std::endl; + env.out() << orAxiom1->toString() << std::endl; + env.out() << orAxiom2->toString() << std::endl; + env.out() << orAxiom3->toString() << std::endl; + } + +} + +Literal* LambdaConversion::toEquality(TermList booleanTerm, bool polarity) { + TermList boolVal = polarity ? TermList(Term::foolTrue()) : TermList(Term::foolFalse()); + return Literal::createEquality(true, booleanTerm, boolVal, AtomicSort::boolSort()); +} + +#endif diff --git a/Shell/LambdaConversion.hpp b/Shell/LambdaConversion.hpp new file mode 100644 index 0000000000..93eff92cb7 --- /dev/null +++ b/Shell/LambdaConversion.hpp @@ -0,0 +1,63 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/** + * @file LambdaElimination.hpp + * Defines class LambdaElimination. + */ + +#ifndef __LambdaConversion__ +#define __LambdaConversion__ + +#if VHOL + +#include "Lib/Deque.hpp" +#include "Forwards.hpp" + +using namespace Kernel; +using namespace Shell; + +/** + * A class that converts lamba terms from named to nameless (De Bruijn indices) representation. + * + * Along the way, it also converts formulas to terms with proxy symbols for connectives + */ +class LambdaConversion { +public: + + typedef pair IndexSortPair; + typedef DHMap VarToIndexMap; + + LambdaConversion() {}; +// LambdaElimination(DHMap varSorts) : _varSorts(varSorts){}; + + TermList convertLambda(Term* lambdaTerm); + TermList convertLambda(TermList term); + TermList convertLambda(Formula*); + + //void addFunctionExtensionalityAxioms(UnitList*& units); + //void addBooleanExtensionalityAxiom(UnitList*& units); + + static void addProxyAxioms(Problem& prb); + static void addFunctionExtensionalityAxiom(Problem& prb); + static void addChoiceAxiom(Problem& prb); + static Literal* toEquality(TermList booleanTerm, bool polarity); + +private: + + TermList convertLambda(TermList term, VarToIndexMap& map); + TermList convertLambda(VList* vars, SList* sorts, TermList body, TermList bodySort, VarToIndexMap& map); + TermList convertLambda(Formula*, VarToIndexMap& map); + + TermList sortOf(TermList t); +}; + +#endif + +#endif // __LambdaConversion__ diff --git a/Shell/LambdaElimination.cpp b/Shell/LambdaElimination.cpp deleted file mode 100644 index a1c6dce644..0000000000 --- a/Shell/LambdaElimination.cpp +++ /dev/null @@ -1,724 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file LambdaElimination.cpp - * Takes a single lambda term and eliminates the lambda(s) - * from the term by translating to combinatory logic. - * A term of the form ^[X, Y, Z]:exp is interpreted as: - * ^[X]:(^[Y]:(^[Z]:exp)). I.e. as three lambdas in a single term. - */ - - -#include "Indexing/TermSharing.hpp" - -#include "Lib/Environment.hpp" -#include "Lib/Deque.hpp" -#include "Lib/Sort.hpp" - -#include "Kernel/Clause.hpp" -#include "Kernel/FormulaUnit.hpp" -#include "Kernel/Inference.hpp" -#include "Kernel/Problem.hpp" -#include "Kernel/Formula.hpp" -#include "Kernel/Signature.hpp" -#include "Kernel/SortHelper.hpp" -#include "Kernel/ApplicativeHelper.hpp" -#include "Kernel/SKIKBO.hpp" -#include "Kernel/TermIterators.hpp" - -#include "Skolem.hpp" -#include "Options.hpp" -//#include "Shell/SymbolOccurrenceReplacement.hpp" - - -#include "LambdaElimination.hpp" - -using namespace Lib; -using namespace Kernel; -using namespace Shell; - -typedef ApplicativeHelper AH; - - -/** - * Return true if t1 is less than t2 in some arbitrary - * total ordering. - * - * Is used just for normalization of commutative term and - * literal arguments. - */ -bool LambdaElimination::TermListComparator::lessThan(TermList t1, TermList t2) -{ - CALL("TermListComparator::lessThan"); - - if(t1.tag()!=t2.tag()) { - return t1.tag() < t2.tag(); - } - if(!t2.isTerm()) { - return t2.content() > t1.content(); - } - Term* trm1=t1.term(); - Term* trm2=t2.term(); - if(trm1->functor()!=trm2->functor()) { - return trm1->functor()functor(); - } - if(trm1->weight()!=trm2->weight()) { - return trm1->weight()weight(); - } - if(trm1->numVarOccs()!=trm2->numVarOccs()) { - return trm1->numVarOccs()numVarOccs(); - } - - //To avoid non-determinism, now we'll compare the terms lexicographicaly. - static DisagreementSetIterator dsit; - dsit.reset(trm1, trm2, false); - - if(!dsit.hasNext()) { - ASS_EQ(trm1,trm2); - return false; - } - - pair diff=dsit.next(); - TermList st1=diff.first; - TermList st2=diff.second; - if(st1.isTerm()) { - if(st2.isTerm()) { - unsigned f1=st1.term()->functor(); - unsigned f2=st2.term()->functor(); - ASS_NEQ(f1,f2); - return f1connective(); - - switch(conn){ - case LITERAL: { - Literal* lit = formula->literal(); - ASS(lit->isEquality()); //Is this a valid assumption? - - TermList lhs = *lit->nthArgument(0); - TermList rhs = *lit->nthArgument(1); - - if (lhs.isTerm()) { lhs = elimLambda(lhs); } - if (rhs.isTerm()) { rhs = elimLambda(rhs); } - - TermList equalsSort = SortHelper::getEqualityArgumentSort(lit); - - unsigned eqProxy = env.signature->getEqualityProxy(); - constant = TermList(Term::create1(eqProxy, equalsSort)); - appTerm = AH::createAppTerm3(sortOf(constant), constant, lhs, rhs); - - if(!lit->polarity()){ - constant = TermList(Term::createConstant(env.signature->getNotProxy())); - appTerm = AH::createAppTerm(sortOf(constant), constant, appTerm); - } - return appTerm; - } - case IFF: - case IMP: - case XOR:{ - Formula* lhs = formula->left(); - Formula* rhs = formula->right(); - - vstring name = (conn == IFF ? "vIFF" : (conn == IMP ? "vIMP" : "vXOR")); - constant = TermList(Term::createConstant(env.signature->getBinaryProxy(name))); - - TermList form1 = elimLambda(lhs); - TermList form2 = elimLambda(rhs); - - /*TermListComparator tlc; - if((conn == IFF || conn == XOR) && tlc.lessThan(form2, form1)){ - TermList temp = form1; - form1 = form2; - form2 = temp; - }*/ - - return AH::createAppTerm3(sortOf(constant), constant, form1, form2);; - } - case AND: - case OR:{ - FormulaList::Iterator argsIt(formula->args()); - - vstring name = (conn == AND ? "vAND" : "vOR"); - constant = TermList(Term::createConstant(env.signature->getBinaryProxy(name))); - - /*TermListComparator tlc; - unsigned length = FormulaList::length(formula->args()); - Sort srt(length, tlc); - while(argsIt.hasNext()){ - srt.add(processBeyondLambda(argsIt.next())); - } - srt.sort(); - - appTerm = AH::createAppTerm3(sortOf(constant), constant, srt[0], srt[1]); - for(unsigned i = 2; i < length; i++){ - appTerm = AH::createAppTerm3(sortOf(constant), constant, appTerm, srt[i]); - }*/ - TermList form; - unsigned count = 1; - while(argsIt.hasNext()){ - Formula* arg = argsIt.next(); - form = elimLambda(arg); - if(count == 1){ - appTerm = AH::createAppTerm(sortOf(constant), constant, form); - }else if(count == 2){ - appTerm = AH::createAppTerm(sortOf(appTerm), appTerm, form); - }else{ - appTerm = AH::createAppTerm3(sortOf(constant), constant, appTerm, form); - } - count++; - } - return appTerm; - } - case NOT: { - constant = TermList(Term::createConstant(env.signature->getNotProxy())); - TermList form = elimLambda(formula->uarg()); - return AH::createAppTerm(sortOf(constant), constant, form); - } - case FORALL: - case EXISTS: { - VList* vars = formula->vars(); - VList::Iterator vit(vars); - SList* sort = SList::singleton(TermList(0, true)); //dummy data - VList* var = VList::singleton(0); - - TermList form = elimLambda(formula->qarg()); - vstring name = (conn == FORALL ? "vPI" : "vSIGMA"); - unsigned proxy = env.signature->getPiSigmaProxy(name); - - TermList s; - while(vit.hasNext()){ - int v = vit.next(); - ALWAYS(SortHelper::tryGetVariableSort(v, formula->qarg(), s)); - var->setHead(v); - sort->setHead(s); - form = elimLambda(Term::createLambda(form, var, sort, AtomicSort::boolSort())); - constant = TermList(Term::create1(proxy, s)); - form = AH::createAppTerm(sortOf(constant), constant, form); - } - return form; - } - case BOOL_TERM: - return elimLambda(formula->getBooleanTerm()); - case TRUE: - return TermList(Term::foolTrue()); - case FALSE: - return TermList(Term::foolFalse()); - default: - ASSERTION_VIOLATION; - - }//switch conn -} - -TermList LambdaElimination::elimLambda(TermList term) -{ - CALL("LambdaElimination::elimLambda(TermList)"); - - if(term.isVar()){ - return term; - } - - Term* t = term.term(); - if(t->isSpecial()){ - switch(t->functor()){ - case Term::SF_FORMULA: - return elimLambda(t->getSpecialData()->getFormula()); - - case Term::SF_LAMBDA:{ - Stack vars; - TermStack sorts; - Term::SpecialTermData* sd = t->getSpecialData(); - SList* srts = sd->getLambdaVarSorts(); - VList* vrs = sd->getLambdaVars(); - - VList::Iterator vlit(vrs); - SList::Iterator slit(srts); - - while(vlit.hasNext()){ - vars.push(vlit.next()); - sorts.push(slit.next()); - } - TermList eliminated = elimLambda(vars, sorts, sd->getLambdaExp(), sd->getLambdaExpSort()); - ASS_REP2(eliminated.isVar() || sortOf(eliminated) == sd->getSort(), t->toString(), eliminated.toString()) - return eliminated; - } - - default: - ASSERTION_VIOLATION; - } - } - - if(!t->isApplication()){ - return term; - } - - //must be of the form app(s1, s2, arg1, arg2) - TermList s1 = *t->nthArgument(0); - TermList s2 = *t->nthArgument(1); - TermList arg1 = *t->nthArgument(2); - TermList arg2 = *t->nthArgument(3); - - return AH::createAppTerm(s1, s2, elimLambda(arg1), elimLambda(arg2)); -} - - -TermList LambdaElimination::elimLambda(Stack& vars, TermStack& sorts, - TermList body, TermList sort) -{ - CALL("LambdaElimination::elimLambda(Stack& vars...)"); - - TermList bodye = elimLambda(body); - // Lambda elimination should not change the sort - // of a term - ASS(bodye.isVar() || sortOf(bodye) == sort); - - while(vars.size()){ - int v = vars.pop(); - TermList s = sorts.pop(); - bodye = elimLambda(v, s, bodye, sort); - sort = AtomicSort::arrowSort(s, sort); - } - - return bodye; -} - - -TermList LambdaElimination::elimLambda(int var, TermList varSort, - TermList body, TermList sort) -{ - CALL("LambdaElimination::elimLambda(int var...)"); - - if(!body.isFreeVariable(var)){ - return createKTerm(sort, varSort, body); - } - - if(body.isVar()){ - ASS(body.var() == (unsigned)var); - return TermList(Term::create1(env.signature->getCombinator(Signature::I_COMB), varSort)); - } - - Term* t = body.term(); - // Specials should already have been removed via earlier - // recursive calls - ASS_REP(!t->isSpecial(), t->toString()); - - //must be of the form app(s1, s2, arg1, arg2) - TermList s1 = *t->nthArgument(0); - TermList s2 = *t->nthArgument(1); - TermList arg1 = *t->nthArgument(2); - TermList arg2 = *t->nthArgument(3); - TermList a1sort = AtomicSort::arrowSort(s1, s2); - TermList a2sort = s1; - - bool freeInArg1 = arg1.isFreeVariable(var); - bool freeInArg2 = arg2.isFreeVariable(var); - - if(arg2.isVar() && (arg2.var() == (unsigned)var) && !freeInArg1){ - //This is the case [\x. exp @ x] wehere x is not free in exp. - return arg1; - } - - if (freeInArg1 && freeInArg2){ - TermList arg1e = elimLambda(var, varSort, arg1, a1sort); - TermList s1e = AtomicSort::arrowSort(varSort, a1sort); - TermList arg2e = elimLambda(var, varSort, arg2, a2sort); - TermList s2e = AtomicSort::arrowSort(varSort, a2sort); - return createSCorBTerm(arg1e, s1e, arg2e, s2e, Signature::S_COMB); - } else if (freeInArg1) { - TermList arg1e = elimLambda(var, varSort, arg1, a1sort); - TermList s1e = AtomicSort::arrowSort(varSort, a1sort); - return createSCorBTerm(arg1e, s1e, arg2, a2sort, Signature::C_COMB); - } else{ - ASS(freeInArg2); - TermList arg2e = elimLambda(var, varSort, arg2, a2sort); - TermList s2e = AtomicSort::arrowSort(varSort, a2sort); - return createSCorBTerm(arg1, a1sort, arg2e, s2e, Signature::B_COMB); - } -} - -TermList LambdaElimination::elimLambda(Term* lambdaTerm) -{ - CALL("LambdaElimination::elimLambda"); - - return elimLambda(TermList(lambdaTerm)); -} - -TermList LambdaElimination::createKTerm(TermList s1, TermList s2, TermList arg1) -{ - CALL("LambdaElimination::createKTerm"); - - unsigned kcomb = env.signature->getCombinator(Signature::K_COMB); - TermList res = TermList(Term::create2(kcomb, s1, s2)); - return AH::createAppTerm(sortOf(res), res, arg1); -} - -TermList LambdaElimination::createSCorBTerm(TermList arg1, TermList arg1sort, - TermList arg2, TermList arg2sort, Signature::Combinator comb) -{ - CALL("LambdaElimination::createSCorBTerm"); - - TermList s1, s2, s3; - unsigned cb = env.signature->getCombinator(comb); - - if(comb == Signature::S_COMB || comb == Signature::C_COMB){ - s1 = AH::getNthArg(arg1sort, 1); - s2 = AH::getNthArg(arg1sort, 2); - s3 = AH::getResultApplieadToNArgs(arg1sort, 2); - } else { - s1 = AH::getNthArg(arg2sort, 1); - s2 = AH::getNthArg(arg1sort, 1); - s3 = AH::getResultApplieadToNArgs(arg1sort, 1); - } - - TermList args[] = {s1, s2, s3}; - TermList c = TermList(Term::create(cb, 3, args)); - return AH::createAppTerm3(sortOf(c), c, arg1, arg2); -} - -TermList LambdaElimination::sortOf(TermList t) -{ - CALL("LambdaElimination::sortOf"); - - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); -} - -void LambdaElimination::addCombinatorAxioms(Problem& prb) -{ - CALL("LambdaElimination::addCombinatorAxioms"); - - auto srtOf = [] (TermList t) { - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); - }; - - TermList s1 = TermList(0, false); - TermList s2 = TermList(1, false); - TermList s3 = TermList(2, false); - TermList x = TermList(3, false); - TermList y = TermList(4, false); - TermList z = TermList(5, false); - TermList args[] = {s1, s2, s3}; - - unsigned s_comb = env.signature->getCombinator(Signature::S_COMB); - TermList constant = TermList(Term::create(s_comb, 3, args)); - TermList lhs = AH::createAppTerm(srtOf(constant), constant, x, y, z); //TODO fix - TermList rhs = AH::createAppTerm3(AtomicSort::arrowSort(s1, s2, s3), x, z, AH::createAppTerm(AtomicSort::arrowSort(s1, s2), y, z)); - - Clause* sAxiom = new(1) Clause(1, TheoryAxiom(InferenceRule::COMBINATOR_AXIOM)); - (*sAxiom)[0] = Literal::createEquality(true, lhs, rhs, s3); - sAxiom->inference().setCombAxiomsDescendant(true); - UnitList::push(sAxiom, prb.units()); - - unsigned c_comb = env.signature->getCombinator(Signature::C_COMB); - constant = TermList(Term::create(c_comb, 3, args)); - lhs = AH::createAppTerm(srtOf(constant), constant, x, y, z); //TODO fix - rhs = AH::createAppTerm3(AtomicSort::arrowSort(s1, s2, s3), x, z, y); - - Clause* cAxiom = new(1) Clause(1, TheoryAxiom(InferenceRule::COMBINATOR_AXIOM)); - (*cAxiom)[0] = Literal::createEquality(true, lhs, rhs, s3); - cAxiom->inference().setCombAxiomsDescendant(true); - UnitList::push(cAxiom, prb.units()); - - unsigned b_comb = env.signature->getCombinator(Signature::B_COMB); - constant = TermList(Term::create(b_comb, 3, args)); - lhs = AH::createAppTerm(srtOf(constant), constant, x, y, z); //TODO fix - rhs = AH::createAppTerm(AtomicSort::arrowSort(s2, s3), x, AH::createAppTerm(AtomicSort::arrowSort(s1, s2), y, z)); - - Clause* bAxiom = new(1) Clause(1, TheoryAxiom(InferenceRule::COMBINATOR_AXIOM)); - (*bAxiom)[0] = Literal::createEquality(true, lhs, rhs, s3); - bAxiom->inference().setCombAxiomsDescendant(true); - UnitList::push(bAxiom, prb.units()); - - unsigned k_comb = env.signature->getCombinator(Signature::K_COMB); - constant = TermList(Term::create2(k_comb, s1, s2)); - lhs = AH::createAppTerm3(srtOf(constant), constant, x, y); - - Clause* kAxiom = new(1) Clause(1, TheoryAxiom(InferenceRule::COMBINATOR_AXIOM)); - (*kAxiom)[0] = Literal::createEquality(true, lhs, x, s1); - bAxiom->inference().setCombAxiomsDescendant(true); - UnitList::push(kAxiom, prb.units()); - - unsigned i_comb = env.signature->getCombinator(Signature::I_COMB); - constant = TermList(Term::create1(i_comb, s1)); - lhs = AH::createAppTerm(srtOf(constant), constant, x); - - Clause* iAxiom = new(1) Clause(1, TheoryAxiom(InferenceRule::COMBINATOR_AXIOM)); - (*iAxiom)[0] = Literal::createEquality(true, lhs, x, s1); - iAxiom->inference().setCombAxiomsDescendant(true); - UnitList::push(iAxiom, prb.units()); - - if (env.options->showPreprocessing()) { - env.out() << "Added combinator axioms: " << std::endl; - env.out() << sAxiom->toString() << std::endl; - env.out() << cAxiom->toString() << std::endl; - env.out() << bAxiom->toString() << std::endl; - env.out() << kAxiom->toString() << std::endl; - env.out() << iAxiom->toString() << std::endl; - } -} - - -void LambdaElimination::addFunctionExtensionalityAxiom(Problem& prb) -{ - CALL("LambdaElimination::addFunctionExtensionalityAxiom"); - - auto srtOf = [] (TermList t) { - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); - }; - - TermList alpha = TermList(0, false); - TermList beta = TermList(1, false); - TermList x = TermList(2, false); - TermList y = TermList(3, false); - unsigned diff = env.signature->getDiff(); - - TermList diffT = TermList(Term::create2(diff, alpha, beta)); - TermList diffTApplied = AH::createAppTerm3(srtOf(diffT), diffT, x, y); - TermList lhs = AH::createAppTerm(alpha, beta, x, diffTApplied); - TermList rhs = AH::createAppTerm(alpha, beta, y, diffTApplied); - - Clause* funcExtAx = new(2) Clause(2, NonspecificInference0(UnitInputType::AXIOM,InferenceRule::FUNC_EXT_AXIOM)); - (*funcExtAx)[0] = Literal::createEquality(false, lhs, rhs, beta); - (*funcExtAx)[1] = Literal::createEquality(true, x, y, AtomicSort::arrowSort(alpha, beta)); - UnitList::push(funcExtAx, prb.units()); - - - if (env.options->showPreprocessing()) { - env.out() << "Added functional extensionality axiom: " << std::endl; - env.out() << funcExtAx->toString() << std::endl; - } -} - -void LambdaElimination::addChoiceAxiom(Problem& prb) -{ - CALL("LambdaElimination::addChoiceAxiom"); - - TermList alpha = TermList(0, false); - TermList boolS = AtomicSort::boolSort(); - TermList alphaBool = AtomicSort::arrowSort(alpha, AtomicSort::boolSort()); - TermList p = TermList(1, false); - TermList x = TermList(2, false); - unsigned choice = env.signature->getChoice(); - - TermList choiceT = TermList(Term::create1(choice, alpha)); - TermList choiceTApplied = AH::createAppTerm(alphaBool, alpha, choiceT, p); - TermList px = AH::createAppTerm(alpha, boolS, p, x); - TermList pchoiceT = AH::createAppTerm(alpha, boolS, p, choiceTApplied); - - Clause* choiceAx = new(2) Clause(2, NonspecificInference0(UnitInputType::AXIOM,InferenceRule::CHOICE_AXIOM)); - (*choiceAx)[0] = Literal::createEquality(true, px, TermList(Term::foolFalse()), boolS); - (*choiceAx)[1] = Literal::createEquality(true, pchoiceT, TermList(Term::foolTrue()), boolS); - UnitList::push(choiceAx, prb.units()); - - - if (env.options->showPreprocessing()) { - env.out() << "Added Hilbert choice axiom: " << std::endl; - env.out() << choiceAx->toString() << std::endl; - } -} - -void LambdaElimination::addProxyAxioms(Problem& prb) -{ - CALL("LambdaElimination::addProxyAxioms"); - - auto srtOf = [] (TermList t) { - ASS(t.isTerm()); - return SortHelper::getResultSort(t.term()); - }; - - TermList s1 = TermList(0, false); - TermList x = TermList(1, false); - TermList y = TermList(2, false); - - TermList choiceSort = AtomicSort::arrowSort(AtomicSort::arrowSort(s1, AtomicSort::boolSort()), s1); - unsigned skolem1 = Skolem::addSkolemFunction(1,1,0, choiceSort); - unsigned skolem2 = Skolem::addSkolemFunction(1,1,0, choiceSort); - TermList sk1 = TermList(Term::create1(skolem1, s1)); - TermList sk2 = TermList(Term::create1(skolem2, s1)); - - unsigned eqProxy = env.signature->getEqualityProxy(); - TermList constant = TermList(Term::create1(eqProxy, s1)); - - Clause* eqAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::EQUALITY_PROXY_AXIOM)); - (*eqAxiom1)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*eqAxiom1)[1] = Literal::createEquality(false,x,y,s1); - eqAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(eqAxiom1, prb.units()); - - Clause* eqAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::EQUALITY_PROXY_AXIOM)); - (*eqAxiom2)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), false); - (*eqAxiom2)[1] = Literal::createEquality(true,x,y,s1); - eqAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(eqAxiom2, prb.units()); - - unsigned notProxy = env.signature->getNotProxy(); - constant = TermList(Term::createConstant(notProxy)); - - Clause* notAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::NOT_PROXY_AXIOM)); - (*notAxiom1)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), true); - (*notAxiom1)[1] = toEquality(x, true); - notAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(notAxiom1, prb.units()); - - Clause* notAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::NOT_PROXY_AXIOM)); - (*notAxiom2)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), false); - (*notAxiom2)[1] = toEquality(x, false); - notAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(notAxiom2, prb.units()); - - unsigned piProxy = env.signature->getPiSigmaProxy("vPI"); - constant = TermList(Term::create1(piProxy, s1)); - - Clause* piAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::PI_PROXY_AXIOM)); - (*piAxiom1)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), true); - (*piAxiom1)[1] = toEquality(AH::createAppTerm(s1, AtomicSort::boolSort(), x, AH::createAppTerm(srtOf(sk1), sk1, x)), false); - piAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(piAxiom1, prb.units()); - - Clause* piAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::PI_PROXY_AXIOM)); - (*piAxiom2)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), false); - (*piAxiom2)[1] = toEquality(AH::createAppTerm(s1, AtomicSort::boolSort(), x, y), true); - piAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(piAxiom2, prb.units()); - - unsigned sigmaProxy = env.signature->getPiSigmaProxy("vSIGMA"); - constant = TermList(Term::create1(sigmaProxy, s1)); - - Clause* sigmaAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::SIGMA_PROXY_AXIOM)); - (*sigmaAxiom1)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), true); - (*sigmaAxiom1)[1] = toEquality(AH::createAppTerm(s1, AtomicSort::boolSort(), x, y), false); - sigmaAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(sigmaAxiom1, prb.units()); - - Clause* sigmaAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::SIGMA_PROXY_AXIOM)); - (*sigmaAxiom2)[0] = toEquality(AH::createAppTerm(srtOf(constant), constant, x), false); - (*sigmaAxiom2)[1] = toEquality(AH::createAppTerm(s1, AtomicSort::boolSort(), x, AH::createAppTerm(srtOf(sk2), sk2, x)), true); - sigmaAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(sigmaAxiom2, prb.units()); - - unsigned impProxy = env.signature->getBinaryProxy("vIMP"); - constant = TermList(Term::createConstant(impProxy)); - - Clause* impAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); - (*impAxiom1)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*impAxiom1)[1] = toEquality(x, true); - impAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(impAxiom1, prb.units()); - - Clause* impAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); - (*impAxiom2)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*impAxiom2)[1] = toEquality(y, false); - impAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(impAxiom2, prb.units()); - - Clause* impAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::IMPLIES_PROXY_AXIOM)); - (*impAxiom3)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), false); - (*impAxiom3)[1] = toEquality(x, false); - (*impAxiom3)[2] = toEquality(y, true); - impAxiom3->inference().setProxyAxiomsDescendant(true); - UnitList::push(impAxiom3, prb.units()); - - unsigned andProxy = env.signature->getBinaryProxy("vAND"); - constant = TermList(Term::createConstant(andProxy)); - - Clause* andAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); - (*andAxiom1)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), false); - (*andAxiom1)[1] = toEquality(x, true); - andAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(andAxiom1, prb.units()); - - Clause* andAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); - (*andAxiom2)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), false); - (*andAxiom2)[1] = toEquality(y, true); - andAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(andAxiom2, prb.units()); - - Clause* andAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::AND_PROXY_AXIOM)); - (*andAxiom3)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*andAxiom3)[1] = toEquality(x, false); - (*andAxiom3)[2] = toEquality(y, false); - andAxiom3->inference().setProxyAxiomsDescendant(true); - UnitList::push(andAxiom3, prb.units()); - - unsigned orProxy = env.signature->getBinaryProxy("vOR"); - constant = TermList(Term::createConstant(orProxy)); - - Clause* orAxiom1 = new(2) Clause(2, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); - (*orAxiom1)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*orAxiom1)[1] = toEquality(x, false); - orAxiom1->inference().setProxyAxiomsDescendant(true); - UnitList::push(orAxiom1, prb.units()); - - Clause* orAxiom2 = new(2) Clause(2, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); - (*orAxiom2)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), true); - (*orAxiom2)[1] = toEquality(y, false); - orAxiom2->inference().setProxyAxiomsDescendant(true); - UnitList::push(orAxiom2, prb.units()); - - Clause* orAxiom3 = new(3) Clause(3, TheoryAxiom(InferenceRule::OR_PROXY_AXIOM)); - (*orAxiom3)[0] = toEquality(AH::createAppTerm3(srtOf(constant), constant, x, y), false); - (*orAxiom3)[1] = toEquality(x, true); - (*orAxiom3)[2] = toEquality(y, true); - orAxiom3->inference().setProxyAxiomsDescendant(true); - UnitList::push(orAxiom3, prb.units()); - - - //TODO iff and xor - - if (env.options->showPreprocessing()) { - env.out() << "Added proxy axioms: " << std::endl; - env.out() << eqAxiom1->toString() << std::endl; - env.out() << eqAxiom2->toString() << std::endl; - env.out() << notAxiom1->toString() << std::endl; - env.out() << notAxiom2->toString() << std::endl; - env.out() << piAxiom1->toString() << std::endl; - env.out() << piAxiom2->toString() << std::endl; - env.out() << sigmaAxiom1->toString() << std::endl; - env.out() << sigmaAxiom2->toString() << std::endl; - env.out() << impAxiom1->toString() << std::endl; - env.out() << impAxiom2->toString() << std::endl; - env.out() << impAxiom3->toString() << std::endl; - env.out() << andAxiom1->toString() << std::endl; - env.out() << andAxiom2->toString() << std::endl; - env.out() << andAxiom3->toString() << std::endl; - env.out() << orAxiom1->toString() << std::endl; - env.out() << orAxiom2->toString() << std::endl; - env.out() << orAxiom3->toString() << std::endl; - } - -} - -Literal* LambdaElimination::toEquality(TermList booleanTerm, bool polarity) { - TermList boolVal = polarity ? TermList(Term::foolTrue()) : TermList(Term::foolFalse()); - return Literal::createEquality(true, booleanTerm, boolVal, AtomicSort::boolSort()); -} diff --git a/Shell/LambdaElimination.hpp b/Shell/LambdaElimination.hpp deleted file mode 100644 index f1a8e9c4ac..0000000000 --- a/Shell/LambdaElimination.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ -/** - * @file LambdaElimination.hpp - * Defines class LambdaElimination. - */ - -#ifndef __LambdaElimination__ -#define __LambdaElimination__ - -#include "Lib/Deque.hpp" -#include "Forwards.hpp" - -using namespace Kernel; -using namespace Shell; - -/** - * A class with function @b elimLambda() that eliminates a lambda expressions - * It does this by applying the well known rewrite rules for SKIBC combinators. - * - * These can be found: - * https://en.wikipedia.org/wiki/Combinatory_logic - */ -class LambdaElimination { -public: - - LambdaElimination() {}; -// LambdaElimination(DHMap varSorts) : _varSorts(varSorts){}; - - /** Set of recursive functions that rconvert lambda terms to - * combinatory terms and replace logical symbols by proxies. - * It can be used as an alternative to FOOLElimination - */ - TermList elimLambda(Term* lambdaTerm); - TermList elimLambda(TermList term); - TermList elimLambda(Stack& vars, TermStack& sorts, TermList body, TermList sort); - TermList elimLambda(int var, TermList varSort, TermList body, TermList sort); - TermList elimLambda(Formula*); - - //void addFunctionExtensionalityAxioms(UnitList*& units); - //void addBooleanExtensionalityAxiom(UnitList*& units); - - static void addCombinatorAxioms(Problem& prb); - static void addProxyAxioms(Problem& prb); - static void addFunctionExtensionalityAxiom(Problem& prb); - static void addChoiceAxiom(Problem& prb); - static Literal* toEquality(TermList booleanTerm, bool polarity); - - class TermListComparator { - public: - bool lessThan(TermList t1, TermList t2); - }; - -private: - - /********************************************* - * Lambda and application elimination functions - *********************************************/ - - TermList sortOf(TermList t); - - void addToProcessed(TermList ts, TermList sort, Stack &_argNums); - void dealWithApp(Term* app, const unsigned lambdaVar, - TermStack &toBeProcessed, TermStack &sorts, Stack &argNums); - - TermList createKTerm(TermList s1, TermList s2, TermList arg1); - TermList createSCorBTerm(TermList arg1, TermList arg1sort, - TermList arg2, TermList arg2sort, Signature::Combinator comb); - - void process(Stack &vars, TermStack &varSorts, - TermStack &toBeProcessed, TermStack &sorts); - - /** Lexical scope of the current unit */ - TermStack _processed; - TermStack _processedSorts; - Stack _combinators; -}; - -#endif // __LambdaElimination__ diff --git a/Shell/NameReuse.cpp b/Shell/NameReuse.cpp index b969a5f048..1f1ee3e412 100644 --- a/Shell/NameReuse.cpp +++ b/Shell/NameReuse.cpp @@ -40,7 +40,7 @@ void NameReuse::key(vstringstream &buf, TermList ts) CALL("NameReuse::key(vstringstream &, TermList)"); if(ts.isVar()) // need to rename variables occuring in terms, sorts - buf << 'x' << _renaming.getOrBind(ts.var()); + buf << 'x' << _renaming.getOrBind(ts.var(), ts.bank()); else // all functors realised as fN, where N is the functor's index // sorts are known to be sorts from their context, so this is OK @@ -124,7 +124,7 @@ vstring NameReuse::key(Formula *f) // unless they're not used, but in that case it's OK anyway VList::Iterator vars(subformula->vars()); while(vars.hasNext()) - buf << 'x' << _renaming.getOrBind(vars.next()); + buf << 'x' << _renaming.getOrBind(vars.next(), DEFAULT_BANK); break; } case BOOL_TERM: diff --git a/Shell/Naming.cpp b/Shell/Naming.cpp index 524e52afac..23303f3a6d 100644 --- a/Shell/Naming.cpp +++ b/Shell/Naming.cpp @@ -28,7 +28,9 @@ #include "Kernel/SortHelper.hpp" #include "Kernel/SubformulaIterator.hpp" #include "Kernel/Term.hpp" +#if VHOL #include "Kernel/ApplicativeHelper.hpp" +#endif #include "Shell/Statistics.hpp" #include "Shell/Options.hpp" @@ -52,7 +54,10 @@ using namespace Shell; */ Naming::Naming(int threshold, bool preserveEpr, bool appify) : _threshold(threshold + 1), _preserveEpr(preserveEpr), - _appify(appify), _varsInScope(false) { +#if VHOL + _appify(appify), +#endif + _varsInScope(false) { ASS(threshold < 32768); } // Naming::Naming @@ -1160,11 +1165,17 @@ Literal* Naming::getDefinitionLiteral(Formula* f, VList* freeVars) { SortHelper::normaliseArgSorts(typeVars, termVarSorts); - for(unsigned i = 0; i < termVars.size() && !_appify; i++){ + for(unsigned i = 0; i < termVars.size() +#if VHOL + && !_appify +#endif + ; i++){ allVars.push(termVars[i]); } +#if VHOL if(!_appify){ +#endif unsigned pred = reused_symbol; if(!successfully_reused) { pred = env.signature->addNamePredicate(arity); @@ -1186,6 +1197,7 @@ Literal* Naming::getDefinitionLiteral(Formula* f, VList* freeVars) { predSym->setType(OperatorType::getPredicateType(arity - typeArgArity, termVarSorts.begin(), typeArgArity)); } return Literal::create(pred, arity, true, false, allVars.begin()); +#if VHOL } else { unsigned fun = reused_symbol; if(!successfully_reused) { @@ -1197,10 +1209,10 @@ Literal* Naming::getDefinitionLiteral(Formula* f, VList* freeVars) { name_reuse->put(reuse_key, fun); } TermList head = TermList(Term::create(fun, typeVars.size(), typeVars.begin())); - TermList t = ApplicativeHelper::createAppTerm( - SortHelper::getResultSort(head.term()), head, termVars); + TermList t = ApplicativeHelper::app(head, termVars); return Literal::createEquality(true, TermList(t), TermList(Term::foolTrue()), AtomicSort::boolSort()); } +#endif } /** @@ -1263,7 +1275,7 @@ Formula* Naming::introduceDefinition(Formula* f, bool iff) { } Unit* definition = new FormulaUnit(def, NonspecificInference0(UnitInputType::AXIOM,InferenceRule::PREDICATE_DEFINITION)); - InferenceStore::instance()->recordIntroducedSymbol(definition, false, + InferenceStore::instance()->recordIntroducedSymbol(definition, SymbolType::PRED, atom->functor()); UnitList::push(definition, _defs); diff --git a/Shell/Naming.hpp b/Shell/Naming.hpp index f7efeafa20..53bea6bcdb 100644 --- a/Shell/Naming.hpp +++ b/Shell/Naming.hpp @@ -32,7 +32,7 @@ namespace Shell { class Naming { public: - Naming (int threshold, bool preserveEpr, bool appify); + Naming (int threshold, bool preserveEpr, bool appify = false); FormulaUnit* apply(FormulaUnit* unit,UnitList*& defs); private: /** Encodes information about the position of the sub formula */ @@ -126,7 +126,9 @@ class Naming * Corresponds to the value of the epr_preserving_naming option. */ bool _preserveEpr; +#if VHOL bool _appify; // higher-order stuff +#endif /** * True if there are universally quantified variables at the scope of the current formula * diff --git a/Shell/NewCNF.cpp b/Shell/NewCNF.cpp index 209c02e951..b00222e2b8 100644 --- a/Shell/NewCNF.cpp +++ b/Shell/NewCNF.cpp @@ -32,6 +32,7 @@ #include "Shell/SymbolOccurrenceReplacement.hpp" #include "Shell/SymbolDefinitionInlining.hpp" #include "Shell/Statistics.hpp" +#include "Shell/FOOLElimination.hpp" #include "NewCNF.hpp" @@ -1244,7 +1245,7 @@ void NewCNF::process(QuantifiedFormula* g, Occurrences &occurrences) void NewCNF::processBoolterm(TermList ts, Occurrences &occurrences) { - CALL("NewCNF::process(TermList)"); + CALL("NewCNF::processBoolterm"); if (ts.isVar()) { processBoolVar(POSITIVE, ts.var(), occurrences); @@ -1252,35 +1253,38 @@ void NewCNF::processBoolterm(TermList ts, Occurrences &occurrences) } Term* term = ts.term(); - ASS_REP(term->isSpecial(), term->toString()); + //ASS_REP(term->isSpecial(), term->toString()); + + if(term->isSpecial()){ + Term::SpecialTermData* sd = term->getSpecialData(); + switch (sd->getType()) { + case Term::SF_FORMULA: + process(sd->getFormula(), occurrences); + break; - Term::SpecialTermData* sd = term->getSpecialData(); - switch (sd->getType()) { - case Term::SF_FORMULA: - process(sd->getFormula(), occurrences); - break; + case Term::SF_ITE: { + Formula* condition = sd->getCondition(); - case Term::SF_ITE: { - Formula* condition = sd->getCondition(); + Formula* left = BoolTermFormula::create(*term->nthArgument(LEFT)); + Formula* right = BoolTermFormula::create(*term->nthArgument(RIGHT)); + processITE(condition, left, right, occurrences); + break; + } - Formula* left = BoolTermFormula::create(*term->nthArgument(LEFT)); - Formula* right = BoolTermFormula::create(*term->nthArgument(RIGHT)); - processITE(condition, left, right, occurrences); - break; - } + case Term::SF_LET: + case Term::SF_LET_TUPLE: + processLet(sd, *term->nthArgument(0), occurrences); + break; - case Term::SF_LET: - case Term::SF_LET_TUPLE: - processLet(sd, *term->nthArgument(0), occurrences); - break; + case Term::SF_MATCH: { + processMatch(sd, term, occurrences); + break; + } - case Term::SF_MATCH: { - processMatch(sd, term, occurrences); - break; + default: { + ASSERTION_VIOLATION_REP(term->toString()); + } } - - default: - ASSERTION_VIOLATION_REP(term->toString()); } } @@ -1644,6 +1648,14 @@ Clause* NewCNF::toClause(SPGenClause gc) GenLit gl = lit.next(); Formula* g = formula(gl); + // This can happen when the problem is pseudo-higher-order + // I.e. marked as THF, but only containing FOOL constructs. + // THF parses works a little differntly to FOOL parses, so + // internal structures will be different. + if(g->connective() == BOOL_TERM){ + g = FOOLElimination::toEquality(static_cast(g)->getTerm()); + } + ASS_REP(g->connective() == LITERAL, gc->toString()); ASS_REP(g->literal()->shared(), g->toString()); ASS_REP((SIGN)g->literal()->polarity() == POSITIVE, g->toString()); diff --git a/Shell/Normalisation.cpp b/Shell/Normalisation.cpp index 0c0ffe0437..3c7f0b824d 100644 --- a/Shell/Normalisation.cpp +++ b/Shell/Normalisation.cpp @@ -506,6 +506,7 @@ Comparison Normalisation::compare(Term* t1, Term* t2) break; // compare body of the tuple below } +#if VHOL case Term::SF_LAMBDA: { comp = compare((int) VList::length(t1->getSpecialData()->getLambdaVars()), (int) VList::length(t2->getSpecialData()->getLambdaVars())); @@ -517,7 +518,8 @@ Comparison Normalisation::compare(Term* t1, Term* t2) comp = compare(b1, b2); return comp; } - +#endif + case Term::SF_MATCH: { break; // comparison by arity and pairwise by arguments is done below } diff --git a/Shell/Options.cpp b/Shell/Options.cpp index 12e79f78b9..411ac4aa9c 100644 --- a/Shell/Options.cpp +++ b/Shell/Options.cpp @@ -21,6 +21,8 @@ // Visual does not know the round function #include +#include +#include #include "Forwards.hpp" @@ -102,7 +104,9 @@ void Options::init() _mode = ChoiceOptionValue("mode","",Mode::VAMPIRE, {"axiom_selection", "casc", +#if VHOL "casc_hol", +#endif "casc_sat", "casc_ltb", "clausify", @@ -136,7 +140,10 @@ void Options::init() auto UsingPortfolioTechnology = [this] { // Consider extending this list when adding a new Casc-like mode - return Or(_mode.is(equal(Mode::CASC_HOL)), + return Or( +#if VHOL + _mode.is(equal(Mode::CASC_HOL)), +#endif _mode.is(equal(Mode::CASC)), _mode.is(equal(Mode::CASC_SAT)), _mode.is(equal(Mode::SMTCOMP)), @@ -147,8 +154,7 @@ void Options::init() {"casc", "casc_2019", "casc_sat", - "casc_sat_2019", - "casc_hol_2020", + "casc_sat_2019", "file", "induction", "integer_induction", @@ -161,6 +167,10 @@ void Options::init() "smtcomp_2018", "snake_tptp_uns", "snake_tptp_sat", +#if VHOL + "snake_tptp_hol", + "snake_slh", +#endif "struct_induction"}); _schedule.description = "Schedule to be run by the portfolio mode. casc and smtcomp usually point to the most recent schedule in that category. file loads the schedule from a file specified in --schedule_file. Note that some old schedules may contain option values that are no longer supported - see ignore_missing."; _lookup.insert(&_schedule); @@ -215,6 +225,13 @@ void Options::init() _randomStrategy.reliesOn(Or(_mode.is(equal(Mode::VAMPIRE)),_mode.is(equal(Mode::RANDOM_STRATEGY)))); _randomStrategy.tag(OptionTag::DEVELOPMENT); + _sampleStrategy = StringOptionValue("sample_strategy","",""); + _sampleStrategy.description = "Specify a path to a filename (of homemade format) describing how to sample a random strategy (incompatible with the --random_strategy way)."; + _lookup.insert(&_sampleStrategy); + _sampleStrategy.reliesOn(_mode.is(equal(Mode::VAMPIRE))); + _sampleStrategy.setExperimental(); + _sampleStrategy.tag(OptionTag::DEVELOPMENT); + _forbiddenOptions = StringOptionValue("forbidden_options","",""); _forbiddenOptions.description= "If some of the specified options are set to a forbidden state, vampire will fail to start, or in portfolio modes it will skip such strategies. The expected syntax is =:::...:="; @@ -306,9 +323,23 @@ void Options::init() _lookup.insert(&_printProofToFile); _printProofToFile.tag(OptionTag::OUTPUT); - _proofExtra = ChoiceOptionValue("proof_extra","",ProofExtra::OFF,{"off","free","full"}); +#if VDEBUG + _printVarBanks = BoolOptionValue("print_var_banks","pvb",false); + _printVarBanks.description="print var bank after each variable. useful for debugging"; + _lookup.insert(&_printVarBanks); + _printVarBanks.tag(OptionTag::OUTPUT); +#endif + + _printDefaultSorts = BoolOptionValue("print_def_sorts","pds",false); + _printDefaultSorts.description="Output variable sort in quantifier list, even if sort is default ($i)\n" + "Useful as some of Geoff's proof tools don't work with implicit sorts"; + _lookup.insert(&_printDefaultSorts); + _printDefaultSorts.tag(OptionTag::OUTPUT); + + _proofExtra = ChoiceOptionValue("proof_extra","",ProofExtra::OFF,{"off","free", "unifier", "full"}); _proofExtra.description="Add extra detail to proofs:\n " "- free uses known information only\n" + "- unifier records the actual unifer used in superposition\n" "- full may perform expensive operations to acheive this so may" " significantly impact on performance.\n" " The option is still under development and the format of extra information (mainly from full) may change between minor releases"; @@ -410,7 +441,7 @@ void Options::init() "where s (or conversely t) is ground and has weight greater or equal than w " "is replaced by C \\/ p(s) with the additional unit clause ~p(t) being added " "for fresh predicate p."; - _inequalitySplitting.addProblemConstraint(hasEquality()); + // _inequalitySplitting.addProblemConstraint(hasEquality()); // in HO varions axioms may add equality on which we can possibly split _lookup.insert(&_inequalitySplitting); _inequalitySplitting.tag(OptionTag::PREPROCESSING); @@ -429,8 +460,9 @@ void Options::init() _lookup.insert(&_equalityProxy); _equalityProxy.tag(OptionTag::PREPROCESSING); _equalityProxy.addProblemConstraint(hasEquality()); +#if VHOL _equalityProxy.addProblemConstraint(onlyFirstOrder()); - _equalityProxy.addHardConstraint(If(notEqual(EqualityProxy::OFF)).then(_combinatorySuperposition.is(notEqual(true)))); +#endif _equalityProxy.addHardConstraint(If(notEqual(EqualityProxy::OFF)).then(Or(_useMonoEqualityProxy.is(equal(true)), _saturationAlgorithm.is(notEqual(SaturationAlgorithm::INST_GEN))))); _equalityProxy.setRandomChoices(isRandOn(),{"R","RS","RST","RSTC","off","off","off","off","off"}); // wasn't tested, make off more likely @@ -552,13 +584,14 @@ void Options::init() _sineSelection.setRandomChoices(atomsMoreThan(1000),{"axioms","off","off","off","off","off","off","off"}); _sineTolerance = FloatOptionValue("sine_tolerance","st",1.0); - _sineTolerance.description="SInE tolerance parameter (sometimes referred to as 'benevolence')"; + _sineTolerance.description="SInE tolerance parameter (sometimes referred to as 'benevolence')." + " Has special value of -1.0, but otherwise must be greater or equal 1.0."; _lookup.insert(&_sineTolerance); _sineTolerance.tag(OptionTag::PREPROCESSING); - _sineTolerance.addConstraint(Or(equal(0.0f),greaterThanEq(1.0f) )); + _sineTolerance.addConstraint(Or(equal(-1.0f),greaterThanEq(1.0f) )); // Captures that if the value is not 1.0 then sineSelection must be on _sineTolerance.onlyUsefulWith(_sineSelection.is(notEqual(SineSelection::OFF))); - _sineTolerance.setRandomChoices({"1.0","1.2","1.5","2.0","3.0","5.0"}); + _sineTolerance.setRandomChoices({"-1.0","1.0","1.2","1.5","2.0","3.0","5.0"}); _naming = IntOptionValue("naming","nm",8); _naming.description="Introduce names for subformulas. Given a subformula F(x1,..,xk) of formula G a new predicate symbol is introduced as a name for F(x1,..,xk) by adding the axiom n(x1,..,xk) <=> F(x1,..,xk) and replacing F(x1,..,xk) with n(x1,..,xk) in G. The value indicates how many times a subformula must be used before it is named."; @@ -573,7 +606,9 @@ void Options::init() _newCNF.description="Use NewCNF algorithm to do naming, preprecess3 and clausificiation."; _lookup.insert(&_newCNF); _newCNF.addProblemConstraint(hasFormulas()); +#if VHOL _newCNF.addProblemConstraint(onlyFirstOrder()); +#endif _newCNF.tag(OptionTag::PREPROCESSING); _newCNF.setRandomChoices({"on","off"}); @@ -940,9 +975,53 @@ void Options::init() _ageWeightRatioShapeFrequency = UnsignedOptionValue("age_weight_ratio_shape_frequency","awrsf",100); _ageWeightRatioShapeFrequency.description = "How frequently the age/weight ratio shape is to change: i.e. if set to 'decay' at a frequency of 100, the age/weight ratio will change every 100 age/weight choices."; _ageWeightRatioShapeFrequency.onlyUsefulWith(_ageWeightRatioShape.is(notEqual(AgeWeightRatioShape::CONSTANT))); + _ageWeightRatioShapeFrequency.addHardConstraint(greaterThan(0u)); // we divide by this value in AWPPassiveClauseContainer::popSelected _lookup.insert(&_ageWeightRatioShapeFrequency); _ageWeightRatioShapeFrequency.tag(OptionTag::SATURATION); +#if VHOL + + _hoFeaturesSplitQueues = BoolOptionValue("ho_feature_split_queue","hfsq",false); + _hoFeaturesSplitQueues.description = "Turn on clause selection using multiple queues containing different clauses (split by amount of higher-order featues)"; + _hoFeaturesSplitQueues.onlyUsefulWith(ProperSaturationAlgorithm()); // could be "IncludingInstgen"? (not with theories...) + _hoFeaturesSplitQueues.addProblemConstraint(hasHigherOrder()); + _lookup.insert(&_hoFeaturesSplitQueues); + _hoFeaturesSplitQueues.tag(OptionTag::SATURATION); + + _hoFeaturesLambdaWeight = UnsignedOptionValue("ho_feature_lambda_weight","hflw",1); + _hoFeaturesLambdaWeight.description = "How much should lambda occurrences count in the HO features"; + _hoFeaturesLambdaWeight.onlyUsefulWith(_hoFeaturesSplitQueues.is(equal(true))); + _hoFeaturesLambdaWeight.addProblemConstraint(hasHigherOrder()); + _lookup.insert(&_hoFeaturesLambdaWeight); + _hoFeaturesLambdaWeight.tag(OptionTag::SATURATION); + + _hoFeaturesAppVarWeight = UnsignedOptionValue("ho_feature_appvar_weight","hfaw",1); + _hoFeaturesAppVarWeight.description = "How much should app-var occurrences count in the HO features"; + _hoFeaturesAppVarWeight.onlyUsefulWith(_hoFeaturesSplitQueues.is(equal(true))); + _hoFeaturesAppVarWeight.addProblemConstraint(hasHigherOrder()); + _lookup.insert(&_hoFeaturesAppVarWeight); + _hoFeaturesAppVarWeight.tag(OptionTag::SATURATION); + + _hoFeaturesSplitQueueCutoffs = StringOptionValue("ho_feature_split_queue_cutoffs", "hfsqc", "0"); + _hoFeaturesSplitQueueCutoffs.description = "The cutoff-values for the split-queues (the cutoff value for the last queue has to be omitted, as it is always infinity). Any split-queue contains all clauses which are assigned a feature-value less or equal to the cutoff-value of the queue. If no custom value for this option is set, the implementation will use cutoffs 0,4*d,10*d,infinity (where d denotes the theory split queue expected ratio denominator)."; + _lookup.insert(&_hoFeaturesSplitQueueCutoffs); + _hoFeaturesSplitQueueCutoffs.onlyUsefulWith(_hoFeaturesSplitQueues.is(equal(true))); + _hoFeaturesSplitQueueCutoffs.tag(OptionTag::SATURATION); + + _hoFeaturesSplitQueueRatios = StringOptionValue("ho_features_split_queue_ratios", "hfsqr", "1,1"); + _hoFeaturesSplitQueueRatios.description = "The ratios for picking clauses from the split-queues using weighted round robin. If a queue is empty, the clause will be picked from the next non-empty queue to the right. Note that this option implicitly also sets the number of queues."; + _lookup.insert(&_hoFeaturesSplitQueueRatios); + _hoFeaturesSplitQueueRatios.onlyUsefulWith(_hoFeaturesSplitQueues.is(equal(true))); + _hoFeaturesSplitQueueRatios.tag(OptionTag::AVATAR); + + _hoFeaturesSplitQueueLayeredArrangement = BoolOptionValue("ho_features_split_queue_layered_arrangement","hfsql",true); + _hoFeaturesSplitQueueLayeredArrangement.description = "If turned on, use a layered arrangement to split clauses into queues. Otherwise use a tammet-style-arrangement."; + _lookup.insert(&_hoFeaturesSplitQueueLayeredArrangement); + _hoFeaturesSplitQueueLayeredArrangement.onlyUsefulWith(_hoFeaturesSplitQueues.is(equal(true))); + _hoFeaturesSplitQueueLayeredArrangement.tag(OptionTag::SATURATION); + +#else + _useTheorySplitQueues = BoolOptionValue("theory_split_queue","thsq",false); _useTheorySplitQueues.description = "Turn on clause selection using multiple queues containing different clauses (split by amount of theory reasoning)"; _useTheorySplitQueues.onlyUsefulWith(ProperSaturationAlgorithm()); // could be "IncludingInstgen"? (not with theories...) @@ -974,6 +1053,8 @@ void Options::init() _theorySplitQueueLayeredArrangement.onlyUsefulWith(_useTheorySplitQueues.is(equal(true))); _theorySplitQueueLayeredArrangement.tag(OptionTag::SATURATION); +#endif + _useAvatarSplitQueues = BoolOptionValue("avatar_split_queue","avsq",false); _useAvatarSplitQueues.description = "Turn on experiments: clause selection with multiple queues containing different clauses (split by amount of avatar-split-set-size)"; _lookup.insert(&_useAvatarSplitQueues); @@ -1091,16 +1172,17 @@ void Options::init() // Like generality threshold for SiNE, except used by the sine2age trick _sineToAgeTolerance = FloatOptionValue("sine_to_age_tolerance","s2at",1.0); - _sineToAgeTolerance.description = "Like sine_tolerance but influences sine_to_age, sine_to_pred_levels, and sine_level_split_queue rather than sine_selection."; + _sineToAgeTolerance.description = "Like sine_tolerance but influences sine_to_age, sine_to_pred_levels, and sine_level_split_queue rather than sine_selection." + " Has special value of -1.0, but otherwise must be greater or equal 1.0."; _lookup.insert(&_sineToAgeTolerance); _sineToAgeTolerance.tag(OptionTag::SATURATION); - _sineToAgeTolerance.addConstraint(Or(equal(0.0f),greaterThanEq(1.0f))); + _sineToAgeTolerance.addConstraint(Or(equal(-1.0f),greaterThanEq(1.0f))); // Captures that if the value is not 1.0 then sineSelection must be on _sineToAgeTolerance.onlyUsefulWith(Or( _sineToAge.is(equal(true)), _sineToPredLevels.is(notEqual(PredicateSineLevels::OFF)), _useSineLevelSplitQueues.is(equal(true)))); - _sineToAgeTolerance.setRandomChoices({"1.0","1.2","1.5","2.0","3.0","5.0"}); + _sineToAgeTolerance.setRandomChoices({"-1.0","1.0","1.2","1.5","2.0","3.0","5.0"}); _lrsFirstTimeCheck = IntOptionValue("lrs_first_time_check","",5); _lrsFirstTimeCheck.description= @@ -1130,8 +1212,8 @@ void Options::init() _lrsEstimateCorrectionCoef.tag(OptionTag::SATURATION); _lrsEstimateCorrectionCoef.addConstraint(greaterThan(0.0f)); _lrsEstimateCorrectionCoef.onlyUsefulWith(_saturationAlgorithm.is(equal(SaturationAlgorithm::LRS))); - _lrsEstimateCorrectionCoef.setRandomChoices({"1.0","1.1","1.2","0.9","0.8"}); - + _lrsEstimateCorrectionCoef.setRandomChoices({"1.0","1.1","1.2","0.9","0.8"}); + //*********************** Inferences *********************** #if VZ3 @@ -1189,7 +1271,7 @@ void Options::init() _unificationWithAbstraction = ChoiceOptionValue("unification_with_abstraction","uwa", UnificationWithAbstraction::OFF, - {"off","interpreted_only","one_side_interpreted","one_side_constant","all","ground"}); + {"off","interpreted_only","one_side_interpreted","constant","all","ground","ac1","ac2"}); _unificationWithAbstraction.description= "During unification, if two terms s and t fail to unify we will introduce a constraint s!=t and carry on. For example, " "resolving p(1) \\/ C with ~p(a+2) would produce C \\/ 1 !=a+2. This is controlled by a check on the terms. The expected " @@ -1204,6 +1286,12 @@ void Options::init() _unificationWithAbstraction.tag(OptionTag::INFERENCES); _lookup.insert(&_unificationWithAbstraction); + _unificationWithAbstractionFixedPointIteration = BoolOptionValue("unification_with_abstraction_postpro","uwa_fpi", + false); + _unificationWithAbstractionFixedPointIteration.description="TODO"; + _unificationWithAbstractionFixedPointIteration.tag(OptionTag::INFERENCES); + _lookup.insert(&_unificationWithAbstractionFixedPointIteration); + _useACeval = BoolOptionValue("use_ac_eval","uace",true); _useACeval.description="Evaluate associative and commutative operators e.g. + and *."; _useACeval.tag(OptionTag::INFERENCES); @@ -1505,7 +1593,6 @@ void Options::init() _backwardSubsumptionDemodulation.tag(OptionTag::INFERENCES); _backwardSubsumptionDemodulation.onlyUsefulWith(InferencingSaturationAlgorithm()); _backwardSubsumptionDemodulation.addProblemConstraint(hasEquality()); - _backwardSubsumptionDemodulation.onlyUsefulWith(_combinatorySuperposition.is(equal(false))); // higher-order support is not yet implemented _backwardSubsumptionDemodulation.setRandomChoices({"on","off"}); _backwardSubsumptionDemodulationMaxMatches = UnsignedOptionValue("backward_subsumption_demodulation_max_matches", "bsdmm", 0); @@ -1530,10 +1617,6 @@ void Options::init() _binaryResolution.setRandomChoices(And(isRandSat(),saNotInstGen(),Or(hasEquality(),hasCat(Property::HNE))),{"on"}); _binaryResolution.setRandomChoices({"on","off"}); - _superposition = BoolOptionValue("superposition","sup",true); - _superposition.description= "Control superposition. Turning off this core inference leads to an incomplete calculus on equational problems."; - _lookup.insert(&_superposition); - _condensation = ChoiceOptionValue("condensation","cond",Condensation::OFF,{"fast","off","on"}); _condensation.description= "Perform condensation. If 'fast' is specified, we only perform condensations that are easy to check for."; @@ -1686,7 +1769,6 @@ void Options::init() _forwardSubsumptionDemodulation.onlyUsefulWith(InferencingSaturationAlgorithm()); _forwardSubsumptionDemodulation.tag(OptionTag::INFERENCES); _forwardSubsumptionDemodulation.addProblemConstraint(hasEquality()); - _forwardSubsumptionDemodulation.onlyUsefulWith(_combinatorySuperposition.is(equal(false))); // higher-order support is not yet implemented _forwardSubsumptionDemodulation.setRandomChoices({"off","on"}); _forwardSubsumptionDemodulationMaxMatches = UnsignedOptionValue("forward_subsumption_demodulation_max_matches", "fsdmm", 0); @@ -1745,12 +1827,45 @@ void Options::init() //*********************** Higher-order *********************** - _addCombAxioms = BoolOptionValue("add_comb_axioms","aca",false); - _addCombAxioms.description="Add combinator axioms"; - _lookup.insert(&_addCombAxioms); - _addCombAxioms.addProblemConstraint(hasHigherOrder()); - _addCombAxioms.onlyUsefulWith(_combinatorySuperposition.is(equal(false))); //no point having two together - _addCombAxioms.tag(OptionTag::HIGHER_ORDER); +#if VHOL + _superposition = BoolOptionValue("superposition","sup",true); + _superposition.onlyUsefulWith(InferencingSaturationAlgorithm()); + _superposition.tag(OptionTag::INFERENCES); + _superposition.description= "Control superposition. Turning off this core inference leads to an incomplete calculus on equational problems."; + _lookup.insert(&_superposition); + + + _heuristicInstantiation = BoolOptionValue("heur_inst","hi",false); + _heuristicInstantiation.onlyUsefulWith(InferencingSaturationAlgorithm()); + _heuristicInstantiation.addProblemConstraint(hasHigherOrder()); + _heuristicInstantiation.addHardConstraint(If(notEqual(false)).then(_clausificationOnTheFly.is(equal(CNFOnTheFly::CONJ_EAGER)))); + _heuristicInstantiation.description= "Heuristically instantiates universally quantified variables with abstractions of literals from negated conjecture"; + _lookup.insert(&_heuristicInstantiation); + _heuristicInstantiation.tag(OptionTag::HIGHER_ORDER); + + + _applicativeUnify = BoolOptionValue("applicative_unif","au",false); + _applicativeUnify.onlyUsefulWith(InferencingSaturationAlgorithm()); + _applicativeUnify.addProblemConstraint(hasHigherOrder()); + // _applicativeUnify.onlyUsefulWith(_functionExtensionality.is(notEqual(FunctionExtensionality::ABSTRACTION))); // not good for minimizer: defaulting fe to abstraction would trigger turning off au, which will not be the same + _applicativeUnify.description= "Carries out first-order applicative unification instead of higher-order unification"; + _lookup.insert(&_applicativeUnify); + _applicativeUnify.tag(OptionTag::HIGHER_ORDER); + + _higherOrderUnifDepth = UnsignedOptionValue("hol_unif_depth","hud",2); + _higherOrderUnifDepth.description = "Set the maximum depth (in terms of projextions and imitations) that higher-order unification can descend to. Once limit is reached, remaining pairs are retunred as constraints."; + _higherOrderUnifDepth.addProblemConstraint(hasHigherOrder()); + _higherOrderUnifDepth.addHardConstraint(lessThan(100u)); + _lookup.insert(&_higherOrderUnifDepth); + _higherOrderUnifDepth.tag(OptionTag::HIGHER_ORDER); + + _takeNUnifiersOnly = UnsignedOptionValue("take_n_unifiers","tnu",0); + _takeNUnifiersOnly.description = "Only take the first n unifiers returned by the higher-order unification iterator. 0 means don't use this option"; + _takeNUnifiersOnly.addProblemConstraint(hasHigherOrder()); + _takeNUnifiersOnly.addHardConstraint(If(notEqual(0u)).then(_applicativeUnify.is(equal(false)))); + _takeNUnifiersOnly.addHardConstraint(lessThan(10u)); + _lookup.insert(&_takeNUnifiersOnly); + _takeNUnifiersOnly.tag(OptionTag::HIGHER_ORDER); _addProxyAxioms = BoolOptionValue("add_proxy_axioms","apa",false); _addProxyAxioms.description="Add logical proxy axioms"; @@ -1758,15 +1873,6 @@ void Options::init() _addProxyAxioms.addProblemConstraint(hasHigherOrder()); _addProxyAxioms.tag(OptionTag::HIGHER_ORDER); - _combinatorySuperposition = BoolOptionValue("combinatory_sup","csup",false); - _combinatorySuperposition.description="Switches on a specific ordering and that orients combinator axioms left-right." - " Also turns on a number of special inference rules"; - _lookup.insert(&_combinatorySuperposition); - _combinatorySuperposition.addProblemConstraint(hasHigherOrder()); - _combinatorySuperposition.onlyUsefulWith(_addCombAxioms.is(equal(false))); //no point having two together - _combinatorySuperposition.onlyUsefulWith(ProperSaturationAlgorithm()); - _combinatorySuperposition.tag(OptionTag::HIGHER_ORDER); - _choiceAxiom = BoolOptionValue("choice_ax","cha",false); _choiceAxiom.description="Adds the cnf form of the Hilbert choice axiom"; _lookup.insert(&_choiceAxiom); @@ -1780,11 +1886,11 @@ void Options::init() _choiceReasoning.onlyUsefulWith(_choiceAxiom.is(equal(false))); //no point having two together _choiceReasoning.tag(OptionTag::HIGHER_ORDER); - _priortyToLongReducts = BoolOptionValue("priority_to_long_reducts","ptlr",false); + /*_priortyToLongReducts = BoolOptionValue("priority_to_long_reducts","ptlr",false); _priortyToLongReducts.description="give priority to clauses produced by lengthy reductions"; _lookup.insert(&_priortyToLongReducts); _priortyToLongReducts.addProblemConstraint(hasHigherOrder()); - _priortyToLongReducts.tag(OptionTag::HIGHER_ORDER); + _priortyToLongReducts.tag(OptionTag::HIGHER_ORDER);*/ _injectivity = BoolOptionValue("injectivity","inj",false); _injectivity.description="Attempts to identify injective functions and postulates a left-inverse"; @@ -1794,18 +1900,14 @@ void Options::init() _pragmatic = BoolOptionValue("pragmatic","prag",false); _pragmatic.description="Modifes various parameters to help Vampire solve 'hard' higher-order"; - _pragmatic.onlyUsefulWith(_combinatorySuperposition.is(equal(true))); _lookup.insert(&_pragmatic); _pragmatic.addProblemConstraint(hasHigherOrder()); + _pragmatic.addHardConstraint(If(equal(true)).then(_higherOrderUnifDepth.is(notEqual(0u)))); _pragmatic.tag(OptionTag::HIGHER_ORDER); - _maximumXXNarrows = IntOptionValue("max_XX_narrows","mXXn", 0); - _maximumXXNarrows.description="Maximum number of BXX', CXX' and SXX' narrows that" - "can be carried out 0 means that there is no limit. "; - _lookup.insert(&_maximumXXNarrows); - _maximumXXNarrows.addProblemConstraint(hasHigherOrder()); - _maximumXXNarrows.tag(OptionTag::HIGHER_ORDER); - + // TODO we have two ways of enabling function extensionality abstraction atm: + // this option, and `-uwa`. + // We should sort this out before merging into master. _functionExtensionality = ChoiceOptionValue("func_ext","fe",FunctionExtensionality::ABSTRACTION, {"off", "axiom", "abstraction"}); _functionExtensionality.description="Deal with extensionality using abstraction, axiom or neither"; @@ -1818,37 +1920,32 @@ void Options::init() "lazy_gen", "lazy_simp", "lazy_not_gen", + "lazy_pi_sigma_gen", "lazy_not_gen_be_off", "lazy_not_be_gen", + "conj_eager", "off"}); _clausificationOnTheFly.description="Various options linked to clausification on the fly"; _lookup.insert(&_clausificationOnTheFly); - _clausificationOnTheFly.addProblemConstraint(hasHigherOrder()); + _clausificationOnTheFly.addProblemConstraint(hasHigherOrder()); + _clausificationOnTheFly.addHardConstraint(If(notEqual(CNFOnTheFly::OFF)).then(_addProxyAxioms.is(equal(false)))); _clausificationOnTheFly.tag(OptionTag::HIGHER_ORDER); - - _piSet = ChoiceOptionValue("prim_inst_set","piset",PISet::ALL_EXCEPT_NOT_EQ, + _piSet = ChoiceOptionValue("prim_inst_set","piset",PISet::PRAGMATIC, {"all", "all_but_not_eq", - "false_true_not", - "small_set"}); + "not", + "small_set", + "pragmatic", + "and", + "or", + "equals", + "pi_sigma" }); _piSet.description="Controls the set of equations to use in primitive instantiation"; _lookup.insert(&_piSet); _piSet.addProblemConstraint(hasHigherOrder()); _piSet.tag(OptionTag::HIGHER_ORDER); - - _narrow = ChoiceOptionValue("narrow","narr",Narrow::ALL, - {"all", - "sk", - "ski", - "off"}); - _narrow.description="Controls the set of combinator equations to use in narrowing"; - _lookup.insert(&_narrow); - _narrow.addProblemConstraint(hasHigherOrder()); - _narrow.tag(OptionTag::HIGHER_ORDER); - - _equalityToEquivalence = BoolOptionValue("equality_to_equiv","e2e",false); _equalityToEquivalence.description= "Equality between boolean terms changed to equivalence \n" @@ -1860,9 +1957,10 @@ void Options::init() _complexBooleanReasoning = BoolOptionValue("complex_bool_reasoning","cbe",true); _complexBooleanReasoning.description= "Switches on primitive instantiation and elimination of leibniz equality"; - _complexBooleanReasoning.onlyUsefulWith(_addProxyAxioms.is(equal(false))); + // add this back to warn users about a suboptimal conf; but actually the two options do something together + // _complexBooleanReasoning.addConstraint(If(equal(true)).then(_addProxyAxioms.is(equal(false)))); _lookup.insert(&_complexBooleanReasoning); - _complexBooleanReasoning.addProblemConstraint(hasHigherOrder()); + _complexBooleanReasoning.addProblemConstraint(hasHigherOrder()); _complexBooleanReasoning.tag(OptionTag::HIGHER_ORDER); _booleanEqTrick = BoolOptionValue("bool_eq_trick","bet",false); @@ -1899,20 +1997,53 @@ void Options::init() // potentially could be useful for FOOL, so am not adding the HOL constraint _newTautologyDel.tag(OptionTag::HIGHER_ORDER); - _lambdaFreeHol = BoolOptionValue("lam_free_hol","lfh",false); + _positiveExt = BoolOptionValue("pos_ext","pe",false); + _positiveExt.description= + "Enables the following inference\n" + "C \\/ t X = s X \n" + "----------------\n" + " C \\/ t = s \n" + "where X doesn't occur in t,s or C"; + _lookup.insert(&_positiveExt); + _positiveExt.addProblemConstraint(hasHigherOrder()); + _positiveExt.onlyUsefulWith(_functionExtensionality.is(notEqual(FunctionExtensionality::AXIOM))); + _positiveExt.tag(OptionTag::HIGHER_ORDER); + + /*_lambdaFreeHol = BoolOptionValue("lam_free_hol","lfh",false); _lambdaFreeHol.description= "Reason about lambda-free hol. See paper by Vukmirovic et al."; _lookup.insert(&_lambdaFreeHol); _lambdaFreeHol.addProblemConstraint(hasHigherOrder()); - _lambdaFreeHol.tag(OptionTag::HIGHER_ORDER); + _lambdaFreeHol.tag(OptionTag::HIGHER_ORDER);*/ + + _iffXorRewriter = BoolOptionValue("iff_xor_rewriter","ixr",true); + _iffXorRewriter.description= + "Rewrites p <=> q = $true to p <=> q and the like. It does this as an immediate simplification."; + _lookup.insert(&_iffXorRewriter); + _iffXorRewriter.addProblemConstraint(hasHigherOrder()); + _iffXorRewriter.tag(OptionTag::HIGHER_ORDER); + - _complexVarCondition = BoolOptionValue("complex_var_cond","cvc",false); + /*_complexVarCondition = BoolOptionValue("complex_var_cond","cvc",false); _complexVarCondition.description= "Use the more complex variable condition provided in the SKIKBO paper.\n" "More terms are comparable with this ordering, but it has worst case" "exponential complexity"; _lookup.insert(&_complexVarCondition); - _complexVarCondition.tag(OptionTag::HIGHER_ORDER); + _complexVarCondition.tag(OptionTag::HIGHER_ORDER);*/ + + _holPrinting = ChoiceOptionValue("pretty_hol_printing","php",HPrinting::TPTP, + {"raw","db","pretty","tptp"}); + _holPrinting.description= + "Various methods of printing higher-order terms: \n" + " -raw : prints the internal representation of terms \n" + " -pretty : converts internal representation to something resembling textbook notation \n" + " -tptp : matches tptp standards \n" + " -db : same as tptp, except that De Bruijn indices printed instead of named variables"; + _lookup.insert(&_holPrinting); + _holPrinting.tag(OptionTag::HIGHER_ORDER); + +#endif //*********************** InstGen *********************** @@ -2142,7 +2273,7 @@ void Options::init() _lookup.insert(&_splittingFlushQuotient); _splittingFlushQuotient.tag(OptionTag::AVATAR); _splittingFlushQuotient.addConstraint(greaterThanEq(1.0f)); - _splittingFlushQuotient.onlyUsefulWith(_splitting.is(equal(true))); + _splittingFlushQuotient.onlyUsefulWith(_splittingFlushPeriod.is(notEqual((unsigned)0))); _splittingFlushQuotient.setRandomChoices({"1.0","1.1","1.2","1.4","2.0"}); _splittingAvatimer = FloatOptionValue("avatar_turn_off_time_frac","atotf",1.0); @@ -2151,7 +2282,7 @@ void Options::init() "but not introducing new splits anymore. This fights the theoretical possibility of AVATAR's dynamic incompletness.)"; _lookup.insert(&_splittingAvatimer); _splittingAvatimer.tag(OptionTag::AVATAR); - _splittingAvatimer.addConstraint(greaterThan(0.0f)); //if you want to stop splitting right-away, just turn AVATAR off + _splittingAvatimer.addConstraint(greaterThanEq(0.0f)); //if you want to stop splitting right-away, just turn AVATAR off _splittingAvatimer.addConstraint(smallerThanEq(1.0f)); _splittingAvatimer.onlyUsefulWith(_splitting.is(equal(true))); _splittingAvatimer.setRandomChoices({"0.0","0.5","0.7","0.9"}); @@ -2187,7 +2318,8 @@ void Options::init() #endif }); _satSolver.description= - "Select the SAT solver to be used throughout the solver. This will be used in AVATAR (for splitting) when the saturation algorithm is discount,lrs or otter and in instance generation for selection and global subsumption."; + "Select the SAT solver to be used throughout the solver. This will be used in AVATAR (for splitting) when the saturation algorithm is discount,lrs or otter." + " (For instance generation for selection and global subsumption, we currently only use minisat.)"; _lookup.insert(&_satSolver); // in principle, global_subsumption and instgen also depend on the SAT solver choice, however, // 1) currently, neither is actually supporting Z3 @@ -2304,9 +2436,9 @@ void Options::init() "scramble","frequency","unary_frequency","const_frequency", "reverse_frequency", "weighted_frequency","reverse_weighted_frequency"}); _symbolPrecedence.description="Vampire uses term orderings which require a precedence relation between symbols.\n" - "Arity orders symbols by their arity (and reverse_arity takes the reverse of this) and occurence orders symbols by the order they appear in the problem. " + "Arity orders symbols by their arity (and reverse_arity takes the reverse of this) and occurrence orders symbols by the order they appear in the problem. " "Then we have a few precedence generating schemes adopted from E: frequency - sort by frequency making rare symbols large, reverse does the opposite, " - "(For the weighted versions, each symbol occurence counts as many times as is the lenght of the clause in which it occurs.) " + "(For the weighted versions, each symbol occurrence counts as many times as is the length of the clause in which it occurs.) " "unary_first is like arity, except that unary symbols are maximal (and ties are broken by frequency), " "unary_frequency is like frequency, except that unary symbols are maximal, " "const_max makes constants the largest, then falls back to arity, " @@ -2315,7 +2447,7 @@ void Options::init() _lookup.insert(&_symbolPrecedence); _symbolPrecedence.onlyUsefulWith(InferencingSaturationAlgorithm()); _symbolPrecedence.tag(OptionTag::SATURATION); - _symbolPrecedence.setRandomChoices({"arity","occurence","reverse_arity","frequency"}); + _symbolPrecedence.setRandomChoices({"arity","occurrence","reverse_arity","frequency"}); _introducedSymbolPrecedence = ChoiceOptionValue("introduced_symbol_precedence","isp", IntroducedSymbolPrecedence::TOP, @@ -2330,11 +2462,13 @@ void Options::init() _kboWeightGenerationScheme.description = "Weight generation schemes from KBO inspired by E. This gets overridden by the function_weights option if used."; _kboWeightGenerationScheme.setExperimental(); _kboWeightGenerationScheme.onlyUsefulWith(_termOrdering.is(equal(TermOrdering::KBO))); + _kboWeightGenerationScheme.tag(OptionTag::SATURATION); _lookup.insert(&_kboWeightGenerationScheme); _kboMaxZero = BoolOptionValue("kbo_max_zero","kmz",false); _kboMaxZero.setExperimental(); _kboMaxZero.onlyUsefulWith(_termOrdering.is(equal(TermOrdering::KBO))); + _kboMaxZero.tag(OptionTag::SATURATION); _kboMaxZero.description="Modifies any kbo_weight_scheme by setting the maximal (by the precedence) function symbol to have weight 0."; _lookup.insert(&_kboMaxZero); @@ -2344,6 +2478,7 @@ void Options::init() _kboAdmissabilityCheck.description = "Choose to emit a warning instead of throwing an exception if the weight function and precedence ordering for kbo are not compatible."; _kboAdmissabilityCheck.setExperimental(); _kboAdmissabilityCheck.onlyUsefulWith(_termOrdering.is(equal(TermOrdering::KBO))); + _kboAdmissabilityCheck.tag(OptionTag::SATURATION); _lookup.insert(&_kboAdmissabilityCheck); @@ -3024,6 +3159,7 @@ bool Options::SelectionOptionValue::setValue(const vstring& value) case -1004: case -1010: case -1011: // almost same as 1011 (but factoring will be on negative and not positive literals) + case -1666: actualValue = sel; return true; default: @@ -3186,6 +3322,267 @@ void Options::randomizeStrategy(Property* prop) if(prop) cout << "Random strategy: " + generateEncodedOptions() << endl; } +void Options::strategySamplingAssign(vstring optname, vstring value, DHMap& fakes) +{ + CALL("Options::strategySamplingAssign"); + + // dollar sign signifies fake options + if (optname[0] == '$') { + fakes.set(optname,value); + return; + } + + AbstractOptionValue* opt = getOptionValueByName(optname); + if (opt) { + if (!opt->set(value)) { + USER_ERROR("Sampling file processing error -- unknown option value: " + value + " for option " + optname); + } + } else { + USER_ERROR("Sampling file processing error -- unknown option: " + optname); + } +} + +vstring Options::strategySamplingLookup(vstring optname, DHMap& fakes) +{ + CALL("Options::strategySamplingLookup"); + + if (optname[0] == '$') { + vstring* foundVal = fakes.findPtr(optname); + if (!foundVal) { + USER_ERROR("Sampling file processing error -- unassigned fake option: " + optname); + } + return *foundVal; + } + + AbstractOptionValue* opt = getOptionValueByName(optname); + if (opt) { + return opt->getStringOfActual(); + } else { + USER_ERROR("Sampling file processing error -- unknown option to look up: " + optname); + } + return ""; +} + +void Options::trySamplingStrategy() +{ + CALL("Options::trySamplingStrategy"); + if(_sampleStrategy.actualValue=="") return; + + BYPASSING_ALLOCATOR; + + std::ifstream input(_sampleStrategy.actualValue.c_str()); + + if (input.fail()) { + USER_ERROR("Cannot open sampler file: "+_sampleStrategy.actualValue); + } + + // our local randomizing engine (randomly seeded) + std::mt19937 rng((std::random_device())()); + // map of local variables (fake options) + DHMap fakes; + + vstring line; // parsed lines + Stack pieces; // temp stack used for splitting + while (std::getline(input, line)) + { + if (line.length() == 0 || line[0] == '#') { // empty lines and comments (starting with # as the first! character) + continue; + } + + StringUtils::splitStr(line.c_str(),'>',pieces); + if (pieces.size() != 2) { + USER_ERROR("Sampling file parse error -- each rule must contain exactly one >. Here: "+line); + } + + vstring cond = pieces[0]; + vstring body = pieces[1]; + pieces.reset(); + + // evaluate condition, if false, will skip the rest + bool fireRule = true; + { + StringUtils::splitStr(cond.c_str(),' ',pieces); + StringUtils::dropEmpty(pieces); + + Stack pair; + Stack::BottomFirstIterator it(pieces); + while(it.hasNext()) { + vstring equation = it.next(); + StringUtils::splitStr(equation.c_str(),'=',pair); + StringUtils::dropEmpty(pair); + if (pair.size() != 2) { + USER_ERROR("Sampling file parse error -- invalid equation: "+equation); + } + bool negated = false; + vstring optName = pair[0]; + if (optName.back() == '!') { + negated = true; + optName.pop_back(); + } + vstring storedVal = strategySamplingLookup(optName,fakes); + if ((storedVal != pair[1]) != negated) { + fireRule = false; + break; + } + pair.reset(); + } + + pieces.reset(); + } + + if (!fireRule) { + continue; + } + + // now it's time to read the body + // cout << "fire: " << body << endl; + + StringUtils::splitStr(body.c_str(),' ',pieces); + StringUtils::dropEmpty(pieces); + if (pieces.size() != 3) { + USER_ERROR("Sampling file parse error -- rule body must consist of three space-separated parts. Here: "+body); + } + + vstring optname = pieces[0]; + vstring sampler = pieces[1]; + vstring args = pieces[2]; + pieces.reset(); + + if (sampler == "~cat") { // categorical sampling + StringUtils::splitStr(args.c_str(),',',pieces); + + unsigned total = 0; + Stack> mulvals; + + // parse the mulvals + { + Stack pair; + Stack::BottomFirstIterator it(pieces); + while(it.hasNext()) { + vstring mulval = it.next(); + StringUtils::splitStr(mulval.c_str(),':',pair); + StringUtils::dropEmpty(pair); + if (pair.size() != 2) { + USER_ERROR("Sampling file parse error -- invalid mulval: "+mulval); + } + + int multiplicity = 0; + if (!Int::stringToInt(pair[1],multiplicity) || multiplicity <= 0) { + USER_ERROR("Sampling file parse error -- invalid multiplicity in mulval: "+mulval); + } + total += multiplicity; + mulvals.push(std::make_pair(multiplicity,pair[0])); + pair.reset(); + } + pieces.reset(); + } + + // actual sampling + vstring value; + int sample = std::uniform_int_distribution(1,total)(rng); + Stack>::BottomFirstIterator it(mulvals); + while (it.hasNext()) { + auto mulval = it.next(); + if (sample <= mulval.first) { + value = mulval.second; + break; + } + sample -= mulval.first; + } + ASS_NEQ(value,""); + + strategySamplingAssign(optname,value,fakes); + } else if (sampler == "~u2r") { + StringUtils::splitStr(args.c_str(),';',pieces); + StringUtils::dropEmpty(pieces); + + if (pieces.size() != 3) { + USER_ERROR("Sampling file parse error -- ~u2r sampler expects exatly three simecolon-separated arguments but got: "+args); + } + if (pieces[2].length() != 1) { + USER_ERROR("Sampling file parse error -- the third argument of the ~u2r sampler needs to be a single character and not: "+pieces[2]); + } + float low,high; + if (!Int::stringToFloat(pieces[0].c_str(),low) || !Int::stringToFloat(pieces[1].c_str(),high)) { + USER_ERROR("Sampling file parse error -- can't convert one of ~u2r sampler arguments to float: "+args); + } + std::uniform_real_distribution dis(low,high); + float raw = dis(rng); + float exped = powf(2.0,raw); + unsigned denom = 1 << 20; + unsigned numer = exped*denom; + // don't generate factions in non-base form + while (numer % 2 == 0 && denom % 2 == 0) { + numer /= 2; + denom /= 2; + } + strategySamplingAssign(optname,Int::toString(numer)+pieces[2]+Int::toString(denom),fakes); + + pieces.reset(); + } else if (sampler == "~sgd") { + StringUtils::splitStr(args.c_str(),',',pieces); + StringUtils::dropEmpty(pieces); + + if (pieces.size() != 2) { + USER_ERROR("Sampling file parse error -- ~sgd sampler expects exatly two comma-separated arguments but got: "+args); + } + double prob; + int offset; + if (!Int::stringToDouble(pieces[0].c_str(),prob) || !Int::stringToInt(pieces[1].c_str(),offset)) { + USER_ERROR("Sampling file parse error -- can't convert one of ~sgd sampler arguments to numbers: "+args); + } + std::geometric_distribution dis(prob); + int nval = offset+dis(rng); + strategySamplingAssign(optname,Int::toString(nval),fakes); + + pieces.reset(); + } else if (sampler == "~uf") { + StringUtils::splitStr(args.c_str(),',',pieces); + StringUtils::dropEmpty(pieces); + + if (pieces.size() != 2) { + USER_ERROR("Sampling file parse error -- ~uf sampler expects exatly two comma-separated arguments but got: "+args); + } + float low,high; + if (!Int::stringToFloat(pieces[0].c_str(),low) || !Int::stringToFloat(pieces[1].c_str(),high)) { + USER_ERROR("Sampling file parse error -- can't convert one of ~uf sampler arguments to float: "+args); + } + std::uniform_real_distribution dis(low,high); + float raw = dis(rng); + strategySamplingAssign(optname,Int::toString(raw),fakes); + + pieces.reset(); + } else if (sampler == "~ui") { + StringUtils::splitStr(args.c_str(),',',pieces); + StringUtils::dropEmpty(pieces); + + if (pieces.size() != 2) { + USER_ERROR("Sampling file parse error -- ~ui sampler expects exatly two comma-separated arguments but got: "+args); + } + int low,high; + if (!Int::stringToInt(pieces[0].c_str(),low) || !Int::stringToInt(pieces[1].c_str(),high)) { + USER_ERROR("Sampling file parse error -- can't convert one of ~ui sampler arguments to integer: "+args); + } + std::uniform_int_distribution dis(low,high); + int raw = dis(rng); + strategySamplingAssign(optname,Int::toString(raw),fakes); + + pieces.reset(); + } else { + USER_ERROR("Sampling file parse error -- unrecognized sampler: " + sampler); + } + + /* + Stack::BottomFirstIterator it(pieces); + while(it.hasNext()) { + cout << "tok:" << it.next() << endl; + } + */ + } + + cout << "Random strategy: " + generateEncodedOptions() << endl; +} + /** * Assign option values as encoded in the option vstring if assign=true, otherwise check that * the option values are not currently set to those values. @@ -3409,7 +3806,11 @@ vstring Options::generateEncodedOptions() const forbidden.insert(&_randomStrategy); forbidden.insert(&_encode); forbidden.insert(&_decode); + forbidden.insert(&_sampleStrategy); forbidden.insert(&_ignoreMissing); // or maybe we do! +#if VDEBUG + forbidden.insert(&_printVarBanks); +#endif } VirtualIterator options = _lookup.values(); @@ -3441,10 +3842,12 @@ bool Options::complete(const Problem& prb) const { CALL("Options::complete"); +#if VHOL if(prb.higherOrder()){ //safer for competition return false; } +#endif if (_showInterpolant.actualValue != InterpolantMode::OFF) { return false; @@ -3456,6 +3859,13 @@ bool Options::complete(const Problem& prb) const return false; } +#if VHOL + if(prb.hasFOOL() && _casesSimp.actualValue){ + // casesSimp is not complete + return false; + } +#endif + Property& prop = *prb.getProperty(); // general properties causing incompleteness @@ -3487,19 +3897,9 @@ bool Options::complete(const Problem& prb) const bool unitEquality = prop.category() == Property::UEQ; bool hasEquality = (prop.equalityAtoms() != 0); +#if VHOL if (hasEquality && !_superposition.actualValue) return false; - - if((prop.hasCombs() || prop.hasAppliedVar()) && - !_addCombAxioms.actualValue && !_combinatorySuperposition.actualValue) { - //TODO make a more complex more precise case here - //There are instance where we are complete - return false; - } - - //TODO update once we have another method of dealing with bools - if((prop.hasLogicalProxy() || prop.hasBoolVar()) && !_addProxyAxioms.actualValue){ - return false; - } +#endif if (!unitEquality) { if (_selection.actualValue <= -1000 || _selection.actualValue >= 1000) return false; @@ -3670,6 +4070,49 @@ Lib::vvector Options::theorySplitQueueCutoffs() const return cutoffs; } +#if VHOL + +Lib::vvector Options::hoFeaturesSplitQueueRatios() const +{ + CALL("Options::hoFeaturesSplitQueueRatios"); + Lib::vvector inputRatios = parseCommaSeparatedList(_hoFeaturesSplitQueueRatios.actualValue); + + // sanity checks + if (inputRatios.size() < 2) { + USER_ERROR("Wrong usage of option '-hfsqr'. Needs to have at least two values (e.g. '10,1')"); + } + for (unsigned i = 0; i < inputRatios.size(); i++) { + if(inputRatios[i] <= 0) { + USER_ERROR("Each ratio (supplied by option '-hfsqr') needs to be a positive integer"); + } + } + + return inputRatios; +} + +Lib::vvector Options::hoFeaturesSplitQueueCutoffs() const +{ + CALL("Options::hoFeaturesSplitQueueCutoffs"); + // initialize cutoffs and add float-max as last value + auto cutoffs = parseCommaSeparatedList(_hoFeaturesSplitQueueCutoffs.actualValue); + cutoffs.push_back(std::numeric_limits::max()); + + // sanity checks + for (unsigned i = 0; i < cutoffs.size(); i++) + { + auto cutoff = cutoffs[i]; + + if (i > 0 && cutoff <= cutoffs[i-1]) + { + USER_ERROR("The cutoff values (supplied by option '-hfsqc') must be strictly increasing"); + } + } + + return cutoffs; +} + +#endif + Lib::vvector Options::avatarSplitQueueRatios() const { CALL("Options::avatarSplitQueueRatios"); diff --git a/Shell/Options.hpp b/Shell/Options.hpp index 2d76db6995..3f018ba0f2 100644 --- a/Shell/Options.hpp +++ b/Shell/Options.hpp @@ -152,7 +152,9 @@ class Options // This dual usage is required as the property object is created during // the preprocessing stage. This means that in vampire.cpp we call this twice void randomizeStrategy(Property* prop); - + + void trySamplingStrategy(); + /** * Return the problem name * @@ -222,7 +224,9 @@ class Options ONE_INTERP, CONSTANT, ALL, - GROUND + GROUND, + AC1, + AC2, }; enum class Induction : unsigned int { @@ -283,6 +287,7 @@ class Options enum class ProofExtra : unsigned int { OFF, FREE, + UNIFIER, FULL }; enum class FMBWidgetOrders : unsigned int { @@ -377,7 +382,9 @@ class Options enum class Mode : unsigned int { AXIOM_SELECTION, CASC, +#if VHOL CASC_HOL, +#endif CASC_SAT, CASC_LTB, CLAUSIFY, @@ -402,7 +409,6 @@ class Options CASC_2019, CASC_SAT, CASC_SAT_2019, - CASC_HOL_2020, FILE, INDUCTION, INTEGER_INDUCTION, @@ -415,6 +421,10 @@ class Options SMTCOMP_2018, SNAKE_TPTP_UNS, SNAKE_TPTP_SAT, +#if VHOL + SNAKE_TPTP_HOL, + SNAKE_SLH, +#endif STRUCT_INDUCTION }; @@ -721,6 +731,7 @@ class Options WARNING = 1, }; +#if VHOL enum class FunctionExtensionality : unsigned int { OFF = 0, AXIOM = 1, @@ -732,25 +743,32 @@ class Options LAZY_GEN = 1, LAZY_SIMP = 2, LAZY_SIMP_NOT_GEN = 3, - LAZY_SIMP_NOT_GEN_BOOL_EQ_OFF = 4, - LAZY_SIMP_NOT_GEN_BOOL_EQ_GEN = 5, - OFF = 6 + LAZY_SIMP_PI_SIGMA_GEN = 4, + LAZY_SIMP_NOT_GEN_BOOL_EQ_OFF = 5, + LAZY_SIMP_NOT_GEN_BOOL_EQ_GEN = 6, + CONJ_EAGER = 7, + OFF = 8 }; enum class PISet : unsigned int { ALL = 0, ALL_EXCEPT_NOT_EQ = 1, - FALSE_TRUE_NOT = 2, - FALSE_TRUE_NOT_EQ_NOT_EQ = 3 + NOT = 2, + NOT_EQ_NOT_EQ = 3, + PRAGMATIC = 4, + AND = 5, + OR = 6, + EQUALS = 7, + PI_SIGMA = 8 }; - enum class Narrow : unsigned int { - ALL = 0, - SK = 1, - SKI = 2, - OFF = 3 + enum class HPrinting : unsigned int { + RAW = 0, + DB_INDICES = 1, + PRETTY = 2, + TPTP = 3 }; - +#endif //========================================================== // The Internals @@ -766,7 +784,10 @@ class Options // // The details are explained in comments below private: - + // helper function of trySamplingStrategy + void strategySamplingAssign(vstring optname, vstring value, DHMap& fakes); + vstring strategySamplingLookup(vstring optname, DHMap& fakes); + /** * These store the names of the choices for an option. * They can be declared using initializer lists i.e. {"on","off","half_on"} @@ -1859,6 +1880,7 @@ bool _hard; vstring msg(){ return " only useful with equality"; } }; +#if VHOL struct HasHigherOrder : OptionProblemConstraint{ CLASS_NAME(HasHigherOrder); USE_ALLOCATOR(HasHigherOrder); @@ -1882,6 +1904,7 @@ bool _hard; } vstring msg(){ return " not compatible with higher-order problems"; } }; +#endif struct MayHaveNonUnits : OptionProblemConstraint{ CLASS_NAME(MayHaveNonUnits); @@ -1964,9 +1987,11 @@ bool _hard; static OptionProblemConstraintUP hasCat(Property::Category c){ return OptionProblemConstraintUP(new CategoryCondition(c,true)); } - static OptionProblemConstraintUP hasEquality(){ return OptionProblemConstraintUP(new UsesEquality); } +#if VHOL static OptionProblemConstraintUP hasHigherOrder(){ return OptionProblemConstraintUP(new HasHigherOrder); } static OptionProblemConstraintUP onlyFirstOrder(){ return OptionProblemConstraintUP(new OnlyFirstOrder); } +#endif + static OptionProblemConstraintUP hasEquality(){ return OptionProblemConstraintUP(new UsesEquality); } static OptionProblemConstraintUP mayHaveNonUnits(){ return OptionProblemConstraintUP(new MayHaveNonUnits); } static OptionProblemConstraintUP notJustEquality(){ return OptionProblemConstraintUP(new NotJustEquality); } static OptionProblemConstraintUP atomsMoreThan(int a){ @@ -2078,6 +2103,10 @@ bool _hard; ProofExtra proofExtra() const { return _proofExtra.actualValue; } vstring printProofToFile() const { return _printProofToFile.actualValue; } int naming() const { return _naming.actualValue; } +#if VDEBUG + bool printVarBanks() const { return _printVarBanks.actualValue; } +#endif + bool printDefaultSorts() const { return _printDefaultSorts.actualValue; } bool fmbNonGroundDefs() const { return _fmbNonGroundDefs.actualValue; } unsigned fmbStartSize() const { return _fmbStartSize.actualValue;} @@ -2108,7 +2137,6 @@ bool _hard; void setNormalize(bool normalize) { _normalize.actualValue = normalize; } GoalGuess guessTheGoal() const { return _guessTheGoal.actualValue; } unsigned gtgLimit() const { return _guessTheGoalLimit.actualValue; } - void setMaxXX(unsigned max) { _maximumXXNarrows.actualValue = max; } void setNaming(int n){ _naming.actualValue = n;} //TODO: ensure global constraints vstring include() const { return _include.actualValue; } @@ -2168,8 +2196,8 @@ bool _hard; bool thiTautologyDeletion() const { return _thiTautologyDeletion.actualValue; } #endif UnificationWithAbstraction unificationWithAbstraction() const { return _unificationWithAbstraction.actualValue; } + bool unificationWithAbstractionFixedPointIteration() const { return _unificationWithAbstractionFixedPointIteration.actualValue; } void setUWA(UnificationWithAbstraction value){ _unificationWithAbstraction.actualValue = value; } - bool fixUWA() const { return _fixUWA.actualValue; } bool useACeval() const { return _useACeval.actualValue;} bool unusedPredicateDefinitionRemoval() const { return _unusedPredicateDefinitionRemoval.actualValue; } @@ -2191,7 +2219,6 @@ bool _hard; unsigned forwardSubsumptionDemodulationMaxMatches() const { return _forwardSubsumptionDemodulationMaxMatches.actualValue; } Demodulation forwardDemodulation() const { return _forwardDemodulation.actualValue; } bool binaryResolution() const { return _binaryResolution.actualValue; } - bool superposition() const {return _superposition.actualValue; } URResolution unitResultingResolution() const { return _unitResultingResolution.actualValue; } bool hyperSuperposition() const { return _hyperSuperposition.actualValue; } bool simulatenousSuperposition() const { return _simultaneousSuperposition.actualValue; } @@ -2246,6 +2273,16 @@ bool _hard; Lib::vvector theorySplitQueueCutoffs() const; int theorySplitQueueExpectedRatioDenom() const { return _theorySplitQueueExpectedRatioDenom.actualValue; } bool theorySplitQueueLayeredArrangement() const { return _theorySplitQueueLayeredArrangement.actualValue; } + +#if VHOL + bool hoFeaturesSplitQueues() const { return _hoFeaturesSplitQueues.actualValue; } + unsigned hoFeaturesLambdaWeight() const { return _hoFeaturesLambdaWeight.actualValue; } + unsigned hoFeaturesAppVarWeight() const { return _hoFeaturesAppVarWeight.actualValue; } + Lib::vvector hoFeaturesSplitQueueRatios() const; + Lib::vvector hoFeaturesSplitQueueCutoffs() const; + bool hoFeaturesSplitQueueLayeredArrangement() const { return _hoFeaturesSplitQueueLayeredArrangement.actualValue; } +#endif + bool useAvatarSplitQueues() const { return _useAvatarSplitQueues.actualValue; } Lib::vvector avatarSplitQueueRatios() const; Lib::vvector avatarSplitQueueCutoffs() const; @@ -2393,32 +2430,36 @@ bool _hard; //Higher-order Options - bool addCombAxioms() const { return _addCombAxioms.actualValue; } +#if VHOL bool addProxyAxioms() const { return _addProxyAxioms.actualValue; } - bool combinatorySup() const { return _combinatorySuperposition.actualValue; } bool choiceAxiom() const { return _choiceAxiom.actualValue; } bool injectivityReasoning() const { return _injectivity.actualValue; } bool pragmatic() const { return _pragmatic.actualValue; } bool choiceReasoning() const { return _choiceReasoning.actualValue; } - bool prioritiseClausesProducedByLongReduction() const { return _priortyToLongReducts.actualValue; } - int maxXXNarrows() const { return _maximumXXNarrows.actualValue; } + // bool prioritiseClausesProducedByLongReduction() const { return _priortyToLongReducts.actualValue; } FunctionExtensionality functionExtensionality() const { return _functionExtensionality.actualValue; } CNFOnTheFly cnfOnTheFly() const { return _clausificationOnTheFly.actualValue; } PISet piSet() const { return _piSet.actualValue; } - Narrow narrow() const { return _narrow.actualValue; } bool equalityToEquivalence () const { return _equalityToEquivalence.actualValue; } bool complexBooleanReasoning () const { return _complexBooleanReasoning.actualValue; } bool booleanEqTrick() const { return _booleanEqTrick.actualValue; } bool casesSimp() const { return _casesSimp.actualValue; } bool cases() const { return _cases.actualValue; } bool newTautologyDel() const { return _newTautologyDel.actualValue; } - bool lambdaFreeHol() const { return _lambdaFreeHol.actualValue; } - bool complexVarCondition() const { return _complexVarCondition.actualValue; } + bool positiveExtensionality() const { return _positiveExt.actualValue; } + // bool lambdaFreeHol() const { return _lambdaFreeHol.actualValue; } + bool iffXorRewriter() const { return _iffXorRewriter.actualValue; } + // TODO doesn't do anyhting currently + // bool complexVarCondition() const { return _complexVarCondition.actualValue; } + HPrinting holPrinting() const { return _holPrinting.actualValue; } + void setHolPrinting(HPrinting setting) { _holPrinting.actualValue = setting; } + bool superposition() const {return _superposition.actualValue; } + bool heuristicInstantiation() const { return _heuristicInstantiation.actualValue; } + bool applicativeUnify() const { return _applicativeUnify.actualValue; } + unsigned higherOrderUnifDepth() const { return _higherOrderUnifDepth.actualValue; } + unsigned takeNUnifiersOnly() const { return _takeNUnifiersOnly.actualValue; } +#endif // For unit testing - void useCombSup() { - _combinatorySuperposition.actualValue = true; - _complexVarCondition.actualValue = true; - } private: @@ -2536,6 +2577,14 @@ bool _hard; StringOptionValue _theorySplitQueueCutoffs; IntOptionValue _theorySplitQueueExpectedRatioDenom; BoolOptionValue _theorySplitQueueLayeredArrangement; +#if VHOL + BoolOptionValue _hoFeaturesSplitQueues; + UnsignedOptionValue _hoFeaturesLambdaWeight; + UnsignedOptionValue _hoFeaturesAppVarWeight; + StringOptionValue _hoFeaturesSplitQueueRatios; + StringOptionValue _hoFeaturesSplitQueueCutoffs; + BoolOptionValue _hoFeaturesSplitQueueLayeredArrangement; +#endif BoolOptionValue _useAvatarSplitQueues; StringOptionValue _avatarSplitQueueRatios; StringOptionValue _avatarSplitQueueCutoffs; @@ -2696,6 +2745,10 @@ bool _hard; BoolOptionValue _outputAxiomNames; StringOptionValue _printProofToFile; +#if VDEBUG + BoolOptionValue _printVarBanks; +#endif + BoolOptionValue _printDefaultSorts; BoolOptionValue _printClausifierPremises; StringOptionValue _problemName; ChoiceOptionValue _proof; @@ -2709,6 +2762,8 @@ bool _hard; UnsignedOptionValue _randomSeed; UnsignedOptionValue _randomStrategySeed; + StringOptionValue _sampleStrategy; + IntOptionValue _activationLimit; ChoiceOptionValue _satSolver; @@ -2751,6 +2806,8 @@ bool _hard; BoolOptionValue _thiTautologyDeletion; #endif ChoiceOptionValue _unificationWithAbstraction; + + BoolOptionValue _unificationWithAbstractionFixedPointIteration; BoolOptionValue _fixUWA; BoolOptionValue _useACeval; TimeLimitOptionValue _simulatedTimeLimit; @@ -2833,30 +2890,34 @@ bool _hard; ChoiceOptionValue _cancellation; ChoiceOptionValue _arithmeticSubtermGeneralizations; - +#if VHOL //Higher-order options - BoolOptionValue _addCombAxioms; BoolOptionValue _addProxyAxioms; - BoolOptionValue _combinatorySuperposition; BoolOptionValue _choiceAxiom; BoolOptionValue _injectivity; BoolOptionValue _pragmatic; BoolOptionValue _choiceReasoning; - BoolOptionValue _priortyToLongReducts; - IntOptionValue _maximumXXNarrows; + // BoolOptionValue _priortyToLongReducts; ChoiceOptionValue _functionExtensionality; ChoiceOptionValue _clausificationOnTheFly; ChoiceOptionValue _piSet; - ChoiceOptionValue _narrow; BoolOptionValue _equalityToEquivalence; BoolOptionValue _complexBooleanReasoning; BoolOptionValue _booleanEqTrick; BoolOptionValue _superposition; + BoolOptionValue _heuristicInstantiation; + BoolOptionValue _applicativeUnify; BoolOptionValue _casesSimp; BoolOptionValue _cases; BoolOptionValue _newTautologyDel; + BoolOptionValue _positiveExt; BoolOptionValue _lambdaFreeHol; - BoolOptionValue _complexVarCondition; + BoolOptionValue _iffXorRewriter; + // BoolOptionValue _complexVarCondition; + ChoiceOptionValue _holPrinting; + UnsignedOptionValue _higherOrderUnifDepth; + UnsignedOptionValue _takeNUnifiersOnly; +#endif }; // class Options diff --git a/Shell/Preprocess.cpp b/Shell/Preprocess.cpp index e33d65a834..633907ce00 100644 --- a/Shell/Preprocess.cpp +++ b/Shell/Preprocess.cpp @@ -49,7 +49,10 @@ #include "SineUtils.hpp" #include "Statistics.hpp" #include "FOOLElimination.hpp" -#include "LambdaElimination.hpp" +#if VHOL +#include "LambdaConversion.hpp" +#include "Kernel/ApplicativeHelper.hpp" +#endif #include "TheoryAxioms.hpp" #include "TheoryFlattening.hpp" #include "TweeGoalTransformation.hpp" @@ -76,9 +79,12 @@ void Preprocess::preprocess(Problem& prb) { CALL("Preprocess::preprocess"); +#if VHOL + //TODO AYB move to somewhere more appropriate if(env.options->choiceReasoning()){ env.signature->addChoiceOperator(env.signature->getChoice()); } +#endif if (env.options->showPreprocessing()) { env.beginOutput(); @@ -139,11 +145,19 @@ void Preprocess::preprocess(Problem& prb) } } - if (prb.hasFOOL() || prb.higherOrder()) { + if (prb.hasFOOL() +#if VHOL + || prb.higherOrder() +#endif + ) { // This is the point to extend the signature with $$true and $$false // If we don't have fool then these constants get in the way (a lot) - if (!_options.newCNF() || prb.hasPolymorphicSym() || prb.higherOrder()) { + if (!_options.newCNF() || prb.hasPolymorphicSym() +#if VHOL + || prb.higherOrder() +#endif + ) { if (env.options->showPreprocessing()) env.out() << "FOOL elimination" << std::endl; @@ -152,23 +166,48 @@ void Preprocess::preprocess(Problem& prb) } } +prb.getProperty(); + +#if VHOL if(env.options->functionExtensionality() == Options::FunctionExtensionality::AXIOM){ - LambdaElimination::addFunctionExtensionalityAxiom(prb); + if(!env.property->higherOrder()){ + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: ignoring request to add function extensionality axiom as problem is first-order" << std::endl; + env.endOutput(); + } + } else { + LambdaConversion::addFunctionExtensionalityAxiom(prb); + } } if(env.options->choiceAxiom()){ - LambdaElimination::addChoiceAxiom(prb); - } - - prb.getProperty(); - - if ((prb.hasCombs() || prb.hasAppliedVar()) && env.options->addCombAxioms()){ - LambdaElimination::addCombinatorAxioms(prb); + if(!env.property->higherOrder()){ + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: ignoring request to add choice axiom as problem is first-order" << std::endl; + env.endOutput(); + } + } else { + LambdaConversion::addChoiceAxiom(prb); + } } - if ((prb.hasLogicalProxy() || prb.hasBoolVar()) && env.options->addProxyAxioms()){ - LambdaElimination::addProxyAxioms(prb); + if (env.options->addProxyAxioms()){ + if(!env.property->higherOrder()){ + if (outputAllowed()) { + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: ignoring request to add logical proxy axioms as problem is first-order" << std::endl; + env.endOutput(); + } + } else { + LambdaConversion::addProxyAxioms(prb); + } } +#endif if (prb.hasInterpretedOperations() || env.signature->hasTermAlgebras()){ // Some axioms needed to be normalized, so we call InterpretedNormalizer twice @@ -271,14 +310,20 @@ void Preprocess::preprocess(Problem& prb) } if (prb.mayHaveFormulas() && _options.newCNF() && - !prb.hasPolymorphicSym() && !prb.higherOrder()) { + !prb.hasPolymorphicSym() +#if VHOL + && !prb.higherOrder() +#endif + ) { if (env.options->showPreprocessing()) env.out() << "newCnf" << std::endl; newCnf(prb); } else { if (prb.mayHaveFormulas() && _options.newCNF()) { // TODO: update newCNF to deal with polymorphism / higher-order +#if VHOL ASS(prb.hasPolymorphicSym() || prb.higherOrder()); +#endif if (outputAllowed()) { env.beginOutput(); addCommentSignForSZS(env.out()); @@ -363,7 +408,11 @@ void Preprocess::preprocess(Problem& prb) } if (_options.generalSplitting()) { - if (prb.higherOrder() || prb.hasPolymorphicSym()) { // TODO: extend GeneralSplitting to support polymorphism (would higher-order make sense?) + if ( +#if VHOL + prb.higherOrder() || +#endif + prb.hasPolymorphicSym()) { // TODO: extend GeneralSplitting to support polymorphism (would higher-order make sense?) if (outputAllowed()) { env.beginOutput(); addCommentSignForSZS(env.out()); @@ -389,7 +438,17 @@ void Preprocess::preprocess(Problem& prb) twee.apply(prb,(env.options->tweeGoalTransformation() == Options::TweeGoalTransformation::GROUND)); } - if (!prb.higherOrder() && _options.equalityProxy()!=Options::EqualityProxy::OFF && prb.mayHaveEquality()) { +#if VHOL + if(env.property->higherOrder() && env.options->heuristicInstantiation()){ + findAbstractions(prb.units()); + } +#endif + + if ( +#if VHOL + !prb.higherOrder() && +#endif + _options.equalityProxy()!=Options::EqualityProxy::OFF && prb.mayHaveEquality()) { env.statistics->phase=Statistics::EQUALITY_PROXY; if (env.options->showPreprocessing()) env.out() << "equality proxy" << std::endl; @@ -423,12 +482,23 @@ void Preprocess::preprocess(Problem& prb) } if (_options.blockedClauseElimination()) { - env.statistics->phase=Statistics::BLOCKED_CLAUSE_ELIMINATION; - if(env.options->showPreprocessing()) - env.out() << "blocked clause elimination" << std::endl; - - BlockedClauseElimination bce; - bce.apply(prb); +#if VHOL + if(prb.higherOrder()){ + env.beginOutput(); + addCommentSignForSZS(env.out()); + env.out() << "WARNING: blocked clause elimination is currently not compatible with higher-order. Ignoring request to use." << endl; + env.endOutput(); + } else { +#endif + env.statistics->phase=Statistics::BLOCKED_CLAUSE_ELIMINATION; + if(env.options->showPreprocessing()) + env.out() << "blocked clause elimination" << std::endl; + + BlockedClauseElimination bce; + bce.apply(prb); +#if VHOL + } +#endif } if (_options.shuffleInput()) { @@ -468,6 +538,31 @@ void Preprocess::preprocess(Problem& prb) } } // Preprocess::preprocess () +#if VHOL +void Preprocess::findAbstractions(UnitList*& units){ + CALL("Preprocess::findAbstractions"); + + UnitList::RefIterator uit(units); + while (uit.hasNext()) { + Unit* &u = uit.next(); + if (!u->derivedFromGoal()) + continue; + + ASS(u->isClause()); + Clause* c = u->asClause(); + + for(unsigned i = 0; i < c->length(); i++){ + Literal* lit = (*c)[i]; + TermStack abstractionTerms; + ApplicativeHelper::getAbstractionTerms(lit, abstractionTerms); + while(!abstractionTerms.isEmpty()){ + env.signature->addInstantiation(abstractionTerms.pop()); + } + } + } +} +#endif + /** * Preprocess the unit using options from opt. Preprocessing may @@ -506,7 +601,11 @@ void Preprocess::preprocess1 (Problem& prb) fu = Rectify::rectify(fu); FormulaUnit* rectFu = fu; // Simplify the formula if it contains true or false - if (!_options.newCNF() || prb.higherOrder() || prb.hasPolymorphicSym()) { + if (!_options.newCNF() +#if VHOL + || prb.higherOrder() +#endif + || prb.hasPolymorphicSym()) { // NewCNF effectively implements this simplification already (but could have been skipped if higherOrder || hasPolymorphicSym) fu = SimplifyFalseTrue::simplify(fu); } @@ -573,7 +672,11 @@ void Preprocess::naming(Problem& prb) env.statistics->phase=Statistics::NAMING; UnitList::DelIterator us(prb.units()); //TODO fix the below - Naming naming(_options.naming(),false, prb.higherOrder()); // For now just force eprPreservingNaming to be false, should update Naming + Naming naming(_options.naming(),false +#if VHOL + , prb.higherOrder() +#endif + ); // For now just force eprPreservingNaming to be false, should update Naming while (us.hasNext()) { Unit* u = us.next(); if (u->isClause()) { @@ -703,7 +806,11 @@ void Preprocess::preprocess3 (Problem& prb) UnitList::DelIterator us(prb.units()); while (us.hasNext()) { Unit* u = us.next(); - Unit* v = preprocess3(u, prb.higherOrder()); + Unit* v = preprocess3(u +#if VHOL + ,prb.higherOrder() +#endif + ); if (u!=v) { us.replace(v); modified = true; diff --git a/Shell/Preprocess.hpp b/Shell/Preprocess.hpp index 1d36c9eb19..bd8d1417f4 100644 --- a/Shell/Preprocess.hpp +++ b/Shell/Preprocess.hpp @@ -49,10 +49,14 @@ class Preprocess private: void preprocess2(Problem& prb); void naming(Problem& prb); - Unit* preprocess3(Unit* u, bool appify /*higher order stuff*/); + Unit* preprocess3(Unit* u, bool appify = false/*higher order stuff*/); void preprocess3(Problem& prb); void clausify(Problem& prb); +#if VHOL + void findAbstractions(UnitList*& units); +#endif + void newCnf(Problem& prb); /** Options used in the normalisation */ diff --git a/Shell/Property.cpp b/Shell/Property.cpp index f5ad6b4324..d2068efb6f 100644 --- a/Shell/Property.cpp +++ b/Shell/Property.cpp @@ -28,7 +28,9 @@ #include "Kernel/Signature.hpp" #include "Kernel/Inference.hpp" #include "Kernel/TermIterators.hpp" +#if VHOL #include "Kernel/ApplicativeHelper.hpp" +#endif #include "Options.hpp" #include "Statistics.hpp" @@ -74,13 +76,14 @@ Property::Property() _hasNonDefaultSorts(false), _sortsUsed(0), _hasFOOL(false), - _hasCombs(false), + _hasBoolVar(false), +#if VHOL _hasArrowSort(false), _hasApp(false), - _hasAppliedVar(false), - _hasBoolVar(false), _hasLogicalProxy(false), _hasLambda(false), + _higherOrder(false), +#endif _hasPolymorphicSym(false), _quantifiesOverPolymorphicVar(false), _onlyFiniteDomainDatatypes(true), @@ -508,11 +511,17 @@ void Property::scanSort(TermList sort) return; } +#if VHOL if(sort.isArrowSort()){ _hasArrowSort = true; } +#endif - if(!higherOrder() && !hasPolymorphicSym()){ + if( +#if VHOL + !higherOrder() && +#endif + !hasPolymorphicSym()){ //used sorts is for FMB which is not compatible with //higher-order or polymorphism unsigned sortU = sort.term()->functor(); @@ -554,7 +563,10 @@ void Property::scanSort(TermList sort) return; } - TermList resultSort = ApplicativeHelper::getResultSort(sort); + TermList resultSort = sort; +#if VHOL + resultSort = sort.finalResult(); +#endif if(resultSort == AtomicSort::boolSort()){ _hasFOOL = true; } @@ -595,8 +607,11 @@ void Property::scan(Literal* lit, int polarity, unsigned cLen, bool goal) if((lhs.isVar() || rhs.isVar()) && eqSort == AtomicSort::boolSort()){ _hasBoolVar = true; } - if((eqSort.isVar() || eqSort.term()->arity()) && - !eqSort.isArrowSort() && !eqSort.isArraySort() && !eqSort.isTupleSort()){ + if((eqSort.isVar() || eqSort.term()->arity()) +#if VHOL + && !eqSort.isArrowSort() +#endif + && !eqSort.isArraySort() && !eqSort.isTupleSort()){ _hasPolymorphicSym = true; } scanSort(eqSort); @@ -686,11 +701,11 @@ void Property::scan(TermList ts,bool unit,bool goal) case Term::SF_MATCH: _hasFOOL = true; break; - +#if VHOL case Term::SF_LAMBDA: _hasLambda = true; break; - +#endif default: break; } @@ -710,31 +725,32 @@ void Property::scan(TermList ts,bool unit,bool goal) if(unit){ func->markInUnit();} if(goal){ func->markInGoal();} +#if VHOL if(t->isApplication()){ _hasApp = true; TermList sort = SortHelper::getResultSort(t); - if(ApplicativeHelper::getResultSort(sort) == AtomicSort::boolSort()){ - TermList head = ApplicativeHelper::getHead(ts); - if(head.isVar()){ - _hasBoolVar = true; - } + if(sort.finalResult().isBoolSort() && ts.head().isVar()){ + _hasBoolVar = true; } } - if(func->combinator() != Signature::NOT_COMB){ - _hasCombs = true; - } else if(func->proxy() != Signature::NOT_PROXY){ + if(func->proxy() != Signature::NOT_PROXY){ if(func->proxy() == Signature::PI || func->proxy() == Signature::SIGMA){ ASS(t->arity() == 1); TermList sort = *t->nthArgument(0); - if(ApplicativeHelper::getResultSort(sort) == AtomicSort::boolSort()){ + if(sort.finalResult().isBoolSort()){ _hasBoolVar = true; } } _hasLogicalProxy = true; } +#endif - if(!t->isApplication() && t->numTypeArguments() > 0){ + if( +#if VHOL + !t->isApplication() && !t->isLambdaTerm() && +#endif + t->numTypeArguments() > 0){ _hasPolymorphicSym = true; } diff --git a/Shell/Property.hpp b/Shell/Property.hpp index bd1268b8c7..8417504098 100644 --- a/Shell/Property.hpp +++ b/Shell/Property.hpp @@ -191,6 +191,12 @@ class Property int maxFunArity() const { return _maxFunArity; } /** Maximal arity of a type con in the problem */ unsigned maxTypeConArity() const { return _maxTypeConArity; } +#if VDEBUG + // for use by polymorphic unit tests + // have to force the type con arity to avoid + // running KBOforEPR + void forceMaxTypeConArity() { _maxTypeConArity = 1; } +#endif /** Total number of variables in problem */ int totalNumberOfVariables() const { return _totalNumberOfVariables;} @@ -226,15 +232,19 @@ class Property /** Problem contains non-default sorts */ bool hasNonDefaultSorts() const { return _hasNonDefaultSorts; } bool hasFOOL() const { return _hasFOOL; } - bool hasCombs() const { return _hasCombs;} + bool hasBoolVar() const { return _hasBoolVar; } + +#if VHOL bool hasArrowSort() const { return _hasArrowSort; } bool hasApp() const { return _hasApp; } - bool hasAppliedVar() const { return _hasAppliedVar; } - bool hasBoolVar() const { return _hasBoolVar; } bool hasLogicalProxy() const { return _hasLogicalProxy; } + bool higherOrder() const { return hasApp() || hasLogicalProxy() || + hasArrowSort() || _hasLambda || _higherOrder; } + // for use in unit tests + void forceHigherOrder() { _higherOrder = true; } +#endif + bool hasPolymorphicSym() const { return _hasPolymorphicSym; } - bool higherOrder() const { return hasCombs() || hasApp() || hasLogicalProxy() || - hasArrowSort() || _hasLambda; } bool quantifiesOverPolymorphicVar() const { return _quantifiesOverPolymorphicVar; } bool usesSort(unsigned sort) const { CALL("Property::usesSort"); @@ -330,13 +340,14 @@ class Property DHSet _polymorphicInterpretations; bool _hasFOOL; - bool _hasCombs; + bool _hasBoolVar; +#if VHOL bool _hasArrowSort; bool _hasApp; - bool _hasAppliedVar; - bool _hasBoolVar; bool _hasLogicalProxy; bool _hasLambda; + bool _higherOrder; +#endif bool _hasPolymorphicSym; bool _quantifiesOverPolymorphicVar; diff --git a/Shell/Rectify.cpp b/Shell/Rectify.cpp index 29e8202a80..9a5143f9f1 100644 --- a/Shell/Rectify.cpp +++ b/Shell/Rectify.cpp @@ -197,6 +197,7 @@ Term* Rectify::rectifySpecialTerm(Term* t) } return Term::createFormula(orig); } +#if VHOL case Term::SF_LAMBDA: { ASS_EQ(t->arity(),0); @@ -231,6 +232,7 @@ Term* Rectify::rectifySpecialTerm(Term* t) } return Term::createLambda(lambdaTerm, vs, rectifiedSorts, lambdaTermS); } +#endif case Term::SF_TUPLE: { ASS_EQ(t->arity(),0); diff --git a/Shell/Shuffling.cpp b/Shell/Shuffling.cpp index 2892e79874..ece4404933 100644 --- a/Shell/Shuffling.cpp +++ b/Shell/Shuffling.cpp @@ -208,13 +208,15 @@ void Shuffling::shuffleIter(Shufflable sh) { //cout << "Shuffling FORALL/EXISTS: " << fla->toString() << endl; - // can even shuffle the variables in the quantifier! - if (fla->sorts()) { // need to shuffle sorts in sync with vars, if they are there - shuffleTwoList(*fla->varsPtr(),*fla->sortsPtr()); - } else { - shuffleList(*fla->varsPtr()); + // can't naively shuffle variables in the polymorphic case + // as we require type variables to come before term variable in the list + if(!env.property->hasPolymorphicSym()){ + if (fla->sorts()) { // need to shuffle sorts in sync with vars, if they are there + shuffleTwoList(*fla->varsPtr(),*fla->sortsPtr()); + } else { + shuffleList(*fla->varsPtr()); + } } - //cout << "getting: " << fla->toString() << endl; fla = fla->qarg(); @@ -287,6 +289,13 @@ void Shuffling::shuffleIter(Shufflable sh) { goto tl_updated; break; // I know, unreachable; +#if VHOL + case Term::SF_LAMBDA: + tl = TermList(sd->getLambdaExp()); + goto tl_updated; + break; // I know, unreachable; +#endif + default: ASSERTION_VIOLATION_REP(tl.toString()); } diff --git a/Shell/Skolem.cpp b/Shell/Skolem.cpp index 74ddada8ea..dd426e8831 100644 --- a/Shell/Skolem.cpp +++ b/Shell/Skolem.cpp @@ -23,7 +23,9 @@ #include "Kernel/SortHelper.hpp" #include "Kernel/SubformulaIterator.hpp" #include "Kernel/TermIterators.hpp" +#if VHOL #include "Kernel/ApplicativeHelper.hpp" +#endif #include "Lib/SharedSet.hpp" #include "Shell/NameReuse.hpp" @@ -74,7 +76,9 @@ FormulaUnit* Skolem::skolemiseImpl (FormulaUnit* unit, bool appify) ASS(_introducedSkolemSyms.isEmpty()); +#if VHOL _appify = appify; +#endif _beingSkolemised=unit; _skolimizingDefinitions = UnitList::empty(); _varOccs.reset(); @@ -101,10 +105,20 @@ FormulaUnit* Skolem::skolemiseImpl (FormulaUnit* unit, bool appify) ASS(_introducedSkolemSyms.isNonEmpty()); while(_introducedSkolemSyms.isNonEmpty()) { - unsigned fn = _introducedSkolemSyms.pop(); - InferenceStore::instance()->recordIntroducedSymbol(res,true,fn); + auto symPair = _introducedSkolemSyms.pop(); + + if(symPair.first){ + InferenceStore::instance()->recordIntroducedSymbol(res,SymbolType::TYPE_CON,symPair.second); + } else { + InferenceStore::instance()->recordIntroducedSymbol(res,SymbolType::FUNC,symPair.second); + } + if(unit->derivedFromGoal()){ - env.signature->getFunction(fn)->markInGoal(); + if(symPair.first){ + env.signature->getTypeCon(symPair.second)->markInGoal(); + } else { + env.signature->getFunction(symPair.second)->markInGoal(); + } } } @@ -464,7 +478,11 @@ Formula* Skolem::skolemise (Formula* f) arity++; } - for(unsigned i = 0; i < termVars.size() && !_appify; i++){ + for(unsigned i = 0; i < termVars.size() +#if VHOL + && !_appify +#endif + ; i++){ allVars.push(termVars[i]); } SortHelper::normaliseArgSorts(typeVars, termVarSorts); @@ -497,6 +515,10 @@ Formula* Skolem::skolemise (Formula* f) TermList rangeSort=_varSorts.get(v, AtomicSort::defaultSort()); bool skolemisingTypeVar = rangeSort == AtomicSort::superSort(); + if(skolemisingTypeVar && termVars.size()){ + USER_ERROR("TH1 does not permit an existential type quantifer underneath a univesal term quantifier"); + } + if(rangeSort.isVar() || !rangeSort.term()->shared() || !rangeSort.term()->ground()) { //the range sort may include existential type variables that have been skolemised above @@ -506,7 +528,9 @@ Formula* Skolem::skolemise (Formula* f) SortHelper::normaliseSort(typeVars, rangeSort); Term* skolemTerm; +#if VHOL if(!_appify || skolemisingTypeVar){ +#endif //Not the higher-order case. Create the term //sk(typevars, termvars). if(skolemisingTypeVar){ @@ -518,6 +542,7 @@ Formula* Skolem::skolemise (Formula* f) sym = addSkolemFunction(arity, termVarSorts.begin(), rangeSort, v, typeVars.size()); skolemTerm = Term::create(sym, arity, allVars.begin()); } +#if VHOL } else { //The higher-order case. Create the term //sk(typevars) @ termvar_1 @ termvar_2 @ ... @ termvar_n @@ -525,10 +550,10 @@ Formula* Skolem::skolemise (Formula* f) if(!successfully_reused) sym = addSkolemFunction(typeVars.size(), 0, skSymSort, v, typeVars.size()); TermList head = TermList(Term::create(sym, typeVars.size(), typeVars.begin())); - skolemTerm = ApplicativeHelper::createAppTerm( - SortHelper::getResultSort(head.term()), head, termVars).term(); + skolemTerm = ApplicativeHelper::app(head, termVars).term(); } - _introducedSkolemSyms.push(sym); +#endif + _introducedSkolemSyms.push(make_pair(skolemisingTypeVar, sym)); if(!successfully_reused) { env.statistics->skolemFunctions++; @@ -561,7 +586,7 @@ Formula* Skolem::skolemise (Formula* f) } #if VDEBUG - ASS(first_pass || sym == last_sym+1); + ASS(!name_reuse || first_pass || sym == last_sym+1); last_sym = sym; #endif // in case we are reusing and there is more than one f->vars() in the block diff --git a/Shell/Skolem.hpp b/Shell/Skolem.hpp index e3aee8d3d4..8e27b547fb 100644 --- a/Shell/Skolem.hpp +++ b/Shell/Skolem.hpp @@ -42,7 +42,9 @@ namespace Shell { class Skolem { public: - static FormulaUnit* skolemise(FormulaUnit*, bool appify = false); + // AYB perhaps should hide appify behind compiler directive + // but resulting code is seriously ugly + static FormulaUnit* skolemise(FormulaUnit* , bool appify = false); static unsigned addSkolemFunction(unsigned arity, TermList* domainSorts, TermList rangeSort, unsigned var, unsigned taArity = 0); static unsigned addSkolemFunction(unsigned arity, unsigned taArity, TermList* domainSorts, TermList rangeSort, const char* suffix=0); static unsigned addSkolemTypeCon(unsigned arity, unsigned var); @@ -107,14 +109,16 @@ class Skolem DHMap _varSorts; // for some heuristic evaluations after we are done - Stack _introducedSkolemSyms; + Stack> _introducedSkolemSyms; FormulaUnit* _beingSkolemised; // to create one big inference after we are done UnitList* _skolimizingDefinitions; +#if VHOL bool _appify; // a higher-order solution +#endif }; // class Skolem diff --git a/Shell/Statistics.cpp b/Shell/Statistics.cpp index ee174c33c3..7d2b8b1fd1 100644 --- a/Shell/Statistics.cpp +++ b/Shell/Statistics.cpp @@ -95,17 +95,18 @@ Statistics::Statistics() inductionApplicationInProof(0), generalizedInductionApplication(0), generalizedInductionApplicationInProof(0), +#if VHOL argumentCongruence(0), - narrow(0), - forwardSubVarSup(0), - backwardSubVarSup(0), - selfSubVarSup(0), negativeExtensionality(0), + positiveExtensionality(0), primitiveInstantiations(0), choiceInstances(0), proxyEliminations(0), leibnizElims(0), booleanSimps(0), + injectiveFunInverses(0), + boolEqTricks(0), +#endif duplicateLiterals(0), trivialInequalities(0), forwardSubsumptionResolution(0), @@ -197,7 +198,7 @@ void Statistics::explainRefutationNotFound(ostream& out) out << "Refutation not found, SMT solver inside AVATAR failed to evaluate a literal\n"; } else { - out << "Refutation not found, incomplete strategy"; + out << "Refutation not found, incomplete strategy\n"; } } @@ -306,7 +307,10 @@ void Statistics::print(ostream& out) HEADING("Simplifying Inferences",duplicateLiterals+trivialInequalities+ - forwardSubsumptionResolution+backwardSubsumptionResolution+proxyEliminations+ + forwardSubsumptionResolution+backwardSubsumptionResolution+ +#if VHOL + proxyEliminations+ +#endif forwardDemodulations+backwardDemodulations+forwardLiteralRewrites+ forwardSubsumptionDemodulations+backwardSubsumptionDemodulations+ condensations+globalSubsumption+evaluationCnt @@ -314,7 +318,9 @@ void Statistics::print(ostream& out) +( asgCnt - asgViolations) +( evaluationCnt - evaluationIncomp - evaluationGreater) +innerRewrites +#if VHOL +booleanSimps +#endif ); COND_OUT("Duplicate literals", duplicateLiterals); COND_OUT("Trivial inequalities", trivialInequalities); @@ -339,8 +345,10 @@ void Statistics::print(ostream& out) COND_OUT("Evaluation count", evaluationCnt); COND_OUT("Evaluation results greater than premise", evaluationGreater); COND_OUT("Evaluation results incomparable to premise", evaluationIncomp); +#if VHOL COND_OUT("Logicial proxy rewrites", proxyEliminations); COND_OUT("Boolean simplifications", booleanSimps) +#endif //COND_OUT("Interpreted simplifications", interpretedSimplifications); SEPARATOR; @@ -362,10 +370,13 @@ void Statistics::print(ostream& out) HEADING("Generating Inferences",resolution+urResolution+cResolution+factoring+ forwardSuperposition+backwardSuperposition+selfSuperposition+ - cForwardSuperposition+cBackwardSuperposition+cSelfSuperposition+leibnizElims+ + cForwardSuperposition+cBackwardSuperposition+cSelfSuperposition+ equalityFactoring+equalityResolution+forwardExtensionalityResolution+ - backwardExtensionalityResolution+argumentCongruence+negativeExtensionality+ - +primitiveInstantiations+choiceInstances+narrow+forwardSubVarSup+backwardSubVarSup+selfSubVarSup+ + backwardExtensionalityResolution+ +#if VHOL + argumentCongruence+leibnizElims+negativeExtensionality+ + +primitiveInstantiations+choiceInstances+positiveExtensionality+injectiveFunInverses+boolEqTricks+ +#endif theoryInstSimp+theoryInstSimpCandidates+theoryInstSimpTautologies+theoryInstSimpLostSolution+inductionApplication+generalizedInductionApplication); COND_OUT("Binary resolution", resolution); COND_OUT("Unit resulting resolution", urResolution); @@ -411,15 +422,16 @@ void Statistics::print(ostream& out) COND_OUT("InductionApplicationsInProof",inductionApplicationInProof); COND_OUT("GeneralizedInductionApplications",generalizedInductionApplication); COND_OUT("GeneralizedInductionApplicationsInProof",generalizedInductionApplicationInProof); +#if VHOL COND_OUT("Argument congruence", argumentCongruence); COND_OUT("Negative extensionality", negativeExtensionality); - COND_OUT("Primitive substitutions", primitiveInstantiations); - COND_OUT("Elimination of Leibniz equalities", leibnizElims); - COND_OUT("Choice axiom instances creatded", choiceInstances); - COND_OUT("Narrow", narrow); - COND_OUT("Forward sub-variable superposition", forwardSubVarSup); - COND_OUT("Backward sub-variable superposition", backwardSubVarSup); - COND_OUT("Self sub-variable superposition", selfSubVarSup); + COND_OUT("Positive extensionality", positiveExtensionality); + COND_OUT("Primitive substitution", primitiveInstantiations); + COND_OUT("Elimination of Leibniz equality", leibnizElims); + COND_OUT("Inverse function postulation", injectiveFunInverses); + COND_OUT("Boolean equality to disequality", boolEqTricks); + COND_OUT("Choice axiom instance", choiceInstances); +#endif SEPARATOR; HEADING("Term algebra simplifications",taDistinctnessSimplifications+ @@ -520,6 +532,8 @@ const char* Statistics::phaseToString(ExecutionPhase p) return "Unused predicate definition removal"; case BLOCKED_CLAUSE_ELIMINATION: return "Blocked clause elimination"; + case TWEE: + return "Twee Goal Transformation"; case PREPROCESS_2: return "Preprocessing 2"; case NEW_CNF: diff --git a/Shell/Statistics.hpp b/Shell/Statistics.hpp index b70f9dda24..2f602496d9 100644 --- a/Shell/Statistics.hpp +++ b/Shell/Statistics.hpp @@ -151,17 +151,18 @@ class Statistics unsigned generalizedInductionApplication; unsigned generalizedInductionApplicationInProof; /** number of argument congruences */ +#if VHOL unsigned argumentCongruence; - unsigned narrow; - unsigned forwardSubVarSup; - unsigned backwardSubVarSup; - unsigned selfSubVarSup; unsigned negativeExtensionality; + unsigned positiveExtensionality; unsigned primitiveInstantiations; unsigned choiceInstances; unsigned proxyEliminations; unsigned leibnizElims; unsigned booleanSimps; + unsigned injectiveFunInverses; + unsigned boolEqTricks; +#endif // Simplifying inferences /** number of duplicate literals deleted */ diff --git a/Shell/SubexpressionIterator.cpp b/Shell/SubexpressionIterator.cpp index 2d2653166e..69b794c2a8 100644 --- a/Shell/SubexpressionIterator.cpp +++ b/Shell/SubexpressionIterator.cpp @@ -148,10 +148,11 @@ namespace Shell { _subexpressions.push(Expression(*term->nthArgument(0), polarity)); break; +#if VHOL case Term::SF_LAMBDA: _subexpressions.push(Expression(sd->getLambdaExp(), polarity)); break; - +#endif /*case Term::SF_TUPLE: _subexpressions.push(Expression(sd->getTupleTerm())); break; */ diff --git a/Shell/SymCounter.cpp b/Shell/SymCounter.cpp index 9bdd1d63d5..b17bdbbd4b 100644 --- a/Shell/SymCounter.cpp +++ b/Shell/SymCounter.cpp @@ -253,6 +253,7 @@ void SymCounter::count(Term* term, int polarity, int add) count(sd->getTupleTerm(), 0, add); break; } +#if VHOL case Term::SF_LAMBDA: { TermList lambdaExp = sd->getLambdaExp(); if(lambdaExp.isTerm()){ @@ -260,6 +261,7 @@ void SymCounter::count(Term* term, int polarity, int add) } break; } +#endif case Term::SF_MATCH: { for (unsigned i = 0; i < term->arity(); i++) { TermList t = *term->nthArgument(i); diff --git a/Shell/TPTPPrinter.cpp b/Shell/TPTPPrinter.cpp index 27883c3c71..038dcd3fe6 100644 --- a/Shell/TPTPPrinter.cpp +++ b/Shell/TPTPPrinter.cpp @@ -234,9 +234,11 @@ void TPTPPrinter::outputSymbolTypeDefinitions(unsigned symNumber, SymbolType sym } vstring cat = "tff("; +#if VHOL if(env.property->higherOrder()){ cat = "thf("; } +#endif vstring st = "func"; if(symType == SymbolType::PRED){ diff --git a/Shell/TPTPPrinter.hpp b/Shell/TPTPPrinter.hpp index 1797c1e617..968987090d 100644 --- a/Shell/TPTPPrinter.hpp +++ b/Shell/TPTPPrinter.hpp @@ -33,9 +33,7 @@ using namespace Kernel; class TPTPPrinter { public: TPTPPrinter(ostream* tgtStream=0); - - enum SymbolType{FUNC, PRED, TYPE_CON}; - + void print(Unit* u); void printAsClaim(vstring name, Unit* u); void printWithRole(vstring name, vstring role, Unit* u, bool includeSplitLevels = true); diff --git a/Shell/TheoryAxioms.cpp b/Shell/TheoryAxioms.cpp index e19bd93cd9..288e5f7139 100644 --- a/Shell/TheoryAxioms.cpp +++ b/Shell/TheoryAxioms.cpp @@ -1146,8 +1146,13 @@ void TheoryAxioms::applyFOOL() { addTheoryClauseFromLits({tneqf},InferenceRule::FOOL_AXIOM_TRUE_NEQ_FALSE,CHEAP); // Do not add the finite domain axiom if --fool_paradomulation on - if (env.options->FOOLParamodulation() || env.options->cases() || - env.options->casesSimp()) { + if (env.options->FOOLParamodulation() +#if VHOL + || env.options->cases() || env.options->casesSimp() || env.property->higherOrder() + // never want to add these axioms in higher-order. Either deal with Bools using + // cases or using unification with abstraction +#endif + ) { return; } diff --git a/Shell/TweeGoalTransformation.cpp b/Shell/TweeGoalTransformation.cpp index fb8a83d76b..0d7e471c52 100644 --- a/Shell/TweeGoalTransformation.cpp +++ b/Shell/TweeGoalTransformation.cpp @@ -66,6 +66,8 @@ class Definizator : public BottomUpTermTransformer { bool _groundOnly; unsigned _typeArity; + TermStack _typeVars; + TermStack _termVars; TermStack _allVars; // including typeVars, which will come first, then termVars TermStack _termVarSorts; @@ -78,8 +80,8 @@ class Definizator : public BottomUpTermTransformer { varSeen.reset(); _typeArity = 0; _allVars.reset(); - static TermStack termVars; - termVars.reset(); + _typeVars.reset(); + _termVars.reset(); _termVarSorts.reset(); // fake scanVars cheaply @@ -88,23 +90,28 @@ class Definizator : public BottomUpTermTransformer { VariableWithSortIterator it(t); while (it.hasNext()) { auto varAndSort = it.next(); - unsigned v = varAndSort.first.var(); + TermList v = varAndSort.first; TermList s = varAndSort.second; - if (varSeen.insert(v)) { + if (varSeen.insert(v.var())) { if(s == AtomicSort::superSort()) { - _allVars.push(TermList(v,false)); + _allVars.push(v); + _typeVars.push(v); } else { - termVars.push(TermList(v,false)); - _termVarSorts.push(varAndSort.second); + _termVars.push(v); + _termVarSorts.push(s); } } } _typeArity = _allVars.size(); // allVars only collected typeVars until now - for(unsigned i = 0; i < termVars.size(); i++){ - _allVars.push(termVars[i]); + for(unsigned i = 0; i < _termVars.size() +#if VHOL + && !env.property->higherOrder() +#endif + ; i++){ + _allVars.push(_termVars[i]); } - ASS_EQ(_typeArity+_termVarSorts.size(), _allVars.size()) + SortHelper::normaliseArgSorts(_typeVars, _termVarSorts); } protected: @@ -113,9 +120,15 @@ class Definizator : public BottomUpTermTransformer { // cout << "tf: " << trm.toString() << endl; if (trm.isVar()) return trm; + Term* t = trm.term(); if (t->isSort() || t->arity() == 0 || (!t->ground() && _groundOnly)) return trm; +#if VHOL + if (env.property->higherOrder() && trm.containsLooseIndex()) + { return trm; } +#endif + Term* key = t; if (!t->ground()) { // as we go bottom up, t is never too big (well, it could be wide, but at least not deep) @@ -133,21 +146,37 @@ class Definizator : public BottomUpTermTransformer { Clause* newDef; scanVars(t); + SortHelper::normaliseSort(_typeVars, outSort); + + // will the definition folding decrease term weight? // (whether we will also demodulate in this direction may depend on the ordering, but with a constant-weight KBO we will) if (t->weight() > _allVars.size()+1) { // this is always true in the ground case (where t->weight()>=2 and _allVars.size() == 0) +#if VHOL + if(!env.property->higherOrder()){ +#endif + newSym = env.signature->addFreshFunction(_allVars.size(), "sF"); + OperatorType* type = OperatorType::getFunctionType(_termVarSorts.size(),_termVarSorts.begin(),outSort,_typeArity); + env.signature->getFunction(newSym)->setType(type); - newSym = env.signature->addFreshFunction(_allVars.size(), "sF"); - OperatorType* type = OperatorType::getFunctionType(_termVarSorts.size(),_termVarSorts.begin(),outSort,_typeArity); - env.signature->getFunction(newSym)->setType(type); + // res is used both to replace here, but also in the new definition + res = TermList(Term::create(newSym,_allVars.size(),_allVars.begin())); +#if VHOL + } else { + newSym = env.signature->addFreshFunction(_typeVars.size(), "sF"); + TermList sort = AtomicSort::arrowSort(_termVarSorts, outSort); + Signature::Symbol* sym = env.signature->getFunction(newSym); + sym->setType(OperatorType::getConstantsType(sort, _typeVars.size())); - // res is used both to replace here, but also in the new definition - res = TermList(Term::create(newSym,_allVars.size(),_allVars.begin())); + TermList head = TermList(Term::create(newSym, _typeVars.size(), _typeVars.begin())); + res= ApplicativeHelper::app(head, _termVars); + } +#endif // (we don't care the definition is not rectified, as long as it's correct) // it is correct, because the lhs below is t and not key - Literal* equation = Literal::createEquality(true, TermList(t), res, outSort); + Literal* equation = Literal::createEquality(true, TermList(t), res, SortHelper::getResultSort(res.term())); Inference inference(NonspecificInference0(UnitInputType::AXIOM,InferenceRule::FUNCTION_DEFINITION)); newDef = new (1) Clause(1, inference); newDef->literals()[0] = equation; @@ -174,7 +203,17 @@ class Definizator : public BottomUpTermTransformer { } scanVars(t); - res = TermList(Term::create(symAndDef.first,_allVars.size(),_allVars.begin())); +#if VHOL + if(!env.property->higherOrder()){ +#endif + res = TermList(Term::create(symAndDef.first,_allVars.size(),_allVars.begin())); +#if VHOL + } else { + TermList head = TermList(Term::create(symAndDef.first, _typeVars.size(), _typeVars.begin())); + res= ApplicativeHelper::app(head, _termVars); + } +#endif + } // record as a new premise UnitList::push(symAndDef.second,premises); diff --git a/Shell/UIHelper.cpp b/Shell/UIHelper.cpp index 90089e09a8..9edec23f4f 100644 --- a/Shell/UIHelper.cpp +++ b/Shell/UIHelper.cpp @@ -567,6 +567,27 @@ void UIHelper::outputSymbolTypeDeclarationIfNeeded(ostream& out, bool function, sym = env.signature->getPredicate(symNumber); } +#if VHOL + auto printingMode = env.options->holPrinting(); + if(printingMode != Options::HPrinting::RAW){ + if(sym->proxy() != Signature::NOT_PROXY){ + return; + } + if(sym->dbIndex().isSome()){ + return; + } + if(function && env.signature->isAppFun(symNumber)){ + return; + } + if(function && env.signature->isLamFun(symNumber)){ + return; + } + if(typeCon && env.signature->isArrowCon(symNumber)){ + return; + } + } +#endif + if (typeCon && (env.signature->isArrayCon(symNumber) || env.signature->isTupleCon(symNumber))){ return; @@ -608,16 +629,19 @@ void UIHelper::outputSymbolTypeDeclarationIfNeeded(ostream& out, bool function, //out << "tff(" << (function ? "func" : "pred") << "_def_" << symNumber << ", type, " // << sym->name() << ": "; + + bool higherOrder = false; +#if VHOL + higherOrder = env.property->higherOrder(); +#endif - //don't output type of app. It is an internal Vampire thing - if(!(function && env.signature->isAppFun(symNumber))){ - out << (env.property->higherOrder() ? "thf(" : "tff(") - << (function ? "func" : (typeCon ? "type" : "pred")) - << "_def_" << symNumber << ", type, " - << sym->name() << ": "; - out << type->toString(); - out << ")." << endl; - } + out << (higherOrder ? "thf(" : "tff(") + << (function ? "func" : (typeCon ? "type" : "pred")) + << "_def_" << symNumber << ", type, " + << sym->name() << ": "; + out << type->toString(); + out << ")." << endl; + //out << ")." << endl; } diff --git a/Shell/UnificationWithAbstractionConfig.cpp b/Shell/UnificationWithAbstractionConfig.cpp deleted file mode 100644 index 8f99eed63e..0000000000 --- a/Shell/UnificationWithAbstractionConfig.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ - - -#include "Shell/UnificationWithAbstractionConfig.hpp" -#include "Lib/Environment.hpp" -#include "Kernel/Signature.hpp" - -using namespace Shell; -using namespace Kernel; - -bool UnificationWithAbstractionConfig::isInterpreted(TermList t) -{ - if (t.isVar()) { - return false; - } else { - return isInterpreted(t.term()); - } -} - -bool UnificationWithAbstractionConfig::isInterpreted(Term* t) -{ - return theory->isInterpretedFunction(t) - || theory->isInterpretedConstant(t) - || env.signature->getFunction(t->functor())->termAlgebraCons(); -} diff --git a/Shell/UnificationWithAbstractionConfig.hpp b/Shell/UnificationWithAbstractionConfig.hpp deleted file mode 100644 index 3ee44a6410..0000000000 --- a/Shell/UnificationWithAbstractionConfig.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the source code of the software program - * Vampire. It is protected by applicable - * copyright laws. - * - * This source code is distributed under the licence found here - * https://vprover.github.io/license.html - * and in the source directory - */ - -#ifndef __SHELL__UNIFICATION_WITH_ABSTRACTION_CONFIG__ -#define __SHELL__UNIFICATION_WITH_ABSTRACTION_CONFIG__ - -#include "Kernel/Term.hpp" - -namespace Shell { - - -class UnificationWithAbstractionConfig -{ -public: - UnificationWithAbstractionConfig() {} - - static bool isInterpreted(Kernel::Term* t ); - static bool isInterpreted(Kernel::TermList t); -}; - -} // namespace Shell - -#endif // __SHELL__UNIFICATION_WITH_ABSTRACTION_CONFIG__ diff --git a/Test/GenerationTester.hpp b/Test/GenerationTester.hpp index b9fc94febb..b02cefbfc7 100644 --- a/Test/GenerationTester.hpp +++ b/Test/GenerationTester.hpp @@ -86,6 +86,10 @@ class TestCase Stack _expected; Stack _context; bool _premiseRedundant; +#if VHOL + bool _higherOrder; +#endif + bool _polymorphic; Stack _indices; OptionMap _options; Stack _preConditions; @@ -104,7 +108,11 @@ class TestCase public: - TestCase() : _rule(), _input(NULL), _expected(), _premiseRedundant(false), _options() {} + TestCase() : _rule(), _input(NULL), _expected(), _premiseRedundant(false), +#if VHOL + _higherOrder(false), +#endif + _polymorphic(false), _options() {} #define BUILDER_METHOD(type, field) \ TestCase field(type field) \ @@ -117,6 +125,10 @@ class TestCase BUILDER_METHOD(Stack, context) BUILDER_METHOD(Stack, expected) BUILDER_METHOD(bool, premiseRedundant) +#if VHOL + BUILDER_METHOD(bool, higherOrder) +#endif + BUILDER_METHOD(bool, polymorphic) BUILDER_METHOD(SimplifyingGeneratingInference*, rule) BUILDER_METHOD(Stack, indices) BUILDER_METHOD(OptionMap, options) @@ -130,10 +142,16 @@ class TestCase auto container = PlainClauseContainer(); Problem p; Options o; + + if(_polymorphic){ + p.getProperty()->forceMaxTypeConArity(); + } + for (const auto& kv : _options) { o.set(kv.first, kv.second); env.options->set(kv.first, kv.second); } + MockedSaturationAlgorithm alg(p, o); SimplifyingGeneratingInference& rule = *_rule.unwrapOrElse([&](){ return &simpl._rule; }); rule.setTestIndices(_indices); @@ -142,6 +160,12 @@ class TestCase i->attachContainer(&container); } +#if VHOL + if(_higherOrder){ + env.property->forceHigherOrder(); + } +#endif + // add the clauses to the index for (auto c : _context) { c->setStore(Clause::ACTIVE); diff --git a/Test/SyntaxSugar.hpp b/Test/SyntaxSugar.hpp index b2dd4455be..b0ca7a142d 100644 --- a/Test/SyntaxSugar.hpp +++ b/Test/SyntaxSugar.hpp @@ -28,7 +28,10 @@ #include "Kernel/Clause.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/NumTraits.hpp" +#if VHOL #include "Kernel/ApplicativeHelper.hpp" +#endif +#include "Kernel/TypedTermList.hpp" #include "Indexing/TermSharing.hpp" #include "Kernel/Signature.hpp" @@ -115,18 +118,16 @@ #define DECL_POLY_FUNC(f, i, ...) auto f = FuncSugar(#f, __VA_ARGS__, i); #define DECL_POLY_CONST(f, i, sort) auto f = FuncSugar(#f, Stack(0), sort, i); #define DECL_PRED(f, ...) auto f = PredSugar(#f, __VA_ARGS__); -#define DECL_POLY_PRED(f, i, ...) auto f = PredSugar(#f, __VA_ARGS__, i); #define DECL_TYPE_CON(f, arity) auto f = TypeConSugar(#f, arity); #define DECL_SORT(s) auto s = TypeConstSugar(#s); -#define DECL_ARROW_SORT(s, ...) auto s = SortSugar(#s, __VA_ARGS__); +#define DECL_ARROW_SORT(s, ...) auto s = SortSugar(#s, __VA_ARGS__); #define DECL_VAR(x, i) auto x = TermSugar(TermList::var(i)); #define DECL_SORT_VAR(x, i) auto x = SortSugar(TermList::var(i)); +// same sugar, remove 1? #define DECL_HOL_VAR(x, i, s) auto x = TermSugar(TermList::var(i), s); -#define DECL_I_COMB(i) auto i = FuncSugar(env.signature->getCombinator(Signature::I_COMB)); -#define DECL_K_COMB(k) auto k = FuncSugar(env.signature->getCombinator(Signature::K_COMB)); -#define DECL_B_COMB(b) auto b = FuncSugar(env.signature->getCombinator(Signature::B_COMB)); -#define DECL_C_COMB(c) auto c = FuncSugar(env.signature->getCombinator(Signature::C_COMB)); -#define DECL_S_COMB(s) auto s = FuncSugar(env.signature->getCombinator(Signature::S_COMB)); +#define DECL_VAR_SORTED(x, i, s) auto x = TermSugar(TermList::var(i), s); + +#define DECL_BOOL_SORT(b) auto b = SortSugar(AtomicSort::boolSort()); #define DECL_DEFAULT_VARS \ __ALLOW_UNUSED( \ @@ -146,15 +147,6 @@ DECL_SORT_VAR(gamma, 103) \ ) -#define DECL_COMBINATORS \ - __ALLOW_UNUSED( \ - DECL_I_COMB(I) \ - DECL_K_COMB(K) \ - DECL_B_COMB(B) \ - DECL_C_COMB(C) \ - DECL_S_COMB(S) \ - ) - /** tldr: For examples on usage see UnitTesting/tSyntaxSugar.cpp * @@ -259,19 +251,33 @@ class SyntaxSugarGlobals public: static SyntaxSugarGlobals& instance() { +#if VHOL _instance.setApply(); + _instance.setLambda(); +#endif return _instance; } - +#if VHOL void setApply() { apply = [](TermList sort, TermList t1, TermList t2) { - TermList app = ApplicativeHelper::createAppTerm(sort, t1, t2); + TermList app = ApplicativeHelper::app(sort, t1, t2); return app; }; } + void setLambda() + { + lambda = [](TermList varSort, TermList var, TermList termSort, TermList term) { + VList* boundVar = new VList(var.var()); + SList* boundVarSort = new SList(varSort); + Term* lambdaTerm = Term::createLambda(term, boundVar, boundVarSort, termSort); + return TermList(lambdaTerm); + }; + } +#endif + void setNumTraits(IntTraits) { setAllNumTraits(); @@ -292,6 +298,7 @@ class SyntaxSugarGlobals { setFracTraits(); } std::function apply; + std::function lambda; std::function createFraction; std::function createNumeral; @@ -356,13 +363,22 @@ struct SortSugar : public ExpressionSugar SortSugar(const char* name, Stack as_) { +#if VHOL if(as_.isEmpty()){ +#endif _sugaredExpr = TermList(AtomicSort::createConstant(name)); +#if VHOL } else { + //AYB TODO, we don't need this now that we have the arrow sort creation functions Stack as; for (auto a : as_){ as.push(a.sugaredExpr()); } - _sugaredExpr = AtomicSort::arrowSort(as, as.pop()); + auto res = as.pop(); + // reverse arguments. Bit of a hack really + Stack as2; + while(!as.isEmpty()){ as2.push(as.pop()); } + _sugaredExpr = AtomicSort::arrowSort(as2, res); } +#endif } SortSugar(const char* name) @@ -376,19 +392,26 @@ class TermSugar : public ExpressionSugar public: TermSugar(bool foolConst) - : ExpressionSugar(TermList(foolConst ? Term::foolTrue() : Term::foolFalse())) - { _srt.makeEmpty(); } + : TermSugar(TermList(foolConst ? Term::foolTrue() : Term::foolFalse())) + {} TermSugar(int trm) - : ExpressionSugar(TermList(syntaxSugarGlobals().createNumeral(trm))) - { _srt.makeEmpty(); } + : TermSugar(TermList(syntaxSugarGlobals().createNumeral(trm))) + {} TermSugar(TermList trm) : ExpressionSugar(trm) { ASS_REP(!_sugaredExpr.isEmpty(), _sugaredExpr); - if(!_sugaredExpr.isVar()){ - _srt = SortHelper::getResultSort(_sugaredExpr.term()); + + if (_sugaredExpr.isVar()) { + _srt.makeEmpty(); + } else { + if(_sugaredExpr.term()->isSpecial()){ + _srt = _sugaredExpr.term()->getSpecialData()->getSort(); + } else { + _srt = SortHelper::getResultSort(_sugaredExpr.term()); + } } } @@ -399,9 +422,13 @@ class TermSugar : public ExpressionSugar _srt = sort.sugaredExpr(); } + operator TypedTermList() const {return TypedTermList(_sugaredExpr, _srt);} + /** explicit conversion */ SortId sort() const { return _srt; } + TermSugar sort(SortId s) { _srt = s; return *this; } + static TermSugar createConstant(const char* name, SortSugar s, bool skolem) { unsigned f = env.signature->addFunction(name,0); @@ -444,9 +471,17 @@ inline TermSugar fool(bool b) ////////////////////////// operators to create terms ////////////////////////// -inline TermSugar ap(TermSugar lhs, TermSugar rhs) { - return syntaxSugarGlobals().apply(lhs.sort(), lhs, rhs); -} +#if VHOL +inline TermSugar ap(SortSugar sort, TermSugar lhs, TermSugar rhs) +{ return ApplicativeHelper::app(sort, lhs, rhs); } + +inline TermSugar ap(TermSugar lhs, TermSugar rhs) +{ return ap(lhs.sort(), lhs, rhs); } + +inline TermSugar lam(TermSugar var, TermSugar term) { + return syntaxSugarGlobals().lambda(var.sort(), var, term.sort(), term); +} +#endif inline TermSugar operator+(TermSugar lhs, TermSugar rhs) { return syntaxSugarGlobals().add(lhs, rhs); } inline TermSugar operator*(TermSugar lhs, TermSugar rhs) { return syntaxSugarGlobals().mul(lhs, rhs); } @@ -482,8 +517,12 @@ inline TermSugar operator-(TermSugar x) { return syntaxSugarGlobals().minus(x); inline Lit operator==(TermSugar lhs, TermSugar rhs) { SortId sort; - ALWAYS(SortHelper::tryGetResultSort(lhs, sort) || SortHelper::tryGetResultSort(rhs, sort)); - return Literal::createEquality(true, lhs, rhs, sort); + SortId lhsSort = lhs.sort(); + SortId rhsSort = rhs.sort(); + ASS(!lhsSort.isEmpty() || !rhsSort.isEmpty()); + ASS(lhsSort.isEmpty() || rhsSort.isEmpty() || lhsSort == rhsSort); + SortId nonEmptySort = lhsSort.isEmpty() ? rhsSort : lhsSort; + return Literal::createEquality(true, lhs, rhs, nonEmptySort); } @@ -512,6 +551,14 @@ __IMPL_NUMBER_BIN_FUN(operator<=, Lit) __IMPL_NUMBER_BIN_FUN(operator> , Lit) __IMPL_NUMBER_BIN_FUN(operator>=, Lit) +#if VHOL +inline SortSugar arrow(TermList args, TermList res) +{ return AtomicSort::arrowSort({ args }, res); } + +inline SortSugar arrow(Stack args, TermList res) +{ return AtomicSort::arrowSort(args, res); } + +#endif class FuncSugar { unsigned _functor; @@ -643,7 +690,7 @@ class PredSugar { _functor = env.signature->addPredicate(name, as.size() + taArity); env.signature ->getPredicate(_functor) - ->setType(OperatorType::getPredicateType(as.size(), &as[0], taArity)); + ->setType(OperatorType::getPredicateType(as.size(), as.begin(), taArity)); } template @@ -680,6 +727,7 @@ inline Clause* clause(std::initializer_list ls_) { return &out; } + inline Stack clauses(std::initializer_list> cls) { auto out = Stack(); for (auto cl : cls) { diff --git a/Test/TestUtils.cpp b/Test/TestUtils.cpp index 9497e91fc8..5e19a0a931 100644 --- a/Test/TestUtils.cpp +++ b/Test/TestUtils.cpp @@ -67,26 +67,41 @@ std::ostream& Pretty::prettyPrint(std::ostream& out) const return out << "X" << t.var(); } else { auto term = t.term(); +#if VHOL + if(env.property->higherOrder()){ + // higher order has its own pretty printing + // procedure + out << term->toString(); + return out; + } +#endif + auto func = term->functor(); - if (theory->isInterpretedFunction(func)) { - switch(theory->interpretFunction(func)) { -#define NUM_CASE(oper) \ - case Kernel::Theory::INT_ ## oper: \ - case Kernel::Theory::REAL_ ## oper: \ - case Kernel::Theory::RAT_ ## oper - NUM_CASE(PLUS): - return printOp(out, term, "+"); - NUM_CASE(MULTIPLY): - return printOp(out, term, "*"); - // case Kernel::Theory::EQUAL: - // return printOp("=") - default: {} + Signature::Symbol* sym; + if (term->isSort()) { + sym = env.signature->getTypeCon(func); + } else { + if (theory->isInterpretedFunction(func)) { + switch(theory->interpretFunction(func)) { +#define NUM_CASE(oper) \ + case Kernel::Theory::INT_ ## oper: \ + case Kernel::Theory::REAL_ ## oper: \ + case Kernel::Theory::RAT_ ## oper + + NUM_CASE(PLUS): + return printOp(out, term, "+"); + NUM_CASE(MULTIPLY): + return printOp(out, term, "*"); + // case Kernel::Theory::EQUAL: + // return printOp("=") + default: {} #undef NUM_CASE + } } + sym = env.signature->getFunction(func); } - Signature::Symbol* sym = env.signature->getFunction(func); out << sym->name(); if (sym->arity() > 0) { out << "(" << pretty(*term->nthArgument(0)); @@ -172,6 +187,8 @@ bool TestUtils::isAC(Term* t) auto f = t->functor(); if (t->isLiteral()) { return theory->isInterpretedPredicate(f) && isAC(theory->interpretPredicate(f)); + } else if (t->isSort()) { + return false; } else { return theory->isInterpretedFunction(f) && isAC(theory->interpretFunction(f)); } diff --git a/Test/TestUtils.hpp b/Test/TestUtils.hpp index 008ab04adb..78c6dbda03 100644 --- a/Test/TestUtils.hpp +++ b/Test/TestUtils.hpp @@ -250,6 +250,7 @@ bool __permEq(L1& lhs, L2& rhs, Eq elemEq, DArray& perm, unsigned idx) template bool TestUtils::permEq(L1& lhs, L2& rhs, Eq elemEq) { + CALL("TestUtils::permEq") if (lhs.size() != rhs.size()) return false; DArray perm(lhs.size()); for (unsigned i = 0; i < lhs.size(); i++) { diff --git a/Test/UnitTesting.cpp b/Test/UnitTesting.cpp index ba4254e49e..2b75211428 100644 --- a/Test/UnitTesting.cpp +++ b/Test/UnitTesting.cpp @@ -44,31 +44,51 @@ UnitTesting& UnitTesting::instance() return *_instance; } -bool UnitTesting::runTest(vstring const& unitId, vstring const& testCase) +bool UnitTesting::runTest(vstring const& unitId, vstring const& testName) { auto unit = findUnit(unitId); if (unit == nullptr) return false; - else return unit->runTest(testCase); + else if (unit->hasTest(testName)) { + return unit->runTest(testName); + } else { + return unit->runTestsWithNameSubstring(testName, std::cout); + } } -bool TestUnit::runTest(vstring const& testCase) + +TestUnit::Test* TestUnit::findTest(vstring const& testCase) { - for (auto test : _tests) { + for (auto& test : _tests) { if (test.name == testCase) { - test.proc(); - return true; + return &test; } } - std::cerr << "test \"" << testCase << "\" not found in " << id() << std::endl; - return false; + return nullptr; +} +bool TestUnit::hasTest(vstring const& name) +{ return findTest(name) != nullptr; } + + +bool TestUnit::runTest(vstring const& name) +{ + auto test = findTest(name); + if (test != nullptr) { + test->proc(); + return true; + } else { + std::cerr << "test \"" << name << "\" not found in " << id() << std::endl; + return false; + } } bool UnitTesting::run(Stack const& args) { if (args.size() == 2) { return runTest(args[0], args[1]); - } else { - ASS_EQ(args.size(), 1) + } else if (args.size() == 1) { return runUnit(args[0]); + } else { + std::cerr << "usage: vtest [ ]"; + exit(-1); } } @@ -110,7 +130,7 @@ bool UnitTesting::listTests(Stack const&) return true; } -bool TestUnit::run(ostream& out) +bool TestUnit::runTestsWithNameSubstring(vstring const& pref, ostream& out) { Stack::BottomFirstIterator uit(_tests); @@ -121,16 +141,18 @@ bool TestUnit::run(ostream& out) unsigned cnt_ok = 0; while(uit.hasNext()) { TestUnit::Test t=uit.next(); - out << "Running " << t.name << "... "; - out.flush(); - bool ok; - { - CALL(t.name); - ok = spawnTest(t.proc); + if (vstring(t.name).find(pref) != vstring::npos) { + out << "Running " << t.name << "... \r"; + out.flush(); + bool ok; + { + CALL(t.name); + ok = spawnTest(t.proc); + } + out << "\r" << ( ok ? "[ OK ]" : "[ FAIL ]" ) << " " << t.name << " " << endl; + if (ok) cnt_ok++; + else cnt_fail++; } - out << "\r" << ( ok ? "[ OK ]" : "[ FAIL ]" ) << " " << t.name << " " << endl; - if (ok) cnt_ok++; - else cnt_fail++; } out << endl; auto cnt = cnt_fail + cnt_ok; @@ -141,6 +163,9 @@ bool TestUnit::run(ostream& out) return cnt_fail == 0; } +bool TestUnit::run(ostream& out) +{ return runTestsWithNameSubstring("", out); } + void TestUnit::add(Test t) { _tests.push(t); } diff --git a/Test/UnitTesting.hpp b/Test/UnitTesting.hpp index 996270bb27..356669a790 100644 --- a/Test/UnitTesting.hpp +++ b/Test/UnitTesting.hpp @@ -55,7 +55,11 @@ class TestUnit * returns true iff all tests of the unit were successfull. */ bool run(ostream& out); - bool runTest(vstring const& testCase); + bool runTestsWithNameSubstring(vstring const& pref, ostream& out); + bool runTest(vstring const& name); + + + bool hasTest(vstring const& name); friend std::ostream& operator<<(ostream& out, TestUnit const& t) { return out << t._name << t._tests; } @@ -64,6 +68,7 @@ class TestUnit Stack const& tests() { return _tests; } private: + Test* findTest(vstring const& testCase); /** Runs a test as a single process and awaits its termination. * This is to provide isolation when running multiple tests in one go. * diff --git a/UnitTests/tBetaReduction.cpp b/UnitTests/tBetaReduction.cpp new file mode 100644 index 0000000000..2c2aaf9d8d --- /dev/null +++ b/UnitTests/tBetaReduction.cpp @@ -0,0 +1,331 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +/**! + * + * @author Ahmed Bhayat + */ + +#if VHOL + +#include "Test/UnitTesting.hpp" +#include "Test/SyntaxSugar.hpp" +#include "Kernel/ApplicativeHelper.hpp" +#include "Shell/LambdaConversion.hpp" + +TermList toDeBruijnIndices(TermList t){ + return LambdaConversion().convertLambda(t); +} + +//////////////////////////////////////////////////////////////////////////////// +////////////////////////////////// TEST CASES ////////////////////////////////// + +TEST_FUN(beta_reduction01) { + DECL_DEFAULT_VARS + DECL_SORT(srt) + DECL_HOL_VAR(x0, 0, srt) + DECL_CONST(a, srt) + + BetaNormaliser bn; + auto t = ap(lam(x0,x0),a); + auto reduced = bn.normalise(toDeBruijnIndices(t)); + + ASS_EQ(reduced, a.sugaredExpr()); +} + +TEST_FUN(beta_reduction02) { + DECL_DEFAULT_VARS + DECL_SORT(srt) + DECL_ARROW_SORT(fSrt, {srt, srt}) + DECL_HOL_VAR(x0, 0, srt) + DECL_CONST(a, srt) + DECL_CONST(f,fSrt) + + BetaNormaliser bn; + auto t = ap(lam(x0,ap(f, x0)),a); + auto reduced = bn.normalise( toDeBruijnIndices(t)); + + ASS_EQ(reduced, ap(f, a).sugaredExpr()); +} + +TEST_FUN(beta_reduction03) { + DECL_SORT(srt) + DECL_ARROW_SORT(xSrt, {srt, srt}) + DECL_HOL_VAR(x, 0, xSrt) + DECL_HOL_VAR(y, 1, srt) + DECL_CONST(a, srt) + + BetaNormaliser bn; + auto t = ap( lam(x,ap(x,a)) , lam(y, y) ); + auto reduced = bn.normalise( toDeBruijnIndices(t) ); + + ASS_EQ(reduced, a.sugaredExpr()); +} + +TEST_FUN(beta_reduction04) { + DECL_SORT(srt) + DECL_ARROW_SORT(xSrt, {srt, srt}) + DECL_HOL_VAR(x, 0, xSrt) + DECL_HOL_VAR(y, 1, srt) + DECL_CONST(a, srt) + DECL_CONST(f, xSrt) + + BetaNormaliser bn; + auto t = ap(f, ap( lam(x,ap(x,a)) , lam(y, y) ) ); + auto reduced = bn.normalise( toDeBruijnIndices(t) ); + + ASS_EQ(reduced, ap(f, a).sugaredExpr()); +} + +TEST_FUN(beta_reduction05) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + + BetaNormaliser bn; + auto t = lam(x, ap(lam(y, lam(z, y) ), x)) ; + auto res = lam(x,lam(z, x)); + auto reduced = bn.normalise( toDeBruijnIndices(t) ); + + ASS_EQ(reduced, toDeBruijnIndices(res)); +} + +TEST_FUN(beta_reduction06) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_CONST(a, srt) + DECL_CONST(b, srt) + DECL_ARROW_SORT(fSrt, {srt, srt, srt}) + DECL_CONST(f, fSrt) + + BetaNormaliser bn; + auto t = ap( ap( lam(x, lam(y, ap(ap(f, x), y))), a), b) ; + auto res = ap(ap(f, a), b); + auto reduced = bn.normalise( toDeBruijnIndices(t) ); + + ASS_EQ(reduced, res.sugaredExpr()); +} + +TEST_FUN(eta_reduction01) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + DECL_ARROW_SORT(fSrt, {srt, srt, srt, srt}) + DECL_CONST(f, fSrt) + + EtaNormaliser en; + auto t = lam(x, lam(y, lam(z, ap(ap(ap(f, x), y), z)))); + + auto reduced = en.normalise( toDeBruijnIndices(t) ); + + ASS_EQ(reduced, f.sugaredExpr()); +} + +TEST_FUN(eta_reduction02) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + DECL_ARROW_SORT(fSrt, {srt, srt, srt, srt}) + DECL_CONST(f, fSrt) + + EtaNormaliser en; + auto t = lam(x, lam(y, lam(z, ap(ap(ap(f, x), z), y)))); + auto tdb = toDeBruijnIndices(t); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, tdb); +} + +TEST_FUN(eta_reduction03) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + DECL_ARROW_SORT(fSrt, {srt, srt, srt, srt}) + DECL_CONST(f, fSrt) + + EtaNormaliser en; + auto t = lam(x, lam(y, lam(z, ap(ap(ap(f, y), x), z)))); + auto tdb = toDeBruijnIndices(t); + auto res = lam(x, lam(y, ap(ap(f, y), x) )); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, toDeBruijnIndices(res)); +} + +TEST_FUN(eta_reduction04) { + DECL_SORT(srt) + DECL_ARROW_SORT(xSrt, {srt, srt, srt}) + DECL_HOL_VAR(x, 0, xSrt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + + EtaNormaliser en; + auto t = lam(x, lam(y, lam(z, ap(ap(x, y), z)))); + auto tdb = toDeBruijnIndices(t); + auto res = lam(x, x); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, toDeBruijnIndices(res)); +} + +TEST_FUN(eta_reduction05) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_ARROW_SORT(fSrt, {srt, srt, srt}) + DECL_CONST(f, fSrt) + + EtaNormaliser en; + auto t = lam(x, ap(ap(f, x), x)); + auto tdb = toDeBruijnIndices(t); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, tdb); +} + +TEST_FUN(eta_reduction06) { + env.property->forceHigherOrder(); + env.options->set("pretty_hol_printing","pretty"); + + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, arrow(srt,srt)) + DECL_HOL_VAR(y, 1, srt) + // TODO wierd stuff below... + DECL_CONST(f, arrow(arrow(srt,srt),srt)) + + EtaNormaliser en; + auto t = lam(x, ap(f, lam(y, ap(x,y)))); + auto tdb = toDeBruijnIndices(t); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, f.sugaredExpr()); +} + +TEST_FUN(eta_reduction07) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_ARROW_SORT(gSrt, {srt, srt}) + // TODO wierd stuff below... + DECL_ARROW_SORT(fSrt, {gSrt, srt, srt}) + DECL_CONST(f, fSrt) + DECL_CONST(g, gSrt) + + EtaNormaliser en; + auto t = lam(x, ap(ap(f, lam(y, ap(g, y))), x)); + auto tdb = toDeBruijnIndices(t); + + auto reduced = en.normalise( tdb ); + + ASS_EQ(reduced, ap(f,g).sugaredExpr()); +} + +/*TEST_FUN(whnf_01) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_CONST(f, arrow(srt,srt)) + DECL_CONST(a, srt) + + env.options->setHolPrinting(Options::HPrinting::PRETTY); + env.property->forceHigherOrder(); + + auto inner = ap(f, ap( lam(x,x), a )); + auto t = ap(lam(y,y), inner ); + auto tdb = toDeBruijnIndices(t); + + + ASS_EQ(tdb.whnf(), toDeBruijnIndices(inner)); +} + +TEST_FUN(whnf_02) { + DECL_SORT(srt) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, srt) + DECL_HOL_VAR(z, 2, srt) + DECL_HOL_VAR(q, 3, srt) + DECL_CONST(f, arrow(srt,srt)) + DECL_CONST(a, srt) + + env.options->setHolPrinting(Options::HPrinting::PRETTY); + env.property->forceHigherOrder(); + + auto t = lam(y,ap(lam(x, lam(z, ap( lam(q,q), x ) )), a)); + auto tdb = toDeBruijnIndices(t); + + + ASS_EQ(tdb.whnf(), toDeBruijnIndices(lam(y, lam(z, a)))); +}*/ + +TEST_FUN(fo_subterm_rep1) { + DECL_SORT(srt) + DECL_ARROW_SORT(gSrt, {srt, srt}) + // TODO wierd stuff below... + DECL_ARROW_SORT(fSrt, {gSrt, srt, srt}) + DECL_HOL_VAR(y, 1, gSrt) + DECL_HOL_VAR(x, 2, srt) + DECL_HOL_VAR(z, 3, arrow(arrow(srt,srt), srt)) + DECL_CONST(f, fSrt) + DECL_CONST(g, gSrt) + DECL_CONST(a, arrow(srt,srt)) + + env.options->setHolPrinting(Options::HPrinting::PRETTY); + env.property->forceHigherOrder(); + + ToPlaceholders sr; + auto t = ap(ap(f,g), ap(y, x)); + + auto replaced = sr.replace( t ); + auto replaced2 = sr.replace ( ap(z, a)); + + cout << t << endl; + cout << replaced << endl; + cout << replaced2 << endl; +} + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UnitTests/tEqualityFactoring.cpp b/UnitTests/tEqualityFactoring.cpp new file mode 100644 index 0000000000..9aed0c4917 --- /dev/null +++ b/UnitTests/tEqualityFactoring.cpp @@ -0,0 +1,57 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ + + +#include "Test/UnitTesting.hpp" +#include "Test/SyntaxSugar.hpp" +#include "Test/TestUtils.hpp" +#include "Test/GenerationTester.hpp" + +#include "Inferences/EqualityFactoring.hpp" + +using namespace Test; + +REGISTER_GEN_TESTER(EqualityFactoring) + +/** + * NECESSARY: We neet to tell the tester which syntax sugar to import for creating terms & clauses. + * See Test/SyntaxSugar.hpp for which kinds of syntax sugar are available + */ +#define MY_SYNTAX_SUGAR \ + DECL_DEFAULT_VARS \ + DECL_DEFAULT_SORT_VARS \ + DECL_SORT(s) \ + DECL_SORT(s2) \ + DECL_FUNC(f, {s}, s) \ + DECL_FUNC(g, {s}, s) \ + DECL_TYPE_CON(list, 1) \ + DECL_POLY_CONST(poly_list, 1, {list(alpha)}) \ + DECL_POLY_CONST(j, 1, {list(alpha)}) \ + DECL_CONST(a, s) \ + DECL_PRED (p, {s}) \ + DECL_PRED (q, {s}) \ + DECL_VAR(k, 3) \ + +TEST_GENERATION(test_01, // <- name + Generation::TestCase() + .input( clause({ selected(poly_list(alpha) == j(alpha)), j(s) == poly_list(s) })) // <- input clause + .expected(exactly( // <- a list of exactly which clauses are expected + clause({ j(s) == poly_list(s), poly_list(s) != poly_list(s) }) // to be returned. Order matters! + )) + .polymorphic(true) + ) + +TEST_GENERATION(test_02, + Generation::TestCase() + .input( clause({ selected(x.sort(s2) == y), z.sort(s) == k })) + .expected(exactly( + )) + .polymorphic(true) + ) \ No newline at end of file diff --git a/UnitTests/tHOLMatching.cpp b/UnitTests/tHOLMatching.cpp new file mode 100644 index 0000000000..9a5ba4a0f7 --- /dev/null +++ b/UnitTests/tHOLMatching.cpp @@ -0,0 +1,377 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ +#if VHOL + +#include "Forwards.hpp" +#include "Indexing/SubstitutionTree.hpp" +#include "Lib/Environment.hpp" + +#include "Shell/Options.hpp" +#include "Test/TestUtils.hpp" + +#include "Kernel/Unit.hpp" +#include "Kernel/Clause.hpp" +#include "Kernel/Inference.hpp" +#include "Kernel/Problem.hpp" +#include "Kernel/Signature.hpp" +#include "Kernel/Term.hpp" +#include "Kernel/OperatorType.hpp" +#include "Kernel/SortHelper.hpp" +#include "Kernel/RobSubstitution.hpp" +#include "Kernel/MismatchHandler.hpp" + +#include "Indexing/Index.hpp" +#include "Indexing/LiteralSubstitutionTree.hpp" +#include "Indexing/LiteralIndex.hpp" +#include "Indexing/TermSubstitutionTree.hpp" +#include "Indexing/TermIndex.hpp" +#include "Shell/LambdaConversion.hpp" + +#include "Test/UnitTesting.hpp" +#include "Test/SyntaxSugar.hpp" + +#include + + +using namespace Kernel; +using namespace Indexing; + +#define TODO ASSERTION_VIOLATION_REP("TODO") + +TypedTermList toDeBrs(TermList t){ + CALL("toDeBrs"); + ASS(!t.isVar()); + + auto converted = LambdaConversion().convertLambda(t); + auto sort = SortHelper::getResultSort(converted.term()); + return TypedTermList(converted, sort); +} + +Clause* unt(Literal* lit) +{ + return clause({ lit }); +} + +unique_ptr getIndexTerm() +{ return std::make_unique(SplittingAlgo::HOL_MATCH); } + +auto getIndexLiteral() +{ return std::make_unique(); } + +template +struct MatchingResultSpec { + TermOrLit querySigma; + TermOrLit resultSigma; + + friend bool operator==(MatchingResultSpec const& l, MatchingResultSpec const& r) + { + return Test::TestUtils::eqModAC(l.querySigma, r.querySigma) + && Test::TestUtils::eqModAC(l.resultSigma, r.resultSigma); + } + + friend std::ostream& operator<<(std::ostream& out, MatchingResultSpec const& self) + { + return out << "{ querySigma = " << Test::pretty(self.querySigma) << ", resultSigma = " << Test::pretty(self.resultSigma); + } +}; + +using TermMatchingResultSpec = MatchingResultSpec; +using LiteralMatchingResultSpec = MatchingResultSpec; + +template +void checkLiteralMatches(LiteralSubstitutionTree& index, Literal* lit, Stack expected, F unifFun) +{ + Stack is; + for (auto qr : iterTraits(unifFun(index, lit)) ) { + is.push(TermMatchingResultSpec { + .querySigma = qr.unifier->apply(lit, QUERY_BANK), + .resultSigma = qr.unifier->apply(qr.literal, RESULT_BANK) + }); + } + if (Test::TestUtils::permEq(is, expected, [](auto& l, auto& r) { return l == r; })) { + cout << "[ OK ] " << *lit << endl; + } else { + cout << "[ FAIL ] " << *lit << endl; + cout << "tree: " << multiline(index, 1) << endl; + cout << "query: " << *lit << endl; + + cout << "is:" << endl; + for (auto& x : is) + cout << " " << x << endl; + + cout << "expected:" << endl; + for (auto& x : expected) + cout << " " << x << endl; + + exit(-1); + } + // cout << endl; +} + +void checkTermMatches(TermSubstitutionTree& index, TypedTermList term, Stack expected, bool instances) +{ + CALL("checkTermMatchesWithUnifFun(TermSubstitutionTree& index, TermList term, Stack expected, bool instances)") + + auto it = iterTraits(instances ? index.getHOLInstances(term) : index.getHOLGeneralizations(term) ); + + Stack is; + for (auto qr : it) { + is.push(TermMatchingResultSpec { + .querySigma = instances ? qr.unifier->applyTo(term, QUERY_BANK) : term, + .resultSigma = instances ? qr.term : qr.unifier->applyTo(qr.term, RESULT_BANK) + }); + } + if (Test::TestUtils::permEq(is, expected, [](auto& l, auto& r) { return l == r; })) { + cout << "[ OK ] " << term << endl; + } else { + cout << "[ FAIL ] " << term << endl; + + cout << "tree: " << multiline(index, 1) << endl; + cout << "query: " << term << endl; + + cout << "is:" << endl; + for (auto& x : is) + cout << " " << x << endl; + + cout << "expected:" << endl; + for (auto& x : expected) + cout << " " << x << endl; + + exit(-1); + } + // cout << endl; +} + +void checkTermInstances(TermSubstitutionTree& index, TypedTermList term, Stack expected) +{ + checkTermMatches(index, term, expected, true); +} + +void checkTermGeneralizations(TermSubstitutionTree& index, TypedTermList term, Stack expected) +{ + checkTermMatches(index, term, expected,false); +} + + +struct IndTest { + unique_ptr index; + Stack insert; + TermSugar query; + Stack expected; + bool instantiation; + + void run() { + CALL("IndexTest::run") + + env.property->forceHigherOrder(); + // if printing causes a crash, set this to raw + // crash happens when attempting to print a loose De Bruijn index + env.options->set("pretty_hol_printing","pretty"); + + DECL_PRED(dummy, Stack()) + for (auto x : this->insert) { + index->insert(x, dummy(), unt(dummy())); + } + + if(instantiation){ + checkTermInstances(*this->index, TypedTermList(this->query, this->query.sort()),this->expected); + } else { + checkTermGeneralizations(*this->index, TypedTermList(this->query, this->query.sort()),this->expected); + } + } +}; + + +#define HOL_SUGAR \ + __ALLOW_UNUSED( \ + DECL_SORT(srt) \ + DECL_DEFAULT_VARS \ + DECL_DEFAULT_SORT_VARS \ + DECL_HOL_VAR(x0, 0, srt) \ + DECL_HOL_VAR(x1, 1, srt) \ + DECL_HOL_VAR(y0, 5, srt) \ + DECL_HOL_VAR(x2, 2, arrow(srt,srt)) \ + DECL_HOL_VAR(x3, 3, arrow(srt,srt)) \ + DECL_HOL_VAR(x4, 4, arrow(arrow(srt, srt),arrow(srt,srt))) \ + DECL_CONST(a,srt) \ + DECL_CONST(b,srt) \ + DECL_CONST(c,srt) \ + DECL_CONST(f,arrow(srt,srt)) \ + DECL_CONST(g,arrow(srt,srt)) \ + DECL_CONST(h,arrow(arrow(srt, srt),arrow(srt,srt))) \ + DECL_CONST(k,arrow(srt,arrow(srt,srt))) \ + ) \ + + +#define RUN_TEST(name, sugar, ...) \ + TEST_FUN(name) { \ + __ALLOW_UNUSED(sugar) \ + __VA_ARGS__.run(); \ + } \ + +RUN_TEST(hol_matching_01, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + toDeBrs(lam(x1, ap(f, x1))), + }, + .query = x2, + .expected = { + + TermMatchingResultSpec + { .querySigma = toDeBrs(lam(x1, ap(f, x1))), + .resultSigma = toDeBrs(lam(x1, ap(f, x1))) + } + + }, + .instantiation = true, + }) + +RUN_TEST(hol_matching_09, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + ap(ap(k, ap(g, a) ), ap(g,a) ), + ap(ap(k, ap(g, c) ), ap(g,b) ), + ap(ap(k, x1 ), x1 ), + }, + .query = ap(ap(k, x0 ), x0 ), + .expected = { + + TermMatchingResultSpec + { .querySigma = ap(ap(k, ap(g, a) ), ap(g,a) ), + .resultSigma = ap(ap(k, ap(g, a) ), ap(g,a) ) + } , + + TermMatchingResultSpec + { .querySigma = ap(ap(k, x1 ), x1 ), + .resultSigma = ap(ap(k, x1 ), x1 ) + } + + }, + .instantiation = true, + }) + +RUN_TEST(hol_matching_02, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + ap(x2,a), + }, + .query = ap(f,a), + .expected = { + + TermMatchingResultSpec + { .querySigma = ap(f,a), + .resultSigma = ap(f,a) + } + + }, + .instantiation = false, + }) + +RUN_TEST(hol_matching_03, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + toDeBrs(ap(ap(x4,lam(x0,x0)), a)), + }, + .query = toDeBrs(ap(ap(h,lam(x0,x0)), a)), + .expected = { + + TermMatchingResultSpec + { .querySigma = toDeBrs(ap(ap(h,lam(x0,x0)), a)), + .resultSigma = toDeBrs(ap(ap(h,lam(x0,x0)), a)) + } + + }, + .instantiation = false, + }) + +RUN_TEST(hol_matching_04, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + toDeBrs(lam(x0, lam(x1, x0))), + }, + .query = toDeBrs(lam(x0, lam(x1, x0))), + .expected = { + + TermMatchingResultSpec + { .querySigma = toDeBrs(lam(x0, lam(x1, x0))), + .resultSigma = toDeBrs(lam(x0, lam(x1, x0))) + } + + }, + .instantiation = false, + }) + +RUN_TEST(hol_matching_05, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + toDeBrs(lam(x0, lam(x1, x0))), + }, + .query = toDeBrs(lam(x0, lam(x1, x1))), + .expected = Stack{}, + .instantiation = false, + }) + +RUN_TEST(hol_matching_06, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + toDeBrs(lam(x0, lam(x1, x0))), + }, + .query = toDeBrs(lam(x0, lam(x1, y0))), + .expected = Stack{}, + .instantiation = true, + }) + +RUN_TEST(hol_matching_07, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + ap(ap(k,a),b), + ap(ap(k,b),b), + }, + .query = ap(ap(k,x0),x0), + .expected = { + + TermMatchingResultSpec + { .querySigma = ap(ap(k,b),b), + .resultSigma = ap(ap(k,b),b) + } + + }, + .instantiation = true, + }) + +RUN_TEST(hol_matching_08, + HOL_SUGAR, + IndTest { + .index = getIndexTerm(), + .insert = { + ap(ap(k,a),b), + }, + .query = ap(ap(k,ap(f, x0)),x0), + .expected = Stack{}, + .instantiation = true, + }) + +#endif \ No newline at end of file diff --git a/UnitTests/tImitateProject.cpp b/UnitTests/tImitateProject.cpp new file mode 100644 index 0000000000..7f01a25cfb --- /dev/null +++ b/UnitTests/tImitateProject.cpp @@ -0,0 +1,84 @@ +/* + * This file is part of the source code of the software program + * Vampire. It is protected by applicable + * copyright laws. + * + * This source code is distributed under the licence found here + * https://vprover.github.io/license.html + * and in the source directory + */ + +#if VHOL + +#include "Test/UnitTesting.hpp" +#include "Test/SyntaxSugar.hpp" +#include "Test/TestUtils.hpp" +#include "Test/GenerationTester.hpp" +#include "Shell/LambdaConversion.hpp" + +#include "Inferences/ImitateProject.hpp" + +using namespace Test; + +REGISTER_GEN_TESTER(ImitateProject) + +TermList dbs(TermList t){ + return LambdaConversion().convertLambda(t); +} + +/** + * NECESSARY: We neet to tell the tester which syntax sugar to import for creating terms & clauses. + * See Test/SyntaxSugar.hpp for which kinds of syntax sugar are available + */ +#define MY_SYNTAX_SUGAR \ + DECL_SORT(srt) \ + DECL_ARROW_SORT(xSrt, {srt, srt}) \ + DECL_ARROW_SORT(gSrt, {srt, srt, srt}) \ + DECL_HOL_VAR(x, 0, xSrt) \ + DECL_HOL_VAR(y, 2, srt) \ + DECL_HOL_VAR(z, 1, xSrt) \ + DECL_HOL_VAR(w, 3, gSrt) \ + DECL_HOL_VAR(k, 4, gSrt) \ + DECL_HOL_VAR(m, 5, gSrt) \ + DECL_HOL_VAR(p, 6, srt) \ + DECL_CONST(a, srt) \ + DECL_CONST(b, srt) \ + DECL_CONST(g, gSrt) \ + DECL_CONST(f, xSrt) \ + + +/** Defines a test case. */ +TEST_GENERATION(test_01, // <- name + Generation::TestCase() + .options({ { "pretty_hol_printing", "pretty" } }) + .input( clause({ selected(a != ap(x, a)) })) // <- input clause + .expected(exactly( // <- a list of exactly which clauses are expected + clause({ a != ap(dbs(lam(y,y)), a) }), + clause({ a != ap(dbs(lam(y,a)), a) }) // to be returned. Order matters! + )) + .higherOrder(true) + ) + +/** Defines a test case. */ +TEST_GENERATION(test_02, // <- name + Generation::TestCase() + .options({ { "pretty_hol_printing", "pretty" } }) + .input( clause({ selected(ap(f, a) != ap(x, a)) })) // <- input clause + .expected(exactly( // <- a list of exactly which clauses are expected + clause({ ap(f, a) != ap(dbs(lam(y,ap(f, ap(z, y)))), a) }) // to be returned. Order matters! + )) + .higherOrder(true) + ) + +/** Defines a test case. */ +TEST_GENERATION(test_03, // <- name + Generation::TestCase() + .options({ { "pretty_hol_printing", "pretty" } }) + .input( clause({ selected(ap(ap(g, a), b) != ap(ap(w, b), a)) })) // <- input clause + .expected(exactly( // <- a list of exactly which clauses are expected + clause({ ap(ap(g, a), b) != ap(ap( dbs(lam(y, lam(p, ap(ap(g, ap(ap(m, y), p) ), ap(ap(k, y), p)) ))), b ), a) }) // to be returned. Order matters! + )) + .higherOrder(true) + ) + +#endif \ No newline at end of file diff --git a/UnitTests/tInduction.cpp b/UnitTests/tInduction.cpp index 67b12fe39f..eefe70a758 100644 --- a/UnitTests/tInduction.cpp +++ b/UnitTests/tInduction.cpp @@ -176,7 +176,7 @@ class GenerationTesterInduction return true; } - Kernel::RobSubstitution _subst; + Kernel::RobSubstitutionTS _subst; unordered_set _varsMatched; BacktrackData _btd; @@ -1207,4 +1207,4 @@ TEST_FUN(generalizations_03) { f(f(f(ph_s,sK2),f(ph_s,ph_s)),f(f(ph_s,g(sK2)),f(f(ph_s,sK2),ph_s)))) }), }), }); -} \ No newline at end of file +} diff --git a/UnitTests/tIterator.cpp b/UnitTests/tIterator.cpp index e35fd5aeb7..2337528ff0 100644 --- a/UnitTests/tIterator.cpp +++ b/UnitTests/tIterator.cpp @@ -70,7 +70,7 @@ TEST_FUN(testFlatMap1) { auto out = Stack{ 1, 2, 3, 4, 5, 6, }; ASS_EQ(iterTraits(in.iterFifo()) - .flatMap([](Stack const& i) { return i.iterFifo(); }) + .flatMap([](Stack i) { return ownedArrayishIterator(std::move(i)); }) .template collect(), out) } diff --git a/UnitTests/tSKIKBO.cpp b/UnitTests/tSKIKBO.cpp index 8fc1788fd0..20ee227224 100644 --- a/UnitTests/tSKIKBO.cpp +++ b/UnitTests/tSKIKBO.cpp @@ -58,8 +58,7 @@ SKIKBO skikbo(const Map& symbolWeights) { TEST_FUN(skikbo_test01) { DECL_DEFAULT_VARS // <- macro to initialize some syntax sugar for creating terms over a single uninterpreted sort DECL_SORT(srt) - DECL_ARROW_SORT(xSrt, {srt, srt}) - DECL_HOL_VAR(x0, 0, xSrt) + DECL_VAR_SORTED(x0, 0, arrow(srt, srt)) DECL_CONST(a, srt) // <- declares a constant symbol DECL_CONST(b, srt) // <- declares a constant symbol @@ -84,8 +83,7 @@ TEST_FUN(skikbo_test01) { TEST_FUN(skikbo_test02) { DECL_DEFAULT_VARS DECL_SORT(srt) - DECL_ARROW_SORT(xSrt, {srt, srt, srt}) - DECL_HOL_VAR(x0, 0, xSrt) + DECL_VAR_SORTED(x0, 0, arrow({srt, srt}, srt)) DECL_CONST(a, srt) DECL_CONST(b, srt) @@ -104,8 +102,7 @@ TEST_FUN(skikbo_test02) { TEST_FUN(skikbo_test03) { DECL_DEFAULT_VARS DECL_SORT(srt) - DECL_ARROW_SORT(xSrt, {srt, srt, srt}) - DECL_HOL_VAR(x0, 0, xSrt) + DECL_VAR_SORTED(x0, 0, arrow({srt, srt}, srt)) DECL_CONST(a, srt) DECL_CONST(b, srt) @@ -125,9 +122,8 @@ TEST_FUN(skikbo_test04) { DECL_DEFAULT_VARS DECL_COMBINATORS DECL_SORT(srt) - DECL_ARROW_SORT(fSrt, {srt, srt, srt, srt}) DECL_CONST(a, srt) - DECL_CONST(f, fSrt) + DECL_CONST(f, arrow({srt, srt, srt}, srt)) auto ord = skikbo( weights( @@ -145,12 +141,10 @@ TEST_FUN(skikbo_test05) { DECL_DEFAULT_VARS DECL_COMBINATORS DECL_SORT(srt) - DECL_ARROW_SORT(xSrt, {srt, srt}) - DECL_ARROW_SORT(fSrt, {srt, srt, srt}) - DECL_HOL_VAR(x0, 0, xSrt) + DECL_VAR_SORTED(x0, 0, arrow(srt,srt)) DECL_CONST(a, srt) DECL_CONST(b, srt) - DECL_CONST(f, fSrt) + DECL_CONST(f, arrow({srt,srt}, srt)) auto ord = skikbo( weights( @@ -175,9 +169,8 @@ TEST_FUN(skikbo_test06) { DECL_DEFAULT_SORT_VARS DECL_SORT(srt1) DECL_TYPE_CON(list, 1) - DECL_ARROW_SORT(fSrt, {srt1, srt1}) DECL_CONST(a, srt1) - DECL_POLY_CONST(f, 1, fSrt) + DECL_POLY_CONST(f, 1, arrow(srt1,srt1)) auto ord = skikbo( weights( diff --git a/UnitTests/tUnificationWithAbstraction.cpp b/UnitTests/tUnificationWithAbstraction.cpp index 85235d9d01..f624d1752a 100644 --- a/UnitTests/tUnificationWithAbstraction.cpp +++ b/UnitTests/tUnificationWithAbstraction.cpp @@ -8,9 +8,11 @@ * and in the source directory */ #include "Forwards.hpp" +#include "Indexing/SubstitutionTree.hpp" #include "Lib/Environment.hpp" #include "Shell/Options.hpp" +#include "Test/TestUtils.hpp" #include "Kernel/Unit.hpp" #include "Kernel/Clause.hpp" @@ -21,244 +23,1508 @@ #include "Kernel/OperatorType.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/RobSubstitution.hpp" +#include "Kernel/MismatchHandler.hpp" #include "Indexing/Index.hpp" #include "Indexing/LiteralSubstitutionTree.hpp" #include "Indexing/LiteralIndex.hpp" +#include "Indexing/TermSubstitutionTree.hpp" +#include "Indexing/TermIndex.hpp" +#if VHOL +#include "Shell/LambdaConversion.hpp" +#endif #include "Test/UnitTesting.hpp" +#include "Test/SyntaxSugar.hpp" + +#include "z3++.h" +#include -// TODO make this test use assertions, instead of printing output using namespace Kernel; using namespace Indexing; -using SortType = TermList; -TermList number(vstring n) -{ - return TermList(Term::create(env.signature->addIntegerConstant(n,false),0,0)); +#define TODO ASSERTION_VIOLATION_REP("TODO") + +#if VHOL +TermList toDBs(TermList t){ + return LambdaConversion().convertLambda(t); } -TermList var(unsigned i) +#endif + +Clause* unit(Literal* lit) { - return TermList(i,false); + return clause({ lit }); } -unsigned function_symbol(vstring name,unsigned arity,SortType srt) + +unique_ptr getTermIndex() +{ + return std::make_unique(); +} + +#if VHOL + // same as normal index now. should remove TODO + unique_ptr getHOLTermIndex() + { return std::make_unique(SplittingAlgo::HOL_UNIF); } +#endif + +auto getLiteralIndex() +{ return std::make_unique(); } + +template +struct UnificationResultSpec { + TermOrLit querySigma; + TermOrLit resultSigma; + Stack constraints; + + friend bool operator==(UnificationResultSpec const& l, UnificationResultSpec const& r) + { + return Test::TestUtils::eqModAC(l.querySigma, r.querySigma) + && Test::TestUtils::eqModAC(l.resultSigma, r.resultSigma) + && Test::TestUtils::permEq(l.constraints, r.constraints, + [](auto& l, auto& r) { return Test::TestUtils::eqModAC(l,r); }); + } + + friend std::ostream& operator<<(std::ostream& out, UnificationResultSpec const& self) + { + out << "{ querySigma = " << Test::pretty(self.querySigma) << ", resultSigma = " << Test::pretty(self.resultSigma) << ", cons = [ "; + for (auto& c : self.constraints) { + out << *c << ", "; + } + return out << "] }"; + } +}; + +using TermUnificationResultSpec = UnificationResultSpec; +using LiteralUnificationResultSpec = UnificationResultSpec; + +void checkLiteralMatches(LiteralSubstitutionTree& index, Literal* lit, Stack expected) { - bool added; - unsigned f = env.signature->addFunction(name,arity,added); - if(added){ - Signature::Symbol* symbol = env.signature->getFunction(f); - OperatorType* ot = OperatorType::getFunctionTypeUniformRange(arity,srt,srt); - symbol->setType(ot); + Stack is; + for (auto qr : iterTraits(index.getUwa(lit, /* complementary */ false)) ) { + // qr.substitution->numberOfConstraints(); + + is.push(LiteralUnificationResultSpec { + .querySigma = qr.unifier->apply(lit, QUERY_BANK), + .resultSigma = qr.unifier->apply(qr.literal, RESULT_BANK), + .constraints = *qr.unifier->getConstraints(), + }); + } + if (Test::TestUtils::permEq(is, expected, [](auto& l, auto& r) { return l == r; })) { + cout << "[ OK ] " << *lit << endl; + } else { + cout << "[ FAIL ] " << *lit << endl; + cout << "tree: " << multiline(index, 1) << endl; + cout << "query: " << *lit << endl; + + cout << "is:" << endl; + for (auto& x : is) + cout << " " << x << endl; + + cout << "expected:" << endl; + for (auto& x : expected) + cout << " " << x << endl; + + exit(-1); } - return f; + // cout << endl; } -TermList constant(vstring name,SortType srt) + +template +void checkTermMatchesWithUnifFun(TermSubstitutionTree& index, TermList term, Stack expected, F unifFun) { - auto c = function_symbol(name,0,srt); - Term* t = Term::create(c,0,0); - return TermList(t); + CALL("checkTermMatchesWithUnifFun(TermSubstitutionTree& index, TermList term, Stack expected, F unifFun)") + + Stack is; + for (auto qr : iterTraits(unifFun(index, term))) { + is.push(TermUnificationResultSpec { + .querySigma = qr.unifier->applyTo(term, QUERY_BANK) , + .resultSigma = qr.unifier->applyTo(qr.term, RESULT_BANK) , + .constraints = *qr.unifier->getConstraints(), + }); + } + if (Test::TestUtils::permEq(is, expected, [](auto& l, auto& r) { return l == r; })) { + cout << "[ OK ] " << term << endl; + } else { + cout << "[ FAIL ] " << term << endl; + + cout << "tree: " << multiline(index, 1) << endl; + cout << "query: " << term << endl; + + cout << "is:" << endl; + for (auto& x : is) + cout << " " << x << endl; + + cout << "expected:" << endl; + for (auto& x : expected) + cout << " " << x << endl; + + exit(-1); + } + // cout << endl; } -TermList int_constant(vstring name) + +void checkTermMatches(TermSubstitutionTree& index, TypedTermList term, Stack expected) { - return constant(name,IntegerConstantType::getSort()); + checkTermMatchesWithUnifFun(index, term, expected, + [&](auto& idx, auto t) { return idx.getUwa(term); }); } -TermList binary(Interpretation fun, TermList n1, TermList n2) + +#if VHOL +void checkHigherOrderTermMatches(TermSubstitutionTree& index, TypedTermList term, Stack expected) { - return TermList(Term::create2(env.signature->getInterpretingSymbol(fun),n1,n2)); + checkTermMatchesWithUnifFun(index, term, expected, + [&](auto& idx, auto t) { return idx.getHOLUnifiers(term); }); } -TermList int_plus(TermList n1, TermList n2) +#endif + +struct IndexTest { + unique_ptr index; + Stack insert; + TermSugar query; + Stack expected; + vstring uwa; + vstring fixedPointIteration = "off"; + + void run() { + CALL("IndexTest::run") + + env.options->set("unification_with_abstraction", uwa); + env.options->set("unification_with_abstraction_postpro", fixedPointIteration); + + DECL_PRED(dummy, Stack()) + for (auto x : this->insert) { + index->insert(x, dummy(), unit(dummy())); + } + + checkTermMatches(*this->index, TypedTermList(this->query, this->query.sort()),this->expected); + + } +}; + + +#define INT_SUGAR \ + __ALLOW_UNUSED( \ + DECL_DEFAULT_VARS \ + DECL_VAR(x0, 0) \ + DECL_VAR(x1, 1) \ + DECL_VAR(x2, 2) \ + DECL_VAR(x3, 3) \ + NUMBER_SUGAR(Int) \ + DECL_PRED(p, {Int}) \ + DECL_FUNC(f, {Int}, Int) \ + DECL_FUNC(g, {Int}, Int) \ + DECL_FUNC(f2, {Int, Int}, Int) \ + DECL_FUNC(g2, {Int, Int}, Int) \ + DECL_CONST(a, Int) \ + DECL_CONST(b, Int) \ + DECL_CONST(c, Int) \ + ) \ + + +#define RUN_TEST(name, sugar, ...) \ + TEST_FUN(name) { \ + __ALLOW_UNUSED(sugar) \ + __VA_ARGS__.run(); \ + } \ + +RUN_TEST(term_indexing_one_side_interp_01, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + f(1 + num(1)), + f(1 + a), + }, + .query = f(x), + .expected = { + + TermUnificationResultSpec + { .querySigma = f(1 + a), + .resultSigma = f(1 + a), + .constraints = Stack() }, + + TermUnificationResultSpec + { .querySigma = f(1 + num(1)), + .resultSigma = f(1 + num(1)), + .constraints = Stack() }, + + }, + }) + + +RUN_TEST(term_indexing_one_side_interp_02, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + f(1 + num(1)), + f(1 + a), + }, + .query = g(x), + .expected = Stack(), + }) + +RUN_TEST(term_indexing_one_side_interp_03, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + }, + .query = x.sort(Int), + .expected = { + + TermUnificationResultSpec + { .querySigma = 1 + a, + .resultSigma = 1 + a, + .constraints = Stack() }, + + TermUnificationResultSpec + { .querySigma = 1 + num(1), + .resultSigma = 1 + num(1), + .constraints = Stack() }, + + } + }) + + +RUN_TEST(term_indexing_one_side_interp_04, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + }, + .query = b + 2, + .expected = { + + TermUnificationResultSpec + { .querySigma = 2 + b, + .resultSigma = 1 + a, + .constraints = { 1 + a != 2 + b, } }, + + TermUnificationResultSpec + { .querySigma = 2 + b, + .resultSigma = 1 + num(1), + .constraints = { 2 + b != 1 + num(1), } }, + + } + }) + + + +RUN_TEST(term_indexing_one_side_interp_04_b, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + a, + }, + .query = 2 + a, + .expected = { + + TermUnificationResultSpec + { .querySigma = 2 + a, + .resultSigma = 1 + a, + .constraints = { 1 + a != 2 + a, } }, + + + } + }) + + +RUN_TEST(term_indexing_one_side_interp_04_c, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + f(1 + num(1)), + f(1 + a), + }, + .query = f( b + 2 ), + .expected = { + + TermUnificationResultSpec + { .querySigma = f( 2 + b ), + .resultSigma = f( 1 + a ), + .constraints = { 1 + a != 2 + b, } }, + + TermUnificationResultSpec + { .querySigma = f( 2 + b ), + .resultSigma = f( 1 + num(1) ), + .constraints = { 2 + b != 1 + num(1), } }, + + } + }) + +RUN_TEST(term_indexing_one_side_interp_04_d, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + g(f(1 + num(1))), + g(f(1 + a)), + }, + .query = g(f( b + 2 )), + .expected = { + + TermUnificationResultSpec + { .querySigma = g(f( 2 + b )), + .resultSigma = g(f( 1 + a )), + .constraints = { 1 + a != 2 + b, } }, + + TermUnificationResultSpec + { .querySigma = g(f( 2 + b )), + .resultSigma = g(f( 1 + num(1) )), + .constraints = { 2 + b != 1 + num(1), } }, + + } + }) + +RUN_TEST(term_indexing_one_side_interp_05, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + a, + }, + .query = b + 2, + .expected = { + TermUnificationResultSpec + { .querySigma = 2 + b, + .resultSigma = 1 + a, + .constraints = { 1 + a != 2 + b, } }, + + TermUnificationResultSpec + { .querySigma = 2 + b, + .resultSigma = 1 + num(1), + .constraints = { 2 + b != 1 + num(1), } }, + + TermUnificationResultSpec + { .querySigma = 2 + b, + .resultSigma = a, + .constraints = { 2 + b != a, } }, + + } +}) + + +RUN_TEST(term_indexing_one_side_interp_06, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + a, + }, + .query = x.sort(Int), + .expected = { + TermUnificationResultSpec + { .querySigma = 1 + a, + .resultSigma = 1 + a, + .constraints = Stack{} }, + + TermUnificationResultSpec + { .querySigma = 1 + num(1), + .resultSigma = 1 + num(1), + .constraints = Stack{} }, + + TermUnificationResultSpec + { .querySigma = a, + .resultSigma = a, + .constraints = Stack{} }, + + } +}) + + +RUN_TEST(term_indexing_one_side_interp_07, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + a, + f(x), + }, + .query = f(a), + .expected = { + TermUnificationResultSpec + { .querySigma = f(a), + .resultSigma = 1 + a, + .constraints = { 1 + a != f(a), } }, + + TermUnificationResultSpec + { .querySigma = f(a), + .resultSigma = 1 + num(1), + .constraints = { f(a) != 1 + num(1), } }, + + + TermUnificationResultSpec + { .querySigma = f(a), + .resultSigma = f(a), + .constraints = Stack{} }, + + } +}) + +RUN_TEST(term_indexing_one_side_interp_08, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + 1 + num(1), + 1 + a, + a, + f(x), + }, + .query = 3 + a, + .expected = { + TermUnificationResultSpec + { .querySigma = 3 + a, + .resultSigma = 1 + a, + .constraints = { 1 + a != 3 + a, } }, + + TermUnificationResultSpec + { .querySigma = 3 + a, + .resultSigma = 1 + num(1), + .constraints = { 3 + a != 1 + num(1), } }, + + TermUnificationResultSpec + { .querySigma = 3 + a, + .resultSigma = a, + .constraints = { 3 + a != a, } }, + + TermUnificationResultSpec + { .querySigma = 3 + a, + .resultSigma = f(x), + .constraints = { 3 + a != f(x) } }, + + } +}) + +TEST_FUN(term_indexing_poly_01) { - return binary(Theory::INT_PLUS,n1,n2); + env.options->set("unification_with_abstraction", "one_side_interpreted"); + env.options->set("unification_with_abstraction_postpro", "off"); + + auto index = getTermIndex(); + + DECL_DEFAULT_VARS + DECL_DEFAULT_SORT_VARS + NUMBER_SUGAR(Int) + DECL_PRED(p, {Int}) + DECL_CONST(a, Int) + DECL_POLY_CONST(h, 1, alpha) + DECL_SORT(A) + + index->insert(1 + a, p(1 + a), unit(p(a + a))); + index->insert(h(Int), p(h(Int)), unit(p(h(Int)))); + + checkTermMatches(*index, h(alpha), Stack{ + + TermUnificationResultSpec + { .querySigma = h(Int), + .resultSigma = h(Int), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = h(Int), + .resultSigma = 1 + a, + .constraints = { 1 + a != h(Int), } }, + + }); + + checkTermMatches(*index, h(A), Stack{ }); } -Literal* equals(TermList t1, TermList t2) + + +#define POLY_INT_SUGAR \ + DECL_DEFAULT_VARS \ + DECL_DEFAULT_SORT_VARS \ + NUMBER_SUGAR(Int) \ + DECL_POLY_CONST(b, 1, alpha) \ + DECL_POLY_CONST(a, 1, alpha) \ + DECL_POLY_FUNC(f, 1, {alpha}, alpha) \ + DECL_SORT(A) \ + DECL_CONST(someA, A) \ + + +#define HOL_SUGAR(...) \ + DECL_DEFAULT_VARS \ + DECL_DEFAULT_SORT_VARS \ + NUMBER_SUGAR(Int) \ + DECL_SORT(srt) \ + __VA_ARGS__ + + +RUN_TEST(term_indexing_poly_uwa_01, + POLY_INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "one_side_interpreted", + .insert = { + f(alpha, a(alpha)), + f(alpha, b(alpha)), + f(A, someA), + f(A, a(A)), + }, + .query = f(Int, a(Int) + x), + .expected = { + + TermUnificationResultSpec + { .querySigma = f(Int, a(Int) + x), + .resultSigma = f(Int, a(Int)), + .constraints = { a(Int) != a(Int) + x } }, + + TermUnificationResultSpec + { .querySigma = f(Int, a(Int) + y), + .resultSigma = f(Int, b(Int)), + .constraints = { b(Int) != a(Int) + y } }, + + } + }) + + +TEST_FUN(term_indexing_interp_only) { - SortType srt; - if(!SortHelper::tryGetResultSort(t1,srt)){ - cout << "Don't call equals with two variables" << endl; - exit(0); - } - return Literal::createEquality(true, t1,t2,srt); + env.options->set("unification_with_abstraction", "interpreted_only"); + env.options->set("unification_with_abstraction_postpro", "off"); + + auto index = getTermIndex(); + + DECL_DEFAULT_VARS + NUMBER_SUGAR(Int) + DECL_PRED(p, {Int}) + + DECL_CONST(a, Int) + DECL_CONST(b, Int) + + index->insert(num(1) + num(1), p(num(1) + num(1)), unit(p(num(1) + num(1)))); + index->insert(1 + a, p(1 + a), unit(p(a + a))); + + checkTermMatches(*index, b + 2, { + + TermUnificationResultSpec + { .querySigma = b + 2, + .resultSigma = 1 + a, + .constraints = { 1 + a != b + 2, } }, + + TermUnificationResultSpec + { .querySigma = b + 2, + .resultSigma = 1 + num(1), + .constraints = { 1 + num(1) != b + 2, } }, + + }); + + index->insert(a,p(a),unit(p(a))); + + checkTermMatches(*index, b + 2 , { + + TermUnificationResultSpec + { .querySigma = b + 2, + .resultSigma = 1 + a, + .constraints = { 1 + a != b + 2, } }, + + TermUnificationResultSpec + { .querySigma = b + 2, + .resultSigma = 1 + num(1), + .constraints = { 1 + num(1) != b + 2, } }, + + }); + } -Literal* pred(vstring p, TermList t, SortType srt) + +TEST_FUN(literal_indexing) { - bool added; - unsigned ps = env.signature->addPredicate(p,1,added); - if(added){ - Signature::Symbol* symbol = env.signature->getPredicate(ps); - OperatorType* ot = OperatorType::getPredicateTypeUniformRange(1,srt); - symbol->setType(ot); - } - return Literal::create1(ps,true,t); + env.options->set("unification_with_abstraction", "one_side_interpreted"); + env.options->set("unification_with_abstraction_postpro", "off"); + + auto index = getLiteralIndex(); + + DECL_DEFAULT_VARS + NUMBER_SUGAR(Int) + DECL_PRED(p, {Int}) + + DECL_CONST(a, Int) + DECL_CONST(b, Int) + + index->insert(p(num(1) + num(1)), unit(p(num(1) + num(1)))); + index->insert(p(1 + a), unit(p(1 + a))); + + checkLiteralMatches(*index, p(b + 2), { + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(num(1) + 1), + .constraints = { b + 2 != num(1) + 1 }, }, + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(a + 1), + .constraints = { b + 2 != a + 1 }, }, + + }); + + index->insert(p(b + 2),unit(p(b + 2))); + index->insert(p(2 + b),unit(p(2 + b))); + + checkLiteralMatches(*index, p(b + 2), { + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(num(1) + 1), + .constraints = { b + 2 != num(1) + 1 }, }, + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(a + 1), + .constraints = { b + 2 != a + 1 }, }, + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(b + 2), + .constraints = Stack{ }, }, + + LiteralUnificationResultSpec { + .querySigma = p(b + 2), + .resultSigma = p(b + 2), + .constraints = Stack{ b + 2 != 2 + b }, }, + + }); + + } -Literal* pred(vstring p, TermList t) + +#if VHOL + +TEST_FUN(higher_order) { - SortType srt; - if(!SortHelper::tryGetResultSort(t,srt)){ - cout << "Don't call this pred with a variable argument" << endl; - exit(0); - } - return pred(p,t,srt); + DECL_DEFAULT_VARS + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + DECL_CONST(a, arrow(srt, srt)) + DECL_CONST(b, arrow(srt, srt)) + DECL_CONST(c, srt) + DECL_CONST(d, srt) + DECL_CONST(f, arrow(arrow(srt, srt), srt)) + DECL_CONST(g, arrow(srt, arrow(srt, srt))) + + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + index->insert(ap(f,a), 0, 0); + + checkHigherOrderTermMatches(*index, ap(f,b), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(f,b), + .resultSigma = ap(f,a), + .constraints = Stack{a != b } }, + + }); + + index->insert(ap(g,c), 0, 0); + index->insert(g, 0, 0); + + checkHigherOrderTermMatches(*index, TypedTermList(x, arrow(srt, srt)), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(g,c), + .resultSigma = ap(g,c), + .constraints = Stack{} }, + + }); + + checkHigherOrderTermMatches(*index, ap(f,b), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(f,b), + .resultSigma = ap(f,a), + .constraints = Stack{ a != b } }, + + }); + + checkHigherOrderTermMatches(*index, ap(g,d), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(g,d), + .resultSigma = ap(g,c), + .constraints = Stack{ ap(g,c) != ap(g,d) } }, + + }); } -Clause* unit(Literal* lit) + +TEST_FUN(higher_order2) { - static Inference testInf = Kernel::NonspecificInference0(UnitInputType::ASSUMPTION, InferenceRule::INPUT); - Clause * cl = new(1) Clause(1,testInf); - (* cl)[0] = lit; - return cl; -} + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, srt) + DECL_HOL_VAR(x, 9, arrow(srt, srt)) + DECL_HOL_VAR(x2, 10, arrow(srt, arrow(srt, srt))) + DECL_HOL_VAR(x3, 11, srt) + DECL_HOL_VAR(z, 3, srt) + DECL_HOL_VAR(x4, 0, srt) + DECL_HOL_VAR(x5, 1, arrow(srt, srt)) + DECL_HOL_VAR(x7, 1, arrow(srt, arrow(srt, srt))) + DECL_HOL_VAR(x8, 2, srt) + + index->insert(ap(x, a), 0, 0); + + auto id = toDBs(lam(z, z)); + auto conFun = toDBs(lam(z, a)); + + checkHigherOrderTermMatches(*index, a, Stack{ + TermUnificationResultSpec + { .querySigma = a, + .resultSigma = ap(id,a), + .constraints = Stack{} }, -LiteralIndexingStructure* getBasicIndex() + TermUnificationResultSpec + { .querySigma = a, + .resultSigma = ap(conFun,a), + .constraints = Stack{} }, + + }); + + index->insert(ap(ap(x2, a), x3), 0, 0); + + checkHigherOrderTermMatches(*index, x3, Stack{ + + TermUnificationResultSpec + { .querySigma = x4, + .resultSigma = ap(ap(x7, a), x8), + .constraints = {x4 != ap(ap(x7, a), x8)} }, + + TermUnificationResultSpec + { .querySigma = x4, + .resultSigma = ap(x5,a), + .constraints = {x4 != ap(x5,a) } }, + + }); + +} + +TEST_FUN(higher_order3) { - // Let's create an index with some data in it - // We pass true to say that we want to use constraints - LiteralIndexingStructure * is = new LiteralSubstitutionTree(true); + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + DECL_CONST(a, arrow(srt,srt)) + DECL_CONST(f, arrow(arrow(srt,srt), srt)) + DECL_HOL_VAR(x, 0, srt) - TermList one_plus_one = int_plus(number("1"),number("1")); - TermList one_plus_a = int_plus(number("1"),int_constant("a")); + auto lamTerm = toDBs(lam(x, ap(a, x))); + auto t = ap(f, lamTerm); - Literal* p1 = pred("p",one_plus_one); - Literal* p2 = pred("p",one_plus_a); + index->insert(t, 0, 0); - is->insert(p1,unit(p1)); - is->insert(p2,unit(p2)); + checkHigherOrderTermMatches(*index, ap(f,a), Stack{ - return is; + TermUnificationResultSpec + { .querySigma = ap(f,a), + .resultSigma = toDBs(ap(f, lam(x, ap(a, x)))), + .constraints = Stack{ } }, + }); } -void reportMatches(LiteralIndexingStructure* index, Literal* qlit) +TEST_FUN(higher_order4) { - SLQueryResultIterator it= index->getUnificationsWithConstraints(qlit,false,true); - cout << endl; - cout << "Unify with " << qlit->toString() << endl; - while(it.hasNext()){ - SLQueryResult qr = it.next(); - cout << qr.clause->toString() << " matches with substitution: "<< endl; - // cout << qr.substitution->tryGetRobSubstitution()->toString() << endl; - cout << "and constraints: "<< endl; - auto constraints = qr.constraints; - for(unsigned i=0;isize();i++){ - auto con = (*constraints)[i]; - TermList qT = qr.substitution->applyTo(con.first.first,con.first.second); - TermList rT = qr.substitution->applyTo(con.second.first,con.second.second); - - cout << "> "<< qT.toString() << "!=" << rT.toString() << "\t\t from " << con.first.first.toString() << "!=" << con.second.first.toString() << endl; - } - } - cout << endl; + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, srt) + DECL_CONST(g, arrow(srt,srt)) + DECL_CONST(f, arrow(arrow(srt,srt), arrow(srt, srt))) + DECL_HOL_VAR(x, 0, arrow(srt,srt)) + + + auto t = ap(ap(f, g), a); + + index->insert(t, 0, 0); + + checkHigherOrderTermMatches(*index, ap(ap(f, x), ap(x,a)), Stack{ + }); } -// This test demonstrates the current issue. The constraints produced depend on -TEST_FUN(current_issue) +TEST_FUN(higher_order5) { - env.options->setUWA(Options::UnificationWithAbstraction::ALL); - - LiteralIndexingStructure* index = getBasicIndex(); - - Literal* qlit = pred("p",int_plus(int_constant("b"),number("2"))); - - reportMatches(index,qlit); - // Currently this produces - //1. p($sum(1,1)) [input] matches with constraints - //> $sum(b,2)!=$sum(1,1) - //2. p($sum(1,a)) [input] matches with constraints - //> $sum(b,2)!=$sum(1,a) - - index->insert(qlit,unit(qlit)); - - reportMatches(index,qlit); - // Whereas this produces - //2. p($sum(1,a)) [input] matches with constraints - //> b!=1 - //> 2!=a - //1. p($sum(1,1)) [input] matches with constraints - //> b!=1 - //> 2!=1 - //3. p($sum(b,2)) [input] matches with constraints + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, srt) + DECL_CONST(g, arrow(srt,srt)) + DECL_CONST(f, arrow(arrow(srt,srt), arrow(srt, srt))) + DECL_HOL_VAR(x, 0, arrow(srt,srt)) + + + auto t = ap(ap(f, g), a); + + index->insert(t, 0, 0); + + checkHigherOrderTermMatches(*index, ap(ap(f, x), ap(x,a)), Stack{ + + }); } -static const int NORM_QUERY_BANK=2; -static const int NORM_RESULT_BANK=3; -struct testMismatchHandler : MismatchHandler +TEST_FUN(higher_order6) { -testMismatchHandler(Stack* c) : _constraints(c) {} -bool handle(RobSubstitution* subst, TermList query, unsigned index1, TermList node, unsigned index2){ - ASS(index1 == NORM_QUERY_BANK && index2 == NORM_RESULT_BANK); - static unsigned _var = 0; - unsigned x = _var++; - TermList nodeVar = TermList(x,true); - subst->bindSpecialVar(x,node,index2); - auto constraint = make_pair(make_pair(query,index1),make_pair(nodeVar,index2)); - _constraints->push(constraint); - return true; + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(f, arrow(srt, arrow(srt, srt))) + DECL_HOL_VAR(x0, 0, arrow(srt, srt)) + DECL_HOL_VAR(x1, 1, srt) + + DECL_HOL_VAR(x, 10, srt) + DECL_HOL_VAR(z, 11, srt) + DECL_HOL_VAR(y, 12, arrow(srt, srt)) + + auto t = ap(ap(f, x), x); + + index->insert(t, 0, 0); + + checkHigherOrderTermMatches(*index, ap(ap(f, ap(y,z)), z), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(ap(f, ap(x0,x1)), x1), + .resultSigma = ap(ap(f, x1), x1), + .constraints = { ap(x0,x1) != x1 } }, + + }); } -Stack* _constraints; -}; -void reportRobUnify(TermList a, TermList b) +TEST_FUN(higher_order7) { - cout << endl; - cout << "Unifying " << a.toString() << " with " << b.toString() << endl; - RobSubstitution sub; - Stack constraints; - //MismatchHandler* hndlr = new testMismatchHandler(&constraints); - MismatchHandler* hndlr = new UWAMismatchHandler(constraints); - bool result = sub.unify(a,NORM_QUERY_BANK,b,NORM_RESULT_BANK,hndlr); - cout << "Result is " << result << endl; - if(result){ - // cout << "> Substitution is " << endl << sub.toString(); - cout << "> Constraints are:" << endl; - auto rs = ResultSubstitution::fromSubstitution(&sub,NORM_QUERY_BANK,NORM_RESULT_BANK); - for(unsigned i=0;i "<< qT.toString() << "!=" << rT.toString() << "\t\t from " << con.first.first.toString() << "!=" << con.second.first.toString() << endl; - } - } - cout << endl; + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(f, arrow(srt, arrow(srt, srt))) + DECL_CONST(g, arrow(srt, srt)) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(z, 1, srt) + + auto t = ap(ap(f, x), x); + + index->insert(t, 0, 0); + + checkHigherOrderTermMatches(*index, ap(ap(f, ap(g,z)), z), Stack{ + }); } -TEST_FUN(using_robsub) +TEST_FUN(higher_order8) { - env.options->setUWA(Options::UnificationWithAbstraction::ALL); + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + env.options->set("print_var_banks", "true"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, srt) + DECL_CONST(g, arrow(srt,srt)) + + DECL_HOL_VAR(x, 10, arrow(srt,srt)) + DECL_HOL_VAR(z, 11, arrow(srt,srt)) + + DECL_HOL_VAR(z2, 12, srt) + DECL_HOL_VAR(z3, 13, srt) + + auto id = toDBs(lam(z2, z2)); + auto conFun = toDBs(lam(z2, a)); + + auto b1 = toDBs(lam(z3, ap(g, ap(id, z3)))); + auto b2 = toDBs(lam(z3, ap(g, ap(conFun, z3)))); + + index->insert(ap(x,a), 0, 0); + + index->insert(ap(z,a), 0, 0); + index->insert(ap(g,ap(z, a)), 0, 0); + + cout << *index << endl; + + checkHigherOrderTermMatches(*index, ap(g,a), Stack{ + + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(b1,a), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(b2,a), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(b1,a), + .constraints = Stack{ } }, - TermList b_plus_two = int_plus(int_constant("b"),number("2")); - TermList one_plus_a = int_plus(number("1"),int_constant("a")); - TermList x_plus_two = int_plus(var(0),number("2")); + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(b2,a), + .constraints = Stack{ } }, - reportRobUnify(b_plus_two,x_plus_two); - reportRobUnify(b_plus_two,one_plus_a); + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(g,ap(id,a)), //really irritating variable renaming... + .constraints = Stack{ } }, + TermUnificationResultSpec + { .querySigma = ap(g,a), + .resultSigma = ap(g,ap(conFun,a)), //really irritating variable renaming... + .constraints = Stack{ } }, + + }); } +TEST_FUN(higher_order9) +{ + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + env.options->set("print_var_banks", "true"); + env.options->set("hol_unif_depth", "9"); + auto index = getHOLTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, srt) + DECL_CONST(b, srt) + DECL_CONST(g, arrow(srt,arrow(srt, srt))) + + DECL_HOL_VAR(x, 10, arrow(srt,arrow(srt, srt))) + + DECL_HOL_VAR(x0, 0, srt) + DECL_HOL_VAR(x1, 1, srt) + DECL_HOL_VAR(x2, 2, srt) + DECL_HOL_VAR(x3, 3, srt) + + index->insert(ap(ap(g,a),b), 0, 0); + + auto b1 = toDBs(lam(x0, lam(x1, ap(ap(g, ap(ap(lam(x2, lam(x3, x3)), x0), x1) ), ap(ap(lam(x2, lam(x3, x2)), x0), x1) ) ))); + auto b2 = toDBs(lam(x0, lam(x1, ap(ap(g, ap(ap(lam(x2, lam(x3, a)), x0), x1) ), ap(ap(lam(x2, lam(x3, x2)), x0), x1) ) ))); + auto b3 = toDBs(lam(x0, lam(x1, ap(ap(g, ap(ap(lam(x2, lam(x3, x3)), x0), x1) ), ap(ap(lam(x2, lam(x3, b)), x0), x1) ) ))); + auto b4 = toDBs(lam(x0, lam(x1, ap(ap(g, ap(ap(lam(x2, lam(x3, a)), x0), x1) ), ap(ap(lam(x2, lam(x3, b)), x0), x1) ) ))); + + checkHigherOrderTermMatches(*index, ap(ap(x,b),a), Stack{ -TEST_FUN(complex_case) + TermUnificationResultSpec + { .querySigma = ap(ap(b1,b),a), + .resultSigma = ap(ap(g,a),b), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = ap(ap(b2,b),a), + .resultSigma = ap(ap(g,a),b), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = ap(ap(b3,b),a), + .resultSigma = ap(ap(g,a),b), + .constraints = Stack{ } }, + + TermUnificationResultSpec + { .querySigma = ap(ap(b4,b),a), + .resultSigma = ap(ap(g,a),b), + .constraints = Stack{ } }, + + }); +} + +// AYB not a real test, but if run with debugging info +// in HOLSubstitutionTree, very useful for ensuring +// that insertions and deletions are taking place correctly +/*TEST_FUN(higher_order_tree) { - env.options->setUWA(Options::UnificationWithAbstraction::ALL); + env.property->forceHigherOrder(); + + env.options->set("pretty_hol_printing","pretty"); + env.options->set("func_ext", "abstraction"); + auto index = getTermIndex(); + + DECL_DEFAULT_SORT_VARS + DECL_SORT(srt) + + DECL_CONST(a, arrow(srt,srt)) + DECL_CONST(b, srt) + DECL_CONST(d, arrow(srt, arrow(srt, srt))) + DECL_CONST(e, srt) + DECL_CONST(f, arrow(arrow(srt,srt), srt)) + DECL_HOL_VAR(x, 0, srt) + DECL_HOL_VAR(y, 1, arrow(srt,srt)) + DECL_HOL_VAR(z, 2, arrow(srt,srt)) + DECL_BOOL_SORT(bools); + DECL_CONST(p, arrow(srt,bools)) + DECL_CONST(g, arrow(bools,srt)) - // The complex case is where we have a variable that needs to be instantiated elsewhere - // e.g. unifying f(f(g(X),X),f(Y,a)) with f(f(1,2),(3,g(Z))) - - unsigned f = function_symbol("f",2,IntegerConstantType::getSort()); - unsigned g = function_symbol("g",1,IntegerConstantType::getSort()); - TermList query = TermList(Term::create2(f,TermList(Term::create2(f,TermList(Term::create1(g,var(0))),var(0))), - TermList(Term::create2(f,var(1),TermList(constant("a",IntegerConstantType::getSort())))))); - TermList node = TermList(Term::create2(f,TermList(Term::create2(f,number("1"),number("2"))), - TermList(Term::create2(f,number("3"),TermList(Term::create1(g,var(1))))))); - reportRobUnify(query,node); + auto t = ap(f, lam(x, ap(a, x))); + t = toDBs(t); + auto t2 = ap(f,lam(x, b)); + t2 = toDBs(t2); - LiteralIndexingStructure* index = new LiteralSubstitutionTree(true); - Literal* nlit = pred("p",node); - index->insert(nlit,unit(nlit)); - Literal* qlit = pred("p",query); - reportMatches(index,qlit); + index->insert(t, 0, 0); + index->insert(t2, 0, 0); + + index->remove(t2, 0, 0); + index->remove(t, 0, 0); + + index->insert(ap(y,b), 0, 0); + index->insert(ap(y, ap(a,b)), 0, 0); + index->insert(ap(z, ap(a,b)), 0, 0); + + index->remove(ap(y,b), 0, 0); + index->remove(ap(y, ap(a,b)), 0, 0); + index->remove(ap(z, ap(a,b)), 0, 0); + + index->insert(ap(f,ap(d,b)), 0, 0); + index->insert(ap(f,ap(d,e)), 0, 0); + + index->remove(ap(f,ap(d,b)), 0, 0); + index->remove(ap(f,ap(d,e)), 0, 0); + + index->insert(ap(p,b), 0, 0); + index->insert(ap(p,e), 0, 0); + + index->remove(ap(p,b), 0, 0); + index->remove(ap(p,e), 0, 0); + + index->insert(ap(g, ap(p,b)), 0, 0); + index->insert(ap(g, ap(p,e)), 0, 0); +}*/ + +#endif + +Option runRobUnify(TermList a, TermList b, Options::UnificationWithAbstraction opt, bool fixedPointIteration) { + + Kernel::UnificationAlgorithms::AbstractingUnification au(MismatchHandler(opt), fixedPointIteration); + + static Kernel::RobSubstitutionTL subst; + subst.reset(); + + auto unifs = au.unifiers(a, b, &subst); + + if (unifs.hasNext()) { + Kernel::RobSubstitutionTL* sub = unifs.next(); + return some(TermUnificationResultSpec { + .querySigma = sub->apply(a, DEFAULT_BANK), + .resultSigma = sub->apply(b, DEFAULT_BANK), + .constraints = *sub->constraints(), + }); + } else { + return {}; + } +} + +void checkRobUnify(TermList a, TermList b, Options::UnificationWithAbstraction opt, bool fixedPointIteration, TermUnificationResultSpec exp) +{ + auto is = runRobUnify(a,b,opt, fixedPointIteration); + if (is.isSome() && is.unwrap() == exp) { + cout << "[ OK ] " << a << " unify " << b << endl; + } else { + cout << "[ FAIL ] " << a << " unify " << b << endl; + cout << "is: " << is << endl; + cout << "expected: " << exp << endl; + exit(-1); + } +} +void checkRobUnifyFail(TermList a, TermList b, Options::UnificationWithAbstraction opt, bool fixedPointIteration) +{ + auto is = runRobUnify(a,b,opt, fixedPointIteration); + if(is.isNone()) { + cout << "[ OK ] " << a << " unify " << b << endl; + } else { + cout << "[ FAIL ] " << a << " unify " << b << endl; + cout << "is: " << is << endl; + cout << "expected: nothing" << endl; + exit(-1); + } } + +#define ROB_UNIFY_TEST(name, opt, fixedPointIteration, lhs, rhs, ...) \ + TEST_FUN(name) \ + { \ + INT_SUGAR \ + checkRobUnify(lhs, rhs, opt, fixedPointIteration, __VA_ARGS__ ); \ + } \ + +#define ROB_UNIFY_TEST_FAIL(name, opt, fixedPointIteration, lhs, rhs) \ + TEST_FUN(name) \ + { \ + INT_SUGAR \ + checkRobUnifyFail(lhs, rhs, opt, fixedPointIteration); \ + } \ + +ROB_UNIFY_TEST(rob_unif_test_01, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f(b + 2), + f(x + 2), + TermUnificationResultSpec { + .querySigma = f(b + 2), + .resultSigma = f(x + 2), + .constraints = { x + 2 != b + 2 }, + }) + +ROB_UNIFY_TEST(rob_unif_test_02, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f(b + 2), + f(x + 2), + TermUnificationResultSpec { + .querySigma = f(b + 2), + .resultSigma = f(x + 2), + .constraints = { x + 2 != b + 2 }, + }) + +ROB_UNIFY_TEST(rob_unif_test_03, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f(x + 2), + f(a), + TermUnificationResultSpec { + .querySigma = f(x + 2), + .resultSigma = f(a), + .constraints = { x + 2 != a }, + }) + +ROB_UNIFY_TEST_FAIL(rob_unif_test_04, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f(a), g(1 + a)) + + +ROB_UNIFY_TEST(rob_unif_test_05, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f(a + b), + f(x + y), + TermUnificationResultSpec { + .querySigma = f(a + b), + .resultSigma = f(x + y), + .constraints = { x + y != a + b }, + }) + +ROB_UNIFY_TEST(rob_unif_test_06, + Options::UnificationWithAbstraction::ONE_INTERP, + /* withFinalize */ false, + f2(x, x + 1), + f2(a, a), + TermUnificationResultSpec { + .querySigma = f2(a, a + 1), + .resultSigma = f2(a, a), + .constraints = { a != a + 1 }, + }) + +// ROB_UNIFY_TEST(over_approx_test_1_bad, +// Options::UnificationWithAbstraction::AC1, +// f2(x + b, x), +// f2(a , a), +// TermUnificationResultSpec { +// .querySigma = f2(a + b, a), +// .resultSigma = f2(a , a), +// .constraints = { a != a + b }, +// }) +// +// ROB_UNIFY_TEST_FAIL(over_approx_test_1_good, +// Options::UnificationWithAbstraction::AC1, +// f2(x, x + b), +// f2(a, a )) + +ROB_UNIFY_TEST(over_approx_test_2_bad_AC1, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(x, a + x), + f2(c, b + a), + TermUnificationResultSpec { + .querySigma = f2(c, a + c), + .resultSigma = f2(c, b + a), + .constraints = { c != b }, + }) + +ROB_UNIFY_TEST_FAIL(over_approx_test_2_bad_AC1_fixedPointIteration, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ true, + f2(x, a + x), + f2(c, b + a) + ) + +ROB_UNIFY_TEST_FAIL(over_approx_test_2_good_AC1, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(a + x, x), + f2(b + a, c)) + +ROB_UNIFY_TEST(bottom_constraint_test_1_bad_AC1, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(f2(y, x), a + y + x), + f2(f2(b, c), c + b + a), + TermUnificationResultSpec { + .querySigma = f2(f2(b,c), a + b + c), + .resultSigma = f2(f2(b,c), c + b + a), + .constraints = Stack{ b + c != c + b }, + }) + +ROB_UNIFY_TEST(bottom_constraint_test_1_bad_AC1_fixedPointIteration, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ true, + f2(f2(y, x), a + y + x), + f2(f2(b, c), c + b + a), + TermUnificationResultSpec { + .querySigma = f2(f2(b,c), a + b + c), + .resultSigma = f2(f2(b,c), c + b + a), + .constraints = Stack{ }, + }) + +ROB_UNIFY_TEST(bottom_constraint_test_1_good_AC1, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(a + x + y, f2(x, y)), + f2(c + b + a, f2(b, c)), + // f2(a + x, x), + // f2(b + a, b), + TermUnificationResultSpec { + .querySigma = f2(a + b + c, f2(b,c)), + .resultSigma = f2(c + b + a, f2(b,c)), + .constraints = Stack{}, + }) + + +ROB_UNIFY_TEST(ac_bug_01, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + a + b + c + a, + a + b + x + y, + TermUnificationResultSpec { + .querySigma = a + b + c + a, + .resultSigma = a + b + x + y, + .constraints = { c + a != x + y }, + }) + +ROB_UNIFY_TEST(ac_test_01_AC1, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(b, a + b + c), + f2(b, x + y + c), + TermUnificationResultSpec { + .querySigma = f2(b, a + b + c), + .resultSigma = f2(b, x + y + c), + .constraints = { a + b != x + y }, + }) + +ROB_UNIFY_TEST(ac_test_02_AC1_good, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(a + b + c, c), + f2(x + y + z, z), + TermUnificationResultSpec { + .querySigma = f2(a + b + c, c), + .resultSigma = f2(x + y + c, c), + .constraints = { a + b != x + y }, + }) + +ROB_UNIFY_TEST(ac_test_02_AC1_bad, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ false, + f2(c, a + b + c), + f2(z, x + y + z), + TermUnificationResultSpec { + .querySigma = f2(c, a + b + c), + .resultSigma = f2(c, x + y + c), + .constraints = { a + b + c != x + y + c }, + }) + +ROB_UNIFY_TEST(ac_test_02_AC1_bad_fixedPointIteration, + Options::UnificationWithAbstraction::AC1, + /* withFinalize */ true, + f2(c, a + b + c), + f2(z, x + y + z), + TermUnificationResultSpec { + .querySigma = f2(c, a + b + c), + .resultSigma = f2(c, x + y + c), + .constraints = { a + b != x + y }, + }) + +ROB_UNIFY_TEST(ac2_test_01, + Options::UnificationWithAbstraction::AC2, + /* withFinalize */ false, + f2(x, a + b + c), + f2(x, x + b + a), + TermUnificationResultSpec { + .querySigma = f2(c, a + b + c), + .resultSigma = f2(c, c + b + a), + .constraints = Stack{}, + }) + +ROB_UNIFY_TEST(ac2_test_02, + Options::UnificationWithAbstraction::AC2, + /* withFinalize */ false, + f2(a + b + c, f2(x,b)), + f2(x + y + a, f2(x,y)), + TermUnificationResultSpec { + .querySigma = f2(a + b + c, f2(c,b)), + .resultSigma = f2(c + b + a, f2(c,b)), + .constraints = Stack{}, + }) + +ROB_UNIFY_TEST(ac2_test_02_bad, + Options::UnificationWithAbstraction::AC2, + /* withFinalize */ false, + f2(f2(x,b), a + b + c), + f2(f2(x,y), x + y + a), + TermUnificationResultSpec { + .querySigma = f2(f2(x,b), a + b + c), + .resultSigma = f2(f2(x,b), x + b + a), + .constraints = Stack{ b + c != x + b }, + }) + +ROB_UNIFY_TEST(ac2_test_02_bad_fixedPointIteration, + Options::UnificationWithAbstraction::AC2, + /* withFinalize */ true, + f2(f2(x,b), a + b + c), + f2(f2(x,y), x + y + a), + TermUnificationResultSpec { + .querySigma = f2(f2(c,b), a + b + c), + .resultSigma = f2(f2(c,b), c + b + a), + .constraints = Stack{ }, + }) + + +ROB_UNIFY_TEST(top_level_constraints_1, + Options::UnificationWithAbstraction::AC2, + /* withFinalize */ false, + a + y + x, + a + b + c, + TermUnificationResultSpec { + .querySigma = a + y + x, + .resultSigma = a + b + c, + .constraints = Stack{ b + c != x + y }, + }) + +RUN_TEST(top_level_constraints_2_with_fixedPointIteration, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "ac2", + .fixedPointIteration = "on", + .insert = { + a + b + c, + b, + a + b + f(a) + c, + f(x), + f(a), + }, + .query = a + y + x, + .expected = { + + TermUnificationResultSpec + { .querySigma = a + x0 + x1, + .resultSigma = a + b + c, + .constraints = Stack{ b + c != x1 + x0 } }, + + TermUnificationResultSpec + { .querySigma = a + x2 + x3, + .resultSigma = a + b + f(a) + c, + .constraints = Stack{ b + f(a) + c != x3 + x2 } }, + + }, + }) + + +RUN_TEST(top_level_constraints_2, + INT_SUGAR, + IndexTest { + .index = getTermIndex(), + .uwa = "ac2", + .insert = { + a + b + c, + b, + a + b + a + c, + f(x), + f(a), + }, + .query = a + y + x, + .expected = { + + TermUnificationResultSpec + { .querySigma = a + x0 + x1, + .resultSigma = a + b + c, + .constraints = Stack{ a + b + c != a + x1 + x0 } }, + + TermUnificationResultSpec + { .querySigma = a + x2 + x3, + .resultSigma = a + b + a + c, + .constraints = Stack{ a + b + a + c != a + x3 + x2 } }, + + }, + }) \ No newline at end of file diff --git a/samplerHOL.txt b/samplerHOL.txt new file mode 100644 index 0000000000..2fe448bfee --- /dev/null +++ b/samplerHOL.txt @@ -0,0 +1,401 @@ +# PREPROCESSING + +# blocked_clause_elimination (preferring to skip for HO) +# > bce ~cat off:5,on:1 + +# equality_proxy (no ep for Ahmed) +#> ep ~cat off:70,RST:2,R:3,RSTC:2,RS:3 +# mono_ep +# ep!=off > mep ~cat on:10,off:1 + +# equality_resolution_with_deletion +> erd ~cat on:20,off:1 + +# function_definition_elimination +> fde ~cat all:20,none:2,unused:1 + +# general_splitting (no gsp for Ahmed) +# > gsp ~cat off:8,on:1 + +# inline_let -- this is probably irrelevant on TPTP anyway +> ile ~cat off:30,on:1 + +# naming +> $nm ~cat Z:1,NZ:5 +$nm=Z > nm ~cat 0:1 +$nm=NZ > nm ~sgd 0.07,2 + +# inequality_splitting +> ins ~cat 0:40,1:8,2:12,3:17,4:5,5:2 + +# random_polarities +> rp ~cat off:10,on:1 + +# twee_goal_transformation (not currently with HO) +> tgt ~cat off:20,ground:5,full:1 + +# set_of_support +> sos ~cat off:100,on:36,all:15 + +# sine_selection +> ss ~cat off:204,axioms:77,included:5 + +# sine_depth +ss!=off > sd ~cat 0:45,1:13,2:12,3:5,4:4,5:4,7:3,10:2,12:1,15:1 + +# sine_generality_threshold +ss!=off > sgt ~cat 0:7,5:1,10:1,15:1,20:1,30:1,50:1,100:1 + +# sine_tolerance +ss!=off > st ~cat -1.0:50,1.0:150,1.5:37,2.0:60,2.5:20,3.0:70,3.5:15,4.0:60,4.5:15,5.0:50,5.5:10,6.0:30,7.0:20 + +# unused_predicate_definition_removal +> updr ~cat on:25,off:1 + +# SATURATION + +# saturation algorithm +> sa ~cat lrs:144,otter:25,discount:117 + +# literal selection #(kicked out looakead selections: 11:131,-11:131,1011:357,-1011:357, not compatible with HO) +> $s_pos ~cat Y:4,N:1 +$s_pos=Y > s ~cat 0:11,1:31,2:52,3:21,4:22,10:300,20:11,21:66,22:11,30:6,31:14,32:4,33:10,34:3,35:8,666:50,1002:141,1003:14,1004:23,1010:145,1666:50 +$s_pos=N > s ~cat -1:31,-2:52,-3:21,-4:22,-10:300,-20:11,-21:66,-22:11,-30:6,-31:14,-32:4,-33:10,-34:3,-35:8,-666:50,-1002:141,-1003:14,-1004:23,-1010:145,-1666:50 + +# lookahaed_delay +> $ls ~cat off:1 +s=11 > $ls ~cat on:1 +s=-11 > $ls ~cat on:1 +s=1011 > $ls ~cat on:1 +s=-1011 > $ls ~cat on:1 + +$ls=on > lsd ~cat 0:20,1:1,5:1,10:1,20:1,50:1,100:1 + +# age/weight ratio +> awr ~u2r -10;4;: + +# random_awr +> rawr ~cat off:8,on:1 + +# lrs_weight_limit_only +sa=lrs > lwlo ~cat off:15,on:1 + +# lrs_estimate_correction_coef +sa=lrs > lecc ~cat 1:10,666:1 +lecc!=1 > lecc ~uf 0.5,2.0 + +# age_weight_ratio_shape +> awrs ~cat constant:20,converge:2,decay:1 + +# age_weight_ratio_shape_frequency +awrs!=constant > awrsf ~ui 1,500 + +# nongoal_weight_coefficient +> nwc ~cat 1:2,2:1 +nwc!=1 > nwc ~ui 2,15 + +# restrict_nwc_to_goal_constants +nwc!=1 > rnwc ~cat off:10,on:1 + +# literal_maximality_aftercheck +> lma ~cat off:500,on:83 + +# POSITIVE LITERAL SPLIT QUEUE +> plsq ~cat off:4,on:1 + +# positive_literal_split_queue_layered_arrangement +plsq=on > plsql ~cat on:1,off:8 + +# positive_literal_split_queue_cutoffs +plsq=on > plsqc ~cat 0:12,1:30,2:4,3:1,4:1 + +# positive_literal_split_queue_ratios +plsq=on > plsqr ~u2r -5;7;, + +# INFERENCES + +# superposition (don't turn this off at home!) +> sup ~cat on:100,off:1 + +# simultaneous_superposition +sup=on > sims ~cat on:50,off:1 + +# superposition_from_variables +sup=on > sfv ~cat on:38,off:1 + +# forward_subsumption +> fs ~cat on:500,off:31 + +# forward_subsumption_resolution +fs=off > fsr ~cat off:1 +fs=on > fsr ~cat on:500,off:193 + +# forward_subsumption_demodulation +> fsd ~cat off:279,on:7 + +# forward_subsumption_demodulation_max_matches +fsd=on > fsdmm ~cat 0:10,1:3,2:2,3:1 + +# backward_demodulation +> bd ~cat all:500,off:245,preordered:91 + +# backward_subsumption +fs!=off > bs ~cat off::500,unit_only:74,on:64 + +# backward_subsumption_resolution +> bsr ~cat off:500,unit_only:118,on:75 + +# backward_subsumption_demodulation +> bsd ~cat off:500,on:74 + +# backward_subsumption_demodulation_max_matches +bsd=on > bsdmm ~cat 0:10,1:3,2:2,3:1 + +# binary_resolution +> br ~cat on:40,off:1 + +# condensation +> cond ~cat off:266,on:12,fast:8 + +# demodulation_redundancy_check (not implemented in Ahmed's branch) +# > drc ~cat encompass:500,on:500,off:354 + +# equational_tautology_removal +> etr ~cat off:100,on:1 + +# extensionality_resolution +ins=0 > er ~cat off:500,known:25,filter:26 + +# fool_paramodulation (TODO: out for Ahmed for now) +# > foolp ~cat off:10,on:1 + +# forward_demodulation +> fd ~cat all:244,off:27,preordered:15 + +# forward_literal_rewriting +> flr ~cat off:30,on:1 + +# function_definition_introduction (not implemented in Ahmed's branch) +# > fdi ~cat 0:100,2:1,4:1,8:1,16:1,32:1,64:1,128:1,256:1,512:1,1024:1 + +# inner_rewriting +> irw ~cat off:165,on:1 + +# unit_resulting_resolution (TODO: out for Ahmed for now) +# > urr ~cat off:1200,ec_only:162,on:340 + +# SINE LEVELS and shit + +# sine_to_age +> s2a ~cat off:4,on:1 + +# sine_level_split_queue +> slsq ~cat off:25,on:1 + +# sine_level_split_queue_layered_arrangement +slsq=on > slsql ~cat on:10,off:1 + +# sine_level_split_queue_cutoffs +slsq=on > slsqc ~cat 0:6,1:8,2:1,3:1 + +# sine_level_split_queue_ratios +slsq=on > slsqr ~u2r -5;2;, + +# ORDERING + +# term_ordering (lpo not compatible with HO) +# > to ~cat kbo:13,lpo:4 + +# symbol_precendence +> sp ~cat arity:100,const_min:72,frequency:130,const_frequency:49,reverse_frequency:55,reverse_arity:72,weighted_frequency:24,unary_first:28,occurrence:82,unary_frequency:14,const_max:18 +# symbol_precedence_boost +> spb ~cat none:100,units:3,goal:1,goal_then_units:8,non_intro:6,intro:2 + +to=kbo > kmz ~cat off:200,on:1 +to=kbo > kws ~cat const:200,inv_arity_squared:1,precedence:16,arity_squared:10,inv_arity:3,inv_frequency:10,frequency:1 + +# literal_comparison_mode +> lcm ~cat standard:100,reverse:5,predicate:5 + +# sine_to_pred_levels +> s2pl ~cat off:50,on:2,no:3 + +# SINE LEVELS - configure (must come after sine_to_age & slsq & s2pl) + +# set $s2a as the disjunction: s2a=on | slsq=on | s2pl!=off +> $s2a ~cat off:1 +s2a=on > $s2a ~cat on:1 +slsq=on > $s2a ~cat on:1 +s2pl!=off > $s2a ~cat on:1 + +# now configure (stealing the values from sine proper, which is not ideal, but should do) + +# sine_to_age_generality_threshold +$s2a=on > s2agt ~cat 0:7,5:1,10:1,15:1,20:1,30:1,50:1,100:1 + +# sine_to_age_tolerance +$s2a=on > s2at ~cat -1.0:50,1.0:150,1.5:37,2.0:60,2.5:20,3.0:70,3.5:15,4.0:60,4.5:15,5.0:50,5.5:10,6.0:30,7.0:20 + +# AVATAR +> av ~cat on:5,off:1 + +# avatar_add_complementary +av=on > aac ~cat none:19,ground:100 + +# avatar_buffered_solver +av=on > abs ~cat on:8,off:100 + +# avatar_congruence_closure +av=on > acc ~cat off:100,model:2,on:5 + +# cc_unsat_cores +acc!=off > ccuc ~cat first:1,small_ones:1,all:3 + +# avatar_minimize_model +av=on acc=model > amm ~cat all:600,off:69 +av=on acc!=model > amm ~cat all:600,sco:32,off:69 + +# avatar_eager_removal +av=on amm=all > aer ~cat on:300,off:1 + +# avatar_delete_deactivated +av=on > add ~cat on:100,large:2,off:1 + +# avatar_fast_restart +av=on > afr ~cat off:10,on:1 + +# avatar_literal_polarity_advice +av=on > alpa ~cat none:200,false:1,true:6,random:1 + +# avatar_nonsplittable_components +av=on > anc ~cat known:300,all_dependent:14,all:5,none:14 + +# avatar_turn_off_time_frac +av=on > atotf ~cat 1.0:10,0.5:1 +# careful that 1.0 becomes "1" by the ->toFloat->toStr internal transformation +atotf!=1 > atotf ~uf 0.0,0.5 + +# avatar_flush_period +av=on > afp ~cat 0:15,1:1 +afp!=0 > afp ~cat 1:1,10:1,50:1,300:1,1000:1,2000:1,4000:1,10000:1,40000:1,100000:1,1000000:1 + +# avatar_flush_quotient +afp!=0 > afq ~uf 1.0,3.0 + +# nonliterals_in_clause_weight +av=on > nicw ~cat off:100,on:1 + +# split_at_activation +av=on > sac ~cat off:3,on:1 + +# TODO: consider enabling this for vampire_z3 compiles! +# av=on > sas ~cat minisat:10,z3:1 + +# AVATAR SPLIT QUEUE + +# avatar_split_queue +av=on > avsq ~cat off:8,on:1 + +# avatar_split_queue_layered_arrangement +avsq=on > avsql ~cat off:8,on:1 + +# avatar_split_queue_cutoffs +avsq=on > avsqc ~cat 0:20,1:1,2:1,3:1,4:1,5:1 + +# avatar_split_queue_ratios +avsq=on > avsqr ~u2r -5;3;, + +# GLOBAL SUBSUMPTION (only after AVATAR -- careful of dependencies!) + +> gs ~cat off:15,on:1 + +# global_subsumption_explicit_minim +gs=on > gsem ~cat randomized:50,on:5,off:17 + +# global_subsumption_sat_solver_power +gs=on > gsssp ~cat propagation_only:20,full:1 + +# global_subsumption_avatar_assumptions +gs=on av=on > gsaa ~cat off:30,from_current:11,full_model:3 + +# MISC + +> uhcvi ~cat off:1,on:1 + +# HIGHER ORDER STUFF + +# complex_bool_reasoning +> cbe ~cat on:100,off:65 + +# add_proxy_axioms +> apa ~cat off:100,on:13 + +# bool_eq_trick +> bet ~cat off:100,on:19 + +# cases +> c ~cat off:100,on:31 + +# cases_simp +c=off > cs ~cat off:100,on:14 + +# choice_ax +> cha ~cat off:100,on:16 + +# choice_reasoning +cha=off > chr ~cat off:100,on:15 + +# cnf_on_the_fly +apa=on > cnfonf ~cat off:1 +apa=off > cnfonf ~cat eager:111,off:43,lazy_gen:29,conj_eager:19,lazy_not_gen_be_off:15,lazy_pi_sigma_gen:26,lazy_not_be_gen:12,lazy_simp:19,lazy_not_gen:12 + +# heur_inst +cnfonf=conj_eager > hi ~cat off:100,on:5 + +# bool_inst (disable for now) +# cnfonf!=off > bi ~cat off:1,abs:1,abs_sub:1 + +# equality_to_equiv +> e2e ~cat off:222,on:64 + +# func_ext +> fe ~cat abstraction:172,off:74,axiom:40 + +# hol_unif_depth +> hud ~ui 0,25 + +# lam_free_hol +# > lfh ~cat off:1,on:1 + +# iff_xor_rewriter +> ixr ~cat on:100,off:21 + +# new_taut_del +> ntd ~cat off:100,on:60 + +# pos_ext +func_ext!=axiom > pe ~cat off:20,on:1 + +# prim_inst_set +> piset ~cat pragmatic:214,or:14,equals:19,and:15,not:3,pi_sigma:8,all:3,small_set:7,all_but_not_eq:3 + +# pragmatic +hud!=0 > prag ~cat off:1,on:1 + +# applicative_unif +> au ~cat off:10,on:3 + +# take_n_unifiers +au=off > tnu ~ui 0,9 + +# injectivity +> inj ~cat off:4,on:1 + +# higher order split queue +> hfsq ~cat off:10,on:1 +hfsq=on > hfsql ~cat off:1,on:4 +hfsq=on > hfsqc ~cat 0:80,1:30,2:20,3:20,4:10,5:5 +hfsq=on > hfsqr ~u2r -5;3;, + +hfsq=on > hflw ~cat 0:1,1:5,2:3,3:2,4:2,5:1 +hfsq=on > hfaw ~cat 0:1,1:5,2:3,3:2,4:2,5:1 diff --git a/vampire.cpp b/vampire.cpp index a7794eae27..7d4da64ea8 100644 --- a/vampire.cpp +++ b/vampire.cpp @@ -190,13 +190,17 @@ void getRandomStrategy() void doProving() { CALL("doProving()"); + + // a new strategy randomization mechanism independent with randomizeStrategy below + env.options->trySamplingStrategy(); + // One call to randomize before preprocessing (see Options) env.options->randomizeStrategy(0); ScopedPtr prb(getPreprocessedProblem()); // Then again when the property is here (this will only randomize non-default things if an option is set to do so) - env.options->randomizeStrategy(prb->getProperty()); + env.options->randomizeStrategy(prb->getProperty()); // this will provide warning if options don't make sense for problem if (env.options->mode()!=Options::Mode::SPIDER) { @@ -414,7 +418,11 @@ void modelCheckMode() env.options->setOutputAxiomNames(true); Problem* prb = UIHelper::getInputProblem(*env.options); - if(env.property->hasPolymorphicSym() || env.property->higherOrder()){ + if(env.property->hasPolymorphicSym() +#if VHOL + || env.property->higherOrder() +#endif + ){ USER_ERROR("Polymorphic Vampire is not yet compatible with theory reasoning"); } @@ -708,22 +716,24 @@ int main(int argc, char* argv[]) } break; +#if VHOL case Options::Mode::CASC_HOL: { env.options->setIgnoreMissing(Options::IgnoreMissing::WARN); - env.options->setSchedule(Options::Schedule::CASC_HOL_2020); + env.options->setSchedule(Options::Schedule::SNAKE_TPTP_HOL); env.options->setOutputMode(Options::Output::SZS); env.options->setProof(Options::Proof::TPTP); - //env.options->setMulticore(0); // use all available cores + env.options->setMulticore(0); // use all available cores env.options->setOutputAxiomNames(true); + // normalise? + // switch of seed randomisation? - //unsigned int nthreads = std::thread::hardware_concurrency(); - //float slowness = 1.00 + (0.04 * nthreads); - if (CASC::PortfolioMode::perform(env.options->slowness())) { vampireReturnValue = VAMP_RESULT_STATUS_SUCCESS; } break; } +#endif + case Options::Mode::CASC_SAT: env.options->setIgnoreMissing(Options::IgnoreMissing::WARN); env.options->setSchedule(Options::Schedule::CASC_SAT); diff --git a/z3 b/z3 index 6ed071b444..e417f7d785 160000 --- a/z3 +++ b/z3 @@ -1 +1 @@ -Subproject commit 6ed071b44407cf6623b8d3c0dceb2a8fb7040cee +Subproject commit e417f7d78509b2d0c9ebc911fee7632e6ef546b6