Prolog "compat"

Admin User, erstellt 15. März 2024
         
/**
* Modern Albufeira Prolog Interpreter
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
:-(forall(A, B), \+(','(A, \+(B)))).
:-(sort(L, R), ','(sys_check_list(L), sys_quicksort(L, R, []))).
:-(sys_check_list(V), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_check_list([]), !).
:-(sys_check_list('.'(_, L)), ','(!, sys_check_list(L))).
:-(sys_check_list(L), throw(error(type_error(list, L), _))).
-->(sys_quicksort([]), []).
-->(sys_quicksort('.'(X, L)), ','({}(sys_partition(L, X, L1, L2)), ','(sys_quicksort(L1), ','('.'(X, []), sys_quicksort(L2))))).
sys_partition([], _, [], []).
:-(sys_partition('.'(X, L), Y, R, L2), ','(@<(X, Y), ','(!, ','(=(R, '.'(X, L1)), sys_partition(L, Y, L1, L2))))).
:-(sys_partition('.'(X, L), Y, L1, L2), ','(==(X, Y), ','(!, sys_partition(L, Y, L1, L2)))).
:-(sys_partition('.'(X, L), Y, L1, '.'(X, L2)), sys_partition(L, Y, L1, L2)).
:-(keysort(L, R), ','(sys_check_pairs(L), sys_keyquicksort(L, R, []))).
:-(sys_check_pairs(V), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_check_pairs([]), !).
:-(sys_check_pairs('.'(P, L)), ','(!, ','(sys_check_pair(P), sys_check_pairs(L)))).
:-(sys_check_pairs(L), throw(error(type_error(list, L), _))).
:-(sys_check_pair(V), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_check_pair(-(_, _)), !).
:-(sys_check_pair(P), throw(error(type_error(pair, P), _))).
-->(sys_keyquicksort([]), []).
-->(sys_keyquicksort('.'(-(X, P), L)), ','({}(sys_keypartition(L, X, L1, L2, L3)), ','(sys_keyquicksort(L1), ','('.'(-(X, P), []), ','(sys_keylist(L2), sys_keyquicksort(L3)))))).
sys_keypartition([], _, [], [], []).
:-(sys_keypartition('.'(-(X, P), L), Y, R, L2, L3), ','(@<(X, Y), ','(!, ','(=(R, '.'(-(X, P), L1)), sys_keypartition(L, Y, L1, L2, L3))))).
:-(sys_keypartition('.'(-(X, P), L), Y, L1, R, L3), ','(==(X, Y), ','(!, ','(=(R, '.'(-(X, P), L2)), sys_keypartition(L, Y, L1, L2, L3))))).
:-(sys_keypartition('.'(-(X, P), L), Y, L1, L2, '.'(-(X, P), L3)), sys_keypartition(L, Y, L1, L2, L3)).
-->(sys_keylist([]), []).
-->(sys_keylist('.'(X, L)), ','('.'(X, []), sys_keylist(L))).
:-(subsumes_term(X, Y), ','(sys_not_subsumes(X, Y), ','(!, fail))).
subsumes_term(_, _).
:-(sys_not_subsumes(X, Y), ','(subsumes(X, Y), ','(!, fail))).
sys_not_subsumes(_, _).
:-(ensure_loaded(foreign(fastlib))).