Skip to content

Commit

Permalink
into_lhs
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed May 2, 2023
1 parent 6f88104 commit c75e041
Show file tree
Hide file tree
Showing 10 changed files with 553 additions and 267 deletions.
2 changes: 1 addition & 1 deletion packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 20 additions & 12 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -473,17 +473,21 @@
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).

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(_,_).

Expand Down Expand Up @@ -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.
Expand All @@ -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))).
Expand All @@ -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=[_|_].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):-
Expand Down
71 changes: 49 additions & 22 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_howdiff.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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.
Expand Down Expand Up @@ -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),!.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,!.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),!.



Expand Down Expand Up @@ -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).
Expand Down
24 changes: 14 additions & 10 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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).
Expand Down Expand Up @@ -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)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
Loading

0 comments on commit c75e041

Please sign in to comment.