作为一个粗略和未经指导的背景,在HoTT中,人们从归纳定义的类型中推导出了heck
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.Lemma transport将是HoTT“替换”或“重写”策略的核心;据我所知,诀窍是假设一个您或我可以抽象地识别为
...
H : paths x y
[ Q : (G x) ]
_____________
(G y)找出什么是必要的依赖类型G,这样我们就可以apply (transport G H)了。到目前为止,我所想出来的就是
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经常被使用。
问题是
有没有|正确的做法是什么?
发布于 2012-02-22 11:21:23
对于类型中的关系使用重写有一个bug,它允许您只使用rewrite <- y.
同时,
Ltac transport_along γ :=
match (type of γ) with
| ?a ~~> ?b => pattern b; apply (transport _ y)
| _ => idtac "Are you sure" γ "is a path?"
end.可能是你想要的。
发布于 2017-09-30 02:46:01
汤姆·普林斯在his answer中提到的功能请求已经被批准:
Require Import Coq.Setoids.Setoid Coq.Classes.CMorphisms.
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.
Global Instance paths_Reflexive {A} : Reflexive (@paths A) := idpath.
Global Instance paths_Symmetric {A} : Symmetric (@paths A).
Proof. intros ?? []; constructor. Defined.
Global Instance proper_paths {A} (x : A) : Proper paths x := idpath x.
Global Instance paths_subrelation
(A : Type) (R : crelation A)
{RR : Reflexive R}
: subrelation paths R.
Proof.
intros ?? p.
apply (transport _ p), RR.
Defined.
Global Instance reflexive_paths_dom_reflexive
{B} {R' : crelation B} {RR' : Reflexive R'}
{A : Type}
: Reflexive (@paths A ==> R')%signature.
Proof. intros ??? []; apply RR'. Defined.
Goal forall (x y : nat) G, paths x y -> G x -> G y.
intros x y G H Q.
rewrite <- H.
exact Q.
Qed.我通过比较从setoid_rewrite <- H获得的Set Typeclasses Debug、when H : paths x y和when H : eq x y获得的日志,找到了所需的实例。
https://stackoverflow.com/questions/9014073
复制相似问题