-
Notifications
You must be signed in to change notification settings - Fork 235
Different types of equality in F*
Catalin Hritcu edited this page Mar 26, 2020
·
12 revisions
F* has 3 different types of equality:
val (=) : #a:Type{hasEq a} -> a -> a -> Tot bool
val (==) : #a:Type -> a -> a -> Tot Type0
val (===): #a:Type -> #b:Type -> a -> b -> Tot Type0
Here is what each of them means:
-
=
is boolean equality that is automatically generated by F* for many types with decidable equality; such types satisfy thehasEq
predicate. By default every inductive datatype and records have decidable equality generated by F* unless thenoeq
qualifier has been explicitly set. The standard library also defines the useful aliaseqtype
asa:Type{hasEq a}
. -
==
is homogeneous propositional equality, and is defined for all F* types, even the ones withouthasEq
(==
is defined inprims.fst
as a squashed inductive and further documented here) -
===
is heterogeneous propositional equality; this more exotic equality is sometimes called "John Major equality" (===
is defined inprims.fst
as a squashed inductive)
Corresponding to the equalities, there are also the corresponding disequalities :
-
x <> y
is equivalent tonot (x = y)
(the decidable boolean valued disequality) -
x =!= y
is equivalent to~(x == y)
(the logical, homogeneous disequality)