<html><head></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Sorry, I sent my mail to Sean directly, instead of to the list, by accident. And he replied to me, off list as well. So I'm forwarding his answer here. My mail just said "For real? What did it say?".</div><div><br></div><div>-------- Ursprüngliche Nachricht --------</div><div>Von: Sean Charles (emacstheviking) <<a href="mailto:%22Sean%20Charles%20%28emacstheviking%29%22%20%3cobjitsu@gmail.com%3e">objitsu@gmail.com</a>></div><div>An: Volker Wysk <<a href="mailto:Volker%20Wysk%20%3cpost@volker-wysk.de%3e">post@volker-wysk.de</a>></div><div>Betreff: Re: [m-users.] Self-improvement subjects.</div><div>Datum: Mon, 23 Oct 2023 17:52:53 +0100</div><div><br></div><!-- text/html --><meta http-equiv="content-type" content="text/html; charset=us-ascii"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div></blockquote><div>Here you go!</div><div><br></div><div>---------[start chatgpt content]</div><div><br></div><div><b>In terms of logic programming, what is an existential variable? Can you show me an example in a language called Mercury?</b></div><div><b>ChatGPT</b></div><div><br></div><div><br></div><div>In logic programming, an existential variable is a variable that is introduced to represent an unknown value or an existentially quantified variable. Existential variables are used in predicate logic to indicate that there exists some value that satisfies a certain condition without specifying the value itself. These variables are typically denoted using unique symbols, and their values are determined by the program's inference engine when solving a logical query.</div><div><br></div><div>Mercury is a logic programming language that is closely related to Prolog. In Mercury, existential variables are represented using the ^ symbol followed by a unique identifier. Here's an example of how you might use an existential variable in Mercury:</div><div><br></div><div>mercury</div><div><br></div><div>:- type person ---> john ; mary.</div><div><br></div><div>:- pred likes(person, person).</div><div>:- mode likes(in, in) is semidet.</div><div><br></div><div>% Rule 1: John likes someone (existential variable Y).</div><div>likes(john, Y) :-</div><div> % Here, ^ is used to introduce an existential variable.</div><div> Y ^ (mary ; john).</div><div><br></div><div>% Rule 2: Mary likes someone (existential variable X).</div><div>likes(mary, X) :-</div><div> X ^ (john ; mary).</div><div><br></div><div>% Query: Who does John like?</div><div>:- func who_does_john_like = person is nondet.</div><div>who_does_john_like = X :-</div><div> likes(john, X).</div><div><br></div><div>% Query: Who does Mary like?</div><div>:- func who_does_mary_like = person is nondet.</div><div>who_does_mary_like = Y :-</div><div> likes(mary, Y).</div><div><br></div><div>In the example above, ^ is used to introduce existential variables, such as X ^ (john ; mary), indicating that there exists a value X (an unknown person) that Mary likes. The actual value of X is determined by the inference engine when solving queries.</div><div><br></div><div>When you query who_does_john_like or who_does_mary_like, the Mercury system will provide the answers based on the rules and the values of the existential variables introduced in the rules. The use of existential variables allows you to express existentially quantified statements and perform logical inference in Mercury.</div><div><br></div><div>---------[end of chatgpt content]</div><div><br></div><div><br></div><div><br></div><div><br><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>On 23 Oct 2023, at 17:48, Volker Wysk <post@volker-wysk.de> wrote:</div><div><br class="Apple-interchange-newline"></div><div>Am Montag, dem 23.10.2023 um 17:39 +0100 schrieb Sean Charles<br>(emacstheviking):<br><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>I decided to ask Chat-GPT Volker, it has been most helpful too!<br></div></blockquote><br>For real? What did it say?<br><br><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><span class="Apple-tab-span" style="white-space: pre;"> </span>In terms of logic programming, what is an existential variable?<br>Can you show me an example in a language called Mercury?<br><br>And what came back was clear, and explained and so for the rest of the<br>evening, some cheese and biscuits will accompany on my Chat-GPT education<br>about such matters!<br><br>Thanks!<br><br>:D<br><br><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>On 23 Oct 2023, at 17:37, Volker Wysk <post@volker-wysk.de> wrote:<br><br>Am Montag, dem 23.10.2023 um 14:37 +0100 schrieb Sean Charles<br>(emacstheviking):<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>What areas of maths / logic do I need to study to better understand<br>the<br>Mercury compiler?<br><br>I have a brain, so I have a chance.<br><br>What I find mostly confusing is all the talk of 'existential' things,<br>from<br>philosophy I know what Existentialism means but not when applied to a<br>language like Mercury. <br></div></blockquote><div><br>Existential types (more precisely: types with existentially quantified<br>type<br>variables in them) gave me a headache, too, at first. I recommend this<br>page:<br><br>https://github.com/Mercury-Language/mercury/wiki/Existential-types<br><br>"Existential" refers to the existential quantifier in such types. As<br>opposed<br>to the usual implicit universal quantifier (which can be made explicit,<br>but<br>doesn't need to).<br><br>What that page doesn't say, is that for an existential type you will<br>probably also need a type class, so you can do more with it. <br><br>You can think of an existential data constructor as a container for a<br>value<br>that can have any type (possibly restricted to the members of a type<br>class).<br>That type, encapsulated inside of it, isn't give out to the outside.<br>This<br>means, it isn't restricted to anything from the outside.<br><br><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Also I still struggle with modes/inst and 'and-or' trees. I read the<br>Wikipedia page on those until it stopped making sense (didn't take<br>long),<br>I have rough idea of what the Mercury manual is trying to tell me but<br>I am<br>sick and tired of feeling like a semi-educated simpleton and need to<br>up my<br>game.<br><br>When I learned Prolog, I did some study about Horne clauses, and some<br>other related subjects but only enough really to understand what I was<br>doing at the time time, and it got me further down the road.<br><br>But...Mercury. What a beast! <br></div></blockquote><div><br>Yes, insts are beasty. :-))<br><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>I truly want to get to know it's inner dialogue as it once again is<br>forced<br>to eat my probably horrendous code over and over.<br><br>So... any topic for self-study would be most appreciated.<br></div></blockquote><div><br>Good luck,<br>Volker<br></div></blockquote><div><br></div></blockquote><br></div></blockquote></div><br class="Apple-interchange-newline"><div><br></div><div><span></span></div></body></html>