Grace/Core/Syntax.g17
Open in Workbench Download source
Imports
Grace.Core.Nat
Declarations
Source
1234567module Grace.Core.Syntax8namespace Grace.Core.Syntax9import Grace.Core.Nat10open Grace.Core.Nat.Rec11121314datatype TermSyntax15 | variable(name : Set)16 | application(function : Set, argument : self)1718datatype FormulaSyntax19 | atom(relation left right : Set)20 | implication(left right : self)21 | universal(variable : Set, body : self)2223datatype GoalSyntax24 | goal(context target : Set)2526272829datatype TacticSyntax30 | exactStep(theoremName : Set)31 | introStep(name : Set, continuation : self)32 | sequence(first second : self)33 | choice(first second : self)34 | repeatStep(body : self)3536namespace Formula3738def size (formula : FormulaSyntax) -> Nat39 | FormulaSyntax.atom(relation, left, right) => 140 | FormulaSyntax.implication(left, right) => succ(add(size(left), size(right)))41 | FormulaSyntax.universal(variable, body) => succ(size(body))4243theorem size.atom44 shows size(FormulaSyntax.atom(1, 2, 3)) = 145proof46 compute4748end Formula4950namespace Tactic5152def cost (tactic : TacticSyntax) -> Nat53 | TacticSyntax.exactStep(theoremName) => 154 | TacticSyntax.introStep(name, continuation) => succ(cost(continuation))55 | TacticSyntax.sequence(first, second) => add(cost(first), cost(second))56 | TacticSyntax.choice(first, second) => add(cost(first), cost(second))57 | TacticSyntax.repeatStep(body) => succ(cost(body))5859theorem cost.example60 shows cost(TacticSyntax.sequence(TacticSyntax.exactStep(1), TacticSyntax.introStep(2, TacticSyntax.exactStep(3)))) = 361proof62 compute6364end Tactic6566eval Formula.size(FormulaSyntax.implication(FormulaSyntax.atom(1, 2, 3), FormulaSyntax.universal(4, FormulaSyntax.atom(5, 6, 7))))67eval Tactic.cost(TacticSyntax.sequence(TacticSyntax.exactStep(1), TacticSyntax.introStep(2, TacticSyntax.exactStep(3))))6869end Grace.Core.Syntax70