Пример #1
0
        // if the user says ( forall x :: forall y :: { f(x,y) } ... ) we transform it to
        // (forall x, y :: { f(x,y) } ... ) otherwise the prover ignores the trigger
        private void MergeAdjecentQuantifier()
        {
            QuantifierExpr qbody = Body as QuantifierExpr;

            if (!(qbody != null && (qbody is ForallExpr) == (this is ForallExpr) && Triggers == null))
            {
                return;
            }
            qbody.MergeAdjecentQuantifier();
            if (qbody.Triggers == null)
            {
                return;
            }
            Body = qbody.Body;
            TypeParameters.AddRange(qbody.TypeParameters);
            Dummies.AddRange(qbody.Dummies);
            Triggers = qbody.Triggers;
            if (qbody.Attributes != null)
            {
                if (Attributes == null)
                {
                    Attributes = qbody.Attributes;
                }
                else
                {
                    QKeyValue p = Attributes;
                    while (p.Next != null)
                    {
                        p = p.Next;
                    }
                    p.Next = qbody.Attributes;
                }
            }
        }
Пример #2
0
        internal static IEnumerable<Expression> SplitQuantifier(QuantifierExpr quantifier)
        {
            var body = quantifier.Term;
              var binary = body as BinaryExpr;

              if (quantifier is ForallExpr) {
            IEnumerable<Expression> stream;
            if (binary != null && (binary.Op == BinaryExpr.Opcode.Imp || binary.Op == BinaryExpr.Opcode.Or)) {
              stream = SplitAndStich(binary, BinaryExpr.Opcode.And);
            } else {
              stream = SplitExpr(body, BinaryExpr.Opcode.And);
            }
            foreach (var e in stream) {
              var tok = new NestedToken(quantifier.tok, e.tok);
              yield return new ForallExpr(tok, quantifier.TypeArgs, quantifier.BoundVars, quantifier.Range, e, CopyAttributes(quantifier.Attributes)) { Type = quantifier.Type };
            }
              } else if (quantifier is ExistsExpr) {
            IEnumerable<Expression> stream;
            if (binary != null && binary.Op == BinaryExpr.Opcode.And) {
              stream = SplitAndStich(binary, BinaryExpr.Opcode.Or);
            } else {
              stream = SplitExpr(body, BinaryExpr.Opcode.Or);
            }
            foreach (var e in stream) {
              var tok = new NestedToken(quantifier.tok, e.tok);
              yield return new ExistsExpr(tok, quantifier.TypeArgs, quantifier.BoundVars, quantifier.Range, e, CopyAttributes(quantifier.Attributes)) { Type = quantifier.Type };
            }
              } else {
            yield return quantifier;
              }
        }
Пример #3
0
 public virtual QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
     Contract.Requires(node != null);
     Contract.Ensures(Contract.Result <QuantifierExpr>() != null);
     node = cce.NonNull((QuantifierExpr)this.VisitBinderExpr(node));
     if (node.Triggers != null)
     {
         node.Triggers = this.VisitTrigger(node.Triggers);
     }
     return(node);
 }
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
     currentTrigger = node.Triggers;
     while (currentTrigger != null)
     {
         foreach (var e in currentTrigger.Tr)
         {
             VisitExpr(e);
         }
         currentTrigger = currentTrigger.Next;
     }
     return(base.VisitQuantifierExpr(node));
 }
Пример #5
0
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
     // don't go into quantifier expression or its triggers, since the terms in there may have more bound variables
     // (note, with only the VisitBinderExpr override below, we'd still be visiting triggers, which we don't want to do)
     return(node);
 }
Пример #6
0
 public NeverTriggerCollector(QuantifierExpr p)
 {
     Contract.Requires(p != null);
     parent = p;
 }
Пример #7
0
 private static bool AllowsSplitting(QuantifierExpr quantifier)
 {
     bool splitAttr = true;
       return !Attributes.ContainsBool(quantifier.Attributes, "split", ref splitAttr) || splitAttr;
 }
Пример #8
0
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
   currentTrigger = node.Triggers;
   while (currentTrigger != null)
   {
     foreach (var e in currentTrigger.Tr)
     {
       VisitExpr(e);
     }
     currentTrigger = currentTrigger.Next;
   }
   return base.VisitQuantifierExpr(node);
 }
Пример #9
0
 public virtual QuantifierExpr VisitQuantifierExpr(QuantifierExpr node) {
   Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<QuantifierExpr>() != null);
   node = cce.NonNull((QuantifierExpr)this.VisitBinderExpr(node));
   if (node.Triggers != null) {
     node.Triggers = this.VisitTrigger(node.Triggers);
   }
   return node;
 }
Пример #10
0
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
     Contract.Ensures(Contract.Result<QuantifierExpr>() == node);
     this.VisitBinderExpr(node);
     if (node.Triggers != null)
     {
         this.VisitTrigger(node.Triggers);
     }
     return node;
 }
Пример #11
0
            public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
            {
                var oldE = existentialExpr;

                if (node is ExistsExpr)
                    existentialExpr = (node as ExistsExpr);

                node = base.VisitQuantifierExpr(node);

                existentialExpr = oldE;
                return node;
            }
Пример #12
0
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node) {
   // don't go into quantifier expression or its triggers, since the terms in there may have more bound variables
   // (note, with only the VisitBinderExpr override below, we'd still be visiting triggers, which we don't want to do)
   return node;
 }
Пример #13
0
 public NeverTriggerCollector(QuantifierExpr p) {
   Contract.Requires(p != null);
   parent = p;
 }
Пример #14
0
 public override QuantifierExpr VisitQuantifierExpr(QuantifierExpr node)
 {
     // Don't remove this implementation! Triggers should be duplicated in VisitBinderExpr.
     return((QuantifierExpr)this.VisitBinderExpr(node));
 }