aeternity / aesophia

Stand alone compiler for the Sophia smart contract language
https://docs.aeternity.com/aesophia
ISC License
51 stars 19 forks source link

Improve constraint solving #480

Closed hanssv closed 1 year ago

hanssv commented 1 year ago

Fingers itched... This solves one actual problem (on Ceres branch once rebased) where three constraints depended on each other and the current implementation only made two iterations.

The rewrite should be more general and easier to further change if necessary. Would be nice to separate solving and error reporting further - but lets save that for another rainy day.

This PR is supported by the Æternity Crypto Foundation

hanssv commented 1 year ago

@radrow The general problem addressed was the lack of a proper fix-point iteration - this shows up when there are constraints that depend on each other and the order in which you try suddenly matters. It seemed like you or @ghallak had already noticed this -- and "solved" it by adding a second copy of all constraints to the solver.

I could have solved the current issue by adding a third copy of the constraints, but instead opted to implement the iteration that checked for progress more generally. And yes there could have been more comments, but it could also have been done properly the first time.