// src/lisp/vlm/AtomizationUtils.ts

import type { SExpr } from '../SExpr';

/**
 * Operators that can be parallelized (commutative/associative)
 */
export const PARALLELIZABLE_OPS = ['+', '*', 'and', 'or', 'list', 'parallel'];

/**
 * Check if an expression can be atomized
 */
export function canAtomize(expr: SExpr): boolean {
  if (!Array.isArray(expr) || expr.length < 3) {
    return false;
  }
  const [op] = expr;
  return typeof op === 'string' && PARALLELIZABLE_OPS.includes(op);
}

/**
 * Check if all arguments are atoms (leaves)
 */
export function allArgsAreAtoms(expr: SExpr): boolean {
  if (!Array.isArray(expr)) return true;
  const [, ...args] = expr;
  return args.every(arg => !Array.isArray(arg) || arg[0] === 'quote');
}
