Path: ...!3.eu.feeder.erje.net!feeder.erje.net!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mild Shock Newsgroups: comp.lang.prolog Subject: variant_term/2 is faster than variant/1 (Was: Request for comments, Novacore the sequel to ISO modules) Date: Sat, 12 Oct 2024 22:02:21 +0200 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 12 Oct 2024 20:02:21 -0000 (UTC) Injection-Info: solani.org; logging-data="370639"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19 Cancel-Lock: sha1:Qg4pAX6hsW/lyX81OJXQ8zPLV0s= X-User-ID: eJwNyNEBRDEEBMCWgrWknCP0X8K7+Rw3CjtAJ3x9tRIZO1rH5xGXT/uIqgoZ9xni/zkL3JrehskB6wemIfkBPUIUtA== In-Reply-To: Bytes: 2268 Lines: 46 The ISO core standard probably set the stage for a couple of performance sins. In 7.1.6.1 Variants of a term we find these test cases: - f(A, B, A) is a variant of f(X, Y, X). - g(A, B) is a variant of g(_, _). - P+Q is a variant of P+Q. What is doubious here, is the last test case with P+Q. Do we need to test terms that have common variables? Lets assume we have situations where we don't need variant working with common variables in the two argument terms, what about then using this bootstrapping: variant_term(X, Y) :- subsumes_term(X, Y), subsumes_term(Y, X). Here some testing, does it work ok? Take this code: enum_arg(_, 1). enum_arg(_, _). enum_arg(X, X). enum_list(_, []). enum_list(X, [H|T]) :- enum_arg(X, H), enum_list(X, T). boole(G, 1) :- G, !. boole(_, 0). nok(L, R) :- length(L, 6), length(R, 6), enum_list(_, L), enum_list(_, R), boole(variant(L, R), A), boole(variant_term(L, R), B), A \== B. Seems to work fine: ?- nok(L, R). false.