Models Dana Angluin’s Language Learner.

Example

Imports

import axle._
import axle.lx._
import Angluin._
import cats.implicits._

Setup

val mHi = Symbol("hi")
val mIm = Symbol("I'm")
val mYour = Symbol("your")
val mMother = Symbol("Mother")
val mShut = Symbol("shut")
val mUp = Symbol("up")

val Σ = Alphabet(Set(mHi, mIm, mYour, mMother, mShut, mUp))

val s1 = mHi :: mIm :: mYour :: mMother :: Nil
val s2 = mShut :: mUp :: Nil
val  = Language(s1 :: s2 :: Nil)

val T = Text(s1 ::  ::  :: s2 ::  :: s2 :: s2 :: Nil)

val ɸ = MemorizingLearner()

Usage

ɸ.guesses(T).
  find(_. === ).
  map(finalGuess => "well done, ɸ").
  getOrElse("ɸ never made a correct guess")
// res4: String = well done, ɸ

T
// res5: axle.lx.Angluin.Text = Text(List(List(Symbol(hi), Symbol(I'm), Symbol(your), Symbol(Mother)), List(), List(), List(Symbol(shut), Symbol(up)), List(), List(Symbol(shut), Symbol(up)), List(Symbol(shut), Symbol(up))))


// res6: axle.lx.Angluin.Language = Language(List(List(Symbol(hi), Symbol(I'm), Symbol(your), Symbol(Mother)), List(Symbol(shut), Symbol(up))))

T.isFor()
// res7: Boolean = false