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

fix(data/fin): rename raise_fin -> fin.raise; simp lemmas for fin #138

Merged
merged 5 commits into from
May 24, 2018
Merged

Conversation

jcommelin
Copy link
Member

No description provided.

data/fin.lean Outdated

def raise (k : fin n) : fin (n + 1) := ⟨val k, lt_succ_of_lt (is_lt k)⟩

def lower (k : fin (n + 1)) (h : k.val < n) : fin n := ⟨k.val, h⟩
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want this function. As it is it's basically mk; I guess it would be better if it did something else with the extra element like send n to n-1 and i < n to i. But then we will probably want more control on which element to double, and then it is a different function altogether. I think the easiest thing is just to say there is no lower function.

@johoelzl johoelzl changed the title Put raise_fin in fin namespace; simp lemmas for fin fix(data/fin): rename raise_fin -> fin.raise; simp lemmas for fin May 23, 2018
Copy link
Collaborator

@johoelzl johoelzl left a comment

Choose a reason for hiding this comment

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

@jcommelin do you want to incorporate the changes? They are only syntactic so I can do them too. (there is a short style guide: https://github.com/leanprover/mathlib/blob/master/docs/style.md , but it misses some things, e.g. having short attribute annotations inline...)

I usually change the title of the commits (or if it contains only one commit, the title of the PR) to follow Lean's commit convention. See:
https://github.com/leanprover/lean/blob/master/doc/commit_convention.md

data/fin.lean Outdated

variable {n : ℕ}

def raise (k : fin n) : fin (n + 1) := ⟨val k, lt_succ_of_lt (is_lt k)⟩
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add the comment /-- Embedding of fin ninfin (n+1) -/ back.
This is a user comment, i.e. you see it a tooltip.

data/fin.lean Outdated
def raise (k : fin n) : fin (n + 1) := ⟨val k, lt_succ_of_lt (is_lt k)⟩

@[simp]
lemma succ_val (j : fin n) : j.succ.val = j.val.succ := by cases j; simp [fin.succ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

The attribute annotation is inline with lemma succ_val etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

but the proof in a new line, i.e.

@[simp] lemma succ_val (j : fin n) : j.succ.val = j.val.succ :=
by cases j; simp [fin.succ]

data/fin.lean Outdated
lemma succ_val (j : fin n) : j.succ.val = j.val.succ := by cases j; simp [fin.succ]

@[simp]
lemma pred_val (j : fin (n+1)) (h : j ≠ 0) : (j.pred h).val = j.val.pred := by cases j; simp [fin.pred]
Copy link
Collaborator

Choose a reason for hiding this comment

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

The attribute annotation is inline with lemma succ_val etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

but the proof in a new line, i.e.

@[simp] lemma pred_val (j : fin (n+1)) (h : j ≠ 0) : (j.pred h).val = j.val.pred :=
by cases j; simp [fin.pred]

@jcommelin
Copy link
Member Author

@johoelzl Thanks for the feedback. I will incorporate it; it's good practice for me. Thanks for the links to the style guides.

@johoelzl johoelzl merged commit 2c94668 into leanprover-community:master May 24, 2018
@johoelzl
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants