CADiZ

Reference manual / Tactic syntax


Introduction

The syntax of tactics is a CADi\num-specific extension to the standard Z syntax.

This syntax refers to some non-terminal symbols of the standard syntax, as well as to tokens of the standard lexis and to tokens specific to tactics, all of which are defined elsewhere.

The syntax is formalized below using syntactic metalanguage.

Formal definition of tactic syntax

Goal = GOAL, [[, NAME, {,, NAME}, ]], Hyp, \vdash?, Concs;

Hyp = DeclPart, {\dagger, DeclPart}, [|, Antes];

Antes = [Predicate, {,, Predicate}];

Concs = [Predicate, {,, Predicate}];

NamedTacticDef = TACTIC, NAME, TacticDef;

TacticDef = TypedJoker, {,, TypedJoker}, |, Tactic;

TypedJoker = expr, NAME
| pred, NAME
| decl, NAME
| goal, NAME
| exprs, NAME
| decls, NAME
| stxt, NAME
| name, NAME
| names, NAME
| type, NAME
| str, NAME
;

Tactic = RuleName, RuleArg, {RuleArg}
| Tactic, ;, Tactic
| (, Tactic, ||, Tactic, {||, Tactic}, )
| (, Tactic, !!, Tactic, {!!, Tactic}, )
| map, Tactic
| Tactic, |, Tactic
| !, Tactic
| skip
| fail
| rec, NAME, @, Tactic
| RecJoker
| (, Tactic, )
| match, ExprJoker, ExprCase, {ExprCase}, ::, .
| match, PredJoker, PredCase, {PredCase}, ::, .
| match, ExprsJoker, ExprsCase, {ExprsCase}, ::, .
| match, DeclsJoker, DeclsCase, {DeclsCase}, ::, .
| match, StxtJoker, StxtCase, {StxtCase}, ::, .
| match, DeclJoker, DeclCase, {DeclCase}, ::, .
| match, NamesJoker, NamesCase, {NamesCase}, ::, .
| match, TypeJoker, TypeCase, {TypeCase}, ::, .
| patante, pred, NAME, |, NUMBER, @, Tactic
| patcons, pred, NAME, |, NUMBER, @, Tactic
| patgoal, [TypedJoker, {,, TypedJoker}], |, Hyp, \vdash?, Concs, @, Tactic
| let, [TacBinding, {,, TacBinding}], @, Tactic
;

ExprCase = ::, [TypedJoker, {,, TypedJoker}], |, Expression, @, {|, Expression, @}, Tactic;

PredCase = ::, [TypedJoker, {,, TypedJoker}], |, Predicate, @, {|, Predicate, @}, Tactic;

ExprsCase = ::, [TypedJoker, {,, TypedJoker}], |, Expressions, @, {|, Expressions, @}, Tactic;

DeclsCase = ::, [TypedJoker, {,, TypedJoker}], |, DeclPart, @, {|, DeclPart, @}, Tactic;

StxtCase = ::, [TypedJoker, {,, TypedJoker}], |, SchemaText, @, {|, SchemaText, @}, Tactic;

DeclCase = ::, [TypedJoker, {,, TypedJoker}], |, Declaration, @, {|, Declaration, @}, Tactic;

NamesCase = ::, [TypedJoker, {,, TypedJoker}], |, [DeclName, {,, DeclName}], @,
], @), Tactic;

TypeCase = ::, [TypedJoker, {,, TypedJoker}], |, Type, @, {|, Type, @}, Tactic;

RuleName = STRING;

RuleArg = NUMBER
| STRING
| (, String, {++, String}, )
| ExprJoker
| PredJoker
| DeclJoker
| GoalJoker
| ExprsJoker
| DeclsJoker
| StxtJoker
| NameJoker
| NamesJoker
| TypeJoker
| StringJoker
;

String = STRING
| ExprJoker
| PredJoker
| DeclJoker
| ExprsJoker
| DeclsJoker
| StxtJoker
| NameJoker
| NamesJoker
| TypeJoker
| StringJoker
;

TacBinding = [TypedJoker, {,, TypedJoker}], ==, TacFunction;

