Skip to content

Commit e890280

Browse files
committed
Merge pull request #1619 from ahmadsalim/feature/renamevoid
Removed `_|_` as a built in declaration and renamed it to `Void`
2 parents 7a0f64d + d6981dc commit e890280

38 files changed

+108
-132
lines changed

benchmarks/quasigroups/Solver.idr

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ legalVal b (x, y) v =
103103
Filled : Cell n -> Type
104104
--Filled {n=n} x = Not (Empty x) -- TODO: Find out why this doesn't work
105105
Filled {n=n} = (\x => Not (Empty x))
106-
--Filled {n=n} x = the (Maybe (Fin n)) Nothing = x -> _|_
107-
--Filled {n=n} = \x => the (Maybe (Fin n)) Nothing = x -> _|_
106+
--Filled {n=n} x = the (Maybe (Fin n)) Nothing = x -> Void
107+
--Filled {n=n} = \x => the (Maybe (Fin n)) Nothing = x -> Void
108108

109109
filled : (cell : Cell n) -> Dec (Filled cell)
110110
filled Nothing = No (\f => f Refl)

libs/base/Control/Isomorphism.idr

+21-21
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ eitherAssoc = MkIso eitherAssoc1 eitherAssoc2 ok1 ok2
7070
ok2 (Right x) = Refl
7171

7272
||| Disjunction with false is a no-op
73-
eitherBotLeft : Iso (Either _|_ a) a
73+
eitherBotLeft : Iso (Either Void a) a
7474
eitherBotLeft = MkIso to from ok1 ok2
75-
where to : Either _|_ a -> a
76-
to (Left x) = FalseElim x
75+
where to : Either Void a -> a
76+
to (Left x) = void x
7777
to (Right x) = x
78-
from : a -> Either _|_ a
78+
from : a -> Either Void a
7979
from = Right
8080
ok1 : (x : a) -> to (from x) = x
8181
ok1 x = Refl
82-
ok2 : (x : Either _|_ a) -> from (to x) = x
83-
ok2 (Left x) = FalseElim x
82+
ok2 : (x : Either Void a) -> from (to x) = x
83+
ok2 (Left x) = void x
8484
ok2 (Right x) = Refl
8585

8686
||| Disjunction with false is a no-op
87-
eitherBotRight : Iso (Either a _|_) a
87+
eitherBotRight : Iso (Either a Void) a
8888
eitherBotRight = isoTrans eitherComm eitherBotLeft
8989

9090
||| Isomorphism is a congruence with regards to disjunction
@@ -145,11 +145,11 @@ pairUnitLeft : Iso ((), a) a
145145
pairUnitLeft = isoTrans pairComm pairUnitRight
146146

147147
||| Conjunction preserves falsehood
148-
pairBotLeft : Iso (_|_, a) _|_
149-
pairBotLeft = MkIso fst FalseElim (\x => FalseElim x) (\y => FalseElim (fst y))
148+
pairBotLeft : Iso (Void, a) Void
149+
pairBotLeft = MkIso fst void (\x => void x) (\y => void (fst y))
150150

151151
||| Conjunction preserves falsehood
152-
pairBotRight : Iso (a, _|_) _|_
152+
pairBotRight : Iso (a, Void) Void
153153
pairBotRight = isoTrans pairComm pairBotLeft
154154

155155
||| Isomorphism is a congruence with regards to conjunction
@@ -240,9 +240,9 @@ maybeEither = MkIso to from iso1 iso2
240240
iso2 (Just x) = Refl
241241

242242
||| Maybe of void is just unit
243-
maybeVoidUnit : Iso (Maybe _|_) ()
244-
maybeVoidUnit = (Maybe _|_) ={ maybeEither }=
245-
(Either _|_ ()) ={ eitherBotLeft }=
243+
maybeVoidUnit : Iso (Maybe Void) ()
244+
maybeVoidUnit = (Maybe Void) ={ maybeEither }=
245+
(Either Void ()) ={ eitherBotLeft }=
246246
() QED
247247

248248
eitherMaybeLeftMaybe : Iso (Either (Maybe a) b) (Maybe (Either a b))
@@ -280,16 +280,16 @@ maybeIsoS = MkIso forth back fb bf
280280
fb FZ = Refl
281281
fb (FS x) = Refl
282282

