Skip to content

Report predicate occurrences per signature with role and provenance #2

Description

@GregoryGelfond

Motivation

A language server's definitions, references, rename, and completion; an explainer's "where does this atom come from"; a REPL's introspection. All ask the same question: for a signature, where does it occur and in what role. DependencyGraph already visits every occurrence to build its edges and then discards the positions, so the fact is computed today and not reported.

This is the analysis-level occurrence: per predicate signature, across a whole Program. It is distinct from the per-statement raise occurrences of #1, which it can be built over.

Proposed surface, in themelios-analysis

A pure, total reading of a Program yielding, per Signature, its occurrences in source order. Each occurrence carries the WithProvenance node it was read from and a role drawn from a closed enumeration: head literal; positive body literal; default-negated body literal; condition; aggregate element; and one variant per declaring directive (#show, #external, #defined, #project, #heuristic). The existing DependencyKind distinguishes positive from negative body dependence and should be reused rather than mirrored.

Cost

One walk: O(program) time and space. Owned plain data (Send + Sync + 'static), as everywhere in the tier.

Laws to state

  • Every edge of DependencyGraph is witnessed by a head occurrence and a body occurrence of its two signatures.
  • Equality over the occurrence set is provenance-blind, as everywhere in the tier.
  • A program recovered from a malformed parse yields occurrences for what was raised; never a panic.

Extends

analysis.md §4, beside the dependency graph, whose construction it shares.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions