Permalink
Browse files

Adicionando restricao: sem premissas supérfluas

O gerador agora descarta exercicios demonstráveis que possuam
premissas que não sejam essenciais para a demonstração.
  • Loading branch information...
1 parent e3c77f5 commit 3b47717272aa55d7e0a5cef704abae461a816934 @dlight committed Apr 2, 2012
Showing with 18 additions and 10 deletions.
  1. +16 −8 generate.php
  2. +1 −1 index.html
  3. +1 −1 query.js
View
@@ -65,9 +65,12 @@ function superfluous($p, $premises, $conclusion) {
return follows($premises_without_p, $conclusion);
}
-function has_superfluous_premises($premises, $conclusion) {
- foreach($premises as $p)
- if (superfluous($p, $premises, $conclusion))
+function has_superfluous_premises($exercise) {
+ if (!$exercise['is_valid'])
+ return false;
+
+ foreach($exercise['premises'] as $p)
+ if (superfluous($p, $exercise['premises'], $exercise['conclusion']))
return true;
return false;
@@ -85,7 +88,7 @@ function new_exercise($num_premises, $new_formula) {
return $exercise;
}
-function generate_exercises($num_valid, $num_invalid, $num_premises, $exercise_is_not_fit, $new_formula) {
+function generate_exercises($num_valid, $num_invalid, $num_premises, $exercise_is_fit, $new_formula) {
$valid = array();
$invalid = array();
$discarded_valid = array();
@@ -96,7 +99,7 @@ function generate_exercises($num_valid, $num_invalid, $num_premises, $exercise_i
while (count($valid) < $num_valid || count($invalid) < $num_invalid) {
$exercise = new_exercise($num_premises, $new_formula);
- while ($exercise_is_not_fit($exercise)) {
+ while (!$exercise_is_fit($exercise)) {
array_push($discarded_not_fit, $exercise);
$exercise = new_exercise($num_premises, $new_formula);
}
@@ -174,14 +177,19 @@ function gen($params) {
$fgenerator = new FormulaGenerator($conectives, $atoms);
$compl_min = intval($params['compl_min']);
- $compl_min = intval($params['compl_max']);
+ $compl_max = intval($params['compl_max']);
return generate_exercises(
$num_valid, $num_invalid, $num_premises,
- function ($exercise) {
- return false;
+ function ($exercise) use($no_superfluous) {
+ //die('Debug: ' . var_dump(has_superfluous_premises($exercise)));
+
+ if ($no_superfluous && has_superfluous_premises($exercise))
+ return false;
+
+ return true;
},
function () use ($fgenerator, $compl_min, $compl_max) {
$complex = rand($compl_min, $compl_max);
View
@@ -76,7 +76,7 @@
<div class="cell"><div class="name">Número de premissas</div></div>
<div class="cell">
<div class="block">
- <input type="text" class="num" name="num_premises" value="3" />
+ <input type="text" class="num" name="num_premises" value="2" />
<div class="desc">
<p>Número de premissas em cada exercício.</p>
View
@@ -23,7 +23,7 @@ function form_value() {
atoms: read_atoms('atoms'),
compl_min: read_num('compl_min'),
compl_max: read_num('compl_max'),
- num_premises: read_num('compl_min'),
+ num_premises: read_num('num_premises'),
conectives: checked('conectives'),
restrictions: checked('restrictions')
};

0 comments on commit 3b47717

Please sign in to comment.