Presentation is loading. Please wait.

Presentation is loading. Please wait.

05.03.2003Marc Conrad, University of Luton1 Abstract Classes – pure computer science meets pure mathematics. The Beauty of Implementing Abstract Structures.

Similar presentations


Presentation on theme: "05.03.2003Marc Conrad, University of Luton1 Abstract Classes – pure computer science meets pure mathematics. The Beauty of Implementing Abstract Structures."— Presentation transcript:

1 05.03.2003Marc Conrad, University of Luton1 Abstract Classes – pure computer science meets pure mathematics. The Beauty of Implementing Abstract Structures as Abstract Structures. Marc Conrad, University of Luton.

2 05.03.2003Marc Conrad, University of Luton2 An Overview – the context. Mathematics before the 20 th century axiomatic (Hilbert, Bourbaki, …) algorithmic (Turing, Church, …) "pure" mathematics computer science computer algebra etc.

3 05.03.2003Marc Conrad, University of Luton3 Some motivating remarks Students in Computer Science learn object oriented techniques as a method for designing software systems. Without explicitly knowing it they learn fundamental principles of abstract mathematics. Java as an object oriented language is widely used and accepted for many areas as Graphical User Interfaces or Networking. We will see that the underlying principles are also very well suited for implementing "mathematics". More possibilities to deal with abstract mathematical entities in software. L'art pour l'art

4 05.03.2003Marc Conrad, University of Luton4 Object Oriented Concepts History: Since 1962 with SIMULA 1. Inheritance used since 1967 in SIMULA 67. Today: Java, C++. Concepts: Objects send messages to other objects. Classes are blueprints for objects. A class defines the behaviour of an object using methods. Classes are linked via associations & inheritance.

5 05.03.2003Marc Conrad, University of Luton5 Classes and Objects: A class has data and methods. Textbook Example: A car class may have the following methods: startEngine() move() And as data: speed, numberOfDoors, numberOfSeats,... Math Example A finite field class may have as methods: add(), multiply(), subtract(), divide(), exponentiate(), computeFrobenius() And as data: characteristic, generating polynomial, generator of multiplicative group,... Rings, spaces, categories, etc. can easily identified as classes or objects.

6 05.03.2003Marc Conrad, University of Luton6 Inheritance: Give one class (the child class) all the methods and data of another class (the parent class): An "is a" relationship. Textbook: Math Example Vehicle Car The class car gets all methods of the vehicle + additional own methods. Quadratic Extension F(  d) Complex Field C C = R(  -1) "is a" quadratic extension of R Specifying a special case from a general concept.

7 05.03.2003Marc Conrad, University of Luton7 Inheritance hierarchies usually have a tree or directed graph structure Estate Bicycle Car Vehicle Hatchback Ring R R / f RR[x] C = R(  -1) F(  d) = F/ (x 2 – d)F R

8 05.03.2003Marc Conrad, University of Luton8 Overriding methods: Reimplement a method of the parent class in the child class. Textbook: Vehicle: Implement a method move(). Car (inherits Vehicle): Also implements a method move().  Car objects execute the move() method defined in the Car class. Math Example F(  d): Implement multiplication C (inherits F(  d) ): Re-implement multiplication, e.g. using polar coordinates in some cases. Reinterpreting behavior in the specialisation

9 05.03.2003Marc Conrad, University of Luton9 An advantage of Overriding methods: Generic algorithms Textbook: A class Driver can be associated with the Vehicle class. The Driver can move the Vehicle moving in fact a car or a bicycle. Math Example Define a polynomial ring over an arbitrary ring of coefficients and obtain polynomials over C, Q, F(  d) etc. Define new structures on an abstract level.

10 05.03.2003Marc Conrad, University of Luton10 Abstract methods – abstract classes. That is, the driver moves only Cars, Bicycles, but not a "Vehicle". In fact the Vehicle class does not need to define the move() method. Similarly a Ring class does not need to define addition and multiplication. (But it is obvious, that a Ring has addition, multiplication, etc.) The object oriented paradigm allows to declare a method in a class without implementing it. This is the concept of abstract classes.

11 05.03.2003Marc Conrad, University of Luton11 Abstract methods: Declare a method in the parent class – implement in the child class. Textbook: Vehicle: Declare a method move(). Car (inherits Vehicle): Also implements a method move().  Car objects execute the move() method defined in the Car class. Math Example A Ring R: Declare multiplication. C (inherits R): Implement multiplication. Reinterpreting behavior in the specialisation

12 05.03.2003Marc Conrad, University of Luton12 Example: A ring. We cannot implement: addition negation multiplication inversion "zero" "one" check if zero We can implement: subtraction: a-b = a + (-b) exponentiation: a n = a ...  a. embedding of Z, Q. check for equality polynomials over this ring etc. n abstract methods

13 05.03.2003Marc Conrad, University of Luton13 An Experiment. Implementing abstract mathematics in Java from scratch. Implement a class Ring. Methods which cannot be implemented are declared abstract. Implement a polynomial ring using an abstract Ring as coefficient ring. The polynomial ring is a child of the ring class. Implement Z as a child of the Ring class.  This generates a simple arithmetic for multivariate polynomials with integral coefficients. See http://ring.perisic.com for a Java implementation.

14 05.03.2003Marc Conrad, University of Luton14 Some results It is astonishing simple to implement complex mathematical structures in an object oriented environment from scratch. Drawbacks: Performance. Decisions on how to organise classes (e.g. is field a property of a ring or is it a child class of a ring). Special algorithms as primality testing or factoring do not fit into an object oriented environment.

15 05.03.2003Marc Conrad, University of Luton15 More abstract structures It is possible to work with abstract structures! Modular Ring R/p(x), where R is abstract. Quotient Field Quot(R), where R is abstract. Same amount of work as implementing Z/mZ or Q. Infinite algebraic extensions. Multivariate polynomials can be used although only univariate polynomials have been implemented Advanced structures can be derived as child classes: Complex numbers, rational function fields, cyclotomic fields... Concepts for automatic mapping from one ring to another.

16 05.03.2003Marc Conrad, University of Luton16 Conclusions The experiments with Java show that object oriented programming deserves a closer look in the context of mathematics. Knowledge of the mechanism of overriding and dynamic binding allows a straightforward implementation of abstract mathematical structures. Object oriented programming should be a main feature in CAS (as user defined functions a couple of years ago). Mathematical software should use object oriented terminology instead of "reinventing the wheel".

17 05.03.2003Marc Conrad, University of Luton17 Maple/Mathematica and Object Oriented Programming Maple Not designed to be object oriented. Maple 8.0 allows to link Maple with Java using MathML as interface language The aim however is not to do “object oriented” mathematics but to allow the design of Java applets (MapleNet, Maplets). Mathematica Not designed as an object oriented system. The J/Link technology enables calling of Java classes from Mathematica and vice versa.

18 05.03.2003Marc Conrad, University of Luton18 Other Systems and Object Oriented Programming Axiom. Although not explicitly designed as an Object Oriented System it has many aspects of this. E.g. a type hierarchy, generic functions, generic types. Since September 2002 Axiom is open source. MuPAD Has clearly object oriented aspects. Allows Domains which are organised similar to a class hierarchy. The user can add own domains. Not related to Java or C++. Limited capabilities compared to Maple/Mathematica.


Download ppt "05.03.2003Marc Conrad, University of Luton1 Abstract Classes – pure computer science meets pure mathematics. The Beauty of Implementing Abstract Structures."

Similar presentations


Ads by Google