resdag 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. resdag-0.1.0/.claude/docs/lean4/axiom-elimination.md +252 -0
  2. resdag-0.1.0/.claude/docs/lean4/compiler-guided-repair.md +717 -0
  3. resdag-0.1.0/.claude/docs/lean4/lean-lsp-tools-api.md +790 -0
  4. resdag-0.1.0/.claude/docs/lean4/proof-golfing.md +702 -0
  5. resdag-0.1.0/.claude/docs/lean4/sorry-filling.md +154 -0
  6. resdag-0.1.0/.claude/settings.local.json +19 -0
  7. resdag-0.1.0/.claude/tools/lean4/analyze_let_usage.py +336 -0
  8. resdag-0.1.0/.claude/tools/lean4/check_axioms.sh +149 -0
  9. resdag-0.1.0/.claude/tools/lean4/count_tokens.py +235 -0
  10. resdag-0.1.0/.claude/tools/lean4/find_golfable.py +492 -0
  11. resdag-0.1.0/.claude/tools/lean4/search_mathlib.sh +103 -0
  12. resdag-0.1.0/.claude/tools/lean4/smart_search.sh +195 -0
  13. resdag-0.1.0/.claude/tools/lean4/sorry_analyzer.py +332 -0
  14. resdag-0.1.0/.claude/tools/lean4/suggest_tactics.sh +296 -0
  15. resdag-0.1.0/.github/BUGFIX_dendrocycle_rounding.md +97 -0
  16. resdag-0.1.0/.gitignore +57 -0
  17. resdag-0.1.0/.python-version +1 -0
  18. resdag-0.1.0/Logo.png +0 -0
  19. resdag-0.1.0/Logo.svg +15 -0
  20. resdag-0.1.0/PKG-INFO +631 -0
  21. resdag-0.1.0/README.md +596 -0
  22. resdag-0.1.0/examples/00_registry_system.py +218 -0
  23. resdag-0.1.0/examples/01_reservoir_with_topology.py +139 -0
  24. resdag-0.1.0/examples/02_input_feedback_initializers.py +179 -0
  25. resdag-0.1.0/examples/03_model_composition.py +228 -0
  26. resdag-0.1.0/examples/04_model_visualization.py +169 -0
  27. resdag-0.1.0/examples/05_functional_api.py +141 -0
  28. resdag-0.1.0/examples/06_premade_models.py +241 -0
  29. resdag-0.1.0/examples/07_save_load_models.py +264 -0
  30. resdag-0.1.0/examples/08_forecasting.py +292 -0
  31. resdag-0.1.0/examples/09_model_visualization_new.py +140 -0
  32. resdag-0.1.0/examples/09_training.py +277 -0
  33. resdag-0.1.0/examples/10_hpo.py +721 -0
  34. resdag-0.1.0/examples/README.md +164 -0
  35. resdag-0.1.0/pyproject.toml +97 -0
  36. resdag-0.1.0/requirements-dev.txt +7 -0
  37. resdag-0.1.0/requirements.txt +4 -0
  38. resdag-0.1.0/src/resdag/__init__.py +132 -0
  39. resdag-0.1.0/src/resdag/composition/__init__.py +48 -0
  40. resdag-0.1.0/src/resdag/composition/symbolic.py +768 -0
  41. resdag-0.1.0/src/resdag/hpo/__init__.py +157 -0
  42. resdag-0.1.0/src/resdag/hpo/losses.py +345 -0
  43. resdag-0.1.0/src/resdag/hpo/objective.py +214 -0
  44. resdag-0.1.0/src/resdag/hpo/run.py +279 -0
  45. resdag-0.1.0/src/resdag/hpo/utils.py +136 -0
  46. resdag-0.1.0/src/resdag/init/__init__.py +43 -0
  47. resdag-0.1.0/src/resdag/init/graphs/__init__.py +51 -0
  48. resdag-0.1.0/src/resdag/init/graphs/barabasi_albert.py +78 -0
  49. resdag-0.1.0/src/resdag/init/graphs/chord_dendrocycle.py +154 -0
  50. resdag-0.1.0/src/resdag/init/graphs/complete.py +56 -0
  51. resdag-0.1.0/src/resdag/init/graphs/connected_erdos_renyi.py +63 -0
  52. resdag-0.1.0/src/resdag/init/graphs/connected_watts_strogatz.py +57 -0
  53. resdag-0.1.0/src/resdag/init/graphs/dendrocycle.py +205 -0
  54. resdag-0.1.0/src/resdag/init/graphs/erdos_renyi.py +62 -0
  55. resdag-0.1.0/src/resdag/init/graphs/kleinberg_small_world.py +111 -0
  56. resdag-0.1.0/src/resdag/init/graphs/multi_cycle.py +72 -0
  57. resdag-0.1.0/src/resdag/init/graphs/newman_watts_strogatz.py +83 -0
  58. resdag-0.1.0/src/resdag/init/graphs/random.py +57 -0
  59. resdag-0.1.0/src/resdag/init/graphs/regular.py +79 -0
  60. resdag-0.1.0/src/resdag/init/graphs/ring_chord.py +69 -0
  61. resdag-0.1.0/src/resdag/init/graphs/simple_cycle_jumps.py +55 -0
  62. resdag-0.1.0/src/resdag/init/graphs/spectral_cascade.py +129 -0
  63. resdag-0.1.0/src/resdag/init/graphs/watts_strogatz.py +89 -0
  64. resdag-0.1.0/src/resdag/init/input_feedback/__init__.py +105 -0
  65. resdag-0.1.0/src/resdag/init/input_feedback/base.py +109 -0
  66. resdag-0.1.0/src/resdag/init/input_feedback/binary_balanced.py +209 -0
  67. resdag-0.1.0/src/resdag/init/input_feedback/chain_of_neurons_input.py +112 -0
  68. resdag-0.1.0/src/resdag/init/input_feedback/chebyshev.py +120 -0
  69. resdag-0.1.0/src/resdag/init/input_feedback/chessboard.py +79 -0
  70. resdag-0.1.0/src/resdag/init/input_feedback/dendrocycle_input.py +113 -0
  71. resdag-0.1.0/src/resdag/init/input_feedback/opposite_anchors.py +90 -0
  72. resdag-0.1.0/src/resdag/init/input_feedback/pseudo_diagonal.py +133 -0
  73. resdag-0.1.0/src/resdag/init/input_feedback/random.py +117 -0
  74. resdag-0.1.0/src/resdag/init/input_feedback/random_binary.py +90 -0
  75. resdag-0.1.0/src/resdag/init/input_feedback/registry.py +188 -0
  76. resdag-0.1.0/src/resdag/init/input_feedback/ring_window.py +176 -0
  77. resdag-0.1.0/src/resdag/init/topology/__init__.py +71 -0
  78. resdag-0.1.0/src/resdag/init/topology/base.py +220 -0
  79. resdag-0.1.0/src/resdag/init/topology/registry.py +237 -0
  80. resdag-0.1.0/src/resdag/init/utils/__init__.py +17 -0
  81. resdag-0.1.0/src/resdag/init/utils/graph_tools.py +68 -0
  82. resdag-0.1.0/src/resdag/init/utils/resolve.py +114 -0
  83. resdag-0.1.0/src/resdag/layers/__init__.py +61 -0
  84. resdag-0.1.0/src/resdag/layers/custom/__init__.py +44 -0
  85. resdag-0.1.0/src/resdag/layers/custom/concatenate.py +84 -0
  86. resdag-0.1.0/src/resdag/layers/custom/feature_partitioner.py +120 -0
  87. resdag-0.1.0/src/resdag/layers/custom/outliers_filtered_mean.py +135 -0
  88. resdag-0.1.0/src/resdag/layers/custom/selective_dropout.py +95 -0
  89. resdag-0.1.0/src/resdag/layers/custom/selective_exponentiation.py +87 -0
  90. resdag-0.1.0/src/resdag/layers/readouts/__init__.py +36 -0
  91. resdag-0.1.0/src/resdag/layers/readouts/base.py +212 -0
  92. resdag-0.1.0/src/resdag/layers/readouts/cg_readout.py +282 -0
  93. resdag-0.1.0/src/resdag/layers/reservoir.py +515 -0
  94. resdag-0.1.0/src/resdag/models/__init__.py +60 -0
  95. resdag-0.1.0/src/resdag/models/classic_esn.py +162 -0
  96. resdag-0.1.0/src/resdag/models/headless_esn.py +97 -0
  97. resdag-0.1.0/src/resdag/models/linear_esn.py +90 -0
  98. resdag-0.1.0/src/resdag/models/ott_esn.py +179 -0
  99. resdag-0.1.0/src/resdag/training/__init__.py +31 -0
  100. resdag-0.1.0/src/resdag/training/trainer.py +249 -0
  101. resdag-0.1.0/src/resdag/utils/__init__.py +34 -0
  102. resdag-0.1.0/src/resdag/utils/data/__init__.py +95 -0
  103. resdag-0.1.0/src/resdag/utils/data/io.py +304 -0
  104. resdag-0.1.0/src/resdag/utils/data/prepare.py +311 -0
  105. resdag-0.1.0/src/resdag/utils/general.py +23 -0
  106. resdag-0.1.0/tests/__init__.py +1 -0
  107. resdag-0.1.0/tests/test_composition/test_save_load.py +407 -0
  108. resdag-0.1.0/tests/test_gpu_and_compile.py +370 -0
  109. resdag-0.1.0/tests/test_hpo/__init__.py +1 -0
  110. resdag-0.1.0/tests/test_hpo/test_losses.py +182 -0
  111. resdag-0.1.0/tests/test_hpo/test_run.py +243 -0
  112. resdag-0.1.0/tests/test_layers/__init__.py +1 -0
  113. resdag-0.1.0/tests/test_layers/test_cg_readout.py +372 -0
  114. resdag-0.1.0/tests/test_layers/test_custom_layers.py +374 -0
  115. resdag-0.1.0/tests/test_layers/test_readout.py +357 -0
  116. resdag-0.1.0/tests/test_layers/test_reservoir.py +375 -0
  117. resdag-0.1.0/tests/test_layers/test_reservoir_topology.py +190 -0
  118. resdag-0.1.0/tests/test_models/test_premade_models.py +310 -0
  119. resdag-0.1.0/tests/test_topology/__init__.py +1 -0
  120. resdag-0.1.0/tests/test_topology/test_graph_topology.py +194 -0
  121. resdag-0.1.0/tests/test_training/__init__.py +1 -0
  122. resdag-0.1.0/tests/test_training/test_trainer.py +363 -0
  123. resdag-0.1.0/uv.lock +1243 -0
