Representing algebraic expressions is a good place to start, but for the Physics Derivation Graph I care about covering the full scope of Physics - calculus, derivatives, linear algebra, tensors, Dirac notation, Einstein notation, etc. See
https://github.com/allofphysicsgraph/proofofconcept/issues/7
Mathematica has a "tree form" for expressions which yields an Abstract Syntax Tree. I think the AST is incomplete, and would be more accurate as a property tree.
As an example, suppose we want to expand
TreeForm[ (a*x^2)+(b*x)+c=d ]
The nodes are a,b,c,d,x,2,=,+,^,*
The (directed) edges are
- x-->power
- 2-->power
- a-->times
- power-->times
- times-->plus
- b-->times
- x-->times
- times-->plus
- c-->plus
- plus-->equal
- d-->equal
However, this graph representation is incomplete. First, the nodes are not all of the same type:
CREATE ( x:variable )
CREATE ( a:constant )
CREATE ( b:constant )
CREATE ( c:constant )
CREATE ( d:constant )
CREATE ( 2:integer )
CREATE ( =:relation )
CREATE ( ^:operator { name:"power" } )
CREATE ( +:operator { name:"plus" } )
Then edges are created, similar to above
CREATE ( x )-->( power )
CREATE ( 2 )-->( power )
CREATE ( a )-->( times )
...
However, the bulleted list of edges has collisions -- there are two instances of "times-->plus", but they are not supposed to be the same. Thus, the edges require unique IDs to deal with collisions.
Similarly, the nodes in the graph feature collisions. The expression refers to a single "x", but the TreeForm representation has multiple separate "x" nodes.
CREATE ( 5938:variable { symbol:"x" } )
CREATE ( 5782:constant { symbol:"a" } )
CREATE ( 4525:constant { symbol:"b" } )
CREATE ( :constant { symbol:"c" } )
CREATE ( :constant { symbol:"d" } )
CREATE ( :integer { symbol:"2" } )
CREATE ( :relation { symbol:"=" } )
CREATE ( :operator { name:"power", symbol:"^" } )
CREATE ( :operator { name:"plus", symbol:"+" } )
No comments:
Post a Comment