Skip to content

Abstract semantic graph

A graph representation of a formal expression or program whose nodes denote terms or semantic entities and whose shared nodes can represent common subexpressions beyond an abstract syntax tree.

Core Idea

ASGs or term graphs compact repeated structure, support common-subexpression elimination and graph rewriting, and may use directed acyclic structure for sharing or cycles for recursive definitions under explicit binding and mutation rules. Parsing and semantic analysis map occurrences to typed nodes, identical or equivalent subterms can share a node, directed edges encode argument or dependency roles, and graph rewrites transform the representation while preserving declared meaning. The abstraction is therefore identified by a declared carrier, a transformation or constraint over that carrier, and an invariant that tells an analyst whether the named structure is genuinely present.

How would you explain it like I'm…

Write It Once, Point Twice

Imagine a recipe that says 'mix flour and sugar' in two different places. Instead of writing that step twice, you write it once and draw two arrows pointing to it. An abstract semantic graph is a computer's picture of a program that shares repeated pieces like that, so it stays small and means the same thing.

Program Diagram With Sharing

When a computer reads a program, it builds a diagram of what the program means, with boxes for each piece and arrows showing which pieces feed into which. In an abstract semantic graph, if the same piece shows up more than once, the computer can keep just one box and point to it from every place that uses it. That saves space and lets the computer notice it doesn't have to calculate the same thing twice. Sometimes arrows even loop back around, which is how the diagram shows something defined in terms of itself. The computer can reshape the diagram to improve the program, as long as the meaning stays the same.

Shared-Node Program Graph

An abstract semantic graph (ASG), also called a term graph, is a representation of a program built during parsing and semantic analysis. Each piece of the program becomes a typed node, and directed edges connect a node to its arguments or dependencies. Unlike a tree, where every repeated piece gets its own copy, an ASG lets identical or equivalent subexpressions share a single node. That sharing supports common-subexpression elimination - computing a repeated expression once - and graph rewriting, where the graph is transformed while its meaning is preserved. The graph may be acyclic, using sharing only, or may contain cycles to represent recursive definitions, provided the rules for names and changes are spelled out.

 

An abstract semantic graph, or term graph, is a compiler representation in which parsing and semantic analysis map occurrences in source code to typed nodes, directed edges encode argument or dependency roles, and identical or equivalent subterms may share one node. Sharing compacts repeated structure and directly supports common-subexpression elimination and graph rewriting, where rewrites transform the graph while preserving its declared meaning. The graph can be a directed acyclic graph when only sharing is needed, or can include cycles to represent recursive definitions, but then binding and mutation rules must be explicit. This distinguishes it from an abstract syntax tree, which duplicates every occurrence and has no cycles. A precise use of the idea states the source language, the node and edge types, the term and binding semantics, the criterion for sharing, whether cycles are allowed, whether sharing means identity or mere equality, typing, the mapping back to source locations, the rewrite and mutation rules, and what semantic-preservation claim is being made.

Scope of Application

Abstract semantic graph belongs to compiler intermediate representations and is useful where the analyst can specify the typed compiler intermediate representations carrier, defining objects and relations, parameters, conventions, evidence, boundary cases, and comparison targets, then evaluate the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim are explicit. The scope is broad within that domain but bounded by the need for the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim are explicit.

Clarity

The abstraction clarifies a crowded vocabulary by making the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim are explicit the center of the account. A claim should name the carrier, the governing operation or relation, the applicable assumptions, and the recognition test.

Manages Complexity

Without the abstraction, an analyst must reason directly over many local details: the carrier roles, admissibility assumptions, competing conventions, derived invariants, boundary cases, and proof or validation obligations specific to Abstract semantic graph. Abstract semantic graph compresses them into the roles in the structural signature. That compression permits comparison across instances without erasing the variables that determine validity. It also exposes which details may be varied safely and which are constitutive.

Abstract Reasoning

  1. Identify the carrier. State what the elements, states, objects, or observations are: the typed compiler intermediate representations carrier, defining objects and relations, parameters, conventions, evidence, boundary cases, and comparison targets. Reject examples whose alleged carrier belongs to a different problem.
  2. Lock the constitutive rule. Express the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim are explicit independently of one notation or implementation.

Knowledge Transfer

Knowledge transfers strongly among subfields of compiler intermediate representations because they reuse the typed compiler intermediate representations carrier, defining objects and relations, parameters, conventions, evidence, boundary cases, and comparison targets, Parsing and semantic analysis map occurrences to typed nodes, identical or equivalent subterms can share a node, directed edges encode argument or dependency roles, and graph rewrites transform the representation while preserving declared meaning., and type the carrier, state every parameter and convention in the definition, test that the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim are explicit, compare the nearest accepted identity, and report counterexamples, uncertainty, and limiting cases.

Relationships to Other Abstractions

Local relationship map for Abstract semantic graphParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Abstractsemantic graphDOMAINPrime abstraction: Symbolic Representation — is a kind ofSymbolicRepresentationPRIME

Current abstraction Abstract semantic graph Domain-specific

Parents (1) — outgoing typed relations

  • Abstract semantic graph is a kind of Symbolic Representation Prime

    It remains its own entry because its identity is fixed by the source language, graph node and edge types, term and binding semantics, sharing criterion, acyclic or cyclic allowance, identity versus equality, typing, source-location mapping, mutation and rewrite rules, serialization, and semantic-preservation claim.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Abstract semantic graph sits in a crowded region of the domain-specific corpus (9th percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.

Family — Graph Theory Structures & Invariants (48 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-10-25