Thursday, May 31, 2018

Cookies, HTTPs and OpenId

I finally got around to looking at the various notices that have accumulated on the admin pages for this blog.  As a result:

  • This blog is supposed to display a notice regarding cookies if you access it from the EU.  I'm not sure that this notice is actually appearing when it should (I've sent feedback to try to clarify), but as far as I can tell blogspot is handling cookies for this blog just like any other.  I have not tried to explicitly change that behavior.
  • I've turned on "redirect to https".  This means that if you try to access this blog via http://, it will be automatically changed to https://.  This shouldn't make any difference.  On the one hand, https has been around for many years and all browsers I know of handle it just fine.  On the other hand, this is a public blog, so there's no sensitive private information here.  It might maybe make a difference if you have to do some sort of login to leave comments, but I doubt it.
  • Blogger no longer supports OpenID.  I think this would only matter if I'd set up "trust these web sites" under the OpenId settings, but I didn't.
In other words, this should all be a whole lot of nothing, but I thought I'd let people know.

Wednesday, May 23, 2018

The stuff of dreams


... and then our hero woke up and it was all a dream ...

... has to rank among the most notorious pulled-out-of-thin-air deus ex machina twist endings in the book, along with "it was actually twins" and "it was actually the same person with multiple personalities".  As with all such tropes, there's nothing wrong with these plot twists per se.  The problem is generally the setup.

In a well-written "it was actually twins" twist, you have clues all along that there were actually two people -- maybe subtle shifts in behavior, or a detail of clothing that comes and goes, or the character showing up in an unexpected place that it seemed unlikely they'd be able to get to.  With a good setup, you're reaction is "Oh, so that's why ..." and not "Wait ... what?  Seriously?"

The same goes for "it was all a dream".  In a good setup, there are clues that it was all a dream.  Maybe things start out ok, then something happens that doesn't quite make sense, then towards the end things get seriously weird, but more in a "wait, what's going on here, why did they do that?" kind of way, as opposed to a "wait, was that a flying elephant I just saw with a unicyclist on its back?" kind of way, though that can be made to work as well.

There's a skill to making things dreamlike, particularly if you're trying not to give the game away completely.  Dream logic doesn't just mean randomly bizarre things happening.  Dreams are bizarre in particular ways which are not particularly well understood, even though people have been talking about and interpreting dreams probably for as long as there have been talking and dreams.

A while ago I ran across a survey by Jennifer Windt and Thomas Metzinger that has quite a bit to say about dreams and the dream state, both ordinary dreams and "lucid" dreams where the rules are somewhat different.  They compare the three states of ordinary dreaming, lucid dreaming and waking consciousness to try to tease out what makes each one what it is with, I found, fair success.  I'm not going to go into a detailed analysis of that paper here, but I did want to acknowledge it, if only as a starting point.


First, though, some more mundane observations about dreams.  We tend to dream several times a night, in cycles lasting around 90 minutes.  We don't typically remember this, but a subject who is awakened while exhibiting signs of a dream state can generally recall dreaming while a subject awakened under other conditions doesn't.  The dream state is marked by particular patterns of electrical activity in the brain, near-complete relaxation of the skeletal muscles and, probably best-known, Rapid Eye Movement, or REM.  REM is not a foolproof marker, but the correlation is high.

Dreams in early sleep cycles tend to be closely related to things that happened during the waking day.  Subjects who studied a particular skill prior to going to sleep, for example, tended to have dreams about that skill.  I've personally had dreams after coding intensely that were a sort of rehash of how I'd been thinking about the code in question, not so much in the concrete sense of writing or reading particular pieces as more abstractly navigating data and control structures.

Later dreams -- those closer to when you wake up -- tend to be more emotional and less closely associated with recent memories.  Since these are more likely to be the ones you remember unless someone is waking you up as part of a sleep experiment, these are the kind of dreams we tend to think of as "dreamlike".  These are the "I was in this restaurant having dinner with such-and-such celebrity, except it didn't look like them, and I could hear my third-grade teacher yelling something, but everyone just ignored it and then a huge ocean wave came crashing in and we all had to swim for it, even though the restaurant was in the Swiss Alps" kind of dreams.

In my experience this kind of dream can often be linked back to relevant events, but in a sort of mashed-up, piecemeal, indirect way.  Maybe you heard a news story about a tidal wave yesterday and a couple of days ago some relative or old friend had mentioned something that happened to you in grade school.  Celebrities, by definition, are frequently in the news, and it was the Swiss Alps just because.  That doesn't really explain what the dream might mean, if indeed it meant anything, but it does shed some light on why those particular elements might have been present.

But why that particular assemblage of elements?  Why wasn't the third grade teacher your dinner companion?  Why did all the other diners ignore the teacher?  Why wasn't the restaurant on the beach? And so on.

My personal theory on such things is pretty unsatisfying: it just is.  Whatever part of the mind is throwing dream elements together is distinct from the parts of the mind concerned with cause and effect and pulling together coherent narratives.

To draw a very crude analogy, imagine memory as a warehouse.  From time to time things have to be shuffled around in a warehouse in for various logistical reasons.  For example, if something that's been stored in the back for months now needs to be brought out, you may have to move other items around to get at it.  Those items were put there for their own reasons that may not have anything to do with the item that's being brought out.

Now suppose someone from management in a different part of the company -- say media relations -- comes in and starts observing what's going on.  A pallet of widgets gets moved from section 12D, next to the gadgets, to section 4B, next to the thingamajigs.  This goes on for a while and our curious manager may even start to notice patterns and make tentative notes on them.

Suppose upper-level management demands, for its own inscrutable reasons, a press release on the warehouse activity.  The media relations person writing the release is not able to contact the warehouse people to find out what's really going on and just has to go by the media relations manager's notes about widgets moving from next to the gadgets to next to the thingamajigs.  The resulting press release is going to try to tell a coherent story, but it's not going to make much sense.  It's almost certainly not going to say "We had to get the frobulator out of long-term storage for an upcoming project so we moved a bunch of stuff to get at it."

My guess is that something similar is going on in the brain with dreams.  In normal waking consciousness, the brain is receiving a stream of inputs from the outside world and putting them together into a coherent picture of what's going on.  There are glitches all the time for various reasons. The input we get is generally incomplete and ambiguous.  We can only pay attention to so much at a time.

In order to cope with this we constantly make unconscious assumptions based on expectations, and these vary from person to person since we all have different experiences.  The whole concept of consciousness is slippery and by no means completely understood, but for the purpose of this post consciousness (as opposed to any particular state of consciousness) means whatever weaves perception into a coherent picture of what's going on.

Despite all the difficulties in turning perception into a coherent reality, we still do pretty well.  Different people perceiving the same events can generally agree on at least the gist of what happened, so in turn we agree that there is such a thing as "objective reality" independent of the particular person observing it.  Things fall down.  The sun rises in the morning.  It rains sometimes.  People talk to each other, and so on.  Certainly there's a lot we disagree on, sometimes passionately with each person firmly believing the other just doesn't know the simple facts, but this doesn't mean there's no such thing as objective reality at all.



In the dream state, at least some of the apparatus that builds conscious experience is active, but it's almost completely isolated from the outside world (occasionally people will incorporate outside sounds or other sensory input into a dream, but this is the exception).  Instead it is being fed images from memories which, as in the warehouse analogy, are being processed according to however memory works, without regard to the outside world.  Presented with this, consciousness tries to build a narrative anyway, because that's what it does, but it's not going to make the same kind of sense as waking consciousness because it's not anchored to the objective, physical world.

If the early memory-processing is more concerned with organizing memories of recent events, early-cycle dreams will reflect this.  If later memory processing deals in larger-scale rearrangement and less recent, less clearly correlated memories, later-cycle dreams will reflect this.


As I understand it, Windt and Metzinger's analysis is broadly compatible with this description, but they bring in two other key concepts that are important to understanding the various states of consciousness: agency and phenomenal transparency.

Agency is just the power to act.  In waking consciousness we have a significant degree of agency.  In normal circumstances we can control what we do directly -- I choose to type words on a keyboard.  We can influence the actions of others to some extent, whether by force or persuasion.  We can move physical objects around, directly or indirectly.  If I push over the first domino in a chain, the others will fall.

In a normal dream the dreamer has no agency.  Things just happen.  Even things that the dreamer experiences as doing just happen.  You can recall "I was running through a field", but generally that's just a fact.  Even if your dream self decides to do something, as in "The water was rushing in so I started swimming", it's not the same as "I wanted to buy new curtains so I looked at a few online and then I picked these out".  Your dream self is either just doing things, or sometimes just doing things in a natural reaction to something that happened.

Even that much is a bit suspect.  It wouldn't be a surprise to hear "... a huge ocean wave came crashing in and then I was walking through this city, even though it was underwater".  In some fundamental way, in a dream you're not making things happen.  They just happen.

