100% found this document useful (2 votes)
18 views

Complete Download Programming Languages and Systems Amal Ahmed PDF All Chapters

Ahmed

Uploaded by

maredigunzer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
18 views

Complete Download Programming Languages and Systems Amal Ahmed PDF All Chapters

Ahmed

Uploaded by

maredigunzer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Programming Languages and Systems Amal Ahmed

https://textbookfull.com/product/programming-languages-and-
systems-amal-ahmed/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Programming Languages and Systems 1st Edition Nobuko


Yoshida

https://textbookfull.com/product/programming-languages-and-
systems-1st-edition-nobuko-yoshida/

textboxfull.com

Foundations of Programming Languages Kent D. Lee

https://textbookfull.com/product/foundations-of-programming-languages-
kent-d-lee/

textboxfull.com

Foundations of Programming Languages Second Edition Lee

https://textbookfull.com/product/foundations-of-programming-languages-
second-edition-lee/

textboxfull.com

Concepts of programming languages Twelfth Edition Sebesta

https://textbookfull.com/product/concepts-of-programming-languages-
twelfth-edition-sebesta/

textboxfull.com
Concepts of programming languages 11th Edition Sebesta

https://textbookfull.com/product/concepts-of-programming-
languages-11th-edition-sebesta/

textboxfull.com

Energy Internet Systems and Applications Ahmed F Zobaa

https://textbookfull.com/product/energy-internet-systems-and-
applications-ahmed-f-zobaa/

textboxfull.com

Understanding Programming Languages 1st Edition Cliff B.


Jones

https://textbookfull.com/product/understanding-programming-
languages-1st-edition-cliff-b-jones/

textboxfull.com

Programming Languages and Systems 16th Asian Symposium


APLAS 2018 Wellington New Zealand December 2 6 2018
Proceedings Sukyoung Ryu
https://textbookfull.com/product/programming-languages-and-
systems-16th-asian-symposium-aplas-2018-wellington-new-zealand-
december-2-6-2018-proceedings-sukyoung-ryu/
textboxfull.com

Practical Foundations For Programming Languages 2nd


Edition Robert Harper

https://textbookfull.com/product/practical-foundations-for-
programming-languages-2nd-edition-robert-harper/

textboxfull.com
ARCoSS Amal Ahmed (Ed.)

Programming
LNCS 10801

Languages
and Systems
27th European Symposium on Programming, ESOP 2018
Held as Part of the European Joint Conferences
on Theory and Practice of Software, ETAPS 2018
Thessaloniki, Greece, April 14–20, 2018, Proceedings
Lecture Notes in Computer Science 10801
Commenced Publication in 1973
Founding and Former Series Editors:
Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen

Editorial Board
David Hutchison, UK Takeo Kanade, USA
Josef Kittler, UK Jon M. Kleinberg, USA
Friedemann Mattern, Switzerland John C. Mitchell, USA
Moni Naor, Israel C. Pandu Rangan, India
Bernhard Steffen, Germany Demetri Terzopoulos, USA
Doug Tygar, USA Gerhard Weikum, Germany

Advanced Research in Computing and Software Science


Subline of Lecture Notes in Computer Science

Subline Series Editors


Giorgio Ausiello, University of Rome ‘La Sapienza’, Italy
Vladimiro Sassone, University of Southampton, UK

Subline Advisory Board


Susanne Albers, TU Munich, Germany
Benjamin C. Pierce, University of Pennsylvania, USA
Bernhard Steffen, University of Dortmund, Germany
Deng Xiaotie, City University of Hong Kong
Jeannette M. Wing, Microsoft Research, Redmond, WA, USA
More information about this series at http://www.springer.com/series/7407
Amal Ahmed (Ed.)

Programming
Languages
and Systems
27th European Symposium on Programming, ESOP 2018
Held as Part of the European Joint Conferences
on Theory and Practice of Software, ETAPS 2018
Thessaloniki, Greece, April 14–20, 2018
Proceedings
Editor
Amal Ahmed
Northeastern University
Boston, MA
USA

ISSN 0302-9743 ISSN 1611-3349 (electronic)


Lecture Notes in Computer Science
ISBN 978-3-319-89883-4 ISBN 978-3-319-89884-1 (eBook)
https://doi.org/10.1007/978-3-319-89884-1

Library of Congress Control Number: 2018940640

LNCS Sublibrary: SL1 – Theoretical Computer Science and General Issues

© The Editor(s) (if applicable) and The Author(s) 2018. This book is an open access publication.
Open Access This book is licensed under the terms of the Creative Commons Attribution 4.0 International
License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution
and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and
the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this book are included in the book’s Creative Commons license,
unless indicated otherwise in a credit line to the material. If material is not included in the book’s Creative
Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use,
you will need to obtain permission directly from the copyright holder.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are
believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors
give a warranty, express or implied, with respect to the material contained herein or for any errors or
omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in
published maps and institutional affiliations.

Printed on acid-free paper

This Springer imprint is published by the registered company Springer International Publishing AG
part of Springer Nature
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
ETAPS Foreword

Welcome to the proceedings of ETAPS 2018! After a somewhat coldish ETAPS 2017
in Uppsala in the north, ETAPS this year took place in Thessaloniki, Greece. I am
happy to announce that this is the first ETAPS with gold open access proceedings. This
means that all papers are accessible by anyone for free.
ETAPS 2018 was the 21st instance of the European Joint Conferences on Theory
and Practice of Software. ETAPS is an annual federated conference established in
1998, and consists of five conferences: ESOP, FASE, FoSSaCS, TACAS, and POST.
Each conference has its own Program Committee (PC) and its own Steering Com-
mittee. The conferences cover various aspects of software systems, ranging from
theoretical computer science to foundations to programming language developments,
analysis tools, formal approaches to software engineering, and security. Organizing
these conferences in a coherent, highly synchronized conference program facilitates
participation in an exciting event, offering attendees the possibility to meet many
researchers working in different directions in the field, and to easily attend talks of
different conferences. Before and after the main conference, numerous satellite work-
shops take place and attract many researchers from all over the globe.
ETAPS 2018 received 479 submissions in total, 144 of which were accepted,
yielding an overall acceptance rate of 30%. I thank all the authors for their interest in
ETAPS, all the reviewers for their peer reviewing efforts, the PC members for their
contributions, and in particular the PC (co-)chairs for their hard work in running this
entire intensive process. Last but not least, my congratulations to all authors of the
accepted papers!
ETAPS 2018 was enriched by the unifying invited speaker Martin Abadi (Google
Brain, USA) and the conference-specific invited speakers (FASE) Pamela Zave (AT &
T Labs, USA), (POST) Benjamin C. Pierce (University of Pennsylvania, USA), and
(ESOP) Derek Dreyer (Max Planck Institute for Software Systems, Germany). Invited
tutorials were provided by Armin Biere (Johannes Kepler University, Linz, Austria) on
modern SAT solving and Fabio Somenzi (University of Colorado, Boulder, USA) on
hardware verification. My sincere thanks to all these speakers for their inspiring and
interesting talks!
ETAPS 2018 took place in Thessaloniki, Greece, and was organised by the
Department of Informatics of the Aristotle University of Thessaloniki. The university
was founded in 1925 and currently has around 75,000 students; it is the largest uni-
versity in Greece. ETAPS 2018 was further supported by the following associations
and societies: ETAPS e.V., EATCS (European Association for Theoretical Computer
Science), EAPLS (European Association for Programming Languages and Systems),
and EASST (European Association of Software Science and Technology). The local
organization team consisted of Panagiotis Katsaros (general chair), Ioannis Stamelos,
VI ETAPS Foreword

Lefteris Angelis, George Rahonis, Nick Bassiliades, Alexander Chatzigeorgiou, Ezio


Bartocci, Simon Bliudze, Emmanouela Stachtiari, Kyriakos Georgiadis, and Petros
Stratis (EasyConferences).
The overall planning for ETAPS is the main responsibility of the Steering Com-
mittee, and in particular of its Executive Board. The ETAPS Steering Committee
consists of an Executive Board and representatives of the individual ETAPS confer-
ences, as well as representatives of EATCS, EAPLS, and EASST. The Executive
Board consists of Gilles Barthe (Madrid), Holger Hermanns (Saarbrücken), Joost-Pieter
Katoen (chair, Aachen and Twente), Gerald Lüttgen (Bamberg), Vladimiro Sassone
(Southampton), Tarmo Uustalu (Tallinn), and Lenore Zuck (Chicago). Other members
of the Steering Committee are: Wil van der Aalst (Aachen), Parosh Abdulla (Uppsala),
Amal Ahmed (Boston), Christel Baier (Dresden), Lujo Bauer (Pittsburgh), Dirk Beyer
(Munich), Mikolaj Bojanczyk (Warsaw), Luis Caires (Lisbon), Jurriaan Hage
(Utrecht), Rainer Hähnle (Darmstadt), Reiko Heckel (Leicester), Marieke Huisman
(Twente), Panagiotis Katsaros (Thessaloniki), Ralf Küsters (Stuttgart), Ugo Dal Lago
(Bologna), Kim G. Larsen (Aalborg), Matteo Maffei (Vienna), Tiziana Margaria
(Limerick), Flemming Nielson (Copenhagen), Catuscia Palamidessi (Palaiseau),
Andrew M. Pitts (Cambridge), Alessandra Russo (London), Dave Sands (Göteborg),
Don Sannella (Edinburgh), Andy Schürr (Darmstadt), Alex Simpson (Ljubljana),
Gabriele Taentzer (Marburg), Peter Thiemann (Freiburg), Jan Vitek (Prague), Tomas
Vojnar (Brno), and Lijun Zhang (Beijing).
I would like to take this opportunity to thank all speakers, attendees, organizers
of the satellite workshops, and Springer for their support. I hope you all enjoy the
proceedings of ETAPS 2018. Finally, a big thanks to Panagiotis and his local orga-
nization team for all their enormous efforts that led to a fantastic ETAPS in
Thessaloniki!

