In Coq, what's the difference between ... ?
Require X.
Import X.
Require Import X.
I have basically memorized some common patterns. I usually see code using Require Import X
. Then there's Import ListNotation
. And I just noticed it's also possible to write just Require X
. What's the difference? Some practical examples would be appreciated.
Require
loads a library whereasImport
brings its definitions into scope.Require Import
does both. If you only have the library loaded, you'll need to refer to names fully qualified. Coq allows top-level modules corresponding to files to define modules; these have to be imported separately to bring all of their definitions into scope, and they can't beRequire
d - that's what's going on withListNotations
:Note there are some quirks with how Coq handles modules, especially compared to other languages:
Global Set
in the module being imported.