From b3f6fd14aabd748f808f8a5f106297e91564b8a6 Mon Sep 17 00:00:00 2001 From: Andreas Zeller Date: Mon, 6 Jan 2025 15:40:02 +0100 Subject: [PATCH] Fix: no leading zeros in `CALC_GRAMMAR` --- notebooks/Alhazen.ipynb | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/notebooks/Alhazen.ipynb b/notebooks/Alhazen.ipynb index 73644f28..5d981ba3 100644 --- a/notebooks/Alhazen.ipynb +++ b/notebooks/Alhazen.ipynb @@ -138,13 +138,6 @@ "Additional test inputs are generated and executed to refine or refute the hypothesis, eventually obtaining a prediction model of the circumstances of why the behavior in question takes place." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -167,11 +160,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In a nutshell, this is how Alhazen works.\n", + "Let us give a high-level description of how Alhazen works, illustrated above.\n", + "\n", "Alhazen is given an _input grammar_ and a number of _input files_ (whose format is given by the grammar),\n", "and produces a _decision tree_ – a machine learning model that explains under which circumstances the program fails.\n", "\n", - "Alhazen determines and refines these decision trees in five steps, illustrated above.\n", + "Alhazen determines and refines these decision trees in five steps:\n", "\n", "1. For each input file, Alhazen extracts a number of _input features_ that apply.\n", " These input features are predicates over the individual elements of the input grammar, such as ` > 0` (an `` element is larger than zero) or `exists()` (the input contains a minus sign).\n", @@ -277,14 +271,20 @@ " \"\": [\"-\", \"\"],\n", "\n", " \"\":\n", - " [\".\",\n", + " [\".\",\n", " \"\"],\n", "\n", " \"\":\n", - " [\"\", \"\"],\n", + " [\"\", \"\"],\n", + "\n", + " \"\":\n", + " [\"\", \"\"],\n", + "\n", + " \"\": # First digit cannot be zero\n", + " [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"],\n", "\n", " \"\":\n", - " [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n", + " [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"],\n", "}" ] }, @@ -292,14 +292,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We see that the `CALCULATOR` Grammar consists of several production rules. The calculator subject will only accept inputs that conform to this grammar definition." + "We see that the `CALC_GRAMMAR` consists of several production rules. The calculator subject will only accept inputs that conform to this grammar definition." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now, lets load two initial input samples:" + "Now, let us load two initial input samples:\n", + "- `sqrt(-16)`\n", + "- `sqrt(4)`" ] }, { @@ -312,17 +314,6 @@ "initial_sample_list = ['sqrt(-16)', 'sqrt(4)']" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The two initial input samples for our calculator should be:\n", - "- _sqrt(-16)_\n", - "- _sqrt(4)_\n", - "\n", - "Let's check if this is true with python's `assert` function. The condition is True, if no Assertion is thrown." - ] - }, { "cell_type": "markdown", "metadata": {},