  This paper adds counterfactuals to the framework of knowledge-based programs
of Fagin, Halpern, Moses, and Vardi. The use of counterfactuals is illustrated
by designing a protocol in which an agent stops sending messages once it knows
that it is safe to do so. Such behavior is difficult to capture in the original
framework because it involves reasoning about counterfactual executions,
including ones that are not consistent with the protocol. Attempts to formalize
these notions without counterfactuals are shown to lead to rather
counterintuitive behavior.
