Docsity

Initial Algebra in Equational Theory: Construction and Properties - Prof. Jose Meseguer, Study notes of Computer Science

Partial preview of the text

Download Initial Algebra in Equational Theory: Construction and Properties - Prof. Jose Meseguer and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 11

Jos´

e Meseguer

Computer Science Department

University of Illinois at Urbana-Champaign

1

Construction of the Initial Algebra

T

Σ

/E

T

Σ

is initial in the class

Alg

Σ

of

all

-algebras. We are

interested in a more general construction: an initial algebrain the class of all models of a given equational theory T

, E

. That is, of an initial algebra in the class,

Alg

(Σ

,E

)

{A ∈

Alg

Σ

| A |

E

We shall construct such an algebra, denoted

T

Σ

/E

, and show

that it is indeed initial in

Alg

(Σ

,E

)

, i.e., for any

A ∈

Alg

(Σ

,E

)

there is a unique

-homomorphism

eval

E A

T

Σ

/E

−→ A

.

Remark:

Maude functional modules of the form

fmod

, E

endfm

, have indeed an

initial algebra semantics

,

given by

T

Σ

/E

.

1

Construction of

T

Σ

/E

(III)

Note that

E

is indeed an equivalence relation because of

the

Reflexivity

,

Symmetry

and

Transitivity

rules in our

inference system. Denote by

T

Σ

/E,C

the quotient set

T

Σ

,C

E

.

We can then define the

S

-indexed family of sets

T

Σ

/E

T

Σ

/E,s

s

∈

S

, where, by definition,

T

Σ

/E,s

[

t

]

T

Σ

/E,C

t

′

t

′

[

t

]

t

′

T

Σ

,s

We now make

T

Σ

/E

into a

-algebra

T

Σ

/E

T

Σ

/E

, ι

T

Σ

/E

as

follows. We interpret a constant

a

nil

s

in

by its

equivalence class

[

a

]

, which obviously does not depend on

our choice of the subsort-overloaded declaration

a

nil

s

for

a

.

3

Construction of

T

Σ

/E

(IV)

Similarly, given

f

s

1

... s

n

s

in

, and given

[

t

i

]

T

Σ

/E,s

i

,

i

n

, we define

f

s

1

...s

n

,s

T

Σ

/E

([

t

1

]

[

t

n

]) = [

f

t

′ 1

,... , t

′ n

)]

where

t

′ i

[

t

i

]

t

′ i

T

Σ

,s

i

,

i

n

.

Checking that (assuming as always

sensible) the above

definition does not depend on either: (1) the choice of the t

′ i

[

t

i

]

, or (2) the choice of the subsort-overloaded operator

f

s

1

... s

n

s

in

, so that it is well-defined and indeed

defines a

-algebra is left as an easy exercise.

4

Initiality Theorem for

T

Σ

/E

(II)

Therefore, we can always choose a substitution

θ

X

T

Σ

such that

a

eval

T

Σ

/E

θ

. Therefore,

a

eval

T

Σ

/E

θ

. But

since

eval

T

Σ

/E

θ

η

X

eval

T

Σ

/E

θ

η

X

, By the Freeness

Theorem we have

eval

T

Σ

/E

θ

eval

T

Σ

/E

θ

. And therefore,

a

eval

T

Σ

/E

θ

(see diagram next page).

Therefore, our hypothesis that

a

u

i

a

v

i

,

i

n

,

exactly means that

[

θ

u

i

)] = [

θ

v

i

)]

,

i

n

, and by the

definition of

E

this exactly means that^ E

θ

u

i

θ

v

i

i

n,

which by

Modus ponens

yields

E

θ

t

θ

t

′

, that is,

a

t

a

t

′

. Therefore,

T

Σ

/E

E

.

6

Lifting of

a

to a Substitution

θ

X

T

Σ

/E

T

Σ

T

Σ(

X

)

P

P

P

P

P

P

P

P

P

P

P

P

P

P

P

  • Pq

a

θ

eval

T

Σ

/E

a η

X

θ

7

Initiality Theorem for

T

Σ

/E

(IV)

To show

existence

of

eval

E A

T

Σ

/E

−→ A

, given

[

t

]

T

Σ

/E,s

,

define

eval

E A

,s

[

t

] =

eval

A,s

t

′

, where

t

′

[

t

]

t

′

T

Σ

,s

. Then

show (exercise) that:

eval

E A

,s

[

t

]

is independent of the choice of

t

′

because

of

the hypothesis

A |

E

and the Soundness Theorem; and

the family of functions

eval

E A

eval

E A

,s

s

∈

S

thus defined

is indeed a

-homomorphism.

q.e.d.

9

The Mathematical and Operational Semantics Coincide

