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:32:05 -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-qv1-f45.google.com
  • Ironport-phdr: 9a23:XgZKmxbXAH5Akg1EgzE1Stn/LSx+4OfEezUN459isYplN5qZrs2/bnLW6fgltlLVR4KTs6sC17OI9f+8EjVcuN6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVrO+/7BpDdj9it1+C15pbffxhEiCCybL9vLRi6twfcu8YZjYd/Jas91wbCr2dVdehR2W5mP0+YkQzm5se38p5j8iBQtOwk+sVdT6j0fLk2QKJBAjg+PG87+MPktR/YTQuS/XQcSXkZkgBJAwfe8h73WIr6vzbguep83CmaOtD2TawxVD+/4apnVAPkhSEaPDM/7WrZiNF/jLhDrRyvpxJx3ZPaboKXO/pwea3Scs8VS2VaU8ZNVSFMGJ+wYpETA+YfO+tTsonzp0EJrRu7HQSgCuHvyjhOhn/33q01zeAhHh/Y0wE7ENIOtW7brNTxNKsITe+1y6zIwTveZP5R2zf9747IchEiof6SWbJ/b9TexFIgFwPAlFqQqIjlMymJ2eQKtmiW9uxtXv+ghGA7sQ9+uCSvxtsyhYnTgIIY0kzI+CpkzIooO9C1SE12bN2rHZZOuS+XOIV4T80sTm12tis3yqALtIO7ciUE1Zgq2RDRZuKEfoaG5h/tVOafLDR+iXl4e7y/nw6//Va8xuD4TMW501ZHojBbntXRsn0BzRPe58ifRvdj/0qtxSuD2gXO5uxAPU85kKXWJp89zrIsk5cfrEvOEjHzlUj3kKCbeUYp9+2s5uTpbLXro5GcOJFuhQz9N6kjmc+yDOA6PwUIQmOV4/6z1Kf58k38WLhKjuM5kq3esJ3CIMQUvK+5AwtM3oY69RazEi6q0NoXkHQHNl5FdxWHj4/mO1HKPv/0F+uwg1OpkDtzxvDGOKPuAonVI3TdjLvseaxx5k1cxQYp09xT+pZZBqsOLf/zQkPxscbXDh49Mwy62ebnD9B925scWWKIBK+ZMaDSvkGM5u0xPeaBf4AVuDPnJPgk4/7il2M2mVgYfaWxx5sYdGi4Huh6I0WeeXfjntABEX4TsgUiSOzqlUaNXCVIZ3eyWqI8/is0BJinDYfFXICtgaaO0D21Hp1MNSh6DQWuDHH5cJiCVL8nbCuIL4dDmzoLHeyjSYRwjkj2nAD/wrtjaOHT/3tLm4jk0Y0/5erVlBI/8TF5J8uY2mCJCWpzmylAEz0x2qF8rEhwx3+M1KF5h7pTEtkFtKABaRszKZOJl78yMNv1QA+UJo7YGmbjec2vBHQKdvx0xtYPZ0hnHND710LM2iOrB/kekLnZXcVooJKZ5GD4IoNG81iDzLMo1gB0Tc5GNGngjal6pVCKWtz51n6BnqPvTpwymS7A8GDZkDiLtUBcFRduCODLAS1ZaUzRotD0oEjFSu32BA==

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.

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