Commit graph

502 commits

Author SHA1 Message Date
Leonardo de Moura
33193e1ab3 feat(library/simplifier): improve contextual simplifications
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-23 12:54:29 -08:00
Leonardo de Moura
d6692264e8 feat(library/simplifier): contextual simplifications
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-23 12:23:22 -08:00
Leonardo de Moura
1638a7bb02 fix(frontends/lean/pp): compute local shared nodes, and avoid unnecessary let's
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-22 21:44:24 -08:00
Leonardo de Moura
17cce340f6 fix(library/elaborator): in optimization for metavariable free terms
The optimization was incorrect if the term indirectly contained a metavariable.
It could happen if the term contained a free variable that was assigned in the context to a term containing a metavariable.

This commit also adds a new test that exposes the problem.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-22 18:06:00 -08:00
Leonardo de Moura
8214c7add4 feat(library/elaborator): compensate the lack of eta-reduction (and eta-expanded normal forms) in the kernel normalizer
Before this commit, the elaborator was solving constraints of the form

       ctx |- (?m x) == (f x)
as
       ?m <- (fun x : A, f x)    where A is the domain of f.

In our kernel, the terms f and (fun x, f x) are not definitionally equal.
So, the solution above is not the only one. Another possible solution is

       ?m  <- f

Depending of the circumstances we want  ?m <- (fun x : A, f x) OR ?m <- f.
For example, when Lean is elaborating the eta-theorem in kernel.lean, the first solution should be used:
       ?m <- (fun x : A, f x)

When we are elaborating the axiom_of_choice theorem, we need to use the second one:
       ?m <- f

Of course, we can always provide the parameters explicitly and bypass the elaborator.
However, this goes against the idea that the elaborator can do mechanical steps for us.

This commit addresses this issue by creating a case-split
       ?m <- (fun x : A, f x)
       OR
       ?m <- f

Another solution is to implement eta-expanded normal forms in the Kernel.

With this change, we were able to cleanup the following "hacks" in kernel.lean:
     @eps_ax A (nonempty_ex_intro H) P w Hw
     @axiom_of_choice A B P H
where we had to explicitly provided the implicit arguments

This commit also improves the imitation step for Pi-terms that are actually arrows.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-22 13:28:54 -08:00
Leonardo de Moura
331b5846c6 test(library/simplifier): add test for the single_pass option in the simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-21 13:47:54 -08:00
Leonardo de Moura
ead54bbf57 feat(library/simplifier): enforce max_steps option
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-21 12:12:17 -08:00
Leonardo de Moura
1ccfac5873 feat(library/simplifier): conditional rewriting
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 21:15:46 -08:00
Leonardo de Moura
1ef75a9ba6 test(tests/lua): add test/example that demonstrates how to collect statistics of used theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 18:04:22 -08:00
Leonardo de Moura
6bcd8e3ee5 fix(library/expr_lt): use expression depth instead of size to obtain a monotonic total order on terms
It is not incorrect to use size, but it can easily overflow due to sharing.
The following script demonstrates the problem:

local f = Const("f")
local a = Const("a")
function mk_shared(d)
   if d == 0 then
      return a
   else
      local c = mk_shared(d-1)
      return f(c, c)
   end
end
print(mk_shared(33):size())

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 17:40:49 -08:00
Leonardo de Moura
cd19d4da01 feat(library/simplifier): memoize intermediate results
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 17:03:44 -08:00
Leonardo de Moura
97ead50a3e feat(builtin/Nat): flip orientation of associativity axioms for + and *
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 15:38:00 -08:00
Leonardo de Moura
d1bd56b3d3 fix(tests/lean): adjust test to reflect recent changes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 14:47:03 -08:00
Leonardo de Moura
ad219d43d9 refactor(*): semantic attachment parsing and simplification
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 14:44:45 -08:00
Leonardo de Moura
ac9f8f340d feat(kernel/expr): add efficient get_size() function for expressions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 12:28:37 -08:00
Leonardo de Moura
5224df56a3 test(tests/lean): add example showing how to 'sort' argumentes of AC operators using the simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 08:36:48 -08:00
Leonardo de Moura
913d893204 feat(library/simplifier): add support for 'permutation' rewrite rules
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-20 08:29:31 -08:00
Leonardo de Moura
69d7ee316f feat(library/simplifier): improve simplification by evaluation
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 23:26:34 -08:00
Leonardo de Moura
bcede6925f fix(tests/lean): add expected result file
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 16:31:35 -08:00
Leonardo de Moura
19f3c281c3 test(tests/lean): matrix multiplication example
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 16:29:32 -08:00
Leonardo de Moura
999984e701 fix(tests/lean): remove unnecessary theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 12:55:33 -08:00
Leonardo de Moura
cc11b9e125 test(tests/lean): rewriting proof example
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 12:53:21 -08:00
Leonardo de Moura
d322f63113 feat(frontends/lea): add commands for creating and managing rewrite rule sets
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 12:03:59 -08:00
Leonardo de Moura
bbf6e6a256 feat(builtin/kernel): create default rule set in the kernel, and adjust unit tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 11:24:20 -08:00
Leonardo de Moura
7492fd5a2c feat(library/simplifier): add support for simplification by evaluation
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 10:34:55 -08:00
Leonardo de Moura
11719713ec feat(library/hop_match): optionally unfold constants when performing higher order matching
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 10:32:06 -08:00
Leonardo de Moura
39c3b17eb7 feat(library/simplifier): add support for Eta-reduction in the simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 00:40:35 -08:00
Leonardo de Moura
ed009f4c88 feat(kernel/simplifier): add support for Beta-reduction in the simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-19 00:40:20 -08:00
Leonardo de Moura
7a3aab60c6 chore(builtin/kernel): remove \bowtie as notation for transitivity
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-18 21:11:12 -08:00
Leonardo de Moura
32c5bc25e3 refactor(library/simplifier): cleanup rewrite_rule_set, and use it in the simplifier
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-18 20:52:33 -08:00
Leonardo de Moura
feea96e84d feat(library/simplifier): add rewrite_rule_set extension for managing rewrite rules in an environment
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-18 15:43:24 -08:00
Leonardo de Moura
40b7ed13c2 fix(tests/lean): adjust tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-17 19:27:32 -08:00
Leonardo de Moura
fc4c6454a7 chore(tests/lean): adjust tests to reflect recent changes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-17 14:36:55 -08:00
Leonardo de Moura
a43020b31b refactor(kernel): remove heterogeneous equality
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-16 17:39:12 -08:00
Leonardo de Moura
5453a8f2f1 test(tests/lua): hop_match experiment
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-16 00:15:31 -08:00
Leonardo de Moura
3238c7e2a0 feat(library/simplifier): add is_permutation_ceq predicate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 19:53:52 -08:00
Leonardo de Moura
2368c936d3 test(tests/lua): exercise fields method for semantic attachments
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 17:24:18 -08:00
Leonardo de Moura
57e58c598c fix(tests/lean): adjust tests to reflect recent changes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 16:35:33 -08:00
Leonardo de Moura
c73398a0b8 refactor(library/simplifier): relax rule for conditional equalities
The idea is to support conditional equations where the left-hand-side does not contain all theorem arguments, but the missing arguments can be inferred using type inference.
For example, we will be able to have the eta theorem as rewrite rule:

theorem eta {A : TypeU} {B : A → TypeU} (f : ∀ x : A, B x) : (λ x : A, f x) = f
:= funext (λ x : A, refl (f x))

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 16:06:00 -08:00
Leonardo de Moura
3daac17ea8 feat(library/simplifier): convert disequalities (a ≠ b) into equations '(a = b) = false'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 15:30:16 -08:00
Leonardo de Moura
f67b5c4d00 test(tests/lua): more to_ceqs tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 13:50:35 -08:00
Leonardo de Moura
c651d3ea2d feat(library/simplifier): filter out propositions that cannot be used as conditional equations
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 12:06:27 -08:00
Leonardo de Moura
94fa987814 fix(kernel/type_checker): is_proposition method was still assuming that a Pi never has type Bool
The method is_proposition was using an optimization that became incorrect after  we identified Pi and forall.
It was assuming that any Pi expression is not a proposition.
This is not true anymore. Now, (Pi x : A, B) is a proposition if B is a proposition.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 11:02:52 -08:00
Leonardo de Moura
91e1f9fc02 fix(tests/lean): adjust test to reflect recent changes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 10:20:35 -08:00
Leonardo de Moura
3ab2d2a441 fix(frontends/lean/parser): memory leak due to g++ bug
g++ implementation of std::initializer_list has bug.
http://gcc.gnu.org/ml/gcc-bugs/2013-06/msg00095.html

This commit memory leaks triggered by this bug.
It also adds minimal tests to expose three different instances of the problem.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 10:15:04 -08:00
Leonardo de Moura
97d9765992 fix(tests/lua/threads): increase timeout to make sure it passes the test on slow machines
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 08:46:14 -08:00
Leonardo de Moura
c8e1ec87d2 feat(library/simplifier): add to_ceqs function that converts a theorem into a sequence of conditional equations
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-14 18:30:19 -08:00
Leonardo de Moura
7c2a4211a8 feat(kernel): expose imported predicate
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-14 16:41:40 -08:00
Leonardo de Moura
8217a544cc fix(library/hop_match): bugs in the higher-order matching procedure, add more tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-14 14:37:28 -08:00
Leonardo de Moura
485ca842c9 test(tests/lua): extra tests for Lua hierachical name API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-14 11:38:10 -08:00
Leonardo de Moura
4595c50f7e fix(library/hop_match): in locally bound variable management
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-13 18:06:23 -08:00
Leonardo de Moura
ccb9faf065 refactor(*): error messages
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-13 16:54:21 -08:00
Leonardo de Moura
55aa4cbfa3 feat(frontends/lean): improve error message for expressions containing unsolved metavariables
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-13 13:21:44 -08:00
Leonardo de Moura
12451e4a35 feat(frontends/lean/pp): display implicit arguments when expression contains metavariables
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-13 12:42:05 -08:00
Leonardo de Moura
84f017f127 chore(tests/lua): use default environment instead of creating a new one
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-12 18:24:04 -08:00
Leonardo de Moura
35bacf95fc feat(shell): provide the default environment when parsing Lua files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-12 18:21:14 -08:00
Leonardo de Moura
7f818ecd92 feat(library): match procedure for higher-order patterns
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-12 17:45:24 -08:00
Leonardo de Moura
b85b45b40f test(tests/lean): When and Cond tactical tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 20:43:39 -08:00
Leonardo de Moura
65bdb9c7e0 fix(frontends/lean): unprotected call to Lua API
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 19:56:20 -08:00
Leonardo de Moura
411f14415d feat(builtin): automatically generate Lean/C++ interface for builtin theories
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 18:09:53 -08:00
Leonardo de Moura
a339a53f50 feat(util/options): 'verbose' as a system option, add -q (quiet) option
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 15:31:58 -08:00
Leonardo de Moura
2179e57db3 refactor(builtin): move if_then_else to its own module
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 14:08:39 -08:00
Leonardo de Moura
52e11dbbee test(tests/lean): 'using' command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 12:21:14 -08:00
Leonardo de Moura
fdeb457a81 feat(kernel/pos_info_provider): add support for file names in pos_info_provider
The idea is to include the file name when displaying justification objects.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 12:19:30 -08:00
Leonardo de Moura
84e211b81b fix(frontends/lean): missing ':' in error messages
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 11:19:58 -08:00
Leonardo de Moura
f7c7dd4ed4 feat(frontends/lean): include filename in error messages, use GNU error message style
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 11:01:27 -08:00
Leonardo de Moura
57c0006916 chore(*): cleanup lean builtin symbols, replace :: with _
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-09 08:33:52 -08:00
Leonardo de Moura
e42b616438 fix(kernel/normalizer): equality between semantic attachments
Given a heterogenous equality:  a == b
The normalizer will only reduce it if a and b are objects of the same kind.
Now, 1 == true is not reduced to false anymore.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 19:10:30 -08:00
Leonardo de Moura
a4b3d6d6c8 refactor(builtin/kernel): prove eta using function extensionality, and rename abst and abstpi to funext and allext
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 17:25:14 -08:00
Leonardo de Moura
a6e0dcc96c fix(builtin/cast): remove dominj axiom, it is not consistent with the new semantics of Pi/forall
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 16:19:11 -08:00
Leonardo de Moura
2b2aa228e3 refactor(builtin/kernel): start with small universes
The universe constraint manager is more flexible now.
We don't need to start with a huge universe  U >= 512.
We can start small, and increase it on demand.

If module mod1 needs it, it can always add

   universe U >= 3

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 12:35:00 -08:00
Leonardo de Moura
abf61be8f6 chore(library/tactic): remove imp_tac, it is not needed anymore
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 00:57:04 -08:00
Leonardo de Moura
048151487e feat(kernel): use Pi as forall/implication
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-08 00:38:39 -08:00
Leonardo de Moura
d12d0f036f feat(kernel/environment): universe variables now live in their own namespace
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 15:57:36 -08:00
Leonardo de Moura
d29d23cade test(tests/lean): alias command error
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 15:29:16 -08:00
Leonardo de Moura
9f4959fb64 test(tests/lean): kernel exception pp method
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 15:19:52 -08:00
Leonardo de Moura
0363faeec8 fix(frontends/lean/scanner): assertion violation, and add more tests
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 15:12:34 -08:00
Leonardo de Moura
29db6accb8 test(tests/lean): new tests for exercising the environment object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 14:34:21 -08:00
Leonardo de Moura
0a20356a51 fix(kernel/environment): we should not add an universe contraint object to the set of object when an integer overflow occurs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 13:43:22 -08:00
Leonardo de Moura
17c4cce89c fix(library/elaborator): remove_detail procedure was keeping a lot of details when typeof_mvar_justification was being used
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 13:24:46 -08:00
Leonardo de Moura
0f1737d62c fix(frontends/lean): more precise position information for infix operators
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 13:19:26 -08:00
Leonardo de Moura
8f3c97ca98 test(tests/lean): standard induction
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-07 10:18:31 -08:00
Leonardo de Moura
abb9b8af83 fix(frontends/lean): bug in pop::context command, and add new tests for the universe command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-06 17:14:07 -08:00
Leonardo de Moura
5fe8c32da9 feat(kernel): use new universe contraints in the environment, allow new constraints to be added
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-06 16:46:11 -08:00
Leonardo de Moura
8c956280d9 chore(frontends/lean): rename setoption and setopaque commands to set::option and set::opaque
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-06 11:41:03 -08:00
Leonardo de Moura
7222a2d1a9 feat(builtin/kernel): use the same notation for mp, eq::mp and forall::elim
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 21:39:31 -08:00
Leonardo de Moura
935c2a03a3 feat(*): change name conventions for Lean builtin libraries
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 19:21:44 -08:00
Leonardo de Moura
4ba097a141 feat(frontends/lean): use lowercase commands, replace 'endscope' and 'endnamespace' with 'end'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 13:06:36 -08:00
Leonardo de Moura
6569b07b7c feat(frontends/lean/parser): rename 'show' expression to 'have'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 11:25:58 -08:00
Leonardo de Moura
0b4bdceb10 feat(builtin/macros): rename 'For' macro to 'take'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 11:08:55 -08:00
Leonardo de Moura
9f08156a73 feat(frontends/lean/parser): combine Echo and Show commands into the 'print' command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 11:03:35 -08:00
Leonardo de Moura
ce1213a020 feat(frontends/lean): use '(* ... *)' instead of '(** ... **)' for script code blocks
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 10:32:47 -08:00
Leonardo de Moura
028a9bd9bd feat(frontends/lean/scanner): use Lua style comments in Lean
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 08:53:27 -08:00
Leonardo de Moura
fbe0bccf51 chore(*): name convention, proof construnction functions/macros start with upper-case
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-03 18:11:01 -08:00
Leonardo de Moura
9eb4dc4a81 feat(kernel, library/elaborator, frontends/lean): improve how elaborator_exceptions are displayed in the Lean frontend
This commit affects different modules.
I used the following approach:
1- I store the metavariable environment at unification_failure_justifications. The idea is to capture the set of instantiated metavariables at the time of failure.
2- I added a remove_detail function. It removes propagation steps from the justification tree object. I also remove the backtracking search space associated with higher-order unificiation. I keep only the search related to case-splits due to coercions and overloads.

3- I use the metavariable environment captured at step 1 when pretty printing the justification of an elaborator_exception.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-03 17:18:23 -08:00
Leonardo de Moura
502d9f47ac test(tests/lean): new test full of holes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 16:31:52 -08:00
Leonardo de Moura
9620b00e24 feat(kernel/metavar): is instantiate_metavars, we are also instantiating assigned metavariables that occur in the local context of unassinged ones.
This modification improves the effectiveness of the process_metavar_inst procedure in the Lean elaborator.

For example, suppose we have the constraint

   ctx |- ?M1[inst:0 ?M2] == a

If ?M1 and ?M2 are unassigned, then we have to consider the two possible solutions:

        ?M1 == a
    or
        ?M1 == #0 and ?M2 == a

On the other hand, if ?M2 is assigned to b, then we can ignore the second case.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 16:08:38 -08:00
Leonardo de Moura
430b75f38f test(tests/lean): add version of the Nat library full of holes
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 12:31:13 -08:00
Leonardo de Moura
e714bd7982 feat(frontends/lean): add syntax sugar for applying Subst in calculational proofs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 11:23:55 -08:00
Leonardo de Moura
111949b9be feat(frontends/lean): calculational proofs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-02 10:53:14 -08:00
Leonardo de Moura
b2a8f4118d feat(library/elaborator): process ho-match before normalizing
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 14:46:19 -08:00
Leonardo de Moura
7726ccad28 chore(builtin): rename nat, int and real modules to Nat, Int and Real.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 13:52:25 -08:00
Leonardo de Moura
d633622d90 feat(frontends/lean/parser): namespaces
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 12:28:18 -08:00
Leonardo de Moura
c423198a69 feat(builtin/kernel): add Not.*Elim theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 11:35:21 -08:00
Leonardo de Moura
a8bc9fb4e0 refactor(builtin/kernel): mark exists as opaque after proving key theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 11:00:32 -08:00
Leonardo de Moura
cbd1f98365 fix(library/elaborator): bug at method process_metavar_inst, add new test that exposed the bug
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-01 03:02:41 -08:00
Leonardo de Moura
cd3bbb1ebf fix(kernel/builtin): enforcing design decision: semantic attachments are NOT simplifiers, they should do only evaluation
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-31 10:14:17 -08:00
Leonardo de Moura
390a78a8d2 chore(frontends/lean/parser): remove 'Skipped' message
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 15:35:12 -08:00
Leonardo de Moura
08718e33dc refactor(builtin): only load the kernel and natural numbers by default
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 13:35:37 -08:00
Leonardo de Moura
ecd62a1783 refactor(builtin/basic): rename basic.lean to kernel.lean
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 11:46:03 -08:00
Leonardo de Moura
4401b390fe refactor(library/arith): do not load specialfn by default
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 11:25:43 -08:00
Leonardo de Moura
46a8300a2d refactor(library/arith): move real and special function declarations to .lean files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 11:02:22 -08:00
Leonardo de Moura
c3bc6afb12 refactor(library/arith): move int and nat declarations to .lean files.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-30 10:32:14 -08:00
Leonardo de Moura
15621610e9 refactor(library/arith): replace Nat, Int, Real with simple variable decls instead of semantic attachments
This commit also fixes bugs in the Alias command.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 17:04:36 -08:00
Leonardo de Moura
a1a5fb101d feat(frontends/lean): add Alias command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 16:25:45 -08:00
Leonardo de Moura
dfe46b9d25 refactor(kernel/builtin): move definition and axioms to basic.lean
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 14:01:30 -08:00
Leonardo de Moura
f8b82d854e feat(builtin/basic): add TypeM alias
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 13:03:32 -08:00
Leonardo de Moura
411ebbc3c1 refactor(library/basic_thms): move the proof of all basic theorems to a .Lean file
This commit also adds several new theorems that are useful for implementing the simplifier.
TODO: perhaps we should remove the declarations at basic_thms.h?

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-29 03:04:49 -08:00
Leonardo de Moura
41c1010043 feat(frontends/lean/parser): make Import command use binary Lean files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-28 19:20:04 -08:00
Leonardo de Moura
1fd81dd3a1 feat(frontends/lean/parser): disable verbose messages when importing files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-28 12:24:13 -08:00
Leonardo de Moura
44a31dd8fb feat(frontends/lean/parser): improve Import command
- The extension does not have to be provided.
- It can also import Lua files.
- Hierachical names can be used instead of strings.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-28 12:05:01 -08:00
Leonardo de Moura
8e86d6578c fix(tests/lean): adjust tests to reflect modifications in the pp
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-27 18:38:45 -08:00
Leonardo de Moura
3f0279b88c refactor(frontends/lua): replace lean.lua.h with util.lua
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 19:49:26 -08:00
Leonardo de Moura
40eca048e0 feat(extra): replace parse_lean_tpl with improved parse_template, that is based on macros
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 19:28:02 -08:00
Leonardo de Moura
275f022d79 fix(tests/lean): ignore lines containing 'executing external script' in test scripts, these lines contain references to the path where Lean was built
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 18:41:01 -08:00
Leonardo de Moura
f1b97b18b4 refactor(frontends/lean/parser): tactic macros, and tactic Lua bindings
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 15:54:53 -08:00
Leonardo de Moura
ef18cc4a92 fix(frontends/lean/parser): add existing command macros when creating parser object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 13:38:14 -08:00
Leonardo de Moura
8e4560a866 feat(frontends/lean/parser): protect imported modules from Lua definitions and macros in the file importing the module
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 13:21:36 -08:00
Leonardo de Moura
ba02132a90 feat(frontends/lean/parser): add command macros
The idea is to allow users to define their own commands using Lua.
The builtin command Find is now written in Lua.
This commit also fixes a bug in the get_formatter() Lua API.
It also adds String arguments to macros.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 13:00:28 -08:00
Leonardo de Moura
480781d13e feat(frontends/lean/parser): provide environment as an argument to macros, allow macros to parse tactics
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-26 11:15:45 -08:00
Leonardo de Moura
3673f2ac1d feat(frontends/lean/parser): add Find command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-25 18:31:52 -08:00
Leonardo de Moura
a3dde29f3c feat(frontends/lua/parser): allow users to specify the precedence of macros
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-25 12:27:56 -08:00
Leonardo de Moura
88235d2922 feat(library/tactic/apply_tactic): try other solutions produced by the elaborator
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-25 11:51:27 -08:00
Leonardo de Moura
8e45064f25 feat(library/tactic/apply_tactic): improved parametric apply_tactic
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-24 22:40:34 -08:00
Leonardo de Moura
c87e965f86 fix(tests/lean/tactic14.lean): typo
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-24 21:36:49 -08:00
Leonardo de Moura
cb95b14332 feat(library/tactic/apply_tactic): improve apply_tactic
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-24 14:23:06 -08:00
Leonardo de Moura
879ab6924a tests(test/lean): remove 'Importing...' message, the tests using the Import command fail when running on a different machine
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-24 12:26:53 -08:00
Leonardo de Moura
00e89190c2 refactor(library/cast): use .lean file instead of .cpp file to define casting library
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-23 22:04:19 -08:00
Leonardo de Moura
8c8cefcb0c feat(frontends/lean/parser): compact definitions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-23 21:24:50 -08:00
Leonardo de Moura
5043cc75f6 fix(frontends/lean/parser): allow parenthesis in level expressions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-23 13:31:55 -08:00
Leonardo de Moura
2c30b87f30 test(tests/lean): ExistsElim test
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-23 12:57:25 -08:00
Leonardo de Moura
baf99779dc feat(frontends/lean/frontend_elaborator): use is_convertible to minimize number of coercions
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-22 17:57:51 -08:00
Leonardo de Moura
65f7217935 fix(tests/lean/norm_tac): display implicit parameters to make sure output can be parsed
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-22 17:11:36 -08:00
Leonardo de Moura
3e32d9bef2 feat(library/tactic): add support for Pi's at to_proof_state
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-22 16:40:55 -08:00
Leonardo de Moura
104bd990e1 feat(library/tactic): add normalize_tac, eval_tac and trivial_tac
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-22 14:10:42 -08:00
Leonardo de Moura
4229e498d2 refactor(kernel/type_checker): combine type_checker and type_inferer into a single class, and avoid code duplication
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-22 11:51:38 -08:00
Leonardo de Moura
9128a437b8 refactor(library/cast): replace cast semantic attachment with axioms, add heterogeneous symmetry axiom
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-21 18:23:37 -08:00
Leonardo de Moura
df58eb132e feat(frontends/lean): simplify explicit version names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-21 17:05:25 -08:00
Leonardo de Moura
36b2ec9abb fix(library/cast): bugs in Cast semantic attachment
TODO: revise cast semantic attachment.
It should be axioms instead of semantic attachments.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-21 16:16:54 -08:00
Leonardo de Moura
aebff0b4d3 fix(library/type_inferer): bug in get_range method
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-21 14:55:07 -08:00