-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from Deducteam/acu-merge
- Loading branch information
Showing
59 changed files
with
3,551 additions
and
909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ struct | |
let rs = E.add_rules rs in | ||
List.iter (fun (s,r) -> | ||
Debug.debug Debug.d_notice "%[email protected] the following constraints: %a" | ||
pp_typed_rule r (Subst.Subst.pp (fun n -> let _,n,_ = List.nth r.ctx n in n)) s) rs | ||
pp_typed_rule r (Exsubst.ExSubst.pp (fun n -> let _,n,_ = List.nth r.ctx n in n)) s) rs | ||
| Eval(_,red,te) -> | ||
let te = E.reduction ~red te in | ||
Format.printf "%a@." Printer.print_term te | ||
|
@@ -84,7 +84,7 @@ struct | |
Signature.add_external_declaration sg lc (Basic.mk_name md id) scope st ty | ||
| Def(lc,id,scope,_,Some ty,te) -> | ||
let open Rule in | ||
Signature.add_external_declaration sg lc (Basic.mk_name md id) scope Signature.Definable ty; | ||
Signature.add_external_declaration sg lc (Basic.mk_name md id) scope (Signature.Definable Term.Free) ty; | ||
let cst = Basic.mk_name md id in | ||
let rule = { name= Delta(cst) ; ctx = [] ; pat = Pattern(lc, cst, []); rhs = te ; } in | ||
Signature.add_rules sg [Rule.to_rule_infos rule] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
open Basic | ||
open Term | ||
|
||
(* AC identifier (name and algebra). *) | ||
|
||
type ac_ident = name * algebra | ||
|
||
let ac_ident_eq (name,_) (name',_) = name_eq name name' | ||
|
||
let pp_ac_ident fmt (name,_) = Format.fprintf fmt "%a" pp_name name | ||
|
||
(* AC functions *) | ||
|
||
let get_AC_args name = function | ||
| App( Const (_,name'), a1, [a2]) when name_eq name name' -> Some (a1, a2) | ||
| _ -> None | ||
|
||
(* Reduces subterms with f to have a maximal set of elements. *) | ||
let force_flatten_AC_terms | ||
(snf:term -> term) | ||
(are_convertible:term -> term -> bool) | ||
(name,aci) terms = | ||
let rec aux acc = function | ||
| [] -> acc | ||
| hd :: tl -> | ||
match get_AC_args name hd with | ||
| Some (a1,a2) -> aux acc (a1 :: a2 :: tl) | ||
| None -> | ||
let snfhd = snf hd in | ||
match get_AC_args name snfhd with | ||
| Some (a1,a2) -> aux acc (a1 :: a2 :: tl) | ||
| None -> aux (snfhd :: acc) tl in | ||
let res = aux [] terms in | ||
(* If aci is an ACU symbol, remove corresponding neutral element. *) | ||
match aci with | ||
| ACU neu -> List.filter (fun x -> not (are_convertible neu x)) res | ||
| _ -> res | ||
|
||
|
||
(* Reduces subterms with f to have a maximal set of elements. *) | ||
let force_flatten_AC_term | ||
(snf:term -> term) | ||
(are_convertible:term -> term -> bool) | ||
aci t = force_flatten_AC_terms snf are_convertible aci [t] | ||
|
||
let flatten_AC_terms name = | ||
let rec aux acc = function | ||
| [] -> acc | ||
| hd :: tl -> | ||
match get_AC_args name hd with | ||
| Some (a1,a2) -> aux acc (a1 :: a2 :: tl) | ||
| None -> aux (hd :: acc) tl in | ||
aux [] | ||
|
||
let flatten_AC_term name t = flatten_AC_terms name [t] | ||
|
||
let rec unflatten_AC (name,alg) = function | ||
| [] -> ( match alg with ACU neu -> neu | _ -> assert false ) | ||
| [t] -> t | ||
| t1 :: t2 :: tl -> | ||
unflatten_AC (name,alg) ((mk_App (mk_Const dloc name) t1 [t2]) :: tl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
open Basic | ||
open Term | ||
|
||
type ac_ident = name * algebra | ||
|
||
val ac_ident_eq : ac_ident -> ac_ident -> bool | ||
|
||
val pp_ac_ident : ac_ident printer | ||
|
||
val force_flatten_AC_term : | ||
(term -> term) -> | ||
(term -> term -> bool) -> | ||
ac_ident -> term -> term list | ||
(** [force_flatten_AC_term snf are_convertible aci t] | ||
returns the list [t1 ; ... ; tn] where | ||
[t] is convertible with [t1 + ... + tn] and | ||
[aci] represents the AC(U) operator [+] while | ||
[whnf] is used to reduce to head normal form to check for [+] symbol | ||
at the head. All [ti] are reduced with [whnf]. | ||
[are_convertible] checks convertibility to neutral element if needed. | ||
*) | ||
|
||
val flatten_AC_terms : name -> term list -> term list | ||
|
||
val flatten_AC_term : name -> term -> term list | ||
|
||
val unflatten_AC : ac_ident -> term list -> term |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.