首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ltac中使用类型参数?

如何在ltac中使用类型参数?
EN

Stack Overflow用户
提问于 2019-04-02 04:37:34
回答 1查看 82关注 0票数 1

我正在尝试编写以下函数:

代码语言:javascript
复制
Ltac restore_dims :=
  repeat match goal with
  | [ |- context[@Mmult ?m ?n ?o ?A ?B]] => let Matrix m' n' := type of A in 
                                           let Matrix n'' o' := type of B in 
                                           replace m with m' by easy
         end.

也就是说,我想在我的Ltac中使用关于A和B的类型的信息(它们都是带有2维参数的矩阵)。这是可能的吗?如果可能,是如何实现的?

(理想情况下,这将用m'替换有问题的m,对于我目标中的所有矩阵产品,no也是如此。)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-02 09:00:25

您可以在type of A上执行语法匹配以提取参数。

代码语言:javascript
复制
Ltac restore_dims :=
  repeat match goal with
  | [ |- context[@Mmult ?m ?n ?o ?A ?B]] =>
        match type of A with
        |  Matrix ?m' ?n' => replace m with m' by easy
        end;
        match type of B with
        |  Matrix ?n'' ?o' => replace n with n'' by easy
          (* or whatever you wanted to do with n'' and o' *)
        end
  end.

如果你认为mm'将是可转换的,而不仅仅是平等的,并且你关心有好的证明条款,考虑使用策略change而不是replace,例如change n'' with n。这不会给证明项增加任何东西,所以它可能更容易使用。

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

https://stackoverflow.com/questions/55463216

复制
相关文章

相似问题

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