Reputation: 71
i have a function that is supposed to convert a wff in a cnf, one part of that function doesnt want to work, and i managed to pinpoint the problem, here is the code
(defun skole-gay (fbf &optional (var-for nil) (var-ex nil))
(if (consp fbf)
(case (car fbf)
(forall ;nel caso di forall salvo il prossimo elemento assieme a possibile altri elementi di altri forall
(skole-gay (third fbf) (cons (second fbf) var-for) var-ex))
(exist ;nel caso di exist salvo il suo elemento
(skole-gay (third fbf) var-for (cons (second fbf) var-ex)))
((car var-ex) ;nel caso che trovo l'elemento salvato della exist faccio dei contrllo per vedere cosa devo fare
(cond
((eql (car var-for) nil) ;se sub-for e' vuoto vuol dire che non ci sn stati forall indi devo solo inserire la const
(cons (skolem-variable)
(skole-gay (cdr fbf) nil var-ex))) ;dopo la costante metter il resto della fbf
((not(eql (car var-for) nil)) ;ci sono stati forall
(cons (skolem-function var-for)
(cons (car var-for) (skole-gay (cdr fbf) nil var-ex))))))
((and or) ;se trovo and or not semplicemente li riscrivo e continuo con la ricorsione
(list (car fbf) (skole-gay (second fbf) var-for var-ex) (skole-gay (third fbf) var-for var-ex)))
((not) ;se trovo and or not semplicemente li riscrivo e continuo con la ricorsione
(list (car fbf) (skole-gay (second fbf) var-for var-ex)))
(otherwise
;; e' solo 1 proposizione, la ritorno
fbf))
fbf))
at one point im doing (case (car fbf) ; where car of fbf = ?x and one of the cases is ((car var-ex) ; that at that point of them program is also ?x but it doenst run that part of the program and i dont know why,
ignore the comments in the code because they are in italian
Upvotes: 1
Views: 116
Reputation: 3885
The clauses in a case
form has to be available at compile time. The clauses are not evaluated and will be used exactly as they were written in the code.
In your example, the clause specifies (car var-ex)
which is a list of two symbols: car
and var-ex
. If the value is either of these, that clause will be called. I doubt that is ever the case, which is why it seems like it was ignored.
Upvotes: 3