February 2018 Joost-Pieter Katoen


Preface

This volume contains the papers presented at the 27th European Symposium on Pro-
gramming (ESOP 2018) held April 16–19, 2018, in Thessaloniki, Greece. ESOP is one
of the European Joint Conferences on Theory and Practice of Software (ETAPS). It is
devoted to fundamental issues in the specification, design, analysis, and implementa-
tion of programming languages and systems.
The 36 papers in this volume were selected from 114 submissions based on origi-
nality and quality. Each submission was reviewed by three to six Program Committee
(PC) members and external reviewers, with an average of 3.3 reviews per paper.
Authors were given a chance to respond to these reviews during the rebuttal period
from December 6 to 8, 2017. All submissions, reviews, and author responses were
considered during the online discussion, which identified 74 submissions to be dis-
cussed further at the physical PC meeting held at Inria Paris, December 13–14, 2017.
Each paper was assigned a guardian, who was responsible for making sure that external
reviews were solicited if there was not enough non-conflicted expertise among the PC,
and for presenting a summary of the reviews and author responses at the PC meeting.
All non-conflicted PC members participated in the discussion of a paper’s merits. PC
members wrote reactions to author responses, including summaries of online discus-
sions and discussions during the physical PC meeting, so as to help the authors
understand decisions. Papers co-authored by members of the PC were held to a higher
standard and discussed toward the end of the physical PC meeting. There were ten such
submissions and five were accepted. Papers for which the program chair had a conflict
of interest were kindly handled by Fritz Henglein.
My sincere thanks to all who contributed to the success of the conference. This
includes the authors who submitted papers for consideration; the external reviewers,
who provided timely expert reviews, sometimes on short notice; and the PC, who
worked hard to provide extensive reviews, engaged in high-quality discussions about
the submissions, and added detailed comments to help authors understand the PC
discussion and decisions. I am grateful to the past ESOP PC chairs, particularly Jan
Vitek and Hongseok Yang, and to the ESOP SC chairs, Giuseppe Castagna and Peter
Thiemann, who helped with numerous procedural matters. I would like to thank the
ETAPS SC chair, Joost-Pieter Katoen, for his amazing work and his responsiveness.
HotCRP was used to handle submissions and online discussion, and helped smoothly
run the physical PC meeting. Finally, I would like to thank Cătălin Hriţcu for spon-
soring the physical PC meeting through ERC grant SECOMP, Mathieu Mourey and the
Inria Paris staff for their help organizing the meeting, and William Bowman for
assisting with the PC meeting.

February 2018 Amal Ahmed


Organization

Program Committee
Amal Ahmed Northeastern University, USA and Inria, France
Nick Benton Facebook, UK
Josh Berdine Facebook, UK
Viviana Bono Università di Torino, Italy
Dominique Devriese KU Leuven, Belgium
Marco Gaboardi University at Buffalo, SUNY, USA
Roberto Giacobazzi Università di Verona, Italy and IMDEA Software Institute,
Spain
Philipp Haller KTH Royal Institute of Technology, Sweden
Matthew Hammer University of Colorado Boulder, USA
Fritz Henglein University of Copenhagen, Denmark
Jan Hoffmann Carnegie Mellon University, USA
Cătălin Hriţcu Inria Paris, France
Suresh Jagannathan Purdue University, USA
Limin Jia Carnegie Mellon University, USA
Naoki Kobayashi University of Tokyo, Japan
Xavier Leroy Inria Paris, France
Aleksandar Nanevski IMDEA Software Institute, Spain
Michael Norrish Data61 and CSIRO, Australia
Andreas Rossberg Google, Germany
Davide Sangiorgi Università di Bologna, Italy and Inria, France
Peter Sewell University of Cambridge, UK
Éric Tanter University of Chile, Chile
Niki Vazou University of Maryland, USA
Steve Zdancewic University of Pennsylvania, USA

Additional Reviewers

Danel Ahman Mariangiola Dezani


S. Akshay Derek Dreyer
Aws Albarghouthi Ronald Garcia
Jade Alglave Deepak Garg
Vincenzo Arceri Samir Genaim
Samik Basu Victor Gomes
Gavin Bierman Peter Habermehl
Filippo Bonchi Matthew Hague
Thierry Coquand Justin Hsu
X Organization

Zhenjiang Hu Andreas Nuyts


Peter Jipsen Paulo Oliva
Shin-ya Katsumata Dominic Orchard
Andrew Kennedy Luca Padovani
Heidy Khlaaf Brigitte Pientka
Neelakantan Krishnaswami Benjamin C. Pierce
César Kunz Andreas Podelski
Ugo Dal Lago Chris Poskitt
Paul Levy Francesco Ranzato
Kenji Maillard Andrey Rybalchenko
Roman Manevich Sriram Sankaranarayanan
Paulo Mateus Tetsuya Sato
Antoine Miné Sandro Stucki
Stefan Monnier Zachary Tatlock
Andrzej Murawski Bernardo Toninho
Anders Møller Viktor Vafeiadis
Vivek Notani
RustBelt: Logical Foundations for the Future
of Safe Systems Programming

Derek Dreyer

Max Planck Institute for Software Systems (MPI-SWS), Germany


dreyer@mpi-sws.org

Abstract. Rust is a new systems programming language, developed at Mozilla,


