HAIDOX
HAIDOX Help

Math Engine Reference: Cas

개요

제한된 exact CAS와 명시적 수치 fallback을 제공하는 caller-owned C ABI.

Symbolic 변환은 정수·유리수와 pointer-free expression tree만 사용한다. 지원하지 않는 변환은 입력을 보존한 UNEVALUATED/UNSUPPORTED 결과이며 근삿값 성공으로 바뀌지 않는다. 모든 parse, rewrite, condition과 quadrature storage는 caller가 제공한다.

공개 API

Header 사용 시작

이 module의 public declaration을 사용하려면 installed SDK의 다음 header를 include한다.

#include <math_engine/math_engine_cas.h>

Type과 callback

math_engine_cas_profile_t

Full은 bounded cubic을, embedded exact는 작은 degree-2 subset만 허용한다.

typedef enum math_engine_cas_profile {
    MATH_ENGINE_CAS_PROFILE_INVALID = 0, /**< 유효한 실행 profile이 아닌 zero/sentinel 값이다. */
    MATH_ENGINE_CAS_PROFILE_EMBEDDED_EXACT = 1, /**< Heap 없는 degree-2 exact subset과 작은 ceiling을 선택한다. */
    MATH_ENGINE_CAS_PROFILE_FULL = 2 /**< Degree 3까지의 bounded exact 규칙과 큰 ceiling을 선택한다. */
} math_engine_cas_profile_t;
  • math_engine_cas_profile_t.MATH_ENGINE_CAS_PROFILE_INVALID

    유효한 실행 profile이 아닌 zero/sentinel 값이다.

    MATH_ENGINE_CAS_PROFILE_INVALID = 0,
    
  • math_engine_cas_profile_t.MATH_ENGINE_CAS_PROFILE_EMBEDDED_EXACT

    Heap 없는 degree-2 exact subset과 작은 ceiling을 선택한다.

    MATH_ENGINE_CAS_PROFILE_EMBEDDED_EXACT = 1,
    
  • math_engine_cas_profile_t.MATH_ENGINE_CAS_PROFILE_FULL

    Degree 3까지의 bounded exact 규칙과 큰 ceiling을 선택한다.

    MATH_ENGINE_CAS_PROFILE_FULL = 2,
    

math_engine_cas_operation_t

Bounded symbolic transform 종류다.

typedef enum math_engine_cas_operation {
    MATH_ENGINE_CAS_OPERATION_INVALID = 0, /**< 연산이 지정되지 않은 sentinel이다. */
    MATH_ENGINE_CAS_OPERATION_SIMPLIFY = 1, /**< 입력 표현식을 domain-safe canonical exact 형식으로 단순화한다. */
    MATH_ENGINE_CAS_OPERATION_DIFFERENTIATE = 2, /**< 지정 symbol에 대한 exact 일차 도함수를 만든다. */
    MATH_ENGINE_CAS_OPERATION_INTEGRATE = 3, /**< 지원되는 규칙 범위에서 지정 symbol의 부정적분을 만든다. */
    MATH_ENGINE_CAS_OPERATION_SOLVE_POLYNOMIAL = 4 /**< 지정 symbol의 bounded degree 다항식 근을 exact 형식으로 푼다. */
} math_engine_cas_operation_t;
  • math_engine_cas_operation_t.MATH_ENGINE_CAS_OPERATION_INVALID

    연산이 지정되지 않은 sentinel이다.

    MATH_ENGINE_CAS_OPERATION_INVALID = 0,
    
  • math_engine_cas_operation_t.MATH_ENGINE_CAS_OPERATION_SIMPLIFY

    입력 표현식을 domain-safe canonical exact 형식으로 단순화한다.

    MATH_ENGINE_CAS_OPERATION_SIMPLIFY = 1,
    
  • math_engine_cas_operation_t.MATH_ENGINE_CAS_OPERATION_DIFFERENTIATE

    지정 symbol에 대한 exact 일차 도함수를 만든다.

    MATH_ENGINE_CAS_OPERATION_DIFFERENTIATE = 2,
    
  • math_engine_cas_operation_t.MATH_ENGINE_CAS_OPERATION_INTEGRATE

    지원되는 규칙 범위에서 지정 symbol의 부정적분을 만든다.

    MATH_ENGINE_CAS_OPERATION_INTEGRATE = 3,
    
  • math_engine_cas_operation_t.MATH_ENGINE_CAS_OPERATION_SOLVE_POLYNOMIAL

    지정 symbol의 bounded degree 다항식 근을 exact 형식으로 푼다.

    MATH_ENGINE_CAS_OPERATION_SOLVE_POLYNOMIAL = 4,
    

math_engine_cas_result_kind_t

의미론적 종료 상태다. APPROXIMATE만 비정확 수치 답을 포함할 수 있다.

typedef enum math_engine_cas_result_kind {
    MATH_ENGINE_CAS_RESULT_INVALID = 0, /**< 초기화됐지만 terminal 결과가 없는 sentinel이다. */
    MATH_ENGINE_CAS_RESULT_EXACT = 1, /**< 조건 없는 exact symbolic 결과다. */
    MATH_ENGINE_CAS_RESULT_CONDITIONAL = 2, /**< 별도 condition text를 만족할 때 exact인 결과다. */
    MATH_ENGINE_CAS_RESULT_APPROXIMATE = 3, /**< 명시적 수치 fallback에서만 생성되는 오차 포함 결과다. */
    MATH_ENGINE_CAS_RESULT_UNEVALUATED = 4, /**< 안전한 지원 규칙이 없어 canonical 입력 표현식을 보존했다. */
    MATH_ENGINE_CAS_RESULT_UNSUPPORTED = 5, /**< 요청 연산 또는 표현식 계층이 profile 범위 밖이다. */
    MATH_ENGINE_CAS_RESULT_BUDGET_EXHAUSTED = 6 /**< 결정적 node/rewrite/depth ceiling에서 중단됐다. */
} math_engine_cas_result_kind_t;
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_INVALID

    초기화됐지만 terminal 결과가 없는 sentinel이다.

    MATH_ENGINE_CAS_RESULT_INVALID = 0,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_EXACT

    조건 없는 exact symbolic 결과다.

    MATH_ENGINE_CAS_RESULT_EXACT = 1,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_CONDITIONAL

    별도 condition text를 만족할 때 exact인 결과다.

    MATH_ENGINE_CAS_RESULT_CONDITIONAL = 2,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_APPROXIMATE

    명시적 수치 fallback에서만 생성되는 오차 포함 결과다.

    MATH_ENGINE_CAS_RESULT_APPROXIMATE = 3,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_UNEVALUATED

    안전한 지원 규칙이 없어 canonical 입력 표현식을 보존했다.

    MATH_ENGINE_CAS_RESULT_UNEVALUATED = 4,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_UNSUPPORTED

    요청 연산 또는 표현식 계층이 profile 범위 밖이다.

    MATH_ENGINE_CAS_RESULT_UNSUPPORTED = 5,
    
  • math_engine_cas_result_kind_t.MATH_ENGINE_CAS_RESULT_BUDGET_EXHAUSTED

    결정적 node/rewrite/depth ceiling에서 중단됐다.

    MATH_ENGINE_CAS_RESULT_BUDGET_EXHAUSTED = 6,
    

math_engine_cas_node_kind_t

Caller가 storage를 할당하므로 append-only로 유지하는 scratch node 종류다.

