[英]apply ltac to subexpression of a goal
這是我正在嘗試做的一個簡短示例。
假設我有關系
Inductive divisible: nat -> nat -> Type :=
| one : forall n, divisible n 1.
..etc...
我還有以下 ltac Ltac simplify := autorewrite with blah
我想定義一個 ltac,它確實簡化為“可分”目標中的第一項。 就像是
Ltac simplify_fst :=
match goal with |- (divisible ?N ?M) =>
autorewrite with subst1 in N
end.
當我在下面嘗試上述內容時,
Lemma silly: forall n m, divisible (n + m) 1.
intros. simplify_fst.
我得到一個
Error:
Ltac call to "simplify_fst" failed.
Ltac variable N is bound to n + m which cannot be
coerced to a variable.
是否可以將 ltacs(即使是僅涉及自動展開和自動重寫的簡單的)應用到目標的子表達式中?
謝謝你。
在您的情況下, remember
可能有用:
Ltac simplify_fst :=
match goal with |- (divisible ?N ?M) =>
let x := fresh "x" in
let Hx := fresh "Hx" in
remember N as x eqn:Hx;
autorewrite with subst1 in Hx;
subst x
end.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.