-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
131 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Mathlib | ||
|
||
theorem getElem?_eq_some_getElem_of_valid_index [GetElem cont idx elem domain] [Decidable (domain container index)] (h : domain container index): | ||
container[index]? = some container[index] := by | ||
unfold getElem? | ||
split | ||
. rfl | ||
. contradiction | ||
|
||
theorem getElem?_none_of_invalid_index [GetElem cont idx elem domain] [Decidable (domain container index)] (h : ¬ domain container index): | ||
container[index]? = none := by | ||
unfold getElem? | ||
split | ||
. tauto | ||
. rfl | ||
|
||
theorem valid_index_of_getElem?_some [GetElem cont idx elem domain] [Decidable (domain container index)] (h : container[index]? = some element): | ||
domain container index := by | ||
unfold getElem? at h | ||
split at h | ||
. assumption | ||
. contradiction | ||
|
||
theorem getElem_of_getElem?_some [GetElem cont idx elem domain] [Decidable (domain container index)] (h : container[index]? = some element): | ||
container[index]'(valid_index_of_getElem?_some h) = element := by | ||
unfold getElem? at h | ||
split at h | ||
. injection h | ||
. contradiction | ||
|
||
theorem getElem?_some_of_getElem [GetElem cont idx elem domain] [Decidable (domain container index)] {ix_valid : domain container index} (h : container[index]'ix_valid = element): | ||
container[index]? = some element := by | ||
unfold getElem? | ||
split | ||
. congr | ||
. contradiction | ||
|
||
theorem getElem!_eq_getElem?_get! [GetElem cont idx elem domain] [Decidable (domain container index)] [Inhabited elem]: | ||
container[index]! = container[index]?.get! := by | ||
simp [getElem!, getElem?] | ||
split | ||
. rfl | ||
. unfold Option.get!; rfl |
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