Abstract%20Classes%20 - PowerPoint PPT Presentation

View by Category
Title:

Abstract%20Classes%20

Description:

pure computer science meets pure mathematics. The Beauty of Implementing Abstract ... characteristic, generating polynomial, generator of multiplicative group, ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 19
Provided by: vesnaundma
Category:
Tags:
Transcript and Presenter's Notes

Title: Abstract%20Classes%20

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

2
An Overview the context.
axiomatic (Hilbert, Bourbaki, )
"pure" mathematics
Mathematics before the 20th century
computer algebra etc.
algorithmic (Turing, Church, )
computer science
3
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
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
Classes and Objects A class has data and
methods.
• Math Example
• A finite field class may have as methods
exponentiate(), computeFrobenius()
• And as data
• characteristic, generating polynomial, generator
of multiplicative group, ...
• Textbook Example
• A car class may have the following methods
• startEngine()
• move()
• And as data
• speed, numberOfDoors, numberOfSeats, ...

Rings, spaces, categories, etc. can easily
identified as classes or objects.
6
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
The class car gets all methods of the vehicle
Car
Complex Field C
Specifying a special case from a general concept.
C R(?-1) "is a" quadratic extension of R
7
Inheritance hierarchies usually have a tree or
directed graph structure
Ring R
Vehicle
Car
R / f R
Rx
R
Bicycle
F(?d) F/ (x2 d)F
Estate
Hatchback
C R(?-1)
8
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
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
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
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
Example A ring.
• We cannot implement
• negation
• multiplication
• inversion
• "zero"
• "one"
• check if zero
• We can implement
• subtraction a-b a (-b)
• exponentiation an a ? ... ? a.
• embedding of Z, Q.
• check for equality
• polynomials over this ring
• etc.

n
abstract methods
13
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
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
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
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
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
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.