-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: declaration form to document welcome proofs (#401)
Add proof_wanted, a declaration form that is elaborated as an axiom and then thrown away. This can serve as a guide for new contributors who are looking for high-impact work that can be more quickly reviewed. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
- Loading branch information
1 parent
d2d9ea1
commit bf8a6ea
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/- | ||
Copyright (c) 2023 Lean FRO, LLC. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Scott Morrison | ||
-/ | ||
import Std.Data.HashMap.Basic | ||
import Std.Util.ProofWanted | ||
|
||
namespace Std.HashMap | ||
|
||
@[simp] proof_wanted empty_find? [BEq α] [Hashable α] {a : α} : | ||
(∅ : HashMap α β).find? a = none | ||
|
||
proof_wanted insert_find? [BEq α] [Hashable α] (m : HashMap α β) (a a' : α) (b : β) : | ||
(m.insert a b).find? a' = if a' == a then some b else m.find? a' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/- | ||
Copyright (c) 2023 Lean FRO, LLC. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: David Thrane Christiansen | ||
-/ | ||
import Lean.Elab.Exception | ||
import Lean.Elab.Command | ||
import Lean.Parser | ||
|
||
|
||
open Lean Parser Elab Command | ||
|
||
/-- This proof would be a welcome contribution to the library! | ||
The syntax of `proof_wanted` declarations is just like that of `theorem`, but without `:=` or the | ||
proof. Lean checks that `proof_wanted` declarations are well-formed (e.g. it ensures that all the | ||
mentioned names are in scope, and that the theorem statement is a valid proposition), but they are | ||
discarded afterwards. This means that they cannot be used as axioms. | ||
Typical usage: | ||
``` | ||
@[simp] proof_wanted empty_find? [BEq α] [Hashable α] {a : α} : | ||
(∅ : HashMap α β).find? a = none | ||
``` | ||
-/ | ||
@[command_parser] | ||
def «proof_wanted» := leading_parser | ||
declModifiers false >> "proof_wanted" >> declId >> ppIndent declSig | ||
|
||
/-- Elaborate a `proof_wanted` declaration. The declaration is translated to an axiom during | ||
elaboration, but it's then removed from the environment. | ||
-/ | ||
@[command_elab «proof_wanted»] | ||
def elabProofWanted : CommandElab | ||
| `($mods:declModifiers proof_wanted $name $args* : $res) => withoutModifyingEnv do | ||
-- The helper axiom is used instead of `sorry` to avoid spurious warnings | ||
elabCommand <| ← `(axiom helper (p : Prop) : p | ||
$mods:declModifiers | ||
theorem $name $args* : $res := helper _) | ||
| _ => throwUnsupportedSyntax |