]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_tactics/nCicTacReduction.ml
Preparing for 0.5.9 release.
[helm.git] / helm / software / components / ng_tactics / nCicTacReduction.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 (* $Id: nCic.ml 9058 2008-10-13 17:42:30Z tassi $ *)
13  
14 let rec normalize ?(delta=0) ~subst ctx t =
15  normalize_machine ~delta ~subst ctx
16   (fst (NCicReduction.reduce_machine ~delta ~subst ctx (0,[],t,[])))
17 and normalize_machine ?(delta=0) ~subst ctx (k,e,t,s) =
18  assert (delta=0);
19  let t = 
20    if k = 0 then t
21    else
22      NCicSubstitution.psubst ~avoid_beta_redexes:true  
23        (fun e -> normalize_machine ~delta ~subst ctx (NCicReduction.from_env ~delta e)) e t in
24  let t =
25   match t with
26      NCic.Meta (n,(s,lc)) ->
27       let l = NCicUtils.expand_local_context lc in
28       let l' = List.map (normalize ~delta ~subst ctx) l in
29        if l = l' then t
30        else
31         NCic.Meta (n,(s,NCic.Ctx l))
32    | t -> NCicUtils.map (fun h ctx -> h::ctx) ctx (normalize ~delta ~subst) t
33  in
34  if s = [] then t 
35  else
36   NCic.Appl
37    (t::
38     (List.map (fun i -> normalize_machine ~delta ~subst ctx (NCicReduction.from_stack ~delta i)) s))
39 ;;