Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Ideal eliminator for { l : list T & length l = n}

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Ideal eliminator for { l : list T & length l = n}


Chronological Thread 
  • From: Talia Ringer <tringer AT cs.washington.edu>
  • To: Coq-Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Ideal eliminator for { l : list T & length l = n}
  • Date: Fri, 21 Feb 2020 11:21:11 -0800
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=tringer AT cs.washington.edu; spf=Pass smtp.mailfrom=tringer AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-io1-f52.google.com
  • Ironport-phdr: 9a23:Q2LxVxA1Y3rc48YmifO6UyQJP3N1i/DPJgcQr6AfoPdwSPv+p8bcNUDSrc9gkEXOFd2Cra4d16yG7+u5AzVIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRq7oR/Su8QZjoduN7g9xgbUqXZUZupawn9lKl2Ukxvg/Mm74YRt8z5Xu/Iv9s5AVbv1cqElRrFGDzooLn446tTzuRbMUQWA6H0cUn4LkhVTGAjK8Av6XpbqvSTksOd2xTSXMtf3TbAwXjSi8rtrRRr1gyoJKzI17GfagdF2galGohyuugZ/zpbbb4GbNvVwfq3Tc9AHS2RfQslcTDZODp+mYoYVE+YNIeRVoo/grFUOtxu+AgysCfvxxDBSgn/23Lc12Pk9HwHH2gwgEMwBsG7Jp9jyKKcSS+G1zK/HzTrddfNbwivy6JPSfhEvu/6MRrJwccvXyUkgCwPFiVOQpZb7MDyIy+QAqm6W5PdjW+K3k2MrtR19rzy1ysovioTFnJ8Zx1HF+CljwIs5O9u1Q1Nhb9G+CptfrSSaOpN2Qsw8R2Fovz43yrgctp66eCgG0ZUnxxnCZ/CefYiF4gzvWPyeITd/g3Jld7a/iAio/Ue8ze38U9G40FdMriVbjtnBrm4B2wDX58SdSfZw/l2t1SuO2g3S8O1JIV44mbLeK5E7w74wkpQTsV7EHi/zgEj2kLWWdkQi+uin9evneK7rqYOHN4NuhADxKL8umsy+AeQ+PQgOQ2+b+eKm2LL94EL5Xa1GjucqnanBrJDaOcMbq7alDA9Sy4Yv8gqwDzO70NsDhnQHN1JEeBefj4fzIV3OIfb4De2+g1u2ijtryerGbfXdBcDmKWGGu7P8d/4p4ElFjQE30Np35pROC7hHLuilCWHrs9mNMhY9MgX8+efhB9hnntcCQ2OJDaKDGKjJ90CB/eIuJeaQY4lTtTrgfat2r8XyhGM0zAdONZKi2oEaPSjhQ6ZWZn6BaH+pue8vVGcHug1kEb7vgVyGFD9UPjO8Avh66TY8B4arS4zEQ9L12eDT7GKABpRTI1t+JBWUC36xJtePQLETYTmSI8lujjsCE7WtVt15jED8hErB07Nia9Hs1GgdvJPn2sJy4rSCxxopsyN9FMSc1W6RSGcyk28VFWY7

Sorry, all proofs of equalities between terms of type unit are equal to each other. That was a semantically significant typo.

On Fri, Feb 21, 2020 at 11:19 AM Talia Ringer <tringer AT cs.washington.edu> wrote:
Interesting feedback. Does anyone have any examples that don't use SSReflect? I am really not used to SSReflect, and I find it hard to understand what is happening in proofs written in that style.

Is there a useful induction principle for { l : list T & length l = n } that people use in general? For example if you'd like to write your list functions and proofs separately from the invariants about their lengths and proofs about those invariants. Is there an easy way to glue them together in general? Could I define this as a single induction principle, something that takes separately a proof about lists and a proof about its lengths?

It should be pretty easy to show that the equality type [bar = bar] is isomorphic to the equality type [nat = nat], which is nontrivial if you assume univalence.  Does this help?

Interesting, so the type of your index really matters, not just the structure? What is the intuition behind this? It's just weird to me because I could define another type:

Inductive C : unit -> Type :=
| baz : C tt.

and then you could define indexer functions between B and C that let you prove an equivalence between B and C at those indices. It should be very easy to work over equalities between C (because all proofs of unit are equal to each other). What happens when you transport those equalities to proofs about equalities between B?

Talia

On Fri, Feb 21, 2020 at 9:04 AM Valentin Robert <valentin.robert.42 AT gmail.com> wrote:
Very nice, indeed fixing `n`, unlike in the more general `Vector.caseS`, makes the problems I had go away!

- Valentin

On Fri, 21 Feb 2020 at 17:34, Daniel Schepler <dschepler AT gmail.com> wrote:
On Fri, Feb 21, 2020 at 2:42 AM Valentin Robert
<valentin.robert.42 AT gmail.com> wrote:
> Or I have to painfully roll my own inversion:
>
> Goal forall T (P : Vector.t T 2 -> Type) v, P v.
>   move => T P v.
>   pose goal :=
>     (
>       fun n v =>
>         match n as n' return Vector.t T n' -> Type with
>         | 2 => P
>         | _ => fun _ => True
>         end v
>     ).

What if instead, you rolled the basic vectorS_inv and vector0_inv
once, and then used those as building blocks?  e.g.

Definition vectorS_inv {X:Type} {n:nat} :
  forall P : Vector.t X (S n) -> Type,
  (forall (h : X) (t : Vector.t X n), P (Vector.cons _ h _ t)) ->
  forall v : Vector.t X (S n), P v.
Admitted.
Definition vector0_inv {X:Type} :
  forall P : Vector.t X O -> Type,
  P (Vector.nil _) -> forall v : Vector.t X O, P v.
Admitted.

Goal forall {X:Type} (P : Vector.t X 2 -> Type),
  (forall a b : X, P (Vector.cons _ a _ (Vector.cons _ b _ (Vector.nil _)))) ->
  forall v : Vector.t X 2, P v.
intros X P f v. destruct v as [a0 v'] using @vectorS_inv.
destruct v' as [b0 v''] using @vectorS_inv.
inversion v'' using @vector0_inv. apply f.
Defined.
--
Daniel Schepler



Archive powered by MHonArc 2.6.18.

Top of Page