• On the order of cyclic terms (Was: Mild Block(s))

    From Julio Di Egidio@21:1/5 to Mild Shock on Sun Jul 20 16:15:25 2025
    On 20/07/2025 15:13, Mild Shock wrote:

    Let (H, <) be the standard total oder an the
    Prolog finite terms. Let R be the set of rational
    term. H c R. Then there is total order
    extention (R, <') of (H, <).

    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural". Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julio Di Egidio@21:1/5 to Julio Di Egidio on Sun Jul 20 16:22:47 2025
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

      > Let (H, <) be the standard total oder an the
      > Prolog finite terms. Let R be the set of rational
      > term. H c R. Then there is total order
      > extention (R, <') of (H, <).

    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S. I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Julio Di Egidio on Sun Jul 20 17:26:16 2025
    Strange this little Prolog code snippet,
    that creates a polish notation with sharing
    out of a Prolog term, either acyclic or cyclic,
    works for me to compare terms (that do not contain ‘$VAR’/1):

    polish(X, L, T) :-
    sys_polish_term(X, [], H, T),
    sys_strip_reverse(H, [], L).

    Here the test cases from the top-level ticket:

    ?- p(X,Y), polish(p(X,Y),L,T).
    L = [A=p(B, B), B=f(B)],
    L = [A=p(B, D), B=a(C), C=f(B, D), D=b(E), E=g(B, D)],
    L = [A=p(B, D), B=s(C, _A), C=s(B, D), D=s(D, B)],

    The description “Polish” refers to the nationality
    of logician Jan Łukasiewicz who invented Polish notation
    in 1924. In the above I am more doing what is called

    reverse polish notation, known from pocket calculators
    such as HP-41C, the perfect toy for, boring math classes
    during school. You can imagine the sharing happens

    by pressing the memory store and recall keys of a HP-41C.

    Defining a comparison as:

    compare2(C,X,Y) :- polish(X,L,T), polish(Y,R,S),
    compare(C,L-T,R-S).

    Has the following properties:

    - It is conservative:
    For acyclic terms compare2/3 and compare/3 agree.

    - It is a total order:
    Because compare2/3 falls back to compare/3, and polish
    is injective versus (==)/2, it has all desired properties.

    https://www.hpmuseum.org/hp41.htm

    Julio Di Egidio schrieb:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    -Julio


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Mild Shock on Sun Jul 20 17:27:30 2025
    % polish(+Term, -List, -Term)
    polish(X, L, T) :-
    sys_polish_term(X, [], H, T),
    sys_strip_reverse(H, [], L).

    % sys_polish_term(+Term, +List, -List, -Term)
    sys_polish_term(T, L, L, T) :- (var(T); atomic(T)), !.
    sys_polish_term(T, L, L, V) :-
    member(v(S,V,_), L),
    S == T, !.
    sys_polish_term(T, L, R, V) :-
    length(L, N),
    V = '$VAR'(N),
    T =.. [F|P],
    sys_polish_terms(P, [v(T,V,S)|L], R, Q),
    S =.. [F|Q].

    % sys_polish_terms(+List, +List, -List, -List)
    sys_polish_terms([], L, L, []).
    sys_polish_terms([X|P], L, R, [Y|Q]) :-
    sys_polish_term(X, L, H, Y),
    sys_polish_terms(P, H, R, Q).

    % sys_strip_reverse(+List, +List, -List)
    sys_strip_reverse([], L, L).
    sys_strip_reverse([v(_,V,T)|L], R, S) :-
    sys_strip_reverse(L, [V=T|R], S).

    Mild Shock schrieb:
    Strange this little Prolog code snippet,
    that creates a polish notation with sharing
    out of a Prolog term, either acyclic or cyclic,
    works for me to compare terms (that do not contain ‘$VAR’/1):

    polish(X, L, T) :-
       sys_polish_term(X, [], H, T),
       sys_strip_reverse(H, [], L).

    Here the test cases from the top-level ticket:

    ?- p(X,Y), polish(p(X,Y),L,T).
    L = [A=p(B, B), B=f(B)],
    L = [A=p(B, D), B=a(C), C=f(B, D), D=b(E), E=g(B, D)],
    L = [A=p(B, D), B=s(C, _A), C=s(B, D), D=s(D, B)],

    The description “Polish” refers to the nationality
    of logician Jan Łukasiewicz who invented Polish notation
    in 1924. In the above I am more doing what is called

    reverse polish notation, known from pocket calculators
    such as HP-41C, the perfect toy for, boring math classes
    during school. You can imagine the sharing happens

    by pressing the memory store and recall keys of a HP-41C.

    Defining a comparison as:

    compare2(C,X,Y) :- polish(X,L,T), polish(Y,R,S),
       compare(C,L-T,R-S).

    Has the following properties:

    - It is conservative:
      For acyclic terms compare2/3 and compare/3 agree.

    - It is a total order:
      Because compare2/3 falls back to compare/3, and polish
      is injective versus (==)/2, it has all desired properties.

    https://www.hpmuseum.org/hp41.htm

    Julio Di Egidio schrieb:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    -Julio



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Mild Shock on Sun Jul 20 17:36:13 2025
    BTW: Its essentially the same code like
    here from 2023, a little “polished”:

    Cheap compare for cyclic terms [injective collation keys] https://swi-prolog.discourse.group/t/cheap-compare-for-cyclic-terms-injective-collation-keys/6427

    But I have removed my old file rep2.p,
    since I wanted a more didactic presentation.

    Mild Shock schrieb:

    % polish(+Term, -List, -Term)
    polish(X, L, T) :-
       sys_polish_term(X, [], H, T),
       sys_strip_reverse(H, [], L).

    % sys_polish_term(+Term, +List, -List, -Term)
    sys_polish_term(T, L, L, T) :- (var(T); atomic(T)), !.
    sys_polish_term(T, L, L, V) :-
       member(v(S,V,_), L),
       S == T, !.
    sys_polish_term(T, L, R, V) :-
       length(L, N),
       V = '$VAR'(N),
       T =.. [F|P],
       sys_polish_terms(P, [v(T,V,S)|L], R, Q),
       S =.. [F|Q].

    % sys_polish_terms(+List, +List, -List, -List)
    sys_polish_terms([], L, L, []).
    sys_polish_terms([X|P], L, R, [Y|Q]) :-
       sys_polish_term(X, L, H, Y),
       sys_polish_terms(P, H, R, Q).

    % sys_strip_reverse(+List, +List, -List)
    sys_strip_reverse([], L, L).
    sys_strip_reverse([v(_,V,T)|L], R, S) :-
       sys_strip_reverse(L, [V=T|R], S).

    Mild Shock schrieb:
    Strange this little Prolog code snippet,
    that creates a polish notation with sharing
    out of a Prolog term, either acyclic or cyclic,
    works for me to compare terms (that do not contain ‘$VAR’/1):

    polish(X, L, T) :-
        sys_polish_term(X, [], H, T),
        sys_strip_reverse(H, [], L).

    Here the test cases from the top-level ticket:

    ?- p(X,Y), polish(p(X,Y),L,T).
    L = [A=p(B, B), B=f(B)],
    L = [A=p(B, D), B=a(C), C=f(B, D), D=b(E), E=g(B, D)],
    L = [A=p(B, D), B=s(C, _A), C=s(B, D), D=s(D, B)],

    The description “Polish” refers to the nationality
    of logician Jan Łukasiewicz who invented Polish notation
    in 1924. In the above I am more doing what is called

    reverse polish notation, known from pocket calculators
    such as HP-41C, the perfect toy for, boring math classes
    during school. You can imagine the sharing happens

    by pressing the memory store and recall keys of a HP-41C.

    Defining a comparison as:

    compare2(C,X,Y) :- polish(X,L,T), polish(Y,R,S),
        compare(C,L-T,R-S).

    Has the following properties:

    - It is conservative:
       For acyclic terms compare2/3 and compare/3 agree.

    - It is a total order:
       Because compare2/3 falls back to compare/3, and polish
       is injective versus (==)/2, it has all desired properties.

    https://www.hpmuseum.org/hp41.htm

    Julio Di Egidio schrieb:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    -Julio




    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Julio Di Egidio on Sun Jul 20 19:03:58 2025
    Hi,

    Reverse Polish Notation has nice Stack Machine Proofs.
    You could finally show some muscles, and use Coq or
    Rocq for a good deed. I suspect there is the following

    lemma now, for a Reverse Polish Notation string:

    Let P1 and P2 be two strings:

    P1 = Prefix1 Suffix1
    P2 = Prefix2 Suffix2

    If Prefix1 = Prefix2 then the evaluation P1 up
    respectively P2 to the length |Prefix1| = |Prefix2|
    has a stack result of the form:

    [Value1, .., Valuen]

    With identical values for both P1 and P2. Question is
    iwhat happens with the first instruction of Suffix1
    respectively Suffix2, can we use it for compare/3.

    I have now changed what I originally wrote to:

    - Open question whether it is conservative:
    I have mixed feelings whether it is conservative,
    i.e. whether compare2/3 and compare/3 agree on acyclic terms.

    Mostlikely not. You can mittigate the problem, by
    creating monster instructions inside the P1 and P2.
    And then I guess the above proposition holds.

    I am currently creating monster instructions during
    printing, but was completely busy with printing, didn't
    really look yet into comparison and especially having

    a cheap way of conservativity.

    Bye

    Julio Di Egidio schrieb:
    On 20/07/2025 15:13, Mild Shock wrote:

      > Let (H, <) be the standard total oder an the
      > Prolog finite terms. Let R be the set of rational
      > term. H c R. Then there is total order
      > extention (R, <') of (H, <).

    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Julio Di Egidio on Sun Jul 20 19:46:14 2025
    compare/2 doesn't cover only (==)/2.
    It also covers (@<)/2 and (@>)/2.

    Julio Di Egidio schrieb:
    On 20/07/2025 16:22, Julio Di Egidio wrote:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    Normalise this: `X = f(g(f(g(X))`

    Or, even simpler: `X = f(f(X))`

    (I don't think it gets essentially more complicated
    than that: I might be wrong, but AFAICT, we can only
    construct (rooted) terms with nested cycles...)

    -Julio


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julio Di Egidio@21:1/5 to Julio Di Egidio on Sun Jul 20 19:15:25 2025
    On 20/07/2025 16:22, Julio Di Egidio wrote:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    Normalise this: `X = f(g(f(g(X))`

    Or, even simpler: `X = f(f(X))`

    (I don't think it gets essentially more complicated
    than that: I might be wrong, but AFAICT, we can only
    construct (rooted) terms with nested cycles...)

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Mild Shock on Sun Jul 20 19:50:16 2025
    Hi,

    You find the idea of Monster and Non-Monster
    instructions already in Clocksins paper about
    the instruction stream for Prolog-X, usually
    called ZIP which is also the basis for SWI-Prolog:

    Design and Simulation of a Sequential Prolog Machine
    D.L. Bowen, L.H. Byrd, W. F. Clocksin - 1983 https://www.softwarepreservation.org/projects/prolog/lisbon/lpw83/p74-Bowen.pdf

    He simultates the ZIP instructions itself, and
    shows a little meta Interpreter for ZIP. The
    non-monster instruction to create a compound
    reads as follows:

    execute([functor, X|PC], XR, Vars, Cont, [Arg | Arest], Astack) :-!,
    arg(X, XR, Fatom/Farity), % Get functor from XR table
    functor(Arg, Faton, Farity), % Match principal functors
    Arg ..= [Fatom|Args], % Get Args of Arg term
    execute(PC, XR, Vars, Cont, Args, [Arest | Astack]).

    His code is so clever, and makes use of the
    bidirectionality of (=..)/2 that the above
    executor works for read and write mode
    of a clause head stream, i.e. all modes
    are supported.

    If you make a representation with indexes
    and monster instructions, that build more
    than only one compound, you can make a
    conservative and total compare/3.

    Bye

    Mild Shock schrieb:
    Hi,

    Reverse Polish Notation has nice Stack Machine Proofs.
    You could finally show some muscles, and use Coq or
    Rocq for a good deed. I suspect there is the following

    lemma now, for a Reverse Polish Notation string:

    Let P1 and P2 be two strings:

    P1 =  Prefix1 Suffix1
    P2 =  Prefix2 Suffix2

    If Prefix1 = Prefix2 then the evaluation P1 up
    respectively P2 to the length |Prefix1| = |Prefix2|
    has a stack result of the form:

    [Value1, .., Valuen]

    With identical values for both P1 and P2. Question is
    iwhat happens with the first instruction of Suffix1
    respectively Suffix2, can we use it for compare/3.

    I have now changed what I originally wrote to:

    - Open question whether it is conservative:
      I have mixed feelings whether it is conservative,
      i.e. whether compare2/3 and compare/3 agree on acyclic terms.

    Mostlikely not. You can mittigate the problem, by
    creating monster instructions inside the P1 and P2.
    And then I guess the above proposition holds.

    I am currently creating monster instructions during
    printing, but was completely busy with printing, didn't
    really look yet into comparison and especially having

    a cheap way of conservativity.

    Bye

    Julio Di Egidio schrieb:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    -Julio


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julio Di Egidio@21:1/5 to Mild Shock on Sun Jul 20 20:24:55 2025
    On 20/07/2025 19:46, Mild Shock wrote:

    compare/2 doesn't cover only (==)/2.
    It also covers (@<)/2 and (@>)/2.

    Which must be the reason you keep posting code,
    and inscrutable one at that, on bisimulation...
    you complete asshole.

    But all attempts to translate the idea to
    compare_with_stack/3 have failed so far. SWI
    Prolog discourse is full of failed attempts,
    and missing insights as well, why it fails.

    Don't underestimate your own contribution...

    *Plonk*

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julio Di Egidio@21:1/5 to Julio Di Egidio on Mon Jul 21 05:39:52 2025
    On 20/07/2025 19:15, Julio Di Egidio wrote:
    On 20/07/2025 16:22, Julio Di Egidio wrote:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    Normalise this: `X = f(g(f(g(X))`

    Or, even simpler: `X = f(f(X))`

    (I don't think it gets essentially more complicated
    than that: I might be wrong, but AFAICT, we can only
    construct (rooted) terms with nested cycles...)

    But we are in luck, here is the whole theory:

    Prolog and Infinite Trees - A Colmerauer (1982): <https://www.softwarepreservation.org/projects/prolog/marseille/doc/Colmerauer-InfTree-1982.pdf/view>

    For bonus points, there is even an open problem
    that looks like the perfect job for Coq/Rocq...

    Have fun,

    -Julio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mild Shock@21:1/5 to Julio Di Egidio on Mon Jul 21 10:35:55 2025
    Hi,

    Colmerauer 1982 writes:
    The objective of this paper is to describe a
    novel theoretical model of Prolog involving
    infinite trees. This model corresponds to the
    Prolog interpreters which do not perform the
    "occur check". However, the unification
    algorithm for these interpreters must be
    modified so as to assure termination. The
    best way to achieve this termination is an open
    problem which is not discussed here.

    "open" problem of that time. The Epoch/Community
    change was from Graph Theory / Algorithms to
    Concurrency / Process Theory. Bisimulation

    is again a word not used by Colmerauer 1982, as
    it was a word not used by Aho, Garey &
    Ullman - 1972. But trivially unification (=)/2

    for rational trees is a bisimulation problem,
    the same way like syntactic equality (==)/2
    for rational trees is a bisimulation problem.

    But where does the compare/3 problem come from?
    Well move fast forward to 1995 when the ISO
    core standard was published which required

    compare/3, sort/2, etc.. etc.. without
    specfying a reference algorithm for compare/3
    on rational trees. And so where the gates

    of hell opened. Since then some exorcism
    has to be applied to solutions like compare_with_stack/3,
    that use bisimulation , but that do not work.

    An unlearning has to be done: Hey (=)/2
    and (==)/2 can be related to bisimulation,
    but my skull has to digest that compare/3

    cannot be implemented the same way.

    Bye

    Julio Di Egidio schrieb:
    On 20/07/2025 19:15, Julio Di Egidio wrote:
    On 20/07/2025 16:22, Julio Di Egidio wrote:
    On 20/07/2025 16:15, Julio Di Egidio wrote:
    On 20/07/2025 15:13, Mild Shock wrote:

    ;  > Let (H, <) be the standard total oder an the
    ;  > Prolog finite terms. Let R be the set of rational
    ;  > term. H c R. Then there is total order
    ;  > extention (R, <') of (H, <).
    ;
    Is the problem of a compare/3 for rational trees,
    that is a extension of the compare/3 for finite aka
    acyclic terms with the submodel property.

    Your "discourse" implicitly assumes that the
    "extension" is somewhat "trivial" and/or
    "natural".  Which, in turn, I'd think is the
    case (can be done) only if we can *effectively*
    (and, ideally, somewhat "naturally") define
    *canonical form* then *normalization* of
    (Prolog's) cyclic terms...

    P.S.  I have not actually investigated this, but
    if "normalization" is not a problem, then I do not
    see what the problem is...

    Normalise this: `X = f(g(f(g(X))`

    Or, even simpler: `X = f(f(X))`

    (I don't think it gets essentially more complicated
    than that: I might be wrong, but AFAICT, we can only
    construct (rooted) terms with nested cycles...)

    But we are in luck, here is the whole theory:

    Prolog and Infinite Trees - A Colmerauer (1982): <https://www.softwarepreservation.org/projects/prolog/marseille/doc/Colmerauer-InfTree-1982.pdf/view>


    For bonus points, there is even an open problem
    that looks like the perfect job for Coq/Rocq...

    Have fun,

    -Julio


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)