Created
July 11, 2019 17:10
-
-
Save adolfont/347f86e49f24fd45e1277dac2c528d2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Cpl do | |
| @moduledoc """ | |
| Documentation for Classical Propositional Logoc. | |
| """ | |
| defp arity(connective, language) do | |
| language[:connectives][connective] | |
| end | |
| @spec is_formula(any, any) :: boolean | |
| def is_formula(atom, language) when is_atom(atom) do | |
| atom in language[:atoms] | |
| end | |
| def is_formula([unary_connective, subformula], language) do | |
| arity(unary_connective, language) == 1 and is_formula(subformula, language) | |
| end | |
| def is_formula([left_subformula, binary_connective, right_subformula], language) do | |
| arity(binary_connective, language) == 2 and is_formula(left_subformula, language) and | |
| is_formula(right_subformula, language) | |
| end | |
| def is_formula(_, _), do: false | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment