Debian Codegraph @

texmf-dist/source/latex/ptolemaicastronomy/ptolemaicastronomy.dtx

raw
1 % \iffalse meta-comment
2 % vim: textwidth=75
3 %<*internal>
4 \iffalse
5 %</internal>
6 %<*readme>
7 ptolemaicastronomy
8 ==================
9
10 Diagrams of sphere models for variably strict conditionals (Lewis
11 counterfactuals)
12
13 Author: Richard Zach
14 E-mail: [email protected]
15 License: Released under the LaTeX Project Public License v1.3c or later
16 See: http://www.latex-project.org/lppl.txt
17
18 David K. Lewis (Counterfactuals, Blackwell 1973) introduced a sphere
19 semantics for counterfactual conditionals. He jokingly referred to the
20 diagrams depicting such sphere models as Ptolemaic astronomy, hence
21 the name of this package. It has nothing to do with Ptolemy or with
22 astronomy, sorry.
23
24 The macros provided in this package aid in the construction of
25 sphere model diagrams in the style of Lewis. The macros all make use
26 of TikZ.
27
28 See https://github.com/rzach/ptolemaic-astronomy
29
30 %</readme>
31 %<*internal>
32 \fi
33 \def\nameofplainTeX{plain}
34 \ifx\fmtname\nameofplainTeX\else
35 \expandafter\begingroup
36 \fi
37 %</internal>
38 %<*install>
39 \input docstrip.tex
40 \keepsilent
41 \askforoverwritefalse
42 \preamble
43
44 ptolemaicastronomy
45 ==================
46
47 Diagrams of sphere models for variably strict conditionals (Lewis
48 counterfactuals)
49
50 Author: Richard Zach
51 E-mail: [email protected]
52 License: Released under the LaTeX Project Public License v1.3c or later
53 See: http://www.latex-project.org/lppl.txt
54
55 David K. Lewis (Counterfactuals, Blackwell 1973) introduced a sphere
56 semantics for counterfactual conditionals. He jokingly referred to the
57 diagrams depicting such sphere models as Ptolemaic astronomy, hence
58 the name of this package. It has nothing to do with Ptolemy or with
59 astronomy, sorry.
60
61 The macros provided in this package aid in the construction of
62 sphere model diagrams in the style of Lewis. The macros all make use
63 of TikZ.
64
65 for documentation and source code see
66 https://github.com/rzach/ptolemaic-astronomy
67
68 \endpreamble
69 \usedir{tex/latex/ptolemaicastronomy}
70 \generate{
71 \file{\jobname.sty}{\from{\jobname.dtx}{package}}
72 }
73 %</install>
74 %<install>\endbatchfile
75 %<*internal>
76 \usedir{source/latex/ptolemaicastronomy}
77 \generate{
78 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
79 }
80 \nopreamble\nopostamble
81 \usedir{doc/latex/ptolemaicastronomy}
82 \generate{
83 \file{README.txt}{\from{\jobname.dtx}{readme}}
84 }
85 \ifx\fmtname\nameofplainTeX
86 \expandafter\endbatchfile
87 \else
88 \expandafter\endgroup
89 \fi
90 %</internal>
91 % \fi
92 %
93 % \iffalse
94 %<*driver>
95 \ProvidesFile{ptolemaicastronomy.dtx}
96 %</driver>
97 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
98 %<package>\ProvidesPackage{ptolemaicastronomy}
99 %<*package>
100 [2018/04/08 v1.00 Diagrams of sphere models for variably strict conditionals (Lewis counterfactuals)]
101 %</package>
102 %<*driver>
103 \documentclass{ltxdoc}
104 \usepackage[numbered]{hypdoc}
105 \usepackage{\jobname}
106 \usepackage{lstdoc}
107 \EnableCrossrefs
108 \CodelineIndex
109 \RecordChanges
110 \begin{document}
111 \DocInput{\jobname.dtx}
112 \end{document}
113 %</driver>
114 % \fi
115 %
116 % \GetFileInfo{\jobname.dtx}
117 % \DoNotIndex{\newcommand,\newenvironment}
118 %
119 %\title{\textsf{ptolemaicastronomy} --- Diagrams of sphere models for variably strict conditionals (Lewis counterfactuals)\thanks{This file
120 % describes version \fileversion, last revised \filedate.}
121 %}
122 %\author{Richard Zach\thanks{\href{http://richardzach.org/}{richardzach.org}, E-mail: [email protected]}}
123 %\date{Released \filedate}
124 %
125 %\maketitle
126 %
127 %\changes{v1.00}{2018/04/08}{First public release}
128 %
129 % \section{Introduction}
130
131 % Lewis\footnote{David K. Lewis, \emph{Counterfactuals} (Blackwell
132 % 1973)} introduced a sphere semantics for counterfactual
133 % conditionals. He jokingly referred to the diagrams depicting such
134 % sphere models as ``Ptolemaic astronomy,'' hence the name of this
135 % package. It has nothing to do with Ptolemy or with astronomy, sorry.
136
137 % The macros provided in this package aid in the construction of
138 % sphere model diagrams in the style of Lewis. The macros all make use
139 % of \href{https://ctan.org/tex-archive/graphics/pgf/}{Ti\emph{k}Z}.
140
141 % Source code can be found at \url{https://github.com/rzach/ptolemaic-astronomy}
142 %
143 % \section{Usage}
144 %
145 % \DescribeMacro{\spheresystem}
146 % To draw a sphere system with \meta{n} layers, say
147 % \cmd{\spheresystem}\marg{n}:
148 % \begin{lstsample}{}{}
149 % \begin{tikzpicture}
150 % \spheresystem{5}
151 % \end{tikzpicture}
152 % \end{lstsample}
153 % The width of each layer is determined by the TikZ parameter
154 % \verb|layerwidth| and defaults to $.5$ TikZ units (so $0.5$ cm by
155 % default). The radius of the center sphere is \emph{not}
156 % \verb|layerwidth|, but $\verb|layerwidth| \times (1 -
157 % \verb|innerfactor|)$. \verb|innerfactor| defaults to $0.4$.
158 % Spheres are drawn in \verb|dotted| style by default. You can change
159 % this by passing an option to \cmd{\spheresystem}, e.g.,
160 % to get red, dashed, thick lines and wider layers:
161 % \begin{lstsample}{}{}
162 % \begin{tikzpicture}
163 % \spheresystem[dashed, red,
164 % thick, layerwidth=.75]{3}
165 % \end{tikzpicture}
166 % \end{lstsample}
167 % \DescribeMacro{\spherelayer} \DescribeMacro{\spherefill} These
168 % macros shade the \meta{n}-th layer of the sphere model, or the
169 % entire \meta{n}-th sphere. The fill defaults to \verb|lightgray| and
170 % can be changed with \oarg{options}. Note that the fill extends to the
171 % center of the layer boundary line, so you should fill first and then
172 % draw the spheres. For instance:
173 % \begin{lstsample}{}{}
174 % \begin{tikzpicture}
175 % \spherelayer{3}
176 % \spherefill[yellow]{1}
177 % \spheresystem[densely dashed]{3}
178 % \end{tikzpicture}
179 % \end{lstsample}
180 % \DescribeMacro{\proposition}
181 % \DescribeMacro{\propositionintersect}
182
183 % A proposition is a set of worlds which (usually) intersects with a
184 % sphere system. A common way of drawing them is as a parabola, and
185 % often we want to highlight the intersection of the proposition with
186 % the closest sphere with which it intersects.
187 % \cmd{\proposition}\marg{direction}\marg{n}\marg{width}\marg{length}
188 % will draw such a parabola. \meta{direction} is the angle (0 is due
189 % east and 90 is due north) from which you want the proposition to
190 % reach into the sphere system. \meta{n} is the innermost layer you
191 % want it to intersect. \meta{width} and \meta{length} describe the
192 % triangle with apex \meta{width} degrees and sides of length
193 % \meta{length}. Use \cmd{\propositionintersect} to also highlight the
194 % intersection with the \meta{n}-th sphere. E.g., here are
195 % propositions that intersects the 3rd layer at 45 degrees, with a
196 % width of 20, 40, and 60 degrees, and the intersection of the first
197 % one with the innermost sphere it intersects.
198
199 % With the \verb|shift| option you can also position propositions outside the center, e.g., a proposition extending from the north through the west side of the sphere system would use, say, \verb|shift={(-1,-1)}|.
200
201 % \begin{lstsample}{}{}
202 % \begin{tikzpicture}
203 % \propositionintersect{45}{3}{20}{3}
204 % \proposition{45}{3}{40}{3}
205 % \proposition{45}{3}{60}{3}
206 % \proposition[shift={(-1,-1)}]{90}{1}{20}{4}
207 % \spheresystem{5}
208 % \end{tikzpicture}
209 % \end{lstsample}
210
211 % The degree of ``pointedness'' of propositions is determined by the
212 % \verb|tension| parameter, which defaults to $1.7$. Larger values
213 % make the proposition more bulgy, smaller values more pointy.
214
215 % \begin{lstsample}{}{}
216 % \begin{tikzpicture}
217 % \proposition[green,
218 % proposition/.style={tension=3}]{0}{3}{80}{3}
219 % \proposition{0}{3}{80}{3}
220 % \proposition[red,
221 % proposition/.style={tension=1}]{0}{3}{80}{3}
222 % \proposition[blue,
223 % proposition/.style={tension=.5}]{0}{3}{80}{3}
224 % \spheresystem{5}
225 % \end{tikzpicture}
226 % \end{lstsample}
227
228 % \DescribeMacro{\spherepos}
229 % \cmd{\spherepos}\marg{direction}\marg{n}\marg{code} moves to a
230 % position in the center of layer \meta{n} in \meta{direction} and
231 % then executes TikZ \verb|path| code \meta{code}. It's useful to put
232 % labels or other things into the sphere system.
233
234 % \begin{lstsample}{}{}
235 % \begin{tikzpicture}
236 % \propositionintersect{45}{3}{20}{3}
237 % \spheresystem{5}
238 % \spherepos[fill,red]{45}{3}{circle[radius=.1]}
239 % \spherepos{90}{4}{node {$w$}}
240 % \spherepos{45}{6.5}{node {$\varphi$}}
241 % \end{tikzpicture}
242 % \end{lstsample}
243
244 % \DescribeMacro{\sphereintersect} \cmd{\propositionintersect} uses
245 % \cmd{\sphereintersect}\oarg{options}\marg{n}\marg{code} to fill the
246 % area between the parabola and the outside edge of the \meta{n}-th
247 % sphere. (More precisely: what happens is that the area between the
248 % parabola and the line between its two endpoints is set as the
249 % clipping path, and then TikZ only shows the part of the shaded
250 % sphere within that clipping path.) That macro can also be used to
251 % intersect the respective layer with other paths, and in cases where
252 % the convex closure of the proposition does not include enough area.
253 % In that case, the clipping region has to be extended, and the path
254 % drawn separately. The example below shows what happens when a very
255 % wide parabola does not completely intersect with a sphere (on the
256 % right), how to use the trick to get the fill right (on the left), as
257 % well as how to intersect a more complex path with a sphere.
258
259 % \begin{lstsample}{}{}
260 % \begin{tikzpicture}
261 % \propositionintersect{0}{3}{140}{3}
262 % \sphereintersect{3}{\propositionplot{180}{3}{140}{3} -- (-2,-2)}
263 % \proposition{180}{3}{140}{3}
264 % \sphereintersect{4}{plot[smooth] coordinates
265 % {(1.5,2) (2.5,1) (1.5,0) (2.5,-1) (1.5,-2) (2.5,-3)}}
266 % \draw[red] plot[smooth] coordinates
267 % {(1.5,2) (2.5,1) (1.5,0) (2.5,-1) (1.5,-2) (2.5,-3)} ;
268 % \spheresystem{5}
269 % \end{tikzpicture}
270 % \end{lstsample}
271
272 % Finally, a complex example: the Sobel sequence diagram, Figure~2 from Lewis, p.~11:
273 % \begin{lstsample}{}{}
274 % \begin{tikzpicture}[scale=.8]\small
275 % % wider layers, pointier propositions
276 % \tikzset{layerwidth=1,innerfactor=0,
277 % proposition/.style={smooth,tension=1}}
278 % % fill the areas between three props and their innermost spheres
279 % \sphereintersect{3}{\propositionplot{30}{3.3}{30}{4}}
280 % \sphereintersect{2}{\propositionplot{30}{2.3}{45}{4}}
281 % \sphereintersect{1}{\propositionplot{30}{1.3}{60}{4}}
282 % % draw the sphere system
283 % \spheresystem{3}
284 % % draw the propositions
285 % \draw \propositionplot{30}{3.3}{30}{4};
286 % \draw \propositionplot{30}{2.3}{45}{4};
287 % \draw \propositionplot{30}{1.3}{60}{4};
288 % % draw \psi (coordinates figured out by trial and error)
289 % \draw plot[smooth,tension=1.2]
290 % coordinates {(-1.5,3) (1.2,-1) (.8,2.3) (2.8,.7) (3,4)};
291 % % draw and label the center world, spheres, and propositions
292 % \filldraw circle[radius=.05];
293 % \node at (-.2,-.2) {$i$};
294 % \spherepos{-70}{1.8}{node {$S^1_i$}}
295 % \spherepos{-70}{2.8}{node {$S^2_i$}}
296 % \spherepos{-70}{3.8}{node {$S^3_i$}}
297 % \spherepos{4}{4.3}{node {$\phi_1$}
298 % node at +(0,.5) {$\phi_2$}
299 % node at +(0,1) {$\phi_3$}}
300 % \spherepos{80}{4}{node {$\psi$}}
301 % \end{tikzpicture}
302 % \end{lstsample}
303
304 %\StopEventually{^^A
305 % \PrintChanges
306 % \PrintIndex
307 %}
308 %
309 % \section{Implementation}
310 %
311 % \iffalse
312 %<*package>
313 % \fi
314 %
315 % \begin{macrocode}
316 \RequirePackage{tikz}
317
318 \tikzset{
319 sphere/.style = {dotted},
320 sphere intersection/.style = {fill=lightgray},
321 sphere layer/.style = {fill=lightgray},
322 proposition/.style={smooth,tension=1.7},
323 }
324 % \end{macrocode}
325 % \begin{macro}{layerwidth}
326 % \begin{macro}{innerfactor}
327 % TikZ parameters used to compute the sphere radii and can be set
328 % using TikZ's options mechanism or using \cmd{\tikzset}.
329 % \begin{macrocode}
330 \pgfkeyssetvalue{/tikz/layerwidth}{.5}
331 \pgfkeyssetvalue{/tikz/innerfactor}{.4}
332 % \end{macrocode}
333 % \end{macro}\end{macro}
334 % \begin{macro}{\sphereplot}
335 % \cmd{\sphereplot}\marg{n} gives the plot codes for the \meta{n}-th sphere
336 % \begin{macrocode}
337 \newcommand{\sphereplot}[1]{
338 circle
339 [radius=(#1)*\pgfkeysvalueof{/tikz/layerwidth}-
340 \pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor}]
341 }
342 % \end{macrocode}
343 % \end{macro}
344 %
345 %
346 % \begin{macro}{\spheresystem}
347 % \cmd{\spheresystem}\oarg{options}\marg{n} draws a sphere system centered at
348 % the origin with \meta{n} number of layers
349 %
350 % \begin{macrocode}
351 \newcommand{\spheresystem}[2][]{
352 \foreach \i in {1,...,#2}{
353 \draw[sphere,#1] \sphereplot{\i} ;
354 }
355 }
356 % \end{macrocode}
357 % \end{macro}
358 %
359
360 %
361 %
362 % \begin{macro}{\spherelayer}
363 % \cmd{\spherelayer}\oarg{options}\marg{n} shades the \meta{n}-th layer
364 % \begin{macrocode}
365 \newcommand{\spherelayer}[2][]{
366 \begin{scope}[even odd rule]
367 \fill[#1,sphere layer]
368 \sphereplot{#2-1} \sphereplot{#2} ;
369 \end{scope}
370 }
371 % \end{macrocode}
372 % \end{macro}
373 %
374 % \begin{macro}{\spherefill}
375 %
376 % \cmd{\spherefill}\oarg{options}\marg{n} fills the \meta{n}-th sphere
377 %
378 % \begin{macrocode}
379 \newcommand{\spherefill}[2][]{
380 \fill[sphere intersection,#1]
381 \sphereplot{#2} ;
382 }
383 % \end{macrocode}
384 % \end{macro}
385 %
386 %
387 % \begin{macro}{\sphereintersect}
388 % \cmd{\sphereintersect}\oarg{options}\marg{n}\marg{path} shades the
389 % area between \meta{path} and the the \meta{n}-th sphere
390 % layer. Options only apply to the sphere layer.
391 % \begin{macrocode}
392 \newcommand{\sphereintersect}[3][]{
393 \begin{scope}[even odd rule]
394 \path[clip] #3;
395 \spherefill[#1]{#2}
396 \end{scope}
397 }
398 % \end{macrocode}
399 % \end{macro}
400 %
401 %
402 %
403 % \begin{macro}{\propositionplot}
404 % \cmd{\propositionplot}\oarg{options}\marg{direction}\marg{n}\marg{width}\marg{length}
405 % produces the \verb|plot| code for a proposition intersecting the \meta{n}-th layer in angle \meta{direction}
406 % away from the center of the sphere system, with endpoints \meta{length}
407 % away from the center at an angle of $\meta{direction} \pm \meta{width}/2$.
408 % \begin{macrocode}
409 \newcommand{\propositionplot}[4]{
410 plot [proposition]
411 coordinates {+(#1+#3/2:#4)
412 +(#1:#2*\pgfkeysvalueof{/tikz/layerwidth}-
413 \pgfkeysvalueof{/tikz/layerwidth}*.9
414 -\pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor})
415 +(#1-#3/2:#4)}
416 }
417 % \end{macrocode}
418 % \end{macro}
419 %
420 %
421 % \begin{macro}{\proposition}
422 % \cmd{\proposition}\oarg{options}\marg{direction}\marg{n}\marg{width}\marg{length}
423 % actually draws the proposition. Note that \meta{options} applies to
424 % \cmd{\draw}, not to \cs{plot}.
425 % \begin{macrocode}
426 \newcommand{\proposition}[5][]{
427 \draw[proposition,#1] \propositionplot {#2}{#3}{#4}{#5} ;
428 }
429 % \end{macrocode}
430 % \end{macro}
431 %
432 %
433 % \begin{macro}{\propositionintersect}
434 % \cmd{\spherepropositionintersect} does the same as \cmd{\sphereproposition} but
435 % also shades the area of intersection with the \meta{n}-th sphere.
436 %
437 % \begin{macrocode}
438 \newcommand{\propositionintersect}[5][]{
439 \begin{scope}
440 \path[clip] \propositionplot{#2}{#3}{#4}{#5};
441 \spherefill[#1]{#3}
442 \end{scope}
443 \draw[proposition,#1] \propositionplot{#2}{#3}{#4}{#5};
444 }
445 % \end{macrocode}
446 % \end{macro}
447 %
448 % \begin{macro}{\spherepos}
449 % \cmd{\spherepos}\oarg{options}\marg{direction}\marg{n}\marg{code}
450 % shifts the scope to a position in the center of the \meta{n}-th layer in
451 % direction angle from the center---and then puts a \meta{code} \verb|path|
452 % there.
453 %\begin{macrocode}
454 \newcommand{\spherepos}[4][]{
455 \begin{scope}[shift=(#2:#3*\pgfkeysvalueof{/tikz/layerwidth}-
456 \pgfkeysvalueof{/tikz/layerwidth}/2-
457 \pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor})]
458 \path[#1] #4 ;
459 \end{scope}
460 }
461 % \end{macrocode}
462 % \end{macro}
463 %
464 %
465 % \iffalse
466 %</package>
467 % \fi
468 %
469 % \Finale
470 \endinput
471