typedef enum math_engine_cas_node_kind {
    MATH_ENGINE_CAS_NODE_INVALID = 0, /**< 할당되지 않은 scratch node sentinel이다. */
    MATH_ENGINE_CAS_NODE_RATIONAL = 1, /**< =rational=만 의미가 있는 exact 상수 leaf다. */
    MATH_ENGINE_CAS_NODE_SYMBOL = 2, /**< =name[0..name_size)=에 저장된 symbol leaf다. */
    MATH_ENGINE_CAS_NODE_NEGATE = 3, /**< =left= 하나를 피연산자로 갖는 unary negation이다. */
    MATH_ENGINE_CAS_NODE_ADD = 4, /**< =left=와 =right=의 canonical binary sum이다. */
    MATH_ENGINE_CAS_NODE_MULTIPLY = 5, /**< =left=와 =right=의 canonical binary product다. */
    MATH_ENGINE_CAS_NODE_DIVIDE = 6, /**< =left/right=이며 분모 nonzero condition을 가질 수 있다. */
    MATH_ENGINE_CAS_NODE_POWER = 7, /**< =left= base와 =right= exponent의 exact power다. */
    MATH_ENGINE_CAS_NODE_CALL = 8 /**< =name= 함수와 =first_child/next_sibling= argument chain이다. */
} math_engine_cas_node_kind_t;
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_INVALID

    할당되지 않은 scratch node sentinel이다.

    MATH_ENGINE_CAS_NODE_INVALID = 0,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_RATIONAL

    rational 만 의미가 있는 exact 상수 leaf다.

    MATH_ENGINE_CAS_NODE_RATIONAL = 1,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_SYMBOL

    name[0..name_size) 에 저장된 symbol leaf다.

    MATH_ENGINE_CAS_NODE_SYMBOL = 2,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_NEGATE

    left 하나를 피연산자로 갖는 unary negation이다.

    MATH_ENGINE_CAS_NODE_NEGATE = 3,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_ADD

    left 와 right 의 canonical binary sum이다.

    MATH_ENGINE_CAS_NODE_ADD = 4,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_MULTIPLY

    left 와 right 의 canonical binary product다.

    MATH_ENGINE_CAS_NODE_MULTIPLY = 5,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_DIVIDE

    left/right 이며 분모 nonzero condition을 가질 수 있다.

    MATH_ENGINE_CAS_NODE_DIVIDE = 6,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_POWER

    left base와 right exponent의 exact power다.

    MATH_ENGINE_CAS_NODE_POWER = 7,
    
  • math_engine_cas_node_kind_t.MATH_ENGINE_CAS_NODE_CALL

    name 함수와 first_child/next_sibling argument chain이다.

    MATH_ENGINE_CAS_NODE_CALL = 8,
    

math_engine_cas_condition_kind_t

Real-domain 변환에 부착하거나 assumption으로 해소할 수 있는 조건 종류다.

typedef enum math_engine_cas_condition_kind {
    MATH_ENGINE_CAS_CONDITION_INVALID = 0, /**< 유효한 조건이 아닌 sentinel이다. */
    MATH_ENGINE_CAS_CONDITION_NONZERO = 1, /**< 대상 expression 값이 0이 아니어야 한다. */
    MATH_ENGINE_CAS_CONDITION_POSITIVE = 2, /**< 대상 real expression 값이 0보다 커야 한다. */
    MATH_ENGINE_CAS_CONDITION_NONNEGATIVE = 3, /**< 대상 real expression 값이 0 이상이어야 한다. */
    MATH_ENGINE_CAS_CONDITION_REAL = 4 /**< 대상 expression이 실수 domain에 속해야 한다. */
} math_engine_cas_condition_kind_t;
  • math_engine_cas_condition_kind_t.MATH_ENGINE_CAS_CONDITION_INVALID

    유효한 조건이 아닌 sentinel이다.

    MATH_ENGINE_CAS_CONDITION_INVALID = 0,
    
  • math_engine_cas_condition_kind_t.MATH_ENGINE_CAS_CONDITION_NONZERO

    대상 expression 값이 0이 아니어야 한다.

    MATH_ENGINE_CAS_CONDITION_NONZERO = 1,
    
  • math_engine_cas_condition_kind_t.MATH_ENGINE_CAS_CONDITION_POSITIVE

    대상 real expression 값이 0보다 커야 한다.

    MATH_ENGINE_CAS_CONDITION_POSITIVE = 2,
    
  • math_engine_cas_condition_kind_t.MATH_ENGINE_CAS_CONDITION_NONNEGATIVE

    대상 real expression 값이 0 이상이어야 한다.

    MATH_ENGINE_CAS_CONDITION_NONNEGATIVE = 3,
    
  • math_engine_cas_condition_kind_t.MATH_ENGINE_CAS_CONDITION_REAL

    대상 expression이 실수 domain에 속해야 한다.

    MATH_ENGINE_CAS_CONDITION_REAL = 4,
    

math_engine_cas_approximation_operation_t

명시적으로 수치 fallback을 요청할 때 선택하는 연산 종류다.

typedef enum math_engine_cas_approximation_operation {
    MATH_ENGINE_CAS_APPROXIMATION_INVALID = 0, /**< 수치 연산이 지정되지 않은 sentinel이다. */
    MATH_ENGINE_CAS_APPROXIMATION_VALUE = 1, /**< =argument=에서 표현식 값을 계산한다. */
    MATH_ENGINE_CAS_APPROXIMATION_DERIVATIVE = 2, /**< =argument=에서 수치 일차 미분을 계산한다. */
    MATH_ENGINE_CAS_APPROXIMATION_INTEGRAL = 3, /**< =[lower_bound,upper_bound]= 정적분을 계산한다. */
    MATH_ENGINE_CAS_APPROXIMATION_ROOT = 4 /**< bracket 안에서 =argument=를 초기 추정으로 근을 찾는다. */
} math_engine_cas_approximation_operation_t;
  • math_engine_cas_approximation_operation_t.MATH_ENGINE_CAS_APPROXIMATION_INVALID

    수치 연산이 지정되지 않은 sentinel이다.

    MATH_ENGINE_CAS_APPROXIMATION_INVALID = 0,
    
  • math_engine_cas_approximation_operation_t.MATH_ENGINE_CAS_APPROXIMATION_VALUE

    argument 에서 표현식 값을 계산한다.

    MATH_ENGINE_CAS_APPROXIMATION_VALUE = 1,
    
  • math_engine_cas_approximation_operation_t.MATH_ENGINE_CAS_APPROXIMATION_DERIVATIVE

    argument 에서 수치 일차 미분을 계산한다.

    MATH_ENGINE_CAS_APPROXIMATION_DERIVATIVE = 2,
    
  • math_engine_cas_approximation_operation_t.MATH_ENGINE_CAS_APPROXIMATION_INTEGRAL

    [lower_bound,upper_bound] 정적분을 계산한다.

    MATH_ENGINE_CAS_APPROXIMATION_INTEGRAL = 3,
    
  • math_engine_cas_approximation_operation_t.MATH_ENGINE_CAS_APPROXIMATION_ROOT

    bracket 안에서 argument 를 초기 추정으로 근을 찾는다.

    MATH_ENGINE_CAS_APPROXIMATION_ROOT = 4,
    

math_engine_cas_rational_t

정규화된 exact rational이다. 분모는 양수이고 0은 0/1로 저장한다.

typedef struct math_engine_cas_rational {
    uint32_t struct_size; /**< ABI 검증용 byte 크기이며 =sizeof(math_engine_cas_rational_t)=여야 한다. */
    uint32_t struct_version; /**< =MATH_ENGINE_CAS_RATIONAL_VERSION_1=이어야 한다. */
    int64_t numerator; /**< 기약분수의 signed 분자이며 0은 반드시 0/1로 표현한다. */
    int64_t denominator; /**< 기약분수의 strictly-positive 분모이며 0은 유효하지 않다. */
} math_engine_cas_rational_t;
  • math_engine_cas_rational_t.struct_size

    ABI 검증용 byte 크기이며 sizeof(math_engine_cas_rational_t) 여야 한다.

    uint32_t struct_size;
    
  • math_engine_cas_rational_t.struct_version

    MATH_ENGINE_CAS_RATIONAL_VERSION_1 이어야 한다.

    uint32_t struct_version;
    
  • math_engine_cas_rational_t.numerator

    기약분수의 signed 분자이며 0은 반드시 0/1로 표현한다.

    int64_t numerator;
    
  • math_engine_cas_rational_t.denominator

    기약분수의 strictly-positive 분모이며 0은 유효하지 않다.

    int64_t denominator;
    

