-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More general formulas for Pick
, Fill
and Decide
#124
Conversation
I just stumbled upon the |
I've looked into the distant past. There once was this code: genPickExercise :: PickConfig -> IO (String,Either ([(Int,Cnf)],Table) ([(Int,Table)],Cnf))
genPickExercise
PickConfig {cnfConfig = CnfConfig {clauseConf = ClauseConfig {..}, ..}, ..}
= do
first <- generate (getCnf usedLiterals)
let satForm = convert first
rest <- generate (vectorOf (amountOfOptions-1) (getWithSameLiterals first satForm))
let cnfs = first : rest
rightCnf <- generate (elements cnfs)
if pickCnf
then do
let
table = getTable rightCnf
zippedCnfs = zip [1..] cnfs
desc = exerciseDescPick2 zippedCnfs table
pure (desc,Left (zippedCnfs,table))
else do
let
tables = zip [1..] (map getTable cnfs)
desc = exerciseDescPick tables rightCnf
pure (desc,Right (tables,rightCnf))
where
getCnf :: [Char] -> Gen Cnf
getCnf lits = genCnf (minClauseAmount, maxClauseAmount) (minClauseLength, maxClauseLength)
lits
getWithSameLiterals :: Cnf -> Sat.Formula Char -> Gen Cnf
getWithSameLiterals cnf sat = do
let cnfLits = getLiterals cnf
newCnf <- getCnf (map getC cnfLits)
if getLiterals newCnf == cnfLits && Sat.satisfiable (sat Sat.:++: convert newCnf)
then pure newCnf
else getWithSameLiterals cnf sat
exerciseDescPick :: [(Int,Table)] -> Cnf -> String
exerciseDescPick tables cnf =
"Betrachten Sie die folgende Formel in konjunktiver Normalform: \n\n" ++
show cnf ++
"\n Welche der folgenden Wahrheitstafeln passt zu der Formel?\n\n" ++
showIndexedList tables ++
"\nGeben Sie die richtige Tafel durch ihre Nummer an."
exerciseDescPick2 :: [(Int,Cnf)] -> Table -> String
exerciseDescPick2 cnfs table =
"Betrachten Sie die folgende Wahrheitstafel: \n\n" ++
show table ++
"\n Welche der folgenden Formeln in konjunktiver Normalform passt zu der Wahrheitstafel?\n\n" ++
showIndexedList cnfs ++
"\nGeben Sie die richtige Tafel durch ihre Nummer an." So it looks like at some point that parameter was used to decide whether to let the student choose one of three formulas for one given truth table, or one of three truth tables for one given formula. Wheras by now only one of these modes is still supported, I guess. |
Here are some problematic examples: PickConfig {
syntaxTreeConfig = SynTreeConfig {
minNodes = 8,
maxNodes = 9,
minDepth = 4,
maxDepth = 4,
availableAtoms = "FGIKLSUVWXYZ",
minAmountOfUniqueAtoms = 2,
allowArrowOperators = False,
maxConsecutiveNegations = 2,
minUniqueBinOperators = 1},
amountOfOptions = 5,
pickCnf = False,
printSolution = False,
extraText = Nothing
}
-- fails to fill these shapes with "FKV" such that the formulas are not semantically equivalent
[
Binary And (Binary And (Not (Leaf ())) (Binary Or (Leaf ()) (Leaf ()))) (Leaf ()),
Binary And (Not (Leaf ())) (Binary And (Not (Leaf ())) (Not (Leaf ()))),
Binary And (Binary And (Not (Leaf ())) (Not (Leaf ()))) (Not (Leaf ())),
Binary And (Binary And (Leaf ()) (Binary And (Leaf ()) (Leaf ()))) (Binary Or (Leaf ()) (Leaf ())),
Binary Or (Not (Leaf ())) (Binary Or (Binary Or (Leaf ()) (Leaf ())) (Not (Leaf ())))
]
-- same here with "DZ"
PickConfig {
syntaxTreeConfig = SynTreeConfig {
minNodes = 6,
maxNodes = 12,
minDepth = 3,
maxDepth = 4,
availableAtoms = "ABDEFGJKRSTVXZ",
minAmountOfUniqueAtoms = 2,
allowArrowOperators = True,
maxConsecutiveNegations = 2,
minUniqueBinOperators = 1},
amountOfOptions = 5,
pickCnf = False,
printSolution = False,
extraText = Nothing
}
[
Binary And (Not (Not (Leaf ()))) (Binary And (Binary Equi (Leaf ()) (Leaf ())) (Not (Leaf ()))),
Binary Or (Leaf ()) (Binary Impl (Not (Leaf ())) (Binary Or (Leaf ()) (Leaf ()))),
Not (Binary Or (Binary And (Leaf ()) (Leaf ())) (Binary Or (Leaf ()) (Leaf ()))),
Binary And (Leaf ()) (Not (Binary And (Leaf ()) (Leaf ()))),
Binary Impl (Not (Leaf ())) (Not (Not (Leaf ())))
] |
I could not really perceive any decrease in the duration, but there is no harm in implementing it anyway. |
I will probably just go ahead and implement it this way. |
This is not quite finished yet. I will have another look at it the next days. |
I would say this is good for now. The tests currently only work for syntax trees, as the tasks assume that the configurations are valid. This has to do with the usage of It might also be a good idea to refactor the structure of this repo a bit. The current structure creates a few scenarios leading into circular dependencies (this is why some functions are defined in |
This:
is already the subject of #27. What currently holds this back is that there is another Bachelor thesis whose task types are waiting for being merged into this repo, and which still uses the old naming schemes/hierarchy. It seems that a refactoring/restructuring would be better applied after that stuff has arrived here. |
First steps towards an implementation for #98