lean4-htt/tests/lean/run/CoeNew.lean
Leonardo de Moura 0c4030137f feat: simplify Coe again
Users may add the expensive instances if they want.
The goal is to make sure the default configuration is solid, and
covers all examples we really want to support.

cc @kha @dselsam
2020-01-29 22:08:42 -08:00

29 lines
749 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

universes u v w
instance boolToNat : Coe Bool Nat :=
{ coe := fun b => cond b 1 0 }
instance natToBool : Coe Nat Bool :=
{ coe := fun n => match n with
| 0 => false
| _ => true }
structure ConstantFunction (α β : Type) :=
(f : α → β)
(h : ∀ a₁ a₂, f a₁ = f a₂)
instance constantFunctionCoe {α β : Type} : CoeFun (ConstantFunction α β) (fun _ => α → β) :=
{ coe := fun c => c.f }
new_frontend
set_option pp.implicit true
#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _⟩ Nat
#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _⟩ Bool
#synth CoeT Nat 0 (Option Nat)
#synth CoeT Bool true (Option Nat)
#synth CoeT Prop (0 = 1) Bool
#synth CoeT Bool true (Option Nat)
def f (c : ConstantFunction Nat Nat) : Nat :=
c 0