283-
finZeroBot : Iso (Fin 0) _|_
284-
finZeroBot = MkIso (\x => FalseElim (uninhabited x))
285-
(\x => FalseElim x)
286-
(\x => FalseElim x)
287-
(\x => FalseElim (uninhabited x))
283+
finZeroBot : Iso (Fin 0) Void
284+
finZeroBot = MkIso (\x => void (uninhabited x))
285+
(\x => void x)
286+
(\x => void x)
287+
(\x => void (uninhabited x))
288288

289289
eitherFinPlus : Iso (Either (Fin m) (Fin n)) (Fin (m + n))
290290
eitherFinPlus {m = Z} {n=n} =
291291
(Either (Fin 0) (Fin n)) ={ eitherCongLeft finZeroBot }=
292-
(Either _|_ (Fin n)) ={ eitherBotLeft }=
292+
(Either Void (Fin n)) ={ eitherBotLeft }=
293293
(Fin n) QED
294294
eitherFinPlus {m = S k} {n=n} =
295295
(Either (Fin (S k)) (Fin n)) ={ eitherCongLeft (isoSym maybeIsoS) }=
@@ -302,8 +302,8 @@ eitherFinPlus {m = S k} {n=n} =
302302
finPairTimes : Iso (Fin m, Fin n) (Fin (m * n))
303303
finPairTimes {m = Z} {n=n} =
304304
(Fin Z, Fin n) ={ pairCongLeft finZeroBot }=
305-
(_|_, Fin n) ={ pairBotLeft }=
306-
_|_ ={ isoSym finZeroBot }=
305+
(Void, Fin n) ={ pairBotLeft }=
306+
Void ={ isoSym finZeroBot }=
307307
(Fin Z) QED
308308
finPairTimes {m = S k} {n=n} =
309309
(Fin (S k), Fin n) ={ pairCongLeft (isoSym maybeIsoS) }=

libs/base/Data/Heap.idr

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ instance Ord a => JoinSemilattice (MaxiphobicHeap a) where
135135
-- Properties
136136
--------------------------------------------------------------------------------
137137

138-
total absurdBoolDischarge : False = True -> _|_
138+
total absurdBoolDischarge : False = True -> Void
139139
absurdBoolDischarge p = replace {P = disjointTy} p ()
140140
where
141141
total disjointTy : Bool -> Type
142142
disjointTy False = ()
143-
disjointTy True = _|_
143+
disjointTy True = Void
144144

145145
total isEmptySizeZero : (h : MaxiphobicHeap a) -> (isEmpty h = True) -> size h = Z
146146
isEmptySizeZero Empty p = Refl
@@ -169,7 +169,7 @@ mergePreservesValidHeaps (Node ls ll le lr) (Node rs rl re rr) lp rp =
169169

170170
isEmptySizeZeroNodeAbsurd = proof {
171171
intros;
172-
refine FalseElim;
172+
refine void;
173173
refine absurdBoolDischarge;
174174
exact p;
175175
}

