leanprover / lean3

Lean Theorem Prover
http://leanprover.github.io/
Apache License 2.0
2.15k stars 215 forks source link

javascript tutorial: no output #891

Closed cristipp closed 8 years ago

cristipp commented 8 years ago

I'm going through https://leanprover.github.io/tutorial. I'd expect the result of the "check" statements (which is manually added as comments) to show up somewhere upon execution. Unfortunately, it doesn't, so experimenting on my own is rather limited. There are also statements in the text that indicate I should see something, like Lean's output seems to indicates that Type is an element of itself..

All I see is:

-- Processing...
-- Saved at cookie.
-- Done(0.013sec)
cristipp commented 8 years ago

Oh, the types do show up. As comments in text. Since the original text already had them as comments, nothing was happening on "shift + enter".

cristipp commented 8 years ago

Sorry, the types didn't show up as comments. I still see no output on "shift + enter". Furthermore:

soonhokong commented 8 years ago

For each check command, it provides a small "i" icon on the left gutter to display a corresponding information. You can move your mouse on it to see the details. See the following screenshot.

screen shot 2015-11-20 at 7 32 55 pm

If you want to see the output at the console pane, there is an option for that. Please click the 'gear' icon (Settings) and set the value for "Print output to console" to be true.

screen shot 2015-11-20 at 7 34 32 pm

Then, the output should be directed to the console pane as the following screenshot.

screen shot 2015-11-20 at 7 35 55 pm

soonhokong commented 8 years ago

Unclear what \what sequence to use for the lambda symbol.

There is an appendix A.1.8 which explains how to type some of the Unicode symbols in the editor.

screen shot 2015-11-20 at 7 36 43 pm

fpvandoorn commented 8 years ago

@soonhokong: This seems to be a recurring question. I recommend setting this value to be true by default:

If you want to see the output at the console pane, there is an option for that. Please click the 'gear' icon (Settings) and set the value for "Print output to console" to be true.

cristipp commented 8 years ago

Thanks! I'm getting some output now. Regarding \lam, I'm doing something wrong in the JS console. Perhaps Emacs is doing some preprocessing that is not available in js?

screen shot 2015-11-20 at 6 03 30 pm
cristipp commented 8 years ago

Here's another fun one, the result of eval 2 + 3 is somewhat harder to read than 5:

screen shot 2015-11-20 at 6 06 01 pm
avigad commented 8 years ago

@cristipp Thanks for catching this.

Recently, we changed the handling of numerals in Lean. The issue is now that the numerals in "2 + 3" are interpreted as generic numerals. The metavariable expressions like "?M_1" means that the system doesn't know what type they are, and so the "evaluation" is uninformative.

We can fix this by writing, for example, (2 : nat) + 3. I will fix this tomorrow.

cristipp commented 8 years ago

Thanks for the eval tip. I also figured out how to type lambdas:

definition curry (A B C : Type) (f : A × B → C) : A → B → C :=
  fun a b, f (a, b)
fpvandoorn commented 8 years ago

\lam is not a way to input λ, you should use \fun or \l (or the ASCII variant fun). I fixed it in the Quick Reference: leanprover/tutorial#147

cristipp commented 8 years ago

Edit2. @fpvandoorn was kind to answer quick enough, only fair to leave the question. I was confused in the declaration of vec, why cons takes an A first argument, whereas empty and append don't. In particular, as A is already the first argument of Π.

namespace vec
  constant empty : Π A : Type, vec A 0
  constant cons : Π (A : Type) (n : nat), A → vec A n → vec A (n + 1)
  constant append : Π (A : Type) (n m : nat), vec A m → vec A n → vec A (n + m)
end vec

Edit: Ignore, figured it out.

PS. The online interactive tutorial is fantastic. I wish I had it 10 years ago :)

fpvandoorn commented 8 years ago

The reason is that cons is a function, which takes an element a of type A, and a vector v of type vec A n and produces a vector a :: v (prepend a to v) of type vec A (n+1).

So (for a given A and n) it is really a function A → vec A n → vec A (n + 1). The other two functions don't depend on an element a of type A (but they do depend on the type A itself).

avigad commented 8 years ago

@cristipp Thanks for the kind words about the tutorial! The problem described above was fixed in this pull request:

https://github.com/leanprover/tutorial/pull/148

If that looks good to you, could you close this issue?

Two small comments:

cristipp commented 8 years ago

@avigad. All looks great. Thanks for the pointers. Keep up the good work! About the tutorial, one thing it didn't seem to get to [or I didn't got that far] is how to harness the power of the SMT apis to create one's own automated tactics.

avigad commented 8 years ago

The Lean project is still new, and that kind of automation is not there yet. Leo de Moura and Daniel Selsam are working hard now on adding a tableau theorem prover and term simplifier, and SMT capabilities are further down the line. Rest assured, though, that as they become available, we'll continue to document them.