[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] / [ ] / intro_objects
[Contents] [Source Text] || [Notation] || [Copyright] || [Contact] [Search ]
Thu May 17 07:55:21 PDT 2012

# Documenting Objects in MATHS

MATHS predates the OO explosion of the middle 1990s. However it had already incorporated several ideas that have been absorbed into OOP/OOA/OOD. Inheritance for example was present in some of the very earliest notes prepared like this in the late 1960's.

An object has both a state and a pattern of behavior. Both of these must be documented:

# Static Aspects

If you only look at the possible states that an object can have then you are looking at a static picture... and one that is easliy expressed by the record structures used in MATHS: [ intro_structures.html ]

For example a point in the Cartesian plan might be described as:

1. POINT::=following,
Net
1. x::real.
2. y::real.

(End of Net)

These 'nets' can also be abbreviated and used in expressions like this:
2. Net{x,y:real}

The static interrelationships between objects is treated using the MATHS techniques that also apply to "data bases": [ math_13_Data_Bases.html ]

# Extensions and subsets

You can extend and/or subset Nets:
3. POINT2::= \$ POINT with following,
Net
1. arg::Angle.
2. abs::Positive & REAL.
3. |-x*tan(arg)=y.
4. |-arg^2 = x^2 + y^2.

(End of Net)

which adds polar coordinates. As a result POINT3 is
Net
1. x::real.
2. y::real.
3. arg::Angle.
4. abs::Positive & REAL.
5. |-x*tan(arg)=y.
6. |-arg^2 = x^2 + y^2.

(End of Net)

# Behavior

The behavior of objects is expresed in diffeernt ways by different methodologists. One technique is to list and define the operations that apply to objects of a given class. THis can be like an Abstract Data Type. Or it can be describing the changes that can occur to an implicit object [ intro_dynamics.html ]

MATHS can use the Z (Zed) approach of describing change in a complex object as a Net (schema) that contains a description of the start and end of the change and the constraint beteen them. The prime "'" indicates the final or future value:

4. For x0,y0:real, MOVE(x0,y0)::=following,
Net

1. |-POINT.
2. |-POINT'.
3. |-x'=x+x0 and y'=y+y0.

(End of Net)

Notice that the arg and abs of a POINT2 will always be adjusted when either x or y changes.

5. For x0,y0:real, MOVE2(x0,y0)::=following,
Net

1. |-POINT2.
2. |-POINT2'.
3. |-x'=x+x0 and y'=y+y0.

(End of Net)

And vice versa -- if a change rotates the point

6. p.arg = x.arg + 45.degrees, then p.x, and p.y will change.

7. Operations::Partly_Baked_Idea=following,
Net
Another (as yet informal) convention could be to include object-oriented operations inside a Network of variables and predicates. For example
1. POINT3::=following
Net
1. x::real.
2. y::real.
3. arg::Angle.
4. abs::Positive & REAL.
5. |-x*tan(arg)=y.
6. |-arg^2 = x^2 + y^2.

7. For x0:real, setX(x0)::operation = (x'=x0).
8. For y0:real, setY(y0)::operation = (y'=y0).
9. For x0,y0:real, move(x0,y0)::operation = (x'=x+x0 and y'=y0+y).

(End of Net POINT3)

2. p1: POINT(x=1,y=1).
3. p2:= p1.move(-1,-1).

or

4. p3:=p1.move(1,1).

The above is a Partly_Baked_Idea.

[click here OperationOnObjects if you can fill this hole]

(End of Net)

# Dynamics

Davaid Harel invented the Statechart as an improvement of the Finite State Machine and these have been put into the UML. These can be expressed in MATHS but Jackson Life History Program technique gives a cleaner structure to problems. It also means that the states are deduced from the problem rather than guessed. Here the possible lives of an object in the class are written as structured running program. Each real object is a thread executing the program. [ math_75_Programs.html ] The threads run for as long as the real object exists... when the program is not running the object must be saved in a persistent form. When the real object becomes active the saved stae is restored and the life-history is restarted. The communication between these (highly poarallel) objects is close to that in CSP.

# Scenarios

Scenarios can described in a simple structured form using: [ intro_ebnf.html ]

# Inheritance

If you have already written the documentation for something called N then
8. N and w is the result of adding a condition or well formed formula to N as a constraint.

You can add a whole set of features to a piece of documentation called N by

9. N with{ new_features}.

# Generics and Templates

Any loosely bound terms in a piece of MATHS documentation is generic and can be replaced by a more tightly bound and so specific form.

# No Privacy

VAriable can be hidden by using an existential quantifier, if needed. But this is pretty rare.

# More

[ math_12_Structure.html ]

# Notes on MATHS Notation

Special characters are defined in [ intro_characters.html ] that also outlines the syntax of expressions and a document.

Proofs follow a natural deduction style that start with assumptions ("Let") and continue to a consequence ("Close Let") and then discard the assumptions and deduce a conclusion. Look here [ Block Structure in logic_25_Proofs ] for more on the structure and rules.

The notation also allows you to create a new network of variables and constraints. A "Net" has a number of variables (including none) and a number of properties (including none) that connect variables. You can give them a name and then reuse them. The schema, formal system, or an elementary piece of documentation starts with "Net" and finishes "End of Net". For more, see [ notn_13_Docn_Syntax.html ] for these ways of defining and reusing pieces of logic and algebra in your documents. A quick example: a circle might be described by Net{radius:Positive Real, center:Point, area:=π*radius^2, ...}.

For a complete listing of pages in this part of my site by topic see [ home.html ]

# Notes on the Underlying Logic of MATHS

The notation used here is a formal language with syntax and a semantics described using traditional formal logic [ logic_0_Intro.html ] plus sets, functions, relations, and other mathematical extensions.

For a more rigorous description of the standard notations see

10. STANDARD::= See http://www.csci.csusb.edu/dick/maths/math_11_STANDARD.html

# Glossary

11. above::reason="I'm too lazy to work out which of the above statements I need here", often the last 3 or 4 statements. The previous and previous but one statments are shown as (-1) and (-2).
12. given::reason="I've been told that...", used to describe a problem.
13. given::variable="I'll be given a value or object like this...", used to describe a problem.
14. goal::theorem="The result I'm trying to prove right now".
15. goal::variable="The value or object I'm trying to find or construct".
16. let::reason="For the sake of argument let...", introduces a temporary hypothesis that survives until the end of the surrounding "Let...Close.Let" block or Case.
17. hyp::reason="I assumed this in my last Let/Case/Po/...".
18. QED::conclusion="Quite Easily Done" or "Quod Erat Demonstrandum", indicates that you have proved what you wanted to prove.
19. QEF::conclusion="Quite Easily Faked", -- indicate that you have proved that the object you constructed fitted the goal you were given.
20. RAA::conclusion="Reducto Ad Absurdum". This allows you to discard the last assumption (let) that you introduced.