Commit graph

1345 commits

Author SHA1 Message Date
Sebastian Ullrich
3f717c586e feat(init/meta/interactive): declare format! and sformat! macros and start putting them to use 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
38aa99e7a5 fix(init/meta/has_reflect): reflect 1 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
79f29a693e refactor(init/meta/interactive): split file 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
56995348d3 hack(frontends/lean/parser): allow input to be substituted and use it to implement interpolating format macro 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
2bb93aa4f9 feat(init/meta): tactic -> parser coercion 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
20ab8feeae feat(init/meta/lean/parser): pexpr parser that does not use quoted mode 2017-06-07 10:09:38 -07:00
Sebastian Ullrich
59184e888f feat(init/meta/pexpr): has_to_pexpr (reflected a) 2017-06-07 10:09:38 -07:00
Mario Carneiro
77264a6074 fix(init/meta/interactive): get rhs using relation_lhs_rhs 2017-06-07 10:03:35 -07:00
Mario Carneiro
1354514c80 feat(init/meta/interactive): specify intermediate goal in transitivity
As suggested by @Armael on gitter
2017-06-07 10:03:23 -07:00
Leonardo de Moura
9b60e25ca4 fix(library/init/meta/level): make level as meta 2017-06-06 16:12:35 -07:00
Leonardo de Moura
3bc414efff perf(library/tactic): add unsafe_change tactic
The `unsafe_change e` tactic is similar to the `change e` tactic, but it
does not check whether `e` is definitionally equal to the current
tactic. It is useful when implementing tactics such as:

```
meta def dunfold : list name → tactic unit :=
λ cs, target >>= dunfold_core transparency.instances default_max_steps cs >>= unsafe_change
```

The tactic `dunfold_core` guarantees that the resultant expression is
definitionally equal to the input one.

This was one of the performance problems at issue #1646.
Here are the runtimes for size 7 in the example described at issue #1646.

Before this commit:

   tactic execution took 4.96s
   elaboration of some_lifted_lets took 7.6s
   type checking time of some_lifted_lets took 31.1ms (aka QED time)
   total execution time: 12.785s

After this commit:

   tactic execution took 3.78s
   elaboration of some_lifted_lets took 5.71s
   type checking time of some_lifted_lets took 35.2ms
   total execution time: 10.693s
2017-06-06 14:55:25 -07:00
Leonardo de Moura
aac7777beb perf(library/tactic/unfold_tactic): implement dunfold_core and dunfold_occs_core in C++
Before this commit they were implemented using C++ and Lean.
A Lean procedure was being invoked for each subterm of the input term.

This is one of the performance problems at issue #1646.
Here are the runtimes for size 7 in the example described at issue #1646.

Before this commit:

   tactic execution took 7.48s
   elaboration of some_lifted_lets took 11.5s
   type checking time of some_lifted_lets took 33.4ms (aka QED time)
   total execution time: 16.841s

After this commit:

   tactic execution took 4.96s
   elaboration of some_lifted_lets took 7.6s
   type checking time of some_lifted_lets took 31.1ms (aka QED time)
   total execution time: 12.785s
2017-06-06 14:35:05 -07:00
Johannes Hölzl
d7fc571e36 fix(library/init/meta): show_goal also changes the goal 2017-06-05 20:07:44 -07:00
Leonardo de Moura
f5ec29ab1a feat(library/init/meta/interactive): add add_interactive command.
@Armael: the new file `tests/lean/run/add_interactive.lean` contains a
small example. Note that we don't have auto quotation for commands yet.
So, I have to use the backtick in the example.

@Kha: this is a good candidate for the future command parser extensions.
2017-06-05 16:43:15 -07:00
Leonardo de Moura
3140243bad chore(library/init/meta/interactive): reduce code duplication 2017-06-05 15:36:44 -07:00
Leonardo de Moura
ea8ecfd390 fix(library/init/meta/interactive): use replace_target at simp_goal
replace_target uses id_locked.
The id_locked solution is more robust because simp may build a proof
using refl lemmas, but type_context may not be able to establish that
the previous and new target are definitionally equal.

@Armael This commit fixes the issue in the KreMLin proof you showed me.
Now, the following tactic succeeds (as expected)
```
        simp [lowstar_semantics.apply_ectx],
```
and the resulting goal is
```
...
|- exp.subbuf (exp.loc (b, n, list.nil field)) a_1 = exp.subbuf ↑?m_1 ?m_2
```
2017-06-05 15:21:20 -07:00
Jeremy Avigad
c68326ac14 feat(library/init/meta/interactive): update simp docstring 2017-06-04 13:23:26 -07:00
Jeremy Avigad
dedc87fa7e refactor(library/init/meta/simp_tactic): include defaults for 'simp with' 2017-06-04 13:23:26 -07:00
Jeremy Avigad
d045042ae7 refactor(library/init/meta/interactive): remove special printing of loc, style fixes 2017-06-04 13:23:26 -07:00
Jeremy Avigad
c09aa24977 refactor(library/init/meta/interactive): make mk_simp_set public 2017-06-04 13:23:26 -07:00
Jeremy Avigad
ee5f00d3d0 feat(library/init/meta/simp_tactic): make simp_at return new hypothesis 2017-06-04 13:23:26 -07:00
Jeremy Avigad
c2df664c39 feat(library/init/meta/tactic): make tactics that introduce a local constant return the expr 2017-06-04 13:23:26 -07:00
Jeremy Avigad
7fe0fff91d feat(library/init/meta/interactive): add 'only' option for simp, dimph, dimp_intros, and dsimp 2017-06-04 13:23:26 -07:00
Jeremy Avigad
862d23f6b6 fix(library/init/meta/interactive): disallow wildcard in rewrite 2017-06-04 13:23:26 -07:00
Jeremy Avigad
e1c024d4d9 fix(library/init/meta/simp_tactic): fix relabeling of hypotheses in simp_intro_aux 2017-06-04 13:23:26 -07:00
Jeremy Avigad
4160f23847 fix(library/init/meta/interactive): fix printing of description string for locations 2017-06-04 13:23:26 -07:00
Jeremy Avigad
1fa7c2285e fix(library/init/meta/smt/interactive): adapt to wildcards in locations 2017-06-04 13:23:26 -07:00
Jeremy Avigad
649118c99a fix(library/init/meta/interactive): remove sorry in dunfold_occs 2017-06-04 13:23:26 -07:00
Jared Roesch
998f90b849 feat(library/init/meta/interactive): add support for location wildcards
This allows users to now use  to apply a tactic in all hypotheses as well as the goal, we add support for all
interactive tactics using location: rewrite, simp, dsimp, unfold, and delta including each tactics many variants.
2017-06-04 13:23:26 -07:00
Leonardo de Moura
a1dc121eee feat(library/init/meta/environment): add environment.fingerprint API 2017-06-02 16:52:40 -07:00
Leonardo de Moura
c59543bde8 feat(library/init/meta/tactic): add sleep tactic for debugging purposes
We are going to use it to simulate the issue described at issue #1601
2017-06-02 15:38:08 -07:00
Leonardo de Moura
92a72b238b feat(library/tactic): add tactic::ref
They can be used to store user state in the tactic_state object.

@Armael @jroesch: The new file tests/lean/run/tactic_ref.lean contains a few examples.
2017-06-02 15:19:03 -07:00
Leonardo de Moura
ca5439c698 feat(frontends/lean/tactic_notation): add support for tac ; [tac_1, ..., tac_n] notation in interactive tactic mode
closes #1634

This commit also changes the semantic of `tactic.focus [tac_1, ..., tac_n]`.
It now fails if the number of goals is not `n`.
Before it would only fail if there were more tactics than goals.

