Algebra of Normal Function Tables. Martin von Mohrenschildt. May 29, 1997

Similar documents
Symbolic Verification of Hybrid Systems: An Algebraic Approach

Deductive Verification

Herbrand Theorem, Equality, and Compactness

A MODEL-THEORETIC PROOF OF HILBERT S NULLSTELLENSATZ

P.B. Stark. January 29, 1998

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready.

Lecture 2: Axiomatic semantics

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Continuity of Bçezier patches. Jana Pçlnikovça, Jaroslav Plaçcek, Juraj ç Sofranko. Faculty of Mathematics and Physics. Comenius University

2 C. A. Gunter ackground asic Domain Theory. A poset is a set D together with a binary relation v which is reexive, transitive and anti-symmetric. A s

LECTURE Review. In this lecture we shall study the errors and stability properties for numerical solutions of initial value.

SPRING Final Exam. May 5, 1999

Deænition 1 A set S is ænite if there exists a number N such that the number of elements in S èdenoted jsjè is less than N. If no such N exists, then

Integration of the signum, piecewise and related functions

R TH + V TH. Vport. + Rport V TH

The following techniques for methods of proofs are discussed in our text: - Vacuous proof - Trivial proof

Resolution for Predicate Logic

Category Theory. Categories. Definition.

1 CHAPTER 1 INTRODUCTION 1.1 Background One branch of the study of descriptive complexity aims at characterizing complexity classes according to the l

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

2 Lecture 2: Logical statements and proof by contradiction Lecture 10: More on Permutations, Group Homomorphisms 31

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

Informal Statement Calculus

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

Algebras with finite descriptions

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

Axiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements

1.A Sets, Relations, Graphs, and Functions 1.A.1 Set a collection of objects(element) Let A be a set and a be an elements in A, then we write a A.

Introduction Radiative habhas can be used as one of the calibrations of the aar electromagnetic calorimeter èemè. Radiative habha events èe, e +! e, e

Lecture Notes: Axiomatic Semantics and Hoare-style Verification

An Eæcient Tridiagonal Eigenvalue Solver. Ren-Cang Li and Huan Ren.

also has x æ as a local imizer. Of course, æ is typically not known, but an algorithm can approximate æ as it approximates x æ èas the augmented Lagra

Introduction to Kleene Algebras

Computability and Complexity

Equational Logic and Term Rewriting: Lecture I

A.V. SAVKIN AND I.R. PETERSEN uncertain systems in which the uncertainty satisæes a certain integral quadratic constraint; e.g., see ë5, 6, 7ë. The ad

Part II. Logic and Set Theory. Year

CS 294-2, Visual Grouping and Recognition èprof. Jitendra Malikè Sept. 8, 1999

Axiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs

Isomorphism of Finitary Inductive Types

Equational Logic. Chapter Syntax Terms and Term Algebras

UNPROVABLE THEOREMS by Harvey M. Friedman Cal Tech Math Colloq April 19, 2005

EXP. LOGIC: M.Ziegler PSPACE. NPcomplete. School of Computing PSPACE CH #P PH. Martin Ziegler 박세원신승우조준희 ( 박찬수 ) complete. co- P NP. Re a ) Computation

Chapter 1. Sets and Mappings

Journal of Universal Computer Science, vol. 3, no. 11 (1997), submitted: 8/8/97, accepted: 16/10/97, appeared: 28/11/97 Springer Pub. Co.

Completely regular semigroups and (Completely) (E, H E )-abundant semigroups (a.k.a. U-superabundant semigroups): Similarities and Contrasts

The Underlying Semantics of Transition Systems

Information Flow on Directed Acyclic Graphs

Lecture 1. Introduction. The importance, ubiquity, and complexity of embedded systems are growing

Logic Synthesis and Verification

An Independence Relation for Sets of Secrets

2. Introduction to commutative rings (continued)

A strongly rigid binary relation

Combinational Logic Design Principles

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program

Assessing the Calibration of Naive Bayes' Posterior. Estimates. Paul N. Bennett. September 12, 2000 CMU-CS Carnegie Mellon University

Denoting computation

Topics in Model-Based Reasoning

Background: Functional Dependencies. æ We are always talking about a relation R, with a æxed schema èset of attributesè and a

COMP9020 Lecture 3 Session 2, 2014 Sets, Functions, and Sequences. Revision: 1.3

If we remove the cyclotomic factors of fèxè, must the resulting polynomial be 1 or irreducible? This is in fact not the case. A simple example is give