that promises to overcome the seemingly fundamental tradeoff in language
design between high-level safety guarantees and low-level control over resource
management. Unfortunately, none of Rust’s safety claims have been formally
proven, and there is good reason to question whether they actually hold.
Specifically, Rust employs a strong, ownership-based type system, but then
extends the expressive power of this core type system through libraries that
internally use unsafe features.
In this talk, I will present RustBelt (http://plv.mpi-sws.org/rustbelt), the first
formal (and machine-checked) safety proof for a language representing a real-
istic subset of Rust. Our proof is extensible in the sense that, for each new Rust
library that uses unsafe features, we can say what verification condition it must
satisfy in order for it to be deemed a safe extension to the language. We have
carried out this verification for some of the most important libraries that are used
throughout the Rust ecosystem.
After reviewing some essential features of the Rust language, I will describe
the high-level structure of the RustBelt verification and then delve into detail
about the secret weapon that makes RustBelt possible: the Iris framework for
higher-order concurrent separation logic in Coq (http://iris-project.org). I will
explain by example how Iris generalizes the expressive power of O’Hearn’s
original concurrent separation logic in ways that are essential for verifying the
safety of Rust libraries. I will not assume any prior familiarity with concurrent
separation logic or Rust.
This is joint work with Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers,
and the rest of the Iris team.
Contents

Language Design

Consistent Subtyping for All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira

HOBiT: Programming Lenses Without Using Lens Combinators . . . . . . . . . . 31


Kazutaka Matsuda and Meng Wang

Dualizing Generalized Algebraic Data Types by Matrix Transposition . . . . . . 60


Klaus Ostermann and Julian Jabs

Deterministic Concurrency: A Clock-Synchronised Shared


Memory Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Joaquín Aguado, Michael Mendler, Marc Pouzet, Partha Roop,
and Reinhard von Hanxleden

Probabilistic Programming

An Assertion-Based Program Logic for Probabilistic Programs . . . . . . . . . . . 117


Gilles Barthe, Thomas Espitau, Marco Gaboardi, Benjamin Grégoire,
Justin Hsu, and Pierre-Yves Strub

Fine-Grained Semantics for Probabilistic Programs . . . . . . . . . . . . . . . . . . . 145


Benjamin Bichsel, Timon Gehr, and Martin Vechev

How long, O Bayesian network, will I sample thee? A program


analysis perspective on expected sampling times . . . . . . . . . . . . . . . . . . . . . 186
Kevin Batz, Benjamin Lucien Kaminski, Joost-Pieter Katoen,
and Christoph Matheja

Relational Reasoning for Markov Chains in a Probabilistic Guarded


Lambda Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Alejandro Aguirre, Gilles Barthe, Lars Birkedal, Aleš Bizjak,
Marco Gaboardi, and Deepak Garg

Types and Effects

Failure is Not an Option: An Exceptional Type Theory . . . . . . . . . . . . . . . . 245


Pierre-Marie Pédrot and Nicolas Tabareau

Let Arguments Go First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272


Ningning Xie and Bruno C. d. S. Oliveira
XIV Contents

Behavioural Equivalence via Modalities for Algebraic Effects. . . . . . . . . . . . 300


Alex Simpson and Niels Voorneveld

Explicit Effect Subtyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327


Amr Hany Saleh, Georgios Karachalias, Matija Pretnar,
and Tom Schrijvers

Concurrency

A Separation Logic for a Promising Semantics . . . . . . . . . . . . . . . . . . . . . . 357


Kasper Svendsen, Jean Pichon-Pharabod, Marko Doko, Ori Lahav,
and Viktor Vafeiadis

Logical Reasoning for Disjoint Permissions . . . . . . . . . . . . . . . . . . . . . . . . 385


Xuan-Bach Le and Aquinas Hobor

Deadlock-Free Monitors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415


Jafar Hamin and Bart Jacobs

Fragment Abstraction for Concurrent Shape Analysis . . . . . . . . . . . . . . . . . 442


Parosh Aziz Abdulla, Bengt Jonsson, and Cong Quy Trinh

Security

Reasoning About a Machine with Local Capabilities: Provably Safe


Stack and Return Pointer Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Lau Skorstengaard, Dominique Devriese, and Lars Birkedal

Modular Product Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502


Marco Eilers, Peter Müller, and Samuel Hitz

Program Verification

A Fistful of Dollars: Formalizing Asymptotic Complexity Claims


via Deductive Program Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Armaël Guéneau, Arthur Charguéraud, and François Pottier

Verified Learning Without Regret: From Algorithmic Game Theory


to Distributed Systems with Mechanized Complexity Guarantees . . . . . . . . . 561
Samuel Merten, Alexander Bagnall, and Gordon Stewart

Program Verification by Coinduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589


Brandon Moore, Lucas Peña, and Grigore Rosu

Velisarios: Byzantine Fault-Tolerant Protocols Powered by Coq . . . . . . . . . . 619


Vincent Rahli, Ivana Vukotic, Marcus Völp,
and Paulo Esteves-Verissimo
Contents XV

Program Analysis and Automated Verification

Evaluating Design Tradeoffs in Numeric Static Analysis for Java . . . . . . . . . 653


Shiyi Wei, Piotr Mardziel, Andrew Ruef, Jeffrey S. Foster,
and Michael Hicks

An Abstract Interpretation Framework for Input Data Usage. . . . . . . . . . . . . 683


Caterina Urban and Peter Müller

Higher-Order Program Verification via HFL Model Checking. . . . . . . . . . . . 711


Naoki Kobayashi, Takeshi Tsukada, and Keiichi Watanabe

Quantitative Analysis of Smart Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . 739


Krishnendu Chatterjee, Amir Kafshdar Goharshady, and Yaron Velner

Session Types and Concurrency

Session-Typed Concurrent Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771


Hannah Gommerstadt, Limin Jia, and Frank Pfenning

A Typing Discipline for Statically Verified Crash Failure Handling


in Distributed Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799
Malte Viering, Tzu-Chun Chen, Patrick Eugster, Raymond Hu,
and Lukasz Ziarek

On Polymorphic Sessions and Functions: A Tale of Two


(Fully Abstract) Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
Bernardo Toninho and Nobuko Yoshida

Concurrent Kleene Algebra: Free Model and Completeness . . . . . . . . . . . . . 856


Tobias Kappé, Paul Brunet, Alexandra Silva, and Fabio Zanasi

Concurrency and Distribution

Correctness of a Concurrent Object Collector for Actor Languages . . . . . . . . 885


Juliana Franco, Sylvan Clebsch, Sophia Drossopoulou, Jan Vitek,
and Tobias Wrigstad

Paxos Consensus, Deconstructed and Abstracted . . . . . . . . . . . . . . . . . . . . . 912


Álvaro García-Pérez, Alexey Gotsman, Yuri Meshman, and Ilya Sergey

On Parallel Snapshot Isolation and Release/Acquire Consistency. . . . . . . . . . 940


Azalea Raad, Ori Lahav, and Viktor Vafeiadis

Eventual Consistency for CRDTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968


Radha Jagadeesan and James Riely
XVI Contents

Compiler Verification

A Verified Compiler from Isabelle/HOL to CakeML . . . . . . . . . . . . . . . . . . 999


Lars Hupel and Tobias Nipkow

Compositional Verification of Compiler Optimisations


on Relaxed Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027
Mike Dodds, Mark Batty, and Alexey Gotsman

Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1057


Language Design
Consistent Subtyping for All

Ningning Xie(B) , Xuan Bi, and Bruno C. d. S. Oliveira

The University of Hong Kong, Pokfulam, Hong Kong


{nnxie,xbi,bruno}@cs.hku.hk

Abstract. Consistent subtyping is employed in some gradual type sys-


tems to validate type conversions. The original definition by Siek and
Taha serves as a guideline for designing gradual type systems with
subtyping. Polymorphic types à la System F also induce a subtyping
relation that relates polymorphic types to their instantiations. However
Siek and Taha’s definition is not adequate for polymorphic subtyping.
The first goal of this paper is to propose a generalization of consistent
subtyping that is adequate for polymorphic subtyping, and subsumes
the original definition by Siek and Taha. The new definition of consis-
tent subtyping provides novel insights with respect to previous polymor-
phic gradual type systems, which did not employ consistent subtyping.
The second goal of this paper is to present a gradually typed calcu-
lus for implicit (higher-rank) polymorphism that uses our new notion
of consistent subtyping. We develop both declarative and (bidirectional)
algorithmic versions for the type system. We prove that the new calculus
satisfies all static aspects of the refined criteria for gradual typing, which
are mechanically formalized using the Coq proof assistant.

1 Introduction
Gradual typing [21] is an increasingly popular topic in both programming
language practice and theory. On the practical side there is a growing num-
ber of programming languages adopting gradual typing. Those languages include
Clojure [6], Python [27], TypeScript [5], Hack [26], and the addition of Dynamic to
C# [4], to cite a few. On the theoretical side, recent years have seen a large body of
research that defines the foundations of gradual typing [8,9,13], explores their use
for both functional and object-oriented programming [21,22], as well as its appli-
cations to many other areas [3,24].
A key concept in gradual type systems is consistency [21]. Consistency weak-
ens type equality to allow for the presence of unknown types. In some gradual
type systems with subtyping, consistency is combined with subtyping to give
rise to the notion of consistent subtyping [22]. Consistent subtyping is employed
by gradual type systems to validate type conversions arising from conventional
subtyping. One nice feature of consistent subtyping is that it is derivable from
the more primitive notions of consistency and subtyping. As Siek and Taha [22]
put it this shows that “gradual typing and subtyping are orthogonal and can be
combined in a principled fashion”. Thus consistent subtyping is often used as a
guideline for designing gradual type systems with subtyping.
c The Author(s) 2018
A. Ahmed (Ed.): ESOP 2018, LNCS 10801, pp. 3–30, 2018.
https://doi.org/10.1007/978-3-319-89884-1_1
4 N. Xie et al.

Unfortunately, as noted by Garcia et al. [13], notions of consistency and/or


consistent subtyping “become more difficult to adapt as type systems get more
complex ”. In particular, for the case of type systems with subtyping, certain
kinds of subtyping do not fit well with the original definition of consistent sub-
typing by Siek and Taha [22]. One important case where such mismatch happens
is in type systems supporting implicit (higher-rank) polymorphism [11,18]. It is
well-known that polymorphic types à la System F induce a subtyping relation
that relates polymorphic types to their instantiations [16,17]. However Siek and
Taha’s [22] definition is not adequate for this kind of subtyping. Moreover the
current framework for Abstracting Gradual Typing (AGT) [13] also does not
account for polymorphism, with the authors acknowledging that this is one of
the interesting avenues for future work.
Existing work on gradual type systems with polymorphism does not use
consistent subtyping. The Polymorphic Blame Calculus (λB) [1] is an explic-
itly polymorphic calculus with explicit casts, which is often used as a target
language for gradual type systems with polymorphism. In λB a notion of com-
patibility is employed to validate conversions allowed by casts. Interestingly λB
allows conversions from polymorphic types to their instantiations. For exam-
ple, it is possible to cast a value with type ∀a.a → a into Int → Int. Thus
an important remark here is that while λB is explicitly polymorphic, casting
and conversions are closer to implicit polymorphism. That is, in a conventional
explicitly polymorphic calculus (such as System F), the primary notion is type
equality, where instantiation is not taken into account. Thus the types ∀a.a → a
and Int → Int are deemed incompatible. However in implicitly polymorphic cal-
culi [11,18] ∀a.a → a and Int → Int are deemed compatible, since the latter type
is an instantiation of the former. Therefore λB is in a sense a hybrid between
implicit and explicit polymorphism, utilizing type equality (à la System F) for
validating applications, and compatibility for validating casts.
An alternative approach to polymorphism has recently been proposed by
Igarashi et al. [14]. Like λB their calculus is explicitly polymorphic. However,
in that work they employ type consistency to validate cast conversions, and
forbid conversions from ∀a.a → a to Int → Int. This makes their casts closer
to explicit polymorphism, in contrast to λB. Nonetheless, there is still same
flavour of implicit polymorphism in their calculus when it comes to interactions
between dynamically typed and polymorphically typed code. For example, in
their calculus type consistency allows types such as ∀a.a → Int to be related to
 → Int, where some sort of (implicit) polymorphic subtyping is involved.
The first goal of this paper is to study the gradually typed subtyping and con-
sistent subtyping relations for predicative implicit polymorphism. To accomplish
this, we first show how to reconcile consistent subtyping with polymorphism
by generalizing the original consistent subtyping definition by Siek and Taha
[22]. The new definition of consistent subtyping can deal with polymorphism,
Consistent Subtyping for All 5

and preserves the orthogonality between consistency and subtyping. To slightly


rephrase Siek and Taha [22], the motto of our paper is that:

Gradual typing and polymorphism are orthogonal and can be combined


in a principled fashion.1

With the insights gained from our work, we argue that, for implicit polymor-
phism, Ahmed et al.’s [1] notion of compatibility is too permissive (i.e. too many
programs are allowed to type-check), and that Igarashi et al.’s [14] notion of type
consistency is too conservative. As a step towards an algorithmic version of con-
sistent subtyping, we present a syntax-directed version of consistent subtyping
that is sound and complete with respect to our formal definition of consistent
subtyping. The syntax-directed version of consistent subtyping is remarkably
simple and well-behaved, without the ad-hoc restriction operator [22]. More-
over, to further illustrate the generality of our consistent subtyping definition,
we show that it can also account for top types, which cannot be dealt with by
Siek and Taha’s [22] definition either.
The second goal of this paper is to present a (source-level) gradually typed
calculus for (predicative) implicit higher-rank polymorphism that uses our new
notion of consistent subtyping. As far as we are aware, there is no work on
bridging the gap between implicit higher-rank polymorphism and gradual typing,
which is interesting for two reasons. On one hand, modern functional languages
(such as Haskell) employ sophisticated type-inference algorithms that, aided by
type annotations, can deal with implicit higher-rank polymorphism. So a natural
question is how gradual typing can be integrated in such languages. On the other
hand, there is several existing work on integrating explicit polymorphism into
gradual typing [1,14]. Yet no work investigates how to move such expressive
power into a source language with implicit polymorphism. Therefore as a step
towards gradualizing such type systems, this paper develops both declarative
and algorithmic versions for a gradual type system with implicit higher-rank
polymorphism. The new calculus brings the expressive power of full implicit
higher-rank polymorphic into a gradually typed source language. We prove that
our calculus satisfies all of the static aspects of the refined criteria for gradual
typing [25], while discussing some issues related with the dynamic guarantee.
In summary, the contributions of this paper are:

– We define a framework for consistent subtyping with:


• a new definition of consistent subtyping that subsumes and generalizes that
of Siek and Taha [22], and can deal with polymorphism and top types.
• a syntax-directed version of consistent subtyping that is sound and com-
plete with respect to our definition of consistent subtyping, but still
guesses polymorphic instantiations.

1
Note here that we borrow Siek and Taha’s [22] motto mostly to talk about the
static semantics. As Ahmed et al. [1] show there are several non-trivial interactions
between polymorphism and casts at the level of the dynamic semantics.
6 N. Xie et al.

A <: B

Int <: Int Bool <: Bool Float <: Float Int <: Float

B1 <: A1 A2 <: B2
[li : Aii∈1...n+m ] <: [li : Ai∈1...n
i ]  <: 
A1 → A2 <: B1 → B2

A∼B

A1 ∼ B1 A2 ∼ B2 Ai ∼ Bi
A∼A A∼ ∼A
A1 → A2 ∼ B1 → B2 [li : Ai ] ∼ [li : Bi ]

Fig. 1. Subtyping and type consistency in FOb?<:

– Based on consistent subtyping, we present a declarative gradual type system


with predicative implicit higher-rank polymorphism. We prove that our cal-
culus satisfies the static aspects of the refined criteria for gradual typing [25],
and is type-safe by a type-directed translation to λB, and thus hereditarily
preserves parametricity [2].
– We present a complete and sound bidirectional algorithm for implementing
the declarative system based on the design principle of Garcia and Cimini
[12] and the approach of Dunfield and Krishnaswami [11].
– All of the metatheory of this paper, except some manual proofs for the algo-
rithmic type system, has been mechanically formalized in Coq2 .

2 Background and Motivation


In this section we review a simple gradually typed language with objects [22],
to introduce the concept of consistency subtyping. We also briefly talk about
the Odersky-Läufer type system for higher-rank types [17], which serves as the
original language on which our gradually typed calculus with implicit higher-
rank polymorphism is based.

2.1 Gradual Subtyping

Siek and Taha [22] developed a gradual typed system for object-oriented lan-
guages that they call FOb?<: . Central to gradual typing is the concept of con-
sistency (written ∼) between gradual types, which are types that may involve
the unknown type . The intuition is that consistency relaxes the structure of a
type system to tolerate unknown positions in a gradual type. They also defined
the subtyping relation in a way that static type safety is preserved. Their key
2
All supplementary materials are available at https://bitbucket.org/xieningning/
consistent-subtyping.
Consistent Subtyping for All 7

insight is that the unknown type  is neutral to subtyping, with only  <: .
Both relations are found in Fig. 1.
A primary contribution of their work is to show that consistency and subtyp-
ing are orthogonal. To compose subtyping and consistency, Siek and Taha [22]
defined consistent subtyping (written ) in two equivalent ways:

Definition 1 (Consistent Subtyping à la Siek and Taha [22])

– A  B if and only if A ∼ C and C <: B for some C.


– A  B if and only if A <: C and C ∼ B for some C.

Both definitions are non-deterministic because of the intermediate type C. To


remove non-determinism, they proposed a so-called restriction operator, written
A|B that masks off the parts of a type A that are unknown in a type B.
A|B = case A, B of | (−, ) ⇒ 
| A1 → A2 , B1 → B2 = A1 |B1 → A2 |B2
| [l1 : A1 , ..., ln : An ], [l1 : B1 , ..., lm : Bm ] if n ≤ m ⇒ [l1 : A1 |B1 , ..., ln : An |Bn ]
| [l1 : A1 , ..., ln : An ], [l1 : B1 , ..., lm : Bm ] if n > m ⇒
[l1 : A1 |B1 , ..., lm : Am |Bm , ..., ln : An ]
| otherwise ⇒ A

With the restriction operator, consistent subtyping is simply defined as A  B ≡


A|B <: B|A . Then they proved that this definition is equivalent to Definition 1.

2.2 The Odersky-Läufer Type System

The calculus we are combining gradual typing with is the well-established pred-
icative type system for higher-rank types proposed by Odersky and Läufer [17].
One difference is that, for simplicity, we do not account for a let expression,
as there is already existing work about gradual type systems with let expres-
sions and let generalization (for example, see Garcia and Cimini [12]). Similar
techniques can be applied to our calculus to enable let generalization.
The syntax of the type system, along with the typing and subtyping judg-
ments is given in Fig. 2. An implicit assumption throughout the paper is that
variables in contexts are distinct. We save the explanations for the static seman-
tics to Sect. 4, where we present our gradually typed version of the calculus.

2.3 Motivation: Gradually Typed Higher-Rank Polymorphism

Our work combines implicit (higher-rank) polymorphism with gradual typing.


As is well known, a gradually typed language supports both fully static and fully
dynamic checking of program properties, as well as the continuum between these
two extremes. It also offers programmers fine-grained control over the static-to-
dynamic spectrum, i.e., a program can be evolved by introducing more or less
precise types as needed [13].
8 N. Xie et al.

Expressions e ::= x | n | λx : A. e | λx. e | e e


Types A, B ::= Int | a | A → B | ∀a.A
Monotypes τ, σ ::= Int | a | τ → σ
Contexts Ψ ::= ∅ | Ψ, x : A | Ψ, a

Ψ OL e : A

x:A∈Ψ Ψ, x : A OL e : B
OL
Var OL
Nat LamAnn
Ψ x:A Ψ n : Int Ψ OL λx : A. e : A → B

Ψ OL e1 : A1 → A2 Ψ OL e2 : A1 Ψ OL e : A1 Ψ  A1 <: A2


OL
App OL
Sub
Ψ e1 e2 : A2 Ψ e : A2

Ψ, x : τ OL e : B Ψ, a OL e : A
Lam Gen
Ψ OL λx. e : τ → B Ψ OL e : ∀a.A

Ψ  A <: B

a∈Ψ Ψ τ Ψ  A[a → τ ] <: B


CS-TVar CS-Int ForallL
Ψ  a <: a Ψ  Int <: Int Ψ  ∀a.A <: B

Ψ , a  A <: B Ψ  B1 <: A1 Ψ  A2 <: B2


ForallR CS-Fun
Ψ  A <: ∀a.B Ψ  A1 → A2 <: B1 → B2

Fig. 2. Syntax and static semantics of the Odersky-Läufer type system.

Haskell is a language that supports implicit higher-rank polymorphism, but


no gradual typing. Therefore some programs that are safe at run-time may be
rejected due to the conservativity of the type system. For example, consider the
following Haskell program adapted from Jones et al. [18]:
foo :: ([Int], [Char])
foo = let f x = (x [1, 2] , x [ a ,  b ]) in f reverse
This program is rejected by Haskell’s type checker because Haskell imple-
ments the Damas-Milner rule that a lambda-bound argument (such as x) can only
have a monotype, i.e., the type checker can only assign x the type [Int] → [Int],
or [Char] → [Char], but not ∀a.[a] → [a]. Finding such manual polymorphic
annotations can be non-trivial. Instead of rejecting the program outright, due to
missing type annotations, gradual typing provides a simple alternative by giving
x the unknown type (denoted ). With such typing the same program type-checks
and produces ([2, 1], [ b , a ]). By running the program, programmers can gain
some additional insight about the run-time behaviour. Then, with such insight,
they can also give x a more precise type (∀a.[a] → [a]) a posteriori so that
the program continues to type-check via implicit polymorphism and also grants
Consistent Subtyping for All 9

Types A, B ::= Int | a | A → B | ∀a.A | 


Monotypes τ, σ ::= Int | a | τ → σ
Contexts Ψ ::= ∅ | Ψ, x : A | Ψ, a

A∼B

A1 ∼ B1 A2 ∼ B2 A∼B
A∼A A∼ ∼A
A1 → A2 ∼ B1 → B2 ∀a.A ∼ ∀a.B

Ψ  A <: B

Ψ , a  A <: B Ψ τ Ψ  A[a → τ ] <: B a∈Ψ


S-ForallR S-ForallL S-TVar
Ψ  A <: ∀a.B Ψ  ∀a.A <: B Ψ  a <: a

Ψ  B1 <: A1 Ψ  A2 <: B2
S-Int S-Fun S-Unknown
Ψ  Int <: Int Ψ  A1 → A2 <: B1 → B2 Ψ   <: 

Fig. 3. Syntax of types, consistency, and subtyping in the declarative system.

more static safety. In this paper, we envision such a language that combines the
benefits of both implicit higher-rank polymorphism and gradual typing.

3 Revisiting Consistent Subtyping

In this section we explore the design space of consistent subtyping. We start


with the definitions of consistency and subtyping for polymorphic types, and
compare with some relevant work. We then discuss the design decisions involved
towards our new definition of consistent subtyping, and justify the new definition
by demonstrating its equivalence with that of Siek and Taha [22] and the AGT
approach [13] on simple types.
The syntax of types is given at the top of Fig. 3. We write A, B for types.
Types are either the integer type Int, type variables a, functions types A → B,
universal quantification ∀a.A, or the unknown type . Though we only have one
base type Int, we also use Bool for the purpose of illustration. Note that mono-
types τ contain all types other than the universal quantifier and the unknown
type . We will discuss this restriction when we present the subtyping rules.
Contexts Ψ are ordered lists of type variable declarations and term variables.

3.1 Consistency and Subtyping

We start by giving the definitions of consistency and subtyping for polymorphic


types, and comparing our definitions with the compatibility relation by Ahmed
et al. [1] and type consistency by Igarashi et al. [14].
10 N. Xie et al.

Consistency. The key observation here is that consistency is mostly a structural


relation, except that the unknown type  can be regarded as any type. Following
this observation, we naturally extend the definition from Fig. 1 with polymorphic
types, as shown at the middle of Fig. 3. In particular a polymorphic type ∀a.A
is consistent with another polymorphic type ∀a.B if A is consistent with B.

Subtyping. We express the fact that one type is a polymorphic generalization


of another by means of the subtyping judgment Ψ  A <: B. Compared with
the subtyping rules of Odersky and Läufer [17] in Fig. 2, the only addition is
the neutral subtyping of . Notice that, in the rule S-ForallL, the universal
quantifier is only allowed to be instantiated with a monotype. The judgment
Ψ  τ checks all the type variables in τ are bound in the context Ψ . For space
reasons, we omit the definition. According to the syntax in Fig. 3, monotypes
do not include the unknown type . This is because if we were to allow the
unknown type to be used for instantiation, we could have ∀a.a → a <:  → 
by instantiating a with . Since  →  is consistent with any functions A → B,
for instance, Int → Bool, this means that we could provide an expression of
type ∀a.a → a to a function where the input type is supposed to be Int →
Bool. However, as we might expect, ∀a.a → a is definitely not compatible with
Int → Bool. This does not hold in any polymorphic type systems without gradual
typing. So the gradual type system should not accept it either. (This is the so-
called conservative extension property that will be made precise in Sect. 4.3.)
Importantly there is a subtle but crucial distinction between a type variable
and the unknown type, although they all represent a kind of “arbitrary” type.
The unknown type stands for the absence of type information: it could be any
type at any instance. Therefore, the unknown type is consistent with any type,
and additional type-checks have to be performed at runtime. On the other hand,
a type variable indicates parametricity. In other words, a type variable can only
be instantiated to a single type. For example, in the type ∀a.a → a, the two
occurrences of a represent an arbitrary but single type (e.g., Int → Int, Bool →
Bool), while  →  could be an arbitrary function (e.g., Int → Bool) at runtime.

Comparison with Other Relations. In other polymorphic gradual calculi, consis-


tency and subtyping are often mixed up to some extent. In λB [1], the compat-
ibility relation for polymorphic types is defined as follows:

A≺B A[X → ] ≺ B
Comp-AllR Comp-AllL
A ≺ ∀X.B ∀X.A ≺ B

Notice that, in rule Comp-AllL, the universal quantifier is always instantiated


to . However, this way, λB allows ∀a.a → a ≺ Int → Bool, which as we discussed
before might not be what we expect. Indeed λB relies on sophisticated runtime
checks to rule out such instances of the compatibility relation a posteriori.
Consistent Subtyping for All 11

∼ ∼
⊥ ( → Int) → Int
Int → Int Int → 
<: <: <: <:
(∀a.a → Int) → Int ∼ (∀a. → Int) → Int ∀a.a ⊥

(a) (b)

⊥ ((( → Int) → Int) → Bool) → (Int → )
<: <:
(((∀a.a → Int) → Int) → Bool) → (∀a.a) ∼ ⊥

(c)

Fig. 4. Examples that break the original definition of consistent subtyping.

Igarashi et al. [14] introduced the so-called quasi-polymorphic types for types
that may be used where a ∀-type is expected, which is important for their pur-
pose of conservativity over System F. Their type consistency relation, involving
polymorphism, is defined as follows3 :

A∼B A∼B B = ∀a.B   ∈ Types(B)


∀a.A ∼ ∀a.B ∀a.A ∼ B

Compared with our consistency definition in Fig. 3, their first rule is the same
as ours. The second rule says that a non ∀-type can be consistent with a ∀-type
only if it contains . In this way, their type system is able to reject ∀a.a → a ∼
Int → Bool. However, in order to keep conservativity, they also reject ∀a.a → a ∼
Int → Int, which is perfectly sensible in their setting (i.e., explicit polymorphism).
However with implicit polymorphism, we would expect ∀a.a → a to be related
with Int → Int, since a can be instantiated to Int.
Nonetheless, when it comes to interactions between dynamically typed and
polymorphically typed terms, both relations allow ∀a.a → Int to be related with
 → Int for example, which in our view, is some sort of (implicit) polymorphic
subtyping combined with type consistency, and that should be derivable by the
more primitive notions in the type system (instead of inventing new relations).
One of our design principles is that subtyping and consistency is orthogonal, and
can be naturally superimposed, echoing the same opinion of Siek and Taha [22].

3.2 Towards Consistent Subtyping


With the definitions of consistency and subtyping, the question now is how to
compose these two relations so that two types can be compared in a way that
takes these two relations into account.
3
This is a simplified version.
12 N. Xie et al.

Unfortunately, the original definition of Siek and Taha [22] (Definition 1) does
not work well with our definitions of consistency and subtyping for polymorphic
types. Consider two types: (∀a.a → Int) → Int, and ( → Int) → Int. The first
type can only reach the second type in one way (first by applying consistency,
then subtyping), but not the other way, as shown in Fig. 4a. We use ⊥ to mean
that we cannot find such a type. Similarly, there are situations where the first
type can only reach the second type by the other way (first applying subtyping,
and then consistency), as shown in Fig. 4b.
What is worse, if those two examples are composed in a way that those types
all appear co-variantly, then the resulting types cannot reach each other in either
way. For example, Fig. 4c shows such two types by putting a Bool type in the
middle, and neither definition of consistent subtyping works.

Observations on Consistent Subtyping Based on Information Propagation. In


order to develop the correct definition of consistent subtyping for polymorphic
types, we need to understand how consistent subtyping works. We first review
two important properties of subtyping: (1) subtyping induces the subsumption
rule: if A <: B, then an expression of type A can be used where B is expected;
(2) subtyping is transitive: if A <: B, and B <: C, then A <: C. Though con-
sistent subtyping takes the unknown type into consideration, the subsumption
rule should also apply: if A  B, then an expression of type A can also be used
where B is expected, given that there might be some information lost by con-
sistency. A crucial difference from subtyping is that consistent subtyping is not
transitive because information can only be lost once (otherwise, any two types
are a consistent subtype of each other). Now consider a situation where we have
both A <: B, and B  C, this means that A can be used where B is expected,
and B can be used where C is expected, with possibly some loss of information.
In other words, we should expect that A can be used where C is expected, since
there is at most one-time loss of information.

Observation 1. If A <: B, and B  C, then A  C.

This is reflected in Fig. 5a. A symmetrical observation is given in Fig. 5b:

Observation 2. If C  B, and B <: A, then C  A.

From the above observations, we see what the problem is with the original
definition. In Fig. 5a, if B can reach C by T1 , then by subtyping transitivity, A
can reach C by T1 . However, if B can only reach C by T2 , then A cannot reach
C through the original definition. A similar problem is shown in Fig. 5b.
However, it turns out that those two problems can be fixed using the same
strategy: instead of taking one-step subtyping and one-step consistency, our def-
inition of consistent subtyping allows types to take one-step subtyping, one-step
consistency, and one more step subtyping. Specifically, A <: B ∼ T2 <: C (in
Fig. 5a) and C <: T1 ∼ B <: A (in Fig. 5b) have the same relation chain:
subtyping, consistency, and subtyping.
Consistent Subtyping for All 13


T1 C A

<: <:  <:

B T2  T1 B


<: <: <:

A C ∼ T2

(a) (b)

Fig. 5. Observations of consistent subtyping


A2 A3 A1 = (((∀a.a → Int) → Int) → Bool) → (∀a.a)
<: <: A2 = ((∀a.a → Int) → Int) → Bool) → (Int → Int)
A3 = ((∀a. → Int) → Int) → Bool) → (Int → )
A1  A4
A4 = ((( → Int) → Int) → Bool) → (Int → )

