mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-21 03:41:30 +03:00
a59a104230
Mostly direct from Blodwen (some minor modifications to deal with new way of going into a new scope in the elaborator as well as the usual bits dealing with name lookup and Glued terms)
38 lines
810 B
Plaintext
38 lines
810 B
Plaintext
data Nat : Type where
|
|
Z : Nat
|
|
S : Nat -> Nat
|
|
|
|
plus : Nat -> Nat -> Nat
|
|
plus Z y = y
|
|
plus (S k) y = S (plus k y)
|
|
|
|
data Eq : a -> b -> Type where
|
|
Refl : Eq x x
|
|
|
|
rewrite__impl : {0 x, y : a} -> (0 p : _) ->
|
|
(0 rule : Eq x y) -> (1 val : p y) -> p x
|
|
rewrite__impl p Refl prf = prf
|
|
|
|
%rewrite Eq rewrite__impl
|
|
|
|
plusnZ : (n : Nat) -> Eq (plus n Z) n
|
|
plusnZ Z = Refl
|
|
plusnZ (S k) = rewrite plusnZ k in Refl
|
|
|
|
plusnSm : (n : Nat) -> (m : Nat) ->
|
|
Eq (S (plus n m)) (plus n (S m))
|
|
plusnSm Z m = Refl
|
|
plusnSm (S k) m
|
|
= let ih = plusnSm k m in
|
|
rewrite ih in Refl
|
|
|
|
plusComm : (n : Nat) -> (m : Nat) -> Eq (plus n m) (plus m n)
|
|
plusComm Z m = rewrite plusnZ m in Refl
|
|
plusComm (S k) m =
|
|
let ih = plusComm k m in
|
|
rewrite ih in
|
|
rewrite plusnSm m k in Refl
|
|
|
|
|
|
|