Do numbers exist?

Feb. 21st, 2019 07:48 pm
[syndicated profile] drmaciver_feed

Posted by David R. MacIver

Do numbers exist?

In What even is a number? I finished with:

There is a more foundational question, which is whether numbers "exist" in any meaningful sense. My answer is "Almost certainly not, but if so why would we care?"

I'm going to backtrack on that a bit. Obviously numbers exist.

The problem is that this is a bad question because there are no non-misleading answers to it. Both the statements "numbers exist" and "numbers do not exist" are more likely to cause you to believe false things than true ones, and which answer you prefer says more about what you mean by "exist" than it does about numbers.

Numbers don't exist, in that there is no platonic realm where you will find the authentic number 3. At least, there is no evidence that there is such a realm, there isn't even a suggestion of what such evidence would look like, and it doesn't seem to be especially useful to postulate that one exists, so there might as well not be. Insert your own atheism analogy here. Michelangelo's Stone: an Argument against Platonism in Mathematics is a good argument against the idea that one exists, basically by pointing out that if such a thing existed it would be too large to serve the role that its proponents want it to - it is basically the infinite library of Borges, with every random string written down in a book. All published works exist there, but finding them is a harder task than creating them would be.

Additionally, they don't exist because as I argued, numbers aren't really any one thing. There is not "the number 3", there is only "the value that corresponds to the number 3 in our current implementation of natural numbers." In What Numbers Could not Be Paul Benacerraf argues quite convincingly that it is a category error to equate the number 3 with any particular instantiation of it.

So numbers really don't exist in any literal physical sense. I promise.

And yet numbers obviously exist.


Well because all of the same arguments apply to Chess, and if you try telling someone that Chess doesn't exist they'll look at you like you've sprouted an extra head.

Imagine the conversation:

You: Chess does not exist.

Them: Um, yes it does. Look, here's a Chess board.

You: Sure, that's a Chess board, but that's not Chess, that's just the symbolic representation you use to play the game of Chess.

Them: Which doesn't exist.

You: That's correct, yes.

Them: We have literally played a game of Chess on this board. How can we play Chess if it doesn't exist?

You: It's easy, you just follow the rules of Chess.

Them: Which don't exist.

You: Oh, well, there are rules of Chess of course, but those are mere matters of human convention. They don't imply any sort of abstract platonic ideal of Chess that exists somewhere.

Them: Look, here is a printed out copy of the rules of Chess.

You: I see. And?

Them: That seems to suggest the rules of chess exist.

You: Why? Those aren't the rules of chess, they're just words on a page that describe how to play chess. The rules are a purely abstract concept that exist purely as a matter of human convention.

Them: This seems like a fairly spurious distinction.

You: I suppose it does rather.

Them: Shall we settle it over a game of Chess?

You: Sure, why not.

And yet these are exactly parallel to the arguments that say numbers don't exist. People are very attached to the idea that you can apply the word "exist" to abstract objects and, while I don't want to entirely defer to common usage of a word for its more specific meaning, I think it would require an extremely convincing argument to persuade me that they are wrong to do so. Countries are also purely abstract objects designed purely as a matter of human rules and convention, but if you told me that France did not exist I could only answer "It does, though".

So, any reasonable definition of the word "exist" should incorporate abstract concepts with rules and names defined purely by human convention. Numbers are such a thing, and as purely abstract concepts it is perfectly reasonable to say that they exist. They exist in the same way and for the same reasons that France and Chess exist: Because we say so.

kaberett: a watercolour of a pale gold/salmon honeysuckle blossom against a background of green leaves (honeysuckle)
[personal profile] kaberett
I didn't (unsurprisingly) get the greenhouse, but looking at it did substantially clarify my thoughts and the eBays do regularly contain less fancy greenhouses that, actually, probably will perfectly well do the job now I know what I'm after.

In which I ramble about hardware and tell stories about secateurs. )

In terms of my upcoming jobs and planting...

Well, I need to spend some quality time pruning the Ribes bushes various; the plot came with a red dessert gooseberry, a redcurrant, and what-I-think-is-a-jostaberry, all of which are a little neglected and tangled. Tidying them up was on the list for Sunday immediately after the teasels, but a pair of secateurs that couldn't handle a teasel was... erstrecht not going to cope with actual wood. They also need top dressing with manure and then probably mulching, but that can wait until after I've tidied them up a little.

Next door, I've come to the conclusion that what I want to do with my ground-level bed (squash, pak choi, and failed calabrese last year) this season is set some broad beans and peas going down the middle around now, and then sow quinoa down the edges some time later. On the one hand, it's not known that this is a good idea; on the other, intercropping legumes and quinoa is a topic of active research and growing trials, and it looks to me like it ought to be sensible, so no doubt you will collectively get Running Commentary while I experiment.

At home, it's time for me to get the purple chillis and the orange bell peppers started (if I'm going to); that can't really happen until we're back full time, and while I'm happy to heat the house to a temperature that is safe and adequate for me to exist in when I'm actually there most of the time, that is... less the case when I'm away. (I'm attempting to resist the temptation to acquire a heated propagator.) Also the tomatoes, though there the thing I really need to do is work out where I want to put them -- whether I want to grow them on at home again, or if I'll be looking to plant them out at the plot.

