X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_disambiguation%2Flogic_notation.ml;h=fdbc75bf18ddf990326a18893f27bcf3bc9d5610;hb=45586ab88c026e6a21927654387b6df266a44700;hp=f23098f9688764a3083447f2cd91959fa56f1979;hpb=aba014724c9ad08f80944ec3021c9fa3826dca4a;p=helm.git diff --git a/helm/ocaml/cic_disambiguation/logic_notation.ml b/helm/ocaml/cic_disambiguation/logic_notation.ml index f23098f96..fdbc75bf1 100644 --- a/helm/ocaml/cic_disambiguation/logic_notation.ml +++ b/helm/ocaml/cic_disambiguation/logic_notation.ml @@ -23,24 +23,65 @@ * http://helm.cs.unibo.it/ *) -open Ast -open Parser +open CicTextualParser2 EXTEND term: LEVEL "add" [ - [ t1 = term; SYMBOL "∨"; t2 = term -> - return_term loc (Appl_symbol ("or", [t1; t2])) + [ t1 = term; SYMBOL <:unicode> (* ∨ *); t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("or", 0); t1; t2]) ] ]; term: LEVEL "mult" [ - [ t1 = term; SYMBOL "∧"; t2 = term -> - return_term loc (Appl_symbol ("and", [t1; t2])) + [ t1 = term; SYMBOL <:unicode> (* ∧ *); t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("and", 0); t1; t2]) ] ]; term: LEVEL "inv" [ - [ SYMBOL "¬"; t = term -> return_term loc (Appl_symbol ("not", [t])) ] + [ SYMBOL <:unicode> (* ¬ *); t = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("not", 0); t]) + ] ]; END + +(* TODO a lot of hard coded URIs, move them in HelmLibraryObjects *) + +let _ = + (* TODO cut-and-pasted code: here, in arit_notation.ml and + * disambiguateChoices.ml *) + let uri s = UriManager.uri_of_string s in + let const s = Cic.Const (uri s, []) in + let mutind s = Cic.MutInd (uri s, 0, []) in + DisambiguateChoices.add_symbol_choice "eq" + ("leibnitz's equality", + (fun interp _ args -> + let t1, t2 = + match args with + | [t1; t2] -> t1, t2 + | _ -> raise DisambiguateChoices.Invalid_choice + in + Cic.Appl [ + Cic.MutInd (HelmLibraryObjects.Logic.eq_URI, 0, []); + Cic.Implicit (Some `Type); t1; t2 + ])); + DisambiguateChoices.add_symbol_choice "eq" + ("equality over objects with sort Type", + (fun interp _ args -> + let t1, t2 = + match args with + | [t1; t2] -> t1, t2 + | _ -> raise DisambiguateChoices.Invalid_choice + in + Cic.Appl [ + Cic.MutInd (HelmLibraryObjects.Logic_Type.eqt_URI, 0, []); + Cic.Implicit (Some `Type); t1; t2 + ])); + DisambiguateChoices.add_binary_op "and" "logical and" + (mutind "cic:/Coq/Init/Logic/and.ind"); + DisambiguateChoices.add_binary_op "or" "logical or" + (mutind "cic:/Coq/Init/Logic/or.ind"); + DisambiguateChoices.add_unary_op "not" "logical not" + (const "cic:/Coq/Init/Logic/not.con"); +