algorithms – Does H correctly decide that P (source-code provided) never halts?

Does H correctly decide that P never halts?
(The C/x86 source-code for P is provided below)

The only thing that we need to know about H is that it continues to simulate its input with an x86 emulator until the behavior of this input matches a non-halting behavior pattern. If a non-halting behavior pattern is matched H aborts its input and returns 0 for non-halting input. Otherwise H remains a pure x86 emulator and returns 1 for halting when its input terminates.

The x86utm operating system was created so that the halting problem could be examined concretely in the high level language of C. UTM tape elements are 32-bit unsigned integers. H is a function written in C that analyzes the x86 machine language of other functions written in C. H is able to recognize simple cases of infinite recursion and infinite loops.

// Simplified Linz Ĥ (Linz:1990:319)
void P(u32 x)
{
  if (H(x, x))
    HERE: goto HERE;
}

int main()
{
  Output("Input_Halts = ", H((u32)P, (u32)P));
}

H acts as a pure x86 simulator until its input demonstrates non-halting behavior. It is common knowledge that when-so-ever the pure simulation of the machine description of a machine never halts on its input that this logically entails that this machine never halts on its input. This proves that H uses the same halting criteria as the halting problem.

Because H acts as a pure simulator of its input until after it makes its halt status decision we know that the behavior of H cannot possibly have any effect on the behavior of P thus the behavior of H can be totally ignored in any halt status decision.

Using the above reasoning we can know that when the x86 execution trace of P on input P shows that there is no code in P that escapes the infinitely nested simulation of P on input P, then we know that P on input P meets the definition of a computation that never halts: (a pure simulation that never halts).

_P()
(00000c36)(01)  55          push ebp
(00000c37)(02)  8bec        mov ebp,esp
(00000c39)(03)  8b4508      mov eax,(ebp+08)
(00000c3c)(01)  50          push eax
(00000c3d)(03)  8b4d08      mov ecx,(ebp+08)
(00000c40)(01)  51          push ecx
(00000c41)(05)  e820fdffff  call 00000966
(00000c46)(03)  83c408      add esp,+08
(00000c49)(02)  85c0        test eax,eax
(00000c4b)(02)  7402        jz 00000c4f
(00000c4d)(02)  ebfe        jmp 00000c4d
(00000c4f)(01)  5d          pop ebp
(00000c50)(01)  c3          ret
Size in bytes:(0027) (00000c50)

_main()
(00000c56)(01)  55          push ebp
(00000c57)(02)  8bec        mov ebp,esp
(00000c59)(05)  68360c0000  push 00000c36
(00000c5e)(05)  68360c0000  push 00000c36
(00000c63)(05)  e8fefcffff  call 00000966
(00000c68)(03)  83c408      add esp,+08
(00000c6b)(01)  50          push eax
(00000c6c)(05)  6857030000  push 00000357
(00000c71)(05)  e810f7ffff  call 00000386
(00000c76)(03)  83c408      add esp,+08
(00000c79)(02)  33c0        xor eax,eax
(00000c7b)(01)  5d          pop ebp
(00000c7c)(01)  c3          ret
Size in bytes:(0039) (00000c7c)

Execution Trace of H(P,P)

 machine   stack     stack     machine    assembly 
 address   address   data      code       language
 ========  ========  ========  =========  =============
(00000c56)(0010172a)(00000000) 55         push ebp
(00000c57)(0010172a)(00000000) 8bec       mov ebp,esp
(00000c59)(00101726)(00000c36) 68360c0000 push 00000c36 
(00000c5e)(00101722)(00000c36) 68360c0000 push 00000c36
(00000c63)(0010171e)(00000c68) e8fefcffff call 00000966

