Abstract Trace Summarizer 标志

Abstract Trace Summarizer

社区
ArabelaTso
abstract-trace-summarizer

通过抽象解释生成摘要式执行轨迹和高层次的程序行为表示。使用抽象域(区间、符号、空值状态等)突出显示关键控制流路径、变量关系、循环不变量、函数摘要和潜在运行时状态。适用于分析程序行为、理解执行路径、计算循环不变量、跟踪变量取值范围、检测潜在运行时错误,或在不实际执行程序的情况下生成程序摘要。

Add to TypingMind

概览

发布者ArabelaTso
代码仓库Skills-4-SE
技能名称abstract-trace-summarizer
星标数
258
复刻数
25
附带文件
2
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 2 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 ArabelaTso 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Abstract Trace Summarizer AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/abstract-trace-summarizer
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git /tmp/Skills-4-SE
mkdir -p .claude/skills
cp -r /tmp/Skills-4-SE/skills/abstract-trace-summarizer .claude/skills/abstract-trace-summarizer
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Abstract Trace Summarizer,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Abstract Trace Summarizer。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Abstract Trace Summarizer 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Abstract Trace Summarizer

Overview

This skill performs abstract interpretation to analyze program behavior and produce summarized execution traces. It computes over-approximations of possible runtime states, tracks control flow paths, infers variable relationships, and generates high-level behavioral summaries without requiring concrete program execution.

Core Workflow

1. Program Analysis Setup

Initial Assessment:

  • Identify programming language and paradigm
  • Determine analysis scope (function, module, program)
  • Select appropriate abstract domains
  • Identify analysis goals (safety, correctness, optimization)

Abstract Domain Selection:

Choose domains based on analysis needs:

Numerical domains:

  • Intervals: Track value ranges [min, max]
  • Signs: Track {negative, zero, positive, unknown}
  • Octagons: Linear constraints ±x ±y ≤ c
  • Polyhedra: General linear constraints

Non-numerical domains:

  • Nullness: Track {null, non-null, unknown} for pointers
  • Constant propagation: Track known constant values
  • Type domains: Track possible types
  • Parity: Track {even, odd, unknown}

Relational vs non-relational:

  • Non-relational: Track variables independently (faster, less precise)
  • Relational: Track relationships between variables (slower, more precise)

2. Control Flow Analysis

Build Control Flow Graph (CFG):

Represent program structure:

Entry → Statement₁ → Statement₂ → ... → Exit
         ↓ (branch)
       Statement₃ → ...

Identify key structures:

  • Sequential: Straight-line code
  • Conditional: if-then-else branches
  • Loops: while, for, do-while
  • Function calls: Call/return edges
  • Exception handling: try-catch-finally

Path analysis:

  • Path-sensitive: Track separate states per path (more precise)
  • Path-insensitive: Merge states at join points (more efficient)
  • Trace partitioning: Hybrid approach based on key predicates

3. Abstract State Computation

Transfer Functions:

Model how statements affect abstract states:

Assignment: x = expr

1. Evaluate expr in current abstract state
2. Update abstract state for variable x
3. Propagate to successor states

Conditional: if (condition)

