Monoid Modules and Structured Document Algebra

Similar documents
Universität Augsburg. Institut für Informatik. Separability in Domain Semirings. D Augsburg. Report Dezember 2004

Universität Augsburg

Universität Augsburg

From Sequential Algebra to Kleene Algebra: Interval Modalities and Duration Calculus. Peter Höfner. Report Juli 2005

An Algebraic Semantics for Duration Calculus

Omega Algebra, Demonic Refinement Algebra and Commands. Peter Höfner Kim Solin Bernhard Möller. Report June 2006

Universität Augsburg. Institut für Informatik D Augsburg. Kleene Algebras and Pointer Structures. Thorsten Ehm. Report July 2003

Universität Augsburg. Quantales and Temporal Logics. Institut für Informatik D Augsburg. B. Möller P. Höfner G. Struth. Report June 2006

Extended Transitive Separation Logic

Universität Augsburg

Universität Augsburg

A theory of modular and dynamic knowledge representation

Institut für Informatik D Augsburg

On the Structure of Rough Approximations

An Algebra of Hybrid Systems

UNIVERSALITY OF THE LATTICE OF TRANSFORMATION MONOIDS

The Journal of Logic and Algebraic Programming

Kleene Algebra and Arden s Theorem. Anshul Kumar Inzemamul Haque

Boolean Algebras. Chapter 2

Kleene modules and linear languages

Kleene Algebra with Domain

Closure operators on sets and algebraic lattices

When does a semiring become a residuated lattice?

Only Intervals Preserve the Invertibility of Arithmetic Operations

Knowledge for tomorrow

Modal Design Algebra

Completeness of Star-Continuity

Sets and Motivation for Boolean algebra

Making functionality more general

1. Introduction to commutative rings and fields

Lattices and Orders in Isabelle/HOL

A Weak Bisimulation for Weighted Automata

Partial model checking via abstract interpretation

Vector Space Basics. 1 Abstract Vector Spaces. 1. (commutativity of vector addition) u + v = v + u. 2. (associativity of vector addition)

Kleene under a modal demonic star

Subrings of Finite Commutative Rings

On Ordering Descriptions in a Description Logic

Reasoning Automatically about Termination and Refinement

Yet Another Proof of the Strong Equivalence Between Propositional Theories and Logic Programs

Modal Design Algebra

Universität Augsburg. wp is wlp. Institut für Informatik D Augsburg. Report October 2004

Algebraic Notions of Nontermination: Omega and Divergence in Idempotent Semirings

Review of Linear Algebra

Universal Algebra for Logics

Universität Augsburg. Knowledge and Games in Modal Semirings. Institut für Informatik D Augsburg. Report February 2007

NOTES ON CONGRUENCE n-permutability AND SEMIDISTRIBUTIVITY

Universität Augsburg. On Two Dually Nondeterministic Refinement Algebras. Institut für Informatik D Augsburg. Kim Solin

Axioms of Kleene Algebra

Non-Termination in Idempotent Semirings

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

1 Differentiable manifolds and smooth maps

Tree sets. Reinhard Diestel

Combinatorial Structures

Bulletin of the. Iranian Mathematical Society

Definition 5.1. A vector field v on a manifold M is map M T M such that for all x M, v(x) T x M.

Notes on Abstract Interpretation

Relational semantics for a fragment of linear logic

Lecture 4. Algebra, continued Section 2: Lattices and Boolean algebras

A Logical Characterization for Weighted Event-Recording Automata

1. Introduction to commutative rings and fields

A GENERAL THEORY OF ZERO-DIVISOR GRAPHS OVER A COMMUTATIVE RING. David F. Anderson and Elizabeth F. Lewis

THE EQUATIONAL THEORIES OF REPRESENTABLE RESIDUATED SEMIGROUPS

Imperative Abstractions for Functional Actions

Theory of Computation

Algebras of modal operators and partial correctness

Extended Index. 89f depth (of a prime ideal) 121f Artin-Rees Lemma. 107f descending chain condition 74f Artinian module

