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.HasLocalValue(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.UpdateLocal(local, item); yield return(copy); } } }
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.HasLocalValue(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.UpdateLocal(local, item); yield return copy; } } }