Acme::HaltingProblem - A program to decide whether a given program halts


Acme-HaltingProblem documentation Contained in the Acme-HaltingProblem distribution.

Index


Code Index:

NAME

Top

Acme::HaltingProblem - A program to decide whether a given program halts

SYNOPSIS

Top

	use Acme::HaltingProblem;
	my $problem = new Acme::HaltingProblem(
		Machine	=> sub { ... },
		Input	=> [ ... ],
			);
	my $solution = $problem->solve();

DESCRIPTION

Top

The Halting Problem is one of the hardest problems in computing. The problem, approximately stated, is thus:

	Given an arbitrary Turing Machine T and input for that turing
	machine D, decide whether the computation T(D) will terminate.

new Acme::HaltingProblem(...)

Construct a new instance of the halting problem where the Machine is given as an arbitrary subref, and the Input is a reference to a list of arguments.

$problem->analyse()

Analyse the instance of the halting problem. If it halts, the method will return 1. Otherwise, it will not return 1.

BUGS

Top

This code does not correctly deal with the case where the machine does not halt.

TODO

Top

It would be nice if this module accepted instances of Acme::Turing.

SUPPORT

Top

Mail the author at <cpan@anarres.org>

AUTHOR

Top

	Shevek
	CPAN ID: SHEVEK
	cpan@anarres.org
	http://www.anarres.org/projects/

COPYRIGHT

Top


Acme-HaltingProblem documentation Contained in the Acme-HaltingProblem distribution.

package Acme::HaltingProblem;

use strict;
use vars qw($VERSION);

$VERSION = "1.00";

sub new {
	my $class = shift;
	my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ };
	die "No code provided for analysis" unless $self->{Machine};
	$self->{Input} = [ ] unless ref($self->{Input}) eq 'ARRAY';
	return bless $self, $class;
}

sub analyse {
	my $self = shift;
	eval { $self->{Machine}->(@{ $self->{Input} }); };
	return 1;
}