-
Notifications
You must be signed in to change notification settings - Fork 2
BuildAllFormulasInterpritations
George Plotnikov edited this page Feb 7, 2022
·
5 revisions
let BuildAllFormulasInterpritations formulaCalcList =
let vars =
formulaCalcList
|> List.filter (function
| Formula.Var (_) -> true
| _ -> false)
let data = List.init vars.Length (fun _ -> [ true; false ])
cartList data
There are only two steps to calculate all possible interpretations for a formula in the propositional logic.
- Filter out all non-variable elements.
- Build a cartesian product for a list length of (1.) with the possible values as a parameter.
P.S. to expand the function for a modal logic the function to retrieve possible combinations for a input set from fun _ -> [ true; false ]
to fun _ -> [ true; semitrue; false; semifalse ]
Input:
[0]: Var "P"
[1]: Var "Q"
[2]: Var "R"
[3]: Var "S"
[4]: Neg (Var "S")
[5]: Conj (Var "P", Var "Q")
[6]: Bic (Var "R", Neg (Var "S"))
[7]: Impl (Conj (Var "P", Var "Q"), Bic (Var ..., ...))
_FullList: {SharpLogic.Formula.Formula[8]}
Output:
[0]: Length = 4
[1]: Length = 4
[2]: Length = 4
[3]: Length = 4
[4]: Length = 4
[5]: Length = 4
[6]: Length = 4
[7]: Length = 4
[8]: Length = 4
[9]: Length = 4
[10]: Length = 4
[11]: Length = 4
[12]: Length = 4
[13]: Length = 4
[14]: Length = 4
[15]: Length = 4
_FullList: {Microsoft.FSharp.Collections.FSharpList<bool>[16]}
each element is
Length = 4
[0]: true
[1]: true
[2]: true
[3]: true
_FullList: {bool[4]}
with all possible combinations according to cartesian product 2^n
let formulaInterpritations = BuildAllFormulasInterpritations formulas
Functions