Which is a general problem -- the working-out-where-to-plant-things. I'm dithering but probably about to come down on the side of putting the saffron bulbs in around the base of the cherry tree; I think I know where I'm going to put the comfrey once it's established itself a little better; and I'm tentatively leaning towards growing the poppies-for-seed in a patch of mixed wildflowers. (WHERE, though, Alex, you need to work out where you're going to put this. Probably also in the general vicinity of the cherry, if we're honest.)

But. Yes. Priorities: getting misc. seeds started; actually sourcing and constructing my proper raised beds so that I can plant out into them (which will inevitably involve More Weeding); pruning and dressing the Ribes; and working out what I want by way of asparagus, because my mother has offered to buy me some crowns.

So, you know, if you have asparagus cultivar recommendations, please by all means go ahead! I prefer the stems to the tips, and I am resigned to growing at least some purple...

What even is a number?

Feb. 18th, 2019 06:52 pm
[syndicated profile] drmaciver_feed

Posted by David R. MacIver

What even is a number?

Context: A philosopher friend asked me this question. This is my attempt to answer.

Attention Conservation Notice: It may not be a very good attempt to answer.

Epistemic status: My philosophy of mathematics is slightly idiosyncratic, in the sense that most people appear to believe ridiculously wrong things so it is unusual to be correct about this. I'm aware that feeling this is a bad sign for one's reliability.

Content warning: Highly informal mathematics.

My glib answer to this question which is completely 100% true and is actually quite deep when unpacked is "Depends. What do you want it to be?".

This is an answer that took a few hundred years of very heated arguing and people defending their own aesthetic preferences about numbers to arrive at. You can see some of that history of what we call some of the different sorts of numbers: e.g. Negative, irrational, and imaginary numbers.

Each of these represents a bitter argument about whether a new type of number should be allowed, all of which were eventually won by the people on the side of the new numbers, but with a legacy of our distaste for them left in the name.

You can view this as a process of discovery, with people finding out new things that are also numbers. You would be factually incorrect in doing so, and misunderstanding the basic nature of mathematics, but you could.

The main problems with this viewpoint are that there isn't really a single thing that we mean by "number", and each of these types of number is better viewed as having been invented than discovered.

Anyway, before we talk about the fundamental nature of mathematics, lets talk about sheep.

Suppose you are a farmer and you want to keep track of your sheep. In particular you want to make sure that all of your sheep who left the enclosure in the morning return to it in the evening. Unfortunately, numbers haven't been invented yet. What do you do?

(This is not a true history and is only a parable. Also it is definitely not my own invention but I can't figure out who the original source for this story is. Plausibly it's based on a misremembering of Yan Tan Tethera. People keep telling me it's from Yudkowsky but that's definitely not where I got it from and Lucy Keer points out prior art that is also not where I got it from. At this point I think we might as well just label it folklore)

Well, there's a very easy trick! You keep a small bag. Every time a sheep leaves the enclosure in the morning, you put a pebble in the bag. Every time a sheep returns to the enclosure, you take a stone out of the bag.

There are a couple of scenarios here:

  1. If all the sheep are in the enclosure and the bag is empty then the same number of sheep have left as returned, yay.
  2. If all the sheep you see are in the enclosure and there are still stones in the bag, you're missing some sheep. For each stone remaining, there is a missing sheep out there somewhere.
  3. If the bag is empty and there are still sheep outside of the enclosure, something has gone a bit wrong. You seem to have picked up some extra sheep from somewhere.

To take a simple system and make it complicated, what we have done is create a correspondence between the set of stones in the bag and the set of sheep outside the enclosure, such that we can perform equivalent operations on each of these things. In this correspondence we have the following:

  • There is a ground state of emptiness.
  • We can add an item to the set (a sheep leaves the enclosure, a stone enters the bag), at which point it becomes non-empty.
  • If the set is non-empty, we can remove an item from it (a sheep enters the enclosure, a stone leaves the bag).

The thing that makes this correspondence work is that the set of stones and the set of sheep behave in the same way, and so we can set up parallel arguments based on the behaviour of these two different systems matching at every step of the way.

Our claim is that the sheep are all in the enclosure if and only if the bag is empty. How can we know that this is the case?

Lets represent a series of operations on one of these things (the bag or the sheep) by writing them down as follows: We write down a \(+\) every time something is added to the collection (the rocks in the bag, the sheep in the enclosure), and a \(-\) every time something is removed. So for example if three sheep leave the enclosure and then two enter it (three rocks enter the bag, two are taken out of it), we would write that as \(+++--\).

These sequences obey the following rules:

  1. If the sequence starts with \(-\) then something has gone wrong - we've tried to take a rock out of an empty bag, or a sheep out of a world with no sheep in it.
  2. If the sequence ends with a \(+\) then the collection is not empty (we've just added something to it - we put a rock in the bag, a sheep left the enclosure).
  3. If there is a \(+-\) somewhere in the sequence (we put a rock in the bag then immediately took one out, a sheep left the enclosure and then a sheep returned) then the sequence of operations is equivalent to the same sequence with that \(+-\) removed (any two sheep and any two rocks are interchangeable for our purposes).

We can now determine whether the end state of any sequence of operations is empty solely from its representation in this notation by running the following procedure:

  1. If there are no operations, we are in the starting state of emptiness so the set is empty.
  2. If the last element is a \(+\) then by the above rules the set is not empty.
  3. If the first element is a \(-\) then we're in an error state. Thus the first element must be a \(+\) and we contain at least one \(-\). Scan forward until we find the first \(-\). This must follow a \(+\) (because it's the first). Remove that \(+-\) pair from the sequence to get a shorter sequence, and determine if the new sequence is empty.

