-
Notifications
You must be signed in to change notification settings - Fork 30
Structure Guidelines
Andrej Dudenhefner edited this page Jun 14, 2022
·
8 revisions
The directory structure of theories
is organized as follows
-
ProblemClass
-
ProblemFamily.v
,ProblemFamily_undec.v
-
Reductions
ForeignProblem_to_Problem.v
HaltTM_1_chain_Problem.v
-
Util
,Misc
,Shared
, ...
-
In the above
-
ProblemClass
is a general class of Problems -
ProblemFamily.v
contains a cohesive (overlapping preliminaries) family of decision problems (Coq predicates) inProblemClass
-
ProblemFamily.v
should be a minimalistic, possibly self-contained problem specification, suitable for modular reuse -
ProblemFamily.v
should be well-documented via comments and feasible to understand with minimal Coq knowledge -
ProblemFamily.v
should not contains any reasoning, dependencies to undecidability results etc.
-
-
ProblemFamily_undec.v
contains exactly the proofs ofTheorem Problem_undec : undecidable Problem.
for eachProblem
defined inProblemFamily.v
-
ProblemFamily_undec.v
should contain only high-level reasoning (transitive application of reduction steps) -
ProblemFamily_undec.v
should be documented via comments and feasible to understand with a basic Coq knowledge -
ProblemFamily_undec.v
should not contains auxiliary lemmas
-
-
Reductions
contains relevant reductions to problems inProblemClass
-
ForeignProblem_to_Problem.v
contains the main argument to reduceForeignProblem
toProblem
inProblemClass
-
ForeignProblem_to_Problem.v
should (if possible) containTheorem reduction : ForeignProblem ⪯ Problem.
-
ForeignProblem_to_Problem.v
may encapsulate all other lemmas and theorems necessary forreduction
in aModule
-
ForeignProblem_to_Problem.v
should not contain proofs ofForeignProblem' ⪯ Problem'
where eitherForeignProblem'
differs fromForeignProblem
orProblem'
differs fromProblem
-
ForeignProblem_to_Problem.v
should (if possible) not depend on any otherForeignProblem'_to_Problem'.v
for parallel compilation of atomic reduction steps
-
-
HaltTM_1_chain_Problem.v
is optional and contains the conjunction of reduction steps from Turing machine haltingHaltTM 1
toProblem
-
HaltTM_1_chain_Problem.v
should (if possible) containTheorem HaltTM_1_chain_Problem : HaltTM 1 ⪯ Problem_1 /\ ... /\ Problem_n ⪯ Problem.
-
HaltTM_1_chain_Problem.v
should be documented via comments and feasible to understand with a basic Coq knowledge -
HaltTM_1_chain_Problem.v
should not contains auxiliary lemmas -
HaltTM_1_chain_Problem.v
should not used in other arguments (it should be a compilation leaf) -
HaltTM_1_chain_Problem.v
should be used for presentations, publications, code review, etc.
-
-
-
Util
,Misc
,Shared
, etc. contain auxiliary lemmas used for proofs inProblemClass
to keep the top-level ofProblemClass
clean - Intermediate files should not depend on
ProblemFamily_undec.v
files (otherwise, this could pollute the overall context)
-
Modularity:
ProblemClass
should not contain proofs regarding inherent properties ofOtherProblemClass
that could as well be proven inOtherProblemClass
. -
Specification surveyability:
ProblemFamily.v
is intended to be surveyed by mathematicians with little effort. This should not be obstructed by ltac hacks, interspersed lemmas, dependencies, etc. -
Result surveyability:
ProblemFamily_undec.v
is intended to be surveyed by mathematicians with little effort. Same design guidelines as forProblemFamily.v
apply. This is also true forHaltTM_1_chain_Problem.v
. -
Name uniformity: Names of important files and theorems should be easy to guess. For example, a file showing
HaltTM 1 ⪯ Problem
should neither be calledHalt_Prob.v
,HALTTM_Problem.v
, norHALTTM_1_Problem.v
. The preferred name would beHaltTM_1_to_Problem.v
. -
Opt-in notations: Notations (also coercions, typeclasses, hints) should not be exposed at the top level of specification. A good practice (cf. Coq
List
containingListNotations
) is to encapsulate notations (also coercions, typeclasses, hints) in aModule
. Adding hints tocore
is discouraged in favor of specialized hint databases.
-
Fast Interfaces: Whenever using
Section
for code structure, also useSet Default Proof Using "Type".
to ensure fast interface file (vos
) compilation. Avoid too manyLet
definitions in aSection
for compact interfaces.
-
Structured Proofs: Use
Set Default Goal Selector "!".
to ensure precise goal selection and improve maintainability. -
Principled Naming: Avoid referring to automatically generated names (e.g. from
inversion
). Such names often break code between Coq version changes. A good guideline is compatibility withSet Mangle Names.
. - Regarding Anti-Patterns: For stable code, it is recommended to have a look at Anti-patterns and avoid them when possible.