Advise-me-0.1: Assessment services for the Advise-Me project

Maintainerbastiaan.heeren@ou.nl
Stabilityprovisional
Portabilityportable (depends on ghc)
Safe HaskellNone
LanguageHaskell98

Task.MagicTrick.Recognizer

Description

Here we implemented the diagnosis for the magictrick exercise

Synopsis

Documentation

whereDidWeGoWrong :: Evidence -> Evidence Source #

Postprocessing step on the found evidence: When there is no final answer, but there are intermediate steps, we boldly assume that the step after the last intermediate step was the culprit and we set its evidence to negative. If there were no intermediate steps, we set the first step of each strategy to negative.

fillInMissedSteps :: Evidence -> Evidence Source #

Postprocessing steps on the found evidence. When all the nodes on the LHS are present in the evidence but none on the RHS are, we set evidence to the nodes on the RHS. Note that it is evaluated left-to-right, so later steps should appear first.

pAttempts :: SEParser [Diagnosis] Source #

Tries to parse many attempts. If one fails then skip one input and try again until no input is left.

pStdDiagnosis :: SEParser Diagnosis Source #

Main diagnosis function.

First we guess some magic expression and then try to recognize the formula

task :: Expr -> [Op] Source #

pStepsFor :: Expr -> Expr -> [Op] -> SEParser (Expr, [Step]) Source #

Pipeline for recognition

The pipeline consists of 4 phases:

  • Parse correct steps
  • Parse a simplification step
  • Forget a step
  • A mistake was made. Try fixing the step

These phases are passed through linearly, but a phase may go back to phase 1 before reaching the latter phases.

pStepsPhase1 :: Expr -> Expr -> [Op] -> SEParser (Either (Expr, [Step], [Op]) (Expr, [Step], [Op])) Source #

pStepsPhase4 :: Expr -> Expr -> [Op] -> [Step] -> SEParser (Expr, [Step], [Op]) Source #

pTask Source #

Arguments

:: (Expr -> Expr -> [Op] -> SEParser (Expr, Step))

to use recognition strategy

-> Expr

magic expression

-> Expr

current expression

-> [Op]

remaining operators

-> SEParser (Either (Expr, [Step], [Op]) (Expr, [Step], [Op])) 

Expands the current formula with a different number of operators.

Then attempts are made to recognize this formula.

pTaskSimplify :: Expr -> Expr -> SEParser (Maybe (Expr, Step)) Source #

tries to match the current formula to some simplified form of that formula

pTaskForget :: Expr -> Expr -> [Op] -> [Step] -> SEParser (Expr, [Step], [Op]) Source #

It's possible some operation was forgotten to be added

pTaskErr :: Expr -> Expr -> [Op] -> SEParser (Maybe (Expr, Step, [Op])) Source #

See if an error was made given the next operation

pStepOperators Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, Step) 

pStepError Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, Step) 

pStepForget Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> Op

current step

-> Op

next step

-> SEParser (Expr, Step) 

pStep Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, [Attribute]) 

Parse a step

Equation step, expression step or some erronuous step

pBuggyStep Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, [Attribute]) 

pStepSimplify Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> SEParser (Expr, [Attribute]) 

pExplicitSimplifyEq Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> SEParser (Expr, [Attribute]) 

pExplicitSimplifyExpr Source #

Arguments

:: Expr

the current expression

-> SEParser (Expr, [Attribute]) 

pStepEquation Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, [Attribute]) 

pStepExpr Source #

Arguments

:: Expr

magic expression

-> Expr

the current expression

-> [Op]

list of operators to be added

-> SEParser (Expr, [Attribute]) 

pStepExpr probeert een expressie te parsen probeer eerst zonder normaliseren (maar modulo commassocdistr) probeer dan met normaliseren (dan telt de stap/berekening als impliciet) probeer dan met fout correctie.

splits :: [a] -> [([a], [a])] Source #

pIf :: Alternative f => Bool -> f a -> f a Source #

pFixEqCom Source #

Arguments

:: Equation Expr

expected

-> SEParser (Expr, [Attribute]) 

pMatchEq Source #

Arguments

:: Equation Expr

expected

-> Equation Expr

provided

-> SEParser (Expr, [Attribute]) 

pMatchExpr Source #

Arguments

:: Expr

expected

-> Expr

provided

-> SEParser (Expr, [Attribute]) 

pEqWithL :: (Expr -> (Expr, [Attribute])) -> Expr -> SEParser (Expr, [Attribute]) Source #

Compares the left arguments of two subsequent equations

A = 7 B = 7 C = 7

In this case B should be a simplification of A and C a simplification of B.

hasCommonality :: [Attribute] -> [Attribute] -> Bool Source #

Two expressions might simplify to the same expression, but their paths there are different.

This function will check that there was at least one common step in simplification.