Functional programming 我如何解释Coq中的条件句?
我正在使用Coq标准库中的Functional programming 我如何解释Coq中的条件句?,functional-programming,conditional,coq,theorem-proving,Functional Programming,Conditional,Coq,Theorem Proving,我正在使用Coq标准库中的ListSet模块。我不知道如何推理证明中的条件句。例如,我在下面的证明中遇到了问题。为上下文提供了定义 Fixpoint set_mem (x : A) (xs : set) : bool := match xs with | nil => false | cons y ys => match Aeq_dec x y with | left _ => true | right _ =&
ListSet
模块。我不知道如何推理证明中的条件句。例如,我在下面的证明中遇到了问题。为上下文提供了定义
Fixpoint set_mem (x : A) (xs : set) : bool :=
match xs with
| nil => false
| cons y ys =>
match Aeq_dec x y with
| left _ => true
| right _ => set_mem x ys
end
end.
Definition set_In : A -> set -> Prop := In (A := A).
Lemma set_mem_correct1 : forall (x : A) (xs : set),
set_mem x xs = true -> set_In x xs.
Proof. intros. induction xs.
discriminate.
simpl; destruct Aeq_dec with a x.
intuition.
simpl in H.
当前证明状态包括Aeq_dec
的inr
作为假设。我已经放弃了归纳的基本情况和归纳的情况,其中Aeq_dec
的inl
为真
A : Type
Aeq_dec : forall x y : A, {x = y} + {x <> y}
x : A
a : A
xs : list A
H : (if Aeq_dec x a then true else set_mem x xs) = true
IHxs : set_mem x xs = true -> set_In x xs
n : a <> x
============================
a = x \/ set_In x xs
A:Type
Aeq_dec:forall xy:A,{x=y}+{xy}
x:A
a:a
xs:list A
H:(如果Aeq_dec x a则为真,否则设置_mem x xs)=真
IHxs:set_mem x xs=true->set_In x xs
n:一个x
============================
a=x\/set_在x xs中
如果a x
为真,则H
为真的唯一方法是set_mem xs
为真。我应该能够将H
中的条件应用于a x
,以获得set\u mem xs
。然而,我不明白该怎么做。我该如何处理、分解或应用条件句?你试过这个吗?(语法可能有问题,这里没有coqtop)
(
如果
与匹配差不多。您必须减少(析构函数
,大小写
,…)以便确定匹配(或者对于如果
,则必须减少到使用它的任何类型的第一个或第二个构造函数。)大多数情况下,您将需要进行案例分析的值(虽然不在这里)。如果需要,请执行记住()作为foo;destruct foo
,而不是直接销毁。)我相信我理解。tractic destruct(Aeq_dec)
销毁H
中的总和,为总和的左分支和右分支生成两个子目标。第一种情况产生了相互矛盾的假设,是微不足道的;第二部分介绍归纳假说的前因。我没有意识到我可以破坏嵌套在假设中的总和。谢谢你指出这一点。
destruct (Aeq_dec x a);
[ subst; elim (n eq_refl)
| right; apply (IHxs H)
].