Docsity

Program Verification: Lecture 9 - Homomorphisms in Order-Sorted Algebras - Prof. Jose Mese, Study notes of Computer Science

Partial preview of the text

Download Program Verification: Lecture 9 - Homomorphisms in Order-Sorted Algebras - Prof. Jose Mese and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 9

Jos´e Meseguer Computer Science DepartmentUniversity of Illinois at Urbana-Champaign

1

Unsorted Homomorphisms

Given unsorted

Σ-algebras

A^ = (A, ι

)^ andA B^ = (B, ι

), aB

Σ-homomorphism

h^ from

A^ to^ B

, written

h^ :^ A −→ B

, is a

function

h^ :^ A^ −→

B^ such that (with

s^ the only sort) we

have:^ •^ for each constant

a^ :^ nil^

−→^ s^ in

Σ,^ h(a

) =^ aAB

(preservation of constants

)

-^ for each

n f : s... s −→^ s^ in

Σ^ and each

(a,... , a^1

n) ∈ An ,

we have

h(f(aA

,... , a 1

)) =^ fnB

(h(a),... , h^1

(a))n

(preservation of operations

)

2

Examples of Unsorted Homomorphisms (II) Recall (Lecture 2, pg. 30) the powerset algebra

P(X)^

over

the Boolean signature

ΣBOOL

. Let^ X

and^ Y

be any sets,

and let

f^ :^ X^ −→

Y^ be any function. Prove in detail that the function

−^1 f :^ P

(Y^ )^ −→ P

(X)

defined for any

A^ ⊆^ Y^

−by: f

1 (A) =^

{x^ ∈^ X^

|^ f^ (x)^ ∈

A}, is a

ΣBOOL

-homomorphism. Prove also that if we also have a function

g^ :^ Y^ −→

Z, then we have the identity −^1 (f ; g) −^1 =^ g;

−^1 f , and therefore that −^1 − g;^ f^

1 :^ P(Z

)^ −→ P

(X)^ is also a

ΣBOOL

-homomorphism.

4

Many-Sorted Homomorphisms

Given (many-sorted)

Σ-algebras

A^ = (A, ι

)^ andA B^ = (B, ι

),B

a^ Σ-homomorphism

h^ from

A^ to^ B

, written

h^ :^ A −→ B

, is an

S-indexed family of functions

h^ =^ {h

:^ A−→s s^

B}ss∈S

such

that:^ •^ for each constant

a^ :^ nil^

−→^ s,^ h

nil,s(a) =sA^

nil,s aB

(preservation of constants

)

-^ for each

f^ :^ w^ −→

s^ with

w^ =^ s^1

... s,^ n n^ ≥^1 , and each

(a,... , a^1

w) ∈ An , we have w,s h(f (^) sA^ (a,... , a^1

)) =^ f^ n w,s(h(sB^1

a),... , h^1

(a))snn

(preservation of operations

)

5

any such homomorphism

h^ can be completely described by

a^2 ×^3

matrix

Mwith real coefficients, so that applying toh^ a 3-dimensionsl vector

~v^ the homomorphims

h, that is,

computing

h(~v)^ exactly corresponds to computing the matrix multiplication

~v^ ◦^ Mh

. Generalize this to

A^ and

B^ real

vector spaces of arbitrary finite dimensions

n^ and^

m.

Generalize it further to rational, resp. complex, vectorspaces of any pair of finite dimensions

n^ and

m.

Now generalize this even further to characterize by meansof matrices

all^ Σ-homomorphims between

Σ-algebras in

cases 2–7 in pages 36–38 of Lecture 2, where in case 7(fuzzy sets) you sould restrict yourself to the fuzzy subsetsof^ finite

sets. Give for each of these cases specific examples of^ h^ :^ A −→ B

showing how this works and how

h^ is thus

applied to specific elements in the corresponding algebra

A.^7

Order-Sorted Homomorphisms

For^ Σ = (

S,^ {Σw,s

}(w,s)∈S

∗, <)×S^

