Skip to content
The Lumenary

Practice · First-year graduate

Formal methods

Formal methods

Warm-upHuman

Which of these are valid partial-correctness triples over the integers? (Choose all that apply.)

Choose all that apply

Formal methods

Warm-upHuman

Compute wp(y:=x+3; z:=2y,   z=20)\mathrm{wp}(y := x + 3;\ z := 2y,\ \; z = 20). It has the form x=nx = n. What is nn?

Formal methods

CoreHuman

The program s:=0; i:=0; while i<n do (i:=i+1; s:=s+i)s := 0;\ i := 0;\ \mathtt{while}\ i \lt n\ \mathtt{do}\ (i := i + 1;\ s := s + i) should satisfy {n≥0} ⋅ {s=n(n+1)/2}\{n \ge 0\}\ \cdot\ \{s = n(n+1)/2\}. Which loop invariant lets the loop rule and the rule of consequence prove this?

Choose one

Formal methods

CoreHuman

In the soundness proof of Hoare logic, the loop case is proved by induction on the derivation of ⟨while b do c,s⟩⇓t\langle \mathtt{while}\ b\ \mathtt{do}\ c, s\rangle \Downarrow t. Why would structural induction on the command not work?

Choose one

Formal methods

CoreHuman

Which CTL formula says: from every reachable state it is possible to get back to an initial state (a "reset" property)?

Choose one

Formal methods

CoreComputational

A Kripke structure has states 1,…,61, \dots, 6 and transitions 1→21 \to 2, 2→32 \to 3, 3→33 \to 3, 4→54 \to 5, 5→45 \to 4, 6→16 \to 1. The proposition pp holds only in state 33. Compute EF p\mathsf{EF}\,p by the iteration Z0=∅Z_0 = \emptyset, Zk+1={3}∪pre(Zk)Z_{k+1} = \{3\} \cup \mathrm{pre}(Z_k). How many states satisfy EF p\mathsf{EF}\,p?

Formal methods

CoreHuman

Programs are written in a Turing-complete language. Which of these problems are undecidable? (Choose all that apply.)

Choose all that apply

Formal methods

CoreFormal

Which Lean definition correctly formalises the partial-correctness triple {P} c {Q}\{P\}\ c\ \{Q\}, where BigStep c s t means that c run from s terminates in t?

Choose one

Formal methods

CoreHuman

A compiler comes with a machine-checked proof that, whenever it succeeds, the generated assembly has only behaviours allowed by the source program, according to formal semantics of the source and assembly languages. Which of the following could still lead to a wrongly behaving executable? (Choose all that apply.)

Choose all that apply

Formal methods

StretchComputational

Write find_violation(initial, successors, is_bad) for explicit-state model checking of a safety property. successors(s) returns a list of states and is_bad(s) a boolean. Return a shortest path [initial, ..., bad_state] to a reachable bad state, or None if no reachable state is bad. Your search must terminate on finite systems with cycles.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.