equal
deleted
inserted
replaced
33 val auxcnf : prop_formula -> prop_formula (* cnf with auxiliary variables *) |
33 val auxcnf : prop_formula -> prop_formula (* cnf with auxiliary variables *) |
34 val defcnf : prop_formula -> prop_formula (* definitional cnf *) |
34 val defcnf : prop_formula -> prop_formula (* definitional cnf *) |
35 |
35 |
36 val eval : (int -> bool) -> prop_formula -> bool (* semantics *) |
36 val eval : (int -> bool) -> prop_formula -> bool (* semantics *) |
37 |
37 |
|
38 (* propositional representation of HOL terms *) |
38 val prop_formula_of_term : Term.term -> int Termtab.table -> prop_formula * int Termtab.table |
39 val prop_formula_of_term : Term.term -> int Termtab.table -> prop_formula * int Termtab.table |
39 (* propositional representation of HOL terms *) |
40 (* HOL term representation of propositional formulae *) |
|
41 val term_of_prop_formula : prop_formula -> Term.term |
40 end; |
42 end; |
41 |
43 |
42 structure PropLogic : PROP_LOGIC = |
44 structure PropLogic : PROP_LOGIC = |
43 struct |
45 struct |
44 |
46 |
484 end) |
486 end) |
485 in |
487 in |
486 aux t table |
488 aux t table |
487 end; |
489 end; |
488 |
490 |
|
491 (* ------------------------------------------------------------------------- *) |
|
492 (* term_of_prop_formula: returns a HOL term that corresponds to a *) |
|
493 (* propositional formula, with Boolean variables replaced by Free's *) |
|
494 (* ------------------------------------------------------------------------- *) |
|
495 |
|
496 (* Note: A more generic implementation should take another argument of type *) |
|
497 (* Term.term Inttab.table (or so) that specifies HOL terms for some *) |
|
498 (* Boolean variables in the formula, similar to 'prop_formula_of_term' *) |
|
499 (* (but the other way round). *) |
|
500 |
|
501 (* prop_formula -> Term.term *) |
|
502 fun term_of_prop_formula True = |
|
503 HOLogic.true_const |
|
504 | term_of_prop_formula False = |
|
505 HOLogic.false_const |
|
506 | term_of_prop_formula (BoolVar i) = |
|
507 Free ("v" ^ Int.toString i, HOLogic.boolT) |
|
508 | term_of_prop_formula (Not fm) = |
|
509 HOLogic.mk_not (term_of_prop_formula fm) |
|
510 | term_of_prop_formula (Or (fm1, fm2)) = |
|
511 HOLogic.mk_disj (term_of_prop_formula fm1, term_of_prop_formula fm2) |
|
512 | term_of_prop_formula (And (fm1, fm2)) = |
|
513 HOLogic.mk_conj (term_of_prop_formula fm1, term_of_prop_formula fm2); |
|
514 |
489 end; |
515 end; |