Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 707741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:18:45+00:00 2026-05-14T04:18:45+00:00

I’m trying to encode some denotational semantics into Agda based on a program I

  • 0

I’m trying to encode some denotational semantics into Agda based on a program I wrote in Haskell.

data Value = FunVal (Value -> Value)
           | PriVal Int
           | ConVal Id [Value]
           | Error  String

In Agda, the direct translation would be;

data Value : Set where
    FunVal : (Value -> Value) -> Value
    PriVal : ℕ -> Value
    ConVal : String -> List Value -> Value
    Error  : String -> Value

but I get an error relating to the FunVal because;

Value is not strictly positive, because it occurs to the left of an
arrow in the type of the constructor FunVal in the definition of
Value.

What does this mean? Can I encode this in Agda? Am I going about it the wrong way?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:18:45+00:00Added an answer on May 14, 2026 at 4:18 am

    HOAS doesn’t work in Agda, because of this:

    apply : Value -> Value -> Value
    apply (FunVal f) x = f x
    apply _ x = Error "Applying non-function"
    
    w : Value
    w = FunVal (\x -> apply x x)
    

    Now, notice that evaluating apply w w gives you apply w w back again. The term apply w w has no normal form, which is a no-no in agda. Using this idea and the type:

    data P : Set where
        MkP : (P -> Set) -> P
    

    We can derive a contradiction.

    One of the ways out of these paradoxes is only to allow strictly positive recursive types, which is what Agda and Coq choose. That means that if you declare:

    data X : Set where
        MkX : F X -> X
    

    That F must be a strictly positive functor, which means that X may never occur to the left of any arrow. So these types are strictly positive in X:

    X * X
    Nat -> X
    X * (Nat -> X)
    

    But these are not:

    X -> Bool
    (X -> Nat) -> Nat  -- this one is "positive", but not strictly
    (X * Nat) -> X
    

    So in short, no you can’t represent your data type in Agda. You can use de Bruijn encoding to get a term type you can work with, but usually the evaluation function needs some sort of “timeout” (generally called “fuel”), e.g. a maximum number of steps to evaluate, because Agda requires all functions to be total. Here is an example due to @gallais that uses a coinductive partiality type to accomplish this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 365k
  • Answers 365k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the data in the /proc filesystem to… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer Do you still get the error when you use a… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer You can use array_chunk to create a single array comprised… May 14, 2026 at 3:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.