Normalization by Completeness with Heyting Algebras Gaëtan Gilbert, Olivier Hermant
Total Page:16
File Type:pdf, Size:1020Kb
Normalization by Completeness with Heyting Algebras Gaëtan Gilbert, Olivier Hermant To cite this version: Gaëtan Gilbert, Olivier Hermant. Normalization by Completeness with Heyting Algebras. LPAR 20 : 20th International Conference on Logic for Programming, Artificial Intelligence and Reasoning, Nov 2015, Suva, Fiji. hal-01204599 HAL Id: hal-01204599 https://hal-mines-paristech.archives-ouvertes.fr/hal-01204599 Submitted on 24 Sep 2015 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. Normalisation by Completeness with Heyting Algebras Gaëtan Gilbert12 and Olivier Hermant34 1 ENS Lyon, France [email protected] 2 Inria Paris, France 3 MINES ParisTech, PSL Research University, France 4 Wesleyan University, Middletown, CT, USA [email protected] Abstract. Usual normalization by evaluation techniques have a strong relationship with completeness with respect to Kripke structures. But Kripke structures is not the only semantics that ts intuitionistic logic: Heyting algebras are a more algebraic alternative. In this paper, we focus on this less investigated area: how completeness with respect to Heyting algebras generate a normalization algorithm for a natural deduction calculus, in the propositional fragment. Our main contributions is that we prove in a direct way completeness of natural deduction with respect to Heyting algebras, that the underlying algo- rithm natively deals with disjunction, that we formalized those proofs in Coq, and give an extracted algorithm. 1 Introduction In logic, a restriction to cut-free proofs makes analysis of a theory and proof-search signicantly simpler. Evaluating programs boils down to nd- ing ecient ways to reach a normal form, in order to produce a result. Through the proof-as-programs paradigms, those two processes can be reduced to a single one: reduction steps of lambda-terms, such as β reduction, can be seen as a way to remove cuts from proofs expressed in natural deduction. Under this correspondence, a proof is cut-free when the associated proof-term is in normal form. But there exist other, semantic, ways to eliminate cuts from proofs [15], through a completeness theorem that produces cut-free proofs, hereafter strong completeness, in combination with soundness. When those proofs can be made constructive [17,10,3], a natural question arises: what is the computational content of such proofs ? A link has already been exhibited. A line of research in program nor- malization, dubbed normalisation by evaluation, aims at evaluating a pro- gram in a type-directed fashion, by reusing the reduction mechanisms at hand at the meta level5 through a pair of reection/reication functions [2]. Soon after, Coquand noticed a strong similarity with completeness proofs [4]. This seminal work has been extended to more complex types [5,1], and also studied from the point of view of the completeness theorem for intu- itionistic natural deduction with respect to Kripke-like structures [9,6,8]. But when it comes to incorporating disjunction, one must be very careful, in particular because Kripke structures require worlds to decide between both members of the conjunction - from a pure normalization by evalua- tion point of view, dealing with sum types also requires special care. In this paper, we follow this line, relating constructive completeness proofs and normalization procedures. But, instead of considering Kripke semantics, as has been done in the works described above, we consider Heyting algebras: completeness theorems for the cut-free system (strong completeness), and therefore cut elimination [11,7] can be proved constructively; handling disjunction is straightforward, and hence we get cut elimina- tion for sum types. An adaptation of existing completeness proofs with respect to Heyting algebras is required, since all the known proofs, starting from Okada's contribution to linear logic [12], use sequent calculus. To support these claims, we have formalized the proofs of this paper in Coq, and used extraction to get an executable interpreter. To keep the complexity of the formalization reasonable, we remained in the proposi- tional fragment. The Coq sources are available at https://github.com/ SkySkimmer/NormalisationByCompleteness. The organization of this paper is the following: in Sec. 2 we recall natural deduction, in particular the notion of cut, and show basic lemmas. In Sec. 3, we develop the strong completeness proof, and discuss its Coq formalization in the next Sec. 4.1, where we also devise the behavior of the extracted algorithm on examples. Sec. 5 concludes the paper. 2 Natural Deduction Denition 1 (Terms and formulas). Let V be an innite set of vari- ables, S be a set of function symbols along with an arity and P be a set of predicate symbols along with an arity. The set of terms T is dened by: t ::= x j f(t1; :::; tn) 5 namely, the programming language in which the evaluation function is written 2 where x 2 V and f 2 S has arity n. The set of formulas F is dened by: A; B ::= P (t1; :::; tn) j A ^ B j A _ B j A ) B j > j ? j 8x:A j 9x:A where P 2 P has arity n. Denition 2 (Substitutions). A substitution σ is a partial function from variables to terms, with nite domain. We expand it inductively to a function from terms to terms and formulas to formulas, letting σ(x) = x for x2 = dom(σ). Notably for Q 2 f8; 9g; σ(Q x:A) := Qx.σ(A), assuming x fresh w.r.t. the image of σ by α-conversion. This is always possible since dom(σ) is nite, and so the image of σ is also nite. Denition 3 (Updated Substitution). Let σ be a substitution, x 2 V and t 2 T , σ[x 7! t] is the substitution with domain dom(σ) [ fxg such that for all y 6= x, σ[x 7! t](y) = σ(y) and σ[x 7! t](x) = t. The substitution with the empty set as domain is denoted ;. For t a term (resp. A a formula), x a variable and u a term, we abbreviate ;[x 7! u](t) (resp. ;[x 7! u](A)) as t[u=x] (resp. A[t=x]). Denition 4 (Contexts). A context Γ is a list of formulas [A1; :::; An]. We let Γ; A be the concatenation of A and Γ . Membership is denoted B 2 Γ . Inclusion, denoted Γ ⊆ Σ, holds when any B 2 Γ is also in Σ. Remark 1. The relation ⊆ is a preorder, but not an order. Indeed, it strictly subsumes contraction (Γ; A; A ⊆ Γ; A) as well as reordering of premises. Denition 5 (Cut-Free Proofs). Figure 1 denes the relations `ne (neutral proof) and `∗ (cut-free proof) by mutual induction. In Fig. 1, rules on the left are introduction rules and produce cut-free proofs, while rules on the right are elimination rules and produce neutral proofs. FV denotes the set of free variables. The usual natural deduction calculus NJ is a merge of both relations. For two contexts Γ; Σ and any relation `0, Σ `0 Γ denotes Σ `0 A for all A 2 Γ . Denition 6 (Natural Deduction). The judgment Γ ` A has the same ∗ rules as both Γ ` A and Γ `ne A. ∗ Therefore, if Γ ` A or Γ `ne A, then Γ ` A. 3 Γ `ne A A 2 Γ ∗ coerce ax Γ ` A Γ `ne A ∗ ∗ Γ ` AΓ ` B Γ `ne A ^ B Γ `ne A ^ B ∗ ^I ^El ^Er Γ ` A ^ B Γ `ne A Γ `ne B ∗ ∗ ∗ ∗ Γ ` A Γ ` B Γ `ne A _ B A; Γ ` C B; Γ ` C _ ∗ Il ∗ _Ir _E Γ ` A _ B Γ ` A _ B Γ `ne C ∗ ∗ Γ; A ` B Γ `ne A ) BΓ ` A ) )E ∗ I Γ ` A ) B Γ `ne B >I Γ `ne ? Γ `∗ > ?E Γ `ne A ∗ Γ ` A x2 = FV (Γ ) Γ `ne 8x:A ∗ 8I 8E Γ ` 8x:A Γ `ne A[t=x] ∗ ∗ Γ ` A[t=x] Γ `ne 9x:A A; Γ ` C x2 = FV (C; Γ ) ∗ 9I 9E Γ ` 9x:A Γ `ne C Fig. 1. Rules of Natural Deduction Lemma 1 (Weakening). Let Γ; Σ be contexts such that Γ ⊆ Σ. Let A be a formula. The three following rules are admissible: ∗ Γ ` A Γ `ne A Γ ` A ∗ Σ ` A Σ `ne A Σ ` A ∗ Proof. By mutual induction on Γ ` A and Γ `ne A, and by induction on Γ ` A. Corollary 1 (Contraction). For any context Γ and any formula B, if Γ; A; A ` B then Γ; A ` B. Neutral proofs are such that they can replace axioms in cut-free proofs without introducing any cut. Lemma 2 (Axiom Replacement). Let Γ; Σ be contexts and A be a formula. The three following rules are admissible: ∗ Σ `ne ΓΓ ` A Σ `ne ΓΓ `ne A Σ ` ΓΓ ` A ∗ Σ ` A Σ `ne A Σ ` A ∗ Proof. By mutual induction on Γ ` A and Γ `ne A, and by induction on Γ ` A. Note that we need the weakening lemma (Lem. 1) when the context is modied in a premise of a rule. ∗ Consider for instance the )I case of Fig. 1. Γ; A ` B is derivable. Σ; A `ne Γ; A holds, by weakening for Γ and by ax for A.