(type [type-name] st [symbol])
(type [type-parent-name] st [type-name])

(type [base-type-def] st [sexp]
  (typedef 
     `(type ,[type-name] st ,[type-parent-name]
        @,listOf[type-attribute]) ) )
         
(type [type-def] <=> union[[BaseTypeDef], ... ]

(type [object] st [Top]) 
(type [named-object] st [object]) 
(type [model] st [object]) 
(type [modeler] st of [model]) 

-----------------------------------------------------

(type [model] subtype [named-object]
  (name *type* [model-name])
  (current *type* [model-name])
  (context *type* [fol-context])
  (|objects| [object]
              (*range* @ 0 INF)
              (flag . AMOOE)
              (split (attribute-name (key . name))) )
  (|type-def-table| [type-spec]
              (*range* @ 0 INF)
              (flag . AMOOE)
              (split (attribute-name (key . name))) )
  (tsys *type* [Tsys])
  (dsys *type* [Csys])
  (fsys *type* [Fsys])
  (constraint (and
    (= tsys.ksysname name)
    (= csys.ksysname name)
    (= fsys.ksysname name) ) )
)

(type [modeler] subtype [model]
  (name [model-name])
  (current-model [model-name])
  (|objects) [model]
              (*range* @ 0 INF)
              (flag . AMOOE)
              (split (attribute-name (key . name))) )
  (|type-def-table| [type-spec]
              (*range* @ 0 INF)
              (flag . AMOOE)
              (split (attribute-name (key . name))) )
  (constraint 
    (member current-model (attributes-of type-def-table (val name))) )
)

(type [Tsys] subtype [sys]
  (name *type* [tsys-name])
  (ksys-name *type* [ksys-name])
  (current-typename [SplitName]) 
  (type-table [type-spec]
              *range* [0-INF]
              *flag* AMOOE
              *split* attribute-name key: type-table.name
  (types [Type]
         *range* [0-INF]
         :flag AMOOE  
         :split integer)
)

; type [Tsys] is a subtype of [Type]
;    name type: [TsysName]
;    is composed of 
;        type-table type: [typeSpec]
;                   range: [0-INF]
;                   flag: AMOOE
;                   split: attribute-name key: alist-att;
;        types type: [Type]
;              range: |0-INF|
;              flag: AMOOE  
;              split: integer;

[TypeSpec] <==> alist[ [type-name],
                       tuple3[ [parent-type-name],[type-def],[type-tree] ] ] 

(type [Csys] subtype [Type]
  (name *type* [csys-name])
)
; type [Fsys] is a subtype of [Type]
;    name type: [FsysName]

; type [Application] is a subtype of [Type]
;    Its attributes are
;        current-model type: [SplitName];
;        Ksys type: [Ksys];
;    Is composed of 
;        symbol-table type: [TypeDef]
;                     range: [0-INF]
;                     flag: AMOOE
;                     split: attribute-name key: name;
;        configuration type: [Type]
;                      range: |0-INF|
;                      flag: AMOOE  
;                      split: integer;

(defparameter *application-typedef* 
  '(type [Application] subtype [Type]
     (iaa 
       (current-model-name *type* [SplitName]) 
       (name *type* [symbol])
       (ksys [Ksys]) )
     (ico
       (configuration [type] (*range* 1 INF) (*dm* AMOOE)
        (split integer) )
       (symbol-table [type-def] (*range* 1 INF) (*dm* AMOOE)
        (split attribute-name (key name) ))
))



; Type [AppApp] is a subtype of [Application] 
;    Its resrictions are
;        symbol-table type: [TypeDef]
;                     range: [0-INF]
;                     flag: AMOOE
;                     split: attribute-name key: name;
;        configuration type: [Application]
;                      range: |0-INF|
;                      flag: AMOOE  
;                      split: integer;


(defparameter *appapp-typedef* 
  '(type [AppApp] subttpe [Aaplication]
     (current-model-name *type* [split-name]) 
     (name *type* [symbol])
     (ksys *type* [Ksys])
     (icr 
       (symbol-table [typeDef] (*range* 1 INF) (*dm* AMOOE)
        (split attribute-name (key name) ))
       (configuration [application] (*range* 1 INF) (*dm* AMOOE)
        (split integer) ) ) )
)     (current-model-name [SplitName]) 
     (name [SYMBOL])
     (Ksys [Ksys])
     (symbol-table [typeDef] (*range* 1 INF) (*dm* AMOOE)
        (split attribute-name (key name) ))
     (head [Ksys] (*range* 1 INF) (*dm* AMOOE)
        (split integer) )
))))