Preconditions and Postconditions

Preconditions and postconditions state what must be true before an event, action or program step can occur and what is true once it has finished.

Status
Published, version 1.0.1
Last reviewed
22 Nov 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Preconditions and Postconditions in Process Representation

A precondition says what has to be the case before something can happen, and a postcondition says what is the case after it has happened. In knowledge representation the pair is attached to a type of event, so that an event such as starting a new treatment line can occur only in certain states and always leaves certain others behind. In many health economic models a patient switches therapy only after progression, and a model cycle should leave the cohort the same size. Stated conditions let a modeller check each step and let software work out which events can come next.

Who uses the terms and how

The terms come from computer science and knowledge representation. In his paper Processes and Causality, John Sowa calls the input state types of an event type its preconditions and the output state types its postconditions. C. A. R. Hoare's 1969 paper links a precondition, a program and a description of its result. The health economics sources cited here describe events and checks that do this job without the terms.

Event signatures in Sowa's account of processes

Sowa represents a discrete process as a directed acyclic graph in which every arc links a state to an event or an event to a state. States leading into an event are its input states, and those following are its output states. Each event type carries a signature.

σ(p)=⟨Prep,Postp⟩\sigma(p) = \langle \mathrm{Pre}_p, \mathrm{Post}_p \rangle

where σ(p)\sigma(p) is the signature of event type pp, Prep\mathrm{Pre}_p is the ordered list of nn state types that must be true of the input states of any event of type pp, and Postp\mathrm{Post}_p is the ordered list of mm state types that must be true of its output states.

The state and event types sit in a partially ordered generalisation hierarchy. Sowa's axiom of event signatures requires a more specialised event type to have at least as many preconditions and postconditions as a more general one, each implying the corresponding condition of the general type, so selling may carry more conditions than giving. In a Petri net, Sowa writes, the precondition of a transition is the conjunction of the conditions of its input places and its postcondition the conjunction of those of its output places.

Preconditions and postconditions in programs and plans

Hoare introduced a notation for proving programs correct. In it the program sits between two assertions.

P {Q} RP \, \{Q\} \, R

where PP is the precondition, an assertion about the variables before the program starts, QQ is the program, and RR is an assertion about the result. Hoare reads the formula as saying that if PP is true before QQ starts, then RR will be true on its completion.

The STRIPS planner of Fikes and Nilsson applies an operator to a world model only when an instance of its precondition, a formula schema of first-order predicate logic, can be proved from the model, and it records the effects as a delete list and an add list of clauses. Design by contract, as documented for Eiffel, turns the pair into an agreement. The caller must meet the precondition and gains what the postcondition promises, so a broken precondition places the fault with the caller and a broken postcondition with the routine.

Uses in health economic models

A treatment line in a treatment sequence model can be read as an event type with a signature. In an illustrative oncology model, starting second-line therapy has the preconditions that the patient is alive, has progressed on first-line therapy and meets the eligibility rule for the next drug, and the postconditions that first-line therapy has stopped and second-line therapy has begun. The ISPOR-SMDM report on discrete event simulation by Karnon and colleagues counts clinical decisions such as a change in dose among model events, and says that an entity's attributes may determine how it responds to a given set of circumstances. In the wiki's reading, the attribute tests that allow an event are its preconditions and the attribute updates are its postconditions.

The same pair describes one step of a cohort model. The TECH-VER checklist of Büyükkaramikli and colleagues asks for checks that all probabilities and numbers of patients in a state are greater than or equal to 0, that all probabilities are at most 1, and that the numbers in all health states add up to the cohort size. Read through Hoare's notation, the probability checks act as preconditions of a cycle and the state count checks as postconditions. TECH-VER lists them among its black-box tests for technical verification. Eric Evans's assertions pattern asks for post-conditions of operations to be stated, and the wiki's pages on invariants and domain services apply it to model runs.

Event signatures in RHEO

The Real Health Economics Ontology (RHEO), at healtheconomics.wiki/ontologies/rheo, has a class clinical event type specification (RHEO_0000005) for a kind of clinical event, such as disease progression or stroke. Its relations has from state (RHEO_1000083) and has to state (RHEO_1000084) link such a specification to the state the event starts from and the state it leads to, each a state description (RHEO_0000064). The wiki reads these as a signature with one precondition and one postcondition, although RHEO does not use those words.

Worked example with a second-line switch in a cohort

All numbers are illustrative. At the start of a cycle a cohort of 1,000 people holds 600 in first-line stable disease, 250 progressed on first line, 100 on second line, none on best supportive care and 50 dead. A cohort cannot test each person's eligibility, so the switch event has the precondition that a person is progressed on first line, and 80% of those people meet the eligibility rule, the rest moving to best supportive care.

m=e×nP1m = e \times n_{P1}

where mm is the number who start second-line therapy, ee is the proportion meeting the eligibility rule, and nP1n_{P1} is the number progressed on first line before the event.

Step 1. Check the precondition. Only the 250 people progressed on first line qualify, so nP1n_{P1} = 250.

Step 2. Apply the event. The number switching is 0.8 × 250 = 200, and 250 − 200 = 50 move to best supportive care.

Step 3. Check the postconditions. No one remains progressed on first line, second line now holds 100 + 200 = 300, and the total is 600 + 0 + 300 + 50 + 50 = 1,000, as before.

Step 4. Catch a faulty step. Code that wrongly applied the eligibility proportion to all 950 people alive, while still emptying the progressed state and sending 50 to best supportive care, would move 0.8 × 950 = 760 people, giving 100 + 760 = 860 on second line and a total of 600 + 0 + 860 + 50 + 50 = 1,560. The postcondition on the total fails, so the error is caught before 560 extra starters are costed.

Where the idea ends and neighbouring ideas begin

A precondition or postcondition belongs to one event or operation, whereas an invariant must hold of an object between any two operations, so an invariant of the transition matrix also acts as a precondition of every cycle. A precondition says whether an event can happen in a state, while a state-transition model gives the probability that it does happen. Which real occurrences count as the event is settled by an event definition, not by the signature, which decides which states the event type connects. Sowa writes that the state types tied to an event type may be causes or preconditions of the event, and the wiki keeps the two words apart, since a cause is what brings an event about.

Common misreadings

For preconditions, specialisation runs in opposite directions in the two traditions. In Sowa's hierarchy a more specialised event type has preconditions and postconditions at least as strong as the general type's, while the Eiffel documentation lets a redefined routine in a descendant class only weaken its precondition, although its postcondition, as in Sowa, can only become stronger. Sowa's rule concerns kinds of event, and Eiffel's concerns when one routine can stand in for another. A proof of a Hoare formula also gives no assurance that a step finishes, since Hoare's result assertion holds only if the program terminates.

Sources

Frequently Asked Questions (6)

  • What is Preconditions and Postconditions?

    Preconditions and postconditions state what must be true before an event, action or program step can occur and what is true once it has finished.

    Source: Sowa 2000

  • How does John Sowa define the preconditions and postconditions of an event type?

    In his paper Processes and Causality, John Sowa represents a discrete process as a graph whose nodes are states and events. Every event type has a fixed number of input state types, called its preconditions, and of output state types, called its postconditions, and the list of both is the signature of the event type. The preconditions must be true of the input states of any event of that type, and the postconditions must be true of its output states. A more specialised event type may carry more preconditions and postconditions than a general one, and each of them implies the corresponding condition of the general type.

    Source: Sowa 2000

  • What does the Hoare notation P {Q} R say about preconditions and postconditions?

    C. A. R. Hoare introduced the notation in 1969 to link a precondition P, a program Q and an assertion R that describes the result of running the program. He read the formula as saying that if P is true before Q starts, then R will be true when Q completes, and he said the treatment was due mainly to Floyd. The assertion R plays the part that later sources, such as the Eiffel documentation, call the postcondition. Hoare added that his axioms and rules give no basis for a proof that a program terminates, so the formula states only conditional correctness, holding provided that the program finishes.

    Source: Hoare 1969

  • How do preconditions and postconditions work in the STRIPS planner?

    The STRIPS planner of Fikes and Nilsson, described in 1971, represents a world model as a set of formulas of the first-order predicate calculus. Each operator has a precondition, stated as a formula schema, and the operator can be applied to a model only when an instance of that schema can be proved from the model. Its effects are given by two lists, a delete list of clauses that may no longer be true and an add list of clauses that become true. With preconditions and these effect lists, the planner searches for a sequence of operators that turns the initial world model into one in which the goal can be proved.

    Source: Fikes and Nilsson 1971

  • How does design by contract use preconditions and postconditions?

    In design by contract, as documented for the Eiffel language, each routine can carry one precondition, introduced by the keyword require, and one postcondition, introduced by the keyword ensure. The precondition states what must be true for the routine to have a chance of working correctly, and the postcondition states what will be true if the routine works correctly. The documentation treats the pair as a contract in which the client's obligations come from the precondition and its benefits from the postcondition. Faults are assigned the same way, so a violated precondition indicates a fault in the client and a violated postcondition a fault in the supplier.

    Source: Eiffel Software n.d.

  • How can preconditions and postconditions help verify a cohort model in health economics?

    The TECH-VER checklist of Büyükkaramikli and colleagues does not use the terms, but several of its black-box tests can be read as preconditions and postconditions of a model cycle. It asks for checks that all probabilities and numbers of patients in a state are greater than or equal to 0, that all probabilities are at most 1, and that the numbers in all health states add up to the cohort size. Read this way, the probability checks guard the start of a cycle and the count checks test its result. The paper also suggests a macro that stops a probabilistic analysis when an error such as a negative transition probability is detected.

    Source: Büyükkaramikli et al. 2019

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 22 Nov 2026

Content version: 1.0.1

Canonical Identity

Term code
HS-HP-DH-187

Stable URI · Machine-readable · Resolvable · CC BY 4.0

This article is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/concept/preconditions-and-postconditions