emi
emi

Reputation: 5410

equality of eta-equivalent terms not established by reflexivity in coq

edit: I should probably say how I am currently worked around the problem here. I defined a principle for showing equality of permutations,

Lemma permInd : ∀ (U : Type) (A : Ensemble U) (φ ψ : Perm A),
  φ ↓ = ψ ↓ → φ ↑ = ψ ↑ → φ = ψ

then applied the lemma in the proof context that's giving me trouble below and shows that the eta-equivalent terms are equal. The problem therefore seems to be showing eta-equivalence when the terms are nested inside the record. But I'm not good at working with records, so I might be missing something.

original:

I am having trouble proving the equality of eta-equivalent terms nested in record fields. For reference, eta-reduction is independently provable by reflexivity:

Lemma etaEquivalence : ∀ (A B : Type) (f : A → B), (λ x : A, f x) = f.
Proof. reflexivity. Qed.

In my current proof context, I have two records the equality of which I must prove. Fully destructed and unfolded, the proof context and current subgoal looks like this:

U : Type
A : Ensemble U
perm0 : U → U
pinv0 : U → U
permutes0 : IsPerm A perm0 pinv0
============================
 {|
 perm := λ x : U, perm0 x;
 pinv := λ x : U, pinv0 x;
 permutes := permutationComp permutes0 (permutationId A) |} =
 {| perm := perm0; pinv := pinv0; permutes := permutes0 |}

The equalities that must be established are

perm0 = λ x : U, perm0 x
pinv0 = λ x : U, pinv0 x

Because these equalities can be established by reflexivity, I'm unsure what the problem is. However, I suspect something is awry, because attempting to replace λ x : U, perm0 x with perm0 generates the appropriate subgoal, but doesn't replace the term inside the record. Furthermore, rewriting using eqa_reduction causes errors regarding abstraction causing ill-typed terms or nested dependent arguments.

I've simplified the context as much as possible and pasted it below. Beyond stylistic problems and the fact that I'm still a beginner, I don't see any problems with the current development.

Require Import Unicode.Utf8 Utf8_core Ensembles Setoid.

Class IsPerm {U : Type} (A : Ensemble U) (φ ψ :  U → U) : Prop := {
  pinvLeft    : ∀ x : U, ψ (φ x) = x;
  pinvRight   : ∀ x : U, φ (ψ x) = x;
  closedPerm  : ∀ x : U, In U A x → In U A (φ x);
  closedPinv  : ∀ x : U, In U A x → In U A (ψ x)
}.

Record Perm {U : Type} (A : Ensemble U) : Type := {
  perm : U → U;
  pinv : U → U;
  permutes :> IsPerm A perm pinv
}.

Notation "f ∘ g"  := (λ x, f (g x)) (at level 45).
Notation "P ↓"    := (@perm _ _ P)  (at level 2, no associativity).
Notation "P ↑"    := (@pinv _ _ P)  (at level 2, no associativity).

Instance permutationComp
  {U : Type} {A : Ensemble U} {f g k h : U → U}
    (P : IsPerm A f k) (Q : IsPerm A g h) : IsPerm A (f ∘ g) (h ∘ k).
Proof.
  constructor; intros.
  setoid_rewrite pinvLeft. apply pinvLeft.
  setoid_rewrite pinvRight. apply pinvRight.
  apply closedPerm. apply closedPerm. auto.
  apply closedPinv. apply closedPinv. auto.
Defined.

Instance permutationId
  {U : Type} (A : Ensemble U) :
    IsPerm A (λ x : U, x) (λ x : U, x).
Proof. constructor; intros; auto. Defined.

Definition permComp
  {U : Type} (A : Ensemble U)
    (φ : Perm A) (ψ : Perm A) : Perm A :=
  Build_Perm U A (φ↓ ∘ ψ↓) (ψ↑ ∘ φ↑)
    (permutationComp (permutes A φ) (permutes A ψ)).

Definition permId {U : Type} (A : Ensemble U) : Perm A :=
  Build_Perm U A (λ x : U, x) (λ x : U, x) (permutationId A).

(* problems occur after the application of the tactic simpl, below: *)

Lemma permCompRightIdentity :
  ∀ {U : Type} (A : Ensemble U) (φ : Perm A), permComp A φ (permId A) = φ.
Proof. intros. unfold permComp. simpl. admit. Qed.

Finally, I want to thank everyone here for helping me out with Coq and being patient.

Upvotes: 4

Views: 697

Answers (1)

Stéphane Glondu
Stéphane Glondu

Reputation: 670

Proof irrelevance is not built-in in Coq. You can easily prove what you want if you assume the proof irrelevance axiom:

Require Import ProofIrrelevance.

Lemma permCompRightIdentity :
  ∀ {U : Type} (A : Ensemble U) (φ : Perm A), permComp A φ (permId A) = φ.
Proof.
  intros. unfold permComp. simpl.
  destruct φ.
  f_equal.
  apply proof_irrelevance.
Qed.

Upvotes: 6

Related Questions