Abstract Domain Explorer logo

Abstract Domain Explorer

Community
ArabelaTso
abstract-domain-explorer

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

Overview

PublisherArabelaTso
RepositorySkills-4-SE
Skill nameabstract-domain-explorer
Stars
258
Forks
25
Bundled files
2
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ArabelaTso on GitHub. Read the source before you install it.

Installation

Install the Abstract Domain Explorer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/abstract-domain-explorer
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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-domain-explorer .claude/skills/abstract-domain-explorer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Abstract Domain Explorer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Abstract Domain Explorer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Abstract Domain Explorer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Abstract Domain Explorer

Overview

This skill applies abstract interpretation to statically analyze programs using various abstract domains. It infers invariants, value ranges, and relationships between variables without executing the code. Different domains offer different trade-offs between precision and efficiency.

Analysis Workflow

Follow these steps to analyze programs with abstract domains:

1. Select Appropriate Domain(s)

Choose based on analysis goals:

Interval Domain:

  • Use for: Range analysis, bounds checking, array indexing
  • Precision: Low to medium
  • Cost: Very efficient
  • Example: Determine if x ∈ [0, 100]

Sign Domain:

  • Use for: Sign analysis, division by zero detection
  • Precision: Low
  • Cost: Very efficient
  • Example: Determine if x is positive, negative, or zero

Congruence Domain:

  • Use for: Modular arithmetic, alignment analysis
  • Precision: Medium (for specific patterns)
  • Cost: Efficient
  • Example: Determine if x ≡ 0 (mod 4)

Octagon Domain:

  • Use for: Relational analysis, loop invariants with simple relationships
  • Precision: Medium to high
  • Cost: Moderate (O(n³) operations)
  • Example: Infer x ≤ y + 5, x + y ≤ 10

Polyhedra Domain:

  • Use for: Complex linear relationships, precise invariants
  • Precision: High
  • Cost: Expensive (exponential worst-case)
  • Example: Infer 2x + 3y ≤ z + 10

Reduced Product:

  • Use for: Combining strengths of multiple domains
  • Precision: Higher than individual domains
  • Cost: Sum of component costs
  • Example: Intervals × Congruence for precise range with modular constraints

2. Initialize Abstract State

Set initial values for program entry:

  • Constants: Exact values (e.g., x = 5 → x ∈ [5, 5])
  • Inputs: Top element (e.g., user input → x ∈ [-∞, +∞])
  • Uninitialized: Bottom element (unreachable)

Example:

c
int x = 0;        // x ∈ [0, 0]
int y = input();  // y ∈ [-∞, +∞]

3. Apply Transfer Functions

For each statement, compute abstract semantics:

Assignment (x = e):

  • Evaluate expression e in abstract domain
  • Update abstract state for x

Condition (assume c):

  • Refine abstract state based on condition
  • Intersect with constraint

Join (control flow merge):

  • Compute least upper bound of incoming states
  • Used after if-else, at loop headers

Example (Intervals):

c
x = y + 5;        // If y ∈ [a, b], then x ∈ [a+5, b+5]
assume(x > 10);   // If x ∈ [a, b], then x ∈ [max(a, 11), b]

4. Handle Loops with Widening

For loops, apply widening to ensure termination:

  1. Compute first iteration
  2. Compute second iteration
  3. Apply widening operator (∇)
  4. Check for convergence
  5. Continue until fixpoint reached

Example:

c
int x = 0;
while (x < 100) {
    x = x + 1;
}
  • Iteration 0: x ∈ [0, 0]
  • Iteration 1: x ∈ [0, 1]
  • Widening: x ∈ [0, +∞]
  • Refine with condition: x ∈ [0, 99] in loop
  • Exit: x ∈ [100, 100]

5. Refine with Narrowing (Optional)

Apply narrowing to improve precision:

  • Iterate a few more times (typically 1-3)
  • Use narrowing operator (△)
  • Refine over-approximations from widening

6. Extract Invariants

Identify inferred properties:

  • Value ranges for each variable
  • Relationships between variables
  • Loop invariants
  • Preconditions for safe operations

Report format:

  • Variable: abstract value
  • Invariants: logical formulas
  • Safety properties: bounds checks, division by zero, etc.

Analysis Examples

Example 1: Range Analysis with Intervals

Code:

c
int x = 0;
int y = 100;
while (x < 10) {
    x = x + 1;
    y = y - 1;
}
// What are the values of x and y here?

Analysis (Interval Domain):

  • Entry: x ∈ [0, 0], y ∈ [100, 100]
  • Loop iterations with widening:
    • Iter 0: x ∈ [0, 0], y ∈ [100, 100]
    • Iter 1: x ∈ [0, 1], y ∈ [99, 100]
    • Widening: x ∈ [0, +∞], y ∈ [-∞, 100]
    • Refine with x < 10: x ∈ [0, 9], y ∈ [-∞, 100]
  • Narrowing: y ∈ [91, 100]
  • Exit: x ∈ [10, 10], y ∈ [90, 90]

Inferred Invariants:

  • Loop: x ∈ [0, 9], y ∈ [91, 100]
  • Exit: x = 10, y = 90
  • Implicit: x + y = 100 (not captured by intervals alone)

Example 2: Relational Analysis with Octagons

Code:

c
int x = 0;
int y = 0;
while (x < 10) {
    x = x + 1;
    y = y + 1;
}

Analysis (Octagon Domain):

  • Entry: x = 0, y = 0, x - y = 0
  • Loop iterations:
    • Maintains x - y = 0 throughout
    • x ∈ [0, 10], y ∈ [0, 10]
  • Exit: x = 10, y = 10, x = y

Inferred Invariants:

  • x = y (captured by octagon)
  • x ∈ [0, 10], y ∈ [0, 10]

