@param c a rational
@return the new flin
*)
-let flin_add f x c =
- let cx = flin_coef f x in
- Hashtbl.remove f.fhom x;
- Hashtbl.add f.fhom x (rplus cx c);
- f
+let flin_add f x c =
+ match x with
+ Cic.Rel(n) ->(
+ let cx = flin_coef f x in
+ Hashtbl.remove f.fhom x;
+ Hashtbl.add f.fhom x (rplus cx c);
+ f)
+ |_->debug ("Internal error in Fourier! this is not a Rel "^CicPp.ppterm x^"\n");
+ let cx = flin_coef f x in
+ Hashtbl.remove f.fhom x;
+ Hashtbl.add f.fhom x (rplus cx c);
+ f
;;
(**
Adds c to f.fcste
;;
(**
- @return f times a
+ @return a times f
*)
let flin_emult a f =
let f2 = flin_zero() in
(* coq wrapper
let rational_of_const = rational_of_term;;
*)
-
+let fails f a =
+ try
+ let tmp = (f a) in
+ false
+ with
+ _-> true
+ ;;
let rec flin_of_term t =
let fl_of_binop f l =
let arg1 = (List.hd next) and
arg2 = (List.hd(List.tl next))
in
- try
+ if fails rational_of_term arg1
+ then
+ if fails rational_of_term arg2
+ then
+ ( (* prodotto tra 2 incognite ????? impossibile*)
+ failwith "Sistemi lineari!!!!\n"
+ )
+ else
+ (
+ match arg1 with
+ Cic.Rel(n) -> (*trasformo al volo*)
+ (flin_add (flin_zero()) arg1 (rational_of_term arg2))
+ |_-> (* test this *)
+ let tmp = flin_of_term arg1 in
+ flin_emult (rational_of_term arg2) (tmp)
+ )
+ else
+ if fails rational_of_term arg2
+ then
+ (
+ match arg2 with
+ Cic.Rel(n) -> (*trasformo al volo*)
+ (flin_add (flin_zero()) arg2 (rational_of_term arg1))
+ |_-> (* test this *)
+ let tmp = flin_of_term arg2 in
+ flin_emult (rational_of_term arg1) (tmp)
+
+ )
+ else
+ ( (*prodotto tra razionali*)
+ (flin_add_cste (flin_zero()) (rmult (rational_of_term arg1) (rational_of_term arg2)))
+ )
+ (*try
begin
- let a = rational_of_term arg1 in
+ (*let a = rational_of_term arg1 in
+ debug("ho fatto rational of term di "^CicPp.ppterm arg1^
+ " e ho ottenuto "^string_of_int a.num^"/"^string_of_int a.den^"\n");*)
+ let a = flin_of_term arg1
try
begin
let b = (rational_of_term arg2) in
+ debug("ho fatto rational of term di "^CicPp.ppterm arg2^
+ " e ho ottenuto "^string_of_int b.num^"/"^string_of_int b.den^"\n");
(flin_add_cste (flin_zero()) (rmult a b))
end
with
- _ -> (flin_add (flin_zero()) arg2 a)
+ _ -> debug ("ho fallito2 su "^CicPp.ppterm arg2^"\n");
+ (flin_add (flin_zero()) arg2 a)
end
with
- _-> (flin_add(flin_zero()) arg1 (rational_of_term arg2))
+ _-> debug ("ho fallito1 su "^CicPp.ppterm arg1^"\n");
+ (flin_add(flin_zero()) arg1 (rational_of_term arg2))
+ *)
end
|"cic:/Coq/Reals/Rdefinitions/Rinv.con"->
let a=(rational_of_term (List.hd next)) in
|_-> assert false
end
|_-> assert false)
- with _ -> flin_add (flin_zero()) t r1
+ with _ -> debug("eccezione = "^CicPp.ppterm t^"\n");flin_add (flin_zero()) t r1
;;
(* coq wrapper
|_->assert false)(* match u *)
| Cic.MutInd (u,i,o) ->
(match UriManager.string_of_uri u with
- "cic:/Coq/Init/Logic_Type/eqT.con" ->
+ "cic:/Coq/Init/Logic_Type/eqT.ind" ->
let t0= arg1 in
let arg1= arg2 in
let arg2= List.hd(List.tl (List.tl next)) in
Hashtbl.iter (fun x c ->
try (Hashtbl.find hvar x;())
with _-> nvar:=(!nvar)+1;
- Hashtbl.add hvar x (!nvar))
+ Hashtbl.add hvar x (!nvar);
+ debug("aggiungo una var "^
+ string_of_int !nvar^" per "^
+ CicPp.ppterm x^"\n"))
f.hflin.fhom)
lineq1;
(*print_hash hvar;*)
debug("Il numero di incognite e' "^string_of_int (!nvar+1)^"\n");
let sys= List.map (fun h->
let v=Array.create ((!nvar)+1) r0 in
- Hashtbl.iter (fun x c -> v.(Hashtbl.find hvar x)<-c)
+ Hashtbl.iter (fun x c -> v.(Hashtbl.find hvar x) <- c)
h.hflin.fhom;
((Array.to_list v)@[rop h.hflin.fcste],h.hstrict))
lineq1 in
"cic:/Coq/fourier/Fourier_util/Rle_zero_1.con") [] ;;
let _Rle_zero_pos_plus1 = Cic.Const (UriManager.uri_of_string
"cic:/Coq/fourier/Fourier_util/Rle_zero_pos_plus1.con") [] ;;
-let _Rle_zero_zero = Cic.Const (UriManager.uri_of_string
- "cic:/Coq/fourier/Fourier_util/Rle_zero_zero.con") [] ;;
+(*let _Rle_zero_zero = Cic.Const (UriManager.uri_of_string
+ "cic:/Coq/fourier/Fourier_util/Rle_zero_zero.con") [] ;;*)
let _Rlt = Cic.Const (UriManager.uri_of_string
"cic:/Coq/Reals/Rdefinitions/Rlt.con") [] ;;
let _Rlt_mult_inv_pos = Cic.Const (UriManager.uri_of_string
(*let cste = pf_parse_constr gl in*)
debug("inizio tac_zero_infeq_pos\n");
let tacn = ref
- (if n=0 then
+ (*(if n=0 then
(PrimitiveTactics.apply_tac ~term:_Rle_zero_zero )
- else
+ else*)
(PrimitiveTactics.apply_tac ~term:_Rle_zero_1 )
- )
+ (* ) *)
in
let tacd=ref (PrimitiveTactics.apply_tac ~term:_Rlt_zero_1 ) in
for i=1 to n-1 do
let metasenv' = (fresh_meta,context,t)::metasenv in
let proof' = curi,metasenv',pbo,pty in
let proof'',goals =
- PrimitiveTactics.apply_tac ~term:(Cic.Appl ((Cic.Cast (Cic.Meta
- (fresh_meta,irl),t))::al)) ~status:(proof',goal)
+ PrimitiveTactics.apply_tac
+ (*~term:(Cic.Appl ((Cic.Cast (Cic.Meta (fresh_meta,irl),t))::al)) (* ??? *)*)
+ ~term:(Cic.Appl ((Cic.Meta (fresh_meta,irl))::al)) (* ??? *)
+ ~status:(proof',goal)
in
proof'',fresh_meta::goals
;;
let curi,metasenv,pbo,pty = proof in
let metano,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
+debug("my_cut di "^CicPp.ppterm c^"\n");
+
+
let fresh_meta = ProofEngineHelpers.new_meta proof in
let irl =
ProofEngineHelpers.identity_relocation_list_for_metavariable context in
| _ -> c
;;
-let find_in_context id context =
+(*let find_in_context id context =
let rec find_in_context_aux c n =
match c with
[] -> failwith (id^" not found in context")
[] -> []
| Some(Cic.Name(h),Cic.Decl(t))::next -> (
let n = find_in_context h cont in
+ debug("assegno "^string_of_int n^" a "^CicPp.ppterm t^"\n");
[(Cic.Rel(n),t)] @ filter_real_hyp next cont)
| a::next -> debug(" no\n"); filter_real_hyp next cont
+;;*)
+let filter_real_hyp context _ =
+ let rec filter_aux context num =
+ match context with
+ [] -> []
+ | Some(Cic.Name(h),Cic.Decl(t))::next ->
+ (
+ (*let n = find_in_context h cont in*)
+ debug("assegno "^string_of_int num^" a "^h^":"^CicPp.ppterm t^"\n");
+ [(Cic.Rel(num),t)] @ filter_aux next (num+1)
+ )
+ | a::next -> filter_aux next (num+1)
+ in
+ filter_aux context 1
;;
+
(* lifts everithing at the conclusion level *)
let rec superlift c n=
match c with
(* !!!!! fix !!!!!!!!!! *)
let contradiction_tac ~status:(proof,goal)=
Tacticals.then_
- ~start:(PrimitiveTactics.intros_tac ~name:"bo?" )
+ ~start:(PrimitiveTactics.intros_tac ~name:"bo?" ) (*inutile sia questo che quello prima della chiamata*)
~continuation:(Tacticals.then_
~start:(Ring.elim_type_tac ~term:_False)
~continuation:(assumption_tac))
in
tac:=(Tacticals.thens
~start:(my_cut ~term:ineq)
- ~continuations:[Tacticals.then_
+ ~continuations:[(*Tacticals.id_tac;Tacticals.id_tac*)(**)Tacticals.then_
~start:(fun ~status:(proof,goal as status) ->
let curi,metasenv,pbo,pty = proof in
let metano,context,ty = List.find (function (m,_,_) -> m=goal)
~continuation:(Tacticals.thens
~start:(
fun ~status ->
+ debug("t1 ="^CicPp.ppterm !t1 ^"t2 ="^CicPp.ppterm !t2 ^"tc="^ CicPp.ppterm tc^"\n");
let r = equality_replace (Cic.Appl [_Rminus;!t2;!t1] ) tc
~status
in
r)
~continuations:
[PrimitiveTactics.apply_tac ~term:_Rinv_R1
-(* CSC: Il nostro goal e' 1^-1 = 1 e non 1 = 1^-1. Quindi non c'e' bisogno
- di applicare sym_eqT. Perche' in Coq il goal e' al contrario? Forse i
- parametri della equality_replace vengono passati al contrario? Oppure la
- tattica usa i parametri al contrario?
- CODICE NEL COMMENTO NON PORTATO. ORA ESISTE ANCHE LA TATTICA symmetry_tac
- ~continuations:[Tacticals.then_
- ~start:(
- fun ~status:(proof,goal as status) ->
- debug("ECCOCI\n");
- let curi,metasenv,pbo,pty = proof in
- let metano,context,ty = List.find (function (m,_,_) -> m=
- goal) metasenv in
- debug("ty = "^CicPp.ppterm ty^"\n");
- let r = PrimitiveTactics.apply_tac ~term:_sym_eqT
- ~status in
- debug("fine ECCOCI\n");
- r)
- ~continuation:(PrimitiveTactics.apply_tac ~term:_Rinv_R1)
-*)
;Tacticals.try_tactics
~tactics:[ "ring", (fun ~status ->
debug("begin RING\n");
r)
; "id", Tacticals.id_tac]
])
- ;Tacticals.then_
+ ;(*Tacticals.id_tac*)
+ Tacticals.then_
~start:
(
fun ~status:(proof,goal as status) ->
let w1 =
debug("qui c'e' gia' l'or "^CicPp.ppterm ty^"\n");
(match ty with
- (* Fix: aspetta mail di Claudio per capire cosa comporta anonimous*)
Cic.Prod (Cic.Anonymous,a,b) -> (Cic.Appl [_not;a])
|_ -> assert false)
in
let r = PrimitiveTactics.change_tac ~what:ty ~with_what:w1 ~status in
debug("fine MY_CHNGE\n");
r
+
)
~continuation:(*PORTINGTacticals.id_tac*)tac2]))
;(*Tacticals.id_tac*)!tac1]);(*end tac:=*)
- tac:=(Tacticals.thens
- ~start:(PrimitiveTactics.cut_tac ~term:_False)
- ~continuations:[Tacticals.then_
- ~start:(PrimitiveTactics.intros_tac ~name:"??")
- ~continuation:contradiction_tac
- ;!tac])
-
|_-> assert false)(*match (!lutil) *)
|_-> assert false); (*match res*)
debug ("finalmente applico tac\n");
- (!tac ~status:(proof,goal))
+ (
+ let r = !tac ~status:(proof,goal) in
+ debug("\n\n]]]]]]]]]]]]]]]]]) That's all folks ([[[[[[[[[[[[[[[[[[[\n\n");r
+
+ )
;;
let fourier_tac ~status:(proof,goal) = fourier ~status:(proof,goal);;