genTransMFormFunc.pl revision 662d733158fbedc2f128f0f39c7d4f93dc1f2574
# $Id$
# usage:
# substitute ##<WORD> with Haskell code snippits
use strict;
# subtitutions with common parts of Modal- and CASL-formulas
my %substs =
("�!modalAx" =>
"inlineAxioms Modal \"modality empty\\n".
"pred p,q:()\\n".
". ",
"�!caslAx" =>
"inlineAxioms CASL \"sort world\\n".
"pred rel : world * world\\n".
"forall w1 : world\\n. ");
my $input = "";
# Argument processing
###unless ($infile eq "DEBUG") {
print STDERR "Generating $outfile1\n";
# open the first two files
# perform the substitutions
while (<IN>) {
s/$key\"/$substs{$key}/ge;
}
print OUT $_;
}
close IN;
close OUT;
# call outlineAxioms and get the result imidiately
if($? >> 8) {
print STDERR "outlineAxioms detected an error\n";
exit 5;
}
###}
###if ($input eq "") {
### $input = join("",<STDIN>);
###}
# process the output of outlineAxioms (further called input)
$input =~ s/^\s*\[\(\[\[//s;
$input =~ s/(\})\]\]\)\]\s*$/$1/s;
# print "$input\n";
# split the input into pairs
print STDERR "Generating $outfile\n";
# open the outputfile and print out the header
print OUT '{- look but don\'t touch !!
import Common.AS_Annotation
-- CASL
import CASL.AS_Basic_CASL
-- ModalCASL
',
'transSchemaMFormula mapT world rel vars anMF =
let '.
join("\n ",map {'w'.$_.' = vars !! '.($_-1);} (1,2,3)).
' in
';
# print "Pair: $pair\n";
my $moda_i = 0;
# split each pair into raw pattern and raw result
#print STDERR " $pattern => $result\n";
# pattern is the left hand side of the case '->'
# Each field of NamedSen is substituted by a variable
# And then NamedSen is transformend to a tuple
# remove line breaks and spaces
# add variables foreach modality
# substitute formula variables with underscore
# only 'p','q' and 'r' are recognized
# substitute nullRange with underscore
# remove all stuff that s not needed from the pattern
# closing brace
$pattern =~ s/\}\s*$//o;
# SenAttr Constructor, opening brace and first selector
#print STDERR "222: $pattern\n";
# new isAxiom field
# new isDef field
# new wasTheorem field
$pattern =~ s/wasTheorem = \w+,//o;
# new simpAnno field
# new attrOrigin field
$pattern =~ s/attrOrigin = \w+,//o;
# sentence selector
#print STDERR "223: $pattern\n";
# All empty lists in the pattern are substituted by underscores
# the result is in the right format and only white spaces / line
# breaks are removed
my $list = "";
$list = "[$list";
$list =~ s/,$/]/o;
}
print OUT
}
print OUT
' (_,f)'." ->\n".
' error ("Modal2CASL: unknown formula: " ++ showDoc f "") Nothing
';
close OUT;