The relationship between a language and its type system is one of the most crucial aspects of engineering the language; this is as true for rule languages as any other formal language intended to be processed automatically.
The purpose of this series of questions is to try to ascertain what kind of support there is for types in the rule language. The range of possible type systems is huge, so it is a little difficult to ensure that one questionnaire covers all the possibilities.
We are attempting to answer the following core questions about types:
  1. A.The range of possible types, for example whether types are simple or have structure (i.e., polymorphic types, object types, collection types), whether recursive types are permitted, whether type definitions and/or type renaming are permitted.
  2. B.What relationships between types, such as subtyping, are supported.
  3. C.What the relationship is between types and values in the language.
  4. D.What form of type processing is supported/required by the language: whether types are processed statically (before runtime) or dynamically (at runtime), or both, whether types are inferred or verified only, and so on.
In the following questions, we will use the abbreviation RL to denote the rule language, type-free if appropriate; and TL will refer to the type language. (It is quite possible for TL=RL, in some systems. In general they are distinct.)
Is the language typed?
  1. 1.Does the RL support any form of types on terms, predicates and other program elements?
Note: If no, please read following questions, you might decide to re-answer this question.
  1. 2.Does the language support any form of explicit type language (=TL) ?
  2. 3.Does the language require type safety checks on the arity and/or input arguments of built-ins? (E.g., does the arithmetic addition operator verify that the arguments are numbers?)
  3. 4.Can a type violation cause a different kind of result from a normal failure/negative response?
Note: if yes, then the language supports dynamic types on terms.
About the type language
  1. 5.Do types have names? I.e., is type equivalence defined as type name equivalence or structural equivalence (a.k.a. type unification)?
  2. 6.Are TL terms simple names, or may a TL term be a function term (i.e., may a type term contain other type terms as arguments)?
Note: if yes, then the type language support parametric polymorphism.
  1. 7.Does the TL support standard complex type terms?
  2. 8.Are collection types supported?
  3. 9.Are array types supported?
  4. 10.Are set/bag types supported?
  5. 11.Are index types supported? (I.e., can the index of an array or collection be typed separately?)
  6. 12.Are list types supported?
  7. 13.Are tuple types/type tuples supported?
  8. 14.Are numeric interval types supported?
  9. 15.Are class types supported?
  10. 16.Are higher-order elements of the RL given specific TL terms? E.g., can function types be used as arguments of other types?
  11. 17.Is there any distinction between primitive types (e.g., numbers) and other types? (I.e., does the term “boxable” apply to the TL?)
  12. 18.Does the language support any form of reference type?
Note: Reference types are a kind of pointer type often used in conjunction with re-assignable variables.
  1. 19.For parametric polymorphic type systems, are there any distinctions between the types permitted on reference types as compared to non-reference types?
Note: Many functional programming languages have complex rules associated with the type targets of reference types; such as not permitting polymorphism in such cases.
  1. 20.Is it possible to define new types?
  2. 21.Is it possible to define type aliases?
  3. 22.Can a type be defined extensionally? (a.k.a. algebraic types)
  4. 23.Can a type be defined intensionally?
  5. 24.Does the TL permit definition of recursive types?
  6. 25.Is it possible to define arbitrary predicates over type terms?
Note: if yes, then the language is likely not type decidable.
  1. 26.Does the language support any predefined predicates over type terms?
  2. 27.Does the language support any form of sub-type relation over type terms?
Note: if yes, then the language supports sub-type polymorphism
  1. 28.Does the TL support existential types? E.g., is it possible to write rules that can 'recover' a type of an argument whose type is obscured?
  2. 29.Does the language support type reflection? I.e., can the type of an expression be reified, and can the type of an expression be determined to be consistent with a reified type expression?
Note: if yes, then the language must also support type casting.
  1. 30.Does the language support type interfaces?
  2. 31.Can a type interface include assertions as well as pure type descriptions?
  3. 32.Can a type interface capture preconditions/postconditions/invariants?
  4. a.Preconditions only
  5. b.Preconditions and postconditions
  6. c.Preconditions, postconditions and invariants
  7. 33.Are types of large scale entities such as classes, modules, packages etc. part of the TL.?
  8. 34.Does the type system support the assembly of rule systems from multiple sources? (I.e., are features such as loading of modules also type safe?)
Relationship between the TL and the RL
  1. 35.Are TL terms syntactically distinct from RL terms that denote values?
  2. 36.Are TL terms semantically distinct from RL terms that denote values?
  3. 37.Are TL terms permitted as value terms in rules?
Note: if yes, then language supports explicit dynamic typing
  1. 38.Which statement is more accurate for the relationship between type terms and other elements of the language:
  2. a.The type system induces an abstract interpretation over the sets of rules.
  3. b.The type system partitions the universe of elements into disjoint categories.
  4. c.The type system represents a system of monadic predicates with a distinguished interpretation.
  5. d.All of the above.
  6. e.None of the above.
Note: this is an attempt to gain a rough characterization of the semantics of types vs the semantics of rules themselves.
  1. 39.Does the language system perform type consistency verification independently of any queries?
Note: if yes, then the language supports static type checking
  1. 40.Does the language permit more than one type interpretation of any terms/rules/functions/predicates etc.?
Note: if yes, then the language is weakly typed, if no, then the language is strongly typed.
  1. 41.Does the language permit more than one type for any function/predicate/action symbol?
Note: if yes, then the language supports overloading.
Note: this is different to previous question, it is possible to be strongly type checked and to support overloading.
  1. 42.Are type assignments to RL terms inferred automatically by the type systems?
  2. 43.Can type inference infer recursive types for RL expressions?
  3. 44.Are all elements of the RL associated with unique elements from TL?
  4. 45.Can a type of an element of the RL be left as a type variable?
Note: this, together with type terms being structured, means that the language supports parametric polymorphism. On its own, permitting free variables to denote types is a marker for support for generics.
  1. 46.Does the language permit annotations on expressions that further constrain the type of the expression?
  2. 47.Does the RL language permit type casting?
  3. 48.Does the language permit runtime evaluation if one or more type inconsistencies are detected?
  4. 49.Does the language permit individual rules to select on the type of the arguments (as opposed to the values of the arguments)?
Note: if yes, the language supports type restrictions.
  1. 50.If the TL and RL support classes, what is the correspondence between a class type and a class implementation:
  2. a.Each class type has exactly one implementation
  3. b.An interface can be implemented by any number of implementations
  4. c.A class type can be implemented by any number of class implementations
  5. 51.Which statement is more accurate?
  6. a.Predicates are typed, tuples are not.
  7. b.Each tuple in a relation carries an independent type assignment.