Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.prolog > #14965

Credits to Hiord: A Type-Free Higher-Order (2004) (Was: AOT Compiled Inner if-then-else)

From Mild Shock <janburse@fastmail.fm>
Newsgroups comp.lang.prolog
Subject Credits to Hiord: A Type-Free Higher-Order (2004) (Was: AOT Compiled Inner if-then-else)
Date 2025-11-05 21:19 +0100
Message-ID <10egbfl$14lsj$1@solani.org> (permalink)
References <107cdlv$3ok9q$1@solani.org> <10eg874$14jvm$1@solani.org>

Show all headers | View raw


Hi,

Credits go to myself (an old Stackoverflow
post of mine from 2020):

The algorithm "A" according to Antoni Diller looks fairly simple:
https://stackoverflow.com/questions/65066544/bracket-abstraction-in-prolog

The OrReference aka Anonymous Predicate is just another variant
of combinatorial logic. You can view OrReference having the same
logtical status as a closed SKI expression.

Plus to this guys here also already in 2004:

Hiord: A Type-Free Higher-Order Logic Programming
Language with Predicate Abstraction
Daniel Cabeza, Manuel V. Hermenegildo, Manuel V. Hermenegildo
https://www.researchgate.net/publication/221052995

Only they botched it, since recursion and mutual recursion
needs still some fixpoint operator construction. But
the Anonymous Predicate thingy is beautiful, without

any fixpoint operator construction needed:

test(Even) :-
    Even = ((X) => Y^(X = n; X = s(Y), call(Odd, Y))),
    Odd = ((X) => Y^(X = s(Y), call(Even, Y))).

?- listing(test).
test(A) :-
    A = 0rReference(B),
    B = 0rReference(A).

Basically evaluating a rational tree closure:

?- test(_X), call(_X, s(s(s(s(n))))).
true.

?- test(_X), call(_X, s(s(s(s(s(n)))))).
fail.

?- test(_X), call(_X, s(s(s(s(s(s(n))))))).
true.

Bye

Mild Shock schrieb:
> Hi,
> 
> Now that we managed to conceive nested arrow
> functions, next step on the menu is inner if-then-else
> or disjunction, like inside a findall/3 or inside
> 
> (\+)/1, doing ahead of time compilation (AOT).
> That it leads to problems of rational trees was
> more a psyop easter egg of mine. Although I am not
> 
> yet sure, in the long run the compiler should
> be able to handle rational trees, like copy_term/2
> can handle them. But before tackling inner
> 
> if-then-else, first check the occurence frequency
> of then. Do they happen often? Is it worth AOT-ing
> them. Then also before tackling inner if-then-else,
> 
> does the code use (,)/2, (;)/2 or (->)/2 in
> scenarios where it is used for meta programming
> i.e. _,_, _;_ or _->_ pattern for deconstruction
> 
> or construction. And do these cases fall into
> the new arrow viability check adopte to a if-then-else
> viability check, or fall they through?
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Functional requirement:
>>
>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>     L == [C,D].
>>
>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>     L == [A,B,C,D].
>>
>> Non-Functional requirement:
>>
>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>> true.
>>
>> Can your Prolog system do that?
>>
>> P.S.: Benchmark was:
>>
>> singletons(N) :-
>>     hydra2(N,Y),
>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>
>> hydra2(0, _) :- !.
>> hydra2(N, s(X,X)) :-
>>     M is N-1,
>>     hydra2(M, X).
>>
>> Bye
> 

Back to comp.lang.prolog | Previous | NextPrevious in thread | Find similar


Thread

VIP0909: VibeCore Improvement Proposal [term_singletons] Mild Shock <janburse@fastmail.fm> - 2025-08-11 11:38 +0200
  Dushnik–Miller theorem [1940] (Was: VIP0909: VibeCore Improvement Proposal [term_singletons]) Mild Shock <janburse@fastmail.fm> - 2025-08-11 14:31 +0200
    Moore-Naish Algorithm in Prolog (Was: Dushnik–Miller theorem [1940]) Mild Shock <janburse@fastmail.fm> - 2025-08-11 14:44 +0200
      Who was Seiiti Huzita (1958) ? (Was: Moore-Naish Algorithm in Prolog) Mild Shock <janburse@fastmail.fm> - 2025-08-11 14:50 +0200
  What are the constraints of program sharing (Was: Cheap hybrid binary algorithms) Mild Shock <janburse@fastmail.fm> - 2025-09-27 19:34 +0200
  VIP0909: VibeCore Improvement Proposal [Jaffar's Algorithm] Mild Shock <janburse@fastmail.fm> - 2025-09-27 19:26 +0200
    Cheap hybrid binary algorithms (Was: VIP0909: VibeCore Improvement Proposal [Jaffar's Algorithm]) Mild Shock <janburse@fastmail.fm> - 2025-09-27 19:28 +0200
  VIP4711: Variadic Predicates and Array Patterns (Was: VIP0909: VibeCore Improvement Proposal [term_singletons]) Mild Shock <janburse@fastmail.fm> - 2025-10-27 14:40 +0100
    The C# Span and new code instructions (Was: VIP4711: Variadic Predicates and Array Patterns) Mild Shock <janburse@fastmail.fm> - 2025-10-27 14:57 +0100
      Superintelligence or community? [The Almend Paradox] (Re: The C# Span and new code instructions) Mild Shock <janburse@fastmail.fm> - 2025-10-27 15:16 +0100
        No more Almend Paradox [China has enough] (Was: Superintelligence or community? [The Almend Paradox]) Mild Shock <janburse@fastmail.fm> - 2025-10-28 13:54 +0100
        No more Almend Paradox [China has enough] (Was: Superintelligence or community? [The Almend Paradox]) Mild Shock <janburse@fastmail.fm> - 2025-10-28 13:57 +0100
          Communities betrayed by GitHub [The Matrix is booting] (Was: No more Almend Paradox [China has enough]) Mild Shock <janburse@fastmail.fm> - 2025-10-28 21:06 +0100
  Dogzilla: Arrow Functions can be Super Dicts (Was: VIP0909: VibeCore Improvement Proposal [term_singletons]) Mild Shock <janburse@fastmail.fm> - 2025-11-02 15:50 +0100
    Dogzilla: Compilation gives First Argument Indexing (Was: Dogzilla: Arrow Functions can be Super Dicts) Mild Shock <janburse@fastmail.fm> - 2025-11-02 15:58 +0100
      Dogzilla: History of Dicts in Theorem Provers (Was: Dogzilla: Compilation gives First Argument Indexing) Mild Shock <janburse@fastmail.fm> - 2025-11-02 16:28 +0100
      Dogzilla: From Bryan Ford to Lars Hupel (Compilation gives First Argument Indexing) Mild Shock <janburse@fastmail.fm> - 2025-11-02 16:41 +0100
        Dogzilla: Set-Like via Clark Completion (Was: Dogzilla: From Bryan Ford to Lars Hupel) Mild Shock <janburse@fastmail.fm> - 2025-11-02 19:47 +0100
  AOT Compiled Inner if-then-else (Was: VIP0909: VibeCore Improvement Proposal [term_singletons]) Mild Shock <janburse@fastmail.fm> - 2025-11-05 20:23 +0100
    Credits to Hiord: A Type-Free Higher-Order (2004) (Was: AOT Compiled Inner if-then-else) Mild Shock <janburse@fastmail.fm> - 2025-11-05 21:19 +0100

csiph-web