Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

2010-12-31

survey of programming architectures

11.15: web.adda/oop/architectures:

the categories of inheritance:

# type clustering (inclusion polymorphism):

. numbers are the classic type cluster;
that type's major subtypes have overlapping interfaces;
and they need a supertype to coordinate biop's
(binary operations; a function with 2 arg's;
eg, addition's signature is: +:NxN->N )
whenever the param's have unmatched subtypes
(eg, RxC->C, ZxN->Z, /:NxN->Q, ...).

type cluster/supervision models:
#coordinated:
. the set of polymorphic subtypes is fixed,
and the supertype knows how to convert between them;
because,
it knows the data formats of all its subtypes .
# translated:
. the supertype provides an all-inclusive
universal data format;
eg, numbers -> complex .
. all subtypes convert between that format
and their own .

type cluster/subtypes must include range constraints:
. range constraints are essential for efficiency
as well as stronger static typing;
because, range limits are what allow
direct use of native numeric types .
. typical native types include
{N,Z,R}{8,16,32,64,128} .

# type classing (Subtype polymorphism):
. declaring a type is a member of a class,
and is compatable with that class
by inheriting its interface;
the new type is then usable
anywhere the inherited class is . [12.31:
. the type class is defined by its interface;
any type following that interface
is considered a member of that class .
. it's not about sharing code by extension;
it's organizing hierarchies of compatability .]

# type cluster combined with type classing:
. the subtypes of a type cluster
can be type classed; eg,
a dimensioned number could inherit from int;
and then to coordinate with the numeric supertype
it uses functionality from int.type
to deal with these messages:
{ what is your numeric subtype?
, your numeric value?
, replace your numeric value with this one
} .
. with just that interface,
any subclass of any numeric subtype
can be used in any numeric operation . [12.31:
. all self-modifying operations ( x`f)
can be translated as assignments (x`= f(x));
so then the inherited subtype
provides all the transform code .]

#type classing without clustering:
11.20:
. without type clustering;
what does type classing do then?
are biop's supported? polymorphism?
. historical reasons for inheritance:
# polymorphism
# type compatability
# reuse of work .
. you want to extend a type's
structure and functionality,
not interfere with its code base,
and still be useful everywhere your ancestors are .

. in the popular oop model,
the inherited work is reused by
adding to an inherited type's
functionality and instance var'space
(creating a polymorphism in the type).
. there's type compatability because
the obj' can handle all the ancestor's
unary and self-modifying functions;
but, popular oop approaches differ on
how biop's are handled .

. the classic, math'al oop uses clusters, [12.31:
which can handle biop's because the supertype
has limited membership to its type class
and can thus know in advance
what combinations of subtypes to expect
among a biop's pair of arg's .
. in a system without clustering's
closed class of subtypes
then there is no particular type to handle
the coordination of mixed biop arg's .
(that mix can consist of any types in
one arg's ancestors, or their descendents).]

. if subtypes can redefine a biop,
then a biop's method might be arbitrated by:
# nearest common ancestor:
the arg' set's nearest common ancestor type;
# popular:
the first arg determines the method;
# translation:
. an inheritable type has a universal format
which inheritors convert to,
in order to use the root's biop method .]

# incremental composition:
. it can be simplifying to describe a type
in terms of how it differs from other types;
this case includes anything not considered to be
type clustering or subclassing .
. revisions such as removing inherited parts
can preclude type compatability;
in such cases, compatability could be declared
with the use of a conversion map .
. incremental composition provides
module operators for building in ways
familiar to lisp users:
code can read other code, modify it,
and then use it as a module definition .
[11.20:
. with incremental composition,
any inheritance behaviors should be possible;
but the built-in inheritance should be
simple, classic type clustering and classing
as described above .
. the directions of popular oop
are not helping either readability or reuse;
esp'y unrewarding is the ability to
inherit multiple implementations
that have overlapping interfaces .]

#frameworks:
11.15:
. generic types can implement frameworks:
a type is an interface with all code supplied;
a generic type
leaves some of its interface undefined
or optionally redefinable,
with the intent that parameter instantiations
are customizing the framework;
eg,
a typical gui framework would be impl'd as
a generic task type;
so that creating an obj' of that type
initiates a thread of execution
that captures all user input
and responds to these events by
calling functions supplied by the
framework's customizing init's .]

adda/oop/value types:
11.16:
. the classic use of oop is type clustering
as is done for numerics:
it provides users of the numeric library
with an effortless, automated way
to use a variety of numeric subtypes
while also employing static typing,
and enjoying any enhanced readability or safety
that may be provided by that .
. coercions and range checks can all be
tucked under the hood,
without requiring compliance from clients .
. this automation is possible because
the designer of a type cluster's supertype
is using subtype tags to determine
each value's data format .

. the supertype module is also
the only place to coordinate
multiple param's having unmatched subtypes;
after one param' is coerced to match the other,
operations involving matched binary subtypes
are then relegated to subtype modules .

11.19: intro to value`type:
. static typing generally means
that a var's allowed values are confined to
one declared type,
and perhaps also constrained;
eg, limited to a range of values,
or a specific subtype .
. if that declared type is a type cluster,
it's values will include a type tag
for use by the supertype module,
to indicate which of its subtype modules
is responsible for that data format .

. type.tags are sometimes seen as a way to
replace Static typing with ducktyping
(where the tag is used at run-time
to check that the given value has a type
that is compatible with the requested operation).
. type clustering, in contrast to ducktyping,
is static typing with polymorphism
(statically bound to the cluster's supertype);
and there, the purpose of the type.tag
is merely to allow the supertype module
to support a variety of subtypes,
usually for the efficiency to be gained
from supporting a variety of data formats;
eg,
if huge complex numbers won't be used,
then a real.tag can indicate there is
no mem' allocated for the imaginary component;
or,
if only int's within a certain range will be used,
then the format can be that of a native int,
which is considerably faster than non-native formats .

. the value's subtype (or value`type)
is contrasted with a var's subtype
to remind us that they need not be equal
as long as they are compatable;
eg,
a var' of type"real may contain
a value of type"integer;
because they are both subtypes of number,
and the integer values are a
subset of the real values
(independent of format).

. the obj's subtype puts a limit on
the value`types it can support;
eg,
while a var' of subtype"R16 (16bit float)
can coerce any ints to float,
it raises an exception if that float
can't fit in a 16-bit storage .

. another possibly interesting distinction
between var' types and value`types
is that value`types have no concept of
operating on self; [11.19:
a unary operation over a value`type
doesn't involve any addresses,
and there is nothing being modified .
. while popular oop has a var`address
modify itself with a msg,
eg, x`f;
classic oop would say that was an
assignment stmt plus a unary operation:
x`= x`type`f(x) -- shown here fully qualified
to indicate how modularity is preserved:
the function belongs to x's type .]

. adda can also enforce typing between
unrelated types like {pure number, Meters},
but the system depends on supertype designers
to correctly handle their own subtypes .

. in addition to the distinction between
{library, application} programmers,
there is also kernel mode:
the adda run-time manages all native types
so that any code that
could be responsible for system crashes
is all in one module .

10.23: news.adda/compositional modularity:
11.14: Bracha, Lindstrom 1992`Modularity meets Inheritance
We "unbundle" the roles of classes
by providing a suite of operators
independently controlling such effects as
combination, modification, encapsulation,
name resolution, and sharing,
all on the single notion of module.
All module operators are forms of inheritance.
Thus, inheritance not only is
not in conflict with modularity in our system,
but is its foundation.
This allows a previously unobtainable
spectrum of features
to be combined in a cohesive manner,
including multiple inheritance, mixins,
encapsulation and strong typing.
We demonstrate our approach in a language:
Jigsaw is modular in two senses:
# it manipulates modules,
# it is highly modular in its own conception,
permitting various module combinators to be
included, omitted, or newly constructed
in various realizations .
10.23: Banavar 1995`compositional modularity app framework:
11.14:
. it provides not only decomposition and encapsulation
but also module recomposition .
. the model of compositional modularity is itself
realized as a generic, reusable software arch',
an oo-app framework" Etyma
that borrows meta module operators
from the module manipulation lang, Jigsaw
-- Bracha 1992`modularity meets inheritance .

. it efficiently builds completions;
ie, tools for compositionally modular system .
. it uses the unix toolbox approach:
each module does just one thing well,
but has sophisticated and reliable mechanisms
for massive recomposition .
. forms of composition:
#functional: returns are piped to param's;
#data-flow: data filters piped;
#conventional modules: lib api calls;
# compositional modularity:
. interfaces and module impl's
operated on to obtain new modules .

. oop inheritance is a form of recomposition;
it's a linguistic mechanism that supports
reuse via incremental programming;
ie, describing a system in terms of
how it differs from another system .
. compositional modularity evolves
traditional modules beyond oop .

. that compositional modularity
sounds interesting,
what's the author been up to recently?
reflective cap'based security lang's!

Bracha 2010`Modules as Objects in Newspeak:
. a module can exist as several instances;
they can be mutually recursive .
. Newspeak, a msg-based lang has no globals,
and all names are late-bound (obj' msg's).
. programming to an interface (msg's vs methods)
is central to modularity .

. it features cap'based security:
# obj's can hide internals
even from other instances of the same class;
# obj's have no access to globals
thus avoiding [ambient authority]
(being modified by external agents) .
# unlike E-lang, Newspeak supports reflection .

Newspeak handles foreign functions
by wrapping them in an alien obj,
rather than let safe code
call unsafe functions directly .
--. this is the equivalent of SOA:
whatever you foreigners want to do,
do it on your own box (thread, module)
and send me the neat results .

2010-11-14

oop with frameworks

10.23: adda/oop/the 3 layers:
. Padlipsky, author of
The Elements of Networking Style:
"(If you know what you're doing,
three layers is enough...)

. oop'ing needs only 3 layers,
not endless inheritance ?
that reminds how I saw oop as simply
a layer under structured programming: [11.14:
the 1980's structured paradigm meant that
programs could create vocabularies with functions;
but they could create class types
like the native types that were provide
where there was the use of binary ideograms
and implicit coercions among related types .
. the types were provided,
then you built your vocabulary of functions
on top of those types .]
. at that time,
I had not yet thought about frameworks ...

. one place where many levels of
inheritance can be appreciated,
is within the system it was modeled after:
biological classifications of animals
involving inherited features or behaviors .

. I would say the 3rd layer of Padlipsky's oop
is the type cluster, just as type Number is
for the numeric subtypes {R,Q,N,Z,C};
notice the Number type.class is not abstract;
it has the code that handles binary operations, [11.14:
and diff's in operand subtype;
eg, you don't coerce an int to rational
if the rational's value happens to be integral .]
. objects can interact with each other based on
having context menu's which include
recognized submenu's .
. this is programming to interfaces,
and doesn't involve the impl'inheritance
that is usually associcated with oop .

. in summary, the 3 layers of oop are:
#1: a type having an interface to share;
#2: a type claiming to adopt a shared interface;
#3: an app that instantiates interface adopters .

. frameworks are a sort of
structured programming with generics;
you can think of generics as a
layer under stuctured code,
parallel with type.classes .
[11.14:
. a structure library
gives you a language of functions
which you may compose in various ways;
ie, the library is an employee,
and you're the exec .
. a framework library takes the exec' seat
letting you customize its decisions
with your own structure library .
. a datatype is like a structure library
but it's purpose is to control modifications
to the obj's it will create .]

2010-03-31

typedef syntax vs terminology trade-offs

3.25: adda/oop/classes vs types:

. if using 2 keywords for defining class vs type,
the class could mean a type that is an
adt (abstract data type),
so then one could replace the type`def's
angle brackets (used for an interface literal)
with a simple enclosure
since a class`def would always be an interface,
and would therefore no longer need a variety
of enclosures; eg, t.class: (,,,) .
3.30: adda/dstr/nominally typed structs:
. another way to avoid various enclosure types,
is to use typing of parentheses:
(.braces ,,,), (.set ,,,) .

. any reason to reserve the terms"{class, classwide}
for the way ada uses the concept of class-wide ?
[3.31: adda uses class-wide semantics universally ]
. notice the english meanings of
"(what type) vs "(what class),
or "(typical) vs "(classical) .
...
. a good reserved meaning for "(class) vs "(type),
is when dealing with generics,
eg, the class of scalars
includes many enum.types .
3.27:
. generally, the meaning of "(class) within the
field of logic -- the origins of oop nomenclature --
is a set defined by a predicate .
. a class can include many types,
and for many reasons .
. the type.classes of interest to oop and generics
are those where membership is defined by
shared interfaces .

2009-12-30

booking robotics

11.30: todo.adde/lib/pdf's on knowledge representation:

web.adde/wordnet:

WordNet is an online lexical reference system.
Word forms in WordNet are represented in their familiar orthography;
word meanings are represented by synonym sets (synsets)
- lists of synonymous word forms that are interchangeable in some context.
Two kinds of relations are recognized: lexical and semantic.
Lexical relations hold between word forms;
semantic relations hold between word meanings.
To learn more about WordNet, the book
containing an updated version of "Five Papers on WordNet"
and additional papers by WordNet users .
Several "standoff" files provide further semantic information

* The Morphosemantic Database
(Semantic relations between morphologically related nouns and verbs)
* The Teleological Database
(an encoding of typical activity for which artifact was intended)
* "Core" WordNet
A semi-automatically compiled list of 5000 "core" word senses in WordNet
(approximately the 5000 most frequently used word senses,
followed by some manual filtering and adjustment).
* Logical Forms for Glosses (Core WordNet Nouns)
Logical forms for the glosses of the ~2800 noun senses in core WordNet, in plain text format, using eventuality notation.
* Logical Forms for Glosses (All WordNet)
Logical forms for most of the glosses in WordNet 3.0
(except where generation failed), in XML format, using eventuality notation.

Texai is an chatbot that intelligently seeks to
acquire knowledge and friendly behaviors.
Important components include the RDF Entity Manager, the Texai Lexicon,
and Incremental Fluid Construction Grammar.
The blog

Cyc is an artificial intelligence project(unix)
that attempts to assemble a comprehensive ontology
and knowledge base of everyday common sense knowledge,
with the goal of enabling AI applications to perform human-like reasoning.
Now that wikipedia and opencyc are linked,[11]
a version of Wikipedia is being developed that enables
browsing the encyclopedia by cyc concepts.[12]

Cyc ontology whose domain is all of human consensus reality.
* Links between Cyc concepts and WordNet synsets.
* NEW! 100,000+ "broaderTerm" assertions, in addition to the previous generalization (subclass) and instance (member) assertions, to capture additional relations among concepts.
* NEW Links between Cyc concepts (including predicates) and the FOAF ontology.
* NEW! Links between Cyc concepts and Wikipedia articles.
* The entire Cyc ontology containing hundreds of thousands of terms,
along with millions of assertions relating the terms to each other,
forming an ontology whose domain is all of human consensus reality.
* English strings (a canonical one and alternatives)
corresponding to each concept term, to assist with search and display.
* The Cyc Inference Engine and the Cyc Knowledge Base Browser
are now Java-based for improved performance and increased platform portability.
* Documentation and self-paced learning materials
to help users achieve a basic- to intermediate-level understanding
of the issues of knowledge representation
and application development using Cyc.
* A specification of CycL,
the language in which Cyc (and hence OpenCyc) is written.
* A specification of the Cyc API
for application development.

I've been following the Texai discussion,
but I don't see how it overcomes the shortcomings of Cyc
such that it requires a very expensive process of
encoding knowledge explicitly.
This may have seemed like a sensible approach in the 1980's
when we lacked the computing power and training data to
implement statistical approaches.
But in hindsight the programming effort was grossly underestimated,
and we still don't know.
IMHO Cyc failed because it is based on models of artificial language
unrelated to the way children learn natural language.
In artificial languages,
you have to parse a sentence before you can understand it.
In natural language,
you have to understand a sentence before you can parse it.
I entirely agree with [that] comment above.
The notion of bootstrapping in the Texai English dialog system
is to learn the meanings of the most frequently occurring words
in the definitions of its yet-to-be-learned vocabulary,
and then by reading their definitions,
learn the meanings of the remaining words
with help from a multitude of volunteer mentors.
In particular Matt said:
you have to understand a sentence before you can parse it.
An analysis of the word usage frequency in the Texai vocabulary definitions
reveals that knowing perhaps only 10000 frequently occurring words
should be enough to understand half
of the whole lexicon of 85000 English words.
I acknowledge that there must be a very expensive process of
encoding knowledge explicitly.
Like Cycorp's initial approach for DARPA's
Rapid Knowledge Formation project,
for which I was the first project manager,
Texai will use English dialog to rapidly acquire knowledge.
I hypothesize that such dialog greatly reduces the expense
of teaching new facts to the system,
and also permits a vast multitude of volunteer mentors to divide the effort:
many hands make light work.

. a family of knowledge representation languages for authoring ontologies .
OWL Characteristics
OWL provides the capability of creating classes, properties, defining instances and its operations.
* Classes:
User-defined classes which are subclasses of root class owl:Thing. A class may contain individuals, which are instances of the class, and other subclasses. For example, Employee could be the subclass of class owl:Thing while Dealer, Manager, and Labourer all subclass of Employee.
* Properties:
A property is a binary relation that specifies class characteristics. They are attributes of instances and sometimes act as data values or link to other instances.
There are two types of simple properties:
datatype and object properties.
Datatype properties are relations between instances of classes
and RDF literals or XML schema datatypes.
* Instances:
Instances are individuals that belong to the classes defined. A class may have any number of instances. Instances are used to define the relationship among different classes.
* Operations:
OWL supports various operations on classes such as union, intersection and complement. It also allows class enumeration, cardinality, and disjointness.
TDWG have an ontology for taxonomy[21].