Ejemplo n.º 1
0
        public override IEnumerable <ProofState> Generate(Statement statement, ProofState state)
        {
            var tvds = statement as TacticVarDeclStmt;
            AssignSuchThatStmt suchThat = null;

            if (tvds != null)
            {
                suchThat = tvds.Update as AssignSuchThatStmt;
            }
            else if (statement is AssignSuchThatStmt)
            {
                suchThat = (AssignSuchThatStmt)statement;
            }
            else
            {
                Contract.Assert(false, "Unexpected statement type");
            }
            Contract.Assert(suchThat != null, "Unexpected statement type");

            BinaryExpr bexp   = suchThat.Expr as BinaryExpr;
            var        locals = new List <string>();

            if (tvds == null)
            {
                foreach (var item in suchThat.Lhss)
                {
                    if (item is IdentifierExpr)
                    {
                        var id = (IdentifierExpr)item;
                        if (state.ContainTacnyVal(id.Name))
                        {
                            locals.Add(id.Name);
                        }
                        else
                        {
                            //TODO: error
                        }
                    }
                }
            }
            else
            {
                locals = new List <string>(tvds.Locals.Select(x => x.Name).ToList());
            }
            // this will cause issues when multiple variables are used
            // as the variables are updated one at a time
            foreach (var local in locals)
            {
                foreach (var item in ResolveExpression(state, bexp, local))
                {
                    var copy = state.Copy();
                    copy.UpdateTacnyVar(local, item);
                    yield return(copy);
                }
            }
        }
Ejemplo n.º 2
0
        private void InitArgs(ProofState ps, Statement st, out IVariable lv, out List <Expression> callArguments)
        {
            Contract.Requires(st != null);
            Contract.Ensures(Contract.ValueAtReturn(out callArguments) != null);
            lv            = null;
            callArguments = null;
            TacticVarDeclStmt tvds;
            UpdateStmt        us;
            TacnyBlockStmt    tbs;

            // tacny variables should be declared as tvar or tactic var
            //if(st is VarDeclStmt)
            //  Contract.Assert(false, Error.MkErr(st, 13));

            if ((tvds = st as TacticVarDeclStmt) != null)
            {
                lv            = tvds.Locals[0];
                callArguments = GetCallArguments(tvds.Update as UpdateStmt);
            }
            else if ((us = st as UpdateStmt) != null)
            {
                if (us.Lhss.Count == 0)
                {
                    callArguments = GetCallArguments(us);
                }
                else
                {
                    var ns = (NameSegment)us.Lhss[0];
                    if (ps.ContainTacnyVal(ns))
                    {
                        //TODO: need to doubel check this
                        lv            = ps.GetTacnyVarValue(ns) as IVariable;
                        callArguments = GetCallArguments(us);
                    }
                }
            }
            else if ((tbs = st as TacnyBlockStmt) != null)
            {
                var pe = tbs.Guard as ParensExpression;
                callArguments = pe != null ? new List <Expression> {
                    pe.E
                } : new List <Expression> {
                    tbs.Guard
                };
            }
        }
Ejemplo n.º 3
0
    private void InitArgs(ProofState ps, Statement st, out IVariable lv, out List<Expression> callArguments) {
      Contract.Requires(st != null);
      Contract.Ensures(Contract.ValueAtReturn(out callArguments) != null);
      lv = null;
      callArguments = null;
      TacticVarDeclStmt tvds;
      UpdateStmt us;
      TacnyBlockStmt tbs;

      // tacny variables should be declared as tvar or tactic var
      //if(st is VarDeclStmt)
      //  Contract.Assert(false, Error.MkErr(st, 13));

      if((tvds = st as TacticVarDeclStmt) != null) {
        lv = tvds.Locals[0];
        callArguments = GetCallArguments(tvds.Update as UpdateStmt);

      } else if((us = st as UpdateStmt) != null) {
        if(us.Lhss.Count == 0)
          callArguments = GetCallArguments(us);
        else {
          var ns = (NameSegment)us.Lhss[0];
          if(ps.ContainTacnyVal(ns)) {
            //TODO: need to doubel check this
            lv = ps.GetTacnyVarValue(ns) as IVariable;
            callArguments = GetCallArguments(us);
          }
        }
      } else if((tbs = st as TacnyBlockStmt) != null) {
        var pe = tbs.Guard as ParensExpression;
        callArguments = pe != null ? new List<Expression> { pe.E } : new List<Expression> { tbs.Guard };
      }

    }