Notes on generating functions in automata theory

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.

The L Machines are very high-level, in two senses:

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161

Notions of s/comp in Topological Algebras over the Reals

Mathematical Foundations of Logic and Functional Programming

Extended RE's. UNIX pioneered the use of additional operators. and notation for RE's: æ E? = 0 or 1 occurrences of E = æ + E.

INTRODUCTION TO SEMIGROUPS AND MONOIDS

UNIVERSAL DERIVED EQUIVALENCES OF POSETS

322 HENDRA GUNAWAN AND MASHADI èivè kx; y + zk çkx; yk + kx; zk: The pair èx; kæ; ækè is then called a 2-normed space. A standard example of a 2-norme

Organization of Receptive Fields in Networks with. Hebbian Learning: The Connection Between. Box 1843, Brown University.

2.2 Lowenheim-Skolem-Tarski theorems

6c Lecture 14: May 14, 2014

Satisfiability Modulo Theories (SMT)

Adjunctions! Everywhere!

Formal Development of a Feedback Control System with Fault. Department of Automatic Control, Abstract

LECTURE 17. Algorithms for Polynomial Interpolation

An Overview of Residuated Kleene Algebras and Lattices Peter Jipsen Chapman University, California. 2. Background: Semirings and Kleene algebras

Also, course highlights the importance of discrete structures towards simulation of a problem in computer science and engineering.

6.8 The Post Correspondence Problem

A. Arenz, E. Schnieder: Modelling and control of a æexible 'goliath' robot - a case study using ADAMSèControls 1. a case study using ADAMSèControls

Topological algebra based on sorts and properties as free and cofree universes

Sets and Functions. (As we will see, in describing a set the order in which elements are listed is irrelevant).

Programming Languages and Compilers (CS 421)

In Class Problem Set #15

Program Verification Using Separation Logic

Axiomatic Semantics. Lecture 9 CS 565 2/12/08

Soundness and Completeness of Axiomatic Semantics

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods

Algebraizing Hybrid Logic. Evangelos Tzanis University of Amsterdam Institute of Logic, Language and Computation

2. Intersection Multiplicities

Sequential Equivalence Checking - I

Introduction to Axiomatic Semantics

Trichotomy Results on the Complexity of Reasoning with Disjunctive Logic Programs

2. Syntactic Congruences and Monoids

Introduction to Groups

Conservation of Information

MISHA GAVRILOVICH, ALEXANDER LUZGAREV, AND VLADIMIR SOSNILO PRELIMINARY DRAFT

Transcription:

Algebra of Normal Function Tables Martin von Mohrenschildt Electrical and Computer Engineering McMaster University, Hamilton, ON, Canada mohrens@mcmaster.ca May 29, 1997 Abstract In contrast to classical algebra and analysis the functions encountered in computer science are usually piecewise continuous functions or functions whose evaluation rules change dramatically depending on a subset of the input values. Because of the pervasiveness of the if-then-else construction in programming, we have to extend classical mathematical methods to handle this kind of object. We approach this class of functions using tabular expressions. In this paper we deæne a function algebra, over a many sorted algebra, which is closed under composition. Then, this function algebra is extended to tables. This enables us to deæne the composition of tables. We show that this algebra of tables is closed under composition. We give two algorithms to compute the composition of tables. 1 Introduction In literature we ænd several diæerent approaches to deæne easily readable but mathematically precise notations for piecewise functions and functions changing deænition depending on parameters ëmohrenschildt96ë, ëparnas94.1ë, ëbojanowskië. We are interested in a complete mathematical formal theory for functions of this type, clearly motivated by the development and needs of modern software engineering. Tabular expressions or tables proved to be a precise instrument used in the documentation and speciæcation of software. Tables oæer an easy to read notation, whose structure is clean and can be used in many diæerent contexts ëparnas95ë, ëheniger80ë. In ëparnas95ë, ëjanicki95.2ë and ëjanicki95.1ë a precise mathematical deænition of tables is given. We take a little diæerent view point and consider tables as algebraic objects. 1

