2
$\begingroup$

So I have a file in coq, which is a bit like the following:

Section S.

  Context (a : TA).
  Context (b : TA → TB).

  Definition X : TB.
  Proof.
    apply b.
    exact a.
  Defined.

  Context (c : TB → TC).

  Definition Y : TC.
  Proof.
    apply c.
    exact X.
  Defined.

End S.

This file is growing very large, which means waiting a long time if I add an import statement and then start working at the bottom of the file. Therefore, I thought I'd split it up into smaller files. However, when I split the section into smaller sections, these sections don't share their context...

Section S.

  Context (a : TA).
  Context (b : TA → TB).

  Definition X : TB.
  Proof.
    apply b.
    exact a.
  Defined.

End S.

Section T.

  Context (a : TA).
  Context (b : TA → TB).
  Context (c : TB → TC).

  Definition Y : TC.
  Proof.
    apply c.
    exact X. (* Error: The term "X" has type "TA → (TA → TB) → TB" while it is expected to have type "TB". *)
  Defined.

End T.

...so if I want to use definitions and lemmas from a previous section, I will need to manually provide these context variables every time (X a b instead of X) and this will grow unreadable and cumbersome quite quickly. So is there a way to either

  • tell coq that one section is merely a continuation of another,
  • or to say "for the definitions from section S, fill in the values a and b for their arguments a and b"?
$\endgroup$

2 Answers 2

2
$\begingroup$

As Meven said, there is no great solution to this problem. However, there is a way to (manually) accomplish your second option, namely to add Notation X := (X a b). to Section T, and similarly with every other definition from Section S. It's not very scalable, but if you only have a handful of definitions it works fine.

$\endgroup$
1
  • $\begingroup$ Oof, that is ugly. But thanks. $\endgroup$ Nov 1 at 8:29
2
$\begingroup$

This is a long-time desire of many users, but it is not currently available, and would require deep changes to the section mechanism which are not likely to happen soon. You can look at this thread on the Coq zulip for more context and potential workaround solutions.

$\endgroup$
1
  • $\begingroup$ Thank you. At least it is good to know that there is not a feature that I didn't know existed until now. $\endgroup$ Oct 31 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.