mirror of
https://github.com/Jaxan/nominal-lstar.git
synced 2025-04-27 14:47:45 +02:00
Code: Implemented adding CEs as columns (Rivest Schapire variant?)
This commit is contained in:
parent
004e71ccd9
commit
7c0cdcf7c3
1 changed files with 17 additions and 6 deletions
23
src/Main.hs
23
src/Main.hs
|
@ -9,7 +9,7 @@ import Teacher
|
|||
|
||||
import NLambda
|
||||
|
||||
import Data.List (inits)
|
||||
import Data.List (inits, tails)
|
||||
import Prelude hiding (and, curry, filter, lookup, map, not,
|
||||
sum, uncurry)
|
||||
|
||||
|
@ -53,9 +53,6 @@ instance (Conditional a) => Conditional (IO a) where
|
|||
-- (Same holds for many other functions here)
|
||||
makeCompleteConsistent :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> IO (State i)
|
||||
makeCompleteConsistent teacher state@State{..} = do
|
||||
putStrLn ""
|
||||
print state
|
||||
putStrLn ""
|
||||
-- inc is the set of rows witnessing incompleteness, that is the sequences
|
||||
-- 's1 a' which do not have their equivalents of the form 's2'.
|
||||
let inc = incompleteness state
|
||||
|
@ -106,8 +103,8 @@ constructHypothesis State{..} = automaton q a d i f
|
|||
toform s = forAll id . map fromBool $ s
|
||||
|
||||
-- Extends the table with all prefixes of a set of counter examples.
|
||||
useCounterExample :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> Set [i] -> IO (State i)
|
||||
useCounterExample teacher state@State{..} ces = do
|
||||
useCounterExampleAngluin :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> Set [i] -> IO (State i)
|
||||
useCounterExampleAngluin teacher state@State{..} ces = do
|
||||
putStr "Using ce: "
|
||||
print ces
|
||||
let ds = sum . map (fromList . inits) $ ces
|
||||
|
@ -116,6 +113,20 @@ useCounterExample teacher state@State{..} ces = do
|
|||
let state2 = addRows teacher ds state
|
||||
return state2
|
||||
|
||||
-- I am not quite sure whether this variant is due to Rivest & Schapire or Maler & Pnueli.
|
||||
useCounterExampleRS :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> Set [i] -> IO (State i)
|
||||
useCounterExampleRS teacher state@State{..} ces = do
|
||||
putStr "Using ce: "
|
||||
print ces
|
||||
let de = sum . map (fromList . tails) $ ces
|
||||
putStr " -> Adding columns: "
|
||||
print de
|
||||
let state2 = addColumns teacher de state
|
||||
return state2
|
||||
|
||||
useCounterExample :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> Set [i] -> IO (State i)
|
||||
useCounterExample = useCounterExampleRS
|
||||
|
||||
-- The main loop, which results in an automaton. Will stop if the hypothesis
|
||||
-- exactly accepts the language we are learning.
|
||||
loop :: (Show i, Contextual i, NominalType i, Teacher t i) => t -> State i -> IO (Automaton (BRow i) i)
|
||||
|
|
Loading…
Add table
Reference in a new issue