Discussion:
[Agda] Checking termination is not sufficiently exploratory.
Serge Leblanc
2018-07-30 14:55:22 UTC
Permalink
Dear all,
Why the checking termination rejects the coSplit" function although the
coSplit' function is accepted ?
Why the checking termination so suspicious?
Sincerely

Estimataj ĉiuj,
Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la
funkcio coSplit′ trafas ?
Kial la finiĝa kontrolo estas tiel malakceptanda ?
Sincere

  coSplit′ : Costring → Costring
  coSplit′ [] = []
  coSplit′ (x ∷ xs) with x ≐ '!'
  ... | false = x ∷ ♯ coSplit′ (♭ xs)
  ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))

  coSplit″ : Costring → Costring
  coSplit″ [] = []
  coSplit″ (x ∷ xs) with x ≐ '!'
  ... | false = x ∷ ♯ coSplit″ (♭ xs)
  ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)

  main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
a.j.rouvoet
2018-07-30 14:59:38 UTC
Permalink
For coSplit to pass the checker, the recursive invocation must appear
guarded by a constructor.
This is clearly the case in coSplit', but not necessarily in coSplit''
(e.g. when toString ">>" returns the empty costring).


On 07/30/2018 04:55 PM, Serge Leblanc wrote:
> Dear all,
> Why the checking termination rejects the coSplit" function although
> the coSplit' function is accepted ?
> Why the checking termination so suspicious?
> Sincerely
>
> Estimataj ĉiuj,
> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la
> funkcio coSplit′ trafas ?
> Kial la finiĝa kontrolo estas tiel malakceptanda ?
> Sincere
>
>   coSplit′ : Costring → Costring
>   coSplit′ [] = []
>   coSplit′ (x ∷ xs) with x ≐ '!'
>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>
>   coSplit″ : Costring → Costring
>   coSplit″ [] = []
>   coSplit″ (x ∷ xs) with x ≐ '!'
>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>
>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>
> --
> Serge Leblanc
> ------------------------------------------------------------------------
> gpg --search-keys 0x67B17A3F
> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
Serge Leblanc
2018-07-30 16:04:59 UTC
Permalink
Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs) to
its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)). Right?
So, the recursive call is well protected by a constructor.

Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs) ĝis
sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs)). Ĉu ne ?
Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.

On 2018-07-30 16:59, a.j.rouvoet wrote:
>
> For coSplit to pass the checker, the recursive invocation must appear
> guarded by a constructor.
> This is clearly the case in coSplit', but not necessarily in coSplit''
> (e.g. when toString ">>" returns the empty costring).
>
>
> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>> Dear all,
>> Why the checking termination rejects the coSplit" function although
>> the coSplit' function is accepted ?
>> Why the checking termination so suspicious?
>> Sincerely
>>
>> Estimataj ĉiuj,
>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la
>> funkcio coSplit′ trafas ?
>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>> Sincere
>>
>>   coSplit′ : Costring → Costring
>>   coSplit′ [] = []
>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>
>>   coSplit″ : Costring → Costring
>>   coSplit″ [] = []
>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>
>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>
>> --
>> Serge Leblanc
>> ------------------------------------------------------------------------
>> gpg --search-keys 0x67B17A3F
>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
a.j.rouvoet
2018-07-30 18:06:28 UTC
Permalink
I believe that you are right that the two snippets are equivalent, but
it requires some computation to show that this is the case.
The check that Agda runs on the other hand is very syntactic. This is
indeed a limitation, but at least it ensures that checking for
termination terminates ;-)

On 07/30/2018 06:04 PM, Serge Leblanc wrote:
> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs) to
> its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)). Right?
> So, the recursive call is well protected by a constructor.
>
> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs) ĝis
> sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs)). Ĉu
> ne ?
> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>
> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>
>> For coSplit to pass the checker, the recursive invocation must appear
>> guarded by a constructor.
>> This is clearly the case in coSplit', but not necessarily in
>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>
>>
>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>> Dear all,
>>> Why the checking termination rejects the coSplit" function although
>>> the coSplit' function is accepted ?
>>> Why the checking termination so suspicious?
>>> Sincerely
>>>
>>> Estimataj ĉiuj,
>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la
>>> funkcio coSplit′ trafas ?
>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>> Sincere
>>>
>>>   coSplit′ : Costring → Costring
>>>   coSplit′ [] = []
>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>
>>>   coSplit″ : Costring → Costring
>>>   coSplit″ [] = []
>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>
>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>
>>> --
>>> Serge Leblanc
>>> ------------------------------------------------------------------------
>>> gpg --search-keys 0x67B17A3F
>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
> --
> Serge Leblanc
> ------------------------------------------------------------------------
> gpg --search-keys 0x67B17A3F
> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
Serge Leblanc
2018-07-31 01:02:29 UTC
Permalink
In my opinion, a normal form verification phase could be added without
changing the termination checking algorithm.
Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
kontrolan algoritmon.

Sincere


On 2018-07-30 20:06, a.j.rouvoet wrote:
>
> I believe that you are right that the two snippets are equivalent, but
> it requires some computation to show that this is the case.
> The check that Agda runs on the other hand is very syntactic. This is
> indeed a limitation, but at least it ensures that checking for
> termination terminates ;-)
>
> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>> Right?
>> So, the recursive call is well protected by a constructor.
>>
>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>> xs)). Ĉu ne ?
>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>
>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>
>>> For coSplit to pass the checker, the recursive invocation must
>>> appear guarded by a constructor.
>>> This is clearly the case in coSplit', but not necessarily in
>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>
>>>
>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>> Dear all,
>>>> Why the checking termination rejects the coSplit" function although
>>>> the coSplit' function is accepted ?
>>>> Why the checking termination so suspicious?
>>>> Sincerely
>>>>
>>>> Estimataj ĉiuj,
>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la
>>>> funkcio coSplit′ trafas ?
>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>> Sincere
>>>>
>>>>   coSplit′ : Costring → Costring
>>>>   coSplit′ [] = []
>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>
>>>>   coSplit″ : Costring → Costring
>>>>   coSplit″ [] = []
>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>
>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>
>>>> --
>>>> Serge Leblanc
>>>> ------------------------------------------------------------------------
>>>> gpg --search-keys 0x67B17A3F
>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>
>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>> --
>> Serge Leblanc
>> ------------------------------------------------------------------------
>> gpg --search-keys 0x67B17A3F
>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Jason -Zhong Sheng- Hu
2018-07-31 01:19:04 UTC
Permalink
I am wondering if there is any implementation of dependent type theory performs normalization before termination checking?


