ajayv
ajayv

Reputation: 703

How to write this in agda?

I wanted to implement this statement in agda ;

A dedekind cut is a pair (L, U) of mere predicates L : Q -> Set and R : Q -> Set which is 
 1) inhibited : exists (q : Q) . L(q) ^ exists (r : Q) . U(r)

I have tried in this way,

record cut : Set where
   field 
      L : Q -> Set
      R : Q -> Set 
      inhibited :  exists (q : Q) . L(q) ^ exists (r : Q) . U(r)

but this is not working. I want to write this and i am struck please help. And also what is the difference between 1)data R : Set and record R : Set and 2) data R : Set and data R : Q -> Set

Upvotes: 0

Views: 172

Answers (1)

glguy
glguy

Reputation: 1090

I don't know about defining the whole of the dedekind cut, though I did find your definition on page 369 of Homotopy Type Theory: Univalent Foundations of Mathematics.

Here is the syntax for defining what you asked about in your question in two forms, one using the standard library and one expanded out to show what it is doing.

open import Data.Product using (∃)

record Cut (Q : Set) : Set₁ where
  field
    L U : Q → Set  -- The two predicates
    L-inhabited : ∃ L
    U-inhabited : ∃ U

If we manually expand the definition of ∃ (exists) we have:

record Cut′ (Q : Set) : Set₁ where
  field
    L U : Q → Set  -- The two predicates
    q r : Q        -- Witnesses
    Lq  : L q      -- Witness satisfies predicate
    Ur  : U r      -- Witness satisfies predicate

Note that the record has type Set₁ due to the types of fields L and U.

Regarding your question about records and inductively defined data types, there are lots of differences. You might want to start with the wiki and ask more specific questions if you get stuck somewhere: Data, Records

Upvotes: 2

Related Questions