EQUIVALENCE RELATIONS AND OPERATORS ON ORDERED ALGEBRAIC STRUCTURES. UNIVERSITÀ DEGLI STUDI DELL'INSUBRIA Via Ravasi 2, Varese, Italy

Boolean Algebra and Propositional Logic

A proof of the Graph Semigroup Group Test in The Graph Menagerie

Boolean Algebra and Propositional Logic

Streams and Coalgebra Lecture 2

Lattices, closure operators, and Galois connections.

11 Annihilators. Suppose that R, S, and T are rings, that R P S, S Q T, and R U T are bimodules, and finally, that

Keywords: Specification technique, expressive power, computation models, sequential algorithms, transition systems, Abstract State Machines

IDEAL CLASSES AND RELATIVE INTEGERS

Hierarchic reasoning in local theory extensions

On Fixed Point Equations over Commutative Semirings

Applications of Regular Algebra to Language Theory Problems. Roland Backhouse February 2001

Duality and Automata Theory

Nested Epistemic Logic Programs

2MA105 Algebraic Structures I

Egoroff Theorem for Operator-Valued Measures in Locally Convex Cones

Elementary linear algebra

Characterising nested database dependencies by fragments of propositional logic

Foundations of Mathematics

MULTIRELATIONAL MODELS OF LAZY, MONODIC TREE, AND PROBABILISTIC KLEENE ALGEBRAS

hal , version 1-21 Oct 2009

A Convolution as a Unifying Concept: Applications in Separation Logic, Interval Calculi and Concurrency

Congruence Boolean Lifting Property

In N we can do addition, but in order to do subtraction we need to extend N to the integers

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

A Comparison of Disjunctive Well-founded Semantics

Equational Logic. Chapter Syntax Terms and Term Algebras

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

Static Program Analysis using Abstract Interpretation

ALGEBRA EXERCISES, PhD EXAMINATION LEVEL

GENERALIZED DIFFERENCE POSETS AND ORTHOALGEBRAS. 0. Introduction

Ekkehart Schlicht: Trend Extraction From Time Series With Structural Breaks and Missing Observations

Duality in Logic. Duality in Logic. Lecture 2. Mai Gehrke. Université Paris 7 and CNRS. {ε} A ((ab) (ba) ) (ab) + (ba) +

MaanavaN.Com MA1256 DISCRETE MATHEMATICS. DEPARTMENT OF MATHEMATICS QUESTION BANK Subject & Code : MA1256 DISCRETE MATHEMATICS

Transcription:

Monoid Modules and Structured Document Algebra (Extendend Abstract) Andreas Zelend Institut für Informatik, Universität Augsburg, Germany zelend@informatik.uni-augsburg.de 1 Introduction Feature Oriented Software Development (e.g. [3]) has been established in computer science as a general programming paradigm that provides formalisms, methods, languages, and tools for building maintainable, customisable, and extensible software product lines (SPLs) [8]. An SPL is a collection of programs that share a common part, e.g., functionality or code fragments. To encode an SPL, one can use variation points (VPs) in the source code. A VP is a location in a program whose content, called a fragment, can vary among different members of the SPL. In [2] a Structured Document Algebra (SDA) is used to algebraically describe modules that include VPs and their composition. In [4] we showed that we can reason about SDA in a more general way using a so called relational predomain monoid module (RMM). In this paper we present the following extensions and results: an investigation of the structure of transformations, e.g., a condition when transformations commute, insights into the pre-order of modules, and new properties of predomain monoid modules. 2 Structured Document Algebra VPs and Fragments. Let V denote a set of VPs at which fragments may be inserted and F(V) be the set of fragments which may, among other things, contain VPs from V. Elements of F(V) are denoted by f 1, f 2,.... There are two special elements, a default fragment 0 and an error. An error signals an attempt to assign two or more non-default fragments to the same VP within one module. The addition, or supremum operator + on fragments obeys the following rules: 0 + x = x, + x =, x + x = x, f i + f j = (i j), where x {0, f i, }. This structure forms a flat lattice with least element 0 and greatest element and pairwise incomparable f i. By standard lattice theory + is commutative, associative and idempotent and has 0 as its neutral element. Modules. A module is a partial function m : V F(V). A VP v is assigned in m if v dom(m), otherwise unassigned or external. By using partial functions rather

34 A. Zelend than relations, a VP can be filled with at most one fragment (uniqueness). The simplest module is the empty module 0, i.e., the empty partial map. Module Addition. The main goal of feature oriented programming is to construct programs step by step from reusable modules. In the algebra this is done by module addition (+). Addition fuses two modules while maintaining uniqueness (and signaling an error upon a conflict). Desirable properties for + are commutativity and associativity. For module addition, + on fragments is lifted to partial functions: m(v) if v dom(m) dom(n), n(v) if v dom(n) dom(m), (m + n)(v) = df m(v) + n(v) if v dom(m) dom(n), undefined if v dom(m) dom(n). If in the third case m(v) n(v) and m(v), n(v) 0 then (m + n)(v) =, thus signalling an error. The set of modules forms a commutative monoid under + with the neutral element 0. Deletion and Subtraction. For modules m and n the subtraction m n is defined as (m n)(v) = df { m(v) if v dom(m) dom(n), undefined otherwise. Overriding. To allow overriding, an operation can be defined in terms of subtraction and addition. Module m overrides n, written m n, if m n = m + (n m) This replaces all assignments in n for which m also provides a value. is associative and idempotent with neutral element 0. Modules m and n are called compatible, in signs m n, if their fragments coincide on their shared domains, i.e., m n df v dom(m) dom(n) : m(v) = n(v). We have chosen this characterization of compatibility with regard to the nonrelational abstract approach, to be pursued in Section 3, which especially needs no converse operation. For a relational treatment see [9]. All submodules of a module are pairwise compatible with each other. 2.1 Transformations In this section we sketch an extension of SDA, intended to cope with some standard techniques in software refactoring (e.g., [1, 7]). Examples of such techniques are consistent renaming of methods or classes in a large software system. To stay at the same level of abstraction as before, we realize this by a mechanism for generally modifying the fragments in SDA modules.

Monoid Modules and Structured Document Algebra 35 By a transformation or modification or refactoring we mean a total function T : F(V) F(V). By T m we denote the application of T to a module m. It yields a new module defined by (T m)(v) = df { T(m(v)) if v dom(m) undefined otherwise. We need to handle the special case of transforming the error fragment. Since we don t want to allow transformations to mask errors that are related to module addition, we add the requirement T( ) =. We use the convention that binds stronger than all other operators. Note that, although T is supposed to be a total function on all fragments, it might well leave many of those unchanged, i.e., act as the identity on them. 2.2 Structure of Transformations Definition 2.1 A monoid of transformations is a structure F = (F,, 1), where F is a set of total functions f : X X over some set X, closed under function composition, and 1 the identity function. The pair (X, F) is called transformation monoid of X. By T A we denote the transformation T restricted to the set A. We call the set of transformations on fragments Γ. Then, by the above definition, (F(V), Γ ) is the transformation monoid of fragments F(V) which we abbreviate to Γ. Since these transformations are not necessarily invertible, in general Γ is not a transformation group. We now can extend the list of properties given in [2]. (6) T (m + n) = T m + n T ran(n) = 1 ran(n) m n, (7) 1 m = m, (8) T 0 = 0. 0 being an annihilator, (Property (8)) means that transformations can only change existing fragments rather than create new ones. Furthermore we can define the application equivalence of two transformations S, T by S T df m : S m = T m. It is common to undo refactorings, e.g., undo a renaming of a variable. This can be modelled by inverse transformations, denoted by 1. When it exists, the inverse of a stacked, or composed transformation, is given by (T S) 1 = S 1 T 1. Of course the inverse of T or S might not exist, e.g., if T is not injective. As stated above transformations are total functions. Since they act as the identity for fragments that should not be modified we define the set of fragments they transform as follows. Definition 2.2 Let T : F(V) F(V) be a transformation. Then we call T m = df {f F(V) : T(f) f} the modified fragments of T and T v = df {T(f) F(V) : T(f) f} = ran(t Tm ) the value set of T.

36 A. Zelend Restricting transformations to their modified fragments allows us to state situations in which transformations can be omitted or commute. Lemma 2.3 1. T (S m) = S m if T m S m T m S v =. 2. T and S commute if T m S m = T m S v = T v S m =. A proof can be found in Appendix A.1. 3 Abstracting from SDA The set M of modules, i.e., partial maps m : V F(V), with + and, defined as in subsection 2, forms an algebraic structure SDA = df (M, +,, 0) such that (M, +, 0) is an idempotent and commutative monoid and which satisfies the following laws for all l, m, n M: 1. (l m) n = l (m + n), 3. 0 l = 0, 2. (l + m) n = (l n) + (m l), 4. l 0 = l. Definition 3.1 A monoid module (m-module) is an algebraic structure (B, M, :) where (M, +, 0) is an idempotent and commutative monoid and (B, +,, 0, 1, ) is a Boolean algebra in which 0 and 1 are the least and greatest element and and + denote meet and join. Note that 0 and + are overloaded, like in classical modules or vector spaces. The restriction, or scalar product, : is a mapping B M M satisfying for all p, q B and m, n M: (p + q) : m = p : m + q : m, (1) p : (m + n) = p : m + p : n, (2) 0 : m = 0, (3) (p q) : m = p : (q : m), (4) 1 : m = m, (5) p : 0 = 0. (6) We define the natural pre-order on (M, +, 0) by m n df m + n = n. Therefore + is isotone in both arguments. We have choosen the name monoid module following the notion of a module over a ring and because SDA s modules form an idempotent and commutative monoid. Lemma 3.2 1. Restriction : is isotone in both arguments. 2. p : m m. 3. p : (q : m) = q : (p : m) The first claim follows by distributivity, the second by isotony and (5) and the third by (4) and Boolean algebra. The structure RMM = (P(M), P(M N), :), where : is restriction, i.e., p : m = {(x, y) x p (x, y) m}, forms a mono module. To model subtraction we extend mono modules with the predomain operator : M B. Definition 3.3 A predomain monoid module (predomain m-module) is a structure (B, M, :, ) such that(b, M, :) is a m-module and : M B satisfies for all p B and m M:

Monoid Modules and Structured Document Algebra 37 (d1) m m : m, (d2) (p : m) p. In a predomain m-module m is the least left preserver of m and a is the greatest left annihilator. To justify this we present the following lemma. Lemma 3.4 In a predomain m-module (B, M, :, ) for all p B and m M: (llp) m p m p : m, (gla) p m p : m 0. Note that (llp) does not establish a Galois connection, since there is no greatest element in the monoid (M, +, 0) per se, cf. [5] A proof can be found in Appendix A.2. Now we can give more useful properties of the predomain function like isotony or strictness. Lemma 3.5 In a predomain m-module (B, M, :, ) for all p B and m, n M: 1. m = 0 m = 0, 2. m n m n, 3. m = m : m, 4. (m + n) = m + n, 5. (p : m) : m = p : m, 6. (p : m) = p m. A proof can be found in Appendix A.3. Now it is easy to verify that the SDA laws for subtractions also hold in a predomain m-module. Note that the sides change, e.g., right distributivity becomes left distributivity. Lemma 3.6 Assume a predomain m-module (B, M, :, ). Then for all l, m, n M: 1. ( n : m) = m n, 2. ( n : 0 = 0), 3. l : (m + n) = l : m + l : n, 4. (m + n) : l = n :( m : l), 5. 0 : m = m, 6. m : m = 0, 7. n : m m, 8. m n n : m = 0. A proof can be found in Appendix A.4. By defining m = df {x (x, y) m} RMM becomes a predomain m-module and using an RMM over binary functional relations R V F(V), i.e., R ; R id(f(v)), allows us to reason about SDA. As a result, SDA s subtraction m n of modules is equivalent to n : m in the corresponding RMM.

38 A. Zelend Using SDA s module addition, cf. Section 2, we can investigate the induced natural pre-order. m n df m + n = n m(v) if v m n n(v) if v n m = n(v) m(v) + n(v) if v m n undefined if v m n m(v) = n(v) if v m n n(v) = n(v) if v n m m(v) + n(v) = n(v) if v m n true if v m n false if v m n true if v n m m(v) n(v) if v m n true if v m n v n m (v m n m(v) n(v)) v m n for any v V. Therefore the least element w.r.t. is the empty module 0 and the top element is the module t with t(v) = for any v V. SDA s overriding operator m n can also be defined in a predomain m- module: m n = df m + m : n. In [6] this operator, embedded into a Kleene algebra, is used to update links in pointer structures. Lemma 3.7 In a predomain m-module (B, M, :, ) for all p B and l, m, n M: 1. 0 n = n, 2. m 0 = m, 3. m m n, 4. m = m :(m n), 5. (m n) = m + n, 6. m n m n = m, 7. l (m + n) = l m + l n. A proof can be found in Appendix A.5. Future work will focus on further properties of transformations and their incorporation into the abstract framework of predomain m-modules. Acknowledgments I am very grateful to the anonymous referees for helpful comments and suggestions and I thank B. Möller for fruitful discussions and valuable comments.

Monoid Modules and Structured Document Algebra 39 References 1. Batory, D.: Program refactorings, program synthesis, and model-driven design. In: Krishnamurthi, S., Odersky, M. (eds.) Compiler Construction. LNCS, vol. 4420, pp. 156 171. Springer (2007) 2. Batory, D., Höfner, P., Möller, B., Zelend, A.: Features, modularity, and variation points. Tech. Rep. CS-TR-13-14, The University of Texas at Austin (2013) 3. Batory, D., O Malley, S.: The design and implementation of hierarchical software systems with reusable components. ACM Transactions Software Engineering and Methodology 1(4), 355 398 (1992) 4. Dang, H.H., Glück, R., Möller, B., Roocks, P., Zelend, A.: Exploring modal worlds. Journal of Logical and Algebraic Methods in Programming 83(2), 135 153 (2014), http://www.sciencedirect.com/science/article/pii/s1567832614000058, festschrift in Honour of Gunther Schmidt on the Occasion of his 75th Birthday 5. Desharnais, J., Möller, B., Struth, G.: Kleene algebra with domain. ACM Trans. Comput. Log. 7(4), 798 833 (2006), http://doi.acm.org/10.1145/1183278.1183285 6. Ehm, T.: The Kleene Algebra of Nested Pointer Structures: Theory and Applications. Ph.D. thesis, Universität Augsburg (2005) 7. Kuhlemann, M., Batory, D., Apel, S.: Refactoring feature modules. In: Edwards, S., Kulczycki, G. (eds.) Formal Foundations of Reuse and Domain Engineering. LNCS, vol. 5791, pp. 106 115. Springer (2009) 8. Lopez-Herrejon, R., Batory, D.: A standard problem for evaluating product-line methodologies. In: Bosch, J. (ed.) GCSE 01: Generative and Component-Based Software Engineering. LNCS, vol. 2186, pp. 10 24. Springer (2001) 9. Möller, B.: Towards pointer algebra. Sci. Comput. Program. 21(1), 57 90 (1993), http://dx.doi.org/10.1016/0167-6423(93)90008-d A Proofs for Subsection 2.2 and Section 3 A.1 Proofs for Lemma 2.3 1. T m S v = implies that T acts as the identity on the set S v. Since T m S m, we obtain that T also is the identity on the set ran(m) S m. Therefore we have T (S m)(v) = T (S(m(v))) = S(m(v)). 2. We have x S m T(x) = x x T m S(x) = x because T m S m =. Therefore, for an arbitrary x = m(v), we get S(x) if x S m since T m S v =, (T S)(x) = T(S(x)) = T(x) if x T m, x if x S m T m. On the other hand we get (S T)(x) = S(T(x)) = T(x) if x T m since S m T v =, S(x) if x S m, x if x T m S m.

40 A. Zelend A.2 Proofs for Lemma 3.4 (llp) : m m : m p : m by (d1) and isotony of restriction ( m p). : m p : m m = p : m by Lemma 3.2.2 and therefore m = (p : m) p by (d2). (gla) : p : m p :( m : m) = (p m) : m by (d1), isotony of restriction and (4). Since p m, p m = 0 holds and therefore (p m) : m = 0 : m = 0 by (3). : m = 1 : m = (p + p) : m = p : m + p : m = 0 + p : m = p : m by (5), Boolean algebra, (1) and the assumption (p : m 0). Using (llp) we have m p which is equivalent to p m by shunting. A.3 Proofs for Lemma 3.5 1. : m = 0 = (0 : 0) 0 by (3) and (d2). : m m : m by (d1) and therefore m 0 : m = 0 by (3). 2. n n n : n 0 n : m 0 n m m n by (gla), isotony of restriction, (gla) again and shunting (2 times). 3. p (m + n) p : (m + n) 0 p : m + p : n 0 p : m 0 p : n 0 p m p n p m n p ( m + n). Using indirect equality we get (m + n) = ( m + m) (m + n) = m + m. 4. m m : m holds by (d1) and m : m m holds by Lemma 3.2.2. 5. : (p : m) : m p : m holds by (d2) and isotony of restriction. : p : m (p : m) :(p : m) = ( (p : m) p) : m by (d1) and (4). Since (p : m) p by (d2) it follows that (p : m) p = (p : m). In sum we have p : m (p : m) : m. 6. First we have m = (1 : m) = ((p + p) : m) = (p : m + p : m) = (p : m) + ( p : m) by (5), Boolean algebra, and Part 4. By (d2) it holds that (p : m) p ( p : m) p. And therefore by Boolean algebra: p (p : m) = (p : m) and p ( p : m) = 0. In sum we conclude: p m = p ( (p : m) + ( p : m)) = p (p : m) + p ( p : m) = p (p : m) + 0 = (p : m). A.4 Proofs for Lemma 3.6 1. ( n : m) = m n by Lemma 3.5.6 and Boolean algebra. 2. ( n : 0 = 0) by (6). 3. l : (m + n) = l : m + l : n by (5). 4. (m + n) : l = ( m + n) : l = ( m n) = m :( n : l) = m :( n : l) by Lemma 3.5.4, Boolean algebra, (4) and Lemma 3.2.3. 5. 0 : m = 0 : m = 1 : m = m by (5) and 0 = 0 = 1 Lemma 3.5.1, Boolean algebra and (5). 6. m m m : m 0 by (gla). 7. n : m m by Lemma 3.2.2. 8. m n m n n m n : m 0 by Lemma 3.5.2, Boolean algebra and (gla).

Monoid Modules and Structured Document Algebra 41 A.5 Proofs for Lemma 3.7 1. 0 n = 0 + 0 : n = 0 : n = 1 : n = n by Lemma 3.5.1 and (5). 2. m 0 = m + m : 0 = m + 0 = m by (6). 3. m m + m : n = m n by isotony of +. 4. m :(m n) = m :(m + m : n) = m : m + m :( m : n) = m + ( m m) : n = m + 0 : n = m + 0 = m by (2), (4) and (3). 5. (m n) = (m + m : n) = m + ( m : n) = m + m n = m + n, by Lemma 3.5.4, 3.5.6 and Boolean algebra. 6. First we conclude m n m n m : n 0 by (gla). Therefore m n = m + m : n = m + 0 = m. 7. l (m+n) = l+ l :(m+n) = l+ l : m+ l : n = l+ l : m+l+ l : n = l m + l n by (2) and idempotence.