├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Makefile ├── README.md ├── ROOT ├── _config.yml ├── _data ├── common_errors.yml ├── common_pitfalls.yml └── lemma_collections.yml ├── _includes └── head-custom.html ├── _layouts └── default.html ├── about.md ├── assets ├── css │ └── style.scss └── images │ ├── Isabelle.jpg │ └── favicon.ico ├── index.md └── src ├── commands ├── Find.thy ├── datatypes │ └── index.md └── index.md ├── common_errors └── index.md ├── common_pitfalls └── index.md ├── general └── index.md ├── proofs ├── finite_sets │ ├── Finite_Sets.thy │ └── index.md ├── index.md ├── lemma_collections.md ├── methods │ ├── Chained_Facts.thy │ └── index.md └── proof_patterns │ └── index.md └── searching_isabelle └── index.md /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build/ 3 | _site/ 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | gem 'github-pages', group: :jekyll_plugins 4 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | activesupport (6.0.4.4) 5 | concurrent-ruby (~> 1.0, >= 1.0.2) 6 | i18n (>= 0.7, < 2) 7 | minitest (~> 5.1) 8 | tzinfo (~> 1.1) 9 | zeitwerk (~> 2.2, >= 2.2.2) 10 | addressable (2.8.0) 11 | public_suffix (>= 2.0.2, < 5.0) 12 | coffee-script (2.4.1) 13 | coffee-script-source 14 | execjs 15 | coffee-script-source (1.11.1) 16 | colorator (1.1.0) 17 | commonmarker (0.17.13) 18 | ruby-enum (~> 0.5) 19 | concurrent-ruby (1.1.9) 20 | dnsruby (1.61.7) 21 | simpleidn (~> 0.1) 22 | em-websocket (0.5.3) 23 | eventmachine (>= 0.12.9) 24 | http_parser.rb (~> 0) 25 | ethon (0.15.0) 26 | ffi (>= 1.15.0) 27 | eventmachine (1.2.7) 28 | execjs (2.8.1) 29 | faraday (1.9.3) 30 | faraday-em_http (~> 1.0) 31 | faraday-em_synchrony (~> 1.0) 32 | faraday-excon (~> 1.1) 33 | faraday-httpclient (~> 1.0) 34 | faraday-multipart (~> 1.0) 35 | faraday-net_http (~> 1.0) 36 | faraday-net_http_persistent (~> 1.0) 37 | faraday-patron (~> 1.0) 38 | faraday-rack (~> 1.0) 39 | faraday-retry (~> 1.0) 40 | ruby2_keywords (>= 0.0.4) 41 | faraday-em_http (1.0.0) 42 | faraday-em_synchrony (1.0.0) 43 | faraday-excon (1.1.0) 44 | faraday-httpclient (1.0.1) 45 | faraday-multipart (1.0.3) 46 | multipart-post (>= 1.2, < 3) 47 | faraday-net_http (1.0.1) 48 | faraday-net_http_persistent (1.2.0) 49 | faraday-patron (1.0.0) 50 | faraday-rack (1.0.0) 51 | faraday-retry (1.0.3) 52 | ffi (1.15.5) 53 | forwardable-extended (2.6.0) 54 | gemoji (3.0.1) 55 | github-pages (223) 56 | github-pages-health-check (= 1.17.9) 57 | jekyll (= 3.9.0) 58 | jekyll-avatar (= 0.7.0) 59 | jekyll-coffeescript (= 1.1.1) 60 | jekyll-commonmark-ghpages (= 0.1.6) 61 | jekyll-default-layout (= 0.1.4) 62 | jekyll-feed (= 0.15.1) 63 | jekyll-gist (= 1.5.0) 64 | jekyll-github-metadata (= 2.13.0) 65 | jekyll-include-cache (= 0.2.1) 66 | jekyll-mentions (= 1.6.0) 67 | jekyll-optional-front-matter (= 0.3.2) 68 | jekyll-paginate (= 1.1.0) 69 | jekyll-readme-index (= 0.3.0) 70 | jekyll-redirect-from (= 0.16.0) 71 | jekyll-relative-links (= 0.6.1) 72 | jekyll-remote-theme (= 0.4.3) 73 | jekyll-sass-converter (= 1.5.2) 74 | jekyll-seo-tag (= 2.7.1) 75 | jekyll-sitemap (= 1.4.0) 76 | jekyll-swiss (= 1.0.0) 77 | jekyll-theme-architect (= 0.2.0) 78 | jekyll-theme-cayman (= 0.2.0) 79 | jekyll-theme-dinky (= 0.2.0) 80 | jekyll-theme-hacker (= 0.2.0) 81 | jekyll-theme-leap-day (= 0.2.0) 82 | jekyll-theme-merlot (= 0.2.0) 83 | jekyll-theme-midnight (= 0.2.0) 84 | jekyll-theme-minimal (= 0.2.0) 85 | jekyll-theme-modernist (= 0.2.0) 86 | jekyll-theme-primer (= 0.6.0) 87 | jekyll-theme-slate (= 0.2.0) 88 | jekyll-theme-tactile (= 0.2.0) 89 | jekyll-theme-time-machine (= 0.2.0) 90 | jekyll-titles-from-headings (= 0.5.3) 91 | jemoji (= 0.12.0) 92 | kramdown (= 2.3.1) 93 | kramdown-parser-gfm (= 1.1.0) 94 | liquid (= 4.0.3) 95 | mercenary (~> 0.3) 96 | minima (= 2.5.1) 97 | nokogiri (>= 1.12.5, < 2.0) 98 | rouge (= 3.26.0) 99 | terminal-table (~> 1.4) 100 | github-pages-health-check (1.17.9) 101 | addressable (~> 2.3) 102 | dnsruby (~> 1.60) 103 | octokit (~> 4.0) 104 | public_suffix (>= 3.0, < 5.0) 105 | typhoeus (~> 1.3) 106 | html-pipeline (2.14.0) 107 | activesupport (>= 2) 108 | nokogiri (>= 1.4) 109 | http_parser.rb (0.8.0) 110 | i18n (0.9.5) 111 | concurrent-ruby (~> 1.0) 112 | jekyll (3.9.0) 113 | addressable (~> 2.4) 114 | colorator (~> 1.0) 115 | em-websocket (~> 0.5) 116 | i18n (~> 0.7) 117 | jekyll-sass-converter (~> 1.0) 118 | jekyll-watch (~> 2.0) 119 | kramdown (>= 1.17, < 3) 120 | liquid (~> 4.0) 121 | mercenary (~> 0.3.3) 122 | pathutil (~> 0.9) 123 | rouge (>= 1.7, < 4) 124 | safe_yaml (~> 1.0) 125 | jekyll-avatar (0.7.0) 126 | jekyll (>= 3.0, < 5.0) 127 | jekyll-coffeescript (1.1.1) 128 | coffee-script (~> 2.2) 129 | coffee-script-source (~> 1.11.1) 130 | jekyll-commonmark (1.3.1) 131 | commonmarker (~> 0.14) 132 | jekyll (>= 3.7, < 5.0) 133 | jekyll-commonmark-ghpages (0.1.6) 134 | commonmarker (~> 0.17.6) 135 | jekyll-commonmark (~> 1.2) 136 | rouge (>= 2.0, < 4.0) 137 | jekyll-default-layout (0.1.4) 138 | jekyll (~> 3.0) 139 | jekyll-feed (0.15.1) 140 | jekyll (>= 3.7, < 5.0) 141 | jekyll-gist (1.5.0) 142 | octokit (~> 4.2) 143 | jekyll-github-metadata (2.13.0) 144 | jekyll (>= 3.4, < 5.0) 145 | octokit (~> 4.0, != 4.4.0) 146 | jekyll-include-cache (0.2.1) 147 | jekyll (>= 3.7, < 5.0) 148 | jekyll-mentions (1.6.0) 149 | html-pipeline (~> 2.3) 150 | jekyll (>= 3.7, < 5.0) 151 | jekyll-optional-front-matter (0.3.2) 152 | jekyll (>= 3.0, < 5.0) 153 | jekyll-paginate (1.1.0) 154 | jekyll-readme-index (0.3.0) 155 | jekyll (>= 3.0, < 5.0) 156 | jekyll-redirect-from (0.16.0) 157 | jekyll (>= 3.3, < 5.0) 158 | jekyll-relative-links (0.6.1) 159 | jekyll (>= 3.3, < 5.0) 160 | jekyll-remote-theme (0.4.3) 161 | addressable (~> 2.0) 162 | jekyll (>= 3.5, < 5.0) 163 | jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) 164 | rubyzip (>= 1.3.0, < 3.0) 165 | jekyll-sass-converter (1.5.2) 166 | sass (~> 3.4) 167 | jekyll-seo-tag (2.7.1) 168 | jekyll (>= 3.8, < 5.0) 169 | jekyll-sitemap (1.4.0) 170 | jekyll (>= 3.7, < 5.0) 171 | jekyll-swiss (1.0.0) 172 | jekyll-theme-architect (0.2.0) 173 | jekyll (> 3.5, < 5.0) 174 | jekyll-seo-tag (~> 2.0) 175 | jekyll-theme-cayman (0.2.0) 176 | jekyll (> 3.5, < 5.0) 177 | jekyll-seo-tag (~> 2.0) 178 | jekyll-theme-dinky (0.2.0) 179 | jekyll (> 3.5, < 5.0) 180 | jekyll-seo-tag (~> 2.0) 181 | jekyll-theme-hacker (0.2.0) 182 | jekyll (> 3.5, < 5.0) 183 | jekyll-seo-tag (~> 2.0) 184 | jekyll-theme-leap-day (0.2.0) 185 | jekyll (> 3.5, < 5.0) 186 | jekyll-seo-tag (~> 2.0) 187 | jekyll-theme-merlot (0.2.0) 188 | jekyll (> 3.5, < 5.0) 189 | jekyll-seo-tag (~> 2.0) 190 | jekyll-theme-midnight (0.2.0) 191 | jekyll (> 3.5, < 5.0) 192 | jekyll-seo-tag (~> 2.0) 193 | jekyll-theme-minimal (0.2.0) 194 | jekyll (> 3.5, < 5.0) 195 | jekyll-seo-tag (~> 2.0) 196 | jekyll-theme-modernist (0.2.0) 197 | jekyll (> 3.5, < 5.0) 198 | jekyll-seo-tag (~> 2.0) 199 | jekyll-theme-primer (0.6.0) 200 | jekyll (> 3.5, < 5.0) 201 | jekyll-github-metadata (~> 2.9) 202 | jekyll-seo-tag (~> 2.0) 203 | jekyll-theme-slate (0.2.0) 204 | jekyll (> 3.5, < 5.0) 205 | jekyll-seo-tag (~> 2.0) 206 | jekyll-theme-tactile (0.2.0) 207 | jekyll (> 3.5, < 5.0) 208 | jekyll-seo-tag (~> 2.0) 209 | jekyll-theme-time-machine (0.2.0) 210 | jekyll (> 3.5, < 5.0) 211 | jekyll-seo-tag (~> 2.0) 212 | jekyll-titles-from-headings (0.5.3) 213 | jekyll (>= 3.3, < 5.0) 214 | jekyll-watch (2.2.1) 215 | listen (~> 3.0) 216 | jemoji (0.12.0) 217 | gemoji (~> 3.0) 218 | html-pipeline (~> 2.2) 219 | jekyll (>= 3.0, < 5.0) 220 | kramdown (2.3.1) 221 | rexml 222 | kramdown-parser-gfm (1.1.0) 223 | kramdown (~> 2.0) 224 | liquid (4.0.3) 225 | listen (3.7.0) 226 | rb-fsevent (~> 0.10, >= 0.10.3) 227 | rb-inotify (~> 0.9, >= 0.9.10) 228 | mercenary (0.3.6) 229 | minima (2.5.1) 230 | jekyll (>= 3.5, < 5.0) 231 | jekyll-feed (~> 0.9) 232 | jekyll-seo-tag (~> 2.1) 233 | minitest (5.15.0) 234 | multipart-post (2.1.1) 235 | nokogiri (1.13.0-x86_64-linux) 236 | racc (~> 1.4) 237 | octokit (4.21.0) 238 | faraday (>= 0.9) 239 | sawyer (~> 0.8.0, >= 0.5.3) 240 | pathutil (0.16.2) 241 | forwardable-extended (~> 2.6) 242 | public_suffix (4.0.6) 243 | racc (1.6.0) 244 | rb-fsevent (0.11.0) 245 | rb-inotify (0.10.1) 246 | ffi (~> 1.0) 247 | rexml (3.2.5) 248 | rouge (3.26.0) 249 | ruby-enum (0.9.0) 250 | i18n 251 | ruby2_keywords (0.0.5) 252 | rubyzip (2.3.2) 253 | safe_yaml (1.0.5) 254 | sass (3.7.4) 255 | sass-listen (~> 4.0.0) 256 | sass-listen (4.0.0) 257 | rb-fsevent (~> 0.9, >= 0.9.4) 258 | rb-inotify (~> 0.9, >= 0.9.7) 259 | sawyer (0.8.2) 260 | addressable (>= 2.3.5) 261 | faraday (> 0.8, < 2.0) 262 | simpleidn (0.2.1) 263 | unf (~> 0.1.4) 264 | terminal-table (1.8.0) 265 | unicode-display_width (~> 1.1, >= 1.1.1) 266 | thread_safe (0.3.6) 267 | typhoeus (1.4.0) 268 | ethon (>= 0.9.0) 269 | tzinfo (1.2.9) 270 | thread_safe (~> 0.1) 271 | unf (0.1.4) 272 | unf_ext 273 | unf_ext (0.0.8) 274 | unicode-display_width (1.8.0) 275 | zeitwerk (2.5.3) 276 | 277 | PLATFORMS 278 | x86_64-linux 279 | 280 | DEPENDENCIES 281 | github-pages 282 | 283 | BUNDLED WITH 284 | 2.2.28 285 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all browse clean 2 | 3 | OBJDIR := build 4 | 5 | all: $(OBJDIR)/index.html 6 | 7 | $(OBJDIR)/index.html: $(wildcard src/**/*.thy) $(wildcard src/**/*.md) 8 | isabelle build -o browser_info -d . -v Index 9 | cp -r "$$(isabelle getenv -b ISABELLE_BROWSER_INFO)/Unsorted/Index/." $(OBJDIR)/ 10 | chmod -R u+w $(OBJDIR)/fonts 11 | 12 | browse: $(OBJDIR)/index.html 13 | xdg-open $< 14 | 15 | clean: 16 | rm -rf $(OBJDIR) 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Isabelle Community Cookbook 2 | 3 | ## What is this? 4 | 5 | This repository contains the resources for the [isabelle community cookbook](https://isabelle.systems/cookbook). 6 | The cookbook contains a collection of useful tips/tricks/hints 7 | for Isabelle users. 8 | 9 | ## How to contribute 10 | 11 | If you want to add/udpdate an entry, simply add/edit the corresponding entry in the corresponding directory and create a pull request. 12 | If you need help, simply create an [issue](https://github.com/isabelle-prover/cookbook/issues). 13 | 14 | ## Build site locally 15 | 16 | To build and view the website locally, see [here](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll). 17 | 18 | ## TODO 19 | - Add CI and html output for linked theory files (cf current Makefile) 20 | - Move material from [https://isabelle.in.tum.de/community/](https://isabelle.in.tum.de/community/) 21 | - Recipes for proving existential statements 22 | - Primer on conversions 23 | - Latex tips 24 | - Debugging ML code (`print_tac`, `print` antiquotation, debugger etc.) 25 | - Overview of different tactics (should also include `rewrite` etc.) 26 | - Difference between methods and tactics 27 | - Namespacing of operators and more with bundles 28 | - Function package tutorial 29 | - Isabelle/jEdit FAQ. For instance: how do I get symbols to display properly? 30 | -------------------------------------------------------------------------------- /ROOT: -------------------------------------------------------------------------------- 1 | session Index = HOL + 2 | options [browser_info] 3 | sessions 4 | "HOL-Library" 5 | directories 6 | "src/commands/" 7 | "src/proofs/finite_sets/" 8 | "src/proofs/methods/" 9 | theories 10 | (*src/commands/*) 11 | "Find" 12 | 13 | (*src/proofs/*) 14 | (*finite_sets/*) 15 | "Finite_Sets" 16 | (*methods/*) 17 | "Chained_Facts" 18 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | title: Isabelle Community Cookbook 3 | markdown: GFM 4 | logo: /assets/images/Isabelle.jpg 5 | -------------------------------------------------------------------------------- /_data/common_errors.yml: -------------------------------------------------------------------------------- 1 | - error_msg: > 2 | exception TYPE raised (line XXX of "envir.ML"): expand_atom: ill-typed replacement 3 | explanation: | 4 | This error can occur if you bind and use a pattern in a lemma statement, e.g. 5 | 6 | ``` 7 | lemma assumes "P foo" (is "P ?bar") shows "Q ?bar" 8 | ``` 9 | 10 | This is due to the fact that parsing and type inference for the whole lemma statement is done at once. 11 | 12 | **Fix:** 13 | Sufficiently verbose type annotations might help, e.g. 14 | 15 | ``` 16 | lemma assumes "P (foo ::'a)" (is "P ?bar") shows "Q (?bar :: 'a)" 17 | ``` 18 | - error_msg: > 19 | Bad Name: "t :: T" 20 | explanation: | 21 | When typing a definition and using type annotations at the wrong position, as in: 22 | 23 | ``` 24 | definition "a :: bool" where "a ≡ False" 25 | ``` 26 | 27 | Isabelle returns `Bad name: "a :: bool"`. 28 | 29 | **Fix:** use type annotations in the `where` clause instead: 30 | 31 | ``` 32 | definition "a" where "a :: bool ≡ False" 33 | ``` 34 | - error_msg: > 35 | Not an equation | Not a meta-equality (≡) 36 | explanation: | 37 | Most commonly, these errors occur because Isabelle's equality `=` binds relatively strongly. 38 | For example 39 | 40 | ``` 41 | definition d where "d b = b ∧ False" 42 | 43 | fun f where "f b = b ∧ False" 44 | ``` 45 | 46 | lead both to above error. 47 | Isabelle parses the term `t b = b ∧ False` as `(t b = b) ∧ False` and not `t b = (b ∧ False)`. 48 | 49 | **Fix:** 50 | Explicitly set the parentheses, e.g. `t b = (b ∧ False)` 51 | 52 | - error_msg: > 53 | (in an instantiation proof) 54 | Failed to refine any pending goal. 55 | Local statement fails to refine any pending goal. 56 | explanation: | 57 | When attempting to prove the necessary assumptions for the instantiation of a class, Isabelle may not infer the correct type. 58 | Assume there is a class `C`: 59 | ``` 60 | class C = 61 | fixes f :: "'a option ⇒ 'a option" 62 | assumes "f None = None" 63 | ``` 64 | When instantiating the class for an arbitrary type, e.g. `int`, one goal is: `f None = None`. 65 | ``` 66 | instantiation int :: C 67 | begin 68 | definition "f_int (x :: int option) ≡ (None :: int option)" (*arbitrary definition*) 69 | instance proof 70 | show "f None = None" sorry 71 | qed 72 | end 73 | ``` 74 | Isabelle does not infer the right type for `f` (since `f` may refer to another instantiation of `C`). 75 | 76 | **Fix:** Add a type annotation. For example: 77 | ``` 78 | show "f None = (None :: int option)" sorry 79 | ``` 80 | 81 | -------------------------------------------------------------------------------- /_data/common_pitfalls.yml: -------------------------------------------------------------------------------- 1 | - title: Misleading variable naming in set comprehension 2 | explanation: | 3 | **Problem:** The expression 4 | 5 | ``` 6 | {(v, v). v ∈ {''a'', ''b''}} 7 | ``` 8 | 9 | is actually interpreted as 10 | 11 | ``` 12 | {(va ∷ 'a, v ∷ char list). v ∈ {''a'', ''b''}} 13 | ``` 14 | 15 | **Fix**: Write 16 | 17 | ``` 18 | {(v, v) | v. v ∈ {''a'', ''b''}} 19 | ``` 20 | - title: The simplifier does not apply my rule 21 | explanation: | 22 | Most commonly this is a typing problem. 23 | The rule you want to apply may require a more special (or just plain different) type from what you have in the current goal. 24 | Use `declare [[show_types, show_sorts]]` to display types and sorts, and then check whether the types in your rule and your goal match up. 25 | - title: What is the difference between the ⇒, ⟹ , and ⟶ arrows? 26 | explanation: | 27 | Isabelle uses the `⇒` arrow for the function type (contrary to most functional languages which use `->`). 28 | So `a ⇒ b` is the type of a function that takes an element of type `a` as input and gives you an element of type `b` as output. 29 | 30 | The long arrows ⟶ and ⟹ are object and meta level implication, respectively. 31 | Roughly speaking, meta level implication should be used to separate the assumptions from the conclusion in statements. 32 | Whenever you need an implication inside a closed HOL formula, use ⟶. 33 | - title: Where do I have to put double quotes? 34 | explanation: | 35 | Isabelle distinguishes between *inner* and *outer* syntax. 36 | The outer syntax comes from the Isabelle framework, 37 | the inner syntax is the one in between quotation marks and comes from the object logic (in this case HOL). 38 | With time the distinction between the two becomes obvious, 39 | but in the beginning the following rules of thumb may work: 40 | 41 | Types should be inside quotation marks, formulas and lemmas should be inside quotation marks, 42 | rules and equations (e.g. for definitions) should be inside quotation marks, 43 | commands like `lemma`, `definition`, `primrec`, `inductive`, `apply`, `fun`, `done` are without quotation marks, 44 | as are the names of constants in constant definitions (`consts`) 45 | 46 | -------------------------------------------------------------------------------- /_data/lemma_collections.yml: -------------------------------------------------------------------------------- 1 | - name: eval_nat_numeral 2 | explanation: | 3 | simp rules to convert numerals to Suc/Zero notation 4 | - name: ac_simps 5 | explanation: | 6 | TODO 7 | - name: algebra_simps 8 | explanation: | 9 | simp rules to deal with the classical algebraic structures of groups and rings and fields. 10 | They simplify terms by multiplying everything out (in case of a ring) and bringing sums and products into a canonical form (by ordered rewriting). 11 | As a result, it decides group and ring equalities but also helps with inequalities. 12 | 13 | Of course it also works for fields, but it knows nothing about multiplicative inverses or division. 14 | This is catered for by `field_simps`. 15 | - name: field_simps 16 | explanation: | 17 | simp rules that multiply with denominators in (in)equations if they can be proved to be non-zero (for equations) or positive/negative (for inequations); 18 | can be too aggressive and is therefore separate from the more benign algebra_simps. 19 | - name: sign_simps 20 | explanation: | 21 | TODO 22 | - name: DERIV_intros 23 | explanation: | 24 | TODO 25 | - name: tendsto_intros 26 | explanation: | 27 | TODO 28 | 29 | -------------------------------------------------------------------------------- /_includes/head-custom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% include head-custom-google-analytics.html %} 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | {% seo %} 9 | 10 | 13 | {% include head-custom.html %} 14 | 15 | 16 |{{ item.error_msg }}
9 |