# Re: copy variables including their constraints

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Mon 28 Apr 2003 01:56:09 PM GMT
```Ulrich Scholz wrote:
>
> Let us assume we have a constraint set with three constraints
>
> C1(X,Z), C2(Y,Z), C3(X,R)
>
> Now we want to "magically" copy variables Y and Z, ie get new variables Y2 and
> Z2.  This would result in the constraint set
>
> C1(X,Z), C2(Y,Z), C3(X,R), C1(X,Z2), C2(Y2,Z2).

This is neither a full copy nor a projection.

> > magic_copy(Orig, Copy) :-
> >       shelf_create(s(Orig),S),
> >       shelf_get(S, 1, Copy),
> >       shelf_abolish(S).
>
> Hey, that seems to do exactly what I need.

No it doesn't. In your above example it would create:

C1(X,Z), C2(Y,Z), C3(X,R),  C1(Xcopy,Z2), C2(Y2,Z2), C3(Xcopy,Rcopy).

I.e. if your constraint graph is fully connected, it will create
a full copy of the whole graph no matter which subset of its variables
(nodes) you give to magic_copy/2.

In contrast, a proper projection of the constraint graph onto Y an Z
would in this case only create

C1(X,Z), C2(Y,Z), C3(X,R),  C2(Y2,Z2).

i.e. add a new constraint graph over the copied variables, which is
disconnected from the old graph. In general, the projection will
not just contain a subset of the original constraints, but new
surrogate constraints which achieve the same constraining as the
original constraints, but without the eliminted variables.
If all your constraints are linear, you can compute that with
Fourier-Motzkin elimination, if I remember correctly.

>  Somehow, I didn't understand from
> the manual pages of shelf_* that it copies constraints, too.  I thought it
> copies similar to copy_term.

It's not documented because I think it's a misfeature and it
actually _should_ work like copy_term :-)

>
> > If you can collect the constraints in that way, this is probably the
> > best solution. You might not need to list all individual constraints,
> > you just need one goal that sets them all up:
> >
> > ?-  setup_cstr(Vars),
> >     copy_term(Vars-setup_cstr(Vars), VarsCopy-GoalCopy),
> >     call(GoalCopy),
> >     ...
>
> Ah, that is a sneak way of unifying some but not all variables of a term.

??? You may be misunderstanding something.

--
Joachim Schimpf              /             phone: +44 20 7594 8187
IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
```
Received on Mon Apr 28 14:57:04 2003

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:23 PM GMT GMT