---
title: "That of which we cannot speak, we must remain silent: absent symbols and the `frab` package"
author: "Robin Hankin"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
suppressMessages(library("frab"))
```

```{r out.width='20%', out.extra='style="float:right; padding:10px"',echo=FALSE}
knitr::include_graphics(system.file("help/figures/frab.png", package = "frab"))
```

I do not really understand what Wittgenstein was trying to say in
proposition 7 of his _Tractatus_, but the interpretation of symbols
not present in a `frab` object is certainly an interesting problem.
In this short unstructured and informal document, I consider how one
might consider key-value pairs in associative arrays when a particular
key is absent.  First, the canonical use-case for `frab` objects:

```{r frabaplusb}
(a <- frab(c(u= -5,v=2,w=1)))
(b <- frab(c(v=1,x=2)))
a+b
```

Above we see that `a` has no `"x"` term, and `b` has `"x"=2`, the sum
being `"x"=2`; we are justified in asserting that, in object `b`,
`"x"=0` even though it is not present.  However, consider this:

```{r frabminus2}
(x <- frab(c(a=4, b=-3, c=1, d=-1, e=9)))
x[x > -2]
```

Above we extract every element greater than $-2$.  We might say
"extract every element from `x` that is _known_ to exceed $-2$".  It
has not extracted any absent symbols such as `f`, and as such we
cannot associate `f` with zero (because zero exceeds $-2$, and no `f`
element was extracted).  But this is not consistent with the `a+b`
example above, in which absent symbols have the very definite and very
known value of zero.

One might wonder what happens if we try to coerce a named _logical_
vector to a `frab`:


```{r trytocoercelog,error=TRUE}
(logvec <- c(x=TRUE,y=FALSE,z=TRUE))
frab(logvec)
```

[earlier versions of the package allowed the coercion].  However, we
may coerce `logvec` to numeric (observe that `as.numeric()` loses the
names):

```{r coercetonum}
(logvec <- +logvec)   # NB as.numeric() loses names
frab(logvec)
```

Above, we see that `logvec["y"]` vanishes, being zero.  So logical
`frab` objects do not make sense as `FALSE` entries are discarded.