1. Evaluate condition in current abstract state
2. Refine state for true branch (assume condition holds)
3. Refine state for false branch (assume condition doesn't hold)
4. Analyze both branches separately

Loop: while (condition)

1. Compute fixpoint at loop head using widening
2. Analyze loop body with refined state
3. Optionally apply narrowing for precision
4. Extract loop invariant from fixpoint

Function call: y = f(x)

1. Look up or compute function summary
2. Apply preconditions to arguments
3. Update state with postconditions
4. Handle side effects

Lattice Operations:

Join (∪): Merge states from different paths

Example: [1,5] ∪ [3,8] = [1,8]
Use: At control flow merge points

Meet (∩): Refine state with constraints

Example: [1,10] ∩ [5,15] = [5,10]
Use: When adding constraints from conditions

Widening (∇): Accelerate convergence for loops

Example: [0,n] ∇ [0,n+1] = [0,+∞]
Use: At loop heads to ensure termination

Narrowing (△): Refine widened results

Example: [0,+∞] △ [0,100] = [0,100]
Use: After widening to improve precision

4. Variable Relationship Tracking

Data Dependencies:

Track how variables affect each other:

  • Def-use chains: Where variables are defined and used
  • Use-def chains: Which definitions reach each use
  • Dependency graph: Variable dependency relationships

Relational Constraints:

For relational domains, track constraints:

Intervals: x ∈ [0,10], y ∈ [5,15]
Octagons: x - y ≤ 5, x + y ≤ 20
Polyhedra: 2x + 3y ≤ 30, x - y ≥ 0

Equality Tracking:

After x = y: track that x and y have equal values
After x = y + 1: track that x = y + 1

5. Loop Invariant Inference

Fixpoint Computation:

1. Initialize loop head state
2. Analyze loop body
3. Compute join of entry state and back-edge state
4. Apply widening if not converged
5. Repeat until fixpoint reached
6. Optionally apply narrowing

Loop Invariant:

Properties that hold at loop head:

Example: for i in range(n):
  Invariant: 0 ≤ i < n

Loop Bounds:

Estimate iteration counts:

  • Constant bounds: for i in range(10) → 10 iterations
  • Symbolic bounds: for i in range(n) → n iterations
  • Unbounded: while condition → unknown iterations

Loop Effects:

Summarize loop behavior:

  • Which variables are modified
  • How values change per iteration
  • Accumulated effects over all iterations

6. Function Summarization

Compute Function Summaries:

Preconditions: Required input states

Example: def divide(a, b)
  Precondition: b ≠ 0

Postconditions: Guaranteed output states

Example: def abs(x)
  Postcondition: result ≥ 0

Side effects: Modifications to global state

Example: def append(list, item)
  Side effect: list length increases by 1

Frame conditions: What remains unchanged

Example: def get_first(list)
  Frame: list is not modified

Modular Analysis:

Analyze functions separately:

  1. Compute summary for each function
  2. Reuse summaries at call sites
  3. Handle recursion with fixpoint computation

7. Trace Summarization

Generate High-Level Summary:

Execution paths:

Path 1: Entry → L1 → L2 → L5 → Exit
  Condition: x > 0
  Result: returns positive value

Path 2: Entry → L1 → L3 → L4 → Exit
  Condition: x ≤ 0
  Result: returns zero or negative value

Key control flow:

- 3 conditional branches
- 2 loops (nested)
- 5 function calls
- 1 exception handler

Variable states:

Entry: x ∈ ℤ, y ∈ ℤ
Exit: result ∈ [0, +∞]
Invariant: x + y ≤ 100

Potential runtime states:

Normal termination: 85% of paths
Exception thrown: 15% of paths
Infinite loop: Not possible (proven)

Output Format

Structure the abstract trace summary as follows:

markdown
## Program Summary
- **Language**: [Programming language]
- **Scope**: [Function/Module/Program name]
- **Analysis Type**: [Abstract domain(s) used]

## Control Flow Structure
- **Total paths**: [Number of execution paths]
- **Loops**: [Number and nesting depth]
- **Conditionals**: [Number of branches]
- **Function calls**: [Number of calls]

## Abstract States

### Entry State
[Initial abstract state for variables]

### Key Program Points
**Location L1**: [Statement or label]

[Abstract state at this point]


**Location L2**: [Statement or label]

[Abstract state at this point]


### Exit State
[Final abstract state for variables]

## Variable Relationships
[Tracked relationships and constraints between variables]

## Loop Invariants
**Loop at L[X]**:
- **Invariant**: [Properties that hold at loop head]
- **Bound**: [Iteration count estimate]
- **Effect**: [How loop modifies state]

## Function Summaries
**Function [name]**:
- **Precondition**: [Required input conditions]
- **Postcondition**: [Guaranteed output conditions]
- **Side effects**: [Modifications to global state]
- **Complexity**: [Time/space complexity]

## Execution Paths

### Path 1: [Description]
**Condition**: [Path condition]
**Trace**: [Sequence of program points]
**Result**: [Final state or return value]

### Path 2: [Description]
**Condition**: [Path condition]
**Trace**: [Sequence of program points]
**Result**: [Final state or return value]

## Potential Runtime Behaviors
- **Normal termination**: [Conditions and states]
- **Exceptions**: [Possible exceptions and conditions]
- **Non-termination**: [Infinite loops or recursion]
- **Resource usage**: [Memory, time estimates]

## Safety Properties
- **Buffer safety**: [Array bounds checking results]
- **Null safety**: [Null pointer dereference analysis]
- **Type safety**: [Type correctness analysis]
- **Arithmetic safety**: [Overflow/underflow analysis]

## Recommendations
[Suggestions for improving code based on analysis]

Analysis Techniques by Language

Python

  • Type inference: Track possible types for dynamic variables
  • Exception flow: Model try-except-finally blocks
  • List operations: Track list lengths and element types
  • Dictionary operations: Track key-value relationships

Java/C#

  • Null analysis: Track nullness for object references
  • Type hierarchy: Use class hierarchy for precision
  • Exception handling: Model checked and unchecked exceptions
  • Concurrency: Analyze thread interleavings and synchronization

C/C++

  • Pointer analysis: Track points-to relationships
  • Buffer bounds: Analyze array and buffer accesses
  • Memory safety: Detect use-after-free, double-free
  • Undefined behavior: Identify potential UB

JavaScript

  • Type coercion: Model implicit type conversions
  • Prototype chain: Track prototype relationships
  • Async operations: Model promises and callbacks
  • Dynamic properties: Track object property additions

Common Analysis Patterns

Pattern 1: Simple Loop Analysis

python
# Code
for i in range(n):
    sum += arr[i]

# Analysis
Entry: sum = 0, i = ⊤, n ∈ [0,+∞]
Loop head: sum ∈ [0,+∞], i ∈ [0,n-1]
Loop invariant: 0 ≤ i < n, sum ≥ 0
Exit: sum ∈ [0,+∞], i = n

Pattern 2: Conditional Branch Analysis

python
# Code
if x > 0:
    result = x
else:
    result = -x

# Analysis
Entry: x ∈ ℤ
Branch 1 (x > 0): x ∈ [1,+∞], result = x ∈ [1,+∞]
Branch 2 (x ≤ 0): x ∈ [-∞,0], result = -x ∈ [0,+∞]
Join: result ∈ [0,+∞]

Pattern 3: Null Safety Analysis

java
// Code
if (obj != null) {
    return obj.getValue();
}
return -1;

// Analysis
Entry: obj ∈ {null, non-null, ⊤}
Branch 1 (obj != null): obj = non-null, access SAFE
Branch 2 (obj == null): obj = null, no dereference
Result: No null pointer dereference possible

Pattern 4: Array Bounds Analysis

python
# Code
for i in range(len(arr)):
    arr[i] = 0

# Analysis
Entry: arr has length L ∈ [0,+∞]
Loop: i ∈ [0, L-1]
Access: arr[i] where i ∈ [0, L-1] ⊆ [0, L-1]
Result: All accesses are safe

Precision vs Performance Trade-offs

High Precision (Slower)

  • Path-sensitive analysis
  • Relational domains (polyhedra, octagons)
  • Context-sensitive function analysis
  • Narrowing after widening

Use when:

  • Proving critical safety properties
  • Small code regions
  • High assurance requirements

Balanced Precision

  • Trace partitioning
  • Interval domain with some relations
  • Summary-based function analysis
  • Widening without narrowing

Use when:

  • General program analysis
  • Medium-sized programs
  • Balance between precision and cost

High Performance (Less Precise)

  • Path-insensitive analysis
  • Non-relational domains (intervals, signs)
  • Context-insensitive function analysis
  • Aggressive widening

Use when:

  • Large codebases
  • Quick feedback needed
  • Scalability is priority

Important Guidelines

DO:

  • ✅ Select appropriate abstract domains for the analysis goal
  • ✅ Clearly document assumptions and approximations
  • ✅ Explain loop invariants and their significance
  • ✅ Highlight potential safety issues or runtime errors
  • ✅ Provide concrete examples when explaining abstract states
  • ✅ Show both over-approximation and under-approximation when relevant
  • ✅ Explain fixpoint computation for loops
  • ✅ Track variable relationships when using relational domains

DON'T:

  • ❌ Claim absolute certainty (abstract interpretation is approximate)
  • ❌ Ignore infeasible paths without noting them
  • ❌ Use overly complex domains when simpler ones suffice
  • ❌ Forget to apply widening at loop heads (may not terminate)
  • ❌ Present abstract states without explaining their meaning
  • ❌ Ignore language-specific features (exceptions, concurrency)
  • ❌ Overlook function summaries for modular analysis

Resources

references/abstract_interpretation.md

Comprehensive guide to abstract interpretation concepts including abstract domains, lattice operations, transfer functions, control flow analysis, variable relationship tracking, runtime state abstraction, trace summarization techniques, and precision vs performance trade-offs.

references/examples.md

Complete examples of abstract trace summarization for various program patterns including simple loops, conditional branches, nested loops, pointer analysis, exception flow, recursive functions, concurrent programs, array bounds checking, string analysis, and state machines.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Abstract Trace Summarizer AI 技能有什么作用?

通过抽象解释生成摘要式执行轨迹和高层次的程序行为表示。使用抽象域(区间、符号、空值状态等)突出显示关键控制流路径、变量关系、循环不变量、函数摘要和潜在运行时状态。适用于分析程序行为、理解执行路径、计算循环不变量、跟踪变量取值范围、检测潜在运行时错误,或在不实际执行程序的情况下生成程序摘要。

为什么在 TypingMind 中使用 Abstract Trace Summarizer?

因为您只需安装一次,就能搭配任何模型使用。Abstract Trace Summarizer 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Abstract Trace Summarizer?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/abstract-trace-summarizer。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Abstract Trace Summarizer?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Abstract Trace Summarizer 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Abstract Trace Summarizer 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Abstract Trace Summarizer AI 技能免费吗?

是的。ArabelaTso 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