This paper is part of the project we are conducting at the Software Research Group at McMaster University to automate the veriæcation of table based speciæcations. To be able to perform these veriæcations we need to verify properness of tables, compute the composition of tables, simplify tables, perform transformations of tables, e.g. change the dimension, and to decide the semantical equality of tables by deæning a canonical from. To get the idea, a normal function table is a table consisting of headers and a n-dimensional grid. The table x 1 é 0 ^ x 1 ç 1 x 1 ç 0 x 1 é 1 x 2 éx 1 x 1, x 2 x 2 1, x2 2,x 1, x 2 x 2 ç x 2 x 2, x 1 x 2 2, x 2 1,x 1 + x 2 deænes a function of two variables x 1 and x 2. The headers are expressions of a logic L and the grid entries are expressions of an algebra. The headers describe conditions, which evaluated at a point, deæne an index to a grid element, which is then evaluated to a value. Based on a many sorted algebra we deæne our function ring FA. FA is an algebra of functions of several typed variables closed under composition. The composition in FA can be compared with the sequential composition in computer programs, executing two pieces of software one after another. Our deænition of composition allows us to show associativity of this composition. This notion of composition, sometimes called symbolic composition ëcolbyë, can nicely be modeled using our algebra FA. Next the algebra FA is extended to tables. We will prove that this algebra of normal tables is closed in the sense that composition of normal function tables results in a function that can eæectively, using an algorithm, be represented as a single normal function table again. The algorithm depends only on the associative of the composition of functions. The paper is outlined as follows: In the ærst section, we deæne the algebra, functions and evaluation. The second section discusses the concept of a logic needed to deæne conditions. Then we are ready to deæne the notion of tables. Tables are constructed using the deæned algebra and the logic. These tables can be interpreted as functions by giving the semantics of evaluation. We then extend the algebra A to the algebra ~ A. We deæne the extended algebraic operations and compositions. Finally, we present the main theorem, stating that any algebraic operation or composition performed on tables can be represented as a single normal table. Two algorithms are given to compute the composition of tables. 2 The Algebras We deæne a many sorted algebra A æ by ærst deæning a many sorted signature æ and then giving an interpretation of the terms ëzuckerë. This many sorted 2

algebra A æ is then used to deæne an algebra of functions FA with composition. 2.1 The many-sorted signature æ A many-sorted signature æ=èsort æ ; Func æ è where Sort æ is a ænite set of sorts of æ, and Func æ is a ænite set of æ-function symbols, each with its type s 1 æ s 2 æææææs n! s, arity n, domain sorts s 1 ; æææ;s n, and range sort s. A function of arity 0 is a constant. Examples of sorts with there signatures are: bool : _; ^ : bool æ bool! bool : : bool! bool true; false :! bool A ænite set of n elements equipped with equality is called fin. fin : =: fin æ fin! bool a 1 ;a 2 ; æææa n :! fin real : +;,; æ;=: real æ real! real 0; 1! real =; é; é; ç; ç: real æ real! bool Other æ-functions symbols and sorts can be added if needed. Given is also a ænite set of variables x; y; x 1 ; æææ. The variables are typed, x :: s declare that x is of type s. Deænition 2.1 èterm of æè Given a set of typed variables x :: s i1 ;y :: s i2 ; æææ;x n :: s in, terms of type s of the many-sorted signature æ are æ aconstant of æ is a term of type s, æ a variable x i :: s is a term of type s, æ if f is a æ-function symbol of type s i1 æ s i2 æææææs in! s and t k are terms of type s ik then fèt 1 ;t 2 ; æææ;t n è is a term of type s.. 2.2 The many-sorted Algebra A æ Given a signature æ. The many sorted algebra A æ has for each sort s a carrier set A s and each æ-function symbol f of type s 1 æ s 2 æææææs m! s a function f A : A s1 æ A s2 æææææa sm! A s, the interpretation of f in A. Our algebra A æ contains now ainterpretation for the æ-function symbols and constants. 3

Deænition 2.2 èsubstitution, Constant Substitutionè A substitution is a set of expression of the form x i 7! p i where x i is a variable of type s j and p i is a term of the same type s j of the algebra A æ. Aconstant substitution is a set of expressions of the form x i 7! a where x i is a variable of type s j and a 2 A sj. Note, a constant substitution is not a special case of a substitution. Constant substitutions, some times called states, give a semantical meaning to the terms. æ For terms t varètè is set of variables occurring in t. æ For a substitution V varèv è is the set of variables occurring in the terms being the right hand sides of the substitutions. varèv è:=fx i jx i 2 varèt j è; èx j 7! t j è 2 V g æ With rangevarèv èwe denote the set of variables being the left hand side of the substitution V. rangevarèv è:=fx i jèx i 7! t i è 2 V g Next we deæne the mapping val used for substitution and constant substitutions: Deænition 2.3 The mapping val takes two arguments, a term of the algebra A æ and a substitution èconstant substitutionè V and returns a term of A æ èa constant of A s è. valèt; V è is recursively deæned by æ If varètè =fg then valèt; V è=t. æ If t is a variable, t = x i, then valèt; V è is the right hand side of the substitution x i 7! p i of V. æ If t is composed byop i, t = op i èt 1 ;t 2 ; æææ;t si è then valèt; V è=op i èvalèt 1 ;Vè;valèt 2 ;Vè; æææ;valèt si ;Vèè. Note, val represents simultaneous substitution, the right hand side of any expression in the substitution is not aæected by any other substitution in the set of substitutions V.For example valèx 1 ; fx 1 7! x 2 ;x 2 7! x 3 gèisx 2 and not x 3. We write varèæ; æ; æææè for varèæè ë varèæè ëæææ. Deænition 2.4 èevaluation of a Termè A term t of type s is evaluated under a constant substitution V with varètè ç rangevarèv è to valèt; V è an element of the set A s. The evaluation of a term under a constant substitution is often called the state of a term. We extend the function val to substitutions. Let F and G be substitutions then valèf; Gè :=fx i 7! valèt i ;Gèjèx i 7! t i è 2 F g: We close this section by the remark that val is not associative. 4

2.3 The Function algebra FA Now we deæne the notion of a function of the algebra FA over the algebra A æ. The algebra FA is very closely related the the assignments of expressions to variables commonly used programming languages. Deænition 2.5 èfunction, Evaluation of Functionè A function of FA is a substitution of A æ.aconstant function is a constant substitution of A æ. A function F is is evaluated under the constant substitution V with varèfè ç rangevarèv è to valèf; Vè resulting in a constant function. We use capital letters F; G; H for FA functions and t; g; f for terms of A æ. Deænition 2.6 ècomposition of Functionsè Let F and G be FA function. We deæne the composition of F and GFæ G by F æ G := valèf; Gè ëfèx i 7! t i è 2 Gjx i 62 rangevarèf èg For example the two functions F := fx 1 7! x 1 + x 2 g and G := fx 2 7! x 2 +1g are composed to F æ G = fx 1 7! x 1 + x 2 +1;x 2 7! x 2 +1g. Theorem 2.7 The function algebra FA with composition æ is a monoid. Proof We have toverify that there exists a neutral element of composition and that composition is associative. The neutral element of composition is I := fg I æ F = fvalèfg;fè ëfèx i 7! t i è 2 F jx i 62 rangevarèfgèg = F and F æ I = valèf; fgè ëfèx i 7! t i è 2 fgjx i 62 rangevarèf èg = F The composition is associative. We have verify that èf æ Gè æ H = F æ èg æ Hè. We show èf æ Gè æ H ç F æ èg æ Hè and F æ èg æ Hè ç èf æ Gè æ H. Let èx i 7! t i è 2 F æ èg æ Hè then x i 62 rangevarèf è then x i 2 rangevarèg æ Hè x i 62 rangevarègè then èx i 7! t i è 2 H è èx i 7! t i è 2 èf æ Gè æ H x i 2 rangevarègè then èx i 7! gè 2 G and èx i 7! valèg; Hèè 2 H with valèg; Hè =t i. è èx i 7! t i è 2 èf æ Gè æ H 5

