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 9038295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:27:14+00:00 2026-06-16T09:27:14+00:00

I would like to somehow limit what kind of inputs constructors are allowed to

  • 0

I would like to somehow limit what kind of inputs constructors are allowed to take in an inductive definition. Say I want to say define binary numbers as follows:

Inductive bin : Type :=
  | O : bin
  | D : bin -> bin
  | S : bin -> bin.

The idea here is that D doubles up a nonzero number by adding a zero at the end and S takes a number with zero as the last digit and turns the last digit into a one. This means that the following are legal numbers:

S 0
D (S 0)
D (D (S 0))

while the following would not be:

S (S 0)
D 0

Is there a way to enforce such restrictions in an inductive definition in a clean way?

  • 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-06-16T09:27:15+00:00Added an answer on June 16, 2026 at 9:27 am

    You could define what it means for a bin to be legal with a predicate, and then give a name to the subset of bins that obey that predicate. Then you write functions with Program Definition and Program Fixpoint instead of Definition and Fixpoint. For recursive functions you’ll also need a measure to prove the arguments of your functions decrease in size since the functions are not structurally recursive anymore.

    Require Import Coq.Program.Program.
    
    Fixpoint Legal (b1 : bin) : Prop :=
      match b1 with
      | O       => True
      | D O     => False
      | D b2    => Legal b2
      | S (S _) => False
      | S b2    => Legal b2
      end.
    
    Definition lbin : Type := {b1 : bin | Legal b1}.
    
    Fixpoint to_un (b1 : bin) : nat :=
      match b1 with
      | O    => 0
      | D b2 => to_un b2 + to_un b2
      | S b2 => Coq.Init.Datatypes.S (to_un b2)
      end.
    
    Program Definition zer (b1 : lbin) := O.
    
    Program Fixpoint succ (b1 : lbin) {measure (to_un b1)} : lbin :=
    

    But this simply-typed approach would probably be easier.

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

Sidebar

Related Questions

I have some hidden inputs like this <input name=exam.normals[1].blahblah ..../> I would like somehow
I have a static method in my code that I would like somehow to
My question is a NodeJS newbie question. I would like to somehow detect if
I would like to avoid the if statement below. Can I somehow copy the
Using a Google Chrome Extension, I would like to fire some event or somehow
Would like someone to take a look at my script and tell me where
I'm using EntityFramework database first in an application. I would like somehow to be
I would like to somehow inject all HttpMessageConverter instances registered in Spring-MVC. I can
I would like to define a function which returns the string NaN or sprintf(%g,val)
I would like to somehow feed by camera feed through a web service /

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.