智能修改Coq环境
Smart modification of Coq environment
Ltac 用于 automating proofs and modifying proof environment, outputting strings and 。它也可以用于 "smart" Coq 环境的修改吗?这是两次失败的尝试:
Variable Phy: Set.
Fail Let pp (x:Type) := ltac: (match type of x with
| Set => constr: (Reset Phy)
| _ => idtac end).
(*Cannot infer an internal placeholder of type "Type" in environment: x : Type*)
Fail Ltac pp x := match type of x with
| Set => constr: (Reset Phy)
| _ => idtac end.
(*The reference Reset was not found in the current environment.*)
此外,如果这不是 Ltac 的工作,也许还有其他方法?
简答:否
即使您使用一些 hack 来做到这一点,它也会在下一个 Coq 版本中停止工作。
原因是 ltac 命令的解释发生在比文档解释更低的级别。这个选择可能值得商榷,但它就是这样。攻略运行在不断的环境中,只能获得证明。因此,你最多可以从 ltac 做的是修改当前证明。
您的错误发生是因为 Reset
确实在 ltac 无法访问的更高级别进行了解析。
对于环境和文档本身的编程操作,您需要依赖 ML 代码,或者您可以尝试编写一些接口工具(例如 SerAPI)的脚本来实现您想要的。
Ltac 用于 automating proofs and modifying proof environment, outputting strings and
Variable Phy: Set.
Fail Let pp (x:Type) := ltac: (match type of x with
| Set => constr: (Reset Phy)
| _ => idtac end).
(*Cannot infer an internal placeholder of type "Type" in environment: x : Type*)
Fail Ltac pp x := match type of x with
| Set => constr: (Reset Phy)
| _ => idtac end.
(*The reference Reset was not found in the current environment.*)
此外,如果这不是 Ltac 的工作,也许还有其他方法?
简答:否
即使您使用一些 hack 来做到这一点,它也会在下一个 Coq 版本中停止工作。
原因是 ltac 命令的解释发生在比文档解释更低的级别。这个选择可能值得商榷,但它就是这样。攻略运行在不断的环境中,只能获得证明。因此,你最多可以从 ltac 做的是修改当前证明。
您的错误发生是因为 Reset
确实在 ltac 无法访问的更高级别进行了解析。
对于环境和文档本身的编程操作,您需要依赖 ML 代码,或者您可以尝试编写一些接口工具(例如 SerAPI)的脚本来实现您想要的。