[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] / [ ] / math_64_Meta_Macros
[Contents] [Source Text] || [Notation] || [Copyright] || [Contact] [Search ]
Mon Dec 13 14:20:08 PST 2010

# Macros

Macros are a useful technique for describing languages, and if used correctly leave the complexity of the processor unchanged.

## Macros

Functions that map sets of strings into sets of strings can be used as macros. If they are not recursive and defined with the same formula as any other definition then they can be removed. They can be treated as 'macros' or abreviations. Even so they are are convenient.

1. Set_of_abreviations::= macro_definition #macro_definition,

2. macro_definition_pack::= "For" #(variable ",") macro_definition #(punctuator, macro_definition),

3. macro_definition::= name "(" bound_symbol #("," bound_symbol)")" ":"":= " regular_expression(element=>(string|variable))

The expressions in the above may not use macros, etc.

4. macro_reference::= name "(" expression #("," expression)")"

There are the same number of expressions in a macro_reference as symbols in the macro_definition.

Examples useful for describing languages (See Ada and C)

5. For x, non(x)::= character~{x},
6. O(x)::= (x|),
7. N(x)::= x #x,
8. P(x)::= "(" x #(comma x) ")".
9. For x,y, L(x,y)::= x #(y x). Macros redefined using the above macros and other extensions

10. Set_of_abreviations::= N(macro_definition_pack),

11. macro_definition_pack::= "For" L(variable,",") "," L(macro_definition, punctuator),

12. macro_definition::=name P(variable) ":"":=" regular_expression(element=>(string|variable))

13. macro_reference::= name P(expression).

It is also possible to include more complex mappings than the context free macros described above. A nice example occurs in most programming languages in the definition of a litteral character string. Coming up with a clear, unambiguous and universal notation is not easier and there have been half-a-dozen solutions proposed [Higman, Chapter ??]. By using the more advanced (non-Chomsky) notations of MATHS many of these can be defined as follows:

There is a designated quote character q and a partial 1-1 map called 'escaping' (E) which associates some of the characters with a unique string. The domain of definition of E are the escapable characters. The image of E are the escape strings. q is one of these escapable character. The escape strings are NOT characters. Therefore q is not one of the escape strings (but may be a character in an escape string. Strings are then defined unambiguously by

14. For E:char<>->#char, q:/E(#char),
15. string(q,E)::= q #( E(char) | char~/E(#char) ) q.

In MATHS,

16. q = double_quote,
17. E = q+>backslash!q | backslash +> backslash!backslash. In C,
18. q = double_quote,
19. E(char)==>backslash #char,
20. For x:{q, backslash, ...}, E(x) = backslash!x,
21. E(CR)=backslash!"r", E(HT)=backslash!"t",... In Pascal,
22. q = single_quote, E=(single_quote+>single_quote single_quote).

. . . . . . . . . ( end of section Macros) <<Contents | End>>

# Standard Forms

## Macros

Examples useful for describing languages (See Ada and C)
1. macro::=@#char->@#char
2. non::macro= character~(_),
3. O::macro= ((_) |),
4. N::nacro= (_) #(_),
5. P::macro= "(" (_) #(comma (_) ) ")".
6. For x,y, L(x,y)::= x #(y x).

7. For A:@lexeme,
8. R::=map[ x:@#A ] ("(" #( x comma) identifier "=>" x #( comma identifier "=>" x ) ")"),
9. N::=map[ a:@#A ] (a #a).
10. L::=map[ x, y:@#A ] (x #(y x)).
11. P::=map[ a:@#A ] ( "(" L(a, comma) ")" ).

## Typical Expression Types

12. POSTFIX::=map[ e, R:@#A ]("("e")"R),
13. PREFIX::=map[ e, R:@#A ] (R"("e")"),
14. LISP_S_expression::=map[ e, R:@#A ] ("(" R e")"),
15. CAMBRIDGE::=LISP_S_expression,
16. RPN::=map[ e, R:@#A ] (e R).
17. UNARY::=map[ a, f:@#A ] ( POSTFIX(a,f) | PREFIX(a,f)),
18. BINARY::=map[ a, b, o:@#A ] ( "(" a o b ")").
19. INFIX::=map[ a:@#A, o:#A ]( "(" a #(o a) ")" ).

20. BRA-KET::=map[ p:@(A><A), e:@#A ] ({ b e k || (b,k):b }).

21. LAMBDA::=map[ d, c:@#A ] ("map" "[" d "]" "(" c ")" ).

22. INTENTION::=map[ d,p:@#A ] ("{" d "||" p "}"),
23. EXTENSION::=map[ e:@#A] ("{" L(e, "," ) "}").

24. N-TUPLE::=map[ e:#@#A ] ("(" LIST(e) ")"),
25. LIST::=map[ e:#@#A ] (e.1st "," LIST(e.rest) ).

## Notes on MATHS Notation

Special characters are defined in [ intro_characters.html ] that also outlines the syntax of expressions and a document.

Proofs follow a natural deduction style that start with assumptions ("Let") and continue to a consequence ("Close Let") and then discard the assumptions and deduce a conclusion. Look here [ Block Structure in logic_25_Proofs ] for more on the structure and rules.

The notation also allows you to create a new network of variables and constraints. A "Net" has a number of variables (including none) and a number of properties (including none) that connect variables. You can give them a name and then reuse them. The schema, formal system, or an elementary piece of documentation starts with "Net" and finishes "End of Net". For more, see [ notn_13_Docn_Syntax.html ] for these ways of defining and reusing pieces of logic and algebra in your documents. A quick example: a circle might be described by Net{radius:Positive Real, center:Point, area:=π*radius^2, ...}.

For a complete listing of pages in this part of my site by topic see [ home.html ]

## Notes on the Underlying Logic of MATHS

The notation used here is a formal language with syntax and a semantics described using traditional formal logic [ logic_0_Intro.html ] plus sets, functions, relations, and other mathematical extensions.

For a more rigorous description of the standard notations see

26. STANDARD::= See http://www.csci.csusb.edu/dick/maths/math_11_STANDARD.html

## Glossary

27. above::reason="I'm too lazy to work out which of the above statements I need here", often the last 3 or 4 statements. The previous and previous but one statments are shown as (-1) and (-2).
28. given::reason="I've been told that...", used to describe a problem.
29. given::variable="I'll be given a value or object like this...", used to describe a problem.
30. goal::theorem="The result I'm trying to prove right now".
31. goal::variable="The value or object I'm trying to find or construct".
32. let::reason="For the sake of argument let...", introduces a temporary hypothesis that survives until the end of the surrounding "Let...Close.Let" block or Case.
33. hyp::reason="I assumed this in my last Let/Case/Po/...".
34. QED::conclusion="Quite Easily Done" or "Quod Erat Demonstrandum", indicates that you have proved what you wanted to prove.
35. QEF::conclusion="Quite Easily Faked", -- indicate that you have proved that the object you constructed fitted the goal you were given.
36. RAA::conclusion="Reducto Ad Absurdum". This allows you to discard the last assumption (let) that you introduced.