Wednesday, February 21, 2018

Good and Evil

Some years ago I was on an airplane and sat next to a person who was a life coach of some kind. I think we could all use a bit of help in leading better lives, so I was keen to find out what kind of approaches she used. I don’t remember exactly what I was struggling with myself at that time, but I asked this life coach how she helped people think through ethical dilemmas, situations where it was difficult to see which action was best.

This life coach said that she really didn’t think there was any such thing as an ethical dilemma. A good person would just know in their heart what the right thing to do would be. If a person doesn’t know right from wrong, then coaching isn’t going to help them anyway.

I was completely shocked by this answer. The idea that some people just inherently know the right thing to do where other people don’t… the idea that in the real world there is generally a choice between a right thing versus a wrong thing, rather than a choice where every option available has negative aspects… these ideas strike me as so utterly simplistic! And this woman was a life coach! These were the ideas she was encouraging in her clients. I have to admit, I let her know that I thought her approach to ethics was naïve to the point of being delusory and destructive. We did not disembark that flight with warm friendly feelings!

This idea, that people can be divided neatly into good people and not-good people, clearly has well established roots in American culture. It has roots in Calvin’s theology and the Puritans, the folks who came over on the Mayflower. This idea seems to be alive and well today. I hear strong echoes of it when I hear gun advocates contrasting law-abiding citizens versus criminals.

Recognizing the Puritan roots of today’s political conflicts certainly doesn’t solve any problems. John Calvin was no fool. I suspect one difficulty is that his theology was too subtle for most of his followers, so what we’re stuck with is a crude distortion. Perhaps some kind of return to Calvin, learning to dig deeper into his ideas, could be a way to help folks out of their simplistic Manichean trap. Anyway, I hope that a more accurate diagnosis of the problem can help lead us into a healthier way of living.

Tuesday, December 26, 2017


Sophomore year at Princeton was definitely mind expanding for me! Two physics classes are on my mind right now: electromagnetic theory, taught by Stewart Smith, and Thermodynamics, taught by Steve Schnatterly. I learned about the dynamics of vibrating strings in Smith’s class, which got me into musical tuning, one of my lifelong obsessions. In Schnatterly’s class I learned about phase transitions, another lifelong obsession. I’ve been using software to explore these realms in theoretical ways ever since. I've been looking into a new little wrinkle in the phase transitions realm that I would like to share here.

The basic idea is to make an image that is striped, but where the stripe pattern is not consistent across the entire image. The width of the stripes won’t change, but their direction can change and also they can be offset. The image will be broken into an array of cells, and a stripe pattern assigned to each cell. Randomly assigning stripe direction and offset to each cell produces this kind of image:

This random assignment is not very interesting though. The real fun is in introducing correlations between the directions and offsets of neighboring cells. To do this, I use a cost function. The total cost for the whole image is the sum of a cost for each neighboring pair of cells. If neighboring cells have the same direction and offset, the cost for that pair is zero. The more their direction and offset differ, the more that pair contributes to the total cost.

There are some interesting details in how direction and offset can vary. The set of possible stripe patterns of a cell has a topology that characterizes when one stripe pattern, given by a direction and offset, is close to another stripe pattern. For example, when the direction of a stripe pattern is rotated by 180 degrees, it returns to the original stripe pattern. So the direction of the stripe pattern forms a circle, topologically.

Similarly, the offsets of the stripe pattern form a circle topologically. If the stripes are offset far enough, they just end up back where they started.

Given a circular topology of directions and a circular topology of offsets, the obvious way they would combine would be in a torus topology. But that is not what happens here. As the direction is rotated through 180 degrees, offsets in one direction are transformed to offsets in the opposite direction. The topology of the set of directions and offsets of the stripe patterns for a cell actually has the topology of a Klein bottle!

With this understanding of the choices available for a cell, the cost function can be used to drive a simulated annealing algorithm. This algorithm is driven by a temperature parameter. High temperatures give high costs which imply loose correlations between neighboring cells. Low temperatures give low costs and tighter correlations between neighboring cells. Systems such as these generally exhibit phase transitions, where local correlations extend to global correlations. The image above was generated at a temperature just above the phase transition. At a slightly lower temperature, very much higher correlation is observable:

