Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make List.length_eq_countP_add_countP avoid Prop #808

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BoltonBailey
Copy link

@BoltonBailey BoltonBailey commented May 23, 2024

Changes this lemma to use boolean not rather than propositional not.

@BoltonBailey
Copy link
Author

Is this repo accepting PRs that could break downstream? Is there anything I need to do to make sure mathlib doesn't break here?

@BoltonBailey BoltonBailey changed the title make change refactor: make List.length_eq_countP_add_countP avoid Prop May 23, 2024
@BoltonBailey
Copy link
Author

WIP

@github-actions github-actions bot added the WIP work in progress label May 23, 2024
@Shreyas4991
Copy link
Contributor

Is this repo accepting PRs that could break downstream? Is there anything I need to do to make sure mathlib doesn't break here?

There's a bot that will add a merge-conflict label if this is an issue.

Comment on lines +47 to +59
theorem length_eq_countP_add_countP (l) : length l = countP p l + countP (fun a => ! p a) l := by
induction l with
| nil => rfl
| cons x h ih =>
if h : p x then
rw [countP_cons_of_pos _ _ h, countP_cons_of_neg _ _ _, length, ih]
· rw [Nat.add_assoc, Nat.add_comm _ 1, Nat.add_assoc]
· simp only [h, not_true_eq_false, decide_False, not_false_eq_true]
· simp only [h, not_true_eq_false, decide_False, not_false_eq_true, Bool.not_true,
Bool.false_eq_true, not_false_eq_true]
else
rw [countP_cons_of_pos (fun a => ¬p a) _ _, countP_cons_of_neg _ _ h, length, ih]
rw [countP_cons_of_pos (fun a => ! p a) _ _, countP_cons_of_neg _ _ h, length, ih]
· rfl
· simp only [h, not_false_eq_true, decide_True]
· simp only [h, not_false_eq_true, decide_True, Bool.not_false]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified proof:

theorem length_eq_countP_add_countP (l) : length l = countP p l + countP (!p ·) l := by
  induction l with
  | nil => rfl
  | cons x _ _ => cases h : p x <;> simp_arith [*]

@Shreyas4991
Copy link
Contributor

Is this repo accepting PRs that could break downstream? Is there anything I need to do to make sure mathlib doesn't break here?

On second thoughts, I might help to make one of those testing PRs in mathlib. I was asked to make this for another PR. Im such a PR, one basically changes the repository's batteries dependency to one's own fork and PR branch in Mathlib's lakefile and lake manifest

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. WIP work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants