feat(frontends/lean): add basic notation for collections
This commit is contained in:
parent
2b570e1eae
commit
c0ff9967af
25 changed files with 277 additions and 59 deletions
|
|
@ -9,7 +9,7 @@ import init.relation init.nat init.prod init.sum init.combinator
|
|||
import init.bool init.unit init.num init.sigma init.setoid init.quot
|
||||
import init.funext init.function init.subtype init.classical
|
||||
import init.monad init.option init.state init.fin init.list init.char init.string init.to_string
|
||||
import init.monad_combinators
|
||||
import init.monad_combinators init.set
|
||||
import init.timeit init.trace init.unsigned init.ordering init.list_classes init.coe
|
||||
import init.wf init.nat_div init.meta init.instances
|
||||
import init.wf_k init.sigma_lex
|
||||
|
|
|
|||
|
|
@ -9,30 +9,28 @@ open decidable
|
|||
|
||||
universe variables u
|
||||
|
||||
structure subtype {A : Type u} (P : A → Prop) :=
|
||||
tag :: (elt_of : A) (has_property : P elt_of)
|
||||
|
||||
notation `{` binder ` \ `:0 r:(scoped:1 P, subtype P) `}` := r
|
||||
structure subtype {A : Type u} (p : A → Prop) :=
|
||||
tag :: (elt_of : A) (has_property : p elt_of)
|
||||
|
||||
namespace subtype
|
||||
|
||||
definition exists_of_subtype {A : Type u} {P : A → Prop} : { x \ P x } → ∃ x, P x
|
||||
definition exists_of_subtype {A : Type u} {p : A → Prop} : { x \ p x } → ∃ x, p x
|
||||
| ⟨a, h⟩ := ⟨a, h⟩
|
||||
|
||||
variables {A : Type u} {P : A → Prop}
|
||||
variables {A : Type u} {p : A → Prop}
|
||||
|
||||
theorem tag_irrelevant {a : A} (h1 h2 : P a) : tag a h1 = tag a h2 :=
|
||||
theorem tag_irrelevant {a : A} (h1 h2 : p a) : tag a h1 = tag a h2 :=
|
||||
rfl
|
||||
|
||||
protected theorem eq : ∀ {a1 a2 : {x \ P x}}, elt_of a1 = elt_of a2 → a1 = a2
|
||||
protected theorem eq : ∀ {a1 a2 : {x \ p x}}, elt_of a1 = elt_of a2 → a1 = a2
|
||||
| ⟨x, h1⟩ ⟨.x, h2⟩ rfl := rfl
|
||||
|
||||
end subtype
|
||||
|
||||
open subtype
|
||||
|
||||
variables {A : Type u} {P : A → Prop}
|
||||
variables {A : Type u} {p : A → Prop}
|
||||
|
||||
attribute [instance]
|
||||
protected definition subtype.is_inhabited {a : A} (h : P a) : inhabited {x \ P x} :=
|
||||
protected definition subtype.is_inhabited {a : A} (h : p a) : inhabited {x \ p x} :=
|
||||
⟨⟨a, h⟩⟩
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ inductive_cmds.cpp dependencies.cpp
|
|||
pp.cpp structure_cmd.cpp structure_instance.cpp
|
||||
init_module.cpp type_util.cpp local_ref_info.cpp decl_attributes.cpp nested_declaration.cpp
|
||||
opt_cmd.cpp prenum.cpp print_cmd.cpp elaborator.cpp
|
||||
match_expr.cpp local_context_adapter.cpp decl_util.cpp definition_cmds.cpp)
|
||||
match_expr.cpp local_context_adapter.cpp decl_util.cpp definition_cmds.cpp
|
||||
brackets.cpp)
|
||||
|
|
|
|||
130
src/frontends/lean/brackets.cpp
Normal file
130
src/frontends/lean/brackets.cpp
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#include "kernel/abstract.h"
|
||||
#include "library/constants.h"
|
||||
#include "library/placeholder.h"
|
||||
#include "frontends/lean/parser.h"
|
||||
#include "frontends/lean/util.h"
|
||||
#include "frontends/lean/tokens.h"
|
||||
|
||||
namespace lean {
|
||||
/* Parse rest of the subtype expression prefix '{' id ':' expr '\' ... */
|
||||
static expr parse_subtype(parser & p, pos_info const & pos, expr const & local) {
|
||||
parser::local_scope scope(p);
|
||||
p.add_local(local);
|
||||
expr pred = p.parse_expr();
|
||||
p.check_token_next(get_rcurly_tk(), "invalid subtype, '}' expected");
|
||||
pred = p.save_pos(Fun(local, pred), pos);
|
||||
expr subtype = p.save_pos(mk_constant(get_subtype_name()), pos);
|
||||
return p.mk_app(subtype, pred, pos);
|
||||
}
|
||||
|
||||
/* Create empty collection for '{' '}' */
|
||||
static expr mk_empty_collection(parser & p, pos_info const & pos) {
|
||||
return p.save_pos(mk_constant(get_empty_col_name()), pos);
|
||||
}
|
||||
|
||||
/* Create singletoncollection for '{' expr '}' */
|
||||
static expr mk_singleton(parser & p, pos_info const & pos, expr const & e) {
|
||||
return p.mk_app(p.save_pos(mk_constant(get_singleton_name()), pos), e, pos);
|
||||
}
|
||||
|
||||
/* Parse rest of the insertable '{' expr ... */
|
||||
static expr parse_insertable(parser & p, pos_info const & pos, expr const & e) {
|
||||
lean_assert(p.curr_is_token(get_comma_tk()));
|
||||
expr r = mk_singleton(p, pos, e);
|
||||
while (p.curr_is_token(get_comma_tk())) {
|
||||
auto ins_pos = p.pos();
|
||||
p.next();
|
||||
expr e2 = p.parse_expr();
|
||||
expr insert = p.save_pos(mk_constant(get_insert_name()), ins_pos);
|
||||
r = p.rec_save_pos(mk_app(insert, e2, r), ins_pos);
|
||||
}
|
||||
p.check_token_next(get_rcurly_tk(), "invalid explicit finite collection, '}' expected");
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Parse rest of the qualified structure instance prefix '{' S '.' ... */
|
||||
static expr parse_qualified_structure_instance(parser & p, pos_info const & pos, name const & S) {
|
||||
throw parser_error("qualified strucuture instance was not implemented yet", pos);
|
||||
}
|
||||
|
||||
/* Parse rest of the structure instance prefix '{' fname ... */
|
||||
static expr parse_structure_instance(parser & p, pos_info const & pos, name const & fname) {
|
||||
throw parser_error("strucuture instance was not implemented yet", pos);
|
||||
}
|
||||
|
||||
/* Parse rest of the structure instance update '{' expr 'with' ... */
|
||||
static expr parse_structure_instance_update(parser & p, pos_info const & pos, expr const & e) {
|
||||
throw parser_error("strucuture instance update was not implemented yet", pos);
|
||||
}
|
||||
|
||||
/* Parse rest of the monadic comprehension expression '{' expr '|' ... */
|
||||
static expr parse_monadic_comprehension(parser & p, pos_info const & pos, expr const & e) {
|
||||
throw parser_error("monadic comprehension was not implemented yet", pos);
|
||||
}
|
||||
|
||||
/* Parse rest of the sep expression '{' id '∈' ... */
|
||||
static expr parse_sep(parser & p, pos_info const & pos, name const & id) {
|
||||
throw parser_error("sep was not implemented yet", pos);
|
||||
}
|
||||
|
||||
expr parse_curly_bracket(parser & p, unsigned, expr const *, pos_info const & pos) {
|
||||
expr e;
|
||||
if (p.curr_is_token(get_rcurly_tk())) {
|
||||
p.next();
|
||||
return mk_empty_collection(p, pos);
|
||||
} else if (p.curr_is_identifier()) {
|
||||
auto id_pos = p.pos();
|
||||
name id = p.get_name_val();
|
||||
p.next();
|
||||
if (p.curr_is_token(get_backslash_tk())) {
|
||||
expr type = p.save_pos(mk_expr_placeholder(), id_pos);
|
||||
expr local = p.save_pos(mk_local(id, type), id_pos);
|
||||
p.next();
|
||||
return parse_subtype(p, pos, local);
|
||||
} else if (p.curr_is_token(get_colon_tk())) {
|
||||
p.next();
|
||||
expr type = p.parse_expr();
|
||||
expr local = p.save_pos(mk_local(id, type), id_pos);
|
||||
p.check_token_next(get_backslash_tk(), "invalid subtype, '\' expected");
|
||||
return parse_subtype(p, pos, local);
|
||||
} else if (p.curr_is_token(get_period_tk())) {
|
||||
p.next();
|
||||
return parse_qualified_structure_instance(p, pos, id);
|
||||
} else if (p.curr_is_token(get_assign_tk()) || p.curr_is_token(get_fieldarrow_tk())) {
|
||||
return parse_structure_instance(p, pos, id);
|
||||
} else if (p.curr_is_token(get_membership_tk())) {
|
||||
p.next();
|
||||
return parse_sep(p, pos, id);
|
||||
} else {
|
||||
expr left = p.id_to_expr(id, id_pos);
|
||||
unsigned rbp = 0;
|
||||
while (rbp < p.curr_lbp()) {
|
||||
left = p.parse_led(left);
|
||||
}
|
||||
e = left;
|
||||
}
|
||||
} else {
|
||||
e = p.parse_expr();
|
||||
}
|
||||
|
||||
if (p.curr_is_token(get_comma_tk())) {
|
||||
return parse_insertable(p, pos, e);
|
||||
} else if (p.curr_is_token(get_rcurly_tk())) {
|
||||
return parse_insertable(p, pos, e);
|
||||
} else if (p.curr_is_token(get_with_tk())) {
|
||||
p.next();
|
||||
return parse_structure_instance_update(p, pos, e);
|
||||
} else if (p.curr_is_token(get_bar_tk())) {
|
||||
p.next();
|
||||
return parse_monadic_comprehension(p, pos, e);
|
||||
} else {
|
||||
throw parser_error("invalid '{' expression, ',', '}', 'with', `\\` or `|` expected", p.pos());
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/frontends/lean/brackets.h
Normal file
11
src/frontends/lean/brackets.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#pragma once
|
||||
#include "frontends/lean/parser.h"
|
||||
namespace lean {
|
||||
expr parse_curly_bracket(parser & p, unsigned, expr const * args, pos_info const & pos);
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ Author: Leonardo de Moura
|
|||
#include "frontends/lean/nested_declaration.h"
|
||||
#include "frontends/lean/match_expr.h"
|
||||
#include "frontends/lean/decl_util.h"
|
||||
#include "frontends/lean/brackets.h"
|
||||
|
||||
#ifndef LEAN_DEFAULT_PARSER_CHECKPOINT_HAVE
|
||||
#define LEAN_DEFAULT_PARSER_CHECKPOINT_HAVE true
|
||||
|
|
@ -750,6 +751,7 @@ parse_table init_nud_table() {
|
|||
r = r.add({transition("(", Expr), transition(")", mk_ext_action(parse_rparen))}, x0);
|
||||
r = r.add({transition("(", Expr), transition(":", Expr), transition(")", mk_ext_action(parse_typed_expr))}, x0);
|
||||
r = r.add({transition("⟨", mk_ext_action(parse_constructor))}, x0);
|
||||
r = r.add({transition("{", mk_ext_action(parse_curly_bracket))}, x0);
|
||||
r = r.add({transition("`(", mk_ext_action(parse_quoted_expr))}, x0);
|
||||
r = r.add({transition("`", mk_ext_action(parse_quoted_name))}, x0);
|
||||
r = r.add({transition("%%", mk_ext_action(parse_antiquote_expr))}, x0);
|
||||
|
|
|
|||
|
|
@ -1456,6 +1456,60 @@ auto pretty_fn::pp_proof_type(expr const & t) -> result {
|
|||
return result(group(nest(1, li + pp(t).fmt() + ri)));
|
||||
}
|
||||
|
||||
static bool is_subtype(expr const & e) {
|
||||
return
|
||||
is_constant(get_app_fn(e), get_subtype_name()) &&
|
||||
get_app_num_args(e) == 2 &&
|
||||
is_lambda(app_arg(e));
|
||||
}
|
||||
|
||||
auto pretty_fn::pp_subtype(expr const & e) -> result {
|
||||
lean_assert(is_subtype(e));
|
||||
expr pred = app_arg(e);
|
||||
lean_assert(is_lambda(pred));
|
||||
auto p = binding_body_fresh(pred, true);
|
||||
expr body = p.first;
|
||||
expr local = p.second;
|
||||
format r = bracket("{", format(local_pp_name(local)) + space() + format("\\") + space() + pp_child(body, 0).fmt(), "}");
|
||||
return result(r);
|
||||
}
|
||||
|
||||
static bool is_singleton(expr const & e) {
|
||||
return
|
||||
is_constant(get_app_fn(e), get_singleton_name()) &&
|
||||
get_app_num_args(e) == 4;
|
||||
}
|
||||
|
||||
static bool is_insert(expr const & e) {
|
||||
return
|
||||
is_constant(get_app_fn(e), get_insert_name()) &&
|
||||
get_app_num_args(e) == 5;
|
||||
}
|
||||
|
||||
/* Return true iff 'e' encodes a nonempty finite collection,
|
||||
and stores its elements at elems. */
|
||||
static bool is_explicit_collection(expr const & e, buffer<expr> & elems) {
|
||||
if (is_singleton(e)) {
|
||||
elems.push_back(app_arg(e));
|
||||
return true;
|
||||
} else if (is_insert(e) && is_explicit_collection(app_arg(e), elems)) {
|
||||
elems.push_back(app_arg(app_fn(e)));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto pretty_fn::pp_explicit_collection(buffer<expr> const & elems) -> result {
|
||||
lean_assert(!elems.empty());
|
||||
format r = pp_child(elems[0], 0).fmt();
|
||||
for (unsigned i = 1; i < elems.size(); i++) {
|
||||
r += nest(m_indent, comma() + line() + pp_child(elems[i], 0).fmt());
|
||||
}
|
||||
r = group(bracket("{", r, "}"));
|
||||
return result(r);
|
||||
}
|
||||
|
||||
auto pretty_fn::pp(expr const & e, bool ignore_hide) -> result {
|
||||
check_system("pretty printer");
|
||||
if ((m_depth >= m_max_depth ||
|
||||
|
|
@ -1481,6 +1535,14 @@ auto pretty_fn::pp(expr const & e, bool ignore_hide) -> result {
|
|||
if (auto r = pp_notation(e))
|
||||
return *r;
|
||||
|
||||
if (m_notation) {
|
||||
if (is_subtype(e))
|
||||
return pp_subtype(e);
|
||||
buffer<expr> elems;
|
||||
if (is_explicit_collection(e, elems))
|
||||
return pp_explicit_collection(elems);
|
||||
}
|
||||
|
||||
if (is_placeholder(e)) return result(*g_placeholder_fmt);
|
||||
if (is_show(e)) return pp_show(e);
|
||||
if (is_have(e)) return pp_have(e);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ private:
|
|||
result pp_hide_coercion_fn(expr const & e, unsigned bp, bool ignore_hide = false);
|
||||
result pp_child_core(expr const & e, unsigned bp, bool ignore_hide = false);
|
||||
result pp_child(expr const & e, unsigned bp, bool ignore_hide = false);
|
||||
result pp_subtype(expr const & e);
|
||||
result pp_explicit_collection(buffer<expr> const & elems);
|
||||
result pp_var(expr const & e);
|
||||
result pp_sort(expr const & e);
|
||||
result pp_const(expr const & e, optional<unsigned> const & num_ref_univs = optional<unsigned>());
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ void init_token_table(token_table & t) {
|
|||
{"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec}, {"Type*", g_max_prec},
|
||||
{"{|", g_max_prec}, {"|}", 0}, {"(:", g_max_prec}, {":)", 0},
|
||||
{"⊢", 0}, {"⟨", g_max_prec}, {"⟩", 0}, {"^", 0}, {"↑", 0}, {"▸", 0},
|
||||
{"|", 0}, {"!", g_max_prec}, {"?", 0}, {"with", 0}, {"...", 0}, {",", 0},
|
||||
{"\\", 0}, {"|", 0}, {"!", g_max_prec}, {"?", 0}, {"with", 0}, {"...", 0}, {",", 0},
|
||||
{".", 0}, {":", 0}, {"::", 0}, {"calc", 0}, {"as", 0}, {":=", 0}, {"--", 0}, {"#", 0},
|
||||
{"(*", 0}, {"/-", 0}, {"begin", g_max_prec}, {"abstract", g_max_prec},
|
||||
{"@@", g_max_prec}, {"@", g_max_prec},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ namespace lean{
|
|||
static name const * g_aliases_tk = nullptr;
|
||||
static name const * g_period_tk = nullptr;
|
||||
static name const * g_backtick_tk = nullptr;
|
||||
static name const * g_backslash_tk = nullptr;
|
||||
static name const * g_fieldarrow_tk = nullptr;
|
||||
static name const * g_placeholder_tk = nullptr;
|
||||
static name const * g_colon_tk = nullptr;
|
||||
static name const * g_semicolon_tk = nullptr;
|
||||
|
|
@ -36,6 +38,7 @@ static name const * g_slash_tk = nullptr;
|
|||
static name const * g_plus_tk = nullptr;
|
||||
static name const * g_star_tk = nullptr;
|
||||
static name const * g_turnstile_tk = nullptr;
|
||||
static name const * g_membership_tk = nullptr;
|
||||
static name const * g_explicit_tk = nullptr;
|
||||
static name const * g_partial_explicit_tk = nullptr;
|
||||
static name const * g_max_tk = nullptr;
|
||||
|
|
@ -124,6 +127,8 @@ void initialize_tokens() {
|
|||
g_aliases_tk = new name{"aliases"};
|
||||
g_period_tk = new name{"."};
|
||||
g_backtick_tk = new name{"`"};
|
||||
g_backslash_tk = new name{"\\"};
|
||||
g_fieldarrow_tk = new name{"~>"};
|
||||
g_placeholder_tk = new name{"_"};
|
||||
g_colon_tk = new name{":"};
|
||||
g_semicolon_tk = new name{";"};
|
||||
|
|
@ -154,6 +159,7 @@ void initialize_tokens() {
|
|||
g_plus_tk = new name{"+"};
|
||||
g_star_tk = new name{"*"};
|
||||
g_turnstile_tk = new name{"⊢"};
|
||||
g_membership_tk = new name{"∈"};
|
||||
g_explicit_tk = new name{"@"};
|
||||
g_partial_explicit_tk = new name{"@@"};
|
||||
g_max_tk = new name{"max"};
|
||||
|
|
@ -243,6 +249,8 @@ void finalize_tokens() {
|
|||
delete g_aliases_tk;
|
||||
delete g_period_tk;
|
||||
delete g_backtick_tk;
|
||||
delete g_backslash_tk;
|
||||
delete g_fieldarrow_tk;
|
||||
delete g_placeholder_tk;
|
||||
delete g_colon_tk;
|
||||
delete g_semicolon_tk;
|
||||
|
|
@ -273,6 +281,7 @@ void finalize_tokens() {
|
|||
delete g_plus_tk;
|
||||
delete g_star_tk;
|
||||
delete g_turnstile_tk;
|
||||
delete g_membership_tk;
|
||||
delete g_explicit_tk;
|
||||
delete g_partial_explicit_tk;
|
||||
delete g_max_tk;
|
||||
|
|
@ -361,6 +370,8 @@ void finalize_tokens() {
|
|||
name const & get_aliases_tk() { return *g_aliases_tk; }
|
||||
name const & get_period_tk() { return *g_period_tk; }
|
||||
name const & get_backtick_tk() { return *g_backtick_tk; }
|
||||
name const & get_backslash_tk() { return *g_backslash_tk; }
|
||||
name const & get_fieldarrow_tk() { return *g_fieldarrow_tk; }
|
||||
name const & get_placeholder_tk() { return *g_placeholder_tk; }
|
||||
name const & get_colon_tk() { return *g_colon_tk; }
|
||||
name const & get_semicolon_tk() { return *g_semicolon_tk; }
|
||||
|
|
@ -391,6 +402,7 @@ name const & get_slash_tk() { return *g_slash_tk; }
|
|||
name const & get_plus_tk() { return *g_plus_tk; }
|
||||
name const & get_star_tk() { return *g_star_tk; }
|
||||
name const & get_turnstile_tk() { return *g_turnstile_tk; }
|
||||
name const & get_membership_tk() { return *g_membership_tk; }
|
||||
name const & get_explicit_tk() { return *g_explicit_tk; }
|
||||
name const & get_partial_explicit_tk() { return *g_partial_explicit_tk; }
|
||||
name const & get_max_tk() { return *g_max_tk; }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ void finalize_tokens();
|
|||
name const & get_aliases_tk();
|
||||
name const & get_period_tk();
|
||||
name const & get_backtick_tk();
|
||||
name const & get_backslash_tk();
|
||||
name const & get_fieldarrow_tk();
|
||||
name const & get_placeholder_tk();
|
||||
name const & get_colon_tk();
|
||||
name const & get_semicolon_tk();
|
||||
|
|
@ -38,6 +40,7 @@ name const & get_slash_tk();
|
|||
name const & get_plus_tk();
|
||||
name const & get_star_tk();
|
||||
name const & get_turnstile_tk();
|
||||
name const & get_membership_tk();
|
||||
name const & get_explicit_tk();
|
||||
name const & get_partial_explicit_tk();
|
||||
name const & get_max_tk();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
aliases aliases
|
||||
period .
|
||||
backtick `
|
||||
backslash \\
|
||||
fieldarrow ~>
|
||||
placeholder _
|
||||
colon :
|
||||
semicolon ;
|
||||
|
|
@ -31,6 +33,7 @@ slash /
|
|||
plus +
|
||||
star *
|
||||
turnstile ⊢
|
||||
membership ∈
|
||||
explicit @
|
||||
partial_explicit @@
|
||||
max max
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ name const * g_div = nullptr;
|
|||
name const * g_id = nullptr;
|
||||
name const * g_empty = nullptr;
|
||||
name const * g_empty_rec = nullptr;
|
||||
name const * g_empty_col = nullptr;
|
||||
name const * g_Exists = nullptr;
|
||||
name const * g_eq = nullptr;
|
||||
name const * g_eq_drec = nullptr;
|
||||
|
|
@ -119,6 +120,7 @@ name const * g_implies = nullptr;
|
|||
name const * g_implies_of_if_neg = nullptr;
|
||||
name const * g_implies_of_if_pos = nullptr;
|
||||
name const * g_implies_resolve = nullptr;
|
||||
name const * g_insert = nullptr;
|
||||
name const * g_int = nullptr;
|
||||
name const * g_int_of_nat = nullptr;
|
||||
name const * g_int_has_zero = nullptr;
|
||||
|
|
@ -309,6 +311,7 @@ name const * g_simplifier_congr_bin_op = nullptr;
|
|||
name const * g_simplifier_congr_bin_arg1 = nullptr;
|
||||
name const * g_simplifier_congr_bin_arg2 = nullptr;
|
||||
name const * g_simplifier_congr_bin_args = nullptr;
|
||||
name const * g_singleton = nullptr;
|
||||
name const * g_sizeof = nullptr;
|
||||
name const * g_smt_array = nullptr;
|
||||
name const * g_smt_select = nullptr;
|
||||
|
|
@ -323,6 +326,7 @@ name const * g_sub = nullptr;
|
|||
name const * g_subsingleton = nullptr;
|
||||
name const * g_subsingleton_elim = nullptr;
|
||||
name const * g_subsingleton_helim = nullptr;
|
||||
name const * g_subtype = nullptr;
|
||||
name const * g_subtype_tag = nullptr;
|
||||
name const * g_subtype_elt_of = nullptr;
|
||||
name const * g_subtype_rec = nullptr;
|
||||
|
|
@ -405,6 +409,7 @@ void initialize_constants() {
|
|||
g_id = new name{"id"};
|
||||
g_empty = new name{"empty"};
|
||||
g_empty_rec = new name{"empty", "rec"};
|
||||
g_empty_col = new name{"empty_col"};
|
||||
g_Exists = new name{"Exists"};
|
||||
g_eq = new name{"eq"};
|
||||
g_eq_drec = new name{"eq", "drec"};
|
||||
|
|
@ -472,6 +477,7 @@ void initialize_constants() {
|
|||
g_implies_of_if_neg = new name{"implies_of_if_neg"};
|
||||
g_implies_of_if_pos = new name{"implies_of_if_pos"};
|
||||
g_implies_resolve = new name{"implies", "resolve"};
|
||||
g_insert = new name{"insert"};
|
||||
g_int = new name{"int"};
|
||||
g_int_of_nat = new name{"int", "of_nat"};
|
||||
g_int_has_zero = new name{"int_has_zero"};
|
||||
|
|
@ -662,6 +668,7 @@ void initialize_constants() {
|
|||
g_simplifier_congr_bin_arg1 = new name{"simplifier", "congr_bin_arg1"};
|
||||
g_simplifier_congr_bin_arg2 = new name{"simplifier", "congr_bin_arg2"};
|
||||
g_simplifier_congr_bin_args = new name{"simplifier", "congr_bin_args"};
|
||||
g_singleton = new name{"singleton"};
|
||||
g_sizeof = new name{"sizeof"};
|
||||
g_smt_array = new name{"smt", "array"};
|
||||
g_smt_select = new name{"smt", "select"};
|
||||
|
|
@ -676,6 +683,7 @@ void initialize_constants() {
|
|||
g_subsingleton = new name{"subsingleton"};
|
||||
g_subsingleton_elim = new name{"subsingleton", "elim"};
|
||||
g_subsingleton_helim = new name{"subsingleton", "helim"};
|
||||
g_subtype = new name{"subtype"};
|
||||
g_subtype_tag = new name{"subtype", "tag"};
|
||||
g_subtype_elt_of = new name{"subtype", "elt_of"};
|
||||
g_subtype_rec = new name{"subtype", "rec"};
|
||||
|
|
@ -759,6 +767,7 @@ void finalize_constants() {
|
|||
delete g_id;
|
||||
delete g_empty;
|
||||
delete g_empty_rec;
|
||||
delete g_empty_col;
|
||||
delete g_Exists;
|
||||
delete g_eq;
|
||||
delete g_eq_drec;
|
||||
|
|
@ -826,6 +835,7 @@ void finalize_constants() {
|
|||
delete g_implies_of_if_neg;
|
||||
delete g_implies_of_if_pos;
|
||||
delete g_implies_resolve;
|
||||
delete g_insert;
|
||||
delete g_int;
|
||||
delete g_int_of_nat;
|
||||
delete g_int_has_zero;
|
||||
|
|
@ -1016,6 +1026,7 @@ void finalize_constants() {
|
|||
delete g_simplifier_congr_bin_arg1;
|
||||
delete g_simplifier_congr_bin_arg2;
|
||||
delete g_simplifier_congr_bin_args;
|
||||
delete g_singleton;
|
||||
delete g_sizeof;
|
||||
delete g_smt_array;
|
||||
delete g_smt_select;
|
||||
|
|
@ -1030,6 +1041,7 @@ void finalize_constants() {
|
|||
delete g_subsingleton;
|
||||
delete g_subsingleton_elim;
|
||||
delete g_subsingleton_helim;
|
||||
delete g_subtype;
|
||||
delete g_subtype_tag;
|
||||
delete g_subtype_elt_of;
|
||||
delete g_subtype_rec;
|
||||
|
|
@ -1112,6 +1124,7 @@ name const & get_div_name() { return *g_div; }
|
|||
name const & get_id_name() { return *g_id; }
|
||||
name const & get_empty_name() { return *g_empty; }
|
||||
name const & get_empty_rec_name() { return *g_empty_rec; }
|
||||
name const & get_empty_col_name() { return *g_empty_col; }
|
||||
name const & get_Exists_name() { return *g_Exists; }
|
||||
name const & get_eq_name() { return *g_eq; }
|
||||
name const & get_eq_drec_name() { return *g_eq_drec; }
|
||||
|
|
@ -1179,6 +1192,7 @@ name const & get_implies_name() { return *g_implies; }
|
|||
name const & get_implies_of_if_neg_name() { return *g_implies_of_if_neg; }
|
||||
name const & get_implies_of_if_pos_name() { return *g_implies_of_if_pos; }
|
||||
name const & get_implies_resolve_name() { return *g_implies_resolve; }
|
||||
name const & get_insert_name() { return *g_insert; }
|
||||
name const & get_int_name() { return *g_int; }
|
||||
name const & get_int_of_nat_name() { return *g_int_of_nat; }
|
||||
name const & get_int_has_zero_name() { return *g_int_has_zero; }
|
||||
|
|
@ -1369,6 +1383,7 @@ name const & get_simplifier_congr_bin_op_name() { return *g_simplifier_congr_bin
|
|||
name const & get_simplifier_congr_bin_arg1_name() { return *g_simplifier_congr_bin_arg1; }
|
||||
name const & get_simplifier_congr_bin_arg2_name() { return *g_simplifier_congr_bin_arg2; }
|
||||
name const & get_simplifier_congr_bin_args_name() { return *g_simplifier_congr_bin_args; }
|
||||
name const & get_singleton_name() { return *g_singleton; }
|
||||
name const & get_sizeof_name() { return *g_sizeof; }
|
||||
name const & get_smt_array_name() { return *g_smt_array; }
|
||||
name const & get_smt_select_name() { return *g_smt_select; }
|
||||
|
|
@ -1383,6 +1398,7 @@ name const & get_sub_name() { return *g_sub; }
|
|||
name const & get_subsingleton_name() { return *g_subsingleton; }
|
||||
name const & get_subsingleton_elim_name() { return *g_subsingleton_elim; }
|
||||
name const & get_subsingleton_helim_name() { return *g_subsingleton_helim; }
|
||||
name const & get_subtype_name() { return *g_subtype; }
|
||||
name const & get_subtype_tag_name() { return *g_subtype_tag; }
|
||||
name const & get_subtype_elt_of_name() { return *g_subtype_elt_of; }
|
||||
name const & get_subtype_rec_name() { return *g_subtype_rec; }
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ name const & get_div_name();
|
|||
name const & get_id_name();
|
||||
name const & get_empty_name();
|
||||
name const & get_empty_rec_name();
|
||||
name const & get_empty_col_name();
|
||||
name const & get_Exists_name();
|
||||
name const & get_eq_name();
|
||||
name const & get_eq_drec_name();
|
||||
|
|
@ -121,6 +122,7 @@ name const & get_implies_name();
|
|||
name const & get_implies_of_if_neg_name();
|
||||
name const & get_implies_of_if_pos_name();
|
||||
name const & get_implies_resolve_name();
|
||||
name const & get_insert_name();
|
||||
name const & get_int_name();
|
||||
name const & get_int_of_nat_name();
|
||||
name const & get_int_has_zero_name();
|
||||
|
|
@ -311,6 +313,7 @@ name const & get_simplifier_congr_bin_op_name();
|
|||
name const & get_simplifier_congr_bin_arg1_name();
|
||||
name const & get_simplifier_congr_bin_arg2_name();
|
||||
name const & get_simplifier_congr_bin_args_name();
|
||||
name const & get_singleton_name();
|
||||
name const & get_sizeof_name();
|
||||
name const & get_smt_array_name();
|
||||
name const & get_smt_select_name();
|
||||
|
|
@ -325,6 +328,7 @@ name const & get_sub_name();
|
|||
name const & get_subsingleton_name();
|
||||
name const & get_subsingleton_elim_name();
|
||||
name const & get_subsingleton_helim_name();
|
||||
name const & get_subtype_name();
|
||||
name const & get_subtype_tag_name();
|
||||
name const & get_subtype_elt_of_name();
|
||||
name const & get_subtype_rec_name();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ div
|
|||
id
|
||||
empty
|
||||
empty.rec
|
||||
empty_col
|
||||
Exists
|
||||
eq
|
||||
eq.drec
|
||||
|
|
@ -114,6 +115,7 @@ implies
|
|||
implies_of_if_neg
|
||||
implies_of_if_pos
|
||||
implies.resolve
|
||||
insert
|
||||
int
|
||||
int.of_nat
|
||||
int_has_zero
|
||||
|
|
@ -304,6 +306,7 @@ simplifier.congr_bin_op
|
|||
simplifier.congr_bin_arg1
|
||||
simplifier.congr_bin_arg2
|
||||
simplifier.congr_bin_args
|
||||
singleton
|
||||
sizeof
|
||||
smt.array
|
||||
smt.select
|
||||
|
|
@ -318,6 +321,7 @@ sub
|
|||
subsingleton
|
||||
subsingleton.elim
|
||||
subsingleton.helim
|
||||
subtype
|
||||
subtype.tag
|
||||
subtype.elt_of
|
||||
subtype.rec
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
noncomputable definition Sum : nat → (nat → nat) → nat := sorry
|
||||
attribute [forward]
|
||||
definition Sum_weird (f g h : nat → nat) (n : nat) : (Sum n (λ x, f (g (h x)))) = 1 := sorry
|
||||
print Sum_weird
|
||||
|
||||
/-
|
||||
attribute [forward]
|
||||
definition Sum_weird : ∀ (f g h : nat → nat) (n : nat), eq (Sum n (λ (x : nat), f (g (h x)))) 1 :=
|
||||
λ (f g h : nat → nat) (n : nat), sorry
|
||||
(multi-)patterns:
|
||||
?M_1 : nat → nat, ?M_2 : nat → nat, ?M_3 : nat → nat, ?M_4 : nat
|
||||
{Sum ?M_4 (λ (x : nat), ?M_1)}
|
||||
-/
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
attribute [forward]
|
||||
definition Sum_weird : ∀ (f g h : ℕ → ℕ) (n : ℕ), Sum n (λ (x : ℕ), f (g (h x))) = 1 :=
|
||||
λ (f g h : ℕ → ℕ) (n : ℕ), sorry
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
quot.sound : ∀ {A : Type u} [s : setoid A] {a b : A}, a ≈ b → ⟦a⟧ = ⟦b⟧
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x : A \ Exists P → P x}
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x \ Exists P → P x}
|
||||
propext : ∀ {a b : Prop}, (a ↔ b) → a = b
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
quot.sound : ∀ {A : Type u} [s : setoid A] {a b : A}, a ≈ b → ⟦a⟧ = ⟦b⟧
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x : A \ Exists P → P x}
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x \ Exists P → P x}
|
||||
propext : ∀ {a b : Prop}, (a ↔ b) → a = b
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
no axioms
|
||||
------
|
||||
quot.sound : ∀ {A : Type u} [s : setoid A] {a b : A}, a ≈ b → ⟦a⟧ = ⟦b⟧
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x : A \ Exists P → P x}
|
||||
classical.strong_indefinite_description : Π {A : Type u} (P : A → Prop), nonempty A → {x \ Exists P → P x}
|
||||
propext : ∀ {a b : Prop}, (a ↔ b) → a = b
|
||||
------
|
||||
theorem foo3 : 0 = 0 :=
|
||||
|
|
|
|||
12
tests/lean/run/curly_notation.lean
Normal file
12
tests/lean/run/curly_notation.lean
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
check ({1, 2, 3} : set nat)
|
||||
check ({1} : set nat)
|
||||
check ({} : set nat)
|
||||
|
||||
definition s1 : set nat := {1, 2+3, 3, 4}
|
||||
print s1
|
||||
|
||||
definition s2 : set char := {'a', 'b', 'c'}
|
||||
print s2
|
||||
|
||||
definition s3 : set string := {"hello", "world"}
|
||||
print s3
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
constant f : nat → nat → nat
|
||||
constant g : nat → nat → nat
|
||||
attribute g [no_pattern]
|
||||
|
||||
namespace foo
|
||||
|
||||
attribute [forward]
|
||||
definition lemma1 {a b : nat} : f a b = g a b :=
|
||||
sorry
|
||||
|
||||
end foo
|
||||
|
||||
print foo.lemma1
|
||||
open foo
|
||||
print foo.lemma1
|
||||
attribute foo.lemma1 [forward]
|
||||
|
||||
print foo.lemma1
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
constant Sum : (nat → nat) → nat → nat
|
||||
|
||||
attribute [forward]
|
||||
lemma l1 (f : nat → nat) : Sum f 0 = 0 :=
|
||||
sorry
|
||||
|
||||
print l1
|
||||
|
|
@ -1 +0,0 @@
|
|||
print [no_pattern]
|
||||
|
|
@ -1 +1 @@
|
|||
{x : ℕ \ x > 0} : Type
|
||||
{x \ x > 0} : Type
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue