Path: utzoo!mnetor!uunet!mcvax!unido!ecrcvax!micha From: micha@ecrcvax.UUCP (Micha Meier) Newsgroups: comp.lang.prolog Subject: Re: Triangle Puzzle (Trilogy) Message-ID: <508@ecrcvax.UUCP> Date: 7 Mar 88 10:37:58 GMT References: <652@cresswell.quintus.UUCP> <1863@ubc-cs.UUCP> <721@cresswell.quintus.UUCP> Reply-To: micha@ecrcvax.UUCP (Micha Meier) Organization: ECRC, Munich 81, West Germany Lines: 57 Keywords: Modifiable Variables, State Transition, TRILOGY. Since Paul Voda is travelling in Europe, I will try to answer some of your questions (knowing the basic principles of Trilogy): In article <721@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >But let's hear more about Trilogy. Have I understood correctly that an >'in' or 'in out' parameter, cannot be unresolved, so that if the actual >parameter is defined by constraints, those constraints must be solved >before the call can happen? Does this mean that an 'in' or 'in out' >parameter must be completely ground, or may such a parameter contain >constrained elements? Input variables are always ground, output variables will obtain ground values and since an input-output variable stands for a pair (input, output), it is ground before the assignment and stays so afterwards. When one wants to use partially instantiated variables and constraints, then one has to use symbolic (logical) variables. When you don't use symbolic variables, your code can be as efficient as in Pascal (or Turbo Prolog). >Interesting! Please explain this some more. If I write > > x := 6 & Incr(x) & y = x & Incr(x) & P(x) > >which version of x does y get? (The answer should be obvious, but I'd like >to see how it's done.) This is an abbreviation for x1 = 6 & Incr(x1, x2) & y = x2 & Incr(x2, x3) & P(x3) and thus y is a copy of x at the moment of executing y = x and subsequent changes of x don't affect y. >What if we have some larger structure, and I do > > x := NewThing & Update(x,1) & y = x & Update(x,2) & Update(y,3) > >How does one avoid interference between the updates to x and y? Or is this >disallowed somehow? {This is also a problem with the 'var' hack in Prolog, >by the way. It is not a problem with pure versions using trees.} This is an abbreviation for x1 = NewThing & Update(x1, x2, 1) & y1 = x2 & Update(x2, x3, 2) & Update(y1, y2, 3) Since y is used as an input-output variable, the formula y = x is only a test of the current values of y and x (both must be ground). If there would be y := x instead of y = x, then y would be assigned a copy of the current value of x and so there is no interference. I think that in Prolog you could achieve similar results with a very clever compiler (reusing the environemnts etc.) but only in a very limited number of cases. --Micha Meier