@@ -793,21 +793,29 @@ private void GenerateAndCheckGuesses(IOrigin tok, List<BoundVar> bvars, List<Bou
793
793
/// <summary>
794
794
/// Return a pair of expressions (a, b) such that the disjunction "a || b" is equivalent to "expression"
795
795
/// and expression "a" does not mention any variable in "vars".
796
- /// Expression "a" is always returns as "false" unless all variables in "vars" are known to have a value.
796
+ /// Expression "a" is always returned as "false" unless the types of all variables in "vars" are known to have a value.
797
797
/// </summary>
798
798
( Expression , Expression ) SeparateDisjunctsAccordingToVariableUsage ( List < BoundVar > vars , Expression expression ) {
799
799
Expression a = Expression . CreateBoolLiteral ( expression . Origin , false ) ;
800
800
801
- if ( vars . Exists ( x => ! x . Type . KnownToHaveToAValue ( x . IsGhost ) ) ) {
801
+ if ( vars . Any ( x => ! x . Type . KnownToHaveToAValue ( x . IsGhost ) ) ) {
802
802
return ( a , expression ) ;
803
803
}
804
804
805
805
// Place the left-most var-independent disjuncts into "a" and the rest into "b".
806
+ // The loop below has the effect of:
807
+ // var d: List<Expression> := Expression.Disjuncts(expression);
808
+ // var (prefix, rest) :|
809
+ // "prefix" is the longest prefix of "d" where no Expression mentions a variable in "vars" and
810
+ // "rest" is the remaining Expression's of "d";
811
+ // return (Or(prefix), Or(rest));
812
+ // But the loop optimizes the case where "prefix" is empty, returning "(false, expression)" in the event
813
+ // that the first element of "d" contains some variable in "vars".
806
814
Expression b = Expression . CreateBoolLiteral ( expression . Origin , false ) ;
807
815
var seenDisjunctsWithoutVariables = false ;
808
816
var seenDisjunctsWithVariables = false ;
809
817
foreach ( var disjunct in Expression . Disjuncts ( expression ) ) {
810
- if ( ! seenDisjunctsWithVariables && vars . All ( x => ! FreeVariablesUtil . ContainsFreeVariable ( disjunct , false , x ) ) ) {
818
+ if ( ! seenDisjunctsWithVariables && ! vars . Any ( x => FreeVariablesUtil . ContainsFreeVariable ( disjunct , false , x ) ) ) {
811
819
a = Expression . CreateOr ( a , disjunct ) ;
812
820
seenDisjunctsWithoutVariables = true ;
813
821
} else if ( ! seenDisjunctsWithoutVariables ) {
0 commit comments