Types Coq:在环境中显示一个或多个类型中的所有术语

Types Coq:在环境中显示一个或多个类型中的所有术语,types,coq,Types,Coq,有没有一种方法可以在环境中显示一个类型中的所有术语或一个宇宙中的所有类型 Print Set. (*Syntax error: 'Firstorder' 'Solver' expected after 'Print' (in [vernac:command]).*) 不,Coq中没有此类功能打印将仅显示给定术语的正文,例如: Print plus. plus = fix plus (n m : nat) {struct n} : nat := match n with | 0 =&g

有没有一种方法可以在环境中显示一个类型中的所有术语或一个宇宙中的所有类型

Print Set. (*Syntax error: 'Firstorder' 'Solver' expected after 'Print' (in [vernac:command]).*)

不,Coq中没有此类功能<代码>打印将仅显示给定术语的正文,例如:

Print plus.
plus = 
fix plus (n m : nat) {struct n} : nat :=
  match n with
  | 0 => m
  | S p => S (plus p m)
  end
     : nat -> nat -> nat

Argument scopes are [nat_scope nat_scope]

如果您所说的环境是指验证环境,那么以下用户定义的策略就可以做到这一点

Ltac printInType t :=
  match goal with
    | [ H : t |- _ ] =>
      idtac H; fail
    | _ => idtac
  end
.

Theorem test : forall n m, n + m = m + n.
Proof.
  intros.
  printInType nat.
  (* prints in the Message window:
     m
     n
  *)
  printInType Set.
  (* prints nothing
     because nat for instance is not explicitely in the proof environment *)

它所做的就是通过证明环境,找到一个具有参数类型
t
的假设或变量
idtac H
打印它,然后分支由于策略而失败。现在,Coq在不同的假设/变量上再次尝试相同的分支,因此所有这些假设/变量最终都被打印出来。现在,第二个分支是idtac,以确保策略最终成功。如果该分支不存在,策略将失败并出现错误,并且在打印错误时,Coq将删除它以前打印的信息。

您可以使用搜索来获得近似值。你可以做:

Search $Type.
并使用type
$type
获取结果。比如说,

Search nat -(forall _, _).
将显示类型
nat
的所有术语

Search Set -(forall _, _).
将显示类型
Set
的所有非功能术语。
SearchPattern
应该提供类似的功能,但我不确定。Ssreflect搜索可以做到这一点,甚至更多。

我的问题不仅仅是关于证明环境,而且这是有用的对不起@jaam,你是什么意思?+n表单在我的设置中不起作用。因此不允许以w/+1开头的注释,因此…:)啊!!我以为你想用搜索命令中的
+n
替换
-(…)