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

doc(tactic/ring2): document parts of ring2 #1208

Merged
merged 6 commits into from
Aug 20, 2019

Conversation

Vtec234
Copy link
Collaborator

@Vtec234 Vtec234 commented Jul 10, 2019

@Vtec234 Vtec234 requested a review from a team as a code owner July 10, 2019 13:04
Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

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

Thanks! I appreciate the effort to document things. This looks accurate to me, but perhaps @digama0 (who wrote ring2) can take a quick look before merging.

@@ -39,21 +42,34 @@ def tree.index_of {α} (lt : α → α → Prop) [decidable_rel lt]
| ordering.gt := pos_num.bit1 <$> tree.index_of t₂
end

/-- Reflects a tree of expressions into an expression that,
when evaluated, yields the original tree. -/
Copy link
Member

Choose a reason for hiding this comment

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

This isn't clear to me. What do you mean the "original tree"? What is the type of the resulting expr?

/-- An efficient representation of expressions in a commutative
semiring using the sparse Horner normal form. This type admits
non-optimal instantiations (e.g. `P` can be represented as `P+0+0`),
so care must be taken to maintain an optimal, *canonical* form.-/
Copy link
Member

Choose a reason for hiding this comment

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

Care must be taken where? In the ring2 tactic, I suppose, but this comment reads a little strange as a doc string.

| horner : horner_expr → pos_num → num → horner_expr → horner_expr

namespace horner_expr

/-- "Is this `horner_expr` a valid `csring_expr`?" Basically all constants
must be non-negative. -/
Copy link
Member

Choose a reason for hiding this comment

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

Can this be made declarative? "Tests whether a horner_expr is a valid csring_expr, i.e. whether all constants are non-negative."

@Vtec234
Copy link
Collaborator Author

Vtec234 commented Jul 18, 2019

I rewrote some comments - hopefully they should be clearer. I also refactored the binary tree type tree into its own module as it was defined twice, in ring2 and linarith. Also had to recommit all of linarith.lean because it was using CRLF line endings, but the only real change is to pull data.tree out of it.

@Vtec234 Vtec234 force-pushed the ring2_doc branch 2 times, most recently from 89219d2 to 2aa5773 Compare July 23, 2019 00:28
meta def tree.reflect' (u : level) (α : expr) : tree expr → expr
/-- `(reflect' t u α)` turns a tree `(t: tree expr)` of reflected values
of type `α` at level `u` into an `expr` which concretizes to a `tree α`
containing the concretizations of the `expr`s from the original `t`. -/
Copy link
Member

Choose a reason for hiding this comment

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

Hm, this comment reads a bit convoluted. The way I would explain this is that we can quasiquote a tree expr, with unquotations at the leaves, where the leaves represent elements of type alpha (at level u).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am also not too happy with this comment. The issue here is that the terminology around quoting is varied and inconsistent. I've heard the terms reflection, reification, quotation and concretization all used in this context and they always confuse me. Perhaps "quoting" is closest to existing Lean terminology, so I will use that instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to use "(quasi)quotation"/"reification" but avoided the use of "unquotation". The reason is that a quick search for "unquotation" comes up with nothing, while the former terms have some explanations on the Haskell wiki.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(One nitpick, this tree type has values at every node rather than just the leaves).

@robertylewis robertylewis added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Aug 20, 2019
@mergify mergify bot merged commit 8771432 into leanprover-community:master Aug 20, 2019
cipher1024 pushed a commit that referenced this pull request Aug 23, 2019
* doc(tactic/ring2): document parts of ring2

* feat(data/tree): refactor binary trees into their own module

* feat(tactic/ring2): resolve correct correctness

* chore(tactic/ring2): move copyright into comment

* doc(tactic/ring2): wording
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
* doc(tactic/ring2): document parts of ring2

* feat(data/tree): refactor binary trees into their own module

* feat(tactic/ring2): resolve correct correctness

* chore(tactic/ring2): move copyright into comment

* doc(tactic/ring2): wording
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants