refactor(*): normalize metaclass names
@avigad and @fpvandoorn, I changed the metaclasses names. They were not uniform: - The plural was used in some cases (e.g., [coercions]). - In other cases a cryptic name was used (e.g., [brs]). Now, I tried to use the attribute name as the metaclass name whenever possible. For example, we write definition foo [coercion] ... definition bla [forward] ... and open [coercion] nat open [forward] nat It is easier to remember and is uniform.
This commit is contained in:
parent
96bec8b4f9
commit
f177082c3b
45 changed files with 112 additions and 105 deletions
|
@ -17,11 +17,11 @@ namespace core
|
||||||
export empty (hiding elim)
|
export empty (hiding elim)
|
||||||
export sum (hiding elim)
|
export sum (hiding elim)
|
||||||
export sigma (hiding pr1 pr2)
|
export sigma (hiding pr1 pr2)
|
||||||
export [notations] prod
|
export [notation] prod
|
||||||
export [notations] nat
|
export [notation] nat
|
||||||
export eq (idp idpath concat inverse transport ap ap10 cast tr_inv homotopy ap11 apd refl)
|
export eq (idp idpath concat inverse transport ap ap10 cast tr_inv homotopy ap11 apd refl)
|
||||||
export [declarations] function
|
export [declaration] function
|
||||||
export equiv (to_inv to_right_inv to_left_inv)
|
export equiv (to_inv to_right_inv to_left_inv)
|
||||||
export is_equiv (inv right_inv left_inv adjointify)
|
export is_equiv (inv right_inv left_inv adjointify)
|
||||||
export [abbreviations] [declarations] is_trunc (trunctype hprop.mk hset.mk)
|
export [abbreviation] [declaration] is_trunc (trunctype hprop.mk hset.mk)
|
||||||
end core
|
end core
|
||||||
|
|
|
@ -373,5 +373,5 @@ namespace is_equiv
|
||||||
|
|
||||||
end is_equiv
|
end is_equiv
|
||||||
|
|
||||||
export [unfold_hints] equiv
|
export [unfold] equiv
|
||||||
export [unfold_hints] is_equiv
|
export [unfold] is_equiv
|
||||||
|
|
|
@ -60,4 +60,4 @@ notation f ` -[` op `]- ` g := combine f op g
|
||||||
end function
|
end function
|
||||||
|
|
||||||
-- copy reducible annotations to top-level
|
-- copy reducible annotations to top-level
|
||||||
export [reduce_hints] [unfold_hints] function
|
export [reducible] [unfold] function
|
||||||
|
|
|
@ -7,7 +7,7 @@ Finite bags.
|
||||||
-/
|
-/
|
||||||
import data.nat data.list.perm algebra.binary
|
import data.nat data.list.perm algebra.binary
|
||||||
open nat quot list subtype binary function eq.ops
|
open nat quot list subtype binary function eq.ops
|
||||||
open [declarations] perm
|
open [decl] perm
|
||||||
|
|
||||||
variable {A : Type}
|
variable {A : Type}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ Finite sets.
|
||||||
-/
|
-/
|
||||||
import data.fintype.basic data.nat data.list.perm algebra.binary
|
import data.fintype.basic data.nat data.list.perm algebra.binary
|
||||||
open nat quot list subtype binary function eq.ops
|
open nat quot list subtype binary function eq.ops
|
||||||
open [declarations] perm
|
open [decl] perm
|
||||||
|
|
||||||
definition nodup_list (A : Type) := {l : list A | nodup l}
|
definition nodup_list (A : Type) := {l : list A | nodup l}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ this bijection is implemeted using the Ackermann coding.
|
||||||
-/
|
-/
|
||||||
import data.nat data.finset.equiv data.list
|
import data.nat data.finset.equiv data.list
|
||||||
open nat binary
|
open nat binary
|
||||||
open - [notations] finset
|
open - [notation] finset
|
||||||
|
|
||||||
definition hf := nat
|
definition hf := nat
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ theorem empty_mem_powerset (s : hf) : ∅ ∈ 𝒫 s :=
|
||||||
mem_powerset_of_subset (empty_subset s)
|
mem_powerset_of_subset (empty_subset s)
|
||||||
|
|
||||||
/- hf as lists -/
|
/- hf as lists -/
|
||||||
open - [notations] list
|
open - [notation] list
|
||||||
|
|
||||||
definition of_list (s : list hf) : hf :=
|
definition of_list (s : list hf) : hf :=
|
||||||
@equiv.to_fun _ _ list_nat_equiv_nat s
|
@equiv.to_fun _ _ list_nat_equiv_nat s
|
||||||
|
|
|
@ -8,8 +8,8 @@ Definitions and properties of div and mod, following the SSReflect library.
|
||||||
Following SSReflect and the SMTlib standard, we define a % b so that 0 ≤ a % b < |b| when b ≠ 0.
|
Following SSReflect and the SMTlib standard, we define a % b so that 0 ≤ a % b < |b| when b ≠ 0.
|
||||||
-/
|
-/
|
||||||
import data.int.order data.nat.div
|
import data.int.order data.nat.div
|
||||||
open [coercions] [reduce_hints] nat
|
open [coercion] [reducible] nat
|
||||||
open [declarations] [classes] nat (succ)
|
open [declaration] [class] nat (succ)
|
||||||
open eq.ops
|
open eq.ops
|
||||||
|
|
||||||
namespace int
|
namespace int
|
||||||
|
|
|
@ -22,7 +22,7 @@ The construction of the reals is arranged in four files.
|
||||||
-/
|
-/
|
||||||
import data.nat data.rat.order data.pnat
|
import data.nat data.rat.order data.pnat
|
||||||
open nat eq pnat
|
open nat eq pnat
|
||||||
open - [coercions] rat
|
open - [coercion] rat
|
||||||
|
|
||||||
local postfix `⁻¹` := pnat.inv
|
local postfix `⁻¹` := pnat.inv
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ theorem r_equiv_neg_abs_of_le_zero {s : reg_seq} (Hz : r_le s r_zero) : requiv (
|
||||||
end rat_seq
|
end rat_seq
|
||||||
|
|
||||||
namespace real
|
namespace real
|
||||||
open [classes] rat_seq
|
open [class] rat_seq
|
||||||
|
|
||||||
private theorem rewrite_helper9 (a b c : ℝ) : b - c = (b - a) - (c - a) :=
|
private theorem rewrite_helper9 (a b c : ℝ) : b - c = (b - a) - (c - a) :=
|
||||||
by rewrite [-sub_add_eq_sub_sub_swap, sub_add_cancel]
|
by rewrite [-sub_add_eq_sub_sub_swap, sub_add_cancel]
|
||||||
|
|
|
@ -581,7 +581,7 @@ theorem r_abs_well_defined {s t : reg_seq} (H : requiv s t) : requiv (r_abs s) (
|
||||||
end rat_seq
|
end rat_seq
|
||||||
|
|
||||||
namespace real
|
namespace real
|
||||||
open [classes] rat_seq
|
open [class] rat_seq
|
||||||
|
|
||||||
noncomputable protected definition inv (x : ℝ) : ℝ :=
|
noncomputable protected definition inv (x : ℝ) : ℝ :=
|
||||||
quot.lift_on x (λ a, quot.mk (rat_seq.r_inv a))
|
quot.lift_on x (λ a, quot.mk (rat_seq.r_inv a))
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ theorem r_le_of_reprs_le (s t : reg_seq) (Hle : ∀ n : ℕ+, r_le (r_const (reg
|
||||||
end rat_seq
|
end rat_seq
|
||||||
|
|
||||||
open real
|
open real
|
||||||
open [classes] rat_seq
|
open [class] rat_seq
|
||||||
namespace real
|
namespace real
|
||||||
|
|
||||||
protected definition lt (x y : ℝ) :=
|
protected definition lt (x y : ℝ) :=
|
||||||
|
|
|
@ -156,4 +156,4 @@ theorem bijective_id : bijective (@id A) := and.intro injective_id surjective_id
|
||||||
end function
|
end function
|
||||||
|
|
||||||
-- copy reducible annotations to top-level
|
-- copy reducible annotations to top-level
|
||||||
export [reduce_hints] [unfold_hints] function
|
export [reducible] [unfold] function
|
||||||
|
|
|
@ -38,7 +38,7 @@ protected definition metric_space [instance] : metric_space ℝ :=
|
||||||
⦄
|
⦄
|
||||||
|
|
||||||
open nat
|
open nat
|
||||||
open [classes] rat
|
open [class] rat
|
||||||
|
|
||||||
definition converges_to_seq (X : ℕ → ℝ) (y : ℝ) : Prop :=
|
definition converges_to_seq (X : ℕ → ℝ) (y : ℝ) : Prop :=
|
||||||
∀ ⦃ε : ℝ⦄, ε > 0 → ∃ N : ℕ, ∀ {n}, n ≥ N → abs (X n - y) < ε
|
∀ ⦃ε : ℝ⦄, ε > 0 → ∃ N : ℕ, ∀ {n}, n ≥ N → abs (X n - y) < ε
|
||||||
|
|
|
@ -54,10 +54,10 @@
|
||||||
'("persistent" "notation" "visible" "instance" "trans_instance"
|
'("persistent" "notation" "visible" "instance" "trans_instance"
|
||||||
"class" "parsing_only" "coercion" "unfold_full" "constructor"
|
"class" "parsing_only" "coercion" "unfold_full" "constructor"
|
||||||
"reducible" "irreducible" "semireducible" "quasireducible" "wf"
|
"reducible" "irreducible" "semireducible" "quasireducible" "wf"
|
||||||
"whnf" "multiple_instances" "none" "decls" "declarations"
|
"whnf" "multiple_instances" "none" "decl" "declaration"
|
||||||
"coercions" "classes" "symm" "subst" "refl" "trans" "simp" "simps" "congr"
|
"relation" "symm" "subst" "refl" "trans" "simp" "congr"
|
||||||
"forward" "no_pattern" "notations" "abbreviations" "begin_end_hints" "tactic_hints"
|
"backward" "forward" "no_pattern" "begin_end" "tactic" "abbreviation"
|
||||||
"reduce_hints" "unfold_hints" "aliases" "eqv" "intro" "intro!" "elim"
|
"reducible" "unfold" "alias" "eqv" "intro" "intro!" "elim" "grinder"
|
||||||
"localrefinfo" "recursor"))
|
"localrefinfo" "recursor"))
|
||||||
"lean modifiers")
|
"lean modifiers")
|
||||||
(defconst lean-modifiers-regexp
|
(defconst lean-modifiers-regexp
|
||||||
|
|
|
@ -78,8 +78,8 @@ bool is_begin_end_annotation(expr const & e) { return is_annotation(e, *g_begin_
|
||||||
bool is_begin_end_element_annotation(expr const & e) { return is_annotation(e, *g_begin_end_element); }
|
bool is_begin_end_element_annotation(expr const & e) { return is_annotation(e, *g_begin_end_element); }
|
||||||
|
|
||||||
void initialize_begin_end_ext() {
|
void initialize_begin_end_ext() {
|
||||||
g_class_name = new name("begin_end_hints");
|
g_class_name = new name("begin_end");
|
||||||
g_key = new std::string("bepretac");
|
g_key = new std::string("BEPRETAC");
|
||||||
begin_end_ext::initialize();
|
begin_end_ext::initialize();
|
||||||
g_begin_end = new name("begin_end");
|
g_begin_end = new name("begin_end");
|
||||||
g_begin_end_element = new name("begin_end_element");
|
g_begin_end_element = new name("begin_end_element");
|
||||||
|
|
|
@ -221,19 +221,26 @@ static optional<name> parse_metaclass(parser & p) {
|
||||||
p.next();
|
p.next();
|
||||||
}
|
}
|
||||||
p.check_token_next(get_rbracket_tk(), "invalid 'open' command, ']' expected");
|
p.check_token_next(get_rbracket_tk(), "invalid 'open' command, ']' expected");
|
||||||
if (!is_metaclass(n) && n != get_decls_tk() && n != get_declarations_tk())
|
if (!is_metaclass(n) && n != get_decl_tk() && n != get_declaration_tk())
|
||||||
throw parser_error(sstream() << "invalid metaclass name '[" << n << "]'", pos);
|
throw parser_error(sstream() << "invalid metaclass name '[" << n << "]'", pos);
|
||||||
return optional<name>(n);
|
return optional<name>(n);
|
||||||
} else if (p.curr() == scanner::token_kind::CommandKeyword) {
|
} else if (p.curr() == scanner::token_kind::CommandKeyword) {
|
||||||
|
// Meta-classes whose name conflict with tokens of the form `[<id>]` `[<id>`
|
||||||
|
// Example: [class] and [unfold
|
||||||
name v = p.get_token_info().value();
|
name v = p.get_token_info().value();
|
||||||
if (v.is_atomic() && v.is_string() && v.size() > 2 && v.get_string()[0] == '[' && v.get_string()[v.size()-1] == ']') {
|
if (v.is_atomic() && v.is_string() && v.size() > 1 && v.get_string()[0] == '[') {
|
||||||
auto pos = p.pos();
|
auto pos = p.pos();
|
||||||
p.next();
|
p.next();
|
||||||
std::string s(v.get_string() + 1);
|
std::string s(v.get_string() + 1);
|
||||||
s.pop_back();
|
if (v.get_string()[v.size()-1] == ']')
|
||||||
|
s.pop_back();
|
||||||
name n(s);
|
name n(s);
|
||||||
if (!is_metaclass(n) && n != get_decls_tk() && n != get_declarations_tk())
|
if (!is_metaclass(n) && n != get_decl_tk() && n != get_declaration_tk())
|
||||||
throw parser_error(sstream() << "invalid metaclass name '[" << n << "]'", pos);
|
throw parser_error(sstream() << "invalid metaclass name '[" << n << "]'", pos);
|
||||||
|
if (v.get_string()[v.size()-1] != ']') {
|
||||||
|
// Consume ']' for tokens such as `[unfold`
|
||||||
|
p.check_token_next(get_rbracket_tk(), "invalid 'open' command, ']' expected");
|
||||||
|
}
|
||||||
return optional<name>(n);
|
return optional<name>(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,12 +252,12 @@ static void parse_metaclasses(parser & p, buffer<name> & r) {
|
||||||
p.next();
|
p.next();
|
||||||
buffer<name> tmp;
|
buffer<name> tmp;
|
||||||
get_metaclasses(tmp);
|
get_metaclasses(tmp);
|
||||||
tmp.push_back(get_decls_tk());
|
tmp.push_back(get_decl_tk());
|
||||||
while (true) {
|
while (true) {
|
||||||
if (optional<name> m = parse_metaclass(p)) {
|
if (optional<name> m = parse_metaclass(p)) {
|
||||||
tmp.erase_elem(*m);
|
tmp.erase_elem(*m);
|
||||||
if (*m == get_declarations_tk())
|
if (*m == get_declaration_tk())
|
||||||
tmp.erase_elem(get_decls_tk());
|
tmp.erase_elem(get_decl_tk());
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -299,8 +306,8 @@ environment open_export_cmd(parser & p, bool open) {
|
||||||
parse_metaclasses(p, metacls);
|
parse_metaclasses(p, metacls);
|
||||||
bool decls = false;
|
bool decls = false;
|
||||||
if (metacls.empty() ||
|
if (metacls.empty() ||
|
||||||
std::find(metacls.begin(), metacls.end(), get_decls_tk()) != metacls.end() ||
|
std::find(metacls.begin(), metacls.end(), get_decl_tk()) != metacls.end() ||
|
||||||
std::find(metacls.begin(), metacls.end(), get_declarations_tk()) != metacls.end())
|
std::find(metacls.begin(), metacls.end(), get_declaration_tk()) != metacls.end())
|
||||||
decls = true;
|
decls = true;
|
||||||
for (name const & n : metacls)
|
for (name const & n : metacls)
|
||||||
fingerprint = hash(fingerprint, n.hash());
|
fingerprint = hash(fingerprint, n.hash());
|
||||||
|
|
|
@ -437,11 +437,11 @@ cmd_table const & get_cmd_table(environment const & env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_parser_config() {
|
void initialize_parser_config() {
|
||||||
token_config::g_class_name = new name("notations");
|
token_config::g_class_name = new name("notation");
|
||||||
token_config::g_key = new std::string("tk");
|
token_config::g_key = new std::string("TK");
|
||||||
token_ext::initialize();
|
token_ext::initialize();
|
||||||
notation_config::g_class_name = new name("notations");
|
notation_config::g_class_name = new name("notation");
|
||||||
notation_config::g_key = new std::string("nota");
|
notation_config::g_key = new std::string("NOTA");
|
||||||
notation_ext::initialize();
|
notation_ext::initialize();
|
||||||
g_ext = new cmd_ext_reg();
|
g_ext = new cmd_ext_reg();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,8 @@ template class scoped_ext<tactic_hint_config>;
|
||||||
typedef scoped_ext<tactic_hint_config> tactic_hint_ext;
|
typedef scoped_ext<tactic_hint_config> tactic_hint_ext;
|
||||||
|
|
||||||
void initialize_tactic_hint() {
|
void initialize_tactic_hint() {
|
||||||
g_class_name = new name("tactic_hints");
|
g_class_name = new name("tactic");
|
||||||
g_key = new std::string("tachint");
|
g_key = new std::string("TACHINT");
|
||||||
tactic_hint_ext::initialize();
|
tactic_hint_ext::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ static name const * g_instances_tk = nullptr;
|
||||||
static name const * g_classes_tk = nullptr;
|
static name const * g_classes_tk = nullptr;
|
||||||
static name const * g_coercions_tk = nullptr;
|
static name const * g_coercions_tk = nullptr;
|
||||||
static name const * g_arrow_tk = nullptr;
|
static name const * g_arrow_tk = nullptr;
|
||||||
static name const * g_declarations_tk = nullptr;
|
static name const * g_declaration_tk = nullptr;
|
||||||
static name const * g_decls_tk = nullptr;
|
static name const * g_decl_tk = nullptr;
|
||||||
static name const * g_hiding_tk = nullptr;
|
static name const * g_hiding_tk = nullptr;
|
||||||
static name const * g_exposing_tk = nullptr;
|
static name const * g_exposing_tk = nullptr;
|
||||||
static name const * g_renaming_tk = nullptr;
|
static name const * g_renaming_tk = nullptr;
|
||||||
|
@ -213,8 +213,8 @@ void initialize_tokens() {
|
||||||
g_classes_tk = new name{"classes"};
|
g_classes_tk = new name{"classes"};
|
||||||
g_coercions_tk = new name{"coercions"};
|
g_coercions_tk = new name{"coercions"};
|
||||||
g_arrow_tk = new name{"->"};
|
g_arrow_tk = new name{"->"};
|
||||||
g_declarations_tk = new name{"declarations"};
|
g_declaration_tk = new name{"declaration"};
|
||||||
g_decls_tk = new name{"decls"};
|
g_decl_tk = new name{"decl"};
|
||||||
g_hiding_tk = new name{"hiding"};
|
g_hiding_tk = new name{"hiding"};
|
||||||
g_exposing_tk = new name{"exposing"};
|
g_exposing_tk = new name{"exposing"};
|
||||||
g_renaming_tk = new name{"renaming"};
|
g_renaming_tk = new name{"renaming"};
|
||||||
|
@ -364,8 +364,8 @@ void finalize_tokens() {
|
||||||
delete g_classes_tk;
|
delete g_classes_tk;
|
||||||
delete g_coercions_tk;
|
delete g_coercions_tk;
|
||||||
delete g_arrow_tk;
|
delete g_arrow_tk;
|
||||||
delete g_declarations_tk;
|
delete g_declaration_tk;
|
||||||
delete g_decls_tk;
|
delete g_decl_tk;
|
||||||
delete g_hiding_tk;
|
delete g_hiding_tk;
|
||||||
delete g_exposing_tk;
|
delete g_exposing_tk;
|
||||||
delete g_renaming_tk;
|
delete g_renaming_tk;
|
||||||
|
@ -514,8 +514,8 @@ name const & get_instances_tk() { return *g_instances_tk; }
|
||||||
name const & get_classes_tk() { return *g_classes_tk; }
|
name const & get_classes_tk() { return *g_classes_tk; }
|
||||||
name const & get_coercions_tk() { return *g_coercions_tk; }
|
name const & get_coercions_tk() { return *g_coercions_tk; }
|
||||||
name const & get_arrow_tk() { return *g_arrow_tk; }
|
name const & get_arrow_tk() { return *g_arrow_tk; }
|
||||||
name const & get_declarations_tk() { return *g_declarations_tk; }
|
name const & get_declaration_tk() { return *g_declaration_tk; }
|
||||||
name const & get_decls_tk() { return *g_decls_tk; }
|
name const & get_decl_tk() { return *g_decl_tk; }
|
||||||
name const & get_hiding_tk() { return *g_hiding_tk; }
|
name const & get_hiding_tk() { return *g_hiding_tk; }
|
||||||
name const & get_exposing_tk() { return *g_exposing_tk; }
|
name const & get_exposing_tk() { return *g_exposing_tk; }
|
||||||
name const & get_renaming_tk() { return *g_renaming_tk; }
|
name const & get_renaming_tk() { return *g_renaming_tk; }
|
||||||
|
|
|
@ -65,8 +65,8 @@ name const & get_instances_tk();
|
||||||
name const & get_classes_tk();
|
name const & get_classes_tk();
|
||||||
name const & get_coercions_tk();
|
name const & get_coercions_tk();
|
||||||
name const & get_arrow_tk();
|
name const & get_arrow_tk();
|
||||||
name const & get_declarations_tk();
|
name const & get_declaration_tk();
|
||||||
name const & get_decls_tk();
|
name const & get_decl_tk();
|
||||||
name const & get_hiding_tk();
|
name const & get_hiding_tk();
|
||||||
name const & get_exposing_tk();
|
name const & get_exposing_tk();
|
||||||
name const & get_renaming_tk();
|
name const & get_renaming_tk();
|
||||||
|
|
|
@ -58,8 +58,8 @@ instances instances
|
||||||
classes classes
|
classes classes
|
||||||
coercions coercions
|
coercions coercions
|
||||||
arrow ->
|
arrow ->
|
||||||
declarations declarations
|
declaration declaration
|
||||||
decls decls
|
decl decl
|
||||||
hiding hiding
|
hiding hiding
|
||||||
exposing exposing
|
exposing exposing
|
||||||
renaming renaming
|
renaming renaming
|
||||||
|
|
|
@ -119,8 +119,8 @@ expr expand_abbreviations(environment const & env, expr const & e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_abbreviation() {
|
void initialize_abbreviation() {
|
||||||
g_class_name = new name("abbreviations");
|
g_class_name = new name("abbreviation");
|
||||||
g_key = new std::string("abbrev");
|
g_key = new std::string("ABBREV");
|
||||||
abbrev_ext::initialize();
|
abbrev_ext::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ void open_aliases(lua_State * L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_aliases() {
|
void initialize_aliases() {
|
||||||
g_aliases = new name("aliases");
|
g_aliases = new name("alias");
|
||||||
g_ext = new aliases_ext_reg();
|
g_ext = new aliases_ext_reg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,8 @@ list<gexpr> backward_rule_set::find(head_index const & h) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_backward_rule_set() {
|
void initialize_backward_rule_set() {
|
||||||
g_class_name = new name("brs");
|
g_class_name = new name("backward");
|
||||||
g_key = new std::string("brs");
|
g_key = new std::string("BWD");
|
||||||
brs_ext::initialize();
|
brs_ext::initialize();
|
||||||
register_prio_attribute("intro", "backward chaining",
|
register_prio_attribute("intro", "backward chaining",
|
||||||
[](environment const & env, io_state const &, name const & d, unsigned prio, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, unsigned prio, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -114,7 +114,7 @@ void get_intro_lemmas(environment const & env, buffer<name> & r) {
|
||||||
|
|
||||||
void initialize_intro_elim_lemmas() {
|
void initialize_intro_elim_lemmas() {
|
||||||
g_class_name = new name("grinder");
|
g_class_name = new name("grinder");
|
||||||
g_key = new std::string("grinder");
|
g_key = new std::string("GRD");
|
||||||
intro_elim_ext::initialize();
|
intro_elim_ext::initialize();
|
||||||
|
|
||||||
register_prio_attribute("elim", "elimination rule that is eagerly applied by blast grinder",
|
register_prio_attribute("elim", "elimination rule that is eagerly applied by blast grinder",
|
||||||
|
|
|
@ -579,8 +579,8 @@ io_state_stream const & operator<<(io_state_stream const & out, simp_rule_sets c
|
||||||
|
|
||||||
void initialize_simplifier_rule_set() {
|
void initialize_simplifier_rule_set() {
|
||||||
g_prefix = new name(name::mk_internal_unique_name());
|
g_prefix = new name(name::mk_internal_unique_name());
|
||||||
g_class_name = new name("simps");
|
g_class_name = new name("simp");
|
||||||
g_key = new std::string("simp");
|
g_key = new std::string("SIMP");
|
||||||
rrs_ext::initialize();
|
rrs_ext::initialize();
|
||||||
register_prio_attribute("simp", "simplification rule",
|
register_prio_attribute("simp", "simplification rule",
|
||||||
[](environment const & env, io_state const &, name const & d, unsigned prio, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, unsigned prio, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -483,7 +483,7 @@ list<expr> get_local_instances(type_checker & tc, list<expr> const & ctx, name c
|
||||||
void initialize_class() {
|
void initialize_class() {
|
||||||
g_tmp_prefix = new name(name::mk_internal_unique_name());
|
g_tmp_prefix = new name(name::mk_internal_unique_name());
|
||||||
g_source = new name("_source");
|
g_source = new name("_source");
|
||||||
g_class_name = new name("classes");
|
g_class_name = new name("class");
|
||||||
g_key = new std::string("class");
|
g_key = new std::string("class");
|
||||||
class_ext::initialize();
|
class_ext::initialize();
|
||||||
|
|
||||||
|
|
|
@ -373,8 +373,8 @@ environment add_coercion(environment const & env, io_state const &, name const &
|
||||||
void initialize_coercion() {
|
void initialize_coercion() {
|
||||||
g_fun = new name("_Fun");
|
g_fun = new name("_Fun");
|
||||||
g_sort = new name("_Sort");
|
g_sort = new name("_Sort");
|
||||||
g_class_name = new name("coercions");
|
g_class_name = new name("coercion");
|
||||||
g_key = new std::string("coerce");
|
g_key = new std::string("COERCE");
|
||||||
coercion_ext::initialize();
|
coercion_ext::initialize();
|
||||||
register_attribute("coercion", "coercion",
|
register_attribute("coercion", "coercion",
|
||||||
[](environment const & env, io_state const & ios, name const & d, name const & ns, bool persistent) {
|
[](environment const & env, io_state const & ios, name const & d, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -191,8 +191,8 @@ io_state_stream const & operator<<(io_state_stream const & out, light_rule_set c
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_light_rule_set() {
|
void initialize_light_rule_set() {
|
||||||
g_class_name = new name("lrs");
|
g_class_name = new name("light");
|
||||||
g_key = new std::string("lrs");
|
g_key = new std::string("LIGHT");
|
||||||
lrs_ext::initialize();
|
lrs_ext::initialize();
|
||||||
register_param_attribute("light", "hint for simplifier",
|
register_param_attribute("light", "hint for simplifier",
|
||||||
[](environment const & env, io_state const &, name const & d, unsigned idx, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, unsigned idx, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -163,8 +163,8 @@ environment erase_constructor_hint(environment const & env, name const & n, name
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_normalize() {
|
void initialize_normalize() {
|
||||||
g_unfold_hint_name = new name("unfold_hints");
|
g_unfold_hint_name = new name("unfold");
|
||||||
g_key = new std::string("unfoldh");
|
g_key = new std::string("UNFOLDH");
|
||||||
unfold_hint_ext::initialize();
|
unfold_hint_ext::initialize();
|
||||||
register_params_attribute("unfold", "unfold definition when the given positions are constructors",
|
register_params_attribute("unfold", "unfold definition when the given positions are constructors",
|
||||||
[](environment const & env, io_state const &, name const & d, list<unsigned> const & idxs, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, list<unsigned> const & idxs, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -66,8 +66,8 @@ typedef scoped_ext<reducible_config> reducible_ext;
|
||||||
static name * g_tmp_prefix = nullptr;
|
static name * g_tmp_prefix = nullptr;
|
||||||
|
|
||||||
void initialize_reducible() {
|
void initialize_reducible() {
|
||||||
g_class_name = new name("reduce_hints");
|
g_class_name = new name("reducible");
|
||||||
g_key = new std::string("redu");
|
g_key = new std::string("REDU");
|
||||||
g_tmp_prefix = new name(name::mk_internal_unique_name());
|
g_tmp_prefix = new name(name::mk_internal_unique_name());
|
||||||
reducible_ext::initialize();
|
reducible_ext::initialize();
|
||||||
|
|
||||||
|
|
|
@ -327,8 +327,8 @@ is_relation_pred mk_is_relation_pred(environment const & env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize_relation_manager() {
|
void initialize_relation_manager() {
|
||||||
g_rel_name = new name("rel");
|
g_rel_name = new name("relation");
|
||||||
g_key = new std::string("rel");
|
g_key = new std::string("REL");
|
||||||
rel_ext::initialize();
|
rel_ext::initialize();
|
||||||
register_attribute("refl", "reflexive relation",
|
register_attribute("refl", "reflexive relation",
|
||||||
[](environment const & env, io_state const &, name const & d, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -345,7 +345,7 @@ has_recursors_pred::has_recursors_pred(environment const & env):
|
||||||
|
|
||||||
void initialize_user_recursors() {
|
void initialize_user_recursors() {
|
||||||
g_class_name = new name("recursor");
|
g_class_name = new name("recursor");
|
||||||
g_key = new std::string("urec");
|
g_key = new std::string("UREC");
|
||||||
recursor_ext::initialize();
|
recursor_ext::initialize();
|
||||||
register_opt_param_attribute("recursor", "user defined recursor",
|
register_opt_param_attribute("recursor", "user defined recursor",
|
||||||
[](environment const & env, io_state const &, name const & d, optional<unsigned> const & major, name const & ns, bool persistent) {
|
[](environment const & env, io_state const &, name const & d, optional<unsigned> const & major, name const & ns, bool persistent) {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
open "nat"
|
open "nat"
|
||||||
|
|
||||||
open [classes] "nat"
|
open [class] "nat"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
bad_open.lean:1:5: error: invalid 'open/export' command, identifier expected
|
bad_open.lean:1:5: error: invalid 'open/export' command, identifier expected
|
||||||
bad_open.lean:3:15: error: invalid 'open/export' command, identifier expected
|
bad_open.lean:3:13: error: invalid 'open/export' command, identifier expected
|
||||||
|
|
|
@ -7,7 +7,7 @@ Finite bags.
|
||||||
-/
|
-/
|
||||||
import data.nat data.list.perm algebra.binary
|
import data.nat data.list.perm algebra.binary
|
||||||
open nat quot list subtype binary function eq.ops algebra
|
open nat quot list subtype binary function eq.ops algebra
|
||||||
open [declarations] perm
|
open [decl] perm
|
||||||
|
|
||||||
variable {A : Type}
|
variable {A : Type}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ section
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open - [classes] nat
|
open - [class] nat
|
||||||
variable a : nat
|
variable a : nat
|
||||||
check a + a
|
check a + a
|
||||||
check add a a
|
check add a a
|
||||||
|
@ -21,7 +21,7 @@ section
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open - [classes] [decls] nat
|
open - [class] [decl] nat
|
||||||
variable a : nat
|
variable a : nat
|
||||||
check a + a
|
check a + a
|
||||||
check a + 1
|
check a + 1
|
||||||
|
@ -30,7 +30,7 @@ section
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open [classes] nat
|
open [class] nat
|
||||||
definition foo3 : inhabited nat :=
|
definition foo3 : inhabited nat :=
|
||||||
_
|
_
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ namespace f2
|
||||||
end f2
|
end f2
|
||||||
|
|
||||||
namespace f3
|
namespace f3
|
||||||
export [declarations] f1
|
export [declaration] f1
|
||||||
export - [declarations] f2
|
export - [declaration] f2
|
||||||
end f3
|
end f3
|
||||||
|
|
||||||
export [declarations] f1
|
export [declaration] f1
|
||||||
export - [declarations] f2
|
export - [declaration] f2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import data.nat
|
import data.nat
|
||||||
open - [simps] nat
|
open - [simp] nat
|
||||||
|
|
||||||
definition Sum : nat → (nat → nat) → nat :=
|
definition Sum : nat → (nat → nat) → nat :=
|
||||||
sorry
|
sorry
|
||||||
|
|
|
@ -31,7 +31,7 @@ section
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open [notations] algebra
|
open [notation] algebra
|
||||||
open nat
|
open nat
|
||||||
-- check mul_struct nat << This is an error, we opened only the notation from algebra
|
-- check mul_struct nat << This is an error, we opened only the notation from algebra
|
||||||
variables a b c : nat
|
variables a b c : nat
|
||||||
|
|
|
@ -18,10 +18,10 @@ end int
|
||||||
|
|
||||||
section
|
section
|
||||||
-- Open "only" the notation and declarations from the namespaces nat and int
|
-- Open "only" the notation and declarations from the namespaces nat and int
|
||||||
open [notations] nat
|
open [notation] nat
|
||||||
open [notations] int
|
open [notation] int
|
||||||
open [decls] nat
|
open [decl] nat
|
||||||
open [decls] int
|
open [decl] int
|
||||||
|
|
||||||
variables n m : nat
|
variables n m : nat
|
||||||
variables i j : int
|
variables i j : int
|
||||||
|
|
|
@ -20,17 +20,17 @@ constants n m : nat.nat
|
||||||
constants i j : int.int
|
constants i j : int.int
|
||||||
|
|
||||||
section
|
section
|
||||||
open [notations] nat
|
open [notation] nat
|
||||||
open [notations] int
|
open [notation] int
|
||||||
open [decls] nat
|
open [decl] nat
|
||||||
open [decls] int
|
open [decl] int
|
||||||
check n+m
|
check n+m
|
||||||
check i+j
|
check i+j
|
||||||
-- check i+n -- Error
|
-- check i+n -- Error
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace int
|
namespace int
|
||||||
open [decls] nat (nat)
|
open [decl] nat (nat)
|
||||||
-- Here is a possible trick for this kind of configuration
|
-- Here is a possible trick for this kind of configuration
|
||||||
definition add_ni (a : nat) (b : int) := (of_nat a) + b
|
definition add_ni (a : nat) (b : int) := (of_nat a) + b
|
||||||
definition add_in (a : int) (b : nat) := a + (of_nat b)
|
definition add_in (a : int) (b : nat) := a + (of_nat b)
|
||||||
|
@ -39,10 +39,10 @@ namespace int
|
||||||
end int
|
end int
|
||||||
|
|
||||||
section
|
section
|
||||||
open [notations] nat
|
open [notation] nat
|
||||||
open [notations] int
|
open [notation] int
|
||||||
open [declarations] nat
|
open [declaration] nat
|
||||||
open [declarations] int
|
open [declaration] int
|
||||||
check n+m
|
check n+m
|
||||||
check i+n
|
check i+n
|
||||||
check n+i
|
check n+i
|
||||||
|
|
|
@ -17,10 +17,10 @@ attribute of_nat [coercion]
|
||||||
end int
|
end int
|
||||||
|
|
||||||
-- Open "only" the notation and declarations from the namespaces nat and int
|
-- Open "only" the notation and declarations from the namespaces nat and int
|
||||||
open [notations] nat
|
open [notation] nat
|
||||||
open [notations] int
|
open [notation] int
|
||||||
open [decls] nat
|
open [decl] nat
|
||||||
open [decls] int
|
open [decl] int
|
||||||
|
|
||||||
constants n m : nat
|
constants n m : nat
|
||||||
constants i j : int
|
constants i j : int
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import data.int
|
import data.int
|
||||||
open [coercions] [classes] int
|
open [coercion] [class] int
|
||||||
open [coercions] nat
|
open [coercion] nat
|
||||||
|
|
||||||
definition lt1 (a b : int) := int.le (int.add a 1) b
|
definition lt1 (a b : int) := int.le (int.add a 1) b
|
||||||
infix `<` := lt1
|
infix `<` := lt1
|
||||||
|
|
|
@ -41,13 +41,13 @@ section
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open [notations] foo -- use only the notation
|
open [notation] foo -- use only the notation
|
||||||
check foo.a * foo.c
|
check foo.a * foo.c
|
||||||
check a * c -- Error
|
check a * c -- Error
|
||||||
end
|
end
|
||||||
|
|
||||||
section
|
section
|
||||||
open [decls] foo -- use only the declarations
|
open [decl] foo -- use only the declarations
|
||||||
check f a c
|
check f a c
|
||||||
check a*c -- Error
|
check a*c -- Error
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue