## Type Checking and Type Inferencing for Logic Programs with Subtypes and Parametric Polymorphism (1996)

Venue: | Subtypes and Parametric Polymorphism, Informatik Berichte 200, Fern Universitat |

Citations: | 10 - 3 self |

### BibTeX

@INPROCEEDINGS{Meyer96typechecking,

author = {Gregor Meyer},

title = {Type Checking and Type Inferencing for Logic Programs with Subtypes and Parametric Polymorphism},

booktitle = {Subtypes and Parametric Polymorphism, Informatik Berichte 200, Fern Universitat},

year = {1996}

}

### OpenURL

### Abstract

We analyze basic shortcomings of existing proposals for type checking and type inferencing in logic programming languages. A new type system is presented using simple and declarative type annotations. It includes parametric polymorphism and subtyping. Static type checking and inferencing within the new type system is able to detect more programming errors than in other comparable systems. Our approach is independent of a specific resolution calculus and therefore applicable to a wide range of logic languages. A type inferencing algorithm is presented for reconstructing variable typings. As a concrete instance, the results were applied to unrestricted standard Prolog with type annotations, for which a type checking and type inferencing tool is available. This report is part of the documentation for a type checking tool available at !URL:http://www.fernuni-hagen.de/pi8/typical/?. It is complemented by a report "On the Use of Types in Logic Programming" [Mey96]. Research supported by ...

### Citations

984 | A theory of type polymorphism in programming
- MILNER
- 1978
(Show Context)
Citation Context ... if wanted. Given countably infinite many (value) variables v, terms t are described by the abstract grammar t ::= v j f(t 1 ; \Delta \Delta \Delta ; t n ) A variable typing V T , also called prefix (=-=[Mil78]), is a -=-set of type assignments for variables in the form fv 1 : �� 1 ; \Delta \Delta \Delta ; v k : �� k g, with pairwise distinct (value) variables v i . Type substitutions are extended to variable ... |

871 | Foundations of Constraint Satisfaction
- Tsang
- 1993
(Show Context)
Citation Context ... \Gamma; \Gamma 2 Mg and S is not empty. These transformations result in a set C s of constraints over the finite set of type symbols (T; ). Standard constraint solving techniques can be applied (cf. =-=[Tsa93]-=-). The computational complexity of solving constraints over partial ordered set is rather high in the general case. The need for solving least upper bound constraints y = t(S) makes the problem even h... |

796 | On understanding types, data abstraction, and polymorphism
- Cardelli, Wegner
- 1985
(Show Context)
Citation Context ...structor symbols. A ground type term, i.e. without type variables, is called monomorphic, while a type term containing type parameters is called a type scheme, parametric, or polymorphic. In terms of =-=[CW86]-=- parametric polymorphism corresponds to universal quantification and has to be distinguished from subtype polymorphism. In this report, polymorphism will generally mean parametric polymorphism. 2.2.2 ... |

552 | Lambda calculi with types - Barendregt - 1992 |

382 | Principal type-schemes for functional programs - Damas, Milner - 1982 |

144 |
A polymorphic type system for Prolog
- Mycroft, O’Keefe
- 1984
(Show Context)
Citation Context ...e ability to find type errors is rather restricted, because hints for the intended meaning of predicates are missing. An ML-like type system for logic programming was proposed by Mycroft and O'Keefe (=-=[MO84]-=-. It includes explicit type declarations and parametric polymorphism but no subtypes. Most prominently the languages Godel [HL94] and Mercury [Som95] are based on this kind of type system. But it is n... |

98 | Type inference with simple subtypes - Mitchell - 1991 |

82 | On the occur-check free Prolog programs - Apt, Pellegrini - 1994 |

77 |
Towards a theory of types in Prolog
- Mishra
- 1984
(Show Context)
Citation Context ...relations to other sytems proposed in the literature. The last section gives a conclusion and an outlook on applications of this approach. 1.1 Shortcomings of other type systems Starting with Mishra (=-=[Mis84]-=-), several authors have proposed type checking mechanisms that do not require explicit type declarations as part of the program. A type inference procedure is used to find so-called useless clauses. U... |

59 | Logic Programming over Polymorphically Order-Sorted Types
- Smolka
- 1989
(Show Context)
Citation Context ...ls �� 2 T with the arity(��) = 0. Later we will distinguish a subset TV 0 of TV. To give some intuition in advance, TV 0 contains don't-care type variables, which play a role similar to the ty=-=pe ? in [Smo89]-=-. They will be exploited for computing principal types. In the following, (T;ss ) is generally assumed to be a quasi-lattice. This condition is needed in order to be able to compute the principal type... |

57 | Typed Prolog: A semantic reconstruction of the Mycroft-O’Keefe type system - Lakshman, Reddy - 1991 |

55 | A framework of directionality for proving termination of logic programs - Bronsard, Lakshman, et al. |

49 |
A semantics for typed logic programs
- Hill, Topor
(Show Context)
Citation Context ...re commonly used for typed -calculus ([DM82, Bar92, Mit91]). V T ` t : �� is true if and only if it is derivable using the rules (Var), (Func), (Subtype): 1 This condition is called `transparency'=-= in [HT92] and `type prese-=-rving' in [Han89]. It is also part of the `minimality condition' in [Smo88]. (Var) V T [ fv : ��g ` v : �� T (Func) V T ` t 1 : \Theta(�� 1 ) \Delta \Delta \Delta V T ` t k : \Theta(��... |

44 | Directional type checking of logic programs - Aiken, Lakshman - 1994 |

28 | Polymorphically typed logic programs - Yardeni, Frühwirth, et al. - 1992 |

27 | Algorithmic aspects of type inference with subtypes
- Lincoln, Mitchell
- 1992
(Show Context)
Citation Context ...se. The need for solving least upper bound constraints y = t(S) makes the problem even harder. Satisfiability of -constraints in partial ordered sets, i.e. even without t-constraints, is NP-complete (=-=[LM92]-=- [PT95]). For lattices the problem is known to be in PTIME, but for quasi-lattices the problem remains NP-complete. Another computational complexity comes from overloaded function symbols. Backtrackin... |

24 | Type inferencing for polymorphic order-sorted logic programs - Beierle - 1995 |

22 | luszynsky. Two aspects of directional types - Boye, Ma - 1995 |

19 |
Logic programming with type specifications
- Hanus
- 1992
(Show Context)
Citation Context ...versions. 2.5.4 Definitional genericity There are several variants for the well-typing of clauses reported in the literature. E.g., Hanus defines a type system allowing for so-called lemma generation =-=[Han92]-=-, this corresponds to our notion of weak type-consistency. In many cases it is useful to disallow this feature for clauses by imposing a so-called head-condition or definitional genericity requirement... |

18 | Integrating modes and subtypes into a prolog type-checker - Rouzaud, Nguyen-Phuong - 1992 |

15 |
Polymorphic higher-order programming in Prolog
- Hanus
- 1989
(Show Context)
Citation Context ...ulus ([DM82, Bar92, Mit91]). V T ` t : �� is true if and only if it is derivable using the rules (Var), (Func), (Subtype): 1 This condition is called `transparency' in [HT92] and `type preserving'=-= in [Han89]. It is also par-=-t of the `minimality condition' in [Smo88]. (Var) V T [ fv : ��g ` v : �� T (Func) V T ` t 1 : \Theta(�� 1 ) \Delta \Delta \Delta V T ` t k : \Theta(�� k ) V T ` f(t 1 ; \Delta \Delta ... |

14 | Inference of polymorphic types for logic programs - Pyo, Reddy - 1989 |

12 | A First-order Theory of Types and Polymorphism in Logic Programming
- Wu
- 1992
(Show Context)
Citation Context ...rict the language or impose a run-time overhead that is not accepted by most programmers. Closer to our type system are proposals using so-called implication types [Red88, PR89] or type dependencies (=-=[KW90], see al-=-so [CK93]). An example for a type dependency is appendhlist(T ); list(T ); list(T )=1; 2 ! 3; 3 ! 1; 2i. Its meaning is: For all �� , if the first two arguments of append have the type list(��... |

11 | Logic programming with typed unification and its realization on an abstract machine - Beierle |

11 |
Run-time type computations in the Warren Abstract Machine
- Beierle, Meyer
- 1994
(Show Context)
Citation Context ...amming and require the resolution and its unification to obey the type constraints on variables. In that case, i.e. using an inference calculus implementing the correct order-sorted unification as in =-=[BM94]-=-, the goal absdist(5,4,D) fails. With respect to detecting the programming error in this example, the practical consequences of using or leaving out order-sorted unification are essentially the same: ... |

11 | Notions of polymorphism for predicate logic programs - Reddy |

10 |
Parametric order-sorted types in logic programming
- Hanus
- 1991
(Show Context)
Citation Context ...tions cause a few details for the definition of type-consistency and in the type inference algorithm given below. We could forbid such declarations and apply a program transformation such as given in =-=[Han91] whi-=-ch introduces new artificial (type) variables but we found such transformations not satisfying. Given some variable typing V T and a term t, a principal type �� of the term t has the property: t h... |

9 | TEL (Version 0.9) Report and User Manual
- Smolka
- 1988
(Show Context)
Citation Context ...nly if it is derivable using the rules (Var), (Func), (Subtype): 1 This condition is called `transparency' in [HT92] and `type preserving' in [Han89]. It is also part of the `minimality condition' in =-=[Smo88]. (Var) V T [ fv : ���-=-�g ` v : �� T (Func) V T ` t 1 : \Theta(�� 1 ) \Delta \Delta \Delta V T ` t k : \Theta(�� k ) V T ` f(t 1 ; \Delta \Delta \Delta ; t k ) : \Theta(��) T if f : �� 1 \Theta : : : \Th... |

8 |
The Gödel Programming Language. Logic programming series
- Hill, Lloyd
- 1994
(Show Context)
Citation Context ...type system for logic programming was proposed by Mycroft and O'Keefe ([MO84]. It includes explicit type declarations and parametric polymorphism but no subtypes. Most prominently the languages Godel =-=[HL94]-=- and Mercury [Som95] are based on this kind of type system. But it is not possible to model often needed type hierarchies as in `integers are numbers and numbers are expressions', not to speak of obje... |

5 | Dimensions of types in logic programming
- Meyer, Beierle
- 1998
(Show Context)
Citation Context ...his report is part of the documentation for a type checking tool available at !URL:http://www.fernuni-hagen.de/pi8/typical/?. It is complemented by a report "On the Use of Types in Logic Programm=-=ing" [Mey96]. Research-=- supported by DFG within "Schwerpunkt Deduktion" Contents 1 Introduction 1 1.1 Shortcomings of other type systems : : : : : : : : : : : : : : : : : 1 1.2 A new approach : : : : : : : : : : :... |

4 | Polymorphic types in higher-order logic programming
- Chen, Kifer
- 1993
(Show Context)
Citation Context ... or impose a run-time overhead that is not accepted by most programmers. Closer to our type system are proposals using so-called implication types [Red88, PR89] or type dependencies ([KW90], see also =-=[CK93]). An ex-=-ample for a type dependency is appendhlist(T ); list(T ); list(T )=1; 2 ! 3; 3 ! 1; 2i. Its meaning is: For all �� , if the first two arguments of append have the type list(�� ) then so does t... |

2 |
The Mercury project. http://www.cs.mu.oz.au/~zs/mercury.html
- Somogyi
- 1995
(Show Context)
Citation Context ...ic programming was proposed by Mycroft and O'Keefe ([MO84]. It includes explicit type declarations and parametric polymorphism but no subtypes. Most prominently the languages Godel [HL94] and Mercury =-=[Som95]-=- are based on this kind of type system. But it is not possible to model often needed type hierarchies as in `integers are numbers and numbers are expressions', not to speak of object-oriented extensio... |

1 | Typed prolog. ftp://a.cs.uiuc.edu/pub/reddy/typedprolog - Lakshman - 1991 |

1 | Prolog type-checker. typecheck.pl in ftp://doc.ic.ac.uk/packages/prolog-pd-software/tools.tar.Z - O'Keefe - 1984 |

1 |
Satisfiability of inequalities in a poset. Tr 95-15(215
- Pratt, Tiuryn
- 1995
(Show Context)
Citation Context ... need for solving least upper bound constraints y = t(S) makes the problem even harder. Satisfiability of -constraints in partial ordered sets, i.e. even without t-constraints, is NP-complete ([LM92] =-=[PT95]-=-). For lattices the problem is known to be in PTIME, but for quasi-lattices the problem remains NP-complete. Another computational complexity comes from overloaded function symbols. Backtracking leads... |