coq tips

Section

Require Import ZArith.

Open Scope Z_scope.

 

Section ss.

End.

 

Qed.

Print t.

Check type.

 

apply t.

apply t with(v:=m v2:=n ).

eapply t.

eexact H.

Search Zle.

SearchPattern(_+_<=_)%Z. SearchPattern(?X1 * _ <=?X1 * _)%Z.

 

le_S : forall n m : nat, n <= m -> n <= S m

 

transparent theorem vs opaque theorem:

       Defined.尾;以Qed.结尾。

unfold transparent_theorem.

unfold id at n1 ... nk. 指定在哪几阶展开。

 

5.2 Logic Connectives.

not

elim False.这个能推出任何命题。等价于apply False_ind.exact False.

否定命题的理解:

       引入规则:如果能从A真推导出任何命题为真,必然蕴含~A真。

       削去规则:如果A,~A同时为真,必然蕴含所有的命题为真。

Hypothesis中有A真,同时又推导出~A真,用destruct(~A)可以为推导引入False到推导的前提中,从而可以证明任何的goal

 

True

引入规则:空(无任何前提条件)蕴含True为真。

没有规则,即是说,如果我们知道True为真这个前提,我们得不出任何新的东西。

 

False:

没有引入规则,和削去规则对应,仅当all为真,才能引入False为真。而这是不可能的。

削去规则:如果False真,必然蕴含anything为真。

unfold not. unfold not at 1 2. unfold ~p == p->False.

or_introl.

or_intror.

repeat tac.

 

assert ( ~~~P->~P ). 引入一个引理。先证明该引理,后使用。

cut (~~~P->~P).  引入一个引理。先使用该引理,后证明。

 

exact vs assumption. exact指定前提or假定的名称,assumption自动查找。

 

5.3 Equality and Rewriting

reflexivity. 证明数上的相等。不会计算(规约)包含有自由变量的等式。

ring. 同上,但会计算包含自由变量的等式。 存在于ZArithRing.

rewrite e. e has the form e: a=b ,作用是把goal中的每个a替换为b,可能会产生多个goal

rewrite <- e. 同上,但是把每个b替换为a

rewrite [<-] e in H.  rewrite operates on a Hypothesis.

 

pattern x [at 1]. x is the 模式。at 1指定匹配的范围。

 

Search eq.

SearchRewrite (1*_)%Z. 参数为模式。可以使用匿名_

 

chap6. Inductive Data Types.

Inductive id:Set :=  a | b |c .

 

coq course note

一些等价关系

当假设可以直接用于证明goal时,exact h = apply h =assumption 三者等价。

 

rewrite [<- or ->] H.

simpl. 应用于goal,goalbeta规约.

reflexivity.判断等式形式的goal是否等式两边相等.

elim k.展开k的定义,一般会产生多个subgoal,但每个subgoal要相对简单了.从而易证.

 

induction t. 按照t所属的induction 类型的定义展开,或说是按结构归纳证明。tbound变量形式出现在goal中。

inversion_clear H. 展开H假设。

rewrite <- H 3 in H0.  把假设H0中的项用H3的左项重写。H0中的项和H3中的右项相同。

 

Require Import Classical.  classical逻辑引入,

elim (classic (exists x : D, ~ Drinks x)). 

应用上述tactic后会产生下面两个新的goal

(exists x : D, ~ Drinks x) -> old_goal

~ (exists x : D, ~ Drinks x) -> old_goal.

回顾elim的用法 elim H. 会把goal变成 H->old_goal.

 

unfold not in H. 把假设中的~展开。

 

注意with / in / at 用法的区别:

with 一般用在apply H with (boundvar:=var). 中,用来指定要应用的假设中的变量用假设中的那个变量来代换,

  比如在应用传递规则的时候,我们一定要指定中间传递变量y应该绑定到那个假设中的变量。

in 一般用来指出操作/作用所应用的领域,如常见的 rewrite <- H 3 in H0. in的作用是指出要把H0中的某项怎么重写。

at 一般用来指出展开的幅度、层次等。如unfold not at 1,表示只展开最外层的not。等等

 

elimtype False. 如果goal不好证明,我们可以把goal换成证明False为真,因为False能证明一切。

  elimtype False.作用相当于cut False.当然elim I.相当于 cut I. intro Hn; elim Hn; clear Hn.

 

apply not_ex_not_all. goal forall x : D, Drinks x 转换成 ~ (exists n : D, ~ Drinks n)

 

assert (subgoal). 将会产生新的subgoal,且要求先证明该subgoal,再证明原goal

 

elim (H1 H2). 如果H1H2互为否命题,则H1 H2会产生False,而False可以推导出一切。

 

False相关: False有削去规则,没有引入规则。即是说我们不可能证明False为真。elim False.可以证明任何goal

 

8.9.4   injection ident

http://coq.inria.fr/doc/Reference-Manual010.html#@tactic82

 

8.8.7   subst ident

http://coq.inria.fr/doc/Reference-Manual010.html#@tactic75

This tactic applies to a goal which has ident in its context and (at least) one hypothesis, say H, of type ident=t or t=ident. Then it replaces ident by t everywhere in the goal (in the hypotheses and in the conclusion) and clears ident and H from the context.

 

 

Section

二、 types and expressions

1.         Gallina specification language.

2.         Expressions à programs  type à ?

3.         Interpertation Scopes:

              Open Scope Z_scope/nat_scope

4.         Type Checking

              Check t%[nat|Z]

              O=0%nat 大写的字母O

5.         Simple type:

1)        atomic types.

2)        arrow types.

6.         A->B->C equals A->(B->C) .

1)        Fun 接受参数A返回B->C.

2)        Fun 接受AB返回C

7.         def/dec, global/local

1)        declaration: variable/constant x:A

2)        definition: variable/constant x:=t:A . while t is well-formed.

3)        Environment: Global variables, constant声明

4)        Context local variables, variable 声明

8.         Sections and Local Variables.

9.         Computing.

三、 Propositions and Proofs.

 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值