ArticleslgStudy

computer science

Safety and liveness properties

Safety and liveness properties is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Safety and liveness properties rather than just read about it. In short: Properties of an execution of a computer program—particularly for concurrent and distributed systems—have long been formulated by giving safety properties ("bad things don't happen") and liveness properties ("good things do happen"). A program is totally correct with respect to a precondition P {\displaystyle P} and postcondition Q {\displaystyle Q} if any execution started in a state satisfying P {\displaystyle P}…

Key takeaways

  • Safety and liveness properties belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Safety and liveness properties to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Safety and liveness properties from memory before moving on to harder problems.

Reference excerpt

Properties of an execution of a computer program—particularly for concurrent and distributed systems—have long been formulated by giving safety properties ("bad things don't happen") and liveness properties ("good things do happen"). A program is totally correct with respect to a precondition P {\displaystyle P} and postcondition Q {\displaystyle Q} if any execution started in a state satisfying P {\displaystyle P} terminates in a state satisfying Q {\displaystyle Q} . Total correctness is a conjunction of a safety property and a liveness property:

The safety property prohibits these "bad things": executions that start in a state satisfying P {\displaystyle P} and terminate in a final state that does not satisfy Q {\displaystyle Q} . For a program C {\displaystyle C} , this safety property is usually written using the Hoare triple { P } C { Q } {\displaystyle \{P\}C\{Q\}} . The liveness property, the "good thing", is that execution that starts in a state satisfying P {\displaystyle P} terminates. Note that a bad thing is discrete, since it happens at a particular place during execution. A "good thing" need not be discrete, but the liveness property of termination is discrete. Formal definitions that were ultimately proposed for safety properties and liveness properties demonstrated that this decomposition is not only intuitively appealing but is also complete: all properties of an execution are a conjunction of safety and liveness properties. Moreover, undertaking the decomposition can be helpful, because the formal definitions enable a proof that different methods must be used for verifying safety properties versus for verifying liveness properties.

Safety A safety property proscribes discrete bad things from occurring during an execution. A safety property thus characterizes what is permitted by stating what is prohibited. The requirement that the bad thing be discrete means that a bad thing occurring during execution necessarily occurs at some identifiable point. Examples of a discrete bad thing that could be used to define a safety property include:

An execution that starts in a state satisfying a given precondition terminates, but the final state does not satisfy the required postcondition; An execution of two concurrent processes, where the program counters for both processes designate statements within a critical section; An execution of two concurrent processes where each process is waiting for another to change state (known as deadlock). An execution of a program can be described formally by giving the infinite sequence of program states that results as execution proceeds, where the last state for a terminating program is repeated infinitely. For a program of interest, let S {\displaystyle S} denote the set of possible program states, S ∗ {\displaystyle S^{*}} denote the set of finite sequences of program states, and S ω {\displaystyle S^{\omega }} denote the set of infinite sequences of program states. The relation σ ≤ τ {\displaystyle \sigma \leq \tau } holds for sequences σ {\displaystyle \sigma } and τ {\displaystyle \tau } iff σ {\displaystyle \sigma } is a prefix of τ {\displaystyle \tau } or σ {\displaystyle \sigma } equals τ {\displaystyle \tau } . A property of a program is the set of allowed executions. The essential characteristic of a safety property S P {\displaystyle SP} is: If some execution σ {\displaystyle \sigma } does not satisfy S P {\displaystyle SP} then the defining bad thing for that safety property occurs at some point in σ {\displaystyle \sigma } . Notice that after such a bad thing, if further execution results in an execution

σ ′ {\displaystyle \sigma ^{\prime }} , then σ ′ {\displaystyle \sigma ^{\prime }} also does not satisfy S P {\displaystyle SP} , since the bad thing in σ {\displaystyle \sigma } also occurs in σ ′ {\displaystyle \sigma ^{\prime }} . We take this inference about the irremediability of bad things to be the defining characteristic for S P {\displaystyle SP} to be a safety property. Formalizing this in predicate logic gives a formal definition for S P {\displaystyle SP} being a safety property.

∀ σ ∈ S ω : σ ∉ S P ⟹ ( ∃ β ≤ σ : ( ∀ τ ∈ S ω : β τ ∉ S P ) ) {\displaystyle \forall \sigma \in S^{\omega }:\sigma \notin SP\implies (\exists \beta \leq \sigma :(\forall \tau \in S^{\omega }:\beta \tau \notin SP))}

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Safety and liveness properties

Start with the simplest possible case. Write down what Safety and liveness properties claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Safety and liveness properties before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Safety and liveness properties ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Safety and liveness properties

In research
Safety and liveness properties appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Safety and liveness properties in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Safety and liveness properties is common in secondary-school and first-year university syllabi. It links to neighbouring topics Concurrent computing, Model checking, Theoretical computer science, so understanding it makes those chapters shorter.
In everyday life
Look for Safety and liveness properties outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Safety and liveness properties” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Safety and liveness properties in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Safety and liveness properties means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Safety and liveness properties out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Safety and liveness properties in simple terms?

Properties of an execution of a computer program—particularly for concurrent and distributed systems—have long been formulated by giving safety properties ("bad things don't happen") and liveness properties ("good things do happen"). A program is totally correct with respect to a precondition P {\d…

Why does Safety and liveness properties matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Safety and liveness properties?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Safety and liveness properties.

Tags

  • Concurrent computing
  • Model checking
  • Theoretical computer science

Keep exploring