Skip to content

Commit

Permalink
OBO
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Aug 17, 2023
1 parent d258703 commit b195bcf
Show file tree
Hide file tree
Showing 65 changed files with 1,938,646 additions and 500 deletions.
98 changes: 0 additions & 98 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_boards.pl
Original file line number Diff line number Diff line change
Expand Up @@ -498,25 +498,6 @@
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(X1,X2):- verbatum_unifiable(X1), !, X2=X1.
%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(_,_).


:- dynamic(io_xform/3).
add_xform_maybe(In1,Out1):- ignore(get_current_test(TestID)),
Expand Down Expand Up @@ -729,85 +710,6 @@
numbervars(true),singletons(true),blobs(portray),
quote_non_ascii(true),brace_terms(false),ignore_ops(true)]))).

must_min_unifier(A,B,D):- must_det_ll(min_unifier_e(A,B,D)).
%min_unifier_e(A,B,C):- compound(B),maybe_extract_value(B,BB), \+ maybe_extract_values(A,_), c_proportional(A,BB,AABB),min_unifier(AABB,B,C),!.
%min_unifier_e(B,A,C):- compound(B),maybe_extract_value(B,BB), \+ maybe_extract_values(A,_), c_proportional(A,BB,AABB),min_unifier(AABB,B,C),!.
min_unifier_e(A,B,C):- maybe_extract_value(B,BB), \+ maybe_extract_value(A,_), min_unifier(A,BB,C).
min_unifier_e(B,A,C):- maybe_extract_value(B,BB), \+ maybe_extract_value(A,_), min_unifier(BB,A,C).
min_unifier_e(A,B,C):- min_unifier(A,B,C),nonvar(C),!.
%min_unifier_e(A,B,C):- compound(B),maybe_extract_values(B,BB), \+ maybe_extract_values(A,_), c_proportional(A,BB,AABB),must_min_unifier(AABB,B,C),!.
%min_unifier_e(B,A,C):- compound(B),maybe_extract_values(B,BB), \+ maybe_extract_values(A,_), c_proportional(A,BB,AABB),must_min_unifier(AABB,B,C),!.
min_unifier_e(_,_,_).

some_min_unifier(X,X):- \+ compound(X),!.
some_min_unifier([A|List],Term):- some_min_unifier_3(A,List,Term).

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\==unkC,B\==wbg,!,C=A.
is_a_min_unifier(A,_,C):- plain_var(A),!,C=A.
is_a_min_unifier(A,B,C):- compound(A),A=trim(BB),B==BB,!,C=A.

min_unifier(A,B,C):- A=@=B,!,C=A.
min_unifier(A,B,C):- is_a_min_unifier(A,B,C),!.
min_unifier(B,A,C):- is_a_min_unifier(A,B,C),!.
min_unifier(A,B,C):- min_unifier_u(A,B,C),!.
/*
min_unifier(A,B,A):- plain_var(B),!.
min_unifier(A,B,B):- plain_var(A),!.
*/

min_unifier_n(A,B,D):- number(A),number(B),!,c_proportional(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,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))).
min_unifier_u(A,B,AA):- is_cons(A),is_cons(B),!,min_list_unifier(A,B,AA),!.
%min_unifier(A,B,C):- is_list(A),sort_safe(A,AA),A\==AA,!,min_unifier(B,AA,C).
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=[_|_].


min_grid_unifier(A,B,_):- (\+ is_list(A) ; \+ is_list(B)),!.
min_grid_unifier(A,B,[E1|C]):- select(E1,A,AA),select(E2,B,BB), E1=@=E2 ,!,min_grid_unifier(AA,BB,C).
min_grid_unifier(A,B,[E |C]):- select(E1,A,AA),select(E2,B,BB),min_unifier(E1,E2,E),!,min_grid_unifier(AA,BB,C).
min_grid_unifier(_,_,_).


min_list_unifier(A,B,A):- A=@=B,!.
min_list_unifier(A,B,_):- ( \+ compound(A); \+ compound(B) ),!.
min_list_unifier(A,B,A):- is_list(A),is_list(B), sort_safe(A,AA),sort_safe(B,BB),BB=@=AA,!.
min_list_unifier([A|AA],[B|BB],[A|CC]):- A=@=B,min_list_unifier(AA,BB,CC).
min_list_unifier([A|AA],[B|BB],[C|CC]):- A\=@=B,min_list_unifier(AA,BB,CC),min_unifier(A,B,C),!.
min_list_unifier(A,B,[EC|C]):- is_list(A),is_list(B), select_two(A,B,E1,E2,AA,BB), min_unifier(E1,E2,EC) ,!,min_list_unifier(AA,BB,C).


