-
Notifications
You must be signed in to change notification settings - Fork 243
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 thehasEqpredicate. By default every inductive datatype and records have decidable equality generated by F* unless thenoeqqualifier has been explicitly set. The standard library also defines the useful aliaseqtypeasa:Type{hasEq a}. -
==is homogeneous propositional equality, and is defined for all F* types, even the ones withouthasEq(==is defined inprims.fstas a squashed inductive and further documented here) -
===is heterogeneous propositional equality; this more exotic equality is sometimes called "John Major equality" (===is defined inprims.fstas a squashed inductive)
Corresponding to the equalities, there are also the corresponding disequalities :
-
x <> yis equivalent tonot (x = y)(the decidable boolean valued disequality) -
x =!= yis equivalent to~(x == y)(the logical, homogeneous disequality)