## `Dom::BaseDomain` -- the root of the domain hierarchy

#### Introduction

`Dom::BaseDomain` is the root of the domain hierarchy of the `Dom` package. Every domain of the package inherits from it.

#### Domain

`Dom::BaseDomain()`

#### Details

- `Dom::BaseDomain` is the root of the domain hierarchy as defined by the `Dom` package. Every domain of the package inherits from it.
- The only purpose of `Dom::BaseDomain` is to supply all domains of the package with some basic methods like `"hasProp"`. Elements of `Dom::BaseDomain` cannot be created.
- Unlike other super-domains this domain does not impose any restrictions on the representation of the elements of its sub-domains. Thus it may be a super-domain for any domain created by a domain constructor.

#### Categories

`Cat::BaseCategory`

#### Entries

create_dom

  This domain entry is used to revive the domain when it is read from a binary MCode stream.

  If this entry is present it is written to the MCode stream instead of the contents of the domain. When the stream is read it is used to create the domain.

  If this entry does not exist all entries of the domain are written to the stream and read in later to create the domain.

  `Dom::BaseDomain` defines `"create_dom"` to have the same value as the key of the domain, as stored in the entry `"key"`. All domains of the `Dom` package inherit this entry, thus they must be created by the reader of the MCode stream by evaluating the expression stored in the key.

#### Method equal: test for mathematical equality

- `equal(dom x, dom y)`
- - This method must return `TRUE` if it can decide that `x` is equal to `y` in the mathematical sense imposed by this domain. It must return `FALSE` if it can decide that `x` is not equal to `y` mathematically. If the method cannot decide the equality it must return `UNKNOWN`, see `Cat::BaseCategory`.
  - If this domain has the axiom `Ax::canonicalRep`, which implies that two domain elements are mathematically equal if and only if they are structurally equal, the kernel function `_equal` is used to decide the equality. In this case `UNKNOWN` is never returned.
  - If the axiom `Ax::canonicalRep` does not hold the method will return `TRUE` if `x` and `y` are structurally equal (in the sense of the function `_equal`) and `UNKNOWN` otherwise.

#### Method convert_to: convert element

- `convert_to(dom x, type T)`
- - This method may be used to convert elements of this domain to a given type `T`. It returns `FAIL` if a conversion is not possible.
  - The implementation provided here can convert `x` to an element of this domain (the trivial case) or to an element of `Dom::Expression` (by using the method `"expr"`, see `Cat::BaseCategory`).

#### Method TeX: generate TeX output

- `TeX(dom x)`
- - Returns a TeX-formatted string for `x`.
  - The default implementation provided here converts `x` into an expression using the method `"expr"` and then uses the function `generate::TeX` to convert the expression.

#### Method allAxioms: return all axioms

- `allAxioms()`
- - Returns a set containing all axioms holding for this domain, as stated explicitly or in the inherited domains or categories.

#### Method allCategories: return all categories

- `allCategories()`
- - Returns a list containing all all categories of this domain. The order of the categories in the list is the order which is used to search for entries of the categories.

#### Method allEntries: return the names of all entries

- `allEntries()`
- - Returns a set containing the names of all entries of this domain.

#### Method allSuperDomains: return all super-domains

- `allSuperDomains()`
- - Returns a list containing all super-domains of this domain. The order of the domains in the list is given by the domain hierarchy: The first domain is the direct super-domain, the second the direct super-domain of the first and so on.
  - The last, most general, super-domain of all domains of the `Dom` package is `Dom::BaseDomain`.

#### Method getAxioms: return axioms stated in the constructor

- `getAxioms()`
- - Returns a set containing the axioms stated directly for this domain.

#### Method getCategories: return categories stated in the constructor

- `getCategories()`
- - Returns a list containing the categories of this domain which are are listed directly by the domain constructor.

#### Method getSuperDomain: return super-domain stated in the constructor

- `getSuperDomain()`
- - Returns the direct super-domain of this domain as given by the domain constructor.

#### Method hasProp: test for a certain property

- `hasProp(DOM_DOMAIN d)`
- - Tests if the domain `d` is this domain or a super-domain of this domain.

- `hasProp(DomainConstructor dc)`
- - Tests if this domain or a super-domain of it was defined by the domain constructor `dc`.

- `hasProp(Axiom a)`
- - Tests if this domain has the axiom `a`.

- `hasProp(AxiomConstructor ac)`
- - Tests if an axiom of this domain was defined by the axiom constructor `ac`.

- `hasProp(Category c)`
- - Tests if this domain has the category `c`.

- `hasProp(CategoryConstructor cc)`
- - Tests if a category of this domain was defined by the category constructor `cc`.

#### Method info: prints short information about this domain

- `info()`
- - This method overloads the function `info`.
  - It prints out the super-domains, categories, axioms and entry names of this domain.
  - If an entry `"info_str"`, which must be a string, is defined for this domain it is used to print the header line.

#### Method printMethods: prints out methods

- `printMethods( <function sort,> Table)`
- - Sorts the names of all entries of this domain using the function `sort` and then prints them. The entries are grouped according to the domains and categories defining them and printed out in a tabular form.
  - If no sorting function is given, `sort` is used as default.

- `printMethods( <function sort,> Tree)`
- - Similar as above, only that the names of the entries are inserted into a tree, an element of the domain `adt::Tree`. The tree is both printed out and returned by the method.

- `printMethods( <function sort>)`
- - Does the same as `dom::printMethods(sort, Table)`.

#### Method subs: avoid substitution

- `subs(dom x, ...)`
- - This method overloads the function `subs`. The implementation provided here simply returns `x` in any case, so it avoids unwanted substitutions inside of domain elements.
  - Sub-domains should provide a new implementation of this method with sensible semantics if possible.

#### Method subsex: avoid extended substitution

- `subsex(dom x, ...)`
- - This method overloads the function `subsex`. The implementation provided here simply returns `x` in any case, so it avoids unwanted substitutions inside of domain elements.
  - Sub-domains should provide a new implementation of this method with sensible semantics if possible.

#### Method undefinedEntries: return missing entries

- `undefinedEntries()`
- - Returns a set containing the names of all those entries of this domain that are missing.
  - An entry is missing if it should have a definition according to a category of the domain, but the definition is not present.

#### Method whichEntry: return the domain or category implementing an entry

- `whichEntry(e)`
- - Returns the domain or category which implements the entry with name `e`.
  - `FAIL` is returned if no entry with the given name is defined for this domain.

#### Changes

- New methods: `"create_dom"` and `"printMethods"`.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000