├── LICENSE ├── README.md ├── addtools ├── addfmsg.dpr ├── chkerr.dpr ├── commextr.dpr ├── edtfile.dpr ├── errflag.dpr ├── mglue.dpr ├── msplit.dpr ├── prune.dpr └── remflags.dpr ├── base ├── _formats.pas ├── abstract_syntax.pas ├── block_and_item.pas ├── dicthan.pas ├── errhan.pas ├── esmprocessor.dpr ├── first_identification.pas ├── info.pas ├── librenv.pas ├── mconsole.pas ├── mizenv.pas ├── mobjects.pas ├── monitor.pas ├── mscanner.pas ├── msmprocessor.dpr ├── mstate.pas ├── mtime.pas ├── numbers.pas ├── parser.pas ├── parseraddition.pas ├── pcmizver.pas ├── pragmas.pas ├── scanner.pas ├── syntax.pas ├── wsmarticle.pas ├── wsmparser.dpr ├── xml_dict.pas ├── xml_inout.pas └── xml_parser.pas ├── kernel ├── absinfo.pas ├── acc_han.pas ├── accdict.pas ├── accom.dpr ├── analyzer.pas ├── builtin.pas ├── checker.pas ├── correl.pas ├── e_prep.pas ├── ellipses.pas ├── enums.pas ├── envhan.pas ├── envinout.pas ├── equalizer.pas ├── exporter.dpr ├── express.pas ├── extunit.pas ├── formats.pas ├── generato.pas ├── heapctrl.pas ├── identify.pas ├── impobjs.pas ├── inenviro.pas ├── inlibr.pas ├── inout.pas ├── inoutmml.pas ├── iocorrel.pas ├── justhan.pas ├── lexicon.pas ├── limits.pas ├── makeenv.dpr ├── mizprep.pas ├── naccom.dpr ├── outinfo.pas ├── outlibr.pas ├── polynom.pas ├── prechecker.pas ├── prelhan.pas ├── prephan.pas ├── prepobj.pas ├── prochan.pas ├── propcoll.pas ├── req_info.pas ├── roundcl.pas ├── schemes.pas ├── schemhan.pas ├── stdprep.pas ├── trans2analyzer.pas ├── transfer.dpr ├── unifier.pas ├── verfinit.pas ├── verifier.dpr ├── xmldict.pas └── xmlpars.pas ├── libtools ├── checkvoc.dpr ├── chkrprem.dpr ├── createvd.dpr ├── dellink.dpr ├── edt_han.pas ├── envget.dpr ├── inf_prep.pas ├── itr_prep.pas ├── labelact.pas ├── ref_han.pas ├── ref_unit.pas ├── refrem.dpr ├── relinfer.dpr ├── reliters.dpr ├── relpprep.pas ├── renthlab.dpr ├── replthls.dpr ├── rpremact.pas ├── td_prep.pas ├── trivdemo.dpr └── unhereby.dpr └── usrtools ├── absact.pas ├── absedt.dpr ├── chklab.dpr ├── constr.dpr ├── findvoc.dpr ├── inacc.dpr ├── inaccact.pas ├── irlabact.pas ├── irrths.dpr ├── irrvoc.dpr ├── lisppars.dpr ├── lispscan.pas ├── listvoc.dpr └── relprem.dpr /README.md: -------------------------------------------------------------------------------- 1 | This repository contains the source code of the Mizar system. 2 | Mizar is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License as published by 4 | the Free Software Foundation, either version 3 of the License, or 5 | (at your option) any later version. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | Binary distribution for major platforms can be downloaded from the main Mizar website (https://mizar.uwb.edu.pl). 13 | The source code can be compiled with Free Pascal Compiler (https://www.freepascal.org). 14 | -------------------------------------------------------------------------------- /addtools/addfmsg.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program AddFMsg; 11 | 12 | uses mizenv,errhan,mconsole; 13 | 14 | const 15 | MaxErrNbr = 3000; 16 | MaxError = 9999; 17 | MaxColumn = 80; 18 | 19 | var 20 | Source, Messages, Errors: text; 21 | SourceBuff, MessagesBuff: array[0..$4000] of char; 22 | EndOfMessage: boolean; 23 | ErrorsBuff: array[0..$1000] of char; 24 | Occurs: array[1..MaxError] of boolean; 25 | Line, Col, Code, ErrNbr, ErrCode, i: integer; 26 | Buffer: string; 27 | 28 | procedure GetErrCode; 29 | var Err,FirstDig,Count,Nbr: integer; 30 | label 1,2; 31 | begin 32 | for FirstDig:=2 to length(Buffer) do 33 | if Buffer[FirstDig]<>' ' then goto 1; 34 | FirstDig:=length(Buffer)+1; 35 | 1: 36 | for Count:=FirstDig to length(Buffer) do 37 | if not (Buffer[Count] in ['0'..'9']) then goto 2; 38 | Count:=length(Buffer)+1; 39 | 2: 40 | val(copy(Buffer,FirstDig,Count-FirstDig),Nbr,Err); 41 | if (Err=0) and (Nbr>ErrCode) then ErrCode:=Nbr else inc(ErrCode); 42 | end; 43 | 44 | procedure ReadMsg; 45 | begin if eof(Messages) then begin Buffer:=''; EndOfMessage:=true; exit end; 46 | readln(Messages,Buffer); 47 | EndOfMessage := (length(Buffer)<>0) and (Buffer[1]='#'); 48 | end; 49 | 50 | label EndOfErrors; 51 | 52 | begin { Main } 53 | 54 | if paramcount <> 2 then 55 | begin 56 | Noise; 57 | DrawMizarScreen('Appending Errors Explanations'); 58 | writeln('Syntax: addfmsg ArticleName ErrorsExplanationFileName'); 59 | FinishDrawing; 60 | Halt(1); 61 | end; 62 | 63 | GetMizFileName('.miz'); 64 | 65 | ErrNbr:=0; 66 | for i:=1 to MaxError do Occurs[i]:=false; 67 | assign(Errors,MizFileName+'.err'); settextbuf(Errors,ErrorsBuff); 68 | {$I-} reset(Errors); {$I+} 69 | if ioresult<>0 70 | then begin writeln(^G+'Can''t open ',MizFileName+'.err'); halt(1) end; 71 | while not seekeof(Errors) do 72 | begin if ErrNbr >= MaxErrNbr then goto EndOfErrors; 73 | inc(ErrNbr); 74 | readln(Errors,Line,Col,Code); 75 | if (Code > 0) and (Code <= MaxError) then Occurs[Code]:=true; 76 | end; 77 | EndOfErrors: 78 | close(Errors); 79 | if ErrNbr = 0 then halt; 80 | assign(Source,MizFileName+ArticleExt); 81 | settextbuf(Source,SourceBuff); 82 | {$I-} append(Source); {$I+} 83 | if ioresult<>0 84 | then begin writeln(^G+'Can''t open ',MizFileName,ArticleExt); halt(1); end; 85 | 86 | assign(Messages,paramstr(2)+'.msg'); 87 | settextbuf(Messages,MessagesBuff); 88 | {$I-} reset(Messages);{$I+} 89 | if ioresult<>0 90 | then begin writeln(^G+'Can''t open ',paramstr(2)+'.msg'); halt(1) end; 91 | repeat ReadMsg until EndOfMessage; 92 | readln(Messages); 93 | ReadMsg; 94 | if not EndOfMessage then ReadMsg; 95 | ErrCode:=0; 96 | GetErrCode; 97 | Buffer:=' '; 98 | writeln(Source,'::>'); 99 | ReadMsg; 100 | for i:=1 to MaxError do 101 | if Occurs[i] then 102 | begin 103 | while ErrCode < i do 104 | begin while not EndOfMessage do ReadMsg; GetErrCode; ReadMsg end; 105 | if i=ErrCode then 106 | begin 107 | if EndOfMessage then writeln(Source,'::> ',ErrCode:1,': ?') 108 | else 109 | begin writeln(Source,'::> ',ErrCode:1,': ',Buffer); 110 | ReadMsg; 111 | while not EndOfMessage do 112 | begin writeln(Source,'::> ',Buffer); ReadMsg end; 113 | end; 114 | GetErrCode; 115 | ReadMsg; 116 | end 117 | else writeln(Source,'::> ',i:1,': ???'); 118 | end; 119 | close(Source); 120 | end. 121 | -------------------------------------------------------------------------------- /addtools/chkerr.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program ChkErr; 11 | 12 | uses mizenv; 13 | var ErrorsFile: text; 14 | 15 | begin if paramcount = 0 then halt(1); 16 | GetMizFileName(''); 17 | assign(ErrorsFile,MizFileName+'.err'); {$I-} reset(ErrorsFile); {$I+} 18 | if ioresult<> 0 then 19 | begin writeln(^G+^G+'Can''t open ',MizFileName+'.err'); halt(2) end; 20 | if not seekeof(ErrorsFile) then begin close(ErrorsFile); halt(1) end; 21 | close(ErrorsFile); 22 | end. 23 | -------------------------------------------------------------------------------- /addtools/commextr.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program CommentsExtract; 12 | 13 | uses pcmizver,monitor,mizenv; 14 | 15 | var InFile,CMM:text; 16 | InFileBuf: array[1..$6000] of char; 17 | CommBuf: array[1..$1000] of char; 18 | Line:string; x:integer; 19 | begin 20 | writeln('Comments Extractor, Version 1.0 ',Copyright); 21 | if ParamCount = 0 then 22 | begin 23 | writeln('Syntax: COMMEXTR ArticleName'); 24 | writeln; 25 | end; 26 | GetMizFileName('.evd'); 27 | InitExitProc; 28 | FileExam(MizFileName+ArticleExt); 29 | writeln('Processing ',MizFileName+ArticleExt); writeln; 30 | assign(InFile,MizFileName+ArticleExt); settextbuf(InFile,InFileBuf); 31 | reset(InFile); 32 | assign(CMM,MizFileName+'.cmm'); settextbuf(CMM,CommBuf); 33 | rewrite(CMM); 34 | while not seekeof(InFile) do 35 | begin 36 | readln(InFile,Line); x:=Pos('::',Line); 37 | if x > 0 then writeln(CMM,copy(Line,x,length(Line))); 38 | end; 39 | close(CMM); close(InFile) 40 | end. 41 | -------------------------------------------------------------------------------- /addtools/edtfile.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program EdtFile; 12 | 13 | uses pcmizver,mizenv,edt_han,monitor,mconsole; 14 | 15 | var Copying: boolean; 16 | TargetFileName: string; 17 | begin 18 | DrawMizarScreen('Editor'); 19 | if ParamCount = 0 then 20 | begin 21 | writeln('Syntax: edtfile ArticleName [-c] [-79]'); 22 | halt(1); 23 | end; 24 | InitExitProc; 25 | GetArticleName; 26 | TargetFileName:=MizFileName+'.$-$'; 27 | FileExam(MizFileName+ArticleExt); 28 | FileExam(MizFileName+'.edt'); 29 | writeln(MizFileName+ArticleExt,' => ',TargetFileName); 30 | Copying:=true; 31 | if paramcount>1 then 32 | if ParamStr(2) = '-c' then Copying:=false 33 | else if paramcount>2 then 34 | if ParamStr(3) = '-c' then Copying:=false; 35 | if paramcount>1 then 36 | if ParamStr(2) = '-79' then gForceShortLines:=false 37 | else if paramcount>2 then 38 | if ParamStr(3) = '-79' then gForceShortLines:=false; 39 | EditFile(MizFileName+ArticleExt,TargetFileName,Copying); 40 | FinishDrawing; 41 | end. 42 | -------------------------------------------------------------------------------- /addtools/errflag.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Errflag; 11 | 12 | uses mizenv,mconsole; 13 | 14 | const MaxErrNbr = 5000; 15 | 16 | type ErrDes = record Line,Col,Code: integer; end; 17 | 18 | var 19 | Source, Listing: text; SourceBuff, ListingBuff: array[0..$6000] of char; 20 | Errors: text; ErrorsBuff: array[0..$1000] of char; 21 | Error: array[0..MaxErrNbr+1] of ErrDes; 22 | CurrentError: ErrDes; 23 | ErrNbr, ErrNr, RmFlagNbr: integer; 24 | ErrorOvfl: boolean; 25 | i, j: integer; 26 | Buffer: string; Ch: char; 27 | SourceLine,TargetCol: integer; 28 | aFileName,FileExt: string; 29 | 30 | label Earlier,EndOfErrors; 31 | begin 32 | if paramcount <1 then 33 | begin 34 | Noise; 35 | DrawMizarScreen('Put Error Flags'); 36 | writeln('Syntax: errflag filename'); 37 | FinishDrawing; 38 | halt(1); 39 | end; 40 | GetFileExtName(1,'.miz',aFileName,FileExt); 41 | assign(Source,aFileName+FileExt); 42 | settextbuf(Source,SourceBuff); 43 | {$I-} reset(Source); {$I+} 44 | if ioresult<>0 then 45 | begin writeln(^G+'Can''t open ',aFileName+FileExt); halt(2); end; 46 | ErrNbr:=0; ErrorOvfl:=false; 47 | assign(Errors,aFileName+'.err'); settextbuf(Errors,ErrorsBuff); 48 | {$I-} reset(Errors); {$I+} 49 | if ioresult<>0 then halt(2); 50 | while not seekeof(Errors) do 51 | begin 52 | if ErrNbr >= MaxErrNbr then begin ErrorOvfl:=true; goto EndOfErrors end; 53 | inc(ErrNbr); 54 | with Error[ErrNbr] do readln(Errors,Line,Col,Code); 55 | end; 56 | EndOfErrors: 57 | close(Errors); 58 | for i := 2 to ErrNbr do 59 | begin CurrentError:=Error[i]; 60 | for j:=i-1 downto 1 do 61 | begin if CurrentError.Line > Error[j].Line then goto Earlier; 62 | if CurrentError.Line = Error[j].Line then 63 | if CurrentError.Col >= Error[j].Col then goto Earlier; 64 | Error[j+1]:=Error[j]; 65 | end; 66 | j:=0; 67 | Earlier: 68 | Error[j+1]:=CurrentError 69 | end; 70 | if ErrorOvfl then Error[MaxErrNbr].Code:=499; 71 | Error[ErrNbr+1].Line:=-1; 72 | ErrNr:=1; 73 | assign(Listing,aFileName+'.$$$'); settextbuf(Listing,ListingBuff); 74 | rewrite(Listing); 75 | SourceLine:=0; RmFlagNbr:=0; 76 | while not eof(Source) do 77 | begin inc(SourceLine); read(Source,Buffer); 78 | if pos('::>',Buffer) <> 1 then 79 | begin 80 | write(Listing,Buffer); 81 | while not eoln(Source) do begin read(Source,Ch); write(Listing,Ch) end; 82 | writeln(Listing); 83 | if SourceLine=Error[ErrNr].Line then 84 | begin write(Listing,'::>'); TargetCol:=4; 85 | while (SourceLine=Error[ErrNr].Line) do 86 | with Error[ErrNr] do 87 | begin 88 | if col>=TargetCol then 89 | begin if col>TargetCol then write(Listing,' ': col-TargetCol); 90 | TargetCol:=col; write(Listing,'*'); 91 | end 92 | else write(Listing,','); 93 | if Code<10 then inc(TargetCol,2) 94 | else if Code<100 then inc(TargetCol,3) 95 | else inc(TargetCol,4); 96 | write(Listing,Code:1); inc(ErrNr); 97 | end; 98 | writeln(Listing); 99 | while SourceLine = Error[ErrNr].Line do inc(ErrNr); 100 | end; 101 | end else inc(RmFlagNbr); 102 | readln(Source); 103 | end; 104 | close(Source); close(Listing); 105 | if (ErrNbr = 0) and (RmFlagNbr = 0) 106 | then erase(Listing) 107 | else begin erase(Source); rename(Listing,aFileName+FileExt) end; 108 | end. 109 | -------------------------------------------------------------------------------- /addtools/mglue.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program MGlue; 11 | 12 | uses pcmizver,mizenv,errhan,monitor; 13 | 14 | const BuffSize = $E000; 15 | var Buffer: array[0..BuffSize] of char; 16 | SourceText,TargetText: file; 17 | i: word; 18 | NumRead, NumWritten: integer; 19 | label 1; 20 | begin 21 | writeln('Mglue, ',PCMizarVersionStr); 22 | writeln(Copyright); 23 | if ParamCount = 0 then 24 | begin 25 | writeln('Syntax: mglue ArticleName'); 26 | writeln; 27 | Halt(1); 28 | end; 29 | GetMizFileName(''); 30 | FileExam(MizFileName+'.evd'); FileExam(MizFileName+'.tpr'); 31 | writeln('Processing ',MizFileName); 32 | InitExitProc; 33 | assign(TargetText,MizFileName+'.miz'); 34 | rewrite(TargetText,1); 35 | assign(SourceText,MizFileName+'.evd'); 36 | reset(SourceText,1); 37 | repeat BlockRead(SourceText,Buffer, SizeOf(Buffer),NumRead); 38 | for i:=NumRead downto 1 do if Buffer[i] = ^Z then 39 | begin Numread:=i; goto 1 end; 40 | 1: 41 | BlockWrite(TargetText,Buffer,NumRead,NumWritten); 42 | until (NumRead = 0) or (NumWritten <> NumRead); 43 | close(SourceText); 44 | assign(SourceText,MizFileName+'.tpr'); 45 | reset(SourceText,1); 46 | repeat BlockRead(SourceText,Buffer, SizeOf(Buffer),NumRead); 47 | BlockWrite(TargetText,Buffer,NumRead,NumWritten); 48 | until (NumRead = 0) or (NumWritten <> NumRead); 49 | close(SourceText); 50 | close(TargetText); 51 | end. 52 | -------------------------------------------------------------------------------- /addtools/msplit.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program MSplit; 11 | 12 | uses pcmizver,mizenv,librenv,monitor,errhan,mscanner,mconsole; 13 | 14 | var SourceBuff, TargetBuff: array[0..$6000] of char; 15 | PosBegin: Position; 16 | SourceText, TargetText: text; 17 | SourceLine: string; 18 | LineNbr: integer; 19 | 20 | function EmptyLine: boolean; 21 | var K:integer; Line: string; 22 | begin Line:=Copy(SourceLine,1,PosBegin.Col-1); 23 | for K:=1 to PosBegin.Col-1 do 24 | if Line[K]<>' ' then begin EmptyLine:=false; exit end; 25 | EmptyLine:=true; 26 | end; 27 | 28 | begin 29 | writeln('Msplit, ',PCMizarVersionStr); 30 | writeln(Copyright); 31 | if ParamCount = 0 then 32 | begin 33 | writeln('Syntax: msplit [-l] ArticleName'); 34 | writeln; 35 | end; 36 | GetOptions; 37 | GetMizFileName('.miz'); 38 | FileExam(MizFileName+'.miz'); 39 | writeln('Processing ',MizFileName,'.miz'); 40 | OpenErrors(MizFileName); 41 | FileExam(MizFiles+'mizar.dct'); 42 | InitSourceFile(MizFileName+ArticleExt,MizFiles+'mizar'); 43 | ReadToken; 44 | if CurWord.Kind <> sy_Environ then ErrImm(212); 45 | while (CurWord.Kind <> sy_Begin) and (CurWord.Kind <> EOT) do ReadToken; 46 | if CurWord.Kind <> sy_Begin then ErrImm(213); 47 | PosBegin:=CurPos; dec(PosBegin.Col,4); 48 | CloseSourceFile; 49 | if ErrorNbr = 1 then 50 | begin writeln('**** One error detected.'); halt(1) end 51 | else if ErrorNbr > 1 then 52 | begin writeln('**** ',ErrorNbr,' error(s) detected.'); halt(1) end; 53 | assign(SourceText,MizFileName+'.miz'); settextbuf(SourceText,SourceBuff); 54 | reset(SourceText); 55 | assign(TargetText,MizFileName+'.evd'); settextbuf(TargetText,TargetBuff); 56 | rewrite(TargetText); 57 | LineNbr:=1; readln(SourceText,SourceLine); 58 | while LineNbr < PosBegin.Line do 59 | begin writeln(TargetText,SourceLine); 60 | readln(SourceText,SourceLine); inc(LineNbr); 61 | end; 62 | if PosBegin.Col > 1 then 63 | begin 64 | if not EmptyLine then 65 | writeln(TargetText,Copy(SourceLine,1,PosBegin.Col-1)); 66 | delete(SourceLine,1,PosBegin.Col-1); 67 | end; 68 | close(TargetText); 69 | assign(TargetText,MizFileName+'.tpr'); settextbuf(TargetText,TargetBuff); 70 | rewrite(TargetText); 71 | writeln(TargetText,SourceLine); 72 | while not eof(SourceText) do 73 | begin readln(SourceText,SourceLine); writeln(TargetText,SourceLine) end; 74 | close(TargetText); 75 | close(SourceText); 76 | end. 77 | -------------------------------------------------------------------------------- /addtools/prune.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Pruner; 11 | 12 | uses pcmizver,mizenv; 13 | 14 | var InFile,OutFile: text; 15 | InFileBuf,OutFileBuf: array[1..$6000] of char; 16 | Line: string; Options: string; 17 | lCom,i,lEmptyLinesNbr: integer; 18 | RemEmptyLines,RemComments,Prunning: boolean; 19 | TargetFileName: string; 20 | begin 21 | writeln('Pruner, Version 2.0 ',Copyright); 22 | if ParamCount = 0 then 23 | begin 24 | writeln('Syntax: prune ArticleName [-[lc]]'); 25 | writeln; 26 | writeln('Options:'); 27 | writeln(' -l Remove empty lines'); 28 | writeln(' -c Remove comments'); 29 | writeln; 30 | halt(2); 31 | end; 32 | GetMizFileName('.miz'); 33 | TargetFileName:=MizFileName+'.$-$'; 34 | RemEmptyLines:=false; 35 | RemComments:=false; 36 | Prunning:=false; 37 | if paramcount>1 then 38 | begin 39 | Options:=ParamStr(2); 40 | if Options[1] <> '-' then 41 | if paramcount>2 then 42 | begin Options:=ParamStr(3); 43 | if Options[1] <> '-' then Options:=''; 44 | end 45 | else Options:=''; 46 | if Pos('l',Options) <> 0 then RemEmptyLines:=true; 47 | if Pos('c',Options) <> 0 then RemComments:=true; 48 | end; 49 | FileExam(MizFileName+ArticleExt); 50 | writeln(MizFileName+ArticleExt,' => ',TargetFileName); 51 | assign(InFile,MizFileName+ArticleExt); settextbuf(InFile,InFileBuf); 52 | reset(InFile); 53 | assign(OutFile,TargetFileName); settextbuf(OutFile,OutFileBuf); 54 | rewrite(OutFile); 55 | lEmptyLinesNbr:=0; 56 | while not eof(InFile) do 57 | begin 58 | readln(InFile,Line); 59 | if RemComments then 60 | begin 61 | lCom:=pos('::',Line); 62 | if lCom > 0 then 63 | begin 64 | delete(Line,lCom,length(Line)); 65 | Prunning:=true; 66 | end; 67 | end; 68 | if length(line) <> 0 then while Line[length(line)] = ' ' do 69 | begin 70 | delete(Line,length(Line),1); 71 | Prunning:=true; 72 | end; 73 | if length(Line) = 0 then inc(lEmptyLinesNbr) 74 | else 75 | begin 76 | if lEmptyLinesNbr > 0 then 77 | if RemEmptyLines then Prunning:=true 78 | else 79 | begin 80 | for i:=1 to lEmptyLinesNbr do writeln(OutFile); 81 | lEmptyLinesNbr:=0; 82 | end; 83 | writeln(OutFile,Line); 84 | end; 85 | end; 86 | close(InFile); 87 | close(OutFile); 88 | if not Prunning then halt(1); 89 | end. 90 | 91 | -------------------------------------------------------------------------------- /addtools/remflags.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program RemErrf; 11 | 12 | uses mizenv,mconsole; 13 | 14 | var 15 | Source, Listing: text; SourceBuff, ListingBuff: array[0..$6000] of char; 16 | RmFlagNbr: integer; 17 | Buffer: string; 18 | 19 | begin 20 | if paramcount <1 then 21 | begin 22 | Noise; 23 | DrawMizarScreen('Remove Error Flags'); 24 | writeln('Syntax: remflags articlename'); 25 | FinishDrawing; 26 | halt(1) 27 | end; 28 | GetMizFileName(''); 29 | assign(Source,MizFileName+ArticleExt); 30 | settextbuf(Source,SourceBuff); 31 | {$I-} reset(Source); {$I+} 32 | if ioresult<>0 then 33 | begin writeln(^G+'Can''t open ',MizFileName); halt(2); end; 34 | assign(Listing,MizFileName+'.$$$'); settextbuf(Listing,ListingBuff); 35 | rewrite(Listing); 36 | RmFlagNbr:=0; 37 | while not eof(Source) do 38 | begin readln(Source,Buffer); 39 | if pos('::>',Buffer) <> 1 then writeln(Listing,Buffer) 40 | else inc(RmFlagNbr); 41 | end; 42 | close(Source); close(Listing); 43 | if RmFlagNbr = 0 then erase(Listing) else 44 | begin erase(Source); 45 | rename(Listing,MizFileName+ArticleExt); 46 | end 47 | end. 48 | -------------------------------------------------------------------------------- /base/errhan.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit errhan; 8 | 9 | interface 10 | 11 | type Position = record Line,Col: integer end; 12 | 13 | ErrorReport = procedure(Pos:Position; ErrNr:integer); 14 | 15 | const ZeroPos : Position = (Line:0; Col:0); 16 | 17 | var CurPos: Position; 18 | ErrorNbr: integer; 19 | 20 | PutError: ErrorReport = nil; 21 | 22 | RTErrorCode: integer = 0; 23 | OverflowErroor: boolean = false; 24 | 25 | procedure Error(Pos:Position; ErrNr:integer); 26 | procedure ErrImm(ErrNr:integer); 27 | 28 | procedure WriteError(Pos:Position; ErrNr:integer); 29 | procedure OpenErrors(FileName:string); 30 | procedure AppendErrors(FileName:string); 31 | procedure EraseErrors; 32 | procedure CloseErrors; 33 | 34 | procedure OverflowError(ErrorCode:word); 35 | procedure Mizassert (ErrorCode:word; Cond:boolean); 36 | procedure RunTimeError(ErrorCode:word); 37 | 38 | implementation 39 | 40 | uses mconsole,mizenv; 41 | 42 | procedure Error(Pos:Position; ErrNr:integer); 43 | begin inc(ErrorNbr); 44 | if @PutError <> nil then PutError(Pos,ErrNr); 45 | if StopOnError then 46 | begin 47 | DrawMessage('Stopped on first error',''); 48 | Halt(1); 49 | end; 50 | end; 51 | 52 | procedure ErrImm(ErrNr:integer); 53 | begin 54 | Error(CurPos,ErrNr); 55 | end; 56 | 57 | var 58 | Errors: text; 59 | OpenedErrors: boolean = false; 60 | 61 | procedure WriteError(Pos:Position; ErrNr:integer); 62 | begin 63 | if not OpenedErrors then RunTimeError(2001); 64 | with Pos do writeln(Errors,Line,' ',Col,' ',ErrNr); 65 | end; 66 | 67 | procedure OpenErrors(FileName:string); 68 | begin 69 | if ExtractFileExt(FileName)='' then FileName:=FileName+'.err'; 70 | assign(Errors,FileName); 71 | {$I-} 72 | rewrite(Errors); 73 | {$I+} 74 | if IOResult <> 0 then 75 | begin 76 | DrawMessage('Can''t open errors file '''+FileName+''' for writing',''); 77 | halt(1); 78 | end; 79 | OpenedErrors:=true; 80 | ErrorNbr:=0; with CurPos do begin Line:=1; Col:=1 end; 81 | if @PutError = nil then PutError:=WriteError; 82 | end; 83 | 84 | procedure AppendErrors(FileName:string); 85 | begin 86 | OpenedErrors:=true; 87 | if ExtractFileExt(FileName)='' then FileName:=FileName+'.err'; 88 | assign(Errors,FileName); 89 | ErrorNbr:=0; 90 | with CurPos do begin Line:=1; Col:=1 end; 91 | {$I-} append(Errors); {$I+} 92 | if ioresult<>0 then rewrite(Errors); 93 | end; 94 | 95 | procedure EraseErrors; 96 | begin 97 | if OpenedErrors then 98 | begin 99 | OpenedErrors:=false; 100 | close(Errors); erase(Errors); 101 | end; 102 | end; 103 | 104 | procedure CloseErrors; 105 | begin 106 | if OpenedErrors then 107 | begin 108 | OpenedErrors:=false; 109 | close(Errors); 110 | end; 111 | end; 112 | 113 | procedure OverflowError(ErrorCode:word); 114 | begin 115 | RTErrorCode:=ErrorCode; 116 | OverflowErroor:=true; 117 | RunError(97); 118 | end; 119 | 120 | procedure Mizassert( ErrorCode:word; Cond: boolean ); 121 | begin 122 | if not Cond then 123 | begin 124 | RTErrorCode:=ErrorCode; 125 | RunError(98); 126 | end; 127 | end; 128 | 129 | procedure RunTimeError(ErrorCode:word); 130 | begin 131 | RTErrorCode:=ErrorCode; 132 | RunError(99); 133 | end; 134 | 135 | end. 136 | -------------------------------------------------------------------------------- /base/esmprocessor.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Even_More_Strict_Mizar_Processor; 11 | 12 | uses mizenv, mstate, errhan, mconsole, 13 | _formats, wsmarticle, 14 | block_and_item, first_identification 15 | {$IFDEF MDEBUG} ,info {$ENDIF}; 16 | 17 | procedure ESMAnalyzer; 18 | var lWSTextProper: wsTextProperPtr; 19 | lMizArticle: ProcessingArticlePtr; 20 | begin 21 | FileExam(EnvFileName+'.frx'); 22 | gFormatsColl.LoadFormats(EnvFileName+'.frx'); 23 | lWSTextProper:=Read_WSMizArticle((MizFileName+'.wsx')); 24 | lMizArticle:=new(FirstIdentArticlePtr,Init(lWSTextProper)); 25 | InitPass('First Identyfication '); 26 | lMizArticle^.nDisplayInformationOnScreen:=true; 27 | lMizArticle^.Process_Article; 28 | FinishPass; 29 | // InitPass('XML '); 30 | Write_MSMizArticle(lWSTextProper,MizFileName+'.msx'); 31 | // FinishPass; 32 | InitPass('Printing '); 33 | Print_MSMizArticle(lWSTextProper,MizFileName+'.msm'); 34 | FinishPass; 35 | dispose(lMizArticle,Done); 36 | // dispose(lWSTextProper,Done); 37 | end; 38 | 39 | begin 40 | InitProcessing('More Strict Mizar Processor','.msm'); 41 | ESMAnalyzer; 42 | ProcessingEnding; 43 | end. 44 | 45 | -------------------------------------------------------------------------------- /base/info.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit info; 8 | 9 | interface 10 | 11 | uses errhan; 12 | 13 | var InfoFile: text; 14 | 15 | procedure InfoChar ( C: char ); 16 | procedure InfoInt ( I: integer ); 17 | procedure InfoWord ( C: char; I: integer ); 18 | procedure InfoNewLine; 19 | procedure InfoString ( S: string ); 20 | procedure InfoPos ( Pos: Position ); 21 | procedure InfoCurPos; 22 | 23 | procedure OpenInfoFile; 24 | procedure CloseInfofile; 25 | 26 | implementation 27 | 28 | uses mizenv,mconsole; 29 | 30 | procedure InfoChar ( C: char ); 31 | begin write(InfoFile,C) end; 32 | 33 | procedure InfoInt ( I: integer ); 34 | begin write(InfoFile,I,' ') end; 35 | 36 | procedure InfoWord ( C: char; I: integer ); 37 | begin write(InfoFile,C,I,' ') end; 38 | 39 | procedure InfoNewLine; 40 | begin writeln(InfoFile) end; 41 | 42 | procedure InfoString ( S: string ); 43 | begin write(InfoFile,S) end; 44 | 45 | procedure InfoPos ( Pos: Position ); 46 | begin with Pos do write(InfoFile,Line,' ',Col,' ') end; 47 | 48 | procedure InfoCurPos; 49 | begin with CurPos do write(InfoFile,Line,' ',Col,' ') end; 50 | 51 | var _InfoExitProc:pointer; 52 | 53 | procedure InfoExitProc; 54 | begin 55 | CloseInfoFile; 56 | ExitProc:=_InfoExitProc; 57 | end; 58 | 59 | procedure OpenInfoFile; 60 | begin 61 | assign(InfoFile,MizFileName+'.inf'); 62 | rewrite(InfoFile); 63 | writeln(InfoFile,'Mizared article: "',MizFileName,'"'); 64 | _InfoExitProc := ExitProc; 65 | ExitProc:=@InfoExitProc; 66 | end; 67 | 68 | procedure CloseInfofile; 69 | begin close(InfoFile) end; 70 | 71 | end. 72 | -------------------------------------------------------------------------------- /base/monitor.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit monitor; 8 | 9 | interface 10 | 11 | procedure InitExitProc; 12 | 13 | implementation 14 | 15 | uses 16 | {$IFDEF FPC} 17 | {$IFNDEF WIN32} 18 | baseunix, 19 | {$ENDIF} 20 | {$ENDIF} 21 | mizenv,errhan,mconsole 22 | {$IFDEF WIN32} ,windows {$ENDIF} 23 | {$IFDEF MDEBUG} ,info {$ENDIF}; 24 | 25 | var 26 | _ExitProc: pointer; 27 | _IOResult:integer; 28 | 29 | procedure _Halt_(ErrorCode: word); 30 | begin 31 | _IOResult:=IOResult; 32 | ErrorAddr:=nil; 33 | if ErrorCode>1 then 34 | case ErrorCode of 35 | 2..4: begin ErrImm(1000+ErrorCode); 36 | DrawMessage('I/O error',ErrMsg[ErrorCode]) 37 | end; 38 | 5..6: begin ErrImm(1000+ErrorCode); BugInProcessor end; 39 | 12: begin ErrImm(1000+ErrorCode); BugInProcessor end; 40 | 97,98,99: 41 | begin ErrImm(RTErrorCode); 42 | case RTErrorCode of 43 | 800,804: DrawMessage('Library Corrupted',''); 44 | 857: DrawMessage('Connection Fault',''); 45 | // 900..999: DrawMessage('Mizar parameter overflow: '+IntToStr(RTErrorCode),''); 46 | 1255: DrawMessage('User break',''); 47 | else 48 | if OverflowErroor then 49 | DrawMessage('Mizar parameter overflow: '+IntToStr(RTErrorCode),'') 50 | else BugInProcessor 51 | end; 52 | end; 53 | 100..101: begin ErrImm(1000+ErrorCode); 54 | DrawMessage('I/O error',ErrMsg[ErrorCode-95]); 55 | end; 56 | 102..106: begin ErrImm(1000+ErrorCode); BugInProcessor end; 57 | 150..162: begin ErrImm(1000+ErrorCode); 58 | DrawMessage('I/O error','Critical disk error'); 59 | end; 60 | 200..201: begin ErrImm(1000+ErrorCode); BugInProcessor end; 61 | 202: begin ErrImm(1000+ErrorCode); DrawMessage('Stack overflow error','') end; 62 | 203,204: begin ErrImm(1000+ErrorCode); DrawMessage('Heap overflow error','') end; 63 | 208: begin ErrImm(1000+ErrorCode); DrawMessage('Overlay manager not installed','') end; 64 | 209: begin ErrImm(1000+ErrorCode); DrawMessage('Overlay file read error','') end; 65 | 210..212: begin ErrImm(1000+ErrorCode); BugInProcessor end; 66 | 213: begin ErrImm(1000+ErrorCode); DrawMessage('Collection Index out of range','') end; 67 | 214: begin ErrImm(1000+ErrorCode); DrawMessage('Collection overflow error','') end; 68 | 215: begin ErrImm(1000+ErrorCode); DrawMessage('Arithmetic overflow error','') end; 69 | 216: begin ErrImm(1000+ErrorCode); DrawMessage('General Protection fault','') end; 70 | 217: begin ErrImm(1000+ErrorCode); DrawMessage('Segmentation fault','') end; 71 | 218..254: begin ErrImm(1000+ErrorCode); BugInProcessor end; 72 | 255: ErrImm(1000+ErrorCode); 73 | else 74 | begin ErrImm(ErrorCode); 75 | if OverflowErroor then 76 | DrawMessage('Mizar parameter overflow error','') 77 | else BugInProcessor 78 | end; 79 | end; 80 | CloseErrors; 81 | ExitProc:=_ExitProc; 82 | if (ErrorCode = 0) and (ErrorNbr <> 0) then Halt(1) else Halt(ErrorCode); 83 | end; 84 | 85 | procedure MizExitProc; 86 | begin 87 | {$IFDEF IODEBUG} 88 | ExitProc:=_ExitProc; 89 | {$ELSE} 90 | _Halt_(ExitCode); 91 | {$ENDIF} 92 | end; 93 | 94 | procedure InitExitProc; 95 | begin ExitProc := @MizExitProc end; 96 | 97 | 98 | {$IFDEF FPC} 99 | {$IFNDEF WIN32} 100 | procedure CatchSignal(aSig : Integer);cdecl; 101 | begin 102 | case aSig of 103 | SIGINT,SIGQUIT,SIGTERM: 104 | begin 105 | CtrlCPressed:=true; 106 | RunTimeError(1255); 107 | end; 108 | end; 109 | end; 110 | 111 | var NewSignal, OldSigInt : SignalHandler; 112 | 113 | procedure InitCtrl; 114 | begin 115 | NewSignal:=SignalHandler(@CatchSignal); 116 | OldSigInt:=fpSignal(SIGINT,NewSignal); 117 | OldSigInt:=fpSignal(SIGQUIT,NewSignal); 118 | OldSigInt:=fpSignal(SIGTERM,NewSignal); 119 | end; 120 | {$ENDIF} 121 | {$ENDIF} 122 | 123 | {$IFDEF WIN32} 124 | {$IFDEF FPC} 125 | function CtrlSignal(aSignal: DWORD): WINBOOL ;stdcall; 126 | {$ENDIF} 127 | {$IFDEF DELPHI} 128 | function CtrlSignal(aSignal: DWORD): BOOL; cdecl; 129 | {$ENDIF} 130 | begin 131 | { TRUE: do not call next handler in the queue, FALSE: call it } 132 | {case aSignal of 133 | CTRL_C_EVENT: Writeln('Ctrl+C'); 134 | CTRL_BREAK_EVENT: Writeln('Ctrl+Break'); 135 | CTRL_CLOSE_EVENT: Writeln('Close'); 136 | CTRL_LOGOFF_EVENT: Writeln('Logoff'); 137 | CTRL_SHUTDOWN_EVENT: Writeln('Shutdown'); 138 | else 139 | Writeln('Unexpected signal'); 140 | end;} 141 | CtrlCPressed:=true; 142 | RunTimeError(1255); 143 | CtrlSignal := true; 144 | {ExitProcess(1);} 145 | end; 146 | {$IFDEF FPC} 147 | procedure InitCtrl; 148 | begin 149 | SetConsoleCtrlHandler(CtrlSignal, TRUE); 150 | end; 151 | {$ENDIF} 152 | {$IFDEF DELPHI} 153 | procedure InitCtrl; 154 | var 155 | ConsoleMode,lConsoleMode: DWORD; 156 | begin 157 | if GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ConsoleMode) then 158 | begin 159 | lConsoleMode := ConsoleMode or ENABLE_PROCESSED_INPUT; 160 | { Treat Ctrl+C as a signal } 161 | if SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), lConsoleMode) then 162 | begin 163 | SetConsoleCtrlHandler(@CtrlSignal, TRUE); 164 | end; 165 | end; 166 | end; 167 | {$ENDIF} 168 | {$ENDIF} 169 | 170 | begin 171 | _ExitProc := ExitProc; 172 | InitCtrl; 173 | end. 174 | -------------------------------------------------------------------------------- /base/msmprocessor.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program More_Strict_Mizar_Processor; 11 | 12 | uses mizenv, pcmizver, monitor, errhan, mconsole, mtime, 13 | _formats, wsmarticle, block_and_item,first_identification 14 | {$IFDEF MDEBUG} ,info {$ENDIF}; 15 | 16 | var PassTime: longint; 17 | 18 | procedure InitPass(const aPassName: string); 19 | begin 20 | CurPos.Line:=1; 21 | CurPos.Col:=1; 22 | InitDisplayLine(aPassName); 23 | TimeMark(PassTime); 24 | end; 25 | 26 | procedure FinishPass; 27 | begin 28 | FinishingPass:=true; 29 | if QuietMode then DisplayLine(CurPos.Line,ErrorNbr); 30 | FinishingPass:=false; 31 | DrawTime(' '+ReportTime(PassTime)); 32 | end; 33 | 34 | procedure ParserError(Pos:Position; ErrNr:integer); 35 | begin 36 | WriteError(Pos,ErrNr); 37 | DisplayLine(CurPos.Line,ErrorNbr); 38 | end; 39 | 40 | var _WSMizExitProc: pointer; 41 | procedure WSMizarExitProc; 42 | begin 43 | ExitProc:=_WSMizExitProc; 44 | {$I-} 45 | if IOResult<>0 then; 46 | if not StopOnError then DisplayLine(CurPos.Line,ErrorNbr); 47 | PutError:=WriteError; 48 | DrawVerifierExit(ReportTime(gStartTime)); 49 | { Halt(ErrorCode);} 50 | {$I+} 51 | end; 52 | 53 | procedure InitAnalyzing(const aProgName: string); 54 | begin 55 | DrawMizarScreen(aProgName); 56 | if paramcount<1 then EmptyParameterList; 57 | GetArticleName; 58 | GetEnvironName; 59 | DrawArticleName(MizFileName+'.wsx'); 60 | GetOptions; 61 | InitExitProc; 62 | FileExam(MizFileName+'.wsx'); 63 | _WSMizExitProc := ExitProc; 64 | ExitProc:=@WSMizarExitProc; 65 | PutError:=ParserError; 66 | OpenErrors(MizFileName); 67 | {$IFDEF MDEBUG} 68 | OpenInfoFile; 69 | {$ENDIF} 70 | end; 71 | 72 | procedure MSMAnalyzer; 73 | var lWSTextProper: wsTextProperPtr; 74 | lMizArticle: ProcessingArticlePtr; 75 | begin 76 | FileExam(EnvFileName+'.frx'); 77 | gFormatsColl.LoadFormats(EnvFileName+'.frx'); 78 | lWSTextProper:=Read_WSMizArticle((MizFileName+'.wsx')); 79 | lMizArticle:=new(FirstIdentArticlePtr,Init(lWSTextProper)); 80 | InitPass('First Identyfication '); 81 | lMizArticle^.nDisplayInformationOnScreen:=true; 82 | lMizArticle^.Process_Article; 83 | FinishPass; 84 | // InitPass('XML '); 85 | Write_MSMizArticle(lWSTextProper,MizFileName+'.msx'); 86 | // FinishPass; 87 | InitPass('Printing '); 88 | Print_MSMizArticle(lWSTextProper,MizFileName+'.msm'); 89 | FinishPass; 90 | dispose(lMizArticle,Done); 91 | // dispose(lWSTextProper,Done); 92 | end; 93 | 94 | begin 95 | InitAnalyzing('More Strict Mizar Processor'); 96 | // Parsing; 97 | MSMAnalyzer; 98 | if ErrorNbr > 0 then 99 | begin 100 | DrawErrorsMsg(ErrorNbr); 101 | FinishDrawing; 102 | end; 103 | end. 104 | 105 | -------------------------------------------------------------------------------- /base/mstate.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit mstate; 8 | 9 | interface 10 | 11 | procedure InitPass(const aPassName: string); 12 | procedure FinishPass; 13 | procedure InitProcessing(const aProgName,aExt: string); 14 | procedure ProcessingEnding; 15 | 16 | implementation 17 | 18 | uses mizenv, pcmizver, monitor, errhan, mconsole, mtime 19 | {$IFDEF MDEBUG} ,info {$ENDIF}; 20 | 21 | var PassTime: longint; 22 | 23 | procedure InitPass(const aPassName: string); 24 | begin 25 | CurPos.Line:=1; 26 | CurPos.Col:=1; 27 | InitDisplayLine(aPassName); 28 | TimeMark(PassTime); 29 | end; 30 | 31 | procedure FinishPass; 32 | begin 33 | FinishingPass:=true; 34 | if QuietMode then DisplayLine(CurPos.Line,ErrorNbr); 35 | FinishingPass:=false; 36 | DrawTime(' '+ReportTime(PassTime)); 37 | end; 38 | 39 | procedure MError(Pos:Position; ErrNr:integer); 40 | begin 41 | WriteError(Pos,ErrNr); 42 | DisplayLine(CurPos.Line,ErrorNbr); 43 | end; 44 | 45 | var _ExitProc: pointer; 46 | procedure MizarExitProc; 47 | begin 48 | ExitProc:=_ExitProc; 49 | {$I-} 50 | if IOResult<>0 then; 51 | if not StopOnError then DisplayLine(CurPos.Line,ErrorNbr); 52 | PutError:=WriteError; 53 | DrawVerifierExit(ReportTime(gStartTime)); 54 | { Halt(ErrorCode);} 55 | {$I+} 56 | end; 57 | 58 | procedure InitProcessing(const aProgName,aExt: string); 59 | begin 60 | DrawMizarScreen(aProgName); 61 | if paramcount<1 then EmptyParameterList; 62 | GetArticleName; 63 | GetEnvironName; 64 | DrawArticleName(MizFileName+aExt); 65 | GetOptions; 66 | InitExitProc; 67 | FileExam(MizFileName+aExt); 68 | _ExitProc := ExitProc; 69 | ExitProc:=@MizarExitProc; 70 | PutError:=MError; 71 | OpenErrors(MizFileName); 72 | {$IFDEF MDEBUG} 73 | OpenInfoFile; 74 | {$ENDIF} 75 | end; 76 | 77 | procedure ProcessingEnding; 78 | begin 79 | if ErrorNbr > 0 then 80 | begin 81 | DrawErrorsMsg(ErrorNbr); 82 | FinishDrawing; 83 | end; 84 | end; 85 | 86 | end. 87 | 88 | -------------------------------------------------------------------------------- /base/mtime.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit mtime; 8 | 9 | interface 10 | 11 | procedure TimeMark(var W:longint); 12 | function ElapsedTime(W:longint): longint; 13 | procedure MUnpackTime(W:longint; var H,M,S,F: word); 14 | function ReportTime(W:longint): string; 15 | 16 | var 17 | gStartTime: longint; 18 | 19 | implementation 20 | 21 | {$IFDEF DELPHI} 22 | uses windows; 23 | const cmSecs = 1000; 24 | {$ENDIF} 25 | {$IFDEF FPC} 26 | uses dos; 27 | const cmSecs = 100; 28 | type 29 | TSystemTime = 30 | record 31 | wHour:word; 32 | wMinute:word; 33 | wSecond:word; 34 | wMilliseconds:word; 35 | end; 36 | procedure GetLocalTime(var aTime: TSystemTime); 37 | begin 38 | with aTime do GetTime(wHour,wMinute,wSecond,wMilliseconds); 39 | end; 40 | {$ENDIF} 41 | 42 | function SystemTimeToMiliSec(const fTime: TSystemTime): longint; 43 | begin 44 | SystemTimeToMiliSec:=fTime.wHour*(3600*cmSecs)+ 45 | fTime.wMinute*longint(60*cmSecs)+ 46 | fTime.wSecond*cmSecs+ 47 | fTime.wMilliseconds; 48 | end; 49 | 50 | procedure TimeMark(var W:longint); 51 | var SystemTime: TSystemTime; 52 | begin 53 | GetLocalTime(SystemTime); 54 | W:=SystemTimeToMiliSec(SystemTime); 55 | end; 56 | 57 | function ElapsedTime(W:longint): longint; 58 | var T : longint; 59 | SystemTime: TSystemTime; 60 | begin 61 | GetLocalTime(SystemTime); 62 | T := SystemTimeToMiliSec(SystemTime)-W; 63 | if T < 0 then T:=86400*cmSecs+T; 64 | ElapsedTime:=T; 65 | end; 66 | 67 | procedure MUnpackTime(W:longint; var H,M,S,F: word); 68 | begin 69 | H := W div (3600*cmSecs); 70 | M := (W-H*3600*cmSecs) div (60*cmSecs); 71 | S := (W-H*3600*cmSecs-M*60*cmSecs) div cmSecs; 72 | F := W-H*3600*cmSecs-M*60*cmSecs-S*cmSecs; 73 | end; 74 | 75 | function LeadingZero(w : Word) : String; 76 | var lStr: string; 77 | begin 78 | Str(w:0,lStr); 79 | if Length(lStr) = 1 then lStr := '0' + lStr; 80 | LeadingZero := lStr; 81 | end; 82 | 83 | function ReportTime(W:longint): string; 84 | var H,M,S,F: word; lTimeStr: string; 85 | begin 86 | MUnpackTime(ElapsedTime(W),H,M,S,F); 87 | if F >= (cmSecs div 2) then inc(S); 88 | if H<>0 then 89 | begin Str(H,lTimeStr); lTimeStr:=lTimeStr+'.'+LeadingZero(M) end 90 | else Str(M:2,lTimeStr); 91 | ReportTime:=lTimeStr+':'+LeadingZero(S); 92 | end; 93 | 94 | begin 95 | TimeMark(gStartTime); 96 | end. 97 | -------------------------------------------------------------------------------- /base/pcmizver.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit pcmizver; 8 | 9 | interface 10 | 11 | const 12 | PCMizarReleaseNbr = 8; 13 | PCMizarVersionNbr = 2; 14 | PCMizarVariantNbr = 1; 15 | 16 | CurrentYear = 2025; 17 | 18 | {$IFDEF WIN32} 19 | DirSeparator = '\'; 20 | {$ELSE} 21 | DirSeparator = '/'; 22 | {$ENDIF} 23 | 24 | function PCMizarVersionStr: string; 25 | function VersionStr: string; 26 | function PlatformNameStr: string; 27 | function Copyright : string; 28 | 29 | implementation 30 | 31 | function Copyright : string; 32 | var s:string; 33 | begin 34 | str(CurrentYear,s); 35 | Copyright:='Copyright (c) 1990-'+s+' Association of Mizar Users'; 36 | end; 37 | 38 | function VersionStr: string; 39 | var lRel,lVer,lVar: string[2]; lStr:string; 40 | begin 41 | Str(PCMizarReleaseNbr,lRel); 42 | Str(PCMizarVersionNbr,lVer); 43 | Str(PCMizarVariantNbr,lVar); 44 | if length(lVar) = 1 then lVar:='0'+lVar; 45 | {$IFDEF VERALPHA} 46 | lStr:='-alpha'; 47 | {$ELSE} 48 | lStr:=''; 49 | {$ENDIF} 50 | VersionStr:=lRel+'.'+lVer+'.'+lVar+lStr; 51 | end; 52 | 53 | function PlatformNameStr: string; 54 | var lStr: string; 55 | begin lStr:=''; 56 | {$IFDEF WIN32} 57 | lStr:=lStr+'Win32'; 58 | {$ENDIF} 59 | {$IFDEF LINUX} 60 | lStr:=lStr+'Linux'; 61 | {$ENDIF} 62 | {$IFDEF SOLARIS} 63 | lStr:=lStr+'Solaris'; 64 | {$ENDIF} 65 | {$IFDEF FREEBSD} 66 | lStr:=lStr+'FreeBSD'; 67 | {$ENDIF} 68 | {$IFDEF DARWIN} 69 | lStr:=lStr+'Darwin'; 70 | {$ENDIF} 71 | {$IFDEF FPC} 72 | lStr:=lStr+'/FPC'; 73 | {$ENDIF} 74 | {$IFDEF DELPHI} 75 | lStr:=lStr+'/Delphi'; 76 | {$ENDIF} 77 | PlatformNameStr:=lStr; 78 | end; 79 | 80 | function PCMizarVersionStr: string; 81 | begin 82 | PCMizarVersionStr:='Mizar Ver. '+VersionStr; 83 | end; 84 | 85 | end. 86 | -------------------------------------------------------------------------------- /base/pragmas.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit pragmas; 8 | 9 | interface 10 | 11 | uses mobjects; 12 | 13 | var 14 | VerifyPragmaOn,VerifyPragmaOff : NatSet; 15 | VerifyPragmaIntervals: NatFunc; 16 | SchemePragmaOn,SchemePragmaOff: NatSet; 17 | SchemePragmaIntervals : NatFunc; 18 | ProofPragma: Boolean = true; 19 | 20 | procedure SetParserPragma(aPrg: string); 21 | procedure InsertPragma(aLine: integer; aPrg: string); 22 | procedure CompletePragmas(aLine: integer); 23 | 24 | procedure CanceledPragma(const aPrg:string; var aKind: char; var aNbr: integer); 25 | 26 | implementation 27 | 28 | uses mizenv; 29 | 30 | procedure CanceledPragma(const aPrg:string; var aKind: char; var aNbr: integer); 31 | var lStr: string; 32 | k,lCod: integer; 33 | begin 34 | aKind:=' '; 35 | if (Copy(aPrg,1,2) = '$C') then 36 | begin 37 | if (length(aPrg) >= 3) and (aPrg[3] in ['D','S','T']) then 38 | begin 39 | aKind:=aPrg[3]; 40 | lStr:=TrimString(Copy(aPrg,4,length(aPrg)-3)); 41 | aNbr:=1; 42 | if length(lStr) > 0 then 43 | begin 44 | k:=1; 45 | while (k <= length(lStr)) and (lStr[k] in ['0'..'9']) do inc(k); 46 | delete(lStr,k,length(lStr)); 47 | if length(lStr) > 0 then 48 | Val(lStr,aNbr,lCod); 49 | end; 50 | end; 51 | end; 52 | end; 53 | 54 | procedure SetParserPragma(aPrg: string); 55 | begin 56 | if copy(aPrg,1,3)='$P+' then 57 | begin 58 | ProofPragma:=true; 59 | end; 60 | if copy(aPrg,1,3)='$P-' then 61 | begin 62 | ProofPragma:=false; 63 | end; 64 | end; 65 | 66 | procedure InsertPragma(aLine: integer; aPrg: string); 67 | begin 68 | if copy(aPrg,1,3)='$V+' then 69 | begin 70 | VerifyPragmaOn.InsertElem(aLine); 71 | end; 72 | if copy(aPrg,1,3)='$V-' then 73 | begin 74 | VerifyPragmaOff.InsertElem(aLine); 75 | end; 76 | 77 | if copy(aPrg,1,3)='$S+' then 78 | begin 79 | SchemePragmaOn.InsertElem(aLine); 80 | end; 81 | if copy(aPrg,1,3)='$S-' then 82 | begin 83 | SchemePragmaOff.InsertElem(aLine); 84 | end; 85 | end; 86 | 87 | procedure CompletePragmas(aLine: integer); 88 | var i,j,a,b : integer; f:boolean; 89 | begin 90 | for i:=0 to VerifyPragmaOff.Count-1 do 91 | begin 92 | f:=false; 93 | a:=VerifyPragmaOff.Items^[i].X; 94 | for j:=0 to VerifyPragmaOn.Count-1 do 95 | begin 96 | b:=VerifyPragmaOn.Items^[j].X; 97 | if b >= a then 98 | begin 99 | VerifyPragmaIntervals.Assign(a,b); 100 | f:=true; 101 | break; 102 | end; 103 | end; 104 | if not f then VerifyPragmaIntervals.Assign(a,aLine); 105 | end; 106 | for i:=0 to SchemePragmaOff.Count-1 do 107 | begin 108 | f:=false; 109 | a:=SchemePragmaOff.Items^[i].X; 110 | for j:=0 to SchemePragmaOn.Count-1 do 111 | begin 112 | b:=SchemePragmaOn.Items^[j].X; 113 | if b >= a then 114 | begin 115 | SchemePragmaIntervals.Assign(a,b); 116 | f:=true; 117 | break; 118 | end; 119 | end; 120 | if not f then SchemePragmaIntervals.Assign(a,aLine); 121 | end; 122 | end; 123 | 124 | begin 125 | 126 | VerifyPragmaOn.Init(10,10); 127 | VerifyPragmaOff.Init(10,10); 128 | VerifyPragmaIntervals.InitNatFunc(10,10); 129 | SchemePragmaOn.Init(10,10); 130 | SchemePragmaOff.Init(10,10); 131 | SchemePragmaIntervals.InitNatFunc(10,10); 132 | 133 | end. 134 | -------------------------------------------------------------------------------- /base/wsmparser.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Weakly_Strict_Mizar_Parser; 11 | 12 | uses mizenv, pcmizver, monitor, errhan, mconsole, mtime, 13 | _formats, parseraddition, syntax, 14 | parser, mscanner, wsmarticle, xml_parser 15 | {$IFDEF MDEBUG} ,info {$ENDIF}; 16 | 17 | var PassTime: longint; 18 | 19 | procedure InitPass(const aPassName: string); 20 | begin 21 | CurPos.Line:=1; 22 | CurPos.Col:=1; 23 | InitDisplayLine(aPassName); 24 | TimeMark(PassTime); 25 | end; 26 | 27 | procedure FinishPass; 28 | begin 29 | FinishingPass:=true; 30 | if QuietMode then DisplayLine(CurPos.Line,ErrorNbr); 31 | FinishingPass:=false; 32 | DrawTime(' '+ReportTime(PassTime)); 33 | end; 34 | 35 | procedure ParserError(Pos:Position; ErrNr:integer); 36 | begin 37 | WriteError(Pos,ErrNr); 38 | DisplayLine(CurPos.Line,ErrorNbr); 39 | end; 40 | 41 | var _WSMizExitProc: pointer; 42 | procedure WSMizarExitProc; 43 | begin 44 | ExitProc:=_WSMizExitProc; 45 | {$I-} 46 | if IOResult<>0 then; 47 | if not StopOnError then DisplayLine(CurPos.Line,ErrorNbr); 48 | PutError:=WriteError; 49 | DrawVerifierExit(ReportTime(gStartTime)); 50 | { Halt(ErrorCode);} 51 | {$I+} 52 | end; 53 | 54 | procedure InitParsing(const aProgName: string); 55 | begin 56 | DrawMizarScreen(aProgName); 57 | if paramcount<1 then EmptyParameterList; 58 | GetArticleName; 59 | GetEnvironName; 60 | DrawArticleName(MizFileName+ArticleExt); 61 | GetOptions; 62 | InitExitProc; 63 | FileExam(MizFileName+ArticleExt); 64 | _WSMizExitProc := ExitProc; 65 | ExitProc:=@WSMizarExitProc; 66 | PutError:=ParserError; 67 | OpenErrors(MizFileName); 68 | {$IFDEF MDEBUG} 69 | OpenInfoFile; 70 | {$ENDIF} 71 | end; 72 | 73 | procedure InitWSMizArticle; 74 | begin 75 | gWSTextProper:=new(wsTextProperPtr,Init(ArticleID,ArticleExt,CurPos)); 76 | gLastWSBlock:=gWSTextProper; 77 | gLastWSItem:=nil; 78 | gBlockPtr:=new(extBlockPtr, Init(blMain)); 79 | end; 80 | 81 | procedure Parsing; 82 | begin 83 | FileExam(EnvFileName+'.dct'); 84 | InitScanning(MizFileName+ArticleExt,EnvFileName); 85 | InitWSMizArticle; 86 | InitPass('Parser '); 87 | Parse; 88 | gFormatsColl.Done; 89 | FinishScanning; 90 | Write_WSMizArticle(gWSTextProper,MizFileName+'.wsx'); 91 | FinishPass; 92 | end; 93 | 94 | begin 95 | InitParsing('Pure Parser for Mizar'); 96 | Parsing; 97 | if ErrorNbr > 0 then 98 | begin 99 | DrawErrorsMsg(ErrorNbr); 100 | FinishDrawing; 101 | end; 102 | Print_WSMizArticle(gWSTextProper,MizFileName+'.wsm'); 103 | end. 104 | 105 | -------------------------------------------------------------------------------- /base/xml_dict.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit xml_dict; 8 | 9 | interface 10 | 11 | uses mobjects; 12 | 13 | // known (and only allowed) XML elements 14 | type 15 | XMLElemKind = 16 | ( 17 | elUnknown, 18 | elAdjective, 19 | elAdjectiveCluster, 20 | elArticleID, 21 | elAncestors, 22 | elArguments, 23 | elBlock, 24 | elConditions, 25 | elCorrectnessConditions, 26 | elDefiniens, 27 | elDirective, 28 | elEnviron, 29 | elEquality, 30 | elFieldSegment, 31 | elFormat, 32 | elFormats, 33 | elIdent, 34 | elItem, 35 | elIterativeStep, 36 | elLabel, 37 | elLink, 38 | elLoci, 39 | elLociEquality, 40 | elLocus, 41 | elNegatedAdjective, 42 | elPartialDefiniens, 43 | elPriority, 44 | elProposition, 45 | elProvisionalFormulas, 46 | elRedefine, 47 | elRightCircumflexSymbol, 48 | elSchematicVariables, 49 | elScheme, 50 | elSelector, 51 | elSetMember, 52 | elSkippedProof, 53 | elSymbol, 54 | elSymbolCount, 55 | elSymbols, 56 | elSubstitution, 57 | elTypeSpecification, 58 | elTypeList, 59 | elVariable, 60 | elVariables, 61 | elVocabularies, 62 | elVocabulary 63 | ); 64 | 65 | // known XML attributes 66 | XMLAttrKind = 67 | ( 68 | atUnknown, 69 | atAid, 70 | atArgNr, 71 | atArticleId, 72 | atArticleExt, 73 | atCol, 74 | atCondition, 75 | atConstrNr, 76 | atIdNr, 77 | atInfinitive, 78 | atKind, 79 | atLabelNr, 80 | atLeftArgNr, 81 | atLine, 82 | atMizfiles, 83 | atName, 84 | atNegated, 85 | atNr, 86 | atNumber, 87 | atOrigin, 88 | atPosLine, 89 | atPosCol, 90 | atPriority, 91 | atProperty, 92 | atRightSymbolNr, 93 | atSchNr, 94 | atSerialNr, 95 | atShape, 96 | atSpelling, 97 | atSymbolNr, 98 | atValue, 99 | atVarNr, 100 | atVarSort, 101 | atX, 102 | atX1, 103 | atX2, 104 | atY, 105 | atY1, 106 | atY2 107 | ); 108 | 109 | const 110 | XMLElemName: array[XMLElemKind] of string = 111 | ( 112 | 'Unknown', 113 | 'Adjective', 114 | 'Adjective-Cluster', 115 | 'ArticleID', 116 | 'Ancestors', 117 | 'Arguments', 118 | 'Block', 119 | 'Conditions', 120 | 'CorrectnessConditions', 121 | 'Definiens', 122 | 'Directive', 123 | 'Environ', 124 | 'Equality', 125 | 'Field-Segment', 126 | 'Format', 127 | 'Formats', 128 | 'Ident', 129 | 'Item', 130 | 'Iterative-Step', 131 | 'Label', 132 | 'Link', 133 | 'Loci', 134 | 'LociEquality', 135 | 'Locus', 136 | 'NegatedAdjective', 137 | 'Partial-Definiens', 138 | 'Priority', 139 | 'Proposition', 140 | 'Provisional-Formulas', 141 | 'Redefine', 142 | 'Right-Circumflex-Symbol', 143 | 'Schematic-Variables', 144 | 'Scheme', 145 | 'Selector', 146 | 'SetMember', 147 | 'elSkippedProof', 148 | 'Symbol', 149 | 'SymbolCount', 150 | 'Symbols', 151 | 'Substitution', 152 | 'Type-Specification', 153 | 'Type-List', 154 | 'Variable', 155 | 'Variables', 156 | 'Vocabularies', 157 | 'Vocabulary' 158 | ); 159 | 160 | XMLAttrName: array[XMLAttrKind] of string = 161 | ( 162 | 'unknown', 163 | 'aid', 164 | 'argnr', 165 | 'articleid', 166 | 'articleext', 167 | 'col', 168 | 'condition', 169 | 'constrnr', 170 | 'idnr', 171 | 'infinitive', 172 | 'kind', 173 | 'labelnr', 174 | 'leftargnr', 175 | 'line', 176 | 'mizfiles', 177 | 'name', 178 | 'negated', 179 | 'nr', 180 | 'number', 181 | 'origin', 182 | 'posline', 183 | 'poscol', 184 | 'priority', 185 | 'property', 186 | 'rightsymbolnr', 187 | 'schnr', 188 | 'serialnr', 189 | 'shape', 190 | 'spelling', 191 | 'symbolnr', 192 | 'value', 193 | 'varnr', 194 | 'varsort', 195 | 'x', 196 | 'x1', 197 | 'x2', 198 | 'y', 199 | 'y1', 200 | 'y2' 201 | ); 202 | 203 | 204 | implementation 205 | 206 | end. 207 | 208 | -------------------------------------------------------------------------------- /kernel/absinfo.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit absinfo; 8 | 9 | interface 10 | 11 | uses generato,limits,express,mobjects; 12 | 13 | procedure AbsTerm(fTrm: ExpPtr); 14 | procedure AbsType(fTyp: ExpPtr); 15 | procedure AbsFormula(fFrm: ExpPtr); 16 | {procedure AbsTypeList(fTypList: aTypList);} 17 | procedure AbsSigmaRec(var fSigma:SigmaRec); 18 | procedure AbsThetaRec(var fTheta:ThetaRec); 19 | procedure AbsResDes(var fResDes: ResDes); 20 | procedure AbsResList(var fResList:MCollection); 21 | procedure AbsTermList(var fTrmList: MCollection); 22 | 23 | procedure AbsmultipleTypeExp(fPtr:multipleTypePtr); 24 | 25 | implementation 26 | 27 | uses info,errhan,lexicon; 28 | 29 | {+--------------------P-I-S-A-N-I-E----------------------------------+} 30 | 31 | procedure AbsmultipleTypeExp(fPtr:multipleTypePtr); 32 | begin 33 | with fPtr^ do 34 | begin AbsType(nType); InfoString(' times '); InfoInt(nNumberOfCopies); end; 35 | end; 36 | { procedure AbsTypeList; 37 | var i:integer; 38 | begin 39 | for i:=1 to MaxElemNbr do 40 | if fTypList=nil then begin InfoChar(';'); exit end else 41 | with fTypList^ do begin AbsType(TypPtr); fTypList:=NextTyp end; 42 | RunError(2001); 43 | end;} 44 | 45 | procedure AbsTermList(var fTrmList: MCollection); 46 | var i,z:integer; 47 | procedure AbsItem(Item:ExpPtr); 48 | begin AbsTerm(Item); 49 | end; 50 | begin 51 | with fTrmList do for z:=0 to Count-1 do AbsItem(ExpPtr(Items^[z])); 52 | end; 53 | 54 | procedure AbsType(fTyp: ExpPtr); 55 | begin 56 | with fTyp^ do 57 | if TypeOf(fTyp^) = TypeOf(AttributedType) then 58 | with AttributedTypePtr(fTyp)^ do 59 | begin AbsType(Podmiot); InfoPos(ExpPos); end 60 | else if TypeOf(fTyp^) = TypeOf(TypeExp) then 61 | with TypePtr(fTyp)^ do 62 | begin InfoWord(ExpSort,nConstrNr); InfoPos(ExpPos); AbsTermList(Argumenty) end 63 | else if TypeOf(fTyp^) = TypeOf(ResDesNode) then 64 | with TypePtr(fTyp)^ do 65 | begin InfoWord(ExpSort,nConstrNr); InfoPos(ExpPos); AbsTermList(Argumenty) end 66 | (*+ else if TypeOf(fTyp^) = TypeOf(SetType) then 67 | with SetTypePtr(fTyp)^ do 68 | {sySet:} begin InfoChar(sySet); InfoPos(ExpPos); AbsType(BasicType) end+*) 69 | else if TypeOf(fTyp^) = TypeOf(InCorrType) then 70 | with InCorrTypePtr(fTyp)^ do 71 | {ikError:} InfoChar(ikError) 72 | else begin writeln(InfoFile,'Abstype ?'); RunTimeError(2003) end; 73 | end; 74 | 75 | procedure AbsResDes(var fResDes: ResDes); 76 | procedure AbsVar(Item:SimpleTermPtr); 77 | begin with Item^ do write(InfoFile,'"',ExpSort,'"',VarNr,' '); 78 | end; 79 | var z: integer; 80 | begin InfoWord('D',fResDes.ResNr); 81 | write(InfoFile,'Count=',fResDes.Subst.Count); 82 | with fResDes.Subst do for z:=0 to Count-1 do AbsVar(SimpleTermPtr(Items^[z])); 83 | InfoChar(';'); 84 | end; 85 | 86 | procedure AbsResList(var fResList:MCollection); 87 | procedure lAbsResDes(Item:ResDesPtr); 88 | begin AbsType(Item) end; 89 | var z: integer; 90 | begin 91 | with fResList do for z:=0 to Count-1 do lAbsResDes(ResDesPtr(Items^[z])); 92 | 93 | InfoChar(';'); 94 | end; 95 | 96 | procedure AbsFormula(fFrm: ExpPtr); 97 | begin 98 | with fFrm^ do 99 | if TypeOf(fFrm^) = TypeOf(PredicateFormula) then 100 | with PredicateFormulaPtr(fFrm)^ do 101 | begin InfoWord(ExpSort,nConstrNr); InfoPos(ExpPos); 102 | AbsTermList(Argumenty); 103 | end 104 | else if TypeOf(fFrm^) = TypeOf(QualifyingFormula) then 105 | with QualifyingFormulaPtr(fFrm)^ do 106 | begin InfoChar(ikFrmQual); 107 | AbsTerm(Obiekt); AbsType(Kwalifikacja); 108 | end 109 | else if TypeOf(fFrm^) = TypeOf(NegativeFormula) then 110 | with NegativeFormulaPtr(fFrm)^ do 111 | begin InfoChar(ikFrmNeg); AbsFormula(NegArg) end 112 | else if TypeOf(fFrm^) = TypeOf(BinaryFormula) then 113 | with BinaryFormulaPtr(fFrm)^ do 114 | begin InfoChar(ExpSort); 115 | AbsFormula(BinArg1); AbsFormula(BinArg2); 116 | end 117 | else if TypeOf(fFrm^) = TypeOf(QuantifiedFormula) then 118 | with QuantifiedFormulaPtr(fFrm)^ do 119 | begin InfoWord('Q',QuantVars.fCount); 120 | AbsType(Quantified); AbsFormula(Scope); 121 | end 122 | else if TypeOf(fFrm^) = TypeOf(ThesisFormula) then 123 | InfoChar('$') 124 | else if TypeOf(fFrm^) = TypeOf(VerumFormula) then 125 | InfoChar('%') 126 | else if TypeOf(fFrm^) = TypeOf(InCorrFormula) then 127 | InfoChar(ikError) 128 | else InfoChar('@'); 129 | end; 130 | 131 | procedure AbsTerm(fTrm: ExpPtr); 132 | procedure AbsMultiType(Item:multipleTypePtr); 133 | begin 134 | with Item^ do 135 | begin AbsType(nType); InfoString(' times '); InfoInt(nNumberOfCopies); 136 | writeln(InfoFile); 137 | end; 138 | end; 139 | var z: integer; 140 | begin 141 | with fTrm^ do 142 | if TypeOf(fTrm^) = TypeOf(SimpleTerm) then 143 | with SimpleTermPtr(fTrm)^ do 144 | InfoWord(ExpSort,VarNr) 145 | else if TypeOf(fTrm^) = TypeOf(NumeralTerm) then 146 | InfoWord('N',NumeralTermPtr(fTrm)^.nNatVal) 147 | else if TypeOf(fTrm^) = TypeOf(FunctorTerm) then 148 | with FunctorTermPtr(fTrm)^ do 149 | begin InfoWord(ExpSort,nConstrNr); InfoPos(ExpPos); AbsTermList(Argumenty) end 150 | else if TypeOf(fTrm^) = TypeOf(SelectorTerm) then 151 | with SelectorTermPtr(fTrm)^ do 152 | begin InfoWord('U',Select); InfoPos(ExpPos); AbsTerm(Struct) end 153 | else if TypeOf(fTrm^) = TypeOf(FraenkelTerm) then 154 | with FraenkelTermPtr(fTrm)^ do 155 | begin InfoChar(ikTrmFraenkel); InfoPos(ExpPos); 156 | with Kappa(Sample)^ do 157 | begin 158 | { AbsResList(nBoundVars);} 159 | with nBoundVars do for z:=0 to Count-1 do AbsMultiType(multipleTypePtr(Items^[z])); 160 | AbsTerm(nExpressionPtr); 161 | end; 162 | AbsSigmaRec(Compr^); 163 | end 164 | else if TypeOf(fTrm^) = TypeOf(QualifiedTerm) then 165 | with QualifiedTermPtr(fTrm)^ do 166 | begin InfoChar(ikTrmQua); InfoPos(ExpPos); 167 | AbsTerm(Obiekt); AbsType(Kwalifikacja); 168 | end 169 | else if TypeOf(fTrm^) = TypeOf(ItTerm) then 170 | InfoChar(ikTrmIt) 171 | else if TypeOf(fTrm^) = TypeOf(InCorrTerm) then 172 | InfoChar(ikError) 173 | else InfoChar('@'); 174 | end; 175 | 176 | procedure AbsSigmaRec(var fSigma:SigmaRec); 177 | begin 178 | with fSigma do 179 | begin AbsResList(nFreeVars); AbsFormula(nExpressionPtr) end; 180 | end; 181 | 182 | procedure AbsThetaRec(var fTheta:ThetaRec); 183 | begin 184 | with fTheta do 185 | begin AbsResList(nFreeVars); AbsType(nExpressionPtr) end; 186 | end; 187 | 188 | end. 189 | -------------------------------------------------------------------------------- /kernel/accdict.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit accdict; 8 | interface 9 | 10 | uses mobjects,envhan,dicthan; 11 | 12 | type 13 | 14 | DictBasePtr = ^DictBaseObj; 15 | DictBaseObj = Object(MStrObj) 16 | nBase: SymbolCounters; 17 | constructor Init(fIdent:string); 18 | end; 19 | 20 | var 21 | gSymBase : SymbolCounters; 22 | DictBase : MSortedStrList; 23 | 24 | procedure ProcessVocabularies; 25 | 26 | procedure PrintVocabulariesList; 27 | 28 | procedure PrintPRF(fFileName:string); 29 | procedure PrintStrictPRF(fFileName:string); 30 | 31 | implementation 32 | 33 | uses pcmizver,mizenv,librenv,errhan,_formats, 34 | scanner,mscanner,xml_dict,xml_inout; 35 | 36 | var 37 | TokCounter: SymbolCounters; 38 | gTokens : TokensCollection; 39 | 40 | constructor DictBaseObj.Init(fIdent:string); 41 | begin 42 | inherited Init(fIdent); 43 | fillchar(nBase,sizeof(nBase),0); 44 | end; 45 | 46 | procedure PrintPRF(fFileName:string); 47 | var i:integer; 48 | DctFile: text; 49 | begin 50 | assign(DctFile,fFileName+'.prf'); rewrite(DctFile); 51 | Writeln(DctFile,gSymBase['M'],' ',gSymBase['G'],' ',gSymBase['R'],' '); 52 | if gSymBase['M'] > 0 then 53 | begin 54 | for i:=1 to gSymBase['M'] do 55 | write(DctFile,ModeMaxArgs.fList^[i],' '); 56 | writeln(DctFile); 57 | end; 58 | if gSymBase['G'] > 0 then 59 | begin 60 | for i:=1 to gSymBase['G'] do 61 | write(DctFile,StructModeMaxArgs.fList^[i],' '); 62 | writeln(DctFile); 63 | end; 64 | if gSymBase['R'] > 0 then 65 | begin 66 | for i:=1 to gSymBase['R'] do 67 | write(DctFile,PredMaxArgs.fList^[i],' '); 68 | writeln(DctFile); 69 | end; 70 | ModeMaxArgs.Done; 71 | StructModeMaxArgs.Done; 72 | PredMaxArgs.Done; 73 | close(DctFile); 74 | end; 75 | 76 | procedure PrintStrictPRF(fFileName:string); 77 | var DctFile: text; 78 | begin 79 | assign(DctFile,fFileName+'.prf'); rewrite(DctFile); 80 | Writeln(DctFile,'0 0 0 '); 81 | close(DctFile); 82 | end; 83 | 84 | procedure CollectTheorems; 85 | var lToken: LexemRec; 86 | procedure AddTheoremIdent(fIdent:PImpArticleId); 87 | begin inc(TokCounter['A']); 88 | lToken.Nr:=TokCounter['A']; 89 | with fIdent^ do 90 | if not gTokens.CollectToken(lToken,fStr) 91 | then Error(fPos,815); 92 | end; 93 | procedure AddNotationsIdent(fIdent:PImpArticleId); 94 | begin 95 | with fIdent^ do 96 | begin 97 | if Env.Directive[syTheorems].IndexOfStr(fStr)<0 then 98 | begin 99 | inc(TokCounter['A']); 100 | lToken.Nr:=TokCounter['A']; 101 | if not gTokens.CollectToken(lToken,fStr) 102 | then Error(fPos,815); 103 | end; 104 | end; 105 | end; 106 | var z: integer; 107 | begin 108 | lToken.Kind:='A'; 109 | with Env.Directive[syTheorems] do 110 | for z:=0 to Count-1 do AddTheoremIdent(PImpArticleId(Items^[z])); 111 | with Env.Directive[syNotations] do 112 | for z:=0 to Count-1 do AddNotationsIdent(PImpArticleId(Items^[z])); 113 | end; 114 | 115 | procedure InitDictBase; 116 | begin 117 | FillChar(TokCounter,SizeOf(TokCounter),0); 118 | DictBase.Init(Env.Directive[syVocabularies].Count+10); 119 | DictBase.Insert(new(DictBasePtr,Init(''))); 120 | gPriority.Init(10); 121 | TokCounter['M']:=1; { "set" } 122 | TokCounter['R']:=1; { "=" } 123 | TokCounter['K']:=3; (* nawias lewy "[" i "{" "(" *) 124 | TokCounter['L']:=3; (* nawias prawy "]" i "}" ")" *) 125 | end; 126 | 127 | // ##TODO: try to merge with OutMarkedVocs 128 | procedure PrintVocabulariesList; 129 | var lOutEnvFile:XMLOutStreamObj; i:integer; c,s:char; lCounts:SymbolCounters; 130 | begin 131 | lOutEnvFile.OpenFile( EnvFileName+'.vcl'); 132 | lOutEnvFile.Out_XElStart0( XMLElemName[elVocabularies]); 133 | for i:=1 to DictBase.Count-1 do 134 | with DictBasePtr(DictBase.Items^[i])^ do 135 | begin 136 | for c:='A' to 'Z' do 137 | lCounts[c]:= nBase[c] - DictBasePtr(DictBase.Items^[i-1])^.nBase[c]; 138 | lOutEnvFile.Out_XElStart0( XMLElemName[elVocabulary]); 139 | lOutEnvFile.Out_XElStart( XMLElemName[elArticleID]); 140 | lOutEnvFile.Out_XAttr( XMLAttrName[atName], fStr); 141 | lOutEnvFile.Out_XElEnd0; 142 | for s:='A' to 'Z' do if s in AvailableSymbols then 143 | begin 144 | lOutEnvFile.Out_XElStart( XMLElemName[elSymbolCount]); 145 | lOutEnvFile.Out_XAttr( XMLAttrName[atKind], s); 146 | lOutEnvFile.Out_XIntAttr( XMLAttrName[atNr], lCounts[s]); 147 | lOutEnvFile.Out_XElEnd0; 148 | end; 149 | lOutEnvFile.Out_XElEnd( XMLElemName[elVocabulary]); 150 | end; 151 | lOutEnvFile.Out_XElEnd( XMLElemName[elVocabularies]); 152 | lOutEnvFile.Done; 153 | end; 154 | 155 | procedure ProcessVocabularies; 156 | var VocFile: text; 157 | procedure AddIdent(fIdent:PImpArticleId); 158 | var lLexem: LexemRec; 159 | begin inc(TokCounter['A']); 160 | lLexem.Kind:='A'; 161 | lLexem.Nr:=TokCounter['A']; 162 | with fIdent^ do 163 | if not gTokens.CollectToken(lLexem,fStr) 164 | then Error(fPos,815); 165 | end; 166 | procedure ProcessVocabulary(fIdent:PImpArticleId); 167 | procedure AddSymbol(fSymbol: PSymbol); 168 | var lSymbol: LexemRec; lPrior: integer; 169 | begin 170 | with fSymbol^ do 171 | begin 172 | lSymbol.Kind:=Kind; 173 | inc(TokCounter[lSymbol.Kind]); 174 | lSymbol.Nr:=TokCounter[lSymbol.Kind]; 175 | lPrior:=Prior; 176 | if lPrior = 0 then lPrior:=StandardPriority; 177 | case Kind of 178 | 'O': gPriority.Assign(ord('O'),TokCounter['O'],lPrior); 179 | 'K': gPriority.Assign(ord('K'),TokCounter['K'],lPrior); 180 | 'L': gPriority.Assign(ord('L'),TokCounter['L'],lPrior); 181 | end; 182 | if not gTokens.CollectToken(lSymbol,Repr) 183 | then Error(fIdent^.fPos,815); 184 | if (Infinitive <> '') and not gTokens.CollectToken(lSymbol,Infinitive) 185 | then Error(fIdent^.fPos,815); 186 | end; 187 | end; 188 | var lDictBase: DictBasePtr; 189 | lVoc: PVocabulary; 190 | z: integer; 191 | label 1; 192 | begin 193 | if MFileExists('dict'+DirSeparator+LowerCase(fIdent^.fStr)+'.voc') then 194 | begin 195 | lVoc:=GetPrivateVoc('dict'+DirSeparator+LowerCase(fIdent^.fStr)+'.voc'); 196 | if lVoc = nil then begin Error(fIdent^.fPos,801); goto 1 end; 197 | with lVoc^.Reprs do 198 | for z:=0 to Count-1 do AddSymbol(PSymbol(Items^[z])); 199 | LocFilesCollection.Insert( 200 | New(PFileDescr,Init('dict'+DirSeparator+LowerCase(fIdent^.fStr)+'.voc',0))); 201 | end 202 | else 203 | begin 204 | lVoc:=GetPublicVoc(fIdent^.fStr,VocFile); 205 | if lVoc = nil then begin Error(fIdent^.fPos,801); goto 1 end; 206 | with lVoc^.Reprs do 207 | for z:=0 to Count-1 do AddSymbol(PSymbol(Items^[z])); 208 | end; 209 | 1: 210 | lDictBase:=New(DictBasePtr,Init(fIdent^.fStr)); 211 | lDictBase^.nBase:=TokCounter; 212 | DictBase.Insert(lDictBase); 213 | end; 214 | var z: integer; 215 | begin 216 | FileExam(MizFiles+'mizar.dct'); 217 | gTokens.LoadDct(MizFiles+'mizar'); 218 | InitDictBase; 219 | FileExam(MizFiles+MML+'.vct'); 220 | Assign(VocFile,MizFiles+MML+'.vct'); 221 | Reset(VocFile); 222 | with Env.Directive[syVocabularies] do 223 | for z:=0 to Count-1 do 224 | begin 225 | CurPos:=PImpArticleId(Items^[z])^.fPos; 226 | ProcessVocabulary(PImpArticleId(Items^[z])); 227 | end; 228 | close(VocFile); 229 | gSymBase:=TokCounter; 230 | with Env.Directive[syTheorems] do 231 | for z:=0 to Count-1 do AddIdent(PImpArticleId(Items^[z])); 232 | with Env.Directive[sySchemes] do 233 | for z:=0 to Count-1 do 234 | if gTokens.IndexOfStr(PImpArticleId(Items^[z])^.fStr) = -1 then 235 | AddIdent(PImpArticleId(Items^[z])); 236 | gTokens.SaveDct(EnvFileName); 237 | gTokens.SaveXDct(EnvFileName+'.dcx'); 238 | gTokens.Done; 239 | end; 240 | 241 | end. 242 | -------------------------------------------------------------------------------- /kernel/accom.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Accommodator; 11 | 12 | uses pcmizver, librenv, mizenv, errhan, monitor, mconsole, 13 | envhan, inlibr, acc_han, accdict 14 | {$IFDEF MDEBUG},info {$ENDIF}; 15 | 16 | var _MizExitProc:pointer; 17 | 18 | procedure PCMizExitProc; 19 | begin 20 | ExitProc:=_MizExitProc; 21 | {$I-} 22 | if IOResult<>0 then; 23 | CloseLogFile; 24 | if IOResult<>0 then; 25 | {$I+} 26 | end; 27 | 28 | begin 29 | DrawMizarScreen('Accommodator'); 30 | GetArticleName; GetEnvironName; 31 | FileExam(MizFileName+ArticleExt); 32 | DrawArticleName(MizFileName+ArticleExt); 33 | InitExitProc; 34 | _MizExitProc := ExitProc; 35 | ExitProc:=@PCMizExitProc; 36 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 37 | OpenErrors(MizFileName); 38 | OpenLogFile; 39 | GetAccOptions; 40 | FileExam(MizFiles+MML+'.vct'); 41 | LocFilesCollection.Insert(New(PFileDescr,Init(MizFiles+MML+'.vct',0))); 42 | DrawPass('-Parsing'); 43 | Env.ReadEnvironment; 44 | if ErrorNbr=0 then 45 | begin 46 | Accomodate; 47 | LocFilesCollection.StoreFIL(MizFileName+'.fil'); 48 | end; 49 | DrawErrorsMsg(ErrorNbr); 50 | FinishDrawing; 51 | end. 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /kernel/builtin.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit builtin; 8 | 9 | interface 10 | 11 | uses limits; 12 | 13 | type 14 | 15 | Requirement = ( rqNone, 16 | {--- HIDDEN ---} 17 | rqAny, //1 18 | rqSetMode, //2 19 | rqEqualsTo, //3 20 | rqBelongsTo, //4 21 | {--- XBOOLE_0/BOOLE ---} 22 | rqEmpty, //5 23 | rqEmptySet, //6 24 | {--- SUBSET_1/SUBSET ---} 25 | rqElement, //7 26 | {--- ZFMISC_1/SUBSET ---} 27 | rqPowerSet, //8 28 | {--- TARSKI/SUBSET ---} 29 | rqInclusion, //9 30 | {--- SUBSET_1/SUBSET ---} 31 | rqSubDomElem, //10 32 | {--- NUMBERS ---} 33 | rqRealDom, //11 34 | rqNatDom, //12 35 | {--- XCMPLX_0/ARITHM ---} 36 | rqRealAdd, //13 37 | rqRealMult, //14 38 | {--- XREAL_0/REAL ---} 39 | rqLessOrEqual, //15 40 | {--- ORDINAL1/NUMERALS ---} 41 | rqSucc, //16 42 | {--- XBOOLE_0/BOOLE) ---} 43 | rqUnion, //17 44 | rqIntersection, //18 45 | rqSubtraction, //19 46 | rqSymmetricDifference, //20 47 | rqMeets, //21 48 | {--- XCMPLX_0/ARITHM ---} 49 | rqRealNeg, //22 50 | rqRealInv, //23 51 | rqRealDiff, //24 52 | rqRealDiv, //25 53 | {--- XREAL_0/REAL ---} 54 | rqReal, //26 55 | {--- XXREAL_0/REAL ---} 56 | rqPositive, //27 57 | rqNegative, //28 58 | {--- ORDINAL1/NUMERALS ---} 59 | rqNatural, //29 60 | {--- XCMPLX_0/COMPLEX ---} 61 | rqImaginaryUnit, //30 62 | rqComplex, //31 63 | {--- ORDINAL1/NUMERALS ---} 64 | rqOmega, //32 65 | rqZeroNumber, //33 66 | rqZero, //34 67 | {--- INT_1/INT_D ---} 68 | rqDiv, //35 69 | rqMod, //36 70 | rqDivides, //37 71 | {--- INT_2/INT_D ---} 72 | rqLCM, //38 73 | rqGCD, //39 74 | rqPrime //40 75 | ); 76 | 77 | const ReqName: array[Requirement] of string = ( 78 | 'rqNone', 79 | {--- HIDDEN ---} 80 | 'rqAny', //1 81 | 'rqSetMode', //2 82 | 'rqEqualsTo', //3 83 | 'rqBelongsTo', //4 84 | {--- XBOOLE_0/BOOLE ---} 85 | 'rqEmpty', //5 86 | 'rqEmptySet', //6 87 | {--- SUBSET_1/SUBSET ---} 88 | 'rqElement', //7 89 | {--- ZFMISC_1/SUBSET ---} 90 | 'rqPowerSet', //8 91 | {--- TARSKI/SUBSET ---} 92 | 'rqInclusion', //9 93 | {--- SUBSET_1/SUBSET ---} 94 | 'rqSubDomElem', //10 95 | {--- NUMBERS ---} 96 | 'rqRealDom', //11 97 | 'rqNatDom', //12 98 | {--- XCMPLX_0/ARITHM ---} 99 | 'rqRealAdd', //13 100 | 'rqRealMult', //14 101 | {--- XREAL_0/REAL ---} 102 | 'rqLessOrEqual', //15 103 | {--- ORDINAL1/NUMERALS ---} 104 | 'rqSucc', //16 105 | {--- XBOOLE_0/BOOLE) ---} 106 | 'rqUnion', //17 107 | 'rqIntersection', //18 108 | 'rqSubtraction', //19 109 | 'rqSymmetricDifference', //20 110 | 'rqMeets', //21 111 | {--- XCMPLX_0/ARITHM ---} 112 | 'rqRealNeg', //22 113 | 'rqRealInv', //23 114 | 'rqRealDiff', //24 115 | 'rqRealDiv', //25 116 | {--- XREAL_0/REAL ---} 117 | 'rqReal', //26 118 | {--- XXREAL_0/REAL ---} 119 | 'rqPositive', //27 120 | 'rqNegative', //28 121 | {--- ORDINAL1/NUMERALS ---} 122 | 'rqNatural', //29 123 | {--- XCMPLX_0/COMPLEX ---} 124 | 'rqImaginaryUnit', //30 125 | 'rqComplex', //31 126 | {--- ORDINAL1/NUMERALS ---} 127 | 'rqOmega', //32 128 | 'rqZeroNumber', //33 129 | 'rqZero', //34 130 | {--- INT_1/INT_D ---} 131 | 'rqDiv', //35 132 | 'rqMod', //36 133 | 'rqDivides', //37 134 | {--- INT_2/INT_D ---} 135 | 'rqLCM', //38 136 | 'rqGCD', //39 137 | 'rqPrime' //40 138 | ); 139 | 140 | const 141 | 142 | FunctorRequirement: set of Requirement = 143 | [rqEmptySet, 144 | rqPowerSet, 145 | rqRealAdd, 146 | rqRealMult, 147 | rqSucc, 148 | rqUnion, 149 | rqIntersection, 150 | rqSubtraction, 151 | rqSymmetricDifference, 152 | rqRealNeg, 153 | rqRealInv, 154 | rqRealDiff, 155 | rqRealDiv, 156 | rqImaginaryUnit, 157 | rqOmega, 158 | rqZeroNumber, 159 | rqDiv, 160 | rqMod, 161 | rqLCM, 162 | rqGCD 163 | ]; 164 | 165 | { Homonymic and special symbols in buildin vocabulery HIDDEN} 166 | StrictSym = 1; {"strict"} 167 | SetSym = 1; {'set'} 168 | EqualitySym = 1; {'='} 169 | Square = 1; {'[' ']'} 170 | Curled = 2; (* '{' '}' *) 171 | Rounded = 3; {'(' ')'} 172 | 173 | var 174 | gBuiltIn: array[Requirement] of integer = 175 | (0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); 176 | gRevReq: array[0..MaxFuncNbr] of Requirement; 177 | 178 | procedure InitReverseRequirements; 179 | 180 | implementation 181 | 182 | procedure InitReverseRequirements; 183 | var i:integer; r:Requirement; 184 | begin 185 | for i:=0 to MaxFuncNbr do gRevReq[i]:=rqNone; 186 | for r:=low(Requirement) to high(Requirement) do 187 | if r in FunctorRequirement then gRevReq[gBuiltIn[r]]:=r; 188 | end; 189 | 190 | end. 191 | -------------------------------------------------------------------------------- /kernel/e_prep.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | // The preparator objects for exporter. 8 | 9 | // This is used only to collect schemes, theorems and definitions. 10 | // Clusters, constructors, notation and definienda are saved before 11 | // disposing analyzer data so they are ignored here. 12 | 13 | 14 | unit e_prep; 15 | 16 | interface 17 | 18 | uses mobjects,justhan,correl,limits,prepobj,schemhan,inout; 19 | 20 | type 21 | 22 | ExtPBlockPtr = ^ExtPBlockObj; 23 | ExtPBlockObj = 24 | object(PrepBlockObj) 25 | nSchLab: integer; // nonzero only for blPublicScheme 26 | procedure InitPrepData; virtual; 27 | // this is a bit silly, but FPC does not allow other result type 28 | function CreateItem(fItemKind:ItemKind):PrepItemPtr; virtual; 29 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 30 | function GetPrevious : ExtPBlockPtr; 31 | procedure ProcessSchemeLabel; virtual; 32 | end; 33 | 34 | ExtPItemPtr = ^ExtPItemObj; 35 | ExtPItemObj = 36 | object(PrepItemObj) 37 | nDefThConstr: Lexem; // nonzero only for itDefTheorem 38 | function GetPrevious : ExtPItemPtr; 39 | function GetBlock : ExtPBlockPtr; 40 | procedure StartSchemeTypes; virtual; 41 | procedure FinishSchFuncSegment; virtual; 42 | procedure FinishSchemeTypes; virtual; 43 | procedure StartSchemePremises; virtual; 44 | procedure FinishSchemePremise; virtual; 45 | procedure FinishSchemeThesis; virtual; 46 | procedure StartDefTheorem; virtual; 47 | procedure FinishTheoremBody; virtual; 48 | procedure FinishCanceledScheme; virtual; 49 | procedure FinishCanceled; virtual; 50 | procedure FinishCanceledDef; virtual; 51 | end; 52 | 53 | var gTheorem: array of 54 | record Definitional:boolean; nDefConstr: Lexem; Theo: FrmPtr end; 55 | gScheme: array of 56 | record nCanceled: boolean; nSchemeDef: SchRefPtr; end; 57 | gTheoremNbr,gSchemeNbr: integer; 58 | 59 | implementation 60 | 61 | uses errhan,mizenv,lexicon,prephan,iocorrel,propcoll 62 | {$IFDEF MDEBUG} 63 | ,info,outinfo 64 | {$ENDIF}; 65 | 66 | (********** Standard overloaded stuff **********) 67 | 68 | function ExtPItemObj.GetPrevious : ExtPItemPtr; 69 | begin GetPrevious := ExtPItemPtr(Previous); end; 70 | 71 | function ExtPItemObj.GetBlock : ExtPBlockPtr; 72 | begin GetBlock := ExtPBlockPtr(nBlock); end; 73 | 74 | function ExtPBlockObj.GetPrevious : ExtPBlockPtr; 75 | begin GetPrevious := ExtPBlockPtr(Previous); end; 76 | 77 | function ExtPBlockObj.CreateItem(fItemKind:ItemKind): PrepItemPtr; 78 | begin 79 | nCurrItm:= new(ExtPItemPtr, Init(fItemKind, @Self)); 80 | nCurrItm^.StartItem; 81 | CreateItem:= nCurrItm; 82 | end; 83 | 84 | procedure ExtPBlockObj.CreateBlock(fBlockKind:BlockKind); 85 | begin 86 | DebugBlockCreate(fBlockKind); 87 | gPrBlockPtr:= new(ExtPBlockPtr,Init(fBlockKind)); 88 | gPrBlockPtr^.StartBlock; 89 | end; 90 | 91 | (***********************************************) 92 | 93 | procedure ExtPBlockObj.ProcessSchemeLabel; 94 | var lSch: SchRefPtr; 95 | begin 96 | Mizassert(errSchemeBlockExpected, nBlockKind = blPublicScheme); 97 | nSchLab:= InFile.Current.Nr; 98 | lSch:= new(SchRefPtr,Init1); 99 | lSch^.fKey.Y:= nSchLab; 100 | lSch^.nSchState:= schStateBeingProved; 101 | Ord_Scheme.Insert(lSch); 102 | if gSchemeNbr >= length(gScheme) then 103 | setlength(gScheme,2*length(gScheme)); 104 | inc(gSchemeNbr); 105 | with gScheme[gSchemeNbr] do 106 | begin nCanceled:=false; 107 | nSchemeDef:=lSch; 108 | end; 109 | end; 110 | 111 | procedure ExtPItemObj.StartSchemeTypes; 112 | begin CurSchFuncTyp.Init(0,MaxArgNbr); end; 113 | 114 | procedure ExtPItemObj.FinishSchFuncSegment; 115 | begin 116 | CurSchFuncTyp.Insert(gPrep^.nLastType); 117 | gPrep^.nLastType:= nil; 118 | end; 119 | 120 | // ##TODO: the 'move' should be replaced here 121 | procedure ExtPItemObj.FinishSchemeTypes; 122 | begin 123 | CurSchFuncTyp.SetLimit(0); 124 | move(CurSchFuncTyp,Scheme(0,GetBlock^.nSchLab)^.SchTypes,SizeOf(MCollection)); 125 | end; 126 | 127 | // reserve place for thesis it comes first 128 | procedure ExtPItemObj.StartSchemePremises; 129 | begin 130 | with Scheme(0,GetBlock^.nSchLab)^ do 131 | begin 132 | SchProps.Init(1,4); 133 | SchProps.Insert(nil); 134 | end; 135 | end; 136 | 137 | procedure ExtPItemObj.FinishSchemePremise; 138 | begin 139 | with Scheme(0,GetBlock^.nSchLab)^ do 140 | SchProps.Insert(gPrep^.nLastProposition^.nSentence^.CopyFormula); 141 | end; 142 | 143 | procedure ExtPItemObj.FinishSchemeThesis; 144 | begin 145 | with Scheme(0,GetBlock^.nSchLab)^ do 146 | begin 147 | SchProps.AtPut(0, gPrep^.nLastProposition^.nSentence^.CopyFormula); 148 | nSchState:= schStateQuotable; // safety 149 | end; 150 | end; 151 | 152 | procedure ExtPItemObj.StartDefTheorem; 153 | begin nDefThConstr:= InFile.Current; end; 154 | 155 | procedure ExtPItemObj.FinishTheoremBody; 156 | begin 157 | if gTheoremNbr >= length(gTheorem) then 158 | setlength(gTheorem,2*length(gTheorem)); 159 | inc(gTheoremNbr); 160 | with gTheorem[gTheoremNbr] do 161 | begin 162 | Theo := gPrep^.nLastProposition^.nSentence^.CopyFormula; 163 | Definitional:= (gPrep^.nLastProposition^.nKind = propDefTheorem); 164 | nDefConstr:= nDefThConstr; 165 | end; 166 | end; 167 | 168 | procedure ExtPItemObj.FinishCanceledScheme; 169 | begin 170 | if gSchemeNbr >= length(gScheme) then 171 | setlength(gScheme,2*length(gScheme)); 172 | inc(gSchemeNbr); 173 | with gScheme[gSchemeNbr] do 174 | begin 175 | nCanceled:=true; 176 | nSchemeDef:=nil; 177 | end; 178 | end; 179 | 180 | procedure ExtPItemObj.FinishCanceled; 181 | begin 182 | if gTheoremNbr >= length(gTheorem) then 183 | setlength(gTheorem,2*length(gTheorem)); 184 | inc(gTheoremNbr); 185 | with gTheorem[gTheoremNbr] do 186 | begin 187 | Theo:=NewVerum; 188 | Definitional:=false; 189 | nDefConstr.Kind:=ikError; 190 | end; 191 | end; 192 | 193 | procedure ExtPItemObj.FinishCanceledDef; 194 | begin 195 | if gTheoremNbr >= length(gTheorem) then 196 | setlength(gTheorem,2*length(gTheorem)); 197 | inc(gTheoremNbr); 198 | with gTheorem[gTheoremNbr] do 199 | begin 200 | Theo:=NewVerum; 201 | Definitional:=true; 202 | nDefConstr.Kind:=ikError; 203 | end; 204 | end; 205 | 206 | procedure ExtPBlockObj.InitPrepData; 207 | begin 208 | Load_EnvConstructors; 209 | Ord_Scheme.Init(0, 16); 210 | Ord_Scheme.Insert(new(SchRefPtr, Init1)); 211 | setlength(gTheorem,MaxTheoNbr); 212 | gTheoremNbr:=0; 213 | setlength(gScheme,MaxTheoNbr); 214 | with gScheme[0] do 215 | begin 216 | nCanceled:=true; 217 | nSchemeDef:=nil; 218 | end; 219 | gSchemeNbr:=0; 220 | end; 221 | 222 | end. 223 | -------------------------------------------------------------------------------- /kernel/enums.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit enums; 8 | 9 | // Definitions of some enumerated types and simple 10 | // (usually conversion) functions on them mainly used in correl 11 | 12 | interface 13 | 14 | uses limits, lexicon; 15 | 16 | type 17 | 18 | ConstructorsKind = (coMode,coStructMode,coAttribute,coPredicate, 19 | coFunctor,coSelector,coAggregate); 20 | 21 | NotationKind = (noMode,noStructMode,noAttribute,noPredicate, 22 | noFunctor,noSelector,noAggregate,noForgetFunctor); 23 | 24 | ClusterKind = (clRegistered,clConditional,clFunctor); 25 | 26 | SymbolKind = (symMode,symStructure,symAttribute,symPredicate, 27 | symFunctor,symLeftBracket,symRightBracket,symSelector); 28 | 29 | ComplexTrmExprKind = 30 | ( expTrmFunctor,expTrmAggreg,expTrmSelector,expTrmPrivFunc,expTrmSchFunc, 31 | expTrmChoice,expTrmFraenkel ); 32 | FuncTrmExprKind = expTrmFunctor..expTrmSchFunc; 33 | 34 | ConstrIntArr = array[ConstructorsKind] of integer; 35 | NotationIntArr = array[NotationKind] of integer; 36 | SymbolIntArr = array[SymbolKind] of integer; 37 | 38 | var 39 | TrmKindArr: array[ComplexTrmExprKind] of char 40 | = ( ikTrmFunctor, 41 | ikTrmAggreg, 42 | ikTrmSelector, 43 | ikTrmPrivFunc, 44 | ikTrmSchFunc, 45 | ikTrmChoice, 46 | ikTrmFraenkel ); 47 | 48 | function ConstructorRepr(fKind: ConstructorsKind): char; 49 | function ConstructorKind(fKind: char): ConstructorsKind; 50 | function SgnKind(fKind: char): ConstructorsKind; 51 | function SgnRepr(fKind: ConstructorsKind): char; 52 | 53 | function NotationRepr(fKind: NotationKind): char; 54 | function NotatKind(fKind: char): NotationKind; 55 | function NotatSgnKind(fKind: char): NotationKind; 56 | function NotationSgnRepr(fKind: NotationKind): char; 57 | 58 | // could be arrays probably 59 | function ConstrIndex( fKind: ConstructorsKind): IndexSort; 60 | function NotatIndex( fKind: NotationKind): IndexSort; 61 | 62 | function MaxNotatNbr(fKind: NotationKind): integer; 63 | 64 | // constructor kinds for which type is printed 65 | const TypedConstrKinds = 66 | [coFunctor, coMode, coAttribute, coAggregate, coSelector]; 67 | 68 | const MaxRenumNbr = MaxFuncNbr; { TODO: should be in limits depending on 69 | symbol and constructor numbers} 70 | 71 | 72 | implementation 73 | uses errhan; 74 | 75 | function ConstructorRepr(fKind: ConstructorsKind): char; 76 | begin 77 | case fKind of 78 | coMode: ConstructorRepr:='M'; 79 | coStructMode: ConstructorRepr:='L'; 80 | coAttribute: ConstructorRepr:='V'; 81 | coPredicate: ConstructorRepr:='R'; 82 | coFunctor: ConstructorRepr:='K'; 83 | coSelector: ConstructorRepr:='U'; 84 | coAggregate: ConstructorRepr:='G'; 85 | else RunTimeError(2210); 86 | end; 87 | end; 88 | 89 | function ConstructorKind(fKind: char): ConstructorsKind; 90 | begin 91 | case fKInd of 92 | 'M': ConstructorKind:=coMode; 93 | 'L': ConstructorKind:=coStructMode; 94 | 'V': ConstructorKind:=coAttribute; 95 | 'R': ConstructorKind:=coPredicate; 96 | 'K': ConstructorKind:=coFunctor; 97 | 'U': ConstructorKind:=coSelector; 98 | 'G','J': ConstructorKind:=coAggregate; 99 | else RunTimeError(2211); 100 | end; 101 | end; 102 | 103 | function NotationRepr(fKind: NotationKind): char; 104 | begin 105 | case fKInd of 106 | noFunctor : NotationRepr:= 'K' {ikSgnFunctor}; 107 | noAttribute : NotationRepr:= 'V' {ikSgnAttribute}; 108 | noMode : NotationRepr:= 'M' {ikSgnMode}; 109 | noPredicate : NotationRepr:= 'R' {ikSgnPredicate}; 110 | noStructMode : NotationRepr:= 'L' {ikSgnStructMode}; 111 | noAggregate : NotationRepr:= 'G' {ikSgnAggregate}; 112 | noSelector : NotationRepr:= 'U' {ikSgnSelector}; 113 | noForgetFunctor: NotationRepr:= 'J' {ikSgnForgetFunc}; 114 | else RunTimeError(2212); 115 | end; 116 | end; 117 | 118 | function NotationSgnRepr(fKind: NotationKind): char; 119 | begin 120 | case fKInd of 121 | noFunctor : NotationSgnRepr:= ikSgnFunctor; 122 | noAttribute : NotationSgnRepr:= ikSgnAttribute; 123 | noMode : NotationSgnRepr:= ikSgnMode; 124 | noPredicate : NotationSgnRepr:= ikSgnPredicate; 125 | noStructMode : NotationSgnRepr:= ikSgnStructMode; 126 | noAggregate : NotationSgnRepr:= ikSgnAggregate; 127 | noSelector : NotationSgnRepr:= ikSgnSelector; 128 | noForgetFunctor: NotationSgnRepr:= ikSgnForgetFunc; 129 | else RunTimeError(2213); 130 | end; 131 | end; 132 | 133 | function NotatKind(fKind: char): NotationKind; 134 | begin 135 | case fKInd of 136 | 'K' : NotatKind:= noFunctor; 137 | 'V' : NotatKind:= noAttribute; 138 | 'M' : NotatKind:= noMode; 139 | 'R' : NotatKind:= noPredicate; 140 | 'L' : NotatKind:= noStructMode; 141 | 'G' : NotatKind:= noAggregate; 142 | 'U' : NotatKind:= noSelector; 143 | 'J' : NotatKind:= noForgetFunctor; 144 | else RunTimeError(2214); 145 | end; 146 | end; 147 | 148 | function NotatSgnKind(fKind: char): NotationKind; 149 | begin 150 | case fKInd of 151 | ikSgnFunctor : NotatSgnKind:= noFunctor; 152 | ikSgnAttribute : NotatSgnKind:= noAttribute; 153 | ikSgnMode : NotatSgnKind:= noMode; 154 | ikSgnPredicate : NotatSgnKind:= noPredicate; 155 | ikSgnStructMode : NotatSgnKind:= noStructMode; 156 | ikSgnAggregate : NotatSgnKind:= noAggregate; 157 | ikSgnSelector : NotatSgnKind:= noSelector; 158 | ikSgnForgetFunc : NotatSgnKind:= noForgetFunctor; 159 | else RunTimeError(2215); 160 | end; 161 | end; 162 | 163 | function NotatIndex( fKind: NotationKind): IndexSort; 164 | begin 165 | case fKInd of 166 | noFunctor : NotatIndex:= FuncPattIndex; 167 | noAttribute : NotatIndex:= AttrPattIndex; 168 | noMode : NotatIndex:= ModePattIndex; 169 | noPredicate : NotatIndex:= PredPattIndex; 170 | noStructMode : NotatIndex:= StructPattIndex; 171 | noAggregate : NotatIndex:= StructPattIndex; 172 | noSelector : NotatIndex:= SelectPattIndex; 173 | noForgetFunctor: NotatIndex:= StructPattIndex; 174 | else RunTimeError(2216); 175 | end; 176 | end; 177 | 178 | function MaxNotatNbr(fKind: NotationKind): integer; 179 | begin MaxNotatNbr:= IndexLimit[ NotatIndex( fKind)]; end; 180 | 181 | // ##TODO: This duplicates ConstructorKind 182 | function SgnKind(fKind: char): ConstructorsKind; 183 | begin 184 | case fKind of 185 | ikSgnMode: SgnKind:=coMode; 186 | ikSgnStructMode: SgnKind:=coStructMode; 187 | ikSgnAttribute: SgnKind:=coAttribute; 188 | ikSgnPredicate: SgnKind:=coPredicate; 189 | ikSgnFunctor: SgnKind:=coFunctor; 190 | ikSgnSelector: SgnKind:=coSelector; 191 | ikSgnAggregate: SgnKind:=coAggregate; 192 | else RunTimeError(2217); 193 | end; 194 | end; 195 | 196 | // ##TODO: This duplicates ConstructorRepr 197 | function SgnRepr(fKind: ConstructorsKind): char; 198 | begin 199 | case fKind of 200 | coMode: SgnRepr:=ikSgnMode; 201 | coStructMode: SgnRepr:=ikSgnStructMode; 202 | coAttribute: SgnRepr:=ikSgnAttribute; 203 | coPredicate: SgnRepr:=ikSgnPredicate; 204 | coFunctor: SgnRepr:=ikSgnFunctor; 205 | coSelector: SgnRepr:=ikSgnSelector; 206 | coAggregate: SgnRepr:=ikSgnAggregate; 207 | else RunTimeError(2218); 208 | end; 209 | end; 210 | 211 | function ConstrIndex( fKind: ConstructorsKind): IndexSort; 212 | begin 213 | case fKind of 214 | coMode: ConstrIndex:=ModeIndex; 215 | coStructMode: ConstrIndex:=StructIndex; 216 | coAttribute: ConstrIndex:=AttrIndex; 217 | coPredicate: ConstrIndex:=PredIndex; 218 | coFunctor: ConstrIndex:=FuncIndex; 219 | coSelector: ConstrIndex:=SelectIndex; 220 | coAggregate: ConstrIndex:=StructIndex; 221 | else RunTimeError(2219); 222 | end; 223 | end; 224 | 225 | end. 226 | -------------------------------------------------------------------------------- /kernel/envinout.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit envinout; 8 | 9 | interface 10 | 11 | uses inout; 12 | 13 | var 14 | OutEnvFile: MizOutStream; 15 | 16 | implementation 17 | 18 | end. 19 | 20 | -------------------------------------------------------------------------------- /kernel/exporter.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program Exporter; 12 | 13 | uses extunit 14 | {$IFDEF MDEBUG} ,info,outinfo {$ENDIF}; 15 | 16 | begin 17 | MSMExportArticle; 18 | end. 19 | -------------------------------------------------------------------------------- /kernel/express.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit express; 8 | 9 | interface 10 | 11 | uses errhan,mobjects,inout; 12 | 13 | type 14 | ExpPtr = ^ Expression; 15 | Expression = 16 | object(MObject) 17 | ExpPos: Position; 18 | ExpSort: char; 19 | constructor InitExp(aSort:char); 20 | function Analyze: pointer; virtual; 21 | procedure ExpError(fNr:integer); 22 | end; 23 | 24 | implementation 25 | 26 | constructor Expression.InitExp(aSort:char); 27 | begin ExpPos:=CurPos; 28 | ExpSort:=aSort; 29 | end; 30 | 31 | function Expression.Analyze: pointer; 32 | begin Abstract1; Analyze:= nil; end; 33 | 34 | procedure Expression.ExpError(fNr:integer); 35 | begin Error(ExpPos,fNr) end; 36 | 37 | end. 38 | -------------------------------------------------------------------------------- /kernel/formats.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit formats; 8 | 9 | interface 10 | 11 | uses mobjects,inout,dicthan,_formats; 12 | 13 | type 14 | FormatPtr = MFormatPtr; 15 | 16 | PrefixFormatPtr = MPrefixFormatPtr; 17 | 18 | InfixFormatPtr = MInfixFormatPtr; 19 | 20 | BracketFormatPtr = MBracketFormatPtr; 21 | 22 | FormatsListPtr = MFormatsListPtr; 23 | 24 | FormatsList= MFormatsList; 25 | 26 | function In_Format( var fInFile: MizXInStream): FormatPtr; 27 | procedure Out_Format(var fOutFile: MizXOutStream; fForm: FormatPtr; aFormNr: integer); 28 | 29 | // tells if SymbolTrans should be used for tranlsating symbol 30 | // numbers, used in transferer 31 | var 32 | DoStrans:boolean = false; 33 | SymbolTrans: ^SymbolIntSeqArr; 34 | 35 | // global symbol renumbering 36 | function STrans(fSymbolKind:char; fSymbolNr:integer): integer; 37 | 38 | implementation 39 | 40 | uses errhan,xmldict,xmlpars 41 | {$IFDEF MDEBUG} ,info {$ENDIF}; 42 | 43 | 44 | {global symbol renumbering} 45 | function STrans(fSymbolKind:char; fSymbolNr:integer): integer; 46 | begin 47 | if DoSTrans then 48 | begin 49 | STrans:=SymbolTrans^[fSymbolKind].Value(fSymbolNr) 50 | end 51 | else 52 | STrans:= fSymbolNr; 53 | end; { STrans } 54 | 55 | 56 | function In_Format( var fInFile: MizXInStream): FormatPtr; 57 | var 58 | lLex: Lexem; 59 | lArgsNbr,lLeftArgsNbr,lRightSymNr:integer; 60 | begin 61 | with fInFile do 62 | begin 63 | GetLexemAttrs( atKind, atSymbolNr, lLex); 64 | lArgsNbr:= GetIntAttr( atArgNr); 65 | case lLex.Kind of 66 | 'O','R': 67 | begin 68 | lLeftArgsNbr:= GetIntAttr( atLeftArgNr); 69 | In_Format:= new(InfixFormatPtr, Init(lLex.Kind,lLex.Nr,lLeftArgsNbr, 70 | lArgsNbr - lLeftArgsNbr)); 71 | end; 72 | 'J','U','V','G','L','M': 73 | In_Format:= new(PrefixFormatPtr,Init(lLex.Kind,lLex.Nr,lArgsNbr)); 74 | 'K': 75 | begin 76 | lRightSymNr:= GetIntAttr( atRightSymbolNr); 77 | In_Format:= new(BracketFormatPtr, Init(lLex.Nr, lRightSymNr, 78 | lArgsNbr, 0, 0)); 79 | end; 80 | else RunTimeError(2019); 81 | end; 82 | AcceptEndState; 83 | NextElementState; 84 | end; 85 | end; 86 | 87 | // ##TODO: since STrans is needed, OutMMLFileObj must be used; 88 | // so either include iocorrel or move this there 89 | // ##TODO: Is 'J' still used 90 | // if aFormNr = 0, the atNr is not printed 91 | (* ##RNC: 92 | ## Format keeps the kind of a given symbol and arities. 93 | ## For bracket formats (K) this keeps both symbols. 94 | ## Optionally a nr (of the format) is kept, to which patterns may refer, 95 | ## This implementation might change in some time. 96 | elFormat = 97 | element elFormat { 98 | attribute atKind {'G'|'K'|'J'|'L'|'M'|'O'|'R'|'U'|'V'}, 99 | attribute atNr { xsd:integer }?, 100 | attribute atSymbolNr { xsd:integer }, 101 | attribute atArgNr { xsd:integer }, 102 | attribute atLeftArgNr { xsd:integer }?, 103 | attribute atRightSymbolNr { xsd:integer }? 104 | } 105 | *) 106 | 107 | procedure Out_Format( var fOutFile: MizXOutStream; fForm: FormatPtr; aFormNr: integer); 108 | begin 109 | with fOutFile,fForm^ do 110 | begin 111 | Out_XElStart( elFormat); 112 | Out_XAttr( atKind, fSymbol.Kind); 113 | if aFormNr > 0 then Out_XIntAttr( atNr, aFormNr); 114 | if fSymbol.Kind in ['L','J'] then 115 | Out_XIntAttr( atSymbolNr, STrans( 'G', fSymbol.Nr)) 116 | else Out_XIntAttr( atSymbolNr, STrans( fSymbol.Kind, fSymbol.Nr)); 117 | case fSymbol.Kind of 118 | 'J','U','V','G','L','M': 119 | Out_XIntAttr( atArgNr, PrefixFormatPtr(fForm)^.fRightArgsNbr); 120 | 'O','R': 121 | with InfixFormatPtr(fForm)^ do 122 | begin 123 | Out_XIntAttr( atArgNr, fLeftArgsNbr+fRightArgsNbr); 124 | Out_XIntAttr( atLeftArgNr, fLeftArgsNbr); 125 | end; 126 | 'K': 127 | with BracketFormatPtr(fForm)^ do 128 | begin 129 | Out_XIntAttr( atArgNr, fArgsNbr); 130 | Out_XIntAttr( atRightSymbolNr, STrans( 'L', fRightSymbolNr)); 131 | end; 132 | else RuntimeError(3300); 133 | end; 134 | Out_XElEnd0; 135 | end; 136 | end; 137 | 138 | 139 | end. 140 | 141 | -------------------------------------------------------------------------------- /kernel/heapctrl.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit heapctrl; 8 | 9 | interface 10 | 11 | function BlockSize(Size:pointer):longint; 12 | procedure InfoHeap; 13 | procedure HeapControl(fErrNr:integer); 14 | 15 | implementation 16 | 17 | uses info; 18 | 19 | type 20 | PFreeRec = ^TFreeRec; 21 | TFreeRec = 22 | record Next: PFreeRec; Size: Pointer; end; 23 | function BlockSize(Size:pointer):longint; 24 | type PtrRec = record Lo, Hi: Word end; 25 | begin BlockSize:=Longint(PtrRec(Size).Hi)*16 + PtrRec(Size).Lo end; 26 | 27 | procedure InfoHeap; 28 | var lPtr: PFreeRec; 29 | k:integer; 30 | begin lPtr:=FreeList; k:=0; 31 | writeln(InfoFile,'FreeList=',BlockSize(FreeList)); 32 | if FreeList <> HeapPtr then 33 | while lPtr <> HeapPtr do 34 | begin inc(k); write('.'); 35 | writeln(InfoFile,BlockSize(lPtr), 36 | '..',BlockSize(lPtr)+BlockSize(lPtr^.Size), 37 | ' (',BlockSize(lPtr^.Size),')'); 38 | 39 | lPtr:=lPtr^.Next; 40 | if k > 1000 then 41 | begin writeln(InfoFile,'Przerwane'); RunError(3000) end; 42 | end; 43 | writeln(InfoFile,'HeapPtr=',BlockSize(HeapPtr)); 44 | { writeln(InfoFile,'MaxAvail=',MaxAvail);} 45 | end; 46 | 47 | procedure HeapControl(fErrNr:integer); 48 | var lPtr: PFreeRec; lPrev: longint; 49 | begin lPtr:=FreeList; lPrev:=0; 50 | if FreeList <> HeapPtr then 51 | begin lPtr:=PFreeRec(FreeList)^.Next; 52 | while lPtr <> HeapPtr do 53 | begin 54 | if lPrev >= BlockSize(lPtr) then 55 | begin writeln(InfoFile,'*** ',fErrNr,' ***'); 56 | RunError(fErrNr); 57 | end; 58 | lPrev:=BlockSize(lPtr)+BlockSize(lPtr^.Size); 59 | if lPrev > BlockSize(HeapPtr) then 60 | begin writeln(InfoFile,'**** ',fErrNr,' ****'); 61 | RunError(fErrNr); 62 | end; 63 | lPtr:=lPtr^.Next; 64 | end; 65 | end; 66 | end; 67 | 68 | end. 69 | -------------------------------------------------------------------------------- /kernel/inenviro.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit inenviro; 8 | 9 | interface 10 | 11 | uses inout; 12 | 13 | var 14 | AfterClusters: boolean = false; 15 | implementation 16 | 17 | end. 18 | -------------------------------------------------------------------------------- /kernel/makeenv.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program MakeEnvironment; 12 | 13 | uses mobjects,pcmizver,mizenv,librenv,mconsole,monitor,errhan, 14 | mscanner,envhan,inlibr,acc_han 15 | {$IFDEF MDEBUG} ,info {$ENDIF}; 16 | var OldEvl: EnvironmentDescr; 17 | 18 | function EqEvl(const EVL1,EVL2: MSortedStrList): boolean; 19 | var k: integer; 20 | begin EqEvl:=false; 21 | if EVL1.Count <> EVL2.Count then exit; 22 | for k:=0 to EVL1.Count-1 do 23 | if PImpArticleId(EVL1.Items^[k])^.fStr <> 24 | PImpArticleId(EVL2.Items^[k])^.fStr then exit; 25 | EqEvl:=true; 26 | end; 27 | procedure CheckEvl; 28 | var lTime,lEVLTime,lFILTime: longint; 29 | lLocFiles: FileDescrCollection; 30 | i: integer; 31 | lDir: DirectiveKind; 32 | lvct:string; 33 | label 1; 34 | begin 35 | for lDir:=low(DirectiveKind) to High(DirectiveKind) do 36 | if not EqEvl(OldEvl.Directive[lDir],Env.Directive[lDir]) then 37 | begin Accomodation:=true; exit end; 38 | if MFileExists(MizFileName+'.fil') then 39 | begin lLocFiles.LoadFil(MizFileName+'.fil'); 40 | lFILTime:=GetFileTime(MizFileName+'.fil'); 41 | lEVLTime:=GetFileTime(EnvFileName+'.evl'); 42 | if lEVLTime > lFILTime then 43 | begin Accomodation:=true; goto 1 end; 44 | if lLocFiles.Count <> 0 then 45 | for i:=0 to lLocFiles.Count-1 do 46 | with PFileDescr(lLocFiles.Items^[i])^ do 47 | begin 48 | lvct:=nName^; 49 | delete(lvct,1,length(lvct)-4); 50 | if (lvct='.vct') and (nName^<>MizFiles+MML+'.vct') then begin Accomodation:=true; goto 1 end; 51 | lTime:=GetFileTime(nName^); 52 | if Time <> lTime then begin Accomodation:=true; goto 1 end; 53 | if lTime > lFILTime then begin Accomodation:=true; goto 1 end; 54 | end 55 | else Accomodation:=true; 56 | 1: 57 | lLocFiles.Done; 58 | end 59 | else begin Accomodation:=true; exit end; 60 | end; 61 | 62 | var _MizExitProc:pointer; 63 | 64 | procedure PCMizExitProc; 65 | begin 66 | ExitProc:=_MizExitProc; 67 | {$I-} 68 | if IOResult<>0 then; 69 | if LogOpened then CloseLogFile; 70 | if IOResult<>0 then; 71 | {$I+} 72 | end; 73 | 74 | begin 75 | DrawMizarScreen('Make Environment'); 76 | GetArticleName; GetEnvironName; 77 | FileExam(MizFileName+ArticleExt); 78 | InitExitProc; 79 | _MizExitProc := ExitProc; 80 | ExitProc:=@PCMizExitProc; 81 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 82 | OpenErrors(MizFileName); 83 | InitAccOptions; 84 | GetMEOptions; 85 | FileExam(MizFiles+MML+'.vct'); 86 | LocFilesCollection.Insert(New(PFileDescr,Init(MizFiles+MML+'.vct',0))); 87 | Env.ReadEnvironment; 88 | if ErrorNbr > 0 then 89 | begin 90 | DrawErrorsMsg(ErrorNbr); 91 | Halt(1) 92 | end; 93 | if not Accomodation then 94 | if MFileExists(EnvFileName+'.evl') then 95 | begin 96 | OldEvl.LoadEvl(EnvFileName+'.evl'); 97 | CheckEvl; 98 | end 99 | else Accomodation:=true; 100 | if Accomodation then 101 | begin 102 | OpenLogFile; 103 | Localization:=NewAccom; 104 | Accomodate; 105 | if ErrorNbr > 0 then 106 | begin 107 | DrawErrorsMsg(ErrorNbr); 108 | Halt(1) 109 | end; 110 | LocFilesCollection.StoreFIL(MizFileName+'.fil'); 111 | end; 112 | FinishDrawing; 113 | end. 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /kernel/naccom.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program Accomodator; 11 | 12 | uses librenv,pcmizver,mizenv,errhan,monitor,envhan,inlibr,acc_han, 13 | mconsole 14 | {$IFDEF MDEBUG} ,info {$ENDIF} 15 | ; 16 | 17 | var _MizExitProc:pointer; 18 | 19 | procedure PCMizExitProc; 20 | var I: integer; 21 | begin 22 | ExitProc:=_MizExitProc; 23 | {$I-} 24 | I:=IOResult; 25 | {$I+} 26 | CloseLogFile; 27 | end; 28 | 29 | begin 30 | DrawMizarScreen('New Accomodator'); 31 | GetArticleName; GetEnvironName; 32 | FileExam(MizFileName+ArticleExt); 33 | DrawArticleName(MizFileName+ArticleExt); 34 | InitExitProc; 35 | _MizExitProc := ExitProc; 36 | ExitProc:=@PCMizExitProc; 37 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 38 | OpenErrors(MizFileName); 39 | OpenLogFile; 40 | GetAccOptions; 41 | FileExam(MizFiles+MML+'.vct'); 42 | LocFilesCollection.Insert(New(PFileDescr,Init(MizFiles+MML+'.vct',0))); 43 | DrawPass('-Parsing'); 44 | Env.ReadEnvironment; 45 | Localization:=true; 46 | if ErrorNbr=0 then 47 | begin 48 | Accomodate; 49 | LocFilesCollection.StoreFIL(MizFileName+'.fil'); 50 | end; 51 | DrawErrorsMsg(ErrorNbr); 52 | FinishDrawing; 53 | end. 54 | -------------------------------------------------------------------------------- /kernel/outlibr.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | // ##TODO: kill this unit completely, it is replaced by OutMMLFileObj 8 | 9 | unit outlibr; 10 | 11 | interface 12 | 13 | procedure ReadSignatureList; 14 | 15 | // commented to find out wher it is yet needed 16 | // var OutLibrFile: MizOutStream; 17 | 18 | implementation 19 | 20 | uses errhan,mizenv,correl,mobjects,inout,inoutmml,lexicon 21 | {$IFDEF MDEBUG} 22 | ,info 23 | {$ENDIF}; 24 | 25 | procedure ReadSignatureList; 26 | var i,lImpSgnNbr: integer; s: string; lInFile: MizInStream; 27 | begin 28 | FileExam(EnvFileName+'.sgl'); 29 | lInFile.OpenFile(EnvFileName+'.sgl'); 30 | lInFile.InInt(lImpSgnNbr); 31 | gImpSgnNames.Init(lImpSgnNbr); 32 | for i:=1 to lImpSgnNbr do 33 | begin lInFile.InString(s); 34 | gImpSgnNames.Insert(new(MStrPtr,init(s))); 35 | end; 36 | lInFile.Done; 37 | end; 38 | 39 | 40 | end. 41 | -------------------------------------------------------------------------------- /kernel/prelhan.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | unit prelhan; 12 | 13 | interface 14 | 15 | procedure PRELTransfer; 16 | procedure CreatePREL; 17 | 18 | implementation 19 | 20 | uses 21 | pcmizver,mizenv,mconsole, 22 | mobjects,iocorrel,formats,inoutmml,impobjs, 23 | correl,generato,identify 24 | {$IFDEF MDEBUG}, info, outinfo {$ENDIF}; 25 | 26 | var AllConstrs: ImpMultConstrObj; 27 | 28 | function Exist( Ext:string):boolean; 29 | begin 30 | Exist:=MFileExists(MizFileName+'.'+Ext); 31 | end; 32 | 33 | function LibrFileName(Ext: string):string; 34 | begin 35 | if PublicLibr then 36 | LibrFileName:= 'prel'+DirSeparator+ArticleName[1]+DirSeparator+ArticleName+'.'+Ext 37 | else LibrFileName:= 'prel'+DirSeparator+ArticleName+'.'+Ext; 38 | end; { LibrFileName } 39 | 40 | procedure ProcessTYP; 41 | var existsdco:boolean; 42 | begin 43 | with AllConstrs do 44 | begin 45 | DoCTrans := false; 46 | existsdco := AddDCO; 47 | if not existsdco then exit; 48 | InitMark; 49 | Mark(fBases); 50 | Renumerate(true); 51 | DoCTrans := true; 52 | DrawPass('Constructors file is transfered into the local library'); 53 | PutMarked(nil,LibrFileName('dco')); 54 | { writes a file in the old format } 55 | {$ifdef IMPDEBUG} 56 | PutOldConstructors(LibrFileName('test')); 57 | ImpMultConstrObj(AllConstrs).PutOldConstructors(LibrFileName('test1')); 58 | {$ENDIF} 59 | end; 60 | end; 61 | 62 | procedure Formats; 63 | var lFormats: ImpFormatsMarkingObj; 64 | begin 65 | if not Exist('dfr') then exit; 66 | with lFormats do 67 | begin 68 | DrawPass('Formats file is transfered into the local library'); 69 | DoCTrans := false; 70 | GetFormats(MizFileName+'.dfr'); 71 | MarkDicts; 72 | Renumerate; 73 | DoCTrans := true; 74 | DoSTrans := true; 75 | SymbolTrans:= @fSymbolTrans; 76 | PutMarked(LibrFileName('dfr')); 77 | DoCTrans := false; 78 | DoSTrans := false; 79 | Done; 80 | end; 81 | end; 82 | 83 | procedure Signature; 84 | var lNotation: ImpNotationMarkingObj; 85 | begin 86 | if not Exist('dno') then exit; 87 | with lNotation do 88 | begin 89 | DrawPass('Notations file is transfered into the local library'); 90 | DoCTrans := false; 91 | GetNotation(MizFileName+'.dno'); 92 | { TODO remove this after debugging, PutNotation will be in XML too} 93 | {$IFDEF IMPDEBUG} 94 | PutNotation(MizFileName+'test1'+'.dno'); 95 | ImpNotationMarkingObj(lNotation).PutNotation(MizFileName+'test2'+'.dno'); 96 | {$ENDIF} 97 | MarkDicts; 98 | Renumerate; 99 | AllConstrs.InitMark; 100 | Mark(AllConstrs.fConstrCounts); 101 | AllConstrs.Renumerate(false); 102 | DoCTrans := true; 103 | DoSTrans := true; 104 | SymbolTrans:= @fSymbolTrans; {TODO: quite risky, it will get disposed} 105 | PutMarked(@AllConstrs,LibrFileName('dno')); 106 | 107 | DoCTrans := false; 108 | DoSTrans := false; 109 | Done; 110 | end; 111 | end; 112 | 113 | procedure Clusters; 114 | var lClusters: ImpClustersObj; 115 | begin 116 | if not Exist('dcl') then exit; 117 | with lClusters do 118 | begin 119 | DrawPass('Cluster registrations file is transfered into the local library'); 120 | DoCTrans := false; 121 | GetClusters(MizFileName+'.dcl'); 122 | AllConstrs.InitMark; 123 | Mark(AllConstrs.fConstrCounts); 124 | AllConstrs.Renumerate(false); 125 | DoCTrans := true; 126 | PutMarked(@AllConstrs,LibrFileName('dcl')); 127 | Done; 128 | end; 129 | end; 130 | 131 | procedure Identify; 132 | var lFuncIds: ImpIdentifyObj; 133 | begin 134 | if not Exist('did') then exit; 135 | with lFuncIds do 136 | begin 137 | DrawPass('Identify registrations file is transfered into the local library'); 138 | DoCTrans := false; 139 | GetIdentify(MizFileName+'.did'); 140 | AllConstrs.InitMark; 141 | Mark(AllConstrs.fConstrCounts); 142 | AllConstrs.Renumerate(false); 143 | DoCTrans := true; 144 | PutMarked(@AllConstrs,LibrFileName('did')); 145 | Done; 146 | end; 147 | end; 148 | 149 | procedure Reductions; 150 | var lFuncIds: ImpReductionObj; 151 | begin 152 | if not Exist('drd') then exit; 153 | with lFuncIds do 154 | begin 155 | DrawPass('Reduction registrations file is transfered into the local library'); 156 | DoCTrans := false; 157 | GetReductions(MizFileName+'.drd'); 158 | AllConstrs.InitMark; 159 | Mark(AllConstrs.fConstrCounts); 160 | AllConstrs.Renumerate(false); 161 | DoCTrans := true; 162 | PutMarked(@AllConstrs,LibrFileName('drd')); 163 | Done; 164 | end; 165 | end; 166 | 167 | procedure Properties; 168 | var lFuncIds: ImpPropertiesObj; 169 | begin 170 | if not Exist('dpr') then exit; 171 | with lFuncIds do 172 | begin 173 | DrawPass('Properties registrations file is transfered into the local library'); 174 | DoCTrans := false; 175 | GetProperties(MizFileName+'.dpr'); 176 | AllConstrs.InitMark; 177 | Mark(AllConstrs.fConstrCounts); 178 | AllConstrs.Renumerate(false); 179 | DoCTrans := true; 180 | PutMarked(@AllConstrs,LibrFileName('dpr')); 181 | Done; 182 | end; 183 | end; 184 | 185 | {REPLACED} 186 | procedure Definitions; 187 | var lDefinientia: ImpDefinientiaObj; 188 | begin 189 | if not Exist('def') then exit; 190 | with lDefinientia do 191 | begin 192 | DrawPass('Definitions file is transfered into the local library'); 193 | DoCTrans := false; 194 | GetDefinientia(MizFileName+'.def'); 195 | AllConstrs.InitMark; 196 | Mark(AllConstrs.fConstrCounts);; 197 | AllConstrs.Renumerate(false); 198 | DoCtrans := true; 199 | PutMarked(@AllConstrs,LibrFileName('def')); 200 | Done; 201 | end; 202 | end; 203 | 204 | {REPLACED} 205 | procedure Theorems; 206 | var lTheorems: ImpTheoremsObj; 207 | begin 208 | if not Exist('the') then exit; 209 | with lTheorems do 210 | begin 211 | DrawPass('Theorems file is transfered into the local library'); 212 | DoCTrans := false; 213 | GetTheorems(MizFileName+'.the'); 214 | AllConstrs.InitMark; 215 | Mark(AllConstrs.fConstrCounts); 216 | AllConstrs.Renumerate(false); 217 | DoCtrans := true; 218 | PutMarked(@AllConstrs,LibrFileName('the')); 219 | Done; 220 | end; 221 | end; 222 | 223 | {REPLACED} 224 | procedure Schemes; 225 | var lSchemes: ImpSchemeObj; 226 | begin 227 | if not Exist('sch') then exit; 228 | with lSchemes do 229 | begin 230 | DrawPass('Schemes file is transfered into the local library'); 231 | DoCTrans := false; 232 | GetSchemes(MizFileName+'.sch'); 233 | AllConstrs.InitMark; 234 | Mark(AllConstrs.fConstrCounts); 235 | AllConstrs.Renumerate(false); 236 | DoCtrans := true; 237 | PutMarked(@AllConstrs,LibrFileName('sch')); 238 | Done; 239 | end; 240 | end; 241 | 242 | procedure CreatePREL; 243 | var i:integer; 244 | begin 245 | {$I-} mkdir('prel'); i:=ioresult; 246 | if PublicLibr then 247 | begin 248 | mkdir('prel'+DirSeparator+ArticleName[1]); 249 | i:=ioresult 250 | end; 251 | {$I+} 252 | end; 253 | 254 | {------------------------------------------------------} 255 | 256 | procedure PRELTransfer; 257 | begin 258 | CreatePREL; 259 | DoSTrans := false; 260 | DoCTrans := false; 261 | Formats; 262 | AllConstrs.GetACO; 263 | ProcessTyp; 264 | Signature; 265 | Clusters; 266 | Identify; 267 | Reductions; 268 | Properties; 269 | Definitions; 270 | Theorems; 271 | Schemes; 272 | end; 273 | 274 | end. 275 | -------------------------------------------------------------------------------- /kernel/prochan.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit prochan; 8 | 9 | interface 10 | 11 | type 12 | DoInElem = procedure (fElem: pointer); 13 | PtrList = ^PtrElem; 14 | PtrElem = record NextPtr: PtrList; ElemPtr: pointer end; 15 | EqElem = function (fArg1,fArg2:pointer) : boolean; 16 | 17 | procedure ProcessPtrList(fList:PtrList; P:DoInElem); 18 | function EqPtrLists(fList1,fList2:PtrList; Eq:EqElem) : boolean; 19 | function EqPtrElems(fList1,fList2:PtrList; Eq:EqElem) : boolean; 20 | 21 | implementation 22 | uses errhan,limits; 23 | 24 | procedure ProcessPtrList(fList:PtrList; P:DoInElem); 25 | var i:integer; 26 | begin 27 | for i:=1 to MaxElemNbr do 28 | if fList=nil then exit else 29 | with fList^ do begin P(ElemPtr); fList:=NextPtr end; 30 | RunTimeError(2018); 31 | end; 32 | 33 | function EqPtrLists 34 | (fList1,fList2:PtrList; Eq:EqElem) : boolean; 35 | begin EqPtrLists:=false; 36 | while (fList1<>nil) and (fList2<>nil) do 37 | begin if not Eq(fList1^.ElemPtr,fList2^.ElemPtr) then exit; 38 | fList1:=fList1^.NextPtr; fList2:=fList2^.NextPtr; 39 | end; 40 | EqPtrLists:=fList1=fList2; 41 | end; 42 | 43 | function EqPtrElems 44 | (fList1,fList2:PtrList; Eq:EqElem) : boolean; 45 | begin EqPtrElems:=false; 46 | while fList1<>nil do 47 | begin mizassert(2505,fList2<>nil); 48 | if not Eq(fList1^.ElemPtr,fList2^.ElemPtr) then exit; 49 | fList1:=fList1^.NextPtr; fList2:=fList2^.NextPtr; 50 | end; 51 | mizassert(2506,fList2=nil); EqPtrElems:=true; 52 | end; 53 | 54 | 55 | end. 56 | -------------------------------------------------------------------------------- /kernel/schemhan.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit schemhan; 8 | 9 | interface 10 | 11 | uses errhan,correl,mobjects 12 | {$IFDEF MDEBUG} 13 | ,info 14 | {$ENDIF}; 15 | 16 | type 17 | SchemeStateKind = 18 | ( 19 | schStateCanceled, 20 | schStateMissingConstrs,// used to be PremNbr = -3 21 | schStateBeingProved,// used to be PremNbr = -2 22 | schStateErrorOccurred,// used to be PremNbr = -1 23 | schStateUnquotable,// used to be PremNbr = -1 24 | schStateQuotable// only this kind can be used 25 | ); 26 | 27 | SchemePtr = ^ SchemeObj; 28 | SchemeObj = object(MObject) 29 | fSchNr: word; 30 | fSchTypes,fSchProps: MCollection; 31 | constructor Init(aNr: word);//(const aName: string); 32 | destructor Done; virtual; 33 | end; 34 | 35 | SchRefPtr = ^SchRefItem; 36 | SchRefItem = object(IntPairItem) 37 | SchTypes, 38 | SchProps: MCollection; 39 | nSchState: SchemeStateKind; 40 | constructor Init(aMMLNr,aNr: integer; 41 | var aSchTypes,aSchProps: MCollection; 42 | fSchState: SchemeStateKind); 43 | constructor Init1; 44 | end; 45 | 46 | var 47 | SchReferNbr: BinIntFunc; 48 | Ord_Scheme: IntPairKeyCollection; 49 | 50 | function Scheme(FileNr,SchNr: integer): SchRefPtr; 51 | 52 | implementation 53 | 54 | constructor SchemeObj.Init(aNr: word); 55 | begin 56 | fSchNr:=aNr; 57 | fSchTypes.Init(4,4); 58 | fSchProps.Init (4,4); 59 | end; 60 | 61 | destructor SchemeObj.Done; 62 | begin 63 | fSchTypes.Done; 64 | fSchProps.Done; 65 | inherited Done; 66 | end; 67 | 68 | function Scheme(FileNr,SchNr: integer): SchRefPtr; 69 | begin 70 | Result:=SchRefPtr(Ord_Scheme.ObjectOf(FileNr,SchNr)); 71 | end; 72 | 73 | constructor SchRefItem.Init(aMMLNr,aNr: integer; 74 | var aSchTypes,aSchProps: MCollection; 75 | fSchState: SchemeStateKind); 76 | begin 77 | fKey.X:= aMMLNr; 78 | fKey.Y:= aNr; 79 | SchTypes.MoveCollection(aSchTypes); 80 | SchProps.MoveCollection(aSchProps); 81 | nSchState:= fSchState; 82 | end; 83 | 84 | constructor SchRefItem.Init1; 85 | begin 86 | fKey.X:= 0; 87 | fKey.Y:= 0; 88 | SchTypes.Init(0,4); 89 | SchProps.Init(0,4); 90 | nSchState:= schStateErrorOccurred; 91 | end; 92 | 93 | end. 94 | -------------------------------------------------------------------------------- /kernel/transfer.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program Transfer; 12 | 13 | uses pcmizver,mizenv,mconsole,monitor,prelhan 14 | {$IFDEF MDEBUG} ,info {$ENDIF}; 15 | 16 | {------------------------------------------------------} 17 | 18 | begin 19 | DrawMizarScreen('Transferer'); 20 | if ParamCount=0 then 21 | begin 22 | Noise; 23 | Writeln('Syntax: transfer articlename'); 24 | FinishDrawing; 25 | halt; 26 | end; 27 | GetMizFileName(''); 28 | InitExitProc; 29 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 30 | GetTransfOptions; 31 | PRELTransfer; 32 | FinishDrawing; 33 | end. 34 | 35 | -------------------------------------------------------------------------------- /kernel/verfinit.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit verfinit; 8 | 9 | interface 10 | 11 | uses errhan,mizprep; 12 | 13 | procedure MSMVerifyArticle(const aProgName: string; aError: ErrorReport 14 | {$IFNDEF PDEBUG} {$IFNDEF ADEBUG}; aChecker: Procedure0{$ENDIF} {$ENDIF} 15 | ); 16 | 17 | procedure ReviewArticle(const aName:string; aChkInf: Procedure0; aPBloc: MizPBlockPtr); 18 | 19 | procedure VerifierError(Pos:Position; ErrNr:integer); 20 | 21 | implementation 22 | 23 | uses 24 | mizenv,pcmizver,monitor,mconsole,mtime,_formats, parser, mscanner, 25 | parseraddition, wsmarticle ,first_identification, trans2analyzer 26 | {$IFNDEF PDEBUG}, analyzer 27 | {$IFNDEF ADEBUG}, prepobj, prephan, schemes 28 | {$ENDIF} 29 | {$ENDIF} 30 | {$IFDEF MDEBUG} ,info {$ENDIF}; 31 | 32 | var PassTime: longint; 33 | 34 | procedure InitPass(const aPassName: string); 35 | begin 36 | with CurPos do begin Line:=1; Col:=1 end; 37 | InitDisplayLine(aPassName); 38 | TimeMark(PassTime); 39 | {$IFDEF MDEBUG} 40 | writeln(InfoFile); writeln(InfoFile,' ':30,aPassName); 41 | writeln(InfoFile); 42 | {$ENDIF} 43 | end; 44 | 45 | procedure FinishPass; 46 | begin 47 | FinishingPass:=true; 48 | if QuietMode then DisplayLine(CurPos.Line,ErrorNbr); 49 | FinishingPass:=false; 50 | DrawTime(' '+ReportTime(PassTime)); 51 | end; 52 | 53 | procedure FollowingPass(const aPassName: string); 54 | begin FinishPass; InitPass(aPassName) end; 55 | 56 | procedure VerifierError(Pos:Position; ErrNr:integer); 57 | begin 58 | WriteError(Pos,ErrNr); 59 | DisplayLine(CurPos.Line,ErrorNbr); 60 | end; 61 | 62 | var _MizExitProc: pointer; 63 | 64 | procedure VerifierExitProc;{(ErrorCode: word);} {*MZ kto tego ErrorCode uzywa?} 65 | begin 66 | ExitProc:=_MizExitProc; 67 | {$I-} 68 | if IOResult<>0 then; 69 | if not StopOnError then DisplayLine(CurPos.Line,ErrorNbr); 70 | PutError:=WriteError; 71 | DrawVerifierExit(ReportTime(gStartTime)); 72 | { Halt(ErrorCode);} 73 | {$I+} 74 | end; 75 | 76 | procedure InitVerifier(const aProgName: string; aError: ErrorReport); 77 | begin 78 | DrawMizarScreen(aProgName); 79 | if paramcount<1 then EmptyParameterList; 80 | GetArticleName; GetEnvironName; 81 | DrawArticleName(MizFileName+ArticleExt); 82 | GetOptions; 83 | InitExitProc; 84 | FileExam(MizFileName+ArticleExt); 85 | _MizExitProc := ExitProc; ExitProc:=@VerifierExitProc; 86 | PutError:=aError; 87 | OpenErrors(MizFileName); 88 | {$IFDEF MDEBUG} 89 | OpenInfoFile; 90 | {$ENDIF} 91 | end; 92 | 93 | procedure MSMVerifyArticle; 94 | begin 95 | InitVerifier(aProgname,aError); 96 | {------------------ Parsing ------------------------} 97 | if not CheckerOnly then 98 | begin 99 | InitPass('Parser '); 100 | FileExam(EnvFileName+'.dct'); 101 | InitScanning(MizFileName+ArticleExt,EnvFileName); 102 | InitWSMizarArticle; 103 | Parse; 104 | gFormatsColl.StoreFormats(EnvFileName+'.frx'); 105 | gFormatsColl.Done; 106 | FinishScanning; 107 | Write_WSMizArticle(gWSTextProper,EnvFileName+'.wsx'); 108 | FollowingPass('MSM '); 109 | MSMAnalyzer; 110 | Transfer2Analyzer; 111 | end; 112 | {$IFNDEF PDEBUG} 113 | if not ParserOnly then 114 | begin 115 | {------------------ Analyser ------------------------} 116 | if not CheckerOnly then 117 | begin 118 | FollowingPass('Analyzer'); 119 | Analyze; 120 | DisposeAnalyze; 121 | end; 122 | {------------------ Checker ------------------------} 123 | {$IFNDEF ADEBUG} 124 | if not AnalyzerOnly then 125 | begin 126 | if CheckerOnly then 127 | InitPass('Checker ') 128 | else FollowingPass('Checker '); 129 | ChkInference:=aChecker; 130 | gPrBlockPtr:=new(MizPBlockPtr,Init(blMain)); 131 | MizPBlockPtr(gPrBlockPtr)^.InitPrepData; 132 | Prepare; 133 | end; 134 | {$ENDIF} 135 | end; 136 | {$ENDIF} 137 | FinishPass; 138 | end; 139 | 140 | procedure ReviewArticle(const aName:string; aChkInf: Procedure0; aPBloc: MizPBlockPtr); 141 | begin 142 | DrawMizarScreen(aName); 143 | if paramcount<1 then EmptyParameterList; 144 | GetArticleName; GetEnvironName; 145 | GetOptions; 146 | InitExitProc; 147 | FileExam(MizFileName+ArticleExt); 148 | DrawArticleName(MizFileName+ArticleExt); 149 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 150 | OpenErrors(MizFileName); 151 | 152 | InitDisplayLine('Parser '); 153 | FileExam(EnvFileName+'.dct'); 154 | InitScanning(MizFileName+ArticleExt,EnvFileName); 155 | InitWSMizarArticle; 156 | Parse; 157 | gFormatsColl.StoreFormats(EnvFileName+'.frx'); 158 | gFormatsColl.Done; 159 | FinishScanning; 160 | Write_WSMizArticle(gWSTextProper,EnvFileName+'.wsx'); 161 | InitDisplayLine('MSM '); 162 | MSMAnalyzer; 163 | Transfer2Analyzer; 164 | 165 | InitDisplayLine('Analyser'); 166 | Analyze; 167 | DisposeAnalyze; 168 | DisplayLine(CurPos.Line,ErrorNbr); 169 | CurPos.Line:=1; 170 | 171 | InitDisplayLine('Checker '); 172 | if @aChkInf <> nil then 173 | ChkInference:=aChkInf; 174 | gPrBlockPtr:=aPBloc; 175 | MizPBlockPtr(gPrBlockPtr)^.InitPrepData; 176 | Prepare; 177 | DisplayLine(CurPos.Line,ErrorNbr); 178 | DrawErrorsMSg(ErrorNbr); 179 | FinishDrawing; 180 | 181 | end; 182 | 183 | end. 184 | -------------------------------------------------------------------------------- /kernel/verifier.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program MizarVerifier; 11 | 12 | uses errhan,verfinit 13 | {$IFNDEF PDEBUG}{$IFNDEF ADEBUG},mizprep{$ENDIF} {$ENDIF}; 14 | 15 | begin 16 | MSMVerifyArticle('Verifier based on More Strict Mizar Processor', VerifierError 17 | {$IFNDEF PDEBUG} {$IFNDEF ADEBUG},ClassicalChecker{$ENDIF} {$ENDIF} 18 | ); 19 | end. 20 | 21 | -------------------------------------------------------------------------------- /kernel/xmlpars.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit xmlpars; 8 | 9 | interface 10 | 11 | uses xml_parser,xmldict; 12 | 13 | // for xml tokenizer 14 | type 15 | 16 | XMLParsObj = object(XMLParserObj) 17 | nElKind : TXMLElemKind; // kind of nElName 18 | constructor InitParsing(const aFileName:string); 19 | procedure OpenStartTag; virtual; 20 | end; 21 | 22 | procedure UnexpectedElem( aElem:TXMLElemKind; aErr:integer; aExpected: TXMLElemSet); 23 | 24 | implementation 25 | {$IFDEF MDEBUG} uses info; {$ENDIF} 26 | 27 | procedure UnexpectedElem( aElem:TXMLElemKind; aErr:integer; 28 | aExpected: TXMLElemSet); 29 | {$IFDEF MDEBUG} 30 | var lEl:string; 31 | {$ENDIF} 32 | begin 33 | {$IFDEF MDEBUG} 34 | InfoNewLine; 35 | // InfoString('Unexpected elem: '+ XMLElemName[aElem]+'; expected:'); 36 | // for lEl := Low(string) to High(string) do 37 | // if lEl in aExpected then InfoString( XMLElemName[lEl]+','); 38 | {$ENDIF} 39 | UnexpectedXMLElem(XMLElemName[aElem], aErr); 40 | end; 41 | 42 | constructor XMLParsObj.InitParsing(const aFileName:string); 43 | begin 44 | inherited InitParsing(aFileName); 45 | end; 46 | 47 | procedure XMLParsObj.OpenStartTag; 48 | begin 49 | inherited OpenStartTag; 50 | nElKind:= Str2XMLElemKind( nSpelling); 51 | end; 52 | 53 | // Very simple (Tiny) XML parser 54 | procedure ReadXML(const aFileName:string); 55 | var lXMLParser: XmlParsObj; lIndent,i:integer; 56 | begin 57 | lXMLParser.InitParsing(aFileName); 58 | lIndent:=0; 59 | with lXMLParser do 60 | // Document Type Definition is missed and the preliminary part of Standard XML 61 | while (nCurTokenKind <> EOTX) do 62 | begin 63 | NextElementState; 64 | if nState= eStart then 65 | begin 66 | for i:=1 to lIndent do write(' '); 67 | writeln(nElName + ' ' + XMLElemName[ nElKind]); 68 | inc(lIndent); 69 | end 70 | else 71 | begin 72 | dec(lIndent); 73 | for i:=1 to lIndent do write(' '); 74 | writeln(''); 75 | end; 76 | end; 77 | lXMLParser.Done; 78 | end; 79 | (* 80 | begin 81 | DrawMizarScreen('Tiny XML Parser for Mizar'); 82 | InitExitProc; 83 | GetMizFileName('.xml'); 84 | FileExam(MizFileName+ArticleExt); 85 | OpenErrors(MizFileName); 86 | ReadXML(MizFileName+ArticleExt); 87 | DrawErrorsMsg(ErrorNbr); 88 | FinishDrawing; 89 | *) 90 | end. 91 | -------------------------------------------------------------------------------- /libtools/checkvoc.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program CheckingVocabulary; 11 | 12 | uses mobjects,pcmizver,mizenv,inout,librenv,monitor,mscanner,scanner,accdict, 13 | envhan,dicthan,mconsole; 14 | 15 | var gPrivVoc: PVocabulary; 16 | gVocsColl: MStringList; 17 | gTokens: TokensCollection; 18 | 19 | function FindSymbol(fRepr:string):PSymbol; 20 | function EqSymbol(Item:PSymbol): boolean; 21 | begin 22 | EqSymbol:=Item^.Repr = fRepr; 23 | end; 24 | var z: integer; 25 | begin 26 | FindSymbol := nil; 27 | with gPrivVoc^.Reprs do 28 | for z:=0 to Count-1 do 29 | if EqSymbol(Items^[z]) then 30 | begin FindSymbol :=Items^[z]; exit end; 31 | end; 32 | 33 | procedure CheckSymbolsIn(fName:NameStr; fVoc:PVocabulary); 34 | var lPrintMsg: boolean; 35 | procedure PrintToken(fSymb: PSymbol); 36 | var lSymb:PSymbol; 37 | begin 38 | lPrintMsg:=false; 39 | lSymb:=FindSymbol(fSymb^.Repr); 40 | if lSymb <> nil then 41 | begin lPrintMsg:=true; 42 | writeln('Equal symbols:'); 43 | writeln(fName,':',' ':9-length(fName),fSymb^.SymbolStr); 44 | writeln(ArticleName,':',' ':9-length(ArticleName),lSymb^.SymbolStr); 45 | end; 46 | end; 47 | var z:integer; 48 | begin 49 | with fVoc^.Reprs do 50 | for z:=0 to Count-1 do PrintToken(PSymbol(Items^[z])); 51 | if lPrintMsg then writeln; 52 | end; 53 | 54 | procedure CheckWithMMLVocs; 55 | var i:integer; 56 | begin 57 | with gVocsColl do 58 | for i:=0 to fCount-1 do 59 | begin 60 | CheckSymbolsIn(GetString(i),PVocabulary(GetObject(i))); 61 | end; 62 | end; 63 | 64 | procedure CheckSymbols; 65 | procedure ChkSymbol(fSymb:PSymbol); 66 | var i: integer; 67 | begin 68 | with fSymb^ do 69 | begin 70 | if (Capital[Kind]=0) or not (Kind in AvailableSymbols) then 71 | begin 72 | writeln('wrong symbol kind: ',fSymb^.SymbolStr); 73 | end; 74 | if pos('::',Repr) <> 0 then 75 | begin 76 | writeln('comment "::" in symbol: ',fSymb^.SymbolStr); 77 | end; 78 | if pos(' ',Repr) <> 0 then 79 | begin 80 | writeln('space in symbol: ',fSymb^.SymbolStr); 81 | end; 82 | if (length(Repr) = 1) and (UpCase(Repr[1]) in ['A'..'Z']) then 83 | begin 84 | writeln('one letter symbol: ',fSymb^.SymbolStr); 85 | end; 86 | for i:=1 to length(Repr) do 87 | if Repr[i] in [#0..#31,#127..#255] then 88 | begin 89 | writeln('wrong character in symbol: ',fSymb^.SymbolStr); 90 | end; 91 | end; 92 | end; 93 | var lDict: PVocabulary; 94 | z: integer; 95 | begin 96 | FileExam(MizFiles+'mizar.dct'); 97 | gTokens.LoadDct(MizFiles+'mizar'); 98 | lDict:=new(PVocabulary,Init); 99 | for z:=0 to gTokens.Count-1 do 100 | lDict^.Reprs.Insert(new(PSymbol, Init('A',(TokenPtr(gTokens.Items^[z])^.fStr),'',0))); 101 | CheckSymbolsIn('mizar',lDict); 102 | Dispose(lDict,Done); 103 | gTokens.Done; 104 | with gPrivVoc^.Reprs do 105 | for z:=0 to Count-1 do ChkSymbol(PSymbol(Items^[z])); 106 | end; 107 | 108 | procedure BadParameters; 109 | begin 110 | if ParamCount > 0 then Exit; 111 | Noise; 112 | writeln('Syntax: checkvoc vocabularyname'); 113 | FinishDrawing; 114 | halt(2); 115 | end; 116 | 117 | var gVocsFileName: string; 118 | 119 | procedure InitParams; 120 | begin 121 | BadParameters; 122 | GetMizFileName('.voc'); 123 | if ParamCount >= 2 then GetFileName(2,'.vct',gVocsFileName) 124 | else gVocsFileName:=MizFiles+MML+'.vct'; 125 | end; 126 | 127 | begin 128 | DrawMizarScreen('Checking Vocabulary'); 129 | InitParams; 130 | if not MFileExists(MizFileName) then 131 | if MFileExists(MizFileName+'.voc') 132 | then MizFileName:=MizFileName+'.voc' 133 | else if MFileExists('dict'+DirSeparator+MizFileName+'.voc') 134 | then MizFileName:='dict'+DirSeparator+MizFileName+'.voc' 135 | else if MFileExists('dict'+DirSeparator+MizFileName) 136 | then MizFileName:='dict'+DirSeparator+MizFileName; 137 | gPrivVoc:=GetPrivateVoc(MizFileName); 138 | if gPrivVoc = nil then 139 | begin 140 | DrawMessage('Can''t open '' '+ChangeFileExt(MizFileName,'.voc'),''); 141 | exit; 142 | end; 143 | LoadMmlVcb(gVocsFileName,gVocsColl); 144 | CheckWithMMLVocs; 145 | CheckSymbols; 146 | gVocsColl.Done; 147 | FinishDrawing; 148 | end. 149 | 150 | -------------------------------------------------------------------------------- /libtools/chkrprem.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program IrrelevantPremises; 12 | 13 | uses verfinit,prepobj,mizprep,relpprep; 14 | 15 | begin 16 | ReviewArticle('Irrelevant Premises Detector (from the right hand side)',FindRelPrem, 17 | new(RelPremPBlockPtr,Init(blMain))); 18 | end. 19 | -------------------------------------------------------------------------------- /libtools/createvd.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program CreateEvd; 11 | 12 | uses pcmizver,mizenv,mconsole,monitor,envhan,mobjects,mscanner,info; 13 | 14 | var Target: text; 15 | TargetCol: integer; 16 | 17 | procedure WriteString(aStr: string; fTail: integer); 18 | begin 19 | aStr := ' ' + aStr; 20 | if (TargetCol + Length(aStr) + fTail) <= 79 then 21 | begin 22 | write(Target,aStr); 23 | inc(TargetCol,Length(aStr)); 24 | end 25 | else 26 | begin 27 | writeln(Target); 28 | write(Target,' ':5,aStr); 29 | TargetCol:=Length(aStr) + 5; 30 | end; 31 | end; 32 | 33 | procedure PrintDirectives(const DirName:string; const Directive: MSortedStrList); 34 | var i,FirstDir: integer; 35 | begin 36 | if Directive.Count = 0 then exit; 37 | FirstDir:=0; 38 | if PImpArticleId(Directive.Items^[0])^.fStr='HIDDEN' then 39 | begin FirstDir:=1; if Directive.Count = 1 then exit end; 40 | write(Target,' ',DirName); TargetCol:=Length(DirName)+1; 41 | for i:=FirstDir to Directive.Count-2 do 42 | begin 43 | WriteString(PImpArticleId(Directive.Items^[i])^.fStr,1); 44 | write(Target,','); inc(TargetCol); 45 | end; 46 | WriteString(PImpArticleId(Directive.Items^[Directive.Count-1])^.fStr,1); 47 | writeln(Target,';'); 48 | end; 49 | 50 | procedure CopyComments; 51 | var CMM: text; CommBuf: array[1..$1000] of char; 52 | Line: string; 53 | begin 54 | if MFileExists(MizFileName+'.cmm') then 55 | begin 56 | assign(CMM,MizFileName+'.cmm'); settextbuf(CMM,CommBuf); 57 | reset(CMM); 58 | while not eof(CMM) do 59 | begin 60 | readln(CMM,Line); writeln(Target,Line); 61 | end; 62 | writeln(Target); 63 | close(CMM); 64 | end; 65 | end; 66 | 67 | var TargetBuf: array[1..$1000] of char; 68 | 69 | begin 70 | DrawMizarScreen('Creating Environment Description'); 71 | InitExitProc; 72 | GetMizFileName('.evl'); GetEnvironName; 73 | {$IFDEF MDEBUG} 74 | OpenInfoFile; 75 | {$ENDIF} 76 | DrawArticleName(MizFileName); 77 | assign(Target,MizFileName+'.evd'); settextbuf(Target,TargetBuf); 78 | rewrite(Target); 79 | CopyComments; 80 | writeln(Target,'environ'); writeln(Target); 81 | Env.LoadEvl(EnvFileName+ArticleExt); 82 | PrintDirectives('vocabularies',Env.Directive[syVocabularies]); 83 | PrintDirectives('notations',Env.Directive[syNotations]); 84 | PrintDirectives('constructors',Env.Directive[syConstructors]); 85 | PrintDirectives('registrations',Env.Directive[syRegistrations]); 86 | PrintDirectives('requirements',Env.Directive[syRequirements]); 87 | PrintDirectives('definitions',Env.Directive[syDefinitions]); 88 | PrintDirectives('equalities',Env.Directive[syEqualities]); 89 | PrintDirectives('expansions',Env.Directive[syExpansions]); 90 | PrintDirectives('theorems',Env.Directive[syTheorems]); 91 | PrintDirectives('schemes',Env.Directive[sySchemes]); 92 | writeln(Target); 93 | close(Target); 94 | FinishDrawing; 95 | end. 96 | -------------------------------------------------------------------------------- /libtools/dellink.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | uses mconsole,mizenv,monitor,errhan,mscanner,syntax,parser; 11 | 12 | type 13 | LabelItemPtr = ^LabelItemObj; 14 | LabelItemObj = object(ItemObj) 15 | constructor Init(fKind:ItemKind); 16 | procedure Pop; virtual; 17 | procedure ProcessLabel; virtual; 18 | procedure ProcessDefiniensLabel; virtual; 19 | procedure ProcessPrivateReference; virtual; 20 | procedure StartSimpleJustification; virtual; 21 | end; 22 | 23 | LabelBlockPtr = ^LabelBlockObj; 24 | LabelBlockObj = object(BlockObj) 25 | constructor Init(fBlockKind:BlockKind); 26 | procedure Pop; virtual; 27 | procedure ProcessLink; virtual; 28 | procedure CreateItem(fItemKind:ItemKind); virtual; 29 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 30 | end; 31 | 32 | LabLevel = record 33 | Lab: String; 34 | Lev: Integer; 35 | isDef: Boolean; 36 | end; 37 | 38 | var 39 | edt :text; 40 | arrLab : Array[1..10000] of LabLevel; 41 | indexLab,indexThen,curLevel : Integer; 42 | iDelLink,iDelLinkHence : Boolean; 43 | 44 | procedure InitArticle; 45 | begin 46 | gBlockPtr:=New(LabelBlockPtr, Init(blMain)); 47 | end; 48 | 49 | constructor LabelItemObj.Init; 50 | begin inherited Init(fKind); 51 | end; 52 | 53 | procedure LabelItemObj.Pop; 54 | begin 55 | inherited Pop; 56 | end; 57 | 58 | procedure LabelItemObj.ProcessLabel; 59 | begin 60 | inc(indexLab); 61 | if AheadWord.Kind=sy_Colon then 62 | begin 63 | arrLab[indexLab].Lab:=CurWord.Spelling; 64 | arrLab[indexLab].Lev:=curLevel; 65 | arrLab[indexLab].isDef:=false; 66 | writeln(edt,'d',CurPos.Line,' ', 67 | CurPos.Col-length(CurWord.Spelling)+1,' ',AheadPos.line,' ', 68 | AheadPos.Col); 69 | writeln(edt,'i','R',indexLab,':'); 70 | end else 71 | if CurWord.Kind=sy_Hereby then 72 | begin 73 | arrLab[indexLab].Lab:='0'; 74 | arrLab[indexLab].Lev:=curLevel; 75 | arrLab[indexLab].isDef:=false; 76 | writeln(edt,'d',CurPos.Line,' ', 77 | CurPos.Col-length(CurWord.Spelling)+1,' ',CurPos.Line,' ', 78 | CurPos.Col); 79 | writeln(edt,'i','thus R',indexLab,': now'); 80 | end else 81 | begin 82 | arrLab[indexLab].Lab:='0'; 83 | arrLab[indexLab].Lev:=curLevel; 84 | arrLab[indexLab].isDef:=false; 85 | writeln(edt,'g',CurPos.Line,' ', 86 | CurPos.Col-length(CurWord.Spelling)+1); 87 | if (CurPos.Line=PrevPos.Line) and 88 | (CurPos.Col-length(CurWord.Spelling)=PrevPos.Col) 89 | then 90 | if iDelLink and not iDelLinkHence 91 | then writeln(edt,'i','R',indexLab,': ') 92 | else writeln(edt,'i',' R',indexLab,': ') 93 | else writeln(edt,'i','R',indexLab,': '); 94 | end; 95 | end; 96 | 97 | procedure LabelItemObj.ProcessDefiniensLabel; 98 | begin 99 | inc(indexLab); 100 | if AheadWord.Kind=sy_Colon then 101 | begin 102 | arrLab[indexLab].Lab:=CurWord.Spelling; 103 | arrLab[indexLab].Lev:=curLevel-1; 104 | arrLab[indexLab].isDef:=true; 105 | writeln(edt,'d',CurPos.Line,' ', 106 | CurPos.Col-length(CurWord.Spelling)+1,' ',AheadPos.line,' ', 107 | AheadPos.Col); 108 | writeln(edt,'i','R',indexLab,':'); 109 | end else 110 | begin 111 | arrLab[indexLab].Lab:='0'; 112 | arrLab[indexLab].Lev:=curLevel-1; 113 | arrLab[indexLab].isDef:=true; 114 | writeln(edt,'g',CurPos.Line,' ', 115 | CurPos.Col-length(CurWord.Spelling)+1); 116 | writeln(edt,'i',':R',indexLab,': '); 117 | end; 118 | end; 119 | 120 | procedure LabelItemObj.ProcessPrivateReference; 121 | var i,minLevel: Integer; 122 | begin 123 | minLevel:=curLevel; 124 | for i:= indexLab downto 1 do 125 | begin 126 | if (arrLab[i].Lev < minLevel) and not arrLab[i].isDef then 127 | minLevel:=arrLab[i].Lev; 128 | if (arrLab[i].Lev+1 < minLevel) and arrLab[i].isDef then 129 | minLevel:=arrLab[i].Lev+1; 130 | if (CurWord.Spelling=arrLab[i].Lab) and 131 | (minLevel>=arrLab[i].Lev) then 132 | begin 133 | writeln(edt,'d',CurPos.Line,' ', 134 | CurPos.Col-length(CurWord.Spelling)+1,' ',CurPos.Line,' ', 135 | CurPos.Col); 136 | writeln(edt,'i','R',i); 137 | break; 138 | end; 139 | end; 140 | end; 141 | 142 | procedure LabelItemObj.StartSimpleJustification; 143 | begin 144 | if iDelLink then 145 | begin 146 | if CurWord.Kind=sy_By then 147 | begin 148 | writeln(edt,'g',AheadPos.Line,' ', 149 | AheadPos.Col-length(AheadWord.Spelling)+1); 150 | writeln(edt,'i','R',indexThen,','); 151 | end; 152 | if CurWord.Kind=sy_Semicolon then 153 | begin 154 | writeln(edt,'g',CurPos.Line,' ',CurPos.Col); 155 | writeln(edt,'i',' by R',indexThen); 156 | end; 157 | if CurWord.Kind=sy_DotEquals then 158 | begin 159 | writeln(edt,'g',PrevPos.Line,' ',PrevPos.Col+1); 160 | writeln(edt,'i',' by R',indexThen); 161 | end; 162 | end; 163 | iDelLink:=False; 164 | iDelLinkHence:=False; 165 | end; 166 | 167 | constructor LabelBlockObj.Init; 168 | begin 169 | inherited Init(fBlockKind); 170 | if nBlockKind=blMain then 171 | begin 172 | AssignFile(edt,MizFileName+'.edt'); 173 | Rewrite(edt); 174 | end; 175 | inc(curLevel); 176 | end; 177 | 178 | procedure LabelBlockObj.Pop; 179 | begin 180 | dec(curLevel); 181 | if (nBlockKind=blCase) or (nBlockKind=blSuppose) then 182 | dec(arrLab[indexLab].Lev); 183 | if nBlockKind=blMain then CloseFile(edt); 184 | inherited Pop; 185 | end; 186 | 187 | procedure LabelBlockObj.ProcessLink; 188 | var i: Integer; 189 | begin 190 | if CurWord.Kind=sy_Then then 191 | begin 192 | if CurPos.Line<>PrevPos.Line then 193 | writeln(edt,'d',CurPos.Line,' ', 194 | CurPos.Col-length(CurWord.Spelling)+1,' ',AheadPos.Line, 195 | ' ',AheadPos.Col-length(AheadWord.Spelling)) else 196 | writeln(edt,'d',PrevPos.Line,' ',PrevPos.Col+1,' ',CurPos.Line,' ', 197 | CurPos.Col); 198 | iDelLink:=True; 199 | for i:=indexLab downto 1 do 200 | if curLevel>=arrLab[i].Lev then 201 | begin 202 | indexThen:=i; 203 | break; 204 | end; 205 | end; 206 | if CurWord.Kind=sy_Hence then 207 | begin 208 | writeln(edt,'d',CurPos.Line,' ', 209 | CurPos.Col-length(CurWord.Spelling)+1,' ',CurPos.Line,' ', 210 | CurPos.Col); 211 | writeln(edt,'i','thus'); 212 | iDelLink:=True; 213 | iDelLinkHence:=True; 214 | for i:=indexLab downto 1 do 215 | if curLevel>=arrLab[i].Lev then 216 | begin 217 | indexThen:=i; 218 | break; 219 | end; 220 | end; 221 | end; 222 | 223 | procedure LabelBlockObj.CreateItem; 224 | begin 225 | gItemPtr:=New(LabelItemPtr, Init(fItemKind)); 226 | end; 227 | 228 | procedure LabelBlockObj.CreateBlock; 229 | begin 230 | gBlockPtr:=New(LabelBlockPtr,Init(fBlockKind)); 231 | end; 232 | 233 | begin 234 | indexLab:=0; 235 | iDelLink:=False; 236 | iDelLinkHence:=False; 237 | curLevel:=0; 238 | DrawMizarScreen('Delinker'); 239 | if paramcount<1 then EmptyParameterList; 240 | InitExitProc; 241 | GetArticleName; 242 | GetEnvironName; 243 | GetOptions; 244 | FileExam(MizFileName+ArticleExt); 245 | OpenErrors(MizFileName); 246 | InitArticle; 247 | InitDisplayLine('Parsing'); 248 | FileExam(EnvFileName+'.dct'); 249 | InitScanning(MizFileName+ArticleExt,EnvFileName); 250 | Parse; 251 | FinishScanning; 252 | FinishDrawing; 253 | end. 254 | -------------------------------------------------------------------------------- /libtools/envget.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program EnvGet; 11 | 12 | uses pcmizver, librenv, mizenv, errhan, monitor, mconsole, 13 | envhan, inlibr 14 | {$IFDEF MDEBUG},info {$ENDIF}; 15 | 16 | var _MizExitProc:pointer; 17 | 18 | procedure PCMizExitProc; 19 | begin 20 | ExitProc:=_MizExitProc; 21 | {$I-} 22 | if IOResult<>0 then; 23 | // CloseLogFile; 24 | if IOResult<>0 then; 25 | {$I+} 26 | end; 27 | 28 | begin 29 | DrawMizarScreen('Environment Dumper'); 30 | GetArticleName; GetEnvironName; 31 | FileExam(MizFileName+ArticleExt); 32 | DrawArticleName(MizFileName+ArticleExt); 33 | InitExitProc; 34 | _MizExitProc := ExitProc; 35 | ExitProc:=@PCMizExitProc; 36 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 37 | OpenErrors(MizFileName); 38 | // OpenLogFile; 39 | // GetAccOptions; 40 | FileExam(MizFiles+MML+'.vct'); 41 | LocFilesCollection.Insert(New(PFileDescr,Init(MizFiles+MML+'.vct',0))); 42 | // DrawPass('-Parsing'); 43 | Env.ReadEnvironment; 44 | Env.StoreEvl(EnvFileName+'.evl'); 45 | CloseErrors; 46 | (* if ErrorNbr=0 then 47 | begin 48 | Accomodate; 49 | LocFilesCollection.StoreFIL(MizFileName+'.fil'); 50 | end; *) 51 | DrawErrorsMsg(ErrorNbr); 52 | FinishDrawing; 53 | end. 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /libtools/inf_prep.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | // This unit tries in each "by" inference to replace each 8 | // private reference with its own references. 9 | 10 | unit inf_prep; 11 | 12 | interface 13 | 14 | uses mobjects,justhan,correl,stdprep,prephan,prepobj,mizprep; 15 | 16 | var gCheckLinkedRefs : boolean = true; // expand linked references 17 | var gCheckNonLinkedRefs : boolean = true; // ex[and normal references 18 | 19 | type 20 | 21 | InfPBlockPtr = ^InfPBlockObj; 22 | InfPBlockObj = object(MizPBlockObj) 23 | function CreateItem(fItemKind:ItemKind):PrepItemPtr; virtual; 24 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 25 | function GetPrevious : InfPBlockPtr; 26 | end; 27 | 28 | InfPItemPtr = ^InfPItemObj; 29 | InfPItemObj = object(MizPItemObj) 30 | function GetPrevious : InfPItemPtr; 31 | function GetBlock : InfPBlockPtr; 32 | procedure Justify(fInferencePtr:pointer); virtual; 33 | end; 34 | 35 | SimpleJustInferPtr = ^SimpleJustInferObj; 36 | SimpleJustInferObj = object(ChInferObj) 37 | procedure Justify(fBlock:MizPBlockPtr); 38 | end; 39 | 40 | implementation 41 | 42 | uses mconsole,errhan,mizenv,monitor,inout,limits,lexicon, 43 | inenviro,schemhan,schemes,checker,propcoll 44 | {$IFDEF MDEBUG} ,info,outinfo {$ENDIF}; 45 | 46 | 47 | (********** Standard overloaded stuff **********) 48 | 49 | function InfPItemObj.GetPrevious : InfPItemPtr; 50 | begin GetPrevious := InfPItemPtr(Previous); end; 51 | 52 | function InfPItemObj.GetBlock : InfPBlockPtr; 53 | begin GetBlock := InfPBlockPtr(nBlock); end; 54 | 55 | function InfPBlockObj.GetPrevious : InfPBlockPtr; 56 | begin GetPrevious := InfPBlockPtr(Previous); end; 57 | 58 | function InfPBlockObj.CreateItem(fItemKind:ItemKind): PrepItemPtr; 59 | begin 60 | nCurrItm := new(InfPItemPtr, Init(fItemKind, @Self)); 61 | nCurrItm^.StartItem; 62 | CreateItem := nCurrItm; 63 | end; 64 | 65 | procedure InfPBlockObj.CreateBlock(fBlockKind:BlockKind); 66 | begin 67 | DebugBlockCreate(fBlockKind); 68 | gPrBlockPtr := new(InfPBlockPtr,Init(fBlockKind)); 69 | gPrBlockPtr^.StartBlock; 70 | end; 71 | 72 | (***********************************************) 73 | 74 | procedure InfPItemObj.Justify(fInferencePtr:pointer); 75 | begin 76 | SimpleJustInferPtr(fInferencePtr)^.Justify(GetBlock); 77 | Propositions^.GetCurrProp^.nSimpleJustif := fInferencePtr; 78 | end; 79 | 80 | 81 | // Try to replace private refs with their own refs. 82 | // Report Error 604 (resp. 605 for linked ref) for each success. 83 | procedure SimpleJustInferObj.Justify(fBlock:MizPBlockPtr); 84 | 85 | procedure CheckIt(fPos:Position; fError: integer); 86 | begin 87 | if not InferOK then exit; 88 | ChErrNr.Init(10,10); 89 | InferenceChecker( Reference, PremNbr, fBlock^.nVarNbr); 90 | if ChErrNr.Count = 0 then Error(fPos, fError); 91 | ChErrNr.Done; 92 | end; 93 | 94 | var 95 | lThesis : FrmPtr; 96 | lInf : InferencePtr; 97 | lRef : PPrivateReference; 98 | i,z,lPremNbr,llPremNbr : integer; 99 | begin 100 | DisplayLine(CurPos.Line,ErrorNbr); 101 | lThesis := NewNeg(Propositions^.GetCurrProp^.nSentence); 102 | 103 | // expanding the linked reference - only if link has simple justif. 104 | if gCheckLinkedRefs and nLinked 105 | and Assigned(Propositions^.GetPrevProp^.nSimpleJustif) then 106 | begin 107 | lInf := Propositions^.GetPrevProp^.nSimpleJustif; 108 | lPremNbr := lInf^.nReferences.Count; 109 | 110 | 111 | if lInf^.nLinked then inc(lPremNbr); 112 | 113 | if nReferences.Count + lPremNbr < MaxPremNbr then 114 | begin 115 | PremNbr := 0; InferOK := true; InsertRef(nPos,lThesis); 116 | if lInf^.nLinked then // add the link's own link 117 | InsertRef(nPos,Propositions^.GetNthPrevQuotable(2)^.nSentence); 118 | CollectRefs; // add normal refs 119 | ChInferPtr(lInf)^.CollectRefs; // add the expanded 120 | CheckIt(nPos, 605); 121 | end; 122 | end; 123 | 124 | // expanding normal (nonlinked) references 125 | if gCheckNonLinkedRefs then with nReferences do 126 | begin 127 | 128 | // added thesis, one less - is expanded, 0-based to 1-based 129 | lPremNbr := nReferences.Count; 130 | if nLinked then inc(lPremNbr); 131 | 132 | for i:= 0 to Count - 1 do 133 | if typeof(PReference(Items^[i])^) = typeof(TPrivateReference) then 134 | begin 135 | lRef := PPrivateReference(Items^[i]); 136 | lInf := Propositions^.GetLabeled(lRef^.LabNr)^.nSimpleJustif; 137 | 138 | if nInferSort=ikInfFrom then continue; // skipping schemes 139 | if not Assigned(lInf) then continue; // the ref has no simple justif 140 | 141 | llPremNbr := lPremNbr; 142 | if lInf^.nLinked then inc(llPremNbr); 143 | 144 | if llPremNbr + lInf^.nReferences.Count <= MaxPremNbr then 145 | begin 146 | PremNbr := 0; InferOK := true; InsertRef(nPos,lThesis); 147 | 148 | // insert my refs without the ommited 149 | if nLinked then 150 | InsertRef(nPos,Propositions^.GetPrevProp^.nSentence); 151 | for z:=0 to Count-1 do if (z <> i) then 152 | PReference(Items^[z])^.CollectRef1; 153 | 154 | // insert the lInf's references 155 | if lInf^.nLinked then // add the link's own link 156 | InsertRef(nPos, 157 | Propositions^.FirstQuotableBefore(lRef^.LabNr)^.nSentence); 158 | ChInferPtr(lInf)^.CollectRefs; // add the expanded 159 | CheckIt(lRef^.RefPos, 604); 160 | end; 161 | end; 162 | end; 163 | 164 | if lThesis^.FrmSort = ikFrmNeg then dispose(lThesis); 165 | 166 | end; 167 | 168 | end. 169 | -------------------------------------------------------------------------------- /libtools/itr_prep.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | // Detects irrelevant iterative steps 8 | 9 | unit itr_prep; 10 | 11 | interface 12 | 13 | uses mobjects,mconsole,justhan,correl,stdprep,mizprep,prepobj, 14 | prephan,propcoll; 15 | 16 | type 17 | 18 | IterEqPBlockPtr = ^IterEqPBlockObj; 19 | IterEqPBlockObj = object(MizPBlockObj) 20 | function CreateItem(fItemKind:ItemKind):PrepItemPtr; virtual; 21 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 22 | function GetPrevious : IterEqPBlockPtr; 23 | end; 24 | 25 | IterEqPItemPtr = ^IterEqPItemObj; 26 | IterEqPItemObj = object(MizPItemObj) 27 | function GetPrevious : IterEqPItemPtr; 28 | function GetBlock : IterEqPBlockPtr; 29 | procedure Justify(fInferencePtr:pointer); virtual; 30 | procedure FinishIterEquality; virtual; 31 | procedure FinishSimpleJustification; virtual; 32 | end; 33 | 34 | // If false, the step following an irrelevant step 35 | // is not checked. 36 | var gFullChecking: boolean = false; 37 | 38 | // This is used instead of the ClassicalChecker 39 | procedure IterEqChecker(fBlock:MizPBlockPtr); 40 | 41 | implementation 42 | 43 | uses errhan,mizenv,monitor,inout,limits,inenviro,schemhan,schemes, 44 | checker,lexicon 45 | {$IFDEF MDEBUG} ,info,outinfo {$ENDIF}; 46 | 47 | (********** Standard overloaded stuff **********) 48 | 49 | function IterEqPItemObj.GetPrevious : IterEqPItemPtr; 50 | begin GetPrevious := IterEqPItemPtr(Previous); end; 51 | 52 | function IterEqPItemObj.GetBlock : IterEqPBlockPtr; 53 | begin GetBlock := IterEqPBlockPtr(nBlock); end; 54 | 55 | function IterEqPBlockObj.GetPrevious : IterEqPBlockPtr; 56 | begin GetPrevious := IterEqPBlockPtr(Previous); end; 57 | 58 | function IterEqPBlockObj.CreateItem(fItemKind:ItemKind): PrepItemPtr; 59 | begin 60 | nCurrItm := new(IterEqPItemPtr, Init(fItemKind, @Self)); 61 | nCurrItm^.StartItem; 62 | CreateItem := nCurrItm; 63 | end; 64 | 65 | procedure IterEqPBlockObj.CreateBlock(fBlockKind:BlockKind); 66 | begin 67 | DebugBlockCreate(fBlockKind); 68 | gPrBlockPtr := new(IterEqPBlockPtr,Init(fBlockKind)); 69 | gPrBlockPtr^.StartBlock; 70 | end; 71 | 72 | (***********************************************) 73 | 74 | 75 | // Passes the info that the previous step was irrlevant 76 | var gIrrStepFound: boolean = false; 77 | 78 | // This is used instead of the ClassicalChecker 79 | procedure IterEqChecker(fBlock:MizPBlockPtr); 80 | begin 81 | InferenceChecker(Reference,PremNbr,fBlock^.nVarNbr); 82 | if ChErrNr.Count = 0 then 83 | begin 84 | Error(CurPos,746); 85 | gIrrStepFound := true; 86 | end; 87 | end; 88 | 89 | // Ignore normal simple justifs. this means that we also 90 | // do not collect the simplejustifs for such propositions 91 | procedure IterEqPItemObj.FinishSimpleJustification; begin end; 92 | 93 | procedure IterEqPItemObj.Justify(fInferencePtr:pointer); 94 | begin 95 | if gIrrStepFound then 96 | begin 97 | gIrrStepFound := false; 98 | if gFullChecking then inherited Justify(fInferencePtr); 99 | end 100 | else inherited Justify(fInferencePtr); 101 | end; 102 | 103 | // Combine references of two subsequent steps and try 104 | // to prove the equality without the middle term. 105 | procedure IterEqPItemObj.FinishIterEquality; 106 | var 107 | lLeft,lRight : TrmPtr; 108 | lFrm : FrmPtr; 109 | i,lPremNbr : integer; 110 | lProp : PrepProposPtr; 111 | lCurStep, 112 | lNextStep : IterStepPtr; 113 | begin 114 | gIrrStepFound := false; 115 | lLeft := GetBlock^.nLeftSide; 116 | 117 | with gPrep^.nLastIterSteps^ do 118 | begin 119 | for i:= 0 to Count - 2 do 120 | begin 121 | lCurStep := IterStepPtr(Items^[i]); 122 | lNextStep := IterStepPtr(Items^[i+1]); 123 | lCurStep^.nReferences.CopyItems(lNextStep^.nReferences); 124 | 125 | lCurStep^.nInferSort := ikInfBy; // to avoid RunTimeError for schemes 126 | lRight := lNextStep^.nEquatedTrm; 127 | lFrm := NewEqFrm(CopyTerm(lLeft), CopyTerm(lRight)); 128 | lProp := new(PrepProposPtr, 129 | Init( 0, lFrm, lCurStep^.nPos, propIterStep)); 130 | 131 | Propositions^.InsertUnlabeled(lProp); 132 | 133 | lPremNbr := lCurStep^.nReferences.Count + 1; 134 | if lCurStep^.nLinked then inc(lPremNbr); 135 | if lPremNbr <= MaxPremNbr then 136 | Justify(ChInferPtr(Items^[i])); 137 | 138 | lLeft := lCurStep^.nEquatedTrm; 139 | end; 140 | 141 | lLeft := GetBlock^.nLeftSide; 142 | lFrm := NewEqFrm(lLeft, CopyTerm(lRight)); 143 | lProp := new(PrepProposPtr, Init( nItemLab, lFrm, lNextStep^.nPos, 144 | propIterResult)); 145 | end; 146 | 147 | if nItemLab <> 0 then Propositions^.InsertLabeled(lProp) 148 | else Propositions^.InsertUnlabeled(lProp); 149 | 150 | gPrep^.nLastIterSteps^.DeleteAll; // justifications now kept in props 151 | GetBlock^.nLeftSide := nil; // safety 152 | end; 153 | 154 | end. 155 | -------------------------------------------------------------------------------- /libtools/labelact.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit labelact; 8 | 9 | interface 10 | 11 | uses mobjects,errhan,syntax; 12 | 13 | type 14 | ProcessNode = procedure (fNodePtr: StackedPtr); 15 | MatchNode = function (fNodePtr: StackedPtr): boolean; 16 | 17 | StackPtr = ^StackObj; 18 | StackObj = object(MObject) 19 | Top: StackedPtr; 20 | constructor Init; 21 | procedure DeleteTo(N: StackedPtr); 22 | destructor Done; virtual; 23 | procedure Clear; 24 | procedure Mark(var N: StackedPtr); 25 | procedure Push(N: StackedPtr); 26 | procedure Append(var fStack: StackObj); 27 | function Pop: StackedPtr; 28 | procedure PopAndDelete; 29 | function isEmpty: boolean; 30 | function Entries: longint; 31 | function LastThat(M: MatchNode): StackedPtr; 32 | procedure ProcessTo(N: StackedPtr; P: ProcessNode); 33 | procedure ForEach(P: ProcessNode); 34 | end; 35 | 36 | IdentPtr = ^IdentObj; 37 | IdentObj = Object(StackedObj) 38 | Ident: string; 39 | constructor Init(const fIdent: string); 40 | destructor Done; virtual; 41 | procedure ProcessReference; virtual; 42 | end; 43 | 44 | LabIdItemPtr = ^LabIdItemObj; 45 | LabIdItemObj = 46 | object(ItemObj) 47 | procedure ProcessLabel; virtual; 48 | procedure ProcessDefiniensLabel; virtual; 49 | procedure ProcessPrivateReference; virtual; 50 | 51 | procedure InsertLabel; virtual; 52 | procedure InsertDefiniensLabel; virtual; 53 | end; 54 | 55 | LabIdBlockPtr = ^LabIdBlockObj; 56 | LabIdBlockObj = 57 | object(BlockObj) 58 | nLabMark: StackedPtr; 59 | constructor Init(fBlockKind:BlockKind); 60 | procedure Pop; virtual; 61 | end; 62 | 63 | LabelPtr = ^LabelObj; 64 | LabelObj = Object(IdentObj) 65 | Kind: ItemKind; 66 | constructor Init(const fIdent:string; fKind:ItemKind); 67 | end; 68 | 69 | LabelDescrPtr = ^LabelDescrObj; 70 | LabelDescrObj = Object(LabelObj) 71 | LabPos,LabBegPos,ColonPos,PrevWordPos: Position; 72 | RefNbr: Word; 73 | constructor Init(fIdent:string; fKind:ItemKind); 74 | procedure ProcessReference; virtual; 75 | end; 76 | 77 | LabItemPtr = ^LabItemObj; 78 | LabItemObj = 79 | object(LabIdItemObj) 80 | procedure InsertLabel; virtual; 81 | procedure InsertDefiniensLabel; virtual; 82 | end; 83 | 84 | function LastLabel(const fIdent:string): IdentPtr; 85 | 86 | var gLab,gDefLab: StackObj; 87 | 88 | implementation 89 | 90 | uses mscanner 91 | {$IFDEF MDEBUG} ,info {$ENDIF}; 92 | 93 | constructor StackObj.Init; 94 | begin 95 | Top:=nil; 96 | end; 97 | 98 | procedure StackObj.DeleteTo; 99 | begin 100 | while Top <> N do PopAndDelete; 101 | end; 102 | 103 | destructor StackObj.Done; 104 | begin 105 | DeleteTo(nil); 106 | end; 107 | 108 | procedure StackObj.Clear; 109 | begin 110 | Top:=nil; 111 | end; 112 | 113 | procedure StackObj.Mark; 114 | begin 115 | N:=Top; 116 | end; 117 | 118 | procedure StackObj.Push; 119 | begin 120 | N^.Previous:=Top; 121 | Top:=N; 122 | end; 123 | 124 | procedure StackObj.Append; 125 | var L: StackedPtr; 126 | begin L:=fStack.Top; 127 | if L = nil then exit; 128 | while L^.Previous <> nil do L:=L^.Previous; 129 | L^.Previous:=Top; 130 | Top:=fStack.Top; 131 | fStack.Clear; 132 | end; 133 | 134 | function StackObj.Pop; 135 | begin Pop:=Top; 136 | if Top = nil then exit; 137 | Top:=Top^.Previous; 138 | end; 139 | 140 | procedure StackObj.PopAndDelete; 141 | var p:StackedPtr; 142 | begin if Top = nil then exit; 143 | p:=Pop; 144 | p^.Done; 145 | end; 146 | 147 | function StackObj.isEmpty; 148 | begin 149 | isEmpty:=Top=nil; 150 | end; 151 | 152 | function StackObj.Entries; 153 | var L: StackedPtr; N: longint; 154 | begin L:=Top; N:=0; 155 | while L <> nil do begin inc(N); L:=L^.Previous end; 156 | Entries:=N; 157 | end; 158 | 159 | function StackObj.LastThat; 160 | var L: StackedPtr; 161 | begin L:=Top; 162 | while L <> nil do 163 | begin 164 | if M(L) then begin LastThat:=L; exit end; 165 | L:=L^.Previous; 166 | end; 167 | LastThat:=nil; 168 | end; 169 | 170 | procedure StackObj.ProcessTo; 171 | var L: StackedPtr; 172 | begin L:=Top; 173 | while L <> N do begin P(L); L:=L^.Previous end; 174 | end; 175 | 176 | procedure StackObj.ForEach; 177 | begin 178 | ProcessTo(nil,P); 179 | end; 180 | 181 | constructor IdentObj.Init; 182 | begin Previous:=nil; 183 | Ident:=fIdent; 184 | end; 185 | 186 | destructor IdentObj.Done; 187 | begin 188 | end; 189 | 190 | procedure IdentObj.ProcessReference; 191 | begin 192 | end; 193 | 194 | procedure LabIdItemObj.InsertLabel; 195 | begin 196 | gLab.Push(new(IdentPtr,Init(CurWord.Spelling))); 197 | end; 198 | 199 | procedure LabIdItemObj.InsertDefiniensLabel; 200 | begin 201 | gDefLab.Push(new(IdentPtr,Init(CurWord.Spelling))); 202 | end; 203 | 204 | procedure LabIdItemObj.ProcessLabel; 205 | begin 206 | if (CurWord.Kind=Identifier) and (AheadWord.Kind=sy_Colon) then 207 | InsertLabel; 208 | end; 209 | 210 | procedure LabIdItemObj.ProcessDefiniensLabel; 211 | begin 212 | if (CurWord.Kind=Identifier) and (AheadWord.Kind=sy_Colon) then 213 | InsertDefiniensLabel; 214 | end; 215 | 216 | function MatchCurLabel(N: StackedPtr): boolean; 217 | var lSpelling: string; 218 | begin 219 | lSpelling:=CurWord.Spelling; 220 | MatchCurLabel:=lSpelling = IdentPtr(N)^.Ident; 221 | end; 222 | 223 | procedure LabIdItemObj.ProcessPrivateReference; 224 | var lLab: IdentPtr; 225 | begin 226 | lLab:=IdentPtr(gLab.LastThat(MatchCurLabel)); 227 | if lLab <> nil then lLab^.ProcessReference 228 | else Error(CurPos,144); 229 | end; 230 | 231 | constructor LabIdBlockObj.Init; 232 | begin 233 | inherited Init(fBlockKind); 234 | gLab.Mark(nLabMark); 235 | case fBlockKind of 236 | blDefinition: gDefLab.Init; 237 | blMain: gLab.Init; 238 | end; 239 | end; 240 | 241 | procedure LabIdBlockObj.Pop; 242 | begin 243 | gLab.DeleteTo(nLabMark); 244 | case nBlockKind of 245 | blDefinition: gLab.Append(gDefLab); 246 | blMain: gLab.Done; 247 | end; 248 | inherited Pop; 249 | end; 250 | 251 | constructor LabelObj.Init; 252 | begin Previous:=nil; 253 | Ident:=fIdent; 254 | Kind:=fKind; 255 | end; 256 | 257 | constructor LabelDescrObj.Init; 258 | begin Previous:=nil; 259 | Ident:=fIdent; 260 | Kind:=fKind; 261 | LabPos:=CurPos; 262 | LabBegPos.Line:=CurPos.Line; 263 | LabBegPos.Col:=CurPos.Col-length(CurWord.Spelling)+1; 264 | ColonPos:=AHeadPos; 265 | PrevWordPos:=PrevPos; 266 | RefNbr:=0; 267 | end; 268 | 269 | procedure LabelDescrObj.ProcessReference; 270 | begin 271 | inc(RefNbr); 272 | end; 273 | 274 | procedure LabItemObj.InsertLabel; 275 | begin 276 | gLab.Push(new(LabelDescrPtr,Init(CurWord.Spelling,nItemKind))); 277 | end; 278 | 279 | procedure LabItemObj.InsertDefiniensLabel; 280 | begin 281 | gDefLab.Push(new(LabelDescrPtr,Init(CurWord.Spelling,nItemKind))); 282 | end; 283 | 284 | var MatchedLabel: string; 285 | function MatchLabel(N: StackedPtr): boolean; 286 | begin 287 | MatchLabel:=MatchedLabel = IdentPtr(N)^.Ident; 288 | end; 289 | 290 | function LastLabel; 291 | begin MatchedLabel:=fIdent; 292 | LastLabel:=IdentPtr(gLab.LastThat(MatchLabel)); 293 | end; 294 | 295 | var AuxLabNbr,AuxLabBase:Word; 296 | procedure InitAuxiliaryLabels; 297 | var Lab: text; 298 | begin 299 | assign(Lab,'auxlabs.doc'); 300 | {$I-} reset(Lab); {$I+} 301 | AuxLabNbr:=0; 302 | if ioresult = 0 then begin readln(Lab,AuxLabNbr); close(Lab) end; 303 | AuxLabBase:=AuxLabNbr; 304 | end; 305 | 306 | procedure SaveAuxiliaryLabels; 307 | var Lab: text; 308 | begin 309 | if AuxLabBase = AuxLabNbr then exit; 310 | assign(Lab,'auxlabs.doc'); 311 | rewrite(Lab); 312 | writeln(Lab,AuxLabNbr); 313 | close(Lab); 314 | end; 315 | 316 | function GenAuxiliaryLabel: string; 317 | var Nr:string; lLab:string; 318 | begin 319 | inc(AuxLabNbr); 320 | str(AuxLabNbr,Nr); 321 | lLab:='_'+Nr+'_'; 322 | GenAuxiliaryLabel:=lLab; 323 | end; 324 | end. 325 | 326 | -------------------------------------------------------------------------------- /libtools/ref_han.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit ref_han; 8 | 9 | interface 10 | uses mobjects,envhan; 11 | 12 | type 13 | LibrRefKind = (lrWrong, 14 | lrTh, lrDef, lrSch, lrExreg, lrFuncreg, lrCondreg, 15 | lrAll); 16 | PLibrReference = ^LibrReference; 17 | LibrReference = object(MStrObj) 18 | Kind: LibrRefKInd; 19 | Nr: integer; 20 | constructor Init(fIdent:string; fDef: LibrRefKind; fNr:integer); 21 | function Repr: string; virtual; 22 | end; 23 | 24 | PLibrRefCollection = ^LibrRefCollection; 25 | LibrRefCollection = object(MSortedCollection) 26 | function Compare(Key1, Key2: Pointer): Integer; virtual; 27 | end; 28 | 29 | PReplLibrRef = ^ReplLibrRef; 30 | ReplLibrRef = object(LibrReference) 31 | Repl: LibrReference; 32 | constructor Init(fIdent1:string; fDef1: LibrRefKInd; fNr1:integer; 33 | fIdent2:string; fDef2: LibrRefKInd; fNr2:integer); 34 | end; 35 | 36 | PCommLibrRef = ^CommLibrRef; 37 | CommLibrRef = object(LibrReference) 38 | Comm: PString; 39 | constructor Init(fIdent:string; fDef: LibrRefKInd; fNr:integer; 40 | fComm:string); 41 | destructor Done; virtual; 42 | end; 43 | 44 | PCntLibrRef = ^CntLibrRef; 45 | CntLibrRef = object(LibrReference) 46 | Cnt: longint; 47 | constructor Init(fIdent:string; fDef: LibrRefKInd; fNr:integer; 48 | fCnt:longint); 49 | procedure Increment(fCnt: integer); 50 | end; 51 | 52 | function TheoremNr(var fTheo:LibrReference): string; 53 | procedure SplitLibrReference(fLine:string; 54 | var fIdent:string; var fDef:LibrRefKind; var fNr: integer); 55 | 56 | implementation 57 | 58 | uses mizenv; 59 | 60 | constructor LibrReference.Init; 61 | begin fStr:=fIdent; Kind:=fDef; Nr:=fNr end; 62 | 63 | function LibrReference.Repr; 64 | var lRepr,lNrRepr: string; 65 | begin 66 | lRepr:=fStr+':'; 67 | case Kind of 68 | lrth: {lRepr:=lRepr+'th '}; 69 | lrdef: lRepr:=lRepr+'def '; 70 | lrsch: lRepr:=lRepr+'sch '; 71 | lrexreg: lRepr:=lRepr+'exreg '; 72 | lrfuncreg: lRepr:=lRepr+'funcreg '; 73 | lrcondreg: lRepr:=lRepr+'condreg '; 74 | end; 75 | str(Nr,lNrRepr); 76 | Repr:=lRepr+lNrRepr; 77 | end; 78 | 79 | function CompNums(fN1,fN2:PLibrReference):integer; 80 | begin 81 | if fN1^.fStr = fN2^.fStr then 82 | begin 83 | if integer(fN1^.Kind) < integer(fN2^.Kind) then CompNums:=-1 84 | else if integer(fN1^.KInd) > integer(fN2^.Kind) then CompNums:=1 85 | else if fN1^.Nr < fN2^.Nr then CompNums:=-1 86 | else if fN1^.Nr > fN2^.Nr then CompNums:=1 87 | else CompNums:=0 88 | end 89 | else if fN1^.fStr < fN2^.fStr then CompNums:=-1 90 | else CompNums:=1 91 | end; 92 | 93 | function LibrRefCollection.Compare; 94 | begin 95 | Compare:= CompNums(PLibrReference(Key1),PLibrReference(Key2)); 96 | end; 97 | 98 | constructor ReplLibrRef.Init; 99 | begin fStr:=fIdent1; Kind:=fDef1; Nr:=fNr1; 100 | Repl.Init(fIdent2,fDef2,fNr2); 101 | end; 102 | 103 | constructor CommLibrRef.Init; 104 | begin fStr:=fIdent; Kind:=fDef; Nr:=fNr; 105 | Comm:=nil; 106 | if fComm <> '' then Comm:=NewStr(fComm); 107 | end; 108 | 109 | destructor CommLibrRef.Done; 110 | begin 111 | if Comm <> nil then DisposeStr(Comm); 112 | end; 113 | 114 | constructor CntLibrRef.Init; 115 | begin fStr:=fIdent; Kind:=fDef; Nr:=fNr; 116 | Cnt:=fCnt; 117 | end; 118 | 119 | procedure CntLibrRef.Increment; 120 | begin 121 | inc(Cnt,fCnt); 122 | end; 123 | 124 | function TheoremNr(var fTheo:LibrReference): string; 125 | var s: string; 126 | begin 127 | Str(fTheo.Nr, s); 128 | case fTheo.Kind of 129 | lrth: {s:='th '+s}; 130 | lrdef: s:='def '+s; 131 | lrsch: s:='sch '+s; 132 | lrexreg: s:='exreg '+s; 133 | lrfuncreg: s:='funcreg '+s; 134 | lrcondreg: s:='condreg '+s; 135 | end; 136 | TheoremNr:=s; 137 | end; 138 | 139 | procedure SplitLibrReference(fLine:string; 140 | var fIdent:string; var fDef:LibrRefKind; var fNr: integer); 141 | var l,n,c: integer; 142 | begin 143 | l:=pos(':',fLine); 144 | if l = 0 then 145 | begin 146 | fIdent:=''; fDef:=lrTh; fNr:=0; 147 | exit; 148 | end; 149 | fIdent:=TrimString(copy(fLine,1,l-1)); 150 | UpperCase(fIdent); 151 | fDef:=lrTh; inc(l); 152 | while fLine[l] = ' ' do inc(l); 153 | if fLine[l] = 'd' then 154 | begin fDef:=lrDef; inc(l,4); 155 | while fLine[l] = ' ' do inc(l); 156 | end; 157 | val(TrimString(copy(fLine,l,length(fLine))),fNr,c); 158 | end; 159 | 160 | end. 161 | -------------------------------------------------------------------------------- /libtools/refrem.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program ReferenceRemoving; 11 | 12 | uses pcmizver,mizenv,errhan,mconsole,monitor,rpremact,parser,mscanner 13 | {$IFDEF MDEBUG},info {$ENDIF}; 14 | 15 | begin 16 | DrawMizarScreen('Irrelevant References Editor'); 17 | GetArticleName; GetEnvironName; 18 | GetOptions; 19 | InitExitProc; 20 | FileExam(MizFileName+ArticleExt); 21 | DrawArticleName(MizFileName+ArticleExt); 22 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 23 | OpenErrors(MizFileName); 24 | IrrPremErrors.ReadErrors(MizFileName+'.$er'); 25 | if IrrPremErrors.Count = 0 then begin IrrPremErrors.Done; halt end; 26 | gEDT.Init(200,100); 27 | RpremactInitArticle; 28 | InitDisplayLine('Parser '); 29 | FileExam(EnvFileName+'.dct'); 30 | InitScanning(MizFileName+ArticleExt,EnvFileName); 31 | Parse; 32 | FinishScanning; 33 | if not IrrPremErrors.EofErrors then 34 | DrawMessage('Internal error','There are some unused errors'); 35 | IrrPremErrors.Done; 36 | gEDT.StoreEDT(MizFileName); 37 | gEDT.Done; 38 | FinishDrawing; 39 | DrawErrorsMSg(ErrorNbr); 40 | FinishDrawing; 41 | end. 42 | -------------------------------------------------------------------------------- /libtools/relinfer.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program RelInfer; 12 | 13 | uses verfinit,prepobj,mizprep,inf_prep; 14 | 15 | begin 16 | ReviewArticle('Irrelevant Inferences Detector',nil, 17 | new(InfPBlockPtr,Init(blMain))); 18 | end. 19 | -------------------------------------------------------------------------------- /libtools/reliters.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program CheckIteratives; 11 | 12 | uses verfinit,prepobj,mizprep,itr_prep; 13 | 14 | begin 15 | gFullChecking := true; 16 | ReviewArticle('Irrelevant Iterative Steps Detector',IterEqChecker, 17 | new(IterEqPBlockPtr,Init(blMain))); 18 | end. 19 | -------------------------------------------------------------------------------- /libtools/relpprep.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | // Detects unnecessary premises in simple justifications 8 | 9 | unit relpprep; 10 | 11 | interface 12 | 13 | uses mobjects,mconsole,justhan,correl,stdprep,mizprep,prepobj, 14 | prephan,propcoll; 15 | 16 | procedure RelevantPremises(fBlock:MizPBlockPtr); 17 | procedure FindRelPrem(fBlock:MizPBlockPtr); 18 | 19 | type 20 | 21 | RelPremPBlockPtr = ^RelPremPBlockObj; 22 | RelPremPBlockObj = object(MizPBlockObj) 23 | function CreateItem(fItemKind:ItemKind):PrepItemPtr; virtual; 24 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 25 | function GetPrevious : RelPremPBlockPtr; 26 | end; 27 | 28 | RelPremPItemPtr = ^RelPremPItemObj; 29 | RelPremPItemObj = object(MizPItemObj) 30 | function GetPrevious : RelPremPItemPtr; 31 | function GetBlock : RelPremPBlockPtr; 32 | procedure Justify(fInferencePtr:pointer); virtual; 33 | end; 34 | 35 | implementation 36 | 37 | uses errhan,mizenv,monitor,inout,limits,lexicon, 38 | inenviro,schemhan,schemes,checker 39 | {$IFDEF MDEBUG} ,info,outinfo {$ENDIF}; 40 | 41 | (********** Standard overloaded stuff **********) 42 | 43 | function RelPremPItemObj.GetPrevious : RelPremPItemPtr; 44 | begin GetPrevious := RelPremPItemPtr(Previous); end; 45 | 46 | function RelPremPItemObj.GetBlock : RelPremPBlockPtr; 47 | begin GetBlock := RelPremPBlockPtr(nBlock); end; 48 | 49 | function RelPremPBlockObj.GetPrevious : RelPremPBlockPtr; 50 | begin GetPrevious := RelPremPBlockPtr(Previous); end; 51 | 52 | function RelPremPBlockObj.CreateItem(fItemKind:ItemKind): PrepItemPtr; 53 | begin 54 | nCurrItm := new(RelPremPItemPtr, Init(fItemKind, @Self)); 55 | nCurrItm^.StartItem; 56 | CreateItem := nCurrItm; 57 | end; 58 | 59 | procedure RelPremPBlockObj.CreateBlock(fBlockKind:BlockKind); 60 | begin 61 | DebugBlockCreate(fBlockKind); 62 | gPrBlockPtr := new(RelPremPBlockPtr,Init(fBlockKind)); 63 | gPrBlockPtr^.StartBlock; 64 | end; 65 | 66 | (***********************************************) 67 | 68 | // tells whether the last inference was linked 69 | var gLinked : boolean; 70 | 71 | // The checking procedure used in relprem. 72 | // Tries to ommit each reference and find a proof without it. 73 | procedure RelevantPremises(fBlock:MizPBlockPtr); 74 | var i,r,e: integer; lReference: RefSntArr; b:byte; 75 | begin 76 | InferenceChecker(Reference,PremNbr,fBlock^.nVarNbr); 77 | if ChErrNr.Count <> 0 then 78 | with ChErrNr do 79 | for e:=0 to Count-1 do ErrImm(Items^[e].X) 80 | else 81 | // try to skip the i-th reference, the 1st is the thesis 82 | for i:=2 to PremNbr do 83 | begin 84 | for r:=1 to i-1 do lReference[r]:=Reference[r]; 85 | for r:=i+1 to PremNbr do lReference[r-1]:=Reference[r]; 86 | ChErrNr.DeleteAll; 87 | InferenceChecker(lReference,PremNbr-1,fBlock^.nVarNbr); 88 | if ChErrNr.Count = 0 then 89 | if (i = 2) and gLinked then Error(RefPos[i],603) 90 | else Error(RefPos[i],602); 91 | { with ChErrNr do 92 | for e:=0 to Count-1 do 93 | begin 94 | b:=byte(Items^[e].X); 95 | if not (b in [1,4,19]) then 96 | ErrImm(Items^[e].X); 97 | end; 98 | } 99 | end; 100 | end; 101 | 102 | // The checking procedure used in chkrprem. 103 | // A greedy version of RelevantPremises, which tries to 104 | // find a maximal set of references that are simultaneously 105 | // unnecessary. 106 | //procedure FindRelPrem(fBlock:MizPBlockPtr); 107 | //var i,r,lPremNbr: integer; lReference,wReference: RefSntArr; 108 | //begin 109 | // lReference:=Reference; wReference:=Reference; 110 | // lPremNbr:=PremNbr; 111 | // for i:=PremNbr downto 2 do 112 | // begin 113 | // Skip the i-th reference by using smaller PremNbr 114 | // and shifting the reference array above i. 115 | // If checker succeeds, decrease PremNbr again, and 116 | // continue trying skipping references smaller than i. 117 | // for r:=i+1 to lPremNbr do wReference[r-1]:=lReference[r]; 118 | // ChErrNr.DeleteAll; 119 | // InferenceChecker(wReference,lPremNbr-1,fBlock.nVarNbr); 120 | // if ChErrNr.Count = 0 then 121 | // begin 122 | // if (i=2) and gLinked then 123 | // Error(RefPos[2],603) 124 | // else Error(RefPos[i],602); 125 | // dec(lPremNbr); 126 | // lReference:=wReference; 127 | // end; 128 | // end; 129 | //end; 130 | 131 | // RM - New implementation of procedure used in chkrprem. 132 | procedure FindRelPrem(fBlock:MizPBlockPtr); 133 | var i,r,k,lPremNbr: integer; wReference: RefSntArr; 134 | bReference: array[1..MaxPremNbr] of Boolean; 135 | begin 136 | lPremNbr:=PremNbr; 137 | for i:=1 to PremNbr do bReference[i]:=true; 138 | for i:=PremNbr downto 2 do 139 | begin 140 | bReference[i]:=false; 141 | k:=1; 142 | for r:=1 to PremNbr do if bReference[r] then 143 | begin 144 | wReference[k]:=Reference[r]; 145 | inc(k); 146 | end; 147 | ChErrNr.DeleteAll; 148 | InferenceChecker(wReference,lPremNbr-1,fBlock^.nVarNbr); 149 | if ChErrNr.Count = 0 then 150 | begin 151 | if (i=2) and gLinked then 152 | Error(RefPos[2],603) 153 | else Error(RefPos[i],602); 154 | dec(lPremNbr); 155 | end 156 | else bReference[i]:=true; 157 | end; 158 | end; 159 | 160 | // ignore scheme inferences 161 | procedure RelPremPItemObj.Justify(fInferencePtr:pointer); 162 | begin 163 | if ChInferPtr(fInferencePtr)^.nInferSort = ikInfBy then 164 | begin 165 | gLinked := ChInferPtr(fInferencePtr)^.nLinked; 166 | inherited Justify(fInferencePtr); 167 | end 168 | else Propositions^.GetCurrProp^.nSimpleJustif := fInferencePtr; 169 | end; 170 | 171 | end. 172 | -------------------------------------------------------------------------------- /libtools/renthlab.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program RenThLab; 11 | 12 | uses pcmizver,mconsole,mizenv,errhan,monitor,parser,mscanner, 13 | syntax,edt_han,labelact; 14 | 15 | type 16 | ThLabItemPtr = ^ThLabItemObj; 17 | ThLabItemObj = 18 | object(LabItemObj) 19 | constructor Init(fKind:ItemKind); 20 | procedure Pop; virtual; 21 | procedure ProcessMeans; virtual; 22 | procedure ProcessEquals; virtual; 23 | procedure InsertLabel; virtual; 24 | procedure InsertDefiniensLabel; virtual; 25 | end; 26 | 27 | ThLabBlockPtr = ^ThLabBlockObj; 28 | ThLabBlockObj = 29 | object(LabIdBlockObj) 30 | constructor Init(fBlockKind:BlockKind); 31 | procedure Pop; virtual; 32 | procedure CreateItem(fItemKind:ItemKind); virtual; 33 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 34 | end; 35 | 36 | ThLabelPtr = ^ThLabelObj; 37 | ThLabelObj = Object(LabelDescrObj) 38 | LabRep: string; 39 | constructor Init(const fIdent:string; fKind:ItemKind); 40 | procedure ProcessReference; virtual; 41 | end; 42 | 43 | var 44 | gDfNbr,gThNbr,gLmNbr,gLocNbr: integer; 45 | gEDT: EdtCollection; 46 | 47 | procedure InitArticle; 48 | begin 49 | gBlockPtr:=new(ThLabBlockPtr, Init(blMain)); 50 | end; 51 | 52 | constructor ThLabItemObj.Init; 53 | begin inherited Init(fKind); 54 | case fKind of 55 | itTheorem: inc(gThNbr); 56 | itCanceled: 57 | if gBlockPtr^.nBlockKind = blMain then 58 | begin 59 | if AheadWord.Nr = 0 then inc(gThNbr) 60 | else inc(gThNbr,AheadWord.Nr) 61 | end 62 | else 63 | begin 64 | if AheadWord.Nr = 0 then inc(gDfNbr) 65 | else inc(gDfNbr,AheadWord.Nr); 66 | end; 67 | end; 68 | DisplayLine(CurPos.Line,ErrorNbr); 69 | end; 70 | 71 | procedure ThLabItemObj.Pop; 72 | begin 73 | DisplayLine(CurPos.Line,ErrorNbr); 74 | inherited Pop; 75 | end; 76 | 77 | procedure ThLabItemObj.ProcessMeans; 78 | begin 79 | inc(gDfNbr); 80 | end; 81 | 82 | procedure ThLabItemObj.ProcessEquals; 83 | begin 84 | inc(gDfNbr); 85 | end; 86 | 87 | procedure ThLabItemObj.InsertLabel; 88 | begin 89 | gLab.Push(new(ThLabelPtr,Init(CurWord.Spelling,nItemKind))); 90 | end; 91 | 92 | procedure ThLabItemObj.InsertDefiniensLabel; 93 | begin 94 | gDefLab.Push(new(ThLabelPtr,Init(CurWord.Spelling,nItemKind))); 95 | end; 96 | 97 | constructor ThLabBlockObj.Init; 98 | begin 99 | DisplayLine(CurPos.Line,ErrorNbr); 100 | inherited Init(fBlockKind); 101 | case fBlockKind of 102 | blMain: 103 | begin 104 | gEDT.Init(200,100); 105 | gThNbr:=0; gLmNbr:=0; gDfNbr:=0; gLocNbr:=0; 106 | end; 107 | else if BlockPtr(Previous)^.nBlockKind = blMain then gLocNbr:=0; 108 | end; 109 | end; 110 | 111 | procedure ThLabBlockObj.CreateItem; 112 | begin gItemPtr:=new(ThLabItemPtr, Init(fItemKind)) end; 113 | 114 | procedure ThLabBlockObj.CreateBlock; 115 | begin gBlockPtr:=new(ThLabBlockPtr,Init(fBlockKind)) end; 116 | 117 | procedure ThLabBlockObj.Pop; 118 | begin 119 | DisplayLine(CurPos.Line,ErrorNbr); 120 | case nBlockKind of 121 | blMain: 122 | begin 123 | if gEdt.Count > 0 then gEDT.StoreEdt(MizFileName); 124 | end; 125 | end; 126 | inherited Pop; 127 | end; 128 | 129 | constructor ThLabelObj.Init; 130 | var lPos: Position; 131 | begin inherited Init(fIdent,fKind); 132 | LabRep:=''; 133 | lPos.Line:=CurPos.Line; 134 | lPos.Col:=CurPos.Col-length(CurWord.Spelling)+1; 135 | case fKind of 136 | itDefPred, itDefFunc, itDefMode, itDefAttr: 137 | begin 138 | Str(gDfNbr,LabRep); 139 | LabRep:='Def'+LabRep; 140 | gEDT.Insert_d(lPos,CurPos); 141 | gEDT.Insert_i(LabRep); 142 | end; 143 | itTheorem: 144 | begin 145 | Str(gThNbr,LabRep); 146 | LabRep:='Th'+LabRep; 147 | gEDT.Insert_d(lPos,CurPos); 148 | gEDT.Insert_i(LabRep); 149 | end; 150 | itRegularStatement, itChoice: 151 | if BlockPtr(gBlockPtr)^.nBlockKind = blMain then 152 | begin 153 | inc(gLmNbr); 154 | Str(gLmNbr,LabRep); 155 | LabRep:='Lm'+LabRep; 156 | gEDT.Insert_d(lPos,CurPos); 157 | gEDT.Insert_i(LabRep); 158 | end 159 | else 160 | begin inc(gLocNbr); 161 | Str(gLocNbr,LabRep); 162 | LabRep:='A'+LabRep; 163 | gEDT.Insert_d(lPos,CurPos); 164 | gEDT.Insert_i(LabRep); 165 | end; 166 | itDefinition, itSchemeBlock, itSchemeHead, 167 | itGeneralization, itLociDeclaration,itExistentialAssumption, 168 | itConclusion, itCaseHead, itSupposeHead, itAssumption: 169 | begin inc(gLocNbr); 170 | Str(gLocNbr,LabRep); 171 | LabRep:='A'+LabRep; 172 | gEDT.Insert_d(lPos,CurPos); 173 | gEDT.Insert_i(LabRep); 174 | end; 175 | end; 176 | end; 177 | 178 | procedure ThLabelObj.ProcessReference; 179 | var lPos:Position; 180 | begin inherited ProcessReference; 181 | if LabRep <> '' then 182 | begin 183 | lPos.Line:=CurPos.Line; 184 | lPos.Col:=CurPos.Col-length(CurWord.Spelling)+1; 185 | gEDT.Insert_d(lPos,CurPos); 186 | gEDT.Insert_i(LabRep); 187 | end; 188 | end; 189 | 190 | begin 191 | DrawMizarScreen('Theorems Label Editor'); 192 | InitExitProc; 193 | GetArticleName; GetEnvironName; 194 | GetOptions; 195 | FileExam(MizFileName+ArticleExt); 196 | OpenErrors(MizFileName); 197 | InitDisplayLine('Parsing'); 198 | InitArticle; 199 | FileExam(EnvFileName+'.dct'); 200 | InitScanning(MizFileName+ArticleExt,EnvFileName); 201 | Parse; 202 | FinishScanning; 203 | DisplayLine(CurPos.Line,ErrorNbr); 204 | DrawErrorsMSg(ErrorNbr); 205 | FinishDrawing; 206 | end. 207 | -------------------------------------------------------------------------------- /libtools/trivdemo.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program TrivDemo; 12 | 13 | uses pcmizver,mconsole,mobjects,mizenv,monitor,errhan,parser,mscanner,scanner, 14 | parseraddition,_formats,wsmarticle,first_identification, 15 | trans2analyzer,analyzer,prephan,prepobj,td_prep,checker 16 | {$IFDEF TRIVDEMO} 17 | ,edt_han 18 | {$ENDIF} 19 | {$IFDEF MDEBUG} ,info {$ENDIF}; 20 | 21 | {$IFDEF TRIVDEMO} 22 | var i : integer; 23 | {$ENDIF} 24 | 25 | begin 26 | DrawMizarScreen('Trivial Proofs Detector'); 27 | if paramcount<1 then EmptyParameterList; 28 | GetArticleName; GetEnvironName; 29 | GetOptions; 30 | InitExitProc; 31 | FileExam(MizFileName+ArticleExt); 32 | DrawArticleName(MizFileName+ArticleExt); 33 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 34 | OpenErrors(MizFileName); 35 | 36 | {$IFDEF TRIVDEMO} 37 | gLabsPos:=0; 38 | {$ENDIF} 39 | 40 | InitDisplayLine('Parser '); 41 | FileExam(EnvFileName+'.dct'); 42 | InitScanning(MizFileName+ArticleExt,EnvFileName); 43 | InitWSMizarArticle; 44 | Parse; 45 | gFormatsColl.StoreFormats(EnvFileName+'.frx'); 46 | FinishScanning; 47 | Write_WSMizArticle(gWSTextProper,EnvFileName+'.wsx'); 48 | InitDisplayLine('MSM '); 49 | MSMAnalyzer; 50 | Transfer2Analyzer; 51 | 52 | InitDisplayLine('Analyser'); 53 | Analyze; 54 | DisposeAnalyze; 55 | DisplayLine(CurPos.Line,ErrorNbr); 56 | CurPos.Line:=1; 57 | 58 | {$IFDEF TRIVDEMO} 59 | Assign(gEdt, MizFileName+'.edt'); 60 | Rewrite(gEdt); 61 | {$ENDIF} 62 | 63 | InitDisplayLine('Proofs '); 64 | gPrBlockPtr:=new(TDemoPBlockPtr,Init(blMain)); 65 | TDemoPBlockPtr(gPrBlockPtr)^.InitPrepData; 66 | Prepare; 67 | DisplayLine(CurPos.Line,ErrorNbr); 68 | DrawErrorsMSg(ErrorNbr); 69 | FinishDrawing; 70 | 71 | {$IFDEF TRIVDEMO} 72 | for i:=0 to gStartPos.Count-1 do 73 | begin 74 | writeln(gEdt,'d',StrPos(PPosition(gStartPos.Items^[i])^.Pos),' ',StrPos(PPosition(gEndPos.Items^[i])^.Pos)); 75 | if (MStrPtr(gI.Items^[i])^.fStr <> '') then 76 | writeln(gEdt,'iby ',MStrPtr(gI.Items^[i])^.fStr); 77 | end; 78 | 79 | Close(gEdt); 80 | {$ENDIF} 81 | 82 | end. 83 | -------------------------------------------------------------------------------- /libtools/unhereby.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program Hereby2ThusNow; 12 | 13 | uses pcmizver,mizenv,errhan,monitor,mscanner,mconsole 14 | {$IFDEF MDEBUG} ,info {$ENDIF}; 15 | 16 | var edt: Text; 17 | 18 | Procedure ProcessText; 19 | Begin 20 | Assign(edt, MizFileName+'.edt'); 21 | Rewrite(edt); 22 | ReadToken; 23 | while CurWord.Kind <> EOT do 24 | begin 25 | if CurWord.Kind = sy_Hereby then 26 | begin 27 | Error(CurPos,705); 28 | WriteLn(edt, 'd', CurPos.Line, ' ', CurPos.Col-5, ' ', CurPos.Line, ' ', CurPos.Col); 29 | WriteLn(edt, 'ithus now'); 30 | end; 31 | ReadToken; 32 | end; 33 | Close(edt); 34 | End; 35 | 36 | BEGIN 37 | writeln('hereby -> thus now, ',PCMizarVersionStr); 38 | writeln(Copyright); 39 | InitExitProc; 40 | GetArticleName; GetEnvironName; 41 | GetOptions; 42 | FileExam(MizFileName+ArticleExt); 43 | OpenErrors(MizFileName); 44 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 45 | Write('Parsing'); 46 | FileExam(EnvFileName+'.dct'); 47 | InitScanning(MizFileName+ArticleExt,EnvFileName); 48 | ProcessText; 49 | FinishScanning; 50 | FinishDrawing; 51 | END. 52 | -------------------------------------------------------------------------------- /usrtools/absedt.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program AbsEdt; 12 | 13 | uses pcmizver,mizenv,mconsole,errhan,monitor,absact,parser,mscanner 14 | {$IFDEF MDEBUG} ,info {$ENDIF}; 15 | 16 | begin 17 | DrawMizarScreen('Editing Abstract'); 18 | InitExitProc; 19 | GetArticleName; GetEnvironName; 20 | GetOptions; 21 | FileExam(MizFileName+ArticleExt); 22 | OpenErrors(MizFileName); 23 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 24 | InitArticle; 25 | InitDisplayLine('Parsing '+MizFileName); 26 | FileExam(EnvFileName+'.dct'); 27 | FileExam(EnvFileName+'.prf'); 28 | InitScanning(MizFileName+ArticleExt,EnvFileName); 29 | Parse; 30 | FinishScanning; 31 | DrawErrorsMsg(ErrorNbr); 32 | FinishDrawing; 33 | end. 34 | -------------------------------------------------------------------------------- /usrtools/chklab.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program ChkLab; 11 | 12 | uses pcmizver,mizenv,errhan,monitor,irlabact,parser,mscanner,mconsole 13 | {$IFDEF MDEBUG} ,info {$ENDIF}; 14 | 15 | begin 16 | DrawMizarScreen('Irrelevant Label Detector'); 17 | InitExitProc; 18 | GetArticleName; GetEnvironName; 19 | GetOptions; 20 | FileExam(MizFileName+ArticleExt); 21 | OpenErrors(MizFileName); 22 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 23 | InitArticle; 24 | InitDisplayLine('Parsing'); 25 | FileExam(EnvFileName+'.dct'); 26 | InitScanning(MizFileName+ArticleExt,EnvFileName); 27 | Parse; 28 | FinishScanning; 29 | dec(ErrorNbr,IrrLabNbr); 30 | if IrrLabNbr=1 then writeln('**** One Irrelevant Label Found ****') 31 | else if IrrLabNbr>1 then writeln('**** ',IrrLabNbr,' Irrelevant Labels Found ****'); 32 | DrawErrorsMsg(ErrorNbr); 33 | FinishDrawing; 34 | end. 35 | -------------------------------------------------------------------------------- /usrtools/findvoc.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program FindVocabulary; 11 | 12 | uses mobjects,pcmizver,mizenv,librenv,monitor,dicthan,mconsole; 13 | 14 | var gPattern: string; 15 | gSymbolKind: set of 'A'..'Z'; 16 | gUpperCase,gWholeWord,gSpecSymbols: boolean; 17 | gVocsColl: MStringList; 18 | 19 | procedure PrintSymbolsInVoc(fName:string); 20 | var lFirstToken: boolean; 21 | procedure PrintToken(P: PSymbol); 22 | var lRepr: string; 23 | begin 24 | with P^ do 25 | begin 26 | if not (Kind in gSymbolKind) then exit; 27 | lRepr:=Repr; 28 | if gUpperCase then lRepr:=UpperCase(lRepr); 29 | if gWholeWord then 30 | begin if lRepr <> gPattern then exit end 31 | else if Pos(gPattern,lRepr) = 0 then exit; 32 | if lFirstToken then 33 | begin lFirstToken:=false; 34 | writeln('vocabulary: ',fName); 35 | end; 36 | write(Kind,Repr,' '); 37 | if (Kind='O') and (Prior<>StandardPriority) then write(' ',Prior); 38 | writeln; 39 | end; 40 | end; 41 | var lVoc:PVocabulary; 42 | z: integer; 43 | begin 44 | fName:=UpperCase(fName); 45 | lFirstToken:=true; 46 | lVoc:=PVocabulary(gVocsColl.ObjectOf(fName)); 47 | if lVoc <> nil then 48 | begin 49 | with lVoc^.Reprs do for z:=0 to Count-1 do PrintToken(PSymbol(At(z))); 50 | if not lFirstToken then writeln; 51 | end; 52 | end; 53 | 54 | procedure PrintAllVocs; 55 | var i:integer; 56 | begin 57 | for i:=0 to gVocsColl.fCount-1 do 58 | PrintSymbolsInVoc(gVocsColl.GetString(i)); 59 | end; 60 | 61 | procedure BadParameters; 62 | begin 63 | if ParamCount > 0 then Exit; 64 | Noise; 65 | DrawMizarScreen('Find Vocabulary'); 66 | writeln('Syntax: findvoc [-iswGKLMORUV] searchstring'); 67 | writeln; 68 | writeln('Options are one or more option characters preceeded by "-"'); 69 | writeln(' -i Ignore case'); 70 | writeln(' -w Word search'); 71 | writeln(' -s Ignore special symbols'); 72 | writeln(' -G structure symbol'); 73 | writeln(' -K left bracket symbol'); 74 | writeln(' -L right bracket symbol'); 75 | writeln(' -M mode symbol'); 76 | writeln(' -O functor symbol'); 77 | writeln(' -R predicate symbol'); 78 | writeln(' -U selector symbol'); 79 | writeln(' -V attribute symbol'); 80 | writeln('The following symbols are treated specially:'); 81 | { writeln(' ^ start of symbol'); 82 | writeln(' $ end of symbol');} 83 | writeln(' \b |'); 84 | writeln(' \l <'); 85 | writeln(' \g >'); 86 | writeln(' \ quote next character:'); 87 | writeln; 88 | halt(2); 89 | end; 90 | 91 | procedure InitParams; 92 | var lNr,i:byte; c: char; lPattern: string; 93 | begin 94 | BadParameters; 95 | gUpperCase:=false; 96 | gWholeWord:=false; 97 | gSpecSymbols:=true; 98 | lPattern:=ParamStr(1); 99 | gSymbolKind:=[]; 100 | lNr:=2; 101 | if lPattern[1]='-' then 102 | begin 103 | if pos('i',lPattern) <> 0 then gUpperCase:=true; 104 | if pos('w',lPattern) <> 0 then gWholeWord:=true; 105 | if pos('s',lPattern) <> 0 then gSpecSymbols:=false; 106 | for c:='A' to 'Z' do 107 | if c in AvailableSymbols then 108 | if pos(c,lPattern) <> 0 109 | then gSymbolKind:=gSymbolKind+[c]; 110 | if ParamCount < 2 then BadParameters; 111 | lPattern:=ParamStr(2); 112 | lNr:=3; 113 | end; 114 | if gSymbolKind=[] then gSymbolKind:=AvailableSymbols; 115 | if not gSpecSymbols then gPattern:=lPattern 116 | else 117 | begin i:=1; gPattern:=''; 118 | while i<=length(lPattern) do 119 | begin 120 | if lPattern[i] = '\' then 121 | begin inc(i); 122 | if i<=length(lPattern) then 123 | begin 124 | case lPattern[i] of 125 | 'b': gPattern:=gPattern+'|'; 126 | 'g': gPattern:=gPattern+'>'; 127 | 'l': gPattern:=gPattern+'<'; 128 | else gPattern:=gPattern+lPattern[i]; 129 | end; 130 | end; 131 | end 132 | else gPattern:=gPattern+lPattern[i]; 133 | inc(i); 134 | end; 135 | end; 136 | if gUpperCase then gPattern:=UpperCase(gPattern); 137 | if ParamCount >= lNr then GetFileName(lNr,'.vct',MizFileName) 138 | else MizFileName:=MizFiles+MML+'.vct'; 139 | end; 140 | 141 | begin 142 | InitParams; 143 | DrawMizarScreen('FindVoc'); 144 | InitExitProc; 145 | LoadMmlVcb(MizFileName,gVocsColl); 146 | PrintAllVocs; 147 | gVocsColl.Done; 148 | FinishDrawing; 149 | end. 150 | -------------------------------------------------------------------------------- /usrtools/inacc.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program InAccItems; 11 | 12 | uses pcmizver,mizenv,monitor,parser,errhan,inaccact,mscanner,mconsole 13 | {$IFDEF MDEBUG} ,info {$ENDIF}; 14 | 15 | begin 16 | DrawMizarScreen('Inaccessible Items Detector'); 17 | InitExitProc; 18 | GetArticleName; GetEnvironName; 19 | GetOptions; 20 | FileExam(MizFileName+ArticleExt); 21 | OpenErrors(MizFileName); 22 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 23 | InitDisplayLine('Parsing'); 24 | InitArticle; 25 | FileExam(EnvFileName+'.dct'); 26 | InitScanning(MizFileName+ArticleExt,EnvFileName); 27 | Parse; 28 | FinishScanning; 29 | writeln; 30 | dec(ErrorNbr,InAccItemsNbr*2+InaccLinkNbr); 31 | if InaccItemsNbr=1 then writeln('**** One Inaccessible Item Found ****') 32 | else if InaccItemsNbr>1 then writeln('**** ',InaccItemsNbr,' Inaccessible Items Found ****'); 33 | if InaccLinkNbr=1 then writeln('**** One Inaccessible Linkage Found ****') 34 | else if InaccLinkNbr>1 then writeln('**** ',InaccLinkNbr,' Inaccessible Linkages Found ****'); 35 | DrawErrorsMsg(ErrorNbr); 36 | FinishDrawing; 37 | end. 38 | -------------------------------------------------------------------------------- /usrtools/irlabact.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | unit irlabact; 8 | 9 | interface 10 | 11 | procedure InitArticle; 12 | 13 | var IrrLabNbr: integer; 14 | 15 | implementation 16 | 17 | uses mconsole,mobjects,limits,errhan,mizenv,monitor,mscanner,syntax,edt_han 18 | {$IFDEF MDEBUG} ,info {$ENDIF}; 19 | 20 | type 21 | 22 | IrrLabItemPtr = ^IrrLabItemObj; 23 | IrrLabItemObj = 24 | object(ItemObj) 25 | constructor Init(fKind:ItemKind); 26 | procedure Pop; virtual; 27 | procedure ProcessLabel; virtual; 28 | procedure ProcessDefiniensLabel; virtual; 29 | procedure ProcessPrivateReference; virtual; 30 | end; 31 | 32 | IrrLabBlockPtr = ^IrrLabBlockObj; 33 | IrrLabBlockObj = 34 | object(BlockObj) 35 | nLabNbr:integer; 36 | constructor Init(fBlockKind:BlockKind); 37 | procedure Pop; virtual; 38 | procedure CreateItem(fItemKind:ItemKind); virtual; 39 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 40 | end; 41 | 42 | LabelDescr = 43 | record rName:string; 44 | LabPos,BegPos,EndPos: Position; 45 | RefNbr: Word; 46 | end; 47 | 48 | var 49 | gLabNbr,gDefLabNbr: integer; 50 | Lab: array[1..MaxLabNbr] of LabelDescr; 51 | DefLab: array[1..MaxLabNbr] of LabelDescr; 52 | gEDT: EdtCollection; 53 | 54 | procedure InitArticle; 55 | begin 56 | gBlockPtr:=new(IrrLabBlockPtr, Init(blMain)); 57 | end; 58 | 59 | constructor IrrLabItemObj.Init; 60 | begin 61 | DisplayLine(CurPos.Line,ErrorNbr); 62 | inherited Init(fKind); 63 | end; 64 | 65 | procedure IrrLabItemObj.Pop; 66 | begin 67 | DisplayLine(CurPos.Line,ErrorNbr); 68 | inherited Pop; 69 | end; 70 | 71 | constructor IrrLabBlockObj.Init; 72 | begin 73 | DisplayLine(CurPos.Line,ErrorNbr); 74 | inherited Init(fBlockKind); 75 | nLabNbr:=gLabNbr; 76 | case fBlockKind of 77 | blDefinition: gDefLabNbr:=0; 78 | blMain: 79 | begin 80 | IrrLabNbr:=0; gLabNbr:=0; 81 | gEDT.Init(200,100); 82 | end; 83 | end; 84 | end; 85 | 86 | procedure IrrLabBlockObj.Pop; 87 | var i: integer; 88 | begin 89 | for i:=nLabNbr+1 to gLabNbr do with Lab[i] do 90 | if RefNbr=0 then 91 | begin Error(LabPos,601); inc(IrrLabNbr); 92 | gEDT.Insert_d(BegPos,EndPos); 93 | end; 94 | DisplayLine(CurPos.Line,ErrorNbr); 95 | gLabNbr:=nLabNbr; 96 | case nBlockKind of 97 | blDefinition: 98 | for i:=1 to gDefLabNbr do 99 | begin IncIndex(gLabNbr,LabIndex); Lab[gLabNbr]:=DefLab[i] end; 100 | blDiffuse,blProof,blCase,blSuppose:; 101 | blMain: 102 | begin 103 | if IrrLabNbr > 0 then gEDT.StoreEDT(MizFileName); 104 | gEDT.Done 105 | end; 106 | end; 107 | inherited Pop; 108 | end; 109 | 110 | procedure IrrLabBlockObj.CreateItem; 111 | begin gItemPtr:=new(IrrLabItemPtr, Init(fItemKind)) end; 112 | 113 | procedure IrrLabBlockObj.CreateBlock; 114 | begin gBlockPtr:=new(IrrLabBlockPtr,Init(fBlockKind)) end; 115 | 116 | procedure IrrLabItemObj.ProcessLabel; 117 | begin 118 | if (CurWord.Kind=Identifier) and (AheadWord.Kind=sy_Colon) then 119 | begin IncIndex(gLabNbr,LabIndex); 120 | with Lab[gLabNbr] do 121 | begin rName:=CurWord.Spelling; LabPos:=CurPos; RefNbr:=0; 122 | BegPos.Line:=CurPos.Line; 123 | BegPos.Col:=CurPos.Col-length(rName)+1; 124 | EndPos:=AheadPos; 125 | end; 126 | end; 127 | end; 128 | 129 | procedure IrrLabItemObj.ProcessDefiniensLabel; 130 | begin 131 | if (CurWord.Kind=Identifier) and (AheadWord.Kind=sy_Colon) then 132 | begin IncIndex(gDefLabNbr,LabIndex); 133 | with DefLab[gDefLabNbr] do 134 | begin rName:=CurWord.Spelling; LabPos:=CurPos; RefNbr:=0; 135 | BegPos:=PrevPos; EndPos:=AHeadPos; 136 | end; 137 | end; 138 | end; 139 | 140 | procedure IrrLabItemObj.ProcessPrivateReference; 141 | var k:integer; lSpelling:String; 142 | begin lSpelling:=CurWord.Spelling; 143 | for k:=gLabNbr downto 1 do 144 | if Lab[k].rName = lSpelling then 145 | begin 146 | inc(Lab[k].RefNbr); 147 | exit; 148 | end; 149 | Error(CurPos,144); 150 | end; 151 | 152 | end. 153 | -------------------------------------------------------------------------------- /usrtools/irrths.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program IrrTheoremsAndSchemes; 12 | 13 | uses mobjects,pcmizver,mconsole,mizenv,monitor,errhan,envhan,mscanner,scanner 14 | {$IFDEF MDEBUG} ,info {$ENDIF}; 15 | 16 | var 17 | ImpTheorems,ImpSchemes: NatSet; 18 | SchemeIdents: MSortedStrList; 19 | IrrSch,IrrThe: integer; 20 | 21 | procedure InitArticle; 22 | var lEdeEvl:boolean; 23 | begin 24 | lEdeEvl:=false; 25 | if paramcount = 2 then 26 | begin 27 | if ParamStr(2) = '-a' then 28 | lEdeEvl:=true 29 | end 30 | else if paramcount > 2 then 31 | if ParamStr(3) = '-a' then 32 | lEdeEvl:=true; 33 | if lEdeEvl then 34 | Env.LoadEvl(EnvFileName+'.$ev') 35 | else 36 | Env.LoadEvl(EnvFileName+'.evl'); 37 | SchemeIdents.Init(30); 38 | {InitInFileBuff;} 39 | ImpTheorems.Init(Env.Directive[syTheorems].Count,10); 40 | ImpTheorems.Duplicates:=false; 41 | ImpSchemes.Init(Env.Directive[sySchemes].Count,10); 42 | ImpSchemes.Duplicates:=false; 43 | end; 44 | 45 | procedure ProcessText; 46 | begin 47 | InitScanning(MizFileName+ArticleExt,EnvFileName); 48 | ReadToken; 49 | while (CurWord.Kind <> sy_Begin) and (CurWord.Kind <> EOT) 50 | do ReadToken; 51 | while CurWord.Kind <> EOT{'!'} do 52 | begin 53 | if CurPos.Line mod 4 = 0 54 | then DisplayLine(CurPos.Line,ErrorNbr); 55 | case CurWord.Kind of 56 | MMLIdentifier {'A'}: 57 | begin 58 | DisplayLine(CurPos.Line,ErrorNbr); 59 | ImpTheorems.InsertElem(CurWord.Nr); 60 | end; 61 | sy_From: 62 | begin 63 | ReadToken; 64 | if CurWord.Kind <> Identifier {'I'} then 65 | begin 66 | DisplayLine(CurPos.Line,ErrorNbr); 67 | ImpSchemes.InsertElem(CurWord.Nr); 68 | end; 69 | end; 70 | end; 71 | ReadToken; 72 | end; 73 | FinishScanning; 74 | end; 75 | 76 | procedure FinishArticle; 77 | var i: integer; 78 | lTokens: TokensCollection; 79 | lToken: TokenPtr; 80 | begin 81 | IrrThe:=0; 82 | IrrSch:=0; 83 | lTokens.LoadDct(EnvFileName); 84 | for i:=0 to Env.Directive[syTheorems].Count-1 do 85 | with PImpArticleId(Env.Directive[syTheorems].Items^[i])^ do 86 | begin 87 | lToken:=TokenPtr(lTokens.ObjectOf(fStr)); 88 | assert(lToken<>nil,'2382'); 89 | if not ImpTheorems.HasInDom(lToken^.fLexem.Nr) then 90 | begin 91 | Error(PImpArticleId(Env.Directive[syTheorems].Items^[i])^.fPos,706); 92 | inc(IrrThe); 93 | Env.Directive[syTheorems].Items^[i]:=nil; 94 | end; 95 | end; 96 | for i:=0 to Env.Directive[sySchemes].Count-1 do 97 | with PImpArticleId(Env.Directive[sySchemes].Items^[i])^ do 98 | begin lToken:=TokenPtr(lTokens.ObjectOf(fStr)); 99 | assert(lToken<>nil,'2382'); 100 | if not ImpSchemes.HasInDom(lToken^.fLexem.Nr) then 101 | begin 102 | Error(PImpArticleId(Env.Directive[sySchemes].Items^[i])^.fPos,707); 103 | inc(IrrSch); 104 | Env.Directive[sySchemes].Items^[i]:=nil; 105 | end; 106 | end; 107 | if (IrrThe > 0) or (IrrSch > 0) then 108 | Env.StoreEvl(EnvFileName+'.$ev'); 109 | end; 110 | 111 | begin 112 | DrawMizarScreen('Irrelevant ''theorems'' & ''schemes'' Detector'); 113 | GetArticleName; GetEnvironName; 114 | GetOptions; 115 | InitExitProc; 116 | FileExam(MizFileName+ArticleExt); 117 | OpenErrors(MizFileName); 118 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 119 | InitArticle; 120 | InitDisplayLine('Scanning'); 121 | ProcessText; 122 | FinishArticle; 123 | writeln; 124 | if IrrThe = 1 then 125 | writeln('**** One irrelevant ''theorems'' directive detected.') 126 | else if IrrThe > 1 then 127 | writeln('**** ',IrrThe,' irrelevant ''theorems'' directives detected.'); 128 | if IrrSch = 1 then 129 | writeln('**** One irrelevant ''schemes'' directive detected.') 130 | else if IrrSch > 1 then 131 | writeln('**** ',IrrSch,' irrelevant ''schemes'' directives detected.'); 132 | FinishDrawing; 133 | end. 134 | -------------------------------------------------------------------------------- /usrtools/irrvoc.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program IrrVoc; 11 | 12 | uses mobjects,pcmizver,mconsole,errhan,mizenv,monitor, 13 | mscanner,scanner,dicthan,accdict,envhan,xml_dict,xml_inout,xml_parser 14 | {$IFDEF MDEBUG},info{$ENDIF}; 15 | 16 | type 17 | PLexem = ^ProfLexem; 18 | ProfLexem = object(MObject) 19 | fSymb: LexemRec; 20 | fCnt: integer; 21 | constructor Init(aKind:char; aNr,aCnt:integer); 22 | end; 23 | 24 | TLexemCollection = object(MSortedCollection) 25 | function Compare(Key1, Key2: Pointer): Integer; virtual; 26 | end; 27 | 28 | PIrrVocabulary = ^TIrrVocabulary; 29 | TIrrVocabulary = object(MObject) 30 | nName: NameStr; Base: SymbolCounters; 31 | Lexems: TLexemCollection; 32 | constructor Init(const fName:string; var fBase:SymbolCounters); 33 | procedure AddLexem(const aLexem:ProfLexem); 34 | end; 35 | 36 | constructor ProfLexem.Init; 37 | begin 38 | fSymb.Kind:=aKind; fSymb.Nr:=aNr; fCnt:=aCnt; 39 | end; 40 | 41 | constructor TIrrVocabulary.Init; 42 | begin 43 | nName:=fName; Base:=fBase; 44 | Lexems.Init(4,1); 45 | end; 46 | 47 | procedure TIrrVocabulary.AddLexem; 48 | var i:integer; lLexem: ProfLexem; 49 | begin lLexem.Init(aLexem.fSymb.Kind,aLexem.fSymb.Nr,0); 50 | if Lexems.Search(addr(lLexem),i) then 51 | inc(PLexem(Lexems.Items^[i])^.fCnt) 52 | else Lexems.Insert(new(PLexem,Init(aLexem.fSymb.Kind,aLexem.fSymb.Nr,1))); 53 | end; 54 | 55 | function TLexemCollection.Compare; 56 | begin 57 | if PLexem(Key1)^.fSymb.Kind < PLexem(Key2)^.fSymb.Kind then Compare:=-1 58 | else if PLexem(Key1)^.fSymb.Kind > PLexem(Key2)^.fSymb.Kind then Compare:=1 59 | else if PLexem(Key1)^.fSymb.Nr < PLexem(Key2)^.fSymb.Nr then Compare:=-1 60 | else if PLexem(Key1)^.fSymb.Nr > PLexem(Key2)^.fSymb.Nr then Compare:=1 61 | else Compare:=0 62 | end; 63 | 64 | var VocCollection: MCollection; 65 | 66 | procedure ReadVCL; 67 | var i,lLexNr: integer; c,lLexKind:char; 68 | lTokBase: SymbolCounters; 69 | lVocs: MStringList; 70 | lName: string; 71 | lInFile: XMLInStreamPtr; 72 | lDictBase: AbsVocabularyPtr; 73 | begin 74 | lVocs.Init(8); 75 | FillChar( lTokBase, sizeof(lTokBase), 0); 76 | FileExam(MizFileName+'.vcl'); 77 | lInFile:=new(XMLInStreamPtr,OpenFile(MizFileName+'.vcl')); 78 | lInFile^.NextElementState; 79 | lInFile^.NextElementState; 80 | while not (lInFile^.nState = eEnd) and (lInFile^.nElName = XMLElemName[elVocabulary]) do 81 | begin 82 | lInFile^.NextElementState; 83 | lName:= lInFile^.GetAttr( XMLAttrName[atName]); 84 | lInFile^.AcceptEndState; lInFile^.NextElementState; // end of elArticleID 85 | lDictBase:=new(AbsVocabularyPtr,Init); 86 | lDictBase^.fSymbolCnt:=lTokBase; 87 | while not (lInFile^.nState = eEnd) and (lInFile^.nElName = XMLElemName[elSymbolCount]) do 88 | begin 89 | lLexKind:=lInFile^.GetAttr(XMLAttrName[atKind])[1]; 90 | lLexNr:=lInFile^.GetIntAttr(XMLAttrName[atNr]); 91 | inc(lDictBase^.fSymbolCnt[ lLexKind], lLexNr); 92 | lInFile^.AcceptEndState; lInFile^.NextElementState; 93 | end; 94 | lVocs.AddObject( lName, lDictBase); 95 | lInFile^.NextElementState; 96 | end; 97 | lInFile^.NextElementState; 98 | dispose(lInFile,Done); 99 | VocCollection.Init(10,1); 100 | // fillchar(lTokBase,sizeof(lTokBase),0); 101 | VocCollection.Insert(new(PIrrVocabulary,init('',lTokBase))); 102 | for i:= 0 to lVocs.fCount - 1 do 103 | begin 104 | for c:= Low(SymbolCounters) to High(SymbolCounters) do 105 | inc( lTokBase[c], AbsVocabularyPtr( lVocs.GetObject(i))^.fSymbolCnt[c]); 106 | VocCollection.Insert(new(PIrrVocabulary, init( lVocs.GetString(i), lTokBase))); 107 | end; 108 | end; 109 | 110 | procedure ChkEVL; 111 | var i,j: integer; 112 | label 1,2; 113 | begin 114 | Env.LoadEvl(EnvFileName+'.evl'); 115 | for i:=1 to Env.Directive[syVocabularies].Count-1 do 116 | begin 117 | for j:=0 to VocCollection.Count-1 do 118 | with PIrrVocabulary(VocCollection.Items^[j])^ do 119 | if nName = PImpArticleId(Env.Directive[syVocabularies].Items^[i])^.fStr then 120 | begin 121 | if Lexems.Count > 0 then goto 2; 122 | goto 1; 123 | end; 124 | 1: 125 | Error(PImpArticleId(Env.Directive[syVocabularies].Items^[i])^.fPos,709); 126 | Env.Directive[syVocabularies].Items^[i]:=nil; 127 | 2: 128 | end; 129 | if ErrorNbr> 0 then Env.StoreEvl(EnvFileName+'.$ev'); 130 | end; 131 | 132 | procedure PrintProf; 133 | var i,z:integer; 134 | Prof:text; 135 | begin 136 | assign(Prof,MizFileName+'.irv'); rewrite(Prof); 137 | for i:=1 to VocCollection.Count-1 do 138 | with PIrrVocabulary(VocCollection.Items^[i])^ do 139 | if Lexems.Count > 0 then 140 | begin writeln(Prof,nName); 141 | with Lexems do 142 | for z:=0 to Count-1 do 143 | with PLexem(At(z))^ do 144 | write(Prof,fSymb.Kind,fSymb.Nr,' ',fCnt,' '); 145 | writeln(Prof,';'); 146 | end; 147 | close(Prof); 148 | end; 149 | 150 | procedure ProcessText; 151 | var i: integer; lLexem: ProfLexem; 152 | label 1; 153 | begin 154 | gScanner:=new(AccScannPtr, InitScanning(MizFileName+ArticleExt,EnvFileName)); 155 | StartScaner; 156 | LoadPrf(EnvFileName); 157 | ReadToken; 158 | while CurWord.Kind <> EOT do 159 | begin 160 | if CurPos.Line mod 4 = 0 161 | then DisplayLine(CurPos.Line,ErrorNbr); 162 | if chr(ord(CurWord.Kind)) in ['A'..'Z'] then 163 | for i:=1 to VocCollection.Count-1 do 164 | if (PIrrVocabulary(VocCollection.Items^[i-1])^.Base[chr(ord(CurWord.Kind))] 0 then 194 | begin 195 | DrawErrorsMsg(ErrorNbr); 196 | halt(1); 197 | end; 198 | ChkEVL; 199 | DrawErrorsMsg(ErrorNbr); 200 | FinishDrawing; 201 | end. 202 | -------------------------------------------------------------------------------- /usrtools/lisppars.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | // Emacs Lisp output of formula skeletons 7 | 8 | // Sentences are printed to the .lsp file as Lisp lists. 9 | // Atomic formulas and quantification segments are just strings. 10 | 11 | program LispPars; 12 | 13 | uses pcmizver,mizenv,mconsole,errhan,monitor,syntax,parser,mscanner,lispscan, 14 | inout 15 | {$IFDEF MDEBUG} ,info {$ENDIF}; 16 | 17 | // Standard parsing stuff 18 | type 19 | LispItemPtr = ^LispItemObj; 20 | LispItemObj = 21 | object(ItemObj) 22 | nCanceledNbr:integer; 23 | constructor Init(fKind:ItemKind); 24 | procedure CreateExpression(fExpKind:ExpKind); virtual; 25 | procedure StartSentence; virtual; 26 | procedure FinishSentence; virtual; 27 | end; 28 | 29 | LispBlockPtr = ^LispBlockObj; 30 | LispBlockObj = 31 | object(BlockObj) 32 | constructor Init(fBlockKind:BlockKind); 33 | procedure CreateItem(fItemKind:ItemKind); virtual; 34 | procedure CreateBlock(fBlockKind:BlockKind); virtual; 35 | end; 36 | 37 | LispExpressionPtr = ^LispExpressionObj; 38 | LispExpressionObj = 39 | object(ExpressionObj) 40 | constructor Init(fExpKind:ExpKind); 41 | procedure CreateSubexpression; virtual; 42 | end; 43 | 44 | LispSubexpPtr = ^LispSubexpObj; 45 | LispSubexpObj = 46 | object(SubexpObj) 47 | constructor Init; 48 | destructor Done; virtual; 49 | procedure StartQualifiedSegment; virtual; 50 | procedure FinishQualifiedSegment; virtual; 51 | procedure FinishQuantified; virtual; 52 | procedure StartAtomicFormula; virtual; 53 | procedure FinishPredicativeFormula; virtual; 54 | procedure FinishQualifyingFormula; virtual; 55 | procedure FinishAttributiveFormula; virtual; 56 | procedure StartPrivateFormula; virtual; 57 | procedure FinishPrivateFormula; virtual; 58 | procedure StartExistential; virtual; 59 | procedure StartUniversal; virtual; 60 | procedure ProcessLeftParenthesis; virtual; 61 | procedure ProcessRightParenthesis; virtual; 62 | end; 63 | 64 | // Standard stuff 65 | constructor LispItemObj.Init(fKind : ItemKind); 66 | begin inherited Init(fKind); end; 67 | constructor LispBlockObj.Init(fBlockKind:BlockKind); 68 | begin inherited Init(fBlockKind); end; 69 | procedure LispItemObj.CreateExpression(fExpKind:ExpKind); 70 | begin gExpPtr:=new(LispExpressionPtr,Init(fExpKind)); end; 71 | procedure LispBlockObj.CreateItem(fItemKind:ItemKind); 72 | begin gItemPtr:=new(LispItemPtr,Init(fItemKind)); end; 73 | procedure LispBlockObj.CreateBlock(fBlockKind:BlockKind); 74 | begin gBlockPtr:=new(LispBlockPtr,Init(fBlockKind)) end; 75 | constructor LispExpressionObj.Init(fExpKind:ExpKind); 76 | begin inherited Init(fExpKind); end; 77 | procedure LispExpressionObj.CreateSubexpression; 78 | begin gSubexpPtr:=new(LispSubexpPtr,Init) end; 79 | constructor LispSubexpObj.Init; 80 | begin inherited Init end; 81 | destructor LispSubexpObj.Done; 82 | begin gSubexpPtr:=LispSubexpPtr(Previous); end; 83 | procedure InitArticle; 84 | begin gBlockPtr:=new(LispBlockPtr, Init(blMain));end; 85 | 86 | // If > 0, everything printable is printed as it goes, 87 | // otherwise the logical connectives are treated specially. 88 | var Ignored:integer = 0; 89 | 90 | 91 | procedure Paren; 92 | begin 93 | if (PrintLevel > 0) and (Ignored = 0) then 94 | gPrintedStr:= gPrintedStr + '('; 95 | end; 96 | 97 | 98 | procedure Unparen; 99 | begin 100 | if (PrintLevel > 0) and (Ignored = 0) then 101 | gPrintedStr:= gPrintedStr + ') '; 102 | end; 103 | 104 | // Quoting if printing 105 | procedure Quote; 106 | begin if (PrintLevel > 0) then 107 | begin 108 | if (Ignored = 0) then gPrintedStr:= gPrintedStr + '"'; 109 | inc(Ignored); 110 | end; 111 | end; 112 | 113 | // Unquoting if printing 114 | procedure Unquote; 115 | begin if (PrintLevel > 0) then 116 | begin 117 | if (Ignored = 1) then gPrintedStr:= gPrintedStr + '" '; 118 | dec(Ignored); 119 | end; 120 | end; { Unquote } 121 | 122 | 123 | var PBal: integer = 0; // paranthesis balance 124 | var AtBal: integer = 0; // balance for current atomic fla 125 | var AtPos: integer = 0; // '"' position for curent atomic fla 126 | 127 | // Quoting of atomic if printing 128 | // we save the postion of the '"' and the balance 129 | procedure QuoteAtom; 130 | begin if (PrintLevel > 0) then 131 | begin 132 | if (Ignored = 0) then 133 | begin 134 | gPrintedStr := gPrintedStr + '"'; 135 | AtBal := PBal; 136 | AtPos := Length(gPrintedStr); 137 | end; 138 | inc(Ignored); 139 | end; 140 | end; 141 | 142 | // Unquoting of atomic if printing 143 | procedure UnquoteAtom; 144 | var i:integer; 145 | begin if (PrintLevel > 0) then 146 | begin 147 | if (Ignored = 1) then 148 | begin 149 | gPrintedStr:= gPrintedStr + '" '; 150 | if AtBal > PBal then 151 | begin 152 | Mizassert(9000, gPrintedStr[AtPos] = '"'); 153 | gPrintedStr[AtPos] := '('; 154 | i:= 1; 155 | while AtBal > PBal do 156 | begin 157 | Mizassert(9000, AtPos > i); 158 | Mizassert(9000, gPrintedStr[AtPos - i] in ['(',' ']); 159 | if gPrintedStr[AtPos - i] = '(' then dec(AtBal); 160 | inc(i); 161 | end; 162 | gPrintedStr[1 + AtPos - i] := '"'; 163 | end; 164 | end; 165 | dec(Ignored); 166 | end; 167 | end; 168 | 169 | procedure LispSubexpObj.ProcessLeftParenthesis; 170 | begin inc(PBal); end; 171 | procedure LispSubexpObj.ProcessRightParenthesis; begin dec(PBal); end; 172 | 173 | // Atomic flas start and end quoting 174 | procedure LispSubexpObj.StartAtomicFormula;begin QuoteAtom; end; 175 | procedure LispSubexpObj.StartPrivateFormula;begin Quote; end; 176 | procedure LispSubexpObj.FinishPredicativeFormula;begin UnquoteAtom; end; 177 | procedure LispSubexpObj.FinishQualifyingFormula;begin UnquoteAtom; end; 178 | procedure LispSubexpObj.FinishAttributiveFormula;begin UnquoteAtom; end; 179 | procedure LispSubexpObj.FinishPrivateFormula;begin Unquote; end; 180 | 181 | // End of quantification ends quoting 182 | procedure LispSubexpObj.FinishQuantified;begin Unparen; end; 183 | 184 | procedure LispSubexpObj.StartQualifiedSegment;begin Paren; Quote; end; 185 | procedure LispSubexpObj.FinishQualifiedSegment;begin Unquote; Unparen; end; 186 | 187 | // Quantified flas have to handle their quentification 188 | procedure LispSubexpObj.StartUniversal; 189 | begin if (PrintLevel > 0) and (Ignored = 0) then 190 | begin gPrintedStr:= gPrintedStr + 'for (Q '; SkipFirst:=true;end; 191 | end; 192 | 193 | procedure LispSubexpObj.StartExistential; 194 | begin if (PrintLevel > 0) and (Ignored = 0) then 195 | begin gPrintedStr:= gPrintedStr + 'ex (Q '; SkipFirst:=true;end; 196 | end; 197 | 198 | 199 | // All is done for sentences only 200 | procedure LispItemObj.StartSentence; 201 | begin 202 | gPrintedStr:= '((pos ' + IntToStr(CurPos.Line) + ' ' 203 | + IntToStr(CurPos.Col) + ') '; 204 | PBal:= 0; AtBal:= 0; 205 | PrintLevel:=1; Ignored:=0; 206 | end; 207 | 208 | procedure LispItemObj.FinishSentence; 209 | begin 210 | gPrintedStr:= gPrintedStr + ')' + #10; 211 | OutFile.OutString(gPrintedStr); 212 | gPrintedStr:= ''; 213 | PrintLevel:=0; Ignored:=1; 214 | end; 215 | 216 | begin 217 | DrawMizarScreen('Lisp Parser'); 218 | InitExitProc; 219 | GetArticleName; GetEnvironName; 220 | GetOptions; 221 | FileExam(MizFileName+ArticleExt); 222 | OpenErrors(MizFileName); 223 | {$IFDEF MDEBUG} OpenInfoFile; {$ENDIF} 224 | InitArticle; 225 | InitDisplayLine('Parsing '+MizFileName); 226 | FileExam(EnvFileName+'.dct'); 227 | // FileExam(EnvFileName+'.prf'); 228 | InitScanning(MizFileName+ArticleExt,EnvFileName); 229 | ReadTokenProc:=LispReadToken; 230 | OutFile.OpenFile(MizFileName+'.lsp'); 231 | Parse; 232 | FinishScanning; 233 | OutFile.Done; 234 | DrawErrorsMsg(ErrorNbr); 235 | FinishDrawing; 236 | end. 237 | -------------------------------------------------------------------------------- /usrtools/lispscan.pas: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | // Scanner modifications for Emacs Lisp output of formula skeletons 7 | 8 | unit lispscan; 9 | 10 | interface 11 | 12 | uses mobjects,limits,syntax,mscanner,scanner,inout; 13 | 14 | procedure LispReadToken; 15 | 16 | var PrintLevel:integer = 0; // could be boolean now 17 | var SkipFirst:boolean = false; // skip the printing 18 | var gPrintedStr: string = ''; // all is printed to this string 19 | implementation 20 | 21 | uses errhan; 22 | 23 | // Protect Lisp characters 24 | procedure PrintRepr(fString: string); 25 | var i: integer; 26 | begin 27 | for i:=1 to length(fString) do 28 | begin 29 | if fString[i] in [ '''','\','"','?'] then 30 | gPrintedStr:= gPrintedStr + '\'; 31 | gPrintedStr:= gPrintedStr + fString[i]; 32 | end; 33 | end; 34 | 35 | // ReadToken procedure changed to do Emacs Lisp output 36 | // of tokens when the parser tells so 37 | procedure LispReadToken; 38 | var i:integer; 39 | begin 40 | ReadToken; 41 | if PrintLevel > 0 then 42 | if SkipFirst then SkipFirst:=false 43 | else 44 | begin 45 | PrintRepr(PrevWord.Spelling); 46 | if PrevPos.Line <> CurPos.Line then 47 | gPrintedStr:= gPrintedStr + ' ' 48 | else 49 | for i:=1 to CurPos.Col - 50 | (PrevPos.Col + length(CurWord.Spelling)) do 51 | gPrintedStr:= gPrintedStr + ' '; 52 | end; 53 | end; { LispReadToken } 54 | 55 | end. 56 | 57 | -------------------------------------------------------------------------------- /usrtools/listvoc.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | program ListVoc; 11 | 12 | uses mobjects,pcmizver,mizenv,librenv,monitor,dicthan,mconsole; 13 | 14 | var VocList: MStringCollection; 15 | PrintAllVocs: boolean; 16 | gVocsColl: MStringList; 17 | 18 | procedure PrintSymbolsInVoc(fName:string); 19 | var lVoc:PVocabulary; 20 | z: integer; 21 | begin 22 | fName:=UpperCase(fName); 23 | lVoc:=PVocabulary(gVocsColl.ObjectOf(fName)); 24 | if lVoc <> nil then 25 | begin 26 | { writeln(fName,':',gVocsColl.GetString(i));} 27 | with lVoc^.Reprs do 28 | for z:=0 to Count-1 do 29 | writeln(PSymbol(Items^[z])^.SymbolStr); 30 | end; 31 | end; 32 | 33 | procedure PrintVocs(const fVocList:MStringCollection); 34 | procedure PrintVoc(P:PString); 35 | begin 36 | writeln('Vocabulary: ',P^); writeln; 37 | PrintSymbolsInVoc(P^); writeln; 38 | end; 39 | var z: integer; 40 | begin 41 | with fVocList do 42 | for z:=0 to Count-1 do PrintVoc(PString(Items^[z])); 43 | end; 44 | 45 | procedure InitAllVocs; 46 | var i:integer; 47 | begin 48 | VocList.Init(gVocsColl.fCount,0); 49 | for i:=0 to gVocsColl.fCount-1 do 50 | VocList.Insert(NewStr(gVocsColl.GetString(i))); 51 | end; 52 | 53 | procedure CheckParameters; 54 | begin 55 | if ParamCount > 0 then Exit; 56 | Noise; 57 | DrawMizarScreen('List Vocabulary'); 58 | writeln('Syntax: listvoc vocabularynames ...'); 59 | FinishDrawing; 60 | halt(2); 61 | end; 62 | 63 | procedure InitParams; 64 | var P,D,N,E:String; 65 | begin 66 | PrintAllVocs:=false; 67 | CheckParameters; 68 | P:=paramstr(1); 69 | MizFileName:=MizFiles+MML+'.vct'; 70 | if pos('-f',P) = 1 then 71 | begin Delete(P,1,2); 72 | P:=UpperCase(P); 73 | D:=ExtractFileDir(P); 74 | if Pos('.',ExtractFileName(P)) > 0 75 | then N:=Copy(ExtractFileName(P),1,Pos('.',ExtractFileName(P))-1) 76 | else N:=ExtractFileName(P); 77 | E:=ExtractFileExt(P); 78 | if E='' then E:='.vct'; 79 | MizFileName:=D+N+E; 80 | if ParamCount > 1 then GetSortedNames(2,VocList) 81 | else PrintAllVocs:=true; 82 | exit 83 | end 84 | else if pos('-a',P) = 1 then 85 | begin 86 | PrintAllVocs:=true; 87 | exit 88 | end; 89 | GetSortedNames(1,VocList); 90 | end; 91 | 92 | begin 93 | DrawMizarScreen('List of Vocabularies'); 94 | InitParams; 95 | FileExam(MizFileName); 96 | InitExitProc; 97 | LoadMmlVcb(MizFileName,gVocsColl); 98 | if PrintAllVocs then InitAllVocs; 99 | PrintVocs(VocList); 100 | gVocsColl.Done; 101 | VocList.Done; 102 | FinishDrawing; 103 | end. 104 | -------------------------------------------------------------------------------- /usrtools/relprem.dpr: -------------------------------------------------------------------------------- 1 | (****************************************************************************** 2 | This file is part of the Mizar system. 3 | Copyright (c) Association of Mizar Users. 4 | License terms: GNU General Public License Version 3 or any later version. 5 | ******************************************************************************) 6 | 7 | {$IFDEF WIN32} 8 | {$APPTYPE CONSOLE} 9 | {$ENDIF} 10 | 11 | program RelPrem; 12 | 13 | uses verfinit,prepobj,mizprep,relpprep; 14 | 15 | begin 16 | ReviewArticle('Irrelevant Premises Detector',RelevantPremises, 17 | new(RelPremPBlockPtr,Init(blMain))); 18 | end. 19 | --------------------------------------------------------------------------------