1
Rapid Prototyping Formal Systems in MMT: 5 Case Studies
Dennis M¨ uller and Florian Rabe
Computer Science, University Erlangen-N¨ urnberg, Germany LRI, University Paris-Sud, France
Rapid Prototyping Formal Systems in MMT: 5 Case Studies Dennis M - - PowerPoint PPT Presentation
1 Rapid Prototyping Formal Systems in MMT: 5 Case Studies Dennis M uller and Florian Rabe Computer Science, University Erlangen-N urnberg, Germany LRI, University Paris-Sud, France June 2019 Motivation 2 Motivation Motivation 3
Computer Science, University Erlangen-N¨ urnberg, Germany LRI, University Paris-Sud, France
◮ Universal concepts
◮ Meta-reasoning
◮ Rapid prototyping
◮ Generic tools
◮ Meta-logic must be simple to be scalable, trustworthy ◮ Object logic must be expressive to be practical ◮ Big challenge for frameworks
◮ choose a λ-calculus ◮ add other features
◮ logic programming (λ-Prolog) ◮ meta logic (Twelf, Abella) ◮ proof assistant for object logic (Isabelle) ◮ concurrency (CLF) ◮ reasoning about contexts (Beluga) ◮ rewriting (Dedukti) ◮ external side conditions (LLFP) ◮ coupling with proof-assistant support (Hybrid) ◮ user-defined unification hints (ELPI) ◮ . . .
◮ Divergence due to choice of other features ◮ Even hypothetical union not expressive enough for real-life logics
◮ increasingly complex problem domains
◮ plain formalization introduces too many artifacts to be
◮ therefore: allow users to define how to interpret human input
◮ unification hints (Coq, Matita)
◮ extra-logical declarations ◮ allow users to guide incomplete algorithms (e.g., unification)
◮ meta-programming (Idris, Lean)
◮ expose internal datatypes to user ◮ allow users to program extensions in the language itself
◮ logical frameworks not expressive for practical logics ◮ more system experimentation needed ◮ trend towards fine-grained user control
◮ DFG project 2009-2012 (with DFKI Bremen and Jacobs Univ.) ◮ Highly modular network of little logic formalizations
◮ separate theory for each ◮ connective/quantifier ◮ type operator ◮ controversial axioms
◮ base type ◮ reference catalog of standardized logics ◮ documentation platform
◮ Written in MMT/LF ◮ 4 years, with ∼ 10 students, ∼ 1000 modules
◮ nodes: MMT/LF theories ◮ edges: MMT/LF theory morphisms
◮ each node is root for library of that logic ◮ each edge yields library translation functor
◮ DFG project, 2014–2020, 15 contributors ◮ Big, overlapping libraries joined in MMT as the uniform
◮ enables archival, comparison, integration
◮ EU project, 2015-2019, 15 sites, 25 partners
◮ MMT as mediator system
◮ system-independent formalization of math
◮ integration of math computation systems
◮ . . . and math databases
◮ SageMath user needs 13th transitive group with conductor 5 ◮ SageMath queries MMT ◮ MMT retrieves it from LMFDB, translates it to SageMath syntax
◮ 251 Repositories ◮ 187 Users ◮ 28.5 GB
◮ few orthogonal concepts ◮ uniform representations of diverse languages
◮ theory = named set of declarations
◮ foundations, logics, type theories, classes, specifications, . . .
◮ theory morphism = compositional translation
◮ inclusions, translations, models, katamorphisms, . . .
◮ constant = named atomic declaration
◮ function symbols, theorems, rules, . . . ◮ may have type, definition, notation
◮ term = unnamed complex entity, formed from constants
◮ expressions, types, formulas, proofs, . . .
◮ typing ⊢T s : t between terms relative to a theory
◮ well-formedness, truth, consequence . . .
◮ no predefined constants ◮ single general syntax tree constructor c(Γ;
◮ c(Γ;
◮ non-binding operators: Γ empty
◮ typical binders: Γ and
◮ Theories may attach notation(s) to each constant declaration ◮ Notations of c introduce concrete syntax for c(Γ;
◮ MMT terms subsume terms of specific languages ◮ Type systems singles out the well-typed terms
◮ MMT defines some global rules once and for all
◮ declared in MMT theories, subject to scoping
◮ Lookup rules for atomic terms over a theory T = {Σ}
◮ Equivalence and congruence rules for equality ◮ Rules for well-formed theories/contexts
◮ Declared in theories as constants ◮ Carry reference to self-contained Scala object implementing a
◮ simplification: Γ ⊢T E =? ◮ equality checking: Γ ⊢T E = E ′ ? ◮ type inference: Γ ⊢T t :? ◮ type checking: Γ ⊢T t : A ? ◮ proving: Γ ⊢T ? : A
◮ applicable to Γ ⊢T t :? whenever t = λx : A.s ◮ recursively infers type of s, returns Π-type ◮ reports errors and trace messages
◮ API for representation language
◮ Collection of reusable algorithms
◮ Extensible wherever reasonable
◮ Foundation developers
◮ Service developers
◮ Application developers
◮ API for representation language
◮ Collection of reusable algorithms
◮ Extensible wherever reasonable
◮ Foundation developers
◮ Service developers
◮ Application developers
◮ Module system
◮ Concrete/abstract syntax
◮ Interpreted symbols, literals
◮ Type reconstruction
◮ Simplification
◮ Theorem proving? ◮ Code generation? Computation?
◮ Change management
◮ Project management
◮ Extensible export infrastructure
◮ Search, querying
◮ Browser
◮ Editing
◮ MMT implements foundation-independent rules ◮ visible foundation-specific rules collected from current context ◮ algorithm delegates to foundation-specific rules as needed
◮ unknown meta-variables ◮ delaying constraints ◮ definition expansion ◮ module system
◮ Key idea: annotate
◮ a binary judgment as a rewrite predicate ◮ axioms for that judgment as rewrite rules
◮ Implement MMT plugin that dynamically generates new
◮ implemented via Change Listener interface ◮ Termination of rewrite system remain user’s responsibility
◮ Needed work: a few 100 hundred loc for the rule generator
◮ Special expressions that represent keys
◮ normal MMT expressions ◮ but not part of the type system
◮ New rules for keys that run external side condition ◮ Variables typed by keys indicate which locks can be opened
◮ declared wheneve traversing into the monad ◮ automatically ignored by all other typing rules
◮ Add new rules for lock types that look for keys in the context
◮ if found, monad can be inspected ◮ otherwise, discharge external side condition by calling rule for
◮ Needed work: ∼ 100 loc for 7 rules
◮ Already done in LF
◮ Kripke style model, worlds represent available resources ◮ monoid of worlds to represent empty world, union ◮ additional laws represent structural rules
◮ Problem in LF: requires explicit reasoning in the monoid
◮ Solution: add new rules for equality reasoning ◮ Needed work: depends on desired reasoning strength, < 100
◮ MMT: foundation-independent framework for declarative
◮ representation language ◮ implementation
◮ Easy to instantiate with specific foundations
◮ Deep foundation-independent results
◮ logical: parsing, type reconstruction, module system, . . . ◮ knowledge management: search, browsers, IDE, . . .
◮ Serious contender for
◮ experimenting with new system ideas ◮ generic applications/services ◮ universal library ◮ system integration platform
◮ Inspired by programming language IDEs ◮ Components
◮ jEdit text editor (in Java): graphical interface ◮ MMT API (in Scala) ◮ jEdit plugin to tie them together
◮ Features
◮ outline view ◮ error list ◮ display of inferred information ◮ type inference of subterms ◮ hyperlinks: jump to definition ◮ search interface ◮ context-sensitive auto-completion: show identifiers that
◮ MMT content presented as HTML5+MathML pages ◮ Dynamic page updates via Ajax ◮ MMT used through HTTP interface with JavaScript wrapper ◮ Features
◮ interactive display
◮ smart navigation via MMT ontology
◮ dynamic computation of content
◮ graph view: theory diagram as SVG
◮ upper part: L AT
◮ lower part: pdf after compiling with L AT
◮ enriched with type inference, cross references, tooltips