Prolog is one of the best-known logic programming languages and suitable for implementing an inference engine for agents. However, Prolog does not take into account the dynamic nature of agents such as knowledge acquisition and action execution. This poses a problem because the agent might work in a dynamic environment where unexpected things can happen. In order to use a Prolog-like procedure as an inference engine of an agent, the procedure should be able to modify the computation, if necessary, after updating the program or executing an action. We introduce a new Prolog-like procedure which integrates planning, action execution, program updates, and plan modifications. Our new procedure computes plans by abduction. During or after a computation, it can update a program by adding a rule to the program or deleting a rule from the program. After updating the program, it modifies the computation, cuts invalid plans, and adds new valid plans. We use the technique of Dynamic SLDNF (DSLDNF) [1][2] to modify computation after updating a program. It is also possible to execute an action during or after planning. We can use three types of actions: an action without a side effect; an action with a side effect which can be undone; an action with a side effect which cannot be undone. Following the result of action execution, the procedure modifies the computation: invalid plans are erased; some actions are undone; some redundant actions are erased. Even if a plan becomes invalid, it is possible to switch to another plan without loss of correctness.