diff --git a/library/init/algebra/classes.lean b/library/init/algebra/classes.lean index 9af0964932..554a281d7c 100644 --- a/library/init/algebra/classes.lean +++ b/library/init/algebra/classes.lean @@ -13,17 +13,16 @@ class is_commutative (α : Type u) (op : α → α → α) : Prop := class is_associative (α : Type u) (op : α → α → α) : Prop := (assoc : ∀ a b c, op (op a b) c = op a (op b c)) --- TODO: better notation for out_param -class is_left_id (α : Type u) (op : α → α → α) (o : out_param α) : Prop := +class is_left_id (α : Type u) (op : α → α → α) (o : inout α) : Prop := (left_id : ∀ a, op o a = a) -class is_right_id (α : Type u) (op : α → α → α) (o : out_param α) : Prop := +class is_right_id (α : Type u) (op : α → α → α) (o : inout α) : Prop := (right_id : ∀ a, op a o = a) -class is_left_null (α : Type u) (op : α → α → α) (o : out_param α) : Prop := +class is_left_null (α : Type u) (op : α → α → α) (o : inout α) : Prop := (left_null : ∀ a, op o a = o) -class is_right_null (α : Type u) (op : α → α → α) (o : out_param α) : Prop := +class is_right_null (α : Type u) (op : α → α → α) (o : inout α) : Prop := (right_null : ∀ a, op a o = o) class is_left_cancel (α : Type u) (op : α → α → α) : Prop := @@ -35,22 +34,22 @@ class is_right_cancel (α : Type u) (op : α → α → α) : Prop := class is_idempotent (α : Type u) (op : α → α → α) : Prop := (idempotent : ∀ a, op a a = a) -class is_left_distrib (α : Type u) (op₁ : α → α → α) (op₂ : out_param $ α → α → α) : Prop := +class is_left_distrib (α : Type u) (op₁ : α → α → α) (op₂ : inout α → α → α) : Prop := (left_distrib : ∀ a b c, op₁ a (op₂ b c) = op₂ (op₁ a b) (op₁ a c)) -class is_right_distrib (α : Type u) (op₁ : α → α → α) (op₂ : out_param $ α → α → α) : Prop := +class is_right_distrib (α : Type u) (op₁ : α → α → α) (op₂ : inout α → α → α) : Prop := (right_distrib : ∀ a b c, op₁ (op₂ a b) c = op₂ (op₁ a c) (op₁ b c)) -class is_left_inv (α : Type u) (op : α → α → α) (inv : out_param $ α → α) (o : out_param α) : Prop := +class is_left_inv (α : Type u) (op : α → α → α) (inv : inout α → α) (o : inout α) : Prop := (left_inv : ∀ a, op (inv a) a = o) -class is_right_inv (α : Type u) (op : α → α → α) (inv : out_param $ α → α) (o : out_param α) : Prop := +class is_right_inv (α : Type u) (op : α → α → α) (inv : inout α → α) (o : inout α) : Prop := (right_inv : ∀ a, op a (inv a) = o) -class is_cond_left_inv (α : Type u) (op : α → α → α) (inv : out_param $ α → α) (o : out_param α) (p : out_param $ α → Prop) : Prop := +class is_cond_left_inv (α : Type u) (op : α → α → α) (inv : inout α → α) (o : inout α) (p : inout α → Prop) : Prop := (left_inv : ∀ a, p a → op (inv a) a = o) -class is_cond_right_inv (α : Type u) (op : α → α → α) (inv : out_param $ α → α) (o : out_param α) (p : out_param $ α → Prop) : Prop := +class is_cond_right_inv (α : Type u) (op : α → α → α) (inv : inout α → α) (o : inout α) (p : inout α → Prop) : Prop := (right_inv : ∀ a, p a → op a (inv a) = o) class is_distinct (α : Type u) (a : α) (b : α) : Prop := @@ -58,7 +57,7 @@ class is_distinct (α : Type u) (a : α) (b : α) : Prop := /- -- The following type class doesn't seem very useful, a regular simp lemma should work for this. -class is_inv (α : Type u) (β : Type v) (f : α → β) (g : out_param $ β → α) : Prop := +class is_inv (α : Type u) (β : Type v) (f : α → β) (g : inout β → α) : Prop := (inv : ∀ a, g (f a) = a) -- The following one can also be handled using a regular simp lemma diff --git a/library/init/core.lean b/library/init/core.lean index c02cbab47e..49d61f0dbc 100644 --- a/library/init/core.lean +++ b/library/init/core.lean @@ -87,6 +87,8 @@ universes u v w /-- Gadget for marking output parameters in type classes. -/ @[reducible] def out_param (α : Sort u) : Sort u := α +notation `inout`:1024 a:0 := out_param a + inductive punit : Sort u | star : punit @@ -316,12 +318,12 @@ class has_ssubset (α : Type u) := (ssubset : α → α → Prop) used to implement polymorphic notation for collections. Example: {a, b, c}. -/ class has_emptyc (α : Type u) := (emptyc : α) -class has_insert (α : out_param (Type u)) (γ : Type v) := (insert : α → γ → γ) +class has_insert (α : inout Type u) (γ : Type v) := (insert : α → γ → γ) /- Type class used to implement the notation { a ∈ c | p a } -/ -class has_sep (α : out_param (Type u)) (γ : Type v) := +class has_sep (α : inout Type u) (γ : Type v) := (sep : (α → Prop) → γ → γ) /- Type class for set-like membership -/ -class has_mem (α : out_param (Type u)) (γ : Type v) := (mem : α → γ → Prop) +class has_mem (α : inout Type u) (γ : Type v) := (mem : α → γ → Prop) infix ∈ := has_mem.mem notation a ∉ s := ¬ has_mem.mem a s diff --git a/library/init/relator.lean b/library/init/relator.lean index 019dc3525a..f978953639 100644 --- a/library/init/relator.lean +++ b/library/init/relator.lean @@ -34,7 +34,7 @@ infixr ⇒ := lift_fun end section -variables {α : Type u₁} {β : out_param (Type u₂)} (R : out_param (α → β → Prop)) +variables {α : Type u₁} {β : inout Type u₂} (R : inout α → β → Prop) @[class] def right_total := ∀b, ∃a, R a b @[class] def left_total := ∀a, ∃b, R a b diff --git a/src/emacs/lean-syntax.el b/src/emacs/lean-syntax.el index f9410a4158..b36e0ddbbf 100644 --- a/src/emacs/lean-syntax.el +++ b/src/emacs/lean-syntax.el @@ -11,7 +11,7 @@ '("import" "prelude" "protected" "private" "noncomputable" "definition" "meta" "renaming" "hiding" "exposing" "parameter" "parameters" "begin" "constant" "constants" "lemma" "variable" "variables" "theorem" "example" - "open" "export" "axiom" "axioms" "inductive" "with" "without" + "open" "export" "axiom" "axioms" "inductive" "with" "without" "inout" "structure" "universe" "universes" "precedence" "reserve" "declare_trace" "add_key_equivalence" "match" "infix" "infixl" "infixr" "notation" "postfix" "prefix" "instance" diff --git a/tests/lean/interactive/complete_field.lean.expected.out b/tests/lean/interactive/complete_field.lean.expected.out index 114bea4699..07c4c81366 100644 --- a/tests/lean/interactive/complete_field.lean.expected.out +++ b/tests/lean/interactive/complete_field.lean.expected.out @@ -5,5 +5,5 @@ {"message":"file invalidated","response":"ok","seq_num":0} {"completions":[{"source":,"text":"left","type":"?a ∧ ?b → ?a"},{"source":{"column":14,"file":"/library/init/logic.lean","line":405},"text":"left_comm","type":"?a ∧ ?b ∧ ?c ↔ ?b ∧ ?a ∧ ?c"}],"prefix":"l","response":"ok","seq_num":5} {"completions":[{"source":,"text":"left","type":"?a ∧ ?b → ?a"},{"source":{"column":14,"file":"/library/init/logic.lean","line":405},"text":"left_comm","type":"?a ∧ ?b ∧ ?c ↔ ?b ∧ ?a ∧ ?c"}],"prefix":"le","response":"ok","seq_num":9} -{"completions":[{"source":,"text":"rec","type":"(?a → ?b → ?C) → ?a ∧ ?b → ?C"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"rec_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":4,"file":"/library/init/core.lean","line":145},"text":"right","type":"?a ∧ ?b → ?b"}],"prefix":"r","response":"ok","seq_num":13} -{"completions":[{"source":,"text":"assoc","type":"(?a ∧ ?b) ∧ ?c ↔ ?a ∧ ?b ∧ ?c"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"cases_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":14,"file":"/library/init/logic.lean","line":393},"text":"comm","type":"?a ∧ ?b ↔ ?b ∧ ?a"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"dcases_on","type":"Π (n : ?a ∧ ?b), (Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → ?C n"},{"source":{"column":11,"file":"/library/init/logic.lean","line":653},"text":"decidable","type":"decidable (?p ∧ ?q)"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"drec","type":"(Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → Π (n : ?a ∧ ?b), ?C n"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"drec_on","type":"Π (n : ?a ∧ ?b), (Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → ?C n"},{"source":{"column":6,"file":"/library/init/logic.lean","line":201},"text":"elim","type":"?a ∧ ?b → (?a → ?b → ?c) → ?c"},{"source":{"column":4,"file":"/library/init/core.lean","line":137},"text":"elim_left","type":"?a ∧ ?b → ?a"},{"source":{"column":4,"file":"/library/init/core.lean","line":142},"text":"elim_right","type":"?a ∧ ?b → ?b"},{"source":{"column":6,"file":"/library/init/logic.lean","line":380},"text":"imp","type":"(?a → ?c) → (?b → ?d) → ?a ∧ ?b → ?c ∧ ?d"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"intro","type":"?a → ?b → ?a ∧ ?b"},{"source":{"column":4,"file":"/library/init/core.lean","line":140},"text":"left","type":"?a ∧ ?b → ?a"},{"source":{"column":14,"file":"/library/init/logic.lean","line":405},"text":"left_comm","type":"?a ∧ ?b ∧ ?c ↔ ?b ∧ ?a ∧ ?c"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"rec","type":"(?a → ?b → ?C) → ?a ∧ ?b → ?C"},{"source":{"column":10,"file":"/library/init/core.lean","line":134},"text":"rec_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":4,"file":"/library/init/core.lean","line":145},"text":"right","type":"?a ∧ ?b → ?b"},{"source":{"column":6,"file":"/library/init/logic.lean","line":204},"text":"swap","type":"?a ∧ ?b → ?b ∧ ?a"},{"source":{"column":4,"file":"/library/init/logic.lean","line":207},"text":"symm","type":"?a ∧ ?b → ?b ∧ ?a"}],"prefix":"","response":"ok","seq_num":17} +{"completions":[{"source":,"text":"rec","type":"(?a → ?b → ?C) → ?a ∧ ?b → ?C"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"rec_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":4,"file":"/library/init/core.lean","line":147},"text":"right","type":"?a ∧ ?b → ?b"}],"prefix":"r","response":"ok","seq_num":13} +{"completions":[{"source":,"text":"assoc","type":"(?a ∧ ?b) ∧ ?c ↔ ?a ∧ ?b ∧ ?c"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"cases_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":14,"file":"/library/init/logic.lean","line":393},"text":"comm","type":"?a ∧ ?b ↔ ?b ∧ ?a"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"dcases_on","type":"Π (n : ?a ∧ ?b), (Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → ?C n"},{"source":{"column":11,"file":"/library/init/logic.lean","line":653},"text":"decidable","type":"decidable (?p ∧ ?q)"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"drec","type":"(Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → Π (n : ?a ∧ ?b), ?C n"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"drec_on","type":"Π (n : ?a ∧ ?b), (Π (a : ?a) (a_1 : ?b), ?C (and.intro a a_1)) → ?C n"},{"source":{"column":6,"file":"/library/init/logic.lean","line":201},"text":"elim","type":"?a ∧ ?b → (?a → ?b → ?c) → ?c"},{"source":{"column":4,"file":"/library/init/core.lean","line":139},"text":"elim_left","type":"?a ∧ ?b → ?a"},{"source":{"column":4,"file":"/library/init/core.lean","line":144},"text":"elim_right","type":"?a ∧ ?b → ?b"},{"source":{"column":6,"file":"/library/init/logic.lean","line":380},"text":"imp","type":"(?a → ?c) → (?b → ?d) → ?a ∧ ?b → ?c ∧ ?d"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"intro","type":"?a → ?b → ?a ∧ ?b"},{"source":{"column":4,"file":"/library/init/core.lean","line":142},"text":"left","type":"?a ∧ ?b → ?a"},{"source":{"column":14,"file":"/library/init/logic.lean","line":405},"text":"left_comm","type":"?a ∧ ?b ∧ ?c ↔ ?b ∧ ?a ∧ ?c"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"rec","type":"(?a → ?b → ?C) → ?a ∧ ?b → ?C"},{"source":{"column":10,"file":"/library/init/core.lean","line":136},"text":"rec_on","type":"?a ∧ ?b → (?a → ?b → ?C) → ?C"},{"source":{"column":4,"file":"/library/init/core.lean","line":147},"text":"right","type":"?a ∧ ?b → ?b"},{"source":{"column":6,"file":"/library/init/logic.lean","line":204},"text":"swap","type":"?a ∧ ?b → ?b ∧ ?a"},{"source":{"column":4,"file":"/library/init/logic.lean","line":207},"text":"symm","type":"?a ∧ ?b → ?b ∧ ?a"}],"prefix":"","response":"ok","seq_num":17} diff --git a/tests/lean/struct_class.lean.expected.out b/tests/lean/struct_class.lean.expected.out index b3c8209f8a..72e323dbed 100644 --- a/tests/lean/struct_class.lean.expected.out +++ b/tests/lean/struct_class.lean.expected.out @@ -5,18 +5,18 @@ has_append : Type u → Type u has_div : Type u → Type u has_dvd : Type u → Type u has_emptyc : Type u → Type u -has_insert : out_param Type u → Type v → Type (max u v) +has_insert : (inout Type u) → Type v → Type (max u v) has_inter : Type u → Type u has_inv : Type u → Type u has_le : Type u → Type u has_lt : Type u → Type u -has_mem : out_param Type u → Type v → Type (max u v) +has_mem : (inout Type u) → Type v → Type (max u v) has_mod : Type u → Type u has_mul : Type u → Type u has_neg : Type u → Type u has_one : Type u → Type u has_sdiff : Type u → Type u -has_sep : out_param Type u → Type v → Type (max u v) +has_sep : (inout Type u) → Type v → Type (max u v) has_sizeof : Sort u → Sort (max 1 u) has_ssubset : Type u → Type u has_sub : Type u → Type u @@ -31,18 +31,18 @@ has_append : Type u → Type u has_div : Type u → Type u has_dvd : Type u → Type u has_emptyc : Type u → Type u -has_insert : out_param Type u → Type v → Type (max u v) +has_insert : (inout Type u) → Type v → Type (max u v) has_inter : Type u → Type u has_inv : Type u → Type u has_le : Type u → Type u has_lt : Type u → Type u -has_mem : out_param Type u → Type v → Type (max u v) +has_mem : (inout Type u) → Type v → Type (max u v) has_mod : Type u → Type u has_mul : Type u → Type u has_neg : Type u → Type u has_one : Type u → Type u has_sdiff : Type u → Type u -has_sep : out_param Type u → Type v → Type (max u v) +has_sep : (inout Type u) → Type v → Type (max u v) has_sizeof : Sort u → Sort (max 1 u) has_ssubset : Type u → Type u has_sub : Type u → Type u