Coq 在使用介绍模式时,是否可能保留原始假设
我有一个涉及相依对(sigT)的定理。其目标如下所示:Coq 在使用介绍模式时,是否可能保留原始假设,coq,coq-tactic,Coq,Coq Tactic,我有一个涉及相依对(sigT)的定理。其目标如下所示: -------------------------------------------- forall x : {x : G | P x}, mult1 sub_e x = x 当我运行intros[x Px]。时,以下内容被添加到上下文中: x : G Px : P x x : G Px : P x x_pair := exist P x Px : {x : G | P x} 是否可以将依赖对的变量作为一个整体保留?我必须运行set
--------------------------------------------
forall x : {x : G | P x}, mult1 sub_e x = x
当我运行intros[x Px]。
时,以下内容被添加到上下文中:
x : G
Px : P x
x : G
Px : P x
x_pair := exist P x Px : {x : G | P x}
是否可以将依赖对的变量作为一个整体保留?我必须运行set(x_对:=existp x Px)。
将其放入上下文:
x : G
Px : P x
x : G
Px : P x
x_pair := exist P x Px : {x : G | P x}
不使用额外命令是否可以执行此操作?这里有一种方法:定义一个包含重复信息的记录,使用
%
介绍模式构建此记录的值,然后销毁它:
(* sing_copy contains a copy of the value sing_val *)
Record Sing A := sing { sing_val : A ; sing_copy := sing_val }.
Arguments sing {A} _.
Variable X : Type.
Variable P : X -> Prop.
Goal forall z : { x : X | P x }, bool.
Proof.
intros [[x Hx] x_pair]%sing.
然而,这似乎不适用于取决于要破坏的值的目标。在这种情况下,这里有2-3种相对简单且更可靠的方法来实现相同的目标
Definition dupl {A B} (f : forall (a : A), let x := a in B a) : forall a : A, B a := f.
Ltac add_let :=
change (forall a : ?A, @?B a) with (forall a : A, let z := a in B a).
Variable X : Type.
Variable P : X -> Prop.
Goal { x : X | P x } -> bool.
Proof.
(* intro the term, duplicate it before destructing it *)
intros z; pose (x_pair := z); destruct z as [x Hx].
Restart.
(* duplicate before using an intro pattern *)
apply dupl; intros [x Hx] x_pair.
Restart.
(* same thing using change instead of the application of a lemma *)
add_let ; intros [x Hx] x_pair.