Begin Local Halt Decider Simulation at Machine Address:c36
(00000c36)(002117ca)(002117ce) 55         push ebp
(00000c37)(002117ca)(002117ce) 8bec       mov ebp,esp
(00000c39)(002117ca)(002117ce) 8b4508     mov eax,(ebp+08)
(00000c3c)(002117c6)(00000c36) 50         push eax      // push P
(00000c3d)(002117c6)(00000c36) 8b4d08     mov ecx,(ebp+08)
(00000c40)(002117c2)(00000c36) 51         push ecx      // push P
(00000c41)(002117be)(00000c46) e820fdffff call 00000966 // call H
(00000c36)(0025c1f2)(0025c1f6) 55         push ebp
(00000c37)(0025c1f2)(0025c1f6) 8bec       mov ebp,esp
(00000c39)(0025c1f2)(0025c1f6) 8b4508     mov eax,(ebp+08)
(00000c3c)(0025c1ee)(00000c36) 50         push eax      // push P
(00000c3d)(0025c1ee)(00000c36) 8b4d08     mov ecx,(ebp+08)
(00000c40)(0025c1ea)(00000c36) 51         push ecx      // push P
(00000c41)(0025c1e6)(00000c46) e820fdffff call 00000966 // call H
Local Halt Decider: Infinite Recursion Detected Simulation Stopped 

In the above 14 instructions of the simulation of P(P) we can see that the first 7 instructions of P are repeated. The end of this sequence of 7 instructions P calls H with its own machine address as the parameters to H: H(P,P). Because H only examines the behavior of its inputs and ignores its own behavior when H(P,P) is called we only see the first instruction of P being simulated.

Anyone knowing the x86 language well enough can see that none of these 7 simulated instructions of P have any escape from their infinitely repeating behavior pattern. When H recognizes this infinitely repeating pattern it aborts its simulation of P(P) and reports that its input: (P,P) would never halt on its input.

(00000c68)(0010172a)(00000000) 83c408      add esp,+08
(00000c6b)(00101726)(00000000) 50          push eax
(00000c6c)(00101722)(00000357) 6857030000  push 00000357
(00000c71)(00101722)(00000357) e810f7ffff  call 00000386
Input_Halts = 0
(00000c76)(0010172a)(00000000) 83c408      add esp,+08
(00000c79)(0010172a)(00000000) 33c0        xor eax,eax
(00000c7b)(0010172e)(00100000) 5d          pop ebp
(00000c7c)(00101732)(00000068) c3          ret
Number_of_User_Instructions(27)
Number of Instructions Executed(23721)

I have provided:
(a) the assembly language source-code for P,
(b) the x86 execution trace of P,
(c) stated that H only acts as a pure x86 emulator until after its makes its halt status decision.

It should be clear from the execution trace of P that P is stuck in infinitely nested simulation. The same 8 instructions are repeated and these instructions have no escape from their infinite repetition.

To eliminate the pathological self-reference(polcott 2004) from the halting problem such that there is no feedback loop between what the halt decider decides and how the input behaves the simulating halt decider simply watches what the input does without interfering at all.

As soon as the simulating halt decider determines that the simulation of the input on its input would never halt (the conventional definition of non-halting) it aborts the simulation of its inputs and reports that its input does not halt.

algorithms – Does H correctly decide that P never halts?

Does H correctly decide that P never halts?

The x86utm operating system was created so that the halting problem could be examined concretely in the high level language of C. UTM tape elements are 32-bit unsigned integers. H is a function written in C that analyzes the x86 machine language of other functions written in C. H is able to recognize simple cases of infinite recursion and infinite loops.

H simulates its input with an x86 emulator until it determines that its input would never halt. As soon as H recognizes that its input would never halt it stops simulating this input and returns 0. For inputs that do halt H acts exactly as if it was an x86 emulator and simply runs its input to completion and then returns 1.

// Simplified Linz Ĥ (Linz:1990:319)
void P(u32 x)
{
  u32 Input_Halts = H(x, x);
  if (Input_Halts)
    HERE: goto HERE;
}

int main()
{
  u32 Input_Halts = H((u32)P, (u32)P);
  Output("Input_Halts = ", Input_Halts);
}

When the simulation of the Turing machine description ⟨P⟩ of a Turing machine P on input I never halts we know that P(I) never halts.

Simulating halt deciders must abort their simulation of all inputs where the pure simulation of this input would never halt.

Simulating halt deciders act as a pure simulators of their input until this input demonstrates non-halting behavior.

This allows simulating halt deciders to totally ignore their own behavior in making their halt status decision.

