diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl index 5b2bf68941..cbc22b2df0 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl @@ -880,7 +880,7 @@ %copy with mod '08ed6ac7', 'ea32f347', '0a2355a6', '37d3e8b2', 'a61ba2ce', 'b230c067', 'd2abd087', '6e82a1ae', %copy with mod (harder?) - 'e41c6fd3', 'a61f2674', '0d3d703e', 'makesboxsq', 'a79310a0', '27a77e38', + '705a3229', 'e41c6fd3', 'a61f2674', '0d3d703e', 'makesboxsq', 'a79310a0', '27a77e38', %todo 'f8b3ba0a', '5582e5ca', '33b52de3', '1b60fb0c', %recolor with a pattern from output diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl index ede7a74495..82049a58b7 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl @@ -108,14 +108,14 @@ %cache_devel(_TestID,File):- exists_file(File), !, writeln(exists_file(File)),!. cache_devel( TestID,File):- ensure_test(TestID), - alarm(180, halt(666), Id, [install(true),remove(false)]), + alarm(300, halt(0), Id, [install(true),remove(false)]), nl,writeq(starting(cache_devel( TestID,File))),nl, - % sformat(S,'touch "~w"',[File]), shell(S), + sformat(S,'touch "~w"',[File]), shell(S), cache_devel_1(TestID), - if_t(has_individuals(TestID), - ((writeln(save_test_hints(TestID,File)), + writeln(save_test_hints(TestID,File)), + remove_alarm(Id), save_test_hints_now(TestID,File), - writeln(finised_saving(TestID,File))))). + writeln(finised_saving(TestID,File)). cache_devel_1(TestID):- learn_grid_size(TestID), @@ -473,10 +473,13 @@ hint_into_data(mono(Hints),(F)):- !, hint_into_data(Hints,F). hint_into_data(Data,Data). - + relax_hint(G,G):- (\+ compound(G)) -> !; true. -relax_hint(rev(G),rev(GG)):- !, relax_hint(G,GG). -relax_hint(mono(G),mono(GG)):- !, relax_hint(G,GG). +%relax_hint(rev(G),rev(GG)):- !, relax_hint(G,GG). +%relax_hint(mono(G),mono(GG)):- !, relax_hint(G,GG). +%relax_hint(iz(G),iz(GG)):- relax_hint(G,GG). +%relax_hint(info(G),info(GG)):- relax_hint(G,GG). +relax_hint(P,PP):- compound_name_arguments(P,F,[G]),compound_name_arguments(PP,F,[GG]),relax_hint(G,GG). relax_hint(cg(W,G),cg(W,GG)):- !, relax_hint(G,GG). relax_hint(G,GG):- compound(G), duplicate_term(G,GG),arg(N,G,E),relax_arg(E,Hints),nb_setarg(N,GG,Hints). %relax_hint(G,GG):- functor(G,F,A),functor(GG,F,A). @@ -484,6 +487,7 @@ relax_arg(E,C):- is_color(E),!,relax_color_arg(E,C). %relax_arg(E,_):- var(E),!,fail. relax_arg(E,E):- var(E) -> !; true. +relax_arg((G),(GG)):- relax_hint(G,GG). relax_arg(E,len(L)):- is_list(E),length(E,L). relax_arg(_,_). @@ -708,8 +712,11 @@ some_min_unifier(X,X):- \+ compound(X),!. some_min_unifier([A|List],Term):- some_min_unifier_3(A,List,Term). -some_min_unifier_3(A,List,A):- my_maplist('=@='(A),List),!. -some_min_unifier_3(A,[B|List],O):- must_min_unifier(A,B,C), some_min_unifier_3(C,List,O). +can_unfy_already(A,B):- \+ \+ A = B. +some_min_unifier_3(A,[B|List],O):- min_unifier(B,A,C),nonvar(C),some_min_unifier_3(C,List,O),!. +some_min_unifier_3(A,[B|List],O):- relax_hint(A,AA),nonvar(AA),maplist(can_unfy_already(AA),[B|List]), some_min_unifier_3(AA,List,O),!. +some_min_unifier_3(A,List,A):- my_maplist(can_unfy_already(A),List),!. + is_a_min_unifier(A,B,C):- B==strict,A==loose,!,C=A. is_a_min_unifier(A,B,C):- A==fg,B\==bg,B\==wbg,!,C=A. @@ -727,11 +734,11 @@ */ min_unifier_n(A,B,D):- number(A),number(B),!,c_proportional(A,B,D). -min_unifier_n(A,B,D):- min_unifier_u(A,B,D). +min_unifier_n(A,B,D):- min_unifier(A,B,D). -min_unifier_u(A,B,_):- (\+ compound(A);\+ compound(B)),!. +min_unifier_u(A,B,_):- (\+ compound(A); \+ compound(B)),!. min_unifier_u(A,B,AA):- is_grid(A),is_grid(B),!,min_grid_unifier(A,B,AA),!. min_unifier_u(A,B,AA):- is_list(A),is_list(B),!,min_list_unifier(A,B,AA), ignore((length(A,AL),length(B,AL),length(AA,AL))). @@ -740,6 +747,7 @@ min_unifier_u(A,B,R):- compound(A),compound(B), compound_name_arguments(A,F,AA),compound_name_arguments(B,F,BB),!, my_maplist(min_unifier,AA,BB,RR),compound_name_arguments(R,F,RR). + min_unifier_u(A,B,R):- relax_hint(A,R),\+ (B \= R),!. is_cons(A):- compound(A),A=[_|_]. diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_explaination.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_explaination.pl index 26ac66035c..1cb5445ceb 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_explaination.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_explaination.pl @@ -418,7 +418,7 @@ object_glyph_colorz(Obj,Colors):- unique_colors(Obj,[UC|CL]), findall(RC,(member(FC,[UC|CL]),to_realer_color(FC,RC)),NColors), - (nonvar(UC)-> flatten_set([NColors,UC],Colors);Colors=NColors),!. + (nonvar(UC)-> flatten_sets([NColors,UC],Colors);Colors=NColors),!. object_glyph_colorz(_,[fg]). object_color_glyph_long(PA, CGA):- diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_howdiff.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_howdiff.pl index 21776e0bff..273ff92fd5 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_howdiff.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_howdiff.pl @@ -700,27 +700,54 @@ not_giz(/*b*/iz(i_o(_))):-!,fail. not_giz(oid(_)):-!,fail. %not_giz(pg(_,_,_,_)):-!,fail. -not_giz(P):- prop_type(_,P),!. +not_giz(P):- type_prop(_,P),!. not_giz(iz(_)):-!. not_giz(_). %not_giz(_):-!,fail. -prop_type(loc2D,loc2D(_,_)). -prop_type(loc2D,center2G(_,_)). -prop_type(loc2D,iz(locX(_))). -prop_type(loc2D,iz(cenGX(_))). -prop_type(loc2D,iz(locY(_))). -prop_type(loc2D,iz(cenGY(_))). -prop_type(scale,rotSize2D(grav,_,_)). -prop_type(scale,vis2D(_,_)). -prop_type(scale,iz(sizeX(_))). -prop_type(scale,iz(sizeY(_))). -prop_type(order,pg(_OG,_Peers,_Ord,_Type)). -prop_type(colorlesspoints,shape_rep(grav,_)). -prop_type(rotate,rot2D(_)). -prop_type(repaint,pen(_)). -prop_type(repaint,colors_cc(_)). -prop_type(loc2D,edge(_,_)). + +prop_type(P,T):- type_prop(T,P). + +prop_type_type(reposition). +prop_type_type(rotate). +prop_type_type(reshape). +prop_type_type(rescale). +prop_type_type(repaint). +prop_type_type(reorder). + + +type_prop(reposition,loc2D(_,_)). +type_prop(reposition,center2G(_,_)). +%type_prop(reposition,loc2G(_,_)). +type_prop(reposition,iz(locX(_))). +type_prop(reposition,iz(cenGX(_))). +type_prop(reposition,iz(locY(_))). +type_prop(reposition,iz(cenGY(_))). +type_prop(reposition,edge(_,_)). +type_prop(reposition,link(_,_)). +type_prop(rotate,rotG(_)). +type_prop(rotate,rot2D(_)). +type_prop(rotate,rotSize2D(_,_,_)). +type_prop(rescale,rotSize2D(grav,_,_)). +type_prop(rescale,vis2D(_,_)). +type_prop(rescale,iz(sizeGX(_))). +type_prop(rescale,iz(sizeGY(_))). +type_prop(rescale,rotSize2D(_,_,_)). +type_prop(rescale,mass(_)). +type_prop(rescale,cc(_,_)). +type_prop(reshape,shape_rep(grav,_)). +type_prop(reshape,iz(sid(_))). +type_prop(reshape,iz(stype(_))). +type_prop(reshape,iz(algo_sid(_, _))). +type_prop(reshape,iz(filltype(_))). +type_prop(reshape,iz(symmetry_type(_,_))). +type_prop(reorder,pg(_Peers,_OG,_Type,_Ord)). +type_prop(reorder,link_count(_,_)). +type_prop(reorder,occurs_in_links(_,_)). +type_prop(repaint,colors_cc(_)). +type_prop(repaint,pen(_)). +type_prop(repaint,cc(_,_)). + changed_by(colorlesspoints,reshape). changed_by(loc2D,move). @@ -731,7 +758,7 @@ changed_by(vis2D,copy). link_prop_types(Loc,O1,O2,Ps):- - findall(P,(prop_type(Loc,P), has_prop(O1,P),has_prop(O2,P)),Ps). + findall(P,(type_prop(Loc,P), has_prop(O1,P),has_prop(O2,P)),Ps). %maybe_allow_pair(PA,PB):- PA=@=PB,!,fail. @@ -810,7 +837,7 @@ dislike_points(I):- is_list(I),dislike_points1(L),forall(member(E,L),member(E,I)). %dislike_points1([iz(type(dot)),grid_size(H,V)]):- freeze(H, freeze(V, (HV is H * V, HV > 49))). -dislike_points1([colors_cc([cc(BG, _)]),iz(shape(polygon))]):- freeze(BG,is_black_or_bg(BG)). +dislike_points1([colors_cc([cc(BG, _)]),iz(reshape(polygon))]):- freeze(BG,is_black_or_bg(BG)). uncomparable(_,Var):- var(Var),!. @@ -1215,10 +1242,10 @@ \+ \+ member(Val,UseList). good_relation_between(DIR,OID1,OID2,Val):- relation_between(DIR,OID1,OID2,Val). -oid_to_node(OID,_{oid:OID,name:OID,desc:Glyph,color:HTMLColor,shape:circle,size:10}):- +oid_to_node(OID,_{oid:OID,name:OID,desc:Glyph,color:HTMLColor,reshape:circle,size:10}):- oid_to_obj(OID,Obj), object_glyph(Obj,Glyph),object_glyph_colorz(Obj,[Color|_]),into_html_color(Color,HTMLColor),!. -oid_to_node(OID,_{oid:OID,name:OID,shape:circle,size:10}). +oid_to_node(OID,_{oid:OID,name:OID,reshape:circle,size:10}). cmpable_value(V):- \+ compound(V),!,fail. @@ -1470,7 +1497,7 @@ select_two_simple(A,B,E1,E2,AA,BB):- select_two(A,B,E1,E2,AA,BB),!. -select_two(I,O,CI,CO,II,OO):- var(CI), prop_type(_,CI),copy_term(CI,CO),select_two(I,O,CI,CO,II,OO). +select_two(I,O,CI,CO,II,OO):- var(CI), type_prop(_,CI),copy_term(CI,CO),select_two(I,O,CI,CO,II,OO). select_two(I,O,CI,CO,II,OO):- select_two0(I,O,CI,CO,II,OO), two_ok(CI,CO),!. select_two(I,O,CI,CO,II,OO):- select_two0(I,O,CI,CO,II,OO), refunctor(CI,CII),CO=CII,!. diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_individuation.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_individuation.pl index a2dd8d8fde..4038c00b96 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_individuation.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_individuation.pl @@ -346,7 +346,7 @@ fill_in_bg(Black,G2,GG2):- \+ G2\=Black,!,ignore(GG2=Black). fill_in_bg(Alt,In,Out):- only_color_data_or(Alt,In,Out),!. fill_in_bg(_Alt,In,In):-!. -into_solid_grid(I,GG):- must_det_ll((into_grid(I,G1),mapgrid(fill_in_bg(black),G1,GG1))),!,GG=GG1. +into_solid_grid(I,GG1):- into_grid(I,G1),mapgrid(fill_in_bg(black),G1,GG1),!. @@ -4149,7 +4149,7 @@ into_list(G,[]):- G==[],!. into_list(G,[G]):- \+ compound(G),!. -into_list(G,L):- is_rule_mapping(G), get_mapping_info_list(G,_,List),!,into_list(List,L). +into_list(G,L):- is_mapping(G), get_mapping_info_list(G,_,List),!,into_list(List,L). into_list(G,[G]):- is_grid(G),!. into_list(G,[G]):- is_object(G),!. into_list(G,L):- maybe_remove_sort_tag(G,LL),!,into_list(LL,L). diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl index 5fef6dc779..c61b382cb7 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl @@ -577,16 +577,20 @@ asserta(saved_sorted_by_closeness(In,Sorted,Objs,List)),!. -sort_by_jaccard(A,Candidates,Objs):- - bonus_sort_by_jaccard([],A,sort_by_jaccard,Candidates,Objs). -sort_by_jaccard(A,GroupID,Candidates,Objs):- - bonus_sort_by_jaccard([],A,GroupID,Candidates,Objs). +%find_prox_mappings(A,Candidates,Objs):- sort_by_jaccard(A,Candidates,Objs). +sort_by_jaccard(A,Candidates,Objs):- bonus_sort_by_jaccard([],A,sort_by_jaccard,Candidates,Objs). + +find_prox_mappings(A,GroupID,Candidates,Objs):- sort_by_jaccard(A,GroupID,Candidates,Objs). +sort_by_jaccard(A,GroupID,Candidates,Objs):- bonus_sort_by_jaccard([],A,GroupID,Candidates,Objs). bonus_sort_by_jaccard(Bonus,A,Candidates,Objs):- bonus_sort_by_jaccard(Bonus,A,sort_by_jaccard,Candidates,Objs). +find_prox_mappings(Bonus,A,GroupID,Candidates,Objs):- bonus_sort_by_jaccard(Bonus,A,GroupID,Candidates,Objs). +bonus_sort_by_jaccard(_,_,_,[Obj],[Obj]):-!. bonus_sort_by_jaccard(Bonus,A,GroupID,Candidates,Objs):- + must_det_ll(( obj_grp_atomslist(GroupID,A,PA,PAP0), obj_atoms(Bonus,BonusAtoms), append(PAP0,BonusAtoms,PAP), @@ -595,16 +599,16 @@ findall(Why, ( member(B,Candidates), - B\==A, - \+ is_whole_grid(B), +% B\==A, +% \+ is_whole_grid(B), obj_grp_atomslist(GroupID,B,PB,PBP), - PA\==PB, + % PA\==PB, memo_op(PAP,PBP,O,Joins,_J,NJ,JO)), % maybe_allow_pair(PA,PB), allow_pair(PA,PB), Pairs), - sort_safe(Pairs,RPairs),!, + sort_safe(Pairs,RPairs), %list_upto(3,RPairs,Some), - my_maplist(arg(4),RPairs,Objs). + my_maplist(arg(4),RPairs,Objs))). memo_op(PAP,PBP,O,Joins,J,NJ,JO):- PAP@>PBP->memo_op_1(PBP,PAP,O,Joins,J,NJ,JO);memo_op_1(PAP,PBP,O,Joins,J,NJ,JO). @@ -1545,7 +1549,7 @@ transfer_prop(rotations,rot2D(_)). -%transfer_prop(Type,How):- prop_type(Type,How). +%transfer_prop(Type,How):- prop_type(How,Type). no_process_props_f(holes). no_process_props(P):- no_process(P); (compound(P),compound_name_arity(P,F,_),no_process_props_f(F)). diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_prior_groups.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_prior_groups.pl index 4486d1ed8f..0fddc354a1 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_prior_groups.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_prior_groups.pl @@ -602,7 +602,7 @@ extend_grp_member_proplist(Grp,[obj(Obj)],[obj(OUT)]):- extend_grp_member_proplist(Grp,Obj,OUT),!. extend_grp_member_proplist(Grp,obj(Obj),obj(OUT)):-!, extend_grp_member_proplist(Grp,Obj,OUT). -extend_grp_member_proplist(_Grp,Props,OUTL):- must_det_ll(is_obj_props(Props)), length(Props,Len), Len==1,!,Props=OUTL. +extend_grp_member_proplist(_Grp,Props,OUTL):- is_obj_props(Props), length(Props,Len), Len==1,!,Props=OUTL. extend_grp_member_proplist(Grp,Props,OUTL):- Obj = obj(Props), findall(P,extend_obj_prop(Grp,Obj,P),NewProps), @@ -1005,7 +1005,7 @@ flatten(PropLists,List), %list_to_set(List,Set), include(not_skip_ku,List,EList). -hack_prop_groups(Named,Objs):- ds, break, +hack_prop_groups(Named,Objs):- %ds, break, must_det_ll(( flat_props(Objs,EList), w_section(print_elists(Named), @@ -1677,7 +1677,7 @@ length(Missing,ML), findall(UHAD,(member(RR,RRR), indv_props_list(RR,R), member(UHAD,R)),VersionL), variant_list_to_set(VersionL,VersionSet), - some_min_unifier(VersionSet,Common),nonvar(Common), + once((call((some_min_unifier(VersionSet,Common),nonvar(Common))))), number_from_magnitude(VersionSet,VersionSetNumbered), count_each(VersionSet,VersionL,CountOfEachL), subst_2L(VersionSet,VersionSetNumbered,CountOfEachL,CountOfEachNumbered), diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_test_iface.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_test_iface.pl index e7a17705e0..49a90d7dd9 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_test_iface.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_test_iface.pl @@ -83,7 +83,7 @@ menu_cmd1(_,'I',' or (I)ndividuate all',(whole_ndividuator)). menu_cmd1(i,'o',' or (o)bjects found in the input/outputs', (clear_tee,cls_z_make,!,locally(nb_setval(show_indiv,t),ndividuator))). menu_cmd1(_,'u',' or (u)niqueness between objects in the input/outputs', (cls_z_make,!,ignore(what_unique),ndividuator)). -menu_cmd1(_,'y',' or Wh(y) between objects in the input/outputs', ((cls_z_make,!,ndividuator))). +menu_cmd1(_,'y',' or Wh(y) between objects in the input/outputs', ((cls_z_make,!,why_io))). menu_cmd1(_,'a',' or (a)ll between objects', (cls_z_make,!,ndividuator)). menu_cmd1(_,'j',' or (j)unctions between objects', (cls_z_make,!,ndividuator)). menu_cmd1(_,'k',' or (k)ill/clear all test data.',(update_changes,clear_test)). @@ -117,7 +117,7 @@ menu_cmd9(_,'m','recomple this progra(m),',(clear_tee,update_changes,threads)). menu_cmd9(_,'c','(c)lear the scrollback buffer,',(force_full_tee,really_cls)). -menu_cmd9(_,'C','(C)lear cached test info,',(clear_training_now,clear_test_now)). +menu_cmd9(_,'C','(C)lear cached test info,',(clear_training_now,clear_test_now,force_clear_test)). menu_cmd9(_,'r','(r)un DSL code,',(call_dsl)). menu_cmd9(_,'Q','(Q)uit Menu,',true). menu_cmd9(_,'^q','(^q)uit to shell,',halt(4)). @@ -600,6 +600,12 @@ print_side_by_side(green,In,in(show_task_pairs(TestID>ExampleNum)),_,Out,out(show_task_pairs(TestID>ExampleNum)))), true). %show_test_grids:- get_current_test(TestID),set_flag(indiv,0),with_test_grids(TestID,Grid,print_grid(show_test_grids(TestID),Grid)). +why_io:- + maplist(ignore,[ + ndividuator, + show_object_dependancy, + ensure_scene_change_rules, + print_scene_change_rules]). first_indivs_modes([complete,pbox_vm,i_repair_pattern]). @@ -1327,9 +1333,12 @@ call_file_goal(_, discontiguous(_)):- !. call_file_goal(_,Goal):- call(Goal),!. -load_file_dyn(TestID):- once(\+ atom(TestID); \+ exists_file(TestID)), - once(test_name_output_file(TestID,'.pl',NewName)),NewName\=@=TestID,!,load_file_dyn_pfc(TestID,NewName). -load_file_dyn(File):- warn_skip(load_file_dyn_pfc(File)),!. +load_file_dyn(TestID):- once(\+ atom(TestID); \+ exists_file(TestID)), + once(test_name_output_file(TestID,'.pl',NewName)),NewName\=@=TestID,!,load_file_dyn(TestID,NewName). +load_file_dyn(File):- warn_skip(load_file_dyn_pfc(File)). + +load_file_dyn(TestID,NewName):- warn_skip(load_file_dyn_pfc(TestID,NewName)). + :- dynamic(has_loaded_file_dyn_pfc/1). @@ -1337,23 +1346,23 @@ once(test_name_output_file(TestID,'.pl',NewName)),NewName\=@=TestID,!,load_file_dyn_pfc(TestID,NewName). /* load_file_dyn_pfc(TestID,TestID):- var(TestID),!,ensure_test(TestID),load_file_dyn_pfc(TestID,TestID). -load_file_dyn_pfc(TestID,File):- has_loaded_file_dyn_pfc(File),!. load_file_dyn_pfc(TestID,TestID):- once(\+ atom(TestID); \+ exists_file(TestID)), once(test_name_output_file(TestID,'.pl',NewName)),NewName\=@=TestID,!,load_file_dyn_pfc(TestID,NewName). -load_file_dyn_pfc(TestID,File):- \+ exists_file(File), !, wdmsg(\+ exists_file(File)). %load_file_dyn(File):- consult(File),!. */ -load_file_dyn_pfc(TestID,File):- asserta(has_loaded_file_dyn_pfc(File)), +load_file_dyn_pfc(_TestID,File):- has_loaded_file_dyn_pfc(File),!. +load_file_dyn_pfc(_TestID,File):- \+ exists_file(File), !, wdmsg(\+ exists_file(File)). +load_file_dyn_pfc( TestID,File):- asserta(has_loaded_file_dyn_pfc(File)), writeln(load_file_dyn_pfc(TestID,File)), setup_call_cleanup(open(File,read,I), - catch(load_dyn_stream(I),E,(print(E),catch(close(I),_,true),delete_file(File))), + catch(load_dyn_stream(I),E,(print(E),catch(close(I),_,true),delete_file(File),retractall(has_loaded_file_dyn_pfc(File)))), catch(close(I),_,true)),!, retractall(is_accompany_changed_db(TestID,_,_,_)). load_dyn_stream(I):- - repeat,read_term(I,Term,[]), + repeat,read_term(I,Term,[]),unwonk_ansi(Term,TT), (Term = end_of_file -> ! ; - (fail_compliants(load_file_term(I,Term)),fail)),!. + (fail_compliants(load_file_term(I,TT)),fail)),!. /* load_dyn_stream(I):- repeat,fail_compliants(read_term(I,Term,[])), @@ -1459,6 +1468,7 @@ my_shell_format(F,A):- shell_op((sformat(S,F,A), shell(S))). warn_skip(Goal):- u_dmsg(warn_skip(Goal)). +not_warn_skip(Goal):- u_dmsg(warn(Goal)),!,call(Goal),!. @@ -1468,7 +1478,7 @@ save_test_hints(TestID,File):- var(TestID),!, forall(ensure_test(TestID), save_test_hints(TestID,File)). save_test_hints(TestID,File):- var(File),!,test_name_output_file(TestID,'.pl',File), save_test_hints(TestID,File). save_test_hints(TestID,File):- maybe_append_file_extension(File,'.pl',NewName),!,save_test_hints(TestID,NewName). -save_test_hints(TestID,File):- !, warn_skip(save_test_hints(TestID,File)). +save_test_hints(TestID,File):- warn_skip(save_test_hints_now(TestID,File)). save_test_hints_now(TestID):- test_name_output_file(TestID,'.pl',File), save_test_hints_now(TestID,File),!. save_test_hints_now(TestID,File):- var(File),!,test_name_output_file(TestID,'.pl',File), save_test_hints_now(TestID,File). @@ -1486,13 +1496,18 @@ saveable_test_info(TestID,Info), my_maplist(print_ref,Info). +force_clear_test(TestID):- + ensure_test(TestID), + clear_test_now(TestID), + save_test_hints_now(TestID). + clear_test(TestID):- is_list(TestID),!,my_maplist(clear_test,TestID). clear_test(TestID):- ensure_test(TestID),warn_skip(clear_test(TestID)). clear_test_now(TestID):- ensure_test(TestID), clear_training_now(TestID), %warn_skip - (clear_saveable_test_info_now(TestID)), + clear_saveable_test_info_now(TestID), unload_test_file(TestID). clear_saveable_test_info(TestID):- ensure_test(TestID),warn_skip(clear_saveable_test_info(TestID)),!. diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_ui_ansi.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_ui_ansi.pl index 9dd0d280e5..ff446d3cd1 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_ui_ansi.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_ui_ansi.pl @@ -2292,13 +2292,13 @@ nobject_glyph(A,Glyph):- atom(A),atom_chars(A,Chars),last(Chars,Glyph),!. nobject_glyph(G,Glyph):- term_to_atom(G,A),nobject_glyph(A,Glyph). +int2glyph(GN2,Glyph):- int2glyph0(GN2,Glyph),!.%unwonk_ansi(Glyph). +int2glyph0(GN2,Glyph):- quietly(int2glyph1(GN2,Glyph)),!. +int2glyph0(GN,Glyph):- GN > 255, GN2 is GN div 2 + (GN rem 2), int2glyph1(GN2,Glyph),!. +int2glyph0(GN2,Glyph):- itrace,i_sym(GN2,GN),!,i_glyph(GN,Glyph),!. -int2glyph(GN2,Glyph):- quietly(int2glyph0(GN2,Glyph)),!. -int2glyph(GN,Glyph):- GN > 255, GN2 is GN div 2 + (GN rem 2), int2glyph(GN2,Glyph),!. -int2glyph(GN2,Glyph):- atrace,i_sym(GN2,GN),!,i_glyph(GN,Glyph),!. - -int2glyph0(GN2,Glyph):- i_sym(GN2,GN),i_glyph(GN,Glyph),atom(Glyph),!. -int2glyph0(GN,Glyph):- GN > 255, GN2 is GN div 2 + (GN rem 2), int2glyph0(GN2,Glyph),!. +int2glyph1(GN2,Glyph):- i_sym(GN2,GN),i_glyph(GN,Glyph),atom(Glyph),!. +int2glyph1(GN,Glyph):- GN > 255, GN2 is GN div 2 + (GN rem 2), int2glyph1(GN2,Glyph),!. %user:portray(S):- (string(S);atom(S)),atom_codes(S,[27|_]),write('"'),write(S),write('"'). @@ -2413,15 +2413,17 @@ %i_glyph(N,Glyph):- i_glyph0(N,Glyph),!.%:- atrace,i_glyph0(N,Glyph),atom(Glyph),!. name_safe(Glyph,Codes):- catch(name(Glyph,Codes),_,fail). -i_glyph0(NIL,'?'):- NIL==nil,!. -i_glyph0(N,Glyph):- bg_sym_ui(BG), BG==N, bg_dot(Code), name_safe(Glyph,[Code]),!. -i_glyph0(N,Glyph):- atom(N),name_safe(N,[_111,95,Code|_])->name_safe(Glyph,[Code]),!. -i_glyph0(N,Glyph):- atom(N),atom_number(N,Num),i_glyph(Num,Glyph),!. -i_glyph0(N,Glyph):- atom(N),name_safe(N,[Code])->name_safe(Glyph,[Code]),!. -i_glyph0(Code,Glyph):- integer(Code), Code> 255, name_safe(Glyph,[Code]),!. -i_glyph0(N,Glyph):- integer(N),quietly((i_sym(N,Code),name_safe(Glyph,[Code]))),!. -i_glyph0(N,Glyph):- plain_var(N),format(chars(Codes),'~p',[N]),last(Codes,Glyph),!. -i_glyph0(N,Glyph):- number(N), N>10, integer(N),N3 is N div 3, i_glyph0(N3,Glyph),!. + +i_glyph0(N,C):-i_glyph1(N,Glyph),!,atom_chars(Glyph,[C|_]). +i_glyph1(NIL,'?'):- NIL==nil,!. +i_glyph1(N,Glyph):- bg_sym_ui(BG), BG==N, bg_dot(Code), name_safe(Glyph,[Code]),!. +i_glyph1(Code,Glyph):- integer(Code), Code> 255, name_safe(Glyph,[Code]),!. +i_glyph1(N,Glyph):- integer(N),quietly((i_sym(N,Code),name_safe(Glyph,[Code]))),!. +i_glyph1(N,Glyph):- number(N), N>10, integer(N),N3 is N div 3, i_glyph1(N3,Glyph),!. +i_glyph1(N,Glyph):- plain_var(N),format(chars(Codes),'~p',[N]),last(Codes,Glyph),!. +i_glyph1(N,Glyph):- atom(N),name_safe(N,[_111,95,Code|_])->name_safe(Glyph,[Code]),!. +i_glyph1(N,Glyph):- atom(N),atom_number(N,Num),i_glyph(Num,Glyph),!. +i_glyph1(N,Glyph):- atom(N),name_safe(N,[Code])->name_safe(Glyph,[Code]),!. %i_glyph(N,Glyph):- atom(N),atom_chars(N,Chars),last(Chars,LGlyph),upcase_atom(LGlyph,Glyph). i_sym(N2,Code):- integer(N2),!, N is N2+160, change_code(N,NN), iss:i_syms(Codes),nth0(NN,Codes,Code),!. @@ -2432,6 +2434,33 @@ change_code(N,M):- M is N. +unwonk_ansi(Y,YY):- string(Y),!,atomics_to_string(List,"\u0083",Y),atomics_to_string(List,YY). +unwonk_ansi(Y,YY):- is_list(Y),!,maplist(unwonk_ansi,Y,YY). +unwonk_ansi(Y, Y):- \+ callable(Y),!. +unwonk_ansi(Y,YY):- Y = oid_glyph_object(OID,Glyph,Obj), YY = oid_glyph_object(YOID,YGlyph,YObj), + unwonk_atom(OID,Number,YOID), + unwonk_ansi(Obj,YObj), + unwonk_atom(Glyph,Number,YGlyph),!, + format(user_error,'~N% ~p.~n',[YY]). + +unwonk_ansi(Y,YY):- compound(Y),!,compound_name_arguments(Y,F,A),maplist(unwonk_ansi,A,AA),compound_name_arguments(YY,F,AA),!. +unwonk_ansi(Y, Y):- \+ atom(Y),!. +unwonk_ansi(Y,YY):- unwonk_atom(Y,YY,_),!. +unwonk_ansi(Y,Y). + + +unwonk_atom(Y,YY,Number):- atom_codes(Y,[111,95,195,402|_Rest]),atomic_list_concat([o,Bad,ANumber|GID_L],'_',Y), + atom_number(ANumber,Number), + unbad_glyph(Bad,Number,Glyph),!, atomic_list_concat([o,Glyph,ANumber|GID_L],'_',YY). +unwonk_atom(Y,YY,Number):- atom_codes(Y,[195,402|_]), glyph_b_g(YY,Number,Y),!. +unwonk_atom(Y,YY,_):- atomics_to_string(List,"\u0083",Y),atomic_list_concat(List,YY). + + +unbad_glyph(Bad,Number,Glyph):- glyph_b_g(Glyph,N,Bad),!,ignore(Number=N). +unbad_glyph(Bad,Number,Glyph):- int2glyph(Number,Glyph),asserta(glyph_b_g(Glyph,Number,Bad)),!. + +:- dynamic(glyph_b_g/3). + print_g1(P2,_,_, E):- print_g1(P2,E),!. %print_g1(_,_,C):- atrace, write(C). diff --git a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_uniqueness.pl b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_uniqueness.pl index 9688377772..ea03d304fe 100644 --- a/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_uniqueness.pl +++ b/packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_uniqueness.pl @@ -9,19 +9,31 @@ :- include(kaggle_arc_header). :- dynamic(is_for_ilp/4). -:- dynamic(is_accompany_changed_db/4). -clear_scene_rules(TestID):- - forall(is_accompany_changed_db(TestID,Ctx,P,PSame), - ignore(retract(is_accompany_changed_db(TestID,Ctx,P,PSame)))),!, +:- abolish(ac_unit/4). +:- dynamic(ac_unit/4). +clear_scene_rules(TestID):- + abolish(ac_unit/4),dynamic(ac_unit/4), + %forall(ac_unit(TestID,Ctx,P,PSame),ignore(retract(ac_unit(TestID,Ctx,P,PSame)))),!, clear_object_dependancy(TestID). +ac_db(List,CtxU,P,PSame):- + ac_db1(List,Ctx,P,PSame), + same_context(CtxU,Ctx). + +ac_db1(List,Ctx,P,PSame):- is_list(List),!,member(ac_unit(Ctx,P,PSame),List). +ac_db1(TestID,Ctx,P,PSame):- ac_unit(TestID,Ctx,P,PSame). + +%ac_db(TestID,P,PSame):- ac_db(TestID,_,P,PSame). + + % Define predicates that shouldn't be noticed dont_notice(oid(_)). dont_notice(links_count(sees, _)). dont_notice(giz(_)). dont_notice(pg(_, iz(_), rankLS, largest)). dont_notice(iz(symmetry_type(rollD, _))). +dont_notice(P):- compound(P),arg(_,P,E),E==norm,!,fail. %dont_notice(global2G(_,_)). %dont_notice(link(sees(_),_)). %dont_notice(links_count(sees,_)). @@ -65,8 +77,7 @@ %dont_deduce(P):- compound(P),compound_name_arguments(P,_,[X]),number(X). dont_deduce(grid_ops(comp,_)). % rot2D(rot90),changes([]),iz(fg_or_bg(iz_fg)),links_count(contained_by,0),links_count(contains,0),cc(plain_var,0),cc(bg,0),global2G(9,9),iz(sizeGX(1)),unique_colors_count(1),empty_area(0),iz(algo_sid(comp,sid_12)),iz(algo_sid(norm,sid_12)),iz(symmetry_type(flipDHV,false)),iz(symmetry_type(rot180,true)),iz(symmetry_type(flipV,true)),iz(symmetry_type(flipH,true)),iz(symmetry_type(rot270,false)),iz(symmetry_type(rot90,false)),iz(symmetry_type(flipD,false)),iz(symmetry_type(sym_h_xor_v,false)),iz(symmetry_type(sym_hv,true)),iz(filltype(solid)),iz(colormass),iz(media(shaped)),iz(info(birth(colormass))),pg(_1467088,mass(_1467098),rankLS,largest),pg(_1467108,iz(sizeGX(_1467122)),rankLS,smallest),pg(_1467132,iz(sizeGY(_1467146)),rankLS,largest),pg(_1467156,iz(cenGX(_1467170)),rankLS,largest),pg(_1467180,iz(cenGY(_1467194)),rankLS,largest),pg(_1467204,unique_colors_count(_1467214),rankLS,smallest),pg(_1467224,empty_area(_1467234),rankLS,smallest). -dont_deduce(grid_rep(norm,_)). % pen([cc(blue,1)]),pg(_1489874,mass(_1489884),rank1,4). -dont_deduce(iz(stype(_))). % rot2D(rot90),grid_ops(comp,[]),changes([]),iz(fg_or_bg(iz_fg)),links_count(contained_by,0),links_count(contains,0),cc(plain_var,0),cc(bg,0),global2G(9,9),iz(sizeGX(1)),unique_colors_count(1),empty_area(0),iz(algo_sid(comp,sid_12)),iz(algo_sid(norm,sid_12)),iz(symmetry_type(flipDHV,false)),iz(symmetry_type(rot180,true)),iz(symmetry_type(flipV,true)),iz(symmetry_type(flipH,true)),iz(symmetry_type(rot270,false)),iz(symmetry_type(rot90,false)),iz(symmetry_type(flipD,false)),iz(symmetry_type(sym_h_xor_v,false)),iz(symmetry_type(sym_hv,true)),iz(filltype(solid)),iz(colormass),iz(media(shaped)),iz(info(birth(colormass))),pg(_1473178,mass(_1473188),rankLS,largest),pg(_1473198,iz(sizeGX(_1473212)),rankLS,smallest),pg(_1473222,iz(sizeGY(_1473236)),rankLS,largest),pg(_1473246,iz(cenGX(_1473260)),rankLS,largest),pg(_1473270,iz(cenGY(_1473284)),rankLS,largest),pg(_1473294,unique_colors_count(_1473304),rankLS,smallest),pg(_1473314,empty_area(_1473324),rankLS,smallest). +%dont_deduce(iz(stype(_))). % rot2D(rot90),grid_ops(comp,[]),changes([]),iz(fg_or_bg(iz_fg)),links_count(contained_by,0),links_count(contains,0),cc(plain_var,0),cc(bg,0),global2G(9,9),iz(sizeGX(1)),unique_colors_count(1),empty_area(0),iz(algo_sid(comp,sid_12)),iz(algo_sid(norm,sid_12)),iz(symmetry_type(flipDHV,false)),iz(symmetry_type(rot180,true)),iz(symmetry_type(flipV,true)),iz(symmetry_type(flipH,true)),iz(symmetry_type(rot270,false)),iz(symmetry_type(rot90,false)),iz(symmetry_type(flipD,false)),iz(symmetry_type(sym_h_xor_v,false)),iz(symmetry_type(sym_hv,true)),iz(filltype(solid)),iz(colormass),iz(media(shaped)),iz(info(birth(colormass))),pg(_1473178,mass(_1473188),rankLS,largest),pg(_1473198,iz(sizeGX(_1473212)),rankLS,smallest),pg(_1473222,iz(sizeGY(_1473236)),rankLS,largest),pg(_1473246,iz(cenGX(_1473260)),rankLS,largest),pg(_1473270,iz(cenGY(_1473284)),rankLS,largest),pg(_1473294,unique_colors_count(_1473304),rankLS,smallest),pg(_1473314,empty_area(_1473324),rankLS,smallest). dont_deduce(iz(symmetry_type(_,_))). % rot2D(rot90),grid_ops(comp,[]),changes([]),iz(fg_or_bg(iz_fg)),links_count(contained_by,0),links_count(contains,0),cc(plain_var,0),cc(bg,0),global2G(9,9),iz(sizeGX(1)),unique_colors_count(1),empty_area(0),iz(algo_sid(comp,sid_12)),iz(algo_sid(norm,sid_12)),iz(symmetry_type(flipDHV,false)),iz(symmetry_type(rot180,true)),iz(symmetry_type(flipV,true)),iz(symmetry_type(flipH,true)),iz(symmetry_type(rot270,false)),iz(symmetry_type(rot90,false)),iz(symmetry_type(sym_h_xor_v,false)),iz(symmetry_type(sym_hv,true)),iz(filltype(solid)),iz(colormass),iz(media(shaped)),iz(info(birth(colormass))),pg(_1477530,mass(_1477540),rankLS,largest),pg(_1477550,iz(sizeGX(_1477564)),rankLS,smallest),pg(_1477574,iz(sizeGY(_1477588)),rankLS,largest),pg(_1477598,iz(cenGX(_1477612)),rankLS,largest),pg(_1477622,iz(cenGY(_1477636)),rankLS,largest),pg(_1477646,unique_colors_count(_1477656),rankLS,smallest),pg(_1477666,empty_area(_1477676),rankLS,smallest). %dont_deduce(mass(2)). % center2G(2,9),vis2D(1,2),loc2D(2,8),grid_ops(norm,[rot90]),link(sees([cc(e,2)]),o_?_459_t_08ed6ac7_trn_1_out),cc(fg,2),iz(sizeGY(2)),iz(cenGY(9)),rotSize2D(grav,2,1),area(2),iz(sid(sid_12)),\+link(sees([cc(w,2)]),o_i_109_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_?_641_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_?_337_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_Z_24_t_08ed6ac7_trn_1_out),\+link(sees([cc(w,2)]),o_?_459_t_08ed6ac7_trn_1_out). dont_deduce(oid(_)). % center2G(2,9),vis2D(1,2),loc2D(2,8),mass(2),grid_ops(norm,[rot90]),link(sees([cc(e,2)]),o_?_459_t_08ed6ac7_trn_1_out),cc(fg,2),iz(sizeGY(2)),iz(cenGY(9)),rotSize2D(grav,2,1),area(2),iz(sid(sid_12)),\+link(sees([cc(w,2)]),o_i_109_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_?_641_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_?_337_t_08ed6ac7_trn_0_out),\+link(sees([cc(w,2)]),o_?_532_t_08ed6ac7_trn_1_out),\+link(sees([cc(w,2)]),o_Z_24_t_08ed6ac7_trn_1_out),\+link(sees([cc(w,2)]),o_?_459_t_08ed6ac7_trn_1_out). @@ -84,17 +95,16 @@ do_deduce(iz(X)):- !,do_deduce(X),!. do_deduce(P):- compound(P),compound_name_arguments(P,_,[X,Y]),number(X),number(Y). do_deduce(rotSize2D(grav,_,_)). +do_deduce(grid_rep(norm,_)). % pen([cc(blue,1)]),pg(_1489874,mass(_1489884),rank1,4). % Predicate to check if P should be deduced ok_deduce(P):- \+ \+ dont_deduce(P), !, fail. ok_deduce(P):- \+ \+ do_deduce(P),!. -ok_deduce(_). +ok_deduce(P):- good_for_rhs(P). %ok_deduce(P):- \+ \+ dont_notice(P),!,fail. -in_out_atoms(in,out). - @@ -123,18 +133,18 @@ make_unifiable_f(I,O):- same_functor(I,O),!. +same_context(IO,Ctx):- nonvar(Ctx),!,io_to_cntx1(Out,In_Out_Out),once(Ctx==In_Out_Out;Ctx==Out),!, (once(IO=In_Out_Out;IO=Out)). +same_context(IO,Ctx):- nonvar(IO),!, io_to_cntx1(Out,In_Out_Out), once(IO==In_Out_Out;IO ==Out),!, (once(Ctx=In_Out_Out;Ctx=Out)). +same_context(IO,Ctx):- freeze(IO,same_context(IO,Ctx)),freeze(Ctx,same_context(IO,Ctx)). -io_to_cntx(in,in_out). -%io_to_cntx(in,in_out_out). -io_to_cntx(out,in_out_out). -io_to_cntx(out,s(_)). -io_to_cntx(X,X). +io_to_cntx(IO,Ctx):- io_to_cntx1(IO,Ctx). +io_to_cntx1(in,in_out). +%io_to_cntx1(in,in_out_out). +io_to_cntx1(out,in_out_out). +io_to_cntx1(out,s(_)). +io_to_cntx1(X,X). -%assert_become_new(Term):- \+ clause_asserted(Term),!, pp_ilp(assert_become_new=Term), asserta_new(Term). -assert_become_new(Term):- asserta_new(Term). -%assert_become_new(Term):- pp_ilp(assert_become_new=Term),!, assert_if_new(Term). - solve_via_scene_change(TestID):- must_det_ll(( @@ -151,7 +161,7 @@ solve_via_scene_change_rules(TestID,ExampleNum):- must_det_ll(( - %%ensure_scene_change_rules(TestID), + ensure_scene_change_rules(TestID), kaggle_arc(TestID,ExampleNum,In,Expected), banner_lines(green,4), % predict_grid_size_now(TestID,In,PX,PY), @@ -160,9 +170,8 @@ into_fti(TID,ROptions,In,VM), individuate(VM), Objs = VM.objs, - %print_object_dependancy(TestID), - show_object_dependancy(TestID), - %% print_scene_change_rules(solve_via_scene_change_rules,TestID), + print_object_dependancy(TestID), + print_scene_change_rules(solve_via_scene_change_rules,TestID), print_ss(wqs(expected_answer(ExampleNum)),Objs,Expected), dash_chars)),!, @@ -194,6 +203,8 @@ predict_grid_size_now(TestID,In,PX,PY),resize_our_solution(PX,PY,OurSolution1,OurSolution),!. + + enter_solve_obj(VM,TestID,ExampleNum,ROptions,Objs,ObjsO):- must_det_ll(( solve_obj_group(VM,TestID,ExampleNum,ROptions,in_out,Objs,ObjsM), @@ -202,7 +213,8 @@ ObjsO \==[],!. score_rule(Ways,Obj,Rule,Score):- is_object(Rule), \+ is_object(Obj),!,score_rule(Ways,Rule,Obj,Score). -score_rule(Ways,Obj,implies(obj_atoms(PCond),edit(P)),Score):- +score_rule(Ways,Obj,Rule,Score):- + (Rule = (_Ctx:edit(P):- obj_atoms(PCond))), indv_props_list(Obj,Props), \+ member(P,Props), %\+ \+ ((member(E,Props),member(E,PCond))), once( ( \+ is_bg_object(Obj) ); sub_var(black,PCond)), @@ -279,15 +291,20 @@ apply_rules_to_objects(_Ways,_Mapping,_Rules,_Objs,[]). +ac_rules(TestID,IO,P,PCond):- + ac_db(TestID,IO,P,PSame), vsr_set(PSame,PCond). solve_obj_group(VM,TestID,_ExampleNum,_ROptions,Ctx,Objs,ObjsO):- - Rule = implies(obj_atoms(PCond),edit(P)), - io_to_cntx(IO_,Ctx), - findall_vset(Rule,(is_accompany_changed_db(TestID,IO_,P,PSame), list_to_set(PSame,PCond)), Rules), + (Rule = (Ctx:edit(P):- obj_atoms(PCond))), + %io_to_cntx(IO_,Ctx), + findall_vset(Rule,ac_rules(TestID,Ctx,P,PCond), Rules), member(Ways-Strategy,[exact-_,two_way-one_to_one,_-_]), - apply_rules_to_objects(Ways,Strategy,Rules,Objs,Todo), - pp_ilp((see_Strategy(Ways-Strategy)=Todo)), Todo\==[], + apply_rules_to_objects(Ways,Strategy,Rules,Objs,Todo), Todo\==[], + maplist(into_solid_grid_strings,Todo,PStr), + unwonk_ansi(PStr,PPStr), + pp_ilp((see_Strategy(Ways-Strategy)=PPStr)), Todo\==[], once((maplist(run_todo_output(VM),Todo,ObjsM),flatten_objects(ObjsM,ObjsO))), ObjsO\==[],!. + /* solve_obj_group(_VM,TestID,_ExampleNum,Ctx,_ROptions,Objs,ObjsO):- must_det_ll(( @@ -364,15 +381,16 @@ edit_object(VM,Ps,Obj,NewObj):- Ps==[],!,edit_object(VM,pen([cc(black,1)]),Obj,NewObj). edit_object(VM,Ps,Obj,NewObj):- must_det_ll(( - wots(SS,writeln(Ps)), + wots(SS,print(Ps)), override_object_1(VM,Ps,Obj,NewObj), into_solid_grid([NewObj],SG),SG=_, dash_chars, print_ss(override_object(SS),[Obj],[NewObj]), + nop(( indv_props_list(Obj,PL1), indv_props_list(NewObj,PL2), intersection(PL1,PL2,_Same,Removed,Added), - pp_ilp(([[removed=Removed],[added=Added]])))). + pp_ilp(([[removed=Removed],[added=Added]])))))). override_object_1(_VM,[],IO,IO):-!. override_object_1(VM,[H|T],I,OO):- !, override_object_1(VM,H,I,M),!, override_object_1(VM,T,M,OO). @@ -432,6 +450,8 @@ + + common_props([O|Objs],Props):- indv_props_list(O,List), findall(P,(member(P,List),\+ dont_notice(P),forall(member(E,Objs),has_prop(P,E))),Props). @@ -534,7 +554,6 @@ must_det_ll(( ensure_individuals(TestID), ignore((ExampleNum=trn+_)), - retractall(arc_cache:causes(TestID,_,_,_,_)), forall(kaggle_arc(TestID,ExampleNum,_,_), learn_object_dependancy(TestID,ExampleNum)))). learn_object_dependancy(TestID,ExampleNum):- @@ -552,13 +571,19 @@ learn_object_dependancy(TestID,ExampleNum,RHSObjs,LHSObjs):- must_det_ll(( Step=0,Ctx=in_out,IsSwapped=false, - - sort_by_jaccard(one(RHSObjs),LHSObjs,LHSObjsOrdered), - sort_by_jaccard(one(LHSObjs),RHSObjs,RHSObjsOrdered), - %prinnt_sbs_call(LHSObjsOrdered,RHSObjsOrdered), + normalize_objects_for_dependancy(TestID,ExampleNum,RHSObjs,LHSObjs,RHSObjsOrdered,LHSObjsOrdered), + %prinnt_sbs_call(LHSObjsOrdered,RHSObjsOrdered), calc_o_d_recursively(TestID,ExampleNum,IsSwapped,Step,Ctx,[],LHSObjsOrdered,RHSObjsOrdered,Groups), assert_map_pairs(TestID,ExampleNum,Ctx,Groups))). +normalize_objects_for_dependancy(_TestID,_ExampleNum,RHSObjs,LHSObjs,RHSObjsOrdered,LHSObjsOrdered):- + include(is_fg_object,LHSObjs,LHSObjsO), + include(is_fg_object,RHSObjs,RHSObjsO), + sort_by_jaccard(one(RHSObjsO),LHSObjsO,LHSObjsOrdered), + sort_by_jaccard(one(LHSObjsO),RHSObjsO,RHSObjsOrdered), + !. + + prinnt_sbs_call([],[]):- dash_chars,!. prinnt_sbs_call([G1|WP1],[G2|WP2]):- !, length(WP1,L1),length(WP2,L2), @@ -587,14 +612,11 @@ assert_map_pairs(TestID,ExampleNum,Ctx,Group):- is_list(Group),!,maplist(assert_map_pairs(TestID,ExampleNum,Ctx),Group). assert_map_pairs(TestID,ExampleNum,Ctx,grp(Info,In,Out)):- into_list(In,InL),into_list(Out,OutL), - once((diff_l_r(InL,OutL,Same,InPFlat,OutFlatP), - unnumbervars(('$VAR'(0),'$VAR'('_'),Same,InPFlat,OutFlatP),UNV))), + once((diff_l_r(InL,OutL,Same,InFlatP,OutPFlat), + unnumbervars(('$VAR'(0),'$VAR'('_'),Same,InFlatP,OutPFlat),UNV))), UNV = (_FG1,_BG1,USame,InFlatProps,OutFlatProps), - %pp_ilp(grp(Info,InL,OutL)),!, - assertz_new(arc_cache:map_pairs(TestID,ExampleNum,Ctx,Info,InL,OutL)), - maplist(obj_to_oid,InL,InLOID), - maplist(obj_to_oid,OutL,OutLOID), - assertz_new(arc_cache:prop_dep(TestID,ExampleNum,Ctx,Info,InLOID,OutLOID,USame,InFlatProps,OutFlatProps)),!. + %pp_ilp(grp(Info,InL,OutL)),!, + assertz_new(arc_cache:prop_dep(TestID,ExampleNum,Ctx,Info,InL,OutL,USame,InFlatProps,OutFlatProps)),!. assert_map_pairs(_TestID,_ExampleNum,_Ctx,call(Rule)):-!,must_det_ll(Rule),!. % print the object dependencies for this test @@ -610,40 +632,49 @@ dash_chars,dash_chars, %pp_ilp_vset(grp(Info,Pre,Post),pair_obj_info(TestID,_,_,Info,Pre,Post)), - More = call(show_cp_dff_rem_keep_add(USame,InPFlat,OutFlatP)), - pp_ilp_vset(grp(Info,LHS,RHS)+More, - (pair_obj_props_54321(TestID,_ExampleNum,_Ctx,Info,_Step,_TypeO,LHS,RHS,USame,InPFlat,OutFlatP))), + More = call(show_cp_dff_rem_keep_add(USame,InFlatP,OutPFlat)), + pp_ilp_vset( + pair_obj_props_54321(TestID,_ExampleNum,_Ctx,Info,_Step,_TypeO, + LHS,RHS,USame,InFlatP,OutPFlat), + (grp(Info,LHS,RHS)+More)), + dash_chars,dash_chars. %if_t(Set1 =@= Set2, wdmsg('Set 2 the same')), %if_t(Set1 \=@= Set2, - dash_chars,dash_chars. -pp_ilp_vset(T,G):- findall(T,G,L),list_to_set(L,S),maplist(pp_ilp,S). +vsr_set(L,P):- variant_list_to_set(L,S),sort(S,R),reverse(R,P). +pp_ilp_vset(G,T):- dash_chars, findall(T,G,L),vsr_set(L,P),maplist(pp_ilp,P),dash_chars. :- dynamic(arc_cache:map_pairs/6). :- dynamic(arc_cache:prop_dep/9). :- dynamic(arc_cache:causes/5). -pair_obj_props(TestID,ExampleNum,Ctx,Info,Step,TypeO,LHS,RHS,USame,InFlatProps,OutFlatProps):- - Info = info(Step,_IsSwapped,Ctx,TypeO,TestID,ExampleNum), - arc_cache:prop_dep(TestID,_,_,Info,LHS,RHS,USame,InFlatProps,OutFlatProps). +pair_obj_props(TestID,ExampleNum,Ctx,Info,Step,TypeO,LHS,RHS,USame,InFlatProps,OutPFlatrops):- + Info = info(Step,_IsSwapped,Ctx,TypeO,TestID,ExampleNum,ExampleNum), + arc_cache:prop_dep(TestID,_,_,Info,LHS,RHS,USame,InFlatProps,OutPFlatrops). + +pair_obj_props(TestID,ExampleNum,Ctx,Step,TypeO,LHS,RHS,USame,InFlatProps,OutPFlatrops):- + Info = info(Step,_IsSwapped,Ctx,TypeO,TestID,ExampleNum,ExampleNum), + arc_cache:prop_dep(TestID,_,_,Info,LHS,RHS,USame,InFlatProps,OutPFlatrops). pair_obj_info(TestID,ExampleNum,Ctx,Info,LHS,RHS):- - Info = info(_Step,_IsSwapped,Ctx,_TypeO,TestID,ExampleNum), - arc_cache:prop_dep(TestID,_,_,Info,LHS,RHS,_USame,_InFlatProps,_OutFlatProps). + Info = info(_Step,_IsSwapped,Ctx,_TypeO,TestID,ExampleNum,ExampleNum), + arc_cache:prop_dep(TestID,_,_,Info,LHS,RHS,_USame,_InFlatProps,_OutPFlatrops). ok_intersect(L1,L2):- member(E1,L1),member(E2,L2), other_val(E1,E2),!,fail. ok_intersect(_,_). -pair_obj_props_54321(TestID,Ex,Ctx,Info,Step,Type,LHSO,RHSO,S,L,R):- +pair_obj_props_54321(TestID,Ex,Ctx,Info,Step,Type,LHSO,RHSO,S,L,RR):- (pair_obj_props5(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R)*->true; (pair_obj_props4(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R)*->true; (pair_obj_props3(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R)*->true; (pair_obj_props2(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R)*->true; pair_obj_props1(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R))))), - into_solid_objs(LHS,LHSO),into_solid_objs(RHS,RHSO). + into_solid_objs(LHS,LHSO),into_solid_objs(RHS,RHSO), + include(good_for_rhs,R,RR). -into_solid_objs(RHS,RHSO):- flatten([RHS],RHSM), maplist(into_solid_grid_strings,RHSM,RHSO). +into_solid_objs(RHS,RHSO):- flatten([RHS],RHSM), + maplist(into_obj,RHSM,RHSO). points_to_objects(ShapeType,Obj,Points,IndvPoints,NextScanPoints):- @@ -658,23 +689,21 @@ %set(VM.lo_points) = NextScanPoints, %assumeAdded(VM,Obj), %cycle_back_in(VM,OptionC). - true. - - - + true, + Obj = obj([globalpoints(IndvPoints)]). -pair_obj_props1(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R):- +pair_obj_props1(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R):- fail, pair_obj_props(TestID,Ex,Ctx,Info,Step,Type,LHS,RHS,S,L,R). -pair_obj_props2(TestID,Ex2,Ctx,Info,Step,Type,LHS,RHS,S,L,R):- - Info = info(Step1,_IsSwapped,Ctx,Type,TestID,Ex2), - dif(Ex1,Ex2),dif(Ex3,Ex2),dif(Ex1,Ex3), - pair_obj_props(TestID,Ex1,Ctx,_Info1,Step1,Type1,LHS1,RHS1,S1,L1,R1), - pair_obj_props(TestID,Ex2,Ctx,_Info2,Step2,Type2,LHS2,RHS2,S2,L2,R2), +pair_obj_props2(TestID,trn+Ex1,Ctx,Info,Step,Type,LHS,RHS,S,L,R):- + Info = info(Step1,_IsSwapped,Ctx,Type,TestID,trn+Ex1,trn+Ex1+Ex2), + Ex1# (ok_intersect(R1,R2), something_common(R1,R2)) ; true), - once((maplist(merge_vals,[Type1,LHS1,RHS1],[Type2,LHS2,RHS2],[Type,LHS,RHS]))), the_min_unifier(R1,R2,R),the_min_unifier(S1,S2,S),append_sets(L1,L2,L). + +something_common(R1,R2):- \+ \+ ((member(E1,R1), good_for_rhs(E1), member(E2,R2), E1=@=E2)). + /* @@ -731,18 +762,125 @@ -merge_vals(A,B,C):-flatten_set([A,B],C),!. +merge_vals(A,B,C):-flatten_sets([A,B],C),!. -something_common(R1,R2):- good_for_rhs(E1), member(E1,R1), member(E1,R2),!. -good_for_rhs(pen(_)). -good_for_rhs(loc2D(_,_)). +/* good_for_rhs(rot2D(_)). good_for_rhs(iz(sid(_))). +good_for_rhs(mass(_)). +good_for_rhs(iz(centGX(_))). +good_for_rhs(iz(centGY(_))). +good_for_rhs(grid_rep(norm,_)). +good_for_rhs(iz(algo_sid(norm,_))). +%good_for_rhs(grid_ops(norm,_)). +*/ +good_for_rhs(pen(_)). +good_for_rhs(loc2D(_,_)). + + +good_for_lhs(P):- \+ ok_notice(P),!,fail. +%good_for_lhs(P):- make_unifiable(P,U),P=@=U,!,fail. +good_for_lhs(cc(bg, _)). +good_for_lhs(cc(fg, _)). +good_for_lhs(cc(_, 0)). +good_for_lhs(cc(FG, _)):- is_real_color(FG). +good_for_lhs(cc(_, _)):- !, fail. +good_for_lhs(center2D(_, _)). +good_for_lhs(empty_area(_)). +good_for_lhs(global2G(_, _)). +%good_for_lhs(grid_ops(comp, _)). +good_for_lhs(grid_ops(norm, _)). +good_for_lhs(iz(algo_sid(comp, _))). +good_for_lhs(iz(algo_sid(norm, _))). +good_for_lhs(iz(cenGX(_))). +good_for_lhs(iz(cenGY(_))). +%good_for_lhs(iz(fg_or_bg(_))). +good_for_lhs(iz(filltype(_))). +good_for_lhs(iz(info(birth(_)))). +good_for_lhs(iz(sid(_))). +good_for_lhs(iz(sizeGX(_))). +good_for_lhs(iz(sizeGY(_))). +good_for_lhs(iz(stype(_))). +good_for_lhs(link(sees(_),_)):-!,fail. +good_for_lhs(link(NS, _)):- !, NS\=sees(_). +good_for_lhs(links_count(_, _)). +good_for_lhs(loc2D(_, _)). +good_for_lhs(mass(_)). +good_for_lhs(pen(_)). +good_for_lhs(rot2D(_)). +good_for_lhs(rotSize2D(grav, _, _)). +good_for_lhs(unique_colors(_)). +%good_for_lhs(unique_colors_count(_)). +good_for_lhs(vis2D(_, _)). +good_for_lhs(pg(_,_,_,_)). +good_for_lhs(\+ P):- !, good_for_lhs(P). + +pass2_rule_new(TestID,Ctx,P,[iz(info(Info))|PSame]):- ensure_test(TestID),pair_obj_props_54321(TestID,_Ex,Ctx,Info,_Step,_Type,_LHSO,_RHSO,PSame,_L,R),member(P,R),good_for_rhs(P). +pass2_rule_old(TestID,Ctx,P,[iz(info(propcan(true,Ctx)))|PSame]):-ensure_test(TestID), ensure_props_change(TestID,Ctx,P), + Ctx\==in, + prop_can(TestID,Ctx,P,PSame). + +pass2_rule_1(TestID,Ctx,P,PSame):- pass2_rule_old(TestID,Ctx,P,PSame). +pass2_rule_1(TestID,Ctx,P,PSame):- pass2_rule_new(TestID,Ctx,P,PSame). + +pass2_rule_R(TestID,Rule):- + Rule = rule(RuleType,P,PSame), + RuleType = edit_copy(Ctx,ReType,P), + pass2_rule_1(TestID,IO,P,PSame), + once((good_for_rhs(P), + prop_type(P,ReType),io_to_cntx(IO,Ctx))). + +has_a_value(P):- make_unifiable_u(P,U),P\=@=U. + +pass2_rule(TestID,IO,P,OutputRule):- + ensure_test(TestID), + RuleType = edit_copy(IO,ReType,P), + SortKey = P, + OutputRule = rule(RuleType,SortKey,SuperPreconds), + KeyedRule = rule(RuleType,SortKey,Precond), + Rule = rule(RuleType,P,LHS), + findall(Rule,pass2_rule_R(TestID,Rule),Rules), + maplist(arg(1),Rules,Keyz),vsr_set(Keyz,Keys), + member(RuleType,Keys), + findall(KeyedRule, + (prop_type(P,ReType),findall(LHS,member(Rule,Rules),LHSList),flatten(LHSList,FFound), + into_lhs(FFound,Precond)),KeyedRules), + maplist(arg(3),KeyedRules,Preconds),into_lhs(Preconds,SuperPreconds), + member(KeyedRule,KeyedRules), + %include(has_a_value,SuperPreconds,UsedPrconds), + true. -m_unifiers(In,Out):- \+ is_list(In),Out=In. -m_unifiers(In,Out):- select(E,In,More),is_prop1(E),make_unifiable_u(E,U),select(U,More,UMore),other_val(E,U),the_min_unifier(U,E,S),!,m_unifiers([S|UMore],Out). -m_unifiers(In,Out):- select(E,In,More),is_prop1(E),make_unifiable_u(E,U),select(U,More,UMore),other_val(E,U),the_min_unifier(U,E,S),!,m_unifiers([S|UMore],Out). +how_are_differnt(O1,O2,Set):- + findall(Type=Same,prop_pairs(O1,O2,Type,Same,_P),List), + vsr_set(List,Set). + +prop_pairs(O1,O2,Type,Same,P):- + flat_props(O1,F1),flat_props(O2,F2), + member(P1,F1),make_unifiable_u(P1,P2),member(P2,F2), + (other_val(P1,P2)->Same=different;Same=same), + min_unifier(P1,P2,P), + prop_type(P,Type). + +into_lhs(OID,Out):- atom(OID),!,indv_props_list(OID,In),into_lhs(In,Out),!. +into_lhs(In,Out):- \+ compound(In),!,Out=In. +into_lhs(rule(_RuleType,_SortKey,In),Out):- nonvar(In),!,into_lhs(In,Out),!. +into_lhs(obj(In),Out):- nonvar(In),!,into_lhs(In,Out),!. +into_lhs(In,Out):- \+ is_list(In),!,Out=In. +into_lhs(In,Out):- flatten([In],InF),into_lhs1(InF,LHSF),flatten(LHSF,LHSV),variant_list_to_set(LHSV,Out),!. +into_lhs1(In,Out):- m_unifiers(In,MidF),o_unifiers(MidF,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +%into_lhs1(In,Out):- is_group(In),mapgroup(into_lhs1,In,MidF),flatten(MidF,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +%into_lhs1(In,Out):- my_exclude(hide_propchange1,In,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +%into_lhs1(In,Out):- maplist(hide_propchange,In,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +%into_lhs1(In,Out):- remove_giz(In,Out),!. +into_lhs1(In,Out):- maplist(into_lhs,In,LHSF),flatten(LHSF,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +into_lhs1(In,Out):- include(good_for_lhs,In,Mid),In\=@=Mid,!,into_lhs1(Mid,Out). +into_lhs1(Out,Out). + +%m_unifiers(In,Out):- \+ is_list(In),Out=In. +m_unifiers(In,Out):- is_list(In), select(E,In,More),is_prop1(E),make_unifiable_u(E,U),select(U,More,UMore), + min_unifier(U,E,S),!,m_unifiers([S|UMore],Out),!. +%m_unifiers(In,Out):- select(E,In,More),is_prop1(E),make_unifiable_u(E,U),select(U,More,UMore),other_val(E,U),the_min_unifier(U,E,S),!,m_unifiers([S|UMore],Out). m_unifiers(IO,IO). %o_unifiers(In,Out):- select(E,In,More),is_prop1(E),make_unifiable(E,U),select(U,More,UMore),other_val(E,U),the_or_unifier(U,E,S),!,o_unifiers([S|UMore],Out). o_unifiers(IO,IO). @@ -760,11 +898,14 @@ %make_unifiable_u(E1,E2), other_val(E1,E2),%min_unifier(E1,E2,E),!, - min_unifier_u(E1,E2,E), + min_unifier(E1,E2,E), the_min_unifier1(S1R,S2R,S). the_min_unifier1(S1,S2,S):- append(S1,S2,S),!. + + + /* show_cp_dff_obj(PA,[PB]):- !, show_cp_dff_obj(PA,PB). show_cp_dff_obj([PA],PB):- !, show_cp_dff_obj(PA,PB). @@ -774,18 +915,19 @@ show_cp_dff_obj(A,B):- must_det_ll(( flat_props([A],PA), flat_props([B],PB), - diff_l_r(PA,PB,Same,InPFlat,OutFlatP), - show_cp_dff_rem_keep_add(Same,InPFlat,OutFlatP))). + diff_l_r(PA,PB,Same,InFlatP,OutPFlat), + show_cp_dff_rem_keep_add(Same,InFlatP,OutPFlat))). -show_cp_dff_rem_keep_add(Same,InPFlat,OutFlatP):- %flat_props([B],PB), intersection(Same,PB,S,SS,_), append(S,SS,SSame), +show_cp_dff_rem_keep_add(Same,InFlatP,OutPFlat):- %flat_props([B],PB), intersection(Same,PB,S,SS,_), append(S,SS,SSame), must_det_ll((%maplist(print_diffs(1),Same), - (length(InPFlat,LenA), pp_ilp(removed(LenA)=InPFlat), + (length(InFlatP,LenA), pp_ilp(removed(LenA)=InFlatP), length(Same,SL), pp_ilp(sames(SL)=Same), - length(OutFlatP,LenB),pp_ilp(added(LenB)=OutFlatP)))). + length(OutPFlat,LenB),pp_ilp(added(LenB)=OutPFlat)))). pp_ilp(Grp):-pp_ilp(1,Grp),!. +pp_ilp(D,T):- T==[],!,prefix_spaces(D,write('[] ')),!. pp_ilp(_,_):- format('~N'),nl,fail. pp_ilp(D,T):- is_ftVar(T),!,prefix_spaces(D,print(T)),!. pp_ilp(D,call(T)):- !, prefix_spaces(D,call(T)). @@ -795,17 +937,17 @@ get_mapping_info(Grp,Info,In,Out), prefix_spaces(D,(dash_chars,format('\n',[Info]))), print_io_terms(D+7,In,Out), - prefix_spaces(D+8,show_cp_dff_obj(In,Out)), + %prefix_spaces(D+8,show_cp_dff_obj(In,Out)), prefix_spaces(D,(write('\n'),dash_chars)))). pp_ilp(D,Grp):- compound(Grp), (In-Out = Grp), Info=lr,!, must_det_ll(( get_mapping_info(Grp,Info,In,Out), - prefix_spaces(D,(dash_chars,format('\n',[Info]))), + prefix_spaces(D,(dash_chars,format('\n',[Info]))), print_io_terms(D+7,In,Out), - prefix_spaces(D+8,show_cp_dff_obj(In,Out)), - prefix_spaces(D,(write('\n'),dash_chars)))). + %prefix_spaces(D+8,show_cp_dff_obj(In,Out)), + prefix_spaces(D,(write('\n'),dash_chars)))). pp_ilp(D,X=Y):- !, @@ -813,12 +955,21 @@ prefix_spaces(D, (print(X),write(' = '))),nl, prefix_spaces(D,pp_ilp(1,Y)))). -pp_ilp(D,apply(implies(C,P),Obj)):- !, pp_ilp(D,grp(implies(C,P),[],Obj)). +pp_ilp(D,apply(Rule,Obj)):- !, pp_ilp(D,grp(Rule,[],Obj)). -pp_ilp(D,Grid):- is_obj_props(Grid),!,sort(Grid,R),reverse(R,S),prefix_spaces(D,pp(S)). +pp_ilp(D,Grid):- is_obj_props(Grid),!,sort(Grid,R),reverse(R,S), + prefix_spaces(D,pp(S)). + -pp_ilp(D,Grid):- is_group(Grid),!, +pp_ilp(D,Grid):- is_group(Grid),!, + must_det_ll((length(Grid,Len), + prefix_spaces(D,(format('\n',[len=Len]))), + prefix_spaces(D,mapgroup(pp_ilp(D+7),Grid)),!,nl, + prefix_spaces(D,(format('\n',[]))))),!. + + +pp_ilp(D,Grid):- is_group(Grid),!, must_det_ll((length(Grid,Len), prefix_spaces(D,(format('\n',[len=Len]))), prefix_spaces(D,mapgroup(pp_ilp(D+7),Grid)),!,nl, @@ -828,11 +979,12 @@ pp_ilp(D,Grid):- is_grid(Grid),!,prefix_spaces(D,print_grid(Grid)),!,nl. pp_ilp(D,Grid):- is_object(Grid),!,prefix_spaces(D,print_grid([Grid])),!,nl. -pp_ilp(D,is_accompany_changed_db(_TestID,IO,P,PSame)):- !, +pp_ilp(D,ac_db(_TestID,IO,P,PSame)):- !, must_det_ll(( once(io_to_cntx(IO,CTX);IO=CTX), once(list_to_conjuncts(PSame,Conj);PSame=Conj), - prefix_spaces(D,(print((CTX:P)),prefix_spaces(D+10,(portray_clause((:-Conj)))))))),!. + prefix_spaces(D,(print((CTX:P)), + prefix_spaces(D+15,(portray_clause((:-Conj)))))))),!. %pp_ilp(D,(H:-Conj)):- prefix_spaces(D,pp_ilp(H:-Conj)),!. @@ -874,6 +1026,10 @@ %prefix_spaces(D,G):- fail, DD is D, wots(Tabs,(write('\t'),print_spaces(DD),write('.\t'))), wots(SS,G),!, print_prepended(Tabs,SS). prefix_spaces(D,G):- DD is D, wots(Tabs,(write('\t'),print_spaces(DD),write('\t'))),prepend_each_line(Tabs,G). +into_solid_grid_strings_1(T,WithGrids):- + sub_term(Obj,T),is_object(Obj),global_grid(Obj,Grid),into_solid_grid(Grid,Solid), + subst001(T,Obj,Solid,MidTerm),MidTerm\=@=T,!,into_solid_grid_strings_1(MidTerm,WithGrids). + into_solid_grid_strings_1(X,Y):- into_solid_grid_strings(X,Y),!. /*into_solid_grid_strings(T,WithGrids):- @@ -888,7 +1044,7 @@ prin_to_string(T,Text):- wots(Text,print(T)). into_solid_grid_strings(T,Text):- is_ftVar(T),Text=T,!. -into_solid_grid_strings(A,Y):-atom(A),into_obj(A,X),!,into_solid_grid_strings(X,Y). +into_solid_grid_strings(A,Y):-atom(A),into_obj(A,Y),!. %,into_solid_grid_strings(X,Y). %into_solid_grid_strings(T,Text):- \+ compound(T),T=Text,!. %into_solid_grid_strings(T,Text):- term_contains_ansi(T),Text=T,!. %into_solid_grid_strings(T,Text):- as_is(T),T=Text,!. @@ -932,6 +1088,9 @@ into_solid_grid_str(Obj2,Grid2), wots(SS,print_ss(Grid1,Grid2)),!. +into_solid_grid_str(Obj,SS):- is_object(Obj),global_grid(Obj,GG),!,into_solid_grid_str(GG,SS). +into_solid_grid_str(Obj,SS):- is_object(Obj),global_grid(Obj,SS),!. + into_solid_grid_str(Obj,SS):- is_object(Obj),loc2D(Obj,X,Y), vis2D(Obj,H,V), vis2D(Obj,H,V),has_prop(giz(g(IO_)),Obj), (need_positional_context(H,V)->global_grid(Obj,GG);=(Obj,GG)), @@ -950,7 +1109,7 @@ ignore((clear_object_dependancy(TestID,ExampleNum)))). clear_object_dependancy(TestID,ExampleNum):- forall(arc_cache:prop_dep(TestID,ExampleNum,Ctx,Info,Right,Left,A,B,C), - retract(arc_cache:prop_dep(TestID,ExampleNum,Ctx,Info,Right,Left,A,B,C))),!. + retract(arc_cache:prop_dep(TestID,ExampleNum,Ctx,Info,Right,Left,A,B,C))). @@ -1099,15 +1258,22 @@ calc_o_d_recursively(TestID,ExampleNum,IsSwapped,Step,Ctx,Prev,LHSObjs,RHSObjs,RestLR):- LHSObjs==[], RHSObjs == [], !, - Info = info(Step,IsSwapped,Ctx,leftover,TestID,ExampleNum), + Info = info(Step,IsSwapped,Ctx,leftover,TestID,ExampleNum,_), append_LR([call(assert_test_property(TestID,ExampleNum,deps,perfect_balance(Info)))],Prev,RestLR). calc_o_d_recursively(TestID,ExampleNum,IsSwapped,Step,Ctx,Prev,LHSObjs,RHSObjs,RestLR):- - Info = info(Step,IsSwapped,Ctx,leftover,TestID,ExampleNum), + Info = info(Step,IsSwapped,Ctx,leftover,TestID,ExampleNum,_), RHSObjs==[], !, must_det_ll((maplist(into_delete(TestID,ExampleNum,IsSwapped,Step,Ctx,Prev,Info), LHSObjs,Mappings),append_LR(Prev,[call(assert_test_property(TestID,ExampleNum,deps,ignore_rest(Info))),Mappings],RestLR))). +calc_o_d_recursively(TestID,ExampleNum,IsSwapped,_Step,Ctx,Prev,LHSObjs,RHSObjs,RestLR):- + LHSObjs==[], !, must_det_ll(( + incr_cntx(Ctx,IncrCtx), + %incr_step(Step,IncrStep), + into_list(Prev,NewLHS), + calc_o_d_recursively(TestID,ExampleNum,IsSwapped,10,IncrCtx,Prev,NewLHS,RHSObjs,RestLR))). + calc_o_d_recursively(TestID,ExampleNum,IsSwapped,Step,Ctx,Prev,LHSObjsNil,RHSObjs,RestLR):- LHSObjsNil==[], !, incr_cntx(Ctx,IncrCtx), @@ -1125,14 +1291,13 @@ calc_o_d_recursively(TestID,ExampleNum,IsSwapped,IncrStep,IncrCtx,NewPrev,LHSRest,RHSRest,RestLR))). -/* calc_o_d_recursively(TestID,ExampleNum,IsSwapped,_Step,Ctx,Prev,LHSObjs,RHSObjs,RestLR):- LHSObjs==[], !, must_det_ll(( incr_cntx(Ctx,IncrCtx), %incr_step(Step,IncrStep), into_list(Prev,NewLHS), calc_o_d_recursively(TestID,ExampleNum,IsSwapped,10,IncrCtx,Prev,NewLHS,RHSObjs,RestLR))). -*/ + calc_o_d_recursively(TestID,ExampleNum,IsSwapped,Step,Ctx,Prev,LHSObjs,[Right],RestLR):- sort_by_jaccard(Right,LHSObjs,[A,B|C]), make_pairs(TestID,ExampleNum,assumed,IsSwapped,Step,Ctx,[],[B,A],Right,Pairs), @@ -1279,7 +1444,7 @@ % make_pairs(TestID,ExampleNum,Type,IsSwapped,Step,Ctx,[],Prev,LHS,NLHS), % make_pairs(TestID,ExampleNum,Type,IsSwapped,Step,Ctx,[],NLHS,RHS,GRP). make_pairs(TestID,ExampleNum,Type,IsSwapped,Step,Ctx,_Prev,LHS,RHS,GRP):- - Info = info(Step,IsSwapped,Ctx,TypeO,TestID,ExampleNum), + Info = info(Step,IsSwapped,Ctx,TypeO,TestID,ExampleNum,_), must_det_ll(( listify(LHS,LHSL),maplist(obj_in_or_out,LHSL,LCtx),maplist(cto_aa,LCtx,LCtxA),atomic_list_concat(LCtxA,'_',LP), listify(RHS,RHSL),maplist(obj_in_or_out,RHSL,RCtx),maplist(cto_aa,[Type,LP|RCtx],AA),atomic_list_concat(AA,'_',TypeO))), @@ -1527,34 +1692,31 @@ */ -has_individuals(TestID):- var(TestID), !, ensure_test(TestID), has_individuals_real(TestID). -has_individuals(TestID):- has_individuals_real(TestID),!. -has_individuals(TestID):- warn_skip(has_individuals(TestID)),!. -has_individuals_real(TestID):- +has_individuals(TestID):- var(TestID), !, ensure_test(TestID), has_individuals(TestID). +has_individuals(TestID):- forall(current_example_nums(TestID,ExampleNum), (arc_cache:individuated_cache(TestID,TID,GID,_,Objs), sub_var(ExampleNum,(TID,GID)), Objs\==[])),!. + + ensure_individuals(TestID):- var(TestID),!,ensure_test(TestID),ensure_individuals(TestID). -ensure_individuals(TestID):- has_individuals_real(TestID),!. -ensure_individuals(TestID):- load_file_dyn_pfc(TestID),has_individuals_real(TestID),!. +ensure_individuals(TestID):- has_individuals(TestID),!. +ensure_individuals(TestID):- load_file_dyn_pfc(TestID),has_individuals(TestID),!. ensure_individuals(TestID):- time((with_individuated_cache(true, once((with_pair_mode(whole_test, ensure_individuals1(TestID))))))), save_test_hints_now(TestID). % ensure_individuals1 tries the ensure_individuals2 -ensure_individuals1(TestID):- has_individuals_real(TestID),!. +ensure_individuals1(TestID):- has_individuals(TestID),!. ensure_individuals1(TestID):- ensure_test(TestID), - ignore(once((with_pair_mode(whole_test, - ensure_individuals2(TestID)), - has_individuals_real(TestID)))),!. + once((with_pair_mode(whole_test, + ensure_individuals2(TestID)),has_individuals(TestID))),!. ensure_individuals2(TestID):- ignore((ExampleNum=trn+_)), print_collapsed(200, forall( kaggle_arc(TestID,ExampleNum,GridIn,GridOut), individuate_pair(complete,GridIn,GridOut,_InC,_OutC))). -ensure_individuals2(TestID):- warn_skip(ensure_individuals2(TestID)),!. - ensure_individuals2(TestID):- once(with_luser(menu_key,'i',once(ndividuator(TestID)))). ensure_individuals2(TestID):- once(with_luser(menu_key,'o',once(ndividuator(TestID)))). ensure_individuals2(TestID):- calc_propcounts(TestID). @@ -1603,8 +1765,8 @@ map_pairs_info2(TestID,IO,P,_Step):- nonvar(P),nonvar(IO),good_conseq(TestID,IO,P,YN),!,YN=yes. map_pairs_info2(TestID,IO,P,Step):- - var(P), \+ \+ is_accompany_changed_db(TestID,IO,_,_), - is_accompany_changed_db(TestID,IO,P,_),map_pairs_info2(TestID,IO,P,Step). + var(P), \+ \+ ac_db(TestID,IO,_,_), + ac_db(TestID,IO,P,_),map_pairs_info2(TestID,IO,P,Step). map_pairs_info2(TestID,IO,P,Step):- @@ -1620,37 +1782,78 @@ %ensure_propcounts(TestID), %learn_object_dependancy(TestID), - (var(IO)->gather_set(Ctx,map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,InFlatProps,OutFlatProps));true), + (var(IO)->gather_set(Ctx,pair_obj_props(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,InFlatProps,OutFlatProps));true), %IO_ = in, Ctx = in_out, %gather_set(P,(map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,UPA2,UPB2),member(P,PB2))). gather_set(P,( %nop(gather_set(Step,(map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,UPA2,UPB2),member(P,UPB2)))), map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,InFlatProps,UPB2),member(P,UPB2),ok_deduce(P))), %p_to_utbs(TestID,Ctx,P,UTBLists), - %common_members(UTBLists,Members), + %common_members(UTBLists,Members), %member(P,Members), - ignore(gather_set(Step,(map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,InFlatProps,OutFlatProps),member(P,OutFlatProps)))), + ignore(gather_set(Step,(pair_obj_props(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,InFlatProps,OutFlatProps),member(P,OutFlatProps)))), io_to_cntx(IO,Ctx). map_pairs_info_io(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,UPA2,UPB2):- - pair_obj_props(TestID,ExampleNum,Ctx,_Info,Step,TypeO,InL,OutL,USame,UPA2,UPB2). + pair_obj_props(TestID,ExampleNum,Ctx,Step,TypeO,InL,OutL,USame,UPA2,UPB2). -diff_l_r(InL,OutL,Same,InPFlat,OutFlatP):- +% old code +diff_l_r_old(InL,OutL,Same,InFlatP,OutPFlat):- must_det_ll(( (( \+ length(InL,1), OutL=[Out] ) -> sort_by_jaccard(Out,InL,[UseL|_]);UseL=InL), flat_props([UseL],PA), flat_props([OutL],PB), - noteable_propdiffs(PA,PB,Same,InPFlat,OutFlatP))). + noteable_propdiffs(PA,PB,Same,InFlatP,OutPFlat))),!. + + +% no operation +diff_l_r([],[],[],[],[]):- !. +diff_l_r(InL,OutL,Same,InFlatP,OutPFlat):- \+ is_list(InL),!,diff_l_r([InL],OutL,Same,InFlatP,OutPFlat). +diff_l_r(InL,OutL,Same,InFlatP,OutPFlat):- \+ is_list(OutL),!,diff_l_r(InL,[OutL],Same,InFlatP,OutPFlat). + +diff_l_r(InL,OutL,Same,InFlatP,OutPFlat):- fail, + must_det_ll(( + (( \+ length(InL,1), OutL=[Out] ) -> sort_by_jaccard(Out,InL,[UseL|_]);UseL=InL), + flat_props([UseL],PA), flat_props([OutL],PB), + noteable_propdiffs(PA,PB,Same,InFlatP,OutPFlat))),!. + +% copy/transform +diff_l_r([InL],OutL,PA1,[],OutFlat):- OutL\==[],!, + must_det_ll((flat_props([InL],PA), flat_props([OutL],PB), + remove_o_giz(PA,PA1),remove_o_giz(PB,PB1), + pred_intersection(propchange_unnoticable,PA1,PB1,_,_Same,_InFlatP,OutFlat))). + +% create new +diff_l_r([],OutL,[],[],OutL):- OutL\==[],!. + +% delete some +diff_l_r(InL,[],Precond,InFlatP,[pen([cc(bg,1)])]):- !, + flat_props([InL],InFlatP), + remove_o_giz(InFlatP,Precond). + +% mutiple preconds +diff_l_r(InL,OutL,Same,InFlatP,OutPFlat):- OutL\==[],InL\==[],!, + %pp_ilp(out=OutL), pp_ilp(in=InL), + must_det_ll(( + sort_by_jaccard(OutL,InL,SharedInL), + [UseL|Rest] = SharedInL, + diff_l_r([UseL],OutL,Same1,InFlatP1,OutPFlat1), + diff_l_r(Rest,OutL,SameR,InFlatPR,OutPFlatR), + append_vsets([Same1,SameR],Same), + append_vsets([InFlatP1,InFlatPR],InFlatP), + append_vsets([OutPFlat1,OutPFlatR],OutPFlat))). + +append_vsets(I,O):- flatten([I],M),variant_list_to_set(M,O),!. -noteable_propdiffs(PA,PB,Same,InPFlat,OutFlatP):- +noteable_propdiffs(PA,PB,Same,InFlatP,OutPFlat):- remove_o_giz(PA,PA1),remove_o_giz(PB,PB1), %=(PA,PA1),=(PB,PB1), - pred_intersection(propchange_unnoticable,PA1,PB1,_,Same,InPFlat,OutFlatP),!. -noteable_propdiffs(PA,PB,Same,InPFlat,OutFlatP):- + pred_intersection(propchange_unnoticable,PA1,PB1,_,Same,InFlatP,OutPFlat),!. +noteable_propdiffs(PA,PB,Same,InFlatP,OutPFlat):- remove_o_giz(PA,PA1),remove_o_giz(PB,PB1), - intersection(PA1,PB1,Same,InPFlat,OutFlatP),!. + intersection(PA1,PB1,Same,InFlatP,OutPFlat),!. propchange_unnoticable(InL,OutL):- InL=@=OutL,!. propchange_unnoticable(InL,OutL):- make_unifiable_u(InL,AU),make_unifiable_u(OutL,BU), AU\=@=BU,!,fail. @@ -1678,7 +1881,7 @@ hide_propchange2(link(PA,_),link(PA,_)). hide_propchange2(pg(_,P,rank1,N),pg(_,P,rank1,N)). hide_propchange2(occurs_in_links(PA,_),occurs_in_links(PA,_)). -%hide_propchange2(links_count(PA,_),links_count(PA,_)). +hide_propchange2(links_count(PA,_),links_count(PA,_)). hide_propchange2(giz(example_num(ExampleNum)),giz(example_num(ExampleNum))). hide_propchange2(giz(gid(_)),giz(gid(_))). hide_propchange2(giz(InL),giz(OutL)):- make_unifiable_u(InL,OutL). @@ -1692,7 +1895,7 @@ hide_propchange1(iz(symmetry_type(_,False))):- False == false. hide_propchange1(iz(symmetry_type(_,False))):- False == true. %hide_propchange1(pg(_,_,_,_)). -hide_propchange1(line(sees(_),_)). +hide_propchange1(link(sees(_),_)). hide_propchange1(pg(_,_,rankLS,_)). hide_propchange1(iz(P)):-!,hide_propchange1(P). hide_propchange1(P):- \+ ok_notice(P),!. @@ -1705,9 +1908,9 @@ remove_o_giz(In,Out):- \+ compound(In),!,Out=In. remove_o_giz(obj(In),Out):- nonvar(In),!,remove_o_giz(In,Out),!. remove_o_giz(In,Out):- m_unifiers(In,MidF),o_unifiers(MidF,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). -remove_o_giz(In,Out):- is_group(In),mapgroup(remove_o_giz,In,MidF),flatten(MidF,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). remove_o_giz(In,Out):- my_exclude(hide_propchange1,In,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). -remove_o_giz(In,Out):- maplist(hide_propchange,In,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). +remove_o_giz(In,Out):- maplist(hide_propchange,In,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). +remove_o_giz(In,Out):- is_group(In),mapgroup(remove_o_giz,In,MidF),flatten(MidF,Mid),In\=@=Mid,!,remove_o_giz(Mid,Out). %remove_o_giz(In,Out):- remove_giz(In,Out),!. remove_o_giz(Out,Out). @@ -1716,26 +1919,12 @@ - - - - - - - - - - - - - - is_accompany_changed_verified(TestID,IO,P,PSame):- is_accompany_changed_computed(TestID,IO,P,PSame), PSame\==[]. is_accompany_changed_computed(TestID,IO,P,PSame):- - is_accompany_changed_db(TestID,IO,P,PSame) *->true ; prop_can(TestID,IO,P,PSame). -/* + ac_db(TestID,IO,P,PSame) *->true ; prop_can(TestID,IO,P,PSame). + prop_can(TestID,IO,P,Can):- props_change(TestID,IO,P), once((prop_cant(TestID,IO,P,Cant), @@ -1775,6 +1964,7 @@ find_peers_with_same(TestID,IO,P,SameWO,NewSame). find_peers_with_same(_,_,PSame,PSame):-!. + @@ -1810,30 +2000,24 @@ member(X2-IO,X1S), % X1@>X2, other_val(X1,X2). -*/ + +print_scene_change_rules(TestID):- ensure_test(TestID), + print_scene_change_rules(print_scene_change_rules,TestID). + print_scene_change_rules(Why,TestID):- ensure_test(TestID), must_det_ll(( banner_lines(cyan,4), - print_set(Why,is_accompany_changed_db), + print_set(Why,ac_db), banner_lines(cyan,4))). print_set(Why,P3):- - Ele = is_accompany_changed_db(TestID,IO_,P,PSame), - findall(Ele,call(P3,TestID,IO_,P,PSame),List), - sort(List,SetR),reverse(SetR,Set), - pp_ilp(Why), dash_chars, - maplist(pp_ilp,Set),!. - - - - - - - - + pp_ilp(Why), + pp_ilp_vset(call(P3,TestID,IO,P,PSame), + ac_db(TestID,IO,P,PSame)), + dash_chars. has_propcounts(TestID):- forall(current_example_nums(TestID,ExampleNum), @@ -1842,23 +2026,25 @@ ensure_propcounts(TestID):- ensure_test(TestID),ensure_propcounts1(TestID). ensure_propcounts1(TestID):- has_propcounts(TestID),!. -ensure_propcounts1(_TestID):-!. ensure_propcounts1(TestID):- ensure_individuals(TestID),!. ensure_propcounts1(TestID):- calc_propcounts(TestID),has_propcounts(TestID),!. + ensure_propcounts1(TestID):- once((with_pair_mode(whole_test, with_luser(menu_key,'o',once(ndividuator(TestID)))))),has_propcounts(TestID),!. ensure_propcounts1(TestID):- show_prop_counts(TestID), has_propcounts(TestID),!. ensure_propcounts1(_). -props_change(TestID,IO,P):- map_pairs_info(TestID,IO,P,_Step). +props_change(TestID,IO,P):- map_pairs_info(TestID,IO,P,_Step),good_for_rhs(P). props_change2(TestID,IO,P):- % ensure_propcounts(TestID), %ensure_prop_change(E), findall(Q-I_or_O,counts_change(TestID,_,I_or_O,Q,_,_),L),list_to_set(L,S),!,member(P-IO,S),ok_deduce(P). %ensure_prop_change(IO,P):- (var(P)->props_change(_TestID,IO,P);true). -counts_change(TestID,ExampleNum,In,P,N2,N1):- throw(cCC), in_out_atoms(In,Out), +in_out_atoms(in,out). + +counts_change(TestID,ExampleNum,In,P,N2,N1):- in_out_atoms(In,Out), ensure_propcounts(TestID), propcounts(TestID, ExampleNum, Out, count, N1, P), ok_deduce(P), ExampleNum = trn+_, @@ -1871,9 +2057,11 @@ (propcounts(TestID, ExampleNum, Out, count, N2, P) -> true ; N2=0), N1\==N2. + + ensure_scene_change_rules(TestID):- ensure_test(TestID), - ( \+ is_accompany_changed_db(TestID,_,_,_) -> compute_scene_change(TestID) ; true ). + (\+ ac_db(TestID,_,_,_) -> compute_scene_change(TestID) ; true). @@ -1889,9 +2077,10 @@ banner_lines(yellow,4), compute_scene_change_pass3(TestID), banner_lines(blue,4), + compute_scene_change_pass4(TestID), /* - compute_scene_change_pass4(TestID),*/ + ,*/ !))). @@ -1899,22 +2088,22 @@ show_object_dependancy(TestID),!. %learn_object_dependancy(TestID). + compute_scene_change_pass2(TestID):- - forall( pair_obj_props_54321(TestID,Ex,Ctx,Info,Step,Type,LHSO,RHSO,S,L,R), - %forall(ensure_props_change(TestID,Ctx,P), - % forall(prop_can(TestID,Ctx,P,PSame), - ((assert_accompany_changed_db(TestID,Ctx,R,S)))). + retractall(ac_unit(TestID,_,_,_)), + forall(pass2_rule(TestID,Ctx,P,PSame), + assert_accompany_changed_db(TestID,Ctx,P,PSame)). compute_scene_change_pass3(TestID):- must_det_ll(( print_scene_change_rules(pass2,TestID), set_of_changes(TestID,compute_scene_change_pass3a(TestID)), print_scene_change_rules(pass3a,TestID), - get_single_char(_), + %get_single_char(_), set_of_changes(TestID,compute_scene_change_pass3b(TestID,correct_antes1)), set_of_changes(TestID,compute_scene_change_pass3c(TestID)), print_scene_change_rules(pass3b1,TestID), - get_single_char(_), + %get_single_char(_), set_of_changes(TestID,compute_scene_change_pass3b(TestID,correct_antes2)), print_scene_change_rules(pass3b2,TestID), set_of_changes(TestID,compute_scene_change_pass3b(TestID,correct_antes3)), @@ -1924,15 +2113,16 @@ set_of_changes(TestID,compute_scene_change_pass3c(TestID)), print_scene_change_rules(pass3c,TestID))),!. + compute_scene_change_pass3a(TestID,IO_-P):- - findall(PSame,is_accompany_changed_db(TestID,IO_,P,PSame),List), + findall(PSame,ac_db(TestID,IO_,P,PSame),List), List=[_,_|_], - flatten(List,SameF), variant_list_to_set(SameF,SameS), + into_lhs(List,SameS), update_accompany_changed_db(TestID,IO_,P,SameS). compute_scene_change_pass3a(_,_). compute_scene_change_pass3b(TestID,P4,IO_-P):- - findall(PSame,is_accompany_changed_db(TestID,IO_,P,PSame),List), + findall(PSame,ac_db(TestID,IO_,P,PSame),List), flatten(List,SameF), variant_list_to_set(SameF,SameS), call(P4,TestID,IO_,P,SameS,Kept), Kept\==[],!, update_accompany_changed_db(TestID,IO_,P,Kept). @@ -1940,13 +2130,13 @@ compute_scene_change_pass3c(_,_):-!. compute_scene_change_pass3c(TestID,IO_-P):- - is_accompany_changed_db(TestID,IO_,P,PSame), + ac_db(TestID,IO_,P,PSame), findall(DSame, - (is_accompany_changed_db(TestID,IO_,DP,DSame), + (ac_db(TestID,IO_,DP,DSame), once(other_val(DP,P);DP=P),at_least_one_overlap(DSame,PSame)), SL), SL = [_,_|_], common_members(SL,Commons), - forall((is_accompany_changed_db(TestID,IO_,DP,DSame),once(other_val(DP,P);DP=P)), + forall((ac_db(TestID,IO_,DP,DSame),once(other_val(DP,P);DP=P)), (intersection(DSame,Commons,_,Kept,_), ignore((Kept\==[],update_accompany_changed_db(TestID,IO_,P,Kept))))). compute_scene_change_pass3c(_,_). @@ -1956,17 +2146,28 @@ compute_scene_change_pass3(TestID). set_of_changes(TestID,P1):- - findall_vset(IO_-P,ensure_props_change(TestID,IO_,P),Ps), - maplist(P1,Ps). + nop((findall_vset(IO_-P, + (ac_db(TestID,IO_,P,_) + ;ensure_props_change(TestID,IO_,P) + ;pass2_rule(TestID,IO_,P,_)), Ps))), + + findall_vset(IO_-P,(ac_db(TestID,IO_,P,_)), Ps), + maplist(P1,Ps). update_accompany_changed_db(TestID,IO_,P,Kept):- Kept\==[], - forall(retract(is_accompany_changed_db(TestID,IO_,P,_)),true), - assert_accompany_changed_db(TestID,IO_,P,Kept). + forall(retract(ac_unit(TestID,IO_,P,_)),true), + into_lhs(Kept,KeptL), + assert_accompany_changed_db(TestID,IO_,P,KeptL). assert_accompany_changed_db(_TestID,_IO_,_P,Kept):- Kept==[],!. assert_accompany_changed_db(TestID,IO_,P,Kept):- - assert_become_new(is_accompany_changed_db(TestID,IO_,P,Kept)). + into_lhs(Kept,KeptL), + assert_become_new(ac_unit(TestID,IO_,P,KeptL)). + +%assert_become_new(Term):- \+ clause_asserted(Term),!, pp_ilp(assert_become_new=Term), asserta_new(Term). +assert_become_new(Term):- asserta_new(Term). +%assert_become_new(Term):- pp_ilp(assert_become_new=Term),!, assert_if_new(Term). at_least_one_overlap(DSame,PSame):- member(DS,DSame),member(S,PSame), @@ -1977,19 +2178,23 @@ findall(S, (member(S,PSame), \+ \+ (( - forall((is_accompany_changed_db(TestID,IO_,DP,DSame),at_least_one_overlap(DSame,PSame)), + forall((ac_db(TestID,IO_,DP,DSame),at_least_one_overlap(DSame,PSame)), ((P==DP)-> true; (member(DS,DSame), \+ negated_s_lit(S,_), other_val(S,DS))))))), SL), SL\==[],!. correct_antes1(_TestID,_IO_,_P,PSame,PSame). -correct_antes2(TestID,IO_,P,PSame,Kept):- +correct_antes_neg(TestID,IO_,P,PSame,Kept):- %rev_in_out_atoms(OI,IO_), findall( ( \+ S), - ((is_accompany_changed_db(TestID,IO_,DP,DSame), + ((ac_db(TestID,IO_,DP,DSame), other_val(P,DP), at_least_one_overlap(DSame,PSame), - member(S,DSame), \+ negated_s_lit(S,_), make_unifiable_u(S,SU), \+ member(SU,PSame))), SL), + member(S,DSame), \+ negated_s_lit(S,_), make_unifiable_u(S,SU), SU\=@=S , \+ member(SU,PSame))), SL), SL\==[], append(PSame,SL,Kept),Kept\==[],!. +correct_antes_neg(_TestID,_IO_,_P,PSame,PSame). + +correct_antes2(_TestID,_IO_,_P,PSame,Kept):- vsr_set(PSame,Kept),!. +correct_antes2(TestID,IO_,P,PSame,Kept):- fail, correct_antes_neg(TestID,IO_,P,PSame,Kept). correct_antes2(_TestID,_IO_,_P,PSame,PSame). correct_antes3(_TestID,_IO_,P,PSame,Kept):- fail, @@ -2031,5 +2236,3 @@ findall(PreObjs,arc_cache:map_pairs(TestID,_,trn+N,info(0,_,in_out,_,_,trn+N),PreObjs,Out),PreObjs), homogenize(OutL,Sames,Diffs), */ - -