x i 2 rangevarèf è then èx i 7! fè 2 F and t i 7! valèf; G æ Hè. then x i 7! valèf; valèg; Hè ëfèx l 7! t l è 2 Hjx l 62 rangevarggè hence x i 7! valèvalèf; Hè;Gè. è èx i 7! t i è 2 èf æ Gè æ H The other direction èf æ Gè æ H ç F æ èg æ Hè is similar and not presented here. This monoid property enables us to give a meaning to F n by F 0 := fg and F n = F æ F æ F ææææf. This enables us to deæne a loop construct as part of our íz í n structure. Together with tables the structure will be computational complete. èany computable function can be expressed.è Deænition 2.8 èextensional Equality of Functionsè The two functions F and G of FA are extensionally equal F ' G if for all constant substitutions P with varèf; Gè ç rangevarèp è F æ P = G æ P,èequality of the setsè The two functions F := fx 1 7! x 1 g and G := fx 2 7! x 2 g are extensional equal since for all P := fx 1 7! a; x 2 7! bg with a 2 A s and b 2 A r F æ P = G æ P = fx 1 7! a; x 2 7! bg. Example 2.9 Let x 1 :: real, x 2 :: real and x 3 :: bool The term x 1 + x 2 is evaluated under the constant substitution fx 1 7! 1;x 2 7! 2g to valèx 1 + x 2 ; fx 1 7! 1;x 2 7! 2gè =1+2=3. The function F = fx 1 7! x 1 + x 2 ;x 2 7! x 2 +2g evaluated under the constant substitution fx 1 7! 1; x 2 7! 2g is valèf; fx 1 7! 1;x 2 7! 2g = fx 1 7! 3;x 2 7! 4; g The composition of F := fx 2 7! x 2 + x 2 ;x 3 7! x 1 é 0g and G := fx 1 7! x 1 + 1;x 2 7! x 2 + x 1 g is F æ G = fx 1 7! x+1+1;x 2 7! 2x 2 +2x 1 ;x 3 7! x 1 +1 é 0; g. Example 2.10 We can use FA to decide the equality of ëassignments": y:=x-3; y:=x-3; x:=x+2; x:=y+5; x:=x+2; y:=x-5; The FA representation of all these three assignments is: fx 7! x +2;y7! x, 3g In ëcolbyë problems of this kind are examined using a diæerent approach. Remark FA provides a method to decompose a program for parallel execution. For example the instruction sequence x 1 7! a; x 2 7! x 1 + b; x 1 7! x 2 + x 2 written as FA functions fx 1 7! ag æfx +27! x 1 + bg æfx 1 7! x 2 + x 1 ; g resulting in fx 1 7! a + a + b; x 2 7! a + bg. The elements of a FA functions can allays be computed in parallel since there right-hand sides are independent. 6

3 The Logic From now onwe assume that bool is one of the sorts in our many sorted algebra A æ. A function symbol with range-type bool is a predicate. Note that our algebra is closed under boolean combinations of predicates. Deænition 3.1 Acondition c of the algebra A æ is a term with range sort bool. A condition c evaluates under the constant substitution V with varècè ç varèv è resulting in true or false. Example 3.2 With x 1 :: real and x 2 :: real and m :: finfa; B; Cg x 1 éx 2 or x 1 + x 2 ç 0 or m = A ^ x 1 é 0 are conditions. The composition of a condition c and a function F is deæned by c æ F := valèc; F è Note that the conditions of the algebra A æ are closed under composition with functions. Deænition 3.3 A condition c is always true or false iæ for all constant substitutions V with varècè ç rangevarèv è valèc; V è = true; valèc; V è = false. We write c = true ; c = false. Consequently we write c 1 ^ c 2 = true iæ valèc 1 ;Vè ^ valèc 2 ;Vè=true. Deænition 3.4 æ A set of conditions c 1 ;c 2 ; æææ;c n is disjoint, iæ c 1 ^ c 2 ^æææ^c n = false. æ A set of conditions c 1 ;c 2 ; æææ;c n is universal if c 1 _ c 2 _æææ_c n = true. 4 Normal Function Tables over an Algebra Let us deæne the notion of tables ëparnas95ë ëzucker93ë, ëjanicki95.1ë. For the concepts studied in this paper, we restrict ourself to the so called proper normal function tables deæned in ëparnas95ë, ëzucker93ë, ëzucker94ë. A general deænition of tables can be found in ëtowards a Formal Semantic of Tables" ëjanicki95.2ë. We start with an example: xé1 x ç,1 ^ x ç 1 xé1 fx 7!,xg fx 7! x 2 g fx 7! xg This normal function table T with variable x :: real deænes a function. There is one header H with three conditions xé1, x ç,1 ^ x ç 1 and xé1 and a grid containing functions. Evaluating this table under the constant substitution fx 7!,2g results in fx 7! 2g and under fx 7! 1=2g we get fx 7! 1=4g. 7