At a lower temperature yet, the system is nearing uniformity.

Generally the fluctuations near the phase transition have a fractal character, so that is where the most interesting patterns appear.

With these elements in place, we can then toy with the various parameters, e.g. the number of cells and the number of stripes per cell.

Here is a plot of the heat capacity which has a sharp peak indicative of a phase transition:

Tuesday, December 19, 2017


Self and other, us and them, winning and losing, growth and decay: life is struggle. And yet, as one looks closely at the pattern and how the parts fit together, the struggle appears more like a dance. A dance alternates between posture and movement. We can understand a situation in one way, and then look at it from a different perspective. Each phase illuminates the other, with boundless transformative potential.

The basic game in Buddhism consists of a very large number of players called sentient beings, each of whom has a score called karma. It gets tricky though: while most of the time we can track a sentient being because it is attached to a physical body, those physical bodies are subject to gross impermanence, a.k.a. birth and death. How does the associated sentient being come to have whatever karma they do at the time they become associated with a newly born body? What happens to the karma of a sentient being when their body dies?

There is a similar problem in particle physics. There the players are elementary particles such as electrons and quarks. Each particle has a score which includes components such as position and momentum. Curiously, elementary particles are also subject to gross impermanence. What happens to the momentum of a particle when the particle ceases to exist? In physics, particles decay into other particles. Two particles might collide and both cease to exist as a result of the collision, but in their place new particles will appear. These newly appearing particles will carry the scores of the particles that have ceased to exist. In physics, quantities such as momentum are conserved. Momentum can be transferred from one particle to another but it cannot be created or destroyed. These conservation principles are the cornerstones of modern physics. The details of what kinds of particles there are and how they are created and destroyed, these details are constantly being reworked and refined through advances in theory and experiment. But a principle like the conservation of momentum is accepted more or less as an axiom. Of course every principle in science is subject to revision based on evidence. But conservation of momentum is so fundamental that some rather fanciful interpretations of the data will be allowed in order to maintain the conservation principle.

The understanding of beta decay is an example of such fanciful interpretation. Atomic nuclei are composed mainly of protons and neutrons, two types of particles. The simplest atomic nucleus is that of hydrogen, which consists of a solitary proton. This solitary proton is quite stable. Left to itself it will not manifest any sort of gross impermanence but will continue its existence indefinitely. Solitary neutrons, on the other hand, are quite unstable. They can be ejected from a complex nucleus through radioactive decay or through collisions, but they do not last very long outside a nucleus. What one observes is that the neutron decays into a proton and an electron. However, if the momenta of these new particles are added up, the sum will not be equal to the momentum of the neutron that disappeared. The great physicist Enrico Fermi posited a rather fanciful interpretation in order to preserve the principle of the conservation of momentum: there must be a third, invisible, particle also created alongside the proton and the electron. This third particle carries the missing momentum. Further physical principles showed that this third particle could only have tiny mass and would have no electrical charge, so Fermi called it a neutrino: like a very small neutron. These tiny particles were actually detected some years after Fermi’s prediction, one of the great successes of modern physics.

Karma is about as fundamental to Buddhism as momentum is to physics. Cultivate virtue and avoid evil: why? In order to improve one’s situation in the future. If the karma accumulated through one’s actions does not actually lead to future consequences, if karma can come or go independent of one’s actions, then the argument for cultivating virtue falls apart. For the most part it is not too difficult to see how karma might be accumulated and stored in association with a physical body. For example, it is not easy to see how memories are accumulated in a physical body, but it is clear that somehow they are. Karma is much like a habit, which is a kind of memory. The challenge comes when a body manifests gross impermanence, i.e. birth and/or death. We do not generally observe any kind of subtle body which could carry the karma to a newly born body or from a newly deceased body. But the situation is quite similar to beta decay in particle physics. We can maintain the principle of karma by hypothesizing the existence of such subtle bodies. And when expert observers use advanced methods that can actually detect such subtle bodies, we can have confidence in the accuracy of their reports.

