chiark / gitweb /
9ca8012f6589cffebe568008215f152fafe1083c
[topbloke-formulae.git] / article.tex
1 \documentclass[a4paper,leqno]{strayman}
2 \let\numberwithin=\notdef
3 \usepackage{amsmath}
4 \usepackage{mathabx}
5 \usepackage{txfonts}
6 \usepackage{amsfonts}
7 \usepackage{mdwlist}
8 %\usepackage{accents}
9
10 \renewcommand{\ge}{\geqslant}
11 \renewcommand{\le}{\leqslant}
12
13 \newcommand{\has}{\sqsupseteq}
14 \newcommand{\isin}{\sqsubseteq}
15
16 \newcommand{\nothaspatch}{\mathrel{\,\not\!\not\relax\haspatch}}
17 \newcommand{\notpatchisin}{\mathrel{\,\not\!\not\relax\patchisin}}
18 \newcommand{\haspatch}{\sqSupset}
19 \newcommand{\patchisin}{\sqSubset}
20
21 \newcommand{\set}[1]{\mathbb #1}
22 \newcommand{\pa}[1]{\varmathbb #1}
23 \newcommand{\pay}[1]{\pa{#1}^+}
24 \newcommand{\pan}[1]{\pa{#1}^-}
25
26 \newcommand{\p}{\pa{P}}
27 \newcommand{\py}{\pay{P}}
28 \newcommand{\pn}{\pan{P}}
29
30 %\newcommand{\hasparents}{\underaccent{1}{>}}
31 %\newcommand{\hasparents}{{%
32 %  \declareslashed{}{_{_1}}{0}{-0.8}{>}\slashed{>}}}
33 \newcommand{\hasparents}{>_{\mkern-7.0mu _1}}
34 \newcommand{\areparents}{<_{\mkern-14.0mu _1\mkern+5.0mu}}
35
36 \renewcommand{\implies}{\Rightarrow}
37 \renewcommand{\equiv}{\Leftrightarrow}
38 \renewcommand{\land}{\wedge}
39 \renewcommand{\lor}{\vee}
40
41 \newcommand{\pancs}[2]{{\mathcal A} ( #1 , #2 ) }
42 \newcommand{\pends}[2]{{\mathcal E} ( #1 , #2 ) }
43
44 \newcommand{\patchof}[1]{{\mathcal P} ( #1 ) }
45 \newcommand{\baseof}[1]{{\mathcal B} ( #1 ) }
46
47 \newcommand{\eqn}[2]{ #2 \tag*{\mbox{\bf #1}} }
48 \newcommand{\corrolary}[1]{ #1 \tag*{\mbox{\it Corrolary.}} }
49
50 %\newcommand{\bigforall}{\mathop{\hbox{\huge$\forall$}}}
51 \newcommand{\bigforall}{%
52   \mathop{\mathchoice%
53     {\hbox{\huge$\forall$}}%
54     {\hbox{\Large$\forall$}}%
55     {\hbox{\normalsize$\forall$}}%
56     {\hbox{\scriptsize$\forall$}}}%
57 }
58
59 \newcommand{\proof}[1]{{\it Proof.} #1 $\square$}
60
61 \begin{document}
62
63 \section{Notation}
64
65 \begin{basedescript}{
66 \desclabelwidth{5em}
67 \desclabelstyle{\nextlinelabel}
68 }
69 \item[ $ C \hasparents \set X $ ]
70 The parents of commit $C$ are exactly the set
71 $\set X$.
72
73 \item[ $ C \ge D $ ]
74 $C$ is a descendant of $D$ in the git commit
75 graph.  This is a partial order, namely the transitive closure of 
76 $ D \in \set X $ where $ C \hasparents \set X $.
77
78 \item[ $ C \has D $ ]
79 Informally, the tree at commit $C$ contains the change
80 made in commit $D$.  Does not take account of deliberate reversions by
81 the user or in non-Topbloke-controlled branches; these are considered
82 normal, forward, commits.  For merges and Topbloke-generated
83 anticommits, the ``change made'' is only to be thought of as any
84 conflict resolution.  This is not a partial order because it is not
85 transitive.
86
87 \item[ $ \p, \py, \pn $ ]
88 A patch $\p$ consists of two sets of commits $\pn$ and $\py$, which
89 are respectively the base and tip git branches.  $\p$ may be used
90 where the context requires a set, in which case the statement
91 is to be taken as applying to both $\py$ and $\pn$.
92 All these sets are distinct.  Hence:
93
94 \item[ $ \patchof{ C } $ ]
95 Either $\p$ s.t. $ C \in \p $, or $\bot$.  
96 A function from commits to sets $\p$.
97
98 \item[ $ \pancs{C}{\set P} $ ]
99 $ \{ A \; | \; A \le C \land A \in \set P \} $ 
100 i.e. all the ancestors of $C$
101 which are in $\set P$.
102
103 \item[ $ \pends{C}{\set P} $ ]
104 $ \{ E \; | \; E \in \pancs{C}{\set P}
105   \land \mathop{\not\exists}_{A \in \pancs{C}{\set P}}
106   A \neq E \land E \le A \} $ 
107 i.e. all $\le$-maximal commits in $\pancs{C}{\set P}$.
108
109 \item[ $ \baseof{C} $ ]
110 $ \pends{C}{\pn} = \{ \baseof{C} \} $ where $ C \in \py $.
111 A partial function from commits to commits.
112 See ``unique base'', below.
113
114 \item[ $ C \haspatch \p $ ]
115 $\displaystyle \bigforall_{D \in \py} D \isin C \equiv D \le C $.
116 ~ Informally, $C$ has the contents of $\p$.
117
118 \item[ $ C \nothaspatch \p $ ]
119 $\displaystyle \bigforall_{D \in \py} D \not\isin C $.
120 ~ Informally, $C$ has none of the contents of $\p$.  
121
122 Non-Topbloke commits are $\nothaspatch \p$ for all $\p$; if
123 a patch is merged into a non-Topbloke branch and we inherit
124 it, we hope that git's merge algorithm will DTRT.
125
126 \end{basedescript}
127
128 \section{Invariants}
129
130 \[ \eqn{No Replay:}{
131   C \has D \implies C \ge D
132 }\]
133 \[\eqn{Unique Base:}{
134  \bigforall_{C \in \py} \pends{C}{\pn} = \{ B \}
135 }\]
136 \[\eqn{Tip Contents:}{
137   \bigforall_{C \in \py} D \isin C \equiv
138     { D \isin \baseof{C} \lor \atop
139       (D \in \py \land D \le C) }
140 }\]
141 \[\eqn{Base Acyclic:}{
142   \bigforall_{B \in \pn} D \isin B \implies D \notin \py
143 }\]
144
145 \section{Some lemmas}
146
147 \[ \eqn{Exclusive Tip Contents:}{
148   \bigforall_{C \in \py} 
149     \neg \left[ D \isin \baseof{C} \land (D \in \py \land D \le C
150       \right )]
151 }\]
152 Ie, the two limbs of the RHS of Tip Contents are mutually exclusive.
153
154 \proof{
155 Let $B = \baseof{C}$ in $D \isin \baseof{C}$.  Now $B \in \pn$.
156 So by Base Acyclic $D \isin B \implies D \notin \py$.
157 }
158 \[ \corrolary{
159   \bigforall_{C \in \py} D \isin C \equiv
160   \begin{cases}
161     D \in \py : & D \le C \\
162     D \not\in \py : & D \isin \baseof{C}
163   \end{cases}
164 }\]
165
166 \[ \eqn{Tip Self Inpatch:}{
167   \bigforall_{C \in \py} C \haspatch \p
168 }\]
169 Ie, tip commits contain their own patch.
170
171 \proof{
172 Apply Exclusive Tip Contents to some $D \in \py$:
173 $ \bigforall_{C \in \py}\bigforall_{D \in \py}
174   D \isin C \equiv D \le C $
175 }
176
177 \[ \eqn{Exact Ancestors:}{
178   \bigforall_{ C \hasparents \set{R} }
179   D \le C \equiv
180     ( \mathop{\hbox{\huge{$\vee$}}}_{R \in \set R} D \le R )
181     \lor D = C
182 }\]
183
184 \[ \eqn{Transitive Ancestors:}{
185   \left[ \bigforall_{ E \in \pends{C}{\set P} } E \le C \right] \implies
186   \left[ \bigforall_{ A \in \pancs{C}{\set P} } A \le C \right]
187 }\]
188
189 \proof{
190 By the definition of $\mathcal E$,
191 for every such $A$, either $A \in \pends{C}{\set P}$ which implies
192 $A \le C$, or $\exists_{A' \in \pancs{C}{\set P}} \; A' \neq A \land A \le C $
193 in which case we repeat for $A'$.  Since there are finitely many
194 commits, this terminates.
195 }
196
197 \section{Test more symbols}
198
199 $ C \haspatch \p $
200
201 $ C \nothaspatch \p $
202
203 $ \p \patchisin C $
204
205 $ \p \notpatchisin C $
206
207 $ \{ B \} \areparents C $
208
209 \end{document}