Counterfactual reasoning in AGISystem2 uses theory layers to explore "what if" scenarios. A temporary layer holds hypothetical facts that override base knowledge. After reasoning in this altered world, the layer is discarded and reality is restored.

1. Base State Base Knowledge Water IS_A Liquid ASK "Water IS_A ?" → Liquid 2. Push Layer Water IS_A Gas Water IS_A Liquid Hypothetical overrides 3. Reason Water IS_A Gas ✓ (hidden) → Gas 4. Pop Layer Base Knowledge Water IS_A Liquid ASK "Water IS_A ?" → Liquid (restored) Sys2DSL Commands THEORY_PUSH name="what-if" ASSERT Water IS_A Gas ASK "Water IS_A ?" → Gas THEORY_POP ASK "Water IS_A ?" → Liquid

Counterfactual workflow: Push a hypothetical layer, add overriding facts, reason in the altered world, then pop to restore reality. The base knowledge is never modified—only temporarily shadowed by the hypothetical layer.

How It Works

Counterfactuals use the TheoryStack mechanism:

  1. THEORY_PUSH – Create a new layer for hypothetical facts
  2. ASSERT – Add counterfactual facts to the layer (these override base facts)
  3. ASK / reason – Query the system; it sees the hypothetical world
  4. THEORY_POP – Discard the layer; base knowledge is restored

The key insight is that the base knowledge is never modified. The hypothetical layer simply intercepts queries and returns overriding answers.

Use Cases

Use CaseExample
What-if analysis "If water were a gas at room temperature, could fish survive?"
Policy simulation "If the tax rate were 20%, what would be the budget impact?"
Debugging scenarios "If this config value were true, would the bug still occur?"
Alternative history "If Rome had not fallen, what technologies might exist?"
Safe experimentation Test knowledge changes before committing them

CF Syntax Shorthand

For simple counterfactuals, use the CF command:

# Shorthand (push, assert, query, pop in one command)
CF "Water IS_A Gas?" | Water TEMPERATURE_AT Celsius200
# Temporarily assumes Water IS_A Gas and queries implications

# Expanded equivalent
THEORY_PUSH name="cf_temp"
ASSERT Water IS_A Gas
ASSERT Water TEMPERATURE_AT Celsius200
ASK "Can fish survive in Water?"
THEORY_POP

Nested Counterfactuals

Multiple layers can be stacked for nested hypotheticals:

THEORY_PUSH name="layer1"
ASSERT A IS_A B
  THEORY_PUSH name="layer2"
  ASSERT A IS_A C  # Overrides layer1's A IS_A B
  ASK "A IS_A ?"   # → C
  THEORY_POP
ASK "A IS_A ?"     # → B (layer1 still active)
THEORY_POP
ASK "A IS_A ?"     # → (original value)

Related Documentation