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

  • SEARCH
  • Home
  • 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 6676035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:56:11+00:00 2026-05-26T03:56:11+00:00

Finite maps model substitutions with finite domains. I either need to emulate operations on

  • 0

Finite maps model substitutions with finite domains. I either need to emulate operations on substitutions with infinite domains, or find a suitable way to represent substitutions with infinite domains. For instance, consider the restriction operation on substitutions:

  • σ|e(xn) = if xn ∈ FV(e) then σ(xn) else xn

Because the restriction operation applies to all variables in a possibly infinite set, a data type like a finite map can’t “look forward” to anticipate the restriction when new bindings are added. And of course, using finite maps with infinite domains causes nontermination. Is there a way to simulate operations such as restriction using finite maps, or another representation of substitutions that would allow one to write operations like restriction over them easily? I feel I’m overlooking an obvious solution – for instance, taking advantage of lazy evaluation or functional substitutions.

edit:

For reference, here is a naive solution using finite maps. Each time the restriction operation is applied to a substitution σ and expression e, find the set FV(e) of free variables of e. For each variable xn in the domain of σ, if xn ∈ FV(e) then set σ'(xn) = xn. Return σ’. Assume that σ'(xn) = xn if xn ∉ dom(σ’).

edit: This is the obvious solution I overlooked.

  • 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-26T03:56:12+00:00Added an answer on May 26, 2026 at 3:56 am

    Well, the most direct model of a substitution is just a function itself.

    newtype Subst = Subst { apply :: Var -> Expr }
    
    singleton :: Var -> Expr -> Subst
    singleton v e = Subst (\v' -> if v == v' then e else Var v')
    -- etc.
    

    For a first pass at implementing a lanugage, this is probably what I would use as soon as finite maps broke down. It’s not fast (will require O(n) time when n is the size of the domain), but it’s simple. Keep it encapsulated so you can replace it later.

    If you start getting hit by the O(n) time, then you could switch to a trie. data-inttrie was specifically written to behave just like a function on integers but allow efficient modifications at single points (as one would want with a substitution function). If your variables are uniquely identified by integers you could use it directly, otherwise you could emulate the style for strings or whatever you are using.

    But it also seems odd to me that you would need to “look forward”. I have never needed this in my language implementations; if you add a new binding to a restricted substitution, the restriction does not apply to the new bindings (if it did, the semantics would be wrong). Finite maps have done the trick for all cases when I am not doing something absurdly weird (and those don’t usually pan out).

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

Sidebar

Related Questions

Suppose we have an iterator (an infinite one) that returns lists (or finite iterators),
I need to implement a finite-state-machine in order to keep track of a few
I need to draw an elliptic curve over the finite field F17(in other words,
I want to model a kind of FSM(Finite State Machine). I have a sequence
Can someone point to me where I can find Finite Element Delphi library. Preferably
Finite state machine A deterministic finite state machine is a simple computation model, widely
Given a finite dictionary of entity terms, I'm looking for a way to do
I need to generate a Deterministic Finite Automata (DFA), selected from all possible DFAs
I want a datatype to represent a finite set of integers that can be
I am trying to develop an object oriented representation of a finite element model.

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.