Modus Ponens and Modus Tollens in Coq

柔情痞子 提交于 2019-12-05 22:06:55

Here is one solution:

Ltac mt PtoQ notQ notP :=
  match type of PtoQ with
  | ?P -> _ => pose proof ((fun p => notQ (PtoQ p)) : ~ P) as notP
  end.

This tactic asks the user for the two input hypothesis and for an explicit name of the output hypothesis. I use type of PtoQ construction to extract the type P from the input implication and then provide an explicit term (fun p => notQ (PtoQ p) of type P -> False, which is definitionally equal to ~ P. The explicit type ascription : ~ P is used to make the context look prettier, without it Coq would show the output hypothesis's type as P -> False.

Incidentally, I would use something like this to implement the modus ponens tactic:

Ltac mp PtoQ P Q := 
  pose proof (PtoQ P) as Q.

Here, again PtoQ and P parameters are the names of the input hypotheses and Q is the name to be added to the context.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!