# [gecoder-devel] Sugar for "composite" constraints - a.k.a. "extended sugar"

Andreas Launila rubyforge at lokorin.org
Tue Aug 12 08:53:33 EDT 2008

```Andreas Launila wrote:
> Andreas Launila wrote:
>> With such a separation only the "non-composite" constraints would
>> actually be called constraints. The goal would be to make the user think of
>>
>>   set.min.must == 17
>>
>> as selecting the minimum of the set and then placing a relation
>> constraint on that minimum (rather than directly placing a constraint
>> that constrains the minimum of a set).
>>
>
> I'm in the process of rewriting the code (in /branches/composite_sugar)
> to reflect this distinction. It's more or less a rewrite of the
> underpinnings and changes the terminology used in the code. [...]
>
> Hopefully I haven't overextended myself in terms of the amount of
> rewriting needed.
>

Let's see how things are progressing. The following are the old
constraints broken down as in the quick reference[1] (x means that the
constraint has been rewritten).

== Int

[x] relation
[x] linear
[x] domain
[ ] abs
[ ] mult
[ ] square
[ ] square_root

== Int enum

[ ] min
[ ] max
[ ] channel with int enum
[ ] count
[x] distinct
[x] element
[ ] sort
[ ] sort with options
[ ] tuple
[ ] regexp

== Bool

[x] domain
[x] equality
[x] implication
[ ] channel with int

== Bool enum

[ ] conjunction
[ ] disjunction
[ ] tuple
[ ] channel with int
[ ] regexp

== Set

[ ] cardinality
[ ] min
[ ] max
[ ] sum
[ ] include
[x] domain
[x] operation
[x] relation
[ ] elements
[ ] channel with bool enum

== Set enum

[ ] channel with int enum
[x] at most once
[x] operation
[ ] select
[ ] select union
[ ] select intersection
[ ] select disjoint

== Fixnum enum

[x] elements
[x] operation

I have tried to take one of every major type and get the least straight
forward ones (linear, operation, ...) done first. As a result most of
the underlying code should now have been rewritten. From here on out it
should mostly be quantitative work that should be automated as much as
possible.

The constraints to go, broken down by how they need to be reimplemented,
are:

= Properties

== Short circuit int equality

=== Int
[ ] abs
[ ] mult
[ ] square
[ ] square_root

=== Int enum
[ ] min
[ ] max

=== Set
[ ] cardinality
[ ] min
[ ] max
[ ] sum

== Short circuit int relations

[ ] count
[ ] elements

== Short circuit bool equality

[ ] conjunction
[ ] disjunction

== Short circuit set equality

[ ] select
[ ] select union
[ ] select intersection

= Constraints

== Int enum constraints

[ ] channel with int enum
[ ] sort
[ ] sort with options
[ ] tuple
[ ] regexp

== Bool constraints

[ ] channel with int (+ commutativity)

== Bool enum constraints

[ ] tuple
[ ] channel with int (+ commutativity)
[ ] regexp

== Set constraints

[ ] include
[ ] channel with bool enum (+ commutativity)

== Set enum constraints

[ ] channel with int enum (+ commutativity)

== Selected set constraints

[ ] select disjoint

[1]
http://gecoder.rubyforge.org/documentation/constraints/quick-reference.html

--
Andreas Launila
```