Functional Programming

Total Page:16

File Type:pdf, Size:1020Kb

Load more

Functional Programming Sexy types in action Editor: Philip Wadler, University of Edinburgh; [email protected] Chung-chieh Shan Harvard University Cambridge MA 02138 USA The Hindley-Milner type system (Hindley 1969; Mil- tiating a polymorphic type. ner 1978) and its Damas-Milner inference algorithm E : τ (Damas and Milner 1982) for the λ-calculus (Church 8I (a does not escape) (2a) 1932, 1940) are widely adopted in modern functional pro- Λa: E : 8a: τ 0 gramming languages like Haskell and ML. The system E : 8a: τ 8E (2b) delicately balances power and tractability: many poly- Eτ : τ0[τ/a] morphic functions can be built, and many safety con- straints checked, without bogging down compilers in un- In the 8I rule above, the type variable a that is quantified decidability or programmers in verbosity. over must not escape—that is, it must not appear free in an undischarged typing assumption. When a type checker As programmers became familiar with the system's uses this rule bottom-up to check a universal type, it en- power, however, they also became frustrated by its lim- sures that the side condition on the type variable a holds itations. Much recent research thus explores the design by generating a fresh dummy type (termed an eigenvari- space beyond the Hindley-Milner-Damas system, termed able) and substituting it for a. That is, it α-converts the “sexy types” by Peyton Jones (2003). Two features of- bound variable a in 8a: τ. ten requested and implemented are higher-rank polymor- 0 phism and existential types. This annotated bibliography In the 8E rule above, τ [τ/a] denotes the capture- 0 summarizes these features (§1) and motivates them by avoiding substitution of τ for a in τ . The result of the enumerating their present-day applications (§2–3). substitution is said to subsume the universally quantified type 8a: τ0. The term syntax of the polymorphic typed λ-calculus 1 Polymorphic typed λ-calculus makes both of these rules explicit. For example, the polymorphic identity function is written as the term Λ A polymorphic value is one that can take multiple types. a: λx : a: x. It is given the type 8a: a ! a by the fol- We are concerned here with parametric polymorphism lowing derivation. (Strachey 1967), which corresponds to universal quantifi- [x : a] cation over types. To start, we review the typing rules for !Ix the polymorphic (or second-order) typed λ-calculus, also λx : a: x : a ! a 8I known as System F, invented independently by Girard Λa: λx : a: x : 8a: a ! a (1972; Girard et al. 1989) and Reynolds (1974, 1990). Because it is too verbose to mark every introduction and A function is created by discharging an assumption in elimination of a universal quantifier, we would like to the typing environment, and invoked by applying it to a make the rules in (2) implicit in terms, as follows. value of the appropriate argument type. E : τ E : 8a: τ0 [x : τ] 8I (a does not escape) 8E (3) · 0 · 0 E : 8a: τ E : τ [τ/a] · F : τ ! τ E : τ 0 !E (1) E : τ 0 We would also like to omit the argument type τ in the x FE : τ !I function term λx : τ. E. Unfortunately, this move makes λx : τ. E : τ ! τ0 type checking and type inference undecidable (Wells Universal quantification is introduced by generalizing the 1999). To recover decidability while preserving implicit type of a value, and eliminated by specializing or instan- polymorphism, the Hindley-Milner-Damas type system 1 Functional Programming trades off expressive power by restricting the rank of than 1. Type inference for rank-2 polymorphism is de- types to 1. The rank of a type is the maximum number of cidable without any help in the form of additional type function arrows to the left of which a universal quantifier annotations by the programmer, but is too complicated to appears. Formally, the following syntax defines a strati- be implemented so far (Kfoury and Tiuryn 1992; Kfoury fied language of rank-n types τn, where n ranges over the and Wells 1994). Type inference for arbitrarily higher- non-negative integers. rank polymorphism requires programmer annotations in order to be decidable. Several such systems have been τ0 ::= a τ0 ! τ0 proposed and implemented in production compilers such + + + τn 1 ::= 8a: τn 1 τn ! τn 1 as the Glasgow Haskell Compiler (Jones 1997; Odersky and Läufer 1996; Peyton Jones and Shields 2004; Le Bot- 0 A rank-0 type τ has no universal quantifier; it is called a lan and Rémy 2003). monotype. Hindley, Milner, and Damas's innovation is to require monotypes in (1), allow rank-1 types in (3), and add the “let” construct below for polymorphic assump- 2.1 Algebraic data types tions (Clément et al. 1986). Polymorphic functions can encode recursive data types [x : τ1] · (Reynolds 1983; Reynolds and Plotkin 1993; Böhm and · Berarducci 1985). For example, a singly-linked list of · (4) E : τ1 E0 : τ0 integers is defined in Haskell as Letx = 0 τ0 data IntegerList = Nil Cons Integer IntegerList; let x E in E : In the polymorphic typed λ-calculus, the only (closed) but we can encode this recursive data type as the poly- term of the type 8a: a ! a is the identity function. morphic function type In general, terms in the polymorphic typed λ-calculus ≡ 8 : ! ! ! ! : are always parametric, which intuitively means that a IntegerList l l (Integer l l) l value acts “uniformly” at all types it can take, regardless Informally speaking, a list of integers is equivalent to a of how universally quantified type variables are instanti- parametrically polymorphic function that maps a pair of ated. A function that negates booleans while leaving non- list constructors (one for the empty list and one for non- booleans unchanged would not be parametric. This prop- empty lists) to a list, for any (abstract) list data type. erty of uniformity, or type abstraction (Reynolds 1983), is usually formalized by introducing logical relations be- tween types and guaranteeing that, for example, a func- 2.2 Lazy functional state threads tion always maps related arguments to related results. The runST function, for running a stateful computation A semantic model of the polymorphic typed λ-calculus in a purely functional language like Haskell (Launchbury is said to be parametric if all of its values are paramet- and Peyton Jones 1994, 1995; Moggi and Sabry 2001), ric, so the only value in the model that has the type has the rank-2 type 8a: a ! a, for example, is the identity function. In other words, if f is a function from a to b, and g is a value of 8a: (8s: ST s a) ! a: type 8a: a ! a, then a parametric model guarantees that f ◦ g = g ◦ f . More generally, each polymorphic type The type variable s is a dummy that identifies the state gives rise to a parametricity law, an equation satisfied by thread being run: two operations that are performed any value expressible as a λ-term and any value in a para- within the same state thread automatically have their s metric model (Reynolds 1983; Wadler 1989, 2004). As variables unified by the type checker. The type for runST we will see below, useful parametricity laws tend to arise thus ensures that state does not leak or interfere with other from higher-rank polymorphism. stateful computations. The proof of this safety property uses parametricity at the type 8s: ST s a. 2 Higher-rank polymorphism 2.3 Generic (polytypic) programming Extensions to Hindley, Milner, and Damas's system al- A type a is a “traversable term” type if any traversal on low higher-rank polymorphism: types with rank higher the subterms of a can be “lifted” to a traversal on a itself. 2 Functional Programming For instance, if we have a traversal on list elements, then Here m is the monad in which impure computations take we have a traversal on lists: place. If we need to move from one monad m1 to another monad m2, then we need a function to map Value m1 map :: 8a: (a ! a) ! ([a] ! [a]) to Value m2. Such a function would have the following rank-2 (and higher-order polymorphic) type: This idea of lifting traversals from subterms to terms can be combined with a moderate amount of run-time 8m1:8m2:(8a:m1 a ! m2 a) ! (Value m1 ! Value m2): type-safe casting to achieve a form of generic program- ming (Lämmel and Peyton Jones 2003). The traversable The coproducts technique of monad combination (Lüth types a belong to a type class Term, which supports oper- and Ghani 2002) can also be viewed as a type of second- ations such as order kind whose values are manipulated by functions of higher rank. Given two well-behaved monads m1 and m , their coproduct Plus m m is a new monad, gmapT :: (8b: Term b ) b ! b) ! 2 1 2 where the type constructor Plus has the second-order kind (8a: Term a ) a ! a): (∗ ! ∗) ! (∗ ! ∗) ! (∗ ! ∗). Accompanying the type constructor Plus is a term combinator coprod, which has Note that this operation has a rank-2 type: the type vari- the rank-2 type able b is universally quantified over (with a type-class constraint) to the left of an arrow. 8m1: 8m2: 8n: (Monad m1; Monad m2; Monad n) ) If one wishes to avoid run-time type-casting, then (8a: m1 a ! n a) ! (8a: m2 a ! n a) ! one would need to manually write—or mechanically (8a: Plus m1 m2 a ! n a): generate—a slightly different traversal function for every type or type constructor over which generic processing is desired.
Recommended publications
  • Structured Recursion for Non-Uniform Data-Types

    Structured Recursion for Non-Uniform Data-Types

    Structured recursion for non-uniform data-types by Paul Alexander Blampied, B.Sc. Thesis submitted to the University of Nottingham for the degree of Doctor of Philosophy, March 2000 Contents Acknowledgements .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 1 Chapter 1. Introduction .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 2 1.1. Non-uniform data-types .. .. .. .. .. .. .. .. .. .. .. .. 3 1.2. Program calculation .. .. .. .. .. .. .. .. .. .. .. .. .. 10 1.3. Maps and folds in Squiggol .. .. .. .. .. .. .. .. .. .. .. 11 1.4. Related work .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 14 1.5. Purpose and contributions of this thesis .. .. .. .. .. .. .. 15 Chapter 2. Categorical data-types .. .. .. .. .. .. .. .. .. .. .. .. 18 2.1. Notation .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 19 2.2. Data-types as initial algebras .. .. .. .. .. .. .. .. .. .. 21 2.3. Parameterized data-types .. .. .. .. .. .. .. .. .. .. .. 29 2.4. Calculation properties of catamorphisms .. .. .. .. .. .. .. 33 2.5. Existence of initial algebras .. .. .. .. .. .. .. .. .. .. .. 37 2.6. Algebraic data-types in functional programming .. .. .. .. 57 2.7. Chapter summary .. .. .. .. .. .. .. .. .. .. .. .. .. 61 Chapter 3. Folding in functor categories .. .. .. .. .. .. .. .. .. .. 62 3.1. Natural transformations and functor categories .. .. .. .. .. 63 3.2. Initial algebras in functor categories .. .. .. .. .. .. .. .. 68 3.3. Examples and non-examples .. .. .. .. .. .. .. .. .. .. 77 3.4. Existence of initial algebras in functor categories .. .. .. .. 82 3.5.
  • Proving Termination of Evaluation for System F with Control Operators

    Proving Termination of Evaluation for System F with Control Operators

    Proving termination of evaluation for System F with control operators Małgorzata Biernacka Dariusz Biernacki Sergue¨ıLenglet Institute of Computer Science Institute of Computer Science LORIA University of Wrocław University of Wrocław Universit´ede Lorraine [email protected] [email protected] [email protected] Marek Materzok Institute of Computer Science University of Wrocław [email protected] We present new proofs of termination of evaluation in reduction semantics (i.e., a small-step opera- tional semantics with explicit representation of evaluation contexts) for System F with control oper- ators. We introduce a modified version of Girard’s proof method based on reducibility candidates, where the reducibility predicates are defined on values and on evaluation contexts as prescribed by the reduction semantics format. We address both abortive control operators (callcc) and delimited- control operators (shift and reset) for which we introduce novel polymorphic type systems, and we consider both the call-by-value and call-by-name evaluation strategies. 1 Introduction Termination of reductions is one of the crucial properties of typed λ-calculi. When considering a λ- calculus as a deterministic programming language, one is usually interested in termination of reductions according to a given evaluation strategy, such as call by value or call by name, rather than in more general normalization properties. A convenient format to specify such strategies is reduction semantics, i.e., a form of operational semantics with explicit representation of evaluation (reduction) contexts [14], where the evaluation contexts represent continuations [10]. Reduction semantics is particularly convenient for expressing non-local control effects and has been most successfully used to express the semantics of control operators such as callcc [14], or shift and reset [5].
  • The Lambda Calculus Is Algebraic

    The Lambda Calculus Is Algebraic

    Under consideration for publication in J. Functional Programming 1 2 P. Selinger point of view. We suggest another way of looking at the problem, which yields a sense in which the lambda calculus is equivalent to an algebraic theory. The Lambda Calculus is Algebraic The basic observation is that the failure of the ξ-rule is not a deficiency of the lambda calculus itself, nor of combinatory algebras, but rather it is an artifact of the way free variables are interpreted in a model. Under the usual interpretation, free variables are in- PETER SELINGER terpreted as elements of a lambda algebra A. Thus, an equation M = N between terms Department of Mathematics and Statistics University of Ottawa, Ottawa, Ontario K1N 6N5, Canada is said to be satisfied if it holds whenever the free variables of M and N are replaced by (e-mail: [email protected]) elements of A. We call this the local interpretation. We suggest a different interpretation, called the absolute interpretation, under which free variables are interpreted as indetermi- nates. Let A[x1 ...xn] be the lambda algebra obtained from A by freely adjoining elements Abstract x1 ...xn. Under the absolute interpretation, an equation M = N is said to be satisfied if it holds in A[x1 ...xn]. This paper serves as a self-contained, tutorial introduction to combinatory models of the untyped The fundamental observationof this paper is that the two interpretations do not coincide, lambda calculus. We focus particularly on the interpretation of free variables. We argue that free and that the absolute interpretation satisfies all rules of the lambda calculus, including the variables should not be interpreted as elements in a model, as is usually done, but as indeterminates.
  • Binary Search Trees

    Binary Search Trees

    Introduction Recursive data types Binary Trees Binary Search Trees Organizing information Sum-of-Product data types Theory of Programming Languages Computer Science Department Wellesley College Introduction Recursive data types Binary Trees Binary Search Trees Table of contents Introduction Recursive data types Binary Trees Binary Search Trees Introduction Recursive data types Binary Trees Binary Search Trees Sum-of-product data types Every general-purpose programming language must allow the • processing of values with different structure that are nevertheless considered to have the same “type”. For example, in the processing of simple geometric figures, we • want a notion of a “figure type” that includes circles with a radius, rectangles with a width and height, and triangles with three sides: The name in the oval is a tag that indicates which kind of • figure the value is, and the branches leading down from the oval indicate the components of the value. Such types are known as sum-of-product data types because they consist of a sum of tagged types, each of which holds on to a product of components. Introduction Recursive data types Binary Trees Binary Search Trees Declaring the new figure type in Ocaml In Ocaml we can declare a new figure type that represents these sorts of geometric figures as follows: type figure = Circ of float (* radius *) | Rect of float * float (* width, height *) | Tri of float * float * float (* side1, side2, side3 *) Such a declaration is known as a data type declaration. It consists of a series of |-separated clauses of the form constructor-name of component-types, where constructor-name must be capitalized.
  • Lecture Notes on Types for Part II of the Computer Science Tripos

    Lecture Notes on Types for Part II of the Computer Science Tripos

    Q Lecture Notes on Types for Part II of the Computer Science Tripos Prof. Andrew M. Pitts University of Cambridge Computer Laboratory c 2016 A. M. Pitts Contents Learning Guide i 1 Introduction 1 2 ML Polymorphism 6 2.1 Mini-ML type system . 6 2.2 Examples of type inference, by hand . 14 2.3 Principal type schemes . 16 2.4 A type inference algorithm . 18 3 Polymorphic Reference Types 25 3.1 The problem . 25 3.2 Restoring type soundness . 30 4 Polymorphic Lambda Calculus 33 4.1 From type schemes to polymorphic types . 33 4.2 The Polymorphic Lambda Calculus (PLC) type system . 37 4.3 PLC type inference . 42 4.4 Datatypes in PLC . 43 4.5 Existential types . 50 5 Dependent Types 53 5.1 Dependent functions . 53 5.2 Pure Type Systems . 57 5.3 System Fw .............................................. 63 6 Propositions as Types 67 6.1 Intuitionistic logics . 67 6.2 Curry-Howard correspondence . 69 6.3 Calculus of Constructions, lC ................................... 73 6.4 Inductive types . 76 7 Further Topics 81 References 84 Learning Guide These notes and slides are designed to accompany 12 lectures on type systems for Part II of the Cambridge University Computer Science Tripos. The course builds on the techniques intro- duced in the Part IB course on Semantics of Programming Languages for specifying type systems for programming languages and reasoning about their properties. The emphasis here is on type systems for functional languages and their connection to constructive logic. We pay par- ticular attention to the notion of parametric polymorphism (also known as generics), both because it has proven useful in practice and because its theory is quite subtle.
  • Recursive Type Generativity

    Recursive Type Generativity

    Recursive Type Generativity Derek Dreyer Toyota Technological Institute at Chicago [email protected] Abstract 1. Introduction Existential types provide a simple and elegant foundation for un- Recursive modules are one of the most frequently requested exten- derstanding generative abstract data types, of the kind supported by sions to the ML languages. After all, the ability to have cyclic de- the Standard ML module system. However, in attempting to extend pendencies between different files is a feature that is commonplace ML with support for recursive modules, we have found that the tra- in mainstream languages like C and Java. To the novice program- ditional existential account of type generativity does not work well mer especially, it seems very strange that the ML module system in the presence of mutually recursive module definitions. The key should provide such powerful mechanisms for data abstraction and problem is that, in recursive modules, one may wish to define an code reuse as functors and translucent signatures, and yet not allow abstract type in a context where a name for the type already exists, mutually recursive functions and data types to be broken into sepa- but the existential type mechanism does not allow one to do so. rate modules. Certainly, for simple examples of recursive modules, We propose a novel account of recursive type generativity that it is difficult to convincingly argue why ML could not be extended resolves this problem. The basic idea is to separate the act of gener- in some ad hoc way to allow them. However, when one considers ating a name for an abstract type from the act of defining its under- the semantics of a general recursive module mechanism, one runs lying representation.
  • The System F of Variable Types, Fifteen Years Later

    The System F of Variable Types, Fifteen Years Later

    Theoretical Computer Science 45 (1986) 159-192 159 North-Holland THE SYSTEM F OF VARIABLE TYPES, FIFTEEN YEARS LATER Jean-Yves GIRARD Equipe de Logique Mathdmatique, UA 753 du CNRS, 75251 Paris Cedex 05, France Communicated by M. Nivat Received December 1985 Revised March 1986 Abstract. The semantic study of system F stumbles on the problem of variable types for which there was no convincing interpretation; we develop here a semantics based on the category-theoretic idea of direct limit, so that the behaviour of a variable type on any domain is determined by its behaviour on finite ones, thus getting rid of the circularity of variable types. To do so, one has first to simplify somehow the extant semantic ideas, replacing Scott domains by the simpler and more finitary qualitative domains. The interpretation obtained is extremely compact, as shown on simple examples. The paper also contains the definitions of a very small 'universal model' of lambda-calculus, and investigates the concept totality. Contents Introduction ................................... 159 1. Qualitative domains and A-structures ........................ 162 2. Semantics of variable types ............................ 168 3. The system F .................................. 174 3.1. The semantics of F: Discussion ........................ 177 3.2. Case of irrt ................................. 182 4. The intrinsic model of A-calculus .......................... 183 4.1. Discussion about t* ............................. 183 4.2. Final remarks ...............................
  • An Introduction to Logical Relations Proving Program Properties Using Logical Relations

    An Introduction to Logical Relations Proving Program Properties Using Logical Relations

    An Introduction to Logical Relations Proving Program Properties Using Logical Relations Lau Skorstengaard [email protected] Contents 1 Introduction 2 1.1 Simply Typed Lambda Calculus (STLC) . .2 1.2 Logical Relations . .3 1.3 Categories of Logical Relations . .5 2 Normalization of the Simply Typed Lambda Calculus 5 2.1 Strong Normalization of STLC . .5 2.2 Exercises . 10 3 Type Safety for STLC 11 3.1 Type safety - the classical treatment . 11 3.2 Type safety - using logical predicate . 12 3.3 Exercises . 15 4 Universal Types and Relational Substitutions 15 4.1 System F (STLC with universal types) . 16 4.2 Contextual Equivalence . 19 4.3 A Logical Relation for System F . 20 4.4 Exercises . 28 5 Existential types 29 6 Recursive Types and Step Indexing 34 6.1 A motivating introduction to recursive types . 34 6.2 Simply typed lambda calculus extended with µ ............ 36 6.3 Step-indexing, logical relations for recursive types . 37 6.4 Exercises . 41 1 1 Introduction The term logical relations stems from Gordon Plotkin’s memorandum Lambda- definability and logical relations written in 1973. However, the spirit of the proof method can be traced back to Wiliam W. Tait who used it to show strong nor- malization of System T in 1967. Names are a curious thing. When I say “chair”, you immediately get a picture of a chair in your head. If I say “table”, then you picture a table. The reason you do this is because we denote a chair by “chair” and a table by “table”, but we might as well have said “giraffe” for chair and “Buddha” for table.
  • Lightweight Linear Types in System F°

    Lightweight Linear Types in System F°

    University of Pennsylvania ScholarlyCommons Departmental Papers (CIS) Department of Computer & Information Science 1-23-2010 Lightweight linear types in System F° Karl Mazurak University of Pennsylvania Jianzhou Zhao University of Pennsylvania Stephan A. Zdancewic University of Pennsylvania, [email protected] Follow this and additional works at: https://repository.upenn.edu/cis_papers Part of the Computer Sciences Commons Recommended Citation Karl Mazurak, Jianzhou Zhao, and Stephan A. Zdancewic, "Lightweight linear types in System F°", . January 2010. Karl Mazurak, Jianzhou Zhao, and Steve Zdancewic. Lightweight linear types in System Fo. In ACM SIGPLAN International Workshop on Types in Languages Design and Implementation (TLDI), pages 77-88, 2010. doi>10.1145/1708016.1708027 © ACM, 2010. This is the author's version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, {(2010)} http://doi.acm.org/10.1145/1708016.1708027" Email [email protected] This paper is posted at ScholarlyCommons. https://repository.upenn.edu/cis_papers/591 For more information, please contact [email protected]. Lightweight linear types in System F° Abstract We present Fo, an extension of System F that uses kinds to distinguish between linear and unrestricted types, simplifying the use of linearity for general-purpose programming. We demonstrate through examples how Fo can elegantly express many useful protocols, and we prove that any protocol representable as a DFA can be encoded as an Fo type. We supply mechanized proofs of Fo's soundness and parametricity properties, along with a nonstandard operational semantics that formalizes common intuitions about linearity and aids in reasoning about protocols.
  • Deriving Logical Relations from Interpretations of Predicate Logic

    Deriving Logical Relations from Interpretations of Predicate Logic

    Replace this file with prentcsmacro.sty for your meeting, or with entcsmacro.sty for your meeting. Both can be found through links on the ENTCS Web Page. Deriving Logical Relations from Interpretations of Predicate Logic Claudio Hermida1 Uday S. Reddy2 University of Birmingham Edmund P. Robinson3;4 Queen Mary, University of London Abstract This paper extends the results of Hermida's thesis about logical predicates to more general logical relations and a wider collection of types. The extension of type constructors from types to logical relations is derived from an interpretation of those constructors on a model of predicate logic. This is then further extended to n-ary relations by pullback. Hermida's theory shows how right adjoints in the category of fibrations are composed from a combination of Cartesian lifting and a local adjunction. This result is generalised to make it more applicable to left adjoints, and then shown to be stable under pullback, deriving an account of n-ary relations from standard predicate logic. A brief discussion of lifting monads to predicates includes the existence of an initial such lifting, generalising existing results. Keywords: logical relations, fibrations, categorical type theory, monadic types 1 Introduction The purpose of this paper is to illustrate a link between logical relations and predicate logics. We begin by revisiting the conditions under which the predicates in a predicate logic for reasoning about a type theory can be shown to carry the structure of that type theory. We then show that similar structure on binary and more generally n-ary relations can be derived from that on unary predicates.
  • Data Structures Are Ways to Organize Data (Informa- Tion). Examples

    Data Structures Are Ways to Organize Data (Informa- Tion). Examples

    CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 1 ] What are Data Structures? Data structures are ways to organize data (informa- tion). Examples: simple variables — primitive types objects — collection of data items of various types arrays — collection of data items of the same type, stored contiguously linked lists — sequence of data items, each one points to the next one Typically, algorithms go with the data structures to manipulate the data (e.g., the methods of a class). This course will cover some more complicated data structures: how to implement them efficiently what they are good for CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 2 ] Abstract Data Types An abstract data type (ADT) defines a state of an object and operations that act on the object, possibly changing the state. Similar to a Java class. This course will cover specifications of several common ADTs pros and cons of different implementations of the ADTs (e.g., array or linked list? sorted or unsorted?) how the ADT can be used to solve other problems CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 3 ] Specific ADTs The ADTs to be studied (and some sample applica- tions) are: stack evaluate arithmetic expressions queue simulate complex systems, such as traffic general list AI systems, including the LISP language tree simple and fast sorting table database applications, with quick look-up CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 4 ] How Does C Fit In? Although data structures are universal (can be imple- mented in any programming language), this course will use Java and C: non-object-oriented parts of Java are based on C C is not object-oriented We will learn how to gain the advantages of data ab- straction and modularity in C, by using self-discipline to achieve what Java forces you to do.
  • The Proper Treatment of Variables in Predicate Logic

    The Proper Treatment of Variables in Predicate Logic

    The Proper Treatment of Variables in Predicate Logic Kai F. Wehmeier University of California, Irvine Abstract Bertrand Russell (1903, x93) observed that “the variable is a very complicated logi- cal entity, by no means easy to analyze correctly”. This assessment is borne out by the fact that even now we have no fully satisfactory understanding of the role of variables in a compositional semantics for first-order logic. In standard Tarskian semantics, variables are treated as meaning-bearing entities; moreover, they serve as the basic building blocks of all meanings, which are constructed out of variable assignments. But this has disquieting consequences, including Fine’s antinomy of the variable and an undue dependence of meanings on language (representation- alism). Here I develop an alternative, Fregean version of predicate logic that uses the traditional quantifier–variable apparatus for the expression of generality, pos- sesses a fully compositional, non-representational semantics, and is not subject to the antinomy of the variable. The advantages of Fregean over Tarskian predicate logic are due to the former’s treating variables not as meaningful lexical items, but as mere marks of punctuation, similar to parentheses. I submit that this is indeed how the variables of predicate logic should be construed. 1 1 Introduction In standard, Tarski-style syntax for first-order logic, atomic formulas are constructed from predicate symbols and an appropriate number of variables and names. Truth- functional connectives can be used to form new formulas out of ones already con- structed. From any formula already constructed, and any individual variable, a new formula can be obtained by first writing a quantifier symbol, appending the chosen variable, and then appending the original formula.