首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"printf-debugging“在Ltac中是可能的吗?

"printf-debugging“在Ltac中是可能的吗?
EN

Stack Overflow用户
提问于 2018-10-26 04:08:09
回答 1查看 187关注 0票数 2

有没有办法在Ltac过程中间打印变量(无论是假设、策略还是术语)的值?

EN

回答 1

Stack Overflow用户

发布于 2018-10-26 10:00:25

是的,使用idtac策略。

您可以向idtac传递一个要打印的常量字符串。如果您进行模式匹配,它还可以打印标识符(如假设名称),如果您通过模式匹配或type of访问它们,它还可以打印它们的类型。您还可以打印术语或Ltac let绑定变量的内容。最后,您可以向idtac传递多个参数以将它们全部打印出来。您提到了打印策略-不幸的是,这是您不能使用idtac打印的一件事。如果你试着这样做,你只会得到。

这里有一大堆例子:

Goal True -> False. intro Htrue. idtac "hello world". (* prints hello world *) match goal with | [ H: True |- _ ] => idtac H (* prints Htrue *) end. match goal with | |- ?g => idtac g (* prints False *) end. let t := type of Htrue in idtac t. (* prints True *) let x := constr:(1 + 1) in idtac x. (* prints (1 + 1) *) idtac "hello" "there". (* prints hello there *) (* note that this is an Ltac-level function, not a Gallina function *) let x := (fun _ => fail) in idtac x. (* prints <tactic closure> *) Abort.

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52997319

复制
相关文章

相似问题

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