首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:在当前环境中找不到引用fst。

错误:在当前环境中找不到引用fst。
EN

Stack Overflow用户
提问于 2017-10-08 16:25:11
回答 2查看 926关注 0票数 2

我正在编写一个小程序,这样我就可以使用deMorgans书(et )中的类型介绍/消除规则对HoTT定律进行一些证明。(A.)我的模型/示例代码都在这里,Coq.pdf。到目前为止,

代码语言:javascript
复制
Definition idmap {A:Type} (x:A) : A := x.

Inductive prod (A B:Type) : Type := pair : A -> B -> @prod A B.

Notation "x * y" := (prod x y) : type_scope.

Notation "x , y" := (pair _ _ x y) (at level 10).

Section projections.
  Context {A : Type} {B : Type}.
  Definition fst (p: A * B ) :=
    match p with
      | (x , y) => x
    end.

  Definition snd (p:A * B ) :=
    match p with
      | (x , y) => y
    end.
End projections.

Inductive sum (A B : Type ) : Type :=
  | inl : A -> sum A B
  | inr : B -> sum A B.

Arguments inl {A B} _ , [A] B _.
Arguments inr {A B} _ , A [B].

Notation "x + y" := (sum x y) : type_scope.

Inductive Empty_set:Set :=.

Inductive unit:Set := tt:unit.

Definition Empty := Empty_set.
Definition Unit := unit.

Definition not (A:Type) : Type := A -> Empty.
Notation "~ x" := (not x) : type_scope.

Variables X:Type.
Variables Y:Type.

Goal (X * Y) -> (not X + not Y).
intro h. fst h.

现在我不知道问题出在哪里了。我有使用定义的人的例子,但是它们总是涉及“计算”命令,我想将规则fst应用到h以获得x:X,所以它们是没有帮助的。

我试过“申请fst”这让我

代码语言:javascript
复制
Error: Cannot infer the implicit parameter B of fst whose type is
"Type" in environment:
h : A * B
EN

回答 2

Stack Overflow用户

发布于 2017-10-08 20:59:53

在证明上下文中,Coq希望得到执行的策略,而不是要评估的表达式。因为fst没有被定义为一种策略,所以它将给Error: The reference fst was not found in the current environment.

按照你似乎想要做的方式执行的一个可能的策略是set

代码语言:javascript
复制
set (x := fst h).
票数 3
EN

Stack Overflow用户

发布于 2017-10-08 22:11:53

我想把第f条规则应用到h上,得到x:X。

我相信你能做到

代码语言:javascript
复制
apply fst in h.

如果只编写apply fst,Coq将将fst规则应用于目标,而不是h。如果你写fst h,正如丹尼尔在他的回答中所说,Coq将尝试运行fst策略,这是不存在的。除了丹尼尔的set解决方案(如果fst h出现在其中将改变目标)之外(这可能是您想要的,也可能不是您想要的),下面的解决方案也有效:

代码语言:javascript
复制
pose (fst h) as x. (* adds x := fst h to the context *)
pose proof (fst h) as x. (* adds opaque x : X to the context, justified by the term fst h *)
destruct h as [x y]. (* adds x : X and y : Y to the context, and replaces h with pair x y everywhere *)
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46633358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档