module Functions.Functions_vs_Sets where open import Sets.Enumerated using (Bool; true; false)
Representation of negation as a relation between Bool
and Bool
:
data Not : Bool → Bool → Set where n₁ : Not true false n₂ : Not false true
This creates four new sets of which two are non-empty.
Not a b
is non-empty iff b
is the negated value of a
.
Recall the representation of negation as a function:
not : Bool → Bool not true = false not false = true
Relation's advantages:
Function's advantages:
not (not a)
instead of Not a b ∧ Not b c
Relations are good for describing the problem/question (specification).
Functions are good for describing the solution/answer (implementation).
Notes
Remark
An A → B → C
function corresponds to specification A → B → C → Set
according our previous remark. So _≤?_ : ℕ → ℕ → Bool
would correspond to ℕ → ℕ → Bool → Set
, but Boolean valued functions can be specified easier so we have _≤_ : ℕ → ℕ → Set
as specification.