The analogy with particle physics, where sentient beings are like particles and karma is like momentum, can be explored in other ways. Emmy Noether proved a mathematical theorem that provides some of the deepest structure in modern physics. She showed that conservation principles are associated with symmetries. For example, conservation of linear momentum is associated with the translational symmetry of space. The interchange symmetry of sentient beings seems like a natural reflection of the conservation principle of karma. After all, a modern paraphrase of the law of karma is: what goes around, comes around. What we do to others, we ultimately do to ourselves.

There is another perspective on the world, another way of seeing the world as a game, another system of accounting: economics. The players are economic agents such as individuals and corporations. Their scores are their property, which can be reduced to the single dimension of monetary value. The analogy between money and karma can shine a little light on the nature of money. Money, like karma, is relational. Karma is a pattern that relates sentient beings. Money is a pattern that relates economic agents. Henry Ford manifested this insight when he understood that the workers in his factories were also his customers. Naively he would maximize his wealth by raising the prices of the cars he was selling, and lowering the wages of the workers who made those cars. But in fact that naïve formula misses the fact that money lives by flowing in a network. Stationary money is dead money.

Particle physics can provide some further insights to challenge our understanding in Buddhism and economics. The wild thing about particles is that they don’t exactly exist or not exist at any particular time. This is very much in line with the argument of the Buddhist sage Nagarjuna, who showed that atoms cannot exist. One of the fascinating manifestations of this kind of quasi existence of particles is associated with the physics of crystals. Particles such as holes and phonons exist in crystals but not in empty space. Particles exist as collective behaviors of other particles. Particles become a way of understanding a system rather than parts whose existence is prior to the system.

This kind of shifting perspective can be seen in another game, in biology. At one level, biology is about organisms and their interactions. At another level, it is about species. Species can compete with other species much like organisms can compete with other organisms. At yet another level, biology is about genes. The evolution of a species can be viewed as a competition among the genes in the gene pool of the species.

This shifting perspective creates some of the great challenges of our time. Climate change is a consequence we all experience of actions we all perform. Individual persons can act, municipalities can act, corporations can act, nations can act, international organizations can act: these are not separate actions, but different perspectives on actions. The fact that we can see a situation as actions by, and consequences for, different sorts of beings, depending on the perspective we choose to take: this does not imply that these actions and consequences are not real. On the contrary, it is just this resilient play, this presentation of fresh appearance to every perspective, that makes the system real, that makes the world real. There is always more to learn.

Friday, December 15, 2017


I saw a film last night, Happening: A Clean Energy Revolution, written and directed by Jamie Redford. It was a pleasant enough film. Redford admits that he doesn’t know much about the subject; the film was about his beginning to learn about it a bit. I spent a few years working in the field, developing software to help manage the grid as more PV panels are introduced, which create large net load fluctuations that utilities need to respond to. The film didn’t address the puzzles that my path brought me to! But probably for many people it would be a good introduction to some of what is going on.

The major dramatic confrontation of the film was how the Nevada Public Utility Commission cut the rate that home PV owners would be paid for energy fed back into the grid. Obviously this makes installing PV systems less attractive. For those who had already installed systems, their electric bills would be increasing substantially. The damage was quite real.

The film then showed how a year later the Nevada legislature passed bills that reversed the PUC decision. The people had rallied and defeated the big bad corporation. The way the movie portrayed things, the people were in favor of new clean technology, while the corporation was holding on to their old ways that made them big profits.

I was disappointed to see the situation pictured this way. I don’t know about the specifics in Nevada, but I would like to sketch out some general parameters, to propose a more fruitful perspective, one that opens opportunities for greater progress.

At the foundation, there seems to be a widespread notion that being driven by profits is at the core of the capitalist system that is destroying our world. I’m not an economist or political philosopher by any stretch. But I suspect that a lot of these highly trained folks go off into specialized concepts and leave the basics rather unattended. Getting the basics backwards creates real obstacles! I would like to try to tidy up a bit to help us move more effectively in a positive direction.

Profit, meaning that some enterprise provides more benefit than it costs, is not a goal peculiar to capitalism. I would say that profit is the foundation of life. Every organism expends resources in order to gain access to further resources. If the newly acquired resources are not of greater value to the organism than the resources expended to acquire them, the organism is running at a loss. Such losses lead to death. Life requires profit.

