private static bool matches(TypeQuantifier typeQuantifier, Quantifier quantifier) { return ((typeQuantifier is TypeForall && quantifier.isForall) || (typeQuantifier is TypeExists && quantifier.isExists) ); }
public BasicQuantifiedTypeExpression( TypeQuantifier quantifier, TypeVariable variable, Expression expression, IEnumerable <Expression> triggers, string attributes ) { this.quantifier = quantifier; this.variable = variable; this.expression = expression; this.triggers = new ExpressionList(triggers); this.attributes = attributes; }
/////////////////////////////////////////////////////////// public BoogieQuantifiedTypeExpression( QuantifierExpr boogieExpression, TypeQuantifier quantifier, TypeVariable variable, Expression expression, List <Expression> triggers, string attributes ) : base( quantifier, variable, expression, triggers, attributes ) { Debug.Assert(boogieExpression != null); boogieQTExpression = boogieExpression; }
//////////////////////////////////////////////////////////////////////////////////// private Expression makeExpression(QuantifierExpr qe, bool old) { Expression e = null; var quantifiedVariables = new List <StateSpace.Variables.Quantification.BoundVariable>(); var typeVariables = new List <TypeVariable>(); TypeFactory.pushTypeVariables(ref context, qe.TypeParameters); foreach (Microsoft.Boogie.TypeVariable btp in qe.TypeParameters) { typeVariables.Add(context.lookupTypeVariable(btp.Name)); } string attributes = getAttributes(qe.Attributes); { foreach (Variable bv in qe.Dummies) { quantifiedVariables.Add(scope.makeFreshBoundVariable(bv.TypedIdent.Name, makeType(bv.TypedIdent.Type))); } for (int i = 0; i < qe.Dummies.Count; i++) { context.add(qe.Dummies[i].Name, quantifiedVariables[i]); } e = makeExpression(qe.Body, old); { // if (qe.ToString().Contains(@"{ a[o] } { b[o] }")) // Debugger.Break(); Quantifier q = makeQuantifier(qe.Kind); for (int i = qe.Dummies.Count - 1; i >= 0; i--) { // Microsoft.Boogie.Variable v = qe.Dummies[j]; // var ls = makeType(v.TypedIdent.Type); // var lv = new BoogieBoundVariable(v,ls); StateSpace.Variables.Quantification.BoundVariable lv = quantifiedVariables[i]; Debug.Assert(lv.name.Contains(qe.Dummies[i].TypedIdent.Name)); var triggers = new List <List <Expression> >(); // var triggers0 = string attrs = null; if (i == qe.Dummies.Count - 1) { if (qe.Triggers != null) { var btrigs = qe.Triggers; while (btrigs != null) { var ts = new List <Expression>(); foreach (var t in btrigs.Tr) { ts.Add(makeExpression(t, false)); } triggers.Add(ts); btrigs = btrigs.Next; } } attrs = attributes; } e = new BoogieQuantifiedExpression(scope, qe, q, lv, e, triggers, attrs); } // foreach (var v in quantifiedVariables) // boundVariables.Remove(v.name); } } context.pop(); { TypeQuantifier tq = makeTypeQuantifier(qe.Kind); for (int i = qe.TypeParameters.Count - 1; i >= 0; i--) { // Microsoft.Boogie.TypeVariable btv = qe.TypeParameters[j]; // TypeVariable tv = new BoogieTypeVariable( btv); var triggers = new List <Expression>(); string attrs = null; if (i == qe.TypeParameters.Count - 1 && qe.Triggers != null && qe.Dummies.Count == 0) { foreach (Expr t in qe.Triggers.Tr) { triggers.Add(makeExpression(t, false)); } attrs = attributes; } e = new BoogieQuantifiedTypeExpression(qe, tq, typeVariables[i], e, triggers, attributes); } } return(e); }