Skip to content

CalcFormula

George Plotnikov edited this page Feb 7, 2022 · 2 revisions
let CalcFormula formula =
    | match formula with
    | Conj(Const(X), Const(Y)) -> X && Y
    | Disj(Const(X), Const(Y)) -> X || Y
    | Neg(Const(X)) -> not X
    | Bic(Const(X), Const(Y)) -> X = Y
    | Impl(Const(X), Const(Y)) ->
        match (X, Y) with
        | (true, true) -> true
        | (true, false) -> false
        | (false, true) -> true
        | (false, false) -> true
    | _ -> false

This function performs the basic boolean calculation for trivial functions: Conjunction, Disjunction, Negation, Bicondition, Implication. It works with constants and is the intermediate level between libraries types and boolean operations over them.

Example

Input:

Bic(Const(true), Const(false))
Bic(Const(true), Const(true))

Output:

false
true

Usage

let calc = CalcFormula(Bic(Const(true), Const(false)))

Clone this wiki locally