(* I have a section with many variables and definitions. *)
Section SectionWithDefs.
Context {A B C: Type}.
Variable arg1: A -> B.
Variable arg2: B -> C.
(* Functions that uses these variables. *)
Definition f a := arg2 (arg1 a).
...
End SectionWithDefs.
(* Now I want to use some of these functions. *)
Section AnotherSection.
Context {A B C: Type}.
(* Here are the arguments. *)
Variable arg1: A -> B.
Variable arg2: B -> C.
Variable a: A.
Section CallFunctionWithArgiments.
(* We can directly pass the arguments to the function...*)
Eval compute in (f arg1 arg2 a).
End CallFunctionWithArgiments.
Section LetBlock.
(* ... or we can create a sequence of let expression. *)
Let f := f arg1 arg2.
...
Eval compute in (f a).
End LetBlock.
End AnotherSection.
使用第一种方法确实很困难,因为维护此类代码非常困难。如果有五个以上的不同函数,每个函数有4-5个参数,则编写起来会很痛苦。
第二种情况更方便。但是我还有很多额外的“ let”声明行:
Let f1 := ...
Let f2 := ...
...
Let fn := ...
有什么办法可以避免这种多余的样板?理想情况下,我希望Coq只是在上下文中使用类型甚至术语名称来“猜测”正确的参数。
答案 0 :(得分:1)
如果上下文(即if
,[]
等的列表足够简单),则可以使用类型类来不必传递参数。
arg1