
auto- proof searchLtac- automated forward reasoning (hypothesis matching machinery)eauto,eapply- deferred instantiation of existentials
Ltac macro
1 | Ltac inv H := inversion H; subst; clear H. |
The auto Tactic
autocan free us by searching for a sequence of applications that will prove the goal:
1 | intros P Q R H1 H2 H3. |
auto solves goals that are solvable by any combination of
introsapply(of hypotheses from the local context, by default)
使用 auto 一定是“安全”的,它不会失败,也不会改变当前证明的状态: auto 要么完全解决它,要么什么也不做。
Proof search could, in principle, take an arbitrarily long time,
so there are limits to how far auto will search by default. (i.e.5)
1 | Example auto_example_3 : ∀(P Q R S T U: Prop), |
Hint Database 提示数据库
autoauto considers a hint database of other lemmas and constructors.
common lemmas about equality and logical operators are installed by default.
just for the purposes of one application of
auto
我们可以为某次auto的调用扩展提示数据库,auto using ...
1 | Example auto_example_6 : ∀n m p : nat, |
Global Hint Database 添加到全局提示数据库
1 | Hint Resolve T. |
Proof with auto.
Under Proof with t, t1... == t1; t.
Searching For Hypotheses
对于很常见的一种矛盾情形:
1 | H1: beval st b = false |
contradiction 并不能解决,必须 rewrite H1 in H2; inversion H2.
- 宏:
1 | Ltac rwinv H1 H2 := rewrite H1 in H2; inv H2. |
match goal调用宏
1 | Ltac find_rwinv := |
可以看到最后只剩这种改写形式…我们也把他们自动化了:
1 | Ltac find_eqn := |
配合上 repeat…我们可以 keep doing useful rewrites until only trivial ones are left.
最终效果:
1 | Theorem ceval_deterministic''''': ∀c st st1 st2, |
即使我们给 IMP 加上一个 CRepeat(其实就是 DO c WHILE b),
会发现颠倒一下自动化的顺序就能 work 了
1 | induction E1; intros st2 E2; inv E2; |
当然,这种「超级自动化」(hyper-automation) 并不总是现实,也不好调试…
The eapply and eauto variants
推迟量词的实例化
比如对于
1 | Example ceval_example1: |
没有 with 就会 Error: Unable to find an instance for the variable st'
但其实 st' 的取值在后面的步骤是很明显(很好 infer/unify)的,所以 eapply works.
- 本文标题:「SF-LC」16 Auto
- 创建时间:2021-03-28 00:00:00
- 本文链接:posts/fd2b.html
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!