In each step of this process one of two things happen:

  1. We determine the answer and stop.
  2. We replace the sequence with a strictly shorter sequence and try again.

This process of replacing the sequence with a strictly shorter one must eventually stop, because we can run it for no longer than it took us to build the sequence in the first place. This means we eventually end up either with an empty sequence (the set is empty) or with a sequence with only \(+\) operations in it (the set is not empty). Importantly, because these operations represent either sheep or stones, and because both sheep and stones obey the rules we laid out above, we know that the set of sheep in the outside world is empty if and only if the bag is empty: We can represent the current state of each by the same sequence of \(+\) and \(-\) operations, and we can determine solely from those operations whether the set is empty.

We can abstract this further.

Say something is a counter if you can do the following three things and obey the following rules:

  1. Ask if it is currently empty.
  2. Increment it.
  3. If it is not currently empty, decrement it.

Say two counters are observationally equivalent if, after doing the same sequence of increment/decrement operations to each side, they are either both empty or both not-empty.

Now, counters must obey the following rules:

  1. After incrementing it, the counter is not empty.
  2. Incrementing it then decrementing it results in a counter that is observationally equivalent to the original counter (and in particular is empty if and only if it started empty).

The above argument provides the stronger conclusion: Any two empty counters are observationally equivalent. We can represent the sequences of operations with our \(+/-\) notation, and at the end we will have concluded that either both counters are empty or both counters are non-empty.

OK, what does this have to do with the original question about numbers?

A counter can be anything that implements those increment and decrement operations. You can ask "What is a counter?" and the answer isn't any one thing. It could be a flock of sheep, it could be a bag of stones. Both of those things are counters, because they allow you to implement the counter operations in a way that obeys the rules. The notion of a counter is not that of a single concrete class of object, it is an abstract description of the behaviour of a system providing certain operations satisfying certain rules.

The nice thing about the counter rules is that to a certain degree we don't need to care what a counter is - the power of the behaviour is that we can know that whichever counter implementation we have, they will behave the same way. Because any two empty counters are observationally equivalent you can talk about the empty counter, but this is a polite fiction: There are an infinite variety of empty counters, we just don't care because they all behave the same way as far as counting is concerned.

This is also what a number is. A number is not any one thing, it is any one of any number of things that implement some operations (and there are different types of number depending on what operations you want to implement).

The numbers closest to the counters we've discussed are what are called the natural numbers: \(0, 1, 2, \ldots\). They don't include negative numbers like \(-3\) or fractional numbers like \(\frac{1}{2}\). We could also call them counting numbers, as these are the numbers which can be used to represent operations that correspond to counting things

The operations you can perform on natural numbers are that you can take their successor (the next element), and you can test if two numbers are equal. Additionally, there is a special element called zero (or \(0\)). The rules they have to satisfy are the following:

  1. \(0\) is not the successor of any element.
  2. Every element has a successor element.
  3. If two elements are equal then their successor is equal (this is important to state because there may e.g. be irrelevant information in the representation. Think of how we represented counts with stones - two bags of stones represent the same if they have the same number of stones, regardless of whether they're literally the same stones).
  4. If the successor of two elements are equal then those elements are also equal.
  5. Every number can be formed by writing down a series of successor operations from zero.

For example, one implementation of the natural numbers is our sequences of \(+\) operations for a counter. The empty sequence is our \(0\) element, taking the successor is adding a \(+\) to the end, two elements are equal if they are the same word.

In the same way that we reasoned about the behaviour of counters without having to know exactly what counter implementation we were using, we can reason about the behaviour of numbers without knowing how they work, and conclude properties that must hold for any implementations.

In particular, we can conclude from \(4\) that every element other than \(0\) is the successor of some other element: Suppose for an arbitrary number that we'll call \(n\), we write the successor of \(n\) as \(S(n)\). Then any number other than \(0\) can be written as \(S(S(\ldots S(0)\ldots))\) by rule \(4\), so is the successor of the bit inside the brackets. By rule \(3\), every non-zero number has a unique element that it is the successor of. Call this its predecessor. Similarly if \(n\) is some arbitrary non-zero number then we write its predecessor as \(P(n)\).

This means that we can use any implementation of natural numbers to implement a counter as follows:

  1. A counter wraps a single number.
  2. It is empty if that number is \(0\)
  3. When incrementing the counter we replace the number with its successor.
  4. When decrementing the counter we replace the number with its predecessor (which is valid because the counter is non-empty if and only if it contains a non-zero number).

Two of these counters are observationally equivalent if and only if they wrap equal numbers, because for any such counter you can produce a unique sequence of decrements that makes it empty (this isn't totally obvious, but the details are fiddly and unenlightening without getting much more formal than I want to).

This means that we can use any implementation of numbers to define the notion of the size of any given counter: It is the unique (up to equality) number that is observationally equivalent to the current counter.

The careful reader will notice a sleight of hand there: I haven't proven that there is always such a number, only that if there is one then it is unique. This is because there is not always such a number!

The following is a perfectly valid implementation of a counter:

  1. The counter is never empty.
  2. Incrementing the counter does nothing.
  3. Decrementing the counter does nothing.

Such a counter cannot be represented by a number, because for any number based counter implemented as above you can eventually run a sequence of decrement operations to make it empty. You could think of such a thing as representing an infinite collection, but note that this doesn't require any foundational assumptions about whether infinity is in some sense real or realisable, it's just a straightforward implementation of a set of rules.

In fact, every counter as defined is equivalent to either this infinite counter or some number, but I'll leave proving that as an exercise for the interested reader.

OK, after all of that, what actually is a number?

Depends. What do you want it to be?

The problem with asking this question about abstract mathematical entities like numbers is that they are not any one thing. A number is not its representation, any more than a counter is a bag of rocks or a flock of sheep. A number is an entity that comes from some implementation of the operations that we have decided to consider distinctively numeric.

An interesting feature of something like the natural numbers is that we can choose the rules to uniquely constrain the behaviour of the implementation (with some caveats about formal systems that I won't go into here), but there are many other classes of mathematical objects that are also interesting where this is not the case.

There is a more foundational question, which is whether numbers "exist" in any meaningful sense. My answer is "Almost certainly not, but if so why would we care?". It may be that there is some pure platonic realm of numbers where the true numbers exist, but we don't need it to exist to do mathematics, and it's unclear what its existence would imply about how we do mathematics anyway - it's not like this view of mathematical objects as reasoning about abstract systems obeying rules stops working in that event, the platonic realm just becomes another system that we can model this way.

kaberett: Trans symbol with Swiss Army knife tools at other positions around the central circle. (Default)
[personal profile] kaberett
with all the usual caveats about how noisy crowds + not being able to easily move away from people smoking &c all sounds utterly miserable and like it will wreck me for days and possibly weeks--

-- which means that I probably want a sign that reads something to the tune of "Leaving the house was a bad idea. Leaving the EU would be worse." Right? Should I be making it pithier and more entertaining? Is it even a coherent idea?


Feb. 17th, 2019 08:31 pm
kaberett: Trans symbol with Swiss Army knife tools at other positions around the central circle. (Default)
[personal profile] kaberett
Reading. I finished Predators' Gold! It did not redeem itself, to my tastes. I then proceeded to have a bit of a tailspin about "do I object to fiction that portrays people doing bad things without getting 'adequately' punished or without it getting called out in the text? am I secretly an anti?" but the answer is, on reflection, no -- I don't think it's Immoral Art That Should Be Banned, it's just that I've got a very long reading list including a bunch of books I am actually excited (rather than cross) about, and I abruptly Really Don't Care about these characters enough to invest any more time in them at all whatsoever. Meanwhile, I have not been reading much because reasons, but Dreams from My Father reappeared from the library so I'm working slowly on that. Also I finally scraped together the brain to read the most recent shortfic associated with your blue-eyed boys ("shortfic": one of them was 23k words), which was immensely soothing.

Growth. I went to the allotment today! The fennel died back a lot in the frosts but I'm hopeful that 1. it will continue turning into food (it's putting forth new feathery growth) and 2. some if it will get as far as making seeds. I pulled up all the teasels and got as many of them as I could before the cheap shitty secateurs broke, so those are in a neat pile, and did a very little hand-weeding. Happily, though, the combination of manure + weed-suppressant takeaway pizza boxes + wood chip meant that there was really very little weeding as needed done, which impressed me. Spinach is coming along nicely but probably needs thinning (and eating); to my surprise a nontrivial chunk of the remaining pak choi also survived the frosts and are now doing their determined best to flower.

When I got in on Wednesday night, I discovered that my comfrey crowns had finally arrived (on the second attempt) so I've now got those potted up on the patio to establish while I work out where to put them. This means that I also received the last of the seeds currently on order, though I am now seriously considering acquiring two kinds of basil, some caraway and sesame seed, some rocket, and maaaaybe some chickpeas, though chickpeas seem possibly even a step too far for me.

Alas I did not win the greenhouse I had been pining after, but it ended up going for about three times what I was willing or able to pay for it, which means I successfully do not feel bad about having "just missed out" or similar.

Lab supplies. So many lab supplies. I got to campus at around 9 on Thursday and... slightly didn't leave again til 2pm on Saturday, though hopefully by the next time I want to do anything of the sort I'll have 24h access enabled on my card so I'll be able to actually kip on the sofa in my head of group's office rather than drowzing underneath the computer table in the Bloody Cold. (I was wearing three jumpers, a scarf, and fingerless gloves, and I still spent most of those three days shivering.)

Friday Five: Groceries

Feb. 16th, 2019 01:01 pm
jack: (Default)
[personal profile] jack

1. Do you make up a dinner plan for the coming week?

No. Now, with two people in the house, we cook often enough it might be worth planning in advance, but just playing it by ear is working well enough. I used to do less proper cooking, when I didn't think about it at all, I only ever really bought things that kept, and treated each meal separately.

2. Do you make up a shopping list and stick to it when shopping?

There's not really a thing about sticking to it. I've been fortunate not to have to worry deeply about sticking for a budget, but I've also never really excitement to buy unusual things, so I don't usually have a big desire to buy other things (I mean, unless there's like books :)), I just want to get it done, so I don't need to make an effort to stick to a list.

I used to just usually buy the same staples. At some point I started keeping a list on my smartphone which was very convenient. Now we finally found a grocery list app we could both share which had been very convenient.

3. What is one thing that you always buy, but never put down on a list?

Nothing exciting, but things we need to refresh most often, like milk or bread, I usually have an idea if we have enough and just buy it, the list is more for things to buy "in the next few days".

4. Is there anything that you always think you are out of and come home with it to discover you already have a year’s supply on hand?

I can't think of anything specific, but things like flour, vanilla, jam that we only use every so often, I always forget if we have already.

5. Do you get your groceries delivered?

That would probably be more convenient but I keep not getting round to it. I used to not because I was out almost every evening and didn't know when I'd be in to get deliveries. I work right buy large tesco so I usually shop one small batch at a time at lunchtime.

[food] oh go on then

Feb. 16th, 2019 12:06 am
kaberett: a watercolour of a pale gold/salmon honeysuckle blossom against a background of green leaves (honeysuckle)
[personal profile] kaberett
Some of you have specifically mentioned being interested in seeing other people's responses to this week's [community profile] thefridayfive, and I'm sitting around nervously watching the mass spec run without the concentration to do anything more useful, so here you go.

Content note: this week's theme is grocery shopping and meal planning. My answers therefore involve mention of sensory issues with food, dietary restrictions, and disordered eating.

Read more... )

Of course, what these questions don't touch on is HAVE I MENTIONED I HAVE AN ALLOTMENT. :D I make choices about what to grow (and where) for convenience; for example, I don't like buying cut herbs because (i) I feel vaguely guilty and (ii) they're never the right quantities, but I do like fresh herbs, so in pots on the verandah I've got mint, parsley, rosemary, sage, chives, and bay. I'm on the verge of buying seeds for two kinds of basil; an honourable mention to the ancestral wild garlic, that springeth green. I also had tomatoes on the patio (... I still haven't decided what to call it; "decking" seems awfully USois, somehow, and isn't quite in my active vocabulary) this summer, which was convenient and enjoyable enough that I'm likely to do it again. (I might also try cucumbers on the patio, depending on how the weather goes and whether I actually buy a greenhouse.)

At the allotment I'm prioritising things it's ridiculously expensive to buy (poppy seed! caraway seed! hopefully, if I get my act together, asparagus! bay leaves! soft fruit! hopefully some saffron, thanks to [personal profile] ewt!), things that come in entirely the wrong amounts always and are awkward to store (spinach!), things I always wince over the cost of and can rarely be persuaded to indulge myself on (fennel! purple sprouting broccoli! pak choi! shallots! interesting salad leaves! hopefully passionfruit!), things that are Brightly Coloured (this season I'm going to be experimenting with Painted Mountain sweetcorn, rainbow quinoa and purple chillis, among others), things it's otherwise tricksy to find (root parsley! :D), and things that are Just Better when they're really ludicrously fresh (hiiiii peas). I'd already been trying to eat seasonally; I'm looking forward to spending more time paying attention to plants, and trying to remind myself that I'm not going to be starting everything off hideously too late even if I am only getting back from Belfast at the end of February.

This is of course my first year with the allotment so I don't... entirely have a sense of how my shopping patterns will actually be affected, but I Am Excited To Find Out: I've already been enjoying working with the rhubarb and beetroot neighbours have desperately fobbed off on me, and with the things I've managed to get going already. So, you know, if compatible with your diet, should you visit me over the summer there's a very high chance that you'll be fed Things What I Grew (That Aren't The Sourdough), and should I visit you you might get brought A Tribute...
[syndicated profile] drmaciver_feed

Posted by David R. MacIver

Caching interactions with an arbitrary interface

This is a trick I've figured out recently for Hypothesis. I've yet to decide whether it's something I want to use, but it's a neat trick. It's much more easily implemented in a dynamically typed language, though I expect you could make something like it work in a statically typed language relatively easily with macros and metaprogramming and suchlike.

Suppose you have some interface that has the following two properties:

  1. All of the arguments to its methods are immutable.
  2. All of the return values of its methods are both immutable and hashable (for the sake of simplicity I will assume that none of its methods throw exceptions, but this can easily be made to work if they do).

Now suppose you have a deterministic function that takes any implementation of this interface and returns an immutable value. You can cache that function, which may be a big win if it is very slow (as it may be if it's a complicated test function as in Hypothesis).

You do not need to know anything about the implementation of the interface in order to do this. The cache will work by returning the value of any prior implementation of the interface that it is called with that is observationally equivalent to the current implementation.

How could this be?

Because the function is deterministic, what it does next is determined entirely by what has happened so far, which is in turn determined entirely by the sequence of return values from the object it is called with. Thus every result of calling the function corresponds to a unique sequence of return values. Additionally, none of these sequences can be a prefix of another, because that would be non-deterministic behaviour - once the function ran and called another method after this point, another time it didn't.

This structure makes it very easy to store the results in a tree. Each node either records which method was called and its arguments, or that no more methods were called and is a leaf storing the return value, or stores a sentinel value to record that we don't know what happens here and need to ask the underlying test function (this is helpful for the representation):

import attr
from collections import defaultdict

class TreeNode(object):
    """Node wrapping a previous observation. Having a mutable
    wrapper class around the value makes the implementation a lot
    observation = attr.ib(default=None)

class Result(object):
    """A previously observed return value."""
    value = attr.ib()

class Decision(object):
    """A previously observed call to the underlying implementation."""
    method = attr.ib()
    args = attr.ib()
    children = attr.ib(default=attr.Factory(lambda: defaultdict(TreeNode)))

To populate the tree you use the following wrapper around the implementation which proxies method calls to the underlying implementation and puts the observations in the tree:

class WrapperImplementation(object):
    def __init__(self, tree, underlying):
        self.__tree = tree
        self.__underlying = underlying

    def __getattr__(self, name):
        base = getattr(self.__underlying, 'name')
        if not callable(base):
            return base

        def accept(*args):
            if self.__tree.observation is None:
                self.__tree.observation = Decision(name, args)
            rv = base(*args)
            self.__tree = self.__tree.observation.children[rv]

def call_recorded(fn, tree, implementation):
    """Call fn(implementation) and update the tree to reflect the
    return fn(WrapperImplementation(tree, implementaiton))

We can then define a cached version of the test function as follows:

class UnknownResult(Exception):

def simulated_function(tree, implementation)
    """Either returns a previous result we've saved in the tree from
    calling this implementation, or raise UnknownResult."""

    previous = tree.observation

    if previous is None:
        raise UnknownResult()

    if isinstance(previous, Result):
        return previous.value
        rv = getattr(implementation, previous.method)(*args)
        tree = previous.children[rv]

In order get a cached outcome of an arbitrary implementation it's a little complicated and I can't be bothered to sketch out the code: If you can reset the implementation to empty it's easy, you just call it with the simulated function, reset it, and then call it recorded with the real function. If you can't reset it then you can define a new wrapper implementation that replays the prefix that was observed in simulated_function without calling the underlying implementation, then starts calling the real implementation once you're in unknown territory. You can implement this in terms of a resettable wrapper around the implementation.

How useful is this technique? Unsure. It's pretty niche. I think it might help a lot in Hypothesis though, where we're currently having some significant scalability issues for large and hard to reduce examples, and having something like this will allow us to avoid keeping them around because of how easy it is to recreate the data without reinvoking the test function.

kaberett: Photo of a pile of old leather-bound books. (books)
[personal profile] kaberett
spot the difference!

preferment: the selection of clergy to hold positions of senior office in the Church (of England) (largely obsolete)
preferment: a preparation of a portion of a bread dough that is made several hours or more in advance of mixing the final dough

my recreational reading, you see, currently includes a nontrivial amount of Austen and a nontrivial amount of The Theory Of Sourdough. APPARENTLY in this modern day and age we don't believe in clarifying punctuation. as a result I am spending a lot of time being very confused about theology.
jack: (Default)
[personal profile] jack
I've blogged about this ages ago, but apparently I never made myself understood.

Imagine you have a few characters, probably lovable misfits, a tough one, a hacker, a disguise artist, etc. The GM is adjudicating something simple and in theme, say the hacker needs to bypass an electronic keypad and then the tough one needs to spring through the door and take down half a dozen guards.

Traditional resolution mechanics, used commonly in all of simulationist games, tactical games, and lightweight narrative-focused games, go something like:

* Decide how hard each of those are for a typical human
* Each character gets a bonus for how much better than a typical human they are
* Then you resolve it.

It's important that the players and GM all have a similar idea how difficult these things actually are for the players, or they'll get into an argument about the resolution. But in truth... most of them will have watched a LOT of movies about tough ones who take down rooms full of guards, and never ever seen it in real life. So when you get to the "estimate difficulty" part, it's easier to estimate "for the tough one, taking out six surprised and lightly armed guards is of moderate difficulty" than to estimate "for a typical human, is this challenging? extreme? superhuman? something else?"

I'm considering an alternative, something like:

* Look at the obstacle as described by the GM
* Look at the character's ability
* Adjudicate "OK, for your specific character, that's easy/medium/hard/nigh-impossible", and roll a die that says "you succeed on an easy/medium/hard/impossible" challenge.

If you have a simulationist system, the traditional method is almost necessary. It's also a lot more practical if you have lots of different small bonuses, because adding those to the player's achievement is easier than subtracting them from the difficulty. But outside those situations, in theory, that system has some advantages: the GM doesn't need to model the characters abilities, just how hard the situation is; it means players usually get big numbers or lots of dice which is fun. But I'm not sure I actually believe those.

In practice, in creating a fun experience, the GM probably has a better idea of "I want to provide the players with this much of a challenge" than of "I want the situation to be this challenging in the abstract". Especially if there's modifiers being thrown around, it's easy for a "choose a difficulty, and then the players get bonuses" model to end up with "whoops, the player can just always/never succeed at this".

For instance, the players try to bribe a guard. Everyone expects that to happen in heroic fantasy all the time, so the GM gives it a fairly low difficulty. Now the players want to disguise themselves as laundry attendants to escape the castle. The GM does the same thing. But it turns out there's a mechanic for bribing but not disguise, or vice versa, so the players get a whacking great bonus to one of them and not the other, despite both being what you'd expect from the genre. It means the GM and player's instinctive knowledge of what the characters can do can work against them if the mechanics don't perfectly line up.

But with the new system, appropriate difficulties happen automatically if people forget themselves, but you can still calculate them in detail when you feel the need. The GM can always just assume that as long as the hacker does the hacking and the tough one does the bruising, most challenges will be "medium", but they can throw an "easy" or "hard" in there if they want. And if they DO want to make things more objective they can use a rule-of-thumb of "for every notch above typical human you are, you reduce the difficulty by one level" without wiring it into the rules of the universe.

What are the advantages of that system?

One is, as I said, it's easier to adjudicate difficulty on the fly if everyone has a good idea what the characters can do but not what a normal human can do.

Also, if characters want to work outside their specialities it also works better. Maybe "jumping a gap", anyone can try even if only the athlete can be assumed to succeed, but "picking a lock" you can't do at all unless you know. Most systems force you to pick one or the other of those for all possible tasks (or choose two possible levels, as with DnD's "take 10/take 20" system and restrictions on some skills without training). In this system, the GM can adjudicate on the fly what obviously makes sense in the situation at hand, even if it means some tasks which are medium for the hacker are hard for other characters and some are impossible. Whereas with a traditional resolution, if two different players want to try the same thing, it's easy to have the results break everyone's expectation of what the characters can achieve.

And, it implicitly puts the variance under the GM's command, not only the mean. If one character has a special ability that makes routine something that is usually far out of the reach of other characters, the flavour might still suggest that they some of those tasks are easy and some are hard for them. In a traditional resolution mechanic, you *also* need to make sure those difficulties are out of reach of other characters, except for the times they actually should be able to do it with sufficient effort. With the new system, you can simply assign difficulties for the character with the special ability, and worry about the other characters only if they try something like that.

I'm not sure if there's actually any use for this system, but thinking it through helped me think how abilities and difficulties work.

And I'm still confused by the responses I got when I talked about this before, which were mostly, "If you think that, you should try FUDGE" which I mean, sure, a popular widely used system probably is a lot better than one person's random idea, but it seems so irrelevant, since FUDGE uses exactly the same traditional resolution order as DnD, so I wasn't sure what they were trying to say.

Reading Wednesday

Feb. 13th, 2019 08:15 pm
slashmarks: (Leo)
[personal profile] slashmarks
It's been a while since I managed to write any reviews, hasn't it? My body's ability to function vascillates wildly and winter always sucks, so this will definitely continue to happen; I will attempt to catch up on the books that won that poll at some point.

What I've read this week:

The Ayatollah Begs to Differ - Hooman Majd

A book written by an Iranian-American reporter, purporting to describe the "real" Iran. Majd's essential thesis seems to be that the Islamic Republic enjoys widespread support from people who aren't necessarily committed fundamentalists, based on certain relatively democratic principles of government structure and its willingness to ignore what happens inside private homes. He describes his various trips to Iran and experiences there, including interviews with officials, religious authorities, high profile dissenters and random people, in the process of making this argument. He's skilled at making these encounters entertaining and would probably make a good travel writer.

As you might guess, "would make a good travel writer" is not a compliment when said of someone discussing politics, though.

Cut for length )

Rereads: Saffy's Angel by Hilary McKay; Harry Potter and the Prisoner of Azkaban by J K Rowling; Indigo's Star by Hilary McKay

Ancient Bodies, Ancient Lives: Sex, Gender, and Archaeology - Rosemary A Joyce

I didn't realize when I picked this up that it was a textbook, but it is; it's an introduction to gender and sexuality studies in archaeology, divided into loose subjects with examples from various case studies.

As such I found the text a bit simplified in places and I might have appreciated a more critical view of certain studies, but it's good at its job. I really appreciate Joyce's dedication to the point that biology is not destiny, that conflating the gender roles of the archaeologist's society with human biology has been and continues to be a major problem in gender analysis in archaeology; and that there is evidence for societies in which gender was not the most important categorizing tool and might not have even been socially significant at all.

Cut for length. )

Transcendent 2: The Year's Best Transgender Speculative Fiction - ed. Bogi Takács

Anthology from 2017, on the subject in the title. A mixed bag like most anthologies; but this one consisted about half of stories I loathed and half of stories I liked. Maybe three mediocre ones in the mix.

Cut for length and WTF )

Today in teeth

Feb. 13th, 2019 10:47 am
kaberett: Clyde the tortoise from Elementary, crawling across a map, with a red tape cross on his back. (elementary-emergency-clyde)
[personal profile] kaberett
Content notes/conversational parameters: brief discussion of oral health and teething; mention (no specifics) of anxiety dreams. On the whole I think teeth are skin-crawlingly awful, so please don't go into detail about oral damage/dental procedures/etc in comments. The level of detail in the post is probably a good guide. <3

Read more... )
[syndicated profile] drmaciver_feed

Posted by David R. MacIver

Talking to your imaginary friends as a writing prompt

This is an idea that has been bumping around in my head for a while and I've never quite got around to trying, but I still think it's a good idea.

A common problem is this: I want to write, but I don't know what to write about.

A possible solution to this is as follows: Make up a fictional character, and have a conversation with them about something.

Even if you don't do anything with this, it's still useful writing practice, but I suspect it will also result in things that might be usefully edited into a long form piece.

Possible prompts within that:

  1. Explain some problem you're having to the fictional person.
  2. The fictional person doesn't understand something and wants your advice on it.
[syndicated profile] drmaciver_feed

Posted by David R. MacIver

Book Review: Marriage and Morals, by Bertrand Russel

This book is an interesting artifact. It contains many progressive ideas and conclusions that even today would be considered "a bit too modern" by many people. Along the way, it also contains a great deal of casual racism, more than a bit of casual sexism (though you get the feeling that most of the sexism he feels is the result of a culture of depriving women of adequate education, so I'll give him a partial pass on this), and outright advocacy of eugenics.

This makes more sense as a combination when you realise that the book is from 1929, and it's aged as badly as progressive politics usually do once the world has overtaken them. In general I got the sense that he was an intelligent and decent person, and that most of his more objectionable beliefs were some mix of factually wrong and failing to think through the consequences, but it still wasn't a wholly comfortable read.

There was also rather a lot of gender essentialism and some frankly weird assumptions about how people behave, but given the above complaining about those feels like quibbling.

Broadly, his main conclusions were:

  1. People are way too uptight about sex and now that we have contraception it's actively unhealthy for this to be the case.
  2. Marriage should be more explicitly an institution for the raising of children, and as a result there should be no expectation of faithfullness.
  3. A bunch of eugenics stuff that I don't feel inclined to summarise.

The first seems basically accurate, the second... has problems but isn't an unreasonable stance (there are many happily childfree marriages and I think they seem to work very well for the people involved. I don't think in principle what he is describing is bad, but I think the transition to it is fraught, particularly when LGBT rights issues come into play). I'm not touching the third.

