Spaces:
Paused
Paused
File size: 7,680 Bytes
8125804 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | from __future__ import annotations
from dataclasses import dataclass
import torch
from src.data.anchor_cases import AnchorProbeCase
@dataclass(frozen=True)
class SemanticTokenLegend:
token_id: int
label: str
role: str
def semantic_token_legend() -> list[SemanticTokenLegend]:
return [
SemanticTokenLegend(11, 'FORALL', 'quantifier_root'),
SemanticTokenLegend(12, 'EXISTS', 'conflicting_quantifier'),
SemanticTokenLegend(13, 'VAR_N', 'bound_variable'),
SemanticTokenLegend(14, 'CLAIM', 'assertion'),
SemanticTokenLegend(15, 'STEP', 'proof_step'),
SemanticTokenLegend(16, 'UNIFORM', 'uniform_descendant'),
SemanticTokenLegend(17, 'WITNESS', 'existential_descendant'),
SemanticTokenLegend(21, 'ASSUME_NOT', 'contradiction_root'),
SemanticTokenLegend(22, 'DERIVE', 'contradiction_step'),
SemanticTokenLegend(23, 'CONTRADICTION', 'contradiction_close'),
SemanticTokenLegend(24, 'DIRECT', 'direct_mode_conflict'),
SemanticTokenLegend(31, 'CONST', 'complexity_root'),
SemanticTokenLegend(32, 'LOOKUP', 'constant_time_descendant'),
SemanticTokenLegend(33, 'CACHE', 'constant_time_support'),
SemanticTokenLegend(34, 'LOOP', 'linear_conflict'),
SemanticTokenLegend(35, 'SCAN', 'linear_descendant'),
SemanticTokenLegend(41, 'INDUCT', 'induction_root'),
SemanticTokenLegend(42, 'BASE', 'induction_base_case'),
SemanticTokenLegend(43, 'STEP_K', 'induction_step'),
SemanticTokenLegend(44, 'STEP_K1', 'induction_successor'),
SemanticTokenLegend(45, 'EXAMPLE', 'finite_example_conflict'),
SemanticTokenLegend(51, 'EPS', 'epsilon_root'),
SemanticTokenLegend(52, 'DELTA', 'delta_descendant'),
SemanticTokenLegend(53, 'BOUND', 'formal_bound_descendant'),
SemanticTokenLegend(54, 'CLOSE', 'intuitive_closeness_conflict'),
]
def _make_targets(input_ids: torch.Tensor) -> torch.Tensor:
return torch.roll(input_ids, shifts=-1, dims=0)
def make_semantic_anchor_cases(seq_len: int = 24) -> list[AnchorProbeCase]:
if seq_len != 24:
raise ValueError('semantic probe cases currently require seq_len=24')
def t(values: list[int]) -> torch.Tensor:
return torch.tensor(values, dtype=torch.long)
cases: list[AnchorProbeCase] = []
forall_stable = t([
11, 13, 11, 16,
11, 13, 11, 16,
11, 13, 11, 16,
11, 13, 11, 16,
11, 13, 11, 16,
11, 13, 11, 16,
])
cases.append(
AnchorProbeCase(
name='forall_stable',
description='FORALL root followed by uniform descendants that stay semantically consistent.',
input_ids=forall_stable,
target_ids=_make_targets(forall_stable),
expected_anchor_zone=(0, 11),
expected_failure_mode='stable_quantifier_tree',
)
)
forall_exists_conflict = t([
11, 13, 11, 16,
11, 13, 11, 16,
11, 13, 11, 16,
12, 17, 12, 17,
12, 17, 12, 17,
12, 17, 12, 17,
])
cases.append(
AnchorProbeCase(
name='forall_exists_conflict',
description='FORALL root later flips into EXISTS-style descendants.',
input_ids=forall_exists_conflict,
target_ids=_make_targets(forall_exists_conflict),
expected_anchor_zone=(0, 11),
expected_failure_mode='quantifier_flip',
)
)
contradiction_stable = t([
21, 14, 22, 15,
21, 14, 22, 15,
21, 14, 22, 15,
21, 14, 23, 15,
21, 14, 23, 15,
21, 14, 23, 15,
])
cases.append(
AnchorProbeCase(
name='contradiction_stable',
description='ASSUME_NOT mode stays in contradiction style until closure.',
input_ids=contradiction_stable,
target_ids=_make_targets(contradiction_stable),
expected_anchor_zone=(0, 15),
expected_failure_mode='stable_contradiction_tree',
)
)
contradiction_direct_conflict = t([
21, 14, 22, 15,
21, 14, 22, 15,
21, 14, 22, 15,
24, 14, 15, 15,
24, 14, 15, 15,
24, 14, 15, 15,
])
cases.append(
AnchorProbeCase(
name='contradiction_direct_conflict',
description='ASSUME_NOT root later drifts into direct-proof style descendants.',
input_ids=contradiction_direct_conflict,
target_ids=_make_targets(contradiction_direct_conflict),
expected_anchor_zone=(0, 11),
expected_failure_mode='proof_mode_flip',
)
)
const_vs_loop_conflict = t([
31, 32, 33, 15,
31, 32, 33, 15,
31, 32, 33, 15,
34, 35, 35, 15,
34, 35, 35, 15,
34, 35, 35, 15,
])
cases.append(
AnchorProbeCase(
name='const_vs_loop_conflict',
description='Constant-time root later drifts into loop/scan descendants.',
input_ids=const_vs_loop_conflict,
target_ids=_make_targets(const_vs_loop_conflict),
expected_anchor_zone=(0, 11),
expected_failure_mode='complexity_flip',
)
)
induction_stable = t([
41, 42, 43, 44,
41, 42, 43, 44,
41, 42, 43, 44,
41, 42, 43, 44,
41, 42, 43, 44,
41, 42, 43, 44,
])
cases.append(
AnchorProbeCase(
name='induction_stable',
description='INDUCT root followed by repeated base/step/successor structure.',
input_ids=induction_stable,
target_ids=_make_targets(induction_stable),
expected_anchor_zone=(0, 11),
expected_failure_mode='stable_induction_tree',
)
)
induction_example_conflict = t([
41, 42, 43, 44,
41, 42, 43, 44,
41, 42, 43, 44,
45, 45, 45, 15,
45, 45, 45, 15,
45, 45, 45, 15,
])
cases.append(
AnchorProbeCase(
name='induction_example_conflict',
description='INDUCT root later collapses into repeated finite examples instead of inductive structure.',
input_ids=induction_example_conflict,
target_ids=_make_targets(induction_example_conflict),
expected_anchor_zone=(0, 11),
expected_failure_mode='induction_to_examples',
)
)
epsilon_delta_stable = t([
51, 52, 53, 15,
51, 52, 53, 15,
51, 52, 53, 15,
51, 52, 53, 15,
51, 52, 53, 15,
51, 52, 53, 15,
])
cases.append(
AnchorProbeCase(
name='epsilon_delta_stable',
description='EPS root followed by DELTA/BOUND descendants that remain formal.',
input_ids=epsilon_delta_stable,
target_ids=_make_targets(epsilon_delta_stable),
expected_anchor_zone=(0, 11),
expected_failure_mode='stable_formal_limit_tree',
)
)
epsilon_close_conflict = t([
51, 52, 53, 15,
51, 52, 53, 15,
51, 52, 53, 15,
54, 54, 54, 15,
54, 54, 54, 15,
54, 54, 54, 15,
])
cases.append(
AnchorProbeCase(
name='epsilon_close_conflict',
description='EPS root later drifts into intuitive closeness language instead of formal bound structure.',
input_ids=epsilon_close_conflict,
target_ids=_make_targets(epsilon_close_conflict),
expected_anchor_zone=(0, 11),
expected_failure_mode='formal_to_intuitive_drift',
)
)
return cases
|