Fig. 6. Example that is fixed by the new definition of consistent subtyping.

Definition of Consistent Subtyping. From the above discussion, we are ready to


modify Definition 1, and adapt it to our notation:

Definition 2 (Consistent Subtyping)

Ψ  A <: C C∼D Ψ  D <: B


Ψ AB

With Definition 2, Fig. 6 illustrates the correct relation chain for the broken
example shown in Fig. 4c. At first sight, Definition 2 seems worse than the origi-
nal: we need to guess two types! It turns out that Definition 2 is a generalization
of Definition 1, and they are equivalent in the system of Siek and Taha [22].
However, more generally, Definition 2 is compatible with polymorphic types.

Proposition 1 (Generalization of Consistent Subtyping)

– Definition 2 subsumes Definition 1.


– Definition 1 is equivalent to Definition 2 in the system of Siek and Taha [22].

3.3 Abstracting Gradual Typing

Garcia et al. [13] presented a new foundation for gradual typing that they
call the Abstracting Gradual Typing (AGT) approach. In the AGT approach,
gradual types are interpreted as sets of static types, where static types refer
to types containing no unknown types. In this interpretation, predicates and
14 N. Xie et al.

functions on static types can then be lifted to apply to gradual types. Central
to their approach is the so-called concretization function. For simple types, a
concretization γ from gradual types to a set of static types4 is defined as follows:
Definition 3 (Concretization)
γ(Int) = {Int} γ(A → B) = γ(A) → γ(B) γ() = {All static types}
Based on the concretization function, subtyping between static types can be
lifted to gradual types, resulting in the consistent subtyping relation:
: B if and only if A1 <:
Definition 4 (Consistent Subtyping in AGT). A <
B1 for some A1 ∈ γ(A), B1 ∈ γ(B).
Later they proved that this definition of consistent subtyping coincides with
that of Siek and Taha [22] (Definition 1). By Proposition 1, we can directly con-
clude that our definition coincides with AGT:
Proposition 2 (Equivalence to AGT on Simple Types). A  B iff
A<: B.
However, AGT does not show how to deal with polymorphism (e.g. the inter-
pretation of type variables) yet. Still, as noted by Garcia et al. [13], it is a promis-
ing line of future work for AGT, and the question remains whether our definition
would coincide with it.
Another note related to AGT is that the definition is later adopted by
Castagna and Lanvin [7], where the static types A1 , B1 in Definition 4 can be
algorithmically computed by also accounting for top and bottom types.

