---
title: 'LogiCity: Urban Simulation in NeSy AI'
url: https://www.emergentmind.com/topics/logicity
type: topic
---

# LogiCity: Urban Simulation in NeSy AI

LogiCity is a configurable simulation platform designed for advancing research in Neuro-Symbolic (NeSy) AI through abstract urban environments governed by first-order logic (FOL). It addresses critical limitations of prior NeSy benchmarks by enabling long-horizon, multi-agent, and perception-in-the-loop reasoning tasks with user-configurable logical abstractions over dynamic agent populations. LogiCity explicitly decouples logical rule specification from concrete entities, supporting compositional generalization and the scalable evaluation of NeSy methods under urban reasoning challenges [2411.00773].

## 1. System Architecture and Simulation Pipeline

LogiCity models urban environments via a layered architecture:

- **Static Semantic Grid:** $M_s \in \{0,1\}^{W \times H \times B}$ encodes $B$ base categories (streets, sidewalks, intersections, buildings).
- **Agents:** Global agent set $\mathcal{A} = \{A_1, ..., A_N\}$, each annotated with type (e.g., Car, Pedestrian, Ambulance), demographic attributes (IsOld, IsYoung), right-of-way priority $p \in \mathbb{R}$, and dynamic state (position, heading, goal).
- **Global Pathing:** For each start/goal sample, agents compute collision-free trajectories: A* (pedestrian trajectories) or Dijkstra (vehicle/road network).
- **Dynamic Semantic Map:** $M^t \in \{0,1\}^{W \times H \times (B + N)}$ overlays per-agent heatmaps.
- **Local Observation & Grounding:** Each agent $A_n$ receives a cropped percept $M^t_n$ and filtered agent list $\mathcal{A}^t_n$. Grounding functions $\{\mathcal{G}_i\}$ parse these to a grounding vector $g^t_n \in \{0,1\}^D$ ($D$ grows with predicate/agent arity).
- **Logical Inference:** A Z3 SAT/SMT solver instantiates $M$ FOL rules $\mathcal{C}$ over $g^t_n$, computing truth values for action predicates {Slow, Normal, Fast, Stop}, yielding $a^n_t \in \{0,1\}^4$.
- **State Update and Rendering:** Agents execute actions and update states; GPT-4-generated semantic icons are fused into $M^t$ for RGB frame output $I^t$.

This simulation loop produces rich, multi-modal traces for both symbolic and neuro-perceptual evaluation settings [2411.00773].

## 2. First-Order Logic Abstractions

LogiCity's core innovation is its decoupled, customizable FOL abstraction:

- **Predicates:** Arbitrary set $\mathcal{P} = \{P_i\}$, comprising unary “semantic” (e.g., IsAmbulance(X), IsPedestrian(X), IsYoung(X)) and binary “spatial/relational” predicates (e.g., IsClose(X, Y), HigherPri(X, Y), CollidingClose(X, Y)), with formally specified arity and boolean outputs.
- **Clause Syntax:** Each FOL clause $C_m$ takes the form 
  $$\text{Head}(X) :- Q_1(u_1), \ldots, Q_L(u_L)$$
  Example: $\text{Stop}(X) :- \text{IsClose}(X, Y) \land \text{IsAmbulance}(Y)$ corresponds to $\forall X \forall Y (\text{IsClose}(X, Y) \land \text{IsAmbulance}(Y) \implies \text{Stop}(X))$.
- **Compositional Generalization:** Rules are defined on abstract variables ($X, Y, Z$), not fixed agent sets. Predicate and clause libraries are reusable across instantiations (“cities”) with varying agent rosters $\mathcal{A}$, ensuring logical structures remain invariant under different entity permutations.

This yields a benchmark setting for robust evaluation of rule-based, neural, and hybrid approaches on compositional abstraction tasks [2411.00773].

## 3. User-Configurable Abstraction Space

LogiCity exposes several axes of expressivity control:

- **Predicate Count ($K$) and Rule Count ($M$):** Directly affect the grounding vector size and logical inference (SMT) complexity, scaling up combinatorial reasoning challenges.
- **Rule Depth and Breadth:** Users can specify literal count per body (rule depth) and the maximal multi-entity (arity) interactions (breadth).
- **Predicate Types:** Selection of semantic, spatial, or both predicate classes; toggling these shifts the balance between perception and logical complexity.

Example configurations include:
- *Easy SPF mode:* 7 unary + 2 binary predicates, $M=3$ “Stop” rules.
- *Medium/Hard:* Increased predicate vocabulary, more complex constraints. 
- *Expert mode:* 12 mixed clauses, governing all four action predicates (Slow/Normal/Fast/Stop), with nested negation and multi-agent relationships [2411.00773].

## 4. Task Definitions: Safe Path Following and Visual Action Prediction

LogiCity specifies two central benchmarks:

### 4.1 Safe Path Following (SPF)
- **Formulation:** Partially-observable Markov decision process (POMDP) with state $s^t = \{M^t, \mathcal{A}\}$, action set $\mathcal{A} = \{\text{Slow}, \text{Normal}, \text{Fast}, \text{Stop}\}$, and observation $o^t = g^t_1$ for the controlled agent.
- **Reward:** 
  $$
  R(s^t, a^t) = \sum_{m=1}^M w_m^r \psi(s^t, a^t, C_m) + w^a \phi(a^t) + w^o(t)
  $$
  where $\psi$ penalizes rule violations, $\phi$ is action cost, and $w^o$ penalizes overtime.
- **Objective:** Maximize expected cumulative reward over $\geq$40-step horizons.

### 4.2 Visual Action Prediction (VAP)
- **Task:** From RGB observation $I^t$ and agent metadata $H$, predict actions $\{\hat{a}_n\}$ for all agents.
- **Pipeline:** ResNet50+FPN encoder yields regional features; ROIAlign computes unary predicate scores, pairwise concatenation evaluates binary predicates to construct a scene graph; graph reasoning (GNN or NLM) produces agent action logits.
- **Supervision:** Supports modular (predicate/action) and end-to-end (action-only) learning [2411.00773].

## 5. Scenario and City Generation

Multiple urban “cities” are procedurally instantiated:

- Agent compositions $\mathcal{A}$ and start/goal samples are randomized across runs.
- The constant rule/predicate definitions mean each city's instantiation shifts only the grounding, not the logical structure—facilitating systematic evaluation of compositional generalization.
- Example: One city may instantiate 2 ambulances + 3 pedestrians; another, 1 police + 2 tiro + 4 cars, but both use identical logical tables [2411.00773].

## 6. Experimental Results and Benchmarks

### 6.1 Safe Path Following (SPF)
- **Baselines:** Include symbolic learners (Popper, MaxSynth, HRI), neural (GNN, MLP, NLM), and RL variants (DQN, A2C, PPO, DreamerV2, NLM-DQN).
- **Metrics:** Trajectory Success Rate (TSR), Decision Success Rate (DSR), normalized return.
- **Findings:**
  - Easy: Symbolic rule learners achieve TSR $\approx 1.0$.
  - Medium/Hard: NLM and NLM-DQN surpass pure neural (GNN, MLP), indicating superior abstraction learning.
  - Compositional shift: Transfer to new agent mixes halves DQN’s TSR but reduces NLM-DQN’s only by $\sim$20%.
  - Continual: NLM recovers expert-mode with 30% of new-rule data vs. 100% for MLP [2411.00773].

### 6.2 Visual Action Prediction (VAP)
- **Metrics:** Per-action recall, average accuracy (aAcc), weighted accuracy (wAcc).
- **Findings:**
  - End-to-end GNN/NLM reach aAcc $\approx0.85$ (Easy); modular variants drop to 0.60 due to perceptual noise.
  - Hard mode: modular NLM yields wAcc $\approx0.36$ (vs. GNN 0.28), evidencing more robust logical generalization.
  - Perceptual noise: unary predicate recall 55%, binary 89%, emphasizing the challenge for vision-only systems [2411.00773].

### 6.3 LLM and Human Benchmarking
- In-context LLMs (GPT-4o/GPT-4/GPT-3.5) evaluated on VAP: GPT-4o reaches 59% accuracy, below human performance (81%), especially on hard “Stop” rules, indicating the gap remaining for in-context symbolic generalization [2411.00773].

## 7. Implications, Challenges, and Research Frontiers

LogiCity provides a scalable, FOL-driven urban simulation supporting complex, abstract NeSy reasoning tasks, high-dimensional vision, and multi-agent planning. Benchmark results reveal NLMs and related NeSy frameworks excel in abstraction and continual learning, but face significant limitations under combinatorial and perceptual complexity.

**Key open challenges:**
- Inducing compact, conflict-free rule sets in combinatorial spaces.
- Integrating noisy perception (sub-60% unary predicate recall) with reliable logical inference.
- Extending beyond FOL to temporal logics (e.g., LTL), fuzzy SMT, and differentiable reasoning.
- Leveraging real-world urban/traffic data for rule auto-generation and sim-to-real transfer.

**Future directions:**
- Bi-level planners learning abstract actions atop grounded sub-policies.
- LLM-assisted rule induction, with symbolic verifiers.
- Cross-domain transfer of abstractions to platforms such as CARLA, SCENIC, and PDDL-based planners [2411.00773].

LogiCity, as a fully open-source platform, establishes itself as a pivotal resource for evaluating and advancing the state-of-the-art in Neuro-Symbolic AI with a focus on real-world-relevant complexity.

Source: https://www.emergentmind.com/topics/logicity