jldodds/coq-lean-cheatsheet

A quick reference for mapping Coq tactics to Lean tactics

Lean

72

31 commits

updated Apr 23, 2021

See the code

README

Coq to Lean Tactic Cheatsheet

This is a guide for coq users getting into writing lean proofs.

Please PR your own or request additions via issue tracker or lean gitter.

n/a doesn't mean it doesn't exist, only that I don't know about it.

The main table is for the Lean release v3.3.0.

Coq TacticLean TacticNotes
;;
 .      ,
assumptionassumption     
admitadmit
applyapplylean apply is coq eapply
apply H in Ahave A2 := H AWill create a new hypothesis A2, and A will persist, see coq-tactic-substitutes.lean for a closer approximation
asserthave
auton/a
autorewriten/asimp using <attribute> approximates
changechange
change withn/a
clearclearno clear -
constructorconstructor
destructcases
destruct x eqn:?destruct x
eapplyapply
exactexact
exfalsoexfalso
existsexistsiuse is the same, but takes the expected type into account. use requires mathlib
eexistsexistsi _
f_equalcongr' 1requires mathlib
failfail_if_success {skip}
first [A | B |.. | X]first [A B .. X]
generalize tgeneralize : t = yy is name of the new variable, the name must be provided
generalize dependentrevert
idtacskipskip does not print, succeeds trivially
inductioninduction
introintro
introsintros
intuitionn/a
inversioncasesCases should be applied to dependent arguments first
leftleft
omegaomegarequires mathlib. Might not have the same features as Coq's omega
poselet
pose proofhave
progressn/alean tactics by convention should fail if they don't progress
remember x as y eqn:hgeneralize h : x = ynames must be provided
revertn/aalways dependent
revert dependentrevert
rewriterewrite, rw
rewrite <-rewrite <-, rw
rightright
simpldsimpto some approximation at least. simp only might be closer
simpl indsimp at
simpl in *dsimp at *
solvesolve1
specialize (H e)specialize (H e)
splitsplit
subst xsubst x
substn/a
symmetrysymmetry
transitivitytransitivity
trivialtrivial
try Ttry {T}curly braces required
typeclasses eautoapply_instance
unfoldunfold
unfold inunfold at
unshelve eapplyfapply

Similar options from Coq exist in Lean as well. Whereas Coq options are set and unset with the Vernacular Set option and Unset option, Lean options toggled with set_option <option> true and set_option <option> false. Here is a list of Coq options and their Lean versions:

Coq optionLean optionNotes
Printing Implicitpp.implicitdefault false
Printing Universespp.universesdefault false
Printing Notationspp.notationdefault true

And other Vernacular:

Coq VernacularLean directiveNotes
Opaque identattribute [irreducible] ident
Transparent identattribute [reducible] ident
Check term#check term
Print term#print termCan also be used to print structures, inductive types, notation
Proof using Pinclude Pinclude P makes P available to all proofs, as well as typeclass resolution if it is an instance. omit P un-includes P

Variables and sections

Coq constructLean constructNotes
Variableparameteronly within a section. Lean variable does not automatically apply arguments within the section
Universesuniversesuse universe variables if you want to declare the universes, but not fix them for the file

Contributors

bmsherman

15 commits

jldodds

14 commits

fpvandoorn

2 commits

jldodds/coq-lean-cheatsheet

A quick reference for mapping Coq tactics to Lean tactics

Lean

72

31 commits

updated Apr 23, 2021

See the code

README

Coq to Lean Tactic Cheatsheet

This is a guide for coq users getting into writing lean proofs.

Please PR your own or request additions via issue tracker or lean gitter.

n/a doesn't mean it doesn't exist, only that I don't know about it.

The main table is for the Lean release v3.3.0.

Coq TacticLean TacticNotes
;;
 .      ,
assumptionassumption     
admitadmit
applyapplylean apply is coq eapply
apply H in Ahave A2 := H AWill create a new hypothesis A2, and A will persist, see coq-tactic-substitutes.lean for a closer approximation
asserthave
auton/a
autorewriten/asimp using <attribute> approximates
changechange
change withn/a
clearclearno clear -
constructorconstructor
destructcases
destruct x eqn:?destruct x
eapplyapply
exactexact
exfalsoexfalso
existsexistsiuse is the same, but takes the expected type into account. use requires mathlib
eexistsexistsi _
f_equalcongr' 1requires mathlib
failfail_if_success {skip}
first [A | B |.. | X]first [A B .. X]
generalize tgeneralize : t = yy is name of the new variable, the name must be provided
generalize dependentrevert
idtacskipskip does not print, succeeds trivially
inductioninduction
introintro
introsintros
intuitionn/a
inversioncasesCases should be applied to dependent arguments first
leftleft
omegaomegarequires mathlib. Might not have the same features as Coq's omega
poselet
pose proofhave
progressn/alean tactics by convention should fail if they don't progress
remember x as y eqn:hgeneralize h : x = ynames must be provided
revertn/aalways dependent
revert dependentrevert
rewriterewrite, rw
rewrite <-rewrite <-, rw
rightright
simpldsimpto some approximation at least. simp only might be closer
simpl indsimp at
simpl in *dsimp at *
solvesolve1
specialize (H e)specialize (H e)
splitsplit
subst xsubst x
substn/a
symmetrysymmetry
transitivitytransitivity
trivialtrivial
try Ttry {T}curly braces required
typeclasses eautoapply_instance
unfoldunfold
unfold inunfold at
unshelve eapplyfapply

Similar options from Coq exist in Lean as well. Whereas Coq options are set and unset with the Vernacular Set option and Unset option, Lean options toggled with set_option <option> true and set_option <option> false. Here is a list of Coq options and their Lean versions:

Coq optionLean optionNotes
Printing Implicitpp.implicitdefault false
Printing Universespp.universesdefault false
Printing Notationspp.notationdefault true

And other Vernacular:

Coq VernacularLean directiveNotes
Opaque identattribute [irreducible] ident
Transparent identattribute [reducible] ident
Check term#check term
Print term#print termCan also be used to print structures, inductive types, notation
Proof using Pinclude Pinclude P makes P available to all proofs, as well as typeclass resolution if it is an instance. omit P un-includes P

Variables and sections

Coq constructLean constructNotes
Variableparameteronly within a section. Lean variable does not automatically apply arguments within the section
Universesuniversesuse universe variables if you want to declare the universes, but not fix them for the file

Contributors

bmsherman

15 commits

jldodds

14 commits

fpvandoorn

2 commits

Languages

Lean

100.0%