private static bool ShallowEq(MemberSelectExpr expr1, MemberSelectExpr expr2) { return(expr1.MemberName == expr2.MemberName && expr1.Member == expr2.Member && TriggerUtils.SameLists(expr1.TypeApplication_AtEnclosingClass, expr2.TypeApplication_AtEnclosingClass, TypeEq) && TriggerUtils.SameLists(expr1.TypeApplication_JustMember, expr2.TypeApplication_JustMember, TypeEq)); }
internal static bool ExpressionEq(this Expression expr1, Expression expr2) { expr1 = expr1.Resolved; expr2 = expr2.Resolved; return(ShallowEq_Top(expr1, expr2) && TriggerUtils.SameLists(expr1.SubExpressions, expr2.SubExpressions, (e1, e2) => ExpressionEq(e1, e2))); }
private static bool ShallowEq(ComprehensionExpr expr1, ComprehensionExpr expr2) { if (!TriggerUtils.SameLists(expr1.BoundVars, expr2.BoundVars, SameBoundVar) || !ShallowSameAttributes(expr1.Attributes, expr2.Attributes) || // Filled in during resolution: !SameLists(expr1.Bounds, expr2.Bounds, ReferenceCompare) || // !SameLists(expr1.MissingBounds, expr2.MissingBounds, SameBoundVar) || !TriggerUtils.SameNullity(expr1.Range, expr2.Range)) //TODO Check { return(false); } if (expr1 is LambdaExpr && expr2 is LambdaExpr) { return(ShallowEq((LambdaExpr)expr1, (LambdaExpr)expr2)); } else if (expr1 is MapComprehension && expr2 is MapComprehension) { return(ShallowEq((MapComprehension)expr1, (MapComprehension)expr2)); } else if (expr1 is SetComprehension && expr2 is SetComprehension) { return(ShallowEq((SetComprehension)expr1, (SetComprehension)expr2)); } else if (expr1 is QuantifierExpr && expr2 is QuantifierExpr) { return(ShallowEq((QuantifierExpr)expr1, (QuantifierExpr)expr2)); } else { return(false); // ComprehensionExpr is abstract } }
internal static bool MatchesTrigger(this Expression expr, Expression trigger, ISet <BoundVar> holes, Dictionary <IVariable, Expression> bindings) { expr = expr.Resolved; trigger = trigger.Resolved; if (trigger is IdentifierExpr) { var var = ((IdentifierExpr)trigger).Var; if (holes.Contains(var)) { Expression existing_binding = null; if (bindings.TryGetValue(var, out existing_binding)) { return(ExpressionEq(expr, existing_binding)); } else { bindings[var] = expr; return(true); } } } return(ShallowEq_Top(expr, trigger) && TriggerUtils.SameLists(expr.SubExpressions, trigger.SubExpressions, (e1, e2) => MatchesTrigger(e1, e2, holes, bindings))); }
private static bool ShallowEq(DatatypeValue expr1, DatatypeValue expr2) { return // Implied by Ctor equality: expr1.DatatypeName == expr2.DatatypeName && // Implied by Ctor equality: expr1.MemberName == expr2.MemberName && (expr1.Ctor == expr2.Ctor && // Contextual information: expr1.IsCoCall == expr2.IsCoCall && TriggerUtils.SameLists(expr1.InferredTypeArgs, expr2.InferredTypeArgs, TypeEq)); }
internal static bool ExpressionEqModuloExpressionsNotInvolvingBoundVariables(this Expression expr1, Expression expr2, ISet <BoundVar> boundVars) { expr1 = expr1.Resolved; expr2 = expr2.Resolved; if (expr1 is IdentifierExpr) { if (expr2 is IdentifierExpr) { return(true); } else { var freeInE2 = Translator.ComputeFreeVariables(expr2); freeInE2.IntersectWith(boundVars); return(!freeInE2.Any()); } } return(ShallowEq_Top(expr1, expr2) && TriggerUtils.SameLists(expr1.SubExpressions, expr2.SubExpressions, (e1, e2) => ExpressionEqModuloExpressionsNotInvolvingBoundVariables(e1, e2, boundVars))); }
private static bool ShallowSameAttributes(Attributes attributes1, Attributes attributes2) { return(TriggerUtils.SameLists(attributes1.AsEnumerable(), attributes2.AsEnumerable(), ShallowSameSingleAttribute)); }
private static bool SameTriggerCandidate(TriggerCandidate arg1, TriggerCandidate arg2) { return(TriggerUtils.SameLists(arg1.Terms, arg2.Terms, TriggerTerm.Eq)); }
private bool HasSameTriggers(QuantifierWithTriggers one, QuantifierWithTriggers other) { return(TriggerUtils.SameLists(one.Candidates, other.Candidates, SameTriggerCandidate)); }
private static bool ShallowEq(MemberSelectExpr expr1, MemberSelectExpr expr2) { return(expr1.MemberName == expr2.MemberName && expr1.Member == expr2.Member && TriggerUtils.SameLists(expr1.TypeApplication, expr2.TypeApplication, Microsoft.Dafny.Type.Equals)); }
private static bool ShallowEq(MemberSelectExpr expr1, MemberSelectExpr expr2) { return(expr1.MemberName == expr2.MemberName && expr1.Member == expr2.Member && TriggerUtils.SameLists(expr1.TypeApplication, expr2.TypeApplication, TypeEq)); }