Unifying Functional Programming and Logical Reasoning in a Language Based on Mendler-Style Recursion Schemes and Term-Indexed Types

Total Page:16

File Type:pdf, Size:1020Kb

Unifying Functional Programming and Logical Reasoning in a Language Based on Mendler-Style Recursion Schemes and Term-Indexed Types Portland State University PDXScholar Dissertations and Theses Dissertations and Theses Fall 12-16-2014 The Nax Language: Unifying Functional Programming and Logical Reasoning in a Language based on Mendler-style Recursion Schemes and Term-indexed Types Ki Yung Ahn Portland State University Follow this and additional works at: https://pdxscholar.library.pdx.edu/open_access_etds Part of the Programming Languages and Compilers Commons Let us know how access to this document benefits ou.y Recommended Citation Ahn, Ki Yung, "The Nax Language: Unifying Functional Programming and Logical Reasoning in a Language based on Mendler-style Recursion Schemes and Term-indexed Types" (2014). Dissertations and Theses. Paper 2088. https://doi.org/10.15760/etd.2086 This Dissertation is brought to you for free and open access. It has been accepted for inclusion in Dissertations and Theses by an authorized administrator of PDXScholar. Please contact us if we can make this document more accessible: [email protected]. The Nax Language : Unifying Functional Programming and Logical Reasoning in a Language based on Mendler-style Recursion Schemes and Term-indexed Types by Ki Yung Ahn A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Science Dissertation Committee: Tim Sheard, Chair James Hook Mark P. Jones Andrew Tolmach Douglas V. Hall Portland State University 2014 i ABSTRACT Two major applications of lambda calculi in computer science are functional programming languages and mechanized reasoning systems (or, proof assistants). According to the Curry–Howard correspondence, it is possible, in principle, to design a unified language based on a typed lambda calculus for both logical rea- soning and programming. However, the different requirements of programming languages and reasoning systems make it difficult to design such a unified language useful for both purposes. Programming languages usually extend lambda calculi with programming-friendly features (e.g., recursive datatypes, general recursion) for supporting the flexibility to model various computations, while sacrificing log- ical consistency. Logical reasoning systems usually extend lambda calculi with logic-friendly features (e.g., induction principles, dependent types) for paradox- free inference over fine-grained properties, while being more restrictive in modeling computations. In this dissertation, we design and implement a language called Nax that bal- ances between the benefits of both. Nax accepts all recursive datatypes, thus, al- lowing the same flexibility of defining recursive datatypes as functional languages. Nax supports a number of Mendler-style recursion schemes that can express various kinds of recursive computations and also grantee termination. Nax supports term- indexed types to support specifications of fine-grained properties. In addition, Nax supports a conservative extension of Hindley–Milner type inference. The theoretical contributions of this dissertation include theories for Mendler- style recursion schemes and term-indexed types, which we developed to establish strong normalization and logical consistency of Nax. ii DEDICATION To the Logos from the beginning of the universe, who was with the creator and the creator himself, the source of all beings, and the light of life shines in the darkness. iii ACKNOWLEDGMENTS I would like to thank my advisor Tim Sheard, who has always been patient and open to experimenting with new ideas, the members of the dissertation committee for their useful feedback, and special thanks to Andrew M. Pitts and Marcelo Fiore for the discussions greatetly improved my theiss research during the visit to Cambridge, UK, and also to Gabor Grief, who gave feedback on my thesis related research. Many thanks to my parents, Rev. Sam Whan Kim, and friends in Myungsung Presbyterian Church for their love and prayers from the other side of the Pacific; the young adults’ group in Oregon Eden Presbyterian Church for being a warm and dynamic community; and, to coach Ruth Aquino and friends in the Lloyd Center Ice Rink, where I chilled out in the evenings. iv Table of Contents Abstract i Dedication ii Acknowledgments iii List of Tables ix List of Figures x Part I Prelude 1 Chapter 1 Introduction 2 1.1 Programming and Formal Reasoning . 2 1.1.1 The Curry–Howard correspondence . 3 1.1.2 Logical consistency and strong normalization . 9 1.1.3 Datatypes and recursion schemes . 10 1.2 Motivation . 15 1.3 Thesis . 17 1.4 Mendler-style recursion and term-indexed types . 18 1.4.1 Restriction on recursive types for normalization . 18 1.4.2 Justification of Mendler style as a design choice. 22 1.4.3 Term-indexed types, type inference, and datatypes . 23 1.5 Contributions . 25 1.5.1 Contributions related to Mendler style . 25 1.5.2 Contributions to the theory of term-indexed types . 27 1.5.3 Contributions towards the Nax language design . 27 1.5.4 Contributions identifying open problems . 29 v 1.6 Chapter organization . 30 Chapter 2 Polymorphic type systems 35 2.1 Simply-typed lambda calculus . 35 2.1.1 Strong normalization . 38 2.1.2 Motivations for polymorphic type systems . 44 2.2 System F ................................. 45 2.2.1 Encoding datatypes in System F . 48 2.2.2 Subject reduction and strong normalization . 54 2.3 System Fω ................................ 59 2.3.1 Encodings of datatypes in System Fω . 62 2.3.2 Strong normalization . 69 2.4 The Hindley–Milner type system . 75 2.4.1 Syntax . 77 2.4.2 Declarative typing rules . 80 2.4.3 Syntax-directed typing rules . 84 2.4.4 The type inference algorithm W . 87 Part II Mendler style 90 Chapter 3 Mendler-style recursion schemes 91 3.1 Introduction . 92 3.1.1 Background - Termination and Negativity . 94 3.1.2 Historical progression . 96 3.1.3 Roadmap to a tour of the Mendler-style approach . 98 3.2 Defining regular recursive datatypes . 102 3.3 Conventional iteration for regular datatypes . 103 3.4 Mendler-style iteration for regular datatypes . 104 3.5 Mendler-style course-of-values iteration for regular datatypes . 106 3.6 Mendler-style iteration and course-of-values iteration over negative datatypes . 110 3.7 Mendler-style iteration and course-of-values iteration over non-regular datatypes and mutually recursive datatypes . 114 3.7.1 Nested datatypes . 114 3.7.2 Indexed datatypes (GADTs) . 121 vi 3.7.3 Mutually recursive datatypes . 123 3.8 Mendler-style primitive recursion (mpr) . 126 3.9 Mendler-style iteration with syntactic inverses . 131 3.9.1 Formatting HOAS . 132 3.9.2 Fω encoding ofµ ˘∗ and msfit∗ . 139 3.9.3 Evaluating Simply Typed HOAS . 142 3.9.4 A graph datatype with cycles and sharing . 145 3.9.5 Additional Mendler-style combinators . 145 3.10 Properties of recursion combinators . 148 Part III Term-Indexed Lambda Calculi 152 Chapter 4 System Fi 153 4.1 System Fi ................................156 4.1.1 Design of System Fi . 156 4.1.2 System Fi compared to System Fω . 161 4.2 Embedding datatypes and Mendler-style iterators . 164 4.2.1 Embedding datatypes using Church-encoded terms . 164 4.2.2 Embedding recursive datatypes as two-level types . 168 4.2.3 Leibniz index equality . 172 4.3 Metatheory . 174 4.3.1 Well-formedness properties and substitution lemmas . 174 4.3.2 Erasure properties . 176 4.3.3 Strong normalization and logical consistency . 183 Chapter 5 System Fixi 184 5.1 System Fixi ...............................185 5.1.1 Polarities . 190 5.1.2 Equi-recursive type operator fix . 192 5.2 Embedding datatypes and primitive recursion . 193 5.3 Embedding course-of-values recursion . 196 5.3.1 General form for the embedding of course-of-values recursion 199 5.3.2 Embedding unrollers . 200 5.3.3 Deriving uniform embeddings of the unrollers . 202 5.3.4 Properties of unrollers . 208 vii 5.4 Metatheory of Fixi . 210 5.4.1 Strong normalization and logical consistency . 210 5.4.2 Syntactic conditions for well-behaved course-of-values recur- sion . 213 Part IV Nax Language 220 Chapter 6 Introduction to Features of the Nax Language 221 6.1 Two-level types . 221 6.2 Creating values . 223 6.3 Synonyms, constructor functions, and fixpoint derivation . 223 6.4 Mendler combinators for non-indexed types . 224 6.5 Types with static indices . 230 6.6 Mendler-style combinators for indexed types . 232 6.7 Recursive types of unrestricted polarity but restricted elimination . 236 6.8 Lessons from Nax . 238 Chapter 7 Design Principles of Nax’s Type System 240 7.1 Introduction . 240 7.2 The trilingual Rosetta Stone . 242 7.2.1 Type-preserving evaluator for an expression language . 242 7.2.2 Generic Paths parametrized by a binary relation . 247 7.2.3 Stack-safe compiler for the expression language . 253 7.3 Discussion . 254 7.3.1 Universes, kinds, and well-sortedness . 254 7.3.2 Nested Term Indices and Datatypes Containing Types . 257 7.4 Related Work . 259 7.5 Summary and Future Work . 262 Chapter 8 Type Inference in Nax 263 8.1 SmallNax . 263 8.2 SmallNax with Mendler-style recursion . 269 8.2.1 A review of monomorphic recursion and polymorphic recursion270 8.2.2 Typing rules for Mendler-style recursion combinators . 270 8.3 SmallNax with GADTs . 273 8.3.1 Existential type variables . 273 viii 8.3.2 Generalized existential type variables and index transformers 275 Part V Postlude 278 Chapter 9 Related work 279 9.1 Mendler-style co-iteration and co-recursion . 279 9.2 Mendler-style recursion schemes over multiple values . 284 9.2.1 Simultaneous iteration . 284 9.2.2 Lexicographic recursion . 286 9.3 Mendler-style induction . 287 9.4 Type-based termination and sized types . 288 9.5 Logical Frameworks based on the λΠ-calculus .
Recommended publications
  • 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.
    [Show full text]
  • Confusion in the Church-Turing Thesis Has Obscured the Funda- Mental Limitations of Λ-Calculus As a Foundation for Programming Languages
    Confusion in the Church-Turing Thesis Barry Jay and Jose Vergara University of Technology, Sydney {Barry.Jay,Jose.Vergara}@uts.edu.au August 20, 2018 Abstract The Church-Turing Thesis confuses numerical computations with sym- bolic computations. In particular, any model of computability in which equality is not definable, such as the λ-models underpinning higher-order programming languages, is not equivalent to the Turing model. However, a modern combinatory calculus, the SF -calculus, can define equality of its closed normal forms, and so yields a model of computability that is equivalent to the Turing model. This has profound implications for pro- gramming language design. 1 Introduction The λ-calculus [17, 4] does not define the limit of expressive power for higher- order programming languages, even when they are implemented as Turing ma- chines [69]. That this seems to be incompatible with the Church-Turing Thesis is due to confusion over what the thesis is, and confusion within the thesis itself. According to Soare [63, page 11], the Church-Turing Thesis is first mentioned in Steven Kleene’s book Introduction to Metamathematics [42]. However, the thesis is never actually stated there, so that each later writer has had to find their own definition. The main confusions within the thesis can be exposed by using the book to supply the premises for the argument in Figure 1 overleaf. The conclusion asserts the λ-definability of equality of closed λ-terms in normal form, i.e. syntactic equality of their deBruijn representations [20]. Since the conclusion is false [4, page 519] there must be a fault in the argument.
    [Show full text]
  • Software Developement Tools Introduction to Software Building
    Software Developement Tools Introduction to software building SED & friends Outline 1. an example 2. what is software building? 3. tools 4. about CMake SED & friends – Introduction to software building 2 1 an example SED & friends – Introduction to software building 3 - non-portability: works only on a Unix systems, with mpicc shortcut and MPI libraries and headers installed in standard directories - every build, we compile all files - 0 level: hit the following line: mpicc -Wall -o heat par heat par.c heat.c mat utils.c -lm - 0.1 level: write a script (bash, csh, Zsh, ...) • drawbacks: Example • we want to build the parallel program solving heat equation: SED & friends – Introduction to software building 4 - non-portability: works only on a Unix systems, with mpicc shortcut and MPI libraries and headers installed in standard directories - every build, we compile all files - 0.1 level: write a script (bash, csh, Zsh, ...) • drawbacks: Example • we want to build the parallel program solving heat equation: - 0 level: hit the following line: mpicc -Wall -o heat par heat par.c heat.c mat utils.c -lm SED & friends – Introduction to software building 4 - non-portability: works only on a Unix systems, with mpicc shortcut and MPI libraries and headers installed in standard directories - every build, we compile all files • drawbacks: Example • we want to build the parallel program solving heat equation: - 0 level: hit the following line: mpicc -Wall -o heat par heat par.c heat.c mat utils.c -lm - 0.1 level: write a script (bash, csh, Zsh, ...) SED
    [Show full text]
  • Lambda Calculus Encodings
    CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC330 Fall 2017 1 The Power of Lambdas Despite its simplicity, the lambda calculus is quite expressive: it is Turing complete! Means we can encode any computation we want • If we’re sufficiently clever... Examples • Booleans • Pairs • Natural numbers & arithmetic • Looping 2 Booleans Church’s encoding of mathematical logic • true = λx.λy.x • false = λx.λy.y • if a then b else c Ø Defined to be the expression: a b c Examples • if true then b else c = (λx.λy.x) b c → (λy.b) c → b • if false then b else c = (λx.λy.y) b c → (λy.y) c → c 3 Booleans (cont.) Other Boolean operations • not = λx.x false true Ø not x = x false true = if x then false else true Ø not true → (λx.x false true) true → (true false true) → false • and = λx.λy.x y false Ø and x y = if x then y else false • or = λx.λy.x true y Ø or x y = if x then true else y Given these operations • Can build up a logical inference system 4 Quiz #1 What is the lambda calculus encoding of xor x y? - xor true true = xor false false = false - xor true false = xor false true = true A. x x y true = λx.λy.x B. x (y true false) y false = λx.λy.y C. x (y false true) y if a then b else c = a b c not = λx.x false true D. y x y 5 Quiz #1 What is the lambda calculus encoding of xor x y? - xor true true = xor false false = false - xor true false = xor false true = true A.
    [Show full text]
  • Unfold/Fold Transformations and Loop Optimization of Logic Programs
    Unfold/Fold Transformations and Loop Optimization of Logic Programs Saumya K. Debray Department of Computer Science The University of Arizona Tucson, AZ 85721 Abstract: Programs typically spend much of their execution time in loops. This makes the generation of ef®cient code for loops essential for good performance. Loop optimization of logic programming languages is complicated by the fact that such languages lack the iterative constructs of traditional languages, and instead use recursion to express loops. In this paper, we examine the application of unfold/fold transformations to three kinds of loop optimization for logic programming languages: recur- sion removal, loop fusion and code motion out of loops. We describe simple unfold/fold transformation sequences for these optimizations that can be automated relatively easily. In the process, we show that the properties of uni®cation and logical variables can sometimes be used to generalize, from traditional languages, the conditions under which these optimizations may be carried out. Our experience suggests that such source-level transformations may be used as an effective tool for the optimization of logic pro- grams. 1. Introduction The focus of this paper is on the static optimization of logic programs. Speci®cally, we investigate loop optimization of logic programs. Since programs typically spend most of their time in loops, the generation of ef®cient code for loops is essential for good performance. In the context of logic programming languages, the situation is complicated by the fact that iterative constructs, such as for or while, are unavailable. Loops are usually expressed using recursive procedures, and loop optimizations have be considered within the general framework of inter- procedural optimization.
    [Show full text]
  • A Right-To-Left Type System for Value Recursion
    1 A right-to-left type system for value recursion 61 2 62 3 63 4 Alban Reynaud Gabriel Scherer Jeremy Yallop 64 5 ENS Lyon, France INRIA, France University of Cambridge, UK 65 6 66 1 Introduction Seeking to address these problems, we designed and imple- 7 67 mented a new check for recursive definition safety based ona 8 In OCaml recursive functions are defined using the let rec opera- 68 novel static analysis, formulated as a simple type system (which we 9 tor, as in the following definition of factorial: 69 have proved sound with respect to an existing operational seman- 10 let rec fac x = if x = 0 then 1 70 tics [Nordlander et al. 2008]), and implemented as part of OCaml’s 11 else x * (fac (x - 1)) 71 type-checking phase. Our check was merged into the OCaml distri- 12 Beside functions, let rec can define recursive values, such as 72 bution in August 2018. 13 an infinite list ones where every element is 1: 73 Moving the check from the middle end to the type checker re- 14 74 let rec ones = 1 :: ones stores the desirable property that compilation of well-typed programs 15 75 Note that this “infinite” list is actually cyclic, and consists of asingle does not go wrong. This property is convenient for tools that reuse 16 76 cons-cell referencing itself. OCaml’s type-checker without performing compilation, such as 17 77 However, not all recursive definitions can be computed. The MetaOCaml [Kiselyov 2014] (which type-checks quoted code) and 18 78 following definition is justly rejected by the compiler: Merlin [Bour et al.
    [Show full text]
  • Unix Tools 2
    Unix Tools 2 Jeff Freymueller Outline § Variables as a collec9on of words § Making basic output and input § A sampler of unix tools: remote login, text processing, slicing and dicing § ssh (secure shell – use a remote computer!) § grep (“get regular expression”) § awk (a text processing language) § sed (“stream editor”) § tr (translator) § A smorgasbord of examples Variables as a collec9on of words § The shell treats variables as a collec9on of words § set files = ( file1 file2 file3 ) § This sets the variable files to have 3 “words” § If you want the whole variable, access it with $files § If you want just the second word, use $files[2] § The shell doesn’t count characters, only words Basic output: echo and cat § echo string § Writes a line to standard output containing the text string. This can be one or more words, and can include references to variables. § echo “Opening files” § echo “working on week $week” § echo –n “no carriage return at the end of this” § cat file § Sends the contents of a file to standard output Input, Output, Pipes § Output to file, vs. append to file. § > filename creates or overwrites the file filename § >> filename appends output to file filename § Take input from file, or from “inline input” § < filename take all input from file filename § <<STRING take input from the current file, using all lines un9l you get to the label STRING (see next slide for example) § Use a pipe § date | awk '{print $1}' Example of “inline input” gpsdisp << END • Many programs, especially Okmok2002-2010.disp Okmok2002-2010.vec older ones, interac9vely y prompt you to enter input Okmok2002-2010.gmtvec • You can automate (or self- y Okmok2002-2010.newdisp document) this by using << Okmok2002_mod.stacov • Standard input is set to the 5 contents of this file 5 Okmok2010.stacov between << END and END 5 • You can use any label, not 5 just “END”.
    [Show full text]
  • Useful Commands in Linux and Other Tools for Quality Control
    Useful commands in Linux and other tools for quality control Ignacio Aguilar INIA Uruguay 05-2018 Unix Basic Commands pwd show working directory ls list files in working directory ll as before but with more information mkdir d make a directory d cd d change to directory d Copy and moving commands To copy file cp /home/user/is . To copy file directory cp –r /home/folder . to move file aa into bb in folder test mv aa ./test/bb To delete rm yy delete the file yy rm –r xx delete the folder xx Redirections & pipe Redirection useful to read/write from file !! aa < bb program aa reads from file bb blupf90 < in aa > bb program aa write in file bb blupf90 < in > log Redirections & pipe “|” similar to redirection but instead to write to a file, passes content as input to other command tee copy standard input to standard output and save in a file echo copy stream to standard output Example: program blupf90 reads name of parameter file and writes output in terminal and in file log echo par.b90 | blupf90 | tee blup.log Other popular commands head file print first 10 lines list file page-by-page tail file print last 10 lines less file list file line-by-line or page-by-page wc –l file count lines grep text file find lines that contains text cat file1 fiel2 concatenate files sort sort file cut cuts specific columns join join lines of two files on specific columns paste paste lines of two file expand replace TAB with spaces uniq retain unique lines on a sorted file head / tail $ head pedigree.txt 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10
    [Show full text]
  • Basic Plotting Codes in R
    The Basics of R for Windows We will use the data set timetrial.repeated.dat to learn some basic code in R for Windows. Commands will be shown in a different font, e.g., read.table, after the command line prompt, shown here as >. After you open R, type your commands after the prompt in what is called the Console window. Do not type the prompt, just the command. R stores the variables you create in a working directory. From the File menu, you need to first change the working directory to the directory where your data are stored. 1. Reading in data files Download the data file from www.biostat.umn.edu/~lynn/correlated.html to your local disk directory, go to File -> Change Directory to select that directory, and then read the data in: > contact = read.table(file="timetrial.repeated.dat", header=T) Note: if the first row of the data file had data instead of variable names, you would need to use header=F in the read.table command. Now you have named the data set contact, which you can then see in R just by typing its name: > contact or you can look at, for example, just the first 10 rows of the data set: > contact[1:10,] time sex age shape trial subj 1 2.68 M 31 Box 1 1 2 4.14 M 31 Box 2 1 3 7.22 M 31 Box 3 1 4 8.00 M 31 Box 4 1 5 7.09 M 30 Box 1 2 6 8.55 M 30 Box 2 2 7 8.79 M 30 Box 3 2 8 9.68 M 30 Box 4 2 9 6.05 M 30 Box 1 3 10 6.25 M 30 Box 2 3 This data set has 6 variables, one each in a column, where sex and shape are character valued.
    [Show full text]
  • PS TEXT EDIT Reference Manual Is Designed to Give You a Complete Is About Overview of TEDIT
    Information Management Technology Library PS TEXT EDIT™ Reference Manual Abstract This manual describes PS TEXT EDIT, a multi-screen block mode text editor. It provides a complete overview of the product and instructions for using each command. Part Number 058059 Tandem Computers Incorporated Document History Edition Part Number Product Version OS Version Date First Edition 82550 A00 TEDIT B20 GUARDIAN 90 B20 October 1985 (Preliminary) Second Edition 82550 B00 TEDIT B30 GUARDIAN 90 B30 April 1986 Update 1 82242 TEDIT C00 GUARDIAN 90 C00 November 1987 Third Edition 058059 TEDIT C00 GUARDIAN 90 C00 July 1991 Note The second edition of this manual was reformatted in July 1991; no changes were made to the manual’s content at that time. New editions incorporate any updates issued since the previous edition. Copyright All rights reserved. No part of this document may be reproduced in any form, including photocopying or translation to another language, without the prior written consent of Tandem Computers Incorporated. Copyright 1991 Tandem Computers Incorporated. Contents What This Book Is About xvii Who Should Use This Book xvii How to Use This Book xvii Where to Go for More Information xix What’s New in This Update xx Section 1 Introduction to TEDIT What Is PS TEXT EDIT? 1-1 TEDIT Features 1-1 TEDIT Commands 1-2 Using TEDIT Commands 1-3 Terminals and TEDIT 1-3 Starting TEDIT 1-4 Section 2 TEDIT Topics Overview 2-1 Understanding Syntax 2-2 Note About the Examples in This Book 2-3 BALANCED-EXPRESSION 2-5 CHARACTER 2-9 058059 Tandem Computers
    [Show full text]
  • Functional Programming (ML)
    Functional Programming CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 Functional Programming Function evaluation is the basic concept for a programming paradigm that has been implemented in functional programming languages. The language ML (“Meta Language”) was originally introduced in the 1970’s as part of a theorem proving system, and was intended for describing and implementing proof strategies. Standard ML of New Jersey (SML) is an implementation of ML. The basic mode of computation in SML is the use of the definition and application of functions. 2 (c) Paul Fodor (CS Stony Brook) Install Standard ML Download from: http://www.smlnj.org Start Standard ML: Type ''sml'' from the shell (run command line in Windows) Exit Standard ML: Ctrl-Z under Windows Ctrl-D under Unix/Mac 3 (c) Paul Fodor (CS Stony Brook) Standard ML The basic cycle of SML activity has three parts: read input from the user, evaluate it, print the computed value (or an error message). 4 (c) Paul Fodor (CS Stony Brook) First SML example SML prompt: - Simple example: - 3; val it = 3 : int The first line contains the SML prompt, followed by an expression typed in by the user and ended by a semicolon. The second line is SML’s response, indicating the value of the input expression and its type. 5 (c) Paul Fodor (CS Stony Brook) Interacting with SML SML has a number of built-in operators and data types. it provides the standard arithmetic operators - 3+2; val it = 5 : int The Boolean values true and false are available, as are logical operators such as not (negation), andalso (conjunction), and orelse (disjunction).
    [Show full text]
  • Abstract Recursion and Intrinsic Complexity
    ABSTRACT RECURSION AND INTRINSIC COMPLEXITY Yiannis N. Moschovakis Department of Mathematics University of California, Los Angeles [email protected] October 2018 iv Abstract recursion and intrinsic complexity was first published by Cambridge University Press as Volume 48 in the Lecture Notes in Logic, c Association for Symbolic Logic, 2019. The Cambridge University Press catalog entry for the work can be found at https://www.cambridge.org/us/academic/subjects/mathematics /logic-categories-and-sets /abstract-recursion-and-intrinsic-complexity. The published version can be purchased through Cambridge University Press and other standard distribution channels. This copy is made available for personal use only and must not be sold or redistributed. This final prepublication draft of ARIC was compiled on November 30, 2018, 22:50 CONTENTS Introduction ................................................... .... 1 Chapter 1. Preliminaries .......................................... 7 1A.Standardnotations................................ ............. 7 Partial functions, 9. Monotone and continuous functionals, 10. Trees, 12. Problems, 14. 1B. Continuous, call-by-value recursion . ..................... 15 The where -notation for mutual recursion, 17. Recursion rules, 17. Problems, 19. 1C.Somebasicalgorithms............................. .................... 21 The merge-sort algorithm, 21. The Euclidean algorithm, 23. The binary (Stein) algorithm, 24. Horner’s rule, 25. Problems, 25. 1D.Partialstructures............................... ......................
    [Show full text]