The X 3 Language Specification

Σχετικά έγγραφα
ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

The Simply Typed Lambda Calculus

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

2 Composition. Invertible Mappings

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

4.6 Autoregressive Moving Average Model ARMA(1,1)

Συντακτικές λειτουργίες

Homework 3 Solutions

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

EE512: Error Control Coding

C.S. 430 Assignment 6, Sample Solutions

Galatia SIL Keyboard Information

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Every set of first-order formulas is equivalent to an independent set

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

derivation of the Laplacian from rectangular to spherical coordinates

The challenges of non-stable predicates

Instruction Execution Times

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Finite Field Problems: Solutions

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

(C) 2010 Pearson Education, Inc. All rights reserved.

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

Assalamu `alaikum wr. wb.

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Example Sheet 3 Solutions

Partial Trace and Partial Transpose

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

About these lecture notes. Simply Typed λ-calculus. Types

Math221: HW# 1 solutions

Other Test Constructions: Likelihood Ratio & Bayes Tests

Fractional Colorings and Zykov Products of graphs

Areas and Lengths in Polar Coordinates

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

ST5224: Advanced Statistical Theory II

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

ΕΠΙΧΕΙΡΗΣΙΑΚΗ ΑΛΛΗΛΟΓΡΑΦΙΑ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΑ ΣΤΗΝ ΑΓΓΛΙΚΗ ΓΛΩΣΣΑ

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Section 8.3 Trigonometric Equations

Approximation of distance between locations on earth given by latitude and longitude

Μορφοποίηση υπό όρους : Μορφή > Μορφοποίηση υπό όρους/γραμμές δεδομένων/μορφοποίηση μόο των κελιών που περιέχουν/

Concrete Mathematics Exercises from 30 September 2016

SOAP API. Table of Contents

Areas and Lengths in Polar Coordinates

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Congruence Classes of Invertible Matrices of Order 3 over F 2

Μηχανική Μάθηση Hypothesis Testing

Statistical Inference I Locally most powerful tests

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

PARTIAL NOTES for 6.1 Trigonometric Identities

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Math 6 SL Probability Distributions Practice Test Mark Scheme

Code Breaker. TEACHER s NOTES

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

Lecture 2. Soundness and completeness of propositional logic

Section 7.6 Double and Half Angle Formulas

Section 9.2 Polar Equations and Graphs

Matrices and Determinants

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Solutions to Exercise Sheet 5

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 11/3/2006

On a four-dimensional hyperbolic manifold with finite volume

Lecture 15 - Root System Axiomatics

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Second Order Partial Differential Equations

Reminders: linear functions

TMA4115 Matematikk 3

Notes on the Open Economy

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

A Note on Intuitionistic Fuzzy. Equivalence Relation

Inverse trigonometric functions & General Solution of Trigonometric Equations

ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΕΙΡΑΙΩΣ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. Βάσεις Δεδομένων (4 ο εξάμηνο) Εργαστήριο MySQL #2

Block Ciphers Modes. Ramki Thurimella

Second Order RLC Filters

Strain gauge and rosettes

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

ΤΕΧΝΟΛΟΓΙΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΝΟΣΗΛΕΥΤΙΚΗΣ

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

ΠΤΥΧΙΑΚΗ ΕΡΓΑΣΙΑ ΒΑΛΕΝΤΙΝΑ ΠΑΠΑΔΟΠΟΥΛΟΥ Α.Μ.: 09/061. Υπεύθυνος Καθηγητής: Σάββας Μακρίδης

5.4 The Poisson Distribution.

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Η ΠΡΟΣΩΠΙΚΗ ΟΡΙΟΘΕΤΗΣΗ ΤΟΥ ΧΩΡΟΥ Η ΠΕΡΙΠΤΩΣΗ ΤΩΝ CHAT ROOMS

Επιβλέπουσα Καθηγήτρια: ΣΟΦΙΑ ΑΡΑΒΟΥ ΠΑΠΑΔΑΤΟΥ

Tridiagonal matrices. Gérard MEURANT. October, 2008

General 2 2 PT -Symmetric Matrices and Jordan Blocks 1

Uniform Convergence of Fourier Series Michael Taylor

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

Right Rear Door. Let's now finish the door hinge saga with the right rear door

MATH423 String Theory Solutions 4. = 0 τ = f(s). (1) dτ ds = dxµ dτ f (s) (2) dτ 2 [f (s)] 2 + dxµ. dτ f (s) (3)

ΜΕΤΑΠΤΥΧΙΑΚΗ ΔΙΠΛΩΜΑΤΙΚΗ ΕΡΓΑΣΙΑ «ΘΕΜΑ»

Transcript:

The X 3 Language Specification Ross Tate October 11, 2013 1 Lexing and Parsing 1.1 Core and Full Languages ν v ::= variable/function/method names ν c ::= class/interface names ν p ::= type-parameter names ν vc ::= ν v ν c kind context Θ ::= ν p,..., ν p type context Γ ::= ν v :,..., ν v : type ::= ν p ν c,..., type scheme σ ::= Θ (Γ) : expression e ::= ν v ν vc,..., (e,..., e) e.ν v,..., (e,..., e) [e,..., e] e ++ e true false n "string" statement s ::= {s... s} ν v := e; if (e) s else s while (e) s for (ν v in e) s return e; interface i ::= interface ν c Θ extends {fun ν v σ;... fun ν v σ; fun ν v σ s... fun ν v σ s} class c ::= class ν c Θ (Γ) extends {s... s super(e,..., e); fun ν v σ s... fun ν v σ s} program p ::= s s... s p fun ν v σ s... fun ν v σ s p i p c p function context ::=, ν vc σ class context Ψ ::= Ψ, interface ν c Θ extends { ; ν v,..., ν v } Ψ, class ν c Θ extends { } Figure 1: Cubex Core Language Grammar, which gives the grammar for the Cubex core language, along with definitions for the formal constructs and Ψ, which are not part of the language per se but are useful in our formalization of the type system. Note that p stands for program and defines a syntactically-valid program in the Cubex core language. Note also that lists, represented with an elipsis, may consist of zero, one, or more elements. So a,..., a may be the empty string, a, or some list of as separated by commas. We distinguish between the Cubex core language, which is specified by the grammar in Figure 1.1, and the full language. The full language differs from the core language in a number of ways: It includes the following unary and binary operators, listed in order of precedence, which are (except for ++) short for method calls on arbitrary classes (their signatures are those that are given for the built-in classes at the end of this document). All operators are left-associative. 1. Unary prefixes - and! short for negative and negate respectively. 2. Multiplicative operators *, /, and % short for times, divide, and modulo respectively. 3. Additive + and - short for plus and minus respectively. 4. Range operators.., <.,.<, <<,..., and <.., with the last two being unary suffixes; the binary operators are shorthand for through using additional Boolean parameters to indicate whether to include the lower and/or upper bounds; the unary suffixes are shorthand for onwards using an additional Boolean parameter to indicate inclusiveness. 5. The binary operator ++, (actually part of the core language), which implements appending of iterables, denoted in the grammar by ++. 6. Inequality operators <, <=, >=, and > short for lessthan with an additional Boolean parameter indicating strictness, and with order reversed for >= and >. 7. Equational operators == and!=, short for equals and equals followed by negate. 8. Boolean operators & short for and followed by short for or. Characters in the core language which have no obvious ASCII equivalent are represented in the full language in ASCII as follows: 1

Thing for and Nothing for. & for and for. & for. < for and > for. Expressions (denoted e in the grammar) may be surrounded by parentheses. If there are no type parameters (i.e. when,..., is the empty list), a class/interface/function specification can drop the. When calling a function/method/constructor with no type parameters, the may be dropped. If the else case is {}, it can be dropped. In the full language, unimplemented and implemented methods of interfaces may mixed together, unlike in the core language where all of the latter must follow all of the former. If a class or interface just extends, the extends clause can be omitted. If the call to super has no arguments, it can be omitted. If a function implementation is simply return of some expression, the return can be abbreviated to =. For example, fun foo(y : Integer) : Integer return y * 2; may be abbreviated to fun foo(y : Integer) : Integer = y * 2; Finally, there is no name hiding. If a judgement requires binding a name twice, that judgement is ill formed and does not hold. However, all the different kinds of context are different namespaces. So a name can be bound both in and Γ. To clarify, Γ and use the same namespace, so a variable must not be bound in both. 1.2 Name, Keywords, Literals, etc. The grammar uses ν with subscripts to denote both various kinds of names. We enforce a distinction between these kinds. Variables and function/method names (ν v ) are a lower-case letter followed by letters, numbers, and/or underscores. Class/interface names (ν c ) are an upper-case letter followed by one or more letters, numbers, and/or underscores. Type parameters (ν p ) are an upper-case letter alone. In the formalism we refer to all of these collectively as just ν. Key words (i.e. any words receiving special treatment in the core language) cannot be used as names or variables. String literals (denoted in the grammar by "string") have no escaping and cannot contain white space besides the space character. Integer literals (denoted in the grammar by n) are in decimal only. Finally, note that the grammar contains various other syntactic artifacts (semicolons, brackets, etc.) whose only legal uses in the language (outside of comments and string literals) are fully specified by their role in the grammar. 1.3 Whitespace and Comments Unless it occurs inside a string literal, white space is disregarded except for its role of separating names and other tokens (e.g. : = is not the same as := and only the latter can be used in a variable assignment). Unless it occurs inside a string literal, # starts a comment that extends to the end of the line. Unless it occurs inside a string literal, starts a comment that extends to the matching, where these comments can be nested inside each other. Comments are disregarded except for their role of separating names and other tokens. 2

2 Validating The following formalizes when a program is valid, incorporating type validity, type checking, and class/interface validation. Judgements take the form (context) (property). Ψ indicates the classes and interfaces in scope, what they directly inherit, and what their methods are. Θ indicates the type parameters in scope. indicates the function names in scope and what their type scheme is. Γ typically indicates the immutable variable names in scope and what their type is. typically indicates the mutable variable names in scope and what their type is. The following is a summary of the judgements used in this formalism and where their definitions can be found. Judgement Meaning Figure Ψ Θ <: is a subtype of 2 Ψ ν Θ extends generic class/interface ν Θ directly inherits 2 Ψ Θ Γ <: Γ Γ is a subcontext of Γ 2 Ψ Θ σ σ σ and σ are equivalent type schemes Ψ Θ.ν : σ method ν of type has type scheme σ 3 Ψ ˆν Θ.ν : σ generic class/interface ˆν Θ has method ν with type scheme σ 3 Ψ Θ is a valid type 4 Ψ Θ ˆ is an inheritable type with constructable component ˆ 4 Ψ Θ Γ Γ is a valid type context 4 Ψ Θ σ σ is a valid type scheme 4 Ψ Θ Γ e : expression e has type 5 Ψ Θ Γ s : mutable variables are available after valid statement s 6 Ψ Θ Γ b s : like above and all returns have type with b = true guaranteeing a return 7 Ψ Θ : are all the methods of 8 Ψ ˆν Θ : are the direct methods of generic class/interface ˆν Θ 8 Ψ Θ : ν provides an implementation of method ν 9 Ψ Γ i : Ψ i is a valid interface with signature Ψ 10 Ψ Γ c : Ψ c is a valid class with signature Ψ and constructor 10 Ψ Γ p p is a valid program 11 p p is a valid program in the initial environment 11 Ψ Θ <: Ψ ν Θ extends Ψ Θ Γ <: Γ Ψ Θ σ σ Ψ Θ ν <: ν Ψ Θ <: Ψ Θ <: Ψ Θ i <: Ψ Θ 1 2 <: Ψ Θ i <: i and Ψ Θ i <: i Ψ Θ ν 1,..., n <: ν 1,..., n Ψ ν ν 1,..., ν n extends Ψ Θ [ν 1 1,..., ν n n ] <: Ψ Θ ν 1,... n <: Ψ Θ <: Ψ Θ <: 1 Ψ Θ <: 2 Ψ Θ <: 1 2 interface ν Θ extends {... } in Ψ Ψ ν Θ extends Ψ Θ <: Ψ Θ Iterable <: Iterable class ν Θ extends {... } in Ψ Ψ ν Θ extends Ψ Θ <: Ψ Θ Γ <: Γ Ψ Θ ν :, Γ <: ν :, Γ Ψ Θ Γ <: Γ Ψ Θ ν :, Γ <: Γ Ψ Θ, ˆΘ Γ <: Γ Ψ Θ, ˆΘ Γ <: Γ Ψ Θ, ˆΘ <: Ψ Θ, ˆΘ <: Ψ Θ ˆΘ (Γ) : ˆΘ (Γ ) : Figure 2: Subtyping 3

Ψ Θ.ν : σ Ψ ν Θ.ν : σ Ψ Θ.ν : σ Ψ ˆν ν 1,..., ν n.ν : σ Ψ Θ ˆν 1,..., n.ν : σ[ν 1 1,..., ν n n ] interface ˆν Θ extends {..., νσ,... ;... } in Ψ Ψ ˆν Θ.ν : σ class ˆν Θ extends {..., νσ,... } in Ψ Ψ ˆν Θ.ν : σ Figure 3: Method Lookup Ψ Θ Ψ Θ Ψ Θ Γ Ψ Θ σ Ψ Θ ˆ Ψ Θ Ψ Θ Ψ Θ ν in Θ Ψ Θ ν interface ν ν 1,..., ν n extends {... } in Ψ Ψ Θ i Ψ Θ ν 1,..., n class ν ν 1,..., ν n extends {... } in Ψ Ψ Θ i Ψ Θ ν 1,..., n ν 1,..., n Ψ Θ ˆ Ψ Θ for all, Ψ Θ <: and Ψ Θ <: implies Ψ Θ <: Ψ Θ : Ψ Θ ˆ Ψ Θ i Ψ Θ, ˆΘ Γ Ψ Θ, ˆΘ Ψ Θ ν 1 : 1,..., ν n : n Ψ Θ ˆΘ (Γ) : Figure 4: Type Validity Ψ Θ Γ e : Ψ Θ Γ e : Ψ Θ <: Ψ Θ Γ e : ν : in Γ Ψ Θ Γ ν : Ψ Θ i ν ν 1,..., ν m (ˆν 1 : ˆ 1,..., ˆν n : ˆ n ) : in Ψ Θ Γ e i : ˆ i [ν 1 1,..., ν m m ] Ψ Θ Γ ν 1,..., m (e 1,..., e n ) : [ν 1 1,..., ν m m ] Ψ Θ i Ψ Θ Γ e : ˆ Ψ Θ ˆ.ν : ν 1,..., ν m (ˆν 1 : ˆ 1,..., ˆν n : ˆ n ) : Ψ Θ Γ e i : ˆ i [ν 1 1,..., ν m m ] Ψ Θ Γ e.ν 1,..., m (e 1,..., e n ) : [ν 1 1,..., ν m m ] Ψ Θ Γ e i : Ψ Θ Γ [e 1,..., e n ] : Iterable Ψ Θ Γ e i : Iterable Ψ Θ Γ e 1 ++ e 2 : Iterable Ψ Θ Γ true : Boolean Ψ Θ Γ n : Integer Ψ Θ Γ false : Boolean Ψ Θ Γ "string" : String Figure 5: Type Checking Expressions 4

Ψ Θ Γ Γ s : Γ Ψ Θ Γ s : Ψ Θ <: Ψ Ψ Θ Γ s : Θ Γ s :, ν :, ν :, Ψ Θ Γ s :, ν :, ν :, Ψ Θ Γ i 1 s i : i Ψ Θ Γ 0 {s 1... s n } : n Ψ Θ Γ, e : Ψ Θ Γ ν := e; :, ν : Ψ Θ Γ,, ν :, e : Ψ Θ Γ, ν :, ν := e; :, ν :, Ψ Θ Γ, e : Boolean Ψ Θ Γ s 1 : Ψ Θ Γ s 2 : Ψ Θ Γ if (e) s 1 else s 2 : Ψ Θ Γ, e : Boolean Ψ Θ Γ s : Ψ Θ Γ while (e) s : Ψ Θ Γ, e : Iterable Ψ Θ Γ, ν : s : Ψ Θ Γ for (ν in e) s : Figure 6: Type Checking Statements Ψ Θ Γ Γ b s : Γ Ψ Θ Γ b s : Ψ Θ <: Ψ Ψ Θ Γ b s : Ψ Θ Γ, e : ˆ Ψ Θ Γ false Ψ Θ Γ true s : Ψ Θ Γ false s : Ψ Θ Γ i 1 bi s i : i b = true implies there exists i with b i = true ν := e; :, ν : ˆ Ψ Θ Γ 0 b {s 1... s n } : n Θ Γ b s :, ν : ˆ, ν : ˆ, Ψ Θ Γ b s :, ν : ˆ, ν : ˆ, Ψ Θ Γ,, ν : ˆ, e : ˆ Ψ Θ Γ, ν : ˆ, false ν := e; :, ν : ˆ, Ψ Θ Γ, e : Boolean Ψ Θ Γ b s 1 : Ψ Θ Γ b s 2 : Ψ Θ Γ b if (e) s 1 else s 2 : Ψ Θ Γ, e : Boolean Ψ Θ Γ false Ψ Θ Γ, e : Iterable ˆ Ψ Θ Γ false Ψ Θ Γ, e : Ψ Θ Γ true Ψ Θ Γ b s : while (e) s : Ψ Θ Γ, ν : ˆ b s : for (ν in e) s : return e; : Figure 7: Type Checking Returns 5

Ψ Θ : Ψ ν Θ : Ψ Θ : Ψ Θ : Ψ Θ :, Ψ ˆν ν 1,..., ν n : Ψ ˆν ν 1,..., ν n extends Ψ ν 1,..., ν n : for all νσ in, for all ν σ in, ν = ν implies Ψ ν 1,..., ν n σ σ Ψ Θ ˆν 1,..., n : ( )[ν 1 1,..., ν n n ] interface ˆν Θ extends { ;... } in Ψ Ψ ˆν Θ : class ˆν Θ extends { } in Ψ Ψ ˆν Θ : Figure 8: Method-Context Lookup Ψ Θ : ν Ψ Θ i : ν Ψ Θ 1 2 : ν interface ˆν ν 1,..., ν n extends {... ;..., ν,... } in Ψ Ψ ˆν 1,..., n : ν Ψ ˆν ν 1,..., ν n extends Ψ ν 1,..., ν n : ν Ψ Θ ˆν 1,..., n : ν Figure 9: Method-Implemented Check class ˆν ν 1,..., ν n extends {..., νσ,... } in Ψ Ψ ˆν 1,..., n : ν Ψ Γ i : Ψ Ψ Γ c : Ψ Ψ Θ Ψ = interface ν Θ extends {ν 1 σ 1,..., ν n σ n, ˆν 1ˆσ 1,..., ˆνˆnˆσˆn ; ˆν 1,..., ˆνˆn } Ψ, Ψ Θ σ i Ψ, Ψ Θ ˆσ i Ψ, Ψ Θ ν Θ : for all ν Θ ( Γ) : in, for all ν in Θ, ν not in Θ ˆσ i = Θ i (Γ i ) : i Ψ, Ψ Θ, Θ i, Γ Γ i true i ŝ i : Γ i Ψ Γ interface ν Θ extends {fun ν 1 σ 1 ;... ; fun ν n σ n ; fun ˆν 1ˆσ 1 = ŝ 1... fun ˆνˆn σˆn = ŝˆn } : Ψ Ψ Θ ˆ Ψ = class ν Θ extends {ν 1 σ 1 ;... ; ν n σ n ; } = ν Θ () : ν Θ Ψ, Ψ Θ σ i Ψ, Ψ Θ 0 = Ψ, Ψ Θ, Γ i 1 s i : i ˆ(e 1,..., e k ) = () or Ψ, Ψ Θ, Γ, m ˆ(e 1,..., e k ) : ˆ Ψ, Ψ Θ ν Θ : for all ν Θ ( Γ) : in, for all ν in Θ, ν not in Θ σ i = Θ i (Γ i ) : i Ψ, Ψ Θ, Θ i,, Γ, m Γ i true i ŝ i : Γ i for all ˆνσ in, Ψ, Ψ Θ ν Θ : ˆν Ψ Γ class ν Θ () extends {s 1... s m super(e 1,..., e k ); fun ν 1 σ 1 ŝ 1... fun ν n σ n ŝ n } : Ψ Figure 10: Class and Interface Checking 6

Ψ Γ p p Ψ Γ true Iterable String s : Ψ Γ s 0 = Ψ Γ i 1 bi Iterable String s i : i Ψ Γ s 1... s n p Ψ Γ, n p =, ν 1 Θ 1 (Γ 1 ) : 1,..., ν n Θ n (Γ n ) : n Ψ Θ i Γ i Ψ Θ i i Ψ Θ i Γ Γ i true i s i : i Ψ Γ p Ψ Γ fun ν 1 Θ 1 (Γ 1 ) : 1 s 1... fun ν n Θ n (Γ n ) : n s n p Ψ Γ i : Ψ Ψ, Ψ Γ p Ψ Γ i p Ψ Γ c : Ψ Ψ, Ψ, Γ p Ψ Γ c p Ψ 0 = class Iterable E extends { }, class Boolean extends { negate () : Boolean ; and (that : Boolean ) : Boolean ; or (that : Boolean ) : Boolean ; through (upper : Boolean, includelower : Boolean, includeupper : Boolean ) : Iterable Boolean ; onwards (inclusive : Boolean ) : Iterable Boolean ; lessthan (that : Boolean, strict : Boolean ) : Boolean ; equals (that : Boolean ) : Boolean ; }, class Integer extends { negative () : Integer ; times (factor : Integer ) : Integer ; divide (divisor : Integer ) : Iterable Integer ; modulo (modulus : Integer ) : Iterable Integer ; plus (summand : Integer ) : Integer ; minus (subtrahend : Integer ) : Integer ; through (upper : Integer, includelower : Boolean, includeupper : Boolean ) : Iterable Integer ; onwards (inclusive : Boolean ) : Iterable Integer ; lessthan (that : Integer, strict : Boolean ) : Boolean ; equals (that : Integer ) : Boolean ; }, class Character extends { unicode () : Integer ; equals (that : Character ) : Boolean ; }, class String extends Iterable Character { equals (that : String ) : Boolean ; } 0 = character (unicode : Integer ) : Character, string (characters : Iterable Character ) : String Γ 0 = input : Iterable String Ψ 0 0 Γ 0 p p Figure 11: Program Checking 7