Zulip Chat Archive

Stream: Is there code for X?

Topic: finite set with default representation


Paige Thomas (May 27 2024 at 03:12):

Is there a type of finite set that has a builtin default representation, such as a requirement that the elements can be sorted and a representation of them as a sorted list?

Paige Thomas (May 27 2024 at 04:32):

Perhaps Batteries.RBSet.

Johan Commelin (May 27 2024 at 06:18):

@Kayla Thomas Something like docs#Fintype ?

Johan Commelin (May 27 2024 at 06:18):

If you want to be able to sort the elements, you additionally need to assume something like LinearOrder

Yaël Dillies (May 27 2024 at 06:19):

docs#FinEnum ?

Paige Thomas (May 27 2024 at 06:29):

I'm not sure. I'm trying to replace the Lists here in this representation of finite state automata with something equivalent to a finite set, but that is computable and displayable.

structure SymbolStepMultiple
  (α : Type)
  [DecidableEq α]
  (σ : Type)
  [DecidableEq σ] :
  Type :=
  (start_state : σ)
  (symbol : α)
  (stop_state_list : List σ)
  deriving Repr


structure EpsilonStepMultiple
  (σ : Type)
  [DecidableEq σ] :
  Type :=
  (start_state : σ)
  (stop_state_list : List σ)
  deriving Repr


structure EpsilonNFA
  (α : Type)
  [DecidableEq α]
  (σ : Type)
  [DecidableEq σ] :
  Type :=
  (symbol_step_list : List (SymbolStepMultiple α σ))
  (epsilon_step_list : List (EpsilonStepMultiple σ))
  (starting_state_list : List σ)
  (accepting_state_list : List σ)
  deriving Repr

Paige Thomas (May 27 2024 at 06:32):

That is, I want to be able to extract the result of evaluating it and display it.

Paige Thomas (May 27 2024 at 06:39):

I can do that with List, but trying to prove equivalence to a regular language isn't going so well, so trying to simplify it a bit.

Daniel Weber (May 27 2024 at 07:12):

Can't you define a representation for docs#Finset? Either have it unsafe, I'm not sure how that works, or assume some kind of order

Eric Wieser (May 27 2024 at 07:14):

Finset already has an (unsafe) representation, docs#Finset.instRepr

Paige Thomas (May 27 2024 at 07:19):

What are the implications of it being unsafe? Should I be worried about that?

Eric Wieser (May 27 2024 at 08:37):

It means you can't prove things about the string representation

Eric Wieser (May 27 2024 at 08:37):

If you want something safe, you can use docs#Finset.sort to get a list that you can print "safely"

Paige Thomas (May 27 2024 at 18:07):

I see. Thank you.


Last updated: May 02 2025 at 03:31 UTC