• Nenhum resultado encontrado

Object-Oriented Mechanisms for Interoperability Between Proof Systems

N/A
N/A
Protected

Academic year: 2023

Share "Object-Oriented Mechanisms for Interoperability Between Proof Systems"

Copied!
321
0
0

Texto

But the real explosion in the number of logic systems comes from the development of computer science. Deduction modulo [69] is about generalizing this distinction between logical reasoning and computation in the context of automated evidence search for first-order logic.

First-Order Logic

Syntax

In first-order terms, all variables are free, hence the notation FV(t) for the set of all variables occurring in the term. The set of axioms can be infinite, but it is required to be computable (ie, we can always decide whether a given formula is an axiom or not).

A Proof System for First-Order Logic: Natural Deduction

Natural deduction is a constructive system of proof; to obtain a classical system equivalent to the calculations implemented in classical first-order theorem provers, we need to add an axiom scheme like the Law of Excluded Means: for all closed formulas φ, the formula φ∨ ¬φ is an axiom.

Figure 1.1: Natural Deduction
Figure 1.1: Natural Deduction

Polymorphic First-Order Logic

For example, integers must be represented by a constant type, and the type of polymorphic lists is introduced with a unary type symbol. Also, to avoid ambiguity, the type of quantified variables is attached to the quantifier, so we write.

Term Rewriting

In general, not all expressions are normalized, and normal forms, if they exist, are not unique. If for all terms t1, t2, and t3 such that t1 reduces to t2 and t3, there exists a term t4 such that both t2 and t3 reduce tot4, we say that Ris is conuent.

Deduction Modulo

Presentation

In this section, we do not attempt to give an exhaustive presentation of the discount module, but only highlight some results that are relevant to our concerns. How axioms are chosen to be replaced by rewriting rules is beyond the scope of this thesis.

Extending First-Order Logic

These two approaches are equivalent [69], the first is preferred when studying the connection between the deduction module and the type theory, the second is closer to the implementation of the proofs of the theorem for the deduction module.

Termination and Consistency

Zenon Modulo

In the particular case of the λ calculus at the heart of the functional languages, many types of systems have been studied. In the context of the λ calculus, the renaming operation is called α-renaming, α-conversion, or α-equivalence.

Simple Types

We write x∈Γ, to denote that x is declared in Γ, and (x:τ)∈Γ, to denote that the declaration x:τ is present in Γ.

Figure 2.1: Typing rules for simply-typed λ-calculus
Figure 2.1: Typing rules for simply-typed λ-calculus

Polymorphism

Damas-Hindley-Milner Type System

To write the types of the identity function and of the composition of functions, we add type variables denoted by α. 1We use the notationΠfor prenex quantification instead of the more common notation∀to avoid confusion with the logical universal quantifier.

Figure 2.2: Damas-Hindley-Milner type system
Figure 2.2: Damas-Hindley-Milner type system

HOL

As in the simply-typed case, this result is constructive in the sense that when such a type τ exists, it can actually be computed from Γ ent. If we want to work in an intuitionistic higher-order logic, we can take the universal quantifier and the implication as primitives instead of equality and the choice operator.

Dependent Types

Martin-Löf Type Theory

The disjoint sum A+B contains terms of the form inl(a) where a lives in A and terms of the form inr(b) where b lives in B. Now in type theory we must internalize the principle that all inhabitants of A+ B have one of the following forms: inl(a) or inr(b).

Curry-Howard Correspondence for Natural Deduction

A derivation of a domΓ⊢φ can then be translated as a type derivation of some expression, such that JΓK⊢t:JφK.

The Calculus of Inductive Constructions

Logical Frameworks

  • Representing Binding
  • Edinburgh Logical Framework
  • Martin-Löf's Logical Framework
  • Internal vs. External Conversion
  • Proposition-as-Type vs. Judgment-as-Type

2 Other representations of relation such as distinct names and De Bruijn indices are possible, but we do not present them because logical frameworks provide no more support for them than first-order logic. The LP-calculus is a λ Barendregt cube system [22] and thus can be represented as a pure-type system [23], this is the representation we use because it is very concise. In this thesis, we are only interested in the higher-order rewriting systems corresponding to the rewriting systems of the calculus module λΠ.

Figure 2.4: The λΠ-calculus
Figure 2.4: The λΠ-calculus

The λΠ -Calculus Modulo

In [155] Saillard showed that if the coherence of the relation βΓ (on untyped terms) is assumed, the λΠ calculus modulo enjoys the subject reduction property. If the ratioβΓ is also finite (on well-typed terms), then ≡βΓ and type are determinable, so under these assumptions theλΠ-calculus can be implemented modulo.

