Monday, February 21, 2022

Lots of tasks for 2022; what are the priorities

With the JSON/SQL implementation, I showed myself that what I was imagining (Latex entry, CAS integration, symbol tracking, Latex/PDF output) was in fact feasible. However, the JSON/SQL backend and the forms-based web front-end were sufficiently embarrassing that I wasn't interested in showing off the idea. 

Now my goal with the Neo4j/SQL backend my goal is 1) provide query capability and 2) to not be embarrassed. 


High priority:

Low priority: 

  • analysis of server logs -- https://github.com/allofphysicsgraph/proofofconcept/issues/246

Tuesday, February 8, 2022

old undated project goals

This page content is from two migrations, most recently https://sites.google.com/site/physicsderivationgraph/goals

I don't know the original date of this post


Objectives

  • Create a framework capable of describing all mathematics needed for physics derivations. I use Latex as the syntax in the framework because Latex is how I think of equations. However, Latex is insufficient for processing by computer algebra systems. Status: proof of concept exists

  • Create machine-readable databases which use the above framework to capture the mathematical derivations in physics. To hold the content of the databases I'm using custom XML. Status: proof of concept exists

  • Create graphical representation of relations content in the databases. I'm using GraphViz to render the visualization. Status: proof of concept works

  • Use a computer algebra system to verify the relations in the databases. I'm using SymPy as the CAS (see also a list of candidates). Status: proof of concept works.

  • Create a web browser-based viewing of the generated graph. HTML5 seems capable. Status: investigated, not started

Create a web browser-based graph input tool. Status: not started


The above workflow applies to both CLI and web-based GUI. Implementing a web-based GUI is its own learning curve, so separate the above workflow diagram into two sets of tasks. The following applies to both web-based GUI and CLI.

Tasks

  • user adds content to internal data structure (user --> IDS)

  • write content to external database from internal data structure (IDS --> DB)

  • read content from external database into internal data structure (IDS <-- DB)

  • render internal data structure as visual graph (IDS --> graph)

  • check internal data structure content using CAS (IDS --> CAS)

Currently (20140527) what I'm actually doing is (user --> DB) and (DB --> graph)

Rant 1: historical progress

How we do math and physics has undergone some historical transitions in how the process is carried out. 

Initially research was done by individuals by paper and pen, then communicated via letters and later journals. <claim>Mechanical computers were initially used for computation of known capability, rather than enabling novel research. </claim> 

In the past 50 years, electronic computers have enabled numeric and symbolic computation. High performance computers at large scale allow for research at unprecedented pace. Results in article form are still communicated via printed journals, and more recently, electronically. Sharing data and algorithms in electronic format is the current revolution. 

The tools we use have expanded from paper and pen to Computer Algebra Systems, databases, and programming languages.

old log entries from 2014

20140927 syntax := ABNF

An issue I've previously encountered is how to store the information associated with the graph. I started with plain text, and then moved to XML (the current state). The content stored in the XML is Latex. Latex renders well, but lacks context (meaning). I am now investigating Content MathML as a stricter (but less widely adopted) syntax. Although Content MathML is better, it doesn't entirely capture the use I intend for this project.

The core of the project centers on the following two conventions:

<statement> = <left hand side> <relation> <right hand side>
<statement> --> <inference rule> --> <statement>
The relation is typically equality or inequality, though it could include union and other operators.

The inference rule acts on one or more statements.

The statement is the relation between two mathematical expressions

This is outside the scope of Content MathML, XML, and Latex. I think the appropriate capture is to use something like Augmented Backus-Naur Form (ABNF). Here are a few possible rules:

derivation = 1*2statement inferenceRule statement; some derivations involve multiple input statements, here we allow 1 or 2

statement = mathExpression relation mathExpression

mathExpression = *ALPHA *DIGIT *SP *operator *"\" *"." *"," *"'" 

relation = ( "=" / "<=" / "<" / ">" / ">=" / "U" )

operator = ( "+" / "-" / "/" / "*" / "^" / "!" / ( "[" "]" ) / ( "(" ")" ) / ( "{" "}" ) / "|" )
Looking at the code, I've already adopted the following rules
infrule_name = 1*ALPHA

statement_punid = 10DIGIT

statement_tunid = 7DIGIT

symbol_punid = 15DIGIT

From my notes, it appears I first figured out the requirement for the statement label restrictions on 20110406.

20140527 commercial projects

In the past week I've been made aware of 3 commercial efforts similar to this project

SymboLab and Formula-Database are similar, in that both are about search of equations. In addition to search, SymboLab provides derivations and plot. It's not clear whether these are dynamic or hand-coded. SymboLab appears to be more mathematics oriented, whereas Formula-Database has descriptions of the physics and symbol definitions. EquationMap is about user-generated graphs of derivations. My project has a poorer user interface, and the objective is grander (capture all of physics derivations).

None of these three are direct competition with this open source project, though there is overlap with subtasks from each project. I don't see a clear use case for any of the three -- if it were that useful as a product, I would have expected someone else to already be working in this area.

I'm not clear on why there aren't other open source projects in this area. Proofwiki.org is not graph-based, and PlanetPhysics disappeared.

20140527 task prioritization

Task prioritization:

  • navigable interface. The current graph is large enough that intuitive navigation is an issue which needs to be addressed. The graph is currently rendered as a static PNG file. Rendering the graph in a web browser might be more accessible (allowing interactive navigation), and would generate a new set of issues to be addressed (i.e., reading XML databases into a new data structure). By "navigable interface" I am distinguishing from an interface for entering new data to be stored in the database
  • ability to high-light subsections of the total graph related to a specific derivation
  • ability to high-light the symbol use graph within the statement graph
  • add content (E=mc^2, Maxwell's equations)
  • fully check graph using CAS (currently SymPy)
  • user input through CLI
  • user input through web browser GUI
To create a navigable interface, my first guess is to start by finding an example of an HTML5/Javascript directed graph with png/svg files as nodes. This is because I think it's probably unrealistic to render the Latex statements in a browser with a dynamic graph

As far as intuitive interface, I like Google Maps and its ability to zoom in/out when visualizing large spatial data. EquationMap is a good start but isn't open source.

20140526 computer algebra system (CAS) inputs

In reviewing candidate Computer Algebra systems, I still think SymPy is the best option compared to the other free and open source CASs https://en.wikipedia.org/wiki/List_of_computer_algebra_systems

Currently I expect the user to provide two inputs for each statement: Latex for visual rendering, and the SymPy equivalent for checking with the CAS. This is redundant, since SymPy can render Latex.

The reason I let the user supply Latex is because as a physicist I think in terms of Latex (not SymPy). I treat the addition of the SymPy equivalent as a second step

I have a fundamental conflict with (1) wanting the input format to be easy (i.e., Latex) and (2) wanting the content to be checkable by a CAS (i.e., MathML). I don't think there is a an easy-to-input format which is also easily checkable by a CAS.

Does the database need to be checked by a CAS?

There are two reasons one builds this database:

  • as a notepad for current research, possibly to be used in a publication. Assumptions: dynamic; written to by only a few people; it may contain mistakes. Thus, it would be helpful to be checked by a CAS
  • to store relations between all accumulated knowledge. Assumptions: static database; written to by many people; read by many people. Thus, mistakes are likely to be found whether or not there is a CAS

20140510 graph vs relational database

I need to better understand the difference between Graph vs relational database vs object

  • https://en.wikipedia.org/wiki/Graph_database
  • https://en.wikipedia.org/wiki/Relational_databases

Wednesday, January 5, 2022

two hours to manually transcribe three typed pages of math into 150 lines of HTML+Latex

I have about 20 boxes of notes from roughly 10 years of undergrad and graduate classes in Math and Physics. I've kept the notes for the past 10 years with the intent of converting the notes into a structured and computer-readable format. The current site https://derivationmap.net/ shows the proof-of-concept that the technical capability is feasible. 

I spent two hours manually transcribing three typed pages of math into https://derivationmap.net/class_notes/math402_mathematical_physics_hale. The resulting HTML with MathJax was about 150 lines. By the end my attention/focus was waning, so a break was necessary. 

The typed notes are merely transcription into computer-readable format; the notes are not in the "equation graph" form necessary for the Physics Derivation Graph. That is a separate tedious process. 

Observations:

  • An estimate of how long transcribing all the notes would take:
    • If I type HTML+MathJax for 4 hours a day, that seems reasonable
    • If a box of notes is 1 ream (500 pages), (500 pages/box)*(2 hours/3 pages)*(20 boxes)=6666 hours
    • 6666 hours/(4 hours/day) = 1666.5 days, or 4.5 years
  • There are many diagrams that go with the text and equations. The three pages in this sample didn't have diagrams. Converting the diagrams into tikz would be time consuming.
  • The structure of the notes is not compatible with the constraints of the "equation graph" structure. 
  • I expect that scanning + OCR would be of limited value for producing Latex. Also, much of the notation in the notes is sloppy and requires translation to more rigorous notation. 
  • Even the more "rigorous notation" is merely an improvement; the notation is a long ways from the specificity needed for use in a computer algebra system. As an example, 
    • the original format for an inner product is (x, y) -- here "x" and "y" are merely bolded
    • my more rigorous notation is $(\vec{x}, \vec{y})$
    • Multiplying the inner product by a complex value $\alpha(\vec{x}, \vec{y})$ is visually ambiguous -- it could be interpreted that $\vec{x}$ and $\vec{y}$ are arguments to the function $\alpha$. See also this question.
  • Notes for a course are either a single page (with thousands of equations, which render in MathJax slowly) or split among many pages (increasing the number of context switches)

If typing every page of notes into HTML+MathJax is not reasonable (or useful), then identifying what part of the notes are useful should be the objective. 
  • not useful: Homework problems and exams are reliant on identifying and applying one or more Physics expressions and then numerically compute the result for a given scenario. Homework problems rarely demonstrate connectivity among Physics expressions. 
  • not useful: identities that arise from definitions. Example: Cauchy Schwartz
  • marginally useful: Derivation from definitions 
  • marginally useful: Derivation from experiments 
  • potentially useful: Derivation from another expression 

Simple harmonic oscillator - identify every domain it is used in

Saturday, October 9, 2021

periodic renewal of https letsencrypt certificates

Confirm expiration date of current certificates
openssl x509 -dates -noout < \
/home/pdg/ui_v8_website_flask_neo4j/certs/fullchain.pem

Delete existing certs
sudo rm -rf /etc/letsencrypt/live/derivationmap.net
sudo rm -rf /etc/letsencrypt/renewal/derivationmap.net
sudo rm -rf /etc/letsencrypt/archive/derivationmap.net
Confirm folders are empty
sudo ls -hal /etc/letsencrypt/live/
sudo ls -hal /etc/letsencrypt/renewal/
sudo ls -hal /etc/letsencrypt/archive/

Request new certs
sudo certbot certonly --webroot \
-w /home/pdg/ui_v8_website_flask_neo4j/certs \
--server https://acme-v02.api.letsencrypt.org/directory \
-d derivationmap.net -d www.derivationmap.net
To use multiple domains and a single cert, use
sudo certbot certonly --webroot \
-w /home/pdg/ui_v8_website_flask_neo4j/certs \
--server https://acme-v02.api.letsencrypt.org/directory \
-d derivationmap.net -d www.derivationmap.net \
-d allofphysics.com -d www.allofphysics.com
Output should be something like
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/derivationmap.net/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/derivationmap.net/privkey.pem
   Your cert will expire on YYYY-MM-DD. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"

Copy new certs to directory that nginx mounts in Docker-compose
cd /home/pdg/ui_v8_website_flask_neo4j/certs

mv dhparam.pem dhparam.pem_OLD
mv fullchain.pem fullchain.pem_OLD
mv privkey.pem privkey.pem_OLD

sudo cp /etc/letsencrypt/live/derivationmap.net/fullchain.pem .
sudo cp /etc/letsencrypt/live/derivationmap.net/privkey.pem .
sudo chown pdg:pdg privkey.pem
sudo openssl dhparam -out dhparam.pem 2048

Restart Docker-compose
cd /home/pdg/ui_v8_website_flask_neo4j/
docker compose up --build --force-recreate --remove-orphans --detach
If the docker containers are not restarted, the changes made to the file on the host won't take effect.

Verify in a browser that https://derivationmap.net/ has the updated certificate. 

Set a calendar reminder to renew the certificate.

Saturday, August 21, 2021

documenting my frequent pivots

  • survey all topics in Physics. [See this 2017-07 post.]
  • investigate refactoring the database from JSON to RDF. [See this 2020-12 post.]
  • goal: add a new derivation to the Physics Derivation Graph to identify bugs and inefficiencies in the workflow
  • instead of entering a new derivation, new goal is to create tutorials for an existing derivation. [See this 2021-08 post.]
  • before creating tutorials, write a "gold standard" for one derivation (then create tutorials). [See this 2021-07 post and this page.]
  • instead of fixating on a "gold standard," refocus on the original intent of the project: connecting expressions from the breadth of Physics. [See this 2021-08 post and this page.]

Friday, August 20, 2021

refocusing the motivation for the Physics Derivation Graph

The following aspects are "nice-to-have" in the Physics Derivation Graph:

  • validation of derivation steps using computer algebra systems
  • validation of consistency expression dimensions
  • validation of consistency of units when present in expressions
  • visualization of the graph
  • make the code pretty and easy to navigate for contributors
  • document the source code and design decisions
  • searching the graph (see this and this and this)
  • ability to determine whether paper is written by a crackpot
  • ability to detect unintentional errors in an article or book
  • cross-document references
  • semantic tagging of Latex documents
  • converting Latex from arxiv into formats supporting the above objectives
  • linking Physics Derivation Graph to existing ontology databases

The core objective of the Physics Derivation Graph is identifying the mathematical connectivity of the various domains of Physics. The same connectivity should be able to relate "basic" Physics (e.g., F=ma) to advanced Physics (e.g., the theory of the Standard model, string theory). 

I know of two ways to document the connectivity:
  • identify symbol re-use
  • identify inter-related derivations at the level of expressions
The symbol re-use is less interesting than the re-use of expressions. 


I've previously documented a plan,
but I didn't specify what would qualify as sufficient to show completeness. 

What core expressions are representative of all of Physics? Are there a set of expressions that, if shown to be connected by derivations, would be sufficient to demonstrate the span of the concept?

I expect that, for any given subdomain of Physics, there are central expressions. The task list is then
  1. identify every named expression in Physics -- see https://derivationmap.net/central_expessions
  2. identify every variable in that list of named expressions
  3. enter all named expressions and variables into the PDG database
  4. determine which expressions are not connected to anything