3.4 Directed Consistency


Directed consistency [15] is defined in terms of precision and static subtyping:
A A A <: B B B
A  B 
The judgment A B is read “A is less precise than B”. In their setting, precision
is defined for type constructors and subtyping for static types. If we interpret
this definition from AGT’s point of view, finding a more precise static type5
has the same effect as concretization. Namely, A A implies A ∈ γ(A ) and
 
B B implies B ∈ γ(B ). Therefore we consider this definition as AGT-style.
From this perspective, this definition naturally coincides with Definition 2.
The value of their definition is that consistent subtyping is derived composi-
tionally from static subtyping and precision. These are two more atomic relations.
At first sight, their definition looks very similar to Definition 2 (replacing by
<: and <: by ∼). Then a question arises as to which one is more fundamental. To
answer this, we need to discuss the relation between consistency and precision.
4
For simplification, we directly regard type constructor → as a set-level operator.
5
The definition of precision of types is given in appendix.
Consistent Subtyping for All 15

Relating Consistency and Precision. Precision is a partial order (anti-symmetric


and transitive), while consistency is symmetric but not transitive. Nonetheless,
precision and consistency are related by the following proposition:

Proposition 3 (Consistency and Precision)


– If A ∼ B, then there exists (static) C, such that A C, and B C.
– If for some (static) C, we have A C, and B C, then we have A ∼ B.

