Files
logic-skeleton-bench/logicbench/models.py
T

82 lines
1.9 KiB
Python

from __future__ import annotations
from dataclasses import asdict, dataclass
from typing import Any
@dataclass(frozen=True)
class Entity:
id: str
type: str
@dataclass(frozen=True)
class TransitionRule:
id: str
trigger: str
preconditions: tuple[str, ...]
probability: float
effects: tuple[str, ...]
@dataclass(frozen=True)
class HiddenProgram:
types: tuple[str, ...]
relations: tuple[str, ...]
operators: tuple[str, ...]
quantifiers: tuple[str, ...]
structures: tuple[str, ...]
inference_rules: tuple[str, ...]
transition_rules: tuple[TransitionRule, ...]
@dataclass(frozen=True)
class WorldEvent:
id: str
time: int
kind: str
participants: tuple[str, ...]
arguments: dict[str, Any]
@dataclass(frozen=True)
class Query:
predicate: str
arguments: tuple[str, ...]
time: int
@dataclass(frozen=True)
class WorldSkeleton:
id: str
family: str
complexity: int
entity_count: int
simulation_steps: int
hidden_program: HiddenProgram
entities: tuple[Entity, ...]
initial_state: dict[str, Any]
events: tuple[WorldEvent, ...]
final_state: dict[str, Any]
query: Query
answer_options: tuple[str, ...]
gold_answer: str
proof_event_ids: tuple[str, ...]
proof_facts: tuple[str, ...]
generator_checks: dict[str, Any]
def to_dict(self) -> dict[str, Any]:
return asdict(self)
def renderer_payload(self) -> dict[str, Any]:
"""Expose realized history, never the source program, proof, or answer."""
return {
"family": self.family,
"complexity": self.complexity,
"entity_types": {entity.id: entity.type for entity in self.entities},
"initial_observations": self.initial_state["public_observations"],
"events": [asdict(event) for event in self.events],
"query": asdict(self.query),
"answer_options": self.answer_options,
}