From 9ab592ce3765d07b6dbdb9c1d9b62dc8045e784e Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Fri, 3 Apr 2026 02:46:12 +0800 Subject: feat: implement core term, symbol, and clause storage logic with canonicalization support --- include/atp/core/term.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'include/atp/core/term.h') diff --git a/include/atp/core/term.h b/include/atp/core/term.h index e1edfcf..017882a 100644 --- a/include/atp/core/term.h +++ b/include/atp/core/term.h @@ -16,28 +16,30 @@ * along with this program. If not, see . */ - #pragma once /// @file term.h /// @brief Core Term data structure — hash-consed, immutable. +/// +/// V1 uses vector for args. +/// Future: flat arena with contiguous arg storage for cache locality. -#include +#include #include "atp/core/types.h" namespace atp { /// A term is a function/predicate application: f(t1, t2, ..., tn). -/// Stored in a flat arena; args are contiguous TermIds following the header. -/// Variables are represented as terms with a special symbol range. +/// Variables are 0-arity terms whose symbol has SymbolKind::kVariable. struct Term { - SymbolId symbol_id; ///< Index into the SymbolTable - uint16_t arity; ///< Number of arguments + SymbolId symbol_id; ///< Index into the SymbolTable + std::vector args; ///< Argument sub-term IDs - /// Access the argument TermIds (stored immediately after this struct in the arena). - [[nodiscard]] std::span args() const; - [[nodiscard]] std::span mutableArgs(); + /// Number of arguments. + [[nodiscard]] uint16_t arity() const { + return static_cast(args.size()); + } }; } // namespace atp -- cgit v1.2.3