Elpi: an Extension Language for Coq (Metaprogramming Coq in the Elpi Λprolog Dialect) Enrico Tassi

Total Page:16

File Type:pdf, Size:1020Kb

Elpi: an Extension Language for Coq (Metaprogramming Coq in the Elpi Λprolog Dialect) Enrico Tassi Elpi: an extension language for Coq (Metaprogramming Coq in the Elpi λProlog dialect) Enrico Tassi To cite this version: Enrico Tassi. Elpi: an extension language for Coq (Metaprogramming Coq in the Elpi λProlog dialect). 2018. hal-01637063 HAL Id: hal-01637063 https://hal.inria.fr/hal-01637063 Preprint submitted on 17 Nov 2017 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. 1 Elpi: an extension language for Coq 61 2 62 3 Metaprogramming Coq in the Elpi λProlog dialect 63 4 64 5 Enrico Tassi 65 6 66 Universitè Côte d’Azur, Inria 7 67 France 8 68 [email protected] 9 69 10 Abstract augment the program with hypothetical clauses (clauses about 70 11 Elpi is dialect of λProlog that can be used as an extension language fresh constants). 71 12 for Coq. It lets one define commands and tactics in a high level For example, to the query “which is the type of λxλy:x?”, writ- 72 13 programming language tailored to the manipulation of syntax trees ten of(lam x\lam y\ x) Ty, Elpi answers Ty = arr S1 (arr S2 S1) by 73 14 containing binders and existentially quantified meta variables. using the second clause twice. Operationally each time a clause is 74 15 used its variables (capital letters) are made fresh and the head is 75 16 Keywords Coq, λProlog, extension language, metaprogramming unified with the query. In our example the second clause’s head, 76 17 of(lam F1)(arr S1 T1), is unified with the query giving F1 = x\lam y\ x 77 18 78 1 Introduction and Ty = arr S1 T1. Then a fresh constant c1 is created by the pi op- 19 Extension languages are key to the development of software. From erator, and the program is augmented with the hypothetical clause 79 20 80 text editors to video games, high level extension languages con- (of c1 S1) by the => operator. The sub query is about (F1 c1), but 21 81 tribute to the success of software by letting users improve the soft- since F1 is a function such a term is equivalent to (lam y\ c1), i.e. 22 ware and adapt it to their needs. Coq is no exception: it comes with the body of the first lambda where the bound variable has been 82 23 83 an extension language for tactics called Ltac [1] that proved to replaced by c1. The second clause is used again: this time we have 24 84 be extremely useful, well beyond the “small automation” target a fresh c2, a new clause (of c2 S2) about it, T1 gets arr S2 T2 and 25 85 envisioned by its author. Despite its success Ltac has many limita- consequently Ty becomes arr S1 (arr S2 T2). Finally we perform the 26 86 tions: it can define only tactics, it has no data structures, its binding sub query (of c1 T2). At that stage there is no choice but to use the 27 87 discipline and evaluation order are unclear, etc...As a consequence (of c1 S1) hypothetical clause, and unification imposes T2 = S1, i.e. 28 alternative approaches to extend Coq (or similar systems) were the output type to coincide with the type of the first input. This 88 29 proposed in recent years [3, 4, 6]. yields Ty = arr S1 (arr S2 S1) 89 30 We present a Coq plugin embedding Elpi [2], a dialect of λProlog [5] 90 31 designed to be used as an extension language for software doing 2.1 A dialect of λProlog with constraints 91 32 symbolic computations on syntax trees containing binders and When a syntax tree is partial, i.e. it contains unassigned unifica- 92 33 existentially quantified meta variables (evars). tion variables, λProlog programs naturally perform search: the 93 34 Unlike most of the alternatives cited above Elpi departs from the generative semantics inherited from Prolog enumerates all possi- 94 35 idea of meta programming Coq in itself (i.e. in Gallina) in favor of ble instantiations until one that fits is found. Unfortunately this 95 36 a domain specific, higher level, language that hides to the program- is not (always) welcome when manipulating partial terms: To the 96 37 mer De Buijn indexes and most of the intricacies of evars. It also query of(lam x\ lam y\ F x y) Ty Elpi replies by finding an arbitrary 97 38 provides first class search with backtracking and means to control solution for F: 98 39 it (e.g. the cut operator). F = x\ y\ y Ty = arr S1 (arr S2 S2) 99 40 100 This solution is generated because the sub query (of( F c1 c2) T2) 41 101 2 Elpi finds a possible solution in the hypothetical clause (of c2 S2). 42 102 The interpreter for Elpi (that stands for Embeddable Lambda Prolog To avoid that, Elpi lets one declare that a predicate should never 43 103 Interpreter) is developed by C. Sacerdoti Coen and E. Tassi [2]. Its instantiate one of its arguments (morally an input) and turn a goal 44 104 aim is to provide a programming platform to study the so-called into a constraint when the input is flexible. 45 105 elaborator component of an interactive prover as Coq or Matita. It pred of i:term, o:ty. 46 106 implements a dialect of λProlog where not only the binders of the of(?? as F) T :- declare_constraint(of FT) on F. 47 107 meta language (as in HOAS), but also its unification variables, can 48 The query above now results in the following solution, that com- 108 be used to model the object language ones. 49 prises a (typing) constraint on F (the key of the constraint). 109 We present Elpi by escalating λProlog’s “hello world” example 50 Ty = arr S1 (arr S2 T2) of c1 S1, of c2 S2 ?- of( F c1 c2) T2 on F 110 (a type checker for λ!) to an elaborator manipulating open terms. 51 Constraints are resumed as soon as the key is assigned. If nat and 111 52 type arr ty -> ty -> ty.% the arrow type constructor bool are types, then the following query succeeds. 112 type lam (term -> term) -> term. type app term -> term -> term. 53 113 of(app FX) T :- of F (arr ST), of XS.% clause for app Ty = arr nat (arr bool bool), of(lam x\ lam y\ F x y) Ty, 54 of(lam F)(arr ST):- pi x\ ofx S => of( F x) T.% clause for lam not( F = a\b\a),% the resumed constraint makes this assignment fail 114 55 F = a\b\b% this one is accepted, since the type matches 115 Remark that there is no term constructor for variables: λProlog 56 Finally, Elpi also provides a language of rewriting rules (inspired 116 provides operators to introduce fresh constants (names) and to 57 from Constraint Handling Rules (CHR)) to manipulate the store of 117 58 CoqPL’18, January 13, 2018, Los Angeles, California, United States constraints (e.g. to keep the constraint store duplicate free). 118 59 2018. 119 60 1 120 CoqPL’18, January 13, 2018, Los Angeles, California, United States Enrico Tassi 121 3 HOAS for Gallina terms In the spirit of HOAS, Elpi encodes Coq’s evars as λProlog unifica- 181 122 For lack of space we omit the declaration of all Gallina’s term tion variables with a pending typing constraint on them. The proof 182 123 constructors. Instead we comment the HOAS description of addition construction state (evar_map in Coq’s slang) is hence modelled by 183 124 over natural numbers. the set of constraints. Whenever an evar e gets instantiated with 184 125 185 fix `add` 0 (prod `n` (indt "nat") _\ prod `m` (indt "nat") _\ indt "nat") a term t, the corresponding typing constraint is resumed making 126 add\ lam `n` (indt "nat") n\ lam `m` (indt "nat") m\ the assignment fail if the type of t does not match the type of the 186 127 matchn(lam `n` (indt "nat") _\ indt "nat") e. Constraint Handling Rules are used to keep the constraint set 187 128 [m, lam `p` (indt "nat") p\ app[indc "S", app [add, p, m]]] duplicate free: Every time two typing constraints are keyed on the 188 129 Global names are shortened for the sake of conciseness and are same evar, one of the them is turned into an immediate check for 189 130 between double quotes, like "nat", while pretty printing hints are be- compatibility (unification) of the two types. 190 131 tween single quotes such as `add`. Dummy λ-abstraction is written A tactic invocation on the goal on the left is translated to (roughly) 191 132 _\ (i.e. no variable name). The second argument of fix is the position the query on the right 192 133 of the decreasing argument. indt and indc respectively represent T : U pi t\ declt `T` U => 193 134 inductive types and their constructors. const "plus" represents the x := V : T pi x\ defx `x` V t => 194 135 global constant to which the entire term is associated.
Recommended publications
  • Why Untyped Nonground Metaprogramming Is Not (Much Of) a Problem
    NORTH- HOLLAND WHY UNTYPED NONGROUND METAPROGRAMMING IS NOT (MUCH OF) A PROBLEM BERN MARTENS* and DANNY DE SCHREYE+ D We study a semantics for untyped, vanilla metaprograms, using the non- ground representation for object level variables. We introduce the notion of language independence, which generalizes range restriction. We show that the vanilla metaprogram associated with a stratified normal oljjctct program is weakly stratified. For language independent, stratified normal object programs, we prove that there is a natural one-to-one correspon- dence between atoms p(tl, . , tr) in the perfect Herbrand model of t,he object program and solve(p(tl, , tT)) atoms in the weakly perfect Her\) and model of the associated vanilla metaprogram. Thus, for this class of programs, the weakly perfect, Herbrand model provides a sensible SC mantics for the metaprogram. We show that this result generalizes to nonlanguage independent programs in the context of an extended Hcr- brand semantics, designed to closely mirror the operational behavior of logic programs. Moreover, we also consider a number of interesting exterl- sions and/or variants of the basic vanilla metainterpreter. For instance. WC demonstrate how our approach provides a sensible semantics for a limit4 form of amalgamation. a “Partly supported by the Belgian National Fund for Scientific Research, partly by ESPRlT BRA COMPULOG II, Contract 6810, and partly by GOA “Non-Standard Applications of Ab- stract Interpretation,” Belgium. TResearch Associate of the Belgian National Fund for Scientific Research Address correspondence to Bern Martens and Danny De Schreye, Department of Computer Science, Katholieke Universiteit Leuven, Celestijnenlaan 200A. B-3001 Hevrrlee Belgium E-mail- {bern, dannyd}@cs.kuleuven.ac.be.
    [Show full text]
  • Practical Reflection and Metaprogramming for Dependent
    Practical Reflection and Metaprogramming for Dependent Types David Raymond Christiansen Advisor: Peter Sestoft Submitted: November 2, 2015 i Abstract Embedded domain-specific languages are special-purpose pro- gramming languages that are implemented within existing general- purpose programming languages. Dependent type systems allow strong invariants to be encoded in representations of domain-specific languages, but it can also make it difficult to program in these em- bedded languages. Interpreters and compilers must always take these invariants into account at each stage, and authors of embedded languages must work hard to relieve users of the burden of proving these properties. Idris is a dependently typed functional programming language whose semantics are given by elaboration to a core dependent type theory through a tactic language. This dissertation introduces elabo- rator reflection, in which the core operators of the elaborator are real- ized as a type of computations that are executed during the elab- oration process of Idris itself, along with a rich API for reflection. Elaborator reflection allows domain-specific languages to be imple- mented using the same elaboration technology as Idris itself, and it gives them additional means of interacting with native Idris code. It also allows Idris to be used as its own metalanguage, making it into a programmable programming language and allowing code re-use across all three stages: elaboration, type checking, and execution. Beyond elaborator reflection, other forms of compile-time reflec- tion have proven useful for embedded languages. This dissertation also describes error reflection, in which Idris code can rewrite DSL er- ror messages before presenting domain-specific messages to users, as well as a means for integrating quasiquotation into a tactic-based elaborator so that high-level syntax can be used for low-level reflected terms.
    [Show full text]
  • Metaprogramming with Julia
    Metaprogramming with Julia https://szufel.pl Programmers effort vs execution speed Octave R Python Matlab time, time, log scale - C JavaScript Java Go Julia C rozmiar kodu Sourcewego w KB Source: http://www.oceanographerschoice.com/2016/03/the-julia-language-is-the-way-of-the-future/ 2 Metaprogramming „Metaprogramming is a programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyze or transform other programs, and even modify itself while running.” (source: Wikipedia) julia> code = Meta.parse("x=5") :(x = 5) julia> dump(code) Expr head: Symbol = args: Array{Any}((2,)) 1: Symbol x 2: Int64 5 3 Metaprogramming (cont.) julia> code = Meta.parse("x=5") :(x = 5) julia> dump(code) Expr head: Symbol = args: Array{Any}((2,)) 1: Symbol x 2: Int64 5 julia> eval(code) 5 julia> x 5 4 Julia Compiler system not quite accurate picture... Source: https://www.researchgate.net/ publication/301876510_High- 5 level_GPU_programming_in_Julia Example 1. Select a field from an object function getValueOfA(x) return x.a end function getValueOf(x, name::String) return getproperty(x, Symbol(name)) end function getValueOf2(name::String) field = Symbol(name) code = quote (obj) -> obj.$field end return eval(code) end function getValueOf3(name::String) return eval(Meta.parse("obj -> obj.$name")) end 6 Let’s test using BenchmarkTools struct MyStruct a b end x = MyStruct(5,6) @btime getValueOfA($x) @btime getValueOf($x,"a") const getVal2 = getValueOf2("a") @btime
    [Show full text]
  • A Foundation for Trait-Based Metaprogramming
    A foundation for trait-based metaprogramming John Reppy Aaron Turon University of Chicago {jhr, adrassi}@cs.uchicago.edu Abstract We present a calculus, based on the Fisher-Reppy polymorphic Scharli¨ et al. introduced traits as reusable units of behavior inde- trait calculus [FR03], with support for trait privacy, hiding and deep pendent of the inheritance hierarchy. Despite their relative simplic- renaming of trait methods, and a more granular trait typing. Our ity, traits offer a surprisingly rich calculus. Trait calculi typically in- calculus is more expressive (it provides new forms of conflict- clude operations for resolving conflicts when composing two traits. resolution) and more flexible (it allows after-the-fact renaming) In the existing work on traits, these operations (method exclusion than the previous work. Traits provide a useful mechanism for shar- and aliasing) are shallow, i.e., they have no effect on the body of the ing code between otherwise unrelated classes. By adding deep re- other methods in the trait. In this paper, we present a new trait sys- naming, our trait calculus supports sharing code between methods. tem, based on the Fisher-Reppy trait calculus, that adds deep oper- For example, the JAVA notion of synchronized methods can im- ations (method hiding and renaming) to support conflict resolution. plemented as a trait in our system and can be applied to multiple The proposed operations are deep in the sense that they preserve methods in the same class to produce synchronized versions. We any existing connections between the affected method and the other term this new use of traits trait-based metaprogramming.
    [Show full text]
  • Metaprogramming in .NET by Kevin Hazzard Jason Bock
    S AMPLE CHAPTER in .NET Kevin Hazzard Jason Bock FOREWORD BY Rockford Lhotka MANNING Metaprogramming in .NET by Kevin Hazzard Jason Bock Chapter 1 Copyright 2013 Manning Publications brief contents PART 1DEMYSTIFYING METAPROGRAMMING ..............................1 1 ■ Metaprogramming concepts 3 2 ■ Exploring code and metadata with reflection 41 PART 2TECHNIQUES FOR GENERATING CODE ..........................63 3 ■ The Text Template Transformation Toolkit (T4) 65 4 ■ Generating code with the CodeDOM 101 5 ■ Generating code with Reflection.Emit 139 6 ■ Generating code with expressions 171 7 ■ Generating code with IL rewriting 199 PART 3LANGUAGES AND TOOLS ............................................221 8 ■ The Dynamic Language Runtime 223 9 ■ Languages and tools 267 10 ■ Managing the .NET Compiler 287 v Metaprogramming concepts In this chapter ■ Defining metaprogramming ■ Exploring examples of metaprogramming The basic principles of object-oriented programming (OOP) are understood by most software developers these days. For example, you probably understand how encapsulation and implementation-hiding can increase the cohesion of classes. Languages like C# and Visual Basic are excellent for creating so-called coarsely grained types because they expose simple features for grouping and hiding both code and data. You can use cohesive types to raise the abstraction level across a system, which allows for loose coupling to occur. Systems that enjoy loose cou- pling at the top level are much easier to maintain because each subsystem isn’t as dependent on the others as they could be in a poor design. Those benefits are realized at the lower levels, too, typically through lowered complexity and greater reusability of classes. In figure 1.1, which of the two systems depicted would likely be easier to modify? Without knowing what the gray circles represent, most developers would pick the diagram on the right as the better one.
    [Show full text]
  • A Fast, Verified, Cross-Platform Cryptographic Provider
    EverCrypt: A Fast, Verified, Cross-Platform Cryptographic Provider Jonathan Protzenko∗, Bryan Parnoz, Aymeric Fromherzz, Chris Hawblitzel∗, Marina Polubelovay, Karthikeyan Bhargavany Benjamin Beurdouchey, Joonwon Choi∗x, Antoine Delignat-Lavaud∗,Cedric´ Fournet∗, Natalia Kulatovay, Tahina Ramananandro∗, Aseem Rastogi∗, Nikhil Swamy∗, Christoph M. Wintersteiger∗, Santiago Zanella-Beguelin∗ ∗Microsoft Research zCarnegie Mellon University yInria xMIT Abstract—We present EverCrypt: a comprehensive collection prone (due in part to Intel and AMD reporting CPU features of verified, high-performance cryptographic functionalities avail- inconsistently [78]), with various cryptographic providers able via a carefully designed API. The API provably supports invoking illegal instructions on specific platforms [74], leading agility (choosing between multiple algorithms for the same functionality) and multiplexing (choosing between multiple im- to killed processes and even crashing kernels. plementations of the same algorithm). Through abstraction and Since a cryptographic provider is the linchpin of most zero-cost generic programming, we show how agility can simplify security-sensitive applications, its correctness and security are verification without sacrificing performance, and we demonstrate crucial. However, for most applications (e.g., TLS, cryptocur- how C and assembly can be composed and verified against rencies, or disk encryption), the provider is also on the critical shared specifications. We substantiate the effectiveness of these techniques with
    [Show full text]
  • Specialising Dynamic Techniques for Implementing the Ruby Programming Language
    SPECIALISING DYNAMIC TECHNIQUES FOR IMPLEMENTING THE RUBY PROGRAMMING LANGUAGE A thesis submitted to the University of Manchester for the degree of Doctor of Philosophy in the Faculty of Engineering and Physical Sciences 2015 By Chris Seaton School of Computer Science This published copy of the thesis contains a couple of minor typographical corrections from the version deposited in the University of Manchester Library. [email protected] chrisseaton.com/phd 2 Contents List of Listings7 List of Tables9 List of Figures 11 Abstract 15 Declaration 17 Copyright 19 Acknowledgements 21 1 Introduction 23 1.1 Dynamic Programming Languages.................. 23 1.2 Idiomatic Ruby............................ 25 1.3 Research Questions.......................... 27 1.4 Implementation Work......................... 27 1.5 Contributions............................. 28 1.6 Publications.............................. 29 1.7 Thesis Structure............................ 31 2 Characteristics of Dynamic Languages 35 2.1 Ruby.................................. 35 2.2 Ruby on Rails............................. 36 2.3 Case Study: Idiomatic Ruby..................... 37 2.4 Summary............................... 49 3 3 Implementation of Dynamic Languages 51 3.1 Foundational Techniques....................... 51 3.2 Applied Techniques.......................... 59 3.3 Implementations of Ruby....................... 65 3.4 Parallelism and Concurrency..................... 72 3.5 Summary............................... 73 4 Evaluation Methodology 75 4.1 Evaluation Philosophy
    [Show full text]
  • An Overview of Feature-Oriented Software Development
    Vol. 8, No. 4, July{August 2009 An Overview of Feature-Oriented Software Development Sven Apel, Department of Informatics and Mathematics, University of Passau, Germany Christian K¨astner, School of Computer Science, University of Magdeburg, Germany Feature-oriented software development (FOSD) is a paradigm for the construction, customization, and synthesis of large-scale software systems. In this survey, we give an overview and a personal perspective on the roots of FOSD, connections to other software development paradigms, and recent developments in this field. Our aim is to point to connections between different lines of research and to identify open issues. 1 INTRODUCTION Feature-oriented software development (FOSD) is a paradigm for the construction, customization, and synthesis of large-scale software systems. The concept of a fea- ture is at the heart of FOSD. A feature is a unit of functionality of a software system that satisfies a requirement, represents a design decision, and provides a potential configuration option. The basic idea of FOSD is to decompose a software system in terms of the features it provides. The goal of the decomposition is to construct well-structured software that can be tailored to the needs of the user and the appli- cation scenario. Typically, from a set of features, many different software systems can be generated that share common features and differ in other features. The set of software systems generated from a set of features is also called a software product line [45,101]. FOSD aims essentially at three properties: structure, reuse, and variation. De- velopers use the concept of a feature to structure design and code of a software system, features are the primary units of reuse in FOSD, and the variants of a software system vary in the features they provide.
    [Show full text]
  • Python 3 Metaprogramming Requirements
    Python 3 Metaprogramming David Beazley @dabeaz http://www.dabeaz.com Presented at PyCon'2013, Santa Clara, CA March 14, 2013 Copyright (C) 2013, http://www.dabeaz.com 1 Requirements • Python 3.3 or more recent • Don't even attempt on any earlier version • Support files: http://www.dabeaz.com/py3meta Copyright (C) 2013, http://www.dabeaz.com 2 Welcome! • An advanced tutorial on two topics • Python 3 • Metaprogramming • Honestly, can you have too much of either? • No! Copyright (C) 2013, http://www.dabeaz.com 3 Metaprogramming • In a nutshell: code that manipulates code • Common examples: • Decorators • Metaclasses • Descriptors • Essentially, it's doing things with code Copyright (C) 2013, http://www.dabeaz.com 4 Why Would You Care? • Extensively used in frameworks and libraries • Better understanding of how Python works • It's fun • It solves a practical problem Copyright (C) 2013, http://www.dabeaz.com 5 DRY Copyright (C) 2013, http://www.dabeaz.com 6 DRY Don't Repeat Yourself Copyright (C) 2013, http://www.dabeaz.com 7 DRY Don't Repeat Yourself Don't Repeat Yourself Copyright (C) 2013, http://www.dabeaz.com 8 Don't Repeat Yourself • Highly repetitive code sucks • Tedious to write • Hard to read • Difficult to modify Copyright (C) 2013, http://www.dabeaz.com 9 This Tutorial • A modern journey of metaprogramming • Highlight unique aspects of Python 3 • Explode your brain Copyright (C) 2013, http://www.dabeaz.com 10 Target Audience • Framework/library builders • Anyone who wants to know how things work • Programmers wishing to increase "job security" Copyright (C) 2013, http://www.dabeaz.com 11 Reading • Tutorial loosely based on content in "Python Cookbook, 3rd Ed." • Published May, 2013 • You'll find even more information in the book Copyright (C) 2013, http://www.dabeaz.com 12 Preliminaries Copyright (C) 2013, http://www.dabeaz.com 13 Basic Building Blocks statement1 def func(args): statement2 statement1 statement3 statement2 ..
    [Show full text]
  • Optimizing a Bank of Kalman Filters for Navigation Integrity
    Air Force Institute of Technology AFIT Scholar Theses and Dissertations Student Graduate Works 3-2021 Optimizing a Bank of Kalman Filters for Navigation Integrity Luis E. Sepulveda Follow this and additional works at: https://scholar.afit.edu/etd Part of the Computer Sciences Commons, and the Navigation, Guidance, Control and Dynamics Commons Recommended Citation Sepulveda, Luis E., "Optimizing a Bank of Kalman Filters for Navigation Integrity" (2021). Theses and Dissertations. 4908. https://scholar.afit.edu/etd/4908 This Thesis is brought to you for free and open access by the Student Graduate Works at AFIT Scholar. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of AFIT Scholar. For more information, please contact [email protected]. Optimizing Banks of Kalman Filters for Navigation Integrity using Parallel Computing and Efficient Software Design THESIS Luis E. Sepulveda, Captain, USAF AFIT-ENG-MS-21-M-079 DEPARTMENT OF THE AIR FORCE AIR UNIVERSITY AIR FORCE INSTITUTE OF TECHNOLOGY Wright-Patterson Air Force Base, Ohio DISTRIBUTION STATEMENT A APPROVED FOR PUBLIC RELEASE; DISTRIBUTION UNLIMITED. The views expressed in this document are those of the author and do not reflect the official policy or position of the United States Air Force, the United States Department of Defense or the United States Government. This material is declared a work of the U.S. Government and is not subject to copyright protection in the United States. AFIT-ENG-MS-21-M-079 OPTIMIZING BANKS OF KALMAN FILTERS FOR NAVIGATION INTEGRITY USING PARALLEL COMPUTING AND EFFICIENT SOFTWARE DESIGN THESIS Presented to the Faculty Department of Electrical and Computer Engineering Graduate School of Engineering and Management Air Force Institute of Technology Air University Air Education and Training Command in Partial Fulfillment of the Requirements for the Degree of Master of Science in Computer Science Luis E.
    [Show full text]
  • Type-Safe Polyvariadic Event Correlation 3
    Type-safe Polyvariadic Event Correlation OLIVER BRAČEVAC, TU Darmstadt, Germany GUIDO SALVANESCHI, TU Darmstadt, Germany SEBASTIAN ERDWEG, Johannes Gutenberg University Mainz, Germany MIRA MEZINI, TU Darmstadt, Germany The pivotal role that event correlation technology plays in todays applications has lead to the emergence of different families of event correlation approaches with a multitude of specialized correlation semantics, including computation models that support the composition and extension of different semantics. However, type-safe embeddings of extensible and composable event patterns into statically-typed general- purpose programming languages have not been systematically explored so far. This is unfortunate, as type- safe embedding of event patterns is important to enable increased correctness of event correlation computa- tions as well as domain-specific optimizations. Event correlation technology has often adopted well-known and intuitive notations from database queries, for which approaches to type-safe embedding do exist. How- ever, we argue in the paper that these approaches, which are essentially descendants of the work on monadic comprehensions, are not well-suited for event correlations and, thus, cannot without further ado be reused/re- purposed for embedding event patterns. To close this gap we propose PolyJoin, a novel approach to type-safe embedding for fully polyvariadic event patterns with polymorphic correlation semantics. Our approach is based on a tagless final encoding with uncurried higher-order abstract syntax (HOAS) representation of event patterns with n variables, for arbitrary n ∈ N. Thus, our embedding is defined in terms of the host language without code generation and exploits the host language type system to model and type check the type system of the pattern language.
    [Show full text]
  • Compile-Time Reflection and Metaprogramming for Java
    Compile-time Reflection and Metaprogramming for Java Weiyu Miao Jeremy Siek University of Colorado at Boulder {weiyu.miao, jeremy.siek}@colorado.edu Abstract we also likely need to change the hasGetters for that class, therefore Java reflection enables us to write reusable programs that are inde- such implementation is not adaptable to the change of a class. pendent of certain classes. However, when runtime performance is With runtime reflection, we can write a hasGetters that is appli- a big concern, we propose to use compile-time reflection for writ- cable to any class. Following shows the partial implementation of ing metaprograms that generate non-reflective class/type specific the hasGetters. code, which has lower runtime cost. 1 public boolean hasGetters(Class cls) { We proposed both compile-time reflection and metaprogram- 2 Field[] fds = cls.getFields(); ming for Java, and extended our previous work on pattern-based 3 for(int i=0;i < fds.length; ++i) { traits. Pattern-based traits integrate pattern-based reflection with 4 Field fd = fds[i]; flexible composition of traits. They are capable of pattern-matching 5 String mn = ”get”+capitalize(fd.getName()); over class members and generating expressive code. We add and 6 Class fTy = fd.getType(); formalize pattern-based reflection at the statement-level, which 7 try { enables a meta program to generate statements. We add reified 8 Method m = cls.getMethod(mn, new Class[0]); 9 if (! m.getReturnType().equals(fTy)) { generics for pattern-based traits, which enables a pattern to iter- 10 ... /∗ print the message that field fd has no getter ∗/ ate over any class when traits are instantiated.
    [Show full text]