4.1 Investigation Language and Algebra
Editorial context, 2026-04-20: The questions, constraints, proposals, disagreements, and caveats below are reformulated from the saved research discussion. LLM recommendations remain attributed proposals, not decisions by the author or independently verified findings. Technical examples and quoted source passages retain their original wording.
Initial question: Could investigation be represented as abstract computation on a machine and connected to more fundamental theory without excessive abstraction? Would a DSL provide a useful way to enter this domain?
TODO: Clarify the original XXX marker; no further text is recorded here.
The working interpretation is that there’s a useful level of theory here, and it sits somewhere between “workflow builder” and “formal calculus.”
The proposal is to model it as an abstract machine for investigations.
The machine has state:
MachineState {
corpus
representations
intermediate_results
claims
evidence
lineage
authority_policy
coverage_state
work_queue
}and a relatively small instruction set:
search
filter
map
expand
extract
join
group
compare
rank
reduce
branch
iterate
assert
abstainThen an investigation is a program executed by that machine.
For example:
corpus
| search(query)
| expand(parent=section)
| extract(claims)
| filter(authority >= normative)
| find_conflicts
| synthesizeThat gives you a DSL almost immediately.
The key is that the DSL should describe the investigation, while the runtime decides how to execute it.
For example:
search(query)might compile internally to:
dense_search
|| lexical_search
|| hypothetical_question_search
|| claim_search
→ union
→ rerankSo the user works at one abstraction level, while an expert can open the block and inspect or modify the lower-level plan.
There are several pieces of existing theory that fit without becoming academic decoration.
First, relational algebra.
A surprising amount of research work is:
select
project
join
group
filter
aggregateEvidence retrieval fits this naturally.
Example:
principles
| join(practices, on=topic)
| filter(conflicts)Matrix is basically one projection of this relational computation.
Second, dataflow systems.
The proposed operators naturally form a DAG:
┌ search A ─┐
query → split ─┼ search B ─┼→ merge → evidence → synthesis
└ search C ─┘This gives you scheduling, parallelism, caching and incremental recomputation almost for free conceptually.
If one source changes, you don’t recompute the entire investigation.
source changed
↓
invalidate dependent nodes
↓
recompute affected branchThis makes the system feel somewhat like make, Bazel, spreadsheets or reactive programming.
The product might be closer to a build system for knowledge than to a chatbot.
Third, fixed-point computation.
Investigations frequently contain loops:
retrieve
→ learn vocabulary
→ reformulate
→ retrieve again
→ discover another distinction
→ retrieve againYou need some condition that says when the loop has converged.
For example:
repeat {
evidence = search(query)
gaps = identify_gaps(evidence)
query = reframe(query, gaps)
}
until no_new_evidence
or all_requirements_satisfied
or budget_exhaustedThis is essentially fixed-point evaluation.
Datalog and database recursion have decades of theory around this exact kind of problem. The recommendation is not to expose Datalog to users, but the semantics are useful.
Fourth, provenance algebra.
This one may be particularly valuable for the proposed product.
Suppose:
Claim Cexists because:
Evidence A AND Evidence Bwhile another claim is supported by:
Evidence C OR Evidence DYou want provenance itself to survive composition.
So instead of a result being just:
"value"it is closer to:
Result<T> {
value: T
lineage: ...
}Every operator combines lineage according to explicit rules.
For example:
A ─┐
├─ join → X
B ─┘means X carries dependency on both A and B.
While:
A ─┐
├─ union → X
B ─┘means X may have alternative provenance paths.
Database provenance research formalizes this with provenance semirings. You probably don’t need to expose that term in the product, but the underlying idea is almost exactly what you need.
It lets you answer:
Why is this claim here?
Which source would need to disappear for this conclusion to stop being supported?
Does this conclusion depend entirely on one low-authority document?
Those are much deeper provenance queries than simple citations.
Fifth, types.
The working interpretation is that the DSL should be strongly typed.
Not:
block → block → blockwhere everything is arbitrary JSON.
More like:
search:
Query × Corpus → EvidenceSet
extract_claims:
EvidenceSet → ClaimSet
find_conflicts:
ClaimSet → ConflictSet
synthesize:
EvidenceSet → FindingThen the editor itself can tell the user what can legally connect.
And you can introduce semantic types:
PrimaryEvidence
NormativeSource
Claim
Contradiction
CoverageReport
AuthorityPolicyThat matters because:
synthesize(EvidenceSet)is different from:
synthesize(VerifiedEvidenceSet)You could even make constraints part of the type system.
For example:
evidence
| require(primary_sources)
| require(corpus_coverage >= .99)
| require(no_unresolved_conflicts)
| synthesizeThe output becomes something like:
Finding<
coverage=complete,
authority=verified,
conflicts=resolved
>That’s effectively a lightweight proof system.
The recommendation is not to go too far into theorem proving. But this gives you a clean way of expressing the initial requirement:
An answer is only valid if certain evidence conditions were satisfied.
That’s stronger than adding a confidence score.
A proposed theoretical stack is:
User DSL
↓
typed investigation program
↓
logical execution graph
↓
optimizer / planner
↓
physical operators
↓
LLMs + indexes + toolsVery much like a database:
SQL
↓
logical query plan
↓
query optimizer
↓
physical plan
↓
indexes / joins / scansThat analogy may be more useful than OLAP.
The proposed DSL becomes to investigation what SQL is to relational data: a description of what result you want and some constraints on how it should be established.
The runtime can decide whether a search means vector retrieval, corpus-wide LLM screening, hypothetical-question matching, BM25, or a combination.
A simple DSL could look like:
from corpus("architecture")
let principles =
search("governing principles for retries")
| authority(type="normative")
let practices =
search("current retry practices")
let conflicts =
compare(principles, practices)
| contradictions()
return synthesize(conflicts)
require coverage >= 0.99
require citations
abstain if unsupportedThen power users could descend a level:
search "retry principles" {
parallel {
dense(top=50)
lexical(top=50)
hypothetical_questions(top=50)
}
union
expand parent_section
rerank(top=30)
}That gives you a very nice property:
the visual editor and the DSL are two representations of the same program.
A domain expert manipulates blocks:
[Corpus] → [Search] → [Authority] → [Compare] → [Synthesize]An engineer sees:
corpus
| search(...)
| authority(...)
| compare(...)
| synthesizeAn agent manipulates the underlying AST/graph.
All three are editing the same thing.
The proposal is to resist going much further into lambda calculus, category theory, tensor algebra, etc. They can provide elegant descriptions, but they probably won’t improve the product architecture much.
The theories considered useful here are:
- relational algebra for manipulating sets of evidence;
- dataflow graphs for execution;
- fixed-point semantics for iterative investigation;
- provenance algebra for lineage;
- type/effect systems for epistemic constraints;
- query optimization for choosing efficient execution strategies.
Together, these suggest a tentative model of an investigation language + runtime, with Matrix, graph, report, evidence ledger, and other UIs as views over programs and their execution state.
And there is a deeper product idea hiding in this: the reusable artifact may eventually be the investigation program itself, not the answer.
Someone could publish:
"Architecture proposal review"as a reusable program containing:
find governing principles
→ locate previous decisions
→ inspect relevant incidents
→ find contradictions
→ identify missing evidence
→ produce reviewThen humans and agents run that program repeatedly over new questions and new corpora.
That starts to look like an actual domain-specific computing environment rather than another research UI.
A proposed place for new theory
The proposal is to not start by inventing a new database model.
The novel layer is above the DBMS:
relational algebra
+
investigation algebra
+
provenance semantics
+
epistemic effectsMaybe:
Find<Q, C> Corpus → CandidateSet
Screen<R> Corpus → ScreeningResult
Extract<E> CandidateSet → EvidenceSet
Support Evidence × Claim → Relation
Contradict Evidence × Claim → Relation
Resolve<A> Evidence × AuthorityPolicy → Evidence
Synthesize EvidenceSet → Finding
VerifyCoverage Run → CoverageCertificateAnd each operator has semantics.
For example:
Find[best_effort]and:
Find[complete]have different contracts.
The compiler knows:
Find[complete]
requires a plan whose
corpus participation = completewhile:
Find[best_effort]can compile into top-k retrieval.
This is where the new research could live.
The recommendation is not to call it “field theory,” because mathematically a field has a very specific meaning and we don’t seem to need that structure.
Algebra, calculus, query language, or computational model are more accurate.
Perhaps:
investigation algebra
would be the least presumptuous working name.
A proposed departure from Rubicon
Rubicon deliberately pushes toward relations:
everything
↓
logical tables
↓
relational optimizerThat makes sense for its target.
The recommendation is not to force all of our semantics into flat tables.
The proposal is to distinguish:
Logical values
Set<T>
Relation<A,B>
Tree<T>
Graph<N,E>
Stream<T>
Scalar<T>while still allowing the physical implementation to live in relational storage.
For example:
DocumentTreehas semantic operations:
parent
children
ancestors
descendants
siblingsA claim graph has:
supports
contradicts
depends_on
supersedesThe compiler can lower those to joins/recursive SQL.
That’s exactly what compilers do:
high-level semantics
↓
lower-level representationWe shouldn’t let the capabilities of Postgres dictate the semantics of the language.
Library sources
- Mokhov et al. 2020, Build Systems a la Carte: Theory and Practice: section 2, “Background”, analyses the systems the dataflow passage compares itself to,
make, Excel and Bazel (static versus dynamic dependencies, minimality, early cutoff, cloud caching); “invalidate dependent nodes, recompute affected branch” is the rebuilding of section 5, “Rebuilders”, from a dirty bit (5.1) to verifying traces; a query reformulated from retrieved evidence is a dynamic dependency, section 3.5, “Monadic Tasks”; section 8.5, “Iterative Computations”, treats bounded fixed-point rebuilding (LaTeX, Excel’s iterative calculation); on the “Second, dataflow systems” and “Third, fixed-point computation” passages.