Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Type error for user-defined induction principle for inductive type

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[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: [Coq-Club] Type error for user-defined induction principle for inductive type
  • Date: Fri, 29 Jan 2021 21:58:55 +0000
  • Accept-language: en-US
  • Authentication-results: mail3-smtp-sop.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:LtCFlhQq1UpppwUEjLxNdREYo9psv+yvbD5Q0YIujvd0So/mwa6zYhaN2/xhgRfzUJnB7Loc0qyK6vGmAjZLuMzb+DBaKdoQDkBD0Z1X1yUbQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2agMu4zf299IPOaAtUmjW9falyLBKrpgnNq8Uam4RvJrs1xxfTrHZEZetayX52KV6Ngh3w4tu88IN5/ylfpv4s9dRMXbnmc6g9ULdVECkoP2cp6cPxqBLNVxGP5nwSUmUXlhpHHQ3I5wzkU5nyryX3qPNz1DGVMsPqQ780Xy+i77pwRx/zlCgHLT85/3rJhcF2kalWvQiupx17w47TfYGVKP9zdb7TcN8GWWZMWNtaWipcCY2+coQPFfIMM+ZGoYfgu1sAoxiwBQiwC+zg0TJHnGP63agg3ug9DQ3L3gotFM8OvnTOq9X1Mb8fX+Srw6nSyjXDau1Z0ir/5ojVfRAhvO+DXaltesfWy0kvFx7FjlqNqYP7JDOYzf4Cs26G4Op6S+2uhXQrpB10ojiy3MsjlJTGhp8Mx13C6C52z5o7K8eiR05nfd6rDoFQtyeCOoZrQs4uXm9ltTgmx7MJuZC3YDQHxZQ6yxPedfCJc4mF7xHiWeuTLzl2i25oda+8ihu2/0auxe3yWtW73VhErydIlMTHuH4K1xzW8MeHS/1981+91jaP0wDT6/lELlowlaXBMZIhxKA/loYVvE/eHSH2gF37gLKIekgn4OSk9f7rbqjmq5KeLYN4lA/zPrwzlsChAuk0KBYCU3KU9OiizrHu8lX1TKhUgvA1iKXVrorWKdkbq6O7GQNY0YQu5hCiBDm8ytsYh2MILFdddRKHkYfpP1bOLejiDfihh1Sjijdqy+nYMbzuHprNLmLMkLHufblj8UJT0gwzws1F551KBLANOu78WkrstNDCEBA2LhG0z/7mCNV7yIweRXqCDrKHPK7Rq1OE+PgjL/SMaYIXojrxNfYo6+brjXAjmF8deaep3YEQaHC9BvlmIUWZYWfjgtccD2gKpREzQ/bsiFKfSz5ceXizU7gg6TE+FYKqF5nMSZ2wgLCZxie0AoVWZnxaClCLCXrna4KEW+4VZC2OJs9hjycLWKO6S44h0BGurBX1x6BmLurS4C0YtIjs2MJ75+3JxlkO8mk+BMOElmqJUmtcn2USRjZw0ro16Rh2zU7G2qxlidRZE8ZS7rVHSFFpG4TbyrlYBsr1Xw+JXsqGVVu9CoGkASw+U98q69YIb1xwBJOpiw2F0ia3VexG34eXDYA5p/qPl0P6INxwni6fiPsRymI+S84KDlWIw7Zl/lGNVYfPn1+UiOChcLla0SLQpj/akDi++XpAWQs1ap3rGHASYkyN9Ibj60fLXvqjGb8nOw1OxIiLLKdQZ8KvhlBbAvrvJYaGOjPjqyKLHR+Ng4i0Qs/vcmQZ0j/aDRFawQkV8WyLKk41Azrnrm7DXmVj

Hi,

 

I am using CPDT by Adam Chipala and try to apply the content of “Nested Inductive Types” from http://adam.chlipala.net/cpdt/html/Cpdt.InductiveTypes.html on the code below.

 

I tried to adjust it for the following type:

 

Inductive componentInstance :=

    | component_instance : nat -> list subcomponentInstance -> componentInstance

with subcomponentInstance :=

    | subcomponent_instance : nat -> componentInstance -> subcomponentInstance.

 

(see full code at the end)

 

The original code works with my Coq installation.  But my adaptation fails to pass type checking.

I end up with the following error:

 

In environment

Pc : componentInstance -> Prop

Ps : subcomponentInstance -> Prop

Pls : list subcomponentInstance -> Prop

component_case : forall (n : nat) (ls : list subcomponentInstance),

                 All Ps ls -> Pc (component_instance n ls)

componentInstance_ind' : forall c : componentInstance, Pc c

c : componentInstance

n : nat

ls : list subcomponentInstance

subcomponentInstance_ind : list subcomponentInstance -> All Ps ls

lsi : list subcomponentInstance

The term "I" has type "True" while it is expected to have type "All Ps ls".

Not in proof mode.

 

What bugs me is that All Ps ls computes to a Prop, therefore the code should work. I tried obvious modifications but could not work around this.

Is there anything obvious that I missed here?

 

Thanks for any pointers.

 

(***************************)

 

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.

  Variable Ps : subcomponentInstance -> Prop.

  Variable Pls : list subcomponentInstance -> Prop.

 

  Hypothesis component_case : forall (n : nat) (ls : list subcomponentInstance),

     All Ps ls -> Pc (component_instance n ls).

 

  Definition f (ls : list subcomponentInstance) := All Ps ls. Check f.

  Definition g := All Ps nil. Check g.

  Check True. Check I.

 

Fixpoint componentInstance_ind' (c : componentInstance) : Pc c :=

  match c with

  | component_instance n ls =>

    component_case n ls

    ((fix subcomponentInstance_ind (lsi : list subcomponentInstance) : All (Ps) (ls) :=

      match lsi with

      | nil => I (* True *) (* All Ps nil *)

      | subcomponent_instance _ c' :: lsii => (componentInstance_ind' c') /\

          (subcomponentInstance_ind lsii)

      end)

    ls)

end.

 

End componentInstance_ind'.

 

 

 




Archive powered by MHonArc 2.6.19+.

Top of Page