Error in constraint number of ones in stream is more than 4

In reply to marathuteja:

Calling user-defined function in constraints should be done carefully, because the function shall be called before constraints are solved (no back-track done by the solver to find proper function input), and this is a source potential constraints conflicts.