an order-sorted signature,

and^ A^

and^ B^

order-sorted

Σ-algebras, a

Σ-homomorphism

h

from^ A

to^ B, written

h^ :^ A −→ B

, is an^

S-indexed family of

functions

h^ =^ {h

:^ A−→s s^

B}ss∈S

such that:

-^ h^ :^ A −→ B

is a many-sorted (S,^ {Σw,s

}(w,s)∈S

∗)-homomorphism; and×S^

-^ if^ s^ ≡

′^ sand≤ a^ ∈^ As

′^ ∩ A, then s

h(a) =s

′^ h(a)s

(agreement on data in the same connected component

) 8

Initiality of the Term Algebra

If a signature is sensible, then different terms denotedifferent things. In the argot of algebraic specifications, thisis expressed by saying that the term algebra has

no

confusion

. Furthermore, the term algebra is in some sense

minimal

,

since it has only the elements it needs to have to be analgebra: the constants, and the terms needed so that theoperations can yield a result; that is why this minimality isexpressed saying that it has

no junk

.

Note:^

In the rest of the course

we will always assume that

all signatures are sensible

.

10

Initiality of the Term Algebra (II) This minimality means that there is

at most one way

to

map homomorphically the elements of

Tto any algebra.Σ^

And its “no confusion” lack of ambiguity means that suchan homomorphic map can

always

be defined.

For example, it couldn’t be defined for

Σ^ the non-sensible

signature we showed in pg. 4 of Lecture 3 and the Σ-algebra

K^ with:

K=^ A^

{a},^ KB

=^ {b},^

K=^ {C^

c},

K=^ {D^

′d, d}, and with

A,B^ f (a ) =^ b,^ f

A,C^ (a) =

B,D c, g (b) =^ d,

C,Dand g ′(c) =^ d

. Indeed, there in

no^ Σ-homomorphism

h^ :^ T−→ KΣ^

at all, since

h(g(fD^

(a))^ must be either

d^ or^ d

′. If

h(g(f^ D^

(a)) =^ d

, then^

h^ fails to preserve the operation

g^ :^ C^ −→

D, and if

h(g(fD^

(a)) =^ d

′, then

h^ fails to preserve

the operation

g^ :^ B^ −→

D.

11

Proof of the Initiality Theorem

Proof:

For^ A

any^ Σ

-algebra Let us first prove the

uniqueness of e

val, and then its existence.A Proof of uniqueness

. Let us suppose that we have two

different homomorphisms

′^ h, h:^ T

−→ AΣ

. We can prove that

′^ h = hby induction on the depth of the terms.For terms of depth 0 let

a^ be a constant in

T. ThatΣ,s

means that there is a sort

′^ s≤^ s^ with an operator

declaration

a^ :^ nil^

′^ −→ sand therefore, by

h^ and^

′^ hbeing

Σ-homomorphisms we must have

h(a) =s

′ h(a) = s

′nil,s a. A 13

Proof of the Initiality Theorem (II) Assume that the equality

′^ h = h holds for terms of depth

less or equal to

n, and let

f^ (t,... , t^1

)^ ∈^ TnΣ

have depth,s

n^ + 1. That means that there is an operator declaration f^ :^ s... s^1

−→^ sn ′^ with^

′^ s≤^ s^ and

t∈^ Ti^ Σ

,^1 ≤,si i^ ≤^ n. Again,

by^ h^ and

′^ hbeing

Σ-homomorphisms we must have: h(f^ (ts^1

,... , t)) =n s...s^1 = f ′,sn (hs^1 A (t),... , h^1

(t))^ snn (by^ h^ homomorphism)

s...s^1 = f ′,sn ′(h^ s A 1 (t),... , h^1

′(t))^ n sn^

(by induction hypothesis)

′ = h(f^ ( s t,... , t^1

))^ (byn

′^ hhomomorphism)

14

Proof of the Initiality Theorem (IV) Assume that e

valhas already been defined and is aA^ Σ-homomorphism for terms of depth less or equal to

n, and

let^ f^ (t^1

,... , t)n

∈^ TΣ,s^

be a term of depth

n^ + 1. That means

that there is an operator declaration

f^ :^ s... s^1

−→^ sn ′^ with

′^ s≤^ s^ and

t∈^ Ti^ Σ

,^1 ≤,si i^ ≤^ n. We define

eval(As^

f^ (t,... , t^1

)) =^ f^ n

′s...s,s 1 n A (evalAs

(t),... ,^11

evalAsn

(t)).n

Note that, by the Lemma on the sorts of terms in sensiblesignatures, for any other

′ f : s... s 1 ′′′−→^ s n^

such that

′′^ s≤^ s

and^ t∈i^

′ T,^1 Σ,s i^ ≤^ i^ ≤^ n

, we must have,

s≡i^ ≤^

′s,^1 ≤^ i i^ ≤^ n.

Therefore, both operators are subsort overloaded.Note also that, by the induction hypothesis, e

valhasA^

already been defined for terms of depth less or equal to

n

and is a

Σ-homomorphism on those terms.

16

Proof of the Initiality Theorem (V) Since we have

s≡i^ ≤^

′s,^1 ≤^ i i^ ≤^ n, by definition of

order-sorted

Σ-homomorphism this then forces, evalAsi^

(t) =^ ei

val^ (tA′s^ i

),^1 ≤^ i i^ ≤^ n.

Then, by our definition of

Σ-algebra, all subsort overloaded

operators must agree on common data, so that we have,s...s,s^1 n^ f^

′ (evalAs A

(t),... ,^11 evalAsn^

(t)) =^ fn

′′′′s...s,s^ n^1 A^ (evalA′s^1

(t),... ,^1

eval^ (A′s^ n

t)).n

Therefore, the definition does not depend on the choice ofthe subsort overloaded operator. As a consequence, theextension of e

valto the stepA^

n^ + 1^ is well-defined and, by

construction, a

Σ-homorphim, i.e., we have inductively proved the existence of the

Σ-homomorphism e

val. q.e.d.A

17

More on Homomorphisms (II)

A^ Σ-homomorphim

h^ :^ A −→ B

is called an

isomorphim

if

there is another

Σ-homomorphism

g^ :^ B −→ A

such that

h;^ g^ = 1

and^ A g;^ h^ = 1

. We then may use the notationB −^1 g = h and^ h

−^1 = g. We call a

Σ-homomorphism

h^ :^ A −→ B

-^ injective

(resp.

surjective

) if for each sort

s^ ∈^ S^ the

function

his injective (resp. surjective)s^

-^ a^ monomorphism

if for any pair of

Σ-homomorphisms

g, q^ :^ C −→ A

, if^ g;^ h

=^ q;^ h^

then^ g^

=^ q

-^ an^ epimorphism

if for any pair of

Σ-homomorphisms

g, q^ :^ B −→ C

, if^ h;^ g

=^ h;^ q^

then^ g^

=^ q.

19

More on Homomorphisms (III)

For example, if

N, resp.bin

N, denote the naturaldec

numbers with 0, successor, and addition in binary, resp.decimal, representation, we have an obviousbinary-to-decimal

isomorphism

b^2 d^ :^ N

−→^ bin Npreservingdec^

all operations, whose inverse is the decimal-to-binary isomorphism

,^ d^2 b^ :^ N

−→^ bin N. Of course,dec

d^2 b;^ b^2

d^ = 1Ndec

,

and^ b^2 d

;^ d^2 b^ = 1

.Nbin For^ Nn

the residue classes modulo

n, the reminder function

remn N −→^ Nis an^

surjective

homomorphism for

Σ^ containing,

say,^0 ,^

1 ,^ +,^ ×

. Similarly, for

Zthe integers in decimal notation, thedec^ inclusion

j^ :^ Ndec

֒→^ Z dec

is an^ injective

homomorphism

preserving all shared operations:

0 ,^1 ,^ +

,^ ×, etc.

20