Skip to content

Commit bc32846

Browse files
committed
lean4: Handle setminus natively
1 parent e692275 commit bc32846

2 files changed

Lines changed: 1863 additions & 1311 deletions

File tree

spectec/backend-lean4/print.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let iter_exp_opt_funcs = ["Option.map"; "option_zipWith"; "option_map3"]
99
let error at msg = Util.Error.error at "Lean4 translation" msg
1010

1111
(* List of declaration ids that are hand-coded in the preamble *)
12-
let builtins = [ "disjoint_" ]
12+
let builtins = [ "disjoint_"; "setminus1_"; "setminus_" ]
1313

1414
let rec list_split (f : 'a -> bool) = function
1515
| [] -> ([], [])
@@ -744,6 +744,10 @@ macro "opaqueDef" : term => `(by first | exact Inhabited.default | intros; assum
744744
def disjoint_ (X : Type) [BEq X] : ∀ (var_0 : (List X)), Bool
745745
| [] => true
746746
| (w :: w'_lst) => ((!(List.contains w'_lst w)) && (disjoint_ X w'_lst))
747+
748+
/- written manually due to `BEq` constraint -/
749+
def setminus_ (X : Type) [BEq X] (l1 l2 : List X) : List X :=
750+
l1.filter (fun x => !(List.contains l2 x))
747751
|}
748752

749753

0 commit comments

Comments
 (0)