sbv-13.1: SMT Based Verification: Symbolic Haskell theorem prover using SMT solving.
Copyright(c) Levent Erkok
LicenseBSD3
Maintainererkokl@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Description

From Raymond Smullyan: On a fictional island, all inhabitants are either knights, who always tell the truth, or knaves, who always lie. John and Bill are residents of the island of knights and knaves. John and Bill make several utterances. Determine which one is a knave or a knight, depending on their answers.

Synopsis

Documentation

data Inhabitant Source #

Inhabitants of the island, as an uninterpreted sort

Instances

Instances details
Arbitrary Inhabitant Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

SymVal Inhabitant Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

HasKind Inhabitant Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

cv2Inhabitant :: String -> [CV] -> Inhabitant Source #

Conversion from SMT values to Inhabitant values.

_undefiner_Inhabitant :: a Source #

Autogenerated definition to avoid unused-variable warnings from GHC.

type SInhabitant = SBV Inhabitant Source #

Symbolic version of the type Inhabitant.

data Identity Source #

Each inhabitant is either a knave or a knight

Constructors

Knave 
Knight 

Instances

Instances details
Arbitrary Identity Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

SymVal Identity Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

HasKind Identity Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

EnumSymbolic Identity Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

SatModel Identity Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

parseCVs :: [CV] -> Maybe (Identity, [CV]) Source #

cvtModel :: (Identity -> Maybe b) -> Maybe (Identity, [CV]) -> Maybe (b, [CV]) Source #

OrdSymbolic (SBV Identity) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

HasInductionSchema (Forall ta Identity -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> SBool) -> ProofObj Source #

SymVal extraT => HasInductionSchema (Forall ta Identity -> Forall extraS extraT -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> Forall extraS extraT -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2) => HasInductionSchema (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3) => HasInductionSchema (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3, SymVal extraT4) => HasInductionSchema (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3, SymVal extraT4, SymVal extraT5) => HasInductionSchema (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> Forall extraS5 extraT5 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Identity -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> Forall extraS5 extraT5 -> SBool) -> ProofObj Source #

cv2Identity :: String -> [CV] -> Identity Source #

Conversion from SMT values to Identity values.

_undefiner_Identity :: a Source #

Autogenerated definition to avoid unused-variable warnings from GHC.

type SIdentity = SBV Identity Source #

Symbolic version of the type Identity.

sKnave :: SBV Identity Source #

Symbolic version of the constructor Knave.

sKnight :: SBV Identity Source #

Symbolic version of the constructor Knight.

isKnave :: SBV Identity -> SBool Source #

Field recognizer predicate.

isKnight :: SBV Identity -> SBool Source #

Field recognizer predicate.

sCaseIdentity :: Mergeable result => SBV Identity -> result -> result -> result Source #

Case analyzer for the type Identity.

data Statement Source #

Statements are utterances which are either true or false

Constructors

Truth 
Falsity 

Instances

Instances details
Arbitrary Statement Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

SymVal Statement Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

HasKind Statement Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

EnumSymbolic Statement Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

SatModel Statement Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

parseCVs :: [CV] -> Maybe (Statement, [CV]) Source #

cvtModel :: (Statement -> Maybe b) -> Maybe (Statement, [CV]) -> Maybe (b, [CV]) Source #

OrdSymbolic (SBV Statement) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

HasInductionSchema (Forall ta Statement -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> SBool) -> ProofObj Source #

SymVal extraT => HasInductionSchema (Forall ta Statement -> Forall extraS extraT -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> Forall extraS extraT -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2) => HasInductionSchema (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3) => HasInductionSchema (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3, SymVal extraT4) => HasInductionSchema (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> SBool) -> ProofObj Source #

(SymVal extraT1, SymVal extraT2, SymVal extraT3, SymVal extraT4, SymVal extraT5) => HasInductionSchema (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> Forall extraS5 extraT5 -> SBool) Source # 
Instance details

Defined in Documentation.SBV.Examples.Puzzles.KnightsAndKnaves

Methods

inductionSchema :: (Forall ta Statement -> Forall extraS1 extraT1 -> Forall extraS2 extraT2 -> Forall extraS3 extraT3 -> Forall extraS4 extraT4 -> Forall extraS5 extraT5 -> SBool) -> ProofObj Source #

cv2Statement :: String -> [CV] -> Statement Source #

Conversion from SMT values to Statement values.

_undefiner_Statement :: a Source #

Autogenerated definition to avoid unused-variable warnings from GHC.

type SStatement = SBV Statement Source #

Symbolic version of the type Statement.

sTruth :: SBV Statement Source #

Symbolic version of the constructor Truth.

sFalsity :: SBV Statement Source #

Symbolic version of the constructor Falsity.

isTruth :: SBV Statement -> SBool Source #

Field recognizer predicate.

isFalsity :: SBV Statement -> SBool Source #

Field recognizer predicate.

sCaseStatement :: Mergeable result => SBV Statement -> result -> result -> result Source #

Case analyzer for the type Statement.

john :: SInhabitant Source #

John is an inhabitant of the island.

bill :: SInhabitant Source #

Bill is an inhabitant of the island.

is :: SInhabitant -> SIdentity -> SStatement Source #

The connective is makes a statement about an inhabitant regarding his/her identity.

says :: SInhabitant -> SStatement -> SBool Source #

The connective says makes a predicate from what an inhabitant states

holds :: SStatement -> SBool Source #

The connective holds is will be true if the statement is true

and :: SStatement -> SStatement -> SStatement Source #

The connective and creates the conjunction of two statements

not :: SStatement -> SStatement Source #

The connective not negates a statement

iff :: SStatement -> SStatement -> SStatement Source #

The connective iff creates a statement that equates the truth values of its argument statements

puzzle :: IO () Source #

Encode Smullyan's puzzle. We have:

>>> puzzle
Question 1.
  John says, We are both knaves
    Then, John is: Knave
    And,  Bill is: Knight
Question 2.
  John says If (and only if) Bill is a knave, then I am a knave.
  Bill says We are of different kinds.
    Then, John is: Knave
    And,  Bill is: Knight