Ambiguity while Calling Functions from iterative Constraint


class A ;

typedef int unsigned iu ;

rand iu a[] ;
rand iu b[] ;

constraint SIZE { a.size() == b.size() ; a.size() == 4 ; } 

constraint FOREACH_ITEARION { 
                                foreach ( a[i] )
                               {
                                   b[i] == FUNC(a[i]) ;
				}
     		            }  

constraint VAL {   foreach( a[i] ) 
                   {
	             a[i] == i ; 
		    }
	       }				

function iu FUNC ( iu ip ) ;
    
	$display("returning %0d",ip);
        return ip ;

endfunction

endclass


A a1 ;

initial begin

  a1 = new() ;

  a1.randomize();
  
  $display("%0p",a1) ;

end


I observe following Output ::

===================================================================================
    OUTPUT 1              ||    OUTPUT 2
===================================================================================
                          || 
    returning 3           ||  returning 0
    returning 2           ||  returning 1                                           
    returning 1           ||  returning 2
    returning 0           ||  returning 3
    {0 1 2 3} {0 1 2 3}   ||  '{a:'{'h0, 'h1, 'h2, 'h3} , b:'{'h0, 'h1, 'h2, 'h3} }
                          ||
====================================================================================

//===========================================================================================
//                      OUTPUT 3
//===========================================================================================
//
//   .................... // Multiple return Values
//   .................... // Multiple return Values
//   returning 111398478
//   returning 2606441650
//   returning 1337087584
//   returning 3677353298
//   returning 1915772397
//   returning 250591116
        a1.randomize();
              |
 xmsim: *W,SVRNDF : The randomize method call failed. The unique id of the failed randomize call is 0. These constraints contribute to the set of conflicting constraints:
 
'{a:'{}, b:'{}}

I have a few questions

[Q1] LRM 18.5.12 :: " Function calls in active constraints are executed an unspecified
number of times (at least once) in an unspecified order. "

Why the above rule ? foreach would un-loop in order 0 to 3 .
Wouldn’t it simple to call the functions in order ?

[Q2] Also I feel OUTPUT 3 shouldn’t occur .
Since a is used as function input , so it would be solved implicitly before b .
So a would take values similar to its index i.e a[0] == 0 ; a[3] == 3 .
So we shouldn’t see any other display than " return 0-3 " .

In reply to MICRO_91:

Iterative constraints get unrolled into a pool of equations that are considered as a whole set&mdaah;they’re not procedural constructs.