What precisely distinguishes capitalism? I expect there are many conflicting definitions. I think a useful criterion would be: ownership by investors. By ownership I mean decision-making authority. Every enterprise is given coherency by some decision making process. There are all sorts of people involved in an enterprise, such as customers, workers, managers, suppliers, neighbors, and investors. In a capitalist system it is the investors who have the final authority in how the enterprise is to be run.

One curious feature of the situation in Nevada regarding net metering for residential PV systems is that the Public Utility Commission is, at least theoretically, not representing the investors in the utility. Generally a PUC is appointed by the government and represents the public interest. Electric power utilities in general are heavily regulated by a variety of government agencies and other non-investor bodies. Electric power is not a very capitalist industry! Of course there are powerful investors with enormous influence and decision making authority, so there is a large capitalist component.

Political power doesn’t really flow through textbook channels. Large investors can certainly cast their votes at shareholder meetings, the classical capitalist channel. But there are many other channels of influence. I don’t doubt that the Nevada PUC is pressured in a variety of ways by big money interests, certainly including utility investors. This kind of corruption, where centers of concentrated power can steer decisions to funnel even more wealth and consequent power back to those same centers, is hardly a distortion particular to capitalism. Still, a capitalist system will manifest such steering in its particular way.

Why did the Nevada PUC resist the growth in residential PV systems? No doubt it was to preserve the utility’s profits. But that answer barely scratches the surface. The folks with residential PV systems wanted to stay connected to the grid. If there is no profit in maintaining the grid, the grid will die. So if folks want to stay connected, it’s in their own interest to help insure the profitability of the utility.

The whole electric power system is enormously complex. Some of this complexity is technological and some of it is social. Technologically, the power system can be divided coarsely into generation, transmission, and distribution. The social structure is governed by regulations which vary from region to region. In general, the electric power system was de-monopolized some decades ago. The ownership of generating plants is typically different than the ownership of transmission and distribution systems. Transmission networks usually cross many state lines. Electric power consumed in one state is very often generated in a different state.

The decision of the PUC very likely was intended to protect corporate profits, but the profits of which corporations? If the clean energy revolution is to succeed, what enterprises need to maintain profitability? How can we structure the power system, socially and technologically, to make clean energy profitable? What structures should we avoid that will put the health of the system at risk?

There are certainly large investments in fossil fuel generation – in coal mines, natural gas wells, in railroads and pipelines, and in generating plants that burn fossil fuels. The investors in these facilities want to continue to receive a good return on their investment. Folks that work in these facilities, the municipalities that receive tax revenues from their operations, etc. – it’s not just the investors who want to see these enterprises continuing to operate and continuing to be profitable. For the clean energy revolution to succeed, these are the people whose projects need to be derailed. To whatever extent there can be established alternate ways for these various groups to survive and even thrive despite this disappointment – the less these folks fight against clean energy, the more the revolution can grow.

It’s hard to say exactly what the clean energy system of the future should look like. Redford’s movie provided admiring portraits of large scale facilities such as wind farms and solar thermal generating plants. It’s hard to foresee a practical future where each home and family manages energy usage independently, off any grid, i.e. where the grid is gone. Of course the grid is barely a century old, i.e. humanity survived through almost all its history without the electric grid. So it is entirely conceivable that the grid could just disappear as quickly as it appeared. Still, in trying to plan out a practical path for a clean energy revolution, it seems most practical to incorporate a grid, where generation and consumption can be more loosely coupled.

Building and maintaining a grid, the transmission and distribution networks, together with large scale generation and large scale storage facilities, is a considerable expense. The consumers of electric power who use the grid will have to provide the funds, one way or another, to keep the grid running. Nowadays the main way that consumers pay for their use of the grid is by paying for their total energy use each month, or, equivalently, for their average power use. But this becomes a problem as more and more consumers are also generators of power. Distributed generation adds new sources of fluctuation of power flow in the grid. Distributed generation makes maintaining the grid more difficult and more expensive, while reducing revenue.