Likewise, one of the most basic forms of agency is directing one's attention, but in a dream you don't have any choice in that, either.  Instead, attention is purely salience based, meaning, more or less, that in a dream your attention is directed where it needs to be -- if that ocean wave bursts in you're paying attention to the water -- rather than where you want it to be.

Phenomenal transparency concerns knowing what state of consciousness you're in.  Saying that dreaming is phenomenally transparent is just a technical way of saying "when you're in a dream you don't know you're dreaming" (So why coin such a technical term for such a simple thing?  For the usual reasons.  On the one hand, repeating that whole phrase every time you want to refer to the concept -- which will be a lot if you're writing a paper on dreaming -- is cumbersome at best.  It's really convenient to have a short two-word phrase for "the-quality-of-not-knowing-you're-dreaming-when-you're dreaming".  On the other hand, defining a phrase and using it consistently makes it easier for different people to agree they're talking about the same thing.  But I digress.)

If someone is recalling a dream, they don't recall it as something that they dreamed.  The recall it as something that happened, and happened in a dream.  It "happened" just the same as something in waking consciousness "happened".  During the dream itself, it's completely real.  Only later, as we try to process the memory of a dream, do we understand it as a dream.  I've personally had a few fairly unsettling experiences of waking up still in a dreamlike state and feeling some holdover from the dream as absolutely real, before waking up completely and realizing ... it was all a dream (more on this below).  I expect this is something most people have had happen and this is why the "it was all a dream trope" can work at all.

In some sense this seems related to agency.  When you say "I dreamed that ..." it doesn't mean that you consciously decided to have thus-and-such happen in your dream.  It means that you had a dream, and thus-and-such happened in it.

Except when  it doesn't ...

Windt and Metzinger devote quite a bit of attention to lucid dreams. While the term lucid might suggest vividness and clarity, and this can happen, lucidity generally refers to being aware that one is dreaming (phenomenal transparency breaks down).  Often, but not always, the dreamer has a degree of control (agency) over the action of the dream.  In a famous experiment, lucid dreamers were asked to make a particular motion with their eyes, something like "when you realize you're in a dream, look slowly left and then right, then up, then left and right again", something that would be clearly different from normal REM.  Since the eyes can still move during a dream, even if the rest of the body is completely relaxed, experimenters were able to observe this and confirm that the dreamers were indeed aware and able to act.

Not everybody has lucid dreams, or at least not everyone is aware of having had them.  I'm not sure I've had any lucid dreams in the "extraordinarily clear and vivid" sense, but I've definitely had experiences drifting off to sleep and working through some problem or puzzle to solve, quite consciously, but blissfully unaware that I'm actually asleep and snoring.  I've also had experiences waking up where I was able to consciously replay what had just been happening in a dream and at least to some extent explore what might happen next.  I'm generally at least somewhat aware of my surroundings in such cases, at least intermittently, so it's not clear what to call dreaming and what to call remembering a dream.

