• The Missing Link in Picat: Mercury States

    From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Tue Oct 3 08:33:18 2023
    From Newsgroup: comp.lang.prolog

    Would it be possibly to make a Picat that has more syntactic
    sugar. Like for example today I write:

    foo(X, R, Y, S) =>
    (X := X+1; Y := Y+1), R = X, S = Y.

    What if I could write:

    foo(!X, !Y) =>
    (X := X+1; Y := Y+1).

    Similar something for predicate goal invokation, including
    some query processing along the following lines:

    ?- X = 0, Y = 0, foo(!X, !Y).
    X = 1, Y = 0;
    X = 0, Y = 1.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Wed Oct 4 08:09:24 2023
    From Newsgroup: comp.lang.prolog

    The sum_list example that I made had an evaluable function which is
    predicate defined. But the foo/2 example with X := X+1 and Y := Y+1
    doesn’t use some predicate defined evaluable function.
    One has to check with the Picat Manual. It has a section 1.3 Defining Functions,
    But this was never my point, to introduce this feature of Picat. Because
    you don’t need it to translate X := X+1. It is tempting to translate it into: +(!.X, 1, !:X)
    But you can also translate X := X+1 into, in terms of Mercury state variables: !:X is !.X+1
    Basically in Picat, every variable is already automatically a state
    variable. There are papers of Picat that detail the translation
    used in Picat. Basically Picat translates to BProlog. Example paper: Canonicalizing High-Level Constructs in Picat
    2.4 Assignments and While Loops https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
    The approach is relatively straight forward, every variable is automatically
    a state variable, but its not automatically a pair. It gets a pair during assignment which is described by Neng-Fa Zhou and Jonathan Fruhman: Canonicalizing High-Level Constructs in Picat
    3.5 Transformation of Assignments
    Picat creates a new variable, say X1, to hold the value of X after
    the assignment X := X + 1. […] All occurrences of X after the assignment
    are replaced by X1. […] When encountering X1 := X1 + 2, Picat creates
    another new variable. Etc… https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
    Mild Shock schrieb am Dienstag, 3. Oktober 2023 um 17:33:20 UTC+2:
    Would it be possibly to make a Picat that has more syntactic
    sugar. Like for example today I write:

    foo(X, R, Y, S) =>
    (X := X+1; Y := Y+1), R = X, S = Y.

    What if I could write:

    foo(!X, !Y) =>
    (X := X+1; Y := Y+1).

    Similar something for predicate goal invokation, including
    some query processing along the following lines:

    ?- X = 0, Y = 0, foo(!X, !Y).
    X = 1, Y = 0;
    X = 0, Y = 1.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Wed Oct 4 08:19:55 2023
    From Newsgroup: comp.lang.prolog

    I am already thinking of a name for the new programming language,
    that results from the fusion of Picat and Marcury, basically adding (!)/1
    to Picat. Some ideas: Picachu, Swicat, Candy, what else?
    Mostlikely instead of translating to BProlog or SWI-Prolog, the new
    language can possibly also be translated to Novacore. If the new
    language has some momentum, it could be worth providing such
    a translation layer. Currently Picat alone and also (=>)/2 alone of
    SWI-Prolog is not very attractive. Picachu would go a totally different
    route than Logtalk, instead of adding objects, it adds pseudo imperativity. Mild Shock schrieb am Mittwoch, 4. Oktober 2023 um 17:09:26 UTC+2:
    The sum_list example that I made had an evaluable function which is predicate defined. But the foo/2 example with X := X+1 and Y := Y+1 doesn’t use some predicate defined evaluable function.

    One has to check with the Picat Manual. It has a section 1.3 Defining Functions,
    But this was never my point, to introduce this feature of Picat. Because
    you don’t need it to translate X := X+1. It is tempting to translate it into:

    +(!.X, 1, !:X)

    But you can also translate X := X+1 into, in terms of Mercury state variables:

    !:X is !.X+1

    Basically in Picat, every variable is already automatically a state variable. There are papers of Picat that detail the translation
    used in Picat. Basically Picat translates to BProlog. Example paper:

    Canonicalizing High-Level Constructs in Picat
    2.4 Assignments and While Loops https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf

    The approach is relatively straight forward, every variable is automatically a state variable, but its not automatically a pair. It gets a pair during assignment which is described by Neng-Fa Zhou and Jonathan Fruhman:

    Canonicalizing High-Level Constructs in Picat
    3.5 Transformation of Assignments
    Picat creates a new variable, say X1, to hold the value of X after
    the assignment X := X + 1. […] All occurrences of X after the assignment are replaced by X1. […] When encountering X1 := X1 + 2, Picat creates another new variable. Etc… https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
    Mild Shock schrieb am Dienstag, 3. Oktober 2023 um 17:33:20 UTC+2:
    Would it be possibly to make a Picat that has more syntactic
    sugar. Like for example today I write:

    foo(X, R, Y, S) =>
    (X := X+1; Y := Y+1), R = X, S = Y.

    What if I could write:

    foo(!X, !Y) =>
    (X := X+1; Y := Y+1).

    Similar something for predicate goal invokation, including
    some query processing along the following lines:

    ?- X = 0, Y = 0, foo(!X, !Y).
    X = 1, Y = 0;
    X = 0, Y = 1.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Wed Oct 4 08:37:42 2023
    From Newsgroup: comp.lang.prolog


    You can always tell grandchildren a lie, that its due to Chu-Spaces.
    LoL
    Mild Shock schrieb am Mittwoch, 4. Oktober 2023 um 17:19:57 UTC+2:
    I am already thinking of a name for the new programming language,
    that results from the fusion of Picat and Marcury, basically adding (!)/1
    to Picat. Some ideas: Picachu, Swicat, Candy, what else?

    Mostlikely instead of translating to BProlog or SWI-Prolog, the new
    language can possibly also be translated to Novacore. If the new
    language has some momentum, it could be worth providing such

    a translation layer. Currently Picat alone and also (=>)/2 alone of SWI-Prolog is not very attractive. Picachu would go a totally different route than Logtalk, instead of adding objects, it adds pseudo imperativity. Mild Shock schrieb am Mittwoch, 4. Oktober 2023 um 17:09:26 UTC+2:
    The sum_list example that I made had an evaluable function which is predicate defined. But the foo/2 example with X := X+1 and Y := Y+1 doesn’t use some predicate defined evaluable function.

    One has to check with the Picat Manual. It has a section 1.3 Defining Functions,
    But this was never my point, to introduce this feature of Picat. Because you don’t need it to translate X := X+1. It is tempting to translate it into:

    +(!.X, 1, !:X)

    But you can also translate X := X+1 into, in terms of Mercury state variables:

    !:X is !.X+1

    Basically in Picat, every variable is already automatically a state variable. There are papers of Picat that detail the translation
    used in Picat. Basically Picat translates to BProlog. Example paper:

    Canonicalizing High-Level Constructs in Picat
    2.4 Assignments and While Loops https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf

    The approach is relatively straight forward, every variable is automatically
    a state variable, but its not automatically a pair. It gets a pair during assignment which is described by Neng-Fa Zhou and Jonathan Fruhman:

    Canonicalizing High-Level Constructs in Picat
    3.5 Transformation of Assignments
    Picat creates a new variable, say X1, to hold the value of X after
    the assignment X := X + 1. […] All occurrences of X after the assignment are replaced by X1. […] When encountering X1 := X1 + 2, Picat creates another new variable. Etc… https://www.sci.brooklyn.cuny.edu/~zhou/papers/padl17.pdf
    Mild Shock schrieb am Dienstag, 3. Oktober 2023 um 17:33:20 UTC+2:
    Would it be possibly to make a Picat that has more syntactic
    sugar. Like for example today I write:

    foo(X, R, Y, S) =>
    (X := X+1; Y := Y+1), R = X, S = Y.

    What if I could write:

    foo(!X, !Y) =>
    (X := X+1; Y := Y+1).

    Similar something for predicate goal invokation, including
    some query processing along the following lines:

    ?- X = 0, Y = 0, foo(!X, !Y).
    X = 1, Y = 0;
    X = 0, Y = 1.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Thu Oct 5 12:59:22 2023
    From Newsgroup: comp.lang.prolog

    How does one do the push back? I think its also on the agenda.
    In DCG a push back need not be a list. It can also be a non-terminal.
    If you have the following DCG clause with a push back:

    p, q --> r.

    Its translated as follows:

    p(A, B) :- r(A, C), q(B, C).

    So the push back is appended to the goal list of the body,
    and the push back has the argument order reversed. This lead me
    to an idea, which might be not present in Mercury, not sure, but to
    have both !IO and ?IO. A Push back would be translated:

    p(!IO) :- r(!IO), q(?IO)

    The question mark (?)/2, unlike the exclamation mark (!)/1, has the
    pair flipped, providing a mirror relation ship. This could be useful Short- DeadfishNumbers problem, if the state transtions are formulated !IO style,
    but with the help of ?IO one could search backward from the goal to the start. --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Thu Oct 5 13:00:21 2023
    From Newsgroup: comp.lang.prolog

    Corr.: Typo

    The question mark (?)/1, unlike the exclamation mark (!)/1, has the

    Mild Shock schrieb am Donnerstag, 5. Oktober 2023 um 21:59:23 UTC+2:
    How does one do the push back? I think its also on the agenda.
    In DCG a push back need not be a list. It can also be a non-terminal.
    If you have the following DCG clause with a push back:

    p, q --> r.

    Its translated as follows:

    p(A, B) :- r(A, C), q(B, C).

    So the push back is appended to the goal list of the body,
    and the push back has the argument order reversed. This lead me
    to an idea, which might be not present in Mercury, not sure, but to
    have both !IO and ?IO. A Push back would be translated:

    p(!IO) :- r(!IO), q(?IO)

    The question mark (?)/2, unlike the exclamation mark (!)/1, has the
    pair flipped, providing a mirror relation ship. This could be useful Short- DeadfishNumbers problem, if the state transtions are formulated !IO style, but with the help of ?IO one could search backward from the goal to the start.
    --- Synchronet 3.20a-Linux NewsLink 1.114