libs/base/Data/List.idr

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ isElem x (y :: xs) with (decEq x y)
3232
isElem x (y :: xs) | (No contra) | (No f) = No (mkNo contra f)
3333
where
3434
mkNo : {xs' : List a} ->
35-
((x' = y') -> _|_) -> (Elem x' xs' -> _|_) ->
36-
Elem x' (y' :: xs') -> _|_
35+
((x' = y') -> Void) -> (Elem x' xs' -> Void) ->
36+
Elem x' (y' :: xs') -> Void
3737
mkNo f g Here = f Refl
3838
mkNo f g (There x) = g x

libs/base/Data/Vect.idr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data Elem : a -> Vect k a -> Type where
1515
There : Elem x xs -> Elem x (y::xs)
1616

1717
||| Nothing can be in an empty Vect
18-
noEmptyElem : {x : a} -> Elem x [] -> _|_
18+
noEmptyElem : {x : a} -> Elem x [] -> Void
1919
noEmptyElem Here impossible
2020

2121
||| An item not in the head and not in the tail is not in the Vect at all

libs/base/Data/Vect/Quantifiers.idr

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data Any : (P : a -> Type) -> Vect n a -> Type where
1010
There : {P : a -> Type} -> {xs : Vect n a} -> Any P xs -> Any P (x :: xs)
1111

1212
||| No element of an empty vector satisfies any property
13-
anyNilAbsurd : {P : a -> Type} -> Any P Nil -> _|_
13+
anyNilAbsurd : {P : a -> Type} -> Any P Nil -> Void
1414
anyNilAbsurd (Here _) impossible
1515
anyNilAbsurd (There _) impossible
1616

@@ -48,11 +48,11 @@ negAnyAll : {P : a -> Type} -> {xs : Vect n a} -> Not (Any P xs) -> All (\x => N
4848
negAnyAll {xs=Nil} _ = Nil
4949
negAnyAll {xs=(x::xs)} f = (\x => f (Here x)) :: negAnyAll (\x => f (There x))
5050

51-
notAllHere : {P : a -> Type} -> {xs : Vect n a} -> Not (P x) -> All P (x :: xs) -> _|_
51+
notAllHere : {P : a -> Type} -> {xs : Vect n a} -> Not (P x) -> All P (x :: xs) -> Void
5252
notAllHere _ Nil impossible
5353
notAllHere np (p :: _) = np p
5454

55-
notAllThere : {P : a -> Type} -> {xs : Vect n a} -> Not (All P xs) -> All P (x :: xs) -> _|_
55+
notAllThere : {P : a -> Type} -> {xs : Vect n a} -> Not (All P xs) -> All P (x :: xs) -> Void
5656
notAllThere _ Nil impossible
5757
notAllThere np (_ :: ps) = np ps
5858

libs/base/Data/ZZ.idr

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ posInjective Refl = Refl
122122
negSInjective : NegS n = NegS m -> n = m
123123
negSInjective Refl = Refl
124124

125-
posNotNeg : Pos n = NegS m -> _|_
125+
posNotNeg : Pos n = NegS m -> Void
126126
posNotNeg Refl impossible
127127

128128
-- Decidable equality

libs/base/Decidable/Order.idr

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ LTEIsAntisymmetric (S n) (S m) (LTESucc mLTEn) (LTESucc nLTEm) with (LTEIsAntisy
8484
instance Poset Nat LTE where
8585
antisymmetric = LTEIsAntisymmetric
8686

87-
total zeroNeverGreater : {n : Nat} -> LTE (S n) Z -> _|_
87+
total zeroNeverGreater : {n : Nat} -> LTE (S n) Z -> Void
8888
zeroNeverGreater {n} LTEZero impossible
8989
zeroNeverGreater {n} (LTESucc _) impossible
9090

9191
total zeroAlwaysSmaller : {n : Nat} -> LTE Z n
9292
zeroAlwaysSmaller = LTEZero
9393

94-
total ltesuccinjective : {n : Nat} -> {m : Nat} -> (LTE n m -> _|_) -> LTE (S n) (S m) -> _|_
95-
ltesuccinjective {n} {m} disprf (LTESucc nLTEm) = FalseElim (disprf nLTEm)
94+
total ltesuccinjective : {n : Nat} -> {m : Nat} -> (LTE n m -> Void) -> LTE (S n) (S m) -> Void
95+
ltesuccinjective {n} {m} disprf (LTESucc nLTEm) = void (disprf nLTEm)
9696
ltesuccinjective {n} {m} disprf LTEZero impossible
9797

9898

libs/prelude/Builtins.idr

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ data Pair : (A : Type) -> (B : Type) -> Type where
2929
data Sigma : (a : Type) -> (P : a -> Type) -> Type where
3030
MkSigma : .{P : a -> Type} -> (x : a) -> (pf : P x) -> Sigma a P
3131

32-
||| The eliminator for the empty type.
33-
FalseElim : _|_ -> a
32+
||| The empty type, also known as the trivially false proposition.
33+
|||
34+
||| Use `void` or `absurd` to prove anything if you have a variable of type `Void` in scope.
35+
%elim data Void : Type where
36+
37+
||| The eliminator for the `Void` type.
38+
void : Void -> a
39+
void {a} v = elim_for Void (\_ => a) v
3440

3541
||| For 'symbol syntax. 'foo becomes Symbol_ "foo"
3642
data Symbol_ : String -> Type where

libs/prelude/Decidable/Equality.idr

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Prelude.Maybe
1313
--------------------------------------------------------------------------------
1414

1515
||| The negation of equality is symmetric (follows from symmetry of equality)
16-
total negEqSym : {a : t} -> {b : t} -> (a = b -> _|_) -> (b = a -> _|_)
16+
total negEqSym : {a : t} -> {b : t} -> (a = b -> Void) -> (b = a -> Void)
1717
negEqSym p h = p (sym h)
1818

1919

@@ -36,7 +36,7 @@ instance DecEq () where
3636
--------------------------------------------------------------------------------
3737
-- Booleans
3838
--------------------------------------------------------------------------------
39-
total trueNotFalse : True = False -> _|_
39+
total trueNotFalse : True = False -> Void
4040
trueNotFalse Refl impossible
4141

4242
instance DecEq Bool where
@@ -49,7 +49,7 @@ instance DecEq Bool where
4949
-- Nat
5050
--------------------------------------------------------------------------------
5151

52-
total OnotS : Z = S n -> _|_
52+
total OnotS : Z = S n -> Void
5353
OnotS Refl impossible
5454

5555
instance DecEq Nat where
@@ -64,7 +64,7 @@ instance DecEq Nat where
6464
-- Maybe
6565
--------------------------------------------------------------------------------
6666

67-
total nothingNotJust : {x : t} -> (Nothing {a = t} = Just x) -> _|_
67+
total nothingNotJust : {x : t} -> (Nothing {a = t} = Just x) -> Void
6868
nothingNotJust Refl impossible
6969

7070
instance (DecEq t) => DecEq (Maybe t) where
@@ -79,7 +79,7 @@ instance (DecEq t) => DecEq (Maybe t) where
7979
-- Either
8080
--------------------------------------------------------------------------------
8181

82-
total leftNotRight : {x : a} -> {y : b} -> Left {b = b} x = Right {a = a} y -> _|_
82+
total leftNotRight : {x : a} -> {y : b} -> Left {b = b} x = Right {a = a} y -> Void
8383
leftNotRight Refl impossible
8484

8585
instance (DecEq a, DecEq b) => DecEq (Either a b) where
@@ -96,7 +96,7 @@ instance (DecEq a, DecEq b) => DecEq (Either a b) where
9696
-- Fin
9797
--------------------------------------------------------------------------------
9898

99-
total FZNotFS : {f : Fin n} -> FZ {k = n} = FS f -> _|_
99+
total FZNotFS : {f : Fin n} -> FZ {k = n} = FS f -> Void
100100
FZNotFS Refl impossible
101101

102102
instance DecEq (Fin n) where
@@ -111,16 +111,16 @@ instance DecEq (Fin n) where
111111
-- Tuple
112112
--------------------------------------------------------------------------------
113113

114-
lemma_both_neq : {x : a, y : b, x' : c, y' : d} -> (x = x' -> _|_) -> (y = y' -> _|_) -> ((x, y) = (x', y') -> _|_)
114+
lemma_both_neq : {x : a, y : b, x' : c, y' : d} -> (x = x' -> Void) -> (y = y' -> Void) -> ((x, y) = (x', y') -> Void)
115115
lemma_both_neq p_x_not_x' p_y_not_y' Refl = p_x_not_x' Refl
116116

117-
lemma_snd_neq : {x : a, y : b, y' : d} -> (x = x) -> (y = y' -> _|_) -> ((x, y) = (x, y') -> _|_)
117+
lemma_snd_neq : {x : a, y : b, y' : d} -> (x = x) -> (y = y' -> Void) -> ((x, y) = (x, y') -> Void)
118118
lemma_snd_neq Refl p Refl = p Refl
119119

120120
lemma_fst_neq_snd_eq : {x : a, x' : b, y : c, y' : d} ->
121-
(x = x' -> _|_) ->
121+
(x = x' -> Void) ->
122122
(y = y') ->
123-
((x, y) = (x', y) -> _|_)
123+
((x, y) = (x', y) -> Void)
124124
lemma_fst_neq_snd_eq p_x_not_x' Refl Refl = p_x_not_x' Refl
125125

126126
instance (DecEq a, DecEq b) => DecEq (a, b) where
@@ -137,16 +137,16 @@ instance (DecEq a, DecEq b) => DecEq (a, b) where
137137
-- List
138138
--------------------------------------------------------------------------------
139139

140-
lemma_val_not_nil : {x : t, xs : List t} -> ((x :: xs) = Prelude.List.Nil {a = t} -> _|_)
140+
lemma_val_not_nil : {x : t, xs : List t} -> ((x :: xs) = Prelude.List.Nil {a = t} -> Void)
141141
lemma_val_not_nil Refl impossible
142142

143-
lemma_x_eq_xs_neq : {x : t, xs : List t, y : t, ys : List t} -> (x = y) -> (xs = ys -> _|_) -> ((x :: xs) = (y :: ys) -> _|_)
143+
lemma_x_eq_xs_neq : {x : t, xs : List t, y : t, ys : List t} -> (x = y) -> (xs = ys -> Void) -> ((x :: xs) = (y :: ys) -> Void)
144144
lemma_x_eq_xs_neq Refl p Refl = p Refl
145145

146-
lemma_x_neq_xs_eq : {x : t, xs : List t, y : t, ys : List t} -> (x = y -> _|_) -> (xs = ys) -> ((x :: xs) = (y :: ys) -> _|_)
146+
lemma_x_neq_xs_eq : {x : t, xs : List t, y : t, ys : List t} -> (x = y -> Void) -> (xs = ys) -> ((x :: xs) = (y :: ys) -> Void)
147147
lemma_x_neq_xs_eq p Refl Refl = p Refl
148148

149-
lemma_x_neq_xs_neq : {x : t, xs : List t, y : t, ys : List t} -> (x = y -> _|_) -> (xs = ys -> _|_) -> ((x :: xs) = (y :: ys) -> _|_)
149+
lemma_x_neq_xs_neq : {x : t, xs : List t, y : t, ys : List t} -> (x = y -> Void) -> (xs = ys -> Void) -> ((x :: xs) = (y :: ys) -> Void)
150150
lemma_x_neq_xs_neq p p' Refl = p Refl
151151

152152
instance DecEq a => DecEq (List a) where
@@ -203,7 +203,7 @@ instance DecEq Int where
203203
decEq x y = if x == y then Yes primitiveEq else No primitiveNotEq
204204
where primitiveEq : x = y
205205
primitiveEq = believe_me (Refl {x})
206-
postulate primitiveNotEq : x = y -> _|_
206+
postulate primitiveNotEq : x = y -> Void
207207

208208
--------------------------------------------------------------------------------
209209
-- Char
@@ -213,7 +213,7 @@ instance DecEq Char where
213213
decEq x y = if x == y then Yes primitiveEq else No primitiveNotEq
214214
where primitiveEq : x = y
215215
primitiveEq = believe_me (Refl {x})
216-
postulate primitiveNotEq : x = y -> _|_
216+
postulate primitiveNotEq : x = y -> Void
217217

218218
--------------------------------------------------------------------------------
219219
-- Integer
@@ -223,7 +223,7 @@ instance DecEq Integer where
223223
decEq x y = if x == y then Yes primitiveEq else No primitiveNotEq
224224
where primitiveEq : x = y
225225
primitiveEq = believe_me (Refl {x})
226-
postulate primitiveNotEq : x = y -> _|_
226+
postulate primitiveNotEq : x = y -> Void
227227

228228
--------------------------------------------------------------------------------
229229
-- Float
@@ -233,7 +233,7 @@ instance DecEq Float where
233233
decEq x y = if x == y then Yes primitiveEq else No primitiveNotEq
234234
where primitiveEq : x = y
235235
primitiveEq = believe_me (Refl {x})
236-
postulate primitiveNotEq : x = y -> _|_
236+
postulate primitiveNotEq : x = y -> Void
237237

238238
--------------------------------------------------------------------------------
239239
-- String
@@ -243,6 +243,6 @@ instance DecEq String where
243243
decEq x y = if x == y then Yes primitiveEq else No primitiveNotEq
244244
where primitiveEq : x = y
245245
primitiveEq = believe_me (Refl {x})
246-
postulate primitiveNotEq : x = y -> _|_
246+
postulate primitiveNotEq : x = y -> Void
247247

248248

libs/prelude/Prelude/Basics.idr

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Prelude.Basics
33
import Builtins
44

55
Not : Type -> Type
6-
Not a = a -> _|_
6+
Not a = a -> Void
77

88
||| Identity function.
99
id : a -> a
@@ -55,5 +55,5 @@ data Dec : Type -> Type where
5555

5656
||| The case where the property holding would be a contradiction
5757
||| @ contra a demonstration that A would be a contradiction
58-
No : {A : Type} -> (contra : A -> _|_) -> Dec A
58+
No : {A : Type} -> (contra : A -> Void) -> Dec A
5959

libs/prelude/Prelude/Fin.idr

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ instance Eq (Fin n) where
2828
(==) _ _ = False
2929

3030
||| There are no elements of `Fin Z`
31-
FinZAbsurd : Fin Z -> _|_
31+
FinZAbsurd : Fin Z -> Void
3232
FinZAbsurd FZ impossible
3333

3434
FinZElim : Fin Z -> a
35-
FinZElim x = FalseElim (FinZAbsurd x)
35+
FinZElim x = void (FinZAbsurd x)
3636

3737
||| Convert a Fin to a Nat
3838
finToNat : Fin n -> Nat

0 commit comments

Comments
 (0)