refactor: use typix and massively reorganize file system for innovation
innovation
This commit is contained in:
parent
66478400f7
commit
dad12b76a4
19 changed files with 278 additions and 633 deletions
|
@ -2,10 +2,11 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
typstPackagesCache,
|
typstPackagesCache,
|
||||||
typixLib,
|
typixLib,
|
||||||
|
cleanTypstSource,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
src = typixLib.cleanTypstSource ./.;
|
src = cleanTypstSource ./.;
|
||||||
commonArgs = {
|
commonArgs = {
|
||||||
typstSource = "main.typ";
|
typstSource = "main.typ";
|
||||||
|
|
||||||
|
@ -25,25 +26,10 @@ let
|
||||||
XDG_CACHE_HOME = typstPackagesCache;
|
XDG_CACHE_HOME = typstPackagesCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Compile a Typst project, *without* copying the result
|
|
||||||
# to the current directory
|
|
||||||
build-drv = typixLib.buildTypstProject (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Compile a Typst project, and then copy the result
|
|
||||||
# to the current directory
|
|
||||||
build-script = typixLib.buildTypstProjectLocal (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Watch a project and recompile on changes
|
|
||||||
watch-script = typixLib.watchTypstProject commonArgs;
|
|
||||||
in
|
in
|
||||||
build-drv
|
typixLib.buildTypstProject (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit src;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
165
2024/documents/by-name/digression-linear-algebra/main.typ
Normal file
165
2024/documents/by-name/digression-linear-algebra/main.typ
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
#import "@preview/unequivocal-ams:0.1.1": ams-article, theorem, proof
|
||||||
|
|
||||||
|
#show: ams-article.with(
|
||||||
|
title: [A Digression on Abstract Linear Algebra],
|
||||||
|
authors: (
|
||||||
|
(
|
||||||
|
name: "Youwen Wu",
|
||||||
|
organization: [University of California, Santa Barbara],
|
||||||
|
email: "youwen@ucsb.edu",
|
||||||
|
url: "https://youwen.dev",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bibliography: bibliography("refs.bib"),
|
||||||
|
)
|
||||||
|
|
||||||
|
= Introduction
|
||||||
|
|
||||||
|
Many introductory linear algebra classes focus on _application_. In general,
|
||||||
|
this is a red herring and is engineer-speak for "we will teach you how to
|
||||||
|
crunch numbers with no regard for conceptual understanding."
|
||||||
|
|
||||||
|
If you are a math major (or math-adjacent, such as Computer Science), this
|
||||||
|
class is essentially useless for you. You will learn how to perform trivial
|
||||||
|
numerical operations such as the _matrix multiplication_, _matrix-vector
|
||||||
|
multiplication_, _row reduction_, and other trite tasks better suited for
|
||||||
|
computers.
|
||||||
|
|
||||||
|
If you are taking this course, you might as well learn linear algebra properly.
|
||||||
|
Otherwise, you will have to re-learn it later on, anyways. Completing a math
|
||||||
|
course without gaining a theoretical appreciation for the topics at hand is an
|
||||||
|
unequivocal waste of time. I have prepared this brief crash course designed to
|
||||||
|
fill in the theoretical gaps left by this class.
|
||||||
|
|
||||||
|
= Basic Notions
|
||||||
|
|
||||||
|
== Vector spaces
|
||||||
|
|
||||||
|
Before we can understand vectors, we need to first discuss _vector spaces_. Thus
|
||||||
|
far, you have likely encountered vectors primarily in physics classes,
|
||||||
|
generally in the two-dimensional plane. You may conceptualize them as arrows in
|
||||||
|
space. For vectors of size $>3$, a hand waving argument is made that they are
|
||||||
|
essentially just arrows in higher dimensional spaces.
|
||||||
|
|
||||||
|
It is helpful to take a step back from this primitive geometric understanding
|
||||||
|
of the vector. Let us build up a rigorous idea of vectors from first
|
||||||
|
principles.
|
||||||
|
|
||||||
|
=== Vector axioms
|
||||||
|
|
||||||
|
The so-called _axioms_ of a _vector space_ (which we'll call the vector space
|
||||||
|
$V$) are as follows:
|
||||||
|
|
||||||
|
#enum[
|
||||||
|
Commutativity: $u + v = v + u, " " forall u,v in V$
|
||||||
|
][
|
||||||
|
Associativity: $(u + v) + w = u + (v + w), " " forall u,v,w in V$
|
||||||
|
][
|
||||||
|
Zero vector: $exists$ a special vector, denoted $0$, such that $v + 0 = v, " " forall v in V$
|
||||||
|
][
|
||||||
|
Additive inverse: $forall v in V, " " exists w in V "such that" v + w = 0$. Such an additive inverse is generally denoted $-v$
|
||||||
|
][
|
||||||
|
Multiplicative identity: $1 v = v, " " forall v in V$
|
||||||
|
][
|
||||||
|
Multiplicative associativity: $(alpha beta) v = alpha (beta v) " " forall v in V, "scalars" alpha, beta$
|
||||||
|
][
|
||||||
|
Distributive property for vectors: $alpha (u + v) = alpha u + alpha v " " forall u,v in V, "scalars" alpha$
|
||||||
|
][
|
||||||
|
Distributive property for scalars: $(alpha + beta) v = alpha v + beta v " " forall v in V, " scalars" alpha, beta$
|
||||||
|
]
|
||||||
|
|
||||||
|
It is easy to show that the zero vector $0$ and the additive inverse $-v$ are
|
||||||
|
_unique_. We leave the proof of this fact as an exercise.
|
||||||
|
|
||||||
|
These may seem difficult to memorize, but they are essentially the same
|
||||||
|
familiar algebraic properties of numbers you know from high school. The
|
||||||
|
important thing to remember is which operations are valid for what objects. For
|
||||||
|
example, you cannot add a vector and scalar, as it does not make sense.
|
||||||
|
|
||||||
|
_Remark_. For those of you versed in computer science, you may recognize this
|
||||||
|
as essentially saying that you must ensure your operations are _type-safe_.
|
||||||
|
Adding a vector and scalar is not just false, it is an _invalid question_
|
||||||
|
entirely because vectors and scalars and different types of mathematical
|
||||||
|
objects. See #cite(<chen2024digression>, form: "prose") for more.
|
||||||
|
|
||||||
|
=== Vectors big and small
|
||||||
|
|
||||||
|
In order to begin your descent into what mathematicians colloquially recognize
|
||||||
|
as _abstract vapid nonsense_, let's discuss which fields constitute a vector space. We
|
||||||
|
have the familiar space where all scalars are real numbers, or $RR$. We
|
||||||
|
generally discuss 2-D or 3-D vectors, corresponding to vectors of length 2 or
|
||||||
|
3; in our case, $RR^2$ and $RR^3$.
|
||||||
|
|
||||||
|
However, vectors in $RR$ can really be of any length. Discard your primitive
|
||||||
|
conception of vectors as arrows in space. Vectors are simply arbitrary length
|
||||||
|
lists of numbers (for the computer science folk: think C++ `std::vector`).
|
||||||
|
|
||||||
|
_Example_. $ vec(1,2,3,4,5,6,7,8,9) $
|
||||||
|
|
||||||
|
Moreover, vectors need not be in $RR$ at all. Recall that a vector space need
|
||||||
|
only satisfy the aforementioned _axioms of a vector space_.
|
||||||
|
|
||||||
|
_Example_. The vector space $CC$ is similar to $RR$, except it includes complex
|
||||||
|
numbers. All complex vector spaces are real vector spaces (as you can simply
|
||||||
|
restrict them to only use the real numbers), but not the other way around.
|
||||||
|
|
||||||
|
In general, we can have a vector space where the scalars are in an arbitrary
|
||||||
|
field $FF$, as long as the axioms are satisfied.
|
||||||
|
|
||||||
|
_Example_. The vector space of all polynomials of degree 3, or $PP^3$. It is
|
||||||
|
not yet clear what this vector may look like. We shall return to this example
|
||||||
|
once we discuss _basis_.
|
||||||
|
|
||||||
|
== Vector addition. Multiplication
|
||||||
|
|
||||||
|
Vector addition, represented by $+$, and multiplication, represented by the
|
||||||
|
$dot$ (dot) operator, can be done entrywise.
|
||||||
|
|
||||||
|
_Example._
|
||||||
|
|
||||||
|
$
|
||||||
|
vec(1,2,3) + vec(4,5,6) = vec(1 + 4, 2 + 5, 3 + 6) = vec(5,7,9)
|
||||||
|
$
|
||||||
|
$
|
||||||
|
vec(1,2,3) dot vec(4,5,6) = vec(1 dot 4, 2 dot 5, 3 dot 6) = vec(4,10,18)
|
||||||
|
$
|
||||||
|
|
||||||
|
This is simple enough to understand. Again, the difficulty is simply ensuring
|
||||||
|
that you always perform operations with the correct _types_. For example, once
|
||||||
|
we introduce matrices, it doesn't make sense to multiply or add vectors and
|
||||||
|
matrices in this fashion.
|
||||||
|
|
||||||
|
== Vector-scalar multiplication
|
||||||
|
|
||||||
|
Multiplying a vector by a scalar simply results in each entry of the vector
|
||||||
|
being multiplied by the scalar.
|
||||||
|
|
||||||
|
_Example_.
|
||||||
|
|
||||||
|
$ beta vec(a, b, c) = vec(beta dot a, beta dot b, beta dot c) $
|
||||||
|
|
||||||
|
== Matrices
|
||||||
|
|
||||||
|
Before discussing any properties of matrices, let's simply reiterate what we
|
||||||
|
learned in class about their notation. We say a matrix with rows of length $m$,
|
||||||
|
and columns of size $n$ (in less precise terms, a matrix with length $m$ and
|
||||||
|
height $n$) is a $m times n$ matrix.
|
||||||
|
|
||||||
|
Given a matrix
|
||||||
|
|
||||||
|
$ A = mat(1,2,3;4,5,6;7,8,9) $
|
||||||
|
|
||||||
|
we refer to the entry in row $j$ and column $k$ as $A_(j,k)$ .
|
||||||
|
|
||||||
|
=== Matrix transpose
|
||||||
|
|
||||||
|
A formalism that is useful later on is called the _transpose_, and we obtain it
|
||||||
|
from a matrix $A$ by switching all the rows and columns. More precisely, each
|
||||||
|
row becomes a column instead. We use the notation $A^T$ to represent the
|
||||||
|
transpose of $A$.
|
||||||
|
|
||||||
|
$
|
||||||
|
mat(1,2,3;4,5,6)^T = mat(1,4;2,5;3,6)
|
||||||
|
$
|
||||||
|
|
||||||
|
Formally, we can say $(A_(j,k))^T = A_(k,j)$.
|
35
2024/documents/by-name/digression-linear-algebra/package.nix
Normal file
35
2024/documents/by-name/digression-linear-algebra/package.nix
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
typstPackagesCache,
|
||||||
|
typixLib,
|
||||||
|
cleanTypstSource,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
src = cleanTypstSource ./.;
|
||||||
|
commonArgs = {
|
||||||
|
typstSource = "main.typ";
|
||||||
|
|
||||||
|
fontPaths = [
|
||||||
|
# Add paths to fonts here
|
||||||
|
# "${pkgs.roboto}/share/fonts/truetype"
|
||||||
|
];
|
||||||
|
|
||||||
|
virtualPaths = [
|
||||||
|
# Add paths that must be locally accessible to typst here
|
||||||
|
# {
|
||||||
|
# dest = "icons";
|
||||||
|
# src = "${inputs.font-awesome}/svgs/regular";
|
||||||
|
# }
|
||||||
|
];
|
||||||
|
|
||||||
|
XDG_CACHE_HOME = typstPackagesCache;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
typixLib.buildTypstProject (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit src;
|
||||||
|
}
|
||||||
|
)
|
|
@ -0,0 +1,6 @@
|
||||||
|
@misc{chen2024digression,
|
||||||
|
author = {Evan Chen},
|
||||||
|
title = {Digression on Type Safety},
|
||||||
|
year = {2024},
|
||||||
|
howpublished = {\url{https://web.evanchen.cc/upload/1802/tsafe-1802.pdf}},
|
||||||
|
}
|
|
@ -47,18 +47,24 @@
|
||||||
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
typixLib = typix.lib.${system};
|
||||||
in
|
in
|
||||||
let
|
let
|
||||||
inherit pkgs;
|
alexandriaLib = import ./nix/lib {
|
||||||
typixLib = typix.lib.${system};
|
inherit pkgs typixLib typstPackagesCache;
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# checks = {
|
# checks = {
|
||||||
# inherit build-drv build-script watch-script;
|
# inherit build-drv build-script watch-script;
|
||||||
# };
|
# };
|
||||||
|
|
||||||
packages.default = import ./documents/by-course/phil-1/paper-1/package.nix {
|
legacyPackages = {
|
||||||
inherit pkgs typixLib typstPackagesCache;
|
phil-1 = {
|
||||||
|
paper-1 = alexandriaLib.callTypstProject (import ./documents/by-course/phil-1/paper-1/package.nix);
|
||||||
|
};
|
||||||
|
digression-linear-algebra = alexandriaLib.callTypstProject (import ./documents/by-name/digression-linear-algebra/package.nix);
|
||||||
};
|
};
|
||||||
# apps = rec {
|
# apps = rec {
|
||||||
# default = watch;
|
# default = watch;
|
||||||
|
|
16
2024/nix/lib/callTypstProject.nix
Normal file
16
2024/nix/lib/callTypstProject.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
typixLib,
|
||||||
|
typstPackagesCache,
|
||||||
|
cleanTypstSource,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
package:
|
||||||
|
package {
|
||||||
|
inherit
|
||||||
|
pkgs
|
||||||
|
typixLib
|
||||||
|
typstPackagesCache
|
||||||
|
cleanTypstSource
|
||||||
|
;
|
||||||
|
}
|
18
2024/nix/lib/cleanTypstSource.nix
Normal file
18
2024/nix/lib/cleanTypstSource.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
src:
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
in
|
||||||
|
lib.cleanSourceWith {
|
||||||
|
src = lib.cleanSource src;
|
||||||
|
filter =
|
||||||
|
path: type:
|
||||||
|
let
|
||||||
|
isTypstSource = lib.hasSuffix ".typ" path || lib.hasSuffix ".bib" path;
|
||||||
|
isImage = lib.hasSuffix ".png" path || lib.hasSuffix ".jpeg" path || lib.hasSuffix ".jpg" path;
|
||||||
|
isSpecialFile = builtins.elem (builtins.baseNameOf path) [
|
||||||
|
"typst.toml"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
type == "directory" || isTypstSource || isSpecialFile || isImage;
|
||||||
|
}
|
19
2024/nix/lib/default.nix
Normal file
19
2024/nix/lib/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
typstPackagesCache,
|
||||||
|
typixLib,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
defaultArgs = {
|
||||||
|
inherit pkgs typstPackagesCache typixLib;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
cleanTypstSource = (import ./cleanTypstSource.nix) defaultArgs;
|
||||||
|
callTypstProject = (import ./callTypstProject.nix) (
|
||||||
|
defaultArgs
|
||||||
|
// {
|
||||||
|
inherit cleanTypstSource;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
1
2024/result
Symbolic link
1
2024/result
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/nix/store/fv6y2dqv26lw4gzb2pf6ms5hyikpbkm9-typst
|
1
2024/work/phil-1/paper-1-typix/.gitignore
vendored
1
2024/work/phil-1/paper-1-typix/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
result*
|
|
|
@ -1,99 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1726560853,
|
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1729256560,
|
|
||||||
"narHash": "sha256-/uilDXvCIEs3C9l73JTACm4quuHUsIHcns1c+cHUJwA=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"typix": "typix",
|
|
||||||
"typst-packages": "typst-packages"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"typix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1728290750,
|
|
||||||
"narHash": "sha256-piLZT8398O69hy0e3gX8hUWqSzbCslMCt10pT8d6c8E=",
|
|
||||||
"owner": "loqusion",
|
|
||||||
"repo": "typix",
|
|
||||||
"rev": "62d032735ad32a9a90225c06cb0857677fc753ee",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "loqusion",
|
|
||||||
"repo": "typix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"typst-packages": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1729252723,
|
|
||||||
"narHash": "sha256-xdaQYNw1GApaJnXJO4WnUTNuYeRXisxIUSuAzVXFEW4=",
|
|
||||||
"owner": "typst",
|
|
||||||
"repo": "packages",
|
|
||||||
"rev": "9bcf190c85da91be6df9f5fc25a93ce5812489cc",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "typst",
|
|
||||||
"repo": "packages",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
{
|
|
||||||
description = "A Typst project";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
||||||
|
|
||||||
typix = {
|
|
||||||
url = "github:loqusion/typix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
|
|
||||||
typst-packages = {
|
|
||||||
url = "github:typst/packages";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Example of downloading icons from a non-flake source
|
|
||||||
# font-awesome = {
|
|
||||||
# url = "github:FortAwesome/Font-Awesome";
|
|
||||||
# flake = false;
|
|
||||||
# };
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs =
|
|
||||||
inputs@{
|
|
||||||
nixpkgs,
|
|
||||||
typix,
|
|
||||||
flake-utils,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
flake-utils.lib.eachDefaultSystem (
|
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in
|
|
||||||
let
|
|
||||||
typstPackagesSrc = "${inputs.typst-packages}/packages";
|
|
||||||
|
|
||||||
typstPackagesCache = pkgs.stdenv.mkDerivation {
|
|
||||||
name = "typst-packages-cache";
|
|
||||||
src = typstPackagesSrc;
|
|
||||||
dontBuild = true;
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p "$out/typst/packages"
|
|
||||||
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
|
||||||
let
|
|
||||||
inherit pkgs;
|
|
||||||
typixLib = typix.lib.${system};
|
|
||||||
|
|
||||||
src = typixLib.cleanTypstSource ./.;
|
|
||||||
commonArgs = {
|
|
||||||
typstSource = "main.typ";
|
|
||||||
|
|
||||||
fontPaths = [
|
|
||||||
# Add paths to fonts here
|
|
||||||
# "${pkgs.roboto}/share/fonts/truetype"
|
|
||||||
];
|
|
||||||
|
|
||||||
virtualPaths = [
|
|
||||||
# Add paths that must be locally accessible to typst here
|
|
||||||
# {
|
|
||||||
# dest = "icons";
|
|
||||||
# src = "${inputs.font-awesome}/svgs/regular";
|
|
||||||
# }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Compile a Typst project, *without* copying the result
|
|
||||||
# to the current directory
|
|
||||||
build-drv = typixLib.buildTypstProject (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
XDG_CACHE_HOME = typstPackagesCache;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Compile a Typst project, and then copy the result
|
|
||||||
# to the current directory
|
|
||||||
build-script = typixLib.buildTypstProjectLocal (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
XDG_CACHE_HOME = typstPackagesCache;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Watch a project and recompile on changes
|
|
||||||
watch-script = typixLib.watchTypstProject commonArgs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
checks = {
|
|
||||||
inherit build-drv build-script watch-script;
|
|
||||||
};
|
|
||||||
|
|
||||||
packages.default = build-drv;
|
|
||||||
|
|
||||||
apps = rec {
|
|
||||||
default = watch;
|
|
||||||
build = flake-utils.lib.mkApp {
|
|
||||||
drv = build-script;
|
|
||||||
};
|
|
||||||
watch = flake-utils.lib.mkApp {
|
|
||||||
drv = watch-script;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.default = typixLib.devShell {
|
|
||||||
inherit (commonArgs) fontPaths virtualPaths;
|
|
||||||
packages = [
|
|
||||||
# WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
|
|
||||||
# See https://github.com/loqusion/typix/issues/2
|
|
||||||
# build-script
|
|
||||||
watch-script
|
|
||||||
# More packages can be added here, like typstfmt
|
|
||||||
pkgs.typstyle
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
= Lorem ipsum
|
|
||||||
#lorem(30)
|
|
Binary file not shown.
|
@ -1,302 +0,0 @@
|
||||||
#import "@preview/unequivocal-ams:0.1.1": ams-article, theorem, proof
|
|
||||||
#import "@preview/wordometer:0.1.3": word-count, total-words
|
|
||||||
|
|
||||||
#import "prelude.typ": indented-argument
|
|
||||||
|
|
||||||
#show: ams-article.with(
|
|
||||||
title: [The Argument for Betting on God and the Possibility of Infinite Suffering],
|
|
||||||
bibliography: bibliography("refs.bib"),
|
|
||||||
)
|
|
||||||
|
|
||||||
#show: word-count.with(exclude: (heading, <wordcount-exclude>, table))
|
|
||||||
|
|
||||||
#align(
|
|
||||||
center,
|
|
||||||
table(
|
|
||||||
columns: (auto, auto),
|
|
||||||
[
|
|
||||||
Perm: A2V4847
|
|
||||||
],
|
|
||||||
[
|
|
||||||
Word Count: #total-words
|
|
||||||
#footnote[
|
|
||||||
Figure computed programmatically during document compilation. Discounts
|
|
||||||
content in tables and the AI contribution statement.
|
|
||||||
]<wordcount-exclude>
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
= Introduction
|
|
||||||
|
|
||||||
The argument for Betting on God says that you should believe in God, regardless
|
|
||||||
of other evidence, purely out of self-interest. In this paper, I challenge this
|
|
||||||
argument by assessing the premise that believing in a particular God always
|
|
||||||
guarantees the greatest expected utility.
|
|
||||||
|
|
||||||
The author's argument for belief in God #cite(supplement: [p. 38],
|
|
||||||
<Korman2022-KORLFA>) goes as follows:
|
|
||||||
|
|
||||||
#indented-argument(
|
|
||||||
title: "The Argument for Betting on God",
|
|
||||||
abbreviation: "BG",
|
|
||||||
[One should always choose the option with the greatest expected utility.],
|
|
||||||
[Believing in God has a greater expected utility than not believing in God.],
|
|
||||||
[So, you should believe in God.],
|
|
||||||
)
|
|
||||||
|
|
||||||
BG1 should be uncontroversial. If you expect an action to bring you the most
|
|
||||||
utility (i.e. be the most useful), it's rational to do it.
|
|
||||||
|
|
||||||
To justify BG2, the author uses a so-called "decision matrix" to compute the
|
|
||||||
expected utility of each combination of action and possible outcome. The
|
|
||||||
possible actions are placed on the rows, and the possible outcomes are placed
|
|
||||||
on the columns, except for the last column, which is the calculated expected
|
|
||||||
utility. At each intersection of a row and column, we place the utility we gain
|
|
||||||
from that combination of action and outcome. The expected utility for a given
|
|
||||||
action is computed by multiplying the utility of each action-outcome pair in
|
|
||||||
that row by the probability of the corresponding outcome occurring, and summing
|
|
||||||
up all of those values.
|
|
||||||
|
|
||||||
Here is the decision matrix the author proposes on #cite(supplement: [p. 38],
|
|
||||||
<Korman2022-KORLFA>) which gives the expected utility for believing or not
|
|
||||||
believing in God.
|
|
||||||
|
|
||||||
#show table.cell.where(x: 0): strong
|
|
||||||
#show table.cell.where(y: 0): strong
|
|
||||||
|
|
||||||
#figure(
|
|
||||||
caption: [Author's decision matrix],
|
|
||||||
align(
|
|
||||||
center,
|
|
||||||
table(
|
|
||||||
columns: (auto, auto, auto, auto),
|
|
||||||
table.header(
|
|
||||||
[],
|
|
||||||
[God exists ($50%$)],
|
|
||||||
[God doesn't exist ($50%$)],
|
|
||||||
[Expected utility],
|
|
||||||
),
|
|
||||||
|
|
||||||
[ Believe in God ], [$infinity$], [2], [$infinity$],
|
|
||||||
[
|
|
||||||
Don't believe in God
|
|
||||||
],
|
|
||||||
[1],
|
|
||||||
[3],
|
|
||||||
[2],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
Note that the numerical utility values themselves have no meaning, and they are
|
|
||||||
meant to be viewed relative to each other. Utility doesn't literally provide an
|
|
||||||
empirical measure of "usefulness" or "happiness."
|
|
||||||
|
|
||||||
We assign the various finite utilities as we see fit, based on how much each
|
|
||||||
scenario benefits us. In the case where God does exist, and you believed in
|
|
||||||
God, then you are rewarded with an eternal afterlife of bliss and pleasure in
|
|
||||||
heaven. This reward is infinitely greater than any possible reward on earth, so
|
|
||||||
it has a utility of $infinity$.
|
|
||||||
|
|
||||||
So, the expected utility for not believing is $0.5 times 1 + 0.5 times 3 = 2$,
|
|
||||||
and the expected utility is $0.5 times infinity + 0.5 times 2 = infinity$. If,
|
|
||||||
according to BG1, you should pick the option with greatest expected utility,
|
|
||||||
clearly you should choose to believe in God, because the expected utility is
|
|
||||||
$infinity$.
|
|
||||||
|
|
||||||
The exact utilities don't matter much, since any finite utility you could gain
|
|
||||||
for atheism cannot possibly be greater than the infinite expected utility of
|
|
||||||
believing in God. Also, as the author points out on #cite(<Korman2022-KORLFA>,
|
|
||||||
supplement: [p. 40]), the exact probabilities don't matter either since
|
|
||||||
multiplying them by $infinity$ still results in the expected utility of
|
|
||||||
$infinity$.
|
|
||||||
|
|
||||||
I will show that the Argument for Betting on God fails because BG2 fails. In
|
|
||||||
section 2, I argue you cannot determine whether or not believing in God has the
|
|
||||||
greatest expected utility because the decision matrix approach fails when
|
|
||||||
possible outcomes involving infinitely negative utilities are introduced. In
|
|
||||||
section 3, I address a possible response to this objection.
|
|
||||||
|
|
||||||
= Possibility of Infinite Suffering
|
|
||||||
|
|
||||||
It is possible there are more gods than just the one that sends you to an
|
|
||||||
eternal afterlife for believing? The author partially addresses this in
|
|
||||||
#cite(<Korman2022-KORLFA>, supplement: [pp. 43-44]), using the example of Zeus.
|
|
||||||
Zeus will only reward those who believe in him with an eternal afterlife of
|
|
||||||
pleasure. So, if you believe in the wrong god, you don't go to the afterlife.
|
|
||||||
The author concludes either believing in Zeus or the Christian God still has
|
|
||||||
expected utilities of $infinity$, while being an atheist does has a finite
|
|
||||||
expected utility. Therefore, it is still preferable to believe in _some_ god
|
|
||||||
that may grant you an eternal afterlife, although no argument is made for
|
|
||||||
_which_ god.
|
|
||||||
|
|
||||||
However, this leaves out the possibility of gods who punish you for some
|
|
||||||
reason. For instance, suppose there exists an _Evil God_ who sends anyone who
|
|
||||||
believes in any god to hell for eternity, and does nothing to atheists.
|
|
||||||
|
|
||||||
Let us modify our decision matrix to model an outcome where the Evil God
|
|
||||||
exists.
|
|
||||||
|
|
||||||
#pagebreak()
|
|
||||||
|
|
||||||
#[
|
|
||||||
#set figure()
|
|
||||||
#figure(
|
|
||||||
caption: [Possibility of an Evil God],
|
|
||||||
table(
|
|
||||||
columns: (auto, auto, auto, auto, auto),
|
|
||||||
align: center,
|
|
||||||
table.header(
|
|
||||||
[],
|
|
||||||
[Correct god exists ($33.3%$)],
|
|
||||||
[No god exists ($33.3%$)],
|
|
||||||
[Evil God exists ($33.3%$)],
|
|
||||||
[E.U.],
|
|
||||||
),
|
|
||||||
|
|
||||||
[ Believe in some God ], [$infinity$], [1], [$-infinity$], [$?$],
|
|
||||||
[
|
|
||||||
Don't believe in any God
|
|
||||||
],
|
|
||||||
[2],
|
|
||||||
[3],
|
|
||||||
[4],
|
|
||||||
[4.5],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]<other-gods-table>
|
|
||||||
|
|
||||||
We've added the new option to our matrix. For the sake of argument, let's say
|
|
||||||
each option has an equally likely outcome. Again, the exact probabilities don't
|
|
||||||
really matter when we're multiplying them by infinity.
|
|
||||||
|
|
||||||
The utilities are mostly the same as before. Not believing in any god and the
|
|
||||||
Evil God existing is now the best case for the atheist since they avoided
|
|
||||||
infinite suffering. However, the theist now faces the possibility of the worst
|
|
||||||
case of all: eternal punishment for believing in the wrong god. If eternal
|
|
||||||
bliss in heaven has a utility of $infinity$, then it follows that we should
|
|
||||||
represent eternal punishment in hell with a utility of $-infinity$.
|
|
||||||
|
|
||||||
There is a problem: how do we calculate the expected utility of believing in
|
|
||||||
god? We have $0.333 times infinity + 0.333 times 1 + 0.333 times -infinity$.
|
|
||||||
What is $infinity - infinity$? A naive answer might be 0, but infinity is not a
|
|
||||||
number in the traditional sense. It makes no sense to add or subtract infinite
|
|
||||||
values. For instance, try and subtract the total amount of integers
|
|
||||||
($infinity$) from the total amount of real numbers (also $infinity$)
|
|
||||||
#footnote[Famously, this infinity is "larger" than the infinite number of
|
|
||||||
integers in the sense of cardinality (G. Cantor). But subtracting them still
|
|
||||||
makes no mathematical or physical sense.]. Clearly, this notion is meaningless
|
|
||||||
and we cannot obtain a solution. So, we consider $infinity - infinity$ an
|
|
||||||
_indeterminate form_. So, the expected utility is now _undefined_.
|
|
||||||
|
|
||||||
Consider the following Indeterminate Utilities argument:
|
|
||||||
|
|
||||||
#indented-argument(
|
|
||||||
title: "The Indeterminate Utilities argument",
|
|
||||||
abbreviation: "IU",
|
|
||||||
[If the expected utility of believing in god is undefined, then we
|
|
||||||
cannot compare the expected utilities of believing in god or not believing
|
|
||||||
in god.],
|
|
||||||
[The expected utility of believing in god is undefined.],
|
|
||||||
[So, we cannot compare the expected utilities of believing in god or
|
|
||||||
not believing in god.
|
|
||||||
],
|
|
||||||
[If we cannot compare the expected utilities of believing in god or
|
|
||||||
not believing in god, then we cannot determine if believing in god has a
|
|
||||||
higher expected utility than not believing in god.
|
|
||||||
],
|
|
||||||
[So, we cannot determine if believing in god has a higher expected
|
|
||||||
utility than not believing in god. ],
|
|
||||||
)<wordcount-exclude>
|
|
||||||
|
|
||||||
We just showed why the premise IU2 is true, and the conclusion IU5 is in direct
|
|
||||||
contradiction with BG2. So, if IU5 holds, then BG2 must fail.
|
|
||||||
|
|
||||||
It's important to note that the Indeterminate Utilities argument doesn't say
|
|
||||||
that the _opposite_ of BG2 is true. It doesn't argue that the expected utility
|
|
||||||
of being an atheist is greater. In fact, it doesn't say anything about the
|
|
||||||
expected utilities, except that they cannot be compared. If they can't be
|
|
||||||
compared, then we can't say for certain which option has the higher expected
|
|
||||||
utility. Since BG2 claims that believing in god must have the higher expected
|
|
||||||
utility, it is a false premise.
|
|
||||||
|
|
||||||
= Addressing Objections
|
|
||||||
|
|
||||||
// == Believing in a god is still preferable to atheism
|
|
||||||
//
|
|
||||||
// One might argue that believing in a god that rewards believers is always
|
|
||||||
// preferable to atheism since you at least have the _opportunity_ to receive
|
|
||||||
// eternity in heaven. Perhaps there exists a god who punishes non-believers with
|
|
||||||
// eternal damnation. Then, even without the exact expected utility calculation,
|
|
||||||
// it's clear that the expected utility of believing in some god must be higher
|
|
||||||
// than believing in none as you stand to gain more. Either as a theist or
|
|
||||||
// atheist, you run the risk of eternal punishment, but you only have the
|
|
||||||
// opportunity to go to heaven by believing in some god rather than none.
|
|
||||||
//
|
|
||||||
// Fair, the possibility that you are punished for believing in the wrong god
|
|
||||||
// doesn't imply that you should be an atheist either. Indeed, there may be a god
|
|
||||||
// that punishes atheists. However, there could also exist a god who sends
|
|
||||||
// everyone to heaven regardless. Or perhaps they only send atheists to heaven.
|
|
||||||
// Either way, there is also the possibility of attaining the infinite afterlife
|
|
||||||
// in heaven by being an atheist, so it's still impossible to say that the
|
|
||||||
// expected utility of believing in god is must be higher.
|
|
||||||
|
|
||||||
== The Evil God is not plausible
|
|
||||||
|
|
||||||
One might argue that it is not plausible there is an Evil God who punishes all
|
|
||||||
theists, including their own believers. Many religions present a god that
|
|
||||||
rewards believers and at most punishes disbelievers. None of the major world
|
|
||||||
religions propose an Evil God who punishes all believers. It's much more likely
|
|
||||||
that a benevolent god exists than an evil one.
|
|
||||||
|
|
||||||
I contend that it doesn't matter whether or not the Evil God is less plausible
|
|
||||||
than a benevolent god. Surely, if a rational atheist who is unconvinced by all
|
|
||||||
the world's scriptures can still concede that there is at least a non-zero
|
|
||||||
chance that some god exists, the rational theist should also concede that there
|
|
||||||
is a non-zero chance that the Evil God exists. All it takes is that non-zero
|
|
||||||
chance, no matter how small, because multiplying it by $-infinity$ still
|
|
||||||
results in the undefined expected utility.
|
|
||||||
|
|
||||||
== Finite utilities
|
|
||||||
|
|
||||||
One might argue that we can avoid using $infinity$ to ensure that all expected
|
|
||||||
utility calculations are defined. Instead, suppose that the utility of going to
|
|
||||||
heaven is just an immensely large finite number. The utility of going to hell
|
|
||||||
is likewise a very negative number. All of our expected utility calculations
|
|
||||||
will be defined, and given sufficiently large utilities, we should be able to
|
|
||||||
make a similar argument for believing in god.
|
|
||||||
|
|
||||||
// The problem with this argument is that we now open our expected utilities up to
|
|
||||||
// individual subjective determination. A core feature of the previous argument
|
|
||||||
// involving infinite utilities is that they can effectively bypass numerical
|
|
||||||
// comparison. If, instead, finite utilities were used, then each person may
|
|
||||||
// assign different utilities to each possible outcome based on their own beliefs.
|
|
||||||
// Also, the probabilities are no longer irrelevant, so they must be analyzed as
|
|
||||||
// well. This greatly complicates the decision matrix.
|
|
||||||
|
|
||||||
The problem with this argument is that infinity has a special property the
|
|
||||||
argument relies on. Namely, any number multiplied by $infinity$ is still
|
|
||||||
$infinity$, so the exact probabilities we set for the existence of God don't
|
|
||||||
matter. This is important for defending against the objection the author
|
|
||||||
mentions on #cite(<Korman2022-KORLFA>, supplement: [p. 40]), that the
|
|
||||||
probabilities are possibly incorrect, since the numbers don't matter anyways.
|
|
||||||
|
|
||||||
If, instead, only finite utilities were used, then the theist must contend with
|
|
||||||
the concern that the probabilities in the matrix are wrong. There could
|
|
||||||
conceivably exist a matrix with probabilities for a benevolent god and an Evil
|
|
||||||
God such that the expected utility of atheism is actually higher. The issue is
|
|
||||||
we cannot say for sure what the probabilities of the benevolent god and the
|
|
||||||
Evil God existing are. If we cannot know what the actual probabilities are,
|
|
||||||
then we cannot know the final outcome of our matrix. So, without knowing the
|
|
||||||
final outcome of the matrix, we still cannot determine whether or not believing
|
|
||||||
in god has greater expected utility, and BG2 still fails.
|
|
||||||
|
|
||||||
#pagebreak()
|
|
||||||
|
|
||||||
#[
|
|
||||||
= AI Contribution Statement
|
|
||||||
|
|
||||||
#quote[I did not use AI whatsoever in the writing of this paper.]
|
|
||||||
]<wordcount-exclude>
|
|
|
@ -1,49 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
typstPackagesCache,
|
|
||||||
typixLib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
src = typixLib.cleanTypstSource ./.;
|
|
||||||
commonArgs = {
|
|
||||||
typstSource = "main.typ";
|
|
||||||
|
|
||||||
fontPaths = [
|
|
||||||
# Add paths to fonts here
|
|
||||||
# "${pkgs.roboto}/share/fonts/truetype"
|
|
||||||
];
|
|
||||||
|
|
||||||
virtualPaths = [
|
|
||||||
# Add paths that must be locally accessible to typst here
|
|
||||||
# {
|
|
||||||
# dest = "icons";
|
|
||||||
# src = "${inputs.font-awesome}/svgs/regular";
|
|
||||||
# }
|
|
||||||
];
|
|
||||||
|
|
||||||
XDG_CACHE_HOME = typstPackagesCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Compile a Typst project, *without* copying the result
|
|
||||||
# to the current directory
|
|
||||||
build-drv = typixLib.buildTypstProject (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Compile a Typst project, and then copy the result
|
|
||||||
# to the current directory
|
|
||||||
build-script = typixLib.buildTypstProjectLocal (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit src;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Watch a project and recompile on changes
|
|
||||||
watch-script = typixLib.watchTypstProject commonArgs;
|
|
||||||
in
|
|
||||||
build-drv
|
|
|
@ -1,21 +0,0 @@
|
||||||
#set cite(style: "institute-of-electrical-and-electronics-engineers")
|
|
||||||
#set text(fractions: true)
|
|
||||||
|
|
||||||
#let indented-argument(title: "", abbreviation: "", ..args) = [
|
|
||||||
#set par(first-line-indent: 0pt)
|
|
||||||
|
|
||||||
#pad(left: 12pt, smallcaps(title))
|
|
||||||
|
|
||||||
#let arg-numbering = (..nums) => nums.pos().map(n => (
|
|
||||||
"(" + abbreviation + str(n) + ")"
|
|
||||||
)).join()
|
|
||||||
|
|
||||||
#enum(
|
|
||||||
numbering: arg-numbering,
|
|
||||||
indent: 16pt,
|
|
||||||
tight: false,
|
|
||||||
..args.pos(),
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
@book{Korman2022-KORLFA,
|
|
||||||
author = {Daniel Z. Korman},
|
|
||||||
editor = {},
|
|
||||||
publisher = {The PhilPapers Foundation},
|
|
||||||
title = {Learning From Arguments: An Introduction to Philosophy},
|
|
||||||
year = {2022}
|
|
||||||
}
|
|
Loading…
Reference in a new issue