在 coq 中,我可以为成分是对的协推类型定义等式关系:
Section Pairs.
Variable (A:Type).
CoInductive Stream :=
cons : (A * Stream) -> Stream.
CoInductive Stream_eq : Stream -> Stream -> Prop :=
stream_eq : forall t1 t2 b1 b2, Stream_eq (t1) (t2)
-> (b1 = b2)
-> Stream_eq (cons (b1,t1)) (cons (b2,t2)).
End Pairs.
我也可以对组件是函数的类型执行此操作:
Section Functions.
Variable (A:Type).
CoInductive Useless :=
cons_useless : (A -> Useless) -> Useless.
CoInductive Useless_eq : Useless -> Useless -> Prop :=
useless_eq : forall t1 t2, (forall b, Useless_eq (t1 b) (t2 b))
-> Useless_eq (cons_useless t1) (cons_useless t2).
End Functions.
但我似乎无法为其组件是函数对的类型定义类似的关系:
Section FunctionsToPairs.
Variable (A:Type).
Variable (B:Type).
CoInductive InfiniteTree :=
cons_tree : (A -> B * InfiniteTree) -> InfiniteTree.
CoInductive Tree_eq : InfiniteTree -> InfiniteTree -> Prop :=
tree_eq : forall (t1:A -> B*InfiniteTree) (t2:A -> B*InfiniteTree),
(forall b, let (a1, c1) := (t1 b) in
let (a2, c2) := (t2 b) in Tree_eq c1 c2 /\ a1 = a2)
-> Tree_eq (cons_tree t1) (cons_tree t2).
End FunctionsToPairs.
我得到错误:
Non strictly positive occurrence of "Tree_eq" in
"forall t1 t2 : A -> B * InfiniteTree,
(forall b : A, let (a1, c1) := t1 b in let (a2, c2) := t2 b in Tree_eq c1 c2 /\ a1 = a2) ->
Tree_eq (cons_tree t1) (cons_tree t2)".
有什么方法可以为 InfiniteTree 类型定义明确的相等关系?