Exemple #1
0
        private static IEnumerable <ProofState> RegisterVariable(TacticVarDeclStmt declaration, ProofState state)
        {
            if (declaration.Update == null)
            {
                yield break;
            }
            var rhs = declaration.Update as UpdateStmt;

            if (rhs == null)
            {
                // check if rhs is SuchThatStmt
                if (declaration.Update is AssignSuchThatStmt)
                {
                    foreach (var item in declaration.Locals)
                    {
                        state.AddLocal(item, null);
                    }
                    foreach (var item in EvaluateSuchThatStmt(declaration.Update as AssignSuchThatStmt, state))
                    {
                        yield return(item.Copy());
                    }
                }
                else
                {
                    foreach (var item in declaration.Locals)
                    {
                        state.AddLocal(item, null);
                    }
                }
            }
            else
            {
                foreach (var item in rhs.Rhss)
                {
                    int index = rhs.Rhss.IndexOf(item);
                    Contract.Assert(declaration.Locals.ElementAtOrDefault(index) != null, "register var err");
                    var exprRhs = item as ExprRhs;
                    if (exprRhs?.Expr is ApplySuffix)
                    {
                        var aps = (ApplySuffix)exprRhs.Expr;
                        foreach (var result in EvaluateTacnyExpression(state, aps))
                        {
                            state.AddLocal(declaration.Locals[index], result);
                        }
                    }
                    else if (exprRhs?.Expr is Dafny.LiteralExpr)
                    {
                        state.AddLocal(declaration.Locals[index], (Dafny.LiteralExpr)exprRhs?.Expr);
                    }
                    else
                    {
                        state.AddLocal(declaration.Locals[index], exprRhs?.Expr);
                    }
                }
            }
            yield return(state.Copy());
        }
Exemple #2
0
 private static IEnumerable<ProofState> RegisterVariable(TacticVarDeclStmt declaration, ProofState state) {
   if (declaration.Update == null) yield break;
   var rhs = declaration.Update as UpdateStmt;
   if (rhs == null) {
     // check if rhs is SuchThatStmt
     if (declaration.Update is AssignSuchThatStmt) {
       foreach (var item in declaration.Locals)
         state.AddLocal(item, null);
       foreach (var item in EvaluateSuchThatStmt(declaration.Update as AssignSuchThatStmt, state)) {
         yield return item.Copy();
       }
     } else {
       foreach (var item in declaration.Locals)
         state.AddLocal(item, null);
     }
   } else {
     foreach (var item in rhs.Rhss) {
       int index = rhs.Rhss.IndexOf(item);
       Contract.Assert(declaration.Locals.ElementAtOrDefault(index) != null, "register var err");
       var exprRhs = item as ExprRhs;
       if (exprRhs?.Expr is ApplySuffix) {
         var aps = (ApplySuffix)exprRhs.Expr;
         foreach (var result in EvaluateTacnyExpression(state, aps)) {
           state.AddLocal(declaration.Locals[index], result);
         }
       } else if (exprRhs?.Expr is Dafny.LiteralExpr) {
         state.AddLocal(declaration.Locals[index], (Dafny.LiteralExpr)exprRhs?.Expr);
       } else {
         state.AddLocal(declaration.Locals[index], exprRhs?.Expr);
       }
     }
   }
   yield return state.Copy();
 }