考虑以下发展:
Require Import Relation RelationClasses.
Set Implicit Arguments.
CoInductive stream (A : Type) : Type :=
| scons : A -> stream A -> stream A.
CoInductive stream_le (A : Type) {eqA R : relation A}
`{PO : PartialOrder A eqA R} :
stream A -> stream A -> Prop :=
| le_step : forall h1 h2 t1 t2, R h1 h2 ->
(eqA h1 h2 -> stream_le t1 t2) ->
stream_le (scons h1 t1) (scons h2 t2).
如果我有一个假设stream_le (scons h1 t1) (scons h2 t2)
,那么将destruct
其转化为一对假设R h1 h2
和的策略是合理的eqA h1 h2 -> stream_le t1 t2
。但这不是发生的事情,因为destruct
每当做任何不平凡的事情时都会丢失信息。相反,新术语h0
, h3
, t0
,t3
被引入上下文中,但不记得它们分别等于h1
, h2
, t1
, t2
。
我想知道是否有一种快速简便的方法可以做到这种“智能destruct
”。这是我现在拥有的:
Theorem stream_le_destruct : forall (A : Type) eqA R
`{PO : PartialOrder A eqA R} (h1 h2 : A) (t1 t2 : stream A),
stream_le (scons h1 t1) (scons h2 t2) ->
R h1 h2 /\ (eqA h1 h2 -> stream_le t1 t2).
Proof.
intros.
destruct H eqn:Heq.
remember (scons h1 t1) as s1 eqn:Heqs1;
remember (scons h2 t2) as s2 eqn:Heqs2;
destruct H;
inversion Heqs1; subst; clear Heqs1;
inversion Heqs2; subst; clear Heqs2.
split; assumption.
Qed.