@wentorai/research-plugins 1.0.0 → 1.1.0

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 (203) hide show
  1. package/README.md +22 -22
  2. package/curated/analysis/README.md +71 -56
  3. package/curated/domains/README.md +176 -67
  4. package/curated/literature/README.md +71 -47
  5. package/curated/research/README.md +91 -58
  6. package/curated/tools/README.md +88 -87
  7. package/curated/writing/README.md +80 -45
  8. package/mcp-configs/cloud-docs/confluence-mcp.json +37 -0
  9. package/mcp-configs/cloud-docs/google-drive-mcp.json +35 -0
  10. package/mcp-configs/cloud-docs/notion-mcp.json +29 -0
  11. package/mcp-configs/communication/discord-mcp.json +29 -0
  12. package/mcp-configs/communication/slack-mcp.json +29 -0
  13. package/mcp-configs/communication/telegram-mcp.json +28 -0
  14. package/mcp-configs/database/neo4j-mcp.json +37 -0
  15. package/mcp-configs/database/postgres-mcp.json +28 -0
  16. package/mcp-configs/database/sqlite-mcp.json +29 -0
  17. package/mcp-configs/dev-platform/github-mcp.json +31 -0
  18. package/mcp-configs/dev-platform/gitlab-mcp.json +34 -0
  19. package/mcp-configs/email/email-mcp.json +40 -0
  20. package/mcp-configs/email/gmail-mcp.json +37 -0
  21. package/mcp-configs/registry.json +178 -149
  22. package/mcp-configs/repository/dataverse-mcp.json +33 -0
  23. package/mcp-configs/repository/huggingface-mcp.json +29 -0
  24. package/openclaw.plugin.json +2 -2
  25. package/package.json +2 -2
  26. package/skills/analysis/dataviz/algorithm-visualizer-guide/SKILL.md +259 -0
  27. package/skills/analysis/dataviz/bokeh-visualization-guide/SKILL.md +270 -0
  28. package/skills/analysis/dataviz/chart-image-generator/SKILL.md +229 -0
  29. package/skills/analysis/dataviz/d3-visualization-guide/SKILL.md +281 -0
  30. package/skills/analysis/dataviz/echarts-visualization-guide/SKILL.md +250 -0
  31. package/skills/analysis/dataviz/metabase-analytics-guide/SKILL.md +242 -0
  32. package/skills/analysis/dataviz/plotly-interactive-guide/SKILL.md +266 -0
  33. package/skills/analysis/dataviz/redash-analytics-guide/SKILL.md +284 -0
  34. package/skills/analysis/econometrics/econml-causal-guide/SKILL.md +163 -0
  35. package/skills/analysis/econometrics/mostly-harmless-guide/SKILL.md +139 -0
  36. package/skills/analysis/econometrics/panel-data-analyst/SKILL.md +259 -0
  37. package/skills/analysis/econometrics/python-causality-guide/SKILL.md +134 -0
  38. package/skills/analysis/econometrics/stata-accounting-guide/SKILL.md +269 -0
  39. package/skills/analysis/econometrics/stata-analyst-guide/SKILL.md +245 -0
  40. package/skills/analysis/statistics/data-anomaly-detection/SKILL.md +157 -0
  41. package/skills/analysis/statistics/ml-experiment-tracker/SKILL.md +212 -0
  42. package/skills/analysis/statistics/pywayne-statistics-guide/SKILL.md +192 -0
  43. package/skills/analysis/statistics/quantitative-methods-guide/SKILL.md +193 -0
  44. package/skills/analysis/statistics/senior-data-scientist-guide/SKILL.md +223 -0
  45. package/skills/analysis/wrangling/csv-data-analyzer/SKILL.md +170 -0
  46. package/skills/analysis/wrangling/data-cleaning-pipeline/SKILL.md +266 -0
  47. package/skills/analysis/wrangling/data-cog-guide/SKILL.md +178 -0
  48. package/skills/analysis/wrangling/stata-data-cleaning/SKILL.md +276 -0
  49. package/skills/analysis/wrangling/survey-data-processing/SKILL.md +298 -0
  50. package/skills/domains/ai-ml/ai-model-benchmarking/SKILL.md +209 -0
  51. package/skills/domains/ai-ml/annotated-dl-papers-guide/SKILL.md +159 -0
  52. package/skills/domains/ai-ml/dl-transformer-finetune/SKILL.md +239 -0
  53. package/skills/domains/ai-ml/generative-ai-guide/SKILL.md +146 -0
  54. package/skills/domains/ai-ml/huggingface-inference-guide/SKILL.md +196 -0
  55. package/skills/domains/ai-ml/keras-deep-learning/SKILL.md +210 -0
  56. package/skills/domains/ai-ml/llm-from-scratch-guide/SKILL.md +124 -0
  57. package/skills/domains/ai-ml/ml-pipeline-guide/SKILL.md +295 -0
  58. package/skills/domains/ai-ml/nlp-toolkit-guide/SKILL.md +247 -0
  59. package/skills/domains/ai-ml/pytorch-guide/SKILL.md +281 -0
  60. package/skills/domains/ai-ml/pytorch-lightning-guide/SKILL.md +244 -0
  61. package/skills/domains/ai-ml/tensorflow-guide/SKILL.md +241 -0
  62. package/skills/domains/biomedical/bioagents-guide/SKILL.md +308 -0
  63. package/skills/domains/biomedical/medgeclaw-guide/SKILL.md +345 -0
  64. package/skills/domains/biomedical/medical-imaging-guide/SKILL.md +305 -0
  65. package/skills/domains/business/architecture-design-guide/SKILL.md +279 -0
  66. package/skills/domains/business/innovation-management-guide/SKILL.md +257 -0
  67. package/skills/domains/business/operations-research-guide/SKILL.md +258 -0
  68. package/skills/domains/chemistry/molecular-dynamics-guide/SKILL.md +237 -0
  69. package/skills/domains/chemistry/pubchem-api-guide/SKILL.md +180 -0
  70. package/skills/domains/chemistry/spectroscopy-analysis-guide/SKILL.md +290 -0
  71. package/skills/domains/cs/distributed-systems-guide/SKILL.md +268 -0
  72. package/skills/domains/cs/formal-verification-guide/SKILL.md +298 -0
  73. package/skills/domains/ecology/species-distribution-guide/SKILL.md +343 -0
  74. package/skills/domains/economics/imf-data-api-guide/SKILL.md +174 -0
  75. package/skills/domains/economics/post-labor-economics/SKILL.md +254 -0
  76. package/skills/domains/economics/pricing-psychology-guide/SKILL.md +273 -0
  77. package/skills/domains/economics/world-bank-data-guide/SKILL.md +179 -0
  78. package/skills/domains/education/assessment-design-guide/SKILL.md +213 -0
  79. package/skills/domains/education/educational-research-methods/SKILL.md +179 -0
  80. package/skills/domains/education/mooc-analytics-guide/SKILL.md +206 -0
  81. package/skills/domains/finance/portfolio-optimization-guide/SKILL.md +279 -0
  82. package/skills/domains/finance/risk-modeling-guide/SKILL.md +260 -0
  83. package/skills/domains/finance/stata-accounting-research/SKILL.md +372 -0
  84. package/skills/domains/geoscience/climate-modeling-guide/SKILL.md +215 -0
  85. package/skills/domains/geoscience/satellite-remote-sensing/SKILL.md +193 -0
  86. package/skills/domains/geoscience/seismology-data-guide/SKILL.md +208 -0
  87. package/skills/domains/humanities/ethical-philosophy-guide/SKILL.md +244 -0
  88. package/skills/domains/humanities/history-research-guide/SKILL.md +260 -0
  89. package/skills/domains/humanities/political-history-guide/SKILL.md +241 -0
  90. package/skills/domains/law/legal-nlp-guide/SKILL.md +236 -0
  91. package/skills/domains/law/patent-analysis-guide/SKILL.md +257 -0
  92. package/skills/domains/law/regulatory-compliance-guide/SKILL.md +267 -0
  93. package/skills/domains/math/symbolic-computation-guide/SKILL.md +263 -0
  94. package/skills/domains/math/topology-data-analysis/SKILL.md +305 -0
  95. package/skills/domains/pharma/clinical-trial-design-guide/SKILL.md +271 -0
  96. package/skills/domains/pharma/drug-target-interaction/SKILL.md +242 -0
  97. package/skills/domains/pharma/pharmacovigilance-guide/SKILL.md +216 -0
  98. package/skills/domains/physics/astrophysics-data-guide/SKILL.md +305 -0
  99. package/skills/domains/physics/particle-physics-guide/SKILL.md +287 -0
  100. package/skills/domains/social-science/network-analysis-guide/SKILL.md +310 -0
  101. package/skills/domains/social-science/psychology-research-guide/SKILL.md +270 -0
  102. package/skills/domains/social-science/sociology-research-guide/SKILL.md +238 -0
  103. package/skills/literature/discovery/paper-recommendation-guide/SKILL.md +120 -0
  104. package/skills/literature/discovery/semantic-paper-radar/SKILL.md +144 -0
  105. package/skills/literature/discovery/zotero-arxiv-daily-guide/SKILL.md +94 -0
  106. package/skills/literature/fulltext/core-api-guide/SKILL.md +144 -0
  107. package/skills/literature/fulltext/institutional-repository-guide/SKILL.md +212 -0
  108. package/skills/literature/fulltext/open-access-mining-guide/SKILL.md +341 -0
  109. package/skills/literature/metadata/academic-paper-summarizer/SKILL.md +101 -0
  110. package/skills/literature/metadata/wikidata-api-guide/SKILL.md +156 -0
  111. package/skills/literature/search/arxiv-batch-reporting/SKILL.md +133 -0
  112. package/skills/literature/search/arxiv-paper-processor/SKILL.md +141 -0
  113. package/skills/literature/search/baidu-scholar-guide/SKILL.md +110 -0
  114. package/skills/literature/search/chatpaper-guide/SKILL.md +122 -0
  115. package/skills/literature/search/deep-literature-search/SKILL.md +149 -0
  116. package/skills/literature/search/deepgit-search-guide/SKILL.md +147 -0
  117. package/skills/literature/search/pasa-paper-search-guide/SKILL.md +138 -0
  118. package/skills/research/automation/ai-scientist-v2-guide/SKILL.md +284 -0
  119. package/skills/research/automation/aim-experiment-guide/SKILL.md +234 -0
  120. package/skills/research/automation/datagen-research-guide/SKILL.md +131 -0
  121. package/skills/research/automation/kedro-pipeline-guide/SKILL.md +216 -0
  122. package/skills/research/automation/mle-agent-guide/SKILL.md +139 -0
  123. package/skills/research/automation/paper-to-agent-guide/SKILL.md +116 -0
  124. package/skills/research/automation/rd-agent-guide/SKILL.md +246 -0
  125. package/skills/research/automation/research-paper-orchestrator/SKILL.md +254 -0
  126. package/skills/research/deep-research/academic-deep-research/SKILL.md +190 -0
  127. package/skills/research/deep-research/auto-deep-research-guide/SKILL.md +141 -0
  128. package/skills/research/deep-research/deep-research-pro/SKILL.md +213 -0
  129. package/skills/research/deep-research/deep-research-work/SKILL.md +204 -0
  130. package/skills/research/deep-research/deep-searcher-guide/SKILL.md +253 -0
  131. package/skills/research/deep-research/gpt-researcher-guide/SKILL.md +191 -0
  132. package/skills/research/deep-research/khoj-research-guide/SKILL.md +200 -0
  133. package/skills/research/deep-research/local-deep-research-guide/SKILL.md +253 -0
  134. package/skills/research/deep-research/tongyi-deep-research-guide/SKILL.md +217 -0
  135. package/skills/research/funding/eu-horizon-guide/SKILL.md +244 -0
  136. package/skills/research/funding/grant-budget-guide/SKILL.md +284 -0
  137. package/skills/research/funding/nih-reporter-api-guide/SKILL.md +166 -0
  138. package/skills/research/funding/nsf-award-api-guide/SKILL.md +133 -0
  139. package/skills/research/methodology/academic-mentor-guide/SKILL.md +169 -0
  140. package/skills/research/methodology/claude-scientific-guide/SKILL.md +122 -0
  141. package/skills/research/methodology/deep-innovator-guide/SKILL.md +242 -0
  142. package/skills/research/methodology/osf-api-guide/SKILL.md +165 -0
  143. package/skills/research/methodology/research-paper-kb/SKILL.md +263 -0
  144. package/skills/research/methodology/research-town-guide/SKILL.md +263 -0
  145. package/skills/research/paper-review/automated-review-guide/SKILL.md +281 -0
  146. package/skills/research/paper-review/paper-compare-guide/SKILL.md +238 -0
  147. package/skills/research/paper-review/paper-digest-guide/SKILL.md +240 -0
  148. package/skills/research/paper-review/paper-research-assistant/SKILL.md +231 -0
  149. package/skills/research/paper-review/research-quality-filter/SKILL.md +261 -0
  150. package/skills/research/paper-review/review-response-guide/SKILL.md +275 -0
  151. package/skills/tools/code-exec/google-colab-guide/SKILL.md +276 -0
  152. package/skills/tools/code-exec/kaggle-api-guide/SKILL.md +216 -0
  153. package/skills/tools/code-exec/overleaf-cli-guide/SKILL.md +279 -0
  154. package/skills/tools/diagram/code-flow-visualizer/SKILL.md +197 -0
  155. package/skills/tools/diagram/excalidraw-diagram-guide/SKILL.md +170 -0
  156. package/skills/tools/diagram/json-data-visualizer/SKILL.md +270 -0
  157. package/skills/tools/diagram/mermaid-architect-guide/SKILL.md +219 -0
  158. package/skills/tools/diagram/tldraw-whiteboard-guide/SKILL.md +397 -0
  159. package/skills/tools/document/docsgpt-guide/SKILL.md +130 -0
  160. package/skills/tools/document/large-document-reader/SKILL.md +202 -0
  161. package/skills/tools/document/paper-parse-guide/SKILL.md +243 -0
  162. package/skills/tools/knowledge-graph/citation-network-builder/SKILL.md +244 -0
  163. package/skills/tools/knowledge-graph/concept-map-generator/SKILL.md +284 -0
  164. package/skills/tools/knowledge-graph/graphiti-guide/SKILL.md +219 -0
  165. package/skills/tools/ocr-translate/pdf-math-translate-guide/SKILL.md +141 -0
  166. package/skills/tools/ocr-translate/zotero-pdf-translate-guide/SKILL.md +95 -0
  167. package/skills/tools/ocr-translate/zotero-pdf2zh-guide/SKILL.md +143 -0
  168. package/skills/tools/scraping/dataset-finder-guide/SKILL.md +253 -0
  169. package/skills/tools/scraping/easy-spider-guide/SKILL.md +250 -0
  170. package/skills/tools/scraping/google-scholar-scraper/SKILL.md +255 -0
  171. package/skills/tools/scraping/repository-harvesting-guide/SKILL.md +310 -0
  172. package/skills/writing/citation/academic-citation-manager/SKILL.md +314 -0
  173. package/skills/writing/citation/jabref-reference-guide/SKILL.md +127 -0
  174. package/skills/writing/citation/jasminum-zotero-guide/SKILL.md +103 -0
  175. package/skills/writing/citation/obsidian-citation-guide/SKILL.md +164 -0
  176. package/skills/writing/citation/obsidian-zotero-guide/SKILL.md +137 -0
  177. package/skills/writing/citation/papersgpt-zotero-guide/SKILL.md +132 -0
  178. package/skills/writing/citation/papis-cli-guide/SKILL.md +213 -0
  179. package/skills/writing/citation/zotero-better-bibtex-guide/SKILL.md +107 -0
  180. package/skills/writing/citation/zotero-better-notes-guide/SKILL.md +121 -0
  181. package/skills/writing/citation/zotero-gpt-guide/SKILL.md +111 -0
  182. package/skills/writing/citation/zotero-mcp-guide/SKILL.md +164 -0
  183. package/skills/writing/citation/zotero-mdnotes-guide/SKILL.md +162 -0
  184. package/skills/writing/citation/zotero-reference-guide/SKILL.md +139 -0
  185. package/skills/writing/citation/zotero-scholar-guide/SKILL.md +294 -0
  186. package/skills/writing/citation/zotfile-attachment-guide/SKILL.md +140 -0
  187. package/skills/writing/composition/ml-paper-writing/SKILL.md +163 -0
  188. package/skills/writing/composition/paper-debugger-guide/SKILL.md +143 -0
  189. package/skills/writing/composition/scientific-writing-resources/SKILL.md +151 -0
  190. package/skills/writing/composition/scientific-writing-wrapper/SKILL.md +153 -0
  191. package/skills/writing/latex/latex-drawing-collection/SKILL.md +154 -0
  192. package/skills/writing/latex/latex-templates-collection/SKILL.md +159 -0
  193. package/skills/writing/latex/md-to-pdf-academic/SKILL.md +230 -0
  194. package/skills/writing/latex/tex-render-guide/SKILL.md +243 -0
  195. package/skills/writing/polish/academic-tone-guide/SKILL.md +209 -0
  196. package/skills/writing/polish/conciseness-editing-guide/SKILL.md +225 -0
  197. package/skills/writing/polish/paper-polish-guide/SKILL.md +160 -0
  198. package/skills/writing/templates/graphical-abstract-guide/SKILL.md +183 -0
  199. package/skills/writing/templates/novathesis-guide/SKILL.md +152 -0
  200. package/skills/writing/templates/scientific-article-pdf/SKILL.md +261 -0
  201. package/skills/writing/templates/sjtuthesis-guide/SKILL.md +197 -0
  202. package/skills/writing/templates/thuthesis-guide/SKILL.md +181 -0
  203. package/skills/literature/fulltext/repository-harvesting-guide/SKILL.md +0 -207
