15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Axiom 134 equality on ground constructor terms is trivial<br />

Axiom 135 only ground constructor terms of sort T are in T (induction axioms)<br />

c○: Michael Kohlhase 88<br />

Example 136 (An Abstract Data Type of Truth Values) We want to build an abstract<br />

data type for the set {T, F } of truth values and various operations on it: We have looked at the abbreviations<br />

∧, ∨, ¬, ⇒ for “and”, “or”, “not”, and “implies”. These can be interpreted as functions<br />

on truth values: e.g. ¬(T ) = F , . . . . We choose the abstract data type 〈{B}, {[T : B], [F : B]}〉,<br />

and have the abstract procedures<br />

∧ : 〈∧::B × B → B ; {∧(T, T ) T , ∧(T, F ) F , ∧(F, T ) F , ∧(F, F ) F }〉.<br />

∨ : 〈∨::B × B → B ; {∨(T, T ) T , ∨(T, F ) T , ∨(F, T ) T , ∨(F, F ) F }〉.<br />

¬ : 〈¬::B → B ; {¬(T ) F , ¬(F ) T }〉,<br />

Now that we have established how to represent data, we will develop a theory of programs, which<br />

will consist of directed equations in this case. We will do this as theories often are developed;<br />

we start off with a very first theory will not meet the expectations, but the test will reveal how<br />

we have to extend the theory. We will iterate this procedure of theorizing, testing, and theory<br />

adapting as often as is needed to arrive at a successful theory.<br />

A First Abstract Interpreter<br />

Let us now come up with a first formulation of an abstract interpreter, which we will refine later<br />

when we understand the issues involved. Since we do not yet, the notions will be a bit vague for<br />

the moment, but we will see how they work on the examples.<br />

But how do we compute?<br />

Problem: We can define functions, but how do we compute them?<br />

Intuition: We direct the equations (l2r) and use them as rules.<br />

Definition 137 Let A be an abstract data type and s, t ∈ T g<br />

T (A) ground constructor terms<br />

over A, then we call a pair s t a rule for f, if head(s) = f.<br />

Example 138 turn λ(nil) = o and λ(cons(n, l)) = s(λ(l))<br />

to λ(nil) o and λ(cons(n, l)) s(λ(l))<br />

Definition 139 Let A := 〈S 0 , D〉, then call a quadruple 〈f::A → R ; R〉 an abstract procedure,<br />

iff R is a set of rules for f. A is called the argument sort and R is called the result<br />

sort of 〈f::A → R ; R〉.<br />

Definition 140 A computation of an abstract procedure p is a sequence of ground constructor<br />

terms t1 t2 . . . according to the rules of p. (whatever that means)<br />

Definition 141 An abstract computation is a computation that we can perform in our<br />

heads. (no real world constraints like memory size, time limits)<br />

Definition 142 An abstract interpreter is an imagined machine that performs (abstract)<br />

computations, given abstract procedures.<br />

c○: Michael Kohlhase 89<br />

49

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!