10 GCLC 2015 Manual
User Manual:
Open the PDF directly: View PDF .
Page Count: 109
Download | |
Open PDF In Browser | View PDF |
GCLC 2015 (Geometry Constructions → LATEX Converter) Manual Predrag Janičić Faculty of Mathematics Studentski trg 16 11000 Belgrade Serbia url: www.matf.bg.ac.rs/~janicic e-mail: janicic@matf.bg.ac.rs GCLC page: www.matf.bg.ac.rs/~janicic/gclc October 2015 c 1996-2015 Predrag Janičić 2 Contents 1 Briefly About GCLC 1.1 Comments and Bugs Report . . . . . . . . . . . . . . . . . . . . . 1.2 Copyright Notice . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Quick Start 2.1 Installation . . . . . . . . 2.2 First Example . . . . . . . 2.3 Basic Syntax Rules . . . . 2.4 Basic Objects . . . . . . . 2.5 Geometrical Constructions 2.6 Basic Ideas . . . . . . . . 5 7 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 10 11 11 12 12 3 GCLC Language 3.1 Basic Definition Commands . . . . . . . . . . . . . . . . . 3.2 Basic Constructions Commands . . . . . . . . . . . . . . . 3.3 Transformation Commands . . . . . . . . . . . . . . . . . 3.4 Calculations, Expressions, Arrays, and Control Structures 3.5 Drawing Commands . . . . . . . . . . . . . . . . . . . . . 3.6 Labelling and Printing Commands . . . . . . . . . . . . . 3.7 Low Level Commands . . . . . . . . . . . . . . . . . . . . 3.8 Cartesian Commands . . . . . . . . . . . . . . . . . . . . . 3.9 3D Cartesian Commands . . . . . . . . . . . . . . . . . . 3.10 Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.11 Support for Animations . . . . . . . . . . . . . . . . . . . 3.12 Support for Theorem Provers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 16 16 18 19 23 29 31 33 37 39 40 40 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Graphical User Interface 43 4.1 An Overview of the Graphical Interface . . . . . . . . . . . . . . 43 4.2 Features for Interactive Work . . . . . . . . . . . . . . . . . . . . 44 5 Exporting Options 5.1 Export to Simple LATEX format . . . . . . . . 5.1.1 Generating LATEX Files and gclc.sty 5.1.2 Changing LATEX File Directly . . . . . 5.1.3 Handling More Pictures on a Page . . 5.1.4 Batch Processing . . . . . . . . . . . . 5.2 Export to PSTricks LATEX format . . . . . . . 5.3 Export to TikZ LATEX format . . . . . . . . . 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 49 50 50 51 51 52 53 4 CONTENTS 5.4 5.5 5.6 5.7 5.8 Export to Raster-based Formats and Export to Sequences of Images Export to eps Format . . . . . . . . . . . . . . . . . . . . . . . . Export to svg Format . . . . . . . . . . . . . . . . . . . . . . . . Export to xml Format . . . . . . . . . . . . . . . . . . . . . . . . Generating PostScript and pdf Documents . . . . . . . . . . . 6 Theorem Prover 6.1 Introductory Example . . . . . . . . . . . . . . . . . . 6.2 Basic Sorts of Conjectures . . . . . . . . . . . . . . . . 6.3 Geometry Quantities and Stating Conjectures . . . . . 6.4 Area Method . . . . . . . . . . . . . . . . . . . . . . . 6.4.1 Underlying Constructions . . . . . . . . . . . . 6.4.2 Integration of Algorithm and Auxiliary Points 6.4.3 Non-degenerative Conditions and Lemmas . . . 6.4.4 Structure of Algorithm . . . . . . . . . . . . . . 6.4.5 Scope . . . . . . . . . . . . . . . . . . . . . . . 6.5 Wu’s Method and Gröbner Bases Method . . . . . . . 6.6 Prover Output . . . . . . . . . . . . . . . . . . . . . . 6.6.1 Prover’s Short Report . . . . . . . . . . . . . . 6.6.2 Controlling Level of Output . . . . . . . . . . . 6.6.3 Proofs in LATEX format . . . . . . . . . . . . . 6.6.4 Proofs in xml format . . . . . . . . . . . . . . 6.7 Automatic Verification of Regular Constructions . . . 7 xml 7.1 7.2 7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 54 55 55 55 57 58 58 59 62 62 62 63 63 65 65 65 65 66 66 68 69 Support 73 xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 xml Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Using xml Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 A List of Errors and Warnings 77 B Version History 79 C Additional Modules 85 D Acknowledgements 87 E Examples E.1 Example E.2 Example E.3 Example E.4 Example E.5 Example (Simple Triangle) . (Conics) . . . . . . . (Parametric Curves) (While-loop) . . . . (Ceva’s theorem) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 89 90 92 94 96 Chapter 1 Briefly About GCLC What is GCLC? GCLC (from “Geometry Constructions → LATEX converter”) is a tool for visualizing and teaching geometry, and for producing mathematical illustrations. Its basic purpose is converting descriptions of mathematical objects (written in the gcl language) into digital figures. GCLC provides easy-to-use support for many geometrical constructions, isometric transformations, conics, and parametric curves. The basic idea behind GCLC is that constructions are formal procedures, rather than drawings. Thus, in GCLC, producing mathematical illustrations is based on “describing figures” rather than of “drawing figures”. This approach stresses the fact that geometrical constructions are abstract, formal procedures and not figures. A figure can be generated on the basis of abstract description, in Cartesian model of a plane. These digital figures can be displayed and exported to LATEX or some other format. Although GCLC was initially built as a tool for converting formal descriptions of geometric constructions into LATEX form, now it is much more than that. For instance, there is support for symbolic expressions, for drawing parametric curves, for program loops, user-defined procedures, etc; builtin theorem provers can automatically prove a range of complex theorems; the graphical interface makes GCLC a tool for teaching geometry, and other mathematical fields as well. The main purposes of GCLC: • producing digital mathematical illustrations of high quality; • usage in mathematical education and as a research tool; • storing mathematical contents; • studies of automated geometrical reasoning. The main features of GCLC: • freely available; • support for a range of elementary and advanced constructions, and isometric transformations; • support for symbolic expressions, second order curves, parametric curves, loops, user-defined procedures, etc. 6 1 Briefly About GCLC • user-friendly interface, interactive work, animations, tracing points, watch window (“geometry calculator”), and other tools; • easy drawing of trees; • built-in theorem provers, capable of proving many complex theorems (in traditional geometry style or in algebraic style); • very simple, very easy to use, very small in size; • export of high quality figures into LATEX, eps, svg, bitmap format; • import from JavaView JVX format; • available from http://www.matf.bg.ac.rs/~janicic/gclc and from EMIS (The European Mathematical Information Service) servers: http://www.emis.de/misc/software/gclc/. Implementation and platforms: There are command-line versions and versions with graphical user interface (GUI) of GCLC for Windows and for Linux. The version with graphical user interface provides a range of additional functionalities, including interactive work, animations, traces, “watch window”, etc. It gives GCLC a new, graphic user-friendly interface, and introduces some new features which are not available in the command-line version. It is a kind of an “Integrated Development Environment” or IDE for GCLC. The version of GCLC with GUI for Windows is called WinGCLC. GCLC can be also used via GeoThms (joint work with Pedro Quaresma, University of Coimbra), a web-based framework for constructive geometry (http://hilbert.mat.uc.pt/~geothms). GCLC program is implemented in the C++ programming language. Author: GCLC is being developed at the Faculty of Mathematics, University of Belgrade, by Predrag Janičić and, in some parts, by Predrag Janičić and his collaborators: • Ivan Trajković (University of Belgrade, Serbia) — a co-author of the graphical interface for WinGCLC 2003; • prof. Pedro Quaresma (University of Coimbra, Portugal) — a coauthor of the theorem prover based on the area method built into GCLC. • Goran Predović (University of Belgrade, Serbia) — the main author of the theorem prover based on the Wu’s method and Gröbner based method built into GCLC. • prof. Pedro Quaresma (University of Coimbra, Portugal), Jelena Tomašević (University of Belgrade, Serbia), and Milena Vujošević-Janičić (University of Belgrade, Serbia) — co-authors of the xml support for GCLC. • Luka Tomašević (University of Belgrade, Serbia) — the main author of the support for graph drawing. • prof. Konrad Polthier and Klaus Hildebrandt (Technical University, Berlin, Germany) — coauthors of JavaView → GCLC converter). 1.1 Comments and Bugs Report 7 Version history: GCLC programs is under development since 1996. and had several releases since then. It has thousands of users and has been used for producing digital illustrations for a number of books and journal volumes and in a number of different high-school and university courses. What others said about GCLC/WinGCLC: “... program WinGCLC... is a very useful, impressive professional academic geometry program.” (from an anonymous review for “Teaching Mathematics and its Applications”) References: More on the background of GCLC can be found in [6, 9, 5, 10, 7, 8]. 1.1 Comments and Bugs Report Please send your comments and/or noticed bugs to the following e-mail address: janicic@matf.bg.ac.rs. Your feedback would be very much appreciated and would help in improving the future releases of GCLC. 1.2 Copyright Notice This software is protected by the Creative Commons licence CC BY-ND (https://creativecommons.org/licenses/by-nd/4.0/) Attribution-NoDerivatives 4.0 International. This license allows for redistribution, commercial and non-commercial, as long as it is passed along unchanged and in whole, with credit to the author. You may install and run GCLC without any restrictions. All output of this software is your property. You are free to use it in teaching, studying, research, and in producing digital illustrations. THIS SOFTWARE IS PROVIDED ”AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. If you use GCLC, please let me know by sending an e-mail to Predrag Janičić (janicic@matf.bg.ac.rs). You will be put on the GCLC mailing list and be informed about new releases of GCLC. If you used GCLC for producing figures for your book, article, thesis, I would be happy to hear about that. Your feedback would be very much appreciated and would help in improving the future releases of GCLC. 8 1 Briefly About GCLC Chapter 2 Quick Start In GCLC one describes mathematical objects in the gcl language. This description can be visualized within the version with GUI (or within view previewer, see p 85) or can be converted into some other format, e.g., LATEX format. In this chapter, we describe how to run GCLC and we give one very simple figure description and discuss how it can be processed and give an illustration in LATEX format. 2.1 Installation There is no installation required for GCLC— just unzip the distribution archive (to a folder of your choice) and you can run the program. For convenience, you can add the path to this folder to the system path, so you can run GCLC from any folder. You can associate GCLC (GUI version) with .gcl files, so you can always open them with GCLC. When the archive is unpacked, in the root folder there will be executable programs – a command line version and a version with GUI, and LATEX packages gclc.sty and gclcproofs.sty for processing figures and proofs generated by GCLC. In addition, there will be the following folders: • manual with the manual file and additional reference papers; • samples with a range of .gcl samples, organized in the following subfolders: – basic_samples with basic samples for GCLC; – samples_prover with samples for the theorem prover; – samples_gui with samples specific for GUI version; • tools with additional tools (view and jv2gcl) (not included in the version for Linux); • working_example with a self-contained example ready to be processed by LATEX; • LaTeX_packages with LATEX packages (developed by other authors) required for the prover output or for support for colors. 10 2 Quick Start • XML_support xml suite for different processing of xml files generated by GCLC. 2.2 First Example Using GCLC is very simple. Like many other programs, GCLC has its document type — *.gcl document type. *.gcl file is nothing more than a plain text file (it has no special formatting inside), containing a list of gcl commands. Consider the following text: point A 40 85 point B 35 20 point C 95 20 cmark_lt A cmark_lb B cmark_rb C drawsegment A B drawsegment B C drawsegment C A It describes a triangle ABC via gcl commands. The command point A 40 85 introduces a point A with coordinates (40, 85). The command cmark_lt A denotes the point A by a small circle and prints its name in left-top direction. The command drawsegment A B draws the segment AB. More details on gcl commands can be found in Chapter 3 If you are using the command-line version of GCLC, type the above text (gcl code) in any text editor and save it under the name, say, quick.gcl. The figure in LATEX format can be generated using the following command: > gclc quick.gcl quick.pic where quick.pic is the name of a resulting file. Within the GUI version, you can type the above code directly to the builtin editor, save the file under the name, say, quick.gcl, and press the button Build in the toolbar (or choose the option Picture/Build from the menu). Then, you can export the picture to LATEX format by selecting the option File/Export to.../LaTeX (and choosing the name, say, quick.pic).1 More details about the GUI version can be found in Chapter 4. The picture (contained in quick.pic) can be included in your LATEX document using the command: \input{quick.pic} in an appropriate position in your LATEX document. In addition, you have to include (by the LATEX command \usepackage{gclc}) the package gclc (provided within the gclc distribution) in the preamble of your document,2 and 1 Within this chapter, we comment only on the simple L AT X format, supported by E gclc.sty. However, GCLC can export to other LATEX formats, see Chapter 5. 2 You also have to put the file gclc.sty (providing the gclc package) in the current folder (where your LATEX document is) or in the folder with other LATEX packages. 2.3 Basic Syntax Rules 11 then you can process your LATEX document as usual. If everything is ok, within your LATEX document you will get the illustration as shown in Figure 2.1. More details about export to LATEX can be found in Chapter 5. A B C Figure 2.1: Illustration generated from the given GCLC code 2.3 Basic Syntax Rules The syntax of the gcl language is very simple. Commands, identifiers, constants etc. must be separated by at least one tab or space symbol or a new line. Usually, each new command (with its argument) is in separate line and empty lines separate different parts of the construction. 2.4 Basic Objects There are five types of objects in the gcl language: number, point, line, circle and conic. They are represented in the following manner: number n (n) point (x, y) (x, y) line ax + by + c = 0 (a, b, c) circle (x − x0 )(x − x0 ) + (y − y0 )(y − y0 ) = r2 (x0 , y0 , r) conic ax2 + 2bxy + cy 2 + 2dx + 2ey + f = 0 (a, b, c, d, e, f ) 12 2 Quick Start While processing an input file, GCLC generates the transcript file gclc.log (in the current directory) with the list of all warnings and the list of all defined objects (with their names and parameters). Instead of writing to the log file, the GUI version shows this list in its output window. 2.5 Geometrical Constructions Geometrical constructions are the main area of GCLC. A geometrical construction is a sequence of specific, primitive construction steps. These primitive construction steps are also called elementary constructions and they are: • construction (by ruler) of a line such that two given points belong to it; • construction of a point such that it is the intersection of two lines (if such a point exist); • construction (by compass) of a circle such that its center is one given point and such that the second given point belongs to it; • construction of intersections between a given line and a given circle (if such points exist). By using the set of primitive constructions, one can define more involved, compound constructions (e.g., construction of right angle, construction of the segment midpoint, construction of the segment bisector etc.). In describing geometrical constructions, it is usual to use higher level constructions as well as the primitive ones. GCLC follows the idea of formal constructions. It provides easy-to-use support for all primitive constructions, but also for a range of higher-level constructions. (Although motivated by the formal geometrical constructions, GCLC provides a support for some non-constructible objects too — for instance, in GCLC it is possible to determine/use a point obtained by rotation for 1◦ , although it is not possible to construct that point by ruler and compass). 2.6 Basic Ideas There is a need of distinguishing abstract (i.e., formal, axiomatic) nature of geometrical objects and their usual models. A geometrical construction is a mere procedure of abstract steps and not a picture. However, for each (Euclidean) construction, there is its counterpart in the standard Cartesian model. While a construction is an abstract procedure, in order to make its usual representation in Cartesian model of Euclidean plane, we still have to make some link between these two. For instance, given three vertices of a triangle we can construct a center of its inscribed circle (by using primitive constructions), but in order to represent this construction in Cartesian plane, we have to take three particular Cartesian points as vertices of the triangle. A figure description in GCLC is usually made by a list of definitions of several fixed points (defined in terms of Cartesian plane, i.e., by pairs of coordinates) and then a list of construction steps based on these points. Normally, there should be very few such fixed points and all other points should depend on them. Afterwards, if one wants to vary a 2.6 Basic Ideas 13 figure, he/she would usually change only coordinates of fixed points and all other objects will be recalculated automatically. For instance, if points A and B are given by their coordinates, never introduce their midpoint M also by coordinates, but always via the command midpoint M A B. This would give your GCLC descriptions flexibility and would better reflect the mathematical/geometrical meaning of the figure. 14 2 Quick Start Chapter 3 GCLC Language In the gc language, there are several entities: commands (source code statements), objects (scalar, point, line, conic), and constants. A source code line will generally have a command and identifiers (as handles for an object or variable) and possibly constants (including constant text enclosed by brackets). The syntax requires that entities be separated by at least one tab or space symbol. Commands should be separated by at least one tab or space symbol, or, for better readability, by new line. The commands fall into ten categories, and the identifiers will be one of five types of objects in GCLC: number, point, line, circle, and conic. The types are not attached to variables explicitly, but implicitly (with respect to the given context). Notation conventions. This document uses the following notation to clarify that an identifier is of a particular type. When writing the source code, always leave out the < and > marks. •a constant (a decimal number) or a simple numerical variable (of type number); • an identifier associated with a point; • an identifier associated with a line; • an identifier associated with a circle; • an identifier associated with a conic; • Constant text string beginning with the symbol { and ending with the symbol }. • denotes an arbitrary expression. Identifiers can be one to 99 characters. Underscores, single-quotes or braces are permissible, but not white spaces. Identifiers are case-sensitive. Names like A_1 or Q_{a}’ (in usual TEX form) can be used. 16 3 GCLC Language 3.1 Basic Definition Commands The first parameter for each of these commands is the identifier, the rest are constants or variables. The identifier can have a previous definition which is ignored, it just gets a new type and new value. • number : Definition of a number. The object is defined or re-defined as type number, and can be used in commands as a segment length, measure of an angle (in degrees) or as a command specific parameter (but cannot be used where a point, line, circle or conic is expected). The variable’s value can be changed by another number command, or by expression command. can be a constant or another number identifier. Example: number left_bottom_x 80. • point : Definition of a point. is defined or re-defined as type point, where its x-coordinate value becomes and its y-coordinate value becomes . and can be constants or number variables. • point : Extended definition of a point within support of animations (relevant only for GUI version, see 3.11), where ( , ) is the starting location for the point, and ( , ) is the final location. , , , can be constants or number variables. • line : Definition of a line. Identifier gets type line, determined by (already defined) points and . • circle : Definition of a circle. Identifier gets type circle, and represents a circle determined by two points: the first point ( ) is the center and the second ( ) is anywhere on the circle. • set_equal : The object gets the type and the value of the object . 3.2 Basic Constructions Commands • intersec The object with the specified identifier becomes point and gets coordinates of the intersection of two given lines. This command can also be used in this form: intersec The object with the specified identifier becomes point and gets coordinates of the intersection of two given lines given by and by . The full name, intersection, can also be used for this command. • intersec2 The objects with the specified identifiers and become points and get coordinates 3.2 Basic Constructions Commands 17 of the intersection of two given circles, of a given circle and a line, or of a given line and a circle. The full name, intersection2, can also be used for this command. • midpoint The object with the specified identifier becomes point and gets coordinates of the midpoint of the segment determined by two given points. • med The object with the specified identifier becomes line and gets the parameters of the line that bisects (and is perpendicular to) the segment determined by the two given points. The full name, mediatrice, can also be used for this command. • bis The object with the specified identifier becomes line and gets the parameters of the line that bisects the angle determined by three given points. Example: bis s A B C makes object s to become line with parameters of the bisector of the angle 6 ABC. The full name, bisector, can also be used for this command. • perp The object with the specified identifier becomes line and gets the parameters of the line that is perpendicular to the given line and contains the given point. The full name, perpendicular, can also be used for this command. • foot The object with the specified identifier becomes point and gets the parameters of the foot of the perpendicular from the point to the line . • parallel The object with the specified identifier becomes line and gets the parameters of the line that is parallel to the given line and contains the given point. • getcenter The object with the specified identifier becomes point and gets the parameters of the center of the given circle. • onsegment The object with the specified identifier becomes point, placed randomly on the line segment determined by the two given points. • online The object with the specified identifier becomes point, placed randomly on the line determined by the two given points (more precisely, a random point is chosen between points X and Y such that X is symmetrical to with respect to and Y is symmetrical to with respect to ). (This command is suitable for describing constructions with properties to be proved by the theorem provers.) 18 3 GCLC Language • oncircle The object with the specified identifier becomes point, placed randomly on the circle with center and with the point . (This command is suitable for describing constructions with properties to be proved by the theorem provers.) 3.3 Transformation Commands • translate The object with the specified identifier becomes point and gets the parameters of the point that is an image of the third point ( ) in a translation for the vector determined by the first and the second given point. Example: translate A2 X Y A1 makes object A2 to become point such that T (A1)=A2, where T is translation for the vector XY. • rotate The object with the specified identifier becomes point and gets the parameters of the point that is an image of the second given point in a rotation around the first given point and for the given (positive or negative) angle (determined by the given constant or number). Example: rotate A2 O 90 A1 makes object A2 to become point such that R(A1)=A2, where R is rotation around the point O for the angle of 90◦ . • rotateonellipse The object with the specified identifier becomes point and gets the parameters of the point Y such that the angle X Y is equal to n, where X is the intersection of the half-line and the ellipse determined by . • sim The object with the specified identifier becomes point and gets the parameters of the point that is an image of the given point in a half-turn, line-reflection or inversion (depending of the type (point, line, or circle) of the second argument). Example: If l is line, sim A2 l A1 makes object A2 to become point such that S(A1)=A2 where S is line reflection determined by the line l. The full name, symmetrical, can also be used for this command. • turtle The object with the specified identifier becomes point. Its segment length from will be . The segment determined by and will make an angle (in degrees) with the segment from to . Example: turtle A X Y 90 10.00 makes object A to become point such that YA=10.00 and 6 XYA=90◦ . 3.4 Calculations, Expressions, Arrays, and Control Structures 19 • towards The object with the specified identifier becomes point, placed on the line determined by the two given points. The distance from to the new point is a fraction of the distance from to . Thus, if 0 < < 1, then the point will be between points and ; if > 1, the point will be between points and ; if < 0, the point will be between points and . Example: towards O A B 0.9 makes object O to become point such that AO=0.9 ·AB and O is between A and B. 3.4 Calculations, Expressions, Arrays, and Control Structures • getx : The object with the specified identifier becomes number and gets the value of the x-coordinate of the given point . • gety The object with the specified identifier becomes number and gets the value of the y-coordinate of the given point . • distance : The object with the specified identifier becomes number and gets the value of the distance between two given points. • angle : The object with the specified identifier becomes number and gets the measure of the angle determined by three given points. Example: angle alpha A B C makes object alpha to get type number and its value will be the measure of the (oriented) angle 6 ABC (in degrees). • angle_o : The same as the command angle, but takes orientation into account, so the angle can have positive and negative values. Therefore, this version is compatible with the command rotate. • random The object with the specified identifier gets type number and gets a (pseudo)random value between 0 and 1. • expression {exp}: The object with the specified identifier gets type number and gets the value of the expression exp. Example: expression e {sin(3)*(5+2)} After the above command, e will have the value 0.366352. Defined variables of the type number can be used in expressions. No other variables can be used in expressions. For instance, 20 3 GCLC Language expression e {n+5} makes object e to become number equal to n+5, if n is of the type number. The following standard functions, operators and relations are supported in expressions: + (addition), - (subtraction), * (multiplication), / (division), == (equality), != (inequality), <, <=, >, >=, && (and), || (or), abs, ceil (rounding up), floor (rounding down), sin, cos, tan (with arguments expressed in radians), sinh, cosh, tanh, asin, acos, atan, sqrt, exp, pow (exponentiation), log, log10, min (two arguments), max (two arguments). For example, expression m { pow(n+1,2)} makes object m equal (n+1)2 (note that the operator ^ is not used for exponentiation). The ite operator (from if-then-else) is also supported. For example, expression E {ite(n>0,1,2)} makes object E to become number equal to 1 if n is greater than zero, and 2 otherwise. Blank spaces in expressions are allowed and ignored. • array { ... }: Definition of an (multidimensional) array. The values ... are dimensions of the array. There can be up to 10 dimensions. All elements of the array initially have type number and value 0. Indexing is 1-based, i.e., the first element of the array has all indices equal 1. Indices are written in separate angle brackets. Examples: array A { 4 3 } defines 4 × 3 = 12 elements of the array A — A[1][1], A[1][2], . . ., A[4][3]. All these elements initially have the type number and value 0, but both of these can be changed, as for any other variable. So, different elements of the same array can have different types. Indices of an array element can be arbitrary expressions, that can also involve other array elements (of type number). For instance, if all elements of an (one-dimensional) array A are numbers, one can use the following construction: A[5 + A[5]] (in any position that requires a number). An array with the same name can be defined more than once. If the numbers of dimensions are same, and if all dimensions are same, then all old elements are reset to have type number and value 0. If some dimensions are different, new elements may be added (if some new dimensions are greater then the old ones), but old elements (those not covered by the new definition) are never destroyed (even if some new dimensions are less then the old ones). If the numbers of dimensions (in two definitions) are different, then these two arrays are considered different and there are no resetting of the old elements. 3.4 Calculations, Expressions, Arrays, and Control Structures 21 • while { } { }: is a sequence of commands. This sequence will be repeatedly executed as long as condition is true (nonzero). Example: point A 0 0 number n 0 while { n<30 } { point B n 30 drawsegment A B expression n { n+1 } } Both syntax and run-time errors encountered within a while-block are reported only as Invalid while block error and no other (more detailed) information on the error is provided. Also, all warnings encountered within a while-block are suppressed and are not written to the log. The sequence of commands in the while-block behaves as any GCLC sequence. It shares the defined variables and the environment (defined by commands ang_picture and ang_origin etc) with the outer GCLC context. If the condition is never fulfilled, this leads to non-termination (i.e., infinite loop). In order to prevent this, the system enables only a limited number (10000) of executions of blocks within while-loops. If this number is exceeded, then the error Too many while-block executions (more than 10000). Possible infinite loop is reported and the processing is stopped. Procedures cannot be defined within while-blocks. • if_then_else { } { } { }: is a sequence of commands. This sequence will be executed if condition is true (nonzero). is a sequence of commands. This sequence will be executed if condition is false (zero). Example: distance d1 C A distance d2 C B if_then_else { d1 and are reported only as Invalid if-then-else block error and no other (more detailed) information on the error is provided. Also, all warnings encountered within a if-then-else-block are suppressed and are not written to the log. The sequence of commands in the blocks behaves as any GCLC sequence. It shares the defined variables and the environment (defined by commands ang_picture and ang_origin etc) with the outer GCLC context. Procedures cannot be defined within if-then-else-blocks. • procedure { } { }: is the name of the procedure. is a list of the procedure’s arguments. Arguments are separated by blank spaces. In GCLC, arguments are passed by their names, which means that they may be changed by the procedure. is a sequence of commands. It inherits the environment form the outer context, but not the variables from the outer context. Within a block, only arguments and variables defined within it can be used. The definition of a procedure must precede calling it. Procedures cannot be defined within while-blocks or within definitions of other procedures. Example: procedure drawtriangle { X Y Z } { drawsegment X drawsegment Y drawsegment Z } • call { } is the name of the procedure. is a list of the arguments that will be passed to the procedure. Arguments are separated by blank spaces. In GCLC, variables are passed to procedures as arguments by names and they may be changed by a procedure. Argument of a procedure call can also be a constant (and, of course, it is passed by value). If a variable that is argument is not defined before (i.e., with an intention that it receives the resulting value of the function), by default it get the type number and the value 0. If a single variable is used for several arguments, it will get the value of the last of such arguments (when returning from the procedure). Procedures can be called from other procedures. Example: call drawtriangle { A B C } 3.5 Drawing Commands 23 • include Reads/consults the contents of another .gcl file. After this command, variables and procedures defined in that another file can be used (as they were defined within the current file). Both syntax and run-time errors encountered within the consulted file are reported only as Invalid include file error and no other (more detailed) information on the error is provided. Also, all warnings encountered within the consulted file are suppressed and are not written to the log. 3.5 Drawing Commands All drawn figures are clipped against the defined picture area. The current area can be changed by the area command. • drawpoint Generates a (export–specific) command for drawing the specified point. • drawsegment Generates a command for drawing the segment determined by endpoints named and . • drawdashsegment Generates commands for drawing the dashed segment connecting points named and . The length of dashes can be changed by the dash command. • drawline Generates a command for drawing the given line. • drawline Generates a command for drawing the line determined by the points and . • drawdashline