package lambda

  1. Overview
  2. Docs

Source file bool.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
open L;;

exception NotABoolTerm;;

let ltrue = Abs("x",Abs("y",Var "x"));; 
let lfalse = Abs("x",Abs("y",Var "y"));;

let of_bool b = match b with
| true -> ltrue
| false -> lfalse
;;

let to_bool t =
  match t with 
  | Abs("x", Abs("y", Var "x")) -> true
  | Abs("x", Abs("y", Var "y")) -> false
  | _ -> raise NotABoolTerm
;;

let is_bool t = try to_bool t |> ignore; true with _ -> false;;