Note that there are some explanatory texts on larger screens.

plurals
  1. POexposing the structure of inductively defined terms in coq
    primarykey
    data
    text
    <p>The proof that typing derivations are unique in the simply-typed lambda calculus is trivial on paper. The proof that I am familiar with proceeds by complete induction on typing derivations. However, I am having trouble proving that typing derivations, represented <em>via</em> the type of typing derivations, are unique. Here, the predicate <code>dec Γ x τ</code> is true if the variable <code>x</code> has type <code>τ</code> in environment <code>Γ</code>. The typing predicate <code>J</code> is defined as usual, simply reading off the typing rules for the simply-typed lambda calculus:</p> <pre><code>Inductive J (Γ : env) : term → type → Set := | tvar : ∀ x τ, dec Γ x τ → J γ (var x) τ | tabs : ∀ τ₁ τ₂ e, J (τ₁ :: γ) e τ₂ → J γ (abs τ₁ e) (arr τ₁ τ₂) | tapp : ∀ τ₁ τ₂ e₁ e₂, J γ e₁ (arr τ₁ τ₂) → J γ e₂ τ₁ → J γ (app e₁ e₂) τ₂. </code></pre> <p>I am having trouble exposing the structure of a term of type <code>J</code> when proving that typing derivations are unique. For instance, I can induct on either <code>d1</code> or <code>d2</code> in the following lemma, but cannot induction on <code>d1</code> then destruct <code>d2</code> and conversely. The error message given by Coq (abstracting over terms leads to a term which is ill-typed) is slightly obscure, and the Coq wiki doesn't provide any help. For reference, this is the lemma that I am trying to prove:</p> <pre><code>Lemma unique_derivation : ∀ Γ e τ (d₁ d₂ : J Γ e τ), d₁ = d₂. </code></pre> <p>I have no problems when inducting on terms, for instance, when proving that the types are unique.</p> <p><strong>EDIT:</strong> I added the the minimal number of definitions necessary to state the result that I am having trouble with. In response to huitseeker's comment, the sort of <code>J</code> was chosen because I wanted to reason about typing derivations as structured objects in order to perform operations like extraction and prove results like uniqueness, which I haven't done in Coq before.</p> <p>In response to the first part of the comment, I can perform <code>induction</code> on either <code>d1</code> or <code>d2</code>, but <em>after</em> performing <code>induction</code> I cannot use <code>destruct</code>, <code>case</code>, or <code>induction</code> on the remaining term. This means that I cannot expose the structure of both <code>d1</code> and <code>d2</code> in order to reason about both proof trees. The error that I receive when I attempt to do so, says that abstracting over the remaining terms leads to a term which is ill-typed.</p> <pre><code>Require Import Unicode.Utf8. Require Import Utf8_core. Require Import List. Inductive type : Set := | tau : type | arr : type → type → type. Inductive term : Set := | var : nat → term | abs : type → term → term | app : term → term → term. Definition dec (Γ : list type) x τ : Prop := nth_error γ x = Some τ. Inductive J (Γ : list type) : term → type → Set := | tvar : ∀ x τ, dec Γ x τ → J Γ (var x) τ | tabs : ∀ τ₁ τ₂ e, J (τ₁ :: Γ) e τ₂ → J Γ (abs τ₁ e) (arr τ₁ τ₂) | tapp : ∀ τ₁ τ₂ e₁ e₂, J Γ e₁ (arr τ₁ τ₂) → J Γ e₂ τ₁ → J Γ (app e₁ e₂) τ₂. Lemma derivations_unique : ∀ Γ e τ (d1 d2 : J Γ e τ), d1 = d2. Proof. admit. Qed. </code></pre> <p>I've tried experimenting with <code>dependent induction</code> and several results from the <code>Coq.Logic</code> library, but without success. That derivations are unique seems like it should be an easy proposition to prove.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload