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

    From Julio Di Egidio@julio@diegidio.name to comp.lang.prolog on Sun Jul 20 16:15:25 2025
    From Newsgroup: comp.lang.prolog

    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
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Julio Di Egidio@julio@diegidio.name to comp.lang.prolog on Sun Jul 20 16:22:47 2025
    From Newsgroup: comp.lang.prolog

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 17:26:16 2025
    From Newsgroup: comp.lang.prolog

    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


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 17:27:30 2025
    From Newsgroup: comp.lang.prolog


    % 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



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 17:36:13 2025
    From Newsgroup: comp.lang.prolog


    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




    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 18:14:26 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    The Stargate Project is a new company which intends
    to invest $500 billion over the next four years
    building new AI infrastructure for OpenAI in
    the United States. SoftBank having financial
    responsibility and OpenAI having operational
    responsibility. Masayoshi Son will be the chairman.

    https://openai.com/index/announcing-the-stargate-project/

    What a shame no, solution from USA or Japan
    for decades? Ok, maybe my solution doesn't work
    either. Don't know yet, so far I am using

    my intuition. Which tells me if a polish
    prefix is equivalent then the corresponding
    subterm is equivalent. And where the polish

    prefix diagrees for the first time, one
    has found a conflict which is anyways the
    typical f/n versus g/n conflict, or otherwise

    different arguments used, in this case the algorithm
    will make a choice based on the primtitives and
    the '$VAR'/1 in the compounds. But for acyclic

    terms the '$VAR'/1 values are kind of normed,
    and their appearance indicates a non-primitive.

    Bye

    Mild Shock schrieb:

    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





    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 18:28:39 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    Seems I posted the wrong code, I posted
    some code that is used for printing, which has
    different requirements. Well you can figure out

    the correct code by yourself.

    LoL

    Bye

    Mild Shock schrieb:
    Hi,

    The Stargate Project is a new company which intends
    to invest $500 billion over the next four years
    building new AI infrastructure for OpenAI in
    the United States. SoftBank having financial
    responsibility and OpenAI having operational
    responsibility. Masayoshi Son will be the chairman.

    https://openai.com/index/announcing-the-stargate-project/

    What a shame no, solution from USA or Japan
    for decades? Ok, maybe my solution doesn't work
    either. Don't know yet, so far I am using

    my intuition. Which tells me if a polish
    prefix is equivalent then the corresponding
    subterm is equivalent. And where the polish

    prefix diagrees for the first time, one
    has found a conflict which is anyways the
    typical f/n versus g/n conflict, or otherwise

    different arguments used, in this case the algorithm
    will make a choice based on the primtitives and
    the '$VAR'/1 in the compounds. But for acyclic

    terms the '$VAR'/1 values are kind of normed,
    and their appearance indicates a non-primitive.

    Bye

    Mild Shock schrieb:

    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






    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 19:03:58 2025
    From Newsgroup: comp.lang.prolog

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Julio Di Egidio@julio@diegidio.name to comp.lang.prolog on Sun Jul 20 19:15:25 2025
    From Newsgroup: comp.lang.prolog

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 19:46:14 2025
    From Newsgroup: comp.lang.prolog


    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


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 19:47:10 2025
    From Newsgroup: comp.lang.prolog

    From Dogelog Player:

    % bisim_equals(+Term, +Term)
    bisim_equals(X, Y) :-
    sys_bisim_equals(X, Y, []).

    % sys_bisim_equals(+Term, +Term, +List)
    sys_bisim_equals(X, Y, _) :- primitive(X), !, X == Y.
    sys_bisim_equals(X, Y, _) :- primitive(Y), !, X == Y.
    sys_bisim_equals(X, Y, S) :-
    member(Z-T, S),
    ir_object_equals(X, Z),
    ir_object_equals(Y, T), !.
    sys_bisim_equals(X, Y, _) :-
    functor(X, F, N),
    functor(Y, G, M),
    F/N \== G/M, !, fail.
    sys_bisim_equals(X, Y, S) :-
    X =.. [_|L],
    Y =.. [_|R],
    sys_bisim_equals_list(L, R, [X-Y|S]).

    % sys_bisim_equals_list(+List, +List, +List)
    sys_bisim_equals_list([], [], _).
    sys_bisim_equals_list([X|L], [Y|R], S) :-
    sys_bisim_equals(X, Y, S),
    sys_bisim_equals_list(L, R, S).

    Mild Shock schrieb:

    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



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 19:50:16 2025
    From Newsgroup: comp.lang.prolog

    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


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 19:55:11 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    bisim_equals/2 is just bisimulation. You can
    also implement bisim_unify/2, extremly trivial as well.

    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.

    Bye

    From Dogelog Player, unification that can do cyclic
    terms, also extremly trivial:

    % bisim_unify(+Term, +Term)
    bisim_unify(X, Y) :-
    sys_bisim_unify(X, Y, []).

    % sys_bisim_unify(+Term, +Term, +List)
    sys_bisim_unify(X, Y, _) :- primitive(X), !, X = Y.
    sys_bisim_unify(X, Y, _) :- primitive(Y), !, X = Y.
    sys_bisim_unify(X, Y, S) :-
    member(Z-T, S),
    ir_object_equals(X, Z),
    ir_object_equals(Y, T), !.
    sys_bisim_unify(X, Y, _) :-
    functor(X, F, N),
    functor(Y, G, M),
    F/N \== G/M, !, fail.
    sys_bisim_unify(X, Y, S) :-
    X =.. [_|L],
    Y =.. [_|R],
    sys_bisim_unify_list(L, R, [X-Y|S]).

    % sys_bisim_unify_list(+List, +List, +List)
    sys_bisim_unify_list([], [], _).
    sys_bisim_unify_list([X|L], [Y|R], S) :-
    sys_bisim_unify(X, Y, S),
    sys_bisim_unify_list(L, R, S).

    Mild Shock schrieb:
    From Dogelog Player:

    % bisim_equals(+Term, +Term)
    bisim_equals(X, Y) :-
       sys_bisim_equals(X, Y, []).

    % sys_bisim_equals(+Term, +Term, +List)
    sys_bisim_equals(X, Y, _) :- primitive(X), !, X == Y.
    sys_bisim_equals(X, Y, _) :- primitive(Y), !, X == Y.
    sys_bisim_equals(X, Y, S) :-
       member(Z-T, S),
       ir_object_equals(X, Z),
       ir_object_equals(Y, T), !.
    sys_bisim_equals(X, Y, _) :-
       functor(X, F, N),
       functor(Y, G, M),
       F/N \== G/M, !, fail.
    sys_bisim_equals(X, Y, S) :-
       X =.. [_|L],
       Y =.. [_|R],
       sys_bisim_equals_list(L, R, [X-Y|S]).

    % sys_bisim_equals_list(+List, +List, +List)
    sys_bisim_equals_list([], [], _).
    sys_bisim_equals_list([X|L], [Y|R], S) :-
       sys_bisim_equals(X, Y, S),
       sys_bisim_equals_list(L, R, S).

    Mild Shock schrieb:

    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




    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Julio Di Egidio@julio@diegidio.name to comp.lang.prolog on Sun Jul 20 20:24:55 2025
    From Newsgroup: comp.lang.prolog

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Sun Jul 20 23:14:01 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    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 on

    This normalization can be done quite trivially with
    bisimulation. Like getting X = f(g(X)), or X = f(X)
    as a normalization solution.

    But bisimulation and or normalization, doesn't give you
    compare/3, which is the subject of "On the order of
    cyclic terms", SWI Prolog discourse is full of failed

    attempts, the most hilarious you find here:

    History dependent semi_lex_compare/3 https://swi-prolog.discourse.group/t/history-dependent-semi-lex-compare-3/6431

    I do not object at explorative prototyping.
    It only confirms what I am saying.

    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.

    The main problem is some lack of insight why
    something fails, and the same lack to proceed
    from that proactively to create something

    better. Most stuff you find is extremly
    reactive, without some learning, without
    some incremental progress, and recently

    new posts that show a complete lack of learning,
    even fail for the same old examples from 2023.
    Its just complete cringe.

    Julio Di Egidio schrieb:
    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


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Julio Di Egidio@julio@diegidio.name to comp.lang.prolog on Mon Jul 21 05:39:52 2025
    From Newsgroup: comp.lang.prolog

    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

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Mon Jul 21 10:35:55 2025
    From Newsgroup: comp.lang.prolog

    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


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Mon Jul 21 10:52:13 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    Alain Colmerauer mentions the non-monster
    instruction form here:

    "By introducing intermediate variables
    so that every term contains no more than
    one functional symbol the check for a
    greatest term is no longer necessary."
    - page 236

    But his haluctination of greatest term,
    to archive I guess some normal form,
    formalized for monster instructions,
    as here in his rule:

    "CONFRONTATION (CO): If x is a variable
    and t1,t2 are not variables and |ti| < |t2|
    then replace {x=t1,x=t2} by x=t1,t1=t2.
    By |t| we denote the size oft, i.e. the number
    of occurrences of elements of FuV."
    - page 235

    But using a greatest term is not necessary
    for non-monster approach, as observed by
    Alain Colmerauer himself in page 236 after

    page 235, but in my opion this can be also
    lifted to monster instructions, where the
    equatsions are V=T, where T is not
    restricted to a single function symbol.

    I think Ciao Prolog uncycle_term/2 has
    nowhere a term size comparision and is living
    proof of my claim, that his rules are nonsense.
    So mostlikely the term size has a totally

    different purpose, showing the termination
    of some bisimulation. But showing termination of
    some bisimulation is easier with memory
    adresses, since memory adresses are trivially

    finite in their number, a finite set, whereas new
    equation are infinitely many, an infinite set, that
    could be produced, when one is not careful.

    Bye

    Mild Shock schrieb:
    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



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Mon Jul 21 10:59:18 2025
    From Newsgroup: comp.lang.prolog

    Hi,

    Just compare the top-level of Ciao Prolog:

    /* Ciao Prolog */
    ?- p(X,Y).
    X = f(X),
    Y = f(X) ? ;

    X = a(f(X,b(g(X,Y)))),
    Y = b(g(a(f(X,Y)),Y)) ? ;

    X = s(s(X,s(Y,X)),_A),
    Y = s(Y,s(s(X,Y),_A)) ? ;

    https://ciao-lang.org/playground/

    With Dogelog Player:

    ?- p(X,Y).
    X = f(f(f(X))), Y = f(f(Y));
    X = a(f(X, Y)), Y = b(g(X, Y));
    X = s(s(X, Y), _), Y = s(Y, X).

    https://www.dogelog.ch/littab/doclet/live/07_basic/example01/package.html

    So I guess I a found some Gold!

    LoL

    Bye

    P.S.: I nowhere use term size, also I don't
    use non-monster instructions permanently.

    The test cases are:

    p(X,Y) :- X = f(f(f(X))), Y = f(f(Y)).
    p(X,Y) :- X = a(f(X,Y)), Y = b(g(X,Y)).
    p(X,Y) :- X = s(s(X,Y),_), Y = s(Y,X).

    Mild Shock schrieb:
    Hi,

    Alain Colmerauer mentions the non-monster
    instruction form here:

    "By introducing intermediate variables
    so that every term contains no more than
    one functional symbol the check for a
    greatest term is no longer necessary."
    - page 236

    But his haluctination of greatest term,
    to archive I guess some normal form,
    formalized for monster instructions,
    as here in his rule:

    "CONFRONTATION (CO): If x is a variable
    and t1,t2 are not variables and |ti| < |t2|
    then replace {x=t1,x=t2} by x=t1,t1=t2.
    By |t| we denote the size oft, i.e. the number
    of occurrences of elements of FuV."
    - page 235

    But using a greatest term is not necessary
    for non-monster approach, as observed by
    Alain Colmerauer himself in page 236 after

    page 235, but in my opion this can be also
    lifted to monster instructions, where the
    equatsions are V=T, where T is not
    restricted to a single function symbol.

    I think Ciao Prolog uncycle_term/2 has
    nowhere a term size comparision and is living
    proof of my claim, that his rules are nonsense.
    So mostlikely the term size has a totally

    different purpose, showing the termination
    of some bisimulation. But showing termination of
    some bisimulation is easier with memory
    adresses, since memory adresses are trivially

    finite in their number, a finite set, whereas new
    equation are infinitely many, an infinite set, that
    could be produced, when one is not careful.

    Bye

    Mild Shock schrieb:
    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




    --- Synchronet 3.21a-Linux NewsLink 1.2