Closed DmytroMitin closed 7 years ago
This seems to be a problem with the actual induction code, not .fansi (even the expanded form in map(Nat)(Nat)(succ)(list)
has f
in the expression, but all instances should be replaced by succ
. Looks as if some nested replace is not going deep enough.
There is already some problem with substitution of the introduction rules, e.g., with the list example above.
(A :~> (a :-> (as :-> (bs :-> cons(B)(g(a))(bs) )))).replace(g, f).fansi
res77: String = "(A : π° ) β¦ (a : A) β¦ (as : List(A)) β¦ (bs : List(B)) β¦ cons(B)(g(a))(bs)"
we should have f
in place of g
in the result.
On the other hand, as expected:
( (a :-> (as :-> (bs :-> cons(B)(g(a))(bs) )))).replace(g, f).fansi
res80: String = "(a : A) β¦ (as : List(A)) β¦ (bs : List(B)) β¦ cons(B)(f(a))(bs)"
The difference appears to be the appearance of A
, which is an index.
The above is actually expected behaviour, as A
gets replaced by A.newobj
so g
is also changed in the closure of this. This seems to be the behaviour in all the examples, where f
. op
etc are used in a lambda and one defines a lambda in terms of these.
It appears the correct way would be to define, for example
val f = "f" :: A ~>: (B ~>:(A ->: B)))
and then use f(A)(B)
etc while making definitions. I have not tested this.
Concretely, if f
has domain A
, or more generally depends on A
, then the nesting f :~> ...A ~>: ... f( )
is not valid. One should instead make f
a function of its domain and apply A
.
Yes, with last changes this works. Thanks.
Thanks a lot. You are now the expert on working concretely with my HoTT implementation (ahead of me). As usual, pull requests are gratefully accepted.
best regards, Siddhartha
On Tue, Feb 28, 2017 at 4:22 PM Dmytro Mitin notifications@github.com wrote:
Yes, with last changes this works. Thanks.
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/siddhartha-gadgil/ProvingGround/issues/113#issuecomment-283007662, or mute the thread https://github.com/notifications/unsubscribe-auth/ADatpJsrJwZPAMyLMMCL-8zvFrjDZ5xlks5rg_xPgaJpZM4MMDfv .
After
map(Nat)(Nat)(succ)(list).fansi
producescons(Nat)(f(0))(cons(Nat)(f(succ(0)))(cons(Nat)(f(succ(succ(0))))(nil(Nat))))
rather thancons(Nat)(succ(0))(cons(Nat)(succ(succ(0)))(cons(Nat)(succ(succ(succ(0))))(nil(Nat))))
After
filter(Nat)(isEven)(list).fansi
produces(((<function1>) ((p : ((Nat : π° _0) β (Boolean : π° _0))) (0 : (Nat : π° _0)) : (Boolean : π° _0)) : (((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0) β (((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0) β ((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0)))) ((((cons : ($i : π° _0 ~> ($i : π° _0) β (((List : ((π° _0) β (π° _0))) ($i : π° _0) : π° _0) β ((List : ((π° _0) β (π° _0))) ($i : π° _0) : π° _0)))) (Nat : π° _0) : ((Nat : π° _0) β (((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0) β ((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0)))) (0 : (Nat : π° _0)) : (((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0) β ((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0))) ((((<function1>) ((p : ((Nat : π° _0) β (Boolean : π° _0))) ((succ : ((Nat : π° _0) β (Nat : π° _0))) (0 : (Nat : π° _0)) : (Nat : π° _0)) : (Boolean : π° _0)) : (((List : ((π° _0) β (π° _0))) (Nat : π° _0) : π° _0) β (((List : ((π° _0) β (π° _0))) (Nat : π° _...
rather thancons(Nat)(zero)(cons(Nat)(two)(nil(Nat)))
After
foldl(Nat)(Nat)(add)(zero)(list).fansi
produces(seed : Nat) β¦ op(op(op(seed)(0))(succ(0)))(succ(succ(0)))
rather thansucc(succ(succ(0)))
After
foldr(Nat)(Nat)(add)(zero)(list).fansi
producesop(0)(op(succ(0))(op(succ(succ(0)))(0)))
rather thansucc(succ(succ(0)))