A Hard Problem of Grammar: A formal logic analogue to Nagel’s bat

The hard problem of consciousness, and variations on it, revolves around the difficulty of explaining mental phenomena—I see and smell a rose; I think about my work; I feel pleased by good news—in materialist or physicalist terms.

The presumptive barrier that prevents neurophysiological research answering this question, is that objective observations which can be made by a researcher — such as, electrical current moves through these neurons; a biochemical cascade releases such and such a hormone — appear to be about completely different things than the subjective experiences of a conscious experiencer.

This objective/subjective gap has also been called a first person / third person gap: how can third person sentences such as “that neuron spiked” possibly relate to a first person sentence such as, “I see red.”

Expressed this way, the problem can be studied with formal languages. This appears to make it provably insoluble. It’s a hard problem of grammar: there is no sound deduction from a set of 3rd person sentences to a 1st person sentence in any formal logic.

  • If subjective experience could be explained in objective terms, then that explanation—if it is a rational one—must be expressible in formal language.

(This claim may not be obvious. It’s like claiming that some form of the Church-Turing thesis applies not only to mathematics and logic, but to rational discourse more widely, including empirical research.  I’m suggesting that any argument which is genuinely rational, can be expressed in a formal language. If some part of the argument can’t be formalised then I think we will discover, on inspection, that it’s because the argument isn’t rational. Either it will be a non-sequitor, or it will be an appeal to emotion, or an ad hominem attack, or somesuch).

  • If so, the formal version of that explanation would have to, at some point, define the word ‘I’ in ‘3rd person’ terms, that is, without relying on any first person noun or verb or other part of grammar.

(This is essentially an assertion that some form of the Craig interpolation theorem can be proven for any formal grammar suitable for rational discourse. The Craig interpolation theorem says (more-or-less), that given a set of sentences only about apples, you cannot validly deduce from them a sentence about oranges. I think we would say that any formal language that does not satisfy this constraint is not a language we can use for rational discourse. It may still be fine for poetry).

  • I assert that any such attempted definition will, on inspection, turn out to be invalid.  That is, when we look at any such purported definition, we’ll be able to see that it doesn’t quite work and hence that the explanation which it supports will also fail. I do of course look forward to being proven wrong, but there aren’t any attempts on the table so far.

I think any attempt to define 1st & 2nd  person words – I, you, me, we  – in 3rd person terms fails. Any definition using only 3rd person terms can only succeed in defining 3rd person ‘things’.

The thought is somewhat similar to Chalmer’s “Structure and functions” argument: anything you can define with structure and function will itself be structure and function. I think the grammatical argument is stronger, surprisingly (one doesn’t expect arguing about grammar to prove anything!), because 1st and 2nd person speech and relationships is, and always has been, a core part of the reality of human experience.

Intuitively, throughout the modern era, people have always felt that a reductionist materialist account of humanity surely misses something. The grammar of every human language (at least, every one that I know of) embodies that fact.


Mathematics: a Definition

I propose a definition of mathematics:

Mathematics is the deductive analysis of structures

  • Deductive, because empirical data does not generate mathematical results; only logical deduction does so.
  • Analysis, because mathematicians tease out the consequences of the definitions of structures, rather than merely admiring, or using, or playing with them.
  • Structures because … well, this is the question: what do mathematicians study?

What do Mathematicians Study?

The OED definition of mathematics relies on a rather post hoc list, as the “etc” acknowledges:

“The abstract deductive science of space, number, quantity, and arrangement, including geometry, arithmetic, algebra, etc., studied in its own right (more fully pure mathematics), or as applied to various branches of physics and other sciences (more fully applied mathematics).

Shorter OED 2007

Without the etc, this would need revision every time a new area of mathematics opens up. It is more like a rough description than a definition.

But every branch of mathematics straightforwardly has this in common : it analyses a particular structure (or a family of structures; which is still a structure), and deductively analyses it, that is to say draws out its properties and relationships to other structures.

There are favoured structures. Numbers, of course. Then the Euclidean plane, which is the structure of lines and points on a flat surface. These favoured structures define the familiar major areas of mathematics–number theory, algebra, geometry, analysis. “Progress” in mathematics divides into, on the one hand, discovering new things about known structures; and on the other hand choosing new structures to study.

New structures may be chosen for the light they shed on old ones: complex numbers, for instance, shone a new light on algebra, as did topology on geometry. Formal logic & computer science intended to shine light on the very processes of mathematics itself. Whenever a new structure is found to have interesting properties it may become a part of mathematics and even, if there is work enough in exploring it, be dubbed a branch of mathematics, which is perhaps the ultimate mathematical status.

The virtue of naming structure as the subject of mathematics is that it becomes easy to say whether something is or is not mathematics: anywhere there is a structure that can be analysed deductively, there is a subject of mathematics. The ad hoc element of the definition is banished.

It also reminds us not to be surprised every time a new branch of mathematics opens up. If it moves, or even if it doesn’t, it’s fair game to a mathematician.


Rule #1 of Coffee Club : Keep It Fresh

“Think of when you cut into a banana, how quickly that slice of banana oxidizes. Now think of how big that slice of banana is compared to these tiiinnnyyy granules of espresso.”

“They oxidise quickly! Get rid of them, grind them fresh!”

A well-packed 23 minutes from US Barista Champion Heather Perry on making good espresso:


Deep Learning & Unintended Algorithm Bias

This was a 5 minute talk on deep learning for the very excellent @chesterdevs. Like others talking about deep learning, I took visuals and the face-learning example from the landmark 2012 paper, Quoc Le/Google/Andrew Ng paper, “Building High-level Features Using Large Scale Unsupervised Learning.”

Only afterwards did I notice that the subset of images which their system show as “most like a face” from their test set were 90% male and 90% white, as is the prototypical face that the machine outputs.

And so we have a neat demonstration of unintended algorithm bias: their input was 10 million randomly-chosen youtube videos; the output was white and male. I bet they didn’t expect that.

A salutary reminder that—as the hard-working statistician will tell you—“random selection” does not mean “unbiased”.

Customise Macos XQuartz : xinitrc doesn’t work

If you installed XQuartz and are, for instance, irritated by the small white xterm window you get, you might try customising it in the usual way by editting an .xinitrc file. If only.

Instead, try this:

defaults read org.macosforge.xquartz.X11

to see all the settings; or to permanently change the startup xterm window, something like:

defaults write org.macosforge.xquartz.X11 app_to_run \
 "/opt/X11/bin/xterm -fa Monaco -fs 12 -fg green -bg black -sb -sl 1000"

Or, if you have installed a better bash with homebrew, then e.g. :

defaults write org.macosforge.xquartz.X11 app_to_run \
  "/opt/X11/bin/xterm -fa Monaco -fs 12 -fg green -bg black -sb -sl 1000 -ls /usr/local/bin/bash"

Before setting the default you can check your syntax is correct simply by running your command in a terminal window.

To set the default for a new xterm window from the XQuartz Application menu, the menu itself lets you edit the command.

In short, read the FAQ : https://www.xquartz.org/FAQs.html.

Other Examples of Software Architecture with UML (2002)

This example is from 2002, by IBM and RDA Corp, published at https://www.ibm.com/developerworks/rational/library/content/03July/2000/2000/2000_RDAEStoreAbbrevSAD.doc.

I’m happy with this style of S.A.D, but there some things I would change if I was in an organisation that produced this kind of document. Broadly, I would related the views back to the structure of the 4+1 approach, rather than simply listing 6 apparently unrelated views.

  1. Put the “+1” back in, in the form of a Use Case and Context View.
  2. Add a Domain Model & Glossary to to the Logical View. To my mind, these are the centrepiece of the Logical View.
  3. Notice that the Security View is more a narrative of how the requirement is met than it is a model of the system. I would follow Rozanski & Wood’s terminology and call it the Security Perspective, and/or put it in a Quality Attributes section after the views.
    Also, I don’t believe that Security is the only important Quality Attribute. I’d add sections for them.
  4. Make the Data View a child view of the Logical View. In this example document, physical database details have been explicitly excluded. This suggests to me that the database is owned by a different team to the team developing this system, and the Data View is effectively the “interface” provided by the database team to the team developing this system. In that case, I would show the database on a Context diagram as an external dependency.
  5. I would rename Implementation View back to Development View, and use it to
    1. link to to the CI/CD pipeline, which in my mind entirely replaces all technical detail that you might put in the Implementation View.
    2. Discuss the human factors, team organisation and ownership. The interesting question about the top-level packages is, who owns them?

1       Introduction

The architecture of a software system requires six distinct views, each view focusing on different aspects of the system. Its purpose is to communicate the major components of the system, how it is structured, the system process flows, and major interfaces. From a high level, the goal is to examine the system from several different perspectives, each providing a different “view” in order to capture all critical system features. A brief description of the six architecture views is provided as follows:  

Deployment View – This view documents the physical topology of the system modeled in the Deployment Model.  It includes each computer in the implementation and describes how they are interconnected.  The configuration for each node is also specified – Operating system, databases, Commercial off-the shelf (COTS), and custom applications.

