coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "jonikelee AT gmail.com" <jonikelee AT gmail.com>
- To: Junyoung Clare Jang <jjc9310 AT gmail.com>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Is there a measure for these functions?
- Date: Mon, 3 Aug 2020 17:19:35 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qv1-f54.google.com
- Ironport-phdr: 9a23:UQOr6BT+4FZ06nlvxfZSCmt5adpsv+yvbD5Q0YIujvd0So/mwa6zZRGN2/xhgRfzUJnB7Loc0qyK6v6mBjBLuMvb+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAi3oAnLtMQbjoRuJrsxxxfXv3BFZ/lYyWR0KFyJgh3y/N2w/Jlt8yRRv/Iu6ctNWrjkcqo7ULJVEi0oP3g668P3uxbDSxCP5mYHXWUNjhVIGQnF4wrkUZr3ryD3q/By2CiePc3xULA0RTGv5LplRRP0lCsKMSMy/WfKgcJyka1bugqsqRJ/zYDKfY+bN/hxfq3ac9wVWWVPUd1cVzBDD46yc4cCFfYNMfheooLgp1UOtxy+BQy0Ce/hyD9IgXn23aw50+s/FQHJwhIvEskBsHTRttr1NaMSXfqpw6nPyDXPYe5d1DD/6IjPdBAhoPKMUqx0ccXP10YiDAzFjlCKpozkOzOZzPgCs2+e7+d5U++klmEopR1rrDe12scslpfGhpgTyl3c6Sh03IY7KNO3RUNnb9CqHoZcuzyEOoZ3XM4vXW9mtSY5x7AGu5O3YTQHxZsoyRPRb/GKb5WE7xDjWeqMIzp1h3Roc6+8iRaq6UWs1PHwW82u3FtJridJiMfAum0J2hDJ6sWKReNx8lmg1DqTygze7/xILEQomqfeJJMsw6I8moYWvEjeESL6hkD7ga6KeUgr+eWl7uDqYrvoppKZOY97lBvxP6crl8G8Auk1NgoDUm6G8uqmzrLj51f2QLBSg/02jKbZtJfaKNwepqGjAg9V1p8v6w+hDzu7ydgYk3kKIV1fdBKIiIjpPF7OIPTmAvuln1uslzJry+jHPr3nHJrNMmDOnKn9cbt58UJRywo+wcpB655JDrwNOvL+V0DpuNzdFBA5Mgi0w+j9CNV604MTQWCPAqifMKPTsl+H+OYvLPeSa4IOtzb9LuIq5//qjXMjhVAdeqyp0YMNaH+kBvRmP1mZYX30j9gdFmcKpxMyQ/DuiF2fSjFefG2yXqI55jEjEo2qF4bDRoa3gLyAxii3BJNWZnoVQmyLRFX1cZSDRvEDIAmWK9Vs2h4NU7fpH40j3kD17VfSxL9uL+6S8Sod48HNzt9wsqfRkhcz9jFwAsm13GSETmUylWQNDXdi3qd5oE9wzlqO+ad9iv1cU9dU4qUaAU8BKZfAwrkiWJjJUQXbc4LREQf0cpCdGTg0C+kJ7ZoLakd5Fc+li0majSWvCr4R0beMAc5tq/6O7z3KP894jk3++uw5lVB/G5lAMGSnguh08A2BX9eUwXXcrL6jcOEn5ACI9GqHyjDT7kRRUQo1SLucGH5COg3ZqtP24k6ERLirW+wq
On Mon, 3 Aug 2020 16:33:36 -0400
"jonikelee AT gmail.com" <jonikelee AT gmail.com> wrote:
> On Mon, 3 Aug 2020 16:32:05 -0400
> "jonikelee AT gmail.com" <jonikelee AT gmail.com> wrote:
>
> > It looks to me like substSub is structurally recursive on s', and
> > substTy is recursive and terminating because t''' is an indirect
> > subcomponent of t'. I think you might be able to convince Coq that
> > these all terminate by defining them in continuation-passing style
> > instead of by mutual recursion. I think Coq's mutual recursion
> > "with" clause is very limited in that all functions involved have
> > to recurse in a structurally similar way.
> >
> > If you separate out the "match nth..." component from substTy and
> > turn that also into continuation-passing style, then I think all of
> > these functions can be defined to be structurally recursive.
> >
> > Also, it looks like that "match nth..." part needs a TUnit case.
>
> No - it isn't missing a TUnit case - I was just parsing all those
> primes in t''' as a pattern instead of a binding. Sorry.
Another way to convince Coq of termination is to add a height param
to Sub and Ty, and use that as the measure.
>
> >
> > On Mon, 3 Aug 2020 15:22:22 -0400
> > Junyoung Clare Jang <jjc9310 AT gmail.com> wrote:
> >
> > > Dear All,
> > >
> > > While I am trying to prove some properties of my language, the
> > > following functions come up.
> > >
> > > Inductive Sub : Set :=
> > > | NullS : Sub
> > > | SnocS : Sub -> Ty -> Sub
> > > with Ty : Set :=
> > > | TUnit : Ty
> > > | TBox : Ty -> Ty
> > > | TUnbox : nat -> nat -> Sub -> Ty
> > > .
> > >
> > > Fixpoint nth (s : Sub) (x : nat) : Ty :=
> > > match s with
> > > | NullS => TUnit
> > > | SnocS s' t' =>
> > > match x with
> > > | O => t'
> > > | S x' => nth s' x'
> > > end
> > > end
> > > .
> > > Fixpoint substSub (s : Sub) (n : nat) (s' : Sub) : Sub :=
> > > match s' with
> > > | NullS => NullS
> > > | SnocS s'' t'' => SnocS (substSub s n s'') (substTy s n t'')
> > > end
> > > with substTy (s : Sub) (n : nat) (t' : Ty) : Ty :=
> > > match t' with
> > > | TUnit => TUnit
> > > | TBox t'' => TBox (substTy s n t'')
> > > | TUnbox x'' d'' s'' =>
> > > if eq_dec d'' n
> > > then
> > > match nth s x'' with
> > > | TBox t''' => substTy (substSub s n s'') d'' t'''
> > > | t''' => TUnit
> > > end
> > > else
> > > TUnbox x'' d'' (substSub s n s'')
> > > end
> > > .
> > >
> > > (I simplified the actual version a little)
> > >
> > > However, substSub and substTy are clearly not structurally
> > > recursive, so I tried several measures in order to define them,
> > > but none of those worked. I also attempted to find a looping
> > > example, and that was also unsuccessful. Do these functions
> > > terminate? I will appreciate any helps to show these functions
> > > are terminating or non-terminating...
> > >
> > > Thanks,
> > > Clare Jang
> >
>
- [Coq-Club] Is there a measure for these functions?, Junyoung Clare Jang, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, Dominique Larchey-Wendling, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, Junyoung Clare Jang, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, Junyoung Clare Jang, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, Junyoung Clare Jang, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, jonikelee AT gmail.com, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, jonikelee AT gmail.com, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, jonikelee AT gmail.com, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, Junyoung Clare Jang, 08/03/2020
- Re: [Coq-Club] Is there a measure for these functions?, jonikelee AT gmail.com, 08/03/2020
- <Possible follow-up(s)>
- Re: [Coq-Club] Is there a measure for these functions?, Dominique Larchey-Wendling, 08/11/2020
- Re: [Coq-Club] Is there a measure for these functions?, Dominique Larchey-Wendling, 08/12/2020
- Re: [Coq-Club] Is there a measure for these functions?, Dominique Larchey-Wendling, 08/03/2020
Archive powered by MHonArc 2.6.19+.