0N/A Copyright : (c) Mingyi Liu and Till Mossakowski and Uni Bremen 2004
0N/A Maintainer : hets@tzi.de
0N/A Stability : provisional
0N/A Portability : portable
0N/A Check for truth in one-point model
0N/A with all predicates true, all functions total
We use a three valued logic to evaluate a formula in a one-point expansion
of an unknown arbitrary model. This means that for new sorts and new predicates,
every equation and predicate application holds, but for the old sorts and
predicates, we do not know anything. The three valued logic is represented
with Maybe Bool. It has the following meaning:
The connectives are as follows:
(this is just Kleene's strong three-valued logic)
evaluateOnePoint :: Morphism f e m -> [FORMULA f] -> Maybe Bool
let p = [evaluateOnePointFORMULA (imageOfMorphism m) f|f<-fs]
in if elem (Just False) p then Just False
else if elem Nothing p then Nothing
evaluateOnePoint :: Morphism f e m-> [FORMULA f] -> Maybe Bool
evaluateOnePoint m fs = do
p <- mapM (evaluateOnePointFORMULA (imageOfMorphism m)) fs
evaluateOnePointFORMULA :: Sign f e -> FORMULA f -> Maybe Bool
evaluateOnePointFORMULA sig (Quantification _ _ f _) =
evaluateOnePointFORMULA sig f
evaluateOnePointFORMULA sig (Conjunction fs _)=
let p=[evaluateOnePointFORMULA sig f|f<-fs]
in if elem (Just False) p then Just False
else if elem Nothing p then Nothing
evaluateOnePointFORMULA sig (Disjunction fs _)=
let p=[evaluateOnePointFORMULA sig f|f<-fs]
in if elem (Just True) p then Just True
else if elem Nothing p then Nothing
evaluateOnePointFORMULA sig (Implication f1 f2 _ _)=
let p1=evaluateOnePointFORMULA sig f1
p2=evaluateOnePointFORMULA sig f2
in if p1==(Just False) || p2==(Just True) then Just True
else if p1==(Just True) && p2==(Just False) then Just False
evaluateOnePointFORMULA sig (Equivalence f1 f2 _) =
let p1=evaluateOnePointFORMULA sig f1
p2=evaluateOnePointFORMULA sig f2
in if p1==Nothing || p2==Nothing then Nothing
else if p1==p2 then Just True
evaluateOnePointFORMULA sig (Negation f _)=
case evaluateOnePointFORMULA sig f of
evaluateOnePointFORMULA _ (True_atom _)= Just True
evaluateOnePointFORMULA _ (False_atom _)= Just False
evaluateOnePointFORMULA sig (Predication pred_symb _ _)=
Qual_pred_name pname ptype _ ->
if toPredType ptype `
Set.member` ptypes then Nothing
evaluateOnePointFORMULA sig (Definedness (Sorted_term _ sort _) _)=
evaluateOnePointFORMULA sig (Existl_equation (Sorted_term _ sort1 _) (Sorted_term _ sort2 _) _)=
&& (
Set.member sort2 (sortSet sig)==False) then Just True
evaluateOnePointFORMULA sig (Strong_equation (Sorted_term _ sort1 _) (Sorted_term _ sort2 _) _)=
&& (
Set.member sort2 (sortSet sig)==False) then Just True
-- todo: auch pruefen, ob Sorte von t in sortSet sig
evaluateOnePointFORMULA sig (Membership (Sorted_term _ sort1 _) sort2 _)=
&& (
Set.member sort2 (sortSet sig)==False) then Just True
evaluateOnePointFORMULA _ (Mixfix_formula _)= error "Fehler Mixfix_formula"
evaluateOnePointFORMULA _ (Unparsed_formula _ _)= error "Fehler Unparsed_formula"
compute recover_Sort_gen_ax constr, get (srts,ops,maps)
check whether all srts are "new" (not in the image of the morphism)
check whether for all s in srts, there is a term,
using variables of sorts outside srts
using operation symbols from ops
construct a list L of "inhabited" sorts
initially, the list L is empty
for each operation symbol in ops, such that
all argument sorts (opArgs)
are either in the list L or are outside srts
add the results sort (opRes) to the list L of inhabited sorts
start with initial list, and iterate until iteration is stable
check whether srts is a sublist of the list resulting from the iteration
evaluateOnePointFORMULA sig (Sort_gen_ax constrs _)=
let (srts,ops,_)=recover_Sort_gen_ax constrs
argsAndres=concat $ map (\os-> case os of
Op_type _ args res _->[(args,res)]
if l==newL then newL else iterateInhabited newL
where newL =foldr (\ (as,rs) l'->
if (all (\s->elem s l') as)
-- inhabited = iterateInhabited []
in if any (\s->
Set.member s sorts) srts then Nothing
else if all (\s->elem s inhabited) srts then Just True
evaluateOnePointFORMULA _ (ExtFORMULA _)=error "Fehler ExtFORMULA"
evaluateOnePointFORMULA _ _=error "Fehler" -- or Just False
-- | Compute the image of a signature morphism
imageOfMorphism :: Morphism f e m -> Sign f e
sig {sortSet =
Set.map (mapSort sortMap) (sortSet src),
sortRel =
Rel.map (mapSort sortMap) (sortRel src),
(mapOpSym sortMap funMap (ident,ot)) l') l ots)
(mapPredSym sortMap pMap (ident,pt)) l') l pts)
insertOp (ident,ot) opM =
insertPred (ident,pt) predM =
-- | Test whether a signature morphism adds new supersorts
addsNewSupersorts :: Morphism f e m -> Bool
where sig=imageOfMorphism m
check: is there a sort not in the image of the morphism, that is
simultaneously s supersort of a sort that is in the image.
go through all sorts in the image
for each such sort s, comupte supersortsOf s
test whether a supersort is not in the image
if there is such a sort (
i.e. supersort not in the image), then return True