@@ -0,0 +1,298 @@
1
+ ---
2
+ name: formal-verification-guide
3
+ description: "Formal methods, theorem proving, and model checking for CS research"
4
+ metadata:
5
+ openclaw:
6
+ emoji: "check-mark"
7
+ category: "domains"
8
+ subcategory: "cs"
9
+ keywords: ["formal-verification", "theorem-proving", "model-checking", "tla-plus", "coq", "isabelle"]
10
+ source: "wentor"
11
+ ---
12
+
13
+ # Formal Verification Guide
14
+
15
+ A skill for applying formal methods to verify software and hardware correctness. Covers model checking, interactive theorem proving, specification languages, and practical verification workflows used in systems and programming language research.
16
+
17
+ ## Verification Approaches Overview
18
+
19
+ ### Methods Comparison
20
+
21
+ | Approach | Technique | Strengths | Limitations |
22
+ |----------|-----------|-----------|-------------|
23
+ | Model checking | Exhaustive state exploration | Fully automatic, produces counterexamples | State space explosion |
24
+ | Theorem proving | Interactive proof construction | Handles infinite state | Requires expert effort |
25
+ | Abstract interpretation | Sound static analysis | Automatic, scales well | May report false positives |
26
+ | SMT solving | Constraint satisfiability | Powerful automation | Limited to decidable theories |
27
+ | Runtime verification | Execution monitoring | Low barrier, practical | Only checks observed runs |
28
+
29
+ ## TLA+ Specification
30
+
31
+ ### Specifying Distributed Protocols
32
+
33
+ TLA+ is the standard specification language for distributed systems:
34
+
35
+ ```tla
36
+ --------------------------- MODULE TwoPhaseCommit -------------------------
37
+ EXTENDS Integers, Sequences, FiniteSets
38
+
39
+ CONSTANTS RM \* Set of resource managers
40
+
41
+ VARIABLES
42
+ rmState, \* rmState[r] is the state of resource manager r
43
+ tmState, \* State of the transaction manager
44
+ tmPrepared, \* Set of RMs that have sent "Prepared"
45
+ msgs \* Set of messages sent
46
+
47
+ vars == <<rmState, tmState, tmPrepared, msgs>>
48
+
49
+ Init ==
50
+ /\ rmState = [r \in RM |-> "working"]
51
+ /\ tmState = "init"
52
+ /\ tmPrepared = {}
53
+ /\ msgs = {}
54
+
55
+ \* RM r prepares to commit
56
+ RMPrepare(r) ==
57
+ /\ rmState[r] = "working"
58
+ /\ rmState' = [rmState EXCEPT ![r] = "prepared"]
59
+ /\ msgs' = msgs \union {[type |-> "Prepared", rm |-> r]}
60
+ /\ UNCHANGED <<tmState, tmPrepared>>
61
+
62
+ \* TM receives a Prepared message from RM r
63
+ TMRcvPrepared(r) ==
64
+ /\ tmState = "init"
65
+ /\ [type |-> "Prepared", rm |-> r] \in msgs
66
+ /\ tmPrepared' = tmPrepared \union {r}
67
+ /\ UNCHANGED <<rmState, tmState, msgs>>
68
+
69
+ \* TM commits (all RMs have prepared)
70
+ TMCommit ==
71
+ /\ tmState = "init"
72
+ /\ tmPrepared = RM
73
+ /\ tmState' = "committed"
74
+ /\ msgs' = msgs \union {[type |-> "Commit"]}
75
+ /\ UNCHANGED <<rmState, tmPrepared>>
76
+
77
+ \* Safety property: No RM commits unless TM has committed
78
+ Consistency ==
79
+ \A r \in RM : rmState[r] = "committed" => tmState = "committed"
80
+ ========================================================================
81
+ ```
82
+
83
+ ### Running the TLC Model Checker
84
+
85
+ ```bash
86
+ # Install TLA+ Toolbox or use command-line TLC
87
+ # Define model with specific constants
88
+ # RM = {"rm1", "rm2", "rm3"}
89
+ java -jar tla2tools.jar -config TwoPhaseCommit.cfg TwoPhaseCommit.tla
90
+
91
+ # TLC will explore all reachable states and verify:
92
+ # - No deadlocks (unless specified)
93
+ # - Safety properties (invariants)
94
+ # - Liveness properties (temporal formulas)
95
+ ```
96
+
97
+ ## Interactive Theorem Proving
98
+
99
+ ### Coq Proof Assistant
100
+
101
+ ```coq
102
+ (* Example: Proving properties of a simple functional program *)
103
+
104
+ (* Define natural number addition *)
105
+ Fixpoint add (n m : nat) : nat :=
106
+ match n with
107
+ | O => m
108
+ | S n' => S (add n' m)
109
+ end.
110
+
111
+ (* Prove: 0 + n = n (left identity) *)
112
+ Theorem add_0_l : forall n : nat, add 0 n = n.
113
+ Proof.
114
+ intro n.
115
+ simpl. (* simplification reduces add 0 n to n *)
116
+ reflexivity.
117
+ Qed.
118
+
119
+ (* Prove: n + 0 = n (right identity, requires induction) *)
120
+ Theorem add_0_r : forall n : nat, add n 0 = n.
121
+ Proof.
122
+ intro n.
123
+ induction n as [| n' IHn'].
124
+ - (* Base case: n = 0 *)
125
+ simpl. reflexivity.
126
+ - (* Inductive step: n = S n' *)
127
+ simpl. (* add (S n') 0 = S (add n' 0) *)
128
+ rewrite IHn'. (* apply induction hypothesis *)
129
+ reflexivity.
130
+ Qed.
131
+
132
+ (* Prove associativity of addition *)
133
+ Theorem add_assoc : forall a b c : nat,
134
+ add a (add b c) = add (add a b) c.
135
+ Proof.
136
+ intros a b c.
137
+ induction a as [| a' IHa'].
138
+ - simpl. reflexivity.
139
+ - simpl. rewrite IHa'. reflexivity.
140
+ Qed.
141
+ ```
142
+
143
+ ### Isabelle/HOL
144
+
145
+ ```isabelle
146
+ theory SimpleVerification
147
+ imports Main
148
+ begin
149
+
150
+ (* Define a recursive function *)
151
+ fun fib :: "nat => nat" where
152
+ "fib 0 = 0"
153
+ | "fib (Suc 0) = 1"
154
+ | "fib (Suc (Suc n)) = fib (Suc n) + fib n"
155
+
156
+ (* Prove a property *)
157
+ lemma fib_positive: "0 < fib (Suc n)"
158
+ by (induction n rule: fib.induct) auto
159
+
160
+ (* Verify a sorting algorithm *)
161
+ fun insert :: "nat => nat list => nat list" where
162
+ "insert x [] = [x]"
163
+ | "insert x (y # ys) = (if x <= y then x # y # ys else y # insert x ys)"
164
+
165
+ fun isort :: "nat list => nat list" where
166
+ "isort [] = []"
167
+ | "isort (x # xs) = insert x (isort xs)"
168
+
169
+ (* Prove the output is sorted *)
170
+ lemma sorted_insert: "sorted (insert x xs) = sorted xs"
171
+ sorry (* full proof requires additional lemmas *)
172
+
173
+ end
174
+ ```
175
+
176
+ ## SMT Solving
177
+
178
+ ### Z3 for Program Verification
179
+
180
+ ```python
181
+ from z3 import Solver, Int, Bool, And, Or, Not, Implies, ForAll, sat, unsat
182
+
183
+ def verify_array_bounds():
184
+ """
185
+ Verify that an array access is always within bounds.
186
+ Model a loop: for i = 0 to n-1, access a[i].
187
+ """
188
+ s = Solver()
189
+ n = Int("n")
190
+ i = Int("i")
191
+
192
+ # Precondition: n > 0
193
+ s.add(n > 0)
194
+
195
+ # Loop invariant: 0 <= i < n at each access
196
+ s.add(i >= 0)
197
+ s.add(i < n)
198
+
199
+ # Verify: the access a[i] is within bounds [0, n)
200
+ s.add(Not(And(i >= 0, i < n))) # try to find a violation
201
+
202
+ result = s.check()
203
+ if result == unsat:
204
+ return "VERIFIED: array access is always within bounds"
205
+ else:
206
+ return f"COUNTEREXAMPLE: {s.model()}"
207
+
208
+ def verify_integer_overflow():
209
+ """
210
+ Check if integer addition can overflow for given constraints.
211
+ """
212
+ from z3 import BitVec, BitVecVal
213
+
214
+ s = Solver()
215
+ # 32-bit signed integers
216
+ x = BitVec("x", 32)
217
+ y = BitVec("y", 32)
218
+
219
+ # Preconditions: both positive
220
+ s.add(x > 0)
221
+ s.add(y > 0)
222
+
223
+ # Check: can x + y wrap around to negative?
224
+ s.add(x + y < 0)
225
+
226
+ if s.check() == sat:
227
+ m = s.model()
228
+ return {
229
+ "overflow_possible": True,
230
+ "x": m[x].as_long(),
231
+ "y": m[y].as_long(),
232
+ }
233
+ return {"overflow_possible": False}
234
+ ```
235
+
236
+ ## Model Checking with SPIN
237
+
238
+ ### Promela Specification
239
+
240
+ ```promela
241
+ /* Mutual exclusion with Peterson's algorithm */
242
+ bool flag[2] = false;
243
+ byte turn = 0;
244
+ byte critical = 0; /* count of processes in critical section */
245
+
246
+ active [2] proctype process() {
247
+ byte me = _pid;
248
+ byte other = 1 - _pid;
249
+
250
+ do
251
+ :: /* Entry protocol */
252
+ flag[me] = true;
253
+ turn = other;
254
+ (flag[other] == false || turn == me);
255
+
256
+ /* Critical section */
257
+ critical++;
258
+ assert(critical == 1); /* mutual exclusion */
259
+ critical--;
260
+
261
+ /* Exit protocol */
262
+ flag[me] = false;
263
+ od
264
+ }
265
+
266
+ /* LTL property: mutual exclusion always holds */
267
+ ltl mutex { [] (critical <= 1) }
268
+ ```
269
+
270
+ ## Verification Workflow
271
+
272
+ ### Practical Verification Strategy
273
+
274
+ 1. **Specify**: Write a formal specification of the desired property
275
+ 2. **Model**: Create an abstract model of the system
276
+ 3. **Verify**: Run model checker or construct proof
277
+ 4. **Refine**: If counterexample found, fix the design or refine the model
278
+ 5. **Extract**: Generate verified code from the proof (Coq extraction, Isabelle code generation)
279
+
280
+ ### Common Properties to Verify
281
+
282
+ | Property Type | Example | Specification Pattern |
283
+ |--------------|---------|----------------------|
284
+ | Safety | "No two processes in critical section" | `[] (count <= 1)` |
285
+ | Liveness | "Every request is eventually served" | `[] (request -> <> response)` |
286
+ | Deadlock freedom | "System always has an enabled transition" | `[] <> enabled` |
287
+ | Termination | "Program always halts" | Well-founded ordering |
288
+
289
+ ## Tools and Resources
290
+
291
+ - **TLA+ Toolbox**: IDE for TLA+ with integrated TLC model checker
292
+ - **Coq**: Interactive theorem prover with program extraction
293
+ - **Isabelle/HOL**: Higher-order logic prover with Sledgehammer automation
294
+ - **Z3 / CVC5**: SMT solvers for automated reasoning
295
+ - **SPIN**: Model checker for concurrent systems (Promela)
296
+ - **CBMC**: Bounded model checker for C programs
297
+ - **Dafny**: Verification-aware programming language (Microsoft)
298
+ - **Lean 4**: Modern theorem prover and programming language
@@ -0,0 +1,343 @@
1
+ ---
2
+ name: species-distribution-guide
3
+ description: "Species distribution modeling with MaxEnt, SDM methods, and GBIF data"
4
+ metadata:
5
+ openclaw:
6
+ emoji: "paw-prints"
7
+ category: "domains"
8
+ subcategory: "ecology"
9
+ keywords: ["species-distribution", "maxent", "sdm", "gbif", "ecological-niche", "biodiversity", "habitat"]
10
+ source: "wentor"
11
+ ---
12
+
13
+ # Species Distribution Modeling Guide
14
+
15
+ A skill for building and evaluating species distribution models (SDMs), covering occurrence data acquisition from biodiversity databases, environmental predictor preparation, model fitting with MaxEnt and ensemble methods, model evaluation, and projection under climate change scenarios.
16
+
17
+ ## Occurrence Data
18
+
19
+ ### Accessing GBIF Data
20
+
21
+ The Global Biodiversity Information Facility (GBIF) is the primary source of species occurrence records:
22
+
23
+ ```python
24
+ from pygbif import occurrences, species
25
+
26
+ def download_occurrences(species_name: str, country: str = None,
27
+ limit: int = 5000,
28
+ has_coordinate: bool = True) -> dict:
29
+ """
30
+ Download species occurrence records from GBIF.
31
+ species_name: scientific name (e.g., 'Panthera tigris')
32
+ Returns cleaned occurrence records with coordinates.
33
+ """
34
+ # Get GBIF species key
35
+ name_result = species.name_backbone(name=species_name)
36
+ if "usageKey" not in name_result:
37
+ return {"error": f"Species not found: {species_name}"}
38
+
39
+ species_key = name_result["usageKey"]
40
+
41
+ # Search occurrences
42
+ params = {
43
+ "taxonKey": species_key,
44
+ "hasCoordinate": has_coordinate,
45
+ "hasGeospatialIssue": False,
46
+ "limit": limit,
47
+ }
48
+ if country:
49
+ params["country"] = country
50
+
51
+ results = occurrences.search(**params)
52
+
53
+ # Clean records
54
+ records = []
55
+ seen_coords = set()
56
+ for rec in results.get("results", []):
57
+ lat = rec.get("decimalLatitude")
58
+ lon = rec.get("decimalLongitude")
59
+ if lat is None or lon is None:
60
+ continue
61
+
62
+ # Remove exact duplicates
63
+ coord_key = (round(lat, 4), round(lon, 4))
64
+ if coord_key in seen_coords:
65
+ continue
66
+ seen_coords.add(coord_key)
67
+
68
+ records.append({
69
+ "species": rec.get("species", species_name),
70
+ "latitude": lat,
71
+ "longitude": lon,
72
+ "year": rec.get("year"),
73
+ "basis_of_record": rec.get("basisOfRecord"),
74
+ "institution": rec.get("institutionCode"),
75
+ "country": rec.get("country"),
76
+ })
77
+
78
+ return {
79
+ "species": species_name,
80
+ "gbif_key": species_key,
81
+ "n_records": len(records),
82
+ "records": records,
83
+ }
84
+ ```
85
+
86
+ ### Data Cleaning for SDM
87
+
88
+ ```python
89
+ import pandas as pd
90
+ import numpy as np
91
+
92
+ def clean_occurrences(records: pd.DataFrame,
93
+ study_extent: dict = None,
94
+ thin_distance_km: float = 10.0) -> pd.DataFrame:
95
+ """
96
+ Clean occurrence records for species distribution modeling.
97
+ Removes outliers, duplicates, and applies spatial thinning.
98
+
99
+ study_extent: {min_lon, max_lon, min_lat, max_lat}
100
+ thin_distance_km: minimum distance between retained points
101
+ """
102
+ df = records.copy()
103
+
104
+ # Remove records with missing coordinates
105
+ df = df.dropna(subset=["latitude", "longitude"])
106
+
107
+ # Remove records at (0,0) -- common data error
108
+ df = df[~((df.latitude == 0) & (df.longitude == 0))]
109
+
110
+ # Clip to study extent
111
+ if study_extent:
112
+ df = df[
113
+ (df.longitude >= study_extent["min_lon"]) &
114
+ (df.longitude <= study_extent["max_lon"]) &
115
+ (df.latitude >= study_extent["min_lat"]) &
116
+ (df.latitude <= study_extent["max_lat"])
117
+ ]
118
+
119
+ # Spatial thinning (grid-based)
120
+ # Convert thinning distance to approximate degrees
121
+ thin_deg = thin_distance_km / 111.0
122
+ df["grid_x"] = (df.longitude / thin_deg).astype(int)
123
+ df["grid_y"] = (df.latitude / thin_deg).astype(int)
124
+ df = df.drop_duplicates(subset=["grid_x", "grid_y"])
125
+ df = df.drop(columns=["grid_x", "grid_y"])
126
+
127
+ return df.reset_index(drop=True)
128
+ ```
129
+
130
+ ## Environmental Predictors
131
+
132
+ ### WorldClim Bioclimatic Variables
133
+
134
+ The standard predictor set for SDMs:
135
+
136
+ | Variable | Description | Unit |
137
+ |----------|-------------|------|
138
+ | BIO1 | Annual Mean Temperature | C x 10 |
139
+ | BIO2 | Mean Diurnal Range | C x 10 |
140
+ | BIO4 | Temperature Seasonality | SD x 100 |
141
+ | BIO5 | Max Temperature of Warmest Month | C x 10 |
142
+ | BIO6 | Min Temperature of Coldest Month | C x 10 |
143
+ | BIO12 | Annual Precipitation | mm |
144
+ | BIO13 | Precipitation of Wettest Month | mm |
145
+ | BIO14 | Precipitation of Driest Month | mm |
146
+ | BIO15 | Precipitation Seasonality | CV |
147
+
148
+ ### Extracting Environmental Values
149
+
150
+ ```python
151
+ import rasterio
152
+ from rasterio.sample import sample_gen
153
+
154
+ def extract_environmental_values(occurrence_coords: np.ndarray,
155
+ raster_paths: dict) -> pd.DataFrame:
156
+ """
157
+ Extract environmental variable values at occurrence locations.
158
+ occurrence_coords: array of (longitude, latitude) pairs
159
+ raster_paths: {variable_name: filepath} for each predictor raster
160
+ """
161
+ env_data = {}
162
+
163
+ for var_name, raster_path in raster_paths.items():
164
+ with rasterio.open(raster_path) as src:
165
+ values = []
166
+ for lon, lat in occurrence_coords:
167
+ row, col = src.index(lon, lat)
168
+ if 0 <= row < src.height and 0 <= col < src.width:
169
+ values.append(float(src.read(1)[row, col]))
170
+ else:
171
+ values.append(np.nan)
172
+ env_data[var_name] = values
173
+
174
+ df = pd.DataFrame(env_data)
175
+ df["longitude"] = occurrence_coords[:, 0]
176
+ df["latitude"] = occurrence_coords[:, 1]
177
+
178
+ # Remove points with nodata values
179
+ df = df.replace(src.nodata, np.nan).dropna()
180
+ return df
181
+ ```
182
+
183
+ ## Model Fitting
184
+
185
+ ### MaxEnt (Maximum Entropy)
186
+
187
+ MaxEnt is the most widely used SDM algorithm for presence-only data:
188
+
189
+ ```python
190
+ import subprocess
191
+
192
+ def run_maxent(samples_csv: str, env_layers_dir: str,
193
+ output_dir: str, features: str = "auto",
194
+ regularization: float = 1.0,
195
+ n_background: int = 10000) -> dict:
196
+ """
197
+ Run MaxEnt species distribution model.
198
+ samples_csv: CSV with columns species, longitude, latitude
199
+ env_layers_dir: directory containing .asc raster files
200
+ output_dir: directory for model outputs
201
+ """
202
+ cmd = [
203
+ "java", "-jar", "maxent.jar",
204
+ "-s", samples_csv,
205
+ "-e", env_layers_dir,
206
+ "-o", output_dir,
207
+ f"betamultiplier={regularization}",
208
+ f"maximumbackground={n_background}",
209
+ "responsecurves=true",
210
+ "jackknife=true",
211
+ "writeplotdata=true",
212
+ "autorun=true",
213
+ ]
214
+
215
+ result = subprocess.run(cmd, capture_output=True, text=True)
216
+
217
+ # Parse results from maxentResults.csv
218
+ import csv
219
+ results_file = f"{output_dir}/maxentResults.csv"
220
+ with open(results_file) as f:
221
+ reader = csv.DictReader(f)
222
+ row = next(reader)
223
+
224
+ return {
225
+ "training_auc": float(row.get("Training AUC", 0)),
226
+ "test_auc": float(row.get("Test AUC", 0)),
227
+ "n_training": int(row.get("X Training samples", 0)),
228
+ "regularized_gain": float(row.get("Regularized training gain", 0)),
229
+ "important_variables": row.get("Percent contribution", ""),
230
+ }
231
+ ```
232
+
233
+ ### Ensemble SDM with Python
234
+
235
+ ```python
236
+ from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
237
+ from sklearn.linear_model import LogisticRegression
238
+ from sklearn.model_selection import cross_val_predict
239
+ from sklearn.metrics import roc_auc_score
240
+
241
+ def ensemble_sdm(presence_env: pd.DataFrame,
242
+ background_env: pd.DataFrame,
243
+ predictor_cols: list[str]) -> dict:
244
+ """
245
+ Build an ensemble SDM from multiple algorithms.
246
+ presence_env: environmental values at presence points
247
+ background_env: environmental values at background/pseudo-absence points
248
+ """
249
+ # Prepare data
250
+ X_pres = presence_env[predictor_cols].values
251
+ X_bg = background_env[predictor_cols].values
252
+ X = np.vstack([X_pres, X_bg])
253
+ y = np.concatenate([np.ones(len(X_pres)), np.zeros(len(X_bg))])
254
+
255
+ models = {
256
+ "random_forest": RandomForestClassifier(n_estimators=500, max_depth=10),
257
+ "gbm": GradientBoostingClassifier(n_estimators=300, max_depth=5,
258
+ learning_rate=0.05),
259
+ "logistic": LogisticRegression(max_iter=1000),
260
+ }
261
+
262
+ results = {}
263
+ predictions = {}
264
+
265
+ for name, model in models.items():
266
+ # Cross-validated predictions
267
+ cv_pred = cross_val_predict(model, X, y, cv=5, method="predict_proba")[:, 1]
268
+ auc = roc_auc_score(y, cv_pred)
269
+
270
+ model.fit(X, y)
271
+ results[name] = {"auc": round(auc, 4), "model": model}
272
+ predictions[name] = cv_pred
273
+
274
+ # Weighted ensemble (weight by AUC)
275
+ total_auc = sum(r["auc"] for r in results.values())
276
+ ensemble_pred = sum(
277
+ predictions[name] * results[name]["auc"] / total_auc
278
+ for name in models
279
+ )
280
+ ensemble_auc = roc_auc_score(y, ensemble_pred)
281
+
282
+ results["ensemble"] = {"auc": round(ensemble_auc, 4)}
283
+ return results
284
+ ```
285
+
286
+ ## Model Evaluation
287
+
288
+ ### Evaluation Metrics for SDMs
289
+
290
+ | Metric | Range | Interpretation |
291
+ |--------|-------|---------------|
292
+ | AUC | 0-1 | Discrimination ability (>0.7 useful, >0.8 good) |
293
+ | TSS (True Skill Statistic) | -1 to 1 | Sensitivity + Specificity - 1 |
294
+ | Boyce Index | -1 to 1 | Predicted-to-expected ratio consistency |
295
+ | Kappa | -1 to 1 | Agreement beyond chance |
296
+
297
+ ```python
298
+ def compute_tss(y_true: np.ndarray, y_pred_proba: np.ndarray) -> dict:
299
+ """
300
+ Compute TSS (True Skill Statistic) at the optimal threshold.
301
+ TSS = Sensitivity + Specificity - 1
302
+ """
303
+ from sklearn.metrics import roc_curve
304
+
305
+ fpr, tpr, thresholds = roc_curve(y_true, y_pred_proba)
306
+ specificity = 1 - fpr
307
+ tss_values = tpr + specificity - 1
308
+
309
+ optimal_idx = np.argmax(tss_values)
310
+ return {
311
+ "tss": round(tss_values[optimal_idx], 4),
312
+ "optimal_threshold": round(thresholds[optimal_idx], 4),
313
+ "sensitivity": round(tpr[optimal_idx], 4),
314
+ "specificity": round(specificity[optimal_idx], 4),
315
+ }
316
+ ```
317
+
318
+ ## Climate Change Projections
319
+
320
+ ### Projecting Habitat Shifts
321
+
322
+ SDMs can project future suitable habitat under climate scenarios:
323
+
324
+ 1. Fit model on current climate + occurrences
325
+ 2. Obtain future climate rasters (CMIP6 SSP scenarios)
326
+ 3. Predict suitability on future climate surfaces
327
+ 4. Compare current vs future range to quantify shifts
328
+
329
+ Key considerations:
330
+ - Use multiple GCMs to capture model uncertainty
331
+ - Apply clamping for novel climate combinations
332
+ - Report range change metrics: area gained, area lost, centroid shift
333
+
334
+ ## Tools and Resources
335
+
336
+ - **MaxEnt**: Maximum entropy SDM (Java, most cited SDM software)
337
+ - **biomod2 (R)**: Ensemble SDM framework with 10+ algorithms
338
+ - **Wallace (R Shiny)**: Interactive SDM workflow application
339
+ - **pygbif / rgbif**: GBIF data access from Python/R
340
+ - **rasterio / terra**: Raster data handling
341
+ - **WorldClim (worldclim.org)**: Global climate data at 1km resolution
342
+ - **CHELSA**: High-resolution climate data (better for mountainous regions)
343
+ - **eBird**: Citizen science bird occurrence data (Cornell Lab)