TacFunction = antecedent, [-], NUMBER
| consequent, [-], NUMBER
| parseexpr, STRING
| parseexprs, STRING
| parsepred, STRING
| parsedecl, STRING
| parsename, STRING
| parsestxt, STRING
| declsbefore, DeclsJoker
| declsafter, DeclsJoker
| typeof, ExprJoker
| declof, ExprJoker
;

Expression = ExprJoker
| (, ExprJoker, )
| ExprJoker, as, Expression
| _expr
| all Expression productions of the standard syntax
;
ExpressionList = ExprsJoker
| ExprsJoker, as, ExpressionList
| _exprs
| all ExpressionList productions of the standard syntax
;
Predicate = PredJoker
| (, PredJoker, )
| PredJoker, as, Predicate
| _pred
| all Predicate productions of the standard syntax
;
SchemaText = StxtJoker
| (, StxtJoker, )
| StxtJoker, as, SchemaText
| _stxt
| all SchemaText productions of the standard syntax
;
DeclPart = DeclsJoker
| (, DeclsJoker, )
| DeclsJoker, as, DeclPart
| _decls
| all DeclPart productions of the standard syntax
;
Declaration = DeclJoker
| (, DeclJoker, )
| DeclJoker, as, Declaration
| _decl
| all Declaration productions of the standard syntax
;
DeclName = NameJoker
| _name
| NameJoker, as, DeclName
| all DeclName productions of the standard syntax
;
RefName = NameJoker
| NameJoker, as, RefName
| _name
| all RefName productions of the standard syntax
;
Type = TypeJoker
| _type
| all Type productions of the standard syntax
;
Paragraph = Goal
| NamedTacticDef
| all Paragraph productions of the standard syntax bar conjectures
;

Analogously, names jokers can be used in the name list of a hiding expression, along with as patterns and wildcards.

Operator precedences and associativities

The following table defines the relative precedences of productions and the associativities of their operators. The productions are identified by their rightmost tokens. The rows in the table are ordered so that those entries that bind more weakly appear nearer the top of the table than those that bind more tightly. Those operators that have the same names as Z operators conveniently share the same precedences as those Z operators.

Productions Associativity
as right
@  | right
; left
! right

Parentheses may be used to override the default precedences.

Notes

GOAL and TACTIC are box tokens, distinguishing the two new kinds of paragraph.

The Goal syntax recognises all conjectures of the standard syntax, and so subsumes the Conjecture syntax.

A Goal in a specification may have a name associated with it. The name is written within the mark-up of the paragraph outline, so is not mentioned in this syntax.

TacticDef phrases can appear in text files, in which case the name of the tactic is identified with the name of the file, whereas in specifications the name is given by the NamedTacticDef paragraph in which it appears.

The TypedJoker notation introduces a new joker, the scope of which is limited to the production that declares it. This condition is enforced by the lexer, as names are mapped to joker tokens through the keyword look-up table.

A DeclJoker joker is associated with a single declaration, i.e. either a schema inclusion or the declaration of a single name. Hence in a DeclCase, a pattern having multiple names can never match.

The declaration jokers DeclJoker and DeclsJoker can also be used in those contexts where the standard syntax permits only constant declarations, namely binding extension expressions and subsitution expressions.

The expression list jokers ExprsJoker can be used in tuple extensions, set extensions, generic instantiations and sequence arguments. They cannot yet be used in cartesian products, for which a special syntax will be needed.

RuleArgs take the place of interactive selections and dialogue responses. The dialogue responses are listed first in order, followed by the selections in the same order as they would be made interactively. Each selection is represented by a number n, identifying the n'th well-formed formula in the current goal. Each dialogue response is represented by a string. Jokers, as bound to formulae by earlier pattern matching, may be used as selections or dialogue responses. Dialogue response strings may be constructed from the concatenation of smaller strings. A str argument is typically used to parametrise a tactic on the name of an arbitrary auxiliary tactic.

General purpose tactics may be written independently of specifications. Where a specification applies a function operator, a tactic can use a juxtaposed function application as a pattern to match against the operator application. Where a specification applies a relation operator, a tactic can use a membership predicate as a pattern to match against the operator application. Where a specification applies a generic operator, a tactic can use a generic instantiation expression as a pattern to match against the operator application.


IT 12-Jan-2002