let debug_print s =
if debug then prerr_endline (Lazy.force s);;
+let is_propositional context sort =
+ match CicReduction.whd context sort with
+ | Cic.Sort Cic.Prop
+ | Cic.Sort (Cic.CProp _) -> true
+ | _-> false
+;;
+
+
type auto_params = Cic.term list * (string * string) list
let elems = ref [] ;;
let terms = List.map CicUtil.term_of_uri univ in
List.map
(fun t ->
- (t,fst(CicTypeChecker.type_of_aux' [] [] t CicUniv.empty_ugraph)))
+ (t,fst(CicTypeChecker.type_of_aux' [] [] t CicUniv.oblivion_ugraph)))
terms
let find_context_theorems context metasenv =
let _,_,mt = CicUtil.lookup_meta i metasenv in
let sort,u =
CicTypeChecker.type_of_aux' metasenv context mt
- CicUniv.empty_ugraph
+ CicUniv.oblivion_ugraph
in
- let b, _ =
- CicReduction.are_convertible ~metasenv context
- sort (Cic.Sort Cic.Prop) u
- in
- if b then Some i else None
+ if is_propositional context sort then Some i else None
| _ -> assert false)
args
in
let only signature context metasenv t =
try
let ty,_ =
- CicTypeChecker.type_of_aux' metasenv context t CicUniv.empty_ugraph
+ CicTypeChecker.type_of_aux' metasenv context t CicUniv.oblivion_ugraph
in
let consts = MetadataConstraints.constants_of ty in
let b = MetadataConstraints.UriManagerSet.subset consts signature in
(fun t ->
let ty,_ =
CicTypeChecker.type_of_aux'
- metasenv context t CicUniv.empty_ugraph
+ metasenv context t CicUniv.oblivion_ugraph
in
(* retrieve_equations could also return flexible terms *)
if is_an_equality ty then Some(t,ty)
in
(* SIMPLIFICATION STEP
let equalities =
- let env = (metasenv, context, CicUniv.empty_ugraph) in
+ let env = (metasenv, context, CicUniv.oblivion_ugraph) in
let eq_uri = HExtlib.unopt (LibraryObjects.eq_URI()) in
Saturation.simplify_equalities bag eq_uri env units
in
let _,_,mt = CicUtil.lookup_meta i metasenv in
let sort,u =
CicTypeChecker.type_of_aux' metasenv context mt
- CicUniv.empty_ugraph
- in
- let b, _ =
- CicReduction.are_convertible ~metasenv context
- sort (Cic.Sort Cic.Prop) u
+ CicUniv.oblivion_ugraph
in
- if b then Some i else None
+ if is_propositional context sort then Some i else None
| _ -> assert false)
args
in
HExtlib.filter_map
(fun t ->
let ty,_ =
- CicTypeChecker.type_of_aux' metasenv context t CicUniv.empty_ugraph in
+ CicTypeChecker.type_of_aux' metasenv context t
+ CicUniv.oblivion_ugraph in
(* retrieve_equations could also return flexible terms *)
if is_an_equality ty then Some(t,ty) else None)
equations in
in
let metasenv' = metasenv@newmetasenvfragment in
let termty,_ =
- CicTypeChecker.type_of_aux' metasenv' context term' CicUniv.empty_ugraph
+ CicTypeChecker.type_of_aux' metasenv' context term' CicUniv.oblivion_ugraph
in
let termty = CicSubstitution.subst_vars exp_named_subst_diff termty in
let goal_arity = count_prods context ty in
(****************** AUTO ********************)
let mk_irl ctx = CicMkImplicit.identity_relocation_list_for_metavariable ctx;;
-let ugraph = CicUniv.empty_ugraph;;
+let ugraph = CicUniv.oblivion_ugraph;;
let typeof = CicTypeChecker.type_of_aux';;
let ppterm ctx t =
let names = List.map (function None -> None | Some (x,_) -> Some x) ctx in
CicPp.pp t names
;;
let is_in_prop context subst metasenv ty =
- let sort,u = typeof ~subst metasenv context ty CicUniv.empty_ugraph in
- fst (CicReduction.are_convertible context sort (Cic.Sort Cic.Prop) u)
+ let sort,u = typeof ~subst metasenv context ty CicUniv.oblivion_ugraph in
+ is_propositional context sort
;;
let assert_proof_is_valid proof metasenv context goalty =
if debug then
begin
- let ty,u = typeof metasenv context proof CicUniv.empty_ugraph in
+ let ty,u = typeof metasenv context proof CicUniv.oblivion_ugraph in
let b,_ = CicReduction.are_convertible context ty goalty u in
if not b then
begin
let _,context,ty = CicUtil.lookup_meta g metasenv in
try
let sort,u = typeof ~subst metasenv context ty ugraph in
- let b,_ =
- CicReduction.are_convertible
- ~subst ~metasenv context sort (Cic.Sort Cic.Prop) u in
- b
+ is_propositional context sort
with
| CicTypeChecker.AssertFailure s
| CicTypeChecker.TypeCheckerFailure s ->
let order_new_goals metasenv subst open_goals ppterm =
let prop,rest = split_goals_in_prop metasenv subst open_goals in
let closed_prop, open_prop = split_goals_with_metas metasenv subst prop in
+ let closed_type, open_type = split_goals_with_metas metasenv subst rest in
let open_goals =
- (List.map (fun x -> x,P) (closed_prop @ open_prop))
+ (List.map (fun x -> x,P) (open_prop @ closed_prop))
@
- (List.map (fun x -> x,T) rest)
+ (List.map (fun x -> x,T) (open_type @ closed_type))
in
let tys =
List.map
type subst = Cic.substitution
type goal = ProofEngineTypes.goal * int * AutoTypes.sort
let candidate_no = ref 0;;
-type candidate = int * Cic.term
+type candidate = int * Cic.term Lazy.t
type cache = AutoCache.cache
type tables =
Saturation.active_table * Saturation.passive_table * Equality.equality_bag
(* the status exported to the external observer *)
type auto_status =
(* context, (goal,candidate) list, and_list, history *)
- Cic.context * (int * Cic.term * bool * int * (int * Cic.term) list) list *
- (int * Cic.term * int) list * Cic.term list
+ Cic.context * (int * Cic.term * bool * int * (int * Cic.term Lazy.t) list) list *
+ (int * Cic.term * int) list * Cic.term Lazy.t list
let d_prefix l =
let rec aux acc = function
| None -> Printf.sprintf "D(%d, _, %d)" gi d
in
let string_of_s m su k (ci,ct) gi =
- Printf.sprintf "S(%d, %s, %s, %d)" gi (pp k) (pp ct) ci
+ Printf.sprintf "S(%d, %s, %s, %d)" gi (pp k) (pp (Lazy.force ct)) ci
in
let string_of_ol m su l =
String.concat " | "
subst, metasenv
;;
let mk_fake_proof metasenv subst (goalno,_,_) goalty context =
- None,metasenv,subst ,Cic.Meta(goalno,mk_irl context),goalty, []
+ None,metasenv,subst ,(lazy (Cic.Meta(goalno,mk_irl context))),goalty, []
;;
let equational_case
tables maxm cache depth fake_proof goalno goalty subst context
let open_goals = order_new_goals metasenv subst open_goals ppterm in
let open_goals = List.map (fun (x,sort) -> x,depth-1,sort) open_goals in
incr candidate_no;
- Some ((!candidate_no,cand),metasenv,subst,open_goals), tables , maxmeta
+ Some ((!candidate_no,lazy cand),metasenv,subst,open_goals), tables , maxmeta
with
| ProofEngineTypes.Fail s -> None,tables, maxm
| CicUnification.Uncertain s -> None,tables, maxm
(* we demodulate using both actives passives *)
List.fold_left (fun tbl eq -> Indexing.index tbl eq) (snd active) equalities
in
- let env = metasenv,context,CicUniv.empty_ugraph in
+ let env = metasenv,context,CicUniv.oblivion_ugraph in
match Indexing.solve_demodulating bag env table initgoal steps with
| Some (proof, metasenv, newty) ->
let refl =
in
let changed,(newproof,newmetasenv, newty) =
Indexing.demodulation_goal bag
- (metasenv,context,CicUniv.empty_ugraph) table initgoal
+ (metasenv,context,CicUniv.oblivion_ugraph) table initgoal
in
if changed then
begin