Skip to content

Commit 4fc7d2f

Browse files
committed
Add MathJax to typing rules page.
1 parent dc5212e commit 4fc7d2f

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

spec/typing.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ We define the GraphAlg type system formally using [typing rules](https://en.wiki
1212

1313
### Environments
1414
Typing rules use three distinct environments:
15-
- Function environment $F$: Associates function names with the parameter and results types of those functions.
15+
- Function environment $$F$$: Associates function names with the parameter and results types of those functions.
1616
- Dimension environment $D$: Associates variable names with dimension symbols.
1717
- Local environment $L$: Associates variable names with a matrix type.
1818

1919
The environment objects have map semantics:
2020
- $M \in L$ asserts that $L$ contains a value for $M$.
21-
- $L[M]$ retrieves the value for key $M$ from environment $L$.
21+
- $L[M]$ retrieves the value for key $M$ from environment $L$.
2222
Implies $M \in L$.
23-
- $L' := L[M := \tau]$ creates an updated environment $L'$ that contains all mappings from $L$ plus a mapping from $M$ to $\tau$.
23+
- $L' := L[M := \tau]$ creates an updated environment $L'$ that contains all mappings from $L$ plus a mapping from $M$ to $\tau$.
2424
If $M \in L$, then the original value for $M$ is dropped ($L'[M] = \tau$).
2525

2626
### Type Instances
27-
Type instances are denoted $\langle d_1, d_2, R \rangle$, where
28-
- $d_1$ is the dimension symbol for the number of rows
27+
Type instances are denoted $\langle d_1, d_2, R \rangle$, where
28+
- $d_1$ is the dimension symbol for the number of rows
2929
- $d_2$ is the dimension symbol for the number of columns
3030
- $R$ is the semiring
3131

3232
### Bindings
33-
We use the syntax $A := B$ to bind the value of $B$ to a new variable $A$.
33+
We use the syntax $A := B$ to bind the value of $B$ to a new variable $A$.
3434
This binding syntax is also used to destructure types, e.g. $\langle d_1, d_2, R \rangle := \tau$ allows referencing the dimension symbols and the semiring of $\tau$. Furthermore, the syntax can also be used for asserting (partial) matches. For example, the statement $\langle d, 1, R_1 \rangle = \tau_1$ following by $\langle 1, d, R_2 \rangle$ asserts that:
3535
- $\tau_1$ has one column
3636
- $\tau_2$ has one row
@@ -40,8 +40,8 @@ No requirement is placed on the relation of $R_1$ and $R_2$: they may refer to t
4040

4141
## Functions
4242
Functions have a function type of the form $(\tau_1 \times \tau_2) \rightarrow \tau_r$.
43-
A program is nothing more than a collection of functions.
44-
Note that the order in which functions are defined is significant:
43+
A program is nothing more than a collection of functions.
44+
Note that the order in which functions are defined is significant:
4545
A function cannot be referenced before they are defined.
4646

4747
<img src="latex/program.svg" width="600"/>
@@ -53,7 +53,7 @@ Statements update the $D$ and $L$ environments.
5353
They do not have a type of their own.
5454

5555
### Assign
56-
If there is no existing binding for the variable to be assigned, the first rule applies.
56+
If there is no existing binding for the variable to be assigned, the first rule applies.
5757
Otherwise, the more involved reassignment rule applies.
5858

5959
<img src="latex/stmt-assign.svg" width="600"/>
@@ -107,7 +107,7 @@ Transpose is valid for any input matrix.
107107
<img src="latex/expr-diag.svg" width="600"/>
108108

109109
### `apply`
110-
Functions used in `apply` must be defined over scalar input and output types.
110+
Functions used in `apply` must be defined over scalar input and output types.
111111
The parameter semirings must match those of the respective input arguments.
112112

113113
<img src="latex/expr-apply.svg" width="600"/>
@@ -149,7 +149,7 @@ Operations such as subtraction or division are only allowed on specific semiring
149149
<img src="latex/expr-arith.svg" width="600"/>
150150

151151
### Scalar Compare
152-
Ordered comparison operations are only allowed on the `int` and `real` semirings.
152+
Ordered comparison operations are only allowed on the `int` and `real` semirings.
153153
Equality comparison is allowed regardless of the semiring.
154154

155155
<img src="latex/expr-compare.svg" width="600"/>
@@ -158,3 +158,15 @@ Equality comparison is allowed regardless of the semiring.
158158
Literals must be valid for the specified semiring.
159159

160160
<img src="latex/expr-literal.svg" width="600"/>
161+
162+
<script>
163+
MathJax = {
164+
tex: {
165+
inlineMath: {'[+]': [['$', '$']]}
166+
},
167+
svg: {
168+
fontCache: 'global'
169+
}
170+
};
171+
</script>
172+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"></script>

0 commit comments

Comments
 (0)