Advantage over Intervals: Intervals would only infer x ∈ [0, 10], y ∈ [0, 10] but miss the relationship x = y.

Example 3: Linear Relationships with Polyhedra

Code:

c
int x = 0, y = 0, z = 0;
while (x < 10) {
    x = x + 1;
    y = y + 2;
    z = x + y;
}

Analysis (Polyhedra Domain):

  • Entry: x = 0, y = 0, z = 0
  • Loop iterations:
    • Infers: y = 2x, z = x + y, z = 3x
    • x ∈ [0, 10]
  • Exit: x = 10, y = 20, z = 30

Inferred Invariants:

  • y = 2x
  • z = x + y
  • z = 3x
  • x ∈ [0, 10]

Advantage over Octagons: Polyhedra can express y = 2x, which octagons cannot.

Example 4: Modular Arithmetic with Congruence

Code:

c
int sum = 0;
for (int i = 0; i < 100; i++) {
    sum = sum + 3;
}

Analysis (Congruence Domain):

  • Entry: sum ≡ 0 (mod 3), i ≡ 0 (mod 1)
  • Loop: sum ≡ 0 (mod 3) maintained
  • Exit: sum ≡ 0 (mod 3)

Analysis (Interval Domain):

  • Exit: sum ∈ [0, 300]

Combined (Reduced Product):

  • sum ∈ [0, 300] and sum ≡ 0 (mod 3)
  • Refined: sum ∈ {0, 3, 6, 9, ..., 297, 300}
  • Exact: sum = 300

Inferred Invariants:

  • sum is always divisible by 3
  • sum ∈ [0, 300]

Example 5: Division by Zero Detection with Sign

Code:

c
int x = read_input();
int y = x * x;
int z = 100 / y;  // Safe?

Analysis (Sign Domain):

  • x: ⊤ (unknown sign)
  • y = x * x: ≥0 (non-negative)
  • Problem: y could be 0 if x = 0
  • Division 100 / y: potential division by zero

Analysis (Interval Domain):

  • x: [-∞, +∞]
  • y: [0, +∞]
  • Problem: 0 ∈ [0, +∞]
  • Division 100 / y: potential division by zero

Inferred Property:

  • Unsafe: Division by zero possible when x = 0

Example 6: Array Bounds Checking

Code:

c
int arr[10];
int i = 0;
while (i < 10) {
    arr[i] = 0;  // Safe?
    i = i + 1;
}

Analysis (Interval Domain):

  • Loop: i ∈ [0, 9]
  • Array access: arr[i] where i ∈ [0, 9]
  • Array bounds: [0, 9]
  • Safe: i always within bounds

Inferred Property:

  • No array bounds violation

Example 7: Nested Loops with Octagons

Code:

c
int i = 0, j = 0;
while (i < 10) {
    j = 0;
    while (j < i) {
        j = j + 1;
    }
    i = i + 1;
}

Analysis (Octagon Domain):

  • Outer loop: i ∈ [0, 10]
  • Inner loop: j ∈ [0, i], j ≤ i
  • Exit: i = 10, j = 9, j ≤ i

Inferred Invariants:

  • j ≤ i (relational invariant)
  • i ∈ [0, 10]
  • j ∈ [0, 9]

Domain Comparison

DomainPrecisionCostRelationshipsBest For
SignVery LowO(1)NoneSign errors, division by zero
IntervalLow-MediumO(1)NoneRange analysis, bounds checking
CongruenceMediumO(1)NoneModular patterns, alignment
OctagonMedium-HighO(n³)±x ± y ≤ cSimple relational invariants
PolyhedraHighExponentialLinearComplex linear relationships
Reduced ProductHigherSum of componentsCombinedPrecise analysis with multiple aspects

Choosing the Right Domain

Start with Intervals if:

  • You need range information
  • Efficiency is critical
  • No relationships needed

Use Octagons if:

  • You need simple relationships (x ≤ y + c)
  • Loop invariants involve variable pairs
  • Moderate cost acceptable

Use Polyhedra if:

  • Complex linear relationships needed
  • Precision is critical
  • Small programs or specific code sections
  • Cost is acceptable

Use Reduced Products if:

  • Multiple aspects needed (range + modular)
  • Willing to pay combined cost
  • Need precision from multiple domains

Use Sign if:

  • Only sign information needed
  • Very large programs
  • Quick analysis required

Use Congruence if:

  • Modular arithmetic patterns
  • Alignment analysis
  • Complement to intervals

Constraints

MUST:

  • Select appropriate domain(s) for analysis goals
  • Apply transfer functions correctly
  • Use widening for loops to ensure termination
  • Report inferred invariants clearly
  • Indicate precision limitations of chosen domain

MUST NOT:

  • Claim exact values when domain gives approximations
  • Ignore widening (may not terminate)
  • Use expensive domains unnecessarily
  • Report unsound results

Resources

references/abstract_domains.md

Comprehensive reference covering:

  • Abstract interpretation fundamentals
  • Detailed domain specifications (intervals, octagons, polyhedra, sign, congruence)
  • Domain operations and transfer functions
  • Widening and narrowing techniques
  • Reduced product domains
  • Fixpoint computation
  • Complete analysis examples

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Abstract Domain Explorer AI skill do?

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

Why use Abstract Domain Explorer on TypingMind?

Because you install it once and use it with any model. Abstract Domain Explorer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Abstract Domain Explorer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/abstract-domain-explorer. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Abstract Domain Explorer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Abstract Domain Explorer?

As many as you like. As long as a model supports skills, you can use Abstract Domain Explorer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Abstract Domain Explorer AI skill free?

Yes. It is published on GitHub by ArabelaTso under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