• Keine Ergebnisse gefunden

University of Kaiserslautern Department of Computer Science Software Technology Group

N/A
N/A
Protected

Academic year: 2022

Aktie "University of Kaiserslautern Department of Computer Science Software Technology Group"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. Dr. A. Poetzsch-Heffter Dipl.-Inf. P. Michel

Dipl.-Inf. C. Feller

University of Kaiserslautern

Department of Computer Science Software Technology Group

Exercise Sheet 7: Specification and Verification with Higher-Order Logic (Summer Term 2012)

Date: 13.06.2012

Exercise 1 Case Study: Quicksort

In the lecture you have seen an elegant way to specify and prove quicksort (see “QuickSort.thy”).

The file “EQSort.thy” contains another – more efficient – version of quicksort, which calculates the split with the pivot element in one pass through the list. The file also contains all specifications and proofs for its correctness.

a) Go through theefficientversion of the specification, model and proof and compare them to the elegant one. In particular, note how the splitting is done and what that means for the proofs.

b) Download the theory “RQSort.thy” – which stands for refined quicksort – in which you prove the correctness of theefficientquicksort. To achieve this,

1. prove that the efficient version of quicksort is equivalent to the elegant one and then 2. prove the two main properties by using the theorems from the elegant version.

Exercise 2 Case Study: Mergesort

In this exercise we take a look at another sorting algorithm, namelymergesort. We are thereby changing the model, but keep the properties we already specified and validated for quicksort.

Download the “MSort.thy” theory from our website, which contains all the necessary definitions and pro- perties.

Complete all the missing proofs and find the necessary helper lemmas, which capture the basic ideas of the algorithm.

(2)

Exercise 3 Inductive Definitions, Lattices and Fixpoints

This exercise is meant to deepen your understanding of inductive sets and the theory they are based on. You should do all of the following assignmentson paperonly.

a) (Prepare!) Define the reflexive, transitive closure of a relationras inductive set.

b) (Prepare!) Define a function whose least fixpoint is the aforementioned set.

c) (Prepare!) To get to know the definitions of lattice, complete lattice, supremum, infimum, etc. it is useful to do some proofs of simple properties involving them. For example, you should be able to do the following proofs:

1. LetP(S)be the power set of a set S. Proof that(P(S),⊆)is a complete lattice.

2. Proof that every closed interval (Def. I) of a complete lattice is a complete lattice.

3. The definition ofcomplete latticefrom the slides is not actually based onlattices, but on partially ordered sets. Look at the definition of lattices based on partial orders (Def. L1) and convince yourself that every complete lattice is also a lattice.

4. An equivalent definition of lattice from algebra (Def. L2) is not based on partial orders. Proof that you can define such a lattice(S,∧,∨)for every complete lattice(S,≤).

5. Proof that for every lattice (Def. L2) both operations are idempotent (x∧x=x and x∨x=x).

Definitions:

(I) Let(S,≤)be a partial order. Theclosed intervalfora, b∈Sis defined as:[a, b] :={x. a≤x≤b}

(L1) A partially ordered set(S,≤)is alatticeiff

∀x, y∈S :{x, y}has both a supremum and an infimum inS The normal notation for these two elements isa∨banda∧b, respectively.

(L2) A set(S,∧,∨)with two inner binary operations∧and∨is alatticeiff both operations are associa- tive, commutative and are connected by the absorption law (x∧(x∨y) =x and x∨(x∧y) =x).

Referenzen

ÄHNLICHE DOKUMENTE

b) Create a new theory “RQSort.thy” – which stands for refined quicksort – in which you prove the cor- rectness of the efficient quicksort by proving an equivalence to the

The main goal is to model the setting described in the paper as state transition system. Using this model, it should be possible to specify and prove properties about the

The Ministers noted a number of significant achievements with realignment initiatives since the last SCC meeting in June 2011, including: progress in the environmental

Download the file Sheet4_exprsimp.hs from the website. This Haskell program parses expressions given by the user and simplifies them. You do not have to understand the other parts

b) We now want to proof a more general property of this program which is not fixed to vn being 3. As the first step towards this goal, prove that the execution of the loop body adds

Exercise Sheet 6: Specification and Verification with Higher-Order Logic (Summer Term 2012)..

c) Optimize your proof by using the custom wphoare method, like done in the splitcorrect lemmas... d) The splitcorrect lemma does not prove that split does not change the content of

In a software project, the classes Person, AgePerson und AgeManager were implemented; their source is given in Figure 1... a) For testing purposes, the following code