math_engine_cas_node_t

Caller-owned symbolic scratch node다. Index는 현재 workspace node 배열만 가리킨다. 내용은 다음 CAS 호출에서 재사용될 수 있고 library가 보관하지 않는다.

typedef struct math_engine_cas_node {
    uint32_t struct_size; /**< ABI byte 크기이며 library가 scratch node 생성 시 =sizeof=로 기록한다. */
    uint32_t struct_version; /**< 생성된 node에는 =MATH_ENGINE_CAS_NODE_VERSION_1=이 기록된다. */
    uint32_t kind; /**< =math_engine_cas_node_kind_t= 값으로 활성 payload와 edge 의미를 고른다. */
    uint32_t flags; /**< V1에서는 정의된 bit가 없어 생성 시 0이며 reader는 다른 값을 거부한다. */
    uint32_t left; /**< Unary/binary node의 첫 operand index, 없으면 =MATH_ENGINE_CAS_INDEX_NONE=. */
    uint32_t right; /**< Binary node의 둘째 operand index, 없으면 =MATH_ENGINE_CAS_INDEX_NONE=. */
    uint32_t first_child; /**< CALL의 첫 argument node index, 없으면 =MATH_ENGINE_CAS_INDEX_NONE=. */
    uint32_t next_sibling; /**< CALL argument chain의 다음 node index, 없으면 =MATH_ENGINE_CAS_INDEX_NONE=. */
    uint32_t name_size; /**< =name=의 ASCII payload byte 수이며 0 또는 1..31이다. */
    uint32_t reserved32; /**< ABI 확장용이다. 생성자는 0을 쓰고 consumer는 읽지 않아야 한다. */
    char name[MATH_ENGINE_CAS_NAME_CAPACITY]; /**< Node가 소유하는 32-byte 이름 배열; payload 뒤 byte는 0이다. */
    math_engine_cas_rational_t rational; /**< RATIONAL node가 소유하는 normalized exact 값; 다른 kind에서는 무시한다. */
    math_engine_expression_span_t source_span; /**< 원본 UTF-8의 반열린 byte span; 합성 node는 zero span일 수 있다. */
    uint64_t fingerprint; /**< Kind, 활성 payload와 자식 fingerprint에서 얻은 결정적 non-pointer hash다. */
    uint64_t reserved[2]; /**< ABI 확장용 2개 word이며 생성자는 0을 쓰고 reader는 무시한다. */
} math_engine_cas_node_t;
  • math_engine_cas_node_t.struct_size

    ABI byte 크기이며 library가 scratch node 생성 시 sizeof 로 기록한다.

    uint32_t struct_size;
    
  • math_engine_cas_node_t.struct_version

    생성된 node에는 MATH_ENGINE_CAS_NODE_VERSION_1 이 기록된다.

    uint32_t struct_version;
    
  • math_engine_cas_node_t.kind

    math_engine_cas_node_kind_t 값으로 활성 payload와 edge 의미를 고른다.

    uint32_t kind;
    
  • math_engine_cas_node_t.flags

    V1에서는 정의된 bit가 없어 생성 시 0이며 reader는 다른 값을 거부한다.

    uint32_t flags;
    
  • math_engine_cas_node_t.left

    Unary/binary node의 첫 operand index, 없으면 MATH_ENGINE_CAS_INDEX_NONE.

    uint32_t left;
    
  • math_engine_cas_node_t.right

    Binary node의 둘째 operand index, 없으면 MATH_ENGINE_CAS_INDEX_NONE.

    uint32_t right;
    
  • math_engine_cas_node_t.first_child

    CALL의 첫 argument node index, 없으면 MATH_ENGINE_CAS_INDEX_NONE.

    uint32_t first_child;
    
  • math_engine_cas_node_t.next_sibling

    CALL argument chain의 다음 node index, 없으면 MATH_ENGINE_CAS_INDEX_NONE.

    uint32_t next_sibling;
    
  • math_engine_cas_node_t.name_size

    name 의 ASCII payload byte 수이며 0 또는 1..31이다.

    uint32_t name_size;
    
  • math_engine_cas_node_t.reserved32

    ABI 확장용이다. 생성자는 0을 쓰고 consumer는 읽지 않아야 한다.

    uint32_t reserved32;
    
  • math_engine_cas_node_t.name

    Node가 소유하는 32-byte 이름 배열; payload 뒤 byte는 0이다.

    char name[MATH_ENGINE_CAS_NAME_CAPACITY];
    
  • math_engine_cas_node_t.rational

    RATIONAL node가 소유하는 normalized exact 값; 다른 kind에서는 무시한다.

    math_engine_cas_rational_t rational;
    
  • math_engine_cas_node_t.source_span

    원본 UTF-8의 반열린 byte span; 합성 node는 zero span일 수 있다.

    math_engine_expression_span_t source_span;
    
  • math_engine_cas_node_t.fingerprint

    Kind, 활성 payload와 자식 fingerprint에서 얻은 결정적 non-pointer hash다.

    uint64_t fingerprint;
    
  • math_engine_cas_node_t.reserved

    ABI 확장용 2개 word이며 생성자는 0을 쓰고 reader는 무시한다.

    uint64_t reserved[2];
    

math_engine_cas_condition_t

Workspace node에 대한 명시적 domain/branch 조건 하나다.

typedef struct math_engine_cas_condition {
    uint32_t struct_size; /**< ABI byte 크기이며 =sizeof(math_engine_cas_condition_t)=다. */
    uint32_t struct_version; /**< =MATH_ENGINE_CAS_CONDITION_VERSION_1=이다. */
    uint32_t kind; /**< 적용할 =math_engine_cas_condition_kind_t= 값이다. */
    uint32_t expression_node; /**< 같은 workspace =cas_nodes[0..output_node_count)=의 대상 index다. */
    uint32_t discharged_by_assumption; /**< 일치 assumption이 해소했으면 1, output에 남으면 0이다. */
    uint32_t reserved32; /**< ABI 확장용이며 0으로 기록되고 reader는 무시한다. */
    uint64_t condition_fingerprint; /**< 조건 kind와 대상 node fingerprint의 결정적 hash다. */
    uint64_t reserved[2]; /**< ABI 확장용 2개 word이며 0으로 기록되고 reader는 무시한다. */
} math_engine_cas_condition_t;
  • math_engine_cas_condition_t.struct_size

    ABI byte 크기이며 sizeof(math_engine_cas_condition_t) 다.

    uint32_t struct_size;
    
  • math_engine_cas_condition_t.struct_version

    MATH_ENGINE_CAS_CONDITION_VERSION_1 이다.

    uint32_t struct_version;
    
  • math_engine_cas_condition_t.kind

    적용할 math_engine_cas_condition_kind_t 값이다.

    uint32_t kind;
    
  • math_engine_cas_condition_t.expression_node

    같은 workspace cas_nodes[0..output_node_count) 의 대상 index다.

    uint32_t expression_node;
    
  • math_engine_cas_condition_t.discharged_by_assumption

    일치 assumption이 해소했으면 1, output에 남으면 0이다.

    uint32_t discharged_by_assumption;
    
  • math_engine_cas_condition_t.reserved32

    ABI 확장용이며 0으로 기록되고 reader는 무시한다.

    uint32_t reserved32;
    
  • math_engine_cas_condition_t.condition_fingerprint

    조건 kind와 대상 node fingerprint의 결정적 hash다.

    uint64_t condition_fingerprint;
    
  • math_engine_cas_condition_t.reserved

    ABI 확장용 2개 word이며 0으로 기록되고 reader는 무시한다.

    uint64_t reserved[2];
    

math_engine_cas_assumption_t

Bounded real-domain 규칙이 받아들이는 단순 symbol assumption이다.

typedef struct math_engine_cas_assumption {
    uint32_t struct_size; /**< Caller가 =sizeof(math_engine_cas_assumption_t)=로 설정한다. */
    uint32_t struct_version; /**< Caller가 =MATH_ENGINE_CAS_ASSUMPTION_VERSION_1=로 설정한다. */
    uint32_t kind; /**< NONZERO..REAL 범위의 symbol condition kind다. */
    uint32_t name_size; /**< =name=의 ASCII byte 수이며 1..31이다. */
    char name[MATH_ENGINE_CAS_NAME_CAPACITY]; /**< Record가 소유하는 NUL-terminated fixed buffer다. */
    uint64_t assumption_fingerprint; /**< Kind와 정확한 =name_size= bytes의 결정적 hash다. */
    uint64_t reserved[2]; /**< Caller는 0으로 두며 V1 validation이 nonzero를 거부한다. */
} math_engine_cas_assumption_t;
  • math_engine_cas_assumption_t.struct_size

    Caller가 sizeof(math_engine_cas_assumption_t) 로 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_assumption_t.struct_version

    Caller가 MATH_ENGINE_CAS_ASSUMPTION_VERSION_1 로 설정한다.

    uint32_t struct_version;
    
  • math_engine_cas_assumption_t.kind

    NONZERO..REAL 범위의 symbol condition kind다.

    uint32_t kind;
    
  • math_engine_cas_assumption_t.name_size

    name 의 ASCII byte 수이며 1..31이다.

    uint32_t name_size;
    
  • math_engine_cas_assumption_t.name

    Record가 소유하는 NUL-terminated fixed buffer다.

    char name[MATH_ENGINE_CAS_NAME_CAPACITY];
    
  • math_engine_cas_assumption_t.assumption_fingerprint

    Kind와 정확한 name_size bytes의 결정적 hash다.

    uint64_t assumption_fingerprint;
    
  • math_engine_cas_assumption_t.reserved

    Caller는 0으로 두며 V1 validation이 nonzero를 거부한다.

    uint64_t reserved[2];
    

math_engine_cas_options_t

Deterministic growth, recursion, rewrite와 polynomial ceiling이다.

typedef struct math_engine_cas_options {
    uint32_t struct_size; /**< Caller가 정확한 option record byte 크기로 설정한다. */
    uint32_t struct_version; /**< =MATH_ENGINE_CAS_OPTIONS_VERSION_1=이어야 한다. */
    uint32_t profile; /**< Ceiling과 기능 subset을 고르는 =math_engine_cas_profile_t= 값이다. */
    uint32_t flags; /**< V1에는 option bit가 없으므로 반드시 0이다. */
    uint32_t maximum_tokens; /**< Parser가 만들 수 있는 token 수의 nonzero 상한이다. */
    uint32_t maximum_expression_nodes; /**< Parser AST node 수의 nonzero 상한이다. */
    uint32_t maximum_cas_nodes; /**< Append-only CAS scratch node 수의 nonzero 상한이다. */
    uint32_t maximum_conditions; /**< 생성하고 출력할 domain/branch condition 수의 nonzero 상한이다. */
    uint32_t maximum_rewrite_steps; /**< 결정적 rewrite 방문/변환 횟수의 nonzero 상한이다. */
    uint32_t maximum_depth; /**< Parse/translate/rewrite/render recursion depth의 nonzero 상한이다. */
    uint32_t maximum_polynomial_degree; /**< Solve가 받는 degree 상한; embedded는 1..2, full은 1..3이다. */
    uint32_t reserved32; /**< ABI 확장용이며 caller는 0으로 두고 library는 무시한다. */
    uint64_t reserved[2]; /**< Caller가 0으로 두어야 하는 ABI 확장 word 두 개다. */
} math_engine_cas_options_t;
  • math_engine_cas_options_t.struct_size

    Caller가 정확한 option record byte 크기로 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_options_t.struct_version

    MATH_ENGINE_CAS_OPTIONS_VERSION_1 이어야 한다.

    uint32_t struct_version;
    
  • math_engine_cas_options_t.profile

    Ceiling과 기능 subset을 고르는 math_engine_cas_profile_t 값이다.

    uint32_t profile;
    
  • math_engine_cas_options_t.flags

    V1에는 option bit가 없으므로 반드시 0이다.

    uint32_t flags;
    
  • math_engine_cas_options_t.maximum_tokens

    Parser가 만들 수 있는 token 수의 nonzero 상한이다.

    uint32_t maximum_tokens;
    
  • math_engine_cas_options_t.maximum_expression_nodes

    Parser AST node 수의 nonzero 상한이다.

    uint32_t maximum_expression_nodes;
    
  • math_engine_cas_options_t.maximum_cas_nodes

    Append-only CAS scratch node 수의 nonzero 상한이다.

    uint32_t maximum_cas_nodes;
    
  • math_engine_cas_options_t.maximum_conditions

    생성하고 출력할 domain/branch condition 수의 nonzero 상한이다.

    uint32_t maximum_conditions;
    
  • math_engine_cas_options_t.maximum_rewrite_steps

    결정적 rewrite 방문/변환 횟수의 nonzero 상한이다.

    uint32_t maximum_rewrite_steps;
    
  • math_engine_cas_options_t.maximum_depth

    Parse/translate/rewrite/render recursion depth의 nonzero 상한이다.

    uint32_t maximum_depth;
    
  • math_engine_cas_options_t.maximum_polynomial_degree

    Solve가 받는 degree 상한; embedded는 1..2, full은 1..3이다.

    uint32_t maximum_polynomial_degree;
    
  • math_engine_cas_options_t.reserved32

    ABI 확장용이며 caller는 0으로 두고 library는 무시한다.

    uint32_t reserved32;
    
  • math_engine_cas_options_t.reserved

    Caller가 0으로 두어야 하는 ABI 확장 word 두 개다.

    uint64_t reserved[2];
    

math_engine_cas_workspace_t

Parse, rewrite와 numeric quadrature가 쓰는 모든 variable-size caller storage다.

