Part of coq stdlib. No need of mathcomp
General
do n! tacapply the tactictac,ntimes.
Multipliers
n! |
Exactly n times |
n? |
Upto n times |
! |
As many times as possible and at least once |
? |
As many times as possible (can even be zero times) |
ssrfun
https://coq.inria.fr/doc/V8.18.0/stdlib/Coq.ssr.ssrfun.html
left_id,right_idleft_zero,right_zeroidempotentcommutativeleft_commutative,right_commutativeleft_distributive,right_distributiveassociativeinjective: ∀x y, f x = f y -> x = yleft_injective,right_injectiveleft_inverse,right_inverseinvolutiveinterchange
ssrbool
xpredT: Notation for identity function fortrue- As in a predicate that's always true.
a \in P: P is a predicate andP aholds.a \notin P: opposite ofa \in PpredD P Q: elements which are satisfied byPbut not byQ- As in
P \ Q, like set difference. - Underlying function is
xpredD. - Mathcomp syntax:
[predD P & Q]
- As in
Clear switchᵈ
Introduction with curly braces means at the end of that tactic, the introduced variable will disappear from the set of hypotheses.
rewrite
Probably the most useful tactic.
Tips:
- rewrite within an assumption
Has well as the goal:rewrite in H *
Occurrence selection ᵈ
rewrite {2}<name>: rewrite only 2nd occurrance ofnamerewrites {-2}<name>: rewrite all occurrances ofnameexcept the 2nd one
Some 'reflecting' examples
case/exists_inPis same asmove/exists_inP => x; case: x
andP
Require Import ssreflect ssrbool.
Goal
True -> true && true.
Proof.
move => H.
(*
1 subgoal
H : True
========================= (1 / 1)
true && true
*)
apply/andP.
(*
1 subgoal
H : True
========================= (1 / 1)
true /\ true
*)
exists_inP (move)
One with mathcomp:
Check exists_inP.
(*
exists_inP
: reflect (exists2 x : ?T, ?D x & ?P x) [exists (x | ?D x), ?P x]
where
?T : [ |- finType]
?D : [ |- pred ?T]
?P : [ |- pred ?T]
*)
Goal forall (x:'I_3) (P1 P2: 'I_3 -> bool),
[exists (x | P2 x), P1 x] -> True.
Proof.
move => x P1 P2.
(*
1 subgoal
x : 'I_3
P1, P2 : 'I_3 -> bool
========================= (1 / 1)
[exists (x0 | P2 x0), P1 x0] -> True
*)
move/exists_inP.
(*
1 subgoal
x : 'I_3
P1, P2 : 'I_3 -> bool
========================= (1 / 1)
(exists2 x0 : fintype_ordinal__canonical__fintype_Finite 3, P2 x0 & P1 x0) ->
True
*)
exists_inP (case)
[exists (dst | true), accept eps dst l] -> s :: l \in nilp (T:=A)
case/exists_inP.
forall x : unit, true -> accept eps x l -> s :: l \in nilp (T:=A)
Misc
- An ssreflect library is being developed for Lean as well: https://github.com/verse-lab/lean-ssr/tree/master
- odflt: option default