4.5 Apply rule

Application of a rule or of a user theory

Syntax

  ar(T)
  ar(r, M)

with

Use

ar is a command enabling the application of a rule or a theory on different parts of the lemma to prove.

For rewrite rules, the argument M enables controlled action on any part of the proof obligation, goal or hypothesis .

The rules used are those of the prover rule base, any rules contained in the pmm file (see chapter 6 page §) associated with the component, and also the rules contained in the PatchProver file (see chapter 7 page §).

To access the rules base, click on the “Display/print” menu and then, on the “Display Rules Database” button, of the window INTERACTIVE PROOFof the interactive prover.

Application in backward mode (M=Once or M=Multi):

Application in forward mode(M=Fwd):

Application of a tactic:

The DED theory (native theory of the kernel raising the hypotheses in the stack) is obligatory. The Forward theories are only called when a hypothesis is raised. The Backward theories generate derived goals P => Q but do not raise the hypotheses P. It is thus necessary to associate a theory to them enabling a direct deduction (DED). When the Command ar has finished, the hypotheses will be associated to the current goal, which will then be:

Hypotheses generated current goal

Of course, the theories can be “tilded”. For example:

         ar(((tb1;tb2~;)~;tbn;DED),(tf1;tf2~;...;tfp~))

Implicitly

         ar((tb1;...;tbn),(tf1;...;tfp))

is equivalent to

         ar((tb1;...;tbn)~,(tf1;...;tfp)~)

After the application of the ar command, if new hypotheses are generated, the goal is in the form H G (the user can see the new hypotheses generated). It is necessary to perform the pr command (see chapter 4.38 page §) to reactivate the proof and raise these hypotheses.

Warning! If the user-provided rules (pmm, PatchProver) are used, the validity of the proof can be questioned. We must then perform a mathematical demonstration for each of these rules.

Example 1

Let us consider the following situation:


 
    Hypothesis  
        xx: 1..10 &  
        yy: 1..10 &  
        zz: 1..100  
    Goal  
        xx+yy-1: 1..100  
 


The user uses the pmm file as follows:


 
THEORY test IS  
 
        a: 1..d &  
        b: 1..d  
        =>  
        a+b: 2..2*d;  
 
        d <= a-c &  
        a-c <= e  
        =>  
        a-c: d..e  
 
END  
 


The test theory is read and compiled, using the pc command (see chapter 4.35 page §).


 
PRI> pc  
Loading theory test  
 


The rule test.1 is then applied in forward mode(generation of hypotheses).


 
PRI> ar(test.1,Fwd)  
Starting Apply Rule  
 


5 new hypotheses have been generated. The goal becomes:


 
    Goal  
        xx+xx: 2..20 &  
        xx+yy: 2..20 &  
        yy+xx: 2..20 &  
        yy+yy: 2..20 &  
        zz+zz: 2..200  
        =>  
       xx+yy-1: 1..100  
 


Using the dd command (see chapter 4.14 page §).


 
PRI> dd  
Starting Deduction  
 


the hypotheses are then raised in the hypotheses stack.


 
     New Hypothesis since last command  
        xx+xx: 2..20 &  
        xx+yy: 2..20 &  
        yy+xx: 2..20 &  
        yy+yy: 2..20 &  
        zz+zz: 2..200  
    Goal  
        xx+yy-1: 1..100  
 


The rule test.2 is then used in the backward mode.


 
PRI> ar(test.2, Once)  
Starting Apply Rule  
 


The rule is applied (we must check that the command line contains ar(test.2,Once)) and the two sub-goals 1 xx + yy - 1 and xx + yy - 1 100 will be processed. The first sub-goal is to be proved:


 
    Goal  
        1<=xx+yy-1  


The automatic prover is called for the first time:


 
PRI> pr  
Starting Prover Call  
 


The first sub-goal is discharged. The second sub-goal becomes the current goal.


 
    Goal  
        xx+yy-1<=100  
 


By calling the automatic prover


 
PRI> pr  
Starting Prover Call  


the second sub-goal is discharged and the proof obligation is proved, provided that the rules contained in the pmm file are accurate.

Finally, the command line is:


 
        Force(0) &  
          ar(test.1,Fwd) &  
            dd &  
              dd &  
                ar(test.2,Once) &  
                  pr &  
                  pr &  
          Next  


Example 2

Given the following situation:


 
    Hypothesis  
        tt: {e1,e2,e3,e4,e5} => zz = e5 &  
        zz = e5 => tt: {e1,e2,e3,e4} &  
        tt = e5 => zz = e1 &  
        zz = e1 => tt = e5  
    Goal  
        tt = e5 or zz = e2  
 


associated to the following pmm file:


 
THEORY test IS  
 
        bguard(WRITE: bwritef("Application of test.1\n")) &  
        (B=>not(A))  
        =>  
        (A or B)  
 
END  
&  
THEORY testbis IS  
 
        a = b &  
        b: E  
        =>  
        a: E  
END  
 


The user attempts to apply the backward theory test to the current goal. The hypotheses will be raised by the DED theory. If hypotheses are generated, the forward theory testbis will then be tried.


 
PRI> ar((test;DED),testbis)  
Application of test.1  
Starting Apply Rule  
 


The rule test.1 contains a guard enabling to print a message indicating its activation (Application of test.1). The rule testbis.1 was activated when hypothesis e2 = zz was raised and enabled the generation of hypothesis zz ∈{e1,e2,e3,e4,e5}. All the hypotheses generated are finally put as antecedents of the current goal.


 
    Goal  
        btrue & zz=e2 & zz: {e1,e2,e3,e4,e5} => not(tt = e5)