As stated in pg. 2, the semantics of a Maude functionalmodule

fmod

, E

endfm

is an

initial algebra semantics

, given

by

T

Σ

/E

. Let us call

T

Σ

/E

the module’s

mathematical

semantics

. This sematics does not depend on any

executability assumptions

about

fmod

, E

endfm

: it can be

defined for

any

equational theory

, E

.

Call

fmod

, E

endfm

admissible

if the equations

E

are

ground confluent, sort-decreasing, and terminating. Underthese executabilty requirements we have another semanticsfor

fmod

, E

endfm

: the canonical term algebra

C

Σ

/E

defined

in Lecture 3. This is the most intuitive computationalmodel for

fmod

, E

endfm

. Call it its

operational semantics

.

The beauty is that both semantics coincide!

10

The Canonical Term Algebra is Initial (II)

Let us see that

can

E

T

Σ

/E

−→ C

Σ

/E

is a

homomorphism

.

Preservation of constants is trivial. Let

f

s

1

... s

n

s

in

,

and

[

t

i

]

T

Σ

/E,s

i

,

i

n

. We must show,

can

E,s

f

s

1

...s

n

,s

T

Σ

/E

([

t

1

]

[

t

n

])) =

f

s

1

...s

n

,s

C

Σ

/E

can

E

t

1

,... , can

E

t

n

The key observation is that

can

E

t

i

T

Σ

,s

i

,

i

n

. This

is because:

by definition of

[

t

i

]

there must be a

t

′ i

E

t

i

with

t

′ i

T

Σ

,s

i

,

i

n

; and

by the sort-decreasingness assumption for

E

, since

t

′ i

∗

E

can

t

′ i

can

t

i

, if

t

′ i

T

Σ

,s

i

,

i

n

, then

can

E

t

i

T

Σ

,s

i

,

i

n

.

12

The Canonical Term Algebra is Initial (III)

Therefore, we have: can

E,s

f

s

1

...s

n

,s

T

Σ

/E

([

t

1

]

[

t

n

])) =

by definition of

f

s

1

...s

n

,s

T

Σ

/E

can

E,s

([

f

can

E

t

1

,... , can

E

t

n

))]) =

by definition of

can

E,s

can

E

f

can

E

t

1

,... , can

E

t

n

by definition of

f

s

1

...s

n

,s

C

Σ

/E

f

s

1

...s

n

,s

C

Σ

/E

can

E

t

1

,... , can

E

t

n

as desired.Checking that the inverse family of functions can

−

1

E

can

−

1

E,s

s

∈

S

defines also a

-homomorphism is easy.

For

f

s

1

... s

n

s

in

and

t

i

can

E

t

i

C

Σ

/E,s

i

,

i

n

we have,

13

Math.

Sems.

= Operatl.

Sems.:

An Example

The canonical term algebra

C

Σ

/E

is in some sense the

most

intuitive

representation of the initial algebra from a

computational point of view. Let us see in a simple examplewhat the coincidence beteen mathematical and operationalsemantics means.For example, the equations in the

NATURAL

module are

ground confluent and terminating. Its canonical forms

are

the natural numbers in Peano notation. And its operations are

the successor and addition functions.

Indeed, given two Peano natural numbers

n, m

the general

definition of

f

s

1

...s

n

,s

C

Σ

/E

specializes for

f

to the definition

of addition,

n

C

NATURAL

m

can

NATURAL

n

m

, so that

C

NATURAL

is

the addition function.

15

Math.

Sems.

= Operatl.

Sems.:

An Example (II)

T

Σ

NATURAL

/E

NATURAL

... ... ... ...

ppss

s

ss

s

s

s

ps

pss

psss

s

ss

...

C

Σ

NATURAL

/E

NATURAL

16

Verification of Maude Functional Modules

We are now ready to begin discussing program verificationfor

deterministic declarative programs

, and, more

specifically, for

functional modules in Maude

. of the form

fmod

, E

A

endfm

, where we assume

E

ground confluent,

sort-decreasing, and terminating modulo

A

, and

preregular modulo

A

. Their

mathematical semantics

is

given by the initial algebra

T

Σ

/E

∪

A

.

Their

operational semantics

is given by equational

simplification with

E

modulo

A

. Both semantics

coincide

in

the canonical term algebra, since we have the Σ

-isomorphism,

T

Σ

/E

∪

A

C

Σ

,E/A

18

Verification of Maude Functional Modules (II)

What are

properties

of a module

fmod

, E

A

endfm

?

They are sentences

ϕ

, perhaps in equational logic, or, more

generally, in first-order logic, in the language of a signaturecontaining

.

When do we say that the above module

satisfies

property

ϕ

?

When we have,

T

Σ

/E

∪

A

ϕ.

How do we

verify

such properties?

19