It is this feature of the adapted halt deciding criteria that eliminates the pathological self-reference (polcott 2004) from the halting problem counter-example templates.

Simulating halt deciders never have behavior that effects their halt status decision because they only act as pure simulators until after they have made this decision.

Using the above reasoning we can know that when the x86 execution trace of P on input P shows that there is no code in P that escapes the infinitely nested simulation of P on input P, then we know that P on input P meets the definition of a computation that never halts: (a pure simulation that never halts).

moderation – Why Moderator will decide what is displayed in community forum?

I have just recently added a comment on a question that was something related to the problem I was facing. And then someone (so-called moderator) flagged the question saying it is like a commentary or question over a question. And it was hidden.
Though he was kind of right in saying that question was a question. But I have a problem here.
Moderators have full control over what will be displayed here in the community. And I am not getting any chance to explain anything. Which I think should not be the case in open community forums like this. Instead of moderators, they seem like a dictator.
So I will explain a reason here why I have added a comment over a comment.

Recently WordPress Gutenberg has released something which is still in kind of beta version and not lot of people have tried it. I tried searching for questions or comment related to the problem but could not find. And finally, I found a question that was something related to my problem. And even in that question, answer was given by the same person who has raised the question. It clearly shows that it’s hard to get an answer, as not a lot of people have tried this thing.
That is the reason instead of asking a new question in the forum I raised a question inside question as he might be having the first-hand answer to the question.

Would like to hear some words from the moderator. Or maybe they can block this question too. And I am not new to these community forums it’s just I have recently switched to WordPress.

Regards

Need help to decide of domain move reversal after 5 months!

Hello, first sorry for my bad english,it isn't my first lanugage.
I have a website with 13 years of history and activity. 5 Months ago we received an warning message from our domain provider which would seize our domain because of sanctions (i live in Iran), and they have seized many of iranian domains since then, therefore i have decided to quickly change my domain to another address so i could save my website as much as possible before they take out my domain…
I have moved my website…

Need help to decide of domain move reversal after 5 months!

javascript – Should state and behavior be combined for Buffs? Cannot decide between data-driven and OOP approach

I’m writing a 2D roguelike that uses an Entity Component System and I’m having trouble deciding between the traditional OOP approach versus a data-driven approach to implementing buffs and debuffs. For the purposes of this question, I’ve created two examples (Option A and Option B) to demonstrate the differences.

Option A is the data-driven approach where the data and functionality / behavior for the buffs are separated and we maintain a mapping from buff name to corresponding execute function to link them up.

Meanwhile, Option B just uses the standard OOP approach where buff state and behavior is combined into a single subclass.

Option A:

// Buffs Data File:
let buffs = {
  regeneration: {
    name: "Regeneration",
    description: "Provides some amount of passive regen",
    applyRate: 1000
  },
  snare: {
    name: "Snare",
    description: "Slows the entity by some amount",
    duration: 3000,
    textureName: "items",
    textureFrame = { x: 64, y: 384, w: 32, h: 32 }
  },
  fleeing: {
    name: "Fleeing",
    description: "This unit is running for its life",
    duration: 1000,
    applyRate: 1000
  }
};


// Buffs System
function executeFleeing(scene: Scene, receiver: Entity) {
  let physics = receiver.get(CT.Physics);
  if (!physics) { return; }

  physics.maxSpeed.buffed *= .5;
}

function executeSnare(scene: Scene, receiver: Entity) {
  let physics = receiver.get(CT.Physics);
  if (!physics) { return; }

  physics.maxSpeed.buffed *= 10;
}

function executeRegeneration(scene: Scene, entity: Entity) {
  let health = entity.get(CT.Health);
  if (!health) { return; }

  health.add(5);
}

let mapping = {
  Fleeing: executeFleeing,
  Snare: executeSnare,
  Regeneration: executeRegeneration
};

execute() {
  for (let entity of this.scene.query(CT.Buffs)) {      
    let buffs = entity.get(CT.Buffs);

    for (let b of buffs.list) {
      let buffName = b(0);
      let buff = b(1);

      if (!buff.isActive()) { buffs.list.delete(buffName); continue; }

      if (!buff.elapsed()) { continue; }
      
      buffs.get(buffName).lastTick = performance.now();

      mapping(buffName)(this.scene, entity);
    }
  }
}

