Datasets:
Download lean_project/FormalConjecturesTest/Util/Attributes/Basic.lean from nielsr/formal-conjectures: direct link, hf CLI and curl.
- Browser
- Download file 18.1 kB
-
https://huggingface.co/datasets/nielsr/formal-conjectures/resolve/main/lean_project/FormalConjecturesTest/Util/Attributes/Basic.lean
- Command line
-
hf download hf://datasets/nielsr/formal-conjectures/lean_project/FormalConjecturesTest/Util/Attributes/Basic.lean
-
curl -L -o Basic.lean https://huggingface.co/datasets/nielsr/formal-conjectures/resolve/main/lean_project/FormalConjecturesTest/Util/Attributes/Basic.lean
18.1 kB
| /- | |
| Copyright 2025 The Formal Conjectures Authors. | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| https://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| -/ | |
| module | |
| public meta import FormalConjecturesUtil.Attributes.Basic | |
| public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic | |
| public import Mathlib.NumberTheory.FLT.Basic | |
| public import Mathlib.RingTheory.Algebraic.Defs | |
| @[expose] public section | |
| -- The `Category` and `ProblemSubject` attributes | |
| @[category test] | |
| theorem test : 1 + 1 = 2 := by | |
| sorry | |
| @[category research solved, AMS 11] | |
| theorem FLT : FermatLastTheorem := by | |
| sorry | |
| open scoped Real in | |
| @[category research open, AMS 11 33] | |
| theorem an_open_problem : Transcendental ℝ (π + rexp 1) := by | |
| sorry | |
| @[category research solved, | |
| formal_proof using lean4 at "https://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002"] | |
| theorem a_formally_solved_problem : 2 + 2 = 4 := by | |
| rfl | |
| -- The `question` attribute | |
| /-- Is `2 + 2` equal to `4`? -/ | |
| @[category research solved, question, AMS 11] | |
| theorem a_question : 2 + 2 = 4 := by | |
| rfl | |
| -- The attribute is independent of the order of attributes. | |
| @[question, category research open] | |
| theorem a_question_first : 2 + 2 = 4 := by | |
| sorry | |
| -- `question` is not a keyword. | |
| example (question : Nat) : question = question := rfl | |
| /-- | |
| error: the `question` attribute only applies to theorems, but the type of 'not_a_theorem' is not a proposition | |
| -/ | |
| @[question] | |
| def not_a_theorem : Prop := True | |
| -- The unknown of a value question is a definition `<theorem>.answer`. | |
| def a_value_question_with_def.answer : Nat := sorry | |
| /-- What is `2 + 2`? -/ | |
| @[category research open, question value, AMS 11] | |
| theorem a_value_question_with_def : 2 + 2 = a_value_question_with_def.answer := by | |
| sorry | |
| -- The form is checked against the statement, in both directions. | |
| def a_value_question_with_def_tagged_yes_no.answer : Nat := sorry | |
| /-- | |
| error: the statement of 'a_value_question_with_def_tagged_yes_no' refers to the unknown of a value question; use `question value` | |
| -/ | |
| @[category research open, question, AMS 11] | |
| theorem a_value_question_with_def_tagged_yes_no : 2 + 2 = a_value_question_with_def_tagged_yes_no.answer := by | |
| sorry | |
| /-- | |
| error: `question value` requires the statement of 'a_yes_no_question_tagged_value' to refer to the definition `a_yes_no_question_tagged_value.answer`; for a yes-or-no question use `question` | |
| -/ | |
| @[category research open, question value, AMS 11] | |
| theorem a_yes_no_question_tagged_value : 2 + 2 = 4 := by | |
| sorry | |
| open ProblemAttributes | |
| /-- info: some QuestionKind.yesNo -/ | |
| /-- info: some QuestionKind.yesNo -/ | |
| /-- info: some QuestionKind.value -/ | |
| -- An untagged theorem has no kind. | |
| /-- info: none -/ | |
| -- A question belongs to a research problem, whichever attribute comes first. | |
| /-- | |
| error: the `question` attribute belongs to a `research open` or `research solved` problem, but 'question_on_test' is categorised as `test` | |
| -/ | |
| @[category test, question] | |
| theorem question_on_test : 1 + 1 = 2 := by | |
| rfl | |
| /-- | |
| error: the `question` attribute belongs to a `research open` or `research solved` problem, but 'question_on_api' is categorised as `API` | |
| -/ | |
| @[question, category API] | |
| theorem question_on_api : 1 + 1 = 2 := by | |
| rfl | |
| /-- | |
| error: the `question` attribute belongs to a `research open` or `research solved` problem, but 'question_on_textbook' is categorised as `textbook` | |
| -/ | |
| @[category textbook, question] | |
| theorem question_on_textbook : 1 + 1 = 2 := by | |
| rfl | |
| -- The check also covers the `attribute` command. | |
| @[category test] | |
| theorem later_question_on_test : 1 + 1 = 2 := by | |
| rfl | |
| /-- | |
| error: the `question` attribute belongs to a `research open` or `research solved` problem, but 'later_question_on_test' is categorised as `test` | |
| -/ | |
| attribute [question] later_question_on_test | |
| @[category research open] | |
| theorem later_question : 1 + 1 = 2 := by | |
| sorry | |
| attribute [question] later_question | |
| /-- info: some QuestionKind.yesNo -/ | |
| -- formal_proof on non-research categories | |
| @[category textbook, AMS 11, formal_proof using lean4 at "https://github.com/example/proof"] | |
| theorem a_graduate_problem_with_formal_proof : 1 + 1 = 2 := by | |
| rfl | |
| @[category test, formal_proof using formal_conjectures at ""] | |
| theorem a_test_with_formal_proof : 3 + 3 = 6 := by | |
| rfl | |
| theorem conditional_formal_proof_hypothesis : 0 = 0 := by | |
| sorry | |
| theorem another_conditional_formal_proof_hypothesis : 1 = 1 := by | |
| sorry | |
| @[category research solved, | |
| conditional formal_proof using lean4 at | |
| "https://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002" | |
| assuming conditional_formal_proof_hypothesis] | |
| theorem a_conditionally_formally_solved_problem : 4 + 4 = 8 := by | |
| rfl | |
| @[category research solved, | |
| conditional formal_proof using lean4 at | |
| "https://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002" | |
| assuming conditional_formal_proof_hypothesis another_conditional_formal_proof_hypothesis] | |
| theorem a_conditionally_formally_solved_problem_with_two_hypotheses : 5 + 5 = 10 := by | |
| rfl | |
| run_meta do | |
| let conditions ← ProblemAttributes.getProofConditions ``a_conditionally_formally_solved_problem | |
| unless conditions = [``conditional_formal_proof_hypothesis] do | |
| throwError "unexpected proof conditions for a_conditionally_formally_solved_problem" | |
| run_meta do | |
| let conditions ← ProblemAttributes.getProofConditions | |
| ``a_conditionally_formally_solved_problem_with_two_hypotheses | |
| unless conditions = [``conditional_formal_proof_hypothesis, | |
| ``another_conditional_formal_proof_hypothesis] do | |
| throwError | |
| "unexpected proof conditions for a_conditionally_formally_solved_problem_with_two_hypotheses" | |
| /-- | |
| error: a `conditional` formal proof must name the hypotheses it assumes: state each hypothesis as | |
| a declaration in this file (with a `sorry` proof) and reference it as | |
| `conditional formal_proof using <kind> at "<link>" assuming <decl>`. | |
| -/ | |
| @[category research solved, | |
| conditional formal_proof using lean4 at "https://github.com/example/missing-hypothesis"] | |
| theorem conditional_formal_proof_without_assuming : 6 + 6 = 12 := by | |
| rfl | |
| /-- | |
| error: an `assuming` clause requires the `conditional` modifier: | |
| `conditional formal_proof using <kind> at "<link>" assuming <decl>`. | |
| -/ | |
| @[category research solved, | |
| formal_proof using lean4 at "https://github.com/example/not-conditional" | |
| assuming conditional_formal_proof_hypothesis] | |
| theorem assuming_without_conditional_formal_proof : 7 + 7 = 14 := by | |
| rfl | |
| -- A `formal_proof` link is validated: external kinds must link to the proof, and | |
| -- any link that is given must be a URL. | |
| /-- | |
| warning: A `lean4` or `other_system` `formal_proof` should include a link to the proof. | |
| -/ | |
| @[category test, formal_proof using lean4 at ""] | |
| theorem a_lean4_proof_with_empty_link : 4 + 4 = 8 := by | |
| rfl | |
| /-- | |
| warning: A `formal_proof` link should be a URL (http:// or https://), but got: "not-a-url". | |
| -/ | |
| @[category test, formal_proof using lean4 at "not-a-url"] | |
| theorem a_formal_proof_with_malformed_link : 5 + 5 = 10 := by | |
| rfl | |
| -- Open research problems retain their existing warning for non-Palomar links. | |
| /-- | |
| warning: A `formal_proof` annotation on a `research open` problem is suspicious. If a formal proof exists, the problem should not be categorised as `open`. | |
| -/ | |
| @[category research open, formal_proof using lean4 at "https://github.com/example/proof"] | |
| theorem an_open_problem_with_formal_proof : True := by | |
| sorry | |
| -- Solved research problems require Palomar entries, in either attribute order. | |
| @[category research solved, | |
| formal_proof using lean4 at | |
| "https://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002&version=1"] | |
| theorem a_solved_problem_with_palomar_proof : True := by | |
| sorry | |
| @[formal_proof using other_system at | |
| "https://palomar-registry.org/entry.html?version=1&id=PALOMAR-2026-10-05-000002", | |
| category research solved] | |
| theorem a_solved_problem_with_palomar_proof_first : True := by | |
| sorry | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| @[category research solved, formal_proof using lean4 at "https://github.com/example/proof"] | |
| theorem a_solved_problem_with_non_palomar_proof : True := by | |
| sorry | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| @[formal_proof using other_system at "https://github.com/example/proof", category research solved] | |
| theorem a_solved_problem_with_non_palomar_proof_first : True := by | |
| sorry | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| @[category research solved, formal_proof using formal_conjectures at ""] | |
| theorem a_solved_problem_with_empty_proof_link : True := by | |
| sorry | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| @[category research solved, | |
| conditional formal_proof using lean4 at "https://github.com/example/conditional-proof" | |
| assuming conditional_formal_proof_hypothesis] | |
| theorem a_solved_problem_with_non_palomar_conditional_proof : True := by | |
| sorry | |
| -- Applying either attribute later must enforce the same restriction. | |
| theorem an_uncategorised_problem_with_palomar_proof : True := by | |
| sorry | |
| attribute [formal_proof using formal_conjectures at | |
| "https://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002"] | |
| an_uncategorised_problem_with_palomar_proof | |
| attribute [category research solved] an_uncategorised_problem_with_palomar_proof | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| attribute [formal_proof using lean4 at "https://github.com/example/proof"] FLT | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| attribute [category research solved] a_graduate_problem_with_formal_proof | |
| -- The opt-out is local and does not disable the other link checks. | |
| set_option linter.style.formal_proof_palomar false in | |
| @[category research solved, formal_proof using lean4 at "https://github.com/example/proof"] | |
| theorem a_solved_problem_with_palomar_check_disabled : True := by | |
| sorry | |
| set_option linter.style.formal_proof_palomar false in | |
| @[formal_proof using other_system at "https://github.com/example/proof", category research solved] | |
| theorem a_solved_problem_with_palomar_check_disabled_first : True := by | |
| sorry | |
| set_option linter.style.formal_proof_palomar false in | |
| @[category research solved, | |
| conditional formal_proof using lean4 at "https://github.com/example/conditional-proof" | |
| assuming conditional_formal_proof_hypothesis] | |
| theorem a_conditional_proof_with_palomar_check_disabled : True := by | |
| sorry | |
| /-- | |
| warning: A `lean4` or `other_system` `formal_proof` should include a link to the proof. | |
| -/ | |
| set_option linter.style.formal_proof_palomar false in | |
| @[category research solved, formal_proof using lean4 at ""] | |
| theorem a_solved_problem_with_empty_link_and_palomar_check_disabled : True := by | |
| sorry | |
| /-- | |
| warning: A `formal_proof` link should be a URL (http:// or https://), but got: "not-a-url". | |
| -/ | |
| set_option linter.style.formal_proof_palomar false in | |
| @[category research solved, formal_proof using lean4 at "not-a-url"] | |
| theorem a_solved_problem_with_malformed_link_and_palomar_check_disabled : True := by | |
| sorry | |
| /-- | |
| error: A `formal_proof` annotation on a `research solved` problem must link to a Palomar entry (https://palomar-registry.org/entry.html?id=...). | |
| -/ | |
| @[category research solved, formal_proof using lean4 at "https://github.com/example/proof"] | |
| theorem a_solved_problem_after_local_palomar_opt_out : True := by | |
| sorry | |
| -- Check URL boundaries without relying on the registry being reachable. | |
| run_meta do | |
| let invalidLinks := [ | |
| "https://palomar-registry.org/", | |
| "https://palomar-registry.org/entry.html", | |
| "https://palomar-registry.org/entry.html?id=", | |
| "https://palomar-registry.org/entry.html?version=1", | |
| "https://palomar-registry.org/entry.html#?id=PALOMAR-2026-10-05-000002", | |
| "https://palomar-registry.org.evil.example/entry.html?id=PALOMAR-2026-10-05-000002", | |
| "https://palomar-registry.org@evil.example/entry.html?id=PALOMAR-2026-10-05-000002", | |
| "https://example.com/palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002", | |
| "ftp://palomar-registry.org/entry.html?id=PALOMAR-2026-10-05-000002"] | |
| for link in invalidLinks do | |
| let rejected ← try | |
| ProblemAttributes.checkFormalProofLink (.research .solved) link | |
| pure false | |
| catch _ => pure true | |
| unless rejected do | |
| throwError "unexpectedly accepted Palomar entry link: {link}" | |
| -- The `optimization_constant` attribute | |
| @[optimization_constant "1a"] | |
| noncomputable def anOptimizationConstant : ℝ := 1 | |
| @[optimization_constant "21a"] | |
| def anotherOptimizationConstant : ℕ := 4 | |
| /-- | |
| warning: An `optimization_constant` id should be the name of the entry's page `https://teorth.github.io/optimizationproblems/constants/<id>.html`. This is one or more digits followed by one lowercase letter (e.g. "1a" or "21a"). The letter is required even when the database table shows only the number. Got: "21". | |
| -/ | |
| #guard_msgs in | |
| @[optimization_constant "21"] | |
| def anOptimizationConstantWithoutLetter : ℕ := 4 | |
| run_meta do | |
| let tags ← ProblemAttributes.getOptimizationConstants ``anOptimizationConstant | |
| unless tags.map (·.constantId) = #["1a"] do | |
| throwError "unexpected optimization constant tags for anOptimizationConstant" | |
| /-- | |
| warning: An `optimization_constant` id should be the name of the entry's page `https://teorth.github.io/optimizationproblems/constants/<id>.html`. This is one or more digits followed by one lowercase letter (e.g. "1a" or "21a"). The letter is required even when the database table shows only the number. Got: "a1". | |
| -/ | |
| @[optimization_constant "a1"] | |
| noncomputable def anOptimizationConstantWithMalformedId : ℝ := 3 | |
| /-- | |
| warning: An `optimization_constant` annotation should be applied to the definition of the constant, but `an_optimization_constant_theorem` is not a definition. Theorems about the constant (e.g. bounds) should not carry this attribute. | |
| -/ | |
| @[category research open, AMS 11, optimization_constant "1a"] | |
| theorem an_optimization_constant_theorem : 3 + 3 = 6 := by | |
| sorry | |
| -- The `#AMS` command | |
| /-- | |
| info: 0 General and overarching topics | |
| 1 History and biography | |
| 3 Mathematical logic and foundations | |
| 5 Combinatorics | |
| 6 Order, lattices, ordered algebraic structures | |
| 8 General algebraic systems | |
| 11 Number theory | |
| 12 Field theory and polynomials | |
| 13 Commutative algebra | |
| 14 Algebraic geometry | |
| 15 Linear and multilinear algebra; matrix theory | |
| 16 Associative rings and algebras | |
| 17 Nonassociative rings and algebras | |
| 18 Category theory; homological algebra | |
| 19 K-theory | |
| 20 Group theory and generalizations | |
| 22 Topological groups, Lie groups | |
| 26 Real functions | |
| 28 Measure and integration | |
| 30 Functions of a complex variable | |
| 31 Potential theory | |
| 32 Several complex variables and analytic spaces | |
| 33 Special functions | |
| 34 Ordinary differential equations | |
| 35 Partial differential equations | |
| 37 Dynamical systems and ergodic theory | |
| 39 Difference and functional equations | |
| 40 Sequences, series, summability | |
| 41 Approximations and expansions | |
| 42 Harmonic analysis on Euclidean spaces | |
| 43 Abstract harmonic analysis | |
| 44 Integral transforms, operational calculus | |
| 45 Integral equations | |
| 46 Functional analysis | |
| 47 Operator theory | |
| 49 Calculus of variations and optimal control; optimization | |
| 51 Geometry | |
| 52 Convex and discrete geometry | |
| 53 Differential geometry | |
| 54 General topology | |
| 55 Algebraic topology | |
| 57 Manifolds and cell complexes | |
| 58 Global analysis, analysis on manifolds | |
| 60 Probability theory and stochastic processes | |
| 62 Statistics | |
| 65 Numerical analysis | |
| 68 Computer science | |
| 70 Mechanics of particles and systems | |
| 74 Mechanics of deformable solids | |
| 76 Fluid mechanics | |
| 78 Optics, electromagnetic theory | |
| 80 Classical thermodynamics, heat transfer | |
| 81 Quantum theory | |
| 82 Statistical mechanics, structure of matter | |
| 83 Relativity and gravitational theory | |
| 85 Astronomy and astrophysics | |
| 86 Geophysics | |
| 90 Operations research, mathematical programming | |
| 91 Game theory, economics, social and behavioral sciences | |
| 92 Biology and other natural sciences | |
| 93 Systems theory; control | |
| 94 Information and communication, circuits | |
| 97 Mathematics education | |
| -/ | |