min_list_unifier(A,_,_):- (\+ is_list(A), \+ is_cons(A)),!.
min_list_unifier(_,A,_):- (\+ is_list(A), \+ is_cons(A)),!.
min_list_unifier(A,B,_):- (\+ is_list(A) ; \+ is_list(B)),!.

%min_list_unifier([E1|AA],[E2|BB],[EC|C]):- min_unifier(E1,E2,EC) ,!,min_unifier(AA,BB,C).
min_list_unifier(A,B,[E1|C]):- nonvar(A),nonvar(B), select(E1,A,AA),nonvar(E1),select(E2,B,BB),nonvar(E2), E1=@=E2 ,!,min_list_unifier(AA,BB,C).
%min_list_unifier([_|A],[_|B],[_|C]):- !,min_list_unifier(A,B,C).
%min_list_unifier([_],[_|B],[_|B]):-!.
%min_list_unifier([_|B],[_],[_|B]):-!.
min_list_unifier(_,_,_):-!.
%min_unifier(A,B,C):- is_list(B), is_list(A), length(B,L), length(A,L), length(C,L).

grid_hint_swap(TestID,ExampleNum,IO,In,Out):-
ignore(kaggle_arc(TestID,ExampleNum,In,Out)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:- ensure_loaded(kaggle_arc_typecheck).
:- ensure_loaded(kaggle_arc_interpreter).
:- ensure_loaded(kaggle_arc_test_favs).
:- ensure_loaded(kaggle_arc_unifiable).

:- ensure_loaded(kaggle_arc_skels).
:- ensure_loaded(kaggle_arc_reduce).
Expand Down
28 changes: 0 additions & 28 deletions packs_sys/logicmoo_agi/prolog/kaggle_arc/kaggle_arc_learning.pl
Original file line number Diff line number Diff line change
Expand Up @@ -785,34 +785,6 @@
maybe_exclude_whole(AG1,AG2),
filter_redundant(AG2,AG).

make_unifiable(A1,A2):- make_unifiable0(A1,O),!,A2=O.

make_unifiable0(C1,_):- \+ compound(C1),fail.
make_unifiable0(A1,A2):- var(A1),!,A2=A1.
make_unifiable0(pg(A,B,C,_),pg(A,B,C,_)):-!.
make_unifiable0(cc(C,_),cc(C,_)):-!.
make_unifiable0(iz(C1),iz(C2)):- !, make_unifiable(C1,C2).
make_unifiable0(giz(C1),giz(C2)):- !, make_unifiable(C1,C2).
make_unifiable0(Cmp,CmpU):- Cmp=..[F|List1],
append(Left1,[C1],List1),append(Left2,[C2],List2), CmpU=..[F|List2],
my_maplist(unifiable_cmpd_else_keep,Left1,Left2),
unifiable_cmpd_else_var(C1,C2),!.
make_unifiable0(C1,C2):- functor(C1,F,A),functor(C2,F,A).

%unifiable_cmpd_else_keep(A1,A2):- unifiable_cmpd_keep(A1,A2).
unifiable_cmpd_else_keep(Num,_):- number(Num),!.
unifiable_cmpd_else_keep(A1,A1).

unifiable_cmpd_else_var(A1,A2):- unifiable_cmpd_keep(A1,A2), \+ ground(A2).
unifiable_cmpd_else_var(_,_).


unifiable_cmpd_keep(A1,A2):- var(A1),!,A2=A1.
unifiable_cmpd_keep(cc(C,_),cc(C,_)):-!.
unifiable_cmpd_keep(A1,A2):- compound(A1), \+ is_list(A1), make_unifiable(A1,A2),!.


make_unifiable_with_ftvars(C1,C2):- functor(C1,F,A),functor(C2,F,A),numbervars(C2).



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,42 +956,7 @@
objects_names_props(SubObjs,Props):-
findall(F-Prop,(member(O,SubObjs),object_prop(O,Prop),prop_name(Prop,F)),Props).

prop_value(Prop,Value):- nonvar(Value),prop_value(Prop,Var),!,Value=Var.
prop_value(List,Value):- is_list(List),!,maplist(prop_value,List,Value),!.
prop_value(Prop,Value):- prop_first_value(Prop,Value).

prop_first_value(Prop,Value):- nonvar(Value),prop_first_value(Prop,Var),!,Value=Var.
prop_first_value(Prop,Value):- \+ compound(Prop),!,Value=Prop.
prop_first_value(\+ Prop,Value):- nonvar(Prop),!,prop_first_value(Prop,Value).
prop_first_value(_ - Prop,Value):- nonvar(Prop),!,prop_first_value(Prop,Value).
prop_first_value(List,Value):- is_list(List),!,member(Prop,List),prop_first_value(Prop,Value),!.
prop_first_value(Value,Value).

prop_name(Prop,Named):- nonvar(Named),prop_name(Prop,Var),!,Named=Var.
prop_name(Prop,Named):- make_prop_name(Prop,Named),!.
prop_name(Prop,Named):- prop_first_value(Prop,Value), value_to_name(Value,Named),!.


make_prop_name(X,Y):- \+ compound(X),!,X=Y.
make_prop_name(samez(Prop, _),samez(Named)):- !, make_prop_name(Prop,Named).
make_prop_name(pg(_,X,R,_),pg(X,R)):-!.
make_prop_name(iz(Prop),iz(Named)):- !, make_prop_name(Prop,Named).
make_prop_name(giz(Prop),giz(Named)):- !, make_prop_name(Prop,Named).
make_prop_name(Prop,Free):- make_unifiable_cc(Prop,Named),remove_free_args(Named,Free),!.
make_prop_name(Prop,Named):- functor(Prop,Named,_).
remove_free_args(Named,Free):- copy_term(Named,Free),term_variables(Free,Vs),numbervars(Vs,666,_,[singletons(true)]).
%remove_free_args(Named,Free):- Named=..[F|Args],include(nonvar,Args,NArgs),Free=..[F|NArgs].




value_to_name(Value,Named):- nonvar(Named),value_to_name(Value,Named2),!,Named2=Named.
value_to_name(Value,Named):- \+ compound(Value),!,Value=Named.
value_to_name(Value,Named):- make_unifiable_cc(Value,Named),!.
value_to_name(Value,Named):- make_unifiable_cc(Value,UProp),
compound_name_arguments(UProp,F,Args),
include(nonvar,Args,OArgs),
(OArgs ==[] -> Named=F ; compound_name_arguments(Named,F,OArgs)).


mostly_fg_objs(OutCR,OutCR):-!.
Expand Down Expand Up @@ -2154,19 +2119,7 @@
templify_cc(N-WP1,N-WP2):- !, templify_cc(WP1,WP2).


make_unifiable_cc(WP1,WP2):- \+ compound(WP1),!,WP2=WP1.
make_unifiable_cc(N-WP1,N-_):- \+ is_list(WP1),!.
make_unifiable_cc(N-WP1,N-WP2):- !, make_unifiable_cc(WP1,WP2).
make_unifiable_cc([H|T],[HH|TT]):- !, make_unifiable_cc(H,HH),make_unifiable_cc(T,TT).
make_unifiable_cc(cc(C,N),cc(_,N)):- integer(N), is_real_color(C),!.
make_unifiable_cc(cc(N,_),cc(N,_)):-!.
make_unifiable_cc(oid(_),oid(_)):-!.
make_unifiable_cc(recolor(N,_),recolor(N,_)):-!.
make_unifiable_cc(rotSize2D(grav,_,_),rotSize2D(grav,_,_)):-!.
%make_unifiable_cc(grid_ops(comp,_),grid_ops(comp,_)):-!.
make_unifiable_cc(iz(symmetry_type(N,_)),iz(symmetry_type(N,_))):-!.
make_unifiable_cc(pg(_,G,M,_),pg(_,UG,M,_)):-!,make_unifiable_cc(G,UG).
make_unifiable_cc(O,U):- make_unifiable(O,U).


count_objs(B,O):- \+ is_list(B),!, O = 0.
count_objs(B,O):- \+ ( member(E,B), is_list(E)), \+ ( member(E,B), compound(E), functor(E,F,_), upcase_atom(F,UF),downcase_atom(F,UF)),!,O=1.
Expand Down
Loading

0 comments on commit b195bcf

Please sign in to comment.