genTransMFormFunc.pl revision fbf66630978e9a8d85a130211628fe4694ba3664
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder# genInlines.pl Modal/GeneratePatterns.inline.hs.in Modal/ModalSystems.hs
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder# substitute ##<WORD> with Haskell code snippits
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maedermy $disclaimer = '"Remove this trace when Results from map_sign are available\\n"';
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder# subtitutions with common parts of Modal- and CASL-formulas
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder ("�!modalAx" =>
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder "inlineAxioms Modal \"modality empty\\n".
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder"pred p,q:()\\n".
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder "�!caslAx" =>
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder "inlineAxioms CASL \"sort world \\n".
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder"pred rel : world * world\\n".
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder"forall w1 : world \\n. ");
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder# Argument processing
e774ab5733a1d673b123b0e63b14dd533e6fd4fcChristian Maeder###unless ($infile eq "DEBUG") {
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederdie "exactly one in- and one out-file needed!!" unless @ARGV == 2;
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maedermy $outfile1 = join "", (fileparse($infile,'\.in'))[1,0];
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder# open the first two files
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederopen IN, "<$infile" or die "cannot read \"$infile\"";
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederopen OUT, ">$outfile1" or die "cannot write to \"$outfile1\"";
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder# perform the substitutions
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder# call outlineAxioms and get the result imidiately
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder print STDERR "outlineAxioms detected an error\n";
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder###if ($input eq "") {
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder### $input = join("",<STDIN>);
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder# process the output of outlineAxioms (further called input)
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder$input =~ s,^.*snip\s+><\s+Patterns(.*)snip\s+>/<\s+Patterns,$1,s;
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder$input =~ s/^\s*\[\(\[\[//s;
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder# print "$input\n";
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder# split the input into pairs
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maedermy @input = split(/\]\]\),\s+?\(\[\[/s, $input);
fc8c6570c7b4ee13f375eb607bed2290438573bfChristian Maeder# open the outputfile and print out the header
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maederopen OUT, ">$outfile" or die "cannot write to \"$outfile\"";
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedermodule Modal.ModalSystems (transSchemaMFormula) where
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian MaedertransSchemaMFormula :: ([VAR] -> TERM M_FORMULA -> TERM ())
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder'transSchemaMFormula mapT world rel vars anMF =
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder join("\n ",map {'w'.$_.' = vars !! '.($_-1);} (1,2,3,4,5)).
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder# print "Pair: $pair\n";
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # split each pair into raw pattern and raw result
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder my ($pattern,$result) = split /\]\],\s+?\[\[/s,$pair;
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder #print STDERR " $pattern => $result\n";
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # pattern is the left hand side of the case '->'
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # Each field of NamedSen is substituted by a variable
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # And then NamedSen is transformend to a tuple
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder # remove line breaks and spaces
e1839fb37a3a2ccd457464cb0dcc5efd466dbe22Christian Maeder # add variables foreach modality
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder $pattern =~ s/Simple_mod empty/'moda'.$moda_i++/goe;
e774ab5733a1d673b123b0e63b14dd533e6fd4fcChristian Maeder # substitute formula variables with underscore
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder # only 'p','q' and 'r' are recognized
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # remove all stuff that s not needed from the pattern
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder # closing brace
1738d16957389457347bee85075d3d33d002158fChristian Maeder $pattern =~ s/\}\s*$//o;
1738d16957389457347bee85075d3d33d002158fChristian Maeder # NamedSen Constructor, opening brace and first selector
33a5d53a412ba0a4e5847f7538d6da2e22bd116cChristian Maeder #print STDERR "222: $pattern\n";
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder # new isAxiom field
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder # sentence selctor
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder #print STDERR "223: $pattern\n";
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # All empty lists in the pattern are substituted by underscores
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder # the result is in the right format and only white spaces / line
$list =~ s/,$/]/o;
print OUT
close OUT;