typedef struct math_engine_cas_workspace {
    uint32_t struct_size; /**< Caller가 =sizeof(math_engine_cas_workspace_t)=로 설정한다. */
    uint32_t struct_version; /**< =MATH_ENGINE_CAS_WORKSPACE_VERSION_1=이어야 한다. */
    math_engine_expression_token_t* tokens; /**< Caller-owned mutable token 배열; NULL은 =token_capacity==0=일 때만 허용되고 호출 동안 독점 유효하다. */
    uint64_t token_capacity; /**< =tokens=의 element capacity이며 transform에서는 =options.maximum_tokens= 이상이다. */
    math_engine_expression_node_t* expression_nodes; /**< Caller-owned mutable AST 배열; NULL은 capacity 0일 때만 허용되고 호출 동안 유지한다. */
    uint64_t expression_node_capacity; /**< =expression_nodes= element 수이며 =maximum_expression_nodes= 이상이다. */
    math_engine_expression_diagnostic_t* diagnostics; /**< Caller-owned parse diagnostic scratch; NULL은 capacity 0일 때만 허용되고 반환 후 내용은 진단용이다. */
    uint64_t diagnostic_capacity; /**< =diagnostics= element capacity; parser가 필요한 범위만 쓴다. */
    math_engine_cas_node_t* cas_nodes; /**< Caller-owned append-only symbolic node scratch; NULL은 capacity 0일 때만 허용되고 다음 CAS 호출에서 재사용된다. */
    uint64_t cas_node_capacity; /**< =cas_nodes= element capacity이며 =maximum_cas_nodes= 이상이다. */
    uint32_t* indices; /**< Caller-owned sorting/traversal index scratch; NULL은 capacity 0일 때만 허용되고 호출 밖 값은 지정되지 않는다. */
    uint64_t index_capacity; /**< =indices=의 uint32 element capacity이며 =maximum_cas_nodes= 이상이다. */
    math_engine_cas_condition_t* conditions; /**< Caller-owned condition scratch; NULL은 capacity 0일 때만 허용되고 결과의 =condition_count=개가 유효하다. */
    uint64_t condition_capacity; /**< =conditions= element capacity이며 =maximum_conditions= 이상이다. */
    math_engine_quadrature_interval_f64_t* quadrature; /**< Caller-owned numerical-integration scratch; NULL은 capacity 0일 때만 허용되며 INTEGRAL fallback 동안 유지한다. */
    uint64_t quadrature_capacity; /**< =quadrature= element capacity; approximation integral은 최소 2를 요구한다. */
    uint64_t reserved[2]; /**< Caller가 0으로 두어야 하고 V1 validation이 nonzero를 거부한다. */
} math_engine_cas_workspace_t;
  • math_engine_cas_workspace_t.struct_size

    Caller가 sizeof(math_engine_cas_workspace_t) 로 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_workspace_t.struct_version

    MATH_ENGINE_CAS_WORKSPACE_VERSION_1 이어야 한다.

    uint32_t struct_version;
    
  • math_engine_cas_workspace_t.tokens

    Caller-owned mutable token 배열; NULL은 =token_capacity==0=일 때만 허용되고 호출 동안 독점 유효하다.

    math_engine_expression_token_t* tokens;
    
  • math_engine_cas_workspace_t.token_capacity

    tokens 의 element capacity이며 transform에서는 options.maximum_tokens 이상이다.

    uint64_t token_capacity;
    
  • math_engine_cas_workspace_t.expression_nodes

    Caller-owned mutable AST 배열; NULL은 capacity 0일 때만 허용되고 호출 동안 유지한다.

    math_engine_expression_node_t* expression_nodes;
    
  • math_engine_cas_workspace_t.expression_node_capacity

    expression_nodes element 수이며 maximum_expression_nodes 이상이다.

    uint64_t expression_node_capacity;
    
  • math_engine_cas_workspace_t.diagnostics

    Caller-owned parse diagnostic scratch; NULL은 capacity 0일 때만 허용되고 반환 후 내용은 진단용이다.

    math_engine_expression_diagnostic_t* diagnostics;
    
  • math_engine_cas_workspace_t.diagnostic_capacity

    diagnostics element capacity; parser가 필요한 범위만 쓴다.

    uint64_t diagnostic_capacity;
    
  • math_engine_cas_workspace_t.cas_nodes

    Caller-owned append-only symbolic node scratch; NULL은 capacity 0일 때만 허용되고 다음 CAS 호출에서 재사용된다.

    math_engine_cas_node_t* cas_nodes;
    
  • math_engine_cas_workspace_t.cas_node_capacity

    cas_nodes element capacity이며 maximum_cas_nodes 이상이다.

    uint64_t cas_node_capacity;
    
  • math_engine_cas_workspace_t.indices

    Caller-owned sorting/traversal index scratch; NULL은 capacity 0일 때만 허용되고 호출 밖 값은 지정되지 않는다.

    uint32_t* indices;
    
  • math_engine_cas_workspace_t.index_capacity

    indices 의 uint32 element capacity이며 maximum_cas_nodes 이상이다.

    uint64_t index_capacity;
    
  • math_engine_cas_workspace_t.conditions

    Caller-owned condition scratch; NULL은 capacity 0일 때만 허용되고 결과의 condition_count 개가 유효하다.

    math_engine_cas_condition_t* conditions;
    
  • math_engine_cas_workspace_t.condition_capacity

    conditions element capacity이며 maximum_conditions 이상이다.

    uint64_t condition_capacity;
    
  • math_engine_cas_workspace_t.quadrature

    Caller-owned numerical-integration scratch; NULL은 capacity 0일 때만 허용되며 INTEGRAL fallback 동안 유지한다.

    math_engine_quadrature_interval_f64_t* quadrature;
    
  • math_engine_cas_workspace_t.quadrature_capacity

    quadrature element capacity; approximation integral은 최소 2를 요구한다.

    uint64_t quadrature_capacity;
    
  • math_engine_cas_workspace_t.reserved

    Caller가 0으로 두어야 하고 V1 validation이 nonzero를 거부한다.

    uint64_t reserved[2];
    

math_engine_cas_result_t

Canonical text, condition text와 proof provenance를 함께 commit하는 결과다.

typedef struct math_engine_cas_result {
    uint32_t struct_size; /**< Caller가 정확한 result record byte 크기로 미리 설정한다. */
    uint32_t struct_version; /**< Caller가 =MATH_ENGINE_CAS_RESULT_VERSION_1=로 설정한다. */
    uint32_t operation; /**< 완료된 =math_engine_cas_operation_t= 값이다. */
    uint32_t result_kind; /**< Exact/conditional/terminal 의미를 나타내는 result kind다. */
    uint32_t flags; /**< =MATH_ENGINE_CAS_RESULT_FLAG_*= bit의 OR이며 미정의 bit는 0이다. */
    uint32_t root_count; /**< SOLVE 결과의 exact root 표현식 수; V1 bounded solver에서 0..3이다. */
    uint64_t rewrite_steps; /**< 이번 요청에서 소비한 결정적 rewrite step 수다. */
    uint64_t input_node_count; /**< Parsed source AST의 node 수이며 workspace AST 유효 prefix 길이다. */
    uint64_t output_node_count; /**< =workspace.cas_nodes=에 생성된 유효 prefix element 수다. */
    uint64_t condition_count; /**< =workspace.conditions=의 유효 prefix와 출력 condition 수다. */
    uint64_t assumptions_used; /**< 조건 discharge에 실제 사용한 assumption match 횟수다. */
    uint64_t output_size; /**< 성공 시 =output=에 쓴 UTF-8 byte 수이며 NUL은 포함하지 않는다. */
    uint64_t condition_output_size; /**< 성공 시 condition buffer에 쓴 UTF-8 byte 수이며 NUL은 없다. */
    uint64_t required_output_size; /**< 성공 또는 buffer 부족 시 필요한 output byte capacity다. */
    uint64_t required_condition_output_size; /**< 성공 또는 부족 시 필요한 condition buffer byte capacity다. */
    uint64_t input_fingerprint; /**< Source AST와 ordered assumptions를 결합한 결정적 hash다. */
    uint64_t result_fingerprint; /**< Result kind, 두 출력 byte열과 input fingerprint의 hash다. */
    uint64_t rule_table_fingerprint; /**< 결과를 만든 내장 symbolic rule table revision hash다. */
    uint64_t reserved[2]; /**< Library가 0으로 기록하고 consumer가 무시하는 ABI 확장 word다. */
} math_engine_cas_result_t;
  • math_engine_cas_result_t.struct_size

    Caller가 정확한 result record byte 크기로 미리 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_result_t.struct_version

    Caller가 MATH_ENGINE_CAS_RESULT_VERSION_1 로 설정한다.

    uint32_t struct_version;
    
  • math_engine_cas_result_t.operation

    완료된 math_engine_cas_operation_t 값이다.

    uint32_t operation;
    
  • math_engine_cas_result_t.result_kind

    Exact/conditional/terminal 의미를 나타내는 result kind다.

    uint32_t result_kind;
    
  • math_engine_cas_result_t.flags

    MATH_ENGINE_CAS_RESULT_FLAG_* bit의 OR이며 미정의 bit는 0이다.

    uint32_t flags;
    
  • math_engine_cas_result_t.root_count

    SOLVE 결과의 exact root 표현식 수; V1 bounded solver에서 0..3이다.

    uint32_t root_count;
    
  • math_engine_cas_result_t.rewrite_steps

    이번 요청에서 소비한 결정적 rewrite step 수다.

    uint64_t rewrite_steps;
    
  • math_engine_cas_result_t.input_node_count

    Parsed source AST의 node 수이며 workspace AST 유효 prefix 길이다.

    uint64_t input_node_count;
    
  • math_engine_cas_result_t.output_node_count

    workspace.cas_nodes 에 생성된 유효 prefix element 수다.

    uint64_t output_node_count;
    
  • math_engine_cas_result_t.condition_count

    workspace.conditions 의 유효 prefix와 출력 condition 수다.

    uint64_t condition_count;
    
  • math_engine_cas_result_t.assumptions_used

    조건 discharge에 실제 사용한 assumption match 횟수다.

    uint64_t assumptions_used;
    
  • math_engine_cas_result_t.output_size

    성공 시 output 에 쓴 UTF-8 byte 수이며 NUL은 포함하지 않는다.

    uint64_t output_size;
    
  • math_engine_cas_result_t.condition_output_size

    성공 시 condition buffer에 쓴 UTF-8 byte 수이며 NUL은 없다.

    uint64_t condition_output_size;
    
  • math_engine_cas_result_t.required_output_size

    성공 또는 buffer 부족 시 필요한 output byte capacity다.

    uint64_t required_output_size;
    
  • math_engine_cas_result_t.required_condition_output_size

    성공 또는 부족 시 필요한 condition buffer byte capacity다.

    uint64_t required_condition_output_size;
    
  • math_engine_cas_result_t.input_fingerprint

    Source AST와 ordered assumptions를 결합한 결정적 hash다.

    uint64_t input_fingerprint;
    
  • math_engine_cas_result_t.result_fingerprint

    Result kind, 두 출력 byte열과 input fingerprint의 hash다.

    uint64_t result_fingerprint;
    
  • math_engine_cas_result_t.rule_table_fingerprint

    결과를 만든 내장 symbolic rule table revision hash다.

    uint64_t rule_table_fingerprint;
    
  • math_engine_cas_result_t.reserved

    Library가 0으로 기록하고 consumer가 무시하는 ABI 확장 word다.

    uint64_t reserved[2];
    

math_engine_cas_approximation_request_t

근삿값을 반환할 수 있는 유일한 API에 전달하는 명시적 요청이다.

typedef struct math_engine_cas_approximation_request {
    uint32_t struct_size; /**< Caller가 =sizeof(math_engine_cas_approximation_request_t)=로 설정한다. */
    uint32_t struct_version; /**< =MATH_ENGINE_CAS_APPROXIMATION_REQUEST_VERSION_1=이어야 한다. */
    uint32_t operation; /**< 수행할 =math_engine_cas_approximation_operation_t= 값이다. */
    uint32_t flags; /**< V1에는 request bit가 없어 반드시 0이다. */
    double argument; /**< VALUE/DERIVATIVE의 variable 값 또는 ROOT의 bracket 내부 초기 추정값이다. */
    double lower_bound; /**< INTEGRAL/ROOT domain의 finite lower endpoint이며 ROOT에서는 upper보다 작아야 한다. */
    double upper_bound; /**< INTEGRAL/ROOT domain의 finite upper endpoint이며 ROOT에서는 lower보다 커야 한다. */
    uint64_t reserved[2]; /**< Caller가 0으로 두어야 하는 ABI 확장 word 두 개다. */
} math_engine_cas_approximation_request_t;
  • math_engine_cas_approximation_request_t.struct_size

    Caller가 sizeof(math_engine_cas_approximation_request_t) 로 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_approximation_request_t.struct_version

    MATH_ENGINE_CAS_APPROXIMATION_REQUEST_VERSION_1 이어야 한다.

    uint32_t struct_version;
    
  • math_engine_cas_approximation_request_t.operation

    수행할 math_engine_cas_approximation_operation_t 값이다.

    uint32_t operation;
    
  • math_engine_cas_approximation_request_t.flags

    V1에는 request bit가 없어 반드시 0이다.

    uint32_t flags;
    
  • math_engine_cas_approximation_request_t.argument

    VALUE/DERIVATIVE의 variable 값 또는 ROOT의 bracket 내부 초기 추정값이다.

    double argument;
    
  • math_engine_cas_approximation_request_t.lower_bound

    INTEGRAL/ROOT domain의 finite lower endpoint이며 ROOT에서는 upper보다 작아야 한다.

    double lower_bound;
    
  • math_engine_cas_approximation_request_t.upper_bound

    INTEGRAL/ROOT domain의 finite upper endpoint이며 ROOT에서는 lower보다 커야 한다.

    double upper_bound;
    
  • math_engine_cas_approximation_request_t.reserved

    Caller가 0으로 두어야 하는 ABI 확장 word 두 개다.

    uint64_t reserved[2];
    

math_engine_cas_approximation_result_t

수치 fallback의 값, 절대오차, bracket, 비용과 fingerprint를 담는 결과다.

typedef struct math_engine_cas_approximation_result {
    uint32_t struct_size; /**< Caller가 exact result record byte 크기로 미리 설정한다. */
    uint32_t struct_version; /**< Caller가 =MATH_ENGINE_CAS_APPROXIMATION_RESULT_VERSION_1=로 설정한다. */
    uint32_t operation; /**< 완료된 approximation operation 값이다. */
    uint32_t result_kind; /**< 성공한 수치 fallback에서는 =MATH_ENGINE_CAS_RESULT_APPROXIMATE=다. */
    uint32_t flags; /**< NUMERICAL_FALLBACK와 domain/branch 보존 bit의 OR이다. */
    uint32_t backend; /**< 마지막 표현식 scalar 평가에 사용된 =math_engine_backend_t= 식별값이다. */
    double value; /**< 요청된 값, 도함수, 정적분 또는 root의 finite binary64 결과다. */
    double absolute_error; /**< Numeric kernel이 보고한 nonnegative 절대오차 추정값이다. */
    double lower_bound; /**< Integral의 실제 적분 lower 또는 root의 최종 bracket lower이며 VALUE/DERIVATIVE에서는 0이다. */
    double upper_bound; /**< Integral의 실제 적분 upper 또는 root의 최종 bracket upper이며 VALUE/DERIVATIVE에서는 0이다. */
    uint64_t evaluations; /**< Expression evaluation callback을 실행한 누계 횟수다. */
    uint64_t iterations; /**< 미분 evaluation 수, quadrature interval 수 또는 root iteration 수다. */
    uint64_t result_fingerprint; /**< Operation, backend, 수치 bit pattern과 비용의 결정적 hash다. */
    uint64_t reserved[2]; /**< Library가 0으로 기록하고 consumer가 무시하는 ABI 확장 word다. */
} math_engine_cas_approximation_result_t;
  • math_engine_cas_approximation_result_t.struct_size

    Caller가 exact result record byte 크기로 미리 설정한다.

    uint32_t struct_size;
    
  • math_engine_cas_approximation_result_t.struct_version

    Caller가 MATH_ENGINE_CAS_APPROXIMATION_RESULT_VERSION_1 로 설정한다.

    uint32_t struct_version;
    
  • math_engine_cas_approximation_result_t.operation

    완료된 approximation operation 값이다.

    uint32_t operation;
    
  • math_engine_cas_approximation_result_t.result_kind

    성공한 수치 fallback에서는 MATH_ENGINE_CAS_RESULT_APPROXIMATE 다.

    uint32_t result_kind;
    
  • math_engine_cas_approximation_result_t.flags

    NUMERICAL_FALLBACK와 domain/branch 보존 bit의 OR이다.

    uint32_t flags;
    
  • math_engine_cas_approximation_result_t.backend

    마지막 표현식 scalar 평가에 사용된 math_engine_backend_t 식별값이다.

    uint32_t backend;
    
  • math_engine_cas_approximation_result_t.value

    요청된 값, 도함수, 정적분 또는 root의 finite binary64 결과다.

    double value;
    
  • math_engine_cas_approximation_result_t.absolute_error

    Numeric kernel이 보고한 nonnegative 절대오차 추정값이다.

    double absolute_error;
    
  • math_engine_cas_approximation_result_t.lower_bound

    Integral의 실제 적분 lower 또는 root의 최종 bracket lower이며 VALUE/DERIVATIVE에서는 0이다.

    double lower_bound;
    
  • math_engine_cas_approximation_result_t.upper_bound

    Integral의 실제 적분 upper 또는 root의 최종 bracket upper이며 VALUE/DERIVATIVE에서는 0이다.

    double upper_bound;
    
  • math_engine_cas_approximation_result_t.evaluations

    Expression evaluation callback을 실행한 누계 횟수다.

    uint64_t evaluations;
    
  • math_engine_cas_approximation_result_t.iterations

    미분 evaluation 수, quadrature interval 수 또는 root iteration 수다.

    uint64_t iterations;
    
  • math_engine_cas_approximation_result_t.result_fingerprint

    Operation, backend, 수치 bit pattern과 비용의 결정적 hash다.

    uint64_t result_fingerprint;
    
  • math_engine_cas_approximation_result_t.reserved

    Library가 0으로 기록하고 consumer가 무시하는 ABI 확장 word다.

    uint64_t reserved[2];
    

Anonymous enum

anonymous_enum_at_line_119

@name math_engine_cas_result_t.flags bit

enum {
    MATH_ENGINE_CAS_RESULT_FLAG_CHANGED = UINT32_C(1) << 0u, /**< Bit 0: output text가 입력 canonical text와 다르다. */
    MATH_ENGINE_CAS_RESULT_FLAG_DOMAIN_PRESERVED = UINT32_C(1) << 1u, /**< Bit 1: rewrite가 real-domain 제약을 보존했다. */
    MATH_ENGINE_CAS_RESULT_FLAG_BRANCH_PRESERVED = UINT32_C(1) << 2u, /**< Bit 2: multi-valued 함수의 선택 branch를 보존했다. */
    MATH_ENGINE_CAS_RESULT_FLAG_HAS_CONDITIONS = UINT32_C(1) << 3u, /**< Bit 3: =condition_count>0=이고 condition text가 있다. */
    MATH_ENGINE_CAS_RESULT_FLAG_EMBEDDED_SUBSET = UINT32_C(1) << 4u, /**< Bit 4: embedded-exact ceiling으로 실행했다. */
    MATH_ENGINE_CAS_RESULT_FLAG_ASSUMPTION_USED = UINT32_C(1) << 5u, /**< Bit 5: 하나 이상의 조건을 assumption으로 discharge했다. */
    MATH_ENGINE_CAS_RESULT_FLAG_MULTIPLE_ROOTS = UINT32_C(1) << 6u, /**< Bit 6: polynomial solve가 둘 이상의 root 표현식을 냈다. */
    MATH_ENGINE_CAS_RESULT_FLAG_NUMERICAL_FALLBACK = UINT32_C(1) << 7u /**< Bit 7: exact 변환이 아닌 명시적 수치 kernel 결과다. */
};
  • MATH_ENGINE_CAS_RESULT_FLAG_CHANGED

    Bit 0: output text가 입력 canonical text와 다르다.

    MATH_ENGINE_CAS_RESULT_FLAG_CHANGED = UINT32_C(1) << 0u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_DOMAIN_PRESERVED

    Bit 1: rewrite가 real-domain 제약을 보존했다.

    MATH_ENGINE_CAS_RESULT_FLAG_DOMAIN_PRESERVED = UINT32_C(1) << 1u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_BRANCH_PRESERVED

    Bit 2: multi-valued 함수의 선택 branch를 보존했다.

    MATH_ENGINE_CAS_RESULT_FLAG_BRANCH_PRESERVED = UINT32_C(1) << 2u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_HAS_CONDITIONS

    Bit 3: condition_count>0 이고 condition text가 있다.

    MATH_ENGINE_CAS_RESULT_FLAG_HAS_CONDITIONS = UINT32_C(1) << 3u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_EMBEDDED_SUBSET

    Bit 4: embedded-exact ceiling으로 실행했다.

    MATH_ENGINE_CAS_RESULT_FLAG_EMBEDDED_SUBSET = UINT32_C(1) << 4u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_ASSUMPTION_USED

    Bit 5: 하나 이상의 조건을 assumption으로 discharge했다.

    MATH_ENGINE_CAS_RESULT_FLAG_ASSUMPTION_USED = UINT32_C(1) << 5u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_MULTIPLE_ROOTS

    Bit 6: polynomial solve가 둘 이상의 root 표현식을 냈다.

    MATH_ENGINE_CAS_RESULT_FLAG_MULTIPLE_ROOTS = UINT32_C(1) << 6u,
    
  • MATH_ENGINE_CAS_RESULT_FLAG_NUMERICAL_FALLBACK

    Bit 7: exact 변환이 아닌 명시적 수치 kernel 결과다.

    MATH_ENGINE_CAS_RESULT_FLAG_NUMERICAL_FALLBACK = UINT32_C(1) << 7u,
    

Macro와 constant

MATH_ENGINE_CAS_APPROXIMATION_REQUEST_VERSION_1

math_engine_cas_approximation_request_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_APPROXIMATION_REQUEST_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_APPROXIMATION_RESULT_VERSION_1

math_engine_cas_approximation_result_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_APPROXIMATION_RESULT_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_ASSUMPTION_VERSION_1

math_engine_cas_assumption_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_ASSUMPTION_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_CONDITION_VERSION_1

math_engine_cas_condition_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_CONDITION_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_INDEX_NONE

자식 또는 sibling node가 없음을 나타내는 32-bit sentinel 값 UINT32_MAX 다.

#define MATH_ENGINE_CAS_INDEX_NONE UINT32_MAX

MATH_ENGINE_CAS_NAME_CAPACITY

Symbol/call/assumption 이름 배열의 총 byte 수 32이며 유효 payload는 1..31 byte다.

#define MATH_ENGINE_CAS_NAME_CAPACITY UINT32_C(32)

MATH_ENGINE_CAS_NODE_VERSION_1

math_engine_cas_node_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_NODE_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_OPTIONS_VERSION_1

math_engine_cas_options_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_OPTIONS_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_RATIONAL_VERSION_1

math_engine_cas_rational_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_RATIONAL_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_RESULT_VERSION_1

math_engine_cas_result_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_RESULT_VERSION_1 UINT32_C(1)

MATH_ENGINE_CAS_WORKSPACE_VERSION_1

math_engine_cas_workspace_t.struct_version 에 쓰는 최초 ABI 값 1이다.

#define MATH_ENGINE_CAS_WORKSPACE_VERSION_1 UINT32_C(1)

Function

math_engine_cas_options_init