Deænition 4.1 ènormal Function Tableè Given the algebra FA we deæne a normal function table by: 1. A header H i is a set H i = fh i 1 ;hi 2 ; æææhi l i g, where the h i k are conditions. 2. A grid G is the indexed set of functions of FA, such that integers i 1 ;i 2 ; æææ;i n with 0 ç i k ç l k, give a unique index to G identifying the unique function G i1;i 2;æææ;i n. 3. A Normal Function table T = èg; H 1 ;H 2 ; æææ;h l è consists of headers H i = èh i 1 ;hi 2 ; æææ;hi l i è and a grid G i1;i 2;æææ;i l. Asequence of conditions h 1 i 1 ^ h 2 i 2 ^æææ^h l i l gives an index to the grid entry G i1;i 2;æææ;i l. An example of a normal function table with two headers H 1 ;H 2. h 1 1 h 1 2 h 1 3 h 1 4 h 2 1 G 1;1 G 1;2 G 1;3 G 1;4 h 2 2 G 2;1 G 2;2 G 2;3 G 2;4 h 2 3 G 3;1 G 3;2 G 3;3 G 3;4 Because of obvious typesetting reasons most function tables are one or two dimensional tables. Following the deænitions given by D. Parnas ëparnas95ë we deæne the semantics of a proper normal function table. For a normal table T varèt è=varèh 1 ;H 2 ; æææ;h n ;Gè and rangevarèt è:= rangevarègè = S 1çi kçl k varèg i1;æææ;i n è. Deænition 4.2 èproper Normal Function Tableè Let T =èg; H 1 ;H 2 ; æææ;h l è be a function table, 1. A header H i =èh i 1 ;hi 2 ; æææ;hi l i è is called proper if èaè Universal: h i 1 _ hi 2 _æææ_hi l = true èbè Disjoint: the h i k are disjoint, hi k ^ hi l = false; k6= l 2. A function table is called proper if all headers are proper. We extend the mapping val to tables T.For the table T =èg; H 1 ;H 2 ; æææ;h l è varèt;sè is T ~ =è G; ~ H ~ 1 ; H ~ 2 ; æææ; H ~ l è with G ~ i1;i 2;æææ;i n = valèg i1;i 2;æææ;i n ;Sè and ~H k =èvalèh k 1 ;Sè; æææ;valèhi k i ;Sèè. Note that for a proper normal function table T 1 for each header H i evaluated under a constant substitution V with varèh i è ç rangevarèv è only one of the h k i can be true. This enables us to deæne the semantics of a proper normal function table. Composing a normal function table with a constant substitution is called evaluation of the table under a constant substitution. 8

Deænition 4.3 èevaluation of a Proper Normal Function Tableè Aproper normal function table T evaluated under the constant substitutions V, varèt è ç rangevarèv è valèt;v è to the constant function valèg k i 1;æææ;i l ;Vg, where valèh 1 i 1 ^ h 2 i 2 ^æææ^h l i l ;Vè=true: This deænition justiæes the name normal function table. The composition of tables and function is examined in the next section. Example 4.4 We give a table with two headers. The headers contain variables x 1 :: real and x 2 :: real x 1 ç 0 x 1 é 0 x 2 ç 0 fx 1 7! x 1 ;x 2 7! x 2 g fx 1 7!,x 1 ;x 2 7! x 2 g x 2 é 0 fx 1 7! x 1 ;x 2 7!,x 2 g fx 1 7!,x 1 ;x 2 7!,x 2 g This table is proper since each header is disjoint and universal. For more examples of tables and their applications please refer to ëparnas94.1ë, ëparnas94.2ë, ëheniger80ë. 5 Algebra of Normal Function Tables We extend the algebra FA of the functions to an algebra of normal tables by deæning the composition of tables with functions and tables. We are able to deæne the composition of table independent of the notion of ëtype" or ëreturn types" of a table. The presented algorithms are also general in the sense that they only depend on the associative of the composition of the functions the tables are build with. Deænition 5.1 ècompositionè Let T 1 and T 2 beproper normal function tables. With T 1 æ T 2 we denote the composition of T 1 and T 2 a function such that: èt 1 æ T 2 è æ V = T 1 æ èt 2 æ V è for all constant substitutions V with varèt 1 ;T 2 è ç rangevarèv è. The composition of a normal function table T = èh 1 ;H 2 ; æææ;h n ;Gè with a function F T æ F results in the table T ç = èh ç 1 ; æææ; H ç n ; Gè ç where H ç i = èh i 1 æ F; æææ;h i l i æ F è and G ç i1;i 2;æææ;i n = G i1;i 2;æææ;i n æ F. The composition of a function F with a normal table T =èh 1 ;H 2 ; æææ;h n ;Gè results in the table T ç =èh 1 ;H 2 ; æææ;h n ; Gè ç where Gi1;i ç 2;æææ;i n = F æ G i1;i 2;æææ;i n. Example 5.2 F = fy 7! 2 xg;g= yéx fx 7! x, yg y ç x fx 7! y, xg 9

G æ F = this can be simpliæed to: 2 xéx 2 x ç x fx 7! x, 2 x; y 7! 2 xg fx 7! 2 x, x; y 7! 2 xg xé0 x ç 0 fx 7!,x; y 7! 2 xg fx 7! x; y 7! 2 xg Theorem 5.3 èclosed Algebraè The extended algebra of the proper normal function tables over an algebra FA is closed under composition. There exist algorithms to compute the normal function table resulting from the composition of two normal function tables. We will give an algorithm to transform the composition of normal function tables to a single normal function table. The next examples illustrate the ideas used for the construction of the composed tables. Example 5.4 We deæne the tables T 1 and T 2 with x :: real and the ænite set variables m :: finfa; Bg. T 1 = xé0 x ç 0 fx 7!,xg fx 7! 2xg T 2 := m = A m = B fx 7! x +1g fx 7! x +2g We construct the tables T 1 æt 2 and T 2 æt 1. Note that varèh 2 èërangevarèt 1 è= fg, meaning the headers of T 2 do not depend on the ëoutput" of T 1 for this case we give a special construction for the table T 2 æ T 1. T 1 æ T 2 = m = A ^ x +1é 0 fx 7!,x, 1g m = A ^ x +1ç 0 fx 7! 2x +2g m = B ^ x +2é 0 fx 7!,x, 2g m = B ^ x +2ç 0 fx 7! 2x +4g T 2 æ T 1 = xé0 x ç 0 m = A fx 7!,x +1g fx 7! 2x +1g m = B fx 7!,x +2g fx 7! 2x +2g Proof We construct the composition of the two proper normal tables T = èg; H 1 ; æææh k è and ç T =è ç G; ç H 1 ; æææ ç H r è. We distinguish two cases depending if varèh 1 ;H 2 ; æææ;h n è ë rangevarè ç T è=fg or not. Disjoint Composition varèh 1 ;H 2 ; æææ;h n è ë rangevarè ç T è=fg We show by construction that there exists a proper normal function table ~ T = è ~ G; ~ H 1 ; æææ ~ H k+r è such that ~T ' T æ ç T: 10

The headers of ~ T are the union of the headers of T and ç T. ~T =è ~ G; H 1 ;H 2 ; æææ;h k ; ç H 1 ; æææ ç H r è Clearly the headers of ~ T are proper since the headers of T and ç T are proper. The grid of the table ~ T has the entries The construction is completed. ~G i1;æææi k;i k+1;æææi k+r := G i1;æææi k æ ç G ik+1;æææi k+r : It is left to show that ~ T ' T æ ç T.For any constant function V with varèt; ç T è ç rangevarèv è ~T æ V = G i1;æææi k;i k+1;æææi k+r æ V where valèh 1 i 1 ^æææ^h k i k ^ çh 1 i 2 æææ ç h r i 2 ;Vè=true =èg i1;i 2;æææ;i k æ ç Gik+1;i k+2;æææ;i k+r è æ V = G i1;i 2;æææ;i k æ è ç Gik+1;i k+2 æ V è Composition Since now the headers of T depend on the ëoutput" of ç T varèh 1 ;H 2 ; æææ;h n è ë rangevarè ç T è 6= fg, wehave tochoose a diæerent construction for the table ~ T ' T æ ç T. We construct the table ~ T =è ~ G; ~ Hè a table with one header ~ H The condition of the header ~ H are constructed by ~h k = ç h 1 i 1 ^ çh 2 i 2 ^æææ^çh k i k ^ h 1 p 1 æ ç G k i 1;i 2;æææ;i k ^ h 2 p 2 æ ç G k i 1;i 2;æææ;i k ^æææ^h l p l æ ç G k i 1;i 2;æææ;i k This formula consists of all combinations of one condition of every header of table ç T and one conditions of every header of table T composed with the grid entry of table ç T indexed by the sequence ç h 1 i k. The grid entries of ~ T are formed by composition of the grid entries of T and ç T. The grid entry corresponding to the above condition h k is ~G k = G p1;æææ;p l æ ç G i1;æææ;i k : The number of grid entries is the product of the number of grid entries of the two original tables. We are left to show that the constructed table ~ T represents the composition ~T ' T æ ç T: For any constant function V with varèt; ç T è ç rangevarèv è ~T æ V = ~ Gk æ V 11