Logical View – The logical view documents the Design Model, which defines the layers of the application and the primary classes within each layer.  The system architect identifies patterns of functionality and creates common mechanisms to provide this functionality to several areas across the application. 

Data View – Classes in the logical view are classified as transient or persistent.  The persistent classes are mapped to structures on disk, usually into a combination of rows in a relational database. An entity-relationship data model describes the database schema.  This view also communicates how the Object-Oriented classes are mapped to the relational tables.

Process (Concurrency) View – This view focuses on the concurrency aspects of the system and how they contend for shared resources (i.e., transaction semantics, etc.). The process view documents the independent threads of execution within the system and describes how they communicate.  It also lists the resources in contention by these threads and the transaction model for maintaining integrity with these resources.

Implementation View – This view maps the classes in the Logical View to physical source files and combines the files into deployable components.  The implementation view also tracks the dependencies among the components.

Security ViewThis view focuses on how the system identifies end users, grants authorization to them based on their identity, ensuring integrity of the system and of the data and properly tracking and auditing of system activity.

Note: This is a brief overview of the architecture.  The complete eStore SAD is included in the download.

2       Deployment View

The configuration view presents the topology and its physical and logical connections.

3       Logical View

The logical view presents the core design of the system.  It presents the primary classes that collaborate to implement the system functionality.  It contains the following subsections:

3.1      Three Software Layers

The application is structured along three distinct layers – UI Layer, Business Layer and Data Layer.

UI Layer: Responsible for authentication, presentation and managing session state.

Business Layer: Exports the business objects defined in the Solution Model class analysis.  Maintains no knowledge of presentation.  Insulates the UI Layer from database design.  Responsible for complex business rule logic.

Data Layer: Responsible for managing persistent data and transactions.  Maps business objects to physical relational tables.  Responsible for data integrity, transactions and data intensive business rules such as unique name on a column.

3.2      Business Layer Interface

The following diagram illustrates the classes and their relationships exported from the business layer to the presentation layer.

Figure 1: UI Session Stack Class Diagram


3.3      Business Layer Implementation

Pet Store’s business layer is implemented by leveraging the services provided by IT FlightPlan’s Software Library.  The business classes exported by the business layer are either BusinessClasses or ReferenceClasses.  IT FlightPlan’s Software Library exports a BusinessClass base, abstract class and an IReferenceClass interface.  The following diagram shows how the classes in the business layer are implemented – the session BusinessClasses inherit from BusinessClass while the cached classes implement the IReferenceClass interface.


4       Data View


The Database Model is presented as a logical view, physical view and data dictionary.  The logical data model is included in this overview.



4.1      E/R Model

Logical View

5       Process View (Concurrency)

The Process View focuses on the parallel processing aspects within the system.  eStore deals with concurrency in two distinct areas –

  1. The CPU/process/thread design

2.     Transaction design for shared resources,

A.    Records in the PetStore database – single data source

B.     Updates to PetStore database and the Credit Authorizer

C.     Shared objects in memory

5.1      CPU/Process/Thread Design

This diagram shows the major threads and context switches involved with processing a web request.  IIS allocates a pool of worker threads to process HTTP requests and posts.

5.2      Transaction Design


5.2.1      PetStore Database transactions

All transactions are encapsulated within a call from the BusinessLayer to a stored procedure.  Any SQL errors within a stored procedure force a rollback and the error is raised to the BusinessLayer. 


Account data integrity is maintained through optimistic concurrency.  A unique version timestamp is returned with each head Account object. 


5.2.2      Updates to PetStore database and the Credit Authorizer

There is one point in the application where there are two distinct data sources, so this leads to a critical region in the code.  ConfirmAddresses invokes CreditAuthorizer to charge the customer’s credit card.  If successful, it returns a credit authorization code, which is stored in the Payment when the Order is saved.  We have an exposure in the case where the charge is successful, but Order.save() fails.  CreditAuthorizer does not support two-phased commit transactions, so RDA Pet Store will continue to reconcile its daily charges with the Credit Authorizer at the close of each business day. 

5.2.3      Shared Objects in Memory

The static reference objects that are shared across all sessions have only one instance per web server.  All sessions refer to this single instance.  Since these classes are loaded when the application starts and are not modified, semaphores are not required for synchronization.

6       ImplementationView

The implementation view describes how the software is physically contained in files and how files combine to form components.  At the highest level, the application is comprised of packages.


The 3 layers outlined in the Logical View (UI, Business and Data) are implemented with the above packages as follows –

UI Layer:

  • RDAEStore[CS, VB]  – all aspx, code behinds, images and Pet Store UI utilities

·       ITFlightPlanSWLib  – generic UI utilities to bind/unbind attributes to UI controls

Business Layer:

  • BusinessLayer[CS, VB]  – all of the Pet Store business classes

·       ITFlightPlanSWLib packages – reusable mechanisms the provide persistence and error handling\

Data Layer:

·       DataLayer – the Pet Store tables, stored procedures and reference data

·       ITFlightPlanSWLib – Generic wrapper interface to access ADO

7       Security View

The security view describes how the system implements the security requirements specified in the Detailed Spec.  Security design is presented in the following sub-areas.

ü  User Identification & Authentication – How does the system identify users and verify it is them?

ü  Authorization – Once authenticated, who is allowed to do what?

ü  Data Integrity and Privacy – Ensure the integrity of the data is not compromised.

ü  Non-repudiation and Auditing – Ensure the end user cannot cover up their tracks.  Record access to the data so we know who’s done what.

7.1      User Identification & Authentication

  • eStore uses ASP.Net Forms authentication to authenticate users.
  • UserIDs and passwords are stored in the RDAPetStore database.  Passwords are first “sha1”, 40-byte encrypted before being stored in the database.
  • The eStore application itself authenticates with its own SQL Server userID.  The ID and password is stored in the web.config file.  The only the database objects granted to the eStore userID are execute grants to the eStore stored procedures.

7.2      Authorization – Data Entitlement

eStore uses a single stored procedure – getAccountForUserID – to fetch the account information for a particular user and stores it in the session stack. 

Since the authenticated user contained in the session stack, eStore relies on the integrity of .Net sessions to ensure that users can only access their own accounts. 

7.3      Data Integrity and Privacy

V1.0 of RDA Pet Store provides minimal protection of data.  Passwords are encrypted before they are stored in the database.

Extending Pet Store to be more secure, we would use SSL to transmit password and credit card information.

7.4      Non-repudiation &Auditing

Each table in the database provides last modified by and last modified timestamp columns.  The authenticated userID parameter on the save stored procedure is set in these columns on all inserts and updates.

Dead Nintendo Switch?

“I’m sure this is irrelevant chatter but a few days ago I turned on my Nintendo Switch for the first time in months but the battery had drained, so I went to charge it but noticed after 20 minutes it still wouldn’t turn on, I tried using another plug and putting it in the dock, it still wasn’t working, I knew from early YouTube videos that some people had this problem and sold their console on eBay as “faulty, not accepting charge” when the console was first on the market, not wishing to sell my console I proceeded to calmly take it appart in an attempt to disconnect the battery and plug it in again in order to wake it up, however I’d forgotten how to remove the battery and wasn’t sure the tools I had were best for the job, looking at the connector though made me realise if use 2 electrical screwdrivers, I could short the pins, simulating a temporary disconnect, I allowed the battery to spark for a split second and reassembled the unit. Hey presto, the Nintendo Switch is back in full working order, end of story. Good day to you all.”

James Barnes

Dev Azure Pipeline Web Config Transform

The web.config transform appears at first glance to be somewhat orphaned in Azure DevOps. If you are deploying to a WebApp then the pipeline wizard will probably have given you this snippet for your Build step:

- task: [email protected]
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

To run config transforms you can add the additional parameter /p:TransformConfigFile=true to your msbuildArgs.

The replacement, of course, is the independent FileTransform task (which can also work within zip files). But once your site is packaged the Web.Release.Config is left behind; so you have to run the FileTransform task before, not after, the build step. (Similarly the WebAppDeployment task can’t transform a Web.Release.config that isn’t inside the package).

Slightly magically, the default parameter for the FileTransform is which is exactly what you typically want for web.Release.config transforms:

#xmlTransformationRules: '-transform **\*.Release.config -xml **\*.config-transform **\*.$(Release.EnvironmentName).config -xml **\*.config' # Optional

FileTransform can also do variable substitution, and you can have multiple FileTransform steps in your pipeline. I also like to see some diagnostic feedback so I include script step to show the xml transform result. But I put it before variable substitution, because the variables often include secrets:

- task: [email protected]
displayName: Transform Release.Config
folderPath: '$(System.DefaultWorkingDirectory)/Ui/'
enableXmlTransform: true
xmlTransformationRules: -transform **/*.Release.config -xml **/*.config

- task: [email protected]
displayName: "Confirm web.config transform"
targetType: 'inline'
script: 'cat $env:System_DefaultWorkingDirectory/Ui/web.config'
errorActionPreference: 'continue'

- task: [email protected]
displayName: Variable substitution *.config
folderPath: '$(System.DefaultWorkingDirectory)/Ui/'
fileType: 'xml'
targetFiles: '**/*.config'

- task: [email protected]