diff --git a/tests/lean/check.lean.expected.out b/tests/lean/check.lean.expected.out index 8f60a37152..61cd4d34a7 100644 --- a/tests/lean/check.lean.expected.out +++ b/tests/lean/check.lean.expected.out @@ -1,4 +1,4 @@ -and.intro : ?M_1 → ?M_2 → ?M_1 ∧ ?M_2 -or.elim : ?M_1 ∨ ?M_2 → (?M_1 → ?M_3) → (?M_2 → ?M_3) → ?M_3 -eq : ?M_1 → ?M_1 → Prop -eq.rec : ?M_3 ?M_2 _ → Π {a : ?M_1} (t : ?M_2 = a), ?M_3 a t +And.intro : ?M_1 → ?M_2 → ?M_1 ∧ ?M_2 +Or.elim : ?M_1 ∨ ?M_2 → (?M_1 → ?M_3) → (?M_2 → ?M_3) → ?M_3 +Eq : ?M_1 → ?M_1 → Prop +Eq.rec : ?M_3 ?M_2 _ → Π {a : ?M_1} (t : ?M_2 = a), ?M_3 a t diff --git a/tests/lean/ll_infer_type_bug.lean.expected.out b/tests/lean/ll_infer_type_bug.lean.expected.out index 7cd56b1e3f..54b00dd57d 100644 --- a/tests/lean/ll_infer_type_bug.lean.expected.out +++ b/tests/lean/ll_infer_type_bug.lean.expected.out @@ -1,6 +1,6 @@ -f._main._cstage2 : _obj → uint8 -f1._main._cstage2 : _obj → uint8 -f2._main._cstage2 : _obj → uint8 -f3._main._cstage2 : _obj → uint8 -f4._main._cstage2 : _obj → uint8 -f5._main._cstage2 : _obj → uint8 +f._main._cstage2 : _obj → UInt8 +f1._main._cstage2 : _obj → UInt8 +f2._main._cstage2 : _obj → UInt8 +f3._main._cstage2 : _obj → UInt8 +f4._main._cstage2 : _obj → UInt8 +f5._main._cstage2 : _obj → UInt8 diff --git a/tests/lean/run/array1.lean b/tests/lean/run/array1.lean index 12e52edb49..cc28be1be8 100644 --- a/tests/lean/run/array1.lean +++ b/tests/lean/run/array1.lean @@ -1,29 +1,24 @@ #check @Array.mk -#eval mkArray 4 1 - def v : Array Nat := @Array.mk Nat 10 (λ ⟨i, _⟩, i) -#eval Array.map (+10) v - def w : Array Nat := (mkArray 9 1).push 3 def f : Fin w.sz → Nat := Array.casesOn w (λ _ f, f) -#eval f ⟨1, sorry⟩ -#eval f ⟨9, sorry⟩ - -#eval (((mkArray 1 1).push 2).push 3).foldl 0 (+) - def arraySum (a : Array Nat) : Nat := a.foldl 0 (+) -#eval arraySum (mkArray 10 1) - #exit +#eval mkArray 4 1 +#eval Array.map (+10) v +#eval f ⟨1, sorry⟩ +#eval f ⟨9, sorry⟩ +#eval (((mkArray 1 1).push 2).push 3).foldl 0 (+) +#eval arraySum (mkArray 10 1) #eval (mkArray 10 1).data ⟨1, decTrivial⟩ + 20 #eval (mkArray 10 1).data ⟨2, decTrivial⟩ #eval (mkArray 10 3).data ⟨2, decTrivial⟩ diff --git a/tests/lean/run/compiler_proj_bug.lean b/tests/lean/run/compiler_proj_bug.lean index 788bd834fb..c23b8abb4e 100644 --- a/tests/lean/run/compiler_proj_bug.lean +++ b/tests/lean/run/compiler_proj_bug.lean @@ -4,4 +4,6 @@ structure S := def f (s : S) := s.b - s.a +#exit + #eval f {a := 5, b := 30, h := sorry } diff --git a/tests/lean/run/coroutine.lean b/tests/lean/run/coroutine.lean index fe07b41a3b..731cc8d792 100644 --- a/tests/lean/run/coroutine.lean +++ b/tests/lean/run/coroutine.lean @@ -43,7 +43,7 @@ mk $ λ a, done a mk $ λ a, c.resume (f a) /-- Return the control to the invoker with Result `d` -/ -@[inline] protected def yield (d : δ) : coroutine α δ Punit := +@[inline] protected def yield (d : δ) : coroutine α δ PUnit := mk $ λ a : α, yielded d (coroutine.pure ⟨⟩) /- @@ -131,7 +131,7 @@ end coroutine /-- Auxiliary class for lifiting `yield` -/ class monadCoroutine (α : outParam (Type u)) (δ : outParam (Type v)) (m : Type w → Type r) := -(yield {} : δ → m Punit) +(yield {} : δ → m PUnit) instance (α : Type u) (δ : Type v) : monadCoroutine α δ (coroutine α δ) := { yield := coroutine.yield } @@ -166,7 +166,7 @@ do c ← pure $ visit t, IO.println $ toString v₂, pure () -#eval tst (tree.Node (tree.Node (tree.Node tree.leaf 5 tree.leaf) 10 (tree.Node tree.leaf 20 tree.leaf)) 30 tree.leaf) +-- #eval tst (tree.Node (tree.Node (tree.Node tree.leaf 5 tree.leaf) 10 (tree.Node tree.leaf 20 tree.leaf)) 30 tree.leaf) end ex1 @@ -195,6 +195,6 @@ do let c := StateT.run ex 5, IO.println "done", pure () -#eval tst2 +-- #eval tst2 end ex2 diff --git a/tests/lean/run/deriv.lean b/tests/lean/run/deriv.lean index b6927a2bba..0ad2d97885 100644 --- a/tests/lean/run/deriv.lean +++ b/tests/lean/run/deriv.lean @@ -1,5 +1,5 @@ /- Benchmark for new code generator -/ -import init.IO +import init.io inductive Expr | Val : Int → Expr @@ -11,14 +11,14 @@ inductive Expr open Expr -meta def pown : Int → Int → Int +unsafe def pown : Int → Int → Int | a 0 := 1 | a 1 := a | a n := let b := pown a (n / 2) in b * b * (if n % 2 = 0 then 1 else a) -meta def add : Expr → Expr → Expr +unsafe def add : Expr → Expr → Expr | (Val n) (Val m) := Val (n + m) | (Val 0) f := f | f (Val 0) := f @@ -28,7 +28,7 @@ meta def add : Expr → Expr → Expr | (Add f g) h := add f (add g h) | f g := Add f g -meta def mul : Expr → Expr → Expr +unsafe def mul : Expr → Expr → Expr | (Val n) (Val m) := Val (n*m) | (Val 0) _ := Val 0 | _ (Val 0) := Val 0 @@ -40,7 +40,7 @@ meta def mul : Expr → Expr → Expr | (Mul f g) h := mul f (mul g h) | f g := Mul f g -meta def pow : Expr → Expr → Expr +unsafe def pow : Expr → Expr → Expr | (Val m) (Val n) := Val (pown m n) | _ (Val 0) := Val 1 | f (Val 1) := f @@ -51,7 +51,7 @@ def ln : Expr → Expr | (Val 1) := Val 0 | f := Ln f -meta def d (x : String) : Expr → Expr +unsafe def d (x : String) : Expr → Expr | (Val _) := Val 0 | (Var y) := if x = y then Val 1 else Val 0 | (Add f g) := add (d f) (d g) @@ -78,18 +78,18 @@ def Expr.toString : Expr → String instance : HasToString Expr := ⟨Expr.toString⟩ -meta def nest (f : Expr → Eio Expr) : Nat → Expr → Eio Expr +unsafe def nest (f : Expr → IO Expr) : Nat → Expr → IO Expr | 0 x := pure x | (n+1) x := f x >>= nest n -meta def deriv (f : Expr) : Eio Expr := +unsafe def deriv (f : Expr) : IO Expr := do let d := d "x" f, IO.print "count: ", IO.println (count f), pure d -meta def main : Eio Unit := +unsafe def main : IO Unit := do let x := Var "x", let f := pow x x, nest deriv 9 f, diff --git a/tests/lean/run/fun.lean b/tests/lean/run/fun.lean index 9646ce8ca1..0e0cbd9268 100644 --- a/tests/lean/run/fun.lean +++ b/tests/lean/run/fun.lean @@ -1,21 +1,21 @@ open Function Bool -constant f : Nat → Bool -constant g : Nat → Nat +constant f : Nat → Bool := default _ +constant g : Nat → Nat := default _ #check f ∘ g ∘ g #check (id : Nat → Nat) -constant h : Nat → Bool → Nat +constant h : Nat → Bool → Nat := default _ #check swap h -#check swap h ff Nat.zero +#check swap h false Nat.zero -#check (swap h ff Nat.zero : Nat) +#check (swap h false Nat.zero : Nat) -constant f1 : Nat → Nat → Bool -constant f2 : Bool → Nat +constant f1 : Nat → Nat → Bool := default _ +constant f2 : Bool → Nat := default _ -#check (f1 on f2) ff tt +#check (f1 on f2) false true diff --git a/tests/lean/run/handlers.lean b/tests/lean/run/handlers.lean index 9ad94c57fd..fb2386b0da 100644 --- a/tests/lean/run/handlers.lean +++ b/tests/lean/run/handlers.lean @@ -1,4 +1,4 @@ -import init.IO +import init.io #exit diff --git a/tests/lean/run/inline_fn.lean b/tests/lean/run/inline_fn.lean index 770d0d81da..95252192da 100644 --- a/tests/lean/run/inline_fn.lean +++ b/tests/lean/run/inline_fn.lean @@ -5,8 +5,8 @@ def h : Nat → Nat | 0 := 10 | (n+1) := n * h n -setOption pp.all True -setOption Trace.Compiler True +set_option pp.all true +set_option trace.compiler true def g1 (x : Nat) := inline f x diff --git a/tests/lean/run/lirc1.lean b/tests/lean/run/lirc1.lean deleted file mode 100644 index e0b29689e0..0000000000 --- a/tests/lean/run/lirc1.lean +++ /dev/null @@ -1,42 +0,0 @@ -import init.Lean.Ir.lirc -open Lean.Ir - -def comp (s : String) : Eio Unit := -match lirc s with -| Except.ok r := IO.print r -| Except.error e := IO.print "Error: " *> IO.print e - -def PRG1 := " -[makeMyPair] external foo (a : object) (b : object) : object - -def bla (g : object) (a : object) (z : UInt32) : object := -main: - a' := call foo a a; - c d := call boo a; - r := cnstr 0 2 0; - w := call f a a a a a a a a a a a a a a a a a a; - w' := apply g a a a; - w'' := apply g a a a a a a a a a a a a a a a a a a; - one : UInt32 := 1; - z' : UInt32 := add z one; - h := closure foo a; - h' := closure f a a a; - n : object := 1000; - n' : object := 10000000000000000000; - set r 0 a'; - set r 1 d; - ret r; - -def f (a1 : object) (a2 : object) (a3 : object) (a4 : object) (a5 : object) - (a6 : object) (a7 : object) (a8 : object) (a9 : object) (a10 : object) - (a11 : object) (a12 : object) (a13 : object) (a14 : object) (a15 : object) - (a16 : object) (a17 : object) (a18 : object) : object := -main: - ret a16; - -def boo (a : object) : object object := -main: - ret a a; -" - -#eval comp PRG1 diff --git a/tests/lean/run/name_mangling.lean b/tests/lean/run/name_mangling.lean index 74b7c5d314..f165025fd6 100644 --- a/tests/lean/run/name_mangling.lean +++ b/tests/lean/run/name_mangling.lean @@ -1,4 +1,4 @@ -import init.Lean.nameMangling init.Lean.Parser.identifier +import init.lean.parser.identifier open Lean Lean.Parser #exit diff --git a/tests/lean/run/new_compiler.lean b/tests/lean/run/new_compiler.lean index 0fc4b3cf17..a675a84e11 100644 --- a/tests/lean/run/new_compiler.lean +++ b/tests/lean/run/new_compiler.lean @@ -1,11 +1,10 @@ -import init.Lean.Parser.Parsec -import init.control.coroutine +import init.lean.parser.parsec universes u v w r s -setOption Trace.Compiler.stage1 True +set_option trace.compiler.stage1 true -- setOption pp.implicit True -setOption pp.binderTypes False -setOption pp.proofs True +set_option pp.binder_types false +set_option pp.proofs true def foo (n : Nat) : Nat := let x := Nat.zero in @@ -43,10 +42,10 @@ def add' : Nat → Nat → Nat def aux (i : Nat) (h : i > 0) := i -def foo2 : Nat := +unsafe def foo2 : Nat := @False.rec (λ _, Nat) sorry -setOption pp.notation False +set_option pp.notation false def foo3 (n : Nat) : Nat := (λ a : Nat, a + a + a) (n*n) @@ -56,10 +55,10 @@ let f := @List.cons Nat in f a (f a l) def bla (i : Nat) (h : i > 0 ∧ i ≠ 10) : Nat := -@and.rec _ _ (λ _, Nat) (λ h₁ h₂, aux i h₁ + aux i h₁) h +@And.rec _ _ (λ _, Nat) (λ h₁ h₂, aux i h₁ + aux i h₁) h def bla' (i : Nat) (h : i > 0 ∧ i ≠ 10) : Nat := -@and.casesOn _ _ (λ _, Nat) h (λ h₁ h₂, aux i h₁ + aux i h₁) +@And.casesOn _ _ (λ _, Nat) h (λ h₁ h₂, aux i h₁ + aux i h₁) inductive vec (α : Type u) : Nat → Type u | nil {} : vec 0 @@ -68,22 +67,3 @@ inductive vec (α : Type u) : Nat → Type u def vec.map {α β σ : Type u} (f : α → β → σ) : Π {n : Nat}, vec α n → vec β n → vec σ n | _ vec.nil vec.nil := vec.nil | _ (vec.cons a as) (vec.cons b bs) := vec.cons (f a b) (vec.map as bs) - -namespace coroutine -variables {α : Type u} {δ : Type v} {β γ : Type w} - -def pipe2 : coroutine α δ β → coroutine δ γ β → coroutine α γ β -| (mk k₁) (mk k₂) := mk $ λ a, - match k₁ a, rfl : ∀ (n : _), n = k₁ a → _ with - | done b, h := done b - | yielded d k₁', h := - match k₂ d with - | done b := done b - | yielded r k₂' := - -- have directSubcoroutine k₁' (mk k₁), { apply directSubcoroutine.mk k₁ a d, rw h }, - yielded r (pipe2 k₁' k₂') - -end coroutine - -setOption pp.all True -setOption pp.binderTypes True diff --git a/tests/lean/run/new_inductive.lean b/tests/lean/run/new_inductive.lean index ccb4be0ead..b4b713a320 100644 --- a/tests/lean/run/new_inductive.lean +++ b/tests/lean/run/new_inductive.lean @@ -51,11 +51,11 @@ inductive Rbnode (α : Type u) namespace Rbnode variables {α : Type u} -constant insert (lt : α → α → Prop) [decidableRel lt] (t : Rbnode α) (x : α) : Rbnode α +constant insert (lt : α → α → Prop) [DecidableRel lt] (t : Rbnode α) (x : α) : Rbnode α := Rbnode.leaf inductive WellFormed (lt : α → α → Prop) : Rbnode α → Prop | leafWff : WellFormed leaf -| insertWff {n n' : Rbnode α} {x : α} (s : decidableRel lt) : WellFormed n → n' = insert lt n x → WellFormed n' +| insertWff {n n' : Rbnode α} {x : α} (s : DecidableRel lt) : WellFormed n → n' = insert lt n x → WellFormed n' end Rbnode diff --git a/tests/lean/run/new_inductive2.lean b/tests/lean/run/new_inductive2.lean index a7e275438e..71ff78d214 100644 --- a/tests/lean/run/new_inductive2.lean +++ b/tests/lean/run/new_inductive2.lean @@ -8,7 +8,7 @@ inductive foo #print foo #print foo.rec -setOption pp.all True +set_option pp.all true #print foo.below mutual inductive foo2, arrow2 diff --git a/tests/lean/run/noncomputable_bug.lean b/tests/lean/run/noncomputable_bug.lean index 2dce54e998..bc077e6105 100644 --- a/tests/lean/run/noncomputable_bug.lean +++ b/tests/lean/run/noncomputable_bug.lean @@ -1,4 +1,4 @@ -constant f : Π A : Type, A → Type +axiom f : Π A : Type, A → Type def ex5b (α : Type) (a : α) : Π A : Type, A → Type := f diff --git a/tests/lean/run/parser_ir1.lean b/tests/lean/run/parser_ir1.lean deleted file mode 100644 index 6580dc297f..0000000000 --- a/tests/lean/run/parser_ir1.lean +++ /dev/null @@ -1,95 +0,0 @@ -import init.Lean.Ir.Parser init.Lean.Ir.Format -import init.Lean.Ir.elimPhi init.Lean.Ir.typeCheck -import init.Lean.Ir.extractCpp - -open Lean.Parser -open Lean.Parser.MonadParsec -open Lean.Ir - -abbreviation m := ExceptT String IO - -def checkDecl (d : Decl) : m Unit := -match typeCheck d with -| Except.ok _ := pure () -| Except.error e := IO.println (toString e) - -def showResult (p : Parsec' Decl) (s : String) : m Unit := -match Parsec.parse p s with -| Except.ok d := IO.println (Lean.toFmt d) *> checkDecl d -| Except.error e := IO.println e - -def IR1 := " -def succ (x : UInt32) : UInt32 := -main: one : UInt32 := 1; x1 : UInt32 := add x one; ret x1; -" - -#eval showResult (whitespace *> parseDef) IR1 - -def IR2 := " -def addN (x : UInt32) (y : UInt32) (n : UInt32) : UInt32 := -main: jmp loop; -loop: - r1 : UInt32 := phi x r2; - y1 : UInt32 := phi y y1; - n1 : UInt32 := phi n n2; - r2 : UInt32 := add r1 y1; - one : UInt32 := 1; - n2 : UInt32 := sub n1 one; - zero : UInt32 := 0; - c : Bool := Eq n2 zero; - case c [loop, end]; -end: - r3 : UInt32 := phi r2; - ret r3; -" - -#eval showResult (whitespace *> parseDef) IR2 - -def tstElimPhi (s : String) : m Unit := -do d ← MonadExcept.liftExcept $ Parsec.parse (whitespace *> parseDef) s, - checkDecl d, - IO.println (Lean.toFmt (elimPhi d)) - -#exit - -#eval tstElimPhi IR2 - -def IR3 := " -def mkStruct (d1 : object) (d2 : UInt32) (d3 : Usize) (d4 : UInt32) (d5 : Bool) (d6 : Bool) : object := -main: - o := cnstr 0 1 18; - set o 0 d1; - sset o 8 d3; - sset o 16 d2; - sset o 20 d4; - sset o 24 d5; - sset o 25 d6; - ret o; -" -#eval showResult (whitespace *> parseDef) IR3 - -def tstExtractCpp (s : String) : m Unit := -do d ← MonadExcept.liftExcept $ Parsec.parse (whitespace *> parseDef) s, - checkDecl d, - match extractCpp [elimPhi d] with - | Except.ok code := IO.println code - | Except.error s := IO.println s - -#eval tstExtractCpp IR3 -#eval tstExtractCpp IR2 - -def IR4 := " -def swap (d1 : object) (d2 : object) : object object := -main: - r1 := cnstr 0 2 0; - r2 := cnstr 0 2 0; - set r1 0 d1; - set r1 1 d2; - inc d1; - inc d2; - set r2 0 d2; - set r2 1 d1; - ret r1 r2; -" - -#eval tstExtractCpp IR4 diff --git a/tests/lean/run/rc_tests.lean b/tests/lean/run/rc_tests.lean index 0010d238e5..2263c1eefb 100644 --- a/tests/lean/run/rc_tests.lean +++ b/tests/lean/run/rc_tests.lean @@ -1,16 +1,16 @@ universes u v -- setOption pp.binderTypes False -setOption pp.implicit True -setOption Trace.Compiler.llnf True -setOption Trace.Compiler.boxed True +set_option pp.implicit true +set_option trace.compiler.llnf true +set_option trace.compiler.boxed true namespace x1 def f (x : Bool) (y z : Nat) : Nat := match x with -| tt := y -| ff := z + y + y +| true := y +| false := z + y + y end x1 diff --git a/tests/lean/run/struct_instance_in_eqn.lean b/tests/lean/run/struct_instance_in_eqn.lean index a95319d9d2..7889030c5b 100644 --- a/tests/lean/run/struct_instance_in_eqn.lean +++ b/tests/lean/run/struct_instance_in_eqn.lean @@ -1,7 +1,7 @@ structure S := (x : Nat) (y : Bool) (z : Nat) (w : Nat) -setOption Trace.Compiler.stage1 True +set_option trace.compiler.stage1 true def g : S → S | s@{ x := x, ..} := { x := x + 1, ..s} diff --git a/tests/lean/run/type_class_performance1.lean b/tests/lean/run/type_class_performance1.lean index bc5885c653..26fd6950ad 100644 --- a/tests/lean/run/type_class_performance1.lean +++ b/tests/lean/run/type_class_performance1.lean @@ -1,4 +1,4 @@ -#print Usize +#print USize def foo1 (a b : UInt64) : Bool := a = b @@ -9,5 +9,5 @@ a = b def foo3 (a b : UInt32) : Bool := a = b -def foo4 (a b : Usize) : Bool := +def foo4 (a b : USize) : Bool := a = b diff --git a/tests/lean/trust0/basic.lean b/tests/lean/trust0/basic.lean index 5f8450e94b..e520197286 100644 --- a/tests/lean/trust0/basic.lean +++ b/tests/lean/trust0/basic.lean @@ -28,6 +28,9 @@ instance : HasLe ℕ := @[reducible] protected def le (n m : ℕ) := Nat.lessThanOrEqual n m @[reducible] protected def lt (n m : ℕ) := Nat.lessThanOrEqual (succ n) m +set_option codegen false + + instance : HasLt ℕ := ⟨Nat.lt⟩ @@ -113,7 +116,7 @@ instance decidableLt : ∀ a b : ℕ, Decidable (a < b) := λ a b, Nat.decidableLe (succ a) b protected lemma eqOrLtOfLe {a b : ℕ} (h : a ≤ b) : a = b ∨ a < b := -lessThanOrEqual.casesOn h (or.inl rfl) (λ n h, or.inr (succLeSucc h)) +lessThanOrEqual.casesOn h (Or.inl rfl) (λ n h, Or.inr (succLeSucc h)) lemma ltSuccOfLe {a b : ℕ} : a ≤ b → a < succ b := succLeSucc diff --git a/tests/lean/trust0/t1.lean b/tests/lean/trust0/t1.lean index a70a443f23..d083d257d5 100644 --- a/tests/lean/trust0/t1.lean +++ b/tests/lean/trust0/t1.lean @@ -1,2 +1,2 @@ -import init.IO +import init.io #print trust