In any case, I think this all fits in reasonably well with the idea of multiple parts of the brain doing different things, or not, none of them in complete control of the others.  Memory is doing whatever memory sorting it needs to do during sleep (it's clear that there's at least something essential going on during sleep, because going without sleep for extended periods is generally very bad for one's mental health).  Some level of consciousness's narrative building is active as well, doing its best to make sense of the memories being fed to it.  Some level of self awareness that "I'm here and I can do things" may or may not be active as well, depending on the dreamer and the particular circumstances.

This is nowhere near a formal theory of dreams.  Working those out is a full-time job.  I do think it's interesting, though, to try to categorize what does and doesn't happen in dream states and compare that to normal waking consciousness.  In particular, if you can have A happen without B happening and vice versa, then in some meaningful sense A and B are produced by different mechanisms.

If we draw up a little table of what can happen with or without what else...

Can there be ... without ...ConsciousnessAgencyPhenomenal transparency
Consciousnessyes1yes2
(Conscious) Agencyno?
Phenomenal transparencynoyes3
1 In ordinary dreams, but also, e.g., if paralyzed by fear
2 In ordinary dreams
3 In a lucid dream, if you're aware that you're dreaming but can't influence the dream

... it looks like things are pretty wide open.  I didn't mention it in the table, but agency doesn't require consciousness.  We do things all the time without knowing why, or even that, we're doing them.  However, conscious agency requires consciousness by definition.  So does phenomenal transparency -- it's consciousness of one's own state.

Other than that, everything's wide open except for one question mark: Can you have conscious agency without phenomenal transparency?  That is, can you consciously take an action without knowing whether you're awake or dreaming (or in some other mental state).  This isn't clear from lucid dreaming, since lucid dreaming means you know you're dreaming.  It isn't clear from ordinary dreaming.  Ordinary dreams seem passive in nature.

In a related phenomenon, though, namely false awakening, the dreamer can, while actually remaining asleep, awaken and start to do ordinary things.  In some cases, the dreamer becomes aware of the dream state, but in other cases the illusion of being awake lasts until the dreamer awakens for real.

All of this is just a long way of saying that our various faculties like consciousness, agency and awareness of one's state of consciousness seem to be mix and match.  The normal states are waking consciousness and ordinary dreaming, but anything between seems possible.  In other words, while these faculties generally seem to operate either together (waking consciousness), or with only consciousness (ordinary dreaming) they're actually independent.  It's also worth noting that nothing in the table above distinguishes waking from dreaming.  The difference there would seem to be in whether we're processing the real world or memories of it.

This is an interesting piece of information, one which would have been considerably harder to come by if we didn't have the alternate window into consciousness provided by dreams.

Thursday, May 3, 2018

Getting off the ground

Not long after I published the previous post about the Drake Equation, a couple of headlines surfaced about a paper by Michael Hippke with the admirably straightforward title Spaceflight from Super-Earths is difficult.  The paper is actually a light rewrite of what was originally an April Fool's joke, but the analysis is real, even if the author originally considered the topic frivolous.

The term Super-Earth itself is fairly loosely defined.  For concreteness, Hippke chooses Kepler-20b, with a radius of about 1.87R (Earth radii) and a mass of about 9.7 M (Earth masses).  Since gravity is proportional to mass and inversely proportional to the square of distance, the surface gravity of this planet would be about 2.8g (Earth gravity).  This is assuming that the measured radius is actually the radius of the surface.  There's a good chance that Kepler-20b is actually a "Mini-Neptune" with an extensive atmosphere rather than a Super-Earth with a rocky surface, but let's assume the Earth-like scenario here.

Hippke argues that it would be impractical for a civilization on such a planet to build rockets because the amount of fuel you need to reach escape velocity* increases exponentially in relation to that velocity.  This is exponential in the literal sense that doubling the velocity of a rocket means squaring the ratio of fuel to mass, not in the colloquial sense of "a lot".  Escape velocity in turn increases as the square root of the surface gravity.  For example, four times the surface gravity means twice the escape velocity, so square the ratio of fuel to dry mass.  Taking the square root doesn't make a lot of difference in the big picture.  The exponential part still dominates everything else.

In short, a somewhat bigger planet doesn't mean somewhat more fuel to get to escape velocity.  It can mean a lot more.

On Earth, a chemical rocket which magically had a weightless engine, fuel tank etc. would need to have 26 times as much fuel as payload in order to reach Earth's escape velocity of about 11 km/s**.  In real life that ratio is more like 50 or even 83 since the engine and so forth actually do weigh something.

Escape velocity for Kepler-20b would be about 2.3 times Earth's escape velocity, or around 25 km/s.  Hippke calculates that for a typical chemical rocket, that 26:1 ideal mass ratio is more like 2700:1 and the more realistic ratio of 83:1 would correspond to something like 9000:1.  To send a 1-ton payload out of the planet's gravity well would take 9000 tons of fuel.  By contrast, the Saturn V -- the largest rocket actually put into service so far -- had a mass of around 3000 tons, not all of which was fuel.

All this is fine, and surely more than enough for something that started out thoroughly tongue-in-cheek.  So let's take it at face value and try to poke holes in it anyway.

First, the calculations are for a single-stage rocket, though the real-life rockets used for comparison purposes are multi-stage.  In a multi-stage rocket you use a rocket with plenty of thrust (the first stage) to boost another rocket (the second stage) through the atmosphere quickly and then jettison that first stage.  At that point you no longer have to worry about the mass of the first stage and you consequently get more acceleration out of your remaining fuel.  You don't have to stop there.  The Saturn V, for example, was a three-stage rocket.  Five-stage rockets have been successfully launched.

This doesn't just make a difference in that a multi-stage rocket allows you get more acceleration out of the same mass ratio.  It also means that you don't have to use chemical rockets for all stages.  You could, for example, use an ion drive, which has a much higher effective velocity and therefore a much lower mass ratio, for the final stage and use chemical rockets to get it into orbit.  Ion drives produce very low thrust, far too little to launch from the ground, but they can do it for a very long time using very little fuel, eventually reaching much higher speeds than chemical rockets.  Once in orbit, a modestly-sized ion-driven vehicle could easily escape even Kepler 20b's gravity well.

In other words, getting to escape velocity in a single stage is a red herring.  You really just have to get a reasonable mass to orbital velocity, and you can use multiple stages if that helps.  At a given distance from the planet's center of mass, the orbital velocity is smaller than the escape velocity at the same distance by a factor of the square root of two.  In real life the orbit is -- of course -- further from the center of mass than the surface is.  If escape velocity at the surface is 25 km/s, a more reasonable orbital velocity would be 17 km/s, depending on how high up you have to go to get out of the atmosphere.  That would mean a mass ratio of more like 150 for an ideal rocket and 500 for a more realistic one.

That's still considerably more expensive than here on earth, but not nearly as discouraging as the 9000 figure in the paper.  A 500 ton rocket could put a ton in orbit, and you wouldn't even need to do that to get out of the gravity well.  Japan's ion-driven Hayabusa craft had a mass of about half a ton.  It was able to get to an asteroid, grab a sample and bring it back to Earth -- a pretty impressive piece of engineering if you ask me.  Our counterparts on Kepler 20b could do that with something like a 250 ton rocket.

The rocket that launched Sputnik was 267 tons (the rocket that actually launched Haybusa was around 140 tons, for a mass ratio of around 280).  Sputnik itself was only 84 kg, for a mass ratio of somewhat over 3000.  Small payloads generally mean higher mass ratios because it's not practical to shrink the launch system proportionately.

Leaving all that aside, you could also do multiple launches and assemble the final craft in orbit, if your robotics were good enough.  If you can launch half a ton with a reasonable-sized rocket, you can launch five tons with ten such rockets, and so forth.

Which brings up another point.  In the early stages of space exploration, before Kepler 20b puts its ion drive into orbit, they'll want to start small, using relatively big rockets to put relatively small things in orbit, and before that, to blast relatively small objects -- on Earth, that mainly meant weapons -- across large portions of the planet.

There doesn't seem to be any reason intelligent beings on Kepler 20b couldn't do that, assuming they're there.  Start with toy rockets, then weather rockets to explore the upper atmosphere, work up to ICBM-style systems, then orbit, then out of the gravity well, just as we did.  As far as I can tell, the difference on Kepler 20b would mainly be a matter of time, not a night-and-day difference between plausible and clearly impractical.  The benchmark of putting a ton or more directly on an escape trajectory doesn't seem particularly relevant to the question of whether or not this could happen, though, being concrete and understandable, it's still useful to think about.

There's another way to bring down the mass ratio: faster rocket fuel.  Hippke's calculations use an effective velocity of 3430 m/s, but hydrogen/oxygen delivers more like 4400.  That brings our ideal mass ratio down closer to 50 as opposed to 150.  As I understand it we only use hydrogen/oxygen in specific situations, due to various engineering considerations, but the tradeoffs will be different on Kepler 20b.  It might make sense to find ways to make the faster fuel work in more situations.

Even if chemical rockets weren't a practical way of getting into orbit, there are plenty of other options, some more speculative than others, for doing so.  Space elevators ... mass drivers ... blast wave accelerators ... space fountains.  Some of these require materials we don't know how to make yet or other not-so-proven technologies, but to some extent this is all a matter of economics.  Rockets are easy and cheap enough for us, so we use rockets.

Finally, it's probably worth pointing out that escaping a planet's gravity well is necessary for sending an interstellar mission, but hardly sufficient.  Kepler 20 is 950 light-years away.  To get here from there in, say, less than 10,000 years, you'll need to be going about a tenth the speed of light, or 30,000 km/s.  If you can do that, getting into orbit or even to escape velocity doesn't seem like a major problem.  Conversely, the most likely reason not to receive a visit from Kepler 20b is that it's just too far, not that it's too hard to get off the ground.





* I suppose I should acknowledge that "velocity" here actually means "speed" since it's a magnitude with no particular direction.  But everyone says "velocity" anyway.

** In real life you also have to deal with gravity losses until you reach orbital velocity.  For example, for every second you spend going straight up against Earth's surface gravity, you lose 9.8 m/s.  For Kepler 20b, that's more like 28 m/s.  If your initial stages take 180 seconds (three minutes), that's an extra 4000 m/s or so, except it's not really that simple since you don't spend all your time going straight up, particularly if the goal is to reach orbit.  I'm handwaving that, though it's quite a bit to handwave, just to keep the comparison with the ideal mass ratio of 26.  Part of the reason real rockets, even with multiple stages, needed a higher mass ratio than just the change in speed would suggest was to deal with gravity loss.