* How to define w types in agda?
@ 2018-01-25 16:26 du yu
2018-01-26 2:38 ` [HoTT] " Favonia
0 siblings, 1 reply; 3+ messages in thread
From: du yu @ 2018-01-25 16:26 UTC (permalink / raw)
To: Homotopy Type Theory
[-- Attachment #1.1: Type: text/plain, Size: 560 bytes --]
I have the following initial thoughts but can't work out to define zero as
a w type
data Zro : Set where
data One : Set where
O1 : One
data Two : Set where
O2 : Two
I2 : Two
-- w types
rec2 : (x y : Set) -> Two -> Set
rec2 x _ O2 = x
rec2 _ y I2 = y
data W (A : Set) (B : A -> Set) : Set where -- well founded trees
w : (s : A) -> B s -> W A B
sup : (a : A) -> ((B a) -> ((x : A) -> W A B )) -> W A B
natw : Set
natw = W Two (rec2 Zro One) -- nat type as w type
zero_w : natw
zero_w = sup O2 (λ x y → {!!})
[-- Attachment #1.2: Type: text/html, Size: 896 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [HoTT] How to define w types in agda?
2018-01-25 16:26 How to define w types in agda? du yu
@ 2018-01-26 2:38 ` Favonia
2018-01-26 8:50 ` du yu
0 siblings, 1 reply; 3+ messages in thread
From: Favonia @ 2018-01-26 2:38 UTC (permalink / raw)
To: du yu; +Cc: Homotopy Type Theory
[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]
Hello,
The first argument to the function is of type Zro, and you can use the
absurd pattern to define such a function. See
http://agda.readthedocs.io/en/v2.5.3/language/function-definitions.html#absurd-patterns
.
However, there is a bigger issue---your W type seems wrong. At least I do
not see why it is equivalent to the standard presentation. See
https://github.com/agda/agda-stdlib/blob/master/src/Data/W.agda for a
correct implementation in the standard library.
Hope this helps.
Best,
Favonia
On Thu, Jan 25, 2018 at 11:26 AM du yu <doof...@gmail.com> wrote:
> I have the following initial thoughts but can't work out to define zero as
> a w type
>
> data Zro : Set where
>
> data One : Set where
> O1 : One
>
> data Two : Set where
> O2 : Two
> I2 : Two
> -- w types
>
> rec2 : (x y : Set) -> Two -> Set
> rec2 x _ O2 = x
> rec2 _ y I2 = y
>
>
> data W (A : Set) (B : A -> Set) : Set where -- well founded trees
> w : (s : A) -> B s -> W A B
> sup : (a : A) -> ((B a) -> ((x : A) -> W A B )) -> W A B
>
> natw : Set
> natw = W Two (rec2 Zro One) -- nat type as w type
>
> zero_w : natw
> zero_w = sup O2 (λ x y → {!!})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Homotopy Type Theory" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to HomotopyTypeThe...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
[-- Attachment #2: Type: text/html, Size: 2502 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [HoTT] How to define w types in agda?
2018-01-26 2:38 ` [HoTT] " Favonia
@ 2018-01-26 8:50 ` du yu
0 siblings, 0 replies; 3+ messages in thread
From: du yu @ 2018-01-26 8:50 UTC (permalink / raw)
To: Homotopy Type Theory
[-- Attachment #1.1: Type: text/plain, Size: 1866 bytes --]
Wow thanks! I don't know it is already defined in stdlib (google search
gives none!). As a beginner for dependent types , the data type definition
is quite confusing sometimes!
On Friday, January 26, 2018 at 10:38:39 AM UTC+8, Favonia wrote:
>
> Hello,
>
> The first argument to the function is of type Zro, and you can use the
> absurd pattern to define such a function. See
> http://agda.readthedocs.io/en/v2.5.3/language/function-definitions.html#absurd-patterns
> .
>
> However, there is a bigger issue---your W type seems wrong. At least I do
> not see why it is equivalent to the standard presentation. See
> https://github.com/agda/agda-stdlib/blob/master/src/Data/W.agda for a
> correct implementation in the standard library.
>
> Hope this helps.
>
> Best,
> Favonia
>
> On Thu, Jan 25, 2018 at 11:26 AM du yu <doo...@gmail.com <javascript:>>
> wrote:
>
>> I have the following initial thoughts but can't work out to define zero
>> as a w type
>>
>> data Zro : Set where
>>
>> data One : Set where
>> O1 : One
>>
>> data Two : Set where
>> O2 : Two
>> I2 : Two
>> -- w types
>>
>> rec2 : (x y : Set) -> Two -> Set
>> rec2 x _ O2 = x
>> rec2 _ y I2 = y
>>
>>
>> data W (A : Set) (B : A -> Set) : Set where -- well founded trees
>> w : (s : A) -> B s -> W A B
>> sup : (a : A) -> ((B a) -> ((x : A) -> W A B )) -> W A B
>>
>> natw : Set
>> natw = W Two (rec2 Zro One) -- nat type as w type
>>
>> zero_w : natw
>> zero_w = sup O2 (λ x y → {!!})
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Homotopy Type Theory" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to HomotopyTypeThe...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
[-- Attachment #1.2: Type: text/html, Size: 4414 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-26 8:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25 16:26 How to define w types in agda? du yu
2018-01-26 2:38 ` [HoTT] " Favonia
2018-01-26 8:50 ` du yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).