Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Simplify proofs with nested pattern matching (cases explosion)

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Simplify proofs with nested pattern matching (cases explosion)


Chronological Thread 
  • From: Blaudeau Clément <clement.blaudeau AT polytechnique.edu>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Simplify proofs with nested pattern matching (cases explosion)
  • Date: Mon, 29 Jun 2020 16:46:01 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=Pass smtp.pra=clement.blaudeau AT polytechnique.edu; spf=Pass smtp.mailfrom=clement.blaudeau AT polytechnique.edu; spf=None smtp.helo=postmaster AT mx-b.polytechnique.fr
  • Ironport-phdr: 9a23:/SaRBxxLcsWjnErXCy+O+j09IxM/srCxBDY+r6Qd2+MfIJqq85mqBkHD//Il1AaPAdyGrasV2qGO7ujJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhDexe65+IRGyoAneqsUbgZZpJ7osxBfOvnZGYfldy3lyJVKUkRb858Ow84Bm/i9Npf8v9NNOXLvjcaggQrNWEDopM2Yu5M32rhbDVheA5mEdUmoNjBVFBRXO4QzgUZfwtiv6sfd92DWfMMbrQ704RSiu4qF2QxLulSwJNSM28HvPh8JujKxVvRGvqRJxzIHbfI6bO+Fzfr/ecN4AWWZNQshcWi5HD4ihb4UPFe0BPeNAooTgo1sBtwa+ChSyC+z11z9HnmH73akg1OQkDw7G2hAgFM8JvXvIqNX6KqISXv6zzKnU1znMdPdW1i3g6IfVbB8uu+yMUKloccrWzUkuFx/FgUuMpozlOTOV1/0Ns3WF4OZ6S+2glnMnphh3rzOyycgilpPHiZgJylDY6yp52oA1KMWmRUB1btCpH5pduiGZOoZqXs8vQH9ltSknx7AHt5C1fDUHxIkoyhPbZPKLboeF7xb+WOuVLjl0mHFodbKwihuz90Wr1+7yVtGs3VpXsCZIlsPAum0R2xHc8MSKROdx8l281TuPzwzf9/9ILEQumabGN5IszaQ8m5sXvEjZECL7nEP7h7KMeEo+4Oin8eHnb63mppCCM490jRnzMqEhm8CmGus0KBAOX2+f+eW8yL3s41H2QLVMjv03i6nZrY7VKd4Vpq6jGwNV04Aj5AijDzq+zdgUg30KIEhYdB6bgIXlIV/DLOziAfuig1mgiDJryOrHPr3lDJXNNH/DkLL5cLlh705T1g8zws5Z55JIEL0OO/bzVVXstNPFEBA2KRG0zv3/CNV60oMfWX6PDbGFP6PSt1+I5/svI/SSa4MPpjnyNuUl6+b0jXAlgV8dYbWp3ZwPZX+kGfRmOlyVbmbogtccCmgHpRE+TezviF2aSzFffXeyX6Qm5jE6Eo2qF4nDRpr+yICGiSy8B9hdYn1MIlGKC3bhMYueCNkWbyfHCMtojzAJXKWWYIug0ByoqEeuwL5qK+fS5msSsZv+2NV8+sXLkhUj6TF/D8KcynyACWx4gzVbFHcNwKljrBklmR+42q9ijqkATIEB17ZySg4/cKXk4al6BtT1AFmTe8fMQhC+RdG3HTw6TtQw2sIDJUhnSY3730LzmhGyCrpQrISlQZk986bSxX/0fpcv03HCxbUshFkgQ9JSOCurirMtrlGPVb6MqF2QkuORTYpZxDTErTbR1W2KrV1VWw52ULzYUDYSalaE9Nk=

Hi Everyone,
I'm currently working to prove results on a fonction that uses several levels of nested pattern matching and it generates *a lot* of trivial subgoals, to the point that every proof takes several minutes to go through.

##### High level view of the problem

I have an inductive type with ~ 50 constructors, and nested pattern matching on lists of that type. The nested pattern matching is translated into several levels of normal pattern matching with one case that is interesting and 49 useless cases. To build proofs on my function, I would like to be able to extract easily the interesting cases, and quickly drop all useless cases. Is there automated ways of doing that ? Just destruct the match expressions and using `congruence` is too slow.

##### More details

I have a function  `is_valid : A -> bool`, and I want to prove results of the form `is_valid a = true -> P`, where `A` is an inductive type of the form
```Coq
Inductive A := | N : B -> (list A) -> A . % N is the only constructor
```
And `B` is also an inductive type **with around 50 constructors**.
The problem is that, in the `is_valid` function, I have nested pattern matching (on the list) like
```Coq
| N b1 (N b2 [])::(N b3 [])::_ => (f b1 b2 b3) % some property computed using b1 b2 b3
```
generates huge patterns, because the internal translation of nested patterns is to create several levels of patterns. As my type `B` has 50 constructors, each level of pattern matching generates **a lot** of subgoals and slows down the proofs.

Is there a simple way to say that if `is_valid a = true` then all the possible cases are only the ones of the main pattern matching, without having to break all sub-levels of matching using `congruence` everywhere ? Just doing an `unfold` of the `is_valid` function takes ~2 min on my computer. The dream would be that `is_valid a = true -> P` could be split into the few subgoals of the form `.. /\ (f b1 b2 b3) -> P /\ ...`

Thank you for your help !
Clément

PS: I could write a big theorem saying that for any property P, but I'm looking for an automated way of doing it

--
Clément Blaudeau
clement.blaudeau AT polytechnique.edu

--
Clément Blaudeau
0646116755
clement.blaudeau AT polytechnique.edu




Archive powered by MHonArc 2.6.19+.

Top of Page