It sounds theoretical doable, but somehow termination checking is commonly syntactical, like agda and coq. However, those who care about compilation performance might not be too happy about it.


I am wondering if there is an example makes normalization here looks non-trivial?


Sincerely Yours,

Jason Hu
________________________________
From: Agda <agda-***@lists.chalmers.se> on behalf of Serge Leblanc <***@gmail.com>
Sent: July 30, 2018 9:02:29 PM
To: ***@lists.chalmers.se
Subject: Re: [Agda] Checking termination is not sufficiently exploratory.

In my opinion, a normal form verification phase could be added without changing the termination checking algorithm.
Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan kontrolan algoritmon.

Sincere

On 2018-07-30 20:06, a.j.rouvoet wrote:

I believe that you are right that the two snippets are equivalent, but it requires some computation to show that this is the case.
The check that Agda runs on the other hand is very syntactic. This is indeed a limitation, but at least it ensures that checking for termination terminates ;-)


On 07/30/2018 06:04 PM, Serge Leblanc wrote:
Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs) to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)). Right?
So, the recursive call is well protected by a constructor.

Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs) ĝis sia normala formo, ĝi egalas al '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs)). Ĉu ne ?
Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.

On 2018-07-30 16:59, a.j.rouvoet wrote:

For coSplit to pass the checker, the recursive invocation must appear guarded by a constructor.
This is clearly the case in coSplit', but not necessarily in coSplit'' (e.g. when toString ">>" returns the empty costring).

On 07/30/2018 04:55 PM, Serge Leblanc wrote:
Dear all,
Why the checking termination rejects the coSplit" function although the coSplit' function is accepted ?
Why the checking termination so suspicious?
Sincerely

Estimataj ĉiuj,
Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam la funkcio coSplit′ trafas ?
Kial la finiĝa kontrolo estas tiel malakceptanda ?
Sincere

coSplit′ : Costring → Costring
coSplit′ [] = []
coSplit′ (x ∷ xs) with x ≐ '!'
... | false = x ∷ ♯ coSplit′ (♭ xs)
... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))

coSplit″ : Costring → Costring
coSplit″ [] = []
coSplit″ (x ∷ xs) with x ≐ '!'
... | false = x ∷ ♯ coSplit″ (♭ xs)
... | true = (toCostring ">>") ++ coSplit″ (♭ xs)

main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s

--
Serge Leblanc
________________________________
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F



_______________________________________________
Agda mailing list
***@lists.chalmers.se<mailto:***@lists.chalmers.se>
https://lists.chalmers.se/mailman/listinfo/agda





_______________________________________________
Agda mailing list
***@lists.chalmers.se<mailto:***@lists.chalmers.se>
https://lists.chalmers.se/mailman/listinfo/agda


--
Serge Leblanc
________________________________
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F



_______________________________________________
Agda mailing list
***@lists.chalmers.se<mailto:***@lists.chalmers.se>
https://lists.chalmers.se/mailman/listinfo/agda





_______________________________________________
Agda mailing list
***@lists.chalmers.se<mailto:***@lists.chalmers.se>
https://lists.chalmers.se/mailman/listinfo/agda


--
Serge Leblanc
________________________________
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Serge Leblanc
2018-07-31 06:09:05 UTC
Permalink
When the termination checking fails you can complete it again on a
normalized part of the program. Then the speed is completely preserved
because we will rarely need normalization passe . Therefore, normalized
parts could be stored and used during coding generation.

Kiam la sintaksa finiĝokontrolo fiaskas oni povas denove plenumi ĝin sur
normalita parto de la programo. Tiam la rapideco estas tute konservita
pro oni malofte bezonos nomaladan fazon. Sekve, normalitaj partoj povus
esti konservi kaj uzitaj dum la kodokonstuado.

On 2018-07-31 03:19, Jason -Zhong Sheng- Hu wrote:
>
> I am wondering if there is any implementation of dependent type theory
> performs normalization before termination checking?
>
>
> It sounds theoretical doable, but somehow termination checking is
> commonly syntactical, like agda and coq. However, those who care about
> compilation performance might not be too happy about it.
>
>
> I am wondering if there is an example makes normalization here looks
> non-trivial?
>
>

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Robbert Krebbers
2018-07-31 06:44:12 UTC
Permalink
On 2018-07-31 03:19, Jason -Zhong Sheng- Hu wrote:
> I am wondering if there is any implementation of dependent type
> theory performs normalization before termination checking?
Coq is doing exactly that, the example of Serge is thus happily accepted
by Coq, see below for a version of his example in Coq.

Note that while performing normalization before termination checking
provides extra flexibility, it brings other problems---The following
program is accepted by Coq's termination checker but diverges when
executed using eager evaluation:

Fixpoint foo (n : nat) : nat :=
let _ := foo n in
0.
Eval compute in foo 0.
(* Stack overflow. *)

The problem here is that normalization removes the recursive call, which
makes the termination checker accept the definition.

Best,

Robbert

-----------

Require Import List Ascii String.
Open Scope string_scope.

CoInductive costring := snil | scons : ascii -> costring -> costring.

Fixpoint sapp (xs : string) (ys : costring) : costring :=
match xs with
| "" => ys
| String x xs => scons x (sapp xs ys)
end.

CoFixpoint cosplit'' (xs : costring) : costring :=
match xs with
| snil => snil
| scons x xs =>
if ascii_dec x "!" then scons x (cosplit'' xs)
else sapp ">>" (cosplit'' xs)
end.
Serge Leblanc
2018-08-02 09:30:52 UTC
Permalink
On 2018-07-31 08:44, Robbert Krebbers wrote:
>
> Note that while performing normalization before termination checking
> provides extra flexibility, it brings other problems---The following
> program is accepted by Coq's termination checker but diverges when
> executed using eager evaluation:
>
>   Fixpoint foo (n : nat) : nat :=
>     let _ := foo n in
>     0.
>   Eval compute in foo 0.
>   (* Stack overflow. *)
>
> The problem here is that normalization removes the recursive call,
> which makes the termination checker accept the definition.
>

I doubt to the explanation, Agda accept the same program. It only works
because Agda is lazy evaluation!
Mi dubas pri la kialo, Agda akceptas la saman programon. Ĝi trafas nur
pro Agda prokrastas plenumadon!
 
