Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Is there a measure for these functions?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Is there a measure for these functions?


Chronological Thread 
  • 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 16:33:36 -0400
  • Authentication-results: mail3-smtp-sop.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-qk1-f180.google.com
  • Ironport-phdr: 9a23:P62tqxROIU4vkgsqt3PZGnfCgdpsv+yvbD5Q0YIujvd0So/mwa6zZhWN2/xhgRfzUJnB7Loc0qyK6v6mBjBLuMrY+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAi3oAnLtMQbjoRuJrs+xxfUv3BFZ/lYyWR0KFyJgh3y/N2w/Jlt8yRRv/Iu6ctNWrjkcqo7ULJVEi0oP3g668P3uxbDSxCP5mYHXWUNjhVIGQnF4wrkUZr3ryD3q/By2CiePc3xULA0RTGv5LplRRP0lCsKMSMy/WfKgcJyka1bugqsqRJ/zYDKfY+bN/hxfq3ac9wVWWVPUd1cVzBDD46mc4cCFfYNMfheooLgp1UOtxy+BQy0Ce/hyD9IgXn23aw50+s/FQHJwhIvEskBsHTRttr1NaMSXfqpw6nPyDXPYe5d1DD/6IjPdBAhoPKMUqx0ccXP10YiDAzFjlCKpozkOzOZzPgCs2+e7+d5U++klmEopR1rrDe12scslpfGhpgTyl3c6Sl0z5s5KcCmRUN7YtOpE5Rduj+UOYZ5TM0vTW9ltDg0x7AGpJO2YSgExZo6yxPBZfKKbYuF7BznWeiRITl1h3Roc6+8iRaq6UWs1PHwW82u3FtJridJiMfAum4T2xDJ98SKSedx8l+/1TuOywzf9+RJLV0wmKXHLpMszb89moYPvUnGAyP7l1v6gaqXe0o49eWl6OHqb7Hopp+SMoJ0hB/xPb4tl8G6Auk1MQwDUmqd9O+hzrPs51f5T69PjvAukqnWrpTaJcMDq668GQBV04Ij5w+mDzelzdgUhHcHIE9GdR6blYTpNFbOIPf3Dfe7nVugiitkx/fDPrH5A5XNKGbMkKv5cLpj90JRzBA/wNNf6p5OFL0NPuz/VlXsuNHbEhM1Kwm0zPzmCNV52IMeQ2WPAqqBPaPQtl+I4OMvI+qSa48RpjnyNeMo5/HrjXAjmF8debOl0ocQaHC9BvhmOVmWYWLwgtcdFmcHphYxTOvziFGbTTFTY2uyULkn6zEgCIOmCJ/DSZq3jLyA2ie7BJxWaXpcBlCCC3e7P7mDDtURbjOVP8lu2hcAXKKsA60o0x7m4A34wOs8d7L89SgRtJal399wsb79jxY3oHZ2CMKc0GyJQmxckWYBRjtw16d66wQpyFCF0Kt1h/FVPdNW7vJNFAw9MMiPnKRBF9nuV1eZLZ+yQ1G8T4D+WGBjfpcK29YLJn1FNZCnhxHH0TCtBuZMxbOODZ0wtKnb2iqofpov+zP9zKAkymIebI5XL2T/3/xw8gHSA8jClEDLz//3J5RZ5zbE8SK49UTLvExcV1QuA6DMXHRaf0iP6NqgthuEQLipBrAqdABGzJzaJw==

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.

>
> 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
>




Archive powered by MHonArc 2.6.19+.

Top of Page