Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8d79d48
hpar first version
mcodescu Mar 27, 2018
b7bf3cf
added more files
mcodescu Mar 27, 2018
b2e91a6
more files
mcodescu Mar 27, 2018
36b782c
hpar first version
mcodescu Mar 27, 2018
a9a3a5a
added more files
mcodescu Mar 27, 2018
39961e8
more files
mcodescu Mar 27, 2018
cd51df4
finished comorphism
mcodescu Mar 29, 2018
b5c0683
Merge branch 'rigid_casl' of https://github.com/spechub/Hets into rig…
mcodescu Mar 29, 2018
03b904d
added brackets, needs more tests
mcodescu Mar 30, 2018
c75dcab
dont print keyword when there are no nominals
mcodescu Mar 30, 2018
ac440ad
dont display rigid symbols as non-rigid
mcodescu Mar 30, 2018
985eaa6
printing finally works, cleaning up needed
mcodescu Mar 31, 2018
56cb8d8
total, not partial op symbol
mcodescu Apr 10, 2018
2e33122
fixed quantification on nominals
mcodescu Apr 11, 2018
286c44e
corrected the parser
mcodescu Apr 12, 2018
7f7a727
no tracing, revert change in comorphism
mcodescu Apr 23, 2018
b40bd6e
remove generated file
mcodescu Apr 23, 2018
8165faa
code cleanup
mcodescu Apr 23, 2018
ba8aa45
code cleanup
mcodescu Apr 23, 2018
75b0e77
comment in comorphism
mcodescu Apr 23, 2018
50ce830
added forgotten file
mcodescu Apr 23, 2018
fdbaf1e
hint for repeated rigid symbols
mcodescu Apr 25, 2018
53009fc
hint for symbols redeclared as rigid
mcodescu Apr 25, 2018
5ad946f
hint to warning
mcodescu Apr 25, 2018
6b05a92
warning for redeclared modalities or nominals
mcodescu Apr 26, 2018
097ee15
check that modalities and nominals in sentences have been declared
mcodescu Apr 26, 2018
e28bd7c
properly use diags
mcodescu Apr 26, 2018
c02dfe7
propagate diags for basic items
mcodescu Apr 30, 2018
e679808
allow nominals to be quantified
mcodescu May 1, 2018
e33cb01
added HPAR2CASL as known SPASS comorphism and modified its target sub…
mcodescu May 1, 2018
a0d100c
genric hybridization, before any tests
mcodescu Jul 1, 2018
c8da879
some fixes, not working yet
mcodescu Jul 1, 2018
1c09dde
missing only GetRange and ShATermConvertible instances
mcodescu Jul 1, 2018
10eca5a
try to write type synonyms
mcodescu Jul 3, 2018
496d409
backup
mcodescu Oct 6, 2018
31f3b92
missing files
mcodescu Oct 6, 2018
2ad6c9d
removed generated logics and translations
mcodescu Oct 6, 2018
ae008d7
missing files
mcodescu Oct 6, 2018
eb33124
qualify generated names in comorphism, notation for newhlogic, empty_…
mcodescu Oct 9, 2018
7b1b640
more Logic methods
mcodescu Oct 25, 2018
6df4af0
double hybridization, works for Prop
mcodescu Oct 31, 2018
64ba88c
double hybridization works
mcodescu Nov 5, 2018
61f36a8
SBCS flat goes through
mcodescu Nov 19, 2018
a547a9a
forgotten file
mcodescu Nov 19, 2018
84272ef
made sentence translation in hibridizations of RigidCASL go through
mcodescu Nov 21, 2018
6cf1945
removed import
mcodescu Nov 21, 2018
45da381
fixed a bug
mcodescu Apr 10, 2019
ca94f27
Merge branch 'master' into rigid_casl
tillmo Jun 29, 2019
0afafa0
Merge branch 'master' into rigid_casl
mcodescu Jul 3, 2019
51d8256
shortened lines, trailing
mcodescu Jul 4, 2019
b58b23e
shortened, trailing spaces
mcodescu Jul 4, 2019
a582b79
shorter lines, trailing
mcodescu Jul 4, 2019
6167989
short lines, trailing, no warnings
mcodescu Jul 4, 2019
7db9a2f
delete example file
mcodescu Jul 4, 2019
f9c9ff1
started shortening, long file
mcodescu Jul 4, 2019
bb06f8c
shortened, ready for review
mcodescu Jul 4, 2019
f0e5728
trailing
mcodescu Jul 4, 2019
68851f0
removed existing definitions
mcodescu Jul 4, 2019
b0fdcdd
Merge branch 'master' into rigid_casl
jelmd Oct 16, 2020
9ac66b6
Merge branch 'master' into rigid_casl
jelmd Apr 16, 2021
7fcbb3c
Merge branch 'master' into rigid_casl
mcodescu Sep 23, 2022
c6e5ee0
made Hets compile
mcodescu Sep 23, 2022
8dd9855
made docs go through
mcodescu Sep 23, 2022
515af0d
implementation of H in readme
mcodescu Sep 23, 2022
493f693
changed copyright
mcodescu Sep 30, 2022
226e6fb
fixed warnings
mcodescu Sep 30, 2022
6211fd2
add prefix map
mcodescu Sep 30, 2022
68ecbb6
Merge branch 'master' into rigid_casl
mcodescu Sep 30, 2022
32c0310
removed trace message
mcodescu Oct 4, 2022
16ccc5e
adapt to the changes in Logic.Logic
mcodescu Oct 4, 2022
bffde05
documentation
mcodescu Oct 13, 2022
3776d95
Merge branch 'master' into rigid_casl
mcodescu Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CASL/Formula.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ module CASL.Formula
, qualPredName
, implKey
, ifKey
, orKey
, andKey
) where

import Common.AnnoState
Expand Down
24 changes: 23 additions & 1 deletion CASL/Logic_CASL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import CASL.OMDocExport
import CASL.Freeness

-- test
import CASL.Formula (formula)
import CASL.Formula (formula, primFormula)

#ifdef UNI_PACKAGE
import CASL.QuickCheck
Expand Down Expand Up @@ -225,10 +225,13 @@ instance Sentences CASL CASLFORMULA CASLSign CASLMor Symbol where
symmap_of CASL = morphismToSymbMap
sym_name CASL = symName
symKind CASL = show . pretty . symbolKind . symbType
extSymKind CASL = extSymbolKind . symbType
symsOfSen CASL _ = Set.toList
. foldFormula (symbolsRecord $ const Set.empty)
simplify_sen CASL = simplifyCASLSen
print_named CASL = printTheoryFormula
-- test nominals
is_nominal_sen CASL = isNominalSen

instance StaticAnalysis CASL CASLBasicSpec CASLFORMULA
SYMB_ITEMS SYMB_MAP_ITEMS
Expand All @@ -237,6 +240,7 @@ instance StaticAnalysis CASL CASLBasicSpec CASLFORMULA
Symbol RawSymbol where
basic_analysis CASL = Just basicCASLAnalysis
sen_analysis CASL = Just cASLsen_analysis
convertTheory CASL = Just convertCASLTheory
stat_symb_map_items CASL = statSymbMapItems
stat_symb_items CASL = statSymbItems
signature_colimit CASL diag = return $ signColimit diag extCASLColimit
Expand All @@ -246,13 +250,16 @@ instance StaticAnalysis CASL CASLBasicSpec CASLFORMULA

qualify CASL = qualifySig
symbol_to_raw CASL = symbolToRaw
raw_to_symbol CASL = rawToSymbol
id_to_raw CASL = idToRaw
matches CASL = CASL.Morphism.matches
is_transportable CASL = isSortInjective
is_injective CASL = isInjective
raw_to_var CASL = rawToVar

empty_signature CASL = emptySign ()
add_symb_to_sign CASL = addSymbToSign
add_noms_to_sign CASL = addNomsToSign

signature_union CASL s = return . addSig const s
signatureDiff CASL s = return . diffSig const s
Expand All @@ -275,6 +282,7 @@ instance Logic CASL CASL_Sublogics
stability CASL = Stable
-- for Hybridization
parse_basic_sen CASL = Just $ \ _ -> formula []
parse_prim_formula CASL = Just $ const (primFormula [])

proj_sublogic_epsilon CASL = pr_epsilon ()
all_sublogics CASL = sublogics_all []
Expand All @@ -292,6 +300,20 @@ instance Logic CASL CASL_Sublogics
addOMadtToTheory CASL = OMI.addOMadtToTheory
addOmdocToTheory CASL = OMI.addOmdocToTheory
syntaxTable CASL = Just . getSyntaxTable
constr_to_sens CASL = constrToSens
-- helpers for hybridization
-- for each type, its name and the file where it is defined
sublogicsTypeName CASL = ("CASL_Sublogics","CASL.Sublogic")
basicSpecTypeName CASL = ("CASLBasicSpec","CASL.Logic_CASL")
sentenceTypeName CASL = ("CASLFORMULA","CASL.AS_Basic_CASL")
symbItemsTypeName CASL = ("SYMB_ITEMS","CASL.AS_Basic_CASL")
symbMapItemsTypeName CASL = ("SYMB_MAP_ITEMS","CASL.AS_Basic_CASL")
signTypeName CASL = ("CASLSign","CASL.Sign")
morphismTypeName CASL = ("CASLMor","CASL.Morphism")
symbolTypeName CASL = ("Symbol","")
rawSymbolTypeName CASL = ("RawSymbol","CASL.Morphism")
proofTreeTypeName CASL = ("ProofTree","Common.ProofTree")

#ifdef UNI_PACKAGE
provers CASL = [quickCheckProver]
#endif
13 changes: 13 additions & 0 deletions CASL/Morphism.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module CASL.Morphism
, idToRaw
, typedSymbKindToRaw
, symbolToRaw
, rawToSymbol
, rawToVar
, insertRsys
, mapSort
, mapOpSym
Expand Down Expand Up @@ -208,6 +210,17 @@ mapCASLMor e me m =
symbolToRaw :: Symbol -> RawSymbol
symbolToRaw = ASymbol

rawToSymbol :: RawSymbol -> Maybe Symbol
rawToSymbol (ASymbol s) = Just s
rawToSymbol (AKindedSymb k i) =
case k of
Sorts_kind -> Just $ Symbol i SortAsItemType
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is kind sort assumed here?

_ -> Nothing

rawToVar :: RawSymbol -> Maybe (Token, Id)
rawToVar (ASymbol (Symbol n (OpAsItemType (OpType Total [] s)))) = Just (idToSimpleId n, s)
rawToVar _ = Nothing

idToRaw :: Id -> RawSymbol
idToRaw = AKindedSymb Implicit

Expand Down
21 changes: 19 additions & 2 deletions CASL/Sign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Common.DocUtils
import Data.Data
import Data.Maybe (fromMaybe)
import Data.List (isPrefixOf)
import Control.Monad (when, unless)
import Control.Monad (when, unless, foldM)

-- constants have empty argument lists
data OpType = OpType {opKind :: OpKind, opArgs :: [SORT], opRes :: SORT}
Expand Down Expand Up @@ -81,6 +81,15 @@ symbolKind t = case t of
PredAsItemType _ -> Preds_kind
_ -> Sorts_kind

extSymbolKind :: SymbType -> String
extSymbolKind t = case t of
OpAsItemType (OpType k l _) ->
case (k, l) of
(Total, []) -> "const"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about partial constants? Should they really lead to "op"?

_ -> "op"
PredAsItemType _ -> "pred"
_ -> "sort"

data Symbol = Symbol {symName :: Id, symbType :: SymbType}
deriving (Show, Eq, Ord, Typeable, Data)

Expand Down Expand Up @@ -591,8 +600,16 @@ addSymbToSign sig sy =
PredAsItemType pt -> return $ addPred' sig' n pt
OpAsItemType ot -> return $ addOp' sig' n ot

addNomsToSign :: Sign e f -> Set.Set Id -> Result (Sign e f)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment documenting the function (I won' repeat this comment for other functions).

addNomsToSign sig noms = do
-- add a fake sort for nominals
sig0 <- addSymbToSign sig $ Symbol (genName "ST") SortAsItemType
sig' <- foldM (\aSig nom -> addSymbToSign aSig $ Symbol nom $
PredAsItemType $ PredType [])
sig0 $ Set.toList noms
return sig'

-- The function below belong in a different file. But I put them here for now.
-- TODO: The function below belong in a different file. But I put them here for now.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the TODO should be resolved

-- dual of a quantifier

dualQuant :: QUANTIFIER -> QUANTIFIER
Expand Down
177 changes: 165 additions & 12 deletions CASL/StaticAna.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import qualified Data.Set as Set
import Data.Maybe
import Data.List

import Logic.SemConstr

checkPlaces :: [SORT] -> Id -> [Diagnosis]
checkPlaces args i = let n = placeCount i in
[mkDiag Error "wrong number of places" i | n > 0 && n /= length args ]
Expand Down Expand Up @@ -869,6 +871,14 @@ anaTerm mef mixIn sign msrt pos t = do
(\ srt -> Sorted_term resT srt pos) msrt
return (resT, anaT)

getAllIds :: (FormExtension f, TermExtension f) =>
BASIC_SPEC b s f -> Mix b s f e -> Sign f e -> IdSets
getAllIds bs mix inSig =
unite $ ids_BASIC_SPEC (getBaseIds mix) (getSigIds mix) bs
: getExtIds mix (extendedInfo inSig) :
[mkIdSets (allConstIds inSig) (allOpIds inSig)
$ allPredIds inSig]

basicAnalysis :: (FormExtension f, TermExtension f)
=> Min f e -- ^ type analysis of f
-> Ana b b s f e -- ^ static analysis of basic item b
Expand All @@ -879,10 +889,7 @@ basicAnalysis :: (FormExtension f, TermExtension f)
{- ^ (BS with analysed mixfix formulas for pretty printing,
differences to input Sig,accumulated Sig,analysed Sentences) -}
basicAnalysis mef anab anas mix (bs, inSig, ga) =
let allIds = unite $ ids_BASIC_SPEC (getBaseIds mix) (getSigIds mix) bs
: getExtIds mix (extendedInfo inSig) :
[mkIdSets (allConstIds inSig) (allOpIds inSig)
$ allPredIds inSig]
let allIds = getAllIds bs mix inSig
(newBs, accSig) = runState (ana_BASIC_SPEC mef anab anas
mix { mixRules = makeRules ga allIds }
bs) inSig { globAnnos = addAssocs inSig ga }
Expand All @@ -908,15 +915,161 @@ basicCASLAnalysis = basicAnalysis (const return) (const return)

-- | extra
cASLsen_analysis ::
(BASIC_SPEC () () (), Sign () (), FORMULA ()) -> Result (FORMULA ())
(BASIC_SPEC () () (), Sign () (), FORMULA ()) ->
Result (FORMULA (), FORMULA ())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please document the purpose of returning two formulas

cASLsen_analysis (bs, s, f) = let
mix = emptyMix
allIds = unite $
ids_BASIC_SPEC (getBaseIds mix)
(getSigIds mix) bs
: getExtIds mix (extendedInfo s) :
[mkIdSets (allConstIds s) (allOpIds s)
$ allPredIds s]
allIds = getAllIds bs mix s
mix' = mix { mixRules = makeRules emptyGlobalAnnos
allIds }
in liftM fst $ anaForm (const return) mix' s f
in anaForm (const return) mix' s f

-- | convert theory

convertCASLTheory :: (Sign f e, [Named (FORMULA f)]) -> BASIC_SPEC b s f
convertCASLTheory (sig, nsens) =
case (sig, nsens) of
(_, []) -> Basic_spec [] -- TODO: the sig should be empty
_ -> error "convert theory nyi for CASL logic"

-- | test nominal sen

isNominalSen :: Set.Set Id -> FORMULA f -> (Bool, Maybe Id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a good idea to represent nominals as mixfix formulas, which are usually only used in an intermediate stage an eliminated by static analysis?

isNominalSen noms aSen =
case aSen of
Mixfix_formula (Mixfix_token p) ->
let pId = simpleIdToId p
in if Set.member pId noms then (True, Just pId) else (False, Nothing)
_ -> (False, Nothing)

-- | CASL hybridization: constraints to CASL sentences

constrToSens :: Sign () () -> String -> SemanticConstraint ->
Result [Named (FORMULA ())]
constrToSens sig cname sc =
let
st = genName $ "ST_" ++ cname
domain = genName $ "domain_" ++ cname
defined = genName "defined"
(totals, partials) = partition (\(_, ot) -> opKind ot == Total) $
MapSet.toPairList $ opMap sig
in
case sc of
SameInterpretation "sort" ->
return $
map (\s -> makeNamed ("ga_sem_constr_"++show s)
$ mkForall [mkVarDecl (genToken "w1") st,
mkVarDecl (genToken "w2") st,
mkVarDecl (genToken "x") s]
$ mkEqv
(mkPredication
(mkQualPred domain $ Pred_type [st, s] nullRange)
[Qual_var (genToken "w1") st nullRange,
Qual_var (genToken "x") s nullRange])
(mkPredication
(mkQualPred domain $ Pred_type [st, s] nullRange)
[Qual_var (genToken "w2") st nullRange,
Qual_var (genToken "x") s nullRange])
)
$ Set.toList $ sortSet sig
SameInterpretation "const" -> error "nyi for const"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo?

SameInterpretation "op" ->
let
xs ot = zip (opArgs ot) [1::Int ..]
extOt i ot = Qual_op_name
i
(Op_type Total (st:opArgs ot) (opRes ot) nullRange)
nullRange
in return $
map (\(i,ot) -> makeNamed ("ga_sem_constr_" ++ show i)
$ mkForall
( [mkVarDecl (genToken "w1") st,
mkVarDecl (genToken "w2") st]
++
(map (\(si, ii) ->
mkVarDecl (genToken $ "x" ++ show ii) si) $ xs ot)
)
$ mkStEq
(mkAppl (extOt i ot) $ map (\(a,b) -> mkVarTerm a b) $
(genToken "w1", st):
(map (\(si, ii) -> (genToken $ "x" ++ show ii, si)) $
xs ot))
(mkAppl (extOt i ot) $ map (\(a,b) -> mkVarTerm a b) $
(genToken "w2", st):
(map (\(si, ii) -> (genToken $ "x" ++ show ii, si)) $
xs ot))
) totals
SameInterpretation "pred" ->
let
xs pt = zip (predArgs pt) [1::Int ..]
extPt (Pred_type ss r) = Pred_type (st:ss) r
in return $
map (\(i, pt) -> makeNamed ("ga_sem_constr_" ++ show i) $
mkForall
( [mkVarDecl (genToken "w1") st,
mkVarDecl (genToken "w2") st]
++
(map (\(si, ii) ->
mkVarDecl (genToken $ "x" ++ show ii) si)
$ xs pt)
)
$ mkEqv
(mkPredication
(mkQualPred i $ extPt $ toPRED_TYPE pt) $
map (\(a,b) -> mkVarTerm a b) $
(genToken "w1", st):
(map (\(si, ii) ->
(genToken $ "x" ++ show ii, si))
$ xs pt))
(mkPredication
(mkQualPred i $ extPt $ toPRED_TYPE pt) $
map (\(a,b) -> mkVarTerm a b) $
(genToken "w2", st):
(map (\(si, ii) ->
(genToken $ "x" ++ show ii, si))
$ xs pt))
) $ MapSet.toPairList $ predMap sig
SameDomain False -> let
xs ot = zip (opArgs ot) [1::Int ..]
extOt i ot = Qual_op_name
i
(Op_type Total (st:opArgs ot) (opRes ot) nullRange)
nullRange
in return $
map (\(i,ot) -> makeNamed ("ga_sem_constr_" ++ show i)
$ mkForall
( [mkVarDecl (genToken "w1") st,
mkVarDecl (genToken "w2") st]
++
(map (\(si, ii) ->
mkVarDecl (genToken $ "x" ++ show ii) si)
$ xs ot)
)
$ mkEqv
(mkPredication
(mkQualPred defined $
Pred_type [st, opRes ot] nullRange) $
[mkVarTerm (genToken "w1") st,
mkAppl (extOt i ot) $
map (\(a,b) -> mkVarTerm a b) $
(genToken "w1", st):
(map (\(si, ii) ->
(genToken $ "x" ++ show ii, si))
$ xs ot)
]
)
(mkPredication
(mkQualPred defined $
Pred_type [st, opRes ot] nullRange) $
[mkVarTerm (genToken "w2") st,
mkAppl (extOt i ot) $
map (\(a,b) -> mkVarTerm a b) $
(genToken "w2", st):
(map (\(si, ii) ->
(genToken $ "x" ++ show ii, si))
$ xs ot)
]
)
)
partials
_ -> error $ "Constraint not supported for CASL logic:" ++ show sc
4 changes: 2 additions & 2 deletions CoCASL/StatAna.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ basicCoCASLAnalysis =
-- analyses cocasl sentences only
co_sen_analysis ::
(BASIC_SPEC C_BASIC_ITEM C_SIG_ITEM C_FORMULA, CSign, FORMULA C_FORMULA)
-> Result (FORMULA C_FORMULA)
-> Result (FORMULA C_FORMULA, FORMULA C_FORMULA)
co_sen_analysis (bs, s, f) = let
mix = emptyMix
allIds = unite $
Expand All @@ -68,7 +68,7 @@ co_sen_analysis (bs, s, f) = let
[mkIdSets (allConstIds s) (allOpIds s)
$ allPredIds s]
mix' = mix { mixRules = makeRules emptyGlobalAnnos allIds}
in liftM fst $ anaForm minExpForm mix' s f
in anaForm minExpForm mix' s f


ana_CMix :: Mix C_BASIC_ITEM C_SIG_ITEM C_FORMULA CoCASLSign
Expand Down
3 changes: 3 additions & 0 deletions Common/AnnoState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ equalT :: AParser st Token
equalT = wrapAnnos $ pToken $ reserved [exEqual]
(choice (map (keySign . string) [exEqual, equalS]) <?> show equalS)

doubleColonT :: AParser st Token
doubleColonT = asKey "::"

colonT :: AParser st Token
colonT = asKey colonS

Expand Down
Loading