module Numeral where

  open import Data.Nat using (ℕ ; zero ; suc)
  open import Relation.Binary.PropositionalEquality as PropEq using (_≡_
; refl)

  foo : ℕ → ℕ
  foo n = let _ = foo n in zero

  proof : ∀ n → foo n ≡ zero
  proof n = refl


--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Andreas Abel
2018-08-11 08:34:40 UTC
Permalink
Agda expands let and computes beta-normal forms already during type checking,
this is why the foo-example works in Agda as well. However, function
definitions (like append) are not expanded.

--Andreas

On 02.08.2018 11:30, Serge Leblanc wrote:
>
>
> On 2018-07-31 08:44, Robbert Krebbers wrote:
>>
>> Note that while performing normalization before termination checking provides
>> extra flexibility, it brings other problems---The following program is
>> accepted by Coq's termination checker but diverges when executed using eager
>> evaluation:
>>
>>   Fixpoint foo (n : nat) : nat :=
>>     let _ := foo n in
>>     0.
>>   Eval compute in foo 0.
>>   (* Stack overflow. *)
>>
>> The problem here is that normalization removes the recursive call, which makes
>> the termination checker accept the definition.
>>
>
> I doubt to the explanation, Agda accept the same program. It only works because
> Agda is lazy evaluation!
> Mi dubas pri la kialo, Agda akceptas la saman programon. Ĝi trafas nur pro Agda
> prokrastas plenumadon!
>
> module Numeral where
>
>   open import Data.Nat using (ℕ ; zero ; suc)
>   open import Relation.Binary.PropositionalEquality as PropEq using (_≡_ ; refl)
>
>   foo : ℕ → ℕ
>   foo n = let _ = foo n in zero
>
>   proof : ∀ n → foo n ≡ zero
>   proof n = refl
>
>
> --
> Serge Leblanc
> --------------------------------------------------------------------------------
> gpg --search-keys 0x67B17A3F
> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>


--
Andreas Abel <>< Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

***@gu.se
http://www.cse.chalmers.se/~abela/
Serge Leblanc
2018-08-03 18:57:19 UTC
Permalink
Would an expert help me to improve the termination checking algorithm?
Does someone already work to improve the algorithm?

Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
Ĉu iu jam laboras por plibonigi la algoritmon?

Sincere

 
On 2018-07-31 03:02, Serge Leblanc wrote:
> In my opinion, a normal form verification phase could be added without
> changing the termination checking algorithm.
> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
> kontrolan algoritmon.
>
> Sincere
>
>
> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>
>> I believe that you are right that the two snippets are equivalent,
>> but it requires some computation to show that this is the case.
>> The check that Agda runs on the other hand is very syntactic. This is
>> indeed a limitation, but at least it ensures that checking for
>> termination terminates ;-)
>>
>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>> Right?
>>> So, the recursive call is well protected by a constructor.
>>>
>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>> xs)). Ĉu ne ?
>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>
>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>
>>>> For coSplit to pass the checker, the recursive invocation must
>>>> appear guarded by a constructor.
>>>> This is clearly the case in coSplit', but not necessarily in
>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>
>>>>
>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>> Dear all,
>>>>> Why the checking termination rejects the coSplit" function
>>>>> although the coSplit' function is accepted ?
>>>>> Why the checking termination so suspicious?
>>>>> Sincerely
>>>>>
>>>>> Estimataj ĉiuj,
>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>> la funkcio coSplit′ trafas ?
>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>> Sincere
>>>>>
>>>>>   coSplit′ : Costring → Costring
>>>>>   coSplit′ [] = []
>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>
>>>>>   coSplit″ : Costring → Costring
>>>>>   coSplit″ [] = []
>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>
>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>
>>>>> --
>>>>> Serge Leblanc
>>>>> ------------------------------------------------------------------------
>>>>> gpg --search-keys 0x67B17A3F
>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Agda mailing list
>>>>> ***@lists.chalmers.se
>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>>> --
>>> Serge Leblanc
>>> ------------------------------------------------------------------------
>>> gpg --search-keys 0x67B17A3F
>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
> --
> Serge Leblanc
> ------------------------------------------------------------------------
> gpg --search-keys 0x67B17A3F
> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Guillaume Allais
2018-08-05 08:24:36 UTC
Permalink
Hi Serge,

Using the new-style codata based on sized types which is available in the
latest standard library, you could write something like [see below].

Notice the type of `_:++_`: the second argument is a `Thunk` and because
the string is non-empty it's fine: we can guarantee it'll be used in a
guarded position.

Cheers,
--
gallais

==========================================================================
module Costring where

open import Size
open import Codata.Thunk
open import Data.Nat as Nat
open import Data.Char
open import Data.String hiding (fromList ; _++_ ; _==_)
open import Data.List as List hiding (_++_)
open import Relation.Nullary.Decidable
open import Data.Bool
open import Function

data Costring (i : Size) : Set where
[] : Costring i
_∷_ : Char → Thunk Costring i → Costring i

fromList : List Char → Costring ∞
fromList [] = []
fromList (x ∷ xs) = x ∷ λ where .force → fromList xs

toCostring : String → Costring ∞
toCostring = fromList ∘′ toList

_++_ : ∀ {i} → Costring i → Costring i → Costring i
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ λ where .force → xs .force ++ ys

_:++_ : ∀ {i} (str : List Char) {_ : False (List.length str Nat.≟ 0)} →
Thunk Costring i → Costring i
_:++_ [] {()} xs
_:++_ (x ∷ str) {pr} xs = x ∷ λ where .force → fromList str ++ xs .force

coSplit″ : ∀ {i} → Costring i → Costring i
coSplit″ [] = []
coSplit″ (x ∷ xs) with x == '!'
... | false = x ∷ λ where .force → coSplit″ (xs .force)
... | true = toList ">>" :++ λ where .force → coSplit″ (xs .force)
==========================================================================

