Skip to content

Commit a14a64b

Browse files
committedSep 9, 2021
Fix function convertToTuringMachine
1 parent bd2dc4d commit a14a64b

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
 

‎src/DebuggingTMTypes.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module DebuggingTMTypes where
44

55
import TuringMachine
6+
import TuringMachine.Optimization
67
import GrammarType
78

89
import Control.Monad (forM)
@@ -48,7 +49,7 @@ convertToTuringMachine tm@(DTM (DQuadruples quadruplesMap)) = do
4849
D symbol2 -> S <$> symbols' !? symbol2
4950
qt <- states' !? state2
5051
return ((qf, s), (sm, qt))
51-
return $ turingMachine (fromList quadruplesList) emptyC alphabet'
52+
return $ safeOptimize O1 $ turingMachine (fromList quadruplesList) emptyC alphabet'
5253

5354
getStates :: DebuggingTuringMachine -> IsoMap DebuggingState State
5455
getStates (DTM (DQuadruples qdrs)) = let

‎src/TM2SP.hs

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import TM2SP.Generators
1212
import TM2SP.Relations
1313
import TuringMachine
1414
import qualified SemigroupPresentation as SP
15+
import ShowInfo
1516

1617
tm2sp ::
1718
MonadFail m =>
@@ -78,6 +79,11 @@ semigroupGamma =
7879

7980
newtype SemigroupPresentation_1 = SP1 { unSP1 :: SP.SemigroupPresentation }
8081

82+
instance ShowInfo (SemigroupPresentation_1) where
83+
showTitle = const $ Title "Semigroup Presentation"
84+
showInfo (SP1 sp) = showInfo sp
85+
showListTitle = const $ Title "List of Semigroup Presentations"
86+
8187
semigroupGamma_1 :: MonadFail m => TuringMachine -> m SemigroupPresentation_1
8288
semigroupGamma_1 =
8389
(fmap.fmap) SP1 $ tm2sp [

‎src/TuringMachine/Interpreter.hs

+19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module TuringMachine.Interpreter (
88
initWS,
99
run,
1010
smartRun,
11+
superSmartRun,
1112
module TuringMachine.Interpreter.Tape,
1213
module TuringMachine,
1314
) where
@@ -58,3 +59,21 @@ smartRun tm ws =
5859
if qf == qt && S s == sm
5960
then [ws, ws']
6061
else ws : smartRun tm ws'
62+
63+
superSmartRun ::
64+
MonadFail m =>
65+
TuringMachine ->
66+
WorkingState ->
67+
m [WorkingState]
68+
superSmartRun tm ws =
69+
case step tm ws of
70+
Nothing ->
71+
if ws^.currentState == finalState
72+
then return [ws]
73+
else fail "Can't find step from non-final state"
74+
Just (((qf, s), (sm, qt)), ws') ->
75+
if qf == qt && S s == sm
76+
then return [ws, ws']
77+
else do
78+
wss <- superSmartRun tm ws'
79+
return (ws : wss)

0 commit comments

Comments
 (0)
Please sign in to comment.