chore(library/init): remove unnecessary notations

This commit is contained in:
Leonardo de Moura 2019-07-11 10:27:16 -07:00
parent 57e2f1be2a
commit 295cabed2e
10 changed files with 18 additions and 60 deletions

View file

@ -13,7 +13,6 @@ notation f ` $ `:1 a:0 := f a
/- Logical operations and relations -/
reserve prefix `¬`:40
reserve prefix `~`:40
reserve infixr ` ∧ `:35
reserve infixr ` /\ `:35
reserve infixr ` \/ `:30
@ -27,15 +26,10 @@ reserve infix ` ~= `:50
reserve infix ` ≅ `:50
reserve infix ` ≠ `:50
reserve infix ` ≈ `:50
reserve infix ` ~ `:50
reserve infix ` ≡ `:50
reserve infixl ` ⬝ `:75
reserve infixr ` ▸ `:75
reserve infixr ` ▹ `:75
/- types and Type constructors -/
reserve infixr ` ⊕ `:30
reserve infixr ` × `:35
/- arithmetic operations -/
@ -68,17 +62,9 @@ reserve infixl ` || `:30
reserve infix ` ∈ `:50
reserve infix ` ∉ `:50
reserve infixl ` ∩ `:70
reserve infixl ` `:65
reserve infix ` ⊆ `:50
reserve infix ` ⊇ `:50
reserve infix ` ⊂ `:50
reserve infix ` ⊃ `:50
reserve infix ` \ `:70
/- other symbols -/
reserve infix ` `:50
reserve infixl ` ++ `:65
reserve infixr ` :: `:67
@ -354,7 +340,6 @@ class HasMul (α : Type u) := (mul : ααα)
class HasNeg (α : Type u) := (neg : αα)
class HasSub (α : Type u) := (sub : ααα)
class HasDiv (α : Type u) := (div : ααα)
class HasDivides (α : Type u) := (Divides : αα → Prop)
class HasMod (α : Type u) := (mod : ααα)
class HasModn (α : Type u) := (modn : α → Nat → α)
class HasLessEq (α : Type u) := (LessEq : αα → Prop)
@ -363,20 +348,8 @@ class HasBeq (α : Type u) := (beq : αα → Bool)
class HasAppend (α : Type u) := (append : ααα)
class HasOrelse (α : Type u) := (orelse : ααα)
class HasAndthen (α : Type u) := (andthen : ααα)
class HasUnion (α : Type u) := (union : ααα)
class HasInter (α : Type u) := (inter : ααα)
class HasSDiff (α : Type u) := (sdiff : ααα)
class HasEquiv (α : Sort u) := (Equiv : αα → Prop)
class HasSubset (α : Type u) := (Subset : αα → Prop)
class HasSSubset (α : Type u) := (SSubset : αα → Prop)
/- Type classes HasEmptyc and HasInsert are
used to implement polymorphic notation for collections.
Example: {a, b, c}. -/
class HasEmptyc (α : Type u) := (emptyc : α)
class HasInsert (α : outParam $ Type u) (γ : Type v) := (insert : αγγ)
/- Type class used to implement the notation { a ∈ c | p a } -/
class HasSep (α : outParam $ Type u) (γ : Type v) :=
(sep : (α → Prop) → γγ)
/- Type class for set-like membership -/
class HasMem (α : outParam $ Type u) (γ : Type v) := (mem : αγ → Prop)
@ -392,7 +365,6 @@ infix + := HasAdd.add
infix * := HasMul.mul
infix - := HasSub.sub
infix / := HasDiv.div
infix := HasDivides.Divides
infix % := HasMod.mod
infix %ₙ := HasModn.modn
prefix - := HasNeg.neg
@ -402,11 +374,6 @@ infix < := HasLess.Less
infix == := HasBeq.beq
infix ++ := HasAppend.append
notation `∅` := HasEmptyc.emptyc _
infix := HasUnion.union
infix ∩ := HasInter.inter
infix ⊆ := HasSubset.Subset
infix ⊂ := HasSSubset.SSubset
infix \ := HasSDiff.sdiff
infix ≈ := HasEquiv.Equiv
infixr ^ := HasPow.pow
infixr /\ := And
@ -429,23 +396,11 @@ infix >= := GreaterEq
infix ≥ := GreaterEq
infix > := Greater
@[reducible] def Superset {α : Type u} [HasSubset α] (a b : α) : Prop := HasSubset.Subset b a
@[reducible] def SSuperset {α : Type u} [HasSSubset α] (a b : α) : Prop := HasSSubset.SSubset b a
infix ⊇ := Superset
infix ⊃ := SSuperset
@[inline] def bit0 {α : Type u} [s : HasAdd α] (a : α) : α := a + a
@[inline] def bit1 {α : Type u} [s₁ : HasOne α] [s₂ : HasAdd α] (a : α) : α := (bit0 a) + 1
attribute [matchPattern] HasZero.zero HasOne.one bit0 bit1 HasAdd.add HasNeg.neg
export HasInsert (insert)
/- The Empty collection -/
@[inline] def singleton {α : Type u} {γ : Type v} [HasEmptyc γ] [HasInsert α γ] (a : α) : γ :=
HasInsert.insert a ∅
/- Nat basic instances -/
@[extern cpp "lean::nat_add"]
protected def Nat.add : (@& Nat) → (@& Nat) → Nat
@ -1239,18 +1194,16 @@ end Subtype
/- Sum -/
infixr ⊕ := Sum
section
variables {α : Type u} {β : Type v}
instance Sum.inhabitedLeft [h : Inhabited α] : Inhabited (α β) :=
instance Sum.inhabitedLeft [h : Inhabited α] : Inhabited (Sum α β) :=
⟨Sum.inl (default α)⟩
instance Sum.inhabitedRight [h : Inhabited β] : Inhabited (α β) :=
instance Sum.inhabitedRight [h : Inhabited β] : Inhabited (Sum α β) :=
⟨Sum.inr (default β)⟩
instance {α : Type u} {β : Type v} [DecidableEq α] [DecidableEq β] : DecidableEq (α β) :=
instance {α : Type u} {β : Type v} [DecidableEq α] [DecidableEq β] : DecidableEq (Sum α β) :=
{decEq := fun a b =>
match a, b with
| (Sum.inl a), (Sum.inl b) =>

View file

@ -266,9 +266,6 @@ def unzip : List (α × β) → List α × List β
protected def insert [DecidableEq α] (a : α) (l : List α) : List α :=
if a ∈ l then l else a :: l
instance [DecidableEq α] : HasInsert α (List α) :=
⟨List.insert⟩
def replicate (n : Nat) (a : α) : List α :=
n.repeat (fun xs => a :: xs) []

View file

@ -19,6 +19,9 @@ instance (α : Type u) (lt : αα → Bool) : HasEmptyc (RBTree α lt) :=
namespace RBTree
variables {α : Type u} {β : Type v} {lt : αα → Bool}
@[inline] def empty : RBTree α lt :=
RBMap.empty
@[inline] def depth (f : Nat → Nat → Nat) (t : RBTree α lt) : Nat :=
RBMap.depth f t
@ -56,8 +59,6 @@ instance [HasRepr α] : HasRepr (RBTree α lt) :=
@[inline] def insert (t : RBTree α lt) (a : α) : RBTree α lt :=
RBMap.insert t a ()
instance : HasInsert α (RBTree α lt) := ⟨fun a s => s.insert a⟩
@[inline] def erase (t : RBTree α lt) (a : α) : RBTree α lt :=
RBMap.erase t a

View file

@ -42,7 +42,7 @@ instance : HasRepr Unit :=
instance {α : Type u} [HasRepr α] : HasRepr (Option α) :=
⟨fun o => match o with | none => "none" | (some a) => "(some " ++ repr a ++ ")"⟩
instance {α : Type u} {β : Type v} [HasRepr α] [HasRepr β] : HasRepr (α β) :=
instance {α : Type u} {β : Type v} [HasRepr α] [HasRepr β] : HasRepr (Sum α β) :=
⟨fun s => match s with | (inl a) => "(inl " ++ repr a ++ ")" | (inr b) => "(inr " ++ repr b ++ ")"⟩
instance {α : Type u} {β : Type v} [HasRepr α] [HasRepr β] : HasRepr (α × β) :=

View file

@ -76,7 +76,7 @@ instance : HasToString USize :=
instance {α : Type u} [HasToString α] : HasToString (Option α) :=
⟨fun o => match o with | none => "none" | (some a) => "(some " ++ toString a ++ ")"⟩
instance {α : Type u} {β : Type v} [HasToString α] [HasToString β] : HasToString (α β) :=
instance {α : Type u} {β : Type v} [HasToString α] [HasToString β] : HasToString (Sum α β) :=
⟨fun s => match s with | (inl a) => "(inl " ++ toString a ++ ")" | (inr b) => "(inr " ++ toString b ++ ")"⟩
instance {α : Type u} {β : Type v} [HasToString α] [HasToString β] : HasToString (α × β) :=

View file

@ -390,6 +390,9 @@ Decl.extern f xs ty e
abbrev IndexSet := RBTree Index Index.lt
instance vsetInh : Inhabited IndexSet := ⟨{}⟩
def mkIndexSet (idx : Index) : IndexSet :=
RBTree.empty.insert idx
inductive LocalContextEntry
| param : IRType → LocalContextEntry
| localVar : IRType → Expr → LocalContextEntry

View file

@ -88,6 +88,9 @@ abbrev JPLiveVarMap := RBMap JoinPointId LiveVarSet (fun j₁ j₂ => j₁.idx <
instance LiveVarSet.inhabited : Inhabited LiveVarSet := ⟨{}⟩
def mkLiveVarSet (x : VarId) : LiveVarSet :=
RBTree.empty.insert x
namespace LiveVars
abbrev Collector := LiveVarSet → LiveVarSet

View file

@ -45,7 +45,7 @@ partial def FnBody.pushProj : FnBody → FnBody
match term with
| FnBody.case tid x alts =>
let altsF := alts.map $ fun alt => alt.body.freeIndices;
let (bs, alts) := pushProjs bs alts altsF Array.empty {x.idx};
let (bs, alts) := pushProjs bs alts altsF Array.empty (mkIndexSet x.idx);
let alts := alts.map $ fun alt => alt.modifyBody FnBody.pushProj;
let term := FnBody.case tid x alts;
reshape bs term

View file

@ -260,7 +260,7 @@ partial def visitFnBody : FnBody → Context → (FnBody × LiveVarSet)
match x with
| Arg.var x =>
let info := getVarInfo ctx x;
if info.ref && !info.persistent && !info.consume then (addInc x b, {x}) else (b, {x})
if info.ref && !info.persistent && !info.consume then (addInc x b, mkLiveVarSet x) else (b, mkLiveVarSet x)
| _ => (b, {})
| b@(FnBody.jmp j xs) ctx :=
let jLiveVars := getJPLiveVars ctx j;

View file

@ -45,7 +45,8 @@ pushLeading >> symbol sym lbp >> termParser lbp
@[builtinTermParser] def sort := parser! symbol "Sort" appPrec
@[builtinTermParser] def hole := parser! symbol "_" appPrec
@[builtinTermParser] def «sorry» := parser! symbol "sorry" appPrec
@[builtinTermParser] def cdot := parser! symbol "·" appPrec
@[builtinTermParser] def cdot := parser! symbol "·" appPrec
@[builtinTermParser] def emptyC := parser! symbol "∅" appPrec
def typeAscription := parser! " : " >> termParser
def tupleTail := parser! ", " >> sepBy1 termParser ", "
def parenSpecial : Parser := optional (tupleTail <|> typeAscription)