Full 또는 embedded-exact symbolic 작업의 bounded 기본값을 초기화한다.

  • 매개변수 profile: ceiling을 선택할 CAS profile.
  • 매개변수 out_options: 성공 시 완전히 초기화되는 caller output.
  • 반환: 성공 시 OK. 잘못된 profile/NULL 또는 embedded build의 FULL 요청에서는 output을

보존하고 INVALID_ARGUMENT/UNSUPPORTED를 반환한다.

  • Math Engine ownership: out_options=caller
  • Math Engine nullable: out_options=false
  • Math Engine thread_safety: safe
MATH_ENGINE_API math_engine_status_t math_engine_cas_options_init(
    math_engine_cas_profile_t profile,
    math_engine_cas_options_t* out_options);

math_engine_cas_assumption_init

검증된 symbol assumption 하나를 초기화하고 fingerprint한다.

  • 매개변수 kind: NONZERO, POSITIVE, NONNEGATIVE 또는 REAL 조건.
  • 매개변수 name: NUL 종료가 필요 없는 ASCII symbol name.
  • 매개변수 name_size: name 의 byte 수. 1 이상, fixed capacity 미만이어야 한다.
  • 매개변수 out_assumption: 성공 시 commit되는 caller output.
  • 반환: 성공 시 OK. 잘못된 name/kind/NULL에서는 output을 보존한다.
  • Math Engine ownership: name=borrowed out_assumption=caller
  • Math Engine nullable: name=false out_assumption=false
  • Math Engine thread_safety: safe
MATH_ENGINE_API math_engine_status_t math_engine_cas_assumption_init(
    math_engine_cas_condition_kind_t kind,
    const char* name,
    size_t name_size,
    math_engine_cas_assumption_t* out_assumption);

math_engine_cas_approximation_request_init

명시적 수치 fallback request를 finite 기본 인수로 초기화한다.

  • 매개변수 operation: value, derivative, integral 또는 bracketed root 연산.
  • 매개변수 out_request: 성공 시 argument=0, bracket=[-1,1]로 초기화되는 caller output.
  • 반환: 성공 시 OK. 잘못된 operation/NULL에서는 output을 보존한다.
  • Math Engine ownership: out_request=caller
  • Math Engine nullable: out_request=false
  • Math Engine thread_safety: safe
MATH_ENGINE_API math_engine_status_t math_engine_cas_approximation_request_init(
    math_engine_cas_approximation_operation_t operation,
    math_engine_cas_approximation_request_t* out_request);

math_engine_cas_transform_utf8

UTF-8 expression에 bounded exact symbolic transform을 수행한다.

  • 매개변수 operation: simplify, differentiate, integrate 또는 bounded polynomial solve.
  • 매개변수 source: NUL 종료가 필요 없는 non-empty UTF-8 expression.
  • 매개변수 source_size: source 의 byte 수. UINT32_MAX 이하여야 한다.
  • 매개변수 variable: simplify에서는 무시되고 나머지 연산에서는 필요한 ASCII symbol.
  • 매개변수 variable_size: variable 의 byte 수.
  • 매개변수 assumptions: nullable assumption 배열.
  • 매개변수 assumption_count: assumption element 수. 0이면 assumptions=NULL 을 허용한다.
  • 매개변수 options: profile과 모든 deterministic ceiling을 담은 immutable options.
  • 매개변수 context: tolerance, budget와 동기 cancellation callback을 담은 immutable context.
  • 매개변수 workspace: 호출 중 독점 사용하는 caller-owned parse/rewrite storage.
  • 매개변수 output: canonical UTF-8를 받는 caller buffer. NUL을 추가하지 않는다.
  • 매개변수 output_capacity: output 의 byte capacity.
  • 매개변수 condition_output: nullable condition UTF-8 buffer. Capacity 0일 때만 NULL 가능하다.
  • 매개변수 condition_output_capacity: condition_output 의 byte capacity.
  • 매개변수 out_result: size/version을 설정한 caller result.
  • 반환: 아래 terminal/result 계약에 따라 OK, BUDGET_EXHAUSTED 또는 오류 status를

반환한다. Cancellation callback은 호출 thread에서 동기 호출되고 pointer는 보관되지 않는다. Input, workspace, output 두 개와 result는 서로 overlap하지 않아야 한다.

Parses and performs one bounded exact transform, then emits canonical UTF-8 without NUL. variable is required for derivative, integral and solve, and ignored for simplify. Unsupported safe rewrites return OK with UNEVALUATED/UNSUPPORTED and preserve the expression. BUDGET_EXHAUSTED commits a result of the same name; syntax and validation failures preserve output buffers and out_result. INSUFFICIENT_BUFFER commits only required byte counts.

  • Math Engine ownership: source=borrowed variable=borrowed assumptions=borrowed options=borrowed context=borrowed workspace=caller output=caller condition_output=caller out_result=caller
  • Math Engine nullable: source=false variable=conditional assumptions=count_zero_only options=false context=false workspace=false output=false condition_output=capacity_zero_only out_result=false
  • Math Engine thread_safety: safe
MATH_ENGINE_API math_engine_status_t math_engine_cas_transform_utf8(
    math_engine_cas_operation_t operation,
    const char* source,
    size_t source_size,
    const char* variable,
    size_t variable_size,
    const math_engine_cas_assumption_t* assumptions,
    size_t assumption_count,
    const math_engine_cas_options_t* options,
    const math_engine_context_t* context,
    math_engine_cas_workspace_t* workspace,
    char* output,
    size_t output_capacity,
    char* condition_output,
    size_t condition_output_capacity,
    math_engine_cas_result_t* out_result);

math_engine_cas_approximate_utf8

UTF-8 expression을 명시적으로 수치 value/derivative/integral/root로 평가한다.

  • 매개변수 source: NUL 종료가 필요 없는 non-empty UTF-8 expression.
  • 매개변수 source_size: source 의 byte 수. UINT32_MAX 이하여야 한다.
  • 매개변수 variable: expression에서 대입할 non-empty ASCII symbol.
  • 매개변수 variable_size: variable 의 byte 수.
  • 매개변수 request: finite evaluation point 또는 integration/root bracket request.
  • 매개변수 options: FULL profile의 immutable CAS ceiling.
  • 매개변수 context: tolerance, budget와 동기 cancellation callback을 담은 context.
  • 매개변수 workspace: 호출 중 독점 사용하는 parse/rewrite/quadrature storage.
  • 매개변수 out_result: size/version을 설정한 caller result.
  • 반환: 성공 시 OK와 APPROXIMATE result를 반환한다. Embedded-exact build/profile은

UNSUPPORTED다. Domain, convergence, budget, cancellation과 ABI 오류에서는 output을 보존한다. Pointer는 보관하지 않으며 input/workspace/output은 서로 overlap하지 않아야 한다.

Explicitly evaluates a value, derivative, integral or bracketed root through TODO 17~19 numeric kernels. Embedded-exact builds reject this function with UNSUPPORTED. Failure preserves out_result, and success always reports APPROXIMATE plus NUMERICAL_FALLBACK.

  • Math Engine ownership: source=borrowed variable=borrowed request=borrowed options=borrowed context=borrowed workspace=caller out_result=caller
  • Math Engine nullable: source=false variable=false request=false options=false context=false workspace=false out_result=false
  • Math Engine thread_safety: safe
MATH_ENGINE_API math_engine_status_t math_engine_cas_approximate_utf8(
    const char* source,
    size_t source_size,
    const char* variable,
    size_t variable_size,
    const math_engine_cas_approximation_request_t* request,
    const math_engine_cas_options_t* options,
    const math_engine_context_t* context,
    math_engine_cas_workspace_t* workspace,
    math_engine_cas_approximation_result_t* out_result);