Re: [m-users.] Self-improvement subjects.
Volker Wysk <[email protected]>
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
That Chat GPT answer doesn't make much sense to me. I've tried to compile it, but it doesn't. I know the "^" operator only for field access predicates. And so does the compiler, it seems. Am Montag, dem 23.10.2023 um 19:03 +0200 schrieb Volker Wysk: > 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?". > > -------- Ursprüngliche Nachricht -------- > Von: Sean Charles (emacstheviking) <[email protected]> > An: Volker Wysk <[email protected]> > Betreff: Re: [m-users.] Self-improvement subjects. > Datum: Mon, 23 Oct 2023 17:52:53 +0100 > > > > Here you go! > > ---------[start chatgpt content] > > In terms of logic programming, what is an existential variable? Can you > show me an example in a language called Mercury? > ChatGPT > > > 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. > > 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: > > mercury > > :- type person ---> john ; mary. > > :- pred likes(person, person). > :- mode likes(in, in) is semidet. > > % Rule 1: John likes someone (existential variable Y). > likes(john, Y) :- > % Here, ^ is used to introduce an existential variable. > Y ^ (mary ; john). > > % Rule 2: Mary likes someone (existential variable X). > likes(mary, X) :- > X ^ (john ; mary). > > % Query: Who does John like? > :- func who_does_john_like = person is nondet. > who_does_john_like = X :- > likes(john, X). > > % Query: Who does Mary like? > :- func who_does_mary_like = person is nondet. > who_does_mary_like = Y :- > likes(mary, Y). > > 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. > > 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. > > ---------[end of chatgpt content] > > > > > > On 23 Oct 2023, at 17:48, Volker Wysk <[email protected]> wrote: > > > > Am Montag, dem 23.10.2023 um 17:39 +0100 schrieb Sean Charles > > (emacstheviking): > > > I decided to ask Chat-GPT Volker, it has been most helpful too! > > > > For real? What did it say? > > > > > In terms of logic programming, what is an existential > > > variable? > > > Can you show me an example in a language called Mercury? > > > > > > And what came back was clear, and explained and so for the rest of the > > > evening, some cheese and biscuits will accompany on my Chat-GPT > > > education > > > about such matters! > > > > > > Thanks! > > > > > > :D > > > > > > > > > > On 23 Oct 2023, at 17:37, Volker Wysk <[email protected]> wrote: > > > > > > > > Am Montag, dem 23.10.2023 um 14:37 +0100 schrieb Sean Charles > > > > (emacstheviking): > > > > > What areas of maths / logic do I need to study to better > > > > > understand > > > > > the > > > > > Mercury compiler? > > > > > > > > > > I have a brain, so I have a chance. > > > > > > > > > > What I find mostly confusing is all the talk of 'existential' > > > > > things, > > > > > from > > > > > philosophy I know what Existentialism means but not when applied > > > > > to a > > > > > language like Mercury. > > > > > > > > Existential types (more precisely: types with existentially > > > > quantified > > > > type > > > > variables in them) gave me a headache, too, at first. I recommend > > > > this > > > > page: > > > > > > > > https://github.com/Mercury-Language/mercury/wiki/Existential-types > > > > > > > > "Existential" refers to the existential quantifier in such types. As > > > > opposed > > > > to the usual implicit universal quantifier (which can be made > > > > explicit, > > > > but > > > > doesn't need to). > > > > > > > > What that page doesn't say, is that for an existential type you will > > > > probably also need a type class, so you can do more with it. > > > > > > > > You can think of an existential data constructor as a container for > > > > a > > > > value > > > > that can have any type (possibly restricted to the members of a type > > > > class). > > > > That type, encapsulated inside of it, isn't give out to the outside. > > > > This > > > > means, it isn't restricted to anything from the outside. > > > > > > > > > > > > > Also I still struggle with modes/inst and 'and-or' trees. I read > > > > > the > > > > > Wikipedia page on those until it stopped making sense (didn't take > > > > > long), > > > > > I have rough idea of what the Mercury manual is trying to tell me > > > > > but > > > > > I am > > > > > sick and tired of feeling like a semi-educated simpleton and need > > > > > to > > > > > up my > > > > > game. > > > > > > > > > > When I learned Prolog, I did some study about Horne clauses, and > > > > > some > > > > > other related subjects but only enough really to understand what I > > > > > was > > > > > doing at the time time, and it got me further down the road. > > > > > > > > > > But...Mercury. What a beast! > > > > > > > > Yes, insts are beasty. :-)) > > > > > > > > > I truly want to get to know it's inner dialogue as it once again > > > > > is > > > > > forced > > > > > to eat my probably horrendous code over and over. > > > > > > > > > > So... any topic for self-study would be most appreciated. > > > > > > > > Good luck, > > > > Volker > > > > > > > > _______________________________________________ > users mailing list > [email protected] > https://lists.mercurylang.org/listinfo/users _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users