Skip to content

Commit 8d688fa

Browse files
committed
Migrate to coderefs labels
1 parent 75f8e43 commit 8d688fa

33 files changed

Lines changed: 163 additions & 76 deletions

packages/coderefs.sty

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
}
2222
}
2323

24-
\NewDocumentCommand \WriteCodeRef {m}
24+
\NewDocumentCommand \WriteCodeRefText {m}
2525
{
2626
\\[1ex]
2727
\hbox{\quad}
28-
\texttt{\GetCodeRef{#1}}
28+
\texttt{#1}
29+
}
30+
31+
\NewDocumentCommand \WriteCodeRef {m}
32+
{
33+
\WriteCodeRefText{\GetCodeRef{#1}}
2934
}
3035

3136
\ExplSyntaxOff

src/notebook/commands/watcher/command.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async def iter_build_file_changes(logger: loguru.Logger) -> AsyncIterator[TaskTr
3232
inotify.add_watch(ROOT_PATH / 'bibliography', MASK)
3333
inotify.add_watch(ROOT_PATH / 'asymptote', MASK)
3434
inotify.add_watch(ROOT_PATH / 'classes', MASK)
35+
inotify.add_watch(ROOT_PATH / 'aux', MASK)
3536
inotify.add_watch(ROOT_PATH / 'output', MASK)
3637
logger.info('Started daemon and initialized watchers')
3738

@@ -89,6 +90,7 @@ async def setup_watchers(manager: TaskRunner, base_logger: loguru.Logger, *, reb
8990
path.match('bibliography/*.bib') or
9091
path.match('text/*.tex') or
9192
path.match('images/*') or
93+
path.match('aux/coderefs.tex') or
9294
(path.match('output/*') and not path.match('output/notebook.pdf')) or
9395
path.match('packages/*.sty')
9496
):

src/notebook/math/lambda_/hol/evaluation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
from ....exceptions import UnreachableException
7+
from ....support.coderefs import collector
78
from ..alphabet import BinaryTypeConnective
89
from ..assertions import VariableTypeAssertion
910
from ..terms import Constant, TypedAbstraction, TypedApplication, TypedTerm, Variable
@@ -131,6 +132,7 @@ def evaluate_hol_term[T]( # noqa: C901
131132
raise UnreachableException
132133

133134

135+
@collector.ref('alg:hol_denotation')
134136
def evaluate_hol_expression[T](
135137
expression: HolExpression,
136138
structure: HolStructure[T],

src/notebook/math/lambda_/signature_translation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def visit_connective(self, type_: SimpleConnectiveType) -> SimpleConnectiveType:
3131
)
3232

3333

34-
@collector.ref('alg:fol_formula_signature_translation')
34+
@collector.ref('alg:simple_type_signature_translation')
3535
def translate_type(translation: SignatureMorphism, type_: SimpleType) -> SimpleType:
3636
return TypeTranslationVisitor(translation).visit(type_)
3737

@@ -68,6 +68,6 @@ def visit_abstraction(self, term: TypedAbstraction) -> TypedAbstraction:
6868
)
6969

7070

71-
@collector.ref('alg:fol_term_signature_translation')
71+
@collector.ref('alg:simply_typed_term_signature_translation')
7272
def translate_term(translation: SignatureMorphism, term: TypedTerm) -> TypedTerm:
7373
return TermTranslationVisitor(translation).visit(term)

text/boolean_functions.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ \section{Boolean functions}\label{sec:boolean_functions}
113113
\end{thmenum}
114114
\end{algorithm}
115115
\begin{comments}
116-
\item This algorithm can be found as \identifier{math.polynomials.zhegalkin.infer_zhegalkin} in \cite{notebook:code}.
116+
\item This algorithm is implemented in \cite{notebook:code} as
117+
\WriteCodeRef{alg:infer_zhegalkin_polynomial}
117118
\end{comments}
118119
\begin{defproof}
119120
We will prove correctness by induction. The base case \( n = 0 \) is vacuous, so suppose that \( n > 0 \) and that the algorithm is correct for less than \( n \) variables.

text/curry_howard_correspondence.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ \section{Curry-Howard correspondence}\label{sec:curry_howard_correspondence}
651651
\end{thmenum}
652652
\end{algorithm}
653653
\begin{comments}
654-
\item This algorithm can be found as \identifier{math.lambda_.curry_howard.derivation_to_proof.type_derivation_to_proof_tree} in \cite{notebook:code}.
654+
\item This algorithm is implemented in \cite{notebook:code} as
655+
\WriteCodeRef{alg:type_derivation_to_proof_tree}
655656

656657
\item When restricted to arrow types, this algorithm works just as well for \hyperref[def:lambda_term]{untyped} or even \hyperref[rem:mixed_lambda_term]{mixed} \( \muplambda \)-terms.
657658
\end{comments}
@@ -683,7 +684,8 @@ \section{Curry-Howard correspondence}\label{sec:curry_howard_correspondence}
683684
\end{thmenum}
684685
\end{algorithm}
685686
\begin{comments}
686-
\item This algorithm can be found as \identifier{math.lambda_.curry_howard.proof_to_derivation.proof_tree_to_type_derivation} in \cite{notebook:code}.
687+
\item This algorithm is implemented in \cite{notebook:code} as
688+
\WriteCodeRef{alg:proof_tree_to_type_derivation}
687689
\end{comments}
688690

689691
\begin{example}\label{ex:con:curry_howard_correspondence}

text/digit_based_operations.tex

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ \section{Digit-based operations}\label{sec:digit_based_operations}
4949
\end{thmenum}
5050
\end{algorithm}
5151
\begin{comments}
52-
\item This algorithm can be found as \identifier{math.arithmetic.bases.get_integer_expansion} in \cite{notebook:code}.
52+
\item This algorithm is implemented in \cite{notebook:code} as
53+
\WriteCodeRef{alg:integer_radix_expansion}
5354
\end{comments}
5455

5556
\paragraph{Digit-based integer arithmetic}
@@ -98,7 +99,8 @@ \section{Digit-based operations}\label{sec:digit_based_operations}
9899
\end{algorithm}
99100
\begin{comments}
100101
\item The term \( q_k \) \enquote{carries} either \( -1 \), \( 0 \) or \( 1 \) to be used in the next step.
101-
\item This algorithm can be found as \identifier{math.arithmetic.bases.add_with_carrying} in \cite{notebook:code}.
102+
\item This algorithm is implemented in \cite{notebook:code} as
103+
\WriteCodeRef{alg:addition_with_carrying}
102104
\end{comments}
103105
\begin{defproof}
104106
\SubProof{Proof that \( q_k \) is either \( -1 \), \( 0 \) or \( 1 \)} We will show by induction on \( k \) that \( q_k \) is either \( -1 \), \( 0 \) or \( 1 \). Note that, since \( b \geq 2 \), we have
@@ -243,7 +245,8 @@ \section{Digit-based operations}\label{sec:digit_based_operations}
243245
\end{thmenum}
244246
\end{algorithm}
245247
\begin{comments}
246-
\item This algorithm can be found as \identifier{math.arithmetic.bases.single_digit_mult_with_carrying} in \cite{notebook:code}.
248+
\item This algorithm is implemented in \cite{notebook:code} as
249+
\WriteCodeRef{alg:single_digit_multiplication_with_carrying}
247250
\end{comments}
248251
\begin{defproof}
249252
The proof of correctness is similar, but much simpler than that of \fullref{alg:integer_radix_expansion}.
@@ -355,7 +358,8 @@ \section{Digit-based operations}\label{sec:digit_based_operations}
355358
\end{thmenum}
356359
\end{algorithm}
357360
\begin{comments}
358-
\item This algorithm can be found as \identifier{math.arithmetic.bases.multi_digit_mult_with_carrying} in \cite{notebook:code}.
361+
\item This algorithm is implemented in \cite{notebook:code} as
362+
\WriteCodeRef{alg:multi_digit_multiplication_with_carrying}
359363
\end{comments}
360364

361365
\begin{algorithm}[Long division]\label{alg:long_division}
@@ -418,7 +422,8 @@ \section{Digit-based operations}\label{sec:digit_based_operations}
418422
\end{thmenum}
419423
\end{algorithm}
420424
\begin{comments}
421-
\item This algorithm can be found as \identifier{math.arithmetic.bases.long_integer_division} in \cite{notebook:code}.
425+
\item This algorithm is implemented in \cite{notebook:code} as
426+
\WriteCodeRef{alg:long_division}
422427
\end{comments}
423428
\begin{defproof}
424429
The guard steps \fullref{alg:long_division/n_guard} and \fullref{alg:long_division/m_guard} allow us to assume that \( n \geq 0 \) and \( m \geq 0 \).

text/first_order_logic.tex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ \section{First-order logic}\label{sec:first_order_logic}
227227
\end{algorithm}
228228
\begin{comments}
229229
\item As discussed in \cref{rem:fol_application_notation}, we allow translation to change the notation of symbols.
230-
\item This algorithm can be found as \identifier{math.logic.signature_translation.translate_term} in \cite{notebook:code}.
230+
\item This algorithm is implemented in \cite{notebook:code} as
231+
\WriteCodeRef{alg:fol_term_signature_translation}
231232
\end{comments}
232233

233234
\paragraph{First-order formulas}
@@ -374,7 +375,8 @@ \section{First-order logic}\label{sec:first_order_logic}
374375
\begin{comments}
375376
\item As discussed in \cref{rem:fol_application_notation}, we allow exchanging prefix and infix symbols.
376377

377-
\item This algorithm can be found as \identifier{math.logic.signature_translation.translate_formula} in \cite{notebook:code}.
378+
\item This algorithm is implemented in \cite{notebook:code} as
379+
\WriteCodeRef{alg:fol_formula_signature_translation}
378380
\end{comments}
379381

380382
\paragraph{Variable binding}
@@ -874,7 +876,8 @@ \section{First-order logic}\label{sec:first_order_logic}
874876

875877
\item Of course, this extension will only be valid when the propositional variables are in the domain of the atomic translation map.
876878

877-
\item This algorithm can be found as \identifier{math.logic.propositional.apply_prop_formula_translation} in \cite{notebook:code}.
879+
\item This algorithm is implemented in \cite{notebook:code} as
880+
\WriteCodeRef{alg:fol_propositional_formula_translation}
878881
\end{comments}
879882

880883
\begin{proposition}\label{thm:fol_propositional_formula_translation_semantics}

text/first_order_natural_deduction.tex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ \section{First-order natural deduction}\label{sec:first_order_natural_deduction}
1616
where \( n = \sharp(\op*{Free}_\Bbbs(\varphi)) \).
1717
\end{algorithm}
1818
\begin{comments}
19-
\item This algorithm can be found as \identifier{math.logic.substitution.apply_substitution_to_formula} in \cite{notebook:code}.
19+
\item This algorithm is implemented in \cite{notebook:code} as
20+
\WriteCodeRef{alg:fol_formula_substitution}
2021
\item This substitution is defined as to have the properties listed in \cref{rem:variable_binding_properties}; we elaborate on this in \fullref{thm:alg:fol_formula_substitution}.
2122
\end{comments}
2223

@@ -433,7 +434,8 @@ \section{First-order natural deduction}\label{sec:first_order_natural_deduction}
433434
\end{algorithm}
434435
\begin{comments}
435436
\item Of course, an application of an instantiation is only valid if the placeholders are in its domain.
436-
\item This algorithm can be found as \identifier{math.logic.instantiation.instantiate_term_schema} in \cite{notebook:code}.
437+
\item This algorithm is implemented in \cite{notebook:code} as
438+
\WriteCodeRef{alg:fol_term_schema_instantiation}
437439
\end{comments}
438440

439441
\begin{algorithm}[First-order formula instantiation]\label{alg:fol_formula_schema_instantiation}
@@ -458,7 +460,8 @@ \section{First-order natural deduction}\label{sec:first_order_natural_deduction}
458460

459461
\item A variant of this algorithm, in which certain instantiations are considered invalid, is presented in \cref{rem:sequent_calculus_eigenvariables}.
460462

461-
\item This algorithm can be found as \identifier{math.logic.instantiation.instantiate_substitution} in \cite{notebook:code}.
463+
\item This algorithm is implemented in \cite{notebook:code} as
464+
\WriteCodeRef{alg:fol_formula_schema_instantiation}
462465
\end{comments}
463466

464467
\paragraph{Abstract natural deduction}
@@ -671,7 +674,8 @@ \section{First-order natural deduction}\label{sec:first_order_natural_deduction}
671674
\begin{comments}
672675
\item We will use this algorithm to show compatibility of propositional and first-order derivation relations in \cref{thm:fol_propositional_formula_translation_entailment}.
673676

674-
\item This algorithm can be found as \identifier{math.logic.propositional.apply_prop_proof_tree_translation} in \cite{notebook:code}.
677+
\item This algorithm is implemented in \cite{notebook:code} as
678+
\WriteCodeRef{alg:fol_propositional_proof_tree_translation}
675679
\end{comments}
676680

677681
\paragraph{Concrete natural deduction}

text/first_order_theories.tex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,11 @@ \section{First-order theories}\label{sec:first_order_theories}
981981
\end{thmenum}
982982
\end{algorithm}
983983
\begin{comments}
984-
\item This algorithm can be found as \identifier{math.logic.skolemization.formula_to_prenex_form} in \cite{notebook:code}. The bulk of the implementation is in the module \identifier{math.logic.transformation.pull_quantifiers}.
984+
\item This algorithm is implemented in \cite{notebook:code} as
985+
\WriteCodeRef{alg:fol_formula_to_prenex_normal_form}
986+
987+
The bulk of the implementation is in the module
988+
\WriteCodeRefText{math.logic.transformation.pull_quantifiers}
985989
\end{comments}
986990
\begin{defproof}
987991
We can use induction on the \hyperref[def:graph_cardinality/order]{graph order} of the \hyperref[def:fol_formula_ast]{abstract syntax tree} of \( \varphi \) to show that \( M_{\logic{PNF}}(\varphi) \) is in prenex normal form. This is straightforward because, in every operation, we recursively \enquote{pull} quantifiers outwards.
@@ -1092,7 +1096,8 @@ \section{First-order theories}\label{sec:first_order_theories}
10921096
\begin{comments}
10931097
\item The overall premise of Skolemization is described in \cref{rem:definitional_extensions_and_skolemization} and \cref{thm:skolemization_equisatisfiability} (the latter leading to \fullref{thm:skolems_theorem}).
10941098
\item There are two sources of ambiguity in the algorithm --- the choice of Skolem function symbols and the choice of the functions themselves. The disambiguation that we may find useful depends on the situation.
1095-
\item This algorithm can be found as \identifier{math.logic.skolemization.skolemize} in \cite{notebook:code}.
1099+
\item This algorithm is implemented in \cite{notebook:code} as
1100+
\WriteCodeRef{alg:fol_skolemization}
10961101
\end{comments}
10971102

10981103
\begin{proposition}\label{thm:skolemization_equisatisfiability}

0 commit comments

Comments
 (0)