whonore / Coqtail

Interactive Coq Proofs in Vim
MIT License
274 stars 35 forks source link

Proofs that don't start with "Proof." are not recognized #125

Open Lysxia opened 4 years ago

Lysxia commented 4 years ago

Compare how cbn is highlighted in this example:

Lemma a : False.
Proof.
cbn.
Abort.

Lemma a : False.
cbn.
whonore commented 4 years ago

The problem is tactics are currently only highlighted when they're in a coqProofBody region, which looks for a starting delimiter like Proof or Next Obligation. Without that it's tricky to tell when a proof starts. Some options I can think of are:

  1. Drop the proof body requirement and highlight tactics everywhere, even in places where they may not be valid.
  2. Try to expand proof body to check if the previous vernacular is Lemma, or Theorem, etc. It should probably also check that it's not defined in that same command (Example a : True := I.), but this also has some corner cases (Instance x : Reflexive R := _.).
  3. Keep it as is and don't try to highlight/indent proofs without an explicit start keyword.

1 or 3 are the easiest options but I'm open to 2 if you think this is a common enough/idiomatic use case.

whonore commented 4 years ago

Somewhat related: #43.

Lysxia commented 4 years ago

I'm fine with not fixing it if it's not easy. I just wanted to mention it because it seems somewhat common, but I'm not at all fond of that style.

whonore commented 4 years ago

When I next get some time I'll experiment with how hard it is to make a best-effort attempt at something like option 2.

Tuplanolla commented 2 years ago

As if living with the rooster was not hard enough already, some proofs in the standard library start with both Next Obligation and Proof and thus manifest this issue. The following excerpt is from theories/Classes/EquivDec.v.

#[global]
Program Instance unit_eqdec : EqDec unit eq := fun x y => in_left.

  Next Obligation.
  Proof.
    do 2 match goal with [ x : () |- _ ] => destruct x end.
    reflexivity.
  Qed.