The Lumenary · First-year graduate
Formal methods
Name: ______________________
Date: ______________________
You will learn to
- Give a big-step operational semantics for a small imperative language and prove properties such as determinism by induction on derivations
- State the rules of Hoare logic, prove their soundness, and verify a loop program with an invariant and a variant
- Model-check finite transition systems against CTL formulas by fixed-point iteration, and explain the cost of the labelling algorithm
- Prove type soundness by progress and preservation, and explain what it does and does not guarantee
- Explain what a verification result is relative to — its specification, semantics and trusted base — and why Rice's theorem rules out full automation
- 1.
Which of these are valid partial-correctness triples over the integers? (Choose all that apply.)
- A.
- B.
- C.
- D.
- 2.
Compute . It has the form . What is ?
- 3.
The program should satisfy . Which loop invariant lets the loop rule and the rule of consequence prove this?
- A.
- B.
- C.
- D.
- 4.
In the soundness proof of Hoare logic, the loop case is proved by induction on the derivation of . Why would structural induction on the command not work?
- A.The premise of the rule for contains the same loop , which is not a smaller command.
- B.Because loops might not terminate.
- C.Because the invariant may mention variables not assigned in the loop.
- D.Because the rule of consequence is not syntax-directed.
- 5.
Which CTL formula says: from every reachable state it is possible to get back to an initial state (a "reset" property)?
- A.
- B.
- C.
- D.
- 6.
A Kripke structure has states and transitions , , , , , . The proposition holds only in state . Compute by the iteration , . How many states satisfy ?
- 7.
Programs are written in a Turing-complete language. Which of these problems are undecidable? (Choose all that apply.)
- A.Given a program P, does P halt on input 0?
- B.Given a program P, does P compute a total function?
- C.Given a program P, does its source text contain a while loop?
- D.Given a finite Kripke structure and a state, does hold?
- E.Given P, does P output 1 on every input 0, …, 10 within a million steps?
- 8.
Which Lean definition correctly formalises the partial-correctness triple , where
BigStep c s tmeans thatcrun fromsterminates int?- A.
∀ s t, P s → BigStep c s t → Q t - B.
∀ s, P s → ∃ t, BigStep c s t ∧ Q t - C.
∃ s t, P s ∧ BigStep c s t ∧ Q t - D.
∀ s t, Q t → BigStep c s t → P s
- A.
- 9.
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.)
- A.The formal semantics of the source language differs from what programmers (or the standard) expect.
- B.An unverified parser or assembler used around the verified core has a bug.
- C.The processor does not implement its instruction set as the assembly semantics says.
- D.One of the verified optimisation passes contains an error in its proof.
- 10.
Write
find_violation(initial, successors, is_bad)for explicit-state model checking of a safety property.successors(s)returns a list of states andis_bad(s)a boolean. Return a shortest path[initial, ..., bad_state]to a reachable bad state, orNoneif no reachable state is bad. Your search must terminate on finite systems with cycles.Computational — Practice