@@ -0,0 +1,252 @@
1
+ # Axiom Elimination Reference
2
+
3
+ Quick reference for systematically eliminating custom axioms from Lean 4 proofs.
4
+
5
+ ## Standard vs Custom Axioms
6
+
7
+ **Standard mathlib axioms (ACCEPTABLE):**
8
+ - `Classical.choice` (axiom of choice)
9
+ - `propext` (propositional extensionality)
10
+ - `quot.sound` / `Quot.sound` (quotient soundness)
11
+
12
+ **Custom axioms (MUST ELIMINATE):**
13
+ - Any `axiom` declarations in your code
14
+ - Dependencies on unproven theorems
15
+
16
+ ## Verification
17
+
18
+ **Check axiom usage:**
19
+ ```bash
20
+ bash .claude/tools/lean4/check_axioms.sh FILE.lean
21
+ ```
22
+
23
+ **For individual theorems:**
24
+ ```bash
25
+ lake env lean --run <<EOF
26
+ #print axioms theoremName
27
+ EOF
28
+ ```
29
+
30
+ ## Elimination Workflow
31
+
32
+ ### Phase 1: Audit Current State
33
+
34
+ 1. Run axiom checker on all files
35
+ 2. List all custom axioms with locations
36
+ 3. Identify dependencies (which theorems use which axioms)
37
+ 4. Prioritize by impact (eliminate high-usage axioms first)
38
+
39
+ ### Phase 2: Document Elimination Plan
40
+
41
+ For each axiom, document:
42
+ ```lean
43
+ axiom helper_theorem : P
44
+ -- TODO: Eliminate axiom
45
+ -- Strategy: [search pattern OR proof technique]
46
+ -- Required lemmas: [mathlib lemmas needed]
47
+ -- Difficulty: [easy/medium/hard]
48
+ -- Priority: [high/medium/low - based on usage count]
49
+ -- Est. time: [time estimate]
50
+ ```
51
+
52
+ ### Phase 3: Search Mathlib Exhaustively
53
+
54
+ **60% of axioms already exist as theorems in mathlib!**
55
+
56
+ **Search by name:**
57
+ ```bash
58
+ bash .claude/tools/lean4/search_mathlib.sh "axiom_name_pattern" name
59
+ ```
60
+
61
+ **Search by type/description:**
62
+ ```bash
63
+ bash .claude/tools/lean4/smart_search.sh "property description" --source=leansearch
64
+ ```
65
+
66
+ **Search by type pattern:**
67
+ ```bash
68
+ bash .claude/tools/lean4/smart_search.sh "type signature pattern" --source=loogle
69
+ ```
70
+
71
+ ### Phase 4: Eliminate Axioms
72
+
73
+ **Five common patterns:**
74
+
75
+ **Pattern 1: "It's in mathlib" (60%)**
76
+ - Search finds existing theorem
77
+ - Replace `axiom` with `theorem` and import
78
+ - Replace body with `:= mathlib_lemma`
79
+
80
+ **Pattern 2: "Compositional proof" (30%)**
81
+ - Combine 2-3 existing mathlib lemmas
82
+ - Prove using standard tactics
83
+ - Replace axiom with actual proof
84
+
85
+ **Pattern 3: "Needs domain expertise" (9%)**
86
+ - Break into smaller lemmas
87
+ - Prove components using mathlib
88
+ - Combine for final result
89
+
90
+ **Pattern 4: "Actually false" (1%)**
91
+ - Original axiom too strong
92
+ - Weaken to provable version
93
+ - Update dependent theorems
94
+
95
+ **Pattern 5: "Placeholder for sorry" (common during development)**
96
+ - Convert `axiom` to `theorem` with `sorry`
97
+ - Fill using sorry-filling workflow
98
+ - See sorry-filling.md
99
+
100
+ ## Elimination Strategies by Type
101
+
102
+ ### Simple Lemmas
103
+ ```lean
104
+ -- Before
105
+ axiom simple_fact : A → B
106
+
107
+ -- After (search mathlib)
108
+ import Mathlib.Data.Foo
109
+ theorem simple_fact : A → B := mathlib_existing_lemma
110
+ ```
111
+
112
+ ### Compositional Proofs
113
+ ```lean
114
+ -- Before
115
+ axiom complex_fact : Big_Statement
116
+
117
+ -- After (prove from components)
118
+ theorem complex_fact : Big_Statement := by
119
+ have h1 := mathlib_lemma_1
120
+ have h2 := mathlib_lemma_2
121
+ exact combine h1 h2
122
+ ```
123
+
124
+ ### Structural Refactors
125
+ ```lean
126
+ -- Before
127
+ axiom infrastructure : Property
128
+
129
+ -- After (add structure)
130
+ -- 1. Introduce helper lemmas
131
+ private lemma helper1 : SubProperty := by ...
132
+ private lemma helper2 : AnotherSubProperty := by ...
133
+
134
+ -- 2. Combine for main result
135
+ theorem infrastructure : Property := by
136
+ apply helper1
137
+ exact helper2
138
+ ```
139
+
140
+ ## Handling Dependencies
141
+
142
+ **If axiom A depends on axiom B:**
143
+ 1. Eliminate B first (bottom-up approach)
144
+ 2. Document dependency chain
145
+ 3. Verify elimination doesn't break A
146
+ 4. Then eliminate A
147
+
148
+ **Dependency tracking:**
149
+ ```bash
150
+ # Find what uses an axiom
151
+ bash .claude/tools/lean4/find_usages.sh axiom_name
152
+ ```
153
+
154
+ ## Progress Tracking
155
+
156
+ After each elimination:
157
+ ```bash
158
+ # Verify axiom count decreased
159
+ bash .claude/tools/lean4/check_axioms.sh FILE.lean
160
+
161
+ # Compare before/after
162
+ echo "Before: N custom axioms"
163
+ echo "After: M custom axioms"
164
+ echo "Eliminated: $((N - M))"
165
+ ```
166
+
167
+ **Expected elimination rate:**
168
+ - Easy axioms: 2-3 per hour
169
+ - Medium axioms: 1-2 per day
170
+ - Hard axioms: 2-5 days each
171
+
172
+ ## Migration Plan Template
173
+
174
+ **For large axiom elimination work:**
175
+
176
+ ```markdown
177
+ ## Axiom Elimination Plan
178
+
179
+ Total custom axioms: N
180
+ Target: 0 custom axioms
181
+
182
+ ### Phase 1: Low-hanging fruit (Est: X days)
183
+ - [ ] axiom_1 (type: mathlib_search)
184
+ - [ ] axiom_2 (type: simple_composition)
185
+ - [ ] axiom_3 (type: mathlib_search)
186
+
187
+ ### Phase 2: Medium difficulty (Est: Y days)
188
+ - [ ] axiom_4 (type: structural_refactor)
189
+ - [ ] axiom_5 (type: domain_expertise)
190
+
191
+ ### Phase 3: Hard cases (Est: Z days)
192
+ - [ ] axiom_6 (type: needs_deep_refactor)
193
+
194
+ Estimated total: X+Y+Z days
195
+ ```
196
+
197
+ ## Common Pitfalls
198
+
199
+ ❌ **Don't:**
200
+ - Add new axioms while eliminating old ones
201
+ - Skip mathlib search (60% hit rate!)
202
+ - Eliminate without testing dependents
203
+ - Give up after first search failure
204
+ - Use stronger axiom to replace weaker one
205
+
206
+ ✅ **Do:**
207
+ - Search thoroughly (multiple strategies)
208
+ - Test with `lake build` after each elimination
209
+ - Track progress (axiom count trending down)
210
+ - Document hard cases for future work
211
+ - Prove shims for backward compatibility
212
+
213
+ ## When to Keep Axioms
214
+
215
+ **Rare acceptable cases (WITH user approval):**
216
+ 1. Foundational axioms for new domain (e.g., new mathematical structure)
217
+ 2. Interface with external systems (FFI, oracles)
218
+ 3. Temporary scaffolding with CLEAR timeline
219
+
220
+ **Requires:**
221
+ - Explicit user approval
222
+ - Documented elimination plan
223
+ - Timeline for removal
224
+ - Not acceptable for mathlib contributions
225
+
226
+ ## Integration with Subagents
227
+
228
+ **lean4-axiom-eliminator agent can:**
229
+ - Search mathlib exhaustively for each axiom
230
+ - Try multiple proof strategies
231
+ - Generate elimination patches
232
+ - Track progress across batch
233
+
234
+ **Use for:**
235
+ - Projects with 10+ axioms
236
+ - Systematic cleanup work
237
+ - When you need to focus on other tasks
238
+
239
+ **Keep human for:**
240
+ - Novel mathematical insights
241
+ - Design decisions
242
+ - Hard cases needing creativity
243
+
244
+ ## Output Expectations
245
+
246
+ **Sonnet agents with thinking enabled:**
247
+ - Outline plan FIRST (bullet points)
248
+ - Show search results
249
+ - Propose elimination strategy
250
+ - Apply in small batches
251
+ - Report progress after each batch
252
+ - Total output: ~2000-3000 tokens per axiom