coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] Type error for user-defined induction principle for inductive type
Chronological Thread
- From: Jerome Hugues <jhugues AT andrew.cmu.edu>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Type error for user-defined induction principle for inductive type
- Date: Sat, 30 Jan 2021 01:53:01 +0000
- Accept-language: en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jhugues AT andrew.cmu.edu; spf=Pass smtp.mailfrom=jhugues AT andrew.cmu.edu; spf=None smtp.helo=postmaster AT relay-exchange.andrew.cmu.edu
- Ironport-phdr: 9a23:jCUbOBW0ZgRXO866LxJ2P0McpLnV8LGtZVwlr6E/grcLSJyIuqrYbRaGt8tkgFKBZ4jH8fUM07OQ7/mxHzdbqs3f+DBaKdoQDkBD0Z1X1yUbQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2agMu4zf299IPOaAtUmjW9falyLBKrpgnNq8Uam4RvJrs1xxfTrHZFdetayG1pKFmOmxrw+tq88IRs/ihNuf8t7dJMXbn/c68lUbFWETMqPnwv6sb2rxfDVwyP5nUdUmUSjBVFBhXO4Q/5UJnsrCb0r/Jx1yaGM8L4S7A0Qimi4LxwSBD0kicHNiU2/3/Rh8dtka9UuhOhpxh4w47JfIGYMed1c63Bcd8GQ2dKQ8BcXDFDDIyhdYsCF+oPM/hFoYnhqVUArhW+CgutBOzzxTBFnWX50bE/0+k7DQ3KwA4tEtQTu3rUttX1M6ISXPixwqbW1zXDaPZW1ing44bKbxAhruyMUqxrccHMzkQvFQPFjkifqYz4ITyVzf8AvHKd7+V9T+KglWAmpxttrTiq28cgkJfGiZ8Iyl3d8yhy3Yk6K8GiRkFhfd6kDIVftzucN4ZuTc0vQW9mtSI5x7AbpJK2YScHxYopyhPCZPKJfYeF7BLsWeqPPzt1i31odbG7ihuz8EWt1O7xW9W73ltUsyZInd/BvW0O2RzL8sWLV+Vx80S71TqRzQzf9+FJLEIumabFJJMt2qM8moQQvEjZACP6gkr7gLGMekgr4uSk9vrrb7b8qpOCLYN4lwHzP6Y0lsG8A+k1NBUFUXKB9uSmzrLj+FX0QLVUgf0ylanUqIraKtofpqGjAw5Zy5gs6hmjADemytsYm3YHI0xfdB2diYjmJkvOL+72DPuln1uslSpry+rYMbL8H5XBNnnDkLH/crZh80NQ1RQ/wNNF655KEL0NPfL+V03ruNDGARI1Kwm0zPzmCNV52IMeQ2WPAqqBPaPQsV+I++0vI/SSa48OozvyMf4l6OP0jXAnl14RZ7Wm3Z4KaHyiAPtpPliZbWL2gtgdCWcKohY+TOvyhVKeVj5Tfm++UL445jEmE42rFpzDR4CogLyZxii3BJxWZmZcClCNC3jkbYuEW+1fIB6Vd4VqlSVBXry8Qacg0wuvvUn00fAveuHT42gTsY/p/Nlz/eza0x8oo29aFcOYhkOAVWZxkysoWjAr0bs39U5911ie3LNQivpUD9FMofhMT0E3OYOKnL8yMMz7Rg+UJoTBc12hWNjzWWhtHOJ0+McHZgNGI/vnlgrKhnT4CrkZjbGUQpcx7+TR02Wjf58gmUaD77EoihwdeuUKNWCigfUmpRLeA4fY1kiJnKajc6sRmifL+H2O0iyFuVweXQJtA/2cDCIvI3DOpNG83XvsCrqnCLApKAxEkJDQI61GcND2y15DWbHuNMmMOm8=
Thanks Jason,
You pointed to the right direction. Obviously the type checker was confused and I now understand how to interpret it.
For the record, here is the final working solution
(*************)
From Coq Require Import List.
Set Implicit Arguments. Set Asymmetric Patterns.
Inductive componentInstance := | component_instance : nat -> list subcomponentInstance -> componentInstance with subcomponentInstance := | subcomponent_instance : nat -> componentInstance -> subcomponentInstance.
Section All.
Variable T : Set. Variable P : T -> Prop.
Fixpoint All (ls : list T) : Prop := match ls with | nil => True | h :: t => P h /\ All t end.
End All.
Section componentInstance_ind'.
Variable Pc : componentInstance -> Prop.
Definition Ps (s : subcomponentInstance) : Prop := match s with | subcomponent_instance _ c => Pc c end.
Variable Pls : list subcomponentInstance -> Prop.
Hypothesis component_case : forall (n : nat) (ls : list subcomponentInstance), All Ps ls -> Pc (component_instance n ls).
Fixpoint componentInstance_ind' (c : componentInstance) : Pc c := match c return Pc c with | component_instance n ls => component_case n ls ((fix subcomponentInstance_ind (ls : list subcomponentInstance) : All (Ps) (ls) := match ls return All _ ls with | nil => I | subcomponent_instance _ c' :: ls' => conj (componentInstance_ind' c') (subcomponentInstance_ind ls') end) ls) end.
End componentInstance_ind'.
From:
<coq-club-request AT inria.fr> on behalf of Jason Gross <jasongross9 AT gmail.com>
Have not tried running the code, but try `match ls return All _ ls with` instead of `match ls with`. The error message that you got is saying "I don't know how to figure out what to apply "All" to to get "True"". Another way of phrasing this issue is that when you write "match ls with ..." it doesn't know whether you want the type of the branches to be in terms of `ls`, or to be in terms of the branch of the match.
Best, Jason
On Fri, Jan 29, 2021 at 5:22 PM Jerome Hugues <jhugues AT andrew.cmu.edu> wrote:
|
- [Coq-Club] Type error for user-defined induction principle for inductive type, Jerome Hugues, 01/29/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Gaëtan Gilbert, 01/29/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Jerome Hugues, 01/29/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Jason Gross, 01/30/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Jerome Hugues, 01/30/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Jason Gross, 01/30/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Jerome Hugues, 01/29/2021
- Re: [Coq-Club] Type error for user-defined induction principle for inductive type, Gaëtan Gilbert, 01/29/2021
Archive powered by MHonArc 2.6.19+.