Variables A B : Prop.
Theorem proj1 : A /\ B -> A.
为了学习,我试图通过使用and_ind
明确写下证明项来证明该定理。
我认为正确的证明条件是
fun (H : A /\ B) => and_ind A B A (fun a _ => a) H
但这会引发错误,而正确的术语是
fun (H : A /\ B) => and_ind (fun a _ => a) H
我不明白。 and_ind
的定义是
and_ind =
fun (A B P : Prop) (f : A -> B -> P) (a : A /\ B) => match a with
| conj x x0 => f x x0
end
: forall A B P : Prop, (A -> B -> P) -> A /\ B -> P
如何从中看出必须忽略参数(A B P : Prop)
?
“应用”规则
《参考手册》中的似乎清楚地表明,必须使用我尝试过的函数应用程序语法来明确地“实例化”量化的变量。
答案 0 :(得分:2)
在Coq中,您可以将函数的某些参数声明为隐式。调用该函数时,不会为隐式参数提供值; Coq根据类型检查期间可用的其他信息自动尝试推断合适的值。 A
的{{1}},B
和P
参数都声明为隐式的,并且可以根据and_ind
参数的类型和结果类型来推断函数参数的值。
您可以看到H
命令认为哪些参数是隐式的:
About
您可以通过带有About and_ind.
(* and_ind : forall A B P : Prop, (A -> B -> P) -> A /\ B -> P *)
(* Arguments A, B, P are implicit *)
(* Argument scopes are [type_scope type_scope type_scope function_scope _] *)
(* and_ind is transparent *)
(* Expands to: Constant Coq.Init.Logic.and_ind *)
符号的单个调用来关闭隐式参数:
@
(请注意,Coq在打印术语时也会自动省略隐式参数。)
Coq manual拥有关于该主题的更多信息。