On 03/08/18 20:57, Serge Leblanc wrote:
> Would an expert help me to improve the termination checking algorithm?
> Does someone already work to improve the algorithm?
>
> Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
> Ĉu iu jam laboras por plibonigi la algoritmon?
>
> Sincere
>
>  
> On 2018-07-31 03:02, Serge Leblanc wrote:
>> In my opinion, a normal form verification phase could be added without
>> changing the termination checking algorithm.
>> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
>> kontrolan algoritmon.
>>
>> Sincere
>>
>>
>> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>>
>>> I believe that you are right that the two snippets are equivalent,
>>> but it requires some computation to show that this is the case.
>>> The check that Agda runs on the other hand is very syntactic. This is
>>> indeed a limitation, but at least it ensures that checking for
>>> termination terminates ;-)
>>>
>>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>>> Right?
>>>> So, the recursive call is well protected by a constructor.
>>>>
>>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>>> xs)). Ĉu ne ?
>>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>>
>>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>>
>>>>> For coSplit to pass the checker, the recursive invocation must
>>>>> appear guarded by a constructor.
>>>>> This is clearly the case in coSplit', but not necessarily in
>>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>>
>>>>>
>>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>>> Dear all,
>>>>>> Why the checking termination rejects the coSplit" function
>>>>>> although the coSplit' function is accepted ?
>>>>>> Why the checking termination so suspicious?
>>>>>> Sincerely
>>>>>>
>>>>>> Estimataj ĉiuj,
>>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>>> la funkcio coSplit′ trafas ?
>>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>>> Sincere
>>>>>>
>>>>>>   coSplit′ : Costring → Costring
>>>>>>   coSplit′ [] = []
>>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>>
>>>>>>   coSplit″ : Costring → Costring
>>>>>>   coSplit″ [] = []
>>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>
>>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>>
>>>>>> --
>>>>>> Serge Leblanc
>>>>>> ------------------------------------------------------------------------
>>>>>> gpg --search-keys 0x67B17A3F
>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Agda mailing list
>>>>>> ***@lists.chalmers.se
>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Agda mailing list
>>>>> ***@lists.chalmers.se
>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>
>>>> --
>>>> Serge Leblanc
>>>> ------------------------------------------------------------------------
>>>> gpg --search-keys 0x67B17A3F
>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>
>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>> --
>> Serge Leblanc
>> ------------------------------------------------------------------------
>> gpg --search-keys 0x67B17A3F
>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>
Serge Leblanc
2018-08-06 16:50:44 UTC
Permalink
Thanks , Guillaume.
Now, I have a problem to print the result due to the IO functions
requesting Codata.Musical.Costring.
I fail to write a function: Costring ∞ → Codata.Musical.Costring

Dankon, Guillaume.
Nun, mi havas problemon por afiŝi la resulton pro la IO-funkcioj petas
Codata.Musical.Costring.
Mi fiaskas skribi funkcion: Costring ∞ → Codata.Musical.Costring

Sincere,

On 2018-08-05 10:24, Guillaume Allais wrote:
> Hi Serge,
>
> Using the new-style codata based on sized types which is available in the
> latest standard library, you could write something like [see below].
>
> Notice the type of `_:++_`: the second argument is a `Thunk` and because
> the string is non-empty it's fine: we can guarantee it'll be used in a
> guarded position.
>
> Cheers,
> --
> gallais
>
> ==========================================================================
> module Costring where
>
> open import Size
> open import Codata.Thunk
> open import Data.Nat as Nat
> open import Data.Char
> open import Data.String hiding (fromList ; _++_ ; _==_)
> open import Data.List as List hiding (_++_)
> open import Relation.Nullary.Decidable
> open import Data.Bool
> open import Function
>
> data Costring (i : Size) : Set where
> [] : Costring i
> _∷_ : Char → Thunk Costring i → Costring i
>
> fromList : List Char → Costring ∞
> fromList [] = []
> fromList (x ∷ xs) = x ∷ λ where .force → fromList xs
>
> toCostring : String → Costring ∞
> toCostring = fromList ∘′ toList
>
> _++_ : ∀ {i} → Costring i → Costring i → Costring i
> [] ++ ys = ys
> (x ∷ xs) ++ ys = x ∷ λ where .force → xs .force ++ ys
>
> _:++_ : ∀ {i} (str : List Char) {_ : False (List.length str Nat.≟ 0)} →
> Thunk Costring i → Costring i
> _:++_ [] {()} xs
> _:++_ (x ∷ str) {pr} xs = x ∷ λ where .force → fromList str ++ xs .force
>
> coSplit″ : ∀ {i} → Costring i → Costring i
> coSplit″ [] = []
> coSplit″ (x ∷ xs) with x == '!'
> ... | false = x ∷ λ where .force → coSplit″ (xs .force)
> ... | true = toList ">>" :++ λ where .force → coSplit″ (xs .force)
> ==========================================================================
>
> On 03/08/18 20:57, Serge Leblanc wrote:
>> Would an expert help me to improve the termination checking algorithm?
>> Does someone already work to improve the algorithm?
>>
>> Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
>> Ĉu iu jam laboras por plibonigi la algoritmon?
>>
>> Sincere
>>
>>  
>> On 2018-07-31 03:02, Serge Leblanc wrote:
>>> In my opinion, a normal form verification phase could be added without
>>> changing the termination checking algorithm.
>>> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
>>> kontrolan algoritmon.
>>>
>>> Sincere
>>>
>>>
>>> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>>> I believe that you are right that the two snippets are equivalent,
>>>> but it requires some computation to show that this is the case.
>>>> The check that Agda runs on the other hand is very syntactic. This is
>>>> indeed a limitation, but at least it ensures that checking for
>>>> termination terminates ;-)
>>>>
>>>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>>>> Right?
>>>>> So, the recursive call is well protected by a constructor.
>>>>>
>>>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>>>> xs)). Ĉu ne ?
>>>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>>>
>>>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>>> For coSplit to pass the checker, the recursive invocation must
>>>>>> appear guarded by a constructor.
>>>>>> This is clearly the case in coSplit', but not necessarily in
>>>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>>>
>>>>>>
>>>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>>>> Dear all,
>>>>>>> Why the checking termination rejects the coSplit" function
>>>>>>> although the coSplit' function is accepted ?
>>>>>>> Why the checking termination so suspicious?
>>>>>>> Sincerely
>>>>>>>
>>>>>>> Estimataj ĉiuj,
>>>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>>>> la funkcio coSplit′ trafas ?
>>>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>>>> Sincere
>>>>>>>
>>>>>>>   coSplit′ : Costring → Costring
>>>>>>>   coSplit′ [] = []
>>>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>>>
>>>>>>>   coSplit″ : Costring → Costring
>>>>>>>   coSplit″ [] = []
>>>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>>
>>>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>>>
>>>>>>> --
>>>>>>> Serge Leblanc
>>>>>>> ------------------------------------------------------------------------
>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Agda mailing list
>>>>>>> ***@lists.chalmers.se
>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Agda mailing list
>>>>>> ***@lists.chalmers.se
>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>> --
>>>>> Serge Leblanc
>>>>> ------------------------------------------------------------------------
>>>>> gpg --search-keys 0x67B17A3F
>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Agda mailing list
>>>>> ***@lists.chalmers.se
>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>
>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>> --
>>> Serge Leblanc
>>> ------------------------------------------------------------------------
>>> gpg --search-keys 0x67B17A3F
>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Guillaume Allais
2018-08-06 20:24:15 UTC
Permalink
Hi Serge,