where valè ~ h k ;Vè=valè ç h 1 i 1^çh 2 i 2^æææ^çh k i k^h 1 p 1 æ ç G k i 1;i 2;æææ;i k^h 2 p 2 æ ç G k i 1;i 2;æææ;i k^æææ^h l p l æ ç G k i 1;i 2;æææ;i k ;Vè is true. =èg i1;i 2;æææ;i k æ ç G i1;i 2;æææ;i k è æ V = G i1;i 2;æææ;i k æ è ç G ik+1;i k+2 æ V è: The resulting table ~ T is proper since T and ç T where proper and the construction preserves properness. Naturally we ask the question why the composition of two normal function tables of any dimension results in one one-dimensional table in the general case. Clearly in some special cases we could ænd a diæerent representation of the table representing the composition. But note that our construction produces tables with the minimum number of cells in the sense that if table T 1 has n cells in it's grid and T 2 has m cells in it's grid then the composition has n æ m entries, all possible combinations. The presented algorithms produce tables with exactly this amount of cells. Note that the proof does not depend on the deænition of the composition of the FA functions, just on the associativity of the composition. Finally, we can ëpull" the semi-group structure of the functions FA to the composition of tables. Lemma 5.5 The structure build with the functions of FA and the tables from a semi-group under composition. Proof We can easily verify that for the two presented algorithm the following identity holds: èt 1 æ èt 2 æ T 2 èè æ V =èèt 1 æ T 2 è æ T 2 è æ V by using the associative offa. The one element of this semi-group is I := fg. Example 5.6 We given another example how to use the composition of tables in open :: bool; out open :: bool; out :: bool T 2 := T 3 := T 1 := fout := in open _:out openg meter é 0 meter ç 0 fin open 7! trueg fin open 7! falseg flow é 0 flow ç 0 fout open 7! trueg fout open 7! falseg 12

T 1 æ T 2 æ T 3 = meter é 0 meter ç 0 flow é 0 fout 7! true _:trueg fout 7! false _:trueg flow ç 0 fout 7! true _:falseg fout 7! false _:falseg = meter é 0 meter ç 0 flow é 0 fout 7! trueg fout 7! falseg flow ç 0 fout 7! trueg fout 7! trueg 6 Future Work æ We are developing the notion of a canonical form for tables. A canonical from allows to decide semantical equality of tables. æ We have a project concerning the simpliæcation of tables. Clearly the key word is computer algebra and normal forms. As part of the ëtools for software engineering" project at the McMaster software engineering group we developed a link of our ëtable holder" to the computer algebra system Maple in order to perform simpliæcations of tables. æ As we are able to represent the composition of two tables as a single table again it is natural to ask the same question concerning iteration and recursion. References ëbojanowskië.bojanowski, M. Iglewski, J. Madey, A. Obaid, Functional approach to Protoclols Speciæcations Proceedings of the 14th International IFIP Symposium of Protocol Speciæcation, PSTV'94, Vancouver, June 94, pp. 371-783 ëparnas95ë D. L. Parnas Tabular Representation of Relations CRL Report No. 260 1995 ëparnas94.1ë D. L. Parnas Mathematical Description and Speciæcation of Software, Proceedings of IFIP World, Congress 1994, Volume1 pp.270-277. ëparnas94.2ë nspectiong safty critical software using function tables, Proceedings of IFIP World Congress 1994, Volume I ëmohrenschildt96ë. v. Mohrenschildt Normal Forms for Function Fields Containing Piecewise Functions, Technical Report no. 96-14 University of Waterloo ëmohrenschildt94ë. Engeler, M. v. Mohrenschildt The combinatory Program Birkhaeuser 1994 ëzucker94ë J. Zucker Transformations of Normal and Inverted Function Tables to be publishes in Formal Aspects of Computing, and CRL Report NO. 291, 1994 13

ëzucker93ë J. Zucker Normal and Inverted Function Tables CRL Report NO. 265 1993 ëheniger80ë.l. Heniger Specifying software requierments for complex systems IEEE Transactions on Software Engineering SE-6, 2-13 ëjanicki95.1ë R. Janicki Towards a Formal Semantic of Parnas Tables McMaster MC- SERG Technical Report 95-03, 1995 ëjanicki95.2ë R. Janicki, D. L. Parnas, J. Zucker Tabular Representations in Rational Documents CRL Report No. 313 1995, to appear in ësperschneiderë V. Sperschneider, G. Antoniou Logic, A Foundation for Computer Science International Computer Science Series ëcolbyë C. Colby è1996è Semantics-based Program Analysis via Symbolic Composition of Transfer Relations Carnegie Mellon University CMU-CS-96-162. 14