Figure 3.1: The λΠ -calculus modulo
Figure 3.1: The λΠ -calculus modulo

Dedukti

Syntax

Denitions are a special case of rewriting rules for which a specific syntax is available such as the syntactic sugar shown in Figure 3.3: def f (x1 : A1). xn : An) : A := a., where f is a symbol, xi are variables, and A, Ai, and a are terms, declares the denable symbol f and defines it as a in which the xi are abstracted λ. .

Figure 3.2: Correspondance between Dedukti syntax and the λΠ -calculus modulo
Figure 3.2: Correspondance between Dedukti syntax and the λΠ -calculus modulo

Commands

Conuence Checking

Proving and Programming in Dedukti

  • Smart Constructors
  • Partial Functions
  • Encoding Polymorphism
  • Overfull Denitions
  • Meta-Programming

Usually in type theory (for example in the calculus of inductive constructions, in Martin-Löf type theory or in NuPRL), symbols can be classified into: constructors, type constructors, functions and axioms. Polymorphism is the ability to deny functions that operate on several types; two types of polymorphism can be distinguished, parametric polymorphism and ad-hoc polymorphism.

Translating Logical Systems in Dedukti

First-Order Logic in Dedukti

So far we have faithfully represented the syntax of natural deduction in Dedukti using the judgment-as-type paradigm (see section 2.5.5). Using these rewriting rules, all deduction rules for natural deduction can be derived (see Figure 3.5).

Figure 3.4: Dedukti signature for polymorphic natural deduction
Figure 3.4: Dedukti signature for polymorphic natural deduction

Coqine

The deduct les produced by Coqine depends on a small handwritten Deduct le coq.dk representing the CIC. Le coq.dk also contains declarations and rewrite rules to support some features of CIC.

Holide

Breaking in Deductio is optional and is a good experimental platform for coding object-oriented languages. The simply-typed ς-calculus is similar to the simply-typed λ-calculus we introduced in Section 2.2, but it is used as the core calculus for object-oriented languages ​​instead of functional languages.

Syntax

In this chapter, we first recall its definition in Section 4.1, then embed it into Dedukti in two steps. We conclude this section with small examples of encodings of programming constructs in the ς-calculus.

Typing

Selecting a method returns an expression of the expected type, and updating an expression with a well-typed method returns an expression of the same type.

Operational Semantics

Examples

Translation of Types in Dedukti

Moreover, to ensure the uniqueness of labels, we must break the symmetry and arbitrarily choose one of the associated types. Furthermore, the type ς and its translation have the same size, so A and B have the same size.

Membership as an Inductive Relation

Terminating Translation of Terms

  • Objects, Methods, and Preobjects
  • Method Selection and Update
  • Translation Function for Terms
  • Typing Preservation

The method denoted by l from A to B can be added to a preobject of type A defined on part C to form a preobject of type A defined on part tconsl B C. The translation of the derivation of the typing ∆⊢ a:A is a well-typed expression Deducts JaK of type Obj JAK in any context that extends J∆K with tag declarations appearing in JAK.

Shallow Embedding

By denition, Ja.lj ⇐ς(x:A)bK=objupdateJAKlj JAjK p Jς(x:A)bK JaKhvorp is the position of(lj :Aj) inA. To finish this case, we show by reducing induction onk≤j that preupdateJAKlj JAjK J[li:Ai]i=k..nKpk Jς(x:A)bKαk−→+αk′, where pk is the position of(lj :Aj) in[li:Ai]i=k..n,.

Example

Translation of the Subtyping Relation

Explicit Coercions

The functions objselect and objupdate are defined only on objects of the form pcon. They extend the select and update functions by handling the case of the smart constructor force. The translation of type derivations in section 4.4.3 has been adapted to subtyping by replacing objselect and objupdate with select and update, respectively, and the case of the type rule (subsume) is given by coercion:.

Reverse Translation

If a member of a λΠ-calculus modulo type ObjA is in contextΓ such that ψ is defined on AinΓandφis dened on, then ψ(Γ)⊢φ(t) :ψ(A) is in a ς-calculus with subtype. By induction on the structure of term t, each case corresponds to a different typing rule in the ς-calculus with subtyping.

Canonicity

These improvements in the translation do not affect the semantics of the translated terms, but only their syntax. The second improvement, described in Section 6.2, is the removal from the translation of the position arguments needed for the select and update functions.

Initiating Objects

Decidability

We don't show the proofs because they are quite long and not very interesting. The point of using the reaction technique is that we can do the math with the evidence.

Eciency

Optimization at the Meta-Level