This is how I would do it:

===============================================================
open import Coinduction using (♯_)
import Codata.Musical.Colist as CL
import Codata.Musical.Costring as CS

toMusical : Costring ∞ → CS.Costring
toMusical [] = CL.[]
toMusical (c ∷ cs) = c CL.∷ ♯ toMusical (cs .force)
===============================================================

Note that it's also probably worth replacing my ad-hoc definition of
`Costring` with `Colist Char` where `Colist` comes from `Codata.Colist`.
This way `fromList` and `_++_` are readily available. We also have
`fromMusical` but I see that we are missing `toMusical`. I'll send a PR.

Cheers,
--
gallais



On 06/08/18 18:50, Serge Leblanc wrote:
> Thanks , Guillaume.
> Now, I have a problem to print the result due to the IO functions
> requesting Codata.Musical.Costring.
> I fail to write a function: Costring ∞ → Codata.Musical.Costring
>
> Dankon, Guillaume.
> Nun, mi havas problemon por afiŝi la resulton pro la IO-funkcioj petas
> Codata.Musical.Costring.
> Mi fiaskas skribi funkcion: Costring ∞ → Codata.Musical.Costring
>
> Sincere,
>
> On 2018-08-05 10:24, Guillaume Allais wrote:
>> Hi Serge,
>>
>> Using the new-style codata based on sized types which is available in the
>> latest standard library, you could write something like [see below].
>>
>> Notice the type of `_:++_`: the second argument is a `Thunk` and because
>> the string is non-empty it's fine: we can guarantee it'll be used in a
>> guarded position.
>>
>> Cheers,
>> --
>> gallais
>>
>> ==========================================================================
>> module Costring where
>>
>> open import Size
>> open import Codata.Thunk
>> open import Data.Nat as Nat
>> open import Data.Char
>> open import Data.String hiding (fromList ; _++_ ; _==_)
>> open import Data.List as List hiding (_++_)
>> open import Relation.Nullary.Decidable
>> open import Data.Bool
>> open import Function
>>
>> data Costring (i : Size) : Set where
>> [] : Costring i
>> _∷_ : Char → Thunk Costring i → Costring i
>>
>> fromList : List Char → Costring ∞
>> fromList [] = []
>> fromList (x ∷ xs) = x ∷ λ where .force → fromList xs
>>
>> toCostring : String → Costring ∞
>> toCostring = fromList ∘′ toList
>>
>> _++_ : ∀ {i} → Costring i → Costring i → Costring i
>> [] ++ ys = ys
>> (x ∷ xs) ++ ys = x ∷ λ where .force → xs .force ++ ys
>>
>> _:++_ : ∀ {i} (str : List Char) {_ : False (List.length str Nat.≟ 0)} →
>> Thunk Costring i → Costring i
>> _:++_ [] {()} xs
>> _:++_ (x ∷ str) {pr} xs = x ∷ λ where .force → fromList str ++ xs .force
>>
>> coSplit″ : ∀ {i} → Costring i → Costring i
>> coSplit″ [] = []
>> coSplit″ (x ∷ xs) with x == '!'
>> ... | false = x ∷ λ where .force → coSplit″ (xs .force)
>> ... | true = toList ">>" :++ λ where .force → coSplit″ (xs .force)
>> ==========================================================================
>>
>> On 03/08/18 20:57, Serge Leblanc wrote:
>>> Would an expert help me to improve the termination checking algorithm?
>>> Does someone already work to improve the algorithm?
>>>
>>> Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
>>> Ĉu iu jam laboras por plibonigi la algoritmon?
>>>
>>> Sincere
>>>
>>>  
>>> On 2018-07-31 03:02, Serge Leblanc wrote:
>>>> In my opinion, a normal form verification phase could be added without
>>>> changing the termination checking algorithm.
>>>> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
>>>> kontrolan algoritmon.
>>>>
>>>> Sincere
>>>>
>>>>
>>>> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>>>> I believe that you are right that the two snippets are equivalent,
>>>>> but it requires some computation to show that this is the case.
>>>>> The check that Agda runs on the other hand is very syntactic. This is
>>>>> indeed a limitation, but at least it ensures that checking for
>>>>> termination terminates ;-)
>>>>>
>>>>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>>>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>>>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>>>>> Right?
>>>>>> So, the recursive call is well protected by a constructor.
>>>>>>
>>>>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>>>>> xs)). Ĉu ne ?
>>>>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>>>>
>>>>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>>>> For coSplit to pass the checker, the recursive invocation must
>>>>>>> appear guarded by a constructor.
>>>>>>> This is clearly the case in coSplit', but not necessarily in
>>>>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>>>>
>>>>>>>
>>>>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>>>>> Dear all,
>>>>>>>> Why the checking termination rejects the coSplit" function
>>>>>>>> although the coSplit' function is accepted ?
>>>>>>>> Why the checking termination so suspicious?
>>>>>>>> Sincerely
>>>>>>>>
>>>>>>>> Estimataj ĉiuj,
>>>>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>>>>> la funkcio coSplit′ trafas ?
>>>>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>>>>> Sincere
>>>>>>>>
>>>>>>>>   coSplit′ : Costring → Costring
>>>>>>>>   coSplit′ [] = []
>>>>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>>>>
>>>>>>>>   coSplit″ : Costring → Costring
>>>>>>>>   coSplit″ [] = []
>>>>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>>>
>>>>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>>>>
>>>>>>>> --
>>>>>>>> Serge Leblanc
>>>>>>>> ------------------------------------------------------------------------
>>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Agda mailing list
>>>>>>>> ***@lists.chalmers.se
>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Agda mailing list
>>>>>>> ***@lists.chalmers.se
>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>> --
>>>>>> Serge Leblanc
>>>>>> ------------------------------------------------------------------------
>>>>>> gpg --search-keys 0x67B17A3F
>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Agda mailing list
>>>>>> ***@lists.chalmers.se
>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Agda mailing list
>>>>> ***@lists.chalmers.se
>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>> --
>>>> Serge Leblanc
>>>> ------------------------------------------------------------------------
>>>> gpg --search-keys 0x67B17A3F
>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>
Serge Leblanc
2018-08-07 16:47:22 UTC
Permalink
HiGuillaume, the compilation fails :
Saluton Guillaume, la kompilado fiaskas :

