--- /dev/null
+:- use_module(library(format)).
+
+
+test :- compare(_, ("0"-'2'), ("1"-'1')).
+
+?- test.
+ false, unexpected.
+ true.
--- /dev/null
+get_assoc(Key, t(K,V,_,L,R), Val) :-
+ compare(Rel, Key, K),
+ get_assoc(Rel, Key, V, L, R, Val).
+
+get_assoc(=, _, Val, _, _, Val).
+get_assoc(>, Key, _, _, Tree, Val) :- get_assoc(Key, Tree, Val).
+
+test :- get_assoc("1"-'0', t("0"-'2',_, _, t(_,_,_,t,t), t("1"-'0',_,_,t,t)), _).
+
+?- test.
+ false, unexpected.
+ true.
--- /dev/null
+:- use_module(library(format)).
+
+% is_assoc copied from library(assoc) and renamed to is_assoc_
+% and `% format("~w~n", [is_assoc_(R,RMin,Max,RDepth)]),` added
+
+is_assoc_(Assoc) :-
+ is_assoc_(Assoc, _Min, _Max, _Depth).
+
+is_assoc_(t,X,X,0) :- !.
+is_assoc_(t(K,_,-,t,t),K,K,1) :- !, ground(K).
+is_assoc_(t(K,_,>,t,t(RK,_,-,t,t)),K,RK,2) :-
+ % Ensure right side Key is 'greater' than K
+ !, ground((K,RK)), K @< RK.
+
+is_assoc_(t(K,_,<,t(LK,_,-,t,t),t),LK,K,2) :-
+ % Ensure left side Key is 'less' than K
+ !, ground((LK,K)), LK @< K.
+
+is_assoc_(t(K,_,B,L,R),Min,Max,Depth) :-
+ is_assoc_(L,Min,LMax,LDepth),
+ % format("~w~n", [is_assoc_(R,RMin,Max,RDepth)]),
+ is_assoc_(R,RMin,Max,RDepth),
+ % Ensure Balance matches depth
+ compare(Rel,RDepth,LDepth),
+ balance(Rel,B),
+ % Ensure ordering
+ ground((LMax,K,RMin)),
+ LMax @< K,
+ K @< RMin,
+ Depth is max(LDepth, RDepth)+1.
+
+balance(=,-).
+balance(>,>).
+balance(<,<).
+
+test :- is_assoc_(t(2,1,-,t(1,1,-,t,t),t(3,1,-,t,t))).
+
+?- test.
+ true.
--- /dev/null
+a(t(K),K) :- ground(K).
+
+test :- a(t(3), M), M=M.
+
+?- test.
+ true.
--- /dev/null
+:- use_module(library(assoc)).
+:- use_module(library(lists)).
+:- use_module(library(iso_ext)).
+
+put([_], _).
+put([Old, New | Tail], Idx) :-
+ put_assoc(Idx, Old, 1, New),
+ IdxP is Idx +1,
+ put([New |Tail], IdxP).
+
+run(Max, Bad) :-
+ empty_assoc(A),
+ length(As, Max),
+ put([A|As], 1),
+ findall(Idx, (nth0(Idx, [A|As], Assoc), \+ is_assoc(Assoc)), Bad).
+
+
+?- N = 20, run(N, Bad).
+ N = 20, Bad = [3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], unexpected
+ ; false.
+ N = 20, Bad = []
+ ; false.
+
+test :- run(20, []).
--- /dev/null
+:- use_module(library(assoc)).
+:- use_module(library(lists)).
+:- use_module(library(iso_ext)).
+:- use_module(library(between)).
+
+p(Idx, Idx-1).
+
+test(N) :-
+ numlist(N, As),
+ maplist(p, As, Bs),
+ list_to_assoc(Bs, Assoc),
+ is_assoc(Assoc).
+
+run(Max, Bad) :-
+ numlist(Max, Num),
+ findall(N, (member(N, [0|Num]), \+ test(N)), Bad).
+
+?- N = 20, run(N, Bad).
+ Bad = [3,4,6,7,8,9,10,12,13,14,15,16,17,18,19,20], unexpected.
+ N = 20, Bad = [].
+
+test :- run(20, []).
--- /dev/null
+:- use_module(library(assoc)).
+
+test :-
+ empty_assoc(A1),
+ put_assoc(([a]-1), A1, 1, A2),
+ put_assoc(([a]-2), A2, 1, A3),
+ put_assoc(([b]-1), A3, 1, _).
+
+
+?- test.
+ false, unexpected.
+ true.
--- /dev/null
+Bound Variables are sometimes not considered ground even though they should be ground.
+
+```trycmd
+$ scryer-prolog -f --no-add-history original.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history original_alt.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history minimize1.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history minimize_final.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history pair_string_key.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history compare.pl -g test -g halt
+
+```
+
+```trycmd
+$ scryer-prolog -f --no-add-history compare_get_assoc.pl -g test -g halt
+
+```
\ No newline at end of file
cases
.default_bin_name("scryer-prolog")
.case("tests/scryer/cli/issues/*.toml")
+ .case("tests/scryer/cli/issues/*.md")
.case("tests/scryer/cli/src_tests/*.toml")
.case("tests/scryer/cli/src_tests/*.md");