this post was submitted on 28 Mar 2024
33 points (100.0% liked)

Programming

17443 readers
151 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

While reading Sipser's book on theory of computation, it relies heavily on the concept of formal language, and machines that merely accept or reject an input.

But most useful programs we deal with do more than merely verify an input. They compute something. We may compute a solution for an equation instead of merely verify it. We may sum a list of numbers, or calculate some function on it.

Maybe "most" is an exaggeration since I can't prove it. But still, it begs the question. Why not deal with machines than do more than merely verify?

you are viewing a single comment's thread
view the rest of the comments
[–] KindaABigDyl@programming.dev 6 points 7 months ago* (last edited 7 months ago)

Here's how I think it works

In formal language, what it means to accept a verification means does the result fall into the list of acceptable values.

Consider adding two 2-bit numbers:

  • Alphabet: { 0, 1}
  • Language: { x | x consists of four binary digits representing two 2-bit binary numbers where the result of adding these two numbers is a valid 2-bit binary number (i.e. falls between 00 and 11) }
  • Then you have an automata that will:
    • Start from the rightmost bit
    • Add the corresponding bits (+ carry from any previous iterations)
    • Carry over to the left if needed
    • Repeat for both bits
    • Check for acceptance
  • Machine as a whole simply checks did the inputs produce a valid 2-bit number, so it just accepts or rejects

The machine itself simply holds this automata and language, so all it does is take input and reject/accept end state. I think you're just getting caught up in definitions

A sum of a list of numbers I think would be something like

  • Alphabet: digits 0-9 and ','
  • Language: a single string of digits or a single string of digits followed by a comma and another valid string
  • Automata:
    • Are we a single string of digits? If yes, accept
    • Sum the last number into the first and remove the comma
    • Repeat
  • Machine: Does the some operation result in a valid string?

Machines accept a valid state or hit an error state (accept/reject). The computation happens between the input and accept/reject.

But maybe I don't understand it either. It's been a while since I poked around at this stuff.