private static IEnumerable <ProofState> UpdateLocalValue(UpdateStmt us, ProofState state) { Contract.Requires <ArgumentNullException>(us != null, "stmt"); Contract.Requires <ArgumentNullException>(state != null, "state"); Contract.Requires <ArgumentException>(state.IsLocalAssignment(us), "stmt"); foreach (var item in us.Rhss) { int index = us.Rhss.IndexOf(item); Contract.Assert(us.Lhss.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.UpdateLocal(((NameSegment)us.Lhss[index]).Name, result); } } else if (exprRhs?.Expr is Dafny.LiteralExpr) { state.UpdateLocal(((NameSegment)us.Lhss[index]).Name, (Dafny.LiteralExpr)exprRhs?.Expr); } else { state.UpdateLocal(((NameSegment)us.Lhss[index]).Name, exprRhs?.Expr); } } yield return(state.Copy()); }
public static IEnumerable <ProofState> EvalStep(ProofState state) { Contract.Requires <ArgumentNullException>(state != null, "state"); // one step // call the IEnumerable <ProofState> enumerable = null; var stmt = state.GetStmt(); if (stmt is TacticVarDeclStmt) { enumerable = RegisterVariable(stmt as TacticVarDeclStmt, state); } else if (stmt is UpdateStmt) { var us = stmt as UpdateStmt; if (state.IsLocalAssignment(us)) { enumerable = UpdateLocalValue(us, state); } else if (state.IsArgumentApplication(us)) { //TODO: argument application } else if (state.IsTacticCall(us)) { enumerable = ApplyNestedTactic(state.Copy(), state.DafnyVars(), us); } } else if (stmt is AssignSuchThatStmt) { enumerable = EvaluateSuchThatStmt((AssignSuchThatStmt)stmt, state); } else if (stmt is PredicateStmt) { enumerable = ResolvePredicateStmt((PredicateStmt)stmt, state); } else if (stmt is TStatement || stmt is IfStmt || stmt is WhileStmt) { //TODO: } else { enumerable = DefaultAction(stmt, state); } foreach (var item in enumerable) { yield return(item.Copy()); } }
private static IEnumerable<ProofState> UpdateLocalValue(UpdateStmt us, ProofState state) { Contract.Requires<ArgumentNullException>(us != null, "stmt"); Contract.Requires<ArgumentNullException>(state != null, "state"); Contract.Requires<ArgumentException>(state.IsLocalAssignment(us), "stmt"); foreach (var item in us.Rhss) { int index = us.Rhss.IndexOf(item); Contract.Assert(us.Lhss.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.UpdateLocal(((NameSegment)us.Lhss[index]).Name, result); } } else if (exprRhs?.Expr is Dafny.LiteralExpr) { state.UpdateLocal(((NameSegment)us.Lhss[index]).Name, (Dafny.LiteralExpr)exprRhs?.Expr); } else { state.UpdateLocal(((NameSegment)us.Lhss[index]).Name, exprRhs?.Expr); } } yield return state.Copy(); }
public static IEnumerable<ProofState> EvalStep(ProofState state) { Contract.Requires<ArgumentNullException>(state != null, "state"); // one step // call the IEnumerable<ProofState> enumerable = null; var stmt = state.GetStmt(); if (stmt is TacticVarDeclStmt) { enumerable = RegisterVariable(stmt as TacticVarDeclStmt, state); } else if (stmt is UpdateStmt) { var us = stmt as UpdateStmt; if (state.IsLocalAssignment(us)) { enumerable = UpdateLocalValue(us, state); } else if (state.IsArgumentApplication(us)) { //TODO: argument application } else if (state.IsTacticCall(us)) { enumerable = ApplyNestedTactic(state.Copy(), state.DafnyVars(), us); } } else if (stmt is AssignSuchThatStmt) { enumerable = EvaluateSuchThatStmt((AssignSuchThatStmt)stmt, state); } else if (stmt is PredicateStmt) { enumerable = ResolvePredicateStmt((PredicateStmt)stmt, state); } else if (stmt is TStatement || stmt is IfStmt || stmt is WhileStmt) { //TODO: } else { enumerable = DefaultAction(stmt, state); } foreach (var item in enumerable) yield return item.Copy(); }
public static IEnumerable<ProofState> EvalStep(ProofState state) { Contract.Requires<ArgumentNullException>(state != null, "state"); IEnumerable<ProofState> enumerable = null; var stmt = state.GetStmt(); //if the current frame is a control flow, e.g. match, no need to get stmt if(FlowControlMng.IsFlowControlFrame(state)) { enumerable = FlowControlMng.EvalNextControlFlow(stmt, state); } else { if(stmt is TacticVarDeclStmt) { enumerable = RegisterVariable(stmt as TacticVarDeclStmt, state); } else if(stmt is UpdateStmt) { var us = stmt as UpdateStmt; if(state.IsLocalAssignment(us)) { enumerable = UpdateLocalValue(us, state); } else if(state.IsArgumentApplication(us)) { //TODO: argument application ?? } else if(state.IsTacticCall(us)){ enumerable = EvalTacApp(us, state); } else { // apply atomic string sig = Util.GetSignature(us); //Firstly, check if this is a projection function var types = Assembly.GetAssembly(typeof(Atomic.Atomic)) .GetTypes() .Where(t => t.IsSubclassOf(typeof(Atomic.Atomic))); foreach(var fType in types) { var porjInst = Activator.CreateInstance(fType) as Atomic.Atomic; if(sig == porjInst?.Signature) { //TODO: validate input countx enumerable = porjInst?.Generate(us, state); } } } } else if(stmt is AssignSuchThatStmt) { enumerable = EvalSuchThatStmt((AssignSuchThatStmt)stmt, state); } else if(stmt is PredicateStmt) { enumerable = EvalPredicateStmt((PredicateStmt)stmt, state); } else if(FlowControlMng.IsFlowControl(stmt)) { if(stmt is TacnyCasesBlockStmt) { enumerable = new Match().EvalInit(stmt, state); } //TODO: to implement if and while control flow } else { enumerable = DefaultAction(stmt, state); } } foreach(var item in enumerable) yield return item.Copy(); }
public static IEnumerable <ProofState> EvalStep(ProofState state) { Contract.Requires <ArgumentNullException>(state != null, "state"); IEnumerable <ProofState> enumerable = null; var stmt = state.GetStmt(); //if the current frame is a control flow, e.g. match, no need to get stmt if (FlowControlMng.IsFlowControlFrame(state)) { enumerable = FlowControlMng.EvalNextControlFlow(stmt, state); } else { if (stmt is TacticVarDeclStmt) { enumerable = RegisterVariable(stmt as TacticVarDeclStmt, state); } else if (stmt is UpdateStmt) { var us = stmt as UpdateStmt; if (state.IsLocalAssignment(us)) { enumerable = UpdateLocalValue(us, state); } else if (state.IsArgumentApplication(us)) { //TODO: argument application ?? } else if (state.IsTacticCall(us)) { enumerable = EvalTacApp(us, state); } else { // apply atomic string sig = Util.GetSignature(us); //Firstly, check if this is a projection function var types = Assembly.GetAssembly(typeof(Atomic.Atomic)) .GetTypes() .Where(t => t.IsSubclassOf(typeof(Atomic.Atomic))); foreach (var fType in types) { var porjInst = Activator.CreateInstance(fType) as Atomic.Atomic; if (sig == porjInst?.Signature) { //TODO: validate input countx enumerable = porjInst?.Generate(us, state); } } } } else if (stmt is AssignSuchThatStmt) { enumerable = EvalSuchThatStmt((AssignSuchThatStmt)stmt, state); } else if (stmt is PredicateStmt) { enumerable = EvalPredicateStmt((PredicateStmt)stmt, state); } else if (FlowControlMng.IsFlowControl(stmt)) { if (stmt is TacnyCasesBlockStmt) { enumerable = new Match().EvalInit(stmt, state); } //TODO: to implement if and while control flow } else { enumerable = DefaultAction(stmt, state); } } foreach (var item in enumerable) { yield return(item.Copy()); } }