It may seem that precision is a more atomic relation, since consistency can be
derived from precision. However, recall that consistency is in fact an equivalence
relation lifted from static types to gradual types. Therefore defining consistency
independently is straightforward, and it is theoretically viable to validate the
definition of consistency directly. On the other hand, precision is usually con-
nected with the gradual criteria [25], and finding a correct partial order that
adheres to the criteria is not always an easy task. For example, Igarashi et al.
[14] argued that term precision for System FG is actually nontrivial, leaving
the gradual guarantee of the semantics as a conjecture. Thus precision can be
difficult to extend to more sophisticated type systems, e.g. dependent types.
Still, it is interesting that those two definitions illustrate the correspondence
of different foundations (on simple types): one is defined directly on gradual
types, and the other stems from AGT, which is based on static subtyping.

3.5 Consistent Subtyping Without Existentials


Definition 2 serves as a fine specification of how consistent subtyping should
behave in general. But it is inherently non-deterministic because of the two
intermediate types C and D. As with Definition 1, we need a combined relation to
directly compare two types. A natural attempt is to try to extend the restriction
operator for polymorphic types. Unfortunately, as we show below, this does not
work. However it is possible to devise an equivalent inductive definition instead.

Attempt to Extend the Restriction Operator. Suppose that we try to extend the
restriction operator to account for polymorphic types. The original restriction
operator is structural, meaning that it works for types of similar structures.
But for polymorphic types, two input types could have different structures due
to universal quantifiers, e.g., ∀a.a → Int and (Int → ) → Int. If we try to
mask the first type using the second, it seems hard to maintain the information
that a should be instantiated to a function while ensuring that the return type is
masked. There seems to be no satisfactory way to extend the restriction operator
in order to support this kind of non-structural masking.

Interpretation of the Restriction Operator and Consistent Subtyping. If the


restriction operator cannot be extended naturally, it is useful to take a step
back and revisit what the restriction operator actually does. For consistent sub-
typing, two input types could have unknown types in different positions, but we
only care about the known parts. What the restriction operator does is (1) erase
Exploring the Variety of Random
Documents with Different Content
swept up the chips and patched the fence and whitewashed it. By
this time Mr. Carson had the fever, too. He started to clear off the
land, all the family helping him. All summer long they worked, early
and late, cutting out the briars and underbrush, burning broom sage,
building fences, and by fall you wouldn’t have known it for the same
place. They worked for a number of other people, too, and made a
little money, besides taking seed corn and a pair of little pigs and
other things they needed in payment.
“Well, it took a lot of money for a monument like Andy’s was to be,
but the Carsons worked and saved for it. It seemed as if they had set
a new standard for themselves and were trying hard to live up to
Andy’s monument.
“They painted the house and repaired and whitewashed the
outbuildings and put a paling fence around the front yard. They got
lace curtains and a store carpet for their best room, and when Father
got us a piano, Mrs. Carson bought our organ for a trifle. They got
new clothes and dishes and tablecloths, and every Sunday they all
came to meeting and asked folks home with them to dinner just as
anybody else did.
“Dave Orbison was courting Maggie, and Willie was ready to go to
the academy. He wanted an education and came to our house every
week to get Truman to help him with his studies or to borrow books.
If it hadn’t been for the monument, people would have forgotten that
the Carsons had ever been considered lazy or shiftless.
“But Mrs. Carson was always talking about the monument. She
had never had Andy’s funeral sermon preached, and she planned to
have it preached the Sunday after the monument was set up.
“And at the end of three years they had enough money, but for
some reason they didn’t get the monument. Everybody wondered
about it. Weeks went by, and still no news of the monument. Willie
often came to our house, but he never mentioned it. Then one day
Mrs. Carson came. She had a horse now, and she looked longer and
thinner than ever in her black calico riding skirt.
“Mother was fitting a dress on me—a red wool delaine for Sundays
—but Mrs. Carson dropped into a chair without even glancing at it.
“‘Mrs. Purviance,’ she began immediately, ‘I want your honest
opinion about something. For over three years now we’ve been
saving for Andy’s monument, and until a few weeks ago I never had
a thought but that that was the right thing to do with the money. But
one night I got to thinking that here was Willie wanting an education,
and Maggie getting ready to be married and no money to help her
set up housekeeping, and Lissy longing for music lessons, and I
couldn’t sleep for thinking. And, Mrs. Purviance, I haven’t had a
minute’s peace since. That’s why I haven’t ordered the monument. I
can’t make up my mind to it. It’ll be a long time before we can help
Willie much if we spend the monument money. It looks as if he ought
to have his chance. And of course the money won’t help Andy any,
but I had set my heart on a fine monument for him. I don’t know what
to do,” and she started to cry.

“Mrs. Carson,” said Mother, “you have given Andy a better


monument than you can ever set up in the cemetery”

“‘Mrs. Carson,’ Mother said gently, and there were tears in her
eyes, too, ‘if you want to know what I really think, I’ll tell you. I think
that as far as honoring Andy is concerned you and your family have
already given him a much better monument than any you can ever
set up in the cemetery.’
“Mother ran a pin straight into me and I jumped, and Mother said
she was done with me for a while. I went out, and that was the last I
heard of the monument until the Sunday Andy’s funeral sermon was
to be preached.
“There had been so much talk about the monument and the long
put-off funeral sermon that there was an unusually large crowd at the
church that day.
“And some of them were disappointed, for when the service was
over and we filed out, the Carsons first, past the flower-decked
graves to the corner where Andy was buried, there was Andy’s grave
adorned with only a plain little head stone. But grouped around it
stood his family, and the way that family had improved in the three
years since Andy’s death—well, as my mother said, that was a pretty
fine monument for Andy, don’t you think so?
“And now don’t forget your ‘apple a day,’ and good night to
everybody.”
MEMORY VERSES
Grandma had been reading aloud from Pink’s Sunday-school
paper and when she finished she said:
“We didn’t have anything like this when I was a little girl. We didn’t
even have any Sunday school. The nearest thing to Sunday school
was when we recited our memory verses on meeting day. Every
week we learned so many verses from the Bible, and on meeting
day the preacher heard us recite them.
“I remember one year—it was Reverend Bard’s second year—that
in order to get the children to take more interest in learning the
verses, the preacher offered a Testament to the one who could say
the most verses by a certain time. We were all eager to get the
Testament, and we did study harder than usual.
“The contest was to take place on Sunday afternoon. There was to
be preaching in the morning, dinner on the grounds, and in the
afternoon a prayer meeting and the memory-verse contest. There
would be a large crowd, and anyone who wanted to could try for the
Testament. Even the smallest children would say what verses they
knew.
“Charlie was always hunting for the shortest verses, and he hadn’t
learned very many of any kind till toward the last. Then he learned
five or six a day and carried a Bible around in his pocket wherever
he went and studied every spare minute.
“I had been getting my verses regularly every week and I had a
good memory. So I wasn’t much afraid of anyone beating me except
Charlie or Annie Brierly or maybe Betty Bard, the preacher’s
granddaughter. Betty knew a lot of verses, but at the last minute she
was likely to get to thinking of something else and forget them.
“On Saturday Betty and Annie came to see me, and Betty said that
Lissy Carson was going to try for the Testament, too. The Carsons
hadn’t been coming to meeting very long, but Betty, when she had
been there to call with her grandfather a few days before, said Lissy
knew fifty-one verses.
“‘And I think she ought to have the Testament,’ announced Betty.
‘Grandfather said it would encourage the whole family. If you two
girls and Charlie and I let her say more verses than we do, she
would get it.’
“‘But if we knew more verses and just let her get the Testament on
purpose,’ put in Annie, ‘it wouldn’t be right, would it?’
“‘But see how hard she’s trying,’ argued Betty. ‘The Carsons have
nothing but the big family Bible, and Lissy has to stand by the table
and learn her verses out of it. If she works so hard and doesn’t get
anything, she might think there’s no use in trying.’
“Annie looked stubborn.
“‘My Father said he would give me a dollar if I get the Testament,’
she said, ‘and I mean to try for it. You can do as you like, Betty, but I
will say all the verses I know.’
“‘I should hate to have Lissy get ahead of me,’ I explained, ‘when
I’ve always gone to meeting and she hasn’t and I am in the fifth
reader and she is only in the third. It would look as if she was so
much smarter than I am and Mother hates to have us thought a bit
backward.’
“At these arguments Betty herself looked uncertain.
“‘Well, maybe you’re right,’ she remarked. ‘I know it would
disappoint Grandfather if I only said a few verses, for he says I
should be an example to the other children.’ Then she saw Charlie
picking up some early apples in the orchard. ‘Let’s see what Charlie
says,’ she cried, and was off across the road with Annie and me
following.
“When we had explained the matter to Charlie, he looked at us
scornfully. ‘I never saw such sillies,’ he said. ‘If you girls pull out,
though, it will make it that much easier for the rest of us. I’m for the
Testament.’ Then he pretended he was reading from a book he held
in his hand, ‘Presented to Charles Purviance by his pastor for
excellence—.’ Betty started after him, and then Annie and I chased
him, too, and we got to playing ‘tag’ and forgot all about Lissy and
the Testament.
“Sunday was a beautiful day, bright and sunshiny. From miles
around people came to attend the all-day service. There were many
strangers. With the Orbisons came Mr. Orbison’s sister and her
granddaughter, a little girl about my age named Mary Lou, who was
visiting away from California. Mary Lou wore a silk dress and lace
mitts and a hat with long velvet streamers and she carried a pink
parasol.

Mary Lou wore a silk dress and lace mitts and carried a pink
parasol

“Tables had been set up in the grove across from the church, and
at noon, after the morning sermon, dinner was served. There was
fried chicken and boiled ham and pickles and pie and cake and
everything good you could think of, and the people had all they could
eat.
“After dinner Mrs. Orbison brought Mary Lou over to where Annie
and Betty and I were sitting and left her to get acquainted, so she
said. But Mary Lou didn’t want to get acquainted with us. She just
wanted to talk about herself. She told us that she had three silk
dresses and eleven dolls and a string of red beads and a pony not
much larger than a dog and ever so many other things.
“‘Don’t you have a silk dress for Sunday?’ she asked, looking at
my blue sprigged lawn, which until then I had thought very nice.
“‘No,’ I replied. And I added crossly, ‘My mother says it’s not what
you’ve got that counts but what you are,’ though I’m free to confess I
didn’t get much consolation from this thought, then.
“Pretty soon we went into the church, and after a prayer and some
songs the smaller children began to go up one by one to say their
verses. Brother Bard kept count and as they finished each verse he
would call out the number of it.
“After a while he came to Lissy Carson, and every one was
surprised when she kept on until at last she had recited sixty-one
verses, two more than anyone else had given so far.
“I looked at Betty, but she sat with downcast eyes and flushed
cheeks. Annie looked scared, and I couldn’t see Charlie. Then Betty
was called on and she said fifty-eight verses and quit.
“‘Are you sure that is all, Betty?’ her grandfather said in a puzzled
tone.
“‘Yes, sir,’ Betty replied and took her seat.
“I came next and I had made up my mind by then that I wouldn’t
keep Lissy from getting the Testament, so I recited fifty-nine verses. I
can still see the amazement in Mother’s face when I sat down.
“Annie Brierly gave fifty-nine and Charlie sixty, though of course,
like Betty and me, they each knew many more verses than that.
Lissy would get the Testament, and I was glad of it when I saw her
sitting there so proud and happy. Why didn’t Reverend Bard give it to
her at once and be done with it? Whatever was he waiting for? Then
I saw. Mary Lou, the strange little girl, was tripping up front in all her
finery as self-possessed as you please.
“And what do you think? She said sixty-three verses and got the
Testament!
“Well, you can imagine how Annie and Betty and Charlie and I felt,
though Charlie wouldn’t talk about it even to me. He never admitted
but what he’d said all the verses he knew, though I knew better.
Hadn’t I heard him at home reciting chapter after chapter when he
thought no one was listening?
“We girls went around behind the church to talk it over, and Annie
cried a little, and Betty stamped her foot and said she wasn’t an
example any more and she wished Mary Lou would tear her parasol
and lose her mitts and get caught in a rain and spoil her hat. And we
all got to laughing and forgot our disappointment.
“And now it’s bedtime for three little children I know.”
THE COURTING OF POLLY ANN
One evening when Bobby and Alice and Pink came to Grandma’s
room they found her sitting before the fire rocking gently to and fro
and looking thoughtfully at something she held in her hand. When
they had drawn up their stools and sat down, she handed the object
to them and they passed it from one to the other, examining it
eagerly.
It was a button—a pearl button of a peculiar shape, fancifully
carved. The holes were filled with silk thread, attaching to the button
a bit of faded flannel as if it had been forcibly torn from a garment.
“I found that button today,” Grandma began, “when I was looking
for something else, in a little box in the bottom of my trunk. I had
forgotten I had it. It came off my brother Stanley’s fancy waistcoat,
and the way of it was this:
“Stanley had been away at school all year, and when he came
home he had some stylish new clothes—among other things a pair
of lavender trousers and a waistcoat to match and a ruffled shirt and
some gay silk cravats.
“Every Sunday he dressed up as fine as could be, and all the girls
were nice to him. But he didn’t pay any attention to any of them
except Polly Ann Nesbit, who was the prettiest girl in all the country
round about. Some people called Polly Ann’s hair red, but it wasn’t. It
was a deep rich auburn, and she had brown eyes and a fair creamy
skin. Besides being pretty she was sweet-tempered, though lively
and gay.
“Polly Ann had so many beaux that when she was sixteen every
one thought she would be married before the year was out, and her
father—Polly Ann was his only child—said that he wouldn’t give Polly
Ann to any man. He needn’t have worried, for Polly Ann was so hard
to please that she was still unwed at twenty when Stanley came
home from school. By that time her father was telling every one how
much land he meant to give Polly Ann when she married.
“Stanley hadn’t been home very long until he, like all the other
boys, was crazy about Polly Ann, and she favored him more than
any of the others. Stanley went to see her every week and escorted
her home from parties and singings and took her to ride on Sunday
afternoons in his new top buggy. Father suspected he would be
wanting to get married, and told him he could have the wheat field on
what we called the upper place, to put in a winter crop for himself.
“Then one night at a party at Orbison’s Stanley wore his new
lavender waistcoat. Polly Ann wagered the other girls that she could
have a button off the waistcoat for her button string, and they
wagered her she couldn’t.
“That night when Stanley asked Polly Ann if he might see her
home she said he could if he would give her a button off his
waistcoat. It must have been hard for Stanley, for he knew he could
never wear the waistcoat again if he did as she asked and that he
couldn’t go with Polly Ann any more if he refused. He had no knife
and he wouldn’t borrow one, so he just wrenched a button off and
gave it to Polly Ann.
“When the girls went upstairs to put on their wraps, Polly Ann
showed the button to them and they had lots of fun about it. The next
morning Aggie told Stanley what Polly Ann had done and how every
one was laughing at him.
“Stanley was at breakfast. There was no one in the kitchen but
Stanley and Aggie and me, and they didn’t pay any attention to me. I
remember how red Stanley’s face got when Aggie told him, and his
chin, which had a dimple, seemed suddenly to get square like
Father’s. I thought to myself that Polly Ann Nesbit had better look
out, for, as Father often told us, ‘he who laughs last, laughs best.’
Stanley did get even with Polly Ann, though not in the way we
thought he would.
“Before he went to work that morning he wrote her a letter and
paid Charlie a quarter for taking it to her. Charlie told me that Polly
Ann was in the front yard by herself when he gave her the letter and
when she read it she just laughed and laughed, but that she put it in
her pocket for safekeeping.
“Stanley was as nice as ever to her when they met, but he didn’t
go to see her any more or take her buggy riding on Sunday
afternoons. He took Mother or me instead, and I thought it very nice.
Stanley went right ahead ploughing up his wheat field just as if
nothing had happened, and when he got through with that he began
to fix up a little cottage where brother Joe had lived for two years
after he was married.
Polly Ann was in the front yard when Charlie gave her the letter