Types

The FoCaLiZe type system is very similar to the Damas and Milner type system (see section 2.3.1). The FoCaLiZe type system includes a few simple basic types and can be extended with user-defined algebraic data types.

Expressions

Finally, terms can be inspected by pattern matching and the usual if then else conditional. Moreover, anonymous functions and recursive functions can be introduced respectively by theλ and µbinders (µis not actually part of FoCaLiZe concrete syntax, but it is convenient to deny the semantics of recursive denitions).

Figure 7.5: Typing rules for FoCaLiZe constants and patterns
Figure 7.5: Typing rules for FoCaLiZe constants and patterns

Logical Language: FOL

Formulae

To express the well-written formulas, we introduce a new compression judgment Γ⊢φprop depicted in Figure 7.10.

Proofs

We can now define the evidence control relationship; the relation Σ⊢π :φ means that π is a valid proof of the formula φin contextΣ. It is interdefined in Figure 7.13 with the relation Σ⊢s, which means that this is a valid proof step in context Σ.

Figure 7.11: Syntax of FoCaLiZe proofs
Figure 7.11: Syntax of FoCaLiZe proofs

Object-Oriented Mechanisms

  • Species
  • Methods
  • Inheritance
  • Undened methods
  • Redenition
  • Collections
  • Parameters

An undefined calculation method can be introduced by the keyword signature and an undefined logical method can be introduced by the keyword property; undone in this case means that the logical method has no proof yet. All the methods of species OppZeroPlusAbelian are covered (we say that OppZeroPlusAbelian is a complete species) and the proof of zero_uniq does not depend on the choice of the type for the representation and can be used in any abelian group.

Figure 7.14: Inheritance Hierarchy
Figure 7.14: Inheritance Hierarchy

Compilation

  • Compilation Passes
  • Lifting and Dependency Calculus
  • Backend Input Language
  • Compilation of Proofs to Coq
  • Lifting of Pattern Matchings
  • Serialization
  • Compiling Patterns to Destructors
  • Destructors in Dedukti

The interesting part of computer language translation is the translation of pattern matching and recursion. To avoid useless duplication of the matching expression, it is first factorized using a let binding.

Figure 7.15: FoCaLiZe Compilation Scheme
Figure 7.15: FoCaLiZe Compilation Scheme

Recursive Functions

  • Examples
  • Naive Translation
  • Call-by-Value Application Combinator
  • Local Recursion
  • Termination
  • Eciency and Limitations

In the case of Function, the user can prove the termination of the function in FoCaLiZe using Zenon [71]. For negative values, the behavior of the factorial function is not important; we arbitrarily choose to give the value 1.

Figure 8.3: Constructor-based equality of lists
Figure 8.3: Constructor-based equality of lists

Related Work

However, it does not seem possible to negate a single fix symbol without breaking strong normalization of the rewriting system, so, as in our work, each x-point must be labeled and recursive unfolding must be restricted to expressions that use a constructor start. Pattern matching is a common feature in these languages, so proving the correctness of a compiler for a functional language usually requires dening a translation function from pattern matching to λ calculus.

The FoCaLiZe Extension

The Induction Extension

Higher-Order Right-Hand Sides

Mixing Coq and HOL Logics

Type Inhabitation

Booleans and Propositions

Case Study: Sorting Coq Lists of HOL Numbers

Limitations

Programming the Sieve of Eratosthenes in Coq

Specication

Correctness proof

Relating FoCaLiZe Logic with Coq and HOL

FoCaLiZe as a User Interface to HOL

Specifying Arithmetic as a FoCaLiZe Hierarchy of Species

Abstract arithmetic structures

Morphisms Between Representations

Instantiation of Coq Natural Numbers

Instantiation of HOL Natural Numbers

Instantiation of the Morphism

Discussion

A Rewrite System for the Law of Excluded Middle

A Rewrite System for the Law of Double Negation

Inspecting the Proof

Two Trivial Special Cases

Eliminating Negation Proofs

Exchanging Elimination Rules

Conuence

Combining Rewrite Systems

Experimental Results

B Proof Obligations

FoCaLiZe Standard Library

Related Work

Double-Negation Translations

Intuitionistic Provers

Zenonide

Imagem

Figure 1.1: Natural Deduction
Figure 2.1: Typing rules for simply-typed λ-calculus
Figure 2.2: Damas-Hindley-Milner type system
Figure 2.3: Typing rules for disjoint sums in MLTT
+7

Referências

Documentos relacionados

When developing a simulation, the method is chosen depending on the structure of the system and the objectives of the simulation [63]. It can be extremely time consuming