对目标类型的子项进行策略性抽象
作为一个粗略且未经训练的背景,在 HoTT 中,人们从归纳定义的类型中推断出
Inductive paths {X : Type } : X -> X -> Type :=
| idpath : forall x: X, paths x x.
它允许非常一般的
Lemma transport {X : Type } (P : X -> Type ){ x y : X} (γ : paths x y):
P x -> P y.
Proof.
induction γ.
exact (fun a => a).
Defined.
构造引理传输
将是HoTT“替换”或“重写”策略的核心;据我所知,诀窍是,假设你或我可以抽象地认识到一个目标,即
...
H : paths x y
[ Q : (G x) ]
_____________
(G y)
找出必要的依赖类型 G,以便我们可以应用(传输 GH)
。到目前为止,我发现这
Ltac transport_along γ :=
match (type of γ) with
| ?a ~~> ?b =>
match goal with
|- ?F b => apply (transport F γ)
| _ => idtac "apparently couldn't abstract" b "from the goal." end
| _ => idtac "Are you sure" γ "is a path?" end.
还不够普遍。也就是说,第一个idtac
使用得相当频繁。
问题是
[有没有|什么是]正确的做法?
As a rough and untutored background, in HoTT, one deduces the heck out of the inductively defined type
Inductive paths {X : Type } : X -> X -> Type :=
| idpath : forall x: X, paths x x.
which allows the very general construction
Lemma transport {X : Type } (P : X -> Type ){ x y : X} (γ : paths x y):
P x -> P y.
Proof.
induction γ.
exact (fun a => a).
Defined.
The Lemma transport
would be at the heart of HoTT "replace" or "rewrite" tactics; the trick, so far as I understand it, would be, supposing a goal which you or I can abstractly recognize as
...
H : paths x y
[ Q : (G x) ]
_____________
(G y)
to figure out what is the necessary dependent type G, so that we can apply (transport G H)
. So far, all I've figured out is that
Ltac transport_along γ :=
match (type of γ) with
| ?a ~~> ?b =>
match goal with
|- ?F b => apply (transport F γ)
| _ => idtac "apparently couldn't abstract" b "from the goal." end
| _ => idtac "Are you sure" γ "is a path?" end.
isn't general enough. That is, the first idtac
gets used rather often.
The question is
[Is there a | what is the] Right Thing to Do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于对类型中的关系使用重写,存在一个 bug,这会允许你只说
rewrite <- y.
同时,
可能会做你想做的事情。
There is a bug about using rewrite for relations in type, which would allow you to just say
rewrite <- y.
In the mean time,
probably does what you want.
Tom Prince 在他的回答中提到的功能请求已获得批准:
我通过比较获得的日志找到了所需的实例当
H : paths x y
和当H : eq x 时,从
y 。setoid_rewrite <- H
设置类型类调试The feature request mentioned by Tom Prince in his answer has been granted:
I found the required instances by comparing the logs I got with
Set Typeclasses Debug
fromsetoid_rewrite <- H
whenH : paths x y
and whenH : eq x y
.