“He built a new kitchen, at the side instead of at the back where
most people built their kitchens, so his wife could see the road when
she was working, he said. And he added a front porch with railings
and a seat at each end and painted the house white and set out rose
bushes and honeysuckle vines and began to buy the furniture.
“Of course it caused a great deal of talk, and every one wondered
whom Stanley was going to marry. The girls would laugh about
Stanley’s house and say they wouldn’t marry a man who wouldn’t let
them furnish their own house. And often they would tease Polly Ann,
but she would only toss her head and say nothing.
“And all the time Stanley worked away, singing and whistling as
happy as could be. When any one questioned him, he would say he
meant to keep bachelor’s hall, or that he hadn’t decided what he
would do, or that he planned to marry the sweetest girl he knew.
Belle and Aggie were wild to know what girl he meant. They tried in
every way to find out, but they couldn’t.
“Stanley often talked in his sleep, and they would listen to hear
whether he mentioned a girl’s name, but they could never
understand what he said. Some one told the girls to tie a string
around Stanley’s great toe and when he talked to pull the string
gently and he would repeat clearly what he had just said.
“One night Belle and Aggie did this, but instead of a string they
used a piece of red yarn. When they were pulling it, it snapped in
two, and Stanley woke up and found the yarn on his toe and jumped
out of bed and chased the girls squealing and giggling into their
room, and Father came out to see what was the matter.
“But finally the house was done, even to the last shining pan, and
Mother had given Stanley so many quilts and blankets and things
that Charlie grumbled and said there would be nothing left for the
rest of us.
“One afternoon I was up at the cottage with Stanley planting some
of Mother’s wonderful yellow chrysanthemums by the garden fence.
Stanley was building a lattice at the end of the porch for a climbing
rose which he had only just set out, when the front gate clicked and
there, coming up the path, was Polly Ann Nesbit. Her cheeks were
rosy and she was laughing.
“‘I’ve brought it myself, Stanley,’ she cried gaily. ‘You said in your
letter to send you the button when I was ready to marry you, but I’ve
brought it instead. Do you—do you still want it?’ and she held out
this little button, the very one Stanley had pulled off his lavender
waistcoat to please her.
“I looked at Stanley, so straight and tall and handsome though he
was in his everyday clothes, to see what he would do.
“‘Do I want it?’ he cried starting toward her. ‘Why, Polly Ann, I’ve
just been longing for that button. I never wanted anything so much in
my life. I was only afraid you wouldn’t give it to me.’ He put his arms
around her and they went in to look at the house. When they had
gone in, I saw this little button lying on the path almost at my feet,
and I picked it up and skipped home to tell Mother and the girls that
Stanley was going to marry Polly Ann after all.
“And now, ‘’night, ’night,’ and pleasant dreams.”
EARNING A VIOLIN
“And you don’t like to practice!” Grandma exclaimed in surprise
when Bobby told her why he did not like to take violin lessons. “But
you’ll have to practice, you know, or you will never learn to play. I
knew a boy once, who dearly liked to practice. I think I’ll tell you
about him. It was my brother Charlie. Charlie had wanted a violin
ever since he was just a little bit of a fellow and had first heard old
Mr. Potter play on his violin.
“Mr. Potter was a traveling tailor who went around the country
making and mending men’s clothing. He carried his goods from
place to place in pack saddles, and he always brought his violin
along.
“In the evenings he would play, and we all loved to hear him. He
played beautifully. All Charlie and I had ever heard before were
things like ‘Pop goes the Weasel,’ or ‘Turkey in the Straw.’ There
was such a difference between these tunes and what Mr. Potter
played that the first time Charlie heard him play—‘Annie Laurie,’ I
think it was—he walked up to him and said very solemnly, ‘I like a
violin better than a fiddle,’ and everybody laughed.
“Years before, Mr. Potter had had a thriving trade, but when I knew
him he did not get much to do because store suits for men had
become common. Mother always found some work for him, though,
and in his spare time he gave violin lessons.
“He was in our neighborhood several weeks each spring, and one
winter Charlie determined to have a violin and be ready to take
lessons when he came next time.
“So right away he began to save money for a violin. But there
wasn’t much Charlie could do to earn money, and it looked as
though he would never get enough for a violin, let alone enough for
an instruction book and lessons. But he did get the violin, and this is
how it came about.
“It was one of the coldest winters anyone remembered in years. A
deep snow lay on the ground for weeks and weeks, and the roads
were frozen hard and as smooth as glass.
“There was a sawmill about eight miles down the road from our
house, and every day we could see men passing on their way to the
mill with logs. Big iron hooks called ‘dogs’ would be driven into the
logs and fastened to a heavy chain which would be hitched to a
single-tree, and the log would be dragged over the smooth road by
one horse. It was an easy way to get logs to the mill, and every one
was hurrying to haul as many as possible before the thaw came.

“I like a violin better than a fiddle,” said Charlie to Mr. Potter

“Father had cut one big walnut log when he had been called to
serve on jury duty and had gone to Clayville to attend court. Before
he went, Charlie asked him what he would do with that one log and
Father told Charlie he could have it. Charlie could hardly believe his
ears and he asked Father whether he really meant that he could
have the money for the log if he could get it to the mill. Father said
that was what he meant, but afterward he told Mother he never
dreamed Charlie would try to do it.
“But from the first Charlie intended to move that walnut log to the
mill. He thought of nothing else. He made plan after plan. He found
out from the storekeeper that the man who owned the sawmill came
to the store Saturday afternoons to buy supplies for the next week.
So when Charlie and I went to the store for Mother on the next
Saturday we sat by the stove to warm ourselves and wait for the
sawmill man. When he came, Charlie asked him whether he would
buy the walnut log.
“‘Well, that depends,’ said the man, looking Charlie over good-
naturedly. ‘I’m not anxious to lay in any more logs than we’ve
bargained for. We’re going to move Wednesday.’ Then when he saw
the disappointment on Charlie’s face he asked, ‘Pretty good log, is
it?’
“‘Oh, yes, sir,’ said Charlie eagerly. ‘My father said when he cut it
that it was first grade—woods-grown, ten or twelve feet long.’
“‘Well, if that’s the case, I reckon I could use it,’ said the man. ‘Be
sure to have it in by Tuesday, though.’
“We went home by way of Mr. Brierly’s, and Charlie got permission
to borrow his logging chain and ‘dogs,’ as they were called. We
stopped to look at the log, and Charlie declared he could get it to the
mill without any trouble. He could have, too, if it hadn’t been for the
thaw.
“Sunday was the longest day Charlie ever put in. Sometimes he
would get discouraged and think he couldn’t do it at all. Then the
next minute he would be talking about the kind of violin he would get
with the money the log would bring. Father had come home for over
Sunday and he would help him get started, the older boys being
away from home.
“Sunday, after dinner, the weather turned slightly warmer, and by
four o’clock a gentle rain was falling. When Charlie got up long
before daylight Monday morning, Mother told him that it had rained
hard all night. He fed the horse and ate his breakfast, and Father
helped him drive the hooks or dogs into the log. Then Charlie was
off.
“He got the log as far as Sugar Creek without any trouble, and
there what a sight met his eyes! Sugar Creek was out of bank, and
the shallow stream, easily forded the year round, was like an angry,
rushing little river filled with cakes of ice. To ford it was clearly
impossible till the ice went out, and even then the current would be
rapid and dangerous. There was nothing to do but wait, and Charlie
unhitched the horse and came back home. It was still raining and
thawing and it didn’t get any better all that day. The next morning,
though, the creek was clear of ice, which was some advantage.
“I went with Charlie and sat on the log, feeling very helpless while
he walked up and down the creek bank trying to think of some way
to get the log across. The current was so strong that, though the
horse could swim it, he could not swim and drag the heavy log along.
“Charlie examined the foot-log carefully and found that it had not
been moved by the high water, being chained at each bank to a big
tree. Then he made his plan. He fastened some strong rope he had
brought along to the chain which went around the walnut log.
Holding the other end of the rope, he got on the horse and made him
swim to the opposite bank. Then he fastened the rope at that side to
the single-tree and urged the horse up the bank.
“The horse tugged and pulled and finally the log moved slowly
down into the water. Now came the test of Charlie’s plan. If the foot-
log proved strong enough to withstand the jar it would get when the
walnut log hit it, everything would be all right; but if the foot-log gave
way, Charlie would have to cut the rope quickly to keep the horse
from being drawn back into the water, and the walnut log would float
down stream and be lost.
“I almost held my breath when the walnut log, sucked rapidly down
the stream by the swift current, struck the foot-log. I shut my eyes
tight and did not open them until I heard Charlie shouting for joy. The
foot-log hadn’t budged! Because of the high water Charlie thought it
would be easy for the horse to pull the log out on the ground, but the
log stuck on something under the water. Charlie couldn’t raise the
log up, and he had to let it slide back into the water. It slid back
several times before it finally came out on the road.
“It was nearly noon and Charlie was wet to the waist, so he went
back home to change his clothes and get a fresh horse. After dinner
he started out again. He got to the mill all right and sold the log, and
when he reached home late that night he had money enough for a
violin.
“When Father heard about it, he was so proud of him that he
doubled the money. So Charlie had more than enough for his
lessons and his instruction book, too.”
“And did he really like to practice?” asked Bobby unbelievingly.
“Yes, indeed, and he came to be a fine violinist and owned a violin
that cost a great deal of money, but he always kept that first one, too.
“There! Mother’s calling you to bed.”
AT THE FAIR
“We’re going to the fair tomorrow, Grandma. It’s childrens’ day,”
announced Bobby one evening when he and Alice and Pink came to
Grandma’s room for their usual evening call and story.
“Are you going, Grandma?” inquired Pink.
“Why, I may go. I don’t know yet. Do you like to go to the fair?”
“Yeh, boy!” interrupted Bobby eagerly. “And this year they’re going
to give a pony away. I wish I’d get that pony.”
“That would be nice,” agreed Grandma. “I think I’ll tell you tonight
about the time we took our horse, Prince, to the fair at Clayville. I
had been to the fair several times before, and I always loved to go.
To get up early in the morning, and dress and eat breakfast and start
before daylight with a big basket of dinner tucked away in the back of
the surrey; to take the long pleasant drive through the cool of the
morning and at last go through the gates into the fair grounds and
see all the people and hear the noise of the sideshow barkers and
the bands and the balloon whistles and the lowing of cattle, uneasy
because of their strange quarters, was every bit of it a joy to me—
usually.
“But this particular year it wasn’t a pleasure to look forward to the
fair at all, even though there was to be a balloon ascension. For
when we went to the fair Father was going to take Prince along and
sell him to a horse dealer. Father had raised Prince, and we all loved
him, especially Charlie and I. He was nine years old, but he still
looked like a colt. His coat was brown and glossy, and he was as
playful and active as he had ever been. When he had been a colt,
the older children had petted him and fed him sugar. Charlie and I
had taken it up when they left off, so that he had always been used
to children and loved them.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like