parent
25144dc91a
commit
964fd3f520
9 changed files with 23 additions and 23 deletions
|
|
@ -1,12 +1,12 @@
|
|||
class HasMem (α : outParam $ Type u) (β : Type v) where
|
||||
mem : α → β → Prop
|
||||
|
||||
class PartialOrder (P : Type u) extends HasLessEq P where
|
||||
class PartialOrder (P : Type u) extends LE P where
|
||||
refl (s : P) : s ≤ s
|
||||
antisymm (s t : P) : s ≤ t → t ≤ s → s = t
|
||||
trans (s t u : P) : s ≤ t → t ≤ u → s ≤ u
|
||||
|
||||
theorem HasLessEq.LessEq.trans {P : Type _} [PartialOrder P] {x y z : P} : x ≤ y → y ≤ z → x ≤ z := PartialOrder.trans _ _ _
|
||||
theorem LE.le.trans {P : Type _} [PartialOrder P] {x y z : P} : x ≤ y → y ≤ z → x ≤ z := PartialOrder.trans _ _ _
|
||||
|
||||
infix:50 " ∈ " => HasMem.mem
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ instance : HasMem α (Set α) := ⟨λ a s => s a⟩
|
|||
theorem ext {s t : Set α} (h : ∀ x, x ∈ s ↔ x ∈ t) : s = t :=
|
||||
funext $ λ x => propext $ h x
|
||||
|
||||
instance : HasLessEq (Set α) := ⟨λ s t => ∀ {x : α}, x ∈ s → x ∈ t⟩
|
||||
instance : LE (Set α) := ⟨λ s t => ∀ {x : α}, x ∈ s → x ∈ t⟩
|
||||
|
||||
instance : PartialOrder (Set α) where
|
||||
refl := λ s x => id
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
macroStack.lean:4:5-4:6: error: unknown identifier 'x'
|
||||
macroStack.lean:8:6-8:7: error: unknown identifier 'x'
|
||||
with resulting expansion
|
||||
binrel% Greater✝ x 0
|
||||
binrel% GT.gt✝ x 0
|
||||
while expanding
|
||||
x > 0
|
||||
while expanding
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
def ex1 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less x i
|
||||
binrel% LT.lt x i
|
||||
|
||||
def ex2 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less i x
|
||||
binrel% LT.lt i x
|
||||
|
||||
def ex3 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less (i + 1) x
|
||||
binrel% LT.lt (i + 1) x
|
||||
|
||||
def ex4 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less i (x + 1)
|
||||
binrel% LT.lt i (x + 1)
|
||||
|
||||
def ex5 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less i (x + y)
|
||||
binrel% LT.lt i (x + y)
|
||||
|
||||
def ex6 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less (i + j) (x + 0)
|
||||
binrel% LT.lt (i + j) (x + 0)
|
||||
|
||||
def ex7 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less (i + j) (x + i)
|
||||
binrel% LT.lt (i + j) (x + i)
|
||||
|
||||
def ex8 (x y : Nat) (i j : Int) :=
|
||||
binrel% Less (i + 0) (x + i)
|
||||
binrel% LT.lt (i + 0) (x + i)
|
||||
|
||||
def ex9 (n : UInt32) :=
|
||||
binrel% Less n 0xd800
|
||||
binrel% LT.lt n 0xd800
|
||||
|
||||
def ex10 (x : Lean.Syntax) : Bool :=
|
||||
x.getArgs.all (binrel% BEq.beq ·.getKind `foo)
|
||||
|
||||
def ex11 (xs : Array (Nat × Nat)) :=
|
||||
let f a b := binrel% Less a.1 b.1
|
||||
let f a b := binrel% LT.lt a.1 b.1
|
||||
f xs[1] xs[2]
|
||||
|
||||
def ex12 (i j : Int) :=
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ infix:50 " ∈ " => HasMem.mem
|
|||
|
||||
instance : HasMem α (Set α) := ⟨λ a s => s a⟩
|
||||
|
||||
instance : HasLessEq (Set α) := ⟨λ s t => ∀ {x : α}, x ∈ s → x ∈ t⟩
|
||||
instance : LE (Set α) := ⟨λ s t => ∀ {x : α}, x ∈ s → x ∈ t⟩
|
||||
|
||||
class HasInf (P : Type u) where
|
||||
inf : P → P → P
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
inductive L1.{u} (α : Type u)
|
||||
| nil
|
||||
| cons : α → L1 α → L1 α
|
||||
|
|
@ -80,7 +78,7 @@ inductive ListLast {α : Type u} : List α → Type u
|
|||
inductive Test : Nat → Type
|
||||
| mk : Test ((fun n => n.succ) Nat.zero)
|
||||
|
||||
inductive SortedMap {α : Type u} {β : Type v} [HasLess α] : List (α × β) → Prop
|
||||
inductive SortedMap {α : Type u} {β : Type v} [LT α] : List (α × β) → Prop
|
||||
| nil : SortedMap []
|
||||
| cons : ∀ (k : α) (v : β) (l : List (α × β)),
|
||||
SortedMap l →
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
namespace Ex
|
||||
inductive LE : Nat → Nat → Prop
|
||||
| refl : LE n n
|
||||
| succ : LE n m → LE n m.succ
|
||||
|
|
@ -44,3 +45,4 @@ theorem Power2.mul : Power2 n → Power2 m → Power2 (n*m) := by
|
|||
-- theorem Power2.mul' : Power2 n → Power2 m → Power2 (n*m)
|
||||
-- | h1, base => by simp_all
|
||||
-- | h1, ind h2 => mul_left_comm .. ▸ ind (mul' h1 h2)
|
||||
end Ex
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class Preorder (α : Type u) extends HasLessEq α where
|
||||
class Preorder (α : Type u) extends LE α where
|
||||
le_refl (a : α) : a ≤ a
|
||||
le_trans {a b c : α} : a ≤ b → b ≤ c → a ≤ c
|
||||
|
||||
instance {α : Type u} {β : α → Type v} [(a : α) → Preorder (β a)] : Preorder ((a : α) → β a) where
|
||||
LessEq f g := ∀ a, f a ≤ g a
|
||||
le f g := ∀ a, f a ≤ g a
|
||||
le_refl f := fun a => Preorder.le_refl (f a)
|
||||
le_trans := fun h₁ h₂ a => Preorder.le_trans (h₁ a) (h₂ a)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
structure Fin2 (n : Nat) :=
|
||||
(val : Nat)
|
||||
(isLt : Less val n)
|
||||
(isLt : val < n)
|
||||
|
||||
protected def Fin2.ofNat {n : Nat} (a : Nat) : Fin2 (Nat.succ n) :=
|
||||
⟨a % Nat.succ n, Nat.mod_lt _ (Nat.zeroLtSucc _)⟩
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
def UInt32.ofNatCore' (n : Nat) (h : Less n UInt32.size) : UInt32 := {
|
||||
def UInt32.ofNatCore' (n : Nat) (h : n < UInt32.size) : UInt32 := {
|
||||
val := { val := n, isLt := h }
|
||||
}
|
||||
|
||||
#eval UInt32.ofNatCore' 10 (by decide)
|
||||
|
||||
def UInt64.ofNatCore' (n : Nat) (h : Less n UInt64.size) : UInt64 := {
|
||||
def UInt64.ofNatCore' (n : Nat) (h : n < UInt64.size) : UInt64 := {
|
||||
val := { val := n, isLt := h }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue