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: Junyoung Clare Jang <jjc9310 AT gmail.com>
  • To: "jonikelee AT gmail.com" <jonikelee 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:52:47 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jjc9310 AT gmail.com; spf=Pass smtp.mailfrom=jjc9310 AT gmail.com; spf=None smtp.helo=postmaster AT mail-yb1-f182.google.com
  • Ironport-phdr: 9a23:ReDajhF6NsD3qJGjbk+c851GYnF86YWxBRYc798ds5kLTJ7zpcSwAkXT6L1XgUPTWs2DsrQY0rSQ7P2rATZIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfLJ/IA+0oAjRucUanZVuIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1jioMKjw3/3zNisFog61brhCuqRxxzYDXfY+bKuZxc7jHct8GX2dMRNpdWzBDD466coABD/ABPeFdr4Tlo1UOsB2+BAmrBOPyzD9IiWL90LM+0+s7CwHJwhErEdYUv3TSo9X+KaAfUeK3zKbUyTjOYe5a1Svm5YjHdxAuu/CMXbZqfcXNzkkvEhrIg1ONooPqIz2bzP4Cs3SH7+V+T+KvjXYqpgFzrzWzxsoglpfFi4YJx13A6yl13Zo5KN+lREB1fdKoDJhduiOUOoZrTc0sQ2FltTg0xLMGpJK1cikHxZo6yxPZdveJcJCI7wr9WOqNJTp0nnFodbKlixqs7EStzvfwWtS33VpUqCdOj8PCuWoX1xPJ78iKUvt98Vml2TaIzw3T7/tLIUEwlabCK58u2aM8moMdsUjeHSL6hl/6jKCRdkUj9eio7/robq/6qZ+bMo94kgD+MqIwlcyjGek0LBQCUmyB9em/1LDv51P1TKhOg/Esj6XUs47WKdwepqGjAg9V1ogj6wy4DzejyNkYn3sHI05BdR+JkoTlJ0rDIP/9DfilglSslC1nyOzBPr3kGpnNNGTMkK/9fbZh7E5R0BY8zddG555NFr4BJO/zVVTqudzDDh45NhS0zPz9BNV80IMeQ2OPDbWDPKPcq1/brt4odqOOY4kUuzv5JvUN6PvnjHt/klgYN+H935wRaXO1GvlrC0qcaHvoxNwGFDFZkBA5SbnIlVuTViNVaD6ZW6sm63kZAYSpRdPBRIv82+XZ9Ci+F5xSIGtBDwbfQj/Ta4yYVqJUO2qpKch7n2lcDOnze8oazRir8TTC5f9iJ+vQ9DcfsMu6htdw7uzX0xo18G4tVpnP4yS2V2hx21gwaXo20aR4+xIvz16C1e1piaUdG4UDvbVGVQA1MZOaxOt/WYirBlDxO+yRQVPjee2IRCkrR4tokdALakd5Xd6li0Kb0g==

Hi,

Thank you for having an interest on my question. Sadly, t''' is a subterm of s, not t', and therefore I cannot use a subterm relation (whether direct or indirect) as a measure...
Is CPS conversion still worth its own? If so, I can try something similar.

Thanks,
Clare Jang

2020년 8월 3일 (월) 오후 4:32, jonikelee AT gmail.com <jonikelee AT gmail.com>님이 작성:
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



--
Best,
Junyoung Clare Jang



Archive powered by MHonArc 2.6.19+.

Top of Page