***@serge-UX305FA:~/agda/parser$ agda --compile ./Costring.agda
Compiling Costring in /home/serge/agda/parser/Costring.agdai to
/home/serge/agda/parser/MAlonzo/Code/Costring.hs
Calling: ghc -O -o /home/serge/agda/parser/Costring -Werror
-i/home/serge/agda/parser -main-is MAlonzo.Code.Costring
/home/serge/agda/parser/MAlonzo/Code/Costring.hs --make
-fwarn-incomplete-patterns -fno-warn-overlapping-patterns
[88 of 91] Compiling MAlonzo.Code.Codata.Musical.Stream (
MAlonzo/Code/Codata/Musical/Stream.hs,
MAlonzo/Code/Codata/Musical/Stream.o )
Compilation error:

MAlonzo/Code/Codata/Musical/Stream.hs:22:18: error:
    • Expecting one fewer argument to ‘AgdaStream a0’
      Expected kind ‘k1 -> k0’, but ‘AgdaStream a0’ has kind ‘*’
    • In the type ‘AgdaStream a0 a1’
      In the type declaration for ‘T10’


On 2018-08-06 22:24, Guillaume Allais wrote:
> Hi Serge,
>
> This is how I would do it:
>
> ===============================================================
> open import Coinduction using (♯_)
> import Codata.Musical.Colist as CL
> import Codata.Musical.Costring as CS
>
> toMusical : Costring ∞ → CS.Costring
> toMusical [] = CL.[]
> toMusical (c ∷ cs) = c CL.∷ ♯ toMusical (cs .force)
> ===============================================================
>
> Note that it's also probably worth replacing my ad-hoc definition of
> `Costring` with `Colist Char` where `Colist` comes from `Codata.Colist`.
> This way `fromList` and `_++_` are readily available. We also have
> `fromMusical` but I see that we are missing `toMusical`. I'll send a PR.
>
> Cheers,
> --
> gallais
>
>
>
> On 06/08/18 18:50, Serge Leblanc wrote:
>> Thanks , Guillaume.
>> Now, I have a problem to print the result due to the IO functions
>> requesting Codata.Musical.Costring.
>> I fail to write a function: Costring ∞ → Codata.Musical.Costring
>>
>> Dankon, Guillaume.
>> Nun, mi havas problemon por afiŝi la resulton pro la IO-funkcioj petas
>> Codata.Musical.Costring.
>> Mi fiaskas skribi funkcion: Costring ∞ → Codata.Musical.Costring
>>
>> Sincere,
>>
>> On 2018-08-05 10:24, Guillaume Allais wrote:
>>> Hi Serge,
>>>
>>> Using the new-style codata based on sized types which is available in the
>>> latest standard library, you could write something like [see below].
>>>
>>> Notice the type of `_:++_`: the second argument is a `Thunk` and because
>>> the string is non-empty it's fine: we can guarantee it'll be used in a
>>> guarded position.
>>>
>>> Cheers,
>>> --
>>> gallais
>>>
>>> ==========================================================================
>>> module Costring where
>>>
>>> open import Size
>>> open import Codata.Thunk
>>> open import Data.Nat as Nat
>>> open import Data.Char
>>> open import Data.String hiding (fromList ; _++_ ; _==_)
>>> open import Data.List as List hiding (_++_)
>>> open import Relation.Nullary.Decidable
>>> open import Data.Bool
>>> open import Function
>>>
>>> data Costring (i : Size) : Set where
>>> [] : Costring i
>>> _∷_ : Char → Thunk Costring i → Costring i
>>>
>>> fromList : List Char → Costring ∞
>>> fromList [] = []
>>> fromList (x ∷ xs) = x ∷ λ where .force → fromList xs
>>>
>>> toCostring : String → Costring ∞
>>> toCostring = fromList ∘′ toList
>>>
>>> _++_ : ∀ {i} → Costring i → Costring i → Costring i
>>> [] ++ ys = ys
>>> (x ∷ xs) ++ ys = x ∷ λ where .force → xs .force ++ ys
>>>
>>> _:++_ : ∀ {i} (str : List Char) {_ : False (List.length str Nat.≟ 0)} →
>>> Thunk Costring i → Costring i
>>> _:++_ [] {()} xs
>>> _:++_ (x ∷ str) {pr} xs = x ∷ λ where .force → fromList str ++ xs .force
>>>
>>> coSplit″ : ∀ {i} → Costring i → Costring i
>>> coSplit″ [] = []
>>> coSplit″ (x ∷ xs) with x == '!'
>>> ... | false = x ∷ λ where .force → coSplit″ (xs .force)
>>> ... | true = toList ">>" :++ λ where .force → coSplit″ (xs .force)
>>> ==========================================================================
>>>
>>> On 03/08/18 20:57, Serge Leblanc wrote:
>>>> Would an expert help me to improve the termination checking algorithm?
>>>> Does someone already work to improve the algorithm?
>>>>
>>>> Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
>>>> Ĉu iu jam laboras por plibonigi la algoritmon?
>>>>
>>>> Sincere
>>>>
>>>>  
>>>> On 2018-07-31 03:02, Serge Leblanc wrote:
>>>>> In my opinion, a normal form verification phase could be added without
>>>>> changing the termination checking algorithm.
>>>>> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
>>>>> kontrolan algoritmon.
>>>>>
>>>>> Sincere
>>>>>
>>>>>
>>>>> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>>>>> I believe that you are right that the two snippets are equivalent,
>>>>>> but it requires some computation to show that this is the case.
>>>>>> The check that Agda runs on the other hand is very syntactic. This is
>>>>>> indeed a limitation, but at least it ensures that checking for
>>>>>> termination terminates ;-)
>>>>>>
>>>>>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>>>>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>>>>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>>>>>> Right?
>>>>>>> So, the recursive call is well protected by a constructor.
>>>>>>>
>>>>>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>>>>>> xs)). Ĉu ne ?
>>>>>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>>>>>
>>>>>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>>>>> For coSplit to pass the checker, the recursive invocation must
>>>>>>>> appear guarded by a constructor.
>>>>>>>> This is clearly the case in coSplit', but not necessarily in
>>>>>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>>>>>
>>>>>>>>
>>>>>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>>>>>> Dear all,
>>>>>>>>> Why the checking termination rejects the coSplit" function
>>>>>>>>> although the coSplit' function is accepted ?
>>>>>>>>> Why the checking termination so suspicious?
>>>>>>>>> Sincerely
>>>>>>>>>
>>>>>>>>> Estimataj ĉiuj,
>>>>>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>>>>>> la funkcio coSplit′ trafas ?
>>>>>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>>>>>> Sincere
>>>>>>>>>
>>>>>>>>>   coSplit′ : Costring → Costring
>>>>>>>>>   coSplit′ [] = []
>>>>>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>>>>>
>>>>>>>>>   coSplit″ : Costring → Costring
>>>>>>>>>   coSplit″ [] = []
>>>>>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>>>>
>>>>>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Serge Leblanc
>>>>>>>>> ------------------------------------------------------------------------
>>>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Agda mailing list
>>>>>>>>> ***@lists.chalmers.se
>>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Agda mailing list
>>>>>>>> ***@lists.chalmers.se
>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>> --
>>>>>>> Serge Leblanc
>>>>>>> ------------------------------------------------------------------------
>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Agda mailing list
>>>>>>> ***@lists.chalmers.se
>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>
>>>>>> _______________________________________________
>>>>>> Agda mailing list
>>>>>> ***@lists.chalmers.se
>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>> --
>>>>> Serge Leblanc
>>>>> ------------------------------------------------------------------------
>>>>> gpg --search-keys 0x67B17A3F
>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda

--
Serge Leblanc
------------------------------------------------------------------------
gpg --search-keys 0x67B17A3F
Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
Guillaume Allais
2018-08-07 19:08:23 UTC
Permalink
Wow this bug has been around since October 2016 and we somehow missed
Wen Kokke's report in February 2017.

I have pushed a fix:
https://github.com/agda/agda-stdlib/commit/81a7acad600dfe6d3958f5551e5f48432f98f1a2

Cheers,
--
gallais

On 07/08/18 18:47, Serge Leblanc wrote:
> HiGuillaume, the compilation fails :
> Saluton Guillaume, la kompilado fiaskas :
>
> ***@serge-UX305FA:~/agda/parser$ agda --compile ./Costring.agda
> Compiling Costring in /home/serge/agda/parser/Costring.agdai to
> /home/serge/agda/parser/MAlonzo/Code/Costring.hs
> Calling: ghc -O -o /home/serge/agda/parser/Costring -Werror
> -i/home/serge/agda/parser -main-is MAlonzo.Code.Costring
> /home/serge/agda/parser/MAlonzo/Code/Costring.hs --make
> -fwarn-incomplete-patterns -fno-warn-overlapping-patterns
> [88 of 91] Compiling MAlonzo.Code.Codata.Musical.Stream (
> MAlonzo/Code/Codata/Musical/Stream.hs,
> MAlonzo/Code/Codata/Musical/Stream.o )
> Compilation error:
>
> MAlonzo/Code/Codata/Musical/Stream.hs:22:18: error:
>     • Expecting one fewer argument to ‘AgdaStream a0’
>       Expected kind ‘k1 -> k0’, but ‘AgdaStream a0’ has kind ‘*’
>     • In the type ‘AgdaStream a0 a1’
>       In the type declaration for ‘T10’
>
>
> On 2018-08-06 22:24, Guillaume Allais wrote:
>> Hi Serge,
>>
>> This is how I would do it:
>>
>> ===============================================================
>> open import Coinduction using (♯_)
>> import Codata.Musical.Colist as CL
>> import Codata.Musical.Costring as CS
>>
>> toMusical : Costring ∞ → CS.Costring
>> toMusical [] = CL.[]
>> toMusical (c ∷ cs) = c CL.∷ ♯ toMusical (cs .force)
>> ===============================================================
>>
>> Note that it's also probably worth replacing my ad-hoc definition of
>> `Costring` with `Colist Char` where `Colist` comes from `Codata.Colist`.
>> This way `fromList` and `_++_` are readily available. We also have
>> `fromMusical` but I see that we are missing `toMusical`. I'll send a PR.
>>
>> Cheers,
>> --
>> gallais
>>
>>
>>
>> On 06/08/18 18:50, Serge Leblanc wrote:
>>> Thanks , Guillaume.
>>> Now, I have a problem to print the result due to the IO functions
>>> requesting Codata.Musical.Costring.
>>> I fail to write a function: Costring ∞ → Codata.Musical.Costring
>>>
>>> Dankon, Guillaume.
>>> Nun, mi havas problemon por afiŝi la resulton pro la IO-funkcioj petas
>>> Codata.Musical.Costring.
>>> Mi fiaskas skribi funkcion: Costring ∞ → Codata.Musical.Costring
>>>
>>> Sincere,
>>>
>>> On 2018-08-05 10:24, Guillaume Allais wrote:
>>>> Hi Serge,
>>>>
>>>> Using the new-style codata based on sized types which is available in the
>>>> latest standard library, you could write something like [see below].
>>>>
>>>> Notice the type of `_:++_`: the second argument is a `Thunk` and because
>>>> the string is non-empty it's fine: we can guarantee it'll be used in a
>>>> guarded position.
>>>>
>>>> Cheers,
>>>> --
>>>> gallais
>>>>
>>>> ==========================================================================
>>>> module Costring where
>>>>
>>>> open import Size
>>>> open import Codata.Thunk
>>>> open import Data.Nat as Nat
>>>> open import Data.Char
>>>> open import Data.String hiding (fromList ; _++_ ; _==_)
>>>> open import Data.List as List hiding (_++_)
>>>> open import Relation.Nullary.Decidable
>>>> open import Data.Bool
>>>> open import Function
>>>>
>>>> data Costring (i : Size) : Set where
>>>> [] : Costring i
>>>> _∷_ : Char → Thunk Costring i → Costring i
>>>>
>>>> fromList : List Char → Costring ∞
>>>> fromList [] = []
>>>> fromList (x ∷ xs) = x ∷ λ where .force → fromList xs
>>>>
>>>> toCostring : String → Costring ∞
>>>> toCostring = fromList ∘′ toList
>>>>
>>>> _++_ : ∀ {i} → Costring i → Costring i → Costring i
>>>> [] ++ ys = ys
>>>> (x ∷ xs) ++ ys = x ∷ λ where .force → xs .force ++ ys
>>>>
>>>> _:++_ : ∀ {i} (str : List Char) {_ : False (List.length str Nat.≟ 0)} →
>>>> Thunk Costring i → Costring i
>>>> _:++_ [] {()} xs
>>>> _:++_ (x ∷ str) {pr} xs = x ∷ λ where .force → fromList str ++ xs .force
>>>>
>>>> coSplit″ : ∀ {i} → Costring i → Costring i
>>>> coSplit″ [] = []
>>>> coSplit″ (x ∷ xs) with x == '!'
>>>> ... | false = x ∷ λ where .force → coSplit″ (xs .force)
>>>> ... | true = toList ">>" :++ λ where .force → coSplit″ (xs .force)
>>>> ==========================================================================
>>>>
>>>> On 03/08/18 20:57, Serge Leblanc wrote:
>>>>> Would an expert help me to improve the termination checking algorithm?
>>>>> Does someone already work to improve the algorithm?
>>>>>
>>>>> Ĉu spertulo bonvolus helpi min aldoni ŝanĝon al la finiĝokontrola algoritmo?
>>>>> Ĉu iu jam laboras por plibonigi la algoritmon?
>>>>>
>>>>> Sincere
>>>>>
>>>>>  
>>>>> On 2018-07-31 03:02, Serge Leblanc wrote:
>>>>>> In my opinion, a normal form verification phase could be added without
>>>>>> changing the termination checking algorithm.
>>>>>> Laŭ mi, normala kontrola fazo povus esti aldonita sen ŝangi la finiĝan
>>>>>> kontrolan algoritmon.
>>>>>>
>>>>>> Sincere
>>>>>>
>>>>>>
>>>>>> On 2018-07-30 20:06, a.j.rouvoet wrote:
>>>>>>> I believe that you are right that the two snippets are equivalent,
>>>>>>> but it requires some computation to show that this is the case.
>>>>>>> The check that Agda runs on the other hand is very syntactic. This is
>>>>>>> indeed a limitation, but at least it ensures that checking for
>>>>>>> termination terminates ;-)
>>>>>>>
>>>>>>> On 07/30/2018 06:04 PM, Serge Leblanc wrote:
>>>>>>>> Yes, but you translat the code (toCostring ">>") ++ coSplit "(♭ xs)
>>>>>>>> to its normal form, it equals to '>' ∷ ♯ ('>' ∷ ♯ coSplit '(♭ xs)).
>>>>>>>> Right?
>>>>>>>> So, the recursive call is well protected by a constructor.
>>>>>>>>
>>>>>>>> Jes, sed vi plenumas la kodon (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>>> ĝis sia normala formo, ĝi egalas al  '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭
>>>>>>>> xs)). Ĉu ne ?
>>>>>>>> Do, la memsinkceva alvoko estas bone ŝirmi per konstruisto.
>>>>>>>>
>>>>>>>> On 2018-07-30 16:59, a.j.rouvoet wrote:
>>>>>>>>> For coSplit to pass the checker, the recursive invocation must
>>>>>>>>> appear guarded by a constructor.
>>>>>>>>> This is clearly the case in coSplit', but not necessarily in
>>>>>>>>> coSplit'' (e.g. when toString ">>" returns the empty costring).
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 07/30/2018 04:55 PM, Serge Leblanc wrote:
>>>>>>>>>> Dear all,
>>>>>>>>>> Why the checking termination rejects the coSplit" function
>>>>>>>>>> although the coSplit' function is accepted ?
>>>>>>>>>> Why the checking termination so suspicious?
>>>>>>>>>> Sincerely
>>>>>>>>>>
>>>>>>>>>> Estimataj ĉiuj,
>>>>>>>>>> Kial la finiĝa kontrolo malakceptas la funkcion coSplit″ kvankam
>>>>>>>>>> la funkcio coSplit′ trafas ?
>>>>>>>>>> Kial la finiĝa kontrolo estas tiel malakceptanda ?
>>>>>>>>>> Sincere
>>>>>>>>>>
>>>>>>>>>>   coSplit′ : Costring → Costring
>>>>>>>>>>   coSplit′ [] = []
>>>>>>>>>>   coSplit′ (x ∷ xs) with x ≐ '!'
>>>>>>>>>>   ... | false = x ∷ ♯ coSplit′ (♭ xs)
>>>>>>>>>>   ... | true = '>' ∷ ♯ ('>' ∷ ♯ coSplit′ (♭ xs))
>>>>>>>>>>
>>>>>>>>>>   coSplit″ : Costring → Costring
>>>>>>>>>>   coSplit″ [] = []
>>>>>>>>>>   coSplit″ (x ∷ xs) with x ≐ '!'
>>>>>>>>>>   ... | false = x ∷ ♯ coSplit″ (♭ xs)
>>>>>>>>>>   ... | true = (toCostring ">>") ++ coSplit″ (♭ xs)
>>>>>>>>>>
>>>>>>>>>>   main = run $ ♯ getContents >>= λ s → ♯ (putStrLn∞ ∘ coSplit′) s
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Serge Leblanc
>>>>>>>>>> ------------------------------------------------------------------------
>>>>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Agda mailing list
>>>>>>>>>> ***@lists.chalmers.se
>>>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Agda mailing list
>>>>>>>>> ***@lists.chalmers.se
>>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>>> --
>>>>>>>> Serge Leblanc
>>>>>>>> ------------------------------------------------------------------------
>>>>>>>> gpg --search-keys 0x67B17A3F
>>>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Agda mailing list
>>>>>>>> ***@lists.chalmers.se
>>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Agda mailing list
>>>>>>> ***@lists.chalmers.se
>>>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>> --
>>>>>> Serge Leblanc
>>>>>> ------------------------------------------------------------------------
>>>>>> gpg --search-keys 0x67B17A3F
>>>>>> Fingerprint = 2B2D AC93 8620 43D3 D2C2 C2D3 B67C F631 67B1 7A3F
>>>>>
>>>>> _______________________________________________
>>>>> Agda mailing list
>>>>> ***@lists.chalmers.se
>>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>>>
>>>> _______________________________________________
>>>> Agda mailing list
>>>> ***@lists.chalmers.se
>>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>>>
>>> _______________________________________________
>>> Agda mailing list
>>> ***@lists.chalmers.se
>>> https://lists.chalmers.se/mailman/listinfo/agda
>>>
>>
>>
>> _______________________________________________
>> Agda mailing list
>> ***@lists.chalmers.se
>> https://lists.chalmers.se/mailman/listinfo/agda
>
>
>
> _______________________________________________
> Agda mailing list
> ***@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>
Loading...