@Armael: See tests/lean/run/handthen.lean for examples of the new notation.
2017-06-02 11:38:04 -07:00
Leonardo de Moura
a8173c8194 feat(library/init): heterogeneous andthen type class, and tactic.seq_focus implementation 2017-06-02 10:38:27 -07:00
Leonardo de Moura
81e97de463 feat(library/init/meta/interactive): allow metavars in the show_goal tactic 2017-06-01 19:46:38 -07:00
Leonardo de Moura
18467bd302 feat(library/init/meta/interactive): add show_goal tactic for structuring proofs in interactive tactic mode 2017-06-01 18:36:50 -07:00
Leonardo de Moura
5446df1609 feat(library/init/meta/interactive): add interactive done tactic 2017-06-01 17:28:52 -07:00
Leonardo de Moura
00aef04b81 feat(library/init/meta/rec_util): add mk_constructors_fresh_names
@Armael @jroesch this commit implements the
`mk_constructors_fresh_names` tactic.
The new test file has a few examples.
2017-06-01 17:04:21 -07:00
Leonardo de Moura
190d792225 feat(library/init/meta/tactic): add default parameter value 2017-06-01 16:24:36 -07:00
Mario Carneiro
d82b8ed59e feat(init/data/int,init/data/nat,init/algebra): more algebra theorems 2017-06-01 15:15:40 -07:00
Gabriel Ebner
f049a3f01e refactor(library/init/meta/has_reflect): get rid of unchecked_cast 2017-06-01 10:59:09 +02:00
Gabriel Ebner
04f9eb0b4f refactor(library/init/meta/expr): pure Lean implementation of reflected 2017-06-01 10:17:51 +02:00
Leonardo de Moura
8b0cca57d1 fix(library/noncomputable): fixes #1631
This commit fixes issue #1631. However, it is not a perfect solution.
This commit improves the predicate that checks whether a definition is
noncomputable or not. This predicate was implemented before we had
a code generator.
We should refactor the code and use the code generator to check
whether a definition is noncomputable or not. Otherwise, we will
keep finding mismatches between the predicate at noncomputable.cpp
and what the code generator implements.
2017-05-31 23:16:37 -07:00
Leonardo de Moura
42eeb445d4 fix(library): make sure `(t) does not evaluate t
See #1631
2017-05-31 22:03:15 -07:00
Leonardo de Moura
d8fa93b4a2 feat(library/init/meta/tactic): add dependent parameters for empty introv 2017-05-31 15:10:07 -07:00
Leonardo de Moura
293ab6a032 fix(library/init/data/nat/bitwise): broken lemma 2017-05-31 15:08:03 -07:00
Mario Carneiro
41b928a546 feat(init/data/nat/bitwise): properties of bitwise ops 2017-05-31 14:18:44 -07:00
Mario Carneiro
18b622d709 chore(init/data/nat): modify bitwise defs 2017-05-31 14:18:44 -07:00
Leonardo de Moura
1c6e70d170 feat(library/init/meta): introv tactic
@Armael: this commit implements the `introv` tactic.
The implementation uses an auxiliary `intros_dep` that introduces new
hypotheses with forward dependencies.

The `tactic.introv` tactic implemented at library/init/meta/tactic.lean
is the main implementation, but it is not nice for interactive use since
users would have to write
```
tactic.introv [`h1, `h2]
```
To make it more conveninent to use, we define another
```
meta def introv (ns : parse ident_*) : tactic unit :=
tactic.introv ns >> return ()
```
This one is in the namespace `tactic.interactive`, and
uses parser extensions. The argument `parse ident_*` instructs
the parser to parse 0 or more identifiers and create a term
of type `list name` containing these identifiers.
2017-05-31 14:09:25 -07:00
Leonardo de Moura
71ef240817 feat(library/init/meta/interactive): add nary existsi
@Armael, this commit implements the nary existsi.
We can now write
a) existsi t
b) existsi [t_1, t_2, t_3]
2017-05-31 13:41:25 -07:00