conjure-cp / conjure

Conjure: The Automated Constraint Modelling Tool
Other
96 stars 20 forks source link

Lettings causing SR errors #326

Closed ozgurakgun closed 7 years ago

ozgurakgun commented 8 years ago

Originally reported by: Bilal Hussain (Bitbucket: Bilalh, GitHub: Bilalh)


This spec causes an error using conjure solve at SR

language Essence 1.3

letting N be 5
letting num_nodes be domain int(1..N)

find ordering : function(total) num_nodes --> num_nodes
find dependent: set  of num_nodes

such that
    dependent = toSet([ n  | (n,i) <- toSet(ordering) ])
ERROR: Identifier not defined: q4
ERROR: Failed type checking after substituting in lettings.

whereas this does not

language Essence 1.3

find ordering: function (total) int(1..5) --> int(1..5)
find dependent: set of int(1..5)
such that dependent = toSet([n | (n, i) <- toSet(ordering)])

This is also interesting because when I tried to reduce it, it said there were no error in it since it had already inline the lettings.


ozgurakgun commented 8 years ago

Original comment by Özgür Akgün (Bitbucket: ozgurakgun, GitHub: ozgurakgun):


fixes #55

ozgurakgun commented 8 years ago

Original comment by Bilal Hussain (Bitbucket: Bilalh, GitHub: Bilalh):


The spec is a manually reduced version of a spec I am not using any more. There were various extra constraints on the variables.

ozgurakgun commented 8 years ago

Original comment by Özgür Akgün (Bitbucket: ozgurakgun, GitHub: ozgurakgun):


toSet, with a matrix comprehension inside is not "officially" supported.

the fact that it works in one case is what is surprising!

why not use the following:

such that dependent = toSet([n | n : num_nodes])

or even get rid of dependent, since it is not a decision variable at all? as in, it's value is statically known?

I will have a look to see if there is another bug hiding in there though, so leaving the issue open for now.