Our modern era has created such huge networks that people often lose track of where things come from. We earn money by working at a job and then spend that money paying bills. By keeping up with our bill payments, we maintain the privilege to acquire the various things we need and want. It’s actually our work that fulfills our needs and wants. But there are so many abstract layers between that the connection is hard to recognize. There is a lot of work required to maintain the electric power grid. The idea that there is a greedy corporation that charges us for electric power and that the smart game is to arrange things to avoid paying that corporation: that idea has lost sight of the fact that we rely on systems that take a lot of work to maintain.

There are many challenges we face in bringing about a clean energy revolution. One fundamental shift that we need to navigate is how we pay for the maintenance of the electric power grid. A consumer that uses zero net power but that sometimes pushes energy into the grid and at other times draws energy from the grid, that consumer is deriving benefit from the grid. If the grid is to survive, the users of the grid need to pay to maintain it. Net energy consumption is not going to work anymore as a way to allocate costs across consumers. The clean energy revolution requires us to find a new way to charge consumers for their use of the grid.

This perspective turns upside-down the picture presented by Redford’s movie. Again, I don’t know the specific details driving the decisions of the Nevada PUC. But it is quite reasonable to guess that the PUC understood that net metering is not a method of cost allocation that is going to enable the survival of the grid. Net metering is not going to move the clean energy revolution forward in the long run.

It’s hard to say what sort of cost allocation system can work well in the new clean energy world. For example, maintenance of the grid could simply be funded through government tax revenue. But this approach tends to insulate consumers from the costs their actions incur. Such a lack of feedback tends to foster inefficiency. Another approach is to use smart meters. The typical consumer’s power meter today just accumulates the total power used. Alternative meters could track various statistics of the fluctuations in power consumption and generation. Part of a consumer’s bill could be proportional e.g. to their 90th percentile peak power consumption. After all, the grid operations need to maintain readiness to supply such peak power usage, so it is reasonable to bill customers for such access to power.

After the showing of the movie yesterday in Salt Lake City, there was a short period of discussion with Jamie Redford who was present in the room. I had the opportunity to ask him, “What about smart meters?” He said he hadn’t heard too much about them but had heard about some resistance from consumers who worried about electromagnetic radiation – generally these meters can be read from the street by way of microwave communications. Redford noted that most of us regularly use cell phones that emit very much the same sort of microwave signals, so the resistance to smart meters seemed a bit misplaced.

If the clean energy revolution requires smart meters rather than net metering, it might just be that the consumers are more of a drag on progress than the Public Utilities Commission!

Redford’s film was a reasonable introduction to the clean energy revolution. I hope I have argued effectively here that we need to take the discussion a few layers deeper if we are really going to fulfill the promise of clean energy!

Thursday, November 30, 2017

Goals of Science

Much of what gives science its particular character are its methods, such as the mutual refinement of theory and experiment, and cultivation of community through publications, conferences, the peer review process, etc. But science can also be characterized through its goals. What is science for? Why put effort and resources into science?

At the most fundamental level, science is about making our understanding of the world more accurate and more extensive. Science is exploration and learning. The result of science at this level is a community with a better understanding of the world and an increased capability to interact with the world.

At a more concrete level, science develops a map or picture of the world. Scientists document their understanding of the world not just as a tool to enable further exploration but also as a product or result. The result of science at this level is a collection of documents, databases, simulation programs etc., i.e. information about the world.

Even more concretely, science gives us the power to change the world: to cure diseases, to transform materials, to build airplanes and rockets, to communicate instantaneously around the globe. Whatever the problem, science can show us how to fix it. The result of science at this level is a changed world, a better world that contains medicines, machines, materials, etc. that make the world a better place.

Society changes and so does the institution of science. We need to prioritize our scientific efforts to maximize benefits within constraints. These three levels of goals should help us see that these benefits have a diverse nature. To some extent these levels are mutually reinforcing, for example one component of a better world is the availability of better laboratories which support enhanced exploration and understanding. On the other hand, for example, building a better world is quite expensive so funds will surely be diverted from exploratory efforts whose worldly benefits are uncertain. As political and environmental constraints tighten, these choices will become more difficult. A clearer understanding of their consequences should help us choose more wisely!

Tuesday, October 3, 2017

Conscious Change

