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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

definition of the expressions we are allowed to write down.<br />

Constructor Terms with Variables<br />

Wait a minute!: what are these rules in abstract procedures?<br />

Answer: pairs of constructor terms (really constructor terms?)<br />

Idea: variables stand for arbitrary constructor terms (let’s make this formal)<br />

Definition 145 Let 〈S0 , D〉 be an abstract data type. A (constructor term) variable is a<br />

pair of a symbol and a base sort. E.g. xA, nN1 , xC3,. . . .<br />

Definition 146 We denote the current set of variables of sort A with VA, and use V :=<br />

<br />

A∈S 0 VA for the set of all variables.<br />

Idea: add the following rule to the definition of constructor terms<br />

variables of sort A ∈ S 0 are constructor terms of sort A.<br />

Definition 147 If t is a constructor term, then we denote the set of variables occurring in<br />

t with free(t). If free(t) = ∅, then we say t is ground or closed.<br />

c○: Michael Kohlhase 92<br />

To have everything at hand, we put the whole definition onto one slide.<br />

Constr. Terms with Variables: The Complete Definition<br />

Definition 148 Let 〈S 0 , D〉 be an abstract data type and V a set of variables, then we call<br />

a representation t a constructor term (with variables from V) of sort T, iff<br />

T ∈ S 0 and [t: T] ∈ D, or<br />

t ∈ VT is a variable of sort T ∈ S 0 , or<br />

T = A × B and t is of the form 〈a, b〉, where a and b are constructor terms with variables<br />

of sorts A and B, or<br />

t is of the form c(a), where a is a constructor term with variables of sort A and there is<br />

a constructor declaration [c: A → T] ∈ D.<br />

We denote the set of all constructor terms of sort A with TA(A; V) and use T (A; V) :=<br />

<br />

A∈S TA(A; V).<br />

c○: Michael Kohlhase 93<br />

Now that we have extended our model of terms with variables, we will need to understand how to<br />

use them in computation. The main intuition is that variables stand for arbitrary terms (of the<br />

right sort). This intuition is modeled by the action of instantiating variables with terms, which in<br />

turn is the operation of applying a “substitution” to a term.<br />

Substitutions<br />

Substitutions are very important objects for modeling the operational meaning of variables: applying<br />

a substitution to a term instantiates all the variables with terms in it. Since a substitution<br />

only acts on the variables, we simplify its representation, we can view it as a mapping from variables<br />

to terms that can be extended to a mapping from terms to terms. The natural way to define<br />

substitutions would be to make them partial functions from variables to terms, but the definition<br />

below generalizes better to later uses of substitutions, so we present the real thing.<br />

51

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

Saved successfully!

Ooh no, something went wrong!