playground/coq/mathcomp/hello2.v

46 lines
874 B
Coq

From mathcomp Require Import all_ssreflect all_algebra.
Print negbK.
Check negbK. (* involutive negb *)
Print involutive. (* f (f x) = x *)
Print cancel. (* f g such that f (g x) = x *)
Locate "~~". (* negb *)
Locate "~". (* Could be 'not' *)
Goal forall b: bool,
~~ (~~ b) = b.
Proof.
intro b.
case: b.
by [].
by [].
Show Proof.
Restart.
intro b.
by case: b.
(* Or 'by [case: b].' *)
Qed.
Fixpoint multn (n m: nat): nat :=
if n is n'.+1 then m + multn n' m
else 0.
Compute multn 3 4.
(* = 12 : nat *)
Goal forall n m: nat,
(n * m == 0) = (n == 0) || (m == 0).
Proof.
intros n m.
case: n => [|n] //.
case: m => [|m]; last first => //. (* Good practice to get rid of easy goal first' *)
by rewrite muln0.
Qed.
Goal forall n p:nat,
prime p -> p %| (n`! + 1) -> n < p.
Proof.
move => n p prime_p.
apply: contraLR.