A shocking event like the recent Mandalay Bay massacre can wake us up to a broader problem: our culture is infected with violence. Our military actions abroad, abusive action by police inside our country, our enormous prison system, gangs in our cities, bullies in school, violence within our families – certainly mass shootings are a serious issue but our problem with violence goes far beyond that. Is this violence something rooted in our essential character as a nation or as a species? Or this some passing phase, an arbitrary visitation from the vast realm of possibilities, that will depart as mysteriously as it arrived?

This kind of disease is exactly what the medical practice of Buddhism specializes in. Buddhism addresses more specifically the coming and going of such behavior patterns in individuals, but its insights can be generalized to societies. Of course, societies are made up of individuals. Each of us can individually work to uproot whatever violent patterns or tendencies they might experience, and the traditional approaches of Buddhism can be very effective for that. But we can also address our collective problems using similar methods.

Gun control is a key issue in the public debate over how to respond to mass shootings. Some of the opposition to gun control comes from advocates of violence, for whom, if there is a problem at all, it is how to maintain the space for legitimate violence while working to suppress illegitimate violence. Unfortunately this kind of “I am right, you are wrong” approach to violence is one of escalation. With any luck we can learn to see through its deception before the destruction and suffering reach yet more horrific levels.

Another objection to gun control is that it is too superficial. If a person intends violent action, the lack of a gun is a minor obstacle. Criminals will find illegal guns or use other means to indulge their lust for violence. We need to address that criminal mindset directly. Unfortunately the real root of the problem is quite elusive. Each problem is an outcome of several other problems. We have to change everything to change anything. Even if it were possible to design some total new structure for society that would have no place for violence, how could such a reboot of society be brought about? Archimedes envisioned moving the earth, given only a separate place to stand. Who stands outside society, to be in a position to re-engineer it from a clean slate?

The Buddhist approach to conscious change is incremental. The core insight of the Buddha was interdependent origination. The search for a control panel and a seat beside it from which to steer change, this search is futile. Because things arise in networks of interdependence, change must also occur through such networks. We need to steer our behaviors across their full range. The resulting changes can then reinforce each other and lo, the earth moves.

The basic dimensions involved in individual conscious change are outlined in Buddhism as: view, meditation, and conduct. These same dimensions exist in society and can provide a path by which we can extract ourselves from the pervasive violence in our lives.

These dimensions of society already form the cornerstones of exemplary cultures of conscious change. Modern science is built from theory, experiment, and application. In isolation, these elements cannot come to life. It is by bringing them together, each informing and correcting the others, that modern science has achieved the vitality through which it has transformed our world.

The framers of the United States Constitution also understood the vital importance of conscious change and the kind of interdependence required to achieve it. Our three branches of government, legislative, judicial, and executive also inform and correct each other to keep our government responsive to the evolving needs of the citizens.

An event like the Mandalay Bay massacre can wake us up to the need for conscious cultural change. These three dimensions can provide a rough outline for the kinds of work required. Exactly what kinds of structures and institutions might be most effective for this work – probably we will have to stumble along the way and learn from our mistakes. But if we can address the full scope of the interdependence that generated our disease of violence, we will have the power to cure it.

Violent behavior is one link in a cycle. It spawns the anger and divisiveness that then regenerate further violent behavior. To cut this cycle, it is essential to suppress violent behavior comprehensively, across its full range. Violent suppression is absurd and counterproductive. More restrictive government regulation of citizen weapons is a perfectly reasonable component of a program to suppress violence, but such restrictions must be implemented in a nonviolent way. A key element in conscious nonviolent change is an incremental evolutionary approach.

Armed violence by the public is only one strand of the violence that pervades our culture. Violence perpetrated by government agents must also be addressed. Our military actions around the world must become less violent. Our police at home must become less violent. Of course any such constraints will make it harder for these agents to fulfill their missions. But a surprising amount of the time these missions arise from the unintended side effects of prior violent action. As the general level of violence decreases, the sense of crisis lessens and with it the impulse for violent responses.

The arms industry is another component of behavior that promotes violence. With an incremental, evolutionary approach, it is practically impossible to predict where the path leads. To eliminate all need for weapons seems barely imaginable in the long run and completely unrealistic in the short term. But definite concrete steps need to be taken to curb the worst excesses of weapons production. One good step could be the prohibition of making and selling of land mines.

Certainly it will be important that violence from gangs, domestic abuse, etc. be reduced somehow or they can re-infect the broader society. Different opportunities for action will be available to each person and institution involved in the conscious effort to cure ourselves of our addiction to violence. Some folks will pick up the ball early in the game. Others might be much slower in coming around. If movement can become widespread enough in the network of interdependence, the whole world can move.

The simple suppression of violent behavior is not enough to shift the whole network. Changes in conduct must work hand in hand with changes in view and meditation.

View manifests in society as art, literature, media, etc. Violence is clearly even more pervasive in our video entertainment than it is on our streets. We are not going to cure our streets of violence so long as the glorification of violence is a major theme of our video games. It is good that an event like the Mandalay Bay massacre can inspire some people to support stricter regulation of fire arms. Can it also inspire film makers to stop glorifying violence?

Meditation in society manifests primarily as education and training. In general the antidote for violence is to cultivate a deep understanding and appreciation for the other people with whom one interacts. Before the army deploys to a new country, soldiers could learn the language and culture of the people there. Police need to understand the situations of the people in the communities they serve. Religious leaders must not promote bigotry but work instead to enhance understanding across sectarian boundaries. These are not new ideas, of course. But if we can put together a comprehensive program of nonviolence… the whole world can move!

Wednesday, November 16, 2016

State Reachability

State Reachability is an important problem in computer science, with many applications in engineering. It is the simplest problem in the broader class of Model Checking problems. Principles of Model Checking looks like a good book to learn about model checking. Ken McMillan has been a pioneer in model checking algorithms from the very early days, in the 1980s. Among his many publications, I would refer specifically to his 2003 paper Interpolation and SAT-Based Model Checking which uses SAT-based methods. I will sketch out here another SAT-based method which should complement the interpolation method of McMillan.

State Reachability is an extremely difficult problem, in that for every algorithm there will be some relatively small instances where that algorithm takes a very long time, and a huge amount of memory, to solve that instance. Of course, computer science has still not proved that hard problems actually exist – this is the famous P=NP? theorem, as yet unproved – but if any hard problems exist, State Reachability is hard.

Satisfiability, or SAT, is another hard problem – indeed, it is the prime example of a hard problem. State Reachability is like the big brother of Satisfiability. Satisfiability relates to Boolean functions. A Boolean function is some sort of rule or formula that determines a 1 or 0 result for each possible value of some input. The input of a Boolean function is generally an array of 1/0 values. So a simple Boolean function might map the four input values {000, 011, 101, 110} to the result 0, and {001, 010, 100, 111} to 1. When there are only three bits in the input array, as in this example, it is easy to list all eight values of the inputs, compute the value of the function, and determine whether the result is always 0 or whether there are any input values that have a 1 result. As the number of bits in the input array gets larger, say 30 or 100 or 300 bits, the number of input values grows so quickly that it becomes practically impossible to consider each input value individually. Satisfiability algorithms are some of the oldest algorithms in computer science and continue to be improved. SatLive is a good site to find out about recent work in this field.

The State Reachability problem builds on the Satisfiability problem. State Reachability works with a finite state machine, constructed around a more complex Boolean function, one that maps an input array of 1/0 values to an output array of 1/0 values. Rather than computing a single output value from a single input value, a finite state machine performs a series of computations using the same Boolean function in each step. The output of each step becomes part of the input of the next step. This is essentially how digital electronic circuits, such as computers, work. Other engineering problems can also be abstracted to appear in this guise.

A finite state machine can be pictured like this:

Here the five squares on the left represent the present state of the machine, and the five squares on the right are the next state. The two value on the upper left are the inputs to the machine that steer the machine down one path or another. The grey blob in the middle represents the Boolean function that computes the next state of the machine on the basis of the present state and the machine's input values.

Each value of the output array is a state of the finite state machine. As the machine operates, the machine moves from one state to another. The State Reachability problem asks whether there is any way that the machine can start from a given initial state and eventually reach a given target state.

The behavior of a state machine can be illustrated with a state transition graph:

Here the green dot is the initial state and the red dot is the target state. It is easy to see that there is no path from the initial state to the target state. This kind of inspection gets much harder as the number of states of the machine grows. Each state is a Boolean vector value for the bits of the machine, so every new bit in the machine will double the number of states. Once the number of state bits grows above a few dozen, even a computer will have a hard time recording the complete state graph.

Each step of the machine’s operation involves the evaluation of a Boolean function. To determine whether the target state can be reached in a single step, in one evaluation of the Boolean function, is a Satisfiability problem. The behavior of the machine across two, three, or any fixed number of steps, can again be posed as a Satisfiability problem, just with a larger Boolean function. But as machines grow, the potential number of steps between states also grows. So deciding whether a target state can eventually be reached from an initial state, the State Reachability problem, gets very difficult very quickly as the size of the finite state machine grows.

The first quick and simple approach to checking whether a target state can be reached is to perform random simulation. This allows many states to be explored very quickly. If the target state is easy to reach, random simulation may well find a path to it.

Another approach is to use a Satisfiability checker to see whether there is a reasonably short path from the initial state to the target state. Paths that are too long will be too computationally expensive for the Satisfiability checker. It is simple enough to set up check to see if there is any path to the target that is less than some maximum number of steps. If a path is found, the State Reachability problem is thereby solved! If no path is found, a modern Satisfiability checker will be able to provide a minimized proof. This proof will typically not include every state variable in the machine. The algorithm I am proposing here requires the selection of some relevant state bit to be extracted from this proof.

The algorithm I am proposing here involves the incremental refinement of an abstract state machine. The states of the given finite state machine are partitioned; each block of the partition constitutes a state of the abstract state machine. The abstract state machine is refined incrementally by splitting blocks one at a time. Each block is defined by a partial evaluation of the state bits. A block is split by picking one of the unvalued bits of the block. The two new blocks are formed by given the selected state bit the 0 and the 1 value in turn. The state bit used for splitting will be picked from the various proofs of unsatisfiability generated by the Satisfiability checker as the algorithm proceeds.

The abstract state machine guides the exploration of the concrete state machine that defines the problem. A collection of reached concrete states is maintained. Each of these reached states belongs to a block in the partition that defines the abstract state machine, i.e. maps to an abstract state. The idea is to find ways to reach as many abstract states as possible. If a path cannot be found from an already reached state in one block of the partition to another block In the partition, it may be because there are no paths between any pair of states in those two blocks. If there are no possible paths in the abstract state machine between the block containing the initial state and the block containing the target state, then there are no paths in the concrete machine either. Discovering this would solve this State Reachability problem instance with a negative result.

When some states in a block can reach states in another block, but none of the reached states can, then the block should be refined. The hope is that one of the split off blocks will have all the reached states, while the other block has all the states that have paths to the unreached block. The idea is to work to keep as sparse as possible the state transition graph of the abstract state machine. This sparseness will help guide the Satisfiability checker to focus on abstract paths that have a good likelihood of mapping to concrete paths, or, on the other hand, will result in an abstract state graph with no path at all between the initial block and the target block.

I'll go through the pieces of the algorithm again, in pictures. First, random simulation is used to explore states that are easily reached from the initial state:

The abstract state machine is initially trivial, consisting of a single block, corresponding to a partial evaluation of the state bits that has none of the bits given a value:

The first run of the Satisfiability checker can look for paths from the initial state to the target state. If none are found, a bit can be selected from the proof of unsatisfiability. This bit can then be used to split the block:

Now the Satisfibility checker can be used to look for paths to states in a block that has not yet been reached:

Whenever interesting new states have been reached by using the Satisfiability checker, it can be worthwhile to explore further by running random simulation from these new states.

The Satisfiability checker is used to look for paths to the target or to unreached blocks, starting from reached states that are closest to these goals. When a path cannot be found, the resulting unsatisfiability proof can be used to pick a bit to use in splitting the block:

Before splitting a block, though, one should check whether any of the states in the starting block have a path to a state in the goal block. If not, the abstract state machine can mark as impossible that transition:

Eventually the abstract state graph will chop the path from the initial state to the target state into small enough pieces that a combination of random simulation and Satisfiability will find a path, or enough abstract states will be missing enough transitions that the target block will be unreachable from the initial block in the abstract machine. This, this algorithm will eventually determine an answer to the given State Reachability problem instance.