The most interesting part of the book for me is the central thrust of his argument, which is basically that having moral codes that you know aren't going to be obeyed is actively damaging, especially for children. By teaching people that sex is shameful, given that they're going to have sex anyway, you create a culture of guilt and shame, and you teach people from very early on that deceit is necessary and that they can't trust their parents. This seems like a sound argument, and I think is a useful general principle for evaluating moral precepts on.

I am glad to have read it but don't feel like I could actively recommend it to others. Either way, this copy is not mine and will be returned to the friends I have borrowed it from.


Feb. 10th, 2019 11:31 pm
kaberett: Photo of a pile of old leather-bound books. (books)
[personal profile] kaberett
Reading. Mostly Predator's Gold, the sequel to Mortal Engines, because I found it for two quid in a charity shop and I wanted to know what happened next. Spoilers beneath the cut. Read more... )

TV. Slow progress with Leverage S4, encouraged by a visitcousin who's very into the show. Still pausing several times an episode to go YOU WHAT. THAT ISN'T HOW ANYTHING EVEN. (It's possible I've been spoiled by Matt Damon's Important Space Potatoes, but like, show. SHOW. That is NOT HOW POTATOES.)

Food. I had... two surprisingly faily attempts at sourdough, after a long run of Good Bread. One was in no small part because I started cooking it using the grill rather than the oven because I was Not Terribly With It (...), but both were more of a bread-puddle than they ought to have been. I eventually worked out that I'd made the starter slightly wetter than it had been previously, which meant I needed to decrease the liquid some. Nevertheless our guests this weekend (my parents; a cousin) have consumed three loaves in their entirety, and cousin will make further inroads into the fourth once I've baked it tomorrow morning, so that's all gratifying. For bonus points the cousin is in the process of setting up her own starter so I am getting to do lots of Sourdough Nerdery with her.

Tiny adventures. Yesterday we took a trip to the Giant's Causeway, because it's right there and it would have been silly not to (and also I only waited this long because my mother had put in a special request that we delay it until she could join in). It turns out that despite perfectly well knowing the relevant physics for columnar jointing and therefore what the scales involved are, I'd somehow interpreted "Giant's Causeway" to mean that the jointing itself was on a giant scale i.e. I was expecting diameters of, oooh, at least 75cm or so? Rather than... the thirty-odd we were actually getting. Which, to be fair, is still a good deal larger than my previous in-the-wild encounter: we'd plonked ourselves down in a pile of bracken in a streambed to have lunch, one day during my mapping project, and went "oooh, that's a funny-looking rock..." It turned out, on slightly closer inspection, to be a very small exposure of some really small columns (diameter ~5cm), and I was charmed and delighted. (They were SMOL.) So, yes, this was much more impressive than that, in both scale and definition, and I'm very glad to have seen it, even as I wist after being able to do the proper hike. I hadn't realised about the concave-and-convex ball-joint horizontal fractures as a result of vertical contraction because they're less spectacular so my lecturers just... didn't bother mentioning them? But they were charming, I was charmed, hurrah.

Today we visited HMS Caroline, because my mother is interested in naval history (and my father can be persuaded to be) and it spent nontrivial amounts of time stationed near HMS Essex, which my great-grandfather served on; in the most recent trip to the mouldering ancestral pile some of the things we dug out were A Lot of records pertaining to his time aboard both the Essex and, before that, on the cable-laying ships working the Atlantic. The Caroline is remarkably accessible -- they've installed three lifts, and the ramp to get on board is only unnavigably steep at high tide. I... had a bunch of feelings. [personal profile] me_and's favourite fact was probably that regarding the ships mascots during WWI: two cats and... a rabbit. (I'm not sure I can generate one, because feelings.)

This week coming. Hopefully actually managing to send off a draft of my paper; hopefully actually getting the final data for the final segment of it; hopefully getting to spend a good deal of time at the allotment.


katzenfabrik: A black-and-white icon of a giant cat inside a factory building. The cat's tail comes out of the factory chimney. (Default)

January 2019

678910 1112

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 22nd, 2019 04:58 pm
Powered by Dreamwidth Studios