Option B:

// Date files
class RegenerationBuff extends Buff {
  constructor() {
    super();
    
    this.name = "Regeneration";
    this.description = "Provides some amount of passive regen";

    this.applyRate = 1000;
  }

  execute(scene: Scene, entity: Entity) {
    let health = entity.get(CT.Health);
    if (!health) { return; }

    health.add(5);
  }
}

class SnareBuff extends Buff {
  constructor() {
    super();
    
    this.name = "Snare";
    this.description = "Slows the entity by some amount";

    this.duration = 3000;
    
    this.textureName = "items";
    this.textureFrame = new Frame(64, 384, 32, 32);
  }

  execute(scene: Scene, receiver: Entity) {
    let physics = receiver.get(CT.Physics);
    if (!physics) { return; }

    physics.maxSpeed.buffed *= 10;
  }
}

class RegenerationBuff extends Buff {
  constructor() {
    super();
    
    this.name = "Regeneration";
    this.description = "Provides some amount of passive regen";

    this.applyRate = 1000;
  }

  execute(scene: Scene, entity: Entity) {
    let health = entity.get(CT.Health);
    if (!health) { return; }

    health.add(5);
  }
}


// Buffs System
execute() {
  for (let entity of this.scene.query(CT.Buffs)) {      
    let buffs = entity.get(CT.Buffs);

    for (let b of buffs.list) {
      let buffName = b(0);
      let buff = b(1);

      if (!buff.isActive()) { buffs.list.delete(buffName); continue; }

      if (!buff.elapsed()) { continue; }
      
      buff.lastTick = performance.now();

      buff.execute(this.scene, entity);
    }
  }
}

Option A seems to generally be the recommended paradigm of operation within an ECS (separate state and behavior), but I’m not sure if that would apply to non-components as well. In addition, Option A seems like it could be more performant since entities would only need to maintain a list of buff names rather than instantiate a new buff object every time we want to add one to an entity. This is because the data for the buffs already exists in the data-driven approach, so each entity doesn’t need to duplicate the information.

However, Option B has the advantage in that it is conceptually simpler, and finding and editing a buff should be quicker, as all of the relevant information (data and behavior) is in a single place, in a single file. In addition, we don’t have to maintain an object mapping that maps from buff name to buff execute function, as it is all contained within the object.

Which option is preferable? Which one would you choose?

network flow – Decide if the edges of a mixed graph can be directed in order to be an Eulerian Graph

I’m very stuck with this problem. Given $G = (V, E, A)$ a mixed graph where every edge in $E$ is directed and every edge in $A$ is undirected. Thinking as a max-flow problem, decide if it’s possible to give a direction to every $a in A$ in order to make $G$ an $eulerian$ graph.

The model I’ve thinking so far is to translate the problem as a matching problem. For every non directed edge, I would like to determine to which node this will point. For example, if $e=(u,v)$, from the vertex source there should be an edge connecting to $e$ and this one will be connected to $u$ and $v$. Every edge will have a flow capacity of 1, except for the edges of the target, which will have a capacity of $?$. I don’t know if this model it’s okay, but any clue (or another model) will help, thanks!

pathfinder 1e – When do you decide variable material components for Restoration in a ring of spell storing?

The Ring of Spell Storing allows you to store any spell by casting it into the ring as the spell would normally be cast, presumably expending any material components required at this time as general rules.

A spellcaster can cast any spells into the ring, so long as the total spell levels do not add up to more than 5.

It is also clear that no material components are expended when casting spells from the ring.

The user need not provide any material components or focus to cast the spell…

However, some spells such as Restoration require a variable material component cost depending on decisions made when the spell is cast.

Components V, S, M (diamond dust worth 100 gp or 1,000 gp, see text)

This spell functions like lesser restoration, except that it also dispels temporary negative levels or one permanent negative level. If this spell is used to dispel a permanent negative level, it has a material component of diamond dust worth 1,000 gp.

What price diamond dust is used to store and cast Restoration in the ring and when is it expended?
Can you choose to expend the 1000gp diamond dust and then not dispel a permanent negative level?